` element reference\r\n */\r\n Label.prototype.getHTMLLineElement = function (text) {\r\n // Create the
element\r\n var div = document.createElement(\"div\");\r\n div.innerHTML = text;\r\n // Set text alignment\r\n switch (this.textAlign) {\r\n case \"middle\":\r\n div.style.textAlign = \"center\";\r\n break;\r\n case \"end\":\r\n div.style.textAlign = \"right\";\r\n break;\r\n }\r\n // Disable or enable wrapping\r\n if (this.wrap) {\r\n div.style.wordWrap = \"break-word\";\r\n }\r\n else {\r\n div.style.whiteSpace = \"nowrap\";\r\n }\r\n // Don't let labels bleed out of the alotted area\r\n // Moved to `draw()` because setting \"hidden\" kills all measuring\r\n /*if (this.truncate) {\r\n div.style.overflow = \"hidden\";\r\n }*/\r\n // Set RTL-related styles\r\n if (this.rtl) {\r\n div.style.direction = \"rtl\";\r\n //div.style.unicodeBidi = \"bidi-override\";\r\n }\r\n // Translate some of the SVG styles into CSS\r\n if ($type.hasValue(this.fill)) {\r\n div.style.color = this.fill.toString();\r\n }\r\n return div;\r\n };\r\n /**\r\n * Applies specific styles to text to make it not selectable, unless it is\r\n * explicitly set as `selectable`.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Set styles via AMElement\r\n */\r\n Label.prototype.setStyles = function () {\r\n var group = this.element;\r\n if (!this.selectable || this.draggable || this.resizable || this.swipeable) {\r\n group.addStyle({\r\n \"webkitUserSelect\": \"none\",\r\n \"msUserSelect\": \"none\"\r\n });\r\n }\r\n else if (this.selectable) {\r\n group.removeStyle(\"webkitUserSelect\");\r\n group.removeStyle(\"msUserSelect\");\r\n }\r\n };\r\n /**\r\n * Hides unused lines\r\n */\r\n Label.prototype.hideUnused = function (index) {\r\n this.initLineCache();\r\n var lines = this.getCache(\"lineInfo\");\r\n if (lines.length >= index) {\r\n for (var i = index; i < lines.length; i++) {\r\n var line = lines[i];\r\n if (line && line.element) {\r\n line.element.attr({ \"display\": \"none\" });\r\n }\r\n }\r\n }\r\n };\r\n Object.defineProperty(Label.prototype, \"text\", {\r\n /**\r\n * @return SVG text\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"text\");\r\n },\r\n /**\r\n * An SVG text.\r\n *\r\n * Please note that setting `html` will override this setting if browser\r\n * supports `foreignObject` in SGV, such as most modern browsers excluding\r\n * IEs.\r\n *\r\n * @param value SVG Text\r\n */\r\n set: function (value) {\r\n //this.setPropertyValue(\"html\", undefined);\r\n this.setPropertyValue(\"text\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Label.prototype, \"path\", {\r\n /**\r\n * @return Path\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"path\");\r\n },\r\n /**\r\n * An SVG path string to position text along. If set, the text will follow\r\n * the curvature of the path.\r\n *\r\n * Location along the path can be set using `locationOnPath`.\r\n *\r\n * IMPORTANT: Only SVG text can be put on path. If you are using HTML text\r\n * this setting will be ignored.\r\n *\r\n * @since 4.1.2\r\n * @param value Path\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"path\", value, true)) {\r\n if (this.pathElement) {\r\n this.pathElement.dispose();\r\n }\r\n if (this.textPathElement) {\r\n this.textPathElement.dispose();\r\n }\r\n this.pathElement = this.paper.add(\"path\");\r\n this.pathElement.attr({ \"d\": value });\r\n this.pathElement.attr({ \"id\": \"text-path-\" + this.uid });\r\n this._disposers.push(this.pathElement);\r\n this.textPathElement = this.paper.addGroup(\"textPath\");\r\n this.textPathElement.attrNS($dom.XLINK, \"xlink:href\", \"#text-path-\" + this.uid);\r\n // TODO remove after https://bugzilla.mozilla.org/show_bug.cgi?id=455986 is fixed\r\n this.textPathElement.attr({ \"path\": value });\r\n this._disposers.push(this.textPathElement);\r\n this.hardInvalidate();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Label.prototype, \"locationOnPath\", {\r\n /**\r\n * @return Relatvie location on path\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"locationOnPath\");\r\n },\r\n /**\r\n * Relative label location on `path`. Value range is from 0 (beginning)\r\n * to 1 (end).\r\n *\r\n * Works only if you set `path` setting to an SVG path.\r\n *\r\n * @since 4.1.2\r\n * @default 0\r\n * @param value Relatvie location on path\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"locationOnPath\", value);\r\n if (this.textPathElement) {\r\n this.textPathElement.attr({ \"startOffset\": (value * 100) + \"%\" });\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Label.prototype, \"baseLineRatio\", {\r\n /**\r\n * @return Base line ratio\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"baseLineRatio\");\r\n },\r\n /**\r\n * A ratio to calculate text baseline. Ralative distance from the bottom of\r\n * the label.\r\n *\r\n * @since 4.4.2\r\n * @default -0.27\r\n * @param value Base line ratio\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"baseLineRatio\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Label.prototype, \"wrap\", {\r\n /**\r\n * @return Auto-wrap enabled or not\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"wrap\");\r\n },\r\n /**\r\n * Enables or disables autowrapping of text.\r\n *\r\n * @param value Auto-wrapping enabled\r\n */\r\n set: function (value) {\r\n this.resetBBox();\r\n this.setPropertyValue(\"wrap\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Label.prototype, \"truncate\", {\r\n /**\r\n * @return Truncate text?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"truncate\");\r\n },\r\n /**\r\n * Indicates if text lines need to be truncated if they do not fit, using\r\n * configurable `ellipsis` string.\r\n *\r\n * `truncate` overrides `wrap` if both are set to `true`.\r\n *\r\n * NOTE: For HTML text, this setting **won't** trigger a parser and actual\r\n * line truncation with ellipsis. It will just hide everything that goes\r\n * outside the label.\r\n *\r\n * @param value trincate text?\r\n */\r\n set: function (value) {\r\n this.resetBBox();\r\n this.setPropertyValue(\"truncate\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Label.prototype, \"fullWords\", {\r\n /**\r\n * @return Truncate on full words?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"fullWords\");\r\n },\r\n /**\r\n * If `truncate` is enabled, should Label try to break only on full words\r\n * (`true`), or whenever needed, including middle of the word. (`false`)\r\n *\r\n * @default true\r\n * @param value Truncate on full words?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"fullWords\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Label.prototype, \"ellipsis\", {\r\n /**\r\n * @return Ellipsis string\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"ellipsis\");\r\n },\r\n /**\r\n * Ellipsis character to use if `truncate` is enabled.\r\n *\r\n * @param value Ellipsis string\r\n * @default \"...\"\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"ellipsis\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Label.prototype, \"selectable\", {\r\n /**\r\n * @return Text selectable?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"selectable\");\r\n },\r\n /**\r\n * Forces the text to be selectable. This setting will be ignored if the\r\n * object has some kind of interaction attached to it, such as it is\r\n * `draggable`, `swipeable`, `resizable`.\r\n *\r\n * @param value Text selectable?\r\n * @default false\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"selectable\", value, true);\r\n this.setStyles();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Label.prototype, \"textAlign\", {\r\n /**\r\n * @return Alignment\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"textAlign\");\r\n },\r\n /**\r\n * Horizontal text alignment.\r\n *\r\n * Available choices:\r\n * * \"start\"\r\n * * \"middle\"\r\n * * \"end\"\r\n *\r\n * @param value Alignment\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"textAlign\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Label.prototype, \"textValign\", {\r\n /**\r\n * @ignore Exclude from docs (not used)\r\n * @return Alignment\r\n * @deprecated\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"textValign\");\r\n },\r\n /**\r\n * Vertical text alignment.\r\n *\r\n * @ignore Exclude from docs (not used)\r\n * @param value Alignment\r\n * @deprecated\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"textValign\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Label.prototype, \"html\", {\r\n /**\r\n * @return HTML content\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"html\");\r\n },\r\n /**\r\n * Raw HTML to be used as text.\r\n *\r\n * NOTE: HTML text is subject to browser support. It relies on browsers\r\n * supporting SVG `foreignObject` nodes. Some browsers (read IEs) do not\r\n * support it. On those browsers, the text will fall back to basic SVG text,\r\n * striping out all HTML markup and styling that goes with it.\r\n *\r\n * For more information about `foreignObject` and its browser compatibility\r\n * refer to [this page](https://developer.mozilla.org/en/docs/Web/SVG/Element/foreignObject#Browser_compatibility).\r\n *\r\n * @param value HTML text\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"html\", value, true);\r\n if (!$type.hasValue(value)) {\r\n var group = this.element;\r\n group.removeChildrenByTag(\"foreignObject\");\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Label.prototype.setFill = function (value) {\r\n _super.prototype.setFill.call(this, value);\r\n if (this.html) {\r\n var group = this.element;\r\n var divs = group.node.getElementsByTagName(\"div\");\r\n for (var i = 0; i < divs.length; i++) {\r\n var div = divs[i];\r\n if ($type.hasValue(this.fill)) {\r\n div.style.color = this.fill.toString();\r\n }\r\n }\r\n }\r\n };\r\n Object.defineProperty(Label.prototype, \"hideOversized\", {\r\n /**\r\n * @return Hide if text does not fit?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"hideOversized\");\r\n },\r\n /**\r\n * Indicates whether the whole text should be hidden if it does not fit into\r\n * its allotted space.\r\n *\r\n * @param value Hide if text does not fit?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"hideOversized\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Label.prototype, \"ignoreFormatting\", {\r\n /**\r\n * @return Ignore formatting?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"ignoreFormatting\");\r\n },\r\n /**\r\n * If set to `true` square-bracket formatting blocks will be treated as\r\n * regular text.\r\n *\r\n * @default false\r\n * @param value Ignore formatting?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"ignoreFormatting\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Override `mesaureElement` so it does not get measure again, because\r\n * internal `_bbox` is being updated by measuring routines in Text itself.\r\n */\r\n Label.prototype.measureElement = function () { };\r\n /**\r\n * Returns information about a line element.\r\n *\r\n * @ignore Exclude from docs\r\n * @param index Line index\r\n * @return Line info object\r\n */\r\n Label.prototype.getLineInfo = function (index) {\r\n this.initLineCache();\r\n var lines = this.getCache(\"lineInfo\");\r\n return lines.length > index ? lines[index] : undefined;\r\n };\r\n /**\r\n * Adds a line to line info cache.\r\n *\r\n * @ignore Exclude from docs\r\n * @param line Line info object\r\n * @param index Insert at specified index\r\n */\r\n Label.prototype.addLineInfo = function (line, index) {\r\n this.initLineCache();\r\n this.getCache(\"lineInfo\")[index] = line;\r\n };\r\n /**\r\n * Checks if line cache is initialized and initializes it.\r\n */\r\n Label.prototype.initLineCache = function () {\r\n if (!$type.hasValue(this.getCache(\"lineInfo\"))) {\r\n this.setCache(\"lineInfo\", [], 0);\r\n }\r\n };\r\n /**\r\n * Sets a [[DataItem]] to use for populating dynamic sections of the text.\r\n *\r\n * Check the description for [[Text]] class, for data binding.\r\n *\r\n * @param dataItem Data item\r\n */\r\n Label.prototype.setDataItem = function (dataItem) {\r\n if (this._sourceDataItemEvents) {\r\n this._sourceDataItemEvents.dispose();\r\n }\r\n if (dataItem) {\r\n this._sourceDataItemEvents = new MultiDisposer([\r\n dataItem.events.on(\"valuechanged\", this.invalidate, this, false),\r\n dataItem.events.on(\"workingvaluechanged\", this.invalidate, this, false),\r\n dataItem.events.on(\"calculatedvaluechanged\", this.invalidate, this, false),\r\n dataItem.events.on(\"propertychanged\", this.invalidate, this, false)\r\n ]);\r\n }\r\n _super.prototype.setDataItem.call(this, dataItem);\r\n };\r\n Object.defineProperty(Label.prototype, \"availableWidth\", {\r\n /**\r\n * Returns available horizontal space.\r\n *\r\n * @ignore Exclude from docs\r\n * @return Available width (px)\r\n */\r\n get: function () {\r\n return $type.hasValue(this.maxWidth) ? this.maxWidth : this.pixelWidth;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Label.prototype, \"availableHeight\", {\r\n /**\r\n * Returns available vertical space.\r\n *\r\n * @return Available height (px)\r\n */\r\n get: function () {\r\n return $type.hasValue(this.maxHeight) ? this.maxHeight : this.pixelHeight;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n // temp, replacing textFormatter method\r\n Label.prototype.getSvgElement = function (text, style, parent) {\r\n var element = this.paper.add(\"tspan\");\r\n element.textContent = text;\r\n if (style) {\r\n if (options.nonce && parent) {\r\n //element.node.setAttribute(\"nonce\", \"test123\");\r\n var classid = \"amcharts_element_style_\" + btoa(style).replace(/[^\\w]*/g, \"\");\r\n element.node.setAttribute(\"class\", classid);\r\n var defs = document.createElementNS($dom.SVGNS, \"defs\");\r\n parent.node.appendChild(defs);\r\n var e = document.createElement(\"style\");\r\n e.type = \"text/css\";\r\n e.innerHTML = \".\" + classid + \" { \" + style + \"}\";\r\n e.setAttribute(\"nonce\", options.nonce);\r\n defs.appendChild(e);\r\n }\r\n else {\r\n element.node.setAttribute(\"style\", style);\r\n }\r\n }\r\n if (parent) {\r\n parent.add(element);\r\n }\r\n return element;\r\n };\r\n /**\r\n * Invalidates the whole element, including layout AND all its child\r\n * elements.\r\n */\r\n Label.prototype.deepInvalidate = function () {\r\n _super.prototype.deepInvalidate.call(this);\r\n this.hardInvalidate();\r\n };\r\n Object.defineProperty(Label.prototype, \"readerTitle\", {\r\n /**\r\n * @return Title\r\n */\r\n get: function () {\r\n var title = this.getPropertyValue(\"readerTitle\");\r\n if (!title) {\r\n title = this.populateString($utils.plainText($utils.isNotEmpty(this.html)\r\n ? this.html\r\n : this.text));\r\n }\r\n else if (this.dataItem) {\r\n title = this.populateString(title);\r\n }\r\n return title;\r\n },\r\n /**\r\n * Screen reader title of the element.\r\n *\r\n * @param value Title\r\n */\r\n set: function (value) {\r\n value = $type.toText(value);\r\n if (this.setPropertyValue(\"readerTitle\", value)) {\r\n this.applyAccessibility();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Label;\r\n}(Container));\r\nexport { Label };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Label\"] = Label;\r\n/**\r\n * Add default responsive rules\r\n */\r\n/**\r\n * Hide labels added directly to chart, like titles if chart is short.\r\n */\r\ndefaultRules.push({\r\n relevant: ResponsiveBreakpoints.heightXS,\r\n state: function (target, stateId) {\r\n if (target instanceof Label && target.parent && target.parent.isBaseSprite) {\r\n var state = target.states.create(stateId);\r\n state.properties.disabled = true;\r\n return state;\r\n }\r\n return null;\r\n }\r\n});\r\n//# sourceMappingURL=Label.js.map","/**\r\n * Rounded rectangle module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Sprite } from \"../Sprite\";\r\nimport { registry } from \"../Registry\";\r\nimport * as $math from \"../utils/Math\";\r\nimport * as $type from \"../utils/Type\";\r\nimport * as $utils from \"../utils/Utils\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Draws a rectangle with rounded corners.\r\n *\r\n * @see {@link IRoundedRectangleEvents} for a list of available events\r\n * @see {@link IRoundedRectangleAdapters} for a list of available Adapters\r\n */\r\nvar RoundedRectangle = /** @class */ (function (_super) {\r\n __extends(RoundedRectangle, _super);\r\n /**\r\n * Constructor\r\n */\r\n function RoundedRectangle() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"RoundedRectangle\";\r\n _this.element = _this.paper.add(\"path\");\r\n _this.cornerRadius(3, 3, 3, 3);\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Draws the element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n RoundedRectangle.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n var w = this.innerWidth;\r\n var h = this.innerHeight;\r\n if ($type.isNumber(w) && $type.isNumber(h)) {\r\n var minSide = $math.min(w, h) / 2;\r\n var cornerRadiusTopLeft = $utils.relativeToValue(this.cornerRadiusTopLeft, minSide);\r\n var cornerRadiusTopRight = $utils.relativeToValue(this.cornerRadiusTopRight, minSide);\r\n var cornerRadiusBottomRight = $utils.relativeToValue(this.cornerRadiusBottomRight, minSide);\r\n var cornerRadiusBottomLeft = $utils.relativeToValue(this.cornerRadiusBottomLeft, minSide);\r\n var maxcr = $math.min(Math.abs(w / 2), Math.abs(h / 2));\r\n var crtl = $math.fitToRange(cornerRadiusTopLeft, 0, maxcr);\r\n var crtr = $math.fitToRange(cornerRadiusTopRight, 0, maxcr);\r\n var crbr = $math.fitToRange(cornerRadiusBottomRight, 0, maxcr);\r\n var crbl = $math.fitToRange(cornerRadiusBottomLeft, 0, maxcr);\r\n var lineT = \"M\" + crtl + \",0 L\" + (w - crtr) + \",0\";\r\n var lineB = \" L\" + crbl + \",\" + h;\r\n var lineL = \" L0,\" + crtl;\r\n var lineR = \" L\" + w + \",\" + (h - crbr);\r\n var arcTR = \" a\" + crtr + \",\" + crtr + \" 0 0 1 \" + crtr + \",\" + crtr;\r\n var arcBR = \" a\" + crbr + \",\" + crbr + \" 0 0 1 -\" + crbr + \",\" + crbr;\r\n var arcBL = \" a\" + crbl + \",\" + crbl + \" 0 0 1 -\" + crbl + \",-\" + crbl;\r\n var arcTL = \" a\" + crtl + \",\" + crtl + \" 0 0 1 \" + crtl + \",-\" + crtl;\r\n var path = lineT + arcTR + lineR + arcBR + lineB + arcBL + lineL + arcTL + \" Z\";\r\n this.path = path;\r\n }\r\n };\r\n /**\r\n * Sets radius for all four corners at ones.\r\n *\r\n * All numbers are in pixels.\r\n *\r\n * @param tl Top-left corner\r\n * @param tr Top-right corner\r\n * @param bl Bottom-left corner\r\n * @param br Bottom-right corner\r\n */\r\n RoundedRectangle.prototype.cornerRadius = function (tl, tr, bl, br) {\r\n this.cornerRadiusTopLeft = tl;\r\n this.cornerRadiusTopRight = tr;\r\n this.cornerRadiusBottomLeft = bl;\r\n this.cornerRadiusBottomRight = br;\r\n };\r\n Object.defineProperty(RoundedRectangle.prototype, \"cornerRadiusTopLeft\", {\r\n /**\r\n * @return Radius (px or Percent)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"cornerRadiusTopLeft\");\r\n },\r\n /**\r\n * Radius of the top-left corner in pixels.\r\n *\r\n * @default 3\r\n * @param value Radius (px or Percent)\r\n */\r\n set: function (value) {\r\n this.setPercentProperty(\"cornerRadiusTopLeft\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(RoundedRectangle.prototype, \"cornerRadiusTopRight\", {\r\n /**\r\n * @return Radius (px or Percent)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"cornerRadiusTopRight\");\r\n },\r\n /**\r\n * Radius of the top-right corner in pixels.\r\n *\r\n * @default 3\r\n * @param value Radius (px or Percent)\r\n */\r\n set: function (value) {\r\n this.setPercentProperty(\"cornerRadiusTopRight\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(RoundedRectangle.prototype, \"cornerRadiusBottomRight\", {\r\n /**\r\n * @return Radius (px or Percent)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"cornerRadiusBottomRight\");\r\n },\r\n /**\r\n * Radius of the bottom-right corner in pixels.\r\n *\r\n * @default 3\r\n * @param value Radius (px or Percent)\r\n */\r\n set: function (value) {\r\n this.setPercentProperty(\"cornerRadiusBottomRight\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(RoundedRectangle.prototype, \"cornerRadiusBottomLeft\", {\r\n /**\r\n * @return Radius (px or Percent)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"cornerRadiusBottomLeft\");\r\n },\r\n /**\r\n * Radius of the bottom-left corner in pixels.\r\n *\r\n * @default 3\r\n * @param value Radius (px or Percent)\r\n */\r\n set: function (value) {\r\n this.setPercentProperty(\"cornerRadiusBottomLeft\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Measures the element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n RoundedRectangle.prototype.measureElement = function () {\r\n };\r\n Object.defineProperty(RoundedRectangle.prototype, \"bbox\", {\r\n /**\r\n * Returns bounding box (square) for this element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n get: function () {\r\n if (this.definedBBox) {\r\n return this.definedBBox;\r\n }\r\n if (this.isMeasured) {\r\n return {\r\n x: 0,\r\n y: 0,\r\n width: this.innerWidth,\r\n height: this.innerHeight\r\n };\r\n }\r\n else {\r\n return { x: 0, y: 0, width: 0, height: 0 };\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return RoundedRectangle;\r\n}(Sprite));\r\nexport { RoundedRectangle };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"RoundedRectangle\"] = RoundedRectangle;\r\n//# sourceMappingURL=RoundedRectangle.js.map","/**\r\n * Functionality for drawing simple buttons.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../Container\";\r\nimport { Label } from \"./Label\";\r\nimport { RoundedRectangle } from \"../elements/RoundedRectangle\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport { registry } from \"../Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Button class is capable of drawing a simple rectangular button with\r\n * optionally rounded corners and an icon in it.\r\n *\r\n * @see {@link IButtonEvents} for a list of available events\r\n * @see {@link IButtonAdapters} for a list of available Adapters\r\n */\r\nvar Button = /** @class */ (function (_super) {\r\n __extends(Button, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Button() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"Button\";\r\n _this.tooltipY = 0;\r\n // Set defaults\r\n _this.iconPosition = \"left\";\r\n _this.layout = \"horizontal\";\r\n _this.contentAlign = \"center\";\r\n _this.contentValign = \"middle\";\r\n _this.padding(8, 16, 8, 16);\r\n _this.setStateOnChildren = true;\r\n var interfaceColors = new InterfaceColorSet();\r\n // Create background\r\n var background = _this.background;\r\n background.fill = interfaceColors.getFor(\"secondaryButton\");\r\n background.stroke = interfaceColors.getFor(\"secondaryButtonStroke\");\r\n background.fillOpacity = 1;\r\n background.strokeOpacity = 1;\r\n background.cornerRadius(3, 3, 3, 3);\r\n // Create the label element\r\n _this.label = new Label();\r\n _this.label.fill = interfaceColors.getFor(\"secondaryButtonText\");\r\n ;\r\n _this.label.shouldClone = false;\r\n // Create default states\r\n var hoverState = background.states.create(\"hover\");\r\n hoverState.properties.fillOpacity = 1;\r\n hoverState.properties.fill = interfaceColors.getFor(\"secondaryButtonHover\");\r\n var downState = background.states.create(\"down\");\r\n downState.transitionDuration = 100;\r\n downState.properties.fill = interfaceColors.getFor(\"secondaryButtonDown\");\r\n downState.properties.fillOpacity = 1;\r\n // Set up accessibility\r\n // A button should be always focusable\r\n _this.role = \"button\";\r\n _this.focusable = true;\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(Button.prototype, \"icon\", {\r\n /**\r\n * @return Icon Sprite\r\n */\r\n get: function () {\r\n return this._icon;\r\n },\r\n /**\r\n * A [[Sprite]] to be used as an icon on button.\r\n *\r\n * @param icon Icon Sprite\r\n */\r\n set: function (icon) {\r\n var currentIcon = this._icon;\r\n if (currentIcon) {\r\n //this._icon.dispose();\r\n //this.removeDispose(currentIcon);\r\n currentIcon.parent = undefined;\r\n }\r\n if (icon) {\r\n this._icon = icon;\r\n icon.parent = this;\r\n icon.interactionsEnabled = false;\r\n icon.shouldClone = false;\r\n this.iconPosition = this.iconPosition;\r\n this._disposers.push(icon);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Button.prototype, \"iconPosition\", {\r\n /**\r\n * @return Icon position\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"iconPosition\");\r\n },\r\n /**\r\n * Icon position: \"left\" or \"right\".\r\n *\r\n * @default \"left\"\r\n * @param position Icon position\r\n */\r\n set: function (position) {\r\n this.setPropertyValue(\"iconPosition\", position);\r\n if (this.icon) {\r\n if (position == \"left\") {\r\n this.icon.toBack();\r\n }\r\n else {\r\n this.icon.toFront();\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Button.prototype, \"label\", {\r\n /**\r\n * @return Label element\r\n */\r\n get: function () {\r\n return this._label;\r\n },\r\n /**\r\n * [[Label]] element to be used for text.\r\n *\r\n * @param label element\r\n */\r\n set: function (label) {\r\n if (this._label) {\r\n //this._label.dispose();\r\n this.removeDispose(this._label);\r\n }\r\n this._label = label;\r\n if (label) {\r\n label.parent = this;\r\n label.interactionsEnabled = false;\r\n this._disposers.push(this._label);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Creates a background element for the button.\r\n *\r\n * @ignore Exclude from docs\r\n * @return Background element\r\n */\r\n Button.prototype.createBackground = function () {\r\n return new RoundedRectangle();\r\n };\r\n /**\r\n * Copies properties and other attributes.\r\n *\r\n * @param source Source\r\n */\r\n Button.prototype.copyFrom = function (source) {\r\n _super.prototype.copyFrom.call(this, source);\r\n if (source.label) {\r\n this.label.copyFrom(source.label);\r\n }\r\n if (source.icon) {\r\n this.icon = source.icon.clone();\r\n }\r\n };\r\n return Button;\r\n}(Container));\r\nexport { Button };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Button\"] = Button;\r\n//# sourceMappingURL=Button.js.map","/**\r\n * Functionality for drawing circles.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Sprite } from \"../Sprite\";\r\nimport { percent } from \"../utils/Percent\";\r\nimport { registry } from \"../Registry\";\r\nimport * as $utils from \"../utils/Utils\";\r\nimport * as $math from \"../utils/Math\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Used to create a circle\r\n * @see {@link ICircleEvents} for a list of available events\r\n * @see {@link ICircleAdapters} for a list of available Adapters\r\n */\r\nvar Circle = /** @class */ (function (_super) {\r\n __extends(Circle, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Circle() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"Circle\";\r\n _this.element = _this.paper.add(\"circle\");\r\n _this.setPercentProperty(\"radius\", percent(100));\r\n _this.setPropertyValue(\"horizontalCenter\", \"middle\");\r\n _this.setPropertyValue(\"verticalCenter\", \"middle\");\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Draws the circle.\r\n */\r\n Circle.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n this.element.attr({ \"r\": this.pixelRadius });\r\n };\r\n Object.defineProperty(Circle.prototype, \"radius\", {\r\n /**\r\n * @return Radius\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"radius\");\r\n },\r\n /**\r\n * Radius of the circle.\r\n *\r\n * Can be either absolute (pixels) or relative ([Percent]).\r\n *\r\n * @param value Radius\r\n */\r\n set: function (value) {\r\n this.setPercentProperty(\"radius\", value, true, false, 10, false);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Circle.prototype, \"pixelRadius\", {\r\n /**\r\n * Radius of the circle in pixels.\r\n *\r\n * This is a read-only property. To set radius in pixels, use `radius`\r\n * property.\r\n *\r\n * @readonly\r\n * @return Radius (px)\r\n */\r\n get: function () {\r\n return $utils.relativeToValue(this.radius, $math.min(this.innerWidth / 2, this.innerHeight / 2));\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Updates bounding box.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Circle.prototype.measureElement = function () {\r\n var pixelRadius = this.pixelRadius;\r\n this._bbox = {\r\n x: -pixelRadius,\r\n y: -pixelRadius,\r\n width: pixelRadius * 2,\r\n height: pixelRadius * 2\r\n };\r\n };\r\n return Circle;\r\n}(Sprite));\r\nexport { Circle };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Circle\"] = Circle;\r\n//# sourceMappingURL=Circle.js.map","/**\r\n * Ellipse module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Circle } from \"./Circle\";\r\nimport { registry } from \"../Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Draws an ellipse\r\n * @see {@link IEllipseEvents} for a list of available events\r\n * @see {@link IEllipseAdapters} for a list of available Adapters\r\n */\r\nvar Ellipse = /** @class */ (function (_super) {\r\n __extends(Ellipse, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Ellipse() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"Ellipse\";\r\n _this.element = _this.paper.add(\"ellipse\");\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Draws the ellipsis.\r\n */\r\n Ellipse.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n this.element.attr({ \"rx\": this.radius });\r\n this.element.attr({ \"ry\": this.radiusY });\r\n };\r\n Object.defineProperty(Ellipse.prototype, \"radiusY\", {\r\n /**\r\n * @return Vertical radius\r\n */\r\n get: function () {\r\n return this.innerHeight / 2;\r\n },\r\n /**\r\n * Vertical radius.\r\n *\r\n * It's a relative size to the `radius`.\r\n *\r\n * E.g. 0.8 will mean the height of the ellipsis will be 80% of it's\r\n * horizontal radius.\r\n *\r\n * @param value Vertical radius\r\n */\r\n set: function (value) {\r\n this.height = value * 2;\r\n this.invalidate();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Ellipse.prototype, \"radius\", {\r\n /**\r\n * @return Horizontal radius\r\n */\r\n get: function () {\r\n return this.innerWidth / 2;\r\n },\r\n /**\r\n * Horizontal radius.\r\n *\r\n * @param value Horizontal radius\r\n */\r\n set: function (value) {\r\n this.width = value * 2;\r\n this.invalidate();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Ellipse;\r\n}(Circle));\r\nexport { Ellipse };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Ellipse\"] = Ellipse;\r\n//# sourceMappingURL=Ellipse.js.map","/**\r\n * Functionality for adding images in SVG tree.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Sprite } from \"../Sprite\";\r\nimport { registry } from \"../Registry\";\r\nimport * as $dom from \"../utils/DOM\";\r\nimport * as $type from \"../utils/Type\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Used to add `
` elements to SVG.\r\n *\r\n * @see {@link IImageEvents} for a list of available events\r\n * @see {@link IImageAdapters} for a list of available Adapters\r\n */\r\nvar Image = /** @class */ (function (_super) {\r\n __extends(Image, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Image() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"Image\";\r\n _this.element = _this.paper.add(\"image\");\r\n _this.applyTheme();\r\n _this.width = 50;\r\n _this.height = 50;\r\n return _this;\r\n }\r\n /**\r\n * Draws an `` element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Image.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n if (this.href) {\r\n var width = this.innerWidth;\r\n var height = this.innerHeight;\r\n if ($type.isNumber(this.widthRatio)) {\r\n width = height * this.widthRatio;\r\n this.width = width;\r\n }\r\n if ($type.isNumber(this.heightRatio)) {\r\n height = width * this.heightRatio;\r\n this.height = height;\r\n }\r\n this.element.attr({\r\n \"width\": width,\r\n \"height\": height\r\n });\r\n this.element.attrNS($dom.XLINK, \"xlink:href\", this.href);\r\n }\r\n };\r\n Object.defineProperty(Image.prototype, \"href\", {\r\n /**\r\n * @return Image URI\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"href\");\r\n },\r\n /**\r\n * An image URI.\r\n *\r\n * @param value Image URI\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"href\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Image.prototype, \"widthRatio\", {\r\n /**\r\n * @return Ratio\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"widthRatio\");\r\n },\r\n /**\r\n * Sets image `width` relatively to its `height`.\r\n *\r\n * If image's `height = 100` and `widthRatio = 0.5` the actual width will be\r\n * `50`.\r\n *\r\n * @param value Ratio\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"widthRatio\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Image.prototype, \"heightRatio\", {\r\n /**\r\n * @return Ratio\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"heightRatio\");\r\n },\r\n /**\r\n * Sets image `height` relatively to its `width`.\r\n *\r\n * If image's `width = 100` and `heightRatio = 0.5` the actual height will be\r\n * `50`.\r\n *\r\n * @param value Ratio\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"heightRatio\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Image.prototype, \"bbox\", {\r\n /**\r\n * Returns bounding box (square) for this element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n get: function () {\r\n return {\r\n x: 0,\r\n y: 0,\r\n width: this.pixelWidth,\r\n height: this.pixelHeight\r\n };\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Image;\r\n}(Sprite));\r\nexport { Image };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Image\"] = Image;\r\n//# sourceMappingURL=Image.js.map","/**\r\n * Line drawing functionality.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Sprite } from \"../Sprite\";\r\nimport { color } from \"../utils/Color\";\r\nimport { LinearGradient } from \"../rendering/fills/LinearGradient\";\r\nimport { registry } from \"../Registry\";\r\nimport * as $type from \"../utils/Type\";\r\nimport * as $math from \"../utils/Math\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Draws a line.\r\n *\r\n * @see {@link ILineEvents} for a list of available events\r\n * @see {@link ILineAdapters} for a list of available Adapters\r\n */\r\nvar Line = /** @class */ (function (_super) {\r\n __extends(Line, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Line() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"Line\";\r\n _this.element = _this.paper.add(\"line\");\r\n _this.fill = color(); //\"none\";\r\n _this.x1 = 0;\r\n _this.y1 = 0;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Draws the line.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Line.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n if (this.x1 == this.x2 || this.y1 == this.y2) {\r\n this.pixelPerfect = true;\r\n }\r\n else {\r\n this.pixelPerfect = false;\r\n }\r\n this.x1 = this.x1;\r\n this.x2 = this.x2;\r\n this.y1 = this.y1;\r\n this.y2 = this.y2;\r\n };\r\n Object.defineProperty(Line.prototype, \"x1\", {\r\n /**\r\n * @return X\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"x1\");\r\n },\r\n /**\r\n * X coordinate of first end.\r\n *\r\n * @param value X\r\n */\r\n set: function (value) {\r\n if (!$type.isNumber(value)) {\r\n value = 0;\r\n }\r\n var delta = 0;\r\n if (this.pixelPerfect && this.stroke instanceof LinearGradient) {\r\n delta = 0.00001;\r\n }\r\n this.setPropertyValue(\"x1\", value, true);\r\n this.element.attr({ \"x1\": value + delta });\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Line.prototype, \"x2\", {\r\n /**\r\n * @return X\r\n */\r\n get: function () {\r\n var value = this.getPropertyValue(\"x2\");\r\n if (!$type.isNumber(value)) {\r\n value = this.pixelWidth;\r\n }\r\n return value;\r\n },\r\n /**\r\n * X coordinate of second end.\r\n *\r\n * @param value X\r\n */\r\n set: function (value) {\r\n if (!$type.isNumber(value)) {\r\n value = 0;\r\n }\r\n this.setPropertyValue(\"x2\", value, true);\r\n this.element.attr({ \"x2\": value });\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Line.prototype, \"y1\", {\r\n /**\r\n * @return Y\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"y1\");\r\n },\r\n /**\r\n * Y coordinate of first end.\r\n *\r\n * @param value Y\r\n */\r\n set: function (value) {\r\n if (!$type.isNumber(value)) {\r\n value = 0;\r\n }\r\n var delta = 0;\r\n if (this.pixelPerfect && this.stroke instanceof LinearGradient) {\r\n delta = 0.00001;\r\n }\r\n this.setPropertyValue(\"y1\", value, true);\r\n this.element.attr({ \"y1\": value + delta });\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Line.prototype, \"y2\", {\r\n /**\r\n * @return Y\r\n */\r\n get: function () {\r\n var value = this.getPropertyValue(\"y2\");\r\n if (!$type.isNumber(value)) {\r\n value = this.pixelHeight;\r\n }\r\n return value;\r\n },\r\n /**\r\n * Y coordinate of second end.\r\n *\r\n * @param value Y\r\n */\r\n set: function (value) {\r\n if (!$type.isNumber(value)) {\r\n value = 0;\r\n }\r\n this.setPropertyValue(\"y2\", value, true);\r\n this.element.attr({ \"y2\": value });\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Converts relative position along the line (0-1) into pixel coordinates.\r\n *\r\n * @param position Position (0-1)\r\n * @return Coordinates\r\n */\r\n Line.prototype.positionToPoint = function (position) {\r\n var point1 = { x: this.x1, y: this.y1 };\r\n var point2 = { x: this.x2, y: this.y2 };\r\n var point = $math.getMidPoint(point1, point2, position);\r\n var angle = $math.getAngle(point1, point2);\r\n return { x: point.x, y: point.y, angle: angle };\r\n };\r\n return Line;\r\n}(Sprite));\r\nexport { Line };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Line\"] = Line;\r\n//# sourceMappingURL=Line.js.map","/**\r\n * Pointed shape module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Sprite } from \"../Sprite\";\r\nimport * as $type from \"../utils/Type\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Draws a shape with a pointer.\r\n *\r\n * @see {@link IPointedShapeEvents} for a list of available events\r\n * @see {@link IPointedShapeAdapters} for a list of available Adapters\r\n */\r\nvar PointedShape = /** @class */ (function (_super) {\r\n __extends(PointedShape, _super);\r\n /**\r\n * Constructor\r\n */\r\n function PointedShape() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"PointedShape\";\r\n _this.pointerBaseWidth = 15;\r\n _this.pointerLength = 10;\r\n _this.pointerY = 0;\r\n _this.pointerX = 0;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Draws the element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n PointedShape.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n if (!$type.isNumber(this.pointerX)) {\r\n this.pointerX = this.pixelWidth / 2;\r\n }\r\n if (!$type.isNumber(this.pointerY)) {\r\n this.pointerY = this.pixelHeight + 10;\r\n }\r\n };\r\n Object.defineProperty(PointedShape.prototype, \"pointerBaseWidth\", {\r\n /**\r\n * @return Width (px)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"pointerBaseWidth\");\r\n },\r\n /**\r\n * A width of the pinter's (stem's) thick end (base) in pixels.\r\n *\r\n * @default 15\r\n * @param value Width (px)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"pointerBaseWidth\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(PointedShape.prototype, \"pointerLength\", {\r\n /**\r\n * @return Length (px)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"pointerLength\");\r\n },\r\n /**\r\n * A length of the pinter (stem) in pixels.\r\n *\r\n * @default 10\r\n * @param value Length (px)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"pointerLength\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(PointedShape.prototype, \"pointerX\", {\r\n /**\r\n * @return X\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"pointerX\");\r\n },\r\n /**\r\n * X coordinate the shape is pointing to.\r\n *\r\n * @param value X\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"pointerX\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(PointedShape.prototype, \"pointerY\", {\r\n /**\r\n * @return Y\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"pointerY\");\r\n },\r\n /**\r\n * Y coordinate the shape is pointing to.\r\n *\r\n * @param value Y\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"pointerY\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return PointedShape;\r\n}(Sprite));\r\nexport { PointedShape };\r\n//# sourceMappingURL=PointedShape.js.map","/**\r\n * Pointed rectangle module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { PointedShape } from \"./PointedShape\";\r\nimport * as $math from \"../utils/Math\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Draws a rectangle with a pointer.\r\n *\r\n * @see {@link IPointedRectangleEvents} for a list of available events\r\n * @see {@link IPointedRectangleAdapters} for a list of available Adapters\r\n */\r\nvar PointedRectangle = /** @class */ (function (_super) {\r\n __extends(PointedRectangle, _super);\r\n /**\r\n * Constructor\r\n */\r\n function PointedRectangle() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"PointedRectangle\";\r\n _this.element = _this.paper.add(\"path\");\r\n _this.cornerRadius = 6;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Draws the element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n PointedRectangle.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n var cr = this.cornerRadius;\r\n var w = this.innerWidth;\r\n var h = this.innerHeight;\r\n if (w > 0 && h > 0) {\r\n var x = this.pointerX;\r\n var y = this.pointerY;\r\n var bwh = this.pointerBaseWidth / 2;\r\n var maxcr = $math.min(w / 2, h / 2);\r\n var crtl = $math.fitToRange(cr, 0, maxcr);\r\n var crtr = $math.fitToRange(cr, 0, maxcr);\r\n var crbr = $math.fitToRange(cr, 0, maxcr);\r\n var crbl = $math.fitToRange(cr, 0, maxcr);\r\n // corner coordinates\r\n // top left\r\n var xtl = 0;\r\n var ytl = 0;\r\n // top right\r\n var xtr = w;\r\n var ytr = 0;\r\n // bottom right\r\n var xbr = w;\r\n var ybr = h;\r\n // bottom left\r\n var xbl = 0;\r\n var ybl = h;\r\n var lineT = void 0;\r\n var lineR = void 0;\r\n var lineB = void 0;\r\n var lineL = void 0;\r\n // find stem base side: http://$math.stackexchange.com/questions/274712/calculate-on-which-side-of-straign-line-is-dot-located\r\n // d=(x−x1)(y2−y1)−(y−y1)(x2−x1)\r\n var d1 = (x - xtl) * (ybr - ytl) - (y - ytl) * (xbr - xtl);\r\n var d2 = (x - xbl) * (ytr - ybl) - (y - ybl) * (xtr - xbl);\r\n // top\r\n if (d1 > 0 && d2 > 0) {\r\n var stemX = $math.fitToRange(x, crtl + bwh, w - bwh - crtr);\r\n y = $math.fitToRange(y, -Infinity, 0);\r\n lineT = \"M\" + crtl + \",0 L\" + (stemX - bwh) + \",0 L\" + x + \",\" + y + \" L\" + (stemX + bwh) + \",0 L\" + (w - crtr) + \",0\";\r\n }\r\n else {\r\n lineT = \"M\" + crtl + \",0 L\" + (w - crtr) + \",0\";\r\n }\r\n // bottom\r\n if (d1 < 0 && d2 < 0) {\r\n var stemX = $math.fitToRange(x, crbl + bwh, w - bwh - crbr);\r\n y = $math.fitToRange(y, h, Infinity);\r\n lineB = \" L\" + (w - crbr) + \",\" + h + \" L\" + (stemX + bwh) + \",\" + h + \" L\" + x + \",\" + y + \" L\" + (stemX - bwh) + \",\" + h + \" L\" + crbl + \",\" + h;\r\n }\r\n else {\r\n lineB = \" L\" + crbl + \",\" + h;\r\n }\r\n // left\r\n if (d1 < 0 && d2 > 0) {\r\n var stemY = $math.fitToRange(y, crtl + bwh, h - crbl - bwh);\r\n x = $math.fitToRange(x, -Infinity, 0);\r\n lineL = \" L0,\" + (h - crbl) + \" L0,\" + (stemY + bwh) + \" L\" + x + \",\" + y + \" L0,\" + (stemY - bwh) + \" L0,\" + crtl;\r\n }\r\n else {\r\n lineL = \" L0,\" + crtl;\r\n }\r\n // right\r\n if (d1 > 0 && d2 < 0) {\r\n var stemY = $math.fitToRange(y, crtr + bwh, h - bwh - crbr);\r\n x = $math.fitToRange(x, w, Infinity);\r\n lineR = \" L\" + w + \",\" + crtr + \" L\" + w + \",\" + (stemY - bwh) + \" L\" + x + \",\" + y + \" L\" + w + \",\" + (stemY + bwh) + \" L\" + w + \",\" + (h - crbr);\r\n }\r\n else {\r\n lineR = \" L\" + w + \",\" + (h - crbr);\r\n }\r\n var arcTR = \" a\" + crtr + \",\" + crtr + \" 0 0 1 \" + crtr + \",\" + crtr;\r\n var arcBR = \" a\" + crbr + \",\" + crbr + \" 0 0 1 -\" + crbr + \",\" + crbr;\r\n var arcBL = \" a\" + crbl + \",\" + crbl + \" 0 0 1 -\" + crbl + \",-\" + crbl;\r\n var arcTL = \" a\" + crtl + \",\" + crtl + \" 0 0 1 \" + crtl + \",-\" + crtl;\r\n this.path = lineT + arcTR + lineR + arcBR + lineB + arcBL + lineL + arcTL;\r\n }\r\n };\r\n Object.defineProperty(PointedRectangle.prototype, \"cornerRadius\", {\r\n /**\r\n * @return Corner radius (px)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"cornerRadius\");\r\n },\r\n /**\r\n * Radius of rectangle's border in pixels.\r\n *\r\n * @default 0\r\n * @param value Corner radius (px)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"cornerRadius\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return PointedRectangle;\r\n}(PointedShape));\r\nexport { PointedRectangle };\r\n//# sourceMappingURL=PointedRectangle.js.map","/**\r\n * A collection of functions that deals with path calculations.\r\n */\r\nimport * as $math from \"../utils/Math\";\r\nimport * as $type from \"../utils/Type\";\r\nimport { getGhostPaper } from \"../rendering/Paper\";\r\nimport { options } from \"../Options\";\r\n/**\r\n * ============================================================================\r\n * PATH FUNCTIONS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Returns an SVG path from a number of points.\r\n *\r\n * @ignore Exclude from docs\r\n * @param points An array of line elbow points\r\n * @return SVG path\r\n */\r\nexport function polyline(points) {\r\n var path = lineTo(points[0]);\r\n var prevPoint = { x: 0, y: 0 };\r\n var minStep = options.minPolylineStep;\r\n if (!$type.isNumber(minStep)) {\r\n minStep = 0.5;\r\n }\r\n for (var i = 0, len = points.length; i < len; i++) {\r\n var point = points[i];\r\n if ($math.getDistance(point, prevPoint) > minStep) {\r\n path += lineTo(point);\r\n prevPoint = point;\r\n }\r\n }\r\n return path;\r\n}\r\n/**\r\n * Returns a starting point of an SVG path.\r\n *\r\n * @ignore Exclude from docs\r\n * @param point Starting point\r\n * @return SVG path\r\n */\r\nexport function moveTo(point) {\r\n return \" M\" + $math.round(point.x, 4) + \",\" + $math.round(point.y, 4) + \" \";\r\n}\r\n/**\r\n * Returns a line part of SVG path.\r\n *\r\n * @ignore Exclude from docs\r\n * @param point SVG path\r\n * @return SVG path\r\n */\r\nexport function lineTo(point) {\r\n return \" L\" + $math.round(point.x, 4) + \",\" + $math.round(point.y, 4) + \" \";\r\n}\r\n/**\r\n * Returns a quadratic curve part of an SVG path.\r\n *\r\n * @ignore Exclude from docs\r\n * @param point End point of the curve\r\n * @param controlPoint Control point\r\n * @return SVG path\r\n */\r\nexport function quadraticCurveTo(point, controlPoint) {\r\n return \" Q\" + $math.round(controlPoint.x, 4)\r\n + \",\" + $math.round(controlPoint.y, 4) + \" \" + $math.round(point.x, 4)\r\n + \",\" + $math.round(point.y, 4);\r\n}\r\n/**\r\n * Returns a cubic curve part of an SVG path.\r\n *\r\n * @ignore Exclude from docs\r\n * @param point End point of the curve\r\n * @param controlPointA Control point A\r\n * @param controlPointB Control point B\r\n * @return SVG path\r\n */\r\nexport function cubicCurveTo(point, controlPointA, controlPointB) {\r\n return \" C\" + $math.round(controlPointA.x, 4)\r\n + \",\" + $math.round(controlPointA.y, 4) + \" \" + $math.round(controlPointB.x, 4)\r\n + \",\" + $math.round(controlPointB.y, 4) + \" \" + $math.round(point.x, 4)\r\n + \",\" + $math.round(point.y, 4);\r\n}\r\n/**\r\n * Returns a terminator for an SVG path.\r\n *\r\n * @ignore Exclude from docs\r\n * @return SVG path\r\n */\r\nexport function closePath() {\r\n return \" Z\";\r\n}\r\n/**\r\n * Returns an arc part of an SVG path.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Better parameter descriptions\r\n * @param startAngle Starting angle\r\n * @param arc Arc\r\n * @param radius Radius\r\n * @param radiusY Vertical radius\r\n * @return SVG path\r\n */\r\nexport function arcTo(startAngle, arc, radius, radiusY) {\r\n if (arc == 0) {\r\n return \"\";\r\n }\r\n if (!$type.isNumber(radiusY)) {\r\n radiusY = radius;\r\n }\r\n var path = \"\";\r\n var c = \",\";\r\n var segments = Math.ceil(Math.abs(arc) / 180);\r\n var l = 1;\r\n if (arc < 0) {\r\n l = 0;\r\n }\r\n // previous, as we use a not A\r\n var pax = 0;\r\n var pay = 0;\r\n // center\r\n var cx = -$math.cos(startAngle) * radius;\r\n var cy = -$math.sin(startAngle) * radiusY;\r\n // foir very short angles and big radius, solves artefacts\r\n if (arc < 0.5 && radius > 3000) {\r\n var endAngle = startAngle + arc;\r\n var ax = $math.round($math.cos(endAngle) * radius, 4);\r\n var ay = $math.round($math.sin(endAngle) * radiusY, 4);\r\n return lineTo({ x: ax, y: ay });\r\n }\r\n for (var i = 0; i < segments; i++) {\r\n var endAngle = startAngle + arc / segments * (i + 1);\r\n var ax = $math.round($math.cos(endAngle) * radius + cx - pax, 4);\r\n var ay = $math.round($math.sin(endAngle) * radiusY + cy - pay, 4);\r\n path += \" a\" + radius + c + radiusY + c + 0 + c + 0 + c + l + c + ax + c + ay;\r\n pax = ax;\r\n pay = ay;\r\n }\r\n return path;\r\n}\r\n/**\r\n * Creates an arc path.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param startAngle [description]\r\n * @param arc [description]\r\n * @param radius [description]\r\n * @param innerRadius [description]\r\n * @param radiusY [description]\r\n * @param cornerRadius [description]\r\n * @param innerCornerRadius [description]\r\n * @return SVG path\r\n */\r\nexport function arc(startAngle, arc, radius, innerRadius, radiusY, cornerRadius, innerCornerRadius) {\r\n if (arc == 0) {\r\n return \"\";\r\n }\r\n if (!$type.isNumber(innerRadius)) {\r\n innerRadius = 0;\r\n }\r\n if (radius == 0 && innerRadius <= 0) {\r\n return \"\";\r\n }\r\n if (radius < innerRadius) {\r\n var temp = radius;\r\n radius = innerRadius;\r\n innerRadius = temp;\r\n if ($type.isNumber(radiusY)) {\r\n radiusY = radiusY / innerRadius * radius;\r\n }\r\n }\r\n arc = $math.min(arc, 360);\r\n if (arc == 360) {\r\n cornerRadius = 0;\r\n innerCornerRadius = 0;\r\n }\r\n var endAngle = startAngle + arc;\r\n var crSin = $math.sin($math.min(arc, 45) / 2);\r\n radiusY = $type.isNumber(radiusY) ? radiusY : radius;\r\n cornerRadius = cornerRadius || 0;\r\n innerCornerRadius = $type.isNumber(innerCornerRadius) ? innerCornerRadius : cornerRadius;\r\n var innerRadiusY = (radiusY / radius) * innerRadius;\r\n var cornerRadiusY = (radiusY / radius) * cornerRadius;\r\n var innerCornerRadiusY = (radiusY / radius) * innerCornerRadius;\r\n cornerRadius = $math.fitToRange(cornerRadius, 0, (radius - innerRadius) / 2);\r\n cornerRadiusY = $math.fitToRange(cornerRadiusY, 0, (radiusY - innerRadiusY) / 2);\r\n innerCornerRadius = $math.fitToRange(innerCornerRadius, 0, (radius - innerRadius) / 2);\r\n innerCornerRadiusY = $math.fitToRange(innerCornerRadiusY, 0, (radiusY - innerRadiusY) / 2);\r\n cornerRadius = $math.round($math.fitToRange(cornerRadius, 0, radius * crSin), 4);\r\n cornerRadiusY = $math.round($math.fitToRange(cornerRadiusY, 0, radiusY * crSin), 4);\r\n innerCornerRadius = $math.round($math.fitToRange(innerCornerRadius, 0, innerRadius * crSin), 4);\r\n innerCornerRadiusY = $math.round($math.fitToRange(innerCornerRadiusY, 0, innerRadiusY * crSin), 4);\r\n var crAngle = Math.asin(cornerRadius / radius / 2) * $math.DEGREES * 2;\r\n var crAngleY = Math.asin(cornerRadiusY / radiusY / 2) * $math.DEGREES * 2;\r\n if (innerRadius < innerCornerRadius) {\r\n innerRadius = innerCornerRadius;\r\n }\r\n if (innerRadiusY < innerCornerRadiusY) {\r\n innerRadiusY = innerCornerRadiusY;\r\n }\r\n var crInnerAngle = Math.asin(innerCornerRadius / innerRadius / 2) * $math.DEGREES * 2;\r\n var crInnerAngleY = Math.asin(innerCornerRadiusY / innerRadiusY / 2) * $math.DEGREES * 2;\r\n if (!$type.isNumber(crInnerAngle)) {\r\n crInnerAngle = 0;\r\n }\r\n if (!$type.isNumber(crInnerAngleY)) {\r\n crInnerAngleY = 0;\r\n }\r\n var middleAngle = startAngle + arc / 2;\r\n var mPoint = { x: $math.round($math.cos(middleAngle) * innerRadius, 4), y: $math.sin(middleAngle) * innerRadiusY };\r\n var a0 = { x: $math.cos(startAngle) * (innerRadius + innerCornerRadius), y: $math.sin(startAngle) * (innerRadiusY + innerCornerRadiusY) };\r\n var b0 = { x: $math.cos(startAngle) * (radius - cornerRadius), y: $math.sin(startAngle) * (radiusY - cornerRadiusY) };\r\n var c0 = { x: $math.cos(endAngle) * (radius - cornerRadius), y: $math.sin(endAngle) * (radiusY - cornerRadiusY) };\r\n var d0 = { x: $math.cos(endAngle) * (innerRadius + innerCornerRadius), y: $math.sin(endAngle) * (innerRadiusY + innerCornerRadiusY) };\r\n var b1 = { x: $math.cos(startAngle + crAngle) * radius, y: $math.sin(startAngle + crAngleY) * radiusY };\r\n var d1 = { x: $math.cos(endAngle - crInnerAngle) * innerRadius, y: $math.sin(endAngle - crInnerAngleY) * innerRadiusY };\r\n // some magic math\r\n innerCornerRadius += innerCornerRadius * $math.sin(crInnerAngle / 2);\r\n innerCornerRadiusY += innerCornerRadiusY * $math.sin(crInnerAngleY / 2);\r\n if (crInnerAngle > (endAngle - startAngle) / 2) {\r\n d1 = mPoint;\r\n }\r\n var path = \"\";\r\n // start from b if this is full circle\r\n if (arc == 360) {\r\n path = moveTo(b0);\r\n }\r\n // otherwise start from a\r\n else {\r\n path = moveTo(a0);\r\n path += lineTo(b0);\r\n path += arcToPoint(b1, cornerRadius, cornerRadiusY, true);\r\n }\r\n // draw arc\r\n path += arcTo(startAngle + crAngle, arc - 2 * crAngle, radius, radiusY);\r\n // draw inner arc\r\n if ($type.isNumber(innerRadius) && innerRadius != 0) {\r\n // move to B if this is full circle\r\n if (arc == 360 && cornerRadius == 0) {\r\n path += moveTo(d0);\r\n }\r\n // draw line otherwise\r\n else {\r\n path += arcToPoint(c0, cornerRadius, cornerRadiusY, true);\r\n path += lineTo(d0);\r\n path += arcToPoint(d1, innerCornerRadius, innerCornerRadiusY, true);\r\n }\r\n path += arcTo(endAngle - crInnerAngle, -(arc - 2 * crInnerAngle), innerRadius, innerRadiusY);\r\n if (arc < 360 || cornerRadius > 0) {\r\n path += arcToPoint(a0, innerCornerRadius, innerCornerRadiusY, true);\r\n }\r\n path += lineTo(a0);\r\n }\r\n else {\r\n path += arcToPoint(c0, cornerRadius, cornerRadiusY, true);\r\n if (arc < 360) {\r\n path += lineTo(a0);\r\n }\r\n }\r\n return path;\r\n}\r\n/**\r\n * Creates a path for an arc to specific coordinate.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param point Reference point\r\n * @param radius Radius\r\n * @param radiusY Vertical radius (for skewed arcs)\r\n * @param sweepFlag [description]\r\n * @param largeArcFlag [description]\r\n * @param xAxisRotation [description]\r\n * @return Arc path\r\n */\r\nexport function arcToPoint(point, radius, radiusY, sweepFlag, largeArcFlag, xAxisRotation) {\r\n if (radius == 0) {\r\n return \"\";\r\n }\r\n xAxisRotation = xAxisRotation || 0;\r\n largeArcFlag = Boolean(largeArcFlag);\r\n sweepFlag = Boolean(sweepFlag);\r\n var c = \",\";\r\n var sweepFlagValue = +sweepFlag; // converts to 1 or 0\r\n var largeArcFlagValue = +largeArcFlag; // converts to 1 or 0\r\n return \" A\" + radius + c + radiusY + c + xAxisRotation + c + largeArcFlagValue + c + sweepFlagValue + c + $math.round(point.x, 4) + c + $math.round(point.y, 4);\r\n}\r\n/**\r\n * Creates a new rectangle.\r\n *\r\n * @ignore Exclude from docs\r\n * @param width Width (px)\r\n * @param height Height (px)\r\n * @param x X position\r\n * @param y Y position\r\n * @return Rectangle\r\n */\r\nexport function rectangle(width, height, x, y) {\r\n if (!$type.isNumber(x)) {\r\n x = 0;\r\n }\r\n if (!$type.isNumber(y)) {\r\n y = 0;\r\n }\r\n return moveTo({ x: x, y: y }) + lineTo({ x: x + width, y: y }) + lineTo({ x: x + width, y: y + height }) + lineTo({ x: x, y: y + height }) + closePath();\r\n}\r\n/**\r\n * Converts a rectangle to an SVG path.\r\n *\r\n * @ignore Exclude from docs\r\n * @param rect Rectangle\r\n * @param ccw Counter-clockwise?\r\n * @return SVG path\r\n */\r\nexport function rectToPath(rect, ccw) {\r\n var c = \",\";\r\n var L = \" L\";\r\n if (ccw) {\r\n return \"M\" + rect.x\r\n + c + rect.y + L + rect.x\r\n + c + (rect.y + rect.height) + L + (rect.x + rect.width)\r\n + c + (rect.y + rect.height) + L + (rect.x + rect.width)\r\n + c + rect.y + L + rect.x\r\n + c + rect.y;\r\n }\r\n else {\r\n return \"M\" + rect.x\r\n + c + rect.y + L + (rect.x + rect.width)\r\n + c + rect.y + L + (rect.x + rect.width)\r\n + c + (rect.y + rect.height) + L + rect.x\r\n + c + (rect.y + rect.height) + L + rect.x\r\n + c + rect.y;\r\n }\r\n}\r\n/**\r\n * Converts SVG path to array of points.\r\n *\r\n * Note, this is experimental feature based on method which is deprecated\r\n * on some browsers and some browsers do not support it at all.\r\n *\r\n * You can save the output of this function, but not rely on it completely.\r\n */\r\nexport function pathToPoints(path, pointCount) {\r\n var paper = getGhostPaper();\r\n var svgPath = paper.add(\"path\").node;\r\n svgPath.setAttribute(\"d\", path);\r\n if (svgPath.getPointAtLength && svgPath.getTotalLength) {\r\n var length_1 = svgPath.getTotalLength();\r\n var toPoints = [];\r\n for (var i = 0; i < pointCount; i++) {\r\n var point = svgPath.getPointAtLength(i / pointCount * length_1);\r\n toPoints.push({ x: point.x, y: point.y });\r\n }\r\n return toPoints;\r\n }\r\n svgPath.remove();\r\n}\r\nexport function spiralPoints(cx, cy, radius, radiusY, innerRadius, step, radiusStep, startAngle, endAngle) {\r\n if (!$type.isNumber(startAngle)) {\r\n startAngle = 0;\r\n }\r\n if (!$type.isNumber(startAngle)) {\r\n endAngle = startAngle;\r\n }\r\n var r = innerRadius + 0.01;\r\n var angle = startAngle * $math.RADIANS;\r\n var points = [];\r\n while (r < radius + radiusStep) {\r\n var stepSize = step;\r\n if (stepSize / 2 > r) {\r\n stepSize = 2 * r;\r\n }\r\n angle += 2 * Math.asin(stepSize / 2 / r);\r\n if (angle * $math.DEGREES > endAngle + ((radius - innerRadius) / radiusStep) * 360) {\r\n break;\r\n }\r\n var degrees = angle * $math.DEGREES;\r\n var point = { x: cx + r * Math.cos(angle), y: cy + r * radiusY / radius * Math.sin(angle) };\r\n points.push(point);\r\n r = innerRadius + degrees / 360 * radiusStep;\r\n }\r\n points.shift();\r\n return points;\r\n}\r\nexport function pointsToPath(points) {\r\n if (!points || points.length == 0) {\r\n return \"\";\r\n }\r\n var path = moveTo(points[0]);\r\n if (points && points.length > 0) {\r\n for (var i = 1; i < points.length; i++) {\r\n path += lineTo(points[i]);\r\n }\r\n }\r\n return path;\r\n}\r\n//# sourceMappingURL=Path.js.map","/**\r\n * Polyline module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Sprite } from \"../Sprite\";\r\nimport { color } from \"../utils/Color\";\r\nimport { registry } from \"../Registry\";\r\nimport * as $path from \"../rendering/Path\";\r\nimport * as $math from \"../utils/Math\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Draws a polyline.\r\n *\r\n * @see {@link IPolylineEvents} for a list of available events\r\n * @see {@link IPolylineAdapters} for a list of available Adapters\r\n */\r\nvar Polyline = /** @class */ (function (_super) {\r\n __extends(Polyline, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Polyline() {\r\n var _this = _super.call(this) || this;\r\n /**\r\n * [_distance description]\r\n *\r\n * @todo Description\r\n */\r\n _this._distance = 0;\r\n _this.className = \"Polyline\";\r\n _this.element = _this.paper.add(\"path\");\r\n _this.shapeRendering = \"auto\";\r\n _this.fill = color();\r\n _this.strokeOpacity = 1;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Creats and adds an SVG path for the arc.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Polyline.prototype.makePath = function () {\r\n this._distance = 0;\r\n var segments = this.segments;\r\n if (segments && segments.length > 0) {\r\n var path = \"\";\r\n for (var i = 0, len = segments.length; i < len; i++) {\r\n var points = segments[i];\r\n if (points.length > 0) {\r\n path += $path.moveTo(points[0]);\r\n for (var p = 1; p < points.length; p++) {\r\n var point = points[p];\r\n path += $path.lineTo(point);\r\n this._distance += $math.getDistance(points[p - 1], point);\r\n }\r\n }\r\n }\r\n this.path = path;\r\n }\r\n this._realSegments = segments;\r\n };\r\n Object.defineProperty(Polyline.prototype, \"segments\", {\r\n /**\r\n * @return Segments\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"segments\");\r\n },\r\n /**\r\n * A list of segment coordinates for the multi-part line.\r\n *\r\n * @todo Example\r\n * @param segments Segments\r\n */\r\n set: function (segments) {\r\n this.setPropertyValue(\"segments\", segments);\r\n this.makePath();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Polyline.prototype, \"distance\", {\r\n /**\r\n * [distance description]\r\n *\r\n * @todo Description\r\n * @return [description]\r\n */\r\n get: function () {\r\n return this._distance;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Converts relative position along the line (0-1) into pixel coordinates.\r\n *\r\n * @param position Position (0-1)\r\n * @return Coordinates\r\n */\r\n Polyline.prototype.positionToPoint = function (position) {\r\n var deltaAngle = 0;\r\n if (position < 0) {\r\n position = Math.abs(position);\r\n deltaAngle = 180;\r\n }\r\n var segments = this._realSegments;\r\n if (segments) {\r\n var totalDistance = this.distance;\r\n var currentDistance = 0;\r\n var distanceAB = void 0;\r\n var positionA = 0;\r\n var positionB = 0;\r\n var pointA = void 0;\r\n var pointB = void 0;\r\n for (var s = 0; s < segments.length; s++) {\r\n var points = segments[s];\r\n if (points.length > 1) {\r\n for (var p = 1; p < points.length; p++) {\r\n pointA = points[p - 1];\r\n pointB = points[p];\r\n positionA = currentDistance / totalDistance;\r\n distanceAB = $math.getDistance(pointA, pointB);\r\n currentDistance += distanceAB;\r\n positionB = currentDistance / totalDistance;\r\n if (positionA <= position && positionB > position) {\r\n s = segments.length;\r\n break;\r\n }\r\n }\r\n }\r\n else if (points.length == 1) {\r\n pointA = points[0];\r\n pointB = points[0];\r\n positionA = 0;\r\n positionB = 1;\r\n }\r\n }\r\n if (pointA && pointB) {\r\n var positionAB = (position - positionA) / (positionB - positionA);\r\n var midPoint = $math.getMidPoint(pointA, pointB, positionAB);\r\n return { x: midPoint.x, y: midPoint.y, angle: deltaAngle + $math.getAngle(pointA, pointB) };\r\n }\r\n }\r\n return { x: 0, y: 0, angle: 0 };\r\n };\r\n Object.defineProperty(Polyline.prototype, \"realSegments\", {\r\n /**\r\n * @ignore\r\n */\r\n get: function () {\r\n return this._realSegments;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Polyline;\r\n}(Sprite));\r\nexport { Polyline };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Polyline\"] = Polyline;\r\n//# sourceMappingURL=Polyline.js.map","/**\r\n * Module for a multi-part arched line.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Polyline } from \"./Polyline\";\r\nimport { registry } from \"../Registry\";\r\nimport * as $math from \"../../core/utils/Math\";\r\nimport * as $path from \"../../core/rendering/Path\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Draws a multi-part arched line.\r\n *\r\n * @see {@link IPolyarcEvents} for a list of available events\r\n * @see {@link IPolyarcAdapters} for a list of available Adapters\r\n */\r\nvar Polyarc = /** @class */ (function (_super) {\r\n __extends(Polyarc, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Polyarc() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"Polyarc\";\r\n _this.controlPointDistance = 0.5;\r\n _this.controlPointPosition = 0.5;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Creats and adds an SVG path for the arc.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Polyarc.prototype.makePath = function () {\r\n this._distance = 0;\r\n var segments = this.segments;\r\n if (segments && segments.length > 0) {\r\n var path = \"\";\r\n this._realSegments = [];\r\n for (var i = 0, len = segments.length; i < len; i++) {\r\n var points = segments[i];\r\n var realPoints = [];\r\n this._realSegments.push(realPoints);\r\n if (points.length > 0) {\r\n path += $path.moveTo(points[0]);\r\n for (var p = 1; p < points.length; p++) {\r\n var pointA = points[p - 1];\r\n var pointB = points[p];\r\n var distanceAB = $math.getDistance(pointB, pointA);\r\n var cpDistance = distanceAB * this.controlPointDistance;\r\n var controlPointPosition = this.controlPointPosition;\r\n var angle = -$math.getAngle(pointA, pointB);\r\n var cpx = pointA.x + (pointB.x - pointA.x) * controlPointPosition * 0.5 - cpDistance * $math.sin(angle);\r\n var cpy = pointA.y + (pointB.y - pointA.y) * controlPointPosition * 0.5 - cpDistance * $math.cos(angle);\r\n var controlPoint1 = { x: cpx, y: cpy };\r\n var cpx2 = pointA.x + (pointB.x - pointA.x) * controlPointPosition * 1.5 - cpDistance * $math.sin(angle);\r\n var cpy2 = pointA.y + (pointB.y - pointA.y) * controlPointPosition * 1.5 - cpDistance * $math.cos(angle);\r\n var controlPoint2 = { x: cpx2, y: cpy2 };\r\n path += $path.cubicCurveTo(pointB, controlPoint1, controlPoint2);\r\n // we add a lot of points in order to get the position/angle later\r\n var stepCount = Math.ceil(distanceAB);\r\n var prevPoint = pointA;\r\n if (stepCount > 0) {\r\n for (var i_1 = 0; i_1 <= stepCount; i_1++) {\r\n var point = $math.getPointOnCubicCurve(pointA, pointB, controlPoint1, controlPoint2, i_1 / stepCount);\r\n realPoints.push(point);\r\n this._distance += $math.getDistance(prevPoint, point);\r\n prevPoint = point;\r\n }\r\n }\r\n else {\r\n realPoints.push(pointA);\r\n }\r\n }\r\n }\r\n }\r\n this.path = path;\r\n }\r\n };\r\n Object.defineProperty(Polyarc.prototype, \"controlPointPosition\", {\r\n /**\r\n * @return Position (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"controlPointPosition\");\r\n },\r\n /**\r\n * Relative position along the line the control point is. (0-1)\r\n *\r\n * @default 0.5\r\n * @param value Position (0-1)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"controlPointPosition\", value);\r\n this.makePath();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Polyarc.prototype, \"controlPointDistance\", {\r\n /**\r\n * @return Distance (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"controlPointDistance\");\r\n },\r\n /**\r\n * Relative distance of the control point. (0-1)\r\n *\r\n * Default is half the length of the line. (0.5)\r\n *\r\n * @default 0.5\r\n * @param value Distance (0-1)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"controlPointDistance\", value);\r\n this.makePath();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Polyarc;\r\n}(Polyline));\r\nexport { Polyarc };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Polyarc\"] = Polyarc;\r\n//# sourceMappingURL=Polyarc.js.map","/**\r\n * Morpher module contains functionality that allows morphing one polygon to\r\n * another.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { BaseObject } from \"../Base\";\r\nimport { Animation, AnimationDisposer } from \"../utils/Animation\";\r\nimport * as $math from \"../utils/Math\";\r\nimport * as $ease from \"../utils/Ease\";\r\nimport * as $type from \"../utils/Type\";\r\n/**\r\n * Morpher can be used to morph one polygon to some other polygon.\r\n */\r\nvar Morpher = /** @class */ (function (_super) {\r\n __extends(Morpher, _super);\r\n /**\r\n * Constructor.\r\n *\r\n * @param morphable An object to morph\r\n */\r\n function Morpher(morphable) {\r\n var _this = _super.call(this) || this;\r\n /**\r\n * A storage for measurements.\r\n */\r\n _this._bboxes = [];\r\n /**\r\n * Duration of the morphing animation in milliseconds.\r\n */\r\n _this.morphDuration = 800;\r\n /**\r\n * An easing function to use for morphing animation.\r\n *\r\n * @see {@link Ease}\r\n */\r\n _this.morphEasing = $ease.cubicOut;\r\n /**\r\n * If set to `true`, all separate parts of the multi-part polygon will\r\n * morph into a single circle or polygon when using built-in methods\r\n * `morphToCircle()` or `morphToPolygon()`.\r\n *\r\n * Otherwise each separate part of polygon will morph to individual target\r\n * circle or polgyon.\r\n */\r\n _this.morphToSingle = true;\r\n /**\r\n * A ratio to scale morphed object in relation to the source object.\r\n */\r\n _this.scaleRatio = 1;\r\n _this.className = \"Morpher\";\r\n _this.morphable = morphable;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Morphs a polygon to another polygon.\r\n *\r\n * @param toPoints Corner points of the target shape\r\n * @param duration Duration in milliseconds\r\n * @param easing Easing function\r\n * @return Animation\r\n */\r\n Morpher.prototype.morphToPolygon = function (toPoints, duration, easing) {\r\n var points = this.morphable.currentPoints;\r\n if (points && toPoints) {\r\n this.sortPoints(points);\r\n this.sortPoints(toPoints);\r\n this._morphFromPointsReal = [];\r\n this._morphToPointsReal = [];\r\n if (!$type.hasValue(duration)) {\r\n duration = this.morphDuration;\r\n }\r\n if (!$type.hasValue(easing)) {\r\n easing = this.morphEasing;\r\n }\r\n this._morphFromPointsReal = this.normalizePoints(toPoints, points);\r\n this._morphToPointsReal = this.normalizePoints(points, toPoints);\r\n this.morphable.currentPoints = this._morphFromPointsReal;\r\n var animation = new Animation(this, { property: \"morphProgress\", from: 0, to: 1 }, duration, easing);\r\n this._disposers.push(animation);\r\n animation.start();\r\n return animation;\r\n }\r\n };\r\n /**\r\n * [normalizePoints description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param pointsA Point A\r\n * @param pointsB Point B\r\n * @return Normalized points\r\n */\r\n Morpher.prototype.normalizePoints = function (pointsA, pointsB) {\r\n for (var i = 0, len = pointsA.length; i < len; i++) {\r\n var surfaceA = pointsA[i][0];\r\n var holeA = pointsA[i][1];\r\n var bboxA = $type.getValue($math.getBBox(surfaceA));\r\n var middleX = bboxA.x + bboxA.width;\r\n var middleY = bboxA.y + bboxA.height;\r\n // check if we have the same in PointsB\r\n if (!pointsB[i]) {\r\n pointsB[i] = [];\r\n }\r\n // check if we have surface in pointsB\r\n if (surfaceA && !pointsB[i][0]) {\r\n pointsB[i][0] = [{ x: middleX, y: middleY }, { x: middleX, y: middleY }];\r\n }\r\n if (pointsB[i][0]) {\r\n pointsB[i][0] = this.addPoints(pointsB[i][0], surfaceA.length);\r\n var distance = Infinity;\r\n var splitAt = 0;\r\n for (var a = 0; a < pointsB[i][0].length; a++) {\r\n var newDistance = $math.getDistance(pointsB[i][0][a], surfaceA[0]);\r\n if (newDistance < distance) {\r\n splitAt = a;\r\n distance = newDistance;\r\n }\r\n }\r\n var partA = pointsB[i][0].slice(0, splitAt);\r\n var partB = pointsB[i][0].slice(splitAt);\r\n pointsB[i][0] = partB.concat(partA);\r\n }\r\n if (holeA) {\r\n if (!pointsB[i][1]) {\r\n pointsB[i][1] = [{ x: middleX, y: middleY }, { x: middleX, y: middleY }];\r\n }\r\n pointsB[i][1] = this.addPoints(pointsB[i][1], holeA.length);\r\n }\r\n }\r\n return pointsB;\r\n };\r\n /**\r\n * [sortPoints description]\r\n *\r\n * @ignore Exclude from doc\r\n * @todo Description\r\n * @param points [description]\r\n * @return common bbox of points\r\n */\r\n Morpher.prototype.sortPoints = function (points) {\r\n points.sort(function (a, b) {\r\n var bbox1 = $type.getValue($math.getBBox(a[0]));\r\n var bbox2 = $type.getValue($math.getBBox(b[0]));\r\n if (bbox1.width * bbox1.height > bbox2.width * bbox2.height) {\r\n return -1;\r\n }\r\n else {\r\n return 1;\r\n }\r\n });\r\n var bboxes = [];\r\n for (var i = 0, len = points.length; i < len; i++) {\r\n var surface = points[i][0];\r\n if (surface) {\r\n bboxes.push($type.getValue($math.getBBox(surface)));\r\n }\r\n }\r\n return $math.getCommonRectangle(bboxes);\r\n };\r\n /**\r\n * Morphs polygon to a circle (it is actually a polygon which makes a circle).\r\n *\r\n * @param radius Target circle radius (px)\r\n * @param duration Duration (ms)\r\n * @param easing Easing function\r\n * @return Animation\r\n */\r\n Morpher.prototype.morphToCircle = function (radius, duration, easing) {\r\n var points = this.morphable.points;\r\n var commonBBox = this.sortPoints(points);\r\n this._morphFromPointsReal = [];\r\n this._morphToPointsReal = [];\r\n if (!$type.hasValue(duration)) {\r\n duration = this.morphDuration;\r\n }\r\n if (!$type.hasValue(easing)) {\r\n easing = this.morphEasing;\r\n }\r\n // surface\r\n for (var i = 0, len = points.length; i < len; i++) {\r\n var surface = points[i][0];\r\n var hole = points[i][1];\r\n this._morphFromPointsReal[i] = [];\r\n this._morphToPointsReal[i] = [];\r\n if (surface) {\r\n var toPoints = surface;\r\n var fromPoints = surface;\r\n var bbox = $type.getValue($math.getBBox(fromPoints)); // this._bboxes[i];\r\n if (this.morphToSingle) {\r\n bbox = $type.getValue(commonBBox);\r\n }\r\n var middleX = bbox.x + bbox.width / 2;\r\n var middleY = bbox.y + bbox.height / 2;\r\n var realRadius = radius;\r\n if (!$type.isNumber(realRadius)) {\r\n realRadius = Math.min(bbox.width / 2, bbox.height / 2);\r\n }\r\n toPoints = [];\r\n // find angle for the first point\r\n var startAngle = $math.getAngle({ x: middleX, y: middleY }, surface[0]);\r\n var count = 100;\r\n if (surface.length > count) {\r\n count = surface.length;\r\n }\r\n fromPoints = this.addPoints(surface, count);\r\n count = fromPoints.length; // add Points might increase number a bit\r\n var angle = 360 / (count - 1);\r\n for (var a = 0; a < count; a++) {\r\n var realAngle = angle * a + startAngle;\r\n var pointOnCircle = { x: middleX + realRadius * $math.cos(realAngle), y: middleY + realRadius * $math.sin(realAngle) };\r\n toPoints[a] = pointOnCircle;\r\n }\r\n if (hole && hole.length > 0) {\r\n for (var i_1 = 0, hlen = hole.length; i_1 < hlen; i_1++) {\r\n toPoints.push({ x: middleX, y: middleY });\r\n }\r\n }\r\n this._morphFromPointsReal[i][0] = fromPoints;\r\n this._morphToPointsReal[i][0] = toPoints;\r\n }\r\n }\r\n this.morphable.currentPoints = this._morphFromPointsReal;\r\n var animation = new Animation(this, { property: \"morphProgress\", from: 0, to: 1 }, duration, easing);\r\n this._disposers.push(animation);\r\n animation.start();\r\n return animation;\r\n };\r\n /**\r\n * [addPoints description]\r\n *\r\n * @ignore Exclude from doc\r\n * @todo Description\r\n * @param points [description]\r\n * @param mustHaveCount [description]\r\n * @return [description]\r\n */\r\n Morpher.prototype.addPoints = function (points, mustHaveCount) {\r\n var addToSegmentCount = Math.round(mustHaveCount / points.length);\r\n var newPoints = [];\r\n for (var i = 0, len = points.length; i < len; i++) {\r\n var point0 = points[i];\r\n var point1 = void 0;\r\n if (i == points.length - 1) {\r\n point1 = points[0];\r\n }\r\n else {\r\n point1 = points[i + 1];\r\n }\r\n newPoints.push(point0);\r\n for (var p = 1; p < addToSegmentCount; p++) {\r\n var percent = p / addToSegmentCount;\r\n var extraPoint = { x: point0.x + (point1.x - point0.x) * percent, y: point0.y + (point1.y - point0.y) * percent };\r\n newPoints.push(extraPoint);\r\n }\r\n // stop adding in case we already added more than left in original\r\n if (newPoints.length + points.length - i == mustHaveCount) {\r\n addToSegmentCount = 0;\r\n }\r\n }\r\n if (newPoints.length < mustHaveCount && points.length > 0) {\r\n var lastPoint = points[points.length - 1];\r\n for (var p = newPoints.length; p < mustHaveCount; p++) {\r\n // add same as last\r\n newPoints.push({ x: lastPoint.x, y: lastPoint.y });\r\n }\r\n }\r\n return newPoints;\r\n };\r\n /**\r\n * Morphs polygon into a rectangular polygon.\r\n *\r\n * @param width Width of the target rectangle (px)\r\n * @param height Height of the target rectangle (px)\r\n * @param duration Duration (ms)\r\n * @param easing Easing function\r\n * @return Animation\r\n */\r\n Morpher.prototype.morphToRectangle = function (width, height, duration, easing) {\r\n var points = this.morphable.points;\r\n this.sortPoints(points);\r\n this._morphFromPointsReal = [];\r\n this._morphToPointsReal = [];\r\n if (!$type.hasValue(duration)) {\r\n duration = this.morphDuration;\r\n }\r\n if (!$type.hasValue(easing)) {\r\n easing = this.morphEasing;\r\n }\r\n //\t\tlet biggestBBox: IRectangle = this._bboxes[this._biggestIndex];\r\n // surface\r\n for (var i = 0, len = points.length; i < len; i++) {\r\n var surface = points[i][0];\r\n var hole = points[i][1];\r\n this._morphFromPointsReal[i] = [];\r\n this._morphToPointsReal[i] = [];\r\n if (surface) {\r\n var toPoints = surface;\r\n var fromPoints = surface;\r\n var bbox = this._bboxes[i];\r\n // we only work with first area. TODO: maybe we should find the biggest one?\r\n if (this.morphToSingle) {\r\n //if (i != this._biggestIndex) {\r\n //\tbbox = { x: biggestBBox.x + biggestBBox.width / 2, y: biggestBBox.y + biggestBBox.height / 2, width: 0, height: 0 };\r\n //}\r\n }\r\n var x = bbox.x;\r\n var y = bbox.y;\r\n var realWidth = width;\r\n var realHeight = height;\r\n if (!$type.isNumber(realWidth)) {\r\n realWidth = bbox.width;\r\n }\r\n if (!$type.isNumber(realHeight)) {\r\n realHeight = bbox.height;\r\n }\r\n toPoints = [{ x: x, y: y }, { x: x + realWidth, y: y }, { x: x + realWidth, y: y + realHeight }, { x: x, y: y + realHeight }];\r\n toPoints = this.addPoints(toPoints, surface.length);\r\n // if polygon has less points then count, add\r\n if (surface.length < 4) {\r\n for (var i_2 = surface.length; i_2 < 4; i_2++) {\r\n toPoints.push({ x: surface[i_2].x, y: surface[i_2].y });\r\n }\r\n }\r\n if (hole && hole.length > 0) {\r\n var middleX = bbox.x + bbox.width / 2;\r\n var middleY = bbox.y + bbox.height / 2;\r\n for (var i_3 = 0, hlen = hole.length; i_3 < hlen; i_3++) {\r\n toPoints.push({ x: middleX, y: middleY });\r\n }\r\n }\r\n this._morphFromPointsReal[i][0] = fromPoints;\r\n this._morphToPointsReal[i][0] = toPoints;\r\n }\r\n }\r\n this.morphable.currentPoints = this._morphFromPointsReal;\r\n var animation = new Animation(this, { property: \"morphProgress\", from: 0, to: 1 }, duration, easing);\r\n this._disposers.push(animation);\r\n animation.start();\r\n return animation;\r\n };\r\n Object.defineProperty(Morpher.prototype, \"morphProgress\", {\r\n /**\r\n * Returns the progress of morph transition.\r\n *\r\n * @return Progress (0-1)\r\n */\r\n get: function () {\r\n return this._morphProgress;\r\n },\r\n /**\r\n * Progress of the morph transition.\r\n *\r\n * Setting this will also trigger actual transformation.\r\n *\r\n * @param value Progress (0-1)\r\n */\r\n set: function (value) {\r\n this._morphProgress = value;\r\n var currentPoints = [];\r\n if (value != null) {\r\n var fromPoints = this._morphFromPointsReal;\r\n var toPoints = this._morphToPointsReal;\r\n if (fromPoints != null && toPoints != null) {\r\n for (var i = 0, len = fromPoints.length; i < len; i++) {\r\n var currentArea = [];\r\n currentPoints.push(currentArea);\r\n var surfaceFrom = fromPoints[i][0];\r\n var holeFrom = fromPoints[i][1];\r\n var surfaceTo = toPoints[i][0];\r\n var holeTo = toPoints[i][1];\r\n if (surfaceFrom && surfaceFrom.length > 0 && surfaceTo && surfaceTo.length > 0) {\r\n var currentSurface = [];\r\n for (var i_4 = 0, slen = surfaceFrom.length; i_4 < slen; i_4++) {\r\n var point0 = surfaceFrom[i_4];\r\n var point1 = surfaceTo[i_4];\r\n var currentPoint = { x: point0.x + (point1.x * this.scaleRatio - point0.x) * value, y: point0.y + (point1.y * this.scaleRatio - point0.y) * value };\r\n currentSurface.push(currentPoint);\r\n }\r\n currentArea[0] = currentSurface;\r\n }\r\n if (holeFrom && holeFrom.length > 0 && holeTo && holeTo.length > 0) {\r\n var currentHole = [];\r\n for (var i_5 = 0, hlen = holeFrom.length; i_5 < hlen; i_5++) {\r\n var point0 = holeFrom[i_5];\r\n var point1 = holeTo[i_5];\r\n var currentPoint = { x: point0.x + (point1.x * this.scaleRatio - point0.x) * value, y: point0.y + (point1.y * this.scaleRatio - point0.y) * value };\r\n currentHole.push(currentPoint);\r\n }\r\n currentArea[1] = currentHole;\r\n }\r\n }\r\n }\r\n }\r\n this.morphable.currentPoints = currentPoints;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Restores the polygon to its original appearance.\r\n *\r\n * @param duration Duration (ms)\r\n * @param easing Easing function\r\n * @return Animation\r\n */\r\n Morpher.prototype.morphBack = function (duration, easing) {\r\n this._morphToPointsReal = this._morphFromPointsReal;\r\n this._morphFromPointsReal = this.morphable.currentPoints;\r\n if (!$type.hasValue(duration)) {\r\n duration = this.morphDuration;\r\n }\r\n if (!$type.hasValue(easing)) {\r\n easing = this.morphEasing;\r\n }\r\n var animation = new Animation(this, { property: \"morphProgress\", from: 0, to: 1 }, duration, easing);\r\n this._disposers.push(animation);\r\n animation.start();\r\n return animation;\r\n };\r\n Object.defineProperty(Morpher.prototype, \"animations\", {\r\n /**\r\n * Returns a list of morph animations currently being played.\r\n *\r\n * @return List of animations\r\n */\r\n get: function () {\r\n if (!this._animations) {\r\n this._animations = [];\r\n this._disposers.push(new AnimationDisposer(this._animations));\r\n }\r\n return this._animations;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Morpher;\r\n}(BaseObject));\r\nexport { Morpher };\r\n//# sourceMappingURL=Morpher.js.map","/**\r\n * Polygon module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Sprite } from \"../Sprite\";\r\nimport { Morpher } from \"../utils/Morpher\";\r\nimport { registry } from \"../Registry\";\r\nimport * as $path from \"../rendering/Path\";\r\nimport * as $type from \"../utils/Type\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Draws a polygon.\r\n *\r\n * @see {@link IPolygonEvents} for a list of available events\r\n * @see {@link IPolygonAdapters} for a list of available Adapters\r\n */\r\nvar Polygon = /** @class */ (function (_super) {\r\n __extends(Polygon, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Polygon() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"Polygon\";\r\n _this.element = _this.paper.add(\"path\");\r\n _this.shapeRendering = \"auto\";\r\n _this._currentPoints = [];\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(Polygon.prototype, \"points\", {\r\n /**\r\n * @return Polygon points\r\n */\r\n get: function () {\r\n var points = this.getPropertyValue(\"points\");\r\n var path = this.path;\r\n if (path && (!points || points.length == 0)) {\r\n var valueStr = path.slice(1, path.length - 1);\r\n var segments = valueStr.split(\"ZM\");\r\n for (var s = 0; s < segments.length; s++) {\r\n var segment = segments[s];\r\n if (segment.length > 0) {\r\n var areaHole = segment.split(\"M\");\r\n var areaArr = areaHole[0];\r\n var holeArr = areaHole[1];\r\n if (areaArr && areaArr.length > 0) {\r\n var pointsArr = areaArr.split(\"L\");\r\n if (pointsArr.length > 0) {\r\n var area = [];\r\n var areaAndHole = [area];\r\n points.push(areaAndHole);\r\n for (var p = 0; p < pointsArr.length; p++) {\r\n var coords = pointsArr[p].split(\",\");\r\n area.push({ x: +coords[0], y: +coords[1] });\r\n }\r\n if (holeArr && holeArr.length > 0) {\r\n var pointsArr_1 = holeArr.split(\"L\");\r\n if (pointsArr_1.length > 0) {\r\n var hole = [];\r\n areaAndHole.push(hole);\r\n for (var p = pointsArr_1.length - 1; p >= 0; p--) {\r\n var coords = pointsArr_1[p].split(\",\");\r\n hole.push({ x: +coords[0], y: +coords[1] });\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n this.setPropertyValue(\"points\", points);\r\n this._currentPoints = points;\r\n }\r\n return points;\r\n },\r\n /**\r\n * An array of X/Y coordinates for each elbow of the polygon.\r\n *\r\n * @todo Example\r\n * @param points Polygon points\r\n */\r\n set: function (points) {\r\n this.setPropertyValue(\"points\", points, true);\r\n this._currentPoints = points;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Polygon.prototype, \"currentPoints\", {\r\n /**\r\n * @return Polygon points\r\n */\r\n get: function () {\r\n if ((!this._currentPoints || this._currentPoints.length == 0) && this.path) {\r\n this._currentPoints = this.points;\r\n }\r\n return this._currentPoints;\r\n },\r\n /**\r\n * Current points. Used when morphing the element, so that original `points`\r\n * are not overwritten.\r\n *\r\n * @param points Polygon points\r\n */\r\n set: function (points) {\r\n if (this._currentPoints != points) {\r\n this._currentPoints = points;\r\n this.draw();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Draws the element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Polygon.prototype.draw = function () {\r\n var path = \"\";\r\n var points = this._currentPoints;\r\n var left;\r\n var right;\r\n var top;\r\n var bottom;\r\n if (points.length > 0) {\r\n // separate areas\r\n for (var i = 0, len = points.length; i < len; i++) {\r\n // surface\r\n var surface = points[i][0];\r\n var hole = points[i][1];\r\n if (surface && surface.length > 0) {\r\n var point = surface[0];\r\n path += $path.moveTo(point);\r\n for (var s = 0; s < surface.length; s++) {\r\n point = surface[s];\r\n path += $path.lineTo(point);\r\n if (!$type.isNumber(right) || (right < point.x)) {\r\n right = point.x;\r\n }\r\n if (!$type.isNumber(left) || (left > point.x)) {\r\n left = point.x;\r\n }\r\n if (!$type.isNumber(top) || (top > point.y)) {\r\n top = point.y;\r\n }\r\n if (!$type.isNumber(bottom) || (bottom < point.y)) {\r\n bottom = point.y;\r\n }\r\n }\r\n }\r\n // hole\r\n if (hole && hole.length > 0) {\r\n var point = hole[0];\r\n path += $path.moveTo(point);\r\n for (var h = 0, hlen = hole.length; h < hlen; h++) {\r\n point = hole[h];\r\n path += $path.lineTo(point);\r\n }\r\n }\r\n }\r\n if (path) {\r\n path += $path.closePath();\r\n }\r\n this.bbox.x = left;\r\n this.bbox.y = top;\r\n this.bbox.width = right - left;\r\n this.bbox.height = bottom - top;\r\n _super.prototype.setPath.call(this, path);\r\n }\r\n };\r\n /**\r\n * @ignore\r\n */\r\n Polygon.prototype.setPath = function (value) {\r\n if (_super.prototype.setPath.call(this, value)) {\r\n this.points = [];\r\n this._bbox = this.group.getBBox();\r\n return true;\r\n }\r\n return false;\r\n };\r\n /**\r\n * Measures element\r\n */\r\n Polygon.prototype.measureElement = function () {\r\n // Overriding to avoid extra measurement.\r\n };\r\n Object.defineProperty(Polygon.prototype, \"centerPoint\", {\r\n /**\r\n * A calculated center point for the shape.\r\n *\r\n * @readonly\r\n * @return Center\r\n */\r\n get: function () {\r\n return { x: this.bbox.x + this.bbox.width / 2, y: this.bbox.y + this.bbox.height / 2 };\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Polygon.prototype, \"morpher\", {\r\n /**\r\n * A [[Morpher]] instance that is used to morph polygon into some other\r\n * shape.\r\n *\r\n * @readonly\r\n * @return Morpher instance\r\n */\r\n get: function () {\r\n if (!this._morpher) {\r\n this._morpher = new Morpher(this);\r\n this._disposers.push(this._morpher);\r\n }\r\n return this._morpher;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Polygon;\r\n}(Sprite));\r\nexport { Polygon };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Polygon\"] = Polygon;\r\n//# sourceMappingURL=Polygon.js.map","/**\r\n * Polyspline (smoothed line) module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Polyline } from \"./Polyline\";\r\nimport { registry } from \"../Registry\";\r\nimport * as $math from \"../../core/utils/Math\";\r\nimport * as $type from \"../../core/utils/Type\";\r\nimport * as $path from \"../../core/rendering/Path\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Draws a polysline. (smoothed multi-sigment line)\r\n *\r\n * @see {@link IPolysplineEvents} for a list of available events\r\n * @see {@link IPolysplineAdapters} for a list of available Adapters\r\n */\r\nvar Polyspline = /** @class */ (function (_super) {\r\n __extends(Polyspline, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Polyspline() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"Polyspline\";\r\n _this.tensionX = 0.5;\r\n _this.tensionY = 0.5;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Creats and adds an SVG path for the arc.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Polyspline.prototype.makePath = function () {\r\n this._distance = 0;\r\n var segments = this.segments;\r\n var tensionX = this.tensionX;\r\n var tensionY = this.tensionY;\r\n this.allPoints = [];\r\n if (segments && segments.length > 0) {\r\n var path = \"\";\r\n this._realSegments = [];\r\n for (var i = 0, len = segments.length; i < len; i++) {\r\n var points = segments[i];\r\n var realPoints = [];\r\n this._realSegments.push(realPoints);\r\n if (points.length > 0) {\r\n var first = points[0];\r\n var last = points[points.length - 1];\r\n var closed_1 = false;\r\n if ($math.round(first.x, 3) == $math.round(last.x) && $math.round(first.y) == $math.round(last.y)) {\r\n closed_1 = true;\r\n }\r\n path += $path.moveTo(points[0]);\r\n for (var p = 0; p < points.length - 1; p++) {\r\n var p0 = points[p - 1];\r\n var p1 = points[p];\r\n var p2 = points[p + 1];\r\n var p3 = points[p + 2];\r\n if (p === 0) {\r\n p0 = points[p];\r\n }\r\n else if (p == points.length - 2) {\r\n p3 = points[p + 1];\r\n }\r\n if (!p3) {\r\n p3 = p2;\r\n }\r\n if (p === 0) {\r\n if (closed_1) {\r\n p0 = points[points.length - 2];\r\n }\r\n else {\r\n p0 = points[i];\r\n }\r\n }\r\n else if (p == points.length - 2) {\r\n if (closed_1) {\r\n p3 = points[1];\r\n }\r\n else {\r\n p3 = points[p + 1];\r\n }\r\n }\r\n var controlPointA = $math.getCubicControlPointA(p0, p1, p2, p3, tensionX, tensionY);\r\n var controlPointB = $math.getCubicControlPointB(p0, p1, p2, p3, tensionX, tensionY);\r\n path += $path.cubicCurveTo(p2, controlPointA, controlPointB);\r\n // now split to small segments so that we could have positionToPoint later\r\n var stepCount = Math.ceil($math.getCubicCurveDistance(p1, p2, controlPointA, controlPointB, 20)) * 1.2;\r\n var prevPoint = p1;\r\n if (stepCount > 0) {\r\n // not good for curved charts\r\n //this.allPoints[0] = { x: points[0].x, y: points[0].y, angle: $math.getAngle(points[0], points[1]) };\r\n //realPoints.push(this.allPoints[0]);\r\n for (var s = 0; s <= stepCount; s++) {\r\n var point = $math.getPointOnCubicCurve(p1, p2, controlPointA, controlPointB, s / stepCount);\r\n if (point.x == prevPoint.x && point.y == prevPoint.y) {\r\n continue;\r\n }\r\n realPoints.push(point);\r\n var angle = $math.round($math.getAngle(prevPoint, point), 5);\r\n //this.allPoints.push({ x: point.x, y: point.y, angle: angle });\r\n this._distance += $math.getDistance(prevPoint, point);\r\n this.allPoints[Math.floor(this._distance)] = { x: point.x, y: point.y, angle: angle };\r\n prevPoint = point;\r\n }\r\n }\r\n else {\r\n realPoints.push(p0);\r\n }\r\n }\r\n }\r\n var allPoints = this.allPoints;\r\n if (allPoints.length > 1) {\r\n for (var i_1 = 0; i_1 < allPoints.length; i_1++) {\r\n if (!allPoints[i_1]) {\r\n if (i_1 > 1) {\r\n allPoints[i_1] = allPoints[i_1 - 1];\r\n }\r\n else {\r\n for (var k = 1; k < allPoints.length; k++) {\r\n if (allPoints[k]) {\r\n allPoints[i_1] = allPoints[k];\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n this.path = path;\r\n }\r\n };\r\n /**\r\n * Returns an index of the point that is closest to specified coordinates.\r\n *\r\n * @param point Reference point\r\n * @return Index\r\n */\r\n Polyspline.prototype.getClosestPointIndex = function (point) {\r\n var points = this.allPoints;\r\n var index;\r\n var closest = Infinity;\r\n if (points.length > 1) {\r\n for (var p = 1; p < points.length; p++) {\r\n var distance = $math.getDistance(point, points[p]);\r\n if (distance < closest) {\r\n index = p;\r\n closest = distance;\r\n }\r\n }\r\n }\r\n return index;\r\n };\r\n Object.defineProperty(Polyspline.prototype, \"tensionX\", {\r\n /**\r\n * @return Tension\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"tensionX\");\r\n },\r\n /**\r\n * Horizontal tension for the spline.\r\n *\r\n * Used by the line smoothing algorithm.\r\n *\r\n * @default 0.5\r\n * @param value Tension\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"tensionX\", value);\r\n this.makePath();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Polyspline.prototype, \"tensionY\", {\r\n /**\r\n * @return Tension\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"tensionY\");\r\n },\r\n /**\r\n * Vertical tension for the spline.\r\n *\r\n * Used by the line smoothing algorithm.\r\n *\r\n * @default 0.5\r\n * @param value Tensions\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"tensionY\", value, true);\r\n this.makePath();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Converts relative position along the line (0-1) into pixel coordinates.\r\n *\r\n * @param position Position (0-1)\r\n * @return Coordinates\r\n */\r\n Polyspline.prototype.positionToPoint = function (position, extend) {\r\n var deltaAngle = 0;\r\n var allPoints = this.allPoints;\r\n var len = allPoints.length;\r\n if (!$type.isNumber(position)) {\r\n position = 0;\r\n }\r\n if (len > 1) {\r\n if (extend && len > 3) {\r\n if (position < 0) {\r\n if (position < -0.01) {\r\n position = -0.01;\r\n }\r\n var f0 = allPoints[0];\r\n var f1 = allPoints[1];\r\n var x = f0.x - (f0.x - f1.x) * len * position;\r\n var y = f0.y - (f0.y - f1.y) * len * position;\r\n return { x: x, y: y, angle: $math.getAngle(f0, f1) };\r\n }\r\n else if (position > 1) {\r\n if (position > 1.01) {\r\n position = 1.01;\r\n }\r\n var f0 = allPoints[allPoints.length - 2];\r\n var f1 = allPoints[allPoints.length - 3];\r\n var x = f0.x + (f0.x - f1.x) * len * (position - 1);\r\n var y = f0.y + (f0.y - f1.y) * len * (position - 1);\r\n return { x: x, y: y, angle: $math.getAngle(f0, { x: x, y: y }) };\r\n }\r\n else if (position == 1) {\r\n var point_1 = allPoints[allPoints.length - 1];\r\n return { x: point_1.x, y: point_1.y, angle: point_1.angle };\r\n }\r\n }\r\n else {\r\n if (position < 0) {\r\n position = Math.abs(position);\r\n deltaAngle = 180;\r\n }\r\n if (position >= 1) {\r\n position = 0.9999999999999;\r\n }\r\n }\r\n var point = allPoints[Math.floor(position * len)];\r\n return { x: point.x, y: point.y, angle: point.angle + deltaAngle };\r\n }\r\n else if (len == 1) {\r\n var point = allPoints[0];\r\n return { x: point.x, y: point.y, angle: point.angle };\r\n }\r\n else {\r\n return { x: 0, y: 0, angle: 0 };\r\n }\r\n };\r\n return Polyspline;\r\n}(Polyline));\r\nexport { Polyspline };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Polyspline\"] = Polyspline;\r\n//# sourceMappingURL=Polyspline.js.map","/**\r\n * Slice module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../Container\";\r\nimport { Sprite } from \"../Sprite\";\r\nimport { registry } from \"../Registry\";\r\nimport * as $math from \"../utils/Math\";\r\nimport * as $path from \"../rendering/Path\";\r\nimport * as $type from \"../utils/Type\";\r\nimport * as $utils from \"../utils/Utils\";\r\nimport { Percent } from \"../utils/Percent\";\r\nimport { RadialGradient } from \"../rendering/fills/RadialGradient\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Draws a wedged semi-circle - slice. Usually used for Pie/Donut charts.\r\n *\r\n * @see {@link ISliceEvents} for a list of available events\r\n * @see {@link ISliceAdapters} for a list of available Adapters\r\n */\r\nvar Slice = /** @class */ (function (_super) {\r\n __extends(Slice, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Slice() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"Slice\";\r\n // Set defaults\r\n _this.setPropertyValue(\"cornerRadius\", 0);\r\n _this.setPropertyValue(\"startAngle\", 0);\r\n _this.setPercentProperty(\"innerRadius\", 0);\r\n _this.setPercentProperty(\"radius\", 0);\r\n _this.setPropertyValue(\"arc\", 0);\r\n _this.setPropertyValue(\"shiftRadius\", 0);\r\n _this.strokeOpacity = 1;\r\n _this.setPropertyValue(\"layout\", \"none\");\r\n // Create a slice wedge element\r\n _this.slice = _this.createChild(Sprite);\r\n _this.slice.isMeasured = false;\r\n _this._disposers.push(_this.slice);\r\n //this.element.attr({ \"stroke-linejoin\": \"round\" });\r\n //this.element.attr({ \"stroke-linecap\": \"round\" });\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Draws the element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Slice.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n var radiusY = this.radiusY;\r\n if (this.radius > 0 && radiusY == 0) {\r\n radiusY = 0.01;\r\n }\r\n this.slice.path = $path.arc(this.startAngle, this.arc, this.radius, this.pixelInnerRadius, radiusY, this.cornerRadius, this.innerCornerRadius);\r\n this.slice.invalidate();\r\n this.shiftRadius = this.shiftRadius;\r\n if (this.realFill instanceof RadialGradient) {\r\n this.updateGradient(this.realFill);\r\n }\r\n if (this.realStroke instanceof RadialGradient) {\r\n this.updateGradient(this.realStroke);\r\n }\r\n };\r\n Slice.prototype.updateGradient = function (gradient) {\r\n gradient.element.attr({ \"gradientUnits\": \"userSpaceOnUse\" });\r\n gradient.element.attr({ \"r\": this.radius });\r\n gradient.cx = 0;\r\n gradient.cy = 0;\r\n gradient.element.attr({ radius: this.radius });\r\n };\r\n Object.defineProperty(Slice.prototype, \"bbox\", {\r\n /**\r\n * Returns bounding box (square) for this element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n get: function () {\r\n if (this.definedBBox) {\r\n return this.definedBBox;\r\n }\r\n if (this.isMeasured) {\r\n var innerRect = $math.getArcRect(this.startAngle, this.startAngle + this.arc, this.pixelInnerRadius);\r\n var outerRect = $math.getArcRect(this.startAngle, this.startAngle + this.arc, this.radius);\r\n return $math.getCommonRectangle([innerRect, outerRect]);\r\n }\r\n else {\r\n return { x: 0, y: 0, width: 0, height: 0 };\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slice.prototype, \"startAngle\", {\r\n /**\r\n * @return Angle (0-360)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"startAngle\");\r\n },\r\n /**\r\n * The angle at which left edge of the slice is drawn. (0-360)\r\n *\r\n * 0 is to the right of the center.\r\n *\r\n * @param value Angle (0-360)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"startAngle\", $math.normalizeAngle(value), true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slice.prototype, \"arc\", {\r\n /**\r\n * @return [description]\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"arc\");\r\n },\r\n /**\r\n * [arc description]\r\n *\r\n * @todo Description\r\n * @param value [description]\r\n */\r\n set: function (value) {\r\n if (!$type.isNumber(value)) {\r\n value = 0;\r\n }\r\n this.setPropertyValue(\"arc\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slice.prototype, \"radius\", {\r\n /**\r\n * @return Radius (px)\r\n */\r\n get: function () {\r\n var radius = this.getPropertyValue(\"radius\");\r\n if (!$type.isNumber(radius)) {\r\n radius = 0;\r\n }\r\n return radius;\r\n },\r\n /**\r\n * Radius of the slice in pixels.\r\n *\r\n * @param value Radius (px)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"radius\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slice.prototype, \"radiusY\", {\r\n /**\r\n * @return Vertical radius (0-1)\r\n */\r\n get: function () {\r\n var value = this.getPropertyValue(\"radiusY\");\r\n if (!$type.isNumber(value)) {\r\n value = this.radius;\r\n }\r\n return value;\r\n },\r\n /**\r\n * Vertical radius for creating skewed slices.\r\n *\r\n * This is relevant to `radius`, e.g. 0.5 will set vertical radius to half\r\n * the `radius`.\r\n *\r\n * @param value Vertical radius (0-1)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"radiusY\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slice.prototype, \"innerRadius\", {\r\n /**\r\n * @return Radius (px or %)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"innerRadius\");\r\n },\r\n /**\r\n * Inner radius of the slice for creating cut out (donut) slices.\r\n *\r\n * @default 0\r\n * @param value Radius (px or %)\r\n */\r\n set: function (value) {\r\n this.setPercentProperty(\"innerRadius\", value, true, false, 10, false);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slice.prototype, \"pixelInnerRadius\", {\r\n /**\r\n * @return Radius px\r\n */\r\n get: function () {\r\n return $utils.relativeToValue(this.innerRadius, this.radius);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slice.prototype, \"cornerRadius\", {\r\n /**\r\n * @return Radius (px)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"cornerRadius\");\r\n },\r\n /**\r\n * Radius of slice's outer corners in pixels.\r\n *\r\n * @default 0\r\n * @param value Radius (px)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"cornerRadius\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slice.prototype, \"innerCornerRadius\", {\r\n /**\r\n * @return Radius (px)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"innerCornerRadius\");\r\n },\r\n /**\r\n * Radius of slice's inner corners in pixels.\r\n *\r\n * @default 0\r\n * @param value Radius (px)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"innerCornerRadius\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slice.prototype, \"shiftRadius\", {\r\n /**\r\n * @return Radius shift\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"shiftRadius\");\r\n },\r\n /**\r\n * Indicates how far (relatively to center) a slice should be moved.\r\n *\r\n * The value is relative to the radius of the slice. Meaning 0 no shift,\r\n * 1 - slice shifted outside by whole of its radius.\r\n *\r\n * @param value Radius shift\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"shiftRadius\", value);\r\n value = this.getPropertyValue(\"shiftRadius\");\r\n this.dx = value * this.radius * this.ix;\r\n this.dy = value * this.radiusY * this.iy;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slice.prototype, \"ix\", {\r\n /**\r\n * [ix description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @return [description]\r\n */\r\n get: function () {\r\n return $math.cos(this.middleAngle);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slice.prototype, \"iy\", {\r\n /**\r\n * [iy description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @return [description]\r\n */\r\n get: function () {\r\n return $math.sin(this.middleAngle);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slice.prototype, \"middleAngle\", {\r\n /**\r\n * An angle of the slice's middle.\r\n *\r\n * @ignore Exclude from docs\r\n * @return Angle\r\n */\r\n get: function () {\r\n return this.startAngle + this.arc / 2;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * X coordinate for the slice tooltip.\r\n *\r\n * @return X\r\n */\r\n Slice.prototype.getTooltipX = function () {\r\n var value = this.getPropertyValue(\"tooltipX\");\r\n if ($type.isNumber(value)) {\r\n return value;\r\n }\r\n var p = 0.5;\r\n if (value instanceof Percent) {\r\n p = value.value;\r\n }\r\n var innerRadius = $utils.relativeToValue(this.innerRadius, this.radius);\r\n return this.ix * (innerRadius + (this.radius - innerRadius) * p);\r\n };\r\n /**\r\n * Y coordinate for the slice tooltip.\r\n *\r\n * @return Y\r\n */\r\n Slice.prototype.getTooltipY = function () {\r\n var value = this.getPropertyValue(\"tooltipY\");\r\n if ($type.isNumber(value)) {\r\n return value;\r\n }\r\n var p = 0.5;\r\n if (value instanceof Percent) {\r\n p = value.value;\r\n }\r\n var innerRadius = $utils.relativeToValue(this.innerRadius, this.radius);\r\n return this.iy * (innerRadius + (this.radius - innerRadius) * p) + this.slice.dy;\r\n };\r\n return Slice;\r\n}(Container));\r\nexport { Slice };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Slice\"] = Slice;\r\n//# sourceMappingURL=Slice.js.map","/**\r\n * Preloader module.\r\n *\r\n * Preloader is a progress indicator.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../Container\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport { Slice } from \"./Slice\";\r\nimport { Label } from \"./Label\";\r\nimport { registry } from \"../Registry\";\r\nimport { percent } from \"../../core/utils/Percent\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A class used to draw and display progress indicator.\r\n *\r\n * @see {@link IPreloaderEvents} for a list of available events\r\n * @see {@link IPreloaderAdapters} for a list of available Adapters\r\n */\r\nvar Preloader = /** @class */ (function (_super) {\r\n __extends(Preloader, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Preloader() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"Preloader\";\r\n // Set dimensions\r\n _this.width = percent(100);\r\n _this.height = percent(100);\r\n var interfaceColors = new InterfaceColorSet();\r\n // Create main container\r\n var sliceContainer = _this.createChild(Container);\r\n sliceContainer.shouldClone = false;\r\n // Add background (100%) slice\r\n var backgroundSlice = sliceContainer.createChild(Slice);\r\n backgroundSlice.shouldClone = false;\r\n backgroundSlice.radius = 53;\r\n backgroundSlice.arc = 360;\r\n backgroundSlice.fill = interfaceColors.getFor(\"fill\");\r\n backgroundSlice.fillOpacity = 0.8;\r\n backgroundSlice.innerRadius = 42;\r\n backgroundSlice.isMeasured = false;\r\n _this.backgroundSlice = backgroundSlice;\r\n // Add progress slice\r\n var progressSlice = sliceContainer.createChild(Slice);\r\n progressSlice.shouldClone = false;\r\n progressSlice.radius = 50;\r\n progressSlice.innerRadius = 45;\r\n progressSlice.fill = interfaceColors.getFor(\"alternativeBackground\");\r\n progressSlice.fillOpacity = 0.2;\r\n progressSlice.isMeasured = false;\r\n _this.progressSlice = progressSlice;\r\n // Add text label element\r\n var label = sliceContainer.createChild(Label);\r\n label.shouldClone = false;\r\n label.horizontalCenter = \"middle\";\r\n label.verticalCenter = \"middle\";\r\n label.isMeasured = false;\r\n label.fill = interfaceColors.getFor(\"text\");\r\n label.align = \"center\";\r\n label.valign = \"middle\";\r\n label.textAlign = \"middle\";\r\n label.fillOpacity = 0.4;\r\n _this.label = label;\r\n // Set defaults\r\n _this.background.opacity = 1;\r\n _this.background.fill = interfaceColors.getFor(\"background\");\r\n _this.contentAlign = \"center\";\r\n _this.contentValign = \"middle\";\r\n _this.delay = 300;\r\n // Create hidden state\r\n var hiddenState = _this.states.create(\"hidden\");\r\n hiddenState.properties.opacity = 0;\r\n // Hide by default\r\n _this.visible = false;\r\n _this.hide(0);\r\n _this.__disabled = true;\r\n // Make it disposable\r\n // @todo Maybe it's enough to just dispose `sliceContainer`?\r\n _this._disposers.push(_this.backgroundSlice);\r\n _this._disposers.push(_this.progressSlice);\r\n _this._disposers.push(_this.label);\r\n _this._disposers.push(sliceContainer);\r\n return _this;\r\n }\r\n Object.defineProperty(Preloader.prototype, \"progress\", {\r\n /**\r\n * @return Progress (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"progress\");\r\n },\r\n /**\r\n * Current preload progress. (0-1)\r\n *\r\n * * 0 - 0%\r\n * * 0.5 - 50%\r\n * * 1 - 100%\r\n *\r\n * Setting this to a value less than 1, will automatically reveal the\r\n * preloader, while setting it to 1 (100%) will hide it.\r\n *\r\n * @param value Progress (0-1)\r\n */\r\n set: function (value) {\r\n var _this = this;\r\n this.__disabled = false;\r\n this.validateLayout(); // show not in center without this\r\n this.setPropertyValue(\"progress\", value);\r\n /*if (!this.visible && value == 1) {\r\n return;\r\n }*/\r\n this.progressSlice.arc = 360 * value;\r\n if (this.label) {\r\n this.label.text = Math.round(value * 100) + \"%\";\r\n }\r\n if (value >= 1) {\r\n // Cancel the timeout\r\n if (this._started) {\r\n this._started = undefined;\r\n }\r\n // TODO remove closure ?\r\n registry.events.once(\"enterframe\", function () {\r\n var animation = _this.hide();\r\n if (animation && !animation.isFinished()) {\r\n animation.events.once(\"animationended\", function () {\r\n _this.__disabled = true;\r\n });\r\n }\r\n else {\r\n _this.__disabled = true;\r\n }\r\n });\r\n this.interactionsEnabled = false;\r\n this.setPropertyValue(\"progress\", 0);\r\n }\r\n else if (value > 0) {\r\n if (this.delay) {\r\n if (!this._started) {\r\n this._started = new Date().getTime();\r\n }\r\n else if ((this._started + this.delay) <= new Date().getTime()) {\r\n this.__disabled = false;\r\n this.show();\r\n this.interactionsEnabled = true;\r\n }\r\n }\r\n else {\r\n this.__disabled = false;\r\n this.show();\r\n this.interactionsEnabled = true;\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Preloader.prototype, \"delay\", {\r\n /**\r\n * @return Delay (ms)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"delay\");\r\n },\r\n /**\r\n * Delay display of preloader by X milliseconds.\r\n *\r\n * When loading starts (`progress` is set to <1) and finishes (`progress` is\r\n * set to 1) before `delay` ms, the loader is never shown.\r\n *\r\n * This is used to avoid brief flashing of the preload for very quick loads.\r\n *\r\n * @default 1000\r\n * @param value Delay (ms)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"delay\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Preloader;\r\n}(Container));\r\nexport { Preloader };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Preloader\"] = Preloader;\r\n//# sourceMappingURL=Preloader.js.map","/**\r\n * Resize button module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Button } from \"./Button\";\r\nimport { Sprite } from \"../Sprite\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport { registry } from \"../Registry\";\r\nimport * as $path from \"../rendering/Path\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creates a draggable resize/grip button.\r\n *\r\n * @see {@link IResizeButtonEvents} for a list of available events\r\n * @see {@link IResizeButtonAdapters} for a list of available Adapters\r\n */\r\nvar ResizeButton = /** @class */ (function (_super) {\r\n __extends(ResizeButton, _super);\r\n /**\r\n * Constructor\r\n */\r\n function ResizeButton() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"ResizeButton\";\r\n // Set defaults\r\n _this.orientation = \"horizontal\";\r\n _this.layout = \"absolute\";\r\n _this.horizontalCenter = \"middle\";\r\n _this.verticalCenter = \"middle\";\r\n _this.draggable = true;\r\n _this.padding(8, 8, 8, 8);\r\n _this.background.cornerRadius(20, 20, 20, 20);\r\n // Create an icon\r\n var icon = new Sprite();\r\n icon.element = _this.paper.add(\"path\");\r\n var path = $path.moveTo({ x: -2, y: -6 });\r\n path += $path.lineTo({ x: -2, y: 6 });\r\n path += $path.moveTo({ x: 2, y: -6 });\r\n path += $path.lineTo({ x: 2, y: 6 });\r\n icon.path = path;\r\n icon.pixelPerfect = true;\r\n icon.padding(0, 4, 0, 4);\r\n icon.stroke = new InterfaceColorSet().getFor(\"alternativeText\");\r\n icon.strokeOpacity = 0.7;\r\n //icon.align = \"center\";\r\n //icon.valign = \"middle\";\r\n _this.icon = icon;\r\n _this.label.dispose();\r\n _this.label = undefined;\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(ResizeButton.prototype, \"orientation\", {\r\n /**\r\n * Use for setting of direction (orientation) of the resize button.\r\n *\r\n * Available options: \"horizontal\", \"vertical\".\r\n *\r\n * @param value Orientation\r\n */\r\n set: function (value) {\r\n var icon = this.icon;\r\n if (icon) {\r\n if (value == \"horizontal\") {\r\n icon.rotation = 0;\r\n }\r\n else {\r\n icon.rotation = -90;\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return ResizeButton;\r\n}(Button));\r\nexport { ResizeButton };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"ResizeButton\"] = ResizeButton;\r\n//# sourceMappingURL=ResizeButton.js.map","/**\r\n * Zoom out button functionality.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Button } from \"./Button\";\r\nimport { Sprite } from \"../Sprite\";\r\nimport { registry } from \"../Registry\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport * as $path from \"../rendering/Path\";\r\nimport * as $type from \"../../core/utils/Type\";\r\nimport { MouseCursorStyle } from \"../../core/interaction/Mouse\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creates a zoom out button.\r\n *\r\n * @see {@link ICloseButtonEvents} for a list of available events\r\n * @see {@link ICloseButtonAdapters} for a list of available Adapters\r\n */\r\nvar CloseButton = /** @class */ (function (_super) {\r\n __extends(CloseButton, _super);\r\n /**\r\n * Constructor\r\n */\r\n function CloseButton() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"CloseButton\";\r\n _this.padding(8, 8, 8, 8);\r\n _this.showSystemTooltip = true;\r\n _this.width = 30;\r\n _this.height = 30;\r\n var interfaceColors = new InterfaceColorSet();\r\n _this.cursorOverStyle = MouseCursorStyle.pointer;\r\n var background = _this.background;\r\n background.cornerRadius(20, 20, 20, 20);\r\n var bgc = interfaceColors.getFor(\"background\");\r\n background.fill = bgc;\r\n background.stroke = interfaceColors.getFor(\"primaryButton\");\r\n background.strokeOpacity = 1;\r\n background.strokeWidth = 1;\r\n var downColor = interfaceColors.getFor(\"primaryButtonActive\");\r\n var bhs = background.states.getKey(\"hover\");\r\n bhs.properties.strokeWidth = 3;\r\n bhs.properties.fill = bgc;\r\n var bds = background.states.getKey(\"down\");\r\n bds.properties.stroke = downColor;\r\n bds.properties.fill = bgc;\r\n // Create an icon\r\n var icon = new Sprite();\r\n icon.element = _this.paper.add(\"path\");\r\n icon.stroke = background.stroke;\r\n _this.icon = icon;\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n CloseButton.prototype.validate = function () {\r\n _super.prototype.validate.call(this);\r\n var w = this.pixelWidth / 3;\r\n var h = this.pixelHeight / 3;\r\n var path = $path.moveTo({ x: -w / 2, y: -h / 2 });\r\n path += $path.lineTo({ x: w / 2, y: h / 2 });\r\n path += $path.moveTo({ x: w / 2, y: -h / 2 });\r\n path += $path.lineTo({ x: -w / 2, y: h / 2 });\r\n this.icon.path = path;\r\n this.invalidateLayout();\r\n };\r\n /**\r\n * Sets defaults that instantiate some objects that rely on parent, so they\r\n * cannot be set in constructor.\r\n */\r\n CloseButton.prototype.applyInternalDefaults = function () {\r\n _super.prototype.applyInternalDefaults.call(this);\r\n if (!$type.hasValue(this.readerTitle)) {\r\n this.readerTitle = this.language.translate(\"Close\");\r\n }\r\n };\r\n return CloseButton;\r\n}(Button));\r\nexport { CloseButton };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"CloseButton\"] = CloseButton;\r\n//# sourceMappingURL=CloseButton.js.map","/**\r\n * Functionality for drawing simple SwitchButtons.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../Container\";\r\nimport { Label } from \"./Label\";\r\nimport { Button } from \"../elements/Button\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport { Circle } from \"../../core/elements/Circle\";\r\nimport { percent } from \"../../core/utils/Percent\";\r\nimport { registry } from \"../Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * SwitchButton class is capable of drawing a simple rectangular SwitchButton with\r\n * optionally rounded corners and an icon in it.\r\n *\r\n * @see {@link ISwitchButtonEvents} for a list of available events\r\n * @see {@link ISwitchButtonAdapters} for a list of available Adapters\r\n */\r\nvar SwitchButton = /** @class */ (function (_super) {\r\n __extends(SwitchButton, _super);\r\n /**\r\n * Constructor\r\n */\r\n function SwitchButton() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"SwitchButton\";\r\n _this.tooltipY = 0;\r\n // Set defaults\r\n _this.layout = \"horizontal\";\r\n _this.contentAlign = \"center\";\r\n _this.contentValign = \"middle\";\r\n _this.padding(8, 16, 8, 16);\r\n _this.setStateOnChildren = true;\r\n _this.states.create(\"active\");\r\n var interfaceColors = new InterfaceColorSet();\r\n // Create the label element\r\n var leftLabel = new Label();\r\n leftLabel.fillOpacity = 0.3;\r\n var llas = leftLabel.states.create(\"active\");\r\n llas.properties.fillOpacity = 1;\r\n leftLabel.isActive = true;\r\n _this.leftLabel = leftLabel;\r\n var button = new Button();\r\n var circle = new Circle();\r\n button.contentValign = \"none\";\r\n button.padding(0, 0, 0, 0);\r\n circle.radius = 10;\r\n button.icon = circle;\r\n button.icon.valign = \"middle\";\r\n button.label = undefined;\r\n var p100 = percent(100);\r\n button.background.cornerRadius(p100, p100, p100, p100);\r\n button.width = circle.radius * 3.5;\r\n button.height = circle.radius * 2.1;\r\n button.marginLeft = 8;\r\n button.marginRight = 8;\r\n button.togglable = true;\r\n circle.dx = -circle.radius * 0.7;\r\n circle.fill = interfaceColors.getFor(\"primaryButton\");\r\n var hs = circle.states.create(\"hover\");\r\n hs.properties.fill = interfaceColors.getFor(\"primaryButtonHover\");\r\n var as = circle.states.create(\"active\");\r\n as.properties.fill = interfaceColors.getFor(\"primaryButtonActive\");\r\n as.properties.dx = circle.radius * 0.7;\r\n _this.switchButton = button;\r\n _this.events.on(\"toggled\", function () {\r\n _this.leftLabel.isActive = !_this.isActive;\r\n _this.rightLabel.isActive = _this.isActive;\r\n });\r\n // Create the label element\r\n var rightLabel = new Label();\r\n rightLabel.fillOpacity = 0.3;\r\n var rlas = rightLabel.states.create(\"active\");\r\n rlas.properties.fillOpacity = 1;\r\n _this.rightLabel = rightLabel;\r\n // Set up accessibility\r\n // A Button should be always focusable\r\n _this.role = \"button\";\r\n _this.focusable = true;\r\n rightLabel.valign = \"middle\";\r\n leftLabel.valign = \"middle\";\r\n button.valign = \"middle\";\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(SwitchButton.prototype, \"leftLabel\", {\r\n /**\r\n * @return Left label element\r\n */\r\n get: function () {\r\n return this._leftLabel;\r\n },\r\n /**\r\n * [[Label]] element to be used for left text.\r\n *\r\n * @param left label element\r\n */\r\n set: function (label) {\r\n if (this._leftLabel) {\r\n this.removeDispose(this._leftLabel);\r\n }\r\n this._leftLabel = label;\r\n if (label) {\r\n label.parent = this;\r\n label.interactionsEnabled = false;\r\n label.shouldClone = false;\r\n this._disposers.push(this._leftLabel);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(SwitchButton.prototype, \"rightLabel\", {\r\n /**\r\n * @return Rigth label element\r\n */\r\n get: function () {\r\n return this._rightLabel;\r\n },\r\n /**\r\n * [[Label]] element to be used for left text.\r\n *\r\n * @param rigth label element\r\n */\r\n set: function (label) {\r\n if (this._rightLabel) {\r\n this.removeDispose(this._rightLabel);\r\n }\r\n this._rightLabel = label;\r\n if (label) {\r\n label.parent = this;\r\n label.interactionsEnabled = false;\r\n label.shouldClone = false;\r\n this._disposers.push(this._rightLabel);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(SwitchButton.prototype, \"switch\", {\r\n /**\r\n * @ignore\r\n * @deprecated Use `switchButton` instead\r\n */\r\n get: function () {\r\n return this._switchButton;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(SwitchButton.prototype, \"switchButton\", {\r\n /**\r\n * @return Button\r\n */\r\n get: function () {\r\n return this._switchButton;\r\n },\r\n /**\r\n * A [[Button]] element for switch.\r\n *\r\n * @param Button\r\n */\r\n set: function (button) {\r\n if (this._switchButton) {\r\n this.removeDispose(this._switchButton);\r\n }\r\n this._switchButton = button;\r\n if (button) {\r\n button.parent = this;\r\n button.shouldClone = false;\r\n this._disposers.push(this._switchButton);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Copies properties and other attributes.\r\n *\r\n * @param source Source\r\n */\r\n SwitchButton.prototype.copyFrom = function (source) {\r\n _super.prototype.copyFrom.call(this, source);\r\n if (source.leftLabel) {\r\n this.leftLabel.copyFrom(source.leftLabel);\r\n }\r\n if (source.rightLabel) {\r\n this.rightLabel.copyFrom(source.rightLabel);\r\n }\r\n if (source.switchButton) {\r\n this.switchButton.copyFrom(source.switchButton);\r\n }\r\n };\r\n return SwitchButton;\r\n}(Container));\r\nexport { SwitchButton };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"SwitchButton\"] = SwitchButton;\r\n//# sourceMappingURL=SwitchButton.js.map","/**\r\n * Provides functionality used to build scrollbars.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../Container\";\r\nimport { ResizeButton } from \"../elements/ResizeButton\";\r\nimport { Button } from \"../elements/Button\";\r\nimport { getInteraction } from \"../interaction/Interaction\";\r\nimport { MouseCursorStyle } from \"../interaction/Mouse\";\r\nimport { RoundedRectangle } from \"../elements/RoundedRectangle\";\r\nimport { registry } from \"../Registry\";\r\nimport { keyboard } from \"../utils/Keyboard\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport { percent, Percent } from \"../utils/Percent\";\r\nimport * as $math from \"../utils/Math\";\r\nimport * as $ease from \"../utils/Ease\";\r\nimport * as $type from \"../utils/Type\";\r\nimport * as $utils from \"../utils/Utils\";\r\n;\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Scrollbar is a generic control allowing to select a range of values or pan\r\n * the selection.\r\n *\r\n * @see {@link IScrollbarEvents} for a list of available events\r\n * @see {@link IScrollbarAdapters} for a list of available Adapters\r\n */\r\nvar Scrollbar = /** @class */ (function (_super) {\r\n __extends(Scrollbar, _super);\r\n /**\r\n * Construtor\r\n */\r\n function Scrollbar() {\r\n var _this = _super.call(this) || this;\r\n /**\r\n * Previously selected lower (start) value.\r\n */\r\n _this._previousStart = 0;\r\n /**\r\n * Previously selected upper (end) value.\r\n */\r\n _this._previousEnd = 1;\r\n /**\r\n * A value of previously selected lower value, used for doubleclick function.\r\n */\r\n _this._prevStart = 0;\r\n /**\r\n * A value of previously selected upper value, used for doubleclick function.\r\n */\r\n _this._prevEnd = 1;\r\n /**\r\n * Indicates if the Scrollbar is currently \"busy\" (animating and or\r\n * performing zoom by user interaction).\r\n */\r\n _this._isBusy = false;\r\n /**\r\n * [_skipRangeEvents description]\r\n *\r\n * @todo Description\r\n */\r\n _this._skipRangeEvents = false;\r\n /**\r\n * Update the selection when dragging the grips.\r\n *\r\n * If set to `false` selection will be updated only when the grip is\r\n * released.\r\n *\r\n * @default true\r\n */\r\n _this.updateWhileMoving = true;\r\n _this.className = \"Scrollbar\";\r\n _this.minHeight = 12;\r\n _this.minWidth = 12;\r\n _this.animationDuration = 0;\r\n _this.animationEasing = $ease.cubicOut;\r\n _this.margin(10, 10, 10, 10);\r\n var interfaceColors = new InterfaceColorSet();\r\n // background is also container as it might contain graphs, grid, etc\r\n var background = _this.background;\r\n background.cornerRadius(10, 10, 10, 10);\r\n background.fill = interfaceColors.getFor(\"fill\");\r\n background.fillOpacity = 0.5;\r\n // Make system tooltips appear by default\r\n _this.showSystemTooltip = true;\r\n _this.startGrip = new ResizeButton();\r\n _this.endGrip = new ResizeButton();\r\n // Default orientation...\r\n // ... is set in `applyInternalDefaults()` because it accesses `language`\r\n // and should only be started to access when parent is set\r\n // Set events\r\n _this.events.on(\"transformed\", function () {\r\n _this.updateThumb();\r\n }, _this, false);\r\n // Initial positions\r\n _this.start = 0;\r\n _this.end = 1;\r\n // Set roles\r\n _this.role = \"scrollbar\";\r\n _this.thumb.role = \"slider\";\r\n _this.thumb.readerLive = \"polite\";\r\n _this.startGrip.role = \"slider\";\r\n _this.endGrip.role = \"slider\";\r\n // otherwise range changed won't be registered\r\n _this.events.once(\"inited\", function () {\r\n _this._previousStart = undefined;\r\n _this.dispatchRangeChange();\r\n }, undefined, false);\r\n _this.hideGrips = false;\r\n _this.orientation = \"horizontal\";\r\n // Min/max values for accessibility\r\n _this.setSVGAttribute({ \"aria-valuemin\": \"0\" });\r\n _this.setSVGAttribute({ \"aria-valuemax\": \"100\" });\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Sets defaults that instantiate some objects that rely on parent, so they\r\n * cannot be set in constructor.\r\n */\r\n Scrollbar.prototype.applyInternalDefaults = function () {\r\n _super.prototype.applyInternalDefaults.call(this);\r\n // Set screen reader tetxt accordingly\r\n if (this.orientation === \"horizontal\") {\r\n if (!$type.hasValue(this.readerTitle)) {\r\n this.readerTitle = this.language.translate(\"Use TAB to select grip buttons or left and right arrows to change selection\");\r\n }\r\n if (!$type.hasValue(this.thumb.readerDescription)) {\r\n this.thumb.readerDescription = this.language.translate(\"Use left and right arrows to move selection\");\r\n }\r\n if (!$type.hasValue(this.startGrip.readerDescription)) {\r\n this.startGrip.readerDescription = this.language.translate(\"Use left and right arrows to move left selection\");\r\n }\r\n if (!$type.hasValue(this.endGrip.readerDescription)) {\r\n this.endGrip.readerDescription = this.language.translate(\"Use left and right arrows to move right selection\");\r\n }\r\n this.readerOrientation = \"horizontal\";\r\n }\r\n else {\r\n if (!$type.hasValue(this.readerTitle)) {\r\n this.readerTitle = this.language.translate(\"Use TAB select grip buttons or up and down arrows to change selection\");\r\n }\r\n if (!$type.hasValue(this.thumb.readerDescription)) {\r\n this.thumb.readerDescription = this.language.translate(\"Use up and down arrows to move selection\");\r\n }\r\n if (!$type.hasValue(this.startGrip.readerDescription)) {\r\n this.startGrip.readerDescription = this.language.translate(\"Use up and down arrows to move upper selection\");\r\n }\r\n if (!$type.hasValue(this.endGrip.readerDescription)) {\r\n this.endGrip.readerDescription = this.language.translate(\"Use up and down arrows to move lower selection\");\r\n }\r\n this.readerOrientation = \"vertical\";\r\n }\r\n this.readerControls = this.baseSprite.uidAttr();\r\n };\r\n /**\r\n * Validates the layout of the scrollbar's elements.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Scrollbar.prototype.validateLayout = function () {\r\n this.updateSize();\r\n _super.prototype.validateLayout.call(this);\r\n // when size changes, need to update extremes\r\n this.updateExtremes();\r\n };\r\n /**\r\n * Update background for the scrollbar.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Scrollbar.prototype.processBackground = function () {\r\n _super.prototype.processBackground.call(this);\r\n var background = this.background;\r\n background.clickable = true;\r\n background.events.on(\"hit\", this.handleBgHit, this, undefined);\r\n };\r\n /**\r\n * Zooms to the particular place when clicked/tapped on the scrollbar\r\n * background.\r\n *\r\n * @ignore Exclude from docs\r\n * @param event Event\r\n */\r\n Scrollbar.prototype.handleBgHit = function (event) {\r\n this.makeBusy();\r\n var point = event.spritePoint;\r\n point = $utils.spritePointToSprite(point, this.background, this);\r\n var thumb = this.thumb;\r\n if (this.orientation == \"horizontal\") {\r\n var thumbX = point.x - thumb.pixelWidth / 2;\r\n thumbX = $math.fitToRange(thumbX, 0, this.innerWidth - thumb.pixelWidth);\r\n this._thumbAnimation = thumb.animate({ property: \"x\", to: thumbX }, this.animationDuration, this.animationEasing);\r\n }\r\n else {\r\n var thumbY = point.y - thumb.pixelHeight / 2;\r\n thumbY = $math.fitToRange(thumbY, 0, this.innerHeight - thumb.pixelHeight);\r\n this._thumbAnimation = thumb.animate({ property: \"y\", to: thumbY }, this.animationDuration, this.animationEasing);\r\n }\r\n if (this.animationDuration > 0) {\r\n this._thumbAnimation.events.on(\"animationended\", this.makeUnbusy, this, false);\r\n }\r\n else {\r\n this._thumb.validate();\r\n this.makeUnbusy();\r\n }\r\n };\r\n /**\r\n * Set scrollbar as busy. (currently zooming)\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Scrollbar.prototype.makeBusy = function () {\r\n this._isBusy = true;\r\n this._skipRangeEvents = false;\r\n if (this._unbusyTimeout) {\r\n this.removeDispose(this._unbusyTimeout);\r\n }\r\n this._unbusyTimeout = undefined;\r\n this.stopAnimations();\r\n };\r\n /**\r\n * Stops all animations, currently playing for the scrollbar.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Scrollbar.prototype.stopAnimations = function () {\r\n if (this._thumbAnimation) {\r\n this._thumbAnimation.stop(true);\r\n }\r\n if (this._zoomAnimation) {\r\n this._zoomAnimation.stop(true);\r\n }\r\n };\r\n /**\r\n * Cancels \"busy\" status of the Scrollbar.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Scrollbar.prototype.makeUnbusy = function () {\r\n /**\r\n * We cannot make Scrollbar not busy right after release, because then axes\r\n * will take over controll and Scrollbar will start to animate.\r\n * Theorethically, it's not right to set timeout by `animationDuration`,\r\n * however we can not know all the durations of elements we scroll, so we\r\n * assume that animation duration will be the same as\r\n * `interpolationDuration` or `rangeChange` duration.\r\n */\r\n this._unbusyTimeout = this.setTimeout(this.makeUnbusyReal.bind(this), this.animationDuration * 1.1);\r\n };\r\n /**\r\n * [makeUnbusyReal description]\r\n *\r\n * @todo Description\r\n * @ignore Exclude from docs\r\n */\r\n Scrollbar.prototype.makeUnbusyReal = function () {\r\n this._usingGrip = undefined;\r\n this._isBusy = false;\r\n if (!this.updateWhileMoving) {\r\n this.dispatchRangeChange();\r\n }\r\n };\r\n /**\r\n * Disptatches rangechanged event if it really changed\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Scrollbar.prototype.dispatchRangeChange = function () {\r\n if (this._previousEnd != this.end || this._previousStart != this.start) {\r\n this._previousStart = this.start;\r\n this._previousEnd = this.end;\r\n this.dispatch(\"rangechanged\");\r\n }\r\n };\r\n /**\r\n * Updates the \"thumb\" element. A draggable element between the grips.\r\n * @ignore\r\n */\r\n Scrollbar.prototype.updateThumb = function (dispatchEvents) {\r\n if (dispatchEvents === void 0) { dispatchEvents = true; }\r\n if (!this.parent) {\r\n return;\r\n }\r\n var thumb = this.thumb;\r\n var start = this.start;\r\n var end = this.end;\r\n var startGrip = this.startGrip;\r\n var endGrip = this.endGrip;\r\n var directionFlipped = this.adapter.apply(\"positionValueDirection\", {\r\n flipped: false\r\n }).flipped;\r\n var fromName = directionFlipped ? \"To %1\" : \"From %1\";\r\n var toName = directionFlipped ? \"From %1\" : \"To %1\";\r\n var fromValue;\r\n var toValue;\r\n if (this.orientation == \"horizontal\") {\r\n var innerWidth_1 = this.innerWidth;\r\n thumb.width = innerWidth_1 * (end - start);\r\n thumb.maxX = innerWidth_1 - thumb.pixelWidth;\r\n thumb.x = start * innerWidth_1;\r\n startGrip.moveTo({ x: thumb.pixelX, y: 0 }, undefined, undefined, true); // overrides dragging\r\n endGrip.moveTo({ x: thumb.pixelX + thumb.pixelWidth, y: 0 }, undefined, undefined, true);\r\n fromValue = this.adapter.apply(\"positionValue\", {\r\n value: Math.round(start * 100) + \"%\",\r\n position: start\r\n }).value;\r\n toValue = this.adapter.apply(\"positionValue\", {\r\n value: Math.round(end * 100) + \"%\",\r\n position: end\r\n }).value;\r\n startGrip.readerTitle = this.language.translate(fromName, undefined, fromValue);\r\n startGrip.readerValueNow = \"\" + Math.round(start * 100);\r\n startGrip.readerValueText = startGrip.readerTitle;\r\n endGrip.readerTitle = this.language.translate(toName, undefined, toValue);\r\n endGrip.readerValueNow = \"\" + Math.round(end * 100);\r\n endGrip.readerValueText = endGrip.readerTitle;\r\n }\r\n else {\r\n var innerHeight_1 = this.innerHeight;\r\n thumb.height = innerHeight_1 * (end - start);\r\n thumb.maxY = innerHeight_1 - thumb.pixelHeight;\r\n thumb.y = (1 - end) * innerHeight_1;\r\n startGrip.moveTo({ x: 0, y: thumb.pixelY + thumb.pixelHeight }, undefined, undefined, true);\r\n endGrip.moveTo({ x: 0, y: thumb.pixelY }, undefined, undefined, true);\r\n fromValue = this.adapter.apply(\"positionValue\", {\r\n value: Math.round((1 - start) * 100) + \"%\",\r\n position: (1 - start)\r\n }).value;\r\n toValue = this.adapter.apply(\"positionValue\", {\r\n value: Math.round((1 - end) * 100) + \"%\",\r\n position: (1 - end)\r\n }).value;\r\n startGrip.readerTitle = this.language.translate(toName, undefined, fromValue);\r\n startGrip.readerValueNow = \"\" + Math.round(start * 100);\r\n startGrip.readerValueText = startGrip.readerTitle;\r\n endGrip.readerTitle = this.language.translate(fromName, undefined, toValue);\r\n endGrip.readerValueNow = \"\" + Math.round(end * 100);\r\n endGrip.readerValueText = endGrip.readerTitle;\r\n }\r\n // Add accessibility\r\n thumb.readerTitle = this.language.translate(\"From %1 to %2\", undefined, fromValue, toValue);\r\n thumb.readerValueNow = \"\" + Math.round(start * 100);\r\n thumb.readerValueText = thumb.readerTitle;\r\n this.readerValueNow = \"\" + Math.round(start * 100);\r\n this.readerValueText = thumb.readerTitle;\r\n if (!this._skipRangeEvents && this.updateWhileMoving && dispatchEvents) {\r\n this.dispatchRangeChange();\r\n }\r\n };\r\n /**\r\n * Updates extremes of the scrollbar.\r\n */\r\n Scrollbar.prototype.updateExtremes = function () {\r\n var orientation = this.orientation;\r\n var minX = 0;\r\n var minY = 0;\r\n var maxX = 0;\r\n var maxY = 0;\r\n if (orientation == \"horizontal\") {\r\n maxX = this.innerWidth;\r\n minY = maxY = this.innerHeight / 2;\r\n }\r\n else {\r\n maxY = this.innerHeight;\r\n minX = maxX = this.innerWidth / 2;\r\n }\r\n var startGrip = this.startGrip;\r\n startGrip.minX = minX;\r\n startGrip.maxX = maxX;\r\n startGrip.minY = minY;\r\n startGrip.maxY = maxY;\r\n var endGrip = this.endGrip;\r\n endGrip.minX = minX;\r\n endGrip.maxX = maxX;\r\n endGrip.minY = minY;\r\n endGrip.maxY = maxY;\r\n var thumb = this.thumb;\r\n thumb.minX = minX;\r\n thumb.maxX = maxX;\r\n thumb.minY = minY;\r\n thumb.maxY = maxY;\r\n };\r\n /**\r\n * Updates size of the scrollbar.\r\n */\r\n Scrollbar.prototype.updateSize = function () {\r\n var orientation = this.orientation;\r\n var startGrip = this.startGrip;\r\n if (startGrip) {\r\n startGrip.orientation = orientation;\r\n }\r\n if (this.endGrip) {\r\n this.endGrip.orientation = orientation;\r\n }\r\n var thumb = this.thumb;\r\n if (thumb) {\r\n if (orientation == \"horizontal\") {\r\n if (!$type.isNumber(this._pixelWidth)) {\r\n if (!(this.width instanceof Percent)) {\r\n this.width = percent(100);\r\n }\r\n }\r\n // this teorethically might be wrong, if user indeed sets height of a horizontal scrollbar in percent\r\n // however without this height might be equal to 100% if previous orientation was set to horizontal\r\n // so this is ok solution, in case user really wants to have scrollbar height set in percent,\r\n // he should do this after orientation.\r\n if ($type.hasValue(this.percentHeight)) {\r\n this.height = this.minHeight;\r\n }\r\n thumb.height = this.innerHeight;\r\n thumb.verticalCenter = \"middle\";\r\n thumb.horizontalCenter = \"left\";\r\n }\r\n else {\r\n if (!$type.isNumber(this._pixelHeight)) {\r\n if (!(this.height instanceof Percent)) {\r\n this.height = percent(100);\r\n }\r\n }\r\n // same as above with percentHeight\r\n if ($type.hasValue(this.percentWidth)) {\r\n this.width = this.minWidth;\r\n }\r\n thumb.width = this.innerWidth;\r\n thumb.verticalCenter = \"top\";\r\n thumb.horizontalCenter = \"middle\";\r\n }\r\n }\r\n };\r\n Object.defineProperty(Scrollbar.prototype, \"isBusy\", {\r\n /**\r\n * Indicates if the Scrollbar is currently \"busy\" (animating and or\r\n * performing zoom by user interaction).\r\n * @return boolean\r\n */\r\n get: function () {\r\n return this._isBusy;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Scrollbar.prototype, \"start\", {\r\n /**\r\n * @return Position (0-1)\r\n */\r\n get: function () {\r\n return Math.min(this.getPosition(this._start), this.getPosition(this._end));\r\n },\r\n /**\r\n * ==========================================================================\r\n * POSITIONS\r\n * ==========================================================================\r\n * @hidden\r\n */\r\n /**\r\n * Relative position (0-1) of the start grip.\r\n *\r\n * @param position Position (0-1)\r\n */\r\n set: function (position) {\r\n if (!this._isBusy) {\r\n this.__start = position;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Scrollbar.prototype, \"__start\", {\r\n /**\r\n * @return [description]\r\n */\r\n get: function () {\r\n return this._start;\r\n },\r\n /**\r\n * [__start description]\r\n *\r\n * @todo Description\r\n * @param position [description]\r\n */\r\n set: function (position) {\r\n this._start = this.getPosition(position);\r\n this.updateThumb();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Scrollbar.prototype, \"end\", {\r\n /**\r\n * @return Position (0-1)\r\n */\r\n get: function () {\r\n return Math.max(this.getPosition(this._start), this.getPosition(this._end));\r\n },\r\n /**\r\n * Relative position (0-1) of the end grip.\r\n *\r\n * @param position Position (0-1)\r\n */\r\n set: function (position) {\r\n if (!this._isBusy) {\r\n this.__end = position;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Scrollbar.prototype, \"__end\", {\r\n /**\r\n * @return [description]\r\n */\r\n get: function () {\r\n return this._end;\r\n },\r\n /**\r\n * [__end description]\r\n *\r\n * @todo Description\r\n * @param position [description]\r\n */\r\n set: function (position) {\r\n this._end = this.getPosition(position);\r\n this.updateThumb();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Scrollbar.prototype, \"range\", {\r\n /**\r\n * Current selection range.\r\n *\r\n * @readonly\r\n * @return Range\r\n */\r\n get: function () {\r\n return { start: this.start, end: this.end, priority: this._usingGrip };\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Disables range change events.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Scrollbar.prototype.skipRangeEvents = function () {\r\n if (!this._isBusy) {\r\n this._skipRangeEvents = true;\r\n }\r\n };\r\n /**\r\n * [fixRange description]\r\n *\r\n * @todo Description\r\n * @ignore Exclude from docs\r\n * @param range Range\r\n */\r\n Scrollbar.prototype.fixRange = function (range) {\r\n if (range.start != $math.round(this._start, 2) || range.end != $math.round(this._end, 2)) {\r\n this._start = range.start;\r\n this._end = range.end;\r\n this._skipRangeEvents = true;\r\n this.updateThumb();\r\n this._skipRangeEvents = false;\r\n this.thumb.validate();\r\n this.thumb.background.validate();\r\n }\r\n };\r\n /**\r\n * [getPosition description]\r\n *\r\n * @todo Description\r\n * @param position [description]\r\n * @return [description]\r\n */\r\n Scrollbar.prototype.getPosition = function (position) {\r\n return $math.fitToRange($math.round(position, 4), 0, 1);\r\n };\r\n Object.defineProperty(Scrollbar.prototype, \"orientation\", {\r\n /**\r\n * @return Orientation\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"orientation\");\r\n },\r\n /**\r\n * ==========================================================================\r\n * MISC\r\n * ==========================================================================\r\n * @hidden\r\n */\r\n /**\r\n * Orientation of the scrollbar.\r\n *\r\n * Available options: \"horizontal\" (default) and \"vertical\".\r\n *\r\n * @default \"horizontal\"\r\n * @param value Orientation\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"orientation\", value)) {\r\n // Set mouse cursors and screen reader tetxt accordingly\r\n if (value === \"horizontal\") {\r\n // Mouse styles\r\n this.startGrip.cursorOverStyle = MouseCursorStyle.horizontalResize;\r\n this.endGrip.cursorOverStyle = MouseCursorStyle.horizontalResize;\r\n // Reader text\r\n /*this.readerTitle = this.language.translate(\"Use TAB to select grip buttons or left and right arrows to change selection\");\r\n this.thumb.readerDescription = this.language.translate(\"Use left and right arrows to move selection\");\r\n this.startGrip.readerDescription = this.language.translate(\"Use left and right arrows to move left selection\");\r\n this.endGrip.readerDescription = this.language.translate(\"Use left and right arrows to move right selection\");*/\r\n }\r\n else {\r\n // Mouse styles\r\n this.startGrip.cursorOverStyle = MouseCursorStyle.verticalResize;\r\n this.endGrip.cursorOverStyle = MouseCursorStyle.verticalResize;\r\n // Reader text\r\n /*this.readerTitle = this.language.translate(\"Use TAB select grip buttons or up and down arrows to change selection\");\r\n this.thumb.readerDescription = this.language.translate(\"Use up and down arrows to move selection\");\r\n this.startGrip.readerDescription = this.language.translate(\"Use up and down arrows to move upper selection\");\r\n this.endGrip.readerDescription = this.language.translate(\"Use up and down arrows to move lower selection\");*/\r\n }\r\n this.updateByOrientation();\r\n this.invalidate();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * @ignore\r\n */\r\n Scrollbar.prototype.updateByOrientation = function () {\r\n };\r\n Object.defineProperty(Scrollbar.prototype, \"startGrip\", {\r\n /**\r\n * @return Grip element\r\n */\r\n get: function () {\r\n return this._startGrip;\r\n },\r\n /**\r\n * ==========================================================================\r\n * GRIPS\r\n * ==========================================================================\r\n * @hidden\r\n */\r\n /**\r\n * Start grip element. (button)\r\n *\r\n * @param button Grip element\r\n */\r\n set: function (button) {\r\n if (this._startGrip) {\r\n this.removeDispose(this._startGrip);\r\n }\r\n this._startGrip = button;\r\n this.processGrip(button);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Scrollbar.prototype, \"endGrip\", {\r\n /**\r\n * @return Grip element\r\n */\r\n get: function () {\r\n return this._endGrip;\r\n },\r\n /**\r\n * End grip element. (button)\r\n *\r\n * @param button Grip element\r\n */\r\n set: function (button) {\r\n if (this._endGrip) {\r\n this.removeDispose(this._endGrip);\r\n }\r\n this._endGrip = button;\r\n this.processGrip(button);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Decorates the grip button with properties and events.\r\n *\r\n * @ignore Exclude from docs\r\n * @param button Grip button\r\n */\r\n Scrollbar.prototype.processGrip = function (button) {\r\n button.parent = this;\r\n button.isMeasured = false;\r\n button.focusable = true;\r\n button.shouldClone = false;\r\n // Set button defaults\r\n //button.showSystemTooltip = true; // setting this here is not right because we break inheritance\r\n button.zIndex = 100;\r\n button.events.on(\"drag\", this.handleGripDrag, this, false);\r\n button.events.on(\"dragstop\", this.makeUnbusy, this, false);\r\n button.events.on(\"down\", this.makeBusy, this, false);\r\n button.events.on(\"up\", this.makeUnbusy, this, false);\r\n this._disposers.push(button);\r\n };\r\n /**\r\n * Updates positions of related elements after grip element is dragged.\r\n *\r\n * @ignore Exclude from docs\r\n * @param event Event\r\n */\r\n Scrollbar.prototype.handleGripDrag = function (event) {\r\n this.makeBusy();\r\n if (event.target === this._startGrip) {\r\n this._usingGrip = \"start\";\r\n }\r\n else {\r\n this._usingGrip = \"end\";\r\n }\r\n if (this.orientation == \"horizontal\") {\r\n this._start = this.startGrip.pixelX / this.innerWidth;\r\n this._end = this.endGrip.pixelX / this.innerWidth;\r\n }\r\n else {\r\n this._start = 1 - this.startGrip.pixelY / this.innerHeight;\r\n this._end = 1 - this.endGrip.pixelY / this.innerHeight;\r\n }\r\n this.updateThumb();\r\n };\r\n Object.defineProperty(Scrollbar.prototype, \"thumb\", {\r\n /**\r\n * @return Thumb element\r\n */\r\n get: function () {\r\n if (!this._thumb) {\r\n // Create scrollbar controls (setters will handle adding disposers)\r\n var thumb = new Button();\r\n thumb.background.cornerRadius(10, 10, 10, 10);\r\n thumb.padding(0, 0, 0, 0);\r\n this.thumb = thumb;\r\n }\r\n return this._thumb;\r\n },\r\n /**\r\n * A \"thumb\" element.\r\n *\r\n * It's a draggable square space between the grips, that can be used to\r\n * pan the selection.\r\n *\r\n * @param thumb Thumb element\r\n */\r\n set: function (thumb) {\r\n var _this = this;\r\n if (thumb) {\r\n if (this._thumb) {\r\n this.removeDispose(this._thumb);\r\n }\r\n this._thumb = thumb;\r\n thumb.parent = this;\r\n thumb.isMeasured = false;\r\n thumb.inert = true;\r\n thumb.draggable = true;\r\n thumb.clickable = true;\r\n thumb.hoverable = true;\r\n thumb.focusable = true;\r\n thumb.shouldClone = false;\r\n thumb.zIndex = 0;\r\n // TODO remove closures ?\r\n // Add events\r\n // Add cursor styles to thumb\r\n thumb.cursorOverStyle = MouseCursorStyle.grab;\r\n thumb.cursorDownStyle = MouseCursorStyle.grabbing;\r\n thumb.events.on(\"dragstart\", this.makeBusy, this, false);\r\n thumb.events.on(\"dragstop\", this.makeUnbusy, this, false);\r\n thumb.events.on(\"positionchanged\", this.handleThumbPosition, this, false);\r\n thumb.events.on(\"sizechanged\", this.handleThumbPosition, this, false);\r\n thumb.events.on(\"doublehit\", this.handleDoubleClick, this, false);\r\n // Add event for space and ENTER to toggle full zoom out and back\r\n // (same as doubleclick)\r\n this._disposers.push(getInteraction().body.events.on(\"keyup\", function (ev) {\r\n if (keyboard.isKey(ev.event, [\"space\", \"enter\"]) && _this.thumb.isFocused) {\r\n ev.event.preventDefault();\r\n _this.handleDoubleClick();\r\n }\r\n }));\r\n this._disposers.push(this._thumb);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Zooms-in and out the selection on double-click of the thumb.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Scrollbar.prototype.handleDoubleClick = function () {\r\n this.makeBusy();\r\n var newStart = 0;\r\n var newEnd = 1;\r\n if (this.start != 0 || this.end != 1) {\r\n this._prevStart = this.start;\r\n this._prevEnd = this.end;\r\n }\r\n else {\r\n newStart = this._prevStart;\r\n newEnd = this._prevEnd;\r\n }\r\n var zoomAnimation = this.animate([{ property: \"__start\", to: newStart }, { property: \"__end\", to: newEnd }], this.animationDuration, this.animationEasing);\r\n if (zoomAnimation && !zoomAnimation.isFinished()) {\r\n zoomAnimation.events.on(\"animationended\", this.makeUnbusy, this, false);\r\n this._zoomAnimation = zoomAnimation;\r\n }\r\n else {\r\n this.makeUnbusy();\r\n }\r\n };\r\n /**\r\n * Updates positions of other elements when thumb is moved.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Scrollbar.prototype.handleThumbPosition = function () {\r\n var thumb = this.thumb;\r\n if (this.orientation == \"horizontal\") {\r\n var innerWidth_2 = this.innerWidth;\r\n var w = thumb.innerWidth;\r\n var x = thumb.pixelX;\r\n this._start = x / innerWidth_2;\r\n this._end = (x + w) / innerWidth_2;\r\n this.updateThumb();\r\n }\r\n else {\r\n var innerHeight_2 = this.innerHeight;\r\n var h = thumb.innerHeight;\r\n var y = thumb.pixelY;\r\n if (y + h > innerHeight_2) {\r\n y = innerHeight_2 - h;\r\n thumb.y = y;\r\n }\r\n this._start = 1 - (y + h) / innerHeight_2;\r\n this._end = 1 - y / innerHeight_2;\r\n this.updateThumb();\r\n }\r\n };\r\n /**\r\n * Creates a background element for the scrollbar.\r\n *\r\n * @ignore Exclude from docs\r\n * @return Background\r\n */\r\n Scrollbar.prototype.createBackground = function () {\r\n return new RoundedRectangle();\r\n };\r\n Object.defineProperty(Scrollbar.prototype, \"hideGrips\", {\r\n /**\r\n * @return Show only on hover?\r\n */\r\n get: function () {\r\n return this._hideGrips;\r\n },\r\n /**\r\n * Use this property to set whether grips should be always visible (`false`),\r\n * or they should just appear on scrollbar hover (`true`).\r\n *\r\n * @param value Show only on hover?\r\n */\r\n set: function (value) {\r\n var _this = this;\r\n this._hideGrips = value;\r\n if (this._overDisposer) {\r\n this.removeDispose(this._overDisposer);\r\n }\r\n if (this._outDisposer) {\r\n this.removeDispose(this._outDisposer);\r\n }\r\n if (value) {\r\n this._overDisposer = this.events.on(\"over\", function () {\r\n _this.startGrip.show();\r\n _this.endGrip.show();\r\n }, undefined, false);\r\n this._outDisposer = this.events.on(\"out\", function () {\r\n _this.startGrip.hide();\r\n _this.endGrip.hide();\r\n }, undefined, false);\r\n this.startGrip.hide();\r\n this.endGrip.hide();\r\n }\r\n else {\r\n this.startGrip.show();\r\n this.endGrip.show();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Scrollbar.prototype, \"animationDuration\", {\r\n /**\r\n * @return Orientation\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"animationDuration\");\r\n },\r\n /**\r\n * Duration in milliseconds of scrollbar animation (happens when user clicks on a background of a scrollbar)\r\n * @default 0\r\n * @param value number\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"animationDuration\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Scrollbar.prototype, \"animationEasing\", {\r\n /**\r\n * @return {Function}\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"animationEasing\");\r\n },\r\n /**\r\n * Animation easing function.\r\n * @todo: review description and default\r\n * @default $ease.cubicOut\r\n * @param value (value: number) => number\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"animationEasing\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Adds easing functions to \"function\" fields.\r\n *\r\n * @param field Field name\r\n * @return Assign as function?\r\n */\r\n Scrollbar.prototype.asFunction = function (field) {\r\n return field == \"animationEasing\" || _super.prototype.asIs.call(this, field);\r\n };\r\n return Scrollbar;\r\n}(Container));\r\nexport { Scrollbar };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Scrollbar\"] = Scrollbar;\r\n//# sourceMappingURL=Scrollbar.js.map","/**\r\n * Slider is a scrollbar with just one selection grip.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Scrollbar } from \"../../core/elements/Scrollbar\";\r\nimport { registry } from \"../Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creates a slider - a version of scrollbar with just one grip.\r\n *\r\n * @see {@link ISliderEvents} for a list of available events\r\n * @see {@link ISliderAdapters} for a list of available Adapters\r\n */\r\nvar Slider = /** @class */ (function (_super) {\r\n __extends(Slider, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Slider() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"Slider\";\r\n _this.thumb.opacity = 0;\r\n _this.thumb.interactionsEnabled = false;\r\n _this.endGrip.opacity = 0;\r\n _this.endGrip.interactionsEnabled = false;\r\n _this.startGrip.events.on(\"drag\", function () {\r\n _this.endGrip.x = _this.startGrip.x;\r\n _this.endGrip.y = _this.startGrip.y;\r\n });\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(Slider.prototype, \"__end\", {\r\n /**\r\n * @return [description]\r\n */\r\n get: function () {\r\n return this._start;\r\n },\r\n set: function (value) {\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slider.prototype, \"end\", {\r\n /**\r\n * @return [description]\r\n */\r\n get: function () {\r\n return this._start;\r\n },\r\n /**\r\n * Relative position (0-1) of the end grip.\r\n *\r\n * @param position Position (0-1)\r\n */\r\n set: function (position) {\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slider.prototype, \"start\", {\r\n /**\r\n * @return Position (0-1)\r\n */\r\n get: function () {\r\n return this._start;\r\n },\r\n /**\r\n * Relative position (0-1) of the start grip.\r\n *\r\n * @param position Position (0-1)\r\n */\r\n set: function (position) {\r\n if (!this._isBusy) {\r\n this.__start = position;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Slider;\r\n}(Scrollbar));\r\nexport { Slider };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Slider\"] = Slider;\r\n//# sourceMappingURL=Slider.js.map","/**\r\n * A module that defines Text element used to indicate links.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Label } from \"../../core/elements/Label\";\r\nimport { MouseCursorStyle } from \"../../core/interaction/Mouse\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport { registry } from \"../Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creates a text element with a link.\r\n *\r\n * @see {@link ITextLinkEvents} for a list of available events\r\n * @see {@link ITextLinkAdapters} for a list of available Adapters\r\n */\r\nvar TextLink = /** @class */ (function (_super) {\r\n __extends(TextLink, _super);\r\n /**\r\n * Constructor\r\n */\r\n function TextLink() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"TextLink\";\r\n _this.selectable = true;\r\n var interfaceColors = new InterfaceColorSet();\r\n _this.fill = interfaceColors.getFor(\"primaryButton\").brighten(0.3);\r\n var hoverState = _this.states.create(\"hover\");\r\n hoverState.properties.fill = interfaceColors.getFor(\"primaryButtonHover\").brighten(0.3);\r\n var downState = _this.states.create(\"down\");\r\n downState.properties.fill = interfaceColors.getFor(\"primaryButtonDown\").brighten(0.3);\r\n _this.cursorOverStyle = MouseCursorStyle.pointer;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n return TextLink;\r\n}(Label));\r\nexport { TextLink };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"TextLink\"] = TextLink;\r\n//# sourceMappingURL=TextLink.js.map","/**\r\n * This module contains a base class for an SVG filter.\r\n *\r\n * Filters can be used to decorate, change and transform just about any DOM\r\n * element.\r\n *\r\n * A Filter works by applying one or more effects (primitives) to SVG element.\r\n *\r\n * For more information on how SVG filters work, refer to\r\n * [this MDN tutorial](https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/SVG_Filters_Tutorial).\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { BaseObject } from \"../../Base\";\r\nimport { getGhostPaper } from \"../Paper\";\r\nimport { Animation, AnimationDisposer } from \"../../utils/Animation\";\r\nimport { List } from \"../../utils/List\";\r\nimport * as $object from \"../../utils/Object\";\r\nimport * as $iter from \"../../utils/Iterator\";\r\n;\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Base filter class.\r\n *\r\n * This class while can be instantiated will not do anything. It is just a base\r\n * functionality for any other \"real\" filters to extend.\r\n *\r\n * Filters can be used to decorate, change and transform just about any DOM\r\n * element.\r\n *\r\n * A Filter works by applying one or more effects (primitives) to SVG element.\r\n *\r\n * For more information on how SVG filters work, refer to\r\n * [this MDN tutorial](https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/SVG_Filters_Tutorial).\r\n *\r\n * @todo Example\r\n */\r\nvar Filter = /** @class */ (function (_super) {\r\n __extends(Filter, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Filter() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n /**\r\n * A storage for Filter property/value pairs.\r\n *\r\n * @ignore Exclude from docs\r\n * @see {@link FilterProperties}\r\n */\r\n _this.properties = {};\r\n /**\r\n * Identifies if this object is a \"template\" and should not be treated as\r\n * real object that is drawn or actually used in the chart.\r\n */\r\n _this.isTemplate = false;\r\n /**\r\n * [_scale description]\r\n *\r\n * @todo Description\r\n */\r\n _this._scale = 1;\r\n /**\r\n * [_nonScaling description]\r\n *\r\n * @todo Description\r\n */\r\n _this._nonScaling = true;\r\n _this.className = \"Filter\";\r\n // Create a list to hold primitives (effect elements)\r\n _this.filterPrimitives = new List();\r\n _this.properties.filterUnits = \"objectBoundingBox\";\r\n // Automatically add added primitives to `_disposers` so they are discarded\r\n // when Filter object is destroyed (disposed)\r\n _this.filterPrimitives.events.on(\"inserted\", function (ev) {\r\n _this._disposers.push(ev.newValue);\r\n });\r\n // Set default dimensions\r\n _this.width = 120;\r\n _this.height = 120;\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Appends actual filter elements to the filter group.\r\n *\r\n * @ignore Exclude from docs\r\n * @param filterElement An SVG `` element to add filter element to\r\n */\r\n Filter.prototype.appendPrimitives = function (filterElement) {\r\n $iter.each(this.filterPrimitives.iterator(), function (filterPrimitive) {\r\n filterElement.add(filterPrimitive);\r\n });\r\n };\r\n /**\r\n * Uses Transitions filter's values from current to target. This is used to\r\n * smoothly appear filter, rather than it pop into effect.\r\n *\r\n * @ignore Exclude from docs\r\n * @param animationOptions Animation options\r\n * @param duration Duration in milliseconds\r\n * @param easing Easing function\r\n * @return Animation instance\r\n */\r\n Filter.prototype.animate = function (animationOptions, duration, easing) {\r\n var animation = new Animation(this, animationOptions, duration, easing).start();\r\n return animation;\r\n };\r\n Object.defineProperty(Filter.prototype, \"width\", {\r\n /**\r\n * @return Width (%)\r\n */\r\n get: function () {\r\n return this.properties[\"width\"];\r\n },\r\n /**\r\n * Width of the filter element in percent.\r\n *\r\n * If the filter is designed to \"bleed out\" of the original target element,\r\n * like for example a shadow, you need this bigger than 100, or the\r\n * non-fitting parts will be clipped.\r\n *\r\n * @default 120\r\n * @param value Width (px)\r\n */\r\n set: function (value) {\r\n this.properties[\"width\"] = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Filter.prototype, \"height\", {\r\n /**\r\n * @return Height\r\n */\r\n get: function () {\r\n return this.properties[\"height\"];\r\n },\r\n /**\r\n * Height of the filter element in percent.\r\n *\r\n * If the filter is designed to \"bleed out\" of the original target element,\r\n * like for example a shadow, you need this bigger than 100, or the\r\n * non-fitting parts will be clipped.\r\n *\r\n * @default 120\r\n * @param value Height (%)\r\n */\r\n set: function (value) {\r\n this.properties[\"height\"] = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Copies properties from another [[Filter]] object.\r\n *\r\n * @param filter Source [[Filter]] object\r\n */\r\n Filter.prototype.copyFrom = function (filter) {\r\n var _this = this;\r\n _super.prototype.copyFrom.call(this, filter);\r\n $object.each(filter.properties, function (key, value) {\r\n _this[key] = value;\r\n });\r\n };\r\n Object.defineProperty(Filter.prototype, \"paper\", {\r\n /**\r\n * @return Paper\r\n */\r\n get: function () {\r\n if (this._paper) {\r\n return this._paper;\r\n }\r\n return getGhostPaper();\r\n },\r\n /**\r\n * Sets [[Paper]] instance to create filter's elements in.\r\n *\r\n * @ignore Exclude from docs\r\n * @param paper Paper\r\n */\r\n set: function (paper) {\r\n if (this._paper != paper) {\r\n this._paper = paper;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Filter.prototype, \"animations\", {\r\n /**\r\n * All animations currently in play.\r\n *\r\n * @ignore Exclude from docs\r\n * @return List of animations\r\n */\r\n get: function () {\r\n if (!this._animations) {\r\n this._animations = [];\r\n this._disposers.push(new AnimationDisposer(this._animations));\r\n }\r\n return this._animations;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Filter.prototype, \"scale\", {\r\n /**\r\n * @ignore Exclude from docs\r\n */\r\n get: function () {\r\n return this._scale;\r\n },\r\n /**\r\n * [[Sprite]] uses this method to inform filter about it's scale.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n set: function (value) {\r\n this._scale = value;\r\n this.updateScale();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Updates filter properties which depend on scale.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Filter.prototype.updateScale = function () {\r\n // Dummy method for extending classes to override.\r\n };\r\n Object.defineProperty(Filter.prototype, \"filterUnits\", {\r\n /**\r\n * @return Filter units\r\n */\r\n get: function () {\r\n return this.properties.filterUnits;\r\n },\r\n /**\r\n * Which units are used when drawing filter.\r\n *\r\n * Use `\"userSpaceOnUse\"` when applying filters on a perfectly straight line.\r\n *\r\n * @since 4.9.17\r\n * @default objectBoundingBox\r\n * @param value Filter units\r\n */\r\n set: function (value) {\r\n this.properties.filterUnits = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Filter.prototype, \"nonScaling\", {\r\n /**\r\n * @return Non scaling?\r\n */\r\n get: function () {\r\n return this._nonScaling;\r\n },\r\n /**\r\n * If a filter is non scaling, it will look the same even if the sprite is\r\n * scaled, otherwise filter will scale together with a [[Sprite]].\r\n *\r\n * @default false\r\n * @param value Non scaling?\r\n */\r\n set: function (value) {\r\n this._nonScaling = value;\r\n if (!value) {\r\n this._scale = 1;\r\n }\r\n this.updateScale();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Filter.prototype, \"sprite\", {\r\n /**\r\n * A target element this filter is currently attached to.\r\n *\r\n * We need to keep track of it because one filter can be used for just one\r\n * element, so we have to remove it from the old \"parent\" when attaching to\r\n * the new one.\r\n *\r\n * @ignore Exclude from docs\r\n * @param value Target element\r\n */\r\n set: function (value) {\r\n this.setSprite(value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Sets filter's target element.\r\n *\r\n * @ignore Exclude from docs\r\n * @param value Element filter is being attached to\r\n */\r\n Filter.prototype.setSprite = function (value) {\r\n if (this._sprite && this._sprite != value) {\r\n this._sprite.filters.removeValue(this);\r\n }\r\n this._sprite = value;\r\n };\r\n return Filter;\r\n}(BaseObject));\r\nexport { Filter };\r\n//# sourceMappingURL=Filter.js.map","/**\r\n * Module for \"Drop Shadow\" filter.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Filter } from \"./Filter\";\r\nimport { color } from \"../../utils/Color\";\r\nimport { registry } from \"../../Registry\";\r\n;\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creats a \"Drop Shadow\" filter.\r\n */\r\nvar DropShadowFilter = /** @class */ (function (_super) {\r\n __extends(DropShadowFilter, _super);\r\n /**\r\n * Constructor\r\n */\r\n function DropShadowFilter() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"DropShadowFilter\";\r\n // Create elements\r\n // NOTE: we do not need to add each individual element to `_disposers`\r\n // because `filterPrimitives` has an event handler which automatically adds\r\n // anything added to it to `_disposers`\r\n _this.color = color(\"#000\");\r\n _this.feGaussianBlur = _this.paper.add(\"feGaussianBlur\");\r\n _this.feGaussianBlur.attr({ \"result\": \"blurOut\", \"in\": \"SourceGraphic\" });\r\n _this.filterPrimitives.push(_this.feGaussianBlur);\r\n _this.feOffset = _this.paper.add(\"feOffset\");\r\n _this.feOffset.attr({ \"result\": \"offsetBlur\" });\r\n _this.filterPrimitives.push(_this.feOffset);\r\n _this.feFlood = _this.paper.add(\"feFlood\");\r\n _this.feFlood.attr({ \"flood-color\": _this.color });\r\n _this.filterPrimitives.push(_this.feFlood);\r\n _this.feComposite = _this.paper.add(\"feComposite\");\r\n _this.feComposite.attr({ \"in2\": \"offsetBlur\", operator: \"in\" });\r\n _this.filterPrimitives.push(_this.feComposite);\r\n _this.feMerge = _this.paper.addGroup(\"feMerge\");\r\n _this.feMerge.add(_this.paper.add(\"feMergeNode\"));\r\n _this.feMerge.add(_this.paper.add(\"feMergeNode\").attr({ \"in\": \"SourceGraphic\" }));\r\n _this.filterPrimitives.push(_this.feMerge);\r\n // Set default properties\r\n _this.width = 200;\r\n _this.height = 200;\r\n _this.blur = 1.5;\r\n _this.dx = 3;\r\n _this.dy = 3;\r\n _this.opacity = 0.5;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(DropShadowFilter.prototype, \"color\", {\r\n /**\r\n * @return Color\r\n */\r\n get: function () {\r\n return this.properties.color;\r\n },\r\n /**\r\n * Shadow color.\r\n *\r\n * @param value Color\r\n */\r\n set: function (value) {\r\n this.properties.color = value;\r\n if (this.feFlood) {\r\n this.feFlood.attr({ \"flood-color\": value });\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(DropShadowFilter.prototype, \"opacity\", {\r\n /**\r\n * @return Opacity (0-1)\r\n */\r\n get: function () {\r\n return this.properties.opacity;\r\n },\r\n /**\r\n * Opacity of the shadow. (0-1)\r\n *\r\n * @param value Opacity (0-1)\r\n */\r\n set: function (value) {\r\n this.properties.opacity = value;\r\n this.feFlood.attr({ \"flood-opacity\": value });\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(DropShadowFilter.prototype, \"dx\", {\r\n /**\r\n * @return Horizontal offset (px)\r\n */\r\n get: function () {\r\n return this.properties.dx;\r\n },\r\n /**\r\n * Horizontal offset in pixels.\r\n *\r\n * @param value Horizontal offset (px)\r\n */\r\n set: function (value) {\r\n this.properties.dx = value;\r\n this.feOffset.attr({ \"dx\": value / this.scale });\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(DropShadowFilter.prototype, \"dy\", {\r\n /**\r\n * @return Vertical offset (px)\r\n */\r\n get: function () {\r\n return this.properties.dy;\r\n },\r\n /**\r\n * Vertical offset in pixels.\r\n *\r\n * @param value Vertical offset (px)\r\n */\r\n set: function (value) {\r\n this.properties.dy = value;\r\n this.feOffset.attr({ \"dy\": value / this.scale });\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(DropShadowFilter.prototype, \"blur\", {\r\n /**\r\n * @return Blur\r\n */\r\n get: function () {\r\n return this.properties.blur;\r\n },\r\n /**\r\n * Blur.\r\n *\r\n * @param value Blur\r\n */\r\n set: function (value) {\r\n this.properties.blur = value;\r\n this.feGaussianBlur.attr({ \"stdDeviation\": value / this.scale });\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * [updateScale description]\r\n *\r\n * @todo Description\r\n */\r\n DropShadowFilter.prototype.updateScale = function () {\r\n this.dx = this.dx;\r\n this.dy = this.dy;\r\n this.blur = this.blur;\r\n };\r\n return DropShadowFilter;\r\n}(Filter));\r\nexport { DropShadowFilter };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"DropShadowFilter\"] = DropShadowFilter;\r\n//# sourceMappingURL=DropShadowFilter.js.map","/**\r\n * Provides functionality used to creating and showing tooltips (balloons).\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../Container\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { PointedRectangle } from \"./PointedRectangle\";\r\nimport { Label } from \"../elements/Label\";\r\nimport { Animation } from \"../utils/Animation\";\r\nimport { color } from \"../utils/Color\";\r\nimport { DropShadowFilter } from \"../rendering/filters/DropShadowFilter\";\r\nimport * as $math from \"../utils/Math\";\r\nimport * as $ease from \"../utils/Ease\";\r\nimport * as $utils from \"../utils/Utils\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Tooltip displays text and/or multimedia information in a balloon over chart\r\n * area.\r\n * @see {@link ITooltipEvents} for a list of available events\r\n * @see {@link ITooltipAdapters} for a list of available Adapters\r\n */\r\nvar Tooltip = /** @class */ (function (_super) {\r\n __extends(Tooltip, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Tooltip() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n /**\r\n * Holds numeric boundary values. Calculated from the `boundingContainer`.\r\n * @ignore\r\n */\r\n _this._boundingRect = { x: -40000, y: -40000, width: 80000, height: 80000 };\r\n /**\r\n * Coordinates tooltip's pointer (stem) should point to.\r\n */\r\n _this._pointTo = { x: 0, y: 0 };\r\n /**\r\n * If set to `true` the pointer/stem of the Tooltip will not go outside\r\n * Tooltip's width or height depending on pointer's orientation.\r\n *\r\n * @default false\r\n */\r\n _this.fitPointerToBounds = false;\r\n /**\r\n * If `tooltipOrientation` is vertical, it can be drawn below or above point\r\n * We need to know this when solving overlapping.\r\n */\r\n _this._verticalOrientation = \"up\";\r\n /**\r\n * @ignore\r\n */\r\n _this.fixDoc = true;\r\n _this.className = \"Tooltip\";\r\n _this.isMeasured = false;\r\n _this.getFillFromObject = true;\r\n _this.margin(5, 5, 5, 5);\r\n _this.defaultState.transitionDuration = 1;\r\n _this.hiddenState.transitionDuration = 1;\r\n // Create chrome/background\r\n var background = _this.background;\r\n background.interactionsEnabled = false;\r\n background.fillOpacity = 0.9;\r\n background.strokeWidth = 1;\r\n background.strokeOpacity = 1;\r\n background.stroke = color(\"#ffffff\");\r\n background.cornerRadius = 3;\r\n background.pointerLength = 6;\r\n background.pointerBaseWidth = 10;\r\n var dropShadow = new DropShadowFilter();\r\n dropShadow.dy = 1;\r\n dropShadow.dx = 1;\r\n dropShadow.opacity = 0.5;\r\n background.filters.push(dropShadow);\r\n _this.autoTextColor = true;\r\n // Create text element\r\n var label = _this.createChild(Label);\r\n label.shouldClone = false;\r\n _this.label = label;\r\n label.padding(7, 12, 4, 12);\r\n label.interactionsEnabled = false;\r\n label.horizontalCenter = \"middle\";\r\n label.fill = color(\"#ffffff\");\r\n _this._disposers.push(label);\r\n _this.label.events.on(\"sizechanged\", _this.drawBackground, _this);\r\n _this.label.zIndex = 1; // @todo remove this line when bg sorting is solved\r\n // Set defaults\r\n _this.pointerOrientation = \"vertical\";\r\n _this.animationDuration = 0;\r\n _this.animationEasing = $ease.cubicOut;\r\n _this.setPropertyValue(\"showInViewport\", false);\r\n // Set accessibility options\r\n _this.role = \"tooltip\";\r\n _this.visible = false;\r\n _this.opacity = 0;\r\n _this.x = 0;\r\n _this.y = 0;\r\n _this.events.on(\"visibilitychanged\", _this.handleVisibility, _this);\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Tooltip.prototype.handleVisibility = function () {\r\n if (this.visible) {\r\n this.label.invalidate();\r\n }\r\n };\r\n Object.defineProperty(Tooltip.prototype, \"getStrokeFromObject\", {\r\n /**\r\n * Specifies if tooltip background should get stroke color from the sprite it is pointing to.\r\n *\r\n * @return {boolean}\r\n * @default false\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"getStrokeFromObject\");\r\n },\r\n /**\r\n * Specifies if tooltip background should get stroke color from the sprite it is pointing to.\r\n *\r\n * @param value boolean\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"getStrokeFromObject\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Tooltip.prototype, \"autoTextColor\", {\r\n /**\r\n * @return {boolean}\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"autoTextColor\");\r\n },\r\n /**\r\n * Specifies if text color should be chosen automatically for a better\r\n * readability.\r\n *\r\n * IMPORTANT: this feature is generally ignored, if `getFillFromObject = false`.\r\n *\r\n * If inheriting of `fill` color from object tooltip is displayed for is\r\n * disabled, this feature will not work. If you are explicitly setting a\r\n * color for tooltip background, you may set a color for its label as well\r\n * using `tooltip.label.fill` property.\r\n *\r\n *\r\n * @param value boolean\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"autoTextColor\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Tooltip.prototype, \"keepTargetHover\", {\r\n /**\r\n * @return Keep target hovered?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"keepTargetHover\");\r\n },\r\n /**\r\n * If this tooltip is displayed on hover on some other object, keep that\r\n * element hovered if hovering on the tooltip.\r\n *\r\n * @default false\r\n * @since 4.1.13\r\n * @param value Keep target hovered?\r\n */\r\n set: function (value) {\r\n var _this = this;\r\n if (this.setPropertyValue(\"keepTargetHover\", value, true)) {\r\n if (value) {\r\n this.hoverable = true;\r\n this.background.interactionsEnabled = true;\r\n this._disposers.push(this.events.on(\"over\", function (ev) {\r\n if (_this.targetSprite && _this.targetSprite.hoverable) {\r\n _this.targetSprite.isHover = true;\r\n }\r\n }));\r\n this._disposers.push(this.events.on(\"out\", function (ev) {\r\n if (_this.targetSprite && _this.targetSprite.hoverable) {\r\n //this.hideTooltip();\r\n //this.targetSprite.handleOut();\r\n _this.targetSprite.isHover = false;\r\n }\r\n }));\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Tooltip.prototype, \"showInViewport\", {\r\n /**\r\n * @return Force showing tooltip?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"showInViewport\");\r\n },\r\n /**\r\n * Normally, a tooltip will hide itself if it is pointing to a coordinate\r\n * that is outside viewport.\r\n *\r\n * Setting this setting to `true` will override that and make tooltip\r\n * appear next to the viewport edge closest to the target point.\r\n *\r\n * @default false\r\n * @since 4.5.7\r\n * @param value Force showing tooltip?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"showInViewport\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Tooltip.prototype, \"getFillFromObject\", {\r\n /**\r\n * Specifies if tooltip background should get fill color from the sprite it is pointing to.\r\n *\r\n * @return {boolean}\r\n * @default true\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"getFillFromObject\");\r\n },\r\n /**\r\n * @param value boolean\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"getFillFromObject\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Creates and returns a background element.\r\n *\r\n * @ignore Exclude from docs\r\n * @return Background\r\n */\r\n Tooltip.prototype.createBackground = function () {\r\n return new PointedRectangle();\r\n };\r\n Object.defineProperty(Tooltip.prototype, \"pointerOrientation\", {\r\n /**\r\n * @return Orientation\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"pointerOrientation\");\r\n },\r\n /**\r\n * Pointer orientation: `\"horizontal\"`, `\"vertical\"`, `\"up\"`, `\"down\"`,\r\n * `\"right\"`, or `\"left\"`.\r\n *\r\n * Options`\"horizontal\"` or `\"vertical\"` are location-aware, meaning they\r\n * will change position of the Tooltip based on the target point's position\r\n * in relation to chart center.\r\n *\r\n * Options `\"up\"`, `\"down\"`, `\"right\"`, `\"left\"` are static and will point\r\n * in the specified direction regardless of the position, even if that means\r\n * going out of chart/screen bounds.\r\n *\r\n * IMPORTANT: in some situations, like having multiple tooltips stacked for\r\n * multiple series, the `\"up\"` and `\"down\"` values might be ignored in order\r\n * to make tooltip overlap algorithm work.\r\n *\r\n * @default \"vertical\"\r\n * @param value Orientation\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"pointerOrientation\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Tooltip.prototype, \"animationDuration\", {\r\n /**\r\n * @return Orientation\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"animationDuration\");\r\n },\r\n /**\r\n * Duration in milliseconds for the animation to take place when the tooltip\r\n * is moving from one place to another.\r\n *\r\n * @default 0\r\n * @param value number\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"animationDuration\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Tooltip.prototype, \"animationEasing\", {\r\n /**\r\n * @return {Function}\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"animationEasing\");\r\n },\r\n /**\r\n * Tooltip animation (moving from one place to another) easing function.\r\n *\r\n * @default $ease.cubicOut\r\n * @param value (value: number) => number\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"animationEasing\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Tooltip.prototype, \"html\", {\r\n /**\r\n * @return HTML content\r\n */\r\n get: function () {\r\n return this.label.html;\r\n },\r\n /**\r\n * HTML content for the Tooltip.\r\n *\r\n * Provided value will be used as is, without applying any further\r\n * formatting to it.\r\n *\r\n * @param value HTML content\r\n */\r\n set: function (value) {\r\n if (this.label.html != value) {\r\n this.label.html = value;\r\n this.invalidate();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Tooltip.prototype, \"text\", {\r\n /**\r\n * @return SVG text\r\n */\r\n get: function () {\r\n return this.label.text;\r\n },\r\n /**\r\n * SVG text content for the Tooltip.\r\n *\r\n * Text can have a number of formatting options supported by\r\n * [[TextFormatter]].\r\n *\r\n * @param value SVG text\r\n */\r\n set: function (value) {\r\n if (this.label.text != value) {\r\n this.label.text = value;\r\n this.invalidate();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Creates the Tooltip.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Tooltip.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n var label = this.label;\r\n if (label.invalid) {\r\n label.validate();\r\n }\r\n var x = this._pointTo.x;\r\n var y = this._pointTo.y;\r\n var boundingRect = this._boundingRect;\r\n var textW = label.measuredWidth;\r\n var textH = label.measuredHeight;\r\n var pointerLength = this.background.pointerLength;\r\n var textX;\r\n var textY;\r\n if (this.ignoreBounds) {\r\n boundingRect = undefined;\r\n }\r\n // try to handle if text is wider than br\r\n if (boundingRect && this.fixDoc && textW > boundingRect.width) {\r\n // TODO maybe this isn't needed ?\r\n $utils.spritePointToDocument({ x: boundingRect.x, y: boundingRect.y }, this.parent);\r\n var p1 = $utils.spritePointToDocument({ x: boundingRect.x + boundingRect.width, y: boundingRect.y + boundingRect.height }, this.parent);\r\n var documentWidth = document.body.offsetWidth;\r\n // TODO maybe this isn't needed ?\r\n $utils.used(document.body.offsetHeight);\r\n if (p1.x > documentWidth / 2) {\r\n boundingRect.x = boundingRect.width - textW;\r\n }\r\n else {\r\n boundingRect.width = boundingRect.x + textW;\r\n }\r\n }\r\n var pointerOrientation = this.pointerOrientation;\r\n // horizontal\r\n if (pointerOrientation == \"horizontal\" || pointerOrientation == \"left\" || pointerOrientation == \"right\") {\r\n textY = -textH / 2;\r\n if (pointerOrientation == \"horizontal\") {\r\n if (boundingRect && x > boundingRect.x + boundingRect.width / 2) {\r\n textX = -textW / 2 - pointerLength;\r\n }\r\n else {\r\n textX = textW / 2 + pointerLength;\r\n }\r\n }\r\n else if (pointerOrientation == \"left\") {\r\n textX = textW / 2 + pointerLength;\r\n }\r\n else {\r\n textX = -textW / 2 - pointerLength;\r\n }\r\n }\r\n // vertical pointer\r\n else {\r\n if (boundingRect) {\r\n textX = $math.fitToRange(0, boundingRect.x - x + textW / 2, boundingRect.x - x + boundingRect.width - textW / 2);\r\n }\r\n if (pointerOrientation == \"vertical\") {\r\n if (boundingRect && y > boundingRect.y + textH + pointerLength) {\r\n textY = -textH - pointerLength;\r\n this._verticalOrientation = \"up\";\r\n }\r\n else {\r\n textY = pointerLength;\r\n this._verticalOrientation = \"down\";\r\n }\r\n }\r\n else if (pointerOrientation == \"down\") {\r\n textY = -textH - pointerLength;\r\n this._verticalOrientation = \"up\";\r\n }\r\n else {\r\n textY = pointerLength;\r\n this._verticalOrientation = \"down\";\r\n }\r\n }\r\n if (boundingRect) {\r\n textY = $math.fitToRange(textY, boundingRect.y - y, boundingRect.y + boundingRect.height - textH - y);\r\n }\r\n label.x = textX;\r\n label.y = textY;\r\n this.drawBackground();\r\n };\r\n /**\r\n * Overrides functionality from the superclass.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Tooltip.prototype.updateBackground = function () {\r\n this.group.addToBack(this.background.group);\r\n };\r\n /**\r\n * Draws Tooltip background (chrome, background and pointer/stem).\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Tooltip.prototype.drawBackground = function () {\r\n var label = this.label;\r\n var background = this.background;\r\n var textWidth = label.measuredWidth;\r\n var textHeight = label.measuredHeight;\r\n var boundingRect = this._boundingRect;\r\n var bgWidth = textWidth;\r\n var bgX = label.pixelX - textWidth / 2;\r\n var bgHeight = textHeight;\r\n var bgY = label.pixelY;\r\n var x = this._pointTo.x;\r\n var y = this._pointTo.y;\r\n var boundX1 = boundingRect.x - x;\r\n var boundX2 = boundX1 + boundingRect.width;\r\n var boundY1 = boundingRect.y - y;\r\n var boundY2 = boundY1 + boundingRect.height;\r\n background.x = bgX;\r\n background.y = bgY;\r\n background.width = bgWidth;\r\n background.height = bgHeight;\r\n if (this.fitPointerToBounds) {\r\n background.pointerX = $math.fitToRange(-background.x, boundX1 - background.x, boundX2 - background.x);\r\n background.pointerY = $math.fitToRange(-background.y, boundY1 - background.y, boundY2 - background.y);\r\n }\r\n else {\r\n background.pointerX = -background.x;\r\n background.pointerY = -background.y;\r\n }\r\n background.validate();\r\n };\r\n /**\r\n *\r\n */\r\n Tooltip.prototype.delayedPointTo = function (point, instantly) {\r\n var _this = this;\r\n if (this._pointToDisposer) {\r\n this._pointToDisposer.dispose();\r\n }\r\n this._pointToDisposer = registry.events.once(\"exitframe\", function () {\r\n _this.pointTo(point, instantly);\r\n });\r\n this.addDisposer(this._pointToDisposer);\r\n };\r\n /**\r\n * Set nes tooltip's anchor point and moves whole tooltip.\r\n *\r\n * @param x X coordinate\r\n * @param y Y coordinate\r\n */\r\n Tooltip.prototype.pointTo = function (point, instantly) {\r\n if (this._pointTo.x != point.x || this._pointTo.y != point.y) {\r\n this._pointTo = point;\r\n this.invalidate();\r\n // this helps to avoid strange animation from nowhere on initial show or when balloon was hidden already\r\n if (!this.visible || instantly) {\r\n this.moveTo(this._pointTo);\r\n if (this._animation) {\r\n this._animation.kill();\r\n }\r\n }\r\n else {\r\n // helps to avoid flicker on top/left corner\r\n if (this.pixelX == 0 && this.pixelY == 0) {\r\n this.moveTo(this._pointTo);\r\n }\r\n else {\r\n if (this._animation) {\r\n this._animation.kill();\r\n }\r\n this._animation = new Animation(this, [{ property: \"x\", to: point.x, from: this.pixelX }, { property: \"y\", to: point.y, from: this.pixelY }], this.animationDuration, this.animationEasing).start();\r\n }\r\n }\r\n }\r\n };\r\n /**\r\n * Sets numeric boundaries Tooltip needs to obey (so it does not go outside\r\n * specific area).\r\n *\r\n * @ignore Exclude from docs\r\n * @param rectangle Boundary rectangle\r\n */\r\n Tooltip.prototype.setBounds = function (rectangle) {\r\n var oldRect = this._boundingRect;\r\n if (oldRect.x != rectangle.x || oldRect.y != rectangle.y || oldRect.width != rectangle.width || oldRect.height != rectangle.height) {\r\n this._boundingRect = rectangle;\r\n this.invalidate();\r\n }\r\n };\r\n Object.defineProperty(Tooltip.prototype, \"boundingContainer\", {\r\n /**\r\n * Sets a [[Container]] instance to be used when calculating numeric\r\n * boundaries for the Tooltip.\r\n *\r\n * @ignore Exclude from docs\r\n * @param container Boundary container\r\n */\r\n set: function (container) {\r\n this._boundingContainer = container;\r\n // TODO remove closures ?\r\n container.events.on(\"sizechanged\", this.updateBounds, this);\r\n container.events.on(\"positionchanged\", this.updateBounds, this);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Updates numeric boundaries for the Tooltip, based on the\r\n * `boundingCountrainer`.\r\n */\r\n Tooltip.prototype.updateBounds = function () {\r\n var boundingContainer = this._boundingContainer;\r\n // to global\r\n var rect = $utils.spriteRectToSvg({\r\n x: boundingContainer.pixelX,\r\n y: boundingContainer.pixelY,\r\n width: boundingContainer.maxWidth,\r\n height: boundingContainer.maxHeight\r\n }, boundingContainer);\r\n this.setBounds(rect);\r\n };\r\n Object.defineProperty(Tooltip.prototype, \"ignoreBounds\", {\r\n /**\r\n * @return Ignore chart bounds?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"ignoreBounds\");\r\n },\r\n /**\r\n * Normally, a tooltip's position will be adjusted so it always fits into\r\n * chart's coundaries.\r\n *\r\n * Setting this to `false` will disable such checks and will allow tooltip\r\n * to \"bleed over\" the edge of the chart.\r\n *\r\n * @default false\r\n * @since 4.10.8\r\n * @param value Ignore chart bounds?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"ignoreBounds\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Tooltip.prototype, \"verticalOrientation\", {\r\n /**\r\n * If tooltipOrientation is vertical, it can be drawn below or above point.\r\n * We need to know this when solving overlapping.\r\n *\r\n * @ignore Exclude from docs\r\n * @return \"up\" | \"down\"\r\n */\r\n get: function () {\r\n return this._verticalOrientation;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Tooltip.prototype, \"tooltip\", {\r\n /**\r\n * To avoid stackoverflow\r\n * @ignore\r\n */\r\n get: function () {\r\n return undefined;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Copies properties and other attributes.\r\n *\r\n * @param source Source\r\n */\r\n Tooltip.prototype.copyFrom = function (source) {\r\n _super.prototype.copyFrom.call(this, source);\r\n this.label.copyFrom(source.label);\r\n if (source._boundingRect) {\r\n this._boundingRect = source._boundingRect;\r\n }\r\n };\r\n /**\r\n * Adds easing functions to \"function\" fields.\r\n *\r\n * @param field Field name\r\n * @return Assign as function?\r\n */\r\n Tooltip.prototype.asFunction = function (field) {\r\n return field == \"animationEasing\" || _super.prototype.asIs.call(this, field);\r\n };\r\n return Tooltip;\r\n}(Container));\r\nexport { Tooltip };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Tooltip\"] = Tooltip;\r\n//# sourceMappingURL=Tooltip.js.map","/**\r\n * Functionality for drawing a trapezoid.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Sprite } from \"../Sprite\";\r\nimport { percent } from \"../../core/utils/Percent\";\r\nimport { registry } from \"../Registry\";\r\nimport * as $utils from \"../utils/Utils\";\r\nimport * as $type from \"../utils/Type\";\r\nimport * as $path from \"../rendering/Path\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Used to draw a Trapezoid.\r\n *\r\n * @see {@link ITrapezoidEvents} for a list of available events\r\n * @see {@link ITrapezoidAdapters} for a list of available Adapters\r\n */\r\nvar Trapezoid = /** @class */ (function (_super) {\r\n __extends(Trapezoid, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Trapezoid() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"Trapezoid\";\r\n _this.element = _this.paper.add(\"path\");\r\n _this.topSide = percent(100);\r\n _this.bottomSide = percent(100);\r\n _this.leftSide = percent(100);\r\n _this.rightSide = percent(100);\r\n _this.isMeasured = false; // todo: add measureElement\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Draws the element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Trapezoid.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n var w = this.pixelWidth;\r\n var h = this.pixelHeight;\r\n var ts = $utils.relativeToValue(this.topSide, w);\r\n var bs = $utils.relativeToValue(this.bottomSide, w);\r\n var ls = $utils.relativeToValue(this.leftSide, h);\r\n var rs = $utils.relativeToValue(this.rightSide, h);\r\n // 1----2\r\n // | |\r\n // 4----3\r\n var x0 = (w - ts) / 2;\r\n var y0 = (h - ls) / 2;\r\n var x1 = w - (w - ts) / 2;\r\n var y1 = (h - rs) / 2;\r\n var x2 = w - (w - bs) / 2;\r\n var y2 = h - (h - rs) / 2;\r\n var x3 = (w - bs) / 2;\r\n var y3 = h - (h - ls) / 2;\r\n var mt = \"\";\r\n var mr = \"\";\r\n var mb = \"\";\r\n var ml = \"\";\r\n if ($type.hasValue(this.horizontalNeck)) {\r\n var hn = this.horizontalNeck.value;\r\n mt = $path.lineTo({ x: w * hn, y: Math.max(y0, y1) });\r\n mb = $path.lineTo({ x: w * hn, y: Math.min(y2, y3) });\r\n }\r\n if ($type.hasValue(this.verticalNeck)) {\r\n var vn = this.verticalNeck.value;\r\n mr = $path.lineTo({ x: Math.min(x1, x2), y: h * vn });\r\n ml = $path.lineTo({ x: Math.max(x0, x3), y: h * vn });\r\n }\r\n var path = $path.moveTo({ x: x0, y: y0 })\r\n + mt\r\n + $path.lineTo({ x: x1, y: y1 })\r\n + mr\r\n + $path.lineTo({ x: x2, y: y2 })\r\n + mb\r\n + $path.lineTo({ x: x3, y: y3 })\r\n + ml;\r\n this.path = path;\r\n };\r\n Object.defineProperty(Trapezoid.prototype, \"topSide\", {\r\n /**\r\n * @return Width\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"topSide\");\r\n },\r\n /**\r\n * Wdith of the top side. Absolute (px) or relative ([[Percent]]).\r\n *\r\n * @default Percent(100)\r\n * @param value Width\r\n */\r\n set: function (value) {\r\n this.setPercentProperty(\"topSide\", value, true, false, 10, false);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Trapezoid.prototype, \"bottomSide\", {\r\n /**\r\n * @return Width\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"bottomSide\");\r\n },\r\n /**\r\n * Wdith of the bottom side. Absolute (px) or relative ([[Percent]]).\r\n *\r\n * @default Percent(100)\r\n * @param value Width\r\n */\r\n set: function (value) {\r\n this.setPercentProperty(\"bottomSide\", value, true, false, 10, false);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Trapezoid.prototype, \"leftSide\", {\r\n /**\r\n * @return Height\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"leftSide\");\r\n },\r\n /**\r\n * Height of the left side. Absolute (px) or relative ([[Percent]]).\r\n *\r\n * @default Percent(100)\r\n * @param value Height\r\n */\r\n set: function (value) {\r\n this.setPercentProperty(\"leftSide\", value, true, false, 10, false);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Trapezoid.prototype, \"rightSide\", {\r\n /**\r\n * @return Height\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"rightSide\");\r\n },\r\n /**\r\n * Height of the right side. Absolute (px) or relative ([[Percent]]).\r\n *\r\n * @default Percent(100)\r\n * @param value Height\r\n */\r\n set: function (value) {\r\n this.setPercentProperty(\"rightSide\", value, true, false, 10, false);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Trapezoid.prototype, \"horizontalNeck\", {\r\n /**\r\n * @return Horizontal neck position\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"horizontalNeck\");\r\n },\r\n /**\r\n * A relative vertical position of the \"neck\". If the top and bottom sides\r\n * are of different width, and `horizontalNeck` is set, a choke point\r\n * will be created at that position, creating a funnel shape.\r\n *\r\n * @param value Horizontal neck position\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"horizontalNeck\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Trapezoid.prototype, \"verticalNeck\", {\r\n /**\r\n * @return Vertical neck position\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"verticalNeck\");\r\n },\r\n /**\r\n * A relative horizontal position of the \"neck\". If the left and right sides\r\n * are of different height, and `verticalNeck` is set, a choke point\r\n * will be created at that position, creating a funnel shape.\r\n *\r\n * @param value Vertical neck position\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"verticalNeck\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Trapezoid;\r\n}(Sprite));\r\nexport { Trapezoid };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Trapezoid\"] = Trapezoid;\r\n//# sourceMappingURL=Trapezoid.js.map","/**\r\n * Functionality for drawing triangles.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Sprite } from \"../Sprite\";\r\nimport { registry } from \"../Registry\";\r\nimport * as $path from \"../rendering/Path\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Used to draw a triangle.\r\n *\r\n * @see {@link ITriangleEvents} for a list of available events\r\n * @see {@link ITriangleAdapters} for a list of available Adapters\r\n */\r\nvar Triangle = /** @class */ (function (_super) {\r\n __extends(Triangle, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Triangle() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"Triangle\";\r\n _this.element = _this.paper.add(\"path\");\r\n _this.direction = \"top\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Draws the element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Triangle.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n var w = this.pixelWidth;\r\n var h = this.pixelHeight;\r\n var path;\r\n switch (this.direction) {\r\n case \"right\":\r\n path = $path.moveTo({ x: 0, y: 0 })\r\n + $path.lineTo({ x: w, y: h / 2 })\r\n + $path.lineTo({ x: 0, y: h })\r\n + $path.closePath();\r\n break;\r\n case \"left\":\r\n path = $path.moveTo({ x: w, y: 0 })\r\n + $path.lineTo({ x: 0, y: h / 2 })\r\n + $path.lineTo({ x: w, y: h })\r\n + $path.closePath();\r\n break;\r\n case \"bottom\":\r\n path = $path.moveTo({ x: 0, y: 0 })\r\n + $path.lineTo({ x: w, y: 0 })\r\n + $path.lineTo({ x: w / 2, y: h })\r\n + $path.closePath();\r\n break;\r\n case \"top\":\r\n path = $path.moveTo({ x: w / 2, y: 0 })\r\n + $path.lineTo({ x: w, y: h })\r\n + $path.lineTo({ x: 0, y: h })\r\n + $path.closePath();\r\n break;\r\n }\r\n this.path = path;\r\n };\r\n Object.defineProperty(Triangle.prototype, \"direction\", {\r\n /**\r\n * Returns direction of a triangle\r\n *\r\n * @return value\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"direction\");\r\n },\r\n /**\r\n * Sets direction of a triangle\r\n *\r\n * @param value\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"direction\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Triangle;\r\n}(Sprite));\r\nexport { Triangle };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Triangle\"] = Triangle;\r\n//# sourceMappingURL=Triangle.js.map","import { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { registry } from \"../Registry\";\r\nimport * as $path from \"./Path\";\r\nimport * as $array from \"../utils/Array\";\r\nimport * as $utils from \"../utils/Utils\";\r\nimport * as $math from \"../utils/Math\";\r\n/**\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n */\r\nvar Tension = /** @class */ (function () {\r\n /**\r\n * Constructor.\r\n *\r\n * @param tensionX [description]\r\n * @param tensionY [description]\r\n */\r\n function Tension(tensionX, tensionY) {\r\n this._tensionX = tensionX;\r\n this._tensionY = tensionY;\r\n }\r\n /**\r\n * [smooth description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param points [description]\r\n * @return [description]\r\n */\r\n Tension.prototype.smooth = function (points) {\r\n for (var i = points.length - 1; i > 0; i--) {\r\n var p0 = points[i];\r\n var p1 = points[i - 1];\r\n if (Math.abs(p0.x - p1.x) < 0.1 && Math.abs(p0.y - p1.y) < 0.1) {\r\n points.splice(i - 1, 1);\r\n }\r\n }\r\n var tensionX = this._tensionX;\r\n var tensionY = this._tensionY;\r\n if (points.length < 3 || (tensionX >= 1 && tensionY >= 1)) {\r\n return $path.polyline(points);\r\n }\r\n var first = points[0];\r\n var last = points[points.length - 1];\r\n var closed = false;\r\n if ($math.round(first.x, 3) == $math.round(last.x) && $math.round(first.y) == $math.round(last.y)) {\r\n closed = true;\r\n }\r\n // Can't moveTo here, as it wont be possible to have fill then.\r\n var path = \"\";\r\n for (var i = 0, len = points.length - 1; i < len; i++) {\r\n var p0 = points[i - 1];\r\n var p1 = points[i];\r\n var p2 = points[i + 1];\r\n var p3 = points[i + 2];\r\n if (i === 0) {\r\n if (closed) {\r\n p0 = points[points.length - 2];\r\n }\r\n else {\r\n p0 = points[i];\r\n }\r\n }\r\n else if (i == points.length - 2) {\r\n if (closed) {\r\n p3 = points[1];\r\n }\r\n else {\r\n p3 = points[i + 1];\r\n }\r\n }\r\n var controlPointA = $math.getCubicControlPointA(p0, p1, p2, p3, tensionX, tensionY);\r\n var controlPointB = $math.getCubicControlPointB(p0, p1, p2, p3, tensionX, tensionY);\r\n path += $path.cubicCurveTo(p2, controlPointA, controlPointB);\r\n }\r\n return path;\r\n };\r\n return Tension;\r\n}());\r\nexport { Tension };\r\n/**\r\n * Returns a waved line SVG path between two points.\r\n *\r\n * @ignore Exclude from docs\r\n * @param point1 Starting point\r\n * @param point2 Ending point\r\n * @param waveLength Wave length\r\n * @param waveHeight Wave height\r\n * @param adjustWaveLength Adjust wave length based on the actual line length\r\n * @return SVG path\r\n */\r\nexport function wavedLine(point1, point2, waveLength, waveHeight, tension, adjustWaveLength) {\r\n var x1 = point1.x;\r\n var y1 = point1.y;\r\n var x2 = point2.x;\r\n var y2 = point2.y;\r\n var distance = $math.getDistance(point1, point2);\r\n if (adjustWaveLength) {\r\n waveLength = distance / Math.round(distance / waveLength);\r\n }\r\n var d = registry.getCache($utils.stringify([\"wavedLine\", point1.x, point2.x, point1.y, point2.y, waveLength, waveHeight]));\r\n if (!d) {\r\n if (distance > 0) {\r\n var angle = Math.atan2(y2 - y1, x2 - x1);\r\n var cos = Math.cos(angle);\r\n var sin = Math.sin(angle);\r\n var waveLengthX = waveLength * cos;\r\n var waveLengthY = waveLength * sin;\r\n if (waveLength <= 1 || waveHeight <= 1) {\r\n d = $path.lineTo(point2);\r\n }\r\n else {\r\n var halfWaveCount = Math.round(2 * distance / waveLength);\r\n var points = [];\r\n var sign_1 = 1;\r\n if (x2 < x1) {\r\n sign_1 *= -1;\r\n }\r\n if (y2 < y1) {\r\n sign_1 *= -1;\r\n }\r\n for (var i = 0; i <= halfWaveCount; i++) {\r\n sign_1 *= -1;\r\n var x = x1 + i * waveLengthX / 2 + sign_1 * waveHeight / 2 * sin;\r\n var y = y1 + i * waveLengthY / 2 - sign_1 * waveHeight / 2 * cos;\r\n points.push({ x: x, y: y });\r\n }\r\n d = new Tension(tension, tension).smooth(points);\r\n }\r\n }\r\n else {\r\n d = \"\";\r\n }\r\n registry.setCache($utils.stringify([\"wavedLine\", point1.x, point2.x, point1.y, point2.y, waveLength, waveHeight]), d);\r\n }\r\n return d;\r\n}\r\nvar Monotone = /** @class */ (function () {\r\n function Monotone(reversed, info) {\r\n this._reversed = reversed;\r\n this._closed = info.closed;\r\n }\r\n // According to https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Representations\r\n // \"you can express cubic Hermite interpolation in terms of cubic Bézier curves\r\n // with respect to the four values p0, p0 + m0 / 3, p1 - m1 / 3, p1\".\r\n Monotone.prototype._curve = function (x0, x1, y0, y1, t0, t1) {\r\n var dx = (x1 - x0) / 3;\r\n if (this._reversed) {\r\n return $path.cubicCurveTo({ x: y1, y: x1 }, { x: y0 + dx * t0, y: x0 + dx }, { x: y1 - dx * t1, y: x1 - dx });\r\n }\r\n else {\r\n return $path.cubicCurveTo({ x: x1, y: y1 }, { x: x0 + dx, y: y0 + dx * t0 }, { x: x1 - dx, y: y1 - dx * t1 });\r\n }\r\n };\r\n Monotone.prototype.smooth = function (points) {\r\n var _this = this;\r\n var x0 = NaN;\r\n var x1 = NaN;\r\n var y0 = NaN;\r\n var y1 = NaN;\r\n var t0 = NaN;\r\n var point = 0;\r\n var output = \"\";\r\n $array.each(points, function (_a) {\r\n var x = _a.x, y = _a.y;\r\n if (_this._reversed) {\r\n var temp = x;\r\n x = y;\r\n y = temp;\r\n }\r\n var t1 = NaN;\r\n if (!(x === x1 && y === y1)) {\r\n switch (point) {\r\n case 0:\r\n point = 1;\r\n if (_this._reversed) {\r\n output += $path.lineTo({ x: y, y: x });\r\n }\r\n else {\r\n output += $path.lineTo({ x: x, y: y });\r\n }\r\n break;\r\n case 1:\r\n point = 2;\r\n break;\r\n case 2:\r\n point = 3;\r\n output += _this._curve(x0, x1, y0, y1, slope2(x0, x1, y0, y1, t1 = slope3(x0, x1, y0, y1, x, y)), t1);\r\n break;\r\n default:\r\n output += _this._curve(x0, x1, y0, y1, t0, t1 = slope3(x0, x1, y0, y1, x, y));\r\n break;\r\n }\r\n x0 = x1;\r\n x1 = x;\r\n y0 = y1;\r\n y1 = y;\r\n t0 = t1;\r\n }\r\n });\r\n switch (point) {\r\n case 2:\r\n if (this._reversed) {\r\n output += $path.lineTo({ x: y1, y: x1 });\r\n }\r\n else {\r\n output += $path.lineTo({ x: x1, y: y1 });\r\n }\r\n break;\r\n case 3:\r\n output += this._curve(x0, x1, y0, y1, t0, slope2(x0, x1, y0, y1, t0));\r\n break;\r\n }\r\n if (this._closed) {\r\n output += $path.closePath();\r\n }\r\n return output;\r\n };\r\n return Monotone;\r\n}());\r\nexport { Monotone };\r\n// TODO move this someplace else\r\nfunction sign(x) {\r\n return x < 0 ? -1 : 1;\r\n}\r\nfunction slope2(x0, x1, y0, y1, t) {\r\n var h = x1 - x0;\r\n return h ? (3 * (y1 - y0) / h - t) / 2 : t;\r\n}\r\nfunction slope3(x0, x1, y0, y1, x2, y2) {\r\n var h0 = x1 - x0;\r\n var h1 = x2 - x1;\r\n var s0 = (y1 - y0) / (h0 || h1 < 0 && -0);\r\n var s1 = (y2 - y1) / (h1 || h0 < 0 && -0);\r\n var p = (s0 * h1 + s1 * h0) / (h0 + h1);\r\n return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0;\r\n}\r\nvar MonotoneX = /** @class */ (function (_super) {\r\n __extends(MonotoneX, _super);\r\n function MonotoneX(info) {\r\n return _super.call(this, false, info) || this;\r\n }\r\n return MonotoneX;\r\n}(Monotone));\r\nexport { MonotoneX };\r\nvar MonotoneY = /** @class */ (function (_super) {\r\n __extends(MonotoneY, _super);\r\n function MonotoneY(info) {\r\n return _super.call(this, true, info) || this;\r\n }\r\n return MonotoneY;\r\n}(Monotone));\r\nexport { MonotoneY };\r\n/**\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n */\r\nvar Basis = /** @class */ (function () {\r\n /**\r\n * Constructor.\r\n *\r\n * @param info [description]\r\n */\r\n function Basis(info) {\r\n this._closed = info.closed;\r\n }\r\n /**\r\n * [smooth description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param points [description]\r\n * @return [description]\r\n */\r\n Basis.prototype.smooth = function (points) {\r\n var _this = this;\r\n var x0 = NaN;\r\n var x1 = NaN;\r\n var x2 = NaN;\r\n var x3 = NaN;\r\n var x4 = NaN;\r\n var y0 = NaN;\r\n var y1 = NaN;\r\n var y2 = NaN;\r\n var y3 = NaN;\r\n var y4 = NaN;\r\n var point = 0;\r\n var output = \"\";\r\n var pushCurve = function (x, y) {\r\n output += $path.cubicCurveTo({\r\n x: (x0 + 4 * x1 + x) / 6,\r\n y: (y0 + 4 * y1 + y) / 6\r\n }, {\r\n x: (2 * x0 + x1) / 3,\r\n y: (2 * y0 + y1) / 3\r\n }, {\r\n x: (x0 + 2 * x1) / 3,\r\n y: (y0 + 2 * y1) / 3\r\n });\r\n };\r\n var pushPoint = function (_a) {\r\n var x = _a.x, y = _a.y;\r\n switch (point) {\r\n case 0:\r\n point = 1;\r\n if (_this._closed) {\r\n x2 = x;\r\n y2 = y;\r\n }\r\n else {\r\n output += $path.lineTo({ x: x, y: y });\r\n }\r\n break;\r\n case 1:\r\n point = 2;\r\n if (_this._closed) {\r\n x3 = x;\r\n y3 = y;\r\n }\r\n break;\r\n case 2:\r\n point = 3;\r\n if (_this._closed) {\r\n x4 = x;\r\n y4 = y;\r\n output += $path.moveTo({ x: (x0 + 4 * x1 + x) / 6, y: (y0 + 4 * y1 + y) / 6 });\r\n break;\r\n }\r\n else {\r\n output += $path.lineTo({ x: (5 * x0 + x1) / 6, y: (5 * y0 + y1) / 6 });\r\n // fall-through\r\n }\r\n default:\r\n pushCurve(x, y);\r\n break;\r\n }\r\n x0 = x1;\r\n x1 = x;\r\n y0 = y1;\r\n y1 = y;\r\n };\r\n $array.each(points, pushPoint);\r\n if (this._closed) {\r\n switch (point) {\r\n case 1:\r\n output += $path.moveTo({ x: x2, y: y2 });\r\n output += $path.closePath();\r\n break;\r\n case 2:\r\n output += $path.moveTo({ x: (x2 + 2 * x3) / 3, y: (y2 + 2 * y3) / 3 });\r\n output += $path.lineTo({ x: (x3 + 2 * x2) / 3, y: (y3 + 2 * y2) / 3 });\r\n output += $path.closePath();\r\n break;\r\n case 3:\r\n pushPoint({ x: x2, y: y2 });\r\n pushPoint({ x: x3, y: y3 });\r\n pushPoint({ x: x4, y: y4 });\r\n break;\r\n }\r\n }\r\n else {\r\n switch (point) {\r\n case 3:\r\n pushCurve(x1, y1);\r\n // fall-through\r\n case 2:\r\n output += $path.lineTo({ x: x1, y: y1 });\r\n break;\r\n }\r\n output += $path.closePath();\r\n }\r\n return output;\r\n };\r\n return Basis;\r\n}());\r\nexport { Basis };\r\n//# sourceMappingURL=Smoothing.js.map","/**\r\n * Functionality for drawing waved circles.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Circle } from \"./Circle\";\r\nimport { registry } from \"../Registry\";\r\nimport * as $path from \"../rendering/Path\";\r\nimport * as $math from \"../utils/Math\";\r\nimport * as $utils from \"../utils/Utils\";\r\nimport * as $smoothing from \"../../core/rendering/Smoothing\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Draws a waved circle.\r\n *\r\n * @see {@link IWavedCircleEvents} for a list of available events\r\n * @see {@link IWavedCircleAdapters} for a list of available Adapters\r\n */\r\nvar WavedCircle = /** @class */ (function (_super) {\r\n __extends(WavedCircle, _super);\r\n /**\r\n * Constructor\r\n */\r\n function WavedCircle() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"WavedCircle\";\r\n _this.element = _this.paper.add(\"path\");\r\n _this.waveLength = 16;\r\n _this.waveHeight = 4;\r\n _this.fill = undefined;\r\n _this.fillOpacity = 0;\r\n _this.tension = 0.8;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Draws the waved line.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n WavedCircle.prototype.draw = function () {\r\n var path = \"\";\r\n var radius = this.pixelRadius;\r\n if (radius > 0) {\r\n var points = this.getPoints(radius);\r\n path = $path.moveTo(points[0]) + new $smoothing.Tension(this.tension, this.tension).smooth(points);\r\n }\r\n var innerRadius = this.pixelInnerRadius;\r\n if (innerRadius > 0) {\r\n var points = this.getPoints(innerRadius);\r\n points.reverse();\r\n path += $path.moveTo(points[0]) + new $smoothing.Tension(this.tension, this.tension).smooth(points);\r\n }\r\n this.path = path;\r\n };\r\n /**\r\n * Returns points that circle consists of.\r\n *\r\n * @param radius Radius (px)\r\n * @return Points\r\n */\r\n WavedCircle.prototype.getPoints = function (radius) {\r\n var circleLength = radius * Math.PI * 2;\r\n var halfWaveHeight = this.waveHeight / 2;\r\n var waveLength = circleLength / Math.round(circleLength / this.waveLength);\r\n var halfWaveLength = waveLength / 2;\r\n var points = [];\r\n var count = circleLength / waveLength;\r\n for (var i = 0; i <= count; i++) {\r\n var angle1 = (i * waveLength) / circleLength * 360;\r\n var angle2 = (i * waveLength + halfWaveLength) / circleLength * 360;\r\n points.push({ x: (radius - halfWaveHeight) * $math.cos(angle1), y: (radius - halfWaveHeight) * $math.sin(angle1) });\r\n points.push({ x: (radius + halfWaveHeight) * $math.cos(angle2), y: (radius + halfWaveHeight) * $math.sin(angle2) });\r\n }\r\n points.pop();\r\n return points;\r\n };\r\n Object.defineProperty(WavedCircle.prototype, \"innerRadius\", {\r\n /**\r\n * @return Inner radius\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"innerRadius\");\r\n },\r\n /**\r\n * Inner radius of the circle in pixels (absolute) or [[Percent]] (relative).\r\n *\r\n * @param value Inner radius\r\n */\r\n set: function (value) {\r\n this.setPercentProperty(\"innerRadius\", value, true, false, 10, false);\r\n this.invalidate();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(WavedCircle.prototype, \"pixelInnerRadius\", {\r\n /**\r\n * Calculated inner radius of the circle in pixels.\r\n *\r\n * @readonly\r\n * @return Inner radius (px)\r\n */\r\n get: function () {\r\n return $utils.relativeToValue(this.innerRadius, $math.min(this.innerWidth / 2, this.innerHeight / 2));\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(WavedCircle.prototype, \"waveLength\", {\r\n /**\r\n * @return Wave length (px)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"waveLength\");\r\n },\r\n /**\r\n * Wave length in pixels.\r\n *\r\n * @default 16\r\n * @param value Wave length (px)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"waveLength\", value);\r\n this.invalidate();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(WavedCircle.prototype, \"waveHeight\", {\r\n /**\r\n * @return Wave height (px)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"waveHeight\");\r\n },\r\n /**\r\n * Wave height in pixels.\r\n *\r\n * @default 4\r\n * @param value Wave height (px)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"waveHeight\", value);\r\n this.invalidate();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(WavedCircle.prototype, \"tension\", {\r\n /**\r\n * @return Tension\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"tension\");\r\n },\r\n /**\r\n * Tension of the wave.\r\n *\r\n * @default 0.8\r\n * @param value Tension\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"tension\", value);\r\n this.invalidate();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return WavedCircle;\r\n}(Circle));\r\nexport { WavedCircle };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"WavedCircle\"] = WavedCircle;\r\n//# sourceMappingURL=WavedCircle.js.map","/**\r\n * Functionality for drawing waved lines.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Line } from \"./Line\";\r\nimport { color } from \"../utils/Color\";\r\nimport { wavedLine } from \"../rendering/Smoothing\";\r\nimport * as $path from \"../rendering/Path\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Draws a waved line.\r\n *\r\n * @see {@link IWavedLineEvents} for a list of available events\r\n * @see {@link IWavedLineAdapters} for a list of available Adapters\r\n */\r\nvar WavedLine = /** @class */ (function (_super) {\r\n __extends(WavedLine, _super);\r\n /**\r\n * Constructor\r\n */\r\n function WavedLine() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"WavedLine\";\r\n _this.element = _this.paper.add(\"path\");\r\n _this.waveLength = 16;\r\n _this.waveHeight = 4;\r\n _this.tension = 0.8;\r\n _this.pixelPerfect = false;\r\n _this.fill = color();\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Draws the waved line.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n WavedLine.prototype.draw = function () {\r\n //super.draw();\r\n var p1 = { x: this.x1, y: this.y1 };\r\n var p2 = { x: this.x2, y: this.y2 };\r\n this.path = $path.moveTo(p1) + wavedLine(p1, p2, this.waveLength, this.waveHeight, this.tension, true);\r\n };\r\n Object.defineProperty(WavedLine.prototype, \"waveLength\", {\r\n /**\r\n * @return Wave length (px)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"waveLength\");\r\n },\r\n /**\r\n * Wave length in pixels.\r\n *\r\n * @default 16\r\n * @param value Wave length (px)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"waveLength\", value);\r\n this.invalidate();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(WavedLine.prototype, \"waveHeight\", {\r\n /**\r\n * @return Wave height (px)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"waveHeight\");\r\n },\r\n /**\r\n * Wave height in pixels.\r\n *\r\n * @default 4\r\n * @param value Wave height (px)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"waveHeight\", value);\r\n this.invalidate();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(WavedLine.prototype, \"tension\", {\r\n /**\r\n * @return Tension\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"tension\");\r\n },\r\n /**\r\n * Tension of the wave.\r\n *\r\n * @default 0.8\r\n * @param value Tension\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"tension\", value);\r\n this.invalidate();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return WavedLine;\r\n}(Line));\r\nexport { WavedLine };\r\n//# sourceMappingURL=WavedLine.js.map","/**\r\n * Functionality for drawing rectangles with waved edges.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Rectangle } from \"./Rectangle\";\r\nimport { wavedLine } from \"../rendering/Smoothing\";\r\nimport * as $path from \"../rendering/Path\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Draws a rectangle with waved edges.\r\n *\r\n * @see {@link IWavedRectangleEvents} for a list of available events\r\n * @see {@link IWavedRectangleAdapters} for a list of available Adapters\r\n */\r\nvar WavedRectangle = /** @class */ (function (_super) {\r\n __extends(WavedRectangle, _super);\r\n /**\r\n * Constructor\r\n */\r\n function WavedRectangle() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"WavedRectangle\";\r\n // Add path element\r\n _this.element = _this.paper.add(\"path\");\r\n // Set defaults\r\n _this.waveLength = 16;\r\n _this.waveHeight = 4;\r\n _this.tension = 0.8;\r\n _this.setPropertyValue(\"wavedLeft\", true);\r\n _this.setPropertyValue(\"wavedRight\", true);\r\n _this.setPropertyValue(\"wavedTop\", true);\r\n _this.setPropertyValue(\"wavedBottom\", true);\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Draws the waved rectangle.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n WavedRectangle.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n var w = this.pixelWidth;\r\n var h = this.pixelHeight;\r\n if (w > 0 && h > 0) {\r\n var p1 = { x: 0, y: 0 };\r\n var p2 = { x: w, y: 0 };\r\n var p3 = { x: w, y: h };\r\n var p4 = { x: 0, y: h };\r\n var waveLengthH = Math.min(w, this.waveLength);\r\n var waveHeightH = Math.min(h, this.waveHeight);\r\n var waveLengthV = Math.min(h, this.waveLength);\r\n var waveHeightV = Math.min(w, this.waveHeight);\r\n var td = \"\";\r\n var rd = \"\";\r\n var bd = \"\";\r\n var ld = \"\";\r\n if (this.wavedTop) {\r\n td = wavedLine(p1, p2, waveLengthH, waveHeightH, this.tension, true);\r\n }\r\n if (this.wavedRight) {\r\n rd = wavedLine(p2, p3, waveLengthV, waveHeightV, this.tension, true);\r\n }\r\n if (this.wavedBottom) {\r\n bd = wavedLine(p3, p4, waveLengthH, waveHeightH, this.tension, true);\r\n }\r\n if (this.wavedLeft) {\r\n ld = wavedLine(p4, p1, waveLengthV, waveHeightV, this.tension, true);\r\n }\r\n this.path = $path.moveTo(p1) + td + $path.lineTo(p2) + rd + $path.lineTo(p3) + bd + $path.lineTo(p4) + ld + \"z\";\r\n }\r\n };\r\n Object.defineProperty(WavedRectangle.prototype, \"waveLength\", {\r\n /**\r\n * @return Wave length (px)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"waveLength\");\r\n },\r\n /**\r\n * Wave length in pixels.\r\n *\r\n * @default 16\r\n * @param value Wave length (px)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"waveLength\", value);\r\n this.invalidate();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(WavedRectangle.prototype, \"waveHeight\", {\r\n /**\r\n * @return Wave height (px)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"waveHeight\");\r\n },\r\n /**\r\n * Wave height in pixels.\r\n *\r\n * @default 4\r\n * @param value Wave height (px)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"waveHeight\", value);\r\n this.invalidate();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Sets which side should be waved or not. If particular side is set to\r\n * `false`, a straight line will be drawn on that side.\r\n *\r\n * @param top Top waved?\r\n * @param right Right side waved?\r\n * @param bottom Bottom Waved?\r\n * @param left Left side waved?\r\n */\r\n WavedRectangle.prototype.setWavedSides = function (top, right, bottom, left) {\r\n this.wavedTop = top;\r\n this.wavedRight = right;\r\n this.wavedBottom = bottom;\r\n this.wavedLeft = left;\r\n };\r\n Object.defineProperty(WavedRectangle.prototype, \"tension\", {\r\n /**\r\n * @return Tension\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"tension\");\r\n },\r\n /**\r\n * Tension of the wave.\r\n *\r\n * @default 0.8\r\n * @param value Tension\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"tension\", value);\r\n this.invalidate();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(WavedRectangle.prototype, \"wavedRight\", {\r\n /**\r\n * @return Wave right side?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"wavedRight\");\r\n },\r\n /**\r\n * Specifies if right side should be waved.\r\n *\r\n * @default true\r\n * @param value Waved?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"wavedRight\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(WavedRectangle.prototype, \"wavedLeft\", {\r\n /**\r\n * @return Wave left side?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"wavedLeft\");\r\n },\r\n /**\r\n * Specifies if left side should be waved.\r\n *\r\n * @default true\r\n * @param value Waved?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"wavedLeft\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(WavedRectangle.prototype, \"wavedTop\", {\r\n /**\r\n * @return Wave top side?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"wavedTop\");\r\n },\r\n /**\r\n * Specifies if top side should be waved.\r\n *\r\n * @default true\r\n * @param value Waved?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"wavedTop\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(WavedRectangle.prototype, \"wavedBottom\", {\r\n /**\r\n * @return Wave bottom side?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"wavedBottom\");\r\n },\r\n /**\r\n * Specifies if bottom side should be waved.\r\n *\r\n * @default true\r\n * @param value Waved?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"wavedBottom\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return WavedRectangle;\r\n}(Rectangle));\r\nexport { WavedRectangle };\r\n//# sourceMappingURL=WavedRectangle.js.map","/**\r\n * Zoom out button functionality.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Button } from \"./Button\";\r\nimport { Sprite } from \"../Sprite\";\r\nimport { registry } from \"../Registry\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport * as $path from \"../rendering/Path\";\r\nimport * as $type from \"../../core/utils/Type\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creates a zoom out button.\r\n *\r\n * @see {@link IZoomOutButtonEvents} for a list of available events\r\n * @see {@link IZoomOutButtonAdapters} for a list of available Adapters\r\n */\r\nvar ZoomOutButton = /** @class */ (function (_super) {\r\n __extends(ZoomOutButton, _super);\r\n /**\r\n * Constructor\r\n */\r\n function ZoomOutButton() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"ZoomOutButton\";\r\n _this.padding(9, 9, 9, 9);\r\n //this.dx = - 5;\r\n //this.dy = 5;\r\n _this.showSystemTooltip = true;\r\n var interfaceColors = new InterfaceColorSet();\r\n var background = _this.background;\r\n background.cornerRadius(20, 20, 20, 20);\r\n background.fill = interfaceColors.getFor(\"primaryButton\");\r\n background.stroke = interfaceColors.getFor(\"primaryButtonStroke\");\r\n background.strokeOpacity = 0;\r\n background.states.getKey(\"hover\").properties.fill = interfaceColors.getFor(\"primaryButtonHover\");\r\n background.states.getKey(\"down\").properties.fill = interfaceColors.getFor(\"primaryButtonActive\");\r\n // Create an icon\r\n var icon = new Sprite();\r\n icon.element = _this.paper.add(\"path\");\r\n var path = $path.moveTo({ x: 0, y: 0 });\r\n path += $path.lineTo({ x: 11, y: 0 });\r\n icon.path = path;\r\n icon.pixelPerfect = true;\r\n icon.padding(8, 3, 8, 3);\r\n icon.stroke = interfaceColors.getFor(\"primaryButtonText\");\r\n _this.icon = icon;\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Sets defaults that instantiate some objects that rely on parent, so they\r\n * cannot be set in constructor.\r\n */\r\n ZoomOutButton.prototype.applyInternalDefaults = function () {\r\n _super.prototype.applyInternalDefaults.call(this);\r\n if (!$type.hasValue(this.readerTitle)) {\r\n this.readerTitle = this.language.translate(\"Zoom Out\");\r\n }\r\n };\r\n return ZoomOutButton;\r\n}(Button));\r\nexport { ZoomOutButton };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"ZoomOutButton\"] = ZoomOutButton;\r\n//# sourceMappingURL=ZoomOutButton.js.map","/**\r\n * Play button functionality.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Button } from \"./Button\";\r\nimport { RoundedRectangle } from \"./RoundedRectangle\";\r\nimport { registry } from \"../Registry\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport { Triangle } from \"./Triangle\";\r\nimport * as $type from \"../../core/utils/Type\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creates a zoom out button.\r\n *\r\n * @see {@link IPlayButtonEvents} for a list of available events\r\n * @see {@link IPlayButtonAdapters} for a list of available Adapters\r\n */\r\nvar PlayButton = /** @class */ (function (_super) {\r\n __extends(PlayButton, _super);\r\n /**\r\n * Constructor\r\n */\r\n function PlayButton() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"PlayButton\";\r\n _this.padding(12, 12, 12, 12);\r\n _this.showSystemTooltip = true;\r\n var interfaceColors = new InterfaceColorSet();\r\n var background = _this.background;\r\n background.cornerRadius(25, 25, 25, 25);\r\n background.fill = interfaceColors.getFor(\"primaryButton\");\r\n background.stroke = interfaceColors.getFor(\"primaryButtonStroke\");\r\n background.strokeOpacity = 0;\r\n background.states.getKey(\"hover\").properties.fill = interfaceColors.getFor(\"primaryButtonHover\");\r\n background.states.getKey(\"down\").properties.fill = interfaceColors.getFor(\"primaryButtonActive\");\r\n // Create a play icon\r\n var playIcon = new Triangle();\r\n playIcon.direction = \"right\";\r\n playIcon.width = 9;\r\n playIcon.height = 11;\r\n playIcon.marginLeft = 1;\r\n playIcon.marginRight = 1;\r\n playIcon.horizontalCenter = \"middle\";\r\n playIcon.verticalCenter = \"middle\";\r\n playIcon.stroke = interfaceColors.getFor(\"primaryButtonText\");\r\n playIcon.fill = playIcon.stroke;\r\n _this.icon = playIcon;\r\n // Create a play icon\r\n var stopIcon = new RoundedRectangle();\r\n stopIcon.width = 11;\r\n stopIcon.height = 11;\r\n stopIcon.horizontalCenter = \"middle\";\r\n stopIcon.verticalCenter = \"middle\";\r\n stopIcon.cornerRadius(0, 0, 0, 0);\r\n stopIcon.stroke = interfaceColors.getFor(\"primaryButtonText\");\r\n stopIcon.fill = playIcon.stroke;\r\n _this.togglable = true;\r\n var activeState = _this.states.create(\"active\");\r\n activeState.transitionDuration = 0;\r\n activeState.properties.icon = stopIcon;\r\n _this.defaultState.transitionDuration = 0;\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Sets defaults that instantiate some objects that rely on parent, so they\r\n * cannot be set in constructor.\r\n */\r\n PlayButton.prototype.applyInternalDefaults = function () {\r\n _super.prototype.applyInternalDefaults.call(this);\r\n if (!$type.hasValue(this.readerTitle)) {\r\n this.readerTitle = this.language.translate(\"Play\");\r\n }\r\n };\r\n return PlayButton;\r\n}(Button));\r\nexport { PlayButton };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"PlayButton\"] = PlayButton;\r\n//# sourceMappingURL=PlayButton.js.map","import { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { BaseObject } from \"../../Base\";\r\nimport { registry } from \"../../Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A base class for color modifiers.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\nvar ColorModifier = /** @class */ (function (_super) {\r\n __extends(ColorModifier, _super);\r\n /**\r\n * Constructor\r\n */\r\n function ColorModifier() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"ColorModifier\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Modifies color value.\r\n *\r\n * @ignore Exclude from docs\r\n * @param value Original color\r\n * @return Modified\r\n */\r\n ColorModifier.prototype.modify = function (value) {\r\n return value;\r\n };\r\n return ColorModifier;\r\n}(BaseObject));\r\nexport { ColorModifier };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"ColorModifier\"] = ColorModifier;\r\n//# sourceMappingURL=ColorModifier.js.map","import { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { ColorModifier } from \"./ColorModifier\";\r\nimport { registry } from \"../../Registry\";\r\nimport * as $math from \"../../utils/Math\";\r\nimport * as $type from \"../../utils/Type\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * This class can be used to modify linear gradient steps, changing visual\r\n * properties like lightness, brightness, opacity of each set.\r\n *\r\n * It can also set offsets for each gradient step.\r\n *\r\n * E.g. if I want to fill a columns in a column series to be a solid fill from\r\n * top to 80% of height, then gradually fades out, I can use the following\r\n * gradient modifier as a `fillModifier`:\r\n *\r\n * ```TypeScript\r\n * let fillModifier = new am4core.GradientModifier();\r\n * fillModifier.opacities = [1, 1, 0];\r\n * fillModifier.offsets = [0, 0.8, 1];\r\n * columnSeries.columns.template.fillModifier = fillModifier;\r\n * ```\r\n * ```JavaScript\r\n * var fillModifier = new am4core.GradientModifier();\r\n * fillModifier.opacities = [1, 1, 0];\r\n * fillModifier.offsets = [0, 0.8, 1];\r\n * columnSeries.columns.template.fillModifier = fillModifier;\r\n * ```\r\n * ```JSON\r\n * \"series\": [{\r\n * \"type\": \"ColumnSeries\",\r\n * \"columns\": {\r\n * \"fillModifier\": {\r\n * \"type\": \"GradientModifier\",\r\n * \"opacities\": [1, 1, 0],\r\n * \"offsets\": [0, 0.8, 1]\r\n * }\r\n * }\r\n * }]\r\n * ```\r\n */\r\nvar GradientModifier = /** @class */ (function (_super) {\r\n __extends(GradientModifier, _super);\r\n /**\r\n * Constructor.\r\n */\r\n function GradientModifier() {\r\n var _this = _super.call(this) || this;\r\n _this.lightnesses = [];\r\n _this.brightnesses = [];\r\n _this.opacities = [];\r\n _this.offsets = [];\r\n _this.className = \"GradientModifier\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(GradientModifier.prototype, \"lightnesses\", {\r\n /**\r\n * @return Lightness values\r\n */\r\n get: function () {\r\n return this._lightnesses;\r\n },\r\n /**\r\n * An array of lightness values for each step.\r\n *\r\n * @param value Lightness values\r\n */\r\n set: function (value) {\r\n this._lightnesses = value;\r\n this._brightnesses = [];\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(GradientModifier.prototype, \"brightnesses\", {\r\n /**\r\n * @return Brightness values\r\n */\r\n get: function () {\r\n return this._brightnesses;\r\n },\r\n /**\r\n * An array of brightness values for each step.\r\n *\r\n * @param value Brightness values\r\n */\r\n set: function (value) {\r\n this._brightnesses = value;\r\n this._lightnesses = [];\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(GradientModifier.prototype, \"opacities\", {\r\n /**\r\n * @return Opacity values\r\n */\r\n get: function () {\r\n return this._opacities;\r\n },\r\n /**\r\n * An array of opacity values for each step.\r\n *\r\n * @param value Opacity values\r\n */\r\n set: function (value) {\r\n this._opacities = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(GradientModifier.prototype, \"offsets\", {\r\n /**\r\n * @return Offsets\r\n */\r\n get: function () {\r\n return this._offsets;\r\n },\r\n /**\r\n * An array of relative position (0-1) for each step.\r\n *\r\n * If not set, all steps will be of equal relative length.\r\n *\r\n * @param value Offsets\r\n */\r\n set: function (value) {\r\n this._offsets = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Modifies the color based on step setting.\r\n *\r\n * @ignore Exclude from docs\r\n * @param value Source color\r\n * @return A gradient that matches set modification rules\r\n */\r\n GradientModifier.prototype.modify = function (value) {\r\n // Clear current gradient\r\n this.gradient.clear();\r\n // Get step count\r\n var count = 0;\r\n if (this.opacities) {\r\n count = $math.max(count, this.opacities.length);\r\n }\r\n if (this.lightnesses) {\r\n count = $math.max(count, this.lightnesses.length);\r\n }\r\n if (this.brightnesses) {\r\n count = $math.max(count, this.brightnesses.length);\r\n }\r\n // Init step values\r\n var opacity = 1, lightness, brightness;\r\n // Apply steps\r\n for (var i = 0; i < count; i++) {\r\n // Take base color\r\n var color = value;\r\n // Check if there are any parameters for this step\r\n if (this.opacities && $type.isNumber(this.opacities[i])) {\r\n opacity = this.opacities[i];\r\n }\r\n if (this.lightnesses && $type.isNumber(this.lightnesses[i])) {\r\n lightness = this.lightnesses[i];\r\n brightness = undefined;\r\n }\r\n if (this.brightnesses && $type.isNumber(this.brightnesses[i])) {\r\n brightness = this.brightnesses[i];\r\n lightness = undefined;\r\n }\r\n // Check if we need to brighten/lighten color\r\n if ($type.isNumber(brightness)) {\r\n color = value.brighten(this.brightnesses[i]);\r\n }\r\n else if ($type.isNumber(lightness)) {\r\n color = value.lighten(this.lightnesses[i]);\r\n }\r\n // Get offset (it's OK if it's undefined)\r\n var offset = this.offsets[i];\r\n // Apply step\r\n this.gradient.addColor(color, opacity, offset);\r\n }\r\n return this.gradient;\r\n };\r\n GradientModifier.prototype.copyFrom = function (source) {\r\n _super.prototype.copyFrom.call(this, source);\r\n this._offsets = source.offsets;\r\n this._brightnesses = source.brightnesses;\r\n this._lightnesses = source.lightnesses;\r\n this._opacities = source.opacities;\r\n };\r\n return GradientModifier;\r\n}(ColorModifier));\r\nexport { GradientModifier };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"GradientModifier\"] = GradientModifier;\r\n//# sourceMappingURL=GradientModifier.js.map","import { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { LinearGradient } from \"./LinearGradient\";\r\nimport { GradientModifier } from \"./GradientModifier\";\r\nimport { registry } from \"../../Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * This class can be used to modify linear gradient steps, changing visual\r\n * properties like lightness, brightness, opacity of each set.\r\n *\r\n * It can also set offsets for each gradient step.\r\n *\r\n * E.g. if I want to fill a columns in a column series to be a solid fill from\r\n * top to 80% of height, then gradually fades out, I can use the following\r\n * gradient modifier as a `fillModifier`:\r\n *\r\n * ```TypeScript\r\n * let fillModifier = new am4core.LinearGradientModifier();\r\n * fillModifier.opacities = [1, 1, 0];\r\n * fillModifier.offsets = [0, 0.8, 1];\r\n * columnSeries.columns.template.fillModifier = fillModifier;\r\n * ```\r\n * ```JavaScript\r\n * var fillModifier = new am4core.LinearGradientModifier();\r\n * fillModifier.opacities = [1, 1, 0];\r\n * fillModifier.offsets = [0, 0.8, 1];\r\n * columnSeries.columns.template.fillModifier = fillModifier;\r\n * ```\r\n * ```JSON\r\n * \"series\": [{\r\n * \"type\": \"ColumnSeries\",\r\n * \"columns\": {\r\n * \"fillModifier\": {\r\n * \"type\": \"LinearGradientModifier\",\r\n * \"opacities\": [1, 1, 0],\r\n * \"offsets\": [0, 0.8, 1]\r\n * }\r\n * }\r\n * }]\r\n * ```\r\n */\r\nvar LinearGradientModifier = /** @class */ (function (_super) {\r\n __extends(LinearGradientModifier, _super);\r\n /**\r\n * Constructor.\r\n */\r\n function LinearGradientModifier() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"LinearGradientModifier\";\r\n _this.gradient = new LinearGradient();\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n LinearGradientModifier.prototype.copyFrom = function (source) {\r\n _super.prototype.copyFrom.call(this, source);\r\n this.gradient = source.gradient.clone();\r\n };\r\n return LinearGradientModifier;\r\n}(GradientModifier));\r\nexport { LinearGradientModifier };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"LinearGradientModifier\"] = LinearGradientModifier;\r\n//# sourceMappingURL=LinearGradientModifier.js.map","/**\r\n * Cone module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../../Container\";\r\nimport { Sprite, visualProperties } from \"../../Sprite\";\r\nimport { Ellipse } from \"../../elements/Ellipse\";\r\nimport { LinearGradientModifier } from \"../../rendering/fills/LinearGradientModifier\";\r\nimport { percent } from \"../../utils/Percent\";\r\nimport * as $object from \"../../utils/Object\";\r\nimport * as $path from \"../../rendering/Path\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Builds a round cone/cylinder.\r\n *\r\n * @see {@link IConeEvents} for a list of available events\r\n * @see {@link IConeAdapters} for a list of available Adapters\r\n */\r\nvar Cone = /** @class */ (function (_super) {\r\n __extends(Cone, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Cone() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"Cone\";\r\n _this.angle = 30;\r\n _this.radius = percent(100);\r\n _this.topRadius = percent(100);\r\n _this.top = _this.createChild(Ellipse);\r\n _this.top.shouldClone = false;\r\n _this.bottom = _this.createChild(Ellipse);\r\n _this.bottom.shouldClone = false;\r\n _this.body = _this.createChild(Sprite);\r\n _this.body.shouldClone = false;\r\n _this.body.setElement(_this.paper.add(\"path\"));\r\n _this.layout = \"none\";\r\n _this.bodyFillModifier = new LinearGradientModifier();\r\n _this.bodyFillModifier.lightnesses = [0, -0.25, 0];\r\n _this.body.fillModifier = _this.bodyFillModifier;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Draws the element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Cone.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n $object.copyProperties(this, this.top, visualProperties);\r\n $object.copyProperties(this, this.bottom, visualProperties);\r\n $object.copyProperties(this, this.body, visualProperties);\r\n var w = this.innerWidth;\r\n var h = this.innerHeight;\r\n var bottom = this.bottom;\r\n var top = this.top;\r\n var angle = this.angle;\r\n var radiusBase;\r\n var dx;\r\n var dy;\r\n if (this.orientation == \"horizontal\") {\r\n radiusBase = h / 2;\r\n bottom.y = h / 2;\r\n bottom.x = 0;\r\n top.y = h / 2;\r\n top.x = w;\r\n dx = (90 - angle) / 90;\r\n dy = 0;\r\n this.bodyFillModifier.gradient.rotation = 90;\r\n }\r\n else {\r\n dx = 0;\r\n dy = (90 - angle) / 90;\r\n radiusBase = w / 2;\r\n bottom.y = h;\r\n bottom.x = w / 2;\r\n top.x = w / 2;\r\n this.bodyFillModifier.gradient.rotation = 0;\r\n }\r\n var radius = this.radius.value * radiusBase;\r\n var topRadius = this.topRadius.value * radiusBase;\r\n bottom.radius = radius - radius * dx;\r\n bottom.radiusY = radius - radius * dy;\r\n top.radius = topRadius - topRadius * dx;\r\n top.radiusY = topRadius - topRadius * dy;\r\n var path;\r\n if (this.orientation == \"horizontal\") {\r\n path = $path.moveTo({ x: 0, y: h / 2 - bottom.radiusY }) + $path.arcTo(-90, -180, bottom.radius, bottom.radiusY) + $path.lineTo({ x: w, y: h / 2 + top.radiusY }) + $path.arcTo(90, 180, top.radius, top.radiusY) + $path.closePath();\r\n }\r\n else {\r\n path = $path.moveTo({ x: w / 2 - top.radius, y: 0 }) + $path.arcTo(180, -180, top.radius, top.radiusY) + $path.lineTo({ x: w / 2 + bottom.radius, y: h }) + $path.arcTo(0, 180, bottom.radius, bottom.radiusY) + $path.closePath();\r\n }\r\n this.body.path = path;\r\n };\r\n Object.defineProperty(Cone.prototype, \"angle\", {\r\n /**\r\n * @return Angle\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"angle\");\r\n },\r\n /**\r\n * Angle of the point of view to the 3D element. (0-360)\r\n *\r\n * @default 30\r\n * @param value Angle\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"angle\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Cone.prototype, \"radius\", {\r\n /**\r\n * @return Bottom radius\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"radius\");\r\n },\r\n /**\r\n * A relative radius of the cone's bottom (base).\r\n *\r\n * It is relevant to the inner width or height of the element.\r\n *\r\n * @default Percent(100)\r\n * @param value Bottom radius\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"radius\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Cone.prototype, \"topRadius\", {\r\n /**\r\n * @return Top radius\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"topRadius\");\r\n },\r\n /**\r\n * A relative radius of the cone's top (tip).\r\n *\r\n * It is relevant to the inner width or height of the element.\r\n *\r\n * @default Percent(0)\r\n * @param value Top radius\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"topRadius\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Cone.prototype, \"orientation\", {\r\n /**\r\n * Orientation\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"orientation\");\r\n },\r\n /**\r\n * Orientation of the cone\r\n *\r\n * @default \"vertical\"\r\n * @param value Orientation\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"orientation\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Cone;\r\n}(Container));\r\nexport { Cone };\r\n//# sourceMappingURL=Cone.js.map","/**\r\n * Module for \"Lighten\" filter.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Filter } from \"./Filter\";\r\nimport { registry } from \"../../Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creates a \"Lighten\" filter.\r\n */\r\nvar LightenFilter = /** @class */ (function (_super) {\r\n __extends(LightenFilter, _super);\r\n /**\r\n * Constructor\r\n */\r\n function LightenFilter() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"LightenFilter\";\r\n // Create elements\r\n // NOTE: we do not need to add each individual element to `_disposers`\r\n // because `filterPrimitives` has an event handler which automatically adds\r\n // anything added to it to `_disposers`\r\n _this.feColorMatrix = _this.paper.add(\"feColorMatrix\");\r\n _this.feColorMatrix.attr({ \"type\": \"matrix\" });\r\n _this.filterPrimitives.push(_this.feColorMatrix);\r\n // Set default properties\r\n _this.lightness = 0;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(LightenFilter.prototype, \"lightness\", {\r\n /**\r\n * @return Lightness\r\n */\r\n get: function () {\r\n return this.properties[\"lightness\"];\r\n },\r\n /**\r\n * Lightness of the target colors.\r\n *\r\n * If `lightness` is a positive number, the filter will make all colors\r\n * lighter.\r\n *\r\n * If `lightness` is negative, colors will be darkened.\r\n *\r\n * @param value Lightness\r\n */\r\n set: function (value) {\r\n this.properties[\"lightness\"] = value;\r\n var v = value + 1;\r\n this.feColorMatrix.attr({ \"values\": v + \" 0 0 0 0 0 \" + v + \" 0 0 0 0 0 \" + v + \" 0 0 0 0 0 1 0\" });\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return LightenFilter;\r\n}(Filter));\r\nexport { LightenFilter };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"LightenFilter\"] = LightenFilter;\r\n//# sourceMappingURL=LightenFilter.js.map","/**\r\n * Creates a 3D rectangle.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../../Container\";\r\nimport { Sprite } from \"../../Sprite\";\r\nimport * as $math from \"../../utils/Math\";\r\nimport * as $path from \"../../rendering/Path\";\r\nimport { Color, color, toColor } from \"../../utils/Color\";\r\nimport { RadialGradient } from \"../../rendering/fills/RadialGradient\";\r\nimport { LinearGradient } from \"../../rendering/fills/LinearGradient\";\r\nimport { LightenFilter } from \"../../rendering/filters/LightenFilter\";\r\nimport * as $type from \"../../utils/Type\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Builds a 3D rectangle\r\n * @see {@link IRectangle3DEvents} for a list of available events\r\n * @see {@link IRectangle3DAdapters} for a list of available Adapters\r\n */\r\nvar Rectangle3D = /** @class */ (function (_super) {\r\n __extends(Rectangle3D, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Rectangle3D() {\r\n var _this = _super.call(this) || this;\r\n _this.angle = 30;\r\n _this.depth = 30;\r\n _this.className = \"Rectangle3D\";\r\n _this.layout = \"none\";\r\n var sideBack = _this.createChild(Sprite);\r\n sideBack.shouldClone = false;\r\n sideBack.setElement(_this.paper.add(\"path\"));\r\n sideBack.isMeasured = false;\r\n _this.sideBack = sideBack;\r\n _this._disposers.push(_this.sideBack);\r\n var sideBottom = _this.createChild(Sprite);\r\n sideBottom.shouldClone = false;\r\n sideBottom.setElement(_this.paper.add(\"path\"));\r\n sideBottom.isMeasured = false;\r\n _this.sideBottom = sideBottom;\r\n _this._disposers.push(_this.sideBottom);\r\n var sideLeft = _this.createChild(Sprite);\r\n sideLeft.shouldClone = false;\r\n sideLeft.setElement(_this.paper.add(\"path\"));\r\n sideLeft.isMeasured = false;\r\n _this.sideLeft = sideLeft;\r\n _this._disposers.push(_this.sideLeft);\r\n var sideRight = _this.createChild(Sprite);\r\n sideRight.shouldClone = false;\r\n sideRight.setElement(_this.paper.add(\"path\"));\r\n sideRight.isMeasured = false;\r\n _this.sideRight = sideRight;\r\n _this._disposers.push(_this.sideRight);\r\n var sideTop = _this.createChild(Sprite);\r\n sideTop.shouldClone = false;\r\n sideTop.setElement(_this.paper.add(\"path\"));\r\n sideTop.isMeasured = false;\r\n _this.sideTop = sideTop;\r\n _this._disposers.push(_this.sideTop);\r\n var sideFront = _this.createChild(Sprite);\r\n sideFront.shouldClone = false;\r\n sideFront.setElement(_this.paper.add(\"path\"));\r\n sideFront.isMeasured = false;\r\n _this.sideFront = sideFront;\r\n _this._disposers.push(_this.sideFront);\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Draws the element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Rectangle3D.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n var w = this.innerWidth;\r\n var h = this.innerHeight;\r\n var depth = this.depth;\r\n var angle = this.angle;\r\n var sin = $math.sin(angle);\r\n var cos = $math.cos(angle);\r\n var a = { x: 0, y: 0 };\r\n var b = { x: w, y: 0 };\r\n var c = { x: w, y: h };\r\n var d = { x: 0, y: h };\r\n var ah = { x: depth * cos, y: -depth * sin };\r\n var bh = { x: depth * cos + w, y: -depth * sin };\r\n var ch = { x: depth * cos + w, y: -depth * sin + h };\r\n var dh = { x: depth * cos, y: -depth * sin + h };\r\n this.sideFront.path = $path.moveTo(a) + $path.lineTo(b) + $path.lineTo(c) + $path.lineTo(d) + $path.closePath();\r\n this.sideBack.path = $path.moveTo(ah) + $path.lineTo(bh) + $path.lineTo(ch) + $path.lineTo(dh) + $path.closePath();\r\n this.sideLeft.path = $path.moveTo(a) + $path.lineTo(ah) + $path.lineTo(dh) + $path.lineTo(d) + $path.closePath();\r\n this.sideRight.path = $path.moveTo(b) + $path.lineTo(bh) + $path.lineTo(ch) + $path.lineTo(c) + $path.closePath();\r\n this.sideBottom.path = $path.moveTo(d) + $path.lineTo(dh) + $path.lineTo(ch) + $path.lineTo(c) + $path.closePath();\r\n this.sideTop.path = $path.moveTo(a) + $path.lineTo(ah) + $path.lineTo(bh) + $path.lineTo(b) + $path.closePath();\r\n };\r\n Object.defineProperty(Rectangle3D.prototype, \"depth\", {\r\n /**\r\n * @return Depth (px)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"depth\");\r\n },\r\n /**\r\n * Depth (Z dimension) of the 3D rectangle in pixels.\r\n *\r\n * @default 30\r\n * @param value Depth (px)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"depth\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Rectangle3D.prototype, \"angle\", {\r\n /**\r\n * @return Angle\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"angle\");\r\n },\r\n /**\r\n * Angle of the point of view to the 3D element. (0-360)\r\n *\r\n * @default 30\r\n * @param value Angle\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"angle\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Sets actual `fill` property on the SVG element, including applicable color\r\n * modifiers.\r\n *\r\n * @ignore Exclude from docs\r\n * @param value Fill\r\n */\r\n Rectangle3D.prototype.setFill = function (value) {\r\n _super.prototype.setFill.call(this, value);\r\n if (!$type.isObject(value) || \"r\" in value) {\r\n value = toColor(value);\r\n }\r\n var colorStr;\r\n if (value instanceof Color) {\r\n colorStr = value.hex;\r\n }\r\n else if (value instanceof LinearGradient || value instanceof RadialGradient) {\r\n colorStr = value.stops.getIndex(0).color.hex;\r\n }\r\n else {\r\n var filter = new LightenFilter();\r\n filter.lightness = -0.2;\r\n this.sideBack.filters.push(filter);\r\n var filter2 = filter.clone();\r\n filter2.lightness = -0.4;\r\n this.sideLeft.filters.push(filter2);\r\n var filter3 = filter.clone();\r\n filter3.lightness = -0.2;\r\n this.sideRight.filters.push(filter3);\r\n var filter4 = filter.clone();\r\n filter4.lightness = -0.1;\r\n this.sideTop.filters.push(filter4);\r\n var filter5 = filter.clone();\r\n filter5.lightness = -0.5;\r\n this.sideBottom.filters.push(filter5);\r\n }\r\n if (colorStr) {\r\n this.sideBack.fill = color(colorStr).lighten(-0.2);\r\n this.sideLeft.fill = color(colorStr).lighten(-0.4);\r\n this.sideRight.fill = color(colorStr).lighten(-0.2);\r\n this.sideTop.fill = color(colorStr).lighten(-0.1);\r\n this.sideBottom.fill = color(colorStr).lighten(-0.5);\r\n }\r\n };\r\n /**\r\n * Copies all properties and related data from a different instance of Rectangle3D.\r\n *\r\n * @param source Source Rectangle3D\r\n */\r\n Rectangle3D.prototype.copyFrom = function (source) {\r\n _super.prototype.copyFrom.call(this, source);\r\n this.sideBack.copyFrom(source.sideBack);\r\n this.sideLeft.copyFrom(source.sideLeft);\r\n this.sideRight.copyFrom(source.sideRight);\r\n this.sideTop.copyFrom(source.sideTop);\r\n this.sideBottom.copyFrom(source.sideBottom);\r\n };\r\n return Rectangle3D;\r\n}(Container));\r\nexport { Rectangle3D };\r\n//# sourceMappingURL=Rectangle3D.js.map","/**\r\n * 3D slice module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Slice } from \"../Slice\";\r\nimport { Sprite } from \"../../Sprite\";\r\nimport * as $math from \"../../utils/Math\";\r\nimport * as $path from \"../../rendering/Path\";\r\nimport * as $type from \"../../utils/Type\";\r\nimport { Color, color } from \"../../utils/Color\";\r\nimport { RadialGradient } from \"../../rendering/fills/RadialGradient\";\r\nimport { LinearGradient } from \"../../rendering/fills/LinearGradient\";\r\nimport { LightenFilter } from \"../../rendering/filters/LightenFilter\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Used to draw a 3D slice of a Pie chart.\r\n *\r\n * @see {@link ISlice3DEvents} for a list of available events\r\n * @see {@link ISlice3DAdapters} for a list of available Adapters\r\n */\r\nvar Slice3D = /** @class */ (function (_super) {\r\n __extends(Slice3D, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Slice3D() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"Slice3D\";\r\n _this.layout = \"none\";\r\n // Create edge container\r\n var edge = _this.createChild(Sprite);\r\n _this.edge = edge;\r\n edge.shouldClone = false;\r\n edge.isMeasured = false;\r\n edge.toBack();\r\n // Set defaults\r\n _this.angle = 30;\r\n _this.depth = 20;\r\n // Create side A element\r\n var sideA = _this.createChild(Sprite);\r\n _this.sideA = sideA;\r\n sideA.shouldClone = false;\r\n sideA.isMeasured = false;\r\n //sideA.setElement(this.paper.add(\"path\"));\r\n //sideA.strokeOpacity = 0;\r\n // Crate side B element\r\n var sideB = _this.createChild(Sprite);\r\n _this.sideB = sideB;\r\n sideB.shouldClone = false;\r\n sideB.isMeasured = false;\r\n //sideB.setElement(this.paper.add(\"path\"));\r\n //sideB.strokeOpacity = 0;\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Sets actual `fill` property on the SVG element, including applicable color\r\n * modifiers.\r\n *\r\n * @ignore Exclude from docs\r\n * @param value Fill\r\n */\r\n Slice3D.prototype.setFill = function (value) {\r\n _super.prototype.setFill.call(this, value);\r\n var colorStr;\r\n if (value instanceof Color) {\r\n colorStr = value.hex;\r\n }\r\n else if (value instanceof LinearGradient || value instanceof RadialGradient) {\r\n colorStr = value.stops.getIndex(0).color.hex;\r\n }\r\n else {\r\n var filter = new LightenFilter();\r\n filter.lightness = -0.25;\r\n this.edge.filters.push(filter);\r\n this.sideA.filters.push(filter.clone());\r\n this.sideB.filters.push(filter.clone());\r\n }\r\n if (colorStr) {\r\n var edgeFill = color(colorStr).lighten(-0.25);\r\n this.edge.fill = edgeFill;\r\n this.sideA.fill = edgeFill;\r\n this.sideB.fill = edgeFill;\r\n this.edge.stroke = edgeFill;\r\n this.sideA.stroke = edgeFill;\r\n this.sideB.stroke = edgeFill;\r\n }\r\n };\r\n /**\r\n * Draws the element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Slice3D.prototype.draw = function () {\r\n this.cornerRadius = 0;\r\n this.innerCornerRadius = 0;\r\n _super.prototype.draw.call(this);\r\n if (this.arc !== 0 && this.radius > 0 && this.depth > 0) {\r\n this.sideB.show(0);\r\n this.sideA.show(0);\r\n this.edge.show(0);\r\n var startAngle = this.startAngle;\r\n var arc = this.arc;\r\n var innerRadius = this.pixelInnerRadius || 0;\r\n var radiusY = this.radiusY || 0;\r\n //let cornerRadius = this.cornerRadius || 0;\r\n //let innerCornerRadius = this.innerCornerRadius;\r\n var radius = this.radius;\r\n // this is code duplicate with $path.arc. @todo to think how to avoid it\r\n var endAngle = startAngle + arc;\r\n //let crSin = $math.sin($math.min(arc, 45) / 2);\r\n //innerCornerRadius = innerCornerRadius || cornerRadius;\r\n var innerRadiusY = (radiusY / radius) * innerRadius;\r\n //let cornerRadiusY = (radiusY / radius) * cornerRadius;\r\n //let innerCornerRadiusY = (radiusY / radius) * innerCornerRadius;\r\n //cornerRadius = $math.fitToRange(cornerRadius, 0, (radius - innerRadius) / 2);\r\n //cornerRadiusY = $math.fitToRange(cornerRadiusY, 0, (radiusY - innerRadiusY) / 2);\r\n //innerCornerRadius = $math.fitToRange(innerCornerRadius, 0, (radius - innerRadius) / 2);\r\n //innerCornerRadiusY = $math.fitToRange(innerCornerRadiusY, 0, (radiusY - innerRadiusY) / 2);\r\n //cornerRadius = $math.fitToRange(cornerRadius, 0, radius * crSin);\r\n //cornerRadiusY = $math.fitToRange(cornerRadiusY, 0, radiusY * crSin);\r\n //innerCornerRadius = $math.fitToRange(innerCornerRadius, 0, innerRadius * crSin);\r\n //innerCornerRadiusY = $math.fitToRange(innerCornerRadiusY, 0, innerRadiusY * crSin);\r\n //let crAngle: number = Math.asin(cornerRadius / radius / 2) * $math.DEGREES * 2;\r\n //let crAngleY: number = Math.asin(cornerRadiusY / radiusY / 2) * $math.DEGREES * 2;\r\n //if (innerRadius < innerCornerRadius) {\r\n //\tinnerRadius = innerCornerRadius;\r\n //}\r\n //if (innerRadiusY < innerCornerRadiusY) {\r\n //\tinnerRadiusY = innerCornerRadiusY;\r\n //}\r\n //let crInnerAngle: number = Math.asin(innerCornerRadius / innerRadius / 2) * $math.DEGREES * 2;\r\n //let crInnerAngleY: number = Math.asin(innerCornerRadiusY / innerRadiusY / 2) * $math.DEGREES * 2;\r\n //if (!$type.isNumber(crInnerAngle)) {\r\n //\tcrInnerAngle = 0;\r\n //}\r\n //if (!$type.isNumber(crInnerAngleY)) {\r\n //\tcrInnerAngleY = 0;\r\n //}\r\n //let middleAngle = startAngle + arc / 2;\r\n //let mPoint = { x: $math.round($math.cos(middleAngle) * innerRadius, 4), y: $math.round($math.sin(middleAngle) * innerRadiusY, 4) };\r\n var a0 = { x: $math.cos(startAngle) * (innerRadius), y: $math.sin(startAngle) * (innerRadiusY) };\r\n var b0 = { x: $math.cos(startAngle) * (radius), y: $math.sin(startAngle) * (radiusY) };\r\n var c0 = { x: $math.cos(endAngle) * (radius), y: $math.sin(endAngle) * (radiusY) };\r\n var d0 = { x: $math.cos(endAngle) * (innerRadius), y: $math.sin(endAngle) * (innerRadiusY) };\r\n // end of duplicate\r\n var h = this.depth;\r\n var ah = { x: a0.x, y: a0.y - h };\r\n var bh = { x: b0.x, y: b0.y - h };\r\n var ch = { x: c0.x, y: c0.y - h };\r\n var dh = { x: d0.x, y: d0.y - h };\r\n var edgePath = \"\";\r\n var count = Math.ceil(arc / 5);\r\n var step = arc / count;\r\n var mangle = startAngle;\r\n var prevPoint = bh;\r\n for (var i = 0; i < count; i++) {\r\n mangle += step;\r\n if (mangle > 0 && mangle < 180) {\r\n edgePath += $path.moveTo(prevPoint);\r\n var pp = { x: $math.cos(mangle) * (radius), y: $math.sin(mangle) * (radiusY) - h };\r\n edgePath += $path.lineTo({ x: prevPoint.x, y: prevPoint.y + h });\r\n edgePath += $path.arcToPoint({ x: pp.x, y: pp.y + h }, radius, radiusY, true);\r\n edgePath += $path.lineTo(pp);\r\n edgePath += $path.arcToPoint(prevPoint, radius, radiusY);\r\n edgePath += \"z\";\r\n prevPoint = pp;\r\n }\r\n else {\r\n edgePath += $path.moveTo(prevPoint);\r\n var pp = { x: $math.cos(mangle) * (radius), y: $math.sin(mangle) * (radiusY) - h };\r\n edgePath += $path.arcToPoint(pp, radius, radiusY, true);\r\n edgePath += $path.lineTo({ x: pp.x, y: pp.y + h });\r\n edgePath += $path.arcToPoint({ x: prevPoint.x, y: prevPoint.y + h }, radius, radiusY);\r\n edgePath += $path.lineTo(prevPoint);\r\n edgePath += \"z\";\r\n prevPoint = pp;\r\n }\r\n }\r\n prevPoint = ah;\r\n mangle = startAngle;\r\n for (var i = 0; i < count; i++) {\r\n mangle += step;\r\n if (mangle > 0 && mangle < 180) {\r\n edgePath += $path.moveTo(prevPoint);\r\n var pp = { x: $math.cos(mangle) * (innerRadius), y: $math.sin(mangle) * (innerRadiusY) - h };\r\n edgePath += $path.lineTo({ x: prevPoint.x, y: prevPoint.y + h });\r\n edgePath += $path.arcToPoint({ x: pp.x, y: pp.y + h }, innerRadius, innerRadiusY, true);\r\n edgePath += $path.lineTo(pp);\r\n edgePath += $path.arcToPoint(prevPoint, innerRadius, innerRadiusY);\r\n edgePath += \"z\";\r\n prevPoint = pp;\r\n }\r\n else {\r\n edgePath += $path.moveTo(prevPoint);\r\n var pp = { x: $math.cos(mangle) * (innerRadius), y: $math.sin(mangle) * (innerRadiusY) - h };\r\n edgePath += $path.arcToPoint(pp, innerRadius, innerRadiusY, true);\r\n edgePath += $path.lineTo({ x: pp.x, y: pp.y + h });\r\n edgePath += $path.arcToPoint({ x: prevPoint.x, y: prevPoint.y + h }, innerRadius, innerRadiusY);\r\n edgePath += $path.lineTo(prevPoint);\r\n edgePath += \"z\";\r\n prevPoint = pp;\r\n }\r\n }\r\n this.edge.path = edgePath;\r\n /*\r\n a0 = { x: $math.cos(startAngle) * (innerRadius + innerCornerRadius), y: $math.sin(startAngle) * (innerRadiusY + innerCornerRadiusY) };\r\n b0 = { x: $math.cos(startAngle) * (radius - cornerRadius), y: $math.sin(startAngle) * (radiusY - cornerRadiusY) };\r\n c0 = { x: $math.cos(endAngle) * (radius - cornerRadius), y: $math.sin(endAngle) * (radiusY - cornerRadiusY) };\r\n d0 = { x: $math.cos(endAngle) * (innerRadius + innerCornerRadius), y: $math.sin(endAngle) * (innerRadiusY + innerCornerRadiusY) };\r\n // end of duplicate\r\n \r\n ah = { x: a0.x, y: a0.y - h };\r\n bh = { x: b0.x, y: b0.y - h };\r\n ch = { x: c0.x, y: c0.y - h };\r\n dh = { x: d0.x, y: d0.y - h };\r\n */\r\n this.sideA.path = $path.moveTo(a0) + $path.lineTo(b0) + $path.lineTo(bh) + $path.lineTo(ah) + $path.closePath();\r\n this.sideB.path = $path.moveTo(c0) + $path.lineTo(d0) + $path.lineTo(dh) + $path.lineTo(ch) + $path.closePath();\r\n if (this.startAngle < 90) {\r\n this.sideA.toBack();\r\n }\r\n else {\r\n this.sideA.toFront();\r\n }\r\n if (this.startAngle + this.arc > 90) {\r\n this.sideB.toBack();\r\n }\r\n else {\r\n this.sideB.toFront();\r\n }\r\n this.slice.dy = -h;\r\n }\r\n else {\r\n this.sideA.hide(0);\r\n this.sideB.hide(0);\r\n this.edge.hide(0);\r\n }\r\n };\r\n Object.defineProperty(Slice3D.prototype, \"depth\", {\r\n /**\r\n * @return Depth (px)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"depth\");\r\n },\r\n /**\r\n * Depth (height) of the 3D slice in pixels.\r\n *\r\n * @default 20\r\n * @param depth Depth (px)\r\n */\r\n set: function (depth) {\r\n this.setPropertyValue(\"depth\", depth, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slice3D.prototype, \"angle\", {\r\n /**\r\n * @return Angle\r\n */\r\n get: function () {\r\n var angle = this.getPropertyValue(\"angle\");\r\n if (!$type.isNumber(angle)) {\r\n angle = 0;\r\n }\r\n return angle;\r\n },\r\n /**\r\n * Angle of the point of view to the 3D element. (0-360)\r\n *\r\n * @default 30\r\n * @param value Angle\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"angle\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Slice3D.prototype, \"radiusY\", {\r\n /**\r\n * @return Vertical radius (0-1)\r\n */\r\n get: function () {\r\n var radiusY = this.getPropertyValue(\"radiusY\");\r\n if (!$type.isNumber(radiusY)) {\r\n radiusY = this.radius - this.radius * this.angle / 90;\r\n }\r\n return radiusY;\r\n },\r\n /**\r\n * Vertical radius for creating skewed slices.\r\n *\r\n * This is relevant to `radius`, e.g. 0.5 will set vertical radius to half\r\n * the `radius`.\r\n *\r\n * @param value Vertical radius (0-1)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"radiusY\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Copies all properties and related data from a different instance of Axis.\r\n *\r\n * @param source Source Axis\r\n */\r\n Slice3D.prototype.copyFrom = function (source) {\r\n _super.prototype.copyFrom.call(this, source);\r\n this.edge.copyFrom(source.edge);\r\n this.sideA.copyFrom(source.sideA);\r\n this.sideB.copyFrom(source.sideB);\r\n };\r\n return Slice3D;\r\n}(Slice));\r\nexport { Slice3D };\r\n//# sourceMappingURL=Slice3D.js.map","import { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { RadialGradient } from \"./RadialGradient\";\r\nimport { GradientModifier } from \"./GradientModifier\";\r\nimport { registry } from \"../../Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * This class can be used to modify radial gradient steps, changing visual\r\n * properties like lightness, brightness, opacity of each set.\r\n *\r\n * It can also set offsets for each gradient step.\r\n *\r\n * E.g. if I want to fill a columns in a column series to be a solid fill from\r\n * top to 80% of height, then gradually fades out, I can use the following\r\n * gradient modifier as a `fillModifier`:\r\n *\r\n * ```TypeScript\r\n * let fillModifier = new am4core.LinearGradientModifier();\r\n * fillModifier.opacities = [1, 1, 0];\r\n * fillModifier.offsets = [0, 0.8, 1];\r\n * columnSeries.columns.template.fillModifier = fillModifier;\r\n * ```\r\n * ```JavaScript\r\n * var fillModifier = new am4core.LinearGradientModifier();\r\n * fillModifier.opacities = [1, 1, 0];\r\n * fillModifier.offsets = [0, 0.8, 1];\r\n * columnSeries.columns.template.fillModifier = fillModifier;\r\n * ```\r\n * ```JSON\r\n * \"series\": [{\r\n * \"type\": \"ColumnSeries\",\r\n * \"columns\": {\r\n * \"fillModifier\": {\r\n * \"type\": \"LinearGradientModifier\",\r\n * \"opacities\": [1, 1, 0],\r\n * \"offsets\": [0, 0.8, 1]\r\n * }\r\n * }\r\n * }]\r\n * ```\r\n */\r\nvar RadialGradientModifier = /** @class */ (function (_super) {\r\n __extends(RadialGradientModifier, _super);\r\n /**\r\n * Constructor.\r\n */\r\n function RadialGradientModifier() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"RadialGradientModifier\";\r\n _this.gradient = new RadialGradient();\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n RadialGradientModifier.prototype.copyFrom = function (source) {\r\n _super.prototype.copyFrom.call(this, source);\r\n this.gradient = source.gradient.clone();\r\n };\r\n return RadialGradientModifier;\r\n}(GradientModifier));\r\nexport { RadialGradientModifier };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"RadialGradientModifier\"] = RadialGradientModifier;\r\n//# sourceMappingURL=RadialGradientModifier.js.map","import { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Pattern } from \"./Pattern\";\r\nimport { registry } from \"../../Registry\";\r\nimport * as $path from \"../../rendering/Path\";\r\n;\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Line pattern.\r\n */\r\nvar LinePattern = /** @class */ (function (_super) {\r\n __extends(LinePattern, _super);\r\n /**\r\n * Constructor\r\n */\r\n function LinePattern() {\r\n var _this = _super.call(this) || this;\r\n _this.properties[\"gap\"] = 0;\r\n _this._line = _this.paper.add(\"path\");\r\n _this.addElement(_this._line);\r\n return _this;\r\n }\r\n /**\r\n * Draws the pattern.\r\n */\r\n LinePattern.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n if (Math.round(this.rotation / 90) != this.rotation / 90) {\r\n this.properties[\"shapeRendering\"] = \"auto\";\r\n }\r\n if (this._line) {\r\n var w = this.width;\r\n var h = this.height;\r\n var path = \"\";\r\n if (!this.gap) {\r\n if (Math.round(this.rotation / 90) != this.rotation / 90) {\r\n path = $path.moveTo({ x: -w, y: h / 2 }) + $path.lineTo({ x: w * 2, y: h / 2 });\r\n this.properties[\"rotationX\"] = this.width / 2;\r\n this.properties[\"rotationY\"] = this.height / 2;\r\n }\r\n else {\r\n path = $path.moveTo({ x: 0, y: 0 }) + $path.lineTo({ x: w, y: 0 });\r\n }\r\n }\r\n else {\r\n var step = this.gap + this.strokeWidth;\r\n var count = this.height / step;\r\n for (var i = -count / 2; i < count * 1.5; i++) {\r\n if (Math.round(this.rotation / 90) != this.rotation / 90) {\r\n path += $path.moveTo({ x: -w, y: (i + 0.5) * step }) + $path.lineTo({ x: w * 2, y: (i + 0.5) * step });\r\n this.properties[\"rotationX\"] = this.width / 2;\r\n this.properties[\"rotationY\"] = this.height / 2;\r\n }\r\n else {\r\n path += $path.moveTo({ x: -w, y: i * step }) + $path.lineTo({ x: w * 2, y: i * step });\r\n }\r\n }\r\n }\r\n this._line.attr({ \"d\": path });\r\n }\r\n };\r\n Object.defineProperty(LinePattern.prototype, \"gap\", {\r\n /**\r\n * @return gap\r\n */\r\n get: function () {\r\n return this.properties[\"gap\"];\r\n },\r\n /**\r\n * Number of pixels between pattern lines.\r\n *\r\n * The pattern will automatically draw required number of lines to fill\r\n * pattern area maintaining `gap` distance between them.\r\n *\r\n * 0 (zero) means only single line will be drawn.\r\n *\r\n * @default 0\r\n * @since 4.7.7\r\n */\r\n set: function (value) {\r\n this.properties[\"gap\"] = value;\r\n this.draw();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return LinePattern;\r\n}(Pattern));\r\nexport { LinePattern };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"LinePattern\"] = LinePattern;\r\n//# sourceMappingURL=LinePattern.js.map","/**\r\n * Rectangular pattern module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Pattern } from \"./Pattern\";\r\nimport { registry } from \"../../Registry\";\r\n;\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Circular pattern\r\n */\r\nvar CirclePattern = /** @class */ (function (_super) {\r\n __extends(CirclePattern, _super);\r\n /**\r\n * Constructor\r\n */\r\n function CirclePattern() {\r\n var _this = _super.call(this) || this;\r\n _this.properties[\"radius\"] = 2;\r\n _this._circle = _this.paper.add(\"circle\");\r\n _this.addElement(_this._circle);\r\n _this.shapeRendering = \"auto\";\r\n return _this;\r\n }\r\n /**\r\n * Draws the circle element.\r\n */\r\n CirclePattern.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n if (this._circle) {\r\n this._circle.attr({ \"r\": this.radius, \"cx\": this.width / 2, \"cy\": this.height / 2 });\r\n }\r\n };\r\n Object.defineProperty(CirclePattern.prototype, \"radius\", {\r\n /**\r\n * @return Radius (px)\r\n */\r\n get: function () {\r\n return this.properties[\"radius\"];\r\n },\r\n /**\r\n * Circle radius in pixels.\r\n *\r\n * @param value Radius (px)\r\n */\r\n set: function (value) {\r\n this.properties[\"radius\"] = value;\r\n this.draw();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return CirclePattern;\r\n}(Pattern));\r\nexport { CirclePattern };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"CirclePattern\"] = CirclePattern;\r\n//# sourceMappingURL=CirclePattern.js.map","/**\r\n * Rectangular pattern module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Pattern } from \"./Pattern\";\r\nimport { registry } from \"../../Registry\";\r\n;\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Rectangular pattern\r\n */\r\nvar RectPattern = /** @class */ (function (_super) {\r\n __extends(RectPattern, _super);\r\n /**\r\n * Constructor\r\n */\r\n function RectPattern() {\r\n var _this = _super.call(this) || this;\r\n _this.rectHeight = 1;\r\n _this.rectWidth = 1;\r\n _this._rect = _this.paper.add(\"rect\");\r\n _this.addElement(_this._rect);\r\n return _this;\r\n }\r\n /**\r\n * Draws the rectangular element.\r\n */\r\n RectPattern.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n this.properties[\"rotationX\"] = this.width / 2;\r\n this.properties[\"rotationY\"] = this.height / 2;\r\n if (this._rect) {\r\n this._rect.attr({ \"width\": this.rectWidth, \"height\": this.rectHeight, \"x\": (this.width - this.rectWidth) / 2, \"y\": (this.height - this.rectHeight) / 2 });\r\n }\r\n };\r\n Object.defineProperty(RectPattern.prototype, \"rectWidth\", {\r\n /**\r\n * @return Width (px)\r\n */\r\n get: function () {\r\n return this.properties[\"rectWidth\"];\r\n },\r\n /**\r\n * Rectangle width in pixels.\r\n *\r\n * @param value Width (px)\r\n */\r\n set: function (value) {\r\n this.properties[\"rectWidth\"] = value;\r\n this.draw();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(RectPattern.prototype, \"rectHeight\", {\r\n /**\r\n * @return Height (px)\r\n */\r\n get: function () {\r\n return this.properties[\"rectHeight\"];\r\n },\r\n /**\r\n * Rectangle height in pixels.\r\n *\r\n * @param value Height (px)\r\n */\r\n set: function (value) {\r\n this.properties[\"rectHeight\"] = value;\r\n this.draw();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return RectPattern;\r\n}(Pattern));\r\nexport { RectPattern };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"RectPattern\"] = RectPattern;\r\n//# sourceMappingURL=RectPattern.js.map","/**\r\n * Module for \"Colorize\" filter.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Filter } from \"./Filter\";\r\nimport { registry } from \"../../Registry\";\r\n;\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creates a \"Colorize\" filter.\r\n */\r\nvar ColorizeFilter = /** @class */ (function (_super) {\r\n __extends(ColorizeFilter, _super);\r\n /**\r\n * Constructor\r\n */\r\n function ColorizeFilter() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"ColorizeFilter\";\r\n // Create elements\r\n // NOTE: we do not need to add each individual element to `_disposers`\r\n // because `filterPrimitives` has an event handler which automatically adds\r\n // anything added to it to `_disposers`\r\n _this.feColorMatrix = _this.paper.add(\"feColorMatrix\");\r\n _this.feColorMatrix.attr({ \"type\": \"matrix\" });\r\n //this.feColorMatrix.setAttribute(\"in\", \"SourceAlpha\");\r\n _this.filterPrimitives.push(_this.feColorMatrix);\r\n // Set default properties\r\n _this.intensity = 1;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * (Re)applies colors to the already existing filter by modifying filyer's\r\n * color matrix element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n ColorizeFilter.prototype.applyFilter = function () {\r\n var i = this.intensity;\r\n var ii = 1 - i;\r\n var r;\r\n var g;\r\n var b;\r\n var color = this.color;\r\n if (color && color.rgb) {\r\n r = color.rgb.r / 255 * i;\r\n g = color.rgb.g / 255 * i;\r\n b = color.rgb.b / 255 * i;\r\n }\r\n else {\r\n r = 0;\r\n g = 0;\r\n b = 0;\r\n }\r\n this.feColorMatrix.attr({ \"values\": ii + \" 0 0 0 \" + r + \" 0 \" + ii + \" 0 0 \" + g + \" 0 0 \" + ii + \" 0 \" + b + \" 0 0 0 1 0\" });\r\n };\r\n Object.defineProperty(ColorizeFilter.prototype, \"color\", {\r\n /**\r\n * @return Color\r\n */\r\n get: function () {\r\n return this.properties[\"color\"];\r\n },\r\n /**\r\n * Target color to apply to the element.\r\n *\r\n * Depending on the `intensity`, all colors of the target element will steer\r\n * towards this color.\r\n *\r\n * E.g. setting to `am4core.color(\"greener\")` will make all colors greener.\r\n *\r\n * @param value Color\r\n */\r\n set: function (value) {\r\n this.properties[\"color\"] = value;\r\n this.applyFilter();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ColorizeFilter.prototype, \"intensity\", {\r\n /**\r\n * @return Intensity (0-1)\r\n */\r\n get: function () {\r\n return this.properties.intensity;\r\n },\r\n /**\r\n * Intensity of the color (0-1).\r\n *\r\n * The bigger the number the more of a `color` target's colors will become.\r\n *\r\n * 0 means the colors will remain as they are.\r\n * 1 means all colors will become the target `color`.\r\n *\r\n * @default 1\r\n * @param value Intensity (0-1)\r\n */\r\n set: function (value) {\r\n this.properties.intensity = value;\r\n this.applyFilter();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return ColorizeFilter;\r\n}(Filter));\r\nexport { ColorizeFilter };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"ColorizeFilter\"] = ColorizeFilter;\r\n//# sourceMappingURL=ColorizeFilter.js.map","/**\r\n * Module for \"Desaturate\" filter.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Filter } from \"./Filter\";\r\nimport { registry } from \"../../Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creats a \"Desaturate\" filter\r\n */\r\nvar DesaturateFilter = /** @class */ (function (_super) {\r\n __extends(DesaturateFilter, _super);\r\n /**\r\n * Constructor\r\n */\r\n function DesaturateFilter() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"DesaturateFilter\";\r\n // Create elements\r\n // NOTE: we do not need to add each individual element to `_disposers`\r\n // because `filterPrimitives` has an event handler which automatically adds\r\n // anything added to it to `_disposers`\r\n _this.feColorMatrix = _this.paper.add(\"feColorMatrix\");\r\n _this.feColorMatrix.attr({ \"type\": \"saturate\" });\r\n _this.filterPrimitives.push(_this.feColorMatrix);\r\n // Set default properties\r\n _this.width = 120;\r\n _this.height = 120;\r\n _this.saturation = 0;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(DesaturateFilter.prototype, \"saturation\", {\r\n /**\r\n * @return Saturation (0-1)\r\n */\r\n get: function () {\r\n return this.properties[\"saturation\"];\r\n },\r\n /**\r\n * Saturation.\r\n *\r\n * 0 - completely desaturated.\r\n * 1 - fully saturated (gray).\r\n *\r\n * @param value Saturation (0-1)\r\n */\r\n set: function (value) {\r\n this.properties[\"saturation\"] = value;\r\n this.feColorMatrix.attr({ \"values\": value.toString() });\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return DesaturateFilter;\r\n}(Filter));\r\nexport { DesaturateFilter };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"DesaturateFilter\"] = DesaturateFilter;\r\n//# sourceMappingURL=DesaturateFilter.js.map","/**\r\n * Module for \"Blur\" filter.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Filter } from \"./Filter\";\r\nimport { registry } from \"../../Registry\";\r\n;\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creates a \"Blur\" filter.\r\n */\r\nvar BlurFilter = /** @class */ (function (_super) {\r\n __extends(BlurFilter, _super);\r\n /**\r\n * Constructor\r\n */\r\n function BlurFilter() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"BlurFilter\";\r\n // Create elements\r\n // NOTE: we do not need to add each individual element to `_disposers`\r\n // because `filterPrimitives` has an event handler which automatically adds\r\n // anything added to it to `_disposers`\r\n _this.feGaussianBlur = _this.paper.add(\"feGaussianBlur\");\r\n _this.feGaussianBlur.attr({ \"result\": \"blurOut\", \"in\": \"SourceGraphic\" });\r\n _this.filterPrimitives.push(_this.feGaussianBlur);\r\n // Set default properties\r\n _this.width = 200;\r\n _this.height = 200;\r\n _this.blur = 1.5;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(BlurFilter.prototype, \"blur\", {\r\n /**\r\n * @return Blur\r\n */\r\n get: function () {\r\n return this.properties.blur;\r\n },\r\n /**\r\n * Blur value.\r\n *\r\n * The bigger the value, the blurrier the target element will become.\r\n *\r\n * @default 1.5\r\n * @param value Blur\r\n */\r\n set: function (value) {\r\n this.properties.blur = value;\r\n this.feGaussianBlur.attr({ \"stdDeviation\": value / this.scale });\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return BlurFilter;\r\n}(Filter));\r\nexport { BlurFilter };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"BlurFilter\"] = BlurFilter;\r\n//# sourceMappingURL=BlurFilter.js.map","/**\r\n * Module for \"Focus\" filter.\r\n */\r\nimport { __extends } from \"tslib\";\r\nimport { Filter } from \"./Filter\";\r\nimport { InterfaceColorSet } from \"../../utils/InterfaceColorSet\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creates a \"Focus\" filter.\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/accessibility/} more about accessibility\r\n * @see {@link https://www.amcharts.com/docs/v4/tutorials/changing-appearance-of-focused-items/} cusomizing focus appearance\r\n */\r\nvar FocusFilter = /** @class */ (function (_super) {\r\n __extends(FocusFilter, _super);\r\n /**\r\n * Constructor\r\n */\r\n function FocusFilter() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"FocusFilter\";\r\n // Create elements\r\n // NOTE: we do not need to add each individual element to `_disposers`\r\n // because `filterPrimitives` has an event handler which automatically adds\r\n // anything added to it to `_disposers`\r\n _this.feFlood = _this.paper.add(\"feFlood\");\r\n _this.feFlood.attr({ \"flood-color\": new InterfaceColorSet().getFor(\"primaryButtonHover\"), \"result\": \"base\" });\r\n _this.filterPrimitives.push(_this.feFlood);\r\n _this.feMorphology = _this.paper.add(\"feMorphology\");\r\n _this.feMorphology.attr({ \"result\": \"bigger\", \"in\": \"SourceGraphic\", \"operator\": \"dilate\", \"radius\": \"2\" });\r\n _this.filterPrimitives.push(_this.feMorphology);\r\n _this.feColorMatrix = _this.paper.add(\"feColorMatrix\");\r\n _this.feColorMatrix.attr({ \"result\": \"mask\", \"in\": \"bigger\", \"type\": \"matrix\", \"values\": \"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0\" });\r\n _this.filterPrimitives.push(_this.feColorMatrix);\r\n _this.feComposite = _this.paper.add(\"feComposite\");\r\n _this.feComposite.attr({ \"result\": \"drop\", \"in\": \"base\", \"in2\": \"mask\", \"operator\": \"in\" });\r\n _this.filterPrimitives.push(_this.feComposite);\r\n _this.feBlend = _this.paper.add(\"feBlend\");\r\n _this.feBlend.attr({ \"in\": \"SourceGraphic\", \"in2\": \"drop\", \"mode\": \"normal\" });\r\n _this.filterPrimitives.push(_this.feBlend);\r\n // Set default properties\r\n _this.width = 130;\r\n _this.height = 130;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(FocusFilter.prototype, \"stroke\", {\r\n /**\r\n * @return Color\r\n */\r\n get: function () {\r\n return this.properties[\"stroke\"];\r\n },\r\n /**\r\n * Stroke (outline) color.\r\n *\r\n * @param value Color\r\n */\r\n set: function (value) {\r\n this.properties[\"stroke\"] = value;\r\n this.feFlood.attr({ \"flood-color\": value });\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(FocusFilter.prototype, \"strokeWidth\", {\r\n /**\r\n * @return Outline thickness (px)\r\n */\r\n get: function () {\r\n return this.properties[\"strokeWidth\"];\r\n },\r\n /**\r\n * Stroke (outline) thickness in pixels.\r\n *\r\n * @param value Outline thickness (px)\r\n */\r\n set: function (value) {\r\n this.properties[\"strokeWidth\"] = value;\r\n this.feMorphology.attr({ \"radius\": value });\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(FocusFilter.prototype, \"opacity\", {\r\n /**\r\n * @return Outline opacity (0-1)\r\n */\r\n get: function () {\r\n return this.properties[\"opacity\"];\r\n },\r\n /**\r\n * Opacity of the outline. (0-1)\r\n *\r\n * @param value Outline opacity (0-1)\r\n */\r\n set: function (value) {\r\n this.properties[\"opacity\"] = value;\r\n this.feColorMatrix.attr({ \"values\": \"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \" + value + \" 0\" });\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Sets filter's target element.\r\n *\r\n * In addition it also disables built-in focus outline on element this\r\n * filter is applied to.\r\n *\r\n * @ignore Exclude from docs\r\n * @param value Element filter is being attached to\r\n */\r\n FocusFilter.prototype.setSprite = function (value) {\r\n if (this._sprite && this._sprite != value) {\r\n this._sprite.group.removeStyle(\"outline\");\r\n }\r\n value.group.addStyle({\r\n \"outline\": \"none\"\r\n });\r\n _super.prototype.setSprite.call(this, value);\r\n };\r\n return FocusFilter;\r\n}(Filter));\r\nexport { FocusFilter };\r\n//# sourceMappingURL=FocusFilter.js.map","/**\r\n * This module contains ColorSet object definition\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { BaseObject } from \"../Base\";\r\nimport { Color, color } from \"./Color\";\r\nimport { registry } from \"../Registry\";\r\nimport * as $colors from \"./Colors\";\r\nimport * as $type from \"./Type\";\r\nimport * as $utils from \"./Utils\";\r\nimport * as $math from \"./Math\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Represents a set of colors. Can also generate colors according to set rules.\r\n *\r\n * @important\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/colors/} for color-related info\r\n */\r\nvar ColorSet = /** @class */ (function (_super) {\r\n __extends(ColorSet, _super);\r\n /**\r\n * Constructor\r\n */\r\n function ColorSet() {\r\n var _this = _super.call(this) || this;\r\n /**\r\n * Holds the list of the colors in this set. (preset or auto-generated)\r\n */\r\n _this._list = [];\r\n /**\r\n * Current step in a color generator's cycle.\r\n */\r\n _this._currentStep = 0;\r\n /**\r\n * If set to non-zero value, the ColorSet will start iterating colors from\r\n * that particular index, not the first color in the list.\r\n */\r\n _this._startIndex = 0;\r\n /**\r\n * Current pass in the color generator's cycle. Normally a generator would\r\n * cycle through all available hue range, then repeat it, alternating other\r\n * color properties, to generate distinctive colors.\r\n */\r\n _this._currentPass = 0;\r\n /**\r\n * A base color. If there are no colors pre-set in the color list, ColorSet\r\n * will use this color as a base when generating new ones, applying\r\n * `stepOptions` and `passOptions` to this base color.\r\n */\r\n _this.baseColor = new Color({\r\n r: 103,\r\n g: 183,\r\n b: 220\r\n });\r\n /**\r\n * Modifications to apply with each new generated color.\r\n */\r\n _this.stepOptions = {};\r\n /**\r\n * Modifications to apply on top of `stepOptions` for each \"pass\" of the\r\n * color generation.\r\n *\r\n * A \"pass\" is when ColorSet generates `minColors` number of colors.\r\n */\r\n _this.passOptions = {\r\n brighten: -0.2\r\n };\r\n /**\r\n * An index increment to use when iterating through color list.\r\n *\r\n * Default is 1, which means returning each and every color.\r\n *\r\n * Setting it to a bigger number will make ColorSet `next()` iterator skip\r\n * some colors.\r\n *\r\n * E.g. setting to 2, will return every second color in the list.\r\n *\r\n * This is useful, when the color list has colors that are too close each\r\n * other for contrast.\r\n *\r\n * However, having bigger number will mean that `next()` iterator will go\r\n * through the list quicker, and the generator will kick sooner.\r\n */\r\n _this.step = 1;\r\n /**\r\n * A number of colors to generate in one \"pass\".\r\n *\r\n * This setting can be automatically overridden, if ColorSet has a list of\r\n * pre-set colors. In such case ColorSet will generate exactly the same\r\n * number of colors with each pass as there were colors in original set.\r\n */\r\n _this.minColors = 20;\r\n /**\r\n * Do not let the \"lightness\" of generated color to fall below this\r\n * threshold.\r\n */\r\n _this.minLightness = 0.2;\r\n /**\r\n * Do not let the \"lightness\" of generated color to get above this threshold.\r\n */\r\n _this.maxLightness = 0.9;\r\n /**\r\n * Randomly shuffle generated colors.\r\n */\r\n _this.shuffle = false;\r\n /**\r\n * When colors are generated, based on `stepOptions`, each generated color\r\n * gets either lighter or darker.\r\n *\r\n * If this is set to `true`, color generator will switch to opposing spectrum\r\n * when reaching `minLightness` or `maxLightness`.\r\n *\r\n * E.g. if we start off with a red color, then gradually generate lighter\r\n * colors through rose shades, then switch back to dark red and gradually\r\n * increase the lightness of it until it reaches the starting red.\r\n *\r\n * If set to `false` it will stop there and cap lightness at whatever level\r\n * we hit `minLightness` or `maxLightness`, which may result in a number of\r\n * the same colors.\r\n */\r\n _this.wrap = true;\r\n /**\r\n * Re-use same colors in the pre-set list, when ColorSet runs out of colors,\r\n * rather than start generating new ones.\r\n */\r\n _this.reuse = false;\r\n /**\r\n * Saturation of colors. This will change saturation of all colors of color\r\n * set.\r\n *\r\n * It is recommended to set this in theme, as changing it at run time won't\r\n * make the items to redraw and change color.\r\n */\r\n _this.saturation = 1;\r\n _this.className = \"ColorSet\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(ColorSet.prototype, \"list\", {\r\n /**\r\n * Returns current list of colors.\r\n *\r\n * If there are none, a new list of colors is generated, based on various\r\n * ColorSet settings.\r\n *\r\n * @return Color list\r\n */\r\n get: function () {\r\n if (!this._list) {\r\n this.generate(this.minColors);\r\n }\r\n return this._list;\r\n },\r\n /**\r\n * Sets a list of pre-defined colors to use for the iterator.\r\n *\r\n * @param value Color list\r\n */\r\n set: function (value) {\r\n this._list = value;\r\n this.reset();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Gets reusable color.\r\n *\r\n * @param index Index of color\r\n * @return Color\r\n */\r\n ColorSet.prototype.getReusableColor = function (index) {\r\n if (this._list.length == 0) {\r\n this.generate(1);\r\n return this.list[0];\r\n }\r\n else {\r\n var tmpstep = index - (Math.floor(index / this._list.length) * this.list.length);\r\n return this.list[tmpstep];\r\n }\r\n };\r\n /**\r\n * Returns next color in the list using internal iterator counter.\r\n *\r\n * If `step` is set to something other than 1, it may return other color than\r\n * exact next one in the list.\r\n *\r\n * @return Color\r\n */\r\n ColorSet.prototype.next = function () {\r\n var color;\r\n if (this.list.length <= this._currentStep) {\r\n if (this.reuse) {\r\n color = this.getReusableColor(this._currentStep);\r\n }\r\n else {\r\n this.generate($math.max(this.minColors, this._currentStep + 1));\r\n color = this.list[this._currentStep];\r\n }\r\n }\r\n else {\r\n color = this.list[this._currentStep];\r\n }\r\n this._currentStep += this.step;\r\n return color.saturate(this.saturation);\r\n };\r\n /**\r\n * Returns a color at specific index in the list.\r\n *\r\n * @param i Index\r\n * @return Color\r\n */\r\n ColorSet.prototype.getIndex = function (i) {\r\n var color;\r\n if (this.list.length <= i) {\r\n if (this.reuse) {\r\n color = this.getReusableColor(i);\r\n }\r\n else {\r\n this.generate(this.minColors);\r\n color = this.getIndex(i);\r\n }\r\n }\r\n else {\r\n color = this.list[i];\r\n }\r\n return color.saturate(this.saturation);\r\n };\r\n /**\r\n * Resets internal iterator.\r\n *\r\n * Calling `next()` after this will return the very first color in the color\r\n * list, even if it was already returned before.\r\n */\r\n ColorSet.prototype.reset = function () {\r\n this._currentStep = this._startIndex;\r\n };\r\n Object.defineProperty(ColorSet.prototype, \"currentStep\", {\r\n /**\r\n * @return Step\r\n */\r\n get: function () {\r\n return this._currentStep;\r\n },\r\n /**\r\n * Sets current color iteration. You can use this property to skip some\r\n * colors from iteration. E.g. setting it to `10` will skip first ten\r\n * colors.\r\n *\r\n * Please note that the number is zero-based.\r\n *\r\n * @param value Step\r\n */\r\n set: function (value) {\r\n this._currentStep = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ColorSet.prototype, \"startIndex\", {\r\n /**\r\n * @return Index\r\n */\r\n get: function () {\r\n return this._startIndex;\r\n },\r\n /**\r\n * If set to non-zero value, the ColorSet will start iterating colors from\r\n * that particular index, not the first color in the list.\r\n *\r\n * @default 0\r\n * @since 4.4.9\r\n * @param value Index\r\n */\r\n set: function (value) {\r\n this._startIndex = value;\r\n this.reset();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Generates colors based on the various ColorSet settings.\r\n *\r\n * @param count Number of colors to generate\r\n */\r\n ColorSet.prototype.generate = function (count) {\r\n // Init\r\n var curColor = this.currentColor;\r\n var hsl = $colors.rgbToHsl($type.getValue(curColor.rgb));\r\n var hueStep = $type.hasValue(this.stepOptions.hue) ? this.stepOptions.hue : 1 / count;\r\n var mods = {\r\n brighten: 0,\r\n lighten: 0,\r\n hue: hsl.h,\r\n lightness: hsl.l,\r\n saturation: hsl.s\r\n };\r\n // Generate list of hues, and shuffle them\r\n var hues = [];\r\n var startIndex = this.list.length == 0 ? 0 : 1;\r\n if (this.reuse) {\r\n for (var i = startIndex; i <= count; i++) {\r\n hues.push($colors.rgbToHsl($type.getValue(this._list[i].rgb)).h);\r\n }\r\n }\r\n else {\r\n for (var i = startIndex; i <= count; i++) {\r\n var h = hsl.h + hueStep * i;\r\n if (this.wrap && (h > 1)) {\r\n h -= 1;\r\n }\r\n hues.push(h);\r\n }\r\n }\r\n // Shuffle colors randomly\r\n if (this.shuffle) {\r\n hues.sort(function (a, b) {\r\n return Math.random() - 0.5;\r\n });\r\n }\r\n // Generate colors by rotating hue\r\n for (var i = 0; i < count; i++) {\r\n // Update hue\r\n if (this.reuse) {\r\n hsl = $colors.rgbToHsl($type.getValue(this._list[i].rgb));\r\n }\r\n else {\r\n hsl.h = hues.shift();\r\n }\r\n // Apply HSL mods\r\n this.applyStepOptions(hsl, mods, i, this._currentPass);\r\n // Convert back to Color\r\n var c = color($colors.hslToRgb(hsl));\r\n // Apply regular color mods\r\n var brighten = (this.stepOptions.brighten || 0) * i + (this.passOptions.brighten || 0) * this._currentPass;\r\n if (brighten != 0) {\r\n if (this.wrap) {\r\n brighten = $utils.fitNumberRelative(brighten, this.minLightness, this.maxLightness);\r\n }\r\n else {\r\n brighten = $utils.fitNumber(brighten, this.minLightness, this.maxLightness);\r\n }\r\n c = c.brighten(brighten);\r\n }\r\n var lighten = (this.stepOptions.lighten || 0) * i + (this.passOptions.lighten || 0) * this._currentPass;\r\n if (lighten != 0) {\r\n if (this.wrap) {\r\n lighten = $utils.fitNumberRelative(lighten, this.minLightness, this.maxLightness);\r\n }\r\n else {\r\n lighten = $utils.fitNumber(lighten, this.minLightness, this.maxLightness);\r\n }\r\n c = c.lighten(lighten);\r\n }\r\n this._list.push(c);\r\n }\r\n this._currentPass++;\r\n };\r\n Object.defineProperty(ColorSet.prototype, \"currentColor\", {\r\n /**\r\n * Returns current last color. It's either the last color in the list of\r\n * colors, or `baseColor` if list is empty.\r\n *\r\n * @return Color\r\n */\r\n get: function () {\r\n if (this._list.length == 0) {\r\n return this.baseColor.saturate(this.saturation);\r\n }\r\n else {\r\n return this._list[this._list.length - 1].saturate(this.saturation);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Generates modifiers for color, based on what step and pass.\r\n *\r\n * @param hsl Curren HSL value of the color to modify\r\n * @param base The modifiers that were before modification to use as a base\r\n * @param step Current step\r\n * @param pass Current pass\r\n */\r\n ColorSet.prototype.applyStepOptions = function (hsl, base, step, pass) {\r\n // Process lightness\r\n hsl.l = base.lightness + (this.stepOptions.lightness || 0) * step + (this.passOptions.lightness || 0) * pass;\r\n if (this.wrap) {\r\n if (hsl.l > 1) {\r\n hsl.l = hsl.l - Math.floor(hsl.l);\r\n }\r\n else if (hsl.l < 0) {\r\n hsl.l = -(hsl.l - Math.floor(hsl.l));\r\n }\r\n hsl.l = $utils.fitNumberRelative(hsl.l, this.minLightness, this.maxLightness);\r\n }\r\n else {\r\n if (hsl.l > 1) {\r\n hsl.l = 1;\r\n }\r\n else if (hsl.l < 0) {\r\n hsl.l = 0;\r\n }\r\n hsl.l = $utils.fitNumber(hsl.l, this.minLightness, this.maxLightness);\r\n }\r\n };\r\n /**\r\n * Processes JSON-based config before it is applied to the object.\r\n *\r\n * @ignore Exclude from docs\r\n * @param config Config\r\n */\r\n ColorSet.prototype.processConfig = function (config) {\r\n if (config) {\r\n // Cast colors\r\n if ($type.hasValue(config.list) && $type.isArray(config.list)) {\r\n for (var i = 0, len = config.list.length; i < len; i++) {\r\n if (!(config.list[i] instanceof Color)) {\r\n config.list[i] = color(config.list[i]);\r\n }\r\n }\r\n }\r\n if ($type.hasValue(config.baseColor) && !(config.baseColor instanceof Color)) {\r\n config.baseColor = color(config.baseColor);\r\n }\r\n }\r\n _super.prototype.processConfig.call(this, config);\r\n };\r\n return ColorSet;\r\n}(BaseObject));\r\nexport { ColorSet };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"ColorSet\"] = ColorSet;\r\n//# sourceMappingURL=ColorSet.js.map","/**\r\n * This module contains PatternSet object definition\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { BaseObject } from \"../Base\";\r\nimport { Color } from \"./Color\";\r\nimport { InterfaceColorSet } from \"./InterfaceColorSet\";\r\nimport { LinePattern } from \"../rendering/fills/LinePattern\";\r\nimport { RectPattern } from \"../rendering/fills/RectPattern\";\r\nimport { CirclePattern } from \"../rendering/fills/CirclePattern\";\r\nimport { registry } from \"../Registry\";\r\n/**\r\n * ============================================================================\r\n * REQUISITES\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines an interable list of distinctive patterns that can be used in\r\n * conjunction to colors to generate various fill patterns.\r\n *\r\n * @important\r\n * @since 4.7.5\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/colors/} for color-related info\r\n */\r\nvar PatternSet = /** @class */ (function (_super) {\r\n __extends(PatternSet, _super);\r\n /**\r\n * Constructor\r\n */\r\n function PatternSet() {\r\n var _this = _super.call(this) || this;\r\n /**\r\n * Holds the list of the colors in this set. (preset or auto-generated)\r\n */\r\n _this._list = [];\r\n /**\r\n * Current step.\r\n */\r\n _this._currentStep = 0;\r\n /**\r\n * If set to non-zero value, the PatternSet will start iterating patterns from\r\n * that particular index, not the first pattern in the list.\r\n */\r\n _this._startIndex = 0;\r\n /**\r\n * Current pass in cycle. Once all patterns in the list are iterated,\r\n * iteration restarts from beginning and currentPass is incremented.\r\n */\r\n _this._currentPass = 0;\r\n /**\r\n * A base color. If there are no colors pre-set in the color list, ColorSet\r\n * will use this color as a base when generating new ones, applying\r\n * `stepOptions` and `passOptions` to this base color.\r\n */\r\n _this.baseColor = new Color({\r\n r: 103,\r\n g: 183,\r\n b: 220\r\n });\r\n _this.className = \"PatternSet\";\r\n // Set base color to be used for pattern elements\r\n var interfaceColors = new InterfaceColorSet();\r\n // Set default patterns\r\n _this.list = [\r\n _this.getLinePattern(1000, 45, 1, 6),\r\n _this.getRectPattern(10, 0, 4),\r\n _this.getLinePattern(1000, -45, 1, 6),\r\n _this.getCirclePattern(11, 2, true),\r\n _this.getLinePattern(6, 90, 1),\r\n _this.getRectPattern(12, 45, 6, true),\r\n _this.getLinePattern(6, 0, 1),\r\n _this.getRectPattern(7, 0, 4),\r\n _this.getLinePattern(1000, 45, 2, 3, \"4,2\"),\r\n _this.getCirclePattern(9, 3, false),\r\n _this.getLinePattern(1000, -45, 2, 3, \"4,2\"),\r\n _this.getRectPattern(10, 45, Math.sqrt(50)),\r\n _this.getLinePattern(1000, -45, 2, 1),\r\n _this.getRectPattern(10, 0, 9),\r\n _this.getLinePattern(1000, 45, 2, 1),\r\n _this.getLinePattern(1000, 0, 3, 1),\r\n _this.getRectPattern(10, 45, 10),\r\n _this.getLinePattern(1000, 90, 3, 1)\r\n ];\r\n _this.baseColor = interfaceColors.getFor(\"stroke\");\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n PatternSet.prototype.getLinePattern = function (size, rotation, thickness, gap, strokeDashArray) {\r\n var pattern = new LinePattern();\r\n pattern.width = size;\r\n pattern.height = size;\r\n pattern.stroke = this.baseColor;\r\n pattern.gap = gap;\r\n pattern.strokeDasharray = strokeDashArray;\r\n pattern.strokeWidth = thickness;\r\n pattern.rotation = rotation;\r\n return pattern;\r\n };\r\n PatternSet.prototype.getRectPattern = function (size, rotation, thickness, outline) {\r\n var pattern = new RectPattern();\r\n pattern.width = size;\r\n pattern.height = size;\r\n pattern.rectWidth = thickness;\r\n pattern.rectHeight = thickness;\r\n if (outline) {\r\n pattern.stroke = this.baseColor;\r\n pattern.strokeWidth = 1;\r\n pattern.fillOpacity = 0;\r\n }\r\n else {\r\n pattern.fill = this.baseColor;\r\n pattern.strokeWidth = 0;\r\n }\r\n if (rotation != 0) {\r\n pattern.shapeRendering = \"auto\";\r\n }\r\n pattern.rotation = rotation;\r\n return pattern;\r\n };\r\n PatternSet.prototype.getCirclePattern = function (size, radius, outline) {\r\n var pattern = new CirclePattern();\r\n pattern.width = size;\r\n pattern.height = size;\r\n pattern.shapeRendering = \"auto\";\r\n pattern.radius = radius;\r\n if (outline) {\r\n pattern.stroke = this.baseColor;\r\n pattern.strokeWidth = 1;\r\n pattern.fillOpacity = 0;\r\n }\r\n else {\r\n pattern.fill = this.baseColor;\r\n pattern.strokeWidth = 0;\r\n }\r\n return pattern;\r\n };\r\n Object.defineProperty(PatternSet.prototype, \"list\", {\r\n /**\r\n * @return Pattern list\r\n */\r\n get: function () {\r\n return this._list;\r\n },\r\n /**\r\n * List of pre-defined patterns to be used in set.\r\n *\r\n * @param value Pattern list\r\n */\r\n set: function (value) {\r\n this._list = value;\r\n this.reset();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Returns the next pattern in list.\r\n *\r\n * @return Pattern\r\n */\r\n PatternSet.prototype.next = function () {\r\n var pattern = this.getIndex(this.currentStep);\r\n this._currentStep++;\r\n return pattern;\r\n };\r\n /**\r\n * Returns a color at specific index in the list.\r\n *\r\n * @param i Index\r\n * @return Pattern\r\n */\r\n PatternSet.prototype.getIndex = function (i) {\r\n var pattern;\r\n while (this.list.length <= i) {\r\n this.generatePatterns();\r\n }\r\n pattern = this.list[i];\r\n return pattern.clone();\r\n };\r\n /**\r\n * Generates a new set of patterns.\r\n */\r\n PatternSet.prototype.generatePatterns = function () {\r\n var count = this.list.length / (this._currentPass + 1);\r\n this._currentPass++;\r\n for (var i = 0; i < count; i++) {\r\n this.list.push(this.list[i].clone());\r\n }\r\n };\r\n /**\r\n * Resets internal iterator.\r\n *\r\n * Calling `next()` after this will return the very first color in the color\r\n * list, even if it was already returned before.\r\n */\r\n PatternSet.prototype.reset = function () {\r\n this._currentStep = this._startIndex;\r\n };\r\n Object.defineProperty(PatternSet.prototype, \"currentStep\", {\r\n /**\r\n * @return Step\r\n */\r\n get: function () {\r\n return this._currentStep;\r\n },\r\n /**\r\n * Sets current color iteration. You can use this property to skip some\r\n * colors from iteration. E.g. setting it to `10` will skip first ten\r\n * colors.\r\n *\r\n * Please note that the number is zero-based.\r\n *\r\n * @param value Step\r\n */\r\n set: function (value) {\r\n this._currentStep = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(PatternSet.prototype, \"startIndex\", {\r\n /**\r\n * @return Index\r\n */\r\n get: function () {\r\n return this._startIndex;\r\n },\r\n /**\r\n * If set to non-zero value, the ColorSet will start iterating colors from\r\n * that particular index, not the first color in the list.\r\n *\r\n * @default 0\r\n * @param value Index\r\n */\r\n set: function (value) {\r\n this._startIndex = value;\r\n this.reset();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Processes JSON-based config before it is applied to the object.\r\n *\r\n * @ignore Exclude from docs\r\n * @param config Config\r\n */\r\n PatternSet.prototype.processConfig = function (config) {\r\n // if (config) {\r\n // \t// Set up axis ranges\r\n // \tif ($type.hasValue(config.list) && $type.isArray(config.list)) {\r\n // \t\tfor (let i = 0, len = config.list.length; i < len; i++) {\r\n // \t\t\tif (!(config.list[i] instanceof Color)) {\r\n // \t\t\t\tconfig.list[i] = color(config.list[i]);\r\n // \t\t\t}\r\n // \t\t}\r\n // \t}\r\n // }\r\n _super.prototype.processConfig.call(this, config);\r\n };\r\n return PatternSet;\r\n}(BaseObject));\r\nexport { PatternSet };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"PatternSet\"] = PatternSet;\r\n//# sourceMappingURL=PatternSet.js.map","/**\r\n * A plugin base class.\r\n */\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * This is a base class that provides core functionality for plugins.\r\n *\r\n * The easiest way to start off with a new plugin is to extend this class.\r\n *\r\n * It will provide all the mandatory functionality, such as disposers.\r\n *\r\n * @since 4.2.2\r\n */\r\nvar Plugin = /** @class */ (function () {\r\n /**\r\n * Constructor\r\n */\r\n function Plugin() {\r\n /**\r\n * Is this object disposed?\r\n */\r\n this._disposed = false;\r\n /**\r\n * List of IDisposer which will be disposed when the BaseObject is disposed.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n this._disposers = [];\r\n // Nothing to do here\r\n }\r\n /**\r\n * Decorates series with required events and adapters used to hijack its\r\n * data.\r\n */\r\n Plugin.prototype.init = function () {\r\n // Does nothing\r\n // Override it\r\n };\r\n /**\r\n * Returns if this element is already disposed.\r\n *\r\n * @return Is disposed?\r\n */\r\n Plugin.prototype.isDisposed = function () {\r\n return this._disposed;\r\n };\r\n /**\r\n * Disposes this object and related stuff.\r\n */\r\n Plugin.prototype.dispose = function () {\r\n if (!this._disposed) {\r\n this._disposed = true;\r\n var a = this._disposers;\r\n this._disposers = null;\r\n while (a.length !== 0) {\r\n var disposer = a.shift();\r\n disposer.dispose();\r\n }\r\n }\r\n };\r\n return Plugin;\r\n}());\r\nexport { Plugin };\r\n//# sourceMappingURL=Plugin.js.map","/**\r\n * AmChartsLogo module.\r\n *\r\n * AmChartsLogo shows amCharts logo for non-commercial users of a library.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../Container\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport { Polyspline } from \"./Polyspline\";\r\nimport { color } from \"../utils/Color\";\r\nimport { LinearGradient } from \"../rendering/fills/LinearGradient\";\r\nimport { DesaturateFilter } from \"../rendering/filters/DesaturateFilter\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A class used to draw and display progress indicator.\r\n *\r\n * @see {@link IAmChartsLogoEvents} for a list of available events\r\n * @see {@link IAmChartsLogoAdapters} for a list of available Adapters\r\n * @ignore Exclude from docs\r\n */\r\nvar AmChartsLogo = /** @class */ (function (_super) {\r\n __extends(AmChartsLogo, _super);\r\n /**\r\n * Constructor\r\n */\r\n function AmChartsLogo() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"AmChartsLogo\";\r\n _this.valign = \"bottom\";\r\n var d = 0.3;\r\n _this.opacity = 0.3;\r\n _this.defaultState.properties.opacity = 0.4;\r\n _this.url = \"https://www.amcharts.com/\";\r\n _this.urlTarget = \"_blank\";\r\n _this.showSystemTooltip = true;\r\n _this.readerTitle = \"Chart created using amCharts library\";\r\n _this.width = 220 * d;\r\n _this.height = 70 * d;\r\n _this.background.opacity = 0;\r\n var aColor = color(\"#474758\");\r\n if (new InterfaceColorSet().getFor(\"background\").alternative.hex == \"#ffffff\") {\r\n aColor = color(\"#ffffff\");\r\n }\r\n var aGradient = new LinearGradient();\r\n aGradient.addColor(aColor);\r\n aGradient.addColor(aColor, 1, 0.75);\r\n aGradient.addColor(color(\"#3cabff\"), 1, 0.755);\r\n aGradient.rotation = -10;\r\n var aStroke = aGradient;\r\n var m = _this.createChild(Polyspline);\r\n m.shouldClone = false;\r\n m.isMeasured = false;\r\n m.segments = [[{ x: 50 * d, y: 50 * d }, { x: 90 * d, y: 50 * d }, { x: 120 * d, y: 20 * d }, { x: 135 * d, y: 35 * d }, { x: 150 * d, y: 20 * d }, { x: 180 * d, y: 50 * d }, { x: 200 * d, y: 50 * d }]];\r\n m.strokeWidth = 6 * d;\r\n m.tensionX = 0.8;\r\n m.tensionY = 1;\r\n m.stroke = color(\"#3cabff\");\r\n var a = _this.createChild(Polyspline);\r\n a.shouldClone = false;\r\n a.isMeasured = false;\r\n a.segments = [[{ x: 20 * d, y: 50 * d }, { x: 50 * d, y: 50 * d }, { x: 90 * d, y: 12 * d }, { x: 133 * d, y: 50 * d }, { x: 170 * d, y: 50 * d }, { x: 200 * d, y: 50 * d }]];\r\n a.strokeWidth = 6 * d;\r\n a.tensionX = 0.75;\r\n a.tensionY = 1;\r\n a.stroke = aStroke;\r\n _this._disposers.push(a);\r\n var desaturateFilter = new DesaturateFilter();\r\n _this.filters.push(desaturateFilter);\r\n var desaturateFilterHover = new DesaturateFilter();\r\n desaturateFilterHover.saturation = 1;\r\n var hoverState = _this.states.create(\"hover\");\r\n hoverState.properties.opacity = 1;\r\n hoverState.filters.push(desaturateFilterHover);\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n return AmChartsLogo;\r\n}(Container));\r\nexport { AmChartsLogo };\r\n//# sourceMappingURL=AmChartsLogo.js.map","/**\r\n * Legend-related functionality.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Component } from \"../core/Component\";\r\nimport { DataItem } from \"../core/DataItem\";\r\nimport { ListTemplate, ListDisposer } from \"../core/utils/List\";\r\nimport { RoundedRectangle } from \"../core/elements/RoundedRectangle\";\r\nimport { Container } from \"../core/Container\";\r\nimport { Label } from \"../core/elements/Label\";\r\nimport { keyboard } from \"../core/utils/Keyboard\";\r\nimport { registry } from \"../core/Registry\";\r\nimport { getInteraction } from \"../core/interaction/Interaction\";\r\nimport { percent, Percent } from \"../core/utils/Percent\";\r\nimport { InterfaceColorSet } from \"../core/utils/InterfaceColorSet\";\r\nimport * as $utils from \"../core/utils/Utils\";\r\nimport * as $type from \"../core/utils/Type\";\r\nimport * as $math from \"../core/utils/Math\";\r\nimport { Sprite } from \"../core/Sprite\";\r\nimport { Disposer } from \"../core/utils/Disposer\";\r\nimport { MouseCursorStyle } from \"../core/interaction/Mouse\";\r\nimport { defaultRules, ResponsiveBreakpoints } from \"../core/utils/Responsive\";\r\nimport { Scrollbar } from \"../core/elements/Scrollbar\";\r\n/**\r\n * ============================================================================\r\n * DATA ITEM\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines a [[DataItem]] for [[Legend]].\r\n *\r\n * @see {@link DataItem}\r\n */\r\nvar LegendDataItem = /** @class */ (function (_super) {\r\n __extends(LegendDataItem, _super);\r\n /**\r\n * Constructor\r\n */\r\n function LegendDataItem() {\r\n var _this = _super.call(this) || this;\r\n /**\r\n * @ignore\r\n */\r\n _this.childrenCreated = false;\r\n _this.className = \"LegendDataItem\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(LegendDataItem.prototype, \"label\", {\r\n /**\r\n * A legend item's [[Label]] element.\r\n *\r\n * @return Label\r\n */\r\n get: function () {\r\n var _this = this;\r\n if (!this._label) {\r\n var label_1 = this.component.labels.create();\r\n this._label = label_1;\r\n this.addSprite(label_1);\r\n this._disposers.push(label_1);\r\n label_1.parent = this.itemContainer;\r\n this._disposers.push(new Disposer(function () {\r\n if ($type.hasValue(_this.component)) {\r\n _this.component.labels.removeValue(label_1);\r\n }\r\n }));\r\n }\r\n return this._label;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(LegendDataItem.prototype, \"color\", {\r\n /**\r\n * @return Main color\r\n */\r\n get: function () {\r\n return this.properties.color;\r\n },\r\n /**\r\n * Main color of legend data item.\r\n *\r\n * This is set by the target element this legend item represents, like\r\n * a Series or a Slice.\r\n *\r\n * It can be used to derive a color in legend's sub-items, like label:\r\n *\r\n * ```TypeScript\r\n * chart.legend.labels.template.text = \"[{color}]{name}[/]\";\r\n * ```\r\n * ```JavaScript\r\n * chart.legend.labels.template.text = \"[{color}]{name}[/]\";\r\n * ```\r\n * ```JSON\r\n * {\r\n * // ...\r\n * \"legend\": {\r\n * // ...\r\n * \"labels\": {\r\n * \"text\": \"[{color}]{name}[/]\"\r\n * }\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/legend/#Legend_labels} For more information about configuring legend labels.\r\n * @param value Main color\r\n */\r\n set: function (value) {\r\n this.setProperty(\"color\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(LegendDataItem.prototype, \"valueLabel\", {\r\n /**\r\n * A legend item's [[Label]] element for \"value label\".\r\n *\r\n * @return Label\r\n */\r\n get: function () {\r\n var _this = this;\r\n if (!this._valueLabel) {\r\n var valueLabel_1 = this.component.valueLabels.create();\r\n this._valueLabel = valueLabel_1;\r\n this.addSprite(valueLabel_1);\r\n this._disposers.push(valueLabel_1);\r\n valueLabel_1.parent = this.itemContainer;\r\n this._disposers.push(new Disposer(function () {\r\n if ($type.hasValue(_this.component)) {\r\n _this.component.valueLabels.removeValue(valueLabel_1);\r\n }\r\n }));\r\n }\r\n return this._valueLabel;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(LegendDataItem.prototype, \"itemContainer\", {\r\n /**\r\n * A reference to the main [[Container]] that holds legend item's elements:\r\n * marker and labels.\r\n *\r\n * @return Item container\r\n */\r\n get: function () {\r\n var _this = this;\r\n if (!this._itemContainer) {\r\n var component_1 = this.component;\r\n var itemContainer_1 = component_1.itemContainers.create();\r\n itemContainer_1.parent = component_1;\r\n this._itemContainer = itemContainer_1;\r\n this.addSprite(itemContainer_1);\r\n this._disposers.push(itemContainer_1);\r\n // Add click/tap event to toggle item\r\n if (itemContainer_1.togglable) {\r\n itemContainer_1.events.on(\"toggled\", function (ev) {\r\n component_1.toggleDataItem(ev.target.dataItem);\r\n }, undefined, false);\r\n }\r\n // Add focus event so that we can track which object is currently in focus\r\n // for keyboard toggling\r\n if (itemContainer_1.focusable) {\r\n itemContainer_1.events.on(\"hit\", function (ev) {\r\n // We need this here in order to reset focused item when it is clicked\r\n // normally so that it is not toggled by ENTER afterwards\r\n component_1.focusedItem = undefined;\r\n }, undefined, false);\r\n itemContainer_1.events.on(\"focus\", function (ev) {\r\n component_1.focusedItem = ev.target.dataItem;\r\n }, undefined, false);\r\n itemContainer_1.events.on(\"blur\", function (ev) {\r\n component_1.focusedItem = undefined;\r\n }, undefined, false);\r\n }\r\n this._disposers.push(new Disposer(function () {\r\n if ($type.hasValue(_this.component)) {\r\n _this.component.itemContainers.removeValue(itemContainer_1);\r\n }\r\n }));\r\n if (this.dataContext.uidAttr) {\r\n itemContainer_1.readerControls = this.dataContext.uidAttr();\r\n itemContainer_1.readerLabelledBy = this.dataContext.uidAttr();\r\n }\r\n var sprite = this.dataContext;\r\n if ((sprite instanceof DataItem || sprite instanceof Sprite) && !sprite.isDisposed()) {\r\n var visibilitychanged = function (ev) {\r\n itemContainer_1.readerChecked = ev.visible;\r\n itemContainer_1.events.disableType(\"toggled\");\r\n itemContainer_1.isActive = !ev.visible;\r\n itemContainer_1.events.enableType(\"toggled\");\r\n };\r\n sprite.addDisposer(new Disposer(function () {\r\n if (_this.component) {\r\n _this.component.dataItems.remove(_this);\r\n }\r\n }));\r\n if (sprite instanceof Sprite) {\r\n itemContainer_1.addDisposer(sprite.events.on(\"visibilitychanged\", visibilitychanged, undefined, false));\r\n itemContainer_1.addDisposer(sprite.events.on(\"hidden\", function (ev) {\r\n itemContainer_1.readerChecked = false;\r\n itemContainer_1.events.disableType(\"toggled\");\r\n itemContainer_1.isActive = true;\r\n itemContainer_1.events.enableType(\"toggled\");\r\n }, undefined, false));\r\n itemContainer_1.addDisposer(sprite.events.on(\"shown\", function (ev) {\r\n itemContainer_1.readerChecked = true;\r\n itemContainer_1.events.disableType(\"toggled\");\r\n itemContainer_1.isActive = false;\r\n itemContainer_1.events.enableType(\"toggled\");\r\n }, undefined, false));\r\n }\r\n else {\r\n itemContainer_1.addDisposer(sprite.events.on(\"visibilitychanged\", visibilitychanged, undefined, false));\r\n }\r\n }\r\n }\r\n return this._itemContainer;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(LegendDataItem.prototype, \"marker\", {\r\n /**\r\n * A [[Container]] that holds legend item's marker element.\r\n *\r\n * @return Marker\r\n */\r\n get: function () {\r\n var _this = this;\r\n if (!this._marker) {\r\n var marker_1 = this.component.markers.create();\r\n this._marker = marker_1;\r\n marker_1.parent = this.itemContainer;\r\n this.addSprite(marker_1);\r\n this._disposers.push(marker_1);\r\n this._disposers.push(new Disposer(function () {\r\n if ($type.hasValue(_this.component)) {\r\n _this.component.markers.removeValue(marker_1);\r\n }\r\n }));\r\n }\r\n return this._marker;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return LegendDataItem;\r\n}(DataItem));\r\nexport { LegendDataItem };\r\n/**\r\n * ============================================================================\r\n * REQUISITES\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines a class that carries legend settings.\r\n *\r\n * A legend might change its settings dynamically. Legend can also be shared\r\n * by several elements, requiring different settings.\r\n *\r\n * Having legend's settings in a separate object is a good way to \"hot swap\"\r\n * a set of settings for the legend.\r\n */\r\nvar LegendSettings = /** @class */ (function () {\r\n function LegendSettings() {\r\n /**\r\n * Should marker be created for each legend item.\r\n */\r\n this.createMarker = true;\r\n }\r\n return LegendSettings;\r\n}());\r\nexport { LegendSettings };\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * [[Legend]] class is used to create legend for the chart.\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/legend/} for Legend documentation\r\n * @see {@link ILegendEvents} for a list of available events\r\n * @see {@link ILegendAdapters} for a list of available Adapters\r\n */\r\nvar Legend = /** @class */ (function (_super) {\r\n __extends(Legend, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Legend() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"Legend\";\r\n // Set defaults\r\n _this.layout = \"grid\";\r\n _this.setPropertyValue(\"useDefaultMarker\", false);\r\n _this.setPropertyValue(\"scrollable\", false);\r\n _this.setPropertyValue(\"contentAlign\", \"center\");\r\n // Create a template container and list for legend items\r\n var itemContainer = new Container();\r\n itemContainer.applyOnClones = true;\r\n itemContainer.padding(8, 0, 8, 0);\r\n itemContainer.margin(0, 10, 0, 10);\r\n itemContainer.layout = \"horizontal\";\r\n itemContainer.clickable = true;\r\n itemContainer.focusable = true;\r\n itemContainer.role = \"switch\";\r\n itemContainer.togglable = true;\r\n itemContainer.cursorOverStyle = MouseCursorStyle.pointer;\r\n itemContainer.background.fillOpacity = 0; // creates hit area\r\n // Create container list using item template we just created\r\n _this.itemContainers = new ListTemplate(itemContainer);\r\n _this._disposers.push(new ListDisposer(_this.itemContainers));\r\n _this._disposers.push(_this.itemContainers.template);\r\n // Set up global keyboard events for toggling elements\r\n _this._disposers.push(getInteraction().body.events.on(\"keyup\", function (ev) {\r\n if (keyboard.isKey(ev.event, \"enter\") && _this.focusedItem) {\r\n var focusedItem = _this.focusedItem;\r\n var target = focusedItem.itemContainer;\r\n if (target.togglable) {\r\n _this.toggleDataItem(focusedItem);\r\n }\r\n else if (target.clickable && target.events.isEnabled(\"hit\")) {\r\n target.dispatchImmediately(\"hit\", { event: ev });\r\n // We need this here because \"hit\" event resets `this.focusedItem`\r\n // And we need it here\r\n _this.focusedItem = focusedItem;\r\n }\r\n }\r\n }, _this));\r\n var interfaceColors = new InterfaceColorSet();\r\n // Create a template container and list for the a marker\r\n var marker = new Container();\r\n marker.width = 23;\r\n marker.height = 23;\r\n marker.interactionsEnabled = false;\r\n marker.applyOnClones = true;\r\n marker.setStateOnChildren = true;\r\n marker.background.fillOpacity = 0;\r\n marker.background.strokeOpacity = 0;\r\n marker.propertyFields.fill = \"fill\";\r\n marker.valign = \"middle\";\r\n var disabledColor = interfaceColors.getFor(\"disabledBackground\");\r\n marker.events.on(\"childadded\", function (event) {\r\n var child = event.newValue;\r\n var activeState = child.states.create(\"active\");\r\n activeState.properties.stroke = disabledColor;\r\n activeState.properties.fill = disabledColor;\r\n });\r\n _this.markers = new ListTemplate(marker);\r\n _this._disposers.push(new ListDisposer(_this.markers));\r\n _this._disposers.push(_this.markers.template);\r\n // Create a legend background element\r\n var rectangle = marker.createChild(RoundedRectangle);\r\n rectangle.width = percent(100);\r\n rectangle.height = percent(100);\r\n rectangle.applyOnClones = true;\r\n rectangle.propertyFields.fill = \"fill\"; //othrwise old edge doesn't like as the same pattern is set both on parent and child https://codepen.io/team/amcharts/pen/72d7a98f3fb811d3118795220ff63182\r\n rectangle.strokeOpacity = 0;\r\n // Create a template container and list for item labels\r\n var label = new Label();\r\n label.text = \"{name}\";\r\n label.margin(0, 5, 0, 5);\r\n label.valign = \"middle\";\r\n label.applyOnClones = true;\r\n label.states.create(\"active\").properties.fill = interfaceColors.getFor(\"disabledBackground\");\r\n _this.labels = new ListTemplate(label);\r\n _this._disposers.push(new ListDisposer(_this.labels));\r\n _this._disposers.push(_this.labels.template);\r\n label.interactionsEnabled = false;\r\n label.truncate = true;\r\n label.fullWords = false;\r\n // Create a template container and list for item value labels\r\n var valueLabel = new Label();\r\n valueLabel.margin(0, 5, 0, 0);\r\n valueLabel.valign = \"middle\";\r\n valueLabel.width = 50; // to avoid rearranging legend entries when value changes.\r\n valueLabel.align = \"right\";\r\n valueLabel.textAlign = \"end\";\r\n valueLabel.applyOnClones = true;\r\n valueLabel.states.create(\"active\").properties.fill = interfaceColors.getFor(\"disabledBackground\");\r\n valueLabel.interactionsEnabled = false;\r\n _this.valueLabels = new ListTemplate(valueLabel);\r\n _this._disposers.push(new ListDisposer(_this.valueLabels));\r\n _this._disposers.push(_this.valueLabels.template);\r\n _this.position = \"bottom\"; // don't use setPropertyValue here!\r\n // Create a state for disabled legend items\r\n itemContainer.states.create(\"active\");\r\n itemContainer.setStateOnChildren = true;\r\n // Apply accessibility settings\r\n _this.role = \"group\";\r\n _this.events.on(\"layoutvalidated\", _this.handleScrollbar, _this, false);\r\n _this.events.on(\"parentset\", function () {\r\n var parent = _this.parent;\r\n if (parent) {\r\n _this._disposers.push(parent.events.on(\"maxsizechanged\", function () {\r\n if (_this.scrollable) {\r\n _this.setTimeout(function () {\r\n _this.updateMasks();\r\n _this.handleScrollbar();\r\n _this._handleWheelReal(1);\r\n }, 100);\r\n }\r\n }));\r\n }\r\n });\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Sets defaults that instantiate some objects that rely on parent, so they\r\n * cannot be set in constructor.\r\n */\r\n Legend.prototype.applyInternalDefaults = function () {\r\n _super.prototype.applyInternalDefaults.call(this);\r\n if (!$type.hasValue(this.readerTitle)) {\r\n this.readerTitle = this.language.translate(\"Legend\");\r\n }\r\n };\r\n /**\r\n * Returns a new/empty DataItem of the type appropriate for this object.\r\n *\r\n * @see {@link DataItem}\r\n * @return Data Item\r\n */\r\n Legend.prototype.createDataItem = function () {\r\n return new LegendDataItem();\r\n };\r\n /**\r\n * [validateDataElements description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n */\r\n Legend.prototype.validateDataElements = function () {\r\n if (this.scrollbar) {\r\n this.scrollbar.start = 0;\r\n this.scrollbar.end = 1;\r\n }\r\n _super.prototype.validateDataElements.call(this);\r\n };\r\n /**\r\n * [validateDataElement description]\r\n *\r\n * @ignore Exclude from docs\r\n * @param dataItem Data item\r\n * @todo Description\r\n * @todo Figure out how to update appearance of legend item without losing focus\r\n * @todo Update legend marker appearance as apperance of related series changes\r\n */\r\n Legend.prototype.validateDataElement = function (dataItem) {\r\n _super.prototype.validateDataElement.call(this, dataItem);\r\n // Get data item (legend item's) container\r\n var container = dataItem.itemContainer;\r\n var marker = dataItem.marker;\r\n $utils.used(dataItem.label);\r\n var valueLabel = dataItem.valueLabel;\r\n // Set parent and update current state\r\n container.readerChecked = dataItem.dataContext.visible;\r\n // Tell series its legend data item\r\n dataItem.dataContext.legendDataItem = dataItem;\r\n var tempMaxWidth = dataItem.label.maxWidth;\r\n if (!(dataItem.label.width instanceof Percent)) {\r\n dataItem.label.width = undefined;\r\n }\r\n if (tempMaxWidth > 0) {\r\n dataItem.label.maxWidth = tempMaxWidth;\r\n }\r\n if (valueLabel.align == \"right\") {\r\n valueLabel.width = undefined;\r\n }\r\n var legendSettings = dataItem.dataContext.legendSettings;\r\n // If we are not using default markers, create a unique legend marker based\r\n // on the data item type\r\n var dataContext = dataItem.dataContext;\r\n if (dataContext.createLegendMarker && (!this.useDefaultMarker || !(dataContext instanceof Sprite))) {\r\n if (!dataItem.childrenCreated) {\r\n dataContext.createLegendMarker(marker);\r\n dataItem.childrenCreated = true;\r\n }\r\n }\r\n else {\r\n this.markers.template.propertyFields.fill = undefined;\r\n }\r\n if (dataContext.updateLegendValue) {\r\n dataContext.updateLegendValue(); // this solves issue with external legend, as legend is created after chart updates legend values\r\n }\r\n if (dataContext.component && dataContext.component.updateLegendValue) {\r\n dataContext.component.updateLegendValue(dataContext);\r\n }\r\n if (valueLabel.invalid) {\r\n valueLabel.validate();\r\n }\r\n if (valueLabel.text == \"\" || valueLabel.text == undefined) {\r\n valueLabel.__disabled = true;\r\n }\r\n else {\r\n valueLabel.__disabled = false;\r\n }\r\n if (legendSettings && (legendSettings.itemValueText != undefined || legendSettings.valueText != undefined)) {\r\n valueLabel.__disabled = false;\r\n }\r\n var visible = dataItem.dataContext.visible;\r\n if (visible === undefined) {\r\n visible = true;\r\n }\r\n visible = $type.toBoolean(visible);\r\n dataItem.dataContext.visible = visible;\r\n container.events.disableType(\"toggled\");\r\n container.isActive = !visible;\r\n if (container.isActive) {\r\n container.setState(\"active\", 0);\r\n }\r\n else {\r\n container.setState(\"default\", 0);\r\n }\r\n container.events.enableType(\"toggled\");\r\n };\r\n Legend.prototype.afterDraw = function () {\r\n var _this = this;\r\n var maxWidth = this.getPropertyValue(\"maxWidth\");\r\n var maxLabelWidth = 0;\r\n this.labels.each(function (label) {\r\n if (label.invalid) {\r\n label.maxWidth = undefined;\r\n label.validate();\r\n }\r\n if (label.measuredWidth + label.pixelMarginLeft + label.pixelMarginRight > maxLabelWidth) {\r\n maxLabelWidth = label.measuredWidth + label.pixelMarginLeft + label.pixelMarginRight;\r\n }\r\n });\r\n var maxValueLabelWidth = 0;\r\n this.valueLabels.each(function (label) {\r\n if (label.invalid) {\r\n label.validate();\r\n }\r\n if (label.measuredWidth + label.pixelMarginLeft + label.pixelMarginRight > maxValueLabelWidth) {\r\n maxValueLabelWidth = label.measuredWidth + label.pixelMarginLeft + label.pixelMarginRight;\r\n }\r\n });\r\n var maxMarkerWidth = 0;\r\n this.markers.each(function (marker) {\r\n if (marker.invalid) {\r\n marker.validate();\r\n }\r\n if (marker.measuredWidth + marker.pixelMarginLeft + marker.pixelMarginRight > maxMarkerWidth) {\r\n maxMarkerWidth = marker.measuredWidth + marker.pixelMarginLeft + marker.pixelMarginRight;\r\n }\r\n });\r\n var itemContainer = this.itemContainers.template;\r\n var margin = itemContainer.pixelMarginRight + itemContainer.pixelMarginLeft;\r\n var maxAdjustedLabelWidth;\r\n var trueMaxWidth = maxLabelWidth + maxValueLabelWidth + maxMarkerWidth;\r\n if (!$type.isNumber(maxWidth)) {\r\n maxAdjustedLabelWidth = maxLabelWidth;\r\n }\r\n else {\r\n maxWidth = maxWidth - margin;\r\n if (maxWidth > trueMaxWidth) {\r\n maxWidth = trueMaxWidth;\r\n }\r\n maxAdjustedLabelWidth = maxWidth - maxMarkerWidth - maxValueLabelWidth;\r\n }\r\n this.labels.each(function (label) {\r\n if (_this.valueLabels.template.align == \"right\" || label.measuredWidth > maxAdjustedLabelWidth) {\r\n if (!(label.width instanceof Percent)) {\r\n label.width = Math.min(label.maxWidth, maxAdjustedLabelWidth - label.pixelMarginLeft - label.pixelMarginRight);\r\n label.maxWidth = label.width;\r\n }\r\n }\r\n });\r\n if (this.valueLabels.template.align == \"right\") {\r\n this.valueLabels.each(function (valueLabel) {\r\n valueLabel.width = maxValueLabelWidth - valueLabel.pixelMarginRight - valueLabel.pixelMarginLeft;\r\n });\r\n }\r\n _super.prototype.afterDraw.call(this);\r\n };\r\n Legend.prototype.handleScrollbar = function () {\r\n var scrollbar = this.scrollbar;\r\n if (this.scrollable && scrollbar) {\r\n var measuredHeight = this.maxHeight;\r\n scrollbar.height = measuredHeight;\r\n scrollbar.x = this.measuredWidth - scrollbar.pixelWidth - scrollbar.pixelMarginLeft;\r\n if (this.contentHeight > measuredHeight) {\r\n scrollbar.visible = true;\r\n scrollbar.thumb.height = scrollbar.height * measuredHeight / this.contentHeight;\r\n this.paddingRight = scrollbar.pixelWidth + scrollbar.pixelMarginLeft + scrollbar.pixelMarginRight;\r\n }\r\n else {\r\n scrollbar.thumb.height = scrollbar.height * measuredHeight / this.contentHeight;\r\n this.paddingRight = scrollbar.pixelWidth + scrollbar.pixelMarginLeft + scrollbar.pixelMarginRight;\r\n scrollbar.visible = false;\r\n scrollbar.start = 0;\r\n scrollbar.end = 1;\r\n }\r\n scrollbar.handleThumbPosition();\r\n this.updateMasks();\r\n }\r\n };\r\n Object.defineProperty(Legend.prototype, \"position\", {\r\n /**\r\n * @return Position\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"position\");\r\n },\r\n /**\r\n * Position of the legend.\r\n *\r\n * Options: \"left\", \"right\", \"top\", \"bottom\" (default), or \"absolute\".\r\n *\r\n * IMPORTANT: [[MapChart]] will ignore this setting, as it is using different\r\n * layout structure than other charts.\r\n *\r\n * To position legend in [[MapChart]] set legend's `align` (`\"left\"` or\r\n * `\"right\"`) and `valign` (`\"top\"` or `\"bottom\"`) properties instead.\r\n *\r\n * @default \"bottom\"\r\n * @param value Position\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"position\", value)) {\r\n if (value == \"left\" || value == \"right\") {\r\n this.margin(10, 5, 10, 10);\r\n this.valign = \"middle\";\r\n this.contentAlign = \"none\";\r\n this.valueLabels.template.align = \"right\";\r\n if (!$type.isNumber(this.maxColumns)) {\r\n this.maxColumns = 1;\r\n }\r\n this.width = undefined;\r\n this.maxWidth = 220;\r\n }\r\n else {\r\n this.maxColumns = undefined;\r\n this.width = percent(100);\r\n this.valueLabels.template.align = \"left\";\r\n }\r\n this.invalidate();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Legend.prototype, \"useDefaultMarker\", {\r\n /**\r\n * @return Use default marker?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"useDefaultMarker\");\r\n },\r\n /**\r\n * Should legend try to mirror the look of the related item when building\r\n * the marker for legend item?\r\n *\r\n * If set to `false` it will try to make the marker look like its related\r\n * item.\r\n *\r\n * E.g. if an item is for a Line Series, it will display a line of the\r\n * same thickness, color, and will use the same bullets if series have them.\r\n *\r\n * If set to `true`, all markers will be shown as squares, regardless of te\r\n * series type.\r\n *\r\n * @default false\r\n * @param value Use default marker?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"useDefaultMarker\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Legend.prototype, \"scrollable\", {\r\n /**\r\n * @return Legend Scrollable?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"scrollable\");\r\n },\r\n /**\r\n * If set to `true` the Legend will display a scrollbar if its contents do\r\n * not fit into its `maxHeight`.\r\n *\r\n * Please note that `maxHeight` is automatically set for Legend when its\r\n * `position` is set to `\"left\"` or `\"right\"`.\r\n *\r\n * @default false\r\n * @since 4.8.0\r\n * @param value Legend Scrollable?\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"scrollable\", value, true)) {\r\n if (value) {\r\n var scrollbar = this.createChild(Scrollbar);\r\n this.scrollbar = scrollbar;\r\n scrollbar.isMeasured = false;\r\n scrollbar.orientation = \"vertical\";\r\n scrollbar.endGrip.__disabled = true;\r\n scrollbar.startGrip.__disabled = true;\r\n scrollbar.visible = false;\r\n scrollbar.marginLeft = 5;\r\n this._mouseWheelDisposer = this.events.on(\"wheel\", this.handleWheel, this, false);\r\n this._disposers.push(this._mouseWheelDisposer);\r\n this._disposers.push(scrollbar.events.on(\"rangechanged\", this.updateMasks, this, false));\r\n }\r\n else {\r\n if (this._mouseWheelDisposer) {\r\n this._mouseWheelDisposer.dispose();\r\n if (this.scrollbar) {\r\n this.scrollbar.dispose();\r\n this.scrollbar = undefined;\r\n }\r\n }\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Handles mouse wheel scrolling of legend.\r\n *\r\n * @param event Event\r\n */\r\n Legend.prototype.handleWheel = function (event) {\r\n this._handleWheelReal(event.shift.y);\r\n };\r\n Legend.prototype._handleWheelReal = function (shift) {\r\n var scrollbar = this.scrollbar;\r\n if (scrollbar) {\r\n var ds = (shift / 1000 * this.measuredHeight / this.contentHeight);\r\n var delta = scrollbar.end - scrollbar.start;\r\n if (shift > 0) {\r\n scrollbar.start = $math.max(0, scrollbar.start - ds);\r\n scrollbar.end = scrollbar.start + delta;\r\n }\r\n else {\r\n scrollbar.end = $math.min(1, scrollbar.end - ds);\r\n scrollbar.start = scrollbar.end - delta;\r\n }\r\n }\r\n };\r\n /**\r\n * @ignore\r\n */\r\n Legend.prototype.updateMasks = function () {\r\n var _this = this;\r\n if (this.scrollbar) {\r\n this.itemContainers.each(function (itemContainer) {\r\n itemContainer.dy = -_this.scrollbar.thumb.pixelY * _this.contentHeight / _this.maxHeight;\r\n itemContainer.maskRectangle = { x: 0, y: -itemContainer.dy, width: _this.measuredWidth, height: _this.maxHeight };\r\n });\r\n }\r\n this.invalidatePosition();\r\n };\r\n /**\r\n * Toggles a legend item.\r\n *\r\n * @ignore Exclude from docs\r\n * @param item Legend item\r\n * @todo Maybe do it with togglable instead\r\n */\r\n Legend.prototype.toggleDataItem = function (item) {\r\n var dataContext = item.dataContext;\r\n if (!dataContext.visible || dataContext.isHiding || (dataContext instanceof Sprite && dataContext.isHidden)) {\r\n item.color = item.colorOrig;\r\n dataContext.appeared = true;\r\n item.itemContainer.isActive = false;\r\n if (dataContext.hidden === true) {\r\n dataContext.hidden = false;\r\n }\r\n if (dataContext.show) {\r\n dataContext.show();\r\n }\r\n else {\r\n dataContext.visible = true;\r\n }\r\n this.svgContainer.readerAlert(this.language.translate(\"%1 shown\", this.language.locale, item.label.readerTitle));\r\n }\r\n else {\r\n item.itemContainer.isActive = true;\r\n dataContext.appeared = true;\r\n if (dataContext.hide) {\r\n dataContext.hide();\r\n }\r\n else {\r\n dataContext.visible = false;\r\n }\r\n this.svgContainer.readerAlert(this.language.translate(\"%1 hidden\", this.language.locale, item.label.readerTitle));\r\n item.color = new InterfaceColorSet().getFor(\"disabledBackground\");\r\n }\r\n };\r\n Object.defineProperty(Legend.prototype, \"preloader\", {\r\n /**\r\n * Override preloader method so that legend does not accidentally show its\r\n * own preloader.\r\n *\r\n * @ignore Exclude from docs\r\n * @return Always `undefined`\r\n */\r\n get: function () {\r\n return;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * [handleDataItemPropertyChange description]\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Legend.prototype.handleDataItemPropertyChange = function (dataItem, name) {\r\n dataItem.valueLabel.invalidate();\r\n dataItem.label.invalidate();\r\n };\r\n return Legend;\r\n}(Component));\r\nexport { Legend };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Legend\"] = Legend;\r\n/**\r\n * Add default responsive rules\r\n */\r\n/**\r\n * Move legend to below the chart if chart is narrow\r\n */\r\ndefaultRules.push({\r\n relevant: ResponsiveBreakpoints.widthXS,\r\n state: function (target, stateId) {\r\n if (target instanceof Legend && (target.position == \"left\" || target.position == \"right\")) {\r\n var state = target.states.create(stateId);\r\n state.properties.position = \"bottom\";\r\n return state;\r\n }\r\n return null;\r\n }\r\n});\r\n/**\r\n * Move legend to the right if chart is very short\r\n */\r\ndefaultRules.push({\r\n relevant: ResponsiveBreakpoints.heightXS,\r\n state: function (target, stateId) {\r\n if (target instanceof Legend && (target.position == \"top\" || target.position == \"bottom\")) {\r\n var state = target.states.create(stateId);\r\n state.properties.position = \"right\";\r\n return state;\r\n }\r\n return null;\r\n }\r\n});\r\n/**\r\n * Disable legend altogether on small charts\r\n */\r\ndefaultRules.push({\r\n relevant: ResponsiveBreakpoints.isXS,\r\n state: function (target, stateId) {\r\n if (target instanceof Legend) {\r\n var state = target.states.create(stateId);\r\n state.properties.disabled = true;\r\n return state;\r\n }\r\n return null;\r\n }\r\n});\r\n//# sourceMappingURL=Legend.js.map","/**\r\n * Axis break module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../../core/Container\";\r\nimport { MutableValueDisposer } from \"../../core/utils/Disposer\";\r\nimport { WavedLine } from \"../../core/elements/WavedLine\";\r\nimport { List } from \"../../core/utils/List\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { color } from \"../../core/utils/Color\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Base class to define \"breaks\" on axes.\r\n *\r\n * @see {@link IAxisBreakEvents} for a list of available events\r\n * @see {@link IAxisBreakAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar AxisBreak = /** @class */ (function (_super) {\r\n __extends(AxisBreak, _super);\r\n /**\r\n * Constructor\r\n */\r\n function AxisBreak() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n /**\r\n * Reference to parent Axis.\r\n */\r\n _this._axis = new MutableValueDisposer();\r\n /**\r\n * A list of axis data items which fall within this break.\r\n */\r\n _this.dataItems = new List();\r\n _this.className = \"AxisBreak\";\r\n // Set defaults\r\n _this.breakSize = 0.01;\r\n _this.marginLeft = -5;\r\n _this.marginRight = -5;\r\n _this.marginTop = -5;\r\n _this.marginBottom = -5;\r\n var interfaceColors = new InterfaceColorSet();\r\n // Create elements\r\n // (these won't be used actually, just for setting properties)\r\n var fillShape = new WavedLine();\r\n fillShape.fill = interfaceColors.getFor(\"background\");\r\n fillShape.stroke = color();\r\n fillShape.fillOpacity = 0.9;\r\n fillShape.zIndex = 0;\r\n _this._fillShape = fillShape;\r\n var startLine = new WavedLine();\r\n startLine.fill = color();\r\n startLine.stroke = interfaceColors.getFor(\"grid\");\r\n startLine.strokeOpacity = 0.3;\r\n startLine.zIndex = 1;\r\n _this._startLine = startLine;\r\n var endLine = new WavedLine();\r\n endLine.fill = color();\r\n endLine.stroke = color(\"#000000\"); // interfaceColors.getFor(\"grid\");\r\n endLine.strokeOpacity = 0.3;\r\n endLine.zIndex = 2;\r\n _this._endLine = endLine;\r\n _this._disposers.push(_this._axis);\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n AxisBreak.prototype.dispose = function () {\r\n _super.prototype.dispose.call(this);\r\n if (this._fillShape) {\r\n this._fillShape.dispose();\r\n }\r\n if (this._startLine) {\r\n this._startLine.dispose();\r\n }\r\n if (this._endLine) {\r\n this._endLine.dispose();\r\n }\r\n };\r\n Object.defineProperty(AxisBreak.prototype, \"startLine\", {\r\n /**\r\n * @return Element\r\n */\r\n get: function () {\r\n return this._startLine;\r\n },\r\n /**\r\n * An element used for the starting line of the break.\r\n *\r\n * @param sprite Element\r\n */\r\n set: function (sprite) {\r\n if (this._startLine) {\r\n this._startLine.dispose();\r\n }\r\n this._startLine = sprite;\r\n this.addBreakSprite(sprite);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisBreak.prototype, \"endLine\", {\r\n /**\r\n * @return Element\r\n */\r\n get: function () {\r\n return this._endLine;\r\n },\r\n /**\r\n * An element used for the end line of the break.\r\n *\r\n * @param sprite Element\r\n */\r\n set: function (sprite) {\r\n if (this._endLine) {\r\n this._endLine.dispose();\r\n }\r\n this._endLine = sprite;\r\n this.addBreakSprite(sprite);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisBreak.prototype, \"fillShape\", {\r\n /**\r\n * @return Element\r\n */\r\n get: function () {\r\n return this._fillShape;\r\n },\r\n /**\r\n * An element used for fill of the break.\r\n *\r\n * @param sprite Element\r\n */\r\n set: function (sprite) {\r\n if (this._fillShape) {\r\n this._fillShape.dispose();\r\n }\r\n this._fillShape = sprite;\r\n this.addBreakSprite(sprite);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Adds a break element (e.g. lines, fill) to the break, which is\r\n * [[Container]].\r\n *\r\n * @ignore Exclude from docs\r\n * @param sprite Element to add\r\n */\r\n AxisBreak.prototype.addBreakSprite = function (sprite) {\r\n sprite.parent = this;\r\n sprite.isMeasured = false;\r\n this._disposers.push(sprite);\r\n };\r\n Object.defineProperty(AxisBreak.prototype, \"axis\", {\r\n /**\r\n * @return Axis\r\n */\r\n get: function () {\r\n return this._axis.get();\r\n },\r\n /**\r\n * An Axis this Break is associated with.\r\n *\r\n * @param axis Axis\r\n */\r\n set: function (axis) {\r\n if (this._axis.get() !== axis) {\r\n this._axis.set(axis, axis.renderer.gridContainer.events.on(\"transformed\", this.invalidate, this, false));\r\n axis.renderer.createBreakSprites(this);\r\n // this can't go to copyFrom, as axis is set later\r\n var breakTemplate = axis.axisBreaks.template;\r\n this.startLine.copyFrom(breakTemplate.startLine);\r\n this.endLine.copyFrom(breakTemplate.endLine);\r\n this.fillShape.copyFrom(breakTemplate.fillShape);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisBreak.prototype, \"breakSize\", {\r\n /**\r\n * @return Relative axis break\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"breakSize\");\r\n },\r\n /**\r\n * A size of the break relative to the actual size of the scope break spans.\r\n *\r\n * For example, if `breakSize = 0.1` and unbroken scope of values it spans\r\n * would be 100 pixels, the break would be 10 pixels wide.\r\n *\r\n * 0 means the break will completely collapse and hide the values.\r\n * 1 means break would be not collapse at all, which would make it\r\n * effectively useless.\r\n *\r\n * @default 0.01\r\n * @param value Relative axis break\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"breakSize\", value)) {\r\n if (this.axis) {\r\n this.axis.invalidate();\r\n this.axis.invalidateSeries();\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisBreak.prototype, \"startPoint\", {\r\n /**\r\n * Returns pixel coordinates of axis break's start.\r\n *\r\n * @return Start point\r\n */\r\n get: function () {\r\n var renderer = this.axis.renderer;\r\n if (renderer) {\r\n return renderer.positionToPoint(this.startPosition);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisBreak.prototype, \"endPoint\", {\r\n /**\r\n * Returns pixel coordinates of axis break's end.\r\n *\r\n * @return End point\r\n */\r\n get: function () {\r\n var renderer = this.axis.renderer;\r\n if (renderer) {\r\n return renderer.positionToPoint(this.endPosition);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisBreak.prototype, \"startPosition\", {\r\n /**\r\n * Returns a relative position at which axis break starts.\r\n *\r\n * This is a calculated position, meaning it shows relative position of the\r\n * break after break is applied.\r\n *\r\n * @return Start position\r\n */\r\n get: function () {\r\n return;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisBreak.prototype, \"endPosition\", {\r\n /**\r\n * Returns a relative position at which axis break ends.\r\n *\r\n * This is a calculated position, meaning it shows relative position of the\r\n * break after break is applied.\r\n *\r\n * @return End position\r\n */\r\n get: function () {\r\n return;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Draws the axis break.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n AxisBreak.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n if (this.axis) {\r\n var renderer = this.axis.renderer;\r\n renderer.updateBreakElement(this);\r\n }\r\n };\r\n Object.defineProperty(AxisBreak.prototype, \"startValue\", {\r\n /**\r\n * @return Starting value\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"startValue\");\r\n },\r\n /**\r\n * A starting value for the break.\r\n *\r\n * @param value Starting value\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"startValue\", value)) {\r\n if (this.axis) {\r\n this.axis.invalidate();\r\n this.axis.invalidateSeries();\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisBreak.prototype, \"endValue\", {\r\n /**\r\n * @return End value\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"endValue\");\r\n },\r\n /**\r\n * An end value for the break.\r\n *\r\n * @param value End value\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"endValue\", value)) {\r\n if (this.axis) {\r\n this.axis.invalidate();\r\n this.axis.invalidateSeries();\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return AxisBreak;\r\n}(Container));\r\nexport { AxisBreak };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"AxisBreak\"] = AxisBreak;\r\n//# sourceMappingURL=AxisBreak.js.map","/**\r\n * Base class for all Axis\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Component } from \"../../core/Component\";\r\nimport { Container } from \"../../core/Container\";\r\nimport { DataItem } from \"../../core/DataItem\";\r\nimport { AxisBreak } from \"./AxisBreak\";\r\nimport { Label } from \"../../core/elements/Label\";\r\nimport { Tooltip } from \"../../core/elements/Tooltip\";\r\nimport { SortedListTemplate } from \"../../core/utils/SortedList\";\r\nimport { List, ListTemplate, ListDisposer } from \"../../core/utils/List\";\r\nimport { Disposer, MultiDisposer } from \"../../core/utils/Disposer\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport * as $iter from \"../../core/utils/Iterator\";\r\nimport * as $math from \"../../core/utils/Math\";\r\nimport * as $utils from \"../../core/utils/Utils\";\r\nimport * as $number from \"../../core/utils/Number\";\r\nimport * as $array from \"../../core/utils/Array\";\r\nimport * as $type from \"../../core/utils/Type\";\r\nimport { defaultRules, ResponsiveBreakpoints } from \"../../core/utils/Responsive\";\r\n/**\r\n * ============================================================================\r\n * DATA ITEM\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines a [[DataItem]] for [[Axis]].\r\n *\r\n * @see {@link DataItem}\r\n */\r\nvar AxisDataItem = /** @class */ (function (_super) {\r\n __extends(AxisDataItem, _super);\r\n /**\r\n * Constructor\r\n */\r\n function AxisDataItem() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"AxisDataItem\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(AxisDataItem.prototype, \"grid\", {\r\n /**\r\n * @return Grid element\r\n */\r\n get: function () {\r\n if (!this._grid) {\r\n var component_1 = this.component;\r\n if (component_1) {\r\n var template = void 0;\r\n var grid_1;\r\n if (this.isRange) {\r\n template = component_1.axisRanges.template.grid;\r\n if (template.disabled) {\r\n return;\r\n }\r\n else {\r\n grid_1 = template.clone();\r\n }\r\n }\r\n else {\r\n template = component_1.renderer.grid.template;\r\n if (template.disabled) {\r\n return;\r\n }\r\n else {\r\n grid_1 = component_1.renderer.grid.create();\r\n this._disposers.push(new Disposer(function () {\r\n component_1.renderer.grid.removeValue(grid_1);\r\n }));\r\n }\r\n }\r\n this.grid = grid_1;\r\n grid_1.shouldClone = false;\r\n this._disposers.push(grid_1);\r\n grid_1.axis = this.component;\r\n }\r\n }\r\n return this._grid;\r\n },\r\n /**\r\n * A [[Grid]] element associated with this data item.\r\n *\r\n * If there is no grid element associated with data item, a new one is\r\n * created and returned.\r\n *\r\n * @param grid Grid element\r\n */\r\n set: function (grid) {\r\n if (this._grid && this._grid != grid) {\r\n $array.remove(this.sprites, this._grid);\r\n this._grid.dataItem = undefined;\r\n }\r\n if (grid) {\r\n if (grid.dataItem && grid.dataItem != this) {\r\n $array.remove(grid.dataItem.sprites, grid);\r\n grid.dataItem.grid = undefined;\r\n }\r\n this.addSprite(grid);\r\n }\r\n this._grid = grid;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisDataItem.prototype, \"tick\", {\r\n /**\r\n * @return Tick element\r\n */\r\n get: function () {\r\n if (!this._tick) {\r\n var component_2 = this.component;\r\n if (component_2) {\r\n var template = void 0;\r\n var tick_1;\r\n if (this.isRange) {\r\n template = component_2.axisRanges.template.tick;\r\n if (template.disabled) {\r\n return;\r\n }\r\n else {\r\n tick_1 = template.clone();\r\n }\r\n }\r\n else {\r\n template = component_2.renderer.ticks.template;\r\n if (template.disabled) {\r\n return;\r\n }\r\n else {\r\n tick_1 = component_2.renderer.ticks.create();\r\n this._disposers.push(new Disposer(function () {\r\n component_2.renderer.ticks.removeValue(tick_1);\r\n }));\r\n }\r\n }\r\n this.tick = tick_1;\r\n tick_1.axis = this.component;\r\n tick_1.shouldClone = false;\r\n this._disposers.push(tick_1);\r\n }\r\n }\r\n return this._tick;\r\n },\r\n /**\r\n * An [[AxisTick]] element associated with this data item.\r\n *\r\n * If there is no tick element associated with data item, a new one is\r\n * created and returned.\r\n *\r\n * @param tick Tick element\r\n */\r\n set: function (tick) {\r\n if (this._tick && this._tick != tick) {\r\n $array.remove(this.sprites, this._tick);\r\n this._tick.dataItem = undefined;\r\n }\r\n if (tick) {\r\n if (tick.dataItem && tick.dataItem != this) {\r\n $array.remove(tick.dataItem.sprites, tick);\r\n tick.dataItem.tick = undefined;\r\n }\r\n this.addSprite(tick);\r\n }\r\n this._tick = tick;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisDataItem.prototype, \"label\", {\r\n /**\r\n * @return Label element\r\n */\r\n get: function () {\r\n if (!this._label) {\r\n var component_3 = this.component;\r\n if (component_3) {\r\n var template = void 0;\r\n var label_1;\r\n if (this.isRange) {\r\n template = component_3.axisRanges.template.label;\r\n if (template.disabled) {\r\n return;\r\n }\r\n else {\r\n label_1 = template.clone();\r\n }\r\n }\r\n else {\r\n template = component_3.renderer.labels.template;\r\n if (template.disabled) {\r\n return;\r\n }\r\n else {\r\n label_1 = component_3.renderer.labels.create();\r\n this._disposers.push(new Disposer(function () {\r\n component_3.renderer.labels.removeValue(label_1);\r\n }));\r\n }\r\n }\r\n this._disposers.push(label_1);\r\n this.label = label_1;\r\n label_1.shouldClone = false;\r\n label_1.axis = this.component;\r\n label_1.virtualParent = component_3;\r\n }\r\n }\r\n return this._label;\r\n },\r\n /**\r\n * An [[AxisLabel]] element associated with this data item.\r\n *\r\n * If there is no label element associated with data item, a new one is\r\n * created and returned.\r\n *\r\n * @param label Label element\r\n */\r\n set: function (label) {\r\n if (this._label && this._label != label) {\r\n $array.remove(this.sprites, this._label);\r\n this._label.dataItem = undefined;\r\n }\r\n if (label) {\r\n if (label.dataItem && label.dataItem != this) {\r\n $array.remove(label.dataItem.sprites, label);\r\n label.dataItem.label = undefined;\r\n }\r\n this.addSprite(label);\r\n }\r\n this._label = label;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisDataItem.prototype, \"axisFill\", {\r\n /**\r\n * @return Label element\r\n */\r\n get: function () {\r\n if (!this._axisFill) {\r\n var component_4 = this.component;\r\n if (component_4) {\r\n var template = void 0;\r\n var axisFill_1;\r\n if (this.isRange) {\r\n template = component_4.axisRanges.template.axisFill;\r\n if (!this.isTemplate && template.disabled) {\r\n return;\r\n }\r\n else {\r\n axisFill_1 = template.clone();\r\n }\r\n }\r\n else {\r\n template = component_4.renderer.axisFills.template;\r\n if (template.disabled) {\r\n return;\r\n }\r\n else {\r\n axisFill_1 = component_4.renderer.axisFills.create();\r\n this._disposers.push(new Disposer(function () {\r\n component_4.renderer.axisFills.removeValue(axisFill_1);\r\n }));\r\n }\r\n }\r\n this.axisFill = axisFill_1;\r\n axisFill_1.shouldClone = false;\r\n this._disposers.push(axisFill_1);\r\n }\r\n }\r\n return this._axisFill;\r\n },\r\n /**\r\n * An [[AxisFill]] associated element with this data item.\r\n *\r\n * If there is no fill element associated with data item, a new one is\r\n * created and returned.\r\n *\r\n * @param label Label element\r\n */\r\n set: function (axisFill) {\r\n if (this._axisFill && this._axisFill != axisFill) {\r\n $array.remove(this.sprites, this._axisFill);\r\n this._axisFill.dataItem = undefined;\r\n }\r\n if (axisFill) {\r\n if (axisFill.dataItem && axisFill.dataItem != this) {\r\n $array.remove(axisFill.dataItem.sprites, axisFill);\r\n axisFill.dataItem.axisFill = undefined;\r\n }\r\n axisFill.axis = this.component;\r\n this.addSprite(axisFill);\r\n }\r\n this._axisFill = axisFill;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisDataItem.prototype, \"text\", {\r\n /**\r\n * @return Text label\r\n */\r\n get: function () {\r\n return this._text;\r\n },\r\n /**\r\n * Text to be used as data item's label.\r\n *\r\n * @param text Text label\r\n */\r\n set: function (text) {\r\n this._text = text;\r\n if (this._label) { // do not use getter, it will create unwanted instances!\r\n this._label.text = text;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisDataItem.prototype, \"mask\", {\r\n /**\r\n * Data item's mask.\r\n *\r\n * @return Mask\r\n */\r\n get: function () {\r\n return this._mask;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisDataItem.prototype, \"contents\", {\r\n /**\r\n * Returns a [[Container]] to place all visual elements, related to data item\r\n * in.\r\n *\r\n * If there is no Container, a new one is created.\r\n *\r\n * @return Contents container\r\n */\r\n get: function () {\r\n if (!this._contents) {\r\n var contents = new Container();\r\n this.addSprite(contents);\r\n contents.isMeasured = false;\r\n this._contents = contents;\r\n var component = this.component;\r\n if (component) {\r\n var mask = component.renderer.createFill(this.component);\r\n mask.disabled = false;\r\n mask.axis = component;\r\n this.addSprite(mask);\r\n this._mask = mask;\r\n contents.mask = mask;\r\n }\r\n }\r\n return this._contents;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisDataItem.prototype, \"axisBreak\", {\r\n /**\r\n * @return Axis break\r\n */\r\n get: function () {\r\n return this._axisBreak;\r\n },\r\n /**\r\n * An [[AxisBreak]] this data item falls within.\r\n *\r\n * @param axisBreak Axis break\r\n */\r\n set: function (axisBreak) {\r\n if (this._axisBreak) {\r\n this._axisBreak.dataItems.removeValue(this);\r\n }\r\n if (axisBreak) {\r\n axisBreak.dataItems.push(this);\r\n }\r\n this._axisBreak = axisBreak;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Re-draws the element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n AxisDataItem.prototype.validate = function () {\r\n if (this.component) {\r\n this.component.validateDataElement(this);\r\n }\r\n };\r\n /**\r\n * Appends data item's elements to the parent [[Container]].\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n AxisDataItem.prototype.appendChildren = function () {\r\n if (this.component) {\r\n this.component.appendDataItem(this);\r\n }\r\n };\r\n /**\r\n * Checks if data item has particular property set.\r\n *\r\n * @param prop Property name\r\n * @return Property set?\r\n */\r\n AxisDataItem.prototype.hasProperty = function (prop) {\r\n return prop == \"component\" ? true : _super.prototype.hasProperty.call(this, prop);\r\n };\r\n /**\r\n * Copies all parameters from another [[AxisDataItem]].\r\n *\r\n * @param source Source AxisDataItem\r\n */\r\n AxisDataItem.prototype.copyFrom = function (source) {\r\n _super.prototype.copyFrom.call(this, source);\r\n this.text = source.text;\r\n if (source.bullet) {\r\n this.bullet = source.bullet.clone();\r\n }\r\n this.minPosition = source.minPosition;\r\n this.maxPosition = source.maxPosition;\r\n };\r\n /**\r\n * Sets visibility of the Data Item.\r\n *\r\n * @param value Data Item\r\n */\r\n AxisDataItem.prototype.setVisibility = function (value, noChangeValues) {\r\n _super.prototype.setVisibility.call(this, value, noChangeValues);\r\n if (this._contents) {\r\n this._contents.visible = value;\r\n }\r\n };\r\n Object.defineProperty(AxisDataItem.prototype, \"bullet\", {\r\n /**\r\n * @return Bullet\r\n */\r\n get: function () {\r\n return this._bullet;\r\n },\r\n /**\r\n * Set it to an instance of any [[Sprite]]. It will be displayed as an axis\r\n * bullet in the middle of the cell, or specific value.\r\n *\r\n * If you need position bullet relatively to the cell, use [[AxisBullet]]\r\n * instead. It has a `location` property which can be used to indicate\r\n * precise relative location within cell/range.\r\n *\r\n * Also, [[AxisBullet]] is a [[Container]] so you can push any other element\r\n * into it.\r\n *\r\n * NOTE: `location` is relative to the parent axis range's scope, i.e.\r\n * between its `date` and `endDate` for [[DateAxis]], or `value`/`endValue`\r\n * ([[ValueAxis]]), or `category`/`endCategory` ([[categoryAxis]]).\r\n *\r\n * ```TypeScript\r\n * let range = dateAxis.axisRanges.create();\r\n * range.date = new Date(2018, 0, 5);\r\n *\r\n * let flag = new am4plugins_bullets.FlagBullet();\r\n * flag.label.text = \"Hello\";\r\n *\r\n * range.bullet = flag;\r\n * ```\r\n * ```JavaScript\r\n * var range = dateAxis.axisRanges.create();\r\n * range.date = new Date(2018, 0, 5);\r\n *\r\n * var flag = new am4plugins_bullets.FlagBullet();\r\n * flag.label.text = \"Hello\";\r\n *\r\n * range.bullet = flag;\r\n * ```\r\n * ```JSON\r\n * {\r\n * // ...\r\n * \"xAxes\": [{\r\n * \"type\": \"DateAxis\",\r\n * // ...\r\n * \"axisRanges\": [{\r\n * \"date\": new Date(2018, 0, 5),\r\n * \"bullet: {\r\n * \"type\": \"FlagBullet\",\r\n * \"label\": {\r\n * \"text\": \"Hello\"\r\n * }\r\n * }\r\n * }]\r\n * }]\r\n * }\r\n * ```\r\n *\r\n * @since 4.5.9\r\n * @param value Bullet\r\n */\r\n set: function (value) {\r\n if (this._bullet && this._bullet != value) {\r\n $array.remove(this.sprites, this._bullet);\r\n this._bullet.dataItem = undefined;\r\n }\r\n this._bullet = value;\r\n if (value) {\r\n this.addSprite(value);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return AxisDataItem;\r\n}(DataItem));\r\nexport { AxisDataItem };\r\n/**\r\n * ============================================================================\r\n * REQUISITES\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines named positions for data item's location within [[Axis]].\r\n */\r\nexport var AxisItemLocation;\r\n(function (AxisItemLocation) {\r\n AxisItemLocation[AxisItemLocation[\"Start\"] = 0] = \"Start\";\r\n AxisItemLocation[AxisItemLocation[\"Middle\"] = 0.5] = \"Middle\";\r\n AxisItemLocation[AxisItemLocation[\"End\"] = 1] = \"End\";\r\n})(AxisItemLocation || (AxisItemLocation = {}));\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A base class for all Axis elements.\r\n *\r\n * @see {@link IAxisEvents} for a list of available Events\r\n * @see {@link IAxisAdapters} for a list of available Adapters\r\n */\r\nvar Axis = /** @class */ (function (_super) {\r\n __extends(Axis, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Axis() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n /**\r\n * Number of Grid elements on the axis.\r\n */\r\n _this._gridCount = 10;\r\n /**\r\n * A list of [[XYSeries]] that are using this Axis.\r\n */\r\n _this._series = new List();\r\n /**\r\n * Specifies if axis should be automatically disposed when removing from\r\n * chart's axis list.\r\n *\r\n * @default true\r\n */\r\n _this.autoDispose = true;\r\n /**\r\n * @ignore\r\n */\r\n _this._axisItemCount = 0;\r\n if (_this.constructor === Axis) {\r\n throw new Error(\"'Axis' cannot be instantiated directly. Please use a specific axis type.\");\r\n }\r\n _this.hideTooltipWhileZooming = true;\r\n _this.minWidth = 0.0001;\r\n _this.minHeight = 0.0001;\r\n _this.className = \"Axis\";\r\n _this.shouldClone = false;\r\n _this.setPropertyValue(\"cursorTooltipEnabled\", true);\r\n _this.toggleZoomOutButton = true;\r\n _this.zoomable = true;\r\n var interfaceColors = new InterfaceColorSet();\r\n // Create title\r\n _this.title = new Label();\r\n _this.title.shouldClone = false;\r\n _this._disposers.push(_this.title);\r\n _this.setPropertyValue(\"startLocation\", 0);\r\n _this.setPropertyValue(\"endLocation\", 1);\r\n // Data item iterator\r\n _this._dataItemsIterator = new $iter.ListIterator(_this.dataItems, function () { return _this.dataItems.create(); });\r\n _this._dataItemsIterator.createNewItems = true;\r\n // Create tooltip\r\n var tooltip = new Tooltip();\r\n _this._disposers.push(tooltip);\r\n tooltip.label.padding(5, 10, 5, 10);\r\n tooltip.background.pointerLength = 5;\r\n tooltip.fitPointerToBounds = true;\r\n tooltip.background.filters.clear();\r\n // Set virtual parentfor the tooltip so that it can properly inheirt\r\n // formatters from the axis.\r\n tooltip.virtualParent = _this;\r\n // Create background element for the tooltip\r\n var background = tooltip.background;\r\n background.cornerRadius = 0;\r\n background.fill = interfaceColors.getFor(\"alternativeBackground\");\r\n background.stroke = background.fill;\r\n background.strokeWidth = 1;\r\n background.fillOpacity = 1;\r\n tooltip.label.fill = interfaceColors.getFor(\"alternativeText\");\r\n _this.tooltip = tooltip;\r\n // Accessibility\r\n _this.readerHidden = true;\r\n _this.events.on(\"rangechangestarted\", function () {\r\n _this.series.each(function (series) {\r\n if (series.hideTooltipWhileZooming) {\r\n series.tooltip.hide();\r\n series.tooltip.preventShow = true;\r\n }\r\n });\r\n if (_this.hideTooltipWhileZooming) {\r\n _this.tooltip.hide();\r\n _this.tooltip.preventShow = true;\r\n }\r\n }, undefined, false);\r\n _this.events.on(\"rangechangeended\", function () {\r\n _this.series.each(function (series) {\r\n if (series.hideTooltipWhileZooming) {\r\n series.tooltip.hide();\r\n series.tooltip.preventShow = false;\r\n }\r\n });\r\n if (_this.hideTooltipWhileZooming) {\r\n _this.tooltip.hide();\r\n _this.tooltip.preventShow = false;\r\n }\r\n }, undefined, false);\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Holds reference to a function that accepts a DataItem and its index as\r\n * parameters.\r\n *\r\n * It can either return a fill opacity for a fill, or manipulate data item\r\n * directly, to create various highlighting scenarios.\r\n *\r\n * For example, you can set it up to highlight only weekends on a\r\n * [[DateAxis]].\r\n */\r\n Axis.prototype.fillRule = function (dataItem, index) {\r\n if (!$type.isNumber(index)) {\r\n index = dataItem.index;\r\n }\r\n if (index / 2 == Math.round(index / 2)) {\r\n dataItem.axisFill.__disabled = true;\r\n dataItem.axisFill.opacity = 0;\r\n }\r\n else {\r\n dataItem.axisFill.opacity = 1;\r\n dataItem.axisFill.__disabled = false;\r\n }\r\n };\r\n /**\r\n * Returns a new/empty DataItem of the type appropriate for this object.\r\n *\r\n * @see {@link DataItem}\r\n * @return Data Item\r\n */\r\n Axis.prototype.createDataItem = function () {\r\n return new AxisDataItem();\r\n };\r\n /**\r\n * Invalidates layout.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Axis.prototype.invalidateLayout = function () {\r\n _super.prototype.invalidateLayout.call(this);\r\n // this puts series after axis in invalidation order also makes series update it's data items in case widht/height of a series is not 100%\r\n $iter.each(this.series.iterator(), function (series) {\r\n series.invalidateLayout();\r\n });\r\n };\r\n /**\r\n * Invalidates series of this axis.\r\n */\r\n Axis.prototype.invalidateSeries = function () {\r\n // this puts series after axis in invalidation order also makes series update it's data items in case widht/height of a series is not 100%\r\n $iter.each(this.series.iterator(), function (series) {\r\n series.invalidate();\r\n });\r\n };\r\n /**\r\n * Override to cancel super call for data element validation.\r\n * @ignore\r\n */\r\n Axis.prototype.validateDataElements = function () {\r\n this._axisItemCount = 0;\r\n if (this.ghostLabel) {\r\n this.renderer.updateLabelElement(this.ghostLabel, this.start, this.end);\r\n this.ghostLabel.validate();\r\n }\r\n };\r\n /**\r\n * Recalculates the number of grid items on the axis.\r\n */\r\n Axis.prototype.updateGridCount = function () {\r\n if (this.renderer) {\r\n var gridCount = this.axisLength / this.renderer.minGridDistance;\r\n if (gridCount != this._gridCount) {\r\n this._gridCount = gridCount;\r\n this.clearCache();\r\n }\r\n }\r\n };\r\n /**\r\n * Redraws the element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Axis.prototype.validateLayout = function () {\r\n this.axisFullLength = this.axisLength / (this.end - this.start);\r\n _super.prototype.validateLayout.call(this);\r\n this.updateGridCount();\r\n var renderer = this.renderer;\r\n if (renderer) {\r\n renderer.updateAxisLine();\r\n renderer.updateTooltip();\r\n renderer.updateBaseGridElement();\r\n }\r\n if (this._prevLength != this.axisLength) {\r\n this.dispatchImmediately(\"lengthchanged\");\r\n this._prevLength = this.axisLength;\r\n }\r\n };\r\n /**\r\n * Initializes Axis' renderer.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Axis.prototype.initRenderer = function () {\r\n };\r\n /**\r\n * Adds a data item to the Axis.\r\n *\r\n * @param dataItem Data item\r\n */\r\n Axis.prototype.appendDataItem = function (dataItem) {\r\n var renderer = this.renderer;\r\n var tick = dataItem.tick;\r\n if (tick) {\r\n if (tick.above) {\r\n tick.parent = renderer.bulletsContainer;\r\n }\r\n else {\r\n tick.parent = renderer.gridContainer;\r\n }\r\n }\r\n if (dataItem.label) {\r\n dataItem.label.parent = renderer;\r\n }\r\n var axisFill = dataItem.axisFill;\r\n if (axisFill) {\r\n if (axisFill.above) {\r\n axisFill.parent = renderer.bulletsContainer;\r\n }\r\n else {\r\n axisFill.parent = renderer.gridContainer;\r\n }\r\n }\r\n var grid = dataItem.grid;\r\n if (grid) {\r\n if (grid.above) {\r\n grid.parent = renderer.bulletsContainer;\r\n }\r\n else {\r\n grid.parent = renderer.gridContainer;\r\n }\r\n }\r\n if (dataItem.bullet) {\r\n dataItem.bullet.parent = renderer.bulletsContainer;\r\n }\r\n };\r\n /**\r\n * Redraws Axis' related items.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Axis.prototype.validate = function () {\r\n _super.prototype.validate.call(this);\r\n this.validateLayout();\r\n this.renderer.updateGridContainer();\r\n };\r\n /**\r\n * Redars Axis ranges.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Axis.prototype.validateAxisRanges = function () {\r\n var _this = this;\r\n $iter.each(this.axisRanges.iterator(), function (axisRange) {\r\n _this.appendDataItem(axisRange);\r\n _this.validateDataElement(axisRange);\r\n if (axisRange.grid) {\r\n axisRange.grid.validate();\r\n }\r\n if (axisRange.tick) {\r\n axisRange.tick.validate();\r\n }\r\n if (axisRange.axisFill) {\r\n axisRange.axisFill.validate();\r\n }\r\n if (axisRange.label) {\r\n axisRange.label.validate();\r\n }\r\n });\r\n };\r\n /**\r\n * Invalidates all axis breaks, so they are redrawn.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Axis.prototype.validateBreaks = function () {\r\n if (this._axisBreaks) {\r\n $iter.each(this._axisBreaks.iterator(), function (axisBreak) {\r\n axisBreak.invalidate();\r\n });\r\n }\r\n };\r\n /**\r\n * Associates an Axis break with this Axis, after it is inserted into\r\n * `axisBreaks`.\r\n *\r\n * @ignore Exclude from docs\r\n * @param event Event\r\n */\r\n Axis.prototype.processBreak = function (event) {\r\n var axisBreak = event.newValue;\r\n axisBreak.parent = this.renderer.breakContainer;\r\n axisBreak.axis = this;\r\n };\r\n /**\r\n * Registers a [[XYSeries]] element with this Axis.\r\n *\r\n * Returns a [[Disposer]] for all events, added to Series for watching\r\n * changes in Axis, and vice versa.\r\n * @ignore\r\n * @param series Series\r\n * @return Event disposer\r\n */\r\n Axis.prototype.registerSeries = function (series) {\r\n var _this = this;\r\n this.series.moveValue(series);\r\n return new MultiDisposer([\r\n new Disposer(function () {\r\n _this.series.removeValue(series);\r\n }),\r\n this.events.on(\"lengthchanged\", series.invalidate, series, false),\r\n this.events.on(\"lengthchanged\", series.createMask, series, false),\r\n this.events.on(\"startchanged\", series.invalidate, series, false),\r\n this.events.on(\"endchanged\", series.invalidate, series, false),\r\n ]);\r\n };\r\n Object.defineProperty(Axis.prototype, \"renderer\", {\r\n /**\r\n * @return Renderer\r\n */\r\n get: function () {\r\n return this._renderer;\r\n },\r\n /**\r\n * An [[AxisRenderer]] to be used to render this Axis.\r\n *\r\n * Please note that most of the settings, related to Axis' appearance are set\r\n * via its renderer. Not directly on the Axis.\r\n *\r\n * E.g.:\r\n *\r\n * ```TypeScript\r\n * axis.renderer.inside = true;\r\n * axis.renderer.minLabelPosition = 0.1;\r\n * axis.renderer.maxLabelPosition = 0.9;\r\n * ```\r\n * ```JavaScript\r\n * axis.renderer.inside = true;\r\n * axis.renderer.minLabelPosition = 0.1;\r\n * axis.renderer.maxLabelPosition = 0.9;\r\n * ```\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/axes/} for more info\r\n * @param renderer Renderer\r\n */\r\n set: function (renderer) {\r\n if (renderer != this._renderer) {\r\n this._renderer = renderer;\r\n renderer.chart = this.chart;\r\n renderer.axis = this;\r\n renderer.parent = this;\r\n this.title.parent = this; // we add title to axis and set layout in renderer to avoid one extra container, as otherwise axis container would be used for holding renderer only\r\n this.initRenderer();\r\n this._disposers.push(renderer.gridContainer.events.on(\"maxsizechanged\", this.invalidate, this, false));\r\n var ghostLabel_1 = this.renderer.labels.create();\r\n this._disposers.push(ghostLabel_1);\r\n ghostLabel_1.dataItem = this.dataItems.template.clone(); // just for the adapters not to fail\r\n ghostLabel_1.text = \"L\";\r\n ghostLabel_1.parent = this.renderer;\r\n ghostLabel_1.shouldClone = false;\r\n ghostLabel_1.fillOpacity = 0;\r\n ghostLabel_1.opacity = 0;\r\n ghostLabel_1.strokeOpacity = 0;\r\n ghostLabel_1.interactionsEnabled = false;\r\n ghostLabel_1.validate();\r\n this.ghostLabel = ghostLabel_1;\r\n this.events.on(\"beforedatavalidated\", function () {\r\n ghostLabel_1.text = \"L\";\r\n }, undefined, false);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Converts a relative position to angle. (for circular axes)\r\n *\r\n * @param position Position (0-1)\r\n * @return Angle\r\n */\r\n Axis.prototype.positionToAngle = function (position) {\r\n return this.renderer.positionToAngle(position);\r\n };\r\n /**\r\n * Converts pixel coordinates to a relative position. (0-1)\r\n *\r\n * @param point Coorinates (px)\r\n * @return Position (0-1)\r\n */\r\n Axis.prototype.pointToPosition = function (point) {\r\n return this.renderer.pointToPosition(point);\r\n };\r\n /**\r\n * Converts relative position to coordinate.\r\n *\r\n * @since 4.7.15\r\n * @param position (0-1)\r\n * @return coordinate (px)\r\n */\r\n Axis.prototype.positionToCoordinate = function (position) {\r\n return this.renderer.positionToCoordinate(position);\r\n };\r\n /**\r\n * [getAnyRangePath description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param start [description]\r\n * @param end [description]\r\n * @return [description]\r\n */\r\n Axis.prototype.getAnyRangePath = function (start, end) {\r\n return this.renderer.getPositionRangePath(start, end);\r\n };\r\n /**\r\n * Converts any positional parameter to a relative position on axis.\r\n *\r\n * @todo Description (review)\r\n * @param value Pisition\r\n * @return Position (0-1)\r\n */\r\n Axis.prototype.anyToPosition = function (value) {\r\n return 0;\r\n };\r\n /**\r\n * Converts any positional parameter to a relative position on axis.\r\n *\r\n * @todo Description (review)\r\n * @param value Pisition\r\n * @return Orientation point\r\n */\r\n Axis.prototype.anyToPoint = function (value) {\r\n return { x: 0, y: 0, angle: 0 };\r\n };\r\n /**\r\n * [getPositionRangePath description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param startPosition [description]\r\n * @param endPosition [description]\r\n * @return [description]\r\n */\r\n Axis.prototype.getPositionRangePath = function (startPosition, endPosition) {\r\n if (this.renderer) {\r\n return this.renderer.getPositionRangePath(startPosition, endPosition);\r\n }\r\n return \"\";\r\n };\r\n Object.defineProperty(Axis.prototype, \"axisLength\", {\r\n /**\r\n * Actual axis length in pixels.\r\n *\r\n * @return Axis length (px)\r\n */\r\n get: function () {\r\n if (this.renderer) {\r\n return this.renderer.axisLength;\r\n }\r\n return 0;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Axis.prototype, \"cursorTooltipEnabled\", {\r\n /**\r\n * @return Display tooltip?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"cursorTooltipEnabled\");\r\n },\r\n /**\r\n * Indicates if axis should display a tooltip for chart's cursor.\r\n *\r\n * @param value Display tooltip?\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"cursorTooltipEnabled\", value)) {\r\n if (value && this.renderer) {\r\n this.renderer.updateTooltip();\r\n }\r\n else if (this.tooltip) {\r\n this.tooltip.hide(0);\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Axis.prototype, \"toggleZoomOutButton\", {\r\n /**\r\n * @return Toggle zoom out button?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"toggleZoomOutButton\");\r\n },\r\n /**\r\n * Normally, when axis is zoomed in, a zoom out button is shown by a chart,\r\n * and vice versa: when axis is zoomed out completely, zoom out button is\r\n * hidden.\r\n *\r\n * Setting this to `false` will disable this behavior. Zooming in our out\r\n * this axis will not reveal or hide zoom out button.\r\n *\r\n * @default true\r\n * @since 4.6.2\r\n * @param value Toggle zoom out button?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"toggleZoomOutButton\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Hides element's [[Tooltip]].\r\n *\r\n * @see {@link Tooltip}\r\n */\r\n Axis.prototype.hideTooltip = function (duration) {\r\n _super.prototype.hideTooltip.call(this, duration);\r\n this._tooltipPosition = undefined;\r\n };\r\n /**\r\n * Shows Axis tooltip at specific relative position within Axis. (0-1)\r\n *\r\n * @param position Position (0-1)\r\n * @param local or global position\r\n */\r\n Axis.prototype.showTooltipAtPosition = function (position, local) {\r\n var tooltip = this._tooltip;\r\n if (!tooltip || this.dataItems.length <= 0) {\r\n this._tooltipPosition = undefined;\r\n }\r\n else {\r\n if (!local) {\r\n position = this.toAxisPosition(position);\r\n }\r\n if (!$type.isNumber(position) || position < this.start || position > this.end) {\r\n tooltip.hide(0);\r\n this._tooltipPosition = undefined;\r\n return;\r\n }\r\n var renderer = this.renderer;\r\n //@todo: think of how to solve this better\r\n if (!tooltip.parent) {\r\n tooltip.parent = this.tooltipContainer;\r\n }\r\n var tooltipLocation = renderer.tooltipLocation;\r\n var startPosition = this.getCellStartPosition(position);\r\n var endPosition = this.getCellEndPosition(position);\r\n if (this.tooltipPosition == \"fixed\") {\r\n position = startPosition + (endPosition - startPosition) * tooltipLocation;\r\n }\r\n position = $math.fitToRange(position, this.start, this.end);\r\n if (this._tooltipPosition != position) {\r\n this._tooltipPosition = position;\r\n var tooltipLocation2 = renderer.tooltipLocation2;\r\n var startPoint = renderer.positionToPoint(startPosition, tooltipLocation2);\r\n var endPoint = renderer.positionToPoint(endPosition, tooltipLocation2);\r\n // save values so cursor could use them\r\n this.currentItemStartPoint = startPoint;\r\n this.currentItemEndPoint = endPoint;\r\n if (renderer.fullWidthTooltip) {\r\n tooltip.width = endPoint.x - startPoint.x;\r\n tooltip.height = endPoint.y - startPoint.y;\r\n }\r\n var point = renderer.positionToPoint(position, tooltipLocation2);\r\n var globalPoint = $utils.spritePointToSvg(point, this.renderer.line);\r\n tooltip.text = this.getTooltipText(position);\r\n if (tooltip.text) {\r\n tooltip.delayedPointTo(globalPoint);\r\n tooltip.show();\r\n }\r\n }\r\n if (!this.cursorTooltipEnabled || this.tooltip.disabled) {\r\n tooltip.hide(0);\r\n }\r\n }\r\n };\r\n /**\r\n * Converts relative position (0-1) to Axis position with zoom level and\r\n * inversed taken into account.\r\n *\r\n * @param position Global position (0-1)\r\n * @return Position within Axis (0-1)\r\n */\r\n Axis.prototype.toAxisPosition = function (position) {\r\n position = this.renderer.toAxisPosition(position);\r\n if (position == undefined) {\r\n return;\r\n }\r\n position = position * (this.end - this.start);\r\n if (this.renderer.inversed) {\r\n position = this.end - position;\r\n }\r\n else {\r\n position = this.start + position;\r\n }\r\n return position;\r\n };\r\n /**\r\n * Converts position on the axis with zoom level and\r\n * inversed taken into account to global position.\r\n *\r\n * @param position Axis position (0-1)\r\n * @return Global position (0-1)\r\n */\r\n Axis.prototype.toGlobalPosition = function (position) {\r\n if (this.renderer.inversed) {\r\n position = this.end - position;\r\n }\r\n else {\r\n position = position - this.start;\r\n }\r\n return position / (this.end - this.start);\r\n };\r\n /**\r\n * Returns text to be used for cursor's Axis tooltip.\r\n *\r\n * This is a placeholder to override for extending classes.\r\n *\r\n * @ignore Exclude from docs\r\n * @param position Position coordinate (px)\r\n * @return Label text\r\n */\r\n Axis.prototype.getTooltipText = function (position) {\r\n return;\r\n };\r\n /**\r\n * Updates Axis' tooltip's position and possibly size, and pointer (stem)\r\n * place.\r\n *\r\n * @ignore Exclude from docs\r\n * @param pointerOrientation Pointer (stem) orientation\r\n * @param boundingRectangle A rectangle for tooltip to fit within\r\n */\r\n Axis.prototype.updateTooltip = function (pointerOrientation, boundingRectangle) {\r\n var tooltip = this._tooltip;\r\n if (tooltip) {\r\n tooltip.fixDoc = false;\r\n tooltip.pointerOrientation = pointerOrientation;\r\n tooltip.setBounds($utils.spriteRectToSvg(boundingRectangle, this.renderer.line));\r\n }\r\n };\r\n /**\r\n * [roundPosition description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param position Relative position\r\n * @param location Location on axis\r\n * @return Rounded position\r\n */\r\n Axis.prototype.roundPosition = function (position, location, axisLocation) {\r\n return position;\r\n };\r\n /**\r\n * [getCellStartPosition description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param position [description]\r\n * @return [description]\r\n */\r\n Axis.prototype.getCellStartPosition = function (position) {\r\n return position;\r\n };\r\n /**\r\n * [getCellEndPosition description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param position [description]\r\n * @return [description]\r\n */\r\n Axis.prototype.getCellEndPosition = function (position) {\r\n return position;\r\n };\r\n Object.defineProperty(Axis.prototype, \"axisRanges\", {\r\n /**\r\n * A list of axis ranges for this Axis.\r\n *\r\n * @return Axis ranges\r\n */\r\n get: function () {\r\n if (!this._axisRanges) {\r\n var dataItem = this.createDataItem();\r\n dataItem.isRange = true;\r\n dataItem.axisFill = this.renderer.axisFills.template.clone();\r\n dataItem.grid = this.renderer.grid.template.clone();\r\n dataItem.tick = this.renderer.ticks.template.clone();\r\n dataItem.label = this.renderer.labels.template.clone();\r\n dataItem.isTemplate = true;\r\n dataItem.component = this;\r\n dataItem.axisFill.disabled = false;\r\n dataItem.tick.disabled = false;\r\n dataItem.grid.disabled = false;\r\n dataItem.label.disabled = false;\r\n this._axisRanges = new ListTemplate(dataItem);\r\n this._axisRanges.events.on(\"inserted\", this.processAxisRange, this, false);\r\n this._disposers.push(new ListDisposer(this._axisRanges));\r\n this._disposers.push(this._axisRanges.template);\r\n }\r\n return this._axisRanges;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Decorates an axis range after it has been added to the axis range list.\r\n *\r\n * @param event Event\r\n */\r\n Axis.prototype.processAxisRange = function (event) {\r\n var axisRange = event.newValue;\r\n axisRange.component = this;\r\n axisRange.isRange = true;\r\n };\r\n Object.defineProperty(Axis.prototype, \"axisBreaks\", {\r\n /**\r\n * A list of axis breaks on this Axis.\r\n *\r\n * @return Axis breaks.\r\n */\r\n get: function () {\r\n if (!this._axisBreaks) {\r\n this._axisBreaks = new SortedListTemplate(this.createAxisBreak(), function (a, b) {\r\n return $number.order(a.adjustedStartValue, b.adjustedStartValue);\r\n });\r\n this._axisBreaks.events.on(\"inserted\", this.processBreak, this, false);\r\n this._disposers.push(new ListDisposer(this._axisBreaks));\r\n this._disposers.push(this._axisBreaks.template);\r\n }\r\n return this._axisBreaks;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Creates a new axis break.\r\n *\r\n * @return Axis break\r\n */\r\n Axis.prototype.createAxisBreak = function () {\r\n return new AxisBreak();\r\n };\r\n Object.defineProperty(Axis.prototype, \"series\", {\r\n /**\r\n * A list of Series currently associated with this Axis.\r\n *\r\n * @return Series\r\n */\r\n get: function () {\r\n if (!this._series) {\r\n this._series = new List();\r\n }\r\n return this._series;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Processes Series' data items.\r\n *\r\n * This is a placeholder to override for extending classes.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Axis.prototype.processSeriesDataItems = function () {\r\n };\r\n /**\r\n * Processes Series' single data item.\r\n *\r\n * This is a placeholder to override for extending classes.\r\n *\r\n * @ignore Exclude from docs\r\n * @param dataItem Data item\r\n */\r\n Axis.prototype.processSeriesDataItem = function (dataItem, axisLetter) {\r\n };\r\n /**\r\n * Post-processes Serie's data items.\r\n *\r\n * This is a placeholder to override for extending classes.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Axis.prototype.postProcessSeriesDataItems = function (series) {\r\n };\r\n /**\r\n * Post-processes Serie's single data item.\r\n *\r\n * This is a placeholder to override for extending classes.\r\n *\r\n * @ignore Exclude from docs\r\n * @param dataItem Data item\r\n */\r\n Axis.prototype.postProcessSeriesDataItem = function (dataItem) {\r\n };\r\n //\r\n /**\r\n * Updates Axis based on all Series that might influence it.\r\n *\r\n * Called by Series after Series data is validated.\r\n *\r\n * This is a placeholder to override for extending classes.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Axis.prototype.updateAxisBySeries = function () {\r\n };\r\n /**\r\n * Hides unused data items.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Axis.prototype.hideUnusedDataItems = function () {\r\n var _this = this;\r\n // hide all unused\r\n var dataItemsIterator = this._dataItemsIterator;\r\n dataItemsIterator.createNewItems = false;\r\n $iter.each(dataItemsIterator.iterator(), function (dataItem) {\r\n _this.validateDataElement(dataItem); // solves shrinking\r\n dataItem.__disabled = true;\r\n });\r\n dataItemsIterator.clear();\r\n dataItemsIterator.createNewItems = true;\r\n };\r\n /**\r\n * Returns a Series' data item that corresponds to specific position on Axis.\r\n *\r\n * This is a placeholder to override for extending classes.\r\n *\r\n * @ignore Exclude from docs\r\n * @param series Series\r\n * @param position Position (0-1)\r\n * @param findNearest Should axis try to find nearest tooltip if there is no data item at exact position\r\n * @return Data item\r\n */\r\n Axis.prototype.getSeriesDataItem = function (series, position, findNearest) {\r\n return;\r\n };\r\n /**\r\n * Returns an angle that corresponds to specific position on axis.\r\n *\r\n * This is a placeholder to override for extending classes.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description (review)\r\n * @param dataItem Data item\r\n * @param key ???\r\n * @param location Location\r\n * @param stackKey ???\r\n * @return Angle\r\n */\r\n Axis.prototype.getAngle = function (dataItem, key, location, stackKey, range) {\r\n return;\r\n };\r\n /**\r\n * [getX description]\r\n *\r\n * This is a placeholder to override for extending classes.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description (review)\r\n * @param dataItem [description]\r\n * @param key [description]\r\n * @param location [description]\r\n * @param stackKey [description]\r\n * @return [description]\r\n */\r\n Axis.prototype.getX = function (dataItem, key, location, stackKey, range) {\r\n return;\r\n };\r\n /**\r\n * [getX description]\r\n *\r\n * This is a placeholder to override for extending classes.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description (review)\r\n * @param dataItem [description]\r\n * @param key [description]\r\n * @param location [description]\r\n * @param stackKey [description]\r\n * @return [description]\r\n */\r\n Axis.prototype.getPositionX = function (dataItem, key, location, stackKey, range) {\r\n return;\r\n };\r\n /**\r\n * [getY description]\r\n *\r\n * This is a placeholder to override for extending classes.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description (review)\r\n * @param dataItem [description]\r\n * @param key [description]\r\n * @param location [description]\r\n * @param stackKey [description]\r\n * @return [description]\r\n */\r\n Axis.prototype.getY = function (dataItem, key, location, stackKey, range) {\r\n return;\r\n };\r\n /**\r\n * [getY description]\r\n *\r\n * This is a placeholder to override for extending classes.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description (review)\r\n * @param dataItem [description]\r\n * @param key [description]\r\n * @param location [description]\r\n * @param stackKey [description]\r\n * @return [description]\r\n */\r\n Axis.prototype.getPositionY = function (dataItem, key, location, stackKey, range) {\r\n return;\r\n };\r\n Object.defineProperty(Axis.prototype, \"basePoint\", {\r\n /**\r\n * Coordinates of the actual axis start.\r\n *\r\n * @ignore Exclude from docs\r\n * @return Base point coordinates\r\n */\r\n get: function () {\r\n return { x: 0, y: 0 };\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * [dataChangeUpdate description]\r\n *\r\n * This is a placeholder to override for extending classes.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n */\r\n Axis.prototype.dataChangeUpdate = function () {\r\n };\r\n /**\r\n * [dataChangeUpdate description]\r\n *\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n */\r\n Axis.prototype.seriesDataChangeUpdate = function (series) {\r\n };\r\n /**\r\n * Removes axis breaks that fall between `min` and `max` (???)\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description (review)\r\n * @param min Start value\r\n * @param max End value\r\n * @return Spread o\r\n */\r\n Axis.prototype.adjustDifference = function (min, max) {\r\n var difference = max - min;\r\n if ($type.isNumber(difference)) {\r\n if (this._axisBreaks) {\r\n $iter.eachContinue(this._axisBreaks.iterator(), function (axisBreak) {\r\n var startValue = axisBreak.adjustedStartValue;\r\n var endValue = axisBreak.adjustedEndValue;\r\n if ($type.isNumber(startValue) && $type.isNumber(endValue)) {\r\n // breaks are sorted, we don't need go further anymore\r\n if (startValue > max) {\r\n return false;\r\n }\r\n if (endValue >= min) {\r\n if ($type.isNumber(startValue) && $type.isNumber(endValue)) {\r\n var breakSize = axisBreak.breakSize;\r\n var intersection = $math.intersection({ start: startValue, end: endValue }, { start: min, end: max });\r\n if (intersection) {\r\n difference -= (intersection.end - intersection.start) * (1 - breakSize);\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n });\r\n }\r\n return difference;\r\n }\r\n };\r\n /**\r\n * Checks if specific value falls within a break.\r\n *\r\n * Returns [[AxisBreak]] the value falls into.\r\n *\r\n * @param value Value to check\r\n * @return Axis break\r\n */\r\n Axis.prototype.isInBreak = function (value) {\r\n if (this._axisBreaks) {\r\n return $iter.find(this._axisBreaks.iterator(), function (axisBreak) {\r\n return value >= axisBreak.adjustedStartValue &&\r\n value <= axisBreak.adjustedEndValue;\r\n });\r\n }\r\n };\r\n /**\r\n * [fixAxisBreaks description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n */\r\n Axis.prototype.fixAxisBreaks = function () {\r\n var _this = this;\r\n if (this._axisBreaks) {\r\n var axisBreaks = this._axisBreaks;\r\n if (axisBreaks.length > 0) {\r\n // first make sure that startValue is <= end value\r\n // This needs to make a copy of axisBreaks because it mutates the list while traversing\r\n // TODO very inefficient\r\n $array.each($iter.toArray(axisBreaks.iterator()), function (axisBreak) {\r\n var startValue = $math.min(axisBreak.startValue, axisBreak.endValue);\r\n var endValue = $math.max(axisBreak.startValue, axisBreak.endValue);\r\n axisBreak.adjustedStartValue = startValue;\r\n axisBreak.adjustedEndValue = endValue;\r\n _this._axisBreaks.update(axisBreak);\r\n });\r\n var firstAxisBreak = axisBreaks.first;\r\n var previousEndValue_1 = Math.min(firstAxisBreak.startValue, firstAxisBreak.endValue);\r\n // process breaks\r\n // TODO does this need to call axisBreaks.update ?\r\n $iter.each(axisBreaks.iterator(), function (axisBreak) {\r\n var startValue = axisBreak.adjustedStartValue;\r\n var endValue = axisBreak.adjustedEndValue;\r\n // breaks can't overlap\r\n // if break starts before previous break ends\r\n if (startValue < previousEndValue_1) {\r\n startValue = previousEndValue_1;\r\n if (endValue < previousEndValue_1) {\r\n endValue = previousEndValue_1;\r\n }\r\n }\r\n axisBreak.adjustedStartValue = startValue;\r\n axisBreak.adjustedEndValue = endValue;\r\n });\r\n }\r\n }\r\n };\r\n Object.defineProperty(Axis.prototype, \"startIndex\", {\r\n /**\r\n * @ignore Exclude from docs\r\n * @return [description]\r\n */\r\n get: function () {\r\n return 0;\r\n },\r\n /**\r\n * We need start/end indexes of axes to be 0 - `dataItems.length`.\r\n *\r\n * Yes, also for category axis, this helps to avoid jumping of categories\r\n * while scrolling and does not do a lot of extra work as we use\r\n * protected `_startIndex` and `_endIndex` when working with items.\r\n *\r\n * @hidden\r\n */\r\n /**\r\n * [startIndex description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param value [description]\r\n */\r\n set: function (value) {\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Axis.prototype, \"endIndex\", {\r\n /**\r\n * @ignore Exclude from docs\r\n * @return [description]\r\n */\r\n get: function () {\r\n return this.dataItems.length;\r\n },\r\n /**\r\n * [endIndex description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param value [description]\r\n */\r\n set: function (value) {\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Returns a formatted label based on position.\r\n *\r\n * Individual axis types should override this method to generate a label\r\n * that is relevant to axis type.\r\n *\r\n * Please note that `position` represents position within axis which may be\r\n * zoomed and not correspond to Cursor's `position`.\r\n *\r\n * To convert Cursor's `position` to Axis' `position` use `toAxisPosition()` method.\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/tutorials/tracking-cursors-position-via-api/#Tracking_Cursor_s_position} For more information about cursor tracking.\r\n * @param position Relative position on axis (0-1)\r\n * @return Position label\r\n */\r\n Axis.prototype.getPositionLabel = function (position) {\r\n return Math.round(position * 100) + \"%x\";\r\n };\r\n Object.defineProperty(Axis.prototype, \"chart\", {\r\n /**\r\n * @return Chart\r\n */\r\n get: function () {\r\n return this._chart;\r\n },\r\n /**\r\n * A Chart this Axis belongs to.\r\n *\r\n * @param value Chart\r\n */\r\n set: function (value) {\r\n this._chart = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Creates a data item for a Series range.\r\n *\r\n * @param series Target Series\r\n * @return Range data item\r\n */\r\n Axis.prototype.createSeriesRange = function (series) {\r\n var range = this.axisRanges.create();\r\n range.component = this;\r\n range.axisFill = this.renderer.axisFills.template.clone();\r\n range.axisFill.disabled = false;\r\n range.axisFill.fillOpacity = 0;\r\n range.grid = this.renderer.grid.template.clone();\r\n range.grid.disabled = true;\r\n range.tick = this.renderer.ticks.template.clone();\r\n range.tick.disabled = true;\r\n range.label = this.renderer.labels.template.clone();\r\n range.label.disabled = true;\r\n range.addDisposer(new Disposer(function () {\r\n series.axisRanges.removeValue(range);\r\n }));\r\n series.axisRanges.push(range);\r\n return range;\r\n };\r\n /**\r\n * Copies all properties and related data from a different instance of Axis.\r\n *\r\n * @param source Source Axis\r\n */\r\n Axis.prototype.copyFrom = function (source) {\r\n _super.prototype.copyFrom.call(this, source);\r\n if (this.renderer) {\r\n this.renderer.copyFrom(source.renderer);\r\n }\r\n else {\r\n if (source.renderer) {\r\n this.renderer = source.renderer.clone();\r\n this._disposers.push(this.renderer);\r\n }\r\n }\r\n if (source.title) {\r\n if (!this.title) {\r\n this.title = source.title.clone();\r\n this.title.parent = this;\r\n }\r\n else {\r\n this.title.copyFrom(source.title);\r\n }\r\n this._disposers.push(this.title);\r\n }\r\n };\r\n /**\r\n * Resets internal iterator.\r\n */\r\n Axis.prototype.resetIterators = function () {\r\n this._dataItemsIterator.reset();\r\n };\r\n /**\r\n * Processes JSON-based config before it is applied to the object.\r\n *\r\n * @ignore Exclude from docs\r\n * @param config Config\r\n */\r\n Axis.prototype.processConfig = function (config) {\r\n if (config) {\r\n // Set up axis ranges\r\n if ($type.hasValue(config.axisRanges) && $type.isArray(config.axisRanges)) {\r\n for (var i = 0, len = config.axisRanges.length; i < len; i++) {\r\n var range = config.axisRanges[i];\r\n // If `series` is set, we know it's a series range\r\n if ($type.hasValue(range[\"series\"])) {\r\n if ($type.isString(range[\"series\"])) {\r\n if (this.map.hasKey(range[\"series\"])) {\r\n //range[\"series\"] = this.map.getKey(range[\"series\"]);\r\n config.axisRanges[i] = this.createSeriesRange(this.map.getKey(range[\"series\"]));\r\n delete (range[\"series\"]);\r\n config.axisRanges[i].config = range;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n _super.prototype.processConfig.call(this, config);\r\n };\r\n /**\r\n * Ordering function used in JSON setup.\r\n *\r\n * @param a Item A\r\n * @param b Item B\r\n * @return Order\r\n */\r\n Axis.prototype.configOrder = function (a, b) {\r\n if (a == b) {\r\n return 0;\r\n }\r\n // last\r\n else if (a == \"title\") {\r\n return 1;\r\n }\r\n else if (b == \"title\") {\r\n return -1;\r\n }\r\n // first\r\n else if (a == \"component\") {\r\n return -1;\r\n }\r\n else if (b == \"component\") {\r\n return 1;\r\n }\r\n else {\r\n return _super.prototype.configOrder.call(this, a, b);\r\n }\r\n };\r\n Object.defineProperty(Axis.prototype, \"startLocation\", {\r\n /**\r\n * @return Location (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"startLocation\");\r\n },\r\n /**\r\n * Axis start location. Works on Date/Category axis, doesn't work on Value axis.\r\n *\r\n * * 0 - Full first cell is shown.\r\n * * 0.5 - Half of first cell is shown.\r\n * * 1 - None of the first cell is visible. (you probably don't want that)\r\n *\r\n * @param value Location (0-1)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"startLocation\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Axis.prototype, \"endLocation\", {\r\n /**\r\n * @return Location (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"endLocation\");\r\n },\r\n /**\r\n * Axis end location. Works on Date/Category axis, doesn't work on Value axis.\r\n *\r\n * * 0 - None of the last cell is shown. (don't do that)\r\n * * 0.5 - Half of the last cell is shown.\r\n * * 1 - Full last cell is shown.\r\n *\r\n * @param value Location (0-1)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"endLocation\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Axis.prototype.setDisabled = function (value) {\r\n var changed = _super.prototype.setDisabled.call(this, value);\r\n if (this.renderer) {\r\n this.renderer.gridContainer.disabled = value;\r\n }\r\n return changed;\r\n };\r\n Object.defineProperty(Axis.prototype, \"title\", {\r\n /**\r\n * @return Title label\r\n */\r\n get: function () {\r\n return this._title;\r\n },\r\n /**\r\n * A reference to a [[Label]] element which serves as a title to the axis.\r\n *\r\n * When axis is created it aleready has an element, so you can just modify\r\n * it.\r\n *\r\n * Or you can replace it with your own instance of `Label`.\r\n *\r\n * @param value Title label\r\n */\r\n set: function (value) {\r\n if (this._title && this._title != value) {\r\n this._title.dispose();\r\n }\r\n if (value) {\r\n this._title = value;\r\n value.parent = this;\r\n value.shouldClone = false;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Axis.prototype, \"hideTooltipWhileZooming\", {\r\n /**\r\n * @return Hide tooltip while zooming?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"hideTooltipWhileZooming\");\r\n },\r\n /**\r\n * Indicates if axis' tooltip should be hidden while axis range is animating\r\n * (zooming)\r\n *\r\n * @default true\r\n * @since 4.7.16\r\n * @param value Hide tooltip while zooming?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"hideTooltipWhileZooming\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Axis.prototype, \"zoomable\", {\r\n /**\r\n * @return Zoomable?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"zoomable\");\r\n },\r\n /**\r\n * Should the axis be zoomed with scrollbar/cursor?\r\n *\r\n * @default true\r\n * @since 4.9.28\r\n * @param value Zoomable?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"zoomable\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Axis;\r\n}(Component));\r\nexport { Axis };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Axis\"] = Axis;\r\nregistry.registeredClasses[\"AxisDataItem\"] = AxisDataItem;\r\n/**\r\n * Add default responsive rules\r\n */\r\n/**\r\n * Disable axis tooltips.\r\n */\r\ndefaultRules.push({\r\n relevant: ResponsiveBreakpoints.maybeXS,\r\n state: function (target, stateId) {\r\n if (target instanceof Axis && target.tooltip) {\r\n var state = target.states.create(stateId);\r\n state.properties.cursorTooltipEnabled = false;\r\n return state;\r\n }\r\n return null;\r\n }\r\n});\r\n//# sourceMappingURL=Axis.js.map","/**\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Sprite } from \"../../core/Sprite\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { color } from \"../../core/utils/Color\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Used to draw Axis line.\r\n *\r\n * @see {@link IAxisLineEvents} for a list of available events\r\n * @see {@link IAxisLineAdapters} for a list of available Adapters\r\n */\r\nvar AxisLine = /** @class */ (function (_super) {\r\n __extends(AxisLine, _super);\r\n /**\r\n * Constructor\r\n */\r\n function AxisLine() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"AxisLine\";\r\n _this.element = _this.paper.add(\"path\");\r\n var interfaceColors = new InterfaceColorSet();\r\n _this.stroke = interfaceColors.getFor(\"grid\");\r\n _this.strokeOpacity = 0.15;\r\n _this.pixelPerfect = true;\r\n _this.fill = color();\r\n _this.applyTheme();\r\n _this.interactionsEnabled = false;\r\n return _this;\r\n //this.element.moveTo({ x: 0, y: 0 });\r\n }\r\n return AxisLine;\r\n}(Sprite));\r\nexport { AxisLine };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"AxisLine\"] = AxisLine;\r\n//# sourceMappingURL=AxisLine.js.map","import { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Sprite } from \"../../core/Sprite\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport * as $type from \"../../core/utils/Type\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * AxisFill is a base class used to defines fill shapes for various\r\n * type-specific Axes.\r\n *\r\n * Axis fills are used to add fills to specific ranges of those axes.\r\n *\r\n * @see {@link IAxisFillEvents} for a list of available events\r\n * @see {@link IAxisFillAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar AxisFill = /** @class */ (function (_super) {\r\n __extends(AxisFill, _super);\r\n /**\r\n * Constructor.\r\n *\r\n * @param axis Axis\r\n */\r\n function AxisFill(axis) {\r\n var _this = _super.call(this) || this;\r\n _this.axis = axis;\r\n _this.element = _this.paper.add(\"path\");\r\n _this.className = \"AxisFill\";\r\n _this.isMeasured = false;\r\n _this.location = 0;\r\n _this.above = false;\r\n var interfaceColors = new InterfaceColorSet();\r\n _this.fill = interfaceColors.getFor(\"alternativeBackground\");\r\n _this.fillOpacity = 0;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * @ignore\r\n */\r\n AxisFill.prototype.setDisabled = function (value) {\r\n var changed = _super.prototype.setDisabled.call(this, value);\r\n if (this.axis) {\r\n this.axis.invalidateDataItems();\r\n }\r\n return changed;\r\n };\r\n /**\r\n * Draws the fill element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n AxisFill.prototype.draw = function () {\r\n _super.prototype.draw.call(this);\r\n if (this.__disabled || this.disabled) {\r\n return;\r\n }\r\n if (this.axis && $type.isNumber(this.startPosition) && $type.isNumber(this.endPosition)) {\r\n this.fillPath = this.axis.getPositionRangePath(this.startPosition, this.endPosition);\r\n this.path = this.fillPath;\r\n if (this.isMeasured) {\r\n this.measure();\r\n }\r\n }\r\n };\r\n Object.defineProperty(AxisFill.prototype, \"startPosition\", {\r\n /**\r\n * @return Start position\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"startPosition\");\r\n },\r\n /**\r\n * An actual starting position of the fill.\r\n *\r\n * @param value Starting position\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"startPosition\", value);\r\n this.invalidate(); // this is needed as relative position might not change when zooming\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisFill.prototype, \"endPosition\", {\r\n /**\r\n * @return End position\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"endPosition\");\r\n },\r\n /**\r\n * An actual end position of the fill.\r\n *\r\n * @param value End position\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"endPosition\", value);\r\n this.invalidate(); // this is needed as relative position might not change when zooming\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisFill.prototype, \"location\", {\r\n /**\r\n * @return Location (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"location\");\r\n },\r\n /**\r\n * Relative location of the fill. (0-1)\r\n *\r\n * @param value Location (0-1)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"location\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * @ignore\r\n */\r\n AxisFill.prototype.setPath = function (value) {\r\n if (this.setPropertyValue(\"path\", value)) {\r\n this.element.attr({ \"d\": value });\r\n return true;\r\n }\r\n return false;\r\n };\r\n Object.defineProperty(AxisFill.prototype, \"above\", {\r\n /**\r\n * @return Draw above series?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"above\");\r\n },\r\n /**\r\n * Normally fill goes below series. Set this to `true` to go above.\r\n *\r\n * @default false\r\n * @since 4.5.9\r\n * @param value Draw above series?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"above\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return AxisFill;\r\n}(Sprite));\r\nexport { AxisFill };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"AxisFill\"] = AxisFill;\r\n//# sourceMappingURL=AxisFill.js.map","/**\r\n * A module defining functionality for axis grid elements.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Sprite } from \"../../core/Sprite\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { color } from \"../../core/utils/Color\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport { defaultRules, ResponsiveBreakpoints } from \"../../core/utils/Responsive\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Displays an axis grid line.\r\n *\r\n * @see {@link IGridEvents} for a list of available events\r\n * @see {@link IGridAdapters} for a list of available Adapters\r\n * @todo Review: container is better, as we'll be able to attach something to the grid, also with 3d charts we might need some additional elements\r\n * @important\r\n */\r\nvar Grid = /** @class */ (function (_super) {\r\n __extends(Grid, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Grid() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"Grid\";\r\n _this.element = _this.paper.add(\"path\");\r\n _this.location = 0.5;\r\n _this.isMeasured = false;\r\n _this.above = false;\r\n var interfaceColors = new InterfaceColorSet();\r\n _this.stroke = interfaceColors.getFor(\"grid\");\r\n _this.pixelPerfect = true;\r\n _this.strokeOpacity = 0.15;\r\n _this.fill = color(); // \"none\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(Grid.prototype, \"location\", {\r\n /**\r\n * @return Location (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"location\");\r\n },\r\n /**\r\n * Location within axis cell to place grid line on.\r\n *\r\n * * 0 - start\r\n * * 0.5 - middle\r\n * * 1 - end\r\n *\r\n * @param value Location (0-1)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"location\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Grid.prototype, \"above\", {\r\n /**\r\n * @return Draw above series?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"above\");\r\n },\r\n /**\r\n * Normally fill goes below series. Set this to `true` to go above.\r\n *\r\n * @default false\r\n * @since 4.5.9\r\n * @param value Draw above series?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"above\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * @ignore\r\n */\r\n Grid.prototype.setDisabled = function (value) {\r\n var changed = _super.prototype.setDisabled.call(this, value);\r\n if (this.axis) {\r\n this.axis.invalidateDataItems();\r\n }\r\n return changed;\r\n };\r\n return Grid;\r\n}(Sprite));\r\nexport { Grid };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Grid\"] = Grid;\r\n/**\r\n * Add default responsive rules\r\n */\r\n/**\r\n * Disable grid on smaller charts\r\n */\r\ndefaultRules.push({\r\n relevant: ResponsiveBreakpoints.maybeXS,\r\n state: function (target, stateId) {\r\n if (target instanceof Grid) {\r\n var state = target.states.create(stateId);\r\n state.properties.disabled = true;\r\n return state;\r\n }\r\n return null;\r\n }\r\n});\r\n//# sourceMappingURL=Grid.js.map","/**\r\n * Axis Label module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Label } from \"../../core/elements/Label\";\r\nimport { registry } from \"../../core/Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Use to create labels on Axis.\r\n *\r\n * @see {@link IAxisLabelEvents} for a list of available events\r\n * @see {@link IAxisLabelAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar AxisLabel = /** @class */ (function (_super) {\r\n __extends(AxisLabel, _super);\r\n /**\r\n * Constructor\r\n */\r\n function AxisLabel() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"AxisLabel\";\r\n _this.isMeasured = false;\r\n _this.padding(10, 10, 10, 10);\r\n _this.location = 0.5;\r\n //this.nonScaling = true; // not good for perf\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(AxisLabel.prototype, \"location\", {\r\n /**\r\n * @return Location (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"location\");\r\n },\r\n /**\r\n * Relative location of the label. (0-1)\r\n *\r\n * @param value Location (0-1)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"location\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisLabel.prototype, \"inside\", {\r\n /**\r\n * Returns if label is set to be drawn inside axis.\r\n *\r\n * @return Inside?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"inside\");\r\n },\r\n /**\r\n * Sets if label should be drawn inside axis.\r\n *\r\n * @param value Inside?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"inside\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * @ignore\r\n */\r\n AxisLabel.prototype.setDisabled = function (value) {\r\n var changed = _super.prototype.setDisabled.call(this, value);\r\n if (this.axis) {\r\n this.axis.invalidateDataItems();\r\n }\r\n return changed;\r\n };\r\n return AxisLabel;\r\n}(Label));\r\nexport { AxisLabel };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"AxisLabel\"] = AxisLabel;\r\n//# sourceMappingURL=AxisLabel.js.map","/**\r\n * Tick module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Sprite } from \"../../core/Sprite\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A basic Tick class.\r\n *\r\n * A tick is a short dash, mainly connecting an object like axis or slice to\r\n * it's textual label.\r\n *\r\n * @see {@link ITickEvents} for a list of available events\r\n * @see {@link ITickAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar Tick = /** @class */ (function (_super) {\r\n __extends(Tick, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Tick() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"Tick\";\r\n var interfaceColors = new InterfaceColorSet();\r\n _this.fillOpacity = 0;\r\n _this.length = 6;\r\n _this.strokeOpacity = 0.2;\r\n _this.stroke = interfaceColors.getFor(\"grid\");\r\n _this.isMeasured = false;\r\n _this.nonScalingStroke = true;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(Tick.prototype, \"length\", {\r\n /**\r\n * @return Length (px)\r\n */\r\n get: function () {\r\n if (this.disabled) {\r\n return 0;\r\n }\r\n return this.getPropertyValue(\"length\");\r\n },\r\n /**\r\n * Length of the tick in pixels.\r\n *\r\n * @param value Length (px)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"length\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Tick;\r\n}(Sprite));\r\nexport { Tick };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Tick\"] = Tick;\r\n//# sourceMappingURL=Tick.js.map","/**\r\n * Axis Tick module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Tick } from \"../elements/Tick\";\r\nimport { registry } from \"../../core/Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Draws an axis tick\r\n * @see {@link IAxisTickEvents} for a list of available events\r\n * @see {@link IAxisTickAdapters} for a list of available Adapters\r\n */\r\nvar AxisTick = /** @class */ (function (_super) {\r\n __extends(AxisTick, _super);\r\n function AxisTick() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"AxisTick\";\r\n _this.element = _this.paper.add(\"path\");\r\n _this.location = 0.5;\r\n _this.above = false;\r\n _this.isMeasured = false;\r\n _this.pixelPerfect = true;\r\n _this.strokeOpacity = 0;\r\n _this.length = 5;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(AxisTick.prototype, \"location\", {\r\n /**\r\n * @return Location (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"location\");\r\n },\r\n /**\r\n * Relative location of the tick. (0-1)\r\n *\r\n * @param value Location (0-1)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"location\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisTick.prototype, \"inside\", {\r\n /**\r\n * Returns if label is set to be drawn inside axis.\r\n *\r\n * @return Inside?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"inside\");\r\n },\r\n /**\r\n * Sets if tick should be drawn inside axis.\r\n *\r\n * @param value Inside?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"inside\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisTick.prototype, \"above\", {\r\n /**\r\n * @return Draw above series?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"above\");\r\n },\r\n /**\r\n * Normally tick goes below series. Set this to `true` to go above.\r\n *\r\n * @default false\r\n * @since 4.5.9\r\n * @param value Draw above series?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"above\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * @ignore\r\n */\r\n AxisTick.prototype.setDisabled = function (value) {\r\n var changed = _super.prototype.setDisabled.call(this, value);\r\n if (this.axis) {\r\n this.axis.invalidateDataItems();\r\n }\r\n return changed;\r\n };\r\n return AxisTick;\r\n}(Tick));\r\nexport { AxisTick };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"AxisTick\"] = AxisTick;\r\n//# sourceMappingURL=AxisTick.js.map","/**\r\n * Module, defining base Axis Renderer.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../../core/Container\";\r\nimport { MutableValueDisposer } from \"../../core/utils/Disposer\";\r\nimport { AxisDataItem } from \"./Axis\";\r\nimport { AxisLine } from \"./AxisLine\";\r\nimport { AxisFill } from \"./AxisFill\";\r\nimport { Grid } from \"./Grid\";\r\nimport { AxisLabel } from \"./AxisLabel\";\r\nimport { AxisTick } from \"./AxisTick\";\r\nimport { ListTemplate, ListDisposer } from \"../../core/utils/List\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { percent } from \"../../core/utils/Percent\";\r\nimport * as $math from \"../../core/utils/Math\";\r\nimport * as $type from \"../../core/utils/Type\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A base class for all axis renderers.\r\n *\r\n * @see {@link IAxisRendererEvents} for a list of available events\r\n * @see {@link IAxisRendererAdapters} for a list of available Adapters\r\n */\r\nvar AxisRenderer = /** @class */ (function (_super) {\r\n __extends(AxisRenderer, _super);\r\n /**\r\n * Constructor.\r\n *\r\n * @param axis Related axis\r\n */\r\n function AxisRenderer() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n /**\r\n * A related chart.\r\n */\r\n _this._chart = new MutableValueDisposer();\r\n _this.className = \"AxisRenderer\";\r\n // Set defaults\r\n _this.minGridDistance = 50;\r\n _this.inside = false;\r\n _this.inversed = false;\r\n _this.tooltipLocation = 0.5;\r\n _this.fullWidthTooltip = false;\r\n _this.cellStartLocation = 0;\r\n _this.cellEndLocation = 1;\r\n _this.minLabelPosition = 0;\r\n _this.maxLabelPosition = 1;\r\n _this.shouldClone = false;\r\n var gridContainer = _this.createChild(Container);\r\n gridContainer.shouldClone = false;\r\n gridContainer.layout = \"none\";\r\n //\tgridContainer.isMeasured = false;\r\n gridContainer.virtualParent = _this;\r\n gridContainer.width = percent(100);\r\n gridContainer.height = percent(100);\r\n _this.gridContainer = gridContainer;\r\n // not good without this\r\n gridContainer.events.on(\"maxsizechanged\", function () {\r\n if (_this.inited) {\r\n _this.invalidateAxisItems();\r\n }\r\n }, _this, false);\r\n var breakContainer = _this.createChild(Container);\r\n breakContainer.shouldClone = false;\r\n breakContainer.isMeasured = false;\r\n breakContainer.layout = \"none\";\r\n breakContainer.width = percent(100);\r\n breakContainer.height = percent(100);\r\n _this.breakContainer = breakContainer;\r\n var bulletsContainer = _this.createChild(Container);\r\n bulletsContainer.shouldClone = false;\r\n bulletsContainer.isMeasured = false;\r\n bulletsContainer.layout = \"none\";\r\n bulletsContainer.width = percent(100);\r\n bulletsContainer.height = percent(100);\r\n _this.bulletsContainer = bulletsContainer;\r\n _this.line = _this.createChild(AxisLine);\r\n _this.line.shouldClone = false;\r\n _this.line.strokeOpacity = 0;\r\n var baseGrid = _this.createChild(Grid);\r\n baseGrid.shouldClone = false;\r\n _this.baseGrid = baseGrid;\r\n // Make elements disposable\r\n var disposers = _this._disposers;\r\n disposers.push(baseGrid);\r\n disposers.push(_this.line);\r\n disposers.push(gridContainer);\r\n disposers.push(breakContainer);\r\n disposers.push(bulletsContainer);\r\n disposers.push(_this._chart);\r\n _this.ticks.template.disabled = true;\r\n _this.axisFills.template.disabled = true;\r\n _this.axisFills.template.interactionsEnabled = false;\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(AxisRenderer.prototype, \"axis\", {\r\n /**\r\n * Axis of a renderer\r\n * @return axis Axis\r\n */\r\n get: function () {\r\n return this._axis;\r\n },\r\n /**\r\n * Axis of a renderer\r\n * @param axis Axis\r\n */\r\n set: function (axis) {\r\n this.setAxis(axis);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * @ignore\r\n */\r\n AxisRenderer.prototype.setAxis = function (axis) {\r\n this._axis = axis;\r\n this.baseGrid.parent = axis;\r\n this.line.parent = axis;\r\n this.gridContainer.bind(\"opacity\", axis);\r\n };\r\n /**\r\n * Called when rendered is attached to an Axis, as well as a property of\r\n * Axis that might affect the appearance is updated.\r\n *\r\n * E.g. `axis.opposite`, `axis.inside`, etc.\r\n *\r\n * This method is called **before** draw, so that any related setting\r\n * changed in this method can be changed.\r\n *\r\n * @todo Description (review)\r\n * @ignore Exclude from docs\r\n */\r\n AxisRenderer.prototype.processRenderer = function () {\r\n this.events.on(\"sizechanged\", this.updateTooltip, this, false);\r\n this.events.on(\"positionchanged\", this.updateTooltip, this, false);\r\n this.labels.template.inside = this.inside;\r\n this.ticks.template.inside = this.inside;\r\n };\r\n /**\r\n * Updates Axis' tooltip.\r\n *\r\n * @todo Description (review)\r\n * @ignore Exclude from docs\r\n */\r\n AxisRenderer.prototype.updateTooltip = function () {\r\n // This is a placeholder method for extending classes to override.\r\n };\r\n Object.defineProperty(AxisRenderer.prototype, \"axisLength\", {\r\n /**\r\n * Returns actual length of the Axis, in pixels.\r\n *\r\n * @return Length (px)\r\n */\r\n get: function () {\r\n // This is a placeholder method for extending classes to override.\r\n return 0;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Re-positions an element to new coordinates.\r\n *\r\n * @ignore Exclude from docs\r\n * @param item A target element\r\n * @param point New coordinates\r\n */\r\n AxisRenderer.prototype.positionItem = function (item, point) {\r\n if (item) {\r\n item.moveTo(point);\r\n }\r\n };\r\n /**\r\n * Converts relative position on axis to point coordinates.\r\n *\r\n * @param position Position (0-1)\r\n * @return Point\r\n */\r\n AxisRenderer.prototype.positionToPoint = function (position, position2) {\r\n // This is a placeholder method for extending classes to override.\r\n return { x: 0, y: 0 };\r\n };\r\n /**\r\n * Converts relative position on axis to angle.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description (review / units)\r\n * @param position Position (0-1)\r\n * @return Angle\r\n */\r\n AxisRenderer.prototype.positionToAngle = function (position) {\r\n // This is a placeholder method for extending classes to override.\r\n return 0;\r\n };\r\n /**\r\n * Converts relative position (0-1) on axis to a pixel coordinate.\r\n *\r\n * @param position Position (0-1)\r\n * @return Coordinate (px)\r\n */\r\n AxisRenderer.prototype.positionToCoordinate = function (position) {\r\n var coordinate;\r\n var axis = this.axis;\r\n var axisFullLength = axis.axisFullLength;\r\n if (axis.renderer.inversed) {\r\n coordinate = (axis.end - position) * axisFullLength;\r\n }\r\n else {\r\n coordinate = (position - axis.start) * axisFullLength;\r\n }\r\n return coordinate;\r\n };\r\n AxisRenderer.prototype.updateGridContainer = function () {\r\n };\r\n AxisRenderer.prototype.getHeight = function () {\r\n var gridContainer = this.gridContainer;\r\n if (gridContainer.parent) {\r\n return gridContainer.parent.pixelHeight;\r\n }\r\n return this.gridContainer.pixelHeight || 0;\r\n };\r\n AxisRenderer.prototype.getWidth = function () {\r\n var gridContainer = this.gridContainer;\r\n if (gridContainer.parent) {\r\n return gridContainer.parent.pixelWidth;\r\n }\r\n return this.gridContainer.pixelWidth || 0;\r\n };\r\n /**\r\n * Converts a coordinate in pixels to a relative position. (0-1)\r\n *\r\n * @param coordinate Coordinate (px)\r\n * @param coordinate2 Coordinate of a second axis, only needed for complex axes systems, like timeline (px)\r\n * @return Position (0-1)\r\n */\r\n AxisRenderer.prototype.coordinateToPosition = function (coordinate, coordinate2) {\r\n var position;\r\n var axis = this.axis;\r\n var axisFullLength = axis.axisFullLength;\r\n if (axis.renderer.inversed) {\r\n position = axis.end - coordinate / axisFullLength;\r\n }\r\n else {\r\n position = coordinate / axisFullLength + axis.start;\r\n }\r\n return $math.round(position, 5);\r\n };\r\n /**\r\n * Converts a point at specific coordinates to a relative position (0-1)\r\n * on the axis.\r\n *\r\n * @ignore Exclude from docs\r\n * @param point Point\r\n * @return Position (0-1)\r\n */\r\n AxisRenderer.prototype.pointToPosition = function (point) {\r\n // This is a placeholder method for extending classes to override.\r\n return 0;\r\n };\r\n /**\r\n * [getPositionRangePath description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param startPosition Starting position\r\n * @param endPosition End position\r\n * @return SVG path\r\n */\r\n AxisRenderer.prototype.getPositionRangePath = function (startPosition, endPosition) {\r\n return \"\";\r\n };\r\n /**\r\n * Invalidates all axis data items, effectively causing them re-evaluated.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description (review)\r\n */\r\n AxisRenderer.prototype.invalidateAxisItems = function () {\r\n var axis = this.axis;\r\n if (axis) {\r\n axis.invalidateDataItems();\r\n }\r\n };\r\n /**\r\n * Updates and positions a grid element.\r\n *\r\n * @ignore Exclude from docs\r\n * @param grid Grid element\r\n * @param position Starting position\r\n * @param endPosition End position\r\n */\r\n AxisRenderer.prototype.updateGridElement = function (grid, position, endPosition) {\r\n // This is a placeholder method for extending classes to override.\r\n };\r\n /**\r\n * Updates and positions a tick element.\r\n *\r\n * @ignore Exclude from docs\r\n * @param tick Tick element\r\n * @param position Starting position\r\n * @param endPosition End position\r\n */\r\n AxisRenderer.prototype.updateTickElement = function (tick, position, endPosition) {\r\n // This is a placeholder method for extending classes to override.\r\n };\r\n /**\r\n * Updates and positions axis bullet.\r\n *\r\n * @ignore Exclude from docs\r\n * @param bullet AxisBullet element\r\n * @param position Starting position\r\n * @param endPosition End position\r\n */\r\n AxisRenderer.prototype.updateBullet = function (bullet, position, endPosition) {\r\n // This is a placeholder method for extending classes to override.\r\n };\r\n /**\r\n * Updates and positions a label element.\r\n *\r\n * @ignore Exclude from docs\r\n * @param label Label element\r\n * @param position Starting position\r\n * @param endPosition Ending position\r\n */\r\n AxisRenderer.prototype.updateLabelElement = function (label, position, endPosition, location) {\r\n // This is a placeholder method for extending classes to override.\r\n };\r\n /**\r\n * Updates and positions the axis fill element.\r\n *\r\n * @ignore Exclude from docs\r\n * @param fill Fill element\r\n * @param position Starting position\r\n * @param endPosition Ending position\r\n */\r\n AxisRenderer.prototype.updateFillElement = function (fill, position, endPosition) {\r\n fill.startPosition = position;\r\n fill.endPosition = endPosition;\r\n };\r\n /**\r\n * Updates and positions the axis line element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n AxisRenderer.prototype.updateAxisLine = function () {\r\n // This is a placeholder method for extending classes to override.\r\n };\r\n /**\r\n * Updates and positions the base grid element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n AxisRenderer.prototype.updateBaseGridElement = function () {\r\n // This is a placeholder method for extending classes to override.\r\n };\r\n /**\r\n * Updates and positions an axis break element.\r\n *\r\n * @ignore Exclude from docs\r\n * @param axisBreak Break element\r\n */\r\n AxisRenderer.prototype.updateBreakElement = function (axisBreak) {\r\n this.positionItem(axisBreak.startLine, axisBreak.startPoint);\r\n this.toggleVisibility(axisBreak.startLine, axisBreak.startPosition, 0, 1);\r\n this.positionItem(axisBreak.endLine, axisBreak.endPoint);\r\n this.toggleVisibility(axisBreak.endLine, axisBreak.endPosition, 0, 1);\r\n };\r\n Object.defineProperty(AxisRenderer.prototype, \"minGridDistance\", {\r\n /**\r\n * @return Min distance (px)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"minGridDistance\");\r\n },\r\n /**\r\n * Minimum distance in pixels between grid elements.\r\n *\r\n * Use it to control density of the grid/labels on the axis.element.\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/axes/positioning-axis-elements/#Setting_the_density_of_the_the_grid_labels} for more info\r\n * @param value Min distance (px)\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"minGridDistance\", value)) {\r\n if (this.axis) {\r\n this.axis.invalidateDataItems();\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisRenderer.prototype, \"chart\", {\r\n /**\r\n * @ignore Exclude from docs\r\n * @return Chart\r\n */\r\n get: function () {\r\n return this._chart.get();\r\n },\r\n /**\r\n * A chart, associated with the Axis.\r\n *\r\n * @ignore Exclude from docs\r\n * @param value Chart\r\n */\r\n set: function (value) {\r\n this._chart.set(value, null);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Toggles visibility of an element, based on its current position and\r\n * min/max position settings.\r\n *\r\n * E.g. labels based on `minLabelPosition` and `maxLabelPosition`.\r\n *\r\n * @ignore Exclude from docs\r\n * @param sprite An element to toggle\r\n * @param position Elements current position\r\n * @param minPosition Min position setting\r\n * @param maxPosition Max position setting\r\n */\r\n AxisRenderer.prototype.toggleVisibility = function (sprite, position, minPosition, maxPosition) {\r\n var axis = this.axis;\r\n var dataItem = sprite.dataItem;\r\n if (dataItem && dataItem instanceof AxisDataItem) {\r\n if ($type.isNumber(dataItem.minPosition)) {\r\n minPosition = dataItem.minPosition;\r\n }\r\n if ($type.isNumber(dataItem.maxPosition)) {\r\n maxPosition = dataItem.maxPosition;\r\n }\r\n }\r\n var updatedStart = axis.start + (axis.end - axis.start) * (minPosition - 0.0001);\r\n var updatedEnd = axis.start + (axis.end - axis.start) * (maxPosition + 0.0001);\r\n if (!sprite.disabled) {\r\n if (position < updatedStart || position > updatedEnd) {\r\n sprite.__disabled = true;\r\n }\r\n else {\r\n sprite.__disabled = false;\r\n }\r\n }\r\n };\r\n /**\r\n * Creates visual elements for and axis break.\r\n *\r\n * @ignore Exclude from docs\r\n * @param axisBreak Axis break\r\n */\r\n AxisRenderer.prototype.createBreakSprites = function (axisBreak) {\r\n // This is a placeholder method for extending classes to override.\r\n };\r\n Object.defineProperty(AxisRenderer.prototype, \"axisFills\", {\r\n /**\r\n * A list of Axis' Fill elements.\r\n *\r\n * Those are fill elements that cover the space between every second set\r\n * of grid lines, and can be configured to create striped charts.\r\n *\r\n * Please note that these are disabled by default. To enable them, set\r\n * template to true.\r\n *\r\n * ```TypeScript\r\n * categoryAxis.renderer.axisFills.template.disabled = false;\r\n * ```\r\n * ```JavaScript\r\n * categoryAxis.renderer.axisFills.template.disabled = false;\r\n * ```\r\n * ```JSON\r\n * {\r\n * // ...\r\n * \"xAxes\": [{\r\n * // ...\r\n * \"renderer\": {\r\n * \"axisFills\": {\r\n * \"disabled\": false\r\n * }\r\n * }\r\n * }]\r\n * }\r\n * ```\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/tutorials/alternated-axis-fills/} this tutorial for more info.\r\n * @return Fill elements\r\n */\r\n get: function () {\r\n if (!this._axisFills) {\r\n var fill = this.createFill(this.axis);\r\n this._axisFills = new ListTemplate(fill);\r\n fill.applyOnClones = true;\r\n fill.events.on(\"enabled\", this.invalidateAxisItems, this, false);\r\n this._disposers.push(new ListDisposer(this._axisFills));\r\n this._disposers.push(this._axisFills.template);\r\n }\r\n return this._axisFills;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Returns a new fill element, suitable for this Axis Renderer type.\r\n *\r\n * @return Fill element\r\n */\r\n AxisRenderer.prototype.createFill = function (axis) {\r\n return new AxisFill(axis);\r\n };\r\n Object.defineProperty(AxisRenderer.prototype, \"grid\", {\r\n /**\r\n * A list of Axis' Grid elements.\r\n *\r\n * @return Grid elements\r\n */\r\n get: function () {\r\n if (!this._grid) {\r\n var grid = this.createGrid();\r\n this._grid = new ListTemplate(grid);\r\n grid.applyOnClones = true;\r\n grid.events.on(\"enabled\", this.invalidateAxisItems, this, false);\r\n this._disposers.push(new ListDisposer(this._grid));\r\n this._disposers.push(this._grid.template);\r\n }\r\n return this._grid;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Returns a new grid element, suitable for this Axis Renderer type.\r\n *\r\n * @return Grid element\r\n */\r\n AxisRenderer.prototype.createGrid = function () {\r\n return new Grid();\r\n };\r\n Object.defineProperty(AxisRenderer.prototype, \"ticks\", {\r\n /**\r\n * A list of Axis' Tick elements.\r\n *\r\n * Please note that these are disabled by default. To enable ticks, you'll\r\n * need to set `disabled` and `strokeOpacity` properties of the tick template.\r\n *\r\n * ```TypeScript\r\n * categoryAxis.renderer.ticks.template.disabled = false;\r\n * categoryAxis.renderer.ticks.template.strokeOpacity = 0.5;\r\n * ```\r\n * ```JavaScript\r\n * categoryAxis.renderer.ticks.template.disabled = false;\r\n * categoryAxis.renderer.ticks.template.strokeOpacity = 0.5;\r\n * ```\r\n * ```JSON\r\n * {\r\n * // ...\r\n * \"xAxes\": [{\r\n * // ...\r\n * \"renderer\": {\r\n * \"ticks\": {\r\n * \"disabled\": false,\r\n * \"strokeOpacity\": 0.5\r\n * }\r\n * }\r\n * }]\r\n * }\r\n * ```\r\n *\r\n * @return Tick elements\r\n */\r\n get: function () {\r\n if (!this._ticks) {\r\n var tick = this.createTick();\r\n tick.applyOnClones = true;\r\n tick.isMeasured = false;\r\n tick.events.on(\"enabled\", this.invalidateAxisItems, this, false);\r\n this._ticks = new ListTemplate(tick);\r\n this._disposers.push(new ListDisposer(this._ticks));\r\n this._disposers.push(this._ticks.template);\r\n }\r\n return this._ticks;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Returns a new tick element, suitable for this Axis Renderer type.\r\n *\r\n * @return Tick element\r\n */\r\n AxisRenderer.prototype.createTick = function () {\r\n return new AxisTick();\r\n };\r\n Object.defineProperty(AxisRenderer.prototype, \"labels\", {\r\n /**\r\n * A list of Axis' Label elements.\r\n *\r\n * @return Label elements\r\n */\r\n get: function () {\r\n if (!this._labels) {\r\n var label = this.createLabel();\r\n this._labels = new ListTemplate(label);\r\n label.applyOnClones = true;\r\n label.events.on(\"enabled\", this.invalidateAxisItems, this, false);\r\n this._disposers.push(new ListDisposer(this._labels));\r\n this._disposers.push(this._labels.template);\r\n }\r\n return this._labels;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Returns a new label element, suitable for this Axis Renderer type.\r\n *\r\n * @return Label element\r\n */\r\n AxisRenderer.prototype.createLabel = function () {\r\n return new AxisLabel();\r\n };\r\n Object.defineProperty(AxisRenderer.prototype, \"inside\", {\r\n /**\r\n * @return Labels inside?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"inside\");\r\n },\r\n /**\r\n * Indicates whether Axis' labels and ticks should be drawn inside Plot area.\r\n *\r\n * Does not work with all renderers, like AxisRendererRadial.\r\n *\r\n * @param value Labels inside?\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"inside\", value)) {\r\n if (this.axis) {\r\n this.axis.invalidate();\r\n }\r\n }\r\n if (value) {\r\n this.width = 0;\r\n this.height = 0;\r\n }\r\n else {\r\n this.width = undefined;\r\n this.height = undefined;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisRenderer.prototype, \"opposite\", {\r\n /**\r\n * @return Draw axis on opposite side?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"opposite\");\r\n },\r\n /**\r\n * Indicates whether Axis should be drawn on the opposite side of the plot\r\n * area than it would normally be drawn based on chart's settings.\r\n *\r\n * Does not work with all renderers, like [[AxisRendererRadial]] and\r\n * [[AxisRenderer Circular].\r\n *\r\n * @param value Draw axis on opposite side?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"opposite\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisRenderer.prototype, \"fullWidthTooltip\", {\r\n /**\r\n * @return Full width tooltip?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"fullWidthTooltip\");\r\n },\r\n /**\r\n * Indicates if Axis tooltip should take the whole width of the axis cell.\r\n * (between two grid lines)\r\n *\r\n * NOTE: this setting is ignored on circular axis types.\r\n *\r\n * @param value Full width tooltip?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"fullWidthTooltip\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisRenderer.prototype, \"tooltipLocation\", {\r\n /**\r\n * @return Tooltip location\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"tooltipLocation\");\r\n },\r\n /**\r\n * Location within axis cell to show tooltip on. (0-1)\r\n *\r\n * 0 - show at the start\r\n * 0.5 - show right in the middle\r\n * 1 - show at the end\r\n *\r\n * @param value Tooltip location\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"tooltipLocation\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisRenderer.prototype, \"tooltipLocation2\", {\r\n /**\r\n * @return Tooltip location\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"tooltipLocation2\");\r\n },\r\n /**\r\n * Location within secondary axis cell to show tooltip on. (0-1)\r\n *\r\n * 0 - show at the start\r\n * 0.5 - show right in the middle\r\n * 1 - show at the end\r\n *\r\n * @param value Tooltip location\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"tooltipLocation2\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisRenderer.prototype, \"cellStartLocation\", {\r\n /**\r\n * @return Cell start (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"cellStartLocation\");\r\n },\r\n /**\r\n * Location for the cell start.\r\n *\r\n * Normally a \"cell\" is the whole available width in a category.\r\n *\r\n * If there are several clustered column-like series available, the whole\r\n * space is divided between each clustered column, or column stacks.\r\n *\r\n * `cellStartLocation` identifies where, within available space, the actual\r\n * cell starts.\r\n *\r\n * This, together with column series' `width` will affect actual width of\r\n * columns, and thus gaps between them.\r\n *\r\n * This will affect category-like axes only, like [[DateAxis]], or\r\n * [[CategoryAxis]].\r\n *\r\n * This is used to limit a space occupied by series like column.\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/axes/positioning-axis-elements/} for more info.\r\n * @param value Cell start (0-1)\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"cellStartLocation\", value)) {\r\n if (this.axis) {\r\n this.axis.invalidateSeries();\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisRenderer.prototype, \"cellEndLocation\", {\r\n /**\r\n * @return Cell end (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"cellEndLocation\");\r\n },\r\n /**\r\n * Location for the cell end.\r\n *\r\n * Normally a \"cell\" is the whole available width in a category.\r\n *\r\n * If there are several clustered column-like series available, the whole\r\n * space is divided between each clustered column, or column stacks.\r\n *\r\n * `cellEndLocation` identifies where, within available space, the actual\r\n * cell ends.\r\n *\r\n * This, together with column series' `width` will affect actual width of\r\n * columns, and thus gaps between them.\r\n *\r\n * This will affect category-like axes only, like [[DateAxis]], or\r\n * [[CategoryAxis]].\r\n *\r\n * This is used to limit a space occupied by series like column.\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/axes/positioning-axis-elements/} for more info.\r\n * @param value Cell end (0-1)\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"cellEndLocation\", value)) {\r\n if (this.axis) {\r\n this.axis.invalidateSeries();\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisRenderer.prototype, \"inversed\", {\r\n /**\r\n * @return Flip axis?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"inversed\");\r\n },\r\n /**\r\n * Indicates if the scale of the axis should be flipped.\r\n *\r\n * @param value Flip axis?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"inversed\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisRenderer.prototype, \"minLabelPosition\", {\r\n /**\r\n * @return Min label position (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"minLabelPosition\");\r\n },\r\n /**\r\n * Minimum position along the Axis, for labels.\r\n *\r\n * Labels, which have their position closer to the start of the Axis, will be\r\n * automatically hidden.\r\n *\r\n * E.g., setting this to 0.05 (5% of total axis length) would hide labels,\r\n * that would otherwise be drawn very near start of the Axis.\r\n *\r\n * This is especially usefull with `inside = true`, or if the chart hasn't\r\n * got any extra margins.\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/axes/positioning-axis-elements/} for more info.\r\n * @param value Min label position (0-1)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"minLabelPosition\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AxisRenderer.prototype, \"maxLabelPosition\", {\r\n /**\r\n * @return Max label position (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"maxLabelPosition\");\r\n },\r\n /**\r\n * Maximum position along the Axis, for labels.\r\n *\r\n * Labels, which have their position closer to the and of the Axis, will be\r\n * automatically hidden.\r\n *\r\n * E.g., setting this to 0.95 (95% of total axis length) would hide labels,\r\n * that would otherwise be drawn very near end of the Axis.\r\n *\r\n * This is especially usefull with `inside = true`, or if the chart hasn't\r\n * got any extra margins.\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/axes/positioning-axis-elements/} for more info.\r\n * @param value Max label position (0-1)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"maxLabelPosition\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Copies all settings and related items from another object of the same\r\n * type.\r\n *\r\n * @param source Source object\r\n */\r\n AxisRenderer.prototype.copyFrom = function (source) {\r\n _super.prototype.copyFrom.call(this, source);\r\n this.grid.template.copyFrom(source.grid.template);\r\n this.ticks.template.copyFrom(source.ticks.template);\r\n this.labels.template.copyFrom(source.labels.template);\r\n this.axisFills.template.copyFrom(source.axisFills.template);\r\n this.line.copyFrom(source.line);\r\n this.baseGrid.copyFrom(source.baseGrid);\r\n };\r\n /**\r\n * @ignore\r\n */\r\n AxisRenderer.prototype.toAxisPosition = function (value) {\r\n return value;\r\n };\r\n /**\r\n * Sets `visibility` property:\r\n *\r\n * * `true` - visible\r\n * * `false` - hidden\r\n *\r\n * @param value true - visible, false - hidden\r\n * @return Current visibility\r\n */\r\n AxisRenderer.prototype.setVisibility = function (value) {\r\n _super.prototype.setVisibility.call(this, value);\r\n this.bulletsContainer.visible = value;\r\n };\r\n return AxisRenderer;\r\n}(Container));\r\nexport { AxisRenderer };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"AxisRenderer\"] = AxisRenderer;\r\n//# sourceMappingURL=AxisRenderer.js.map","/**\r\n * Axis Bullet module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../../core/Container\";\r\nimport { registry } from \"../../core/Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Used to draw a positioned bullet (element) on an Axis.\r\n *\r\n * ```TypeScript\r\n * let range = dateAxis.axisRanges.create();\r\n * range.date = new Date(2018, 0, 5);\r\n *\r\n * let flag = new am4plugins_bullets.FlagBullet();\r\n * flag.label.text = \"Hello\";\r\n *\r\n * range.bullet = flag;\r\n * ```\r\n * ```JavaScript\r\n * var range = dateAxis.axisRanges.create();\r\n * range.date = new Date(2018, 0, 5);\r\n *\r\n * var flag = new am4plugins_bullets.FlagBullet();\r\n * flag.label.text = \"Hello\";\r\n *\r\n * range.bullet = flag;\r\n * ```\r\n * ```JSON\r\n * {\r\n * // ...\r\n * \"xAxes\": [{\r\n * \"type\": \"DateAxis\",\r\n * // ...\r\n * \"axisRanges\": [{\r\n * \"date\": new Date(2018, 0, 5),\r\n * \"bullet: {\r\n * \"type\": \"FlagBullet\",\r\n * \"label\": {\r\n * \"text\": \"Hello\"\r\n * }\r\n * }\r\n * }]\r\n * }]\r\n * }\r\n * ```\r\n *\r\n * @since 4.5.9\r\n * @see {@link IAxisBulletEvents} for a list of available events\r\n * @see {@link IAxisBulletAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar AxisBullet = /** @class */ (function (_super) {\r\n __extends(AxisBullet, _super);\r\n function AxisBullet() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"AxisBullet\";\r\n _this.location = 0.5;\r\n _this.isMeasured = false;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(AxisBullet.prototype, \"location\", {\r\n /**\r\n * @return Location (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"location\");\r\n },\r\n /**\r\n * Relative position within cell/range.\r\n *\r\n * Value range is from from `0` (beginning) to `1` (end).\r\n *\r\n * NOTE: `location` is relative to the parent axis range's scope, i.e.\r\n * between its `date` and `endDate` for [[DateAxis]], or `value`/`endValue`\r\n * ([[ValueAxis]]), or `category`/`endCategory` ([[categoryAxis]]).\r\n *\r\n * ```TypeScript\r\n * let range = dateAxis.axisRanges.create();\r\n * range.date = new Date(2018, 0, 5);\r\n * range.endDate = new Date(2018, 0, 6);\r\n *\r\n * let bullet = new am4charts.AxisBullet();\r\n * bullet.location = 1;\r\n *\r\n * let flag = bullet.createChild(am4plugins_bullets.FlagBullet);\r\n * flag.label.text = \"Hello\";\r\n * ```\r\n * ```JavaScript\r\n * var range = dateAxis.axisRanges.create();\r\n * range.date = new Date(2018, 0, 5);\r\n * range.endDate = new Date(2018, 0, 6);\r\n *\r\n * var bullet = new am4charts.AxisBullet();\r\n * bullet.location = 1;\r\n *\r\n * var flag = bullet.createChild(am4plugins_bullets.FlagBullet);\r\n * flag.label.text = \"Hello\";\r\n * ```\r\n * ```JSON\r\n * {\r\n * // ...\r\n * \"xAxes\": [{\r\n * \"type\": \"DateAxis\",\r\n * // ...\r\n * \"axisRanges\": [{\r\n * \"date\": new Date(2018, 0, 5),\r\n * \"endDate\": new Date(2018, 0, 6),\r\n * \"bullet: {\r\n * \"type\": \"AxisBullet\",\r\n * \"location\": 1,\r\n * \"children\": [{\r\n * \"type\": \"FlagBullet\",\r\n * \"label\": {\r\n * \"text\": \"Hello\"\r\n * }\r\n * }]\r\n * }\r\n * }]\r\n * }]\r\n * }\r\n * ```\r\n *\r\n * @default 0.5\r\n * @param value Location (0-1)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"location\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * @ignore\r\n */\r\n AxisBullet.prototype.setDisabled = function (value) {\r\n var changed = _super.prototype.setDisabled.call(this, value);\r\n if (this.axis) {\r\n this.axis.invalidateDataItems();\r\n }\r\n return changed;\r\n };\r\n return AxisBullet;\r\n}(Container));\r\nexport { AxisBullet };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"AxisBullet\"] = AxisBullet;\r\n//# sourceMappingURL=AxisBullet.js.map","/**\r\n * Module, defining Axis Renderer for vertical axes.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { AxisRenderer } from \"./AxisRenderer\";\r\nimport { WavedLine } from \"../../core/elements/WavedLine\";\r\nimport { WavedRectangle } from \"../../core/elements/WavedRectangle\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { percent, Percent } from \"../../core/utils/Percent\";\r\nimport * as $math from \"../../core/utils/Math\";\r\nimport * as $path from \"../../core/rendering/Path\";\r\nimport * as $utils from \"../../core/utils/Utils\";\r\nimport * as $type from \"../../core/utils/Type\";\r\nimport { defaultRules, ResponsiveBreakpoints } from \"../../core/utils/Responsive\";\r\nimport { AxisBullet } from \"./AxisBullet\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A renderer for vertical axis.\r\n *\r\n * @see {@link IAxisRendererYEvents} for a list of available events\r\n * @see {@link IAxisRendererYAdapters} for a list of available Adapters\r\n */\r\nvar AxisRendererY = /** @class */ (function (_super) {\r\n __extends(AxisRendererY, _super);\r\n /**\r\n * Constructor.\r\n *\r\n * @param axis Related axis\r\n */\r\n function AxisRendererY() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"AxisRendererY\";\r\n _this.minGridDistance = 40;\r\n _this.opposite = false;\r\n _this.height = percent(100);\r\n _this.labels.template.verticalCenter = \"middle\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * @ignore\r\n */\r\n AxisRendererY.prototype.setAxis = function (axis) {\r\n _super.prototype.setAxis.call(this, axis);\r\n axis.layout = \"horizontal\";\r\n };\r\n /**\r\n * @ignore\r\n */\r\n AxisRendererY.prototype.updateGridContainer = function () {\r\n var axis = this.axis;\r\n if (axis) {\r\n var gridContainer = this.gridContainer;\r\n gridContainer.y = axis.pixelY;\r\n gridContainer.height = axis.axisLength;\r\n }\r\n };\r\n /**\r\n * @ignore\r\n */\r\n AxisRendererY.prototype.toAxisPosition = function (value) {\r\n var axis = this.axis;\r\n if (axis) {\r\n var inversedPosition = 1 - value;\r\n var relativePositionSprite = axis.relativePositionSprite;\r\n var y = axis.pixelY;\r\n if (relativePositionSprite) {\r\n y = $utils.spritePointToSprite({ x: 0, y: this.pixelY }, this.parent, relativePositionSprite).y;\r\n }\r\n else {\r\n relativePositionSprite = axis.parent;\r\n }\r\n if (relativePositionSprite) {\r\n var relativeY = y / relativePositionSprite.innerHeight;\r\n var relativeHeight = axis.axisLength / relativePositionSprite.innerHeight;\r\n return 1 - (inversedPosition - relativeY) / relativeHeight;\r\n }\r\n }\r\n return value;\r\n };\r\n /**\r\n * Called when rendered is attached to an Axis, as well as a property of\r\n * Axis that might affect the appearance is updated.\r\n *\r\n * E.g. `axis.opposite`, `axis.inside`, etc.\r\n *\r\n * This method is called **before** draw, so that any related setting\r\n * changed in this method can be changed.\r\n *\r\n * @todo Description (review)\r\n * @ignore Exclude from docs\r\n */\r\n AxisRendererY.prototype.processRenderer = function () {\r\n _super.prototype.processRenderer.call(this);\r\n var axis = this.axis;\r\n if (axis) {\r\n var title = axis.title;\r\n title.valign = \"middle\";\r\n if (!(axis.height instanceof Percent)) {\r\n axis.height = percent(100);\r\n }\r\n if (this.opposite) {\r\n title.rotation = 90;\r\n this.line.toBack();\r\n title.toFront();\r\n }\r\n else {\r\n title.rotation = -90;\r\n title.toBack();\r\n this.line.toFront();\r\n }\r\n }\r\n };\r\n /**\r\n * Updates some of the Axis tooltip's visual properties, related to\r\n * rendering of the Axis.\r\n *\r\n * @todo Description (review)\r\n * @ignore Exclude from docs\r\n */\r\n AxisRendererY.prototype.updateTooltip = function () {\r\n var axis = this.axis;\r\n if (axis) {\r\n var bigNum = 2000;\r\n var bbx = 0;\r\n var bby = 0;\r\n var bbw = bigNum;\r\n var bbh = this.axisLength;\r\n // right\r\n if (this.opposite) {\r\n if (this.inside) {\r\n bbx = -bigNum;\r\n bbw = bigNum;\r\n }\r\n }\r\n // left\r\n else {\r\n if (!this.inside) {\r\n bbx = -bigNum;\r\n bbw = bigNum;\r\n }\r\n }\r\n this.axis.updateTooltip(\"horizontal\", { x: bbx, y: bby, width: bbw, height: bbh });\r\n }\r\n };\r\n Object.defineProperty(AxisRendererY.prototype, \"axisLength\", {\r\n /**\r\n * Returns actual length of the Axis, in pixels.\r\n *\r\n * @return Length (px)\r\n */\r\n get: function () {\r\n var axis = this.axis;\r\n return (axis.measuredHeight - axis.pixelPaddingTop - axis.pixelPaddingBottom) || 0;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Converts relative position on axis to point coordinates.\r\n *\r\n * @param position Position (0-1)\r\n * @param position2 Position (0-1) Position on the second axis\r\n * @return Point\r\n */\r\n AxisRendererY.prototype.positionToPoint = function (position, position2) {\r\n return { x: 0, y: this.positionToCoordinate(position) };\r\n };\r\n /**\r\n * Converts a point at specific coordinates to a relative position (0-1)\r\n * on the axis.\r\n *\r\n * @param point Point\r\n * @return Position (0-1)\r\n */\r\n AxisRendererY.prototype.pointToPosition = function (point) {\r\n return this.coordinateToPosition(point.y, point.x);\r\n };\r\n /**\r\n * Converts a coordinate in pixels to a relative position. (0-1)\r\n *\r\n * @param coordinate Coordinate (px)\r\n * @param coordinate2 Coordinate of a second axis, only needed for complex axes systems, like timeline (px)\r\n * @return Position (0-1)\r\n */\r\n AxisRendererY.prototype.coordinateToPosition = function (coordinate, coordinate2) {\r\n var position;\r\n var axis = this.axis;\r\n var axisFullLength = axis.axisFullLength;\r\n if (axis.renderer.inversed) {\r\n position = (1 - axis.start) - coordinate / axisFullLength;\r\n }\r\n else {\r\n position = coordinate / axisFullLength + (1 - axis.end);\r\n }\r\n return $math.round(position, 5);\r\n };\r\n /**\r\n * [getPositionRangePath description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param startPosition Starting position\r\n * @param endPosition End position\r\n * @return SVG path\r\n */\r\n AxisRendererY.prototype.getPositionRangePath = function (startPosition, endPosition) {\r\n var y1 = $math.fitToRange(this.positionToCoordinate(startPosition), 0, this.axisLength);\r\n var y2 = $math.fitToRange(this.positionToCoordinate(endPosition), 0, this.axisLength);\r\n var h = Math.abs(y2 - y1);\r\n var w = this.getWidth();\r\n var y = Math.min(y1, y2);\r\n var x = 0;\r\n return $path.rectToPath({\r\n x: x,\r\n y: y,\r\n width: w,\r\n height: h\r\n }, true);\r\n };\r\n /**\r\n * Updates and positions a grid element.\r\n *\r\n * @ignore Exclude from docs\r\n * @param grid Grid element\r\n * @param position Starting position\r\n * @param endPosition End position\r\n */\r\n AxisRendererY.prototype.updateGridElement = function (grid, position, endPosition) {\r\n position = position + (endPosition - position) * grid.location;\r\n var point = this.positionToPoint(position);\r\n //\tpoint.y = $utils.spritePointToSprite({ x: 0, y: point.y }, this, this.gridContainer).y;\r\n grid.path = $path.moveTo({ x: 0, y: 0 }) + $path.lineTo({ x: this.getWidth(), y: 0 });\r\n this.positionItem(grid, point);\r\n this.toggleVisibility(grid, position, 0, 1);\r\n };\r\n /**\r\n * Updates and positions a tick element.\r\n *\r\n * @ignore Exclude from docs\r\n * @param tick Tick element\r\n * @param position Starting position\r\n * @param endPosition End position\r\n */\r\n AxisRendererY.prototype.updateTickElement = function (tick, position, endPosition) {\r\n position = position + (endPosition - position) * tick.location;\r\n var point = this.positionToPoint(position);\r\n var tickLength = tick.length;\r\n try {\r\n $utils.used(this.axis.title.measuredWidth);\r\n }\r\n catch (_a) {\r\n // void\r\n }\r\n point.x = $utils.spritePointToSprite({ x: this.line.pixelX, y: 0 }, this.line.parent, this.gridContainer).x;\r\n if (!this.opposite) {\r\n tickLength *= (tick.inside ? 1 : -1);\r\n }\r\n else {\r\n tickLength *= (tick.inside ? -1 : 1);\r\n }\r\n tick.path = $path.moveTo({ x: 0, y: 0 }) + $path.lineTo({ x: tickLength, y: 0 });\r\n this.positionItem(tick, point);\r\n this.toggleVisibility(tick, position, 0, 1);\r\n };\r\n /**\r\n * Updates and positions the axis line element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n AxisRendererY.prototype.updateAxisLine = function () {\r\n this.line.path = $path.moveTo({ x: 0, y: 0 }) + $path.lineTo({ x: 0, y: this.axisLength });\r\n };\r\n /**\r\n * Updates and positions the base grid element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n AxisRendererY.prototype.updateBaseGridElement = function () {\r\n _super.prototype.updateBaseGridElement.call(this);\r\n var axis = this.axis;\r\n var w = this.getWidth();\r\n var h = this.axisLength;\r\n var y = axis.basePoint.y;\r\n var baseGrid = this.baseGrid;\r\n if (y < -0.2 || y > h + 0.2) {\r\n baseGrid.hide(0);\r\n }\r\n else {\r\n var x = $utils.spritePointToSprite({ x: 0, y: 0 }, this.gridContainer, baseGrid.parent).x;\r\n baseGrid.path = $path.moveTo({ x: 0, y: 0 }) + $path.lineTo({ x: w, y: 0 });\r\n baseGrid.moveTo({ x: x, y: y });\r\n baseGrid.show(0);\r\n }\r\n };\r\n /**\r\n * Updates and positions a label element.\r\n *\r\n * @ignore Exclude from docs\r\n * @param label Label element\r\n * @param position Starting position\r\n * @param endPosition Ending position\r\n */\r\n AxisRendererY.prototype.updateLabelElement = function (label, position, endPosition, location) {\r\n if (!$type.hasValue(location)) {\r\n location = label.location;\r\n }\r\n position = position + (endPosition - position) * location;\r\n label.isMeasured = !label.inside;\r\n var point = this.positionToPoint(position);\r\n var horizontalCenter;\r\n var deltaX = 0;\r\n var maxWidth = this.gridContainer.maxWidth;\r\n if (this.opposite) {\r\n if (label.inside) {\r\n horizontalCenter = \"right\";\r\n if (label.align == \"left\") {\r\n deltaX = -maxWidth;\r\n horizontalCenter = \"left\";\r\n }\r\n if (label.align == \"center\") {\r\n deltaX = -maxWidth / 2;\r\n horizontalCenter = \"middle\";\r\n }\r\n }\r\n else {\r\n horizontalCenter = \"left\";\r\n }\r\n point.x = 0 + deltaX;\r\n }\r\n else {\r\n if (label.inside) {\r\n horizontalCenter = \"left\";\r\n if (label.align == \"right\") {\r\n deltaX = maxWidth;\r\n horizontalCenter = \"right\";\r\n }\r\n if (label.align == \"center\") {\r\n deltaX = maxWidth / 2;\r\n horizontalCenter = \"middle\";\r\n }\r\n }\r\n else {\r\n horizontalCenter = \"right\";\r\n }\r\n point.x = this.measuredWidth + deltaX;\r\n }\r\n if (label.rotation == 0) {\r\n // Apply fuzzy logic to verticalCenter only if labels are not rotated\r\n label.horizontalCenter = horizontalCenter;\r\n }\r\n this.positionItem(label, point);\r\n this.toggleVisibility(label, position, this.minLabelPosition, this.maxLabelPosition);\r\n };\r\n /**\r\n * Updates and positions an axis break element.\r\n *\r\n * @ignore Exclude from docs\r\n * @param axisBreak Break element\r\n */\r\n AxisRendererY.prototype.updateBreakElement = function (axisBreak) {\r\n _super.prototype.updateBreakElement.call(this, axisBreak);\r\n var startLine = axisBreak.startLine;\r\n var endLine = axisBreak.endLine;\r\n var fillShape = axisBreak.fillShape;\r\n var startPoint = axisBreak.startPoint;\r\n var endPoint = axisBreak.endPoint;\r\n var x1 = axisBreak.pixelMarginLeft;\r\n var x2 = this.getWidth() - axisBreak.pixelMarginLeft - axisBreak.pixelMarginRight;\r\n startPoint.y = $math.fitToRange(startPoint.y, -1, this.axisLength + 1);\r\n endPoint.y = $math.fitToRange(endPoint.y, -1, this.axisLength + 1);\r\n if (startPoint.y == endPoint.y && (startPoint.y < 0 || startPoint.y > this.axisLength)) {\r\n axisBreak.fillShape.__disabled = true;\r\n }\r\n else {\r\n axisBreak.fillShape.__disabled = false;\r\n }\r\n var w = Math.abs(x2 - x1);\r\n startLine.x = x1;\r\n startLine.height = 0;\r\n startLine.width = w;\r\n endLine.x = x1;\r\n endLine.height = 0;\r\n endLine.width = w;\r\n fillShape.width = w;\r\n fillShape.height = Math.abs(endPoint.y - startPoint.y);\r\n fillShape.x = x1;\r\n fillShape.y = endPoint.y;\r\n };\r\n /**\r\n * Creates visual elements for and axis break.\r\n *\r\n * @ignore Exclude from docs\r\n * @param axisBreak Axis break\r\n */\r\n AxisRendererY.prototype.createBreakSprites = function (axisBreak) {\r\n axisBreak.startLine = new WavedLine();\r\n axisBreak.endLine = new WavedLine();\r\n var wavedRectangle = new WavedRectangle();\r\n wavedRectangle.setWavedSides(true, false, true, false);\r\n axisBreak.fillShape = wavedRectangle;\r\n };\r\n /**\r\n * Converts a position on the axis to a coordinate in pixels.\r\n *\r\n * @ignore Exclude from docs\r\n * @param position Position (0-1)\r\n * @return Coordinate (px)\r\n */\r\n AxisRendererY.prototype.positionToCoordinate = function (position) {\r\n var coordinate;\r\n var axis = this.axis;\r\n var axisFullLength = axis.axisFullLength;\r\n if (!axis.renderer.inversed) {\r\n coordinate = (axis.end - position) * axisFullLength;\r\n }\r\n else {\r\n coordinate = (position - axis.start) * axisFullLength;\r\n }\r\n return coordinate;\r\n };\r\n /**\r\n * Updates and positions axis bullets.\r\n *\r\n * @ignore Exclude from docs\r\n * @param bullet AxisBullet element\r\n * @param position Starting position\r\n * @param endPosition End position\r\n */\r\n AxisRendererY.prototype.updateBullet = function (bullet, position, endPosition) {\r\n var location = 0.5;\r\n if (bullet instanceof AxisBullet) {\r\n location = bullet.location;\r\n }\r\n position = position + (endPosition - position) * location;\r\n var point = this.positionToPoint(position);\r\n point.x = $utils.spritePointToSprite({ x: this.line.pixelX, y: 0 }, this.line.parent, this.gridContainer).x;\r\n this.positionItem(bullet, point);\r\n this.toggleVisibility(bullet, position, 0, 1);\r\n };\r\n return AxisRendererY;\r\n}(AxisRenderer));\r\nexport { AxisRendererY };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"AxisRendererY\"] = AxisRendererY;\r\n/**\r\n * Add default responsive rules\r\n */\r\n/**\r\n * Put labels inside plot area.\r\n * Disable first and last labels.\r\n */\r\ndefaultRules.push({\r\n relevant: ResponsiveBreakpoints.widthS,\r\n state: function (target, stateId) {\r\n if (target instanceof AxisRendererY) {\r\n var state = target.states.create(stateId);\r\n state.properties.inside = true;\r\n state.properties.maxLabelPosition = 0.9;\r\n state.properties.minLabelPosition = 0.1;\r\n return state;\r\n }\r\n return null;\r\n }\r\n});\r\n/**\r\n * Disable labels altogather on very small charts\r\n */\r\ndefaultRules.push({\r\n relevant: ResponsiveBreakpoints.widthXS,\r\n state: function (target, stateId) {\r\n if (target instanceof AxisRendererY) {\r\n var state = target.states.create(stateId);\r\n state.properties.disabled = true;\r\n return state;\r\n }\r\n return null;\r\n }\r\n});\r\n//# sourceMappingURL=AxisRendererY.js.map","/**\r\n * A module which defines functionality related to Value Axis Break.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { AxisBreak } from \"./AxisBreak\";\r\nimport { registry } from \"../../core/Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Base class to define \"breaks\" on value axis.\r\n *\r\n * A \"break\" can be used to \"cut out\" specific ranges of the axis scale, e.g.\r\n * when comparing columns with relatively similar values, it would make sense\r\n * to cut out their mid section, so that their tip differences are more\r\n * prominent.\r\n *\r\n * @see {@link IValueAxisBreakEvents} for a list of available events\r\n * @see {@link IValueAxisBreakAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar ValueAxisBreak = /** @class */ (function (_super) {\r\n __extends(ValueAxisBreak, _super);\r\n /**\r\n * Constructor\r\n */\r\n function ValueAxisBreak() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"ValueAxisBreak\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(ValueAxisBreak.prototype, \"startPosition\", {\r\n /**\r\n * Pixel position of the break's start.\r\n *\r\n * @return Position (px)\r\n * @readonly\r\n */\r\n get: function () {\r\n if (this.axis) {\r\n return this.axis.valueToPosition(this.adjustedStartValue);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxisBreak.prototype, \"endPosition\", {\r\n /**\r\n * Pixel position of the break's end.\r\n *\r\n * @return Position (px)\r\n * @readonly\r\n */\r\n get: function () {\r\n if (this.axis) {\r\n return this.axis.valueToPosition(this.adjustedEndValue);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return ValueAxisBreak;\r\n}(AxisBreak));\r\nexport { ValueAxisBreak };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"ValueAxisBreak\"] = ValueAxisBreak;\r\n//# sourceMappingURL=ValueAxisBreak.js.map","/**\r\n * Value Axis module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Axis, AxisDataItem } from \"./Axis\";\r\nimport { AxisRendererY } from \"./AxisRendererY\";\r\nimport { MultiDisposer } from \"../../core/utils/Disposer\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { ValueAxisBreak } from \"./ValueAxisBreak\";\r\nimport * as $math from \"../../core/utils/Math\";\r\nimport * as $iter from \"../../core/utils/Iterator\";\r\nimport * as $object from \"../../core/utils/Object\";\r\nimport * as $type from \"../../core/utils/Type\";\r\nimport * as $utils from \"../../core/utils/Utils\";\r\n/**\r\n * ============================================================================\r\n * DATA ITEM\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines a [[DataItem]] for [[ValueAxis]].\r\n *\r\n * @see {@link DataItem}\r\n */\r\nvar ValueAxisDataItem = /** @class */ (function (_super) {\r\n __extends(ValueAxisDataItem, _super);\r\n /**\r\n * Constructor\r\n */\r\n function ValueAxisDataItem() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"ValueAxisDataItem\";\r\n _this.values.value = {};\r\n _this.values.endValue = {};\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(ValueAxisDataItem.prototype, \"value\", {\r\n /**\r\n * @return Value\r\n */\r\n get: function () {\r\n return this.values[\"value\"].value;\r\n },\r\n /**\r\n * A data point's numeric value.\r\n *\r\n * @param value Value\r\n */\r\n set: function (value) {\r\n this.setValue(\"value\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxisDataItem.prototype, \"endValue\", {\r\n /**\r\n * @return Value\r\n */\r\n get: function () {\r\n return this.values[\"endValue\"].value;\r\n },\r\n /**\r\n * Data point's numeric end value.\r\n *\r\n * @param value End value\r\n */\r\n set: function (value) {\r\n this.setValue(\"endValue\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return ValueAxisDataItem;\r\n}(AxisDataItem));\r\nexport { ValueAxisDataItem };\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Used to create a value axis for the chart.\r\n *\r\n * ```TypeScript\r\n * // Create the axis\r\n * let valueAxis = chart.yAxes.push(new am4charts.ValueAxis());\r\n *\r\n * // Set settings\r\n * valueAxis.title.text = \"Monthly Sales\";\r\n * ```\r\n * ```JavaScript\r\n * // Create the axis\r\n * var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());\r\n *\r\n * // Set settings\r\n * valueAxis.title.text = \"Monthly Sales\";\r\n * ```\r\n * ```JSON\r\n * \"yAxes\": [{\r\n * \"type\": \"ValueAxis\",\r\n * \"title\": {\r\n * \"text\": \"Monthly Sales\"\r\n * }\r\n * }]\r\n * ```\r\n *\r\n * @see {@link IValueAxisEvents} for a list of available Events\r\n * @see {@link IValueAxisAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar ValueAxis = /** @class */ (function (_super) {\r\n __extends(ValueAxis, _super);\r\n /**\r\n * Constructor\r\n */\r\n function ValueAxis() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n /**\r\n * [_stepDecimalPlaces description]\r\n *\r\n * @todo Description\r\n */\r\n _this._stepDecimalPlaces = 0;\r\n _this._prevStepDecimalPlaces = 0;\r\n _this._adjustLabelPrecision = true;\r\n /**\r\n * Base value for the axis.\r\n */\r\n _this._baseValue = 0;\r\n /**\r\n * Adjusted start in case we have breaks.\r\n *\r\n * @todo Description\r\n */\r\n _this._adjustedStart = 0;\r\n /**\r\n * Adjusted end in case we have breaks.\r\n *\r\n * @todo Description\r\n */\r\n _this._adjustedEnd = 1;\r\n _this._extremesChanged = false;\r\n _this._deltaMinMax = 1;\r\n _this._dsc = false;\r\n /**\r\n * As calculating totals is expensive operation and not often needed, we\r\n * don't do it by default.\r\n *\r\n * In case you use `totalPercent` or `total` in your charts, this must be set\r\n * to `true`.\r\n *\r\n * @default false\r\n * @see {@link https://www.amcharts.com/docs/v4/chart-types/xy-chart/#100_stacks} For using `calculateTotals` for 100% stacked series.\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/formatters/formatting-strings/#Placeholders_for_numeric_values} For using `calculateTotals` in labels.\r\n */\r\n _this.calculateTotals = false;\r\n _this.className = \"ValueAxis\";\r\n // Set field name\r\n _this.axisFieldName = \"value\";\r\n // Set defaults\r\n _this.setPropertyValue(\"maxZoomFactor\", 1000);\r\n _this.setPropertyValue(\"extraMin\", 0);\r\n _this.setPropertyValue(\"extraMax\", 0);\r\n _this.setPropertyValue(\"strictMinMax\", false);\r\n _this.setPropertyValue(\"maxPrecision\", Number.MAX_VALUE);\r\n _this.setPropertyValue(\"adjustLabelPrecision\", true);\r\n _this.setPropertyValue(\"extraTooltipPrecision\", 0);\r\n _this.keepSelection = false;\r\n _this.includeRangesInMinMax = false;\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Holds reference to a function that accepts a DataItem as parameter.\r\n *\r\n * It can either return a fill opacity for a fill, or manipulate data item\r\n * directly, to create various highlighting scenarios.\r\n */\r\n ValueAxis.prototype.fillRule = function (dataItem) {\r\n var value = dataItem.value;\r\n var axis = dataItem.component;\r\n if (!dataItem.axisFill.disabled) {\r\n // rounding in left to solve floating point number\r\n if ($math.round(value / axis.step / 2, 5) == Math.round(value / axis.step / 2)) {\r\n dataItem.axisFill.__disabled = true;\r\n }\r\n else {\r\n dataItem.axisFill.__disabled = false;\r\n }\r\n }\r\n };\r\n /**\r\n * Returns a new/empty [[DataItem]] of the type appropriate for this object.\r\n *\r\n * @see {@link DataItem}\r\n * @return Data Item\r\n */\r\n ValueAxis.prototype.createDataItem = function () {\r\n return new ValueAxisDataItem();\r\n };\r\n /**\r\n * Returns a new/empty [[AxisBreak]] of the appropriate type.\r\n *\r\n * @return Axis break\r\n */\r\n ValueAxis.prototype.createAxisBreak = function () {\r\n return new ValueAxisBreak();\r\n };\r\n /**\r\n * [dataChangeUpdate description]\r\n *\r\n * This is a placeholder to override for extending classes.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n */\r\n ValueAxis.prototype.dataChangeUpdate = function () {\r\n this.clearCache();\r\n if (!this.keepSelection) {\r\n if (this._start != 0 || this._end != 1) {\r\n this._start = 0;\r\n this._end = 1;\r\n this.dispatchImmediately(\"startendchanged\");\r\n }\r\n }\r\n else {\r\n if (this._start != 0) {\r\n this.dispatchImmediately(\"startchanged\");\r\n }\r\n if (this._end != 1) {\r\n this.dispatchImmediately(\"endchanged\");\r\n }\r\n if (this._start != 0 || this._end != 1) {\r\n this.dispatchImmediately(\"startendchanged\");\r\n }\r\n }\r\n this._maxZoomed = this._maxDefined;\r\n this._minZoomed = this._minDefined;\r\n this._maxAdjusted = this._maxDefined;\r\n this._minAdjusted = this._minDefined;\r\n };\r\n /**\r\n * Processes data items of the related Series.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n ValueAxis.prototype.processSeriesDataItems = function () {\r\n // @todo: add some boolean (maybe autodedect) if we need these calculations or not. this place uses a lot of cpu\r\n if (this.calculateTotals) {\r\n var series = this.series.getIndex(0);\r\n var startIndex = series.startIndex;\r\n if (series.dataItems.length > 0) {\r\n if (startIndex > 0) {\r\n startIndex--;\r\n }\r\n var endIndex = series.endIndex;\r\n if (endIndex < series.dataItems.length) {\r\n endIndex++;\r\n }\r\n var _loop_1 = function (i) {\r\n // This has to be `var` in order to avoid garbage collection\r\n var total = {};\r\n var sum = {};\r\n this_1.series.each(function (series) {\r\n if (!series.excludeFromTotal) {\r\n var dataItem_1 = series.dataItems.getIndex(i);\r\n if (dataItem_1) {\r\n $object.each(dataItem_1.values, function (key) {\r\n var value = dataItem_1.values[key].workingValue; // can not use getWorkingValue here!\r\n if ($type.isNumber(value)) {\r\n if (!$type.isNumber(total[key])) {\r\n total[key] = Math.abs(value);\r\n }\r\n else {\r\n total[key] += Math.abs(value);\r\n }\r\n if (!$type.isNumber(sum[key])) {\r\n sum[key] = value;\r\n }\r\n else {\r\n sum[key] += value;\r\n }\r\n }\r\n });\r\n }\r\n }\r\n });\r\n this_1.series.each(function (series) {\r\n if (!series.excludeFromTotal) {\r\n var dataItem_2 = series.dataItems.getIndex(i);\r\n if (dataItem_2) {\r\n $object.each(dataItem_2.values, function (key) {\r\n var value = dataItem_2.values[key].workingValue; // can not use getWorkingValue here!\r\n if ($type.isNumber(value)) {\r\n dataItem_2.setCalculatedValue(key, total[key], \"total\");\r\n dataItem_2.setCalculatedValue(key, 100 * value / total[key], \"totalPercent\");\r\n dataItem_2.setCalculatedValue(key, sum[key], \"sum\");\r\n }\r\n });\r\n }\r\n }\r\n });\r\n };\r\n var this_1 = this;\r\n // This has to be `var` in order to avoid garbage collection\r\n for (var i = startIndex; i < endIndex; ++i) {\r\n _loop_1(i);\r\n }\r\n }\r\n }\r\n };\r\n /**\r\n * Validates the whole axis. Causes it to redraw.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description (review)\r\n */\r\n ValueAxis.prototype.validate = function () {\r\n if (this.axisLength <= 0) {\r\n return;\r\n }\r\n _super.prototype.validate.call(this);\r\n this.getMinMax();\r\n if (!$type.isNumber(this._minAdjusted)) {\r\n this.dataItems.each(function (dataItem) {\r\n dataItem.value = null;\r\n });\r\n }\r\n this.fixAxisBreaks();\r\n this.calculateZoom();\r\n this.validateAxisElements();\r\n this.validateAxisRanges();\r\n this.validateBreaks();\r\n this.hideUnusedDataItems();\r\n this.renderer.invalidateLayout();\r\n // hide too close\r\n //this.hideTooCloseDataItems();\r\n };\r\n /**\r\n * Calculates all positions, related to axis as per current zoom.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n ValueAxis.prototype.calculateZoom = function () {\r\n if ($type.isNumber(this.min) && $type.isNumber(this.max)) {\r\n var min = this.positionToValue(this.start);\r\n var max = this.positionToValue(this.end);\r\n var differece = this.adjustDifference(min, max);\r\n var minMaxStep = this.adjustMinMax(min, max, differece, this._gridCount, true);\r\n var stepDecimalPlaces = $utils.decimalPlaces(minMaxStep.step);\r\n this._stepDecimalPlaces = stepDecimalPlaces;\r\n min = $math.round(min, stepDecimalPlaces);\r\n max = $math.round(max, stepDecimalPlaces);\r\n minMaxStep = this.adjustMinMax(min, max, differece, this._gridCount, true);\r\n var step = minMaxStep.step;\r\n if (this.syncWithAxis) {\r\n var calculated = this.getCache(min + \"-\" + max);\r\n if ($type.isNumber(calculated)) {\r\n step = calculated;\r\n }\r\n }\r\n else {\r\n min = minMaxStep.min;\r\n max = minMaxStep.max;\r\n }\r\n if (this._minZoomed != min || this._maxZoomed != max || this._step != step || this._dsc) {\r\n this._dsc = false;\r\n this._minZoomed = min;\r\n this._maxZoomed = max;\r\n this._step = step;\r\n this.dispatchImmediately(\"selectionextremeschanged\");\r\n }\r\n }\r\n };\r\n ValueAxis.prototype.fixSmallStep = function (step) {\r\n if (1 + step == 1) {\r\n step *= 2;\r\n return this.fixSmallStep(step);\r\n }\r\n return step;\r\n };\r\n /**\r\n * Validates Axis elements.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n */\r\n ValueAxis.prototype.validateAxisElements = function () {\r\n var _this = this;\r\n if ($type.isNumber(this.max) && $type.isNumber(this.min)) {\r\n // first regular items\r\n var value_1 = this.minZoomed - this._step * 2;\r\n if (!this.logarithmic) {\r\n value_1 = Math.floor(value_1 / this._step) * this._step;\r\n }\r\n else {\r\n var differencePower = Math.log(this.max) * Math.LOG10E - Math.log(this.min) * Math.LOG10E;\r\n if (differencePower > 1) {\r\n value_1 = Math.pow(10, Math.log(this.min) * Math.LOG10E);\r\n }\r\n else {\r\n value_1 = Math.floor(this.minZoomed / this._step) * this._step;\r\n if (value_1 == 0) {\r\n value_1 = this.minZoomed;\r\n }\r\n }\r\n }\r\n var maxZoomed = this._maxZoomed + this._step;\r\n this.resetIterators();\r\n var dataItemsIterator_1 = this._dataItemsIterator;\r\n if (this._step == 0) {\r\n return;\r\n }\r\n this._step = this.fixSmallStep(this._step);\r\n var i = 0;\r\n var precisionChanged = this._prevStepDecimalPlaces != this._stepDecimalPlaces;\r\n this._prevStepDecimalPlaces = this._stepDecimalPlaces;\r\n while (value_1 <= maxZoomed) {\r\n var axisBreak = this.isInBreak(value_1);\r\n if (!axisBreak) {\r\n var dataItem = dataItemsIterator_1.find(function (x) { return x.value === value_1; });\r\n if (dataItem.__disabled) {\r\n dataItem.__disabled = false;\r\n }\r\n //this.processDataItem(dataItem);\r\n this.appendDataItem(dataItem);\r\n dataItem.axisBreak = undefined;\r\n if (dataItem.value != value_1 || precisionChanged) {\r\n dataItem.value = value_1;\r\n dataItem.text = this.formatLabel(value_1);\r\n if (dataItem.label && dataItem.label.invalid) {\r\n dataItem.label.validate();\r\n }\r\n if (dataItem.value >= this.min && dataItem.value <= this.max) {\r\n if (dataItem.label) {\r\n if ((this.axisLetter == \"Y\" && dataItem.label.measuredWidth > this.ghostLabel.measuredWidth) || (this.axisLetter == \"X\" && dataItem.label.measuredHeight > this.ghostLabel.measuredHeight)) {\r\n this.ghostLabel.text = dataItem.label.currentText;\r\n this.ghostLabel.validate();\r\n }\r\n }\r\n }\r\n }\r\n this.validateDataElement(dataItem);\r\n }\r\n i++;\r\n var oldValue = value_1;\r\n if (!this.logarithmic) {\r\n value_1 += this._step;\r\n }\r\n else {\r\n var differencePower = Math.log(this.max) * Math.LOG10E - Math.log(this.min) * Math.LOG10E;\r\n if (differencePower > 1) {\r\n value_1 = Math.pow(10, Math.log(this.min) * Math.LOG10E + i);\r\n }\r\n else {\r\n value_1 += this._step;\r\n }\r\n }\r\n var stepPower = Math.pow(10, Math.floor(Math.log(Math.abs(this._step)) * Math.LOG10E));\r\n if (stepPower < 1) {\r\n // exponent is less then 1 too. Count decimals of exponent\r\n var decCount = Math.round(Math.abs(Math.log(Math.abs(stepPower)) * Math.LOG10E)) + 2;\r\n decCount = Math.min(13, decCount);\r\n // round value to avoid floating point issues\r\n value_1 = $math.round(value_1, decCount);\r\n // ceil causes problems: https://codepen.io/team/amcharts/pen/XWMjZwy?editors=1010\r\n if (oldValue == value_1) {\r\n value_1 = maxZoomed;\r\n break;\r\n }\r\n }\r\n }\r\n var axisBreaks = this._axisBreaks;\r\n if (axisBreaks) {\r\n // breaks later\r\n var renderer_1 = this.renderer;\r\n $iter.each(axisBreaks.iterator(), function (axisBreak) {\r\n if (axisBreak.breakSize > 0) {\r\n // only add grid if gap is bigger then minGridDistance\r\n if ($math.getDistance(axisBreak.startPoint, axisBreak.endPoint) > renderer_1.minGridDistance) {\r\n var breakValue_1 = axisBreak.adjustedMin;\r\n while (breakValue_1 <= axisBreak.adjustedMax) {\r\n if (breakValue_1 >= axisBreak.adjustedStartValue && breakValue_1 <= axisBreak.adjustedEndValue) {\r\n var dataItem = dataItemsIterator_1.find(function (x) { return x.value === breakValue_1; });\r\n if (dataItem.__disabled) {\r\n dataItem.__disabled = false;\r\n }\r\n //this.processDataItem(dataItem);\r\n _this.appendDataItem(dataItem);\r\n dataItem.axisBreak = axisBreak;\r\n if (dataItem.value != breakValue_1) {\r\n dataItem.value = breakValue_1;\r\n dataItem.text = _this.formatLabel(breakValue_1);\r\n if (dataItem.label && dataItem.label.invalid) {\r\n dataItem.label.validate();\r\n }\r\n }\r\n _this.validateDataElement(dataItem);\r\n }\r\n breakValue_1 += axisBreak.adjustedStep;\r\n }\r\n }\r\n }\r\n });\r\n }\r\n }\r\n };\r\n /**\r\n * Validates axis data item.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param dataItem Data item\r\n */\r\n ValueAxis.prototype.validateDataElement = function (dataItem) {\r\n _super.prototype.validateDataElement.call(this, dataItem);\r\n //dataItem.__disabled = false;\r\n dataItem.itemIndex = this._axisItemCount;\r\n this._axisItemCount++;\r\n var renderer = this.renderer;\r\n var value = dataItem.value;\r\n var endValue = dataItem.endValue;\r\n var position = this.valueToPosition(value);\r\n dataItem.position = position;\r\n var endPosition = position;\r\n var fillEndPosition = this.valueToPosition(value + this._step);\r\n if ($type.isNumber(endValue)) {\r\n endPosition = this.valueToPosition(endValue);\r\n fillEndPosition = endPosition;\r\n }\r\n // this point is needed to calculate distance to satisfy minGridDistance\r\n dataItem.point = renderer.positionToPoint(position);\r\n var tick = dataItem.tick;\r\n if (tick && !tick.disabled) {\r\n renderer.updateTickElement(tick, position, endPosition);\r\n }\r\n var grid = dataItem.grid;\r\n if (grid && !grid.disabled) {\r\n renderer.updateGridElement(grid, position, endPosition);\r\n }\r\n var label = dataItem.label;\r\n if (label && !label.disabled) {\r\n renderer.updateLabelElement(label, position, endPosition);\r\n }\r\n var fill = dataItem.axisFill;\r\n if (fill && !fill.disabled) {\r\n renderer.updateFillElement(fill, position, fillEndPosition);\r\n if (!dataItem.isRange) {\r\n this.fillRule(dataItem);\r\n }\r\n }\r\n if (dataItem.bullet) {\r\n renderer.updateBullet(dataItem.bullet, position, endPosition);\r\n }\r\n var mask = dataItem.mask;\r\n if (mask) {\r\n renderer.updateFillElement(mask, position, fillEndPosition);\r\n }\r\n };\r\n /**\r\n * Formats the value according to axis' own [[NumberFormatter]].\r\n *\r\n * @param value Source value\r\n * @return Formatted value\r\n */\r\n ValueAxis.prototype.formatLabel = function (value) {\r\n if (this.adjustLabelPrecision && value != 0) {\r\n return this.numberFormatter.format(value, undefined, this._stepDecimalPlaces);\r\n }\r\n else {\r\n return this.numberFormatter.format(value);\r\n }\r\n };\r\n Object.defineProperty(ValueAxis.prototype, \"basePoint\", {\r\n /**\r\n * Coordinates of the actual axis start.\r\n *\r\n * @ignore Exclude from docs\r\n * @return Base point\r\n */\r\n get: function () {\r\n var baseValue = this.baseValue;\r\n var position = this.valueToPosition(baseValue);\r\n var basePoint = this.renderer.positionToPoint(position);\r\n return basePoint;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxis.prototype, \"baseValue\", {\r\n /**\r\n * @return base value\r\n */\r\n get: function () {\r\n var baseValue = this._baseValue;\r\n if (this.logarithmic) {\r\n baseValue = this.min;\r\n }\r\n if (!this._adapterO) {\r\n return baseValue;\r\n }\r\n else {\r\n return this._adapterO.apply(\"baseValue\", baseValue);\r\n }\r\n },\r\n /**\r\n * A base value.\r\n *\r\n * This is a threshold value that will divide \"positive\" and \"negative\"\r\n * value ranges.\r\n *\r\n * Other scale-related functionality also depend on base value. E.g. stacks,\r\n * value-dependent coloring, etc.\r\n *\r\n * @param value Base value\r\n */\r\n set: function (value) {\r\n this._baseValue = value;\r\n this.invalidateLayout();\r\n this.invalidateSeries();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Converts a numeric value to relative position on axis\r\n *\r\n * An alias to `valueToPosition()`.\r\n *\r\n * @param value Value\r\n * @return Position\r\n */\r\n ValueAxis.prototype.anyToPosition = function (value) {\r\n return this.valueToPosition(value);\r\n };\r\n /**\r\n * Converts a numeric value to orientation point (x, y, angle) on axis\r\n *\r\n * @param value Value\r\n * @return Orientation point\r\n */\r\n ValueAxis.prototype.valueToPoint = function (value) {\r\n var position = this.valueToPosition(value);\r\n var point = this.renderer.positionToPoint(position);\r\n var angle = this.renderer.positionToAngle(position);\r\n return { x: point.x, y: point.y, angle: angle };\r\n };\r\n /**\r\n * Converts a numeric value to orientation (x, y, angle) point on axis\r\n *\r\n * @param value Value\r\n * @return Orientation point\r\n */\r\n ValueAxis.prototype.anyToPoint = function (value) {\r\n return this.valueToPoint(value);\r\n };\r\n /**\r\n * Converts a numeric value to relative position on axis.\r\n *\r\n * @param value Value\r\n * @return relative position\r\n */\r\n ValueAxis.prototype.valueToPosition = function (value) {\r\n if ($type.isNumber(value)) {\r\n // todo: think if possible to take previous value and do not go through all previous breaks\r\n var min_1 = this.min;\r\n var max_1 = this.max;\r\n if ($type.isNumber(min_1) && $type.isNumber(max_1)) {\r\n var difference = this._difference;\r\n var axisBreaks = this._axisBreaks;\r\n if (axisBreaks && axisBreaks.length > 0) {\r\n $iter.eachContinue(axisBreaks.iterator(), function (axisBreak) {\r\n var startValue = axisBreak.adjustedStartValue;\r\n var endValue = axisBreak.adjustedEndValue;\r\n if ($type.isNumber(startValue) && $type.isNumber(endValue)) {\r\n if (value < startValue) {\r\n return false;\r\n }\r\n if ($math.intersect({ start: startValue, end: endValue }, { start: min_1, end: max_1 })) { // todo: check this once and set some flag in axisBreak\r\n startValue = Math.max(startValue, min_1);\r\n endValue = Math.min(endValue, max_1);\r\n var breakSize = axisBreak.breakSize;\r\n // value to the right of break end\r\n if (value > endValue) {\r\n min_1 += (endValue - startValue) * (1 - breakSize); // todo: maybe this can be done differently?\r\n }\r\n // value to the left of break start\r\n else if (value < startValue) {\r\n }\r\n // value within break\r\n else {\r\n value = startValue + (value - startValue) * breakSize;\r\n }\r\n }\r\n }\r\n return true;\r\n });\r\n }\r\n var position = void 0;\r\n if (!this.logarithmic) {\r\n position = (value - min_1) / difference;\r\n }\r\n else {\r\n var treatZeroAs = this.treatZeroAs;\r\n if ($type.isNumber(treatZeroAs)) {\r\n if (value <= treatZeroAs) {\r\n value = treatZeroAs;\r\n }\r\n }\r\n position = (Math.log(value) * Math.LOG10E - Math.log(this.min) * Math.LOG10E) / ((Math.log(this.max) * Math.LOG10E - Math.log(this.min) * Math.LOG10E));\r\n }\r\n //position = $math.round(position, 10);\r\n return position;\r\n }\r\n }\r\n return 0;\r\n };\r\n /**\r\n * When fontSize of fontFamily changes we need to hard-invalidate all Labels of this container to position them properly.\r\n */\r\n ValueAxis.prototype.invalidateLabels = function () {\r\n _super.prototype.invalidateLabels.call(this);\r\n if (this.dataItems) {\r\n this.dataItems.each(function (dataItem) {\r\n dataItem.value = undefined;\r\n });\r\n this.invalidate();\r\n }\r\n };\r\n /**\r\n * Converts an relative position to a corresponding value within\r\n * axis' scale.\r\n *\r\n * @param position Position (px)\r\n * @return Value\r\n */\r\n ValueAxis.prototype.positionToValue = function (position) {\r\n var min = this.min;\r\n var max = this.max;\r\n if ($type.isNumber(min) && $type.isNumber(max)) {\r\n var difference_1 = max - min; //no need to adjust!\r\n var value_2 = null;\r\n var axisBreaks = this._axisBreaks;\r\n if (axisBreaks) {\r\n // in case we have some axis breaks\r\n if (axisBreaks.length > 0) {\r\n $iter.eachContinue(axisBreaks.iterator(), function (axisBreak) {\r\n var breakStartPosition = axisBreak.startPosition;\r\n var breakEndPosition = axisBreak.endPosition;\r\n var breakStartValue = axisBreak.adjustedStartValue;\r\n var breakEndValue = axisBreak.adjustedEndValue;\r\n if ($type.isNumber(breakStartValue) && $type.isNumber(breakEndValue)) {\r\n if (breakStartValue > max) {\r\n return false;\r\n }\r\n if ($math.intersect({ start: breakStartValue, end: breakEndValue }, { start: min, end: max })) {\r\n breakStartValue = $math.max(breakStartValue, min);\r\n breakEndValue = $math.min(breakEndValue, max);\r\n var breakSize = axisBreak.breakSize;\r\n difference_1 -= (breakEndValue - breakStartValue) * (1 - breakSize);\r\n // position to the right of break end\r\n if (position > breakEndPosition) {\r\n min += (breakEndValue - breakStartValue) * (1 - breakSize);\r\n }\r\n // position to the left of break start\r\n else if (position < breakStartPosition) {\r\n }\r\n // value within break\r\n else {\r\n var breakPosition = (position - breakStartPosition) / (breakEndPosition - breakStartPosition);\r\n value_2 = breakStartValue + breakPosition * (breakEndValue - breakStartValue);\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n });\r\n }\r\n }\r\n if (!$type.isNumber(value_2)) {\r\n if (this.logarithmic) {\r\n value_2 = Math.pow(Math.E, (position * ((Math.log(this.max) * Math.LOG10E - Math.log(this.min) * Math.LOG10E)) + Math.log(this.min) * Math.LOG10E) / Math.LOG10E);\r\n }\r\n else {\r\n value_2 = position * difference_1 + min;\r\n }\r\n }\r\n return value_2;\r\n }\r\n //}\r\n };\r\n /**\r\n * Converts an X coordinate to a relative value in axis' scale.\r\n *\r\n * @param x X (px)\r\n * @return Value\r\n */\r\n ValueAxis.prototype.xToValue = function (x) {\r\n return this.positionToValue(this.pointToPosition({ x: x, y: 0 }));\r\n };\r\n /**\r\n * Converts an Y coordinate to a relative value in axis' scale.\r\n *\r\n * @param y Y (px)\r\n * @return Value\r\n */\r\n ValueAxis.prototype.yToValue = function (y) {\r\n return this.positionToValue(this.pointToPosition({ x: 0, y: y }));\r\n };\r\n /**\r\n * Converts pixel coordinates to a relative position. (0-1)\r\n *\r\n * @param point Coorinates (px)\r\n * @return Position (0-1)\r\n */\r\n ValueAxis.prototype.pointToPosition = function (point) {\r\n if (this.renderer instanceof AxisRendererY) {\r\n return 1 - this.renderer.pointToPosition(point);\r\n }\r\n else {\r\n return this.renderer.pointToPosition(point);\r\n }\r\n };\r\n /**\r\n * @ignore\r\n */\r\n ValueAxis.prototype.animateMinMax = function (min, max) {\r\n return this.animate([{ property: \"_minAdjusted\", from: this._minAdjusted, to: min }, { property: \"_maxAdjusted\", from: this._maxAdjusted, to: max }], this.rangeChangeDuration, this.rangeChangeEasing);\r\n };\r\n /**\r\n * Calculates smallest and biggest value for the axis scale.\r\n * @ignore\r\n * @todo Description (review)\r\n */\r\n ValueAxis.prototype.getMinMax = function () {\r\n var _this = this;\r\n this.updateGridCount();\r\n var min = Number.POSITIVE_INFINITY;\r\n var max = Number.NEGATIVE_INFINITY;\r\n // only if min and max are not set from outside, we go through min and max influencers\r\n if (!$type.isNumber(this._minDefined) || !$type.isNumber(this._maxDefined)) {\r\n this.series.each(function (series) {\r\n if (!series.ignoreMinMax) {\r\n // check min\r\n var seriesMin = series.min(_this);\r\n if ($type.isNumber(seriesMin) && (seriesMin < min)) {\r\n min = seriesMin;\r\n }\r\n // check max\r\n var seriesMax = series.max(_this);\r\n if ($type.isNumber(seriesMax) && (seriesMax > max)) {\r\n max = seriesMax;\r\n }\r\n }\r\n });\r\n if (this.includeRangesInMinMax) {\r\n this.axisRanges.each(function (range) {\r\n if (!range.ignoreMinMax) {\r\n var minValue = $math.min(range.value, range.endValue);\r\n var maxValue = $math.max(range.value, range.endValue);\r\n if (minValue < min || !$type.isNumber(min)) {\r\n min = minValue;\r\n }\r\n if (maxValue > max || !$type.isNumber(max)) {\r\n max = maxValue;\r\n }\r\n }\r\n });\r\n }\r\n }\r\n if (this.logarithmic) {\r\n var treatZeroAs = this.treatZeroAs;\r\n if ($type.isNumber(treatZeroAs)) {\r\n if (min <= 0) {\r\n min = treatZeroAs;\r\n }\r\n }\r\n if (min <= 0) {\r\n this.raiseCriticalError(new Error(\"Logarithmic value axis can not have values <= 0.\"), true);\r\n }\r\n }\r\n if (min == 0 && max == 0) {\r\n max = 0.9;\r\n min = -0.9;\r\n }\r\n // if defined from outside\r\n if ($type.isNumber(this._minDefined)) {\r\n min = this._minDefined;\r\n }\r\n if ($type.isNumber(this._maxDefined)) {\r\n max = this._maxDefined;\r\n }\r\n if (this._adapterO) {\r\n min = this._adapterO.apply(\"min\", min);\r\n }\r\n if (this._adapterO) {\r\n max = this._adapterO.apply(\"max\", max);\r\n }\r\n if (!$type.isNumber(min) || !$type.isNumber(max)) {\r\n return;\r\n }\r\n this._minReal = min;\r\n this._maxReal = max;\r\n if (min == Number.POSITIVE_INFINITY) {\r\n min = undefined;\r\n }\r\n if (max == Number.NEGATIVE_INFINITY) {\r\n max = undefined;\r\n }\r\n var dif = this.adjustDifference(min, max); // previously it was max-min, but not worked well\r\n min = this.fixMin(min);\r\n max = this.fixMax(max);\r\n // this happens if starLocation and endLocation are 0.5 and DateAxis has only one date\r\n if (max - min <= 1 / Math.pow(10, 15)) {\r\n if (max - min != 0) {\r\n this._deltaMinMax = (max - min) / 2;\r\n }\r\n else {\r\n // the number by which we need to raise 10 to get difference\r\n var exponent = Math.log(Math.abs(max)) * Math.LOG10E;\r\n // here we find a number which is power of 10 and has the same count of numbers as difference has\r\n var power = Math.pow(10, Math.floor(exponent));\r\n // reduce this number by 10 times\r\n power = power / 10;\r\n this._deltaMinMax = power;\r\n }\r\n min -= this._deltaMinMax;\r\n max += this._deltaMinMax;\r\n }\r\n min -= (max - min) * this.extraMin;\r\n max += (max - min) * this.extraMax;\r\n var strict = this.strictMinMax;\r\n if ($type.isNumber(this._maxDefined)) {\r\n strict = true;\r\n }\r\n var minMaxStep = this.adjustMinMax(min, max, dif, this._gridCount, strict);\r\n min = minMaxStep.min;\r\n max = minMaxStep.max;\r\n dif = max - min; //new\r\n // do it for the second time (importat!)\r\n minMaxStep = this.adjustMinMax(min, max, max - min, this._gridCount, true);\r\n min = minMaxStep.min;\r\n max = minMaxStep.max;\r\n // return min max if strict\r\n if (this.strictMinMax) {\r\n if ($type.isNumber(this._minDefined)) {\r\n min = this._minDefined;\r\n }\r\n else {\r\n min = this._minReal;\r\n }\r\n if ($type.isNumber(this._maxDefined)) {\r\n max = this._maxDefined;\r\n }\r\n else {\r\n max = this._maxReal;\r\n }\r\n if (max - min <= 0.00000001) {\r\n min -= this._deltaMinMax;\r\n max += this._deltaMinMax;\r\n }\r\n min -= (max - min) * this.extraMin;\r\n max += (max - min) * this.extraMax;\r\n }\r\n if (this._adapterO) {\r\n min = this._adapterO.apply(\"min\", min);\r\n }\r\n if (this._adapterO) {\r\n max = this._adapterO.apply(\"max\", max);\r\n }\r\n this._step = minMaxStep.step;\r\n if (!$type.isNumber(min) && !$type.isNumber(max)) {\r\n this.start = 0;\r\n this.end = 1;\r\n this.renderer.labels.each(function (label) {\r\n label.dataItem.text = \"\";\r\n });\r\n }\r\n // checking isNumber is good when all series are hidden\r\n if ((this._minAdjusted != min || this._maxAdjusted != max) && $type.isNumber(min) && $type.isNumber(max)) {\r\n var animation = this._minMaxAnimation;\r\n if (this._extremesChanged && $type.isNumber(this._minAdjusted) && $type.isNumber(this._maxAdjusted) && this.inited) {\r\n if ((animation && !animation.isFinished()) && this._finalMax == max && this._finalMin == min) {\r\n return;\r\n }\r\n else {\r\n this._finalMin = min;\r\n this._finalMax = max;\r\n animation = this.animateMinMax(min, max);\r\n if (animation && !animation.isFinished()) {\r\n animation.events.on(\"animationprogress\", this.validateDataItems, this);\r\n animation.events.on(\"animationended\", function () {\r\n //this.validateDataItems();\r\n _this.series.each(function (series) {\r\n series.validate();\r\n });\r\n _this.validateDataItems();\r\n _this.handleSelectionExtremesChange();\r\n });\r\n this._minMaxAnimation = animation;\r\n }\r\n else {\r\n this.series.each(function (series) {\r\n series.invalidate();\r\n });\r\n }\r\n this.validateDataItems();\r\n this.dispatchImmediately(\"extremeschanged\");\r\n this.handleSelectionExtremesChange();\r\n }\r\n }\r\n else {\r\n if ((animation && !animation.isFinished()) && this._finalMax == max && this._finalMin == min) {\r\n return;\r\n }\r\n else {\r\n this._minAdjusted = min;\r\n this._maxAdjusted = max;\r\n this._finalMin = min;\r\n this._finalMax = max;\r\n this.invalidateDataItems();\r\n this.dispatchImmediately(\"extremeschanged\");\r\n this._saveMinMax(min, max);\r\n }\r\n }\r\n }\r\n this._extremesChanged = false;\r\n this._difference = this.adjustDifference(min, max);\r\n };\r\n /**\r\n * Adjusts the minimum value.\r\n *\r\n * This is a placeholder method for extending classes to override.\r\n *\r\n * For numeric values this does nothing, however for more complex types, like\r\n * dates, it may be necessary to adjust.\r\n *\r\n * @param value Value\r\n * @return Adjusted value\r\n */\r\n ValueAxis.prototype.fixMin = function (value) {\r\n return value;\r\n };\r\n /**\r\n * Adjusts the maximum value.\r\n *\r\n * This is a placeholder method for extending classes to override.\r\n *\r\n * For numeric values this does nothing, however for more complex types, like\r\n * dates, it may be necessary to adjust.\r\n *\r\n * @param value Value\r\n * @return Adjusted value\r\n */\r\n ValueAxis.prototype.fixMax = function (value) {\r\n return value;\r\n };\r\n /**\r\n * Adjusts actual min and max scale values so that the axis starts and ends\r\n * at \"nice\" values, unless `strictMinMax` is set.\r\n *\r\n * The `difference` can be something else than `max - min`, because of the\r\n * axis breaks.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param min [description]\r\n * @param max [description]\r\n * @param difference [description]\r\n * @param gridCount [description]\r\n * @param strictMode [description]\r\n * @return [description]\r\n */\r\n ValueAxis.prototype.adjustMinMax = function (min, max, difference, gridCount, strictMode) {\r\n // will fail if 0\r\n if (gridCount <= 1) {\r\n gridCount = 1;\r\n }\r\n gridCount = Math.round(gridCount);\r\n var initialMin = min;\r\n var initialMax = max;\r\n // in case min and max is the same, use max\r\n if (difference === 0) {\r\n difference = Math.abs(max);\r\n }\r\n // the number by which we need to raise 10 to get difference\r\n var exponent = Math.log(Math.abs(difference)) * Math.LOG10E;\r\n // here we find a number which is power of 10 and has the same count of numbers as difference has\r\n var power = Math.pow(10, Math.floor(exponent));\r\n // reduce this number by 10 times\r\n power = power / 10;\r\n var extra = power;\r\n if (strictMode) {\r\n extra = 0;\r\n }\r\n if (!this.logarithmic) {\r\n // round down min\r\n if (strictMode) {\r\n min = Math.floor(min / power) * power;\r\n // round up max\r\n max = Math.ceil(max / power) * power;\r\n }\r\n else {\r\n min = Math.ceil(min / power) * power - extra;\r\n // round up max\r\n max = Math.floor(max / power) * power + extra;\r\n }\r\n // don't let min go below 0 if real min is >= 0\r\n if (min < 0 && initialMin >= 0) {\r\n min = 0;\r\n }\r\n // don't let max go above 0 if real max is <= 0\r\n if (max > 0 && initialMax <= 0) {\r\n max = 0;\r\n }\r\n }\r\n else {\r\n if (min <= 0) {\r\n //throw Error(\"Logarithmic value axis can not have values <= 0.\");\r\n min = this.baseValue;\r\n }\r\n // @todo: think of a better way or to restrict zooming when no series are selected\r\n if (min == Infinity) {\r\n min = 1;\r\n }\r\n if (max == -Infinity) {\r\n max = 10;\r\n }\r\n if (this.strictMinMax) {\r\n if (this._minDefined > 0) {\r\n min = this._minDefined;\r\n }\r\n else {\r\n min = min;\r\n }\r\n if (this._maxDefined > 0) {\r\n max = max;\r\n }\r\n }\r\n else {\r\n min = Math.pow(10, Math.floor(Math.log(Math.abs(min)) * Math.LOG10E));\r\n max = Math.pow(10, Math.ceil(Math.log(Math.abs(max)) * Math.LOG10E));\r\n }\r\n }\r\n // repeat diff, exponent and power again with rounded values\r\n //difference = this.adjustDifference(min, max);\r\n /*\r\n\r\n if(min > initialMin){\r\n min = initialMin;\r\n }\r\n\r\n if(max < initialMax){\r\n max = initialMax;\r\n }\r\n */\r\n exponent = Math.log(Math.abs(difference)) * Math.LOG10E;\r\n power = Math.pow(10, Math.floor(exponent));\r\n power = power / 10;\r\n // approximate difference between two grid lines\r\n var step = Math.ceil((difference / gridCount) / power) * power;\r\n var stepPower = Math.pow(10, Math.floor(Math.log(Math.abs(step)) * Math.LOG10E));\r\n // TODO: in v3 I had fixStepE here, ommiting it for a while, need to think about other solution\r\n // the step should divide by 2, 5, and 10.\r\n var stepDivisor = Math.ceil(step / stepPower); // number 0 - 10\r\n if (stepDivisor > 5) {\r\n stepDivisor = 10;\r\n }\r\n else if (stepDivisor <= 5 && stepDivisor > 2) {\r\n stepDivisor = 5;\r\n }\r\n // now get real step\r\n step = Math.ceil(step / (stepPower * stepDivisor)) * stepPower * stepDivisor;\r\n if (this.maxPrecision < Number.MAX_VALUE && step != $math.ceil(step, this.maxPrecision)) {\r\n step = $math.ceil(step, this.maxPrecision);\r\n }\r\n var decCount = 0;\r\n // in case numbers are smaller than 1\r\n if (stepPower < 1) {\r\n // exponent is less then 1 too. Count decimals of exponent\r\n decCount = Math.round(Math.abs(Math.log(Math.abs(stepPower)) * Math.LOG10E)) + 1;\r\n // round step\r\n step = $math.round(step, decCount);\r\n }\r\n if (!this.logarithmic) {\r\n // final min and max\r\n var minCount = Math.floor(min / step);\r\n min = $math.round(step * minCount, decCount);\r\n var maxCount = void 0;\r\n if (!strictMode) {\r\n maxCount = Math.ceil(max / step);\r\n }\r\n else {\r\n maxCount = Math.floor(max / step);\r\n }\r\n if (maxCount == minCount) {\r\n maxCount++;\r\n }\r\n max = $math.round(step * maxCount, decCount);\r\n if (max < initialMax) {\r\n max = max + step;\r\n }\r\n if (min > initialMin) {\r\n min = min - step;\r\n }\r\n }\r\n return { min: min, max: max, step: step };\r\n };\r\n Object.defineProperty(ValueAxis.prototype, \"min\", {\r\n /**\r\n * @return Min value\r\n */\r\n get: function () {\r\n var min = this._minAdjusted;\r\n if (!$type.isNumber(min)) {\r\n min = this._minDefined;\r\n }\r\n return min;\r\n },\r\n /**\r\n * A minimum value for the axis scale.\r\n *\r\n * This value might be auto-adjusted by the Axis in order to accomodate the\r\n * grid nicely, i.e. plot area is divided by grid in nice equal cells.\r\n *\r\n * The above might be overridden by `strictMinMax` which will force exact\r\n * user-defined min and max values to be used for scale.\r\n *\r\n * @param value Min value\r\n */\r\n set: function (value) {\r\n if (this._minDefined != value) {\r\n this._minDefined = value;\r\n this.invalidate();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxis.prototype, \"minDefined\", {\r\n /**\r\n * Min value as defined by user's code, not auto-calculated.\r\n *\r\n * @readonly\r\n * @return Min value\r\n */\r\n get: function () {\r\n return this._minDefined;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxis.prototype, \"maxDefined\", {\r\n /**\r\n * Max value as defined by user's code, not auto-calculated.\r\n *\r\n * @readonly\r\n * @return Man value\r\n */\r\n get: function () {\r\n return this._maxDefined;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxis.prototype, \"extraMin\", {\r\n /**\r\n * @return {number}\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"extraMin\");\r\n },\r\n /**\r\n * Allows relatively adjusting minimum value of the axis' scale.\r\n *\r\n * The value is relative to the actual range of values currently displayed\r\n * on the axis.\r\n *\r\n * E.g.: 0.5 will mean half of the current range. If we have axis displaying\r\n * from 100 to 200, we will now have axis displaying from 50 to 200 because\r\n * we asked to expand minimum value by 50% (0.5).\r\n *\r\n * NOTE: this setting is not compatible with `strictMinMax`.\r\n *\r\n * @param {number}\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"extraMin\", value)) {\r\n this.invalidateDataItems();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxis.prototype, \"extraMax\", {\r\n /**\r\n * @return Min multiplier\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"extraMax\");\r\n },\r\n /**\r\n * Allows relatively adjusting maximum value of the axis' scale.\r\n *\r\n * The value is relative to the actual range of values currently displayed\r\n * on the axis.\r\n *\r\n * E.g.: 0.5 will mean half of the current range. If we have axis displaying\r\n * from 100 to 200, we will now have axis displaying from 100 to 250 because\r\n * we asked to expand maximum value by 50% (0.5).\r\n *\r\n * NOTE: this setting is not compatible with `strictMinMax`.\r\n *\r\n * @param {number}\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"extraMax\", value)) {\r\n this.invalidateDataItems();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxis.prototype, \"step\", {\r\n /**\r\n * Current calculated delta in values between two adjacent grid lines (step).\r\n *\r\n * This is a read-only value and cannot be used to set actual step.\r\n *\r\n * @readonly\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/axes/positioning-axis-elements/#Setting_the_density_of_the_the_grid_labels} For more information about modifying density of labels\r\n * @return [description]\r\n */\r\n get: function () {\r\n return this._step;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxis.prototype, \"max\", {\r\n /**\r\n * @return Max value\r\n */\r\n get: function () {\r\n var max = this._maxAdjusted;\r\n if (!$type.isNumber(max)) {\r\n max = this._maxDefined;\r\n }\r\n return max;\r\n },\r\n /**\r\n * A maximum value for the axis scale.\r\n *\r\n * This value might be auto-adjusted by the Axis in order to accomodate the\r\n * grid nicely, i.e. plot area is divided by grid in nice equal cells.\r\n *\r\n * The above might be overridden by `strictMinMax` which will force exact\r\n * user-defined min and max values to be used for scale.\r\n *\r\n * @param value Max value\r\n */\r\n set: function (value) {\r\n if (this._maxDefined != value) {\r\n this._maxDefined = value;\r\n this.invalidate();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxis.prototype, \"adjustLabelPrecision\", {\r\n /**\r\n * @return Adjust precision\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"adjustLabelPrecision\");\r\n },\r\n /**\r\n * By default the axis will adjust precision of all numbers to match number\r\n * of decimals in all its labels, e.g.: `1.0`, `1.5`, `2.0`.\r\n *\r\n * To disable set `adjustLabelPrecision` to `false`, to use whatever other\r\n * precision or number format settings are set.\r\n *\r\n * IMPORTANT: This setting will be ignored if your number format uses\r\n * modifiers, e.g. `\"#a\"`.\r\n *\r\n * @default true\r\n * @since 4.9.14\r\n * @param value Adjust precision\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"adjustLabelPrecision\", value)) {\r\n this.invalidate();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Used for the Series to register itself as the user of this Axis.\r\n *\r\n * This will also decorate both the Series and Axis with event handlers, used\r\n * to redraw on Axis position/zoom change.\r\n *\r\n * A disposer for those events is returned, so that they can be disposed\r\n * together with Series.\r\n *\r\n * @ignore Exclude from docs\r\n * @param series Series\r\n * @return Disposer for events\r\n */\r\n ValueAxis.prototype.registerSeries = function (series) {\r\n return new MultiDisposer([\r\n _super.prototype.registerSeries.call(this, series),\r\n series.events.on(\"extremeschanged\", this.handleExtremesChange, this, false),\r\n series.events.on(\"selectionextremeschanged\", this.handleSelectionExtremesChange, this, false),\r\n this.events.on(\"extremeschanged\", series.invalidate, series, false)\r\n ]);\r\n };\r\n /**\r\n * Perform tasks after Axis zoom.\r\n */\r\n ValueAxis.prototype.handleSelectionExtremesChange = function () {\r\n var _this = this;\r\n var selectionMin;\r\n var selectionMax;\r\n var allHidden = true;\r\n $iter.each(this.series.iterator(), function (series) {\r\n if (!series.ignoreMinMax && !series.isHidden && !series.outOfRange) {\r\n if (series.visible && !series.isHiding) {\r\n allHidden = false;\r\n }\r\n var seriesSelectionMin = series.selectionMin(_this);\r\n var seriesSelectionMax = series.selectionMax(_this);\r\n if ($type.isNumber(seriesSelectionMin)) {\r\n if (!$type.isNumber(selectionMin) || (seriesSelectionMin < selectionMin)) {\r\n selectionMin = seriesSelectionMin;\r\n }\r\n }\r\n // check max\r\n if ($type.isNumber(seriesSelectionMax)) {\r\n if (!$type.isNumber(selectionMax) || (seriesSelectionMax > selectionMax)) {\r\n selectionMax = seriesSelectionMax;\r\n }\r\n }\r\n }\r\n });\r\n if (this.includeRangesInMinMax) {\r\n this.axisRanges.each(function (range) {\r\n if (!range.ignoreMinMax) {\r\n var minValue = $math.min(range.value, range.endValue);\r\n var maxValue = $math.max(range.value, range.endValue);\r\n if (minValue < selectionMin) {\r\n selectionMin = minValue;\r\n }\r\n if (maxValue > selectionMax) {\r\n selectionMax = maxValue;\r\n }\r\n }\r\n });\r\n }\r\n // this is not good, as if date axis is initially zoomed, selection of y axis is reset to 0, 1 at the end of this method\r\n //$iter.each(this.series.iterator(), (series) => {\r\n //\tif (!series.appeared) {\r\n //\t\tallHidden = true;\r\n //\t}\r\n //})\r\n if ($type.isNumber(this._minDefined)) {\r\n if (this.strictMinMax) {\r\n selectionMin = this._minDefined;\r\n }\r\n else {\r\n selectionMin = this.min;\r\n }\r\n }\r\n else if (this.strictMinMax) {\r\n selectionMin = this._minReal;\r\n }\r\n if ($type.isNumber(this._maxDefined)) {\r\n if (this.strictMinMax) {\r\n selectionMax = this._maxDefined;\r\n }\r\n else {\r\n selectionMax = this.max;\r\n }\r\n }\r\n else if (this.strictMinMax) {\r\n selectionMax = this._maxReal;\r\n }\r\n if (selectionMin == selectionMax) {\r\n selectionMin -= this._deltaMinMax;\r\n selectionMax += this._deltaMinMax;\r\n var minMaxStep2 = this.adjustMinMax(selectionMin, selectionMax, 0, this._gridCount, this.strictMinMax);\r\n selectionMin = minMaxStep2.min;\r\n selectionMax = minMaxStep2.max;\r\n }\r\n var dif = this.adjustDifference(selectionMin, selectionMax);\r\n var minMaxStep = this.adjustMinMax(selectionMin, selectionMax, dif, this._gridCount);\r\n selectionMin = minMaxStep.min;\r\n selectionMax = minMaxStep.max;\r\n selectionMin -= (selectionMax - selectionMin) * this.extraMin;\r\n selectionMax += (selectionMax - selectionMin) * this.extraMax;\r\n selectionMin = $math.fitToRange(selectionMin, this.min, this.max);\r\n selectionMax = $math.fitToRange(selectionMax, this.min, this.max);\r\n // do it for the second time !important\r\n dif = this.adjustDifference(selectionMin, selectionMax);\r\n minMaxStep = this.adjustMinMax(selectionMin, selectionMax, dif, this._gridCount, true);\r\n selectionMin = minMaxStep.min;\r\n selectionMax = minMaxStep.max;\r\n if (this.strictMinMax) {\r\n selectionMin = $math.max(selectionMin, this._minDefined);\r\n selectionMax = $math.min(selectionMax, this._maxDefined);\r\n }\r\n var step = minMaxStep.step;\r\n if (this.syncWithAxis) {\r\n minMaxStep = this.syncAxes(selectionMin, selectionMax, step);\r\n selectionMin = minMaxStep.min;\r\n selectionMax = minMaxStep.max;\r\n this.invalidate();\r\n }\r\n step = minMaxStep.step;\r\n // needed because of grouping\r\n this._difference = this.adjustDifference(this.min, this.max);\r\n var start = this.valueToPosition(selectionMin);\r\n var end = this.valueToPosition(selectionMax);\r\n // in case all series are hidden or hiding, full zoomout\r\n if (allHidden && !this.syncWithAxis) {\r\n start = 0;\r\n end = 1;\r\n }\r\n var declination = 0;\r\n if (this.syncWithAxis) {\r\n declination = 5;\r\n this.setCache(selectionMin + \"-\" + selectionMax, step);\r\n }\r\n else {\r\n if (this._step != step || this._minZoomed != selectionMin || this._maxZoomed != selectionMax) {\r\n this._dsc = true;\r\n }\r\n this._step = step;\r\n this._minZoomed = selectionMin;\r\n this._maxZoomed = selectionMax;\r\n }\r\n if (!this.keepSelection) {\r\n this.zoom({ start: start, end: end }, false, false, declination);\r\n }\r\n };\r\n Object.defineProperty(ValueAxis.prototype, \"strictMinMax\", {\r\n /**\r\n * @return Use exact values?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"strictMinMax\");\r\n },\r\n /**\r\n * Indicates whether to blindly use exact `min` and `max` values set by user\r\n * when generating Axis scale.\r\n *\r\n * If not set, the Axis might slightly adjust those values to accomodate a\r\n * better looking grid.\r\n *\r\n * NOTE: if `min` and `max` are not set, setting `strictMinMax` to `true`\r\n * will result in fixing the scale of the axis to actual lowest and highest\r\n * values in the series within currently selected scope.\r\n *\r\n * @default false\r\n * @param value Use exact values?\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"strictMinMax\", value)) {\r\n this.invalidate();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxis.prototype, \"logarithmic\", {\r\n /**\r\n * @return Logarithmic scale?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"logarithmic\");\r\n },\r\n /**\r\n * Indicates if this axis should use a logarithmic scale.\r\n *\r\n * Please note that logarithmic axis can **only** accommodate values bigger\r\n * than zero.\r\n *\r\n * Having zero or negative values will result in error and failure of the\r\n * whole chart.\r\n *\r\n * @param value Logarithmic scale?\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"logarithmic\", value)) {\r\n this.invalidate();\r\n this.series.each(function (series) {\r\n series.invalidateDataItems();\r\n });\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxis.prototype, \"keepSelection\", {\r\n /**\r\n * @return Preseve zoom after data update?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"keepSelection\");\r\n },\r\n /**\r\n * Indicates if a current selection (zoom) should be kept across data updates.\r\n *\r\n * If your axis is zoomed while chart's data is updated, the axis will try\r\n * to retain the same start and end values.\r\n *\r\n * You can also use this to initially pre-zoom axis:\r\n *\r\n * ```TypeScript\r\n * axis.keepSelection = true;\r\n * axis.start = 0.5;\r\n * axis.end = 0.7;\r\n * ```\r\n * ```JavaScript\r\n * axis.keepSelection = true;\r\n * axis.start = 0.5;\r\n * axis.end = 0.7;\r\n * ```\r\n * ```JSON\r\n * {\r\n * \"xAxes\": [{\r\n * // ...\r\n * \"keepSelection\": true,\r\n * \"start\": 0.5,\r\n * \"end\": 0.7\r\n * }]\r\n * }\r\n * ```\r\n *\r\n * The above will start the chart zoomed from the middle of the actual scope\r\n * to 70%.\r\n *\r\n * @since 4.1.1\r\n * @default false\r\n * @param value Preseve zoom after data update?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"keepSelection\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxis.prototype, \"includeRangesInMinMax\", {\r\n /**\r\n * @return Include ranges?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"includeRangesInMinMax\");\r\n },\r\n /**\r\n * If set to `true`, values of axis ranges will be included when calculating\r\n * range of values / scale of the [[ValueAxis]].\r\n *\r\n * @default false\r\n * @since 4.4.9\r\n * @param value Include ranges?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"includeRangesInMinMax\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxis.prototype, \"maxPrecision\", {\r\n /**\r\n * @return max precision\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"maxPrecision\");\r\n },\r\n /**\r\n * Maximum number of decimals to allow when placing grid lines and labels\r\n * on axis.\r\n *\r\n * Set it to `0` (zero) to force integer-only axis labels.\r\n *\r\n * @param {number}\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"maxPrecision\", value)) {\r\n this.invalidate();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxis.prototype, \"extraTooltipPrecision\", {\r\n /**\r\n * @return Extra decimals\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"extraTooltipPrecision\");\r\n },\r\n /**\r\n * This setting allows using bigger precision for numbers displayed in axis\r\n * tooltip.\r\n *\r\n * Please note that this setting indicates additional decimal places to\r\n * automatically-calculated axis number precision.\r\n *\r\n * So if your axis displays numbers like 0.1, 0.2, etc. (one decimal place),\r\n * and you set `extraTooltipPrecision = 1`, tooltips will display numbers\r\n * like 0.12, 0.25, etc. (two decimal places).\r\n *\r\n * @default 0\r\n * @since 4.8.3\r\n * @param value Extra decimals\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"extraTooltipPrecision\", value)) {\r\n this.invalidate();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Invalidates axis data items when series extremes change\r\n */\r\n ValueAxis.prototype.handleExtremesChange = function () {\r\n var _this = this;\r\n this._extremesChanged = true;\r\n this.getMinMax();\r\n if (this.ghostLabel) {\r\n var mw_1 = 0;\r\n this.dataItems.each(function (dataItem) {\r\n if (dataItem.label && dataItem.label.pixelWidth > mw_1) {\r\n _this.ghostLabel.text = dataItem.label.currentText;\r\n }\r\n });\r\n }\r\n };\r\n /**\r\n * Returns relative position on axis for series' data item's value.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description (review)\r\n * @param dataItem Data item\r\n * @param key Data field to get value from\r\n * @param location Location (0-1)\r\n * @param stackKey ?\r\n * @return X coordinate (px)\r\n */\r\n ValueAxis.prototype.getX = function (dataItem, key, location, stackKey, range) {\r\n return this.renderer.positionToPoint(this.getPositionX(dataItem, key, location, stackKey, range)).x;\r\n };\r\n /**\r\n * Returns the X coordinate for series' data item's value.\r\n *\r\n * @since 4.5.14\r\n * @param dataItem Data item\r\n * @param key Data field to get value from\r\n * @param location Location (0-1)\r\n * @param stackKey ?\r\n * @return Relative position\r\n */\r\n ValueAxis.prototype.getPositionX = function (dataItem, key, location, stackKey, range) {\r\n var value = dataItem.getWorkingValue(key);\r\n if (!$type.hasValue(stackKey)) {\r\n stackKey = \"valueX\";\r\n }\r\n var stack = dataItem.getValue(stackKey, \"stack\");\r\n if (!$type.isNumber(value)) {\r\n value = this.baseValue;\r\n if (this.logarithmic) {\r\n if (stack > 0) {\r\n value = 0;\r\n }\r\n }\r\n }\r\n var position = this.valueToPosition(value + stack);\r\n if (range) {\r\n position = $math.fitToRange(position, range.start, range.end);\r\n }\r\n return position;\r\n };\r\n /**\r\n * Returns the Y coordinate for series' data item's value.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description (review)\r\n * @param dataItem Data item\r\n * @param key Data field to get value from\r\n * @param location Location (0-1)\r\n * @param stackKey Stack ID\r\n * @return Y coordinate (px)\r\n */\r\n ValueAxis.prototype.getY = function (dataItem, key, location, stackKey, range) {\r\n return this.renderer.positionToPoint(this.getPositionY(dataItem, key, location, stackKey, range)).y;\r\n };\r\n /**\r\n * Returns relative position on axis for series' data item's value.\r\n *\r\n * @since 4.5.14\r\n * @param dataItem Data item\r\n * @param key Data field to get value from\r\n * @param location Location (0-1)\r\n * @param stackKey Stack ID\r\n * @return Relative position\r\n */\r\n ValueAxis.prototype.getPositionY = function (dataItem, key, location, stackKey, range) {\r\n var value = dataItem.getWorkingValue(key);\r\n if (!$type.hasValue(stackKey)) {\r\n stackKey = \"valueY\";\r\n }\r\n var stack = dataItem.getValue(stackKey, \"stack\");\r\n if (!$type.isNumber(value)) {\r\n value = this.baseValue;\r\n if (this.logarithmic) {\r\n if (stack > 0) {\r\n value = 0;\r\n }\r\n }\r\n }\r\n var position = this.valueToPosition(value + stack);\r\n if (range) {\r\n position = $math.fitToRange(position, range.start, range.end);\r\n }\r\n return position;\r\n };\r\n /**\r\n * Returns an angle for series data item.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description (review)\r\n * @param dataItem Data item\r\n * @param key Data field to get value from\r\n * @param location Location (0-1)\r\n * @param stackKey Stack ID\r\n * @param range Range to fit in\r\n * @return Angle\r\n */\r\n ValueAxis.prototype.getAngle = function (dataItem, key, location, stackKey, range) {\r\n var value = dataItem.getWorkingValue(key);\r\n var stack = dataItem.getValue(stackKey, \"stack\");\r\n if (!$type.isNumber(value)) {\r\n value = this.baseValue;\r\n }\r\n var position = this.valueToPosition(value + stack);\r\n if (range) {\r\n position = $math.fitToRange(position, range.start, range.end);\r\n }\r\n return this.positionToAngle(position);\r\n };\r\n /**\r\n * [getAnyRangePath description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param start [description]\r\n * @param end [description]\r\n * @param location [description]\r\n * @return [description]\r\n */\r\n ValueAxis.prototype.getAnyRangePath = function (start, end, location) {\r\n var startPosition = this.valueToPosition(start);\r\n var endPosition = this.valueToPosition(end);\r\n return this.getPositionRangePath(startPosition, endPosition); // Base class (Axis) gets range shape from AxisRenderer\r\n };\r\n /**\r\n * Returns text to show in a axis tooltip, based on specific position within\r\n * axis.\r\n *\r\n * The label will be formatted as per [[NumberFormatter]] set for the whole\r\n * chart, or explicitly for this Axis.\r\n *\r\n * @ignore Exclude from docs\r\n * @param position Position (px)\r\n * @return Label (numeric value)\r\n */\r\n ValueAxis.prototype.getTooltipText = function (position) {\r\n var value = $math.round(this.positionToValue(position), this._stepDecimalPlaces + this.extraTooltipPrecision);\r\n var valueStr = this.tooltip.numberFormatter.format(value);\r\n if (!this._adapterO) {\r\n return valueStr;\r\n }\r\n else {\r\n return this._adapterO.apply(\"getTooltipText\", valueStr);\r\n }\r\n };\r\n /**\r\n * Zooms axis to specific values.\r\n *\r\n * @param startValue Start value\r\n * @param endValue End value\r\n * @param skipRangeEvent Do not invoke events\r\n * @param instantly Do not play zoom animations\r\n */\r\n ValueAxis.prototype.zoomToValues = function (startValue, endValue, skipRangeEvent, instantly) {\r\n var start = (startValue - this.min) / (this.max - this.min);\r\n var end = (endValue - this.min) / (this.max - this.min);\r\n this.zoom({ start: start, end: end }, skipRangeEvent, instantly);\r\n };\r\n Object.defineProperty(ValueAxis.prototype, \"minZoomed\", {\r\n /**\r\n * A smallest value in axis scale within current zoom.\r\n *\r\n * @return Min zoom value\r\n */\r\n get: function () {\r\n if (!this.syncWithAxis) {\r\n return $math.max(this.min, this._minZoomed);\r\n }\r\n else {\r\n return this._minZoomed;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxis.prototype, \"maxZoomed\", {\r\n /**\r\n * A biggest value in axis scale within current zoom.\r\n * @return [description]\r\n */\r\n get: function () {\r\n if (!this.syncWithAxis) {\r\n return $math.min(this.max, this._maxZoomed);\r\n }\r\n else {\r\n return this._maxZoomed;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Updates positioning of Axis breaks after something changes.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n ValueAxis.prototype.fixAxisBreaks = function () {\r\n var _this = this;\r\n _super.prototype.fixAxisBreaks.call(this);\r\n var axisBreaks = this._axisBreaks;\r\n if (axisBreaks && axisBreaks.length > 0) {\r\n // process breaks\r\n axisBreaks.each(function (axisBreak) {\r\n var startValue = axisBreak.adjustedStartValue;\r\n var endValue = axisBreak.adjustedEndValue;\r\n // break difference\r\n var axisBreakDif = endValue - startValue;\r\n var axisBreakGridCount = Math.ceil(axisBreakDif * axisBreak.breakSize) * _this._gridCount / (_this.max - _this.min);\r\n // calculate min, max and step for axis break\r\n var breakMinMaxStep = _this.adjustMinMax(startValue, endValue, axisBreakDif, axisBreakGridCount, true);\r\n axisBreak.adjustedStep = breakMinMaxStep.step;\r\n axisBreak.adjustedMin = breakMinMaxStep.min;\r\n axisBreak.adjustedMax = breakMinMaxStep.max;\r\n });\r\n }\r\n this._difference = this.adjustDifference(this.min, this.max);\r\n };\r\n /**\r\n * Returns value based on position.\r\n *\r\n * Please note that `position` represents position within axis which may be\r\n * zoomed and not correspond to Cursor's `position`.\r\n *\r\n * To convert Cursor's `position` to Axis' `position` use `toAxisPosition()` method.\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/tutorials/tracking-cursors-position-via-api/#Tracking_Cursor_s_position} For more information about cursor tracking.\r\n * @param position Relative position on axis (0-1)\r\n * @return Position label\r\n */\r\n ValueAxis.prototype.getPositionLabel = function (position) {\r\n var value = this.positionToValue(position);\r\n return this.numberFormatter.format(value);\r\n };\r\n /**\r\n * Shows Axis tooltip at specific value\r\n *\r\n * @param value Value\r\n */\r\n ValueAxis.prototype.showTooltipAt = function (value) {\r\n this.showTooltipAtPosition(this.valueToPosition(value));\r\n };\r\n /**\r\n * Copies all properties and related data from a different instance of Axis.\r\n *\r\n * @param source Source Axis\r\n */\r\n ValueAxis.prototype.copyFrom = function (source) {\r\n _super.prototype.copyFrom.call(this, source);\r\n this.min = source.min;\r\n this.max = source.max;\r\n this.calculateTotals = source.calculateTotals;\r\n this._baseValue = source.baseValue;\r\n };\r\n Object.defineProperty(ValueAxis.prototype, \"syncWithAxis\", {\r\n /**\r\n * @return Target axis\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"syncWithAxis\");\r\n },\r\n /**\r\n * Enables syncing of grid with another axis.\r\n *\r\n * To enable, set to a reference of the other `ValueAxis`. This axis will try\r\n * to maintain its scale in such way that its grid matches target axis grid.\r\n *\r\n * IMPORTANT #1: At this stage it's an experimental feature. Use it at your\r\n * own risk, as it may not work in 100% of the scenarios.\r\n *\r\n * IMPORTANT #2: `syncWithAxis` is not compatible with `strictMinMax` and\r\n * `sequencedInterpolation` settings.\r\n *\r\n * IMPORTANT #3: `syncWithAxis` is not compatible with scrollbars. Make sure\r\n * you do not add a scrollbar in the same direction as synced axes. For\r\n * example, if you have vertical synced axes, do not add `scrollbarY` on\r\n * your chart. It will create anomalies when used.\r\n *\r\n * IMPORTANT #4: `syncWithAxis` is not compatible with `XYCursor` if it has\r\n * its `behavior` set to either `zoomY` or `zoomXY`.\r\n *\r\n * @since 4.8.1\r\n * @param axis Target axis\r\n */\r\n set: function (axis) {\r\n var _this = this;\r\n if (this.setPropertyValue(\"syncWithAxis\", axis, true)) {\r\n if (axis) {\r\n this._disposers.push(axis.events.on(\"extremeschanged\", this.handleSelectionExtremesChange, this, false));\r\n this._disposers.push(axis.events.on(\"selectionextremeschanged\", this.handleSelectionExtremesChange, this, false));\r\n this._disposers.push(axis.events.on(\"startendchanged\", this.handleSelectionExtremesChange, this, false));\r\n this.events.on(\"shown\", this.handleSelectionExtremesChange, this, false);\r\n this.events.on(\"maxsizechanged\", function () {\r\n _this.clearCache();\r\n _this._disposers.push(registry.events.once(\"exitframe\", function () {\r\n _this.handleSelectionExtremesChange();\r\n }));\r\n }, this, false);\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ValueAxis.prototype, \"treatZeroAs\", {\r\n /**\r\n * @return Zero replacement value\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"treatZeroAs\");\r\n },\r\n /**\r\n * If set, zero values will be treated as this value.\r\n *\r\n * It is useful if you need to use data with zero-values on a logarithmic\r\n * axis scale.\r\n *\r\n * @since 4.9.34\r\n * @param value Zero replacement value\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"treatZeroAs\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Syncs with a target axis.\r\n *\r\n * @param min Min\r\n * @param max Max\r\n * @param step Step\r\n */\r\n ValueAxis.prototype.syncAxes = function (min, max, step) {\r\n var axis = this.syncWithAxis;\r\n if (axis) {\r\n if (!$type.isNumber(min)) {\r\n min = this.min;\r\n }\r\n if (!$type.isNumber(max)) {\r\n max = this.max;\r\n }\r\n if (!$type.isNumber(step)) {\r\n step = this._step;\r\n }\r\n var count = Math.round((axis.maxZoomed - axis.minZoomed) / axis.step);\r\n var currentCount = Math.round((max - min) / step);\r\n if ($type.isNumber(count) && $type.isNumber(currentCount)) {\r\n var synced = false;\r\n var c = 0;\r\n var diff = (max - min) * 0.01;\r\n var omin = min;\r\n var omax = max;\r\n var ostep = step;\r\n while (synced != true) {\r\n synced = this.checkSync(omin, omax, ostep, count);\r\n c++;\r\n if (c > 1000) {\r\n synced = true;\r\n }\r\n if (!synced) {\r\n //omin = min - diff * c;\r\n if (c / 3 == Math.round(c / 3)) {\r\n omin = min - diff * c;\r\n if (min >= 0 && omin < 0) {\r\n omin = 0;\r\n }\r\n }\r\n else {\r\n omax = max + diff * c;\r\n if (omax <= 0 && omax > 0) {\r\n omax = 0;\r\n }\r\n }\r\n var minMaxStep = this.adjustMinMax(omin, omax, omax - omin, this._gridCount, true);\r\n omin = minMaxStep.min;\r\n omax = minMaxStep.max;\r\n ostep = minMaxStep.step;\r\n }\r\n else {\r\n min = omin;\r\n max = omax;\r\n step = ostep;\r\n }\r\n }\r\n }\r\n }\r\n return { min: min, max: max, step: step };\r\n };\r\n /**\r\n * Returns `true` if axis needs to be resunced with some other axis.\r\n */\r\n ValueAxis.prototype.checkSync = function (min, max, step, count) {\r\n var currentCount = (max - min) / step;\r\n for (var i = 1; i < count; i++) {\r\n if ($math.round(currentCount / i, 1) == count || currentCount * i == count) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n };\r\n /**\r\n * Processes JSON-based config before it is applied to the object.\r\n *\r\n * @ignore Exclude from docs\r\n * @param config Config\r\n */\r\n ValueAxis.prototype.processConfig = function (config) {\r\n if (config) {\r\n // Set up axes\r\n if ($type.hasValue(config.syncWithAxis) && $type.isString(config.syncWithAxis)) {\r\n if (this.map.hasKey(config.syncWithAxis)) {\r\n config.syncWithAxis = this.map.getKey(config.syncWithAxis);\r\n }\r\n else {\r\n this.processingErrors.push(\"[ValueAxis] No axis with id \\\"\" + config.syncWithAxis + \"\\\" found for `syncWithAxis`\");\r\n delete config.xAxis;\r\n }\r\n }\r\n }\r\n _super.prototype.processConfig.call(this, config);\r\n };\r\n ValueAxis.prototype._saveMinMax = function (_min, _max) {\r\n };\r\n return ValueAxis;\r\n}(Axis));\r\nexport { ValueAxis };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"ValueAxis\"] = ValueAxis;\r\nregistry.registeredClasses[\"ValueAxisDataItem\"] = ValueAxisDataItem;\r\n//# sourceMappingURL=ValueAxis.js.map","/**\r\n * Module, defining Axis Renderer for vertical axes.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { AxisRenderer } from \"./AxisRenderer\";\r\nimport { AxisBullet } from \"./AxisBullet\";\r\nimport { WavedLine } from \"../../core/elements/WavedLine\";\r\nimport { WavedRectangle } from \"../../core/elements/WavedRectangle\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { percent, Percent } from \"../../core/utils/Percent\";\r\nimport * as $math from \"../../core/utils/Math\";\r\nimport * as $path from \"../../core/rendering/Path\";\r\nimport * as $utils from \"../../core/utils/Utils\";\r\nimport * as $type from \"../../core/utils/Type\";\r\nimport { defaultRules, ResponsiveBreakpoints } from \"../../core/utils/Responsive\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A renderer for horizontal axis.\r\n *\r\n * @see {@link IAxisRendererEvents} for a list of available events\r\n * @see {@link IAxisRendererAdapters} for a list of available Adapters\r\n */\r\nvar AxisRendererX = /** @class */ (function (_super) {\r\n __extends(AxisRendererX, _super);\r\n /**\r\n * Constructor.\r\n *\r\n * @param axis Related axis\r\n */\r\n function AxisRendererX() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"AxisRendererX\";\r\n _this.minGridDistance = 120;\r\n _this.opposite = false;\r\n _this.rotation = 0;\r\n _this.width = percent(100);\r\n _this.labels.template.horizontalCenter = \"middle\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * @ignore\r\n */\r\n AxisRendererX.prototype.setAxis = function (axis) {\r\n _super.prototype.setAxis.call(this, axis);\r\n axis.layout = \"vertical\";\r\n };\r\n /**\r\n * @ignore\r\n */\r\n AxisRendererX.prototype.updateGridContainer = function () {\r\n var axis = this.axis;\r\n if (axis) {\r\n var gridContainer = this.gridContainer;\r\n gridContainer.x = axis.pixelX;\r\n gridContainer.width = axis.axisLength;\r\n }\r\n };\r\n /**\r\n * Called when rendered is attached to an Axis, as well as a property of\r\n * Axis that might affect the appearance is updated.\r\n *\r\n * E.g. `axis.opposite`, `axis.inside`, etc.\r\n *\r\n * This method is called **before** draw, so that any related setting\r\n * changed in this method can be changed.\r\n *\r\n * @todo Description (review)\r\n * @ignore Exclude from docs\r\n */\r\n AxisRendererX.prototype.processRenderer = function () {\r\n _super.prototype.processRenderer.call(this);\r\n // can not do this in init, as axis is set later\r\n var axis = this.axis;\r\n if (axis) {\r\n if (!(axis.width instanceof Percent)) {\r\n axis.width = percent(100);\r\n }\r\n // @todo Is thi sneeded?\r\n $utils.used(this.line);\r\n var title = axis.title;\r\n title.rotation = 0;\r\n title.align = \"center\";\r\n if (this.opposite) {\r\n this.line.toFront();\r\n title.toBack();\r\n }\r\n else {\r\n title.toFront();\r\n this.toBack();\r\n this.line.toBack();\r\n }\r\n }\r\n };\r\n /**\r\n * Updates some of the Axis tooltip's visual properties, related to\r\n * rendering of the Axis.\r\n *\r\n * @todo Description (review)\r\n * @ignore Exclude from docs\r\n */\r\n AxisRendererX.prototype.updateTooltip = function () {\r\n var axis = this.axis;\r\n if (axis) {\r\n var bigNum = 1000;\r\n var bbx = this.line.pixelX;\r\n var bby = this.line.pixelY;\r\n var bbw = this.axisLength;\r\n var bbh = bigNum;\r\n // top\r\n if (this.opposite) {\r\n if (!this.inside) {\r\n bby = -bigNum;\r\n bbh = bigNum;\r\n }\r\n }\r\n // bottom\r\n else {\r\n if (this.inside) {\r\n bby = -bigNum;\r\n bbh = bigNum;\r\n }\r\n }\r\n this.axis.updateTooltip(\"vertical\", { x: bbx, y: bby, width: bbw, height: bbh });\r\n }\r\n };\r\n /**\r\n * Updates and positions a label element.\r\n *\r\n * @ignore Exclude from docs\r\n * @param label Label element\r\n * @param position Starting position\r\n * @param endPosition Ending position\r\n */\r\n AxisRendererX.prototype.updateLabelElement = function (label, position, endPosition, location) {\r\n if (!$type.hasValue(location)) {\r\n location = label.location;\r\n }\r\n position = position + (endPosition - position) * location;\r\n var point = this.positionToPoint(position);\r\n label.isMeasured = !label.inside;\r\n var deltaY = 0;\r\n var verticalCenter;\r\n var maxHeight = this.gridContainer.maxHeight;\r\n if (this.opposite) {\r\n if (label.inside) {\r\n verticalCenter = \"top\";\r\n if (label.valign == \"bottom\") {\r\n deltaY = maxHeight;\r\n verticalCenter = \"bottom\";\r\n }\r\n if (label.valign == \"middle\") {\r\n deltaY = maxHeight / 2;\r\n verticalCenter = \"middle\";\r\n }\r\n }\r\n else {\r\n verticalCenter = \"bottom\";\r\n }\r\n point.y = deltaY;\r\n }\r\n else {\r\n if (label.inside) {\r\n verticalCenter = \"bottom\";\r\n if (label.valign == \"top\") {\r\n deltaY = -maxHeight;\r\n verticalCenter = \"top\";\r\n }\r\n if (label.valign == \"middle\") {\r\n deltaY = -maxHeight / 2;\r\n verticalCenter = \"middle\";\r\n }\r\n }\r\n else {\r\n verticalCenter = \"top\";\r\n }\r\n point.y += deltaY;\r\n }\r\n if (label.rotation == 0) {\r\n // Apply fuzzy logic to verticalCenter only if labels are not rotated\r\n label.verticalCenter = verticalCenter;\r\n }\r\n this.positionItem(label, point);\r\n this.toggleVisibility(label, position, this.minLabelPosition, this.maxLabelPosition);\r\n };\r\n Object.defineProperty(AxisRendererX.prototype, \"axisLength\", {\r\n /**\r\n * Returns actual length of the Axis, in pixels.\r\n *\r\n * @return Length (px)\r\n */\r\n get: function () {\r\n var axis = this.axis;\r\n return (axis.measuredWidth - axis.pixelPaddingRight - axis.pixelPaddingLeft) || 0;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Converts relative position on axis to point coordinates.\r\n *\r\n * @param position Position (0-1)\r\n * @param position2 Position (0-1) Position on the second axis\r\n * @return Point\r\n */\r\n AxisRendererX.prototype.positionToPoint = function (position, position2) {\r\n return { x: this.positionToCoordinate(position), y: 0 };\r\n };\r\n /**\r\n * Converts a point at specific coordinates to a relative position (0-1)\r\n * on the axis.\r\n *\r\n * @param point Point\r\n * @return Position (0-1)\r\n */\r\n AxisRendererX.prototype.pointToPosition = function (point) {\r\n return this.coordinateToPosition(point.x, point.y);\r\n };\r\n /**\r\n * [getPositionRangePath description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param startPosition Starting position\r\n * @param endPosition End position\r\n * @return SVG path\r\n */\r\n AxisRendererX.prototype.getPositionRangePath = function (startPosition, endPosition) {\r\n var x1 = $math.fitToRange(this.positionToCoordinate(startPosition), 0, this.axisLength);\r\n var x2 = $math.fitToRange(this.positionToCoordinate(endPosition), 0, this.axisLength);\r\n var w = Math.abs(x2 - x1);\r\n var h = this.getHeight();\r\n var x = Math.min(x1, x2);\r\n var y = 0;\r\n return $path.rectToPath({\r\n x: x,\r\n y: y,\r\n width: w,\r\n height: h\r\n }, true);\r\n };\r\n /**\r\n * Updates and positions an axis break element.\r\n *\r\n * @ignore Exclude from docs\r\n * @param axisBreak Break element\r\n */\r\n AxisRendererX.prototype.updateBreakElement = function (axisBreak) {\r\n _super.prototype.updateBreakElement.call(this, axisBreak);\r\n var startLine = axisBreak.startLine;\r\n var endLine = axisBreak.endLine;\r\n var fillShape = axisBreak.fillShape;\r\n var startPoint = axisBreak.startPoint;\r\n var endPoint = axisBreak.endPoint;\r\n var y1 = axisBreak.pixelMarginLeft;\r\n var y2 = this.getHeight() - axisBreak.pixelMarginTop - axisBreak.pixelMarginBottom;\r\n startPoint.x = $math.fitToRange(startPoint.x, -1, this.axisLength + 1);\r\n endPoint.x = $math.fitToRange(endPoint.x, -1, this.axisLength + 1);\r\n if (startPoint.x == endPoint.x && (startPoint.x < 0 || startPoint.x > this.axisLength)) {\r\n axisBreak.fillShape.__disabled = true;\r\n }\r\n else {\r\n axisBreak.fillShape.__disabled = false;\r\n }\r\n startLine.y = y1;\r\n startLine.width = 0;\r\n startLine.height = y2;\r\n endLine.y = y1;\r\n endLine.width = 0;\r\n endLine.height = y2;\r\n fillShape.height = y2;\r\n fillShape.width = Math.abs(endPoint.x - startPoint.x);\r\n fillShape.y = y1;\r\n fillShape.x = startPoint.x;\r\n };\r\n /**\r\n * Updates and positions a grid element.\r\n *\r\n * @ignore Exclude from docs\r\n * @param grid Grid element\r\n * @param position Starting position\r\n * @param endPosition End position\r\n */\r\n AxisRendererX.prototype.updateGridElement = function (grid, position, endPosition) {\r\n position = position + (endPosition - position) * grid.location;\r\n var point = this.positionToPoint(position);\r\n //point.x = $utils.spritePointToSprite({x:point.x, y:0}, this, this.gridContainer).x;\r\n grid.path = $path.moveTo({ x: 0, y: 0 }) + $path.lineTo({ x: 0, y: this.getHeight() });\r\n this.positionItem(grid, point);\r\n this.toggleVisibility(grid, position, 0, 1);\r\n };\r\n /**\r\n * Updates and positions a tick element.\r\n *\r\n * @ignore Exclude from docs\r\n * @param tick Tick element\r\n * @param position Starting position\r\n * @param endPosition End position\r\n */\r\n AxisRendererX.prototype.updateTickElement = function (tick, position, endPosition) {\r\n position = position + (endPosition - position) * tick.location;\r\n var point = this.positionToPoint(position);\r\n var tickLength = tick.length;\r\n point.y = $utils.spritePointToSprite({ x: 0, y: this.line.pixelY }, this.line.parent, this.gridContainer).y;\r\n if (this.opposite) {\r\n tickLength *= (tick.inside ? 1 : -1);\r\n }\r\n else {\r\n tickLength *= (tick.inside ? -1 : 1);\r\n }\r\n tick.path = $path.moveTo({ x: 0, y: 0 }) + $path.lineTo({ x: 0, y: tickLength });\r\n this.positionItem(tick, point);\r\n this.toggleVisibility(tick, position, 0, 1);\r\n };\r\n /**\r\n * Updates and positions the axis line element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n AxisRendererX.prototype.updateAxisLine = function () {\r\n this.line.path = $path.moveTo({ x: 0, y: 0 }) + $path.lineTo({ x: this.axisLength, y: 0 });\r\n };\r\n /**\r\n * Updates and positions the base grid element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n AxisRendererX.prototype.updateBaseGridElement = function () {\r\n _super.prototype.updateBaseGridElement.call(this);\r\n var axis = this.axis;\r\n var h = this.getHeight();\r\n var w = this.axisLength;\r\n var baseGrid = this.baseGrid;\r\n var x = axis.basePoint.x;\r\n if (x < -0.2 || x > w + 0.2) {\r\n baseGrid.hide(0);\r\n }\r\n else {\r\n var y = $utils.spritePointToSprite({ x: 0, y: 0 }, this.gridContainer, baseGrid.parent).y;\r\n baseGrid.path = $path.moveTo({ x: 0, y: 0 }) + $path.lineTo({ x: 0, y: h });\r\n baseGrid.moveTo({ x: x, y: y });\r\n baseGrid.show(0);\r\n }\r\n };\r\n /**\r\n * Creates visual elements for and axis break.\r\n *\r\n * @ignore Exclude from docs\r\n * @param axisBreak Axis break\r\n */\r\n AxisRendererX.prototype.createBreakSprites = function (axisBreak) {\r\n axisBreak.startLine = new WavedLine();\r\n axisBreak.endLine = new WavedLine();\r\n var wavedRectangle = new WavedRectangle();\r\n wavedRectangle.setWavedSides(false, true, false, true);\r\n axisBreak.fillShape = wavedRectangle;\r\n };\r\n /**\r\n * @ignore\r\n */\r\n AxisRendererX.prototype.toAxisPosition = function (value) {\r\n var inversedPosition = value;\r\n var axis = this.axis;\r\n if (axis) {\r\n var relativePositionSprite = axis.relativePositionSprite;\r\n var x = axis.pixelX;\r\n if (relativePositionSprite) {\r\n x = $utils.spritePointToSprite({ x: this.pixelX, y: 0 }, this.parent, relativePositionSprite).x;\r\n }\r\n else {\r\n relativePositionSprite = axis.parent;\r\n }\r\n if (relativePositionSprite) {\r\n var relativeX = x / relativePositionSprite.innerWidth;\r\n var relativeWidth = axis.axisLength / relativePositionSprite.innerWidth;\r\n return (inversedPosition - relativeX) / relativeWidth;\r\n }\r\n }\r\n return value;\r\n };\r\n /**\r\n * Updates and positions axis bullets.\r\n *\r\n * @ignore Exclude from docs\r\n * @param bullet AxisBullet element\r\n * @param position Starting position\r\n * @param endPosition End position\r\n */\r\n AxisRendererX.prototype.updateBullet = function (bullet, position, endPosition) {\r\n var location = 0.5;\r\n if (bullet instanceof AxisBullet) {\r\n location = bullet.location;\r\n }\r\n position = position + (endPosition - position) * location;\r\n var point = this.positionToPoint(position);\r\n point.y = $utils.spritePointToSprite({ x: 0, y: this.line.pixelY }, this.line.parent, this.gridContainer).y;\r\n this.positionItem(bullet, point);\r\n this.toggleVisibility(bullet, position, 0, 1);\r\n };\r\n return AxisRendererX;\r\n}(AxisRenderer));\r\nexport { AxisRendererX };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"AxisRendererX\"] = AxisRendererX;\r\n/**\r\n * Add default responsive rules\r\n */\r\n/**\r\n * Put labels inside plot area.\r\n * Disable first and last labels.\r\n */\r\ndefaultRules.push({\r\n relevant: ResponsiveBreakpoints.heightXS,\r\n state: function (target, stateId) {\r\n if (target instanceof AxisRendererX) {\r\n var state = target.states.create(stateId);\r\n state.properties.inside = true;\r\n state.properties.maxLabelPosition = 0.9;\r\n state.properties.minLabelPosition = 0.1;\r\n return state;\r\n }\r\n return null;\r\n }\r\n});\r\n/**\r\n * Disable labels altogather on very small charts\r\n */\r\ndefaultRules.push({\r\n relevant: ResponsiveBreakpoints.heightXXS,\r\n state: function (target, stateId) {\r\n if (target instanceof AxisRendererX) {\r\n var state = target.states.create(stateId);\r\n state.properties.disabled = true;\r\n return state;\r\n }\r\n return null;\r\n }\r\n});\r\n//# sourceMappingURL=AxisRendererX.js.map","/**\r\n * HeatLegend module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../../core/Container\";\r\nimport { LinearGradient } from \"../../core/rendering/fills/LinearGradient\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { toColor, Color } from \"../../core/utils/Color\";\r\nimport { ListTemplate, ListDisposer } from \"../../core/utils/List\";\r\nimport { percent } from \"../../core/utils/Percent\";\r\nimport { ValueAxis } from \"../../charts/axes/ValueAxis\";\r\nimport { AxisRendererX } from \"../../charts/axes/AxisRendererX\";\r\nimport { AxisRendererY } from \"../../charts/axes/AxisRendererY\";\r\nimport * as $iter from \"../../core/utils/Iterator\";\r\nimport * as $type from \"../../core/utils/Type\";\r\nimport * as $colors from \"../../core/utils/Colors\";\r\nimport { RoundedRectangle } from \"../../core/elements/RoundedRectangle\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * This class creates a link (waved color-filled line) between two nodes in a\r\n * Sankey Diagram.\r\n *\r\n * @see {@link IHeatLegendEvents} for a list of available events\r\n * @see {@link IHeatLegendAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar HeatLegend = /** @class */ (function (_super) {\r\n __extends(HeatLegend, _super);\r\n /**\r\n * Constructor\r\n */\r\n function HeatLegend() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"HeatLegend\";\r\n _this.markerContainer = _this.createChild(Container);\r\n _this.markerContainer.shouldClone = false;\r\n _this.markerCount = 1;\r\n // Create a template container and list for the a marker\r\n var marker = new RoundedRectangle();\r\n marker.minHeight = 20;\r\n marker.minWidth = 20;\r\n marker.interactionsEnabled = false;\r\n marker.fillOpacity = 1;\r\n marker.cornerRadius(0, 0, 0, 0);\r\n _this.markerContainer.minHeight = 20;\r\n _this.markerContainer.minWidth = 20;\r\n _this.orientation = \"horizontal\";\r\n _this.markers = new ListTemplate(marker);\r\n _this._disposers.push(new ListDisposer(_this.markers));\r\n _this._disposers.push(_this.markers.template);\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n HeatLegend.prototype.getMinFromRules = function (property) {\r\n var series = this.series;\r\n if (series) {\r\n var minValue_1;\r\n $iter.eachContinue(series.heatRules.iterator(), function (heatRule) {\r\n if (heatRule.property == property) {\r\n minValue_1 = heatRule.min;\r\n return false;\r\n }\r\n return true;\r\n });\r\n return minValue_1;\r\n }\r\n };\r\n HeatLegend.prototype.getMaxFromRules = function (property) {\r\n var series = this.series;\r\n if (series) {\r\n var maxValue_1;\r\n $iter.each(series.heatRules.iterator(), function (heatRule) {\r\n if (heatRule.property == property) {\r\n maxValue_1 = heatRule.max;\r\n return false;\r\n }\r\n return true;\r\n });\r\n return maxValue_1;\r\n }\r\n };\r\n /**\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n HeatLegend.prototype.validate = function () {\r\n _super.prototype.validate.call(this);\r\n this.valueAxis.renderer.inversed = this.reverseOrder;\r\n var series = this.series;\r\n var minColor = this.minColor;\r\n var maxColor = this.maxColor;\r\n if (!$type.hasValue(minColor)) {\r\n minColor = toColor(this.getMinFromRules(\"fill\"));\r\n }\r\n if (!$type.hasValue(maxColor)) {\r\n maxColor = toColor(this.getMaxFromRules(\"fill\"));\r\n }\r\n if (series) {\r\n var seriesFill = series.fill;\r\n if (!$type.hasValue(minColor) && seriesFill instanceof Color) {\r\n minColor = seriesFill;\r\n }\r\n if (!$type.hasValue(maxColor) && seriesFill instanceof Color) {\r\n maxColor = seriesFill;\r\n }\r\n }\r\n if (!$type.hasValue(maxColor)) {\r\n maxColor = toColor(this.getMaxFromRules(\"fill\"));\r\n }\r\n var minOpacity = $type.toNumber(this.getMinFromRules(\"fillOpacity\"));\r\n if (!$type.isNumber(minOpacity)) {\r\n minOpacity = 1;\r\n }\r\n var maxOpacity = $type.toNumber(this.getMaxFromRules(\"fillOpacity\"));\r\n if (!$type.isNumber(maxOpacity)) {\r\n maxOpacity = 1;\r\n }\r\n var minStrokeOpacity = $type.toNumber(this.getMinFromRules(\"strokeOpacity\"));\r\n if (!$type.isNumber(minStrokeOpacity)) {\r\n minStrokeOpacity = 1;\r\n }\r\n var maxStrokeOpacity = $type.toNumber(this.getMaxFromRules(\"strokeOpacity\"));\r\n if (!$type.isNumber(maxStrokeOpacity)) {\r\n maxStrokeOpacity = 1;\r\n }\r\n var minStroke = toColor(this.getMinFromRules(\"stroke\"));\r\n var maxStroke = toColor(this.getMaxFromRules(\"stroke\"));\r\n //if (series) {\r\n for (var i = 0; i < this.markerCount; i++) {\r\n var marker = this.markers.getIndex(i);\r\n if (!marker) {\r\n marker = this.markers.create();\r\n marker.parent = this.markerContainer;\r\n marker.height = percent(100);\r\n marker.width = percent(100);\r\n }\r\n if (this.markerCount == 1) {\r\n var gradient = new LinearGradient();\r\n if (this.reverseOrder) {\r\n gradient.addColor(maxColor, maxOpacity);\r\n gradient.addColor(minColor, minOpacity);\r\n }\r\n else {\r\n gradient.addColor(minColor, minOpacity);\r\n gradient.addColor(maxColor, maxOpacity);\r\n }\r\n if (this.orientation == \"vertical\") {\r\n gradient.rotation = -90;\r\n }\r\n marker.fill = gradient;\r\n if ($type.hasValue(minStroke) && $type.hasValue(maxStroke)) {\r\n var strokeGradient = new LinearGradient();\r\n if (this.reverseOrder) {\r\n strokeGradient.addColor(maxStroke, maxStrokeOpacity);\r\n strokeGradient.addColor(minStroke, minStrokeOpacity);\r\n }\r\n else {\r\n strokeGradient.addColor(minStroke, minStrokeOpacity);\r\n strokeGradient.addColor(maxStroke, maxStrokeOpacity);\r\n }\r\n if (this.orientation == \"vertical\") {\r\n strokeGradient.rotation = -90;\r\n }\r\n marker.stroke = strokeGradient;\r\n }\r\n }\r\n else {\r\n var c = i;\r\n if (this.reverseOrder) {\r\n c = this.markerCount - i - 1;\r\n }\r\n var color = new Color($colors.interpolate(minColor.rgb, maxColor.rgb, c / this.markerCount));\r\n marker.fill = color;\r\n var opacity = minOpacity + (maxOpacity - minOpacity) * c / this.markerCount;\r\n marker.fillOpacity = opacity;\r\n if ($type.hasValue(minStroke) && $type.hasValue(maxStroke)) {\r\n var color_1 = new Color($colors.interpolate(minStroke.rgb, maxStroke.rgb, c / this.markerCount));\r\n marker.stroke = color_1;\r\n var opacity_1 = minStrokeOpacity + (maxStrokeOpacity - minStrokeOpacity) * c / this.markerCount;\r\n marker.strokeOpacity = opacity_1;\r\n }\r\n }\r\n }\r\n var renderer = this.valueAxis.renderer;\r\n if (this.markerCount > 1) {\r\n if (this.orientation == \"horizontal\") {\r\n renderer.minGridDistance = this.measuredWidth / this.markerCount;\r\n }\r\n else {\r\n renderer.minGridDistance = this.measuredHeight / this.markerCount;\r\n }\r\n }\r\n this.valueAxis.invalidate();\r\n for (var i = this.markerCount, len = this.markers.length; i < len; i++) {\r\n this.markers.getIndex(i).parent = undefined;\r\n }\r\n };\r\n Object.defineProperty(HeatLegend.prototype, \"minColor\", {\r\n /**\r\n * Returns minColor value\r\n * @return {Color}\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"minColor\");\r\n },\r\n /**\r\n * Min color of a heat legend. If a series is set for the legend, minColor is taken from series.\r\n *\r\n * @param {Color}\r\n */\r\n set: function (value) {\r\n if (!(value instanceof Color)) {\r\n value = toColor(value);\r\n }\r\n this.setColorProperty(\"minColor\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HeatLegend.prototype, \"maxColor\", {\r\n /**\r\n * Returns maxColor value\r\n * @return {Color}\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"maxColor\");\r\n },\r\n /**\r\n * Max color of a heat legend. If a series is set for the legend, maxColor is taken from series.\r\n *\r\n * @param {Color}\r\n */\r\n set: function (value) {\r\n if (!(value instanceof Color)) {\r\n value = toColor(value);\r\n }\r\n this.setColorProperty(\"maxColor\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HeatLegend.prototype, \"markerCount\", {\r\n /**\r\n * Returns number of color squares (markers).\r\n * @return {number}\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"markerCount\");\r\n },\r\n /**\r\n * Number of color squares (markers) in the heat legend. If only 1 marker is used, it will be filled with gradient.\r\n *\r\n * @param {number}\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"markerCount\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HeatLegend.prototype, \"minValue\", {\r\n /**\r\n * Returns minimum value of heat legend.\r\n * @return {number}\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"minValue\");\r\n },\r\n /**\r\n * Minimum value of heat legend's value axis. If a series is set for the legend, min is taken from series.\r\n *\r\n * @param {number}\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"minValue\", value);\r\n this.valueAxis.min = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HeatLegend.prototype, \"maxValue\", {\r\n /**\r\n * Returns maximum value of heat legend.\r\n * @return {number}\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"maxValue\");\r\n },\r\n /**\r\n * Maximum value of heat legend's value axis. If a series is set for the legend, max is taken from series.\r\n *\r\n * @param {number}\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"maxValue\", value);\r\n this.valueAxis.max = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HeatLegend.prototype, \"orientation\", {\r\n /**\r\n * Returns orientation value.\r\n *\r\n * @return {\"horizontal\" | \"vertical\"}\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"orientation\");\r\n },\r\n /**\r\n * Heat legend orientation. Note, if you change orientation of a heat legend, you must set value axis renderer properties after that, as with orientation renderer changes.\r\n *\r\n * @param {\"horizontal\" | \"vertical\"}\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"orientation\", value, true);\r\n var markerContainer = this.markerContainer;\r\n var valueAxis = this.valueAxis;\r\n // HORIZONTAL\r\n if (value == \"horizontal\") {\r\n if (!$type.hasValue(this.width)) {\r\n this.width = 200;\r\n }\r\n this.height = undefined;\r\n valueAxis.width = percent(100);\r\n valueAxis.height = undefined;\r\n valueAxis.tooltip.pointerOrientation = \"vertical\";\r\n this.layout = \"vertical\";\r\n markerContainer.width = percent(100);\r\n markerContainer.height = undefined;\r\n if (!(valueAxis.renderer instanceof AxisRendererX)) {\r\n valueAxis.renderer = new AxisRendererX();\r\n }\r\n }\r\n // VERTICAL\r\n else {\r\n if (!$type.hasValue(this.height)) {\r\n this.height = 200;\r\n }\r\n this.width = undefined;\r\n this.layout = \"horizontal\";\r\n markerContainer.width = undefined;\r\n markerContainer.height = percent(100);\r\n valueAxis.height = percent(100);\r\n valueAxis.width = undefined;\r\n valueAxis.tooltip.pointerOrientation = \"horizontal\";\r\n if (!(valueAxis.renderer instanceof AxisRendererY)) {\r\n valueAxis.renderer = new AxisRendererY();\r\n }\r\n valueAxis.renderer.inside = true;\r\n valueAxis.renderer.labels.template.inside = true;\r\n this.markerContainer.reverseOrder = true;\r\n }\r\n var renderer = valueAxis.renderer;\r\n renderer.grid.template.disabled = true;\r\n renderer.axisFills.template.disabled = true;\r\n renderer.baseGrid.disabled = true;\r\n renderer.labels.template.padding(2, 3, 2, 3);\r\n renderer.minHeight = undefined;\r\n renderer.minWidth = undefined;\r\n this.markerContainer.layout = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HeatLegend.prototype, \"valueAxis\", {\r\n /**\r\n * Returns valueAxis value.\r\n * @return {ValueAxis}\r\n */\r\n get: function () {\r\n if (!this._valueAxis) {\r\n this.valueAxis = this.createChild(ValueAxis);\r\n this.valueAxis.shouldClone = false;\r\n }\r\n return this._valueAxis;\r\n },\r\n /**\r\n * Sets a value axis of heat legend. Value axis for heat legend is created automatically.\r\n * @param {ValueAxis}\r\n */\r\n set: function (valueAxis) {\r\n this._valueAxis = valueAxis;\r\n valueAxis.parent = this;\r\n valueAxis.strictMinMax = true;\r\n this.orientation = this.orientation;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(HeatLegend.prototype, \"series\", {\r\n /**\r\n * Returns series value.\r\n * @return {Series}\r\n */\r\n get: function () {\r\n return this._series;\r\n },\r\n /**\r\n * You can set series for heat legend. It will take min, max, minColor and maxColor values from this series.\r\n * @param series\r\n */\r\n set: function (series) {\r\n var _this = this;\r\n this._series = series;\r\n var dataField = \"value\";\r\n try {\r\n var dataFieldDefined = series.heatRules.getIndex(0).dataField;\r\n if (dataFieldDefined) {\r\n dataField = dataFieldDefined;\r\n }\r\n }\r\n catch (err) {\r\n }\r\n this.updateMinMax(series.dataItem.values[dataField].low, series.dataItem.values[dataField].high);\r\n series.dataItem.events.on(\"calculatedvaluechanged\", function (event) {\r\n _this.updateMinMax(series.dataItem.values[dataField].low, series.dataItem.values[dataField].high);\r\n }, undefined, false);\r\n series.heatRules.events.on(\"inserted\", this.invalidate, this, false);\r\n series.heatRules.events.on(\"removed\", this.invalidate, this, false);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Updates min/max of value axis.\r\n * @ignore\r\n */\r\n HeatLegend.prototype.updateMinMax = function (min, max) {\r\n var valueAxis = this.valueAxis;\r\n if (!$type.isNumber(this.minValue)) {\r\n valueAxis.min = min;\r\n valueAxis.invalidate();\r\n }\r\n if (!$type.isNumber(this.maxValue)) {\r\n valueAxis.max = max;\r\n valueAxis.invalidate();\r\n }\r\n };\r\n /**\r\n * Processes JSON-based config before it is applied to the object.\r\n *\r\n * @ignore Exclude from docs\r\n * @param config Config\r\n */\r\n HeatLegend.prototype.processConfig = function (config) {\r\n if (config) {\r\n // Set up series\r\n if ($type.hasValue(config.series) && $type.isString(config.series)) {\r\n if ($type.isString(config.series)) {\r\n if (this.map.hasKey(config.series)) {\r\n config.series = this.map.getKey(config.series);\r\n }\r\n else {\r\n var seriesId_1 = config.series;\r\n var disposer_1 = this.map.events.on(\"insertKey\", function (ev) {\r\n if (ev.key == seriesId_1) {\r\n this.series = ev.newValue;\r\n disposer_1.dispose();\r\n }\r\n }, this);\r\n this._disposers.push(disposer_1);\r\n delete config.series;\r\n }\r\n }\r\n }\r\n }\r\n _super.prototype.processConfig.call(this, config);\r\n };\r\n return HeatLegend;\r\n}(Container));\r\nexport { HeatLegend };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"HeatLegend\"] = HeatLegend;\r\n//# sourceMappingURL=HeatLegend.js.map","/**\r\n * Grip module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Button } from \"./Button\";\r\nimport { Sprite } from \"../Sprite\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport { registry } from \"../Registry\";\r\nimport { percent } from \"../utils/Percent\";\r\nimport * as $path from \"../rendering/Path\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creates a grip element that can be used for scrolling or other things.\r\n *\r\n * @see {@link IGripEvents} for a list of available events\r\n * @see {@link IGripAdapters} for a list of available Adapters\r\n * @since 4.4.0\r\n */\r\nvar Grip = /** @class */ (function (_super) {\r\n __extends(Grip, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Grip() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"Grip\";\r\n var cs = new InterfaceColorSet();\r\n // Set defaults\r\n _this.layout = \"absolute\";\r\n _this.padding(10, 10, 10, 10);\r\n _this.margin(3, 3, 3, 3);\r\n _this.background.fillOpacity = 0.3;\r\n _this.background.cornerRadius(10, 10, 10, 10);\r\n // Create an icon\r\n var icon = new Sprite();\r\n icon.element = _this.paper.add(\"path\");\r\n var path = $path.moveTo({ x: -6, y: 0 });\r\n path += $path.lineTo({ x: 6, y: 0 });\r\n path += $path.moveTo({ x: -8, y: -6 });\r\n path += $path.lineTo({ x: 0, y: -12 });\r\n path += $path.lineTo({ x: 8, y: -6 });\r\n path += $path.moveTo({ x: -8, y: 6 });\r\n path += $path.lineTo({ x: 0, y: 12 });\r\n path += $path.lineTo({ x: 8, y: 6 });\r\n icon.path = path;\r\n icon.strokeWidth = 2;\r\n icon.fillOpacity = 0;\r\n icon.pixelPerfect = true;\r\n icon.padding(0, 4, 0, 4);\r\n icon.stroke = cs.getFor(\"text\");\r\n icon.strokeOpacity = 0.7;\r\n icon.align = \"center\";\r\n icon.valign = \"middle\";\r\n _this.icon = icon;\r\n _this.label.dispose();\r\n _this.label = undefined;\r\n // Set default position\r\n _this.position = \"right\";\r\n // Set up autohide\r\n _this.autoHideDelay = 3000;\r\n _this.events.on(\"shown\", function (ev) {\r\n if (_this._autoHideTimeout) {\r\n _this._autoHideTimeout.dispose();\r\n }\r\n if (_this.autoHideDelay) {\r\n _this._autoHideTimeout = _this.setTimeout(function () {\r\n _this.hide();\r\n }, _this.autoHideDelay);\r\n }\r\n });\r\n _this.events.on(\"down\", function (ev) {\r\n if (_this._autoHideTimeout) {\r\n _this._autoHideTimeout.dispose();\r\n }\r\n });\r\n _this.events.on(\"out\", function (ev) {\r\n if (_this.autoHideDelay) {\r\n _this._autoHideTimeout = _this.setTimeout(function () {\r\n _this.hide();\r\n }, _this.autoHideDelay);\r\n }\r\n });\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(Grip.prototype, \"position\", {\r\n /**\r\n * @return Position\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"position\");\r\n },\r\n /**\r\n * Sets position of the grip.\r\n *\r\n * Available options: \"left\", \"right\" (default), \"top\", \"bottom\".\r\n *\r\n * @param value Position\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"position\", value)) {\r\n switch (value) {\r\n case \"left\":\r\n this.align = \"left\";\r\n this.valign = \"middle\";\r\n this.horizontalCenter = \"left\";\r\n this.verticalCenter = \"middle\";\r\n this.icon.rotation = 0;\r\n this.width = undefined;\r\n this.height = percent(30);\r\n break;\r\n case \"right\":\r\n this.align = \"right\";\r\n this.valign = \"middle\";\r\n this.horizontalCenter = \"right\";\r\n this.verticalCenter = \"middle\";\r\n this.icon.rotation = 0;\r\n this.width = undefined;\r\n this.height = percent(30);\r\n break;\r\n case \"top\":\r\n this.align = \"center\";\r\n this.valign = \"top\";\r\n this.horizontalCenter = \"middle\";\r\n this.verticalCenter = \"top\";\r\n this.icon.rotation = 90;\r\n this.width = percent(30);\r\n this.height = undefined;\r\n break;\r\n case \"bottom\":\r\n this.align = \"center\";\r\n this.valign = \"bottom\";\r\n this.horizontalCenter = \"middle\";\r\n this.verticalCenter = \"bottom\";\r\n this.icon.rotation = 90;\r\n this.width = percent(30);\r\n this.height = undefined;\r\n break;\r\n default:\r\n this.align = \"center\";\r\n this.valign = \"middle\";\r\n this.horizontalCenter = \"middle\";\r\n this.verticalCenter = \"middle\";\r\n this.icon.rotation = 90;\r\n this.width = percent(30);\r\n this.height = undefined;\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Grip.prototype, \"autoHideDelay\", {\r\n /**\r\n * @return Delay\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"autoHideDelay\");\r\n },\r\n /**\r\n * Number of milliseconds to show grip until it is hidden automatically.\r\n *\r\n * @default 3000\r\n * @param value Delay\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"autoHideDelay\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Grip;\r\n}(Button));\r\nexport { Grip };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Grip\"] = Grip;\r\n//# sourceMappingURL=Grip.js.map","/**\r\n * [[Chart]] class provides base functionality for all chart types to inherit.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { registry } from \"../core/Registry\";\r\nimport { Component } from \"../core/Component\";\r\nimport { MutableValueDisposer, Disposer } from \"../core/utils/Disposer\";\r\nimport { ListTemplate, ListDisposer } from \"../core/utils/List\";\r\nimport { Container } from \"../core/Container\";\r\nimport { Label } from \"../core/elements/Label\";\r\nimport { Grip } from \"../core/elements/Grip\";\r\nimport { DataItem } from \"../core/DataItem\";\r\nimport { percent } from \"../core/utils/Percent\";\r\nimport * as $iter from \"../core/utils/Iterator\";\r\nimport * as $type from \"../core/utils/Type\";\r\nimport { defaultRules, ResponsiveBreakpoints } from \"../core/utils/Responsive\";\r\n/**\r\n * ============================================================================\r\n * DATA ITEM\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines a [[DataItem]] for [[Chart]].\r\n *\r\n * @see {@link DataItem}\r\n */\r\nvar ChartDataItem = /** @class */ (function (_super) {\r\n __extends(ChartDataItem, _super);\r\n /**\r\n * Constructor\r\n */\r\n function ChartDataItem() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"ChartDataItem\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n return ChartDataItem;\r\n}(DataItem));\r\nexport { ChartDataItem };\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A base class for all Charts.\r\n *\r\n * @see {@link IChartEvents} for a list of available Events\r\n * @see {@link IChartAdapters} for a list of available Adapters\r\n */\r\nvar Chart = /** @class */ (function (_super) {\r\n __extends(Chart, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Chart() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n /**\r\n * A reference to chart's [[Legend]].\r\n * @ignore\r\n */\r\n _this._legend = new MutableValueDisposer();\r\n if (_this.constructor === Chart) {\r\n throw new Error(\"'Chart' cannot be instantiated directly. Please use a specific chart type.\");\r\n }\r\n _this.className = \"Chart\";\r\n // Create a list of titles\r\n var template = new Label();\r\n _this.titles = new ListTemplate(template);\r\n _this._disposers.push(new ListDisposer(_this.titles));\r\n _this._disposers.push(template);\r\n // Chart component is also a container. it holds _chartAndLegendCont and titles\r\n _this.width = percent(100);\r\n _this.height = percent(100);\r\n _this.layout = \"vertical\";\r\n // Chart and legend\r\n var chartAndLegendContainer = _this.createChild(Container);\r\n chartAndLegendContainer.shouldClone = false;\r\n chartAndLegendContainer.layout = \"vertical\";\r\n chartAndLegendContainer.width = percent(100);\r\n chartAndLegendContainer.height = percent(100);\r\n _this.chartAndLegendContainer = chartAndLegendContainer;\r\n // Chart container holds all the elements of a chart, extept titles and legend\r\n var chartContainer = chartAndLegendContainer.createChild(Container);\r\n chartContainer.shouldClone = false;\r\n chartContainer.width = percent(100);\r\n chartContainer.height = percent(100);\r\n _this.chartContainer = chartContainer;\r\n _this.showOnInit = true;\r\n _this._disposers.push(_this._legend);\r\n // Add title list events to apply certain formatting options and to make\r\n // the chart reference them as accessible screen reader labels\r\n _this.titles.events.on(\"inserted\", function (label) {\r\n _this.processTitle(label);\r\n _this.updateReaderTitleReferences();\r\n }, _this, false);\r\n _this.titles.events.on(\"removed\", function (label) {\r\n _this.updateReaderTitleReferences();\r\n }, _this, false);\r\n // Accessibility\r\n // It seems we can't set focusable on the whole chart because it seems to\r\n // mess up the whole focus event system - getting a focus on an inside\r\n // object also trigger focus on parent\r\n //this.focusable = true;\r\n _this.role = \"region\";\r\n _this.defaultState.transitionDuration = 1;\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Sets defaults that instantiate some objects that rely on parent, so they\r\n * cannot be set in constructor.\r\n */\r\n Chart.prototype.applyInternalDefaults = function () {\r\n _super.prototype.applyInternalDefaults.call(this);\r\n if (!$type.hasValue(this.readerTitle)) {\r\n this.readerTitle = this.language.translate(\"Chart\");\r\n }\r\n };\r\n /**\r\n * Initiates drawing of the chart.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Chart.prototype.draw = function () {\r\n this.fixLayout();\r\n _super.prototype.draw.call(this);\r\n };\r\n /**\r\n * Updates legend's hierarchy based on the position.\r\n */\r\n Chart.prototype.fixLayout = function () {\r\n var legend = this.legend;\r\n if (legend) {\r\n var chartAndLegendContainer = this.chartAndLegendContainer;\r\n var chartContainer = this.chartContainer;\r\n chartContainer.x = undefined;\r\n chartContainer.y = undefined;\r\n if (legend.position != \"absolute\") {\r\n legend.x = undefined;\r\n legend.y = undefined;\r\n }\r\n switch (legend.position) {\r\n case \"left\":\r\n chartAndLegendContainer.layout = \"horizontal\";\r\n legend.toBack();\r\n break;\r\n case \"right\":\r\n chartAndLegendContainer.layout = \"horizontal\";\r\n legend.toFront();\r\n break;\r\n case \"top\":\r\n chartAndLegendContainer.layout = \"vertical\";\r\n legend.toBack();\r\n break;\r\n case \"bottom\":\r\n chartAndLegendContainer.layout = \"vertical\";\r\n legend.toFront();\r\n break;\r\n case \"absolute\":\r\n legend.isMeasured = false;\r\n break;\r\n }\r\n }\r\n };\r\n /**\r\n * Setups the legend to use the chart's data.\r\n */\r\n Chart.prototype.feedLegend = function () {\r\n // Nothing here. This method is provided only as a \"placeholder\" for\r\n // extending classes to override\r\n };\r\n /**\r\n * Adds a new title to the chart when it is inserted into chart's titles\r\n * list.\r\n * @param event An event object which is triggered when inserting into titles list\r\n * @return Label object\r\n */\r\n Chart.prototype.processTitle = function (event) {\r\n var title = event.newValue;\r\n title.parent = this;\r\n title.toBack();\r\n title.shouldClone = false;\r\n title.align = \"center\";\r\n // Need to explicitly apply the `id` attribute so it can be referenced by\r\n // `aria-labelledby`\r\n title.uidAttr();\r\n return title;\r\n };\r\n /**\r\n * Checks if chart has any title elements. If it does, we will use them in an\r\n * `aria-labelledby` attribute so that screen readers can use them to properly\r\n * describe the chart when it is focused or hovered.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Chart.prototype.updateReaderTitleReferences = function () {\r\n if (this.titles.length) {\r\n var titleIds_1 = [];\r\n $iter.each(this.titles.iterator(), function (title) {\r\n titleIds_1.push(title.uid);\r\n });\r\n this.setSVGAttribute({ \"aria-labelledby\": titleIds_1.join(\" \") });\r\n }\r\n else {\r\n this.removeSVGAttribute(\"aria-labelledby\");\r\n }\r\n };\r\n Object.defineProperty(Chart.prototype, \"legend\", {\r\n /**\r\n * @return Legend\r\n */\r\n get: function () {\r\n return this._legend.get();\r\n },\r\n /**\r\n * Holds the instance of chart's [[Leged]].\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/legend/} for more information about legends\r\n * @param Legend\r\n */\r\n set: function (legend) {\r\n this.setLegend(legend);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Prepares the legend instance for use in this chart.\r\n *\r\n * @param legend Legend\r\n */\r\n Chart.prototype.setLegend = function (legend) {\r\n var _this = this;\r\n if (this._legend.get() !== legend) {\r\n if (legend) {\r\n // Set legend options\r\n legend.parent = this.chartAndLegendContainer;\r\n this._legend.set(legend, legend.events.on(\"propertychanged\", function (event) {\r\n if (event.property == \"position\") {\r\n _this.fixLayout();\r\n }\r\n }, undefined, false));\r\n legend.addDisposer(new Disposer(function () {\r\n _this.legend = undefined;\r\n }));\r\n }\r\n else {\r\n this._legend.reset();\r\n }\r\n this.feedLegend();\r\n }\r\n };\r\n /**\r\n * Destroys this object and all related data.\r\n */\r\n Chart.prototype.dispose = function () {\r\n // otherwise there might be some errors when disposing chart which was just inited\r\n if (this.legend) {\r\n this.legend.dispose();\r\n }\r\n _super.prototype.dispose.call(this);\r\n };\r\n /**\r\n * Processes JSON-based config before it is applied to the object.\r\n *\r\n * @ignore Exclude from docs\r\n * @param config Config\r\n */\r\n Chart.prototype.processConfig = function (config) {\r\n if (config) {\r\n // Set up legend\r\n if ($type.hasValue(config.legend) && !$type.hasValue(config.legend.type)) {\r\n config.legend.type = \"Legend\";\r\n }\r\n }\r\n _super.prototype.processConfig.call(this, config);\r\n };\r\n /**\r\n * Copies all properties from another instance of [[Series]].\r\n *\r\n * @param source Source series\r\n */\r\n Chart.prototype.copyFrom = function (source) {\r\n this.titles.copyFrom(source.titles);\r\n this.chartContainer.copyFrom(source.chartContainer);\r\n if (source.legend) {\r\n this.legend = source.legend.clone();\r\n this.legend.removeChildren();\r\n }\r\n _super.prototype.copyFrom.call(this, source);\r\n };\r\n Object.defineProperty(Chart.prototype, \"dragGrip\", {\r\n /**\r\n * @return Grip\r\n */\r\n get: function () {\r\n var _this = this;\r\n if (!this._dragGrip) {\r\n var grip_1 = this.tooltipContainer.createChild(Grip);\r\n grip_1.align = \"right\";\r\n grip_1.valign = \"middle\";\r\n grip_1.hide(0);\r\n grip_1.events.on(\"down\", function (ev) {\r\n if (ev.touch) {\r\n _this.interactionsEnabled = false;\r\n }\r\n });\r\n grip_1.events.on(\"up\", function (ev) {\r\n _this.interactionsEnabled = true;\r\n });\r\n this.events.on(\"down\", function (ev) {\r\n if (ev.touch) {\r\n grip_1.show();\r\n }\r\n });\r\n this._dragGrip = grip_1;\r\n }\r\n return this._dragGrip;\r\n },\r\n /**\r\n * An instance of [[Grip]] which serves as a grip point which appears on\r\n * touch and allows scrolling whole page even if chart is occupying the\r\n * whole of the screen and would otherwise prevent scrolling.\r\n *\r\n * @since 4.4.0\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/touch/} For more information.\r\n * @param value Grip\r\n */\r\n set: function (value) {\r\n this._dragGrip = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Chart.prototype, \"focusable\", {\r\n get: function () {\r\n return this.parent.focusable;\r\n },\r\n set: function (value) {\r\n this.parent.focusable = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Chart;\r\n}(Component));\r\nexport { Chart };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Chart\"] = Chart;\r\n/**\r\n * Add default responsive rules\r\n */\r\n/**\r\n * Reduce horizontal margins\r\n */\r\ndefaultRules.push({\r\n relevant: ResponsiveBreakpoints.widthXS,\r\n state: function (target, stateId) {\r\n if (target instanceof Chart) {\r\n var state = target.states.create(stateId);\r\n if (target.pixelPaddingLeft > 10) {\r\n state.properties.paddingLeft = 10;\r\n }\r\n if (target.pixelPaddingRight > 10) {\r\n state.properties.paddingRight = 10;\r\n }\r\n return state;\r\n }\r\n return null;\r\n }\r\n});\r\n/**\r\n * Reduce vertical margins\r\n */\r\ndefaultRules.push({\r\n relevant: ResponsiveBreakpoints.heightXS,\r\n state: function (target, stateId) {\r\n if (target instanceof Chart) {\r\n var state = target.states.create(stateId);\r\n if (target.pixelPaddingTop > 10) {\r\n state.properties.paddingTop = 10;\r\n }\r\n if (target.pixelPaddingBottom > 10) {\r\n state.properties.paddingBottom = 10;\r\n }\r\n return state;\r\n }\r\n return null;\r\n }\r\n});\r\n/**\r\n * Remove horizontal padding\r\n */\r\ndefaultRules.push({\r\n relevant: ResponsiveBreakpoints.widthXXS,\r\n state: function (target, stateId) {\r\n if (target instanceof Chart) {\r\n var state = target.states.create(stateId);\r\n state.properties.paddingLeft = 0;\r\n state.properties.paddingRight = 0;\r\n return state;\r\n }\r\n return null;\r\n }\r\n});\r\n/**\r\n * Remove vertical padding\r\n */\r\ndefaultRules.push({\r\n relevant: ResponsiveBreakpoints.heightXXS,\r\n state: function (target, stateId) {\r\n if (target instanceof Chart) {\r\n var state = target.states.create(stateId);\r\n state.properties.paddingTop = 0;\r\n state.properties.paddingBottom = 0;\r\n return state;\r\n }\r\n return null;\r\n }\r\n});\r\n//# sourceMappingURL=Chart.js.map","/**\r\n * Module that defines everything related to building bullets.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../../core/Container\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { defaultRules, ResponsiveBreakpoints } from \"../../core/utils/Responsive\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Class used to creates bullets.\r\n *\r\n * @see {@link IBulletEvents} for a list of available events\r\n * @see {@link IBulletAdapters} for a list of available Adapters\r\n * @todo Usage example\r\n * @important\r\n */\r\nvar Bullet = /** @class */ (function (_super) {\r\n __extends(Bullet, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Bullet() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"Bullet\";\r\n _this.isMeasured = false;\r\n _this.tooltipX = 0;\r\n _this.tooltipY = 0;\r\n _this.layout = \"none\";\r\n _this.applyOnClones = true;\r\n _this.copyToLegendMarker = true;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(Bullet.prototype, \"locationX\", {\r\n /**\r\n * @return Location (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"locationX\");\r\n },\r\n /**\r\n * Relative horizontal location within cell. (0-1)\r\n *\r\n * @param value Location (0-1)\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"locationX\", value)) {\r\n var dataItem = this.dataItem;\r\n if (dataItem && dataItem.component) {\r\n dataItem.component.invalidate();\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Bullet.prototype, \"locationY\", {\r\n /**\r\n * @return Location (0-1)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"locationY\");\r\n },\r\n /**\r\n * Relative vertical location within cell. (0-1)\r\n *\r\n * @param value Location (0-1)\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"locationY\", value)) {\r\n var dataItem = this.dataItem;\r\n if (dataItem && dataItem.component) {\r\n dataItem.component.invalidate();\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Bullet.prototype, \"xField\", {\r\n /**\r\n * @return [description]\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"xField\");\r\n },\r\n /**\r\n * [xField description]\r\n *\r\n * @todo Description\r\n * @param value [description]\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"xField\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Bullet.prototype, \"yField\", {\r\n /**\r\n * @return [description]\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"yField\");\r\n },\r\n /**\r\n * [yField description]\r\n *\r\n * Description\r\n * @param value [description]\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"yField\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Bullet.prototype, \"isDynamic\", {\r\n /**\r\n * @return Redraw on data change?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"isDynamic\");\r\n },\r\n /**\r\n * Indicates if the bullet is \"dynamic\".\r\n *\r\n * In most cases the bullets remain the same, even if the underlying data\r\n * changes.\r\n *\r\n * However, in cases where bullet also displays a label, or its size depends\r\n * on data, it also needs to be redrawn when the underlying data changes.\r\n *\r\n * Only those bullets that have set `isDynamic = true` will be redrawn each\r\n * time data changes. Regular bullets will be reused as they are.\r\n *\r\n * @default false\r\n * @param value Redraw on data change?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"isDynamic\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Bullet.prototype, \"copyToLegendMarker\", {\r\n /**\r\n * @return Redraw on data change?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"copyToLegendMarker\");\r\n },\r\n /**\r\n * Indicates if the bullet should be copied to legend marker\r\n *\r\n * @default false\r\n * @param value Redraw on data change?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"copyToLegendMarker\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return Bullet;\r\n}(Container));\r\nexport { Bullet };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Bullet\"] = Bullet;\r\n/**\r\n * Add default responsive rules\r\n */\r\n/**\r\n * Hide bullets\r\n */\r\ndefaultRules.push({\r\n relevant: ResponsiveBreakpoints.isXS,\r\n state: function (target, stateId) {\r\n if (target instanceof Bullet) {\r\n var state = target.states.create(stateId);\r\n state.properties.disabled = true;\r\n return state;\r\n }\r\n return null;\r\n }\r\n});\r\n//# sourceMappingURL=Bullet.js.map","/**\r\n * Functionality for any series-based elements, like Line Series (graphs),\r\n * Pie slice lists, etc.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Component } from \"../../core/Component\";\r\nimport { Sprite } from \"../../core/Sprite\";\r\nimport { List, ListTemplate, ListDisposer } from \"../../core/utils/List\";\r\nimport { Dictionary, DictionaryDisposer } from \"../../core/utils/Dictionary\";\r\nimport { DataItem } from \"../../core/DataItem\";\r\nimport { Container } from \"../../core/Container\";\r\nimport { Tooltip } from \"../../core/elements/Tooltip\";\r\nimport { Bullet } from \"../elements/Bullet\";\r\nimport { LegendSettings } from \"../Legend\";\r\nimport { options } from \"../../core/Options\";\r\nimport { Color } from \"../../core/utils/Color\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport * as $iter from \"../../core/utils/Iterator\";\r\nimport * as $math from \"../../core/utils/Math\";\r\nimport * as $ease from \"../../core/utils/Ease\";\r\nimport * as $utils from \"../../core/utils/Utils\";\r\nimport * as $object from \"../../core/utils/Object\";\r\nimport * as $type from \"../../core/utils/Type\";\r\nimport * as $array from \"../../core/utils/Array\";\r\nimport * as $colors from \"../../core/utils/Colors\";\r\n/**\r\n * ============================================================================\r\n * DATA ITEM\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines a [[DataItem]] for [[Series]].\r\n *\r\n * @see {@link DataItem}\r\n */\r\nvar SeriesDataItem = /** @class */ (function (_super) {\r\n __extends(SeriesDataItem, _super);\r\n /**\r\n * Constructor\r\n */\r\n function SeriesDataItem() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"SeriesDataItem\";\r\n //@todo Should we make `bullets` list disposable?\r\n //this._disposers.push(new DictionaryDisposer(this.bullets));\r\n _this.values.value = {};\r\n _this.values.value = {};\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(SeriesDataItem.prototype, \"bullets\", {\r\n /**\r\n * A dictionary of data items bullets, where key is uid of a bullet template.\r\n */\r\n get: function () {\r\n if (!this._bullets) {\r\n this._bullets = new Dictionary();\r\n this._disposers.push(new DictionaryDisposer(this._bullets));\r\n }\r\n return this._bullets;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Destroys this object and all related data.\r\n */\r\n SeriesDataItem.prototype.dispose = function () {\r\n this.bullets.clear();\r\n _super.prototype.dispose.call(this);\r\n };\r\n Object.defineProperty(SeriesDataItem.prototype, \"value\", {\r\n /**\r\n * @return Value\r\n */\r\n get: function () {\r\n return this.values.value.value;\r\n },\r\n /**\r\n * data items's numeric value.\r\n *\r\n * @param value Value\r\n */\r\n set: function (value) {\r\n this.setValue(\"value\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return SeriesDataItem;\r\n}(DataItem));\r\nexport { SeriesDataItem };\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines base class for any kind of serial data.\r\n *\r\n * @see {@link ISeriesEvents} for a list of available Events\r\n * @see {@link ISeriesAdapters} for a list of available Adapters\r\n * @todo Separate axis-related stuff to some other class so that MapSeries would not have unrelated stuff\r\n */\r\nvar Series = /** @class */ (function (_super) {\r\n __extends(Series, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Series() {\r\n var _this = _super.call(this) || this;\r\n /**\r\n * Should this series excluded from the axis scale calculations?\r\n *\r\n * @default false\r\n */\r\n _this._ignoreMinMax = false;\r\n /**\r\n * Should series' bullets?\r\n *\r\n * @default true\r\n */\r\n _this._showBullets = true;\r\n /**\r\n * Settings for the appearance of the related legend items.\r\n */\r\n _this.legendSettings = new LegendSettings();\r\n /**\r\n * Lowest overal values by type.\r\n */\r\n _this._tmin = new Dictionary();\r\n /**\r\n * Highest overal values by type.\r\n */\r\n _this._tmax = new Dictionary();\r\n /**\r\n * Lowest values in current selection by type.\r\n */\r\n _this._smin = new Dictionary();\r\n /**\r\n * Highest values in current selection by type.\r\n */\r\n _this._smax = new Dictionary();\r\n /**\r\n * [dataItemsByAxis description]\r\n *\r\n * Both by category and date.\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n */\r\n _this.dataItemsByAxis = new Dictionary();\r\n /**\r\n * Normally series items are focusable using keyboard, so that people can\r\n * select them with a TAB key. However, if there are a lot of data points on\r\n * screen it might be long and useless to tab through all o fthem.\r\n *\r\n * This is where `skipFocusThreshold` comes in. If there are more items than\r\n * the value set here, we will not make those focusable and rather let screen\r\n * reader software rely on the series summary, or authors provide alternative\r\n * detailed information display, such as HTML table.\r\n *\r\n * Different series might have different threshold defaults.\r\n */\r\n _this.skipFocusThreshold = 20;\r\n /**\r\n * Used to indicate if `itemReaderText` was changed \"from the outside\".\r\n */\r\n _this._itemReaderTextChanged = false;\r\n /**\r\n * Most of the series use absolute values. However sometimes various\r\n * calculated percent values are need, e.g. item's percent representation\r\n * across all values in series, etc.\r\n *\r\n * It's a resource-intensive operation, so it is disabled by default.\r\n *\r\n * If you need percents to be calculated, e.g. for showing them in tooltips,\r\n * or creating 100% stacks, this setting needs to be set to `true`.\r\n *\r\n * NOTE: `PieChart`, which relies on slice percentages, has this\r\n * automatically set to `true`.\r\n *\r\n * @default false\r\n */\r\n _this.calculatePercent = false;\r\n /**\r\n * When `calculatePercent` is enabled and data item's percent value is\r\n * calculated, last item's real value is used instead of its working value.\r\n *\r\n * This is done for the animations when last item in series (e.g. slice in\r\n * a `PieSeries`) is hidden or shown. (if we would use real value, the\r\n * calculated percent would always be 100%).\r\n *\r\n * Sometimes there is a need (e.g. for drill-down Sunburst) to disable this\r\n * hack by setting `usePercentHack` to `false`.\r\n *\r\n * @since 4.9.13\r\n * @default true\r\n */\r\n _this.usePercentHack = true;\r\n /**\r\n * Specifies if series should be automatically disposed when removing from\r\n * chart's `series` list.\r\n *\r\n * @default true\r\n */\r\n _this.autoDispose = true;\r\n /**\r\n * When chart/series' data is processed, all kinds of derivative values are\r\n * calculated. E.g. sum, min, max, change, etc. This is a potentially\r\n * time-consuming operation, especially prominent in data-heavy charts.\r\n *\r\n * If your chart does not need those values, and you have a lot of data,\r\n * setting this to `true` might give a dramatic increase in initial chart\r\n * load speed.\r\n *\r\n * Please note, regular column and line series usage scenarios do not\r\n * require derivative values. Those come into play only when you do advanced\r\n * functionality like coloring segments of charts in different colors\r\n * depending on change between open and close values, have stacked series, or\r\n * display any of the derived values, like percent, in tooltips or bullets.\r\n *\r\n * @default false\r\n */\r\n _this.simplifiedProcessing = false;\r\n if (_this.constructor === Series) {\r\n throw new Error(\"'Series' cannot be instantiated directly. Please use a specific series type.\");\r\n }\r\n _this.className = \"Series\";\r\n _this.isMeasured = false;\r\n _this.layout = \"none\";\r\n _this.shouldClone = false;\r\n _this.setPropertyValue(\"hidden\", false);\r\n _this.axisRanges = new List();\r\n _this.axisRanges.events.on(\"inserted\", _this.processAxisRange, _this, false);\r\n _this.minBulletDistance = 0; // otherwise we'll have a lot of cases when people won't see bullets and think it's a bug\r\n _this.mainContainer = _this.createChild(Container);\r\n _this.mainContainer.shouldClone = false;\r\n _this.mainContainer.mask = _this.createChild(Sprite);\r\n _this._disposers.push(_this.mainContainer);\r\n // all bullets should go on top of lines/fills. So we add a separate container for bullets and later set it's parent to chart.bulletsContainer\r\n var bulletsContainer = _this.mainContainer.createChild(Container);\r\n _this._shouldBeReady.push(bulletsContainer);\r\n bulletsContainer.shouldClone = false;\r\n bulletsContainer.layout = \"none\";\r\n bulletsContainer.virtualParent = _this;\r\n _this._disposers.push(bulletsContainer);\r\n _this.bulletsContainer = bulletsContainer;\r\n _this.tooltip = new Tooltip();\r\n _this.tooltip.virtualParent = _this;\r\n _this._disposers.push(_this.tooltip);\r\n _this.hiddenState.transitionEasing = $ease.cubicIn;\r\n // this data item holds sums, averages, etc\r\n _this.dataItem = _this.createDataItem();\r\n _this._disposers.push(_this.dataItem);\r\n _this.dataItem.component = _this;\r\n // Apply accessibility\r\n _this.role = \"group\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * We need this here so that class names can be applied to bullets container.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Series.prototype.applyTheme = function () {\r\n _super.prototype.applyTheme.call(this);\r\n if (options.autoSetClassName && this.bulletsContainer) {\r\n this.bulletsContainer.className = this.className + \"-bullets\";\r\n this.bulletsContainer.setClassName();\r\n }\r\n };\r\n /**\r\n * Sets defaults that instantiate some objects that rely on parent, so they\r\n * cannot be set in constructor.\r\n */\r\n Series.prototype.applyInternalDefaults = function () {\r\n _super.prototype.applyInternalDefaults.call(this);\r\n if (!$type.hasValue(this.readerTitle)) {\r\n this.readerTitle = this.language.translate(\"Series\");\r\n }\r\n };\r\n /**\r\n * Returns a new/empty DataItem of the type appropriate for this object.\r\n *\r\n * @see {@link DataItem}\r\n * @return Data Item\r\n */\r\n Series.prototype.createDataItem = function () {\r\n return new SeriesDataItem();\r\n };\r\n Object.defineProperty(Series.prototype, \"chart\", {\r\n /**\r\n * @return Chart\r\n */\r\n get: function () {\r\n return this._chart;\r\n },\r\n /**\r\n * Chart series is used on.\r\n *\r\n * @param value Chart\r\n */\r\n set: function (value) {\r\n this._chart = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Positions bullet.\r\n *\r\n * @param bullet Sprite\r\n */\r\n Series.prototype.positionBullet = function (bullet) {\r\n // Placeholder method for extending classes to override.\r\n };\r\n /**\r\n * Decorates newly created bullet after it has been instert into the list.\r\n *\r\n * @param event List event\r\n * @todo investigate why itemReaderText is undefined\r\n */\r\n Series.prototype.processBullet = function (event) {\r\n var _this = this;\r\n var bullet = event.newValue;\r\n bullet.isTemplate = true;\r\n // Add accessibility options to bullet\r\n // If there are relatively few bullets, make them focusable\r\n this.events.once(\"datavalidated\", function (ev) {\r\n if (_this.itemsFocusable()) {\r\n bullet.focusable = true;\r\n }\r\n });\r\n this.invalidate();\r\n };\r\n /**\r\n * removes bullets\r\n *\r\n * @param event List event\r\n */\r\n Series.prototype.removeBullet = function (event) {\r\n var bullet = event.oldValue;\r\n this.dataItems.each(function (dataItem) {\r\n var eachBullet = dataItem.bullets.getKey(bullet.uid);\r\n if (eachBullet) {\r\n eachBullet.dispose();\r\n }\r\n });\r\n this.invalidate();\r\n };\r\n /**\r\n * Validates data items.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Series.prototype.validateDataItems = function () {\r\n _super.prototype.validateDataItems.call(this);\r\n this.processValues(false);\r\n };\r\n /**\r\n * Returns first value for the specific key in the series.\r\n *\r\n * @param key Key\r\n * @return Value\r\n * @todo Description\r\n * @todo Convert to propert object property iterator\r\n */\r\n Series.prototype.getFirstValue = function (key, startIndex) {\r\n // find first\r\n /*\r\n return $iter.findMap(this.dataItems.iterator(), (dataItem) => {\r\n for (let key in dataItem.values) {\r\n if ($object.hasKey(dataItem.values, key)) {\r\n let value: number = dataItem.values[key].workingValue;\r\n if ($type.isNumber(value)) {\r\n return value;\r\n }\r\n }\r\n }\r\n\r\n return null;\r\n });*/\r\n //if (startIndex > 0 && startIndex < this.dataItems.length - 1) {\r\n //startIndex++;\r\n //}\r\n for (var i = startIndex; i >= 0; i--) {\r\n var dataItem = this.dataItems.getIndex(i);\r\n var value = dataItem.getActualWorkingValue(key);\r\n if ($type.isNumber(value)) {\r\n return value;\r\n }\r\n }\r\n return null;\r\n };\r\n /**\r\n * Returns first value for the specific key in the series.\r\n *\r\n * @param key Key\r\n * @return Value\r\n * @todo Description\r\n * @todo Convert to propert object property iterator\r\n */\r\n Series.prototype.getAbsoluteFirstValue = function (key) {\r\n for (var i = 0; i < this.dataItems.length; i++) {\r\n var dataItem = this.dataItems.getIndex(i);\r\n var value = dataItem.values[key].value;\r\n if ($type.isNumber(value)) {\r\n return value;\r\n }\r\n }\r\n return null;\r\n };\r\n /**\r\n * [rangeChangeUpdate description]\r\n *\r\n * @todo Description\r\n */\r\n Series.prototype.rangeChangeUpdate = function () {\r\n _super.prototype.rangeChangeUpdate.call(this);\r\n this.processValues(true);\r\n };\r\n /**\r\n * [processValues description]\r\n *\r\n * @todo Description\r\n * @todo Convert to propert object property iterator\r\n * @param dataItems [description]\r\n */\r\n Series.prototype.processValues = function (working) {\r\n var _this = this;\r\n if (!this.simplifiedProcessing) {\r\n var dataItems = this.dataItems;\r\n var count_1 = {};\r\n var sum_1 = {};\r\n var absoluteSum_1 = {};\r\n var low_1 = {};\r\n var high_1 = {};\r\n var open_1 = {};\r\n var close_1 = {};\r\n var previous_1 = {};\r\n var first_1 = {};\r\n var absoluteFirst_1 = {};\r\n //let duration: number = 0; // todo: check if series uses selection.change or selection.change.percent and set duration to interpolationduration\r\n var startIndex_1 = $math.max(0, this.startIndex);\r\n startIndex_1 = $math.min(startIndex_1, this.dataItems.length);\r\n var endIndex = $math.min(this.endIndex, this.dataItems.length);\r\n if (!$type.isNumber(startIndex_1)) {\r\n startIndex_1 = 0;\r\n }\r\n if (!$type.isNumber(endIndex)) {\r\n endIndex = this.dataItems.length;\r\n }\r\n if (startIndex_1 > 0) {\r\n var dataItem_1 = dataItems.getIndex(startIndex_1 - 1);\r\n $object.each(dataItem_1.values, function (key, values) {\r\n var value = dataItem_1.getActualWorkingValue(key);\r\n if ($type.isNumber(value)) {\r\n // save previous\r\n previous_1[key] = value;\r\n }\r\n });\r\n }\r\n var _loop_1 = function (i) {\r\n var dataItem_2 = dataItems.getIndex(i);\r\n $object.each(dataItem_2.values, function (key, values) {\r\n var value = dataItem_2.getActualWorkingValue(key);\r\n //if (i >= startIndex && i <= endIndex) { // do not add to count, sum etc if it is not within start/end index\r\n if ($type.isNumber(value)) {\r\n // count values\r\n if (!$type.isNumber(count_1[key])) {\r\n count_1[key] = 0;\r\n }\r\n count_1[key]++;\r\n // sum values\r\n if (!$type.isNumber(sum_1[key])) {\r\n sum_1[key] = 0;\r\n }\r\n sum_1[key] += value;\r\n // absolute sum values\r\n if (!$type.isNumber(absoluteSum_1[key])) {\r\n absoluteSum_1[key] = 0;\r\n }\r\n absoluteSum_1[key] += Math.abs(value);\r\n // open\r\n if (!$type.isNumber(open_1[key])) {\r\n open_1[key] = value;\r\n }\r\n // close\r\n close_1[key] = value;\r\n // low\r\n if (!$type.isNumber(low_1[key])) {\r\n low_1[key] = value;\r\n }\r\n else {\r\n if (low_1[key] > value) {\r\n low_1[key] = value;\r\n }\r\n }\r\n // high\r\n if (!$type.isNumber(high_1[key])) {\r\n high_1[key] = value;\r\n }\r\n else {\r\n if (high_1[key] < value) {\r\n high_1[key] = value;\r\n }\r\n }\r\n if (!$type.isNumber(first_1[key])) {\r\n first_1[key] = _this.getFirstValue(key, startIndex_1);\r\n }\r\n if (!$type.isNumber(absoluteFirst_1[key])) {\r\n absoluteFirst_1[key] = _this.getAbsoluteFirstValue(key);\r\n }\r\n // change\r\n dataItem_2.setCalculatedValue(key, value - first_1[key], \"change\");\r\n // change from start percent\r\n // will fail if first value is 0\r\n dataItem_2.setCalculatedValue(key, (value - first_1[key]) / first_1[key] * 100, \"changePercent\");\r\n dataItem_2.setCalculatedValue(key, (value - absoluteFirst_1[key]), \"startChange\");\r\n dataItem_2.setCalculatedValue(key, (value - absoluteFirst_1[key]) / absoluteFirst_1[key] * 100, \"startChangePercent\");\r\n // previous change\r\n var prevValue = previous_1[key];\r\n if (!$type.isNumber(prevValue)) {\r\n prevValue = value;\r\n }\r\n dataItem_2.setCalculatedValue(key, value - prevValue, \"previousChange\");\r\n // previous change percent\r\n dataItem_2.setCalculatedValue(key, (value - prevValue) / prevValue * 100, \"previousChangePercent\");\r\n // save previous\r\n previous_1[key] = value;\r\n }\r\n });\r\n };\r\n for (var i = startIndex_1; i < endIndex; i++) {\r\n _loop_1(i);\r\n }\r\n if (this.calculatePercent) {\r\n var _loop_2 = function (i) {\r\n var dataItem_3 = dataItems.getIndex(i);\r\n $object.each(dataItem_3.values, function (key) {\r\n var ksum = absoluteSum_1[key];\r\n var value = dataItem_3.getActualWorkingValue(key);\r\n if ($type.isNumber(value)) {\r\n if (ksum > 0) {\r\n if (_this.usePercentHack) {\r\n // this hack is made in order to make it possible to animate single slice to 0\r\n // if there is only one slice left, percent value is always 100%, so it won't animate\r\n // so we use real value of a slice instead of current value\r\n if (value == ksum) {\r\n ksum = dataItem_3.values[key].value;\r\n }\r\n }\r\n var percent = value / ksum * 100;\r\n dataItem_3.setCalculatedValue(key, percent, \"percent\");\r\n }\r\n else {\r\n dataItem_3.setCalculatedValue(key, 0, \"percent\");\r\n }\r\n }\r\n });\r\n };\r\n for (var i = startIndex_1; i < endIndex; i++) {\r\n _loop_2(i);\r\n }\r\n }\r\n // calculate one before first (cant do that in cycle, as we don't know open yet\r\n // when drawing line chart we should draw line to the invisible data point to the left, otherwise the line will always look like it starts from the selected point\r\n // so we do startIndex - 1\r\n if (startIndex_1 > 0) {\r\n var zeroItem_1 = dataItems.getIndex(startIndex_1 - 1);\r\n $object.each(zeroItem_1.values, function (key) {\r\n var value = zeroItem_1.values[key].value;\r\n // change\r\n zeroItem_1.setCalculatedValue(key, value - open_1[key], \"change\");\r\n // change percent\r\n zeroItem_1.setCalculatedValue(key, (value - open_1[key]) / open_1[key] * 100, \"changePercent\");\r\n });\r\n }\r\n // we save various data like sum, average to dataPoint of the series\r\n var dataItem_4 = this.dataItem;\r\n $object.each(dataItem_4.values, function (key) {\r\n dataItem_4.setCalculatedValue(key, sum_1[key], \"sum\");\r\n dataItem_4.setCalculatedValue(key, absoluteSum_1[key], \"absoluteSum\");\r\n dataItem_4.setCalculatedValue(key, sum_1[key] / count_1[key], \"average\");\r\n dataItem_4.setCalculatedValue(key, open_1[key], \"open\");\r\n dataItem_4.setCalculatedValue(key, close_1[key], \"close\");\r\n dataItem_4.setCalculatedValue(key, low_1[key], \"low\");\r\n dataItem_4.setCalculatedValue(key, high_1[key], \"high\");\r\n dataItem_4.setCalculatedValue(key, count_1[key], \"count\");\r\n });\r\n }\r\n };\r\n /**\r\n * (Re)validates the whole series, effectively causing it to redraw.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Series.prototype.validate = function () {\r\n if ($utils.isIE()) {\r\n this.filters.clear();\r\n }\r\n $iter.each(this.axisRanges.iterator(), function (axisRange) {\r\n //axisRange.contents.disposeChildren(); // not good for columns, as they are reused\r\n //\t\t\taxisRange.appendChildren();\r\n axisRange.validate();\r\n });\r\n _super.prototype.validate.call(this);\r\n var bulletsContainer = this.bulletsContainer;\r\n bulletsContainer.fill = this.fill;\r\n bulletsContainer.stroke = this.stroke;\r\n bulletsContainer.x = this.pixelX;\r\n bulletsContainer.y = this.pixelY;\r\n if (this.bulletsContainer.children.length > 0) {\r\n if (this._showBullets) {\r\n for (var i = 0; i < this.startIndex; i++) {\r\n var dataItem = this.dataItems.getIndex(i);\r\n if (dataItem) {\r\n dataItem.bullets.each(function (key, bullet) {\r\n bullet.__disabled = true;\r\n });\r\n }\r\n }\r\n for (var i = this.dataItems.length - 1; i > this.endIndex; i--) {\r\n var dataItem = this.dataItems.getIndex(i);\r\n if (dataItem) {\r\n dataItem.bullets.each(function (key, bullet) {\r\n bullet.__disabled = true;\r\n });\r\n }\r\n }\r\n }\r\n else {\r\n this.bulletsContainer.children.each(function (bullet) {\r\n bullet.__disabled = true;\r\n });\r\n }\r\n }\r\n this.updateTooltipBounds();\r\n };\r\n /**\r\n * @ignore\r\n */\r\n Series.prototype.updateTooltipBounds = function () {\r\n if (this.topParent) {\r\n var x = 0;\r\n var y = 0;\r\n var w = this.topParent.maxWidth;\r\n var h = this.topParent.maxHeight;\r\n var rect = { x: x, y: y, width: w, height: h };\r\n this.tooltip.setBounds(rect);\r\n }\r\n };\r\n Series.prototype.shouldCreateBullet = function (dataItem, bulletTemplate) {\r\n return true;\r\n };\r\n /**\r\n * Validates data item's element, effectively redrawing it.\r\n *\r\n * @ignore Exclude from docs\r\n * @param dataItem Data item\r\n */\r\n Series.prototype.validateDataElement = function (dataItem) {\r\n var _this = this;\r\n _super.prototype.validateDataElement.call(this, dataItem);\r\n if (this._showBullets) {\r\n if (!this.isHidden) {\r\n this.bulletsContainer.visible = true;\r\n }\r\n this.bullets.each(function (bulletTemplate) {\r\n // always better to use the same, this helps to avoid redrawing\r\n var bullet = dataItem.bullets.getKey(bulletTemplate.uid);\r\n if (_this.shouldCreateBullet(dataItem, bulletTemplate)) {\r\n if (!bullet) {\r\n var disabledField = bulletTemplate.propertyFields.disabled;\r\n var dataContext = dataItem.dataContext;\r\n if (disabledField && dataContext && dataContext[disabledField] === false) {\r\n bulletTemplate.applyOnClones = false;\r\n bulletTemplate.disabled = false;\r\n bullet = bulletTemplate.clone();\r\n bulletTemplate.disabled = true;\r\n bulletTemplate.applyOnClones = true;\r\n }\r\n else {\r\n bullet = bulletTemplate.clone();\r\n }\r\n bullet.shouldClone = false;\r\n dataItem.addSprite(bullet);\r\n if (!_this.visible || _this.isHiding) {\r\n bullet.hide(0);\r\n }\r\n }\r\n var currentDataItem = bullet.dataItem;\r\n if (currentDataItem != dataItem) {\r\n // set to undefined in order not to reuse\r\n if (currentDataItem) {\r\n currentDataItem.bullets.setKey(bulletTemplate.uid, undefined);\r\n }\r\n var readerText_1 = _this.itemReaderText;\r\n if (bullet instanceof Bullet) {\r\n if (!readerText_1) {\r\n readerText_1 = (\"{\" + bullet.xField + \"}: {\" + bullet.yField + \"}\");\r\n }\r\n if (bullet.isDynamic) {\r\n dataItem.events.on(\"workingvaluechanged\", bullet.deepInvalidate, bullet, false);\r\n //dataItem.events.on(\"calculatedvaluechanged\", bullet.deepInvalidate, bullet, false);\r\n _this.dataItem.events.on(\"workingvaluechanged\", bullet.deepInvalidate, bullet, false);\r\n }\r\n bullet.deepInvalidate();\r\n }\r\n // Add accessibility to bullet\r\n if (bullet.focusable) {\r\n bullet.events.on(\"focus\", function (ev) {\r\n bullet.readerTitle = _this.populateString(readerText_1, bullet.dataItem);\r\n }, undefined, false);\r\n bullet.events.on(\"blur\", function (ev) {\r\n bullet.readerTitle = \"\";\r\n }, undefined, false);\r\n }\r\n if (bullet.hoverable) {\r\n bullet.events.on(\"over\", function (ev) {\r\n bullet.readerTitle = _this.populateString(readerText_1, bullet.dataItem);\r\n }, undefined, false);\r\n bullet.events.on(\"out\", function (ev) {\r\n bullet.readerTitle = \"\";\r\n }, undefined, false);\r\n }\r\n }\r\n bullet.parent = _this.bulletsContainer;\r\n dataItem.bullets.setKey(bulletTemplate.uid, bullet);\r\n // pass max w/h so we'd know if we should show/hide somethings\r\n bullet.maxWidth = dataItem.itemWidth;\r\n bullet.maxHeight = dataItem.itemHeight;\r\n bullet.__disabled = false;\r\n _this.positionBullet(bullet);\r\n }\r\n else {\r\n if (bullet) {\r\n bullet.__disabled = true;\r\n }\r\n }\r\n });\r\n }\r\n else {\r\n this.bulletsContainer.visible = false;\r\n }\r\n };\r\n /**\r\n * [handleDataItemWorkingValueChange description]\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Series.prototype.handleDataItemWorkingValueChange = function (dataItem, name) {\r\n if (!this.dataRangeInvalid) {\r\n this.invalidateProcessedData();\r\n }\r\n };\r\n Object.defineProperty(Series.prototype, \"ignoreMinMax\", {\r\n /**\r\n * @return Exclude from calculations?\r\n */\r\n get: function () {\r\n return this._ignoreMinMax;\r\n },\r\n /**\r\n * Should this series excluded from the axis scale calculations?\r\n *\r\n * @default false\r\n * @param value Exclude from calculations?\r\n */\r\n set: function (value) {\r\n this._ignoreMinMax = value;\r\n this.invalidateDataItems();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Create a mask for the series.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Series.prototype.createMask = function () {\r\n // A placeholder method for extending classes to override.\r\n };\r\n /**\r\n * Process axis range after it has been added to the list.\r\n *\r\n * @param event Event\r\n */\r\n Series.prototype.processAxisRange = function (event) {\r\n // create container if not existing\r\n if (!this.rangesContainer) {\r\n this.rangesContainer = this.createChild(Container);\r\n this.rangesContainer.shouldClone = false;\r\n this.rangesContainer.isMeasured = false;\r\n }\r\n var axisRange = event.newValue;\r\n if (axisRange) {\r\n axisRange.contents.parent = this.rangesContainer;\r\n axisRange.isRange = true;\r\n axisRange.events.on(\"valuechanged\", this.invalidateDataItems, this, false);\r\n }\r\n };\r\n /**\r\n * [getAxisField description]\r\n *\r\n * @ignore Exclude from docs\r\n * @todo Description\r\n * @param axis [description]\r\n * @return [description]\r\n */\r\n Series.prototype.getAxisField = function (axis) {\r\n return;\r\n };\r\n /**\r\n * Shows the tooltip at specific position.\r\n *\r\n * @ignore Exclude from docs\r\n * @param xPosition X\r\n * @param yPosition Y\r\n */\r\n Series.prototype.showTooltipAtPosition = function (xPosition, yPosition) {\r\n // Placeholder method for extending classes to override.\r\n };\r\n Object.defineProperty(Series.prototype, \"minBulletDistance\", {\r\n /**\r\n * @return Distance (px)\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"minBulletDistance\");\r\n },\r\n /**\r\n * Minimal distance between data points in pixels.\r\n *\r\n * If distance gets smaller than this, bullets are turned off to avoid\r\n * overlapping.\r\n *\r\n * `0` (zero) disables this behavior.\r\n *\r\n * IMPORTANT: This setting will work only when Series' base axis\r\n * is [[CategoryAxis]] or [[DateAxis]]. If base axis is [[ValueAxis]] the\r\n * setting will be ignored, because it would be a huge overhead to measure\r\n * distance between each and every bullet.\r\n *\r\n * @default 0\r\n * @param value Distance (px)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"minBulletDistance\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Series.prototype, \"bullets\", {\r\n /**\r\n * A list of bullets that will be added to each and every items in the\r\n * series.\r\n *\r\n * You can push any object that is a descendant of a [[Sprite]] here. All\r\n * items added to this list will be copied and used as a bullet on all data\r\n * items, including their properties, events, etc.\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/bullets/} for more info about the concept of Bullets\r\n * @return List of bullets.\r\n */\r\n get: function () {\r\n if (!this._bullets) {\r\n this._bullets = new ListTemplate(new Bullet());\r\n this._bullets.template.virtualParent = this;\r\n this._bullets.events.on(\"inserted\", this.processBullet, this, false);\r\n this._bullets.events.on(\"removed\", this.removeBullet, this, false);\r\n this._disposers.push(new ListDisposer(this._bullets));\r\n this._disposers.push(this._bullets.template);\r\n }\r\n return this._bullets;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Binds related legend data item's visual settings to this series' visual\r\n * settings.\r\n *\r\n * @ignore Exclude from docs\r\n * @param marker Legend item container\r\n */\r\n Series.prototype.createLegendMarker = function (marker) {\r\n // This is a placeholder method for extending classes to override.\r\n };\r\n Object.defineProperty(Series.prototype, \"hiddenInLegend\", {\r\n /**\r\n * @return Hidden in legend?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"hiddenInLegend\");\r\n },\r\n /**\r\n * Should the series be hidden in legend?\r\n *\r\n * @param value Hidden in legend?\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"hiddenInLegend\", value)) {\r\n if (this.chart) {\r\n this.chart.feedLegend();\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Series.prototype, \"name\", {\r\n /**\r\n * @return Name\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"name\");\r\n },\r\n /**\r\n * Series' name.\r\n *\r\n * @param value Name\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"name\", value);\r\n var legendDataItem = this.legendDataItem;\r\n if (legendDataItem) {\r\n legendDataItem.component.invalidate();\r\n legendDataItem.component.invalidateRawData();\r\n }\r\n this.readerTitle = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Series.prototype, \"itemReaderText\", {\r\n /**\r\n * @return Screen reader text template\r\n */\r\n get: function () {\r\n // Get explicitly set reader text\r\n var readerText = this._itemReaderText;\r\n // Not set? Let's try something else\r\n if (!readerText) {\r\n // Tooltip text?\r\n if (this.tooltipText) {\r\n readerText = $utils.plainText(this.tooltipText);\r\n }\r\n else if (this.tooltipHTML) {\r\n readerText = $utils.plainText(this.tooltipHTML);\r\n }\r\n }\r\n if (!this._adapterO) {\r\n return readerText;\r\n }\r\n else {\r\n return this._adapterO.apply(\"itemReaderText\", readerText);\r\n }\r\n },\r\n /**\r\n * Screen reader text to be applied to each individual data item, such\r\n * as bullets, columns or slices.\r\n *\r\n * The template can contain field reference meta codes, i.e. `{dateX}`,\r\n * `{valueY}`, etc.\r\n *\r\n * Any text formatting options, e.g. `[bold]` will be ignored.\r\n *\r\n * @param value Screen reader text template\r\n */\r\n set: function (value) {\r\n this._itemReaderText = value;\r\n this._itemReaderTextChanged = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Returns if number of data items in the series are beyond non-focusable\r\n * count and should not be available for TAB-through.\r\n *\r\n * @ignore Exclude from docs\r\n * @return Items focusable?\r\n */\r\n Series.prototype.itemsFocusable = function () {\r\n return this.dataItems.length >= this.skipFocusThreshold ? false : true;\r\n };\r\n Object.defineProperty(Series.prototype, \"legendDataItem\", {\r\n /**\r\n * @return Data item\r\n */\r\n get: function () {\r\n return this._legendDataItem;\r\n },\r\n /**\r\n * Legend data item that corresponds to this series.\r\n *\r\n * @param value Data item\r\n */\r\n set: function (value) {\r\n this._legendDataItem = value;\r\n this._legendDataItem.itemContainer.deepInvalidate();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Updates corresponding legend data item with current values.\r\n *\r\n * @ignore Exclude from docs\r\n * @param dataItem Data item\r\n */\r\n Series.prototype.updateLegendValue = function (dataItem, notRange) {\r\n // if this series has legend item\r\n if (this.legendDataItem) {\r\n var legendSettings = this.legendSettings;\r\n var legendDataItem = this.legendDataItem;\r\n var label = legendDataItem.label;\r\n var valueLabel = legendDataItem.valueLabel;\r\n // update legend\r\n if ((dataItem && !dataItem.isDisposed()) || notRange) {\r\n if (valueLabel) {\r\n if (legendSettings.itemValueText) {\r\n valueLabel.text = legendSettings.itemValueText;\r\n }\r\n valueLabel.dataItem = dataItem;\r\n }\r\n if (label) {\r\n if (legendSettings.itemLabelText) {\r\n label.text = legendSettings.itemLabelText;\r\n }\r\n label.dataItem = dataItem;\r\n }\r\n }\r\n else {\r\n if (label) {\r\n // if itemLabelText is set, means we have to reset label even if labelText is not set\r\n if (legendSettings.labelText || legendSettings.itemLabelText != undefined) {\r\n label.text = legendSettings.labelText;\r\n }\r\n label.dataItem = this.dataItem;\r\n }\r\n if (valueLabel) {\r\n if (legendSettings.valueText || legendSettings.itemValueText != undefined) {\r\n valueLabel.text = legendSettings.valueText;\r\n }\r\n valueLabel.dataItem = this.dataItem;\r\n }\r\n }\r\n }\r\n };\r\n /**\r\n * Copies all properties from another instance of [[Series]].\r\n *\r\n * @param source Source series\r\n */\r\n Series.prototype.copyFrom = function (source) {\r\n this.bullets.copyFrom(source.bullets);\r\n this.bulletsContainer.copyFrom(source.bulletsContainer);\r\n this.calculatePercent = source.calculatePercent;\r\n this.usePercentHack = source.usePercentHack;\r\n this.simplifiedProcessing = source.simplifiedProcessing;\r\n _super.prototype.copyFrom.call(this, source);\r\n };\r\n /**\r\n * Displays a modal or console message with error, and halts any further\r\n * processing of this element.\r\n *\r\n * @param e Error\r\n */\r\n Series.prototype.raiseCriticalError = function (e) {\r\n if (this._chart && this._chart.modal) {\r\n this._chart.modal.content = this._chart.adapter.apply(\"criticalError\", e).message;\r\n this._chart.modal.closable = false;\r\n if (!options.suppressErrors) {\r\n this._chart.modal.open();\r\n }\r\n this._chart.disabled = true;\r\n }\r\n if (options.verbose) {\r\n console.log(e);\r\n }\r\n };\r\n /**\r\n * Applies filters to the element.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n Series.prototype.applyFilters = function () {\r\n var _this = this;\r\n _super.prototype.applyFilters.call(this);\r\n this.bulletsContainer.filters.clear();\r\n // copyFrom of a list copies, does not clone\r\n $iter.each(this.filters.iterator(), function (filter) {\r\n _this.bulletsContainer.filters.push(filter.clone());\r\n });\r\n };\r\n Object.defineProperty(Series.prototype, \"heatRules\", {\r\n /**\r\n * A list of heat rules to apply to series' elements based on the value\r\n * of the data item.\r\n *\r\n * Heat rules can be any \"numeric\" (including `Color`) property, and can also\r\n * be applied to child objects of series, like columns, bullets, etc.\r\n *\r\n * E.g.:\r\n *\r\n * ```TypeScript\r\n * series.heatRules.push({\r\n * \"target\": series.columns.template,\r\n * \"property\": \"fill\",\r\n * \"min\": am4core.color(\"#F5DBCB\"),\r\n * \"max\": am4core.color(\"#ED7B84\"),\r\n * \"dataField\": \"valueY\"\r\n *});\r\n *```\r\n * ```Javacript\r\n * series.heatRules.push({\r\n * \"target\": series.columns.template,\r\n * \"property\": \"fill\",\r\n * \"min\": am4core.color(\"#F5DBCB\"),\r\n * \"max\": am4core.color(\"#ED7B84\"),\r\n * \"dataField\": \"valueY\"\r\n *});\r\n *```\r\n *```JSON\r\n *{\r\n * // ...\r\n * \"series\": [{\r\n * \"type\": \"ColumnSeries\",\r\n * \"heatRules\": [{\r\n * \"target\": \"columns.template\",\r\n * \"property\": \"fill\",\r\n * \"min\": \"#F5DBCB\",\r\n * \"max\": \"#ED7B84\",\r\n * \"dataField\": \"valueY\"\r\n * }]\r\n * }]\r\n *}\r\n *```\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/concepts/series/#Heat_maps} for more about heat rules\r\n * @return Heat rules\r\n */\r\n get: function () {\r\n var _this = this;\r\n if (!this._heatRules) {\r\n this._heatRules = new List();\r\n this._heatRules.events.on(\"inserted\", function (event) {\r\n var heatRule = event.newValue;\r\n var target = heatRule.target;\r\n if (target) {\r\n var dataField_1 = heatRule.dataField;\r\n if (!$type.hasValue(dataField_1)) {\r\n dataField_1 = \"value\";\r\n }\r\n var seriesDataItem_1 = _this.dataItem;\r\n var property_1 = heatRule.property;\r\n var minValue = $type.toNumber(heatRule.minValue);\r\n var maxValue = $type.toNumber(heatRule.maxValue);\r\n if (!$type.isNumber(minValue) && !$type.isNumber(maxValue)) {\r\n _this.dataItem.events.on(\"calculatedvaluechanged\", function (event) {\r\n if (event.property == dataField_1) {\r\n $iter.each(_this.dataItems.iterator(), function (dataItem) {\r\n var foundSprite = false;\r\n $array.each(dataItem.sprites, function (sprite) {\r\n if (sprite.clonedFrom == target) {\r\n var anySprite = sprite;\r\n anySprite[property_1] = anySprite[property_1];\r\n foundSprite = true;\r\n }\r\n });\r\n if (!foundSprite) {\r\n $array.each(dataItem.sprites, function (sprite) {\r\n if (sprite instanceof Container) {\r\n $iter.each(sprite.children.iterator(), function (child) {\r\n if (child.className == target.className) {\r\n var anyChild = child;\r\n anyChild[property_1] = anyChild[property_1];\r\n }\r\n // giveup here\r\n else if (child instanceof Container) {\r\n child.deepInvalidate();\r\n }\r\n });\r\n }\r\n });\r\n }\r\n });\r\n }\r\n });\r\n }\r\n _this.dataItems.template.events.on(\"workingvaluechanged\", function (event) {\r\n if (event.property == dataField_1) {\r\n var dataItem = event.target;\r\n var foundSprite_1 = false;\r\n $array.each(dataItem.sprites, function (sprite) {\r\n if (sprite.clonedFrom == target) {\r\n var anySprite = sprite;\r\n anySprite[property_1] = anySprite[property_1];\r\n foundSprite_1 = true;\r\n }\r\n });\r\n if (!foundSprite_1) {\r\n $array.each(dataItem.sprites, function (sprite) {\r\n if (sprite instanceof Container) {\r\n $iter.each(sprite.children.iterator(), function (child) {\r\n if (child.className == target.className) {\r\n var anyChild = child;\r\n anyChild[property_1] = anyChild[property_1];\r\n }\r\n // givup here\r\n else if (child instanceof Container) {\r\n child.deepInvalidate();\r\n }\r\n });\r\n }\r\n });\r\n }\r\n }\r\n });\r\n target.adapter.add(property_1, function (value, ruleTarget, property) {\r\n var minValue = $type.toNumber(heatRule.minValue);\r\n var maxValue = $type.toNumber(heatRule.maxValue);\r\n var min = heatRule.min;\r\n var max = heatRule.max;\r\n if (ruleTarget instanceof Sprite) {\r\n var anySprite = ruleTarget;\r\n var propertyField = anySprite.propertyFields[property];\r\n if (propertyField && ruleTarget.dataItem) {\r\n var dataContext = ruleTarget.dataItem.dataContext;\r\n if (dataContext && $type.hasValue(dataContext[propertyField])) {\r\n return value;\r\n }\r\n }\r\n }\r\n var dataItem = ruleTarget.dataItem;\r\n if (!$type.isNumber(minValue)) {\r\n minValue = seriesDataItem_1.values[dataField_1].low;\r\n }\r\n if (!$type.isNumber(maxValue)) {\r\n maxValue = seriesDataItem_1.values[dataField_1].high;\r\n }\r\n if (dataItem) {\r\n var fieldValues = dataItem.values[dataField_1];\r\n if (fieldValues) {\r\n var workingValue = dataItem.getActualWorkingValue(dataField_1);\r\n if ($type.hasValue(min) && $type.hasValue(max) && $type.isNumber(minValue) && $type.isNumber(maxValue) && $type.isNumber(workingValue)) {\r\n var percent = void 0;\r\n if (heatRule.logarithmic) {\r\n percent = (Math.log(workingValue) * Math.LOG10E - Math.log(minValue) * Math.LOG10E) / ((Math.log(maxValue) * Math.LOG10E - Math.log(minValue) * Math.LOG10E));\r\n }\r\n else {\r\n percent = (workingValue - minValue) / (maxValue - minValue);\r\n }\r\n if ($type.isNumber(workingValue) && (!$type.isNumber(percent) || Math.abs(percent) == Infinity)) {\r\n percent = 0.5;\r\n }\r\n // fixes problems if all values are the same\r\n if ($type.isNumber(min)) {\r\n return min + (max - min) * percent;\r\n }\r\n else if (min instanceof Color) {\r\n return new Color($colors.interpolate(min.rgb, max.rgb, percent));\r\n }\r\n }\r\n }\r\n }\r\n return value;\r\n });\r\n }\r\n });\r\n }\r\n return this._heatRules;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Processes JSON-based config before it is applied to the object.\r\n *\r\n * @ignore Exclude from docs\r\n * @param config Config\r\n */\r\n Series.prototype.processConfig = function (config) {\r\n var heatRules;\r\n if (config) {\r\n // Set up bullets\r\n if ($type.hasValue(config.bullets) && $type.isArray(config.bullets)) {\r\n for (var i = 0, len = config.bullets.length; i < len; i++) {\r\n var bullets = config.bullets[i];\r\n if (!$type.hasValue(bullets.type)) {\r\n bullets.type = \"Bullet\";\r\n }\r\n }\r\n }\r\n // Let's take heatRules out of the config, so that we can process\r\n // them later, when bullets are already there\r\n if ($type.hasValue(config.heatRules) && $type.isArray(config.heatRules)) {\r\n heatRules = config.heatRules;\r\n delete config.heatRules;\r\n }\r\n }\r\n _super.prototype.processConfig.call(this, config);\r\n // Process heat rules again, when all other elements are ready\r\n if (heatRules) {\r\n for (var i = 0, len = heatRules.length; i < len; i++) {\r\n var rule = heatRules[i];\r\n // Resolve target\r\n var target = this;\r\n if ($type.hasValue(rule.target) && $type.isString(rule.target)) {\r\n // Check if we can find this element by id\r\n if (this.map.hasKey(rule.target)) {\r\n target = this.map.getKey(rule.target);\r\n }\r\n else {\r\n var parts = rule.target.split(\".\");\r\n for (var x = 0; x < parts.length; x++) {\r\n if (target instanceof List) {\r\n var listitem = target.getIndex($type.toNumber(parts[x]));\r\n if (!listitem) {\r\n target = target[parts[x]];\r\n }\r\n else {\r\n target = listitem;\r\n }\r\n }\r\n else {\r\n var maybeIndex = parts[x].match(/^(.*)\\[([0-9]+)\\]/);\r\n if (maybeIndex) {\r\n if (target[maybeIndex[1]] instanceof List) {\r\n target = target[maybeIndex[1]].getIndex($type.toNumber(maybeIndex[2]));\r\n }\r\n else {\r\n target = target[maybeIndex[1]][$type.toNumber(maybeIndex[2])];\r\n }\r\n }\r\n else {\r\n target = target[parts[x]];\r\n }\r\n }\r\n }\r\n }\r\n }\r\n rule.target = target;\r\n // Resolve colors and percents\r\n if ($type.hasValue(rule.min)) {\r\n rule.min = this.maybeColorOrPercent(rule.min);\r\n }\r\n if ($type.hasValue(rule.max)) {\r\n rule.max = this.maybeColorOrPercent(rule.max);\r\n }\r\n }\r\n _super.prototype.processConfig.call(this, {\r\n heatRules: heatRules\r\n });\r\n }\r\n };\r\n /**\r\n * Returns visibility value\r\n * @ignore\r\n */\r\n /*\r\n protected getVisibility(): boolean {\r\n let hidden = this.getPropertyValue(\"hidden\");\r\n if (hidden) {\r\n return false;\r\n }\r\n else {\r\n return super.getVisibility();\r\n }\r\n }*/\r\n /**\r\n * This function is used to sort element's JSON config properties, so that\r\n * some properties that absolutely need to be processed last, can be put at\r\n * the end.\r\n *\r\n * @ignore Exclude from docs\r\n * @param a Element 1\r\n * @param b Element 2\r\n * @return Sorting number\r\n */\r\n Series.prototype.configOrder = function (a, b) {\r\n if (a == b) {\r\n return 0;\r\n }\r\n // Must come last\r\n else if (a == \"heatRules\") {\r\n return 1;\r\n }\r\n else if (b == \"heatRules\") {\r\n return -1;\r\n }\r\n else {\r\n return _super.prototype.configOrder.call(this, a, b);\r\n }\r\n };\r\n /**\r\n * Sets `visibility` property:\r\n *\r\n * * `true` - visible\r\n * * `false` - hidden\r\n *\r\n * @param value true - visible, false - hidden\r\n * @return Current visibility\r\n */\r\n Series.prototype.setVisibility = function (value) {\r\n _super.prototype.setVisibility.call(this, value);\r\n this.bulletsContainer.visible = value;\r\n };\r\n return Series;\r\n}(Component));\r\nexport { Series };\r\n/**\r\n * Register class, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Series\"] = Series;\r\nregistry.registeredClasses[\"SeriesDataItem\"] = SeriesDataItem;\r\n//# sourceMappingURL=Series.js.map","/**\r\n * Serial chart module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Chart, ChartDataItem } from \"../Chart\";\r\nimport { ListTemplate, ListDisposer } from \"../../core/utils/List\";\r\nimport { Container } from \"../../core/Container\";\r\nimport { Series } from \"../series/Series\";\r\nimport { percent } from \"../../core/utils/Percent\";\r\nimport { ColorSet } from \"../../core/utils/ColorSet\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport * as $iter from \"../../core/utils/Iterator\";\r\nimport * as $type from \"../../core/utils/Type\";\r\nimport * as $array from \"../../core/utils/Array\";\r\nimport { Disposer } from \"../../core/utils/Disposer\";\r\n/**\r\n * ============================================================================\r\n * DATA ITEM\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines a [[DataItem]] for [[SerialChart]].\r\n *\r\n * @see {@link DataItem}\r\n */\r\nvar SerialChartDataItem = /** @class */ (function (_super) {\r\n __extends(SerialChartDataItem, _super);\r\n /**\r\n * Constructor\r\n */\r\n function SerialChartDataItem() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"SerialChartDataItem\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n return SerialChartDataItem;\r\n}(ChartDataItem));\r\nexport { SerialChartDataItem };\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A base class for all series-based charts, like XY, Pie, etc.\r\n *\r\n * Is not useful on its own.\r\n *\r\n * @see {@link ISerialChartEvents} for a list of available Events\r\n * @see {@link ISerialChartAdapters} for a list of available Adapters\r\n */\r\nvar SerialChart = /** @class */ (function (_super) {\r\n __extends(SerialChart, _super);\r\n /**\r\n * Constructor\r\n */\r\n function SerialChart() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this._exitDP = {};\r\n _this.className = \"SerialChart\";\r\n _this.colors = new ColorSet();\r\n _this._usesData = false;\r\n // Create a container for series\r\n var seriesContainer = _this.chartContainer.createChild(Container);\r\n seriesContainer.shouldClone = false;\r\n seriesContainer.width = percent(100);\r\n seriesContainer.height = percent(100);\r\n seriesContainer.isMeasured = false;\r\n seriesContainer.layout = \"none\";\r\n seriesContainer.zIndex = 2;\r\n _this.seriesContainer = seriesContainer;\r\n // Create a container for bullets\r\n var bulletsContainer = _this.chartContainer.createChild(Container);\r\n bulletsContainer.shouldClone = false;\r\n bulletsContainer.width = percent(100);\r\n bulletsContainer.height = percent(100);\r\n bulletsContainer.isMeasured = false;\r\n bulletsContainer.zIndex = 3;\r\n bulletsContainer.layout = \"none\";\r\n _this.bulletsContainer = bulletsContainer;\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n SerialChart.prototype.dispose = function () {\r\n _super.prototype.dispose.call(this);\r\n if (this.colors) {\r\n this.colors.dispose();\r\n }\r\n if (this.patterns) {\r\n this.patterns.dispose();\r\n }\r\n };\r\n /**\r\n * Sets defaults that instantiate some objects that rely on parent, so they\r\n * cannot be set in constructor\r\n */\r\n SerialChart.prototype.applyInternalDefaults = function () {\r\n _super.prototype.applyInternalDefaults.call(this);\r\n // Add a default screen reader title for accessibility\r\n // This will be overridden in screen reader if there are any `titles` set\r\n if (!$type.hasValue(this.readerTitle)) {\r\n this.readerTitle = this.language.translate(\"Serial chart\");\r\n }\r\n };\r\n Object.defineProperty(SerialChart.prototype, \"series\", {\r\n /**\r\n * A list of chart's series.\r\n *\r\n * @return Chart's series\r\n */\r\n get: function () {\r\n if (!this._series) {\r\n this._series = new ListTemplate(this.createSeries());\r\n this._series.events.on(\"inserted\", this.handleSeriesAdded, this, false);\r\n this._series.events.on(\"removed\", this.handleSeriesRemoved, this, false);\r\n this._disposers.push(new ListDisposer(this._series, false));\r\n this._disposers.push(this._series.template);\r\n }\r\n return this._series;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n SerialChart.prototype.handleSeriesRemoved = function (event) {\r\n var series = event.oldValue;\r\n this.dataUsers.removeValue(series);\r\n this.dataUsers.each(function (dataUser) {\r\n dataUser.invalidateDataItems();\r\n });\r\n if (this._exitDP[series.uid]) {\r\n this._exitDP[series.uid].dispose();\r\n delete this._exitDP[series.uid];\r\n }\r\n if (series.autoDispose) {\r\n series.dispose();\r\n }\r\n else {\r\n series.parent = undefined;\r\n series.bulletsContainer.parent = undefined;\r\n }\r\n //this.feedLegend();\r\n var legend = this.legend;\r\n if (legend) {\r\n var dataItems = this.legend.dataItems;\r\n for (var i = dataItems.length - 1; i >= 0; i--) {\r\n var dataItem = dataItems.getIndex(i);\r\n if (dataItem && dataItem.dataContext == series) {\r\n legend.dataItems.remove(dataItem);\r\n }\r\n }\r\n for (var i = legend.data.length - 1; i >= 0; i--) {\r\n var di = legend.data[i];\r\n if (di && di == series) {\r\n $array.remove(legend.data, di);\r\n }\r\n }\r\n }\r\n };\r\n /**\r\n * Decorates a new [[Series]] object with required parameters when it is\r\n * added to the chart.\r\n *\r\n * @ignore Exclude from docs\r\n * @param event Event\r\n */\r\n SerialChart.prototype.handleSeriesAdded = function (event) {\r\n var _this = this;\r\n var series = event.newValue;\r\n if (series.isDisposed()) {\r\n return;\r\n }\r\n series.chart = this;\r\n series.parent = this.seriesContainer;\r\n series.bulletsContainer.parent = this.bulletsContainer;\r\n this._dataUsers.moveValue(series);\r\n series.addDisposer(new Disposer(function () {\r\n _this.dataUsers.removeValue(series);\r\n }));\r\n this.handleSeriesAdded2(series);\r\n this.handleLegendSeriesAdded(series);\r\n };\r\n SerialChart.prototype.handleLegendSeriesAdded = function (series) {\r\n if (!series.hiddenInLegend) {\r\n if (this.legend) {\r\n this.legend.addData(series);\r\n }\r\n }\r\n };\r\n SerialChart.prototype.handleSeriesAdded2 = function (series) {\r\n var _this = this;\r\n if (!this.dataInvalid) {\r\n this._exitDP[series.uid] = registry.events.once(\"exitframe\", function () {\r\n if (!series.data || series.data.length == 0) {\r\n series.data = _this.data;\r\n if (series.showOnInit) {\r\n series.reinit();\r\n series.setPropertyValue(\"showOnInit\", false);\r\n series.showOnInit = true;\r\n }\r\n if (!series.isDisposed()) {\r\n series.events.once(\"datavalidated\", function () {\r\n if (series.data == _this.data) {\r\n series._data = [];\r\n }\r\n });\r\n }\r\n }\r\n });\r\n this._disposers.push(this._exitDP[series.uid]);\r\n }\r\n };\r\n /**\r\n * Setups the legend to use the chart's data.\r\n * @ignore\r\n */\r\n SerialChart.prototype.feedLegend = function () {\r\n var legend = this.legend;\r\n if (legend) {\r\n var legendData_1 = [];\r\n $iter.each(this.series.iterator(), function (series) {\r\n if (!series.hiddenInLegend) {\r\n legendData_1.push(series);\r\n }\r\n });\r\n legend.dataFields.name = \"name\";\r\n legend.data = legendData_1;\r\n }\r\n };\r\n /**\r\n * Creates and returns a new Series, suitable for this chart type.\r\n *\r\n * @return New series\r\n */\r\n SerialChart.prototype.createSeries = function () {\r\n return new Series();\r\n };\r\n Object.defineProperty(SerialChart.prototype, \"colors\", {\r\n /**\r\n * @return Color list\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"colors\");\r\n },\r\n /**\r\n * Chart's color list.\r\n *\r\n * This list can be used by a number of serial items, like applying a new\r\n * color for each Series added. Or, applying a new color for each slice\r\n * of a Pie chart.\r\n *\r\n * Please see [[ColorSet]] for information on how you can set up to generate\r\n * unique colors.\r\n *\r\n * A theme you are using may override default pre-defined colors.\r\n *\r\n * @param value Color list\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"colors\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(SerialChart.prototype, \"patterns\", {\r\n /**\r\n * @return Pattern set\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"patterns\");\r\n },\r\n /**\r\n * A [[PatternSet]] to use when creating patterned fills for slices.\r\n *\r\n * @since 4.7.5\r\n * @param value Pattern set\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"patterns\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Copies all parameters from another [[SerialChart]].\r\n *\r\n * @param source Source SerialChart\r\n */\r\n SerialChart.prototype.copyFrom = function (source) {\r\n _super.prototype.copyFrom.call(this, source);\r\n this.series.copyFrom(source.series);\r\n };\r\n /**\r\n * Hides the chart instantly and then shows it. If defaultState.transitionDuration > 0, this will result an animation in which properties of hidden state will animate to properties of visible state.\r\n */\r\n SerialChart.prototype.appear = function () {\r\n _super.prototype.appear.call(this);\r\n this.series.each(function (series) {\r\n if (series.showOnInit && series.inited) {\r\n series.appear();\r\n }\r\n });\r\n };\r\n return SerialChart;\r\n}(Chart));\r\nexport { SerialChart };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"SerialChart\"] = SerialChart;\r\n//# sourceMappingURL=SerialChart.js.map","// https://github.com/python/cpython/blob/a74eea238f5baba15797e2e8b570d153bc8690a7/Modules/mathmodule.c#L1423\nexport class Adder {\n constructor() {\n this._partials = new Float64Array(32);\n this._n = 0;\n }\n add(x) {\n const p = this._partials;\n let i = 0;\n for (let j = 0; j < this._n && j < 32; j++) {\n const y = p[j],\n hi = x + y,\n lo = Math.abs(x) < Math.abs(y) ? x - (hi - y) : y - (hi - x);\n if (lo) p[i++] = lo;\n x = hi;\n }\n p[i] = x;\n this._n = i + 1;\n return this;\n }\n valueOf() {\n const p = this._partials;\n let n = this._n, x, y, lo, hi = 0;\n if (n > 0) {\n hi = p[--n];\n while (n > 0) {\n x = hi;\n y = p[--n];\n hi = x + y;\n lo = y - (hi - x);\n if (lo) break;\n }\n if (n > 0 && ((lo < 0 && p[n - 1] < 0) || (lo > 0 && p[n - 1] > 0))) {\n y = lo * 2;\n x = hi + y;\n if (y == x - hi) hi = x;\n }\n }\n return hi;\n }\n}\n\nexport function fsum(values, valueof) {\n const adder = new Adder();\n if (valueof === undefined) {\n for (let value of values) {\n if (value = +value) {\n adder.add(value);\n }\n }\n } else {\n let index = -1;\n for (let value of values) {\n if (value = +valueof(value, ++index, values)) {\n adder.add(value);\n }\n }\n }\n return +adder;\n}\n\nexport function fcumsum(values, valueof) {\n const adder = new Adder();\n let index = -1;\n return Float64Array.from(values, valueof === undefined\n ? v => adder.add(+v || 0)\n : v => adder.add(+valueof(v, ++index, values) || 0)\n );\n}\n","export var epsilon = 1e-6;\nexport var epsilon2 = 1e-12;\nexport var pi = Math.PI;\nexport var halfPi = pi / 2;\nexport var quarterPi = pi / 4;\nexport var tau = pi * 2;\n\nexport var degrees = 180 / pi;\nexport var radians = pi / 180;\n\nexport var abs = Math.abs;\nexport var atan = Math.atan;\nexport var atan2 = Math.atan2;\nexport var cos = Math.cos;\nexport var ceil = Math.ceil;\nexport var exp = Math.exp;\nexport var floor = Math.floor;\nexport var hypot = Math.hypot;\nexport var log = Math.log;\nexport var pow = Math.pow;\nexport var sin = Math.sin;\nexport var sign = Math.sign || function(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; };\nexport var sqrt = Math.sqrt;\nexport var tan = Math.tan;\n\nexport function acos(x) {\n return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);\n}\n\nexport function asin(x) {\n return x > 1 ? halfPi : x < -1 ? -halfPi : Math.asin(x);\n}\n\nexport function haversin(x) {\n return (x = sin(x / 2)) * x;\n}\n","export default function noop() {}\n","function streamGeometry(geometry, stream) {\n if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) {\n streamGeometryType[geometry.type](geometry, stream);\n }\n}\n\nvar streamObjectType = {\n Feature: function(object, stream) {\n streamGeometry(object.geometry, stream);\n },\n FeatureCollection: function(object, stream) {\n var features = object.features, i = -1, n = features.length;\n while (++i < n) streamGeometry(features[i].geometry, stream);\n }\n};\n\nvar streamGeometryType = {\n Sphere: function(object, stream) {\n stream.sphere();\n },\n Point: function(object, stream) {\n object = object.coordinates;\n stream.point(object[0], object[1], object[2]);\n },\n MultiPoint: function(object, stream) {\n var coordinates = object.coordinates, i = -1, n = coordinates.length;\n while (++i < n) object = coordinates[i], stream.point(object[0], object[1], object[2]);\n },\n LineString: function(object, stream) {\n streamLine(object.coordinates, stream, 0);\n },\n MultiLineString: function(object, stream) {\n var coordinates = object.coordinates, i = -1, n = coordinates.length;\n while (++i < n) streamLine(coordinates[i], stream, 0);\n },\n Polygon: function(object, stream) {\n streamPolygon(object.coordinates, stream);\n },\n MultiPolygon: function(object, stream) {\n var coordinates = object.coordinates, i = -1, n = coordinates.length;\n while (++i < n) streamPolygon(coordinates[i], stream);\n },\n GeometryCollection: function(object, stream) {\n var geometries = object.geometries, i = -1, n = geometries.length;\n while (++i < n) streamGeometry(geometries[i], stream);\n }\n};\n\nfunction streamLine(coordinates, stream, closed) {\n var i = -1, n = coordinates.length - closed, coordinate;\n stream.lineStart();\n while (++i < n) coordinate = coordinates[i], stream.point(coordinate[0], coordinate[1], coordinate[2]);\n stream.lineEnd();\n}\n\nfunction streamPolygon(coordinates, stream) {\n var i = -1, n = coordinates.length;\n stream.polygonStart();\n while (++i < n) streamLine(coordinates[i], stream, 1);\n stream.polygonEnd();\n}\n\nexport default function(object, stream) {\n if (object && streamObjectType.hasOwnProperty(object.type)) {\n streamObjectType[object.type](object, stream);\n } else {\n streamGeometry(object, stream);\n }\n}\n","import {Adder} from \"d3-array\";\nimport {atan2, cos, quarterPi, radians, sin, tau} from \"./math.js\";\nimport noop from \"./noop.js\";\nimport stream from \"./stream.js\";\n\nexport var areaRingSum = new Adder();\n\n// hello?\n\nvar areaSum = new Adder(),\n lambda00,\n phi00,\n lambda0,\n cosPhi0,\n sinPhi0;\n\nexport var areaStream = {\n point: noop,\n lineStart: noop,\n lineEnd: noop,\n polygonStart: function() {\n areaRingSum = new Adder();\n areaStream.lineStart = areaRingStart;\n areaStream.lineEnd = areaRingEnd;\n },\n polygonEnd: function() {\n var areaRing = +areaRingSum;\n areaSum.add(areaRing < 0 ? tau + areaRing : areaRing);\n this.lineStart = this.lineEnd = this.point = noop;\n },\n sphere: function() {\n areaSum.add(tau);\n }\n};\n\nfunction areaRingStart() {\n areaStream.point = areaPointFirst;\n}\n\nfunction areaRingEnd() {\n areaPoint(lambda00, phi00);\n}\n\nfunction areaPointFirst(lambda, phi) {\n areaStream.point = areaPoint;\n lambda00 = lambda, phi00 = phi;\n lambda *= radians, phi *= radians;\n lambda0 = lambda, cosPhi0 = cos(phi = phi / 2 + quarterPi), sinPhi0 = sin(phi);\n}\n\nfunction areaPoint(lambda, phi) {\n lambda *= radians, phi *= radians;\n phi = phi / 2 + quarterPi; // half the angular distance from south pole\n\n // Spherical excess E for a spherical triangle with vertices: south pole,\n // previous point, current point. Uses a formula derived from Cagnoli’s\n // theorem. See Todhunter, Spherical Trig. (1871), Sec. 103, Eq. (2).\n var dLambda = lambda - lambda0,\n sdLambda = dLambda >= 0 ? 1 : -1,\n adLambda = sdLambda * dLambda,\n cosPhi = cos(phi),\n sinPhi = sin(phi),\n k = sinPhi0 * sinPhi,\n u = cosPhi0 * cosPhi + k * cos(adLambda),\n v = k * sdLambda * sin(adLambda);\n areaRingSum.add(atan2(v, u));\n\n // Advance the previous points.\n lambda0 = lambda, cosPhi0 = cosPhi, sinPhi0 = sinPhi;\n}\n\nexport default function(object) {\n areaSum = new Adder();\n stream(object, areaStream);\n return areaSum * 2;\n}\n","import {Adder} from \"d3-array\";\nimport {areaStream, areaRingSum} from \"./area.js\";\nimport {cartesian, cartesianCross, cartesianNormalizeInPlace, spherical} from \"./cartesian.js\";\nimport {abs, degrees, epsilon, radians} from \"./math.js\";\nimport stream from \"./stream.js\";\n\nvar lambda0, phi0, lambda1, phi1, // bounds\n lambda2, // previous lambda-coordinate\n lambda00, phi00, // first point\n p0, // previous 3D point\n deltaSum,\n ranges,\n range;\n\nvar boundsStream = {\n point: boundsPoint,\n lineStart: boundsLineStart,\n lineEnd: boundsLineEnd,\n polygonStart: function() {\n boundsStream.point = boundsRingPoint;\n boundsStream.lineStart = boundsRingStart;\n boundsStream.lineEnd = boundsRingEnd;\n deltaSum = new Adder();\n areaStream.polygonStart();\n },\n polygonEnd: function() {\n areaStream.polygonEnd();\n boundsStream.point = boundsPoint;\n boundsStream.lineStart = boundsLineStart;\n boundsStream.lineEnd = boundsLineEnd;\n if (areaRingSum < 0) lambda0 = -(lambda1 = 180), phi0 = -(phi1 = 90);\n else if (deltaSum > epsilon) phi1 = 90;\n else if (deltaSum < -epsilon) phi0 = -90;\n range[0] = lambda0, range[1] = lambda1;\n },\n sphere: function() {\n lambda0 = -(lambda1 = 180), phi0 = -(phi1 = 90);\n }\n};\n\nfunction boundsPoint(lambda, phi) {\n ranges.push(range = [lambda0 = lambda, lambda1 = lambda]);\n if (phi < phi0) phi0 = phi;\n if (phi > phi1) phi1 = phi;\n}\n\nfunction linePoint(lambda, phi) {\n var p = cartesian([lambda * radians, phi * radians]);\n if (p0) {\n var normal = cartesianCross(p0, p),\n equatorial = [normal[1], -normal[0], 0],\n inflection = cartesianCross(equatorial, normal);\n cartesianNormalizeInPlace(inflection);\n inflection = spherical(inflection);\n var delta = lambda - lambda2,\n sign = delta > 0 ? 1 : -1,\n lambdai = inflection[0] * degrees * sign,\n phii,\n antimeridian = abs(delta) > 180;\n if (antimeridian ^ (sign * lambda2 < lambdai && lambdai < sign * lambda)) {\n phii = inflection[1] * degrees;\n if (phii > phi1) phi1 = phii;\n } else if (lambdai = (lambdai + 360) % 360 - 180, antimeridian ^ (sign * lambda2 < lambdai && lambdai < sign * lambda)) {\n phii = -inflection[1] * degrees;\n if (phii < phi0) phi0 = phii;\n } else {\n if (phi < phi0) phi0 = phi;\n if (phi > phi1) phi1 = phi;\n }\n if (antimeridian) {\n if (lambda < lambda2) {\n if (angle(lambda0, lambda) > angle(lambda0, lambda1)) lambda1 = lambda;\n } else {\n if (angle(lambda, lambda1) > angle(lambda0, lambda1)) lambda0 = lambda;\n }\n } else {\n if (lambda1 >= lambda0) {\n if (lambda < lambda0) lambda0 = lambda;\n if (lambda > lambda1) lambda1 = lambda;\n } else {\n if (lambda > lambda2) {\n if (angle(lambda0, lambda) > angle(lambda0, lambda1)) lambda1 = lambda;\n } else {\n if (angle(lambda, lambda1) > angle(lambda0, lambda1)) lambda0 = lambda;\n }\n }\n }\n } else {\n ranges.push(range = [lambda0 = lambda, lambda1 = lambda]);\n }\n if (phi < phi0) phi0 = phi;\n if (phi > phi1) phi1 = phi;\n p0 = p, lambda2 = lambda;\n}\n\nfunction boundsLineStart() {\n boundsStream.point = linePoint;\n}\n\nfunction boundsLineEnd() {\n range[0] = lambda0, range[1] = lambda1;\n boundsStream.point = boundsPoint;\n p0 = null;\n}\n\nfunction boundsRingPoint(lambda, phi) {\n if (p0) {\n var delta = lambda - lambda2;\n deltaSum.add(abs(delta) > 180 ? delta + (delta > 0 ? 360 : -360) : delta);\n } else {\n lambda00 = lambda, phi00 = phi;\n }\n areaStream.point(lambda, phi);\n linePoint(lambda, phi);\n}\n\nfunction boundsRingStart() {\n areaStream.lineStart();\n}\n\nfunction boundsRingEnd() {\n boundsRingPoint(lambda00, phi00);\n areaStream.lineEnd();\n if (abs(deltaSum) > epsilon) lambda0 = -(lambda1 = 180);\n range[0] = lambda0, range[1] = lambda1;\n p0 = null;\n}\n\n// Finds the left-right distance between two longitudes.\n// This is almost the same as (lambda1 - lambda0 + 360°) % 360°, except that we want\n// the distance between ±180° to be 360°.\nfunction angle(lambda0, lambda1) {\n return (lambda1 -= lambda0) < 0 ? lambda1 + 360 : lambda1;\n}\n\nfunction rangeCompare(a, b) {\n return a[0] - b[0];\n}\n\nfunction rangeContains(range, x) {\n return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x;\n}\n\nexport default function(feature) {\n var i, n, a, b, merged, deltaMax, delta;\n\n phi1 = lambda1 = -(lambda0 = phi0 = Infinity);\n ranges = [];\n stream(feature, boundsStream);\n\n // First, sort ranges by their minimum longitudes.\n if (n = ranges.length) {\n ranges.sort(rangeCompare);\n\n // Then, merge any ranges that overlap.\n for (i = 1, a = ranges[0], merged = [a]; i < n; ++i) {\n b = ranges[i];\n if (rangeContains(a, b[0]) || rangeContains(a, b[1])) {\n if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1];\n if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0];\n } else {\n merged.push(a = b);\n }\n }\n\n // Finally, find the largest gap between the merged ranges.\n // The final bounding box will be the inverse of this gap.\n for (deltaMax = -Infinity, n = merged.length - 1, i = 0, a = merged[n]; i <= n; a = b, ++i) {\n b = merged[i];\n if ((delta = angle(a[1], b[0])) > deltaMax) deltaMax = delta, lambda0 = b[0], lambda1 = a[1];\n }\n }\n\n ranges = range = null;\n\n return lambda0 === Infinity || phi0 === Infinity\n ? [[NaN, NaN], [NaN, NaN]]\n : [[lambda0, phi0], [lambda1, phi1]];\n}\n","import {asin, atan2, cos, sin, sqrt} from \"./math.js\";\n\nexport function spherical(cartesian) {\n return [atan2(cartesian[1], cartesian[0]), asin(cartesian[2])];\n}\n\nexport function cartesian(spherical) {\n var lambda = spherical[0], phi = spherical[1], cosPhi = cos(phi);\n return [cosPhi * cos(lambda), cosPhi * sin(lambda), sin(phi)];\n}\n\nexport function cartesianDot(a, b) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n}\n\nexport function cartesianCross(a, b) {\n return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];\n}\n\n// TODO return a\nexport function cartesianAddInPlace(a, b) {\n a[0] += b[0], a[1] += b[1], a[2] += b[2];\n}\n\nexport function cartesianScale(vector, k) {\n return [vector[0] * k, vector[1] * k, vector[2] * k];\n}\n\n// TODO return d\nexport function cartesianNormalizeInPlace(d) {\n var l = sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);\n d[0] /= l, d[1] /= l, d[2] /= l;\n}\n","/**\r\n * Map series module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Series, SeriesDataItem } from \"../series/Series\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport * as $type from \"../../core/utils/Type\";\r\nimport * as $math from \"../../core/utils/Math\";\r\nimport * as d3geo from \"d3-geo\";\r\n/**\r\n * ============================================================================\r\n * DATA ITEM\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines a [[DataItem]] for [[MapSeries]].\r\n *\r\n * @see {@link DataItem}\r\n */\r\nvar MapSeriesDataItem = /** @class */ (function (_super) {\r\n __extends(MapSeriesDataItem, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapSeriesDataItem() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"MapSeriesDataItem\";\r\n _this.values.value = {};\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(MapSeriesDataItem.prototype, \"value\", {\r\n /**\r\n * @return Value\r\n */\r\n get: function () {\r\n return this.values.value.value;\r\n },\r\n /**\r\n * Numeric value of the data item.\r\n *\r\n * Value may be used in heat-map calculations.\r\n *\r\n * @param value Value\r\n */\r\n set: function (value) {\r\n this.setValue(\"value\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapSeriesDataItem.prototype, \"zoomLevel\", {\r\n /**\r\n * @return Zoom level\r\n */\r\n get: function () {\r\n return this.properties[\"zoomLevel\"];\r\n },\r\n /**\r\n * When `zoomToMapObject()` is called the map will either calculate suitable\r\n * zoom level itself or use object's `zoomLevel` if set.\r\n *\r\n * @param value Zoom level\r\n */\r\n set: function (value) {\r\n this.setProperty(\"zoomLevel\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapSeriesDataItem.prototype, \"zoomGeoPoint\", {\r\n /**\r\n * @return Zoom geo point\r\n */\r\n get: function () {\r\n return this.properties[\"zoomGeoPoint\"];\r\n },\r\n /**\r\n * When `zoomToMapObject()` is called the map will either calculate suitable\r\n * center position itself or use object's `zoomGeoPoint` if set.\r\n *\r\n * @param value Zoom geo point\r\n */\r\n set: function (value) {\r\n this.setProperty(\"zoomGeoPoint\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapSeriesDataItem.prototype, \"east\", {\r\n /**\r\n * Longitude of the East-most point of the element.\r\n */\r\n get: function () {\r\n return this._east;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapSeriesDataItem.prototype, \"west\", {\r\n /**\r\n * Longitude of the West-most point of the element.\r\n */\r\n get: function () {\r\n return this._west;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapSeriesDataItem.prototype, \"south\", {\r\n /**\r\n * Latitude of the South-most point of the element.\r\n */\r\n get: function () {\r\n return this._south;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapSeriesDataItem.prototype, \"north\", {\r\n /**\r\n * Latitude of the North-most point of the element.\r\n */\r\n get: function () {\r\n return this._north;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Updates the item's bounding coordinates: coordinates of the East, West,\r\n * North, and South-most points.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n MapSeriesDataItem.prototype.updateExtremes = function () {\r\n var geometry = this.getFeature().geometry;\r\n if (geometry) {\r\n var bounds = d3geo.geoBounds(geometry);\r\n var west = bounds[0][0];\r\n var south = bounds[0][1];\r\n var north = bounds[1][1];\r\n var east = bounds[1][0];\r\n var changed = false;\r\n if (north != this.north) {\r\n this._north = $math.round(north, 6);\r\n changed = true;\r\n }\r\n if (south != this.south) {\r\n this._south = $math.round(south, 6);\r\n changed = true;\r\n }\r\n if (east != this.east) {\r\n this._east = $math.round(east, 6);\r\n changed = true;\r\n }\r\n if (west != this.west) {\r\n this._west = $math.round(west, 6);\r\n changed = true;\r\n }\r\n // solves single russia prob\r\n if (this._east < this._west) {\r\n this._east = 180;\r\n this._west = -180;\r\n }\r\n if (changed) {\r\n this.component.invalidateDataItems();\r\n }\r\n }\r\n };\r\n MapSeriesDataItem.prototype.getFeature = function () {\r\n return {};\r\n };\r\n return MapSeriesDataItem;\r\n}(SeriesDataItem));\r\nexport { MapSeriesDataItem };\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A base class for series of map objects.\r\n *\r\n * @see {@link IMapSeriesEvents} for a list of available Events\r\n * @see {@link IMapSeriesAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar MapSeries = /** @class */ (function (_super) {\r\n __extends(MapSeries, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapSeries() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"MapSeries\";\r\n // Set defaults\r\n _this.isMeasured = false;\r\n _this.nonScalingStroke = true;\r\n // Set data fields\r\n _this.dataFields.value = \"value\";\r\n _this.ignoreBounds = false;\r\n if (_this.tooltip) {\r\n _this.tooltip.showInViewport = true;\r\n }\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Returns a new/empty DataItem of the type appropriate for this object.\r\n *\r\n * @see {@link DataItem}\r\n * @return Data Item\r\n */\r\n MapSeries.prototype.createDataItem = function () {\r\n return new MapSeriesDataItem();\r\n };\r\n /**\r\n * Checks whether object should be included in series.\r\n *\r\n * @param includes A list of explicitly included ids\r\n * @param excludes A list of explicitly excluded ids\r\n * @param id Id of the object\r\n * @return Include?\r\n */\r\n MapSeries.prototype.checkInclude = function (includes, excludes, id) {\r\n if (includes) {\r\n if (includes.length == 0) {\r\n return false;\r\n }\r\n else {\r\n if (includes.indexOf(id) == -1) {\r\n return false;\r\n }\r\n }\r\n }\r\n if (excludes && excludes.length > 0) {\r\n if (excludes.indexOf(id) != -1) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n };\r\n Object.defineProperty(MapSeries.prototype, \"useGeodata\", {\r\n /**\r\n * @return Use GeoJSON data?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"useGeodata\");\r\n },\r\n /**\r\n * Should the map extract all the data about element from the GeoJSON?\r\n *\r\n * This is especially relevant for [[MapPolygonSeries]]. If not set to `true`\r\n * polygon series will need to contain geographical data in itself in order\r\n * to be drawn.\r\n *\r\n * If this is set to `true`, series will try to extract data for its objects\r\n * from either chart-level `geodata` or from series' `geodata` which holds\r\n * map infor in GeoJSON format.\r\n *\r\n * @default false\r\n * @param value Use GeoJSON data?\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"useGeodata\", value)) {\r\n this.invalidateData();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapSeries.prototype, \"include\", {\r\n /**\r\n * @return Included objects\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"include\");\r\n },\r\n /**\r\n * A list of object ids that should be explictly included in the series.\r\n *\r\n * If this is not set, the series will automatically include all of the\r\n * objects, available in the GeoJSON map. (minus the ones listed in\r\n * `exclude`)\r\n *\r\n * If you need to display only specific objects, use `include`. E.g.:\r\n *\r\n * `include = [\"FR\", \"ES\", \"DE\"];`\r\n *\r\n * The above will show only France, Spain, and Germany out of the whole map.\r\n *\r\n * @param value Included objects\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"include\", value)) {\r\n this.processIncExc();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * @ignore\r\n */\r\n MapSeries.prototype.processIncExc = function () {\r\n //this.data = [];\r\n this.invalidateData();\r\n };\r\n Object.defineProperty(MapSeries.prototype, \"ignoreBounds\", {\r\n /**\r\n * @return Ignore bounds?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"ignoreBounds\");\r\n },\r\n /**\r\n * Should this series be included when calculating bounds of the map?\r\n *\r\n * This affects initial zoom as well as limits for zoom/pan.\r\n *\r\n * By default, `MapPolygonSeries` included (true), while `MapImageSeries` and\r\n * `MapLineSeries` are not (`false`).\r\n *\r\n * @since 4.3.0\r\n * @param value Ignore bounds?\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"ignoreBounds\", value)) {\r\n if (this.chart) {\r\n this.chart.updateExtremes();\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapSeries.prototype, \"exclude\", {\r\n /**\r\n * @return Excluded ids\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"exclude\");\r\n },\r\n /**\r\n * A list of object ids that should be excluded from the series.\r\n *\r\n * E.g. you want to include all of the areas from a GeoJSON map, except\r\n * Antarctica.\r\n *\r\n * You'd leave `include` empty, and set `exclude = [\"AQ\"]`.\r\n *\r\n * @param value Excluded ids\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"exclude\", value)) {\r\n this.processIncExc();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Decorates a newly added object.\r\n *\r\n * @param event [description]\r\n */\r\n MapSeries.prototype.handleObjectAdded = function (event) {\r\n var mapObject = event.newValue;\r\n mapObject.parent = this;\r\n mapObject.series = this;\r\n mapObject.strokeWidth = mapObject.strokeWidth;\r\n };\r\n Object.defineProperty(MapSeries.prototype, \"geodata\", {\r\n /**\r\n * @return GeoJSON data\r\n */\r\n get: function () {\r\n return this._geodata;\r\n },\r\n /**\r\n * Map data in GeoJSON format.\r\n *\r\n * The series supports the following GeoJSON objects: `Point`, `LineString`,\r\n * `Polygon`, `MultiPoint`, `MultiLineString`, and `MultiPolygon`.\r\n *\r\n * @see {@link http://geojson.org/} Official GeoJSON format specification\r\n * @param geoJSON GeoJSON data\r\n */\r\n set: function (geodata) {\r\n if (geodata != this._geodata) {\r\n this._geodata = geodata;\r\n if (this.reverseGeodata) {\r\n this.chart.processReverseGeodata(this._geodata);\r\n }\r\n for (var i = this.data.length - 1; i >= 0; i--) {\r\n if (this.data[i].madeFromGeoData == true) {\r\n this.data.splice(i, 1);\r\n }\r\n }\r\n this.disposeData();\r\n this.invalidateData();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapSeries.prototype, \"reverseGeodata\", {\r\n /**\r\n * @returns Reverse the order of geodata coordinates?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"reverseGeodata\");\r\n },\r\n /**\r\n * Indicates whether GeoJSON geodata supplied to the chart uses\r\n * ESRI (clockwise) or non-ESRI (counter-clockwise) order of the polygon\r\n * coordinates.\r\n *\r\n * `MapChart` supports only ESRI standard, so if your custom maps appears\r\n * garbled, try setting `reverseGeodata = true`.\r\n *\r\n * @default false\r\n * @since 4.10.11\r\n * @param value Reverse the order of geodata coordinates?\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"reverseGeodata\", value) && this._geodata) {\r\n this.chart.processReverseGeodata(this._geodata);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapSeries.prototype, \"geodataSource\", {\r\n /**\r\n * Returns a [[DataSource]] specifically for loading Component's data.\r\n *\r\n * @return Data source\r\n */\r\n get: function () {\r\n if (!this._dataSources[\"geodata\"]) {\r\n this.getDataSource(\"geodata\");\r\n }\r\n return this._dataSources[\"geodata\"];\r\n },\r\n /**\r\n * Sets a [[DataSource]] to be used for loading Component's data.\r\n *\r\n * @param value Data source\r\n */\r\n set: function (value) {\r\n var _this = this;\r\n if (this._dataSources[\"geodata\"]) {\r\n this.removeDispose(this._dataSources[\"geodata\"]);\r\n }\r\n this._dataSources[\"geodata\"] = value;\r\n this._dataSources[\"geodata\"].component = this;\r\n this.events.on(\"inited\", function () {\r\n _this.loadData(\"geodata\");\r\n }, undefined, false);\r\n this.setDataSourceEvents(value, \"geodata\");\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * @ignore\r\n */\r\n MapSeries.prototype.getFeatures = function () {\r\n return;\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapSeries.prototype.validateDataItems = function () {\r\n _super.prototype.validateDataItems.call(this);\r\n this.updateExtremes();\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapSeries.prototype.updateExtremes = function () {\r\n var north;\r\n var south;\r\n var east;\r\n var west;\r\n this.dataItems.each(function (dataItem) {\r\n if (dataItem.north > north || !$type.isNumber(north)) {\r\n north = dataItem.north;\r\n }\r\n if (dataItem.south < south || !$type.isNumber(south)) {\r\n south = dataItem.south;\r\n }\r\n if (dataItem.west < west || !$type.isNumber(west)) {\r\n west = dataItem.west;\r\n }\r\n if (dataItem.east > east || !$type.isNumber(east)) {\r\n east = dataItem.east;\r\n }\r\n });\r\n if (this._mapObjects) {\r\n this._mapObjects.each(function (mapObject) {\r\n if (mapObject.north > north || !$type.isNumber(north)) {\r\n north = mapObject.north;\r\n }\r\n if (mapObject.south < south || !$type.isNumber(south)) {\r\n south = mapObject.south;\r\n }\r\n if (mapObject.west < west || !$type.isNumber(west)) {\r\n west = mapObject.west;\r\n }\r\n if (mapObject.east > east || !$type.isNumber(east)) {\r\n east = mapObject.east;\r\n }\r\n });\r\n }\r\n if (this.north != north || this.east != east || this.south != south || this.west != west) {\r\n this._north = north;\r\n this._east = east;\r\n this._west = west;\r\n this._south = south;\r\n this.dispatch(\"geoBoundsChanged\");\r\n if (!this.ignoreBounds) {\r\n this.chart.updateExtremes();\r\n }\r\n }\r\n };\r\n Object.defineProperty(MapSeries.prototype, \"north\", {\r\n /**\r\n * @return Latitude\r\n */\r\n get: function () {\r\n if ($type.isNumber(this._northDefined)) {\r\n return this._northDefined;\r\n }\r\n return this._north;\r\n },\r\n /**\r\n * North-most latitude of the series.\r\n *\r\n * By default, this holds auto-calculated latitude of the extremity.\r\n *\r\n * It can be overridden manually.\r\n *\r\n * @param value Latitude\r\n */\r\n set: function (value) {\r\n this._northDefined = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapSeries.prototype, \"south\", {\r\n /**\r\n * @return Latitude\r\n */\r\n get: function () {\r\n if ($type.isNumber(this._southDefined)) {\r\n return this._southDefined;\r\n }\r\n return this._south;\r\n },\r\n /**\r\n * South-most latitude of the series.\r\n *\r\n * By default, this holds auto-calculated latitude of the extremity.\r\n *\r\n * It can be overridden manually.\r\n *\r\n * @param value Latitude\r\n */\r\n set: function (value) {\r\n this._southDefined = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapSeries.prototype, \"west\", {\r\n /**\r\n * @return Longitude\r\n */\r\n get: function () {\r\n if ($type.isNumber(this._westDefined)) {\r\n return this._westDefined;\r\n }\r\n return this._west;\r\n },\r\n /**\r\n * West-most longitude of the series.\r\n *\r\n * By default, this holds auto-calculated longitude of the extremity.\r\n *\r\n * It can be overridden manually.\r\n *\r\n * @param value Longitude\r\n */\r\n set: function (value) {\r\n this._westDefined = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapSeries.prototype, \"east\", {\r\n /**\r\n * @return Longitude\r\n */\r\n get: function () {\r\n if ($type.isNumber(this._eastDefined)) {\r\n return this._eastDefined;\r\n }\r\n return this._east;\r\n },\r\n /**\r\n * East-most longitude of the series.\r\n *\r\n * By default, this holds auto-calculated longitude of the extremity.\r\n *\r\n * It can be overridden manually.\r\n *\r\n * @param value Longitude\r\n */\r\n set: function (value) {\r\n this._eastDefined = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Processes JSON-based config before it is applied to the object.\r\n *\r\n * @ignore Exclude from docs\r\n * @param config Config\r\n */\r\n MapSeries.prototype.processConfig = function (config) {\r\n if ($type.hasValue(config[\"geodata\"]) && $type.isString(config[\"geodata\"])) {\r\n var name_1 = config[\"geodata\"];\r\n // Check if there's a map loaded by such name\r\n if ($type.hasValue(window[\"am4geodata_\" + config[\"geodata\"]])) {\r\n config[\"geodata\"] = window[\"am4geodata_\" + config[\"geodata\"]];\r\n }\r\n // Nope. Let's try maybe we got JSON as string?\r\n else {\r\n try {\r\n config[\"geodata\"] = JSON.parse(config[\"geodata\"]);\r\n }\r\n catch (e) {\r\n // No go again. Error out.\r\n throw Error(\"MapChart error: Geodata `\" + name_1 + \"` is not loaded or is incorrect.\");\r\n }\r\n }\r\n }\r\n _super.prototype.processConfig.call(this, config);\r\n };\r\n /**\r\n * Adds `projection` to \"as is\" fields.\r\n *\r\n * @param field Field name\r\n * @return Assign as is?\r\n */\r\n MapSeries.prototype.asIs = function (field) {\r\n return field == \"geodata\" || _super.prototype.asIs.call(this, field);\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapSeries.prototype.updateTooltipBounds = function () {\r\n if (this.tooltip && this.topParent) {\r\n this.tooltip.setBounds({ x: 10, y: 10, width: this.topParent.maxWidth - 20, height: this.topParent.maxHeight - 20 });\r\n }\r\n };\r\n return MapSeries;\r\n}(Series));\r\nexport { MapSeries };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"MapSeries\"] = MapSeries;\r\nregistry.registeredClasses[\"MapSeriesDataItem\"] = MapSeriesDataItem;\r\n//# sourceMappingURL=MapSeries.js.map","/**\r\n * Map object module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../../core/Container\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport * as $math from \"../../core/utils/Math\";\r\nimport * as d3geo from \"d3-geo\";\r\nimport * as $type from \"../../core/utils/Type\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A base class for all map objects: lines, images, etc.\r\n *\r\n * @see {@link IMapObjectEvents} for a list of available events\r\n * @see {@link IMapObjectAdapters} for a list of available Adapters\r\n */\r\nvar MapObject = /** @class */ (function (_super) {\r\n __extends(MapObject, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapObject() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"MapObject\";\r\n // Set defaults\r\n _this.isMeasured = false;\r\n _this.layout = \"none\";\r\n _this.clickable = true;\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * (Re)validates this object, forcing it to redraw.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n MapObject.prototype.validate = function () {\r\n if (this.series && this.series.itemReaderText) {\r\n this.readerTitle = this.series.itemReaderText;\r\n }\r\n _super.prototype.validate.call(this);\r\n };\r\n /**\r\n * Updates the item's bounding coordinates: coordinates of the East, West,\r\n * North, and South-most points.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n MapObject.prototype.updateExtremes = function () {\r\n var feature = this.getFeature();\r\n if (feature) {\r\n var geometry = feature.geometry;\r\n if (geometry) {\r\n var bounds = d3geo.geoBounds(geometry);\r\n var west = bounds[0][0];\r\n var south = bounds[0][1];\r\n var north = bounds[1][1];\r\n var east = bounds[1][0];\r\n var changed = false;\r\n if (north != this.north) {\r\n this._north = $math.round(north, 8);\r\n changed = true;\r\n }\r\n if (south != this.south) {\r\n this._south = $math.round(south);\r\n changed = true;\r\n }\r\n if (east != this.east) {\r\n this._east = $math.round(east);\r\n changed = true;\r\n }\r\n if (west != this.west) {\r\n this._west = $math.round(west);\r\n changed = true;\r\n }\r\n if (changed) {\r\n this.dispatch(\"geoBoundsChanged\");\r\n if (this.series) {\r\n this.series.invalidateDataItems();\r\n }\r\n }\r\n }\r\n }\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapObject.prototype.getFeature = function () {\r\n return {};\r\n };\r\n Object.defineProperty(MapObject.prototype, \"east\", {\r\n /**\r\n * Longitude of the East-most point of the element.\r\n */\r\n get: function () {\r\n if ($type.isNumber(this._east)) {\r\n return this._east;\r\n }\r\n else if (this.dataItem) {\r\n return this.dataItem.east;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapObject.prototype, \"west\", {\r\n /**\r\n * Longitude of the West-most point of the element.\r\n */\r\n get: function () {\r\n if ($type.isNumber(this._west)) {\r\n return this._west;\r\n }\r\n else if (this.dataItem) {\r\n return this.dataItem.west;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapObject.prototype, \"south\", {\r\n /**\r\n * Latitude of the South-most point of the element.\r\n */\r\n get: function () {\r\n if ($type.isNumber(this._south)) {\r\n return this._south;\r\n }\r\n else if (this.dataItem) {\r\n return this.dataItem.south;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapObject.prototype, \"north\", {\r\n /**\r\n * Latitude of the North-most point of the element.\r\n */\r\n get: function () {\r\n if ($type.isNumber(this._north)) {\r\n return this._north;\r\n }\r\n else if (this.dataItem) {\r\n return this.dataItem.north;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Shows the element's [[Tooltip]].\r\n *\r\n * A tooltip will be populated using text templates in either `tooltipHTML` or\r\n * `tooltipText` as well as data in `tooltipDataItem`.\r\n *\r\n * @see {@link Tooltip}\r\n * @param optional point (sprite-related) to which tooltip must point.\r\n * @return returns true if the tooltip was shown and false if it wasn't (no text was found)\r\n */\r\n MapObject.prototype.showTooltip = function (point) {\r\n var res = _super.prototype.showTooltip.call(this, point);\r\n if (res && this.showTooltipOn == \"always\" && !this.series.chart.events.has(\"mappositionchanged\", this.handleTooltipMove, this)) {\r\n this.addDisposer(this.series.chart.events.on(\"mappositionchanged\", this.handleTooltipMove, this));\r\n }\r\n return res;\r\n };\r\n MapObject.prototype.handleTooltipMove = function (ev) {\r\n if (!this.tooltip.isHidden) {\r\n this.showTooltip();\r\n }\r\n };\r\n /**\r\n * Sets a [[DataItem]].\r\n * @param dataItem DataItem\r\n */\r\n MapObject.prototype.setDataItem = function (dataItem) {\r\n _super.prototype.setDataItem.call(this, dataItem);\r\n this.applyAccessibility();\r\n };\r\n return MapObject;\r\n}(Container));\r\nexport { MapObject };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"MapObject\"] = MapObject;\r\n//# sourceMappingURL=MapObject.js.map","/**\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { MapObject } from \"./MapObject\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport * as $type from \"../../core/utils/Type\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Used to place an image on the map.\r\n *\r\n * @see {@link IMapImageEvents} for a list of available events\r\n * @see {@link IMapImageAdapters} for a list of available Adapters\r\n */\r\nvar MapImage = /** @class */ (function (_super) {\r\n __extends(MapImage, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapImage() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"MapImage\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(MapImage.prototype, \"latitude\", {\r\n /**\r\n * @return Latitude\r\n */\r\n get: function () {\r\n var latitude = this.getPropertyValue(\"latitude\");\r\n if (!$type.isNumber(latitude) && this.dataItem && this.dataItem.geoPoint) {\r\n latitude = this.dataItem.geoPoint.latitude;\r\n }\r\n return latitude;\r\n },\r\n /**\r\n * Latitude image is placed at.\r\n *\r\n * @param value Latitude\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"latitude\", value, false, true);\r\n this.updateExtremes();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapImage.prototype, \"longitude\", {\r\n /**\r\n * @return Longitude\r\n */\r\n get: function () {\r\n var longitude = this.getPropertyValue(\"longitude\");\r\n if (!$type.isNumber(longitude) && this.dataItem && this.dataItem.geoPoint) {\r\n longitude = this.dataItem.geoPoint.longitude;\r\n }\r\n return longitude;\r\n },\r\n /**\r\n * Longitude image is placed on.\r\n *\r\n * @param value Longitude\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"longitude\", value, false, true);\r\n this.updateExtremes();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Repositions the image to it's current position.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n MapImage.prototype.validatePosition = function () {\r\n if ($type.isNumber(this.latitude) && $type.isNumber(this.longitude)) {\r\n //this.moveTo(this.series.chart.projection.convert({ latitude: this.latitude, longitude: this.longitude }));\r\n var p = this.series.chart.projection.d3Projection([this.longitude, this.latitude]);\r\n var visible = this.series.chart.projection.d3Path({ type: 'Point', coordinates: [this.longitude, this.latitude] });\r\n if (!visible) {\r\n this.__disabled = true;\r\n }\r\n else {\r\n this.__disabled = false;\r\n }\r\n this.moveTo({ x: p[0], y: p[1] });\r\n }\r\n _super.prototype.validatePosition.call(this);\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapImage.prototype.getFeature = function () {\r\n return { \"type\": \"Feature\", geometry: { type: \"Point\", coordinates: [this.longitude, this.latitude] } };\r\n };\r\n return MapImage;\r\n}(MapObject));\r\nexport { MapImage };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"MapImage\"] = MapImage;\r\n//# sourceMappingURL=MapImage.js.map","/**\r\n * A collection of Map-related utility functions.\r\n */\r\nimport * as $array from \"../../core/utils/Array\";\r\nimport * as d3geo from \"d3-geo\";\r\n/**\r\n * Converts a multi-part polygon in X/Y coordinates to a geo-multipolygon in\r\n * geo-points (lat/long).\r\n *\r\n * @param multiPolygon Source multi-polygon\r\n * @return Geo-multipolygon\r\n */\r\nexport function multiPolygonToGeo(multiPolygon) {\r\n return $array.map(multiPolygon, function (polygon) {\r\n var surface = polygon[0];\r\n var hole = polygon[1];\r\n //let holePoints: Array = [];\r\n var geoArea = [];\r\n if (surface) {\r\n geoArea.push(multiPointToGeo(surface));\r\n }\r\n if (hole) {\r\n geoArea.push(multiPointToGeo(hole));\r\n }\r\n return geoArea;\r\n });\r\n}\r\n/**\r\n * Converts a multiline in X/Y coordinates to a geo-multiline in geo-points\r\n * (lat/long).\r\n *\r\n * @param multiLine Source multiline\r\n * @return Geo-multiline\r\n */\r\nexport function multiLineToGeo(multiLine) {\r\n return $array.map(multiLine, function (multiLine) {\r\n return multiPointToGeo(multiLine);\r\n });\r\n}\r\n/**\r\n * Converts multiple X/Y points into a lat/long geo-points.\r\n *\r\n * @param points Source points\r\n * @return Geo-points\r\n */\r\nexport function multiPointToGeo(points) {\r\n return $array.map(points, function (point) {\r\n return pointToGeo(point);\r\n });\r\n}\r\n/**\r\n * Converts multiple X/Y points into a lat/long geo-points.\r\n *\r\n * @param points Source points\r\n * @return Geo-points\r\n */\r\nexport function multiGeoToPoint(geoPoints) {\r\n return $array.map(geoPoints, geoToPoint);\r\n}\r\n/**\r\n * Converts X/Y point into a lat/long geo-point.\r\n *\r\n * @param point Source point\r\n * @return Geo-point\r\n */\r\nexport function pointToGeo(point) {\r\n return { longitude: point[0], latitude: point[1] };\r\n}\r\n/**\r\n * Converts lat/long geo-point into a X/Y point.\r\n *\r\n * @param point Source geo-point\r\n * @return X/Y point\r\n */\r\nexport function geoToPoint(geoPoint) {\r\n return [geoPoint.longitude, geoPoint.latitude];\r\n}\r\n/**\r\n * Converts geo line (collection of lat/long coordinates) to screen line (x/y).\r\n *\r\n * @param multiGeoLine Source geo line\r\n * @return Screen line\r\n */\r\nexport function multiGeoLineToMultiLine(multiGeoLine) {\r\n return $array.map(multiGeoLine, function (segment) {\r\n return $array.map(segment, geoToPoint);\r\n });\r\n}\r\n/**\r\n * Converts a geo polygon (collection of lat/long coordinates) to screen\r\n * polygon (x/y).\r\n *\r\n * @param multiGeoPolygon Source polygon\r\n * @return Screen polygon\r\n */\r\nexport function multiGeoPolygonToMultipolygon(multiGeoPolygon) {\r\n return $array.map(multiGeoPolygon, function (geoPolygon) {\r\n var surface = geoPolygon[0];\r\n var hole = geoPolygon[1];\r\n var multiPolygon = [];\r\n if (surface) {\r\n multiPolygon.push(multiGeoToPoint(surface));\r\n }\r\n if (hole) {\r\n multiPolygon.push(multiGeoToPoint(hole));\r\n }\r\n return multiPolygon;\r\n });\r\n}\r\n/**\r\n * Returns a set of geographical coordinates for the circle with a center\r\n * at specific lat/long coordinates and radius (in degrees).\r\n *\r\n * @since 4.3.0\r\n * @param longitude Center longitude\r\n * @param latitude Center latitude\r\n * @param radius Radius (degrees)\r\n * @return Circle coordinates\r\n */\r\nexport function getCircle(longitude, latitude, radius) {\r\n return [d3geo.geoCircle().center([longitude, latitude]).radius(radius)().coordinates];\r\n}\r\n/**\r\n * Returns a set of screen coordinates that represents a \"background\" area\r\n * between provided extremities.\r\n *\r\n * @since 4.3.0\r\n * @param north North latitude\r\n * @param east East longitude\r\n * @param south South latitude\r\n * @param west West longitude\r\n * @return Polygon\r\n */\r\nexport function getBackground(north, east, south, west) {\r\n var multiPolygon = [];\r\n if (west == -180) {\r\n west = -179.9999;\r\n }\r\n if (south == -90) {\r\n south = -89.9999;\r\n }\r\n if (north == 90) {\r\n north = 89.9999;\r\n }\r\n if (east == 180) {\r\n east = 179.9999;\r\n }\r\n var stepLong = Math.min(90, (east - west) / Math.ceil((east - west) / 90));\r\n var stepLat = (north - south) / Math.ceil((north - south) / 90);\r\n for (var ln = west; ln < east; ln = ln + stepLong) {\r\n var surface = [];\r\n multiPolygon.push([surface]);\r\n if (ln + stepLong > east) {\r\n stepLong = east - ln;\r\n }\r\n for (var ll = ln; ll <= ln + stepLong; ll = ll + 5) {\r\n surface.push([ll, north]);\r\n }\r\n for (var lt = north; lt >= south; lt = lt - stepLat) {\r\n surface.push([ln + stepLong, lt]);\r\n }\r\n for (var ll = ln + stepLong; ll >= ln; ll = ll - 5) {\r\n surface.push([ll, south]);\r\n }\r\n for (var lt = south; lt <= north; lt = lt + stepLat) {\r\n surface.push([ln, lt]);\r\n }\r\n }\r\n return multiPolygon;\r\n}\r\n//# sourceMappingURL=MapUtils.js.map","/**\r\n * Map polygon module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { MapObject } from \"./MapObject\";\r\nimport { Polygon } from \"../../core/elements/Polygon\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport * as $type from \"../../core/utils/Type\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport $polylabel from \"polylabel\";\r\nimport * as $mapUtils from \"./MapUtils\";\r\nimport * as d3geo from \"d3-geo\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Used to draw a polygon on the map.\r\n *\r\n * @see {@link IMapPolygonEvents} for a list of available events\r\n * @see {@link IMapPolygonAdapters} for a list of available Adapters\r\n */\r\nvar MapPolygon = /** @class */ (function (_super) {\r\n __extends(MapPolygon, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapPolygon() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"MapPolygon\";\r\n _this.polygon = _this.createChild(Polygon);\r\n _this.polygon.shouldClone = false;\r\n _this.polygon.applyOnClones = true;\r\n _this.setPropertyValue(\"precision\", 0.5);\r\n var interfaceColors = new InterfaceColorSet();\r\n _this.fill = interfaceColors.getFor(\"secondaryButton\");\r\n _this.stroke = interfaceColors.getFor(\"secondaryButtonStroke\");\r\n _this.strokeOpacity = 1;\r\n _this.tooltipPosition = \"pointer\";\r\n _this.nonScalingStroke = true;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * @ignore\r\n */\r\n MapPolygon.prototype.getFeature = function () {\r\n if (this.multiPolygon && this.multiPolygon.length > 0) {\r\n return { \"type\": \"Feature\", geometry: { type: \"MultiPolygon\", coordinates: this.multiPolygon } };\r\n }\r\n };\r\n Object.defineProperty(MapPolygon.prototype, \"multiGeoPolygon\", {\r\n /**\r\n * @return Polygon coordinates\r\n */\r\n get: function () {\r\n var multiGeoPolygon = this.getPropertyValue(\"multiGeoPolygon\");\r\n if (!multiGeoPolygon && this.dataItem) {\r\n multiGeoPolygon = this.dataItem.multiGeoPolygon;\r\n }\r\n return multiGeoPolygon;\r\n },\r\n /**\r\n * Set of coordinates for the polygon.\r\n *\r\n * @param multiGeoPolygon Polygon coordinates\r\n */\r\n set: function (multiGeoPolygon) {\r\n this.setPropertyValue(\"multiGeoPolygon\", multiGeoPolygon, true);\r\n this.multiPolygon = $mapUtils.multiGeoPolygonToMultipolygon(multiGeoPolygon);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapPolygon.prototype, \"multiPolygon\", {\r\n /**\r\n * @return Coordinates\r\n */\r\n get: function () {\r\n var multiPolygon = this.getPropertyValue(\"multiPolygon\");\r\n if (!multiPolygon && this.dataItem) {\r\n multiPolygon = this.dataItem.multiPolygon;\r\n }\r\n return multiPolygon;\r\n },\r\n /**\r\n * A collection of X/Y coordinates for a multi-part polygon. E.g.:\r\n *\r\n * ```JSON\r\n * [\r\n * // Part 1\r\n * [\r\n * [\r\n * [ 100, 150 ],\r\n * [ 120, 200 ],\r\n * [ 150, 220 ],\r\n * [ 170, 240 ],\r\n * [ 100, 150 ]\r\n * ]\r\n * ],\r\n *\r\n * // Part 2\r\n * [\r\n * [\r\n * [ 300, 350 ],\r\n * [ 320, 400 ],\r\n * [ 350, 420 ],\r\n * [ 370, 440 ],\r\n * [ 300, 350 ]\r\n * ]\r\n * ]\r\n * ]\r\n * ```\r\n *\r\n * @param multiPolygon Coordinates\r\n */\r\n set: function (multiPolygon) {\r\n if (this.setPropertyValue(\"multiPolygon\", multiPolygon)) {\r\n this.updateExtremes();\r\n this.invalidate();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * (Re)validates the polygon, effectively redrawing it.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n MapPolygon.prototype.validate = function () {\r\n if (this.series) {\r\n var projection = this.series.chart.projection;\r\n var pathGenerator = projection.d3Path;\r\n if (this.multiPolygon) {\r\n if (this.series) {\r\n var feature = { type: \"MultiPolygon\", coordinates: this.multiPolygon };\r\n projection.d3Projection.precision(this.precision);\r\n this.polygon.path = pathGenerator(feature);\r\n }\r\n if (this.series.calculateVisualCenter) {\r\n var biggestArea = 0;\r\n var biggestPolygon = this.multiPolygon[0];\r\n if (this.multiPolygon.length > 1) {\r\n for (var i = 0; i < this.multiPolygon.length; i++) {\r\n var polygon = this.multiPolygon[i];\r\n var area = d3geo.geoArea({ type: \"Polygon\", coordinates: polygon });\r\n if (area > biggestArea) {\r\n biggestPolygon = polygon;\r\n biggestArea = area;\r\n }\r\n }\r\n }\r\n var center = $polylabel(biggestPolygon);\r\n this._visualLongitude = center[0];\r\n this._visualLatitude = center[1];\r\n }\r\n else {\r\n this._visualLongitude = this.longitude;\r\n this._visualLatitude = this.latitude;\r\n }\r\n }\r\n }\r\n _super.prototype.validate.call(this);\r\n };\r\n /**\r\n * @ignore Exclude from docs\r\n */\r\n MapPolygon.prototype.measureElement = function () {\r\n // Overriding, just to avoid extra measure\r\n };\r\n Object.defineProperty(MapPolygon.prototype, \"latitude\", {\r\n /**\r\n * Latitude of the geometrical center of the polygon.\r\n *\r\n * @readonly\r\n * @return Center latitude\r\n */\r\n get: function () {\r\n return this.north + (this.south - this.north) / 2;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapPolygon.prototype, \"longitude\", {\r\n /**\r\n * Longitude of the geometrical center of the polygon.\r\n *\r\n * @readonly\r\n * @return Center longitude\r\n */\r\n get: function () {\r\n return this.east + (this.west - this.east) / 2;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapPolygon.prototype, \"visualLatitude\", {\r\n /**\r\n * @return Latitude\r\n */\r\n get: function () {\r\n var latitude = this.getPropertyValue(\"visualLatitude\");\r\n if ($type.isNumber(latitude)) {\r\n return (latitude);\r\n }\r\n if (!this._adapterO) {\r\n return this._visualLatitude;\r\n }\r\n else {\r\n return this._adapterO.apply(\"visualLatitude\", this._visualLatitude);\r\n }\r\n },\r\n /**\r\n * Latitude of the visual center of the polygon.\r\n *\r\n * It may (and probably won't) coincide with geometrical center.\r\n *\r\n * @since 4.3.0\r\n * @param value Latitude\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"visualLatitude\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapPolygon.prototype, \"visualLongitude\", {\r\n /**\r\n * @return Longitude\r\n */\r\n get: function () {\r\n var longitude = this.getPropertyValue(\"visualLongitude\");\r\n if ($type.isNumber(longitude)) {\r\n return (longitude);\r\n }\r\n if (!this._adapterO) {\r\n return this._visualLongitude;\r\n }\r\n else {\r\n return this._adapterO.apply(\"visualLongitude\", this._visualLongitude);\r\n }\r\n },\r\n /**\r\n * Longitude of the visual center of the polygon.\r\n *\r\n * It may (and probably won't) coincide with geometrical center.\r\n *\r\n * @since 4.3.0\r\n * @param value Longitude\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"visualLongitude\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapPolygon.prototype, \"pixelWidth\", {\r\n /**\r\n * Not 100% sure about this, as if we add something to MapPolygon this\r\n * won't be true, but otherwise we will get all 0 and the tooltip won't\r\n * be positioned properly\r\n * @hidden\r\n */\r\n /**\r\n * Element's width in pixels.\r\n *\r\n * @readonly\r\n * @return Width (px)\r\n */\r\n get: function () {\r\n return this.polygon.pixelWidth;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapPolygon.prototype, \"pixelHeight\", {\r\n /**\r\n * Element's height in pixels.\r\n *\r\n * @readonly\r\n * @return Width (px)\r\n */\r\n get: function () {\r\n return this.polygon.pixelHeight;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Copies all properties from another instance of [[MapPolygon]].\r\n *\r\n * @param source Source series\r\n */\r\n MapPolygon.prototype.copyFrom = function (source) {\r\n _super.prototype.copyFrom.call(this, source);\r\n this.polygon.copyFrom(source.polygon);\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapPolygon.prototype.updateExtremes = function () {\r\n _super.prototype.updateExtremes.call(this);\r\n };\r\n Object.defineProperty(MapPolygon.prototype, \"boxArea\", {\r\n /**\r\n * @ignore\r\n * used to sorth polygons from big to small\r\n */\r\n get: function () {\r\n return (this.north - this.south) * (this.east - this.west);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * X coordinate for the slice tooltip.\r\n *\r\n * @ignore\r\n * @return X\r\n */\r\n MapPolygon.prototype.getTooltipX = function () {\r\n return this.series.chart.projection.convert({ longitude: this.visualLongitude, latitude: this.visualLatitude }).x;\r\n };\r\n /**\r\n * Y coordinate for the slice tooltip.\r\n *\r\n * @ignore\r\n * @return Y\r\n */\r\n MapPolygon.prototype.getTooltipY = function () {\r\n return this.series.chart.projection.convert({ longitude: this.visualLongitude, latitude: this.visualLatitude }).y;\r\n };\r\n Object.defineProperty(MapPolygon.prototype, \"precision\", {\r\n get: function () {\r\n return this.getPropertyValue(\"precision\");\r\n },\r\n /**\r\n * When polygon's sides are plotted, they are bent according to the used\r\n * projection.\r\n *\r\n * `precision` introduces a setting which can control when such bending\r\n * occurs.\r\n *\r\n * If the distance (in degrees) between two points of polygon's side is less\r\n * than `precision`, no bending will take place and the line will be straight.\r\n *\r\n * Set to large number (e.g. 10000) for perfectly straight lines on all\r\n * polygon's sides.\r\n *\r\n * @since 4.9.1\r\n * @default 0.5\r\n * @param value Precision\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"precision\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return MapPolygon;\r\n}(MapObject));\r\nexport { MapPolygon };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"MapPolygon\"] = MapPolygon;\r\n//# sourceMappingURL=MapPolygon.js.map","/**\r\n * Map polygon series module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { MapSeries, MapSeriesDataItem } from \"./MapSeries\";\r\nimport { MapPolygon } from \"./MapPolygon\";\r\nimport { ListTemplate, ListDisposer } from \"../../core/utils/List\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport * as $mapUtils from \"./MapUtils\";\r\nimport * as $array from \"../../core/utils/Array\";\r\nimport * as $utils from \"../../core/utils/Utils\";\r\nimport * as $iter from \"../../core/utils/Iterator\";\r\nimport { Disposer } from \"../../core/utils/Disposer\";\r\n/**\r\n * ============================================================================\r\n * DATA ITEM\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines a [[DataItem]] for [[MapPolygonSeries]]\r\n * @see {@link DataItem}\r\n */\r\nvar MapPolygonSeriesDataItem = /** @class */ (function (_super) {\r\n __extends(MapPolygonSeriesDataItem, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapPolygonSeriesDataItem() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"MapPolygonSeriesDataItem\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * @ignore\r\n */\r\n MapPolygonSeriesDataItem.prototype.getFeature = function () {\r\n if (this.multiPolygon && this.multiPolygon.length > 0) {\r\n return { \"type\": \"Feature\", geometry: { type: \"MultiPolygon\", coordinates: this.multiPolygon } };\r\n }\r\n };\r\n Object.defineProperty(MapPolygonSeriesDataItem.prototype, \"mapPolygon\", {\r\n /**\r\n * A [[MapPolygon]] element related to this data item.\r\n *\r\n * @readonly\r\n * @return Element\r\n */\r\n get: function () {\r\n var _this = this;\r\n if (!this._mapPolygon) {\r\n var mapPolygon_1 = this.component.mapPolygons.create();\r\n this._mapPolygon = mapPolygon_1;\r\n this.addSprite(mapPolygon_1);\r\n this._disposers.push(new Disposer(function () {\r\n if (_this.component) {\r\n _this.component.mapPolygons.removeValue(mapPolygon_1);\r\n }\r\n }));\r\n this.mapObject = mapPolygon_1;\r\n }\r\n return this._mapPolygon;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapPolygonSeriesDataItem.prototype, \"polygon\", {\r\n /**\r\n * @return Coordinates\r\n */\r\n get: function () {\r\n return this._polygon;\r\n },\r\n /**\r\n * A collection of X/Y coordinates for a single polygon. E.g.:\r\n *\r\n * ```JSON\r\n * [\r\n * [\r\n * [ 100, 150 ],\r\n * [ 120, 200 ],\r\n * [ 150, 200 ],\r\n * [ 170, 240 ],\r\n * [ 100, 150 ]\r\n * ]\r\n * ]\r\n * ```\r\n *\r\n * @param polygon Coordinates\r\n */\r\n set: function (polygon) {\r\n this._polygon = polygon;\r\n this.multiPolygon = [polygon];\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapPolygonSeriesDataItem.prototype, \"multiPolygon\", {\r\n /**\r\n * @return Coordinates\r\n */\r\n get: function () {\r\n return this._multiPolygon;\r\n },\r\n /**\r\n * A collection of X/Y coordinates for a multi-part polygon. E.g.:\r\n *\r\n * ```JSON\r\n * [\r\n * // Part 1\r\n * [\r\n * [\r\n * [ 100, 150 ],\r\n * [ 120, 200 ],\r\n * [ 150, 220 ],\r\n * [ 170, 240 ],\r\n * [ 100, 150 ]\r\n * ]\r\n * ],\r\n *\r\n * // Part 2\r\n * [\r\n * [\r\n * [ 300, 350 ],\r\n * [ 320, 400 ],\r\n * [ 350, 420 ],\r\n * [ 370, 440 ],\r\n * [ 300, 350 ]\r\n * ]\r\n * ]\r\n * ]\r\n * ```\r\n *\r\n * @param multiPolygon Coordinates\r\n */\r\n set: function (multiPolygon) {\r\n this._multiPolygon = multiPolygon;\r\n this.updateExtremes();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapPolygonSeriesDataItem.prototype, \"geoPolygon\", {\r\n /**\r\n * @return Coordinates\r\n */\r\n get: function () {\r\n return this._geoPolygon;\r\n },\r\n /**\r\n * A collection of lat/long coordinates for a single polygon. E.g.:\r\n *\r\n * ```JSON\r\n * [\r\n * [\r\n * { latitude: -10.0, longitude: -10.0 },\r\n * { latitude: 10.0, longitude: -10.0 },\r\n * { latitude: 10.0, longitude: 10.0 },\r\n * { latitude: -10.0, longitude: -10.0 }\r\n * ]\r\n * ]\r\n * ```\r\n *\r\n * @see {@link https://tools.ietf.org/html/rfc7946#section-3.1.6} GeoJSON Polygon reference\r\n * @param geoPolygon Coordinates\r\n */\r\n set: function (geoPolygon) {\r\n this._geoPolygon = geoPolygon;\r\n this.multiGeoPolygon = [geoPolygon];\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapPolygonSeriesDataItem.prototype, \"multiGeoPolygon\", {\r\n /**\r\n * @return Coordinates\r\n */\r\n get: function () {\r\n return this._multiGeoPolygon;\r\n },\r\n /**\r\n * A collection of lat/long coordinates for a multi-part polygon. E.g.:\r\n *\r\n * ```JSON\r\n * [\r\n * [\r\n * [\r\n * { longitude: 180.0, latitude: 40.0 },\r\n * { longitude: 180.0, latitude: 50.0 },\r\n * { longitude: 170.0, latitude: 50.0 },\r\n * { longitude: 170.0, latitude: 40.0 },\r\n * { longitude: 180.0, latitude: 40.0 }\r\n * ]\r\n * ],\r\n * [\r\n * [\r\n * { longitude: -170.0, latitude: 40.0 },\r\n * { longitude: -170.0, latitude: 50.0 },\r\n * { longitude: -180.0, latitude: 50.0 },\r\n * { longitude: -180.0, latitude: 40.0 },\r\n * { longitude: -170.0, latitude: 40.0 }\r\n * ]\r\n * ]\r\n * ]\r\n * ```\r\n *\r\n * @see {@link https://tools.ietf.org/html/rfc7946#section-3.1.7} GeoJSON MultiPolygon reference\r\n * @param multiGeoPolygon Coordinates\r\n */\r\n set: function (multiGeoPolygon) {\r\n this._multiGeoPolygon = multiGeoPolygon;\r\n this.multiPolygon = $mapUtils.multiGeoPolygonToMultipolygon(multiGeoPolygon);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return MapPolygonSeriesDataItem;\r\n}(MapSeriesDataItem));\r\nexport { MapPolygonSeriesDataItem };\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A series of map polygon elements.\r\n *\r\n * @see {@link IMapPolygonSeriesEvents} for a list of available Events\r\n * @see {@link IMapPolygonSeriesAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar MapPolygonSeries = /** @class */ (function (_super) {\r\n __extends(MapPolygonSeries, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapPolygonSeries() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n /**\r\n * Indicates if series should automatically calculate visual center of the\r\n * polygons (accessible via `visualLongitude` and `visualLatitude` properties\r\n * of the [[MapPolygon]]).\r\n *\r\n * @default false\r\n * @since 4.3.0\r\n */\r\n _this.calculateVisualCenter = false;\r\n _this.className = \"MapPolygonSeries\";\r\n // Set data fields\r\n _this.dataFields.multiPolygon = \"multiPolygon\";\r\n _this.dataFields.polygon = \"polygon\";\r\n _this.dataFields.geoPolygon = \"geoPolygon\";\r\n _this.dataFields.multiGeoPolygon = \"multiGeoPolygon\";\r\n _this.setPropertyValue(\"sortPolygonsBy\", \"area\");\r\n _this.setPropertyValue(\"sortPolygonsReversed\", false);\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Returns a new/empty DataItem of the type appropriate for this object.\r\n *\r\n * @see {@link DataItem}\r\n * @return Data Item\r\n */\r\n MapPolygonSeries.prototype.createDataItem = function () {\r\n return new MapPolygonSeriesDataItem();\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapPolygonSeries.prototype.processIncExc = function () {\r\n this.mapPolygons.clear();\r\n _super.prototype.processIncExc.call(this);\r\n };\r\n /**\r\n * (Re)validates series data, effectively causing the whole series to be\r\n * redrawn.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n MapPolygonSeries.prototype.validateData = function () {\r\n // process geoJSON and created map objects\r\n if (this.useGeodata || this.geodata) {\r\n var geoJSON = !this._dataSources[\"geodata\"] ? this.chart.geodata : undefined;\r\n if (this.geodata) {\r\n geoJSON = this.geodata;\r\n }\r\n if (geoJSON) {\r\n var features = void 0;\r\n if (geoJSON.type == \"FeatureCollection\") {\r\n features = geoJSON.features;\r\n }\r\n else if (geoJSON.type == \"Feature\") {\r\n features = [geoJSON];\r\n }\r\n else if ([\"Point\", \"LineString\", \"Polygon\", \"MultiPoint\", \"MultiLineString\", \"MultiPolygon\"].indexOf(geoJSON.type) != -1) {\r\n features = [{ geometry: geoJSON }];\r\n }\r\n else {\r\n console.log(\"nothing found in geoJSON\");\r\n }\r\n if (features) {\r\n var _loop_1 = function (i, len) {\r\n var feature = features[i];\r\n var geometry = feature.geometry;\r\n if (geometry) {\r\n var type = geometry.type;\r\n var id_1 = feature.id;\r\n if (this_1.chart.geodataNames && this_1.chart.geodataNames[id_1]) {\r\n feature.properties.name = this_1.chart.geodataNames[id_1];\r\n }\r\n if (type == \"Polygon\" || type == \"MultiPolygon\") {\r\n if (!this_1.checkInclude(this_1.include, this_1.exclude, id_1)) {\r\n return \"continue\";\r\n }\r\n var coordinates = geometry.coordinates;\r\n if (coordinates) {\r\n // make the same as MultiPolygon\r\n if (type == \"Polygon\") {\r\n coordinates = [coordinates];\r\n }\r\n }\r\n // find data object in user-provided data\r\n var dataObject = $array.find(this_1.data, function (value, i) {\r\n return value.id == id_1;\r\n });\r\n // create one if not found\r\n if (!dataObject) {\r\n dataObject = { multiPolygon: coordinates, id: id_1, madeFromGeoData: true };\r\n this_1.data.push(dataObject);\r\n }\r\n // in case found\r\n else {\r\n // if user-provided object doesn't have points data provided in any way:\r\n if (!dataObject.multiPolygon) {\r\n dataObject.multiPolygon = coordinates;\r\n }\r\n }\r\n // copy properties data to datacontext\r\n $utils.softCopyProperties(feature.properties, dataObject);\r\n }\r\n }\r\n };\r\n var this_1 = this;\r\n for (var i = 0, len = features.length; i < len; i++) {\r\n _loop_1(i, len);\r\n }\r\n }\r\n }\r\n }\r\n _super.prototype.validateData.call(this);\r\n };\r\n /**\r\n * (Re)validates the series\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n MapPolygonSeries.prototype.validate = function () {\r\n _super.prototype.validate.call(this);\r\n this.dataItems.each(function (dataItem) {\r\n $utils.used(dataItem.mapPolygon);\r\n });\r\n if (this.sortPolygonsBy != \"none\") {\r\n var sortBy_1 = this.sortPolygonsBy;\r\n var reversed_1 = this.sortPolygonsReversed;\r\n this.mapPolygons.sort(function (a, b) {\r\n var valA = \"\";\r\n var valB = \"\";\r\n var dirA = -1;\r\n var dirB = 1;\r\n switch (sortBy_1) {\r\n case \"area\":\r\n valA = a.boxArea;\r\n valB = b.boxArea;\r\n dirA = -1;\r\n dirB = 1;\r\n break;\r\n case \"name\":\r\n valA = a.dataItem.dataContext.name || \"\";\r\n valB = b.dataItem.dataContext.name || \"\";\r\n dirA = 1;\r\n dirB = -1;\r\n break;\r\n case \"id\":\r\n valA = a.dataItem.dataContext.id || \"\";\r\n valB = b.dataItem.dataContext.id || \"\";\r\n dirA = 1;\r\n dirB = -1;\r\n break;\r\n case \"latitude\":\r\n valA = reversed_1 ? a.south : a.north;\r\n valB = reversed_1 ? b.south : b.north;\r\n dirA = -1;\r\n dirB = 1;\r\n break;\r\n case \"longitude\":\r\n valA = reversed_1 ? a.east : a.west;\r\n valB = reversed_1 ? b.east : b.west;\r\n dirA = 1;\r\n dirB = -1;\r\n break;\r\n }\r\n if (valA < valB) {\r\n return reversed_1 ? dirB : dirA;\r\n }\r\n if (valA > valB) {\r\n return reversed_1 ? dirA : dirB;\r\n }\r\n return 0;\r\n });\r\n this.mapPolygons.each(function (mapPolygon, index) {\r\n mapPolygon.validate();\r\n // makes small go first to avoid hover problems with IE\r\n if (!mapPolygon.zIndex && !mapPolygon.propertyFields.zIndex) {\r\n mapPolygon.zIndex = 1000000 - index;\r\n }\r\n });\r\n }\r\n };\r\n Object.defineProperty(MapPolygonSeries.prototype, \"mapPolygons\", {\r\n /**\r\n * List of polygon elements in the series.\r\n *\r\n * @return Polygon list\r\n */\r\n get: function () {\r\n if (!this._mapPolygons) {\r\n var polygonTemplate = new MapPolygon();\r\n var mapPolygons = new ListTemplate(polygonTemplate);\r\n this._disposers.push(new ListDisposer(mapPolygons));\r\n this._disposers.push(mapPolygons.template);\r\n mapPolygons.template.focusable = true;\r\n mapPolygons.events.on(\"inserted\", this.handleObjectAdded, this, false);\r\n this._mapPolygons = mapPolygons;\r\n this._mapObjects = mapPolygons;\r\n }\r\n return this._mapPolygons;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * returns MapPolygon by id in geoJSON file\r\n * @param polygon id\r\n * @return {MapPolygon}\r\n */\r\n MapPolygonSeries.prototype.getPolygonById = function (id) {\r\n return $iter.find(this.mapPolygons.iterator(), function (mapPolygon) {\r\n var dataContext = mapPolygon.dataItem.dataContext;\r\n return dataContext.id == id;\r\n });\r\n };\r\n /**\r\n * Copies all properties from another instance of [[Series]].\r\n *\r\n * @param source Source series\r\n */\r\n MapPolygonSeries.prototype.copyFrom = function (source) {\r\n this.mapPolygons.template.copyFrom(source.mapPolygons.template);\r\n _super.prototype.copyFrom.call(this, source);\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapPolygonSeries.prototype.getFeatures = function () {\r\n var _this = this;\r\n var features = [];\r\n this.dataItems.each(function (dataItem) {\r\n var feature = dataItem.getFeature();\r\n if (feature) {\r\n features.push(feature);\r\n }\r\n });\r\n this.mapPolygons.each(function (mapPolygon) {\r\n if (_this.dataItems.indexOf(mapPolygon._dataItem) == -1) {\r\n var feature = mapPolygon.getFeature();\r\n if (feature) {\r\n features.push(feature);\r\n }\r\n }\r\n });\r\n return features;\r\n };\r\n Object.defineProperty(MapPolygonSeries.prototype, \"sortPolygonsBy\", {\r\n /**\r\n * @return How to sort map polygons\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"sortPolygonsBy\");\r\n },\r\n /**\r\n * How to order polygons in actual SVG document. Affects selection order\r\n * using TAB key.\r\n *\r\n * Available options: `\"area\"` (default), `\"name\"`, `\"longitude\"`,\r\n * `\"latitude\"`, `\"id\"`, and `\"none\"`.\r\n *\r\n * @default area\r\n * @since 4.9.36\r\n * @param value How to sort map polygons\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"sortPolygonsBy\", value)) {\r\n this.invalidateData();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapPolygonSeries.prototype, \"sortPolygonsReversed\", {\r\n /**\r\n * @return Reverse polygon sort direction\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"sortPolygonsReversed\");\r\n },\r\n /**\r\n * If `sortPolygonsBy` is set to something other than `\"none\"`, polygons\r\n * will be sorted by the given parameter, using natural sort direction.\r\n *\r\n * Setting `sortPolygonsReversed = true` will reverse this direction.\r\n *\r\n * @default false\r\n * @since 4.9.36\r\n * @param value Reverse polygon sort direction\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"sortPolygonsReversed\", value)) {\r\n this.invalidateData();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return MapPolygonSeries;\r\n}(MapSeries));\r\nexport { MapPolygonSeries };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"MapPolygonSeries\"] = MapPolygonSeries;\r\nregistry.registeredClasses[\"MapPolygonSeriesDataItem\"] = MapPolygonSeriesDataItem;\r\n//# sourceMappingURL=MapPolygonSeries.js.map","import noop from \"../noop.js\";\n\nexport default function() {\n var lines = [],\n line;\n return {\n point: function(x, y, m) {\n line.push([x, y, m]);\n },\n lineStart: function() {\n lines.push(line = []);\n },\n lineEnd: noop,\n rejoin: function() {\n if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));\n },\n result: function() {\n var result = lines;\n lines = [];\n line = null;\n return result;\n }\n };\n}\n","import {abs, epsilon} from \"./math.js\";\n\nexport default function(a, b) {\n return abs(a[0] - b[0]) < epsilon && abs(a[1] - b[1]) < epsilon;\n}\n","import pointEqual from \"../pointEqual.js\";\nimport {epsilon} from \"../math.js\";\n\nfunction Intersection(point, points, other, entry) {\n this.x = point;\n this.z = points;\n this.o = other; // another intersection\n this.e = entry; // is an entry?\n this.v = false; // visited\n this.n = this.p = null; // next & previous\n}\n\n// A generalized polygon clipping algorithm: given a polygon that has been cut\n// into its visible line segments, and rejoins the segments by interpolating\n// along the clip edge.\nexport default function(segments, compareIntersection, startInside, interpolate, stream) {\n var subject = [],\n clip = [],\n i,\n n;\n\n segments.forEach(function(segment) {\n if ((n = segment.length - 1) <= 0) return;\n var n, p0 = segment[0], p1 = segment[n], x;\n\n if (pointEqual(p0, p1)) {\n if (!p0[2] && !p1[2]) {\n stream.lineStart();\n for (i = 0; i < n; ++i) stream.point((p0 = segment[i])[0], p0[1]);\n stream.lineEnd();\n return;\n }\n // handle degenerate cases by moving the point\n p1[0] += 2 * epsilon;\n }\n\n subject.push(x = new Intersection(p0, segment, null, true));\n clip.push(x.o = new Intersection(p0, null, x, false));\n subject.push(x = new Intersection(p1, segment, null, false));\n clip.push(x.o = new Intersection(p1, null, x, true));\n });\n\n if (!subject.length) return;\n\n clip.sort(compareIntersection);\n link(subject);\n link(clip);\n\n for (i = 0, n = clip.length; i < n; ++i) {\n clip[i].e = startInside = !startInside;\n }\n\n var start = subject[0],\n points,\n point;\n\n while (1) {\n // Find first unvisited intersection.\n var current = start,\n isSubject = true;\n while (current.v) if ((current = current.n) === start) return;\n points = current.z;\n stream.lineStart();\n do {\n current.v = current.o.v = true;\n if (current.e) {\n if (isSubject) {\n for (i = 0, n = points.length; i < n; ++i) stream.point((point = points[i])[0], point[1]);\n } else {\n interpolate(current.x, current.n.x, 1, stream);\n }\n current = current.n;\n } else {\n if (isSubject) {\n points = current.p.z;\n for (i = points.length - 1; i >= 0; --i) stream.point((point = points[i])[0], point[1]);\n } else {\n interpolate(current.x, current.p.x, -1, stream);\n }\n current = current.p;\n }\n current = current.o;\n points = current.z;\n isSubject = !isSubject;\n } while (!current.v);\n stream.lineEnd();\n }\n}\n\nfunction link(array) {\n if (!(n = array.length)) return;\n var n,\n i = 0,\n a = array[0],\n b;\n while (++i < n) {\n a.n = b = array[i];\n b.p = a;\n a = b;\n }\n a.n = b = array[0];\n b.p = a;\n}\n","import {Adder} from \"d3-array\";\nimport {cartesian, cartesianCross, cartesianNormalizeInPlace} from \"./cartesian.js\";\nimport {abs, asin, atan2, cos, epsilon, epsilon2, halfPi, pi, quarterPi, sign, sin, tau} from \"./math.js\";\n\nfunction longitude(point) {\n return abs(point[0]) <= pi ? point[0] : sign(point[0]) * ((abs(point[0]) + pi) % tau - pi);\n}\n\nexport default function(polygon, point) {\n var lambda = longitude(point),\n phi = point[1],\n sinPhi = sin(phi),\n normal = [sin(lambda), -cos(lambda), 0],\n angle = 0,\n winding = 0;\n\n var sum = new Adder();\n\n if (sinPhi === 1) phi = halfPi + epsilon;\n else if (sinPhi === -1) phi = -halfPi - epsilon;\n\n for (var i = 0, n = polygon.length; i < n; ++i) {\n if (!(m = (ring = polygon[i]).length)) continue;\n var ring,\n m,\n point0 = ring[m - 1],\n lambda0 = longitude(point0),\n phi0 = point0[1] / 2 + quarterPi,\n sinPhi0 = sin(phi0),\n cosPhi0 = cos(phi0);\n\n for (var j = 0; j < m; ++j, lambda0 = lambda1, sinPhi0 = sinPhi1, cosPhi0 = cosPhi1, point0 = point1) {\n var point1 = ring[j],\n lambda1 = longitude(point1),\n phi1 = point1[1] / 2 + quarterPi,\n sinPhi1 = sin(phi1),\n cosPhi1 = cos(phi1),\n delta = lambda1 - lambda0,\n sign = delta >= 0 ? 1 : -1,\n absDelta = sign * delta,\n antimeridian = absDelta > pi,\n k = sinPhi0 * sinPhi1;\n\n sum.add(atan2(k * sign * sin(absDelta), cosPhi0 * cosPhi1 + k * cos(absDelta)));\n angle += antimeridian ? delta + sign * tau : delta;\n\n // Are the longitudes either side of the point’s meridian (lambda),\n // and are the latitudes smaller than the parallel (phi)?\n if (antimeridian ^ lambda0 >= lambda ^ lambda1 >= lambda) {\n var arc = cartesianCross(cartesian(point0), cartesian(point1));\n cartesianNormalizeInPlace(arc);\n var intersection = cartesianCross(normal, arc);\n cartesianNormalizeInPlace(intersection);\n var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin(intersection[2]);\n if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) {\n winding += antimeridian ^ delta >= 0 ? 1 : -1;\n }\n }\n }\n }\n\n // First, determine whether the South pole is inside or outside:\n //\n // It is inside if:\n // * the polygon winds around it in a clockwise direction.\n // * the polygon does not (cumulatively) wind around it, but has a negative\n // (counter-clockwise) area.\n //\n // Second, count the (signed) number of times a segment crosses a lambda\n // from the point to the South pole. If it is zero, then the point is the\n // same side as the South pole.\n\n return (angle < -epsilon || angle < epsilon && sum < -epsilon2) ^ (winding & 1);\n}\n","function* flatten(arrays) {\n for (const array of arrays) {\n yield* array;\n }\n}\n\nexport default function merge(arrays) {\n return Array.from(flatten(arrays));\n}\n","import clipBuffer from \"./buffer.js\";\nimport clipRejoin from \"./rejoin.js\";\nimport {epsilon, halfPi} from \"../math.js\";\nimport polygonContains from \"../polygonContains.js\";\nimport {merge} from \"d3-array\";\n\nexport default function(pointVisible, clipLine, interpolate, start) {\n return function(sink) {\n var line = clipLine(sink),\n ringBuffer = clipBuffer(),\n ringSink = clipLine(ringBuffer),\n polygonStarted = false,\n polygon,\n segments,\n ring;\n\n var clip = {\n point: point,\n lineStart: lineStart,\n lineEnd: lineEnd,\n polygonStart: function() {\n clip.point = pointRing;\n clip.lineStart = ringStart;\n clip.lineEnd = ringEnd;\n segments = [];\n polygon = [];\n },\n polygonEnd: function() {\n clip.point = point;\n clip.lineStart = lineStart;\n clip.lineEnd = lineEnd;\n segments = merge(segments);\n var startInside = polygonContains(polygon, start);\n if (segments.length) {\n if (!polygonStarted) sink.polygonStart(), polygonStarted = true;\n clipRejoin(segments, compareIntersection, startInside, interpolate, sink);\n } else if (startInside) {\n if (!polygonStarted) sink.polygonStart(), polygonStarted = true;\n sink.lineStart();\n interpolate(null, null, 1, sink);\n sink.lineEnd();\n }\n if (polygonStarted) sink.polygonEnd(), polygonStarted = false;\n segments = polygon = null;\n },\n sphere: function() {\n sink.polygonStart();\n sink.lineStart();\n interpolate(null, null, 1, sink);\n sink.lineEnd();\n sink.polygonEnd();\n }\n };\n\n function point(lambda, phi) {\n if (pointVisible(lambda, phi)) sink.point(lambda, phi);\n }\n\n function pointLine(lambda, phi) {\n line.point(lambda, phi);\n }\n\n function lineStart() {\n clip.point = pointLine;\n line.lineStart();\n }\n\n function lineEnd() {\n clip.point = point;\n line.lineEnd();\n }\n\n function pointRing(lambda, phi) {\n ring.push([lambda, phi]);\n ringSink.point(lambda, phi);\n }\n\n function ringStart() {\n ringSink.lineStart();\n ring = [];\n }\n\n function ringEnd() {\n pointRing(ring[0][0], ring[0][1]);\n ringSink.lineEnd();\n\n var clean = ringSink.clean(),\n ringSegments = ringBuffer.result(),\n i, n = ringSegments.length, m,\n segment,\n point;\n\n ring.pop();\n polygon.push(ring);\n ring = null;\n\n if (!n) return;\n\n // No intersections.\n if (clean & 1) {\n segment = ringSegments[0];\n if ((m = segment.length - 1) > 0) {\n if (!polygonStarted) sink.polygonStart(), polygonStarted = true;\n sink.lineStart();\n for (i = 0; i < m; ++i) sink.point((point = segment[i])[0], point[1]);\n sink.lineEnd();\n }\n return;\n }\n\n // Rejoin connected segments.\n // TODO reuse ringBuffer.rejoin()?\n if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));\n\n segments.push(ringSegments.filter(validSegment));\n }\n\n return clip;\n };\n}\n\nfunction validSegment(segment) {\n return segment.length > 1;\n}\n\n// Intersections are sorted along the clip edge. For both antimeridian cutting\n// and circle clipping, the same comparison is used.\nfunction compareIntersection(a, b) {\n return ((a = a.x)[0] < 0 ? a[1] - halfPi - epsilon : halfPi - a[1])\n - ((b = b.x)[0] < 0 ? b[1] - halfPi - epsilon : halfPi - b[1]);\n}\n","import clip from \"./index.js\";\nimport {abs, atan, cos, epsilon, halfPi, pi, sin} from \"../math.js\";\n\nexport default clip(\n function() { return true; },\n clipAntimeridianLine,\n clipAntimeridianInterpolate,\n [-pi, -halfPi]\n);\n\n// Takes a line and cuts into visible segments. Return values: 0 - there were\n// intersections or the line was empty; 1 - no intersections; 2 - there were\n// intersections, and the first and last segments should be rejoined.\nfunction clipAntimeridianLine(stream) {\n var lambda0 = NaN,\n phi0 = NaN,\n sign0 = NaN,\n clean; // no intersections\n\n return {\n lineStart: function() {\n stream.lineStart();\n clean = 1;\n },\n point: function(lambda1, phi1) {\n var sign1 = lambda1 > 0 ? pi : -pi,\n delta = abs(lambda1 - lambda0);\n if (abs(delta - pi) < epsilon) { // line crosses a pole\n stream.point(lambda0, phi0 = (phi0 + phi1) / 2 > 0 ? halfPi : -halfPi);\n stream.point(sign0, phi0);\n stream.lineEnd();\n stream.lineStart();\n stream.point(sign1, phi0);\n stream.point(lambda1, phi0);\n clean = 0;\n } else if (sign0 !== sign1 && delta >= pi) { // line crosses antimeridian\n if (abs(lambda0 - sign0) < epsilon) lambda0 -= sign0 * epsilon; // handle degeneracies\n if (abs(lambda1 - sign1) < epsilon) lambda1 -= sign1 * epsilon;\n phi0 = clipAntimeridianIntersect(lambda0, phi0, lambda1, phi1);\n stream.point(sign0, phi0);\n stream.lineEnd();\n stream.lineStart();\n stream.point(sign1, phi0);\n clean = 0;\n }\n stream.point(lambda0 = lambda1, phi0 = phi1);\n sign0 = sign1;\n },\n lineEnd: function() {\n stream.lineEnd();\n lambda0 = phi0 = NaN;\n },\n clean: function() {\n return 2 - clean; // if intersections, rejoin first and last segments\n }\n };\n}\n\nfunction clipAntimeridianIntersect(lambda0, phi0, lambda1, phi1) {\n var cosPhi0,\n cosPhi1,\n sinLambda0Lambda1 = sin(lambda0 - lambda1);\n return abs(sinLambda0Lambda1) > epsilon\n ? atan((sin(phi0) * (cosPhi1 = cos(phi1)) * sin(lambda1)\n - sin(phi1) * (cosPhi0 = cos(phi0)) * sin(lambda0))\n / (cosPhi0 * cosPhi1 * sinLambda0Lambda1))\n : (phi0 + phi1) / 2;\n}\n\nfunction clipAntimeridianInterpolate(from, to, direction, stream) {\n var phi;\n if (from == null) {\n phi = direction * halfPi;\n stream.point(-pi, phi);\n stream.point(0, phi);\n stream.point(pi, phi);\n stream.point(pi, 0);\n stream.point(pi, -phi);\n stream.point(0, -phi);\n stream.point(-pi, -phi);\n stream.point(-pi, 0);\n stream.point(-pi, phi);\n } else if (abs(from[0] - to[0]) > epsilon) {\n var lambda = from[0] < to[0] ? pi : -pi;\n phi = direction * lambda / 2;\n stream.point(-lambda, phi);\n stream.point(0, phi);\n stream.point(lambda, phi);\n } else {\n stream.point(to[0], to[1]);\n }\n}\n","import {cartesian, cartesianNormalizeInPlace, spherical} from \"./cartesian.js\";\nimport constant from \"./constant.js\";\nimport {acos, cos, degrees, epsilon, radians, sin, tau} from \"./math.js\";\nimport {rotateRadians} from \"./rotation.js\";\n\n// Generates a circle centered at [0°, 0°], with a given radius and precision.\nexport function circleStream(stream, radius, delta, direction, t0, t1) {\n if (!delta) return;\n var cosRadius = cos(radius),\n sinRadius = sin(radius),\n step = direction * delta;\n if (t0 == null) {\n t0 = radius + direction * tau;\n t1 = radius - step / 2;\n } else {\n t0 = circleRadius(cosRadius, t0);\n t1 = circleRadius(cosRadius, t1);\n if (direction > 0 ? t0 < t1 : t0 > t1) t0 += direction * tau;\n }\n for (var point, t = t0; direction > 0 ? t > t1 : t < t1; t -= step) {\n point = spherical([cosRadius, -sinRadius * cos(t), -sinRadius * sin(t)]);\n stream.point(point[0], point[1]);\n }\n}\n\n// Returns the signed angle of a cartesian point relative to [cosRadius, 0, 0].\nfunction circleRadius(cosRadius, point) {\n point = cartesian(point), point[0] -= cosRadius;\n cartesianNormalizeInPlace(point);\n var radius = acos(-point[1]);\n return ((-point[2] < 0 ? -radius : radius) + tau - epsilon) % tau;\n}\n\nexport default function() {\n var center = constant([0, 0]),\n radius = constant(90),\n precision = constant(2),\n ring,\n rotate,\n stream = {point: point};\n\n function point(x, y) {\n ring.push(x = rotate(x, y));\n x[0] *= degrees, x[1] *= degrees;\n }\n\n function circle() {\n var c = center.apply(this, arguments),\n r = radius.apply(this, arguments) * radians,\n p = precision.apply(this, arguments) * radians;\n ring = [];\n rotate = rotateRadians(-c[0] * radians, -c[1] * radians, 0).invert;\n circleStream(stream, r, p, 1);\n c = {type: \"Polygon\", coordinates: [ring]};\n ring = rotate = null;\n return c;\n }\n\n circle.center = function(_) {\n return arguments.length ? (center = typeof _ === \"function\" ? _ : constant([+_[0], +_[1]]), circle) : center;\n };\n\n circle.radius = function(_) {\n return arguments.length ? (radius = typeof _ === \"function\" ? _ : constant(+_), circle) : radius;\n };\n\n circle.precision = function(_) {\n return arguments.length ? (precision = typeof _ === \"function\" ? _ : constant(+_), circle) : precision;\n };\n\n return circle;\n}\n","import {cartesian, cartesianAddInPlace, cartesianCross, cartesianDot, cartesianScale, spherical} from \"../cartesian.js\";\nimport {circleStream} from \"../circle.js\";\nimport {abs, cos, epsilon, pi, radians, sqrt} from \"../math.js\";\nimport pointEqual from \"../pointEqual.js\";\nimport clip from \"./index.js\";\n\nexport default function(radius) {\n var cr = cos(radius),\n delta = 2 * radians,\n smallRadius = cr > 0,\n notHemisphere = abs(cr) > epsilon; // TODO optimise for this common case\n\n function interpolate(from, to, direction, stream) {\n circleStream(stream, radius, delta, direction, from, to);\n }\n\n function visible(lambda, phi) {\n return cos(lambda) * cos(phi) > cr;\n }\n\n // Takes a line and cuts into visible segments. Return values used for polygon\n // clipping: 0 - there were intersections or the line was empty; 1 - no\n // intersections 2 - there were intersections, and the first and last segments\n // should be rejoined.\n function clipLine(stream) {\n var point0, // previous point\n c0, // code for previous point\n v0, // visibility of previous point\n v00, // visibility of first point\n clean; // no intersections\n return {\n lineStart: function() {\n v00 = v0 = false;\n clean = 1;\n },\n point: function(lambda, phi) {\n var point1 = [lambda, phi],\n point2,\n v = visible(lambda, phi),\n c = smallRadius\n ? v ? 0 : code(lambda, phi)\n : v ? code(lambda + (lambda < 0 ? pi : -pi), phi) : 0;\n if (!point0 && (v00 = v0 = v)) stream.lineStart();\n if (v !== v0) {\n point2 = intersect(point0, point1);\n if (!point2 || pointEqual(point0, point2) || pointEqual(point1, point2))\n point1[2] = 1;\n }\n if (v !== v0) {\n clean = 0;\n if (v) {\n // outside going in\n stream.lineStart();\n point2 = intersect(point1, point0);\n stream.point(point2[0], point2[1]);\n } else {\n // inside going out\n point2 = intersect(point0, point1);\n stream.point(point2[0], point2[1], 2);\n stream.lineEnd();\n }\n point0 = point2;\n } else if (notHemisphere && point0 && smallRadius ^ v) {\n var t;\n // If the codes for two points are different, or are both zero,\n // and there this segment intersects with the small circle.\n if (!(c & c0) && (t = intersect(point1, point0, true))) {\n clean = 0;\n if (smallRadius) {\n stream.lineStart();\n stream.point(t[0][0], t[0][1]);\n stream.point(t[1][0], t[1][1]);\n stream.lineEnd();\n } else {\n stream.point(t[1][0], t[1][1]);\n stream.lineEnd();\n stream.lineStart();\n stream.point(t[0][0], t[0][1], 3);\n }\n }\n }\n if (v && (!point0 || !pointEqual(point0, point1))) {\n stream.point(point1[0], point1[1]);\n }\n point0 = point1, v0 = v, c0 = c;\n },\n lineEnd: function() {\n if (v0) stream.lineEnd();\n point0 = null;\n },\n // Rejoin first and last segments if there were intersections and the first\n // and last points were visible.\n clean: function() {\n return clean | ((v00 && v0) << 1);\n }\n };\n }\n\n // Intersects the great circle between a and b with the clip circle.\n function intersect(a, b, two) {\n var pa = cartesian(a),\n pb = cartesian(b);\n\n // We have two planes, n1.p = d1 and n2.p = d2.\n // Find intersection line p(t) = c1 n1 + c2 n2 + t (n1 ⨯ n2).\n var n1 = [1, 0, 0], // normal\n n2 = cartesianCross(pa, pb),\n n2n2 = cartesianDot(n2, n2),\n n1n2 = n2[0], // cartesianDot(n1, n2),\n determinant = n2n2 - n1n2 * n1n2;\n\n // Two polar points.\n if (!determinant) return !two && a;\n\n var c1 = cr * n2n2 / determinant,\n c2 = -cr * n1n2 / determinant,\n n1xn2 = cartesianCross(n1, n2),\n A = cartesianScale(n1, c1),\n B = cartesianScale(n2, c2);\n cartesianAddInPlace(A, B);\n\n // Solve |p(t)|^2 = 1.\n var u = n1xn2,\n w = cartesianDot(A, u),\n uu = cartesianDot(u, u),\n t2 = w * w - uu * (cartesianDot(A, A) - 1);\n\n if (t2 < 0) return;\n\n var t = sqrt(t2),\n q = cartesianScale(u, (-w - t) / uu);\n cartesianAddInPlace(q, A);\n q = spherical(q);\n\n if (!two) return q;\n\n // Two intersection points.\n var lambda0 = a[0],\n lambda1 = b[0],\n phi0 = a[1],\n phi1 = b[1],\n z;\n\n if (lambda1 < lambda0) z = lambda0, lambda0 = lambda1, lambda1 = z;\n\n var delta = lambda1 - lambda0,\n polar = abs(delta - pi) < epsilon,\n meridian = polar || delta < epsilon;\n\n if (!polar && phi1 < phi0) z = phi0, phi0 = phi1, phi1 = z;\n\n // Check that the first point is between a and b.\n if (meridian\n ? polar\n ? phi0 + phi1 > 0 ^ q[1] < (abs(q[0] - lambda0) < epsilon ? phi0 : phi1)\n : phi0 <= q[1] && q[1] <= phi1\n : delta > pi ^ (lambda0 <= q[0] && q[0] <= lambda1)) {\n var q1 = cartesianScale(u, (-w + t) / uu);\n cartesianAddInPlace(q1, A);\n return [q, spherical(q1)];\n }\n }\n\n // Generates a 4-bit vector representing the location of a point relative to\n // the small circle's bounding box.\n function code(lambda, phi) {\n var r = smallRadius ? radius : pi - radius,\n code = 0;\n if (lambda < -r) code |= 1; // left\n else if (lambda > r) code |= 2; // right\n if (phi < -r) code |= 4; // below\n else if (phi > r) code |= 8; // above\n return code;\n }\n\n return clip(visible, clipLine, interpolate, smallRadius ? [0, -radius] : [-pi, radius - pi]);\n}\n","import {abs, epsilon} from \"../math.js\";\nimport clipBuffer from \"./buffer.js\";\nimport clipLine from \"./line.js\";\nimport clipRejoin from \"./rejoin.js\";\nimport {merge} from \"d3-array\";\n\nvar clipMax = 1e9, clipMin = -clipMax;\n\n// TODO Use d3-polygon’s polygonContains here for the ring check?\n// TODO Eliminate duplicate buffering in clipBuffer and polygon.push?\n\nexport default function clipRectangle(x0, y0, x1, y1) {\n\n function visible(x, y) {\n return x0 <= x && x <= x1 && y0 <= y && y <= y1;\n }\n\n function interpolate(from, to, direction, stream) {\n var a = 0, a1 = 0;\n if (from == null\n || (a = corner(from, direction)) !== (a1 = corner(to, direction))\n || comparePoint(from, to) < 0 ^ direction > 0) {\n do stream.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0);\n while ((a = (a + direction + 4) % 4) !== a1);\n } else {\n stream.point(to[0], to[1]);\n }\n }\n\n function corner(p, direction) {\n return abs(p[0] - x0) < epsilon ? direction > 0 ? 0 : 3\n : abs(p[0] - x1) < epsilon ? direction > 0 ? 2 : 1\n : abs(p[1] - y0) < epsilon ? direction > 0 ? 1 : 0\n : direction > 0 ? 3 : 2; // abs(p[1] - y1) < epsilon\n }\n\n function compareIntersection(a, b) {\n return comparePoint(a.x, b.x);\n }\n\n function comparePoint(a, b) {\n var ca = corner(a, 1),\n cb = corner(b, 1);\n return ca !== cb ? ca - cb\n : ca === 0 ? b[1] - a[1]\n : ca === 1 ? a[0] - b[0]\n : ca === 2 ? a[1] - b[1]\n : b[0] - a[0];\n }\n\n return function(stream) {\n var activeStream = stream,\n bufferStream = clipBuffer(),\n segments,\n polygon,\n ring,\n x__, y__, v__, // first point\n x_, y_, v_, // previous point\n first,\n clean;\n\n var clipStream = {\n point: point,\n lineStart: lineStart,\n lineEnd: lineEnd,\n polygonStart: polygonStart,\n polygonEnd: polygonEnd\n };\n\n function point(x, y) {\n if (visible(x, y)) activeStream.point(x, y);\n }\n\n function polygonInside() {\n var winding = 0;\n\n for (var i = 0, n = polygon.length; i < n; ++i) {\n for (var ring = polygon[i], j = 1, m = ring.length, point = ring[0], a0, a1, b0 = point[0], b1 = point[1]; j < m; ++j) {\n a0 = b0, a1 = b1, point = ring[j], b0 = point[0], b1 = point[1];\n if (a1 <= y1) { if (b1 > y1 && (b0 - a0) * (y1 - a1) > (b1 - a1) * (x0 - a0)) ++winding; }\n else { if (b1 <= y1 && (b0 - a0) * (y1 - a1) < (b1 - a1) * (x0 - a0)) --winding; }\n }\n }\n\n return winding;\n }\n\n // Buffer geometry within a polygon and then clip it en masse.\n function polygonStart() {\n activeStream = bufferStream, segments = [], polygon = [], clean = true;\n }\n\n function polygonEnd() {\n var startInside = polygonInside(),\n cleanInside = clean && startInside,\n visible = (segments = merge(segments)).length;\n if (cleanInside || visible) {\n stream.polygonStart();\n if (cleanInside) {\n stream.lineStart();\n interpolate(null, null, 1, stream);\n stream.lineEnd();\n }\n if (visible) {\n clipRejoin(segments, compareIntersection, startInside, interpolate, stream);\n }\n stream.polygonEnd();\n }\n activeStream = stream, segments = polygon = ring = null;\n }\n\n function lineStart() {\n clipStream.point = linePoint;\n if (polygon) polygon.push(ring = []);\n first = true;\n v_ = false;\n x_ = y_ = NaN;\n }\n\n // TODO rather than special-case polygons, simply handle them separately.\n // Ideally, coincident intersection points should be jittered to avoid\n // clipping issues.\n function lineEnd() {\n if (segments) {\n linePoint(x__, y__);\n if (v__ && v_) bufferStream.rejoin();\n segments.push(bufferStream.result());\n }\n clipStream.point = point;\n if (v_) activeStream.lineEnd();\n }\n\n function linePoint(x, y) {\n var v = visible(x, y);\n if (polygon) ring.push([x, y]);\n if (first) {\n x__ = x, y__ = y, v__ = v;\n first = false;\n if (v) {\n activeStream.lineStart();\n activeStream.point(x, y);\n }\n } else {\n if (v && v_) activeStream.point(x, y);\n else {\n var a = [x_ = Math.max(clipMin, Math.min(clipMax, x_)), y_ = Math.max(clipMin, Math.min(clipMax, y_))],\n b = [x = Math.max(clipMin, Math.min(clipMax, x)), y = Math.max(clipMin, Math.min(clipMax, y))];\n if (clipLine(a, b, x0, y0, x1, y1)) {\n if (!v_) {\n activeStream.lineStart();\n activeStream.point(a[0], a[1]);\n }\n activeStream.point(b[0], b[1]);\n if (!v) activeStream.lineEnd();\n clean = false;\n } else if (v) {\n activeStream.lineStart();\n activeStream.point(x, y);\n clean = false;\n }\n }\n }\n x_ = x, y_ = y, v_ = v;\n }\n\n return clipStream;\n };\n}\n","export default function(a, b, x0, y0, x1, y1) {\n var ax = a[0],\n ay = a[1],\n bx = b[0],\n by = b[1],\n t0 = 0,\n t1 = 1,\n dx = bx - ax,\n dy = by - ay,\n r;\n\n r = x0 - ax;\n if (!dx && r > 0) return;\n r /= dx;\n if (dx < 0) {\n if (r < t0) return;\n if (r < t1) t1 = r;\n } else if (dx > 0) {\n if (r > t1) return;\n if (r > t0) t0 = r;\n }\n\n r = x1 - ax;\n if (!dx && r < 0) return;\n r /= dx;\n if (dx < 0) {\n if (r > t1) return;\n if (r > t0) t0 = r;\n } else if (dx > 0) {\n if (r < t0) return;\n if (r < t1) t1 = r;\n }\n\n r = y0 - ay;\n if (!dy && r > 0) return;\n r /= dy;\n if (dy < 0) {\n if (r < t0) return;\n if (r < t1) t1 = r;\n } else if (dy > 0) {\n if (r > t1) return;\n if (r > t0) t0 = r;\n }\n\n r = y1 - ay;\n if (!dy && r < 0) return;\n r /= dy;\n if (dy < 0) {\n if (r > t1) return;\n if (r > t0) t0 = r;\n } else if (dy > 0) {\n if (r < t0) return;\n if (r < t1) t1 = r;\n }\n\n if (t0 > 0) a[0] = ax + t0 * dx, a[1] = ay + t0 * dy;\n if (t1 < 1) b[0] = ax + t1 * dx, b[1] = ay + t1 * dy;\n return true;\n}\n","export default function(a, b) {\n\n function compose(x, y) {\n return x = a(x, y), b(x[0], x[1]);\n }\n\n if (a.invert && b.invert) compose.invert = function(x, y) {\n return x = b.invert(x, y), x && a.invert(x[0], x[1]);\n };\n\n return compose;\n}\n","export default x => x;\n","import compose from \"./compose.js\";\nimport {abs, asin, atan2, cos, degrees, pi, radians, sin, tau} from \"./math.js\";\n\nfunction rotationIdentity(lambda, phi) {\n if (abs(lambda) > pi) lambda -= Math.round(lambda / tau) * tau;\n return [lambda, phi];\n}\n\nrotationIdentity.invert = rotationIdentity;\n\nexport function rotateRadians(deltaLambda, deltaPhi, deltaGamma) {\n return (deltaLambda %= tau) ? (deltaPhi || deltaGamma ? compose(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma))\n : rotationLambda(deltaLambda))\n : (deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma)\n : rotationIdentity);\n}\n\nfunction forwardRotationLambda(deltaLambda) {\n return function(lambda, phi) {\n lambda += deltaLambda;\n if (abs(lambda) > pi) lambda -= Math.round(lambda / tau) * tau;\n return [lambda, phi];\n };\n}\n\nfunction rotationLambda(deltaLambda) {\n var rotation = forwardRotationLambda(deltaLambda);\n rotation.invert = forwardRotationLambda(-deltaLambda);\n return rotation;\n}\n\nfunction rotationPhiGamma(deltaPhi, deltaGamma) {\n var cosDeltaPhi = cos(deltaPhi),\n sinDeltaPhi = sin(deltaPhi),\n cosDeltaGamma = cos(deltaGamma),\n sinDeltaGamma = sin(deltaGamma);\n\n function rotation(lambda, phi) {\n var cosPhi = cos(phi),\n x = cos(lambda) * cosPhi,\n y = sin(lambda) * cosPhi,\n z = sin(phi),\n k = z * cosDeltaPhi + x * sinDeltaPhi;\n return [\n atan2(y * cosDeltaGamma - k * sinDeltaGamma, x * cosDeltaPhi - z * sinDeltaPhi),\n asin(k * cosDeltaGamma + y * sinDeltaGamma)\n ];\n }\n\n rotation.invert = function(lambda, phi) {\n var cosPhi = cos(phi),\n x = cos(lambda) * cosPhi,\n y = sin(lambda) * cosPhi,\n z = sin(phi),\n k = z * cosDeltaGamma - y * sinDeltaGamma;\n return [\n atan2(y * cosDeltaGamma + z * sinDeltaGamma, x * cosDeltaPhi + k * sinDeltaPhi),\n asin(k * cosDeltaPhi - x * sinDeltaPhi)\n ];\n };\n\n return rotation;\n}\n\nexport default function(rotate) {\n rotate = rotateRadians(rotate[0] * radians, rotate[1] * radians, rotate.length > 2 ? rotate[2] * radians : 0);\n\n function forward(coordinates) {\n coordinates = rotate(coordinates[0] * radians, coordinates[1] * radians);\n return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates;\n }\n\n forward.invert = function(coordinates) {\n coordinates = rotate.invert(coordinates[0] * radians, coordinates[1] * radians);\n return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates;\n };\n\n return forward;\n}\n","export default function(methods) {\n return {\n stream: transformer(methods)\n };\n}\n\nexport function transformer(methods) {\n return function(stream) {\n var s = new TransformStream;\n for (var key in methods) s[key] = methods[key];\n s.stream = stream;\n return s;\n };\n}\n\nfunction TransformStream() {}\n\nTransformStream.prototype = {\n constructor: TransformStream,\n point: function(x, y) { this.stream.point(x, y); },\n sphere: function() { this.stream.sphere(); },\n lineStart: function() { this.stream.lineStart(); },\n lineEnd: function() { this.stream.lineEnd(); },\n polygonStart: function() { this.stream.polygonStart(); },\n polygonEnd: function() { this.stream.polygonEnd(); }\n};\n","import noop from \"../noop.js\";\n\nvar x0 = Infinity,\n y0 = x0,\n x1 = -x0,\n y1 = x1;\n\nvar boundsStream = {\n point: boundsPoint,\n lineStart: noop,\n lineEnd: noop,\n polygonStart: noop,\n polygonEnd: noop,\n result: function() {\n var bounds = [[x0, y0], [x1, y1]];\n x1 = y1 = -(y0 = x0 = Infinity);\n return bounds;\n }\n};\n\nfunction boundsPoint(x, y) {\n if (x < x0) x0 = x;\n if (x > x1) x1 = x;\n if (y < y0) y0 = y;\n if (y > y1) y1 = y;\n}\n\nexport default boundsStream;\n","import {default as geoStream} from \"../stream.js\";\nimport boundsStream from \"../path/bounds.js\";\n\nfunction fit(projection, fitBounds, object) {\n var clip = projection.clipExtent && projection.clipExtent();\n projection.scale(150).translate([0, 0]);\n if (clip != null) projection.clipExtent(null);\n geoStream(object, projection.stream(boundsStream));\n fitBounds(boundsStream.result());\n if (clip != null) projection.clipExtent(clip);\n return projection;\n}\n\nexport function fitExtent(projection, extent, object) {\n return fit(projection, function(b) {\n var w = extent[1][0] - extent[0][0],\n h = extent[1][1] - extent[0][1],\n k = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])),\n x = +extent[0][0] + (w - k * (b[1][0] + b[0][0])) / 2,\n y = +extent[0][1] + (h - k * (b[1][1] + b[0][1])) / 2;\n projection.scale(150 * k).translate([x, y]);\n }, object);\n}\n\nexport function fitSize(projection, size, object) {\n return fitExtent(projection, [[0, 0], size], object);\n}\n\nexport function fitWidth(projection, width, object) {\n return fit(projection, function(b) {\n var w = +width,\n k = w / (b[1][0] - b[0][0]),\n x = (w - k * (b[1][0] + b[0][0])) / 2,\n y = -k * b[0][1];\n projection.scale(150 * k).translate([x, y]);\n }, object);\n}\n\nexport function fitHeight(projection, height, object) {\n return fit(projection, function(b) {\n var h = +height,\n k = h / (b[1][1] - b[0][1]),\n x = -k * b[0][0],\n y = (h - k * (b[1][1] + b[0][1])) / 2;\n projection.scale(150 * k).translate([x, y]);\n }, object);\n}\n","import {cartesian} from \"../cartesian.js\";\nimport {abs, asin, atan2, cos, epsilon, radians, sqrt} from \"../math.js\";\nimport {transformer} from \"../transform.js\";\n\nvar maxDepth = 16, // maximum depth of subdivision\n cosMinDistance = cos(30 * radians); // cos(minimum angular distance)\n\nexport default function(project, delta2) {\n return +delta2 ? resample(project, delta2) : resampleNone(project);\n}\n\nfunction resampleNone(project) {\n return transformer({\n point: function(x, y) {\n x = project(x, y);\n this.stream.point(x[0], x[1]);\n }\n });\n}\n\nfunction resample(project, delta2) {\n\n function resampleLineTo(x0, y0, lambda0, a0, b0, c0, x1, y1, lambda1, a1, b1, c1, depth, stream) {\n var dx = x1 - x0,\n dy = y1 - y0,\n d2 = dx * dx + dy * dy;\n if (d2 > 4 * delta2 && depth--) {\n var a = a0 + a1,\n b = b0 + b1,\n c = c0 + c1,\n m = sqrt(a * a + b * b + c * c),\n phi2 = asin(c /= m),\n lambda2 = abs(abs(c) - 1) < epsilon || abs(lambda0 - lambda1) < epsilon ? (lambda0 + lambda1) / 2 : atan2(b, a),\n p = project(lambda2, phi2),\n x2 = p[0],\n y2 = p[1],\n dx2 = x2 - x0,\n dy2 = y2 - y0,\n dz = dy * dx2 - dx * dy2;\n if (dz * dz / d2 > delta2 // perpendicular projected distance\n || abs((dx * dx2 + dy * dy2) / d2 - 0.5) > 0.3 // midpoint close to an end\n || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) { // angular distance\n resampleLineTo(x0, y0, lambda0, a0, b0, c0, x2, y2, lambda2, a /= m, b /= m, c, depth, stream);\n stream.point(x2, y2);\n resampleLineTo(x2, y2, lambda2, a, b, c, x1, y1, lambda1, a1, b1, c1, depth, stream);\n }\n }\n }\n return function(stream) {\n var lambda00, x00, y00, a00, b00, c00, // first point\n lambda0, x0, y0, a0, b0, c0; // previous point\n\n var resampleStream = {\n point: point,\n lineStart: lineStart,\n lineEnd: lineEnd,\n polygonStart: function() { stream.polygonStart(); resampleStream.lineStart = ringStart; },\n polygonEnd: function() { stream.polygonEnd(); resampleStream.lineStart = lineStart; }\n };\n\n function point(x, y) {\n x = project(x, y);\n stream.point(x[0], x[1]);\n }\n\n function lineStart() {\n x0 = NaN;\n resampleStream.point = linePoint;\n stream.lineStart();\n }\n\n function linePoint(lambda, phi) {\n var c = cartesian([lambda, phi]), p = project(lambda, phi);\n resampleLineTo(x0, y0, lambda0, a0, b0, c0, x0 = p[0], y0 = p[1], lambda0 = lambda, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream);\n stream.point(x0, y0);\n }\n\n function lineEnd() {\n resampleStream.point = point;\n stream.lineEnd();\n }\n\n function ringStart() {\n lineStart();\n resampleStream.point = ringPoint;\n resampleStream.lineEnd = ringEnd;\n }\n\n function ringPoint(lambda, phi) {\n linePoint(lambda00 = lambda, phi), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0;\n resampleStream.point = linePoint;\n }\n\n function ringEnd() {\n resampleLineTo(x0, y0, lambda0, a0, b0, c0, x00, y00, lambda00, a00, b00, c00, maxDepth, stream);\n resampleStream.lineEnd = lineEnd;\n lineEnd();\n }\n\n return resampleStream;\n };\n}\n","import clipAntimeridian from \"../clip/antimeridian.js\";\nimport clipCircle from \"../clip/circle.js\";\nimport clipRectangle from \"../clip/rectangle.js\";\nimport compose from \"../compose.js\";\nimport identity from \"../identity.js\";\nimport {cos, degrees, radians, sin, sqrt} from \"../math.js\";\nimport {rotateRadians} from \"../rotation.js\";\nimport {transformer} from \"../transform.js\";\nimport {fitExtent, fitSize, fitWidth, fitHeight} from \"./fit.js\";\nimport resample from \"./resample.js\";\n\nvar transformRadians = transformer({\n point: function(x, y) {\n this.stream.point(x * radians, y * radians);\n }\n});\n\nfunction transformRotate(rotate) {\n return transformer({\n point: function(x, y) {\n var r = rotate(x, y);\n return this.stream.point(r[0], r[1]);\n }\n });\n}\n\nfunction scaleTranslate(k, dx, dy, sx, sy) {\n function transform(x, y) {\n x *= sx; y *= sy;\n return [dx + k * x, dy - k * y];\n }\n transform.invert = function(x, y) {\n return [(x - dx) / k * sx, (dy - y) / k * sy];\n };\n return transform;\n}\n\nfunction scaleTranslateRotate(k, dx, dy, sx, sy, alpha) {\n if (!alpha) return scaleTranslate(k, dx, dy, sx, sy);\n var cosAlpha = cos(alpha),\n sinAlpha = sin(alpha),\n a = cosAlpha * k,\n b = sinAlpha * k,\n ai = cosAlpha / k,\n bi = sinAlpha / k,\n ci = (sinAlpha * dy - cosAlpha * dx) / k,\n fi = (sinAlpha * dx + cosAlpha * dy) / k;\n function transform(x, y) {\n x *= sx; y *= sy;\n return [a * x - b * y + dx, dy - b * x - a * y];\n }\n transform.invert = function(x, y) {\n return [sx * (ai * x - bi * y + ci), sy * (fi - bi * x - ai * y)];\n };\n return transform;\n}\n\nexport default function projection(project) {\n return projectionMutator(function() { return project; })();\n}\n\nexport function projectionMutator(projectAt) {\n var project,\n k = 150, // scale\n x = 480, y = 250, // translate\n lambda = 0, phi = 0, // center\n deltaLambda = 0, deltaPhi = 0, deltaGamma = 0, rotate, // pre-rotate\n alpha = 0, // post-rotate angle\n sx = 1, // reflectX\n sy = 1, // reflectX\n theta = null, preclip = clipAntimeridian, // pre-clip angle\n x0 = null, y0, x1, y1, postclip = identity, // post-clip extent\n delta2 = 0.5, // precision\n projectResample,\n projectTransform,\n projectRotateTransform,\n cache,\n cacheStream;\n\n function projection(point) {\n return projectRotateTransform(point[0] * radians, point[1] * radians);\n }\n\n function invert(point) {\n point = projectRotateTransform.invert(point[0], point[1]);\n return point && [point[0] * degrees, point[1] * degrees];\n }\n\n projection.stream = function(stream) {\n return cache && cacheStream === stream ? cache : cache = transformRadians(transformRotate(rotate)(preclip(projectResample(postclip(cacheStream = stream)))));\n };\n\n projection.preclip = function(_) {\n return arguments.length ? (preclip = _, theta = undefined, reset()) : preclip;\n };\n\n projection.postclip = function(_) {\n return arguments.length ? (postclip = _, x0 = y0 = x1 = y1 = null, reset()) : postclip;\n };\n\n projection.clipAngle = function(_) {\n return arguments.length ? (preclip = +_ ? clipCircle(theta = _ * radians) : (theta = null, clipAntimeridian), reset()) : theta * degrees;\n };\n\n projection.clipExtent = function(_) {\n return arguments.length ? (postclip = _ == null ? (x0 = y0 = x1 = y1 = null, identity) : clipRectangle(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reset()) : x0 == null ? null : [[x0, y0], [x1, y1]];\n };\n\n projection.scale = function(_) {\n return arguments.length ? (k = +_, recenter()) : k;\n };\n\n projection.translate = function(_) {\n return arguments.length ? (x = +_[0], y = +_[1], recenter()) : [x, y];\n };\n\n projection.center = function(_) {\n return arguments.length ? (lambda = _[0] % 360 * radians, phi = _[1] % 360 * radians, recenter()) : [lambda * degrees, phi * degrees];\n };\n\n projection.rotate = function(_) {\n return arguments.length ? (deltaLambda = _[0] % 360 * radians, deltaPhi = _[1] % 360 * radians, deltaGamma = _.length > 2 ? _[2] % 360 * radians : 0, recenter()) : [deltaLambda * degrees, deltaPhi * degrees, deltaGamma * degrees];\n };\n\n projection.angle = function(_) {\n return arguments.length ? (alpha = _ % 360 * radians, recenter()) : alpha * degrees;\n };\n\n projection.reflectX = function(_) {\n return arguments.length ? (sx = _ ? -1 : 1, recenter()) : sx < 0;\n };\n\n projection.reflectY = function(_) {\n return arguments.length ? (sy = _ ? -1 : 1, recenter()) : sy < 0;\n };\n\n projection.precision = function(_) {\n return arguments.length ? (projectResample = resample(projectTransform, delta2 = _ * _), reset()) : sqrt(delta2);\n };\n\n projection.fitExtent = function(extent, object) {\n return fitExtent(projection, extent, object);\n };\n\n projection.fitSize = function(size, object) {\n return fitSize(projection, size, object);\n };\n\n projection.fitWidth = function(width, object) {\n return fitWidth(projection, width, object);\n };\n\n projection.fitHeight = function(height, object) {\n return fitHeight(projection, height, object);\n };\n\n function recenter() {\n var center = scaleTranslateRotate(k, 0, 0, sx, sy, alpha).apply(null, project(lambda, phi)),\n transform = scaleTranslateRotate(k, x - center[0], y - center[1], sx, sy, alpha);\n rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma);\n projectTransform = compose(project, transform);\n projectRotateTransform = compose(rotate, projectTransform);\n projectResample = resample(projectTransform, delta2);\n return reset();\n }\n\n function reset() {\n cache = cacheStream = null;\n return projection;\n }\n\n return function() {\n project = projectAt.apply(this, arguments);\n projection.invert = project.invert && invert;\n return recenter();\n };\n}\n","import projection from \"./index.js\";\n\nexport function equirectangularRaw(lambda, phi) {\n return [lambda, phi];\n}\n\nequirectangularRaw.invert = equirectangularRaw;\n\nexport default function() {\n return projection(equirectangularRaw)\n .scale(152.63);\n}\n","import {Adder} from \"d3-array\";\nimport {abs} from \"../math.js\";\nimport noop from \"../noop.js\";\n\nvar areaSum = new Adder(),\n areaRingSum = new Adder(),\n x00,\n y00,\n x0,\n y0;\n\nvar areaStream = {\n point: noop,\n lineStart: noop,\n lineEnd: noop,\n polygonStart: function() {\n areaStream.lineStart = areaRingStart;\n areaStream.lineEnd = areaRingEnd;\n },\n polygonEnd: function() {\n areaStream.lineStart = areaStream.lineEnd = areaStream.point = noop;\n areaSum.add(abs(areaRingSum));\n areaRingSum = new Adder();\n },\n result: function() {\n var area = areaSum / 2;\n areaSum = new Adder();\n return area;\n }\n};\n\nfunction areaRingStart() {\n areaStream.point = areaPointFirst;\n}\n\nfunction areaPointFirst(x, y) {\n areaStream.point = areaPoint;\n x00 = x0 = x, y00 = y0 = y;\n}\n\nfunction areaPoint(x, y) {\n areaRingSum.add(y0 * x - x0 * y);\n x0 = x, y0 = y;\n}\n\nfunction areaRingEnd() {\n areaPoint(x00, y00);\n}\n\nexport default areaStream;\n","import {sqrt} from \"../math.js\";\n\n// TODO Enforce positive area for exterior, negative area for interior?\n\nvar X0 = 0,\n Y0 = 0,\n Z0 = 0,\n X1 = 0,\n Y1 = 0,\n Z1 = 0,\n X2 = 0,\n Y2 = 0,\n Z2 = 0,\n x00,\n y00,\n x0,\n y0;\n\nvar centroidStream = {\n point: centroidPoint,\n lineStart: centroidLineStart,\n lineEnd: centroidLineEnd,\n polygonStart: function() {\n centroidStream.lineStart = centroidRingStart;\n centroidStream.lineEnd = centroidRingEnd;\n },\n polygonEnd: function() {\n centroidStream.point = centroidPoint;\n centroidStream.lineStart = centroidLineStart;\n centroidStream.lineEnd = centroidLineEnd;\n },\n result: function() {\n var centroid = Z2 ? [X2 / Z2, Y2 / Z2]\n : Z1 ? [X1 / Z1, Y1 / Z1]\n : Z0 ? [X0 / Z0, Y0 / Z0]\n : [NaN, NaN];\n X0 = Y0 = Z0 =\n X1 = Y1 = Z1 =\n X2 = Y2 = Z2 = 0;\n return centroid;\n }\n};\n\nfunction centroidPoint(x, y) {\n X0 += x;\n Y0 += y;\n ++Z0;\n}\n\nfunction centroidLineStart() {\n centroidStream.point = centroidPointFirstLine;\n}\n\nfunction centroidPointFirstLine(x, y) {\n centroidStream.point = centroidPointLine;\n centroidPoint(x0 = x, y0 = y);\n}\n\nfunction centroidPointLine(x, y) {\n var dx = x - x0, dy = y - y0, z = sqrt(dx * dx + dy * dy);\n X1 += z * (x0 + x) / 2;\n Y1 += z * (y0 + y) / 2;\n Z1 += z;\n centroidPoint(x0 = x, y0 = y);\n}\n\nfunction centroidLineEnd() {\n centroidStream.point = centroidPoint;\n}\n\nfunction centroidRingStart() {\n centroidStream.point = centroidPointFirstRing;\n}\n\nfunction centroidRingEnd() {\n centroidPointRing(x00, y00);\n}\n\nfunction centroidPointFirstRing(x, y) {\n centroidStream.point = centroidPointRing;\n centroidPoint(x00 = x0 = x, y00 = y0 = y);\n}\n\nfunction centroidPointRing(x, y) {\n var dx = x - x0,\n dy = y - y0,\n z = sqrt(dx * dx + dy * dy);\n\n X1 += z * (x0 + x) / 2;\n Y1 += z * (y0 + y) / 2;\n Z1 += z;\n\n z = y0 * x - x0 * y;\n X2 += z * (x0 + x);\n Y2 += z * (y0 + y);\n Z2 += z * 3;\n centroidPoint(x0 = x, y0 = y);\n}\n\nexport default centroidStream;\n","import {tau} from \"../math.js\";\nimport noop from \"../noop.js\";\n\nexport default function PathContext(context) {\n this._context = context;\n}\n\nPathContext.prototype = {\n _radius: 4.5,\n pointRadius: function(_) {\n return this._radius = _, this;\n },\n polygonStart: function() {\n this._line = 0;\n },\n polygonEnd: function() {\n this._line = NaN;\n },\n lineStart: function() {\n this._point = 0;\n },\n lineEnd: function() {\n if (this._line === 0) this._context.closePath();\n this._point = NaN;\n },\n point: function(x, y) {\n switch (this._point) {\n case 0: {\n this._context.moveTo(x, y);\n this._point = 1;\n break;\n }\n case 1: {\n this._context.lineTo(x, y);\n break;\n }\n default: {\n this._context.moveTo(x + this._radius, y);\n this._context.arc(x, y, this._radius, 0, tau);\n break;\n }\n }\n },\n result: noop\n};\n","import {Adder} from \"d3-array\";\nimport {sqrt} from \"../math.js\";\nimport noop from \"../noop.js\";\n\nvar lengthSum = new Adder(),\n lengthRing,\n x00,\n y00,\n x0,\n y0;\n\nvar lengthStream = {\n point: noop,\n lineStart: function() {\n lengthStream.point = lengthPointFirst;\n },\n lineEnd: function() {\n if (lengthRing) lengthPoint(x00, y00);\n lengthStream.point = noop;\n },\n polygonStart: function() {\n lengthRing = true;\n },\n polygonEnd: function() {\n lengthRing = null;\n },\n result: function() {\n var length = +lengthSum;\n lengthSum = new Adder();\n return length;\n }\n};\n\nfunction lengthPointFirst(x, y) {\n lengthStream.point = lengthPoint;\n x00 = x0 = x, y00 = y0 = y;\n}\n\nfunction lengthPoint(x, y) {\n x0 -= x, y0 -= y;\n lengthSum.add(sqrt(x0 * x0 + y0 * y0));\n x0 = x, y0 = y;\n}\n\nexport default lengthStream;\n","// Simple caching for constant-radius points.\nlet cacheDigits, cacheAppend, cacheRadius, cacheCircle;\n\nexport default class PathString {\n constructor(digits) {\n this._append = digits == null ? append : appendRound(digits);\n this._radius = 4.5;\n this._ = \"\";\n }\n pointRadius(_) {\n this._radius = +_;\n return this;\n }\n polygonStart() {\n this._line = 0;\n }\n polygonEnd() {\n this._line = NaN;\n }\n lineStart() {\n this._point = 0;\n }\n lineEnd() {\n if (this._line === 0) this._ += \"Z\";\n this._point = NaN;\n }\n point(x, y) {\n switch (this._point) {\n case 0: {\n this._append`M${x},${y}`;\n this._point = 1;\n break;\n }\n case 1: {\n this._append`L${x},${y}`;\n break;\n }\n default: {\n this._append`M${x},${y}`;\n if (this._radius !== cacheRadius || this._append !== cacheAppend) {\n const r = this._radius;\n const s = this._;\n this._ = \"\"; // stash the old string so we can cache the circle path fragment\n this._append`m0,${r}a${r},${r} 0 1,1 0,${-2 * r}a${r},${r} 0 1,1 0,${2 * r}z`;\n cacheRadius = r;\n cacheAppend = this._append;\n cacheCircle = this._;\n this._ = s;\n }\n this._ += cacheCircle;\n break;\n }\n }\n }\n result() {\n const result = this._;\n this._ = \"\";\n return result.length ? result : null;\n }\n}\n\nfunction append(strings) {\n let i = 1;\n this._ += strings[0];\n for (const j = strings.length; i < j; ++i) {\n this._ += arguments[i] + strings[i];\n }\n}\n\nfunction appendRound(digits) {\n const d = Math.floor(digits);\n if (!(d >= 0)) throw new RangeError(`invalid digits: ${digits}`);\n if (d > 15) return append;\n if (d !== cacheDigits) {\n const k = 10 ** d;\n cacheDigits = d;\n cacheAppend = function append(strings) {\n let i = 1;\n this._ += strings[0];\n for (const j = strings.length; i < j; ++i) {\n this._ += Math.round(arguments[i] * k) / k + strings[i];\n }\n };\n }\n return cacheAppend;\n}\n","import {Adder} from \"d3-array\";\nimport {abs, atan2, cos, radians, sin, sqrt} from \"./math.js\";\nimport noop from \"./noop.js\";\nimport stream from \"./stream.js\";\n\nvar lengthSum,\n lambda0,\n sinPhi0,\n cosPhi0;\n\nvar lengthStream = {\n sphere: noop,\n point: noop,\n lineStart: lengthLineStart,\n lineEnd: noop,\n polygonStart: noop,\n polygonEnd: noop\n};\n\nfunction lengthLineStart() {\n lengthStream.point = lengthPointFirst;\n lengthStream.lineEnd = lengthLineEnd;\n}\n\nfunction lengthLineEnd() {\n lengthStream.point = lengthStream.lineEnd = noop;\n}\n\nfunction lengthPointFirst(lambda, phi) {\n lambda *= radians, phi *= radians;\n lambda0 = lambda, sinPhi0 = sin(phi), cosPhi0 = cos(phi);\n lengthStream.point = lengthPoint;\n}\n\nfunction lengthPoint(lambda, phi) {\n lambda *= radians, phi *= radians;\n var sinPhi = sin(phi),\n cosPhi = cos(phi),\n delta = abs(lambda - lambda0),\n cosDelta = cos(delta),\n sinDelta = sin(delta),\n x = cosPhi * sinDelta,\n y = cosPhi0 * sinPhi - sinPhi0 * cosPhi * cosDelta,\n z = sinPhi0 * sinPhi + cosPhi0 * cosPhi * cosDelta;\n lengthSum.add(atan2(sqrt(x * x + y * y), z));\n lambda0 = lambda, sinPhi0 = sinPhi, cosPhi0 = cosPhi;\n}\n\nexport default function(object) {\n lengthSum = new Adder();\n stream(object, lengthStream);\n return +lengthSum;\n}\n","import length from \"./length.js\";\n\nvar coordinates = [null, null],\n object = {type: \"LineString\", coordinates: coordinates};\n\nexport default function(a, b) {\n coordinates[0] = a;\n coordinates[1] = b;\n return length(object);\n}\n","/**\r\n * This module contains funcitonality related to geographical projections\r\n */\r\nimport { registry } from \"../../../core/Registry\";\r\nimport * as $math from \"../../../core/utils/Math\";\r\nimport * as d3geo from \"d3-geo\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * This is a base class for a geographical projection.\r\n */\r\nvar Projection = /** @class */ (function () {\r\n function Projection() {\r\n this.d3Projection = d3geo.geoEquirectangular();\r\n }\r\n Object.defineProperty(Projection.prototype, \"d3Projection\", {\r\n /**\r\n * d3 projection\r\n */\r\n get: function () {\r\n return this._d3Projection;\r\n },\r\n /**\r\n * d3 projection\r\n */\r\n set: function (projection) {\r\n this._d3Projection = projection;\r\n projection.precision(0.1);\r\n this._d3Path = d3geo.geoPath().projection(projection);\r\n if (this.chart) {\r\n this.chart.invalidateProjection();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Projection.prototype, \"d3Path\", {\r\n /**\r\n * d3 path generator method\r\n * @ignore\r\n */\r\n get: function () {\r\n return this._d3Path;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Projection.prototype, \"scale\", {\r\n /**\r\n * @ignore\r\n */\r\n get: function () {\r\n return this.d3Projection.scale() / 100;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Converts a geographical point (lat/long) to a screen point (x/y)\r\n * @param geoPoint Geo point (lat/long)\r\n * @return Screen point (x/y)\r\n */\r\n Projection.prototype.convert = function (geoPoint) {\r\n /*\r\n geoPoint = $geo.normalizePoint(geoPoint);\r\n geoPoint = this.rotate(geoPoint, this.deltaLongitude, this.deltaLatitude, this.deltaGama);\r\n let pointInRadians: IPoint = this.project(geoPoint.longitude * $math.RADIANS, geoPoint.latitude * $math.RADIANS);\r\n return {\r\n x: $math.round(pointInRadians.x * $math.DEGREES - this.centerPoint.x, 4) * this.scale,\r\n y: $math.round(-pointInRadians.y * $math.DEGREES - this.centerPoint.y, 4) * this.scale\r\n };*/\r\n var p = this.d3Projection([geoPoint.longitude, geoPoint.latitude]);\r\n if (p) {\r\n return { x: p[0], y: p[1] };\r\n }\r\n };\r\n /**\r\n * Converts a screen point (x/y) to a geographical point (lat/long)\r\n * @param point Screen point (x/y)\r\n * @return Geo point (lat/long)\r\n */\r\n Projection.prototype.invert = function (point) {\r\n /*\r\n let pointInRadians: IGeoPoint = this.unproject((point.x / this.scale + this.centerPoint.x) * $math.RADIANS, (-point.y / this.scale - this.centerPoint.y) * $math.RADIANS);\r\n\r\n let geoPoint = { longitude: pointInRadians.longitude * $math.DEGREES, latitude: pointInRadians.latitude * $math.DEGREES };\r\n\r\n geoPoint = this.unrotate(geoPoint, this.deltaLongitude, this.deltaLatitude, this.deltaGama);\r\n */\r\n var p = this.d3Projection.invert([point.x, point.y]);\r\n if (p) {\r\n return { longitude: p[0], latitude: p[1] };\r\n }\r\n };\r\n /**\r\n * Returns X/Y coordinates.\r\n * Individual projections will override this method to apply their own\r\n * projection logic.\r\n * @deprecated\r\n * @param lambda [description]\r\n * @param phi [description]\r\n * @return X/Y coordinates\r\n * @todo Needs description\r\n */\r\n Projection.prototype.project = function (lambda, phi) {\r\n return this.convert({ longitude: lambda * $math.DEGREES, latitude: phi * $math.DEGREES });\r\n };\r\n /**\r\n * Returns geographical coordinates (lat/long).\r\n * Individual projections will override this method to apply their own\r\n * projection logic.\r\n * @deprecated\r\n * @param x X coordinate\r\n * @param y Y coordinate\r\n * @return Geographical point\r\n * @todo Needs description\r\n */\r\n Projection.prototype.unproject = function (x, y) {\r\n return this.invert({ x: x, y: y });\r\n };\r\n /**\r\n * @ignore\r\n * @deprecated\r\n */\r\n Projection.prototype.rotate = function (geoPoint, deltaLongitude, deltaLatitude, deltaGamma) {\r\n var deltaLambda = deltaLongitude * $math.RADIANS;\r\n var deltaPhi = deltaLatitude * $math.RADIANS;\r\n deltaGamma = deltaGamma * $math.RADIANS;\r\n var lambda = geoPoint.longitude * $math.RADIANS + deltaLambda;\r\n var phi = geoPoint.latitude * $math.RADIANS;\r\n var cosDeltaPhi = Math.cos(deltaPhi);\r\n var sinDeltaPhi = Math.sin(deltaPhi);\r\n var cosDeltaGamma = Math.cos(deltaGamma);\r\n var sinDeltaGamma = Math.sin(deltaGamma);\r\n var cosPhi = Math.cos(phi);\r\n var x = Math.cos(lambda) * cosPhi;\r\n var y = Math.sin(lambda) * cosPhi;\r\n var z = Math.sin(phi);\r\n var k = z * cosDeltaPhi + x * sinDeltaPhi;\r\n return { longitude: $math.DEGREES * Math.atan2(y * cosDeltaGamma - k * sinDeltaGamma, x * cosDeltaPhi - z * sinDeltaPhi), latitude: $math.DEGREES * Math.asin(k * cosDeltaGamma + y * sinDeltaGamma) };\r\n };\r\n /**\r\n * @ignore\r\n * @deprecated\r\n */\r\n Projection.prototype.unrotate = function (geoPoint, deltaLongitude, deltaLatitude, deltaGamma) {\r\n var deltaLambda = deltaLongitude * $math.RADIANS;\r\n var deltaPhi = deltaLatitude * $math.RADIANS;\r\n deltaGamma = deltaGamma * $math.RADIANS;\r\n var lambda = geoPoint.longitude * $math.RADIANS - deltaLambda;\r\n var phi = geoPoint.latitude * $math.RADIANS;\r\n var cosDeltaPhi = Math.cos(deltaPhi);\r\n var sinDeltaPhi = Math.sin(deltaPhi);\r\n var cosDeltaGamma = Math.cos(deltaGamma);\r\n var sinDeltaGamma = Math.sin(deltaGamma);\r\n var cosPhi = Math.cos(phi);\r\n var x = Math.cos(lambda) * cosPhi;\r\n var y = Math.sin(lambda) * cosPhi;\r\n var z = Math.sin(phi);\r\n var k = z * cosDeltaGamma - y * sinDeltaGamma;\r\n return { longitude: $math.DEGREES * Math.atan2(y * cosDeltaGamma + z * sinDeltaGamma, x * cosDeltaPhi + k * sinDeltaPhi), latitude: $math.DEGREES * Math.asin(k * cosDeltaPhi - x * sinDeltaPhi) };\r\n };\r\n //@todo: move to some utils?\r\n //@todo: add credits to: https://www.movable-type.co.uk/scripts/latlong.html\r\n Projection.prototype.intermediatePoint = function (pointA, pointB, position) {\r\n var p = d3geo.geoInterpolate([pointA.longitude, pointA.latitude], [pointB.longitude, pointB.latitude])(position);\r\n return { longitude: p[0], latitude: p[1] };\r\n };\r\n ;\r\n // returns radians\r\n Projection.prototype.multiDistance = function (multiGeoLine) {\r\n var distance = 0;\r\n for (var s = 0; s < multiGeoLine.length; s++) {\r\n var points = multiGeoLine[s];\r\n if (points.length > 1) {\r\n for (var p = 1; p < points.length; p++) {\r\n var pointA = points[p - 1];\r\n var pointB = points[p];\r\n distance += this.distance(pointA, pointB);\r\n }\r\n }\r\n }\r\n return distance;\r\n };\r\n // returns radians\r\n Projection.prototype.distance = function (pointA, pointB) {\r\n return d3geo.geoDistance([pointA.longitude, pointA.latitude], [pointB.longitude, pointB.latitude]);\r\n };\r\n /**\r\n * Converts relative position along the line (0-1) into pixel coordinates.\r\n *\r\n * @param position Position (0-1)\r\n * @return Coordinates\r\n */\r\n Projection.prototype.positionToPoint = function (multiGeoLine, position) {\r\n if (multiGeoLine) {\r\n var intermediatePoint = this.positionToGeoPoint(multiGeoLine, position);\r\n var intermediatePointA = this.positionToGeoPoint(multiGeoLine, position - 0.01);\r\n var intermediatePointB = this.positionToGeoPoint(multiGeoLine, position + 0.01);\r\n if (intermediatePointA && intermediatePointB) {\r\n var point = this.convert(intermediatePoint);\r\n var pa = this.convert(intermediatePointA);\r\n var pb = this.convert(intermediatePointB);\r\n return { x: point.x, y: point.y, angle: $math.getAngle(pa, pb) };\r\n }\r\n }\r\n return { x: 0, y: 0, angle: 0 };\r\n };\r\n /**\r\n * Converts relative position along the line (0-1) into pixel coordinates.\r\n *\r\n * @param position Position (0-1)\r\n * @return Coordinates\r\n */\r\n Projection.prototype.positionToGeoPoint = function (multiGeoLine, position) {\r\n if (multiGeoLine) {\r\n var totalDistance = this.multiDistance(multiGeoLine);\r\n var currentDistance = 0;\r\n var distanceAB = void 0;\r\n var positionA = 0;\r\n var positionB = 0;\r\n var pointA = void 0;\r\n var pointB = void 0;\r\n for (var s = 0; s < multiGeoLine.length; s++) {\r\n var points = multiGeoLine[s];\r\n if (points.length > 1) {\r\n for (var p = 1; p < points.length; p++) {\r\n pointA = points[p - 1];\r\n pointB = points[p];\r\n positionA = currentDistance / totalDistance;\r\n distanceAB = this.distance(pointA, pointB);\r\n currentDistance += distanceAB;\r\n positionB = currentDistance / totalDistance;\r\n if (positionA <= position && positionB > position) {\r\n s = multiGeoLine.length;\r\n break;\r\n }\r\n }\r\n }\r\n else if (points.length == 1) {\r\n pointA = points[0];\r\n pointB = points[0];\r\n positionA = 0;\r\n positionB = 1;\r\n }\r\n }\r\n if (pointA && pointB) {\r\n var positionAB = (position - positionA) / (positionB - positionA);\r\n return this.intermediatePoint(pointA, pointB, positionAB);\r\n }\r\n }\r\n return { longitude: 0, latitude: 0 };\r\n };\r\n return Projection;\r\n}());\r\nexport { Projection };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Projection\"] = Projection;\r\n//# sourceMappingURL=Projection.js.map","import identity from \"../identity.js\";\nimport stream from \"../stream.js\";\nimport pathArea from \"./area.js\";\nimport pathBounds from \"./bounds.js\";\nimport pathCentroid from \"./centroid.js\";\nimport PathContext from \"./context.js\";\nimport pathMeasure from \"./measure.js\";\nimport PathString from \"./string.js\";\n\nexport default function(projection, context) {\n let digits = 3,\n pointRadius = 4.5,\n projectionStream,\n contextStream;\n\n function path(object) {\n if (object) {\n if (typeof pointRadius === \"function\") contextStream.pointRadius(+pointRadius.apply(this, arguments));\n stream(object, projectionStream(contextStream));\n }\n return contextStream.result();\n }\n\n path.area = function(object) {\n stream(object, projectionStream(pathArea));\n return pathArea.result();\n };\n\n path.measure = function(object) {\n stream(object, projectionStream(pathMeasure));\n return pathMeasure.result();\n };\n\n path.bounds = function(object) {\n stream(object, projectionStream(pathBounds));\n return pathBounds.result();\n };\n\n path.centroid = function(object) {\n stream(object, projectionStream(pathCentroid));\n return pathCentroid.result();\n };\n\n path.projection = function(_) {\n if (!arguments.length) return projection;\n projectionStream = _ == null ? (projection = null, identity) : (projection = _).stream;\n return path;\n };\n\n path.context = function(_) {\n if (!arguments.length) return context;\n contextStream = _ == null ? (context = null, new PathString(digits)) : new PathContext(context = _);\n if (typeof pointRadius !== \"function\") contextStream.pointRadius(pointRadius);\n return path;\n };\n\n path.pointRadius = function(_) {\n if (!arguments.length) return pointRadius;\n pointRadius = typeof _ === \"function\" ? _ : (contextStream.pointRadius(+_), +_);\n return path;\n };\n\n path.digits = function(_) {\n if (!arguments.length) return digits;\n if (_ == null) digits = null;\n else {\n const d = Math.floor(_);\n if (!(d >= 0)) throw new RangeError(`invalid digits: ${_}`);\n digits = d;\n }\n if (context === null) contextStream = new PathString(digits);\n return path;\n };\n\n return path.projection(projection).digits(digits).context(context);\n}\n","import {asin, atan2, cos, degrees, haversin, radians, sin, sqrt} from \"./math.js\";\n\nexport default function(a, b) {\n var x0 = a[0] * radians,\n y0 = a[1] * radians,\n x1 = b[0] * radians,\n y1 = b[1] * radians,\n cy0 = cos(y0),\n sy0 = sin(y0),\n cy1 = cos(y1),\n sy1 = sin(y1),\n kx0 = cy0 * cos(x0),\n ky0 = cy0 * sin(x0),\n kx1 = cy1 * cos(x1),\n ky1 = cy1 * sin(x1),\n d = 2 * asin(sqrt(haversin(y1 - y0) + cy0 * cy1 * haversin(x1 - x0))),\n k = sin(d);\n\n var interpolate = d ? function(t) {\n var B = sin(t *= d) / k,\n A = sin(d - t) / k,\n x = A * kx0 + B * kx1,\n y = A * ky0 + B * ky1,\n z = A * sy0 + B * sy1;\n return [\n atan2(y, x) * degrees,\n atan2(z, sqrt(x * x + y * y)) * degrees\n ];\n } : function() {\n return [x0 * degrees, y0 * degrees];\n };\n\n interpolate.distance = d;\n\n return interpolate;\n}\n","/**\r\n * A module for the mini-map control.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../../core/Container\";\r\nimport { Rectangle } from \"../../core/elements/Rectangle\";\r\nimport { List } from \"../../core/utils/List\";\r\nimport { MutableValueDisposer, MultiDisposer } from \"../../core/utils/Disposer\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { color } from \"../../core/utils/Color\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport * as $utils from \"../../core/utils/Utils\";\r\nimport * as $type from \"../../core/utils/Type\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creates a \"bird's eye\" view of the whole map.\r\n *\r\n * This control creates a mini-map with the whole of the map, highlighting\r\n * the area which is in the current viewport of the map map.\r\n *\r\n * @see {@link ISmallMapEvents} for a list of available events\r\n * @see {@link ISmallMapAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar SmallMap = /** @class */ (function (_super) {\r\n __extends(SmallMap, _super);\r\n /**\r\n * Constructor\r\n */\r\n function SmallMap() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n /**\r\n * A target map.\r\n */\r\n _this._chart = new MutableValueDisposer();\r\n _this.className = \"SmallMap\";\r\n // Set defaults\r\n _this.align = \"left\";\r\n _this.valign = \"bottom\";\r\n _this.percentHeight = 20;\r\n _this.percentWidth = 20;\r\n _this.margin(5, 5, 5, 5);\r\n var interfaceColors = new InterfaceColorSet();\r\n // Set background defailts\r\n _this.background.fillOpacity = 0.9;\r\n _this.background.fill = interfaceColors.getFor(\"background\");\r\n // Set up events\r\n _this.events.on(\"hit\", _this.moveToPosition, _this, false);\r\n _this.events.on(\"maxsizechanged\", _this.updateMapSize, _this, false);\r\n // Create a container\r\n _this.seriesContainer = _this.createChild(Container);\r\n _this.seriesContainer.shouldClone = false;\r\n // Create an outline rectangle\r\n var rectangle = _this.createChild(Rectangle);\r\n rectangle.shouldClone = false;\r\n rectangle.stroke = interfaceColors.getFor(\"alternativeBackground\");\r\n rectangle.strokeWidth = 1;\r\n rectangle.strokeOpacity = 0.5;\r\n rectangle.fill = color(); //\"none\";\r\n rectangle.verticalCenter = \"middle\";\r\n rectangle.horizontalCenter = \"middle\";\r\n rectangle.isMeasured = false;\r\n rectangle.visible = false;\r\n _this.rectangle = rectangle;\r\n _this._disposers.push(_this._chart);\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n Object.defineProperty(SmallMap.prototype, \"series\", {\r\n /**\r\n * A list of map series used to draw the mini-map.\r\n *\r\n * @readonly\r\n * @return Series\r\n */\r\n get: function () {\r\n if (!this._series) {\r\n this._series = new List();\r\n this._series.events.on(\"inserted\", this.handleSeriesAdded, this, false);\r\n this._series.events.on(\"removed\", this.handleSeriesRemoved, this, false);\r\n }\r\n return this._series;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Decorates a new series when they are pushed into a `series` list.\r\n *\r\n * @param event Event\r\n */\r\n SmallMap.prototype.handleSeriesAdded = function (event) {\r\n var series = event.newValue;\r\n if (this.chart.series.contains(series)) {\r\n var newSeries = series.clone();\r\n this._series.removeValue(series);\r\n this._series.push(newSeries);\r\n series = newSeries;\r\n this.chart.dataUsers.push(newSeries);\r\n }\r\n series.chart = this.chart;\r\n series.parent = this.seriesContainer;\r\n series.interactionsEnabled = false;\r\n series.events.on(\"inited\", this.updateMapSize, this, false);\r\n series.hidden = false;\r\n };\r\n /**\r\n * Cleans up after series are removed from Scrollbar.\r\n *\r\n * @param event Event\r\n */\r\n SmallMap.prototype.handleSeriesRemoved = function (event) {\r\n //let sourceSeries: MapSeries = event.oldValue;\r\n this.invalidate();\r\n };\r\n /**\r\n * Moves main map pan position after click on the small map.\r\n *\r\n * @ignore Exclude from docs\r\n * @param event Event\r\n */\r\n SmallMap.prototype.moveToPosition = function (event) {\r\n var rectPoint = $utils.spritePointToSprite(event.spritePoint, this, this.seriesContainer);\r\n var geoPoint = this.chart.seriesPointToGeo(rectPoint);\r\n this.chart.zoomToGeoPoint(geoPoint, this.chart.zoomLevel, true);\r\n };\r\n Object.defineProperty(SmallMap.prototype, \"chart\", {\r\n /**\r\n * @return Chart/map\r\n */\r\n get: function () {\r\n return this._chart.get();\r\n },\r\n /**\r\n * A chart/map that this control is meant for.\r\n *\r\n * @param chart Chart/map\r\n */\r\n set: function (chart) {\r\n if (this.chart != chart) {\r\n this._chart.set(chart, new MultiDisposer([\r\n //chart.events.on(\"zoomlevelchanged\", this.updateRectangle, this, false),\r\n chart.events.on(\"mappositionchanged\", this.updateRectangle, this, false),\r\n chart.events.on(\"scaleratiochanged\", this.updateMapSize, this, false)\r\n ]));\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Updates the viewport recangle as per current map zoom/pan position.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n SmallMap.prototype.updateRectangle = function () {\r\n var chart = this.chart;\r\n var zoomLevel = chart.zoomLevel;\r\n var rectangle = this.rectangle;\r\n rectangle.width = this.pixelWidth / zoomLevel;\r\n rectangle.height = this.pixelHeight / zoomLevel;\r\n var scale = Math.min(this.percentWidth, this.percentHeight) / 100;\r\n var seriesContainer = chart.seriesContainer;\r\n rectangle.x = Math.ceil((-seriesContainer.pixelX) * scale / zoomLevel) + this.seriesContainer.pixelX;\r\n rectangle.y = Math.ceil((-seriesContainer.pixelY) * scale / zoomLevel) + this.seriesContainer.pixelY;\r\n rectangle.validate();\r\n };\r\n /**\r\n * Update map size so that internal elements can redraw themselves after\r\n * the size of the small map changes.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n SmallMap.prototype.updateMapSize = function () {\r\n if (this.chart) {\r\n var scale = this.chart.scaleRatio * Math.min(this.percentWidth, this.percentHeight) / 100;\r\n this.seriesContainer.scale = scale;\r\n var bbox = {\r\n width: 0,\r\n height: 0,\r\n x: 0,\r\n y: 0\r\n };\r\n try { // Add exception catching to tame FF\r\n bbox = this.seriesContainer.group.node.getBBox();\r\n }\r\n catch (err) { }\r\n if (bbox.width > 0) {\r\n this.rectangle.visible = true;\r\n }\r\n this.seriesContainer.x = this.pixelWidth / 2 - bbox.x * scale - bbox.width / 2 * scale;\r\n this.seriesContainer.y = this.pixelHeight / 2 - bbox.y * scale - bbox.height / 2 * scale;\r\n this.updateRectangle();\r\n this.afterDraw();\r\n }\r\n };\r\n /**\r\n * Update elements after drawing the small map.\r\n */\r\n SmallMap.prototype.afterDraw = function () {\r\n _super.prototype.afterDraw.call(this);\r\n //this.seriesContainer.moveTo({ x: this.pixelWidth / 2, y: this.pixelHeight / 2 });\r\n this.rectangle.maskRectangle = { x: -1, y: -1, width: Math.ceil(this.pixelWidth + 2), height: Math.ceil(this.pixelHeight + 2) };\r\n };\r\n /**\r\n * Processes JSON-based config before it is applied to the object.\r\n *\r\n * @ignore Exclude from docs\r\n * @param config Config\r\n */\r\n SmallMap.prototype.processConfig = function (config) {\r\n if (config) {\r\n // Set up series\r\n if ($type.hasValue(config.series) && $type.isArray(config.series)) {\r\n for (var i = 0, len = config.series.length; i < len; i++) {\r\n var series = config.series[i];\r\n if ($type.hasValue(series) && $type.isString(series) && this.map.hasKey(series)) {\r\n config.series[i] = this.map.getKey(series);\r\n }\r\n }\r\n }\r\n }\r\n _super.prototype.processConfig.call(this, config);\r\n };\r\n return SmallMap;\r\n}(Container));\r\nexport { SmallMap };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"SmallMap\"] = SmallMap;\r\n//# sourceMappingURL=SmallMap.js.map","/**\r\n * A collection of GeoJSON format-related utility functions.\r\n */\r\nimport * as $math from \"../../core/utils/Math\";\r\nimport * as $array from \"../../core/utils/Array\";\r\n/**\r\n * Normalizes a geo-point.\r\n *\r\n * @ignore Exclude from docs\r\n * @param geoPoint Source geo-point\r\n * @return Normalized geo-point\r\n */\r\nexport function normalizePoint(geoPoint) {\r\n var longitude = wrapAngleTo180(geoPoint.longitude);\r\n var latitude = Math.asin(Math.sin((geoPoint.latitude * $math.RADIANS))) * $math.DEGREES;\r\n var latitude180 = wrapAngleTo180(geoPoint.latitude);\r\n if (Math.abs(latitude180) > 90) {\r\n longitude = wrapAngleTo180(longitude + 180);\r\n }\r\n geoPoint.longitude = longitude;\r\n geoPoint.latitude = latitude;\r\n return geoPoint;\r\n}\r\n/**\r\n * Normalizes all points of a geo-line.\r\n *\r\n * @ignore Exclude from docs\r\n * @param multiline Source geo-line\r\n * @return Normalized geo-line\r\n */\r\nexport function normalizeMultiline(multiline) {\r\n $array.each(multiline, function (segment) {\r\n $array.each(segment, function (point) {\r\n normalizePoint(point);\r\n });\r\n });\r\n return multiline;\r\n}\r\n/**\r\n * [wrapAngleTo180 description]\r\n *\r\n * @todo Description\r\n * @ignore Exclude from docs\r\n * @param angle Angle\r\n * @return Angle\r\n */\r\nexport function wrapAngleTo180(angle) {\r\n angle = angle % 360;\r\n if (angle > 180) {\r\n angle -= 360;\r\n }\r\n if (angle < -180) {\r\n angle += 360;\r\n }\r\n return angle;\r\n}\r\n/**\r\n * Converts a geo point to a regular point object.\r\n *\r\n * @ignore Exclude from docs\r\n * @param geoPoint Source geo point\r\n * @return Point\r\n */\r\nexport function geoToPoint(geoPoint) {\r\n return { x: geoPoint.longitude, y: geoPoint.latitude };\r\n}\r\n//# sourceMappingURL=Geo.js.map","/**\r\n * Map line module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../../core/Container\";\r\nimport { registry } from \"../../core/Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Draws a line on the map.\r\n *\r\n * @see {@link IMapLineObjectEvents} for a list of available events\r\n * @see {@link IMapLineObjectAdapters} for a list of available Adapters\r\n */\r\nvar MapLineObject = /** @class */ (function (_super) {\r\n __extends(MapLineObject, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapLineObject() {\r\n var _this = _super.call(this) || this;\r\n _this.adjustRotation = true;\r\n _this.className = \"MapLineObject\";\r\n _this.isMeasured = false;\r\n _this.layout = \"none\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * (Re)validates element's position.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n MapLineObject.prototype.validatePosition = function () {\r\n var mapLine = this.mapLine;\r\n if (mapLine) {\r\n var point = mapLine.positionToPoint(this.position);\r\n this.x = point.x;\r\n this.y = point.y;\r\n if (this.adjustRotation) {\r\n this.rotation = point.angle;\r\n }\r\n var dataItem = this.mapLine.dataItem;\r\n if (dataItem) {\r\n var series = this.mapLine.dataItem.component;\r\n this.scale = 1 / series.scale;\r\n }\r\n // hide out of bounds\r\n if (mapLine.shortestDistance) {\r\n var projection = this.mapLine.series.chart.projection;\r\n var geoPoint = projection.positionToGeoPoint(mapLine.multiGeoLine, this.position);\r\n var visible = projection.d3Path({ type: 'Point', coordinates: [geoPoint.longitude, geoPoint.latitude] });\r\n if (!visible) {\r\n this.__disabled = true;\r\n }\r\n else {\r\n this.__disabled = false;\r\n }\r\n }\r\n }\r\n _super.prototype.validatePosition.call(this);\r\n };\r\n Object.defineProperty(MapLineObject.prototype, \"position\", {\r\n /**\r\n * @return Position within the line\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"position\");\r\n },\r\n /**\r\n * Sets object's relative position (0-1) within the line.\r\n *\r\n * `0` will place the object at the beginning of the line. `1` - at the end.\r\n *\r\n * Any intermediate number will place the object at some point within the\r\n * line.\r\n *\r\n * @param value Position within the line (0-1)\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"position\", value, false, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapLineObject.prototype, \"adjustRotation\", {\r\n /**\r\n * @return Auto-rotate\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"adjustRotation\");\r\n },\r\n /**\r\n * If set to `true`, the object will be automatically rotated to face the\r\n * direction of the line at the specific position.\r\n *\r\n * This allows creating images that has its \"front\" always facing the logical\r\n * direction of the line.\r\n *\r\n * @default false\r\n * @param value Auto-rotate\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"adjustRotation\", value, false, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return MapLineObject;\r\n}(Container));\r\nexport { MapLineObject };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"MapLineObject\"] = MapLineObject;\r\n//# sourceMappingURL=MapLineObject.js.map","/**\r\n * Map image series module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { MapSeries, MapSeriesDataItem } from \"./MapSeries\";\r\nimport { MapImage } from \"./MapImage\";\r\nimport { ListTemplate, ListDisposer } from \"../../core/utils/List\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport * as $array from \"../../core/utils/Array\";\r\nimport * as $mapUtils from \"./MapUtils\";\r\nimport * as $utils from \"../../core/utils/Utils\";\r\nimport * as $iter from \"../../core/utils/Iterator\";\r\nimport * as $type from \"../../core/utils/Type\";\r\nimport { Disposer } from \"../../core/utils/Disposer\";\r\n/**\r\n * ============================================================================\r\n * DATA ITEM\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines a [[DataItem]] for [[MapImageSeries]]\r\n * @see {@link DataItem}\r\n */\r\nvar MapImageSeriesDataItem = /** @class */ (function (_super) {\r\n __extends(MapImageSeriesDataItem, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapImageSeriesDataItem() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"MapImageSeriesDataItem\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * @ignore\r\n */\r\n MapImageSeriesDataItem.prototype.getFeature = function () {\r\n return { \"type\": \"Feature\", geometry: { type: \"Point\", coordinates: this.point } };\r\n };\r\n Object.defineProperty(MapImageSeriesDataItem.prototype, \"mapImage\", {\r\n /**\r\n * A [[MapImage]] element related to this data item.\r\n *\r\n * @return Element\r\n */\r\n get: function () {\r\n var _this = this;\r\n if (!this._mapImage) {\r\n var mapImage_1 = this.component.mapImages.create();\r\n this.addSprite(mapImage_1);\r\n this._mapImage = mapImage_1;\r\n this._disposers.push(mapImage_1);\r\n this._disposers.push(new Disposer(function () {\r\n if (_this.component) {\r\n _this.component.mapImages.removeValue(mapImage_1);\r\n }\r\n }));\r\n this.mapObject = mapImage_1;\r\n }\r\n return this._mapImage;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapImageSeriesDataItem.prototype, \"point\", {\r\n /**\r\n * @return [description]\r\n */\r\n get: function () {\r\n return this._point;\r\n },\r\n /**\r\n * [point description]\r\n *\r\n * @todo Description\r\n * @param point [description]\r\n */\r\n set: function (point) {\r\n this._point = point;\r\n this._geoPoint = $mapUtils.pointToGeo(point);\r\n this.updateExtremes();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapImageSeriesDataItem.prototype, \"multiPoint\", {\r\n /**\r\n * @return [description]\r\n */\r\n get: function () {\r\n return [this._point];\r\n },\r\n /**\r\n * [point description]\r\n *\r\n * @todo Description\r\n * @param point [description]\r\n */\r\n set: function (multiPoint) {\r\n this._point = multiPoint[0];\r\n this._geoPoint = $mapUtils.pointToGeo(this._point);\r\n this.updateExtremes();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapImageSeriesDataItem.prototype, \"geoPoint\", {\r\n /**\r\n * @return Image coordinates\r\n */\r\n get: function () {\r\n return this._geoPoint;\r\n },\r\n /**\r\n * Geographical coordinates (lat/long) image is placed at.\r\n *\r\n * @param geoPoint Image coordinates\r\n */\r\n set: function (geoPoint) {\r\n this._geoPoint = geoPoint;\r\n this.point = [geoPoint.longitude, geoPoint.latitude];\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return MapImageSeriesDataItem;\r\n}(MapSeriesDataItem));\r\nexport { MapImageSeriesDataItem };\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A series of map image (marker) elements.\r\n *\r\n * @see {@link IMapImageSeriesEvents} for a list of available Events\r\n * @see {@link IMapImageSeriesAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar MapImageSeries = /** @class */ (function (_super) {\r\n __extends(MapImageSeries, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapImageSeries() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"MapImageSeries\";\r\n // Set data fields\r\n _this.dataFields.multiPoint = \"multiPoint\";\r\n _this.dataFields.point = \"point\";\r\n _this.dataFields.geoPoint = \"geoPoint\";\r\n _this.dataFields.multiGeoPoint = \"multiGeoPoint\";\r\n _this.ignoreBounds = true;\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Returns a new/empty DataItem of the type appropriate for this object.\r\n *\r\n * @see {@link DataItem}\r\n * @return Data Item\r\n */\r\n MapImageSeries.prototype.createDataItem = function () {\r\n return new MapImageSeriesDataItem();\r\n };\r\n /**\r\n * (Re)validates the data of the sries, effectively forcing it to redraw\r\n * all of its elements.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n MapImageSeries.prototype.validateData = function () {\r\n var _this = this;\r\n if (this.data.length > 0 && this._parseDataFrom == 0) {\r\n this.mapImages.clear();\r\n }\r\n // process geoJSON and created map objects\r\n if (this.useGeodata) {\r\n if (this.useGeodata || this.geodata) {\r\n var geoJSON = this.chart.geodata;\r\n var features = void 0;\r\n if (geoJSON.type == \"FeatureCollection\") {\r\n features = geoJSON.features;\r\n }\r\n else if (geoJSON.type == \"Feature\") {\r\n features = [geoJSON];\r\n }\r\n else if ([\"Point\", \"LineString\", \"Polygon\", \"MultiPoint\", \"MultiLineString\", \"MultiPolygon\"].indexOf(geoJSON.type) != -1) {\r\n features = [{ geometry: geoJSON }];\r\n }\r\n else {\r\n console.log(\"nothing found in geoJSON\");\r\n }\r\n if (features) {\r\n var _loop_1 = function (i, len) {\r\n var feature = features[i];\r\n var geometry = feature.geometry;\r\n if (geometry) {\r\n var type = geometry.type;\r\n var id_1 = feature.id;\r\n if (type == \"Point\" || type == \"MultiPoint\") { // todo: we don't support multipoints at the moment actually\r\n if (!this_1.checkInclude(this_1.include, this_1.exclude, id_1)) {\r\n return \"continue\";\r\n }\r\n var coordinates = geometry.coordinates;\r\n // make the same as MultiPoint\r\n if (type == \"Point\") {\r\n coordinates = [coordinates];\r\n }\r\n var dataObject = $array.find(this_1.data, function (value, i) {\r\n return value.id == id_1;\r\n });\r\n if (!dataObject) {\r\n dataObject = { multiPoint: coordinates, id: id_1, madeFromGeoData: true };\r\n this_1.data.push(dataObject);\r\n }\r\n else {\r\n if (!dataObject.multiPoint) {\r\n dataObject.multiPoint = coordinates;\r\n }\r\n }\r\n // copy properties data to datacontext\r\n $utils.softCopyProperties(feature.properties, dataObject);\r\n }\r\n }\r\n };\r\n var this_1 = this;\r\n for (var i = 0, len = features.length; i < len; i++) {\r\n _loop_1(i, len);\r\n }\r\n }\r\n }\r\n }\r\n _super.prototype.validateData.call(this);\r\n // important! this should go after super.validateData\r\n // if data is parsed in chunks, images list is corrupted, fix it here\r\n $iter.each(this.dataItems.iterator(), function (dataItem) {\r\n var mapImage = dataItem.mapImage;\r\n if (!mapImage.isDisposed()) {\r\n _this.mapImages.moveValue(mapImage);\r\n if ($type.isNumber(mapImage.latitude) && $type.isNumber(mapImage.latitude)) {\r\n dataItem.geoPoint = { latitude: mapImage.latitude, longitude: mapImage.longitude };\r\n }\r\n }\r\n });\r\n };\r\n Object.defineProperty(MapImageSeries.prototype, \"mapImages\", {\r\n /**\r\n * A list of map images in the series.\r\n *\r\n * @return Map images\r\n */\r\n get: function () {\r\n if (!this._mapImages) {\r\n var template = new MapImage();\r\n var mapImages = new ListTemplate(template);\r\n this._disposers.push(new ListDisposer(mapImages));\r\n this._disposers.push(mapImages.template);\r\n mapImages.template.focusable = true;\r\n mapImages.events.on(\"inserted\", this.handleObjectAdded, this, false);\r\n this._mapImages = mapImages;\r\n this._mapObjects = mapImages;\r\n }\r\n return this._mapImages;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * (Re)validates data element, effectively triggering its redrawal.\r\n *\r\n * @ignore Exclude from docs\r\n * @param dataItem Data item\r\n */\r\n MapImageSeries.prototype.validateDataElement = function (dataItem) {\r\n _super.prototype.validateDataElement.call(this, dataItem);\r\n dataItem.mapImage.invalidate();\r\n };\r\n /**\r\n * (Re)validates the series\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n MapImageSeries.prototype.validate = function () {\r\n _super.prototype.validate.call(this);\r\n $iter.each(this.mapImages.iterator(), function (mapImage) {\r\n mapImage.validatePosition();\r\n });\r\n };\r\n /**\r\n * Copies all properties from another instance of [[Series]].\r\n *\r\n * @param source Source series\r\n */\r\n MapImageSeries.prototype.copyFrom = function (source) {\r\n this.mapImages.template.copyFrom(source.mapImages.template);\r\n _super.prototype.copyFrom.call(this, source);\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapImageSeries.prototype.getFeatures = function () {\r\n var _this = this;\r\n var features = [];\r\n this.dataItems.each(function (dataItem) {\r\n var feature = dataItem.getFeature();\r\n if (feature) {\r\n features.push(feature);\r\n }\r\n });\r\n this.mapImages.each(function (mapImage) {\r\n if (_this.dataItems.indexOf(mapImage._dataItem) == -1) {\r\n var feature = mapImage.getFeature();\r\n if (feature) {\r\n features.push(feature);\r\n }\r\n }\r\n });\r\n return features;\r\n };\r\n /**\r\n * returns MapImage by id\r\n * @param image id\r\n * @return {MapImage}\r\n */\r\n MapImageSeries.prototype.getImageById = function (id) {\r\n return $iter.find(this.mapImages.iterator(), function (mapImage) {\r\n var dataContext = mapImage.dataItem.dataContext;\r\n if (mapImage.id == id || (dataContext && dataContext.id == id)) {\r\n return true;\r\n }\r\n });\r\n };\r\n return MapImageSeries;\r\n}(MapSeries));\r\nexport { MapImageSeries };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"MapImageSeries\"] = MapImageSeries;\r\nregistry.registeredClasses[\"MapImageSeriesDataItem\"] = MapImageSeriesDataItem;\r\n//# sourceMappingURL=MapImageSeries.js.map","/**\r\n * Map line module\r\n */\r\nimport { __extends, __values } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { MapObject } from \"./MapObject\";\r\nimport { MapLineObject } from \"./MapLineObject\";\r\nimport { MapImage } from \"./MapImage\";\r\nimport { MapImageSeries } from \"./MapImageSeries\";\r\nimport { Triangle } from \"../../core/elements/Triangle\";\r\nimport { ListTemplate, ListDisposer } from \"../../core/utils/List\";\r\nimport { Polyline } from \"../../core/elements/Polyline\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { color } from \"../../core/utils/Color\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport { percent, Percent } from \"../../core/utils/Percent\";\r\nimport * as $type from \"../../core/utils/Type\";\r\nimport * as $iter from \"../../core/utils/Iterator\";\r\nimport * as $geo from \"./Geo\";\r\nimport * as $mapUtils from \"./MapUtils\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Used to draw a line on the map.\r\n *\r\n * @see {@link IMapLineEvents} for a list of available events\r\n * @see {@link IMapLineAdapters} for a list of available Adapters\r\n */\r\nvar MapLine = /** @class */ (function (_super) {\r\n __extends(MapLine, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapLine() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n /**\r\n * A list of event disposers for images.\r\n */\r\n _this._imageListeners = {};\r\n _this.className = \"MapLine\";\r\n _this.createLine();\r\n _this.line.stroke = color();\r\n _this.line.parent = _this;\r\n _this.strokeOpacity = 1;\r\n _this.setPropertyValue(\"precision\", 0.1);\r\n var interfaceColors = new InterfaceColorSet();\r\n _this.stroke = interfaceColors.getFor(\"grid\");\r\n _this.shortestDistance = true;\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * @ignore\r\n */\r\n MapLine.prototype.createLine = function () {\r\n this.line = new Polyline();\r\n };\r\n /**\r\n * Converts a position within the line (0-1) to a physical point\r\n * coordinates.\r\n *\r\n * 0 indicates start of the line, 0.5 - middle, while 1 indicates the end.\r\n *\r\n * @param position Position (0-1)\r\n * @return Coordinates\r\n */\r\n MapLine.prototype.positionToPoint = function (position) {\r\n if (this.shortestDistance) {\r\n return this.series.chart.projection.positionToPoint(this.multiGeoLine, position);\r\n }\r\n else {\r\n if (this.line) {\r\n return this.line.positionToPoint(position);\r\n }\r\n }\r\n return { x: 0, y: 0, angle: 0 };\r\n };\r\n Object.defineProperty(MapLine.prototype, \"multiGeoLine\", {\r\n /**\r\n * @return Coordinates\r\n */\r\n get: function () {\r\n var multiGeoLine = this.getPropertyValue(\"multiGeoLine\");\r\n if (!multiGeoLine && this.dataItem && this.dataItem.multiGeoLine) {\r\n multiGeoLine = this.dataItem.multiGeoLine;\r\n }\r\n return multiGeoLine;\r\n },\r\n /**\r\n * A collection of X/Y coordinates for a multi-segment line. E.g.:\r\n *\r\n * ```JSON\r\n * [\r\n * // Segment 1\r\n * [\r\n * { longitude: 3.121, latitude: 0.58 },\r\n * { longitude: -5.199, latitude: 21.223 }\r\n * ],\r\n *\r\n * // Segment 2\r\n * [\r\n * { longitude: -5.199, latitude: 21.223 },\r\n * { longitude: -12.9, latitude: 25.85 }\r\n * ]\r\n * ]\r\n * ```\r\n *\r\n * @see {@link https://tools.ietf.org/html/rfc7946#section-3.1.5} GeoJSON MultiLineString reference\r\n * @param multiGeoLine Coordinates\r\n */\r\n set: function (multiGeoLine) {\r\n if (multiGeoLine && multiGeoLine.length > 0) {\r\n this.setPropertyValue(\"multiGeoLine\", $geo.normalizeMultiline(multiGeoLine), true);\r\n var multiLine = $mapUtils.multiGeoLineToMultiLine(multiGeoLine);\r\n this.setPropertyValue(\"multiLine\", multiLine);\r\n this.updateExtremes();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapLine.prototype, \"multiLine\", {\r\n /**\r\n * @return Coordinates\r\n */\r\n get: function () {\r\n var multiLine = this.getPropertyValue(\"multiLine\");\r\n if (!multiLine && this.dataItem && this.dataItem.multiLine) {\r\n multiLine = this.dataItem.multiLine;\r\n }\r\n return multiLine;\r\n },\r\n /**\r\n * A collection of X/Y coordinates for a multi-segment line. E.g.:\r\n *\r\n * ```JSON\r\n * [\r\n * // Segment 1\r\n * [\r\n * [ 100, 150 ],\r\n * [ 120, 200 ]\r\n * ],\r\n *\r\n * // Segment 2\r\n * [\r\n * [ 120, 200 ],\r\n * [ 150, 100 ]\r\n * ]\r\n * ]\r\n * ```\r\n *\r\n * @param multiLine Coordinates\r\n */\r\n set: function (multiLine) {\r\n this.setPropertyValue(\"multiLine\", multiLine);\r\n this.multiGeoLine = $mapUtils.multiLineToGeo(multiLine);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapLine.prototype, \"imagesToConnect\", {\r\n /**\r\n * @return {MapImages[]}\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"imagesToConnect\");\r\n },\r\n /**\r\n * Instead of setting longitudes/latitudes you can set an array of images\r\n * which will be connected by the line.\r\n *\r\n * Parameter is an array that can hold string `id`'s to of the images, or\r\n * references to actual [[MapImage]] objects.\r\n *\r\n * @param images Images\r\n */\r\n set: function (images) {\r\n var _this = this;\r\n this.setPropertyValue(\"imagesToConnect\", images, true);\r\n this.handleImagesToConnect();\r\n if (this.series) {\r\n var chart = this.series.chart;\r\n if (chart) {\r\n chart.series.each(function (series) {\r\n if (series instanceof MapImageSeries) {\r\n if (!series.isReady()) {\r\n _this._disposers.push(series.events.on(\"ready\", _this.handleImagesToConnect, _this, false));\r\n }\r\n }\r\n });\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n MapLine.prototype.handleImagesToConnect = function () {\r\n var e_1, _a;\r\n var _this = this;\r\n if (this.imagesToConnect) {\r\n var segment = [];\r\n var multiGeoLine = [segment];\r\n var _loop_1 = function (image) {\r\n if ($type.isString(image)) {\r\n var chart = this_1.series.chart;\r\n if (chart) {\r\n chart.series.each(function (series) {\r\n if (series instanceof MapImageSeries) {\r\n var img = series.getImageById(image);\r\n if (img) {\r\n image = img;\r\n }\r\n }\r\n });\r\n }\r\n }\r\n if (image instanceof MapImage) {\r\n segment.push({ longitude: image.longitude, latitude: image.latitude });\r\n if (!this_1._imageListeners[image.uid]) {\r\n var disposer = image.events.on(\"propertychanged\", function (event) {\r\n if (event.property == \"longitude\" || event.property == \"latitude\") {\r\n _this.handleImagesToConnect();\r\n _this.invalidate();\r\n }\r\n }, this_1, false);\r\n this_1._imageListeners[image.uid] = disposer;\r\n this_1._disposers.push(disposer);\r\n }\r\n }\r\n };\r\n var this_1 = this;\r\n try {\r\n for (var _b = __values(this.imagesToConnect), _c = _b.next(); !_c.done; _c = _b.next()) {\r\n var image = _c.value;\r\n _loop_1(image);\r\n }\r\n }\r\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\r\n finally {\r\n try {\r\n if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\r\n }\r\n finally { if (e_1) throw e_1.error; }\r\n }\r\n this.multiGeoLine = multiGeoLine;\r\n }\r\n };\r\n /**\r\n * (Re)validates the line, effectively forcing it to redraw.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n MapLine.prototype.validate = function () {\r\n var chart = this.series.chart;\r\n if (this.multiLine) {\r\n if (!this.shortestDistance) {\r\n var convertedPoints = [];\r\n for (var i = 0, len = this.multiLine.length; i < len; i++) {\r\n var segment = this.multiLine[i];\r\n var convertedSegmentPoints = [];\r\n for (var s = 0, slen = segment.length; s < slen; s++) {\r\n var geoPoint = segment[s];\r\n var point = this.series.chart.projection.convert({ longitude: geoPoint[0], latitude: geoPoint[1] });\r\n convertedSegmentPoints.push(point);\r\n }\r\n convertedPoints.push(convertedSegmentPoints);\r\n }\r\n this.line.segments = convertedPoints;\r\n }\r\n else {\r\n chart.projection.d3Projection.precision(this.precision);\r\n this.line.path = chart.projection.d3Path(this.getFeature());\r\n }\r\n if (this._arrow) {\r\n this._arrow.validatePosition();\r\n }\r\n $iter.each(this.lineObjects.iterator(), function (x) {\r\n x.validatePosition();\r\n });\r\n this.handleGlobalScale();\r\n }\r\n else if (this.imagesToConnect) {\r\n this.handleImagesToConnect();\r\n }\r\n _super.prototype.validate.call(this);\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapLine.prototype.getFeature = function () {\r\n if (this.multiLine && this.multiLine.length > 0 && this.multiLine[0] && this.multiLine[0].length > 0) {\r\n return { \"type\": \"Feature\", geometry: { type: \"MultiLineString\", coordinates: this.multiLine } };\r\n }\r\n };\r\n /**\r\n * @ignore Exclude from docs\r\n */\r\n MapLine.prototype.measureElement = function () {\r\n // Overriding, just to avoid extra measure\r\n };\r\n Object.defineProperty(MapLine.prototype, \"shortestDistance\", {\r\n /**\r\n * @return Real path?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"shortestDistance\");\r\n },\r\n /**\r\n * The line should take the shortest path over the globe.\r\n *\r\n * Enabling this will make the line look differently in different\r\n * projections. Only `MapLine` supports this setting, `MapArc` and\r\n * `MapSplice` don't.\r\n *\r\n * @default true\r\n * @param value Real path?\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"shortestDistance\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapLine.prototype, \"lineObjects\", {\r\n /**\r\n * List of separate line objects the line consists of.\r\n *\r\n * @readonly\r\n * @return List of line objects\r\n */\r\n get: function () {\r\n if (!this._lineObjects) {\r\n this._lineObjects = new ListTemplate(new MapLineObject());\r\n this._lineObjects.events.on(\"inserted\", this.handleLineObjectAdded, this, false);\r\n this._disposers.push(new ListDisposer(this._lineObjects));\r\n this._disposers.push(this._lineObjects.template);\r\n }\r\n return this._lineObjects;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Decorate a [[LineObject]] when it is added to the line.\r\n *\r\n * @param event Event\r\n */\r\n MapLine.prototype.handleLineObjectAdded = function (event) {\r\n var mapLineObject = event.newValue;\r\n mapLineObject.mapLine = this;\r\n mapLineObject.shouldClone = false;\r\n mapLineObject.parent = this;\r\n };\r\n Object.defineProperty(MapLine.prototype, \"arrow\", {\r\n /**\r\n * @return Arrow element\r\n */\r\n get: function () {\r\n if (!this._arrow) {\r\n var arrow = this.createChild(MapLineObject);\r\n arrow.shouldClone = false;\r\n arrow.width = 8;\r\n arrow.height = 10;\r\n arrow.mapLine = this;\r\n arrow.position = 0.5;\r\n var triangle = arrow.createChild(Triangle);\r\n //triangle.shouldClone = false;\r\n triangle.fillOpacity = 1;\r\n triangle.width = percent(100);\r\n triangle.height = percent(100);\r\n triangle.rotation = 90;\r\n triangle.horizontalCenter = \"middle\";\r\n triangle.verticalCenter = \"middle\";\r\n this._arrow = arrow;\r\n }\r\n return this._arrow;\r\n },\r\n /**\r\n * A [[MapLineObject]] to use as an option arrowhead on the line.\r\n *\r\n * Just accessing this property will create a default arrowhead on the line\r\n * automatically.\r\n *\r\n * @param arrow Arrow element\r\n */\r\n set: function (arrow) {\r\n this._arrow = arrow;\r\n arrow.mapLine = this;\r\n arrow.parent = this;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Copies line properties and other attributes, like arrow, from another\r\n * instance of [[MapLine]].\r\n *\r\n * @param source Source map line\r\n */\r\n MapLine.prototype.copyFrom = function (source) {\r\n _super.prototype.copyFrom.call(this, source);\r\n this.line.copyFrom(source.line);\r\n this.lineObjects.copyFrom(source.lineObjects);\r\n if (source._arrow) {\r\n this.arrow = source.arrow.clone();\r\n }\r\n };\r\n Object.defineProperty(MapLine.prototype, \"latitude\", {\r\n /**\r\n * Latitude of the line center.\r\n *\r\n * @readonly\r\n * @return Latitude\r\n */\r\n get: function () {\r\n return this.north + (this.south - this.north) / 2;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapLine.prototype, \"longitude\", {\r\n /**\r\n * Longitude of the line center.\r\n *\r\n * @readonly\r\n * @return Latitude\r\n */\r\n get: function () {\r\n return this.east + (this.west - this.east) / 2;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * X coordinate for the slice tooltip.\r\n *\r\n * @ignore\r\n * @return X\r\n */\r\n MapLine.prototype.getTooltipX = function () {\r\n var x = this.getPropertyValue(\"tooltipX\");\r\n if (!(x instanceof Percent)) {\r\n x = percent(50);\r\n }\r\n if (x instanceof Percent) {\r\n return this.positionToPoint(x.value).x;\r\n }\r\n else {\r\n return 0;\r\n }\r\n };\r\n /**\r\n * Y coordinate for the slice tooltip.\r\n *\r\n * @ignore\r\n * @return Y\r\n */\r\n MapLine.prototype.getTooltipY = function () {\r\n var y = this.getPropertyValue(\"tooltipY\");\r\n if (!(y instanceof Percent)) {\r\n y = percent(50);\r\n }\r\n if (y instanceof Percent) {\r\n return this.positionToPoint(y.value).y;\r\n }\r\n else {\r\n return 0;\r\n }\r\n };\r\n Object.defineProperty(MapLine.prototype, \"precision\", {\r\n /**\r\n * @return Precision\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"precision\");\r\n },\r\n /**\r\n * When line is plotted, if its `shortestDistance` is set to `true` it is\r\n * bent according to the used projection, to depict the shortest distance how\r\n * it would go on the actual land.\r\n *\r\n * `precision` introduces a setting which can control when such bending\r\n * occurs.\r\n *\r\n * If the distance (in degrees) between line start and end points\r\n * is less than `precision`, no bending will take place and the line will be\r\n * straight.\r\n *\r\n * Set to large number (e.g. 10000) for perfectly straight line.\r\n *\r\n * @since 4.9.1\r\n * @default 0.1\r\n * @param value Precision\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"precision\", value, true);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return MapLine;\r\n}(MapObject));\r\nexport { MapLine };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"MapLine\"] = MapLine;\r\n//# sourceMappingURL=MapLine.js.map","/**\r\n * Map line series module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { MapSeries, MapSeriesDataItem } from \"./MapSeries\";\r\nimport { MapLine } from \"./MapLine\";\r\nimport { ListTemplate, ListDisposer } from \"../../core/utils/List\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport * as $mapUtils from \"./MapUtils\";\r\nimport * as $array from \"../../core/utils/Array\";\r\nimport * as $utils from \"../../core/utils/Utils\";\r\nimport * as $iter from \"../../core/utils/Iterator\";\r\nimport { Disposer } from \"../../core/utils/Disposer\";\r\n/**\r\n * ============================================================================\r\n * DATA ITEM\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines a [[DataItem]] for [[MapLineSeries]]\r\n * @see {@link DataItem}\r\n */\r\nvar MapLineSeriesDataItem = /** @class */ (function (_super) {\r\n __extends(MapLineSeriesDataItem, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapLineSeriesDataItem() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"MapLineSeriesDataItem\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n MapLineSeriesDataItem.prototype.getFeature = function () {\r\n if (this.multiLine && this.multiLine.length > 0) {\r\n return { \"type\": \"Feature\", geometry: { type: \"MultiLineString\", coordinates: this.multiLine } };\r\n }\r\n };\r\n Object.defineProperty(MapLineSeriesDataItem.prototype, \"mapLine\", {\r\n /**\r\n * A [[MapLine]] element related to this data item.\r\n *\r\n * @readonly\r\n * @return Element\r\n */\r\n get: function () {\r\n var _this = this;\r\n if (!this._mapLine) {\r\n var mapLine_1 = this.component.mapLines.create();\r\n this._mapLine = mapLine_1;\r\n this.addSprite(mapLine_1);\r\n this._disposers.push(mapLine_1);\r\n this._disposers.push(new Disposer(function () {\r\n if (_this.component) {\r\n _this.component.mapLines.removeValue(mapLine_1);\r\n }\r\n }));\r\n this.mapObject = mapLine_1;\r\n }\r\n return this._mapLine;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapLineSeriesDataItem.prototype, \"line\", {\r\n /**\r\n * @return Coordinates\r\n */\r\n get: function () {\r\n return this._line;\r\n },\r\n /**\r\n * A collection of X/Y coordinates for a single-segment line. E.g.:\r\n *\r\n * ```JSON\r\n * [\r\n * [ 100, 150 ],\r\n * [ 120, 200 ]\r\n * ]\r\n * ```\r\n *\r\n * @param line Coordinates\r\n */\r\n set: function (line) {\r\n this._line = line;\r\n this.multiLine = [line];\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapLineSeriesDataItem.prototype, \"multiLine\", {\r\n /**\r\n * @return Coordinates\r\n */\r\n get: function () {\r\n return this._multiLine;\r\n },\r\n /**\r\n * A collection of X/Y coordinates for a multi-segment line. E.g.:\r\n *\r\n * ```JSON\r\n * [\r\n * // Segment 1\r\n * [\r\n * [ 100, 150 ],\r\n * [ 120, 200 ]\r\n * ],\r\n *\r\n * // Segment 2\r\n * [\r\n * [ 120, 200 ],\r\n * [ 150, 100 ]\r\n * ]\r\n * ]\r\n * ```\r\n *\r\n * @param multiLine Coordinates\r\n */\r\n set: function (multiLine) {\r\n this._multiLine = multiLine;\r\n this._multiGeoLine = $mapUtils.multiLineToGeo(multiLine);\r\n this.updateExtremes();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapLineSeriesDataItem.prototype, \"geoLine\", {\r\n /**\r\n * @return Coordinates\r\n */\r\n get: function () {\r\n return this._geoLine;\r\n },\r\n /**\r\n * A collection of lat/long coordinates for a single-segment line. E.g.:\r\n *\r\n * ```JSON\r\n * [\r\n * { longitude: 3.121, latitude: 0.58 },\r\n * { longitude: -5.199, latitude: 21.223 }\r\n * ]\r\n * ```\r\n *\r\n * @see {@link https://tools.ietf.org/html/rfc7946#section-3.1.4} GeoJSON LineString reference\r\n * @param geoLine Coordinates\r\n */\r\n set: function (geoLine) {\r\n this._geoLine = geoLine;\r\n this.multiLine = $mapUtils.multiGeoLineToMultiLine([geoLine]);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapLineSeriesDataItem.prototype, \"multiGeoLine\", {\r\n /**\r\n * @return Coordinates\r\n */\r\n get: function () {\r\n return this._multiGeoLine;\r\n },\r\n /**\r\n * A collection of X/Y coordinates for a multi-segment line. E.g.:\r\n *\r\n * ```JSON\r\n * [\r\n * // Segment 1\r\n * [\r\n * { longitude: 3.121, latitude: 0.58 },\r\n * { longitude: -5.199, latitude: 21.223 }\r\n * ],\r\n *\r\n * // Segment 2\r\n * [\r\n * { longitude: -5.199, latitude: 21.223 },\r\n * { longitude: -12.9, latitude: 25.85 }\r\n * ]\r\n * ]\r\n * ```\r\n *\r\n * @see {@link https://tools.ietf.org/html/rfc7946#section-3.1.5} GeoJSON MultiLineString reference\r\n * @param multiGeoLine Coordinates\r\n */\r\n set: function (multiGeoLine) {\r\n this._multiGeoLine = multiGeoLine;\r\n this.multiLine = $mapUtils.multiGeoLineToMultiLine(multiGeoLine);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return MapLineSeriesDataItem;\r\n}(MapSeriesDataItem));\r\nexport { MapLineSeriesDataItem };\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A series of map line series.\r\n *\r\n * @see {@link IMapLineSeriesEvents} for a list of available Events\r\n * @see {@link IMapLineSeriesAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar MapLineSeries = /** @class */ (function (_super) {\r\n __extends(MapLineSeries, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapLineSeries() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"MapLineSeries\";\r\n // Set data fields\r\n _this.dataFields.multiLine = \"multiLine\";\r\n _this.dataFields.line = \"line\";\r\n _this.dataFields.geoLine = \"geoLine\";\r\n _this.dataFields.multiGeoLine = \"multiGeoLine\";\r\n _this.ignoreBounds = true;\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Returns a new/empty DataItem of the type appropriate for this object.\r\n *\r\n * @see {@link DataItem}\r\n * @return Data Item\r\n */\r\n MapLineSeries.prototype.createDataItem = function () {\r\n return new MapLineSeriesDataItem();\r\n };\r\n /**\r\n * (Re)validates series data, effectively causing the whole series to be\r\n * redrawn.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n MapLineSeries.prototype.validateData = function () {\r\n // process geoJSON and created map objects\r\n if (this.useGeodata || this.geodata) {\r\n var geoJSON = this.chart.geodata;\r\n if (geoJSON) {\r\n var features = void 0;\r\n if (geoJSON.type == \"FeatureCollection\") {\r\n features = geoJSON.features;\r\n }\r\n else if (geoJSON.type == \"Feature\") {\r\n features = [geoJSON];\r\n }\r\n else if ([\"Point\", \"LineString\", \"Polygon\", \"MultiPoint\", \"MultiLineString\", \"MultiPolygon\"].indexOf(geoJSON.type) != -1) {\r\n features = [{ geometry: geoJSON }];\r\n }\r\n else {\r\n console.log(\"nothing found in geoJSON\");\r\n }\r\n if (features) {\r\n var _loop_1 = function (i, len) {\r\n var feature = features[i];\r\n var geometry = feature.geometry;\r\n if (geometry) {\r\n var type = geometry.type;\r\n var id_1 = feature.id;\r\n if (type == \"LineString\" || type == \"MultiLineString\") {\r\n if (!this_1.checkInclude(this_1.include, this_1.exclude, id_1)) {\r\n return \"continue\";\r\n }\r\n var coordinates = geometry.coordinates;\r\n var dataObject = $array.find(this_1.data, function (value, i) {\r\n return value.id == id_1;\r\n });\r\n if (type == \"LineString\") {\r\n coordinates = [coordinates];\r\n }\r\n if (!dataObject) {\r\n dataObject = { multiLine: coordinates, id: id_1, madeFromGeoData: true };\r\n this_1.data.push(dataObject);\r\n }\r\n else {\r\n if (!dataObject.multiLine) {\r\n dataObject.multiLine = coordinates;\r\n }\r\n }\r\n // copy properties data to datacontext\r\n $utils.softCopyProperties(feature.properties, dataObject);\r\n }\r\n }\r\n };\r\n var this_1 = this;\r\n for (var i = 0, len = features.length; i < len; i++) {\r\n _loop_1(i, len);\r\n }\r\n }\r\n }\r\n }\r\n _super.prototype.validateData.call(this);\r\n };\r\n Object.defineProperty(MapLineSeries.prototype, \"mapLines\", {\r\n /**\r\n * A list of lines in the series.\r\n *\r\n * @return Lines\r\n */\r\n get: function () {\r\n if (!this._mapLines) {\r\n var lineTemplate = this.createLine();\r\n var mapLines = new ListTemplate(lineTemplate);\r\n this._disposers.push(new ListDisposer(mapLines));\r\n this._disposers.push(mapLines.template);\r\n mapLines.events.on(\"inserted\", this.handleObjectAdded, this, false);\r\n this._mapLines = mapLines;\r\n this._mapObjects = mapLines;\r\n }\r\n return this._mapLines;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Returns a new line instance of suitable type.\r\n *\r\n * @return New line\r\n */\r\n MapLineSeries.prototype.createLine = function () {\r\n return new MapLine();\r\n };\r\n /**\r\n * (Re)validates the series\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n MapLineSeries.prototype.validate = function () {\r\n this.dataItems.each(function (dataItem) {\r\n $utils.used(dataItem.mapLine);\r\n });\r\n _super.prototype.validate.call(this);\r\n this.mapLines.each(function (mapLine) {\r\n mapLine.validate();\r\n });\r\n };\r\n /**\r\n * Copies all properties from another instance of [[Series]].\r\n *\r\n * @param source Source series\r\n */\r\n MapLineSeries.prototype.copyFrom = function (source) {\r\n this.mapLines.template.copyFrom(source.mapLines.template);\r\n _super.prototype.copyFrom.call(this, source);\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapLineSeries.prototype.getFeatures = function () {\r\n var _this = this;\r\n var features = [];\r\n this.dataItems.each(function (dataItem) {\r\n var feature = dataItem.getFeature();\r\n if (feature) {\r\n features.push(feature);\r\n }\r\n });\r\n this.mapLines.each(function (mapLine) {\r\n if (_this.dataItems.indexOf(mapLine._dataItem) == -1) {\r\n var feature = mapLine.getFeature();\r\n if (feature) {\r\n features.push(feature);\r\n }\r\n }\r\n });\r\n return features;\r\n };\r\n /**\r\n * returns MapLine by id\r\n * @param line id\r\n * @return {MapLine}\r\n */\r\n MapLineSeries.prototype.getLineById = function (id) {\r\n return $iter.find(this.mapLines.iterator(), function (mapLine) {\r\n var dataContext = mapLine.dataItem.dataContext;\r\n return dataContext.id == id;\r\n });\r\n };\r\n return MapLineSeries;\r\n}(MapSeries));\r\nexport { MapLineSeries };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"MapLineSeries\"] = MapLineSeries;\r\nregistry.registeredClasses[\"MapLineSeriesDataItem\"] = MapLineSeriesDataItem;\r\n//# sourceMappingURL=MapLineSeries.js.map","/**\r\n * Graticule (map grid line).\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { MapLine } from \"./MapLine\";\r\nimport { registry } from \"../../core/Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Graticule is a map line spanning from the poles or around the globe.\r\n *\r\n * @since 4.3.0\r\n * @see {@link IGraticuleEvents} for a list of available events\r\n * @see {@link IGraticuleAdapters} for a list of available Adapters\r\n */\r\nvar Graticule = /** @class */ (function (_super) {\r\n __extends(Graticule, _super);\r\n /**\r\n * Constructor\r\n */\r\n function Graticule() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"Graticule\";\r\n // Apply theme\r\n _this.applyTheme();\r\n _this.shortestDistance = true;\r\n return _this;\r\n }\r\n return Graticule;\r\n}(MapLine));\r\nexport { Graticule };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Graticule\"] = Graticule;\r\n//# sourceMappingURL=Graticule.js.map","export default function range(start, stop, step) {\n start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;\n\n var i = -1,\n n = Math.max(0, Math.ceil((stop - start) / step)) | 0,\n range = new Array(n);\n\n while (++i < n) {\n range[i] = start + i * step;\n }\n\n return range;\n}\n","import {range} from \"d3-array\";\nimport {abs, ceil, epsilon} from \"./math.js\";\n\nfunction graticuleX(y0, y1, dy) {\n var y = range(y0, y1 - epsilon, dy).concat(y1);\n return function(x) { return y.map(function(y) { return [x, y]; }); };\n}\n\nfunction graticuleY(x0, x1, dx) {\n var x = range(x0, x1 - epsilon, dx).concat(x1);\n return function(y) { return x.map(function(x) { return [x, y]; }); };\n}\n\nexport default function graticule() {\n var x1, x0, X1, X0,\n y1, y0, Y1, Y0,\n dx = 10, dy = dx, DX = 90, DY = 360,\n x, y, X, Y,\n precision = 2.5;\n\n function graticule() {\n return {type: \"MultiLineString\", coordinates: lines()};\n }\n\n function lines() {\n return range(ceil(X0 / DX) * DX, X1, DX).map(X)\n .concat(range(ceil(Y0 / DY) * DY, Y1, DY).map(Y))\n .concat(range(ceil(x0 / dx) * dx, x1, dx).filter(function(x) { return abs(x % DX) > epsilon; }).map(x))\n .concat(range(ceil(y0 / dy) * dy, y1, dy).filter(function(y) { return abs(y % DY) > epsilon; }).map(y));\n }\n\n graticule.lines = function() {\n return lines().map(function(coordinates) { return {type: \"LineString\", coordinates: coordinates}; });\n };\n\n graticule.outline = function() {\n return {\n type: \"Polygon\",\n coordinates: [\n X(X0).concat(\n Y(Y1).slice(1),\n X(X1).reverse().slice(1),\n Y(Y0).reverse().slice(1))\n ]\n };\n };\n\n graticule.extent = function(_) {\n if (!arguments.length) return graticule.extentMinor();\n return graticule.extentMajor(_).extentMinor(_);\n };\n\n graticule.extentMajor = function(_) {\n if (!arguments.length) return [[X0, Y0], [X1, Y1]];\n X0 = +_[0][0], X1 = +_[1][0];\n Y0 = +_[0][1], Y1 = +_[1][1];\n if (X0 > X1) _ = X0, X0 = X1, X1 = _;\n if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _;\n return graticule.precision(precision);\n };\n\n graticule.extentMinor = function(_) {\n if (!arguments.length) return [[x0, y0], [x1, y1]];\n x0 = +_[0][0], x1 = +_[1][0];\n y0 = +_[0][1], y1 = +_[1][1];\n if (x0 > x1) _ = x0, x0 = x1, x1 = _;\n if (y0 > y1) _ = y0, y0 = y1, y1 = _;\n return graticule.precision(precision);\n };\n\n graticule.step = function(_) {\n if (!arguments.length) return graticule.stepMinor();\n return graticule.stepMajor(_).stepMinor(_);\n };\n\n graticule.stepMajor = function(_) {\n if (!arguments.length) return [DX, DY];\n DX = +_[0], DY = +_[1];\n return graticule;\n };\n\n graticule.stepMinor = function(_) {\n if (!arguments.length) return [dx, dy];\n dx = +_[0], dy = +_[1];\n return graticule;\n };\n\n graticule.precision = function(_) {\n if (!arguments.length) return precision;\n precision = +_;\n x = graticuleX(y0, y1, 90);\n y = graticuleY(x0, x1, precision);\n X = graticuleX(Y0, Y1, 90);\n Y = graticuleY(X0, X1, precision);\n return graticule;\n };\n\n return graticule\n .extentMajor([[-180, -90 + epsilon], [180, 90 - epsilon]])\n .extentMinor([[-180, -80 - epsilon], [180, 80 + epsilon]]);\n}\n\nexport function graticule10() {\n return graticule()();\n}\n","/**\r\n * Graticule (map grid) series functionality.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { MapLineSeries, MapLineSeriesDataItem } from \"./MapLineSeries\";\r\nimport { Graticule } from \"./Graticule\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport * as d3geo from \"d3-geo\";\r\nimport * as $array from \"../../core/utils/Array\";\r\n/**\r\n * ============================================================================\r\n * DATA ITEM\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines a [[DataItem]] for [[GraticuleSeries]].\r\n *\r\n * @see {@link DataItem}\r\n */\r\nvar GraticuleSeriesDataItem = /** @class */ (function (_super) {\r\n __extends(GraticuleSeriesDataItem, _super);\r\n /**\r\n * Constructor\r\n */\r\n function GraticuleSeriesDataItem() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"GraticuleSeriesDataItem\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n return GraticuleSeriesDataItem;\r\n}(MapLineSeriesDataItem));\r\nexport { GraticuleSeriesDataItem };\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * This class is used to create a set of graticules (map grid).\r\n *\r\n * To enable, create like you would create any regular map series:\r\n *\r\n * ```TypeScript\r\n * let graticule = chart.series.push(new am4maps.GraticuleSeries())\r\n * graticule.mapLines.template.line.stroke = am4core.color(\"#000000\");\r\n * graticule.mapLines.template.line.strokeOpacity = 0.1;\r\n * ```\r\n * ```JavaScript\r\n * var graticule = chart.series.push(new am4maps.GraticuleSeries())\r\n * graticule.mapLines.template.line.stroke = am4core.color(\"#000000\");\r\n * graticule.mapLines.template.line.strokeOpacity = 0.1;\r\n * ```\r\n * ```JSON\r\n * {\r\n * // ...\r\n * \"series\": [{\r\n * \"type\": \"GraticuleSeries\",\r\n * \"mapLines\": {\r\n * \"line\": {\r\n * \"stroke\": \"#000000\",\r\n * \"strokeOpacity\": 0.1\r\n * }\r\n * }\r\n * }]\r\n * }\r\n * ```\r\n *\r\n * @since 4.3.0\r\n * @see {@link IGraticuleSeriesEvents} for a list of available Events\r\n * @see {@link IGraticuleSeriesAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar GraticuleSeries = /** @class */ (function (_super) {\r\n __extends(GraticuleSeries, _super);\r\n /**\r\n * Constructor\r\n */\r\n function GraticuleSeries() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"GraticuleSeries\";\r\n _this.longitudeStep = 10;\r\n _this.latitudeStep = 10;\r\n _this.north = 90;\r\n _this.south = -90;\r\n _this.east = -180;\r\n _this.west = 180;\r\n //this.majorLatitudeStep = 90;\r\n //this.majorLongitudeStep = 360;\r\n _this.fitExtent = true;\r\n _this.singleSprite = true;\r\n _this.events.disableType(\"geoBoundsChanged\");\r\n _this.mapLines.template.line.strokeOpacity = 0.08;\r\n _this.ignoreBounds = false;\r\n _this.hiddenInLegend = true;\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Returns a new/empty DataItem of the type appropriate for this object.\r\n *\r\n * @see {@link DataItem}\r\n * @return Data Item\r\n */\r\n GraticuleSeries.prototype.createDataItem = function () {\r\n return new GraticuleSeriesDataItem();\r\n };\r\n GraticuleSeries.prototype.validateData = function () {\r\n var _this = this;\r\n _super.prototype.validateData.call(this);\r\n this.mapLines.clear();\r\n var graticule = d3geo.geoGraticule();\r\n if (graticule) {\r\n graticule.stepMinor([this.longitudeStep, this.latitudeStep]);\r\n graticule.stepMajor([360, 360]);\r\n var chart = this.chart;\r\n if (this.fitExtent) {\r\n graticule.extent([[chart.east, chart.north], [chart.west, chart.south]]);\r\n }\r\n else {\r\n graticule.extent([[this.east, this.north], [this.west, this.south]]);\r\n }\r\n if (this.singleSprite) {\r\n var mapLine = this.mapLines.create();\r\n mapLine.multiLine = graticule().coordinates;\r\n }\r\n else {\r\n var lineStrings = graticule.lines();\r\n $array.each(lineStrings, function (lineString) {\r\n var mapLine = _this.mapLines.create();\r\n mapLine.multiLine = [lineString.coordinates];\r\n });\r\n }\r\n }\r\n };\r\n /**\r\n * Returns a new line instance of suitable type.\r\n *\r\n * @return New line\r\n */\r\n GraticuleSeries.prototype.createLine = function () {\r\n return new Graticule();\r\n };\r\n Object.defineProperty(GraticuleSeries.prototype, \"latitudeStep\", {\r\n /**\r\n * @return Step\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"latitudeStep\");\r\n },\r\n /**\r\n * Draw a graticule (grid) every X degrees of latitude.\r\n *\r\n * @default 10\r\n * @param value Step\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"latitudeStep\", value)) {\r\n this.invalidateData();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(GraticuleSeries.prototype, \"longitudeStep\", {\r\n /**\r\n * @return Step\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"longitudeStep\");\r\n },\r\n /**\r\n * Draw a graticule (grid) every X degrees of longitude.\r\n *\r\n * @default 10\r\n * @param value Step\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"longitudeStep\", value)) {\r\n this.invalidateData();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(GraticuleSeries.prototype, \"fitExtent\", {\r\n /**\r\n * @return Fit?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"fitExtent\");\r\n },\r\n /**\r\n * Draw a thicker (major) graticule every X degrees of latitude.\r\n *\r\n * @default 90\r\n * @param value Step\r\n */\r\n // public set majorLatitudeStep(value: number) {\r\n // \tif (this.setPropertyValue(\"majorLatitudeStep\", value)) {\r\n // \t\tthis.invalidateData();\r\n // \t}\r\n // }\r\n /**\r\n * @return Step\r\n */\r\n // public get majorLatitudeStep(): number {\r\n // \treturn this.getPropertyValue(\"majorLatitudeStep\");\r\n // }\r\n /**\r\n * Draw a thicker (major) graticule every X degrees of longitude.\r\n *\r\n * @default 360\r\n * @param value Step\r\n */\r\n // public set majorLongitudeStep(value: number) {\r\n // \tif (this.setPropertyValue(\"majorLongitudeStep\", value)) {\r\n // \t\tthis.invalidateData();\r\n // \t}\r\n // }\r\n /**\r\n * @return Step\r\n */\r\n // public get majorLongitudeStep(): number {\r\n // \treturn this.getPropertyValue(\"majorLongitudeStep\");\r\n // }\r\n /**\r\n * Whether to cap graticules (grid) to actual span of the map (`true`), e.g.\r\n * where there are polygons, or draw full-world grid (`false`).\r\n *\r\n * For world maps, using `false` makes sense. For smaller maps - not so much.\r\n *\r\n * If set to `false`, the grid will be drawn from this series `east` to\r\n * `west`, and from `south` to `north` (default values: `east = -180`;\r\n * `west = 180`; `south =-90`; `north =90`).\r\n *\r\n * These can be overridden by setting `GraticuleSeries`' respective\r\n * properties.\r\n *\r\n * @default true\r\n * @param value Fit?\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"fitExtent\", value)) {\r\n this.invalidateData();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(GraticuleSeries.prototype, \"singleSprite\", {\r\n /**\r\n * @return Use single sprite?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"singleSprite\");\r\n },\r\n /**\r\n * Whether to draw all the grid as a single element or as separate lines.\r\n *\r\n * Setting `true` (default) will result in better performance, whereas\r\n * `false` allows setting visual properties of each line individually.\r\n *\r\n * @default true\r\n * @param value Use single sprite?\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"singleSprite\", value)) {\r\n this.invalidateData();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return GraticuleSeries;\r\n}(MapLineSeries));\r\nexport { GraticuleSeries };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"GraticuleSeries\"] = GraticuleSeries;\r\nregistry.registeredClasses[\"GraticuleSeriesDataItem\"] = GraticuleSeriesDataItem;\r\n//# sourceMappingURL=GraticuleSeries.js.map","/**\r\n * Map module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { SerialChart, SerialChartDataItem } from \"./SerialChart\";\r\nimport { Disposer } from \"../../core/utils/Disposer\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\nimport { MapSeries } from \"../map/MapSeries\";\r\nimport { MapImage } from \"../map/MapImage\";\r\nimport { MapPolygon } from \"../map/MapPolygon\";\r\nimport { MapPolygonSeries } from \"../map/MapPolygonSeries\";\r\nimport { Projection } from \"../map/projections/Projection\";\r\nimport { Circle } from \"../../core/elements/Circle\";\r\nimport { SmallMap } from \"../map/SmallMap\";\r\nimport * as $mapUtils from \"../map/MapUtils\";\r\nimport { keyboard } from \"../../core/utils/Keyboard\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { options } from \"../../core/Options\";\r\nimport * as $math from \"../../core/utils/Math\";\r\nimport * as $utils from \"../../core/utils/Utils\";\r\nimport * as $ease from \"../../core/utils/Ease\";\r\nimport * as $iter from \"../../core/utils/Iterator\";\r\nimport * as $type from \"../../core/utils/Type\";\r\nimport * as $geo from \"../map/Geo\";\r\nimport { GraticuleSeries } from \"../map/GraticuleSeries\";\r\nimport { getInteraction } from \"../../core/interaction/Interaction\";\r\n/**\r\n * ============================================================================\r\n * DATA ITEM\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines a [[DataItem]] for [[MapChart]].\r\n *\r\n * @see {@link DataItem}\r\n */\r\nvar MapChartDataItem = /** @class */ (function (_super) {\r\n __extends(MapChartDataItem, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapChartDataItem() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"MapChartDataItem\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n return MapChartDataItem;\r\n}(SerialChartDataItem));\r\nexport { MapChartDataItem };\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creates a map.\r\n *\r\n * @see {@link IMapChartEvents} for a list of available Events\r\n * @see {@link IMapChartAdapters} for a list of available Adapters\r\n * @see {@link https://www.amcharts.com/docs/v4/chart-types/map/} for documentation\r\n */\r\nvar MapChart = /** @class */ (function (_super) {\r\n __extends(MapChart, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapChart() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n /**\r\n * A ratio to be used when scaling the map shapes.\r\n *\r\n * @readonly\r\n */\r\n _this.scaleRatio = 1;\r\n /**\r\n * Default duration of zoom animations (ms).\r\n */\r\n _this.zoomDuration = 1000;\r\n /**\r\n * Default zooming animation easing function.\r\n */\r\n _this.zoomEasing = $ease.cubicOut;\r\n /**\r\n * Smallest available zoom level. The map will not allow to zoom out past\r\n * this setting.\r\n *\r\n * NOTE: Should be power of 2.\r\n *\r\n * @default 1\r\n */\r\n _this.minZoomLevel = 1;\r\n /**\r\n * Biggest available zoom level. The map will not allow to zoom in past\r\n * this setting.\r\n *\r\n * NOTE: Should be power of 2.\r\n *\r\n * @default 32\r\n */\r\n _this.maxZoomLevel = 32;\r\n /**\r\n * [_prevZoomGeoPoint description]\r\n *\r\n * @todo Description\r\n */\r\n _this._prevZoomGeoPoint = { latitude: 0, longitude: 0 };\r\n _this.className = \"MapChart\";\r\n // Set default projection\r\n _this.projection = new Projection();\r\n _this.setPropertyValue(\"deltaLatitude\", 0);\r\n _this.setPropertyValue(\"deltaLongitude\", 0);\r\n _this.setPropertyValue(\"deltaGamma\", 0);\r\n _this.maxPanOut = 0.7;\r\n _this.homeZoomLevel = 1;\r\n _this.zoomStep = 2;\r\n _this.layout = \"absolute\";\r\n _this.centerMapOnZoomOut = true;\r\n // Set padding\r\n _this.padding(0, 0, 0, 0);\r\n $utils.used(_this.backgroundSeries);\r\n // so that the map would render in a hidden div too\r\n _this.minWidth = 10;\r\n _this.minHeight = 10;\r\n _this.events.once(\"inited\", _this.handleAllInited, _this, false);\r\n // Create a container for map series\r\n var seriesContainer = _this.seriesContainer;\r\n seriesContainer.visible = false;\r\n seriesContainer.inert = true;\r\n seriesContainer.resizable = true;\r\n seriesContainer.events.on(\"transformed\", _this.handleMapTransform, _this, false);\r\n seriesContainer.events.on(\"doublehit\", _this.handleDoubleHit, _this, false);\r\n seriesContainer.events.on(\"dragged\", _this.handleDrag, _this, false);\r\n seriesContainer.zIndex = 0;\r\n seriesContainer.dragWhileResize = true;\r\n //seriesContainer.background.fillOpacity = 0;\r\n seriesContainer.adapter.add(\"scale\", function (scale, target) {\r\n return $math.fitToRange(scale, _this.minZoomLevel, _this.maxZoomLevel);\r\n });\r\n // Set up events\r\n //this.events.on(\"validated\", this.updateExtremes, this);\r\n //this.events.on(\"datavalidated\", this.handleAllValidated, this, false);\r\n //this.events.on(\"datavalidated\", this.updateExtremes, this, false);\r\n _this.events.on(\"maxsizechanged\", function (event) {\r\n if (event.previousWidth == 0 || event.previousHeight == 0) {\r\n _this.updateExtremes();\r\n _this.updateCenterGeoPoint();\r\n }\r\n }, undefined, false);\r\n // Set up main chart container, e.g. set backgrounds and events to monitor\r\n // size changes, etc.\r\n var chartContainer = _this.chartContainer;\r\n chartContainer.parent = _this;\r\n chartContainer.zIndex = -1;\r\n _this._disposers.push(_this.events.on(\"maxsizechanged\", function () {\r\n if (_this.inited) {\r\n if (_this._mapAnimation) {\r\n _this._mapAnimation.stop();\r\n }\r\n var allInited_1 = true;\r\n _this.series.each(function (series) {\r\n series.updateTooltipBounds();\r\n if (!series.inited || series.dataInvalid) {\r\n allInited_1 = false;\r\n }\r\n });\r\n if (allInited_1) {\r\n _this.updateScaleRatio();\r\n }\r\n _this.zoomToGeoPoint(_this._zoomGeoPointReal, _this.zoomLevel, true, 0);\r\n }\r\n }, undefined, false));\r\n var chartContainerBg = chartContainer.background;\r\n chartContainerBg.fillOpacity = 0;\r\n chartContainerBg.events.on(\"down\", function (e) { _this.seriesContainer.dragStart(e.target.interactions.downPointers.getIndex(0)); }, _this);\r\n chartContainerBg.events.on(\"up\", function (e) { _this.seriesContainer.dragStop(); }, _this);\r\n chartContainerBg.events.on(\"doublehit\", _this.handleDoubleHit, _this);\r\n chartContainerBg.focusable = true;\r\n chartContainer.events.on(\"down\", _this.handleMapDown, _this, false);\r\n _this.addDisposer(seriesContainer.events.on(\"down\", function () {\r\n // Cancel any move inertia if there is one\r\n var inertia = _this.seriesContainer.interactions.inertias.getKey(\"move\");\r\n if (inertia) {\r\n inertia.done();\r\n }\r\n }));\r\n // Add description to background\r\n _this.background.fillOpacity = 0;\r\n // Add keyboard events for panning\r\n _this._disposers.push(getInteraction().body.events.on(\"keyup\", function (ev) {\r\n if (_this.topParent.hasFocused) {\r\n var key = keyboard.getEventKey(ev.event);\r\n if (!_this._zoomControl || !_this._zoomControl.thumb.isFocused) {\r\n switch (key) {\r\n case \"up\":\r\n _this.pan({ x: 0, y: 0.1 });\r\n break;\r\n case \"down\":\r\n _this.pan({ x: 0, y: -0.1 });\r\n break;\r\n case \"left\":\r\n _this.pan({ x: 0.1, y: 0 });\r\n break;\r\n case \"right\":\r\n _this.pan({ x: -0.1, y: 0 });\r\n break;\r\n }\r\n }\r\n }\r\n }, _this));\r\n _this.mouseWheelBehavior = \"zoom\";\r\n var interaction = getInteraction();\r\n _this._disposers.push(interaction.body.events.on(\"down\", _this.handlePanDown, _this));\r\n _this._disposers.push(interaction.body.events.on(\"up\", _this.handlePanUp, _this));\r\n //this._disposers.push(interaction.body.events.on(\"track\", this.handlePanMove, this));\r\n var panSprite = _this.seriesContainer.createChild(Circle);\r\n panSprite.radius = 10;\r\n panSprite.inert = true;\r\n panSprite.isMeasured = false;\r\n panSprite.events.on(\"transformed\", _this.handlePanMove, _this, false);\r\n panSprite.interactionsEnabled = false;\r\n panSprite.opacity = 0;\r\n panSprite.x = 0;\r\n panSprite.y = 0;\r\n _this.panSprite = panSprite;\r\n _this.panBehavior = \"move\";\r\n /*\r\n this.panSprite.inertiaOptions.setKey(\"move\", {\r\n \"time\": 100,\r\n \"duration\": 1000,\r\n \"factor\": 3,\r\n \"easing\": $ease.sinOut\r\n });*/\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * @ignore\r\n */\r\n MapChart.prototype.handlePanDown = function (event) {\r\n var svgPoint = $utils.documentPointToSvg(event.pointer.point, this.htmlContainer);\r\n if (svgPoint.x > 0 && svgPoint.y > 0 && svgPoint.x < this.svgContainer.width && svgPoint.y < this.svgContainer.height) {\r\n // Get local point\r\n this._downPointOrig = $utils.documentPointToSprite(event.pointer.point, this.seriesContainer);\r\n this.panSprite.moveTo(this._downPointOrig);\r\n this.panSprite.dragStart(event.pointer);\r\n this._downDeltaLongitude = this.deltaLongitude;\r\n this._downDeltaLatitude = this.deltaLatitude;\r\n }\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapChart.prototype.handlePanUp = function (event) {\r\n if (this._downPointOrig) {\r\n this.panSprite.dragStop(event.pointer, true);\r\n }\r\n this._downPointOrig = undefined;\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapChart.prototype.handlePanMove = function () {\r\n if (!this.seriesContainer.isResized) {\r\n if (getInteraction().areTransformed([this.panSprite.interactions, this.seriesContainer.interactions])) {\r\n return;\r\n }\r\n var d3Projection = this.projection.d3Projection;\r\n var panBehavior = this.panBehavior;\r\n if (panBehavior != \"move\" && panBehavior != \"none\" && this._downPointOrig && d3Projection.rotate) {\r\n var rotation = d3Projection.rotate();\r\n var dln = rotation[0];\r\n var dlt = rotation[1];\r\n var dlg = rotation[2];\r\n d3Projection.rotate([0, 0, 0]);\r\n var downGeoLocal = this.projection.invert(this._downPointOrig);\r\n var local = { x: this.panSprite.pixelX, y: this.panSprite.pixelY };\r\n var geoLocal = void 0;\r\n if (local) {\r\n geoLocal = this.projection.invert(local);\r\n }\r\n d3Projection.rotate([dln, dlt, dlg]);\r\n if (geoLocal) {\r\n if (panBehavior == \"rotateLat\" || panBehavior == \"rotateLongLat\") {\r\n this.deltaLatitude = this._downDeltaLatitude + geoLocal.latitude - downGeoLocal.latitude;\r\n }\r\n if (panBehavior == \"rotateLong\" || panBehavior == \"rotateLongLat\") {\r\n this.deltaLongitude = this._downDeltaLongitude + geoLocal.longitude - downGeoLocal.longitude;\r\n }\r\n }\r\n }\r\n }\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapChart.prototype.handleAllInited = function () {\r\n var _this = this;\r\n var inited = true;\r\n this.seriesContainer.visible = true;\r\n this.series.each(function (series) {\r\n if (!series.inited || series.dataInvalid) {\r\n inited = false;\r\n }\r\n });\r\n if (inited) {\r\n this.updateCenterGeoPoint();\r\n this.updateScaleRatio();\r\n this.goHome(0);\r\n }\r\n else {\r\n // TODO verify that this is correct\r\n var disposer_1 = registry.events.once(\"exitframe\", function () {\r\n _this.removeDispose(disposer_1);\r\n _this.handleAllInited();\r\n }, this, false);\r\n this.addDisposer(disposer_1);\r\n }\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapChart.prototype.updateZoomGeoPoint = function () {\r\n var seriesPoint = $utils.svgPointToSprite({ x: this.innerWidth / 2 + this.pixelPaddingLeft, y: this.innerHeight / 2 + this.pixelPaddingTop }, this.series.getIndex(0));\r\n var geoPoint = this.projection.invert(seriesPoint);\r\n this._zoomGeoPointReal = geoPoint;\r\n };\r\n /**\r\n * @ignore\r\n */\r\n MapChart.prototype.updateCenterGeoPoint = function () {\r\n var maxLeft;\r\n var maxRight;\r\n var maxTop;\r\n var maxBottom;\r\n if (this.backgroundSeries) {\r\n var features = this.backgroundSeries.getFeatures();\r\n if (features.length > 0) {\r\n var bounds = this.projection.d3Path.bounds(features[0].geometry);\r\n maxLeft = bounds[0][0];\r\n maxTop = bounds[0][1];\r\n maxRight = bounds[1][0];\r\n maxBottom = bounds[1][1];\r\n }\r\n }\r\n else {\r\n this.series.each(function (series) {\r\n var bbox = series.group.node.getBBox();\r\n if (maxLeft > bbox.x || !$type.isNumber(maxLeft)) {\r\n maxLeft = bbox.x;\r\n }\r\n if (maxRight < bbox.x + bbox.width || !$type.isNumber(maxRight)) {\r\n maxRight = bbox.x + bbox.width;\r\n }\r\n if (maxTop > bbox.y || !$type.isNumber(maxTop)) {\r\n maxTop = bbox.y;\r\n }\r\n if (maxBottom < bbox.y + bbox.height || !$type.isNumber(maxBottom)) {\r\n maxBottom = bbox.y + bbox.height;\r\n }\r\n });\r\n }\r\n this.seriesMaxLeft = maxLeft;\r\n this.seriesMaxRight = maxRight;\r\n this.seriesMaxTop = maxTop;\r\n this.seriesMaxBottom = maxBottom;\r\n this.seriesWidth = maxRight - maxLeft;\r\n this.seriesHeight = maxBottom - maxTop;\r\n if (this.seriesWidth > 0 && this.seriesHeight > 0) {\r\n this.chartContainer.visible = true;\r\n this._centerGeoPoint = this.projection.invert({ x: maxLeft + (maxRight - maxLeft) / 2, y: maxTop + (maxBottom - maxTop) / 2 });\r\n if (!this._zoomGeoPointReal || !$type.isNumber(this._zoomGeoPointReal.latitude)) {\r\n this._zoomGeoPointReal = this._centerGeoPoint;\r\n }\r\n }\r\n else {\r\n this.chartContainer.visible = false;\r\n }\r\n };\r\n /**\r\n * Prevents map to be dragged out of the container area\r\n * @ignore\r\n */\r\n MapChart.prototype.handleDrag = function () {\r\n var d = this.zoomLevel * this.scaleRatio;\r\n var ww = this.seriesWidth * d;\r\n var hh = this.seriesHeight * d;\r\n var seriesContainer = this.seriesContainer;\r\n var maxLeft = this.seriesMaxLeft * d;\r\n var maxRight = this.seriesMaxRight * d;\r\n var maxTop = this.seriesMaxTop * d;\r\n var maxBottom = this.seriesMaxBottom * d;\r\n var x = seriesContainer.pixelX;\r\n var y = seriesContainer.pixelY;\r\n var maxPanOut = this.maxPanOut;\r\n var minX = Math.min(this.maxWidth * (1 - maxPanOut) - ww - maxLeft, -maxLeft);\r\n if (x < minX) {\r\n x = minX;\r\n }\r\n var maxX = Math.max(this.maxWidth * maxPanOut - maxLeft, this.maxWidth - maxRight);\r\n if (x > maxX) {\r\n x = maxX;\r\n }\r\n var minY = Math.min(this.maxHeight * (1 - maxPanOut) - hh - maxTop, -maxTop);\r\n if (y < minY) {\r\n y = minY;\r\n }\r\n var maxY = Math.max(this.maxHeight * maxPanOut - maxTop, this.maxHeight - maxBottom);\r\n if (y > maxY) {\r\n y = maxY;\r\n }\r\n seriesContainer.moveTo({ x: x, y: y }, undefined, undefined, true);\r\n this._zoomGeoPointReal = this.zoomGeoPoint;\r\n };\r\n /**\r\n * Sets defaults that instantiate some objects that rely on parent, so they\r\n * cannot be set in constructor.\r\n */\r\n MapChart.prototype.applyInternalDefaults = function () {\r\n _super.prototype.applyInternalDefaults.call(this);\r\n // Add a default screen reader title for accessibility\r\n // This will be overridden in screen reader if there are any `titles` set\r\n if (!$type.hasValue(this.readerTitle)) {\r\n this.readerTitle = this.language.translate(\"Map\");\r\n }\r\n if (!$type.hasValue(this.background.readerTitle)) {\r\n this.background.role = \"application\";\r\n this.background.readerTitle = this.language.translate(\"Use plus and minus keys on your keyboard to zoom in and out\");\r\n }\r\n };\r\n /**\r\n * Handles event when a pointer presses down on the map, e.g. user presses\r\n * down mouse or touches the map on a screen.\r\n *\r\n * Stops all animations currently going on.\r\n */\r\n MapChart.prototype.handleMapDown = function () {\r\n if (this._mapAnimation) {\r\n this._mapAnimation.stop();\r\n }\r\n };\r\n /**\r\n * Handles the event when user doubleclicks or dooubletaps the map: zooms\r\n * in on the reference point.\r\n *\r\n * @param event Original event\r\n */\r\n MapChart.prototype.handleDoubleHit = function (event) {\r\n var svgPoint = $utils.documentPointToSvg(event.point, this.htmlContainer, this.svgContainer.cssScale);\r\n var geoPoint = this.svgPointToGeo(svgPoint);\r\n this.zoomIn(geoPoint);\r\n };\r\n /**\r\n * Handles mouse wheel event, e.g. user rotates mouse wheel while over the\r\n * map: zooms in or out depending on the direction of the wheel turn.\r\n *\r\n * @param event Original event\r\n */\r\n MapChart.prototype.handleWheel = function (event) {\r\n // Cancel any move inertia if there is one\r\n var inertia = this.seriesContainer.interactions.inertias.getKey(\"move\");\r\n if (inertia) {\r\n inertia.done();\r\n }\r\n var svgPoint = $utils.documentPointToSvg(event.point, this.htmlContainer, this.svgContainer.cssScale);\r\n var geoPoint = this.svgPointToGeo(svgPoint);\r\n if (event.shift.y < 0) {\r\n this.zoomIn(geoPoint, undefined, this.interactions.mouseOptions.sensitivity);\r\n }\r\n else {\r\n this.zoomOut(geoPoint, undefined, this.interactions.mouseOptions.sensitivity);\r\n }\r\n };\r\n Object.defineProperty(MapChart.prototype, \"mouseWheelBehavior\", {\r\n /**\r\n * @return mouse wheel behavior\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"mouseWheelBehavior\");\r\n },\r\n /**\r\n * Specifies what should chart do if when mouse wheel is rotated.\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/reference/sprite/#mouseOptions_property} More information about `mouseOptions`\r\n * @param mouse wheel behavior\r\n * @default zoomX\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"mouseWheelBehavior\", value)) {\r\n if (value != \"none\") {\r\n this._mouseWheelDisposer = this.chartContainer.events.on(\"wheel\", this.handleWheel, this, false);\r\n this._disposers.push(this._mouseWheelDisposer);\r\n }\r\n else {\r\n if (this._mouseWheelDisposer) {\r\n this._mouseWheelDisposer.dispose();\r\n }\r\n this.chartContainer.wheelable = false;\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapChart.prototype, \"panBehavior\", {\r\n /**\r\n * @returns Behavior\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"panBehavior\");\r\n },\r\n /**\r\n * What \"dragging\" map does.\r\n *\r\n * Available values:\r\n * * `\"move\"` (default): changes position of the map.\r\n * * `\"rotateLat\"`: changes `deltaLatitude` (rotates the globe vertically).\r\n * * `\"rotateLong\"`: changes `deltaLongitude` (rotates the globe horizontally).\r\n * * `\"rotateLongLat\"`: changes both `deltaLongitude` and `deltaLatitude` (rotates the globe in any direction).\r\n *\r\n * @default \"move\"\r\n * @since 4.3.0\r\n * @param value Behavior\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"panBehavior\", value)) {\r\n var seriesContainer = this.seriesContainer;\r\n this.panSprite.draggable = false;\r\n seriesContainer.draggable = false;\r\n switch (value) {\r\n case \"move\":\r\n seriesContainer.draggable = true;\r\n break;\r\n default:\r\n this.panSprite.draggable = true;\r\n break;\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapChart.prototype, \"centerMapOnZoomOut\", {\r\n /**\r\n * @returns If the map should be centered when zooming out.\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"centerMapOnZoomOut\");\r\n },\r\n /**\r\n * Specifies if the map should be centered when zooming out\r\n * @default true\r\n * @since 4.7.12\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"centerMapOnZoomOut\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapChart.prototype, \"projection\", {\r\n /**\r\n * @return Projection\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"projection\");\r\n },\r\n /**\r\n * Projection to use for the map.\r\n *\r\n * Available projections:\r\n * * Albers\r\n * * AlbersUSA\r\n * * AzimuthalEqualArea\r\n * * Eckert6\r\n * * EqualEarth\r\n * * Mercator\r\n * * Miller\r\n * * NaturalEarth\r\n * * Orthographic\r\n * * Stereographic\r\n *\r\n * ```TypeScript\r\n * map.projection = new am4maps.projections.Mercator();\r\n * ```\r\n * ```JavaScript\r\n * map.projection = new am4maps.projections.Mercator();\r\n * ```\r\n * ```JSON\r\n * {\r\n * // ...\r\n * \"projection\": \"Mercator\"\r\n * // ...\r\n * }\r\n * ```\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/chart-types/map/#Setting_projection} More about projections\r\n * @param projection Projection\r\n */\r\n set: function (projection) {\r\n var _this = this;\r\n if (this.setPropertyValue(\"projection\", projection)) {\r\n this.invalidateProjection();\r\n projection.chart = this;\r\n if (this._backgroundSeries) {\r\n this._backgroundSeries.invalidate();\r\n }\r\n if (this.inited) {\r\n this.updateExtremes();\r\n }\r\n this.series.each(function (series) {\r\n series.events.once(\"validated\", function () {\r\n _this.updateCenterGeoPoint();\r\n _this.updateScaleRatio();\r\n _this.goHome(0);\r\n });\r\n });\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Validates (processes) data items.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n MapChart.prototype.validateDataItems = function () {\r\n _super.prototype.validateDataItems.call(this);\r\n this.updateExtremes();\r\n };\r\n /**\r\n * Calculates the longitudes and latitudes of the most distant points from\r\n * the center in all four directions: West, East, North, and South.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n MapChart.prototype.updateExtremes = function () {\r\n var east;\r\n var north;\r\n var west;\r\n var south;\r\n this.series.each(function (series) {\r\n if (series.ignoreBounds || (series instanceof GraticuleSeries && series.fitExtent)) {\r\n }\r\n else {\r\n if (series.north > north || !$type.isNumber(north)) {\r\n north = series.north;\r\n }\r\n if (series.south < south || !$type.isNumber(south)) {\r\n south = series.south;\r\n }\r\n if (series.west < west || !$type.isNumber(west)) {\r\n west = series.west;\r\n }\r\n if (series.east > east || !$type.isNumber(east)) {\r\n east = series.east;\r\n }\r\n }\r\n });\r\n var features = [];\r\n var foundGraticule = false;\r\n // if we gave graticule, get features of these series only for faster fitSize\r\n this.series.each(function (series) {\r\n if (series instanceof GraticuleSeries && !series.fitExtent) {\r\n features = series.getFeatures();\r\n foundGraticule = true;\r\n }\r\n });\r\n if (!foundGraticule) {\r\n this.series.each(function (series) {\r\n if (series.ignoreBounds || (series instanceof GraticuleSeries && series.fitExtent)) {\r\n }\r\n else {\r\n features = features.concat(series.getFeatures());\r\n }\r\n });\r\n }\r\n var w = $math.max(50, this.innerWidth);\r\n var h = $math.max(50, this.innerHeight);\r\n var d3Projection = this.projection.d3Projection;\r\n if (features.length > 0 && d3Projection && (this.east != east || this.west != west || this.north != north || this.south != south)) {\r\n this.east = east;\r\n this.west = west;\r\n this.north = north;\r\n this.south = south;\r\n if (d3Projection.rotate) {\r\n var rotation = d3Projection.rotate();\r\n var deltaLong = rotation[0];\r\n var deltaLat = rotation[1];\r\n var deltaGamma = rotation[2];\r\n this.deltaLongitude = deltaLong;\r\n this.deltaLatitude = deltaLat;\r\n this.deltaGamma = deltaGamma;\r\n }\r\n var geoJSON = { \"type\": \"FeatureCollection\", features: features };\r\n var initialScale = d3Projection.scale();\r\n d3Projection.fitSize([w, h], geoJSON);\r\n if (d3Projection.scale() != initialScale) {\r\n this.invalidateDataUsers();\r\n }\r\n this.series.each(function (series) {\r\n if (series instanceof GraticuleSeries) {\r\n series.invalidateData();\r\n }\r\n });\r\n if (this._backgroundSeries) {\r\n var polygon = this._backgroundSeries.mapPolygons.getIndex(0);\r\n if (polygon) {\r\n polygon.multiPolygon = $mapUtils.getBackground(this.north, this.east, this.south, this.west);\r\n }\r\n }\r\n this._fitWidth = w;\r\n this._fitHeight = h;\r\n }\r\n if (!this._zoomGeoPointReal || !$type.isNumber(this._zoomGeoPointReal.latitude)) {\r\n this.goHome(0);\r\n }\r\n };\r\n /**\r\n * (Re)calculates a ratio which should be used to scale the actual map so\r\n * that it fits perfectly into available space. Helps to avoid redrawing of all the map if container size changes\r\n * @ignore\r\n */\r\n MapChart.prototype.updateScaleRatio = function () {\r\n var scaleRatio;\r\n this.updateCenterGeoPoint();\r\n var hScale = this.innerWidth / this.seriesWidth;\r\n var vScale = this.innerHeight / this.seriesHeight;\r\n scaleRatio = $math.min(hScale, vScale);\r\n if ($type.isNaN(scaleRatio) || scaleRatio == Infinity) {\r\n scaleRatio = 1;\r\n }\r\n if (scaleRatio != this.scaleRatio) {\r\n this.scaleRatio = scaleRatio;\r\n $iter.each(this.series.iterator(), function (series) {\r\n series.scale = scaleRatio;\r\n series.updateTooltipBounds();\r\n });\r\n this.backgroundSeries.scale = scaleRatio;\r\n this.dispatch(\"scaleratiochanged\");\r\n }\r\n };\r\n /**\r\n * Converts a point within map container to geographical (lat/long)\r\n * coordinates.\r\n *\r\n * @param point Source point\r\n * @return Geo-point\r\n */\r\n MapChart.prototype.svgPointToGeo = function (point) {\r\n var series = this.series.getIndex(0);\r\n if (series) {\r\n var seriesPoint = $utils.svgPointToSprite(point, series);\r\n return this.seriesPointToGeo(seriesPoint);\r\n }\r\n };\r\n /**\r\n * Converts geographical (lat/long) coordinates to an X/Y point within map's\r\n * container.\r\n *\r\n * @param point Source geo-point\r\n * @return Point\r\n */\r\n MapChart.prototype.geoPointToSVG = function (point) {\r\n var series = this.series.getIndex(0);\r\n if (series) {\r\n var seriesPoint = this.geoPointToSeries(point);\r\n return $utils.spritePointToSvg(seriesPoint, series);\r\n }\r\n };\r\n /**\r\n * Converts a point (X/Y) within actual objects of the map to geographical\r\n * (lat/long) coordinates.\r\n *\r\n * @param point Source point\r\n * @return Geo-point\r\n */\r\n MapChart.prototype.seriesPointToGeo = function (point) {\r\n return this.projection.invert(point);\r\n };\r\n /**\r\n * Converts geographical (lat/long) coordinates to an X/Y point within\r\n * actual elements/objects of the maps.\r\n *\r\n * @param point Source geo-point\r\n * @return Point\r\n */\r\n MapChart.prototype.geoPointToSeries = function (point) {\r\n return this.projection.convert(point);\r\n };\r\n Object.defineProperty(MapChart.prototype, \"geodata\", {\r\n /**\r\n * @return GeoJSON data\r\n */\r\n get: function () {\r\n return this._geodata;\r\n },\r\n /**\r\n * Map data in GeoJSON format.\r\n *\r\n * The Map supports the following GeoJSON objects: `Point`, `LineString`,\r\n * `Polygon`, `MultiPoint`, `MultiLineString`, and `MultiPolygon`.\r\n *\r\n * @see {@link http://geojson.org/} Official GeoJSON format specification\r\n * @param geoJSON GeoJSON data\r\n */\r\n set: function (geodata) {\r\n if (geodata != this._geodata) {\r\n this._geodata = geodata;\r\n if (this.reverseGeodata) {\r\n this.processReverseGeodata(this._geodata);\r\n }\r\n this.invalidateData();\r\n this.dataUsers.each(function (dataUser) {\r\n for (var i = dataUser.data.length - 1; i >= 0; i--) {\r\n if (dataUser.data[i].madeFromGeoData == true) {\r\n dataUser.data.splice(i, 1);\r\n }\r\n }\r\n dataUser.disposeData();\r\n dataUser.invalidateData();\r\n });\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapChart.prototype, \"reverseGeodata\", {\r\n /**\r\n * @returns Reverse the order of geodata coordinates?\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"reverseGeodata\");\r\n },\r\n /**\r\n * Indicates whether GeoJSON geodata supplied to the chart uses\r\n * ESRI (clockwise) or non-ESRI (counter-clockwise) order of the polygon\r\n * coordinates.\r\n *\r\n * `MapChart` supports only ESRI standard, so if your custom maps appears\r\n * garbled, try setting `reverseGeodata = true`.\r\n *\r\n * @default false\r\n * @since 4.10.11\r\n * @param value Reverse the order of geodata coordinates?\r\n */\r\n set: function (value) {\r\n if (this.setPropertyValue(\"reverseGeodata\", value) && this._geodata) {\r\n this.processReverseGeodata(this._geodata);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Reverses the order of polygons on a GeoJSON data.\r\n *\r\n * @since 4.10.11\r\n * @param geodata Source geodata\r\n */\r\n MapChart.prototype.processReverseGeodata = function (geodata) {\r\n for (var i = 0; i < geodata.features.length; i++) {\r\n var feature = geodata.features[i];\r\n for (var x = 0; x < feature.geometry.coordinates.length; x++) {\r\n if (feature.geometry.type == \"MultiPolygon\") {\r\n for (var y = 0; y < feature.geometry.coordinates[x].length; y++) {\r\n feature.geometry.coordinates[x][y].reverse();\r\n }\r\n }\r\n else {\r\n feature.geometry.coordinates[x].reverse();\r\n }\r\n }\r\n }\r\n };\r\n /**\r\n * Zooms the map to particular zoom level and centers on a latitude/longitude\r\n * coordinate.\r\n *\r\n * @param point Center coordinate\r\n * @param zoomLevel Zoom level\r\n * @param center Center on the given coordinate?\r\n * @param duration Duration for zoom animation (ms)\r\n * @return Zoom animation\r\n */\r\n MapChart.prototype.zoomToGeoPoint = function (point, zoomLevel, center, duration, mapObject) {\r\n var _this = this;\r\n if (!point) {\r\n var hasData_1 = false;\r\n this.series.each(function (series) {\r\n if (series.dataItems.length > 0) {\r\n hasData_1 = true;\r\n }\r\n });\r\n if (hasData_1) {\r\n point = this.zoomGeoPoint;\r\n }\r\n else {\r\n return;\r\n }\r\n }\r\n if (!point || !$type.isNumber(point.longitude) || !$type.isNumber(point.latitude)) {\r\n return;\r\n }\r\n this._zoomGeoPointReal = point;\r\n zoomLevel = $math.fitToRange(zoomLevel, this.minZoomLevel, this.maxZoomLevel);\r\n var seriesPoint = this.projection.convert(point);\r\n if (seriesPoint) {\r\n var svgPoint = this.geoPointToSVG(point);\r\n var mapPoint = $utils.svgPointToSprite(svgPoint, this);\r\n if (center) {\r\n mapPoint = {\r\n x: this.innerWidth / 2,\r\n y: this.innerHeight / 2\r\n };\r\n }\r\n if (!$type.isNumber(duration)) {\r\n duration = this.zoomDuration;\r\n }\r\n var x = mapPoint.x - seriesPoint.x * zoomLevel * this.scaleRatio;\r\n var y = mapPoint.y - seriesPoint.y * zoomLevel * this.scaleRatio;\r\n if (!mapObject && zoomLevel < this.zoomLevel && this.centerMapOnZoomOut && zoomLevel < 1.5) {\r\n x = this.innerWidth / 2 - (this.seriesMaxLeft + (this.seriesMaxRight - this.seriesMaxLeft) / 2) * zoomLevel * this.scaleRatio;\r\n y = this.innerHeight / 2 - (this.seriesMaxTop + (this.seriesMaxBottom - this.seriesMaxTop) / 2) * zoomLevel * this.scaleRatio;\r\n }\r\n this._mapAnimation = this.seriesContainer.animate([{\r\n property: \"scale\",\r\n to: zoomLevel\r\n }, {\r\n property: \"x\", from: this.seriesContainer.pixelX,\r\n to: x\r\n }, {\r\n property: \"y\", from: this.seriesContainer.pixelY,\r\n to: y\r\n }], duration, this.zoomEasing);\r\n this._disposers.push(this._mapAnimation.events.on(\"animationended\", function () {\r\n _this._zoomGeoPointReal = _this.zoomGeoPoint;\r\n }));\r\n this.seriesContainer.validatePosition();\r\n return this._mapAnimation;\r\n }\r\n };\r\n /**\r\n * Zooms the map to a particular map object.\r\n *\r\n * @param mapObject Target map object\r\n * @param zoomLevel Zoom level\r\n * @param center Center on the given coordinate?\r\n * @param duration Duration for zoom animation (ms)\r\n * @return Zoom animation\r\n */\r\n MapChart.prototype.zoomToMapObject = function (mapObject, zoomLevel, center, duration) {\r\n if (center == undefined) {\r\n center = true;\r\n }\r\n var inertia = this.seriesContainer.interactions.inertias.getKey(\"move\");\r\n if (inertia) {\r\n inertia.done();\r\n }\r\n if (mapObject instanceof MapImage) {\r\n if ($type.isNaN(zoomLevel)) {\r\n zoomLevel = 5;\r\n }\r\n return this.zoomToGeoPoint({ latitude: mapObject.latitude, longitude: mapObject.longitude }, zoomLevel, center, duration, true);\r\n }\r\n var dataItem = mapObject.dataItem;\r\n if (dataItem && $type.isNumber(dataItem.zoomLevel)) {\r\n zoomLevel = dataItem.zoomLevel;\r\n }\r\n if (mapObject instanceof MapPolygon) {\r\n var dataItem_1 = mapObject.dataItem;\r\n var bbox = mapObject.polygon.bbox;\r\n if (bbox.width == 0 || bbox.height == 0) {\r\n bbox = mapObject.polygon.group.getBBox();\r\n }\r\n if (!$type.isNumber(zoomLevel)) {\r\n zoomLevel = Math.min(this.seriesWidth / bbox.width, this.seriesHeight / bbox.height);\r\n }\r\n var geoPoint = void 0;\r\n if (dataItem_1 && $type.hasValue(dataItem_1.zoomGeoPoint)) {\r\n geoPoint = dataItem_1.zoomGeoPoint;\r\n }\r\n else {\r\n // this is more accurate\r\n var polygonPoint = { x: bbox.x + bbox.width / 2, y: bbox.y + bbox.height / 2 };\r\n var seriesPoint = $utils.spritePointToSprite(polygonPoint, mapObject.polygon, mapObject.series);\r\n geoPoint = this.seriesPointToGeo(seriesPoint);\r\n }\r\n return this.zoomToGeoPoint(geoPoint, zoomLevel, true, duration, true);\r\n }\r\n };\r\n /**\r\n * Zooms the map to a particular viewport.\r\n *\r\n * The `north`, `east`, `south`, and `west` define boundaries of the\r\n * imaginary viewort we want to zoom the map to.\r\n *\r\n * `level` is not actual zoom level. The map will determine the zoom level\r\n * required to accommodated such zoom, and will adjust it by `level` if set.\r\n *\r\n * @param north Latitude of the North-most boundary\r\n * @param east Longitude of the East-most boundary\r\n * @param south Latitude of the South-most boundary\r\n * @param west Longitude of the West-most boundary\r\n * @param level Adjust zoom level\r\n * @param center Center on the given coordinate?\r\n * @param duration Duration for zoom animation (ms)\r\n * @return Zoom animation\r\n */\r\n MapChart.prototype.zoomToRectangle = function (north, east, south, west, level, center, duration) {\r\n if ($type.isNaN(level)) {\r\n level = 1;\r\n }\r\n var w = $math.min(west, east);\r\n var e = $math.max(west, east);\r\n west = w;\r\n east = e;\r\n var splitLongitude = $math.normalizeAngle(180 - this.deltaLongitude);\r\n if (splitLongitude > 180) {\r\n splitLongitude -= 360;\r\n }\r\n var newLong = west + (east - west) / 2;\r\n var d = (west - east);\r\n if (west < splitLongitude && east > splitLongitude) {\r\n newLong += 180;\r\n d = $math.normalizeAngle(east - west - 360);\r\n }\r\n var zoomLevel = level * Math.min((this.south - this.north) / (south - north), Math.abs((this.west - this.east) / d));\r\n return this.zoomToGeoPoint({ latitude: north + (south - north) / 2, longitude: newLong }, zoomLevel, center, duration, true);\r\n };\r\n /**\r\n * Zooms in the map, optionally centering on particular latitude/longitude\r\n * point.\r\n *\r\n * @param geoPoint Optional center point\r\n * @param duration Duration for zoom animation (ms)\r\n * @return Zoom animation\r\n */\r\n MapChart.prototype.zoomIn = function (geoPoint, duration, sensitivity) {\r\n if (sensitivity === void 0) { sensitivity = 1; }\r\n var step = 1 + (this.zoomStep - 1) * sensitivity;\r\n if (step < 1) {\r\n step = 1;\r\n }\r\n return this.zoomToGeoPoint(geoPoint, this.zoomLevel * step, false, duration);\r\n };\r\n /**\r\n * Zooms out the map, optionally centering on particular latitude/longitude\r\n * point.\r\n *\r\n * @param geoPoint Optional center point\r\n * @param duration Duration for zoom animation (ms)\r\n * @return Zoom animation\r\n */\r\n MapChart.prototype.zoomOut = function (geoPoint, duration, sensitivity) {\r\n if (sensitivity === void 0) { sensitivity = 1; }\r\n var step = 1 + (this.zoomStep - 1) * sensitivity;\r\n if (step < 1) {\r\n step = 1;\r\n }\r\n return this.zoomToGeoPoint(geoPoint, this.zoomLevel / step, false, duration);\r\n };\r\n /**\r\n * Pans the maps using relative coordinates. E.g.:\r\n *\r\n * ```JSON\r\n * {\r\n * x: 0.1,\r\n * y: -0.1\r\n * }\r\n * ```\r\n *\r\n * The above will move the map by 10% to the right, and by 10% upwards.\r\n *\r\n * @param shift Vertical and horizontal shift\r\n * @param duration Pan animation duration (ms)\r\n */\r\n MapChart.prototype.pan = function (shift, duration) {\r\n var point = this.geoPointToSVG(this.zoomGeoPoint);\r\n point.x += this.pixelWidth * shift.x;\r\n point.y += this.pixelHeight * shift.y;\r\n this.zoomToGeoPoint(this.svgPointToGeo(point), this.zoomLevel, true, duration, true);\r\n };\r\n Object.defineProperty(MapChart.prototype, \"zoomGeoPoint\", {\r\n /**\r\n * Current lat/long coordinates for the center of the viewport. (default\r\n * zoom reference point)\r\n *\r\n * @readonly\r\n * @return Coordinates\r\n */\r\n get: function () {\r\n var point = $utils.spritePointToSvg({ x: this.pixelWidth / 2, y: this.pixelHeight / 2 }, this);\r\n return this.svgPointToGeo(point);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapChart.prototype, \"zoomLevel\", {\r\n /**\r\n * @return Zoom level\r\n */\r\n get: function () {\r\n return this.seriesContainer.scale;\r\n },\r\n /**\r\n * Current zoom level.\r\n *\r\n * @readonly\r\n * @return Zoom level\r\n */\r\n set: function (value) {\r\n this.seriesContainer.scale = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Dispatches events after some map transformation, like pan or zoom.\r\n *\r\n * @ignore\r\n */\r\n MapChart.prototype.handleMapTransform = function () {\r\n if (this.zoomLevel != this._prevZoomLevel) {\r\n this.dispatch(\"zoomlevelchanged\");\r\n this._prevZoomLevel = this.zoomLevel;\r\n this.svgContainer.readerAlert(this.language.translate(\"Zoom level changed to %1\", this.language.locale, $type.castString(this.zoomLevel)));\r\n }\r\n if (this.zoomGeoPoint && (this._prevZoomGeoPoint.latitude != this.zoomGeoPoint.latitude || this._prevZoomGeoPoint.longitude != this.zoomGeoPoint.longitude)) {\r\n this.dispatch(\"mappositionchanged\");\r\n }\r\n };\r\n Object.defineProperty(MapChart.prototype, \"smallMap\", {\r\n /**\r\n * @return Small map\r\n */\r\n get: function () {\r\n if (!this._smallMap) {\r\n var smallMap = new SmallMap();\r\n this.smallMap = smallMap;\r\n }\r\n return this._smallMap;\r\n },\r\n /**\r\n * A [[SmallMap]] to be used on the map.\r\n *\r\n * Please note, that accessing this property will NOT create a small map\r\n * if it has not yet been created. (except in JSON)\r\n *\r\n * ```TypeScript\r\n * // Create a small map\r\n * map.smallMap = new am4maps.SmallMap();\r\n * ```\r\n * ```JavaScript\r\n * // Create a small map\r\n * map.smallMap = new am4maps.SmallMap();\r\n * ```\r\n * ```JSON\r\n * {\r\n * // ...\r\n * \"smallMap\": {}\r\n * // ...\r\n * }\r\n * ```\r\n *\r\n * @param smallMap Small map\r\n */\r\n set: function (smallMap) {\r\n if (this._smallMap) {\r\n this.removeDispose(this._smallMap);\r\n }\r\n this._smallMap = smallMap;\r\n this._smallMap.chart = this;\r\n smallMap.parent = this.chartContainer;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapChart.prototype, \"zoomControl\", {\r\n /**\r\n * @return Zoom control\r\n */\r\n get: function () {\r\n return this._zoomControl;\r\n },\r\n /**\r\n * A [[ZoomControl]] to be used on the map.\r\n *\r\n * Please note, that accessing this property will NOT create a zoom control\r\n * if it has not yet been created. (except in JSON)\r\n *\r\n * ```TypeScript\r\n * // Create a zoom control\r\n * map.zoomControl = new am4maps.ZoomControl();\r\n * ```\r\n * ```JavaScript\r\n * // Create a zoom control\r\n * map.zoomControl = new am4maps.ZoomControl();\r\n * ```\r\n * ```JSON\r\n * {\r\n * // ...\r\n * \"zoomControl\": {}\r\n * // ...\r\n * }\r\n * ```\r\n *\r\n * @param zoomControl Zoom control\r\n */\r\n set: function (zoomControl) {\r\n if (this._zoomControl) {\r\n this.removeDispose(this._zoomControl);\r\n }\r\n this._zoomControl = zoomControl;\r\n zoomControl.chart = this;\r\n zoomControl.parent = this.chartContainer;\r\n zoomControl.plusButton.exportable = false;\r\n zoomControl.minusButton.exportable = false;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Creates and returns a map series of appropriate type.\r\n *\r\n * @return Map series\r\n */\r\n MapChart.prototype.createSeries = function () {\r\n return new MapSeries();\r\n };\r\n Object.defineProperty(MapChart.prototype, \"deltaLongitude\", {\r\n /**\r\n * @return Rotation\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"deltaLongitude\");\r\n },\r\n /**\r\n * Degrees to rotate the map around vertical axis (Y).\r\n *\r\n * E.g. if set to -160, the longitude 20 will become a new center, creating\r\n * a Pacific-centered map.\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/chart-types/map/#Map_rotation} For more info on map rotation.\r\n * @param value Rotation\r\n */\r\n set: function (value) {\r\n value = $math.round(value, 3);\r\n if (this.setPropertyValue(\"deltaLongitude\", $geo.wrapAngleTo180(value))) {\r\n this.rotateMap();\r\n this.updateZoomGeoPoint();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapChart.prototype, \"deltaLatitude\", {\r\n /**\r\n * @return Rotation\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"deltaLatitude\");\r\n },\r\n /**\r\n * Degrees to rotate the map around horizontal axis (X).\r\n *\r\n * E.g. setting this to 90 will put Antarctica directly in the center of\r\n * the map.\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/chart-types/map/#Map_rotation} For more info on map rotation.\r\n * @since 4.3.0\r\n * @param value Rotation\r\n */\r\n set: function (value) {\r\n value = $math.round(value, 3);\r\n if (this.setPropertyValue(\"deltaLatitude\", value)) {\r\n this.rotateMap();\r\n this.updateZoomGeoPoint();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapChart.prototype, \"deltaGamma\", {\r\n /**\r\n * @return Rotation\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"deltaGamma\");\r\n },\r\n /**\r\n * Degrees to rotate the map around \"Z\" axis. This is the axis that pierces\r\n * the globe directly from the viewer's point of view.\r\n *\r\n * @see {@link https://www.amcharts.com/docs/v4/chart-types/map/#Map_rotation} For more info on map rotation.\r\n * @since 4.3.0\r\n * @param value Rotation\r\n */\r\n set: function (value) {\r\n value = $math.round(value, 3);\r\n if (this.setPropertyValue(\"deltaGamma\", value)) {\r\n this.rotateMap();\r\n this.updateZoomGeoPoint();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * @ignore\r\n */\r\n MapChart.prototype.rotateMap = function () {\r\n if (this.projection.d3Projection) {\r\n if (this.projection.d3Projection.rotate) {\r\n this.projection.d3Projection.rotate([this.deltaLongitude, this.deltaLatitude, this.deltaGamma]);\r\n this.invalidateProjection();\r\n //this.updateExtremes(); // removal fixes #3292\r\n }\r\n }\r\n };\r\n Object.defineProperty(MapChart.prototype, \"maxPanOut\", {\r\n /**\r\n * @return Max pan out\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"maxPanOut\");\r\n },\r\n /**\r\n * Maximum portion of the map's width/height to allow panning \"off screen\".\r\n *\r\n * A value of 0 (zero) will prevent any portion of the the map to be panned\r\n * outside the viewport.\r\n *\r\n * 0.5 will allow half of the map to be outside viewable area.\r\n *\r\n * @default 0.7\r\n * @param value Max pan out\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"maxPanOut\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapChart.prototype, \"homeGeoPoint\", {\r\n /**\r\n * @return Home geo point\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"homeGeoPoint\");\r\n },\r\n /**\r\n * The geographical point to center map on when it is first loaded.\r\n *\r\n * The map will also be centered to this point when you call `goHome()`\r\n * method.\r\n *\r\n * @param value Home geo point\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"homeGeoPoint\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapChart.prototype, \"homeZoomLevel\", {\r\n /**\r\n * @return Home zoom level\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"homeZoomLevel\");\r\n },\r\n /**\r\n * The zoom level to put the map in when it is first loaded.\r\n *\r\n * The map will also be set to this zoom level when you call `goHome()`\r\n * method.\r\n *\r\n * @param value Home zoom level\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"homeZoomLevel\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MapChart.prototype, \"zoomStep\", {\r\n /**\r\n * @return Zoom factor\r\n */\r\n get: function () {\r\n return this.getPropertyValue(\"zoomStep\");\r\n },\r\n /**\r\n * When user zooms in or out current zoom level is multiplied or divided\r\n * by value of this setting.\r\n *\r\n * @default 2\r\n * @param value Zoom factor\r\n */\r\n set: function (value) {\r\n this.setPropertyValue(\"zoomStep\", value);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Invalidates projection, causing all series to be redrawn.\r\n *\r\n * Call this after changing projection or its settings.\r\n */\r\n MapChart.prototype.invalidateProjection = function () {\r\n this.east = undefined;\r\n this.invalidateDataUsers();\r\n this.updateCenterGeoPoint();\r\n };\r\n Object.defineProperty(MapChart.prototype, \"geodataSource\", {\r\n /**\r\n * Returns a [[DataSource]] specifically for loading Component's data.\r\n *\r\n * @return Data source\r\n */\r\n get: function () {\r\n var _this = this;\r\n if (!this._dataSources[\"geodata\"]) {\r\n var dataSource = this.getDataSource(\"geodata\");\r\n dataSource.events.on(\"parseended\", function () {\r\n _this.events.once(\"datavalidated\", function () {\r\n _this.goHome(0);\r\n });\r\n });\r\n }\r\n return this._dataSources[\"geodata\"];\r\n },\r\n /**\r\n * Sets a [[DataSource]] to be used for loading Component's data.\r\n *\r\n * @param value Data source\r\n */\r\n set: function (value) {\r\n var _this = this;\r\n if (this._dataSources[\"geodata\"]) {\r\n this.removeDispose(this._dataSources[\"geodata\"]);\r\n }\r\n this._dataSources[\"geodata\"] = value;\r\n this._dataSources[\"geodata\"].component = this;\r\n this.events.on(\"inited\", function () {\r\n _this.loadData(\"geodata\");\r\n }, this, false);\r\n this.setDataSourceEvents(value, \"geodata\");\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Processes JSON-based config before it is applied to the object.\r\n *\r\n * @ignore Exclude from docs\r\n * @param config Config\r\n */\r\n MapChart.prototype.processConfig = function (config) {\r\n if ($type.hasValue(config[\"geodata\"]) && $type.isString(config[\"geodata\"])) {\r\n var name_1 = config[\"geodata\"];\r\n // Check if there's a map loaded by such name\r\n if ($type.hasValue(window[\"am4geodata_\" + config[\"geodata\"]])) {\r\n config[\"geodata\"] = window[\"am4geodata_\" + config[\"geodata\"]];\r\n }\r\n // Nope. Let's try maybe we got JSON as string?\r\n else {\r\n try {\r\n config[\"geodata\"] = JSON.parse(config[\"geodata\"]);\r\n }\r\n catch (e) {\r\n // No go again. Error out.\r\n this.raiseCriticalError(Error(\"MapChart error: Geodata `\" + name_1 + \"` is not loaded or is incorrect.\"), true);\r\n }\r\n }\r\n }\r\n // Instantiate projection\r\n if ($type.hasValue(config[\"projection\"]) && $type.isString(config[\"projection\"])) {\r\n config[\"projection\"] = this.createClassInstance(config[\"projection\"]);\r\n }\r\n // Set up small map\r\n if ($type.hasValue(config.smallMap) && !$type.hasValue(config.smallMap.type)) {\r\n config.smallMap.type = \"SmallMap\";\r\n }\r\n // Set up zoom control\r\n if ($type.hasValue(config.zoomControl) && !$type.hasValue(config.zoomControl.type)) {\r\n config.zoomControl.type = \"ZoomControl\";\r\n }\r\n _super.prototype.processConfig.call(this, config);\r\n };\r\n /**\r\n * Decorates a new [[Series]] object with required parameters when it is\r\n * added to the chart.\r\n *\r\n * @ignore Exclude from docs\r\n * @param event Event\r\n */\r\n MapChart.prototype.handleSeriesAdded = function (event) {\r\n _super.prototype.handleSeriesAdded.call(this, event);\r\n var series = event.newValue;\r\n series.scale = this.scaleRatio;\r\n series.events.on(\"validated\", this.updateCenterGeoPoint, this, false);\r\n };\r\n /**\r\n * This function is used to sort element's JSON config properties, so that\r\n * some properties that absolutely need to be processed last, can be put at\r\n * the end.\r\n *\r\n * @ignore Exclude from docs\r\n * @param a Element 1\r\n * @param b Element 2\r\n * @return Sorting number\r\n */\r\n MapChart.prototype.configOrder = function (a, b) {\r\n if (a == b) {\r\n return 0;\r\n }\r\n // Must come last\r\n else if (a == \"smallMap\") {\r\n return 1;\r\n }\r\n else if (b == \"smallMap\") {\r\n return -1;\r\n }\r\n else if (a == \"series\") {\r\n return 1;\r\n }\r\n else if (b == \"series\") {\r\n return -1;\r\n }\r\n else {\r\n return _super.prototype.configOrder.call(this, a, b);\r\n }\r\n };\r\n /**\r\n * Adds `projection` to \"as is\" fields.\r\n *\r\n * @param field Field name\r\n * @return Assign as is?\r\n */\r\n MapChart.prototype.asIs = function (field) {\r\n return field == \"projection\" || field == \"geodata\" || _super.prototype.asIs.call(this, field);\r\n };\r\n Object.defineProperty(MapChart.prototype, \"centerGeoPoint\", {\r\n /**\r\n * Geo point of map center\r\n *\r\n * @readonly\r\n */\r\n get: function () {\r\n return this._centerGeoPoint;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Resets the map to its original position and zoom level.\r\n *\r\n * Use the only parameter to set number of milliseconds for the zoom\r\n * animation to play.\r\n *\r\n * @param duration Duration (ms)\r\n */\r\n MapChart.prototype.goHome = function (duration) {\r\n var homeGeoPoint = this.homeGeoPoint;\r\n if (!homeGeoPoint) {\r\n homeGeoPoint = this.centerGeoPoint;\r\n }\r\n if (homeGeoPoint) {\r\n this.zoomToGeoPoint(homeGeoPoint, this.homeZoomLevel, true, duration, true);\r\n }\r\n };\r\n /**\r\n * Sets [[Paper]] instance to use to draw elements.\r\n *\r\n * @ignore\r\n * @param paper Paper\r\n * @return true if paper was changed, false, if it's the same\r\n */\r\n MapChart.prototype.setPaper = function (paper) {\r\n if (this.svgContainer) {\r\n this.svgContainer.hideOverflow = true;\r\n }\r\n return _super.prototype.setPaper.call(this, paper);\r\n };\r\n Object.defineProperty(MapChart.prototype, \"backgroundSeries\", {\r\n /**\r\n * Background series will create polygons that will fill all the map area\r\n * with some color (or other fill).\r\n *\r\n * This might be useful with non-rectangular projections, like Orthographic,\r\n * Albers, etc.\r\n *\r\n * To change background color/opacity access polygon template.\r\n *\r\n * ```TypeScript\r\n * chart.backgroundSeries.mapPolygons.template.polygon.fill = am4core.color(\"#fff\");\r\n * chart.backgroundSeries.mapPolygons.template.polygon.fillOpacity = 0.1;\r\n * ```\r\n * ```JavaScript\r\n * chart.backgroundSeries.mapPolygons.template.polygon.fill = am4core.color(\"#fff\");\r\n * chart.backgroundSeries.mapPolygons.template.polygon.fillOpacity = 0.1;\r\n * ```\r\n * ```JSON\r\n * {\r\n * \"backgroundSeries\": {\r\n * \"mapPolygons\": {\r\n * \"polygon\": {\r\n * \"fill\": \"#fff\",\r\n * \"fillOpacity\": 0.1\r\n * }\r\n * }\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @since 4.3.0\r\n */\r\n get: function () {\r\n var _this = this;\r\n if (!this._backgroundSeries) {\r\n var backgroundSeries = new MapPolygonSeries();\r\n backgroundSeries.parent = this.seriesContainer;\r\n backgroundSeries.chart = this;\r\n backgroundSeries.hiddenInLegend = true;\r\n backgroundSeries.mapPolygons.template.focusable = false;\r\n backgroundSeries.addDisposer(new Disposer(function () {\r\n _this._backgroundSeries = undefined;\r\n }));\r\n this._disposers.push(backgroundSeries);\r\n var interfaceColors = new InterfaceColorSet();\r\n var color = interfaceColors.getFor(\"background\");\r\n var polygonTemplate = backgroundSeries.mapPolygons.template.polygon;\r\n polygonTemplate.stroke = color;\r\n polygonTemplate.fill = color;\r\n polygonTemplate.fillOpacity = 0;\r\n polygonTemplate.strokeOpacity = 0;\r\n //polygonTemplate.focusable = false;\r\n backgroundSeries.mapPolygons.create();\r\n this._backgroundSeries = backgroundSeries;\r\n }\r\n return this._backgroundSeries;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Prepares the legend instance for use in this chart.\r\n *\r\n * @param legend Legend\r\n */\r\n MapChart.prototype.setLegend = function (legend) {\r\n _super.prototype.setLegend.call(this, legend);\r\n if (legend) {\r\n legend.parent = this;\r\n }\r\n };\r\n /**\r\n * @param value Tap to activate?\r\n */\r\n MapChart.prototype.setTapToActivate = function (value) {\r\n _super.prototype.setTapToActivate.call(this, value);\r\n // setup other containers\r\n this.seriesContainer.interactions.isTouchProtected = true;\r\n this.panSprite.interactions.isTouchProtected = true;\r\n };\r\n MapChart.prototype.handleTapToActivate = function () {\r\n _super.prototype.handleTapToActivate.call(this);\r\n this.seriesContainer.interactions.isTouchProtected = false;\r\n this.panSprite.interactions.isTouchProtected = false;\r\n };\r\n MapChart.prototype.handleTapToActivateDeactivation = function () {\r\n _super.prototype.handleTapToActivateDeactivation.call(this);\r\n this.seriesContainer.interactions.isTouchProtected = true;\r\n this.panSprite.interactions.isTouchProtected = true;\r\n };\r\n /**\r\n * Adds easing functions to \"function\" fields.\r\n *\r\n * @param field Field name\r\n * @return Assign as function?\r\n */\r\n MapChart.prototype.asFunction = function (field) {\r\n return field == \"zoomEasing\" || _super.prototype.asIs.call(this, field);\r\n };\r\n /**\r\n * @ignore\r\n * @return Has license?\r\n */\r\n MapChart.prototype.hasLicense = function () {\r\n if (options.commercialLicense) {\r\n return true;\r\n }\r\n if (!_super.prototype.hasLicense.call(this)) {\r\n return false;\r\n }\r\n for (var i = 0; i < options.licenses.length; i++) {\r\n if (options.licenses[i].match(/^MP.{5,}/i)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n };\r\n return MapChart;\r\n}(SerialChart));\r\nexport { MapChart };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"MapChart\"] = MapChart;\r\n//# sourceMappingURL=MapChart.js.map","/**\r\n * Map spline module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { MapLine } from \"./MapLine\";\r\nimport { Polyspline } from \"../../core/elements/Polyspline\";\r\nimport { registry } from \"../../core/Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Used to draw a spline on the map.\r\n *\r\n * @see {@link IMapSplineEvents} for a list of available events\r\n * @see {@link IMapSplineAdapters} for a list of available Adapters\r\n */\r\nvar MapSpline = /** @class */ (function (_super) {\r\n __extends(MapSpline, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapSpline() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"MapSpline\";\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * @ignore\r\n */\r\n MapSpline.prototype.createLine = function () {\r\n this.line = new Polyspline();\r\n this.line.tensionX = 0.8;\r\n this.line.tensionY = 0.8;\r\n };\r\n Object.defineProperty(MapSpline.prototype, \"shortestDistance\", {\r\n /**\r\n * ShortestDistance = true is not supported by MapSpline, only MapLine does support it\r\n * @default false\r\n * @param value\r\n * @todo: review description\r\n */\r\n get: function () {\r\n return false;\r\n },\r\n set: function (value) {\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return MapSpline;\r\n}(MapLine));\r\nexport { MapSpline };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"MapSpline\"] = MapSpline;\r\n//# sourceMappingURL=MapSpline.js.map","/**\r\n * Map arched line module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { MapLine } from \"./MapLine\";\r\nimport { Polyarc } from \"../../core/elements/Polyarc\";\r\nimport { registry } from \"../../core/Registry\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Used to draw an arched line on the map.\r\n *\r\n * @see {@link IMapArcEvents} for a list of available events\r\n * @see {@link IMapArcAdapters} for a list of available Adapters\r\n */\r\nvar MapArc = /** @class */ (function (_super) {\r\n __extends(MapArc, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapArc() {\r\n var _this = \r\n // Init\r\n _super.call(this) || this;\r\n _this.className = \"MapArc\";\r\n // Apply theme\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * @ignore\r\n */\r\n MapArc.prototype.createLine = function () {\r\n this.line = new Polyarc();\r\n };\r\n Object.defineProperty(MapArc.prototype, \"shortestDistance\", {\r\n get: function () {\r\n return false;\r\n },\r\n /**\r\n * `shortestDistance = true` is not supported by `MapArc`.\r\n *\r\n * Only [[MapLine]] supports it.\r\n *\r\n * @default false\r\n * @param value\r\n */\r\n set: function (value) {\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return MapArc;\r\n}(MapLine));\r\nexport { MapArc };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"MapArc\"] = MapArc;\r\n//# sourceMappingURL=MapArc.js.map","/**\r\n * Map spline series module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { MapLineSeries, MapLineSeriesDataItem } from \"./MapLineSeries\";\r\nimport { MapSpline } from \"./MapSpline\";\r\nimport { registry } from \"../../core/Registry\";\r\n/**\r\n * ============================================================================\r\n * DATA ITEM\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines a [[DataItem]] for [[MapSplineSeries]]\r\n * @see {@link DataItem}\r\n */\r\nvar MapSplineSeriesDataItem = /** @class */ (function (_super) {\r\n __extends(MapSplineSeriesDataItem, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapSplineSeriesDataItem() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"MapSplineSeriesDataItem\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n return MapSplineSeriesDataItem;\r\n}(MapLineSeriesDataItem));\r\nexport { MapSplineSeriesDataItem };\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A series of map spline elements.\r\n *\r\n * @see {@link IMapSplineSeriesEvents} for a list of available Events\r\n * @see {@link IMapSplineSeriesAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar MapSplineSeries = /** @class */ (function (_super) {\r\n __extends(MapSplineSeries, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapSplineSeries() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"MapSplineSeries\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Returns a new/empty DataItem of the type appropriate for this object.\r\n *\r\n * @see {@link DataItem}\r\n * @return Data Item\r\n */\r\n MapSplineSeries.prototype.createDataItem = function () {\r\n return new MapSplineSeriesDataItem();\r\n };\r\n /**\r\n * Returns a new line instance of suitable type.\r\n *\r\n * @return New line\r\n */\r\n MapSplineSeries.prototype.createLine = function () {\r\n return new MapSpline();\r\n };\r\n return MapSplineSeries;\r\n}(MapLineSeries));\r\nexport { MapSplineSeries };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"MapSplineSeries\"] = MapSplineSeries;\r\nregistry.registeredClasses[\"MapSplineSeriesDataItem\"] = MapSplineSeriesDataItem;\r\n//# sourceMappingURL=MapSplineSeries.js.map","/**\r\n * Map arc series module.\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { MapLineSeries, MapLineSeriesDataItem } from \"./MapLineSeries\";\r\nimport { MapArc } from \"./MapArc\";\r\nimport { registry } from \"../../core/Registry\";\r\n/**\r\n * ============================================================================\r\n * DATA ITEM\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Defines a [[DataItem]] for [[MapArcSeries]].\r\n *\r\n * @see {@link DataItem}\r\n */\r\nvar MapArcSeriesDataItem = /** @class */ (function (_super) {\r\n __extends(MapArcSeriesDataItem, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapArcSeriesDataItem() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"MapArcSeriesDataItem\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n return MapArcSeriesDataItem;\r\n}(MapLineSeriesDataItem));\r\nexport { MapArcSeriesDataItem };\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * A series of arc elements. (curved lines)\r\n *\r\n * @see {@link IMapArcSeriesEvents} for a list of available Events\r\n * @see {@link IMapArcSeriesAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar MapArcSeries = /** @class */ (function (_super) {\r\n __extends(MapArcSeries, _super);\r\n /**\r\n * Constructor\r\n */\r\n function MapArcSeries() {\r\n var _this = _super.call(this) || this;\r\n _this.className = \"MapArcSeries\";\r\n _this.applyTheme();\r\n return _this;\r\n }\r\n /**\r\n * Returns a new/empty DataItem of the type appropriate for this object.\r\n *\r\n * @see {@link DataItem}\r\n * @return Data Item\r\n */\r\n MapArcSeries.prototype.createDataItem = function () {\r\n return new MapArcSeriesDataItem();\r\n };\r\n /**\r\n * Returns a new line instance of suitable type.\r\n *\r\n * @return New line\r\n */\r\n MapArcSeries.prototype.createLine = function () {\r\n return new MapArc();\r\n };\r\n return MapArcSeries;\r\n}(MapLineSeries));\r\nexport { MapArcSeries };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"MapArcSeries\"] = MapArcSeries;\r\nregistry.registeredClasses[\"MapArcSeriesDataItem\"] = MapArcSeriesDataItem;\r\n//# sourceMappingURL=MapArcSeries.js.map","/**\r\n * Zoom control module\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Container } from \"../../core/Container\";\r\nimport { Button } from \"../../core/elements/Button\";\r\nimport { RoundedRectangle } from \"../../core/elements/RoundedRectangle\";\r\nimport { MutableValueDisposer, MultiDisposer } from \"../../core/utils/Disposer\";\r\nimport { keyboard } from \"../../core/utils/Keyboard\";\r\nimport { getInteraction } from \"../../core/interaction/Interaction\";\r\nimport { percent } from \"../../core/utils/Percent\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { InterfaceColorSet } from \"../../core/utils/InterfaceColorSet\";\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n/**\r\n * Creates a control for zooming the map.\r\n *\r\n * @see {@link IZoomControlEvents} for a list of available events\r\n * @see {@link IZoomControlAdapters} for a list of available Adapters\r\n * @important\r\n */\r\nvar ZoomControl = /** @class */ (function (_super) {\r\n __extends(ZoomControl, _super);\r\n /**\r\n * Constructor\r\n */\r\n function ZoomControl() {\r\n var _this = _super.call(this) || this;\r\n /**\r\n * A target map.\r\n */\r\n _this._chart = new MutableValueDisposer();\r\n _this.className = \"ZoomControl\";\r\n _this.align = \"right\";\r\n _this.valign = \"bottom\";\r\n _this.layout = \"vertical\";\r\n _this.padding(5, 5, 5, 5);\r\n var interfaceColors = new InterfaceColorSet();\r\n var plusButton = _this.createChild(Button);\r\n plusButton.shouldClone = false;\r\n plusButton.label.text = \"+\";\r\n //plusButton.fontFamily = \"Verdana\";\r\n _this.plusButton = plusButton;\r\n var slider = _this.createChild(Container);\r\n slider.shouldClone = false;\r\n slider.background.fill = interfaceColors.getFor(\"alternativeBackground\");\r\n slider.background.fillOpacity = 0.05;\r\n slider.background.events.on(\"hit\", _this.handleBackgroundClick, _this, false);\r\n slider.events.on(\"sizechanged\", _this.updateThumbSize, _this, false);\r\n _this.slider = slider;\r\n var thumb = slider.createChild(Button);\r\n thumb.shouldClone = false;\r\n thumb.padding(0, 0, 0, 0);\r\n thumb.draggable = true;\r\n thumb.events.on(\"drag\", _this.handleThumbDrag, _this, false);\r\n _this.thumb = thumb;\r\n var minusButton = _this.createChild(Button);\r\n minusButton.shouldClone = false;\r\n minusButton.label.text = \"-\";\r\n //minusButton.fontFamily = \"Verdana\";\r\n _this.minusButton = minusButton;\r\n // Set roles\r\n _this.thumb.role = \"slider\";\r\n _this.thumb.readerLive = \"polite\";\r\n // Set reader text\r\n _this.thumb.readerTitle = _this.language.translate(\"Use arrow keys to zoom in and out\");\r\n _this.minusButton.readerTitle = _this.language.translate(\"Press ENTER to zoom in\");\r\n _this.plusButton.readerTitle = _this.language.translate(\"Press ENTER to zoom out\");\r\n _this.applyTheme();\r\n _this.events.on(\"propertychanged\", function (event) {\r\n if (event.property == \"layout\") {\r\n _this.fixLayout();\r\n }\r\n }, undefined, false);\r\n _this._disposers.push(_this._chart);\r\n _this.fixLayout();\r\n return _this;\r\n }\r\n /**\r\n * @ignore\r\n */\r\n ZoomControl.prototype.fixLayout = function () {\r\n var plusButton = this.plusButton;\r\n var minusButton = this.minusButton;\r\n var thumb = this.thumb;\r\n var slider = this.slider;\r\n plusButton.x = undefined;\r\n plusButton.y = undefined;\r\n minusButton.x = undefined;\r\n minusButton.y = undefined;\r\n thumb.x = undefined;\r\n thumb.y = undefined;\r\n slider.x = undefined;\r\n slider.y = undefined;\r\n plusButton.padding(6, 10, 6, 10);\r\n minusButton.padding(6, 10, 6, 10);\r\n minusButton.label.align = \"center\";\r\n minusButton.label.valign = \"middle\";\r\n plusButton.label.align = \"center\";\r\n plusButton.label.valign = \"middle\";\r\n if (this.layout == \"vertical\") {\r\n this.width = 40;\r\n this.height = undefined;\r\n minusButton.width = percent(100);\r\n minusButton.height = undefined;\r\n thumb.width = percent(100);\r\n thumb.height = undefined;\r\n plusButton.width = percent(100);\r\n plusButton.height = undefined;\r\n slider.width = percent(100);\r\n minusButton.marginTop = 1;\r\n plusButton.marginBottom = 2;\r\n slider.height = 0;\r\n minusButton.toFront();\r\n plusButton.toBack();\r\n thumb.minX = 0;\r\n thumb.maxX = 0;\r\n thumb.minY = 0;\r\n }\r\n else if (this.layout == \"horizontal\") {\r\n this.height = 40;\r\n this.width = undefined;\r\n minusButton.height = percent(100);\r\n minusButton.width = undefined;\r\n plusButton.height = percent(100);\r\n plusButton.width = undefined;\r\n thumb.height = percent(100);\r\n thumb.width = undefined;\r\n thumb.minX = 0;\r\n thumb.minY = 0;\r\n thumb.maxY = 0;\r\n slider.height = percent(100);\r\n slider.width = 0;\r\n minusButton.toBack();\r\n plusButton.toFront();\r\n }\r\n };\r\n /**\r\n * Handles zoom operation after clicking on the slider background.\r\n *\r\n * @ignore Exclude from docs\r\n * @param event Event\r\n */\r\n ZoomControl.prototype.handleBackgroundClick = function (event) {\r\n var sprite = event.target;\r\n var y = event.spritePoint.y;\r\n var chart = this.chart;\r\n var maxPower = Math.log(chart.maxZoomLevel) / Math.LN2;\r\n var minPower = Math.log(chart.minZoomLevel) / Math.LN2;\r\n var power = (sprite.pixelHeight - y) / sprite.pixelHeight * (minPower + (maxPower - minPower));\r\n var zoomLevel = Math.pow(2, power);\r\n chart.zoomToGeoPoint(chart.zoomGeoPoint, zoomLevel);\r\n };\r\n Object.defineProperty(ZoomControl.prototype, \"chart\", {\r\n /**\r\n * @return Map/chart\r\n */\r\n get: function () {\r\n return this._chart.get();\r\n },\r\n /**\r\n * A main chart/map that this zoom control is for.\r\n *\r\n * @param chart Map/chart\r\n */\r\n set: function (chart) {\r\n var _this = this;\r\n this._chart.set(chart, new MultiDisposer([\r\n chart.events.on(\"maxsizechanged\", this.updateThumbSize, this, false),\r\n chart.events.on(\"zoomlevelchanged\", this.updateThumb, this, false),\r\n this.minusButton.events.on(\"hit\", function () { chart.zoomOut(chart.zoomGeoPoint); }, chart, false),\r\n getInteraction().body.events.on(\"keyup\", function (ev) {\r\n if (_this.topParent.hasFocused) {\r\n // ENTER is now handled globally\r\n if (keyboard.isKey(ev.event, \"plus\")) {\r\n chart.zoomIn();\r\n }\r\n else if (keyboard.isKey(ev.event, \"minus\")) {\r\n chart.zoomOut();\r\n }\r\n }\r\n }, chart),\r\n this.plusButton.events.on(\"hit\", function () { chart.zoomIn(chart.zoomGeoPoint); }, chart, false)\r\n ]));\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Updates the slider's thumb size based on the available zoom space.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n ZoomControl.prototype.updateThumbSize = function () {\r\n var chart = this.chart;\r\n if (chart) {\r\n var slider = this.slider;\r\n var thumb = this.thumb;\r\n if (this.layout == \"vertical\") {\r\n thumb.minHeight = Math.min(this.slider.pixelHeight, 20);\r\n thumb.height = slider.pixelHeight / this.stepCount;\r\n thumb.maxY = slider.pixelHeight - thumb.pixelHeight;\r\n if (thumb.pixelHeight <= 1) {\r\n thumb.visible = false;\r\n }\r\n else {\r\n thumb.visible = true;\r\n }\r\n }\r\n else {\r\n thumb.minWidth = Math.min(this.slider.pixelWidth, 20);\r\n thumb.width = slider.pixelWidth / this.stepCount;\r\n thumb.maxX = slider.pixelWidth - thumb.pixelWidth;\r\n if (thumb.pixelWidth <= 1) {\r\n thumb.visible = false;\r\n }\r\n else {\r\n thumb.visible = true;\r\n }\r\n }\r\n }\r\n };\r\n /**\r\n * Updates thumb according to current zoom position from map.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n ZoomControl.prototype.updateThumb = function () {\r\n var slider = this.slider;\r\n var chart = this.chart;\r\n var thumb = this.thumb;\r\n if (!thumb.isDown) {\r\n var step = (Math.log(chart.zoomLevel) - Math.log(this.chart.minZoomLevel)) / Math.LN2;\r\n if (this.layout == \"vertical\") {\r\n thumb.y = slider.pixelHeight - (slider.pixelHeight - thumb.pixelHeight) * step / this.stepCount - thumb.pixelHeight;\r\n }\r\n else {\r\n thumb.x = slider.pixelWidth * step / this.stepCount;\r\n }\r\n }\r\n };\r\n /**\r\n * Zooms the actual map when slider position changes.\r\n *\r\n * @ignore Exclude from docs\r\n */\r\n ZoomControl.prototype.handleThumbDrag = function () {\r\n var slider = this.slider;\r\n var chart = this.chart;\r\n var thumb = this.thumb;\r\n var step;\r\n var minStep = Math.log(this.chart.minZoomLevel) / Math.LN2;\r\n if (this.layout == \"vertical\") {\r\n step = this.stepCount * (slider.pixelHeight - thumb.pixelY - thumb.pixelHeight) / (slider.pixelHeight - thumb.pixelHeight);\r\n }\r\n else {\r\n step = this.stepCount * thumb.pixelX / slider.pixelWidth;\r\n }\r\n step = minStep + step;\r\n var zoomLevel = Math.pow(2, step);\r\n chart.zoomToGeoPoint(undefined, zoomLevel, false, 0);\r\n };\r\n Object.defineProperty(ZoomControl.prototype, \"stepCount\", {\r\n /**\r\n * Returns the step countfor the slider grid according to map's min and max\r\n * zoom level settings.\r\n *\r\n * @ignore Exclude from docs\r\n * @return Step count\r\n */\r\n get: function () {\r\n return Math.log(this.chart.maxZoomLevel) / Math.LN2 - Math.log(this.chart.minZoomLevel) / Math.LN2;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Creates a background element for slider control.\r\n *\r\n * @ignore Exclude from docs\r\n * @return Background\r\n */\r\n ZoomControl.prototype.createBackground = function () {\r\n return new RoundedRectangle();\r\n };\r\n return ZoomControl;\r\n}(Container));\r\nexport { ZoomControl };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"ZoomControl\"] = ZoomControl;\r\n//# sourceMappingURL=ZoomControl.js.map","import {atan, exp, halfPi, log, pi, tan, tau} from \"../math.js\";\nimport rotation from \"../rotation.js\";\nimport projection from \"./index.js\";\n\nexport function mercatorRaw(lambda, phi) {\n return [lambda, log(tan((halfPi + phi) / 2))];\n}\n\nmercatorRaw.invert = function(x, y) {\n return [x, 2 * atan(exp(y)) - halfPi];\n};\n\nexport default function() {\n return mercatorProjection(mercatorRaw)\n .scale(961 / tau);\n}\n\nexport function mercatorProjection(project) {\n var m = projection(project),\n center = m.center,\n scale = m.scale,\n translate = m.translate,\n clipExtent = m.clipExtent,\n x0 = null, y0, x1, y1; // clip extent\n\n m.scale = function(_) {\n return arguments.length ? (scale(_), reclip()) : scale();\n };\n\n m.translate = function(_) {\n return arguments.length ? (translate(_), reclip()) : translate();\n };\n\n m.center = function(_) {\n return arguments.length ? (center(_), reclip()) : center();\n };\n\n m.clipExtent = function(_) {\n return arguments.length ? ((_ == null ? x0 = y0 = x1 = y1 = null : (x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1])), reclip()) : x0 == null ? null : [[x0, y0], [x1, y1]];\n };\n\n function reclip() {\n var k = pi * scale(),\n t = m(rotation(m.rotate()).invert([0, 0]));\n return clipExtent(x0 == null\n ? [[t[0] - k, t[1] - k], [t[0] + k, t[1] + k]] : project === mercatorRaw\n ? [[Math.max(t[0] - k, x0), y0], [Math.min(t[0] + k, x1), y1]]\n : [[x0, Math.max(t[1] - k, y0)], [x1, Math.min(t[1] + k, y1)]]);\n }\n\n return reclip();\n}\n","/**\r\n * Functionality for Mercator projection\r\n *\r\n * The function(s) below are from D3.js library (https://d3js.org/)\r\n *\r\n * ```\r\n * Copyright 2017 Mike Bostock\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * 1. Redistributions of source code must retain the above copyright notice,\r\n * this list of conditions and the following disclaimer.\r\n *\r\n * 2. Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * 3. Neither the name of the copyright holder nor the names of its\r\n * contributors may be used to endorse or promote products derived from this\r\n * software without specific prior written permission.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n * ```\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Projection } from \"./Projection\";\r\nimport { registry } from \"../../../core/Registry\";\r\nimport * as d3geo from \"d3-geo\";\r\n/**\r\n * Mercator projection.\r\n */\r\nvar Mercator = /** @class */ (function (_super) {\r\n __extends(Mercator, _super);\r\n function Mercator() {\r\n var _this = _super.call(this) || this;\r\n _this.d3Projection = d3geo.geoMercator();\r\n return _this;\r\n }\r\n return Mercator;\r\n}(Projection));\r\nexport { Mercator };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Mercator\"] = Mercator;\r\n//# sourceMappingURL=Mercator.js.map","export var abs = Math.abs;\nexport var atan = Math.atan;\nexport var atan2 = Math.atan2;\nexport var ceil = Math.ceil;\nexport var cos = Math.cos;\nexport var exp = Math.exp;\nexport var floor = Math.floor;\nexport var log = Math.log;\nexport var max = Math.max;\nexport var min = Math.min;\nexport var pow = Math.pow;\nexport var round = Math.round;\nexport var sign = Math.sign || function(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; };\nexport var sin = Math.sin;\nexport var tan = Math.tan;\n\nexport var epsilon = 1e-6;\nexport var epsilon2 = 1e-12;\nexport var pi = Math.PI;\nexport var halfPi = pi / 2;\nexport var quarterPi = pi / 4;\nexport var sqrt1_2 = Math.SQRT1_2;\nexport var sqrt2 = sqrt(2);\nexport var sqrtPi = sqrt(pi);\nexport var tau = pi * 2;\nexport var degrees = 180 / pi;\nexport var radians = pi / 180;\n\nexport function sinci(x) {\n return x ? x / Math.sin(x) : 1;\n}\n\nexport function asin(x) {\n return x > 1 ? halfPi : x < -1 ? -halfPi : Math.asin(x);\n}\n\nexport function acos(x) {\n return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);\n}\n\nexport function sqrt(x) {\n return x > 0 ? Math.sqrt(x) : 0;\n}\n\nexport function tanh(x) {\n x = exp(2 * x);\n return (x - 1) / (x + 1);\n}\n\nexport function sinh(x) {\n return (exp(x) - exp(-x)) / 2;\n}\n\nexport function cosh(x) {\n return (exp(x) + exp(-x)) / 2;\n}\n\nexport function arsinh(x) {\n return log(x + sqrt(x * x + 1));\n}\n\nexport function arcosh(x) {\n return log(x + sqrt(x * x - 1));\n}\n","import {geoProjection as projection} from \"d3-geo\";\nimport {atan, exp, log, quarterPi, pi, tan} from \"./math.js\";\n\nexport function millerRaw(lambda, phi) {\n return [lambda, 1.25 * log(tan(quarterPi + 0.4 * phi))];\n}\n\nmillerRaw.invert = function(x, y) {\n return [x, 2.5 * atan(exp(0.8 * y)) - 0.625 * pi];\n};\n\nexport default function() {\n return projection(millerRaw)\n .scale(108.318);\n}\n","/**\r\n * Functionality for Miller projection\r\n *\r\n * The function(s) below are from D3.js library (https://d3js.org/)\r\n *\r\n * ```\r\n * Copyright 2017 Mike Bostock\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * 1. Redistributions of source code must retain the above copyright notice,\r\n * this list of conditions and the following disclaimer.\r\n *\r\n * 2. Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * 3. Neither the name of the copyright holder nor the names of its\r\n * contributors may be used to endorse or promote products derived from this\r\n * software without specific prior written permission.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n * ```\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Projection } from \"./Projection\";\r\nimport { registry } from \"../../../core/Registry\";\r\n// @ts-ignore\r\nimport * as d3geoprojection from \"d3-geo-projection\";\r\n/**\r\n * Miller projection.\r\n */\r\nvar Miller = /** @class */ (function (_super) {\r\n __extends(Miller, _super);\r\n function Miller() {\r\n var _this = _super.call(this) || this;\r\n _this.d3Projection = d3geoprojection.geoMiller();\r\n return _this;\r\n }\r\n return Miller;\r\n}(Projection));\r\nexport { Miller };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Miller\"] = Miller;\r\n//# sourceMappingURL=Miller.js.map","import {geoProjection as projection} from \"d3-geo\";\nimport {abs, asin, cos, epsilon, halfPi, pi, sin, sqrt} from \"./math.js\";\n\nexport function eckert6Raw(lambda, phi) {\n var k = (1 + halfPi) * sin(phi);\n for (var i = 0, delta = Infinity; i < 10 && abs(delta) > epsilon; i++) {\n phi -= delta = (phi + sin(phi) - k) / (1 + cos(phi));\n }\n k = sqrt(2 + pi);\n return [\n lambda * (1 + cos(phi)) / k,\n 2 * phi / k\n ];\n}\n\neckert6Raw.invert = function(x, y) {\n var j = 1 + halfPi,\n k = sqrt(j / 2);\n return [\n x * 2 * k / (1 + cos(y *= k)),\n asin((y + sin(y)) / j)\n ];\n};\n\nexport default function() {\n return projection(eckert6Raw)\n .scale(173.044);\n}\n","/**\r\n * Functionality for Eckert6 projection\r\n *\r\n * The function(s) below are from D3.js library (https://d3js.org/)\r\n *\r\n * ```\r\n * Copyright 2017 Mike Bostock\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * 1. Redistributions of source code must retain the above copyright notice,\r\n * this list of conditions and the following disclaimer.\r\n *\r\n * 2. Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * 3. Neither the name of the copyright holder nor the names of its\r\n * contributors may be used to endorse or promote products derived from this\r\n * software without specific prior written permission.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n * ```\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Projection } from \"./Projection\";\r\nimport { registry } from \"../../../core/Registry\";\r\n// @ts-ignore\r\nimport * as d3geoprojection from \"d3-geo-projection\";\r\n/**\r\n * Eckert6 projection.\r\n */\r\nvar Eckert6 = /** @class */ (function (_super) {\r\n __extends(Eckert6, _super);\r\n function Eckert6() {\r\n var _this = _super.call(this) || this;\r\n _this.d3Projection = d3geoprojection.geoEckert6();\r\n return _this;\r\n }\r\n return Eckert6;\r\n}(Projection));\r\nexport { Eckert6 };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Eckert6\"] = Eckert6;\r\n//# sourceMappingURL=Eckert6.js.map","import {asin, atan2, cos, sin, sqrt} from \"../math.js\";\n\nexport function azimuthalRaw(scale) {\n return function(x, y) {\n var cx = cos(x),\n cy = cos(y),\n k = scale(cx * cy);\n if (k === Infinity) return [2, 0];\n return [\n k * cy * sin(x),\n k * sin(y)\n ];\n }\n}\n\nexport function azimuthalInvert(angle) {\n return function(x, y) {\n var z = sqrt(x * x + y * y),\n c = angle(z),\n sc = sin(c),\n cc = cos(c);\n return [\n atan2(x * sc, z * cc),\n asin(z && y * sc / z)\n ];\n }\n}\n","import {asin, cos, epsilon, sin} from \"../math.js\";\nimport {azimuthalInvert} from \"./azimuthal.js\";\nimport projection from \"./index.js\";\n\nexport function orthographicRaw(x, y) {\n return [cos(y) * sin(x), sin(y)];\n}\n\northographicRaw.invert = azimuthalInvert(asin);\n\nexport default function() {\n return projection(orthographicRaw)\n .scale(249.5)\n .clipAngle(90 + epsilon);\n}\n","/**\r\n * Functionality for Mercator projection\r\n *\r\n * The function(s) below are from D3.js library (https://d3js.org/)\r\n *\r\n * ```\r\n * Copyright 2017 Mike Bostock\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * 1. Redistributions of source code must retain the above copyright notice,\r\n * this list of conditions and the following disclaimer.\r\n *\r\n * 2. Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * 3. Neither the name of the copyright holder nor the names of its\r\n * contributors may be used to endorse or promote products derived from this\r\n * software without specific prior written permission.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n * ```\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Projection } from \"./Projection\";\r\nimport { registry } from \"../../../core/Registry\";\r\nimport * as d3geo from \"d3-geo\";\r\n/**\r\n * Orthographic projection.\r\n */\r\nvar Orthographic = /** @class */ (function (_super) {\r\n __extends(Orthographic, _super);\r\n function Orthographic() {\r\n var _this = _super.call(this) || this;\r\n _this.d3Projection = d3geo.geoOrthographic();\r\n return _this;\r\n }\r\n return Orthographic;\r\n}(Projection));\r\nexport { Orthographic };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Orthographic\"] = Orthographic;\r\n//# sourceMappingURL=Orthographic.js.map","import {atan, cos, sin} from \"../math.js\";\nimport {azimuthalInvert} from \"./azimuthal.js\";\nimport projection from \"./index.js\";\n\nexport function stereographicRaw(x, y) {\n var cy = cos(y), k = 1 + cos(x) * cy;\n return [cy * sin(x) / k, sin(y) / k];\n}\n\nstereographicRaw.invert = azimuthalInvert(function(z) {\n return 2 * atan(z);\n});\n\nexport default function() {\n return projection(stereographicRaw)\n .scale(250)\n .clipAngle(142);\n}\n","/**\r\n * Functionality for Mercator projection\r\n *\r\n * The function(s) below are from D3.js library (https://d3js.org/)\r\n *\r\n * ```\r\n * Copyright 2017 Mike Bostock\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * 1. Redistributions of source code must retain the above copyright notice,\r\n * this list of conditions and the following disclaimer.\r\n *\r\n * 2. Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * 3. Neither the name of the copyright holder nor the names of its\r\n * contributors may be used to endorse or promote products derived from this\r\n * software without specific prior written permission.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n * ```\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Projection } from \"./Projection\";\r\nimport { registry } from \"../../../core/Registry\";\r\nimport * as d3geo from \"d3-geo\";\r\n/**\r\n * Orthographic projection.\r\n */\r\nvar Stereographic = /** @class */ (function (_super) {\r\n __extends(Stereographic, _super);\r\n function Stereographic() {\r\n var _this = _super.call(this) || this;\r\n _this.d3Projection = d3geo.geoStereographic();\r\n return _this;\r\n }\r\n return Stereographic;\r\n}(Projection));\r\nexport { Stereographic };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Stereographic\"] = Stereographic;\r\n//# sourceMappingURL=Stereographic.js.map","import {abs, asin, atan2, cos, epsilon, pi, sign, sin, sqrt} from \"../math.js\";\nimport {conicProjection} from \"./conic.js\";\nimport {cylindricalEqualAreaRaw} from \"./cylindricalEqualArea.js\";\n\nexport function conicEqualAreaRaw(y0, y1) {\n var sy0 = sin(y0), n = (sy0 + sin(y1)) / 2;\n\n // Are the parallels symmetrical around the Equator?\n if (abs(n) < epsilon) return cylindricalEqualAreaRaw(y0);\n\n var c = 1 + sy0 * (2 * n - sy0), r0 = sqrt(c) / n;\n\n function project(x, y) {\n var r = sqrt(c - 2 * n * sin(y)) / n;\n return [r * sin(x *= n), r0 - r * cos(x)];\n }\n\n project.invert = function(x, y) {\n var r0y = r0 - y,\n l = atan2(x, abs(r0y)) * sign(r0y);\n if (r0y * n < 0)\n l -= pi * sign(x) * sign(r0y);\n return [l / n, asin((c - (x * x + r0y * r0y) * n * n) / (2 * n))];\n };\n\n return project;\n}\n\nexport default function() {\n return conicProjection(conicEqualAreaRaw)\n .scale(155.424)\n .center([0, 33.6442]);\n}\n","import {asin, cos, sin} from \"../math.js\";\n\nexport function cylindricalEqualAreaRaw(phi0) {\n var cosPhi0 = cos(phi0);\n\n function forward(lambda, phi) {\n return [lambda * cosPhi0, sin(phi) / cosPhi0];\n }\n\n forward.invert = function(x, y) {\n return [x / cosPhi0, asin(y * cosPhi0)];\n };\n\n return forward;\n}\n","import {degrees, pi, radians} from \"../math.js\";\nimport {projectionMutator} from \"./index.js\";\n\nexport function conicProjection(projectAt) {\n var phi0 = 0,\n phi1 = pi / 3,\n m = projectionMutator(projectAt),\n p = m(phi0, phi1);\n\n p.parallels = function(_) {\n return arguments.length ? m(phi0 = _[0] * radians, phi1 = _[1] * radians) : [phi0 * degrees, phi1 * degrees];\n };\n\n return p;\n}\n","import conicEqualArea from \"./conicEqualArea.js\";\n\nexport default function() {\n return conicEqualArea()\n .parallels([29.5, 45.5])\n .scale(1070)\n .translate([480, 250])\n .rotate([96, 0])\n .center([-0.6, 38.7]);\n}\n","/**\r\n * Functionality for Mercator projection\r\n *\r\n * The function(s) below are from D3.js library (https://d3js.org/)\r\n *\r\n * ```\r\n * Copyright 2017 Mike Bostock\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * 1. Redistributions of source code must retain the above copyright notice,\r\n * this list of conditions and the following disclaimer.\r\n *\r\n * 2. Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * 3. Neither the name of the copyright holder nor the names of its\r\n * contributors may be used to endorse or promote products derived from this\r\n * software without specific prior written permission.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n * ```\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Projection } from \"./Projection\";\r\nimport { registry } from \"../../../core/Registry\";\r\nimport * as d3geo from \"d3-geo\";\r\n/**\r\n * Orthographic projection.\r\n */\r\nvar Albers = /** @class */ (function (_super) {\r\n __extends(Albers, _super);\r\n function Albers() {\r\n var _this = _super.call(this) || this;\r\n _this.d3Projection = d3geo.geoAlbers();\r\n return _this;\r\n }\r\n return Albers;\r\n}(Projection));\r\nexport { Albers };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Albers\"] = Albers;\r\n//# sourceMappingURL=Albers.js.map","/**\r\n * Functionality for Mercator projection\r\n *\r\n * The function(s) below are from D3.js library (https://d3js.org/)\r\n *\r\n * ```\r\n * Copyright 2017 Mike Bostock\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * 1. Redistributions of source code must retain the above copyright notice,\r\n * this list of conditions and the following disclaimer.\r\n *\r\n * 2. Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * 3. Neither the name of the copyright holder nor the names of its\r\n * contributors may be used to endorse or promote products derived from this\r\n * software without specific prior written permission.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n * ```\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Projection } from \"./Projection\";\r\nimport { registry } from \"../../../core/Registry\";\r\nimport * as d3geo from \"d3-geo\";\r\n/**\r\n * Orthographic projection.\r\n */\r\nvar AlbersUsa = /** @class */ (function (_super) {\r\n __extends(AlbersUsa, _super);\r\n function AlbersUsa() {\r\n var _this = _super.call(this) || this;\r\n _this.d3Projection = d3geo.geoAlbersUsa();\r\n return _this;\r\n }\r\n return AlbersUsa;\r\n}(Projection));\r\nexport { AlbersUsa };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"AlbersUsa\"] = AlbersUsa;\r\n//# sourceMappingURL=AlbersUSA.js.map","import {epsilon} from \"../math.js\";\nimport albers from \"./albers.js\";\nimport conicEqualArea from \"./conicEqualArea.js\";\nimport {fitExtent, fitSize, fitWidth, fitHeight} from \"./fit.js\";\n\n// The projections must have mutually exclusive clip regions on the sphere,\n// as this will avoid emitting interleaving lines and polygons.\nfunction multiplex(streams) {\n var n = streams.length;\n return {\n point: function(x, y) { var i = -1; while (++i < n) streams[i].point(x, y); },\n sphere: function() { var i = -1; while (++i < n) streams[i].sphere(); },\n lineStart: function() { var i = -1; while (++i < n) streams[i].lineStart(); },\n lineEnd: function() { var i = -1; while (++i < n) streams[i].lineEnd(); },\n polygonStart: function() { var i = -1; while (++i < n) streams[i].polygonStart(); },\n polygonEnd: function() { var i = -1; while (++i < n) streams[i].polygonEnd(); }\n };\n}\n\n// A composite projection for the United States, configured by default for\n// 960×500. The projection also works quite well at 960×600 if you change the\n// scale to 1285 and adjust the translate accordingly. The set of standard\n// parallels for each region comes from USGS, which is published here:\n// http://egsc.usgs.gov/isb/pubs/MapProjections/projections.html#albers\nexport default function() {\n var cache,\n cacheStream,\n lower48 = albers(), lower48Point,\n alaska = conicEqualArea().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), alaskaPoint, // EPSG:3338\n hawaii = conicEqualArea().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), hawaiiPoint, // ESRI:102007\n point, pointStream = {point: function(x, y) { point = [x, y]; }};\n\n function albersUsa(coordinates) {\n var x = coordinates[0], y = coordinates[1];\n return point = null,\n (lower48Point.point(x, y), point)\n || (alaskaPoint.point(x, y), point)\n || (hawaiiPoint.point(x, y), point);\n }\n\n albersUsa.invert = function(coordinates) {\n var k = lower48.scale(),\n t = lower48.translate(),\n x = (coordinates[0] - t[0]) / k,\n y = (coordinates[1] - t[1]) / k;\n return (y >= 0.120 && y < 0.234 && x >= -0.425 && x < -0.214 ? alaska\n : y >= 0.166 && y < 0.234 && x >= -0.214 && x < -0.115 ? hawaii\n : lower48).invert(coordinates);\n };\n\n albersUsa.stream = function(stream) {\n return cache && cacheStream === stream ? cache : cache = multiplex([lower48.stream(cacheStream = stream), alaska.stream(stream), hawaii.stream(stream)]);\n };\n\n albersUsa.precision = function(_) {\n if (!arguments.length) return lower48.precision();\n lower48.precision(_), alaska.precision(_), hawaii.precision(_);\n return reset();\n };\n\n albersUsa.scale = function(_) {\n if (!arguments.length) return lower48.scale();\n lower48.scale(_), alaska.scale(_ * 0.35), hawaii.scale(_);\n return albersUsa.translate(lower48.translate());\n };\n\n albersUsa.translate = function(_) {\n if (!arguments.length) return lower48.translate();\n var k = lower48.scale(), x = +_[0], y = +_[1];\n\n lower48Point = lower48\n .translate(_)\n .clipExtent([[x - 0.455 * k, y - 0.238 * k], [x + 0.455 * k, y + 0.238 * k]])\n .stream(pointStream);\n\n alaskaPoint = alaska\n .translate([x - 0.307 * k, y + 0.201 * k])\n .clipExtent([[x - 0.425 * k + epsilon, y + 0.120 * k + epsilon], [x - 0.214 * k - epsilon, y + 0.234 * k - epsilon]])\n .stream(pointStream);\n\n hawaiiPoint = hawaii\n .translate([x - 0.205 * k, y + 0.212 * k])\n .clipExtent([[x - 0.214 * k + epsilon, y + 0.166 * k + epsilon], [x - 0.115 * k - epsilon, y + 0.234 * k - epsilon]])\n .stream(pointStream);\n\n return reset();\n };\n\n albersUsa.fitExtent = function(extent, object) {\n return fitExtent(albersUsa, extent, object);\n };\n\n albersUsa.fitSize = function(size, object) {\n return fitSize(albersUsa, size, object);\n };\n\n albersUsa.fitWidth = function(width, object) {\n return fitWidth(albersUsa, width, object);\n };\n\n albersUsa.fitHeight = function(height, object) {\n return fitHeight(albersUsa, height, object);\n };\n\n function reset() {\n cache = cacheStream = null;\n return albersUsa;\n }\n\n return albersUsa.scale(1070);\n}\n","import projection from \"./index.js\";\nimport {abs, epsilon} from \"../math.js\";\n\nexport function naturalEarth1Raw(lambda, phi) {\n var phi2 = phi * phi, phi4 = phi2 * phi2;\n return [\n lambda * (0.8707 - 0.131979 * phi2 + phi4 * (-0.013791 + phi4 * (0.003971 * phi2 - 0.001529 * phi4))),\n phi * (1.007226 + phi2 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi2 - 0.005916 * phi4)))\n ];\n}\n\nnaturalEarth1Raw.invert = function(x, y) {\n var phi = y, i = 25, delta;\n do {\n var phi2 = phi * phi, phi4 = phi2 * phi2;\n phi -= delta = (phi * (1.007226 + phi2 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi2 - 0.005916 * phi4))) - y) /\n (1.007226 + phi2 * (0.015085 * 3 + phi4 * (-0.044475 * 7 + 0.028874 * 9 * phi2 - 0.005916 * 11 * phi4)));\n } while (abs(delta) > epsilon && --i > 0);\n return [\n x / (0.8707 + (phi2 = phi * phi) * (-0.131979 + phi2 * (-0.013791 + phi2 * phi2 * phi2 * (0.003971 - 0.001529 * phi2)))),\n phi\n ];\n};\n\nexport default function() {\n return projection(naturalEarth1Raw)\n .scale(175.295);\n}\n","/**\r\n * Functionality for Mercator projection\r\n *\r\n * The function(s) below are from D3.js library (https://d3js.org/)\r\n *\r\n * ```\r\n * Copyright 2017 Mike Bostock\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * 1. Redistributions of source code must retain the above copyright notice,\r\n * this list of conditions and the following disclaimer.\r\n *\r\n * 2. Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * 3. Neither the name of the copyright holder nor the names of its\r\n * contributors may be used to endorse or promote products derived from this\r\n * software without specific prior written permission.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n * ```\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Projection } from \"./Projection\";\r\nimport { registry } from \"../../../core/Registry\";\r\nimport * as d3geo from \"d3-geo\";\r\n/**\r\n * Orthographic projection.\r\n */\r\nvar NaturalEarth1 = /** @class */ (function (_super) {\r\n __extends(NaturalEarth1, _super);\r\n function NaturalEarth1() {\r\n var _this = _super.call(this) || this;\r\n _this.d3Projection = d3geo.geoNaturalEarth1();\r\n return _this;\r\n }\r\n return NaturalEarth1;\r\n}(Projection));\r\nexport { NaturalEarth1 };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"NaturalEarth1\"] = NaturalEarth1;\r\n//# sourceMappingURL=NaturalEarth1.js.map","import {asin, sqrt} from \"../math.js\";\nimport {azimuthalRaw, azimuthalInvert} from \"./azimuthal.js\";\nimport projection from \"./index.js\";\n\nexport var azimuthalEqualAreaRaw = azimuthalRaw(function(cxcy) {\n return sqrt(2 / (1 + cxcy));\n});\n\nazimuthalEqualAreaRaw.invert = azimuthalInvert(function(z) {\n return 2 * asin(z / 2);\n});\n\nexport default function() {\n return projection(azimuthalEqualAreaRaw)\n .scale(124.75)\n .clipAngle(180 - 1e-3);\n}\n","/**\r\n * Functionality for Mercator projection\r\n *\r\n * The function(s) below are from D3.js library (https://d3js.org/)\r\n *\r\n * ```\r\n * Copyright 2017 Mike Bostock\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * 1. Redistributions of source code must retain the above copyright notice,\r\n * this list of conditions and the following disclaimer.\r\n *\r\n * 2. Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * 3. Neither the name of the copyright holder nor the names of its\r\n * contributors may be used to endorse or promote products derived from this\r\n * software without specific prior written permission.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n * ```\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Projection } from \"./Projection\";\r\nimport { registry } from \"../../../core/Registry\";\r\nimport * as d3geo from \"d3-geo\";\r\n/**\r\n * Orthographic projection.\r\n */\r\nvar AzimuthalEqualArea = /** @class */ (function (_super) {\r\n __extends(AzimuthalEqualArea, _super);\r\n function AzimuthalEqualArea() {\r\n var _this = _super.call(this) || this;\r\n _this.d3Projection = d3geo.geoAzimuthalEqualArea();\r\n return _this;\r\n }\r\n return AzimuthalEqualArea;\r\n}(Projection));\r\nexport { AzimuthalEqualArea };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"AzimuthalEqualArea\"] = AzimuthalEqualArea;\r\n//# sourceMappingURL=AzimuthalEqualArea.js.map","import projection from \"./index.js\";\nimport {abs, asin, cos, epsilon2, sin, sqrt} from \"../math.js\";\n\nvar A1 = 1.340264,\n A2 = -0.081106,\n A3 = 0.000893,\n A4 = 0.003796,\n M = sqrt(3) / 2,\n iterations = 12;\n\nexport function equalEarthRaw(lambda, phi) {\n var l = asin(M * sin(phi)), l2 = l * l, l6 = l2 * l2 * l2;\n return [\n lambda * cos(l) / (M * (A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2))),\n l * (A1 + A2 * l2 + l6 * (A3 + A4 * l2))\n ];\n}\n\nequalEarthRaw.invert = function(x, y) {\n var l = y, l2 = l * l, l6 = l2 * l2 * l2;\n for (var i = 0, delta, fy, fpy; i < iterations; ++i) {\n fy = l * (A1 + A2 * l2 + l6 * (A3 + A4 * l2)) - y;\n fpy = A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2);\n l -= delta = fy / fpy, l2 = l * l, l6 = l2 * l2 * l2;\n if (abs(delta) < epsilon2) break;\n }\n return [\n M * x * (A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2)) / cos(l),\n asin(sin(l) / M)\n ];\n};\n\nexport default function() {\n return projection(equalEarthRaw)\n .scale(177.158);\n}\n","/**\r\n * Functionality for Mercator projection\r\n *\r\n * The function(s) below are from D3.js library (https://d3js.org/)\r\n *\r\n * ```\r\n * Copyright 2017 Mike Bostock\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * 1. Redistributions of source code must retain the above copyright notice,\r\n * this list of conditions and the following disclaimer.\r\n *\r\n * 2. Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * 3. Neither the name of the copyright holder nor the names of its\r\n * contributors may be used to endorse or promote products derived from this\r\n * software without specific prior written permission.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n * ```\r\n */\r\nimport { __extends } from \"tslib\";\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport { Projection } from \"./Projection\";\r\nimport { registry } from \"../../../core/Registry\";\r\nimport * as d3geo from \"d3-geo\";\r\n/**\r\n * Orthographic projection.\r\n */\r\nvar EqualEarth = /** @class */ (function (_super) {\r\n __extends(EqualEarth, _super);\r\n function EqualEarth() {\r\n var _this = _super.call(this) || this;\r\n _this.d3Projection = d3geo.geoEqualEarth();\r\n return _this;\r\n }\r\n return EqualEarth;\r\n}(Projection));\r\nexport { EqualEarth };\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"EqualEarth\"] = EqualEarth;\r\n//# sourceMappingURL=EqualEarth.js.map","/**\r\n * Tab Component\r\n *\r\n * @file tab.js\r\n */\r\n\r\nimport $ from \"jquery\";\r\nimport Swiper from 'swiper';\r\nimport SwiperCore, { Navigation, Pagination, Autoplay, EffectFade, Controller, Thumbs, Keyboard, Mousewheel } from 'swiper/core';\r\nSwiperCore.use([Navigation, Pagination, Autoplay, EffectFade, Controller, Thumbs, Keyboard, Mousewheel]);\r\n\r\nimport * as am4core from \"@amcharts/amcharts4/core\";\r\nimport * as am4maps from \"@amcharts/amcharts4/maps\";\r\nimport am4geodata_worldLow from \"@amcharts/amcharts4-geodata/worldLow\";\r\nimport am4themes_animated from \"@amcharts/amcharts4/themes/animated\";\r\n\r\nimport 'swiper/swiper-bundle.css';\r\nconst tabs = (() => {\r\n /**\r\n * Default Tab\r\n * Project default tab style\r\n */\r\n const defaultTab = () => {\r\n const tabsBtns = document.querySelectorAll(\".a-tab-item\");\r\n const tabsContents = document.querySelectorAll(\".a-tab-content\");\r\n\r\n\r\n for (let i = 0; i < tabsBtns.length; i += 1) {\r\n tabsBtns[i].addEventListener('click', function (event) {\r\n [].forEach.call(tabsBtns, function (el) {\r\n el.classList.remove('active');\r\n });\r\n tabsBtns[i].classList.toggle(\"active\");\r\n [].forEach.call(tabsContents, function (el) {\r\n el.classList.remove('tab-active');\r\n });\r\n tabsContents[i].classList.toggle(\"tab-active\");\r\n event.preventDefault();\r\n });\r\n }\r\n };\r\n\r\n const defaultTab2 = () => {\r\n const tabsBtns = document.querySelectorAll(\".a-tab-item2\");\r\n const tabsContents = document.querySelectorAll(\".a-tab-content2\");\r\n\r\n\r\n for (let i = 0; i < tabsBtns.length; i += 1) {\r\n tabsBtns[i].addEventListener('click', function (event) {\r\n [].forEach.call(tabsBtns, function (el) {\r\n el.classList.remove('active');\r\n });\r\n tabsBtns[i].classList.toggle(\"active\");\r\n [].forEach.call(tabsContents, function (el) {\r\n el.classList.remove('tab-active');\r\n });\r\n tabsContents[i].classList.toggle(\"tab-active\");\r\n event.preventDefault();\r\n });\r\n }\r\n };\r\n\r\n const defaultTab3 = () => {\r\n const tabsBtns = document.querySelectorAll(\".a-tab-item3\");\r\n const tabsContents = document.querySelectorAll(\".a-tab-content3\");\r\n\r\n\r\n for (let i = 0; i < tabsBtns.length; i += 1) {\r\n tabsBtns[i].addEventListener('click', function (event) {\r\n [].forEach.call(tabsBtns, function (el) {\r\n el.classList.remove('active');\r\n });\r\n tabsBtns[i].classList.toggle(\"active\");\r\n [].forEach.call(tabsContents, function (el) {\r\n el.classList.remove('tab-active');\r\n });\r\n tabsContents[i].classList.toggle(\"tab-active\");\r\n event.preventDefault();\r\n });\r\n }\r\n };\r\n const defaultTab4 = () => {\r\n \r\n\r\n };\r\n\r\n const init = () => {\r\n defaultTab();\r\n defaultTab2();\r\n defaultTab3();\r\n defaultTab4();\r\n };\r\n\r\n return {\r\n init,\r\n };\r\n})();\r\n\r\nexport default tabs;\r\n","/**\r\n * Slider Component\r\n *\r\n * @file slider.js\r\n */\r\n\r\nimport $ from \"jquery\";\r\nimport Swiper from 'swiper';\r\nimport SwiperCore, { Navigation, Pagination, Autoplay, EffectFade, Controller, Thumbs, Keyboard, Mousewheel } from 'swiper/core';\r\nSwiperCore.use([Navigation, Pagination, Autoplay, EffectFade, Controller, Thumbs, Keyboard, Mousewheel]);\r\n\r\nimport 'swiper/swiper-bundle.css';\r\n\r\nconst slider = (() => {\r\n /**\r\n * fullSlider\r\n * Full width slider settings\r\n */\r\n const fullSlider = () => {\r\n const homeSlide = new Swiper('.main-slide', {\r\n effect: 'fade', \r\n fadeEffect: {\r\n crossFade: true\r\n },\r\n speed: 1500,\r\n loop: false,\r\n navigation: {\r\n nextEl: \".main-slide-next\",\r\n prevEl: \".main-slide-prev\",\r\n }\r\n });\r\n };\r\n \r\n const homeNumberCarousel = () => {\r\n var homeNumberCarousel = new Swiper('.number-value-item', {\r\n // direction: 'horizontal',\r\n // mousewheel: {\r\n\t\t\t// \treleaseOnEdges: true,\r\n\t\t\t// },\r\n\t\t\t// touchReleaseOnEdges: true,\r\n slidesPerView: 4.2,\r\n spaceBetween: 25,\r\n loop:false,\r\n navigation: {\r\n nextEl: \".number-sl-next\",\r\n prevEl: \".number-sl-prev\",\r\n },\r\n breakpoints: {\r\n 0: {\r\n slidesPerView: 1.1,\r\n spaceBetween: 15,\r\n },\r\n 768: {\r\n slidesPerView: 2,\r\n spaceBetween: 25,\r\n },\r\n 1024: {\r\n slidesPerView: 3.04,\r\n spaceBetween: 25,\r\n },\r\n 1380: {\r\n slidesPerView: 3.5,\r\n spaceBetween: 25,\r\n },\r\n 1480: {\r\n slidesPerView: 4.2,\r\n spaceBetween: 25,\r\n },\r\n },\r\n });\r\n };\r\n \r\n const homeMobileMapCarousel = () => {\r\n var homeMobileMapCarousel = new Swiper('.mobile-map-list', {\r\n // direction: 'horizontal',\r\n // mousewheel: {\r\n\t\t\t// \treleaseOnEdges: true,\r\n\t\t\t// },\r\n\t\t\t// touchReleaseOnEdges: true,\r\n slidesPerView: 1.2,\r\n spaceBetween: 10,\r\n loop:false,\r\n observer: true,\r\n observeParents: true,\r\n navigation: {\r\n nextEl: \".mb-map-sl-next\",\r\n prevEl: \".mb-map-sl-prev\",\r\n },\r\n breakpoints: {\r\n 0: {\r\n slidesPerView: 1.2,\r\n spaceBetween: 10,\r\n },\r\n 768: {\r\n slidesPerView: 2,\r\n spaceBetween: 10,\r\n },\r\n },\r\n });\r\n };\r\n \r\n const homeJobCarousel = () => {\r\n var homeJobCarousel = new Swiper('.job-value-item-carousel', {\r\n // direction: 'horizontal',\r\n // mousewheel: {\r\n\t\t\t// \treleaseOnEdges: true,\r\n\t\t\t// },\r\n\t\t\t// touchReleaseOnEdges: true,\r\n slidesPerView: 4.3,\r\n spaceBetween: 15,\r\n loop:false,\r\n navigation: {\r\n nextEl: \".job-sl-next\",\r\n prevEl: \".job-sl-prev\",\r\n },\r\n breakpoints: {\r\n 0: {\r\n slidesPerView: 1.2,\r\n spaceBetween: 15,\r\n },\r\n 768: {\r\n slidesPerView: 2,\r\n spaceBetween: 15,\r\n },\r\n 1024: {\r\n slidesPerView: 3.5,\r\n spaceBetween: 15,\r\n },\r\n 1380: {\r\n slidesPerView: 4.1,\r\n spaceBetween: 15,\r\n },\r\n 1480: {\r\n slidesPerView: 4.3,\r\n spaceBetween: 15,\r\n },\r\n },\r\n });\r\n };\r\n \r\n const homecompanyCarousel = () => {\r\n var homecompanyCarousel = new Swiper('.group-company-value-item', {\r\n // direction: 'horizontal',\r\n // mousewheel: {\r\n\t\t\t// \treleaseOnEdges: true,\r\n\t\t\t// },\r\n\t\t\t// touchReleaseOnEdges: true,\r\n slidesPerView: 4.3,\r\n spaceBetween: 40,\r\n loop:false,\r\n navigation: {\r\n nextEl: \".company-sl-next\",\r\n prevEl: \".company-sl-prev\",\r\n },\r\n breakpoints: {\r\n 0: {\r\n slidesPerView: 1.2,\r\n spaceBetween: 15,\r\n },\r\n 768: {\r\n slidesPerView: 2,\r\n spaceBetween: 25,\r\n },\r\n 1024: {\r\n slidesPerView: 3.04,\r\n spaceBetween: 25,\r\n },\r\n 1380: {\r\n slidesPerView: 3.5,\r\n spaceBetween: 25,\r\n },\r\n 1480: {\r\n slidesPerView: 4.3,\r\n spaceBetween: 40,\r\n },\r\n },\r\n });\r\n };\r\n \r\n const videoMainCarousel = () => {\r\n var videoThumbCarousel = new Swiper('.video-container-thumb-slide', {\r\n // direction: 'horizontal',\r\n // mousewheel: {\r\n\t\t\t// \treleaseOnEdges: true,\r\n\t\t\t// },\r\n\t\t\t// touchReleaseOnEdges: true,\r\n slidesPerView: 10,\r\n spaceBetween: 8,\r\n loop:false, \r\n freeMode: true,\r\n breakpoints: {\r\n 0: {\r\n slidesPerView: 4,\r\n spaceBetween: 8,\r\n },\r\n 768: {\r\n slidesPerView: 6,\r\n spaceBetween: 8,\r\n },\r\n 1024: {\r\n slidesPerView: 8,\r\n spaceBetween: 8,\r\n },\r\n 1200: {\r\n slidesPerView: 10,\r\n spaceBetween: 8,\r\n },\r\n },\r\n });\r\n var videoMainCarousel = new Swiper('.video-container-main-slide', {\r\n // direction: 'horizontal',\r\n // mousewheel: {\r\n\t\t\t// \treleaseOnEdges: true,\r\n\t\t\t// },\r\n\t\t\t// touchReleaseOnEdges: true,\r\n slidesPerView: 1,\r\n spaceBetween: 0,\r\n loop:false,\r\n effect: 'fade', \r\n fadeEffect: {\r\n crossFade: true\r\n },\r\n thumbs: {\r\n swiper: videoThumbCarousel,\r\n },\r\n on: {\r\n init: function() {\r\n if($(\"video-container-main-slide .swiper-slide\").length <= 1) {\r\n $(\".video-container-thumb-slide\").hide();\r\n }\r\n }\r\n }\r\n });\r\n };\r\n \r\n const historyCarousel = () => {\r\n const historyTextCarousel = new Swiper('.history-text-carousel', {\r\n // direction: 'horizontal',\r\n // mousewheel: {\r\n\t\t\t// \treleaseOnEdges: true,\r\n\t\t\t// },\r\n\t\t\t// touchReleaseOnEdges: true,\r\n slidesPerView: 1.3,\r\n spaceBetween: 0,\r\n loop: false,\r\n watchSlidesProgress: true,\r\n allowTouchMove: true,\r\n speed:1200,\r\n breakpoints: {\r\n 0: {\r\n slidesPerView: 1.1,\r\n spaceBetween: 15,\r\n },\r\n 768: {\r\n slidesPerView: 1.2,\r\n spaceBetween: 0,\r\n },\r\n 1024: {\r\n slidesPerView: 1.3,\r\n spaceBetween: 0,\r\n },\r\n },\r\n });\r\n historyTextCarousel.on('slideChange', function () {\r\n // console.log(this.realIndex);\r\n historyNumberCarousel.slideTo(this.realIndex)\r\n });\r\n var historyNumberCarousel = new Swiper('.history-number-carousel', {\r\n // direction: 'horizontal',\r\n // mousewheel: {\r\n\t\t\t// \treleaseOnEdges: true,\r\n\t\t\t// },\r\n\t\t\t// touchReleaseOnEdges: true,\r\n slidesPerView: \"auto\",\r\n spaceBetween: 40,\r\n speed:1200,\r\n loop:false,\r\n centeredSlides: true,\r\n slideToClickedSlide: true,\r\n navigation: {\r\n nextEl: \".history-sl-next\",\r\n prevEl: \".history-sl-prev\",\r\n },\r\n thumbs: {\r\n swiper: historyTextCarousel,\r\n },\r\n });\r\n };\r\n \r\n const privilegesCarousel = () => {\r\n const privilegesCarousel = new Swiper('.privileges-carousel ', {\r\n // direction: 'horizontal',\r\n // mousewheel: {\r\n\t\t\t// \treleaseOnEdges: true,\r\n\t\t\t// },\r\n\t\t\t// touchReleaseOnEdges: true,\r\n slidesPerView: 4,\r\n spaceBetween: 35,\r\n loop:false,\r\n navigation: {\r\n nextEl: \".privileges-sl-next\",\r\n prevEl: \".privileges-sl-prev\",\r\n },\r\n breakpoints: {\r\n 0: {\r\n slidesPerView: 1.2,\r\n spaceBetween: 15,\r\n },\r\n 768: {\r\n slidesPerView: 2,\r\n spaceBetween: 25,\r\n },\r\n 1024: {\r\n slidesPerView: 3,\r\n spaceBetween: 25,\r\n },\r\n 1380: {\r\n slidesPerView: 4,\r\n spaceBetween: 25,\r\n },\r\n 1480: {\r\n slidesPerView: 4,\r\n spaceBetween: 35,\r\n },\r\n },\r\n });\r\n };\r\n \r\n const galleryCarousel = () => {\r\n const galleryCarousel = new Swiper('.gallery-carousel ', {\r\n // direction: 'horizontal',\r\n // mousewheel: {\r\n\t\t\t// \treleaseOnEdges: true,\r\n\t\t\t// },\r\n\t\t\t// touchReleaseOnEdges: true,\r\n slidesPerView: 4,\r\n spaceBetween: 40,\r\n loop:false,\r\n centerMode:true,\r\n navigation: {\r\n nextEl: \".gallery-sl-next\",\r\n prevEl: \".gallery-sl-prev\",\r\n },\r\n breakpoints: {\r\n 0: {\r\n slidesPerView: 1.2,\r\n spaceBetween: 15,\r\n },\r\n 768: {\r\n slidesPerView: 2,\r\n spaceBetween: 25,\r\n },\r\n 1024: {\r\n slidesPerView: 3.04,\r\n spaceBetween: 25,\r\n },\r\n 1380: {\r\n slidesPerView: 3.5,\r\n spaceBetween: 25,\r\n },\r\n 1480: {\r\n slidesPerView: 4,\r\n spaceBetween: 40,\r\n },\r\n },\r\n });\r\n const galleryCarouselv3 = new Swiper('.gallery-carousel-w3 ', {\r\n // direction: 'horizontal',\r\n // mousewheel: {\r\n\t\t\t// \treleaseOnEdges: true,\r\n\t\t\t// },\r\n\t\t\t// touchReleaseOnEdges: true,\r\n slidesPerView: 3.1,\r\n spaceBetween: 40,\r\n loop:false,\r\n centerMode:true,\r\n navigation: {\r\n nextEl: \".gallery-v3-sl-next\",\r\n prevEl: \".gallery-v3-sl-prev\",\r\n },\r\n breakpoints: {\r\n 0: {\r\n slidesPerView: 1.2,\r\n spaceBetween: 15,\r\n },\r\n 768: {\r\n slidesPerView: 2,\r\n spaceBetween: 25,\r\n },\r\n 1024: {\r\n slidesPerView: 3.04,\r\n spaceBetween: 25,\r\n },\r\n 1380: {\r\n slidesPerView: 3.5,\r\n spaceBetween: 25,\r\n },\r\n 1480: {\r\n slidesPerView: 3.1,\r\n spaceBetween: 40,\r\n },\r\n },\r\n });\r\n };\r\n \r\n const jobVideoCarousel = () => {\r\n const jobVideoCarousel1 = new Swiper('.job-value-video-carousel-1 ', {\r\n // direction: 'horizontal',\r\n // mousewheel: {\r\n\t\t\t// \treleaseOnEdges: true,\r\n\t\t\t// },\r\n\t\t\t// touchReleaseOnEdges: true,\r\n slidesPerView: 3.1,\r\n spaceBetween: 20,\r\n loop:false,\r\n navigation: {\r\n nextEl: \".job-video-sl-next1\",\r\n prevEl: \".job-video-sl-prev1\",\r\n },\r\n breakpoints: {\r\n 0: {\r\n slidesPerView: 1.2,\r\n spaceBetween: 15,\r\n },\r\n 768: {\r\n slidesPerView: 2,\r\n spaceBetween: 25,\r\n },\r\n 1024: {\r\n slidesPerView: 3.04,\r\n spaceBetween: 25,\r\n },\r\n 1380: {\r\n slidesPerView: 3.5,\r\n spaceBetween: 25,\r\n },\r\n 1480: {\r\n slidesPerView: 3.1,\r\n spaceBetween: 20,\r\n },\r\n },\r\n });\r\n const jobVideoCarousel2 = new Swiper('.job-value-video-carousel-2 ', {\r\n // direction: 'horizontal',\r\n // mousewheel: {\r\n\t\t\t// \treleaseOnEdges: true,\r\n\t\t\t// },\r\n\t\t\t// touchReleaseOnEdges: true,\r\n slidesPerView: 3.1,\r\n spaceBetween: 20,\r\n loop:false,\r\n navigation: {\r\n nextEl: \".job-video-sl-next2\",\r\n prevEl: \".job-video-sl-prev2\",\r\n },\r\n breakpoints: {\r\n 0: {\r\n slidesPerView: 1.2,\r\n spaceBetween: 15,\r\n },\r\n 768: {\r\n slidesPerView: 2,\r\n spaceBetween: 25,\r\n },\r\n 1024: {\r\n slidesPerView: 3.04,\r\n spaceBetween: 25,\r\n },\r\n 1380: {\r\n slidesPerView: 3.5,\r\n spaceBetween: 25,\r\n },\r\n 1480: {\r\n slidesPerView: 3.1,\r\n spaceBetween: 20,\r\n },\r\n },\r\n });\r\n };\r\n\r\n const otherNewsCarousel = () => {\r\n const otherNewsCarousel = new Swiper('.other-news-carousel', {\r\n // direction: 'horizontal',\r\n // mousewheel: {\r\n\t\t\t// \treleaseOnEdges: true,\r\n\t\t\t// },\r\n\t\t\t// touchReleaseOnEdges: true,\r\n slidesPerView: 3,\r\n spaceBetween: 30,\r\n autoplay: {\r\n delay: 5000,\r\n disableOnInteraction: false, \r\n },\r\n navigation: {\r\n nextEl: \".oth-sl-next\",\r\n prevEl: \".oth-sl-prev\",\r\n },\r\n breakpoints: {\r\n 0: {\r\n slidesPerView: 1.2,\r\n spaceBetween: 15,\r\n },\r\n 768: {\r\n slidesPerView: 2,\r\n spaceBetween: 15,\r\n },\r\n 992: {\r\n slidesPerView: 2.5,\r\n spaceBetween: 30,\r\n },\r\n 1100: {\r\n slidesPerView: 3,\r\n spaceBetween: 30,\r\n },\r\n },\r\n });\r\n };\r\n\r\n const init = () => {\r\n fullSlider();\r\n homeNumberCarousel();\r\n homeMobileMapCarousel();\r\n homeJobCarousel();\r\n homecompanyCarousel();\r\n videoMainCarousel();\r\n historyCarousel();\r\n privilegesCarousel();\r\n galleryCarousel();\r\n jobVideoCarousel();\r\n otherNewsCarousel();\r\n };\r\n\r\n return {\r\n init,\r\n };\r\n})();\r\n\r\nexport default slider;\r\n","\r\nimport $ from 'jquery';\r\n\r\nconst accordion = (() => {\r\n const arrowDownBtn = () => {\r\n // $(\".arrow-down-btn\").on(\"click\", function(){\r\n // $('body,html').animate({ scrollTop: $(this).parents(\"section\").next(\"section\").offset().top}, 800);\r\n // });\r\n };\r\n const defaultAccordion = () => {\r\n const accordionItem = document.getElementsByClassName('js-trigger-accordion');\r\n\r\n for (let i = 0; i < accordionItem.length; i += 1) {\r\n accordionItem[i].addEventListener('click', function (event) {\r\n event.currentTarget.classList.toggle('js-active');\r\n const accordionContent = this.nextElementSibling;\r\n accordionContent.classList.toggle('js-active');\r\n });\r\n }\r\n };\r\n \r\n const stickyArrow = () => {\r\n // var scrollTopButton = document.getElementById(\"scrollTopBtn\");\r\n\r\n // window.onscroll = function() {\r\n // scrollFunction();\r\n // };\r\n\r\n // function scrollFunction() {\r\n // if (document.body.scrollTop > 250 || document.documentElement.scrollTop > 250) {\r\n // scrollTopButton.classList.add(\"active\");\r\n // } else {\r\n // scrollTopButton.classList.remove(\"active\");\r\n // }\r\n // }\r\n // scrollTopButton.addEventListener(\"click\", scrollToTop); \r\n // function scrollToTop() {\r\n // scrollToTopAnimation();\r\n // }\r\n\r\n // function scrollToTopAnimation() {\r\n // var currentPosition = document.documentElement.scrollTop || document.body.scrollTop;\r\n\r\n // if (currentPosition > 0) {\r\n // window.requestAnimationFrame(scrollToTopAnimation);\r\n // window.scrollTo(0, currentPosition - currentPosition / 8);\r\n // }\r\n // }\r\n }\r\n\r\n const reservationScroll = () => {\r\n var floatingDiv = document.querySelector('.position-search');\r\n if (floatingDiv) {\r\n var floatingDivParent = document.querySelector(\".position-search\");\r\n var scrollPosition = window.scrollY || document.documentElement.scrollTop;\r\n var scrollFirstPosition = floatingDivParent.offsetTop + floatingDiv.offsetTop - 20;\r\n var scrolldDataPos = floatingDivParent.setAttribute('data-offset-top', scrollFirstPosition);\r\n var scrollDataPosAt = floatingDivParent.getAttribute('data-offset-top');\r\n if (scrollPosition >= scrollDataPosAt) { \r\n floatingDivParent.classList.add('fixed');\r\n } else { \r\n floatingDivParent.classList.remove('fixed');\r\n }\r\n var minWidth = 992;\r\n\r\n // Check if the current window width is less than the threshold\r\n if (window.innerWidth >= minWidth) {\r\n $(window).scroll(function() {\r\n var scrollPosition = window.scrollY || document.documentElement.scrollTop;\r\n if (scrollPosition >= scrollDataPosAt) { \r\n floatingDivParent.classList.add('fixed');\r\n } else { \r\n floatingDivParent.classList.remove('fixed');\r\n }\r\n });\r\n }\r\n } \r\n };\r\n\r\n const filterAccordion = () => {\r\n // document.addEventListener(\"DOMContentLoaded\", function() {\r\n // const accordion = document.getElementById(\"pos-left-menu\");\r\n // if(accordion){\r\n // document.querySelectorAll('.col-sel').forEach(item => {\r\n // item.addEventListener('click', function() {\r\n // const nextElement = this.nextElementSibling;\r\n // if (nextElement && nextElement.classList.contains('col-list')) {\r\n // nextElement.classList.toggle('active'); // Toggle 'active' class\r\n // }\r\n // });\r\n // });\r\n // }\r\n // });\r\n const isMobile = window.matchMedia(\"(max-width: 992px)\");\r\n\r\n // Mobilde click olayını dinle\r\n if (isMobile.matches) {\r\n $(\".col-sel\").on(\"click\", function() {\r\n $(this).next(\".col-list\").toggleClass(\"active\");\r\n });\r\n }\r\n\r\n };\r\n\r\n const activeJobScroll = () => {\r\n if ($('.active-job').is(\":visible\")){\r\n var targetScroll = $('.home-current-job-eksim').offset().top;\r\n $(\".active-job .bt-arr\").on(\"click\", function(){\r\n $('html, body').animate({scrollTop: targetScroll }, 'slow');\r\n });\r\n }\r\n }\r\n\r\n const init = () => {\r\n arrowDownBtn();\r\n defaultAccordion();\r\n stickyArrow();\r\n reservationScroll();\r\n filterAccordion();\r\n activeJobScroll();\r\n };\r\n\r\n return {\r\n init,\r\n };\r\n})();\r\n\r\nexport default accordion;\r\n","import $ from 'jquery';\r\nconst aosAnim = (() => {\r\n\r\n const socialAnim = () => {\r\n var elems = [$('.circle-bg-fb'), $('.circle-bg-tw'), $('.circle-bg-p')];\r\n var cls = [\"circle-bg-fb-end\", \"circle-bg-tw-end\", \"circle-bg-p-end\"];\r\n\r\n $('div#social-holder').on(\"click\", function(){\r\n for(var i=0; i {\r\n socialAnim();\r\n };\r\n\r\n return {\r\n init,\r\n };\r\n})();\r\n\r\nexport default aosAnim;\r\n","const t=(t,e=1e4)=>(t=parseFloat(t+\"\")||0,Math.round((t+Number.EPSILON)*e)/e),e=function(t){if(!(t&&t instanceof Element&&t.offsetParent))return!1;const e=t.scrollHeight>t.clientHeight,i=window.getComputedStyle(t).overflowY,n=-1!==i.indexOf(\"hidden\"),s=-1!==i.indexOf(\"visible\");return e&&!n&&!s},i=function(t,n=void 0){return!(!t||t===document.body||n&&t===n)&&(e(t)?t:i(t.parentElement,n))},n=function(t){var e=(new DOMParser).parseFromString(t,\"text/html\").body;if(e.childElementCount>1){for(var i=document.createElement(\"div\");e.firstChild;)i.appendChild(e.firstChild);return i}return e.firstChild},s=t=>`${t||\"\"}`.split(\" \").filter((t=>!!t)),o=(t,e,i)=>{s(e).forEach((e=>{t&&t.classList.toggle(e,i||!1)}))};class a{constructor(t){Object.defineProperty(this,\"pageX\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"pageY\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"clientX\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"clientY\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"id\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"time\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"nativePointer\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.nativePointer=t,this.pageX=t.pageX,this.pageY=t.pageY,this.clientX=t.clientX,this.clientY=t.clientY,this.id=self.Touch&&t instanceof Touch?t.identifier:-1,this.time=Date.now()}}const r={passive:!1};class l{constructor(t,{start:e=(()=>!0),move:i=(()=>{}),end:n=(()=>{})}){Object.defineProperty(this,\"element\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"startCallback\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"moveCallback\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"endCallback\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"currentPointers\",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,\"startPointers\",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this.element=t,this.startCallback=e,this.moveCallback=i,this.endCallback=n;for(const t of[\"onPointerStart\",\"onTouchStart\",\"onMove\",\"onTouchEnd\",\"onPointerEnd\",\"onWindowBlur\"])this[t]=this[t].bind(this);this.element.addEventListener(\"mousedown\",this.onPointerStart,r),this.element.addEventListener(\"touchstart\",this.onTouchStart,r),this.element.addEventListener(\"touchmove\",this.onMove,r),this.element.addEventListener(\"touchend\",this.onTouchEnd),this.element.addEventListener(\"touchcancel\",this.onTouchEnd)}onPointerStart(t){if(!t.buttons||0!==t.button)return;const e=new a(t);this.currentPointers.some((t=>t.id===e.id))||this.triggerPointerStart(e,t)&&(window.addEventListener(\"mousemove\",this.onMove),window.addEventListener(\"mouseup\",this.onPointerEnd),window.addEventListener(\"blur\",this.onWindowBlur))}onTouchStart(t){for(const e of Array.from(t.changedTouches||[]))this.triggerPointerStart(new a(e),t);window.addEventListener(\"blur\",this.onWindowBlur)}onMove(t){const e=this.currentPointers.slice(),i=\"changedTouches\"in t?Array.from(t.changedTouches||[]).map((t=>new a(t))):[new a(t)],n=[];for(const t of i){const e=this.currentPointers.findIndex((e=>e.id===t.id));e<0||(n.push(t),this.currentPointers[e]=t)}n.length&&this.moveCallback(t,this.currentPointers.slice(),e)}onPointerEnd(t){t.buttons>0&&0!==t.button||(this.triggerPointerEnd(t,new a(t)),window.removeEventListener(\"mousemove\",this.onMove),window.removeEventListener(\"mouseup\",this.onPointerEnd),window.removeEventListener(\"blur\",this.onWindowBlur))}onTouchEnd(t){for(const e of Array.from(t.changedTouches||[]))this.triggerPointerEnd(t,new a(e))}triggerPointerStart(t,e){return!!this.startCallback(e,t,this.currentPointers.slice())&&(this.currentPointers.push(t),this.startPointers.push(t),!0)}triggerPointerEnd(t,e){const i=this.currentPointers.findIndex((t=>t.id===e.id));i<0||(this.currentPointers.splice(i,1),this.startPointers.splice(i,1),this.endCallback(t,e,this.currentPointers.slice()))}onWindowBlur(){this.clear()}clear(){for(;this.currentPointers.length;){const t=this.currentPointers[this.currentPointers.length-1];this.currentPointers.splice(this.currentPointers.length-1,1),this.startPointers.splice(this.currentPointers.length-1,1),this.endCallback(new Event(\"touchend\",{bubbles:!0,cancelable:!0,clientX:t.clientX,clientY:t.clientY}),t,this.currentPointers.slice())}}stop(){this.element.removeEventListener(\"mousedown\",this.onPointerStart,r),this.element.removeEventListener(\"touchstart\",this.onTouchStart,r),this.element.removeEventListener(\"touchmove\",this.onMove,r),this.element.removeEventListener(\"touchend\",this.onTouchEnd),this.element.removeEventListener(\"touchcancel\",this.onTouchEnd),window.removeEventListener(\"mousemove\",this.onMove),window.removeEventListener(\"mouseup\",this.onPointerEnd),window.removeEventListener(\"blur\",this.onWindowBlur)}}function c(t,e){return e?Math.sqrt(Math.pow(e.clientX-t.clientX,2)+Math.pow(e.clientY-t.clientY,2)):0}function h(t,e){return e?{clientX:(t.clientX+e.clientX)/2,clientY:(t.clientY+e.clientY)/2}:t}const d=t=>\"object\"==typeof t&&null!==t&&t.constructor===Object&&\"[object Object]\"===Object.prototype.toString.call(t),u=(t,...e)=>{const i=e.length;for(let n=0;n{const n=Array.isArray(i)?[]:{};t[e]||Object.assign(t,{[e]:n}),d(i)?Object.assign(t[e],u(n,i)):Array.isArray(i)?Object.assign(t,{[e]:[...i]}):Object.assign(t,{[e]:i})}))}return t},p=function(t,e){return t.split(\".\").reduce(((t,e)=>\"object\"==typeof t?t[e]:void 0),e)};class f{constructor(t={}){Object.defineProperty(this,\"options\",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,\"events\",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),this.setOptions(t);for(const t of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))t.startsWith(\"on\")&&\"function\"==typeof this[t]&&(this[t]=this[t].bind(this))}setOptions(t){this.options=t?u({},this.constructor.defaults,t):{};for(const[t,e]of Object.entries(this.option(\"on\")||{}))this.on(t,e)}option(t,...e){let i=p(t,this.options);return i&&\"function\"==typeof i&&(i=i.call(this,this,...e)),i}optionFor(t,e,i,...n){let s=p(e,t);var o;\"string\"!=typeof(o=s)||isNaN(o)||isNaN(parseFloat(o))||(s=parseFloat(s)),\"true\"===s&&(s=!0),\"false\"===s&&(s=!1),s&&\"function\"==typeof s&&(s=s.call(this,this,t,...n));let a=p(e,this.options);return a&&\"function\"==typeof a?s=a.call(this,this,t,...n,s):void 0===s&&(s=a),void 0===s?i:s}cn(t){const e=this.options.classes;return e&&e[t]||\"\"}localize(t,e=[]){t=String(t).replace(/\\{\\{(\\w+).?(\\w+)?\\}\\}/g,((t,e,i)=>{let n=\"\";return i?n=this.option(`${e[0]+e.toLowerCase().substring(1)}.l10n.${i}`):e&&(n=this.option(`l10n.${e}`)),n||(n=t),n}));for(let i=0;ie))}on(t,e){let i=[];\"string\"==typeof t?i=t.split(\" \"):Array.isArray(t)&&(i=t),this.events||(this.events=new Map),i.forEach((t=>{let i=this.events.get(t);i||(this.events.set(t,[]),i=[]),i.includes(e)||i.push(e),this.events.set(t,i)}))}off(t,e){let i=[];\"string\"==typeof t?i=t.split(\" \"):Array.isArray(t)&&(i=t),i.forEach((t=>{const i=this.events.get(t);if(Array.isArray(i)){const t=i.indexOf(e);t>-1&&i.splice(t,1)}}))}emit(t,...e){[...this.events.get(t)||[]].forEach((t=>t(this,...e))),\"*\"!==t&&this.emit(\"*\",t,...e)}}Object.defineProperty(f,\"version\",{enumerable:!0,configurable:!0,writable:!0,value:\"5.0.22\"}),Object.defineProperty(f,\"defaults\",{enumerable:!0,configurable:!0,writable:!0,value:{}});class m extends f{constructor(t={}){super(t),Object.defineProperty(this,\"plugins\",{enumerable:!0,configurable:!0,writable:!0,value:{}})}attachPlugins(t={}){const e=new Map;for(const[i,n]of Object.entries(t)){const t=this.option(i),s=this.plugins[i];s||!1===t?s&&!1===t&&(s.detach(),delete this.plugins[i]):e.set(i,new n(this,t||{}))}for(const[t,i]of e)this.plugins[t]=i,i.attach();this.emit(\"attachPlugins\")}detachPlugins(t){t=t||Object.keys(this.plugins);for(const e of t){const t=this.plugins[e];t&&t.detach(),delete this.plugins[e]}return this.emit(\"detachPlugins\"),this}}var g;!function(t){t[t.Init=0]=\"Init\",t[t.Error=1]=\"Error\",t[t.Ready=2]=\"Ready\",t[t.Panning=3]=\"Panning\",t[t.Mousemove=4]=\"Mousemove\",t[t.Destroy=5]=\"Destroy\"}(g||(g={}));const b=[\"a\",\"b\",\"c\",\"d\",\"e\",\"f\"],v={PANUP:\"Move up\",PANDOWN:\"Move down\",PANLEFT:\"Move left\",PANRIGHT:\"Move right\",ZOOMIN:\"Zoom in\",ZOOMOUT:\"Zoom out\",TOGGLEZOOM:\"Toggle zoom level\",TOGGLE1TO1:\"Toggle zoom level\",ITERATEZOOM:\"Toggle zoom level\",ROTATECCW:\"Rotate counterclockwise\",ROTATECW:\"Rotate clockwise\",FLIPX:\"Flip horizontally\",FLIPY:\"Flip vertically\",FITX:\"Fit horizontally\",FITY:\"Fit vertically\",RESET:\"Reset\",TOGGLEFS:\"Toggle fullscreen\"},y={content:null,width:\"auto\",height:\"auto\",panMode:\"drag\",touch:!0,dragMinThreshold:3,lockAxis:!1,mouseMoveFactor:1,mouseMoveFriction:.12,zoom:!0,pinchToZoom:!0,panOnlyZoomed:\"auto\",minScale:1,maxScale:2,friction:.25,dragFriction:.35,decelFriction:.05,click:\"toggleZoom\",dblClick:!1,wheel:\"zoom\",wheelLimit:7,spinner:!0,bounds:\"auto\",infinite:!1,rubberband:!0,bounce:!0,maxVelocity:75,transformParent:!1,classes:{content:\"f-panzoom__content\",isLoading:\"is-loading\",canZoomIn:\"can-zoom_in\",canZoomOut:\"can-zoom_out\",isDraggable:\"is-draggable\",isDragging:\"is-dragging\",inFullscreen:\"in-fullscreen\",htmlHasFullscreen:\"with-panzoom-in-fullscreen\"},l10n:v},w='',x=t=>t&&null!==t&&t instanceof Element&&\"nodeType\"in t,E=(t,e)=>{t&&s(e).forEach((e=>{t.classList.remove(e)}))},S=(t,e)=>{t&&s(e).forEach((e=>{t.classList.add(e)}))},P={a:1,b:0,c:0,d:1,e:0,f:0},C=1e5,M=1e3,T=\"mousemove\",O=\"drag\",A=\"content\";let z=null,L=null;class R extends m{get isTouchDevice(){return null===L&&(L=window.matchMedia(\"(hover: none)\").matches),L}get isMobile(){return null===z&&(z=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)),z}get panMode(){return this.options.panMode!==T||this.isTouchDevice?O:T}get panOnlyZoomed(){const t=this.options.panOnlyZoomed;return\"auto\"===t?this.isTouchDevice:t}get isInfinite(){return this.option(\"infinite\")}get angle(){return 180*Math.atan2(this.current.b,this.current.a)/Math.PI||0}get targetAngle(){return 180*Math.atan2(this.target.b,this.target.a)/Math.PI||0}get scale(){const{a:t,b:e}=this.current;return Math.sqrt(t*t+e*e)||1}get targetScale(){const{a:t,b:e}=this.target;return Math.sqrt(t*t+e*e)||1}get minScale(){return this.option(\"minScale\")||1}get fullScale(){const{contentRect:t}=this;return t.fullWidth/t.fitWidth||1}get maxScale(){return this.fullScale*(this.option(\"maxScale\")||1)||1}get coverScale(){const{containerRect:t,contentRect:e}=this,i=Math.max(t.height/e.fitHeight,t.width/e.fitWidth)||1;return Math.min(this.fullScale,i)}get isScaling(){return Math.abs(this.targetScale-this.scale)>1e-5&&!this.isResting}get isContentLoading(){const t=this.content;return!!(t&&t instanceof HTMLImageElement)&&!t.complete}get isResting(){if(this.isBouncingX||this.isBouncingY)return!1;for(const t of b){const e=\"e\"==t||\"f\"===t?.001:1e-5;if(Math.abs(this.target[t]-this.current[t])>e)return!1}return!(!this.ignoreBounds&&!this.checkBounds().inBounds)}constructor(t,e={},i={}){var s;if(super(e),Object.defineProperty(this,\"pointerTracker\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"resizeObserver\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"updateTimer\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"clickTimer\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"rAF\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"isTicking\",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,\"friction\",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,\"ignoreBounds\",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,\"isBouncingX\",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,\"isBouncingY\",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,\"clicks\",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,\"trackingPoints\",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,\"pwt\",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,\"cwd\",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,\"pmme\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"state\",{enumerable:!0,configurable:!0,writable:!0,value:g.Init}),Object.defineProperty(this,\"isDragging\",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,\"container\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"content\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"spinner\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"containerRect\",{enumerable:!0,configurable:!0,writable:!0,value:{width:0,height:0,innerWidth:0,innerHeight:0}}),Object.defineProperty(this,\"contentRect\",{enumerable:!0,configurable:!0,writable:!0,value:{top:0,right:0,bottom:0,left:0,fullWidth:0,fullHeight:0,fitWidth:0,fitHeight:0,width:0,height:0}}),Object.defineProperty(this,\"dragStart\",{enumerable:!0,configurable:!0,writable:!0,value:{x:0,y:0,top:0,left:0,time:0}}),Object.defineProperty(this,\"dragOffset\",{enumerable:!0,configurable:!0,writable:!0,value:{x:0,y:0,time:0}}),Object.defineProperty(this,\"current\",{enumerable:!0,configurable:!0,writable:!0,value:Object.assign({},P)}),Object.defineProperty(this,\"target\",{enumerable:!0,configurable:!0,writable:!0,value:Object.assign({},P)}),Object.defineProperty(this,\"velocity\",{enumerable:!0,configurable:!0,writable:!0,value:{a:0,b:0,c:0,d:0,e:0,f:0}}),Object.defineProperty(this,\"lockedAxis\",{enumerable:!0,configurable:!0,writable:!0,value:!1}),!t)throw new Error(\"Container Element Not Found\");this.container=t,this.initContent(),this.attachPlugins(Object.assign(Object.assign({},R.Plugins),i)),this.emit(\"init\");const o=this.content;if(o.addEventListener(\"load\",this.onLoad),o.addEventListener(\"error\",this.onError),this.isContentLoading){if(this.option(\"spinner\")){t.classList.add(this.cn(\"isLoading\"));const e=n(w);!t.contains(o)||o.parentElement instanceof HTMLPictureElement?this.spinner=t.appendChild(e):this.spinner=(null===(s=o.parentElement)||void 0===s?void 0:s.insertBefore(e,o))||null}this.emit(\"beforeLoad\")}else queueMicrotask((()=>{this.enable()}))}initContent(){const{container:t}=this,e=this.cn(A);let i=this.option(A)||t.querySelector(`.${e}`);if(i||(i=t.querySelector(\"img,picture\")||t.firstElementChild,i&&S(i,e)),i instanceof HTMLPictureElement&&(i=i.querySelector(\"img\")),!i)throw new Error(\"No content found\");this.content=i}onLoad(){this.spinner&&(this.spinner.remove(),this.spinner=null),this.option(\"spinner\")&&this.container.classList.remove(this.cn(\"isLoading\")),this.emit(\"afterLoad\"),this.state===g.Init?this.enable():this.updateMetrics()}onError(){this.state!==g.Destroy&&(this.spinner&&(this.spinner.remove(),this.spinner=null),this.stop(),this.detachEvents(),this.state=g.Error,this.emit(\"error\"))}attachObserver(){var t;const e=()=>Math.abs(this.containerRect.width-this.container.getBoundingClientRect().width)>.1||Math.abs(this.containerRect.height-this.container.getBoundingClientRect().height)>.1;this.resizeObserver||void 0===window.ResizeObserver||(this.resizeObserver=new ResizeObserver((()=>{this.updateTimer||(e()?(this.onResize(),this.isMobile&&(this.updateTimer=setTimeout((()=>{e()&&this.onResize(),this.updateTimer=null}),500))):this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null))}))),null===(t=this.resizeObserver)||void 0===t||t.observe(this.container)}detachObserver(){var t;null===(t=this.resizeObserver)||void 0===t||t.disconnect()}attachEvents(){const{container:t}=this;t.addEventListener(\"click\",this.onClick,{passive:!1,capture:!1}),t.addEventListener(\"wheel\",this.onWheel,{passive:!1}),this.pointerTracker=new l(t,{start:this.onPointerDown,move:this.onPointerMove,end:this.onPointerUp}),document.addEventListener(T,this.onMouseMove)}detachEvents(){var t;const{container:e}=this;e.removeEventListener(\"click\",this.onClick,{passive:!1,capture:!1}),e.removeEventListener(\"wheel\",this.onWheel,{passive:!1}),null===(t=this.pointerTracker)||void 0===t||t.stop(),this.pointerTracker=null,document.removeEventListener(T,this.onMouseMove),document.removeEventListener(\"keydown\",this.onKeydown,!0),this.clickTimer&&(clearTimeout(this.clickTimer),this.clickTimer=null),this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null)}animate(){const t=this.friction;this.setTargetForce();const e=this.option(\"maxVelocity\");for(const i of b)t?(this.velocity[i]*=1-t,e&&!this.isScaling&&(this.velocity[i]=Math.max(Math.min(this.velocity[i],e),-1*e)),this.current[i]+=this.velocity[i]):this.current[i]=this.target[i];this.setTransform(),this.setEdgeForce(),!this.isResting||this.isDragging?this.rAF=requestAnimationFrame((()=>this.animate())):this.stop(\"current\")}setTargetForce(){for(const t of b)\"e\"===t&&this.isBouncingX||\"f\"===t&&this.isBouncingY||(this.velocity[t]=(1/(1-this.friction)-1)*(this.target[t]-this.current[t]))}checkBounds(t=0,e=0){const{current:i}=this,n=i.e+t,s=i.f+e,o=this.getBounds(),{x:a,y:r}=o,l=a.min,c=a.max,h=r.min,d=r.max;let u=0,p=0;return l!==1/0&&nc&&(u=c-n),h!==1/0&&sd&&(p=d-s),Math.abs(u)<.001&&(u=0),Math.abs(p)<.001&&(p=0),Object.assign(Object.assign({},o),{xDiff:u,yDiff:p,inBounds:!u&&!p})}clampTargetBounds(){const{target:t}=this,{x:e,y:i}=this.getBounds();e.min!==1/0&&(t.e=Math.max(t.e,e.min)),e.max!==1/0&&(t.e=Math.min(t.e,e.max)),i.min!==1/0&&(t.f=Math.max(t.f,i.min)),i.max!==1/0&&(t.f=Math.min(t.f,i.max))}calculateContentDim(t=this.current){const{content:e,contentRect:i}=this,{fitWidth:n,fitHeight:s,fullWidth:o,fullHeight:a}=i;let r=o,l=a;if(this.option(\"zoom\")||0!==this.angle){const i=!(e instanceof HTMLImageElement)&&(\"none\"===window.getComputedStyle(e).maxWidth||\"none\"===window.getComputedStyle(e).maxHeight),c=i?o:n,h=i?a:s,d=this.getMatrix(t),u=new DOMPoint(0,0).matrixTransform(d),p=new DOMPoint(0+c,0).matrixTransform(d),f=new DOMPoint(0+c,0+h).matrixTransform(d),m=new DOMPoint(0,0+h).matrixTransform(d),g=Math.abs(f.x-u.x),b=Math.abs(f.y-u.y),v=Math.abs(m.x-p.x),y=Math.abs(m.y-p.y);r=Math.max(g,v),l=Math.max(b,y)}return{contentWidth:r,contentHeight:l}}setEdgeForce(){if(this.ignoreBounds||this.isDragging||this.panMode===T||this.targetScale{const t=window.getSelection();return t&&\"Range\"===t.type})()&&!i.closest(\"button\"))return;const n=i.closest(\"[data-panzoom-action]\"),s=i.closest(\"[data-panzoom-change]\"),o=n||s,a=o&&x(o)?o.dataset:null;if(a){const e=a.panzoomChange,i=a.panzoomAction;if((e||i)&&t.preventDefault(),e){let t={};try{t=JSON.parse(e)}catch(t){console&&console.warn(\"The given data was not valid JSON\")}return void this.applyChange(t)}if(i)return void(this[i]&&this[i]())}if(Math.abs(this.dragOffset.x)>3||Math.abs(this.dragOffset.y)>3)return t.preventDefault(),void t.stopPropagation();const r=this.content.getBoundingClientRect();if(this.dragStart.time&&!this.canZoomOut()&&(Math.abs(r.x-this.dragStart.x)>2||Math.abs(r.y-this.dragStart.y)>2))return;this.dragStart.time=0;const l=e=>{this.option(\"zoom\")&&e&&\"string\"==typeof e&&/(iterateZoom)|(toggle(Zoom|Full|Cover|Max)|(zoomTo(Fit|Cover|Max)))/.test(e)&&\"function\"==typeof this[e]&&(t.preventDefault(),this[e]({event:t}))},c=this.option(\"click\",t),h=this.option(\"dblClick\",t);h?(this.clicks++,1==this.clicks&&(this.clickTimer=setTimeout((()=>{1===this.clicks?(this.emit(\"click\",t),!t.defaultPrevented&&c&&l(c)):(this.emit(\"dblClick\",t),t.defaultPrevented||l(h)),this.clicks=0,this.clickTimer=null}),350))):(this.emit(\"click\",t),!t.defaultPrevented&&c&&l(c))}addTrackingPoint(t){const e=this.trackingPoints.filter((t=>t.time>Date.now()-100));e.push(t),this.trackingPoints=e}onPointerDown(t,e,i){var n;if(!1===this.option(\"touch\",t))return!1;this.pwt=0,this.dragOffset={x:0,y:0,time:0},this.trackingPoints=[];const s=this.content.getBoundingClientRect();if(this.dragStart={x:s.x,y:s.y,top:s.top,left:s.left,time:Date.now()},this.clickTimer)return!1;if(this.panMode===T&&this.targetScale>1)return t.preventDefault(),t.stopPropagation(),!1;const o=t.composedPath()[0];if(!i.length){if([\"TEXTAREA\",\"OPTION\",\"INPUT\",\"SELECT\",\"VIDEO\",\"IFRAME\"].includes(o.nodeName)||o.closest(\"[contenteditable]\")||o.closest(\"[data-selectable]\")||o.closest(\"[data-draggable]\")||o.closest(\"[data-clickable]\")||o.closest(\"[data-panzoom-change]\")||o.closest(\"[data-panzoom-action]\"))return!1;null===(n=window.getSelection())||void 0===n||n.removeAllRanges()}if(\"mousedown\"===t.type)[\"A\",\"BUTTON\"].includes(o.nodeName)||t.preventDefault();else if(Math.abs(this.velocity.a)>.3)return!1;return this.target.e=this.current.e,this.target.f=this.current.f,this.stop(),this.isDragging||(this.isDragging=!0,this.addTrackingPoint(e),this.emit(\"touchStart\",t)),!0}onPointerMove(e,n,s){if(!1===this.option(\"touch\",e))return;if(!this.isDragging)return;if(n.length<2&&this.panOnlyZoomed&&t(this.targetScale)<=t(this.minScale))return;if(this.emit(\"touchMove\",e),e.defaultPrevented)return;this.addTrackingPoint(n[0]);const{content:o}=this,a=h(s[0],s[1]),r=h(n[0],n[1]);let l=0,d=0;if(n.length>1){const t=o.getBoundingClientRect();l=a.clientX-t.left-.5*t.width,d=a.clientY-t.top-.5*t.height}const u=c(s[0],s[1]),p=c(n[0],n[1]);let f=u?p/u:1,m=r.clientX-a.clientX,g=r.clientY-a.clientY;this.dragOffset.x+=m,this.dragOffset.y+=g,this.dragOffset.time=Date.now()-this.dragStart.time;let b=t(this.targetScale)===t(this.minScale)&&this.option(\"lockAxis\");if(b&&!this.lockedAxis)if(\"xy\"===b||\"y\"===b||\"touchmove\"===e.type){if(Math.abs(this.dragOffset.x)<6&&Math.abs(this.dragOffset.y)<6)return void e.preventDefault();const t=Math.abs(180*Math.atan2(this.dragOffset.y,this.dragOffset.x)/Math.PI);this.lockedAxis=t>45&&t<135?\"y\":\"x\",this.dragOffset.x=0,this.dragOffset.y=0,m=0,g=0}else this.lockedAxis=b;if(i(e.target,this.content)&&(b=\"x\",this.dragOffset.y=0),b&&\"xy\"!==b&&this.lockedAxis!==b&&t(this.targetScale)===t(this.minScale))return;e.cancelable&&e.preventDefault(),this.container.classList.add(this.cn(\"isDragging\"));const v=this.checkBounds(m,g);this.option(\"rubberband\")?(\"x\"!==this.isInfinite&&(v.xDiff>0&&m<0||v.xDiff<0&&m>0)&&(m*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitWidth*v.xDiff))),\"y\"!==this.isInfinite&&(v.yDiff>0&&g<0||v.yDiff<0&&g>0)&&(g*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitHeight*v.yDiff)))):(v.xDiff&&(m=0),v.yDiff&&(g=0));const y=this.targetScale,w=this.minScale,x=this.maxScale;y<.5*w&&(f=Math.max(f,w)),y>1.5*x&&(f=Math.min(f,x)),\"y\"===this.lockedAxis&&t(y)===t(w)&&(m=0),\"x\"===this.lockedAxis&&t(y)===t(w)&&(g=0),this.applyChange({originX:l,originY:d,panX:m,panY:g,scale:f,friction:this.option(\"dragFriction\"),ignoreBounds:!0})}onPointerUp(t,e,n){if(n.length)return this.dragOffset.x=0,this.dragOffset.y=0,void(this.trackingPoints=[]);this.container.classList.remove(this.cn(\"isDragging\")),this.isDragging&&(this.addTrackingPoint(e),this.panOnlyZoomed&&this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1&&(this.trackingPoints=[]),i(t.target,this.content)&&\"y\"===this.lockedAxis&&(this.trackingPoints=[]),this.emit(\"touchEnd\",t),this.isDragging=!1,this.lockedAxis=!1,this.state!==g.Destroy&&(t.defaultPrevented||this.startDecelAnim()))}startDecelAnim(){var e;const i=this.isScaling;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const t of b)this.velocity[t]=0;this.target.e=this.current.e,this.target.f=this.current.f,E(this.container,\"is-scaling\"),E(this.container,\"is-animating\"),this.isTicking=!1;const{trackingPoints:n}=this,s=n[0],o=n[n.length-1];let a=0,r=0,l=0;o&&s&&(a=o.clientX-s.clientX,r=o.clientY-s.clientY,l=o.time-s.time);const c=(null===(e=window.visualViewport)||void 0===e?void 0:e.scale)||1;1!==c&&(a*=c,r*=c);let h=0,d=0,u=0,p=0,f=this.option(\"decelFriction\");const m=this.targetScale;if(l>0){u=Math.abs(a)>3?a/(l/30):0,p=Math.abs(r)>3?r/(l/30):0;const t=this.option(\"maxVelocity\");t&&(u=Math.max(Math.min(u,t),-1*t),p=Math.max(Math.min(p,t),-1*t))}u&&(h=u/(1/(1-f)-1)),p&&(d=p/(1/(1-f)-1)),(\"y\"===this.option(\"lockAxis\")||\"xy\"===this.option(\"lockAxis\")&&\"y\"===this.lockedAxis&&t(m)===this.minScale)&&(h=u=0),(\"x\"===this.option(\"lockAxis\")||\"xy\"===this.option(\"lockAxis\")&&\"x\"===this.lockedAxis&&t(m)===this.minScale)&&(d=p=0);const g=this.dragOffset.x,v=this.dragOffset.y,y=this.option(\"dragMinThreshold\")||0;Math.abs(g)this.maxScale+1e-5||i&&!h&&!d)&&(f=.35),this.applyChange({panX:h,panY:d,friction:f}),this.emit(\"decel\",u,p,g,v)}onWheel(t){var e=[-t.deltaX||0,-t.deltaY||0,-t.detail||0].reduce((function(t,e){return Math.abs(e)>Math.abs(t)?e:t}));const i=Math.max(-1,Math.min(1,e));if(this.emit(\"wheel\",t,i),this.panMode===T)return;if(t.defaultPrevented)return;const n=this.option(\"wheel\");\"pan\"===n?(t.preventDefault(),this.panOnlyZoomed&&!this.canZoomOut()||this.applyChange({panX:2*-t.deltaX,panY:2*-t.deltaY,bounce:!1})):\"zoom\"===n&&!1!==this.option(\"zoom\")&&this.zoomWithWheel(t)}onMouseMove(t){this.panWithMouse(t)}onKeydown(t){\"Escape\"===t.key&&this.toggleFS()}onResize(){this.updateMetrics(),this.checkBounds().inBounds||this.requestTick()}setTransform(){this.emit(\"beforeTransform\");const{current:e,target:i,content:n,contentRect:s}=this,o=Object.assign({},P);for(const n of b){const s=\"e\"==n||\"f\"===n?M:C;o[n]=t(e[n],s),Math.abs(i[n]-e[n])<(\"e\"==n||\"f\"===n?.51:.001)&&(e[n]=i[n])}let{a:a,b:r,c:l,d:c,e:h,f:d}=o,u=`matrix(${a}, ${r}, ${l}, ${c}, ${h}, ${d})`,p=n.parentElement instanceof HTMLPictureElement?n.parentElement:n;if(this.option(\"transformParent\")&&(p=p.parentElement||p),p.style.transform===u)return;p.style.transform=u;const{contentWidth:f,contentHeight:m}=this.calculateContentDim();s.width=f,s.height=m,this.emit(\"afterTransform\")}updateMetrics(e=!1){var i;if(!this||this.state===g.Destroy)return;if(this.isContentLoading)return;const n=Math.max(1,(null===(i=window.visualViewport)||void 0===i?void 0:i.scale)||1),{container:s,content:o}=this,a=o instanceof HTMLImageElement,r=s.getBoundingClientRect(),l=getComputedStyle(this.container);let c=r.width*n,h=r.height*n;const d=parseFloat(l.paddingTop)+parseFloat(l.paddingBottom),u=c-(parseFloat(l.paddingLeft)+parseFloat(l.paddingRight)),p=h-d;this.containerRect={width:c,height:h,innerWidth:u,innerHeight:p};let f=this.option(\"width\")||\"auto\",m=this.option(\"height\")||\"auto\";\"auto\"===f&&(f=parseFloat(o.dataset.width||\"\")||(t=>{let e=0;return e=t instanceof HTMLImageElement?t.naturalWidth:t instanceof SVGElement?t.width.baseVal.value:Math.max(t.offsetWidth,t.scrollWidth),e||0})(o)),\"auto\"===m&&(m=parseFloat(o.dataset.height||\"\")||(t=>{let e=0;return e=t instanceof HTMLImageElement?t.naturalHeight:t instanceof SVGElement?t.height.baseVal.value:Math.max(t.offsetHeight,t.scrollHeight),e||0})(o));let b=o.parentElement instanceof HTMLPictureElement?o.parentElement:o;this.option(\"transformParent\")&&(b=b.parentElement||b);const v=b.getAttribute(\"style\")||\"\";b.style.setProperty(\"transform\",\"none\",\"important\"),a&&(b.style.width=\"\",b.style.height=\"\"),b.offsetHeight;const y=o.getBoundingClientRect();let w=y.width*n,x=y.height*n,E=0,S=0;a&&(Math.abs(f-w)>1||Math.abs(m-x)>1)&&({width:w,height:x,top:E,left:S}=((t,e,i,n)=>{const s=i/n;return s>t/e?(i=t,n=t/s):(i=e*s,n=e),{width:i,height:n,top:.5*(e-n),left:.5*(t-i)}})(w,x,f,m)),this.contentRect=Object.assign(Object.assign({},this.contentRect),{top:y.top-r.top+E,bottom:r.bottom-y.bottom+E,left:y.left-r.left+S,right:r.right-y.right+S,fitWidth:w,fitHeight:x,width:w,height:x,fullWidth:f,fullHeight:m}),b.style.cssText=v,a&&(b.style.width=`${w}px`,b.style.height=`${x}px`),this.setTransform(),!0!==e&&this.emit(\"refresh\"),this.ignoreBounds||(t(this.targetScale)this.maxScale?this.zoomTo(this.maxScale,{friction:0}):this.state===g.Init||this.checkBounds().inBounds||this.requestTick()),this.updateControls()}getBounds(){const e=this.option(\"bounds\");if(\"auto\"!==e)return e;const{contentWidth:i,contentHeight:n}=this.calculateContentDim(this.target);let s=0,o=0,a=0,r=0;const l=this.option(\"infinite\");if(!0===l||this.lockedAxis&&l===this.lockedAxis)s=-1/0,a=1/0,o=-1/0,r=1/0;else{let{containerRect:e,contentRect:l}=this,c=t(this.contentRect.fitWidth*this.targetScale,M),h=t(this.contentRect.fitHeight*this.targetScale,M),{innerWidth:d,innerHeight:u}=e;if(this.containerRect.width===c&&(d=e.width),this.containerRect.width===h&&(u=e.height),i>d){a=.5*(i-d),s=-1*a;let t=.5*(l.right-l.left);s+=t,a+=t}if(this.contentRect.fitWidth>d&&iu){r=.5*(n-u),o=-1*r;let t=.5*(l.bottom-l.top);o+=t,r+=t}this.contentRect.fitHeight>u&&nt(s.fitWidth,1)||t(s.height,1)>t(s.fitHeight,1))&&(m=!0)),t(s.width*r,1)t(r),b=!g&&!m&&p&&t(d)i&&(n=i/t)}v=v.scale(n)}v=v.translate(-o,-a).translate(-p,-f).multiply(m),s&&(v=v.rotate(s)),l&&(v=v.scale(-1,1)),c&&(v=v.scale(1,-1));for(const e of b)\"e\"!==e&&\"f\"!==e&&(v[e]>this.minScale+1e-5||v[e].1||this.panMode===T||!1===d)&&!h&&this.clampTargetBounds(),this.isResting||(this.state=g.Panning,this.requestTick())}stop(t=!1){if(this.state===g.Init||this.state===g.Destroy)return;const e=this.isTicking;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const e of b)this.velocity[e]=0,\"current\"===t?this.current[e]=this.target[e]:\"target\"===t&&(this.target[e]=this.current[e]);this.setTransform(),E(this.container,\"is-scaling\"),E(this.container,\"is-animating\"),this.isTicking=!1,this.state=g.Ready,e&&(this.emit(\"endAnimation\"),this.updateControls())}requestTick(){this.isTicking||(this.emit(\"startAnimation\"),this.updateControls(),S(this.container,\"is-animating\"),this.isScaling&&S(this.container,\"is-scaling\")),this.isTicking=!0,this.rAF||(this.rAF=requestAnimationFrame((()=>this.animate())))}panWithMouse(e,i=this.option(\"mouseMoveFriction\")){if(this.pmme=e,this.panMode!==T||!e)return;if(t(this.targetScale)<=t(this.minScale))return;this.emit(\"mouseMove\",e);const{container:n,containerRect:s,contentRect:o}=this,a=s.width,r=s.height,l=n.getBoundingClientRect(),c=(e.clientX||0)-l.left,h=(e.clientY||0)-l.top;let{contentWidth:d,contentHeight:u}=this.calculateContentDim(this.target);const p=this.option(\"mouseMoveFactor\");p>1&&(d!==a&&(d*=p),u!==r&&(u*=p));let f=.5*(d-a)-c/a*100/100*(d-a);f+=.5*(o.right-o.left);let m=.5*(u-r)-h/r*100/100*(u-r);m+=.5*(o.bottom-o.top),this.applyChange({panX:f-this.target.e,panY:m-this.target.f,friction:i})}zoomWithWheel(e){if(this.state===g.Destroy||this.state===g.Init)return;const i=Date.now();if(i-this.pwt<45)return void e.preventDefault();this.pwt=i;var n=[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce((function(t,e){return Math.abs(e)>Math.abs(t)?e:t}));const s=Math.max(-1,Math.min(1,n)),{targetScale:o,maxScale:a,minScale:r}=this;let l=o*(100+45*s)/100;t(l)t(a)&&t(o)>=t(a)?(this.cwd+=Math.abs(s),l=a):(this.cwd=0,l=Math.max(Math.min(l,a),r)),this.cwd>this.option(\"wheelLimit\")||(e.preventDefault(),t(l)!==t(o)&&this.zoomTo(l,{event:e}))}canZoomIn(){return this.option(\"zoom\")&&(t(this.contentRect.width,1)t(this.minScale)}zoomIn(t=1.25,e){this.zoomTo(this.targetScale*t,e)}zoomOut(t=.8,e){this.zoomTo(this.targetScale*t,e)}zoomToFit(t){this.zoomTo(\"fit\",t)}zoomToCover(t){this.zoomTo(\"cover\",t)}zoomToFull(t){this.zoomTo(\"full\",t)}zoomToMax(t){this.zoomTo(\"max\",t)}toggleZoom(t){this.zoomTo(this.targetScale-this.minScale<.5*(this.fullScale-this.minScale)?\"full\":\"fit\",t)}toggleMax(t){this.zoomTo(this.targetScale-this.minScale<.5*(this.maxScale-this.minScale)?\"max\":\"fit\",t)}toggleCover(t){this.zoomTo(this.targetScale-this.minScale<.5*(this.coverScale-this.minScale)?\"cover\":\"fit\",t)}iterateZoom(t){this.zoomTo(\"next\",t)}zoomTo(t=1,{friction:e=\"auto\",originX:i=\"auto\",originY:n=\"auto\",event:s}={}){if(this.isContentLoading||this.state===g.Destroy)return;const{targetScale:o}=this;this.stop();let a=1;if(this.panMode===T&&(s=this.pmme||s),s||\"auto\"===i||\"auto\"===n){const t=this.content.getBoundingClientRect(),e=this.container.getBoundingClientRect(),o=s?s.clientX:e.left+.5*e.width,a=s?s.clientY:e.top+.5*e.height;i=o-t.left-.5*t.width,n=a-t.top-.5*t.height}const r=this.fullScale,l=this.maxScale;let c=this.coverScale;\"number\"==typeof t?a=t/o:(\"next\"===t&&(r-c<.2&&(c=r),t=o1?.15:.25:e,this.applyChange({scale:a,originX:i,originY:n,friction:e}),s&&this.panMode===T&&this.panWithMouse(s,e)}rotateCCW(){this.applyChange({angle:-90})}rotateCW(){this.applyChange({angle:90})}flipX(){this.applyChange({flipX:!0})}flipY(){this.applyChange({flipY:!0})}fitX(){this.stop(\"target\");const{containerRect:t,contentRect:e,target:i}=this;this.applyChange({panX:.5*t.width-(e.left+.5*e.fitWidth)-i.e,panY:.5*t.height-(e.top+.5*e.fitHeight)-i.f,scale:t.width/e.fitWidth/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}fitY(){this.stop(\"target\");const{containerRect:t,contentRect:e,target:i}=this;this.applyChange({panX:.5*t.width-(e.left+.5*e.fitWidth)-i.e,panY:.5*t.innerHeight-(e.top+.5*e.fitHeight)-i.f,scale:t.height/e.fitHeight/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}toggleFS(){const{container:t}=this,e=this.cn(\"inFullscreen\"),i=this.cn(\"htmlHasFullscreen\");t.classList.toggle(e);const n=t.classList.contains(e);n?(document.documentElement.classList.add(i),document.addEventListener(\"keydown\",this.onKeydown,!0)):(document.documentElement.classList.remove(i),document.removeEventListener(\"keydown\",this.onKeydown,!0)),this.updateMetrics(),this.emit(n?\"enterFS\":\"exitFS\")}getMatrix(t=this.current){const{a:e,b:i,c:n,d:s,e:o,f:a}=t;return new DOMMatrix([e,i,n,s,o,a])}reset(t){if(this.state!==g.Init&&this.state!==g.Destroy){this.stop(\"current\");for(const t of b)this.target[t]=P[t];this.target.a=this.minScale,this.target.d=this.minScale,this.clampTargetBounds(),this.isResting||(this.friction=void 0===t?this.option(\"friction\"):t,this.state=g.Panning,this.requestTick())}}destroy(){this.stop(),this.state=g.Destroy,this.detachEvents(),this.detachObserver();const{container:t,content:e}=this,i=this.option(\"classes\")||{};for(const e of Object.values(i))t.classList.remove(e+\"\");e&&(e.removeEventListener(\"load\",this.onLoad),e.removeEventListener(\"error\",this.onError)),this.detachPlugins()}}Object.defineProperty(R,\"defaults\",{enumerable:!0,configurable:!0,writable:!0,value:y}),Object.defineProperty(R,\"Plugins\",{enumerable:!0,configurable:!0,writable:!0,value:{}});const k=function(t,e){let i=!0;return(...n)=>{i&&(i=!1,t(...n),setTimeout((()=>{i=!0}),e))}},I=(t,e)=>{let i=[];return t.childNodes.forEach((t=>{t.nodeType!==Node.ELEMENT_NODE||e&&!t.matches(e)||i.push(t)})),i},D={viewport:null,track:null,enabled:!0,slides:[],axis:\"x\",transition:\"fade\",preload:1,slidesPerPage:\"auto\",initialPage:0,friction:.12,Panzoom:{decelFriction:.12},center:!0,infinite:!0,fill:!0,dragFree:!1,adaptiveHeight:!1,direction:\"ltr\",classes:{container:\"f-carousel\",viewport:\"f-carousel__viewport\",track:\"f-carousel__track\",slide:\"f-carousel__slide\",isLTR:\"is-ltr\",isRTL:\"is-rtl\",isHorizontal:\"is-horizontal\",isVertical:\"is-vertical\",inTransition:\"in-transition\",isSelected:\"is-selected\"},l10n:{NEXT:\"Next slide\",PREV:\"Previous slide\",GOTO:\"Go to slide #%d\"}};var F;!function(t){t[t.Init=0]=\"Init\",t[t.Ready=1]=\"Ready\",t[t.Destroy=2]=\"Destroy\"}(F||(F={}));const j=t=>{if(\"string\"==typeof t||t instanceof HTMLElement)t={html:t};else{const e=t.thumb;void 0!==e&&(\"string\"==typeof e&&(t.thumbSrc=e),e instanceof HTMLImageElement&&(t.thumbEl=e,t.thumbElSrc=e.src,t.thumbSrc=e.src),delete t.thumb)}return Object.assign({html:\"\",el:null,isDom:!1,class:\"\",customClass:\"\",index:-1,dim:0,gap:0,pos:0,transition:!1},t)},H=(t={})=>Object.assign({index:-1,slides:[],dim:0,pos:-1},t);class B extends f{constructor(t,e){super(e),Object.defineProperty(this,\"instance\",{enumerable:!0,configurable:!0,writable:!0,value:t})}attach(){}detach(){}}const N={classes:{list:\"f-carousel__dots\",isDynamic:\"is-dynamic\",hasDots:\"has-dots\",dot:\"f-carousel__dot\",isBeforePrev:\"is-before-prev\",isPrev:\"is-prev\",isCurrent:\"is-current\",isNext:\"is-next\",isAfterNext:\"is-after-next\"},dotTpl:'',dynamicFrom:11,maxCount:1/0,minCount:2};class _ extends B{constructor(){super(...arguments),Object.defineProperty(this,\"isDynamic\",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,\"list\",{enumerable:!0,configurable:!0,writable:!0,value:null})}onRefresh(){this.refresh()}build(){let t=this.list;return t||(t=document.createElement(\"ul\"),S(t,this.cn(\"list\")),t.setAttribute(\"role\",\"tablist\"),this.instance.container.appendChild(t),S(this.instance.container,this.cn(\"hasDots\")),this.list=t),t}refresh(){var t;const e=this.instance.pages.length,i=Math.min(2,this.option(\"minCount\")),n=Math.max(2e3,this.option(\"maxCount\")),s=this.option(\"dynamicFrom\");if(en)return void this.cleanup();const a=\"number\"==typeof s&&e>5&&e>=s,r=!this.list||this.isDynamic!==a||this.list.children.length!==e;r&&this.cleanup();const l=this.build();if(o(l,this.cn(\"isDynamic\"),!!a),r)for(let t=0;t=e-1&&s.setAttribute(W,\"\")))}createButton(t){const e=this.instance,i=document.createElement(\"button\");i.setAttribute(\"tabindex\",\"0\"),i.setAttribute(\"title\",e.localize(`{{${t.toUpperCase()}}}`)),S(i,this.cn(\"button\")+\" \"+this.cn(t===$?\"isNext\":\"isPrev\"));const n=e.isRTL?t===$?X:$:t;var s;return i.innerHTML=e.localize(this.option(`${n}Tpl`)),i.dataset[`carousel${s=t,s?s.match(\"^[a-z]\")?s.charAt(0).toUpperCase()+s.substring(1):s:\"\"}`]=\"true\",i}build(){let t=this.container;t||(this.container=t=document.createElement(\"div\"),S(t,this.cn(\"container\")),this.instance.container.appendChild(t)),this.next||(this.next=t.appendChild(this.createButton($))),this.prev||(this.prev=t.appendChild(this.createButton(X)))}cleanup(){this.prev&&this.prev.remove(),this.next&&this.next.remove(),this.container&&this.container.remove(),this.prev=null,this.next=null,this.container=null}attach(){this.instance.on([\"refresh\",\"change\"],this.onRefresh)}detach(){this.instance.off([\"refresh\",\"change\"],this.onRefresh),this.cleanup()}}Object.defineProperty(Y,\"defaults\",{enumerable:!0,configurable:!0,writable:!0,value:{classes:{container:\"f-carousel__nav\",button:\"f-button\",isNext:\"is-next\",isPrev:\"is-prev\"},nextTpl:'',prevTpl:''}});class q extends B{constructor(){super(...arguments),Object.defineProperty(this,\"selectedIndex\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"target\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"nav\",{enumerable:!0,configurable:!0,writable:!0,value:null})}addAsTargetFor(t){this.target=this.instance,this.nav=t,this.attachEvents()}addAsNavFor(t){this.nav=this.instance,this.target=t,this.attachEvents()}attachEvents(){this.nav&&this.target&&(this.nav.options.initialSlide=this.target.options.initialPage,this.nav.on(\"ready\",this.onNavReady),this.nav.state===F.Ready&&this.onNavReady(this.nav),this.target.on(\"ready\",this.onTargetReady),this.target.state===F.Ready&&this.onTargetReady(this.target))}onNavReady(t){t.on(\"createSlide\",this.onNavCreateSlide),t.on(\"Panzoom.click\",this.onNavClick),t.on(\"Panzoom.touchEnd\",this.onNavTouch),this.onTargetChange()}onTargetReady(t){t.on(\"change\",this.onTargetChange),t.on(\"Panzoom.refresh\",this.onTargetChange),this.onTargetChange()}onNavClick(t,e,i){this.onNavTouch(t,t.panzoom,i)}onNavTouch(t,e,i){var n,s;if(Math.abs(e.dragOffset.x)>3||Math.abs(e.dragOffset.y)>3)return;const o=i.target,{nav:a,target:r}=this;if(!a||!r||!o)return;const l=o.closest(\"[data-index]\");if(i.stopPropagation(),i.preventDefault(),!l)return;const c=parseInt(l.dataset.index||\"\",10)||0,h=r.getPageForSlide(c),d=a.getPageForSlide(c);a.slideTo(d),r.slideTo(h,{friction:(null===(s=null===(n=this.nav)||void 0===n?void 0:n.plugins)||void 0===s?void 0:s.Sync.option(\"friction\"))||0}),this.markSelectedSlide(c)}onNavCreateSlide(t,e){e.index===this.selectedIndex&&this.markSelectedSlide(e.index)}onTargetChange(){const{target:t,nav:e}=this;if(!t||!e)return;if(e.state!==F.Ready||t.state!==F.Ready)return;const i=t.pages[t.page].slides[0].index,n=e.getPageForSlide(i);this.markSelectedSlide(i),e.slideTo(n)}markSelectedSlide(t){const e=this.nav;e&&e.state===F.Ready&&(this.selectedIndex=t,[...e.slides].map((e=>{e.el&&e.el.classList[e.index===t?\"add\":\"remove\"](\"is-nav-selected\")})))}attach(){const t=this;let e=t.options.target,i=t.options.nav;e?t.addAsNavFor(e):i&&t.addAsTargetFor(i)}detach(){const t=this,e=t.nav,i=t.target;e&&(e.off(\"ready\",t.onNavReady),e.off(\"createSlide\",t.onNavCreateSlide),e.off(\"Panzoom.click\",t.onNavClick),e.off(\"Panzoom.touchEnd\",t.onNavTouch)),t.nav=null,i&&(i.off(\"ready\",t.onTargetReady),i.off(\"refresh\",t.onTargetChange),i.off(\"change\",t.onTargetChange)),t.target=null}}Object.defineProperty(q,\"defaults\",{enumerable:!0,configurable:!0,writable:!0,value:{friction:.35}});const V={Navigation:Y,Dots:_,Sync:q};class Z extends m{get axis(){return this.isHorizontal?\"e\":\"f\"}get isEnabled(){return this.state===F.Ready}get isInfinite(){let t=!1;const{contentDim:e,viewportDim:i,pages:n,slides:s}=this;return n.length>=2&&e+s[0].dim>=i&&(t=this.option(\"infinite\")),t}get isRTL(){return\"rtl\"===this.option(\"direction\")}get isHorizontal(){return\"x\"===this.option(\"axis\")}constructor(t,e={},i={}){if(super(),Object.defineProperty(this,\"userOptions\",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,\"userPlugins\",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,\"bp\",{enumerable:!0,configurable:!0,writable:!0,value:\"\"}),Object.defineProperty(this,\"lp\",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,\"state\",{enumerable:!0,configurable:!0,writable:!0,value:F.Init}),Object.defineProperty(this,\"page\",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,\"prevPage\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"container\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"viewport\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"track\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"slides\",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,\"pages\",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,\"panzoom\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"inTransition\",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,\"contentDim\",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,\"viewportDim\",{enumerable:!0,configurable:!0,writable:!0,value:0}),\"string\"==typeof t&&(t=document.querySelector(t)),!t||!x(t))throw new Error(\"No Element found\");this.container=t,this.slideNext=k(this.slideNext.bind(this),150),this.slidePrev=k(this.slidePrev.bind(this),150),this.userOptions=e,this.userPlugins=i,queueMicrotask((()=>{this.processOptions()}))}processOptions(){const t=u({},Z.defaults,this.userOptions);let e=\"\";const i=t.breakpoints;if(i&&d(i))for(const[n,s]of Object.entries(i))window.matchMedia(n).matches&&d(s)&&(e+=n,u(t,s));e===this.bp&&this.state!==F.Init||(this.bp=e,this.state===F.Ready&&(t.initialSlide=this.pages[this.page].slides[0].index),this.state!==F.Init&&this.destroy(),super.setOptions(t),!1===this.option(\"enabled\")?this.attachEvents():setTimeout((()=>{this.init()}),0))}init(){this.state=F.Init,this.emit(\"init\"),this.attachPlugins(Object.assign(Object.assign({},Z.Plugins),this.userPlugins)),this.initLayout(),this.initSlides(),this.updateMetrics(),this.setInitialPosition(),this.initPanzoom(),this.attachEvents(),this.state=F.Ready,this.emit(\"ready\")}initLayout(){const{container:t}=this,e=this.option(\"classes\");S(t,this.cn(\"container\")),o(t,e.isLTR,!this.isRTL),o(t,e.isRTL,this.isRTL),o(t,e.isVertical,!this.isHorizontal),o(t,e.isHorizontal,this.isHorizontal);let i=this.option(\"viewport\")||t.querySelector(`.${e.viewport}`);i||(i=document.createElement(\"div\"),S(i,e.viewport),i.append(...I(t,`.${e.slide}`)),t.prepend(i));let n=this.option(\"track\")||t.querySelector(`.${e.track}`);n||(n=document.createElement(\"div\"),S(n,e.track),n.append(...Array.from(i.childNodes))),n.setAttribute(\"aria-live\",\"polite\"),i.contains(n)||i.prepend(n),this.viewport=i,this.track=n,this.emit(\"initLayout\")}initSlides(){const{track:t}=this;if(t){this.slides=[],[...I(t,`.${this.cn(\"slide\")}`)].forEach((t=>{if(x(t)){const e=j({el:t,isDom:!0,index:this.slides.length});this.slides.push(e),this.emit(\"initSlide\",e,this.slides.length)}}));for(let t of this.option(\"slides\",[])){const e=j(t);e.index=this.slides.length,this.slides.push(e),this.emit(\"initSlide\",e,this.slides.length)}this.emit(\"initSlides\")}}setInitialPage(){let t=0;const e=this.option(\"initialSlide\");t=\"number\"==typeof e?this.getPageForSlide(e):parseInt(this.option(\"initialPage\",0)+\"\",10)||0,this.page=t}setInitialPosition(){if(!this.track||!this.pages.length)return;const t=this.isHorizontal;let e=this.page;this.pages[e]||(this.page=e=0);const i=this.pages[e].pos*(this.isRTL&&t?1:-1),n=t?`${i}px`:\"0\",s=t?\"0\":`${i}px`;this.track.style.transform=`translate3d(${n}, ${s}, 0) scale(1)`,this.option(\"adaptiveHeight\")&&this.setViewportHeight()}initPanzoom(){this.panzoom&&(this.panzoom.destroy(),this.panzoom=null);const t=this.option(\"Panzoom\")||{};this.panzoom=new R(this.viewport,u({},{content:this.track,zoom:!1,panOnlyZoomed:!1,lockAxis:this.isHorizontal?\"x\":\"y\",infinite:this.isInfinite,click:!1,dblClick:!1,touch:t=>!(this.pages.length<2&&!t.options.infinite),bounds:()=>this.getBounds(),maxVelocity:t=>Math.abs(t.target[this.axis]-t.current[this.axis])<2*this.viewportDim?100:0},t)),this.panzoom.on(\"*\",((t,e,...i)=>{this.emit(`Panzoom.${e}`,t,...i)})),this.panzoom.on(\"decel\",this.onDecel),this.panzoom.on(\"refresh\",this.onRefresh),this.panzoom.on(\"beforeTransform\",this.onBeforeTransform),this.panzoom.on(\"endAnimation\",this.onEndAnimation)}attachEvents(){const t=this.container;t&&(t.addEventListener(\"click\",this.onClick,{passive:!1,capture:!1}),t.addEventListener(\"slideTo\",this.onSlideTo)),window.addEventListener(\"resize\",this.onResize)}createPages(){let t=[];const{contentDim:e,viewportDim:i}=this;let n=this.option(\"slidesPerPage\");(\"number\"!=typeof n||e<=i)&&(n=1/0);let s=0,o=0,a=0;for(const e of this.slides)(!t.length||o+e.dim>i||a===n)&&(t.push(H()),s=t.length-1,o=0,a=0),t[s].slides.push(e),o+=e.dim+e.gap,a++;return t}processPages(){const e=this.pages,{contentDim:i,viewportDim:n}=this,s=this.option(\"center\"),o=this.option(\"fill\"),a=o&&s&&i>n&&!this.isInfinite;if(e.forEach(((t,e)=>{t.index=e,t.pos=t.slides[0].pos,t.dim=0;for(const[e,i]of t.slides.entries())t.dim+=i.dim,e=i-.5*n?t.pos=i-n:s&&(t.pos+=-.5*(n-t.dim))})),e.forEach(((e,s)=>{o&&!this.isInfinite&&i>n&&(e.pos=Math.max(e.pos,0),e.pos=Math.min(e.pos,i-n)),e.pos=t(e.pos,1e3),e.dim=t(e.dim,1e3),Math.abs(e.pos)<=.1&&(e.pos=0)})),this.isInfinite)return e;const r=[];let l;return e.forEach((t=>{const e=Object.assign({},t);l&&e.pos===l.pos?(l.dim+=e.dim,l.slides=[...l.slides,...e.slides]):(e.index=r.length,l=e,r.push(e))})),r}getPageFromIndex(t=0){const e=this.pages.length;let i;return t=parseInt((t||0).toString())||0,i=this.isInfinite?(t%e+e)%e:Math.max(Math.min(t,e-1),0),i}getSlideMetrics(e){var i,n;const s=this.isHorizontal?\"width\":\"height\";let o=0,a=0,r=e.el;const l=r&&!r.parentNode;if(r?o=parseFloat(r.dataset[s]||\"\")||0:(r=document.createElement(\"div\"),r.style.visibility=\"hidden\",(this.track||document.body).prepend(r)),S(r,this.cn(\"slide\")+\" \"+e.class+\" \"+e.customClass),o)r.style[s]=`${o}px`,r.style[\"width\"===s?\"height\":\"width\"]=\"\";else{l&&(this.track||document.body).prepend(r);const t=Math.max(1,(null===(i=window.visualViewport)||void 0===i?void 0:i.scale)||1);o=r.getBoundingClientRect()[s]*t}const c=getComputedStyle(r);return\"content-box\"===c.boxSizing&&(this.isHorizontal?(o+=parseFloat(c.paddingLeft)||0,o+=parseFloat(c.paddingRight)||0):(o+=parseFloat(c.paddingTop)||0,o+=parseFloat(c.paddingBottom)||0)),a=parseFloat(c[this.isHorizontal?\"marginRight\":\"marginBottom\"])||0,l?null===(n=r.parentElement)||void 0===n||n.removeChild(r):e.el||r.remove(),{dim:t(o,1e3),gap:t(a,1e3)}}getBounds(){const{isInfinite:t,isRTL:e,isHorizontal:i,pages:n}=this;let s={min:0,max:0};if(t)s={min:-1/0,max:1/0};else if(n.length){const t=n[0].pos,o=n[n.length-1].pos;s=e&&i?{min:t,max:o}:{min:-1*o,max:-1*t}}return{x:i?s:{min:0,max:0},y:i?{min:0,max:0}:s}}repositionSlides(){let e,{isHorizontal:i,isRTL:n,isInfinite:s,viewport:o,viewportDim:a,contentDim:r,page:l,pages:c,slides:h,panzoom:d}=this,u=0,p=0,f=0,m=0;d?m=-1*d.current[this.axis]:c[l]&&(m=c[l].pos||0),e=i?n?\"right\":\"left\":\"top\",n&&i&&(m*=-1);for(const i of h)i.el?(\"top\"===e?(i.el.style.right=\"\",i.el.style.left=\"\"):i.el.style.top=\"\",i.index!==u?i.el.style[e]=0===p?\"\":`${t(p,1e3)}px`:i.el.style[e]=\"\",f+=i.dim+i.gap,u++):p+=i.dim+i.gap;if(s&&f&&o){let n=getComputedStyle(o),s=\"padding\",l=i?\"Right\":\"Bottom\",c=parseFloat(n[s+(i?\"Left\":\"Top\")]);m-=c,a+=c,a+=parseFloat(n[s+l]);for(const i of h)i.el&&(t(i.pos)t(r-a)&&(i.el.style[e]=`${t(p+f,1e3)}px`),t(i.pos+i.gap)>=t(r-a)&&t(i.pos)>t(m+a)&&t(m)1&&(g=c[v[0]],b=c[v[1]]),g&&b){let i=0;for(const n of h)n.el?this.inTransition.has(n.index)&&g.slides.indexOf(n)<0&&(n.el.style[e]=`${t(i+(g.pos-b.pos),1e3)}px`):i+=n.dim+n.gap}}createSlideEl(t){const{track:e,slides:i}=this;if(!e||!t)return;if(t.el&&t.el.parentNode)return;const n=t.el||document.createElement(\"div\");S(n,this.cn(\"slide\")),S(n,t.class),S(n,t.customClass);const s=t.html;s&&(s instanceof HTMLElement?n.appendChild(s):n.innerHTML=t.html+\"\");const o=[];i.forEach(((t,e)=>{t.el&&o.push(e)}));const a=t.index;let r=null;if(o.length){r=i[o.reduce(((t,e)=>Math.abs(e-a)1)return!1;const o=t>this.page?1:-1,a=this.pages[s].pos*(this.isRTL?1:-1);if(this.page===s&&Math.abs(a-n.target[this.axis])<1)return!1;this.clearTransitions();const r=n.isResting;S(this.container,this.cn(\"inTransition\"));const l=this.pages[this.page].slides[0],c=this.pages[s].slides[0];this.inTransition.add(c.index),this.createSlideEl(c);let h=l.el,d=c.el;r||\"slide\"===e||(e=\"fadeFast\",h=null);const u=this.isRTL?\"next\":\"prev\",p=this.isRTL?\"prev\":\"next\";return h&&(this.inTransition.add(l.index),l.transition=e,h.addEventListener(\"animationend\",this.onAnimationEnd),h.classList.add(`f-${e}Out`,`to-${o>0?p:u}`)),d&&(c.transition=e,d.addEventListener(\"animationend\",this.onAnimationEnd),d.classList.add(`f-${e}In`,`from-${o>0?u:p}`)),n.panTo({x:this.isHorizontal?a:0,y:this.isHorizontal?0:a,friction:0}),this.onChange(s),!0}manageSlideVisiblity(){const t=new Set,e=new Set,i=this.getVisibleSlides(parseFloat(this.option(\"preload\",0)+\"\")||0);for(const n of this.slides)i.has(n)?t.add(n):e.add(n);for(const e of this.inTransition)t.add(this.slides[e]);for(const e of t)this.createSlideEl(e),this.lazyLoadSlide(e);for(const i of e)t.has(i)||this.removeSlideEl(i);this.markSelectedSlides(),this.repositionSlides()}markSelectedSlides(){if(!this.pages[this.page]||!this.pages[this.page].slides)return;const t=\"aria-hidden\";let e=this.cn(\"isSelected\");if(e)for(const i of this.slides)i.el&&(i.el.dataset.index=`${i.index}`,this.pages[this.page].slides.includes(i)?(i.el.classList.contains(e)||(S(i.el,e),this.emit(\"selectSlide\",i)),i.el.removeAttribute(t)):(i.el.classList.contains(e)&&(E(i.el,e),this.emit(\"unselectSlide\",i)),i.el.setAttribute(t,\"true\")))}flipInfiniteTrack(){const t=this.panzoom;if(!t||!this.isInfinite)return;const e=\"x\"===this.option(\"axis\")?\"e\":\"f\",{viewportDim:i,contentDim:n}=this;let s=t.current[e],o=t.target[e]-s,a=0,r=.5*i,l=n;this.isRTL&&this.isHorizontal?(s<-r&&(a=-1,s+=l),s>l-r&&(a=1,s-=l)):(s>r&&(a=1,s-=l),s<-l+r&&(a=-1,s+=l)),a&&(t.current[e]=s,t.target[e]=s+o)}lazyLoadSlide(t){const e=this,i=t&&t.el;if(!i)return;const s=new Set,o=\"f-fadeIn\";i.querySelectorAll(\"[data-lazy-srcset]\").forEach((t=>{t instanceof HTMLImageElement&&s.add(t)}));let a=Array.from(i.querySelectorAll(\"[data-lazy-src]\"));i.dataset.lazySrc&&a.push(i),a.map((t=>{t instanceof HTMLImageElement?s.add(t):x(t)&&(t.style.backgroundImage=`url('${t.dataset.lazySrc||\"\"}')`,delete t.dataset.lazySrc)}));const r=(t,i,n)=>{n&&(n.remove(),n=null),i.complete&&(i.classList.add(o),setTimeout((()=>{i.classList.remove(o)}),350),i.style.display=\"\"),this.option(\"adaptiveHeight\")&&t.el&&this.pages[this.page].slides.indexOf(t)>-1&&(e.updateMetrics(),e.setViewportHeight()),this.emit(\"load\",t)};for(const e of s){let i=null;e.src=e.dataset.lazySrcset||e.dataset.lazySrc||\"\",delete e.dataset.lazySrc,delete e.dataset.lazySrcset,e.style.display=\"none\",e.addEventListener(\"error\",(()=>{r(t,e,i)})),e.addEventListener(\"load\",(()=>{r(t,e,i)})),setTimeout((()=>{e.parentNode&&t.el&&(e.complete?r(t,e,i):(i=n(w),e.parentNode.insertBefore(i,e)))}),300)}}onAnimationEnd(t){var e;const i=t.target,n=i?parseInt(i.dataset.index||\"\",10)||0:-1,s=this.slides[n],o=t.animationName;if(!i||!s||!o)return;const a=!!this.inTransition.has(n)&&s.transition;a&&o.substring(0,a.length+2)===`f-${a}`&&this.inTransition.delete(n),this.inTransition.size||this.clearTransitions(),n===this.page&&(null===(e=this.panzoom)||void 0===e?void 0:e.isResting)&&this.emit(\"settle\")}onDecel(t,e=0,i=0,n=0,s=0){const{isRTL:o,isHorizontal:a,axis:r,pages:l}=this,c=l.length,h=Math.abs(Math.atan2(i,e)/(Math.PI/180));let d=0;if(d=h>45&&h<135?a?0:i:a?e:0,!c)return;const u=this.option(\"dragFree\");let p=this.page,f=o&&a?1:-1;const m=t.target[r]*f,g=t.current[r]*f;let{pageIndex:b}=this.getPageFromPosition(m),{pageIndex:v}=this.getPageFromPosition(g);u?this.onChange(b):(Math.abs(d)>5?(l[p].dim.5&&(e.target[this.axis]=-1*this.pages[this.page].pos,e.current[this.axis]=-1*this.pages[this.page].pos,e.stop()),this.manageSlideVisiblity(),this.emit(\"refresh\")}getProgress(e,i=!1){void 0===e&&(e=this.page);const n=this,s=n.panzoom,o=n.pages[e]||0;if(!o||!s)return 0;let a=-1*s.current.e,r=n.contentDim;var l=[t((a-o.pos)/(1*o.dim),1e3),t((a+r-o.pos)/(1*o.dim),1e3),t((a-r-o.pos)/(1*o.dim),1e3)].reduce((function(t,e){return Math.abs(e){t.el&&(s=Math.max(s,t.el.offsetHeight))}))),i.style.height=s?`${s}px`:\"\"}getPageForSlide(t){for(const e of this.pages)for(const i of e.slides)if(i.index===t)return e.index;return-1}getVisibleSlides(t=0){var e;const i=new Set;let{contentDim:n,viewportDim:s,pages:o,page:a}=this;n=n+(null===(e=this.slides[this.slides.length-1])||void 0===e?void 0:e.gap)||0;let r=0;r=this.panzoom?-1*this.panzoom.current[this.axis]:o[a]&&o[a].pos||0,this.isInfinite&&(r-=Math.floor(r/n)*n),this.isRTL&&this.isHorizontal&&(r*=-1);const l=r-s*t,c=r+s*(t+1),h=this.isInfinite?[-1,0,1]:[0];for(const t of this.slides)for(const e of h){const s=t.pos+e*n,o=t.pos+t.dim+t.gap+e*n;sl&&i.add(t)}return i}getPageFromPosition(t){const{viewportDim:e,contentDim:i}=this,n=this.pages.length,s=this.slides.length,o=this.slides[s-1];let a=0,r=0,l=0;const c=this.option(\"center\");c&&(t+=.5*e),this.isInfinite||(t=Math.max(this.slides[0].pos,Math.min(t,o.pos)));const h=i+o.gap;l=Math.floor(t/h)||0,t-=l*h;let d=o,u=this.slides.find((e=>{const i=t+(d&&!c?.5*d.dim:0);return d=e,e.pos<=i&&e.pos+e.dim+e.gap>i}));return u||(u=o),r=this.getPageForSlide(u.index),a=r+l*n,{page:a,pageIndex:r}}destroy(){if([F.Destroy].includes(this.state))return;this.state=F.Destroy;const{container:t,viewport:e,track:i,slides:n,panzoom:s}=this,o=this.option(\"classes\");t.removeEventListener(\"click\",this.onClick,{passive:!1,capture:!1}),t.removeEventListener(\"slideTo\",this.onSlideTo),window.removeEventListener(\"resize\",this.onResize),s&&(s.destroy(),this.panzoom=null),n&&n.forEach((t=>{this.removeSlideEl(t)})),this.detachPlugins(),e&&e.offsetParent&&i&&i.offsetParent&&e.replaceWith(...i.childNodes);for(const[e,i]of Object.entries(o))\"container\"!==e&&i&&t.classList.remove(i);this.track=null,this.viewport=null,this.page=0,this.slides=[];const a=this.events.get(\"ready\");this.events=new Map,a&&this.events.set(\"ready\",a)}}Object.defineProperty(Z,\"Panzoom\",{enumerable:!0,configurable:!0,writable:!0,value:R}),Object.defineProperty(Z,\"defaults\",{enumerable:!0,configurable:!0,writable:!0,value:D}),Object.defineProperty(Z,\"Plugins\",{enumerable:!0,configurable:!0,writable:!0,value:V});const U=function(t){const e=window.pageYOffset,i=window.pageYOffset+window.innerHeight;if(!x(t))return 0;const n=t.getBoundingClientRect(),s=n.y+window.pageYOffset,o=n.y+n.height+window.pageYOffset;if(e>o||io)return 100;if(si)return 100;let a=n.height;si&&(a-=o-i);const r=a/window.innerHeight*100;return Math.round(r)},G=!(\"undefined\"==typeof window||!window.document||!window.document.createElement);let K;const J=[\"a[href]\",\"area[href]\",'input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden])',\"select:not([disabled]):not([aria-hidden])\",\"textarea:not([disabled]):not([aria-hidden])\",\"button:not([disabled]):not([aria-hidden]):not(.fancybox-focus-guard)\",\"iframe\",\"object\",\"embed\",\"video\",\"audio\",\"[contenteditable]\",'[tabindex]:not([tabindex^=\"-\"]):not([disabled]):not([aria-hidden])'].join(\",\"),Q=t=>{if(t&&G){void 0===K&&document.createElement(\"div\").focus({get preventScroll(){return K=!0,!1}});try{if(K)t.focus({preventScroll:!0});else{const e=window.pageXOffset||document.body.scrollTop,i=window.pageYOffset||document.body.scrollLeft;t.focus(),document.body.scrollTo({top:e,left:i,behavior:\"auto\"})}}catch(t){}}},tt={dragToClose:!0,hideScrollbar:!0,Carousel:{classes:{container:\"fancybox__carousel\",viewport:\"fancybox__viewport\",track:\"fancybox__track\",slide:\"fancybox__slide\"}},contentClick:\"toggleZoom\",contentDblClick:!1,backdropClick:\"close\",animated:!0,idle:3500,showClass:\"f-zoomInUp\",hideClass:\"f-fadeOut\",commonCaption:!1,parentEl:null,startIndex:0,l10n:Object.assign(Object.assign({},v),{CLOSE:\"Close\",NEXT:\"Next\",PREV:\"Previous\",MODAL:\"You can close this modal content with the ESC key\",ERROR:\"Something Went Wrong, Please Try Again Later\",IMAGE_ERROR:\"Image Not Found\",ELEMENT_NOT_FOUND:\"HTML Element Not Found\",AJAX_NOT_FOUND:\"Error Loading AJAX : Not Found\",AJAX_FORBIDDEN:\"Error Loading AJAX : Forbidden\",IFRAME_ERROR:\"Error Loading Page\",TOGGLE_ZOOM:\"Toggle zoom level\",TOGGLE_THUMBS:\"Toggle thumbnails\",TOGGLE_SLIDESHOW:\"Toggle slideshow\",TOGGLE_FULLSCREEN:\"Toggle full-screen mode\",DOWNLOAD:\"Download\"}),tpl:{closeButton:'',main:''},groupAll:!1,groupAttr:\"data-fancybox\",defaultType:\"image\",defaultDisplay:\"block\",autoFocus:!0,trapFocus:!0,placeFocusBack:!0,closeButton:\"auto\",keyboard:{Escape:\"close\",Delete:\"close\",Backspace:\"close\",PageUp:\"next\",PageDown:\"prev\",ArrowUp:\"prev\",ArrowDown:\"next\",ArrowRight:\"next\",ArrowLeft:\"prev\"},Fullscreen:{autoStart:!1},compact:()=>window.matchMedia(\"(max-width: 578px), (max-height: 578px)\").matches,wheel:\"zoom\"};var et,it;!function(t){t[t.Init=0]=\"Init\",t[t.Ready=1]=\"Ready\",t[t.Closing=2]=\"Closing\",t[t.CustomClosing=3]=\"CustomClosing\",t[t.Destroy=4]=\"Destroy\"}(et||(et={})),function(t){t[t.Loading=0]=\"Loading\",t[t.Opening=1]=\"Opening\",t[t.Ready=2]=\"Ready\",t[t.Closing=3]=\"Closing\"}(it||(it={}));const nt=()=>{queueMicrotask((()=>{(()=>{const{slug:t,index:e}=st.parseURL(),i=_t.getInstance();if(i&&!1!==i.option(\"Hash\")){const n=i.carousel;if(t&&n){for(let e of n.slides)if(e.slug&&e.slug===t)return n.slideTo(e.index);if(t===i.option(\"slug\"))return n.slideTo(e-1);const s=i.getSlide(),o=s&&s.triggerEl&&s.triggerEl.dataset;if(o&&o.fancybox===t)return n.slideTo(e-1)}st.hasSilentClose=!0,i.close()}st.startFromUrl()})()}))};class st extends B{constructor(){super(...arguments),Object.defineProperty(this,\"origHash\",{enumerable:!0,configurable:!0,writable:!0,value:\"\"}),Object.defineProperty(this,\"timer\",{enumerable:!0,configurable:!0,writable:!0,value:null})}onChange(){const t=this.instance,e=t.carousel;this.timer&&clearTimeout(this.timer);const i=t.getSlide();if(!e||!i)return;const n=t.isOpeningSlide(i),s=new URL(document.URL).hash;let o,a=i.slug||void 0,r=i.triggerEl||void 0;o=a||this.instance.option(\"slug\"),!o&&r&&r.dataset&&(o=r.dataset.fancybox);let l=\"\";o&&\"true\"!==o&&(l=\"#\"+o+(!a&&e.slides.length>1?\"-\"+(i.index+1):\"\")),n&&(this.origHash=s!==l?s:\"\"),l&&s!==l&&(this.timer=setTimeout((()=>{try{t.state===et.Ready&&window.history[n?\"pushState\":\"replaceState\"]({},document.title,window.location.pathname+window.location.search+l)}catch(t){}}),300))}onClose(){if(this.timer&&clearTimeout(this.timer),!0!==st.hasSilentClose)try{window.history.replaceState({},document.title,window.location.pathname+window.location.search+(this.origHash||\"\"))}catch(t){}}attach(){const t=this.instance;t.on(\"Carousel.ready\",this.onChange),t.on(\"Carousel.change\",this.onChange),t.on(\"close\",this.onClose)}detach(){const t=this.instance;t.off(\"Carousel.ready\",this.onChange),t.off(\"Carousel.change\",this.onChange),t.off(\"close\",this.onClose)}static parseURL(){const t=window.location.hash.slice(1),e=t.split(\"-\"),i=e[e.length-1],n=i&&/^\\+?\\d+$/.test(i)&&parseInt(e.pop()||\"1\",10)||1;return{hash:t,slug:e.join(\"-\"),index:n}}static startFromUrl(){if(st.hasSilentClose=!1,_t.getInstance()||!1===_t.defaults.Hash)return;const{hash:t,slug:e,index:i}=st.parseURL();if(!e)return;let n=document.querySelector(`[data-slug=\"${t}\"]`);if(n&&n.dispatchEvent(new CustomEvent(\"click\",{bubbles:!0,cancelable:!0})),_t.getInstance())return;const s=document.querySelectorAll(`[data-fancybox=\"${e}\"]`);s.length&&(n=s[i-1],n&&n.dispatchEvent(new CustomEvent(\"click\",{bubbles:!0,cancelable:!0})))}static destroy(){window.removeEventListener(\"hashchange\",nt,!1)}}function ot(){window.addEventListener(\"hashchange\",nt,!1),setTimeout((()=>{st.startFromUrl()}),500)}Object.defineProperty(st,\"defaults\",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(st,\"hasSilentClose\",{enumerable:!0,configurable:!0,writable:!0,value:!1}),G&&(/complete|interactive|loaded/.test(document.readyState)?ot():document.addEventListener(\"DOMContentLoaded\",ot));class at extends B{onCreateSlide(t,e,i){const n=this.instance.optionFor(i,\"src\")||\"\";i.el&&\"image\"===i.type&&\"string\"==typeof n&&this.setImage(i,n)}onRemoveSlide(t,e,i){i.panzoom&&i.panzoom.destroy(),i.panzoom=void 0,i.imageEl=void 0}onChange(t,e,i,n){for(const t of e.slides){const e=t.panzoom;e&&t.index!==i&&e.reset(.35)}}onClose(){var t;const e=this.instance,i=e.container,n=e.getSlide();if(!i||!i.parentElement||!n)return;const{el:s,contentEl:o,panzoom:a}=n,r=n.thumbElSrc;if(!s||!r||!o||!a||a.isContentLoading||a.state===g.Init||a.state===g.Destroy)return;a.updateMetrics();let l=this.getZoomInfo(n);if(!l)return;this.instance.state=et.CustomClosing,i.classList.remove(\"is-zooming-in\"),i.classList.add(\"is-zooming-out\"),o.style.backgroundImage=`url('${r}')`;const c=i.getBoundingClientRect();1===((null===(t=window.visualViewport)||void 0===t?void 0:t.scale)||1)&&Object.assign(i.style,{position:\"absolute\",top:`${window.pageYOffset}px`,left:`${window.pageXOffset}px`,bottom:\"auto\",right:\"auto\",width:`${c.width}px`,height:`${c.height}px`,overflow:\"hidden\"});const{x:h,y:d,scale:u,opacity:p}=l;if(p){const t=((t,e,i,n)=>{const s=e-t,o=n-i;return e=>i+((e-t)/s*o||0)})(a.scale,u,1,0);a.on(\"afterTransform\",(()=>{o.style.opacity=t(a.scale)+\"\"}))}a.on(\"endAnimation\",(()=>{e.destroy()})),a.target.a=u,a.target.b=0,a.target.c=0,a.target.d=u,a.panTo({x:h,y:d,scale:u,friction:p?.2:.33,ignoreBounds:!0}),a.isResting&&e.destroy()}setImage(t,e){const i=this.instance;t.src=e,this.process(t,e).then((e=>{var n;const s=t.contentEl,o=t.imageEl,a=t.thumbElSrc;if(i.isClosing()||!s||!o)return;s.offsetHeight;const r=!!i.isOpeningSlide(t)&&this.getZoomInfo(t);if(this.option(\"protected\")){null===(n=t.el)||void 0===n||n.addEventListener(\"contextmenu\",(t=>{t.preventDefault()}));const e=document.createElement(\"div\");S(e,\"fancybox-protected\"),s.appendChild(e)}if(a&&r){const n=e.contentRect,o=Math.max(n.fullWidth,n.fullHeight);let c=null;!r.opacity&&o>1200&&(c=document.createElement(\"img\"),S(c,\"fancybox-ghost\"),c.src=a,s.appendChild(c));const h=()=>{c&&(S(c,\"f-fadeFastOut\"),setTimeout((()=>{c&&(c.remove(),c=null)}),200))};(l=a,new Promise(((t,e)=>{const i=new Image;i.onload=t,i.onerror=e,i.src=l}))).then((()=>{t.state=it.Opening,this.instance.emit(\"reveal\",t),this.zoomIn(t).then((()=>{h(),this.instance.done(t)}),(()=>{i.hideLoading(t)})),c&&setTimeout((()=>{h()}),o>2500?800:200)}),(()=>{i.hideLoading(t),i.revealContent(t)}))}else{const n=this.optionFor(t,\"initialSize\"),s=this.optionFor(t,\"zoom\"),o={event:i.prevMouseMoveEvent||i.options.event,friction:s?.12:0};let a=i.optionFor(t,\"showClass\")||void 0,r=!0;i.isOpeningSlide(t)&&(\"full\"===n?e.zoomToFull(o):\"cover\"===n?e.zoomToCover(o):\"max\"===n?e.zoomToMax(o):r=!1,e.stop(\"current\")),r&&a&&(a=e.isDragging?\"f-fadeIn\":\"\"),i.revealContent(t,a)}var l}),(()=>{i.setError(t,\"{{IMAGE_ERROR}}\")}))}process(t,e){return new Promise(((i,s)=>{var o;const a=this.instance,r=t.el;a.clearContent(t),a.showLoading(t);let l=this.optionFor(t,\"content\");if(\"string\"==typeof l&&(l=n(l)),!l||!x(l)){if(l=document.createElement(\"img\"),l instanceof HTMLImageElement){let i=\"\",n=t.caption;i=\"string\"==typeof n&&n?n.replace(/<[^>]+>/gi,\"\").substring(0,1e3):`Image ${t.index+1} of ${null===(o=a.carousel)||void 0===o?void 0:o.pages.length}`,l.src=e||\"\",l.alt=i,l.draggable=!1,t.srcset&&l.setAttribute(\"srcset\",t.srcset)}t.sizes&&l.setAttribute(\"sizes\",t.sizes)}l.classList.add(\"fancybox-image\"),t.imageEl=l,a.setContent(t,l,!1);t.panzoom=new R(r,u({transformParent:!0},this.option(\"Panzoom\")||{},{content:l,width:a.optionFor(t,\"width\",\"auto\"),height:a.optionFor(t,\"height\",\"auto\"),wheel:()=>{const t=a.option(\"wheel\");return(\"zoom\"===t||\"pan\"==t)&&t},click:(e,i)=>{var n,s;if(a.isCompact||a.isClosing())return!1;if(t.index!==(null===(n=a.getSlide())||void 0===n?void 0:n.index))return!1;if(i){const t=i.composedPath()[0];if([\"A\",\"BUTTON\",\"TEXTAREA\",\"OPTION\",\"INPUT\",\"SELECT\",\"VIDEO\"].includes(t.nodeName))return!1}let o=!i||i.target&&(null===(s=t.contentEl)||void 0===s?void 0:s.contains(i.target));return a.option(o?\"contentClick\":\"backdropClick\")||!1},dblClick:()=>a.isCompact?\"toggleZoom\":a.option(\"contentDblClick\")||!1,spinner:!1,panOnlyZoomed:!0,wheelLimit:1/0,on:{ready:t=>{i(t)},error:()=>{s()},destroy:()=>{s()}}}))}))}zoomIn(t){return new Promise(((e,i)=>{const n=this.instance,s=n.container,{panzoom:o,contentEl:a,el:r}=t;o&&o.updateMetrics();const l=this.getZoomInfo(t);if(!(l&&r&&a&&o&&s))return void i();const{x:c,y:h,scale:d,opacity:u}=l,p=()=>{t.state!==it.Closing&&(u&&(a.style.opacity=Math.max(Math.min(1,1-(1-o.scale)/(1-d)),0)+\"\"),o.scale>=1&&o.scale>o.targetScale-.1&&e(o))},f=t=>{E(s,\"is-zooming-in\"),t.scale<.99||t.scale>1.01||(a.style.opacity=\"\",t.off(\"endAnimation\",f),t.off(\"touchStart\",f),t.off(\"afterTransform\",p),e(t))};o.on(\"endAnimation\",f),o.on(\"touchStart\",f),o.on(\"afterTransform\",p),o.on([\"error\",\"destroy\"],(()=>{i()})),o.panTo({x:c,y:h,scale:d,friction:0,ignoreBounds:!0}),o.stop(\"current\");const m={event:\"mousemove\"===o.panMode?n.prevMouseMoveEvent||n.options.event:void 0},g=this.optionFor(t,\"initialSize\");S(s,\"is-zooming-in\"),n.hideLoading(t),\"full\"===g?o.zoomToFull(m):\"cover\"===g?o.zoomToCover(m):\"max\"===g?o.zoomToMax(m):o.reset(.172)}))}getZoomInfo(t){var e;const{el:i,imageEl:n,thumbEl:s,panzoom:o}=t;if(!i||!n||!s||!o||U(s)<3||!this.optionFor(t,\"zoom\")||this.instance.state===et.Destroy)return!1;if(1!==((null===(e=window.visualViewport)||void 0===e?void 0:e.scale)||1))return!1;let{top:a,left:r,width:l,height:c}=s.getBoundingClientRect(),{top:h,left:d,fitWidth:u,fitHeight:p}=o.contentRect;if(!(l&&c&&u&&p))return!1;const f=o.container.getBoundingClientRect();d+=f.left,h+=f.top;const m=-1*(d+.5*u-(r+.5*l)),g=-1*(h+.5*p-(a+.5*c)),b=l/u;let v=this.option(\"zoomOpacity\")||!1;return\"auto\"===v&&(v=Math.abs(l/c-u/p)>.1),{x:m,y:g,scale:b,opacity:v}}attach(){const t=this,e=t.instance;e.on(\"Carousel.change\",t.onChange),e.on(\"Carousel.createSlide\",t.onCreateSlide),e.on(\"Carousel.removeSlide\",t.onRemoveSlide),e.on(\"close\",t.onClose)}detach(){const t=this,e=t.instance;e.off(\"Carousel.change\",t.onChange),e.off(\"Carousel.createSlide\",t.onCreateSlide),e.off(\"Carousel.removeSlide\",t.onRemoveSlide),e.off(\"close\",t.onClose)}}Object.defineProperty(at,\"defaults\",{enumerable:!0,configurable:!0,writable:!0,value:{initialSize:\"fit\",Panzoom:{maxScale:1},protected:!1,zoom:!0,zoomOpacity:\"auto\"}}),\"function\"==typeof SuppressedError&&SuppressedError;const rt=(t,e={})=>{const i=new URL(t),n=new URLSearchParams(i.search),s=new URLSearchParams;for(const[t,i]of[...n,...Object.entries(e)]){let e=i.toString();\"t\"===t?s.set(\"start\",parseInt(e).toString()):s.set(t,e)}let o=s.toString(),a=t.match(/#t=((.*)?\\d+s)/);return a&&(o+=`#t=${a[1]}`),o},lt={ajax:null,autoSize:!0,iframeAttr:{allow:\"autoplay; fullscreen\",scrolling:\"auto\"},preload:!0,videoAutoplay:!0,videoRatio:16/9,videoTpl:'',videoFormat:\"\",vimeo:{byline:1,color:\"00adef\",controls:1,dnt:1,muted:0},youtube:{controls:1,enablejsapi:1,nocookie:1,rel:0,fs:1}},ct=[\"image\",\"html\",\"ajax\",\"inline\",\"clone\",\"iframe\",\"map\",\"pdf\",\"html5video\",\"youtube\",\"vimeo\",\"video\"];class ht extends B{onInitSlide(t,e,i){this.processType(i)}onCreateSlide(t,e,i){this.setContent(i)}onRemoveSlide(t,e,i){i.xhr&&(i.xhr.abort(),i.xhr=null);const n=i.iframeEl;n&&(n.onload=n.onerror=null,n.src=\"//about:blank\",i.iframeEl=null);const s=i.contentEl,o=i.placeholderEl;if(\"inline\"===i.type&&s&&o)s.classList.remove(\"fancybox__content\"),\"none\"!==s.style.display&&(s.style.display=\"none\"),o.parentNode&&o.parentNode.insertBefore(s,o),o.remove(),i.contentEl=void 0,i.placeholderEl=void 0;else for(;i.el&&i.el.firstChild;)i.el.removeChild(i.el.firstChild)}onSelectSlide(t,e,i){i.state===it.Ready&&this.playVideo()}onUnselectSlide(t,e,i){var n,s;if(\"html5video\"===i.type){try{null===(s=null===(n=i.el)||void 0===n?void 0:n.querySelector(\"video\"))||void 0===s||s.pause()}catch(t){}return}let o;\"vimeo\"===i.type?o={method:\"pause\",value:\"true\"}:\"youtube\"===i.type&&(o={event:\"command\",func:\"pauseVideo\"}),o&&i.iframeEl&&i.iframeEl.contentWindow&&i.iframeEl.contentWindow.postMessage(JSON.stringify(o),\"*\"),i.poller&&clearTimeout(i.poller)}onDone(t,e){t.isCurrentSlide(e)&&!t.isClosing()&&this.playVideo()}onRefresh(t,e){e.slides.forEach((t=>{t.el&&(this.setAspectRatio(t),this.resizeIframe(t))}))}onMessage(t){try{let e=JSON.parse(t.data);if(\"https://player.vimeo.com\"===t.origin){if(\"ready\"===e.event)for(let e of Array.from(document.getElementsByClassName(\"fancybox__iframe\")))e instanceof HTMLIFrameElement&&e.contentWindow===t.source&&(e.dataset.ready=\"true\")}else if(t.origin.match(/^https:\\/\\/(www.)?youtube(-nocookie)?.com$/)&&\"onReady\"===e.event){const t=document.getElementById(e.id);t&&(t.dataset.ready=\"true\")}}catch(t){}}loadAjaxContent(t){const e=this.instance.optionFor(t,\"src\")||\"\";this.instance.showLoading(t);const i=this.instance,n=new XMLHttpRequest;i.showLoading(t),n.onreadystatechange=function(){n.readyState===XMLHttpRequest.DONE&&i.state===et.Ready&&(i.hideLoading(t),200===n.status?i.setContent(t,n.responseText):i.setError(t,404===n.status?\"{{AJAX_NOT_FOUND}}\":\"{{AJAX_FORBIDDEN}}\"))};const s=t.ajax||null;n.open(s?\"POST\":\"GET\",e+\"\"),n.setRequestHeader(\"Content-Type\",\"application/x-www-form-urlencoded\"),n.setRequestHeader(\"X-Requested-With\",\"XMLHttpRequest\"),n.send(s),t.xhr=n}setInlineContent(t){let e=null;if(x(t.src))e=t.src;else if(\"string\"==typeof t.src){const i=t.src.split(\"#\",2).pop();e=i?document.getElementById(i):null}if(e){if(\"clone\"===t.type||e.closest(\".fancybox__slide\")){e=e.cloneNode(!0);const i=e.dataset.animationName;i&&(e.classList.remove(i),delete e.dataset.animationName);let n=e.getAttribute(\"id\");n=n?`${n}--clone`:`clone-${this.instance.id}-${t.index}`,e.setAttribute(\"id\",n)}else if(e.parentNode){const i=document.createElement(\"div\");i.classList.add(\"fancybox-placeholder\"),e.parentNode.insertBefore(i,e),t.placeholderEl=i}this.instance.setContent(t,e)}else this.instance.setError(t,\"{{ELEMENT_NOT_FOUND}}\")}setIframeContent(t){const{src:e,el:i}=t;if(!e||\"string\"!=typeof e||!i)return;i.classList.add(\"is-loading\");const n=this.instance,s=document.createElement(\"iframe\");s.className=\"fancybox__iframe\",s.setAttribute(\"id\",`fancybox__iframe_${n.id}_${t.index}`);for(const[e,i]of Object.entries(this.optionFor(t,\"iframeAttr\")||{}))s.setAttribute(e,i);s.onerror=()=>{n.setError(t,\"{{IFRAME_ERROR}}\")},t.iframeEl=s;const o=this.optionFor(t,\"preload\");if(\"iframe\"!==t.type||!1===o)return s.setAttribute(\"src\",t.src+\"\"),n.setContent(t,s,!1),this.resizeIframe(t),void n.revealContent(t);n.showLoading(t),s.onload=()=>{if(!s.src.length)return;const e=\"true\"!==s.dataset.ready;s.dataset.ready=\"true\",this.resizeIframe(t),e?n.revealContent(t):n.hideLoading(t)},s.setAttribute(\"src\",e),n.setContent(t,s,!1)}resizeIframe(t){const e=t.iframeEl,i=null==e?void 0:e.parentElement;if(!e||!i)return;let n=t.autoSize,s=t.width||0,o=t.height||0;s&&o&&(n=!1);const a=i&&i.style;if(!1!==t.preload&&!1!==n&&a)try{const t=window.getComputedStyle(i),n=parseFloat(t.paddingLeft)+parseFloat(t.paddingRight),r=parseFloat(t.paddingTop)+parseFloat(t.paddingBottom),l=e.contentWindow;if(l){const t=l.document,e=t.getElementsByTagName(\"html\")[0],i=t.body;a.width=\"\",i.style.overflow=\"hidden\",s=s||e.scrollWidth+n,a.width=`${s}px`,i.style.overflow=\"\",a.flex=\"0 0 auto\",a.height=`${i.scrollHeight}px`,o=e.scrollHeight+r}}catch(t){}if(s||o){const t={flex:\"0 1 auto\",width:\"\",height:\"\"};s&&(t.width=`${s}px`),o&&(t.height=`${o}px`),Object.assign(a,t)}}playVideo(){const t=this.instance.getSlide();if(!t)return;const{el:e}=t;if(!e||!e.offsetParent)return;if(!this.optionFor(t,\"videoAutoplay\"))return;if(\"html5video\"===t.type)try{const t=e.querySelector(\"video\");if(t){const e=t.play();void 0!==e&&e.then((()=>{})).catch((e=>{t.muted=!0,t.play()}))}}catch(t){}if(\"youtube\"!==t.type&&\"vimeo\"!==t.type)return;const i=()=>{if(t.iframeEl&&t.iframeEl.contentWindow){let e;if(\"true\"===t.iframeEl.dataset.ready)return e=\"youtube\"===t.type?{event:\"command\",func:\"playVideo\"}:{method:\"play\",value:\"true\"},e&&t.iframeEl.contentWindow.postMessage(JSON.stringify(e),\"*\"),void(t.poller=void 0);\"youtube\"===t.type&&(e={event:\"listening\",id:t.iframeEl.getAttribute(\"id\")},t.iframeEl.contentWindow.postMessage(JSON.stringify(e),\"*\"))}t.poller=setTimeout(i,250)};i()}processType(t){if(t.html)return t.type=\"html\",t.src=t.html,void(t.html=\"\");const e=this.instance.optionFor(t,\"src\",\"\");if(!e||\"string\"!=typeof e)return;let i=t.type,n=null;if(n=e.match(/(youtube\\.com|youtu\\.be|youtube\\-nocookie\\.com)\\/(?:watch\\?(?:.*&)?v=|v\\/|u\\/|shorts\\/|embed\\/?)?(videoseries\\?list=(?:.*)|[\\w-]{11}|\\?listType=(?:.*)&list=(?:.*))(?:.*)/i)){const s=this.optionFor(t,\"youtube\"),{nocookie:o}=s,a=function(t,e){var i={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(null!=t&&\"function\"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(t);s0?\"svembed\":\"embed\"}`,i=\"map\"):(n=e.match(/(?:maps\\.)?google\\.([a-z]{2,3}(?:\\.[a-z]{2})?)\\/(?:maps\\/search\\/)(.*)/i))&&(t.src=`https://maps.google.${n[1]}/maps?q=${n[2].replace(\"query=\",\"q=\").replace(\"api=1\",\"\")}&output=embed`,i=\"map\")),i=i||this.instance.option(\"defaultType\"),t.type=i,\"image\"===i&&(t.thumbSrc=t.thumbSrc||t.src)}setContent(t){const e=this.instance.optionFor(t,\"src\")||\"\";if(t&&t.type&&e){switch(t.type){case\"html\":this.instance.setContent(t,e);break;case\"html5video\":const i=this.option(\"videoTpl\");i&&this.instance.setContent(t,i.replace(/\\{\\{src\\}\\}/gi,e+\"\").replace(/\\{\\{format\\}\\}/gi,this.optionFor(t,\"videoFormat\")||\"\").replace(/\\{\\{poster\\}\\}/gi,t.poster||t.thumbSrc||\"\"));break;case\"inline\":case\"clone\":this.setInlineContent(t);break;case\"ajax\":this.loadAjaxContent(t);break;case\"pdf\":case\"map\":case\"youtube\":case\"vimeo\":t.preload=!1;case\"iframe\":this.setIframeContent(t)}this.setAspectRatio(t)}}setAspectRatio(t){var e;const i=t.width||0,n=t.height||0;if(i&&n)return;const s=t.contentEl,o=this.optionFor(t,\"videoRatio\"),a=null===(e=t.el)||void 0===e?void 0:e.getBoundingClientRect();if(!(s&&a&&o&&1!==o&&t.type&&[\"video\",\"youtube\",\"vimeo\",\"html5video\"].includes(t.type)))return;const r=a.width,l=a.height;s.style.aspectRatio=o+\"\",s.style.width=r/l>o?\"auto\":\"\",s.style.height=r/l>o?\"\":\"auto\"}attach(){const t=this,e=t.instance;e.on(\"Carousel.initSlide\",t.onInitSlide),e.on(\"Carousel.createSlide\",t.onCreateSlide),e.on(\"Carousel.removeSlide\",t.onRemoveSlide),e.on(\"Carousel.selectSlide\",t.onSelectSlide),e.on(\"Carousel.unselectSlide\",t.onUnselectSlide),e.on(\"Carousel.Panzoom.refresh\",t.onRefresh),e.on(\"done\",t.onDone),window.addEventListener(\"message\",t.onMessage)}detach(){const t=this,e=t.instance;e.off(\"Carousel.initSlide\",t.onInitSlide),e.off(\"Carousel.createSlide\",t.onCreateSlide),e.off(\"Carousel.removeSlide\",t.onRemoveSlide),e.off(\"Carousel.selectSlide\",t.onSelectSlide),e.off(\"Carousel.unselectSlide\",t.onUnselectSlide),e.off(\"Carousel.Panzoom.refresh\",t.onRefresh),e.off(\"done\",t.onDone),window.removeEventListener(\"message\",t.onMessage)}}Object.defineProperty(ht,\"defaults\",{enumerable:!0,configurable:!0,writable:!0,value:lt});const dt=\"play\",ut=\"pause\",pt=\"ready\";class ft extends B{constructor(){super(...arguments),Object.defineProperty(this,\"state\",{enumerable:!0,configurable:!0,writable:!0,value:pt}),Object.defineProperty(this,\"inHover\",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,\"timer\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"progressBar\",{enumerable:!0,configurable:!0,writable:!0,value:null})}get isActive(){return this.state!==pt}onReady(t){this.option(\"autoStart\")&&(t.isInfinite||t.page{t.timer=null,t.inHover||t.onTimerEnd()}),i),t.emit(\"set\")}clear(){const t=this;t.timer&&(clearTimeout(t.timer),t.timer=null),t.removeProgressBar()}start(){const t=this;if(t.set(),t.state!==pt){if(t.option(\"pauseOnHover\")){const e=t.instance.container;e.addEventListener(\"mouseenter\",t.onMouseEnter,!1),e.addEventListener(\"mouseleave\",t.onMouseLeave,!1)}document.addEventListener(\"visibilitychange\",t.onVisibilityChange,!1),t.emit(\"start\")}}stop(){const t=this,e=t.state,i=t.instance.container;t.clear(),t.state=pt,i.removeEventListener(\"mouseenter\",t.onMouseEnter,!1),i.removeEventListener(\"mouseleave\",t.onMouseLeave,!1),document.removeEventListener(\"visibilitychange\",t.onVisibilityChange,!1),E(i,\"has-autoplay\"),e!==pt&&t.emit(\"stop\")}pause(){const t=this;t.state===dt&&(t.state=ut,t.clear(),t.emit(ut))}resume(){const t=this,e=t.instance;if(e.isInfinite||e.page!==e.pages.length-1)if(t.state!==dt){if(t.state===ut&&!t.inHover){const e=new Event(\"resume\",{bubbles:!0,cancelable:!0});t.emit(\"resume\",e),e.defaultPrevented||t.set()}}else t.set();else t.stop()}toggle(){this.state===dt||this.state===ut?this.stop():this.start()}attach(){const t=this,e=t.instance;e.on(\"ready\",t.onReady),e.on(\"Panzoom.startAnimation\",t.onChange),e.on(\"Panzoom.endAnimation\",t.onSettle),e.on(\"Panzoom.touchMove\",t.onChange)}detach(){const t=this,e=t.instance;e.off(\"ready\",t.onReady),e.off(\"Panzoom.startAnimation\",t.onChange),e.off(\"Panzoom.endAnimation\",t.onSettle),e.off(\"Panzoom.touchMove\",t.onChange),t.stop()}}Object.defineProperty(ft,\"defaults\",{enumerable:!0,configurable:!0,writable:!0,value:{autoStart:!0,pauseOnHover:!0,progressParentEl:null,showProgress:!0,timeout:3e3}});class mt extends B{constructor(){super(...arguments),Object.defineProperty(this,\"ref\",{enumerable:!0,configurable:!0,writable:!0,value:null})}onPrepare(t){const e=t.carousel;if(!e)return;const i=t.container;i&&(e.options.Autoplay=u({autoStart:!1},this.option(\"Autoplay\")||{},{pauseOnHover:!1,timeout:this.option(\"timeout\"),progressParentEl:()=>this.option(\"progressParentEl\")||null,on:{start:()=>{t.emit(\"startSlideshow\")},set:e=>{var n;i.classList.add(\"has-slideshow\"),(null===(n=t.getSlide())||void 0===n?void 0:n.state)!==it.Ready&&e.pause()},stop:()=>{i.classList.remove(\"has-slideshow\"),t.isCompact||t.endIdle(),t.emit(\"endSlideshow\")},resume:(e,i)=>{var n,s,o;!i||!i.cancelable||(null===(n=t.getSlide())||void 0===n?void 0:n.state)===it.Ready&&(null===(o=null===(s=t.carousel)||void 0===s?void 0:s.panzoom)||void 0===o?void 0:o.isResting)||i.preventDefault()}}}),e.attachPlugins({Autoplay:ft}),this.ref=e.plugins.Autoplay)}onReady(t){const e=t.carousel,i=this.ref;e&&i&&this.option(\"playOnStart\")&&(e.isInfinite||e.page{t.isCurrentSlide(e)&&i.stop()})),t.isCurrentSlide(e)&&i.resume()}onKeydown(t,e){var i;const n=this.ref;n&&e===this.option(\"key\")&&\"BUTTON\"!==(null===(i=document.activeElement)||void 0===i?void 0:i.nodeName)&&n.toggle()}attach(){const t=this,e=t.instance;e.on(\"Carousel.init\",t.onPrepare),e.on(\"Carousel.ready\",t.onReady),e.on(\"done\",t.onDone),e.on(\"keydown\",t.onKeydown)}detach(){const t=this,e=t.instance;e.off(\"Carousel.init\",t.onPrepare),e.off(\"Carousel.ready\",t.onReady),e.off(\"done\",t.onDone),e.off(\"keydown\",t.onKeydown)}}Object.defineProperty(mt,\"defaults\",{enumerable:!0,configurable:!0,writable:!0,value:{key:\" \",playOnStart:!1,progressParentEl:t=>{var e;return(null===(e=t.instance.container)||void 0===e?void 0:e.querySelector(\".fancybox__toolbar [data-fancybox-toggle-slideshow]\"))||t.instance.container},timeout:3e3}});const gt={classes:{container:\"f-thumbs f-carousel__thumbs\",viewport:\"f-thumbs__viewport\",track:\"f-thumbs__track\",slide:\"f-thumbs__slide\",isResting:\"is-resting\",isSelected:\"is-selected\",isLoading:\"is-loading\",hasThumbs:\"has-thumbs\"},minCount:2,parentEl:null,thumbTpl:'',type:\"modern\"};var bt;!function(t){t[t.Init=0]=\"Init\",t[t.Ready=1]=\"Ready\",t[t.Hidden=2]=\"Hidden\",t[t.Disabled=3]=\"Disabled\"}(bt||(bt={}));let vt=class extends B{constructor(){super(...arguments),Object.defineProperty(this,\"type\",{enumerable:!0,configurable:!0,writable:!0,value:\"modern\"}),Object.defineProperty(this,\"container\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"track\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"carousel\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"panzoom\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"thumbWidth\",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,\"thumbClipWidth\",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,\"thumbHeight\",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,\"thumbGap\",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,\"thumbExtraGap\",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,\"shouldCenter\",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,\"state\",{enumerable:!0,configurable:!0,writable:!0,value:bt.Init})}formatThumb(t,e){return this.instance.localize(e,[[\"%i\",t.index],[\"%d\",t.index+1],[\"%s\",t.thumbSrc||\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\"]])}getSlides(){const t=[],e=this.option(\"thumbTpl\")||\"\";if(e)for(const i of this.instance.slides||[]){let n=\"\";i.type&&(n=`for-${i.type}`,i.type&&[\"video\",\"youtube\",\"vimeo\",\"html5video\"].includes(i.type)&&(n+=\" for-video\")),t.push({html:this.formatThumb(i,e),customClass:n})}return t}onInitSlide(t,e){const i=e.el;i&&(e.thumbSrc=i.dataset.thumbSrc||e.thumbSrc||\"\",e.thumbClipWidth=parseFloat(i.dataset.thumbClipWidth||\"\")||e.thumbClipWidth||0,e.thumbHeight=parseFloat(i.dataset.thumbHeight||\"\")||e.thumbHeight||0)}onInitSlides(){this.state===bt.Init&&this.build()}onRefreshM(){this.refreshModern()}onChangeM(){\"modern\"===this.type&&(this.shouldCenter=!0,this.centerModern())}onClickModern(t){t.preventDefault(),t.stopPropagation();const e=this.instance,i=e.page,n=t=>{if(t){const e=t.closest(\"[data-carousel-index]\");if(e)return parseInt(e.dataset.carouselIndex||\"\",10)||0}return-1},s=(t,e)=>{const i=document.elementFromPoint(t,e);return i?n(i):-1};let o=n(t.target);o<0&&(o=s(t.clientX+this.thumbGap,t.clientY),o===i&&(o=i-1)),o<0&&(o=s(t.clientX-this.thumbGap,t.clientY),o===i&&(o=i+1)),o<0&&(o=(e=>{let n=s(t.clientX-e,t.clientY),a=s(t.clientX+e,t.clientY);return o<0&&n===i&&(o=i+1),o<0&&a===i&&(o=i-1),o})(this.thumbExtraGap)),o===i?this.centerModern():o>-1&&o{this.emit(\"ready\")})),n.on(\"createSlide\",((t,e)=>{this.emit(\"createSlide\",e,e.el)}))}buildModern(){if(\"modern\"!==this.type)return;const{container:t,track:e,instance:i}=this,s=this.option(\"thumbTpl\")||\"\";if(!t||!e||!s)return;t.addEventListener(\"keydown\",(()=>{E(t,\"is-using-mouse\")})),S(t,\"is-horizontal\"),this.updateModern();for(const t of i.slides||[]){const i=document.createElement(\"div\");if(S(i,this.cn(\"slide\")),t.type){let e=`for-${t.type}`;[\"video\",\"youtube\",\"vimeo\",\"html5video\"].includes(t.type)&&(e+=\" for-video\"),S(i,e)}i.appendChild(n(this.formatThumb(t,s))),this.emit(\"createSlide\",t,i),t.thumbSlideEl=i,e.appendChild(i),this.resizeModernSlide(t)}const o=new i.constructor.Panzoom(t,{content:e,lockAxis:\"x\",zoom:!1,panOnlyZoomed:!1,bounds:()=>{let t=0,e=0,n=i.slides[0],s=i.slides[i.slides.length-1],o=i.slides[i.page];return n&&s&&o&&(e=-1*this.getModernThumbPos(0),0!==i.page&&(e+=.5*(n.thumbWidth||0)),t=-1*this.getModernThumbPos(i.slides.length-1),i.page!==i.slides.length-1&&(t+=(s.thumbWidth||0)-(o.thumbWidth||0)-.5*(s.thumbWidth||0))),{x:{min:t,max:e},y:{min:0,max:0}}}});o.on(\"touchStart\",((t,e)=>{this.shouldCenter=!1,S(this.container,\"is-using-mouse\")})),o.on(\"click\",((t,e)=>this.onClickModern(e))),o.on(\"ready\",(()=>{this.centerModern(),this.emit(\"ready\")})),o.on([\"afterTransform\",\"refresh\"],(t=>{this.lazyLoadModern()})),this.panzoom=o,this.refreshModern()}updateModern(){if(\"modern\"!==this.type)return;const{container:t}=this;t&&(this.thumbGap=parseFloat(getComputedStyle(t).getPropertyValue(\"--f-thumb-gap\"))||0,this.thumbExtraGap=parseFloat(getComputedStyle(t).getPropertyValue(\"--f-thumb-extra-gap\"))||0,this.thumbWidth=parseFloat(getComputedStyle(t).getPropertyValue(\"--f-thumb-width\"))||40,this.thumbClipWidth=parseFloat(getComputedStyle(t).getPropertyValue(\"--f-thumb-clip-width\"))||40,this.thumbHeight=parseFloat(getComputedStyle(t).getPropertyValue(\"--f-thumb-height\"))||40)}refreshModern(){var t;if(\"modern\"===this.type){this.updateModern();for(const t of this.instance.slides||[])this.resizeModernSlide(t);this.onTransformM(),null===(t=this.panzoom)||void 0===t||t.updateMetrics(!0),this.centerModern(0)}}centerModern(e){const i=this.instance,{container:n,panzoom:s}=this;if(!n||!s||s.state===g.Init)return;const o=i.page;let a=this.getModernThumbPos(o),r=a;for(let t=i.page-3;ti.pages.length-1||t===i.page)continue;const e=1-Math.abs(i.getProgress(t));e>0&&e<1&&(r+=e*(this.getModernThumbPos(t)-a))}let l=100;void 0===e&&(e=.2,i.inTransition.size>0&&(e=.12),Math.abs(-1*s.current.e-r)>s.containerRect.width&&(e=.5,l=0)),s.options.maxVelocity=l,s.applyChange({panX:t(-1*r-s.target.e,1e3),friction:null===i.prevPage?0:e})}lazyLoadModern(){const{instance:t,panzoom:e}=this;if(!e)return;const i=-1*e.current.e||0;let s=this.getModernThumbPos(t.page);if(e.state!==g.Init||0===s)for(const s of t.slides||[]){const t=s.thumbSlideEl;if(!t)continue;const o=t.querySelector(\"img[data-lazy-src]\"),a=s.index,r=this.getModernThumbPos(a),l=i-.5*e.containerRect.innerWidth,c=l+e.containerRect.innerWidth;if(!o||rc)continue;let h=o.dataset.lazySrc;if(!h||!h.length)continue;if(delete o.dataset.lazySrc,o.src=h,o.complete)continue;S(t,this.cn(\"isLoading\"));const d=n(w);t.appendChild(d),o.addEventListener(\"load\",(()=>{t.offsetParent&&(t.classList.remove(this.cn(\"isLoading\")),d.remove())}),!1)}}resizeModernSlide(t){if(\"modern\"!==this.type)return;if(!t.thumbSlideEl)return;const e=t.thumbClipWidth&&t.thumbHeight?Math.round(this.thumbHeight*(t.thumbClipWidth/t.thumbHeight)):this.thumbWidth;t.thumbWidth=e}getModernThumbPos(e){const i=this.instance.slides[e],n=this.panzoom;if(!n||!n.contentRect.fitWidth)return 0;let s=n.containerRect.innerWidth,o=n.contentRect.width;2===this.instance.slides.length&&(e-=1,o=2*this.thumbClipWidth);let a=e*(this.thumbClipWidth+this.thumbGap)+this.thumbExtraGap+.5*(i.thumbWidth||0);return a-=o>s?.5*s:.5*o,t(a||0,1)}build(){const t=this.instance,e=t.container,i=this.option(\"minCount\")||0;if(i){let e=0;for(const i of t.slides||[])i.thumbSrc&&e++;if(e{const i=t.container;i&&this.hidden&&(e.refresh(),i.style.transition=\"none\",e.hide(),i.offsetHeight,queueMicrotask((()=>{i.style.transition=\"\",e.show()})))}}});o.Carousel=o.Carousel||{},o.Carousel.on=u((null===(t=e.options.Carousel)||void 0===t?void 0:t.on)||{},{click:(t,e)=>{e.stopPropagation()}}),n.options.Thumbs=o,n.attachPlugins({Thumbs:vt}),e.ref=n.plugins.Thumbs,e.option(\"showOnStart\")||(e.ref.state=bt.Hidden,e.hidden=!0)}onResize(){var t;const e=null===(t=this.ref)||void 0===t?void 0:t.container;e&&(e.style.maxHeight=\"\")}onKeydown(t,e){const i=this.option(\"key\");i&&i===e&&this.toggle()}toggle(){const t=this.ref;t&&t.state!==bt.Disabled&&(t.state!==bt.Hidden?this.hidden?this.show():this.hide():t.build())}show(){const t=this.ref,e=t&&t.state!==bt.Disabled&&t.container;e&&(this.refresh(),e.offsetHeight,e.removeAttribute(xt),e.classList.remove(wt),this.hidden=!1)}hide(){const t=this.ref,e=t&&t.container;e&&(this.refresh(),e.offsetHeight,e.classList.add(wt),e.setAttribute(xt,\"true\")),this.hidden=!0}refresh(){const t=this.ref;if(!t||t.state===bt.Disabled)return;const e=t.container,i=(null==e?void 0:e.firstChild)||null;e&&i&&i.childNodes.length&&(e.style.maxHeight=`${i.getBoundingClientRect().height}px`)}attach(){const t=this,e=t.instance;e.state===et.Init?e.on(\"Carousel.init\",t.onInit):t.onInit(),e.on(\"resize\",t.onResize),e.on(\"keydown\",t.onKeydown)}detach(){var t;const e=this,i=e.instance;i.off(\"Carousel.init\",e.onInit),i.off(\"resize\",e.onResize),i.off(\"keydown\",e.onKeydown),null===(t=i.carousel)||void 0===t||t.detachPlugins([\"Thumbs\"]),e.ref=null}}Object.defineProperty(Et,\"defaults\",{enumerable:!0,configurable:!0,writable:!0,value:yt});const St={panLeft:{icon:'',change:{panX:-100}},panRight:{icon:'',change:{panX:100}},panUp:{icon:'',change:{panY:-100}},panDown:{icon:'',change:{panY:100}},zoomIn:{icon:'',action:\"zoomIn\"},zoomOut:{icon:'',action:\"zoomOut\"},toggle1to1:{icon:'',action:\"toggleZoom\"},toggleZoom:{icon:'',action:\"toggleZoom\"},iterateZoom:{icon:'',action:\"iterateZoom\"},rotateCCW:{icon:'',action:\"rotateCCW\"},rotateCW:{icon:'',action:\"rotateCW\"},flipX:{icon:'',action:\"flipX\"},flipY:{icon:'',action:\"flipY\"},fitX:{icon:'',action:\"fitX\"},fitY:{icon:'',action:\"fitY\"},reset:{icon:'',action:\"reset\"},toggleFS:{icon:'',action:\"toggleFS\"}};var Pt;!function(t){t[t.Init=0]=\"Init\",t[t.Ready=1]=\"Ready\",t[t.Disabled=2]=\"Disabled\"}(Pt||(Pt={}));const Ct={absolute:\"auto\",display:{left:[\"infobar\"],middle:[],right:[\"iterateZoom\",\"slideshow\",\"fullscreen\",\"thumbs\",\"close\"]},enabled:\"auto\",items:{infobar:{tpl:'/
'},download:{tpl:''},prev:{tpl:''},next:{tpl:''},slideshow:{tpl:''},fullscreen:{tpl:''},thumbs:{tpl:''},close:{tpl:''}},parentEl:null},Mt={tabindex:\"-1\",width:\"24\",height:\"24\",viewBox:\"0 0 24 24\",xmlns:\"http://www.w3.org/2000/svg\"};class Tt extends B{constructor(){super(...arguments),Object.defineProperty(this,\"state\",{enumerable:!0,configurable:!0,writable:!0,value:Pt.Init}),Object.defineProperty(this,\"container\",{enumerable:!0,configurable:!0,writable:!0,value:null})}onReady(t){var e;if(!t.carousel)return;let i=this.option(\"display\"),n=this.option(\"absolute\"),s=this.option(\"enabled\");if(\"auto\"===s){const t=this.instance.carousel;let e=0;if(t)for(const i of t.slides)(i.panzoom||\"image\"===i.type)&&e++;e||(s=!1)}s||(i=void 0);let o=0;const a={left:[],middle:[],right:[]};if(i)for(const t of[\"left\",\"middle\",\"right\"])for(const n of i[t]){const i=this.createEl(n);i&&(null===(e=a[t])||void 0===e||e.push(i),o++)}let r=null;if(o&&(r=this.createContainer()),r){for(const[t,e]of Object.entries(a)){const i=document.createElement(\"div\");S(i,\"fancybox__toolbar__column is-\"+t);for(const t of e)i.appendChild(t);\"auto\"!==n||\"middle\"!==t||e.length||(n=!0),r.appendChild(i)}!0===n&&S(r,\"is-absolute\"),this.state=Pt.Ready,this.onRefresh()}else this.state=Pt.Disabled}onClick(t){var e,i;const n=this.instance,s=n.getSlide(),o=null==s?void 0:s.panzoom,a=t.target,r=a&&x(a)?a.dataset:null;if(!r)return;if(void 0!==r.fancyboxToggleThumbs)return t.preventDefault(),t.stopPropagation(),void(null===(e=n.plugins.Thumbs)||void 0===e||e.toggle());if(void 0!==r.fancyboxToggleFullscreen)return t.preventDefault(),t.stopPropagation(),void this.instance.toggleFullscreen();if(void 0!==r.fancyboxToggleSlideshow){t.preventDefault(),t.stopPropagation();const e=null===(i=n.carousel)||void 0===i?void 0:i.plugins.Autoplay;let s=e.isActive;return o&&\"mousemove\"===o.panMode&&!s&&o.reset(),void(s?e.stop():e.start())}const l=r.panzoomAction,c=r.panzoomChange;if((c||l)&&(t.preventDefault(),t.stopPropagation()),c){let t={};try{t=JSON.parse(c)}catch(t){}o&&o.applyChange(t)}else l&&o&&o[l]&&o[l]()}onChange(){this.onRefresh()}onRefresh(){if(this.instance.isClosing())return;const t=this.container;if(!t)return;const e=this.instance.getSlide();if(!e||e.state!==it.Ready)return;const i=e&&!e.error&&e.panzoom;for(const e of t.querySelectorAll(\"[data-panzoom-action]\"))i?(e.removeAttribute(\"disabled\"),e.removeAttribute(\"tabindex\")):(e.setAttribute(\"disabled\",\"\"),e.setAttribute(\"tabindex\",\"-1\"));let n=i&&i.canZoomIn(),s=i&&i.canZoomOut();for(const e of t.querySelectorAll('[data-panzoom-action=\"zoomIn\"]'))n?(e.removeAttribute(\"disabled\"),e.removeAttribute(\"tabindex\")):(e.setAttribute(\"disabled\",\"\"),e.setAttribute(\"tabindex\",\"-1\"));for(const e of t.querySelectorAll('[data-panzoom-action=\"zoomOut\"]'))s?(e.removeAttribute(\"disabled\"),e.removeAttribute(\"tabindex\")):(e.setAttribute(\"disabled\",\"\"),e.setAttribute(\"tabindex\",\"-1\"));for(const e of t.querySelectorAll('[data-panzoom-action=\"toggleZoom\"],[data-panzoom-action=\"iterateZoom\"]')){s||n?(e.removeAttribute(\"disabled\"),e.removeAttribute(\"tabindex\")):(e.setAttribute(\"disabled\",\"\"),e.setAttribute(\"tabindex\",\"-1\"));const t=e.querySelector(\"g\");t&&(t.style.display=n?\"\":\"none\")}}onDone(t,e){var i;null===(i=e.panzoom)||void 0===i||i.on(\"afterTransform\",(()=>{this.instance.isCurrentSlide(e)&&this.onRefresh()})),this.instance.isCurrentSlide(e)&&this.onRefresh()}createContainer(){const t=this.instance.container;if(!t)return null;const e=this.option(\"parentEl\")||t,i=document.createElement(\"div\");return S(i,\"fancybox__toolbar\"),e.prepend(i),i.addEventListener(\"click\",this.onClick,{passive:!1,capture:!0}),t&&S(t,\"has-toolbar\"),this.container=i,i}createEl(t){const e=this.instance,i=e.carousel;if(!i)return null;if(\"toggleFS\"===t)return null;if(\"fullscreen\"===t&&!e.fsAPI)return null;let s=null;const o=i.slides.length||0;let a=0,r=0;for(const t of i.slides)(t.panzoom||\"image\"===t.type)&&a++,(\"image\"===t.type||t.downloadSrc)&&r++;if(o<2&&[\"infobar\",\"prev\",\"next\"].includes(t))return s;if(void 0!==St[t]&&!a)return null;if(\"download\"===t&&!r)return null;if(\"thumbs\"===t){const t=e.plugins.Thumbs;if(!t||!t.isEnabled)return null}if(\"slideshow\"===t){if(!i.plugins.Autoplay||o<2)return null}if(void 0!==St[t]){const e=St[t];s=document.createElement(\"button\"),s.setAttribute(\"title\",this.instance.localize(`{{${t.toUpperCase()}}}`)),S(s,\"f-button\"),e.action&&(s.dataset.panzoomAction=e.action),e.change&&(s.dataset.panzoomChange=JSON.stringify(e.change)),s.appendChild(n(this.instance.localize(e.icon)))}else{const e=(this.option(\"items\")||[])[t];e&&(s=n(this.instance.localize(e.tpl)),\"function\"==typeof e.click&&s.addEventListener(\"click\",(t=>{t.preventDefault(),t.stopPropagation(),\"function\"==typeof e.click&&e.click.call(this,this,t)})))}const l=null==s?void 0:s.querySelector(\"svg\");if(l)for(const[t,e]of Object.entries(Mt))l.getAttribute(t)||l.setAttribute(t,String(e));return s}removeContainer(){const t=this.container;t&&t.remove(),this.container=null,this.state=Pt.Disabled;const e=this.instance.container;e&&E(e,\"has-toolbar\")}attach(){const t=this,e=t.instance;e.on(\"Carousel.initSlides\",t.onReady),e.on(\"done\",t.onDone),e.on(\"reveal\",t.onChange),e.on(\"Carousel.change\",t.onChange),t.onReady(t.instance)}detach(){const t=this,e=t.instance;e.off(\"Carousel.initSlides\",t.onReady),e.off(\"done\",t.onDone),e.off(\"reveal\",t.onChange),e.off(\"Carousel.change\",t.onChange),t.removeContainer()}}Object.defineProperty(Tt,\"defaults\",{enumerable:!0,configurable:!0,writable:!0,value:Ct});const Ot={Hash:st,Html:ht,Images:at,Slideshow:mt,Thumbs:Et,Toolbar:Tt},At=\"with-fancybox\",zt=\"hide-scrollbar\",Lt=\"--fancybox-scrollbar-compensate\",Rt=\"--fancybox-body-margin\",kt=\"is-animated\",It=\"is-compact\",Dt=\"is-loading\",Ft=function(){var t=window.getSelection();return t&&\"Range\"===t.type};let jt=null,Ht=null;const Bt=new Map;let Nt=0;class _t extends m{get isIdle(){return this.idle}get isCompact(){return this.option(\"compact\")}constructor(t=[],e={},i={}){super(e),Object.defineProperty(this,\"userSlides\",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,\"userPlugins\",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,\"idle\",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,\"idleTimer\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"clickTimer\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"pwt\",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,\"ignoreFocusChange\",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,\"state\",{enumerable:!0,configurable:!0,writable:!0,value:et.Init}),Object.defineProperty(this,\"id\",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,\"container\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"footer\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"caption\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"carousel\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"lastFocus\",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,\"prevMouseMoveEvent\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"fsAPI\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.fsAPI=(()=>{let t,e=\"\",i=\"\",n=\"\";return document.fullscreenEnabled?(e=\"requestFullscreen\",i=\"exitFullscreen\",n=\"fullscreenElement\"):document.webkitFullscreenEnabled&&(e=\"webkitRequestFullscreen\",i=\"webkitExitFullscreen\",n=\"webkitFullscreenElement\"),e&&(t={request:function(t){return\"webkitRequestFullscreen\"===e?t[e](Element.ALLOW_KEYBOARD_INPUT):t[e]()},exit:function(){return document[n]&&document[i]()},isFullscreen:function(){return document[n]}}),t})(),this.id=e.id||++Nt,Bt.set(this.id,this),this.userSlides=t,this.userPlugins=i,queueMicrotask((()=>{this.init()}))}init(){if(this.state===et.Destroy)return;this.state=et.Init,this.attachPlugins(Object.assign(Object.assign({},_t.Plugins),this.userPlugins)),this.emit(\"init\"),!0===this.option(\"hideScrollbar\")&&(()=>{if(!G)return;const t=document.body;if(t.classList.contains(zt))return;let e=window.innerWidth-document.documentElement.getBoundingClientRect().width;e<0&&(e=0);const i=t.currentStyle||window.getComputedStyle(t),n=parseFloat(i.marginRight);document.documentElement.style.setProperty(Lt,`${e}px`),n&&t.style.setProperty(Rt,`${n}px`),t.classList.add(zt)})(),this.initLayout(),this.scale();const t=()=>{this.initCarousel(this.userSlides),this.state=et.Ready,this.attachEvents(),this.emit(\"ready\"),setTimeout((()=>{this.container&&this.container.setAttribute(\"aria-hidden\",\"false\")}),16)},e=this.fsAPI;this.option(\"Fullscreen.autoStart\")&&e&&!e.isFullscreen()?e.request(this.container).then((()=>t())).catch((()=>t())):t()}initLayout(){var t,e;const i=this.option(\"parentEl\")||document.body,s=n(this.localize(this.option(\"tpl.main\")||\"\"));s&&(s.setAttribute(\"id\",`fancybox-${this.id}`),s.setAttribute(\"aria-label\",this.localize(\"{{MODAL}}\")),s.classList.toggle(It,this.isCompact),S(s,this.option(\"mainClass\")||\"\"),this.container=s,this.footer=s.querySelector(\".fancybox__footer\"),i.appendChild(s),S(document.documentElement,At),jt&&Ht||(jt=document.createElement(\"span\"),S(jt,\"fancybox-focus-guard\"),jt.setAttribute(\"tabindex\",\"0\"),jt.setAttribute(\"aria-hidden\",\"true\"),jt.setAttribute(\"aria-label\",\"Focus guard\"),Ht=jt.cloneNode(),null===(t=s.parentElement)||void 0===t||t.insertBefore(jt,s),null===(e=s.parentElement)||void 0===e||e.append(Ht)),this.option(\"animated\")&&(S(s,kt),setTimeout((()=>{this.isClosing()||E(s,kt)}),350)),this.emit(\"initLayout\"))}initCarousel(t){const i=this.container;if(!i)return;const n=i.querySelector(\".fancybox__carousel\");if(!n)return;const s=this.carousel=new Z(n,u({},{slides:t,transition:\"fade\",Panzoom:{lockAxis:this.option(\"dragToClose\")?\"xy\":\"x\",infinite:!!this.option(\"dragToClose\")&&\"y\"},Dots:!1,Navigation:{classes:{container:\"fancybox__nav\",button:\"f-button\",isNext:\"is-next\",isPrev:\"is-prev\"}},initialPage:this.option(\"startIndex\"),l10n:this.option(\"l10n\")},this.option(\"Carousel\")||{}));s.on(\"*\",((t,e,...i)=>{this.emit(`Carousel.${e}`,t,...i)})),s.on([\"ready\",\"change\"],(()=>{var t;const e=this.getSlide();e&&(null===(t=e.panzoom)||void 0===t||t.updateControls()),this.manageCaption(e)})),this.on(\"Carousel.removeSlide\",((t,e,i)=>{i.contentEl&&(i.contentEl.remove(),i.contentEl=void 0);const n=i.el;n&&(E(n,\"has-error\"),E(n,\"has-unknown\"),E(n,`has-${i.type||\"unknown\"}`)),i.closeBtnEl&&i.closeBtnEl.remove(),i.closeBtnEl=void 0,i.captionEl&&i.captionEl.remove(),i.captionEl=void 0,i.spinnerEl&&i.spinnerEl.remove(),i.spinnerEl=void 0,i.state=void 0})),s.on(\"Panzoom.touchStart\",(()=>{var t,e;this.isCompact||this.endIdle(),(null===(t=document.activeElement)||void 0===t?void 0:t.closest(\".f-thumbs\"))&&(null===(e=this.container)||void 0===e||e.focus())})),s.on(\"settle\",(()=>{this.idleTimer||this.isCompact||!this.option(\"idle\")||this.setIdle(),this.option(\"autoFocus\")&&!this.isClosing&&this.checkFocus()})),this.option(\"dragToClose\")&&(s.on(\"Panzoom.afterTransform\",((t,i)=>{const n=this.getSlide();if(n&&e(n.el))return;const s=this.container;if(s){const t=Math.abs(i.current.f),e=t<1?\"\":Math.max(.5,Math.min(1,1-t/i.contentRect.fitHeight*1.5));s.style.setProperty(\"--fancybox-ts\",e?\"0s\":\"\"),s.style.setProperty(\"--fancybox-opacity\",e+\"\")}})),s.on(\"Panzoom.touchEnd\",((t,i,n)=>{var s;const o=this.getSlide();if(o&&e(o.el))return;if(i.isMobile&&document.activeElement&&-1!==[\"TEXTAREA\",\"INPUT\"].indexOf(null===(s=document.activeElement)||void 0===s?void 0:s.nodeName))return;const a=Math.abs(i.dragOffset.y);\"y\"===i.lockedAxis&&(a>=200||a>=50&&i.dragOffset.time<300)&&(n&&n.cancelable&&n.preventDefault(),this.close(n,\"f-throwOut\"+(i.current.f<0?\"Up\":\"Down\")))}))),s.on(\"change\",(t=>{var e;let i=null===(e=this.getSlide())||void 0===e?void 0:e.triggerEl;if(i){const e=new CustomEvent(\"slideTo\",{bubbles:!0,cancelable:!0,detail:t.page});i.dispatchEvent(e)}})),s.on([\"refresh\",\"change\"],(t=>{const e=this.container;if(!e)return;for(const i of e.querySelectorAll(\"[data-fancybox-current-index]\"))i.innerHTML=t.page+1;for(const i of e.querySelectorAll(\"[data-fancybox-count]\"))i.innerHTML=t.pages.length;if(!t.isInfinite){for(const i of e.querySelectorAll(\"[data-fancybox-next]\"))t.page0?(i.removeAttribute(\"disabled\"),i.removeAttribute(\"tabindex\")):(i.setAttribute(\"disabled\",\"\"),i.setAttribute(\"tabindex\",\"-1\"))}const i=this.getSlide();if(!i)return;let n=i.downloadSrc||\"\";n||\"image\"!==i.type||i.error||\"string\"!=typeof i.src||(n=i.src);const s=\"disabled\",o=\"tabindex\",a=\"download\",r=\"href\";for(const t of e.querySelectorAll(\"[data-fancybox-download]\")){const e=i.downloadFilename;n?(t.removeAttribute(s),t.removeAttribute(o),t.setAttribute(r,n),t.setAttribute(a,e||n),t.setAttribute(\"target\",\"_blank\")):(t.setAttribute(s,\"\"),t.setAttribute(o,\"-1\"),t.removeAttribute(r),t.removeAttribute(a))}})),this.emit(\"initCarousel\")}attachEvents(){const t=this,e=t.container;if(!e)return;e.addEventListener(\"click\",t.onClick,{passive:!1,capture:!1}),e.addEventListener(\"wheel\",t.onWheel,{passive:!1,capture:!1}),document.addEventListener(\"keydown\",t.onKeydown,{passive:!1,capture:!0}),document.addEventListener(\"visibilitychange\",t.onVisibilityChange,!1),document.addEventListener(\"mousemove\",t.onMousemove),t.option(\"trapFocus\")&&document.addEventListener(\"focus\",t.onFocus,!0),window.addEventListener(\"resize\",t.onResize);const i=window.visualViewport;i&&(i.addEventListener(\"scroll\",t.onResize),i.addEventListener(\"resize\",t.onResize))}detachEvents(){const t=this,e=t.container;if(!e)return;document.removeEventListener(\"keydown\",t.onKeydown,{passive:!1,capture:!0}),e.removeEventListener(\"wheel\",t.onWheel,{passive:!1,capture:!1}),e.removeEventListener(\"click\",t.onClick,{passive:!1,capture:!1}),document.removeEventListener(\"mousemove\",t.onMousemove),window.removeEventListener(\"resize\",t.onResize);const i=window.visualViewport;i&&(i.removeEventListener(\"resize\",t.onResize),i.removeEventListener(\"scroll\",t.onResize)),document.removeEventListener(\"visibilitychange\",t.onVisibilityChange,!1),document.removeEventListener(\"focus\",t.onFocus,!0)}scale(){const t=this.container;if(!t)return;const e=window.visualViewport,i=Math.max(1,(null==e?void 0:e.scale)||1);let n=\"\",s=\"\",o=\"\";if(e&&i>1){let t=`${e.offsetLeft}px`,a=`${e.offsetTop}px`;n=e.width*i+\"px\",s=e.height*i+\"px\",o=`translate3d(${t}, ${a}, 0) scale(${1/i})`}t.style.transform=o,t.style.width=n,t.style.height=s}onClick(t){var e,i;const{container:n,isCompact:s}=this;if(!n||this.isClosing())return;!s&&this.option(\"idle\")&&this.resetIdle();const o=document.activeElement;if(Ft()&&o&&n.contains(o))return;const a=t.composedPath()[0];if(a===(null===(e=this.carousel)||void 0===e?void 0:e.container))return;if(a.closest(\".f-spinner\")||a.closest(\"[data-fancybox-close]\"))return t.preventDefault(),void this.close(t);if(a.closest(\"[data-fancybox-prev]\"))return t.preventDefault(),void this.prev();if(a.closest(\"[data-fancybox-next]\"))return t.preventDefault(),void this.next();if(s&&\"image\"===(null===(i=this.getSlide())||void 0===i?void 0:i.type))return void(this.clickTimer?(clearTimeout(this.clickTimer),this.clickTimer=null):this.clickTimer=setTimeout((()=>{this.toggleIdle(),this.clickTimer=null}),350));if(this.emit(\"click\",t),t.defaultPrevented)return;let r=!1;if(a.closest(\".fancybox__content\")){if(o){if(o.closest(\"[contenteditable]\"))return;a.matches(J)||o.blur()}if(Ft())return;r=this.option(\"contentClick\")}else a.closest(\".fancybox__carousel\")&&!a.matches(J)&&(r=this.option(\"backdropClick\"));\"close\"===r?(t.preventDefault(),this.close(t)):\"next\"===r?(t.preventDefault(),this.next()):\"prev\"===r&&(t.preventDefault(),this.prev())}onWheel(t){var e;let i=this.option(\"wheel\",t);(null===(e=t.target)||void 0===e?void 0:e.closest(\".fancybox__thumbs\"))&&(i=\"slide\");const n=\"slide\"===i,s=[-t.deltaX||0,-t.deltaY||0,-t.detail||0].reduce((function(t,e){return Math.abs(e)>Math.abs(t)?e:t})),o=Math.max(-1,Math.min(1,s)),a=Date.now();this.pwt&&a-this.pwt<300?n&&t.preventDefault():(this.pwt=a,this.emit(\"wheel\",t),t.defaultPrevented||(\"close\"===i?(t.preventDefault(),this.close(t)):\"slide\"===i&&(t.preventDefault(),this[o>0?\"prev\":\"next\"]())))}onKeydown(t){if(!this.isTopmost())return;this.isCompact||!this.option(\"idle\")||this.isClosing()||this.resetIdle();const e=t.key,i=this.option(\"keyboard\");if(!i||t.ctrlKey||t.altKey||t.shiftKey)return;const n=t.composedPath()[0],s=document.activeElement&&document.activeElement.classList,o=s&&s.contains(\"f-button\")||n.dataset.carouselPage||n.dataset.carouselIndex;if(\"Escape\"!==e&&!o&&x(n)){if(n.isContentEditable||-1!==[\"TEXTAREA\",\"OPTION\",\"INPUT\",\"SELECT\",\"VIDEO\"].indexOf(n.nodeName))return}this.emit(\"keydown\",e,t);const a=i[e];\"function\"==typeof this[a]&&(t.preventDefault(),this[a]())}onResize(){const t=It,e=this.container;if(!e)return;const i=this.isCompact;e.classList.toggle(t,i),this.manageCaption(this.getSlide()),this.isCompact?this.clearIdle():this.endIdle(),this.scale(),this.emit(\"resize\")}onFocus(t){this.isTopmost()&&this.checkFocus(t)}onMousemove(t){this.prevMouseMoveEvent=t,!this.isCompact&&this.option(\"idle\")&&this.resetIdle()}onVisibilityChange(){\"visible\"===document.visibilityState?this.checkFocus():this.endIdle()}manageCloseBtn(t){const e=this.optionFor(t,\"closeButton\")||!1;if(\"auto\"===e){const t=this.plugins.Toolbar;if(t&&t.state===Pt.Ready)return}if(!e)return;if(!t.contentEl||t.closeBtnEl)return;const i=this.option(\"tpl.closeButton\");if(i){const e=n(this.localize(i));t.closeBtnEl=t.contentEl.appendChild(e),t.el&&S(t.el,\"has-close-btn\")}}manageCaption(t=void 0){var e,i;const n=\"fancybox__caption\",s=\"has-caption\",o=this.container;if(!o)return;const a=this.isCompact||this.option(\"commonCaption\"),r=!a;if(this.caption&&this.stop(this.caption),r&&this.caption&&(this.caption.remove(),this.caption=null),a&&!this.caption)for(const t of(null===(e=this.carousel)||void 0===e?void 0:e.slides)||[])t.captionEl&&(t.captionEl.remove(),t.captionEl=void 0,E(t.el,s),null===(i=t.el)||void 0===i||i.removeAttribute(\"aria-labelledby\"));if(t||(t=this.getSlide()),!t||a&&!this.isCurrentSlide(t))return;const l=t.el;let c=this.optionFor(t,\"caption\",\"\");if(!c)return void(a&&this.caption&&this.animate(this.caption,\"f-fadeOut\",(()=>{this.caption&&(this.caption.innerHTML=\"\")})));let h=null;if(r){if(h=t.captionEl||null,l&&!h){const e=n+`_${this.id}_${t.index}`;h=document.createElement(\"div\"),S(h,n),h.setAttribute(\"id\",e),t.captionEl=l.appendChild(h),S(l,s),l.setAttribute(\"aria-labelledby\",e)}}else{if(h=this.caption,h||(h=o.querySelector(\".\"+n)),!h){h=document.createElement(\"div\"),h.dataset.fancyboxCaption=\"\",S(h,n);(this.footer||o).prepend(h)}S(o,s),this.caption=h}h&&(h.innerHTML=\"\",\"string\"==typeof c?h.innerHTML=c:c instanceof HTMLElement&&h.appendChild(c))}checkFocus(t){var e;const i=document.activeElement||null;i&&(null===(e=this.container)||void 0===e?void 0:e.contains(i))||this.focus(t)}focus(t){var e;if(this.ignoreFocusChange)return;const i=document.activeElement||null,n=(null==t?void 0:t.target)||null,s=this.container,o=this.getSlide();if(!s||!(null===(e=this.carousel)||void 0===e?void 0:e.viewport))return;if(!t&&i&&s.contains(i))return;const a=o&&o.state===it.Ready?o.el:null;if(!a||a.contains(i)||s===i)return;t&&t.cancelable&&t.preventDefault(),this.ignoreFocusChange=!0;const r=Array.from(s.querySelectorAll(J));let l=[],c=null;for(let t of r){const e=!t.offsetParent||t.closest('[aria-hidden=\"true\"]'),i=a&&a.contains(t),n=!this.carousel.viewport.contains(t);if(t===s||(i||n)&&!e){l.push(t);const e=t.dataset.origTabindex;void 0!==e&&e&&(t.tabIndex=parseFloat(e)),t.removeAttribute(\"data-orig-tabindex\"),!t.hasAttribute(\"autoFocus\")&&c||(c=t)}else{const e=void 0===t.dataset.origTabindex?t.getAttribute(\"tabindex\")||\"\":t.dataset.origTabindex;e&&(t.dataset.origTabindex=e),t.tabIndex=-1}}let h=null;t?(!n||l.indexOf(n)<0)&&(h=c||s,l.length&&(i===Ht?h=l[0]:this.lastFocus!==s&&i!==jt||(h=l[l.length-1]))):h=o&&\"image\"===o.type?s:c||s,h&&Q(h),this.lastFocus=document.activeElement,this.ignoreFocusChange=!1}next(){const t=this.carousel;t&&t.pages.length>1&&t.slideNext()}prev(){const t=this.carousel;t&&t.pages.length>1&&t.slidePrev()}jumpTo(...t){this.carousel&&this.carousel.slideTo(...t)}isTopmost(){var t;return(null===(t=_t.getInstance())||void 0===t?void 0:t.id)==this.id}animate(t=null,e=\"\",i){if(!t||!e)return void(i&&i());this.stop(t);const n=s=>{s.target===t&&t.dataset.animationName&&(t.removeEventListener(\"animationend\",n),delete t.dataset.animationName,i&&i(),E(t,e))};t.dataset.animationName=e,t.addEventListener(\"animationend\",n),S(t,e)}stop(t){t&&t.dispatchEvent(new CustomEvent(\"animationend\",{bubbles:!1,cancelable:!0,currentTarget:t}))}setContent(t,e=\"\",i=!0){if(this.isClosing())return;const s=t.el;if(!s)return;let o=null;if(x(e)?o=e:(o=n(e+\"\"),x(o)||(o=document.createElement(\"div\"),o.innerHTML=e+\"\")),[\"img\",\"picture\",\"iframe\",\"video\",\"audio\"].includes(o.nodeName.toLowerCase())){const t=document.createElement(\"div\");t.appendChild(o),o=t}x(o)&&t.filter&&!t.error&&(o=o.querySelector(t.filter)),o&&x(o)?(S(o,\"fancybox__content\"),t.id&&o.setAttribute(\"id\",t.id),\"none\"!==o.style.display&&\"none\"!==getComputedStyle(o).getPropertyValue(\"display\")||(o.style.display=t.display||this.option(\"defaultDisplay\")||\"flex\"),s.classList.add(`has-${t.error?\"error\":t.type||\"unknown\"}`),s.prepend(o),t.contentEl=o,i&&this.revealContent(t),this.manageCloseBtn(t),this.manageCaption(t)):this.setError(t,\"{{ELEMENT_NOT_FOUND}}\")}revealContent(t,e){const i=t.el,n=t.contentEl;i&&n&&(this.emit(\"reveal\",t),this.hideLoading(t),t.state=it.Opening,(e=this.isOpeningSlide(t)?void 0===e?this.optionFor(t,\"showClass\"):e:\"f-fadeIn\")?this.animate(n,e,(()=>{this.done(t)})):this.done(t))}done(t){this.isClosing()||(t.state=it.Ready,this.emit(\"done\",t),S(t.el,\"is-done\"),this.isCurrentSlide(t)&&this.option(\"autoFocus\")&&queueMicrotask((()=>{this.option(\"autoFocus\")&&(this.option(\"autoFocus\")?this.focus():this.checkFocus())})),this.isOpeningSlide(t)&&!this.isCompact&&this.option(\"idle\")&&this.setIdle())}isCurrentSlide(t){const e=this.getSlide();return!(!t||!e)&&e.index===t.index}isOpeningSlide(t){var e,i;return null===(null===(e=this.carousel)||void 0===e?void 0:e.prevPage)&&t.index===(null===(i=this.getSlide())||void 0===i?void 0:i.index)}showLoading(t){t.state=it.Loading;const e=t.el;if(!e)return;S(e,Dt),this.emit(\"loading\",t),t.spinnerEl||setTimeout((()=>{if(!this.isClosing()&&!t.spinnerEl&&t.state===it.Loading){let i=n(w);t.spinnerEl=i,e.prepend(i),this.animate(i,\"f-fadeIn\")}}),250)}hideLoading(t){const e=t.el;if(!e)return;const i=t.spinnerEl;this.isClosing()?null==i||i.remove():(E(e,Dt),i&&this.animate(i,\"f-fadeOut\",(()=>{i.remove()})),t.state===it.Loading&&(this.emit(\"loaded\",t),t.state=it.Ready))}setError(t,e){if(this.isClosing())return;const i=new Event(\"error\",{bubbles:!0,cancelable:!0});if(this.emit(\"error\",i,t),i.defaultPrevented)return;t.error=e,this.hideLoading(t),this.clearContent(t);const n=document.createElement(\"div\");n.classList.add(\"fancybox-error\"),n.innerHTML=this.localize(e||\"{{ERROR}}
\"),this.setContent(t,n)}clearContent(t){var e;null===(e=this.carousel)||void 0===e||e.emit(\"removeSlide\",t)}getSlide(){var t;const e=this.carousel;return(null===(t=null==e?void 0:e.pages[null==e?void 0:e.page])||void 0===t?void 0:t.slides[0])||void 0}close(t,e){if(this.isClosing())return;const i=new Event(\"shouldClose\",{bubbles:!0,cancelable:!0});if(this.emit(\"shouldClose\",i,t),i.defaultPrevented)return;t&&t.cancelable&&(t.preventDefault(),t.stopPropagation());const n=this.fsAPI,s=()=>{this.proceedClose(t,e)};n&&n.isFullscreen()?Promise.resolve(n.exit()).then((()=>s())):s()}clearIdle(){this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=null}setIdle(t=!1){const e=()=>{this.clearIdle(),this.idle=!0,S(this.container,\"is-idle\"),this.emit(\"setIdle\")};if(this.clearIdle(),!this.isClosing())if(t)e();else{const t=this.option(\"idle\");t&&(this.idleTimer=setTimeout(e,t))}}endIdle(){this.clearIdle(),this.idle&&!this.isClosing()&&(this.idle=!1,E(this.container,\"is-idle\"),this.emit(\"endIdle\"))}resetIdle(){this.endIdle(),this.setIdle()}toggleIdle(){this.idle?this.endIdle():this.setIdle(!0)}toggleFullscreen(){const t=this.fsAPI;t&&(t.isFullscreen()?t.exit():this.container&&t.request(this.container))}isClosing(){return[et.Closing,et.CustomClosing,et.Destroy].includes(this.state)}proceedClose(t,e){var i,n;this.state=et.Closing,this.clearIdle(),this.detachEvents();const s=this.container,o=this.carousel,a=this.getSlide(),r=a&&this.option(\"placeFocusBack\")?a.triggerEl||this.option(\"triggerEl\"):null;if(r&&(U(r)?Q(r):r.focus()),s&&(S(s,\"is-closing\"),s.setAttribute(\"aria-hidden\",\"true\"),this.option(\"animated\")&&S(s,kt),s.style.pointerEvents=\"none\"),o){o.clearTransitions(),null===(i=o.panzoom)||void 0===i||i.destroy(),null===(n=o.plugins.Navigation)||void 0===n||n.detach();for(const t of o.slides){t.state=it.Closing,this.hideLoading(t);const e=t.contentEl;e&&this.stop(e);const i=null==t?void 0:t.panzoom;i&&(i.stop(),i.detachEvents(),i.detachObserver()),this.isCurrentSlide(t)||o.emit(\"removeSlide\",t)}}this.emit(\"close\",t),this.state!==et.CustomClosing?(void 0===e&&a&&(e=this.optionFor(a,\"hideClass\")),e&&a?(this.animate(a.contentEl,e,(()=>{o&&o.emit(\"removeSlide\",a)})),setTimeout((()=>{this.destroy()}),500)):this.destroy()):setTimeout((()=>{this.destroy()}),500)}destroy(){var t;if(this.state===et.Destroy)return;this.state=et.Destroy,null===(t=this.carousel)||void 0===t||t.destroy();const e=this.container;e&&e.remove(),Bt.delete(this.id);const i=_t.getInstance();i?i.focus():(jt&&(jt.remove(),jt=null),Ht&&(Ht.remove(),Ht=null),E(document.documentElement,At),(()=>{if(!G)return;const t=document,e=t.body;e.classList.remove(zt),e.style.setProperty(Rt,\"\"),t.documentElement.style.setProperty(Lt,\"\")})(),this.emit(\"destroy\"))}static bind(t,e,i){if(!G)return;let n,s=\"\",o={};if(void 0===t?n=document.body:\"string\"==typeof t?(n=document.body,s=t,\"object\"==typeof e&&(o=e||{})):(n=t,\"string\"==typeof e&&(s=e),\"object\"==typeof i&&(o=i||{})),!n||!x(n))return;s=s||\"[data-fancybox]\";const a=_t.openers.get(n)||new Map;a.set(s,o),_t.openers.set(n,a),1===a.size&&n.addEventListener(\"click\",_t.fromEvent)}static unbind(t,e){let i,n=\"\";if(\"string\"==typeof t?(i=document.body,n=t):(i=t,\"string\"==typeof e&&(n=e)),!i)return;const s=_t.openers.get(i);s&&n&&s.delete(n),n&&s||(_t.openers.delete(i),i.removeEventListener(\"click\",_t.fromEvent))}static destroy(){let t;for(;t=_t.getInstance();)t.destroy();for(const t of _t.openers.keys())t.removeEventListener(\"click\",_t.fromEvent);_t.openers=new Map}static fromEvent(t){if(t.defaultPrevented)return;if(t.button&&0!==t.button)return;if(t.ctrlKey||t.metaKey||t.shiftKey)return;let e=t.composedPath()[0];const i=e.closest(\"[data-fancybox-trigger]\");if(i){const t=i.dataset.fancyboxTrigger||\"\",n=document.querySelectorAll(`[data-fancybox=\"${t}\"]`),s=parseInt(i.dataset.fancyboxIndex||\"\",10)||0;e=n[s]||e}if(!(e&&e instanceof Element))return;let n,s,o,a;if([..._t.openers].reverse().find((([t,i])=>!(!t.contains(e)||![...i].reverse().find((([i,r])=>{let l=e.closest(i);return!!l&&(n=t,s=i,o=l,a=r,!0)}))))),!n||!s||!o)return;a=a||{},t.preventDefault(),e=o;let r=[],l=u({},tt,a);l.event=t,l.triggerEl=e,l.delegate=i;const c=l.groupAll,h=l.groupAttr,d=h&&e?e.getAttribute(`${h}`):\"\";if((!e||d||c)&&(r=[].slice.call(n.querySelectorAll(s))),e&&!c&&(r=d?r.filter((t=>t.getAttribute(`${h}`)===d)):[e]),!r.length)return;const p=_t.getInstance();return p&&p.options.triggerEl&&r.indexOf(p.options.triggerEl)>-1?void 0:(e&&(l.startIndex=r.indexOf(e)),_t.fromNodes(r,l))}static fromSelector(t,e){let i=null,n=\"\";if(\"string\"==typeof t?(i=document.body,n=t):t instanceof HTMLElement&&\"string\"==typeof e&&(i=t,n=e),!i||!n)return!1;const s=_t.openers.get(i);if(!s)return!1;const o=s.get(n);return!!o&&_t.fromNodes(Array.from(i.querySelectorAll(n)),o)}static fromNodes(t,e){e=u({},tt,e||{});const i=[];for(const n of t){const t=n.dataset||{},s=t.src||n.getAttribute(\"href\")||n.getAttribute(\"currentSrc\")||n.getAttribute(\"src\")||void 0;let o;const a=e.delegate;let r;a&&i.length===e.startIndex&&(o=a instanceof HTMLImageElement?a:a.querySelector(\"img:not([aria-hidden])\")),o||(o=n instanceof HTMLImageElement?n:n.querySelector(\"img:not([aria-hidden])\")),o&&(r=o.currentSrc||o.src||void 0,!r&&o.dataset&&(r=o.dataset.lazySrc||o.dataset.src||void 0));const l={src:s,triggerEl:n,thumbEl:o,thumbElSrc:r,thumbSrc:r};for(const e in t)l[e]=t[e]+\"\";i.push(l)}return new _t(i,e)}static getInstance(t){if(t)return Bt.get(t);return Array.from(Bt.values()).reverse().find((t=>!t.isClosing()&&t))||null}static getSlide(){var t;return(null===(t=_t.getInstance())||void 0===t?void 0:t.getSlide())||null}static show(t=[],e={}){return new _t(t,e)}static next(){const t=_t.getInstance();t&&t.next()}static prev(){const t=_t.getInstance();t&&t.prev()}static close(t=!0,...e){if(t)for(const t of Bt.values())t.close(...e);else{const t=_t.getInstance();t&&t.close(...e)}}}Object.defineProperty(_t,\"version\",{enumerable:!0,configurable:!0,writable:!0,value:\"5.0.22\"}),Object.defineProperty(_t,\"defaults\",{enumerable:!0,configurable:!0,writable:!0,value:tt}),Object.defineProperty(_t,\"Plugins\",{enumerable:!0,configurable:!0,writable:!0,value:Ot}),Object.defineProperty(_t,\"openers\",{enumerable:!0,configurable:!0,writable:!0,value:new Map});export{Z as Carousel,_t as Fancybox,R as Panzoom};\n","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nimport { getDocument } from 'ssr-window';\nimport $ from '../../utils/dom';\nimport { extend, nextTick, bindModuleMethods, createElementIfNotDefined } from '../../utils/utils';\nvar Scrollbar = {\n setTranslate: function setTranslate() {\n var swiper = this;\n if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;\n var scrollbar = swiper.scrollbar,\n rtl = swiper.rtlTranslate,\n progress = swiper.progress;\n var dragSize = scrollbar.dragSize,\n trackSize = scrollbar.trackSize,\n $dragEl = scrollbar.$dragEl,\n $el = scrollbar.$el;\n var params = swiper.params.scrollbar;\n var newSize = dragSize;\n var newPos = (trackSize - dragSize) * progress;\n\n if (rtl) {\n newPos = -newPos;\n\n if (newPos > 0) {\n newSize = dragSize - newPos;\n newPos = 0;\n } else if (-newPos + dragSize > trackSize) {\n newSize = trackSize + newPos;\n }\n } else if (newPos < 0) {\n newSize = dragSize + newPos;\n newPos = 0;\n } else if (newPos + dragSize > trackSize) {\n newSize = trackSize - newPos;\n }\n\n if (swiper.isHorizontal()) {\n $dragEl.transform(\"translate3d(\" + newPos + \"px, 0, 0)\");\n $dragEl[0].style.width = newSize + \"px\";\n } else {\n $dragEl.transform(\"translate3d(0px, \" + newPos + \"px, 0)\");\n $dragEl[0].style.height = newSize + \"px\";\n }\n\n if (params.hide) {\n clearTimeout(swiper.scrollbar.timeout);\n $el[0].style.opacity = 1;\n swiper.scrollbar.timeout = setTimeout(function () {\n $el[0].style.opacity = 0;\n $el.transition(400);\n }, 1000);\n }\n },\n setTransition: function setTransition(duration) {\n var swiper = this;\n if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;\n swiper.scrollbar.$dragEl.transition(duration);\n },\n updateSize: function updateSize() {\n var swiper = this;\n if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;\n var scrollbar = swiper.scrollbar;\n var $dragEl = scrollbar.$dragEl,\n $el = scrollbar.$el;\n $dragEl[0].style.width = '';\n $dragEl[0].style.height = '';\n var trackSize = swiper.isHorizontal() ? $el[0].offsetWidth : $el[0].offsetHeight;\n var divider = swiper.size / swiper.virtualSize;\n var moveDivider = divider * (trackSize / swiper.size);\n var dragSize;\n\n if (swiper.params.scrollbar.dragSize === 'auto') {\n dragSize = trackSize * divider;\n } else {\n dragSize = parseInt(swiper.params.scrollbar.dragSize, 10);\n }\n\n if (swiper.isHorizontal()) {\n $dragEl[0].style.width = dragSize + \"px\";\n } else {\n $dragEl[0].style.height = dragSize + \"px\";\n }\n\n if (divider >= 1) {\n $el[0].style.display = 'none';\n } else {\n $el[0].style.display = '';\n }\n\n if (swiper.params.scrollbar.hide) {\n $el[0].style.opacity = 0;\n }\n\n extend(scrollbar, {\n trackSize: trackSize,\n divider: divider,\n moveDivider: moveDivider,\n dragSize: dragSize\n });\n\n if (swiper.params.watchOverflow && swiper.enabled) {\n scrollbar.$el[swiper.isLocked ? 'addClass' : 'removeClass'](swiper.params.scrollbar.lockClass);\n }\n },\n getPointerPosition: function getPointerPosition(e) {\n var swiper = this;\n\n if (swiper.isHorizontal()) {\n return e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].clientX : e.clientX;\n }\n\n return e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].clientY : e.clientY;\n },\n setDragPosition: function setDragPosition(e) {\n var swiper = this;\n var scrollbar = swiper.scrollbar,\n rtl = swiper.rtlTranslate;\n var $el = scrollbar.$el,\n dragSize = scrollbar.dragSize,\n trackSize = scrollbar.trackSize,\n dragStartPos = scrollbar.dragStartPos;\n var positionRatio;\n positionRatio = (scrollbar.getPointerPosition(e) - $el.offset()[swiper.isHorizontal() ? 'left' : 'top'] - (dragStartPos !== null ? dragStartPos : dragSize / 2)) / (trackSize - dragSize);\n positionRatio = Math.max(Math.min(positionRatio, 1), 0);\n\n if (rtl) {\n positionRatio = 1 - positionRatio;\n }\n\n var position = swiper.minTranslate() + (swiper.maxTranslate() - swiper.minTranslate()) * positionRatio;\n swiper.updateProgress(position);\n swiper.setTranslate(position);\n swiper.updateActiveIndex();\n swiper.updateSlidesClasses();\n },\n onDragStart: function onDragStart(e) {\n var swiper = this;\n var params = swiper.params.scrollbar;\n var scrollbar = swiper.scrollbar,\n $wrapperEl = swiper.$wrapperEl;\n var $el = scrollbar.$el,\n $dragEl = scrollbar.$dragEl;\n swiper.scrollbar.isTouched = true;\n swiper.scrollbar.dragStartPos = e.target === $dragEl[0] || e.target === $dragEl ? scrollbar.getPointerPosition(e) - e.target.getBoundingClientRect()[swiper.isHorizontal() ? 'left' : 'top'] : null;\n e.preventDefault();\n e.stopPropagation();\n $wrapperEl.transition(100);\n $dragEl.transition(100);\n scrollbar.setDragPosition(e);\n clearTimeout(swiper.scrollbar.dragTimeout);\n $el.transition(0);\n\n if (params.hide) {\n $el.css('opacity', 1);\n }\n\n if (swiper.params.cssMode) {\n swiper.$wrapperEl.css('scroll-snap-type', 'none');\n }\n\n swiper.emit('scrollbarDragStart', e);\n },\n onDragMove: function onDragMove(e) {\n var swiper = this;\n var scrollbar = swiper.scrollbar,\n $wrapperEl = swiper.$wrapperEl;\n var $el = scrollbar.$el,\n $dragEl = scrollbar.$dragEl;\n if (!swiper.scrollbar.isTouched) return;\n if (e.preventDefault) e.preventDefault();else e.returnValue = false;\n scrollbar.setDragPosition(e);\n $wrapperEl.transition(0);\n $el.transition(0);\n $dragEl.transition(0);\n swiper.emit('scrollbarDragMove', e);\n },\n onDragEnd: function onDragEnd(e) {\n var swiper = this;\n var params = swiper.params.scrollbar;\n var scrollbar = swiper.scrollbar,\n $wrapperEl = swiper.$wrapperEl;\n var $el = scrollbar.$el;\n if (!swiper.scrollbar.isTouched) return;\n swiper.scrollbar.isTouched = false;\n\n if (swiper.params.cssMode) {\n swiper.$wrapperEl.css('scroll-snap-type', '');\n $wrapperEl.transition('');\n }\n\n if (params.hide) {\n clearTimeout(swiper.scrollbar.dragTimeout);\n swiper.scrollbar.dragTimeout = nextTick(function () {\n $el.css('opacity', 0);\n $el.transition(400);\n }, 1000);\n }\n\n swiper.emit('scrollbarDragEnd', e);\n\n if (params.snapOnRelease) {\n swiper.slideToClosest();\n }\n },\n enableDraggable: function enableDraggable() {\n var swiper = this;\n if (!swiper.params.scrollbar.el) return;\n var document = getDocument();\n var scrollbar = swiper.scrollbar,\n touchEventsTouch = swiper.touchEventsTouch,\n touchEventsDesktop = swiper.touchEventsDesktop,\n params = swiper.params,\n support = swiper.support;\n var $el = scrollbar.$el;\n var target = $el[0];\n var activeListener = support.passiveListener && params.passiveListeners ? {\n passive: false,\n capture: false\n } : false;\n var passiveListener = support.passiveListener && params.passiveListeners ? {\n passive: true,\n capture: false\n } : false;\n if (!target) return;\n\n if (!support.touch) {\n target.addEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener);\n document.addEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener);\n document.addEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener);\n } else {\n target.addEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener);\n target.addEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener);\n target.addEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener);\n }\n },\n disableDraggable: function disableDraggable() {\n var swiper = this;\n if (!swiper.params.scrollbar.el) return;\n var document = getDocument();\n var scrollbar = swiper.scrollbar,\n touchEventsTouch = swiper.touchEventsTouch,\n touchEventsDesktop = swiper.touchEventsDesktop,\n params = swiper.params,\n support = swiper.support;\n var $el = scrollbar.$el;\n var target = $el[0];\n var activeListener = support.passiveListener && params.passiveListeners ? {\n passive: false,\n capture: false\n } : false;\n var passiveListener = support.passiveListener && params.passiveListeners ? {\n passive: true,\n capture: false\n } : false;\n if (!target) return;\n\n if (!support.touch) {\n target.removeEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener);\n document.removeEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener);\n document.removeEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener);\n } else {\n target.removeEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener);\n target.removeEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener);\n target.removeEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener);\n }\n },\n init: function init() {\n var swiper = this;\n var scrollbar = swiper.scrollbar,\n $swiperEl = swiper.$el;\n swiper.params.scrollbar = createElementIfNotDefined($swiperEl, swiper.params.scrollbar, swiper.params.createElements, {\n el: 'swiper-scrollbar'\n });\n var params = swiper.params.scrollbar;\n if (!params.el) return;\n var $el = $(params.el);\n\n if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1 && $swiperEl.find(params.el).length === 1) {\n $el = $swiperEl.find(params.el);\n }\n\n var $dragEl = $el.find(\".\" + swiper.params.scrollbar.dragClass);\n\n if ($dragEl.length === 0) {\n $dragEl = $(\"\");\n $el.append($dragEl);\n }\n\n extend(scrollbar, {\n $el: $el,\n el: $el[0],\n $dragEl: $dragEl,\n dragEl: $dragEl[0]\n });\n\n if (params.draggable) {\n scrollbar.enableDraggable();\n }\n\n if ($el) {\n $el[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.scrollbar.lockClass);\n }\n },\n destroy: function destroy() {\n var swiper = this;\n swiper.scrollbar.disableDraggable();\n }\n};\nexport default {\n name: 'scrollbar',\n params: {\n scrollbar: {\n el: null,\n dragSize: 'auto',\n hide: false,\n draggable: false,\n snapOnRelease: true,\n lockClass: 'swiper-scrollbar-lock',\n dragClass: 'swiper-scrollbar-drag'\n }\n },\n create: function create() {\n var swiper = this;\n bindModuleMethods(swiper, {\n scrollbar: _extends({\n isTouched: false,\n timeout: null,\n dragTimeout: null\n }, Scrollbar)\n });\n },\n on: {\n init: function init(swiper) {\n swiper.scrollbar.init();\n swiper.scrollbar.updateSize();\n swiper.scrollbar.setTranslate();\n },\n update: function update(swiper) {\n swiper.scrollbar.updateSize();\n },\n resize: function resize(swiper) {\n swiper.scrollbar.updateSize();\n },\n observerUpdate: function observerUpdate(swiper) {\n swiper.scrollbar.updateSize();\n },\n setTranslate: function setTranslate(swiper) {\n swiper.scrollbar.setTranslate();\n },\n setTransition: function setTransition(swiper, duration) {\n swiper.scrollbar.setTransition(duration);\n },\n 'enable disable': function enableDisable(swiper) {\n var $el = swiper.scrollbar.$el;\n\n if ($el) {\n $el[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.scrollbar.lockClass);\n }\n },\n destroy: function destroy(swiper) {\n swiper.scrollbar.destroy();\n }\n }\n};","/**\r\n * fancyboxGallery Component\r\n *\r\n * @file slider.js\r\n */\r\n\r\nimport $ from \"jquery\";\r\nimport { Fancybox } from \"@fancyapps/ui\";\r\nimport \"@fancyapps/ui/dist/fancybox/fancybox.css\";\r\nimport Swiper from 'swiper';\r\nimport SwiperCore, { Navigation, Pagination, Autoplay, EffectFade, Controller, Thumbs, Keyboard, Mousewheel, Scrollbar } from 'swiper/core';\r\nSwiperCore.use([Navigation, Pagination, Autoplay, EffectFade, Controller, Thumbs, Keyboard, Mousewheel, Scrollbar]);\r\n\r\nimport 'swiper/swiper-bundle.css';\r\n\r\n\r\nconst fancyboxGallery = (() => {\r\n /**\r\n * fullSlider\r\n * Full width slider settings\r\n */\r\n const defaultFancybox = () => {\r\n Fancybox.bind('[data-fancybox]', {\r\n // Custom options for all galleries\r\n }); \r\n Fancybox.bind('[data-fancybox=\"home-video-gallery\"]', {\r\n // Custom options for all galleries\r\n Thumbs:false\r\n }); \r\n $('.cookie-accept').on('click', function(){\r\n Fancybox.close();\r\n }); \r\n };\r\n\r\n const balloonModal = () => {\r\n var e = document.getElementsByClassName(\"svg-map-hr\")\r\n , t = document.querySelector(\".map-balloon\");\r\n for (let i = 0; i < e.length; i += 1) {\r\n e[i].addEventListener(\"mouseover\", function(e) {\r\n if (e.target.getAttribute(\"data-value\") === \"1\"){\r\n $(\".svg-map-hr\").addClass(\"hover\");\r\n if (e.target.getAttribute(\"data-box2\") !== null){\r\n t.innerHTML = ['', e.target.getAttribute(\"data-box\") + e.target.getAttribute(\"data-box2\"), \"
\"].join(\"\");\r\n } else{\r\n t.innerHTML = ['', e.target.getAttribute(\"data-box\"), \"
\"].join(\"\");\r\n }\r\n } else{\r\n t.innerHTML = \"\"\r\n $(\".svg-map-hr\").removeClass(\"hover\");\r\n }\r\n });\r\n e[i].addEventListener(\"mousemove\", function(e) {\r\n var t = $(this).parent().offset(),\r\n mouse_x = e.pageX - t.left + -170 + \"px\",\r\n mouse_y = e.pageY - t.top + -150 + \"px\",\r\n mouse_x = mouse_x,\r\n mouse_y = mouse_y;\r\n $(\".map-balloon\").css({\r\n left: mouse_x,\r\n top: mouse_y\r\n });\r\n }),\r\n e[i].addEventListener(\"mouseout\", function(e) {\r\n t.innerHTML = \"\";\r\n $(\".svg-map-hr\").removeClass(\"hover\");\r\n });\r\n }\r\n };\r\n\r\n const popupImgCarousel = () => {\r\n Fancybox.bind('[data-fancybox=\"popupGallery\"]', {\r\n groupAttr: false,\r\n dragToClose:false,\r\n hash : false,\r\n on: {\r\n done: (fancybox, eventName) => {\r\n var popupTextCarousel = new Swiper('.text-'+eventName.contentEl.id+\"-carousel\", {\r\n slidesPerView: 1.5,\r\n spaceBetween: 30,\r\n watchSlidesProgress: true,\r\n direction:\"vertical\",\r\n observer:true,\r\n observeParents:true,\r\n mousewheel: {\r\n \treleaseOnEdges: true,\r\n },\r\n touchReleaseOnEdges: true,\r\n scrollbar: {\r\n el: '.swiper-scrollbar',\r\n draggable: true,\r\n },\r\n breakpoints: {\r\n 0: {\r\n direction:\"horizontal\",\r\n slidesPerView: 1.2,\r\n spaceBetween: 15,\r\n // centeredSlides: false,\r\n },\r\n 768: {\r\n slidesPerView: 1.5,\r\n spaceBetween: 15,\r\n direction:\"vertical\",\r\n // centeredSlides: true,\r\n },\r\n 992: {\r\n slidesPerView: 1.5,\r\n spaceBetween: 30,\r\n },\r\n }\r\n });\r\n var popupImgCarousel = new Swiper('.img-'+eventName.contentEl.id+\"-carousel\", {\r\n slidesPerView: 1,\r\n spaceBetween: 0,\r\n allowTouchMove: false,\r\n });\r\n popupTextCarousel.on('slideChange', function () {\r\n popupImgCarousel.slideTo(this.realIndex);\t\r\n });\r\n popupTextCarousel.on('reachEnd', function () {\r\n $(\".dty-popup-carousel-text .swiper-slide\").addClass(\"last-ph\");\r\n });\r\n popupTextCarousel.on('fromEdge', function(){\r\n $(\".dty-popup-carousel-text .swiper-slide\").removeClass(\"last-ph\");\r\n });\r\n },\r\n close: (fancybox, eventName) => {\r\n var popupTextCarousel = new Swiper('.text-'+fancybox.userSlides[0].src.replace(\"#\", \"\")+\"-carousel\", {\r\n slidesPerView: 1.5,\r\n spaceBetween: 30,\r\n watchSlidesProgress: true,\r\n direction:\"vertical\",\r\n observer:true,\r\n observeParents:true,\r\n mousewheel: {\r\n \treleaseOnEdges: true,\r\n },\r\n touchReleaseOnEdges: true,\r\n scrollbar: {\r\n el: '.swiper-scrollbar',\r\n draggable: true,\r\n },\r\n breakpoints: {\r\n 0: {\r\n direction:\"horizontal\",\r\n slidesPerView: 1.2,\r\n spaceBetween: 15,\r\n // centeredSlides: false,\r\n },\r\n 768: {\r\n slidesPerView: 1.5,\r\n spaceBetween: 15,\r\n direction:\"vertical\",\r\n // centeredSlides: true,\r\n },\r\n 992: {\r\n slidesPerView: 1.5,\r\n spaceBetween: 30,\r\n },\r\n }\r\n });\r\n var popupImgCarousel = new Swiper('.img-'+fancybox.userSlides[0].src.replace(\"#\", \"\")+\"-carousel\", {\r\n slidesPerView: 1,\r\n spaceBetween: 0,\r\n allowTouchMove: false,\r\n });\r\n popupTextCarousel.update();\r\n popupImgCarousel.update();\r\n },\r\n },\r\n });\r\n };\r\n\r\n const customSelect = () => {\r\n var x, i, j, l, ll, selElmnt, a, b, c;\r\n /*look for any elements with the class \"custom-select\":*/\r\n x = document.getElementsByClassName(\"custom-select\");\r\n l = x.length;\r\n for (i = 0; i < l; i++) {\r\n selElmnt = x[i].getElementsByTagName(\"select\")[0];\r\n ll = selElmnt.length;\r\n /*for each element, create a new DIV that will act as the selected item:*/\r\n a = document.createElement(\"DIV\");\r\n a.setAttribute(\"class\", \"select-selected\");\r\n a.innerHTML = selElmnt.options[selElmnt.selectedIndex].innerHTML;\r\n x[i].appendChild(a);\r\n /*for each element, create a new DIV that will contain the option list:*/\r\n b = document.createElement(\"DIV\");\r\n b.setAttribute(\"class\", \"select-items select-hide\");\r\n for (j = 1; j < ll; j++) {\r\n /*for each option in the original select element,\r\n create a new DIV that will act as an option item:*/\r\n c = document.createElement(\"DIV\");\r\n c.innerHTML = selElmnt.options[j].innerHTML;\r\n c.addEventListener(\"click\", function(e) {\r\n /*when an item is clicked, update the original select box,\r\n and the selected item:*/\r\n var y, i, k, s, h, sl, yl;\r\n s = this.parentNode.parentNode.getElementsByTagName(\"select\")[0];\r\n sl = s.length;\r\n h = this.parentNode.previousSibling;\r\n for (i = 0; i < sl; i++) {\r\n if (s.options[i].innerHTML == this.innerHTML) {\r\n s.selectedIndex = i;\r\n h.innerHTML = this.innerHTML;\r\n y = this.parentNode.getElementsByClassName(\"same-as-selected\");\r\n yl = y.length;\r\n for (k = 0; k < yl; k++) {\r\n y[k].removeAttribute(\"class\");\r\n }\r\n this.setAttribute(\"class\", \"same-as-selected\");\r\n break;\r\n }\r\n }\r\n h.click();\r\n });\r\n b.appendChild(c);\r\n }\r\n x[i].appendChild(b);\r\n a.addEventListener(\"click\", function(e) {\r\n /*when the select box is clicked, close any other select boxes,\r\n and open/close the current select box:*/\r\n e.stopPropagation();\r\n closeAllSelect(this);\r\n this.nextSibling.classList.toggle(\"select-hide\");\r\n this.classList.toggle(\"select-arrow-active\");\r\n });\r\n }\r\n function closeAllSelect(elmnt) {\r\n /*a function that will close all select boxes in the document,\r\n except the current select box:*/\r\n var x, y, i, xl, yl, arrNo = [];\r\n x = document.getElementsByClassName(\"select-items\");\r\n y = document.getElementsByClassName(\"select-selected\");\r\n xl = x.length;\r\n yl = y.length;\r\n for (i = 0; i < yl; i++) {\r\n if (elmnt == y[i]) {\r\n arrNo.push(i)\r\n } else {\r\n y[i].classList.remove(\"select-arrow-active\");\r\n }\r\n }\r\n for (i = 0; i < xl; i++) {\r\n if (arrNo.indexOf(i)) {\r\n x[i].classList.add(\"select-hide\");\r\n }\r\n }\r\n }\r\n /*if the user clicks anywhere outside the select box,\r\n then close all select boxes:*/\r\n document.addEventListener(\"click\", closeAllSelect);\r\n };\r\n\r\n const init = () => {\r\n defaultFancybox();\r\n balloonModal();\r\n customSelect();\r\n popupImgCarousel();\r\n };\r\n\r\n return {\r\n init,\r\n };\r\n})();\r\n\r\nexport default fancyboxGallery;","import URLToolkit from 'url-toolkit';\nimport window from 'global/window';\nvar DEFAULT_LOCATION = 'http://example.com';\n\nvar resolveUrl = function resolveUrl(baseUrl, relativeUrl) {\n // return early if we don't need to resolve\n if (/^[a-z]+:/i.test(relativeUrl)) {\n return relativeUrl;\n } // if baseUrl is a data URI, ignore it and resolve everything relative to window.location\n\n\n if (/^data:/.test(baseUrl)) {\n baseUrl = window.location && window.location.href || '';\n } // IE11 supports URL but not the URL constructor\n // feature detect the behavior we want\n\n\n var nativeURL = typeof window.URL === 'function';\n var protocolLess = /^\\/\\//.test(baseUrl); // remove location if window.location isn't available (i.e. we're in node)\n // and if baseUrl isn't an absolute url\n\n var removeLocation = !window.location && !/\\/\\//i.test(baseUrl); // if the base URL is relative then combine with the current location\n\n if (nativeURL) {\n baseUrl = new window.URL(baseUrl, window.location || DEFAULT_LOCATION);\n } else if (!/\\/\\//i.test(baseUrl)) {\n baseUrl = URLToolkit.buildAbsoluteURL(window.location && window.location.href || '', baseUrl);\n }\n\n if (nativeURL) {\n var newUrl = new URL(relativeUrl, baseUrl); // if we're a protocol-less url, remove the protocol\n // and if we're location-less, remove the location\n // otherwise, return the url unmodified\n\n if (removeLocation) {\n return newUrl.href.slice(DEFAULT_LOCATION.length);\n } else if (protocolLess) {\n return newUrl.href.slice(newUrl.protocol.length);\n }\n\n return newUrl.href;\n }\n\n return URLToolkit.buildAbsoluteURL(baseUrl, relativeUrl);\n};\n\nexport default resolveUrl;","export default function _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}","/**\n * @file stream.js\n */\n\n/**\n * A lightweight readable stream implemention that handles event dispatching.\n *\n * @class Stream\n */\nvar Stream = /*#__PURE__*/function () {\n function Stream() {\n this.listeners = {};\n }\n /**\n * Add a listener for a specified event type.\n *\n * @param {string} type the event name\n * @param {Function} listener the callback to be invoked when an event of\n * the specified type occurs\n */\n\n\n var _proto = Stream.prototype;\n\n _proto.on = function on(type, listener) {\n if (!this.listeners[type]) {\n this.listeners[type] = [];\n }\n\n this.listeners[type].push(listener);\n }\n /**\n * Remove a listener for a specified event type.\n *\n * @param {string} type the event name\n * @param {Function} listener a function previously registered for this\n * type of event through `on`\n * @return {boolean} if we could turn it off or not\n */\n ;\n\n _proto.off = function off(type, listener) {\n if (!this.listeners[type]) {\n return false;\n }\n\n var index = this.listeners[type].indexOf(listener); // TODO: which is better?\n // In Video.js we slice listener functions\n // on trigger so that it does not mess up the order\n // while we loop through.\n //\n // Here we slice on off so that the loop in trigger\n // can continue using it's old reference to loop without\n // messing up the order.\n\n this.listeners[type] = this.listeners[type].slice(0);\n this.listeners[type].splice(index, 1);\n return index > -1;\n }\n /**\n * Trigger an event of the specified type on this stream. Any additional\n * arguments to this function are passed as parameters to event listeners.\n *\n * @param {string} type the event name\n */\n ;\n\n _proto.trigger = function trigger(type) {\n var callbacks = this.listeners[type];\n\n if (!callbacks) {\n return;\n } // Slicing the arguments on every invocation of this method\n // can add a significant amount of overhead. Avoid the\n // intermediate object creation for the common case of a\n // single callback argument\n\n\n if (arguments.length === 2) {\n var length = callbacks.length;\n\n for (var i = 0; i < length; ++i) {\n callbacks[i].call(this, arguments[1]);\n }\n } else {\n var args = Array.prototype.slice.call(arguments, 1);\n var _length = callbacks.length;\n\n for (var _i = 0; _i < _length; ++_i) {\n callbacks[_i].apply(this, args);\n }\n }\n }\n /**\n * Destroys the stream and cleans up.\n */\n ;\n\n _proto.dispose = function dispose() {\n this.listeners = {};\n }\n /**\n * Forwards all `data` events on this stream to the destination stream. The\n * destination stream should provide a method `push` to receive the data\n * events as they arrive.\n *\n * @param {Stream} destination the stream that will receive all `data` events\n * @see http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options\n */\n ;\n\n _proto.pipe = function pipe(destination) {\n this.on('data', function (data) {\n destination.push(data);\n });\n };\n\n return Stream;\n}();\n\nexport { Stream as default };","import window from 'global/window';\n\nvar atob = function atob(s) {\n return window.atob ? window.atob(s) : Buffer.from(s, 'base64').toString('binary');\n};\n\nexport default function decodeB64ToUint8Array(b64Text) {\n var decodedString = atob(b64Text);\n var array = new Uint8Array(decodedString.length);\n\n for (var i = 0; i < decodedString.length; i++) {\n array[i] = decodedString.charCodeAt(i);\n }\n\n return array;\n}","/*! @name m3u8-parser @version 6.2.0 @license Apache-2.0 */\nimport Stream from '@videojs/vhs-utils/es/stream.js';\nimport _extends from '@babel/runtime/helpers/extends';\nimport decodeB64ToUint8Array from '@videojs/vhs-utils/es/decode-b64-to-uint8-array.js';\n\n/**\n * @file m3u8/line-stream.js\n */\n/**\n * A stream that buffers string input and generates a `data` event for each\n * line.\n *\n * @class LineStream\n * @extends Stream\n */\n\nclass LineStream extends Stream {\n constructor() {\n super();\n this.buffer = '';\n }\n /**\n * Add new data to be parsed.\n *\n * @param {string} data the text to process\n */\n\n\n push(data) {\n let nextNewline;\n this.buffer += data;\n nextNewline = this.buffer.indexOf('\\n');\n\n for (; nextNewline > -1; nextNewline = this.buffer.indexOf('\\n')) {\n this.trigger('data', this.buffer.substring(0, nextNewline));\n this.buffer = this.buffer.substring(nextNewline + 1);\n }\n }\n\n}\n\nconst TAB = String.fromCharCode(0x09);\n\nconst parseByterange = function (byterangeString) {\n // optionally match and capture 0+ digits before `@`\n // optionally match and capture 0+ digits after `@`\n const match = /([0-9.]*)?@?([0-9.]*)?/.exec(byterangeString || '');\n const result = {};\n\n if (match[1]) {\n result.length = parseInt(match[1], 10);\n }\n\n if (match[2]) {\n result.offset = parseInt(match[2], 10);\n }\n\n return result;\n};\n/**\n * \"forgiving\" attribute list psuedo-grammar:\n * attributes -> keyvalue (',' keyvalue)*\n * keyvalue -> key '=' value\n * key -> [^=]*\n * value -> '\"' [^\"]* '\"' | [^,]*\n */\n\n\nconst attributeSeparator = function () {\n const key = '[^=]*';\n const value = '\"[^\"]*\"|[^,]*';\n const keyvalue = '(?:' + key + ')=(?:' + value + ')';\n return new RegExp('(?:^|,)(' + keyvalue + ')');\n};\n/**\n * Parse attributes from a line given the separator\n *\n * @param {string} attributes the attribute line to parse\n */\n\n\nconst parseAttributes = function (attributes) {\n const result = {};\n\n if (!attributes) {\n return result;\n } // split the string using attributes as the separator\n\n\n const attrs = attributes.split(attributeSeparator());\n let i = attrs.length;\n let attr;\n\n while (i--) {\n // filter out unmatched portions of the string\n if (attrs[i] === '') {\n continue;\n } // split the key and value\n\n\n attr = /([^=]*)=(.*)/.exec(attrs[i]).slice(1); // trim whitespace and remove optional quotes around the value\n\n attr[0] = attr[0].replace(/^\\s+|\\s+$/g, '');\n attr[1] = attr[1].replace(/^\\s+|\\s+$/g, '');\n attr[1] = attr[1].replace(/^['\"](.*)['\"]$/g, '$1');\n result[attr[0]] = attr[1];\n }\n\n return result;\n};\n/**\n * A line-level M3U8 parser event stream. It expects to receive input one\n * line at a time and performs a context-free parse of its contents. A stream\n * interpretation of a manifest can be useful if the manifest is expected to\n * be too large to fit comfortably into memory or the entirety of the input\n * is not immediately available. Otherwise, it's probably much easier to work\n * with a regular `Parser` object.\n *\n * Produces `data` events with an object that captures the parser's\n * interpretation of the input. That object has a property `tag` that is one\n * of `uri`, `comment`, or `tag`. URIs only have a single additional\n * property, `line`, which captures the entirety of the input without\n * interpretation. Comments similarly have a single additional property\n * `text` which is the input without the leading `#`.\n *\n * Tags always have a property `tagType` which is the lower-cased version of\n * the M3U8 directive without the `#EXT` or `#EXT-X-` prefix. For instance,\n * `#EXT-X-MEDIA-SEQUENCE` becomes `media-sequence` when parsed. Unrecognized\n * tags are given the tag type `unknown` and a single additional property\n * `data` with the remainder of the input.\n *\n * @class ParseStream\n * @extends Stream\n */\n\n\nclass ParseStream extends Stream {\n constructor() {\n super();\n this.customParsers = [];\n this.tagMappers = [];\n }\n /**\n * Parses an additional line of input.\n *\n * @param {string} line a single line of an M3U8 file to parse\n */\n\n\n push(line) {\n let match;\n let event; // strip whitespace\n\n line = line.trim();\n\n if (line.length === 0) {\n // ignore empty lines\n return;\n } // URIs\n\n\n if (line[0] !== '#') {\n this.trigger('data', {\n type: 'uri',\n uri: line\n });\n return;\n } // map tags\n\n\n const newLines = this.tagMappers.reduce((acc, mapper) => {\n const mappedLine = mapper(line); // skip if unchanged\n\n if (mappedLine === line) {\n return acc;\n }\n\n return acc.concat([mappedLine]);\n }, [line]);\n newLines.forEach(newLine => {\n for (let i = 0; i < this.customParsers.length; i++) {\n if (this.customParsers[i].call(this, newLine)) {\n return;\n }\n } // Comments\n\n\n if (newLine.indexOf('#EXT') !== 0) {\n this.trigger('data', {\n type: 'comment',\n text: newLine.slice(1)\n });\n return;\n } // strip off any carriage returns here so the regex matching\n // doesn't have to account for them.\n\n\n newLine = newLine.replace('\\r', ''); // Tags\n\n match = /^#EXTM3U/.exec(newLine);\n\n if (match) {\n this.trigger('data', {\n type: 'tag',\n tagType: 'm3u'\n });\n return;\n }\n\n match = /^#EXTINF:([0-9\\.]*)?,?(.*)?$/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'inf'\n };\n\n if (match[1]) {\n event.duration = parseFloat(match[1]);\n }\n\n if (match[2]) {\n event.title = match[2];\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-TARGETDURATION:([0-9.]*)?/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'targetduration'\n };\n\n if (match[1]) {\n event.duration = parseInt(match[1], 10);\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-VERSION:([0-9.]*)?/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'version'\n };\n\n if (match[1]) {\n event.version = parseInt(match[1], 10);\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-MEDIA-SEQUENCE:(\\-?[0-9.]*)?/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'media-sequence'\n };\n\n if (match[1]) {\n event.number = parseInt(match[1], 10);\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-DISCONTINUITY-SEQUENCE:(\\-?[0-9.]*)?/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'discontinuity-sequence'\n };\n\n if (match[1]) {\n event.number = parseInt(match[1], 10);\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-PLAYLIST-TYPE:(.*)?$/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'playlist-type'\n };\n\n if (match[1]) {\n event.playlistType = match[1];\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-BYTERANGE:(.*)?$/.exec(newLine);\n\n if (match) {\n event = _extends(parseByterange(match[1]), {\n type: 'tag',\n tagType: 'byterange'\n });\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-ALLOW-CACHE:(YES|NO)?/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'allow-cache'\n };\n\n if (match[1]) {\n event.allowed = !/NO/.test(match[1]);\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-MAP:(.*)$/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'map'\n };\n\n if (match[1]) {\n const attributes = parseAttributes(match[1]);\n\n if (attributes.URI) {\n event.uri = attributes.URI;\n }\n\n if (attributes.BYTERANGE) {\n event.byterange = parseByterange(attributes.BYTERANGE);\n }\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-STREAM-INF:(.*)$/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'stream-inf'\n };\n\n if (match[1]) {\n event.attributes = parseAttributes(match[1]);\n\n if (event.attributes.RESOLUTION) {\n const split = event.attributes.RESOLUTION.split('x');\n const resolution = {};\n\n if (split[0]) {\n resolution.width = parseInt(split[0], 10);\n }\n\n if (split[1]) {\n resolution.height = parseInt(split[1], 10);\n }\n\n event.attributes.RESOLUTION = resolution;\n }\n\n if (event.attributes.BANDWIDTH) {\n event.attributes.BANDWIDTH = parseInt(event.attributes.BANDWIDTH, 10);\n }\n\n if (event.attributes['FRAME-RATE']) {\n event.attributes['FRAME-RATE'] = parseFloat(event.attributes['FRAME-RATE']);\n }\n\n if (event.attributes['PROGRAM-ID']) {\n event.attributes['PROGRAM-ID'] = parseInt(event.attributes['PROGRAM-ID'], 10);\n }\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-MEDIA:(.*)$/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'media'\n };\n\n if (match[1]) {\n event.attributes = parseAttributes(match[1]);\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-ENDLIST/.exec(newLine);\n\n if (match) {\n this.trigger('data', {\n type: 'tag',\n tagType: 'endlist'\n });\n return;\n }\n\n match = /^#EXT-X-DISCONTINUITY/.exec(newLine);\n\n if (match) {\n this.trigger('data', {\n type: 'tag',\n tagType: 'discontinuity'\n });\n return;\n }\n\n match = /^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'program-date-time'\n };\n\n if (match[1]) {\n event.dateTimeString = match[1];\n event.dateTimeObject = new Date(match[1]);\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-KEY:(.*)$/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'key'\n };\n\n if (match[1]) {\n event.attributes = parseAttributes(match[1]); // parse the IV string into a Uint32Array\n\n if (event.attributes.IV) {\n if (event.attributes.IV.substring(0, 2).toLowerCase() === '0x') {\n event.attributes.IV = event.attributes.IV.substring(2);\n }\n\n event.attributes.IV = event.attributes.IV.match(/.{8}/g);\n event.attributes.IV[0] = parseInt(event.attributes.IV[0], 16);\n event.attributes.IV[1] = parseInt(event.attributes.IV[1], 16);\n event.attributes.IV[2] = parseInt(event.attributes.IV[2], 16);\n event.attributes.IV[3] = parseInt(event.attributes.IV[3], 16);\n event.attributes.IV = new Uint32Array(event.attributes.IV);\n }\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-START:(.*)$/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'start'\n };\n\n if (match[1]) {\n event.attributes = parseAttributes(match[1]);\n event.attributes['TIME-OFFSET'] = parseFloat(event.attributes['TIME-OFFSET']);\n event.attributes.PRECISE = /YES/.test(event.attributes.PRECISE);\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-CUE-OUT-CONT:(.*)?$/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'cue-out-cont'\n };\n\n if (match[1]) {\n event.data = match[1];\n } else {\n event.data = '';\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-CUE-OUT:(.*)?$/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'cue-out'\n };\n\n if (match[1]) {\n event.data = match[1];\n } else {\n event.data = '';\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-CUE-IN:(.*)?$/.exec(newLine);\n\n if (match) {\n event = {\n type: 'tag',\n tagType: 'cue-in'\n };\n\n if (match[1]) {\n event.data = match[1];\n } else {\n event.data = '';\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-SKIP:(.*)$/.exec(newLine);\n\n if (match && match[1]) {\n event = {\n type: 'tag',\n tagType: 'skip'\n };\n event.attributes = parseAttributes(match[1]);\n\n if (event.attributes.hasOwnProperty('SKIPPED-SEGMENTS')) {\n event.attributes['SKIPPED-SEGMENTS'] = parseInt(event.attributes['SKIPPED-SEGMENTS'], 10);\n }\n\n if (event.attributes.hasOwnProperty('RECENTLY-REMOVED-DATERANGES')) {\n event.attributes['RECENTLY-REMOVED-DATERANGES'] = event.attributes['RECENTLY-REMOVED-DATERANGES'].split(TAB);\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-PART:(.*)$/.exec(newLine);\n\n if (match && match[1]) {\n event = {\n type: 'tag',\n tagType: 'part'\n };\n event.attributes = parseAttributes(match[1]);\n ['DURATION'].forEach(function (key) {\n if (event.attributes.hasOwnProperty(key)) {\n event.attributes[key] = parseFloat(event.attributes[key]);\n }\n });\n ['INDEPENDENT', 'GAP'].forEach(function (key) {\n if (event.attributes.hasOwnProperty(key)) {\n event.attributes[key] = /YES/.test(event.attributes[key]);\n }\n });\n\n if (event.attributes.hasOwnProperty('BYTERANGE')) {\n event.attributes.byterange = parseByterange(event.attributes.BYTERANGE);\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-SERVER-CONTROL:(.*)$/.exec(newLine);\n\n if (match && match[1]) {\n event = {\n type: 'tag',\n tagType: 'server-control'\n };\n event.attributes = parseAttributes(match[1]);\n ['CAN-SKIP-UNTIL', 'PART-HOLD-BACK', 'HOLD-BACK'].forEach(function (key) {\n if (event.attributes.hasOwnProperty(key)) {\n event.attributes[key] = parseFloat(event.attributes[key]);\n }\n });\n ['CAN-SKIP-DATERANGES', 'CAN-BLOCK-RELOAD'].forEach(function (key) {\n if (event.attributes.hasOwnProperty(key)) {\n event.attributes[key] = /YES/.test(event.attributes[key]);\n }\n });\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-PART-INF:(.*)$/.exec(newLine);\n\n if (match && match[1]) {\n event = {\n type: 'tag',\n tagType: 'part-inf'\n };\n event.attributes = parseAttributes(match[1]);\n ['PART-TARGET'].forEach(function (key) {\n if (event.attributes.hasOwnProperty(key)) {\n event.attributes[key] = parseFloat(event.attributes[key]);\n }\n });\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-PRELOAD-HINT:(.*)$/.exec(newLine);\n\n if (match && match[1]) {\n event = {\n type: 'tag',\n tagType: 'preload-hint'\n };\n event.attributes = parseAttributes(match[1]);\n ['BYTERANGE-START', 'BYTERANGE-LENGTH'].forEach(function (key) {\n if (event.attributes.hasOwnProperty(key)) {\n event.attributes[key] = parseInt(event.attributes[key], 10);\n const subkey = key === 'BYTERANGE-LENGTH' ? 'length' : 'offset';\n event.attributes.byterange = event.attributes.byterange || {};\n event.attributes.byterange[subkey] = event.attributes[key]; // only keep the parsed byterange object.\n\n delete event.attributes[key];\n }\n });\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-RENDITION-REPORT:(.*)$/.exec(newLine);\n\n if (match && match[1]) {\n event = {\n type: 'tag',\n tagType: 'rendition-report'\n };\n event.attributes = parseAttributes(match[1]);\n ['LAST-MSN', 'LAST-PART'].forEach(function (key) {\n if (event.attributes.hasOwnProperty(key)) {\n event.attributes[key] = parseInt(event.attributes[key], 10);\n }\n });\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-DATERANGE:(.*)$/.exec(newLine);\n\n if (match && match[1]) {\n event = {\n type: 'tag',\n tagType: 'daterange'\n };\n event.attributes = parseAttributes(match[1]);\n ['ID', 'CLASS'].forEach(function (key) {\n if (event.attributes.hasOwnProperty(key)) {\n event.attributes[key] = String(event.attributes[key]);\n }\n });\n ['START-DATE', 'END-DATE'].forEach(function (key) {\n if (event.attributes.hasOwnProperty(key)) {\n event.attributes[key] = new Date(event.attributes[key]);\n }\n });\n ['DURATION', 'PLANNED-DURATION'].forEach(function (key) {\n if (event.attributes.hasOwnProperty(key)) {\n event.attributes[key] = parseFloat(event.attributes[key]);\n }\n });\n ['END-ON-NEXT'].forEach(function (key) {\n if (event.attributes.hasOwnProperty(key)) {\n event.attributes[key] = /YES/i.test(event.attributes[key]);\n }\n });\n ['SCTE35-CMD', ' SCTE35-OUT', 'SCTE35-IN'].forEach(function (key) {\n if (event.attributes.hasOwnProperty(key)) {\n event.attributes[key] = event.attributes[key].toString(16);\n }\n });\n const clientAttributePattern = /^X-([A-Z]+-)+[A-Z]+$/;\n\n for (const key in event.attributes) {\n if (!clientAttributePattern.test(key)) {\n continue;\n }\n\n const isHexaDecimal = /[0-9A-Fa-f]{6}/g.test(event.attributes[key]);\n const isDecimalFloating = /^\\d+(\\.\\d+)?$/.test(event.attributes[key]);\n event.attributes[key] = isHexaDecimal ? event.attributes[key].toString(16) : isDecimalFloating ? parseFloat(event.attributes[key]) : String(event.attributes[key]);\n }\n\n this.trigger('data', event);\n return;\n }\n\n match = /^#EXT-X-INDEPENDENT-SEGMENTS/.exec(newLine);\n\n if (match) {\n this.trigger('data', {\n type: 'tag',\n tagType: 'independent-segments'\n });\n return;\n } // unknown tag type\n\n\n this.trigger('data', {\n type: 'tag',\n data: newLine.slice(4)\n });\n });\n }\n /**\n * Add a parser for custom headers\n *\n * @param {Object} options a map of options for the added parser\n * @param {RegExp} options.expression a regular expression to match the custom header\n * @param {string} options.customType the custom type to register to the output\n * @param {Function} [options.dataParser] function to parse the line into an object\n * @param {boolean} [options.segment] should tag data be attached to the segment object\n */\n\n\n addParser({\n expression,\n customType,\n dataParser,\n segment\n }) {\n if (typeof dataParser !== 'function') {\n dataParser = line => line;\n }\n\n this.customParsers.push(line => {\n const match = expression.exec(line);\n\n if (match) {\n this.trigger('data', {\n type: 'custom',\n data: dataParser(line),\n customType,\n segment\n });\n return true;\n }\n });\n }\n /**\n * Add a custom header mapper\n *\n * @param {Object} options\n * @param {RegExp} options.expression a regular expression to match the custom header\n * @param {Function} options.map function to translate tag into a different tag\n */\n\n\n addTagMapper({\n expression,\n map\n }) {\n const mapFn = line => {\n if (expression.test(line)) {\n return map(line);\n }\n\n return line;\n };\n\n this.tagMappers.push(mapFn);\n }\n\n}\n\nconst camelCase = str => str.toLowerCase().replace(/-(\\w)/g, a => a[1].toUpperCase());\n\nconst camelCaseKeys = function (attributes) {\n const result = {};\n Object.keys(attributes).forEach(function (key) {\n result[camelCase(key)] = attributes[key];\n });\n return result;\n}; // set SERVER-CONTROL hold back based upon targetDuration and partTargetDuration\n// we need this helper because defaults are based upon targetDuration and\n// partTargetDuration being set, but they may not be if SERVER-CONTROL appears before\n// target durations are set.\n\n\nconst setHoldBack = function (manifest) {\n const {\n serverControl,\n targetDuration,\n partTargetDuration\n } = manifest;\n\n if (!serverControl) {\n return;\n }\n\n const tag = '#EXT-X-SERVER-CONTROL';\n const hb = 'holdBack';\n const phb = 'partHoldBack';\n const minTargetDuration = targetDuration && targetDuration * 3;\n const minPartDuration = partTargetDuration && partTargetDuration * 2;\n\n if (targetDuration && !serverControl.hasOwnProperty(hb)) {\n serverControl[hb] = minTargetDuration;\n this.trigger('info', {\n message: `${tag} defaulting HOLD-BACK to targetDuration * 3 (${minTargetDuration}).`\n });\n }\n\n if (minTargetDuration && serverControl[hb] < minTargetDuration) {\n this.trigger('warn', {\n message: `${tag} clamping HOLD-BACK (${serverControl[hb]}) to targetDuration * 3 (${minTargetDuration})`\n });\n serverControl[hb] = minTargetDuration;\n } // default no part hold back to part target duration * 3\n\n\n if (partTargetDuration && !serverControl.hasOwnProperty(phb)) {\n serverControl[phb] = partTargetDuration * 3;\n this.trigger('info', {\n message: `${tag} defaulting PART-HOLD-BACK to partTargetDuration * 3 (${serverControl[phb]}).`\n });\n } // if part hold back is too small default it to part target duration * 2\n\n\n if (partTargetDuration && serverControl[phb] < minPartDuration) {\n this.trigger('warn', {\n message: `${tag} clamping PART-HOLD-BACK (${serverControl[phb]}) to partTargetDuration * 2 (${minPartDuration}).`\n });\n serverControl[phb] = minPartDuration;\n }\n};\n/**\n * A parser for M3U8 files. The current interpretation of the input is\n * exposed as a property `manifest` on parser objects. It's just two lines to\n * create and parse a manifest once you have the contents available as a string:\n *\n * ```js\n * var parser = new m3u8.Parser();\n * parser.push(xhr.responseText);\n * ```\n *\n * New input can later be applied to update the manifest object by calling\n * `push` again.\n *\n * The parser attempts to create a usable manifest object even if the\n * underlying input is somewhat nonsensical. It emits `info` and `warning`\n * events during the parse if it encounters input that seems invalid or\n * requires some property of the manifest object to be defaulted.\n *\n * @class Parser\n * @extends Stream\n */\n\n\nclass Parser extends Stream {\n constructor() {\n super();\n this.lineStream = new LineStream();\n this.parseStream = new ParseStream();\n this.lineStream.pipe(this.parseStream);\n /* eslint-disable consistent-this */\n\n const self = this;\n /* eslint-enable consistent-this */\n\n const uris = [];\n let currentUri = {}; // if specified, the active EXT-X-MAP definition\n\n let currentMap; // if specified, the active decryption key\n\n let key;\n let hasParts = false;\n\n const noop = function () {};\n\n const defaultMediaGroups = {\n 'AUDIO': {},\n 'VIDEO': {},\n 'CLOSED-CAPTIONS': {},\n 'SUBTITLES': {}\n }; // This is the Widevine UUID from DASH IF IOP. The same exact string is\n // used in MPDs with Widevine encrypted streams.\n\n const widevineUuid = 'urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed'; // group segments into numbered timelines delineated by discontinuities\n\n let currentTimeline = 0; // the manifest is empty until the parse stream begins delivering data\n\n this.manifest = {\n allowCache: true,\n discontinuityStarts: [],\n segments: []\n }; // keep track of the last seen segment's byte range end, as segments are not required\n // to provide the offset, in which case it defaults to the next byte after the\n // previous segment\n\n let lastByterangeEnd = 0; // keep track of the last seen part's byte range end.\n\n let lastPartByterangeEnd = 0;\n const daterangeTags = {};\n this.on('end', () => {\n // only add preloadSegment if we don't yet have a uri for it.\n // and we actually have parts/preloadHints\n if (currentUri.uri || !currentUri.parts && !currentUri.preloadHints) {\n return;\n }\n\n if (!currentUri.map && currentMap) {\n currentUri.map = currentMap;\n }\n\n if (!currentUri.key && key) {\n currentUri.key = key;\n }\n\n if (!currentUri.timeline && typeof currentTimeline === 'number') {\n currentUri.timeline = currentTimeline;\n }\n\n this.manifest.preloadSegment = currentUri;\n }); // update the manifest with the m3u8 entry from the parse stream\n\n this.parseStream.on('data', function (entry) {\n let mediaGroup;\n let rendition;\n ({\n tag() {\n // switch based on the tag type\n (({\n version() {\n if (entry.version) {\n this.manifest.version = entry.version;\n }\n },\n\n 'allow-cache'() {\n this.manifest.allowCache = entry.allowed;\n\n if (!('allowed' in entry)) {\n this.trigger('info', {\n message: 'defaulting allowCache to YES'\n });\n this.manifest.allowCache = true;\n }\n },\n\n byterange() {\n const byterange = {};\n\n if ('length' in entry) {\n currentUri.byterange = byterange;\n byterange.length = entry.length;\n\n if (!('offset' in entry)) {\n /*\n * From the latest spec (as of this writing):\n * https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.2.2\n *\n * Same text since EXT-X-BYTERANGE's introduction in draft 7:\n * https://tools.ietf.org/html/draft-pantos-http-live-streaming-07#section-3.3.1)\n *\n * \"If o [offset] is not present, the sub-range begins at the next byte\n * following the sub-range of the previous media segment.\"\n */\n entry.offset = lastByterangeEnd;\n }\n }\n\n if ('offset' in entry) {\n currentUri.byterange = byterange;\n byterange.offset = entry.offset;\n }\n\n lastByterangeEnd = byterange.offset + byterange.length;\n },\n\n endlist() {\n this.manifest.endList = true;\n },\n\n inf() {\n if (!('mediaSequence' in this.manifest)) {\n this.manifest.mediaSequence = 0;\n this.trigger('info', {\n message: 'defaulting media sequence to zero'\n });\n }\n\n if (!('discontinuitySequence' in this.manifest)) {\n this.manifest.discontinuitySequence = 0;\n this.trigger('info', {\n message: 'defaulting discontinuity sequence to zero'\n });\n }\n\n if (entry.duration > 0) {\n currentUri.duration = entry.duration;\n }\n\n if (entry.duration === 0) {\n currentUri.duration = 0.01;\n this.trigger('info', {\n message: 'updating zero segment duration to a small value'\n });\n }\n\n this.manifest.segments = uris;\n },\n\n key() {\n if (!entry.attributes) {\n this.trigger('warn', {\n message: 'ignoring key declaration without attribute list'\n });\n return;\n } // clear the active encryption key\n\n\n if (entry.attributes.METHOD === 'NONE') {\n key = null;\n return;\n }\n\n if (!entry.attributes.URI) {\n this.trigger('warn', {\n message: 'ignoring key declaration without URI'\n });\n return;\n }\n\n if (entry.attributes.KEYFORMAT === 'com.apple.streamingkeydelivery') {\n this.manifest.contentProtection = this.manifest.contentProtection || {}; // TODO: add full support for this.\n\n this.manifest.contentProtection['com.apple.fps.1_0'] = {\n attributes: entry.attributes\n };\n return;\n }\n\n if (entry.attributes.KEYFORMAT === 'com.microsoft.playready') {\n this.manifest.contentProtection = this.manifest.contentProtection || {}; // TODO: add full support for this.\n\n this.manifest.contentProtection['com.microsoft.playready'] = {\n uri: entry.attributes.URI\n };\n return;\n } // check if the content is encrypted for Widevine\n // Widevine/HLS spec: https://storage.googleapis.com/wvdocs/Widevine_DRM_HLS.pdf\n\n\n if (entry.attributes.KEYFORMAT === widevineUuid) {\n const VALID_METHODS = ['SAMPLE-AES', 'SAMPLE-AES-CTR', 'SAMPLE-AES-CENC'];\n\n if (VALID_METHODS.indexOf(entry.attributes.METHOD) === -1) {\n this.trigger('warn', {\n message: 'invalid key method provided for Widevine'\n });\n return;\n }\n\n if (entry.attributes.METHOD === 'SAMPLE-AES-CENC') {\n this.trigger('warn', {\n message: 'SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead'\n });\n }\n\n if (entry.attributes.URI.substring(0, 23) !== 'data:text/plain;base64,') {\n this.trigger('warn', {\n message: 'invalid key URI provided for Widevine'\n });\n return;\n }\n\n if (!(entry.attributes.KEYID && entry.attributes.KEYID.substring(0, 2) === '0x')) {\n this.trigger('warn', {\n message: 'invalid key ID provided for Widevine'\n });\n return;\n } // if Widevine key attributes are valid, store them as `contentProtection`\n // on the manifest to emulate Widevine tag structure in a DASH mpd\n\n\n this.manifest.contentProtection = this.manifest.contentProtection || {};\n this.manifest.contentProtection['com.widevine.alpha'] = {\n attributes: {\n schemeIdUri: entry.attributes.KEYFORMAT,\n // remove '0x' from the key id string\n keyId: entry.attributes.KEYID.substring(2)\n },\n // decode the base64-encoded PSSH box\n pssh: decodeB64ToUint8Array(entry.attributes.URI.split(',')[1])\n };\n return;\n }\n\n if (!entry.attributes.METHOD) {\n this.trigger('warn', {\n message: 'defaulting key method to AES-128'\n });\n } // setup an encryption key for upcoming segments\n\n\n key = {\n method: entry.attributes.METHOD || 'AES-128',\n uri: entry.attributes.URI\n };\n\n if (typeof entry.attributes.IV !== 'undefined') {\n key.iv = entry.attributes.IV;\n }\n },\n\n 'media-sequence'() {\n if (!isFinite(entry.number)) {\n this.trigger('warn', {\n message: 'ignoring invalid media sequence: ' + entry.number\n });\n return;\n }\n\n this.manifest.mediaSequence = entry.number;\n },\n\n 'discontinuity-sequence'() {\n if (!isFinite(entry.number)) {\n this.trigger('warn', {\n message: 'ignoring invalid discontinuity sequence: ' + entry.number\n });\n return;\n }\n\n this.manifest.discontinuitySequence = entry.number;\n currentTimeline = entry.number;\n },\n\n 'playlist-type'() {\n if (!/VOD|EVENT/.test(entry.playlistType)) {\n this.trigger('warn', {\n message: 'ignoring unknown playlist type: ' + entry.playlist\n });\n return;\n }\n\n this.manifest.playlistType = entry.playlistType;\n },\n\n map() {\n currentMap = {};\n\n if (entry.uri) {\n currentMap.uri = entry.uri;\n }\n\n if (entry.byterange) {\n currentMap.byterange = entry.byterange;\n }\n\n if (key) {\n currentMap.key = key;\n }\n },\n\n 'stream-inf'() {\n this.manifest.playlists = uris;\n this.manifest.mediaGroups = this.manifest.mediaGroups || defaultMediaGroups;\n\n if (!entry.attributes) {\n this.trigger('warn', {\n message: 'ignoring empty stream-inf attributes'\n });\n return;\n }\n\n if (!currentUri.attributes) {\n currentUri.attributes = {};\n }\n\n _extends(currentUri.attributes, entry.attributes);\n },\n\n media() {\n this.manifest.mediaGroups = this.manifest.mediaGroups || defaultMediaGroups;\n\n if (!(entry.attributes && entry.attributes.TYPE && entry.attributes['GROUP-ID'] && entry.attributes.NAME)) {\n this.trigger('warn', {\n message: 'ignoring incomplete or missing media group'\n });\n return;\n } // find the media group, creating defaults as necessary\n\n\n const mediaGroupType = this.manifest.mediaGroups[entry.attributes.TYPE];\n mediaGroupType[entry.attributes['GROUP-ID']] = mediaGroupType[entry.attributes['GROUP-ID']] || {};\n mediaGroup = mediaGroupType[entry.attributes['GROUP-ID']]; // collect the rendition metadata\n\n rendition = {\n default: /yes/i.test(entry.attributes.DEFAULT)\n };\n\n if (rendition.default) {\n rendition.autoselect = true;\n } else {\n rendition.autoselect = /yes/i.test(entry.attributes.AUTOSELECT);\n }\n\n if (entry.attributes.LANGUAGE) {\n rendition.language = entry.attributes.LANGUAGE;\n }\n\n if (entry.attributes.URI) {\n rendition.uri = entry.attributes.URI;\n }\n\n if (entry.attributes['INSTREAM-ID']) {\n rendition.instreamId = entry.attributes['INSTREAM-ID'];\n }\n\n if (entry.attributes.CHARACTERISTICS) {\n rendition.characteristics = entry.attributes.CHARACTERISTICS;\n }\n\n if (entry.attributes.FORCED) {\n rendition.forced = /yes/i.test(entry.attributes.FORCED);\n } // insert the new rendition\n\n\n mediaGroup[entry.attributes.NAME] = rendition;\n },\n\n discontinuity() {\n currentTimeline += 1;\n currentUri.discontinuity = true;\n this.manifest.discontinuityStarts.push(uris.length);\n },\n\n 'program-date-time'() {\n if (typeof this.manifest.dateTimeString === 'undefined') {\n // PROGRAM-DATE-TIME is a media-segment tag, but for backwards\n // compatibility, we add the first occurence of the PROGRAM-DATE-TIME tag\n // to the manifest object\n // TODO: Consider removing this in future major version\n this.manifest.dateTimeString = entry.dateTimeString;\n this.manifest.dateTimeObject = entry.dateTimeObject;\n }\n\n currentUri.dateTimeString = entry.dateTimeString;\n currentUri.dateTimeObject = entry.dateTimeObject;\n },\n\n targetduration() {\n if (!isFinite(entry.duration) || entry.duration < 0) {\n this.trigger('warn', {\n message: 'ignoring invalid target duration: ' + entry.duration\n });\n return;\n }\n\n this.manifest.targetDuration = entry.duration;\n setHoldBack.call(this, this.manifest);\n },\n\n start() {\n if (!entry.attributes || isNaN(entry.attributes['TIME-OFFSET'])) {\n this.trigger('warn', {\n message: 'ignoring start declaration without appropriate attribute list'\n });\n return;\n }\n\n this.manifest.start = {\n timeOffset: entry.attributes['TIME-OFFSET'],\n precise: entry.attributes.PRECISE\n };\n },\n\n 'cue-out'() {\n currentUri.cueOut = entry.data;\n },\n\n 'cue-out-cont'() {\n currentUri.cueOutCont = entry.data;\n },\n\n 'cue-in'() {\n currentUri.cueIn = entry.data;\n },\n\n 'skip'() {\n this.manifest.skip = camelCaseKeys(entry.attributes);\n this.warnOnMissingAttributes_('#EXT-X-SKIP', entry.attributes, ['SKIPPED-SEGMENTS']);\n },\n\n 'part'() {\n hasParts = true; // parts are always specifed before a segment\n\n const segmentIndex = this.manifest.segments.length;\n const part = camelCaseKeys(entry.attributes);\n currentUri.parts = currentUri.parts || [];\n currentUri.parts.push(part);\n\n if (part.byterange) {\n if (!part.byterange.hasOwnProperty('offset')) {\n part.byterange.offset = lastPartByterangeEnd;\n }\n\n lastPartByterangeEnd = part.byterange.offset + part.byterange.length;\n }\n\n const partIndex = currentUri.parts.length - 1;\n this.warnOnMissingAttributes_(`#EXT-X-PART #${partIndex} for segment #${segmentIndex}`, entry.attributes, ['URI', 'DURATION']);\n\n if (this.manifest.renditionReports) {\n this.manifest.renditionReports.forEach((r, i) => {\n if (!r.hasOwnProperty('lastPart')) {\n this.trigger('warn', {\n message: `#EXT-X-RENDITION-REPORT #${i} lacks required attribute(s): LAST-PART`\n });\n }\n });\n }\n },\n\n 'server-control'() {\n const attrs = this.manifest.serverControl = camelCaseKeys(entry.attributes);\n\n if (!attrs.hasOwnProperty('canBlockReload')) {\n attrs.canBlockReload = false;\n this.trigger('info', {\n message: '#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false'\n });\n }\n\n setHoldBack.call(this, this.manifest);\n\n if (attrs.canSkipDateranges && !attrs.hasOwnProperty('canSkipUntil')) {\n this.trigger('warn', {\n message: '#EXT-X-SERVER-CONTROL lacks required attribute CAN-SKIP-UNTIL which is required when CAN-SKIP-DATERANGES is set'\n });\n }\n },\n\n 'preload-hint'() {\n // parts are always specifed before a segment\n const segmentIndex = this.manifest.segments.length;\n const hint = camelCaseKeys(entry.attributes);\n const isPart = hint.type && hint.type === 'PART';\n currentUri.preloadHints = currentUri.preloadHints || [];\n currentUri.preloadHints.push(hint);\n\n if (hint.byterange) {\n if (!hint.byterange.hasOwnProperty('offset')) {\n // use last part byterange end or zero if not a part.\n hint.byterange.offset = isPart ? lastPartByterangeEnd : 0;\n\n if (isPart) {\n lastPartByterangeEnd = hint.byterange.offset + hint.byterange.length;\n }\n }\n }\n\n const index = currentUri.preloadHints.length - 1;\n this.warnOnMissingAttributes_(`#EXT-X-PRELOAD-HINT #${index} for segment #${segmentIndex}`, entry.attributes, ['TYPE', 'URI']);\n\n if (!hint.type) {\n return;\n } // search through all preload hints except for the current one for\n // a duplicate type.\n\n\n for (let i = 0; i < currentUri.preloadHints.length - 1; i++) {\n const otherHint = currentUri.preloadHints[i];\n\n if (!otherHint.type) {\n continue;\n }\n\n if (otherHint.type === hint.type) {\n this.trigger('warn', {\n message: `#EXT-X-PRELOAD-HINT #${index} for segment #${segmentIndex} has the same TYPE ${hint.type} as preload hint #${i}`\n });\n }\n }\n },\n\n 'rendition-report'() {\n const report = camelCaseKeys(entry.attributes);\n this.manifest.renditionReports = this.manifest.renditionReports || [];\n this.manifest.renditionReports.push(report);\n const index = this.manifest.renditionReports.length - 1;\n const required = ['LAST-MSN', 'URI'];\n\n if (hasParts) {\n required.push('LAST-PART');\n }\n\n this.warnOnMissingAttributes_(`#EXT-X-RENDITION-REPORT #${index}`, entry.attributes, required);\n },\n\n 'part-inf'() {\n this.manifest.partInf = camelCaseKeys(entry.attributes);\n this.warnOnMissingAttributes_('#EXT-X-PART-INF', entry.attributes, ['PART-TARGET']);\n\n if (this.manifest.partInf.partTarget) {\n this.manifest.partTargetDuration = this.manifest.partInf.partTarget;\n }\n\n setHoldBack.call(this, this.manifest);\n },\n\n 'daterange'() {\n this.manifest.daterange = this.manifest.daterange || [];\n this.manifest.daterange.push(camelCaseKeys(entry.attributes));\n const index = this.manifest.daterange.length - 1;\n this.warnOnMissingAttributes_(`#EXT-X-DATERANGE #${index}`, entry.attributes, ['ID', 'START-DATE']);\n const daterange = this.manifest.daterange[index];\n\n if (daterange.endDate && daterange.startDate && new Date(daterange.endDate) < new Date(daterange.startDate)) {\n this.trigger('warn', {\n message: 'EXT-X-DATERANGE END-DATE must be equal to or later than the value of the START-DATE'\n });\n }\n\n if (daterange.duration && daterange.duration < 0) {\n this.trigger('warn', {\n message: 'EXT-X-DATERANGE DURATION must not be negative'\n });\n }\n\n if (daterange.plannedDuration && daterange.plannedDuration < 0) {\n this.trigger('warn', {\n message: 'EXT-X-DATERANGE PLANNED-DURATION must not be negative'\n });\n }\n\n const endOnNextYes = !!daterange.endOnNext;\n\n if (endOnNextYes && !daterange.class) {\n this.trigger('warn', {\n message: 'EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must have a CLASS attribute'\n });\n }\n\n if (endOnNextYes && (daterange.duration || daterange.endDate)) {\n this.trigger('warn', {\n message: 'EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must not contain DURATION or END-DATE attributes'\n });\n }\n\n if (daterange.duration && daterange.endDate) {\n const startDate = daterange.startDate;\n const newDateInSeconds = startDate.setSeconds(startDate.getSeconds() + daterange.duration);\n this.manifest.daterange[index].endDate = new Date(newDateInSeconds);\n }\n\n if (daterange && !this.manifest.dateTimeString) {\n this.trigger('warn', {\n message: 'A playlist with EXT-X-DATERANGE tag must contain atleast one EXT-X-PROGRAM-DATE-TIME tag'\n });\n }\n\n if (!daterangeTags[daterange.id]) {\n daterangeTags[daterange.id] = daterange;\n } else {\n for (const attribute in daterangeTags[daterange.id]) {\n if (daterangeTags[daterange.id][attribute] !== daterange[attribute]) {\n this.trigger('warn', {\n message: 'EXT-X-DATERANGE tags with the same ID in a playlist must have the same attributes and same attribute values'\n });\n break;\n }\n }\n }\n },\n\n 'independent-segments'() {\n this.manifest.independentSegments = true;\n }\n\n })[entry.tagType] || noop).call(self);\n },\n\n uri() {\n currentUri.uri = entry.uri;\n uris.push(currentUri); // if no explicit duration was declared, use the target duration\n\n if (this.manifest.targetDuration && !('duration' in currentUri)) {\n this.trigger('warn', {\n message: 'defaulting segment duration to the target duration'\n });\n currentUri.duration = this.manifest.targetDuration;\n } // annotate with encryption information, if necessary\n\n\n if (key) {\n currentUri.key = key;\n }\n\n currentUri.timeline = currentTimeline; // annotate with initialization segment information, if necessary\n\n if (currentMap) {\n currentUri.map = currentMap;\n } // reset the last byterange end as it needs to be 0 between parts\n\n\n lastPartByterangeEnd = 0; // prepare for the next URI\n\n currentUri = {};\n },\n\n comment() {// comments are not important for playback\n },\n\n custom() {\n // if this is segment-level data attach the output to the segment\n if (entry.segment) {\n currentUri.custom = currentUri.custom || {};\n currentUri.custom[entry.customType] = entry.data; // if this is manifest-level data attach to the top level manifest object\n } else {\n this.manifest.custom = this.manifest.custom || {};\n this.manifest.custom[entry.customType] = entry.data;\n }\n }\n\n })[entry.type].call(self);\n });\n }\n\n warnOnMissingAttributes_(identifier, attributes, required) {\n const missing = [];\n required.forEach(function (key) {\n if (!attributes.hasOwnProperty(key)) {\n missing.push(key);\n }\n });\n\n if (missing.length) {\n this.trigger('warn', {\n message: `${identifier} lacks required attribute(s): ${missing.join(', ')}`\n });\n }\n }\n /**\n * Parse the input string and update the manifest object.\n *\n * @param {string} chunk a potentially incomplete portion of the manifest\n */\n\n\n push(chunk) {\n this.lineStream.push(chunk);\n }\n /**\n * Flush any remaining input. This can be handy if the last line of an M3U8\n * manifest did not contain a trailing newline but the file has been\n * completely received.\n */\n\n\n end() {\n // flush any buffered input\n this.lineStream.push('\\n');\n this.trigger('end');\n }\n /**\n * Add an additional parser for non-standard tags\n *\n * @param {Object} options a map of options for the added parser\n * @param {RegExp} options.expression a regular expression to match the custom header\n * @param {string} options.type the type to register to the output\n * @param {Function} [options.dataParser] function to parse the line into an object\n * @param {boolean} [options.segment] should tag data be attached to the segment object\n */\n\n\n addParser(options) {\n this.parseStream.addParser(options);\n }\n /**\n * Add a custom header mapper\n *\n * @param {Object} options\n * @param {RegExp} options.expression a regular expression to match the custom header\n * @param {Function} options.map function to translate tag into a different tag\n */\n\n\n addTagMapper(options) {\n this.parseStream.addTagMapper(options);\n }\n\n}\n\nexport { LineStream, ParseStream, Parser };\n","import window from 'global/window';\nvar regexs = {\n // to determine mime types\n mp4: /^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/,\n webm: /^(vp0?[89]|av0?1|opus|vorbis)/,\n ogg: /^(vp0?[89]|theora|flac|opus|vorbis)/,\n // to determine if a codec is audio or video\n video: /^(av0?1|avc0?[1234]|vp0?[89]|hvc1|hev1|theora|mp4v)/,\n audio: /^(mp4a|flac|vorbis|opus|ac-[34]|ec-3|alac|mp3|speex|aac)/,\n text: /^(stpp.ttml.im1t)/,\n // mux.js support regex\n muxerVideo: /^(avc0?1)/,\n muxerAudio: /^(mp4a)/,\n // match nothing as muxer does not support text right now.\n // there cannot never be a character before the start of a string\n // so this matches nothing.\n muxerText: /a^/\n};\nvar mediaTypes = ['video', 'audio', 'text'];\nvar upperMediaTypes = ['Video', 'Audio', 'Text'];\n/**\n * Replace the old apple-style `avc1..` codec string with the standard\n * `avc1.`\n *\n * @param {string} codec\n * Codec string to translate\n * @return {string}\n * The translated codec string\n */\n\nexport var translateLegacyCodec = function translateLegacyCodec(codec) {\n if (!codec) {\n return codec;\n }\n\n return codec.replace(/avc1\\.(\\d+)\\.(\\d+)/i, function (orig, profile, avcLevel) {\n var profileHex = ('00' + Number(profile).toString(16)).slice(-2);\n var avcLevelHex = ('00' + Number(avcLevel).toString(16)).slice(-2);\n return 'avc1.' + profileHex + '00' + avcLevelHex;\n });\n};\n/**\n * Replace the old apple-style `avc1..` codec strings with the standard\n * `avc1.`\n *\n * @param {string[]} codecs\n * An array of codec strings to translate\n * @return {string[]}\n * The translated array of codec strings\n */\n\nexport var translateLegacyCodecs = function translateLegacyCodecs(codecs) {\n return codecs.map(translateLegacyCodec);\n};\n/**\n * Replace codecs in the codec string with the old apple-style `avc1..` to the\n * standard `avc1.`.\n *\n * @param {string} codecString\n * The codec string\n * @return {string}\n * The codec string with old apple-style codecs replaced\n *\n * @private\n */\n\nexport var mapLegacyAvcCodecs = function mapLegacyAvcCodecs(codecString) {\n return codecString.replace(/avc1\\.(\\d+)\\.(\\d+)/i, function (match) {\n return translateLegacyCodecs([match])[0];\n });\n};\n/**\n * @typedef {Object} ParsedCodecInfo\n * @property {number} codecCount\n * Number of codecs parsed\n * @property {string} [videoCodec]\n * Parsed video codec (if found)\n * @property {string} [videoObjectTypeIndicator]\n * Video object type indicator (if found)\n * @property {string|null} audioProfile\n * Audio profile\n */\n\n/**\n * Parses a codec string to retrieve the number of codecs specified, the video codec and\n * object type indicator, and the audio profile.\n *\n * @param {string} [codecString]\n * The codec string to parse\n * @return {ParsedCodecInfo}\n * Parsed codec info\n */\n\nexport var parseCodecs = function parseCodecs(codecString) {\n if (codecString === void 0) {\n codecString = '';\n }\n\n var codecs = codecString.split(',');\n var result = [];\n codecs.forEach(function (codec) {\n codec = codec.trim();\n var codecType;\n mediaTypes.forEach(function (name) {\n var match = regexs[name].exec(codec.toLowerCase());\n\n if (!match || match.length <= 1) {\n return;\n }\n\n codecType = name; // maintain codec case\n\n var type = codec.substring(0, match[1].length);\n var details = codec.replace(type, '');\n result.push({\n type: type,\n details: details,\n mediaType: name\n });\n });\n\n if (!codecType) {\n result.push({\n type: codec,\n details: '',\n mediaType: 'unknown'\n });\n }\n });\n return result;\n};\n/**\n * Returns a ParsedCodecInfo object for the default alternate audio playlist if there is\n * a default alternate audio playlist for the provided audio group.\n *\n * @param {Object} master\n * The master playlist\n * @param {string} audioGroupId\n * ID of the audio group for which to find the default codec info\n * @return {ParsedCodecInfo}\n * Parsed codec info\n */\n\nexport var codecsFromDefault = function codecsFromDefault(master, audioGroupId) {\n if (!master.mediaGroups.AUDIO || !audioGroupId) {\n return null;\n }\n\n var audioGroup = master.mediaGroups.AUDIO[audioGroupId];\n\n if (!audioGroup) {\n return null;\n }\n\n for (var name in audioGroup) {\n var audioType = audioGroup[name];\n\n if (audioType.default && audioType.playlists) {\n // codec should be the same for all playlists within the audio type\n return parseCodecs(audioType.playlists[0].attributes.CODECS);\n }\n }\n\n return null;\n};\nexport var isVideoCodec = function isVideoCodec(codec) {\n if (codec === void 0) {\n codec = '';\n }\n\n return regexs.video.test(codec.trim().toLowerCase());\n};\nexport var isAudioCodec = function isAudioCodec(codec) {\n if (codec === void 0) {\n codec = '';\n }\n\n return regexs.audio.test(codec.trim().toLowerCase());\n};\nexport var isTextCodec = function isTextCodec(codec) {\n if (codec === void 0) {\n codec = '';\n }\n\n return regexs.text.test(codec.trim().toLowerCase());\n};\nexport var getMimeForCodec = function getMimeForCodec(codecString) {\n if (!codecString || typeof codecString !== 'string') {\n return;\n }\n\n var codecs = codecString.toLowerCase().split(',').map(function (c) {\n return translateLegacyCodec(c.trim());\n }); // default to video type\n\n var type = 'video'; // only change to audio type if the only codec we have is\n // audio\n\n if (codecs.length === 1 && isAudioCodec(codecs[0])) {\n type = 'audio';\n } else if (codecs.length === 1 && isTextCodec(codecs[0])) {\n // text uses application/ for now\n type = 'application';\n } // default the container to mp4\n\n\n var container = 'mp4'; // every codec must be able to go into the container\n // for that container to be the correct one\n\n if (codecs.every(function (c) {\n return regexs.mp4.test(c);\n })) {\n container = 'mp4';\n } else if (codecs.every(function (c) {\n return regexs.webm.test(c);\n })) {\n container = 'webm';\n } else if (codecs.every(function (c) {\n return regexs.ogg.test(c);\n })) {\n container = 'ogg';\n }\n\n return type + \"/\" + container + \";codecs=\\\"\" + codecString + \"\\\"\";\n};\nexport var browserSupportsCodec = function browserSupportsCodec(codecString) {\n if (codecString === void 0) {\n codecString = '';\n }\n\n return window.MediaSource && window.MediaSource.isTypeSupported && window.MediaSource.isTypeSupported(getMimeForCodec(codecString)) || false;\n};\nexport var muxerSupportsCodec = function muxerSupportsCodec(codecString) {\n if (codecString === void 0) {\n codecString = '';\n }\n\n return codecString.toLowerCase().split(',').every(function (codec) {\n codec = codec.trim(); // any match is supported.\n\n for (var i = 0; i < upperMediaTypes.length; i++) {\n var type = upperMediaTypes[i];\n\n if (regexs[\"muxer\" + type].test(codec)) {\n return true;\n }\n }\n\n return false;\n });\n};\nexport var DEFAULT_AUDIO_CODEC = 'mp4a.40.2';\nexport var DEFAULT_VIDEO_CODEC = 'avc1.4d400d';","var MPEGURL_REGEX = /^(audio|video|application)\\/(x-|vnd\\.apple\\.)?mpegurl/i;\nvar DASH_REGEX = /^application\\/dash\\+xml/i;\n/**\n * Returns a string that describes the type of source based on a video source object's\n * media type.\n *\n * @see {@link https://dev.w3.org/html5/pf-summary/video.html#dom-source-type|Source Type}\n *\n * @param {string} type\n * Video source object media type\n * @return {('hls'|'dash'|'vhs-json'|null)}\n * VHS source type string\n */\n\nexport var simpleTypeFromSourceType = function simpleTypeFromSourceType(type) {\n if (MPEGURL_REGEX.test(type)) {\n return 'hls';\n }\n\n if (DASH_REGEX.test(type)) {\n return 'dash';\n } // Denotes the special case of a manifest object passed to http-streaming instead of a\n // source URL.\n //\n // See https://en.wikipedia.org/wiki/Media_type for details on specifying media types.\n //\n // In this case, vnd stands for vendor, video.js for the organization, VHS for this\n // project, and the +json suffix identifies the structure of the media type.\n\n\n if (type === 'application/vnd.videojs.vhs+json') {\n return 'vhs-json';\n }\n\n return null;\n};","import window from 'global/window'; // const log2 = Math.log2 ? Math.log2 : (x) => (Math.log(x) / Math.log(2));\n\nvar repeat = function repeat(str, len) {\n var acc = '';\n\n while (len--) {\n acc += str;\n }\n\n return acc;\n}; // count the number of bits it would take to represent a number\n// we used to do this with log2 but BigInt does not support builtin math\n// Math.ceil(log2(x));\n\n\nexport var countBits = function countBits(x) {\n return x.toString(2).length;\n}; // count the number of whole bytes it would take to represent a number\n\nexport var countBytes = function countBytes(x) {\n return Math.ceil(countBits(x) / 8);\n};\nexport var padStart = function padStart(b, len, str) {\n if (str === void 0) {\n str = ' ';\n }\n\n return (repeat(str, len) + b.toString()).slice(-len);\n};\nexport var isArrayBufferView = function isArrayBufferView(obj) {\n if (ArrayBuffer.isView === 'function') {\n return ArrayBuffer.isView(obj);\n }\n\n return obj && obj.buffer instanceof ArrayBuffer;\n};\nexport var isTypedArray = function isTypedArray(obj) {\n return isArrayBufferView(obj);\n};\nexport var toUint8 = function toUint8(bytes) {\n if (bytes instanceof Uint8Array) {\n return bytes;\n }\n\n if (!Array.isArray(bytes) && !isTypedArray(bytes) && !(bytes instanceof ArrayBuffer)) {\n // any non-number or NaN leads to empty uint8array\n // eslint-disable-next-line\n if (typeof bytes !== 'number' || typeof bytes === 'number' && bytes !== bytes) {\n bytes = 0;\n } else {\n bytes = [bytes];\n }\n }\n\n return new Uint8Array(bytes && bytes.buffer || bytes, bytes && bytes.byteOffset || 0, bytes && bytes.byteLength || 0);\n};\nexport var toHexString = function toHexString(bytes) {\n bytes = toUint8(bytes);\n var str = '';\n\n for (var i = 0; i < bytes.length; i++) {\n str += padStart(bytes[i].toString(16), 2, '0');\n }\n\n return str;\n};\nexport var toBinaryString = function toBinaryString(bytes) {\n bytes = toUint8(bytes);\n var str = '';\n\n for (var i = 0; i < bytes.length; i++) {\n str += padStart(bytes[i].toString(2), 8, '0');\n }\n\n return str;\n};\nvar BigInt = window.BigInt || Number;\nvar BYTE_TABLE = [BigInt('0x1'), BigInt('0x100'), BigInt('0x10000'), BigInt('0x1000000'), BigInt('0x100000000'), BigInt('0x10000000000'), BigInt('0x1000000000000'), BigInt('0x100000000000000'), BigInt('0x10000000000000000')];\nexport var ENDIANNESS = function () {\n var a = new Uint16Array([0xFFCC]);\n var b = new Uint8Array(a.buffer, a.byteOffset, a.byteLength);\n\n if (b[0] === 0xFF) {\n return 'big';\n }\n\n if (b[0] === 0xCC) {\n return 'little';\n }\n\n return 'unknown';\n}();\nexport var IS_BIG_ENDIAN = ENDIANNESS === 'big';\nexport var IS_LITTLE_ENDIAN = ENDIANNESS === 'little';\nexport var bytesToNumber = function bytesToNumber(bytes, _temp) {\n var _ref = _temp === void 0 ? {} : _temp,\n _ref$signed = _ref.signed,\n signed = _ref$signed === void 0 ? false : _ref$signed,\n _ref$le = _ref.le,\n le = _ref$le === void 0 ? false : _ref$le;\n\n bytes = toUint8(bytes);\n var fn = le ? 'reduce' : 'reduceRight';\n var obj = bytes[fn] ? bytes[fn] : Array.prototype[fn];\n var number = obj.call(bytes, function (total, byte, i) {\n var exponent = le ? i : Math.abs(i + 1 - bytes.length);\n return total + BigInt(byte) * BYTE_TABLE[exponent];\n }, BigInt(0));\n\n if (signed) {\n var max = BYTE_TABLE[bytes.length] / BigInt(2) - BigInt(1);\n number = BigInt(number);\n\n if (number > max) {\n number -= max;\n number -= max;\n number -= BigInt(2);\n }\n }\n\n return Number(number);\n};\nexport var numberToBytes = function numberToBytes(number, _temp2) {\n var _ref2 = _temp2 === void 0 ? {} : _temp2,\n _ref2$le = _ref2.le,\n le = _ref2$le === void 0 ? false : _ref2$le;\n\n // eslint-disable-next-line\n if (typeof number !== 'bigint' && typeof number !== 'number' || typeof number === 'number' && number !== number) {\n number = 0;\n }\n\n number = BigInt(number);\n var byteCount = countBytes(number);\n var bytes = new Uint8Array(new ArrayBuffer(byteCount));\n\n for (var i = 0; i < byteCount; i++) {\n var byteIndex = le ? i : Math.abs(i + 1 - bytes.length);\n bytes[byteIndex] = Number(number / BYTE_TABLE[i] & BigInt(0xFF));\n\n if (number < 0) {\n bytes[byteIndex] = Math.abs(~bytes[byteIndex]);\n bytes[byteIndex] -= i === 0 ? 1 : 2;\n }\n }\n\n return bytes;\n};\nexport var bytesToString = function bytesToString(bytes) {\n if (!bytes) {\n return '';\n } // TODO: should toUint8 handle cases where we only have 8 bytes\n // but report more since this is a Uint16+ Array?\n\n\n bytes = Array.prototype.slice.call(bytes);\n var string = String.fromCharCode.apply(null, toUint8(bytes));\n\n try {\n return decodeURIComponent(escape(string));\n } catch (e) {// if decodeURIComponent/escape fails, we are dealing with partial\n // or full non string data. Just return the potentially garbled string.\n }\n\n return string;\n};\nexport var stringToBytes = function stringToBytes(string, stringIsBytes) {\n if (typeof string !== 'string' && string && typeof string.toString === 'function') {\n string = string.toString();\n }\n\n if (typeof string !== 'string') {\n return new Uint8Array();\n } // If the string already is bytes, we don't have to do this\n // otherwise we do this so that we split multi length characters\n // into individual bytes\n\n\n if (!stringIsBytes) {\n string = unescape(encodeURIComponent(string));\n }\n\n var view = new Uint8Array(string.length);\n\n for (var i = 0; i < string.length; i++) {\n view[i] = string.charCodeAt(i);\n }\n\n return view;\n};\nexport var concatTypedArrays = function concatTypedArrays() {\n for (var _len = arguments.length, buffers = new Array(_len), _key = 0; _key < _len; _key++) {\n buffers[_key] = arguments[_key];\n }\n\n buffers = buffers.filter(function (b) {\n return b && (b.byteLength || b.length) && typeof b !== 'string';\n });\n\n if (buffers.length <= 1) {\n // for 0 length we will return empty uint8\n // for 1 length we return the first uint8\n return toUint8(buffers[0]);\n }\n\n var totalLen = buffers.reduce(function (total, buf, i) {\n return total + (buf.byteLength || buf.length);\n }, 0);\n var tempBuffer = new Uint8Array(totalLen);\n var offset = 0;\n buffers.forEach(function (buf) {\n buf = toUint8(buf);\n tempBuffer.set(buf, offset);\n offset += buf.byteLength;\n });\n return tempBuffer;\n};\n/**\n * Check if the bytes \"b\" are contained within bytes \"a\".\n *\n * @param {Uint8Array|Array} a\n * Bytes to check in\n *\n * @param {Uint8Array|Array} b\n * Bytes to check for\n *\n * @param {Object} options\n * options\n *\n * @param {Array|Uint8Array} [offset=0]\n * offset to use when looking at bytes in a\n *\n * @param {Array|Uint8Array} [mask=[]]\n * mask to use on bytes before comparison.\n *\n * @return {boolean}\n * If all bytes in b are inside of a, taking into account\n * bit masks.\n */\n\nexport var bytesMatch = function bytesMatch(a, b, _temp3) {\n var _ref3 = _temp3 === void 0 ? {} : _temp3,\n _ref3$offset = _ref3.offset,\n offset = _ref3$offset === void 0 ? 0 : _ref3$offset,\n _ref3$mask = _ref3.mask,\n mask = _ref3$mask === void 0 ? [] : _ref3$mask;\n\n a = toUint8(a);\n b = toUint8(b); // ie 11 does not support uint8 every\n\n var fn = b.every ? b.every : Array.prototype.every;\n return b.length && a.length - offset >= b.length && // ie 11 doesn't support every on uin8\n fn.call(b, function (bByte, i) {\n var aByte = mask[i] ? mask[i] & a[offset + i] : a[offset + i];\n return bByte === aByte;\n });\n};\nexport var sliceBytes = function sliceBytes(src, start, end) {\n if (Uint8Array.prototype.slice) {\n return Uint8Array.prototype.slice.call(src, start, end);\n }\n\n return new Uint8Array(Array.prototype.slice.call(src, start, end));\n};\nexport var reverseBytes = function reverseBytes(src) {\n if (src.reverse) {\n return src.reverse();\n }\n\n return Array.prototype.reverse.call(src);\n};","import URLToolkit from 'url-toolkit';\nimport window from 'global/window';\nvar DEFAULT_LOCATION = 'http://example.com';\n\nvar resolveUrl = function resolveUrl(baseUrl, relativeUrl) {\n // return early if we don't need to resolve\n if (/^[a-z]+:/i.test(relativeUrl)) {\n return relativeUrl;\n } // if baseUrl is a data URI, ignore it and resolve everything relative to window.location\n\n\n if (/^data:/.test(baseUrl)) {\n baseUrl = window.location && window.location.href || '';\n } // IE11 supports URL but not the URL constructor\n // feature detect the behavior we want\n\n\n var nativeURL = typeof window.URL === 'function';\n var protocolLess = /^\\/\\//.test(baseUrl); // remove location if window.location isn't available (i.e. we're in node)\n // and if baseUrl isn't an absolute url\n\n var removeLocation = !window.location && !/\\/\\//i.test(baseUrl); // if the base URL is relative then combine with the current location\n\n if (nativeURL) {\n baseUrl = new window.URL(baseUrl, window.location || DEFAULT_LOCATION);\n } else if (!/\\/\\//i.test(baseUrl)) {\n baseUrl = URLToolkit.buildAbsoluteURL(window.location && window.location.href || '', baseUrl);\n }\n\n if (nativeURL) {\n var newUrl = new URL(relativeUrl, baseUrl); // if we're a protocol-less url, remove the protocol\n // and if we're location-less, remove the location\n // otherwise, return the url unmodified\n\n if (removeLocation) {\n return newUrl.href.slice(DEFAULT_LOCATION.length);\n } else if (protocolLess) {\n return newUrl.href.slice(newUrl.protocol.length);\n }\n\n return newUrl.href;\n }\n\n return URLToolkit.buildAbsoluteURL(baseUrl, relativeUrl);\n};\n\nexport default resolveUrl;","/*! @name mpd-parser @version 1.2.2 @license Apache-2.0 */\nimport resolveUrl from '@videojs/vhs-utils/es/resolve-url';\nimport window from 'global/window';\nimport { forEachMediaGroup } from '@videojs/vhs-utils/es/media-groups';\nimport decodeB64ToUint8Array from '@videojs/vhs-utils/es/decode-b64-to-uint8-array';\nimport { DOMParser } from '@xmldom/xmldom';\n\nvar version = \"1.2.2\";\n\nconst isObject = obj => {\n return !!obj && typeof obj === 'object';\n};\n\nconst merge = (...objects) => {\n return objects.reduce((result, source) => {\n if (typeof source !== 'object') {\n return result;\n }\n\n Object.keys(source).forEach(key => {\n if (Array.isArray(result[key]) && Array.isArray(source[key])) {\n result[key] = result[key].concat(source[key]);\n } else if (isObject(result[key]) && isObject(source[key])) {\n result[key] = merge(result[key], source[key]);\n } else {\n result[key] = source[key];\n }\n });\n return result;\n }, {});\n};\nconst values = o => Object.keys(o).map(k => o[k]);\n\nconst range = (start, end) => {\n const result = [];\n\n for (let i = start; i < end; i++) {\n result.push(i);\n }\n\n return result;\n};\nconst flatten = lists => lists.reduce((x, y) => x.concat(y), []);\nconst from = list => {\n if (!list.length) {\n return [];\n }\n\n const result = [];\n\n for (let i = 0; i < list.length; i++) {\n result.push(list[i]);\n }\n\n return result;\n};\nconst findIndexes = (l, key) => l.reduce((a, e, i) => {\n if (e[key]) {\n a.push(i);\n }\n\n return a;\n}, []);\n/**\n * Returns a union of the included lists provided each element can be identified by a key.\n *\n * @param {Array} list - list of lists to get the union of\n * @param {Function} keyFunction - the function to use as a key for each element\n *\n * @return {Array} the union of the arrays\n */\n\nconst union = (lists, keyFunction) => {\n return values(lists.reduce((acc, list) => {\n list.forEach(el => {\n acc[keyFunction(el)] = el;\n });\n return acc;\n }, {}));\n};\n\nvar errors = {\n INVALID_NUMBER_OF_PERIOD: 'INVALID_NUMBER_OF_PERIOD',\n INVALID_NUMBER_OF_CONTENT_STEERING: 'INVALID_NUMBER_OF_CONTENT_STEERING',\n DASH_EMPTY_MANIFEST: 'DASH_EMPTY_MANIFEST',\n DASH_INVALID_XML: 'DASH_INVALID_XML',\n NO_BASE_URL: 'NO_BASE_URL',\n MISSING_SEGMENT_INFORMATION: 'MISSING_SEGMENT_INFORMATION',\n SEGMENT_TIME_UNSPECIFIED: 'SEGMENT_TIME_UNSPECIFIED',\n UNSUPPORTED_UTC_TIMING_SCHEME: 'UNSUPPORTED_UTC_TIMING_SCHEME'\n};\n\n/**\n * @typedef {Object} SingleUri\n * @property {string} uri - relative location of segment\n * @property {string} resolvedUri - resolved location of segment\n * @property {Object} byterange - Object containing information on how to make byte range\n * requests following byte-range-spec per RFC2616.\n * @property {String} byterange.length - length of range request\n * @property {String} byterange.offset - byte offset of range request\n *\n * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1\n */\n\n/**\n * Converts a URLType node (5.3.9.2.3 Table 13) to a segment object\n * that conforms to how m3u8-parser is structured\n *\n * @see https://github.com/videojs/m3u8-parser\n *\n * @param {string} baseUrl - baseUrl provided by nodes\n * @param {string} source - source url for segment\n * @param {string} range - optional range used for range calls,\n * follows RFC 2616, Clause 14.35.1\n * @return {SingleUri} full segment information transformed into a format similar\n * to m3u8-parser\n */\n\nconst urlTypeToSegment = ({\n baseUrl = '',\n source = '',\n range = '',\n indexRange = ''\n}) => {\n const segment = {\n uri: source,\n resolvedUri: resolveUrl(baseUrl || '', source)\n };\n\n if (range || indexRange) {\n const rangeStr = range ? range : indexRange;\n const ranges = rangeStr.split('-'); // default to parsing this as a BigInt if possible\n\n let startRange = window.BigInt ? window.BigInt(ranges[0]) : parseInt(ranges[0], 10);\n let endRange = window.BigInt ? window.BigInt(ranges[1]) : parseInt(ranges[1], 10); // convert back to a number if less than MAX_SAFE_INTEGER\n\n if (startRange < Number.MAX_SAFE_INTEGER && typeof startRange === 'bigint') {\n startRange = Number(startRange);\n }\n\n if (endRange < Number.MAX_SAFE_INTEGER && typeof endRange === 'bigint') {\n endRange = Number(endRange);\n }\n\n let length;\n\n if (typeof endRange === 'bigint' || typeof startRange === 'bigint') {\n length = window.BigInt(endRange) - window.BigInt(startRange) + window.BigInt(1);\n } else {\n length = endRange - startRange + 1;\n }\n\n if (typeof length === 'bigint' && length < Number.MAX_SAFE_INTEGER) {\n length = Number(length);\n } // byterange should be inclusive according to\n // RFC 2616, Clause 14.35.1\n\n\n segment.byterange = {\n length,\n offset: startRange\n };\n }\n\n return segment;\n};\nconst byteRangeToString = byterange => {\n // `endRange` is one less than `offset + length` because the HTTP range\n // header uses inclusive ranges\n let endRange;\n\n if (typeof byterange.offset === 'bigint' || typeof byterange.length === 'bigint') {\n endRange = window.BigInt(byterange.offset) + window.BigInt(byterange.length) - window.BigInt(1);\n } else {\n endRange = byterange.offset + byterange.length - 1;\n }\n\n return `${byterange.offset}-${endRange}`;\n};\n\n/**\n * parse the end number attribue that can be a string\n * number, or undefined.\n *\n * @param {string|number|undefined} endNumber\n * The end number attribute.\n *\n * @return {number|null}\n * The result of parsing the end number.\n */\n\nconst parseEndNumber = endNumber => {\n if (endNumber && typeof endNumber !== 'number') {\n endNumber = parseInt(endNumber, 10);\n }\n\n if (isNaN(endNumber)) {\n return null;\n }\n\n return endNumber;\n};\n/**\n * Functions for calculating the range of available segments in static and dynamic\n * manifests.\n */\n\n\nconst segmentRange = {\n /**\n * Returns the entire range of available segments for a static MPD\n *\n * @param {Object} attributes\n * Inheritied MPD attributes\n * @return {{ start: number, end: number }}\n * The start and end numbers for available segments\n */\n static(attributes) {\n const {\n duration,\n timescale = 1,\n sourceDuration,\n periodDuration\n } = attributes;\n const endNumber = parseEndNumber(attributes.endNumber);\n const segmentDuration = duration / timescale;\n\n if (typeof endNumber === 'number') {\n return {\n start: 0,\n end: endNumber\n };\n }\n\n if (typeof periodDuration === 'number') {\n return {\n start: 0,\n end: periodDuration / segmentDuration\n };\n }\n\n return {\n start: 0,\n end: sourceDuration / segmentDuration\n };\n },\n\n /**\n * Returns the current live window range of available segments for a dynamic MPD\n *\n * @param {Object} attributes\n * Inheritied MPD attributes\n * @return {{ start: number, end: number }}\n * The start and end numbers for available segments\n */\n dynamic(attributes) {\n const {\n NOW,\n clientOffset,\n availabilityStartTime,\n timescale = 1,\n duration,\n periodStart = 0,\n minimumUpdatePeriod = 0,\n timeShiftBufferDepth = Infinity\n } = attributes;\n const endNumber = parseEndNumber(attributes.endNumber); // clientOffset is passed in at the top level of mpd-parser and is an offset calculated\n // after retrieving UTC server time.\n\n const now = (NOW + clientOffset) / 1000; // WC stands for Wall Clock.\n // Convert the period start time to EPOCH.\n\n const periodStartWC = availabilityStartTime + periodStart; // Period end in EPOCH is manifest's retrieval time + time until next update.\n\n const periodEndWC = now + minimumUpdatePeriod;\n const periodDuration = periodEndWC - periodStartWC;\n const segmentCount = Math.ceil(periodDuration * timescale / duration);\n const availableStart = Math.floor((now - periodStartWC - timeShiftBufferDepth) * timescale / duration);\n const availableEnd = Math.floor((now - periodStartWC) * timescale / duration);\n return {\n start: Math.max(0, availableStart),\n end: typeof endNumber === 'number' ? endNumber : Math.min(segmentCount, availableEnd)\n };\n }\n\n};\n/**\n * Maps a range of numbers to objects with information needed to build the corresponding\n * segment list\n *\n * @name toSegmentsCallback\n * @function\n * @param {number} number\n * Number of the segment\n * @param {number} index\n * Index of the number in the range list\n * @return {{ number: Number, duration: Number, timeline: Number, time: Number }}\n * Object with segment timing and duration info\n */\n\n/**\n * Returns a callback for Array.prototype.map for mapping a range of numbers to\n * information needed to build the segment list.\n *\n * @param {Object} attributes\n * Inherited MPD attributes\n * @return {toSegmentsCallback}\n * Callback map function\n */\n\nconst toSegments = attributes => number => {\n const {\n duration,\n timescale = 1,\n periodStart,\n startNumber = 1\n } = attributes;\n return {\n number: startNumber + number,\n duration: duration / timescale,\n timeline: periodStart,\n time: number * duration\n };\n};\n/**\n * Returns a list of objects containing segment timing and duration info used for\n * building the list of segments. This uses the @duration attribute specified\n * in the MPD manifest to derive the range of segments.\n *\n * @param {Object} attributes\n * Inherited MPD attributes\n * @return {{number: number, duration: number, time: number, timeline: number}[]}\n * List of Objects with segment timing and duration info\n */\n\nconst parseByDuration = attributes => {\n const {\n type,\n duration,\n timescale = 1,\n periodDuration,\n sourceDuration\n } = attributes;\n const {\n start,\n end\n } = segmentRange[type](attributes);\n const segments = range(start, end).map(toSegments(attributes));\n\n if (type === 'static') {\n const index = segments.length - 1; // section is either a period or the full source\n\n const sectionDuration = typeof periodDuration === 'number' ? periodDuration : sourceDuration; // final segment may be less than full segment duration\n\n segments[index].duration = sectionDuration - duration / timescale * index;\n }\n\n return segments;\n};\n\n/**\n * Translates SegmentBase into a set of segments.\n * (DASH SPEC Section 5.3.9.3.2) contains a set of nodes. Each\n * node should be translated into segment.\n *\n * @param {Object} attributes\n * Object containing all inherited attributes from parent elements with attribute\n * names as keys\n * @return {Object.} list of segments\n */\n\nconst segmentsFromBase = attributes => {\n const {\n baseUrl,\n initialization = {},\n sourceDuration,\n indexRange = '',\n periodStart,\n presentationTime,\n number = 0,\n duration\n } = attributes; // base url is required for SegmentBase to work, per spec (Section 5.3.9.2.1)\n\n if (!baseUrl) {\n throw new Error(errors.NO_BASE_URL);\n }\n\n const initSegment = urlTypeToSegment({\n baseUrl,\n source: initialization.sourceURL,\n range: initialization.range\n });\n const segment = urlTypeToSegment({\n baseUrl,\n source: baseUrl,\n indexRange\n });\n segment.map = initSegment; // If there is a duration, use it, otherwise use the given duration of the source\n // (since SegmentBase is only for one total segment)\n\n if (duration) {\n const segmentTimeInfo = parseByDuration(attributes);\n\n if (segmentTimeInfo.length) {\n segment.duration = segmentTimeInfo[0].duration;\n segment.timeline = segmentTimeInfo[0].timeline;\n }\n } else if (sourceDuration) {\n segment.duration = sourceDuration;\n segment.timeline = periodStart;\n } // If presentation time is provided, these segments are being generated by SIDX\n // references, and should use the time provided. For the general case of SegmentBase,\n // there should only be one segment in the period, so its presentation time is the same\n // as its period start.\n\n\n segment.presentationTime = presentationTime || periodStart;\n segment.number = number;\n return [segment];\n};\n/**\n * Given a playlist, a sidx box, and a baseUrl, update the segment list of the playlist\n * according to the sidx information given.\n *\n * playlist.sidx has metadadata about the sidx where-as the sidx param\n * is the parsed sidx box itself.\n *\n * @param {Object} playlist the playlist to update the sidx information for\n * @param {Object} sidx the parsed sidx box\n * @return {Object} the playlist object with the updated sidx information\n */\n\nconst addSidxSegmentsToPlaylist$1 = (playlist, sidx, baseUrl) => {\n // Retain init segment information\n const initSegment = playlist.sidx.map ? playlist.sidx.map : null; // Retain source duration from initial main manifest parsing\n\n const sourceDuration = playlist.sidx.duration; // Retain source timeline\n\n const timeline = playlist.timeline || 0;\n const sidxByteRange = playlist.sidx.byterange;\n const sidxEnd = sidxByteRange.offset + sidxByteRange.length; // Retain timescale of the parsed sidx\n\n const timescale = sidx.timescale; // referenceType 1 refers to other sidx boxes\n\n const mediaReferences = sidx.references.filter(r => r.referenceType !== 1);\n const segments = [];\n const type = playlist.endList ? 'static' : 'dynamic';\n const periodStart = playlist.sidx.timeline;\n let presentationTime = periodStart;\n let number = playlist.mediaSequence || 0; // firstOffset is the offset from the end of the sidx box\n\n let startIndex; // eslint-disable-next-line\n\n if (typeof sidx.firstOffset === 'bigint') {\n startIndex = window.BigInt(sidxEnd) + sidx.firstOffset;\n } else {\n startIndex = sidxEnd + sidx.firstOffset;\n }\n\n for (let i = 0; i < mediaReferences.length; i++) {\n const reference = sidx.references[i]; // size of the referenced (sub)segment\n\n const size = reference.referencedSize; // duration of the referenced (sub)segment, in the timescale\n // this will be converted to seconds when generating segments\n\n const duration = reference.subsegmentDuration; // should be an inclusive range\n\n let endIndex; // eslint-disable-next-line\n\n if (typeof startIndex === 'bigint') {\n endIndex = startIndex + window.BigInt(size) - window.BigInt(1);\n } else {\n endIndex = startIndex + size - 1;\n }\n\n const indexRange = `${startIndex}-${endIndex}`;\n const attributes = {\n baseUrl,\n timescale,\n timeline,\n periodStart,\n presentationTime,\n number,\n duration,\n sourceDuration,\n indexRange,\n type\n };\n const segment = segmentsFromBase(attributes)[0];\n\n if (initSegment) {\n segment.map = initSegment;\n }\n\n segments.push(segment);\n\n if (typeof startIndex === 'bigint') {\n startIndex += window.BigInt(size);\n } else {\n startIndex += size;\n }\n\n presentationTime += duration / timescale;\n number++;\n }\n\n playlist.segments = segments;\n return playlist;\n};\n\nconst SUPPORTED_MEDIA_TYPES = ['AUDIO', 'SUBTITLES']; // allow one 60fps frame as leniency (arbitrarily chosen)\n\nconst TIME_FUDGE = 1 / 60;\n/**\n * Given a list of timelineStarts, combines, dedupes, and sorts them.\n *\n * @param {TimelineStart[]} timelineStarts - list of timeline starts\n *\n * @return {TimelineStart[]} the combined and deduped timeline starts\n */\n\nconst getUniqueTimelineStarts = timelineStarts => {\n return union(timelineStarts, ({\n timeline\n }) => timeline).sort((a, b) => a.timeline > b.timeline ? 1 : -1);\n};\n/**\n * Finds the playlist with the matching NAME attribute.\n *\n * @param {Array} playlists - playlists to search through\n * @param {string} name - the NAME attribute to search for\n *\n * @return {Object|null} the matching playlist object, or null\n */\n\nconst findPlaylistWithName = (playlists, name) => {\n for (let i = 0; i < playlists.length; i++) {\n if (playlists[i].attributes.NAME === name) {\n return playlists[i];\n }\n }\n\n return null;\n};\n/**\n * Gets a flattened array of media group playlists.\n *\n * @param {Object} manifest - the main manifest object\n *\n * @return {Array} the media group playlists\n */\n\nconst getMediaGroupPlaylists = manifest => {\n let mediaGroupPlaylists = [];\n forEachMediaGroup(manifest, SUPPORTED_MEDIA_TYPES, (properties, type, group, label) => {\n mediaGroupPlaylists = mediaGroupPlaylists.concat(properties.playlists || []);\n });\n return mediaGroupPlaylists;\n};\n/**\n * Updates the playlist's media sequence numbers.\n *\n * @param {Object} config - options object\n * @param {Object} config.playlist - the playlist to update\n * @param {number} config.mediaSequence - the mediaSequence number to start with\n */\n\nconst updateMediaSequenceForPlaylist = ({\n playlist,\n mediaSequence\n}) => {\n playlist.mediaSequence = mediaSequence;\n playlist.segments.forEach((segment, index) => {\n segment.number = playlist.mediaSequence + index;\n });\n};\n/**\n * Updates the media and discontinuity sequence numbers of newPlaylists given oldPlaylists\n * and a complete list of timeline starts.\n *\n * If no matching playlist is found, only the discontinuity sequence number of the playlist\n * will be updated.\n *\n * Since early available timelines are not supported, at least one segment must be present.\n *\n * @param {Object} config - options object\n * @param {Object[]} oldPlaylists - the old playlists to use as a reference\n * @param {Object[]} newPlaylists - the new playlists to update\n * @param {Object} timelineStarts - all timelineStarts seen in the stream to this point\n */\n\nconst updateSequenceNumbers = ({\n oldPlaylists,\n newPlaylists,\n timelineStarts\n}) => {\n newPlaylists.forEach(playlist => {\n playlist.discontinuitySequence = timelineStarts.findIndex(function ({\n timeline\n }) {\n return timeline === playlist.timeline;\n }); // Playlists NAMEs come from DASH Representation IDs, which are mandatory\n // (see ISO_23009-1-2012 5.3.5.2).\n //\n // If the same Representation existed in a prior Period, it will retain the same NAME.\n\n const oldPlaylist = findPlaylistWithName(oldPlaylists, playlist.attributes.NAME);\n\n if (!oldPlaylist) {\n // Since this is a new playlist, the media sequence values can start from 0 without\n // consequence.\n return;\n } // TODO better support for live SIDX\n //\n // As of this writing, mpd-parser does not support multiperiod SIDX (in live or VOD).\n // This is evident by a playlist only having a single SIDX reference. In a multiperiod\n // playlist there would need to be multiple SIDX references. In addition, live SIDX is\n // not supported when the SIDX properties change on refreshes.\n //\n // In the future, if support needs to be added, the merging logic here can be called\n // after SIDX references are resolved. For now, exit early to prevent exceptions being\n // thrown due to undefined references.\n\n\n if (playlist.sidx) {\n return;\n } // Since we don't yet support early available timelines, we don't need to support\n // playlists with no segments.\n\n\n const firstNewSegment = playlist.segments[0];\n const oldMatchingSegmentIndex = oldPlaylist.segments.findIndex(function (oldSegment) {\n return Math.abs(oldSegment.presentationTime - firstNewSegment.presentationTime) < TIME_FUDGE;\n }); // No matching segment from the old playlist means the entire playlist was refreshed.\n // In this case the media sequence should account for this update, and the new segments\n // should be marked as discontinuous from the prior content, since the last prior\n // timeline was removed.\n\n if (oldMatchingSegmentIndex === -1) {\n updateMediaSequenceForPlaylist({\n playlist,\n mediaSequence: oldPlaylist.mediaSequence + oldPlaylist.segments.length\n });\n playlist.segments[0].discontinuity = true;\n playlist.discontinuityStarts.unshift(0); // No matching segment does not necessarily mean there's missing content.\n //\n // If the new playlist's timeline is the same as the last seen segment's timeline,\n // then a discontinuity can be added to identify that there's potentially missing\n // content. If there's no missing content, the discontinuity should still be rather\n // harmless. It's possible that if segment durations are accurate enough, that the\n // existence of a gap can be determined using the presentation times and durations,\n // but if the segment timing info is off, it may introduce more problems than simply\n // adding the discontinuity.\n //\n // If the new playlist's timeline is different from the last seen segment's timeline,\n // then a discontinuity can be added to identify that this is the first seen segment\n // of a new timeline. However, the logic at the start of this function that\n // determined the disconinuity sequence by timeline index is now off by one (the\n // discontinuity of the newest timeline hasn't yet fallen off the manifest...since\n // we added it), so the disconinuity sequence must be decremented.\n //\n // A period may also have a duration of zero, so the case of no segments is handled\n // here even though we don't yet support early available periods.\n\n if (!oldPlaylist.segments.length && playlist.timeline > oldPlaylist.timeline || oldPlaylist.segments.length && playlist.timeline > oldPlaylist.segments[oldPlaylist.segments.length - 1].timeline) {\n playlist.discontinuitySequence--;\n }\n\n return;\n } // If the first segment matched with a prior segment on a discontinuity (it's matching\n // on the first segment of a period), then the discontinuitySequence shouldn't be the\n // timeline's matching one, but instead should be the one prior, and the first segment\n // of the new manifest should be marked with a discontinuity.\n //\n // The reason for this special case is that discontinuity sequence shows how many\n // discontinuities have fallen off of the playlist, and discontinuities are marked on\n // the first segment of a new \"timeline.\" Because of this, while DASH will retain that\n // Period while the \"timeline\" exists, HLS keeps track of it via the discontinuity\n // sequence, and that first segment is an indicator, but can be removed before that\n // timeline is gone.\n\n\n const oldMatchingSegment = oldPlaylist.segments[oldMatchingSegmentIndex];\n\n if (oldMatchingSegment.discontinuity && !firstNewSegment.discontinuity) {\n firstNewSegment.discontinuity = true;\n playlist.discontinuityStarts.unshift(0);\n playlist.discontinuitySequence--;\n }\n\n updateMediaSequenceForPlaylist({\n playlist,\n mediaSequence: oldPlaylist.segments[oldMatchingSegmentIndex].number\n });\n });\n};\n/**\n * Given an old parsed manifest object and a new parsed manifest object, updates the\n * sequence and timing values within the new manifest to ensure that it lines up with the\n * old.\n *\n * @param {Array} oldManifest - the old main manifest object\n * @param {Array} newManifest - the new main manifest object\n *\n * @return {Object} the updated new manifest object\n */\n\nconst positionManifestOnTimeline = ({\n oldManifest,\n newManifest\n}) => {\n // Starting from v4.1.2 of the IOP, section 4.4.3.3 states:\n //\n // \"MPD@availabilityStartTime and Period@start shall not be changed over MPD updates.\"\n //\n // This was added from https://github.com/Dash-Industry-Forum/DASH-IF-IOP/issues/160\n //\n // Because of this change, and the difficulty of supporting periods with changing start\n // times, periods with changing start times are not supported. This makes the logic much\n // simpler, since periods with the same start time can be considerred the same period\n // across refreshes.\n //\n // To give an example as to the difficulty of handling periods where the start time may\n // change, if a single period manifest is refreshed with another manifest with a single\n // period, and both the start and end times are increased, then the only way to determine\n // if it's a new period or an old one that has changed is to look through the segments of\n // each playlist and determine the presentation time bounds to find a match. In addition,\n // if the period start changed to exceed the old period end, then there would be no\n // match, and it would not be possible to determine whether the refreshed period is a new\n // one or the old one.\n const oldPlaylists = oldManifest.playlists.concat(getMediaGroupPlaylists(oldManifest));\n const newPlaylists = newManifest.playlists.concat(getMediaGroupPlaylists(newManifest)); // Save all seen timelineStarts to the new manifest. Although this potentially means that\n // there's a \"memory leak\" in that it will never stop growing, in reality, only a couple\n // of properties are saved for each seen Period. Even long running live streams won't\n // generate too many Periods, unless the stream is watched for decades. In the future,\n // this can be optimized by mapping to discontinuity sequence numbers for each timeline,\n // but it may not become an issue, and the additional info can be useful for debugging.\n\n newManifest.timelineStarts = getUniqueTimelineStarts([oldManifest.timelineStarts, newManifest.timelineStarts]);\n updateSequenceNumbers({\n oldPlaylists,\n newPlaylists,\n timelineStarts: newManifest.timelineStarts\n });\n return newManifest;\n};\n\nconst generateSidxKey = sidx => sidx && sidx.uri + '-' + byteRangeToString(sidx.byterange);\n\nconst mergeDiscontiguousPlaylists = playlists => {\n // Break out playlists into groups based on their baseUrl\n const playlistsByBaseUrl = playlists.reduce(function (acc, cur) {\n if (!acc[cur.attributes.baseUrl]) {\n acc[cur.attributes.baseUrl] = [];\n }\n\n acc[cur.attributes.baseUrl].push(cur);\n return acc;\n }, {});\n let allPlaylists = [];\n Object.values(playlistsByBaseUrl).forEach(playlistGroup => {\n const mergedPlaylists = values(playlistGroup.reduce((acc, playlist) => {\n // assuming playlist IDs are the same across periods\n // TODO: handle multiperiod where representation sets are not the same\n // across periods\n const name = playlist.attributes.id + (playlist.attributes.lang || '');\n\n if (!acc[name]) {\n // First Period\n acc[name] = playlist;\n acc[name].attributes.timelineStarts = [];\n } else {\n // Subsequent Periods\n if (playlist.segments) {\n // first segment of subsequent periods signal a discontinuity\n if (playlist.segments[0]) {\n playlist.segments[0].discontinuity = true;\n }\n\n acc[name].segments.push(...playlist.segments);\n } // bubble up contentProtection, this assumes all DRM content\n // has the same contentProtection\n\n\n if (playlist.attributes.contentProtection) {\n acc[name].attributes.contentProtection = playlist.attributes.contentProtection;\n }\n }\n\n acc[name].attributes.timelineStarts.push({\n // Although they represent the same number, it's important to have both to make it\n // compatible with HLS potentially having a similar attribute.\n start: playlist.attributes.periodStart,\n timeline: playlist.attributes.periodStart\n });\n return acc;\n }, {}));\n allPlaylists = allPlaylists.concat(mergedPlaylists);\n });\n return allPlaylists.map(playlist => {\n playlist.discontinuityStarts = findIndexes(playlist.segments || [], 'discontinuity');\n return playlist;\n });\n};\n\nconst addSidxSegmentsToPlaylist = (playlist, sidxMapping) => {\n const sidxKey = generateSidxKey(playlist.sidx);\n const sidxMatch = sidxKey && sidxMapping[sidxKey] && sidxMapping[sidxKey].sidx;\n\n if (sidxMatch) {\n addSidxSegmentsToPlaylist$1(playlist, sidxMatch, playlist.sidx.resolvedUri);\n }\n\n return playlist;\n};\nconst addSidxSegmentsToPlaylists = (playlists, sidxMapping = {}) => {\n if (!Object.keys(sidxMapping).length) {\n return playlists;\n }\n\n for (const i in playlists) {\n playlists[i] = addSidxSegmentsToPlaylist(playlists[i], sidxMapping);\n }\n\n return playlists;\n};\nconst formatAudioPlaylist = ({\n attributes,\n segments,\n sidx,\n mediaSequence,\n discontinuitySequence,\n discontinuityStarts\n}, isAudioOnly) => {\n const playlist = {\n attributes: {\n NAME: attributes.id,\n BANDWIDTH: attributes.bandwidth,\n CODECS: attributes.codecs,\n ['PROGRAM-ID']: 1\n },\n uri: '',\n endList: attributes.type === 'static',\n timeline: attributes.periodStart,\n resolvedUri: attributes.baseUrl || '',\n targetDuration: attributes.duration,\n discontinuitySequence,\n discontinuityStarts,\n timelineStarts: attributes.timelineStarts,\n mediaSequence,\n segments\n };\n\n if (attributes.contentProtection) {\n playlist.contentProtection = attributes.contentProtection;\n }\n\n if (attributes.serviceLocation) {\n playlist.attributes.serviceLocation = attributes.serviceLocation;\n }\n\n if (sidx) {\n playlist.sidx = sidx;\n }\n\n if (isAudioOnly) {\n playlist.attributes.AUDIO = 'audio';\n playlist.attributes.SUBTITLES = 'subs';\n }\n\n return playlist;\n};\nconst formatVttPlaylist = ({\n attributes,\n segments,\n mediaSequence,\n discontinuityStarts,\n discontinuitySequence\n}) => {\n if (typeof segments === 'undefined') {\n // vtt tracks may use single file in BaseURL\n segments = [{\n uri: attributes.baseUrl,\n timeline: attributes.periodStart,\n resolvedUri: attributes.baseUrl || '',\n duration: attributes.sourceDuration,\n number: 0\n }]; // targetDuration should be the same duration as the only segment\n\n attributes.duration = attributes.sourceDuration;\n }\n\n const m3u8Attributes = {\n NAME: attributes.id,\n BANDWIDTH: attributes.bandwidth,\n ['PROGRAM-ID']: 1\n };\n\n if (attributes.codecs) {\n m3u8Attributes.CODECS = attributes.codecs;\n }\n\n const vttPlaylist = {\n attributes: m3u8Attributes,\n uri: '',\n endList: attributes.type === 'static',\n timeline: attributes.periodStart,\n resolvedUri: attributes.baseUrl || '',\n targetDuration: attributes.duration,\n timelineStarts: attributes.timelineStarts,\n discontinuityStarts,\n discontinuitySequence,\n mediaSequence,\n segments\n };\n\n if (attributes.serviceLocation) {\n vttPlaylist.attributes.serviceLocation = attributes.serviceLocation;\n }\n\n return vttPlaylist;\n};\nconst organizeAudioPlaylists = (playlists, sidxMapping = {}, isAudioOnly = false) => {\n let mainPlaylist;\n const formattedPlaylists = playlists.reduce((a, playlist) => {\n const role = playlist.attributes.role && playlist.attributes.role.value || '';\n const language = playlist.attributes.lang || '';\n let label = playlist.attributes.label || 'main';\n\n if (language && !playlist.attributes.label) {\n const roleLabel = role ? ` (${role})` : '';\n label = `${playlist.attributes.lang}${roleLabel}`;\n }\n\n if (!a[label]) {\n a[label] = {\n language,\n autoselect: true,\n default: role === 'main',\n playlists: [],\n uri: ''\n };\n }\n\n const formatted = addSidxSegmentsToPlaylist(formatAudioPlaylist(playlist, isAudioOnly), sidxMapping);\n a[label].playlists.push(formatted);\n\n if (typeof mainPlaylist === 'undefined' && role === 'main') {\n mainPlaylist = playlist;\n mainPlaylist.default = true;\n }\n\n return a;\n }, {}); // if no playlists have role \"main\", mark the first as main\n\n if (!mainPlaylist) {\n const firstLabel = Object.keys(formattedPlaylists)[0];\n formattedPlaylists[firstLabel].default = true;\n }\n\n return formattedPlaylists;\n};\nconst organizeVttPlaylists = (playlists, sidxMapping = {}) => {\n return playlists.reduce((a, playlist) => {\n const label = playlist.attributes.label || playlist.attributes.lang || 'text';\n\n if (!a[label]) {\n a[label] = {\n language: label,\n default: false,\n autoselect: false,\n playlists: [],\n uri: ''\n };\n }\n\n a[label].playlists.push(addSidxSegmentsToPlaylist(formatVttPlaylist(playlist), sidxMapping));\n return a;\n }, {});\n};\n\nconst organizeCaptionServices = captionServices => captionServices.reduce((svcObj, svc) => {\n if (!svc) {\n return svcObj;\n }\n\n svc.forEach(service => {\n const {\n channel,\n language\n } = service;\n svcObj[language] = {\n autoselect: false,\n default: false,\n instreamId: channel,\n language\n };\n\n if (service.hasOwnProperty('aspectRatio')) {\n svcObj[language].aspectRatio = service.aspectRatio;\n }\n\n if (service.hasOwnProperty('easyReader')) {\n svcObj[language].easyReader = service.easyReader;\n }\n\n if (service.hasOwnProperty('3D')) {\n svcObj[language]['3D'] = service['3D'];\n }\n });\n return svcObj;\n}, {});\n\nconst formatVideoPlaylist = ({\n attributes,\n segments,\n sidx,\n discontinuityStarts\n}) => {\n const playlist = {\n attributes: {\n NAME: attributes.id,\n AUDIO: 'audio',\n SUBTITLES: 'subs',\n RESOLUTION: {\n width: attributes.width,\n height: attributes.height\n },\n CODECS: attributes.codecs,\n BANDWIDTH: attributes.bandwidth,\n ['PROGRAM-ID']: 1\n },\n uri: '',\n endList: attributes.type === 'static',\n timeline: attributes.periodStart,\n resolvedUri: attributes.baseUrl || '',\n targetDuration: attributes.duration,\n discontinuityStarts,\n timelineStarts: attributes.timelineStarts,\n segments\n };\n\n if (attributes.frameRate) {\n playlist.attributes['FRAME-RATE'] = attributes.frameRate;\n }\n\n if (attributes.contentProtection) {\n playlist.contentProtection = attributes.contentProtection;\n }\n\n if (attributes.serviceLocation) {\n playlist.attributes.serviceLocation = attributes.serviceLocation;\n }\n\n if (sidx) {\n playlist.sidx = sidx;\n }\n\n return playlist;\n};\n\nconst videoOnly = ({\n attributes\n}) => attributes.mimeType === 'video/mp4' || attributes.mimeType === 'video/webm' || attributes.contentType === 'video';\n\nconst audioOnly = ({\n attributes\n}) => attributes.mimeType === 'audio/mp4' || attributes.mimeType === 'audio/webm' || attributes.contentType === 'audio';\n\nconst vttOnly = ({\n attributes\n}) => attributes.mimeType === 'text/vtt' || attributes.contentType === 'text';\n/**\n * Contains start and timeline properties denoting a timeline start. For DASH, these will\n * be the same number.\n *\n * @typedef {Object} TimelineStart\n * @property {number} start - the start time of the timeline\n * @property {number} timeline - the timeline number\n */\n\n/**\n * Adds appropriate media and discontinuity sequence values to the segments and playlists.\n *\n * Throughout mpd-parser, the `number` attribute is used in relation to `startNumber`, a\n * DASH specific attribute used in constructing segment URI's from templates. However, from\n * an HLS perspective, the `number` attribute on a segment would be its `mediaSequence`\n * value, which should start at the original media sequence value (or 0) and increment by 1\n * for each segment thereafter. Since DASH's `startNumber` values are independent per\n * period, it doesn't make sense to use it for `number`. Instead, assume everything starts\n * from a 0 mediaSequence value and increment from there.\n *\n * Note that VHS currently doesn't use the `number` property, but it can be helpful for\n * debugging and making sense of the manifest.\n *\n * For live playlists, to account for values increasing in manifests when periods are\n * removed on refreshes, merging logic should be used to update the numbers to their\n * appropriate values (to ensure they're sequential and increasing).\n *\n * @param {Object[]} playlists - the playlists to update\n * @param {TimelineStart[]} timelineStarts - the timeline starts for the manifest\n */\n\n\nconst addMediaSequenceValues = (playlists, timelineStarts) => {\n // increment all segments sequentially\n playlists.forEach(playlist => {\n playlist.mediaSequence = 0;\n playlist.discontinuitySequence = timelineStarts.findIndex(function ({\n timeline\n }) {\n return timeline === playlist.timeline;\n });\n\n if (!playlist.segments) {\n return;\n }\n\n playlist.segments.forEach((segment, index) => {\n segment.number = index;\n });\n });\n};\n/**\n * Given a media group object, flattens all playlists within the media group into a single\n * array.\n *\n * @param {Object} mediaGroupObject - the media group object\n *\n * @return {Object[]}\n * The media group playlists\n */\n\nconst flattenMediaGroupPlaylists = mediaGroupObject => {\n if (!mediaGroupObject) {\n return [];\n }\n\n return Object.keys(mediaGroupObject).reduce((acc, label) => {\n const labelContents = mediaGroupObject[label];\n return acc.concat(labelContents.playlists);\n }, []);\n};\nconst toM3u8 = ({\n dashPlaylists,\n locations,\n contentSteering,\n sidxMapping = {},\n previousManifest,\n eventStream\n}) => {\n if (!dashPlaylists.length) {\n return {};\n } // grab all main manifest attributes\n\n\n const {\n sourceDuration: duration,\n type,\n suggestedPresentationDelay,\n minimumUpdatePeriod\n } = dashPlaylists[0].attributes;\n const videoPlaylists = mergeDiscontiguousPlaylists(dashPlaylists.filter(videoOnly)).map(formatVideoPlaylist);\n const audioPlaylists = mergeDiscontiguousPlaylists(dashPlaylists.filter(audioOnly));\n const vttPlaylists = mergeDiscontiguousPlaylists(dashPlaylists.filter(vttOnly));\n const captions = dashPlaylists.map(playlist => playlist.attributes.captionServices).filter(Boolean);\n const manifest = {\n allowCache: true,\n discontinuityStarts: [],\n segments: [],\n endList: true,\n mediaGroups: {\n AUDIO: {},\n VIDEO: {},\n ['CLOSED-CAPTIONS']: {},\n SUBTITLES: {}\n },\n uri: '',\n duration,\n playlists: addSidxSegmentsToPlaylists(videoPlaylists, sidxMapping)\n };\n\n if (minimumUpdatePeriod >= 0) {\n manifest.minimumUpdatePeriod = minimumUpdatePeriod * 1000;\n }\n\n if (locations) {\n manifest.locations = locations;\n }\n\n if (contentSteering) {\n manifest.contentSteering = contentSteering;\n }\n\n if (type === 'dynamic') {\n manifest.suggestedPresentationDelay = suggestedPresentationDelay;\n }\n\n if (eventStream && eventStream.length > 0) {\n manifest.eventStream = eventStream;\n }\n\n const isAudioOnly = manifest.playlists.length === 0;\n const organizedAudioGroup = audioPlaylists.length ? organizeAudioPlaylists(audioPlaylists, sidxMapping, isAudioOnly) : null;\n const organizedVttGroup = vttPlaylists.length ? organizeVttPlaylists(vttPlaylists, sidxMapping) : null;\n const formattedPlaylists = videoPlaylists.concat(flattenMediaGroupPlaylists(organizedAudioGroup), flattenMediaGroupPlaylists(organizedVttGroup));\n const playlistTimelineStarts = formattedPlaylists.map(({\n timelineStarts\n }) => timelineStarts);\n manifest.timelineStarts = getUniqueTimelineStarts(playlistTimelineStarts);\n addMediaSequenceValues(formattedPlaylists, manifest.timelineStarts);\n\n if (organizedAudioGroup) {\n manifest.mediaGroups.AUDIO.audio = organizedAudioGroup;\n }\n\n if (organizedVttGroup) {\n manifest.mediaGroups.SUBTITLES.subs = organizedVttGroup;\n }\n\n if (captions.length) {\n manifest.mediaGroups['CLOSED-CAPTIONS'].cc = organizeCaptionServices(captions);\n }\n\n if (previousManifest) {\n return positionManifestOnTimeline({\n oldManifest: previousManifest,\n newManifest: manifest\n });\n }\n\n return manifest;\n};\n\n/**\n * Calculates the R (repetition) value for a live stream (for the final segment\n * in a manifest where the r value is negative 1)\n *\n * @param {Object} attributes\n * Object containing all inherited attributes from parent elements with attribute\n * names as keys\n * @param {number} time\n * current time (typically the total time up until the final segment)\n * @param {number} duration\n * duration property for the given \n *\n * @return {number}\n * R value to reach the end of the given period\n */\nconst getLiveRValue = (attributes, time, duration) => {\n const {\n NOW,\n clientOffset,\n availabilityStartTime,\n timescale = 1,\n periodStart = 0,\n minimumUpdatePeriod = 0\n } = attributes;\n const now = (NOW + clientOffset) / 1000;\n const periodStartWC = availabilityStartTime + periodStart;\n const periodEndWC = now + minimumUpdatePeriod;\n const periodDuration = periodEndWC - periodStartWC;\n return Math.ceil((periodDuration * timescale - time) / duration);\n};\n/**\n * Uses information provided by SegmentTemplate.SegmentTimeline to determine segment\n * timing and duration\n *\n * @param {Object} attributes\n * Object containing all inherited attributes from parent elements with attribute\n * names as keys\n * @param {Object[]} segmentTimeline\n * List of objects representing the attributes of each S element contained within\n *\n * @return {{number: number, duration: number, time: number, timeline: number}[]}\n * List of Objects with segment timing and duration info\n */\n\n\nconst parseByTimeline = (attributes, segmentTimeline) => {\n const {\n type,\n minimumUpdatePeriod = 0,\n media = '',\n sourceDuration,\n timescale = 1,\n startNumber = 1,\n periodStart: timeline\n } = attributes;\n const segments = [];\n let time = -1;\n\n for (let sIndex = 0; sIndex < segmentTimeline.length; sIndex++) {\n const S = segmentTimeline[sIndex];\n const duration = S.d;\n const repeat = S.r || 0;\n const segmentTime = S.t || 0;\n\n if (time < 0) {\n // first segment\n time = segmentTime;\n }\n\n if (segmentTime && segmentTime > time) {\n // discontinuity\n // TODO: How to handle this type of discontinuity\n // timeline++ here would treat it like HLS discontuity and content would\n // get appended without gap\n // E.G.\n // \n // \n // \n // \n // would have $Time$ values of [0, 1, 2, 5]\n // should this be appened at time positions [0, 1, 2, 3],(#EXT-X-DISCONTINUITY)\n // or [0, 1, 2, gap, gap, 5]? (#EXT-X-GAP)\n // does the value of sourceDuration consider this when calculating arbitrary\n // negative @r repeat value?\n // E.G. Same elements as above with this added at the end\n // \n // with a sourceDuration of 10\n // Would the 2 gaps be included in the time duration calculations resulting in\n // 8 segments with $Time$ values of [0, 1, 2, 5, 6, 7, 8, 9] or 10 segments\n // with $Time$ values of [0, 1, 2, 5, 6, 7, 8, 9, 10, 11] ?\n time = segmentTime;\n }\n\n let count;\n\n if (repeat < 0) {\n const nextS = sIndex + 1;\n\n if (nextS === segmentTimeline.length) {\n // last segment\n if (type === 'dynamic' && minimumUpdatePeriod > 0 && media.indexOf('$Number$') > 0) {\n count = getLiveRValue(attributes, time, duration);\n } else {\n // TODO: This may be incorrect depending on conclusion of TODO above\n count = (sourceDuration * timescale - time) / duration;\n }\n } else {\n count = (segmentTimeline[nextS].t - time) / duration;\n }\n } else {\n count = repeat + 1;\n }\n\n const end = startNumber + segments.length + count;\n let number = startNumber + segments.length;\n\n while (number < end) {\n segments.push({\n number,\n duration: duration / timescale,\n time,\n timeline\n });\n time += duration;\n number++;\n }\n }\n\n return segments;\n};\n\nconst identifierPattern = /\\$([A-z]*)(?:(%0)([0-9]+)d)?\\$/g;\n/**\n * Replaces template identifiers with corresponding values. To be used as the callback\n * for String.prototype.replace\n *\n * @name replaceCallback\n * @function\n * @param {string} match\n * Entire match of identifier\n * @param {string} identifier\n * Name of matched identifier\n * @param {string} format\n * Format tag string. Its presence indicates that padding is expected\n * @param {string} width\n * Desired length of the replaced value. Values less than this width shall be left\n * zero padded\n * @return {string}\n * Replacement for the matched identifier\n */\n\n/**\n * Returns a function to be used as a callback for String.prototype.replace to replace\n * template identifiers\n *\n * @param {Obect} values\n * Object containing values that shall be used to replace known identifiers\n * @param {number} values.RepresentationID\n * Value of the Representation@id attribute\n * @param {number} values.Number\n * Number of the corresponding segment\n * @param {number} values.Bandwidth\n * Value of the Representation@bandwidth attribute.\n * @param {number} values.Time\n * Timestamp value of the corresponding segment\n * @return {replaceCallback}\n * Callback to be used with String.prototype.replace to replace identifiers\n */\n\nconst identifierReplacement = values => (match, identifier, format, width) => {\n if (match === '$$') {\n // escape sequence\n return '$';\n }\n\n if (typeof values[identifier] === 'undefined') {\n return match;\n }\n\n const value = '' + values[identifier];\n\n if (identifier === 'RepresentationID') {\n // Format tag shall not be present with RepresentationID\n return value;\n }\n\n if (!format) {\n width = 1;\n } else {\n width = parseInt(width, 10);\n }\n\n if (value.length >= width) {\n return value;\n }\n\n return `${new Array(width - value.length + 1).join('0')}${value}`;\n};\n/**\n * Constructs a segment url from a template string\n *\n * @param {string} url\n * Template string to construct url from\n * @param {Obect} values\n * Object containing values that shall be used to replace known identifiers\n * @param {number} values.RepresentationID\n * Value of the Representation@id attribute\n * @param {number} values.Number\n * Number of the corresponding segment\n * @param {number} values.Bandwidth\n * Value of the Representation@bandwidth attribute.\n * @param {number} values.Time\n * Timestamp value of the corresponding segment\n * @return {string}\n * Segment url with identifiers replaced\n */\n\nconst constructTemplateUrl = (url, values) => url.replace(identifierPattern, identifierReplacement(values));\n/**\n * Generates a list of objects containing timing and duration information about each\n * segment needed to generate segment uris and the complete segment object\n *\n * @param {Object} attributes\n * Object containing all inherited attributes from parent elements with attribute\n * names as keys\n * @param {Object[]|undefined} segmentTimeline\n * List of objects representing the attributes of each S element contained within\n * the SegmentTimeline element\n * @return {{number: number, duration: number, time: number, timeline: number}[]}\n * List of Objects with segment timing and duration info\n */\n\nconst parseTemplateInfo = (attributes, segmentTimeline) => {\n if (!attributes.duration && !segmentTimeline) {\n // if neither @duration or SegmentTimeline are present, then there shall be exactly\n // one media segment\n return [{\n number: attributes.startNumber || 1,\n duration: attributes.sourceDuration,\n time: 0,\n timeline: attributes.periodStart\n }];\n }\n\n if (attributes.duration) {\n return parseByDuration(attributes);\n }\n\n return parseByTimeline(attributes, segmentTimeline);\n};\n/**\n * Generates a list of segments using information provided by the SegmentTemplate element\n *\n * @param {Object} attributes\n * Object containing all inherited attributes from parent elements with attribute\n * names as keys\n * @param {Object[]|undefined} segmentTimeline\n * List of objects representing the attributes of each S element contained within\n * the SegmentTimeline element\n * @return {Object[]}\n * List of segment objects\n */\n\nconst segmentsFromTemplate = (attributes, segmentTimeline) => {\n const templateValues = {\n RepresentationID: attributes.id,\n Bandwidth: attributes.bandwidth || 0\n };\n const {\n initialization = {\n sourceURL: '',\n range: ''\n }\n } = attributes;\n const mapSegment = urlTypeToSegment({\n baseUrl: attributes.baseUrl,\n source: constructTemplateUrl(initialization.sourceURL, templateValues),\n range: initialization.range\n });\n const segments = parseTemplateInfo(attributes, segmentTimeline);\n return segments.map(segment => {\n templateValues.Number = segment.number;\n templateValues.Time = segment.time;\n const uri = constructTemplateUrl(attributes.media || '', templateValues); // See DASH spec section 5.3.9.2.2\n // - if timescale isn't present on any level, default to 1.\n\n const timescale = attributes.timescale || 1; // - if presentationTimeOffset isn't present on any level, default to 0\n\n const presentationTimeOffset = attributes.presentationTimeOffset || 0;\n const presentationTime = // Even if the @t attribute is not specified for the segment, segment.time is\n // calculated in mpd-parser prior to this, so it's assumed to be available.\n attributes.periodStart + (segment.time - presentationTimeOffset) / timescale;\n const map = {\n uri,\n timeline: segment.timeline,\n duration: segment.duration,\n resolvedUri: resolveUrl(attributes.baseUrl || '', uri),\n map: mapSegment,\n number: segment.number,\n presentationTime\n };\n return map;\n });\n};\n\n/**\n * Converts a (of type URLType from the DASH spec 5.3.9.2 Table 14)\n * to an object that matches the output of a segment in videojs/mpd-parser\n *\n * @param {Object} attributes\n * Object containing all inherited attributes from parent elements with attribute\n * names as keys\n * @param {Object} segmentUrl\n * node to translate into a segment object\n * @return {Object} translated segment object\n */\n\nconst SegmentURLToSegmentObject = (attributes, segmentUrl) => {\n const {\n baseUrl,\n initialization = {}\n } = attributes;\n const initSegment = urlTypeToSegment({\n baseUrl,\n source: initialization.sourceURL,\n range: initialization.range\n });\n const segment = urlTypeToSegment({\n baseUrl,\n source: segmentUrl.media,\n range: segmentUrl.mediaRange\n });\n segment.map = initSegment;\n return segment;\n};\n/**\n * Generates a list of segments using information provided by the SegmentList element\n * SegmentList (DASH SPEC Section 5.3.9.3.2) contains a set of nodes. Each\n * node should be translated into segment.\n *\n * @param {Object} attributes\n * Object containing all inherited attributes from parent elements with attribute\n * names as keys\n * @param {Object[]|undefined} segmentTimeline\n * List of objects representing the attributes of each S element contained within\n * the SegmentTimeline element\n * @return {Object.} list of segments\n */\n\n\nconst segmentsFromList = (attributes, segmentTimeline) => {\n const {\n duration,\n segmentUrls = [],\n periodStart\n } = attributes; // Per spec (5.3.9.2.1) no way to determine segment duration OR\n // if both SegmentTimeline and @duration are defined, it is outside of spec.\n\n if (!duration && !segmentTimeline || duration && segmentTimeline) {\n throw new Error(errors.SEGMENT_TIME_UNSPECIFIED);\n }\n\n const segmentUrlMap = segmentUrls.map(segmentUrlObject => SegmentURLToSegmentObject(attributes, segmentUrlObject));\n let segmentTimeInfo;\n\n if (duration) {\n segmentTimeInfo = parseByDuration(attributes);\n }\n\n if (segmentTimeline) {\n segmentTimeInfo = parseByTimeline(attributes, segmentTimeline);\n }\n\n const segments = segmentTimeInfo.map((segmentTime, index) => {\n if (segmentUrlMap[index]) {\n const segment = segmentUrlMap[index]; // See DASH spec section 5.3.9.2.2\n // - if timescale isn't present on any level, default to 1.\n\n const timescale = attributes.timescale || 1; // - if presentationTimeOffset isn't present on any level, default to 0\n\n const presentationTimeOffset = attributes.presentationTimeOffset || 0;\n segment.timeline = segmentTime.timeline;\n segment.duration = segmentTime.duration;\n segment.number = segmentTime.number;\n segment.presentationTime = periodStart + (segmentTime.time - presentationTimeOffset) / timescale;\n return segment;\n } // Since we're mapping we should get rid of any blank segments (in case\n // the given SegmentTimeline is handling for more elements than we have\n // SegmentURLs for).\n\n }).filter(segment => segment);\n return segments;\n};\n\nconst generateSegments = ({\n attributes,\n segmentInfo\n}) => {\n let segmentAttributes;\n let segmentsFn;\n\n if (segmentInfo.template) {\n segmentsFn = segmentsFromTemplate;\n segmentAttributes = merge(attributes, segmentInfo.template);\n } else if (segmentInfo.base) {\n segmentsFn = segmentsFromBase;\n segmentAttributes = merge(attributes, segmentInfo.base);\n } else if (segmentInfo.list) {\n segmentsFn = segmentsFromList;\n segmentAttributes = merge(attributes, segmentInfo.list);\n }\n\n const segmentsInfo = {\n attributes\n };\n\n if (!segmentsFn) {\n return segmentsInfo;\n }\n\n const segments = segmentsFn(segmentAttributes, segmentInfo.segmentTimeline); // The @duration attribute will be used to determin the playlist's targetDuration which\n // must be in seconds. Since we've generated the segment list, we no longer need\n // @duration to be in @timescale units, so we can convert it here.\n\n if (segmentAttributes.duration) {\n const {\n duration,\n timescale = 1\n } = segmentAttributes;\n segmentAttributes.duration = duration / timescale;\n } else if (segments.length) {\n // if there is no @duration attribute, use the largest segment duration as\n // as target duration\n segmentAttributes.duration = segments.reduce((max, segment) => {\n return Math.max(max, Math.ceil(segment.duration));\n }, 0);\n } else {\n segmentAttributes.duration = 0;\n }\n\n segmentsInfo.attributes = segmentAttributes;\n segmentsInfo.segments = segments; // This is a sidx box without actual segment information\n\n if (segmentInfo.base && segmentAttributes.indexRange) {\n segmentsInfo.sidx = segments[0];\n segmentsInfo.segments = [];\n }\n\n return segmentsInfo;\n};\nconst toPlaylists = representations => representations.map(generateSegments);\n\nconst findChildren = (element, name) => from(element.childNodes).filter(({\n tagName\n}) => tagName === name);\nconst getContent = element => element.textContent.trim();\n\n/**\n * Converts the provided string that may contain a division operation to a number.\n *\n * @param {string} value - the provided string value\n *\n * @return {number} the parsed string value\n */\nconst parseDivisionValue = value => {\n return parseFloat(value.split('/').reduce((prev, current) => prev / current));\n};\n\nconst parseDuration = str => {\n const SECONDS_IN_YEAR = 365 * 24 * 60 * 60;\n const SECONDS_IN_MONTH = 30 * 24 * 60 * 60;\n const SECONDS_IN_DAY = 24 * 60 * 60;\n const SECONDS_IN_HOUR = 60 * 60;\n const SECONDS_IN_MIN = 60; // P10Y10M10DT10H10M10.1S\n\n const durationRegex = /P(?:(\\d*)Y)?(?:(\\d*)M)?(?:(\\d*)D)?(?:T(?:(\\d*)H)?(?:(\\d*)M)?(?:([\\d.]*)S)?)?/;\n const match = durationRegex.exec(str);\n\n if (!match) {\n return 0;\n }\n\n const [year, month, day, hour, minute, second] = match.slice(1);\n return parseFloat(year || 0) * SECONDS_IN_YEAR + parseFloat(month || 0) * SECONDS_IN_MONTH + parseFloat(day || 0) * SECONDS_IN_DAY + parseFloat(hour || 0) * SECONDS_IN_HOUR + parseFloat(minute || 0) * SECONDS_IN_MIN + parseFloat(second || 0);\n};\nconst parseDate = str => {\n // Date format without timezone according to ISO 8601\n // YYY-MM-DDThh:mm:ss.ssssss\n const dateRegex = /^\\d+-\\d+-\\d+T\\d+:\\d+:\\d+(\\.\\d+)?$/; // If the date string does not specifiy a timezone, we must specifiy UTC. This is\n // expressed by ending with 'Z'\n\n if (dateRegex.test(str)) {\n str += 'Z';\n }\n\n return Date.parse(str);\n};\n\nconst parsers = {\n /**\n * Specifies the duration of the entire Media Presentation. Format is a duration string\n * as specified in ISO 8601\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The duration in seconds\n */\n mediaPresentationDuration(value) {\n return parseDuration(value);\n },\n\n /**\n * Specifies the Segment availability start time for all Segments referred to in this\n * MPD. For a dynamic manifest, it specifies the anchor for the earliest availability\n * time. Format is a date string as specified in ISO 8601\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The date as seconds from unix epoch\n */\n availabilityStartTime(value) {\n return parseDate(value) / 1000;\n },\n\n /**\n * Specifies the smallest period between potential changes to the MPD. Format is a\n * duration string as specified in ISO 8601\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The duration in seconds\n */\n minimumUpdatePeriod(value) {\n return parseDuration(value);\n },\n\n /**\n * Specifies the suggested presentation delay. Format is a\n * duration string as specified in ISO 8601\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The duration in seconds\n */\n suggestedPresentationDelay(value) {\n return parseDuration(value);\n },\n\n /**\n * specifices the type of mpd. Can be either \"static\" or \"dynamic\"\n *\n * @param {string} value\n * value of attribute as a string\n *\n * @return {string}\n * The type as a string\n */\n type(value) {\n return value;\n },\n\n /**\n * Specifies the duration of the smallest time shifting buffer for any Representation\n * in the MPD. Format is a duration string as specified in ISO 8601\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The duration in seconds\n */\n timeShiftBufferDepth(value) {\n return parseDuration(value);\n },\n\n /**\n * Specifies the PeriodStart time of the Period relative to the availabilityStarttime.\n * Format is a duration string as specified in ISO 8601\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The duration in seconds\n */\n start(value) {\n return parseDuration(value);\n },\n\n /**\n * Specifies the width of the visual presentation\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The parsed width\n */\n width(value) {\n return parseInt(value, 10);\n },\n\n /**\n * Specifies the height of the visual presentation\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The parsed height\n */\n height(value) {\n return parseInt(value, 10);\n },\n\n /**\n * Specifies the bitrate of the representation\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The parsed bandwidth\n */\n bandwidth(value) {\n return parseInt(value, 10);\n },\n\n /**\n * Specifies the frame rate of the representation\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The parsed frame rate\n */\n frameRate(value) {\n return parseDivisionValue(value);\n },\n\n /**\n * Specifies the number of the first Media Segment in this Representation in the Period\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The parsed number\n */\n startNumber(value) {\n return parseInt(value, 10);\n },\n\n /**\n * Specifies the timescale in units per seconds\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The parsed timescale\n */\n timescale(value) {\n return parseInt(value, 10);\n },\n\n /**\n * Specifies the presentationTimeOffset.\n *\n * @param {string} value\n * value of the attribute as a string\n *\n * @return {number}\n * The parsed presentationTimeOffset\n */\n presentationTimeOffset(value) {\n return parseInt(value, 10);\n },\n\n /**\n * Specifies the constant approximate Segment duration\n * NOTE: The element also contains an @duration attribute. This duration\n * specifies the duration of the Period. This attribute is currently not\n * supported by the rest of the parser, however we still check for it to prevent\n * errors.\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The parsed duration\n */\n duration(value) {\n const parsedValue = parseInt(value, 10);\n\n if (isNaN(parsedValue)) {\n return parseDuration(value);\n }\n\n return parsedValue;\n },\n\n /**\n * Specifies the Segment duration, in units of the value of the @timescale.\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The parsed duration\n */\n d(value) {\n return parseInt(value, 10);\n },\n\n /**\n * Specifies the MPD start time, in @timescale units, the first Segment in the series\n * starts relative to the beginning of the Period\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The parsed time\n */\n t(value) {\n return parseInt(value, 10);\n },\n\n /**\n * Specifies the repeat count of the number of following contiguous Segments with the\n * same duration expressed by the value of @d\n *\n * @param {string} value\n * value of attribute as a string\n * @return {number}\n * The parsed number\n */\n r(value) {\n return parseInt(value, 10);\n },\n\n /**\n * Specifies the presentationTime.\n *\n * @param {string} value\n * value of the attribute as a string\n *\n * @return {number}\n * The parsed presentationTime\n */\n presentationTime(value) {\n return parseInt(value, 10);\n },\n\n /**\n * Default parser for all other attributes. Acts as a no-op and just returns the value\n * as a string\n *\n * @param {string} value\n * value of attribute as a string\n * @return {string}\n * Unparsed value\n */\n DEFAULT(value) {\n return value;\n }\n\n};\n/**\n * Gets all the attributes and values of the provided node, parses attributes with known\n * types, and returns an object with attribute names mapped to values.\n *\n * @param {Node} el\n * The node to parse attributes from\n * @return {Object}\n * Object with all attributes of el parsed\n */\n\nconst parseAttributes = el => {\n if (!(el && el.attributes)) {\n return {};\n }\n\n return from(el.attributes).reduce((a, e) => {\n const parseFn = parsers[e.name] || parsers.DEFAULT;\n a[e.name] = parseFn(e.value);\n return a;\n }, {});\n};\n\nconst keySystemsMap = {\n 'urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b': 'org.w3.clearkey',\n 'urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed': 'com.widevine.alpha',\n 'urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95': 'com.microsoft.playready',\n 'urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb': 'com.adobe.primetime'\n};\n/**\n * Builds a list of urls that is the product of the reference urls and BaseURL values\n *\n * @param {Object[]} references\n * List of objects containing the reference URL as well as its attributes\n * @param {Node[]} baseUrlElements\n * List of BaseURL nodes from the mpd\n * @return {Object[]}\n * List of objects with resolved urls and attributes\n */\n\nconst buildBaseUrls = (references, baseUrlElements) => {\n if (!baseUrlElements.length) {\n return references;\n }\n\n return flatten(references.map(function (reference) {\n return baseUrlElements.map(function (baseUrlElement) {\n const initialBaseUrl = getContent(baseUrlElement);\n const resolvedBaseUrl = resolveUrl(reference.baseUrl, initialBaseUrl);\n const finalBaseUrl = merge(parseAttributes(baseUrlElement), {\n baseUrl: resolvedBaseUrl\n }); // If the URL is resolved, we want to get the serviceLocation from the reference\n // assuming there is no serviceLocation on the initialBaseUrl\n\n if (resolvedBaseUrl !== initialBaseUrl && !finalBaseUrl.serviceLocation && reference.serviceLocation) {\n finalBaseUrl.serviceLocation = reference.serviceLocation;\n }\n\n return finalBaseUrl;\n });\n }));\n};\n/**\n * Contains all Segment information for its containing AdaptationSet\n *\n * @typedef {Object} SegmentInformation\n * @property {Object|undefined} template\n * Contains the attributes for the SegmentTemplate node\n * @property {Object[]|undefined} segmentTimeline\n * Contains a list of atrributes for each S node within the SegmentTimeline node\n * @property {Object|undefined} list\n * Contains the attributes for the SegmentList node\n * @property {Object|undefined} base\n * Contains the attributes for the SegmentBase node\n */\n\n/**\n * Returns all available Segment information contained within the AdaptationSet node\n *\n * @param {Node} adaptationSet\n * The AdaptationSet node to get Segment information from\n * @return {SegmentInformation}\n * The Segment information contained within the provided AdaptationSet\n */\n\nconst getSegmentInformation = adaptationSet => {\n const segmentTemplate = findChildren(adaptationSet, 'SegmentTemplate')[0];\n const segmentList = findChildren(adaptationSet, 'SegmentList')[0];\n const segmentUrls = segmentList && findChildren(segmentList, 'SegmentURL').map(s => merge({\n tag: 'SegmentURL'\n }, parseAttributes(s)));\n const segmentBase = findChildren(adaptationSet, 'SegmentBase')[0];\n const segmentTimelineParentNode = segmentList || segmentTemplate;\n const segmentTimeline = segmentTimelineParentNode && findChildren(segmentTimelineParentNode, 'SegmentTimeline')[0];\n const segmentInitializationParentNode = segmentList || segmentBase || segmentTemplate;\n const segmentInitialization = segmentInitializationParentNode && findChildren(segmentInitializationParentNode, 'Initialization')[0]; // SegmentTemplate is handled slightly differently, since it can have both\n // @initialization and an node. @initialization can be templated,\n // while the node can have a url and range specified. If the has\n // both @initialization and an subelement we opt to override with\n // the node, as this interaction is not defined in the spec.\n\n const template = segmentTemplate && parseAttributes(segmentTemplate);\n\n if (template && segmentInitialization) {\n template.initialization = segmentInitialization && parseAttributes(segmentInitialization);\n } else if (template && template.initialization) {\n // If it is @initialization we convert it to an object since this is the format that\n // later functions will rely on for the initialization segment. This is only valid\n // for \n template.initialization = {\n sourceURL: template.initialization\n };\n }\n\n const segmentInfo = {\n template,\n segmentTimeline: segmentTimeline && findChildren(segmentTimeline, 'S').map(s => parseAttributes(s)),\n list: segmentList && merge(parseAttributes(segmentList), {\n segmentUrls,\n initialization: parseAttributes(segmentInitialization)\n }),\n base: segmentBase && merge(parseAttributes(segmentBase), {\n initialization: parseAttributes(segmentInitialization)\n })\n };\n Object.keys(segmentInfo).forEach(key => {\n if (!segmentInfo[key]) {\n delete segmentInfo[key];\n }\n });\n return segmentInfo;\n};\n/**\n * Contains Segment information and attributes needed to construct a Playlist object\n * from a Representation\n *\n * @typedef {Object} RepresentationInformation\n * @property {SegmentInformation} segmentInfo\n * Segment information for this Representation\n * @property {Object} attributes\n * Inherited attributes for this Representation\n */\n\n/**\n * Maps a Representation node to an object containing Segment information and attributes\n *\n * @name inheritBaseUrlsCallback\n * @function\n * @param {Node} representation\n * Representation node from the mpd\n * @return {RepresentationInformation}\n * Representation information needed to construct a Playlist object\n */\n\n/**\n * Returns a callback for Array.prototype.map for mapping Representation nodes to\n * Segment information and attributes using inherited BaseURL nodes.\n *\n * @param {Object} adaptationSetAttributes\n * Contains attributes inherited by the AdaptationSet\n * @param {Object[]} adaptationSetBaseUrls\n * List of objects containing resolved base URLs and attributes\n * inherited by the AdaptationSet\n * @param {SegmentInformation} adaptationSetSegmentInfo\n * Contains Segment information for the AdaptationSet\n * @return {inheritBaseUrlsCallback}\n * Callback map function\n */\n\nconst inheritBaseUrls = (adaptationSetAttributes, adaptationSetBaseUrls, adaptationSetSegmentInfo) => representation => {\n const repBaseUrlElements = findChildren(representation, 'BaseURL');\n const repBaseUrls = buildBaseUrls(adaptationSetBaseUrls, repBaseUrlElements);\n const attributes = merge(adaptationSetAttributes, parseAttributes(representation));\n const representationSegmentInfo = getSegmentInformation(representation);\n return repBaseUrls.map(baseUrl => {\n return {\n segmentInfo: merge(adaptationSetSegmentInfo, representationSegmentInfo),\n attributes: merge(attributes, baseUrl)\n };\n });\n};\n/**\n * Tranforms a series of content protection nodes to\n * an object containing pssh data by key system\n *\n * @param {Node[]} contentProtectionNodes\n * Content protection nodes\n * @return {Object}\n * Object containing pssh data by key system\n */\n\nconst generateKeySystemInformation = contentProtectionNodes => {\n return contentProtectionNodes.reduce((acc, node) => {\n const attributes = parseAttributes(node); // Although it could be argued that according to the UUID RFC spec the UUID string (a-f chars) should be generated\n // as a lowercase string it also mentions it should be treated as case-insensitive on input. Since the key system\n // UUIDs in the keySystemsMap are hardcoded as lowercase in the codebase there isn't any reason not to do\n // .toLowerCase() on the input UUID string from the manifest (at least I could not think of one).\n\n if (attributes.schemeIdUri) {\n attributes.schemeIdUri = attributes.schemeIdUri.toLowerCase();\n }\n\n const keySystem = keySystemsMap[attributes.schemeIdUri];\n\n if (keySystem) {\n acc[keySystem] = {\n attributes\n };\n const psshNode = findChildren(node, 'cenc:pssh')[0];\n\n if (psshNode) {\n const pssh = getContent(psshNode);\n acc[keySystem].pssh = pssh && decodeB64ToUint8Array(pssh);\n }\n }\n\n return acc;\n }, {});\n}; // defined in ANSI_SCTE 214-1 2016\n\n\nconst parseCaptionServiceMetadata = service => {\n // 608 captions\n if (service.schemeIdUri === 'urn:scte:dash:cc:cea-608:2015') {\n const values = typeof service.value !== 'string' ? [] : service.value.split(';');\n return values.map(value => {\n let channel;\n let language; // default language to value\n\n language = value;\n\n if (/^CC\\d=/.test(value)) {\n [channel, language] = value.split('=');\n } else if (/^CC\\d$/.test(value)) {\n channel = value;\n }\n\n return {\n channel,\n language\n };\n });\n } else if (service.schemeIdUri === 'urn:scte:dash:cc:cea-708:2015') {\n const values = typeof service.value !== 'string' ? [] : service.value.split(';');\n return values.map(value => {\n const flags = {\n // service or channel number 1-63\n 'channel': undefined,\n // language is a 3ALPHA per ISO 639.2/B\n // field is required\n 'language': undefined,\n // BIT 1/0 or ?\n // default value is 1, meaning 16:9 aspect ratio, 0 is 4:3, ? is unknown\n 'aspectRatio': 1,\n // BIT 1/0\n // easy reader flag indicated the text is tailed to the needs of beginning readers\n // default 0, or off\n 'easyReader': 0,\n // BIT 1/0\n // If 3d metadata is present (CEA-708.1) then 1\n // default 0\n '3D': 0\n };\n\n if (/=/.test(value)) {\n const [channel, opts = ''] = value.split('=');\n flags.channel = channel;\n flags.language = value;\n opts.split(',').forEach(opt => {\n const [name, val] = opt.split(':');\n\n if (name === 'lang') {\n flags.language = val; // er for easyReadery\n } else if (name === 'er') {\n flags.easyReader = Number(val); // war for wide aspect ratio\n } else if (name === 'war') {\n flags.aspectRatio = Number(val);\n } else if (name === '3D') {\n flags['3D'] = Number(val);\n }\n });\n } else {\n flags.language = value;\n }\n\n if (flags.channel) {\n flags.channel = 'SERVICE' + flags.channel;\n }\n\n return flags;\n });\n }\n};\n/**\n * A map callback that will parse all event stream data for a collection of periods\n * DASH ISO_IEC_23009 5.10.2.2\n * https://dashif-documents.azurewebsites.net/Events/master/event.html#mpd-event-timing\n *\n * @param {PeriodInformation} period object containing necessary period information\n * @return a collection of parsed eventstream event objects\n */\n\nconst toEventStream = period => {\n // get and flatten all EventStreams tags and parse attributes and children\n return flatten(findChildren(period.node, 'EventStream').map(eventStream => {\n const eventStreamAttributes = parseAttributes(eventStream);\n const schemeIdUri = eventStreamAttributes.schemeIdUri; // find all Events per EventStream tag and map to return objects\n\n return findChildren(eventStream, 'Event').map(event => {\n const eventAttributes = parseAttributes(event);\n const presentationTime = eventAttributes.presentationTime || 0;\n const timescale = eventStreamAttributes.timescale || 1;\n const duration = eventAttributes.duration || 0;\n const start = presentationTime / timescale + period.attributes.start;\n return {\n schemeIdUri,\n value: eventStreamAttributes.value,\n id: eventAttributes.id,\n start,\n end: start + duration / timescale,\n messageData: getContent(event) || eventAttributes.messageData,\n contentEncoding: eventStreamAttributes.contentEncoding,\n presentationTimeOffset: eventStreamAttributes.presentationTimeOffset || 0\n };\n });\n }));\n};\n/**\n * Maps an AdaptationSet node to a list of Representation information objects\n *\n * @name toRepresentationsCallback\n * @function\n * @param {Node} adaptationSet\n * AdaptationSet node from the mpd\n * @return {RepresentationInformation[]}\n * List of objects containing Representaion information\n */\n\n/**\n * Returns a callback for Array.prototype.map for mapping AdaptationSet nodes to a list of\n * Representation information objects\n *\n * @param {Object} periodAttributes\n * Contains attributes inherited by the Period\n * @param {Object[]} periodBaseUrls\n * Contains list of objects with resolved base urls and attributes\n * inherited by the Period\n * @param {string[]} periodSegmentInfo\n * Contains Segment Information at the period level\n * @return {toRepresentationsCallback}\n * Callback map function\n */\n\nconst toRepresentations = (periodAttributes, periodBaseUrls, periodSegmentInfo) => adaptationSet => {\n const adaptationSetAttributes = parseAttributes(adaptationSet);\n const adaptationSetBaseUrls = buildBaseUrls(periodBaseUrls, findChildren(adaptationSet, 'BaseURL'));\n const role = findChildren(adaptationSet, 'Role')[0];\n const roleAttributes = {\n role: parseAttributes(role)\n };\n let attrs = merge(periodAttributes, adaptationSetAttributes, roleAttributes);\n const accessibility = findChildren(adaptationSet, 'Accessibility')[0];\n const captionServices = parseCaptionServiceMetadata(parseAttributes(accessibility));\n\n if (captionServices) {\n attrs = merge(attrs, {\n captionServices\n });\n }\n\n const label = findChildren(adaptationSet, 'Label')[0];\n\n if (label && label.childNodes.length) {\n const labelVal = label.childNodes[0].nodeValue.trim();\n attrs = merge(attrs, {\n label: labelVal\n });\n }\n\n const contentProtection = generateKeySystemInformation(findChildren(adaptationSet, 'ContentProtection'));\n\n if (Object.keys(contentProtection).length) {\n attrs = merge(attrs, {\n contentProtection\n });\n }\n\n const segmentInfo = getSegmentInformation(adaptationSet);\n const representations = findChildren(adaptationSet, 'Representation');\n const adaptationSetSegmentInfo = merge(periodSegmentInfo, segmentInfo);\n return flatten(representations.map(inheritBaseUrls(attrs, adaptationSetBaseUrls, adaptationSetSegmentInfo)));\n};\n/**\n * Contains all period information for mapping nodes onto adaptation sets.\n *\n * @typedef {Object} PeriodInformation\n * @property {Node} period.node\n * Period node from the mpd\n * @property {Object} period.attributes\n * Parsed period attributes from node plus any added\n */\n\n/**\n * Maps a PeriodInformation object to a list of Representation information objects for all\n * AdaptationSet nodes contained within the Period.\n *\n * @name toAdaptationSetsCallback\n * @function\n * @param {PeriodInformation} period\n * Period object containing necessary period information\n * @param {number} periodStart\n * Start time of the Period within the mpd\n * @return {RepresentationInformation[]}\n * List of objects containing Representaion information\n */\n\n/**\n * Returns a callback for Array.prototype.map for mapping Period nodes to a list of\n * Representation information objects\n *\n * @param {Object} mpdAttributes\n * Contains attributes inherited by the mpd\n * @param {Object[]} mpdBaseUrls\n * Contains list of objects with resolved base urls and attributes\n * inherited by the mpd\n * @return {toAdaptationSetsCallback}\n * Callback map function\n */\n\nconst toAdaptationSets = (mpdAttributes, mpdBaseUrls) => (period, index) => {\n const periodBaseUrls = buildBaseUrls(mpdBaseUrls, findChildren(period.node, 'BaseURL'));\n const periodAttributes = merge(mpdAttributes, {\n periodStart: period.attributes.start\n });\n\n if (typeof period.attributes.duration === 'number') {\n periodAttributes.periodDuration = period.attributes.duration;\n }\n\n const adaptationSets = findChildren(period.node, 'AdaptationSet');\n const periodSegmentInfo = getSegmentInformation(period.node);\n return flatten(adaptationSets.map(toRepresentations(periodAttributes, periodBaseUrls, periodSegmentInfo)));\n};\n/**\n * Tranforms an array of content steering nodes into an object\n * containing CDN content steering information from the MPD manifest.\n *\n * For more information on the DASH spec for Content Steering parsing, see:\n * https://dashif.org/docs/DASH-IF-CTS-00XX-Content-Steering-Community-Review.pdf\n *\n * @param {Node[]} contentSteeringNodes\n * Content steering nodes\n * @param {Function} eventHandler\n * The event handler passed into the parser options to handle warnings\n * @return {Object}\n * Object containing content steering data\n */\n\nconst generateContentSteeringInformation = (contentSteeringNodes, eventHandler) => {\n // If there are more than one ContentSteering tags, throw an error\n if (contentSteeringNodes.length > 1) {\n eventHandler({\n type: 'warn',\n message: 'The MPD manifest should contain no more than one ContentSteering tag'\n });\n } // Return a null value if there are no ContentSteering tags\n\n\n if (!contentSteeringNodes.length) {\n return null;\n }\n\n const infoFromContentSteeringTag = merge({\n serverURL: getContent(contentSteeringNodes[0])\n }, parseAttributes(contentSteeringNodes[0])); // Converts `queryBeforeStart` to a boolean, as well as setting the default value\n // to `false` if it doesn't exist\n\n infoFromContentSteeringTag.queryBeforeStart = infoFromContentSteeringTag.queryBeforeStart === 'true';\n return infoFromContentSteeringTag;\n};\n/**\n * Gets Period@start property for a given period.\n *\n * @param {Object} options\n * Options object\n * @param {Object} options.attributes\n * Period attributes\n * @param {Object} [options.priorPeriodAttributes]\n * Prior period attributes (if prior period is available)\n * @param {string} options.mpdType\n * The MPD@type these periods came from\n * @return {number|null}\n * The period start, or null if it's an early available period or error\n */\n\nconst getPeriodStart = ({\n attributes,\n priorPeriodAttributes,\n mpdType\n}) => {\n // Summary of period start time calculation from DASH spec section 5.3.2.1\n //\n // A period's start is the first period's start + time elapsed after playing all\n // prior periods to this one. Periods continue one after the other in time (without\n // gaps) until the end of the presentation.\n //\n // The value of Period@start should be:\n // 1. if Period@start is present: value of Period@start\n // 2. if previous period exists and it has @duration: previous Period@start +\n // previous Period@duration\n // 3. if this is first period and MPD@type is 'static': 0\n // 4. in all other cases, consider the period an \"early available period\" (note: not\n // currently supported)\n // (1)\n if (typeof attributes.start === 'number') {\n return attributes.start;\n } // (2)\n\n\n if (priorPeriodAttributes && typeof priorPeriodAttributes.start === 'number' && typeof priorPeriodAttributes.duration === 'number') {\n return priorPeriodAttributes.start + priorPeriodAttributes.duration;\n } // (3)\n\n\n if (!priorPeriodAttributes && mpdType === 'static') {\n return 0;\n } // (4)\n // There is currently no logic for calculating the Period@start value if there is\n // no Period@start or prior Period@start and Period@duration available. This is not made\n // explicit by the DASH interop guidelines or the DASH spec, however, since there's\n // nothing about any other resolution strategies, it's implied. Thus, this case should\n // be considered an early available period, or error, and null should suffice for both\n // of those cases.\n\n\n return null;\n};\n/**\n * Traverses the mpd xml tree to generate a list of Representation information objects\n * that have inherited attributes from parent nodes\n *\n * @param {Node} mpd\n * The root node of the mpd\n * @param {Object} options\n * Available options for inheritAttributes\n * @param {string} options.manifestUri\n * The uri source of the mpd\n * @param {number} options.NOW\n * Current time per DASH IOP. Default is current time in ms since epoch\n * @param {number} options.clientOffset\n * Client time difference from NOW (in milliseconds)\n * @return {RepresentationInformation[]}\n * List of objects containing Representation information\n */\n\nconst inheritAttributes = (mpd, options = {}) => {\n const {\n manifestUri = '',\n NOW = Date.now(),\n clientOffset = 0,\n // TODO: For now, we are expecting an eventHandler callback function\n // to be passed into the mpd parser as an option.\n // In the future, we should enable stream parsing by using the Stream class from vhs-utils.\n // This will support new features including a standardized event handler.\n // See the m3u8 parser for examples of how stream parsing is currently used for HLS parsing.\n // https://github.com/videojs/vhs-utils/blob/88d6e10c631e57a5af02c5a62bc7376cd456b4f5/src/stream.js#L9\n eventHandler = function () {}\n } = options;\n const periodNodes = findChildren(mpd, 'Period');\n\n if (!periodNodes.length) {\n throw new Error(errors.INVALID_NUMBER_OF_PERIOD);\n }\n\n const locations = findChildren(mpd, 'Location');\n const mpdAttributes = parseAttributes(mpd);\n const mpdBaseUrls = buildBaseUrls([{\n baseUrl: manifestUri\n }], findChildren(mpd, 'BaseURL'));\n const contentSteeringNodes = findChildren(mpd, 'ContentSteering'); // See DASH spec section 5.3.1.2, Semantics of MPD element. Default type to 'static'.\n\n mpdAttributes.type = mpdAttributes.type || 'static';\n mpdAttributes.sourceDuration = mpdAttributes.mediaPresentationDuration || 0;\n mpdAttributes.NOW = NOW;\n mpdAttributes.clientOffset = clientOffset;\n\n if (locations.length) {\n mpdAttributes.locations = locations.map(getContent);\n }\n\n const periods = []; // Since toAdaptationSets acts on individual periods right now, the simplest approach to\n // adding properties that require looking at prior periods is to parse attributes and add\n // missing ones before toAdaptationSets is called. If more such properties are added, it\n // may be better to refactor toAdaptationSets.\n\n periodNodes.forEach((node, index) => {\n const attributes = parseAttributes(node); // Use the last modified prior period, as it may contain added information necessary\n // for this period.\n\n const priorPeriod = periods[index - 1];\n attributes.start = getPeriodStart({\n attributes,\n priorPeriodAttributes: priorPeriod ? priorPeriod.attributes : null,\n mpdType: mpdAttributes.type\n });\n periods.push({\n node,\n attributes\n });\n });\n return {\n locations: mpdAttributes.locations,\n contentSteeringInfo: generateContentSteeringInformation(contentSteeringNodes, eventHandler),\n // TODO: There are occurences where this `representationInfo` array contains undesired\n // duplicates. This generally occurs when there are multiple BaseURL nodes that are\n // direct children of the MPD node. When we attempt to resolve URLs from a combination of the\n // parent BaseURL and a child BaseURL, and the value does not resolve,\n // we end up returning the child BaseURL multiple times.\n // We need to determine a way to remove these duplicates in a safe way.\n // See: https://github.com/videojs/mpd-parser/pull/17#discussion_r162750527\n representationInfo: flatten(periods.map(toAdaptationSets(mpdAttributes, mpdBaseUrls))),\n eventStream: flatten(periods.map(toEventStream))\n };\n};\n\nconst stringToMpdXml = manifestString => {\n if (manifestString === '') {\n throw new Error(errors.DASH_EMPTY_MANIFEST);\n }\n\n const parser = new DOMParser();\n let xml;\n let mpd;\n\n try {\n xml = parser.parseFromString(manifestString, 'application/xml');\n mpd = xml && xml.documentElement.tagName === 'MPD' ? xml.documentElement : null;\n } catch (e) {// ie 11 throws on invalid xml\n }\n\n if (!mpd || mpd && mpd.getElementsByTagName('parsererror').length > 0) {\n throw new Error(errors.DASH_INVALID_XML);\n }\n\n return mpd;\n};\n\n/**\n * Parses the manifest for a UTCTiming node, returning the nodes attributes if found\n *\n * @param {string} mpd\n * XML string of the MPD manifest\n * @return {Object|null}\n * Attributes of UTCTiming node specified in the manifest. Null if none found\n */\n\nconst parseUTCTimingScheme = mpd => {\n const UTCTimingNode = findChildren(mpd, 'UTCTiming')[0];\n\n if (!UTCTimingNode) {\n return null;\n }\n\n const attributes = parseAttributes(UTCTimingNode);\n\n switch (attributes.schemeIdUri) {\n case 'urn:mpeg:dash:utc:http-head:2014':\n case 'urn:mpeg:dash:utc:http-head:2012':\n attributes.method = 'HEAD';\n break;\n\n case 'urn:mpeg:dash:utc:http-xsdate:2014':\n case 'urn:mpeg:dash:utc:http-iso:2014':\n case 'urn:mpeg:dash:utc:http-xsdate:2012':\n case 'urn:mpeg:dash:utc:http-iso:2012':\n attributes.method = 'GET';\n break;\n\n case 'urn:mpeg:dash:utc:direct:2014':\n case 'urn:mpeg:dash:utc:direct:2012':\n attributes.method = 'DIRECT';\n attributes.value = Date.parse(attributes.value);\n break;\n\n case 'urn:mpeg:dash:utc:http-ntp:2014':\n case 'urn:mpeg:dash:utc:ntp:2014':\n case 'urn:mpeg:dash:utc:sntp:2014':\n default:\n throw new Error(errors.UNSUPPORTED_UTC_TIMING_SCHEME);\n }\n\n return attributes;\n};\n\nconst VERSION = version;\n/*\n * Given a DASH manifest string and options, parses the DASH manifest into an object in the\n * form outputed by m3u8-parser and accepted by videojs/http-streaming.\n *\n * For live DASH manifests, if `previousManifest` is provided in options, then the newly\n * parsed DASH manifest will have its media sequence and discontinuity sequence values\n * updated to reflect its position relative to the prior manifest.\n *\n * @param {string} manifestString - the DASH manifest as a string\n * @param {options} [options] - any options\n *\n * @return {Object} the manifest object\n */\n\nconst parse = (manifestString, options = {}) => {\n const parsedManifestInfo = inheritAttributes(stringToMpdXml(manifestString), options);\n const playlists = toPlaylists(parsedManifestInfo.representationInfo);\n return toM3u8({\n dashPlaylists: playlists,\n locations: parsedManifestInfo.locations,\n contentSteering: parsedManifestInfo.contentSteeringInfo,\n sidxMapping: options.sidxMapping,\n previousManifest: options.previousManifest,\n eventStream: parsedManifestInfo.eventStream\n });\n};\n/**\n * Parses the manifest for a UTCTiming node, returning the nodes attributes if found\n *\n * @param {string} manifestString\n * XML string of the MPD manifest\n * @return {Object|null}\n * Attributes of UTCTiming node specified in the manifest. Null if none found\n */\n\n\nconst parseUTCTiming = manifestString => parseUTCTimingScheme(stringToMpdXml(manifestString));\n\nexport { VERSION, addSidxSegmentsToPlaylist$1 as addSidxSegmentsToPlaylist, generateSidxKey, inheritAttributes, parse, parseUTCTiming, stringToMpdXml, toM3u8, toPlaylists };\n","/**\n * Loops through all supported media groups in master and calls the provided\n * callback for each group\n *\n * @param {Object} master\n * The parsed master manifest object\n * @param {string[]} groups\n * The media groups to call the callback for\n * @param {Function} callback\n * Callback to call for each media group\n */\nexport var forEachMediaGroup = function forEachMediaGroup(master, groups, callback) {\n groups.forEach(function (mediaType) {\n for (var groupKey in master.mediaGroups[mediaType]) {\n for (var labelKey in master.mediaGroups[mediaType][groupKey]) {\n var mediaProperties = master.mediaGroups[mediaType][groupKey][labelKey];\n callback(mediaProperties, mediaType, groupKey, labelKey);\n }\n }\n });\n};","import window from 'global/window';\n\nvar atob = function atob(s) {\n return window.atob ? window.atob(s) : Buffer.from(s, 'base64').toString('binary');\n};\n\nexport default function decodeB64ToUint8Array(b64Text) {\n var decodedString = atob(b64Text);\n var array = new Uint8Array(decodedString.length);\n\n for (var i = 0; i < decodedString.length; i++) {\n array[i] = decodedString.charCodeAt(i);\n }\n\n return array;\n}","import { stringToBytes, toUint8, bytesMatch, bytesToString, toHexString, padStart, bytesToNumber } from './byte-helpers.js';\nimport { getAvcCodec, getHvcCodec, getAv1Codec } from './codec-helpers.js';\nimport { parseOpusHead } from './opus-helpers.js';\n\nvar normalizePath = function normalizePath(path) {\n if (typeof path === 'string') {\n return stringToBytes(path);\n }\n\n if (typeof path === 'number') {\n return path;\n }\n\n return path;\n};\n\nvar normalizePaths = function normalizePaths(paths) {\n if (!Array.isArray(paths)) {\n return [normalizePath(paths)];\n }\n\n return paths.map(function (p) {\n return normalizePath(p);\n });\n};\n\nvar DESCRIPTORS;\nexport var parseDescriptors = function parseDescriptors(bytes) {\n bytes = toUint8(bytes);\n var results = [];\n var i = 0;\n\n while (bytes.length > i) {\n var tag = bytes[i];\n var size = 0;\n var headerSize = 0; // tag\n\n headerSize++;\n var byte = bytes[headerSize]; // first byte\n\n headerSize++;\n\n while (byte & 0x80) {\n size = (byte & 0x7F) << 7;\n byte = bytes[headerSize];\n headerSize++;\n }\n\n size += byte & 0x7F;\n\n for (var z = 0; z < DESCRIPTORS.length; z++) {\n var _DESCRIPTORS$z = DESCRIPTORS[z],\n id = _DESCRIPTORS$z.id,\n parser = _DESCRIPTORS$z.parser;\n\n if (tag === id) {\n results.push(parser(bytes.subarray(headerSize, headerSize + size)));\n break;\n }\n }\n\n i += size + headerSize;\n }\n\n return results;\n};\nDESCRIPTORS = [{\n id: 0x03,\n parser: function parser(bytes) {\n var desc = {\n tag: 0x03,\n id: bytes[0] << 8 | bytes[1],\n flags: bytes[2],\n size: 3,\n dependsOnEsId: 0,\n ocrEsId: 0,\n descriptors: [],\n url: ''\n }; // depends on es id\n\n if (desc.flags & 0x80) {\n desc.dependsOnEsId = bytes[desc.size] << 8 | bytes[desc.size + 1];\n desc.size += 2;\n } // url\n\n\n if (desc.flags & 0x40) {\n var len = bytes[desc.size];\n desc.url = bytesToString(bytes.subarray(desc.size + 1, desc.size + 1 + len));\n desc.size += len;\n } // ocr es id\n\n\n if (desc.flags & 0x20) {\n desc.ocrEsId = bytes[desc.size] << 8 | bytes[desc.size + 1];\n desc.size += 2;\n }\n\n desc.descriptors = parseDescriptors(bytes.subarray(desc.size)) || [];\n return desc;\n }\n}, {\n id: 0x04,\n parser: function parser(bytes) {\n // DecoderConfigDescriptor\n var desc = {\n tag: 0x04,\n oti: bytes[0],\n streamType: bytes[1],\n bufferSize: bytes[2] << 16 | bytes[3] << 8 | bytes[4],\n maxBitrate: bytes[5] << 24 | bytes[6] << 16 | bytes[7] << 8 | bytes[8],\n avgBitrate: bytes[9] << 24 | bytes[10] << 16 | bytes[11] << 8 | bytes[12],\n descriptors: parseDescriptors(bytes.subarray(13))\n };\n return desc;\n }\n}, {\n id: 0x05,\n parser: function parser(bytes) {\n // DecoderSpecificInfo\n return {\n tag: 0x05,\n bytes: bytes\n };\n }\n}, {\n id: 0x06,\n parser: function parser(bytes) {\n // SLConfigDescriptor\n return {\n tag: 0x06,\n bytes: bytes\n };\n }\n}];\n/**\n * find any number of boxes by name given a path to it in an iso bmff\n * such as mp4.\n *\n * @param {TypedArray} bytes\n * bytes for the iso bmff to search for boxes in\n *\n * @param {Uint8Array[]|string[]|string|Uint8Array} name\n * An array of paths or a single path representing the name\n * of boxes to search through in bytes. Paths may be\n * uint8 (character codes) or strings.\n *\n * @param {boolean} [complete=false]\n * Should we search only for complete boxes on the final path.\n * This is very useful when you do not want to get back partial boxes\n * in the case of streaming files.\n *\n * @return {Uint8Array[]}\n * An array of the end paths that we found.\n */\n\nexport var findBox = function findBox(bytes, paths, complete) {\n if (complete === void 0) {\n complete = false;\n }\n\n paths = normalizePaths(paths);\n bytes = toUint8(bytes);\n var results = [];\n\n if (!paths.length) {\n // short-circuit the search for empty paths\n return results;\n }\n\n var i = 0;\n\n while (i < bytes.length) {\n var size = (bytes[i] << 24 | bytes[i + 1] << 16 | bytes[i + 2] << 8 | bytes[i + 3]) >>> 0;\n var type = bytes.subarray(i + 4, i + 8); // invalid box format.\n\n if (size === 0) {\n break;\n }\n\n var end = i + size;\n\n if (end > bytes.length) {\n // this box is bigger than the number of bytes we have\n // and complete is set, we cannot find any more boxes.\n if (complete) {\n break;\n }\n\n end = bytes.length;\n }\n\n var data = bytes.subarray(i + 8, end);\n\n if (bytesMatch(type, paths[0])) {\n if (paths.length === 1) {\n // this is the end of the path and we've found the box we were\n // looking for\n results.push(data);\n } else {\n // recursively search for the next box along the path\n results.push.apply(results, findBox(data, paths.slice(1), complete));\n }\n }\n\n i = end;\n } // we've finished searching all of bytes\n\n\n return results;\n};\n/**\n * Search for a single matching box by name in an iso bmff format like\n * mp4. This function is useful for finding codec boxes which\n * can be placed arbitrarily in sample descriptions depending\n * on the version of the file or file type.\n *\n * @param {TypedArray} bytes\n * bytes for the iso bmff to search for boxes in\n *\n * @param {string|Uint8Array} name\n * The name of the box to find.\n *\n * @return {Uint8Array[]}\n * a subarray of bytes representing the name boxed we found.\n */\n\nexport var findNamedBox = function findNamedBox(bytes, name) {\n name = normalizePath(name);\n\n if (!name.length) {\n // short-circuit the search for empty paths\n return bytes.subarray(bytes.length);\n }\n\n var i = 0;\n\n while (i < bytes.length) {\n if (bytesMatch(bytes.subarray(i, i + name.length), name)) {\n var size = (bytes[i - 4] << 24 | bytes[i - 3] << 16 | bytes[i - 2] << 8 | bytes[i - 1]) >>> 0;\n var end = size > 1 ? i + size : bytes.byteLength;\n return bytes.subarray(i + 4, end);\n }\n\n i++;\n } // we've finished searching all of bytes\n\n\n return bytes.subarray(bytes.length);\n};\n\nvar parseSamples = function parseSamples(data, entrySize, parseEntry) {\n if (entrySize === void 0) {\n entrySize = 4;\n }\n\n if (parseEntry === void 0) {\n parseEntry = function parseEntry(d) {\n return bytesToNumber(d);\n };\n }\n\n var entries = [];\n\n if (!data || !data.length) {\n return entries;\n }\n\n var entryCount = bytesToNumber(data.subarray(4, 8));\n\n for (var i = 8; entryCount; i += entrySize, entryCount--) {\n entries.push(parseEntry(data.subarray(i, i + entrySize)));\n }\n\n return entries;\n};\n\nexport var buildFrameTable = function buildFrameTable(stbl, timescale) {\n var keySamples = parseSamples(findBox(stbl, ['stss'])[0]);\n var chunkOffsets = parseSamples(findBox(stbl, ['stco'])[0]);\n var timeToSamples = parseSamples(findBox(stbl, ['stts'])[0], 8, function (entry) {\n return {\n sampleCount: bytesToNumber(entry.subarray(0, 4)),\n sampleDelta: bytesToNumber(entry.subarray(4, 8))\n };\n });\n var samplesToChunks = parseSamples(findBox(stbl, ['stsc'])[0], 12, function (entry) {\n return {\n firstChunk: bytesToNumber(entry.subarray(0, 4)),\n samplesPerChunk: bytesToNumber(entry.subarray(4, 8)),\n sampleDescriptionIndex: bytesToNumber(entry.subarray(8, 12))\n };\n });\n var stsz = findBox(stbl, ['stsz'])[0]; // stsz starts with a 4 byte sampleSize which we don't need\n\n var sampleSizes = parseSamples(stsz && stsz.length && stsz.subarray(4) || null);\n var frames = [];\n\n for (var chunkIndex = 0; chunkIndex < chunkOffsets.length; chunkIndex++) {\n var samplesInChunk = void 0;\n\n for (var i = 0; i < samplesToChunks.length; i++) {\n var sampleToChunk = samplesToChunks[i];\n var isThisOne = chunkIndex + 1 >= sampleToChunk.firstChunk && (i + 1 >= samplesToChunks.length || chunkIndex + 1 < samplesToChunks[i + 1].firstChunk);\n\n if (isThisOne) {\n samplesInChunk = sampleToChunk.samplesPerChunk;\n break;\n }\n }\n\n var chunkOffset = chunkOffsets[chunkIndex];\n\n for (var _i = 0; _i < samplesInChunk; _i++) {\n var frameEnd = sampleSizes[frames.length]; // if we don't have key samples every frame is a keyframe\n\n var keyframe = !keySamples.length;\n\n if (keySamples.length && keySamples.indexOf(frames.length + 1) !== -1) {\n keyframe = true;\n }\n\n var frame = {\n keyframe: keyframe,\n start: chunkOffset,\n end: chunkOffset + frameEnd\n };\n\n for (var k = 0; k < timeToSamples.length; k++) {\n var _timeToSamples$k = timeToSamples[k],\n sampleCount = _timeToSamples$k.sampleCount,\n sampleDelta = _timeToSamples$k.sampleDelta;\n\n if (frames.length <= sampleCount) {\n // ms to ns\n var lastTimestamp = frames.length ? frames[frames.length - 1].timestamp : 0;\n frame.timestamp = lastTimestamp + sampleDelta / timescale * 1000;\n frame.duration = sampleDelta;\n break;\n }\n }\n\n frames.push(frame);\n chunkOffset += frameEnd;\n }\n }\n\n return frames;\n};\nexport var addSampleDescription = function addSampleDescription(track, bytes) {\n var codec = bytesToString(bytes.subarray(0, 4));\n\n if (track.type === 'video') {\n track.info = track.info || {};\n track.info.width = bytes[28] << 8 | bytes[29];\n track.info.height = bytes[30] << 8 | bytes[31];\n } else if (track.type === 'audio') {\n track.info = track.info || {};\n track.info.channels = bytes[20] << 8 | bytes[21];\n track.info.bitDepth = bytes[22] << 8 | bytes[23];\n track.info.sampleRate = bytes[28] << 8 | bytes[29];\n }\n\n if (codec === 'avc1') {\n var avcC = findNamedBox(bytes, 'avcC'); // AVCDecoderConfigurationRecord\n\n codec += \".\" + getAvcCodec(avcC);\n track.info.avcC = avcC; // TODO: do we need to parse all this?\n\n /* {\n configurationVersion: avcC[0],\n profile: avcC[1],\n profileCompatibility: avcC[2],\n level: avcC[3],\n lengthSizeMinusOne: avcC[4] & 0x3\n };\n let spsNalUnitCount = avcC[5] & 0x1F;\n const spsNalUnits = track.info.avc.spsNalUnits = [];\n // past spsNalUnitCount\n let offset = 6;\n while (spsNalUnitCount--) {\n const nalLen = avcC[offset] << 8 | avcC[offset + 1];\n spsNalUnits.push(avcC.subarray(offset + 2, offset + 2 + nalLen));\n offset += nalLen + 2;\n }\n let ppsNalUnitCount = avcC[offset];\n const ppsNalUnits = track.info.avc.ppsNalUnits = [];\n // past ppsNalUnitCount\n offset += 1;\n while (ppsNalUnitCount--) {\n const nalLen = avcC[offset] << 8 | avcC[offset + 1];\n ppsNalUnits.push(avcC.subarray(offset + 2, offset + 2 + nalLen));\n offset += nalLen + 2;\n }*/\n // HEVCDecoderConfigurationRecord\n } else if (codec === 'hvc1' || codec === 'hev1') {\n codec += \".\" + getHvcCodec(findNamedBox(bytes, 'hvcC'));\n } else if (codec === 'mp4a' || codec === 'mp4v') {\n var esds = findNamedBox(bytes, 'esds');\n var esDescriptor = parseDescriptors(esds.subarray(4))[0];\n var decoderConfig = esDescriptor && esDescriptor.descriptors.filter(function (_ref) {\n var tag = _ref.tag;\n return tag === 0x04;\n })[0];\n\n if (decoderConfig) {\n // most codecs do not have a further '.'\n // such as 0xa5 for ac-3 and 0xa6 for e-ac-3\n codec += '.' + toHexString(decoderConfig.oti);\n\n if (decoderConfig.oti === 0x40) {\n codec += '.' + (decoderConfig.descriptors[0].bytes[0] >> 3).toString();\n } else if (decoderConfig.oti === 0x20) {\n codec += '.' + decoderConfig.descriptors[0].bytes[4].toString();\n } else if (decoderConfig.oti === 0xdd) {\n codec = 'vorbis';\n }\n } else if (track.type === 'audio') {\n codec += '.40.2';\n } else {\n codec += '.20.9';\n }\n } else if (codec === 'av01') {\n // AV1DecoderConfigurationRecord\n codec += \".\" + getAv1Codec(findNamedBox(bytes, 'av1C'));\n } else if (codec === 'vp09') {\n // VPCodecConfigurationRecord\n var vpcC = findNamedBox(bytes, 'vpcC'); // https://www.webmproject.org/vp9/mp4/\n\n var profile = vpcC[0];\n var level = vpcC[1];\n var bitDepth = vpcC[2] >> 4;\n var chromaSubsampling = (vpcC[2] & 0x0F) >> 1;\n var videoFullRangeFlag = (vpcC[2] & 0x0F) >> 3;\n var colourPrimaries = vpcC[3];\n var transferCharacteristics = vpcC[4];\n var matrixCoefficients = vpcC[5];\n codec += \".\" + padStart(profile, 2, '0');\n codec += \".\" + padStart(level, 2, '0');\n codec += \".\" + padStart(bitDepth, 2, '0');\n codec += \".\" + padStart(chromaSubsampling, 2, '0');\n codec += \".\" + padStart(colourPrimaries, 2, '0');\n codec += \".\" + padStart(transferCharacteristics, 2, '0');\n codec += \".\" + padStart(matrixCoefficients, 2, '0');\n codec += \".\" + padStart(videoFullRangeFlag, 2, '0');\n } else if (codec === 'theo') {\n codec = 'theora';\n } else if (codec === 'spex') {\n codec = 'speex';\n } else if (codec === '.mp3') {\n codec = 'mp4a.40.34';\n } else if (codec === 'msVo') {\n codec = 'vorbis';\n } else if (codec === 'Opus') {\n codec = 'opus';\n var dOps = findNamedBox(bytes, 'dOps');\n track.info.opus = parseOpusHead(dOps); // TODO: should this go into the webm code??\n // Firefox requires a codecDelay for opus playback\n // see https://bugzilla.mozilla.org/show_bug.cgi?id=1276238\n\n track.info.codecDelay = 6500000;\n } else {\n codec = codec.toLowerCase();\n }\n /* eslint-enable */\n // flac, ac-3, ec-3, opus\n\n\n track.codec = codec;\n};\nexport var parseTracks = function parseTracks(bytes, frameTable) {\n if (frameTable === void 0) {\n frameTable = true;\n }\n\n bytes = toUint8(bytes);\n var traks = findBox(bytes, ['moov', 'trak'], true);\n var tracks = [];\n traks.forEach(function (trak) {\n var track = {\n bytes: trak\n };\n var mdia = findBox(trak, ['mdia'])[0];\n var hdlr = findBox(mdia, ['hdlr'])[0];\n var trakType = bytesToString(hdlr.subarray(8, 12));\n\n if (trakType === 'soun') {\n track.type = 'audio';\n } else if (trakType === 'vide') {\n track.type = 'video';\n } else {\n track.type = trakType;\n }\n\n var tkhd = findBox(trak, ['tkhd'])[0];\n\n if (tkhd) {\n var view = new DataView(tkhd.buffer, tkhd.byteOffset, tkhd.byteLength);\n var tkhdVersion = view.getUint8(0);\n track.number = tkhdVersion === 0 ? view.getUint32(12) : view.getUint32(20);\n }\n\n var mdhd = findBox(mdia, ['mdhd'])[0];\n\n if (mdhd) {\n // mdhd is a FullBox, meaning it will have its own version as the first byte\n var version = mdhd[0];\n var index = version === 0 ? 12 : 20;\n track.timescale = (mdhd[index] << 24 | mdhd[index + 1] << 16 | mdhd[index + 2] << 8 | mdhd[index + 3]) >>> 0;\n }\n\n var stbl = findBox(mdia, ['minf', 'stbl'])[0];\n var stsd = findBox(stbl, ['stsd'])[0];\n var descriptionCount = bytesToNumber(stsd.subarray(4, 8));\n var offset = 8; // add codec and codec info\n\n while (descriptionCount--) {\n var len = bytesToNumber(stsd.subarray(offset, offset + 4));\n var sampleDescriptor = stsd.subarray(offset + 4, offset + 4 + len);\n addSampleDescription(track, sampleDescriptor);\n offset += 4 + len;\n }\n\n if (frameTable) {\n track.frameTable = buildFrameTable(stbl, track.timescale);\n } // codec has no sub parameters\n\n\n tracks.push(track);\n });\n return tracks;\n};\nexport var parseMediaInfo = function parseMediaInfo(bytes) {\n var mvhd = findBox(bytes, ['moov', 'mvhd'], true)[0];\n\n if (!mvhd || !mvhd.length) {\n return;\n }\n\n var info = {}; // ms to ns\n // mvhd v1 has 8 byte duration and other fields too\n\n if (mvhd[0] === 1) {\n info.timestampScale = bytesToNumber(mvhd.subarray(20, 24));\n info.duration = bytesToNumber(mvhd.subarray(24, 32));\n } else {\n info.timestampScale = bytesToNumber(mvhd.subarray(12, 16));\n info.duration = bytesToNumber(mvhd.subarray(16, 20));\n }\n\n info.bytes = mvhd;\n return info;\n};","import { toUint8, bytesMatch } from './byte-helpers.js';\nvar ID3 = toUint8([0x49, 0x44, 0x33]);\nexport var getId3Size = function getId3Size(bytes, offset) {\n if (offset === void 0) {\n offset = 0;\n }\n\n bytes = toUint8(bytes);\n var flags = bytes[offset + 5];\n var returnSize = bytes[offset + 6] << 21 | bytes[offset + 7] << 14 | bytes[offset + 8] << 7 | bytes[offset + 9];\n var footerPresent = (flags & 16) >> 4;\n\n if (footerPresent) {\n return returnSize + 20;\n }\n\n return returnSize + 10;\n};\nexport var getId3Offset = function getId3Offset(bytes, offset) {\n if (offset === void 0) {\n offset = 0;\n }\n\n bytes = toUint8(bytes);\n\n if (bytes.length - offset < 10 || !bytesMatch(bytes, ID3, {\n offset: offset\n })) {\n return offset;\n }\n\n offset += getId3Size(bytes, offset); // recursive check for id3 tags as some files\n // have multiple ID3 tag sections even though\n // they should not.\n\n return getId3Offset(bytes, offset);\n};","export var OPUS_HEAD = new Uint8Array([// O, p, u, s\n0x4f, 0x70, 0x75, 0x73, // H, e, a, d\n0x48, 0x65, 0x61, 0x64]); // https://wiki.xiph.org/OggOpus\n// https://vfrmaniac.fushizen.eu/contents/opus_in_isobmff.html\n// https://opus-codec.org/docs/opusfile_api-0.7/structOpusHead.html\n\nexport var parseOpusHead = function parseOpusHead(bytes) {\n var view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n var version = view.getUint8(0); // version 0, from mp4, does not use littleEndian.\n\n var littleEndian = version !== 0;\n var config = {\n version: version,\n channels: view.getUint8(1),\n preSkip: view.getUint16(2, littleEndian),\n sampleRate: view.getUint32(4, littleEndian),\n outputGain: view.getUint16(8, littleEndian),\n channelMappingFamily: view.getUint8(10)\n };\n\n if (config.channelMappingFamily > 0 && bytes.length > 10) {\n config.streamCount = view.getUint8(11);\n config.twoChannelStreamCount = view.getUint8(12);\n config.channelMapping = [];\n\n for (var c = 0; c < config.channels; c++) {\n config.channelMapping.push(view.getUint8(13 + c));\n }\n }\n\n return config;\n};\nexport var setOpusHead = function setOpusHead(config) {\n var size = config.channelMappingFamily <= 0 ? 11 : 12 + config.channels;\n var view = new DataView(new ArrayBuffer(size));\n var littleEndian = config.version !== 0;\n view.setUint8(0, config.version);\n view.setUint8(1, config.channels);\n view.setUint16(2, config.preSkip, littleEndian);\n view.setUint32(4, config.sampleRate, littleEndian);\n view.setUint16(8, config.outputGain, littleEndian);\n view.setUint8(10, config.channelMappingFamily);\n\n if (config.channelMappingFamily > 0) {\n view.setUint8(11, config.streamCount);\n config.channelMapping.foreach(function (cm, i) {\n view.setUint8(12 + i, cm);\n });\n }\n\n return new Uint8Array(view.buffer);\n};","import { toUint8, bytesToNumber, bytesMatch, bytesToString, numberToBytes, padStart } from './byte-helpers';\nimport { getAvcCodec, getHvcCodec, getAv1Codec } from './codec-helpers.js'; // relevant specs for this parser:\n// https://matroska-org.github.io/libebml/specs.html\n// https://www.matroska.org/technical/elements.html\n// https://www.webmproject.org/docs/container/\n\nexport var EBML_TAGS = {\n EBML: toUint8([0x1A, 0x45, 0xDF, 0xA3]),\n DocType: toUint8([0x42, 0x82]),\n Segment: toUint8([0x18, 0x53, 0x80, 0x67]),\n SegmentInfo: toUint8([0x15, 0x49, 0xA9, 0x66]),\n Tracks: toUint8([0x16, 0x54, 0xAE, 0x6B]),\n Track: toUint8([0xAE]),\n TrackNumber: toUint8([0xd7]),\n DefaultDuration: toUint8([0x23, 0xe3, 0x83]),\n TrackEntry: toUint8([0xAE]),\n TrackType: toUint8([0x83]),\n FlagDefault: toUint8([0x88]),\n CodecID: toUint8([0x86]),\n CodecPrivate: toUint8([0x63, 0xA2]),\n VideoTrack: toUint8([0xe0]),\n AudioTrack: toUint8([0xe1]),\n // Not used yet, but will be used for live webm/mkv\n // see https://www.matroska.org/technical/basics.html#block-structure\n // see https://www.matroska.org/technical/basics.html#simpleblock-structure\n Cluster: toUint8([0x1F, 0x43, 0xB6, 0x75]),\n Timestamp: toUint8([0xE7]),\n TimestampScale: toUint8([0x2A, 0xD7, 0xB1]),\n BlockGroup: toUint8([0xA0]),\n BlockDuration: toUint8([0x9B]),\n Block: toUint8([0xA1]),\n SimpleBlock: toUint8([0xA3])\n};\n/**\n * This is a simple table to determine the length\n * of things in ebml. The length is one based (starts at 1,\n * rather than zero) and for every zero bit before a one bit\n * we add one to length. We also need this table because in some\n * case we have to xor all the length bits from another value.\n */\n\nvar LENGTH_TABLE = [128, 64, 32, 16, 8, 4, 2, 1];\n\nvar getLength = function getLength(byte) {\n var len = 1;\n\n for (var i = 0; i < LENGTH_TABLE.length; i++) {\n if (byte & LENGTH_TABLE[i]) {\n break;\n }\n\n len++;\n }\n\n return len;\n}; // length in ebml is stored in the first 4 to 8 bits\n// of the first byte. 4 for the id length and 8 for the\n// data size length. Length is measured by converting the number to binary\n// then 1 + the number of zeros before a 1 is encountered starting\n// from the left.\n\n\nvar getvint = function getvint(bytes, offset, removeLength, signed) {\n if (removeLength === void 0) {\n removeLength = true;\n }\n\n if (signed === void 0) {\n signed = false;\n }\n\n var length = getLength(bytes[offset]);\n var valueBytes = bytes.subarray(offset, offset + length); // NOTE that we do **not** subarray here because we need to copy these bytes\n // as they will be modified below to remove the dataSizeLen bits and we do not\n // want to modify the original data. normally we could just call slice on\n // uint8array but ie 11 does not support that...\n\n if (removeLength) {\n valueBytes = Array.prototype.slice.call(bytes, offset, offset + length);\n valueBytes[0] ^= LENGTH_TABLE[length - 1];\n }\n\n return {\n length: length,\n value: bytesToNumber(valueBytes, {\n signed: signed\n }),\n bytes: valueBytes\n };\n};\n\nvar normalizePath = function normalizePath(path) {\n if (typeof path === 'string') {\n return path.match(/.{1,2}/g).map(function (p) {\n return normalizePath(p);\n });\n }\n\n if (typeof path === 'number') {\n return numberToBytes(path);\n }\n\n return path;\n};\n\nvar normalizePaths = function normalizePaths(paths) {\n if (!Array.isArray(paths)) {\n return [normalizePath(paths)];\n }\n\n return paths.map(function (p) {\n return normalizePath(p);\n });\n};\n\nvar getInfinityDataSize = function getInfinityDataSize(id, bytes, offset) {\n if (offset >= bytes.length) {\n return bytes.length;\n }\n\n var innerid = getvint(bytes, offset, false);\n\n if (bytesMatch(id.bytes, innerid.bytes)) {\n return offset;\n }\n\n var dataHeader = getvint(bytes, offset + innerid.length);\n return getInfinityDataSize(id, bytes, offset + dataHeader.length + dataHeader.value + innerid.length);\n};\n/**\n * Notes on the EBLM format.\n *\n * EBLM uses \"vints\" tags. Every vint tag contains\n * two parts\n *\n * 1. The length from the first byte. You get this by\n * converting the byte to binary and counting the zeros\n * before a 1. Then you add 1 to that. Examples\n * 00011111 = length 4 because there are 3 zeros before a 1.\n * 00100000 = length 3 because there are 2 zeros before a 1.\n * 00000011 = length 7 because there are 6 zeros before a 1.\n *\n * 2. The bits used for length are removed from the first byte\n * Then all the bytes are merged into a value. NOTE: this\n * is not the case for id ebml tags as there id includes\n * length bits.\n *\n */\n\n\nexport var findEbml = function findEbml(bytes, paths) {\n paths = normalizePaths(paths);\n bytes = toUint8(bytes);\n var results = [];\n\n if (!paths.length) {\n return results;\n }\n\n var i = 0;\n\n while (i < bytes.length) {\n var id = getvint(bytes, i, false);\n var dataHeader = getvint(bytes, i + id.length);\n var dataStart = i + id.length + dataHeader.length; // dataSize is unknown or this is a live stream\n\n if (dataHeader.value === 0x7f) {\n dataHeader.value = getInfinityDataSize(id, bytes, dataStart);\n\n if (dataHeader.value !== bytes.length) {\n dataHeader.value -= dataStart;\n }\n }\n\n var dataEnd = dataStart + dataHeader.value > bytes.length ? bytes.length : dataStart + dataHeader.value;\n var data = bytes.subarray(dataStart, dataEnd);\n\n if (bytesMatch(paths[0], id.bytes)) {\n if (paths.length === 1) {\n // this is the end of the paths and we've found the tag we were\n // looking for\n results.push(data);\n } else {\n // recursively search for the next tag inside of the data\n // of this one\n results = results.concat(findEbml(data, paths.slice(1)));\n }\n }\n\n var totalLength = id.length + dataHeader.length + data.length; // move past this tag entirely, we are not looking for it\n\n i += totalLength;\n }\n\n return results;\n}; // see https://www.matroska.org/technical/basics.html#block-structure\n\nexport var decodeBlock = function decodeBlock(block, type, timestampScale, clusterTimestamp) {\n var duration;\n\n if (type === 'group') {\n duration = findEbml(block, [EBML_TAGS.BlockDuration])[0];\n\n if (duration) {\n duration = bytesToNumber(duration);\n duration = 1 / timestampScale * duration * timestampScale / 1000;\n }\n\n block = findEbml(block, [EBML_TAGS.Block])[0];\n type = 'block'; // treat data as a block after this point\n }\n\n var dv = new DataView(block.buffer, block.byteOffset, block.byteLength);\n var trackNumber = getvint(block, 0);\n var timestamp = dv.getInt16(trackNumber.length, false);\n var flags = block[trackNumber.length + 2];\n var data = block.subarray(trackNumber.length + 3); // pts/dts in seconds\n\n var ptsdts = 1 / timestampScale * (clusterTimestamp + timestamp) * timestampScale / 1000; // return the frame\n\n var parsed = {\n duration: duration,\n trackNumber: trackNumber.value,\n keyframe: type === 'simple' && flags >> 7 === 1,\n invisible: (flags & 0x08) >> 3 === 1,\n lacing: (flags & 0x06) >> 1,\n discardable: type === 'simple' && (flags & 0x01) === 1,\n frames: [],\n pts: ptsdts,\n dts: ptsdts,\n timestamp: timestamp\n };\n\n if (!parsed.lacing) {\n parsed.frames.push(data);\n return parsed;\n }\n\n var numberOfFrames = data[0] + 1;\n var frameSizes = [];\n var offset = 1; // Fixed\n\n if (parsed.lacing === 2) {\n var sizeOfFrame = (data.length - offset) / numberOfFrames;\n\n for (var i = 0; i < numberOfFrames; i++) {\n frameSizes.push(sizeOfFrame);\n }\n } // xiph\n\n\n if (parsed.lacing === 1) {\n for (var _i = 0; _i < numberOfFrames - 1; _i++) {\n var size = 0;\n\n do {\n size += data[offset];\n offset++;\n } while (data[offset - 1] === 0xFF);\n\n frameSizes.push(size);\n }\n } // ebml\n\n\n if (parsed.lacing === 3) {\n // first vint is unsinged\n // after that vints are singed and\n // based on a compounding size\n var _size = 0;\n\n for (var _i2 = 0; _i2 < numberOfFrames - 1; _i2++) {\n var vint = _i2 === 0 ? getvint(data, offset) : getvint(data, offset, true, true);\n _size += vint.value;\n frameSizes.push(_size);\n offset += vint.length;\n }\n }\n\n frameSizes.forEach(function (size) {\n parsed.frames.push(data.subarray(offset, offset + size));\n offset += size;\n });\n return parsed;\n}; // VP9 Codec Feature Metadata (CodecPrivate)\n// https://www.webmproject.org/docs/container/\n\nvar parseVp9Private = function parseVp9Private(bytes) {\n var i = 0;\n var params = {};\n\n while (i < bytes.length) {\n var id = bytes[i] & 0x7f;\n var len = bytes[i + 1];\n var val = void 0;\n\n if (len === 1) {\n val = bytes[i + 2];\n } else {\n val = bytes.subarray(i + 2, i + 2 + len);\n }\n\n if (id === 1) {\n params.profile = val;\n } else if (id === 2) {\n params.level = val;\n } else if (id === 3) {\n params.bitDepth = val;\n } else if (id === 4) {\n params.chromaSubsampling = val;\n } else {\n params[id] = val;\n }\n\n i += 2 + len;\n }\n\n return params;\n};\n\nexport var parseTracks = function parseTracks(bytes) {\n bytes = toUint8(bytes);\n var decodedTracks = [];\n var tracks = findEbml(bytes, [EBML_TAGS.Segment, EBML_TAGS.Tracks, EBML_TAGS.Track]);\n\n if (!tracks.length) {\n tracks = findEbml(bytes, [EBML_TAGS.Tracks, EBML_TAGS.Track]);\n }\n\n if (!tracks.length) {\n tracks = findEbml(bytes, [EBML_TAGS.Track]);\n }\n\n if (!tracks.length) {\n return decodedTracks;\n }\n\n tracks.forEach(function (track) {\n var trackType = findEbml(track, EBML_TAGS.TrackType)[0];\n\n if (!trackType || !trackType.length) {\n return;\n } // 1 is video, 2 is audio, 17 is subtitle\n // other values are unimportant in this context\n\n\n if (trackType[0] === 1) {\n trackType = 'video';\n } else if (trackType[0] === 2) {\n trackType = 'audio';\n } else if (trackType[0] === 17) {\n trackType = 'subtitle';\n } else {\n return;\n } // todo parse language\n\n\n var decodedTrack = {\n rawCodec: bytesToString(findEbml(track, [EBML_TAGS.CodecID])[0]),\n type: trackType,\n codecPrivate: findEbml(track, [EBML_TAGS.CodecPrivate])[0],\n number: bytesToNumber(findEbml(track, [EBML_TAGS.TrackNumber])[0]),\n defaultDuration: bytesToNumber(findEbml(track, [EBML_TAGS.DefaultDuration])[0]),\n default: findEbml(track, [EBML_TAGS.FlagDefault])[0],\n rawData: track\n };\n var codec = '';\n\n if (/V_MPEG4\\/ISO\\/AVC/.test(decodedTrack.rawCodec)) {\n codec = \"avc1.\" + getAvcCodec(decodedTrack.codecPrivate);\n } else if (/V_MPEGH\\/ISO\\/HEVC/.test(decodedTrack.rawCodec)) {\n codec = \"hev1.\" + getHvcCodec(decodedTrack.codecPrivate);\n } else if (/V_MPEG4\\/ISO\\/ASP/.test(decodedTrack.rawCodec)) {\n if (decodedTrack.codecPrivate) {\n codec = 'mp4v.20.' + decodedTrack.codecPrivate[4].toString();\n } else {\n codec = 'mp4v.20.9';\n }\n } else if (/^V_THEORA/.test(decodedTrack.rawCodec)) {\n codec = 'theora';\n } else if (/^V_VP8/.test(decodedTrack.rawCodec)) {\n codec = 'vp8';\n } else if (/^V_VP9/.test(decodedTrack.rawCodec)) {\n if (decodedTrack.codecPrivate) {\n var _parseVp9Private = parseVp9Private(decodedTrack.codecPrivate),\n profile = _parseVp9Private.profile,\n level = _parseVp9Private.level,\n bitDepth = _parseVp9Private.bitDepth,\n chromaSubsampling = _parseVp9Private.chromaSubsampling;\n\n codec = 'vp09.';\n codec += padStart(profile, 2, '0') + \".\";\n codec += padStart(level, 2, '0') + \".\";\n codec += padStart(bitDepth, 2, '0') + \".\";\n codec += \"\" + padStart(chromaSubsampling, 2, '0'); // Video -> Colour -> Ebml name\n\n var matrixCoefficients = findEbml(track, [0xE0, [0x55, 0xB0], [0x55, 0xB1]])[0] || [];\n var videoFullRangeFlag = findEbml(track, [0xE0, [0x55, 0xB0], [0x55, 0xB9]])[0] || [];\n var transferCharacteristics = findEbml(track, [0xE0, [0x55, 0xB0], [0x55, 0xBA]])[0] || [];\n var colourPrimaries = findEbml(track, [0xE0, [0x55, 0xB0], [0x55, 0xBB]])[0] || []; // if we find any optional codec parameter specify them all.\n\n if (matrixCoefficients.length || videoFullRangeFlag.length || transferCharacteristics.length || colourPrimaries.length) {\n codec += \".\" + padStart(colourPrimaries[0], 2, '0');\n codec += \".\" + padStart(transferCharacteristics[0], 2, '0');\n codec += \".\" + padStart(matrixCoefficients[0], 2, '0');\n codec += \".\" + padStart(videoFullRangeFlag[0], 2, '0');\n }\n } else {\n codec = 'vp9';\n }\n } else if (/^V_AV1/.test(decodedTrack.rawCodec)) {\n codec = \"av01.\" + getAv1Codec(decodedTrack.codecPrivate);\n } else if (/A_ALAC/.test(decodedTrack.rawCodec)) {\n codec = 'alac';\n } else if (/A_MPEG\\/L2/.test(decodedTrack.rawCodec)) {\n codec = 'mp2';\n } else if (/A_MPEG\\/L3/.test(decodedTrack.rawCodec)) {\n codec = 'mp3';\n } else if (/^A_AAC/.test(decodedTrack.rawCodec)) {\n if (decodedTrack.codecPrivate) {\n codec = 'mp4a.40.' + (decodedTrack.codecPrivate[0] >>> 3).toString();\n } else {\n codec = 'mp4a.40.2';\n }\n } else if (/^A_AC3/.test(decodedTrack.rawCodec)) {\n codec = 'ac-3';\n } else if (/^A_PCM/.test(decodedTrack.rawCodec)) {\n codec = 'pcm';\n } else if (/^A_MS\\/ACM/.test(decodedTrack.rawCodec)) {\n codec = 'speex';\n } else if (/^A_EAC3/.test(decodedTrack.rawCodec)) {\n codec = 'ec-3';\n } else if (/^A_VORBIS/.test(decodedTrack.rawCodec)) {\n codec = 'vorbis';\n } else if (/^A_FLAC/.test(decodedTrack.rawCodec)) {\n codec = 'flac';\n } else if (/^A_OPUS/.test(decodedTrack.rawCodec)) {\n codec = 'opus';\n }\n\n decodedTrack.codec = codec;\n decodedTracks.push(decodedTrack);\n });\n return decodedTracks.sort(function (a, b) {\n return a.number - b.number;\n });\n};\nexport var parseData = function parseData(data, tracks) {\n var allBlocks = [];\n var segment = findEbml(data, [EBML_TAGS.Segment])[0];\n var timestampScale = findEbml(segment, [EBML_TAGS.SegmentInfo, EBML_TAGS.TimestampScale])[0]; // in nanoseconds, defaults to 1ms\n\n if (timestampScale && timestampScale.length) {\n timestampScale = bytesToNumber(timestampScale);\n } else {\n timestampScale = 1000000;\n }\n\n var clusters = findEbml(segment, [EBML_TAGS.Cluster]);\n\n if (!tracks) {\n tracks = parseTracks(segment);\n }\n\n clusters.forEach(function (cluster, ci) {\n var simpleBlocks = findEbml(cluster, [EBML_TAGS.SimpleBlock]).map(function (b) {\n return {\n type: 'simple',\n data: b\n };\n });\n var blockGroups = findEbml(cluster, [EBML_TAGS.BlockGroup]).map(function (b) {\n return {\n type: 'group',\n data: b\n };\n });\n var timestamp = findEbml(cluster, [EBML_TAGS.Timestamp])[0] || 0;\n\n if (timestamp && timestamp.length) {\n timestamp = bytesToNumber(timestamp);\n } // get all blocks then sort them into the correct order\n\n\n var blocks = simpleBlocks.concat(blockGroups).sort(function (a, b) {\n return a.data.byteOffset - b.data.byteOffset;\n });\n blocks.forEach(function (block, bi) {\n var decoded = decodeBlock(block.data, block.type, timestampScale, timestamp);\n allBlocks.push(decoded);\n });\n });\n return {\n tracks: tracks,\n blocks: allBlocks\n };\n};","import { bytesMatch, toUint8 } from './byte-helpers.js';\nexport var NAL_TYPE_ONE = toUint8([0x00, 0x00, 0x00, 0x01]);\nexport var NAL_TYPE_TWO = toUint8([0x00, 0x00, 0x01]);\nexport var EMULATION_PREVENTION = toUint8([0x00, 0x00, 0x03]);\n/**\n * Expunge any \"Emulation Prevention\" bytes from a \"Raw Byte\n * Sequence Payload\"\n *\n * @param data {Uint8Array} the bytes of a RBSP from a NAL\n * unit\n * @return {Uint8Array} the RBSP without any Emulation\n * Prevention Bytes\n */\n\nexport var discardEmulationPreventionBytes = function discardEmulationPreventionBytes(bytes) {\n var positions = [];\n var i = 1; // Find all `Emulation Prevention Bytes`\n\n while (i < bytes.length - 2) {\n if (bytesMatch(bytes.subarray(i, i + 3), EMULATION_PREVENTION)) {\n positions.push(i + 2);\n i++;\n }\n\n i++;\n } // If no Emulation Prevention Bytes were found just return the original\n // array\n\n\n if (positions.length === 0) {\n return bytes;\n } // Create a new array to hold the NAL unit data\n\n\n var newLength = bytes.length - positions.length;\n var newData = new Uint8Array(newLength);\n var sourceIndex = 0;\n\n for (i = 0; i < newLength; sourceIndex++, i++) {\n if (sourceIndex === positions[0]) {\n // Skip this byte\n sourceIndex++; // Remove this position index\n\n positions.shift();\n }\n\n newData[i] = bytes[sourceIndex];\n }\n\n return newData;\n};\nexport var findNal = function findNal(bytes, dataType, types, nalLimit) {\n if (nalLimit === void 0) {\n nalLimit = Infinity;\n }\n\n bytes = toUint8(bytes);\n types = [].concat(types);\n var i = 0;\n var nalStart;\n var nalsFound = 0; // keep searching until:\n // we reach the end of bytes\n // we reach the maximum number of nals they want to seach\n // NOTE: that we disregard nalLimit when we have found the start\n // of the nal we want so that we can find the end of the nal we want.\n\n while (i < bytes.length && (nalsFound < nalLimit || nalStart)) {\n var nalOffset = void 0;\n\n if (bytesMatch(bytes.subarray(i), NAL_TYPE_ONE)) {\n nalOffset = 4;\n } else if (bytesMatch(bytes.subarray(i), NAL_TYPE_TWO)) {\n nalOffset = 3;\n } // we are unsynced,\n // find the next nal unit\n\n\n if (!nalOffset) {\n i++;\n continue;\n }\n\n nalsFound++;\n\n if (nalStart) {\n return discardEmulationPreventionBytes(bytes.subarray(nalStart, i));\n }\n\n var nalType = void 0;\n\n if (dataType === 'h264') {\n nalType = bytes[i + nalOffset] & 0x1f;\n } else if (dataType === 'h265') {\n nalType = bytes[i + nalOffset] >> 1 & 0x3f;\n }\n\n if (types.indexOf(nalType) !== -1) {\n nalStart = i + nalOffset;\n } // nal header is 1 length for h264, and 2 for h265\n\n\n i += nalOffset + (dataType === 'h264' ? 1 : 2);\n }\n\n return bytes.subarray(0, 0);\n};\nexport var findH264Nal = function findH264Nal(bytes, type, nalLimit) {\n return findNal(bytes, 'h264', type, nalLimit);\n};\nexport var findH265Nal = function findH265Nal(bytes, type, nalLimit) {\n return findNal(bytes, 'h265', type, nalLimit);\n};","import { toUint8, bytesMatch } from './byte-helpers.js';\nimport { findBox } from './mp4-helpers.js';\nimport { findEbml, EBML_TAGS } from './ebml-helpers.js';\nimport { getId3Offset } from './id3-helpers.js';\nimport { findH264Nal, findH265Nal } from './nal-helpers.js';\nvar CONSTANTS = {\n // \"webm\" string literal in hex\n 'webm': toUint8([0x77, 0x65, 0x62, 0x6d]),\n // \"matroska\" string literal in hex\n 'matroska': toUint8([0x6d, 0x61, 0x74, 0x72, 0x6f, 0x73, 0x6b, 0x61]),\n // \"fLaC\" string literal in hex\n 'flac': toUint8([0x66, 0x4c, 0x61, 0x43]),\n // \"OggS\" string literal in hex\n 'ogg': toUint8([0x4f, 0x67, 0x67, 0x53]),\n // ac-3 sync byte, also works for ec-3 as that is simply a codec\n // of ac-3\n 'ac3': toUint8([0x0b, 0x77]),\n // \"RIFF\" string literal in hex used for wav and avi\n 'riff': toUint8([0x52, 0x49, 0x46, 0x46]),\n // \"AVI\" string literal in hex\n 'avi': toUint8([0x41, 0x56, 0x49]),\n // \"WAVE\" string literal in hex\n 'wav': toUint8([0x57, 0x41, 0x56, 0x45]),\n // \"ftyp3g\" string literal in hex\n '3gp': toUint8([0x66, 0x74, 0x79, 0x70, 0x33, 0x67]),\n // \"ftyp\" string literal in hex\n 'mp4': toUint8([0x66, 0x74, 0x79, 0x70]),\n // \"styp\" string literal in hex\n 'fmp4': toUint8([0x73, 0x74, 0x79, 0x70]),\n // \"ftypqt\" string literal in hex\n 'mov': toUint8([0x66, 0x74, 0x79, 0x70, 0x71, 0x74]),\n // moov string literal in hex\n 'moov': toUint8([0x6D, 0x6F, 0x6F, 0x76]),\n // moof string literal in hex\n 'moof': toUint8([0x6D, 0x6F, 0x6F, 0x66])\n};\nvar _isLikely = {\n aac: function aac(bytes) {\n var offset = getId3Offset(bytes);\n return bytesMatch(bytes, [0xFF, 0x10], {\n offset: offset,\n mask: [0xFF, 0x16]\n });\n },\n mp3: function mp3(bytes) {\n var offset = getId3Offset(bytes);\n return bytesMatch(bytes, [0xFF, 0x02], {\n offset: offset,\n mask: [0xFF, 0x06]\n });\n },\n webm: function webm(bytes) {\n var docType = findEbml(bytes, [EBML_TAGS.EBML, EBML_TAGS.DocType])[0]; // check if DocType EBML tag is webm\n\n return bytesMatch(docType, CONSTANTS.webm);\n },\n mkv: function mkv(bytes) {\n var docType = findEbml(bytes, [EBML_TAGS.EBML, EBML_TAGS.DocType])[0]; // check if DocType EBML tag is matroska\n\n return bytesMatch(docType, CONSTANTS.matroska);\n },\n mp4: function mp4(bytes) {\n // if this file is another base media file format, it is not mp4\n if (_isLikely['3gp'](bytes) || _isLikely.mov(bytes)) {\n return false;\n } // if this file starts with a ftyp or styp box its mp4\n\n\n if (bytesMatch(bytes, CONSTANTS.mp4, {\n offset: 4\n }) || bytesMatch(bytes, CONSTANTS.fmp4, {\n offset: 4\n })) {\n return true;\n } // if this file starts with a moof/moov box its mp4\n\n\n if (bytesMatch(bytes, CONSTANTS.moof, {\n offset: 4\n }) || bytesMatch(bytes, CONSTANTS.moov, {\n offset: 4\n })) {\n return true;\n }\n },\n mov: function mov(bytes) {\n return bytesMatch(bytes, CONSTANTS.mov, {\n offset: 4\n });\n },\n '3gp': function gp(bytes) {\n return bytesMatch(bytes, CONSTANTS['3gp'], {\n offset: 4\n });\n },\n ac3: function ac3(bytes) {\n var offset = getId3Offset(bytes);\n return bytesMatch(bytes, CONSTANTS.ac3, {\n offset: offset\n });\n },\n ts: function ts(bytes) {\n if (bytes.length < 189 && bytes.length >= 1) {\n return bytes[0] === 0x47;\n }\n\n var i = 0; // check the first 376 bytes for two matching sync bytes\n\n while (i + 188 < bytes.length && i < 188) {\n if (bytes[i] === 0x47 && bytes[i + 188] === 0x47) {\n return true;\n }\n\n i += 1;\n }\n\n return false;\n },\n flac: function flac(bytes) {\n var offset = getId3Offset(bytes);\n return bytesMatch(bytes, CONSTANTS.flac, {\n offset: offset\n });\n },\n ogg: function ogg(bytes) {\n return bytesMatch(bytes, CONSTANTS.ogg);\n },\n avi: function avi(bytes) {\n return bytesMatch(bytes, CONSTANTS.riff) && bytesMatch(bytes, CONSTANTS.avi, {\n offset: 8\n });\n },\n wav: function wav(bytes) {\n return bytesMatch(bytes, CONSTANTS.riff) && bytesMatch(bytes, CONSTANTS.wav, {\n offset: 8\n });\n },\n 'h264': function h264(bytes) {\n // find seq_parameter_set_rbsp\n return findH264Nal(bytes, 7, 3).length;\n },\n 'h265': function h265(bytes) {\n // find video_parameter_set_rbsp or seq_parameter_set_rbsp\n return findH265Nal(bytes, [32, 33], 3).length;\n }\n}; // get all the isLikely functions\n// but make sure 'ts' is above h264 and h265\n// but below everything else as it is the least specific\n\nvar isLikelyTypes = Object.keys(_isLikely) // remove ts, h264, h265\n.filter(function (t) {\n return t !== 'ts' && t !== 'h264' && t !== 'h265';\n}) // add it back to the bottom\n.concat(['ts', 'h264', 'h265']); // make sure we are dealing with uint8 data.\n\nisLikelyTypes.forEach(function (type) {\n var isLikelyFn = _isLikely[type];\n\n _isLikely[type] = function (bytes) {\n return isLikelyFn(toUint8(bytes));\n };\n}); // export after wrapping\n\nexport var isLikely = _isLikely; // A useful list of file signatures can be found here\n// https://en.wikipedia.org/wiki/List_of_file_signatures\n\nexport var detectContainerForBytes = function detectContainerForBytes(bytes) {\n bytes = toUint8(bytes);\n\n for (var i = 0; i < isLikelyTypes.length; i++) {\n var type = isLikelyTypes[i];\n\n if (isLikely[type](bytes)) {\n return type;\n }\n }\n\n return '';\n}; // fmp4 is not a container\n\nexport var isLikelyFmp4MediaSegment = function isLikelyFmp4MediaSegment(bytes) {\n return findBox(bytes, ['moof']).length > 0;\n};","/**\n * @license\n * Video.js 8.6.1 \n * Copyright Brightcove, Inc. \n * Available under Apache License Version 2.0\n * \n *\n * Includes vtt.js \n * Available under Apache License Version 2.0\n * \n */\n\nimport window$1 from 'global/window';\nimport document from 'global/document';\nimport keycode from 'keycode';\nimport safeParseTuple from 'safe-json-parse/tuple';\nimport XHR from '@videojs/xhr';\nimport vtt from 'videojs-vtt.js';\nimport _resolveUrl from '@videojs/vhs-utils/es/resolve-url.js';\nimport _extends from '@babel/runtime/helpers/extends';\nimport { Parser } from 'm3u8-parser';\nimport { DEFAULT_VIDEO_CODEC, DEFAULT_AUDIO_CODEC, parseCodecs, muxerSupportsCodec, browserSupportsCodec, translateLegacyCodec, codecsFromDefault, isAudioCodec, getMimeForCodec } from '@videojs/vhs-utils/es/codecs.js';\nimport { simpleTypeFromSourceType } from '@videojs/vhs-utils/es/media-types.js';\nimport { isArrayBufferView, concatTypedArrays, stringToBytes, toUint8 } from '@videojs/vhs-utils/es/byte-helpers';\nimport { generateSidxKey, parseUTCTiming, parse, addSidxSegmentsToPlaylist } from 'mpd-parser';\nimport parseSidx from 'mux.js/lib/tools/parse-sidx';\nimport { getId3Offset } from '@videojs/vhs-utils/es/id3-helpers';\nimport { detectContainerForBytes, isLikelyFmp4MediaSegment } from '@videojs/vhs-utils/es/containers';\nimport { ONE_SECOND_IN_TS } from 'mux.js/lib/utils/clock';\n\nvar version$6 = \"8.6.1\";\n\n/**\n * An Object that contains lifecycle hooks as keys which point to an array\n * of functions that are run when a lifecycle is triggered\n *\n * @private\n */\nconst hooks_ = {};\n\n/**\n * Get a list of hooks for a specific lifecycle\n *\n * @param {string} type\n * the lifecycle to get hooks from\n *\n * @param {Function|Function[]} [fn]\n * Optionally add a hook (or hooks) to the lifecycle that your are getting.\n *\n * @return {Array}\n * an array of hooks, or an empty array if there are none.\n */\nconst hooks = function (type, fn) {\n hooks_[type] = hooks_[type] || [];\n if (fn) {\n hooks_[type] = hooks_[type].concat(fn);\n }\n return hooks_[type];\n};\n\n/**\n * Add a function hook to a specific videojs lifecycle.\n *\n * @param {string} type\n * the lifecycle to hook the function to.\n *\n * @param {Function|Function[]}\n * The function or array of functions to attach.\n */\nconst hook = function (type, fn) {\n hooks(type, fn);\n};\n\n/**\n * Remove a hook from a specific videojs lifecycle.\n *\n * @param {string} type\n * the lifecycle that the function hooked to\n *\n * @param {Function} fn\n * The hooked function to remove\n *\n * @return {boolean}\n * The function that was removed or undef\n */\nconst removeHook = function (type, fn) {\n const index = hooks(type).indexOf(fn);\n if (index <= -1) {\n return false;\n }\n hooks_[type] = hooks_[type].slice();\n hooks_[type].splice(index, 1);\n return true;\n};\n\n/**\n * Add a function hook that will only run once to a specific videojs lifecycle.\n *\n * @param {string} type\n * the lifecycle to hook the function to.\n *\n * @param {Function|Function[]}\n * The function or array of functions to attach.\n */\nconst hookOnce = function (type, fn) {\n hooks(type, [].concat(fn).map(original => {\n const wrapper = (...args) => {\n removeHook(type, wrapper);\n return original(...args);\n };\n return wrapper;\n }));\n};\n\n/**\n * @file fullscreen-api.js\n * @module fullscreen-api\n */\n\n/**\n * Store the browser-specific methods for the fullscreen API.\n *\n * @type {Object}\n * @see [Specification]{@link https://fullscreen.spec.whatwg.org}\n * @see [Map Approach From Screenfull.js]{@link https://github.com/sindresorhus/screenfull.js}\n */\nconst FullscreenApi = {\n prefixed: true\n};\n\n// browser API methods\nconst apiMap = [['requestFullscreen', 'exitFullscreen', 'fullscreenElement', 'fullscreenEnabled', 'fullscreenchange', 'fullscreenerror', 'fullscreen'],\n// WebKit\n['webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitFullscreenElement', 'webkitFullscreenEnabled', 'webkitfullscreenchange', 'webkitfullscreenerror', '-webkit-full-screen']];\nconst specApi = apiMap[0];\nlet browserApi;\n\n// determine the supported set of functions\nfor (let i = 0; i < apiMap.length; i++) {\n // check for exitFullscreen function\n if (apiMap[i][1] in document) {\n browserApi = apiMap[i];\n break;\n }\n}\n\n// map the browser API names to the spec API names\nif (browserApi) {\n for (let i = 0; i < browserApi.length; i++) {\n FullscreenApi[specApi[i]] = browserApi[i];\n }\n FullscreenApi.prefixed = browserApi[0] !== specApi[0];\n}\n\n/**\n * @file create-logger.js\n * @module create-logger\n */\n\n// This is the private tracking variable for the logging history.\nlet history = [];\n\n/**\n * Log messages to the console and history based on the type of message\n *\n * @private\n * @param {string} name\n * The name of the console method to use.\n *\n * @param {Object} log\n * The arguments to be passed to the matching console method.\n *\n * @param {string} [styles]\n * styles for name\n */\nconst LogByTypeFactory = (name, log, styles) => (type, level, args) => {\n const lvl = log.levels[level];\n const lvlRegExp = new RegExp(`^(${lvl})$`);\n let resultName = name;\n if (type !== 'log') {\n // Add the type to the front of the message when it's not \"log\".\n args.unshift(type.toUpperCase() + ':');\n }\n if (styles) {\n resultName = `%c${name}`;\n args.unshift(styles);\n }\n\n // Add console prefix after adding to history.\n args.unshift(resultName + ':');\n\n // Add a clone of the args at this point to history.\n if (history) {\n history.push([].concat(args));\n\n // only store 1000 history entries\n const splice = history.length - 1000;\n history.splice(0, splice > 0 ? splice : 0);\n }\n\n // If there's no console then don't try to output messages, but they will\n // still be stored in history.\n if (!window$1.console) {\n return;\n }\n\n // Was setting these once outside of this function, but containing them\n // in the function makes it easier to test cases where console doesn't exist\n // when the module is executed.\n let fn = window$1.console[type];\n if (!fn && type === 'debug') {\n // Certain browsers don't have support for console.debug. For those, we\n // should default to the closest comparable log.\n fn = window$1.console.info || window$1.console.log;\n }\n\n // Bail out if there's no console or if this type is not allowed by the\n // current logging level.\n if (!fn || !lvl || !lvlRegExp.test(type)) {\n return;\n }\n fn[Array.isArray(args) ? 'apply' : 'call'](window$1.console, args);\n};\nfunction createLogger$1(name, delimiter = ':', styles = '') {\n // This is the private tracking variable for logging level.\n let level = 'info';\n\n // the curried logByType bound to the specific log and history\n let logByType;\n\n /**\n * Logs plain debug messages. Similar to `console.log`.\n *\n * Due to [limitations](https://github.com/jsdoc3/jsdoc/issues/955#issuecomment-313829149)\n * of our JSDoc template, we cannot properly document this as both a function\n * and a namespace, so its function signature is documented here.\n *\n * #### Arguments\n * ##### *args\n * *[]\n *\n * Any combination of values that could be passed to `console.log()`.\n *\n * #### Return Value\n *\n * `undefined`\n *\n * @namespace\n * @param {...*} args\n * One or more messages or objects that should be logged.\n */\n const log = function (...args) {\n logByType('log', level, args);\n };\n\n // This is the logByType helper that the logging methods below use\n logByType = LogByTypeFactory(name, log, styles);\n\n /**\n * Create a new subLogger which chains the old name to the new name.\n *\n * For example, doing `videojs.log.createLogger('player')` and then using that logger will log the following:\n * ```js\n * mylogger('foo');\n * // > VIDEOJS: player: foo\n * ```\n *\n * @param {string} subName\n * The name to add call the new logger\n * @param {string} [subDelimiter]\n * Optional delimiter\n * @param {string} [subStyles]\n * Optional styles\n * @return {Object}\n */\n log.createLogger = (subName, subDelimiter, subStyles) => {\n const resultDelimiter = subDelimiter !== undefined ? subDelimiter : delimiter;\n const resultStyles = subStyles !== undefined ? subStyles : styles;\n const resultName = `${name} ${resultDelimiter} ${subName}`;\n return createLogger$1(resultName, resultDelimiter, resultStyles);\n };\n\n /**\n * Create a new logger.\n *\n * @param {string} newName\n * The name for the new logger\n * @param {string} [newDelimiter]\n * Optional delimiter\n * @param {string} [newStyles]\n * Optional styles\n * @return {Object}\n */\n log.createNewLogger = (newName, newDelimiter, newStyles) => {\n return createLogger$1(newName, newDelimiter, newStyles);\n };\n\n /**\n * Enumeration of available logging levels, where the keys are the level names\n * and the values are `|`-separated strings containing logging methods allowed\n * in that logging level. These strings are used to create a regular expression\n * matching the function name being called.\n *\n * Levels provided by Video.js are:\n *\n * - `off`: Matches no calls. Any value that can be cast to `false` will have\n * this effect. The most restrictive.\n * - `all`: Matches only Video.js-provided functions (`debug`, `log`,\n * `log.warn`, and `log.error`).\n * - `debug`: Matches `log.debug`, `log`, `log.warn`, and `log.error` calls.\n * - `info` (default): Matches `log`, `log.warn`, and `log.error` calls.\n * - `warn`: Matches `log.warn` and `log.error` calls.\n * - `error`: Matches only `log.error` calls.\n *\n * @type {Object}\n */\n log.levels = {\n all: 'debug|log|warn|error',\n off: '',\n debug: 'debug|log|warn|error',\n info: 'log|warn|error',\n warn: 'warn|error',\n error: 'error',\n DEFAULT: level\n };\n\n /**\n * Get or set the current logging level.\n *\n * If a string matching a key from {@link module:log.levels} is provided, acts\n * as a setter.\n *\n * @param {'all'|'debug'|'info'|'warn'|'error'|'off'} [lvl]\n * Pass a valid level to set a new logging level.\n *\n * @return {string}\n * The current logging level.\n */\n log.level = lvl => {\n if (typeof lvl === 'string') {\n if (!log.levels.hasOwnProperty(lvl)) {\n throw new Error(`\"${lvl}\" in not a valid log level`);\n }\n level = lvl;\n }\n return level;\n };\n\n /**\n * Returns an array containing everything that has been logged to the history.\n *\n * This array is a shallow clone of the internal history record. However, its\n * contents are _not_ cloned; so, mutating objects inside this array will\n * mutate them in history.\n *\n * @return {Array}\n */\n log.history = () => history ? [].concat(history) : [];\n\n /**\n * Allows you to filter the history by the given logger name\n *\n * @param {string} fname\n * The name to filter by\n *\n * @return {Array}\n * The filtered list to return\n */\n log.history.filter = fname => {\n return (history || []).filter(historyItem => {\n // if the first item in each historyItem includes `fname`, then it's a match\n return new RegExp(`.*${fname}.*`).test(historyItem[0]);\n });\n };\n\n /**\n * Clears the internal history tracking, but does not prevent further history\n * tracking.\n */\n log.history.clear = () => {\n if (history) {\n history.length = 0;\n }\n };\n\n /**\n * Disable history tracking if it is currently enabled.\n */\n log.history.disable = () => {\n if (history !== null) {\n history.length = 0;\n history = null;\n }\n };\n\n /**\n * Enable history tracking if it is currently disabled.\n */\n log.history.enable = () => {\n if (history === null) {\n history = [];\n }\n };\n\n /**\n * Logs error messages. Similar to `console.error`.\n *\n * @param {...*} args\n * One or more messages or objects that should be logged as an error\n */\n log.error = (...args) => logByType('error', level, args);\n\n /**\n * Logs warning messages. Similar to `console.warn`.\n *\n * @param {...*} args\n * One or more messages or objects that should be logged as a warning.\n */\n log.warn = (...args) => logByType('warn', level, args);\n\n /**\n * Logs debug messages. Similar to `console.debug`, but may also act as a comparable\n * log if `console.debug` is not available\n *\n * @param {...*} args\n * One or more messages or objects that should be logged as debug.\n */\n log.debug = (...args) => logByType('debug', level, args);\n return log;\n}\n\n/**\n * @file log.js\n * @module log\n */\nconst log$1 = createLogger$1('VIDEOJS');\nconst createLogger = log$1.createLogger;\n\n/**\n * @file obj.js\n * @module obj\n */\n\n/**\n * @callback obj:EachCallback\n *\n * @param {*} value\n * The current key for the object that is being iterated over.\n *\n * @param {string} key\n * The current key-value for object that is being iterated over\n */\n\n/**\n * @callback obj:ReduceCallback\n *\n * @param {*} accum\n * The value that is accumulating over the reduce loop.\n *\n * @param {*} value\n * The current key for the object that is being iterated over.\n *\n * @param {string} key\n * The current key-value for object that is being iterated over\n *\n * @return {*}\n * The new accumulated value.\n */\nconst toString = Object.prototype.toString;\n\n/**\n * Get the keys of an Object\n *\n * @param {Object}\n * The Object to get the keys from\n *\n * @return {string[]}\n * An array of the keys from the object. Returns an empty array if the\n * object passed in was invalid or had no keys.\n *\n * @private\n */\nconst keys = function (object) {\n return isObject(object) ? Object.keys(object) : [];\n};\n\n/**\n * Array-like iteration for objects.\n *\n * @param {Object} object\n * The object to iterate over\n *\n * @param {obj:EachCallback} fn\n * The callback function which is called for each key in the object.\n */\nfunction each(object, fn) {\n keys(object).forEach(key => fn(object[key], key));\n}\n\n/**\n * Array-like reduce for objects.\n *\n * @param {Object} object\n * The Object that you want to reduce.\n *\n * @param {Function} fn\n * A callback function which is called for each key in the object. It\n * receives the accumulated value and the per-iteration value and key\n * as arguments.\n *\n * @param {*} [initial = 0]\n * Starting value\n *\n * @return {*}\n * The final accumulated value.\n */\nfunction reduce(object, fn, initial = 0) {\n return keys(object).reduce((accum, key) => fn(accum, object[key], key), initial);\n}\n\n/**\n * Returns whether a value is an object of any kind - including DOM nodes,\n * arrays, regular expressions, etc. Not functions, though.\n *\n * This avoids the gotcha where using `typeof` on a `null` value\n * results in `'object'`.\n *\n * @param {Object} value\n * @return {boolean}\n */\nfunction isObject(value) {\n return !!value && typeof value === 'object';\n}\n\n/**\n * Returns whether an object appears to be a \"plain\" object - that is, a\n * direct instance of `Object`.\n *\n * @param {Object} value\n * @return {boolean}\n */\nfunction isPlain(value) {\n return isObject(value) && toString.call(value) === '[object Object]' && value.constructor === Object;\n}\n\n/**\n * Merge two objects recursively.\n *\n * Performs a deep merge like\n * {@link https://lodash.com/docs/4.17.10#merge|lodash.merge}, but only merges\n * plain objects (not arrays, elements, or anything else).\n *\n * Non-plain object values will be copied directly from the right-most\n * argument.\n *\n * @param {Object[]} sources\n * One or more objects to merge into a new object.\n *\n * @return {Object}\n * A new object that is the merged result of all sources.\n */\nfunction merge$1(...sources) {\n const result = {};\n sources.forEach(source => {\n if (!source) {\n return;\n }\n each(source, (value, key) => {\n if (!isPlain(value)) {\n result[key] = value;\n return;\n }\n if (!isPlain(result[key])) {\n result[key] = {};\n }\n result[key] = merge$1(result[key], value);\n });\n });\n return result;\n}\n\n/**\n * Returns an array of values for a given object\n *\n * @param {Object} source - target object\n * @return {Array} - object values\n */\nfunction values(source = {}) {\n const result = [];\n for (const key in source) {\n if (source.hasOwnProperty(key)) {\n const value = source[key];\n result.push(value);\n }\n }\n return result;\n}\n\n/**\n * Object.defineProperty but \"lazy\", which means that the value is only set after\n * it is retrieved the first time, rather than being set right away.\n *\n * @param {Object} obj the object to set the property on\n * @param {string} key the key for the property to set\n * @param {Function} getValue the function used to get the value when it is needed.\n * @param {boolean} setter whether a setter should be allowed or not\n */\nfunction defineLazyProperty(obj, key, getValue, setter = true) {\n const set = value => Object.defineProperty(obj, key, {\n value,\n enumerable: true,\n writable: true\n });\n const options = {\n configurable: true,\n enumerable: true,\n get() {\n const value = getValue();\n set(value);\n return value;\n }\n };\n if (setter) {\n options.set = set;\n }\n return Object.defineProperty(obj, key, options);\n}\n\nvar Obj = /*#__PURE__*/Object.freeze({\n __proto__: null,\n each: each,\n reduce: reduce,\n isObject: isObject,\n isPlain: isPlain,\n merge: merge$1,\n values: values,\n defineLazyProperty: defineLazyProperty\n});\n\n/**\n * @file browser.js\n * @module browser\n */\n\n/**\n * Whether or not this device is an iPod.\n *\n * @static\n * @type {Boolean}\n */\nlet IS_IPOD = false;\n\n/**\n * The detected iOS version - or `null`.\n *\n * @static\n * @type {string|null}\n */\nlet IOS_VERSION = null;\n\n/**\n * Whether or not this is an Android device.\n *\n * @static\n * @type {Boolean}\n */\nlet IS_ANDROID = false;\n\n/**\n * The detected Android version - or `null` if not Android or indeterminable.\n *\n * @static\n * @type {number|string|null}\n */\nlet ANDROID_VERSION;\n\n/**\n * Whether or not this is Mozilla Firefox.\n *\n * @static\n * @type {Boolean}\n */\nlet IS_FIREFOX = false;\n\n/**\n * Whether or not this is Microsoft Edge.\n *\n * @static\n * @type {Boolean}\n */\nlet IS_EDGE = false;\n\n/**\n * Whether or not this is any Chromium Browser\n *\n * @static\n * @type {Boolean}\n */\nlet IS_CHROMIUM = false;\n\n/**\n * Whether or not this is any Chromium browser that is not Edge.\n *\n * This will also be `true` for Chrome on iOS, which will have different support\n * as it is actually Safari under the hood.\n *\n * Deprecated, as the behaviour to not match Edge was to prevent Legacy Edge's UA matching.\n * IS_CHROMIUM should be used instead.\n * \"Chromium but not Edge\" could be explicitly tested with IS_CHROMIUM && !IS_EDGE\n *\n * @static\n * @deprecated\n * @type {Boolean}\n */\nlet IS_CHROME = false;\n\n/**\n * The detected Chromium version - or `null`.\n *\n * @static\n * @type {number|null}\n */\nlet CHROMIUM_VERSION = null;\n\n/**\n * The detected Google Chrome version - or `null`.\n * This has always been the _Chromium_ version, i.e. would return on Chromium Edge.\n * Deprecated, use CHROMIUM_VERSION instead.\n *\n * @static\n * @deprecated\n * @type {number|null}\n */\nlet CHROME_VERSION = null;\n\n/**\n * The detected Internet Explorer version - or `null`.\n *\n * @static\n * @deprecated\n * @type {number|null}\n */\nlet IE_VERSION = null;\n\n/**\n * Whether or not this is desktop Safari.\n *\n * @static\n * @type {Boolean}\n */\nlet IS_SAFARI = false;\n\n/**\n * Whether or not this is a Windows machine.\n *\n * @static\n * @type {Boolean}\n */\nlet IS_WINDOWS = false;\n\n/**\n * Whether or not this device is an iPad.\n *\n * @static\n * @type {Boolean}\n */\nlet IS_IPAD = false;\n\n/**\n * Whether or not this device is an iPhone.\n *\n * @static\n * @type {Boolean}\n */\n// The Facebook app's UIWebView identifies as both an iPhone and iPad, so\n// to identify iPhones, we need to exclude iPads.\n// http://artsy.github.io/blog/2012/10/18/the-perils-of-ios-user-agent-sniffing/\nlet IS_IPHONE = false;\n\n/**\n * Whether or not this device is touch-enabled.\n *\n * @static\n * @const\n * @type {Boolean}\n */\nconst TOUCH_ENABLED = Boolean(isReal() && ('ontouchstart' in window$1 || window$1.navigator.maxTouchPoints || window$1.DocumentTouch && window$1.document instanceof window$1.DocumentTouch));\nconst UAD = window$1.navigator && window$1.navigator.userAgentData;\nif (UAD) {\n // If userAgentData is present, use it instead of userAgent to avoid warnings\n // Currently only implemented on Chromium\n // userAgentData does not expose Android version, so ANDROID_VERSION remains `null`\n\n IS_ANDROID = UAD.platform === 'Android';\n IS_EDGE = Boolean(UAD.brands.find(b => b.brand === 'Microsoft Edge'));\n IS_CHROMIUM = Boolean(UAD.brands.find(b => b.brand === 'Chromium'));\n IS_CHROME = !IS_EDGE && IS_CHROMIUM;\n CHROMIUM_VERSION = CHROME_VERSION = (UAD.brands.find(b => b.brand === 'Chromium') || {}).version || null;\n IS_WINDOWS = UAD.platform === 'Windows';\n}\n\n// If the browser is not Chromium, either userAgentData is not present which could be an old Chromium browser,\n// or it's a browser that has added userAgentData since that we don't have tests for yet. In either case,\n// the checks need to be made agiainst the regular userAgent string.\nif (!IS_CHROMIUM) {\n const USER_AGENT = window$1.navigator && window$1.navigator.userAgent || '';\n IS_IPOD = /iPod/i.test(USER_AGENT);\n IOS_VERSION = function () {\n const match = USER_AGENT.match(/OS (\\d+)_/i);\n if (match && match[1]) {\n return match[1];\n }\n return null;\n }();\n IS_ANDROID = /Android/i.test(USER_AGENT);\n ANDROID_VERSION = function () {\n // This matches Android Major.Minor.Patch versions\n // ANDROID_VERSION is Major.Minor as a Number, if Minor isn't available, then only Major is returned\n const match = USER_AGENT.match(/Android (\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))*/i);\n if (!match) {\n return null;\n }\n const major = match[1] && parseFloat(match[1]);\n const minor = match[2] && parseFloat(match[2]);\n if (major && minor) {\n return parseFloat(match[1] + '.' + match[2]);\n } else if (major) {\n return major;\n }\n return null;\n }();\n IS_FIREFOX = /Firefox/i.test(USER_AGENT);\n IS_EDGE = /Edg/i.test(USER_AGENT);\n IS_CHROMIUM = /Chrome/i.test(USER_AGENT) || /CriOS/i.test(USER_AGENT);\n IS_CHROME = !IS_EDGE && IS_CHROMIUM;\n CHROMIUM_VERSION = CHROME_VERSION = function () {\n const match = USER_AGENT.match(/(Chrome|CriOS)\\/(\\d+)/);\n if (match && match[2]) {\n return parseFloat(match[2]);\n }\n return null;\n }();\n IE_VERSION = function () {\n const result = /MSIE\\s(\\d+)\\.\\d/.exec(USER_AGENT);\n let version = result && parseFloat(result[1]);\n if (!version && /Trident\\/7.0/i.test(USER_AGENT) && /rv:11.0/.test(USER_AGENT)) {\n // IE 11 has a different user agent string than other IE versions\n version = 11.0;\n }\n return version;\n }();\n IS_SAFARI = /Safari/i.test(USER_AGENT) && !IS_CHROME && !IS_ANDROID && !IS_EDGE;\n IS_WINDOWS = /Windows/i.test(USER_AGENT);\n IS_IPAD = /iPad/i.test(USER_AGENT) || IS_SAFARI && TOUCH_ENABLED && !/iPhone/i.test(USER_AGENT);\n IS_IPHONE = /iPhone/i.test(USER_AGENT) && !IS_IPAD;\n}\n\n/**\n * Whether or not this is an iOS device.\n *\n * @static\n * @const\n * @type {Boolean}\n */\nconst IS_IOS = IS_IPHONE || IS_IPAD || IS_IPOD;\n\n/**\n * Whether or not this is any flavor of Safari - including iOS.\n *\n * @static\n * @const\n * @type {Boolean}\n */\nconst IS_ANY_SAFARI = (IS_SAFARI || IS_IOS) && !IS_CHROME;\n\nvar browser = /*#__PURE__*/Object.freeze({\n __proto__: null,\n get IS_IPOD () { return IS_IPOD; },\n get IOS_VERSION () { return IOS_VERSION; },\n get IS_ANDROID () { return IS_ANDROID; },\n get ANDROID_VERSION () { return ANDROID_VERSION; },\n get IS_FIREFOX () { return IS_FIREFOX; },\n get IS_EDGE () { return IS_EDGE; },\n get IS_CHROMIUM () { return IS_CHROMIUM; },\n get IS_CHROME () { return IS_CHROME; },\n get CHROMIUM_VERSION () { return CHROMIUM_VERSION; },\n get CHROME_VERSION () { return CHROME_VERSION; },\n get IE_VERSION () { return IE_VERSION; },\n get IS_SAFARI () { return IS_SAFARI; },\n get IS_WINDOWS () { return IS_WINDOWS; },\n get IS_IPAD () { return IS_IPAD; },\n get IS_IPHONE () { return IS_IPHONE; },\n TOUCH_ENABLED: TOUCH_ENABLED,\n IS_IOS: IS_IOS,\n IS_ANY_SAFARI: IS_ANY_SAFARI\n});\n\n/**\n * @file dom.js\n * @module dom\n */\n\n/**\n * Detect if a value is a string with any non-whitespace characters.\n *\n * @private\n * @param {string} str\n * The string to check\n *\n * @return {boolean}\n * Will be `true` if the string is non-blank, `false` otherwise.\n *\n */\nfunction isNonBlankString(str) {\n // we use str.trim as it will trim any whitespace characters\n // from the front or back of non-whitespace characters. aka\n // Any string that contains non-whitespace characters will\n // still contain them after `trim` but whitespace only strings\n // will have a length of 0, failing this check.\n return typeof str === 'string' && Boolean(str.trim());\n}\n\n/**\n * Throws an error if the passed string has whitespace. This is used by\n * class methods to be relatively consistent with the classList API.\n *\n * @private\n * @param {string} str\n * The string to check for whitespace.\n *\n * @throws {Error}\n * Throws an error if there is whitespace in the string.\n */\nfunction throwIfWhitespace(str) {\n // str.indexOf instead of regex because str.indexOf is faster performance wise.\n if (str.indexOf(' ') >= 0) {\n throw new Error('class has illegal whitespace characters');\n }\n}\n\n/**\n * Whether the current DOM interface appears to be real (i.e. not simulated).\n *\n * @return {boolean}\n * Will be `true` if the DOM appears to be real, `false` otherwise.\n */\nfunction isReal() {\n // Both document and window will never be undefined thanks to `global`.\n return document === window$1.document;\n}\n\n/**\n * Determines, via duck typing, whether or not a value is a DOM element.\n *\n * @param {*} value\n * The value to check.\n *\n * @return {boolean}\n * Will be `true` if the value is a DOM element, `false` otherwise.\n */\nfunction isEl(value) {\n return isObject(value) && value.nodeType === 1;\n}\n\n/**\n * Determines if the current DOM is embedded in an iframe.\n *\n * @return {boolean}\n * Will be `true` if the DOM is embedded in an iframe, `false`\n * otherwise.\n */\nfunction isInFrame() {\n // We need a try/catch here because Safari will throw errors when attempting\n // to get either `parent` or `self`\n try {\n return window$1.parent !== window$1.self;\n } catch (x) {\n return true;\n }\n}\n\n/**\n * Creates functions to query the DOM using a given method.\n *\n * @private\n * @param {string} method\n * The method to create the query with.\n *\n * @return {Function}\n * The query method\n */\nfunction createQuerier(method) {\n return function (selector, context) {\n if (!isNonBlankString(selector)) {\n return document[method](null);\n }\n if (isNonBlankString(context)) {\n context = document.querySelector(context);\n }\n const ctx = isEl(context) ? context : document;\n return ctx[method] && ctx[method](selector);\n };\n}\n\n/**\n * Creates an element and applies properties, attributes, and inserts content.\n *\n * @param {string} [tagName='div']\n * Name of tag to be created.\n *\n * @param {Object} [properties={}]\n * Element properties to be applied.\n *\n * @param {Object} [attributes={}]\n * Element attributes to be applied.\n *\n * @param {ContentDescriptor} [content]\n * A content descriptor object.\n *\n * @return {Element}\n * The element that was created.\n */\nfunction createEl(tagName = 'div', properties = {}, attributes = {}, content) {\n const el = document.createElement(tagName);\n Object.getOwnPropertyNames(properties).forEach(function (propName) {\n const val = properties[propName];\n\n // Handle textContent since it's not supported everywhere and we have a\n // method for it.\n if (propName === 'textContent') {\n textContent(el, val);\n } else if (el[propName] !== val || propName === 'tabIndex') {\n el[propName] = val;\n }\n });\n Object.getOwnPropertyNames(attributes).forEach(function (attrName) {\n el.setAttribute(attrName, attributes[attrName]);\n });\n if (content) {\n appendContent(el, content);\n }\n return el;\n}\n\n/**\n * Injects text into an element, replacing any existing contents entirely.\n *\n * @param {HTMLElement} el\n * The element to add text content into\n *\n * @param {string} text\n * The text content to add.\n *\n * @return {Element}\n * The element with added text content.\n */\nfunction textContent(el, text) {\n if (typeof el.textContent === 'undefined') {\n el.innerText = text;\n } else {\n el.textContent = text;\n }\n return el;\n}\n\n/**\n * Insert an element as the first child node of another\n *\n * @param {Element} child\n * Element to insert\n *\n * @param {Element} parent\n * Element to insert child into\n */\nfunction prependTo(child, parent) {\n if (parent.firstChild) {\n parent.insertBefore(child, parent.firstChild);\n } else {\n parent.appendChild(child);\n }\n}\n\n/**\n * Check if an element has a class name.\n *\n * @param {Element} element\n * Element to check\n *\n * @param {string} classToCheck\n * Class name to check for\n *\n * @return {boolean}\n * Will be `true` if the element has a class, `false` otherwise.\n *\n * @throws {Error}\n * Throws an error if `classToCheck` has white space.\n */\nfunction hasClass(element, classToCheck) {\n throwIfWhitespace(classToCheck);\n return element.classList.contains(classToCheck);\n}\n\n/**\n * Add a class name to an element.\n *\n * @param {Element} element\n * Element to add class name to.\n *\n * @param {...string} classesToAdd\n * One or more class name to add.\n *\n * @return {Element}\n * The DOM element with the added class name.\n */\nfunction addClass(element, ...classesToAdd) {\n element.classList.add(...classesToAdd.reduce((prev, current) => prev.concat(current.split(/\\s+/)), []));\n return element;\n}\n\n/**\n * Remove a class name from an element.\n *\n * @param {Element} element\n * Element to remove a class name from.\n *\n * @param {...string} classesToRemove\n * One or more class name to remove.\n *\n * @return {Element}\n * The DOM element with class name removed.\n */\nfunction removeClass(element, ...classesToRemove) {\n // Protect in case the player gets disposed\n if (!element) {\n log$1.warn(\"removeClass was called with an element that doesn't exist\");\n return null;\n }\n element.classList.remove(...classesToRemove.reduce((prev, current) => prev.concat(current.split(/\\s+/)), []));\n return element;\n}\n\n/**\n * The callback definition for toggleClass.\n *\n * @callback module:dom~PredicateCallback\n * @param {Element} element\n * The DOM element of the Component.\n *\n * @param {string} classToToggle\n * The `className` that wants to be toggled\n *\n * @return {boolean|undefined}\n * If `true` is returned, the `classToToggle` will be added to the\n * `element`. If `false`, the `classToToggle` will be removed from\n * the `element`. If `undefined`, the callback will be ignored.\n */\n\n/**\n * Adds or removes a class name to/from an element depending on an optional\n * condition or the presence/absence of the class name.\n *\n * @param {Element} element\n * The element to toggle a class name on.\n *\n * @param {string} classToToggle\n * The class that should be toggled.\n *\n * @param {boolean|module:dom~PredicateCallback} [predicate]\n * See the return value for {@link module:dom~PredicateCallback}\n *\n * @return {Element}\n * The element with a class that has been toggled.\n */\nfunction toggleClass(element, classToToggle, predicate) {\n if (typeof predicate === 'function') {\n predicate = predicate(element, classToToggle);\n }\n if (typeof predicate !== 'boolean') {\n predicate = undefined;\n }\n classToToggle.split(/\\s+/).forEach(className => element.classList.toggle(className, predicate));\n return element;\n}\n\n/**\n * Apply attributes to an HTML element.\n *\n * @param {Element} el\n * Element to add attributes to.\n *\n * @param {Object} [attributes]\n * Attributes to be applied.\n */\nfunction setAttributes(el, attributes) {\n Object.getOwnPropertyNames(attributes).forEach(function (attrName) {\n const attrValue = attributes[attrName];\n if (attrValue === null || typeof attrValue === 'undefined' || attrValue === false) {\n el.removeAttribute(attrName);\n } else {\n el.setAttribute(attrName, attrValue === true ? '' : attrValue);\n }\n });\n}\n\n/**\n * Get an element's attribute values, as defined on the HTML tag.\n *\n * Attributes are not the same as properties. They're defined on the tag\n * or with setAttribute.\n *\n * @param {Element} tag\n * Element from which to get tag attributes.\n *\n * @return {Object}\n * All attributes of the element. Boolean attributes will be `true` or\n * `false`, others will be strings.\n */\nfunction getAttributes(tag) {\n const obj = {};\n\n // known boolean attributes\n // we can check for matching boolean properties, but not all browsers\n // and not all tags know about these attributes, so, we still want to check them manually\n const knownBooleans = ['autoplay', 'controls', 'playsinline', 'loop', 'muted', 'default', 'defaultMuted'];\n if (tag && tag.attributes && tag.attributes.length > 0) {\n const attrs = tag.attributes;\n for (let i = attrs.length - 1; i >= 0; i--) {\n const attrName = attrs[i].name;\n /** @type {boolean|string} */\n let attrVal = attrs[i].value;\n\n // check for known booleans\n // the matching element property will return a value for typeof\n if (knownBooleans.includes(attrName)) {\n // the value of an included boolean attribute is typically an empty\n // string ('') which would equal false if we just check for a false value.\n // we also don't want support bad code like autoplay='false'\n attrVal = attrVal !== null ? true : false;\n }\n obj[attrName] = attrVal;\n }\n }\n return obj;\n}\n\n/**\n * Get the value of an element's attribute.\n *\n * @param {Element} el\n * A DOM element.\n *\n * @param {string} attribute\n * Attribute to get the value of.\n *\n * @return {string}\n * The value of the attribute.\n */\nfunction getAttribute(el, attribute) {\n return el.getAttribute(attribute);\n}\n\n/**\n * Set the value of an element's attribute.\n *\n * @param {Element} el\n * A DOM element.\n *\n * @param {string} attribute\n * Attribute to set.\n *\n * @param {string} value\n * Value to set the attribute to.\n */\nfunction setAttribute(el, attribute, value) {\n el.setAttribute(attribute, value);\n}\n\n/**\n * Remove an element's attribute.\n *\n * @param {Element} el\n * A DOM element.\n *\n * @param {string} attribute\n * Attribute to remove.\n */\nfunction removeAttribute(el, attribute) {\n el.removeAttribute(attribute);\n}\n\n/**\n * Attempt to block the ability to select text.\n */\nfunction blockTextSelection() {\n document.body.focus();\n document.onselectstart = function () {\n return false;\n };\n}\n\n/**\n * Turn off text selection blocking.\n */\nfunction unblockTextSelection() {\n document.onselectstart = function () {\n return true;\n };\n}\n\n/**\n * Identical to the native `getBoundingClientRect` function, but ensures that\n * the method is supported at all (it is in all browsers we claim to support)\n * and that the element is in the DOM before continuing.\n *\n * This wrapper function also shims properties which are not provided by some\n * older browsers (namely, IE8).\n *\n * Additionally, some browsers do not support adding properties to a\n * `ClientRect`/`DOMRect` object; so, we shallow-copy it with the standard\n * properties (except `x` and `y` which are not widely supported). This helps\n * avoid implementations where keys are non-enumerable.\n *\n * @param {Element} el\n * Element whose `ClientRect` we want to calculate.\n *\n * @return {Object|undefined}\n * Always returns a plain object - or `undefined` if it cannot.\n */\nfunction getBoundingClientRect(el) {\n if (el && el.getBoundingClientRect && el.parentNode) {\n const rect = el.getBoundingClientRect();\n const result = {};\n ['bottom', 'height', 'left', 'right', 'top', 'width'].forEach(k => {\n if (rect[k] !== undefined) {\n result[k] = rect[k];\n }\n });\n if (!result.height) {\n result.height = parseFloat(computedStyle(el, 'height'));\n }\n if (!result.width) {\n result.width = parseFloat(computedStyle(el, 'width'));\n }\n return result;\n }\n}\n\n/**\n * Represents the position of a DOM element on the page.\n *\n * @typedef {Object} module:dom~Position\n *\n * @property {number} left\n * Pixels to the left.\n *\n * @property {number} top\n * Pixels from the top.\n */\n\n/**\n * Get the position of an element in the DOM.\n *\n * Uses `getBoundingClientRect` technique from John Resig.\n *\n * @see http://ejohn.org/blog/getboundingclientrect-is-awesome/\n *\n * @param {Element} el\n * Element from which to get offset.\n *\n * @return {module:dom~Position}\n * The position of the element that was passed in.\n */\nfunction findPosition(el) {\n if (!el || el && !el.offsetParent) {\n return {\n left: 0,\n top: 0,\n width: 0,\n height: 0\n };\n }\n const width = el.offsetWidth;\n const height = el.offsetHeight;\n let left = 0;\n let top = 0;\n while (el.offsetParent && el !== document[FullscreenApi.fullscreenElement]) {\n left += el.offsetLeft;\n top += el.offsetTop;\n el = el.offsetParent;\n }\n return {\n left,\n top,\n width,\n height\n };\n}\n\n/**\n * Represents x and y coordinates for a DOM element or mouse pointer.\n *\n * @typedef {Object} module:dom~Coordinates\n *\n * @property {number} x\n * x coordinate in pixels\n *\n * @property {number} y\n * y coordinate in pixels\n */\n\n/**\n * Get the pointer position within an element.\n *\n * The base on the coordinates are the bottom left of the element.\n *\n * @param {Element} el\n * Element on which to get the pointer position on.\n *\n * @param {Event} event\n * Event object.\n *\n * @return {module:dom~Coordinates}\n * A coordinates object corresponding to the mouse position.\n *\n */\nfunction getPointerPosition(el, event) {\n const translated = {\n x: 0,\n y: 0\n };\n if (IS_IOS) {\n let item = el;\n while (item && item.nodeName.toLowerCase() !== 'html') {\n const transform = computedStyle(item, 'transform');\n if (/^matrix/.test(transform)) {\n const values = transform.slice(7, -1).split(/,\\s/).map(Number);\n translated.x += values[4];\n translated.y += values[5];\n } else if (/^matrix3d/.test(transform)) {\n const values = transform.slice(9, -1).split(/,\\s/).map(Number);\n translated.x += values[12];\n translated.y += values[13];\n }\n item = item.parentNode;\n }\n }\n const position = {};\n const boxTarget = findPosition(event.target);\n const box = findPosition(el);\n const boxW = box.width;\n const boxH = box.height;\n let offsetY = event.offsetY - (box.top - boxTarget.top);\n let offsetX = event.offsetX - (box.left - boxTarget.left);\n if (event.changedTouches) {\n offsetX = event.changedTouches[0].pageX - box.left;\n offsetY = event.changedTouches[0].pageY + box.top;\n if (IS_IOS) {\n offsetX -= translated.x;\n offsetY -= translated.y;\n }\n }\n position.y = 1 - Math.max(0, Math.min(1, offsetY / boxH));\n position.x = Math.max(0, Math.min(1, offsetX / boxW));\n return position;\n}\n\n/**\n * Determines, via duck typing, whether or not a value is a text node.\n *\n * @param {*} value\n * Check if this value is a text node.\n *\n * @return {boolean}\n * Will be `true` if the value is a text node, `false` otherwise.\n */\nfunction isTextNode(value) {\n return isObject(value) && value.nodeType === 3;\n}\n\n/**\n * Empties the contents of an element.\n *\n * @param {Element} el\n * The element to empty children from\n *\n * @return {Element}\n * The element with no children\n */\nfunction emptyEl(el) {\n while (el.firstChild) {\n el.removeChild(el.firstChild);\n }\n return el;\n}\n\n/**\n * This is a mixed value that describes content to be injected into the DOM\n * via some method. It can be of the following types:\n *\n * Type | Description\n * -----------|-------------\n * `string` | The value will be normalized into a text node.\n * `Element` | The value will be accepted as-is.\n * `Text` | A TextNode. The value will be accepted as-is.\n * `Array` | A one-dimensional array of strings, elements, text nodes, or functions. These functions should return a string, element, or text node (any other return value, like an array, will be ignored).\n * `Function` | A function, which is expected to return a string, element, text node, or array - any of the other possible values described above. This means that a content descriptor could be a function that returns an array of functions, but those second-level functions must return strings, elements, or text nodes.\n *\n * @typedef {string|Element|Text|Array|Function} ContentDescriptor\n */\n\n/**\n * Normalizes content for eventual insertion into the DOM.\n *\n * This allows a wide range of content definition methods, but helps protect\n * from falling into the trap of simply writing to `innerHTML`, which could\n * be an XSS concern.\n *\n * The content for an element can be passed in multiple types and\n * combinations, whose behavior is as follows:\n *\n * @param {ContentDescriptor} content\n * A content descriptor value.\n *\n * @return {Array}\n * All of the content that was passed in, normalized to an array of\n * elements or text nodes.\n */\nfunction normalizeContent(content) {\n // First, invoke content if it is a function. If it produces an array,\n // that needs to happen before normalization.\n if (typeof content === 'function') {\n content = content();\n }\n\n // Next up, normalize to an array, so one or many items can be normalized,\n // filtered, and returned.\n return (Array.isArray(content) ? content : [content]).map(value => {\n // First, invoke value if it is a function to produce a new value,\n // which will be subsequently normalized to a Node of some kind.\n if (typeof value === 'function') {\n value = value();\n }\n if (isEl(value) || isTextNode(value)) {\n return value;\n }\n if (typeof value === 'string' && /\\S/.test(value)) {\n return document.createTextNode(value);\n }\n }).filter(value => value);\n}\n\n/**\n * Normalizes and appends content to an element.\n *\n * @param {Element} el\n * Element to append normalized content to.\n *\n * @param {ContentDescriptor} content\n * A content descriptor value.\n *\n * @return {Element}\n * The element with appended normalized content.\n */\nfunction appendContent(el, content) {\n normalizeContent(content).forEach(node => el.appendChild(node));\n return el;\n}\n\n/**\n * Normalizes and inserts content into an element; this is identical to\n * `appendContent()`, except it empties the element first.\n *\n * @param {Element} el\n * Element to insert normalized content into.\n *\n * @param {ContentDescriptor} content\n * A content descriptor value.\n *\n * @return {Element}\n * The element with inserted normalized content.\n */\nfunction insertContent(el, content) {\n return appendContent(emptyEl(el), content);\n}\n\n/**\n * Check if an event was a single left click.\n *\n * @param {MouseEvent} event\n * Event object.\n *\n * @return {boolean}\n * Will be `true` if a single left click, `false` otherwise.\n */\nfunction isSingleLeftClick(event) {\n // Note: if you create something draggable, be sure to\n // call it on both `mousedown` and `mousemove` event,\n // otherwise `mousedown` should be enough for a button\n\n if (event.button === undefined && event.buttons === undefined) {\n // Why do we need `buttons` ?\n // Because, middle mouse sometimes have this:\n // e.button === 0 and e.buttons === 4\n // Furthermore, we want to prevent combination click, something like\n // HOLD middlemouse then left click, that would be\n // e.button === 0, e.buttons === 5\n // just `button` is not gonna work\n\n // Alright, then what this block does ?\n // this is for chrome `simulate mobile devices`\n // I want to support this as well\n\n return true;\n }\n if (event.button === 0 && event.buttons === undefined) {\n // Touch screen, sometimes on some specific device, `buttons`\n // doesn't have anything (safari on ios, blackberry...)\n\n return true;\n }\n\n // `mouseup` event on a single left click has\n // `button` and `buttons` equal to 0\n if (event.type === 'mouseup' && event.button === 0 && event.buttons === 0) {\n return true;\n }\n if (event.button !== 0 || event.buttons !== 1) {\n // This is the reason we have those if else block above\n // if any special case we can catch and let it slide\n // we do it above, when get to here, this definitely\n // is-not-left-click\n\n return false;\n }\n return true;\n}\n\n/**\n * Finds a single DOM element matching `selector` within the optional\n * `context` of another DOM element (defaulting to `document`).\n *\n * @param {string} selector\n * A valid CSS selector, which will be passed to `querySelector`.\n *\n * @param {Element|String} [context=document]\n * A DOM element within which to query. Can also be a selector\n * string in which case the first matching element will be used\n * as context. If missing (or no element matches selector), falls\n * back to `document`.\n *\n * @return {Element|null}\n * The element that was found or null.\n */\nconst $ = createQuerier('querySelector');\n\n/**\n * Finds a all DOM elements matching `selector` within the optional\n * `context` of another DOM element (defaulting to `document`).\n *\n * @param {string} selector\n * A valid CSS selector, which will be passed to `querySelectorAll`.\n *\n * @param {Element|String} [context=document]\n * A DOM element within which to query. Can also be a selector\n * string in which case the first matching element will be used\n * as context. If missing (or no element matches selector), falls\n * back to `document`.\n *\n * @return {NodeList}\n * A element list of elements that were found. Will be empty if none\n * were found.\n *\n */\nconst $$ = createQuerier('querySelectorAll');\n\n/**\n * A safe getComputedStyle.\n *\n * This is needed because in Firefox, if the player is loaded in an iframe with\n * `display:none`, then `getComputedStyle` returns `null`, so, we do a\n * null-check to make sure that the player doesn't break in these cases.\n *\n * @param {Element} el\n * The element you want the computed style of\n *\n * @param {string} prop\n * The property name you want\n *\n * @see https://bugzilla.mozilla.org/show_bug.cgi?id=548397\n */\nfunction computedStyle(el, prop) {\n if (!el || !prop) {\n return '';\n }\n if (typeof window$1.getComputedStyle === 'function') {\n let computedStyleValue;\n try {\n computedStyleValue = window$1.getComputedStyle(el);\n } catch (e) {\n return '';\n }\n return computedStyleValue ? computedStyleValue.getPropertyValue(prop) || computedStyleValue[prop] : '';\n }\n return '';\n}\n\n/**\n * Copy document style sheets to another window.\n *\n * @param {Window} win\n * The window element you want to copy the document style sheets to.\n *\n */\nfunction copyStyleSheetsToWindow(win) {\n [...document.styleSheets].forEach(styleSheet => {\n try {\n const cssRules = [...styleSheet.cssRules].map(rule => rule.cssText).join('');\n const style = document.createElement('style');\n style.textContent = cssRules;\n win.document.head.appendChild(style);\n } catch (e) {\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.type = styleSheet.type;\n // For older Safari this has to be the string; on other browsers setting the MediaList works\n link.media = styleSheet.media.mediaText;\n link.href = styleSheet.href;\n win.document.head.appendChild(link);\n }\n });\n}\n\nvar Dom = /*#__PURE__*/Object.freeze({\n __proto__: null,\n isReal: isReal,\n isEl: isEl,\n isInFrame: isInFrame,\n createEl: createEl,\n textContent: textContent,\n prependTo: prependTo,\n hasClass: hasClass,\n addClass: addClass,\n removeClass: removeClass,\n toggleClass: toggleClass,\n setAttributes: setAttributes,\n getAttributes: getAttributes,\n getAttribute: getAttribute,\n setAttribute: setAttribute,\n removeAttribute: removeAttribute,\n blockTextSelection: blockTextSelection,\n unblockTextSelection: unblockTextSelection,\n getBoundingClientRect: getBoundingClientRect,\n findPosition: findPosition,\n getPointerPosition: getPointerPosition,\n isTextNode: isTextNode,\n emptyEl: emptyEl,\n normalizeContent: normalizeContent,\n appendContent: appendContent,\n insertContent: insertContent,\n isSingleLeftClick: isSingleLeftClick,\n $: $,\n $$: $$,\n computedStyle: computedStyle,\n copyStyleSheetsToWindow: copyStyleSheetsToWindow\n});\n\n/**\n * @file setup.js - Functions for setting up a player without\n * user interaction based on the data-setup `attribute` of the video tag.\n *\n * @module setup\n */\nlet _windowLoaded = false;\nlet videojs$1;\n\n/**\n * Set up any tags that have a data-setup `attribute` when the player is started.\n */\nconst autoSetup = function () {\n if (videojs$1.options.autoSetup === false) {\n return;\n }\n const vids = Array.prototype.slice.call(document.getElementsByTagName('video'));\n const audios = Array.prototype.slice.call(document.getElementsByTagName('audio'));\n const divs = Array.prototype.slice.call(document.getElementsByTagName('video-js'));\n const mediaEls = vids.concat(audios, divs);\n\n // Check if any media elements exist\n if (mediaEls && mediaEls.length > 0) {\n for (let i = 0, e = mediaEls.length; i < e; i++) {\n const mediaEl = mediaEls[i];\n\n // Check if element exists, has getAttribute func.\n if (mediaEl && mediaEl.getAttribute) {\n // Make sure this player hasn't already been set up.\n if (mediaEl.player === undefined) {\n const options = mediaEl.getAttribute('data-setup');\n\n // Check if data-setup attr exists.\n // We only auto-setup if they've added the data-setup attr.\n if (options !== null) {\n // Create new video.js instance.\n videojs$1(mediaEl);\n }\n }\n\n // If getAttribute isn't defined, we need to wait for the DOM.\n } else {\n autoSetupTimeout(1);\n break;\n }\n }\n\n // No videos were found, so keep looping unless page is finished loading.\n } else if (!_windowLoaded) {\n autoSetupTimeout(1);\n }\n};\n\n/**\n * Wait until the page is loaded before running autoSetup. This will be called in\n * autoSetup if `hasLoaded` returns false.\n *\n * @param {number} wait\n * How long to wait in ms\n *\n * @param {module:videojs} [vjs]\n * The videojs library function\n */\nfunction autoSetupTimeout(wait, vjs) {\n // Protect against breakage in non-browser environments\n if (!isReal()) {\n return;\n }\n if (vjs) {\n videojs$1 = vjs;\n }\n window$1.setTimeout(autoSetup, wait);\n}\n\n/**\n * Used to set the internal tracking of window loaded state to true.\n *\n * @private\n */\nfunction setWindowLoaded() {\n _windowLoaded = true;\n window$1.removeEventListener('load', setWindowLoaded);\n}\nif (isReal()) {\n if (document.readyState === 'complete') {\n setWindowLoaded();\n } else {\n /**\n * Listen for the load event on window, and set _windowLoaded to true.\n *\n * We use a standard event listener here to avoid incrementing the GUID\n * before any players are created.\n *\n * @listens load\n */\n window$1.addEventListener('load', setWindowLoaded);\n }\n}\n\n/**\n * @file stylesheet.js\n * @module stylesheet\n */\n\n/**\n * Create a DOM style element given a className for it.\n *\n * @param {string} className\n * The className to add to the created style element.\n *\n * @return {Element}\n * The element that was created.\n */\nconst createStyleElement = function (className) {\n const style = document.createElement('style');\n style.className = className;\n return style;\n};\n\n/**\n * Add text to a DOM element.\n *\n * @param {Element} el\n * The Element to add text content to.\n *\n * @param {string} content\n * The text to add to the element.\n */\nconst setTextContent = function (el, content) {\n if (el.styleSheet) {\n el.styleSheet.cssText = content;\n } else {\n el.textContent = content;\n }\n};\n\n/**\n * @file dom-data.js\n * @module dom-data\n */\n\n/**\n * Element Data Store.\n *\n * Allows for binding data to an element without putting it directly on the\n * element. Ex. Event listeners are stored here.\n * (also from jsninja.com, slightly modified and updated for closure compiler)\n *\n * @type {Object}\n * @private\n */\nvar DomData = new WeakMap();\n\n/**\n * @file guid.js\n * @module guid\n */\n\n// Default value for GUIDs. This allows us to reset the GUID counter in tests.\n//\n// The initial GUID is 3 because some users have come to rely on the first\n// default player ID ending up as `vjs_video_3`.\n//\n// See: https://github.com/videojs/video.js/pull/6216\nconst _initialGuid = 3;\n\n/**\n * Unique ID for an element or function\n *\n * @type {Number}\n */\nlet _guid = _initialGuid;\n\n/**\n * Get a unique auto-incrementing ID by number that has not been returned before.\n *\n * @return {number}\n * A new unique ID.\n */\nfunction newGUID() {\n return _guid++;\n}\n\n/**\n * @file events.js. An Event System (John Resig - Secrets of a JS Ninja http://jsninja.com/)\n * (Original book version wasn't completely usable, so fixed some things and made Closure Compiler compatible)\n * This should work very similarly to jQuery's events, however it's based off the book version which isn't as\n * robust as jquery's, so there's probably some differences.\n *\n * @file events.js\n * @module events\n */\n\n/**\n * Clean up the listener cache and dispatchers\n *\n * @param {Element|Object} elem\n * Element to clean up\n *\n * @param {string} type\n * Type of event to clean up\n */\nfunction _cleanUpEvents(elem, type) {\n if (!DomData.has(elem)) {\n return;\n }\n const data = DomData.get(elem);\n\n // Remove the events of a particular type if there are none left\n if (data.handlers[type].length === 0) {\n delete data.handlers[type];\n // data.handlers[type] = null;\n // Setting to null was causing an error with data.handlers\n\n // Remove the meta-handler from the element\n if (elem.removeEventListener) {\n elem.removeEventListener(type, data.dispatcher, false);\n } else if (elem.detachEvent) {\n elem.detachEvent('on' + type, data.dispatcher);\n }\n }\n\n // Remove the events object if there are no types left\n if (Object.getOwnPropertyNames(data.handlers).length <= 0) {\n delete data.handlers;\n delete data.dispatcher;\n delete data.disabled;\n }\n\n // Finally remove the element data if there is no data left\n if (Object.getOwnPropertyNames(data).length === 0) {\n DomData.delete(elem);\n }\n}\n\n/**\n * Loops through an array of event types and calls the requested method for each type.\n *\n * @param {Function} fn\n * The event method we want to use.\n *\n * @param {Element|Object} elem\n * Element or object to bind listeners to\n *\n * @param {string[]} types\n * Type of event to bind to.\n *\n * @param {Function} callback\n * Event listener.\n */\nfunction _handleMultipleEvents(fn, elem, types, callback) {\n types.forEach(function (type) {\n // Call the event method for each one of the types\n fn(elem, type, callback);\n });\n}\n\n/**\n * Fix a native event to have standard property values\n *\n * @param {Object} event\n * Event object to fix.\n *\n * @return {Object}\n * Fixed event object.\n */\nfunction fixEvent(event) {\n if (event.fixed_) {\n return event;\n }\n function returnTrue() {\n return true;\n }\n function returnFalse() {\n return false;\n }\n\n // Test if fixing up is needed\n // Used to check if !event.stopPropagation instead of isPropagationStopped\n // But native events return true for stopPropagation, but don't have\n // other expected methods like isPropagationStopped. Seems to be a problem\n // with the Javascript Ninja code. So we're just overriding all events now.\n if (!event || !event.isPropagationStopped || !event.isImmediatePropagationStopped) {\n const old = event || window$1.event;\n event = {};\n // Clone the old object so that we can modify the values event = {};\n // IE8 Doesn't like when you mess with native event properties\n // Firefox returns false for event.hasOwnProperty('type') and other props\n // which makes copying more difficult.\n // TODO: Probably best to create a whitelist of event props\n for (const key in old) {\n // Safari 6.0.3 warns you if you try to copy deprecated layerX/Y\n // Chrome warns you if you try to copy deprecated keyboardEvent.keyLocation\n // and webkitMovementX/Y\n // Lighthouse complains if Event.path is copied\n if (key !== 'layerX' && key !== 'layerY' && key !== 'keyLocation' && key !== 'webkitMovementX' && key !== 'webkitMovementY' && key !== 'path') {\n // Chrome 32+ warns if you try to copy deprecated returnValue, but\n // we still want to if preventDefault isn't supported (IE8).\n if (!(key === 'returnValue' && old.preventDefault)) {\n event[key] = old[key];\n }\n }\n }\n\n // The event occurred on this element\n if (!event.target) {\n event.target = event.srcElement || document;\n }\n\n // Handle which other element the event is related to\n if (!event.relatedTarget) {\n event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;\n }\n\n // Stop the default browser action\n event.preventDefault = function () {\n if (old.preventDefault) {\n old.preventDefault();\n }\n event.returnValue = false;\n old.returnValue = false;\n event.defaultPrevented = true;\n };\n event.defaultPrevented = false;\n\n // Stop the event from bubbling\n event.stopPropagation = function () {\n if (old.stopPropagation) {\n old.stopPropagation();\n }\n event.cancelBubble = true;\n old.cancelBubble = true;\n event.isPropagationStopped = returnTrue;\n };\n event.isPropagationStopped = returnFalse;\n\n // Stop the event from bubbling and executing other handlers\n event.stopImmediatePropagation = function () {\n if (old.stopImmediatePropagation) {\n old.stopImmediatePropagation();\n }\n event.isImmediatePropagationStopped = returnTrue;\n event.stopPropagation();\n };\n event.isImmediatePropagationStopped = returnFalse;\n\n // Handle mouse position\n if (event.clientX !== null && event.clientX !== undefined) {\n const doc = document.documentElement;\n const body = document.body;\n event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);\n event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);\n }\n\n // Handle key presses\n event.which = event.charCode || event.keyCode;\n\n // Fix button for mouse clicks:\n // 0 == left; 1 == middle; 2 == right\n if (event.button !== null && event.button !== undefined) {\n // The following is disabled because it does not pass videojs-standard\n // and... yikes.\n /* eslint-disable */\n event.button = event.button & 1 ? 0 : event.button & 4 ? 1 : event.button & 2 ? 2 : 0;\n /* eslint-enable */\n }\n }\n\n event.fixed_ = true;\n // Returns fixed-up instance\n return event;\n}\n\n/**\n * Whether passive event listeners are supported\n */\nlet _supportsPassive;\nconst supportsPassive = function () {\n if (typeof _supportsPassive !== 'boolean') {\n _supportsPassive = false;\n try {\n const opts = Object.defineProperty({}, 'passive', {\n get() {\n _supportsPassive = true;\n }\n });\n window$1.addEventListener('test', null, opts);\n window$1.removeEventListener('test', null, opts);\n } catch (e) {\n // disregard\n }\n }\n return _supportsPassive;\n};\n\n/**\n * Touch events Chrome expects to be passive\n */\nconst passiveEvents = ['touchstart', 'touchmove'];\n\n/**\n * Add an event listener to element\n * It stores the handler function in a separate cache object\n * and adds a generic handler to the element's event,\n * along with a unique id (guid) to the element.\n *\n * @param {Element|Object} elem\n * Element or object to bind listeners to\n *\n * @param {string|string[]} type\n * Type of event to bind to.\n *\n * @param {Function} fn\n * Event listener.\n */\nfunction on(elem, type, fn) {\n if (Array.isArray(type)) {\n return _handleMultipleEvents(on, elem, type, fn);\n }\n if (!DomData.has(elem)) {\n DomData.set(elem, {});\n }\n const data = DomData.get(elem);\n\n // We need a place to store all our handler data\n if (!data.handlers) {\n data.handlers = {};\n }\n if (!data.handlers[type]) {\n data.handlers[type] = [];\n }\n if (!fn.guid) {\n fn.guid = newGUID();\n }\n data.handlers[type].push(fn);\n if (!data.dispatcher) {\n data.disabled = false;\n data.dispatcher = function (event, hash) {\n if (data.disabled) {\n return;\n }\n event = fixEvent(event);\n const handlers = data.handlers[event.type];\n if (handlers) {\n // Copy handlers so if handlers are added/removed during the process it doesn't throw everything off.\n const handlersCopy = handlers.slice(0);\n for (let m = 0, n = handlersCopy.length; m < n; m++) {\n if (event.isImmediatePropagationStopped()) {\n break;\n } else {\n try {\n handlersCopy[m].call(elem, event, hash);\n } catch (e) {\n log$1.error(e);\n }\n }\n }\n }\n };\n }\n if (data.handlers[type].length === 1) {\n if (elem.addEventListener) {\n let options = false;\n if (supportsPassive() && passiveEvents.indexOf(type) > -1) {\n options = {\n passive: true\n };\n }\n elem.addEventListener(type, data.dispatcher, options);\n } else if (elem.attachEvent) {\n elem.attachEvent('on' + type, data.dispatcher);\n }\n }\n}\n\n/**\n * Removes event listeners from an element\n *\n * @param {Element|Object} elem\n * Object to remove listeners from.\n *\n * @param {string|string[]} [type]\n * Type of listener to remove. Don't include to remove all events from element.\n *\n * @param {Function} [fn]\n * Specific listener to remove. Don't include to remove listeners for an event\n * type.\n */\nfunction off(elem, type, fn) {\n // Don't want to add a cache object through getElData if not needed\n if (!DomData.has(elem)) {\n return;\n }\n const data = DomData.get(elem);\n\n // If no events exist, nothing to unbind\n if (!data.handlers) {\n return;\n }\n if (Array.isArray(type)) {\n return _handleMultipleEvents(off, elem, type, fn);\n }\n\n // Utility function\n const removeType = function (el, t) {\n data.handlers[t] = [];\n _cleanUpEvents(el, t);\n };\n\n // Are we removing all bound events?\n if (type === undefined) {\n for (const t in data.handlers) {\n if (Object.prototype.hasOwnProperty.call(data.handlers || {}, t)) {\n removeType(elem, t);\n }\n }\n return;\n }\n const handlers = data.handlers[type];\n\n // If no handlers exist, nothing to unbind\n if (!handlers) {\n return;\n }\n\n // If no listener was provided, remove all listeners for type\n if (!fn) {\n removeType(elem, type);\n return;\n }\n\n // We're only removing a single handler\n if (fn.guid) {\n for (let n = 0; n < handlers.length; n++) {\n if (handlers[n].guid === fn.guid) {\n handlers.splice(n--, 1);\n }\n }\n }\n _cleanUpEvents(elem, type);\n}\n\n/**\n * Trigger an event for an element\n *\n * @param {Element|Object} elem\n * Element to trigger an event on\n *\n * @param {EventTarget~Event|string} event\n * A string (the type) or an event object with a type attribute\n *\n * @param {Object} [hash]\n * data hash to pass along with the event\n *\n * @return {boolean|undefined}\n * Returns the opposite of `defaultPrevented` if default was\n * prevented. Otherwise, returns `undefined`\n */\nfunction trigger(elem, event, hash) {\n // Fetches element data and a reference to the parent (for bubbling).\n // Don't want to add a data object to cache for every parent,\n // so checking hasElData first.\n const elemData = DomData.has(elem) ? DomData.get(elem) : {};\n const parent = elem.parentNode || elem.ownerDocument;\n // type = event.type || event,\n // handler;\n\n // If an event name was passed as a string, creates an event out of it\n if (typeof event === 'string') {\n event = {\n type: event,\n target: elem\n };\n } else if (!event.target) {\n event.target = elem;\n }\n\n // Normalizes the event properties.\n event = fixEvent(event);\n\n // If the passed element has a dispatcher, executes the established handlers.\n if (elemData.dispatcher) {\n elemData.dispatcher.call(elem, event, hash);\n }\n\n // Unless explicitly stopped or the event does not bubble (e.g. media events)\n // recursively calls this function to bubble the event up the DOM.\n if (parent && !event.isPropagationStopped() && event.bubbles === true) {\n trigger.call(null, parent, event, hash);\n\n // If at the top of the DOM, triggers the default action unless disabled.\n } else if (!parent && !event.defaultPrevented && event.target && event.target[event.type]) {\n if (!DomData.has(event.target)) {\n DomData.set(event.target, {});\n }\n const targetData = DomData.get(event.target);\n\n // Checks if the target has a default action for this event.\n if (event.target[event.type]) {\n // Temporarily disables event dispatching on the target as we have already executed the handler.\n targetData.disabled = true;\n // Executes the default action.\n if (typeof event.target[event.type] === 'function') {\n event.target[event.type]();\n }\n // Re-enables event dispatching.\n targetData.disabled = false;\n }\n }\n\n // Inform the triggerer if the default was prevented by returning false\n return !event.defaultPrevented;\n}\n\n/**\n * Trigger a listener only once for an event.\n *\n * @param {Element|Object} elem\n * Element or object to bind to.\n *\n * @param {string|string[]} type\n * Name/type of event\n *\n * @param {Event~EventListener} fn\n * Event listener function\n */\nfunction one(elem, type, fn) {\n if (Array.isArray(type)) {\n return _handleMultipleEvents(one, elem, type, fn);\n }\n const func = function () {\n off(elem, type, func);\n fn.apply(this, arguments);\n };\n\n // copy the guid to the new function so it can removed using the original function's ID\n func.guid = fn.guid = fn.guid || newGUID();\n on(elem, type, func);\n}\n\n/**\n * Trigger a listener only once and then turn if off for all\n * configured events\n *\n * @param {Element|Object} elem\n * Element or object to bind to.\n *\n * @param {string|string[]} type\n * Name/type of event\n *\n * @param {Event~EventListener} fn\n * Event listener function\n */\nfunction any(elem, type, fn) {\n const func = function () {\n off(elem, type, func);\n fn.apply(this, arguments);\n };\n\n // copy the guid to the new function so it can removed using the original function's ID\n func.guid = fn.guid = fn.guid || newGUID();\n\n // multiple ons, but one off for everything\n on(elem, type, func);\n}\n\nvar Events = /*#__PURE__*/Object.freeze({\n __proto__: null,\n fixEvent: fixEvent,\n on: on,\n off: off,\n trigger: trigger,\n one: one,\n any: any\n});\n\n/**\n * @file fn.js\n * @module fn\n */\nconst UPDATE_REFRESH_INTERVAL = 30;\n\n/**\n * A private, internal-only function for changing the context of a function.\n *\n * It also stores a unique id on the function so it can be easily removed from\n * events.\n *\n * @private\n * @function\n * @param {*} context\n * The object to bind as scope.\n *\n * @param {Function} fn\n * The function to be bound to a scope.\n *\n * @param {number} [uid]\n * An optional unique ID for the function to be set\n *\n * @return {Function}\n * The new function that will be bound into the context given\n */\nconst bind_ = function (context, fn, uid) {\n // Make sure the function has a unique ID\n if (!fn.guid) {\n fn.guid = newGUID();\n }\n\n // Create the new function that changes the context\n const bound = fn.bind(context);\n\n // Allow for the ability to individualize this function\n // Needed in the case where multiple objects might share the same prototype\n // IF both items add an event listener with the same function, then you try to remove just one\n // it will remove both because they both have the same guid.\n // when using this, you need to use the bind method when you remove the listener as well.\n // currently used in text tracks\n bound.guid = uid ? uid + '_' + fn.guid : fn.guid;\n return bound;\n};\n\n/**\n * Wraps the given function, `fn`, with a new function that only invokes `fn`\n * at most once per every `wait` milliseconds.\n *\n * @function\n * @param {Function} fn\n * The function to be throttled.\n *\n * @param {number} wait\n * The number of milliseconds by which to throttle.\n *\n * @return {Function}\n */\nconst throttle = function (fn, wait) {\n let last = window$1.performance.now();\n const throttled = function (...args) {\n const now = window$1.performance.now();\n if (now - last >= wait) {\n fn(...args);\n last = now;\n }\n };\n return throttled;\n};\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked.\n *\n * Inspired by lodash and underscore implementations.\n *\n * @function\n * @param {Function} func\n * The function to wrap with debounce behavior.\n *\n * @param {number} wait\n * The number of milliseconds to wait after the last invocation.\n *\n * @param {boolean} [immediate]\n * Whether or not to invoke the function immediately upon creation.\n *\n * @param {Object} [context=window]\n * The \"context\" in which the debounced function should debounce. For\n * example, if this function should be tied to a Video.js player,\n * the player can be passed here. Alternatively, defaults to the\n * global `window` object.\n *\n * @return {Function}\n * A debounced function.\n */\nconst debounce = function (func, wait, immediate, context = window$1) {\n let timeout;\n const cancel = () => {\n context.clearTimeout(timeout);\n timeout = null;\n };\n\n /* eslint-disable consistent-this */\n const debounced = function () {\n const self = this;\n const args = arguments;\n let later = function () {\n timeout = null;\n later = null;\n if (!immediate) {\n func.apply(self, args);\n }\n };\n if (!timeout && immediate) {\n func.apply(self, args);\n }\n context.clearTimeout(timeout);\n timeout = context.setTimeout(later, wait);\n };\n /* eslint-enable consistent-this */\n\n debounced.cancel = cancel;\n return debounced;\n};\n\nvar Fn = /*#__PURE__*/Object.freeze({\n __proto__: null,\n UPDATE_REFRESH_INTERVAL: UPDATE_REFRESH_INTERVAL,\n bind_: bind_,\n throttle: throttle,\n debounce: debounce\n});\n\n/**\n * @file src/js/event-target.js\n */\nlet EVENT_MAP;\n\n/**\n * `EventTarget` is a class that can have the same API as the DOM `EventTarget`. It\n * adds shorthand functions that wrap around lengthy functions. For example:\n * the `on` function is a wrapper around `addEventListener`.\n *\n * @see [EventTarget Spec]{@link https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventTarget}\n * @class EventTarget\n */\nclass EventTarget$2 {\n /**\n * Adds an `event listener` to an instance of an `EventTarget`. An `event listener` is a\n * function that will get called when an event with a certain name gets triggered.\n *\n * @param {string|string[]} type\n * An event name or an array of event names.\n *\n * @param {Function} fn\n * The function to call with `EventTarget`s\n */\n on(type, fn) {\n // Remove the addEventListener alias before calling Events.on\n // so we don't get into an infinite type loop\n const ael = this.addEventListener;\n this.addEventListener = () => {};\n on(this, type, fn);\n this.addEventListener = ael;\n }\n /**\n * Removes an `event listener` for a specific event from an instance of `EventTarget`.\n * This makes it so that the `event listener` will no longer get called when the\n * named event happens.\n *\n * @param {string|string[]} type\n * An event name or an array of event names.\n *\n * @param {Function} fn\n * The function to remove.\n */\n off(type, fn) {\n off(this, type, fn);\n }\n /**\n * This function will add an `event listener` that gets triggered only once. After the\n * first trigger it will get removed. This is like adding an `event listener`\n * with {@link EventTarget#on} that calls {@link EventTarget#off} on itself.\n *\n * @param {string|string[]} type\n * An event name or an array of event names.\n *\n * @param {Function} fn\n * The function to be called once for each event name.\n */\n one(type, fn) {\n // Remove the addEventListener aliasing Events.on\n // so we don't get into an infinite type loop\n const ael = this.addEventListener;\n this.addEventListener = () => {};\n one(this, type, fn);\n this.addEventListener = ael;\n }\n /**\n * This function will add an `event listener` that gets triggered only once and is\n * removed from all events. This is like adding an array of `event listener`s\n * with {@link EventTarget#on} that calls {@link EventTarget#off} on all events the\n * first time it is triggered.\n *\n * @param {string|string[]} type\n * An event name or an array of event names.\n *\n * @param {Function} fn\n * The function to be called once for each event name.\n */\n any(type, fn) {\n // Remove the addEventListener aliasing Events.on\n // so we don't get into an infinite type loop\n const ael = this.addEventListener;\n this.addEventListener = () => {};\n any(this, type, fn);\n this.addEventListener = ael;\n }\n /**\n * This function causes an event to happen. This will then cause any `event listeners`\n * that are waiting for that event, to get called. If there are no `event listeners`\n * for an event then nothing will happen.\n *\n * If the name of the `Event` that is being triggered is in `EventTarget.allowedEvents_`.\n * Trigger will also call the `on` + `uppercaseEventName` function.\n *\n * Example:\n * 'click' is in `EventTarget.allowedEvents_`, so, trigger will attempt to call\n * `onClick` if it exists.\n *\n * @param {string|EventTarget~Event|Object} event\n * The name of the event, an `Event`, or an object with a key of type set to\n * an event name.\n */\n trigger(event) {\n const type = event.type || event;\n\n // deprecation\n // In a future version we should default target to `this`\n // similar to how we default the target to `elem` in\n // `Events.trigger`. Right now the default `target` will be\n // `document` due to the `Event.fixEvent` call.\n if (typeof event === 'string') {\n event = {\n type\n };\n }\n event = fixEvent(event);\n if (this.allowedEvents_[type] && this['on' + type]) {\n this['on' + type](event);\n }\n trigger(this, event);\n }\n queueTrigger(event) {\n // only set up EVENT_MAP if it'll be used\n if (!EVENT_MAP) {\n EVENT_MAP = new Map();\n }\n const type = event.type || event;\n let map = EVENT_MAP.get(this);\n if (!map) {\n map = new Map();\n EVENT_MAP.set(this, map);\n }\n const oldTimeout = map.get(type);\n map.delete(type);\n window$1.clearTimeout(oldTimeout);\n const timeout = window$1.setTimeout(() => {\n map.delete(type);\n // if we cleared out all timeouts for the current target, delete its map\n if (map.size === 0) {\n map = null;\n EVENT_MAP.delete(this);\n }\n this.trigger(event);\n }, 0);\n map.set(type, timeout);\n }\n}\n\n/**\n * A Custom DOM event.\n *\n * @typedef {CustomEvent} Event\n * @see [Properties]{@link https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent}\n */\n\n/**\n * All event listeners should follow the following format.\n *\n * @callback EventListener\n * @this {EventTarget}\n *\n * @param {Event} event\n * the event that triggered this function\n *\n * @param {Object} [hash]\n * hash of data sent during the event\n */\n\n/**\n * An object containing event names as keys and booleans as values.\n *\n * > NOTE: If an event name is set to a true value here {@link EventTarget#trigger}\n * will have extra functionality. See that function for more information.\n *\n * @property EventTarget.prototype.allowedEvents_\n * @protected\n */\nEventTarget$2.prototype.allowedEvents_ = {};\n\n/**\n * An alias of {@link EventTarget#on}. Allows `EventTarget` to mimic\n * the standard DOM API.\n *\n * @function\n * @see {@link EventTarget#on}\n */\nEventTarget$2.prototype.addEventListener = EventTarget$2.prototype.on;\n\n/**\n * An alias of {@link EventTarget#off}. Allows `EventTarget` to mimic\n * the standard DOM API.\n *\n * @function\n * @see {@link EventTarget#off}\n */\nEventTarget$2.prototype.removeEventListener = EventTarget$2.prototype.off;\n\n/**\n * An alias of {@link EventTarget#trigger}. Allows `EventTarget` to mimic\n * the standard DOM API.\n *\n * @function\n * @see {@link EventTarget#trigger}\n */\nEventTarget$2.prototype.dispatchEvent = EventTarget$2.prototype.trigger;\n\n/**\n * @file mixins/evented.js\n * @module evented\n */\nconst objName = obj => {\n if (typeof obj.name === 'function') {\n return obj.name();\n }\n if (typeof obj.name === 'string') {\n return obj.name;\n }\n if (obj.name_) {\n return obj.name_;\n }\n if (obj.constructor && obj.constructor.name) {\n return obj.constructor.name;\n }\n return typeof obj;\n};\n\n/**\n * Returns whether or not an object has had the evented mixin applied.\n *\n * @param {Object} object\n * An object to test.\n *\n * @return {boolean}\n * Whether or not the object appears to be evented.\n */\nconst isEvented = object => object instanceof EventTarget$2 || !!object.eventBusEl_ && ['on', 'one', 'off', 'trigger'].every(k => typeof object[k] === 'function');\n\n/**\n * Adds a callback to run after the evented mixin applied.\n *\n * @param {Object} target\n * An object to Add\n * @param {Function} callback\n * The callback to run.\n */\nconst addEventedCallback = (target, callback) => {\n if (isEvented(target)) {\n callback();\n } else {\n if (!target.eventedCallbacks) {\n target.eventedCallbacks = [];\n }\n target.eventedCallbacks.push(callback);\n }\n};\n\n/**\n * Whether a value is a valid event type - non-empty string or array.\n *\n * @private\n * @param {string|Array} type\n * The type value to test.\n *\n * @return {boolean}\n * Whether or not the type is a valid event type.\n */\nconst isValidEventType = type =>\n// The regex here verifies that the `type` contains at least one non-\n// whitespace character.\ntypeof type === 'string' && /\\S/.test(type) || Array.isArray(type) && !!type.length;\n\n/**\n * Validates a value to determine if it is a valid event target. Throws if not.\n *\n * @private\n * @throws {Error}\n * If the target does not appear to be a valid event target.\n *\n * @param {Object} target\n * The object to test.\n *\n * @param {Object} obj\n * The evented object we are validating for\n *\n * @param {string} fnName\n * The name of the evented mixin function that called this.\n */\nconst validateTarget = (target, obj, fnName) => {\n if (!target || !target.nodeName && !isEvented(target)) {\n throw new Error(`Invalid target for ${objName(obj)}#${fnName}; must be a DOM node or evented object.`);\n }\n};\n\n/**\n * Validates a value to determine if it is a valid event target. Throws if not.\n *\n * @private\n * @throws {Error}\n * If the type does not appear to be a valid event type.\n *\n * @param {string|Array} type\n * The type to test.\n *\n * @param {Object} obj\n* The evented object we are validating for\n *\n * @param {string} fnName\n * The name of the evented mixin function that called this.\n */\nconst validateEventType = (type, obj, fnName) => {\n if (!isValidEventType(type)) {\n throw new Error(`Invalid event type for ${objName(obj)}#${fnName}; must be a non-empty string or array.`);\n }\n};\n\n/**\n * Validates a value to determine if it is a valid listener. Throws if not.\n *\n * @private\n * @throws {Error}\n * If the listener is not a function.\n *\n * @param {Function} listener\n * The listener to test.\n *\n * @param {Object} obj\n * The evented object we are validating for\n *\n * @param {string} fnName\n * The name of the evented mixin function that called this.\n */\nconst validateListener = (listener, obj, fnName) => {\n if (typeof listener !== 'function') {\n throw new Error(`Invalid listener for ${objName(obj)}#${fnName}; must be a function.`);\n }\n};\n\n/**\n * Takes an array of arguments given to `on()` or `one()`, validates them, and\n * normalizes them into an object.\n *\n * @private\n * @param {Object} self\n * The evented object on which `on()` or `one()` was called. This\n * object will be bound as the `this` value for the listener.\n *\n * @param {Array} args\n * An array of arguments passed to `on()` or `one()`.\n *\n * @param {string} fnName\n * The name of the evented mixin function that called this.\n *\n * @return {Object}\n * An object containing useful values for `on()` or `one()` calls.\n */\nconst normalizeListenArgs = (self, args, fnName) => {\n // If the number of arguments is less than 3, the target is always the\n // evented object itself.\n const isTargetingSelf = args.length < 3 || args[0] === self || args[0] === self.eventBusEl_;\n let target;\n let type;\n let listener;\n if (isTargetingSelf) {\n target = self.eventBusEl_;\n\n // Deal with cases where we got 3 arguments, but we are still listening to\n // the evented object itself.\n if (args.length >= 3) {\n args.shift();\n }\n [type, listener] = args;\n } else {\n [target, type, listener] = args;\n }\n validateTarget(target, self, fnName);\n validateEventType(type, self, fnName);\n validateListener(listener, self, fnName);\n listener = bind_(self, listener);\n return {\n isTargetingSelf,\n target,\n type,\n listener\n };\n};\n\n/**\n * Adds the listener to the event type(s) on the target, normalizing for\n * the type of target.\n *\n * @private\n * @param {Element|Object} target\n * A DOM node or evented object.\n *\n * @param {string} method\n * The event binding method to use (\"on\" or \"one\").\n *\n * @param {string|Array} type\n * One or more event type(s).\n *\n * @param {Function} listener\n * A listener function.\n */\nconst listen = (target, method, type, listener) => {\n validateTarget(target, target, method);\n if (target.nodeName) {\n Events[method](target, type, listener);\n } else {\n target[method](type, listener);\n }\n};\n\n/**\n * Contains methods that provide event capabilities to an object which is passed\n * to {@link module:evented|evented}.\n *\n * @mixin EventedMixin\n */\nconst EventedMixin = {\n /**\n * Add a listener to an event (or events) on this object or another evented\n * object.\n *\n * @param {string|Array|Element|Object} targetOrType\n * If this is a string or array, it represents the event type(s)\n * that will trigger the listener.\n *\n * Another evented object can be passed here instead, which will\n * cause the listener to listen for events on _that_ object.\n *\n * In either case, the listener's `this` value will be bound to\n * this object.\n *\n * @param {string|Array|Function} typeOrListener\n * If the first argument was a string or array, this should be the\n * listener function. Otherwise, this is a string or array of event\n * type(s).\n *\n * @param {Function} [listener]\n * If the first argument was another evented object, this will be\n * the listener function.\n */\n on(...args) {\n const {\n isTargetingSelf,\n target,\n type,\n listener\n } = normalizeListenArgs(this, args, 'on');\n listen(target, 'on', type, listener);\n\n // If this object is listening to another evented object.\n if (!isTargetingSelf) {\n // If this object is disposed, remove the listener.\n const removeListenerOnDispose = () => this.off(target, type, listener);\n\n // Use the same function ID as the listener so we can remove it later it\n // using the ID of the original listener.\n removeListenerOnDispose.guid = listener.guid;\n\n // Add a listener to the target's dispose event as well. This ensures\n // that if the target is disposed BEFORE this object, we remove the\n // removal listener that was just added. Otherwise, we create a memory leak.\n const removeRemoverOnTargetDispose = () => this.off('dispose', removeListenerOnDispose);\n\n // Use the same function ID as the listener so we can remove it later\n // it using the ID of the original listener.\n removeRemoverOnTargetDispose.guid = listener.guid;\n listen(this, 'on', 'dispose', removeListenerOnDispose);\n listen(target, 'on', 'dispose', removeRemoverOnTargetDispose);\n }\n },\n /**\n * Add a listener to an event (or events) on this object or another evented\n * object. The listener will be called once per event and then removed.\n *\n * @param {string|Array|Element|Object} targetOrType\n * If this is a string or array, it represents the event type(s)\n * that will trigger the listener.\n *\n * Another evented object can be passed here instead, which will\n * cause the listener to listen for events on _that_ object.\n *\n * In either case, the listener's `this` value will be bound to\n * this object.\n *\n * @param {string|Array|Function} typeOrListener\n * If the first argument was a string or array, this should be the\n * listener function. Otherwise, this is a string or array of event\n * type(s).\n *\n * @param {Function} [listener]\n * If the first argument was another evented object, this will be\n * the listener function.\n */\n one(...args) {\n const {\n isTargetingSelf,\n target,\n type,\n listener\n } = normalizeListenArgs(this, args, 'one');\n\n // Targeting this evented object.\n if (isTargetingSelf) {\n listen(target, 'one', type, listener);\n\n // Targeting another evented object.\n } else {\n // TODO: This wrapper is incorrect! It should only\n // remove the wrapper for the event type that called it.\n // Instead all listeners are removed on the first trigger!\n // see https://github.com/videojs/video.js/issues/5962\n const wrapper = (...largs) => {\n this.off(target, type, wrapper);\n listener.apply(null, largs);\n };\n\n // Use the same function ID as the listener so we can remove it later\n // it using the ID of the original listener.\n wrapper.guid = listener.guid;\n listen(target, 'one', type, wrapper);\n }\n },\n /**\n * Add a listener to an event (or events) on this object or another evented\n * object. The listener will only be called once for the first event that is triggered\n * then removed.\n *\n * @param {string|Array|Element|Object} targetOrType\n * If this is a string or array, it represents the event type(s)\n * that will trigger the listener.\n *\n * Another evented object can be passed here instead, which will\n * cause the listener to listen for events on _that_ object.\n *\n * In either case, the listener's `this` value will be bound to\n * this object.\n *\n * @param {string|Array|Function} typeOrListener\n * If the first argument was a string or array, this should be the\n * listener function. Otherwise, this is a string or array of event\n * type(s).\n *\n * @param {Function} [listener]\n * If the first argument was another evented object, this will be\n * the listener function.\n */\n any(...args) {\n const {\n isTargetingSelf,\n target,\n type,\n listener\n } = normalizeListenArgs(this, args, 'any');\n\n // Targeting this evented object.\n if (isTargetingSelf) {\n listen(target, 'any', type, listener);\n\n // Targeting another evented object.\n } else {\n const wrapper = (...largs) => {\n this.off(target, type, wrapper);\n listener.apply(null, largs);\n };\n\n // Use the same function ID as the listener so we can remove it later\n // it using the ID of the original listener.\n wrapper.guid = listener.guid;\n listen(target, 'any', type, wrapper);\n }\n },\n /**\n * Removes listener(s) from event(s) on an evented object.\n *\n * @param {string|Array|Element|Object} [targetOrType]\n * If this is a string or array, it represents the event type(s).\n *\n * Another evented object can be passed here instead, in which case\n * ALL 3 arguments are _required_.\n *\n * @param {string|Array|Function} [typeOrListener]\n * If the first argument was a string or array, this may be the\n * listener function. Otherwise, this is a string or array of event\n * type(s).\n *\n * @param {Function} [listener]\n * If the first argument was another evented object, this will be\n * the listener function; otherwise, _all_ listeners bound to the\n * event type(s) will be removed.\n */\n off(targetOrType, typeOrListener, listener) {\n // Targeting this evented object.\n if (!targetOrType || isValidEventType(targetOrType)) {\n off(this.eventBusEl_, targetOrType, typeOrListener);\n\n // Targeting another evented object.\n } else {\n const target = targetOrType;\n const type = typeOrListener;\n\n // Fail fast and in a meaningful way!\n validateTarget(target, this, 'off');\n validateEventType(type, this, 'off');\n validateListener(listener, this, 'off');\n\n // Ensure there's at least a guid, even if the function hasn't been used\n listener = bind_(this, listener);\n\n // Remove the dispose listener on this evented object, which was given\n // the same guid as the event listener in on().\n this.off('dispose', listener);\n if (target.nodeName) {\n off(target, type, listener);\n off(target, 'dispose', listener);\n } else if (isEvented(target)) {\n target.off(type, listener);\n target.off('dispose', listener);\n }\n }\n },\n /**\n * Fire an event on this evented object, causing its listeners to be called.\n *\n * @param {string|Object} event\n * An event type or an object with a type property.\n *\n * @param {Object} [hash]\n * An additional object to pass along to listeners.\n *\n * @return {boolean}\n * Whether or not the default behavior was prevented.\n */\n trigger(event, hash) {\n validateTarget(this.eventBusEl_, this, 'trigger');\n const type = event && typeof event !== 'string' ? event.type : event;\n if (!isValidEventType(type)) {\n throw new Error(`Invalid event type for ${objName(this)}#trigger; ` + 'must be a non-empty string or object with a type key that has a non-empty value.');\n }\n return trigger(this.eventBusEl_, event, hash);\n }\n};\n\n/**\n * Applies {@link module:evented~EventedMixin|EventedMixin} to a target object.\n *\n * @param {Object} target\n * The object to which to add event methods.\n *\n * @param {Object} [options={}]\n * Options for customizing the mixin behavior.\n *\n * @param {string} [options.eventBusKey]\n * By default, adds a `eventBusEl_` DOM element to the target object,\n * which is used as an event bus. If the target object already has a\n * DOM element that should be used, pass its key here.\n *\n * @return {Object}\n * The target object.\n */\nfunction evented(target, options = {}) {\n const {\n eventBusKey\n } = options;\n\n // Set or create the eventBusEl_.\n if (eventBusKey) {\n if (!target[eventBusKey].nodeName) {\n throw new Error(`The eventBusKey \"${eventBusKey}\" does not refer to an element.`);\n }\n target.eventBusEl_ = target[eventBusKey];\n } else {\n target.eventBusEl_ = createEl('span', {\n className: 'vjs-event-bus'\n });\n }\n Object.assign(target, EventedMixin);\n if (target.eventedCallbacks) {\n target.eventedCallbacks.forEach(callback => {\n callback();\n });\n }\n\n // When any evented object is disposed, it removes all its listeners.\n target.on('dispose', () => {\n target.off();\n [target, target.el_, target.eventBusEl_].forEach(function (val) {\n if (val && DomData.has(val)) {\n DomData.delete(val);\n }\n });\n window$1.setTimeout(() => {\n target.eventBusEl_ = null;\n }, 0);\n });\n return target;\n}\n\n/**\n * @file mixins/stateful.js\n * @module stateful\n */\n\n/**\n * Contains methods that provide statefulness to an object which is passed\n * to {@link module:stateful}.\n *\n * @mixin StatefulMixin\n */\nconst StatefulMixin = {\n /**\n * A hash containing arbitrary keys and values representing the state of\n * the object.\n *\n * @type {Object}\n */\n state: {},\n /**\n * Set the state of an object by mutating its\n * {@link module:stateful~StatefulMixin.state|state} object in place.\n *\n * @fires module:stateful~StatefulMixin#statechanged\n * @param {Object|Function} stateUpdates\n * A new set of properties to shallow-merge into the plugin state.\n * Can be a plain object or a function returning a plain object.\n *\n * @return {Object|undefined}\n * An object containing changes that occurred. If no changes\n * occurred, returns `undefined`.\n */\n setState(stateUpdates) {\n // Support providing the `stateUpdates` state as a function.\n if (typeof stateUpdates === 'function') {\n stateUpdates = stateUpdates();\n }\n let changes;\n each(stateUpdates, (value, key) => {\n // Record the change if the value is different from what's in the\n // current state.\n if (this.state[key] !== value) {\n changes = changes || {};\n changes[key] = {\n from: this.state[key],\n to: value\n };\n }\n this.state[key] = value;\n });\n\n // Only trigger \"statechange\" if there were changes AND we have a trigger\n // function. This allows us to not require that the target object be an\n // evented object.\n if (changes && isEvented(this)) {\n /**\n * An event triggered on an object that is both\n * {@link module:stateful|stateful} and {@link module:evented|evented}\n * indicating that its state has changed.\n *\n * @event module:stateful~StatefulMixin#statechanged\n * @type {Object}\n * @property {Object} changes\n * A hash containing the properties that were changed and\n * the values they were changed `from` and `to`.\n */\n this.trigger({\n changes,\n type: 'statechanged'\n });\n }\n return changes;\n }\n};\n\n/**\n * Applies {@link module:stateful~StatefulMixin|StatefulMixin} to a target\n * object.\n *\n * If the target object is {@link module:evented|evented} and has a\n * `handleStateChanged` method, that method will be automatically bound to the\n * `statechanged` event on itself.\n *\n * @param {Object} target\n * The object to be made stateful.\n *\n * @param {Object} [defaultState]\n * A default set of properties to populate the newly-stateful object's\n * `state` property.\n *\n * @return {Object}\n * Returns the `target`.\n */\nfunction stateful(target, defaultState) {\n Object.assign(target, StatefulMixin);\n\n // This happens after the mixing-in because we need to replace the `state`\n // added in that step.\n target.state = Object.assign({}, target.state, defaultState);\n\n // Auto-bind the `handleStateChanged` method of the target object if it exists.\n if (typeof target.handleStateChanged === 'function' && isEvented(target)) {\n target.on('statechanged', target.handleStateChanged);\n }\n return target;\n}\n\n/**\n * @file str.js\n * @module to-lower-case\n */\n\n/**\n * Lowercase the first letter of a string.\n *\n * @param {string} string\n * String to be lowercased\n *\n * @return {string}\n * The string with a lowercased first letter\n */\nconst toLowerCase = function (string) {\n if (typeof string !== 'string') {\n return string;\n }\n return string.replace(/./, w => w.toLowerCase());\n};\n\n/**\n * Uppercase the first letter of a string.\n *\n * @param {string} string\n * String to be uppercased\n *\n * @return {string}\n * The string with an uppercased first letter\n */\nconst toTitleCase$1 = function (string) {\n if (typeof string !== 'string') {\n return string;\n }\n return string.replace(/./, w => w.toUpperCase());\n};\n\n/**\n * Compares the TitleCase versions of the two strings for equality.\n *\n * @param {string} str1\n * The first string to compare\n *\n * @param {string} str2\n * The second string to compare\n *\n * @return {boolean}\n * Whether the TitleCase versions of the strings are equal\n */\nconst titleCaseEquals = function (str1, str2) {\n return toTitleCase$1(str1) === toTitleCase$1(str2);\n};\n\nvar Str = /*#__PURE__*/Object.freeze({\n __proto__: null,\n toLowerCase: toLowerCase,\n toTitleCase: toTitleCase$1,\n titleCaseEquals: titleCaseEquals\n});\n\n/**\n * Player Component - Base class for all UI objects\n *\n * @file component.js\n */\n\n/**\n * Base class for all UI Components.\n * Components are UI objects which represent both a javascript object and an element\n * in the DOM. They can be children of other components, and can have\n * children themselves.\n *\n * Components can also use methods from {@link EventTarget}\n */\nclass Component$1 {\n /**\n * A callback that is called when a component is ready. Does not have any\n * parameters and any callback value will be ignored.\n *\n * @callback ReadyCallback\n * @this Component\n */\n\n /**\n * Creates an instance of this class.\n *\n * @param { import('./player').default } player\n * The `Player` that this class should be attached to.\n *\n * @param {Object} [options]\n * The key/value store of component options.\n *\n * @param {Object[]} [options.children]\n * An array of children objects to initialize this component with. Children objects have\n * a name property that will be used if more than one component of the same type needs to be\n * added.\n *\n * @param {string} [options.className]\n * A class or space separated list of classes to add the component\n *\n * @param {ReadyCallback} [ready]\n * Function that gets called when the `Component` is ready.\n */\n constructor(player, options, ready) {\n // The component might be the player itself and we can't pass `this` to super\n if (!player && this.play) {\n this.player_ = player = this; // eslint-disable-line\n } else {\n this.player_ = player;\n }\n this.isDisposed_ = false;\n\n // Hold the reference to the parent component via `addChild` method\n this.parentComponent_ = null;\n\n // Make a copy of prototype.options_ to protect against overriding defaults\n this.options_ = merge$1({}, this.options_);\n\n // Updated options with supplied options\n options = this.options_ = merge$1(this.options_, options);\n\n // Get ID from options or options element if one is supplied\n this.id_ = options.id || options.el && options.el.id;\n\n // If there was no ID from the options, generate one\n if (!this.id_) {\n // Don't require the player ID function in the case of mock players\n const id = player && player.id && player.id() || 'no_player';\n this.id_ = `${id}_component_${newGUID()}`;\n }\n this.name_ = options.name || null;\n\n // Create element if one wasn't provided in options\n if (options.el) {\n this.el_ = options.el;\n } else if (options.createEl !== false) {\n this.el_ = this.createEl();\n }\n if (options.className && this.el_) {\n options.className.split(' ').forEach(c => this.addClass(c));\n }\n\n // Remove the placeholder event methods. If the component is evented, the\n // real methods are added next\n ['on', 'off', 'one', 'any', 'trigger'].forEach(fn => {\n this[fn] = undefined;\n });\n\n // if evented is anything except false, we want to mixin in evented\n if (options.evented !== false) {\n // Make this an evented object and use `el_`, if available, as its event bus\n evented(this, {\n eventBusKey: this.el_ ? 'el_' : null\n });\n this.handleLanguagechange = this.handleLanguagechange.bind(this);\n this.on(this.player_, 'languagechange', this.handleLanguagechange);\n }\n stateful(this, this.constructor.defaultState);\n this.children_ = [];\n this.childIndex_ = {};\n this.childNameIndex_ = {};\n this.setTimeoutIds_ = new Set();\n this.setIntervalIds_ = new Set();\n this.rafIds_ = new Set();\n this.namedRafs_ = new Map();\n this.clearingTimersOnDispose_ = false;\n\n // Add any child components in options\n if (options.initChildren !== false) {\n this.initChildren();\n }\n\n // Don't want to trigger ready here or it will go before init is actually\n // finished for all children that run this constructor\n this.ready(ready);\n if (options.reportTouchActivity !== false) {\n this.enableTouchActivity();\n }\n }\n\n // `on`, `off`, `one`, `any` and `trigger` are here so tsc includes them in definitions.\n // They are replaced or removed in the constructor\n\n /**\n * Adds an `event listener` to an instance of an `EventTarget`. An `event listener` is a\n * function that will get called when an event with a certain name gets triggered.\n *\n * @param {string|string[]} type\n * An event name or an array of event names.\n *\n * @param {Function} fn\n * The function to call with `EventTarget`s\n */\n on(type, fn) {}\n\n /**\n * Removes an `event listener` for a specific event from an instance of `EventTarget`.\n * This makes it so that the `event listener` will no longer get called when the\n * named event happens.\n *\n * @param {string|string[]} type\n * An event name or an array of event names.\n *\n * @param {Function} fn\n * The function to remove.\n */\n off(type, fn) {}\n\n /**\n * This function will add an `event listener` that gets triggered only once. After the\n * first trigger it will get removed. This is like adding an `event listener`\n * with {@link EventTarget#on} that calls {@link EventTarget#off} on itself.\n *\n * @param {string|string[]} type\n * An event name or an array of event names.\n *\n * @param {Function} fn\n * The function to be called once for each event name.\n */\n one(type, fn) {}\n\n /**\n * This function will add an `event listener` that gets triggered only once and is\n * removed from all events. This is like adding an array of `event listener`s\n * with {@link EventTarget#on} that calls {@link EventTarget#off} on all events the\n * first time it is triggered.\n *\n * @param {string|string[]} type\n * An event name or an array of event names.\n *\n * @param {Function} fn\n * The function to be called once for each event name.\n */\n any(type, fn) {}\n\n /**\n * This function causes an event to happen. This will then cause any `event listeners`\n * that are waiting for that event, to get called. If there are no `event listeners`\n * for an event then nothing will happen.\n *\n * If the name of the `Event` that is being triggered is in `EventTarget.allowedEvents_`.\n * Trigger will also call the `on` + `uppercaseEventName` function.\n *\n * Example:\n * 'click' is in `EventTarget.allowedEvents_`, so, trigger will attempt to call\n * `onClick` if it exists.\n *\n * @param {string|Event|Object} event\n * The name of the event, an `Event`, or an object with a key of type set to\n * an event name.\n *\n * @param {Object} [hash]\n * Optionally extra argument to pass through to an event listener\n */\n trigger(event, hash) {}\n\n /**\n * Dispose of the `Component` and all child components.\n *\n * @fires Component#dispose\n *\n * @param {Object} options\n * @param {Element} options.originalEl element with which to replace player element\n */\n dispose(options = {}) {\n // Bail out if the component has already been disposed.\n if (this.isDisposed_) {\n return;\n }\n if (this.readyQueue_) {\n this.readyQueue_.length = 0;\n }\n\n /**\n * Triggered when a `Component` is disposed.\n *\n * @event Component#dispose\n * @type {Event}\n *\n * @property {boolean} [bubbles=false]\n * set to false so that the dispose event does not\n * bubble up\n */\n this.trigger({\n type: 'dispose',\n bubbles: false\n });\n this.isDisposed_ = true;\n\n // Dispose all children.\n if (this.children_) {\n for (let i = this.children_.length - 1; i >= 0; i--) {\n if (this.children_[i].dispose) {\n this.children_[i].dispose();\n }\n }\n }\n\n // Delete child references\n this.children_ = null;\n this.childIndex_ = null;\n this.childNameIndex_ = null;\n this.parentComponent_ = null;\n if (this.el_) {\n // Remove element from DOM\n if (this.el_.parentNode) {\n if (options.restoreEl) {\n this.el_.parentNode.replaceChild(options.restoreEl, this.el_);\n } else {\n this.el_.parentNode.removeChild(this.el_);\n }\n }\n this.el_ = null;\n }\n\n // remove reference to the player after disposing of the element\n this.player_ = null;\n }\n\n /**\n * Determine whether or not this component has been disposed.\n *\n * @return {boolean}\n * If the component has been disposed, will be `true`. Otherwise, `false`.\n */\n isDisposed() {\n return Boolean(this.isDisposed_);\n }\n\n /**\n * Return the {@link Player} that the `Component` has attached to.\n *\n * @return { import('./player').default }\n * The player that this `Component` has attached to.\n */\n player() {\n return this.player_;\n }\n\n /**\n * Deep merge of options objects with new options.\n * > Note: When both `obj` and `options` contain properties whose values are objects.\n * The two properties get merged using {@link module:obj.merge}\n *\n * @param {Object} obj\n * The object that contains new options.\n *\n * @return {Object}\n * A new object of `this.options_` and `obj` merged together.\n */\n options(obj) {\n if (!obj) {\n return this.options_;\n }\n this.options_ = merge$1(this.options_, obj);\n return this.options_;\n }\n\n /**\n * Get the `Component`s DOM element\n *\n * @return {Element}\n * The DOM element for this `Component`.\n */\n el() {\n return this.el_;\n }\n\n /**\n * Create the `Component`s DOM element.\n *\n * @param {string} [tagName]\n * Element's DOM node type. e.g. 'div'\n *\n * @param {Object} [properties]\n * An object of properties that should be set.\n *\n * @param {Object} [attributes]\n * An object of attributes that should be set.\n *\n * @return {Element}\n * The element that gets created.\n */\n createEl(tagName, properties, attributes) {\n return createEl(tagName, properties, attributes);\n }\n\n /**\n * Localize a string given the string in english.\n *\n * If tokens are provided, it'll try and run a simple token replacement on the provided string.\n * The tokens it looks for look like `{1}` with the index being 1-indexed into the tokens array.\n *\n * If a `defaultValue` is provided, it'll use that over `string`,\n * if a value isn't found in provided language files.\n * This is useful if you want to have a descriptive key for token replacement\n * but have a succinct localized string and not require `en.json` to be included.\n *\n * Currently, it is used for the progress bar timing.\n * ```js\n * {\n * \"progress bar timing: currentTime={1} duration={2}\": \"{1} of {2}\"\n * }\n * ```\n * It is then used like so:\n * ```js\n * this.localize('progress bar timing: currentTime={1} duration{2}',\n * [this.player_.currentTime(), this.player_.duration()],\n * '{1} of {2}');\n * ```\n *\n * Which outputs something like: `01:23 of 24:56`.\n *\n *\n * @param {string} string\n * The string to localize and the key to lookup in the language files.\n * @param {string[]} [tokens]\n * If the current item has token replacements, provide the tokens here.\n * @param {string} [defaultValue]\n * Defaults to `string`. Can be a default value to use for token replacement\n * if the lookup key is needed to be separate.\n *\n * @return {string}\n * The localized string or if no localization exists the english string.\n */\n localize(string, tokens, defaultValue = string) {\n const code = this.player_.language && this.player_.language();\n const languages = this.player_.languages && this.player_.languages();\n const language = languages && languages[code];\n const primaryCode = code && code.split('-')[0];\n const primaryLang = languages && languages[primaryCode];\n let localizedString = defaultValue;\n if (language && language[string]) {\n localizedString = language[string];\n } else if (primaryLang && primaryLang[string]) {\n localizedString = primaryLang[string];\n }\n if (tokens) {\n localizedString = localizedString.replace(/\\{(\\d+)\\}/g, function (match, index) {\n const value = tokens[index - 1];\n let ret = value;\n if (typeof value === 'undefined') {\n ret = match;\n }\n return ret;\n });\n }\n return localizedString;\n }\n\n /**\n * Handles language change for the player in components. Should be overridden by sub-components.\n *\n * @abstract\n */\n handleLanguagechange() {}\n\n /**\n * Return the `Component`s DOM element. This is where children get inserted.\n * This will usually be the the same as the element returned in {@link Component#el}.\n *\n * @return {Element}\n * The content element for this `Component`.\n */\n contentEl() {\n return this.contentEl_ || this.el_;\n }\n\n /**\n * Get this `Component`s ID\n *\n * @return {string}\n * The id of this `Component`\n */\n id() {\n return this.id_;\n }\n\n /**\n * Get the `Component`s name. The name gets used to reference the `Component`\n * and is set during registration.\n *\n * @return {string}\n * The name of this `Component`.\n */\n name() {\n return this.name_;\n }\n\n /**\n * Get an array of all child components\n *\n * @return {Array}\n * The children\n */\n children() {\n return this.children_;\n }\n\n /**\n * Returns the child `Component` with the given `id`.\n *\n * @param {string} id\n * The id of the child `Component` to get.\n *\n * @return {Component|undefined}\n * The child `Component` with the given `id` or undefined.\n */\n getChildById(id) {\n return this.childIndex_[id];\n }\n\n /**\n * Returns the child `Component` with the given `name`.\n *\n * @param {string} name\n * The name of the child `Component` to get.\n *\n * @return {Component|undefined}\n * The child `Component` with the given `name` or undefined.\n */\n getChild(name) {\n if (!name) {\n return;\n }\n return this.childNameIndex_[name];\n }\n\n /**\n * Returns the descendant `Component` following the givent\n * descendant `names`. For instance ['foo', 'bar', 'baz'] would\n * try to get 'foo' on the current component, 'bar' on the 'foo'\n * component and 'baz' on the 'bar' component and return undefined\n * if any of those don't exist.\n *\n * @param {...string[]|...string} names\n * The name of the child `Component` to get.\n *\n * @return {Component|undefined}\n * The descendant `Component` following the given descendant\n * `names` or undefined.\n */\n getDescendant(...names) {\n // flatten array argument into the main array\n names = names.reduce((acc, n) => acc.concat(n), []);\n let currentChild = this;\n for (let i = 0; i < names.length; i++) {\n currentChild = currentChild.getChild(names[i]);\n if (!currentChild || !currentChild.getChild) {\n return;\n }\n }\n return currentChild;\n }\n\n /**\n * Adds an SVG icon element to another element or component.\n *\n * @param {string} iconName\n * The name of icon. A list of all the icon names can be found at 'sandbox/svg-icons.html'\n *\n * @param {Element} [el=this.el()]\n * Element to set the title on. Defaults to the current Component's element.\n *\n * @return {Element}\n * The newly created icon element.\n */\n setIcon(iconName, el = this.el()) {\n // TODO: In v9 of video.js, we will want to remove font icons entirely.\n // This means this check, as well as the others throughout the code, and\n // the unecessary CSS for font icons, will need to be removed.\n // See https://github.com/videojs/video.js/pull/8260 as to which components\n // need updating.\n if (!this.player_.options_.experimentalSvgIcons) {\n return;\n }\n const xmlnsURL = 'http://www.w3.org/2000/svg';\n\n // The below creates an element in the format of:\n // \n const iconContainer = createEl('span', {\n className: 'vjs-icon-placeholder vjs-svg-icon'\n }, {\n 'aria-hidden': 'true'\n });\n const svgEl = document.createElementNS(xmlnsURL, 'svg');\n svgEl.setAttributeNS(null, 'viewBox', '0 0 512 512');\n const useEl = document.createElementNS(xmlnsURL, 'use');\n svgEl.appendChild(useEl);\n useEl.setAttributeNS(null, 'href', `#vjs-icon-${iconName}`);\n iconContainer.appendChild(svgEl);\n\n // Replace a pre-existing icon if one exists.\n if (this.iconIsSet_) {\n el.replaceChild(iconContainer, el.querySelector('.vjs-icon-placeholder'));\n } else {\n el.appendChild(iconContainer);\n }\n this.iconIsSet_ = true;\n return iconContainer;\n }\n\n /**\n * Add a child `Component` inside the current `Component`.\n *\n * @param {string|Component} child\n * The name or instance of a child to add.\n *\n * @param {Object} [options={}]\n * The key/value store of options that will get passed to children of\n * the child.\n *\n * @param {number} [index=this.children_.length]\n * The index to attempt to add a child into.\n *\n *\n * @return {Component}\n * The `Component` that gets added as a child. When using a string the\n * `Component` will get created by this process.\n */\n addChild(child, options = {}, index = this.children_.length) {\n let component;\n let componentName;\n\n // If child is a string, create component with options\n if (typeof child === 'string') {\n componentName = toTitleCase$1(child);\n const componentClassName = options.componentClass || componentName;\n\n // Set name through options\n options.name = componentName;\n\n // Create a new object & element for this controls set\n // If there's no .player_, this is a player\n const ComponentClass = Component$1.getComponent(componentClassName);\n if (!ComponentClass) {\n throw new Error(`Component ${componentClassName} does not exist`);\n }\n\n // data stored directly on the videojs object may be\n // misidentified as a component to retain\n // backwards-compatibility with 4.x. check to make sure the\n // component class can be instantiated.\n if (typeof ComponentClass !== 'function') {\n return null;\n }\n component = new ComponentClass(this.player_ || this, options);\n\n // child is a component instance\n } else {\n component = child;\n }\n if (component.parentComponent_) {\n component.parentComponent_.removeChild(component);\n }\n this.children_.splice(index, 0, component);\n component.parentComponent_ = this;\n if (typeof component.id === 'function') {\n this.childIndex_[component.id()] = component;\n }\n\n // If a name wasn't used to create the component, check if we can use the\n // name function of the component\n componentName = componentName || component.name && toTitleCase$1(component.name());\n if (componentName) {\n this.childNameIndex_[componentName] = component;\n this.childNameIndex_[toLowerCase(componentName)] = component;\n }\n\n // Add the UI object's element to the container div (box)\n // Having an element is not required\n if (typeof component.el === 'function' && component.el()) {\n // If inserting before a component, insert before that component's element\n let refNode = null;\n if (this.children_[index + 1]) {\n // Most children are components, but the video tech is an HTML element\n if (this.children_[index + 1].el_) {\n refNode = this.children_[index + 1].el_;\n } else if (isEl(this.children_[index + 1])) {\n refNode = this.children_[index + 1];\n }\n }\n this.contentEl().insertBefore(component.el(), refNode);\n }\n\n // Return so it can stored on parent object if desired.\n return component;\n }\n\n /**\n * Remove a child `Component` from this `Component`s list of children. Also removes\n * the child `Component`s element from this `Component`s element.\n *\n * @param {Component} component\n * The child `Component` to remove.\n */\n removeChild(component) {\n if (typeof component === 'string') {\n component = this.getChild(component);\n }\n if (!component || !this.children_) {\n return;\n }\n let childFound = false;\n for (let i = this.children_.length - 1; i >= 0; i--) {\n if (this.children_[i] === component) {\n childFound = true;\n this.children_.splice(i, 1);\n break;\n }\n }\n if (!childFound) {\n return;\n }\n component.parentComponent_ = null;\n this.childIndex_[component.id()] = null;\n this.childNameIndex_[toTitleCase$1(component.name())] = null;\n this.childNameIndex_[toLowerCase(component.name())] = null;\n const compEl = component.el();\n if (compEl && compEl.parentNode === this.contentEl()) {\n this.contentEl().removeChild(component.el());\n }\n }\n\n /**\n * Add and initialize default child `Component`s based upon options.\n */\n initChildren() {\n const children = this.options_.children;\n if (children) {\n // `this` is `parent`\n const parentOptions = this.options_;\n const handleAdd = child => {\n const name = child.name;\n let opts = child.opts;\n\n // Allow options for children to be set at the parent options\n // e.g. videojs(id, { controlBar: false });\n // instead of videojs(id, { children: { controlBar: false });\n if (parentOptions[name] !== undefined) {\n opts = parentOptions[name];\n }\n\n // Allow for disabling default components\n // e.g. options['children']['posterImage'] = false\n if (opts === false) {\n return;\n }\n\n // Allow options to be passed as a simple boolean if no configuration\n // is necessary.\n if (opts === true) {\n opts = {};\n }\n\n // We also want to pass the original player options\n // to each component as well so they don't need to\n // reach back into the player for options later.\n opts.playerOptions = this.options_.playerOptions;\n\n // Create and add the child component.\n // Add a direct reference to the child by name on the parent instance.\n // If two of the same component are used, different names should be supplied\n // for each\n const newChild = this.addChild(name, opts);\n if (newChild) {\n this[name] = newChild;\n }\n };\n\n // Allow for an array of children details to passed in the options\n let workingChildren;\n const Tech = Component$1.getComponent('Tech');\n if (Array.isArray(children)) {\n workingChildren = children;\n } else {\n workingChildren = Object.keys(children);\n }\n workingChildren\n // children that are in this.options_ but also in workingChildren would\n // give us extra children we do not want. So, we want to filter them out.\n .concat(Object.keys(this.options_).filter(function (child) {\n return !workingChildren.some(function (wchild) {\n if (typeof wchild === 'string') {\n return child === wchild;\n }\n return child === wchild.name;\n });\n })).map(child => {\n let name;\n let opts;\n if (typeof child === 'string') {\n name = child;\n opts = children[name] || this.options_[name] || {};\n } else {\n name = child.name;\n opts = child;\n }\n return {\n name,\n opts\n };\n }).filter(child => {\n // we have to make sure that child.name isn't in the techOrder since\n // techs are registered as Components but can't aren't compatible\n // See https://github.com/videojs/video.js/issues/2772\n const c = Component$1.getComponent(child.opts.componentClass || toTitleCase$1(child.name));\n return c && !Tech.isTech(c);\n }).forEach(handleAdd);\n }\n }\n\n /**\n * Builds the default DOM class name. Should be overridden by sub-components.\n *\n * @return {string}\n * The DOM class name for this object.\n *\n * @abstract\n */\n buildCSSClass() {\n // Child classes can include a function that does:\n // return 'CLASS NAME' + this._super();\n return '';\n }\n\n /**\n * Bind a listener to the component's ready state.\n * Different from event listeners in that if the ready event has already happened\n * it will trigger the function immediately.\n *\n * @param {ReadyCallback} fn\n * Function that gets called when the `Component` is ready.\n *\n * @return {Component}\n * Returns itself; method can be chained.\n */\n ready(fn, sync = false) {\n if (!fn) {\n return;\n }\n if (!this.isReady_) {\n this.readyQueue_ = this.readyQueue_ || [];\n this.readyQueue_.push(fn);\n return;\n }\n if (sync) {\n fn.call(this);\n } else {\n // Call the function asynchronously by default for consistency\n this.setTimeout(fn, 1);\n }\n }\n\n /**\n * Trigger all the ready listeners for this `Component`.\n *\n * @fires Component#ready\n */\n triggerReady() {\n this.isReady_ = true;\n\n // Ensure ready is triggered asynchronously\n this.setTimeout(function () {\n const readyQueue = this.readyQueue_;\n\n // Reset Ready Queue\n this.readyQueue_ = [];\n if (readyQueue && readyQueue.length > 0) {\n readyQueue.forEach(function (fn) {\n fn.call(this);\n }, this);\n }\n\n // Allow for using event listeners also\n /**\n * Triggered when a `Component` is ready.\n *\n * @event Component#ready\n * @type {Event}\n */\n this.trigger('ready');\n }, 1);\n }\n\n /**\n * Find a single DOM element matching a `selector`. This can be within the `Component`s\n * `contentEl()` or another custom context.\n *\n * @param {string} selector\n * A valid CSS selector, which will be passed to `querySelector`.\n *\n * @param {Element|string} [context=this.contentEl()]\n * A DOM element within which to query. Can also be a selector string in\n * which case the first matching element will get used as context. If\n * missing `this.contentEl()` gets used. If `this.contentEl()` returns\n * nothing it falls back to `document`.\n *\n * @return {Element|null}\n * the dom element that was found, or null\n *\n * @see [Information on CSS Selectors](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_Started/Selectors)\n */\n $(selector, context) {\n return $(selector, context || this.contentEl());\n }\n\n /**\n * Finds all DOM element matching a `selector`. This can be within the `Component`s\n * `contentEl()` or another custom context.\n *\n * @param {string} selector\n * A valid CSS selector, which will be passed to `querySelectorAll`.\n *\n * @param {Element|string} [context=this.contentEl()]\n * A DOM element within which to query. Can also be a selector string in\n * which case the first matching element will get used as context. If\n * missing `this.contentEl()` gets used. If `this.contentEl()` returns\n * nothing it falls back to `document`.\n *\n * @return {NodeList}\n * a list of dom elements that were found\n *\n * @see [Information on CSS Selectors](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_Started/Selectors)\n */\n $$(selector, context) {\n return $$(selector, context || this.contentEl());\n }\n\n /**\n * Check if a component's element has a CSS class name.\n *\n * @param {string} classToCheck\n * CSS class name to check.\n *\n * @return {boolean}\n * - True if the `Component` has the class.\n * - False if the `Component` does not have the class`\n */\n hasClass(classToCheck) {\n return hasClass(this.el_, classToCheck);\n }\n\n /**\n * Add a CSS class name to the `Component`s element.\n *\n * @param {...string} classesToAdd\n * One or more CSS class name to add.\n */\n addClass(...classesToAdd) {\n addClass(this.el_, ...classesToAdd);\n }\n\n /**\n * Remove a CSS class name from the `Component`s element.\n *\n * @param {...string} classesToRemove\n * One or more CSS class name to remove.\n */\n removeClass(...classesToRemove) {\n removeClass(this.el_, ...classesToRemove);\n }\n\n /**\n * Add or remove a CSS class name from the component's element.\n * - `classToToggle` gets added when {@link Component#hasClass} would return false.\n * - `classToToggle` gets removed when {@link Component#hasClass} would return true.\n *\n * @param {string} classToToggle\n * The class to add or remove based on (@link Component#hasClass}\n *\n * @param {boolean|Dom~predicate} [predicate]\n * An {@link Dom~predicate} function or a boolean\n */\n toggleClass(classToToggle, predicate) {\n toggleClass(this.el_, classToToggle, predicate);\n }\n\n /**\n * Show the `Component`s element if it is hidden by removing the\n * 'vjs-hidden' class name from it.\n */\n show() {\n this.removeClass('vjs-hidden');\n }\n\n /**\n * Hide the `Component`s element if it is currently showing by adding the\n * 'vjs-hidden` class name to it.\n */\n hide() {\n this.addClass('vjs-hidden');\n }\n\n /**\n * Lock a `Component`s element in its visible state by adding the 'vjs-lock-showing'\n * class name to it. Used during fadeIn/fadeOut.\n *\n * @private\n */\n lockShowing() {\n this.addClass('vjs-lock-showing');\n }\n\n /**\n * Unlock a `Component`s element from its visible state by removing the 'vjs-lock-showing'\n * class name from it. Used during fadeIn/fadeOut.\n *\n * @private\n */\n unlockShowing() {\n this.removeClass('vjs-lock-showing');\n }\n\n /**\n * Get the value of an attribute on the `Component`s element.\n *\n * @param {string} attribute\n * Name of the attribute to get the value from.\n *\n * @return {string|null}\n * - The value of the attribute that was asked for.\n * - Can be an empty string on some browsers if the attribute does not exist\n * or has no value\n * - Most browsers will return null if the attribute does not exist or has\n * no value.\n *\n * @see [DOM API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute}\n */\n getAttribute(attribute) {\n return getAttribute(this.el_, attribute);\n }\n\n /**\n * Set the value of an attribute on the `Component`'s element\n *\n * @param {string} attribute\n * Name of the attribute to set.\n *\n * @param {string} value\n * Value to set the attribute to.\n *\n * @see [DOM API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute}\n */\n setAttribute(attribute, value) {\n setAttribute(this.el_, attribute, value);\n }\n\n /**\n * Remove an attribute from the `Component`s element.\n *\n * @param {string} attribute\n * Name of the attribute to remove.\n *\n * @see [DOM API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute}\n */\n removeAttribute(attribute) {\n removeAttribute(this.el_, attribute);\n }\n\n /**\n * Get or set the width of the component based upon the CSS styles.\n * See {@link Component#dimension} for more detailed information.\n *\n * @param {number|string} [num]\n * The width that you want to set postfixed with '%', 'px' or nothing.\n *\n * @param {boolean} [skipListeners]\n * Skip the componentresize event trigger\n *\n * @return {number|undefined}\n * The width when getting, zero if there is no width\n */\n width(num, skipListeners) {\n return this.dimension('width', num, skipListeners);\n }\n\n /**\n * Get or set the height of the component based upon the CSS styles.\n * See {@link Component#dimension} for more detailed information.\n *\n * @param {number|string} [num]\n * The height that you want to set postfixed with '%', 'px' or nothing.\n *\n * @param {boolean} [skipListeners]\n * Skip the componentresize event trigger\n *\n * @return {number|undefined}\n * The height when getting, zero if there is no height\n */\n height(num, skipListeners) {\n return this.dimension('height', num, skipListeners);\n }\n\n /**\n * Set both the width and height of the `Component` element at the same time.\n *\n * @param {number|string} width\n * Width to set the `Component`s element to.\n *\n * @param {number|string} height\n * Height to set the `Component`s element to.\n */\n dimensions(width, height) {\n // Skip componentresize listeners on width for optimization\n this.width(width, true);\n this.height(height);\n }\n\n /**\n * Get or set width or height of the `Component` element. This is the shared code\n * for the {@link Component#width} and {@link Component#height}.\n *\n * Things to know:\n * - If the width or height in an number this will return the number postfixed with 'px'.\n * - If the width/height is a percent this will return the percent postfixed with '%'\n * - Hidden elements have a width of 0 with `window.getComputedStyle`. This function\n * defaults to the `Component`s `style.width` and falls back to `window.getComputedStyle`.\n * See [this]{@link http://www.foliotek.com/devblog/getting-the-width-of-a-hidden-element-with-jquery-using-width/}\n * for more information\n * - If you want the computed style of the component, use {@link Component#currentWidth}\n * and {@link {Component#currentHeight}\n *\n * @fires Component#componentresize\n *\n * @param {string} widthOrHeight\n 8 'width' or 'height'\n *\n * @param {number|string} [num]\n 8 New dimension\n *\n * @param {boolean} [skipListeners]\n * Skip componentresize event trigger\n *\n * @return {number|undefined}\n * The dimension when getting or 0 if unset\n */\n dimension(widthOrHeight, num, skipListeners) {\n if (num !== undefined) {\n // Set to zero if null or literally NaN (NaN !== NaN)\n if (num === null || num !== num) {\n num = 0;\n }\n\n // Check if using css width/height (% or px) and adjust\n if (('' + num).indexOf('%') !== -1 || ('' + num).indexOf('px') !== -1) {\n this.el_.style[widthOrHeight] = num;\n } else if (num === 'auto') {\n this.el_.style[widthOrHeight] = '';\n } else {\n this.el_.style[widthOrHeight] = num + 'px';\n }\n\n // skipListeners allows us to avoid triggering the resize event when setting both width and height\n if (!skipListeners) {\n /**\n * Triggered when a component is resized.\n *\n * @event Component#componentresize\n * @type {Event}\n */\n this.trigger('componentresize');\n }\n return;\n }\n\n // Not setting a value, so getting it\n // Make sure element exists\n if (!this.el_) {\n return 0;\n }\n\n // Get dimension value from style\n const val = this.el_.style[widthOrHeight];\n const pxIndex = val.indexOf('px');\n if (pxIndex !== -1) {\n // Return the pixel value with no 'px'\n return parseInt(val.slice(0, pxIndex), 10);\n }\n\n // No px so using % or no style was set, so falling back to offsetWidth/height\n // If component has display:none, offset will return 0\n // TODO: handle display:none and no dimension style using px\n return parseInt(this.el_['offset' + toTitleCase$1(widthOrHeight)], 10);\n }\n\n /**\n * Get the computed width or the height of the component's element.\n *\n * Uses `window.getComputedStyle`.\n *\n * @param {string} widthOrHeight\n * A string containing 'width' or 'height'. Whichever one you want to get.\n *\n * @return {number}\n * The dimension that gets asked for or 0 if nothing was set\n * for that dimension.\n */\n currentDimension(widthOrHeight) {\n let computedWidthOrHeight = 0;\n if (widthOrHeight !== 'width' && widthOrHeight !== 'height') {\n throw new Error('currentDimension only accepts width or height value');\n }\n computedWidthOrHeight = computedStyle(this.el_, widthOrHeight);\n\n // remove 'px' from variable and parse as integer\n computedWidthOrHeight = parseFloat(computedWidthOrHeight);\n\n // if the computed value is still 0, it's possible that the browser is lying\n // and we want to check the offset values.\n // This code also runs wherever getComputedStyle doesn't exist.\n if (computedWidthOrHeight === 0 || isNaN(computedWidthOrHeight)) {\n const rule = `offset${toTitleCase$1(widthOrHeight)}`;\n computedWidthOrHeight = this.el_[rule];\n }\n return computedWidthOrHeight;\n }\n\n /**\n * An object that contains width and height values of the `Component`s\n * computed style. Uses `window.getComputedStyle`.\n *\n * @typedef {Object} Component~DimensionObject\n *\n * @property {number} width\n * The width of the `Component`s computed style.\n *\n * @property {number} height\n * The height of the `Component`s computed style.\n */\n\n /**\n * Get an object that contains computed width and height values of the\n * component's element.\n *\n * Uses `window.getComputedStyle`.\n *\n * @return {Component~DimensionObject}\n * The computed dimensions of the component's element.\n */\n currentDimensions() {\n return {\n width: this.currentDimension('width'),\n height: this.currentDimension('height')\n };\n }\n\n /**\n * Get the computed width of the component's element.\n *\n * Uses `window.getComputedStyle`.\n *\n * @return {number}\n * The computed width of the component's element.\n */\n currentWidth() {\n return this.currentDimension('width');\n }\n\n /**\n * Get the computed height of the component's element.\n *\n * Uses `window.getComputedStyle`.\n *\n * @return {number}\n * The computed height of the component's element.\n */\n currentHeight() {\n return this.currentDimension('height');\n }\n\n /**\n * Set the focus to this component\n */\n focus() {\n this.el_.focus();\n }\n\n /**\n * Remove the focus from this component\n */\n blur() {\n this.el_.blur();\n }\n\n /**\n * When this Component receives a `keydown` event which it does not process,\n * it passes the event to the Player for handling.\n *\n * @param {KeyboardEvent} event\n * The `keydown` event that caused this function to be called.\n */\n handleKeyDown(event) {\n if (this.player_) {\n // We only stop propagation here because we want unhandled events to fall\n // back to the browser. Exclude Tab for focus trapping.\n if (!keycode.isEventKey(event, 'Tab')) {\n event.stopPropagation();\n }\n this.player_.handleKeyDown(event);\n }\n }\n\n /**\n * Many components used to have a `handleKeyPress` method, which was poorly\n * named because it listened to a `keydown` event. This method name now\n * delegates to `handleKeyDown`. This means anyone calling `handleKeyPress`\n * will not see their method calls stop working.\n *\n * @param {KeyboardEvent} event\n * The event that caused this function to be called.\n */\n handleKeyPress(event) {\n this.handleKeyDown(event);\n }\n\n /**\n * Emit a 'tap' events when touch event support gets detected. This gets used to\n * support toggling the controls through a tap on the video. They get enabled\n * because every sub-component would have extra overhead otherwise.\n *\n * @protected\n * @fires Component#tap\n * @listens Component#touchstart\n * @listens Component#touchmove\n * @listens Component#touchleave\n * @listens Component#touchcancel\n * @listens Component#touchend\n */\n emitTapEvents() {\n // Track the start time so we can determine how long the touch lasted\n let touchStart = 0;\n let firstTouch = null;\n\n // Maximum movement allowed during a touch event to still be considered a tap\n // Other popular libs use anywhere from 2 (hammer.js) to 15,\n // so 10 seems like a nice, round number.\n const tapMovementThreshold = 10;\n\n // The maximum length a touch can be while still being considered a tap\n const touchTimeThreshold = 200;\n let couldBeTap;\n this.on('touchstart', function (event) {\n // If more than one finger, don't consider treating this as a click\n if (event.touches.length === 1) {\n // Copy pageX/pageY from the object\n firstTouch = {\n pageX: event.touches[0].pageX,\n pageY: event.touches[0].pageY\n };\n // Record start time so we can detect a tap vs. \"touch and hold\"\n touchStart = window$1.performance.now();\n // Reset couldBeTap tracking\n couldBeTap = true;\n }\n });\n this.on('touchmove', function (event) {\n // If more than one finger, don't consider treating this as a click\n if (event.touches.length > 1) {\n couldBeTap = false;\n } else if (firstTouch) {\n // Some devices will throw touchmoves for all but the slightest of taps.\n // So, if we moved only a small distance, this could still be a tap\n const xdiff = event.touches[0].pageX - firstTouch.pageX;\n const ydiff = event.touches[0].pageY - firstTouch.pageY;\n const touchDistance = Math.sqrt(xdiff * xdiff + ydiff * ydiff);\n if (touchDistance > tapMovementThreshold) {\n couldBeTap = false;\n }\n }\n });\n const noTap = function () {\n couldBeTap = false;\n };\n\n // TODO: Listen to the original target. http://youtu.be/DujfpXOKUp8?t=13m8s\n this.on('touchleave', noTap);\n this.on('touchcancel', noTap);\n\n // When the touch ends, measure how long it took and trigger the appropriate\n // event\n this.on('touchend', function (event) {\n firstTouch = null;\n // Proceed only if the touchmove/leave/cancel event didn't happen\n if (couldBeTap === true) {\n // Measure how long the touch lasted\n const touchTime = window$1.performance.now() - touchStart;\n\n // Make sure the touch was less than the threshold to be considered a tap\n if (touchTime < touchTimeThreshold) {\n // Don't let browser turn this into a click\n event.preventDefault();\n /**\n * Triggered when a `Component` is tapped.\n *\n * @event Component#tap\n * @type {MouseEvent}\n */\n this.trigger('tap');\n // It may be good to copy the touchend event object and change the\n // type to tap, if the other event properties aren't exact after\n // Events.fixEvent runs (e.g. event.target)\n }\n }\n });\n }\n\n /**\n * This function reports user activity whenever touch events happen. This can get\n * turned off by any sub-components that wants touch events to act another way.\n *\n * Report user touch activity when touch events occur. User activity gets used to\n * determine when controls should show/hide. It is simple when it comes to mouse\n * events, because any mouse event should show the controls. So we capture mouse\n * events that bubble up to the player and report activity when that happens.\n * With touch events it isn't as easy as `touchstart` and `touchend` toggle player\n * controls. So touch events can't help us at the player level either.\n *\n * User activity gets checked asynchronously. So what could happen is a tap event\n * on the video turns the controls off. Then the `touchend` event bubbles up to\n * the player. Which, if it reported user activity, would turn the controls right\n * back on. We also don't want to completely block touch events from bubbling up.\n * Furthermore a `touchmove` event and anything other than a tap, should not turn\n * controls back on.\n *\n * @listens Component#touchstart\n * @listens Component#touchmove\n * @listens Component#touchend\n * @listens Component#touchcancel\n */\n enableTouchActivity() {\n // Don't continue if the root player doesn't support reporting user activity\n if (!this.player() || !this.player().reportUserActivity) {\n return;\n }\n\n // listener for reporting that the user is active\n const report = bind_(this.player(), this.player().reportUserActivity);\n let touchHolding;\n this.on('touchstart', function () {\n report();\n // For as long as the they are touching the device or have their mouse down,\n // we consider them active even if they're not moving their finger or mouse.\n // So we want to continue to update that they are active\n this.clearInterval(touchHolding);\n // report at the same interval as activityCheck\n touchHolding = this.setInterval(report, 250);\n });\n const touchEnd = function (event) {\n report();\n // stop the interval that maintains activity if the touch is holding\n this.clearInterval(touchHolding);\n };\n this.on('touchmove', report);\n this.on('touchend', touchEnd);\n this.on('touchcancel', touchEnd);\n }\n\n /**\n * A callback that has no parameters and is bound into `Component`s context.\n *\n * @callback Component~GenericCallback\n * @this Component\n */\n\n /**\n * Creates a function that runs after an `x` millisecond timeout. This function is a\n * wrapper around `window.setTimeout`. There are a few reasons to use this one\n * instead though:\n * 1. It gets cleared via {@link Component#clearTimeout} when\n * {@link Component#dispose} gets called.\n * 2. The function callback will gets turned into a {@link Component~GenericCallback}\n *\n * > Note: You can't use `window.clearTimeout` on the id returned by this function. This\n * will cause its dispose listener not to get cleaned up! Please use\n * {@link Component#clearTimeout} or {@link Component#dispose} instead.\n *\n * @param {Component~GenericCallback} fn\n * The function that will be run after `timeout`.\n *\n * @param {number} timeout\n * Timeout in milliseconds to delay before executing the specified function.\n *\n * @return {number}\n * Returns a timeout ID that gets used to identify the timeout. It can also\n * get used in {@link Component#clearTimeout} to clear the timeout that\n * was set.\n *\n * @listens Component#dispose\n * @see [Similar to]{@link https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout}\n */\n setTimeout(fn, timeout) {\n // declare as variables so they are properly available in timeout function\n // eslint-disable-next-line\n var timeoutId;\n fn = bind_(this, fn);\n this.clearTimersOnDispose_();\n timeoutId = window$1.setTimeout(() => {\n if (this.setTimeoutIds_.has(timeoutId)) {\n this.setTimeoutIds_.delete(timeoutId);\n }\n fn();\n }, timeout);\n this.setTimeoutIds_.add(timeoutId);\n return timeoutId;\n }\n\n /**\n * Clears a timeout that gets created via `window.setTimeout` or\n * {@link Component#setTimeout}. If you set a timeout via {@link Component#setTimeout}\n * use this function instead of `window.clearTimout`. If you don't your dispose\n * listener will not get cleaned up until {@link Component#dispose}!\n *\n * @param {number} timeoutId\n * The id of the timeout to clear. The return value of\n * {@link Component#setTimeout} or `window.setTimeout`.\n *\n * @return {number}\n * Returns the timeout id that was cleared.\n *\n * @see [Similar to]{@link https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/clearTimeout}\n */\n clearTimeout(timeoutId) {\n if (this.setTimeoutIds_.has(timeoutId)) {\n this.setTimeoutIds_.delete(timeoutId);\n window$1.clearTimeout(timeoutId);\n }\n return timeoutId;\n }\n\n /**\n * Creates a function that gets run every `x` milliseconds. This function is a wrapper\n * around `window.setInterval`. There are a few reasons to use this one instead though.\n * 1. It gets cleared via {@link Component#clearInterval} when\n * {@link Component#dispose} gets called.\n * 2. The function callback will be a {@link Component~GenericCallback}\n *\n * @param {Component~GenericCallback} fn\n * The function to run every `x` seconds.\n *\n * @param {number} interval\n * Execute the specified function every `x` milliseconds.\n *\n * @return {number}\n * Returns an id that can be used to identify the interval. It can also be be used in\n * {@link Component#clearInterval} to clear the interval.\n *\n * @listens Component#dispose\n * @see [Similar to]{@link https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setInterval}\n */\n setInterval(fn, interval) {\n fn = bind_(this, fn);\n this.clearTimersOnDispose_();\n const intervalId = window$1.setInterval(fn, interval);\n this.setIntervalIds_.add(intervalId);\n return intervalId;\n }\n\n /**\n * Clears an interval that gets created via `window.setInterval` or\n * {@link Component#setInterval}. If you set an interval via {@link Component#setInterval}\n * use this function instead of `window.clearInterval`. If you don't your dispose\n * listener will not get cleaned up until {@link Component#dispose}!\n *\n * @param {number} intervalId\n * The id of the interval to clear. The return value of\n * {@link Component#setInterval} or `window.setInterval`.\n *\n * @return {number}\n * Returns the interval id that was cleared.\n *\n * @see [Similar to]{@link https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/clearInterval}\n */\n clearInterval(intervalId) {\n if (this.setIntervalIds_.has(intervalId)) {\n this.setIntervalIds_.delete(intervalId);\n window$1.clearInterval(intervalId);\n }\n return intervalId;\n }\n\n /**\n * Queues up a callback to be passed to requestAnimationFrame (rAF), but\n * with a few extra bonuses:\n *\n * - Supports browsers that do not support rAF by falling back to\n * {@link Component#setTimeout}.\n *\n * - The callback is turned into a {@link Component~GenericCallback} (i.e.\n * bound to the component).\n *\n * - Automatic cancellation of the rAF callback is handled if the component\n * is disposed before it is called.\n *\n * @param {Component~GenericCallback} fn\n * A function that will be bound to this component and executed just\n * before the browser's next repaint.\n *\n * @return {number}\n * Returns an rAF ID that gets used to identify the timeout. It can\n * also be used in {@link Component#cancelAnimationFrame} to cancel\n * the animation frame callback.\n *\n * @listens Component#dispose\n * @see [Similar to]{@link https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame}\n */\n requestAnimationFrame(fn) {\n this.clearTimersOnDispose_();\n\n // declare as variables so they are properly available in rAF function\n // eslint-disable-next-line\n var id;\n fn = bind_(this, fn);\n id = window$1.requestAnimationFrame(() => {\n if (this.rafIds_.has(id)) {\n this.rafIds_.delete(id);\n }\n fn();\n });\n this.rafIds_.add(id);\n return id;\n }\n\n /**\n * Request an animation frame, but only one named animation\n * frame will be queued. Another will never be added until\n * the previous one finishes.\n *\n * @param {string} name\n * The name to give this requestAnimationFrame\n *\n * @param {Component~GenericCallback} fn\n * A function that will be bound to this component and executed just\n * before the browser's next repaint.\n */\n requestNamedAnimationFrame(name, fn) {\n if (this.namedRafs_.has(name)) {\n return;\n }\n this.clearTimersOnDispose_();\n fn = bind_(this, fn);\n const id = this.requestAnimationFrame(() => {\n fn();\n if (this.namedRafs_.has(name)) {\n this.namedRafs_.delete(name);\n }\n });\n this.namedRafs_.set(name, id);\n return name;\n }\n\n /**\n * Cancels a current named animation frame if it exists.\n *\n * @param {string} name\n * The name of the requestAnimationFrame to cancel.\n */\n cancelNamedAnimationFrame(name) {\n if (!this.namedRafs_.has(name)) {\n return;\n }\n this.cancelAnimationFrame(this.namedRafs_.get(name));\n this.namedRafs_.delete(name);\n }\n\n /**\n * Cancels a queued callback passed to {@link Component#requestAnimationFrame}\n * (rAF).\n *\n * If you queue an rAF callback via {@link Component#requestAnimationFrame},\n * use this function instead of `window.cancelAnimationFrame`. If you don't,\n * your dispose listener will not get cleaned up until {@link Component#dispose}!\n *\n * @param {number} id\n * The rAF ID to clear. The return value of {@link Component#requestAnimationFrame}.\n *\n * @return {number}\n * Returns the rAF ID that was cleared.\n *\n * @see [Similar to]{@link https://developer.mozilla.org/en-US/docs/Web/API/window/cancelAnimationFrame}\n */\n cancelAnimationFrame(id) {\n if (this.rafIds_.has(id)) {\n this.rafIds_.delete(id);\n window$1.cancelAnimationFrame(id);\n }\n return id;\n }\n\n /**\n * A function to setup `requestAnimationFrame`, `setTimeout`,\n * and `setInterval`, clearing on dispose.\n *\n * > Previously each timer added and removed dispose listeners on it's own.\n * For better performance it was decided to batch them all, and use `Set`s\n * to track outstanding timer ids.\n *\n * @private\n */\n clearTimersOnDispose_() {\n if (this.clearingTimersOnDispose_) {\n return;\n }\n this.clearingTimersOnDispose_ = true;\n this.one('dispose', () => {\n [['namedRafs_', 'cancelNamedAnimationFrame'], ['rafIds_', 'cancelAnimationFrame'], ['setTimeoutIds_', 'clearTimeout'], ['setIntervalIds_', 'clearInterval']].forEach(([idName, cancelName]) => {\n // for a `Set` key will actually be the value again\n // so forEach((val, val) =>` but for maps we want to use\n // the key.\n this[idName].forEach((val, key) => this[cancelName](key));\n });\n this.clearingTimersOnDispose_ = false;\n });\n }\n\n /**\n * Register a `Component` with `videojs` given the name and the component.\n *\n * > NOTE: {@link Tech}s should not be registered as a `Component`. {@link Tech}s\n * should be registered using {@link Tech.registerTech} or\n * {@link videojs:videojs.registerTech}.\n *\n * > NOTE: This function can also be seen on videojs as\n * {@link videojs:videojs.registerComponent}.\n *\n * @param {string} name\n * The name of the `Component` to register.\n *\n * @param {Component} ComponentToRegister\n * The `Component` class to register.\n *\n * @return {Component}\n * The `Component` that was registered.\n */\n static registerComponent(name, ComponentToRegister) {\n if (typeof name !== 'string' || !name) {\n throw new Error(`Illegal component name, \"${name}\"; must be a non-empty string.`);\n }\n const Tech = Component$1.getComponent('Tech');\n\n // We need to make sure this check is only done if Tech has been registered.\n const isTech = Tech && Tech.isTech(ComponentToRegister);\n const isComp = Component$1 === ComponentToRegister || Component$1.prototype.isPrototypeOf(ComponentToRegister.prototype);\n if (isTech || !isComp) {\n let reason;\n if (isTech) {\n reason = 'techs must be registered using Tech.registerTech()';\n } else {\n reason = 'must be a Component subclass';\n }\n throw new Error(`Illegal component, \"${name}\"; ${reason}.`);\n }\n name = toTitleCase$1(name);\n if (!Component$1.components_) {\n Component$1.components_ = {};\n }\n const Player = Component$1.getComponent('Player');\n if (name === 'Player' && Player && Player.players) {\n const players = Player.players;\n const playerNames = Object.keys(players);\n\n // If we have players that were disposed, then their name will still be\n // in Players.players. So, we must loop through and verify that the value\n // for each item is not null. This allows registration of the Player component\n // after all players have been disposed or before any were created.\n if (players && playerNames.length > 0 && playerNames.map(pname => players[pname]).every(Boolean)) {\n throw new Error('Can not register Player component after player has been created.');\n }\n }\n Component$1.components_[name] = ComponentToRegister;\n Component$1.components_[toLowerCase(name)] = ComponentToRegister;\n return ComponentToRegister;\n }\n\n /**\n * Get a `Component` based on the name it was registered with.\n *\n * @param {string} name\n * The Name of the component to get.\n *\n * @return {Component}\n * The `Component` that got registered under the given name.\n */\n static getComponent(name) {\n if (!name || !Component$1.components_) {\n return;\n }\n return Component$1.components_[name];\n }\n}\nComponent$1.registerComponent('Component', Component$1);\n\n/**\n * @file time.js\n * @module time\n */\n\n/**\n * Returns the time for the specified index at the start or end\n * of a TimeRange object.\n *\n * @typedef {Function} TimeRangeIndex\n *\n * @param {number} [index=0]\n * The range number to return the time for.\n *\n * @return {number}\n * The time offset at the specified index.\n *\n * @deprecated The index argument must be provided.\n * In the future, leaving it out will throw an error.\n */\n\n/**\n * An object that contains ranges of time, which mimics {@link TimeRanges}.\n *\n * @typedef {Object} TimeRange\n *\n * @property {number} length\n * The number of time ranges represented by this object.\n *\n * @property {module:time~TimeRangeIndex} start\n * Returns the time offset at which a specified time range begins.\n *\n * @property {module:time~TimeRangeIndex} end\n * Returns the time offset at which a specified time range ends.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/TimeRanges\n */\n\n/**\n * Check if any of the time ranges are over the maximum index.\n *\n * @private\n * @param {string} fnName\n * The function name to use for logging\n *\n * @param {number} index\n * The index to check\n *\n * @param {number} maxIndex\n * The maximum possible index\n *\n * @throws {Error} if the timeRanges provided are over the maxIndex\n */\nfunction rangeCheck(fnName, index, maxIndex) {\n if (typeof index !== 'number' || index < 0 || index > maxIndex) {\n throw new Error(`Failed to execute '${fnName}' on 'TimeRanges': The index provided (${index}) is non-numeric or out of bounds (0-${maxIndex}).`);\n }\n}\n\n/**\n * Get the time for the specified index at the start or end\n * of a TimeRange object.\n *\n * @private\n * @param {string} fnName\n * The function name to use for logging\n *\n * @param {string} valueIndex\n * The property that should be used to get the time. should be\n * 'start' or 'end'\n *\n * @param {Array} ranges\n * An array of time ranges\n *\n * @param {Array} [rangeIndex=0]\n * The index to start the search at\n *\n * @return {number}\n * The time that offset at the specified index.\n *\n * @deprecated rangeIndex must be set to a value, in the future this will throw an error.\n * @throws {Error} if rangeIndex is more than the length of ranges\n */\nfunction getRange(fnName, valueIndex, ranges, rangeIndex) {\n rangeCheck(fnName, rangeIndex, ranges.length - 1);\n return ranges[rangeIndex][valueIndex];\n}\n\n/**\n * Create a time range object given ranges of time.\n *\n * @private\n * @param {Array} [ranges]\n * An array of time ranges.\n *\n * @return {TimeRange}\n */\nfunction createTimeRangesObj(ranges) {\n let timeRangesObj;\n if (ranges === undefined || ranges.length === 0) {\n timeRangesObj = {\n length: 0,\n start() {\n throw new Error('This TimeRanges object is empty');\n },\n end() {\n throw new Error('This TimeRanges object is empty');\n }\n };\n } else {\n timeRangesObj = {\n length: ranges.length,\n start: getRange.bind(null, 'start', 0, ranges),\n end: getRange.bind(null, 'end', 1, ranges)\n };\n }\n if (window$1.Symbol && window$1.Symbol.iterator) {\n timeRangesObj[window$1.Symbol.iterator] = () => (ranges || []).values();\n }\n return timeRangesObj;\n}\n\n/**\n * Create a `TimeRange` object which mimics an\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/TimeRanges|HTML5 TimeRanges instance}.\n *\n * @param {number|Array[]} start\n * The start of a single range (a number) or an array of ranges (an\n * array of arrays of two numbers each).\n *\n * @param {number} end\n * The end of a single range. Cannot be used with the array form of\n * the `start` argument.\n *\n * @return {TimeRange}\n */\nfunction createTimeRanges$1(start, end) {\n if (Array.isArray(start)) {\n return createTimeRangesObj(start);\n } else if (start === undefined || end === undefined) {\n return createTimeRangesObj();\n }\n return createTimeRangesObj([[start, end]]);\n}\n\n/**\n * Format seconds as a time string, H:MM:SS or M:SS. Supplying a guide (in\n * seconds) will force a number of leading zeros to cover the length of the\n * guide.\n *\n * @private\n * @param {number} seconds\n * Number of seconds to be turned into a string\n *\n * @param {number} guide\n * Number (in seconds) to model the string after\n *\n * @return {string}\n * Time formatted as H:MM:SS or M:SS\n */\nconst defaultImplementation = function (seconds, guide) {\n seconds = seconds < 0 ? 0 : seconds;\n let s = Math.floor(seconds % 60);\n let m = Math.floor(seconds / 60 % 60);\n let h = Math.floor(seconds / 3600);\n const gm = Math.floor(guide / 60 % 60);\n const gh = Math.floor(guide / 3600);\n\n // handle invalid times\n if (isNaN(seconds) || seconds === Infinity) {\n // '-' is false for all relational operators (e.g. <, >=) so this setting\n // will add the minimum number of fields specified by the guide\n h = m = s = '-';\n }\n\n // Check if we need to show hours\n h = h > 0 || gh > 0 ? h + ':' : '';\n\n // If hours are showing, we may need to add a leading zero.\n // Always show at least one digit of minutes.\n m = ((h || gm >= 10) && m < 10 ? '0' + m : m) + ':';\n\n // Check if leading zero is need for seconds\n s = s < 10 ? '0' + s : s;\n return h + m + s;\n};\n\n// Internal pointer to the current implementation.\nlet implementation = defaultImplementation;\n\n/**\n * Replaces the default formatTime implementation with a custom implementation.\n *\n * @param {Function} customImplementation\n * A function which will be used in place of the default formatTime\n * implementation. Will receive the current time in seconds and the\n * guide (in seconds) as arguments.\n */\nfunction setFormatTime(customImplementation) {\n implementation = customImplementation;\n}\n\n/**\n * Resets formatTime to the default implementation.\n */\nfunction resetFormatTime() {\n implementation = defaultImplementation;\n}\n\n/**\n * Delegates to either the default time formatting function or a custom\n * function supplied via `setFormatTime`.\n *\n * Formats seconds as a time string (H:MM:SS or M:SS). Supplying a\n * guide (in seconds) will force a number of leading zeros to cover the\n * length of the guide.\n *\n * @example formatTime(125, 600) === \"02:05\"\n * @param {number} seconds\n * Number of seconds to be turned into a string\n *\n * @param {number} guide\n * Number (in seconds) to model the string after\n *\n * @return {string}\n * Time formatted as H:MM:SS or M:SS\n */\nfunction formatTime(seconds, guide = seconds) {\n return implementation(seconds, guide);\n}\n\nvar Time = /*#__PURE__*/Object.freeze({\n __proto__: null,\n createTimeRanges: createTimeRanges$1,\n createTimeRange: createTimeRanges$1,\n setFormatTime: setFormatTime,\n resetFormatTime: resetFormatTime,\n formatTime: formatTime\n});\n\n/**\n * @file buffer.js\n * @module buffer\n */\n\n/**\n * Compute the percentage of the media that has been buffered.\n *\n * @param { import('./time').TimeRange } buffered\n * The current `TimeRanges` object representing buffered time ranges\n *\n * @param {number} duration\n * Total duration of the media\n *\n * @return {number}\n * Percent buffered of the total duration in decimal form.\n */\nfunction bufferedPercent(buffered, duration) {\n let bufferedDuration = 0;\n let start;\n let end;\n if (!duration) {\n return 0;\n }\n if (!buffered || !buffered.length) {\n buffered = createTimeRanges$1(0, 0);\n }\n for (let i = 0; i < buffered.length; i++) {\n start = buffered.start(i);\n end = buffered.end(i);\n\n // buffered end can be bigger than duration by a very small fraction\n if (end > duration) {\n end = duration;\n }\n bufferedDuration += end - start;\n }\n return bufferedDuration / duration;\n}\n\n/**\n * @file media-error.js\n */\n\n/**\n * A Custom `MediaError` class which mimics the standard HTML5 `MediaError` class.\n *\n * @param {number|string|Object|MediaError} value\n * This can be of multiple types:\n * - number: should be a standard error code\n * - string: an error message (the code will be 0)\n * - Object: arbitrary properties\n * - `MediaError` (native): used to populate a video.js `MediaError` object\n * - `MediaError` (video.js): will return itself if it's already a\n * video.js `MediaError` object.\n *\n * @see [MediaError Spec]{@link https://dev.w3.org/html5/spec-author-view/video.html#mediaerror}\n * @see [Encrypted MediaError Spec]{@link https://www.w3.org/TR/2013/WD-encrypted-media-20130510/#error-codes}\n *\n * @class MediaError\n */\nfunction MediaError(value) {\n // Allow redundant calls to this constructor to avoid having `instanceof`\n // checks peppered around the code.\n if (value instanceof MediaError) {\n return value;\n }\n if (typeof value === 'number') {\n this.code = value;\n } else if (typeof value === 'string') {\n // default code is zero, so this is a custom error\n this.message = value;\n } else if (isObject(value)) {\n // We assign the `code` property manually because native `MediaError` objects\n // do not expose it as an own/enumerable property of the object.\n if (typeof value.code === 'number') {\n this.code = value.code;\n }\n Object.assign(this, value);\n }\n if (!this.message) {\n this.message = MediaError.defaultMessages[this.code] || '';\n }\n}\n\n/**\n * The error code that refers two one of the defined `MediaError` types\n *\n * @type {Number}\n */\nMediaError.prototype.code = 0;\n\n/**\n * An optional message that to show with the error. Message is not part of the HTML5\n * video spec but allows for more informative custom errors.\n *\n * @type {String}\n */\nMediaError.prototype.message = '';\n\n/**\n * An optional status code that can be set by plugins to allow even more detail about\n * the error. For example a plugin might provide a specific HTTP status code and an\n * error message for that code. Then when the plugin gets that error this class will\n * know how to display an error message for it. This allows a custom message to show\n * up on the `Player` error overlay.\n *\n * @type {Array}\n */\nMediaError.prototype.status = null;\n\n/**\n * Errors indexed by the W3C standard. The order **CANNOT CHANGE**! See the\n * specification listed under {@link MediaError} for more information.\n *\n * @enum {array}\n * @readonly\n * @property {string} 0 - MEDIA_ERR_CUSTOM\n * @property {string} 1 - MEDIA_ERR_ABORTED\n * @property {string} 2 - MEDIA_ERR_NETWORK\n * @property {string} 3 - MEDIA_ERR_DECODE\n * @property {string} 4 - MEDIA_ERR_SRC_NOT_SUPPORTED\n * @property {string} 5 - MEDIA_ERR_ENCRYPTED\n */\nMediaError.errorTypes = ['MEDIA_ERR_CUSTOM', 'MEDIA_ERR_ABORTED', 'MEDIA_ERR_NETWORK', 'MEDIA_ERR_DECODE', 'MEDIA_ERR_SRC_NOT_SUPPORTED', 'MEDIA_ERR_ENCRYPTED'];\n\n/**\n * The default `MediaError` messages based on the {@link MediaError.errorTypes}.\n *\n * @type {Array}\n * @constant\n */\nMediaError.defaultMessages = {\n 1: 'You aborted the media playback',\n 2: 'A network error caused the media download to fail part-way.',\n 3: 'The media playback was aborted due to a corruption problem or because the media used features your browser did not support.',\n 4: 'The media could not be loaded, either because the server or network failed or because the format is not supported.',\n 5: 'The media is encrypted and we do not have the keys to decrypt it.'\n};\n\n// Add types as properties on MediaError\n// e.g. MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = 4;\nfor (let errNum = 0; errNum < MediaError.errorTypes.length; errNum++) {\n MediaError[MediaError.errorTypes[errNum]] = errNum;\n // values should be accessible on both the class and instance\n MediaError.prototype[MediaError.errorTypes[errNum]] = errNum;\n}\n\n/**\n * Returns whether an object is `Promise`-like (i.e. has a `then` method).\n *\n * @param {Object} value\n * An object that may or may not be `Promise`-like.\n *\n * @return {boolean}\n * Whether or not the object is `Promise`-like.\n */\nfunction isPromise(value) {\n return value !== undefined && value !== null && typeof value.then === 'function';\n}\n\n/**\n * Silence a Promise-like object.\n *\n * This is useful for avoiding non-harmful, but potentially confusing \"uncaught\n * play promise\" rejection error messages.\n *\n * @param {Object} value\n * An object that may or may not be `Promise`-like.\n */\nfunction silencePromise(value) {\n if (isPromise(value)) {\n value.then(null, e => {});\n }\n}\n\n/**\n * @file text-track-list-converter.js Utilities for capturing text track state and\n * re-creating tracks based on a capture.\n *\n * @module text-track-list-converter\n */\n\n/**\n * Examine a single {@link TextTrack} and return a JSON-compatible javascript object that\n * represents the {@link TextTrack}'s state.\n *\n * @param {TextTrack} track\n * The text track to query.\n *\n * @return {Object}\n * A serializable javascript representation of the TextTrack.\n * @private\n */\nconst trackToJson_ = function (track) {\n const ret = ['kind', 'label', 'language', 'id', 'inBandMetadataTrackDispatchType', 'mode', 'src'].reduce((acc, prop, i) => {\n if (track[prop]) {\n acc[prop] = track[prop];\n }\n return acc;\n }, {\n cues: track.cues && Array.prototype.map.call(track.cues, function (cue) {\n return {\n startTime: cue.startTime,\n endTime: cue.endTime,\n text: cue.text,\n id: cue.id\n };\n })\n });\n return ret;\n};\n\n/**\n * Examine a {@link Tech} and return a JSON-compatible javascript array that represents the\n * state of all {@link TextTrack}s currently configured. The return array is compatible with\n * {@link text-track-list-converter:jsonToTextTracks}.\n *\n * @param { import('../tech/tech').default } tech\n * The tech object to query\n *\n * @return {Array}\n * A serializable javascript representation of the {@link Tech}s\n * {@link TextTrackList}.\n */\nconst textTracksToJson = function (tech) {\n const trackEls = tech.$$('track');\n const trackObjs = Array.prototype.map.call(trackEls, t => t.track);\n const tracks = Array.prototype.map.call(trackEls, function (trackEl) {\n const json = trackToJson_(trackEl.track);\n if (trackEl.src) {\n json.src = trackEl.src;\n }\n return json;\n });\n return tracks.concat(Array.prototype.filter.call(tech.textTracks(), function (track) {\n return trackObjs.indexOf(track) === -1;\n }).map(trackToJson_));\n};\n\n/**\n * Create a set of remote {@link TextTrack}s on a {@link Tech} based on an array of javascript\n * object {@link TextTrack} representations.\n *\n * @param {Array} json\n * An array of `TextTrack` representation objects, like those that would be\n * produced by `textTracksToJson`.\n *\n * @param {Tech} tech\n * The `Tech` to create the `TextTrack`s on.\n */\nconst jsonToTextTracks = function (json, tech) {\n json.forEach(function (track) {\n const addedTrack = tech.addRemoteTextTrack(track).track;\n if (!track.src && track.cues) {\n track.cues.forEach(cue => addedTrack.addCue(cue));\n }\n });\n return tech.textTracks();\n};\nvar textTrackConverter = {\n textTracksToJson,\n jsonToTextTracks,\n trackToJson_\n};\n\n/**\n * @file modal-dialog.js\n */\nconst MODAL_CLASS_NAME = 'vjs-modal-dialog';\n\n/**\n * The `ModalDialog` displays over the video and its controls, which blocks\n * interaction with the player until it is closed.\n *\n * Modal dialogs include a \"Close\" button and will close when that button\n * is activated - or when ESC is pressed anywhere.\n *\n * @extends Component\n */\nclass ModalDialog extends Component$1 {\n /**\n * Create an instance of this class.\n *\n * @param { import('./player').default } player\n * The `Player` that this class should be attached to.\n *\n * @param {Object} [options]\n * The key/value store of player options.\n *\n * @param { import('./utils/dom').ContentDescriptor} [options.content=undefined]\n * Provide customized content for this modal.\n *\n * @param {string} [options.description]\n * A text description for the modal, primarily for accessibility.\n *\n * @param {boolean} [options.fillAlways=false]\n * Normally, modals are automatically filled only the first time\n * they open. This tells the modal to refresh its content\n * every time it opens.\n *\n * @param {string} [options.label]\n * A text label for the modal, primarily for accessibility.\n *\n * @param {boolean} [options.pauseOnOpen=true]\n * If `true`, playback will will be paused if playing when\n * the modal opens, and resumed when it closes.\n *\n * @param {boolean} [options.temporary=true]\n * If `true`, the modal can only be opened once; it will be\n * disposed as soon as it's closed.\n *\n * @param {boolean} [options.uncloseable=false]\n * If `true`, the user will not be able to close the modal\n * through the UI in the normal ways. Programmatic closing is\n * still possible.\n */\n constructor(player, options) {\n super(player, options);\n this.handleKeyDown_ = e => this.handleKeyDown(e);\n this.close_ = e => this.close(e);\n this.opened_ = this.hasBeenOpened_ = this.hasBeenFilled_ = false;\n this.closeable(!this.options_.uncloseable);\n this.content(this.options_.content);\n\n // Make sure the contentEl is defined AFTER any children are initialized\n // because we only want the contents of the modal in the contentEl\n // (not the UI elements like the close button).\n this.contentEl_ = createEl('div', {\n className: `${MODAL_CLASS_NAME}-content`\n }, {\n role: 'document'\n });\n this.descEl_ = createEl('p', {\n className: `${MODAL_CLASS_NAME}-description vjs-control-text`,\n id: this.el().getAttribute('aria-describedby')\n });\n textContent(this.descEl_, this.description());\n this.el_.appendChild(this.descEl_);\n this.el_.appendChild(this.contentEl_);\n }\n\n /**\n * Create the `ModalDialog`'s DOM element\n *\n * @return {Element}\n * The DOM element that gets created.\n */\n createEl() {\n return super.createEl('div', {\n className: this.buildCSSClass(),\n tabIndex: -1\n }, {\n 'aria-describedby': `${this.id()}_description`,\n 'aria-hidden': 'true',\n 'aria-label': this.label(),\n 'role': 'dialog'\n });\n }\n dispose() {\n this.contentEl_ = null;\n this.descEl_ = null;\n this.previouslyActiveEl_ = null;\n super.dispose();\n }\n\n /**\n * Builds the default DOM `className`.\n *\n * @return {string}\n * The DOM `className` for this object.\n */\n buildCSSClass() {\n return `${MODAL_CLASS_NAME} vjs-hidden ${super.buildCSSClass()}`;\n }\n\n /**\n * Returns the label string for this modal. Primarily used for accessibility.\n *\n * @return {string}\n * the localized or raw label of this modal.\n */\n label() {\n return this.localize(this.options_.label || 'Modal Window');\n }\n\n /**\n * Returns the description string for this modal. Primarily used for\n * accessibility.\n *\n * @return {string}\n * The localized or raw description of this modal.\n */\n description() {\n let desc = this.options_.description || this.localize('This is a modal window.');\n\n // Append a universal closeability message if the modal is closeable.\n if (this.closeable()) {\n desc += ' ' + this.localize('This modal can be closed by pressing the Escape key or activating the close button.');\n }\n return desc;\n }\n\n /**\n * Opens the modal.\n *\n * @fires ModalDialog#beforemodalopen\n * @fires ModalDialog#modalopen\n */\n open() {\n if (!this.opened_) {\n const player = this.player();\n\n /**\n * Fired just before a `ModalDialog` is opened.\n *\n * @event ModalDialog#beforemodalopen\n * @type {Event}\n */\n this.trigger('beforemodalopen');\n this.opened_ = true;\n\n // Fill content if the modal has never opened before and\n // never been filled.\n if (this.options_.fillAlways || !this.hasBeenOpened_ && !this.hasBeenFilled_) {\n this.fill();\n }\n\n // If the player was playing, pause it and take note of its previously\n // playing state.\n this.wasPlaying_ = !player.paused();\n if (this.options_.pauseOnOpen && this.wasPlaying_) {\n player.pause();\n }\n this.on('keydown', this.handleKeyDown_);\n\n // Hide controls and note if they were enabled.\n this.hadControls_ = player.controls();\n player.controls(false);\n this.show();\n this.conditionalFocus_();\n this.el().setAttribute('aria-hidden', 'false');\n\n /**\n * Fired just after a `ModalDialog` is opened.\n *\n * @event ModalDialog#modalopen\n * @type {Event}\n */\n this.trigger('modalopen');\n this.hasBeenOpened_ = true;\n }\n }\n\n /**\n * If the `ModalDialog` is currently open or closed.\n *\n * @param {boolean} [value]\n * If given, it will open (`true`) or close (`false`) the modal.\n *\n * @return {boolean}\n * the current open state of the modaldialog\n */\n opened(value) {\n if (typeof value === 'boolean') {\n this[value ? 'open' : 'close']();\n }\n return this.opened_;\n }\n\n /**\n * Closes the modal, does nothing if the `ModalDialog` is\n * not open.\n *\n * @fires ModalDialog#beforemodalclose\n * @fires ModalDialog#modalclose\n */\n close() {\n if (!this.opened_) {\n return;\n }\n const player = this.player();\n\n /**\n * Fired just before a `ModalDialog` is closed.\n *\n * @event ModalDialog#beforemodalclose\n * @type {Event}\n */\n this.trigger('beforemodalclose');\n this.opened_ = false;\n if (this.wasPlaying_ && this.options_.pauseOnOpen) {\n player.play();\n }\n this.off('keydown', this.handleKeyDown_);\n if (this.hadControls_) {\n player.controls(true);\n }\n this.hide();\n this.el().setAttribute('aria-hidden', 'true');\n\n /**\n * Fired just after a `ModalDialog` is closed.\n *\n * @event ModalDialog#modalclose\n * @type {Event}\n */\n this.trigger('modalclose');\n this.conditionalBlur_();\n if (this.options_.temporary) {\n this.dispose();\n }\n }\n\n /**\n * Check to see if the `ModalDialog` is closeable via the UI.\n *\n * @param {boolean} [value]\n * If given as a boolean, it will set the `closeable` option.\n *\n * @return {boolean}\n * Returns the final value of the closable option.\n */\n closeable(value) {\n if (typeof value === 'boolean') {\n const closeable = this.closeable_ = !!value;\n let close = this.getChild('closeButton');\n\n // If this is being made closeable and has no close button, add one.\n if (closeable && !close) {\n // The close button should be a child of the modal - not its\n // content element, so temporarily change the content element.\n const temp = this.contentEl_;\n this.contentEl_ = this.el_;\n close = this.addChild('closeButton', {\n controlText: 'Close Modal Dialog'\n });\n this.contentEl_ = temp;\n this.on(close, 'close', this.close_);\n }\n\n // If this is being made uncloseable and has a close button, remove it.\n if (!closeable && close) {\n this.off(close, 'close', this.close_);\n this.removeChild(close);\n close.dispose();\n }\n }\n return this.closeable_;\n }\n\n /**\n * Fill the modal's content element with the modal's \"content\" option.\n * The content element will be emptied before this change takes place.\n */\n fill() {\n this.fillWith(this.content());\n }\n\n /**\n * Fill the modal's content element with arbitrary content.\n * The content element will be emptied before this change takes place.\n *\n * @fires ModalDialog#beforemodalfill\n * @fires ModalDialog#modalfill\n *\n * @param { import('./utils/dom').ContentDescriptor} [content]\n * The same rules apply to this as apply to the `content` option.\n */\n fillWith(content) {\n const contentEl = this.contentEl();\n const parentEl = contentEl.parentNode;\n const nextSiblingEl = contentEl.nextSibling;\n\n /**\n * Fired just before a `ModalDialog` is filled with content.\n *\n * @event ModalDialog#beforemodalfill\n * @type {Event}\n */\n this.trigger('beforemodalfill');\n this.hasBeenFilled_ = true;\n\n // Detach the content element from the DOM before performing\n // manipulation to avoid modifying the live DOM multiple times.\n parentEl.removeChild(contentEl);\n this.empty();\n insertContent(contentEl, content);\n /**\n * Fired just after a `ModalDialog` is filled with content.\n *\n * @event ModalDialog#modalfill\n * @type {Event}\n */\n this.trigger('modalfill');\n\n // Re-inject the re-filled content element.\n if (nextSiblingEl) {\n parentEl.insertBefore(contentEl, nextSiblingEl);\n } else {\n parentEl.appendChild(contentEl);\n }\n\n // make sure that the close button is last in the dialog DOM\n const closeButton = this.getChild('closeButton');\n if (closeButton) {\n parentEl.appendChild(closeButton.el_);\n }\n }\n\n /**\n * Empties the content element. This happens anytime the modal is filled.\n *\n * @fires ModalDialog#beforemodalempty\n * @fires ModalDialog#modalempty\n */\n empty() {\n /**\n * Fired just before a `ModalDialog` is emptied.\n *\n * @event ModalDialog#beforemodalempty\n * @type {Event}\n */\n this.trigger('beforemodalempty');\n emptyEl(this.contentEl());\n\n /**\n * Fired just after a `ModalDialog` is emptied.\n *\n * @event ModalDialog#modalempty\n * @type {Event}\n */\n this.trigger('modalempty');\n }\n\n /**\n * Gets or sets the modal content, which gets normalized before being\n * rendered into the DOM.\n *\n * This does not update the DOM or fill the modal, but it is called during\n * that process.\n *\n * @param { import('./utils/dom').ContentDescriptor} [value]\n * If defined, sets the internal content value to be used on the\n * next call(s) to `fill`. This value is normalized before being\n * inserted. To \"clear\" the internal content value, pass `null`.\n *\n * @return { import('./utils/dom').ContentDescriptor}\n * The current content of the modal dialog\n */\n content(value) {\n if (typeof value !== 'undefined') {\n this.content_ = value;\n }\n return this.content_;\n }\n\n /**\n * conditionally focus the modal dialog if focus was previously on the player.\n *\n * @private\n */\n conditionalFocus_() {\n const activeEl = document.activeElement;\n const playerEl = this.player_.el_;\n this.previouslyActiveEl_ = null;\n if (playerEl.contains(activeEl) || playerEl === activeEl) {\n this.previouslyActiveEl_ = activeEl;\n this.focus();\n }\n }\n\n /**\n * conditionally blur the element and refocus the last focused element\n *\n * @private\n */\n conditionalBlur_() {\n if (this.previouslyActiveEl_) {\n this.previouslyActiveEl_.focus();\n this.previouslyActiveEl_ = null;\n }\n }\n\n /**\n * Keydown handler. Attached when modal is focused.\n *\n * @listens keydown\n */\n handleKeyDown(event) {\n // Do not allow keydowns to reach out of the modal dialog.\n event.stopPropagation();\n if (keycode.isEventKey(event, 'Escape') && this.closeable()) {\n event.preventDefault();\n this.close();\n return;\n }\n\n // exit early if it isn't a tab key\n if (!keycode.isEventKey(event, 'Tab')) {\n return;\n }\n const focusableEls = this.focusableEls_();\n const activeEl = this.el_.querySelector(':focus');\n let focusIndex;\n for (let i = 0; i < focusableEls.length; i++) {\n if (activeEl === focusableEls[i]) {\n focusIndex = i;\n break;\n }\n }\n if (document.activeElement === this.el_) {\n focusIndex = 0;\n }\n if (event.shiftKey && focusIndex === 0) {\n focusableEls[focusableEls.length - 1].focus();\n event.preventDefault();\n } else if (!event.shiftKey && focusIndex === focusableEls.length - 1) {\n focusableEls[0].focus();\n event.preventDefault();\n }\n }\n\n /**\n * get all focusable elements\n *\n * @private\n */\n focusableEls_() {\n const allChildren = this.el_.querySelectorAll('*');\n return Array.prototype.filter.call(allChildren, child => {\n return (child instanceof window$1.HTMLAnchorElement || child instanceof window$1.HTMLAreaElement) && child.hasAttribute('href') || (child instanceof window$1.HTMLInputElement || child instanceof window$1.HTMLSelectElement || child instanceof window$1.HTMLTextAreaElement || child instanceof window$1.HTMLButtonElement) && !child.hasAttribute('disabled') || child instanceof window$1.HTMLIFrameElement || child instanceof window$1.HTMLObjectElement || child instanceof window$1.HTMLEmbedElement || child.hasAttribute('tabindex') && child.getAttribute('tabindex') !== -1 || child.hasAttribute('contenteditable');\n });\n }\n}\n\n/**\n * Default options for `ModalDialog` default options.\n *\n * @type {Object}\n * @private\n */\nModalDialog.prototype.options_ = {\n pauseOnOpen: true,\n temporary: true\n};\nComponent$1.registerComponent('ModalDialog', ModalDialog);\n\n/**\n * @file track-list.js\n */\n\n/**\n * Common functionaliy between {@link TextTrackList}, {@link AudioTrackList}, and\n * {@link VideoTrackList}\n *\n * @extends EventTarget\n */\nclass TrackList extends EventTarget$2 {\n /**\n * Create an instance of this class\n *\n * @param { import('./track').default[] } tracks\n * A list of tracks to initialize the list with.\n *\n * @abstract\n */\n constructor(tracks = []) {\n super();\n this.tracks_ = [];\n\n /**\n * @memberof TrackList\n * @member {number} length\n * The current number of `Track`s in the this Trackist.\n * @instance\n */\n Object.defineProperty(this, 'length', {\n get() {\n return this.tracks_.length;\n }\n });\n for (let i = 0; i < tracks.length; i++) {\n this.addTrack(tracks[i]);\n }\n }\n\n /**\n * Add a {@link Track} to the `TrackList`\n *\n * @param { import('./track').default } track\n * The audio, video, or text track to add to the list.\n *\n * @fires TrackList#addtrack\n */\n addTrack(track) {\n const index = this.tracks_.length;\n if (!('' + index in this)) {\n Object.defineProperty(this, index, {\n get() {\n return this.tracks_[index];\n }\n });\n }\n\n // Do not add duplicate tracks\n if (this.tracks_.indexOf(track) === -1) {\n this.tracks_.push(track);\n /**\n * Triggered when a track is added to a track list.\n *\n * @event TrackList#addtrack\n * @type {Event}\n * @property {Track} track\n * A reference to track that was added.\n */\n this.trigger({\n track,\n type: 'addtrack',\n target: this\n });\n }\n\n /**\n * Triggered when a track label is changed.\n *\n * @event TrackList#addtrack\n * @type {Event}\n * @property {Track} track\n * A reference to track that was added.\n */\n track.labelchange_ = () => {\n this.trigger({\n track,\n type: 'labelchange',\n target: this\n });\n };\n if (isEvented(track)) {\n track.addEventListener('labelchange', track.labelchange_);\n }\n }\n\n /**\n * Remove a {@link Track} from the `TrackList`\n *\n * @param { import('./track').default } rtrack\n * The audio, video, or text track to remove from the list.\n *\n * @fires TrackList#removetrack\n */\n removeTrack(rtrack) {\n let track;\n for (let i = 0, l = this.length; i < l; i++) {\n if (this[i] === rtrack) {\n track = this[i];\n if (track.off) {\n track.off();\n }\n this.tracks_.splice(i, 1);\n break;\n }\n }\n if (!track) {\n return;\n }\n\n /**\n * Triggered when a track is removed from track list.\n *\n * @event TrackList#removetrack\n * @type {Event}\n * @property {Track} track\n * A reference to track that was removed.\n */\n this.trigger({\n track,\n type: 'removetrack',\n target: this\n });\n }\n\n /**\n * Get a Track from the TrackList by a tracks id\n *\n * @param {string} id - the id of the track to get\n * @method getTrackById\n * @return { import('./track').default }\n * @private\n */\n getTrackById(id) {\n let result = null;\n for (let i = 0, l = this.length; i < l; i++) {\n const track = this[i];\n if (track.id === id) {\n result = track;\n break;\n }\n }\n return result;\n }\n}\n\n/**\n * Triggered when a different track is selected/enabled.\n *\n * @event TrackList#change\n * @type {Event}\n */\n\n/**\n * Events that can be called with on + eventName. See {@link EventHandler}.\n *\n * @property {Object} TrackList#allowedEvents_\n * @protected\n */\nTrackList.prototype.allowedEvents_ = {\n change: 'change',\n addtrack: 'addtrack',\n removetrack: 'removetrack',\n labelchange: 'labelchange'\n};\n\n// emulate attribute EventHandler support to allow for feature detection\nfor (const event in TrackList.prototype.allowedEvents_) {\n TrackList.prototype['on' + event] = null;\n}\n\n/**\n * @file audio-track-list.js\n */\n\n/**\n * Anywhere we call this function we diverge from the spec\n * as we only support one enabled audiotrack at a time\n *\n * @param {AudioTrackList} list\n * list to work on\n *\n * @param { import('./audio-track').default } track\n * The track to skip\n *\n * @private\n */\nconst disableOthers$1 = function (list, track) {\n for (let i = 0; i < list.length; i++) {\n if (!Object.keys(list[i]).length || track.id === list[i].id) {\n continue;\n }\n // another audio track is enabled, disable it\n list[i].enabled = false;\n }\n};\n\n/**\n * The current list of {@link AudioTrack} for a media file.\n *\n * @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#audiotracklist}\n * @extends TrackList\n */\nclass AudioTrackList extends TrackList {\n /**\n * Create an instance of this class.\n *\n * @param { import('./audio-track').default[] } [tracks=[]]\n * A list of `AudioTrack` to instantiate the list with.\n */\n constructor(tracks = []) {\n // make sure only 1 track is enabled\n // sorted from last index to first index\n for (let i = tracks.length - 1; i >= 0; i--) {\n if (tracks[i].enabled) {\n disableOthers$1(tracks, tracks[i]);\n break;\n }\n }\n super(tracks);\n this.changing_ = false;\n }\n\n /**\n * Add an {@link AudioTrack} to the `AudioTrackList`.\n *\n * @param { import('./audio-track').default } track\n * The AudioTrack to add to the list\n *\n * @fires TrackList#addtrack\n */\n addTrack(track) {\n if (track.enabled) {\n disableOthers$1(this, track);\n }\n super.addTrack(track);\n // native tracks don't have this\n if (!track.addEventListener) {\n return;\n }\n track.enabledChange_ = () => {\n // when we are disabling other tracks (since we don't support\n // more than one track at a time) we will set changing_\n // to true so that we don't trigger additional change events\n if (this.changing_) {\n return;\n }\n this.changing_ = true;\n disableOthers$1(this, track);\n this.changing_ = false;\n this.trigger('change');\n };\n\n /**\n * @listens AudioTrack#enabledchange\n * @fires TrackList#change\n */\n track.addEventListener('enabledchange', track.enabledChange_);\n }\n removeTrack(rtrack) {\n super.removeTrack(rtrack);\n if (rtrack.removeEventListener && rtrack.enabledChange_) {\n rtrack.removeEventListener('enabledchange', rtrack.enabledChange_);\n rtrack.enabledChange_ = null;\n }\n }\n}\n\n/**\n * @file video-track-list.js\n */\n\n/**\n * Un-select all other {@link VideoTrack}s that are selected.\n *\n * @param {VideoTrackList} list\n * list to work on\n *\n * @param { import('./video-track').default } track\n * The track to skip\n *\n * @private\n */\nconst disableOthers = function (list, track) {\n for (let i = 0; i < list.length; i++) {\n if (!Object.keys(list[i]).length || track.id === list[i].id) {\n continue;\n }\n // another video track is enabled, disable it\n list[i].selected = false;\n }\n};\n\n/**\n * The current list of {@link VideoTrack} for a video.\n *\n * @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#videotracklist}\n * @extends TrackList\n */\nclass VideoTrackList extends TrackList {\n /**\n * Create an instance of this class.\n *\n * @param {VideoTrack[]} [tracks=[]]\n * A list of `VideoTrack` to instantiate the list with.\n */\n constructor(tracks = []) {\n // make sure only 1 track is enabled\n // sorted from last index to first index\n for (let i = tracks.length - 1; i >= 0; i--) {\n if (tracks[i].selected) {\n disableOthers(tracks, tracks[i]);\n break;\n }\n }\n super(tracks);\n this.changing_ = false;\n\n /**\n * @member {number} VideoTrackList#selectedIndex\n * The current index of the selected {@link VideoTrack`}.\n */\n Object.defineProperty(this, 'selectedIndex', {\n get() {\n for (let i = 0; i < this.length; i++) {\n if (this[i].selected) {\n return i;\n }\n }\n return -1;\n },\n set() {}\n });\n }\n\n /**\n * Add a {@link VideoTrack} to the `VideoTrackList`.\n *\n * @param { import('./video-track').default } track\n * The VideoTrack to add to the list\n *\n * @fires TrackList#addtrack\n */\n addTrack(track) {\n if (track.selected) {\n disableOthers(this, track);\n }\n super.addTrack(track);\n // native tracks don't have this\n if (!track.addEventListener) {\n return;\n }\n track.selectedChange_ = () => {\n if (this.changing_) {\n return;\n }\n this.changing_ = true;\n disableOthers(this, track);\n this.changing_ = false;\n this.trigger('change');\n };\n\n /**\n * @listens VideoTrack#selectedchange\n * @fires TrackList#change\n */\n track.addEventListener('selectedchange', track.selectedChange_);\n }\n removeTrack(rtrack) {\n super.removeTrack(rtrack);\n if (rtrack.removeEventListener && rtrack.selectedChange_) {\n rtrack.removeEventListener('selectedchange', rtrack.selectedChange_);\n rtrack.selectedChange_ = null;\n }\n }\n}\n\n/**\n * @file text-track-list.js\n */\n\n/**\n * The current list of {@link TextTrack} for a media file.\n *\n * @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#texttracklist}\n * @extends TrackList\n */\nclass TextTrackList extends TrackList {\n /**\n * Add a {@link TextTrack} to the `TextTrackList`\n *\n * @param { import('./text-track').default } track\n * The text track to add to the list.\n *\n * @fires TrackList#addtrack\n */\n addTrack(track) {\n super.addTrack(track);\n if (!this.queueChange_) {\n this.queueChange_ = () => this.queueTrigger('change');\n }\n if (!this.triggerSelectedlanguagechange) {\n this.triggerSelectedlanguagechange_ = () => this.trigger('selectedlanguagechange');\n }\n\n /**\n * @listens TextTrack#modechange\n * @fires TrackList#change\n */\n track.addEventListener('modechange', this.queueChange_);\n const nonLanguageTextTrackKind = ['metadata', 'chapters'];\n if (nonLanguageTextTrackKind.indexOf(track.kind) === -1) {\n track.addEventListener('modechange', this.triggerSelectedlanguagechange_);\n }\n }\n removeTrack(rtrack) {\n super.removeTrack(rtrack);\n\n // manually remove the event handlers we added\n if (rtrack.removeEventListener) {\n if (this.queueChange_) {\n rtrack.removeEventListener('modechange', this.queueChange_);\n }\n if (this.selectedlanguagechange_) {\n rtrack.removeEventListener('modechange', this.triggerSelectedlanguagechange_);\n }\n }\n }\n}\n\n/**\n * @file html-track-element-list.js\n */\n\n/**\n * The current list of {@link HtmlTrackElement}s.\n */\nclass HtmlTrackElementList {\n /**\n * Create an instance of this class.\n *\n * @param {HtmlTrackElement[]} [tracks=[]]\n * A list of `HtmlTrackElement` to instantiate the list with.\n */\n constructor(trackElements = []) {\n this.trackElements_ = [];\n\n /**\n * @memberof HtmlTrackElementList\n * @member {number} length\n * The current number of `Track`s in the this Trackist.\n * @instance\n */\n Object.defineProperty(this, 'length', {\n get() {\n return this.trackElements_.length;\n }\n });\n for (let i = 0, length = trackElements.length; i < length; i++) {\n this.addTrackElement_(trackElements[i]);\n }\n }\n\n /**\n * Add an {@link HtmlTrackElement} to the `HtmlTrackElementList`\n *\n * @param {HtmlTrackElement} trackElement\n * The track element to add to the list.\n *\n * @private\n */\n addTrackElement_(trackElement) {\n const index = this.trackElements_.length;\n if (!('' + index in this)) {\n Object.defineProperty(this, index, {\n get() {\n return this.trackElements_[index];\n }\n });\n }\n\n // Do not add duplicate elements\n if (this.trackElements_.indexOf(trackElement) === -1) {\n this.trackElements_.push(trackElement);\n }\n }\n\n /**\n * Get an {@link HtmlTrackElement} from the `HtmlTrackElementList` given an\n * {@link TextTrack}.\n *\n * @param {TextTrack} track\n * The track associated with a track element.\n *\n * @return {HtmlTrackElement|undefined}\n * The track element that was found or undefined.\n *\n * @private\n */\n getTrackElementByTrack_(track) {\n let trackElement_;\n for (let i = 0, length = this.trackElements_.length; i < length; i++) {\n if (track === this.trackElements_[i].track) {\n trackElement_ = this.trackElements_[i];\n break;\n }\n }\n return trackElement_;\n }\n\n /**\n * Remove a {@link HtmlTrackElement} from the `HtmlTrackElementList`\n *\n * @param {HtmlTrackElement} trackElement\n * The track element to remove from the list.\n *\n * @private\n */\n removeTrackElement_(trackElement) {\n for (let i = 0, length = this.trackElements_.length; i < length; i++) {\n if (trackElement === this.trackElements_[i]) {\n if (this.trackElements_[i].track && typeof this.trackElements_[i].track.off === 'function') {\n this.trackElements_[i].track.off();\n }\n if (typeof this.trackElements_[i].off === 'function') {\n this.trackElements_[i].off();\n }\n this.trackElements_.splice(i, 1);\n break;\n }\n }\n }\n}\n\n/**\n * @file text-track-cue-list.js\n */\n\n/**\n * @typedef {Object} TextTrackCueList~TextTrackCue\n *\n * @property {string} id\n * The unique id for this text track cue\n *\n * @property {number} startTime\n * The start time for this text track cue\n *\n * @property {number} endTime\n * The end time for this text track cue\n *\n * @property {boolean} pauseOnExit\n * Pause when the end time is reached if true.\n *\n * @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackcue}\n */\n\n/**\n * A List of TextTrackCues.\n *\n * @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackcuelist}\n */\nclass TextTrackCueList {\n /**\n * Create an instance of this class..\n *\n * @param {Array} cues\n * A list of cues to be initialized with\n */\n constructor(cues) {\n TextTrackCueList.prototype.setCues_.call(this, cues);\n\n /**\n * @memberof TextTrackCueList\n * @member {number} length\n * The current number of `TextTrackCue`s in the TextTrackCueList.\n * @instance\n */\n Object.defineProperty(this, 'length', {\n get() {\n return this.length_;\n }\n });\n }\n\n /**\n * A setter for cues in this list. Creates getters\n * an an index for the cues.\n *\n * @param {Array} cues\n * An array of cues to set\n *\n * @private\n */\n setCues_(cues) {\n const oldLength = this.length || 0;\n let i = 0;\n const l = cues.length;\n this.cues_ = cues;\n this.length_ = cues.length;\n const defineProp = function (index) {\n if (!('' + index in this)) {\n Object.defineProperty(this, '' + index, {\n get() {\n return this.cues_[index];\n }\n });\n }\n };\n if (oldLength < l) {\n i = oldLength;\n for (; i < l; i++) {\n defineProp.call(this, i);\n }\n }\n }\n\n /**\n * Get a `TextTrackCue` that is currently in the `TextTrackCueList` by id.\n *\n * @param {string} id\n * The id of the cue that should be searched for.\n *\n * @return {TextTrackCueList~TextTrackCue|null}\n * A single cue or null if none was found.\n */\n getCueById(id) {\n let result = null;\n for (let i = 0, l = this.length; i < l; i++) {\n const cue = this[i];\n if (cue.id === id) {\n result = cue;\n break;\n }\n }\n return result;\n }\n}\n\n/**\n * @file track-kinds.js\n */\n\n/**\n * All possible `VideoTrackKind`s\n *\n * @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-videotrack-kind\n * @typedef VideoTrack~Kind\n * @enum\n */\nconst VideoTrackKind = {\n alternative: 'alternative',\n captions: 'captions',\n main: 'main',\n sign: 'sign',\n subtitles: 'subtitles',\n commentary: 'commentary'\n};\n\n/**\n * All possible `AudioTrackKind`s\n *\n * @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-audiotrack-kind\n * @typedef AudioTrack~Kind\n * @enum\n */\nconst AudioTrackKind = {\n 'alternative': 'alternative',\n 'descriptions': 'descriptions',\n 'main': 'main',\n 'main-desc': 'main-desc',\n 'translation': 'translation',\n 'commentary': 'commentary'\n};\n\n/**\n * All possible `TextTrackKind`s\n *\n * @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-texttrack-kind\n * @typedef TextTrack~Kind\n * @enum\n */\nconst TextTrackKind = {\n subtitles: 'subtitles',\n captions: 'captions',\n descriptions: 'descriptions',\n chapters: 'chapters',\n metadata: 'metadata'\n};\n\n/**\n * All possible `TextTrackMode`s\n *\n * @see https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackmode\n * @typedef TextTrack~Mode\n * @enum\n */\nconst TextTrackMode = {\n disabled: 'disabled',\n hidden: 'hidden',\n showing: 'showing'\n};\n\n/**\n * @file track.js\n */\n\n/**\n * A Track class that contains all of the common functionality for {@link AudioTrack},\n * {@link VideoTrack}, and {@link TextTrack}.\n *\n * > Note: This class should not be used directly\n *\n * @see {@link https://html.spec.whatwg.org/multipage/embedded-content.html}\n * @extends EventTarget\n * @abstract\n */\nclass Track extends EventTarget$2 {\n /**\n * Create an instance of this class.\n *\n * @param {Object} [options={}]\n * Object of option names and values\n *\n * @param {string} [options.kind='']\n * A valid kind for the track type you are creating.\n *\n * @param {string} [options.id='vjs_track_' + Guid.newGUID()]\n * A unique id for this AudioTrack.\n *\n * @param {string} [options.label='']\n * The menu label for this track.\n *\n * @param {string} [options.language='']\n * A valid two character language code.\n *\n * @abstract\n */\n constructor(options = {}) {\n super();\n const trackProps = {\n id: options.id || 'vjs_track_' + newGUID(),\n kind: options.kind || '',\n language: options.language || ''\n };\n let label = options.label || '';\n\n /**\n * @memberof Track\n * @member {string} id\n * The id of this track. Cannot be changed after creation.\n * @instance\n *\n * @readonly\n */\n\n /**\n * @memberof Track\n * @member {string} kind\n * The kind of track that this is. Cannot be changed after creation.\n * @instance\n *\n * @readonly\n */\n\n /**\n * @memberof Track\n * @member {string} language\n * The two letter language code for this track. Cannot be changed after\n * creation.\n * @instance\n *\n * @readonly\n */\n\n for (const key in trackProps) {\n Object.defineProperty(this, key, {\n get() {\n return trackProps[key];\n },\n set() {}\n });\n }\n\n /**\n * @memberof Track\n * @member {string} label\n * The label of this track. Cannot be changed after creation.\n * @instance\n *\n * @fires Track#labelchange\n */\n Object.defineProperty(this, 'label', {\n get() {\n return label;\n },\n set(newLabel) {\n if (newLabel !== label) {\n label = newLabel;\n\n /**\n * An event that fires when label changes on this track.\n *\n * > Note: This is not part of the spec!\n *\n * @event Track#labelchange\n * @type {Event}\n */\n this.trigger('labelchange');\n }\n }\n });\n }\n}\n\n/**\n * @file url.js\n * @module url\n */\n\n/**\n * @typedef {Object} url:URLObject\n *\n * @property {string} protocol\n * The protocol of the url that was parsed.\n *\n * @property {string} hostname\n * The hostname of the url that was parsed.\n *\n * @property {string} port\n * The port of the url that was parsed.\n *\n * @property {string} pathname\n * The pathname of the url that was parsed.\n *\n * @property {string} search\n * The search query of the url that was parsed.\n *\n * @property {string} hash\n * The hash of the url that was parsed.\n *\n * @property {string} host\n * The host of the url that was parsed.\n */\n\n/**\n * Resolve and parse the elements of a URL.\n *\n * @function\n * @param {String} url\n * The url to parse\n *\n * @return {url:URLObject}\n * An object of url details\n */\nconst parseUrl = function (url) {\n // This entire method can be replace with URL once we are able to drop IE11\n\n const props = ['protocol', 'hostname', 'port', 'pathname', 'search', 'hash', 'host'];\n\n // add the url to an anchor and let the browser parse the URL\n const a = document.createElement('a');\n a.href = url;\n\n // Copy the specific URL properties to a new object\n // This is also needed for IE because the anchor loses its\n // properties when it's removed from the dom\n const details = {};\n for (let i = 0; i < props.length; i++) {\n details[props[i]] = a[props[i]];\n }\n\n // IE adds the port to the host property unlike everyone else. If\n // a port identifier is added for standard ports, strip it.\n if (details.protocol === 'http:') {\n details.host = details.host.replace(/:80$/, '');\n }\n if (details.protocol === 'https:') {\n details.host = details.host.replace(/:443$/, '');\n }\n if (!details.protocol) {\n details.protocol = window$1.location.protocol;\n }\n\n /* istanbul ignore if */\n if (!details.host) {\n details.host = window$1.location.host;\n }\n return details;\n};\n\n/**\n * Get absolute version of relative URL.\n *\n * @function\n * @param {string} url\n * URL to make absolute\n *\n * @return {string}\n * Absolute URL\n *\n * @see http://stackoverflow.com/questions/470832/getting-an-absolute-url-from-a-relative-one-ie6-issue\n */\nconst getAbsoluteURL = function (url) {\n // Check if absolute URL\n if (!url.match(/^https?:\\/\\//)) {\n // Add the url to an anchor and let the browser parse it to convert to an absolute url\n const a = document.createElement('a');\n a.href = url;\n url = a.href;\n }\n return url;\n};\n\n/**\n * Returns the extension of the passed file name. It will return an empty string\n * if passed an invalid path.\n *\n * @function\n * @param {string} path\n * The fileName path like '/path/to/file.mp4'\n *\n * @return {string}\n * The extension in lower case or an empty string if no\n * extension could be found.\n */\nconst getFileExtension = function (path) {\n if (typeof path === 'string') {\n const splitPathRe = /^(\\/?)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?)(\\.([^\\.\\/\\?]+)))(?:[\\/]*|[\\?].*)$/;\n const pathParts = splitPathRe.exec(path);\n if (pathParts) {\n return pathParts.pop().toLowerCase();\n }\n }\n return '';\n};\n\n/**\n * Returns whether the url passed is a cross domain request or not.\n *\n * @function\n * @param {string} url\n * The url to check.\n *\n * @param {Object} [winLoc]\n * the domain to check the url against, defaults to window.location\n *\n * @param {string} [winLoc.protocol]\n * The window location protocol defaults to window.location.protocol\n *\n * @param {string} [winLoc.host]\n * The window location host defaults to window.location.host\n *\n * @return {boolean}\n * Whether it is a cross domain request or not.\n */\nconst isCrossOrigin = function (url, winLoc = window$1.location) {\n const urlInfo = parseUrl(url);\n\n // IE8 protocol relative urls will return ':' for protocol\n const srcProtocol = urlInfo.protocol === ':' ? winLoc.protocol : urlInfo.protocol;\n\n // Check if url is for another domain/origin\n // IE8 doesn't know location.origin, so we won't rely on it here\n const crossOrigin = srcProtocol + urlInfo.host !== winLoc.protocol + winLoc.host;\n return crossOrigin;\n};\n\nvar Url = /*#__PURE__*/Object.freeze({\n __proto__: null,\n parseUrl: parseUrl,\n getAbsoluteURL: getAbsoluteURL,\n getFileExtension: getFileExtension,\n isCrossOrigin: isCrossOrigin\n});\n\n/**\n * @file text-track.js\n */\n\n/**\n * Takes a webvtt file contents and parses it into cues\n *\n * @param {string} srcContent\n * webVTT file contents\n *\n * @param {TextTrack} track\n * TextTrack to add cues to. Cues come from the srcContent.\n *\n * @private\n */\nconst parseCues = function (srcContent, track) {\n const parser = new window$1.WebVTT.Parser(window$1, window$1.vttjs, window$1.WebVTT.StringDecoder());\n const errors = [];\n parser.oncue = function (cue) {\n track.addCue(cue);\n };\n parser.onparsingerror = function (error) {\n errors.push(error);\n };\n parser.onflush = function () {\n track.trigger({\n type: 'loadeddata',\n target: track\n });\n };\n parser.parse(srcContent);\n if (errors.length > 0) {\n if (window$1.console && window$1.console.groupCollapsed) {\n window$1.console.groupCollapsed(`Text Track parsing errors for ${track.src}`);\n }\n errors.forEach(error => log$1.error(error));\n if (window$1.console && window$1.console.groupEnd) {\n window$1.console.groupEnd();\n }\n }\n parser.flush();\n};\n\n/**\n * Load a `TextTrack` from a specified url.\n *\n * @param {string} src\n * Url to load track from.\n *\n * @param {TextTrack} track\n * Track to add cues to. Comes from the content at the end of `url`.\n *\n * @private\n */\nconst loadTrack = function (src, track) {\n const opts = {\n uri: src\n };\n const crossOrigin = isCrossOrigin(src);\n if (crossOrigin) {\n opts.cors = crossOrigin;\n }\n const withCredentials = track.tech_.crossOrigin() === 'use-credentials';\n if (withCredentials) {\n opts.withCredentials = withCredentials;\n }\n XHR(opts, bind_(this, function (err, response, responseBody) {\n if (err) {\n return log$1.error(err, response);\n }\n track.loaded_ = true;\n\n // Make sure that vttjs has loaded, otherwise, wait till it finished loading\n // NOTE: this is only used for the alt/video.novtt.js build\n if (typeof window$1.WebVTT !== 'function') {\n if (track.tech_) {\n // to prevent use before define eslint error, we define loadHandler\n // as a let here\n track.tech_.any(['vttjsloaded', 'vttjserror'], event => {\n if (event.type === 'vttjserror') {\n log$1.error(`vttjs failed to load, stopping trying to process ${track.src}`);\n return;\n }\n return parseCues(responseBody, track);\n });\n }\n } else {\n parseCues(responseBody, track);\n }\n }));\n};\n\n/**\n * A representation of a single `TextTrack`.\n *\n * @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#texttrack}\n * @extends Track\n */\nclass TextTrack extends Track {\n /**\n * Create an instance of this class.\n *\n * @param {Object} options={}\n * Object of option names and values\n *\n * @param { import('../tech/tech').default } options.tech\n * A reference to the tech that owns this TextTrack.\n *\n * @param {TextTrack~Kind} [options.kind='subtitles']\n * A valid text track kind.\n *\n * @param {TextTrack~Mode} [options.mode='disabled']\n * A valid text track mode.\n *\n * @param {string} [options.id='vjs_track_' + Guid.newGUID()]\n * A unique id for this TextTrack.\n *\n * @param {string} [options.label='']\n * The menu label for this track.\n *\n * @param {string} [options.language='']\n * A valid two character language code.\n *\n * @param {string} [options.srclang='']\n * A valid two character language code. An alternative, but deprioritized\n * version of `options.language`\n *\n * @param {string} [options.src]\n * A url to TextTrack cues.\n *\n * @param {boolean} [options.default]\n * If this track should default to on or off.\n */\n constructor(options = {}) {\n if (!options.tech) {\n throw new Error('A tech was not provided.');\n }\n const settings = merge$1(options, {\n kind: TextTrackKind[options.kind] || 'subtitles',\n language: options.language || options.srclang || ''\n });\n let mode = TextTrackMode[settings.mode] || 'disabled';\n const default_ = settings.default;\n if (settings.kind === 'metadata' || settings.kind === 'chapters') {\n mode = 'hidden';\n }\n super(settings);\n this.tech_ = settings.tech;\n this.cues_ = [];\n this.activeCues_ = [];\n this.preload_ = this.tech_.preloadTextTracks !== false;\n const cues = new TextTrackCueList(this.cues_);\n const activeCues = new TextTrackCueList(this.activeCues_);\n let changed = false;\n this.timeupdateHandler = bind_(this, function (event = {}) {\n if (this.tech_.isDisposed()) {\n return;\n }\n if (!this.tech_.isReady_) {\n if (event.type !== 'timeupdate') {\n this.rvf_ = this.tech_.requestVideoFrameCallback(this.timeupdateHandler);\n }\n return;\n }\n\n // Accessing this.activeCues for the side-effects of updating itself\n // due to its nature as a getter function. Do not remove or cues will\n // stop updating!\n // Use the setter to prevent deletion from uglify (pure_getters rule)\n this.activeCues = this.activeCues;\n if (changed) {\n this.trigger('cuechange');\n changed = false;\n }\n if (event.type !== 'timeupdate') {\n this.rvf_ = this.tech_.requestVideoFrameCallback(this.timeupdateHandler);\n }\n });\n const disposeHandler = () => {\n this.stopTracking();\n };\n this.tech_.one('dispose', disposeHandler);\n if (mode !== 'disabled') {\n this.startTracking();\n }\n Object.defineProperties(this, {\n /**\n * @memberof TextTrack\n * @member {boolean} default\n * If this track was set to be on or off by default. Cannot be changed after\n * creation.\n * @instance\n *\n * @readonly\n */\n default: {\n get() {\n return default_;\n },\n set() {}\n },\n /**\n * @memberof TextTrack\n * @member {string} mode\n * Set the mode of this TextTrack to a valid {@link TextTrack~Mode}. Will\n * not be set if setting to an invalid mode.\n * @instance\n *\n * @fires TextTrack#modechange\n */\n mode: {\n get() {\n return mode;\n },\n set(newMode) {\n if (!TextTrackMode[newMode]) {\n return;\n }\n if (mode === newMode) {\n return;\n }\n mode = newMode;\n if (!this.preload_ && mode !== 'disabled' && this.cues.length === 0) {\n // On-demand load.\n loadTrack(this.src, this);\n }\n this.stopTracking();\n if (mode !== 'disabled') {\n this.startTracking();\n }\n /**\n * An event that fires when mode changes on this track. This allows\n * the TextTrackList that holds this track to act accordingly.\n *\n * > Note: This is not part of the spec!\n *\n * @event TextTrack#modechange\n * @type {Event}\n */\n this.trigger('modechange');\n }\n },\n /**\n * @memberof TextTrack\n * @member {TextTrackCueList} cues\n * The text track cue list for this TextTrack.\n * @instance\n */\n cues: {\n get() {\n if (!this.loaded_) {\n return null;\n }\n return cues;\n },\n set() {}\n },\n /**\n * @memberof TextTrack\n * @member {TextTrackCueList} activeCues\n * The list text track cues that are currently active for this TextTrack.\n * @instance\n */\n activeCues: {\n get() {\n if (!this.loaded_) {\n return null;\n }\n\n // nothing to do\n if (this.cues.length === 0) {\n return activeCues;\n }\n const ct = this.tech_.currentTime();\n const active = [];\n for (let i = 0, l = this.cues.length; i < l; i++) {\n const cue = this.cues[i];\n if (cue.startTime <= ct && cue.endTime >= ct) {\n active.push(cue);\n }\n }\n changed = false;\n if (active.length !== this.activeCues_.length) {\n changed = true;\n } else {\n for (let i = 0; i < active.length; i++) {\n if (this.activeCues_.indexOf(active[i]) === -1) {\n changed = true;\n }\n }\n }\n this.activeCues_ = active;\n activeCues.setCues_(this.activeCues_);\n return activeCues;\n },\n // /!\\ Keep this setter empty (see the timeupdate handler above)\n set() {}\n }\n });\n if (settings.src) {\n this.src = settings.src;\n if (!this.preload_) {\n // Tracks will load on-demand.\n // Act like we're loaded for other purposes.\n this.loaded_ = true;\n }\n if (this.preload_ || settings.kind !== 'subtitles' && settings.kind !== 'captions') {\n loadTrack(this.src, this);\n }\n } else {\n this.loaded_ = true;\n }\n }\n startTracking() {\n // More precise cues based on requestVideoFrameCallback with a requestAnimationFram fallback\n this.rvf_ = this.tech_.requestVideoFrameCallback(this.timeupdateHandler);\n // Also listen to timeupdate in case rVFC/rAF stops (window in background, audio in video el)\n this.tech_.on('timeupdate', this.timeupdateHandler);\n }\n stopTracking() {\n if (this.rvf_) {\n this.tech_.cancelVideoFrameCallback(this.rvf_);\n this.rvf_ = undefined;\n }\n this.tech_.off('timeupdate', this.timeupdateHandler);\n }\n\n /**\n * Add a cue to the internal list of cues.\n *\n * @param {TextTrack~Cue} cue\n * The cue to add to our internal list\n */\n addCue(originalCue) {\n let cue = originalCue;\n\n // Testing if the cue is a VTTCue in a way that survives minification\n if (!('getCueAsHTML' in cue)) {\n cue = new window$1.vttjs.VTTCue(originalCue.startTime, originalCue.endTime, originalCue.text);\n for (const prop in originalCue) {\n if (!(prop in cue)) {\n cue[prop] = originalCue[prop];\n }\n }\n\n // make sure that `id` is copied over\n cue.id = originalCue.id;\n cue.originalCue_ = originalCue;\n }\n const tracks = this.tech_.textTracks();\n for (let i = 0; i < tracks.length; i++) {\n if (tracks[i] !== this) {\n tracks[i].removeCue(cue);\n }\n }\n this.cues_.push(cue);\n this.cues.setCues_(this.cues_);\n }\n\n /**\n * Remove a cue from our internal list\n *\n * @param {TextTrack~Cue} removeCue\n * The cue to remove from our internal list\n */\n removeCue(removeCue) {\n let i = this.cues_.length;\n while (i--) {\n const cue = this.cues_[i];\n if (cue === removeCue || cue.originalCue_ && cue.originalCue_ === removeCue) {\n this.cues_.splice(i, 1);\n this.cues.setCues_(this.cues_);\n break;\n }\n }\n }\n}\n\n/**\n * cuechange - One or more cues in the track have become active or stopped being active.\n * @protected\n */\nTextTrack.prototype.allowedEvents_ = {\n cuechange: 'cuechange'\n};\n\n/**\n * A representation of a single `AudioTrack`. If it is part of an {@link AudioTrackList}\n * only one `AudioTrack` in the list will be enabled at a time.\n *\n * @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#audiotrack}\n * @extends Track\n */\nclass AudioTrack extends Track {\n /**\n * Create an instance of this class.\n *\n * @param {Object} [options={}]\n * Object of option names and values\n *\n * @param {AudioTrack~Kind} [options.kind='']\n * A valid audio track kind\n *\n * @param {string} [options.id='vjs_track_' + Guid.newGUID()]\n * A unique id for this AudioTrack.\n *\n * @param {string} [options.label='']\n * The menu label for this track.\n *\n * @param {string} [options.language='']\n * A valid two character language code.\n *\n * @param {boolean} [options.enabled]\n * If this track is the one that is currently playing. If this track is part of\n * an {@link AudioTrackList}, only one {@link AudioTrack} will be enabled.\n */\n constructor(options = {}) {\n const settings = merge$1(options, {\n kind: AudioTrackKind[options.kind] || ''\n });\n super(settings);\n let enabled = false;\n\n /**\n * @memberof AudioTrack\n * @member {boolean} enabled\n * If this `AudioTrack` is enabled or not. When setting this will\n * fire {@link AudioTrack#enabledchange} if the state of enabled is changed.\n * @instance\n *\n * @fires VideoTrack#selectedchange\n */\n Object.defineProperty(this, 'enabled', {\n get() {\n return enabled;\n },\n set(newEnabled) {\n // an invalid or unchanged value\n if (typeof newEnabled !== 'boolean' || newEnabled === enabled) {\n return;\n }\n enabled = newEnabled;\n\n /**\n * An event that fires when enabled changes on this track. This allows\n * the AudioTrackList that holds this track to act accordingly.\n *\n * > Note: This is not part of the spec! Native tracks will do\n * this internally without an event.\n *\n * @event AudioTrack#enabledchange\n * @type {Event}\n */\n this.trigger('enabledchange');\n }\n });\n\n // if the user sets this track to selected then\n // set selected to that true value otherwise\n // we keep it false\n if (settings.enabled) {\n this.enabled = settings.enabled;\n }\n this.loaded_ = true;\n }\n}\n\n/**\n * A representation of a single `VideoTrack`.\n *\n * @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#videotrack}\n * @extends Track\n */\nclass VideoTrack extends Track {\n /**\n * Create an instance of this class.\n *\n * @param {Object} [options={}]\n * Object of option names and values\n *\n * @param {string} [options.kind='']\n * A valid {@link VideoTrack~Kind}\n *\n * @param {string} [options.id='vjs_track_' + Guid.newGUID()]\n * A unique id for this AudioTrack.\n *\n * @param {string} [options.label='']\n * The menu label for this track.\n *\n * @param {string} [options.language='']\n * A valid two character language code.\n *\n * @param {boolean} [options.selected]\n * If this track is the one that is currently playing.\n */\n constructor(options = {}) {\n const settings = merge$1(options, {\n kind: VideoTrackKind[options.kind] || ''\n });\n super(settings);\n let selected = false;\n\n /**\n * @memberof VideoTrack\n * @member {boolean} selected\n * If this `VideoTrack` is selected or not. When setting this will\n * fire {@link VideoTrack#selectedchange} if the state of selected changed.\n * @instance\n *\n * @fires VideoTrack#selectedchange\n */\n Object.defineProperty(this, 'selected', {\n get() {\n return selected;\n },\n set(newSelected) {\n // an invalid or unchanged value\n if (typeof newSelected !== 'boolean' || newSelected === selected) {\n return;\n }\n selected = newSelected;\n\n /**\n * An event that fires when selected changes on this track. This allows\n * the VideoTrackList that holds this track to act accordingly.\n *\n * > Note: This is not part of the spec! Native tracks will do\n * this internally without an event.\n *\n * @event VideoTrack#selectedchange\n * @type {Event}\n */\n this.trigger('selectedchange');\n }\n });\n\n // if the user sets this track to selected then\n // set selected to that true value otherwise\n // we keep it false\n if (settings.selected) {\n this.selected = settings.selected;\n }\n }\n}\n\n/**\n * @file html-track-element.js\n */\n\n/**\n * A single track represented in the DOM.\n *\n * @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#htmltrackelement}\n * @extends EventTarget\n */\nclass HTMLTrackElement extends EventTarget$2 {\n /**\n * Create an instance of this class.\n *\n * @param {Object} options={}\n * Object of option names and values\n *\n * @param { import('../tech/tech').default } options.tech\n * A reference to the tech that owns this HTMLTrackElement.\n *\n * @param {TextTrack~Kind} [options.kind='subtitles']\n * A valid text track kind.\n *\n * @param {TextTrack~Mode} [options.mode='disabled']\n * A valid text track mode.\n *\n * @param {string} [options.id='vjs_track_' + Guid.newGUID()]\n * A unique id for this TextTrack.\n *\n * @param {string} [options.label='']\n * The menu label for this track.\n *\n * @param {string} [options.language='']\n * A valid two character language code.\n *\n * @param {string} [options.srclang='']\n * A valid two character language code. An alternative, but deprioritized\n * version of `options.language`\n *\n * @param {string} [options.src]\n * A url to TextTrack cues.\n *\n * @param {boolean} [options.default]\n * If this track should default to on or off.\n */\n constructor(options = {}) {\n super();\n let readyState;\n const track = new TextTrack(options);\n this.kind = track.kind;\n this.src = track.src;\n this.srclang = track.language;\n this.label = track.label;\n this.default = track.default;\n Object.defineProperties(this, {\n /**\n * @memberof HTMLTrackElement\n * @member {HTMLTrackElement~ReadyState} readyState\n * The current ready state of the track element.\n * @instance\n */\n readyState: {\n get() {\n return readyState;\n }\n },\n /**\n * @memberof HTMLTrackElement\n * @member {TextTrack} track\n * The underlying TextTrack object.\n * @instance\n *\n */\n track: {\n get() {\n return track;\n }\n }\n });\n readyState = HTMLTrackElement.NONE;\n\n /**\n * @listens TextTrack#loadeddata\n * @fires HTMLTrackElement#load\n */\n track.addEventListener('loadeddata', () => {\n readyState = HTMLTrackElement.LOADED;\n this.trigger({\n type: 'load',\n target: this\n });\n });\n }\n}\n\n/**\n * @protected\n */\nHTMLTrackElement.prototype.allowedEvents_ = {\n load: 'load'\n};\n\n/**\n * The text track not loaded state.\n *\n * @type {number}\n * @static\n */\nHTMLTrackElement.NONE = 0;\n\n/**\n * The text track loading state.\n *\n * @type {number}\n * @static\n */\nHTMLTrackElement.LOADING = 1;\n\n/**\n * The text track loaded state.\n *\n * @type {number}\n * @static\n */\nHTMLTrackElement.LOADED = 2;\n\n/**\n * The text track failed to load state.\n *\n * @type {number}\n * @static\n */\nHTMLTrackElement.ERROR = 3;\n\n/*\n * This file contains all track properties that are used in\n * player.js, tech.js, html5.js and possibly other techs in the future.\n */\n\nconst NORMAL = {\n audio: {\n ListClass: AudioTrackList,\n TrackClass: AudioTrack,\n capitalName: 'Audio'\n },\n video: {\n ListClass: VideoTrackList,\n TrackClass: VideoTrack,\n capitalName: 'Video'\n },\n text: {\n ListClass: TextTrackList,\n TrackClass: TextTrack,\n capitalName: 'Text'\n }\n};\nObject.keys(NORMAL).forEach(function (type) {\n NORMAL[type].getterName = `${type}Tracks`;\n NORMAL[type].privateName = `${type}Tracks_`;\n});\nconst REMOTE = {\n remoteText: {\n ListClass: TextTrackList,\n TrackClass: TextTrack,\n capitalName: 'RemoteText',\n getterName: 'remoteTextTracks',\n privateName: 'remoteTextTracks_'\n },\n remoteTextEl: {\n ListClass: HtmlTrackElementList,\n TrackClass: HTMLTrackElement,\n capitalName: 'RemoteTextTrackEls',\n getterName: 'remoteTextTrackEls',\n privateName: 'remoteTextTrackEls_'\n }\n};\nconst ALL = Object.assign({}, NORMAL, REMOTE);\nREMOTE.names = Object.keys(REMOTE);\nNORMAL.names = Object.keys(NORMAL);\nALL.names = [].concat(REMOTE.names).concat(NORMAL.names);\n\n/**\n * @file tech.js\n */\n\n/**\n * An Object containing a structure like: `{src: 'url', type: 'mimetype'}` or string\n * that just contains the src url alone.\n * * `var SourceObject = {src: 'http://ex.com/video.mp4', type: 'video/mp4'};`\n * `var SourceString = 'http://example.com/some-video.mp4';`\n *\n * @typedef {Object|string} SourceObject\n *\n * @property {string} src\n * The url to the source\n *\n * @property {string} type\n * The mime type of the source\n */\n\n/**\n * A function used by {@link Tech} to create a new {@link TextTrack}.\n *\n * @private\n *\n * @param {Tech} self\n * An instance of the Tech class.\n *\n * @param {string} kind\n * `TextTrack` kind (subtitles, captions, descriptions, chapters, or metadata)\n *\n * @param {string} [label]\n * Label to identify the text track\n *\n * @param {string} [language]\n * Two letter language abbreviation\n *\n * @param {Object} [options={}]\n * An object with additional text track options\n *\n * @return {TextTrack}\n * The text track that was created.\n */\nfunction createTrackHelper(self, kind, label, language, options = {}) {\n const tracks = self.textTracks();\n options.kind = kind;\n if (label) {\n options.label = label;\n }\n if (language) {\n options.language = language;\n }\n options.tech = self;\n const track = new ALL.text.TrackClass(options);\n tracks.addTrack(track);\n return track;\n}\n\n/**\n * This is the base class for media playback technology controllers, such as\n * {@link HTML5}\n *\n * @extends Component\n */\nclass Tech extends Component$1 {\n /**\n * Create an instance of this Tech.\n *\n * @param {Object} [options]\n * The key/value store of player options.\n *\n * @param {Function} [ready]\n * Callback function to call when the `HTML5` Tech is ready.\n */\n constructor(options = {}, ready = function () {}) {\n // we don't want the tech to report user activity automatically.\n // This is done manually in addControlsListeners\n options.reportTouchActivity = false;\n super(null, options, ready);\n this.onDurationChange_ = e => this.onDurationChange(e);\n this.trackProgress_ = e => this.trackProgress(e);\n this.trackCurrentTime_ = e => this.trackCurrentTime(e);\n this.stopTrackingCurrentTime_ = e => this.stopTrackingCurrentTime(e);\n this.disposeSourceHandler_ = e => this.disposeSourceHandler(e);\n this.queuedHanders_ = new Set();\n\n // keep track of whether the current source has played at all to\n // implement a very limited played()\n this.hasStarted_ = false;\n this.on('playing', function () {\n this.hasStarted_ = true;\n });\n this.on('loadstart', function () {\n this.hasStarted_ = false;\n });\n ALL.names.forEach(name => {\n const props = ALL[name];\n if (options && options[props.getterName]) {\n this[props.privateName] = options[props.getterName];\n }\n });\n\n // Manually track progress in cases where the browser/tech doesn't report it.\n if (!this.featuresProgressEvents) {\n this.manualProgressOn();\n }\n\n // Manually track timeupdates in cases where the browser/tech doesn't report it.\n if (!this.featuresTimeupdateEvents) {\n this.manualTimeUpdatesOn();\n }\n ['Text', 'Audio', 'Video'].forEach(track => {\n if (options[`native${track}Tracks`] === false) {\n this[`featuresNative${track}Tracks`] = false;\n }\n });\n if (options.nativeCaptions === false || options.nativeTextTracks === false) {\n this.featuresNativeTextTracks = false;\n } else if (options.nativeCaptions === true || options.nativeTextTracks === true) {\n this.featuresNativeTextTracks = true;\n }\n if (!this.featuresNativeTextTracks) {\n this.emulateTextTracks();\n }\n this.preloadTextTracks = options.preloadTextTracks !== false;\n this.autoRemoteTextTracks_ = new ALL.text.ListClass();\n this.initTrackListeners();\n\n // Turn on component tap events only if not using native controls\n if (!options.nativeControlsForTouch) {\n this.emitTapEvents();\n }\n if (this.constructor) {\n this.name_ = this.constructor.name || 'Unknown Tech';\n }\n }\n\n /**\n * A special function to trigger source set in a way that will allow player\n * to re-trigger if the player or tech are not ready yet.\n *\n * @fires Tech#sourceset\n * @param {string} src The source string at the time of the source changing.\n */\n triggerSourceset(src) {\n if (!this.isReady_) {\n // on initial ready we have to trigger source set\n // 1ms after ready so that player can watch for it.\n this.one('ready', () => this.setTimeout(() => this.triggerSourceset(src), 1));\n }\n\n /**\n * Fired when the source is set on the tech causing the media element\n * to reload.\n *\n * @see {@link Player#event:sourceset}\n * @event Tech#sourceset\n * @type {Event}\n */\n this.trigger({\n src,\n type: 'sourceset'\n });\n }\n\n /* Fallbacks for unsupported event types\n ================================================================================ */\n\n /**\n * Polyfill the `progress` event for browsers that don't support it natively.\n *\n * @see {@link Tech#trackProgress}\n */\n manualProgressOn() {\n this.on('durationchange', this.onDurationChange_);\n this.manualProgress = true;\n\n // Trigger progress watching when a source begins loading\n this.one('ready', this.trackProgress_);\n }\n\n /**\n * Turn off the polyfill for `progress` events that was created in\n * {@link Tech#manualProgressOn}\n */\n manualProgressOff() {\n this.manualProgress = false;\n this.stopTrackingProgress();\n this.off('durationchange', this.onDurationChange_);\n }\n\n /**\n * This is used to trigger a `progress` event when the buffered percent changes. It\n * sets an interval function that will be called every 500 milliseconds to check if the\n * buffer end percent has changed.\n *\n * > This function is called by {@link Tech#manualProgressOn}\n *\n * @param {Event} event\n * The `ready` event that caused this to run.\n *\n * @listens Tech#ready\n * @fires Tech#progress\n */\n trackProgress(event) {\n this.stopTrackingProgress();\n this.progressInterval = this.setInterval(bind_(this, function () {\n // Don't trigger unless buffered amount is greater than last time\n\n const numBufferedPercent = this.bufferedPercent();\n if (this.bufferedPercent_ !== numBufferedPercent) {\n /**\n * See {@link Player#progress}\n *\n * @event Tech#progress\n * @type {Event}\n */\n this.trigger('progress');\n }\n this.bufferedPercent_ = numBufferedPercent;\n if (numBufferedPercent === 1) {\n this.stopTrackingProgress();\n }\n }), 500);\n }\n\n /**\n * Update our internal duration on a `durationchange` event by calling\n * {@link Tech#duration}.\n *\n * @param {Event} event\n * The `durationchange` event that caused this to run.\n *\n * @listens Tech#durationchange\n */\n onDurationChange(event) {\n this.duration_ = this.duration();\n }\n\n /**\n * Get and create a `TimeRange` object for buffering.\n *\n * @return { import('../utils/time').TimeRange }\n * The time range object that was created.\n */\n buffered() {\n return createTimeRanges$1(0, 0);\n }\n\n /**\n * Get the percentage of the current video that is currently buffered.\n *\n * @return {number}\n * A number from 0 to 1 that represents the decimal percentage of the\n * video that is buffered.\n *\n */\n bufferedPercent() {\n return bufferedPercent(this.buffered(), this.duration_);\n }\n\n /**\n * Turn off the polyfill for `progress` events that was created in\n * {@link Tech#manualProgressOn}\n * Stop manually tracking progress events by clearing the interval that was set in\n * {@link Tech#trackProgress}.\n */\n stopTrackingProgress() {\n this.clearInterval(this.progressInterval);\n }\n\n /**\n * Polyfill the `timeupdate` event for browsers that don't support it.\n *\n * @see {@link Tech#trackCurrentTime}\n */\n manualTimeUpdatesOn() {\n this.manualTimeUpdates = true;\n this.on('play', this.trackCurrentTime_);\n this.on('pause', this.stopTrackingCurrentTime_);\n }\n\n /**\n * Turn off the polyfill for `timeupdate` events that was created in\n * {@link Tech#manualTimeUpdatesOn}\n */\n manualTimeUpdatesOff() {\n this.manualTimeUpdates = false;\n this.stopTrackingCurrentTime();\n this.off('play', this.trackCurrentTime_);\n this.off('pause', this.stopTrackingCurrentTime_);\n }\n\n /**\n * Sets up an interval function to track current time and trigger `timeupdate` every\n * 250 milliseconds.\n *\n * @listens Tech#play\n * @triggers Tech#timeupdate\n */\n trackCurrentTime() {\n if (this.currentTimeInterval) {\n this.stopTrackingCurrentTime();\n }\n this.currentTimeInterval = this.setInterval(function () {\n /**\n * Triggered at an interval of 250ms to indicated that time is passing in the video.\n *\n * @event Tech#timeupdate\n * @type {Event}\n */\n this.trigger({\n type: 'timeupdate',\n target: this,\n manuallyTriggered: true\n });\n\n // 42 = 24 fps // 250 is what Webkit uses // FF uses 15\n }, 250);\n }\n\n /**\n * Stop the interval function created in {@link Tech#trackCurrentTime} so that the\n * `timeupdate` event is no longer triggered.\n *\n * @listens {Tech#pause}\n */\n stopTrackingCurrentTime() {\n this.clearInterval(this.currentTimeInterval);\n\n // #1002 - if the video ends right before the next timeupdate would happen,\n // the progress bar won't make it all the way to the end\n this.trigger({\n type: 'timeupdate',\n target: this,\n manuallyTriggered: true\n });\n }\n\n /**\n * Turn off all event polyfills, clear the `Tech`s {@link AudioTrackList},\n * {@link VideoTrackList}, and {@link TextTrackList}, and dispose of this Tech.\n *\n * @fires Component#dispose\n */\n dispose() {\n // clear out all tracks because we can't reuse them between techs\n this.clearTracks(NORMAL.names);\n\n // Turn off any manual progress or timeupdate tracking\n if (this.manualProgress) {\n this.manualProgressOff();\n }\n if (this.manualTimeUpdates) {\n this.manualTimeUpdatesOff();\n }\n super.dispose();\n }\n\n /**\n * Clear out a single `TrackList` or an array of `TrackLists` given their names.\n *\n * > Note: Techs without source handlers should call this between sources for `video`\n * & `audio` tracks. You don't want to use them between tracks!\n *\n * @param {string[]|string} types\n * TrackList names to clear, valid names are `video`, `audio`, and\n * `text`.\n */\n clearTracks(types) {\n types = [].concat(types);\n // clear out all tracks because we can't reuse them between techs\n types.forEach(type => {\n const list = this[`${type}Tracks`]() || [];\n let i = list.length;\n while (i--) {\n const track = list[i];\n if (type === 'text') {\n this.removeRemoteTextTrack(track);\n }\n list.removeTrack(track);\n }\n });\n }\n\n /**\n * Remove any TextTracks added via addRemoteTextTrack that are\n * flagged for automatic garbage collection\n */\n cleanupAutoTextTracks() {\n const list = this.autoRemoteTextTracks_ || [];\n let i = list.length;\n while (i--) {\n const track = list[i];\n this.removeRemoteTextTrack(track);\n }\n }\n\n /**\n * Reset the tech, which will removes all sources and reset the internal readyState.\n *\n * @abstract\n */\n reset() {}\n\n /**\n * Get the value of `crossOrigin` from the tech.\n *\n * @abstract\n *\n * @see {Html5#crossOrigin}\n */\n crossOrigin() {}\n\n /**\n * Set the value of `crossOrigin` on the tech.\n *\n * @abstract\n *\n * @param {string} crossOrigin the crossOrigin value\n * @see {Html5#setCrossOrigin}\n */\n setCrossOrigin() {}\n\n /**\n * Get or set an error on the Tech.\n *\n * @param {MediaError} [err]\n * Error to set on the Tech\n *\n * @return {MediaError|null}\n * The current error object on the tech, or null if there isn't one.\n */\n error(err) {\n if (err !== undefined) {\n this.error_ = new MediaError(err);\n this.trigger('error');\n }\n return this.error_;\n }\n\n /**\n * Returns the `TimeRange`s that have been played through for the current source.\n *\n * > NOTE: This implementation is incomplete. It does not track the played `TimeRange`.\n * It only checks whether the source has played at all or not.\n *\n * @return { import('../utils/time').TimeRange }\n * - A single time range if this video has played\n * - An empty set of ranges if not.\n */\n played() {\n if (this.hasStarted_) {\n return createTimeRanges$1(0, 0);\n }\n return createTimeRanges$1();\n }\n\n /**\n * Start playback\n *\n * @abstract\n *\n * @see {Html5#play}\n */\n play() {}\n\n /**\n * Set whether we are scrubbing or not\n *\n * @abstract\n * @param {boolean} _isScrubbing\n * - true for we are currently scrubbing\n * - false for we are no longer scrubbing\n *\n * @see {Html5#setScrubbing}\n */\n setScrubbing(_isScrubbing) {}\n\n /**\n * Get whether we are scrubbing or not\n *\n * @abstract\n *\n * @see {Html5#scrubbing}\n */\n scrubbing() {}\n\n /**\n * Causes a manual time update to occur if {@link Tech#manualTimeUpdatesOn} was\n * previously called.\n *\n * @param {number} _seconds\n * Set the current time of the media to this.\n * @fires Tech#timeupdate\n */\n setCurrentTime(_seconds) {\n // improve the accuracy of manual timeupdates\n if (this.manualTimeUpdates) {\n /**\n * A manual `timeupdate` event.\n *\n * @event Tech#timeupdate\n * @type {Event}\n */\n this.trigger({\n type: 'timeupdate',\n target: this,\n manuallyTriggered: true\n });\n }\n }\n\n /**\n * Turn on listeners for {@link VideoTrackList}, {@link {AudioTrackList}, and\n * {@link TextTrackList} events.\n *\n * This adds {@link EventTarget~EventListeners} for `addtrack`, and `removetrack`.\n *\n * @fires Tech#audiotrackchange\n * @fires Tech#videotrackchange\n * @fires Tech#texttrackchange\n */\n initTrackListeners() {\n /**\n * Triggered when tracks are added or removed on the Tech {@link AudioTrackList}\n *\n * @event Tech#audiotrackchange\n * @type {Event}\n */\n\n /**\n * Triggered when tracks are added or removed on the Tech {@link VideoTrackList}\n *\n * @event Tech#videotrackchange\n * @type {Event}\n */\n\n /**\n * Triggered when tracks are added or removed on the Tech {@link TextTrackList}\n *\n * @event Tech#texttrackchange\n * @type {Event}\n */\n NORMAL.names.forEach(name => {\n const props = NORMAL[name];\n const trackListChanges = () => {\n this.trigger(`${name}trackchange`);\n };\n const tracks = this[props.getterName]();\n tracks.addEventListener('removetrack', trackListChanges);\n tracks.addEventListener('addtrack', trackListChanges);\n this.on('dispose', () => {\n tracks.removeEventListener('removetrack', trackListChanges);\n tracks.removeEventListener('addtrack', trackListChanges);\n });\n });\n }\n\n /**\n * Emulate TextTracks using vtt.js if necessary\n *\n * @fires Tech#vttjsloaded\n * @fires Tech#vttjserror\n */\n addWebVttScript_() {\n if (window$1.WebVTT) {\n return;\n }\n\n // Initially, Tech.el_ is a child of a dummy-div wait until the Component system\n // signals that the Tech is ready at which point Tech.el_ is part of the DOM\n // before inserting the WebVTT script\n if (document.body.contains(this.el())) {\n // load via require if available and vtt.js script location was not passed in\n // as an option. novtt builds will turn the above require call into an empty object\n // which will cause this if check to always fail.\n if (!this.options_['vtt.js'] && isPlain(vtt) && Object.keys(vtt).length > 0) {\n this.trigger('vttjsloaded');\n return;\n }\n\n // load vtt.js via the script location option or the cdn of no location was\n // passed in\n const script = document.createElement('script');\n script.src = this.options_['vtt.js'] || 'https://vjs.zencdn.net/vttjs/0.14.1/vtt.min.js';\n script.onload = () => {\n /**\n * Fired when vtt.js is loaded.\n *\n * @event Tech#vttjsloaded\n * @type {Event}\n */\n this.trigger('vttjsloaded');\n };\n script.onerror = () => {\n /**\n * Fired when vtt.js was not loaded due to an error\n *\n * @event Tech#vttjsloaded\n * @type {Event}\n */\n this.trigger('vttjserror');\n };\n this.on('dispose', () => {\n script.onload = null;\n script.onerror = null;\n });\n // but have not loaded yet and we set it to true before the inject so that\n // we don't overwrite the injected window.WebVTT if it loads right away\n window$1.WebVTT = true;\n this.el().parentNode.appendChild(script);\n } else {\n this.ready(this.addWebVttScript_);\n }\n }\n\n /**\n * Emulate texttracks\n *\n */\n emulateTextTracks() {\n const tracks = this.textTracks();\n const remoteTracks = this.remoteTextTracks();\n const handleAddTrack = e => tracks.addTrack(e.track);\n const handleRemoveTrack = e => tracks.removeTrack(e.track);\n remoteTracks.on('addtrack', handleAddTrack);\n remoteTracks.on('removetrack', handleRemoveTrack);\n this.addWebVttScript_();\n const updateDisplay = () => this.trigger('texttrackchange');\n const textTracksChanges = () => {\n updateDisplay();\n for (let i = 0; i < tracks.length; i++) {\n const track = tracks[i];\n track.removeEventListener('cuechange', updateDisplay);\n if (track.mode === 'showing') {\n track.addEventListener('cuechange', updateDisplay);\n }\n }\n };\n textTracksChanges();\n tracks.addEventListener('change', textTracksChanges);\n tracks.addEventListener('addtrack', textTracksChanges);\n tracks.addEventListener('removetrack', textTracksChanges);\n this.on('dispose', function () {\n remoteTracks.off('addtrack', handleAddTrack);\n remoteTracks.off('removetrack', handleRemoveTrack);\n tracks.removeEventListener('change', textTracksChanges);\n tracks.removeEventListener('addtrack', textTracksChanges);\n tracks.removeEventListener('removetrack', textTracksChanges);\n for (let i = 0; i < tracks.length; i++) {\n const track = tracks[i];\n track.removeEventListener('cuechange', updateDisplay);\n }\n });\n }\n\n /**\n * Create and returns a remote {@link TextTrack} object.\n *\n * @param {string} kind\n * `TextTrack` kind (subtitles, captions, descriptions, chapters, or metadata)\n *\n * @param {string} [label]\n * Label to identify the text track\n *\n * @param {string} [language]\n * Two letter language abbreviation\n *\n * @return {TextTrack}\n * The TextTrack that gets created.\n */\n addTextTrack(kind, label, language) {\n if (!kind) {\n throw new Error('TextTrack kind is required but was not provided');\n }\n return createTrackHelper(this, kind, label, language);\n }\n\n /**\n * Create an emulated TextTrack for use by addRemoteTextTrack\n *\n * This is intended to be overridden by classes that inherit from\n * Tech in order to create native or custom TextTracks.\n *\n * @param {Object} options\n * The object should contain the options to initialize the TextTrack with.\n *\n * @param {string} [options.kind]\n * `TextTrack` kind (subtitles, captions, descriptions, chapters, or metadata).\n *\n * @param {string} [options.label].\n * Label to identify the text track\n *\n * @param {string} [options.language]\n * Two letter language abbreviation.\n *\n * @return {HTMLTrackElement}\n * The track element that gets created.\n */\n createRemoteTextTrack(options) {\n const track = merge$1(options, {\n tech: this\n });\n return new REMOTE.remoteTextEl.TrackClass(track);\n }\n\n /**\n * Creates a remote text track object and returns an html track element.\n *\n * > Note: This can be an emulated {@link HTMLTrackElement} or a native one.\n *\n * @param {Object} options\n * See {@link Tech#createRemoteTextTrack} for more detailed properties.\n *\n * @param {boolean} [manualCleanup=false]\n * - When false: the TextTrack will be automatically removed from the video\n * element whenever the source changes\n * - When True: The TextTrack will have to be cleaned up manually\n *\n * @return {HTMLTrackElement}\n * An Html Track Element.\n *\n */\n addRemoteTextTrack(options = {}, manualCleanup) {\n const htmlTrackElement = this.createRemoteTextTrack(options);\n if (typeof manualCleanup !== 'boolean') {\n manualCleanup = false;\n }\n\n // store HTMLTrackElement and TextTrack to remote list\n this.remoteTextTrackEls().addTrackElement_(htmlTrackElement);\n this.remoteTextTracks().addTrack(htmlTrackElement.track);\n if (manualCleanup === false) {\n // create the TextTrackList if it doesn't exist\n this.ready(() => this.autoRemoteTextTracks_.addTrack(htmlTrackElement.track));\n }\n return htmlTrackElement;\n }\n\n /**\n * Remove a remote text track from the remote `TextTrackList`.\n *\n * @param {TextTrack} track\n * `TextTrack` to remove from the `TextTrackList`\n */\n removeRemoteTextTrack(track) {\n const trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track);\n\n // remove HTMLTrackElement and TextTrack from remote list\n this.remoteTextTrackEls().removeTrackElement_(trackElement);\n this.remoteTextTracks().removeTrack(track);\n this.autoRemoteTextTracks_.removeTrack(track);\n }\n\n /**\n * Gets available media playback quality metrics as specified by the W3C's Media\n * Playback Quality API.\n *\n * @see [Spec]{@link https://wicg.github.io/media-playback-quality}\n *\n * @return {Object}\n * An object with supported media playback quality metrics\n *\n * @abstract\n */\n getVideoPlaybackQuality() {\n return {};\n }\n\n /**\n * Attempt to create a floating video window always on top of other windows\n * so that users may continue consuming media while they interact with other\n * content sites, or applications on their device.\n *\n * @see [Spec]{@link https://wicg.github.io/picture-in-picture}\n *\n * @return {Promise|undefined}\n * A promise with a Picture-in-Picture window if the browser supports\n * Promises (or one was passed in as an option). It returns undefined\n * otherwise.\n *\n * @abstract\n */\n requestPictureInPicture() {\n return Promise.reject();\n }\n\n /**\n * A method to check for the value of the 'disablePictureInPicture'