From 0bfee46b33515e4bd3719249f5b415e02e2346b5 Mon Sep 17 00:00:00 2001 From: jfh Date: Sat, 29 Aug 2020 01:20:37 +0200 Subject: [PATCH] make test run with systemjs build --- badges/coverage-badge.svg | 2 +- badges/tests-badge.svg | 2 +- cypress/integration/ui/accessibility.js | 2 +- cypress/integration/unit/test1.js | 8 +- cypress/support/ui-test-helper.js | 2 +- dist/editor/index.js | 259 +++++----- dist/editor/index.js.map | 2 +- dist/editor/system/index.js | 259 +++++----- package-lock.json | 629 +++++++++++++----------- package.json | 30 +- 10 files changed, 653 insertions(+), 542 deletions(-) diff --git a/badges/coverage-badge.svg b/badges/coverage-badge.svg index a8315467..50e7ce2d 100644 --- a/badges/coverage-badge.svg +++ b/badges/coverage-badge.svg @@ -1 +1 @@ -Statements 46.46%Statements 46.46%Branches 35.01%Branches 35.01%Lines 47.67%Lines 47.67%Functions 50.79%Functions 50.79% +Statements 44.46%Statements 44.46%Branches 39.89%Branches 39.89%Lines 46.25%Lines 46.25%Functions 47.89%Functions 47.89% diff --git a/badges/tests-badge.svg b/badges/tests-badge.svg index 0d1ca370..741adea8 100644 --- a/badges/tests-badge.svg +++ b/badges/tests-badge.svg @@ -1 +1 @@ -TestsTests132/132132/132 \ No newline at end of file +TestsTests124/124124/124 \ No newline at end of file diff --git a/cypress/integration/ui/accessibility.js b/cypress/integration/ui/accessibility.js index 688e9ed6..efd4c6a4 100644 --- a/cypress/integration/ui/accessibility.js +++ b/cypress/integration/ui/accessibility.js @@ -1,6 +1,6 @@ describe('UI - Accessibility', function () { beforeEach(() => { - cy.visit('/instrumented/editor'); + cy.visit('/instrumented/editor/system'); cy.injectAxe(); }); diff --git a/cypress/integration/unit/test1.js b/cypress/integration/unit/test1.js index 5660d1a4..d06d7b1f 100644 --- a/cypress/integration/unit/test1.js +++ b/cypress/integration/unit/test1.js @@ -1,10 +1,12 @@ /* eslint-disable max-len */ -import '../../../instrumented/editor/jquery.min.js'; -import '../../../instrumented/editor/jquery-ui/jquery-ui-1.8.17.custom.min.js'; +// import '../../../instrumented/editor/system/jquery.min.js'; +// import '../../../instrumented/editor/system/jquery-ui/jquery-ui-1.8.17.custom.min.js'; -import '../../../instrumented/common/svgpathseg.js'; +// import '../../../instrumented/common/svgpathseg.js'; import SvgCanvas from '../../../instrumented/svgcanvas/svgcanvas.js'; +// import '../../../instrumented/' + describe('Basic Module', function () { // helper functions /* diff --git a/cypress/support/ui-test-helper.js b/cypress/support/ui-test-helper.js index fec08e69..b9bdd207 100644 --- a/cypress/support/ui-test-helper.js +++ b/cypress/support/ui-test-helper.js @@ -4,7 +4,7 @@ export const approveStorage = () => { }; export const visitAndApproveStorage = () => { - cy.visit('/instrumented/editor'); + cy.visit('/instrumented/editor/system'); approveStorage(); }; diff --git a/dist/editor/index.js b/dist/editor/index.js index 4fe0c3d1..684002bc 100644 --- a/dist/editor/index.js +++ b/dist/editor/index.js @@ -81277,8 +81277,7 @@ var html2canvas = createCommonjsModule(function (module, exports) { }); var html2canvas$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), html2canvas, { - 'default': html2canvas, - __moduleExports: html2canvas + 'default': html2canvas })); var purify = createCommonjsModule(function (module, exports) { @@ -82616,8 +82615,7 @@ var purify = createCommonjsModule(function (module, exports) { }); var purify$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), purify, { - 'default': purify, - __moduleExports: purify + 'default': purify })); // shim for using process in browser @@ -83581,7 +83579,10 @@ function _classCallCheck$3(instance, Constructor) { throw new TypeError("Cannot call a class as a function"); } } -/* eslint-disable no-bitwise, unicorn/prefer-query-selector */ +/* eslint-disable no-bitwise -- used for calculations */ + +/* eslint-disable unicorn/prefer-query-selector -- aiming at + backward-compatibility */ /** * StackBlur - a fast almost Gaussian Blur For Canvas @@ -83623,8 +83624,6 @@ function _classCallCheck$3(instance, Constructor) { * OTHER DEALINGS IN THE SOFTWARE. */ -/* eslint-disable max-len */ - var mulTable$1 = [512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292, 273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259, 496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292, 282, 273, 265, 512, 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278, 271, 265, 259, 507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335, 329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405, 399, 394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271, 268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388, 385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335, 332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292, 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259]; var shgTable$1 = [9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24]; @@ -83690,7 +83689,6 @@ function processCanvasRGBA$1(canvas, topX, topY, width, height, radius) { function processImageDataRGBA$1(imageData, topX, topY, width, height, radius) { var pixels = imageData.data; - var x, y, i, p, yp, yi, yw, rSum, gSum, bSum, aSum, rOutSum, gOutSum, bOutSum, aOutSum, rInSum, gInSum, bInSum, aInSum, pr, pg, pb, pa, rbs; var div = 2 * radius + 1; // const w4 = width << 2; var widthMinus1 = width - 1; @@ -83701,7 +83699,7 @@ function processImageDataRGBA$1(imageData, topX, topY, width, height, radius) { var stack = stackStart; var stackEnd; - for (i = 1; i < div; i++) { + for (var i = 1; i < div; i++) { stack = stack.next = new BlurStack$1(); if (i === radiusPlus1) { @@ -83710,25 +83708,21 @@ function processImageDataRGBA$1(imageData, topX, topY, width, height, radius) { } stack.next = stackStart; - var stackIn = null; - var stackOut = null; - yw = yi = 0; + var stackIn = null, + stackOut = null, + yw = 0, + yi = 0; var mulSum = mulTable$1[radius]; var shgSum = shgTable$1[radius]; - for (y = 0; y < height; y++) { - rInSum = gInSum = bInSum = aInSum = rSum = gSum = bSum = aSum = 0; - rOutSum = radiusPlus1 * (pr = pixels[yi]); - gOutSum = radiusPlus1 * (pg = pixels[yi + 1]); - bOutSum = radiusPlus1 * (pb = pixels[yi + 2]); - aOutSum = radiusPlus1 * (pa = pixels[yi + 3]); - rSum += sumFactor * pr; - gSum += sumFactor * pg; - bSum += sumFactor * pb; - aSum += sumFactor * pa; + for (var y = 0; y < height; y++) { stack = stackStart; + var pr = pixels[yi], + pg = pixels[yi + 1], + pb = pixels[yi + 2], + pa = pixels[yi + 3]; - for (i = 0; i < radiusPlus1; i++) { + for (var _i = 0; _i < radiusPlus1; _i++) { stack.r = pr; stack.g = pg; stack.b = pb; @@ -83736,30 +83730,50 @@ function processImageDataRGBA$1(imageData, topX, topY, width, height, radius) { stack = stack.next; } - for (i = 1; i < radiusPlus1; i++) { - p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2); - rSum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - i); - gSum += (stack.g = pg = pixels[p + 1]) * rbs; - bSum += (stack.b = pb = pixels[p + 2]) * rbs; - aSum += (stack.a = pa = pixels[p + 3]) * rbs; - rInSum += pr; - gInSum += pg; - bInSum += pb; - aInSum += pa; + var rInSum = 0, + gInSum = 0, + bInSum = 0, + aInSum = 0, + rOutSum = radiusPlus1 * pr, + gOutSum = radiusPlus1 * pg, + bOutSum = radiusPlus1 * pb, + aOutSum = radiusPlus1 * pa, + rSum = sumFactor * pr, + gSum = sumFactor * pg, + bSum = sumFactor * pb, + aSum = sumFactor * pa; + + for (var _i2 = 1; _i2 < radiusPlus1; _i2++) { + var p = yi + ((widthMinus1 < _i2 ? widthMinus1 : _i2) << 2); + var r = pixels[p], + g = pixels[p + 1], + b = pixels[p + 2], + a = pixels[p + 3]; + var rbs = radiusPlus1 - _i2; + rSum += (stack.r = r) * rbs; + gSum += (stack.g = g) * rbs; + bSum += (stack.b = b) * rbs; + aSum += (stack.a = a) * rbs; + rInSum += r; + gInSum += g; + bInSum += b; + aInSum += a; stack = stack.next; } stackIn = stackStart; stackOut = stackEnd; - for (x = 0; x < width; x++) { - pixels[yi + 3] = pa = aSum * mulSum >> shgSum; + for (var x = 0; x < width; x++) { + var paInitial = aSum * mulSum >> shgSum; + pixels[yi + 3] = paInitial; - if (pa !== 0) { - pa = 255 / pa; - pixels[yi] = (rSum * mulSum >> shgSum) * pa; - pixels[yi + 1] = (gSum * mulSum >> shgSum) * pa; - pixels[yi + 2] = (bSum * mulSum >> shgSum) * pa; + if (paInitial !== 0) { + var _a2 = 255 / paInitial; + + pixels[yi] = (rSum * mulSum >> shgSum) * _a2; + pixels[yi + 1] = (gSum * mulSum >> shgSum) * _a2; + pixels[yi + 2] = (bSum * mulSum >> shgSum) * _a2; } else { pixels[yi] = pixels[yi + 1] = pixels[yi + 2] = 0; } @@ -83772,24 +83786,32 @@ function processImageDataRGBA$1(imageData, topX, topY, width, height, radius) { gOutSum -= stackIn.g; bOutSum -= stackIn.b; aOutSum -= stackIn.a; - p = yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1) << 2; - rInSum += stackIn.r = pixels[p]; - gInSum += stackIn.g = pixels[p + 1]; - bInSum += stackIn.b = pixels[p + 2]; - aInSum += stackIn.a = pixels[p + 3]; + + var _p = x + radius + 1; + + _p = yw + (_p < widthMinus1 ? _p : widthMinus1) << 2; + rInSum += stackIn.r = pixels[_p]; + gInSum += stackIn.g = pixels[_p + 1]; + bInSum += stackIn.b = pixels[_p + 2]; + aInSum += stackIn.a = pixels[_p + 3]; rSum += rInSum; gSum += gInSum; bSum += bInSum; aSum += aInSum; stackIn = stackIn.next; - rOutSum += pr = stackOut.r; - gOutSum += pg = stackOut.g; - bOutSum += pb = stackOut.b; - aOutSum += pa = stackOut.a; - rInSum -= pr; - gInSum -= pg; - bInSum -= pb; - aInSum -= pa; + var _stackOut = stackOut, + _r = _stackOut.r, + _g = _stackOut.g, + _b = _stackOut.b, + _a = _stackOut.a; + rOutSum += _r; + gOutSum += _g; + bOutSum += _b; + aOutSum += _a; + rInSum -= _r; + gInSum -= _g; + bInSum -= _b; + aInSum -= _a; stackOut = stackOut.next; yi += 4; } @@ -83797,85 +83819,98 @@ function processImageDataRGBA$1(imageData, topX, topY, width, height, radius) { yw += width; } - for (x = 0; x < width; x++) { - gInSum = bInSum = aInSum = rInSum = gSum = bSum = aSum = rSum = 0; - yi = x << 2; - rOutSum = radiusPlus1 * (pr = pixels[yi]); - gOutSum = radiusPlus1 * (pg = pixels[yi + 1]); - bOutSum = radiusPlus1 * (pb = pixels[yi + 2]); - aOutSum = radiusPlus1 * (pa = pixels[yi + 3]); - rSum += sumFactor * pr; - gSum += sumFactor * pg; - bSum += sumFactor * pb; - aSum += sumFactor * pa; + for (var _x = 0; _x < width; _x++) { + yi = _x << 2; + + var _pr = pixels[yi], + _pg = pixels[yi + 1], + _pb = pixels[yi + 2], + _pa = pixels[yi + 3], + _rOutSum = radiusPlus1 * _pr, + _gOutSum = radiusPlus1 * _pg, + _bOutSum = radiusPlus1 * _pb, + _aOutSum = radiusPlus1 * _pa, + _rSum = sumFactor * _pr, + _gSum = sumFactor * _pg, + _bSum = sumFactor * _pb, + _aSum = sumFactor * _pa; + stack = stackStart; - for (i = 0; i < radiusPlus1; i++) { - stack.r = pr; - stack.g = pg; - stack.b = pb; - stack.a = pa; + for (var _i3 = 0; _i3 < radiusPlus1; _i3++) { + stack.r = _pr; + stack.g = _pg; + stack.b = _pb; + stack.a = _pa; stack = stack.next; } - yp = width; + var yp = width; + var _gInSum = 0, + _bInSum = 0, + _aInSum = 0, + _rInSum = 0; - for (i = 1; i <= radius; i++) { - yi = yp + x << 2; - rSum += (stack.r = pr = pixels[yi]) * (rbs = radiusPlus1 - i); - gSum += (stack.g = pg = pixels[yi + 1]) * rbs; - bSum += (stack.b = pb = pixels[yi + 2]) * rbs; - aSum += (stack.a = pa = pixels[yi + 3]) * rbs; - rInSum += pr; - gInSum += pg; - bInSum += pb; - aInSum += pa; + for (var _i4 = 1; _i4 <= radius; _i4++) { + yi = yp + _x << 2; + + var _rbs = radiusPlus1 - _i4; + + _rSum += (stack.r = _pr = pixels[yi]) * _rbs; + _gSum += (stack.g = _pg = pixels[yi + 1]) * _rbs; + _bSum += (stack.b = _pb = pixels[yi + 2]) * _rbs; + _aSum += (stack.a = _pa = pixels[yi + 3]) * _rbs; + _rInSum += _pr; + _gInSum += _pg; + _bInSum += _pb; + _aInSum += _pa; stack = stack.next; - if (i < heightMinus1) { + if (_i4 < heightMinus1) { yp += width; } } - yi = x; + yi = _x; stackIn = stackStart; stackOut = stackEnd; - for (y = 0; y < height; y++) { - p = yi << 2; - pixels[p + 3] = pa = aSum * mulSum >> shgSum; + for (var _y = 0; _y < height; _y++) { + var _p2 = yi << 2; - if (pa > 0) { - pa = 255 / pa; - pixels[p] = (rSum * mulSum >> shgSum) * pa; - pixels[p + 1] = (gSum * mulSum >> shgSum) * pa; - pixels[p + 2] = (bSum * mulSum >> shgSum) * pa; + pixels[_p2 + 3] = _pa = _aSum * mulSum >> shgSum; + + if (_pa > 0) { + _pa = 255 / _pa; + pixels[_p2] = (_rSum * mulSum >> shgSum) * _pa; + pixels[_p2 + 1] = (_gSum * mulSum >> shgSum) * _pa; + pixels[_p2 + 2] = (_bSum * mulSum >> shgSum) * _pa; } else { - pixels[p] = pixels[p + 1] = pixels[p + 2] = 0; + pixels[_p2] = pixels[_p2 + 1] = pixels[_p2 + 2] = 0; } - rSum -= rOutSum; - gSum -= gOutSum; - bSum -= bOutSum; - aSum -= aOutSum; - rOutSum -= stackIn.r; - gOutSum -= stackIn.g; - bOutSum -= stackIn.b; - aOutSum -= stackIn.a; - p = x + ((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width << 2; - rSum += rInSum += stackIn.r = pixels[p]; - gSum += gInSum += stackIn.g = pixels[p + 1]; - bSum += bInSum += stackIn.b = pixels[p + 2]; - aSum += aInSum += stackIn.a = pixels[p + 3]; + _rSum -= _rOutSum; + _gSum -= _gOutSum; + _bSum -= _bOutSum; + _aSum -= _aOutSum; + _rOutSum -= stackIn.r; + _gOutSum -= stackIn.g; + _bOutSum -= stackIn.b; + _aOutSum -= stackIn.a; + _p2 = _x + ((_p2 = _y + radiusPlus1) < heightMinus1 ? _p2 : heightMinus1) * width << 2; + _rSum += _rInSum += stackIn.r = pixels[_p2]; + _gSum += _gInSum += stackIn.g = pixels[_p2 + 1]; + _bSum += _bInSum += stackIn.b = pixels[_p2 + 2]; + _aSum += _aInSum += stackIn.a = pixels[_p2 + 3]; stackIn = stackIn.next; - rOutSum += pr = stackOut.r; - gOutSum += pg = stackOut.g; - bOutSum += pb = stackOut.b; - aOutSum += pa = stackOut.a; - rInSum -= pr; - gInSum -= pg; - bInSum -= pb; - aInSum -= pa; + _rOutSum += _pr = stackOut.r; + _gOutSum += _pg = stackOut.g; + _bOutSum += _pb = stackOut.b; + _aOutSum += _pa = stackOut.a; + _rInSum -= _pr; + _gInSum -= _pg; + _bInSum -= _pb; + _aInSum -= _pa; stackOut = stackOut.next; yi += width; } diff --git a/dist/editor/index.js.map b/dist/editor/index.js.map index bdac0002..446b4c9f 100644 --- a/dist/editor/index.js.map +++ b/dist/editor/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../../node_modules/core-js/internals/global.js","../../node_modules/core-js/internals/fails.js","../../node_modules/core-js/internals/descriptors.js","../../node_modules/core-js/internals/object-property-is-enumerable.js","../../node_modules/core-js/internals/create-property-descriptor.js","../../node_modules/core-js/internals/classof-raw.js","../../node_modules/core-js/internals/indexed-object.js","../../node_modules/core-js/internals/require-object-coercible.js","../../node_modules/core-js/internals/to-indexed-object.js","../../node_modules/core-js/internals/is-object.js","../../node_modules/core-js/internals/to-primitive.js","../../node_modules/core-js/internals/has.js","../../node_modules/core-js/internals/document-create-element.js","../../node_modules/core-js/internals/ie8-dom-define.js","../../node_modules/core-js/internals/object-get-own-property-descriptor.js","../../node_modules/core-js/internals/an-object.js","../../node_modules/core-js/internals/object-define-property.js","../../node_modules/core-js/internals/create-non-enumerable-property.js","../../node_modules/core-js/internals/set-global.js","../../node_modules/core-js/internals/shared-store.js","../../node_modules/core-js/internals/inspect-source.js","../../node_modules/core-js/internals/native-weak-map.js","../../node_modules/core-js/internals/is-pure.js","../../node_modules/core-js/internals/shared.js","../../node_modules/core-js/internals/uid.js","../../node_modules/core-js/internals/shared-key.js","../../node_modules/core-js/internals/hidden-keys.js","../../node_modules/core-js/internals/internal-state.js","../../node_modules/core-js/internals/redefine.js","../../node_modules/core-js/internals/path.js","../../node_modules/core-js/internals/get-built-in.js","../../node_modules/core-js/internals/to-integer.js","../../node_modules/core-js/internals/to-length.js","../../node_modules/core-js/internals/to-absolute-index.js","../../node_modules/core-js/internals/array-includes.js","../../node_modules/core-js/internals/object-keys-internal.js","../../node_modules/core-js/internals/enum-bug-keys.js","../../node_modules/core-js/internals/object-get-own-property-names.js","../../node_modules/core-js/internals/object-get-own-property-symbols.js","../../node_modules/core-js/internals/own-keys.js","../../node_modules/core-js/internals/copy-constructor-properties.js","../../node_modules/core-js/internals/is-forced.js","../../node_modules/core-js/internals/export.js","../../node_modules/core-js/internals/native-symbol.js","../../node_modules/core-js/internals/use-symbol-as-uid.js","../../node_modules/core-js/internals/is-array.js","../../node_modules/core-js/internals/to-object.js","../../node_modules/core-js/internals/object-keys.js","../../node_modules/core-js/internals/object-define-properties.js","../../node_modules/core-js/internals/html.js","../../node_modules/core-js/internals/object-create.js","../../node_modules/core-js/internals/object-get-own-property-names-external.js","../../node_modules/core-js/internals/well-known-symbol.js","../../node_modules/core-js/internals/well-known-symbol-wrapped.js","../../node_modules/core-js/internals/define-well-known-symbol.js","../../node_modules/core-js/internals/set-to-string-tag.js","../../node_modules/core-js/internals/a-function.js","../../node_modules/core-js/internals/function-bind-context.js","../../node_modules/core-js/internals/array-species-create.js","../../node_modules/core-js/internals/array-iteration.js","../../node_modules/core-js/modules/es.symbol.js","../../node_modules/core-js/modules/es.symbol.description.js","../../node_modules/core-js/modules/es.symbol.async-iterator.js","../../node_modules/core-js/modules/es.symbol.has-instance.js","../../node_modules/core-js/modules/es.symbol.is-concat-spreadable.js","../../node_modules/core-js/modules/es.symbol.iterator.js","../../node_modules/core-js/modules/es.symbol.match.js","../../node_modules/core-js/modules/es.symbol.match-all.js","../../node_modules/core-js/modules/es.symbol.replace.js","../../node_modules/core-js/modules/es.symbol.search.js","../../node_modules/core-js/modules/es.symbol.species.js","../../node_modules/core-js/modules/es.symbol.split.js","../../node_modules/core-js/modules/es.symbol.to-primitive.js","../../node_modules/core-js/modules/es.symbol.to-string-tag.js","../../node_modules/core-js/modules/es.symbol.unscopables.js","../../node_modules/core-js/internals/create-property.js","../../node_modules/core-js/internals/engine-user-agent.js","../../node_modules/core-js/internals/engine-v8-version.js","../../node_modules/core-js/internals/array-method-has-species-support.js","../../node_modules/core-js/modules/es.array.concat.js","../../node_modules/core-js/internals/array-copy-within.js","../../node_modules/core-js/internals/add-to-unscopables.js","../../node_modules/core-js/modules/es.array.copy-within.js","../../node_modules/core-js/internals/array-method-is-strict.js","../../node_modules/core-js/internals/array-method-uses-to-length.js","../../node_modules/core-js/modules/es.array.every.js","../../node_modules/core-js/internals/array-fill.js","../../node_modules/core-js/modules/es.array.fill.js","../../node_modules/core-js/modules/es.array.filter.js","../../node_modules/core-js/modules/es.array.find.js","../../node_modules/core-js/modules/es.array.find-index.js","../../node_modules/core-js/internals/flatten-into-array.js","../../node_modules/core-js/modules/es.array.flat.js","../../node_modules/core-js/modules/es.array.flat-map.js","../../node_modules/core-js/internals/array-for-each.js","../../node_modules/core-js/modules/es.array.for-each.js","../../node_modules/core-js/internals/call-with-safe-iteration-closing.js","../../node_modules/core-js/internals/iterators.js","../../node_modules/core-js/internals/is-array-iterator-method.js","../../node_modules/core-js/internals/to-string-tag-support.js","../../node_modules/core-js/internals/classof.js","../../node_modules/core-js/internals/get-iterator-method.js","../../node_modules/core-js/internals/array-from.js","../../node_modules/core-js/internals/check-correctness-of-iteration.js","../../node_modules/core-js/modules/es.array.from.js","../../node_modules/core-js/modules/es.array.includes.js","../../node_modules/core-js/modules/es.array.index-of.js","../../node_modules/core-js/modules/es.array.is-array.js","../../node_modules/core-js/internals/correct-prototype-getter.js","../../node_modules/core-js/internals/object-get-prototype-of.js","../../node_modules/core-js/internals/iterators-core.js","../../node_modules/core-js/internals/create-iterator-constructor.js","../../node_modules/core-js/internals/a-possible-prototype.js","../../node_modules/core-js/internals/object-set-prototype-of.js","../../node_modules/core-js/internals/define-iterator.js","../../node_modules/core-js/modules/es.array.iterator.js","../../node_modules/core-js/modules/es.array.join.js","../../node_modules/core-js/internals/array-last-index-of.js","../../node_modules/core-js/modules/es.array.last-index-of.js","../../node_modules/core-js/modules/es.array.map.js","../../node_modules/core-js/modules/es.array.of.js","../../node_modules/core-js/internals/array-reduce.js","../../node_modules/core-js/modules/es.array.reduce.js","../../node_modules/core-js/modules/es.array.reduce-right.js","../../node_modules/core-js/modules/es.array.reverse.js","../../node_modules/core-js/modules/es.array.slice.js","../../node_modules/core-js/modules/es.array.some.js","../../node_modules/core-js/modules/es.array.sort.js","../../node_modules/core-js/internals/set-species.js","../../node_modules/core-js/modules/es.array.species.js","../../node_modules/core-js/modules/es.array.splice.js","../../node_modules/core-js/modules/es.array.unscopables.flat.js","../../node_modules/core-js/modules/es.array.unscopables.flat-map.js","../../node_modules/core-js/internals/array-buffer-native.js","../../node_modules/core-js/internals/redefine-all.js","../../node_modules/core-js/internals/an-instance.js","../../node_modules/core-js/internals/to-index.js","../../node_modules/core-js/internals/ieee754.js","../../node_modules/core-js/internals/array-buffer.js","../../node_modules/core-js/modules/es.array-buffer.constructor.js","../../node_modules/core-js/internals/array-buffer-view-core.js","../../node_modules/core-js/modules/es.array-buffer.is-view.js","../../node_modules/core-js/internals/species-constructor.js","../../node_modules/core-js/modules/es.array-buffer.slice.js","../../node_modules/core-js/modules/es.data-view.js","../../node_modules/core-js/modules/es.date.now.js","../../node_modules/core-js/internals/string-repeat.js","../../node_modules/core-js/internals/string-pad.js","../../node_modules/core-js/internals/date-to-iso-string.js","../../node_modules/core-js/modules/es.date.to-iso-string.js","../../node_modules/core-js/modules/es.date.to-json.js","../../node_modules/core-js/internals/date-to-primitive.js","../../node_modules/core-js/modules/es.date.to-primitive.js","../../node_modules/core-js/modules/es.date.to-string.js","../../node_modules/core-js/internals/function-bind.js","../../node_modules/core-js/modules/es.function.bind.js","../../node_modules/core-js/modules/es.function.has-instance.js","../../node_modules/core-js/modules/es.function.name.js","../../node_modules/core-js/modules/es.global-this.js","../../node_modules/core-js/modules/es.json.stringify.js","../../node_modules/core-js/modules/es.json.to-string-tag.js","../../node_modules/core-js/internals/freezing.js","../../node_modules/core-js/internals/internal-metadata.js","../../node_modules/core-js/internals/iterate.js","../../node_modules/core-js/internals/inherit-if-required.js","../../node_modules/core-js/internals/collection.js","../../node_modules/core-js/internals/collection-strong.js","../../node_modules/core-js/modules/es.map.js","../../node_modules/core-js/internals/math-log1p.js","../../node_modules/core-js/modules/es.math.acosh.js","../../node_modules/core-js/modules/es.math.asinh.js","../../node_modules/core-js/modules/es.math.atanh.js","../../node_modules/core-js/internals/math-sign.js","../../node_modules/core-js/modules/es.math.cbrt.js","../../node_modules/core-js/modules/es.math.clz32.js","../../node_modules/core-js/internals/math-expm1.js","../../node_modules/core-js/modules/es.math.cosh.js","../../node_modules/core-js/modules/es.math.expm1.js","../../node_modules/core-js/internals/math-fround.js","../../node_modules/core-js/modules/es.math.fround.js","../../node_modules/core-js/modules/es.math.hypot.js","../../node_modules/core-js/modules/es.math.imul.js","../../node_modules/core-js/modules/es.math.log10.js","../../node_modules/core-js/modules/es.math.log1p.js","../../node_modules/core-js/modules/es.math.log2.js","../../node_modules/core-js/modules/es.math.sign.js","../../node_modules/core-js/modules/es.math.sinh.js","../../node_modules/core-js/modules/es.math.tanh.js","../../node_modules/core-js/modules/es.math.to-string-tag.js","../../node_modules/core-js/modules/es.math.trunc.js","../../node_modules/core-js/internals/whitespaces.js","../../node_modules/core-js/internals/string-trim.js","../../node_modules/core-js/modules/es.number.constructor.js","../../node_modules/core-js/modules/es.number.epsilon.js","../../node_modules/core-js/internals/number-is-finite.js","../../node_modules/core-js/modules/es.number.is-finite.js","../../node_modules/core-js/internals/is-integer.js","../../node_modules/core-js/modules/es.number.is-integer.js","../../node_modules/core-js/modules/es.number.is-nan.js","../../node_modules/core-js/modules/es.number.is-safe-integer.js","../../node_modules/core-js/modules/es.number.max-safe-integer.js","../../node_modules/core-js/modules/es.number.min-safe-integer.js","../../node_modules/core-js/internals/number-parse-float.js","../../node_modules/core-js/modules/es.number.parse-float.js","../../node_modules/core-js/internals/number-parse-int.js","../../node_modules/core-js/modules/es.number.parse-int.js","../../node_modules/core-js/internals/this-number-value.js","../../node_modules/core-js/modules/es.number.to-fixed.js","../../node_modules/core-js/modules/es.number.to-precision.js","../../node_modules/core-js/internals/object-assign.js","../../node_modules/core-js/modules/es.object.assign.js","../../node_modules/core-js/modules/es.object.create.js","../../node_modules/core-js/internals/object-prototype-accessors-forced.js","../../node_modules/core-js/modules/es.object.define-getter.js","../../node_modules/core-js/modules/es.object.define-properties.js","../../node_modules/core-js/modules/es.object.define-property.js","../../node_modules/core-js/modules/es.object.define-setter.js","../../node_modules/core-js/internals/object-to-array.js","../../node_modules/core-js/modules/es.object.entries.js","../../node_modules/core-js/modules/es.object.freeze.js","../../node_modules/core-js/modules/es.object.from-entries.js","../../node_modules/core-js/modules/es.object.get-own-property-descriptor.js","../../node_modules/core-js/modules/es.object.get-own-property-descriptors.js","../../node_modules/core-js/modules/es.object.get-own-property-names.js","../../node_modules/core-js/modules/es.object.get-prototype-of.js","../../node_modules/core-js/internals/same-value.js","../../node_modules/core-js/modules/es.object.is.js","../../node_modules/core-js/modules/es.object.is-extensible.js","../../node_modules/core-js/modules/es.object.is-frozen.js","../../node_modules/core-js/modules/es.object.is-sealed.js","../../node_modules/core-js/modules/es.object.keys.js","../../node_modules/core-js/modules/es.object.lookup-getter.js","../../node_modules/core-js/modules/es.object.lookup-setter.js","../../node_modules/core-js/modules/es.object.prevent-extensions.js","../../node_modules/core-js/modules/es.object.seal.js","../../node_modules/core-js/modules/es.object.set-prototype-of.js","../../node_modules/core-js/internals/object-to-string.js","../../node_modules/core-js/modules/es.object.to-string.js","../../node_modules/core-js/modules/es.object.values.js","../../node_modules/core-js/modules/es.parse-float.js","../../node_modules/core-js/modules/es.parse-int.js","../../node_modules/core-js/internals/native-promise-constructor.js","../../node_modules/core-js/internals/engine-is-ios.js","../../node_modules/core-js/internals/task.js","../../node_modules/core-js/internals/microtask.js","../../node_modules/core-js/internals/new-promise-capability.js","../../node_modules/core-js/internals/promise-resolve.js","../../node_modules/core-js/internals/host-report-errors.js","../../node_modules/core-js/internals/perform.js","../../node_modules/core-js/modules/es.promise.js","../../node_modules/core-js/modules/es.promise.all-settled.js","../../node_modules/core-js/modules/es.promise.finally.js","../../node_modules/core-js/modules/es.reflect.apply.js","../../node_modules/core-js/modules/es.reflect.construct.js","../../node_modules/core-js/modules/es.reflect.define-property.js","../../node_modules/core-js/modules/es.reflect.delete-property.js","../../node_modules/core-js/modules/es.reflect.get.js","../../node_modules/core-js/modules/es.reflect.get-own-property-descriptor.js","../../node_modules/core-js/modules/es.reflect.get-prototype-of.js","../../node_modules/core-js/modules/es.reflect.has.js","../../node_modules/core-js/modules/es.reflect.is-extensible.js","../../node_modules/core-js/modules/es.reflect.own-keys.js","../../node_modules/core-js/modules/es.reflect.prevent-extensions.js","../../node_modules/core-js/modules/es.reflect.set.js","../../node_modules/core-js/modules/es.reflect.set-prototype-of.js","../../node_modules/core-js/internals/is-regexp.js","../../node_modules/core-js/internals/regexp-flags.js","../../node_modules/core-js/internals/regexp-sticky-helpers.js","../../node_modules/core-js/modules/es.regexp.constructor.js","../../node_modules/core-js/internals/regexp-exec.js","../../node_modules/core-js/modules/es.regexp.exec.js","../../node_modules/core-js/modules/es.regexp.flags.js","../../node_modules/core-js/modules/es.regexp.sticky.js","../../node_modules/core-js/modules/es.regexp.test.js","../../node_modules/core-js/modules/es.regexp.to-string.js","../../node_modules/core-js/modules/es.set.js","../../node_modules/core-js/internals/string-multibyte.js","../../node_modules/core-js/modules/es.string.code-point-at.js","../../node_modules/core-js/internals/not-a-regexp.js","../../node_modules/core-js/internals/correct-is-regexp-logic.js","../../node_modules/core-js/modules/es.string.ends-with.js","../../node_modules/core-js/modules/es.string.from-code-point.js","../../node_modules/core-js/modules/es.string.includes.js","../../node_modules/core-js/modules/es.string.iterator.js","../../node_modules/core-js/internals/fix-regexp-well-known-symbol-logic.js","../../node_modules/core-js/internals/advance-string-index.js","../../node_modules/core-js/internals/regexp-exec-abstract.js","../../node_modules/core-js/modules/es.string.match.js","../../node_modules/core-js/modules/es.string.match-all.js","../../node_modules/core-js/internals/string-pad-webkit-bug.js","../../node_modules/core-js/modules/es.string.pad-end.js","../../node_modules/core-js/modules/es.string.pad-start.js","../../node_modules/core-js/modules/es.string.raw.js","../../node_modules/core-js/modules/es.string.repeat.js","../../node_modules/core-js/modules/es.string.replace.js","../../node_modules/core-js/modules/es.string.search.js","../../node_modules/core-js/modules/es.string.split.js","../../node_modules/core-js/modules/es.string.starts-with.js","../../node_modules/core-js/internals/string-trim-forced.js","../../node_modules/core-js/modules/es.string.trim.js","../../node_modules/core-js/modules/es.string.trim-end.js","../../node_modules/core-js/modules/es.string.trim-start.js","../../node_modules/core-js/internals/create-html.js","../../node_modules/core-js/internals/string-html-forced.js","../../node_modules/core-js/modules/es.string.anchor.js","../../node_modules/core-js/modules/es.string.big.js","../../node_modules/core-js/modules/es.string.blink.js","../../node_modules/core-js/modules/es.string.bold.js","../../node_modules/core-js/modules/es.string.fixed.js","../../node_modules/core-js/modules/es.string.fontcolor.js","../../node_modules/core-js/modules/es.string.fontsize.js","../../node_modules/core-js/modules/es.string.italics.js","../../node_modules/core-js/modules/es.string.link.js","../../node_modules/core-js/modules/es.string.small.js","../../node_modules/core-js/modules/es.string.strike.js","../../node_modules/core-js/modules/es.string.sub.js","../../node_modules/core-js/modules/es.string.sup.js","../../node_modules/core-js/internals/typed-array-constructors-require-wrappers.js","../../node_modules/core-js/internals/to-positive-integer.js","../../node_modules/core-js/internals/to-offset.js","../../node_modules/core-js/internals/typed-array-from.js","../../node_modules/core-js/internals/typed-array-constructor.js","../../node_modules/core-js/modules/es.typed-array.float32-array.js","../../node_modules/core-js/modules/es.typed-array.float64-array.js","../../node_modules/core-js/modules/es.typed-array.int8-array.js","../../node_modules/core-js/modules/es.typed-array.int16-array.js","../../node_modules/core-js/modules/es.typed-array.int32-array.js","../../node_modules/core-js/modules/es.typed-array.uint8-array.js","../../node_modules/core-js/modules/es.typed-array.uint8-clamped-array.js","../../node_modules/core-js/modules/es.typed-array.uint16-array.js","../../node_modules/core-js/modules/es.typed-array.uint32-array.js","../../node_modules/core-js/modules/es.typed-array.copy-within.js","../../node_modules/core-js/modules/es.typed-array.every.js","../../node_modules/core-js/modules/es.typed-array.fill.js","../../node_modules/core-js/modules/es.typed-array.filter.js","../../node_modules/core-js/modules/es.typed-array.find.js","../../node_modules/core-js/modules/es.typed-array.find-index.js","../../node_modules/core-js/modules/es.typed-array.for-each.js","../../node_modules/core-js/modules/es.typed-array.from.js","../../node_modules/core-js/modules/es.typed-array.includes.js","../../node_modules/core-js/modules/es.typed-array.index-of.js","../../node_modules/core-js/modules/es.typed-array.iterator.js","../../node_modules/core-js/modules/es.typed-array.join.js","../../node_modules/core-js/modules/es.typed-array.last-index-of.js","../../node_modules/core-js/modules/es.typed-array.map.js","../../node_modules/core-js/modules/es.typed-array.of.js","../../node_modules/core-js/modules/es.typed-array.reduce.js","../../node_modules/core-js/modules/es.typed-array.reduce-right.js","../../node_modules/core-js/modules/es.typed-array.reverse.js","../../node_modules/core-js/modules/es.typed-array.set.js","../../node_modules/core-js/modules/es.typed-array.slice.js","../../node_modules/core-js/modules/es.typed-array.some.js","../../node_modules/core-js/modules/es.typed-array.sort.js","../../node_modules/core-js/modules/es.typed-array.subarray.js","../../node_modules/core-js/modules/es.typed-array.to-locale-string.js","../../node_modules/core-js/modules/es.typed-array.to-string.js","../../node_modules/core-js/internals/collection-weak.js","../../node_modules/core-js/modules/es.weak-map.js","../../node_modules/core-js/modules/es.weak-set.js","../../node_modules/core-js/internals/dom-iterables.js","../../node_modules/core-js/modules/web.dom-collections.for-each.js","../../node_modules/core-js/modules/web.dom-collections.iterator.js","../../node_modules/core-js/modules/web.immediate.js","../../node_modules/core-js/modules/web.queue-microtask.js","../../node_modules/core-js/internals/native-url.js","../../node_modules/core-js/internals/string-punycode-to-ascii.js","../../node_modules/core-js/internals/get-iterator.js","../../node_modules/core-js/modules/web.url-search-params.js","../../node_modules/core-js/modules/web.url.js","../../node_modules/core-js/modules/web.url.to-json.js","../../node_modules/regenerator-runtime/runtime.js","../../src/editor/touch.js","../../src/common/namespaces.js","../../src/common/svgpathseg.js","../../src/common/browser.js","../../src/common/jQuery.attr.js","../../src/common/svgtransformlist.js","../../src/common/units.js","../../src/common/math.js","../../src/common/utilities.js","../../src/editor/contextmenu.js","../../src/external/deparam/deparam.esm.js","../../node_modules/rollup-plugin-node-polyfills/polyfills/global.js","../../node_modules/jspdf/dist/jspdf.es.min.js","../../node_modules/cssesc/cssesc.js","../../node_modules/font-family-papandreou/index.js","../../node_modules/svgpath/lib/path_parse.js","../../node_modules/svgpath/lib/matrix.js","../../node_modules/svgpath/lib/transform_parse.js","../../node_modules/svgpath/lib/a2c.js","../../node_modules/svgpath/lib/ellipse.js","../../node_modules/svgpath/lib/svgpath.js","../../node_modules/svgpath/index.js","../../node_modules/specificity/dist/specificity.mjs","../../node_modules/svg2pdf.js/dist/svg2pdf.es.js","../../src/external/canvg/rgbcolor.js","../../src/external/stackblur-canvas/dist/stackblur-es.js","../../src/external/canvg/canvg.js","../../src/svgcanvas/dbox.js","../../src/svgcanvas/history.js","../../src/svgcanvas/path.js","../../src/common/layer.js","../../src/svgcanvas/historyrecording.js","../../src/svgcanvas/copy-elem.js","../../src/svgcanvas/draw.js","../../src/svgcanvas/sanitize.js","../../src/svgcanvas/coords.js","../../src/svgcanvas/recalculate.js","../../src/svgcanvas/select.js","../../src/svgcanvas/svgcanvas.js","../../src/editor/js-hotkeys/jquery.hotkeys.min.js","../../src/editor/svgicons/jQuery.svgIcons.js","../../src/editor/jgraduate/jQuery.jGraduate.js","../../src/editor/spinbtn/jQuery.SpinButton.js","../../src/editor/contextmenu/jQuery.contextMenu.js","../../src/editor/jgraduate/jQuery.jPicker.js","../../src/editor/locale/locale.js","../../src/editor/svgedit.js","../../src/editor/index.js","../../node_modules/html2canvas/dist/html2canvas.js","../../node_modules/dompurify/dist/purify.js","../../node_modules/rollup-plugin-node-polyfills/polyfills/process-es6.js","../../node_modules/@babel/runtime/helpers/arrayWithHoles.js","../../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js","../../node_modules/@babel/runtime/helpers/arrayLikeToArray.js","../../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js","../../node_modules/@babel/runtime/helpers/nonIterableRest.js","../../node_modules/@babel/runtime/helpers/slicedToArray.js","../../node_modules/@babel/runtime/regenerator/index.js","../../node_modules/@babel/runtime/helpers/asyncToGenerator.js","../../node_modules/@babel/runtime/helpers/defineProperty.js","../../node_modules/@babel/runtime/helpers/classCallCheck.js","../../node_modules/@babel/runtime/helpers/createClass.js","../../node_modules/performance-now/lib/performance-now.js","../../node_modules/raf/index.js","../../node_modules/rgbcolor/index.js","../../node_modules/@babel/runtime/helpers/typeof.js","../../node_modules/@babel/runtime/helpers/assertThisInitialized.js","../../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js","../../node_modules/@babel/runtime/helpers/getPrototypeOf.js","../../node_modules/@babel/runtime/helpers/setPrototypeOf.js","../../node_modules/@babel/runtime/helpers/inherits.js","../../node_modules/@babel/runtime/helpers/arrayWithoutHoles.js","../../node_modules/@babel/runtime/helpers/iterableToArray.js","../../node_modules/@babel/runtime/helpers/nonIterableSpread.js","../../node_modules/@babel/runtime/helpers/toConsumableArray.js","../../node_modules/@babel/runtime/helpers/superPropBase.js","../../node_modules/@babel/runtime/helpers/get.js","../../node_modules/stackblur-canvas/dist/stackblur-es.js","../../node_modules/canvg/lib/index.es.js"],"sourcesContent":["var check = function (it) {\n return it && it.Math == Math && it;\n};\n\n// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028\nmodule.exports =\n // eslint-disable-next-line no-undef\n check(typeof globalThis == 'object' && globalThis) ||\n check(typeof window == 'object' && window) ||\n check(typeof self == 'object' && self) ||\n check(typeof global == 'object' && global) ||\n // eslint-disable-next-line no-new-func\n Function('return this')();\n","module.exports = function (exec) {\n try {\n return !!exec();\n } catch (error) {\n return true;\n }\n};\n","var fails = require('../internals/fails');\n\n// Thank's IE8 for his funny defineProperty\nmodule.exports = !fails(function () {\n return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;\n});\n","'use strict';\nvar nativePropertyIsEnumerable = {}.propertyIsEnumerable;\nvar getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\n\n// Nashorn ~ JDK8 bug\nvar NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);\n\n// `Object.prototype.propertyIsEnumerable` method implementation\n// https://tc39.github.io/ecma262/#sec-object.prototype.propertyisenumerable\nexports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {\n var descriptor = getOwnPropertyDescriptor(this, V);\n return !!descriptor && descriptor.enumerable;\n} : nativePropertyIsEnumerable;\n","module.exports = function (bitmap, value) {\n return {\n enumerable: !(bitmap & 1),\n configurable: !(bitmap & 2),\n writable: !(bitmap & 4),\n value: value\n };\n};\n","var toString = {}.toString;\n\nmodule.exports = function (it) {\n return toString.call(it).slice(8, -1);\n};\n","var fails = require('../internals/fails');\nvar classof = require('../internals/classof-raw');\n\nvar split = ''.split;\n\n// fallback for non-array-like ES3 and non-enumerable old V8 strings\nmodule.exports = fails(function () {\n // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346\n // eslint-disable-next-line no-prototype-builtins\n return !Object('z').propertyIsEnumerable(0);\n}) ? function (it) {\n return classof(it) == 'String' ? split.call(it, '') : Object(it);\n} : Object;\n","// `RequireObjectCoercible` abstract operation\n// https://tc39.github.io/ecma262/#sec-requireobjectcoercible\nmodule.exports = function (it) {\n if (it == undefined) throw TypeError(\"Can't call method on \" + it);\n return it;\n};\n","// toObject with fallback for non-array-like ES3 strings\nvar IndexedObject = require('../internals/indexed-object');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\n\nmodule.exports = function (it) {\n return IndexedObject(requireObjectCoercible(it));\n};\n","module.exports = function (it) {\n return typeof it === 'object' ? it !== null : typeof it === 'function';\n};\n","var isObject = require('../internals/is-object');\n\n// `ToPrimitive` abstract operation\n// https://tc39.github.io/ecma262/#sec-toprimitive\n// instead of the ES6 spec version, we didn't implement @@toPrimitive case\n// and the second argument - flag - preferred type is a string\nmodule.exports = function (input, PREFERRED_STRING) {\n if (!isObject(input)) return input;\n var fn, val;\n if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;\n if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;\n if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;\n throw TypeError(\"Can't convert object to primitive value\");\n};\n","var hasOwnProperty = {}.hasOwnProperty;\n\nmodule.exports = function (it, key) {\n return hasOwnProperty.call(it, key);\n};\n","var global = require('../internals/global');\nvar isObject = require('../internals/is-object');\n\nvar document = global.document;\n// typeof document.createElement is 'object' in old IE\nvar EXISTS = isObject(document) && isObject(document.createElement);\n\nmodule.exports = function (it) {\n return EXISTS ? document.createElement(it) : {};\n};\n","var DESCRIPTORS = require('../internals/descriptors');\nvar fails = require('../internals/fails');\nvar createElement = require('../internals/document-create-element');\n\n// Thank's IE8 for his funny defineProperty\nmodule.exports = !DESCRIPTORS && !fails(function () {\n return Object.defineProperty(createElement('div'), 'a', {\n get: function () { return 7; }\n }).a != 7;\n});\n","var DESCRIPTORS = require('../internals/descriptors');\nvar propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar toPrimitive = require('../internals/to-primitive');\nvar has = require('../internals/has');\nvar IE8_DOM_DEFINE = require('../internals/ie8-dom-define');\n\nvar nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\n\n// `Object.getOwnPropertyDescriptor` method\n// https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor\nexports.f = DESCRIPTORS ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {\n O = toIndexedObject(O);\n P = toPrimitive(P, true);\n if (IE8_DOM_DEFINE) try {\n return nativeGetOwnPropertyDescriptor(O, P);\n } catch (error) { /* empty */ }\n if (has(O, P)) return createPropertyDescriptor(!propertyIsEnumerableModule.f.call(O, P), O[P]);\n};\n","var isObject = require('../internals/is-object');\n\nmodule.exports = function (it) {\n if (!isObject(it)) {\n throw TypeError(String(it) + ' is not an object');\n } return it;\n};\n","var DESCRIPTORS = require('../internals/descriptors');\nvar IE8_DOM_DEFINE = require('../internals/ie8-dom-define');\nvar anObject = require('../internals/an-object');\nvar toPrimitive = require('../internals/to-primitive');\n\nvar nativeDefineProperty = Object.defineProperty;\n\n// `Object.defineProperty` method\n// https://tc39.github.io/ecma262/#sec-object.defineproperty\nexports.f = DESCRIPTORS ? nativeDefineProperty : function defineProperty(O, P, Attributes) {\n anObject(O);\n P = toPrimitive(P, true);\n anObject(Attributes);\n if (IE8_DOM_DEFINE) try {\n return nativeDefineProperty(O, P, Attributes);\n } catch (error) { /* empty */ }\n if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');\n if ('value' in Attributes) O[P] = Attributes.value;\n return O;\n};\n","var DESCRIPTORS = require('../internals/descriptors');\nvar definePropertyModule = require('../internals/object-define-property');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\n\nmodule.exports = DESCRIPTORS ? function (object, key, value) {\n return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));\n} : function (object, key, value) {\n object[key] = value;\n return object;\n};\n","var global = require('../internals/global');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\n\nmodule.exports = function (key, value) {\n try {\n createNonEnumerableProperty(global, key, value);\n } catch (error) {\n global[key] = value;\n } return value;\n};\n","var global = require('../internals/global');\nvar setGlobal = require('../internals/set-global');\n\nvar SHARED = '__core-js_shared__';\nvar store = global[SHARED] || setGlobal(SHARED, {});\n\nmodule.exports = store;\n","var store = require('../internals/shared-store');\n\nvar functionToString = Function.toString;\n\n// this helper broken in `3.4.1-3.4.4`, so we can't use `shared` helper\nif (typeof store.inspectSource != 'function') {\n store.inspectSource = function (it) {\n return functionToString.call(it);\n };\n}\n\nmodule.exports = store.inspectSource;\n","var global = require('../internals/global');\nvar inspectSource = require('../internals/inspect-source');\n\nvar WeakMap = global.WeakMap;\n\nmodule.exports = typeof WeakMap === 'function' && /native code/.test(inspectSource(WeakMap));\n","module.exports = false;\n","var IS_PURE = require('../internals/is-pure');\nvar store = require('../internals/shared-store');\n\n(module.exports = function (key, value) {\n return store[key] || (store[key] = value !== undefined ? value : {});\n})('versions', []).push({\n version: '3.6.5',\n mode: IS_PURE ? 'pure' : 'global',\n copyright: '© 2020 Denis Pushkarev (zloirock.ru)'\n});\n","var id = 0;\nvar postfix = Math.random();\n\nmodule.exports = function (key) {\n return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);\n};\n","var shared = require('../internals/shared');\nvar uid = require('../internals/uid');\n\nvar keys = shared('keys');\n\nmodule.exports = function (key) {\n return keys[key] || (keys[key] = uid(key));\n};\n","module.exports = {};\n","var NATIVE_WEAK_MAP = require('../internals/native-weak-map');\nvar global = require('../internals/global');\nvar isObject = require('../internals/is-object');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar objectHas = require('../internals/has');\nvar sharedKey = require('../internals/shared-key');\nvar hiddenKeys = require('../internals/hidden-keys');\n\nvar WeakMap = global.WeakMap;\nvar set, get, has;\n\nvar enforce = function (it) {\n return has(it) ? get(it) : set(it, {});\n};\n\nvar getterFor = function (TYPE) {\n return function (it) {\n var state;\n if (!isObject(it) || (state = get(it)).type !== TYPE) {\n throw TypeError('Incompatible receiver, ' + TYPE + ' required');\n } return state;\n };\n};\n\nif (NATIVE_WEAK_MAP) {\n var store = new WeakMap();\n var wmget = store.get;\n var wmhas = store.has;\n var wmset = store.set;\n set = function (it, metadata) {\n wmset.call(store, it, metadata);\n return metadata;\n };\n get = function (it) {\n return wmget.call(store, it) || {};\n };\n has = function (it) {\n return wmhas.call(store, it);\n };\n} else {\n var STATE = sharedKey('state');\n hiddenKeys[STATE] = true;\n set = function (it, metadata) {\n createNonEnumerableProperty(it, STATE, metadata);\n return metadata;\n };\n get = function (it) {\n return objectHas(it, STATE) ? it[STATE] : {};\n };\n has = function (it) {\n return objectHas(it, STATE);\n };\n}\n\nmodule.exports = {\n set: set,\n get: get,\n has: has,\n enforce: enforce,\n getterFor: getterFor\n};\n","var global = require('../internals/global');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar has = require('../internals/has');\nvar setGlobal = require('../internals/set-global');\nvar inspectSource = require('../internals/inspect-source');\nvar InternalStateModule = require('../internals/internal-state');\n\nvar getInternalState = InternalStateModule.get;\nvar enforceInternalState = InternalStateModule.enforce;\nvar TEMPLATE = String(String).split('String');\n\n(module.exports = function (O, key, value, options) {\n var unsafe = options ? !!options.unsafe : false;\n var simple = options ? !!options.enumerable : false;\n var noTargetGet = options ? !!options.noTargetGet : false;\n if (typeof value == 'function') {\n if (typeof key == 'string' && !has(value, 'name')) createNonEnumerableProperty(value, 'name', key);\n enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');\n }\n if (O === global) {\n if (simple) O[key] = value;\n else setGlobal(key, value);\n return;\n } else if (!unsafe) {\n delete O[key];\n } else if (!noTargetGet && O[key]) {\n simple = true;\n }\n if (simple) O[key] = value;\n else createNonEnumerableProperty(O, key, value);\n// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative\n})(Function.prototype, 'toString', function toString() {\n return typeof this == 'function' && getInternalState(this).source || inspectSource(this);\n});\n","var global = require('../internals/global');\n\nmodule.exports = global;\n","var path = require('../internals/path');\nvar global = require('../internals/global');\n\nvar aFunction = function (variable) {\n return typeof variable == 'function' ? variable : undefined;\n};\n\nmodule.exports = function (namespace, method) {\n return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace])\n : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];\n};\n","var ceil = Math.ceil;\nvar floor = Math.floor;\n\n// `ToInteger` abstract operation\n// https://tc39.github.io/ecma262/#sec-tointeger\nmodule.exports = function (argument) {\n return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);\n};\n","var toInteger = require('../internals/to-integer');\n\nvar min = Math.min;\n\n// `ToLength` abstract operation\n// https://tc39.github.io/ecma262/#sec-tolength\nmodule.exports = function (argument) {\n return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991\n};\n","var toInteger = require('../internals/to-integer');\n\nvar max = Math.max;\nvar min = Math.min;\n\n// Helper for a popular repeating case of the spec:\n// Let integer be ? ToInteger(index).\n// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).\nmodule.exports = function (index, length) {\n var integer = toInteger(index);\n return integer < 0 ? max(integer + length, 0) : min(integer, length);\n};\n","var toIndexedObject = require('../internals/to-indexed-object');\nvar toLength = require('../internals/to-length');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\n\n// `Array.prototype.{ indexOf, includes }` methods implementation\nvar createMethod = function (IS_INCLUDES) {\n return function ($this, el, fromIndex) {\n var O = toIndexedObject($this);\n var length = toLength(O.length);\n var index = toAbsoluteIndex(fromIndex, length);\n var value;\n // Array#includes uses SameValueZero equality algorithm\n // eslint-disable-next-line no-self-compare\n if (IS_INCLUDES && el != el) while (length > index) {\n value = O[index++];\n // eslint-disable-next-line no-self-compare\n if (value != value) return true;\n // Array#indexOf ignores holes, Array#includes - not\n } else for (;length > index; index++) {\n if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;\n } return !IS_INCLUDES && -1;\n };\n};\n\nmodule.exports = {\n // `Array.prototype.includes` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.includes\n includes: createMethod(true),\n // `Array.prototype.indexOf` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.indexof\n indexOf: createMethod(false)\n};\n","var has = require('../internals/has');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar indexOf = require('../internals/array-includes').indexOf;\nvar hiddenKeys = require('../internals/hidden-keys');\n\nmodule.exports = function (object, names) {\n var O = toIndexedObject(object);\n var i = 0;\n var result = [];\n var key;\n for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);\n // Don't enum bug & hidden keys\n while (names.length > i) if (has(O, key = names[i++])) {\n ~indexOf(result, key) || result.push(key);\n }\n return result;\n};\n","// IE8- don't enum bug keys\nmodule.exports = [\n 'constructor',\n 'hasOwnProperty',\n 'isPrototypeOf',\n 'propertyIsEnumerable',\n 'toLocaleString',\n 'toString',\n 'valueOf'\n];\n","var internalObjectKeys = require('../internals/object-keys-internal');\nvar enumBugKeys = require('../internals/enum-bug-keys');\n\nvar hiddenKeys = enumBugKeys.concat('length', 'prototype');\n\n// `Object.getOwnPropertyNames` method\n// https://tc39.github.io/ecma262/#sec-object.getownpropertynames\nexports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {\n return internalObjectKeys(O, hiddenKeys);\n};\n","exports.f = Object.getOwnPropertySymbols;\n","var getBuiltIn = require('../internals/get-built-in');\nvar getOwnPropertyNamesModule = require('../internals/object-get-own-property-names');\nvar getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');\nvar anObject = require('../internals/an-object');\n\n// all object keys, includes non-enumerable and symbols\nmodule.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {\n var keys = getOwnPropertyNamesModule.f(anObject(it));\n var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;\n return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;\n};\n","var has = require('../internals/has');\nvar ownKeys = require('../internals/own-keys');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\nvar definePropertyModule = require('../internals/object-define-property');\n\nmodule.exports = function (target, source) {\n var keys = ownKeys(source);\n var defineProperty = definePropertyModule.f;\n var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));\n }\n};\n","var fails = require('../internals/fails');\n\nvar replacement = /#|\\.prototype\\./;\n\nvar isForced = function (feature, detection) {\n var value = data[normalize(feature)];\n return value == POLYFILL ? true\n : value == NATIVE ? false\n : typeof detection == 'function' ? fails(detection)\n : !!detection;\n};\n\nvar normalize = isForced.normalize = function (string) {\n return String(string).replace(replacement, '.').toLowerCase();\n};\n\nvar data = isForced.data = {};\nvar NATIVE = isForced.NATIVE = 'N';\nvar POLYFILL = isForced.POLYFILL = 'P';\n\nmodule.exports = isForced;\n","var global = require('../internals/global');\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar redefine = require('../internals/redefine');\nvar setGlobal = require('../internals/set-global');\nvar copyConstructorProperties = require('../internals/copy-constructor-properties');\nvar isForced = require('../internals/is-forced');\n\n/*\n options.target - name of the target object\n options.global - target is the global object\n options.stat - export as static methods of target\n options.proto - export as prototype methods of target\n options.real - real prototype method for the `pure` version\n options.forced - export even if the native feature is available\n options.bind - bind methods to the target, required for the `pure` version\n options.wrap - wrap constructors to preventing global pollution, required for the `pure` version\n options.unsafe - use the simple assignment of property instead of delete + defineProperty\n options.sham - add a flag to not completely full polyfills\n options.enumerable - export as enumerable property\n options.noTargetGet - prevent calling a getter on target\n*/\nmodule.exports = function (options, source) {\n var TARGET = options.target;\n var GLOBAL = options.global;\n var STATIC = options.stat;\n var FORCED, target, key, targetProperty, sourceProperty, descriptor;\n if (GLOBAL) {\n target = global;\n } else if (STATIC) {\n target = global[TARGET] || setGlobal(TARGET, {});\n } else {\n target = (global[TARGET] || {}).prototype;\n }\n if (target) for (key in source) {\n sourceProperty = source[key];\n if (options.noTargetGet) {\n descriptor = getOwnPropertyDescriptor(target, key);\n targetProperty = descriptor && descriptor.value;\n } else targetProperty = target[key];\n FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);\n // contained in target\n if (!FORCED && targetProperty !== undefined) {\n if (typeof sourceProperty === typeof targetProperty) continue;\n copyConstructorProperties(sourceProperty, targetProperty);\n }\n // add a flag to not completely full polyfills\n if (options.sham || (targetProperty && targetProperty.sham)) {\n createNonEnumerableProperty(sourceProperty, 'sham', true);\n }\n // extend global\n redefine(target, key, sourceProperty, options);\n }\n};\n","var fails = require('../internals/fails');\n\nmodule.exports = !!Object.getOwnPropertySymbols && !fails(function () {\n // Chrome 38 Symbol has incorrect toString conversion\n // eslint-disable-next-line no-undef\n return !String(Symbol());\n});\n","var NATIVE_SYMBOL = require('../internals/native-symbol');\n\nmodule.exports = NATIVE_SYMBOL\n // eslint-disable-next-line no-undef\n && !Symbol.sham\n // eslint-disable-next-line no-undef\n && typeof Symbol.iterator == 'symbol';\n","var classof = require('../internals/classof-raw');\n\n// `IsArray` abstract operation\n// https://tc39.github.io/ecma262/#sec-isarray\nmodule.exports = Array.isArray || function isArray(arg) {\n return classof(arg) == 'Array';\n};\n","var requireObjectCoercible = require('../internals/require-object-coercible');\n\n// `ToObject` abstract operation\n// https://tc39.github.io/ecma262/#sec-toobject\nmodule.exports = function (argument) {\n return Object(requireObjectCoercible(argument));\n};\n","var internalObjectKeys = require('../internals/object-keys-internal');\nvar enumBugKeys = require('../internals/enum-bug-keys');\n\n// `Object.keys` method\n// https://tc39.github.io/ecma262/#sec-object.keys\nmodule.exports = Object.keys || function keys(O) {\n return internalObjectKeys(O, enumBugKeys);\n};\n","var DESCRIPTORS = require('../internals/descriptors');\nvar definePropertyModule = require('../internals/object-define-property');\nvar anObject = require('../internals/an-object');\nvar objectKeys = require('../internals/object-keys');\n\n// `Object.defineProperties` method\n// https://tc39.github.io/ecma262/#sec-object.defineproperties\nmodule.exports = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {\n anObject(O);\n var keys = objectKeys(Properties);\n var length = keys.length;\n var index = 0;\n var key;\n while (length > index) definePropertyModule.f(O, key = keys[index++], Properties[key]);\n return O;\n};\n","var getBuiltIn = require('../internals/get-built-in');\n\nmodule.exports = getBuiltIn('document', 'documentElement');\n","var anObject = require('../internals/an-object');\nvar defineProperties = require('../internals/object-define-properties');\nvar enumBugKeys = require('../internals/enum-bug-keys');\nvar hiddenKeys = require('../internals/hidden-keys');\nvar html = require('../internals/html');\nvar documentCreateElement = require('../internals/document-create-element');\nvar sharedKey = require('../internals/shared-key');\n\nvar GT = '>';\nvar LT = '<';\nvar PROTOTYPE = 'prototype';\nvar SCRIPT = 'script';\nvar IE_PROTO = sharedKey('IE_PROTO');\n\nvar EmptyConstructor = function () { /* empty */ };\n\nvar scriptTag = function (content) {\n return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;\n};\n\n// Create object with fake `null` prototype: use ActiveX Object with cleared prototype\nvar NullProtoObjectViaActiveX = function (activeXDocument) {\n activeXDocument.write(scriptTag(''));\n activeXDocument.close();\n var temp = activeXDocument.parentWindow.Object;\n activeXDocument = null; // avoid memory leak\n return temp;\n};\n\n// Create object with fake `null` prototype: use iframe Object with cleared prototype\nvar NullProtoObjectViaIFrame = function () {\n // Thrash, waste and sodomy: IE GC bug\n var iframe = documentCreateElement('iframe');\n var JS = 'java' + SCRIPT + ':';\n var iframeDocument;\n iframe.style.display = 'none';\n html.appendChild(iframe);\n // https://github.com/zloirock/core-js/issues/475\n iframe.src = String(JS);\n iframeDocument = iframe.contentWindow.document;\n iframeDocument.open();\n iframeDocument.write(scriptTag('document.F=Object'));\n iframeDocument.close();\n return iframeDocument.F;\n};\n\n// Check for document.domain and active x support\n// No need to use active x approach when document.domain is not set\n// see https://github.com/es-shims/es5-shim/issues/150\n// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346\n// avoid IE GC bug\nvar activeXDocument;\nvar NullProtoObject = function () {\n try {\n /* global ActiveXObject */\n activeXDocument = document.domain && new ActiveXObject('htmlfile');\n } catch (error) { /* ignore */ }\n NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame();\n var length = enumBugKeys.length;\n while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];\n return NullProtoObject();\n};\n\nhiddenKeys[IE_PROTO] = true;\n\n// `Object.create` method\n// https://tc39.github.io/ecma262/#sec-object.create\nmodule.exports = Object.create || function create(O, Properties) {\n var result;\n if (O !== null) {\n EmptyConstructor[PROTOTYPE] = anObject(O);\n result = new EmptyConstructor();\n EmptyConstructor[PROTOTYPE] = null;\n // add \"__proto__\" for Object.getPrototypeOf polyfill\n result[IE_PROTO] = O;\n } else result = NullProtoObject();\n return Properties === undefined ? result : defineProperties(result, Properties);\n};\n","var toIndexedObject = require('../internals/to-indexed-object');\nvar nativeGetOwnPropertyNames = require('../internals/object-get-own-property-names').f;\n\nvar toString = {}.toString;\n\nvar windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames\n ? Object.getOwnPropertyNames(window) : [];\n\nvar getWindowNames = function (it) {\n try {\n return nativeGetOwnPropertyNames(it);\n } catch (error) {\n return windowNames.slice();\n }\n};\n\n// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window\nmodule.exports.f = function getOwnPropertyNames(it) {\n return windowNames && toString.call(it) == '[object Window]'\n ? getWindowNames(it)\n : nativeGetOwnPropertyNames(toIndexedObject(it));\n};\n","var global = require('../internals/global');\nvar shared = require('../internals/shared');\nvar has = require('../internals/has');\nvar uid = require('../internals/uid');\nvar NATIVE_SYMBOL = require('../internals/native-symbol');\nvar USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');\n\nvar WellKnownSymbolsStore = shared('wks');\nvar Symbol = global.Symbol;\nvar createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;\n\nmodule.exports = function (name) {\n if (!has(WellKnownSymbolsStore, name)) {\n if (NATIVE_SYMBOL && has(Symbol, name)) WellKnownSymbolsStore[name] = Symbol[name];\n else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);\n } return WellKnownSymbolsStore[name];\n};\n","var wellKnownSymbol = require('../internals/well-known-symbol');\n\nexports.f = wellKnownSymbol;\n","var path = require('../internals/path');\nvar has = require('../internals/has');\nvar wrappedWellKnownSymbolModule = require('../internals/well-known-symbol-wrapped');\nvar defineProperty = require('../internals/object-define-property').f;\n\nmodule.exports = function (NAME) {\n var Symbol = path.Symbol || (path.Symbol = {});\n if (!has(Symbol, NAME)) defineProperty(Symbol, NAME, {\n value: wrappedWellKnownSymbolModule.f(NAME)\n });\n};\n","var defineProperty = require('../internals/object-define-property').f;\nvar has = require('../internals/has');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\n\nmodule.exports = function (it, TAG, STATIC) {\n if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {\n defineProperty(it, TO_STRING_TAG, { configurable: true, value: TAG });\n }\n};\n","module.exports = function (it) {\n if (typeof it != 'function') {\n throw TypeError(String(it) + ' is not a function');\n } return it;\n};\n","var aFunction = require('../internals/a-function');\n\n// optional / simple context binding\nmodule.exports = function (fn, that, length) {\n aFunction(fn);\n if (that === undefined) return fn;\n switch (length) {\n case 0: return function () {\n return fn.call(that);\n };\n case 1: return function (a) {\n return fn.call(that, a);\n };\n case 2: return function (a, b) {\n return fn.call(that, a, b);\n };\n case 3: return function (a, b, c) {\n return fn.call(that, a, b, c);\n };\n }\n return function (/* ...args */) {\n return fn.apply(that, arguments);\n };\n};\n","var isObject = require('../internals/is-object');\nvar isArray = require('../internals/is-array');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar SPECIES = wellKnownSymbol('species');\n\n// `ArraySpeciesCreate` abstract operation\n// https://tc39.github.io/ecma262/#sec-arrayspeciescreate\nmodule.exports = function (originalArray, length) {\n var C;\n if (isArray(originalArray)) {\n C = originalArray.constructor;\n // cross-realm fallback\n if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;\n else if (isObject(C)) {\n C = C[SPECIES];\n if (C === null) C = undefined;\n }\n } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);\n};\n","var bind = require('../internals/function-bind-context');\nvar IndexedObject = require('../internals/indexed-object');\nvar toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar arraySpeciesCreate = require('../internals/array-species-create');\n\nvar push = [].push;\n\n// `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation\nvar createMethod = function (TYPE) {\n var IS_MAP = TYPE == 1;\n var IS_FILTER = TYPE == 2;\n var IS_SOME = TYPE == 3;\n var IS_EVERY = TYPE == 4;\n var IS_FIND_INDEX = TYPE == 6;\n var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;\n return function ($this, callbackfn, that, specificCreate) {\n var O = toObject($this);\n var self = IndexedObject(O);\n var boundFunction = bind(callbackfn, that, 3);\n var length = toLength(self.length);\n var index = 0;\n var create = specificCreate || arraySpeciesCreate;\n var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;\n var value, result;\n for (;length > index; index++) if (NO_HOLES || index in self) {\n value = self[index];\n result = boundFunction(value, index, O);\n if (TYPE) {\n if (IS_MAP) target[index] = result; // map\n else if (result) switch (TYPE) {\n case 3: return true; // some\n case 5: return value; // find\n case 6: return index; // findIndex\n case 2: push.call(target, value); // filter\n } else if (IS_EVERY) return false; // every\n }\n }\n return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;\n };\n};\n\nmodule.exports = {\n // `Array.prototype.forEach` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.foreach\n forEach: createMethod(0),\n // `Array.prototype.map` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.map\n map: createMethod(1),\n // `Array.prototype.filter` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.filter\n filter: createMethod(2),\n // `Array.prototype.some` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.some\n some: createMethod(3),\n // `Array.prototype.every` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.every\n every: createMethod(4),\n // `Array.prototype.find` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.find\n find: createMethod(5),\n // `Array.prototype.findIndex` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex\n findIndex: createMethod(6)\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar global = require('../internals/global');\nvar getBuiltIn = require('../internals/get-built-in');\nvar IS_PURE = require('../internals/is-pure');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar NATIVE_SYMBOL = require('../internals/native-symbol');\nvar USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');\nvar fails = require('../internals/fails');\nvar has = require('../internals/has');\nvar isArray = require('../internals/is-array');\nvar isObject = require('../internals/is-object');\nvar anObject = require('../internals/an-object');\nvar toObject = require('../internals/to-object');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar toPrimitive = require('../internals/to-primitive');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\nvar nativeObjectCreate = require('../internals/object-create');\nvar objectKeys = require('../internals/object-keys');\nvar getOwnPropertyNamesModule = require('../internals/object-get-own-property-names');\nvar getOwnPropertyNamesExternal = require('../internals/object-get-own-property-names-external');\nvar getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\nvar definePropertyModule = require('../internals/object-define-property');\nvar propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar redefine = require('../internals/redefine');\nvar shared = require('../internals/shared');\nvar sharedKey = require('../internals/shared-key');\nvar hiddenKeys = require('../internals/hidden-keys');\nvar uid = require('../internals/uid');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar wrappedWellKnownSymbolModule = require('../internals/well-known-symbol-wrapped');\nvar defineWellKnownSymbol = require('../internals/define-well-known-symbol');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar InternalStateModule = require('../internals/internal-state');\nvar $forEach = require('../internals/array-iteration').forEach;\n\nvar HIDDEN = sharedKey('hidden');\nvar SYMBOL = 'Symbol';\nvar PROTOTYPE = 'prototype';\nvar TO_PRIMITIVE = wellKnownSymbol('toPrimitive');\nvar setInternalState = InternalStateModule.set;\nvar getInternalState = InternalStateModule.getterFor(SYMBOL);\nvar ObjectPrototype = Object[PROTOTYPE];\nvar $Symbol = global.Symbol;\nvar $stringify = getBuiltIn('JSON', 'stringify');\nvar nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;\nvar nativeDefineProperty = definePropertyModule.f;\nvar nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;\nvar nativePropertyIsEnumerable = propertyIsEnumerableModule.f;\nvar AllSymbols = shared('symbols');\nvar ObjectPrototypeSymbols = shared('op-symbols');\nvar StringToSymbolRegistry = shared('string-to-symbol-registry');\nvar SymbolToStringRegistry = shared('symbol-to-string-registry');\nvar WellKnownSymbolsStore = shared('wks');\nvar QObject = global.QObject;\n// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173\nvar USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;\n\n// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687\nvar setSymbolDescriptor = DESCRIPTORS && fails(function () {\n return nativeObjectCreate(nativeDefineProperty({}, 'a', {\n get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; }\n })).a != 7;\n}) ? function (O, P, Attributes) {\n var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);\n if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];\n nativeDefineProperty(O, P, Attributes);\n if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {\n nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);\n }\n} : nativeDefineProperty;\n\nvar wrap = function (tag, description) {\n var symbol = AllSymbols[tag] = nativeObjectCreate($Symbol[PROTOTYPE]);\n setInternalState(symbol, {\n type: SYMBOL,\n tag: tag,\n description: description\n });\n if (!DESCRIPTORS) symbol.description = description;\n return symbol;\n};\n\nvar isSymbol = USE_SYMBOL_AS_UID ? function (it) {\n return typeof it == 'symbol';\n} : function (it) {\n return Object(it) instanceof $Symbol;\n};\n\nvar $defineProperty = function defineProperty(O, P, Attributes) {\n if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);\n anObject(O);\n var key = toPrimitive(P, true);\n anObject(Attributes);\n if (has(AllSymbols, key)) {\n if (!Attributes.enumerable) {\n if (!has(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));\n O[HIDDEN][key] = true;\n } else {\n if (has(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;\n Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });\n } return setSymbolDescriptor(O, key, Attributes);\n } return nativeDefineProperty(O, key, Attributes);\n};\n\nvar $defineProperties = function defineProperties(O, Properties) {\n anObject(O);\n var properties = toIndexedObject(Properties);\n var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));\n $forEach(keys, function (key) {\n if (!DESCRIPTORS || $propertyIsEnumerable.call(properties, key)) $defineProperty(O, key, properties[key]);\n });\n return O;\n};\n\nvar $create = function create(O, Properties) {\n return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);\n};\n\nvar $propertyIsEnumerable = function propertyIsEnumerable(V) {\n var P = toPrimitive(V, true);\n var enumerable = nativePropertyIsEnumerable.call(this, P);\n if (this === ObjectPrototype && has(AllSymbols, P) && !has(ObjectPrototypeSymbols, P)) return false;\n return enumerable || !has(this, P) || !has(AllSymbols, P) || has(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true;\n};\n\nvar $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {\n var it = toIndexedObject(O);\n var key = toPrimitive(P, true);\n if (it === ObjectPrototype && has(AllSymbols, key) && !has(ObjectPrototypeSymbols, key)) return;\n var descriptor = nativeGetOwnPropertyDescriptor(it, key);\n if (descriptor && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) {\n descriptor.enumerable = true;\n }\n return descriptor;\n};\n\nvar $getOwnPropertyNames = function getOwnPropertyNames(O) {\n var names = nativeGetOwnPropertyNames(toIndexedObject(O));\n var result = [];\n $forEach(names, function (key) {\n if (!has(AllSymbols, key) && !has(hiddenKeys, key)) result.push(key);\n });\n return result;\n};\n\nvar $getOwnPropertySymbols = function getOwnPropertySymbols(O) {\n var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;\n var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));\n var result = [];\n $forEach(names, function (key) {\n if (has(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || has(ObjectPrototype, key))) {\n result.push(AllSymbols[key]);\n }\n });\n return result;\n};\n\n// `Symbol` constructor\n// https://tc39.github.io/ecma262/#sec-symbol-constructor\nif (!NATIVE_SYMBOL) {\n $Symbol = function Symbol() {\n if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor');\n var description = !arguments.length || arguments[0] === undefined ? undefined : String(arguments[0]);\n var tag = uid(description);\n var setter = function (value) {\n if (this === ObjectPrototype) setter.call(ObjectPrototypeSymbols, value);\n if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;\n setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));\n };\n if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });\n return wrap(tag, description);\n };\n\n redefine($Symbol[PROTOTYPE], 'toString', function toString() {\n return getInternalState(this).tag;\n });\n\n redefine($Symbol, 'withoutSetter', function (description) {\n return wrap(uid(description), description);\n });\n\n propertyIsEnumerableModule.f = $propertyIsEnumerable;\n definePropertyModule.f = $defineProperty;\n getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;\n getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;\n getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;\n\n wrappedWellKnownSymbolModule.f = function (name) {\n return wrap(wellKnownSymbol(name), name);\n };\n\n if (DESCRIPTORS) {\n // https://github.com/tc39/proposal-Symbol-description\n nativeDefineProperty($Symbol[PROTOTYPE], 'description', {\n configurable: true,\n get: function description() {\n return getInternalState(this).description;\n }\n });\n if (!IS_PURE) {\n redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });\n }\n }\n}\n\n$({ global: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, {\n Symbol: $Symbol\n});\n\n$forEach(objectKeys(WellKnownSymbolsStore), function (name) {\n defineWellKnownSymbol(name);\n});\n\n$({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, {\n // `Symbol.for` method\n // https://tc39.github.io/ecma262/#sec-symbol.for\n 'for': function (key) {\n var string = String(key);\n if (has(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];\n var symbol = $Symbol(string);\n StringToSymbolRegistry[string] = symbol;\n SymbolToStringRegistry[symbol] = string;\n return symbol;\n },\n // `Symbol.keyFor` method\n // https://tc39.github.io/ecma262/#sec-symbol.keyfor\n keyFor: function keyFor(sym) {\n if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol');\n if (has(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];\n },\n useSetter: function () { USE_SETTER = true; },\n useSimple: function () { USE_SETTER = false; }\n});\n\n$({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS }, {\n // `Object.create` method\n // https://tc39.github.io/ecma262/#sec-object.create\n create: $create,\n // `Object.defineProperty` method\n // https://tc39.github.io/ecma262/#sec-object.defineproperty\n defineProperty: $defineProperty,\n // `Object.defineProperties` method\n // https://tc39.github.io/ecma262/#sec-object.defineproperties\n defineProperties: $defineProperties,\n // `Object.getOwnPropertyDescriptor` method\n // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors\n getOwnPropertyDescriptor: $getOwnPropertyDescriptor\n});\n\n$({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, {\n // `Object.getOwnPropertyNames` method\n // https://tc39.github.io/ecma262/#sec-object.getownpropertynames\n getOwnPropertyNames: $getOwnPropertyNames,\n // `Object.getOwnPropertySymbols` method\n // https://tc39.github.io/ecma262/#sec-object.getownpropertysymbols\n getOwnPropertySymbols: $getOwnPropertySymbols\n});\n\n// Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives\n// https://bugs.chromium.org/p/v8/issues/detail?id=3443\n$({ target: 'Object', stat: true, forced: fails(function () { getOwnPropertySymbolsModule.f(1); }) }, {\n getOwnPropertySymbols: function getOwnPropertySymbols(it) {\n return getOwnPropertySymbolsModule.f(toObject(it));\n }\n});\n\n// `JSON.stringify` method behavior with symbols\n// https://tc39.github.io/ecma262/#sec-json.stringify\nif ($stringify) {\n var FORCED_JSON_STRINGIFY = !NATIVE_SYMBOL || fails(function () {\n var symbol = $Symbol();\n // MS Edge converts symbol values to JSON as {}\n return $stringify([symbol]) != '[null]'\n // WebKit converts symbol values to JSON as null\n || $stringify({ a: symbol }) != '{}'\n // V8 throws on boxed symbols\n || $stringify(Object(symbol)) != '{}';\n });\n\n $({ target: 'JSON', stat: true, forced: FORCED_JSON_STRINGIFY }, {\n // eslint-disable-next-line no-unused-vars\n stringify: function stringify(it, replacer, space) {\n var args = [it];\n var index = 1;\n var $replacer;\n while (arguments.length > index) args.push(arguments[index++]);\n $replacer = replacer;\n if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined\n if (!isArray(replacer)) replacer = function (key, value) {\n if (typeof $replacer == 'function') value = $replacer.call(this, key, value);\n if (!isSymbol(value)) return value;\n };\n args[1] = replacer;\n return $stringify.apply(null, args);\n }\n });\n}\n\n// `Symbol.prototype[@@toPrimitive]` method\n// https://tc39.github.io/ecma262/#sec-symbol.prototype-@@toprimitive\nif (!$Symbol[PROTOTYPE][TO_PRIMITIVE]) {\n createNonEnumerableProperty($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);\n}\n// `Symbol.prototype[@@toStringTag]` property\n// https://tc39.github.io/ecma262/#sec-symbol.prototype-@@tostringtag\nsetToStringTag($Symbol, SYMBOL);\n\nhiddenKeys[HIDDEN] = true;\n","// `Symbol.prototype.description` getter\n// https://tc39.github.io/ecma262/#sec-symbol.prototype.description\n'use strict';\nvar $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar global = require('../internals/global');\nvar has = require('../internals/has');\nvar isObject = require('../internals/is-object');\nvar defineProperty = require('../internals/object-define-property').f;\nvar copyConstructorProperties = require('../internals/copy-constructor-properties');\n\nvar NativeSymbol = global.Symbol;\n\nif (DESCRIPTORS && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) ||\n // Safari 12 bug\n NativeSymbol().description !== undefined\n)) {\n var EmptyStringDescriptionStore = {};\n // wrap Symbol constructor for correct work with undefined description\n var SymbolWrapper = function Symbol() {\n var description = arguments.length < 1 || arguments[0] === undefined ? undefined : String(arguments[0]);\n var result = this instanceof SymbolWrapper\n ? new NativeSymbol(description)\n // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'\n : description === undefined ? NativeSymbol() : NativeSymbol(description);\n if (description === '') EmptyStringDescriptionStore[result] = true;\n return result;\n };\n copyConstructorProperties(SymbolWrapper, NativeSymbol);\n var symbolPrototype = SymbolWrapper.prototype = NativeSymbol.prototype;\n symbolPrototype.constructor = SymbolWrapper;\n\n var symbolToString = symbolPrototype.toString;\n var native = String(NativeSymbol('test')) == 'Symbol(test)';\n var regexp = /^Symbol\\((.*)\\)[^)]+$/;\n defineProperty(symbolPrototype, 'description', {\n configurable: true,\n get: function description() {\n var symbol = isObject(this) ? this.valueOf() : this;\n var string = symbolToString.call(symbol);\n if (has(EmptyStringDescriptionStore, symbol)) return '';\n var desc = native ? string.slice(7, -1) : string.replace(regexp, '$1');\n return desc === '' ? undefined : desc;\n }\n });\n\n $({ global: true, forced: true }, {\n Symbol: SymbolWrapper\n });\n}\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.asyncIterator` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.asynciterator\ndefineWellKnownSymbol('asyncIterator');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.hasInstance` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.hasinstance\ndefineWellKnownSymbol('hasInstance');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.isConcatSpreadable` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.isconcatspreadable\ndefineWellKnownSymbol('isConcatSpreadable');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.iterator` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.iterator\ndefineWellKnownSymbol('iterator');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.match` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.match\ndefineWellKnownSymbol('match');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.matchAll` well-known symbol\ndefineWellKnownSymbol('matchAll');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.replace` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.replace\ndefineWellKnownSymbol('replace');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.search` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.search\ndefineWellKnownSymbol('search');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.species` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.species\ndefineWellKnownSymbol('species');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.split` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.split\ndefineWellKnownSymbol('split');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.toPrimitive` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.toprimitive\ndefineWellKnownSymbol('toPrimitive');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.toStringTag` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.tostringtag\ndefineWellKnownSymbol('toStringTag');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.unscopables` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.unscopables\ndefineWellKnownSymbol('unscopables');\n","'use strict';\nvar toPrimitive = require('../internals/to-primitive');\nvar definePropertyModule = require('../internals/object-define-property');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\n\nmodule.exports = function (object, key, value) {\n var propertyKey = toPrimitive(key);\n if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));\n else object[propertyKey] = value;\n};\n","var getBuiltIn = require('../internals/get-built-in');\n\nmodule.exports = getBuiltIn('navigator', 'userAgent') || '';\n","var global = require('../internals/global');\nvar userAgent = require('../internals/engine-user-agent');\n\nvar process = global.process;\nvar versions = process && process.versions;\nvar v8 = versions && versions.v8;\nvar match, version;\n\nif (v8) {\n match = v8.split('.');\n version = match[0] + match[1];\n} else if (userAgent) {\n match = userAgent.match(/Edge\\/(\\d+)/);\n if (!match || match[1] >= 74) {\n match = userAgent.match(/Chrome\\/(\\d+)/);\n if (match) version = match[1];\n }\n}\n\nmodule.exports = version && +version;\n","var fails = require('../internals/fails');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar V8_VERSION = require('../internals/engine-v8-version');\n\nvar SPECIES = wellKnownSymbol('species');\n\nmodule.exports = function (METHOD_NAME) {\n // We can't use this feature detection in V8 since it causes\n // deoptimization and serious performance degradation\n // https://github.com/zloirock/core-js/issues/677\n return V8_VERSION >= 51 || !fails(function () {\n var array = [];\n var constructor = array.constructor = {};\n constructor[SPECIES] = function () {\n return { foo: 1 };\n };\n return array[METHOD_NAME](Boolean).foo !== 1;\n });\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar isArray = require('../internals/is-array');\nvar isObject = require('../internals/is-object');\nvar toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar createProperty = require('../internals/create-property');\nvar arraySpeciesCreate = require('../internals/array-species-create');\nvar arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar V8_VERSION = require('../internals/engine-v8-version');\n\nvar IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');\nvar MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;\nvar MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';\n\n// We can't use this feature detection in V8 since it causes\n// deoptimization and serious performance degradation\n// https://github.com/zloirock/core-js/issues/679\nvar IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () {\n var array = [];\n array[IS_CONCAT_SPREADABLE] = false;\n return array.concat()[0] !== array;\n});\n\nvar SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');\n\nvar isConcatSpreadable = function (O) {\n if (!isObject(O)) return false;\n var spreadable = O[IS_CONCAT_SPREADABLE];\n return spreadable !== undefined ? !!spreadable : isArray(O);\n};\n\nvar FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;\n\n// `Array.prototype.concat` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.concat\n// with adding support of @@isConcatSpreadable and @@species\n$({ target: 'Array', proto: true, forced: FORCED }, {\n concat: function concat(arg) { // eslint-disable-line no-unused-vars\n var O = toObject(this);\n var A = arraySpeciesCreate(O, 0);\n var n = 0;\n var i, k, length, len, E;\n for (i = -1, length = arguments.length; i < length; i++) {\n E = i === -1 ? O : arguments[i];\n if (isConcatSpreadable(E)) {\n len = toLength(E.length);\n if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);\n for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);\n } else {\n if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);\n createProperty(A, n++, E);\n }\n }\n A.length = n;\n return A;\n }\n});\n","'use strict';\nvar toObject = require('../internals/to-object');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\nvar toLength = require('../internals/to-length');\n\nvar min = Math.min;\n\n// `Array.prototype.copyWithin` method implementation\n// https://tc39.github.io/ecma262/#sec-array.prototype.copywithin\nmodule.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) {\n var O = toObject(this);\n var len = toLength(O.length);\n var to = toAbsoluteIndex(target, len);\n var from = toAbsoluteIndex(start, len);\n var end = arguments.length > 2 ? arguments[2] : undefined;\n var count = min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to);\n var inc = 1;\n if (from < to && to < from + count) {\n inc = -1;\n from += count - 1;\n to += count - 1;\n }\n while (count-- > 0) {\n if (from in O) O[to] = O[from];\n else delete O[to];\n to += inc;\n from += inc;\n } return O;\n};\n","var wellKnownSymbol = require('../internals/well-known-symbol');\nvar create = require('../internals/object-create');\nvar definePropertyModule = require('../internals/object-define-property');\n\nvar UNSCOPABLES = wellKnownSymbol('unscopables');\nvar ArrayPrototype = Array.prototype;\n\n// Array.prototype[@@unscopables]\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\nif (ArrayPrototype[UNSCOPABLES] == undefined) {\n definePropertyModule.f(ArrayPrototype, UNSCOPABLES, {\n configurable: true,\n value: create(null)\n });\n}\n\n// add a key to Array.prototype[@@unscopables]\nmodule.exports = function (key) {\n ArrayPrototype[UNSCOPABLES][key] = true;\n};\n","var $ = require('../internals/export');\nvar copyWithin = require('../internals/array-copy-within');\nvar addToUnscopables = require('../internals/add-to-unscopables');\n\n// `Array.prototype.copyWithin` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.copywithin\n$({ target: 'Array', proto: true }, {\n copyWithin: copyWithin\n});\n\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables('copyWithin');\n","'use strict';\nvar fails = require('../internals/fails');\n\nmodule.exports = function (METHOD_NAME, argument) {\n var method = [][METHOD_NAME];\n return !!method && fails(function () {\n // eslint-disable-next-line no-useless-call,no-throw-literal\n method.call(null, argument || function () { throw 1; }, 1);\n });\n};\n","var DESCRIPTORS = require('../internals/descriptors');\nvar fails = require('../internals/fails');\nvar has = require('../internals/has');\n\nvar defineProperty = Object.defineProperty;\nvar cache = {};\n\nvar thrower = function (it) { throw it; };\n\nmodule.exports = function (METHOD_NAME, options) {\n if (has(cache, METHOD_NAME)) return cache[METHOD_NAME];\n if (!options) options = {};\n var method = [][METHOD_NAME];\n var ACCESSORS = has(options, 'ACCESSORS') ? options.ACCESSORS : false;\n var argument0 = has(options, 0) ? options[0] : thrower;\n var argument1 = has(options, 1) ? options[1] : undefined;\n\n return cache[METHOD_NAME] = !!method && !fails(function () {\n if (ACCESSORS && !DESCRIPTORS) return true;\n var O = { length: -1 };\n\n if (ACCESSORS) defineProperty(O, 1, { enumerable: true, get: thrower });\n else O[1] = 1;\n\n method.call(O, argument0, argument1);\n });\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar $every = require('../internals/array-iteration').every;\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar STRICT_METHOD = arrayMethodIsStrict('every');\nvar USES_TO_LENGTH = arrayMethodUsesToLength('every');\n\n// `Array.prototype.every` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.every\n$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH }, {\n every: function every(callbackfn /* , thisArg */) {\n return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar toObject = require('../internals/to-object');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\nvar toLength = require('../internals/to-length');\n\n// `Array.prototype.fill` method implementation\n// https://tc39.github.io/ecma262/#sec-array.prototype.fill\nmodule.exports = function fill(value /* , start = 0, end = @length */) {\n var O = toObject(this);\n var length = toLength(O.length);\n var argumentsLength = arguments.length;\n var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length);\n var end = argumentsLength > 2 ? arguments[2] : undefined;\n var endPos = end === undefined ? length : toAbsoluteIndex(end, length);\n while (endPos > index) O[index++] = value;\n return O;\n};\n","var $ = require('../internals/export');\nvar fill = require('../internals/array-fill');\nvar addToUnscopables = require('../internals/add-to-unscopables');\n\n// `Array.prototype.fill` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.fill\n$({ target: 'Array', proto: true }, {\n fill: fill\n});\n\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables('fill');\n","'use strict';\nvar $ = require('../internals/export');\nvar $filter = require('../internals/array-iteration').filter;\nvar arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter');\n// Edge 14- issue\nvar USES_TO_LENGTH = arrayMethodUsesToLength('filter');\n\n// `Array.prototype.filter` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.filter\n// with adding support of @@species\n$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, {\n filter: function filter(callbackfn /* , thisArg */) {\n return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $find = require('../internals/array-iteration').find;\nvar addToUnscopables = require('../internals/add-to-unscopables');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar FIND = 'find';\nvar SKIPS_HOLES = true;\n\nvar USES_TO_LENGTH = arrayMethodUsesToLength(FIND);\n\n// Shouldn't skip holes\nif (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });\n\n// `Array.prototype.find` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.find\n$({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH }, {\n find: function find(callbackfn /* , that = undefined */) {\n return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables(FIND);\n","'use strict';\nvar $ = require('../internals/export');\nvar $findIndex = require('../internals/array-iteration').findIndex;\nvar addToUnscopables = require('../internals/add-to-unscopables');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar FIND_INDEX = 'findIndex';\nvar SKIPS_HOLES = true;\n\nvar USES_TO_LENGTH = arrayMethodUsesToLength(FIND_INDEX);\n\n// Shouldn't skip holes\nif (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES = false; });\n\n// `Array.prototype.findIndex` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.findindex\n$({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH }, {\n findIndex: function findIndex(callbackfn /* , that = undefined */) {\n return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables(FIND_INDEX);\n","'use strict';\nvar isArray = require('../internals/is-array');\nvar toLength = require('../internals/to-length');\nvar bind = require('../internals/function-bind-context');\n\n// `FlattenIntoArray` abstract operation\n// https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray\nvar flattenIntoArray = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {\n var targetIndex = start;\n var sourceIndex = 0;\n var mapFn = mapper ? bind(mapper, thisArg, 3) : false;\n var element;\n\n while (sourceIndex < sourceLen) {\n if (sourceIndex in source) {\n element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];\n\n if (depth > 0 && isArray(element)) {\n targetIndex = flattenIntoArray(target, original, element, toLength(element.length), targetIndex, depth - 1) - 1;\n } else {\n if (targetIndex >= 0x1FFFFFFFFFFFFF) throw TypeError('Exceed the acceptable array length');\n target[targetIndex] = element;\n }\n\n targetIndex++;\n }\n sourceIndex++;\n }\n return targetIndex;\n};\n\nmodule.exports = flattenIntoArray;\n","'use strict';\nvar $ = require('../internals/export');\nvar flattenIntoArray = require('../internals/flatten-into-array');\nvar toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar toInteger = require('../internals/to-integer');\nvar arraySpeciesCreate = require('../internals/array-species-create');\n\n// `Array.prototype.flat` method\n// https://github.com/tc39/proposal-flatMap\n$({ target: 'Array', proto: true }, {\n flat: function flat(/* depthArg = 1 */) {\n var depthArg = arguments.length ? arguments[0] : undefined;\n var O = toObject(this);\n var sourceLen = toLength(O.length);\n var A = arraySpeciesCreate(O, 0);\n A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toInteger(depthArg));\n return A;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar flattenIntoArray = require('../internals/flatten-into-array');\nvar toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar aFunction = require('../internals/a-function');\nvar arraySpeciesCreate = require('../internals/array-species-create');\n\n// `Array.prototype.flatMap` method\n// https://github.com/tc39/proposal-flatMap\n$({ target: 'Array', proto: true }, {\n flatMap: function flatMap(callbackfn /* , thisArg */) {\n var O = toObject(this);\n var sourceLen = toLength(O.length);\n var A;\n aFunction(callbackfn);\n A = arraySpeciesCreate(O, 0);\n A.length = flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n return A;\n }\n});\n","'use strict';\nvar $forEach = require('../internals/array-iteration').forEach;\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar STRICT_METHOD = arrayMethodIsStrict('forEach');\nvar USES_TO_LENGTH = arrayMethodUsesToLength('forEach');\n\n// `Array.prototype.forEach` method implementation\n// https://tc39.github.io/ecma262/#sec-array.prototype.foreach\nmodule.exports = (!STRICT_METHOD || !USES_TO_LENGTH) ? function forEach(callbackfn /* , thisArg */) {\n return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n} : [].forEach;\n","'use strict';\nvar $ = require('../internals/export');\nvar forEach = require('../internals/array-for-each');\n\n// `Array.prototype.forEach` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.foreach\n$({ target: 'Array', proto: true, forced: [].forEach != forEach }, {\n forEach: forEach\n});\n","var anObject = require('../internals/an-object');\n\n// call something on iterator step with safe closing on error\nmodule.exports = function (iterator, fn, value, ENTRIES) {\n try {\n return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);\n // 7.4.6 IteratorClose(iterator, completion)\n } catch (error) {\n var returnMethod = iterator['return'];\n if (returnMethod !== undefined) anObject(returnMethod.call(iterator));\n throw error;\n }\n};\n","module.exports = {};\n","var wellKnownSymbol = require('../internals/well-known-symbol');\nvar Iterators = require('../internals/iterators');\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar ArrayPrototype = Array.prototype;\n\n// check on default Array iterator\nmodule.exports = function (it) {\n return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);\n};\n","var wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\nvar test = {};\n\ntest[TO_STRING_TAG] = 'z';\n\nmodule.exports = String(test) === '[object z]';\n","var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');\nvar classofRaw = require('../internals/classof-raw');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\n// ES3 wrong here\nvar CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';\n\n// fallback for IE11 Script Access Denied error\nvar tryGet = function (it, key) {\n try {\n return it[key];\n } catch (error) { /* empty */ }\n};\n\n// getting tag from ES6+ `Object.prototype.toString`\nmodule.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {\n var O, tag, result;\n return it === undefined ? 'Undefined' : it === null ? 'Null'\n // @@toStringTag case\n : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag\n // builtinTag case\n : CORRECT_ARGUMENTS ? classofRaw(O)\n // ES3 arguments fallback\n : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;\n};\n","var classof = require('../internals/classof');\nvar Iterators = require('../internals/iterators');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar ITERATOR = wellKnownSymbol('iterator');\n\nmodule.exports = function (it) {\n if (it != undefined) return it[ITERATOR]\n || it['@@iterator']\n || Iterators[classof(it)];\n};\n","'use strict';\nvar bind = require('../internals/function-bind-context');\nvar toObject = require('../internals/to-object');\nvar callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');\nvar isArrayIteratorMethod = require('../internals/is-array-iterator-method');\nvar toLength = require('../internals/to-length');\nvar createProperty = require('../internals/create-property');\nvar getIteratorMethod = require('../internals/get-iterator-method');\n\n// `Array.from` method implementation\n// https://tc39.github.io/ecma262/#sec-array.from\nmodule.exports = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {\n var O = toObject(arrayLike);\n var C = typeof this == 'function' ? this : Array;\n var argumentsLength = arguments.length;\n var mapfn = argumentsLength > 1 ? arguments[1] : undefined;\n var mapping = mapfn !== undefined;\n var iteratorMethod = getIteratorMethod(O);\n var index = 0;\n var length, result, step, iterator, next, value;\n if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2);\n // if the target is not iterable or it's an array with the default iterator - use a simple case\n if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod(iteratorMethod))) {\n iterator = iteratorMethod.call(O);\n next = iterator.next;\n result = new C();\n for (;!(step = next.call(iterator)).done; index++) {\n value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;\n createProperty(result, index, value);\n }\n } else {\n length = toLength(O.length);\n result = new C(length);\n for (;length > index; index++) {\n value = mapping ? mapfn(O[index], index) : O[index];\n createProperty(result, index, value);\n }\n }\n result.length = index;\n return result;\n};\n","var wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar SAFE_CLOSING = false;\n\ntry {\n var called = 0;\n var iteratorWithReturn = {\n next: function () {\n return { done: !!called++ };\n },\n 'return': function () {\n SAFE_CLOSING = true;\n }\n };\n iteratorWithReturn[ITERATOR] = function () {\n return this;\n };\n // eslint-disable-next-line no-throw-literal\n Array.from(iteratorWithReturn, function () { throw 2; });\n} catch (error) { /* empty */ }\n\nmodule.exports = function (exec, SKIP_CLOSING) {\n if (!SKIP_CLOSING && !SAFE_CLOSING) return false;\n var ITERATION_SUPPORT = false;\n try {\n var object = {};\n object[ITERATOR] = function () {\n return {\n next: function () {\n return { done: ITERATION_SUPPORT = true };\n }\n };\n };\n exec(object);\n } catch (error) { /* empty */ }\n return ITERATION_SUPPORT;\n};\n","var $ = require('../internals/export');\nvar from = require('../internals/array-from');\nvar checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration');\n\nvar INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {\n Array.from(iterable);\n});\n\n// `Array.from` method\n// https://tc39.github.io/ecma262/#sec-array.from\n$({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {\n from: from\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $includes = require('../internals/array-includes').includes;\nvar addToUnscopables = require('../internals/add-to-unscopables');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });\n\n// `Array.prototype.includes` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.includes\n$({ target: 'Array', proto: true, forced: !USES_TO_LENGTH }, {\n includes: function includes(el /* , fromIndex = 0 */) {\n return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables('includes');\n","'use strict';\nvar $ = require('../internals/export');\nvar $indexOf = require('../internals/array-includes').indexOf;\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar nativeIndexOf = [].indexOf;\n\nvar NEGATIVE_ZERO = !!nativeIndexOf && 1 / [1].indexOf(1, -0) < 0;\nvar STRICT_METHOD = arrayMethodIsStrict('indexOf');\nvar USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });\n\n// `Array.prototype.indexOf` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.indexof\n$({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD || !USES_TO_LENGTH }, {\n indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {\n return NEGATIVE_ZERO\n // convert -0 to +0\n ? nativeIndexOf.apply(this, arguments) || 0\n : $indexOf(this, searchElement, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","var $ = require('../internals/export');\nvar isArray = require('../internals/is-array');\n\n// `Array.isArray` method\n// https://tc39.github.io/ecma262/#sec-array.isarray\n$({ target: 'Array', stat: true }, {\n isArray: isArray\n});\n","var fails = require('../internals/fails');\n\nmodule.exports = !fails(function () {\n function F() { /* empty */ }\n F.prototype.constructor = null;\n return Object.getPrototypeOf(new F()) !== F.prototype;\n});\n","var has = require('../internals/has');\nvar toObject = require('../internals/to-object');\nvar sharedKey = require('../internals/shared-key');\nvar CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter');\n\nvar IE_PROTO = sharedKey('IE_PROTO');\nvar ObjectPrototype = Object.prototype;\n\n// `Object.getPrototypeOf` method\n// https://tc39.github.io/ecma262/#sec-object.getprototypeof\nmodule.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {\n O = toObject(O);\n if (has(O, IE_PROTO)) return O[IE_PROTO];\n if (typeof O.constructor == 'function' && O instanceof O.constructor) {\n return O.constructor.prototype;\n } return O instanceof Object ? ObjectPrototype : null;\n};\n","'use strict';\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar has = require('../internals/has');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar IS_PURE = require('../internals/is-pure');\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar BUGGY_SAFARI_ITERATORS = false;\n\nvar returnThis = function () { return this; };\n\n// `%IteratorPrototype%` object\n// https://tc39.github.io/ecma262/#sec-%iteratorprototype%-object\nvar IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;\n\nif ([].keys) {\n arrayIterator = [].keys();\n // Safari 8 has buggy iterators w/o `next`\n if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;\n else {\n PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));\n if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;\n }\n}\n\nif (IteratorPrototype == undefined) IteratorPrototype = {};\n\n// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()\nif (!IS_PURE && !has(IteratorPrototype, ITERATOR)) {\n createNonEnumerableProperty(IteratorPrototype, ITERATOR, returnThis);\n}\n\nmodule.exports = {\n IteratorPrototype: IteratorPrototype,\n BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS\n};\n","'use strict';\nvar IteratorPrototype = require('../internals/iterators-core').IteratorPrototype;\nvar create = require('../internals/object-create');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar Iterators = require('../internals/iterators');\n\nvar returnThis = function () { return this; };\n\nmodule.exports = function (IteratorConstructor, NAME, next) {\n var TO_STRING_TAG = NAME + ' Iterator';\n IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(1, next) });\n setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);\n Iterators[TO_STRING_TAG] = returnThis;\n return IteratorConstructor;\n};\n","var isObject = require('../internals/is-object');\n\nmodule.exports = function (it) {\n if (!isObject(it) && it !== null) {\n throw TypeError(\"Can't set \" + String(it) + ' as a prototype');\n } return it;\n};\n","var anObject = require('../internals/an-object');\nvar aPossiblePrototype = require('../internals/a-possible-prototype');\n\n// `Object.setPrototypeOf` method\n// https://tc39.github.io/ecma262/#sec-object.setprototypeof\n// Works with __proto__ only. Old v8 can't work with null proto objects.\n/* eslint-disable no-proto */\nmodule.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {\n var CORRECT_SETTER = false;\n var test = {};\n var setter;\n try {\n setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;\n setter.call(test, []);\n CORRECT_SETTER = test instanceof Array;\n } catch (error) { /* empty */ }\n return function setPrototypeOf(O, proto) {\n anObject(O);\n aPossiblePrototype(proto);\n if (CORRECT_SETTER) setter.call(O, proto);\n else O.__proto__ = proto;\n return O;\n };\n}() : undefined);\n","'use strict';\nvar $ = require('../internals/export');\nvar createIteratorConstructor = require('../internals/create-iterator-constructor');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar redefine = require('../internals/redefine');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar IS_PURE = require('../internals/is-pure');\nvar Iterators = require('../internals/iterators');\nvar IteratorsCore = require('../internals/iterators-core');\n\nvar IteratorPrototype = IteratorsCore.IteratorPrototype;\nvar BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;\nvar ITERATOR = wellKnownSymbol('iterator');\nvar KEYS = 'keys';\nvar VALUES = 'values';\nvar ENTRIES = 'entries';\n\nvar returnThis = function () { return this; };\n\nmodule.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {\n createIteratorConstructor(IteratorConstructor, NAME, next);\n\n var getIterationMethod = function (KIND) {\n if (KIND === DEFAULT && defaultIterator) return defaultIterator;\n if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];\n switch (KIND) {\n case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };\n case VALUES: return function values() { return new IteratorConstructor(this, KIND); };\n case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };\n } return function () { return new IteratorConstructor(this); };\n };\n\n var TO_STRING_TAG = NAME + ' Iterator';\n var INCORRECT_VALUES_NAME = false;\n var IterablePrototype = Iterable.prototype;\n var nativeIterator = IterablePrototype[ITERATOR]\n || IterablePrototype['@@iterator']\n || DEFAULT && IterablePrototype[DEFAULT];\n var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);\n var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;\n var CurrentIteratorPrototype, methods, KEY;\n\n // fix native\n if (anyNativeIterator) {\n CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));\n if (IteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {\n if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {\n if (setPrototypeOf) {\n setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);\n } else if (typeof CurrentIteratorPrototype[ITERATOR] != 'function') {\n createNonEnumerableProperty(CurrentIteratorPrototype, ITERATOR, returnThis);\n }\n }\n // Set @@toStringTag to native iterators\n setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);\n if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;\n }\n }\n\n // fix Array#{values, @@iterator}.name in V8 / FF\n if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {\n INCORRECT_VALUES_NAME = true;\n defaultIterator = function values() { return nativeIterator.call(this); };\n }\n\n // define iterator\n if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {\n createNonEnumerableProperty(IterablePrototype, ITERATOR, defaultIterator);\n }\n Iterators[NAME] = defaultIterator;\n\n // export additional methods\n if (DEFAULT) {\n methods = {\n values: getIterationMethod(VALUES),\n keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),\n entries: getIterationMethod(ENTRIES)\n };\n if (FORCED) for (KEY in methods) {\n if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {\n redefine(IterablePrototype, KEY, methods[KEY]);\n }\n } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);\n }\n\n return methods;\n};\n","'use strict';\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar addToUnscopables = require('../internals/add-to-unscopables');\nvar Iterators = require('../internals/iterators');\nvar InternalStateModule = require('../internals/internal-state');\nvar defineIterator = require('../internals/define-iterator');\n\nvar ARRAY_ITERATOR = 'Array Iterator';\nvar setInternalState = InternalStateModule.set;\nvar getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);\n\n// `Array.prototype.entries` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.entries\n// `Array.prototype.keys` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.keys\n// `Array.prototype.values` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.values\n// `Array.prototype[@@iterator]` method\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@iterator\n// `CreateArrayIterator` internal method\n// https://tc39.github.io/ecma262/#sec-createarrayiterator\nmodule.exports = defineIterator(Array, 'Array', function (iterated, kind) {\n setInternalState(this, {\n type: ARRAY_ITERATOR,\n target: toIndexedObject(iterated), // target\n index: 0, // next index\n kind: kind // kind\n });\n// `%ArrayIteratorPrototype%.next` method\n// https://tc39.github.io/ecma262/#sec-%arrayiteratorprototype%.next\n}, function () {\n var state = getInternalState(this);\n var target = state.target;\n var kind = state.kind;\n var index = state.index++;\n if (!target || index >= target.length) {\n state.target = undefined;\n return { value: undefined, done: true };\n }\n if (kind == 'keys') return { value: index, done: false };\n if (kind == 'values') return { value: target[index], done: false };\n return { value: [index, target[index]], done: false };\n}, 'values');\n\n// argumentsList[@@iterator] is %ArrayProto_values%\n// https://tc39.github.io/ecma262/#sec-createunmappedargumentsobject\n// https://tc39.github.io/ecma262/#sec-createmappedargumentsobject\nIterators.Arguments = Iterators.Array;\n\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables('keys');\naddToUnscopables('values');\naddToUnscopables('entries');\n","'use strict';\nvar $ = require('../internals/export');\nvar IndexedObject = require('../internals/indexed-object');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\n\nvar nativeJoin = [].join;\n\nvar ES3_STRINGS = IndexedObject != Object;\nvar STRICT_METHOD = arrayMethodIsStrict('join', ',');\n\n// `Array.prototype.join` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.join\n$({ target: 'Array', proto: true, forced: ES3_STRINGS || !STRICT_METHOD }, {\n join: function join(separator) {\n return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator);\n }\n});\n","'use strict';\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar toInteger = require('../internals/to-integer');\nvar toLength = require('../internals/to-length');\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar min = Math.min;\nvar nativeLastIndexOf = [].lastIndexOf;\nvar NEGATIVE_ZERO = !!nativeLastIndexOf && 1 / [1].lastIndexOf(1, -0) < 0;\nvar STRICT_METHOD = arrayMethodIsStrict('lastIndexOf');\n// For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method\nvar USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });\nvar FORCED = NEGATIVE_ZERO || !STRICT_METHOD || !USES_TO_LENGTH;\n\n// `Array.prototype.lastIndexOf` method implementation\n// https://tc39.github.io/ecma262/#sec-array.prototype.lastindexof\nmodule.exports = FORCED ? function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) {\n // convert -0 to +0\n if (NEGATIVE_ZERO) return nativeLastIndexOf.apply(this, arguments) || 0;\n var O = toIndexedObject(this);\n var length = toLength(O.length);\n var index = length - 1;\n if (arguments.length > 1) index = min(index, toInteger(arguments[1]));\n if (index < 0) index = length + index;\n for (;index >= 0; index--) if (index in O && O[index] === searchElement) return index || 0;\n return -1;\n} : nativeLastIndexOf;\n","var $ = require('../internals/export');\nvar lastIndexOf = require('../internals/array-last-index-of');\n\n// `Array.prototype.lastIndexOf` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.lastindexof\n$({ target: 'Array', proto: true, forced: lastIndexOf !== [].lastIndexOf }, {\n lastIndexOf: lastIndexOf\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $map = require('../internals/array-iteration').map;\nvar arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map');\n// FF49- issue\nvar USES_TO_LENGTH = arrayMethodUsesToLength('map');\n\n// `Array.prototype.map` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.map\n// with adding support of @@species\n$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, {\n map: function map(callbackfn /* , thisArg */) {\n return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar createProperty = require('../internals/create-property');\n\nvar ISNT_GENERIC = fails(function () {\n function F() { /* empty */ }\n return !(Array.of.call(F) instanceof F);\n});\n\n// `Array.of` method\n// https://tc39.github.io/ecma262/#sec-array.of\n// WebKit Array.of isn't generic\n$({ target: 'Array', stat: true, forced: ISNT_GENERIC }, {\n of: function of(/* ...args */) {\n var index = 0;\n var argumentsLength = arguments.length;\n var result = new (typeof this == 'function' ? this : Array)(argumentsLength);\n while (argumentsLength > index) createProperty(result, index, arguments[index++]);\n result.length = argumentsLength;\n return result;\n }\n});\n","var aFunction = require('../internals/a-function');\nvar toObject = require('../internals/to-object');\nvar IndexedObject = require('../internals/indexed-object');\nvar toLength = require('../internals/to-length');\n\n// `Array.prototype.{ reduce, reduceRight }` methods implementation\nvar createMethod = function (IS_RIGHT) {\n return function (that, callbackfn, argumentsLength, memo) {\n aFunction(callbackfn);\n var O = toObject(that);\n var self = IndexedObject(O);\n var length = toLength(O.length);\n var index = IS_RIGHT ? length - 1 : 0;\n var i = IS_RIGHT ? -1 : 1;\n if (argumentsLength < 2) while (true) {\n if (index in self) {\n memo = self[index];\n index += i;\n break;\n }\n index += i;\n if (IS_RIGHT ? index < 0 : length <= index) {\n throw TypeError('Reduce of empty array with no initial value');\n }\n }\n for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {\n memo = callbackfn(memo, self[index], index, O);\n }\n return memo;\n };\n};\n\nmodule.exports = {\n // `Array.prototype.reduce` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.reduce\n left: createMethod(false),\n // `Array.prototype.reduceRight` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.reduceright\n right: createMethod(true)\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar $reduce = require('../internals/array-reduce').left;\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar STRICT_METHOD = arrayMethodIsStrict('reduce');\nvar USES_TO_LENGTH = arrayMethodUsesToLength('reduce', { 1: 0 });\n\n// `Array.prototype.reduce` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.reduce\n$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH }, {\n reduce: function reduce(callbackfn /* , initialValue */) {\n return $reduce(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $reduceRight = require('../internals/array-reduce').right;\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar STRICT_METHOD = arrayMethodIsStrict('reduceRight');\n// For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method\nvar USES_TO_LENGTH = arrayMethodUsesToLength('reduce', { 1: 0 });\n\n// `Array.prototype.reduceRight` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.reduceright\n$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH }, {\n reduceRight: function reduceRight(callbackfn /* , initialValue */) {\n return $reduceRight(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar isArray = require('../internals/is-array');\n\nvar nativeReverse = [].reverse;\nvar test = [1, 2];\n\n// `Array.prototype.reverse` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.reverse\n// fix for Safari 12.0 bug\n// https://bugs.webkit.org/show_bug.cgi?id=188794\n$({ target: 'Array', proto: true, forced: String(test) === String(test.reverse()) }, {\n reverse: function reverse() {\n // eslint-disable-next-line no-self-assign\n if (isArray(this)) this.length = this.length;\n return nativeReverse.call(this);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar isObject = require('../internals/is-object');\nvar isArray = require('../internals/is-array');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\nvar toLength = require('../internals/to-length');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar createProperty = require('../internals/create-property');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');\nvar USES_TO_LENGTH = arrayMethodUsesToLength('slice', { ACCESSORS: true, 0: 0, 1: 2 });\n\nvar SPECIES = wellKnownSymbol('species');\nvar nativeSlice = [].slice;\nvar max = Math.max;\n\n// `Array.prototype.slice` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.slice\n// fallback for not array-like ES3 strings and DOM objects\n$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, {\n slice: function slice(start, end) {\n var O = toIndexedObject(this);\n var length = toLength(O.length);\n var k = toAbsoluteIndex(start, length);\n var fin = toAbsoluteIndex(end === undefined ? length : end, length);\n // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible\n var Constructor, result, n;\n if (isArray(O)) {\n Constructor = O.constructor;\n // cross-realm fallback\n if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) {\n Constructor = undefined;\n } else if (isObject(Constructor)) {\n Constructor = Constructor[SPECIES];\n if (Constructor === null) Constructor = undefined;\n }\n if (Constructor === Array || Constructor === undefined) {\n return nativeSlice.call(O, k, fin);\n }\n }\n result = new (Constructor === undefined ? Array : Constructor)(max(fin - k, 0));\n for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);\n result.length = n;\n return result;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $some = require('../internals/array-iteration').some;\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar STRICT_METHOD = arrayMethodIsStrict('some');\nvar USES_TO_LENGTH = arrayMethodUsesToLength('some');\n\n// `Array.prototype.some` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.some\n$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH }, {\n some: function some(callbackfn /* , thisArg */) {\n return $some(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar aFunction = require('../internals/a-function');\nvar toObject = require('../internals/to-object');\nvar fails = require('../internals/fails');\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\n\nvar test = [];\nvar nativeSort = test.sort;\n\n// IE8-\nvar FAILS_ON_UNDEFINED = fails(function () {\n test.sort(undefined);\n});\n// V8 bug\nvar FAILS_ON_NULL = fails(function () {\n test.sort(null);\n});\n// Old WebKit\nvar STRICT_METHOD = arrayMethodIsStrict('sort');\n\nvar FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD;\n\n// `Array.prototype.sort` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.sort\n$({ target: 'Array', proto: true, forced: FORCED }, {\n sort: function sort(comparefn) {\n return comparefn === undefined\n ? nativeSort.call(toObject(this))\n : nativeSort.call(toObject(this), aFunction(comparefn));\n }\n});\n","'use strict';\nvar getBuiltIn = require('../internals/get-built-in');\nvar definePropertyModule = require('../internals/object-define-property');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar DESCRIPTORS = require('../internals/descriptors');\n\nvar SPECIES = wellKnownSymbol('species');\n\nmodule.exports = function (CONSTRUCTOR_NAME) {\n var Constructor = getBuiltIn(CONSTRUCTOR_NAME);\n var defineProperty = definePropertyModule.f;\n\n if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {\n defineProperty(Constructor, SPECIES, {\n configurable: true,\n get: function () { return this; }\n });\n }\n};\n","var setSpecies = require('../internals/set-species');\n\n// `Array[@@species]` getter\n// https://tc39.github.io/ecma262/#sec-get-array-@@species\nsetSpecies('Array');\n","'use strict';\nvar $ = require('../internals/export');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\nvar toInteger = require('../internals/to-integer');\nvar toLength = require('../internals/to-length');\nvar toObject = require('../internals/to-object');\nvar arraySpeciesCreate = require('../internals/array-species-create');\nvar createProperty = require('../internals/create-property');\nvar arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice');\nvar USES_TO_LENGTH = arrayMethodUsesToLength('splice', { ACCESSORS: true, 0: 0, 1: 2 });\n\nvar max = Math.max;\nvar min = Math.min;\nvar MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;\nvar MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded';\n\n// `Array.prototype.splice` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.splice\n// with adding support of @@species\n$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, {\n splice: function splice(start, deleteCount /* , ...items */) {\n var O = toObject(this);\n var len = toLength(O.length);\n var actualStart = toAbsoluteIndex(start, len);\n var argumentsLength = arguments.length;\n var insertCount, actualDeleteCount, A, k, from, to;\n if (argumentsLength === 0) {\n insertCount = actualDeleteCount = 0;\n } else if (argumentsLength === 1) {\n insertCount = 0;\n actualDeleteCount = len - actualStart;\n } else {\n insertCount = argumentsLength - 2;\n actualDeleteCount = min(max(toInteger(deleteCount), 0), len - actualStart);\n }\n if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER) {\n throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);\n }\n A = arraySpeciesCreate(O, actualDeleteCount);\n for (k = 0; k < actualDeleteCount; k++) {\n from = actualStart + k;\n if (from in O) createProperty(A, k, O[from]);\n }\n A.length = actualDeleteCount;\n if (insertCount < actualDeleteCount) {\n for (k = actualStart; k < len - actualDeleteCount; k++) {\n from = k + actualDeleteCount;\n to = k + insertCount;\n if (from in O) O[to] = O[from];\n else delete O[to];\n }\n for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];\n } else if (insertCount > actualDeleteCount) {\n for (k = len - actualDeleteCount; k > actualStart; k--) {\n from = k + actualDeleteCount - 1;\n to = k + insertCount - 1;\n if (from in O) O[to] = O[from];\n else delete O[to];\n }\n }\n for (k = 0; k < insertCount; k++) {\n O[k + actualStart] = arguments[k + 2];\n }\n O.length = len - actualDeleteCount + insertCount;\n return A;\n }\n});\n","// this method was added to unscopables after implementation\n// in popular engines, so it's moved to a separate module\nvar addToUnscopables = require('../internals/add-to-unscopables');\n\naddToUnscopables('flat');\n","// this method was added to unscopables after implementation\n// in popular engines, so it's moved to a separate module\nvar addToUnscopables = require('../internals/add-to-unscopables');\n\naddToUnscopables('flatMap');\n","module.exports = typeof ArrayBuffer !== 'undefined' && typeof DataView !== 'undefined';\n","var redefine = require('../internals/redefine');\n\nmodule.exports = function (target, src, options) {\n for (var key in src) redefine(target, key, src[key], options);\n return target;\n};\n","module.exports = function (it, Constructor, name) {\n if (!(it instanceof Constructor)) {\n throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');\n } return it;\n};\n","var toInteger = require('../internals/to-integer');\nvar toLength = require('../internals/to-length');\n\n// `ToIndex` abstract operation\n// https://tc39.github.io/ecma262/#sec-toindex\nmodule.exports = function (it) {\n if (it === undefined) return 0;\n var number = toInteger(it);\n var length = toLength(number);\n if (number !== length) throw RangeError('Wrong length or index');\n return length;\n};\n","// IEEE754 conversions based on https://github.com/feross/ieee754\n// eslint-disable-next-line no-shadow-restricted-names\nvar Infinity = 1 / 0;\nvar abs = Math.abs;\nvar pow = Math.pow;\nvar floor = Math.floor;\nvar log = Math.log;\nvar LN2 = Math.LN2;\n\nvar pack = function (number, mantissaLength, bytes) {\n var buffer = new Array(bytes);\n var exponentLength = bytes * 8 - mantissaLength - 1;\n var eMax = (1 << exponentLength) - 1;\n var eBias = eMax >> 1;\n var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0;\n var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0;\n var index = 0;\n var exponent, mantissa, c;\n number = abs(number);\n // eslint-disable-next-line no-self-compare\n if (number != number || number === Infinity) {\n // eslint-disable-next-line no-self-compare\n mantissa = number != number ? 1 : 0;\n exponent = eMax;\n } else {\n exponent = floor(log(number) / LN2);\n if (number * (c = pow(2, -exponent)) < 1) {\n exponent--;\n c *= 2;\n }\n if (exponent + eBias >= 1) {\n number += rt / c;\n } else {\n number += rt * pow(2, 1 - eBias);\n }\n if (number * c >= 2) {\n exponent++;\n c /= 2;\n }\n if (exponent + eBias >= eMax) {\n mantissa = 0;\n exponent = eMax;\n } else if (exponent + eBias >= 1) {\n mantissa = (number * c - 1) * pow(2, mantissaLength);\n exponent = exponent + eBias;\n } else {\n mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength);\n exponent = 0;\n }\n }\n for (; mantissaLength >= 8; buffer[index++] = mantissa & 255, mantissa /= 256, mantissaLength -= 8);\n exponent = exponent << mantissaLength | mantissa;\n exponentLength += mantissaLength;\n for (; exponentLength > 0; buffer[index++] = exponent & 255, exponent /= 256, exponentLength -= 8);\n buffer[--index] |= sign * 128;\n return buffer;\n};\n\nvar unpack = function (buffer, mantissaLength) {\n var bytes = buffer.length;\n var exponentLength = bytes * 8 - mantissaLength - 1;\n var eMax = (1 << exponentLength) - 1;\n var eBias = eMax >> 1;\n var nBits = exponentLength - 7;\n var index = bytes - 1;\n var sign = buffer[index--];\n var exponent = sign & 127;\n var mantissa;\n sign >>= 7;\n for (; nBits > 0; exponent = exponent * 256 + buffer[index], index--, nBits -= 8);\n mantissa = exponent & (1 << -nBits) - 1;\n exponent >>= -nBits;\n nBits += mantissaLength;\n for (; nBits > 0; mantissa = mantissa * 256 + buffer[index], index--, nBits -= 8);\n if (exponent === 0) {\n exponent = 1 - eBias;\n } else if (exponent === eMax) {\n return mantissa ? NaN : sign ? -Infinity : Infinity;\n } else {\n mantissa = mantissa + pow(2, mantissaLength);\n exponent = exponent - eBias;\n } return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength);\n};\n\nmodule.exports = {\n pack: pack,\n unpack: unpack\n};\n","'use strict';\nvar global = require('../internals/global');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar NATIVE_ARRAY_BUFFER = require('../internals/array-buffer-native');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar redefineAll = require('../internals/redefine-all');\nvar fails = require('../internals/fails');\nvar anInstance = require('../internals/an-instance');\nvar toInteger = require('../internals/to-integer');\nvar toLength = require('../internals/to-length');\nvar toIndex = require('../internals/to-index');\nvar IEEE754 = require('../internals/ieee754');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\nvar getOwnPropertyNames = require('../internals/object-get-own-property-names').f;\nvar defineProperty = require('../internals/object-define-property').f;\nvar arrayFill = require('../internals/array-fill');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar InternalStateModule = require('../internals/internal-state');\n\nvar getInternalState = InternalStateModule.get;\nvar setInternalState = InternalStateModule.set;\nvar ARRAY_BUFFER = 'ArrayBuffer';\nvar DATA_VIEW = 'DataView';\nvar PROTOTYPE = 'prototype';\nvar WRONG_LENGTH = 'Wrong length';\nvar WRONG_INDEX = 'Wrong index';\nvar NativeArrayBuffer = global[ARRAY_BUFFER];\nvar $ArrayBuffer = NativeArrayBuffer;\nvar $DataView = global[DATA_VIEW];\nvar $DataViewPrototype = $DataView && $DataView[PROTOTYPE];\nvar ObjectPrototype = Object.prototype;\nvar RangeError = global.RangeError;\n\nvar packIEEE754 = IEEE754.pack;\nvar unpackIEEE754 = IEEE754.unpack;\n\nvar packInt8 = function (number) {\n return [number & 0xFF];\n};\n\nvar packInt16 = function (number) {\n return [number & 0xFF, number >> 8 & 0xFF];\n};\n\nvar packInt32 = function (number) {\n return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF];\n};\n\nvar unpackInt32 = function (buffer) {\n return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0];\n};\n\nvar packFloat32 = function (number) {\n return packIEEE754(number, 23, 4);\n};\n\nvar packFloat64 = function (number) {\n return packIEEE754(number, 52, 8);\n};\n\nvar addGetter = function (Constructor, key) {\n defineProperty(Constructor[PROTOTYPE], key, { get: function () { return getInternalState(this)[key]; } });\n};\n\nvar get = function (view, count, index, isLittleEndian) {\n var intIndex = toIndex(index);\n var store = getInternalState(view);\n if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX);\n var bytes = getInternalState(store.buffer).bytes;\n var start = intIndex + store.byteOffset;\n var pack = bytes.slice(start, start + count);\n return isLittleEndian ? pack : pack.reverse();\n};\n\nvar set = function (view, count, index, conversion, value, isLittleEndian) {\n var intIndex = toIndex(index);\n var store = getInternalState(view);\n if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX);\n var bytes = getInternalState(store.buffer).bytes;\n var start = intIndex + store.byteOffset;\n var pack = conversion(+value);\n for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1];\n};\n\nif (!NATIVE_ARRAY_BUFFER) {\n $ArrayBuffer = function ArrayBuffer(length) {\n anInstance(this, $ArrayBuffer, ARRAY_BUFFER);\n var byteLength = toIndex(length);\n setInternalState(this, {\n bytes: arrayFill.call(new Array(byteLength), 0),\n byteLength: byteLength\n });\n if (!DESCRIPTORS) this.byteLength = byteLength;\n };\n\n $DataView = function DataView(buffer, byteOffset, byteLength) {\n anInstance(this, $DataView, DATA_VIEW);\n anInstance(buffer, $ArrayBuffer, DATA_VIEW);\n var bufferLength = getInternalState(buffer).byteLength;\n var offset = toInteger(byteOffset);\n if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset');\n byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength);\n if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH);\n setInternalState(this, {\n buffer: buffer,\n byteLength: byteLength,\n byteOffset: offset\n });\n if (!DESCRIPTORS) {\n this.buffer = buffer;\n this.byteLength = byteLength;\n this.byteOffset = offset;\n }\n };\n\n if (DESCRIPTORS) {\n addGetter($ArrayBuffer, 'byteLength');\n addGetter($DataView, 'buffer');\n addGetter($DataView, 'byteLength');\n addGetter($DataView, 'byteOffset');\n }\n\n redefineAll($DataView[PROTOTYPE], {\n getInt8: function getInt8(byteOffset) {\n return get(this, 1, byteOffset)[0] << 24 >> 24;\n },\n getUint8: function getUint8(byteOffset) {\n return get(this, 1, byteOffset)[0];\n },\n getInt16: function getInt16(byteOffset /* , littleEndian */) {\n var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);\n return (bytes[1] << 8 | bytes[0]) << 16 >> 16;\n },\n getUint16: function getUint16(byteOffset /* , littleEndian */) {\n var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);\n return bytes[1] << 8 | bytes[0];\n },\n getInt32: function getInt32(byteOffset /* , littleEndian */) {\n return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined));\n },\n getUint32: function getUint32(byteOffset /* , littleEndian */) {\n return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0;\n },\n getFloat32: function getFloat32(byteOffset /* , littleEndian */) {\n return unpackIEEE754(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23);\n },\n getFloat64: function getFloat64(byteOffset /* , littleEndian */) {\n return unpackIEEE754(get(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52);\n },\n setInt8: function setInt8(byteOffset, value) {\n set(this, 1, byteOffset, packInt8, value);\n },\n setUint8: function setUint8(byteOffset, value) {\n set(this, 1, byteOffset, packInt8, value);\n },\n setInt16: function setInt16(byteOffset, value /* , littleEndian */) {\n set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined);\n },\n setUint16: function setUint16(byteOffset, value /* , littleEndian */) {\n set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined);\n },\n setInt32: function setInt32(byteOffset, value /* , littleEndian */) {\n set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined);\n },\n setUint32: function setUint32(byteOffset, value /* , littleEndian */) {\n set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined);\n },\n setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) {\n set(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined);\n },\n setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) {\n set(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined);\n }\n });\n} else {\n if (!fails(function () {\n NativeArrayBuffer(1);\n }) || !fails(function () {\n new NativeArrayBuffer(-1); // eslint-disable-line no-new\n }) || fails(function () {\n new NativeArrayBuffer(); // eslint-disable-line no-new\n new NativeArrayBuffer(1.5); // eslint-disable-line no-new\n new NativeArrayBuffer(NaN); // eslint-disable-line no-new\n return NativeArrayBuffer.name != ARRAY_BUFFER;\n })) {\n $ArrayBuffer = function ArrayBuffer(length) {\n anInstance(this, $ArrayBuffer);\n return new NativeArrayBuffer(toIndex(length));\n };\n var ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE] = NativeArrayBuffer[PROTOTYPE];\n for (var keys = getOwnPropertyNames(NativeArrayBuffer), j = 0, key; keys.length > j;) {\n if (!((key = keys[j++]) in $ArrayBuffer)) {\n createNonEnumerableProperty($ArrayBuffer, key, NativeArrayBuffer[key]);\n }\n }\n ArrayBufferPrototype.constructor = $ArrayBuffer;\n }\n\n // WebKit bug - the same parent prototype for typed arrays and data view\n if (setPrototypeOf && getPrototypeOf($DataViewPrototype) !== ObjectPrototype) {\n setPrototypeOf($DataViewPrototype, ObjectPrototype);\n }\n\n // iOS Safari 7.x bug\n var testView = new $DataView(new $ArrayBuffer(2));\n var nativeSetInt8 = $DataViewPrototype.setInt8;\n testView.setInt8(0, 2147483648);\n testView.setInt8(1, 2147483649);\n if (testView.getInt8(0) || !testView.getInt8(1)) redefineAll($DataViewPrototype, {\n setInt8: function setInt8(byteOffset, value) {\n nativeSetInt8.call(this, byteOffset, value << 24 >> 24);\n },\n setUint8: function setUint8(byteOffset, value) {\n nativeSetInt8.call(this, byteOffset, value << 24 >> 24);\n }\n }, { unsafe: true });\n}\n\nsetToStringTag($ArrayBuffer, ARRAY_BUFFER);\nsetToStringTag($DataView, DATA_VIEW);\n\nmodule.exports = {\n ArrayBuffer: $ArrayBuffer,\n DataView: $DataView\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar global = require('../internals/global');\nvar arrayBufferModule = require('../internals/array-buffer');\nvar setSpecies = require('../internals/set-species');\n\nvar ARRAY_BUFFER = 'ArrayBuffer';\nvar ArrayBuffer = arrayBufferModule[ARRAY_BUFFER];\nvar NativeArrayBuffer = global[ARRAY_BUFFER];\n\n// `ArrayBuffer` constructor\n// https://tc39.github.io/ecma262/#sec-arraybuffer-constructor\n$({ global: true, forced: NativeArrayBuffer !== ArrayBuffer }, {\n ArrayBuffer: ArrayBuffer\n});\n\nsetSpecies(ARRAY_BUFFER);\n","'use strict';\nvar NATIVE_ARRAY_BUFFER = require('../internals/array-buffer-native');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar global = require('../internals/global');\nvar isObject = require('../internals/is-object');\nvar has = require('../internals/has');\nvar classof = require('../internals/classof');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar redefine = require('../internals/redefine');\nvar defineProperty = require('../internals/object-define-property').f;\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar uid = require('../internals/uid');\n\nvar Int8Array = global.Int8Array;\nvar Int8ArrayPrototype = Int8Array && Int8Array.prototype;\nvar Uint8ClampedArray = global.Uint8ClampedArray;\nvar Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype;\nvar TypedArray = Int8Array && getPrototypeOf(Int8Array);\nvar TypedArrayPrototype = Int8ArrayPrototype && getPrototypeOf(Int8ArrayPrototype);\nvar ObjectPrototype = Object.prototype;\nvar isPrototypeOf = ObjectPrototype.isPrototypeOf;\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\nvar TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG');\n// Fixing native typed arrays in Opera Presto crashes the browser, see #595\nvar NATIVE_ARRAY_BUFFER_VIEWS = NATIVE_ARRAY_BUFFER && !!setPrototypeOf && classof(global.opera) !== 'Opera';\nvar TYPED_ARRAY_TAG_REQIRED = false;\nvar NAME;\n\nvar TypedArrayConstructorsList = {\n Int8Array: 1,\n Uint8Array: 1,\n Uint8ClampedArray: 1,\n Int16Array: 2,\n Uint16Array: 2,\n Int32Array: 4,\n Uint32Array: 4,\n Float32Array: 4,\n Float64Array: 8\n};\n\nvar isView = function isView(it) {\n var klass = classof(it);\n return klass === 'DataView' || has(TypedArrayConstructorsList, klass);\n};\n\nvar isTypedArray = function (it) {\n return isObject(it) && has(TypedArrayConstructorsList, classof(it));\n};\n\nvar aTypedArray = function (it) {\n if (isTypedArray(it)) return it;\n throw TypeError('Target is not a typed array');\n};\n\nvar aTypedArrayConstructor = function (C) {\n if (setPrototypeOf) {\n if (isPrototypeOf.call(TypedArray, C)) return C;\n } else for (var ARRAY in TypedArrayConstructorsList) if (has(TypedArrayConstructorsList, NAME)) {\n var TypedArrayConstructor = global[ARRAY];\n if (TypedArrayConstructor && (C === TypedArrayConstructor || isPrototypeOf.call(TypedArrayConstructor, C))) {\n return C;\n }\n } throw TypeError('Target is not a typed array constructor');\n};\n\nvar exportTypedArrayMethod = function (KEY, property, forced) {\n if (!DESCRIPTORS) return;\n if (forced) for (var ARRAY in TypedArrayConstructorsList) {\n var TypedArrayConstructor = global[ARRAY];\n if (TypedArrayConstructor && has(TypedArrayConstructor.prototype, KEY)) {\n delete TypedArrayConstructor.prototype[KEY];\n }\n }\n if (!TypedArrayPrototype[KEY] || forced) {\n redefine(TypedArrayPrototype, KEY, forced ? property\n : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property);\n }\n};\n\nvar exportTypedArrayStaticMethod = function (KEY, property, forced) {\n var ARRAY, TypedArrayConstructor;\n if (!DESCRIPTORS) return;\n if (setPrototypeOf) {\n if (forced) for (ARRAY in TypedArrayConstructorsList) {\n TypedArrayConstructor = global[ARRAY];\n if (TypedArrayConstructor && has(TypedArrayConstructor, KEY)) {\n delete TypedArrayConstructor[KEY];\n }\n }\n if (!TypedArray[KEY] || forced) {\n // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable\n try {\n return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8Array[KEY] || property);\n } catch (error) { /* empty */ }\n } else return;\n }\n for (ARRAY in TypedArrayConstructorsList) {\n TypedArrayConstructor = global[ARRAY];\n if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) {\n redefine(TypedArrayConstructor, KEY, property);\n }\n }\n};\n\nfor (NAME in TypedArrayConstructorsList) {\n if (!global[NAME]) NATIVE_ARRAY_BUFFER_VIEWS = false;\n}\n\n// WebKit bug - typed arrays constructors prototype is Object.prototype\nif (!NATIVE_ARRAY_BUFFER_VIEWS || typeof TypedArray != 'function' || TypedArray === Function.prototype) {\n // eslint-disable-next-line no-shadow\n TypedArray = function TypedArray() {\n throw TypeError('Incorrect invocation');\n };\n if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) {\n if (global[NAME]) setPrototypeOf(global[NAME], TypedArray);\n }\n}\n\nif (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype) {\n TypedArrayPrototype = TypedArray.prototype;\n if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) {\n if (global[NAME]) setPrototypeOf(global[NAME].prototype, TypedArrayPrototype);\n }\n}\n\n// WebKit bug - one more object in Uint8ClampedArray prototype chain\nif (NATIVE_ARRAY_BUFFER_VIEWS && getPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) {\n setPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype);\n}\n\nif (DESCRIPTORS && !has(TypedArrayPrototype, TO_STRING_TAG)) {\n TYPED_ARRAY_TAG_REQIRED = true;\n defineProperty(TypedArrayPrototype, TO_STRING_TAG, { get: function () {\n return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined;\n } });\n for (NAME in TypedArrayConstructorsList) if (global[NAME]) {\n createNonEnumerableProperty(global[NAME], TYPED_ARRAY_TAG, NAME);\n }\n}\n\nmodule.exports = {\n NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS,\n TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG,\n aTypedArray: aTypedArray,\n aTypedArrayConstructor: aTypedArrayConstructor,\n exportTypedArrayMethod: exportTypedArrayMethod,\n exportTypedArrayStaticMethod: exportTypedArrayStaticMethod,\n isView: isView,\n isTypedArray: isTypedArray,\n TypedArray: TypedArray,\n TypedArrayPrototype: TypedArrayPrototype\n};\n","var $ = require('../internals/export');\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\n\nvar NATIVE_ARRAY_BUFFER_VIEWS = ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS;\n\n// `ArrayBuffer.isView` method\n// https://tc39.github.io/ecma262/#sec-arraybuffer.isview\n$({ target: 'ArrayBuffer', stat: true, forced: !NATIVE_ARRAY_BUFFER_VIEWS }, {\n isView: ArrayBufferViewCore.isView\n});\n","var anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar SPECIES = wellKnownSymbol('species');\n\n// `SpeciesConstructor` abstract operation\n// https://tc39.github.io/ecma262/#sec-speciesconstructor\nmodule.exports = function (O, defaultConstructor) {\n var C = anObject(O).constructor;\n var S;\n return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aFunction(S);\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar ArrayBufferModule = require('../internals/array-buffer');\nvar anObject = require('../internals/an-object');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\nvar toLength = require('../internals/to-length');\nvar speciesConstructor = require('../internals/species-constructor');\n\nvar ArrayBuffer = ArrayBufferModule.ArrayBuffer;\nvar DataView = ArrayBufferModule.DataView;\nvar nativeArrayBufferSlice = ArrayBuffer.prototype.slice;\n\nvar INCORRECT_SLICE = fails(function () {\n return !new ArrayBuffer(2).slice(1, undefined).byteLength;\n});\n\n// `ArrayBuffer.prototype.slice` method\n// https://tc39.github.io/ecma262/#sec-arraybuffer.prototype.slice\n$({ target: 'ArrayBuffer', proto: true, unsafe: true, forced: INCORRECT_SLICE }, {\n slice: function slice(start, end) {\n if (nativeArrayBufferSlice !== undefined && end === undefined) {\n return nativeArrayBufferSlice.call(anObject(this), start); // FF fix\n }\n var length = anObject(this).byteLength;\n var first = toAbsoluteIndex(start, length);\n var fin = toAbsoluteIndex(end === undefined ? length : end, length);\n var result = new (speciesConstructor(this, ArrayBuffer))(toLength(fin - first));\n var viewSource = new DataView(this);\n var viewTarget = new DataView(result);\n var index = 0;\n while (first < fin) {\n viewTarget.setUint8(index++, viewSource.getUint8(first++));\n } return result;\n }\n});\n","var $ = require('../internals/export');\nvar ArrayBufferModule = require('../internals/array-buffer');\nvar NATIVE_ARRAY_BUFFER = require('../internals/array-buffer-native');\n\n// `DataView` constructor\n// https://tc39.github.io/ecma262/#sec-dataview-constructor\n$({ global: true, forced: !NATIVE_ARRAY_BUFFER }, {\n DataView: ArrayBufferModule.DataView\n});\n","var $ = require('../internals/export');\n\n// `Date.now` method\n// https://tc39.github.io/ecma262/#sec-date.now\n$({ target: 'Date', stat: true }, {\n now: function now() {\n return new Date().getTime();\n }\n});\n","'use strict';\nvar toInteger = require('../internals/to-integer');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\n\n// `String.prototype.repeat` method implementation\n// https://tc39.github.io/ecma262/#sec-string.prototype.repeat\nmodule.exports = ''.repeat || function repeat(count) {\n var str = String(requireObjectCoercible(this));\n var result = '';\n var n = toInteger(count);\n if (n < 0 || n == Infinity) throw RangeError('Wrong number of repetitions');\n for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str;\n return result;\n};\n","// https://github.com/tc39/proposal-string-pad-start-end\nvar toLength = require('../internals/to-length');\nvar repeat = require('../internals/string-repeat');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\n\nvar ceil = Math.ceil;\n\n// `String.prototype.{ padStart, padEnd }` methods implementation\nvar createMethod = function (IS_END) {\n return function ($this, maxLength, fillString) {\n var S = String(requireObjectCoercible($this));\n var stringLength = S.length;\n var fillStr = fillString === undefined ? ' ' : String(fillString);\n var intMaxLength = toLength(maxLength);\n var fillLen, stringFiller;\n if (intMaxLength <= stringLength || fillStr == '') return S;\n fillLen = intMaxLength - stringLength;\n stringFiller = repeat.call(fillStr, ceil(fillLen / fillStr.length));\n if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen);\n return IS_END ? S + stringFiller : stringFiller + S;\n };\n};\n\nmodule.exports = {\n // `String.prototype.padStart` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.padstart\n start: createMethod(false),\n // `String.prototype.padEnd` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.padend\n end: createMethod(true)\n};\n","'use strict';\nvar fails = require('../internals/fails');\nvar padStart = require('../internals/string-pad').start;\n\nvar abs = Math.abs;\nvar DatePrototype = Date.prototype;\nvar getTime = DatePrototype.getTime;\nvar nativeDateToISOString = DatePrototype.toISOString;\n\n// `Date.prototype.toISOString` method implementation\n// https://tc39.github.io/ecma262/#sec-date.prototype.toisostring\n// PhantomJS / old WebKit fails here:\nmodule.exports = (fails(function () {\n return nativeDateToISOString.call(new Date(-5e13 - 1)) != '0385-07-25T07:06:39.999Z';\n}) || !fails(function () {\n nativeDateToISOString.call(new Date(NaN));\n})) ? function toISOString() {\n if (!isFinite(getTime.call(this))) throw RangeError('Invalid time value');\n var date = this;\n var year = date.getUTCFullYear();\n var milliseconds = date.getUTCMilliseconds();\n var sign = year < 0 ? '-' : year > 9999 ? '+' : '';\n return sign + padStart(abs(year), sign ? 6 : 4, 0) +\n '-' + padStart(date.getUTCMonth() + 1, 2, 0) +\n '-' + padStart(date.getUTCDate(), 2, 0) +\n 'T' + padStart(date.getUTCHours(), 2, 0) +\n ':' + padStart(date.getUTCMinutes(), 2, 0) +\n ':' + padStart(date.getUTCSeconds(), 2, 0) +\n '.' + padStart(milliseconds, 3, 0) +\n 'Z';\n} : nativeDateToISOString;\n","var $ = require('../internals/export');\nvar toISOString = require('../internals/date-to-iso-string');\n\n// `Date.prototype.toISOString` method\n// https://tc39.github.io/ecma262/#sec-date.prototype.toisostring\n// PhantomJS / old WebKit has a broken implementations\n$({ target: 'Date', proto: true, forced: Date.prototype.toISOString !== toISOString }, {\n toISOString: toISOString\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar toObject = require('../internals/to-object');\nvar toPrimitive = require('../internals/to-primitive');\n\nvar FORCED = fails(function () {\n return new Date(NaN).toJSON() !== null\n || Date.prototype.toJSON.call({ toISOString: function () { return 1; } }) !== 1;\n});\n\n// `Date.prototype.toJSON` method\n// https://tc39.github.io/ecma262/#sec-date.prototype.tojson\n$({ target: 'Date', proto: true, forced: FORCED }, {\n // eslint-disable-next-line no-unused-vars\n toJSON: function toJSON(key) {\n var O = toObject(this);\n var pv = toPrimitive(O);\n return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString();\n }\n});\n","'use strict';\nvar anObject = require('../internals/an-object');\nvar toPrimitive = require('../internals/to-primitive');\n\nmodule.exports = function (hint) {\n if (hint !== 'string' && hint !== 'number' && hint !== 'default') {\n throw TypeError('Incorrect hint');\n } return toPrimitive(anObject(this), hint !== 'number');\n};\n","var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar dateToPrimitive = require('../internals/date-to-primitive');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar TO_PRIMITIVE = wellKnownSymbol('toPrimitive');\nvar DatePrototype = Date.prototype;\n\n// `Date.prototype[@@toPrimitive]` method\n// https://tc39.github.io/ecma262/#sec-date.prototype-@@toprimitive\nif (!(TO_PRIMITIVE in DatePrototype)) {\n createNonEnumerableProperty(DatePrototype, TO_PRIMITIVE, dateToPrimitive);\n}\n","var redefine = require('../internals/redefine');\n\nvar DatePrototype = Date.prototype;\nvar INVALID_DATE = 'Invalid Date';\nvar TO_STRING = 'toString';\nvar nativeDateToString = DatePrototype[TO_STRING];\nvar getTime = DatePrototype.getTime;\n\n// `Date.prototype.toString` method\n// https://tc39.github.io/ecma262/#sec-date.prototype.tostring\nif (new Date(NaN) + '' != INVALID_DATE) {\n redefine(DatePrototype, TO_STRING, function toString() {\n var value = getTime.call(this);\n // eslint-disable-next-line no-self-compare\n return value === value ? nativeDateToString.call(this) : INVALID_DATE;\n });\n}\n","'use strict';\nvar aFunction = require('../internals/a-function');\nvar isObject = require('../internals/is-object');\n\nvar slice = [].slice;\nvar factories = {};\n\nvar construct = function (C, argsLength, args) {\n if (!(argsLength in factories)) {\n for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';\n // eslint-disable-next-line no-new-func\n factories[argsLength] = Function('C,a', 'return new C(' + list.join(',') + ')');\n } return factories[argsLength](C, args);\n};\n\n// `Function.prototype.bind` method implementation\n// https://tc39.github.io/ecma262/#sec-function.prototype.bind\nmodule.exports = Function.bind || function bind(that /* , ...args */) {\n var fn = aFunction(this);\n var partArgs = slice.call(arguments, 1);\n var boundFunction = function bound(/* args... */) {\n var args = partArgs.concat(slice.call(arguments));\n return this instanceof boundFunction ? construct(fn, args.length, args) : fn.apply(that, args);\n };\n if (isObject(fn.prototype)) boundFunction.prototype = fn.prototype;\n return boundFunction;\n};\n","var $ = require('../internals/export');\nvar bind = require('../internals/function-bind');\n\n// `Function.prototype.bind` method\n// https://tc39.github.io/ecma262/#sec-function.prototype.bind\n$({ target: 'Function', proto: true }, {\n bind: bind\n});\n","'use strict';\nvar isObject = require('../internals/is-object');\nvar definePropertyModule = require('../internals/object-define-property');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar HAS_INSTANCE = wellKnownSymbol('hasInstance');\nvar FunctionPrototype = Function.prototype;\n\n// `Function.prototype[@@hasInstance]` method\n// https://tc39.github.io/ecma262/#sec-function.prototype-@@hasinstance\nif (!(HAS_INSTANCE in FunctionPrototype)) {\n definePropertyModule.f(FunctionPrototype, HAS_INSTANCE, { value: function (O) {\n if (typeof this != 'function' || !isObject(O)) return false;\n if (!isObject(this.prototype)) return O instanceof this;\n // for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:\n while (O = getPrototypeOf(O)) if (this.prototype === O) return true;\n return false;\n } });\n}\n","var DESCRIPTORS = require('../internals/descriptors');\nvar defineProperty = require('../internals/object-define-property').f;\n\nvar FunctionPrototype = Function.prototype;\nvar FunctionPrototypeToString = FunctionPrototype.toString;\nvar nameRE = /^\\s*function ([^ (]*)/;\nvar NAME = 'name';\n\n// Function instances `.name` property\n// https://tc39.github.io/ecma262/#sec-function-instances-name\nif (DESCRIPTORS && !(NAME in FunctionPrototype)) {\n defineProperty(FunctionPrototype, NAME, {\n configurable: true,\n get: function () {\n try {\n return FunctionPrototypeToString.call(this).match(nameRE)[1];\n } catch (error) {\n return '';\n }\n }\n });\n}\n","var $ = require('../internals/export');\nvar global = require('../internals/global');\n\n// `globalThis` object\n// https://github.com/tc39/proposal-global\n$({ global: true }, {\n globalThis: global\n});\n","var $ = require('../internals/export');\nvar getBuiltIn = require('../internals/get-built-in');\nvar fails = require('../internals/fails');\n\nvar $stringify = getBuiltIn('JSON', 'stringify');\nvar re = /[\\uD800-\\uDFFF]/g;\nvar low = /^[\\uD800-\\uDBFF]$/;\nvar hi = /^[\\uDC00-\\uDFFF]$/;\n\nvar fix = function (match, offset, string) {\n var prev = string.charAt(offset - 1);\n var next = string.charAt(offset + 1);\n if ((low.test(match) && !hi.test(next)) || (hi.test(match) && !low.test(prev))) {\n return '\\\\u' + match.charCodeAt(0).toString(16);\n } return match;\n};\n\nvar FORCED = fails(function () {\n return $stringify('\\uDF06\\uD834') !== '\"\\\\udf06\\\\ud834\"'\n || $stringify('\\uDEAD') !== '\"\\\\udead\"';\n});\n\nif ($stringify) {\n // https://github.com/tc39/proposal-well-formed-stringify\n $({ target: 'JSON', stat: true, forced: FORCED }, {\n // eslint-disable-next-line no-unused-vars\n stringify: function stringify(it, replacer, space) {\n var result = $stringify.apply(null, arguments);\n return typeof result == 'string' ? result.replace(re, fix) : result;\n }\n });\n}\n","var global = require('../internals/global');\nvar setToStringTag = require('../internals/set-to-string-tag');\n\n// JSON[@@toStringTag] property\n// https://tc39.github.io/ecma262/#sec-json-@@tostringtag\nsetToStringTag(global.JSON, 'JSON', true);\n","var fails = require('../internals/fails');\n\nmodule.exports = !fails(function () {\n return Object.isExtensible(Object.preventExtensions({}));\n});\n","var hiddenKeys = require('../internals/hidden-keys');\nvar isObject = require('../internals/is-object');\nvar has = require('../internals/has');\nvar defineProperty = require('../internals/object-define-property').f;\nvar uid = require('../internals/uid');\nvar FREEZING = require('../internals/freezing');\n\nvar METADATA = uid('meta');\nvar id = 0;\n\nvar isExtensible = Object.isExtensible || function () {\n return true;\n};\n\nvar setMetadata = function (it) {\n defineProperty(it, METADATA, { value: {\n objectID: 'O' + ++id, // object ID\n weakData: {} // weak collections IDs\n } });\n};\n\nvar fastKey = function (it, create) {\n // return a primitive with prefix\n if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;\n if (!has(it, METADATA)) {\n // can't set metadata to uncaught frozen object\n if (!isExtensible(it)) return 'F';\n // not necessary to add metadata\n if (!create) return 'E';\n // add missing metadata\n setMetadata(it);\n // return object ID\n } return it[METADATA].objectID;\n};\n\nvar getWeakData = function (it, create) {\n if (!has(it, METADATA)) {\n // can't set metadata to uncaught frozen object\n if (!isExtensible(it)) return true;\n // not necessary to add metadata\n if (!create) return false;\n // add missing metadata\n setMetadata(it);\n // return the store of weak collections IDs\n } return it[METADATA].weakData;\n};\n\n// add metadata on freeze-family methods calling\nvar onFreeze = function (it) {\n if (FREEZING && meta.REQUIRED && isExtensible(it) && !has(it, METADATA)) setMetadata(it);\n return it;\n};\n\nvar meta = module.exports = {\n REQUIRED: false,\n fastKey: fastKey,\n getWeakData: getWeakData,\n onFreeze: onFreeze\n};\n\nhiddenKeys[METADATA] = true;\n","var anObject = require('../internals/an-object');\nvar isArrayIteratorMethod = require('../internals/is-array-iterator-method');\nvar toLength = require('../internals/to-length');\nvar bind = require('../internals/function-bind-context');\nvar getIteratorMethod = require('../internals/get-iterator-method');\nvar callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');\n\nvar Result = function (stopped, result) {\n this.stopped = stopped;\n this.result = result;\n};\n\nvar iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITERATOR) {\n var boundFunction = bind(fn, that, AS_ENTRIES ? 2 : 1);\n var iterator, iterFn, index, length, result, next, step;\n\n if (IS_ITERATOR) {\n iterator = iterable;\n } else {\n iterFn = getIteratorMethod(iterable);\n if (typeof iterFn != 'function') throw TypeError('Target is not iterable');\n // optimisation for array iterators\n if (isArrayIteratorMethod(iterFn)) {\n for (index = 0, length = toLength(iterable.length); length > index; index++) {\n result = AS_ENTRIES\n ? boundFunction(anObject(step = iterable[index])[0], step[1])\n : boundFunction(iterable[index]);\n if (result && result instanceof Result) return result;\n } return new Result(false);\n }\n iterator = iterFn.call(iterable);\n }\n\n next = iterator.next;\n while (!(step = next.call(iterator)).done) {\n result = callWithSafeIterationClosing(iterator, boundFunction, step.value, AS_ENTRIES);\n if (typeof result == 'object' && result && result instanceof Result) return result;\n } return new Result(false);\n};\n\niterate.stop = function (result) {\n return new Result(true, result);\n};\n","var isObject = require('../internals/is-object');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\n\n// makes subclassing work correct for wrapped built-ins\nmodule.exports = function ($this, dummy, Wrapper) {\n var NewTarget, NewTargetPrototype;\n if (\n // it can work only with native `setPrototypeOf`\n setPrototypeOf &&\n // we haven't completely correct pre-ES6 way for getting `new.target`, so use this\n typeof (NewTarget = dummy.constructor) == 'function' &&\n NewTarget !== Wrapper &&\n isObject(NewTargetPrototype = NewTarget.prototype) &&\n NewTargetPrototype !== Wrapper.prototype\n ) setPrototypeOf($this, NewTargetPrototype);\n return $this;\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar global = require('../internals/global');\nvar isForced = require('../internals/is-forced');\nvar redefine = require('../internals/redefine');\nvar InternalMetadataModule = require('../internals/internal-metadata');\nvar iterate = require('../internals/iterate');\nvar anInstance = require('../internals/an-instance');\nvar isObject = require('../internals/is-object');\nvar fails = require('../internals/fails');\nvar checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar inheritIfRequired = require('../internals/inherit-if-required');\n\nmodule.exports = function (CONSTRUCTOR_NAME, wrapper, common) {\n var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;\n var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;\n var ADDER = IS_MAP ? 'set' : 'add';\n var NativeConstructor = global[CONSTRUCTOR_NAME];\n var NativePrototype = NativeConstructor && NativeConstructor.prototype;\n var Constructor = NativeConstructor;\n var exported = {};\n\n var fixMethod = function (KEY) {\n var nativeMethod = NativePrototype[KEY];\n redefine(NativePrototype, KEY,\n KEY == 'add' ? function add(value) {\n nativeMethod.call(this, value === 0 ? 0 : value);\n return this;\n } : KEY == 'delete' ? function (key) {\n return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);\n } : KEY == 'get' ? function get(key) {\n return IS_WEAK && !isObject(key) ? undefined : nativeMethod.call(this, key === 0 ? 0 : key);\n } : KEY == 'has' ? function has(key) {\n return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);\n } : function set(key, value) {\n nativeMethod.call(this, key === 0 ? 0 : key, value);\n return this;\n }\n );\n };\n\n // eslint-disable-next-line max-len\n if (isForced(CONSTRUCTOR_NAME, typeof NativeConstructor != 'function' || !(IS_WEAK || NativePrototype.forEach && !fails(function () {\n new NativeConstructor().entries().next();\n })))) {\n // create collection constructor\n Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);\n InternalMetadataModule.REQUIRED = true;\n } else if (isForced(CONSTRUCTOR_NAME, true)) {\n var instance = new Constructor();\n // early implementations not supports chaining\n var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;\n // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false\n var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); });\n // most early implementations doesn't supports iterables, most modern - not close it correctly\n // eslint-disable-next-line no-new\n var ACCEPT_ITERABLES = checkCorrectnessOfIteration(function (iterable) { new NativeConstructor(iterable); });\n // for early implementations -0 and +0 not the same\n var BUGGY_ZERO = !IS_WEAK && fails(function () {\n // V8 ~ Chromium 42- fails only with 5+ elements\n var $instance = new NativeConstructor();\n var index = 5;\n while (index--) $instance[ADDER](index, index);\n return !$instance.has(-0);\n });\n\n if (!ACCEPT_ITERABLES) {\n Constructor = wrapper(function (dummy, iterable) {\n anInstance(dummy, Constructor, CONSTRUCTOR_NAME);\n var that = inheritIfRequired(new NativeConstructor(), dummy, Constructor);\n if (iterable != undefined) iterate(iterable, that[ADDER], that, IS_MAP);\n return that;\n });\n Constructor.prototype = NativePrototype;\n NativePrototype.constructor = Constructor;\n }\n\n if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {\n fixMethod('delete');\n fixMethod('has');\n IS_MAP && fixMethod('get');\n }\n\n if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);\n\n // weak collections should not contains .clear method\n if (IS_WEAK && NativePrototype.clear) delete NativePrototype.clear;\n }\n\n exported[CONSTRUCTOR_NAME] = Constructor;\n $({ global: true, forced: Constructor != NativeConstructor }, exported);\n\n setToStringTag(Constructor, CONSTRUCTOR_NAME);\n\n if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);\n\n return Constructor;\n};\n","'use strict';\nvar defineProperty = require('../internals/object-define-property').f;\nvar create = require('../internals/object-create');\nvar redefineAll = require('../internals/redefine-all');\nvar bind = require('../internals/function-bind-context');\nvar anInstance = require('../internals/an-instance');\nvar iterate = require('../internals/iterate');\nvar defineIterator = require('../internals/define-iterator');\nvar setSpecies = require('../internals/set-species');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar fastKey = require('../internals/internal-metadata').fastKey;\nvar InternalStateModule = require('../internals/internal-state');\n\nvar setInternalState = InternalStateModule.set;\nvar internalStateGetterFor = InternalStateModule.getterFor;\n\nmodule.exports = {\n getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {\n var C = wrapper(function (that, iterable) {\n anInstance(that, C, CONSTRUCTOR_NAME);\n setInternalState(that, {\n type: CONSTRUCTOR_NAME,\n index: create(null),\n first: undefined,\n last: undefined,\n size: 0\n });\n if (!DESCRIPTORS) that.size = 0;\n if (iterable != undefined) iterate(iterable, that[ADDER], that, IS_MAP);\n });\n\n var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);\n\n var define = function (that, key, value) {\n var state = getInternalState(that);\n var entry = getEntry(that, key);\n var previous, index;\n // change existing entry\n if (entry) {\n entry.value = value;\n // create new entry\n } else {\n state.last = entry = {\n index: index = fastKey(key, true),\n key: key,\n value: value,\n previous: previous = state.last,\n next: undefined,\n removed: false\n };\n if (!state.first) state.first = entry;\n if (previous) previous.next = entry;\n if (DESCRIPTORS) state.size++;\n else that.size++;\n // add to index\n if (index !== 'F') state.index[index] = entry;\n } return that;\n };\n\n var getEntry = function (that, key) {\n var state = getInternalState(that);\n // fast case\n var index = fastKey(key);\n var entry;\n if (index !== 'F') return state.index[index];\n // frozen object case\n for (entry = state.first; entry; entry = entry.next) {\n if (entry.key == key) return entry;\n }\n };\n\n redefineAll(C.prototype, {\n // 23.1.3.1 Map.prototype.clear()\n // 23.2.3.2 Set.prototype.clear()\n clear: function clear() {\n var that = this;\n var state = getInternalState(that);\n var data = state.index;\n var entry = state.first;\n while (entry) {\n entry.removed = true;\n if (entry.previous) entry.previous = entry.previous.next = undefined;\n delete data[entry.index];\n entry = entry.next;\n }\n state.first = state.last = undefined;\n if (DESCRIPTORS) state.size = 0;\n else that.size = 0;\n },\n // 23.1.3.3 Map.prototype.delete(key)\n // 23.2.3.4 Set.prototype.delete(value)\n 'delete': function (key) {\n var that = this;\n var state = getInternalState(that);\n var entry = getEntry(that, key);\n if (entry) {\n var next = entry.next;\n var prev = entry.previous;\n delete state.index[entry.index];\n entry.removed = true;\n if (prev) prev.next = next;\n if (next) next.previous = prev;\n if (state.first == entry) state.first = next;\n if (state.last == entry) state.last = prev;\n if (DESCRIPTORS) state.size--;\n else that.size--;\n } return !!entry;\n },\n // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)\n // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)\n forEach: function forEach(callbackfn /* , that = undefined */) {\n var state = getInternalState(this);\n var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n var entry;\n while (entry = entry ? entry.next : state.first) {\n boundFunction(entry.value, entry.key, this);\n // revert to the last existing entry\n while (entry && entry.removed) entry = entry.previous;\n }\n },\n // 23.1.3.7 Map.prototype.has(key)\n // 23.2.3.7 Set.prototype.has(value)\n has: function has(key) {\n return !!getEntry(this, key);\n }\n });\n\n redefineAll(C.prototype, IS_MAP ? {\n // 23.1.3.6 Map.prototype.get(key)\n get: function get(key) {\n var entry = getEntry(this, key);\n return entry && entry.value;\n },\n // 23.1.3.9 Map.prototype.set(key, value)\n set: function set(key, value) {\n return define(this, key === 0 ? 0 : key, value);\n }\n } : {\n // 23.2.3.1 Set.prototype.add(value)\n add: function add(value) {\n return define(this, value = value === 0 ? 0 : value, value);\n }\n });\n if (DESCRIPTORS) defineProperty(C.prototype, 'size', {\n get: function () {\n return getInternalState(this).size;\n }\n });\n return C;\n },\n setStrong: function (C, CONSTRUCTOR_NAME, IS_MAP) {\n var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';\n var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);\n var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME);\n // add .keys, .values, .entries, [@@iterator]\n // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11\n defineIterator(C, CONSTRUCTOR_NAME, function (iterated, kind) {\n setInternalState(this, {\n type: ITERATOR_NAME,\n target: iterated,\n state: getInternalCollectionState(iterated),\n kind: kind,\n last: undefined\n });\n }, function () {\n var state = getInternalIteratorState(this);\n var kind = state.kind;\n var entry = state.last;\n // revert to the last existing entry\n while (entry && entry.removed) entry = entry.previous;\n // get next entry\n if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {\n // or finish the iteration\n state.target = undefined;\n return { value: undefined, done: true };\n }\n // return step by kind\n if (kind == 'keys') return { value: entry.key, done: false };\n if (kind == 'values') return { value: entry.value, done: false };\n return { value: [entry.key, entry.value], done: false };\n }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);\n\n // add [@@species], 23.1.2.2, 23.2.2.2\n setSpecies(CONSTRUCTOR_NAME);\n }\n};\n","'use strict';\nvar collection = require('../internals/collection');\nvar collectionStrong = require('../internals/collection-strong');\n\n// `Map` constructor\n// https://tc39.github.io/ecma262/#sec-map-objects\nmodule.exports = collection('Map', function (init) {\n return function Map() { return init(this, arguments.length ? arguments[0] : undefined); };\n}, collectionStrong);\n","var log = Math.log;\n\n// `Math.log1p` method implementation\n// https://tc39.github.io/ecma262/#sec-math.log1p\nmodule.exports = Math.log1p || function log1p(x) {\n return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : log(1 + x);\n};\n","var $ = require('../internals/export');\nvar log1p = require('../internals/math-log1p');\n\nvar nativeAcosh = Math.acosh;\nvar log = Math.log;\nvar sqrt = Math.sqrt;\nvar LN2 = Math.LN2;\n\nvar FORCED = !nativeAcosh\n // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509\n || Math.floor(nativeAcosh(Number.MAX_VALUE)) != 710\n // Tor Browser bug: Math.acosh(Infinity) -> NaN\n || nativeAcosh(Infinity) != Infinity;\n\n// `Math.acosh` method\n// https://tc39.github.io/ecma262/#sec-math.acosh\n$({ target: 'Math', stat: true, forced: FORCED }, {\n acosh: function acosh(x) {\n return (x = +x) < 1 ? NaN : x > 94906265.62425156\n ? log(x) + LN2\n : log1p(x - 1 + sqrt(x - 1) * sqrt(x + 1));\n }\n});\n","var $ = require('../internals/export');\n\nvar nativeAsinh = Math.asinh;\nvar log = Math.log;\nvar sqrt = Math.sqrt;\n\nfunction asinh(x) {\n return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : log(x + sqrt(x * x + 1));\n}\n\n// `Math.asinh` method\n// https://tc39.github.io/ecma262/#sec-math.asinh\n// Tor Browser bug: Math.asinh(0) -> -0\n$({ target: 'Math', stat: true, forced: !(nativeAsinh && 1 / nativeAsinh(0) > 0) }, {\n asinh: asinh\n});\n","var $ = require('../internals/export');\n\nvar nativeAtanh = Math.atanh;\nvar log = Math.log;\n\n// `Math.atanh` method\n// https://tc39.github.io/ecma262/#sec-math.atanh\n// Tor Browser bug: Math.atanh(-0) -> 0\n$({ target: 'Math', stat: true, forced: !(nativeAtanh && 1 / nativeAtanh(-0) < 0) }, {\n atanh: function atanh(x) {\n return (x = +x) == 0 ? x : log((1 + x) / (1 - x)) / 2;\n }\n});\n","// `Math.sign` method implementation\n// https://tc39.github.io/ecma262/#sec-math.sign\nmodule.exports = Math.sign || function sign(x) {\n // eslint-disable-next-line no-self-compare\n return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;\n};\n","var $ = require('../internals/export');\nvar sign = require('../internals/math-sign');\n\nvar abs = Math.abs;\nvar pow = Math.pow;\n\n// `Math.cbrt` method\n// https://tc39.github.io/ecma262/#sec-math.cbrt\n$({ target: 'Math', stat: true }, {\n cbrt: function cbrt(x) {\n return sign(x = +x) * pow(abs(x), 1 / 3);\n }\n});\n","var $ = require('../internals/export');\n\nvar floor = Math.floor;\nvar log = Math.log;\nvar LOG2E = Math.LOG2E;\n\n// `Math.clz32` method\n// https://tc39.github.io/ecma262/#sec-math.clz32\n$({ target: 'Math', stat: true }, {\n clz32: function clz32(x) {\n return (x >>>= 0) ? 31 - floor(log(x + 0.5) * LOG2E) : 32;\n }\n});\n","var nativeExpm1 = Math.expm1;\nvar exp = Math.exp;\n\n// `Math.expm1` method implementation\n// https://tc39.github.io/ecma262/#sec-math.expm1\nmodule.exports = (!nativeExpm1\n // Old FF bug\n || nativeExpm1(10) > 22025.465794806719 || nativeExpm1(10) < 22025.4657948067165168\n // Tor Browser bug\n || nativeExpm1(-2e-17) != -2e-17\n) ? function expm1(x) {\n return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : exp(x) - 1;\n} : nativeExpm1;\n","var $ = require('../internals/export');\nvar expm1 = require('../internals/math-expm1');\n\nvar nativeCosh = Math.cosh;\nvar abs = Math.abs;\nvar E = Math.E;\n\n// `Math.cosh` method\n// https://tc39.github.io/ecma262/#sec-math.cosh\n$({ target: 'Math', stat: true, forced: !nativeCosh || nativeCosh(710) === Infinity }, {\n cosh: function cosh(x) {\n var t = expm1(abs(x) - 1) + 1;\n return (t + 1 / (t * E * E)) * (E / 2);\n }\n});\n","var $ = require('../internals/export');\nvar expm1 = require('../internals/math-expm1');\n\n// `Math.expm1` method\n// https://tc39.github.io/ecma262/#sec-math.expm1\n$({ target: 'Math', stat: true, forced: expm1 != Math.expm1 }, { expm1: expm1 });\n","var sign = require('../internals/math-sign');\n\nvar abs = Math.abs;\nvar pow = Math.pow;\nvar EPSILON = pow(2, -52);\nvar EPSILON32 = pow(2, -23);\nvar MAX32 = pow(2, 127) * (2 - EPSILON32);\nvar MIN32 = pow(2, -126);\n\nvar roundTiesToEven = function (n) {\n return n + 1 / EPSILON - 1 / EPSILON;\n};\n\n// `Math.fround` method implementation\n// https://tc39.github.io/ecma262/#sec-math.fround\nmodule.exports = Math.fround || function fround(x) {\n var $abs = abs(x);\n var $sign = sign(x);\n var a, result;\n if ($abs < MIN32) return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;\n a = (1 + EPSILON32 / EPSILON) * $abs;\n result = a - (a - $abs);\n // eslint-disable-next-line no-self-compare\n if (result > MAX32 || result != result) return $sign * Infinity;\n return $sign * result;\n};\n","var $ = require('../internals/export');\nvar fround = require('../internals/math-fround');\n\n// `Math.fround` method\n// https://tc39.github.io/ecma262/#sec-math.fround\n$({ target: 'Math', stat: true }, { fround: fround });\n","var $ = require('../internals/export');\n\nvar $hypot = Math.hypot;\nvar abs = Math.abs;\nvar sqrt = Math.sqrt;\n\n// Chrome 77 bug\n// https://bugs.chromium.org/p/v8/issues/detail?id=9546\nvar BUGGY = !!$hypot && $hypot(Infinity, NaN) !== Infinity;\n\n// `Math.hypot` method\n// https://tc39.github.io/ecma262/#sec-math.hypot\n$({ target: 'Math', stat: true, forced: BUGGY }, {\n hypot: function hypot(value1, value2) { // eslint-disable-line no-unused-vars\n var sum = 0;\n var i = 0;\n var aLen = arguments.length;\n var larg = 0;\n var arg, div;\n while (i < aLen) {\n arg = abs(arguments[i++]);\n if (larg < arg) {\n div = larg / arg;\n sum = sum * div * div + 1;\n larg = arg;\n } else if (arg > 0) {\n div = arg / larg;\n sum += div * div;\n } else sum += arg;\n }\n return larg === Infinity ? Infinity : larg * sqrt(sum);\n }\n});\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\n\nvar nativeImul = Math.imul;\n\nvar FORCED = fails(function () {\n return nativeImul(0xFFFFFFFF, 5) != -5 || nativeImul.length != 2;\n});\n\n// `Math.imul` method\n// https://tc39.github.io/ecma262/#sec-math.imul\n// some WebKit versions fails with big numbers, some has wrong arity\n$({ target: 'Math', stat: true, forced: FORCED }, {\n imul: function imul(x, y) {\n var UINT16 = 0xFFFF;\n var xn = +x;\n var yn = +y;\n var xl = UINT16 & xn;\n var yl = UINT16 & yn;\n return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0);\n }\n});\n","var $ = require('../internals/export');\n\nvar log = Math.log;\nvar LOG10E = Math.LOG10E;\n\n// `Math.log10` method\n// https://tc39.github.io/ecma262/#sec-math.log10\n$({ target: 'Math', stat: true }, {\n log10: function log10(x) {\n return log(x) * LOG10E;\n }\n});\n","var $ = require('../internals/export');\nvar log1p = require('../internals/math-log1p');\n\n// `Math.log1p` method\n// https://tc39.github.io/ecma262/#sec-math.log1p\n$({ target: 'Math', stat: true }, { log1p: log1p });\n","var $ = require('../internals/export');\n\nvar log = Math.log;\nvar LN2 = Math.LN2;\n\n// `Math.log2` method\n// https://tc39.github.io/ecma262/#sec-math.log2\n$({ target: 'Math', stat: true }, {\n log2: function log2(x) {\n return log(x) / LN2;\n }\n});\n","var $ = require('../internals/export');\nvar sign = require('../internals/math-sign');\n\n// `Math.sign` method\n// https://tc39.github.io/ecma262/#sec-math.sign\n$({ target: 'Math', stat: true }, {\n sign: sign\n});\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar expm1 = require('../internals/math-expm1');\n\nvar abs = Math.abs;\nvar exp = Math.exp;\nvar E = Math.E;\n\nvar FORCED = fails(function () {\n return Math.sinh(-2e-17) != -2e-17;\n});\n\n// `Math.sinh` method\n// https://tc39.github.io/ecma262/#sec-math.sinh\n// V8 near Chromium 38 has a problem with very small numbers\n$({ target: 'Math', stat: true, forced: FORCED }, {\n sinh: function sinh(x) {\n return abs(x = +x) < 1 ? (expm1(x) - expm1(-x)) / 2 : (exp(x - 1) - exp(-x - 1)) * (E / 2);\n }\n});\n","var $ = require('../internals/export');\nvar expm1 = require('../internals/math-expm1');\n\nvar exp = Math.exp;\n\n// `Math.tanh` method\n// https://tc39.github.io/ecma262/#sec-math.tanh\n$({ target: 'Math', stat: true }, {\n tanh: function tanh(x) {\n var a = expm1(x = +x);\n var b = expm1(-x);\n return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));\n }\n});\n","var setToStringTag = require('../internals/set-to-string-tag');\n\n// Math[@@toStringTag] property\n// https://tc39.github.io/ecma262/#sec-math-@@tostringtag\nsetToStringTag(Math, 'Math', true);\n","var $ = require('../internals/export');\n\nvar ceil = Math.ceil;\nvar floor = Math.floor;\n\n// `Math.trunc` method\n// https://tc39.github.io/ecma262/#sec-math.trunc\n$({ target: 'Math', stat: true }, {\n trunc: function trunc(it) {\n return (it > 0 ? floor : ceil)(it);\n }\n});\n","// a string of all valid unicode whitespaces\n// eslint-disable-next-line max-len\nmodule.exports = '\\u0009\\u000A\\u000B\\u000C\\u000D\\u0020\\u00A0\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF';\n","var requireObjectCoercible = require('../internals/require-object-coercible');\nvar whitespaces = require('../internals/whitespaces');\n\nvar whitespace = '[' + whitespaces + ']';\nvar ltrim = RegExp('^' + whitespace + whitespace + '*');\nvar rtrim = RegExp(whitespace + whitespace + '*$');\n\n// `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation\nvar createMethod = function (TYPE) {\n return function ($this) {\n var string = String(requireObjectCoercible($this));\n if (TYPE & 1) string = string.replace(ltrim, '');\n if (TYPE & 2) string = string.replace(rtrim, '');\n return string;\n };\n};\n\nmodule.exports = {\n // `String.prototype.{ trimLeft, trimStart }` methods\n // https://tc39.github.io/ecma262/#sec-string.prototype.trimstart\n start: createMethod(1),\n // `String.prototype.{ trimRight, trimEnd }` methods\n // https://tc39.github.io/ecma262/#sec-string.prototype.trimend\n end: createMethod(2),\n // `String.prototype.trim` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.trim\n trim: createMethod(3)\n};\n","'use strict';\nvar DESCRIPTORS = require('../internals/descriptors');\nvar global = require('../internals/global');\nvar isForced = require('../internals/is-forced');\nvar redefine = require('../internals/redefine');\nvar has = require('../internals/has');\nvar classof = require('../internals/classof-raw');\nvar inheritIfRequired = require('../internals/inherit-if-required');\nvar toPrimitive = require('../internals/to-primitive');\nvar fails = require('../internals/fails');\nvar create = require('../internals/object-create');\nvar getOwnPropertyNames = require('../internals/object-get-own-property-names').f;\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\nvar defineProperty = require('../internals/object-define-property').f;\nvar trim = require('../internals/string-trim').trim;\n\nvar NUMBER = 'Number';\nvar NativeNumber = global[NUMBER];\nvar NumberPrototype = NativeNumber.prototype;\n\n// Opera ~12 has broken Object#toString\nvar BROKEN_CLASSOF = classof(create(NumberPrototype)) == NUMBER;\n\n// `ToNumber` abstract operation\n// https://tc39.github.io/ecma262/#sec-tonumber\nvar toNumber = function (argument) {\n var it = toPrimitive(argument, false);\n var first, third, radix, maxCode, digits, length, index, code;\n if (typeof it == 'string' && it.length > 2) {\n it = trim(it);\n first = it.charCodeAt(0);\n if (first === 43 || first === 45) {\n third = it.charCodeAt(2);\n if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix\n } else if (first === 48) {\n switch (it.charCodeAt(1)) {\n case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i\n case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i\n default: return +it;\n }\n digits = it.slice(2);\n length = digits.length;\n for (index = 0; index < length; index++) {\n code = digits.charCodeAt(index);\n // parseInt parses a string to a first unavailable symbol\n // but ToNumber should return NaN if a string contains unavailable symbols\n if (code < 48 || code > maxCode) return NaN;\n } return parseInt(digits, radix);\n }\n } return +it;\n};\n\n// `Number` constructor\n// https://tc39.github.io/ecma262/#sec-number-constructor\nif (isForced(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) {\n var NumberWrapper = function Number(value) {\n var it = arguments.length < 1 ? 0 : value;\n var dummy = this;\n return dummy instanceof NumberWrapper\n // check on 1..constructor(foo) case\n && (BROKEN_CLASSOF ? fails(function () { NumberPrototype.valueOf.call(dummy); }) : classof(dummy) != NUMBER)\n ? inheritIfRequired(new NativeNumber(toNumber(it)), dummy, NumberWrapper) : toNumber(it);\n };\n for (var keys = DESCRIPTORS ? getOwnPropertyNames(NativeNumber) : (\n // ES3:\n 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +\n // ES2015 (in case, if modules with ES2015 Number statics required before):\n 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +\n 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'\n ).split(','), j = 0, key; keys.length > j; j++) {\n if (has(NativeNumber, key = keys[j]) && !has(NumberWrapper, key)) {\n defineProperty(NumberWrapper, key, getOwnPropertyDescriptor(NativeNumber, key));\n }\n }\n NumberWrapper.prototype = NumberPrototype;\n NumberPrototype.constructor = NumberWrapper;\n redefine(global, NUMBER, NumberWrapper);\n}\n","var $ = require('../internals/export');\n\n// `Number.EPSILON` constant\n// https://tc39.github.io/ecma262/#sec-number.epsilon\n$({ target: 'Number', stat: true }, {\n EPSILON: Math.pow(2, -52)\n});\n","var global = require('../internals/global');\n\nvar globalIsFinite = global.isFinite;\n\n// `Number.isFinite` method\n// https://tc39.github.io/ecma262/#sec-number.isfinite\nmodule.exports = Number.isFinite || function isFinite(it) {\n return typeof it == 'number' && globalIsFinite(it);\n};\n","var $ = require('../internals/export');\nvar numberIsFinite = require('../internals/number-is-finite');\n\n// `Number.isFinite` method\n// https://tc39.github.io/ecma262/#sec-number.isfinite\n$({ target: 'Number', stat: true }, { isFinite: numberIsFinite });\n","var isObject = require('../internals/is-object');\n\nvar floor = Math.floor;\n\n// `Number.isInteger` method implementation\n// https://tc39.github.io/ecma262/#sec-number.isinteger\nmodule.exports = function isInteger(it) {\n return !isObject(it) && isFinite(it) && floor(it) === it;\n};\n","var $ = require('../internals/export');\nvar isInteger = require('../internals/is-integer');\n\n// `Number.isInteger` method\n// https://tc39.github.io/ecma262/#sec-number.isinteger\n$({ target: 'Number', stat: true }, {\n isInteger: isInteger\n});\n","var $ = require('../internals/export');\n\n// `Number.isNaN` method\n// https://tc39.github.io/ecma262/#sec-number.isnan\n$({ target: 'Number', stat: true }, {\n isNaN: function isNaN(number) {\n // eslint-disable-next-line no-self-compare\n return number != number;\n }\n});\n","var $ = require('../internals/export');\nvar isInteger = require('../internals/is-integer');\n\nvar abs = Math.abs;\n\n// `Number.isSafeInteger` method\n// https://tc39.github.io/ecma262/#sec-number.issafeinteger\n$({ target: 'Number', stat: true }, {\n isSafeInteger: function isSafeInteger(number) {\n return isInteger(number) && abs(number) <= 0x1FFFFFFFFFFFFF;\n }\n});\n","var $ = require('../internals/export');\n\n// `Number.MAX_SAFE_INTEGER` constant\n// https://tc39.github.io/ecma262/#sec-number.max_safe_integer\n$({ target: 'Number', stat: true }, {\n MAX_SAFE_INTEGER: 0x1FFFFFFFFFFFFF\n});\n","var $ = require('../internals/export');\n\n// `Number.MIN_SAFE_INTEGER` constant\n// https://tc39.github.io/ecma262/#sec-number.min_safe_integer\n$({ target: 'Number', stat: true }, {\n MIN_SAFE_INTEGER: -0x1FFFFFFFFFFFFF\n});\n","var global = require('../internals/global');\nvar trim = require('../internals/string-trim').trim;\nvar whitespaces = require('../internals/whitespaces');\n\nvar $parseFloat = global.parseFloat;\nvar FORCED = 1 / $parseFloat(whitespaces + '-0') !== -Infinity;\n\n// `parseFloat` method\n// https://tc39.github.io/ecma262/#sec-parsefloat-string\nmodule.exports = FORCED ? function parseFloat(string) {\n var trimmedString = trim(String(string));\n var result = $parseFloat(trimmedString);\n return result === 0 && trimmedString.charAt(0) == '-' ? -0 : result;\n} : $parseFloat;\n","var $ = require('../internals/export');\nvar parseFloat = require('../internals/number-parse-float');\n\n// `Number.parseFloat` method\n// https://tc39.github.io/ecma262/#sec-number.parseFloat\n$({ target: 'Number', stat: true, forced: Number.parseFloat != parseFloat }, {\n parseFloat: parseFloat\n});\n","var global = require('../internals/global');\nvar trim = require('../internals/string-trim').trim;\nvar whitespaces = require('../internals/whitespaces');\n\nvar $parseInt = global.parseInt;\nvar hex = /^[+-]?0[Xx]/;\nvar FORCED = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22;\n\n// `parseInt` method\n// https://tc39.github.io/ecma262/#sec-parseint-string-radix\nmodule.exports = FORCED ? function parseInt(string, radix) {\n var S = trim(String(string));\n return $parseInt(S, (radix >>> 0) || (hex.test(S) ? 16 : 10));\n} : $parseInt;\n","var $ = require('../internals/export');\nvar parseInt = require('../internals/number-parse-int');\n\n// `Number.parseInt` method\n// https://tc39.github.io/ecma262/#sec-number.parseint\n$({ target: 'Number', stat: true, forced: Number.parseInt != parseInt }, {\n parseInt: parseInt\n});\n","var classof = require('../internals/classof-raw');\n\n// `thisNumberValue` abstract operation\n// https://tc39.github.io/ecma262/#sec-thisnumbervalue\nmodule.exports = function (value) {\n if (typeof value != 'number' && classof(value) != 'Number') {\n throw TypeError('Incorrect invocation');\n }\n return +value;\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar toInteger = require('../internals/to-integer');\nvar thisNumberValue = require('../internals/this-number-value');\nvar repeat = require('../internals/string-repeat');\nvar fails = require('../internals/fails');\n\nvar nativeToFixed = 1.0.toFixed;\nvar floor = Math.floor;\n\nvar pow = function (x, n, acc) {\n return n === 0 ? acc : n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc);\n};\n\nvar log = function (x) {\n var n = 0;\n var x2 = x;\n while (x2 >= 4096) {\n n += 12;\n x2 /= 4096;\n }\n while (x2 >= 2) {\n n += 1;\n x2 /= 2;\n } return n;\n};\n\nvar FORCED = nativeToFixed && (\n 0.00008.toFixed(3) !== '0.000' ||\n 0.9.toFixed(0) !== '1' ||\n 1.255.toFixed(2) !== '1.25' ||\n 1000000000000000128.0.toFixed(0) !== '1000000000000000128'\n) || !fails(function () {\n // V8 ~ Android 4.3-\n nativeToFixed.call({});\n});\n\n// `Number.prototype.toFixed` method\n// https://tc39.github.io/ecma262/#sec-number.prototype.tofixed\n$({ target: 'Number', proto: true, forced: FORCED }, {\n // eslint-disable-next-line max-statements\n toFixed: function toFixed(fractionDigits) {\n var number = thisNumberValue(this);\n var fractDigits = toInteger(fractionDigits);\n var data = [0, 0, 0, 0, 0, 0];\n var sign = '';\n var result = '0';\n var e, z, j, k;\n\n var multiply = function (n, c) {\n var index = -1;\n var c2 = c;\n while (++index < 6) {\n c2 += n * data[index];\n data[index] = c2 % 1e7;\n c2 = floor(c2 / 1e7);\n }\n };\n\n var divide = function (n) {\n var index = 6;\n var c = 0;\n while (--index >= 0) {\n c += data[index];\n data[index] = floor(c / n);\n c = (c % n) * 1e7;\n }\n };\n\n var dataToString = function () {\n var index = 6;\n var s = '';\n while (--index >= 0) {\n if (s !== '' || index === 0 || data[index] !== 0) {\n var t = String(data[index]);\n s = s === '' ? t : s + repeat.call('0', 7 - t.length) + t;\n }\n } return s;\n };\n\n if (fractDigits < 0 || fractDigits > 20) throw RangeError('Incorrect fraction digits');\n // eslint-disable-next-line no-self-compare\n if (number != number) return 'NaN';\n if (number <= -1e21 || number >= 1e21) return String(number);\n if (number < 0) {\n sign = '-';\n number = -number;\n }\n if (number > 1e-21) {\n e = log(number * pow(2, 69, 1)) - 69;\n z = e < 0 ? number * pow(2, -e, 1) : number / pow(2, e, 1);\n z *= 0x10000000000000;\n e = 52 - e;\n if (e > 0) {\n multiply(0, z);\n j = fractDigits;\n while (j >= 7) {\n multiply(1e7, 0);\n j -= 7;\n }\n multiply(pow(10, j, 1), 0);\n j = e - 1;\n while (j >= 23) {\n divide(1 << 23);\n j -= 23;\n }\n divide(1 << j);\n multiply(1, 1);\n divide(2);\n result = dataToString();\n } else {\n multiply(0, z);\n multiply(1 << -e, 0);\n result = dataToString() + repeat.call('0', fractDigits);\n }\n }\n if (fractDigits > 0) {\n k = result.length;\n result = sign + (k <= fractDigits\n ? '0.' + repeat.call('0', fractDigits - k) + result\n : result.slice(0, k - fractDigits) + '.' + result.slice(k - fractDigits));\n } else {\n result = sign + result;\n } return result;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar thisNumberValue = require('../internals/this-number-value');\n\nvar nativeToPrecision = 1.0.toPrecision;\n\nvar FORCED = fails(function () {\n // IE7-\n return nativeToPrecision.call(1, undefined) !== '1';\n}) || !fails(function () {\n // V8 ~ Android 4.3-\n nativeToPrecision.call({});\n});\n\n// `Number.prototype.toPrecision` method\n// https://tc39.github.io/ecma262/#sec-number.prototype.toprecision\n$({ target: 'Number', proto: true, forced: FORCED }, {\n toPrecision: function toPrecision(precision) {\n return precision === undefined\n ? nativeToPrecision.call(thisNumberValue(this))\n : nativeToPrecision.call(thisNumberValue(this), precision);\n }\n});\n","'use strict';\nvar DESCRIPTORS = require('../internals/descriptors');\nvar fails = require('../internals/fails');\nvar objectKeys = require('../internals/object-keys');\nvar getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');\nvar propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');\nvar toObject = require('../internals/to-object');\nvar IndexedObject = require('../internals/indexed-object');\n\nvar nativeAssign = Object.assign;\nvar defineProperty = Object.defineProperty;\n\n// `Object.assign` method\n// https://tc39.github.io/ecma262/#sec-object.assign\nmodule.exports = !nativeAssign || fails(function () {\n // should have correct order of operations (Edge bug)\n if (DESCRIPTORS && nativeAssign({ b: 1 }, nativeAssign(defineProperty({}, 'a', {\n enumerable: true,\n get: function () {\n defineProperty(this, 'b', {\n value: 3,\n enumerable: false\n });\n }\n }), { b: 2 })).b !== 1) return true;\n // should work with symbols and should have deterministic property order (V8 bug)\n var A = {};\n var B = {};\n // eslint-disable-next-line no-undef\n var symbol = Symbol();\n var alphabet = 'abcdefghijklmnopqrst';\n A[symbol] = 7;\n alphabet.split('').forEach(function (chr) { B[chr] = chr; });\n return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;\n}) ? function assign(target, source) { // eslint-disable-line no-unused-vars\n var T = toObject(target);\n var argumentsLength = arguments.length;\n var index = 1;\n var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;\n var propertyIsEnumerable = propertyIsEnumerableModule.f;\n while (argumentsLength > index) {\n var S = IndexedObject(arguments[index++]);\n var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);\n var length = keys.length;\n var j = 0;\n var key;\n while (length > j) {\n key = keys[j++];\n if (!DESCRIPTORS || propertyIsEnumerable.call(S, key)) T[key] = S[key];\n }\n } return T;\n} : nativeAssign;\n","var $ = require('../internals/export');\nvar assign = require('../internals/object-assign');\n\n// `Object.assign` method\n// https://tc39.github.io/ecma262/#sec-object.assign\n$({ target: 'Object', stat: true, forced: Object.assign !== assign }, {\n assign: assign\n});\n","var $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar create = require('../internals/object-create');\n\n// `Object.create` method\n// https://tc39.github.io/ecma262/#sec-object.create\n$({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {\n create: create\n});\n","'use strict';\nvar IS_PURE = require('../internals/is-pure');\nvar global = require('../internals/global');\nvar fails = require('../internals/fails');\n\n// Forced replacement object prototype accessors methods\nmodule.exports = IS_PURE || !fails(function () {\n var key = Math.random();\n // In FF throws only define methods\n // eslint-disable-next-line no-undef, no-useless-call\n __defineSetter__.call(null, key, function () { /* empty */ });\n delete global[key];\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar FORCED = require('../internals/object-prototype-accessors-forced');\nvar toObject = require('../internals/to-object');\nvar aFunction = require('../internals/a-function');\nvar definePropertyModule = require('../internals/object-define-property');\n\n// `Object.prototype.__defineGetter__` method\n// https://tc39.github.io/ecma262/#sec-object.prototype.__defineGetter__\nif (DESCRIPTORS) {\n $({ target: 'Object', proto: true, forced: FORCED }, {\n __defineGetter__: function __defineGetter__(P, getter) {\n definePropertyModule.f(toObject(this), P, { get: aFunction(getter), enumerable: true, configurable: true });\n }\n });\n}\n","var $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar defineProperties = require('../internals/object-define-properties');\n\n// `Object.defineProperties` method\n// https://tc39.github.io/ecma262/#sec-object.defineproperties\n$({ target: 'Object', stat: true, forced: !DESCRIPTORS, sham: !DESCRIPTORS }, {\n defineProperties: defineProperties\n});\n","var $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar objectDefinePropertyModile = require('../internals/object-define-property');\n\n// `Object.defineProperty` method\n// https://tc39.github.io/ecma262/#sec-object.defineproperty\n$({ target: 'Object', stat: true, forced: !DESCRIPTORS, sham: !DESCRIPTORS }, {\n defineProperty: objectDefinePropertyModile.f\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar FORCED = require('../internals/object-prototype-accessors-forced');\nvar toObject = require('../internals/to-object');\nvar aFunction = require('../internals/a-function');\nvar definePropertyModule = require('../internals/object-define-property');\n\n// `Object.prototype.__defineSetter__` method\n// https://tc39.github.io/ecma262/#sec-object.prototype.__defineSetter__\nif (DESCRIPTORS) {\n $({ target: 'Object', proto: true, forced: FORCED }, {\n __defineSetter__: function __defineSetter__(P, setter) {\n definePropertyModule.f(toObject(this), P, { set: aFunction(setter), enumerable: true, configurable: true });\n }\n });\n}\n","var DESCRIPTORS = require('../internals/descriptors');\nvar objectKeys = require('../internals/object-keys');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar propertyIsEnumerable = require('../internals/object-property-is-enumerable').f;\n\n// `Object.{ entries, values }` methods implementation\nvar createMethod = function (TO_ENTRIES) {\n return function (it) {\n var O = toIndexedObject(it);\n var keys = objectKeys(O);\n var length = keys.length;\n var i = 0;\n var result = [];\n var key;\n while (length > i) {\n key = keys[i++];\n if (!DESCRIPTORS || propertyIsEnumerable.call(O, key)) {\n result.push(TO_ENTRIES ? [key, O[key]] : O[key]);\n }\n }\n return result;\n };\n};\n\nmodule.exports = {\n // `Object.entries` method\n // https://tc39.github.io/ecma262/#sec-object.entries\n entries: createMethod(true),\n // `Object.values` method\n // https://tc39.github.io/ecma262/#sec-object.values\n values: createMethod(false)\n};\n","var $ = require('../internals/export');\nvar $entries = require('../internals/object-to-array').entries;\n\n// `Object.entries` method\n// https://tc39.github.io/ecma262/#sec-object.entries\n$({ target: 'Object', stat: true }, {\n entries: function entries(O) {\n return $entries(O);\n }\n});\n","var $ = require('../internals/export');\nvar FREEZING = require('../internals/freezing');\nvar fails = require('../internals/fails');\nvar isObject = require('../internals/is-object');\nvar onFreeze = require('../internals/internal-metadata').onFreeze;\n\nvar nativeFreeze = Object.freeze;\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeFreeze(1); });\n\n// `Object.freeze` method\n// https://tc39.github.io/ecma262/#sec-object.freeze\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {\n freeze: function freeze(it) {\n return nativeFreeze && isObject(it) ? nativeFreeze(onFreeze(it)) : it;\n }\n});\n","var $ = require('../internals/export');\nvar iterate = require('../internals/iterate');\nvar createProperty = require('../internals/create-property');\n\n// `Object.fromEntries` method\n// https://github.com/tc39/proposal-object-from-entries\n$({ target: 'Object', stat: true }, {\n fromEntries: function fromEntries(iterable) {\n var obj = {};\n iterate(iterable, function (k, v) {\n createProperty(obj, k, v);\n }, undefined, true);\n return obj;\n }\n});\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar nativeGetOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\nvar DESCRIPTORS = require('../internals/descriptors');\n\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeGetOwnPropertyDescriptor(1); });\nvar FORCED = !DESCRIPTORS || FAILS_ON_PRIMITIVES;\n\n// `Object.getOwnPropertyDescriptor` method\n// https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor\n$({ target: 'Object', stat: true, forced: FORCED, sham: !DESCRIPTORS }, {\n getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {\n return nativeGetOwnPropertyDescriptor(toIndexedObject(it), key);\n }\n});\n","var $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar ownKeys = require('../internals/own-keys');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\nvar createProperty = require('../internals/create-property');\n\n// `Object.getOwnPropertyDescriptors` method\n// https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors\n$({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {\n getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {\n var O = toIndexedObject(object);\n var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;\n var keys = ownKeys(O);\n var result = {};\n var index = 0;\n var key, descriptor;\n while (keys.length > index) {\n descriptor = getOwnPropertyDescriptor(O, key = keys[index++]);\n if (descriptor !== undefined) createProperty(result, key, descriptor);\n }\n return result;\n }\n});\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar nativeGetOwnPropertyNames = require('../internals/object-get-own-property-names-external').f;\n\nvar FAILS_ON_PRIMITIVES = fails(function () { return !Object.getOwnPropertyNames(1); });\n\n// `Object.getOwnPropertyNames` method\n// https://tc39.github.io/ecma262/#sec-object.getownpropertynames\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {\n getOwnPropertyNames: nativeGetOwnPropertyNames\n});\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar toObject = require('../internals/to-object');\nvar nativeGetPrototypeOf = require('../internals/object-get-prototype-of');\nvar CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter');\n\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeGetPrototypeOf(1); });\n\n// `Object.getPrototypeOf` method\n// https://tc39.github.io/ecma262/#sec-object.getprototypeof\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !CORRECT_PROTOTYPE_GETTER }, {\n getPrototypeOf: function getPrototypeOf(it) {\n return nativeGetPrototypeOf(toObject(it));\n }\n});\n\n","// `SameValue` abstract operation\n// https://tc39.github.io/ecma262/#sec-samevalue\nmodule.exports = Object.is || function is(x, y) {\n // eslint-disable-next-line no-self-compare\n return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;\n};\n","var $ = require('../internals/export');\nvar is = require('../internals/same-value');\n\n// `Object.is` method\n// https://tc39.github.io/ecma262/#sec-object.is\n$({ target: 'Object', stat: true }, {\n is: is\n});\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar isObject = require('../internals/is-object');\n\nvar nativeIsExtensible = Object.isExtensible;\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeIsExtensible(1); });\n\n// `Object.isExtensible` method\n// https://tc39.github.io/ecma262/#sec-object.isextensible\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {\n isExtensible: function isExtensible(it) {\n return isObject(it) ? nativeIsExtensible ? nativeIsExtensible(it) : true : false;\n }\n});\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar isObject = require('../internals/is-object');\n\nvar nativeIsFrozen = Object.isFrozen;\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeIsFrozen(1); });\n\n// `Object.isFrozen` method\n// https://tc39.github.io/ecma262/#sec-object.isfrozen\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {\n isFrozen: function isFrozen(it) {\n return isObject(it) ? nativeIsFrozen ? nativeIsFrozen(it) : false : true;\n }\n});\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar isObject = require('../internals/is-object');\n\nvar nativeIsSealed = Object.isSealed;\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeIsSealed(1); });\n\n// `Object.isSealed` method\n// https://tc39.github.io/ecma262/#sec-object.issealed\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {\n isSealed: function isSealed(it) {\n return isObject(it) ? nativeIsSealed ? nativeIsSealed(it) : false : true;\n }\n});\n","var $ = require('../internals/export');\nvar toObject = require('../internals/to-object');\nvar nativeKeys = require('../internals/object-keys');\nvar fails = require('../internals/fails');\n\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeKeys(1); });\n\n// `Object.keys` method\n// https://tc39.github.io/ecma262/#sec-object.keys\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {\n keys: function keys(it) {\n return nativeKeys(toObject(it));\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar FORCED = require('../internals/object-prototype-accessors-forced');\nvar toObject = require('../internals/to-object');\nvar toPrimitive = require('../internals/to-primitive');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\n\n// `Object.prototype.__lookupGetter__` method\n// https://tc39.github.io/ecma262/#sec-object.prototype.__lookupGetter__\nif (DESCRIPTORS) {\n $({ target: 'Object', proto: true, forced: FORCED }, {\n __lookupGetter__: function __lookupGetter__(P) {\n var O = toObject(this);\n var key = toPrimitive(P, true);\n var desc;\n do {\n if (desc = getOwnPropertyDescriptor(O, key)) return desc.get;\n } while (O = getPrototypeOf(O));\n }\n });\n}\n","'use strict';\nvar $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar FORCED = require('../internals/object-prototype-accessors-forced');\nvar toObject = require('../internals/to-object');\nvar toPrimitive = require('../internals/to-primitive');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\n\n// `Object.prototype.__lookupSetter__` method\n// https://tc39.github.io/ecma262/#sec-object.prototype.__lookupSetter__\nif (DESCRIPTORS) {\n $({ target: 'Object', proto: true, forced: FORCED }, {\n __lookupSetter__: function __lookupSetter__(P) {\n var O = toObject(this);\n var key = toPrimitive(P, true);\n var desc;\n do {\n if (desc = getOwnPropertyDescriptor(O, key)) return desc.set;\n } while (O = getPrototypeOf(O));\n }\n });\n}\n","var $ = require('../internals/export');\nvar isObject = require('../internals/is-object');\nvar onFreeze = require('../internals/internal-metadata').onFreeze;\nvar FREEZING = require('../internals/freezing');\nvar fails = require('../internals/fails');\n\nvar nativePreventExtensions = Object.preventExtensions;\nvar FAILS_ON_PRIMITIVES = fails(function () { nativePreventExtensions(1); });\n\n// `Object.preventExtensions` method\n// https://tc39.github.io/ecma262/#sec-object.preventextensions\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {\n preventExtensions: function preventExtensions(it) {\n return nativePreventExtensions && isObject(it) ? nativePreventExtensions(onFreeze(it)) : it;\n }\n});\n","var $ = require('../internals/export');\nvar isObject = require('../internals/is-object');\nvar onFreeze = require('../internals/internal-metadata').onFreeze;\nvar FREEZING = require('../internals/freezing');\nvar fails = require('../internals/fails');\n\nvar nativeSeal = Object.seal;\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeSeal(1); });\n\n// `Object.seal` method\n// https://tc39.github.io/ecma262/#sec-object.seal\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {\n seal: function seal(it) {\n return nativeSeal && isObject(it) ? nativeSeal(onFreeze(it)) : it;\n }\n});\n","var $ = require('../internals/export');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\n\n// `Object.setPrototypeOf` method\n// https://tc39.github.io/ecma262/#sec-object.setprototypeof\n$({ target: 'Object', stat: true }, {\n setPrototypeOf: setPrototypeOf\n});\n","'use strict';\nvar TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');\nvar classof = require('../internals/classof');\n\n// `Object.prototype.toString` method implementation\n// https://tc39.github.io/ecma262/#sec-object.prototype.tostring\nmodule.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {\n return '[object ' + classof(this) + ']';\n};\n","var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');\nvar redefine = require('../internals/redefine');\nvar toString = require('../internals/object-to-string');\n\n// `Object.prototype.toString` method\n// https://tc39.github.io/ecma262/#sec-object.prototype.tostring\nif (!TO_STRING_TAG_SUPPORT) {\n redefine(Object.prototype, 'toString', toString, { unsafe: true });\n}\n","var $ = require('../internals/export');\nvar $values = require('../internals/object-to-array').values;\n\n// `Object.values` method\n// https://tc39.github.io/ecma262/#sec-object.values\n$({ target: 'Object', stat: true }, {\n values: function values(O) {\n return $values(O);\n }\n});\n","var $ = require('../internals/export');\nvar parseFloatImplementation = require('../internals/number-parse-float');\n\n// `parseFloat` method\n// https://tc39.github.io/ecma262/#sec-parsefloat-string\n$({ global: true, forced: parseFloat != parseFloatImplementation }, {\n parseFloat: parseFloatImplementation\n});\n","var $ = require('../internals/export');\nvar parseIntImplementation = require('../internals/number-parse-int');\n\n// `parseInt` method\n// https://tc39.github.io/ecma262/#sec-parseint-string-radix\n$({ global: true, forced: parseInt != parseIntImplementation }, {\n parseInt: parseIntImplementation\n});\n","var global = require('../internals/global');\n\nmodule.exports = global.Promise;\n","var userAgent = require('../internals/engine-user-agent');\n\nmodule.exports = /(iphone|ipod|ipad).*applewebkit/i.test(userAgent);\n","var global = require('../internals/global');\nvar fails = require('../internals/fails');\nvar classof = require('../internals/classof-raw');\nvar bind = require('../internals/function-bind-context');\nvar html = require('../internals/html');\nvar createElement = require('../internals/document-create-element');\nvar IS_IOS = require('../internals/engine-is-ios');\n\nvar location = global.location;\nvar set = global.setImmediate;\nvar clear = global.clearImmediate;\nvar process = global.process;\nvar MessageChannel = global.MessageChannel;\nvar Dispatch = global.Dispatch;\nvar counter = 0;\nvar queue = {};\nvar ONREADYSTATECHANGE = 'onreadystatechange';\nvar defer, channel, port;\n\nvar run = function (id) {\n // eslint-disable-next-line no-prototype-builtins\n if (queue.hasOwnProperty(id)) {\n var fn = queue[id];\n delete queue[id];\n fn();\n }\n};\n\nvar runner = function (id) {\n return function () {\n run(id);\n };\n};\n\nvar listener = function (event) {\n run(event.data);\n};\n\nvar post = function (id) {\n // old engines have not location.origin\n global.postMessage(id + '', location.protocol + '//' + location.host);\n};\n\n// Node.js 0.9+ & IE10+ has setImmediate, otherwise:\nif (!set || !clear) {\n set = function setImmediate(fn) {\n var args = [];\n var i = 1;\n while (arguments.length > i) args.push(arguments[i++]);\n queue[++counter] = function () {\n // eslint-disable-next-line no-new-func\n (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args);\n };\n defer(counter);\n return counter;\n };\n clear = function clearImmediate(id) {\n delete queue[id];\n };\n // Node.js 0.8-\n if (classof(process) == 'process') {\n defer = function (id) {\n process.nextTick(runner(id));\n };\n // Sphere (JS game engine) Dispatch API\n } else if (Dispatch && Dispatch.now) {\n defer = function (id) {\n Dispatch.now(runner(id));\n };\n // Browsers with MessageChannel, includes WebWorkers\n // except iOS - https://github.com/zloirock/core-js/issues/624\n } else if (MessageChannel && !IS_IOS) {\n channel = new MessageChannel();\n port = channel.port2;\n channel.port1.onmessage = listener;\n defer = bind(port.postMessage, port, 1);\n // Browsers with postMessage, skip WebWorkers\n // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'\n } else if (\n global.addEventListener &&\n typeof postMessage == 'function' &&\n !global.importScripts &&\n !fails(post) &&\n location.protocol !== 'file:'\n ) {\n defer = post;\n global.addEventListener('message', listener, false);\n // IE8-\n } else if (ONREADYSTATECHANGE in createElement('script')) {\n defer = function (id) {\n html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {\n html.removeChild(this);\n run(id);\n };\n };\n // Rest old browsers\n } else {\n defer = function (id) {\n setTimeout(runner(id), 0);\n };\n }\n}\n\nmodule.exports = {\n set: set,\n clear: clear\n};\n","var global = require('../internals/global');\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\nvar classof = require('../internals/classof-raw');\nvar macrotask = require('../internals/task').set;\nvar IS_IOS = require('../internals/engine-is-ios');\n\nvar MutationObserver = global.MutationObserver || global.WebKitMutationObserver;\nvar process = global.process;\nvar Promise = global.Promise;\nvar IS_NODE = classof(process) == 'process';\n// Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`\nvar queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');\nvar queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;\n\nvar flush, head, last, notify, toggle, node, promise, then;\n\n// modern engines have queueMicrotask method\nif (!queueMicrotask) {\n flush = function () {\n var parent, fn;\n if (IS_NODE && (parent = process.domain)) parent.exit();\n while (head) {\n fn = head.fn;\n head = head.next;\n try {\n fn();\n } catch (error) {\n if (head) notify();\n else last = undefined;\n throw error;\n }\n } last = undefined;\n if (parent) parent.enter();\n };\n\n // Node.js\n if (IS_NODE) {\n notify = function () {\n process.nextTick(flush);\n };\n // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339\n } else if (MutationObserver && !IS_IOS) {\n toggle = true;\n node = document.createTextNode('');\n new MutationObserver(flush).observe(node, { characterData: true });\n notify = function () {\n node.data = toggle = !toggle;\n };\n // environments with maybe non-completely correct, but existent Promise\n } else if (Promise && Promise.resolve) {\n // Promise.resolve without an argument throws an error in LG WebOS 2\n promise = Promise.resolve(undefined);\n then = promise.then;\n notify = function () {\n then.call(promise, flush);\n };\n // for other environments - macrotask based on:\n // - setImmediate\n // - MessageChannel\n // - window.postMessag\n // - onreadystatechange\n // - setTimeout\n } else {\n notify = function () {\n // strange IE + webpack dev server bug - use .call(global)\n macrotask.call(global, flush);\n };\n }\n}\n\nmodule.exports = queueMicrotask || function (fn) {\n var task = { fn: fn, next: undefined };\n if (last) last.next = task;\n if (!head) {\n head = task;\n notify();\n } last = task;\n};\n","'use strict';\nvar aFunction = require('../internals/a-function');\n\nvar PromiseCapability = function (C) {\n var resolve, reject;\n this.promise = new C(function ($$resolve, $$reject) {\n if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');\n resolve = $$resolve;\n reject = $$reject;\n });\n this.resolve = aFunction(resolve);\n this.reject = aFunction(reject);\n};\n\n// 25.4.1.5 NewPromiseCapability(C)\nmodule.exports.f = function (C) {\n return new PromiseCapability(C);\n};\n","var anObject = require('../internals/an-object');\nvar isObject = require('../internals/is-object');\nvar newPromiseCapability = require('../internals/new-promise-capability');\n\nmodule.exports = function (C, x) {\n anObject(C);\n if (isObject(x) && x.constructor === C) return x;\n var promiseCapability = newPromiseCapability.f(C);\n var resolve = promiseCapability.resolve;\n resolve(x);\n return promiseCapability.promise;\n};\n","var global = require('../internals/global');\n\nmodule.exports = function (a, b) {\n var console = global.console;\n if (console && console.error) {\n arguments.length === 1 ? console.error(a) : console.error(a, b);\n }\n};\n","module.exports = function (exec) {\n try {\n return { error: false, value: exec() };\n } catch (error) {\n return { error: true, value: error };\n }\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar global = require('../internals/global');\nvar getBuiltIn = require('../internals/get-built-in');\nvar NativePromise = require('../internals/native-promise-constructor');\nvar redefine = require('../internals/redefine');\nvar redefineAll = require('../internals/redefine-all');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar setSpecies = require('../internals/set-species');\nvar isObject = require('../internals/is-object');\nvar aFunction = require('../internals/a-function');\nvar anInstance = require('../internals/an-instance');\nvar classof = require('../internals/classof-raw');\nvar inspectSource = require('../internals/inspect-source');\nvar iterate = require('../internals/iterate');\nvar checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration');\nvar speciesConstructor = require('../internals/species-constructor');\nvar task = require('../internals/task').set;\nvar microtask = require('../internals/microtask');\nvar promiseResolve = require('../internals/promise-resolve');\nvar hostReportErrors = require('../internals/host-report-errors');\nvar newPromiseCapabilityModule = require('../internals/new-promise-capability');\nvar perform = require('../internals/perform');\nvar InternalStateModule = require('../internals/internal-state');\nvar isForced = require('../internals/is-forced');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar V8_VERSION = require('../internals/engine-v8-version');\n\nvar SPECIES = wellKnownSymbol('species');\nvar PROMISE = 'Promise';\nvar getInternalState = InternalStateModule.get;\nvar setInternalState = InternalStateModule.set;\nvar getInternalPromiseState = InternalStateModule.getterFor(PROMISE);\nvar PromiseConstructor = NativePromise;\nvar TypeError = global.TypeError;\nvar document = global.document;\nvar process = global.process;\nvar $fetch = getBuiltIn('fetch');\nvar newPromiseCapability = newPromiseCapabilityModule.f;\nvar newGenericPromiseCapability = newPromiseCapability;\nvar IS_NODE = classof(process) == 'process';\nvar DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);\nvar UNHANDLED_REJECTION = 'unhandledrejection';\nvar REJECTION_HANDLED = 'rejectionhandled';\nvar PENDING = 0;\nvar FULFILLED = 1;\nvar REJECTED = 2;\nvar HANDLED = 1;\nvar UNHANDLED = 2;\nvar Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;\n\nvar FORCED = isForced(PROMISE, function () {\n var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor);\n if (!GLOBAL_CORE_JS_PROMISE) {\n // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables\n // https://bugs.chromium.org/p/chromium/issues/detail?id=830565\n // We can't detect it synchronously, so just check versions\n if (V8_VERSION === 66) return true;\n // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test\n if (!IS_NODE && typeof PromiseRejectionEvent != 'function') return true;\n }\n // We need Promise#finally in the pure version for preventing prototype pollution\n if (IS_PURE && !PromiseConstructor.prototype['finally']) return true;\n // We can't use @@species feature detection in V8 since it causes\n // deoptimization and performance degradation\n // https://github.com/zloirock/core-js/issues/679\n if (V8_VERSION >= 51 && /native code/.test(PromiseConstructor)) return false;\n // Detect correctness of subclassing with @@species support\n var promise = PromiseConstructor.resolve(1);\n var FakePromise = function (exec) {\n exec(function () { /* empty */ }, function () { /* empty */ });\n };\n var constructor = promise.constructor = {};\n constructor[SPECIES] = FakePromise;\n return !(promise.then(function () { /* empty */ }) instanceof FakePromise);\n});\n\nvar INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {\n PromiseConstructor.all(iterable)['catch'](function () { /* empty */ });\n});\n\n// helpers\nvar isThenable = function (it) {\n var then;\n return isObject(it) && typeof (then = it.then) == 'function' ? then : false;\n};\n\nvar notify = function (promise, state, isReject) {\n if (state.notified) return;\n state.notified = true;\n var chain = state.reactions;\n microtask(function () {\n var value = state.value;\n var ok = state.state == FULFILLED;\n var index = 0;\n // variable length - can't use forEach\n while (chain.length > index) {\n var reaction = chain[index++];\n var handler = ok ? reaction.ok : reaction.fail;\n var resolve = reaction.resolve;\n var reject = reaction.reject;\n var domain = reaction.domain;\n var result, then, exited;\n try {\n if (handler) {\n if (!ok) {\n if (state.rejection === UNHANDLED) onHandleUnhandled(promise, state);\n state.rejection = HANDLED;\n }\n if (handler === true) result = value;\n else {\n if (domain) domain.enter();\n result = handler(value); // can throw\n if (domain) {\n domain.exit();\n exited = true;\n }\n }\n if (result === reaction.promise) {\n reject(TypeError('Promise-chain cycle'));\n } else if (then = isThenable(result)) {\n then.call(result, resolve, reject);\n } else resolve(result);\n } else reject(value);\n } catch (error) {\n if (domain && !exited) domain.exit();\n reject(error);\n }\n }\n state.reactions = [];\n state.notified = false;\n if (isReject && !state.rejection) onUnhandled(promise, state);\n });\n};\n\nvar dispatchEvent = function (name, promise, reason) {\n var event, handler;\n if (DISPATCH_EVENT) {\n event = document.createEvent('Event');\n event.promise = promise;\n event.reason = reason;\n event.initEvent(name, false, true);\n global.dispatchEvent(event);\n } else event = { promise: promise, reason: reason };\n if (handler = global['on' + name]) handler(event);\n else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);\n};\n\nvar onUnhandled = function (promise, state) {\n task.call(global, function () {\n var value = state.value;\n var IS_UNHANDLED = isUnhandled(state);\n var result;\n if (IS_UNHANDLED) {\n result = perform(function () {\n if (IS_NODE) {\n process.emit('unhandledRejection', value, promise);\n } else dispatchEvent(UNHANDLED_REJECTION, promise, value);\n });\n // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should\n state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;\n if (result.error) throw result.value;\n }\n });\n};\n\nvar isUnhandled = function (state) {\n return state.rejection !== HANDLED && !state.parent;\n};\n\nvar onHandleUnhandled = function (promise, state) {\n task.call(global, function () {\n if (IS_NODE) {\n process.emit('rejectionHandled', promise);\n } else dispatchEvent(REJECTION_HANDLED, promise, state.value);\n });\n};\n\nvar bind = function (fn, promise, state, unwrap) {\n return function (value) {\n fn(promise, state, value, unwrap);\n };\n};\n\nvar internalReject = function (promise, state, value, unwrap) {\n if (state.done) return;\n state.done = true;\n if (unwrap) state = unwrap;\n state.value = value;\n state.state = REJECTED;\n notify(promise, state, true);\n};\n\nvar internalResolve = function (promise, state, value, unwrap) {\n if (state.done) return;\n state.done = true;\n if (unwrap) state = unwrap;\n try {\n if (promise === value) throw TypeError(\"Promise can't be resolved itself\");\n var then = isThenable(value);\n if (then) {\n microtask(function () {\n var wrapper = { done: false };\n try {\n then.call(value,\n bind(internalResolve, promise, wrapper, state),\n bind(internalReject, promise, wrapper, state)\n );\n } catch (error) {\n internalReject(promise, wrapper, error, state);\n }\n });\n } else {\n state.value = value;\n state.state = FULFILLED;\n notify(promise, state, false);\n }\n } catch (error) {\n internalReject(promise, { done: false }, error, state);\n }\n};\n\n// constructor polyfill\nif (FORCED) {\n // 25.4.3.1 Promise(executor)\n PromiseConstructor = function Promise(executor) {\n anInstance(this, PromiseConstructor, PROMISE);\n aFunction(executor);\n Internal.call(this);\n var state = getInternalState(this);\n try {\n executor(bind(internalResolve, this, state), bind(internalReject, this, state));\n } catch (error) {\n internalReject(this, state, error);\n }\n };\n // eslint-disable-next-line no-unused-vars\n Internal = function Promise(executor) {\n setInternalState(this, {\n type: PROMISE,\n done: false,\n notified: false,\n parent: false,\n reactions: [],\n rejection: false,\n state: PENDING,\n value: undefined\n });\n };\n Internal.prototype = redefineAll(PromiseConstructor.prototype, {\n // `Promise.prototype.then` method\n // https://tc39.github.io/ecma262/#sec-promise.prototype.then\n then: function then(onFulfilled, onRejected) {\n var state = getInternalPromiseState(this);\n var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));\n reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;\n reaction.fail = typeof onRejected == 'function' && onRejected;\n reaction.domain = IS_NODE ? process.domain : undefined;\n state.parent = true;\n state.reactions.push(reaction);\n if (state.state != PENDING) notify(this, state, false);\n return reaction.promise;\n },\n // `Promise.prototype.catch` method\n // https://tc39.github.io/ecma262/#sec-promise.prototype.catch\n 'catch': function (onRejected) {\n return this.then(undefined, onRejected);\n }\n });\n OwnPromiseCapability = function () {\n var promise = new Internal();\n var state = getInternalState(promise);\n this.promise = promise;\n this.resolve = bind(internalResolve, promise, state);\n this.reject = bind(internalReject, promise, state);\n };\n newPromiseCapabilityModule.f = newPromiseCapability = function (C) {\n return C === PromiseConstructor || C === PromiseWrapper\n ? new OwnPromiseCapability(C)\n : newGenericPromiseCapability(C);\n };\n\n if (!IS_PURE && typeof NativePromise == 'function') {\n nativeThen = NativePromise.prototype.then;\n\n // wrap native Promise#then for native async functions\n redefine(NativePromise.prototype, 'then', function then(onFulfilled, onRejected) {\n var that = this;\n return new PromiseConstructor(function (resolve, reject) {\n nativeThen.call(that, resolve, reject);\n }).then(onFulfilled, onRejected);\n // https://github.com/zloirock/core-js/issues/640\n }, { unsafe: true });\n\n // wrap fetch result\n if (typeof $fetch == 'function') $({ global: true, enumerable: true, forced: true }, {\n // eslint-disable-next-line no-unused-vars\n fetch: function fetch(input /* , init */) {\n return promiseResolve(PromiseConstructor, $fetch.apply(global, arguments));\n }\n });\n }\n}\n\n$({ global: true, wrap: true, forced: FORCED }, {\n Promise: PromiseConstructor\n});\n\nsetToStringTag(PromiseConstructor, PROMISE, false, true);\nsetSpecies(PROMISE);\n\nPromiseWrapper = getBuiltIn(PROMISE);\n\n// statics\n$({ target: PROMISE, stat: true, forced: FORCED }, {\n // `Promise.reject` method\n // https://tc39.github.io/ecma262/#sec-promise.reject\n reject: function reject(r) {\n var capability = newPromiseCapability(this);\n capability.reject.call(undefined, r);\n return capability.promise;\n }\n});\n\n$({ target: PROMISE, stat: true, forced: IS_PURE || FORCED }, {\n // `Promise.resolve` method\n // https://tc39.github.io/ecma262/#sec-promise.resolve\n resolve: function resolve(x) {\n return promiseResolve(IS_PURE && this === PromiseWrapper ? PromiseConstructor : this, x);\n }\n});\n\n$({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {\n // `Promise.all` method\n // https://tc39.github.io/ecma262/#sec-promise.all\n all: function all(iterable) {\n var C = this;\n var capability = newPromiseCapability(C);\n var resolve = capability.resolve;\n var reject = capability.reject;\n var result = perform(function () {\n var $promiseResolve = aFunction(C.resolve);\n var values = [];\n var counter = 0;\n var remaining = 1;\n iterate(iterable, function (promise) {\n var index = counter++;\n var alreadyCalled = false;\n values.push(undefined);\n remaining++;\n $promiseResolve.call(C, promise).then(function (value) {\n if (alreadyCalled) return;\n alreadyCalled = true;\n values[index] = value;\n --remaining || resolve(values);\n }, reject);\n });\n --remaining || resolve(values);\n });\n if (result.error) reject(result.value);\n return capability.promise;\n },\n // `Promise.race` method\n // https://tc39.github.io/ecma262/#sec-promise.race\n race: function race(iterable) {\n var C = this;\n var capability = newPromiseCapability(C);\n var reject = capability.reject;\n var result = perform(function () {\n var $promiseResolve = aFunction(C.resolve);\n iterate(iterable, function (promise) {\n $promiseResolve.call(C, promise).then(capability.resolve, reject);\n });\n });\n if (result.error) reject(result.value);\n return capability.promise;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar aFunction = require('../internals/a-function');\nvar newPromiseCapabilityModule = require('../internals/new-promise-capability');\nvar perform = require('../internals/perform');\nvar iterate = require('../internals/iterate');\n\n// `Promise.allSettled` method\n// https://github.com/tc39/proposal-promise-allSettled\n$({ target: 'Promise', stat: true }, {\n allSettled: function allSettled(iterable) {\n var C = this;\n var capability = newPromiseCapabilityModule.f(C);\n var resolve = capability.resolve;\n var reject = capability.reject;\n var result = perform(function () {\n var promiseResolve = aFunction(C.resolve);\n var values = [];\n var counter = 0;\n var remaining = 1;\n iterate(iterable, function (promise) {\n var index = counter++;\n var alreadyCalled = false;\n values.push(undefined);\n remaining++;\n promiseResolve.call(C, promise).then(function (value) {\n if (alreadyCalled) return;\n alreadyCalled = true;\n values[index] = { status: 'fulfilled', value: value };\n --remaining || resolve(values);\n }, function (e) {\n if (alreadyCalled) return;\n alreadyCalled = true;\n values[index] = { status: 'rejected', reason: e };\n --remaining || resolve(values);\n });\n });\n --remaining || resolve(values);\n });\n if (result.error) reject(result.value);\n return capability.promise;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar NativePromise = require('../internals/native-promise-constructor');\nvar fails = require('../internals/fails');\nvar getBuiltIn = require('../internals/get-built-in');\nvar speciesConstructor = require('../internals/species-constructor');\nvar promiseResolve = require('../internals/promise-resolve');\nvar redefine = require('../internals/redefine');\n\n// Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829\nvar NON_GENERIC = !!NativePromise && fails(function () {\n NativePromise.prototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });\n});\n\n// `Promise.prototype.finally` method\n// https://tc39.github.io/ecma262/#sec-promise.prototype.finally\n$({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {\n 'finally': function (onFinally) {\n var C = speciesConstructor(this, getBuiltIn('Promise'));\n var isFunction = typeof onFinally == 'function';\n return this.then(\n isFunction ? function (x) {\n return promiseResolve(C, onFinally()).then(function () { return x; });\n } : onFinally,\n isFunction ? function (e) {\n return promiseResolve(C, onFinally()).then(function () { throw e; });\n } : onFinally\n );\n }\n});\n\n// patch native Promise.prototype for native async functions\nif (!IS_PURE && typeof NativePromise == 'function' && !NativePromise.prototype['finally']) {\n redefine(NativePromise.prototype, 'finally', getBuiltIn('Promise').prototype['finally']);\n}\n","var $ = require('../internals/export');\nvar getBuiltIn = require('../internals/get-built-in');\nvar aFunction = require('../internals/a-function');\nvar anObject = require('../internals/an-object');\nvar fails = require('../internals/fails');\n\nvar nativeApply = getBuiltIn('Reflect', 'apply');\nvar functionApply = Function.apply;\n\n// MS Edge argumentsList argument is optional\nvar OPTIONAL_ARGUMENTS_LIST = !fails(function () {\n nativeApply(function () { /* empty */ });\n});\n\n// `Reflect.apply` method\n// https://tc39.github.io/ecma262/#sec-reflect.apply\n$({ target: 'Reflect', stat: true, forced: OPTIONAL_ARGUMENTS_LIST }, {\n apply: function apply(target, thisArgument, argumentsList) {\n aFunction(target);\n anObject(argumentsList);\n return nativeApply\n ? nativeApply(target, thisArgument, argumentsList)\n : functionApply.call(target, thisArgument, argumentsList);\n }\n});\n","var $ = require('../internals/export');\nvar getBuiltIn = require('../internals/get-built-in');\nvar aFunction = require('../internals/a-function');\nvar anObject = require('../internals/an-object');\nvar isObject = require('../internals/is-object');\nvar create = require('../internals/object-create');\nvar bind = require('../internals/function-bind');\nvar fails = require('../internals/fails');\n\nvar nativeConstruct = getBuiltIn('Reflect', 'construct');\n\n// `Reflect.construct` method\n// https://tc39.github.io/ecma262/#sec-reflect.construct\n// MS Edge supports only 2 arguments and argumentsList argument is optional\n// FF Nightly sets third argument as `new.target`, but does not create `this` from it\nvar NEW_TARGET_BUG = fails(function () {\n function F() { /* empty */ }\n return !(nativeConstruct(function () { /* empty */ }, [], F) instanceof F);\n});\nvar ARGS_BUG = !fails(function () {\n nativeConstruct(function () { /* empty */ });\n});\nvar FORCED = NEW_TARGET_BUG || ARGS_BUG;\n\n$({ target: 'Reflect', stat: true, forced: FORCED, sham: FORCED }, {\n construct: function construct(Target, args /* , newTarget */) {\n aFunction(Target);\n anObject(args);\n var newTarget = arguments.length < 3 ? Target : aFunction(arguments[2]);\n if (ARGS_BUG && !NEW_TARGET_BUG) return nativeConstruct(Target, args, newTarget);\n if (Target == newTarget) {\n // w/o altered newTarget, optimization for 0-4 arguments\n switch (args.length) {\n case 0: return new Target();\n case 1: return new Target(args[0]);\n case 2: return new Target(args[0], args[1]);\n case 3: return new Target(args[0], args[1], args[2]);\n case 4: return new Target(args[0], args[1], args[2], args[3]);\n }\n // w/o altered newTarget, lot of arguments case\n var $args = [null];\n $args.push.apply($args, args);\n return new (bind.apply(Target, $args))();\n }\n // with altered newTarget, not support built-in constructors\n var proto = newTarget.prototype;\n var instance = create(isObject(proto) ? proto : Object.prototype);\n var result = Function.apply.call(Target, instance, args);\n return isObject(result) ? result : instance;\n }\n});\n","var $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar anObject = require('../internals/an-object');\nvar toPrimitive = require('../internals/to-primitive');\nvar definePropertyModule = require('../internals/object-define-property');\nvar fails = require('../internals/fails');\n\n// MS Edge has broken Reflect.defineProperty - throwing instead of returning false\nvar ERROR_INSTEAD_OF_FALSE = fails(function () {\n // eslint-disable-next-line no-undef\n Reflect.defineProperty(definePropertyModule.f({}, 1, { value: 1 }), 1, { value: 2 });\n});\n\n// `Reflect.defineProperty` method\n// https://tc39.github.io/ecma262/#sec-reflect.defineproperty\n$({ target: 'Reflect', stat: true, forced: ERROR_INSTEAD_OF_FALSE, sham: !DESCRIPTORS }, {\n defineProperty: function defineProperty(target, propertyKey, attributes) {\n anObject(target);\n var key = toPrimitive(propertyKey, true);\n anObject(attributes);\n try {\n definePropertyModule.f(target, key, attributes);\n return true;\n } catch (error) {\n return false;\n }\n }\n});\n","var $ = require('../internals/export');\nvar anObject = require('../internals/an-object');\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\n\n// `Reflect.deleteProperty` method\n// https://tc39.github.io/ecma262/#sec-reflect.deleteproperty\n$({ target: 'Reflect', stat: true }, {\n deleteProperty: function deleteProperty(target, propertyKey) {\n var descriptor = getOwnPropertyDescriptor(anObject(target), propertyKey);\n return descriptor && !descriptor.configurable ? false : delete target[propertyKey];\n }\n});\n","var $ = require('../internals/export');\nvar isObject = require('../internals/is-object');\nvar anObject = require('../internals/an-object');\nvar has = require('../internals/has');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\n\n// `Reflect.get` method\n// https://tc39.github.io/ecma262/#sec-reflect.get\nfunction get(target, propertyKey /* , receiver */) {\n var receiver = arguments.length < 3 ? target : arguments[2];\n var descriptor, prototype;\n if (anObject(target) === receiver) return target[propertyKey];\n if (descriptor = getOwnPropertyDescriptorModule.f(target, propertyKey)) return has(descriptor, 'value')\n ? descriptor.value\n : descriptor.get === undefined\n ? undefined\n : descriptor.get.call(receiver);\n if (isObject(prototype = getPrototypeOf(target))) return get(prototype, propertyKey, receiver);\n}\n\n$({ target: 'Reflect', stat: true }, {\n get: get\n});\n","var $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar anObject = require('../internals/an-object');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\n\n// `Reflect.getOwnPropertyDescriptor` method\n// https://tc39.github.io/ecma262/#sec-reflect.getownpropertydescriptor\n$({ target: 'Reflect', stat: true, sham: !DESCRIPTORS }, {\n getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) {\n return getOwnPropertyDescriptorModule.f(anObject(target), propertyKey);\n }\n});\n","var $ = require('../internals/export');\nvar anObject = require('../internals/an-object');\nvar objectGetPrototypeOf = require('../internals/object-get-prototype-of');\nvar CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter');\n\n// `Reflect.getPrototypeOf` method\n// https://tc39.github.io/ecma262/#sec-reflect.getprototypeof\n$({ target: 'Reflect', stat: true, sham: !CORRECT_PROTOTYPE_GETTER }, {\n getPrototypeOf: function getPrototypeOf(target) {\n return objectGetPrototypeOf(anObject(target));\n }\n});\n","var $ = require('../internals/export');\n\n// `Reflect.has` method\n// https://tc39.github.io/ecma262/#sec-reflect.has\n$({ target: 'Reflect', stat: true }, {\n has: function has(target, propertyKey) {\n return propertyKey in target;\n }\n});\n","var $ = require('../internals/export');\nvar anObject = require('../internals/an-object');\n\nvar objectIsExtensible = Object.isExtensible;\n\n// `Reflect.isExtensible` method\n// https://tc39.github.io/ecma262/#sec-reflect.isextensible\n$({ target: 'Reflect', stat: true }, {\n isExtensible: function isExtensible(target) {\n anObject(target);\n return objectIsExtensible ? objectIsExtensible(target) : true;\n }\n});\n","var $ = require('../internals/export');\nvar ownKeys = require('../internals/own-keys');\n\n// `Reflect.ownKeys` method\n// https://tc39.github.io/ecma262/#sec-reflect.ownkeys\n$({ target: 'Reflect', stat: true }, {\n ownKeys: ownKeys\n});\n","var $ = require('../internals/export');\nvar getBuiltIn = require('../internals/get-built-in');\nvar anObject = require('../internals/an-object');\nvar FREEZING = require('../internals/freezing');\n\n// `Reflect.preventExtensions` method\n// https://tc39.github.io/ecma262/#sec-reflect.preventextensions\n$({ target: 'Reflect', stat: true, sham: !FREEZING }, {\n preventExtensions: function preventExtensions(target) {\n anObject(target);\n try {\n var objectPreventExtensions = getBuiltIn('Object', 'preventExtensions');\n if (objectPreventExtensions) objectPreventExtensions(target);\n return true;\n } catch (error) {\n return false;\n }\n }\n});\n","var $ = require('../internals/export');\nvar anObject = require('../internals/an-object');\nvar isObject = require('../internals/is-object');\nvar has = require('../internals/has');\nvar fails = require('../internals/fails');\nvar definePropertyModule = require('../internals/object-define-property');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\n\n// `Reflect.set` method\n// https://tc39.github.io/ecma262/#sec-reflect.set\nfunction set(target, propertyKey, V /* , receiver */) {\n var receiver = arguments.length < 4 ? target : arguments[3];\n var ownDescriptor = getOwnPropertyDescriptorModule.f(anObject(target), propertyKey);\n var existingDescriptor, prototype;\n if (!ownDescriptor) {\n if (isObject(prototype = getPrototypeOf(target))) {\n return set(prototype, propertyKey, V, receiver);\n }\n ownDescriptor = createPropertyDescriptor(0);\n }\n if (has(ownDescriptor, 'value')) {\n if (ownDescriptor.writable === false || !isObject(receiver)) return false;\n if (existingDescriptor = getOwnPropertyDescriptorModule.f(receiver, propertyKey)) {\n if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false;\n existingDescriptor.value = V;\n definePropertyModule.f(receiver, propertyKey, existingDescriptor);\n } else definePropertyModule.f(receiver, propertyKey, createPropertyDescriptor(0, V));\n return true;\n }\n return ownDescriptor.set === undefined ? false : (ownDescriptor.set.call(receiver, V), true);\n}\n\n// MS Edge 17-18 Reflect.set allows setting the property to object\n// with non-writable property on the prototype\nvar MS_EDGE_BUG = fails(function () {\n var object = definePropertyModule.f({}, 'a', { configurable: true });\n // eslint-disable-next-line no-undef\n return Reflect.set(getPrototypeOf(object), 'a', 1, object) !== false;\n});\n\n$({ target: 'Reflect', stat: true, forced: MS_EDGE_BUG }, {\n set: set\n});\n","var $ = require('../internals/export');\nvar anObject = require('../internals/an-object');\nvar aPossiblePrototype = require('../internals/a-possible-prototype');\nvar objectSetPrototypeOf = require('../internals/object-set-prototype-of');\n\n// `Reflect.setPrototypeOf` method\n// https://tc39.github.io/ecma262/#sec-reflect.setprototypeof\nif (objectSetPrototypeOf) $({ target: 'Reflect', stat: true }, {\n setPrototypeOf: function setPrototypeOf(target, proto) {\n anObject(target);\n aPossiblePrototype(proto);\n try {\n objectSetPrototypeOf(target, proto);\n return true;\n } catch (error) {\n return false;\n }\n }\n});\n","var isObject = require('../internals/is-object');\nvar classof = require('../internals/classof-raw');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar MATCH = wellKnownSymbol('match');\n\n// `IsRegExp` abstract operation\n// https://tc39.github.io/ecma262/#sec-isregexp\nmodule.exports = function (it) {\n var isRegExp;\n return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');\n};\n","'use strict';\nvar anObject = require('../internals/an-object');\n\n// `RegExp.prototype.flags` getter implementation\n// https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags\nmodule.exports = function () {\n var that = anObject(this);\n var result = '';\n if (that.global) result += 'g';\n if (that.ignoreCase) result += 'i';\n if (that.multiline) result += 'm';\n if (that.dotAll) result += 's';\n if (that.unicode) result += 'u';\n if (that.sticky) result += 'y';\n return result;\n};\n","'use strict';\n\nvar fails = require('./fails');\n\n// babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError,\n// so we use an intermediate function.\nfunction RE(s, f) {\n return RegExp(s, f);\n}\n\nexports.UNSUPPORTED_Y = fails(function () {\n // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError\n var re = RE('a', 'y');\n re.lastIndex = 2;\n return re.exec('abcd') != null;\n});\n\nexports.BROKEN_CARET = fails(function () {\n // https://bugzilla.mozilla.org/show_bug.cgi?id=773687\n var re = RE('^r', 'gy');\n re.lastIndex = 2;\n return re.exec('str') != null;\n});\n","var DESCRIPTORS = require('../internals/descriptors');\nvar global = require('../internals/global');\nvar isForced = require('../internals/is-forced');\nvar inheritIfRequired = require('../internals/inherit-if-required');\nvar defineProperty = require('../internals/object-define-property').f;\nvar getOwnPropertyNames = require('../internals/object-get-own-property-names').f;\nvar isRegExp = require('../internals/is-regexp');\nvar getFlags = require('../internals/regexp-flags');\nvar stickyHelpers = require('../internals/regexp-sticky-helpers');\nvar redefine = require('../internals/redefine');\nvar fails = require('../internals/fails');\nvar setInternalState = require('../internals/internal-state').set;\nvar setSpecies = require('../internals/set-species');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar MATCH = wellKnownSymbol('match');\nvar NativeRegExp = global.RegExp;\nvar RegExpPrototype = NativeRegExp.prototype;\nvar re1 = /a/g;\nvar re2 = /a/g;\n\n// \"new\" should create a new object, old webkit bug\nvar CORRECT_NEW = new NativeRegExp(re1) !== re1;\n\nvar UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;\n\nvar FORCED = DESCRIPTORS && isForced('RegExp', (!CORRECT_NEW || UNSUPPORTED_Y || fails(function () {\n re2[MATCH] = false;\n // RegExp constructor can alter flags and IsRegExp works correct with @@match\n return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i';\n})));\n\n// `RegExp` constructor\n// https://tc39.github.io/ecma262/#sec-regexp-constructor\nif (FORCED) {\n var RegExpWrapper = function RegExp(pattern, flags) {\n var thisIsRegExp = this instanceof RegExpWrapper;\n var patternIsRegExp = isRegExp(pattern);\n var flagsAreUndefined = flags === undefined;\n var sticky;\n\n if (!thisIsRegExp && patternIsRegExp && pattern.constructor === RegExpWrapper && flagsAreUndefined) {\n return pattern;\n }\n\n if (CORRECT_NEW) {\n if (patternIsRegExp && !flagsAreUndefined) pattern = pattern.source;\n } else if (pattern instanceof RegExpWrapper) {\n if (flagsAreUndefined) flags = getFlags.call(pattern);\n pattern = pattern.source;\n }\n\n if (UNSUPPORTED_Y) {\n sticky = !!flags && flags.indexOf('y') > -1;\n if (sticky) flags = flags.replace(/y/g, '');\n }\n\n var result = inheritIfRequired(\n CORRECT_NEW ? new NativeRegExp(pattern, flags) : NativeRegExp(pattern, flags),\n thisIsRegExp ? this : RegExpPrototype,\n RegExpWrapper\n );\n\n if (UNSUPPORTED_Y && sticky) setInternalState(result, { sticky: sticky });\n\n return result;\n };\n var proxy = function (key) {\n key in RegExpWrapper || defineProperty(RegExpWrapper, key, {\n configurable: true,\n get: function () { return NativeRegExp[key]; },\n set: function (it) { NativeRegExp[key] = it; }\n });\n };\n var keys = getOwnPropertyNames(NativeRegExp);\n var index = 0;\n while (keys.length > index) proxy(keys[index++]);\n RegExpPrototype.constructor = RegExpWrapper;\n RegExpWrapper.prototype = RegExpPrototype;\n redefine(global, 'RegExp', RegExpWrapper);\n}\n\n// https://tc39.github.io/ecma262/#sec-get-regexp-@@species\nsetSpecies('RegExp');\n","'use strict';\nvar regexpFlags = require('./regexp-flags');\nvar stickyHelpers = require('./regexp-sticky-helpers');\n\nvar nativeExec = RegExp.prototype.exec;\n// This always refers to the native implementation, because the\n// String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,\n// which loads this file before patching the method.\nvar nativeReplace = String.prototype.replace;\n\nvar patchedExec = nativeExec;\n\nvar UPDATES_LAST_INDEX_WRONG = (function () {\n var re1 = /a/;\n var re2 = /b*/g;\n nativeExec.call(re1, 'a');\n nativeExec.call(re2, 'a');\n return re1.lastIndex !== 0 || re2.lastIndex !== 0;\n})();\n\nvar UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y || stickyHelpers.BROKEN_CARET;\n\n// nonparticipating capturing group, copied from es5-shim's String#split patch.\nvar NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;\n\nvar PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y;\n\nif (PATCH) {\n patchedExec = function exec(str) {\n var re = this;\n var lastIndex, reCopy, match, i;\n var sticky = UNSUPPORTED_Y && re.sticky;\n var flags = regexpFlags.call(re);\n var source = re.source;\n var charsAdded = 0;\n var strCopy = str;\n\n if (sticky) {\n flags = flags.replace('y', '');\n if (flags.indexOf('g') === -1) {\n flags += 'g';\n }\n\n strCopy = String(str).slice(re.lastIndex);\n // Support anchored sticky behavior.\n if (re.lastIndex > 0 && (!re.multiline || re.multiline && str[re.lastIndex - 1] !== '\\n')) {\n source = '(?: ' + source + ')';\n strCopy = ' ' + strCopy;\n charsAdded++;\n }\n // ^(? + rx + ) is needed, in combination with some str slicing, to\n // simulate the 'y' flag.\n reCopy = new RegExp('^(?:' + source + ')', flags);\n }\n\n if (NPCG_INCLUDED) {\n reCopy = new RegExp('^' + source + '$(?!\\\\s)', flags);\n }\n if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;\n\n match = nativeExec.call(sticky ? reCopy : re, strCopy);\n\n if (sticky) {\n if (match) {\n match.input = match.input.slice(charsAdded);\n match[0] = match[0].slice(charsAdded);\n match.index = re.lastIndex;\n re.lastIndex += match[0].length;\n } else re.lastIndex = 0;\n } else if (UPDATES_LAST_INDEX_WRONG && match) {\n re.lastIndex = re.global ? match.index + match[0].length : lastIndex;\n }\n if (NPCG_INCLUDED && match && match.length > 1) {\n // Fix browsers whose `exec` methods don't consistently return `undefined`\n // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/\n nativeReplace.call(match[0], reCopy, function () {\n for (i = 1; i < arguments.length - 2; i++) {\n if (arguments[i] === undefined) match[i] = undefined;\n }\n });\n }\n\n return match;\n };\n}\n\nmodule.exports = patchedExec;\n","'use strict';\nvar $ = require('../internals/export');\nvar exec = require('../internals/regexp-exec');\n\n$({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, {\n exec: exec\n});\n","var DESCRIPTORS = require('../internals/descriptors');\nvar objectDefinePropertyModule = require('../internals/object-define-property');\nvar regExpFlags = require('../internals/regexp-flags');\nvar UNSUPPORTED_Y = require('../internals/regexp-sticky-helpers').UNSUPPORTED_Y;\n\n// `RegExp.prototype.flags` getter\n// https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags\nif (DESCRIPTORS && (/./g.flags != 'g' || UNSUPPORTED_Y)) {\n objectDefinePropertyModule.f(RegExp.prototype, 'flags', {\n configurable: true,\n get: regExpFlags\n });\n}\n","var DESCRIPTORS = require('../internals/descriptors');\nvar UNSUPPORTED_Y = require('../internals/regexp-sticky-helpers').UNSUPPORTED_Y;\nvar defineProperty = require('../internals/object-define-property').f;\nvar getInternalState = require('../internals/internal-state').get;\nvar RegExpPrototype = RegExp.prototype;\n\n// `RegExp.prototype.sticky` getter\nif (DESCRIPTORS && UNSUPPORTED_Y) {\n defineProperty(RegExp.prototype, 'sticky', {\n configurable: true,\n get: function () {\n if (this === RegExpPrototype) return undefined;\n // We can't use InternalStateModule.getterFor because\n // we don't add metadata for regexps created by a literal.\n if (this instanceof RegExp) {\n return !!getInternalState(this).sticky;\n }\n throw TypeError('Incompatible receiver, RegExp required');\n }\n });\n}\n","'use strict';\n// TODO: Remove from `core-js@4` since it's moved to entry points\nrequire('../modules/es.regexp.exec');\nvar $ = require('../internals/export');\nvar isObject = require('../internals/is-object');\n\nvar DELEGATES_TO_EXEC = function () {\n var execCalled = false;\n var re = /[ac]/;\n re.exec = function () {\n execCalled = true;\n return /./.exec.apply(this, arguments);\n };\n return re.test('abc') === true && execCalled;\n}();\n\nvar nativeTest = /./.test;\n\n$({ target: 'RegExp', proto: true, forced: !DELEGATES_TO_EXEC }, {\n test: function (str) {\n if (typeof this.exec !== 'function') {\n return nativeTest.call(this, str);\n }\n var result = this.exec(str);\n if (result !== null && !isObject(result)) {\n throw new Error('RegExp exec method returned something other than an Object or null');\n }\n return !!result;\n }\n});\n","'use strict';\nvar redefine = require('../internals/redefine');\nvar anObject = require('../internals/an-object');\nvar fails = require('../internals/fails');\nvar flags = require('../internals/regexp-flags');\n\nvar TO_STRING = 'toString';\nvar RegExpPrototype = RegExp.prototype;\nvar nativeToString = RegExpPrototype[TO_STRING];\n\nvar NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });\n// FF44- RegExp#toString has a wrong name\nvar INCORRECT_NAME = nativeToString.name != TO_STRING;\n\n// `RegExp.prototype.toString` method\n// https://tc39.github.io/ecma262/#sec-regexp.prototype.tostring\nif (NOT_GENERIC || INCORRECT_NAME) {\n redefine(RegExp.prototype, TO_STRING, function toString() {\n var R = anObject(this);\n var p = String(R.source);\n var rf = R.flags;\n var f = String(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype) ? flags.call(R) : rf);\n return '/' + p + '/' + f;\n }, { unsafe: true });\n}\n","'use strict';\nvar collection = require('../internals/collection');\nvar collectionStrong = require('../internals/collection-strong');\n\n// `Set` constructor\n// https://tc39.github.io/ecma262/#sec-set-objects\nmodule.exports = collection('Set', function (init) {\n return function Set() { return init(this, arguments.length ? arguments[0] : undefined); };\n}, collectionStrong);\n","var toInteger = require('../internals/to-integer');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\n\n// `String.prototype.{ codePointAt, at }` methods implementation\nvar createMethod = function (CONVERT_TO_STRING) {\n return function ($this, pos) {\n var S = String(requireObjectCoercible($this));\n var position = toInteger(pos);\n var size = S.length;\n var first, second;\n if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;\n first = S.charCodeAt(position);\n return first < 0xD800 || first > 0xDBFF || position + 1 === size\n || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF\n ? CONVERT_TO_STRING ? S.charAt(position) : first\n : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;\n };\n};\n\nmodule.exports = {\n // `String.prototype.codePointAt` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.codepointat\n codeAt: createMethod(false),\n // `String.prototype.at` method\n // https://github.com/mathiasbynens/String.prototype.at\n charAt: createMethod(true)\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar codeAt = require('../internals/string-multibyte').codeAt;\n\n// `String.prototype.codePointAt` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.codepointat\n$({ target: 'String', proto: true }, {\n codePointAt: function codePointAt(pos) {\n return codeAt(this, pos);\n }\n});\n","var isRegExp = require('../internals/is-regexp');\n\nmodule.exports = function (it) {\n if (isRegExp(it)) {\n throw TypeError(\"The method doesn't accept regular expressions\");\n } return it;\n};\n","var wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar MATCH = wellKnownSymbol('match');\n\nmodule.exports = function (METHOD_NAME) {\n var regexp = /./;\n try {\n '/./'[METHOD_NAME](regexp);\n } catch (e) {\n try {\n regexp[MATCH] = false;\n return '/./'[METHOD_NAME](regexp);\n } catch (f) { /* empty */ }\n } return false;\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\nvar toLength = require('../internals/to-length');\nvar notARegExp = require('../internals/not-a-regexp');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar correctIsRegExpLogic = require('../internals/correct-is-regexp-logic');\nvar IS_PURE = require('../internals/is-pure');\n\nvar nativeEndsWith = ''.endsWith;\nvar min = Math.min;\n\nvar CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('endsWith');\n// https://github.com/zloirock/core-js/pull/702\nvar MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {\n var descriptor = getOwnPropertyDescriptor(String.prototype, 'endsWith');\n return descriptor && !descriptor.writable;\n}();\n\n// `String.prototype.endsWith` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.endswith\n$({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {\n endsWith: function endsWith(searchString /* , endPosition = @length */) {\n var that = String(requireObjectCoercible(this));\n notARegExp(searchString);\n var endPosition = arguments.length > 1 ? arguments[1] : undefined;\n var len = toLength(that.length);\n var end = endPosition === undefined ? len : min(toLength(endPosition), len);\n var search = String(searchString);\n return nativeEndsWith\n ? nativeEndsWith.call(that, search, end)\n : that.slice(end - search.length, end) === search;\n }\n});\n","var $ = require('../internals/export');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\n\nvar fromCharCode = String.fromCharCode;\nvar nativeFromCodePoint = String.fromCodePoint;\n\n// length should be 1, old FF problem\nvar INCORRECT_LENGTH = !!nativeFromCodePoint && nativeFromCodePoint.length != 1;\n\n// `String.fromCodePoint` method\n// https://tc39.github.io/ecma262/#sec-string.fromcodepoint\n$({ target: 'String', stat: true, forced: INCORRECT_LENGTH }, {\n fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars\n var elements = [];\n var length = arguments.length;\n var i = 0;\n var code;\n while (length > i) {\n code = +arguments[i++];\n if (toAbsoluteIndex(code, 0x10FFFF) !== code) throw RangeError(code + ' is not a valid code point');\n elements.push(code < 0x10000\n ? fromCharCode(code)\n : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00)\n );\n } return elements.join('');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar notARegExp = require('../internals/not-a-regexp');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar correctIsRegExpLogic = require('../internals/correct-is-regexp-logic');\n\n// `String.prototype.includes` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.includes\n$({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {\n includes: function includes(searchString /* , position = 0 */) {\n return !!~String(requireObjectCoercible(this))\n .indexOf(notARegExp(searchString), arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar charAt = require('../internals/string-multibyte').charAt;\nvar InternalStateModule = require('../internals/internal-state');\nvar defineIterator = require('../internals/define-iterator');\n\nvar STRING_ITERATOR = 'String Iterator';\nvar setInternalState = InternalStateModule.set;\nvar getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);\n\n// `String.prototype[@@iterator]` method\n// https://tc39.github.io/ecma262/#sec-string.prototype-@@iterator\ndefineIterator(String, 'String', function (iterated) {\n setInternalState(this, {\n type: STRING_ITERATOR,\n string: String(iterated),\n index: 0\n });\n// `%StringIteratorPrototype%.next` method\n// https://tc39.github.io/ecma262/#sec-%stringiteratorprototype%.next\n}, function next() {\n var state = getInternalState(this);\n var string = state.string;\n var index = state.index;\n var point;\n if (index >= string.length) return { value: undefined, done: true };\n point = charAt(string, index);\n state.index += point.length;\n return { value: point, done: false };\n});\n","'use strict';\n// TODO: Remove from `core-js@4` since it's moved to entry points\nrequire('../modules/es.regexp.exec');\nvar redefine = require('../internals/redefine');\nvar fails = require('../internals/fails');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar regexpExec = require('../internals/regexp-exec');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\n\nvar SPECIES = wellKnownSymbol('species');\n\nvar REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {\n // #replace needs built-in support for named groups.\n // #match works fine because it just return the exec results, even if it has\n // a \"grops\" property.\n var re = /./;\n re.exec = function () {\n var result = [];\n result.groups = { a: '7' };\n return result;\n };\n return ''.replace(re, '$') !== '7';\n});\n\n// IE <= 11 replaces $0 with the whole match, as if it was $&\n// https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0\nvar REPLACE_KEEPS_$0 = (function () {\n return 'a'.replace(/./, '$0') === '$0';\n})();\n\nvar REPLACE = wellKnownSymbol('replace');\n// Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string\nvar REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () {\n if (/./[REPLACE]) {\n return /./[REPLACE]('a', '$0') === '';\n }\n return false;\n})();\n\n// Chrome 51 has a buggy \"split\" implementation when RegExp#exec !== nativeExec\n// Weex JS has frozen built-in prototypes, so use try / catch wrapper\nvar SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {\n var re = /(?:)/;\n var originalExec = re.exec;\n re.exec = function () { return originalExec.apply(this, arguments); };\n var result = 'ab'.split(re);\n return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';\n});\n\nmodule.exports = function (KEY, length, exec, sham) {\n var SYMBOL = wellKnownSymbol(KEY);\n\n var DELEGATES_TO_SYMBOL = !fails(function () {\n // String methods call symbol-named RegEp methods\n var O = {};\n O[SYMBOL] = function () { return 7; };\n return ''[KEY](O) != 7;\n });\n\n var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {\n // Symbol-named RegExp methods call .exec\n var execCalled = false;\n var re = /a/;\n\n if (KEY === 'split') {\n // We can't use real regex here since it causes deoptimization\n // and serious performance degradation in V8\n // https://github.com/zloirock/core-js/issues/306\n re = {};\n // RegExp[@@split] doesn't call the regex's exec method, but first creates\n // a new one. We need to return the patched regex when creating the new one.\n re.constructor = {};\n re.constructor[SPECIES] = function () { return re; };\n re.flags = '';\n re[SYMBOL] = /./[SYMBOL];\n }\n\n re.exec = function () { execCalled = true; return null; };\n\n re[SYMBOL]('');\n return !execCalled;\n });\n\n if (\n !DELEGATES_TO_SYMBOL ||\n !DELEGATES_TO_EXEC ||\n (KEY === 'replace' && !(\n REPLACE_SUPPORTS_NAMED_GROUPS &&\n REPLACE_KEEPS_$0 &&\n !REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE\n )) ||\n (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)\n ) {\n var nativeRegExpMethod = /./[SYMBOL];\n var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {\n if (regexp.exec === regexpExec) {\n if (DELEGATES_TO_SYMBOL && !forceStringMethod) {\n // The native String method already delegates to @@method (this\n // polyfilled function), leasing to infinite recursion.\n // We avoid it by directly calling the native @@method method.\n return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };\n }\n return { done: true, value: nativeMethod.call(str, regexp, arg2) };\n }\n return { done: false };\n }, {\n REPLACE_KEEPS_$0: REPLACE_KEEPS_$0,\n REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE: REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE\n });\n var stringMethod = methods[0];\n var regexMethod = methods[1];\n\n redefine(String.prototype, KEY, stringMethod);\n redefine(RegExp.prototype, SYMBOL, length == 2\n // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)\n // 21.2.5.11 RegExp.prototype[@@split](string, limit)\n ? function (string, arg) { return regexMethod.call(string, this, arg); }\n // 21.2.5.6 RegExp.prototype[@@match](string)\n // 21.2.5.9 RegExp.prototype[@@search](string)\n : function (string) { return regexMethod.call(string, this); }\n );\n }\n\n if (sham) createNonEnumerableProperty(RegExp.prototype[SYMBOL], 'sham', true);\n};\n","'use strict';\nvar charAt = require('../internals/string-multibyte').charAt;\n\n// `AdvanceStringIndex` abstract operation\n// https://tc39.github.io/ecma262/#sec-advancestringindex\nmodule.exports = function (S, index, unicode) {\n return index + (unicode ? charAt(S, index).length : 1);\n};\n","var classof = require('./classof-raw');\nvar regexpExec = require('./regexp-exec');\n\n// `RegExpExec` abstract operation\n// https://tc39.github.io/ecma262/#sec-regexpexec\nmodule.exports = function (R, S) {\n var exec = R.exec;\n if (typeof exec === 'function') {\n var result = exec.call(R, S);\n if (typeof result !== 'object') {\n throw TypeError('RegExp exec method returned something other than an Object or null');\n }\n return result;\n }\n\n if (classof(R) !== 'RegExp') {\n throw TypeError('RegExp#exec called on incompatible receiver');\n }\n\n return regexpExec.call(R, S);\n};\n\n","'use strict';\nvar fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');\nvar anObject = require('../internals/an-object');\nvar toLength = require('../internals/to-length');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar advanceStringIndex = require('../internals/advance-string-index');\nvar regExpExec = require('../internals/regexp-exec-abstract');\n\n// @@match logic\nfixRegExpWellKnownSymbolLogic('match', 1, function (MATCH, nativeMatch, maybeCallNative) {\n return [\n // `String.prototype.match` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.match\n function match(regexp) {\n var O = requireObjectCoercible(this);\n var matcher = regexp == undefined ? undefined : regexp[MATCH];\n return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));\n },\n // `RegExp.prototype[@@match]` method\n // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match\n function (regexp) {\n var res = maybeCallNative(nativeMatch, regexp, this);\n if (res.done) return res.value;\n\n var rx = anObject(regexp);\n var S = String(this);\n\n if (!rx.global) return regExpExec(rx, S);\n\n var fullUnicode = rx.unicode;\n rx.lastIndex = 0;\n var A = [];\n var n = 0;\n var result;\n while ((result = regExpExec(rx, S)) !== null) {\n var matchStr = String(result[0]);\n A[n] = matchStr;\n if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);\n n++;\n }\n return n === 0 ? null : A;\n }\n ];\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createIteratorConstructor = require('../internals/create-iterator-constructor');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar toLength = require('../internals/to-length');\nvar aFunction = require('../internals/a-function');\nvar anObject = require('../internals/an-object');\nvar classof = require('../internals/classof-raw');\nvar isRegExp = require('../internals/is-regexp');\nvar getRegExpFlags = require('../internals/regexp-flags');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar fails = require('../internals/fails');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar speciesConstructor = require('../internals/species-constructor');\nvar advanceStringIndex = require('../internals/advance-string-index');\nvar InternalStateModule = require('../internals/internal-state');\nvar IS_PURE = require('../internals/is-pure');\n\nvar MATCH_ALL = wellKnownSymbol('matchAll');\nvar REGEXP_STRING = 'RegExp String';\nvar REGEXP_STRING_ITERATOR = REGEXP_STRING + ' Iterator';\nvar setInternalState = InternalStateModule.set;\nvar getInternalState = InternalStateModule.getterFor(REGEXP_STRING_ITERATOR);\nvar RegExpPrototype = RegExp.prototype;\nvar regExpBuiltinExec = RegExpPrototype.exec;\nvar nativeMatchAll = ''.matchAll;\n\nvar WORKS_WITH_NON_GLOBAL_REGEX = !!nativeMatchAll && !fails(function () {\n 'a'.matchAll(/./);\n});\n\nvar regExpExec = function (R, S) {\n var exec = R.exec;\n var result;\n if (typeof exec == 'function') {\n result = exec.call(R, S);\n if (typeof result != 'object') throw TypeError('Incorrect exec result');\n return result;\n } return regExpBuiltinExec.call(R, S);\n};\n\n// eslint-disable-next-line max-len\nvar $RegExpStringIterator = createIteratorConstructor(function RegExpStringIterator(regexp, string, global, fullUnicode) {\n setInternalState(this, {\n type: REGEXP_STRING_ITERATOR,\n regexp: regexp,\n string: string,\n global: global,\n unicode: fullUnicode,\n done: false\n });\n}, REGEXP_STRING, function next() {\n var state = getInternalState(this);\n if (state.done) return { value: undefined, done: true };\n var R = state.regexp;\n var S = state.string;\n var match = regExpExec(R, S);\n if (match === null) return { value: undefined, done: state.done = true };\n if (state.global) {\n if (String(match[0]) == '') R.lastIndex = advanceStringIndex(S, toLength(R.lastIndex), state.unicode);\n return { value: match, done: false };\n }\n state.done = true;\n return { value: match, done: false };\n});\n\nvar $matchAll = function (string) {\n var R = anObject(this);\n var S = String(string);\n var C, flagsValue, flags, matcher, global, fullUnicode;\n C = speciesConstructor(R, RegExp);\n flagsValue = R.flags;\n if (flagsValue === undefined && R instanceof RegExp && !('flags' in RegExpPrototype)) {\n flagsValue = getRegExpFlags.call(R);\n }\n flags = flagsValue === undefined ? '' : String(flagsValue);\n matcher = new C(C === RegExp ? R.source : R, flags);\n global = !!~flags.indexOf('g');\n fullUnicode = !!~flags.indexOf('u');\n matcher.lastIndex = toLength(R.lastIndex);\n return new $RegExpStringIterator(matcher, S, global, fullUnicode);\n};\n\n// `String.prototype.matchAll` method\n// https://github.com/tc39/proposal-string-matchall\n$({ target: 'String', proto: true, forced: WORKS_WITH_NON_GLOBAL_REGEX }, {\n matchAll: function matchAll(regexp) {\n var O = requireObjectCoercible(this);\n var flags, S, matcher, rx;\n if (regexp != null) {\n if (isRegExp(regexp)) {\n flags = String(requireObjectCoercible('flags' in RegExpPrototype\n ? regexp.flags\n : getRegExpFlags.call(regexp)\n ));\n if (!~flags.indexOf('g')) throw TypeError('`.matchAll` does not allow non-global regexes');\n }\n if (WORKS_WITH_NON_GLOBAL_REGEX) return nativeMatchAll.apply(O, arguments);\n matcher = regexp[MATCH_ALL];\n if (matcher === undefined && IS_PURE && classof(regexp) == 'RegExp') matcher = $matchAll;\n if (matcher != null) return aFunction(matcher).call(regexp, O);\n } else if (WORKS_WITH_NON_GLOBAL_REGEX) return nativeMatchAll.apply(O, arguments);\n S = String(O);\n rx = new RegExp(regexp, 'g');\n return IS_PURE ? $matchAll.call(rx, S) : rx[MATCH_ALL](S);\n }\n});\n\nIS_PURE || MATCH_ALL in RegExpPrototype || createNonEnumerableProperty(RegExpPrototype, MATCH_ALL, $matchAll);\n","// https://github.com/zloirock/core-js/issues/280\nvar userAgent = require('../internals/engine-user-agent');\n\n// eslint-disable-next-line unicorn/no-unsafe-regex\nmodule.exports = /Version\\/10\\.\\d+(\\.\\d+)?( Mobile\\/\\w+)? Safari\\//.test(userAgent);\n","'use strict';\nvar $ = require('../internals/export');\nvar $padEnd = require('../internals/string-pad').end;\nvar WEBKIT_BUG = require('../internals/string-pad-webkit-bug');\n\n// `String.prototype.padEnd` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.padend\n$({ target: 'String', proto: true, forced: WEBKIT_BUG }, {\n padEnd: function padEnd(maxLength /* , fillString = ' ' */) {\n return $padEnd(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $padStart = require('../internals/string-pad').start;\nvar WEBKIT_BUG = require('../internals/string-pad-webkit-bug');\n\n// `String.prototype.padStart` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.padstart\n$({ target: 'String', proto: true, forced: WEBKIT_BUG }, {\n padStart: function padStart(maxLength /* , fillString = ' ' */) {\n return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","var $ = require('../internals/export');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar toLength = require('../internals/to-length');\n\n// `String.raw` method\n// https://tc39.github.io/ecma262/#sec-string.raw\n$({ target: 'String', stat: true }, {\n raw: function raw(template) {\n var rawTemplate = toIndexedObject(template.raw);\n var literalSegments = toLength(rawTemplate.length);\n var argumentsLength = arguments.length;\n var elements = [];\n var i = 0;\n while (literalSegments > i) {\n elements.push(String(rawTemplate[i++]));\n if (i < argumentsLength) elements.push(String(arguments[i]));\n } return elements.join('');\n }\n});\n","var $ = require('../internals/export');\nvar repeat = require('../internals/string-repeat');\n\n// `String.prototype.repeat` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.repeat\n$({ target: 'String', proto: true }, {\n repeat: repeat\n});\n","'use strict';\nvar fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');\nvar anObject = require('../internals/an-object');\nvar toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar toInteger = require('../internals/to-integer');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar advanceStringIndex = require('../internals/advance-string-index');\nvar regExpExec = require('../internals/regexp-exec-abstract');\n\nvar max = Math.max;\nvar min = Math.min;\nvar floor = Math.floor;\nvar SUBSTITUTION_SYMBOLS = /\\$([$&'`]|\\d\\d?|<[^>]*>)/g;\nvar SUBSTITUTION_SYMBOLS_NO_NAMED = /\\$([$&'`]|\\d\\d?)/g;\n\nvar maybeToString = function (it) {\n return it === undefined ? it : String(it);\n};\n\n// @@replace logic\nfixRegExpWellKnownSymbolLogic('replace', 2, function (REPLACE, nativeReplace, maybeCallNative, reason) {\n var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = reason.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE;\n var REPLACE_KEEPS_$0 = reason.REPLACE_KEEPS_$0;\n var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0';\n\n return [\n // `String.prototype.replace` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.replace\n function replace(searchValue, replaceValue) {\n var O = requireObjectCoercible(this);\n var replacer = searchValue == undefined ? undefined : searchValue[REPLACE];\n return replacer !== undefined\n ? replacer.call(searchValue, O, replaceValue)\n : nativeReplace.call(String(O), searchValue, replaceValue);\n },\n // `RegExp.prototype[@@replace]` method\n // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace\n function (regexp, replaceValue) {\n if (\n (!REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE && REPLACE_KEEPS_$0) ||\n (typeof replaceValue === 'string' && replaceValue.indexOf(UNSAFE_SUBSTITUTE) === -1)\n ) {\n var res = maybeCallNative(nativeReplace, regexp, this, replaceValue);\n if (res.done) return res.value;\n }\n\n var rx = anObject(regexp);\n var S = String(this);\n\n var functionalReplace = typeof replaceValue === 'function';\n if (!functionalReplace) replaceValue = String(replaceValue);\n\n var global = rx.global;\n if (global) {\n var fullUnicode = rx.unicode;\n rx.lastIndex = 0;\n }\n var results = [];\n while (true) {\n var result = regExpExec(rx, S);\n if (result === null) break;\n\n results.push(result);\n if (!global) break;\n\n var matchStr = String(result[0]);\n if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);\n }\n\n var accumulatedResult = '';\n var nextSourcePosition = 0;\n for (var i = 0; i < results.length; i++) {\n result = results[i];\n\n var matched = String(result[0]);\n var position = max(min(toInteger(result.index), S.length), 0);\n var captures = [];\n // NOTE: This is equivalent to\n // captures = result.slice(1).map(maybeToString)\n // but for some reason `nativeSlice.call(result, 1, result.length)` (called in\n // the slice polyfill when slicing native arrays) \"doesn't work\" in safari 9 and\n // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.\n for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));\n var namedCaptures = result.groups;\n if (functionalReplace) {\n var replacerArgs = [matched].concat(captures, position, S);\n if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);\n var replacement = String(replaceValue.apply(undefined, replacerArgs));\n } else {\n replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);\n }\n if (position >= nextSourcePosition) {\n accumulatedResult += S.slice(nextSourcePosition, position) + replacement;\n nextSourcePosition = position + matched.length;\n }\n }\n return accumulatedResult + S.slice(nextSourcePosition);\n }\n ];\n\n // https://tc39.github.io/ecma262/#sec-getsubstitution\n function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {\n var tailPos = position + matched.length;\n var m = captures.length;\n var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;\n if (namedCaptures !== undefined) {\n namedCaptures = toObject(namedCaptures);\n symbols = SUBSTITUTION_SYMBOLS;\n }\n return nativeReplace.call(replacement, symbols, function (match, ch) {\n var capture;\n switch (ch.charAt(0)) {\n case '$': return '$';\n case '&': return matched;\n case '`': return str.slice(0, position);\n case \"'\": return str.slice(tailPos);\n case '<':\n capture = namedCaptures[ch.slice(1, -1)];\n break;\n default: // \\d\\d?\n var n = +ch;\n if (n === 0) return match;\n if (n > m) {\n var f = floor(n / 10);\n if (f === 0) return match;\n if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);\n return match;\n }\n capture = captures[n - 1];\n }\n return capture === undefined ? '' : capture;\n });\n }\n});\n","'use strict';\nvar fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');\nvar anObject = require('../internals/an-object');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar sameValue = require('../internals/same-value');\nvar regExpExec = require('../internals/regexp-exec-abstract');\n\n// @@search logic\nfixRegExpWellKnownSymbolLogic('search', 1, function (SEARCH, nativeSearch, maybeCallNative) {\n return [\n // `String.prototype.search` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.search\n function search(regexp) {\n var O = requireObjectCoercible(this);\n var searcher = regexp == undefined ? undefined : regexp[SEARCH];\n return searcher !== undefined ? searcher.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));\n },\n // `RegExp.prototype[@@search]` method\n // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@search\n function (regexp) {\n var res = maybeCallNative(nativeSearch, regexp, this);\n if (res.done) return res.value;\n\n var rx = anObject(regexp);\n var S = String(this);\n\n var previousLastIndex = rx.lastIndex;\n if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0;\n var result = regExpExec(rx, S);\n if (!sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex;\n return result === null ? -1 : result.index;\n }\n ];\n});\n","'use strict';\nvar fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');\nvar isRegExp = require('../internals/is-regexp');\nvar anObject = require('../internals/an-object');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar speciesConstructor = require('../internals/species-constructor');\nvar advanceStringIndex = require('../internals/advance-string-index');\nvar toLength = require('../internals/to-length');\nvar callRegExpExec = require('../internals/regexp-exec-abstract');\nvar regexpExec = require('../internals/regexp-exec');\nvar fails = require('../internals/fails');\n\nvar arrayPush = [].push;\nvar min = Math.min;\nvar MAX_UINT32 = 0xFFFFFFFF;\n\n// babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError\nvar SUPPORTS_Y = !fails(function () { return !RegExp(MAX_UINT32, 'y'); });\n\n// @@split logic\nfixRegExpWellKnownSymbolLogic('split', 2, function (SPLIT, nativeSplit, maybeCallNative) {\n var internalSplit;\n if (\n 'abbc'.split(/(b)*/)[1] == 'c' ||\n 'test'.split(/(?:)/, -1).length != 4 ||\n 'ab'.split(/(?:ab)*/).length != 2 ||\n '.'.split(/(.?)(.?)/).length != 4 ||\n '.'.split(/()()/).length > 1 ||\n ''.split(/.?/).length\n ) {\n // based on es5-shim implementation, need to rework it\n internalSplit = function (separator, limit) {\n var string = String(requireObjectCoercible(this));\n var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;\n if (lim === 0) return [];\n if (separator === undefined) return [string];\n // If `separator` is not a regex, use native split\n if (!isRegExp(separator)) {\n return nativeSplit.call(string, separator, lim);\n }\n var output = [];\n var flags = (separator.ignoreCase ? 'i' : '') +\n (separator.multiline ? 'm' : '') +\n (separator.unicode ? 'u' : '') +\n (separator.sticky ? 'y' : '');\n var lastLastIndex = 0;\n // Make `global` and avoid `lastIndex` issues by working with a copy\n var separatorCopy = new RegExp(separator.source, flags + 'g');\n var match, lastIndex, lastLength;\n while (match = regexpExec.call(separatorCopy, string)) {\n lastIndex = separatorCopy.lastIndex;\n if (lastIndex > lastLastIndex) {\n output.push(string.slice(lastLastIndex, match.index));\n if (match.length > 1 && match.index < string.length) arrayPush.apply(output, match.slice(1));\n lastLength = match[0].length;\n lastLastIndex = lastIndex;\n if (output.length >= lim) break;\n }\n if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop\n }\n if (lastLastIndex === string.length) {\n if (lastLength || !separatorCopy.test('')) output.push('');\n } else output.push(string.slice(lastLastIndex));\n return output.length > lim ? output.slice(0, lim) : output;\n };\n // Chakra, V8\n } else if ('0'.split(undefined, 0).length) {\n internalSplit = function (separator, limit) {\n return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit);\n };\n } else internalSplit = nativeSplit;\n\n return [\n // `String.prototype.split` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.split\n function split(separator, limit) {\n var O = requireObjectCoercible(this);\n var splitter = separator == undefined ? undefined : separator[SPLIT];\n return splitter !== undefined\n ? splitter.call(separator, O, limit)\n : internalSplit.call(String(O), separator, limit);\n },\n // `RegExp.prototype[@@split]` method\n // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split\n //\n // NOTE: This cannot be properly polyfilled in engines that don't support\n // the 'y' flag.\n function (regexp, limit) {\n var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== nativeSplit);\n if (res.done) return res.value;\n\n var rx = anObject(regexp);\n var S = String(this);\n var C = speciesConstructor(rx, RegExp);\n\n var unicodeMatching = rx.unicode;\n var flags = (rx.ignoreCase ? 'i' : '') +\n (rx.multiline ? 'm' : '') +\n (rx.unicode ? 'u' : '') +\n (SUPPORTS_Y ? 'y' : 'g');\n\n // ^(? + rx + ) is needed, in combination with some S slicing, to\n // simulate the 'y' flag.\n var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags);\n var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;\n if (lim === 0) return [];\n if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : [];\n var p = 0;\n var q = 0;\n var A = [];\n while (q < S.length) {\n splitter.lastIndex = SUPPORTS_Y ? q : 0;\n var z = callRegExpExec(splitter, SUPPORTS_Y ? S : S.slice(q));\n var e;\n if (\n z === null ||\n (e = min(toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p\n ) {\n q = advanceStringIndex(S, q, unicodeMatching);\n } else {\n A.push(S.slice(p, q));\n if (A.length === lim) return A;\n for (var i = 1; i <= z.length - 1; i++) {\n A.push(z[i]);\n if (A.length === lim) return A;\n }\n q = p = e;\n }\n }\n A.push(S.slice(p));\n return A;\n }\n ];\n}, !SUPPORTS_Y);\n","'use strict';\nvar $ = require('../internals/export');\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\nvar toLength = require('../internals/to-length');\nvar notARegExp = require('../internals/not-a-regexp');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar correctIsRegExpLogic = require('../internals/correct-is-regexp-logic');\nvar IS_PURE = require('../internals/is-pure');\n\nvar nativeStartsWith = ''.startsWith;\nvar min = Math.min;\n\nvar CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith');\n// https://github.com/zloirock/core-js/pull/702\nvar MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {\n var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith');\n return descriptor && !descriptor.writable;\n}();\n\n// `String.prototype.startsWith` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.startswith\n$({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {\n startsWith: function startsWith(searchString /* , position = 0 */) {\n var that = String(requireObjectCoercible(this));\n notARegExp(searchString);\n var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length));\n var search = String(searchString);\n return nativeStartsWith\n ? nativeStartsWith.call(that, search, index)\n : that.slice(index, index + search.length) === search;\n }\n});\n","var fails = require('../internals/fails');\nvar whitespaces = require('../internals/whitespaces');\n\nvar non = '\\u200B\\u0085\\u180E';\n\n// check that a method works with the correct list\n// of whitespaces and has a correct name\nmodule.exports = function (METHOD_NAME) {\n return fails(function () {\n return !!whitespaces[METHOD_NAME]() || non[METHOD_NAME]() != non || whitespaces[METHOD_NAME].name !== METHOD_NAME;\n });\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar $trim = require('../internals/string-trim').trim;\nvar forcedStringTrimMethod = require('../internals/string-trim-forced');\n\n// `String.prototype.trim` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.trim\n$({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {\n trim: function trim() {\n return $trim(this);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $trimEnd = require('../internals/string-trim').end;\nvar forcedStringTrimMethod = require('../internals/string-trim-forced');\n\nvar FORCED = forcedStringTrimMethod('trimEnd');\n\nvar trimEnd = FORCED ? function trimEnd() {\n return $trimEnd(this);\n} : ''.trimEnd;\n\n// `String.prototype.{ trimEnd, trimRight }` methods\n// https://github.com/tc39/ecmascript-string-left-right-trim\n$({ target: 'String', proto: true, forced: FORCED }, {\n trimEnd: trimEnd,\n trimRight: trimEnd\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $trimStart = require('../internals/string-trim').start;\nvar forcedStringTrimMethod = require('../internals/string-trim-forced');\n\nvar FORCED = forcedStringTrimMethod('trimStart');\n\nvar trimStart = FORCED ? function trimStart() {\n return $trimStart(this);\n} : ''.trimStart;\n\n// `String.prototype.{ trimStart, trimLeft }` methods\n// https://github.com/tc39/ecmascript-string-left-right-trim\n$({ target: 'String', proto: true, forced: FORCED }, {\n trimStart: trimStart,\n trimLeft: trimStart\n});\n","var requireObjectCoercible = require('../internals/require-object-coercible');\n\nvar quot = /\"/g;\n\n// B.2.3.2.1 CreateHTML(string, tag, attribute, value)\n// https://tc39.github.io/ecma262/#sec-createhtml\nmodule.exports = function (string, tag, attribute, value) {\n var S = String(requireObjectCoercible(string));\n var p1 = '<' + tag;\n if (attribute !== '') p1 += ' ' + attribute + '=\"' + String(value).replace(quot, '"') + '\"';\n return p1 + '>' + S + '';\n};\n","var fails = require('../internals/fails');\n\n// check the existence of a method, lowercase\n// of a tag and escaping quotes in arguments\nmodule.exports = function (METHOD_NAME) {\n return fails(function () {\n var test = ''[METHOD_NAME]('\"');\n return test !== test.toLowerCase() || test.split('\"').length > 3;\n });\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.anchor` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.anchor\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('anchor') }, {\n anchor: function anchor(name) {\n return createHTML(this, 'a', 'name', name);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.big` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.big\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('big') }, {\n big: function big() {\n return createHTML(this, 'big', '', '');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.blink` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.blink\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('blink') }, {\n blink: function blink() {\n return createHTML(this, 'blink', '', '');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.bold` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.bold\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('bold') }, {\n bold: function bold() {\n return createHTML(this, 'b', '', '');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.fixed` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.fixed\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('fixed') }, {\n fixed: function fixed() {\n return createHTML(this, 'tt', '', '');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.fontcolor` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.fontcolor\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('fontcolor') }, {\n fontcolor: function fontcolor(color) {\n return createHTML(this, 'font', 'color', color);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.fontsize` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.fontsize\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('fontsize') }, {\n fontsize: function fontsize(size) {\n return createHTML(this, 'font', 'size', size);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.italics` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.italics\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('italics') }, {\n italics: function italics() {\n return createHTML(this, 'i', '', '');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.link` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.link\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('link') }, {\n link: function link(url) {\n return createHTML(this, 'a', 'href', url);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.small` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.small\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('small') }, {\n small: function small() {\n return createHTML(this, 'small', '', '');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.strike` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.strike\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('strike') }, {\n strike: function strike() {\n return createHTML(this, 'strike', '', '');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.sub` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.sub\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('sub') }, {\n sub: function sub() {\n return createHTML(this, 'sub', '', '');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.sup` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.sup\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('sup') }, {\n sup: function sup() {\n return createHTML(this, 'sup', '', '');\n }\n});\n","/* eslint-disable no-new */\nvar global = require('../internals/global');\nvar fails = require('../internals/fails');\nvar checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration');\nvar NATIVE_ARRAY_BUFFER_VIEWS = require('../internals/array-buffer-view-core').NATIVE_ARRAY_BUFFER_VIEWS;\n\nvar ArrayBuffer = global.ArrayBuffer;\nvar Int8Array = global.Int8Array;\n\nmodule.exports = !NATIVE_ARRAY_BUFFER_VIEWS || !fails(function () {\n Int8Array(1);\n}) || !fails(function () {\n new Int8Array(-1);\n}) || !checkCorrectnessOfIteration(function (iterable) {\n new Int8Array();\n new Int8Array(null);\n new Int8Array(1.5);\n new Int8Array(iterable);\n}, true) || fails(function () {\n // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill\n return new Int8Array(new ArrayBuffer(2), 1, undefined).length !== 1;\n});\n","var toInteger = require('../internals/to-integer');\n\nmodule.exports = function (it) {\n var result = toInteger(it);\n if (result < 0) throw RangeError(\"The argument can't be less than 0\");\n return result;\n};\n","var toPositiveInteger = require('../internals/to-positive-integer');\n\nmodule.exports = function (it, BYTES) {\n var offset = toPositiveInteger(it);\n if (offset % BYTES) throw RangeError('Wrong offset');\n return offset;\n};\n","var toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar getIteratorMethod = require('../internals/get-iterator-method');\nvar isArrayIteratorMethod = require('../internals/is-array-iterator-method');\nvar bind = require('../internals/function-bind-context');\nvar aTypedArrayConstructor = require('../internals/array-buffer-view-core').aTypedArrayConstructor;\n\nmodule.exports = function from(source /* , mapfn, thisArg */) {\n var O = toObject(source);\n var argumentsLength = arguments.length;\n var mapfn = argumentsLength > 1 ? arguments[1] : undefined;\n var mapping = mapfn !== undefined;\n var iteratorMethod = getIteratorMethod(O);\n var i, length, result, step, iterator, next;\n if (iteratorMethod != undefined && !isArrayIteratorMethod(iteratorMethod)) {\n iterator = iteratorMethod.call(O);\n next = iterator.next;\n O = [];\n while (!(step = next.call(iterator)).done) {\n O.push(step.value);\n }\n }\n if (mapping && argumentsLength > 2) {\n mapfn = bind(mapfn, arguments[2], 2);\n }\n length = toLength(O.length);\n result = new (aTypedArrayConstructor(this))(length);\n for (i = 0; length > i; i++) {\n result[i] = mapping ? mapfn(O[i], i) : O[i];\n }\n return result;\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar global = require('../internals/global');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = require('../internals/typed-array-constructors-require-wrappers');\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar ArrayBufferModule = require('../internals/array-buffer');\nvar anInstance = require('../internals/an-instance');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar toLength = require('../internals/to-length');\nvar toIndex = require('../internals/to-index');\nvar toOffset = require('../internals/to-offset');\nvar toPrimitive = require('../internals/to-primitive');\nvar has = require('../internals/has');\nvar classof = require('../internals/classof');\nvar isObject = require('../internals/is-object');\nvar create = require('../internals/object-create');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\nvar getOwnPropertyNames = require('../internals/object-get-own-property-names').f;\nvar typedArrayFrom = require('../internals/typed-array-from');\nvar forEach = require('../internals/array-iteration').forEach;\nvar setSpecies = require('../internals/set-species');\nvar definePropertyModule = require('../internals/object-define-property');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\nvar InternalStateModule = require('../internals/internal-state');\nvar inheritIfRequired = require('../internals/inherit-if-required');\n\nvar getInternalState = InternalStateModule.get;\nvar setInternalState = InternalStateModule.set;\nvar nativeDefineProperty = definePropertyModule.f;\nvar nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;\nvar round = Math.round;\nvar RangeError = global.RangeError;\nvar ArrayBuffer = ArrayBufferModule.ArrayBuffer;\nvar DataView = ArrayBufferModule.DataView;\nvar NATIVE_ARRAY_BUFFER_VIEWS = ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS;\nvar TYPED_ARRAY_TAG = ArrayBufferViewCore.TYPED_ARRAY_TAG;\nvar TypedArray = ArrayBufferViewCore.TypedArray;\nvar TypedArrayPrototype = ArrayBufferViewCore.TypedArrayPrototype;\nvar aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;\nvar isTypedArray = ArrayBufferViewCore.isTypedArray;\nvar BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT';\nvar WRONG_LENGTH = 'Wrong length';\n\nvar fromList = function (C, list) {\n var index = 0;\n var length = list.length;\n var result = new (aTypedArrayConstructor(C))(length);\n while (length > index) result[index] = list[index++];\n return result;\n};\n\nvar addGetter = function (it, key) {\n nativeDefineProperty(it, key, { get: function () {\n return getInternalState(this)[key];\n } });\n};\n\nvar isArrayBuffer = function (it) {\n var klass;\n return it instanceof ArrayBuffer || (klass = classof(it)) == 'ArrayBuffer' || klass == 'SharedArrayBuffer';\n};\n\nvar isTypedArrayIndex = function (target, key) {\n return isTypedArray(target)\n && typeof key != 'symbol'\n && key in target\n && String(+key) == String(key);\n};\n\nvar wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) {\n return isTypedArrayIndex(target, key = toPrimitive(key, true))\n ? createPropertyDescriptor(2, target[key])\n : nativeGetOwnPropertyDescriptor(target, key);\n};\n\nvar wrappedDefineProperty = function defineProperty(target, key, descriptor) {\n if (isTypedArrayIndex(target, key = toPrimitive(key, true))\n && isObject(descriptor)\n && has(descriptor, 'value')\n && !has(descriptor, 'get')\n && !has(descriptor, 'set')\n // TODO: add validation descriptor w/o calling accessors\n && !descriptor.configurable\n && (!has(descriptor, 'writable') || descriptor.writable)\n && (!has(descriptor, 'enumerable') || descriptor.enumerable)\n ) {\n target[key] = descriptor.value;\n return target;\n } return nativeDefineProperty(target, key, descriptor);\n};\n\nif (DESCRIPTORS) {\n if (!NATIVE_ARRAY_BUFFER_VIEWS) {\n getOwnPropertyDescriptorModule.f = wrappedGetOwnPropertyDescriptor;\n definePropertyModule.f = wrappedDefineProperty;\n addGetter(TypedArrayPrototype, 'buffer');\n addGetter(TypedArrayPrototype, 'byteOffset');\n addGetter(TypedArrayPrototype, 'byteLength');\n addGetter(TypedArrayPrototype, 'length');\n }\n\n $({ target: 'Object', stat: true, forced: !NATIVE_ARRAY_BUFFER_VIEWS }, {\n getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor,\n defineProperty: wrappedDefineProperty\n });\n\n module.exports = function (TYPE, wrapper, CLAMPED) {\n var BYTES = TYPE.match(/\\d+$/)[0] / 8;\n var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array';\n var GETTER = 'get' + TYPE;\n var SETTER = 'set' + TYPE;\n var NativeTypedArrayConstructor = global[CONSTRUCTOR_NAME];\n var TypedArrayConstructor = NativeTypedArrayConstructor;\n var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype;\n var exported = {};\n\n var getter = function (that, index) {\n var data = getInternalState(that);\n return data.view[GETTER](index * BYTES + data.byteOffset, true);\n };\n\n var setter = function (that, index, value) {\n var data = getInternalState(that);\n if (CLAMPED) value = (value = round(value)) < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF;\n data.view[SETTER](index * BYTES + data.byteOffset, value, true);\n };\n\n var addElement = function (that, index) {\n nativeDefineProperty(that, index, {\n get: function () {\n return getter(this, index);\n },\n set: function (value) {\n return setter(this, index, value);\n },\n enumerable: true\n });\n };\n\n if (!NATIVE_ARRAY_BUFFER_VIEWS) {\n TypedArrayConstructor = wrapper(function (that, data, offset, $length) {\n anInstance(that, TypedArrayConstructor, CONSTRUCTOR_NAME);\n var index = 0;\n var byteOffset = 0;\n var buffer, byteLength, length;\n if (!isObject(data)) {\n length = toIndex(data);\n byteLength = length * BYTES;\n buffer = new ArrayBuffer(byteLength);\n } else if (isArrayBuffer(data)) {\n buffer = data;\n byteOffset = toOffset(offset, BYTES);\n var $len = data.byteLength;\n if ($length === undefined) {\n if ($len % BYTES) throw RangeError(WRONG_LENGTH);\n byteLength = $len - byteOffset;\n if (byteLength < 0) throw RangeError(WRONG_LENGTH);\n } else {\n byteLength = toLength($length) * BYTES;\n if (byteLength + byteOffset > $len) throw RangeError(WRONG_LENGTH);\n }\n length = byteLength / BYTES;\n } else if (isTypedArray(data)) {\n return fromList(TypedArrayConstructor, data);\n } else {\n return typedArrayFrom.call(TypedArrayConstructor, data);\n }\n setInternalState(that, {\n buffer: buffer,\n byteOffset: byteOffset,\n byteLength: byteLength,\n length: length,\n view: new DataView(buffer)\n });\n while (index < length) addElement(that, index++);\n });\n\n if (setPrototypeOf) setPrototypeOf(TypedArrayConstructor, TypedArray);\n TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = create(TypedArrayPrototype);\n } else if (TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS) {\n TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) {\n anInstance(dummy, TypedArrayConstructor, CONSTRUCTOR_NAME);\n return inheritIfRequired(function () {\n if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data));\n if (isArrayBuffer(data)) return $length !== undefined\n ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length)\n : typedArrayOffset !== undefined\n ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES))\n : new NativeTypedArrayConstructor(data);\n if (isTypedArray(data)) return fromList(TypedArrayConstructor, data);\n return typedArrayFrom.call(TypedArrayConstructor, data);\n }(), dummy, TypedArrayConstructor);\n });\n\n if (setPrototypeOf) setPrototypeOf(TypedArrayConstructor, TypedArray);\n forEach(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) {\n if (!(key in TypedArrayConstructor)) {\n createNonEnumerableProperty(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]);\n }\n });\n TypedArrayConstructor.prototype = TypedArrayConstructorPrototype;\n }\n\n if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) {\n createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor);\n }\n\n if (TYPED_ARRAY_TAG) {\n createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME);\n }\n\n exported[CONSTRUCTOR_NAME] = TypedArrayConstructor;\n\n $({\n global: true, forced: TypedArrayConstructor != NativeTypedArrayConstructor, sham: !NATIVE_ARRAY_BUFFER_VIEWS\n }, exported);\n\n if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) {\n createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES);\n }\n\n if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) {\n createNonEnumerableProperty(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES);\n }\n\n setSpecies(CONSTRUCTOR_NAME);\n };\n} else module.exports = function () { /* empty */ };\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Float32Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Float32', function (init) {\n return function Float32Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Float64Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Float64', function (init) {\n return function Float64Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Int8Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Int8', function (init) {\n return function Int8Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Int16Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Int16', function (init) {\n return function Int16Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Int32Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Int32', function (init) {\n return function Int32Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Uint8Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Uint8', function (init) {\n return function Uint8Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Uint8ClampedArray` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Uint8', function (init) {\n return function Uint8ClampedArray(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n}, true);\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Uint16Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Uint16', function (init) {\n return function Uint16Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Uint32Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Uint32', function (init) {\n return function Uint32Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $copyWithin = require('../internals/array-copy-within');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.copyWithin` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.copywithin\nexportTypedArrayMethod('copyWithin', function copyWithin(target, start /* , end */) {\n return $copyWithin.call(aTypedArray(this), target, start, arguments.length > 2 ? arguments[2] : undefined);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $every = require('../internals/array-iteration').every;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.every` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.every\nexportTypedArrayMethod('every', function every(callbackfn /* , thisArg */) {\n return $every(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $fill = require('../internals/array-fill');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.fill` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.fill\n// eslint-disable-next-line no-unused-vars\nexportTypedArrayMethod('fill', function fill(value /* , start, end */) {\n return $fill.apply(aTypedArray(this), arguments);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $filter = require('../internals/array-iteration').filter;\nvar speciesConstructor = require('../internals/species-constructor');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.filter` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.filter\nexportTypedArrayMethod('filter', function filter(callbackfn /* , thisArg */) {\n var list = $filter(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n var C = speciesConstructor(this, this.constructor);\n var index = 0;\n var length = list.length;\n var result = new (aTypedArrayConstructor(C))(length);\n while (length > index) result[index] = list[index++];\n return result;\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $find = require('../internals/array-iteration').find;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.find` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.find\nexportTypedArrayMethod('find', function find(predicate /* , thisArg */) {\n return $find(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $findIndex = require('../internals/array-iteration').findIndex;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.findIndex` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.findindex\nexportTypedArrayMethod('findIndex', function findIndex(predicate /* , thisArg */) {\n return $findIndex(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $forEach = require('../internals/array-iteration').forEach;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.forEach` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.foreach\nexportTypedArrayMethod('forEach', function forEach(callbackfn /* , thisArg */) {\n $forEach(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = require('../internals/typed-array-constructors-require-wrappers');\nvar exportTypedArrayStaticMethod = require('../internals/array-buffer-view-core').exportTypedArrayStaticMethod;\nvar typedArrayFrom = require('../internals/typed-array-from');\n\n// `%TypedArray%.from` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.from\nexportTypedArrayStaticMethod('from', typedArrayFrom, TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS);\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $includes = require('../internals/array-includes').includes;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.includes` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.includes\nexportTypedArrayMethod('includes', function includes(searchElement /* , fromIndex */) {\n return $includes(aTypedArray(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $indexOf = require('../internals/array-includes').indexOf;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.indexOf` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.indexof\nexportTypedArrayMethod('indexOf', function indexOf(searchElement /* , fromIndex */) {\n return $indexOf(aTypedArray(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar global = require('../internals/global');\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar ArrayIterators = require('../modules/es.array.iterator');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar Uint8Array = global.Uint8Array;\nvar arrayValues = ArrayIterators.values;\nvar arrayKeys = ArrayIterators.keys;\nvar arrayEntries = ArrayIterators.entries;\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\nvar nativeTypedArrayIterator = Uint8Array && Uint8Array.prototype[ITERATOR];\n\nvar CORRECT_ITER_NAME = !!nativeTypedArrayIterator\n && (nativeTypedArrayIterator.name == 'values' || nativeTypedArrayIterator.name == undefined);\n\nvar typedArrayValues = function values() {\n return arrayValues.call(aTypedArray(this));\n};\n\n// `%TypedArray%.prototype.entries` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.entries\nexportTypedArrayMethod('entries', function entries() {\n return arrayEntries.call(aTypedArray(this));\n});\n// `%TypedArray%.prototype.keys` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.keys\nexportTypedArrayMethod('keys', function keys() {\n return arrayKeys.call(aTypedArray(this));\n});\n// `%TypedArray%.prototype.values` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.values\nexportTypedArrayMethod('values', typedArrayValues, !CORRECT_ITER_NAME);\n// `%TypedArray%.prototype[@@iterator]` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype-@@iterator\nexportTypedArrayMethod(ITERATOR, typedArrayValues, !CORRECT_ITER_NAME);\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\nvar $join = [].join;\n\n// `%TypedArray%.prototype.join` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.join\n// eslint-disable-next-line no-unused-vars\nexportTypedArrayMethod('join', function join(separator) {\n return $join.apply(aTypedArray(this), arguments);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $lastIndexOf = require('../internals/array-last-index-of');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.lastIndexOf` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.lastindexof\n// eslint-disable-next-line no-unused-vars\nexportTypedArrayMethod('lastIndexOf', function lastIndexOf(searchElement /* , fromIndex */) {\n return $lastIndexOf.apply(aTypedArray(this), arguments);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $map = require('../internals/array-iteration').map;\nvar speciesConstructor = require('../internals/species-constructor');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.map` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.map\nexportTypedArrayMethod('map', function map(mapfn /* , thisArg */) {\n return $map(aTypedArray(this), mapfn, arguments.length > 1 ? arguments[1] : undefined, function (O, length) {\n return new (aTypedArrayConstructor(speciesConstructor(O, O.constructor)))(length);\n });\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = require('../internals/typed-array-constructors-require-wrappers');\n\nvar aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;\nvar exportTypedArrayStaticMethod = ArrayBufferViewCore.exportTypedArrayStaticMethod;\n\n// `%TypedArray%.of` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.of\nexportTypedArrayStaticMethod('of', function of(/* ...items */) {\n var index = 0;\n var length = arguments.length;\n var result = new (aTypedArrayConstructor(this))(length);\n while (length > index) result[index] = arguments[index++];\n return result;\n}, TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS);\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $reduce = require('../internals/array-reduce').left;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.reduce` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reduce\nexportTypedArrayMethod('reduce', function reduce(callbackfn /* , initialValue */) {\n return $reduce(aTypedArray(this), callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $reduceRight = require('../internals/array-reduce').right;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.reduceRicht` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reduceright\nexportTypedArrayMethod('reduceRight', function reduceRight(callbackfn /* , initialValue */) {\n return $reduceRight(aTypedArray(this), callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\nvar floor = Math.floor;\n\n// `%TypedArray%.prototype.reverse` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reverse\nexportTypedArrayMethod('reverse', function reverse() {\n var that = this;\n var length = aTypedArray(that).length;\n var middle = floor(length / 2);\n var index = 0;\n var value;\n while (index < middle) {\n value = that[index];\n that[index++] = that[--length];\n that[length] = value;\n } return that;\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar toLength = require('../internals/to-length');\nvar toOffset = require('../internals/to-offset');\nvar toObject = require('../internals/to-object');\nvar fails = require('../internals/fails');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\nvar FORCED = fails(function () {\n // eslint-disable-next-line no-undef\n new Int8Array(1).set({});\n});\n\n// `%TypedArray%.prototype.set` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.set\nexportTypedArrayMethod('set', function set(arrayLike /* , offset */) {\n aTypedArray(this);\n var offset = toOffset(arguments.length > 1 ? arguments[1] : undefined, 1);\n var length = this.length;\n var src = toObject(arrayLike);\n var len = toLength(src.length);\n var index = 0;\n if (len + offset > length) throw RangeError('Wrong length');\n while (index < len) this[offset + index] = src[index++];\n}, FORCED);\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar speciesConstructor = require('../internals/species-constructor');\nvar fails = require('../internals/fails');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\nvar $slice = [].slice;\n\nvar FORCED = fails(function () {\n // eslint-disable-next-line no-undef\n new Int8Array(1).slice();\n});\n\n// `%TypedArray%.prototype.slice` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.slice\nexportTypedArrayMethod('slice', function slice(start, end) {\n var list = $slice.call(aTypedArray(this), start, end);\n var C = speciesConstructor(this, this.constructor);\n var index = 0;\n var length = list.length;\n var result = new (aTypedArrayConstructor(C))(length);\n while (length > index) result[index] = list[index++];\n return result;\n}, FORCED);\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $some = require('../internals/array-iteration').some;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.some` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.some\nexportTypedArrayMethod('some', function some(callbackfn /* , thisArg */) {\n return $some(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\nvar $sort = [].sort;\n\n// `%TypedArray%.prototype.sort` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.sort\nexportTypedArrayMethod('sort', function sort(comparefn) {\n return $sort.call(aTypedArray(this), comparefn);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar toLength = require('../internals/to-length');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\nvar speciesConstructor = require('../internals/species-constructor');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.subarray` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.subarray\nexportTypedArrayMethod('subarray', function subarray(begin, end) {\n var O = aTypedArray(this);\n var length = O.length;\n var beginIndex = toAbsoluteIndex(begin, length);\n return new (speciesConstructor(O, O.constructor))(\n O.buffer,\n O.byteOffset + beginIndex * O.BYTES_PER_ELEMENT,\n toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - beginIndex)\n );\n});\n","'use strict';\nvar global = require('../internals/global');\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar fails = require('../internals/fails');\n\nvar Int8Array = global.Int8Array;\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\nvar $toLocaleString = [].toLocaleString;\nvar $slice = [].slice;\n\n// iOS Safari 6.x fails here\nvar TO_LOCALE_STRING_BUG = !!Int8Array && fails(function () {\n $toLocaleString.call(new Int8Array(1));\n});\n\nvar FORCED = fails(function () {\n return [1, 2].toLocaleString() != new Int8Array([1, 2]).toLocaleString();\n}) || !fails(function () {\n Int8Array.prototype.toLocaleString.call([1, 2]);\n});\n\n// `%TypedArray%.prototype.toLocaleString` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.tolocalestring\nexportTypedArrayMethod('toLocaleString', function toLocaleString() {\n return $toLocaleString.apply(TO_LOCALE_STRING_BUG ? $slice.call(aTypedArray(this)) : aTypedArray(this), arguments);\n}, FORCED);\n","'use strict';\nvar exportTypedArrayMethod = require('../internals/array-buffer-view-core').exportTypedArrayMethod;\nvar fails = require('../internals/fails');\nvar global = require('../internals/global');\n\nvar Uint8Array = global.Uint8Array;\nvar Uint8ArrayPrototype = Uint8Array && Uint8Array.prototype || {};\nvar arrayToString = [].toString;\nvar arrayJoin = [].join;\n\nif (fails(function () { arrayToString.call({}); })) {\n arrayToString = function toString() {\n return arrayJoin.call(this);\n };\n}\n\nvar IS_NOT_ARRAY_METHOD = Uint8ArrayPrototype.toString != arrayToString;\n\n// `%TypedArray%.prototype.toString` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.tostring\nexportTypedArrayMethod('toString', arrayToString, IS_NOT_ARRAY_METHOD);\n","'use strict';\nvar redefineAll = require('../internals/redefine-all');\nvar getWeakData = require('../internals/internal-metadata').getWeakData;\nvar anObject = require('../internals/an-object');\nvar isObject = require('../internals/is-object');\nvar anInstance = require('../internals/an-instance');\nvar iterate = require('../internals/iterate');\nvar ArrayIterationModule = require('../internals/array-iteration');\nvar $has = require('../internals/has');\nvar InternalStateModule = require('../internals/internal-state');\n\nvar setInternalState = InternalStateModule.set;\nvar internalStateGetterFor = InternalStateModule.getterFor;\nvar find = ArrayIterationModule.find;\nvar findIndex = ArrayIterationModule.findIndex;\nvar id = 0;\n\n// fallback for uncaught frozen keys\nvar uncaughtFrozenStore = function (store) {\n return store.frozen || (store.frozen = new UncaughtFrozenStore());\n};\n\nvar UncaughtFrozenStore = function () {\n this.entries = [];\n};\n\nvar findUncaughtFrozen = function (store, key) {\n return find(store.entries, function (it) {\n return it[0] === key;\n });\n};\n\nUncaughtFrozenStore.prototype = {\n get: function (key) {\n var entry = findUncaughtFrozen(this, key);\n if (entry) return entry[1];\n },\n has: function (key) {\n return !!findUncaughtFrozen(this, key);\n },\n set: function (key, value) {\n var entry = findUncaughtFrozen(this, key);\n if (entry) entry[1] = value;\n else this.entries.push([key, value]);\n },\n 'delete': function (key) {\n var index = findIndex(this.entries, function (it) {\n return it[0] === key;\n });\n if (~index) this.entries.splice(index, 1);\n return !!~index;\n }\n};\n\nmodule.exports = {\n getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {\n var C = wrapper(function (that, iterable) {\n anInstance(that, C, CONSTRUCTOR_NAME);\n setInternalState(that, {\n type: CONSTRUCTOR_NAME,\n id: id++,\n frozen: undefined\n });\n if (iterable != undefined) iterate(iterable, that[ADDER], that, IS_MAP);\n });\n\n var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);\n\n var define = function (that, key, value) {\n var state = getInternalState(that);\n var data = getWeakData(anObject(key), true);\n if (data === true) uncaughtFrozenStore(state).set(key, value);\n else data[state.id] = value;\n return that;\n };\n\n redefineAll(C.prototype, {\n // 23.3.3.2 WeakMap.prototype.delete(key)\n // 23.4.3.3 WeakSet.prototype.delete(value)\n 'delete': function (key) {\n var state = getInternalState(this);\n if (!isObject(key)) return false;\n var data = getWeakData(key);\n if (data === true) return uncaughtFrozenStore(state)['delete'](key);\n return data && $has(data, state.id) && delete data[state.id];\n },\n // 23.3.3.4 WeakMap.prototype.has(key)\n // 23.4.3.4 WeakSet.prototype.has(value)\n has: function has(key) {\n var state = getInternalState(this);\n if (!isObject(key)) return false;\n var data = getWeakData(key);\n if (data === true) return uncaughtFrozenStore(state).has(key);\n return data && $has(data, state.id);\n }\n });\n\n redefineAll(C.prototype, IS_MAP ? {\n // 23.3.3.3 WeakMap.prototype.get(key)\n get: function get(key) {\n var state = getInternalState(this);\n if (isObject(key)) {\n var data = getWeakData(key);\n if (data === true) return uncaughtFrozenStore(state).get(key);\n return data ? data[state.id] : undefined;\n }\n },\n // 23.3.3.5 WeakMap.prototype.set(key, value)\n set: function set(key, value) {\n return define(this, key, value);\n }\n } : {\n // 23.4.3.1 WeakSet.prototype.add(value)\n add: function add(value) {\n return define(this, value, true);\n }\n });\n\n return C;\n }\n};\n","'use strict';\nvar global = require('../internals/global');\nvar redefineAll = require('../internals/redefine-all');\nvar InternalMetadataModule = require('../internals/internal-metadata');\nvar collection = require('../internals/collection');\nvar collectionWeak = require('../internals/collection-weak');\nvar isObject = require('../internals/is-object');\nvar enforceIternalState = require('../internals/internal-state').enforce;\nvar NATIVE_WEAK_MAP = require('../internals/native-weak-map');\n\nvar IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;\nvar isExtensible = Object.isExtensible;\nvar InternalWeakMap;\n\nvar wrapper = function (init) {\n return function WeakMap() {\n return init(this, arguments.length ? arguments[0] : undefined);\n };\n};\n\n// `WeakMap` constructor\n// https://tc39.github.io/ecma262/#sec-weakmap-constructor\nvar $WeakMap = module.exports = collection('WeakMap', wrapper, collectionWeak);\n\n// IE11 WeakMap frozen keys fix\n// We can't use feature detection because it crash some old IE builds\n// https://github.com/zloirock/core-js/issues/485\nif (NATIVE_WEAK_MAP && IS_IE11) {\n InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);\n InternalMetadataModule.REQUIRED = true;\n var WeakMapPrototype = $WeakMap.prototype;\n var nativeDelete = WeakMapPrototype['delete'];\n var nativeHas = WeakMapPrototype.has;\n var nativeGet = WeakMapPrototype.get;\n var nativeSet = WeakMapPrototype.set;\n redefineAll(WeakMapPrototype, {\n 'delete': function (key) {\n if (isObject(key) && !isExtensible(key)) {\n var state = enforceIternalState(this);\n if (!state.frozen) state.frozen = new InternalWeakMap();\n return nativeDelete.call(this, key) || state.frozen['delete'](key);\n } return nativeDelete.call(this, key);\n },\n has: function has(key) {\n if (isObject(key) && !isExtensible(key)) {\n var state = enforceIternalState(this);\n if (!state.frozen) state.frozen = new InternalWeakMap();\n return nativeHas.call(this, key) || state.frozen.has(key);\n } return nativeHas.call(this, key);\n },\n get: function get(key) {\n if (isObject(key) && !isExtensible(key)) {\n var state = enforceIternalState(this);\n if (!state.frozen) state.frozen = new InternalWeakMap();\n return nativeHas.call(this, key) ? nativeGet.call(this, key) : state.frozen.get(key);\n } return nativeGet.call(this, key);\n },\n set: function set(key, value) {\n if (isObject(key) && !isExtensible(key)) {\n var state = enforceIternalState(this);\n if (!state.frozen) state.frozen = new InternalWeakMap();\n nativeHas.call(this, key) ? nativeSet.call(this, key, value) : state.frozen.set(key, value);\n } else nativeSet.call(this, key, value);\n return this;\n }\n });\n}\n","'use strict';\nvar collection = require('../internals/collection');\nvar collectionWeak = require('../internals/collection-weak');\n\n// `WeakSet` constructor\n// https://tc39.github.io/ecma262/#sec-weakset-constructor\ncollection('WeakSet', function (init) {\n return function WeakSet() { return init(this, arguments.length ? arguments[0] : undefined); };\n}, collectionWeak);\n","// iterable DOM collections\n// flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods\nmodule.exports = {\n CSSRuleList: 0,\n CSSStyleDeclaration: 0,\n CSSValueList: 0,\n ClientRectList: 0,\n DOMRectList: 0,\n DOMStringList: 0,\n DOMTokenList: 1,\n DataTransferItemList: 0,\n FileList: 0,\n HTMLAllCollection: 0,\n HTMLCollection: 0,\n HTMLFormElement: 0,\n HTMLSelectElement: 0,\n MediaList: 0,\n MimeTypeArray: 0,\n NamedNodeMap: 0,\n NodeList: 1,\n PaintRequestList: 0,\n Plugin: 0,\n PluginArray: 0,\n SVGLengthList: 0,\n SVGNumberList: 0,\n SVGPathSegList: 0,\n SVGPointList: 0,\n SVGStringList: 0,\n SVGTransformList: 0,\n SourceBufferList: 0,\n StyleSheetList: 0,\n TextTrackCueList: 0,\n TextTrackList: 0,\n TouchList: 0\n};\n","var global = require('../internals/global');\nvar DOMIterables = require('../internals/dom-iterables');\nvar forEach = require('../internals/array-for-each');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\n\nfor (var COLLECTION_NAME in DOMIterables) {\n var Collection = global[COLLECTION_NAME];\n var CollectionPrototype = Collection && Collection.prototype;\n // some Chrome versions have non-configurable methods on DOMTokenList\n if (CollectionPrototype && CollectionPrototype.forEach !== forEach) try {\n createNonEnumerableProperty(CollectionPrototype, 'forEach', forEach);\n } catch (error) {\n CollectionPrototype.forEach = forEach;\n }\n}\n","var global = require('../internals/global');\nvar DOMIterables = require('../internals/dom-iterables');\nvar ArrayIteratorMethods = require('../modules/es.array.iterator');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\nvar ArrayValues = ArrayIteratorMethods.values;\n\nfor (var COLLECTION_NAME in DOMIterables) {\n var Collection = global[COLLECTION_NAME];\n var CollectionPrototype = Collection && Collection.prototype;\n if (CollectionPrototype) {\n // some Chrome versions have non-configurable methods on DOMTokenList\n if (CollectionPrototype[ITERATOR] !== ArrayValues) try {\n createNonEnumerableProperty(CollectionPrototype, ITERATOR, ArrayValues);\n } catch (error) {\n CollectionPrototype[ITERATOR] = ArrayValues;\n }\n if (!CollectionPrototype[TO_STRING_TAG]) {\n createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);\n }\n if (DOMIterables[COLLECTION_NAME]) for (var METHOD_NAME in ArrayIteratorMethods) {\n // some Chrome versions have non-configurable methods on DOMTokenList\n if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME]) try {\n createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]);\n } catch (error) {\n CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME];\n }\n }\n }\n}\n","var $ = require('../internals/export');\nvar global = require('../internals/global');\nvar task = require('../internals/task');\n\nvar FORCED = !global.setImmediate || !global.clearImmediate;\n\n// http://w3c.github.io/setImmediate/\n$({ global: true, bind: true, enumerable: true, forced: FORCED }, {\n // `setImmediate` method\n // http://w3c.github.io/setImmediate/#si-setImmediate\n setImmediate: task.set,\n // `clearImmediate` method\n // http://w3c.github.io/setImmediate/#si-clearImmediate\n clearImmediate: task.clear\n});\n","var $ = require('../internals/export');\nvar global = require('../internals/global');\nvar microtask = require('../internals/microtask');\nvar classof = require('../internals/classof-raw');\n\nvar process = global.process;\nvar isNode = classof(process) == 'process';\n\n// `queueMicrotask` method\n// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask\n$({ global: true, enumerable: true, noTargetGet: true }, {\n queueMicrotask: function queueMicrotask(fn) {\n var domain = isNode && process.domain;\n microtask(domain ? domain.bind(fn) : fn);\n }\n});\n","var fails = require('../internals/fails');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar IS_PURE = require('../internals/is-pure');\n\nvar ITERATOR = wellKnownSymbol('iterator');\n\nmodule.exports = !fails(function () {\n var url = new URL('b?a=1&b=2&c=3', 'http://a');\n var searchParams = url.searchParams;\n var result = '';\n url.pathname = 'c%20d';\n searchParams.forEach(function (value, key) {\n searchParams['delete']('b');\n result += key + value;\n });\n return (IS_PURE && !url.toJSON)\n || !searchParams.sort\n || url.href !== 'http://a/c%20d?a=1&c=3'\n || searchParams.get('c') !== '3'\n || String(new URLSearchParams('?a=1')) !== 'a=1'\n || !searchParams[ITERATOR]\n // throws in Edge\n || new URL('https://a@b').username !== 'a'\n || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b'\n // not punycoded in Edge\n || new URL('http://тест').host !== 'xn--e1aybc'\n // not escaped in Chrome 62-\n || new URL('http://a#б').hash !== '#%D0%B1'\n // fails in Chrome 66-\n || result !== 'a1c3'\n // throws in Safari\n || new URL('http://x', undefined).host !== 'x';\n});\n","'use strict';\n// based on https://github.com/bestiejs/punycode.js/blob/master/punycode.js\nvar maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1\nvar base = 36;\nvar tMin = 1;\nvar tMax = 26;\nvar skew = 38;\nvar damp = 700;\nvar initialBias = 72;\nvar initialN = 128; // 0x80\nvar delimiter = '-'; // '\\x2D'\nvar regexNonASCII = /[^\\0-\\u007E]/; // non-ASCII chars\nvar regexSeparators = /[.\\u3002\\uFF0E\\uFF61]/g; // RFC 3490 separators\nvar OVERFLOW_ERROR = 'Overflow: input needs wider integers to process';\nvar baseMinusTMin = base - tMin;\nvar floor = Math.floor;\nvar stringFromCharCode = String.fromCharCode;\n\n/**\n * Creates an array containing the numeric code points of each Unicode\n * character in the string. While JavaScript uses UCS-2 internally,\n * this function will convert a pair of surrogate halves (each of which\n * UCS-2 exposes as separate characters) into a single code point,\n * matching UTF-16.\n */\nvar ucs2decode = function (string) {\n var output = [];\n var counter = 0;\n var length = string.length;\n while (counter < length) {\n var value = string.charCodeAt(counter++);\n if (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n // It's a high surrogate, and there is a next character.\n var extra = string.charCodeAt(counter++);\n if ((extra & 0xFC00) == 0xDC00) { // Low surrogate.\n output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n } else {\n // It's an unmatched surrogate; only append this code unit, in case the\n // next code unit is the high surrogate of a surrogate pair.\n output.push(value);\n counter--;\n }\n } else {\n output.push(value);\n }\n }\n return output;\n};\n\n/**\n * Converts a digit/integer into a basic code point.\n */\nvar digitToBasic = function (digit) {\n // 0..25 map to ASCII a..z or A..Z\n // 26..35 map to ASCII 0..9\n return digit + 22 + 75 * (digit < 26);\n};\n\n/**\n * Bias adaptation function as per section 3.4 of RFC 3492.\n * https://tools.ietf.org/html/rfc3492#section-3.4\n */\nvar adapt = function (delta, numPoints, firstTime) {\n var k = 0;\n delta = firstTime ? floor(delta / damp) : delta >> 1;\n delta += floor(delta / numPoints);\n for (; delta > baseMinusTMin * tMax >> 1; k += base) {\n delta = floor(delta / baseMinusTMin);\n }\n return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));\n};\n\n/**\n * Converts a string of Unicode symbols (e.g. a domain name label) to a\n * Punycode string of ASCII-only symbols.\n */\n// eslint-disable-next-line max-statements\nvar encode = function (input) {\n var output = [];\n\n // Convert the input in UCS-2 to an array of Unicode code points.\n input = ucs2decode(input);\n\n // Cache the length.\n var inputLength = input.length;\n\n // Initialize the state.\n var n = initialN;\n var delta = 0;\n var bias = initialBias;\n var i, currentValue;\n\n // Handle the basic code points.\n for (i = 0; i < input.length; i++) {\n currentValue = input[i];\n if (currentValue < 0x80) {\n output.push(stringFromCharCode(currentValue));\n }\n }\n\n var basicLength = output.length; // number of basic code points.\n var handledCPCount = basicLength; // number of code points that have been handled;\n\n // Finish the basic string with a delimiter unless it's empty.\n if (basicLength) {\n output.push(delimiter);\n }\n\n // Main encoding loop:\n while (handledCPCount < inputLength) {\n // All non-basic code points < n have been handled already. Find the next larger one:\n var m = maxInt;\n for (i = 0; i < input.length; i++) {\n currentValue = input[i];\n if (currentValue >= n && currentValue < m) {\n m = currentValue;\n }\n }\n\n // Increase `delta` enough to advance the decoder's state to , but guard against overflow.\n var handledCPCountPlusOne = handledCPCount + 1;\n if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {\n throw RangeError(OVERFLOW_ERROR);\n }\n\n delta += (m - n) * handledCPCountPlusOne;\n n = m;\n\n for (i = 0; i < input.length; i++) {\n currentValue = input[i];\n if (currentValue < n && ++delta > maxInt) {\n throw RangeError(OVERFLOW_ERROR);\n }\n if (currentValue == n) {\n // Represent delta as a generalized variable-length integer.\n var q = delta;\n for (var k = base; /* no condition */; k += base) {\n var t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n if (q < t) break;\n var qMinusT = q - t;\n var baseMinusT = base - t;\n output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT)));\n q = floor(qMinusT / baseMinusT);\n }\n\n output.push(stringFromCharCode(digitToBasic(q)));\n bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);\n delta = 0;\n ++handledCPCount;\n }\n }\n\n ++delta;\n ++n;\n }\n return output.join('');\n};\n\nmodule.exports = function (input) {\n var encoded = [];\n var labels = input.toLowerCase().replace(regexSeparators, '\\u002E').split('.');\n var i, label;\n for (i = 0; i < labels.length; i++) {\n label = labels[i];\n encoded.push(regexNonASCII.test(label) ? 'xn--' + encode(label) : label);\n }\n return encoded.join('.');\n};\n","var anObject = require('../internals/an-object');\nvar getIteratorMethod = require('../internals/get-iterator-method');\n\nmodule.exports = function (it) {\n var iteratorMethod = getIteratorMethod(it);\n if (typeof iteratorMethod != 'function') {\n throw TypeError(String(it) + ' is not iterable');\n } return anObject(iteratorMethod.call(it));\n};\n","'use strict';\n// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`\nrequire('../modules/es.array.iterator');\nvar $ = require('../internals/export');\nvar getBuiltIn = require('../internals/get-built-in');\nvar USE_NATIVE_URL = require('../internals/native-url');\nvar redefine = require('../internals/redefine');\nvar redefineAll = require('../internals/redefine-all');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar createIteratorConstructor = require('../internals/create-iterator-constructor');\nvar InternalStateModule = require('../internals/internal-state');\nvar anInstance = require('../internals/an-instance');\nvar hasOwn = require('../internals/has');\nvar bind = require('../internals/function-bind-context');\nvar classof = require('../internals/classof');\nvar anObject = require('../internals/an-object');\nvar isObject = require('../internals/is-object');\nvar create = require('../internals/object-create');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\nvar getIterator = require('../internals/get-iterator');\nvar getIteratorMethod = require('../internals/get-iterator-method');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar $fetch = getBuiltIn('fetch');\nvar Headers = getBuiltIn('Headers');\nvar ITERATOR = wellKnownSymbol('iterator');\nvar URL_SEARCH_PARAMS = 'URLSearchParams';\nvar URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator';\nvar setInternalState = InternalStateModule.set;\nvar getInternalParamsState = InternalStateModule.getterFor(URL_SEARCH_PARAMS);\nvar getInternalIteratorState = InternalStateModule.getterFor(URL_SEARCH_PARAMS_ITERATOR);\n\nvar plus = /\\+/g;\nvar sequences = Array(4);\n\nvar percentSequence = function (bytes) {\n return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp('((?:%[\\\\da-f]{2}){' + bytes + '})', 'gi'));\n};\n\nvar percentDecode = function (sequence) {\n try {\n return decodeURIComponent(sequence);\n } catch (error) {\n return sequence;\n }\n};\n\nvar deserialize = function (it) {\n var result = it.replace(plus, ' ');\n var bytes = 4;\n try {\n return decodeURIComponent(result);\n } catch (error) {\n while (bytes) {\n result = result.replace(percentSequence(bytes--), percentDecode);\n }\n return result;\n }\n};\n\nvar find = /[!'()~]|%20/g;\n\nvar replace = {\n '!': '%21',\n \"'\": '%27',\n '(': '%28',\n ')': '%29',\n '~': '%7E',\n '%20': '+'\n};\n\nvar replacer = function (match) {\n return replace[match];\n};\n\nvar serialize = function (it) {\n return encodeURIComponent(it).replace(find, replacer);\n};\n\nvar parseSearchParams = function (result, query) {\n if (query) {\n var attributes = query.split('&');\n var index = 0;\n var attribute, entry;\n while (index < attributes.length) {\n attribute = attributes[index++];\n if (attribute.length) {\n entry = attribute.split('=');\n result.push({\n key: deserialize(entry.shift()),\n value: deserialize(entry.join('='))\n });\n }\n }\n }\n};\n\nvar updateSearchParams = function (query) {\n this.entries.length = 0;\n parseSearchParams(this.entries, query);\n};\n\nvar validateArgumentsLength = function (passed, required) {\n if (passed < required) throw TypeError('Not enough arguments');\n};\n\nvar URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {\n setInternalState(this, {\n type: URL_SEARCH_PARAMS_ITERATOR,\n iterator: getIterator(getInternalParamsState(params).entries),\n kind: kind\n });\n}, 'Iterator', function next() {\n var state = getInternalIteratorState(this);\n var kind = state.kind;\n var step = state.iterator.next();\n var entry = step.value;\n if (!step.done) {\n step.value = kind === 'keys' ? entry.key : kind === 'values' ? entry.value : [entry.key, entry.value];\n } return step;\n});\n\n// `URLSearchParams` constructor\n// https://url.spec.whatwg.org/#interface-urlsearchparams\nvar URLSearchParamsConstructor = function URLSearchParams(/* init */) {\n anInstance(this, URLSearchParamsConstructor, URL_SEARCH_PARAMS);\n var init = arguments.length > 0 ? arguments[0] : undefined;\n var that = this;\n var entries = [];\n var iteratorMethod, iterator, next, step, entryIterator, entryNext, first, second, key;\n\n setInternalState(that, {\n type: URL_SEARCH_PARAMS,\n entries: entries,\n updateURL: function () { /* empty */ },\n updateSearchParams: updateSearchParams\n });\n\n if (init !== undefined) {\n if (isObject(init)) {\n iteratorMethod = getIteratorMethod(init);\n if (typeof iteratorMethod === 'function') {\n iterator = iteratorMethod.call(init);\n next = iterator.next;\n while (!(step = next.call(iterator)).done) {\n entryIterator = getIterator(anObject(step.value));\n entryNext = entryIterator.next;\n if (\n (first = entryNext.call(entryIterator)).done ||\n (second = entryNext.call(entryIterator)).done ||\n !entryNext.call(entryIterator).done\n ) throw TypeError('Expected sequence with length 2');\n entries.push({ key: first.value + '', value: second.value + '' });\n }\n } else for (key in init) if (hasOwn(init, key)) entries.push({ key: key, value: init[key] + '' });\n } else {\n parseSearchParams(entries, typeof init === 'string' ? init.charAt(0) === '?' ? init.slice(1) : init : init + '');\n }\n }\n};\n\nvar URLSearchParamsPrototype = URLSearchParamsConstructor.prototype;\n\nredefineAll(URLSearchParamsPrototype, {\n // `URLSearchParams.prototype.appent` method\n // https://url.spec.whatwg.org/#dom-urlsearchparams-append\n append: function append(name, value) {\n validateArgumentsLength(arguments.length, 2);\n var state = getInternalParamsState(this);\n state.entries.push({ key: name + '', value: value + '' });\n state.updateURL();\n },\n // `URLSearchParams.prototype.delete` method\n // https://url.spec.whatwg.org/#dom-urlsearchparams-delete\n 'delete': function (name) {\n validateArgumentsLength(arguments.length, 1);\n var state = getInternalParamsState(this);\n var entries = state.entries;\n var key = name + '';\n var index = 0;\n while (index < entries.length) {\n if (entries[index].key === key) entries.splice(index, 1);\n else index++;\n }\n state.updateURL();\n },\n // `URLSearchParams.prototype.get` method\n // https://url.spec.whatwg.org/#dom-urlsearchparams-get\n get: function get(name) {\n validateArgumentsLength(arguments.length, 1);\n var entries = getInternalParamsState(this).entries;\n var key = name + '';\n var index = 0;\n for (; index < entries.length; index++) {\n if (entries[index].key === key) return entries[index].value;\n }\n return null;\n },\n // `URLSearchParams.prototype.getAll` method\n // https://url.spec.whatwg.org/#dom-urlsearchparams-getall\n getAll: function getAll(name) {\n validateArgumentsLength(arguments.length, 1);\n var entries = getInternalParamsState(this).entries;\n var key = name + '';\n var result = [];\n var index = 0;\n for (; index < entries.length; index++) {\n if (entries[index].key === key) result.push(entries[index].value);\n }\n return result;\n },\n // `URLSearchParams.prototype.has` method\n // https://url.spec.whatwg.org/#dom-urlsearchparams-has\n has: function has(name) {\n validateArgumentsLength(arguments.length, 1);\n var entries = getInternalParamsState(this).entries;\n var key = name + '';\n var index = 0;\n while (index < entries.length) {\n if (entries[index++].key === key) return true;\n }\n return false;\n },\n // `URLSearchParams.prototype.set` method\n // https://url.spec.whatwg.org/#dom-urlsearchparams-set\n set: function set(name, value) {\n validateArgumentsLength(arguments.length, 1);\n var state = getInternalParamsState(this);\n var entries = state.entries;\n var found = false;\n var key = name + '';\n var val = value + '';\n var index = 0;\n var entry;\n for (; index < entries.length; index++) {\n entry = entries[index];\n if (entry.key === key) {\n if (found) entries.splice(index--, 1);\n else {\n found = true;\n entry.value = val;\n }\n }\n }\n if (!found) entries.push({ key: key, value: val });\n state.updateURL();\n },\n // `URLSearchParams.prototype.sort` method\n // https://url.spec.whatwg.org/#dom-urlsearchparams-sort\n sort: function sort() {\n var state = getInternalParamsState(this);\n var entries = state.entries;\n // Array#sort is not stable in some engines\n var slice = entries.slice();\n var entry, entriesIndex, sliceIndex;\n entries.length = 0;\n for (sliceIndex = 0; sliceIndex < slice.length; sliceIndex++) {\n entry = slice[sliceIndex];\n for (entriesIndex = 0; entriesIndex < sliceIndex; entriesIndex++) {\n if (entries[entriesIndex].key > entry.key) {\n entries.splice(entriesIndex, 0, entry);\n break;\n }\n }\n if (entriesIndex === sliceIndex) entries.push(entry);\n }\n state.updateURL();\n },\n // `URLSearchParams.prototype.forEach` method\n forEach: function forEach(callback /* , thisArg */) {\n var entries = getInternalParamsState(this).entries;\n var boundFunction = bind(callback, arguments.length > 1 ? arguments[1] : undefined, 3);\n var index = 0;\n var entry;\n while (index < entries.length) {\n entry = entries[index++];\n boundFunction(entry.value, entry.key, this);\n }\n },\n // `URLSearchParams.prototype.keys` method\n keys: function keys() {\n return new URLSearchParamsIterator(this, 'keys');\n },\n // `URLSearchParams.prototype.values` method\n values: function values() {\n return new URLSearchParamsIterator(this, 'values');\n },\n // `URLSearchParams.prototype.entries` method\n entries: function entries() {\n return new URLSearchParamsIterator(this, 'entries');\n }\n}, { enumerable: true });\n\n// `URLSearchParams.prototype[@@iterator]` method\nredefine(URLSearchParamsPrototype, ITERATOR, URLSearchParamsPrototype.entries);\n\n// `URLSearchParams.prototype.toString` method\n// https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior\nredefine(URLSearchParamsPrototype, 'toString', function toString() {\n var entries = getInternalParamsState(this).entries;\n var result = [];\n var index = 0;\n var entry;\n while (index < entries.length) {\n entry = entries[index++];\n result.push(serialize(entry.key) + '=' + serialize(entry.value));\n } return result.join('&');\n}, { enumerable: true });\n\nsetToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS);\n\n$({ global: true, forced: !USE_NATIVE_URL }, {\n URLSearchParams: URLSearchParamsConstructor\n});\n\n// Wrap `fetch` for correct work with polyfilled `URLSearchParams`\n// https://github.com/zloirock/core-js/issues/674\nif (!USE_NATIVE_URL && typeof $fetch == 'function' && typeof Headers == 'function') {\n $({ global: true, enumerable: true, forced: true }, {\n fetch: function fetch(input /* , init */) {\n var args = [input];\n var init, body, headers;\n if (arguments.length > 1) {\n init = arguments[1];\n if (isObject(init)) {\n body = init.body;\n if (classof(body) === URL_SEARCH_PARAMS) {\n headers = init.headers ? new Headers(init.headers) : new Headers();\n if (!headers.has('content-type')) {\n headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');\n }\n init = create(init, {\n body: createPropertyDescriptor(0, String(body)),\n headers: createPropertyDescriptor(0, headers)\n });\n }\n }\n args.push(init);\n } return $fetch.apply(this, args);\n }\n });\n}\n\nmodule.exports = {\n URLSearchParams: URLSearchParamsConstructor,\n getState: getInternalParamsState\n};\n","'use strict';\n// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`\nrequire('../modules/es.string.iterator');\nvar $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar USE_NATIVE_URL = require('../internals/native-url');\nvar global = require('../internals/global');\nvar defineProperties = require('../internals/object-define-properties');\nvar redefine = require('../internals/redefine');\nvar anInstance = require('../internals/an-instance');\nvar has = require('../internals/has');\nvar assign = require('../internals/object-assign');\nvar arrayFrom = require('../internals/array-from');\nvar codeAt = require('../internals/string-multibyte').codeAt;\nvar toASCII = require('../internals/string-punycode-to-ascii');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar URLSearchParamsModule = require('../modules/web.url-search-params');\nvar InternalStateModule = require('../internals/internal-state');\n\nvar NativeURL = global.URL;\nvar URLSearchParams = URLSearchParamsModule.URLSearchParams;\nvar getInternalSearchParamsState = URLSearchParamsModule.getState;\nvar setInternalState = InternalStateModule.set;\nvar getInternalURLState = InternalStateModule.getterFor('URL');\nvar floor = Math.floor;\nvar pow = Math.pow;\n\nvar INVALID_AUTHORITY = 'Invalid authority';\nvar INVALID_SCHEME = 'Invalid scheme';\nvar INVALID_HOST = 'Invalid host';\nvar INVALID_PORT = 'Invalid port';\n\nvar ALPHA = /[A-Za-z]/;\nvar ALPHANUMERIC = /[\\d+-.A-Za-z]/;\nvar DIGIT = /\\d/;\nvar HEX_START = /^(0x|0X)/;\nvar OCT = /^[0-7]+$/;\nvar DEC = /^\\d+$/;\nvar HEX = /^[\\dA-Fa-f]+$/;\n// eslint-disable-next-line no-control-regex\nvar FORBIDDEN_HOST_CODE_POINT = /[\\u0000\\u0009\\u000A\\u000D #%/:?@[\\\\]]/;\n// eslint-disable-next-line no-control-regex\nvar FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\\u0000\\u0009\\u000A\\u000D #/:?@[\\\\]]/;\n// eslint-disable-next-line no-control-regex\nvar LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE = /^[\\u0000-\\u001F ]+|[\\u0000-\\u001F ]+$/g;\n// eslint-disable-next-line no-control-regex\nvar TAB_AND_NEW_LINE = /[\\u0009\\u000A\\u000D]/g;\nvar EOF;\n\nvar parseHost = function (url, input) {\n var result, codePoints, index;\n if (input.charAt(0) == '[') {\n if (input.charAt(input.length - 1) != ']') return INVALID_HOST;\n result = parseIPv6(input.slice(1, -1));\n if (!result) return INVALID_HOST;\n url.host = result;\n // opaque host\n } else if (!isSpecial(url)) {\n if (FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT.test(input)) return INVALID_HOST;\n result = '';\n codePoints = arrayFrom(input);\n for (index = 0; index < codePoints.length; index++) {\n result += percentEncode(codePoints[index], C0ControlPercentEncodeSet);\n }\n url.host = result;\n } else {\n input = toASCII(input);\n if (FORBIDDEN_HOST_CODE_POINT.test(input)) return INVALID_HOST;\n result = parseIPv4(input);\n if (result === null) return INVALID_HOST;\n url.host = result;\n }\n};\n\nvar parseIPv4 = function (input) {\n var parts = input.split('.');\n var partsLength, numbers, index, part, radix, number, ipv4;\n if (parts.length && parts[parts.length - 1] == '') {\n parts.pop();\n }\n partsLength = parts.length;\n if (partsLength > 4) return input;\n numbers = [];\n for (index = 0; index < partsLength; index++) {\n part = parts[index];\n if (part == '') return input;\n radix = 10;\n if (part.length > 1 && part.charAt(0) == '0') {\n radix = HEX_START.test(part) ? 16 : 8;\n part = part.slice(radix == 8 ? 1 : 2);\n }\n if (part === '') {\n number = 0;\n } else {\n if (!(radix == 10 ? DEC : radix == 8 ? OCT : HEX).test(part)) return input;\n number = parseInt(part, radix);\n }\n numbers.push(number);\n }\n for (index = 0; index < partsLength; index++) {\n number = numbers[index];\n if (index == partsLength - 1) {\n if (number >= pow(256, 5 - partsLength)) return null;\n } else if (number > 255) return null;\n }\n ipv4 = numbers.pop();\n for (index = 0; index < numbers.length; index++) {\n ipv4 += numbers[index] * pow(256, 3 - index);\n }\n return ipv4;\n};\n\n// eslint-disable-next-line max-statements\nvar parseIPv6 = function (input) {\n var address = [0, 0, 0, 0, 0, 0, 0, 0];\n var pieceIndex = 0;\n var compress = null;\n var pointer = 0;\n var value, length, numbersSeen, ipv4Piece, number, swaps, swap;\n\n var char = function () {\n return input.charAt(pointer);\n };\n\n if (char() == ':') {\n if (input.charAt(1) != ':') return;\n pointer += 2;\n pieceIndex++;\n compress = pieceIndex;\n }\n while (char()) {\n if (pieceIndex == 8) return;\n if (char() == ':') {\n if (compress !== null) return;\n pointer++;\n pieceIndex++;\n compress = pieceIndex;\n continue;\n }\n value = length = 0;\n while (length < 4 && HEX.test(char())) {\n value = value * 16 + parseInt(char(), 16);\n pointer++;\n length++;\n }\n if (char() == '.') {\n if (length == 0) return;\n pointer -= length;\n if (pieceIndex > 6) return;\n numbersSeen = 0;\n while (char()) {\n ipv4Piece = null;\n if (numbersSeen > 0) {\n if (char() == '.' && numbersSeen < 4) pointer++;\n else return;\n }\n if (!DIGIT.test(char())) return;\n while (DIGIT.test(char())) {\n number = parseInt(char(), 10);\n if (ipv4Piece === null) ipv4Piece = number;\n else if (ipv4Piece == 0) return;\n else ipv4Piece = ipv4Piece * 10 + number;\n if (ipv4Piece > 255) return;\n pointer++;\n }\n address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;\n numbersSeen++;\n if (numbersSeen == 2 || numbersSeen == 4) pieceIndex++;\n }\n if (numbersSeen != 4) return;\n break;\n } else if (char() == ':') {\n pointer++;\n if (!char()) return;\n } else if (char()) return;\n address[pieceIndex++] = value;\n }\n if (compress !== null) {\n swaps = pieceIndex - compress;\n pieceIndex = 7;\n while (pieceIndex != 0 && swaps > 0) {\n swap = address[pieceIndex];\n address[pieceIndex--] = address[compress + swaps - 1];\n address[compress + --swaps] = swap;\n }\n } else if (pieceIndex != 8) return;\n return address;\n};\n\nvar findLongestZeroSequence = function (ipv6) {\n var maxIndex = null;\n var maxLength = 1;\n var currStart = null;\n var currLength = 0;\n var index = 0;\n for (; index < 8; index++) {\n if (ipv6[index] !== 0) {\n if (currLength > maxLength) {\n maxIndex = currStart;\n maxLength = currLength;\n }\n currStart = null;\n currLength = 0;\n } else {\n if (currStart === null) currStart = index;\n ++currLength;\n }\n }\n if (currLength > maxLength) {\n maxIndex = currStart;\n maxLength = currLength;\n }\n return maxIndex;\n};\n\nvar serializeHost = function (host) {\n var result, index, compress, ignore0;\n // ipv4\n if (typeof host == 'number') {\n result = [];\n for (index = 0; index < 4; index++) {\n result.unshift(host % 256);\n host = floor(host / 256);\n } return result.join('.');\n // ipv6\n } else if (typeof host == 'object') {\n result = '';\n compress = findLongestZeroSequence(host);\n for (index = 0; index < 8; index++) {\n if (ignore0 && host[index] === 0) continue;\n if (ignore0) ignore0 = false;\n if (compress === index) {\n result += index ? ':' : '::';\n ignore0 = true;\n } else {\n result += host[index].toString(16);\n if (index < 7) result += ':';\n }\n }\n return '[' + result + ']';\n } return host;\n};\n\nvar C0ControlPercentEncodeSet = {};\nvar fragmentPercentEncodeSet = assign({}, C0ControlPercentEncodeSet, {\n ' ': 1, '\"': 1, '<': 1, '>': 1, '`': 1\n});\nvar pathPercentEncodeSet = assign({}, fragmentPercentEncodeSet, {\n '#': 1, '?': 1, '{': 1, '}': 1\n});\nvar userinfoPercentEncodeSet = assign({}, pathPercentEncodeSet, {\n '/': 1, ':': 1, ';': 1, '=': 1, '@': 1, '[': 1, '\\\\': 1, ']': 1, '^': 1, '|': 1\n});\n\nvar percentEncode = function (char, set) {\n var code = codeAt(char, 0);\n return code > 0x20 && code < 0x7F && !has(set, char) ? char : encodeURIComponent(char);\n};\n\nvar specialSchemes = {\n ftp: 21,\n file: null,\n http: 80,\n https: 443,\n ws: 80,\n wss: 443\n};\n\nvar isSpecial = function (url) {\n return has(specialSchemes, url.scheme);\n};\n\nvar includesCredentials = function (url) {\n return url.username != '' || url.password != '';\n};\n\nvar cannotHaveUsernamePasswordPort = function (url) {\n return !url.host || url.cannotBeABaseURL || url.scheme == 'file';\n};\n\nvar isWindowsDriveLetter = function (string, normalized) {\n var second;\n return string.length == 2 && ALPHA.test(string.charAt(0))\n && ((second = string.charAt(1)) == ':' || (!normalized && second == '|'));\n};\n\nvar startsWithWindowsDriveLetter = function (string) {\n var third;\n return string.length > 1 && isWindowsDriveLetter(string.slice(0, 2)) && (\n string.length == 2 ||\n ((third = string.charAt(2)) === '/' || third === '\\\\' || third === '?' || third === '#')\n );\n};\n\nvar shortenURLsPath = function (url) {\n var path = url.path;\n var pathSize = path.length;\n if (pathSize && (url.scheme != 'file' || pathSize != 1 || !isWindowsDriveLetter(path[0], true))) {\n path.pop();\n }\n};\n\nvar isSingleDot = function (segment) {\n return segment === '.' || segment.toLowerCase() === '%2e';\n};\n\nvar isDoubleDot = function (segment) {\n segment = segment.toLowerCase();\n return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e';\n};\n\n// States:\nvar SCHEME_START = {};\nvar SCHEME = {};\nvar NO_SCHEME = {};\nvar SPECIAL_RELATIVE_OR_AUTHORITY = {};\nvar PATH_OR_AUTHORITY = {};\nvar RELATIVE = {};\nvar RELATIVE_SLASH = {};\nvar SPECIAL_AUTHORITY_SLASHES = {};\nvar SPECIAL_AUTHORITY_IGNORE_SLASHES = {};\nvar AUTHORITY = {};\nvar HOST = {};\nvar HOSTNAME = {};\nvar PORT = {};\nvar FILE = {};\nvar FILE_SLASH = {};\nvar FILE_HOST = {};\nvar PATH_START = {};\nvar PATH = {};\nvar CANNOT_BE_A_BASE_URL_PATH = {};\nvar QUERY = {};\nvar FRAGMENT = {};\n\n// eslint-disable-next-line max-statements\nvar parseURL = function (url, input, stateOverride, base) {\n var state = stateOverride || SCHEME_START;\n var pointer = 0;\n var buffer = '';\n var seenAt = false;\n var seenBracket = false;\n var seenPasswordToken = false;\n var codePoints, char, bufferCodePoints, failure;\n\n if (!stateOverride) {\n url.scheme = '';\n url.username = '';\n url.password = '';\n url.host = null;\n url.port = null;\n url.path = [];\n url.query = null;\n url.fragment = null;\n url.cannotBeABaseURL = false;\n input = input.replace(LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE, '');\n }\n\n input = input.replace(TAB_AND_NEW_LINE, '');\n\n codePoints = arrayFrom(input);\n\n while (pointer <= codePoints.length) {\n char = codePoints[pointer];\n switch (state) {\n case SCHEME_START:\n if (char && ALPHA.test(char)) {\n buffer += char.toLowerCase();\n state = SCHEME;\n } else if (!stateOverride) {\n state = NO_SCHEME;\n continue;\n } else return INVALID_SCHEME;\n break;\n\n case SCHEME:\n if (char && (ALPHANUMERIC.test(char) || char == '+' || char == '-' || char == '.')) {\n buffer += char.toLowerCase();\n } else if (char == ':') {\n if (stateOverride && (\n (isSpecial(url) != has(specialSchemes, buffer)) ||\n (buffer == 'file' && (includesCredentials(url) || url.port !== null)) ||\n (url.scheme == 'file' && !url.host)\n )) return;\n url.scheme = buffer;\n if (stateOverride) {\n if (isSpecial(url) && specialSchemes[url.scheme] == url.port) url.port = null;\n return;\n }\n buffer = '';\n if (url.scheme == 'file') {\n state = FILE;\n } else if (isSpecial(url) && base && base.scheme == url.scheme) {\n state = SPECIAL_RELATIVE_OR_AUTHORITY;\n } else if (isSpecial(url)) {\n state = SPECIAL_AUTHORITY_SLASHES;\n } else if (codePoints[pointer + 1] == '/') {\n state = PATH_OR_AUTHORITY;\n pointer++;\n } else {\n url.cannotBeABaseURL = true;\n url.path.push('');\n state = CANNOT_BE_A_BASE_URL_PATH;\n }\n } else if (!stateOverride) {\n buffer = '';\n state = NO_SCHEME;\n pointer = 0;\n continue;\n } else return INVALID_SCHEME;\n break;\n\n case NO_SCHEME:\n if (!base || (base.cannotBeABaseURL && char != '#')) return INVALID_SCHEME;\n if (base.cannotBeABaseURL && char == '#') {\n url.scheme = base.scheme;\n url.path = base.path.slice();\n url.query = base.query;\n url.fragment = '';\n url.cannotBeABaseURL = true;\n state = FRAGMENT;\n break;\n }\n state = base.scheme == 'file' ? FILE : RELATIVE;\n continue;\n\n case SPECIAL_RELATIVE_OR_AUTHORITY:\n if (char == '/' && codePoints[pointer + 1] == '/') {\n state = SPECIAL_AUTHORITY_IGNORE_SLASHES;\n pointer++;\n } else {\n state = RELATIVE;\n continue;\n } break;\n\n case PATH_OR_AUTHORITY:\n if (char == '/') {\n state = AUTHORITY;\n break;\n } else {\n state = PATH;\n continue;\n }\n\n case RELATIVE:\n url.scheme = base.scheme;\n if (char == EOF) {\n url.username = base.username;\n url.password = base.password;\n url.host = base.host;\n url.port = base.port;\n url.path = base.path.slice();\n url.query = base.query;\n } else if (char == '/' || (char == '\\\\' && isSpecial(url))) {\n state = RELATIVE_SLASH;\n } else if (char == '?') {\n url.username = base.username;\n url.password = base.password;\n url.host = base.host;\n url.port = base.port;\n url.path = base.path.slice();\n url.query = '';\n state = QUERY;\n } else if (char == '#') {\n url.username = base.username;\n url.password = base.password;\n url.host = base.host;\n url.port = base.port;\n url.path = base.path.slice();\n url.query = base.query;\n url.fragment = '';\n state = FRAGMENT;\n } else {\n url.username = base.username;\n url.password = base.password;\n url.host = base.host;\n url.port = base.port;\n url.path = base.path.slice();\n url.path.pop();\n state = PATH;\n continue;\n } break;\n\n case RELATIVE_SLASH:\n if (isSpecial(url) && (char == '/' || char == '\\\\')) {\n state = SPECIAL_AUTHORITY_IGNORE_SLASHES;\n } else if (char == '/') {\n state = AUTHORITY;\n } else {\n url.username = base.username;\n url.password = base.password;\n url.host = base.host;\n url.port = base.port;\n state = PATH;\n continue;\n } break;\n\n case SPECIAL_AUTHORITY_SLASHES:\n state = SPECIAL_AUTHORITY_IGNORE_SLASHES;\n if (char != '/' || buffer.charAt(pointer + 1) != '/') continue;\n pointer++;\n break;\n\n case SPECIAL_AUTHORITY_IGNORE_SLASHES:\n if (char != '/' && char != '\\\\') {\n state = AUTHORITY;\n continue;\n } break;\n\n case AUTHORITY:\n if (char == '@') {\n if (seenAt) buffer = '%40' + buffer;\n seenAt = true;\n bufferCodePoints = arrayFrom(buffer);\n for (var i = 0; i < bufferCodePoints.length; i++) {\n var codePoint = bufferCodePoints[i];\n if (codePoint == ':' && !seenPasswordToken) {\n seenPasswordToken = true;\n continue;\n }\n var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet);\n if (seenPasswordToken) url.password += encodedCodePoints;\n else url.username += encodedCodePoints;\n }\n buffer = '';\n } else if (\n char == EOF || char == '/' || char == '?' || char == '#' ||\n (char == '\\\\' && isSpecial(url))\n ) {\n if (seenAt && buffer == '') return INVALID_AUTHORITY;\n pointer -= arrayFrom(buffer).length + 1;\n buffer = '';\n state = HOST;\n } else buffer += char;\n break;\n\n case HOST:\n case HOSTNAME:\n if (stateOverride && url.scheme == 'file') {\n state = FILE_HOST;\n continue;\n } else if (char == ':' && !seenBracket) {\n if (buffer == '') return INVALID_HOST;\n failure = parseHost(url, buffer);\n if (failure) return failure;\n buffer = '';\n state = PORT;\n if (stateOverride == HOSTNAME) return;\n } else if (\n char == EOF || char == '/' || char == '?' || char == '#' ||\n (char == '\\\\' && isSpecial(url))\n ) {\n if (isSpecial(url) && buffer == '') return INVALID_HOST;\n if (stateOverride && buffer == '' && (includesCredentials(url) || url.port !== null)) return;\n failure = parseHost(url, buffer);\n if (failure) return failure;\n buffer = '';\n state = PATH_START;\n if (stateOverride) return;\n continue;\n } else {\n if (char == '[') seenBracket = true;\n else if (char == ']') seenBracket = false;\n buffer += char;\n } break;\n\n case PORT:\n if (DIGIT.test(char)) {\n buffer += char;\n } else if (\n char == EOF || char == '/' || char == '?' || char == '#' ||\n (char == '\\\\' && isSpecial(url)) ||\n stateOverride\n ) {\n if (buffer != '') {\n var port = parseInt(buffer, 10);\n if (port > 0xFFFF) return INVALID_PORT;\n url.port = (isSpecial(url) && port === specialSchemes[url.scheme]) ? null : port;\n buffer = '';\n }\n if (stateOverride) return;\n state = PATH_START;\n continue;\n } else return INVALID_PORT;\n break;\n\n case FILE:\n url.scheme = 'file';\n if (char == '/' || char == '\\\\') state = FILE_SLASH;\n else if (base && base.scheme == 'file') {\n if (char == EOF) {\n url.host = base.host;\n url.path = base.path.slice();\n url.query = base.query;\n } else if (char == '?') {\n url.host = base.host;\n url.path = base.path.slice();\n url.query = '';\n state = QUERY;\n } else if (char == '#') {\n url.host = base.host;\n url.path = base.path.slice();\n url.query = base.query;\n url.fragment = '';\n state = FRAGMENT;\n } else {\n if (!startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {\n url.host = base.host;\n url.path = base.path.slice();\n shortenURLsPath(url);\n }\n state = PATH;\n continue;\n }\n } else {\n state = PATH;\n continue;\n } break;\n\n case FILE_SLASH:\n if (char == '/' || char == '\\\\') {\n state = FILE_HOST;\n break;\n }\n if (base && base.scheme == 'file' && !startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {\n if (isWindowsDriveLetter(base.path[0], true)) url.path.push(base.path[0]);\n else url.host = base.host;\n }\n state = PATH;\n continue;\n\n case FILE_HOST:\n if (char == EOF || char == '/' || char == '\\\\' || char == '?' || char == '#') {\n if (!stateOverride && isWindowsDriveLetter(buffer)) {\n state = PATH;\n } else if (buffer == '') {\n url.host = '';\n if (stateOverride) return;\n state = PATH_START;\n } else {\n failure = parseHost(url, buffer);\n if (failure) return failure;\n if (url.host == 'localhost') url.host = '';\n if (stateOverride) return;\n buffer = '';\n state = PATH_START;\n } continue;\n } else buffer += char;\n break;\n\n case PATH_START:\n if (isSpecial(url)) {\n state = PATH;\n if (char != '/' && char != '\\\\') continue;\n } else if (!stateOverride && char == '?') {\n url.query = '';\n state = QUERY;\n } else if (!stateOverride && char == '#') {\n url.fragment = '';\n state = FRAGMENT;\n } else if (char != EOF) {\n state = PATH;\n if (char != '/') continue;\n } break;\n\n case PATH:\n if (\n char == EOF || char == '/' ||\n (char == '\\\\' && isSpecial(url)) ||\n (!stateOverride && (char == '?' || char == '#'))\n ) {\n if (isDoubleDot(buffer)) {\n shortenURLsPath(url);\n if (char != '/' && !(char == '\\\\' && isSpecial(url))) {\n url.path.push('');\n }\n } else if (isSingleDot(buffer)) {\n if (char != '/' && !(char == '\\\\' && isSpecial(url))) {\n url.path.push('');\n }\n } else {\n if (url.scheme == 'file' && !url.path.length && isWindowsDriveLetter(buffer)) {\n if (url.host) url.host = '';\n buffer = buffer.charAt(0) + ':'; // normalize windows drive letter\n }\n url.path.push(buffer);\n }\n buffer = '';\n if (url.scheme == 'file' && (char == EOF || char == '?' || char == '#')) {\n while (url.path.length > 1 && url.path[0] === '') {\n url.path.shift();\n }\n }\n if (char == '?') {\n url.query = '';\n state = QUERY;\n } else if (char == '#') {\n url.fragment = '';\n state = FRAGMENT;\n }\n } else {\n buffer += percentEncode(char, pathPercentEncodeSet);\n } break;\n\n case CANNOT_BE_A_BASE_URL_PATH:\n if (char == '?') {\n url.query = '';\n state = QUERY;\n } else if (char == '#') {\n url.fragment = '';\n state = FRAGMENT;\n } else if (char != EOF) {\n url.path[0] += percentEncode(char, C0ControlPercentEncodeSet);\n } break;\n\n case QUERY:\n if (!stateOverride && char == '#') {\n url.fragment = '';\n state = FRAGMENT;\n } else if (char != EOF) {\n if (char == \"'\" && isSpecial(url)) url.query += '%27';\n else if (char == '#') url.query += '%23';\n else url.query += percentEncode(char, C0ControlPercentEncodeSet);\n } break;\n\n case FRAGMENT:\n if (char != EOF) url.fragment += percentEncode(char, fragmentPercentEncodeSet);\n break;\n }\n\n pointer++;\n }\n};\n\n// `URL` constructor\n// https://url.spec.whatwg.org/#url-class\nvar URLConstructor = function URL(url /* , base */) {\n var that = anInstance(this, URLConstructor, 'URL');\n var base = arguments.length > 1 ? arguments[1] : undefined;\n var urlString = String(url);\n var state = setInternalState(that, { type: 'URL' });\n var baseState, failure;\n if (base !== undefined) {\n if (base instanceof URLConstructor) baseState = getInternalURLState(base);\n else {\n failure = parseURL(baseState = {}, String(base));\n if (failure) throw TypeError(failure);\n }\n }\n failure = parseURL(state, urlString, null, baseState);\n if (failure) throw TypeError(failure);\n var searchParams = state.searchParams = new URLSearchParams();\n var searchParamsState = getInternalSearchParamsState(searchParams);\n searchParamsState.updateSearchParams(state.query);\n searchParamsState.updateURL = function () {\n state.query = String(searchParams) || null;\n };\n if (!DESCRIPTORS) {\n that.href = serializeURL.call(that);\n that.origin = getOrigin.call(that);\n that.protocol = getProtocol.call(that);\n that.username = getUsername.call(that);\n that.password = getPassword.call(that);\n that.host = getHost.call(that);\n that.hostname = getHostname.call(that);\n that.port = getPort.call(that);\n that.pathname = getPathname.call(that);\n that.search = getSearch.call(that);\n that.searchParams = getSearchParams.call(that);\n that.hash = getHash.call(that);\n }\n};\n\nvar URLPrototype = URLConstructor.prototype;\n\nvar serializeURL = function () {\n var url = getInternalURLState(this);\n var scheme = url.scheme;\n var username = url.username;\n var password = url.password;\n var host = url.host;\n var port = url.port;\n var path = url.path;\n var query = url.query;\n var fragment = url.fragment;\n var output = scheme + ':';\n if (host !== null) {\n output += '//';\n if (includesCredentials(url)) {\n output += username + (password ? ':' + password : '') + '@';\n }\n output += serializeHost(host);\n if (port !== null) output += ':' + port;\n } else if (scheme == 'file') output += '//';\n output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';\n if (query !== null) output += '?' + query;\n if (fragment !== null) output += '#' + fragment;\n return output;\n};\n\nvar getOrigin = function () {\n var url = getInternalURLState(this);\n var scheme = url.scheme;\n var port = url.port;\n if (scheme == 'blob') try {\n return new URL(scheme.path[0]).origin;\n } catch (error) {\n return 'null';\n }\n if (scheme == 'file' || !isSpecial(url)) return 'null';\n return scheme + '://' + serializeHost(url.host) + (port !== null ? ':' + port : '');\n};\n\nvar getProtocol = function () {\n return getInternalURLState(this).scheme + ':';\n};\n\nvar getUsername = function () {\n return getInternalURLState(this).username;\n};\n\nvar getPassword = function () {\n return getInternalURLState(this).password;\n};\n\nvar getHost = function () {\n var url = getInternalURLState(this);\n var host = url.host;\n var port = url.port;\n return host === null ? ''\n : port === null ? serializeHost(host)\n : serializeHost(host) + ':' + port;\n};\n\nvar getHostname = function () {\n var host = getInternalURLState(this).host;\n return host === null ? '' : serializeHost(host);\n};\n\nvar getPort = function () {\n var port = getInternalURLState(this).port;\n return port === null ? '' : String(port);\n};\n\nvar getPathname = function () {\n var url = getInternalURLState(this);\n var path = url.path;\n return url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';\n};\n\nvar getSearch = function () {\n var query = getInternalURLState(this).query;\n return query ? '?' + query : '';\n};\n\nvar getSearchParams = function () {\n return getInternalURLState(this).searchParams;\n};\n\nvar getHash = function () {\n var fragment = getInternalURLState(this).fragment;\n return fragment ? '#' + fragment : '';\n};\n\nvar accessorDescriptor = function (getter, setter) {\n return { get: getter, set: setter, configurable: true, enumerable: true };\n};\n\nif (DESCRIPTORS) {\n defineProperties(URLPrototype, {\n // `URL.prototype.href` accessors pair\n // https://url.spec.whatwg.org/#dom-url-href\n href: accessorDescriptor(serializeURL, function (href) {\n var url = getInternalURLState(this);\n var urlString = String(href);\n var failure = parseURL(url, urlString);\n if (failure) throw TypeError(failure);\n getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);\n }),\n // `URL.prototype.origin` getter\n // https://url.spec.whatwg.org/#dom-url-origin\n origin: accessorDescriptor(getOrigin),\n // `URL.prototype.protocol` accessors pair\n // https://url.spec.whatwg.org/#dom-url-protocol\n protocol: accessorDescriptor(getProtocol, function (protocol) {\n var url = getInternalURLState(this);\n parseURL(url, String(protocol) + ':', SCHEME_START);\n }),\n // `URL.prototype.username` accessors pair\n // https://url.spec.whatwg.org/#dom-url-username\n username: accessorDescriptor(getUsername, function (username) {\n var url = getInternalURLState(this);\n var codePoints = arrayFrom(String(username));\n if (cannotHaveUsernamePasswordPort(url)) return;\n url.username = '';\n for (var i = 0; i < codePoints.length; i++) {\n url.username += percentEncode(codePoints[i], userinfoPercentEncodeSet);\n }\n }),\n // `URL.prototype.password` accessors pair\n // https://url.spec.whatwg.org/#dom-url-password\n password: accessorDescriptor(getPassword, function (password) {\n var url = getInternalURLState(this);\n var codePoints = arrayFrom(String(password));\n if (cannotHaveUsernamePasswordPort(url)) return;\n url.password = '';\n for (var i = 0; i < codePoints.length; i++) {\n url.password += percentEncode(codePoints[i], userinfoPercentEncodeSet);\n }\n }),\n // `URL.prototype.host` accessors pair\n // https://url.spec.whatwg.org/#dom-url-host\n host: accessorDescriptor(getHost, function (host) {\n var url = getInternalURLState(this);\n if (url.cannotBeABaseURL) return;\n parseURL(url, String(host), HOST);\n }),\n // `URL.prototype.hostname` accessors pair\n // https://url.spec.whatwg.org/#dom-url-hostname\n hostname: accessorDescriptor(getHostname, function (hostname) {\n var url = getInternalURLState(this);\n if (url.cannotBeABaseURL) return;\n parseURL(url, String(hostname), HOSTNAME);\n }),\n // `URL.prototype.port` accessors pair\n // https://url.spec.whatwg.org/#dom-url-port\n port: accessorDescriptor(getPort, function (port) {\n var url = getInternalURLState(this);\n if (cannotHaveUsernamePasswordPort(url)) return;\n port = String(port);\n if (port == '') url.port = null;\n else parseURL(url, port, PORT);\n }),\n // `URL.prototype.pathname` accessors pair\n // https://url.spec.whatwg.org/#dom-url-pathname\n pathname: accessorDescriptor(getPathname, function (pathname) {\n var url = getInternalURLState(this);\n if (url.cannotBeABaseURL) return;\n url.path = [];\n parseURL(url, pathname + '', PATH_START);\n }),\n // `URL.prototype.search` accessors pair\n // https://url.spec.whatwg.org/#dom-url-search\n search: accessorDescriptor(getSearch, function (search) {\n var url = getInternalURLState(this);\n search = String(search);\n if (search == '') {\n url.query = null;\n } else {\n if ('?' == search.charAt(0)) search = search.slice(1);\n url.query = '';\n parseURL(url, search, QUERY);\n }\n getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);\n }),\n // `URL.prototype.searchParams` getter\n // https://url.spec.whatwg.org/#dom-url-searchparams\n searchParams: accessorDescriptor(getSearchParams),\n // `URL.prototype.hash` accessors pair\n // https://url.spec.whatwg.org/#dom-url-hash\n hash: accessorDescriptor(getHash, function (hash) {\n var url = getInternalURLState(this);\n hash = String(hash);\n if (hash == '') {\n url.fragment = null;\n return;\n }\n if ('#' == hash.charAt(0)) hash = hash.slice(1);\n url.fragment = '';\n parseURL(url, hash, FRAGMENT);\n })\n });\n}\n\n// `URL.prototype.toJSON` method\n// https://url.spec.whatwg.org/#dom-url-tojson\nredefine(URLPrototype, 'toJSON', function toJSON() {\n return serializeURL.call(this);\n}, { enumerable: true });\n\n// `URL.prototype.toString` method\n// https://url.spec.whatwg.org/#URL-stringification-behavior\nredefine(URLPrototype, 'toString', function toString() {\n return serializeURL.call(this);\n}, { enumerable: true });\n\nif (NativeURL) {\n var nativeCreateObjectURL = NativeURL.createObjectURL;\n var nativeRevokeObjectURL = NativeURL.revokeObjectURL;\n // `URL.createObjectURL` method\n // https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL\n // eslint-disable-next-line no-unused-vars\n if (nativeCreateObjectURL) redefine(URLConstructor, 'createObjectURL', function createObjectURL(blob) {\n return nativeCreateObjectURL.apply(NativeURL, arguments);\n });\n // `URL.revokeObjectURL` method\n // https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL\n // eslint-disable-next-line no-unused-vars\n if (nativeRevokeObjectURL) redefine(URLConstructor, 'revokeObjectURL', function revokeObjectURL(url) {\n return nativeRevokeObjectURL.apply(NativeURL, arguments);\n });\n}\n\nsetToStringTag(URLConstructor, 'URL');\n\n$({ global: true, forced: !USE_NATIVE_URL, sham: !DESCRIPTORS }, {\n URL: URLConstructor\n});\n","'use strict';\nvar $ = require('../internals/export');\n\n// `URL.prototype.toJSON` method\n// https://url.spec.whatwg.org/#dom-url-tojson\n$({ target: 'URL', proto: true, enumerable: true }, {\n toJSON: function toJSON() {\n return URL.prototype.toString.call(this);\n }\n});\n","/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function define(obj, key, value) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n return obj[key];\n }\n try {\n // IE 8 has a broken Object.defineProperty that only works on DOM objects.\n define({}, \"\");\n } catch (err) {\n define = function(obj, key, value) {\n return obj[key] = value;\n };\n }\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunction.displayName = define(\n GeneratorFunctionPrototype,\n toStringTagSymbol,\n \"GeneratorFunction\"\n );\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n define(prototype, method, function(arg) {\n return this._invoke(method, arg);\n });\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n define(genFun, toStringTagSymbol, \"GeneratorFunction\");\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator, PromiseImpl) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return PromiseImpl.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return PromiseImpl.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new PromiseImpl(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {\n if (PromiseImpl === void 0) PromiseImpl = Promise;\n\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList),\n PromiseImpl\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n define(Gp, toStringTagSymbol, \"Generator\");\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n}\n","// http://ross.posterous.com/2008/08/19/iphone-touch-events-in-javascript/\n/**\n *\n * @param {Event} ev\n * @returns {void}\n */\nfunction touchHandler (ev) {\n const {changedTouches} = ev,\n first = changedTouches[0];\n\n let type = '';\n switch (ev.type) {\n case 'touchstart': type = 'mousedown'; break;\n case 'touchmove': type = 'mousemove'; break;\n case 'touchend': type = 'mouseup'; break;\n default: return;\n }\n\n const {screenX, screenY, clientX, clientY} = first; // eslint-disable-line no-shadow\n const simulatedEvent = new MouseEvent(type, {\n // Event interface\n bubbles: true,\n cancelable: true,\n // UIEvent interface\n view: window,\n detail: 1, // click count\n // MouseEvent interface (customized)\n screenX, screenY, clientX, clientY,\n // MouseEvent interface (defaults) - these could be removed\n ctrlKey: false,\n altKey: false,\n shiftKey: false,\n metaKey: false,\n button: 0, // main button (usually left)\n relatedTarget: null\n });\n if (changedTouches.length < 2) {\n first.target.dispatchEvent(simulatedEvent);\n ev.preventDefault();\n }\n}\n\ndocument.addEventListener('touchstart', touchHandler, true);\ndocument.addEventListener('touchmove', touchHandler, true);\ndocument.addEventListener('touchend', touchHandler, true);\ndocument.addEventListener('touchcancel', touchHandler, true);\n","/**\n * Namespaces or tools therefor.\n * @module namespaces\n * @license MIT\n*/\n\n/**\n* Common namepaces constants in alpha order.\n* @enum {string}\n* @type {PlainObject}\n* @memberof module:namespaces\n*/\nexport const NS = {\n HTML: 'http://www.w3.org/1999/xhtml',\n MATH: 'http://www.w3.org/1998/Math/MathML',\n SE: 'http://svg-edit.googlecode.com',\n SVG: 'http://www.w3.org/2000/svg',\n XLINK: 'http://www.w3.org/1999/xlink',\n XML: 'http://www.w3.org/XML/1998/namespace',\n XMLNS: 'http://www.w3.org/2000/xmlns/' // see http://www.w3.org/TR/REC-xml-names/#xmlReserved\n};\n\n/**\n* @function module:namespaces.getReverseNS\n* @returns {string} The NS with key values switched and lowercase\n*/\nexport const getReverseNS = function () {\n const reverseNS = {};\n Object.entries(NS).forEach(([name, URI]) => {\n reverseNS[URI] = name.toLowerCase();\n });\n return reverseNS;\n};\n","/* eslint-disable import/unambiguous, max-len */\n/* globals SVGPathSeg, SVGPathSegMovetoRel, SVGPathSegMovetoAbs,\n SVGPathSegMovetoRel, SVGPathSegLinetoRel, SVGPathSegLinetoAbs,\n SVGPathSegLinetoHorizontalRel, SVGPathSegLinetoHorizontalAbs,\n SVGPathSegLinetoVerticalRel, SVGPathSegLinetoVerticalAbs,\n SVGPathSegClosePath, SVGPathSegCurvetoCubicRel,\n SVGPathSegCurvetoCubicAbs, SVGPathSegCurvetoCubicSmoothRel,\n SVGPathSegCurvetoCubicSmoothAbs, SVGPathSegCurvetoQuadraticRel,\n SVGPathSegCurvetoQuadraticAbs, SVGPathSegCurvetoQuadraticSmoothRel,\n SVGPathSegCurvetoQuadraticSmoothAbs, SVGPathSegArcRel, SVGPathSegArcAbs */\n/**\n* SVGPathSeg API polyfill\n* https://github.com/progers/pathseg\n*\n* This is a drop-in replacement for the `SVGPathSeg` and `SVGPathSegList` APIs\n* that were removed from SVG2 ({@link https://lists.w3.org/Archives/Public/www-svg/2015Jun/0044.html}),\n* including the latest spec changes which were implemented in Firefox 43 and\n* Chrome 46.\n*/\n/* eslint-disable no-shadow, class-methods-use-this, jsdoc/require-jsdoc */\n// Linting: We avoid `no-shadow` as ESLint thinks these are still available globals\n// Linting: We avoid `class-methods-use-this` as this is a polyfill that must\n// follow the conventions\n(() => {\nif (!('SVGPathSeg' in window)) {\n // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSeg\n class SVGPathSeg {\n constructor (type, typeAsLetter, owningPathSegList) {\n this.pathSegType = type;\n this.pathSegTypeAsLetter = typeAsLetter;\n this._owningPathSegList = owningPathSegList;\n }\n // Notify owning PathSegList on any changes so they can be synchronized back to the path element.\n _segmentChanged () {\n if (this._owningPathSegList) {\n this._owningPathSegList.segmentChanged(this);\n }\n }\n }\n SVGPathSeg.prototype.classname = 'SVGPathSeg';\n\n SVGPathSeg.PATHSEG_UNKNOWN = 0;\n SVGPathSeg.PATHSEG_CLOSEPATH = 1;\n SVGPathSeg.PATHSEG_MOVETO_ABS = 2;\n SVGPathSeg.PATHSEG_MOVETO_REL = 3;\n SVGPathSeg.PATHSEG_LINETO_ABS = 4;\n SVGPathSeg.PATHSEG_LINETO_REL = 5;\n SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS = 6;\n SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL = 7;\n SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS = 8;\n SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL = 9;\n SVGPathSeg.PATHSEG_ARC_ABS = 10;\n SVGPathSeg.PATHSEG_ARC_REL = 11;\n SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS = 12;\n SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL = 13;\n SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS = 14;\n SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL = 15;\n SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16;\n SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17;\n SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18;\n SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19;\n\n class SVGPathSegClosePath extends SVGPathSeg {\n constructor (owningPathSegList) {\n super(SVGPathSeg.PATHSEG_CLOSEPATH, 'z', owningPathSegList);\n }\n toString () { return '[object SVGPathSegClosePath]'; }\n _asPathString () { return this.pathSegTypeAsLetter; }\n clone () { return new SVGPathSegClosePath(undefined); }\n }\n\n class SVGPathSegMovetoAbs extends SVGPathSeg {\n constructor (owningPathSegList, x, y) {\n super(SVGPathSeg.PATHSEG_MOVETO_ABS, 'M', owningPathSegList);\n this._x = x;\n this._y = y;\n }\n toString () { return '[object SVGPathSegMovetoAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegMovetoAbs(undefined, this._x, this._y); }\n }\n Object.defineProperties(SVGPathSegMovetoAbs.prototype, {\n x: {\n get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true\n },\n y: {\n get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true\n }\n });\n\n class SVGPathSegMovetoRel extends SVGPathSeg {\n constructor (owningPathSegList, x, y) {\n super(SVGPathSeg.PATHSEG_MOVETO_REL, 'm', owningPathSegList);\n this._x = x;\n this._y = y;\n }\n toString () { return '[object SVGPathSegMovetoRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegMovetoRel(undefined, this._x, this._y); }\n }\n Object.defineProperties(SVGPathSegMovetoRel.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegLinetoAbs extends SVGPathSeg {\n constructor (owningPathSegList, x, y) {\n super(SVGPathSeg.PATHSEG_LINETO_ABS, 'L', owningPathSegList);\n this._x = x;\n this._y = y;\n }\n toString () { return '[object SVGPathSegLinetoAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegLinetoAbs(undefined, this._x, this._y); }\n }\n Object.defineProperties(SVGPathSegLinetoAbs.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegLinetoRel extends SVGPathSeg {\n constructor (owningPathSegList, x, y) {\n super(SVGPathSeg.PATHSEG_LINETO_REL, 'l', owningPathSegList);\n this._x = x;\n this._y = y;\n }\n toString () { return '[object SVGPathSegLinetoRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegLinetoRel(undefined, this._x, this._y); }\n }\n Object.defineProperties(SVGPathSegLinetoRel.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegCurvetoCubicAbs extends SVGPathSeg {\n constructor (owningPathSegList, x, y, x1, y1, x2, y2) {\n super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS, 'C', owningPathSegList);\n this._x = x;\n this._y = y;\n this._x1 = x1;\n this._y1 = y1;\n this._x2 = x2;\n this._y2 = y2;\n }\n toString () { return '[object SVGPathSegCurvetoCubicAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoCubicAbs(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); }\n }\n Object.defineProperties(SVGPathSegCurvetoCubicAbs.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n x1: {get () { return this._x1; }, set (x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true},\n y1: {get () { return this._y1; }, set (y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true},\n x2: {get () { return this._x2; }, set (x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true},\n y2: {get () { return this._y2; }, set (y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegCurvetoCubicRel extends SVGPathSeg {\n constructor (owningPathSegList, x, y, x1, y1, x2, y2) {\n super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL, 'c', owningPathSegList);\n this._x = x;\n this._y = y;\n this._x1 = x1;\n this._y1 = y1;\n this._x2 = x2;\n this._y2 = y2;\n }\n toString () { return '[object SVGPathSegCurvetoCubicRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoCubicRel(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); }\n }\n Object.defineProperties(SVGPathSegCurvetoCubicRel.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n x1: {get () { return this._x1; }, set (x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true},\n y1: {get () { return this._y1; }, set (y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true},\n x2: {get () { return this._x2; }, set (x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true},\n y2: {get () { return this._y2; }, set (y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg {\n constructor (owningPathSegList, x, y, x1, y1) {\n super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS, 'Q', owningPathSegList);\n this._x = x;\n this._y = y;\n this._x1 = x1;\n this._y1 = y1;\n }\n toString () { return '[object SVGPathSegCurvetoQuadraticAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoQuadraticAbs(undefined, this._x, this._y, this._x1, this._y1); }\n }\n Object.defineProperties(SVGPathSegCurvetoQuadraticAbs.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n x1: {get () { return this._x1; }, set (x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true},\n y1: {get () { return this._y1; }, set (y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegCurvetoQuadraticRel extends SVGPathSeg {\n constructor (owningPathSegList, x, y, x1, y1) {\n super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL, 'q', owningPathSegList);\n this._x = x;\n this._y = y;\n this._x1 = x1;\n this._y1 = y1;\n }\n toString () { return '[object SVGPathSegCurvetoQuadraticRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoQuadraticRel(undefined, this._x, this._y, this._x1, this._y1); }\n }\n Object.defineProperties(SVGPathSegCurvetoQuadraticRel.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n x1: {get () { return this._x1; }, set (x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true},\n y1: {get () { return this._y1; }, set (y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegArcAbs extends SVGPathSeg {\n constructor (owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) {\n super(SVGPathSeg.PATHSEG_ARC_ABS, 'A', owningPathSegList);\n this._x = x;\n this._y = y;\n this._r1 = r1;\n this._r2 = r2;\n this._angle = angle;\n this._largeArcFlag = largeArcFlag;\n this._sweepFlag = sweepFlag;\n }\n toString () { return '[object SVGPathSegArcAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegArcAbs(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); }\n }\n Object.defineProperties(SVGPathSegArcAbs.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n r1: {get () { return this._r1; }, set (r1) { this._r1 = r1; this._segmentChanged(); }, enumerable: true},\n r2: {get () { return this._r2; }, set (r2) { this._r2 = r2; this._segmentChanged(); }, enumerable: true},\n angle: {get () { return this._angle; }, set (angle) { this._angle = angle; this._segmentChanged(); }, enumerable: true},\n largeArcFlag: {get () { return this._largeArcFlag; }, set (largeArcFlag) { this._largeArcFlag = largeArcFlag; this._segmentChanged(); }, enumerable: true},\n sweepFlag: {get () { return this._sweepFlag; }, set (sweepFlag) { this._sweepFlag = sweepFlag; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegArcRel extends SVGPathSeg {\n constructor (owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) {\n super(SVGPathSeg.PATHSEG_ARC_REL, 'a', owningPathSegList);\n this._x = x;\n this._y = y;\n this._r1 = r1;\n this._r2 = r2;\n this._angle = angle;\n this._largeArcFlag = largeArcFlag;\n this._sweepFlag = sweepFlag;\n }\n toString () { return '[object SVGPathSegArcRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegArcRel(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); }\n }\n Object.defineProperties(SVGPathSegArcRel.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n r1: {get () { return this._r1; }, set (r1) { this._r1 = r1; this._segmentChanged(); }, enumerable: true},\n r2: {get () { return this._r2; }, set (r2) { this._r2 = r2; this._segmentChanged(); }, enumerable: true},\n angle: {get () { return this._angle; }, set (angle) { this._angle = angle; this._segmentChanged(); }, enumerable: true},\n largeArcFlag: {get () { return this._largeArcFlag; }, set (largeArcFlag) { this._largeArcFlag = largeArcFlag; this._segmentChanged(); }, enumerable: true},\n sweepFlag: {get () { return this._sweepFlag; }, set (sweepFlag) { this._sweepFlag = sweepFlag; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegLinetoHorizontalAbs extends SVGPathSeg {\n constructor (owningPathSegList, x) {\n super(SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS, 'H', owningPathSegList);\n this._x = x;\n }\n toString () { return '[object SVGPathSegLinetoHorizontalAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x; }\n clone () { return new SVGPathSegLinetoHorizontalAbs(undefined, this._x); }\n }\n Object.defineProperty(SVGPathSegLinetoHorizontalAbs.prototype, 'x', {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true});\n\n class SVGPathSegLinetoHorizontalRel extends SVGPathSeg {\n constructor (owningPathSegList, x) {\n super(SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL, 'h', owningPathSegList);\n this._x = x;\n }\n toString () { return '[object SVGPathSegLinetoHorizontalRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x; }\n clone () { return new SVGPathSegLinetoHorizontalRel(undefined, this._x); }\n }\n Object.defineProperty(SVGPathSegLinetoHorizontalRel.prototype, 'x', {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true});\n\n class SVGPathSegLinetoVerticalAbs extends SVGPathSeg {\n constructor (owningPathSegList, y) {\n super(SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS, 'V', owningPathSegList);\n this._y = y;\n }\n toString () { return '[object SVGPathSegLinetoVerticalAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._y; }\n clone () { return new SVGPathSegLinetoVerticalAbs(undefined, this._y); }\n }\n Object.defineProperty(SVGPathSegLinetoVerticalAbs.prototype, 'y', {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true});\n\n class SVGPathSegLinetoVerticalRel extends SVGPathSeg {\n constructor (owningPathSegList, y) {\n super(SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL, 'v', owningPathSegList);\n this._y = y;\n }\n toString () { return '[object SVGPathSegLinetoVerticalRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._y; }\n clone () { return new SVGPathSegLinetoVerticalRel(undefined, this._y); }\n }\n Object.defineProperty(SVGPathSegLinetoVerticalRel.prototype, 'y', {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true});\n\n class SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg {\n constructor (owningPathSegList, x, y, x2, y2) {\n super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, 'S', owningPathSegList);\n this._x = x;\n this._y = y;\n this._x2 = x2;\n this._y2 = y2;\n }\n toString () { return '[object SVGPathSegCurvetoCubicSmoothAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoCubicSmoothAbs(undefined, this._x, this._y, this._x2, this._y2); }\n }\n Object.defineProperties(SVGPathSegCurvetoCubicSmoothAbs.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n x2: {get () { return this._x2; }, set (x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true},\n y2: {get () { return this._y2; }, set (y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg {\n constructor (owningPathSegList, x, y, x2, y2) {\n super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL, 's', owningPathSegList);\n this._x = x;\n this._y = y;\n this._x2 = x2;\n this._y2 = y2;\n }\n toString () { return '[object SVGPathSegCurvetoCubicSmoothRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoCubicSmoothRel(undefined, this._x, this._y, this._x2, this._y2); }\n }\n Object.defineProperties(SVGPathSegCurvetoCubicSmoothRel.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n x2: {get () { return this._x2; }, set (x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true},\n y2: {get () { return this._y2; }, set (y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg {\n constructor (owningPathSegList, x, y) {\n super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, 'T', owningPathSegList);\n this._x = x;\n this._y = y;\n }\n toString () { return '[object SVGPathSegCurvetoQuadraticSmoothAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoQuadraticSmoothAbs(undefined, this._x, this._y); }\n }\n Object.defineProperties(SVGPathSegCurvetoQuadraticSmoothAbs.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg {\n constructor (owningPathSegList, x, y) {\n super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, 't', owningPathSegList);\n this._x = x;\n this._y = y;\n }\n toString () { return '[object SVGPathSegCurvetoQuadraticSmoothRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoQuadraticSmoothRel(undefined, this._x, this._y); }\n }\n Object.defineProperties(SVGPathSegCurvetoQuadraticSmoothRel.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}\n });\n\n // Add createSVGPathSeg* functions to SVGPathElement.\n // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathElement.\n SVGPathElement.prototype.createSVGPathSegClosePath = function () { return new SVGPathSegClosePath(undefined); };\n SVGPathElement.prototype.createSVGPathSegMovetoAbs = function (x, y) { return new SVGPathSegMovetoAbs(undefined, x, y); };\n SVGPathElement.prototype.createSVGPathSegMovetoRel = function (x, y) { return new SVGPathSegMovetoRel(undefined, x, y); };\n SVGPathElement.prototype.createSVGPathSegLinetoAbs = function (x, y) { return new SVGPathSegLinetoAbs(undefined, x, y); };\n SVGPathElement.prototype.createSVGPathSegLinetoRel = function (x, y) { return new SVGPathSegLinetoRel(undefined, x, y); };\n SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs = function (x, y, x1, y1, x2, y2) { return new SVGPathSegCurvetoCubicAbs(undefined, x, y, x1, y1, x2, y2); };\n SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel = function (x, y, x1, y1, x2, y2) { return new SVGPathSegCurvetoCubicRel(undefined, x, y, x1, y1, x2, y2); };\n SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs = function (x, y, x1, y1) { return new SVGPathSegCurvetoQuadraticAbs(undefined, x, y, x1, y1); };\n SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel = function (x, y, x1, y1) { return new SVGPathSegCurvetoQuadraticRel(undefined, x, y, x1, y1); };\n SVGPathElement.prototype.createSVGPathSegArcAbs = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { return new SVGPathSegArcAbs(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); };\n SVGPathElement.prototype.createSVGPathSegArcRel = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { return new SVGPathSegArcRel(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); };\n SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs = function (x) { return new SVGPathSegLinetoHorizontalAbs(undefined, x); };\n SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel = function (x) { return new SVGPathSegLinetoHorizontalRel(undefined, x); };\n SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs = function (y) { return new SVGPathSegLinetoVerticalAbs(undefined, y); };\n SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel = function (y) { return new SVGPathSegLinetoVerticalRel(undefined, y); };\n SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs = function (x, y, x2, y2) { return new SVGPathSegCurvetoCubicSmoothAbs(undefined, x, y, x2, y2); };\n SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel = function (x, y, x2, y2) { return new SVGPathSegCurvetoCubicSmoothRel(undefined, x, y, x2, y2); };\n SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs = function (x, y) { return new SVGPathSegCurvetoQuadraticSmoothAbs(undefined, x, y); };\n SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel = function (x, y) { return new SVGPathSegCurvetoQuadraticSmoothRel(undefined, x, y); };\n\n if (!('getPathSegAtLength' in SVGPathElement.prototype)) {\n // Add getPathSegAtLength to SVGPathElement.\n // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-__svg__SVGPathElement__getPathSegAtLength\n // This polyfill requires SVGPathElement.getTotalLength to implement the distance-along-a-path algorithm.\n SVGPathElement.prototype.getPathSegAtLength = function (distance) {\n if (distance === undefined || !isFinite(distance)) {\n throw new Error('Invalid arguments.');\n }\n\n const measurementElement = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n measurementElement.setAttribute('d', this.getAttribute('d'));\n let lastPathSegment = measurementElement.pathSegList.numberOfItems - 1;\n\n // If the path is empty, return 0.\n if (lastPathSegment <= 0) {\n return 0;\n }\n\n do {\n measurementElement.pathSegList.removeItem(lastPathSegment);\n if (distance > measurementElement.getTotalLength()) {\n break;\n }\n lastPathSegment--;\n } while (lastPathSegment > 0);\n return lastPathSegment;\n };\n }\n\n window.SVGPathSeg = SVGPathSeg;\n window.SVGPathSegClosePath = SVGPathSegClosePath;\n window.SVGPathSegMovetoAbs = SVGPathSegMovetoAbs;\n window.SVGPathSegMovetoRel = SVGPathSegMovetoRel;\n window.SVGPathSegLinetoAbs = SVGPathSegLinetoAbs;\n window.SVGPathSegLinetoRel = SVGPathSegLinetoRel;\n window.SVGPathSegCurvetoCubicAbs = SVGPathSegCurvetoCubicAbs;\n window.SVGPathSegCurvetoCubicRel = SVGPathSegCurvetoCubicRel;\n window.SVGPathSegCurvetoQuadraticAbs = SVGPathSegCurvetoQuadraticAbs;\n window.SVGPathSegCurvetoQuadraticRel = SVGPathSegCurvetoQuadraticRel;\n window.SVGPathSegArcAbs = SVGPathSegArcAbs;\n window.SVGPathSegArcRel = SVGPathSegArcRel;\n window.SVGPathSegLinetoHorizontalAbs = SVGPathSegLinetoHorizontalAbs;\n window.SVGPathSegLinetoHorizontalRel = SVGPathSegLinetoHorizontalRel;\n window.SVGPathSegLinetoVerticalAbs = SVGPathSegLinetoVerticalAbs;\n window.SVGPathSegLinetoVerticalRel = SVGPathSegLinetoVerticalRel;\n window.SVGPathSegCurvetoCubicSmoothAbs = SVGPathSegCurvetoCubicSmoothAbs;\n window.SVGPathSegCurvetoCubicSmoothRel = SVGPathSegCurvetoCubicSmoothRel;\n window.SVGPathSegCurvetoQuadraticSmoothAbs = SVGPathSegCurvetoQuadraticSmoothAbs;\n window.SVGPathSegCurvetoQuadraticSmoothRel = SVGPathSegCurvetoQuadraticSmoothRel;\n}\n\n// Checking for SVGPathSegList in window checks for the case of an implementation without the\n// SVGPathSegList API.\n// The second check for appendItem is specific to Firefox 59+ which removed only parts of the\n// SVGPathSegList API (e.g., appendItem). In this case we need to re-implement the entire API\n// so the polyfill data (i.e., _list) is used throughout.\nif (!('SVGPathSegList' in window) || !('appendItem' in window.SVGPathSegList.prototype)) {\n // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSegList\n class SVGPathSegList {\n constructor (pathElement) {\n this._pathElement = pathElement;\n this._list = this._parsePath(this._pathElement.getAttribute('d'));\n\n // Use a MutationObserver to catch changes to the path's \"d\" attribute.\n this._mutationObserverConfig = {attributes: true, attributeFilter: ['d']};\n this._pathElementMutationObserver = new MutationObserver(this._updateListFromPathMutations.bind(this));\n this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig);\n }\n // Process any pending mutations to the path element and update the list as needed.\n // This should be the first call of all public functions and is needed because\n // MutationObservers are not synchronous so we can have pending asynchronous mutations.\n _checkPathSynchronizedToList () {\n this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords());\n }\n\n _updateListFromPathMutations (mutationRecords) {\n if (!this._pathElement) {\n return;\n }\n let hasPathMutations = false;\n mutationRecords.forEach((record) => {\n if (record.attributeName === 'd') {\n hasPathMutations = true;\n }\n });\n if (hasPathMutations) {\n this._list = this._parsePath(this._pathElement.getAttribute('d'));\n }\n }\n\n // Serialize the list and update the path's 'd' attribute.\n _writeListToPath () {\n this._pathElementMutationObserver.disconnect();\n this._pathElement.setAttribute('d', SVGPathSegList._pathSegArrayAsString(this._list));\n this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig);\n }\n\n // When a path segment changes the list needs to be synchronized back to the path element.\n segmentChanged (pathSeg) {\n this._writeListToPath();\n }\n\n clear () {\n this._checkPathSynchronizedToList();\n\n this._list.forEach((pathSeg) => {\n pathSeg._owningPathSegList = null;\n });\n this._list = [];\n this._writeListToPath();\n }\n\n initialize (newItem) {\n this._checkPathSynchronizedToList();\n\n this._list = [newItem];\n newItem._owningPathSegList = this;\n this._writeListToPath();\n return newItem;\n }\n\n _checkValidIndex (index) {\n if (isNaN(index) || index < 0 || index >= this.numberOfItems) {\n throw new Error('INDEX_SIZE_ERR');\n }\n }\n\n getItem (index) {\n this._checkPathSynchronizedToList();\n\n this._checkValidIndex(index);\n return this._list[index];\n }\n\n insertItemBefore (newItem, index) {\n this._checkPathSynchronizedToList();\n\n // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list.\n if (index > this.numberOfItems) {\n index = this.numberOfItems;\n }\n if (newItem._owningPathSegList) {\n // SVG2 spec says to make a copy.\n newItem = newItem.clone();\n }\n this._list.splice(index, 0, newItem);\n newItem._owningPathSegList = this;\n this._writeListToPath();\n return newItem;\n }\n\n replaceItem (newItem, index) {\n this._checkPathSynchronizedToList();\n\n if (newItem._owningPathSegList) {\n // SVG2 spec says to make a copy.\n newItem = newItem.clone();\n }\n this._checkValidIndex(index);\n this._list[index] = newItem;\n newItem._owningPathSegList = this;\n this._writeListToPath();\n return newItem;\n }\n\n removeItem (index) {\n this._checkPathSynchronizedToList();\n\n this._checkValidIndex(index);\n const item = this._list[index];\n this._list.splice(index, 1);\n this._writeListToPath();\n return item;\n }\n\n appendItem (newItem) {\n this._checkPathSynchronizedToList();\n\n if (newItem._owningPathSegList) {\n // SVG2 spec says to make a copy.\n newItem = newItem.clone();\n }\n this._list.push(newItem);\n newItem._owningPathSegList = this;\n // TODO: Optimize this to just append to the existing attribute.\n this._writeListToPath();\n return newItem;\n }\n\n // This closely follows SVGPathParser::parsePath from Source/core/svg/SVGPathParser.cpp.\n _parsePath (string) {\n if (!string || !string.length) {\n return [];\n }\n\n const owningPathSegList = this;\n\n class Builder {\n constructor () {\n this.pathSegList = [];\n }\n appendSegment (pathSeg) {\n this.pathSegList.push(pathSeg);\n }\n }\n\n class Source {\n constructor (string) {\n this._string = string;\n this._currentIndex = 0;\n this._endIndex = this._string.length;\n this._previousCommand = SVGPathSeg.PATHSEG_UNKNOWN;\n\n this._skipOptionalSpaces();\n }\n _isCurrentSpace () {\n const character = this._string[this._currentIndex];\n return character <= ' ' && (character === ' ' || character === '\\n' || character === '\\t' || character === '\\r' || character === '\\f');\n }\n\n _skipOptionalSpaces () {\n while (this._currentIndex < this._endIndex && this._isCurrentSpace()) {\n this._currentIndex++;\n }\n return this._currentIndex < this._endIndex;\n }\n\n _skipOptionalSpacesOrDelimiter () {\n if (this._currentIndex < this._endIndex && !this._isCurrentSpace() && this._string.charAt(this._currentIndex) !== ',') {\n return false;\n }\n if (this._skipOptionalSpaces()) {\n if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === ',') {\n this._currentIndex++;\n this._skipOptionalSpaces();\n }\n }\n return this._currentIndex < this._endIndex;\n }\n\n hasMoreData () {\n return this._currentIndex < this._endIndex;\n }\n\n peekSegmentType () {\n const lookahead = this._string[this._currentIndex];\n return this._pathSegTypeFromChar(lookahead);\n }\n\n _pathSegTypeFromChar (lookahead) {\n switch (lookahead) {\n case 'Z':\n case 'z':\n return SVGPathSeg.PATHSEG_CLOSEPATH;\n case 'M':\n return SVGPathSeg.PATHSEG_MOVETO_ABS;\n case 'm':\n return SVGPathSeg.PATHSEG_MOVETO_REL;\n case 'L':\n return SVGPathSeg.PATHSEG_LINETO_ABS;\n case 'l':\n return SVGPathSeg.PATHSEG_LINETO_REL;\n case 'C':\n return SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS;\n case 'c':\n return SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL;\n case 'Q':\n return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;\n case 'q':\n return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;\n case 'A':\n return SVGPathSeg.PATHSEG_ARC_ABS;\n case 'a':\n return SVGPathSeg.PATHSEG_ARC_REL;\n case 'H':\n return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;\n case 'h':\n return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;\n case 'V':\n return SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;\n case 'v':\n return SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;\n case 'S':\n return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;\n case 's':\n return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;\n case 'T':\n return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;\n case 't':\n return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;\n default:\n return SVGPathSeg.PATHSEG_UNKNOWN;\n }\n }\n\n _nextCommandHelper (lookahead, previousCommand) {\n // Check for remaining coordinates in the current command.\n if ((lookahead === '+' || lookahead === '-' || lookahead === '.' || (lookahead >= '0' && lookahead <= '9')) && previousCommand !== SVGPathSeg.PATHSEG_CLOSEPATH) {\n if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_ABS) {\n return SVGPathSeg.PATHSEG_LINETO_ABS;\n }\n if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_REL) {\n return SVGPathSeg.PATHSEG_LINETO_REL;\n }\n return previousCommand;\n }\n return SVGPathSeg.PATHSEG_UNKNOWN;\n }\n\n initialCommandIsMoveTo () {\n // If the path is empty it is still valid, so return true.\n if (!this.hasMoreData()) {\n return true;\n }\n const command = this.peekSegmentType();\n // Path must start with moveTo.\n return command === SVGPathSeg.PATHSEG_MOVETO_ABS || command === SVGPathSeg.PATHSEG_MOVETO_REL;\n }\n\n // Parse a number from an SVG path. This very closely follows genericParseNumber(...) from Source/core/svg/SVGParserUtilities.cpp.\n // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-PathDataBNF\n _parseNumber () {\n let exponent = 0;\n let integer = 0;\n let frac = 1;\n let decimal = 0;\n let sign = 1;\n let expsign = 1;\n\n const startIndex = this._currentIndex;\n\n this._skipOptionalSpaces();\n\n // Read the sign.\n if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '+') {\n this._currentIndex++;\n } else if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '-') {\n this._currentIndex++;\n sign = -1;\n }\n\n if (this._currentIndex === this._endIndex || ((this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') && this._string.charAt(this._currentIndex) !== '.')) {\n // The first character of a number must be one of [0-9+-.].\n return undefined;\n }\n\n // Read the integer part, build right-to-left.\n const startIntPartIndex = this._currentIndex;\n while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') {\n this._currentIndex++; // Advance to first non-digit.\n }\n\n if (this._currentIndex !== startIntPartIndex) {\n let scanIntPartIndex = this._currentIndex - 1;\n let multiplier = 1;\n while (scanIntPartIndex >= startIntPartIndex) {\n integer += multiplier * (this._string.charAt(scanIntPartIndex--) - '0');\n multiplier *= 10;\n }\n }\n\n // Read the decimals.\n if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '.') {\n this._currentIndex++;\n\n // There must be a least one digit following the .\n if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') {\n return undefined;\n }\n while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') {\n frac *= 10;\n decimal += (this._string.charAt(this._currentIndex) - '0') / frac;\n this._currentIndex += 1;\n }\n }\n\n // Read the exponent part.\n if (this._currentIndex !== startIndex && this._currentIndex + 1 < this._endIndex && (this._string.charAt(this._currentIndex) === 'e' || this._string.charAt(this._currentIndex) === 'E') && (this._string.charAt(this._currentIndex + 1) !== 'x' && this._string.charAt(this._currentIndex + 1) !== 'm')) {\n this._currentIndex++;\n\n // Read the sign of the exponent.\n if (this._string.charAt(this._currentIndex) === '+') {\n this._currentIndex++;\n } else if (this._string.charAt(this._currentIndex) === '-') {\n this._currentIndex++;\n expsign = -1;\n }\n\n // There must be an exponent.\n if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') {\n return undefined;\n }\n\n while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') {\n exponent *= 10;\n exponent += (this._string.charAt(this._currentIndex) - '0');\n this._currentIndex++;\n }\n }\n\n let number = integer + decimal;\n number *= sign;\n\n if (exponent) {\n number *= 10 ** (expsign * exponent);\n }\n\n if (startIndex === this._currentIndex) {\n return undefined;\n }\n\n this._skipOptionalSpacesOrDelimiter();\n\n return number;\n }\n\n _parseArcFlag () {\n if (this._currentIndex >= this._endIndex) {\n return undefined;\n }\n let flag = false;\n const flagChar = this._string.charAt(this._currentIndex++);\n if (flagChar === '0') {\n flag = false;\n } else if (flagChar === '1') {\n flag = true;\n } else {\n return undefined;\n }\n\n this._skipOptionalSpacesOrDelimiter();\n return flag;\n }\n\n parseSegment () {\n const lookahead = this._string[this._currentIndex];\n let command = this._pathSegTypeFromChar(lookahead);\n if (command === SVGPathSeg.PATHSEG_UNKNOWN) {\n // Possibly an implicit command. Not allowed if this is the first command.\n if (this._previousCommand === SVGPathSeg.PATHSEG_UNKNOWN) {\n return null;\n }\n command = this._nextCommandHelper(lookahead, this._previousCommand);\n if (command === SVGPathSeg.PATHSEG_UNKNOWN) {\n return null;\n }\n } else {\n this._currentIndex++;\n }\n\n this._previousCommand = command;\n\n switch (command) {\n case SVGPathSeg.PATHSEG_MOVETO_REL:\n return new SVGPathSegMovetoRel(owningPathSegList, this._parseNumber(), this._parseNumber());\n case SVGPathSeg.PATHSEG_MOVETO_ABS:\n return new SVGPathSegMovetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber());\n case SVGPathSeg.PATHSEG_LINETO_REL:\n return new SVGPathSegLinetoRel(owningPathSegList, this._parseNumber(), this._parseNumber());\n case SVGPathSeg.PATHSEG_LINETO_ABS:\n return new SVGPathSegLinetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber());\n case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:\n return new SVGPathSegLinetoHorizontalRel(owningPathSegList, this._parseNumber());\n case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:\n return new SVGPathSegLinetoHorizontalAbs(owningPathSegList, this._parseNumber());\n case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:\n return new SVGPathSegLinetoVerticalRel(owningPathSegList, this._parseNumber());\n case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:\n return new SVGPathSegLinetoVerticalAbs(owningPathSegList, this._parseNumber());\n case SVGPathSeg.PATHSEG_CLOSEPATH:\n this._skipOptionalSpaces();\n return new SVGPathSegClosePath(owningPathSegList);\n case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL: {\n const points = {x1: this._parseNumber(), y1: this._parseNumber(), x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegCurvetoCubicRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2);\n } case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS: {\n const points = {x1: this._parseNumber(), y1: this._parseNumber(), x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegCurvetoCubicAbs(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2);\n } case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL: {\n const points = {x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, points.x, points.y, points.x2, points.y2);\n } case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: {\n const points = {x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, points.x, points.y, points.x2, points.y2);\n } case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL: {\n const points = {x1: this._parseNumber(), y1: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegCurvetoQuadraticRel(owningPathSegList, points.x, points.y, points.x1, points.y1);\n } case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS: {\n const points = {x1: this._parseNumber(), y1: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegCurvetoQuadraticAbs(owningPathSegList, points.x, points.y, points.x1, points.y1);\n } case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:\n return new SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, this._parseNumber(), this._parseNumber());\n case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:\n return new SVGPathSegCurvetoQuadraticSmoothAbs(owningPathSegList, this._parseNumber(), this._parseNumber());\n case SVGPathSeg.PATHSEG_ARC_REL: {\n const points = {x1: this._parseNumber(), y1: this._parseNumber(), arcAngle: this._parseNumber(), arcLarge: this._parseArcFlag(), arcSweep: this._parseArcFlag(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegArcRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.arcAngle, points.arcLarge, points.arcSweep);\n } case SVGPathSeg.PATHSEG_ARC_ABS: {\n const points = {x1: this._parseNumber(), y1: this._parseNumber(), arcAngle: this._parseNumber(), arcLarge: this._parseArcFlag(), arcSweep: this._parseArcFlag(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegArcAbs(owningPathSegList, points.x, points.y, points.x1, points.y1, points.arcAngle, points.arcLarge, points.arcSweep);\n } default:\n throw new Error('Unknown path seg type.');\n }\n }\n }\n\n const builder = new Builder();\n const source = new Source(string);\n\n if (!source.initialCommandIsMoveTo()) {\n return [];\n }\n while (source.hasMoreData()) {\n const pathSeg = source.parseSegment();\n if (!pathSeg) {\n return [];\n }\n builder.appendSegment(pathSeg);\n }\n\n return builder.pathSegList;\n }\n\n // STATIC\n static _pathSegArrayAsString (pathSegArray) {\n let string = '';\n let first = true;\n pathSegArray.forEach((pathSeg) => {\n if (first) {\n first = false;\n string += pathSeg._asPathString();\n } else {\n string += ' ' + pathSeg._asPathString();\n }\n });\n return string;\n }\n }\n\n SVGPathSegList.prototype.classname = 'SVGPathSegList';\n\n Object.defineProperty(SVGPathSegList.prototype, 'numberOfItems', {\n get () {\n this._checkPathSynchronizedToList();\n return this._list.length;\n },\n enumerable: true\n });\n\n // Add the pathSegList accessors to SVGPathElement.\n // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData\n Object.defineProperties(SVGPathElement.prototype, {\n pathSegList: {\n get () {\n if (!this._pathSegList) {\n this._pathSegList = new SVGPathSegList(this);\n }\n return this._pathSegList;\n },\n enumerable: true\n },\n // TODO: The following are not implemented and simply return SVGPathElement.pathSegList.\n normalizedPathSegList: {get () { return this.pathSegList; }, enumerable: true},\n animatedPathSegList: {get () { return this.pathSegList; }, enumerable: true},\n animatedNormalizedPathSegList: {get () { return this.pathSegList; }, enumerable: true}\n });\n window.SVGPathSegList = SVGPathSegList;\n}\n})();\n","/* globals jQuery */\n/**\n * Browser detection.\n * @module browser\n * @license MIT\n *\n * @copyright 2010 Jeff Schiller, 2010 Alexis Deveria\n */\n\n// Dependencies:\n// 1) jQuery (for $.alert())\n\nimport './svgpathseg.js';\nimport {NS} from './namespaces.js';\n\nconst $ = jQuery;\n\nconst supportsSVG_ = (function () {\nreturn Boolean(document.createElementNS && document.createElementNS(NS.SVG, 'svg').createSVGRect);\n}());\n\n/**\n * @function module:browser.supportsSvg\n * @returns {boolean}\n*/\nexport const supportsSvg = () => supportsSVG_;\n\nconst {userAgent} = navigator;\nconst svg = document.createElementNS(NS.SVG, 'svg');\n\n// Note: Browser sniffing should only be used if no other detection method is possible\nconst isOpera_ = Boolean(window.opera);\nconst isWebkit_ = userAgent.includes('AppleWebKit');\nconst isGecko_ = userAgent.includes('Gecko/');\nconst isIE_ = userAgent.includes('MSIE');\nconst isChrome_ = userAgent.includes('Chrome/');\nconst isWindows_ = userAgent.includes('Windows');\nconst isMac_ = userAgent.includes('Macintosh');\nconst isTouch_ = 'ontouchstart' in window;\n\nconst supportsSelectors_ = (function () {\nreturn Boolean(svg.querySelector);\n}());\n\nconst supportsXpath_ = (function () {\nreturn Boolean(document.evaluate);\n}());\n\n// segList functions (for FF1.5 and 2.0)\nconst supportsPathReplaceItem_ = (function () {\nconst path = document.createElementNS(NS.SVG, 'path');\npath.setAttribute('d', 'M0,0 10,10');\nconst seglist = path.pathSegList;\nconst seg = path.createSVGPathSegLinetoAbs(5, 5);\ntry {\n seglist.replaceItem(seg, 1);\n return true;\n} catch (err) {}\nreturn false;\n}());\n\nconst supportsPathInsertItemBefore_ = (function () {\nconst path = document.createElementNS(NS.SVG, 'path');\npath.setAttribute('d', 'M0,0 10,10');\nconst seglist = path.pathSegList;\nconst seg = path.createSVGPathSegLinetoAbs(5, 5);\ntry {\n seglist.insertItemBefore(seg, 1);\n return true;\n} catch (err) {}\nreturn false;\n}());\n\n// text character positioning (for IE9 and now Chrome)\nconst supportsGoodTextCharPos_ = (function () {\nconst svgroot = document.createElementNS(NS.SVG, 'svg');\nconst svgcontent = document.createElementNS(NS.SVG, 'svg');\ndocument.documentElement.append(svgroot);\nsvgcontent.setAttribute('x', 5);\nsvgroot.append(svgcontent);\nconst text = document.createElementNS(NS.SVG, 'text');\ntext.textContent = 'a';\nsvgcontent.append(text);\ntry { // Chrome now fails here\n const pos = text.getStartPositionOfChar(0).x;\n return (pos === 0);\n} catch (err) {\n return false;\n} finally {\n svgroot.remove();\n}\n}());\n\nconst supportsPathBBox_ = (function () {\nconst svgcontent = document.createElementNS(NS.SVG, 'svg');\ndocument.documentElement.append(svgcontent);\nconst path = document.createElementNS(NS.SVG, 'path');\npath.setAttribute('d', 'M0,0 C0,0 10,10 10,0');\nsvgcontent.append(path);\nconst bbox = path.getBBox();\nsvgcontent.remove();\nreturn (bbox.height > 4 && bbox.height < 5);\n}());\n\n// Support for correct bbox sizing on groups with horizontal/vertical lines\nconst supportsHVLineContainerBBox_ = (function () {\nconst svgcontent = document.createElementNS(NS.SVG, 'svg');\ndocument.documentElement.append(svgcontent);\nconst path = document.createElementNS(NS.SVG, 'path');\npath.setAttribute('d', 'M0,0 10,0');\nconst path2 = document.createElementNS(NS.SVG, 'path');\npath2.setAttribute('d', 'M5,0 15,0');\nconst g = document.createElementNS(NS.SVG, 'g');\ng.append(path, path2);\nsvgcontent.append(g);\nconst bbox = g.getBBox();\nsvgcontent.remove();\n// Webkit gives 0, FF gives 10, Opera (correctly) gives 15\nreturn (bbox.width === 15);\n}());\n\nconst supportsEditableText_ = (function () {\n// TODO: Find better way to check support for this\nreturn isOpera_;\n}());\n\nconst supportsGoodDecimals_ = (function () {\n// Correct decimals on clone attributes (Opera < 10.5/win/non-en)\nconst rect = document.createElementNS(NS.SVG, 'rect');\nrect.setAttribute('x', 0.1);\nconst crect = rect.cloneNode(false);\nconst retValue = (!crect.getAttribute('x').includes(','));\nif (!retValue) {\n // Todo: i18nize or remove\n $.alert(\n 'NOTE: This version of Opera is known to contain bugs in SVG-edit.\\n' +\n 'Please upgrade to the latest version in which the problems have been fixed.'\n );\n}\nreturn retValue;\n}());\n\nconst supportsNonScalingStroke_ = (function () {\nconst rect = document.createElementNS(NS.SVG, 'rect');\nrect.setAttribute('style', 'vector-effect:non-scaling-stroke');\nreturn rect.style.vectorEffect === 'non-scaling-stroke';\n}());\n\nlet supportsNativeSVGTransformLists_ = (function () {\nconst rect = document.createElementNS(NS.SVG, 'rect');\nconst rxform = rect.transform.baseVal;\nconst t1 = svg.createSVGTransform();\nrxform.appendItem(t1);\nconst r1 = rxform.getItem(0);\nconst isSVGTransform = (o) => {\n // https://developer.mozilla.org/en-US/docs/Web/API/SVGTransform\n return o && typeof o === 'object' && typeof o.setMatrix === 'function' && 'angle' in o;\n};\nreturn isSVGTransform(r1) && isSVGTransform(t1) &&\n r1.type === t1.type && r1.angle === t1.angle &&\n r1.matrix.a === t1.matrix.a &&\n r1.matrix.b === t1.matrix.b &&\n r1.matrix.c === t1.matrix.c &&\n r1.matrix.d === t1.matrix.d &&\n r1.matrix.e === t1.matrix.e &&\n r1.matrix.f === t1.matrix.f;\n}());\n\n// Public API\n\n/**\n * @function module:browser.isOpera\n * @returns {boolean}\n*/\nexport const isOpera = () => isOpera_;\n/**\n * @function module:browser.isWebkit\n * @returns {boolean}\n*/\nexport const isWebkit = () => isWebkit_;\n/**\n * @function module:browser.isGecko\n * @returns {boolean}\n*/\nexport const isGecko = () => isGecko_;\n/**\n * @function module:browser.isIE\n * @returns {boolean}\n*/\nexport const isIE = () => isIE_;\n/**\n * @function module:browser.isChrome\n * @returns {boolean}\n*/\nexport const isChrome = () => isChrome_;\n/**\n * @function module:browser.isWindows\n * @returns {boolean}\n*/\nexport const isWindows = () => isWindows_;\n/**\n * @function module:browser.isMac\n * @returns {boolean}\n*/\nexport const isMac = () => isMac_;\n/**\n * @function module:browser.isTouch\n * @returns {boolean}\n*/\nexport const isTouch = () => isTouch_;\n\n/**\n * @function module:browser.supportsSelectors\n * @returns {boolean}\n*/\nexport const supportsSelectors = () => supportsSelectors_;\n\n/**\n * @function module:browser.supportsXpath\n * @returns {boolean}\n*/\nexport const supportsXpath = () => supportsXpath_;\n\n/**\n * @function module:browser.supportsPathReplaceItem\n * @returns {boolean}\n*/\nexport const supportsPathReplaceItem = () => supportsPathReplaceItem_;\n\n/**\n * @function module:browser.supportsPathInsertItemBefore\n * @returns {boolean}\n*/\nexport const supportsPathInsertItemBefore = () => supportsPathInsertItemBefore_;\n\n/**\n * @function module:browser.supportsPathBBox\n * @returns {boolean}\n*/\nexport const supportsPathBBox = () => supportsPathBBox_;\n\n/**\n * @function module:browser.supportsHVLineContainerBBox\n * @returns {boolean}\n*/\nexport const supportsHVLineContainerBBox = () => supportsHVLineContainerBBox_;\n\n/**\n * @function module:browser.supportsGoodTextCharPos\n * @returns {boolean}\n*/\nexport const supportsGoodTextCharPos = () => supportsGoodTextCharPos_;\n\n/**\n* @function module:browser.supportsEditableText\n * @returns {boolean}\n*/\nexport const supportsEditableText = () => supportsEditableText_;\n\n/**\n * @function module:browser.supportsGoodDecimals\n * @returns {boolean}\n*/\nexport const supportsGoodDecimals = () => supportsGoodDecimals_;\n\n/**\n* @function module:browser.supportsNonScalingStroke\n* @returns {boolean}\n*/\nexport const supportsNonScalingStroke = () => supportsNonScalingStroke_;\n\n/**\n* @function module:browser.supportsNativeTransformLists\n* @returns {boolean}\n*/\nexport const supportsNativeTransformLists = () => supportsNativeSVGTransformLists_;\n\n/**\n * Set `supportsNativeSVGTransformLists_` to `false` (for unit testing).\n * @function module:browser.disableSupportsNativeTransformLists\n * @returns {void}\n*/\nexport const disableSupportsNativeTransformLists = () => {\n supportsNativeSVGTransformLists_ = false;\n};\n","/**\n * A jQuery module to work with SVG attributes.\n * @module jQueryAttr\n * @license MIT\n */\n\n/**\n* This fixes `$(...).attr()` to work as expected with SVG elements.\n* Does not currently use `*AttributeNS()` since we rarely need that.\n* Adds {@link external:jQuery.fn.attr}.\n* See {@link https://api.jquery.com/attr/} for basic documentation of `.attr()`.\n*\n* Additional functionality:\n* - When getting attributes, a string that's a number is returned as type number.\n* - If an array is supplied as the first parameter, multiple values are returned\n* as an object with values for each given attribute.\n* @function module:jQueryAttr.jQueryAttr\n* @param {external:jQuery} $ The jQuery object to which to add the plug-in\n* @returns {external:jQuery}\n*/\nexport default function jQueryPluginSVG ($) {\n const proxied = $.fn.attr,\n svgns = 'http://www.w3.org/2000/svg';\n /**\n * @typedef {PlainObject} module:jQueryAttr.Attributes\n */\n /**\n * @function external:jQuery.fn.attr\n * @param {string|string[]|PlainObject} key\n * @param {string} value\n * @returns {external:jQuery|module:jQueryAttr.Attributes}\n */\n $.fn.attr = function (key, value) {\n const len = this.length;\n if (!len) { return proxied.call(this, key, value); }\n for (let i = 0; i < len; ++i) {\n const elem = this[i];\n // set/get SVG attribute\n if (elem.namespaceURI === svgns) {\n // Setting attribute\n if (value !== undefined) {\n elem.setAttribute(key, value);\n } else if (Array.isArray(key)) {\n // Getting attributes from array\n const obj = {};\n let j = key.length;\n\n while (j--) {\n const aname = key[j];\n let attr = elem.getAttribute(aname);\n // This returns a number when appropriate\n if (attr || attr === '0') {\n attr = isNaN(attr) ? attr : (attr - 0);\n }\n obj[aname] = attr;\n }\n return obj;\n }\n if (typeof key === 'object') {\n // Setting attributes from object\n for (const [name, val] of Object.entries(key)) {\n elem.setAttribute(name, val);\n }\n // Getting attribute\n } else {\n let attr = elem.getAttribute(key);\n if (attr || attr === '0') {\n attr = isNaN(attr) ? attr : (attr - 0);\n }\n return attr;\n }\n } else {\n return proxied.call(this, key, value);\n }\n }\n return this;\n };\n return $;\n}\n","/**\n * Partial polyfill of `SVGTransformList`\n * @module SVGTransformList\n *\n * @license MIT\n *\n * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller\n */\n\nimport {NS} from './namespaces.js';\nimport {supportsNativeTransformLists} from './browser.js';\n\nconst svgroot = document.createElementNS(NS.SVG, 'svg');\n\n/**\n * Helper function to convert `SVGTransform` to a string.\n * @param {SVGTransform} xform\n * @returns {string}\n */\nfunction transformToString (xform) {\n const m = xform.matrix;\n let text = '';\n switch (xform.type) {\n case 1: // MATRIX\n text = 'matrix(' + [m.a, m.b, m.c, m.d, m.e, m.f].join(',') + ')';\n break;\n case 2: // TRANSLATE\n text = 'translate(' + m.e + ',' + m.f + ')';\n break;\n case 3: // SCALE\n if (m.a === m.d) {\n text = 'scale(' + m.a + ')';\n } else {\n text = 'scale(' + m.a + ',' + m.d + ')';\n }\n break;\n case 4: { // ROTATE\n let cx = 0;\n let cy = 0;\n // this prevents divide by zero\n if (xform.angle !== 0) {\n const K = 1 - m.a;\n cy = (K * m.f + m.b * m.e) / (K * K + m.b * m.b);\n cx = (m.e - m.b * cy) / K;\n }\n text = 'rotate(' + xform.angle + ' ' + cx + ',' + cy + ')';\n break;\n }\n }\n return text;\n}\n\n/**\n * Map of SVGTransformList objects.\n */\nlet listMap_ = {};\n\n/**\n* @interface module:SVGTransformList.SVGEditTransformList\n* @property {Integer} numberOfItems unsigned long\n*/\n/**\n* @function module:SVGTransformList.SVGEditTransformList#clear\n* @returns {void}\n*/\n/**\n* @function module:SVGTransformList.SVGEditTransformList#initialize\n* @param {SVGTransform} newItem\n* @returns {SVGTransform}\n*/\n/**\n* DOES NOT THROW DOMException, INDEX_SIZE_ERR.\n* @function module:SVGTransformList.SVGEditTransformList#getItem\n* @param {Integer} index unsigned long\n* @returns {SVGTransform}\n*/\n/**\n* DOES NOT THROW DOMException, INDEX_SIZE_ERR.\n* @function module:SVGTransformList.SVGEditTransformList#insertItemBefore\n* @param {SVGTransform} newItem\n* @param {Integer} index unsigned long\n* @returns {SVGTransform}\n*/\n/**\n* DOES NOT THROW DOMException, INDEX_SIZE_ERR.\n* @function module:SVGTransformList.SVGEditTransformList#replaceItem\n* @param {SVGTransform} newItem\n* @param {Integer} index unsigned long\n* @returns {SVGTransform}\n*/\n/**\n* DOES NOT THROW DOMException, INDEX_SIZE_ERR.\n* @function module:SVGTransformList.SVGEditTransformList#removeItem\n* @param {Integer} index unsigned long\n* @returns {SVGTransform}\n*/\n/**\n* @function module:SVGTransformList.SVGEditTransformList#appendItem\n* @param {SVGTransform} newItem\n* @returns {SVGTransform}\n*/\n/**\n* NOT IMPLEMENTED.\n* @ignore\n* @function module:SVGTransformList.SVGEditTransformList#createSVGTransformFromMatrix\n* @param {SVGMatrix} matrix\n* @returns {SVGTransform}\n*/\n/**\n* NOT IMPLEMENTED.\n* @ignore\n* @function module:SVGTransformList.SVGEditTransformList#consolidate\n* @returns {SVGTransform}\n*/\n\n/**\n* SVGTransformList implementation for Webkit.\n* These methods do not currently raise any exceptions.\n* These methods also do not check that transforms are being inserted. This is basically\n* implementing as much of SVGTransformList that we need to get the job done.\n* @implements {module:SVGTransformList.SVGEditTransformList}\n*/\nexport class SVGTransformList { // eslint-disable-line no-shadow\n /**\n * @param {Element} elem\n * @returns {SVGTransformList}\n */\n constructor (elem) {\n this._elem = elem || null;\n this._xforms = [];\n // TODO: how do we capture the undo-ability in the changed transform list?\n this._update = function () {\n let tstr = '';\n // /* const concatMatrix = */ svgroot.createSVGMatrix();\n for (let i = 0; i < this.numberOfItems; ++i) {\n const xform = this._list.getItem(i);\n tstr += transformToString(xform) + ' ';\n }\n this._elem.setAttribute('transform', tstr);\n };\n this._list = this;\n this._init = function () {\n // Transform attribute parser\n let str = this._elem.getAttribute('transform');\n if (!str) { return; }\n\n // TODO: Add skew support in future\n const re = /\\s*((scale|matrix|rotate|translate)\\s*\\(.*?\\))\\s*,?\\s*/;\n // const re = /\\s*(?(?:scale|matrix|rotate|translate)\\s*\\(.*?\\))\\s*,?\\s*/;\n let m = true;\n while (m) {\n m = str.match(re);\n str = str.replace(re, '');\n if (m && m[1]) {\n const x = m[1];\n const bits = x.split(/\\s*\\(/);\n const name = bits[0];\n const valBits = bits[1].match(/\\s*(.*?)\\s*\\)/);\n valBits[1] = valBits[1].replace(/(\\d)-/g, '$1 -');\n const valArr = valBits[1].split(/[, ]+/);\n const letters = 'abcdef'.split('');\n /*\n if (m && m.groups.xform) {\n const x = m.groups.xform;\n const [name, bits] = x.split(/\\s*\\(/);\n const valBits = bits.match(/\\s*(?.*?)\\s*\\)/);\n valBits.groups.nonWhitespace = valBits.groups.nonWhitespace.replace(\n /(?\\d)-/g, '$ -'\n );\n const valArr = valBits.groups.nonWhitespace.split(/[, ]+/);\n const letters = [...'abcdef'];\n */\n const mtx = svgroot.createSVGMatrix();\n Object.values(valArr).forEach(function (item, i) {\n valArr[i] = Number.parseFloat(item);\n if (name === 'matrix') {\n mtx[letters[i]] = valArr[i];\n }\n });\n const xform = svgroot.createSVGTransform();\n const fname = 'set' + name.charAt(0).toUpperCase() + name.slice(1);\n const values = name === 'matrix' ? [mtx] : valArr;\n\n if (name === 'scale' && values.length === 1) {\n values.push(values[0]);\n } else if (name === 'translate' && values.length === 1) {\n values.push(0);\n } else if (name === 'rotate' && values.length === 1) {\n values.push(0, 0);\n }\n xform[fname](...values);\n this._list.appendItem(xform);\n }\n }\n };\n this._removeFromOtherLists = function (item) {\n if (item) {\n // Check if this transform is already in a transformlist, and\n // remove it if so.\n Object.values(listMap_).some((tl) => {\n for (let i = 0, len = tl._xforms.length; i < len; ++i) {\n if (tl._xforms[i] === item) {\n tl.removeItem(i);\n return true;\n }\n }\n return false;\n });\n }\n };\n\n this.numberOfItems = 0;\n }\n /**\n * @returns {void}\n */\n clear () {\n this.numberOfItems = 0;\n this._xforms = [];\n }\n\n /**\n * @param {SVGTransform} newItem\n * @returns {void}\n */\n initialize (newItem) {\n this.numberOfItems = 1;\n this._removeFromOtherLists(newItem);\n this._xforms = [newItem];\n }\n\n /**\n * @param {Integer} index unsigned long\n * @throws {Error}\n * @returns {SVGTransform}\n */\n getItem (index) {\n if (index < this.numberOfItems && index >= 0) {\n return this._xforms[index];\n }\n const err = new Error('DOMException with code=INDEX_SIZE_ERR');\n err.code = 1;\n throw err;\n }\n\n /**\n * @param {SVGTransform} newItem\n * @param {Integer} index unsigned long\n * @returns {SVGTransform}\n */\n insertItemBefore (newItem, index) {\n let retValue = null;\n if (index >= 0) {\n if (index < this.numberOfItems) {\n this._removeFromOtherLists(newItem);\n const newxforms = new Array(this.numberOfItems + 1);\n // TODO: use array copying and slicing\n let i;\n for (i = 0; i < index; ++i) {\n newxforms[i] = this._xforms[i];\n }\n newxforms[i] = newItem;\n for (let j = i + 1; i < this.numberOfItems; ++j, ++i) {\n newxforms[j] = this._xforms[i];\n }\n this.numberOfItems++;\n this._xforms = newxforms;\n retValue = newItem;\n this._list._update();\n } else {\n retValue = this._list.appendItem(newItem);\n }\n }\n return retValue;\n }\n\n /**\n * @param {SVGTransform} newItem\n * @param {Integer} index unsigned long\n * @returns {SVGTransform}\n */\n replaceItem (newItem, index) {\n let retValue = null;\n if (index < this.numberOfItems && index >= 0) {\n this._removeFromOtherLists(newItem);\n this._xforms[index] = newItem;\n retValue = newItem;\n this._list._update();\n }\n return retValue;\n }\n\n /**\n * @param {Integer} index unsigned long\n * @throws {Error}\n * @returns {SVGTransform}\n */\n removeItem (index) {\n if (index < this.numberOfItems && index >= 0) {\n const retValue = this._xforms[index];\n const newxforms = new Array(this.numberOfItems - 1);\n let i;\n for (i = 0; i < index; ++i) {\n newxforms[i] = this._xforms[i];\n }\n for (let j = i; j < this.numberOfItems - 1; ++j, ++i) {\n newxforms[j] = this._xforms[i + 1];\n }\n this.numberOfItems--;\n this._xforms = newxforms;\n this._list._update();\n return retValue;\n }\n const err = new Error('DOMException with code=INDEX_SIZE_ERR');\n err.code = 1;\n throw err;\n }\n\n /**\n * @param {SVGTransform} newItem\n * @returns {SVGTransform}\n */\n appendItem (newItem) {\n this._removeFromOtherLists(newItem);\n this._xforms.push(newItem);\n this.numberOfItems++;\n this._list._update();\n return newItem;\n }\n}\n\n/**\n* @function module:SVGTransformList.resetListMap\n* @returns {void}\n*/\nexport const resetListMap = function () {\n listMap_ = {};\n};\n\n/**\n * Removes transforms of the given element from the map.\n * @function module:SVGTransformList.removeElementFromListMap\n * @param {Element} elem - a DOM Element\n * @returns {void}\n */\nexport let removeElementFromListMap = function (elem) { // eslint-disable-line import/no-mutable-exports\n if (elem.id && listMap_[elem.id]) {\n delete listMap_[elem.id];\n }\n};\n\n/**\n* Returns an object that behaves like a `SVGTransformList` for the given DOM element.\n* @function module:SVGTransformList.getTransformList\n* @param {Element} elem - DOM element to get a transformlist from\n* @todo The polyfill should have `SVGAnimatedTransformList` and this should use it\n* @returns {SVGAnimatedTransformList|SVGTransformList}\n*/\nexport const getTransformList = function (elem) {\n if (!supportsNativeTransformLists()) {\n const id = elem.id || 'temp';\n let t = listMap_[id];\n if (!t || id === 'temp') {\n listMap_[id] = new SVGTransformList(elem);\n listMap_[id]._init();\n t = listMap_[id];\n }\n return t;\n }\n if (elem.transform) {\n return elem.transform.baseVal;\n }\n if (elem.gradientTransform) {\n return elem.gradientTransform.baseVal;\n }\n if (elem.patternTransform) {\n return elem.patternTransform.baseVal;\n }\n\n return null;\n};\n\n/**\n* @callback module:SVGTransformList.removeElementFromListMap\n* @param {Element} elem\n* @returns {void}\n*/\n/**\n* Replace `removeElementFromListMap` for unit-testing.\n* @function module:SVGTransformList.changeRemoveElementFromListMap\n* @param {module:SVGTransformList.removeElementFromListMap} cb Passed a single argument `elem`\n* @returns {void}\n*/\n\nexport const changeRemoveElementFromListMap = function (cb) { // eslint-disable-line promise/prefer-await-to-callbacks\n removeElementFromListMap = cb;\n};\n","/**\n * Tools for working with units.\n * @module units\n * @license MIT\n *\n * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller\n */\n\nimport {NS} from './namespaces.js';\n\nconst wAttrs = ['x', 'x1', 'cx', 'rx', 'width'];\nconst hAttrs = ['y', 'y1', 'cy', 'ry', 'height'];\nconst unitAttrs = ['r', 'radius', ...wAttrs, ...hAttrs];\n// unused\n/*\nconst unitNumMap = {\n '%': 2,\n em: 3,\n ex: 4,\n px: 5,\n cm: 6,\n mm: 7,\n in: 8,\n pt: 9,\n pc: 10\n};\n*/\n// Container of elements.\nlet elementContainer_;\n\n// Stores mapping of unit type to user coordinates.\nlet typeMap_ = {};\n\n/**\n * @interface module:units.ElementContainer\n */\n/**\n * @function module:units.ElementContainer#getBaseUnit\n * @returns {string} The base unit type of the container ('em')\n */\n/**\n * @function module:units.ElementContainer#getElement\n * @returns {?Element} An element in the container given an id\n */\n/**\n * @function module:units.ElementContainer#getHeight\n * @returns {Float} The container's height\n */\n/**\n * @function module:units.ElementContainer#getWidth\n * @returns {Float} The container's width\n */\n/**\n * @function module:units.ElementContainer#getRoundDigits\n * @returns {Integer} The number of digits number should be rounded to\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef {PlainObject} module:units.TypeMap\n * @property {Float} em\n * @property {Float} ex\n * @property {Float} in\n * @property {Float} cm\n * @property {Float} mm\n * @property {Float} pt\n * @property {Float} pc\n * @property {Integer} px\n * @property {0} %\n */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * Initializes this module.\n *\n * @function module:units.init\n * @param {module:units.ElementContainer} elementContainer - An object implementing the ElementContainer interface.\n * @returns {void}\n */\nexport const init = function (elementContainer) {\n elementContainer_ = elementContainer;\n\n // Get correct em/ex values by creating a temporary SVG.\n const svg = document.createElementNS(NS.SVG, 'svg');\n document.body.append(svg);\n const rect = document.createElementNS(NS.SVG, 'rect');\n rect.setAttribute('width', '1em');\n rect.setAttribute('height', '1ex');\n rect.setAttribute('x', '1in');\n svg.append(rect);\n const bb = rect.getBBox();\n svg.remove();\n\n const inch = bb.x;\n typeMap_ = {\n em: bb.width,\n ex: bb.height,\n in: inch,\n cm: inch / 2.54,\n mm: inch / 25.4,\n pt: inch / 72,\n pc: inch / 6,\n px: 1,\n '%': 0\n };\n};\n\n/**\n* Group: Unit conversion functions.\n*/\n\n/**\n * @function module:units.getTypeMap\n * @returns {module:units.TypeMap} The unit object with values for each unit\n*/\nexport const getTypeMap = function () {\n return typeMap_;\n};\n\n/**\n* @typedef {GenericArray} module:units.CompareNumbers\n* @property {Integer} length 2\n* @property {Float} 0\n* @property {Float} 1\n*/\n\n/**\n* Rounds a given value to a float with number of digits defined in\n* `round_digits` of `saveOptions`\n*\n* @function module:units.shortFloat\n* @param {string|Float|module:units.CompareNumbers} val - The value (or Array of two numbers) to be rounded\n* @returns {Float|string} If a string/number was given, returns a Float. If an array, return a string\n* with comma-separated floats\n*/\nexport const shortFloat = function (val) {\n const digits = elementContainer_.getRoundDigits();\n if (!isNaN(val)) {\n return Number(Number(val).toFixed(digits));\n }\n if (Array.isArray(val)) {\n return shortFloat(val[0]) + ',' + shortFloat(val[1]);\n }\n return Number.parseFloat(val).toFixed(digits) - 0;\n};\n\n/**\n* Converts the number to given unit or baseUnit.\n* @function module:units.convertUnit\n* @param {string|Float} val\n* @param {\"em\"|\"ex\"|\"in\"|\"cm\"|\"mm\"|\"pt\"|\"pc\"|\"px\"|\"%\"} [unit]\n* @returns {Float}\n*/\nexport const convertUnit = function (val, unit) {\n unit = unit || elementContainer_.getBaseUnit();\n // baseVal.convertToSpecifiedUnits(unitNumMap[unit]);\n // const val = baseVal.valueInSpecifiedUnits;\n // baseVal.convertToSpecifiedUnits(1);\n return shortFloat(val / typeMap_[unit]);\n};\n\n/**\n* Sets an element's attribute based on the unit in its current value.\n*\n* @function module:units.setUnitAttr\n* @param {Element} elem - DOM element to be changed\n* @param {string} attr - Name of the attribute associated with the value\n* @param {string} val - Attribute value to convert\n* @returns {void}\n*/\nexport const setUnitAttr = function (elem, attr, val) {\n // if (!isNaN(val)) {\n // New value is a number, so check currently used unit\n // const oldVal = elem.getAttribute(attr);\n\n // Enable this for alternate mode\n // if (oldVal !== null && (isNaN(oldVal) || elementContainer_.getBaseUnit() !== 'px')) {\n // // Old value was a number, so get unit, then convert\n // let unit;\n // if (oldVal.substr(-1) === '%') {\n // const res = getResolution();\n // unit = '%';\n // val *= 100;\n // if (wAttrs.includes(attr)) {\n // val = val / res.w;\n // } else if (hAttrs.includes(attr)) {\n // val = val / res.h;\n // } else {\n // return val / Math.sqrt((res.w*res.w) + (res.h*res.h))/Math.sqrt(2);\n // }\n // } else {\n // if (elementContainer_.getBaseUnit() !== 'px') {\n // unit = elementContainer_.getBaseUnit();\n // } else {\n // unit = oldVal.substr(-2);\n // }\n // val = val / typeMap_[unit];\n // }\n //\n // val += unit;\n // }\n // }\n elem.setAttribute(attr, val);\n};\n\nconst attrsToConvert = {\n line: ['x1', 'x2', 'y1', 'y2'],\n circle: ['cx', 'cy', 'r'],\n ellipse: ['cx', 'cy', 'rx', 'ry'],\n foreignObject: ['x', 'y', 'width', 'height'],\n rect: ['x', 'y', 'width', 'height'],\n image: ['x', 'y', 'width', 'height'],\n use: ['x', 'y', 'width', 'height'],\n text: ['x', 'y']\n};\n\n/**\n* Converts all applicable attributes to the configured baseUnit.\n* @function module:units.convertAttrs\n* @param {Element} element - A DOM element whose attributes should be converted\n* @returns {void}\n*/\nexport const convertAttrs = function (element) {\n const elName = element.tagName;\n const unit = elementContainer_.getBaseUnit();\n const attrs = attrsToConvert[elName];\n if (!attrs) { return; }\n\n const len = attrs.length;\n for (let i = 0; i < len; i++) {\n const attr = attrs[i];\n const cur = element.getAttribute(attr);\n if (cur) {\n if (!isNaN(cur)) {\n element.setAttribute(attr, (cur / typeMap_[unit]) + unit);\n }\n // else {\n // Convert existing?\n // }\n }\n }\n};\n\n/**\n* Converts given values to numbers. Attributes must be supplied in\n* case a percentage is given.\n*\n* @function module:units.convertToNum\n* @param {string} attr - Name of the attribute associated with the value\n* @param {string} val - Attribute value to convert\n* @returns {Float} The converted number\n*/\nexport const convertToNum = function (attr, val) {\n // Return a number if that's what it already is\n if (!isNaN(val)) { return val - 0; }\n if (val.substr(-1) === '%') {\n // Deal with percentage, depends on attribute\n const num = val.substr(0, val.length - 1) / 100;\n const width = elementContainer_.getWidth();\n const height = elementContainer_.getHeight();\n\n if (wAttrs.includes(attr)) {\n return num * width;\n }\n if (hAttrs.includes(attr)) {\n return num * height;\n }\n return num * Math.sqrt((width * width) + (height * height)) / Math.sqrt(2);\n }\n const unit = val.substr(-2);\n const num = val.substr(0, val.length - 2);\n // Note that this multiplication turns the string into a number\n return num * typeMap_[unit];\n};\n\n/**\n* Check if an attribute's value is in a valid format.\n* @function module:units.isValidUnit\n* @param {string} attr - The name of the attribute associated with the value\n* @param {string} val - The attribute value to check\n* @param {Element} selectedElement\n* @returns {boolean} Whether the unit is valid\n*/\nexport const isValidUnit = function (attr, val, selectedElement) {\n if (unitAttrs.includes(attr)) {\n // True if it's just a number\n if (!isNaN(val)) {\n return true;\n }\n // Not a number, check if it has a valid unit\n val = val.toLowerCase();\n return Object.keys(typeMap_).some((unit) => {\n const re = new RegExp('^-?[\\\\d\\\\.]+' + unit + '$');\n return re.test(val);\n });\n }\n if (attr === 'id') {\n // if we're trying to change the id, make sure it's not already present in the doc\n // and the id value is valid.\n\n let result = false;\n // because getElem() can throw an exception in the case of an invalid id\n // (according to https://www.w3.org/TR/xml-id/ IDs must be a NCName)\n // we wrap it in an exception and only return true if the ID was valid and\n // not already present\n try {\n const elem = elementContainer_.getElement(val);\n result = (!elem || elem === selectedElement);\n } catch (e) {}\n return result;\n }\n return true;\n};\n","/**\n * Mathematical utilities.\n * @module math\n * @license MIT\n *\n * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller\n */\n\n/**\n* @typedef {PlainObject} module:math.AngleCoord45\n* @property {Float} x - The angle-snapped x value\n* @property {Float} y - The angle-snapped y value\n* @property {Integer} a - The angle at which to snap\n*/\n\n/**\n* @typedef {PlainObject} module:math.XYObject\n* @property {Float} x\n* @property {Float} y\n*/\n\nimport {NS} from './namespaces.js';\nimport {getTransformList} from './svgtransformlist.js';\n\n// Constants\nconst NEAR_ZERO = 1e-14;\n\n// Throw away SVGSVGElement used for creating matrices/transforms.\nconst svg = document.createElementNS(NS.SVG, 'svg');\n\n/**\n * A (hopefully) quicker function to transform a point by a matrix\n * (this function avoids any DOM calls and just does the math).\n * @function module:math.transformPoint\n * @param {Float} x - Float representing the x coordinate\n * @param {Float} y - Float representing the y coordinate\n * @param {SVGMatrix} m - Matrix object to transform the point with\n * @returns {module:math.XYObject} An x, y object representing the transformed point\n*/\nexport const transformPoint = function (x, y, m) {\n return {x: m.a * x + m.c * y + m.e, y: m.b * x + m.d * y + m.f};\n};\n\n/**\n * Helper function to check if the matrix performs no actual transform\n * (i.e. exists for identity purposes).\n * @function module:math.isIdentity\n * @param {SVGMatrix} m - The matrix object to check\n * @returns {boolean} Indicates whether or not the matrix is 1,0,0,1,0,0\n*/\nexport const isIdentity = function (m) {\n return (m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1 && m.e === 0 && m.f === 0);\n};\n\n/**\n * This function tries to return a `SVGMatrix` that is the multiplication `m1 * m2`.\n * We also round to zero when it's near zero.\n * @function module:math.matrixMultiply\n * @param {...SVGMatrix} args - Matrix objects to multiply\n * @returns {SVGMatrix} The matrix object resulting from the calculation\n*/\nexport const matrixMultiply = function (...args) {\n const m = args.reduceRight((prev, m1) => {\n return m1.multiply(prev);\n });\n\n if (Math.abs(m.a) < NEAR_ZERO) { m.a = 0; }\n if (Math.abs(m.b) < NEAR_ZERO) { m.b = 0; }\n if (Math.abs(m.c) < NEAR_ZERO) { m.c = 0; }\n if (Math.abs(m.d) < NEAR_ZERO) { m.d = 0; }\n if (Math.abs(m.e) < NEAR_ZERO) { m.e = 0; }\n if (Math.abs(m.f) < NEAR_ZERO) { m.f = 0; }\n\n return m;\n};\n\n/**\n * See if the given transformlist includes a non-indentity matrix transform.\n * @function module:math.hasMatrixTransform\n * @param {SVGTransformList} [tlist] - The transformlist to check\n * @returns {boolean} Whether or not a matrix transform was found\n*/\nexport const hasMatrixTransform = function (tlist) {\n if (!tlist) { return false; }\n let num = tlist.numberOfItems;\n while (num--) {\n const xform = tlist.getItem(num);\n if (xform.type === 1 && !isIdentity(xform.matrix)) { return true; }\n }\n return false;\n};\n\n/**\n* @typedef {PlainObject} module:math.TransformedBox An object with the following values\n* @property {module:math.XYObject} tl - The top left coordinate\n* @property {module:math.XYObject} tr - The top right coordinate\n* @property {module:math.XYObject} bl - The bottom left coordinate\n* @property {module:math.XYObject} br - The bottom right coordinate\n* @property {PlainObject} aabox - Object with the following values:\n* @property {Float} aabox.x - Float with the axis-aligned x coordinate\n* @property {Float} aabox.y - Float with the axis-aligned y coordinate\n* @property {Float} aabox.width - Float with the axis-aligned width coordinate\n* @property {Float} aabox.height - Float with the axis-aligned height coordinate\n*/\n\n/**\n * Transforms a rectangle based on the given matrix.\n * @function module:math.transformBox\n * @param {Float} l - Float with the box's left coordinate\n * @param {Float} t - Float with the box's top coordinate\n * @param {Float} w - Float with the box width\n * @param {Float} h - Float with the box height\n * @param {SVGMatrix} m - Matrix object to transform the box by\n * @returns {module:math.TransformedBox}\n*/\nexport const transformBox = function (l, t, w, h, m) {\n const tl = transformPoint(l, t, m),\n tr = transformPoint((l + w), t, m),\n bl = transformPoint(l, (t + h), m),\n br = transformPoint((l + w), (t + h), m),\n\n minx = Math.min(tl.x, tr.x, bl.x, br.x),\n maxx = Math.max(tl.x, tr.x, bl.x, br.x),\n miny = Math.min(tl.y, tr.y, bl.y, br.y),\n maxy = Math.max(tl.y, tr.y, bl.y, br.y);\n\n return {\n tl,\n tr,\n bl,\n br,\n aabox: {\n x: minx,\n y: miny,\n width: (maxx - minx),\n height: (maxy - miny)\n }\n };\n};\n\n/**\n * This returns a single matrix Transform for a given Transform List\n * (this is the equivalent of `SVGTransformList.consolidate()` but unlike\n * that method, this one does not modify the actual `SVGTransformList`).\n * This function is very liberal with its `min`, `max` arguments.\n * @function module:math.transformListToTransform\n * @param {SVGTransformList} tlist - The transformlist object\n * @param {Integer} [min=0] - Optional integer indicating start transform position\n * @param {Integer} [max] - Optional integer indicating end transform position;\n * defaults to one less than the tlist's `numberOfItems`\n * @returns {SVGTransform} A single matrix transform object\n*/\nexport const transformListToTransform = function (tlist, min, max) {\n if (!tlist) {\n // Or should tlist = null have been prevented before this?\n return svg.createSVGTransformFromMatrix(svg.createSVGMatrix());\n }\n min = min || 0;\n max = max || (tlist.numberOfItems - 1);\n min = Number.parseInt(min);\n max = Number.parseInt(max);\n if (min > max) { const temp = max; max = min; min = temp; }\n let m = svg.createSVGMatrix();\n for (let i = min; i <= max; ++i) {\n // if our indices are out of range, just use a harmless identity matrix\n const mtom = (i >= 0 && i < tlist.numberOfItems\n ? tlist.getItem(i).matrix\n : svg.createSVGMatrix());\n m = matrixMultiply(m, mtom);\n }\n return svg.createSVGTransformFromMatrix(m);\n};\n\n/**\n * Get the matrix object for a given element.\n * @function module:math.getMatrix\n * @param {Element} elem - The DOM element to check\n * @returns {SVGMatrix} The matrix object associated with the element's transformlist\n*/\nexport const getMatrix = function (elem) {\n const tlist = getTransformList(elem);\n return transformListToTransform(tlist).matrix;\n};\n\n/**\n * Returns a 45 degree angle coordinate associated with the two given\n * coordinates.\n * @function module:math.snapToAngle\n * @param {Integer} x1 - First coordinate's x value\n * @param {Integer} y1 - First coordinate's y value\n * @param {Integer} x2 - Second coordinate's x value\n * @param {Integer} y2 - Second coordinate's y value\n * @returns {module:math.AngleCoord45}\n*/\nexport const snapToAngle = function (x1, y1, x2, y2) {\n const snap = Math.PI / 4; // 45 degrees\n const dx = x2 - x1;\n const dy = y2 - y1;\n const angle = Math.atan2(dy, dx);\n const dist = Math.sqrt(dx * dx + dy * dy);\n const snapangle = Math.round(angle / snap) * snap;\n\n return {\n x: x1 + dist * Math.cos(snapangle),\n y: y1 + dist * Math.sin(snapangle),\n a: snapangle\n };\n};\n\n/**\n * Check if two rectangles (BBoxes objects) intersect each other.\n * @function module:math.rectsIntersect\n * @param {SVGRect} r1 - The first BBox-like object\n * @param {SVGRect} r2 - The second BBox-like object\n * @returns {boolean} True if rectangles intersect\n */\nexport const rectsIntersect = function (r1, r2) {\n return r2.x < (r1.x + r1.width) &&\n (r2.x + r2.width) > r1.x &&\n r2.y < (r1.y + r1.height) &&\n (r2.y + r2.height) > r1.y;\n};\n","/* globals jQuery */\n/**\n * Miscellaneous utilities.\n * @module utilities\n * @license MIT\n *\n * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller\n */\n\nimport './svgpathseg.js';\nimport jQueryPluginSVG from './jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr`\nimport {NS} from './namespaces.js';\nimport {getTransformList} from './svgtransformlist.js';\nimport {setUnitAttr, getTypeMap} from './units.js';\nimport {\n hasMatrixTransform, transformListToTransform, transformBox\n} from './math.js';\nimport {\n isWebkit, supportsHVLineContainerBBox, supportsPathBBox, supportsXpath,\n supportsSelectors\n} from './browser.js';\n\n// Constants\nconst $ = jQueryPluginSVG(jQuery);\n\n// String used to encode base64.\nconst KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n\n// Much faster than running getBBox() every time\nconst visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath';\nconst visElemsArr = visElems.split(',');\n// const hidElems = 'defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath';\n\nlet editorContext_ = null;\nlet domdoc_ = null;\nlet domcontainer_ = null;\nlet svgroot_ = null;\n\n/**\n* Object with the following keys/values.\n* @typedef {PlainObject} module:utilities.SVGElementJSON\n* @property {string} element - Tag name of the SVG element to create\n* @property {PlainObject} attr - Has key-value attributes to assign to the new element. An `id` should be set so that {@link module:utilities.EditorContext#addSVGElementFromJson} can later re-identify the element for modification or replacement.\n* @property {boolean} [curStyles=false] - Indicates whether current style attributes should be applied first\n* @property {module:utilities.SVGElementJSON[]} [children] - Data objects to be added recursively as children\n* @property {string} [namespace=\"http://www.w3.org/2000/svg\"] - Indicate a (non-SVG) namespace\n*/\n\n/**\n * An object that creates SVG elements for the canvas.\n *\n * @interface module:utilities.EditorContext\n * @property {module:path.pathActions} pathActions\n */\n/**\n * @function module:utilities.EditorContext#getSVGContent\n * @returns {SVGSVGElement}\n */\n/**\n * Create a new SVG element based on the given object keys/values and add it\n * to the current layer.\n * The element will be run through `cleanupElement` before being returned.\n * @function module:utilities.EditorContext#addSVGElementFromJson\n * @param {module:utilities.SVGElementJSON} data\n * @returns {Element} The new element\n*/\n/**\n * @function module:utilities.EditorContext#getSelectedElements\n * @returns {Element[]} the array with selected DOM elements\n*/\n/**\n * @function module:utilities.EditorContext#getDOMDocument\n * @returns {HTMLDocument}\n*/\n/**\n * @function module:utilities.EditorContext#getDOMContainer\n * @returns {HTMLElement}\n*/\n/**\n * @function module:utilities.EditorContext#getSVGRoot\n * @returns {SVGSVGElement}\n*/\n/**\n * @function module:utilities.EditorContext#getBaseUnit\n * @returns {string}\n*/\n/**\n * @function module:utilities.EditorContext#getSnappingStep\n * @returns {Float|string}\n*/\n\n/**\n* @function module:utilities.init\n* @param {module:utilities.EditorContext} editorContext\n* @returns {void}\n*/\nexport const init = function (editorContext) {\n editorContext_ = editorContext;\n domdoc_ = editorContext.getDOMDocument();\n domcontainer_ = editorContext.getDOMContainer();\n svgroot_ = editorContext.getSVGRoot();\n};\n\n/**\n * Used to prevent the [Billion laughs attack]{@link https://en.wikipedia.org/wiki/Billion_laughs_attack}.\n * @function module:utilities.dropXMLInternalSubset\n * @param {string} str String to be processed\n * @returns {string} The string with entity declarations in the internal subset removed\n * @todo This might be needed in other places `parseFromString` is used even without LGTM flagging\n */\nexport const dropXMLInternalSubset = (str) => {\n return str.replace(/()/, '$1$2');\n // return str.replace(/(?\\?\\]>)/, '$$');\n};\n\n/**\n* Converts characters in a string to XML-friendly entities.\n* @function module:utilities.toXml\n* @example `&` becomes `&`\n* @param {string} str - The string to be converted\n* @returns {string} The converted string\n*/\nexport const toXml = function (str) {\n // ' is ok in XML, but not HTML\n // > does not normally need escaping, though it can if within a CDATA expression (and preceded by \"]]\")\n return str\n .replace(/&/g, '&')\n .replace(//g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, '''); // Note: `'` is XML only\n};\n\n/**\n* Converts XML entities in a string to single characters.\n* @function module:utilities.fromXml\n* @example `&` becomes `&`\n* @param {string} str - The string to be converted\n* @returns {string} The converted string\n*/\nexport function fromXml (str) {\n return $('

').html(str).text();\n}\n\n// This code was written by Tyler Akins and has been placed in the\n// public domain. It would be nice if you left this header intact.\n// Base64 code from Tyler Akins -- http://rumkin.com\n\n// schiller: Removed string concatenation in favour of Array.join() optimization,\n// also precalculate the size of the array needed.\n\n/**\n* Converts a string to base64.\n* @function module:utilities.encode64\n* @param {string} input\n* @returns {string} Base64 output\n*/\nexport function encode64 (input) {\n // base64 strings are 4/3 larger than the original string\n input = encodeUTF8(input); // convert non-ASCII characters\n // input = convertToXMLReferences(input);\n if (window.btoa) {\n return window.btoa(input); // Use native if available\n }\n const output = new Array(Math.floor((input.length + 2) / 3) * 4);\n\n let i = 0,\n p = 0;\n do {\n const chr1 = input.charCodeAt(i++);\n const chr2 = input.charCodeAt(i++);\n const chr3 = input.charCodeAt(i++);\n\n /* eslint-disable no-bitwise */\n const enc1 = chr1 >> 2;\n const enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\n\n let enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\n let enc4 = chr3 & 63;\n /* eslint-enable no-bitwise */\n\n if (Number.isNaN(chr2)) {\n enc3 = 64;\n enc4 = 64;\n } else if (Number.isNaN(chr3)) {\n enc4 = 64;\n }\n\n output[p++] = KEYSTR.charAt(enc1);\n output[p++] = KEYSTR.charAt(enc2);\n output[p++] = KEYSTR.charAt(enc3);\n output[p++] = KEYSTR.charAt(enc4);\n } while (i < input.length);\n\n return output.join('');\n}\n\n/**\n* Converts a string from base64.\n* @function module:utilities.decode64\n* @param {string} input Base64-encoded input\n* @returns {string} Decoded output\n*/\nexport function decode64 (input) {\n if (window.atob) {\n return decodeUTF8(window.atob(input));\n }\n\n // remove all characters that are not A-Z, a-z, 0-9, +, /, or =\n input = input.replace(/[^A-Za-z\\d+/=]/g, '');\n\n let output = '';\n let i = 0;\n\n do {\n const enc1 = KEYSTR.indexOf(input.charAt(i++));\n const enc2 = KEYSTR.indexOf(input.charAt(i++));\n const enc3 = KEYSTR.indexOf(input.charAt(i++));\n const enc4 = KEYSTR.indexOf(input.charAt(i++));\n\n /* eslint-disable no-bitwise */\n const chr1 = (enc1 << 2) | (enc2 >> 4);\n const chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);\n const chr3 = ((enc3 & 3) << 6) | enc4;\n /* eslint-enable no-bitwise */\n\n output += String.fromCharCode(chr1);\n\n if (enc3 !== 64) {\n output += String.fromCharCode(chr2);\n }\n if (enc4 !== 64) {\n output += String.fromCharCode(chr3);\n }\n } while (i < input.length);\n return decodeUTF8(output);\n}\n\n/**\n* @function module:utilities.decodeUTF8\n* @param {string} argString\n* @returns {string}\n*/\nexport function decodeUTF8 (argString) {\n return decodeURIComponent(escape(argString));\n}\n\n// codedread:does not seem to work with webkit-based browsers on OSX // Brettz9: please test again as function upgraded\n/**\n* @function module:utilities.encodeUTF8\n* @param {string} argString\n* @returns {string}\n*/\nexport const encodeUTF8 = function (argString) {\n return unescape(encodeURIComponent(argString));\n};\n\n/**\n * Convert dataURL to object URL.\n * @function module:utilities.dataURLToObjectURL\n * @param {string} dataurl\n * @returns {string} object URL or empty string\n */\nexport const dataURLToObjectURL = function (dataurl) {\n if (typeof Uint8Array === 'undefined' || typeof Blob === 'undefined' || typeof URL === 'undefined' || !URL.createObjectURL) {\n return '';\n }\n const arr = dataurl.split(','),\n mime = arr[0].match(/:(.*?);/)[1],\n bstr = atob(arr[1]);\n /*\n const [prefix, suffix] = dataurl.split(','),\n {groups: {mime}} = prefix.match(/:(?.*?);/),\n bstr = atob(suffix);\n */\n let n = bstr.length;\n const u8arr = new Uint8Array(n);\n while (n--) {\n u8arr[n] = bstr.charCodeAt(n);\n }\n const blob = new Blob([u8arr], {type: mime});\n return URL.createObjectURL(blob);\n};\n\n/**\n * Get object URL for a blob object.\n * @function module:utilities.createObjectURL\n * @param {Blob} blob A Blob object or File object\n * @returns {string} object URL or empty string\n */\nexport const createObjectURL = function (blob) {\n if (!blob || typeof URL === 'undefined' || !URL.createObjectURL) {\n return '';\n }\n return URL.createObjectURL(blob);\n};\n\n/**\n * @property {string} blankPageObjectURL\n */\nexport const blankPageObjectURL = (function () {\n if (typeof Blob === 'undefined') {\n return '';\n }\n const blob = new Blob(['SVG-edit '], {type: 'text/html'});\n return createObjectURL(blob);\n})();\n\n/**\n* Converts a string to use XML references (for non-ASCII).\n* @function module:utilities.convertToXMLReferences\n* @param {string} input\n* @returns {string} Decimal numeric character references\n*/\nexport const convertToXMLReferences = function (input) {\n let output = '';\n [...input].forEach((ch) => {\n const c = ch.charCodeAt();\n if (c <= 127) {\n output += ch;\n } else {\n output += `&#${c};`;\n }\n });\n return output;\n};\n\n/**\n* Cross-browser compatible method of converting a string to an XML tree.\n* Found this function [here]{@link http://groups.google.com/group/jquery-dev/browse_thread/thread/c6d11387c580a77f}.\n* @function module:utilities.text2xml\n* @param {string} sXML\n* @throws {Error}\n* @returns {XMLDocument}\n*/\nexport const text2xml = function (sXML) {\n if (sXML.includes('`\n* - ``\n* - ``\n* @function module:utilities.getUrlFromAttr\n* @param {string} attrVal The attribute value as a string\n* @returns {string} String with just the URL, like \"someFile.svg#foo\"\n*/\nexport const getUrlFromAttr = function (attrVal) {\n if (attrVal) {\n // url('#somegrad')\n if (attrVal.startsWith('url(\"')) {\n return attrVal.substring(5, attrVal.indexOf('\"', 6));\n }\n // url('#somegrad')\n if (attrVal.startsWith(\"url('\")) {\n return attrVal.substring(5, attrVal.indexOf(\"'\", 6));\n }\n if (attrVal.startsWith('url(')) {\n return attrVal.substring(4, attrVal.indexOf(')'));\n }\n }\n return null;\n};\n\n/**\n* @function module:utilities.getHref\n* @param {Element} elem\n* @returns {string} The given element's `xlink:href` value\n*/\nexport let getHref = function (elem) { // eslint-disable-line import/no-mutable-exports\n return elem.getAttributeNS(NS.XLINK, 'href');\n};\n\n/**\n* Sets the given element's `xlink:href` value.\n* @function module:utilities.setHref\n* @param {Element} elem\n* @param {string} val\n* @returns {void}\n*/\nexport let setHref = function (elem, val) { // eslint-disable-line import/no-mutable-exports\n elem.setAttributeNS(NS.XLINK, 'xlink:href', val);\n};\n\n/**\n* @function module:utilities.findDefs\n* @returns {SVGDefsElement} The document's `` element, creating it first if necessary\n*/\nexport const findDefs = function () {\n const svgElement = editorContext_.getSVGContent();\n let defs = svgElement.getElementsByTagNameNS(NS.SVG, 'defs');\n if (defs.length > 0) {\n defs = defs[0];\n } else {\n defs = svgElement.ownerDocument.createElementNS(NS.SVG, 'defs');\n if (svgElement.firstChild) {\n // first child is a comment, so call nextSibling\n svgElement.insertBefore(defs, svgElement.firstChild.nextSibling);\n // svgElement.firstChild.nextSibling.before(defs); // Not safe\n } else {\n svgElement.append(defs);\n }\n }\n return defs;\n};\n\n// TODO(codedread): Consider moving the next to functions to bbox.js\n\n/**\n* Get correct BBox for a path in Webkit.\n* Converted from code found [here]{@link http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html}.\n* @function module:utilities.getPathBBox\n* @param {SVGPathElement} path - The path DOM element to get the BBox for\n* @returns {module:utilities.BBoxObject} A BBox-like object\n*/\nexport const getPathBBox = function (path) {\n const seglist = path.pathSegList;\n const tot = seglist.numberOfItems;\n\n const bounds = [[], []];\n const start = seglist.getItem(0);\n let P0 = [start.x, start.y];\n\n const getCalc = function (j, P1, P2, P3) {\n return function (t) {\n return 1 - t ** 3 * P0[j] +\n 3 * 1 - t ** 2 * t * P1[j] +\n 3 * (1 - t) * t ** 2 * P2[j] +\n t ** 3 * P3[j];\n };\n };\n\n for (let i = 0; i < tot; i++) {\n const seg = seglist.getItem(i);\n\n if (seg.x === undefined) { continue; }\n\n // Add actual points to limits\n bounds[0].push(P0[0]);\n bounds[1].push(P0[1]);\n\n if (seg.x1) {\n const P1 = [seg.x1, seg.y1],\n P2 = [seg.x2, seg.y2],\n P3 = [seg.x, seg.y];\n\n for (let j = 0; j < 2; j++) {\n const calc = getCalc(j, P1, P2, P3);\n\n const b = 6 * P0[j] - 12 * P1[j] + 6 * P2[j];\n const a = -3 * P0[j] + 9 * P1[j] - 9 * P2[j] + 3 * P3[j];\n const c = 3 * P1[j] - 3 * P0[j];\n\n if (a === 0) {\n if (b === 0) { continue; }\n const t = -c / b;\n if (t > 0 && t < 1) {\n bounds[j].push(calc(t));\n }\n continue;\n }\n const b2ac = b ** 2 - 4 * c * a;\n if (b2ac < 0) { continue; }\n const t1 = (-b + Math.sqrt(b2ac)) / (2 * a);\n if (t1 > 0 && t1 < 1) { bounds[j].push(calc(t1)); }\n const t2 = (-b - Math.sqrt(b2ac)) / (2 * a);\n if (t2 > 0 && t2 < 1) { bounds[j].push(calc(t2)); }\n }\n P0 = P3;\n } else {\n bounds[0].push(seg.x);\n bounds[1].push(seg.y);\n }\n }\n\n const x = Math.min.apply(null, bounds[0]);\n const w = Math.max.apply(null, bounds[0]) - x;\n const y = Math.min.apply(null, bounds[1]);\n const h = Math.max.apply(null, bounds[1]) - y;\n return {\n x,\n y,\n width: w,\n height: h\n };\n};\n\n/**\n* Get the given/selected element's bounding box object, checking for\n* horizontal/vertical lines (see issue 717)\n* Note that performance is currently terrible, so some way to improve would\n* be great.\n* @param {Element} selected - Container or `` DOM element\n* @returns {DOMRect} Bounding box object\n*/\nfunction groupBBFix (selected) {\n if (supportsHVLineContainerBBox()) {\n try { return selected.getBBox(); } catch (e) {}\n }\n const ref = $.data(selected, 'ref');\n let matched = null;\n let ret, copy;\n\n if (ref) {\n copy = $(ref).children().clone().attr('visibility', 'hidden');\n $(svgroot_).append(copy);\n matched = copy.filter('line, path');\n } else {\n matched = $(selected).find('line, path');\n }\n\n let issue = false;\n if (matched.length) {\n matched.each(function () {\n const bb = this.getBBox();\n if (!bb.width || !bb.height) {\n issue = true;\n }\n });\n if (issue) {\n const elems = ref ? copy : $(selected).children();\n ret = getStrokedBBox(elems);\n } else {\n ret = selected.getBBox();\n }\n } else {\n ret = selected.getBBox();\n }\n if (ref) {\n copy.remove();\n }\n return ret;\n}\n\n/**\n* Get the given/selected element's bounding box object, convert it to be more\n* usable when necessary.\n* @function module:utilities.getBBox\n* @param {Element} elem - Optional DOM element to get the BBox for\n* @returns {module:utilities.BBoxObject} Bounding box object\n*/\nexport const getBBox = function (elem) {\n const selected = elem || editorContext_.geSelectedElements()[0];\n if (elem.nodeType !== 1) { return null; }\n const elname = selected.nodeName;\n\n let ret = null;\n switch (elname) {\n case 'text':\n if (selected.textContent === '') {\n selected.textContent = 'a'; // Some character needed for the selector to use.\n ret = selected.getBBox();\n selected.textContent = '';\n } else if (selected.getBBox) {\n ret = selected.getBBox();\n }\n break;\n case 'path':\n if (!supportsPathBBox()) {\n ret = getPathBBox(selected);\n } else if (selected.getBBox) {\n ret = selected.getBBox();\n }\n break;\n case 'g':\n case 'a':\n ret = groupBBFix(selected);\n break;\n default:\n\n if (elname === 'use') {\n ret = groupBBFix(selected); // , true);\n }\n if (elname === 'use' || (elname === 'foreignObject' && isWebkit())) {\n if (!ret) { ret = selected.getBBox(); }\n // This is resolved in later versions of webkit, perhaps we should\n // have a featured detection for correct 'use' behavior?\n // ——————————\n if (!isWebkit()) {\n const {x, y, width, height} = ret;\n const bb = {\n width,\n height,\n x: x + Number.parseFloat(selected.getAttribute('x') || 0),\n y: y + Number.parseFloat(selected.getAttribute('y') || 0)\n };\n ret = bb;\n }\n } else if (visElemsArr.includes(elname)) {\n if (selected) {\n try {\n ret = selected.getBBox();\n } catch (err) {\n // tspan (and textPath apparently) have no `getBBox` in Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=937268\n // Re: Chrome returning bbox for containing text element, see: https://bugs.chromium.org/p/chromium/issues/detail?id=349835\n const extent = selected.getExtentOfChar(0); // pos+dimensions of the first glyph\n const width = selected.getComputedTextLength(); // width of the tspan\n ret = {\n x: extent.x,\n y: extent.y,\n width,\n height: extent.height\n };\n }\n } else {\n // Check if element is child of a foreignObject\n const fo = $(selected).closest('foreignObject');\n if (fo.length) {\n if (fo[0].getBBox) {\n ret = fo[0].getBBox();\n }\n }\n }\n }\n }\n if (ret) {\n ret = bboxToObj(ret);\n }\n\n // get the bounding box from the DOM (which is in that element's coordinate system)\n return ret;\n};\n\n/**\n* @typedef {GenericArray} module:utilities.PathSegmentArray\n* @property {Integer} length 2\n* @property {\"M\"|\"L\"|\"C\"|\"Z\"} 0\n* @property {Float[]} 1\n*/\n\n/**\n* Create a path 'd' attribute from path segments.\n* Each segment is an array of the form: `[singleChar, [x,y, x,y, ...]]`\n* @function module:utilities.getPathDFromSegments\n* @param {module:utilities.PathSegmentArray[]} pathSegments - An array of path segments to be converted\n* @returns {string} The converted path d attribute.\n*/\nexport const getPathDFromSegments = function (pathSegments) {\n let d = '';\n\n $.each(pathSegments, function (j, [singleChar, pts]) {\n d += singleChar;\n for (let i = 0; i < pts.length; i += 2) {\n d += (pts[i] + ',' + pts[i + 1]) + ' ';\n }\n });\n\n return d;\n};\n\n/**\n* Make a path 'd' attribute from a simple SVG element shape.\n* @function module:utilities.getPathDFromElement\n* @param {Element} elem - The element to be converted\n* @returns {string} The path d attribute or `undefined` if the element type is unknown.\n*/\nexport const getPathDFromElement = function (elem) {\n // Possibly the cubed root of 6, but 1.81 works best\n let num = 1.81;\n let d, a, rx, ry;\n switch (elem.tagName) {\n case 'ellipse':\n case 'circle': {\n a = $(elem).attr(['rx', 'ry', 'cx', 'cy']);\n const {cx, cy} = a;\n ({rx, ry} = a);\n if (elem.tagName === 'circle') {\n ry = $(elem).attr('r');\n rx = ry;\n }\n\n d = getPathDFromSegments([\n ['M', [(cx - rx), (cy)]],\n ['C', [(cx - rx), (cy - ry / num), (cx - rx / num), (cy - ry), (cx), (cy - ry)]],\n ['C', [(cx + rx / num), (cy - ry), (cx + rx), (cy - ry / num), (cx + rx), (cy)]],\n ['C', [(cx + rx), (cy + ry / num), (cx + rx / num), (cy + ry), (cx), (cy + ry)]],\n ['C', [(cx - rx / num), (cy + ry), (cx - rx), (cy + ry / num), (cx - rx), (cy)]],\n ['Z', []]\n ]);\n break;\n } case 'path':\n d = elem.getAttribute('d');\n break;\n case 'line':\n a = $(elem).attr(['x1', 'y1', 'x2', 'y2']);\n d = 'M' + a.x1 + ',' + a.y1 + 'L' + a.x2 + ',' + a.y2;\n break;\n case 'polyline':\n d = 'M' + elem.getAttribute('points');\n break;\n case 'polygon':\n d = 'M' + elem.getAttribute('points') + ' Z';\n break;\n case 'rect': {\n const r = $(elem).attr(['rx', 'ry']);\n ({rx, ry} = r);\n const b = elem.getBBox();\n const {x, y} = b,\n w = b.width,\n h = b.height;\n num = 4 - num; // Why? Because!\n\n if (!rx && !ry) {\n // Regular rect\n d = getPathDFromSegments([\n ['M', [x, y]],\n ['L', [x + w, y]],\n ['L', [x + w, y + h]],\n ['L', [x, y + h]],\n ['L', [x, y]],\n ['Z', []]\n ]);\n } else {\n d = getPathDFromSegments([\n ['M', [x, y + ry]],\n ['C', [x, y + ry / num, x + rx / num, y, x + rx, y]],\n ['L', [x + w - rx, y]],\n ['C', [x + w - rx / num, y, x + w, y + ry / num, x + w, y + ry]],\n ['L', [x + w, y + h - ry]],\n ['C', [x + w, y + h - ry / num, x + w - rx / num, y + h, x + w - rx, y + h]],\n ['L', [x + rx, y + h]],\n ['C', [x + rx / num, y + h, x, y + h - ry / num, x, y + h - ry]],\n ['L', [x, y + ry]],\n ['Z', []]\n ]);\n }\n break;\n } default:\n break;\n }\n\n return d;\n};\n\n/**\n* Get a set of attributes from an element that is useful for convertToPath.\n* @function module:utilities.getExtraAttributesForConvertToPath\n* @param {Element} elem - The element to be probed\n* @returns {PlainObject<\"marker-start\"|\"marker-end\"|\"marker-mid\"|\"filter\"|\"clip-path\", string>} An object with attributes.\n*/\nexport const getExtraAttributesForConvertToPath = function (elem) {\n const attrs = {};\n // TODO: make this list global so that we can properly maintain it\n // TODO: what about @transform, @clip-rule, @fill-rule, etc?\n $.each(['marker-start', 'marker-end', 'marker-mid', 'filter', 'clip-path'], function () {\n const a = elem.getAttribute(this);\n if (a) {\n attrs[this] = a;\n }\n });\n return attrs;\n};\n\n/**\n* Get the BBox of an element-as-path.\n* @function module:utilities.getBBoxOfElementAsPath\n* @param {Element} elem - The DOM element to be probed\n* @param {module:utilities.EditorContext#addSVGElementFromJson} addSVGElementFromJson - Function to add the path element to the current layer. See canvas.addSVGElementFromJson\n* @param {module:path.pathActions} pathActions - If a transform exists, `pathActions.resetOrientation()` is used. See: canvas.pathActions.\n* @returns {DOMRect|false} The resulting path's bounding box object.\n*/\nexport const getBBoxOfElementAsPath = function (elem, addSVGElementFromJson, pathActions) {\n const path = addSVGElementFromJson({\n element: 'path',\n attr: getExtraAttributesForConvertToPath(elem)\n });\n\n const eltrans = elem.getAttribute('transform');\n if (eltrans) {\n path.setAttribute('transform', eltrans);\n }\n\n const {parentNode} = elem;\n if (elem.nextSibling) {\n elem.before(path);\n } else {\n parentNode.append(path);\n }\n\n const d = getPathDFromElement(elem);\n if (d) {\n path.setAttribute('d', d);\n } else {\n path.remove();\n }\n\n // Get the correct BBox of the new path, then discard it\n pathActions.resetOrientation(path);\n let bb = false;\n try {\n bb = path.getBBox();\n } catch (e) {\n // Firefox fails\n }\n path.remove();\n return bb;\n};\n\n/**\n* Convert selected element to a path.\n* @function module:utilities.convertToPath\n* @param {Element} elem - The DOM element to be converted\n* @param {module:utilities.SVGElementJSON} attrs - Apply attributes to new path. see canvas.convertToPath\n* @param {module:utilities.EditorContext#addSVGElementFromJson} addSVGElementFromJson - Function to add the path element to the current layer. See canvas.addSVGElementFromJson\n* @param {module:path.pathActions} pathActions - If a transform exists, pathActions.resetOrientation() is used. See: canvas.pathActions.\n* @param {module:draw.DrawCanvasInit#clearSelection|module:path.EditorContext#clearSelection} clearSelection - see [canvas.clearSelection]{@link module:svgcanvas.SvgCanvas#clearSelection}\n* @param {module:path.EditorContext#addToSelection} addToSelection - see [canvas.addToSelection]{@link module:svgcanvas.SvgCanvas#addToSelection}\n* @param {module:history} hstry - see history module\n* @param {module:path.EditorContext#addCommandToHistory|module:draw.DrawCanvasInit#addCommandToHistory} addCommandToHistory - see [canvas.addCommandToHistory]{@link module:svgcanvas~addCommandToHistory}\n* @returns {SVGPathElement|null} The converted path element or null if the DOM element was not recognized.\n*/\nexport const convertToPath = function (\n elem, attrs, addSVGElementFromJson, pathActions,\n clearSelection, addToSelection, hstry, addCommandToHistory\n) {\n const batchCmd = new hstry.BatchCommand('Convert element to Path');\n\n // Any attribute on the element not covered by the passed-in attributes\n attrs = $.extend({}, attrs, getExtraAttributesForConvertToPath(elem));\n\n const path = addSVGElementFromJson({\n element: 'path',\n attr: attrs\n });\n\n const eltrans = elem.getAttribute('transform');\n if (eltrans) {\n path.setAttribute('transform', eltrans);\n }\n\n const {id} = elem;\n const {parentNode} = elem;\n if (elem.nextSibling) {\n elem.before(path);\n } else {\n parentNode.append(path);\n }\n\n const d = getPathDFromElement(elem);\n if (d) {\n path.setAttribute('d', d);\n\n // Replace the current element with the converted one\n\n // Reorient if it has a matrix\n if (eltrans) {\n const tlist = getTransformList(path);\n if (hasMatrixTransform(tlist)) {\n pathActions.resetOrientation(path);\n }\n }\n\n const {nextSibling} = elem;\n batchCmd.addSubCommand(new hstry.RemoveElementCommand(elem, nextSibling, parent));\n batchCmd.addSubCommand(new hstry.InsertElementCommand(path));\n\n clearSelection();\n elem.remove();\n path.setAttribute('id', id);\n path.removeAttribute('visibility');\n addToSelection([path], true);\n\n addCommandToHistory(batchCmd);\n\n return path;\n }\n // the elem.tagName was not recognized, so no \"d\" attribute. Remove it, so we've haven't changed anything.\n path.remove();\n return null;\n};\n\n/**\n* Can the bbox be optimized over the native getBBox? The optimized bbox is the same as the native getBBox when\n* the rotation angle is a multiple of 90 degrees and there are no complex transforms.\n* Getting an optimized bbox can be dramatically slower, so we want to make sure it's worth it.\n*\n* The best example for this is a circle rotate 45 degrees. The circle doesn't get wider or taller when rotated\n* about it's center.\n*\n* The standard, unoptimized technique gets the native bbox of the circle, rotates the box 45 degrees, uses\n* that width and height, and applies any transforms to get the final bbox. This means the calculated bbox\n* is much wider than the original circle. If the angle had been 0, 90, 180, etc. both techniques render the\n* same bbox.\n*\n* The optimization is not needed if the rotation is a multiple 90 degrees. The default technique is to call\n* getBBox then apply the angle and any transforms.\n*\n* @param {Float} angle - The rotation angle in degrees\n* @param {boolean} hasAMatrixTransform - True if there is a matrix transform\n* @returns {boolean} True if the bbox can be optimized.\n*/\nfunction bBoxCanBeOptimizedOverNativeGetBBox (angle, hasAMatrixTransform) {\n const angleModulo90 = angle % 90;\n const closeTo90 = angleModulo90 < -89.99 || angleModulo90 > 89.99;\n const closeTo0 = angleModulo90 > -0.001 && angleModulo90 < 0.001;\n return hasAMatrixTransform || !(closeTo0 || closeTo90);\n}\n\n/**\n* Get bounding box that includes any transforms.\n* @function module:utilities.getBBoxWithTransform\n* @param {Element} elem - The DOM element to be converted\n* @param {module:utilities.EditorContext#addSVGElementFromJson} addSVGElementFromJson - Function to add the path element to the current layer. See canvas.addSVGElementFromJson\n* @param {module:path.pathActions} pathActions - If a transform exists, pathActions.resetOrientation() is used. See: canvas.pathActions.\n* @returns {module:utilities.BBoxObject|module:math.TransformedBox|DOMRect} A single bounding box object\n*/\nexport const getBBoxWithTransform = function (elem, addSVGElementFromJson, pathActions) {\n // TODO: Fix issue with rotated groups. Currently they work\n // fine in FF, but not in other browsers (same problem mentioned\n // in Issue 339 comment #2).\n\n let bb = getBBox(elem);\n\n if (!bb) {\n return null;\n }\n\n const tlist = getTransformList(elem);\n const angle = getRotationAngleFromTransformList(tlist);\n const hasMatrixXForm = hasMatrixTransform(tlist);\n\n if (angle || hasMatrixXForm) {\n let goodBb = false;\n if (bBoxCanBeOptimizedOverNativeGetBBox(angle, hasMatrixXForm)) {\n // Get the BBox from the raw path for these elements\n // TODO: why ellipse and not circle\n const elemNames = ['ellipse', 'path', 'line', 'polyline', 'polygon'];\n if (elemNames.includes(elem.tagName)) {\n goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions);\n bb = goodBb;\n } else if (elem.tagName === 'rect') {\n // Look for radius\n const rx = elem.getAttribute('rx');\n const ry = elem.getAttribute('ry');\n if (rx || ry) {\n goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions);\n bb = goodBb;\n }\n }\n }\n\n if (!goodBb) {\n const {matrix} = transformListToTransform(tlist);\n bb = transformBox(bb.x, bb.y, bb.width, bb.height, matrix).aabox;\n\n // Old technique that was exceedingly slow with large documents.\n //\n // Accurate way to get BBox of rotated element in Firefox:\n // Put element in group and get its BBox\n //\n // Must use clone else FF freaks out\n // const clone = elem.cloneNode(true);\n // const g = document.createElementNS(NS.SVG, 'g');\n // const parent = elem.parentNode;\n // parent.append(g);\n // g.append(clone);\n // const bb2 = bboxToObj(g.getBBox());\n // g.remove();\n }\n }\n return bb;\n};\n\n/**\n * @param {Element} elem\n * @returns {Float}\n * @todo This is problematic with large stroke-width and, for example, a single\n * horizontal line. The calculated BBox extends way beyond left and right sides.\n */\nfunction getStrokeOffsetForBBox (elem) {\n const sw = elem.getAttribute('stroke-width');\n return (!isNaN(sw) && elem.getAttribute('stroke') !== 'none') ? sw / 2 : 0;\n}\n\n/**\n * @typedef {PlainObject} BBox\n * @property {Integer} x The x value\n * @property {Integer} y The y value\n * @property {Float} width\n * @property {Float} height\n */\n\n/**\n* Get the bounding box for one or more stroked and/or transformed elements.\n* @function module:utilities.getStrokedBBox\n* @param {Element[]} elems - Array with DOM elements to check\n* @param {module:utilities.EditorContext#addSVGElementFromJson} addSVGElementFromJson - Function to add the path element to the current layer. See canvas.addSVGElementFromJson\n* @param {module:path.pathActions} pathActions - If a transform exists, pathActions.resetOrientation() is used. See: canvas.pathActions.\n* @returns {module:utilities.BBoxObject|module:math.TransformedBox|DOMRect} A single bounding box object\n*/\nexport const getStrokedBBox = function (elems, addSVGElementFromJson, pathActions) {\n if (!elems || !elems.length) { return false; }\n\n let fullBb;\n $.each(elems, function () {\n if (fullBb) { return; }\n if (!this.parentNode) { return; }\n fullBb = getBBoxWithTransform(this, addSVGElementFromJson, pathActions);\n });\n\n // This shouldn't ever happen...\n if (fullBb === undefined) { return null; }\n\n // fullBb doesn't include the stoke, so this does no good!\n // if (elems.length == 1) return fullBb;\n\n let maxX = fullBb.x + fullBb.width;\n let maxY = fullBb.y + fullBb.height;\n let minX = fullBb.x;\n let minY = fullBb.y;\n\n // If only one elem, don't call the potentially slow getBBoxWithTransform method again.\n if (elems.length === 1) {\n const offset = getStrokeOffsetForBBox(elems[0]);\n minX -= offset;\n minY -= offset;\n maxX += offset;\n maxY += offset;\n } else {\n $.each(elems, function (i, elem) {\n const curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions);\n if (curBb) {\n const offset = getStrokeOffsetForBBox(elem);\n minX = Math.min(minX, curBb.x - offset);\n minY = Math.min(minY, curBb.y - offset);\n // TODO: The old code had this test for max, but not min. I suspect this test should be for both min and max\n if (elem.nodeType === 1) {\n maxX = Math.max(maxX, curBb.x + curBb.width + offset);\n maxY = Math.max(maxY, curBb.y + curBb.height + offset);\n }\n }\n });\n }\n\n fullBb.x = minX;\n fullBb.y = minY;\n fullBb.width = maxX - minX;\n fullBb.height = maxY - minY;\n return fullBb;\n};\n\n/**\n* Get all elements that have a BBox (excludes ``, ``, etc).\n* Note that 0-opacity, off-screen etc elements are still considered \"visible\"\n* for this function.\n* @function module:utilities.getVisibleElements\n* @param {Element} parentElement - The parent DOM element to search within\n* @returns {Element[]} All \"visible\" elements.\n*/\nexport const getVisibleElements = function (parentElement) {\n if (!parentElement) {\n parentElement = $(editorContext_.getSVGContent()).children(); // Prevent layers from being included\n }\n\n const contentElems = [];\n $(parentElement).children().each(function (i, elem) {\n if (elem.getBBox) {\n contentElems.push(elem);\n }\n });\n return contentElems.reverse();\n};\n\n/**\n* Get the bounding box for one or more stroked and/or transformed elements.\n* @function module:utilities.getStrokedBBoxDefaultVisible\n* @param {Element[]} elems - Array with DOM elements to check\n* @returns {module:utilities.BBoxObject} A single bounding box object\n*/\nexport const getStrokedBBoxDefaultVisible = function (elems) {\n if (!elems) { elems = getVisibleElements(); }\n return getStrokedBBox(\n elems,\n editorContext_.addSVGElementFromJson,\n editorContext_.pathActions\n );\n};\n\n/**\n* Get the rotation angle of the given transform list.\n* @function module:utilities.getRotationAngleFromTransformList\n* @param {SVGTransformList} tlist - List of transforms\n* @param {boolean} toRad - When true returns the value in radians rather than degrees\n* @returns {Float} The angle in degrees or radians\n*/\nexport const getRotationAngleFromTransformList = function (tlist, toRad) {\n if (!tlist) { return 0; } // <svg> elements have no tlist\n const N = tlist.numberOfItems;\n for (let i = 0; i < N; ++i) {\n const xform = tlist.getItem(i);\n if (xform.type === 4) {\n return toRad ? xform.angle * Math.PI / 180.0 : xform.angle;\n }\n }\n return 0.0;\n};\n\n/**\n* Get the rotation angle of the given/selected DOM element.\n* @function module:utilities.getRotationAngle\n* @param {Element} [elem] - DOM element to get the angle for. Default to first of selected elements.\n* @param {boolean} [toRad=false] - When true returns the value in radians rather than degrees\n* @returns {Float} The angle in degrees or radians\n*/\nexport let getRotationAngle = function (elem, toRad) { // eslint-disable-line import/no-mutable-exports\n const selected = elem || editorContext_.getSelectedElements()[0];\n // find the rotation transform (if any) and set it\n const tlist = getTransformList(selected);\n return getRotationAngleFromTransformList(tlist, toRad);\n};\n\n/**\n* Get the reference element associated with the given attribute value.\n* @function module:utilities.getRefElem\n* @param {string} attrVal - The attribute value as a string\n* @returns {Element} Reference element\n*/\nexport const getRefElem = function (attrVal) {\n return getElem(getUrlFromAttr(attrVal).substr(1));\n};\n\n/**\n* Get a DOM element by ID within the SVG root element.\n* @function module:utilities.getElem\n* @param {string} id - String with the element's new ID\n* @returns {?Element}\n*/\nexport const getElem = (supportsSelectors())\n ? function (id) {\n // querySelector lookup\n return svgroot_.querySelector('#' + id);\n }\n : supportsXpath()\n ? function (id) {\n // xpath lookup\n return domdoc_.evaluate(\n 'svg:svg[@id=\"svgroot\"]//svg:*[@id=\"' + id + '\"]',\n domcontainer_,\n function () { return NS.SVG; },\n 9,\n null\n ).singleNodeValue;\n }\n : function (id) {\n // jQuery lookup: twice as slow as xpath in FF\n return $(svgroot_).find(`[id=${id}]`)[0];\n };\n\n/**\n* Assigns multiple attributes to an element.\n* @function module:utilities.assignAttributes\n* @param {Element} elem - DOM element to apply new attribute values to\n* @param {PlainObject<string, string>} attrs - Object with attribute keys/values\n* @param {Integer} [suspendLength] - Milliseconds to suspend redraw\n* @param {boolean} [unitCheck=false] - Boolean to indicate the need to use units.setUnitAttr\n* @returns {void}\n*/\nexport const assignAttributes = function (elem, attrs, suspendLength, unitCheck) {\n for (const [key, value] of Object.entries(attrs)) {\n const ns = (key.substr(0, 4) === 'xml:'\n ? NS.XML\n : key.substr(0, 6) === 'xlink:' ? NS.XLINK : null);\n if (isNullish(value)) {\n if (ns) {\n elem.removeAttributeNS(ns, key);\n } else {\n elem.removeAttribute(key);\n }\n continue;\n }\n if (ns) {\n elem.setAttributeNS(ns, key, value);\n } else if (!unitCheck) {\n elem.setAttribute(key, value);\n } else {\n setUnitAttr(elem, key, value);\n }\n }\n};\n\n/**\n* Remove unneeded (default) attributes, making resulting SVG smaller.\n* @function module:utilities.cleanupElement\n* @param {Element} element - DOM element to clean up\n* @returns {void}\n*/\nexport const cleanupElement = function (element) {\n const defaults = {\n 'fill-opacity': 1,\n 'stop-opacity': 1,\n opacity: 1,\n stroke: 'none',\n 'stroke-dasharray': 'none',\n 'stroke-linejoin': 'miter',\n 'stroke-linecap': 'butt',\n 'stroke-opacity': 1,\n 'stroke-width': 1,\n rx: 0,\n ry: 0\n };\n\n if (element.nodeName === 'ellipse') {\n // Ellipse elements require rx and ry attributes\n delete defaults.rx;\n delete defaults.ry;\n }\n\n Object.entries(defaults).forEach(([attr, val]) => {\n if (element.getAttribute(attr) === String(val)) {\n element.removeAttribute(attr);\n }\n });\n};\n\n/**\n* Round value to for snapping.\n* @function module:utilities.snapToGrid\n* @param {Float} value\n* @returns {Integer}\n*/\nexport const snapToGrid = function (value) {\n const unit = editorContext_.getBaseUnit();\n let stepSize = editorContext_.getSnappingStep();\n if (unit !== 'px') {\n stepSize *= getTypeMap()[unit];\n }\n value = Math.round(value / stepSize) * stepSize;\n return value;\n};\n\n/**\n* Escapes special characters in a regular expression.\n* @function module:utilities.regexEscape\n* @param {string} str\n* @returns {string}\n*/\nexport const regexEscape = function (str) {\n // Originally from: http://phpjs.org/functions\n return String(str).replace(/[.\\\\+*?[^\\]$(){}=!<>|:-]/g, '\\\\$&');\n};\n\n/**\n * Prevents default browser click behaviour on the given element.\n * @function module:utilities.preventClickDefault\n * @param {Element} img - The DOM element to prevent the click on\n * @returns {void}\n */\nexport const preventClickDefault = function (img) {\n $(img).click(function (e) { e.preventDefault(); });\n};\n\n/**\n * @callback module:utilities.GetNextID\n * @returns {string} The ID\n */\n\n/**\n * Whether a value is `null` or `undefined`.\n * @param {any} val\n * @returns {boolean}\n */\nexport const isNullish = (val) => {\n return val === null || val === undefined;\n};\n\n/**\n* Overwrite methods for unit testing.\n* @function module:utilities.mock\n* @param {PlainObject} mockMethods\n* @param {module:utilities.getHref} mockMethods.getHref\n* @param {module:utilities.setHref} mockMethods.setHref\n* @param {module:utilities.getRotationAngle} mockMethods.getRotationAngle\n* @returns {void}\n*/\nexport const mock = ({\n getHref: getHrefUser, setHref: setHrefUser, getRotationAngle: getRotationAngleUser\n}) => {\n getHref = getHrefUser;\n setHref = setHrefUser;\n getRotationAngle = getRotationAngleUser;\n};\n\nexport const $q = (sel) => document.querySelector(sel);\nexport const $qq = (sel) => [...document.querySelectorAll(sel)];\n","/* globals jQuery */\n/**\n * Adds context menu functionality.\n * @module contextmenu\n * @license Apache-2.0\n * @author Adam Bender\n */\n// Dependencies:\n// 1) jQuery (for dom injection of context menus)\n\nconst $ = jQuery;\n\nlet contextMenuExtensions = {};\n\n/**\n * Signature depends on what the user adds; in the case of our uses with\n * SVGEditor, no parameters are passed nor anything expected for a return.\n * @callback module:contextmenu.MenuItemAction\n * @param {...args} args\n * @returns {any}\n*/\n\n/**\n* @typedef {PlainObject} module:contextmenu.MenuItem\n* @property {string} id\n* @property {string} label\n* @property {module:contextmenu.MenuItemAction} action\n*/\n\n/**\n* @param {module:contextmenu.MenuItem} menuItem\n* @returns {boolean}\n*/\nconst menuItemIsValid = function (menuItem) {\n return menuItem && menuItem.id && menuItem.label && menuItem.action && typeof menuItem.action === 'function';\n};\n\n/**\n* @function module:contextmenu.add\n* @param {module:contextmenu.MenuItem} menuItem\n* @throws {Error|TypeError}\n* @returns {void}\n*/\nexport const add = function (menuItem) {\n // menuItem: {id, label, shortcut, action}\n if (!menuItemIsValid(menuItem)) {\n throw new TypeError(\n 'Menu items must be defined and have at least properties: ' +\n 'id, label, action, where action must be a function'\n );\n }\n if (menuItem.id in contextMenuExtensions) {\n throw new Error('Cannot add extension \"' + menuItem.id + '\", an extension by that name already exists\"');\n }\n // Register menuItem action, see below for deferred menu dom injection\n console.log('Registered contextmenu item: {id:' + menuItem.id + ', label:' + menuItem.label + '}'); // eslint-disable-line no-console\n contextMenuExtensions[menuItem.id] = menuItem;\n // TODO: Need to consider how to handle custom enable/disable behavior\n};\n\n/**\n* @function module:contextmenu.hasCustomHandler\n* @param {string} handlerKey\n* @returns {boolean}\n*/\nexport const hasCustomHandler = function (handlerKey) {\n return Boolean(contextMenuExtensions[handlerKey]);\n};\n\n/**\n* @function module:contextmenu.getCustomHandler\n* @param {string} handlerKey\n* @returns {module:contextmenu.MenuItemAction}\n*/\nexport const getCustomHandler = function (handlerKey) {\n return contextMenuExtensions[handlerKey].action;\n};\n\n/**\n* @param {module:contextmenu.MenuItem} menuItem\n* @returns {void}\n*/\nconst injectExtendedContextMenuItemIntoDom = function (menuItem) {\n if (!Object.keys(contextMenuExtensions).length) {\n // all menuItems appear at the bottom of the menu in their own container.\n // if this is the first extension menu we need to add the separator.\n $('#cmenu_canvas').append(\"<li class='separator'>\");\n }\n const shortcut = menuItem.shortcut || '';\n $('#cmenu_canvas').append(\"<li class='disabled'><a href='#\" + menuItem.id + \"'>\" +\n menuItem.label + \"<span class='shortcut'>\" +\n shortcut + '</span></a></li>');\n};\n\n/**\n* @function module:contextmenu.injectExtendedContextMenuItemsIntoDom\n* @returns {void}\n*/\nexport const injectExtendedContextMenuItemsIntoDom = function () {\n Object.values(contextMenuExtensions).forEach((menuItem) => {\n injectExtendedContextMenuItemIntoDom(menuItem);\n });\n};\n/**\n* @function module:contextmenu.resetCustomMenus\n* @returns {void}\n*/\nexport const resetCustomMenus = function () { contextMenuExtensions = {}; };\n","/**\n * Created by alexey2baranov on 28.01.17.\n */\n/*\n An extraction of the deparam method from Ben Alman's jQuery BBQ\n http://benalman.com/projects/jquery-bbq-plugin/\n */\n\nconst coerce_types = {'true': !0, 'false': !1, 'null': null};\n\nfunction deparam (params, coerce) {\n // console.log(params)\n const obj = {};\n\n // Iterate over all name=value pairs.\n params.replace(/\\+/g, ' ').split('&').forEach(function (v) {\n const param = v.split('=');\n\n let\n key = decodeURIComponent(param[0]),\n // If key is more complex than 'foo', like 'a[]' or 'a[b][c]', split it\n // into its component parts.\n keys = key.split(']['),\n keys_last = keys.length - 1;\n\n // If the first keys part contains [ and the last ends with ], then []\n // are correctly balanced.\n if (/\\[/.test(keys[0]) && /\\]$/.test(keys[keys_last])) {\n // Remove the trailing ] from the last keys part.\n keys[keys_last] = keys[keys_last].replace(/\\]$/, '');\n\n // Split first keys part into two parts on the [ and add them back onto\n // the beginning of the keys array.\n keys = keys.shift().split('[').concat(keys);\n\n keys_last = keys.length - 1;\n } else {\n // Basic 'foo' style key.\n keys_last = 0;\n }\n\n // Are we dealing with a name=value pair, or just a name?\n if (param.length >= 2) {\n let val = decodeURIComponent(param.slice(1).join('='));\n\n // Coerce values.\n if (coerce) {\n val = val && !isNaN(val) ? +val // number\n : val === 'undefined' ? undefined // undefined\n : coerce_types[val] !== undefined ? coerce_types[val] // true, false, null\n : val; // string\n }\n\n if (keys_last) {\n let cur = obj;\n // Complex key, build deep object structure based on a few rules:\n // * The 'cur' pointer starts at the object top-level.\n // * [] = array push (n is set to array length), [n] = array if n is\n // numeric, otherwise object.\n // * If at the last keys part, set the value.\n // * For each keys part, if the current level is undefined create an\n // object or array based on the type of the next keys part.\n // * Move the 'cur' pointer to the next level.\n // * Rinse & repeat.\n for (let i = 0; i <= keys_last; i++) {\n key = keys[i] === '' ? cur.length : keys[i];\n cur = cur[key] = i < keys_last\n ? cur[key] || (keys[i + 1] && isNaN(keys[i + 1]) ? {} : [])\n : val;\n }\n\n } else {\n // Simple key, even simpler rules, since only scalars and shallow\n // arrays are allowed.\n\n if (Array.isArray(obj[key])) {\n // val is already an array, so push on the next value.\n obj[key].push(val);\n\n } else if (obj[key] !== undefined) {\n // val isn't an array, but since a second value has been specified,\n // convert val into an array.\n obj[key] = [obj[key], val];\n\n } else {\n // val is a scalar.\n obj[key] = val;\n }\n }\n\n } else if (key) {\n // No value was defined, so set something meaningful.\n obj[key] = coerce\n ? undefined\n : '';\n }\n });\n\n return obj;\n}\n\nexport default deparam;\n","export default (typeof global !== \"undefined\" ? global :\n typeof self !== \"undefined\" ? self :\n typeof window !== \"undefined\" ? window : {});","/** @license\n *\n * jsPDF - PDF Document creation from JavaScript\n * Version 2.1.0 Built on 2020-08-25T16:02:38.141Z\n * CommitID 00000000\n *\n * Copyright (c) 2010-2020 James Hall <james@parall.ax>, https://github.com/MrRio/jsPDF\n * 2015-2020 yWorks GmbH, http://www.yworks.com\n * 2015-2020 Lukas Holländer <lukas.hollaender@yworks.com>, https://github.com/HackbrettXXX\n * 2016-2018 Aras Abbasi <aras.abbasi@gmail.com>\n * 2010 Aaron Spike, https://github.com/acspike\n * 2012 Willow Systems Corporation, willow-systems.com\n * 2012 Pablo Hess, https://github.com/pablohess\n * 2012 Florian Jenett, https://github.com/fjenett\n * 2013 Warren Weckesser, https://github.com/warrenweckesser\n * 2013 Youssef Beddad, https://github.com/lifof\n * 2013 Lee Driscoll, https://github.com/lsdriscoll\n * 2013 Stefan Slonevskiy, https://github.com/stefslon\n * 2013 Jeremy Morel, https://github.com/jmorel\n * 2013 Christoph Hartmann, https://github.com/chris-rock\n * 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria\n * 2014 James Makes, https://github.com/dollaruw\n * 2014 Diego Casorran, https://github.com/diegocr\n * 2014 Steven Spungin, https://github.com/Flamenco\n * 2014 Kenneth Glassey, https://github.com/Gavvers\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n *\n * Contributor(s):\n * siefkenj, ahwolf, rickygu, Midnith, saintclair, eaparango,\n * kim3er, mfo, alnorth, Flamenco\n */\n\nvar t=function(){return\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:this}();function e(){t.console&&\"function\"==typeof t.console.log&&t.console.log.apply(t.console,arguments)}var n={log:e,warn:function(n){t.console&&(\"function\"==typeof t.console.warn?t.console.warn.apply(t.console,arguments):e.call(null,arguments))},error:function(n){t.console&&(\"function\"==typeof t.console.error?t.console.error.apply(t.console,arguments):e(n))}};\n/**\n * @license\n * FileSaver.js\n * A saveAs() FileSaver implementation.\n *\n * By Eli Grey, http://eligrey.com\n *\n * License : https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md (MIT)\n * source : http://purl.eligrey.com/github/FileSaver.js\n */function r(t,e,r){var i=new XMLHttpRequest;i.open(\"GET\",t),i.responseType=\"blob\",i.onload=function(){u(i.response,e,r)},i.onerror=function(){n.error(\"could not download file\")},i.send()}function i(t){var e=new XMLHttpRequest;e.open(\"HEAD\",t,!1);try{e.send()}catch(t){}return e.status>=200&&e.status<=299}function a(t){try{t.dispatchEvent(new MouseEvent(\"click\"))}catch(n){var e=document.createEvent(\"MouseEvents\");e.initMouseEvent(\"click\",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(e)}}var o,s,u=t.saveAs||(\"object\"!=typeof window||window!==t?function(){}:\"download\"in HTMLAnchorElement.prototype?function(e,n,o){var s=t.URL||t.webkitURL,u=document.createElement(\"a\");n=n||e.name||\"download\",u.download=n,u.rel=\"noopener\",\"string\"==typeof e?(u.href=e,u.origin!==location.origin?i(u.href)?r(e,n,o):a(u,u.target=\"_blank\"):a(u)):(u.href=s.createObjectURL(e),setTimeout((function(){s.revokeObjectURL(u.href)}),4e4),setTimeout((function(){a(u)}),0))}:\"msSaveOrOpenBlob\"in navigator?function(t,e,o){if(e=e||t.name||\"download\",\"string\"==typeof t)if(i(t))r(t,e,o);else{var s=document.createElement(\"a\");s.href=t,s.target=\"_blank\",setTimeout((function(){a(s)}))}else navigator.msSaveOrOpenBlob(function(t,e){return void 0===e?e={autoBom:!1}:\"object\"!=typeof e&&(n.warn(\"Deprecated: Expected third argument to be a object\"),e={autoBom:!e}),e.autoBom&&/^\\s*(?:text\\/\\S*|application\\/xml|\\S*\\/\\S*\\+xml)\\s*;.*charset\\s*=\\s*utf-8/i.test(t.type)?new Blob([String.fromCharCode(65279),t],{type:t.type}):t}(t,o),e)}:function(e,n,i,a){if((a=a||open(\"\",\"_blank\"))&&(a.document.title=a.document.body.innerText=\"downloading...\"),\"string\"==typeof e)return r(e,n,i);var o=\"application/octet-stream\"===e.type,s=/constructor/i.test(t.HTMLElement)||t.safari,u=/CriOS\\/[\\d]+/.test(navigator.userAgent);if((u||o&&s)&&\"object\"==typeof FileReader){var c=new FileReader;c.onloadend=function(){var t=c.result;t=u?t:t.replace(/^data:[^;]*;/,\"data:attachment/file;\"),a?a.location.href=t:location=t,a=null},c.readAsDataURL(e)}else{var h=t.URL||t.webkitURL,l=h.createObjectURL(e);a?a.location=l:location.href=l,a=null,setTimeout((function(){h.revokeObjectURL(l)}),4e4)}});\n/**\n * A class to parse color values\n * @author Stoyan Stefanov <sstoo@gmail.com>\n * {@link http://www.phpied.com/rgb-color-parser-in-javascript/}\n * @license Use it if you like it\n */function c(t){var e;t=t||\"\",this.ok=!1,\"#\"==t.charAt(0)&&(t=t.substr(1,6));t={aliceblue:\"f0f8ff\",antiquewhite:\"faebd7\",aqua:\"00ffff\",aquamarine:\"7fffd4\",azure:\"f0ffff\",beige:\"f5f5dc\",bisque:\"ffe4c4\",black:\"000000\",blanchedalmond:\"ffebcd\",blue:\"0000ff\",blueviolet:\"8a2be2\",brown:\"a52a2a\",burlywood:\"deb887\",cadetblue:\"5f9ea0\",chartreuse:\"7fff00\",chocolate:\"d2691e\",coral:\"ff7f50\",cornflowerblue:\"6495ed\",cornsilk:\"fff8dc\",crimson:\"dc143c\",cyan:\"00ffff\",darkblue:\"00008b\",darkcyan:\"008b8b\",darkgoldenrod:\"b8860b\",darkgray:\"a9a9a9\",darkgreen:\"006400\",darkkhaki:\"bdb76b\",darkmagenta:\"8b008b\",darkolivegreen:\"556b2f\",darkorange:\"ff8c00\",darkorchid:\"9932cc\",darkred:\"8b0000\",darksalmon:\"e9967a\",darkseagreen:\"8fbc8f\",darkslateblue:\"483d8b\",darkslategray:\"2f4f4f\",darkturquoise:\"00ced1\",darkviolet:\"9400d3\",deeppink:\"ff1493\",deepskyblue:\"00bfff\",dimgray:\"696969\",dodgerblue:\"1e90ff\",feldspar:\"d19275\",firebrick:\"b22222\",floralwhite:\"fffaf0\",forestgreen:\"228b22\",fuchsia:\"ff00ff\",gainsboro:\"dcdcdc\",ghostwhite:\"f8f8ff\",gold:\"ffd700\",goldenrod:\"daa520\",gray:\"808080\",green:\"008000\",greenyellow:\"adff2f\",honeydew:\"f0fff0\",hotpink:\"ff69b4\",indianred:\"cd5c5c\",indigo:\"4b0082\",ivory:\"fffff0\",khaki:\"f0e68c\",lavender:\"e6e6fa\",lavenderblush:\"fff0f5\",lawngreen:\"7cfc00\",lemonchiffon:\"fffacd\",lightblue:\"add8e6\",lightcoral:\"f08080\",lightcyan:\"e0ffff\",lightgoldenrodyellow:\"fafad2\",lightgrey:\"d3d3d3\",lightgreen:\"90ee90\",lightpink:\"ffb6c1\",lightsalmon:\"ffa07a\",lightseagreen:\"20b2aa\",lightskyblue:\"87cefa\",lightslateblue:\"8470ff\",lightslategray:\"778899\",lightsteelblue:\"b0c4de\",lightyellow:\"ffffe0\",lime:\"00ff00\",limegreen:\"32cd32\",linen:\"faf0e6\",magenta:\"ff00ff\",maroon:\"800000\",mediumaquamarine:\"66cdaa\",mediumblue:\"0000cd\",mediumorchid:\"ba55d3\",mediumpurple:\"9370d8\",mediumseagreen:\"3cb371\",mediumslateblue:\"7b68ee\",mediumspringgreen:\"00fa9a\",mediumturquoise:\"48d1cc\",mediumvioletred:\"c71585\",midnightblue:\"191970\",mintcream:\"f5fffa\",mistyrose:\"ffe4e1\",moccasin:\"ffe4b5\",navajowhite:\"ffdead\",navy:\"000080\",oldlace:\"fdf5e6\",olive:\"808000\",olivedrab:\"6b8e23\",orange:\"ffa500\",orangered:\"ff4500\",orchid:\"da70d6\",palegoldenrod:\"eee8aa\",palegreen:\"98fb98\",paleturquoise:\"afeeee\",palevioletred:\"d87093\",papayawhip:\"ffefd5\",peachpuff:\"ffdab9\",peru:\"cd853f\",pink:\"ffc0cb\",plum:\"dda0dd\",powderblue:\"b0e0e6\",purple:\"800080\",red:\"ff0000\",rosybrown:\"bc8f8f\",royalblue:\"4169e1\",saddlebrown:\"8b4513\",salmon:\"fa8072\",sandybrown:\"f4a460\",seagreen:\"2e8b57\",seashell:\"fff5ee\",sienna:\"a0522d\",silver:\"c0c0c0\",skyblue:\"87ceeb\",slateblue:\"6a5acd\",slategray:\"708090\",snow:\"fffafa\",springgreen:\"00ff7f\",steelblue:\"4682b4\",tan:\"d2b48c\",teal:\"008080\",thistle:\"d8bfd8\",tomato:\"ff6347\",turquoise:\"40e0d0\",violet:\"ee82ee\",violetred:\"d02090\",wheat:\"f5deb3\",white:\"ffffff\",whitesmoke:\"f5f5f5\",yellow:\"ffff00\",yellowgreen:\"9acd32\"}[t=(t=t.replace(/ /g,\"\")).toLowerCase()]||t;for(var n=[{re:/^rgb\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})\\)$/,example:[\"rgb(123, 234, 45)\",\"rgb(255,234,245)\"],process:function(t){return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]}},{re:/^(\\w{2})(\\w{2})(\\w{2})$/,example:[\"#00ff00\",\"336699\"],process:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/^(\\w{1})(\\w{1})(\\w{1})$/,example:[\"#fb0\",\"f0f\"],process:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}}],r=0;r<n.length;r++){var i=n[r].re,a=n[r].process,o=i.exec(t);o&&(e=a(o),this.r=e[0],this.g=e[1],this.b=e[2],this.ok=!0)}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return\"rgb(\"+this.r+\", \"+this.g+\", \"+this.b+\")\"},this.toHex=function(){var t=this.r.toString(16),e=this.g.toString(16),n=this.b.toString(16);return 1==t.length&&(t=\"0\"+t),1==e.length&&(e=\"0\"+e),1==n.length&&(n=\"0\"+n),\"#\"+t+e+n}}function h(e){if(\"object\"!=typeof e)throw new Error(\"Invalid Context passed to initialize PubSub (jsPDF-module)\");var r={};this.subscribe=function(t,e,n){if(n=n||!1,\"string\"!=typeof t||\"function\"!=typeof e||\"boolean\"!=typeof n)throw new Error(\"Invalid arguments passed to PubSub.subscribe (jsPDF-module)\");r.hasOwnProperty(t)||(r[t]={});var i=Math.random().toString(35);return r[t][i]=[e,!!n],i},this.unsubscribe=function(t){for(var e in r)if(r[e][t])return delete r[e][t],0===Object.keys(r[e]).length&&delete r[e],!0;return!1},this.publish=function(i){if(r.hasOwnProperty(i)){var a=Array.prototype.slice.call(arguments,1),o=[];for(var s in r[i]){var u=r[i][s];try{u[0].apply(e,a)}catch(e){t.console&&n.error(\"jsPDF PubSub Error\",e.message,e)}u[1]&&o.push(s)}o.length&&o.forEach(this.unsubscribe)}},this.getTopics=function(){return r}}function l(t){if(!(this instanceof l))return new l(t);var e=\"opacity,stroke-opacity\".split(\",\");for(var n in t)t.hasOwnProperty(n)&&e.indexOf(n)>=0&&(this[n]=t[n]);this.id=\"\",this.objectNumber=-1}function f(t,e){this.gState=t,this.matrix=e,this.id=\"\",this.objectNumber=-1}function d(t,e,n,r,i){if(!(this instanceof d))return new d(t,e,n,r,i);this.type=\"axial\"===t?2:3,this.coords=e,this.colors=n,f.call(this,r,i)}function p(t,e,n,r,i){if(!(this instanceof p))return new p(t,e,n,r,i);this.boundingBox=t,this.xStep=e,this.yStep=n,this.stream=\"\",this.cloneIndex=0,f.call(this,r,i)}function g(e){var r,i=\"string\"==typeof arguments[0]?arguments[0]:\"p\",a=arguments[1],o=arguments[2],f=arguments[3],m=[],v=1,b=16,y=\"S\";\"object\"==typeof(e=e||{})&&(i=e.orientation,a=e.unit||a,o=e.format||o,f=e.compress||e.compressPdf||f,v=\"number\"==typeof e.userUnit?Math.abs(e.userUnit):1,void 0!==e.precision&&(r=e.precision),void 0!==e.floatPrecision&&(b=e.floatPrecision),y=e.defaultPathOperation||\"S\"),m=e.filters||(!0===f?[\"FlateEncode\"]:m),a=a||\"mm\",i=(\"\"+(i||\"P\")).toLowerCase();var w=e.putOnlyUsedFonts||!1,N={},L={internal:{},__private__:{}};L.__private__.PubSub=h;var x=\"1.3\",A=L.__private__.getPdfVersion=function(){return x};L.__private__.setPdfVersion=function(t){x=t};var _={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],\"government-letter\":[576,756],legal:[612,1008],\"junior-legal\":[576,360],ledger:[1224,792],tabloid:[792,1224],\"credit-card\":[153,243]};L.__private__.getPageFormats=function(){return _};var S=L.__private__.getPageFormat=function(t){return _[t]};o=o||\"a4\";var P={COMPAT:\"compat\",ADVANCED:\"advanced\"},k=P.COMPAT;function F(){this.saveGraphicsState(),ot(new Dt(Nt,0,0,-Nt,0,Cn()*Nt).toString()+\" cm\"),this.setFontSize(this.getFontSize()/Nt),y=\"n\",k=P.ADVANCED}function I(){this.restoreGraphicsState(),y=\"S\",k=P.COMPAT}L.advancedAPI=function(t){var e=k===P.COMPAT;return e&&F.call(this),\"function\"!=typeof t||(t(this),e&&I.call(this)),this},L.compatAPI=function(t){var e=k===P.ADVANCED;return e&&I.call(this),\"function\"!=typeof t||(t(this),e&&F.call(this)),this},L.isAdvancedAPI=function(){return k===P.ADVANCED};var C,j=function(t){if(k!==P.ADVANCED)throw new Error(t+\" is only available in 'advanced' API mode. You need to call advancedAPI() first.\")},B=L.roundToPrecision=L.__private__.roundToPrecision=function(t,e){var n=r||e;if(isNaN(t)||isNaN(n))throw new Error(\"Invalid argument passed to jsPDF.roundToPrecision\");return t.toFixed(n).replace(/0+$/,\"\")};C=L.hpf=L.__private__.hpf=\"number\"==typeof b?function(t){if(isNaN(t))throw new Error(\"Invalid argument passed to jsPDF.hpf\");return B(t,b)}:\"smart\"===b?function(t){if(isNaN(t))throw new Error(\"Invalid argument passed to jsPDF.hpf\");return B(t,t>-1&&t<1?16:5)}:function(t){if(isNaN(t))throw new Error(\"Invalid argument passed to jsPDF.hpf\");return B(t,16)};var O=L.f2=L.__private__.f2=function(t){if(isNaN(t))throw new Error(\"Invalid argument passed to jsPDF.f2\");return B(t,2)},M=L.__private__.f3=function(t){if(isNaN(t))throw new Error(\"Invalid argument passed to jsPDF.f3\");return B(t,3)},E=L.scale=L.__private__.scale=function(t){if(isNaN(t))throw new Error(\"Invalid argument passed to jsPDF.scale\");return k===P.COMPAT?t*Nt:k===P.ADVANCED?t:void 0},q=function(t){return k===P.COMPAT?Cn()-t:k===P.ADVANCED?t:void 0},R=function(t){return E(q(t))};L.__private__.setPrecision=L.setPrecision=function(t){\"number\"==typeof parseInt(t,10)&&(r=parseInt(t,10))};var T,D=\"00000000000000000000000000000000\",U=L.__private__.getFileId=function(){return D},z=L.__private__.setFileId=function(t){return D=void 0!==t&&/^[a-fA-F0-9]{32}$/.test(t)?t.toUpperCase():D.split(\"\").map((function(){return\"ABCDEF0123456789\".charAt(Math.floor(16*Math.random()))})).join(\"\")};L.setFileId=function(t){return z(t),this},L.getFileId=function(){return U()};var H=L.__private__.convertDateToPDFDate=function(t){var e=t.getTimezoneOffset(),n=e<0?\"+\":\"-\",r=Math.floor(Math.abs(e/60)),i=Math.abs(e%60),a=[n,J(r),\"'\",J(i),\"'\"].join(\"\");return[\"D:\",t.getFullYear(),J(t.getMonth()+1),J(t.getDate()),J(t.getHours()),J(t.getMinutes()),J(t.getSeconds()),a].join(\"\")},W=L.__private__.convertPDFDateToDate=function(t){var e=parseInt(t.substr(2,4),10),n=parseInt(t.substr(6,2),10)-1,r=parseInt(t.substr(8,2),10),i=parseInt(t.substr(10,2),10),a=parseInt(t.substr(12,2),10),o=parseInt(t.substr(14,2),10);return new Date(e,n,r,i,a,o,0)},V=L.__private__.setCreationDate=function(t){var e;if(void 0===t&&(t=new Date),t instanceof Date)e=H(t);else{if(!/^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\\+0[0-9]|\\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/.test(t))throw new Error(\"Invalid argument passed to jsPDF.setCreationDate\");e=t}return T=e},G=L.__private__.getCreationDate=function(t){var e=T;return\"jsDate\"===t&&(e=W(T)),e};L.setCreationDate=function(t){return V(t),this},L.getCreationDate=function(t){return G(t)};var Y,J=L.__private__.padd2=function(t){return(\"0\"+parseInt(t)).slice(-2)},X=L.__private__.padd2Hex=function(t){return(\"00\"+(t=t.toString())).substr(t.length)},K=0,Z=[],$=[],Q=0,tt=[],et=[],nt=!1,rt=$,it=function(){K=0,Q=0,$=[],Z=[],tt=[],Jt=Vt(),Xt=Vt()};L.__private__.setCustomOutputDestination=function(t){nt=!0,rt=t};var at=function(t){nt||(rt=t)};L.__private__.resetCustomOutputDestination=function(){nt=!1,rt=$};var ot=L.__private__.out=function(t){return t=t.toString(),Q+=t.length+1,rt.push(t),rt},st=L.__private__.write=function(t){return ot(1===arguments.length?t.toString():Array.prototype.join.call(arguments,\" \"))},ut=L.__private__.getArrayBuffer=function(t){for(var e=t.length,n=new ArrayBuffer(e),r=new Uint8Array(n);e--;)r[e]=t.charCodeAt(e);return n},ct=[[\"Helvetica\",\"helvetica\",\"normal\",\"WinAnsiEncoding\"],[\"Helvetica-Bold\",\"helvetica\",\"bold\",\"WinAnsiEncoding\"],[\"Helvetica-Oblique\",\"helvetica\",\"italic\",\"WinAnsiEncoding\"],[\"Helvetica-BoldOblique\",\"helvetica\",\"bolditalic\",\"WinAnsiEncoding\"],[\"Courier\",\"courier\",\"normal\",\"WinAnsiEncoding\"],[\"Courier-Bold\",\"courier\",\"bold\",\"WinAnsiEncoding\"],[\"Courier-Oblique\",\"courier\",\"italic\",\"WinAnsiEncoding\"],[\"Courier-BoldOblique\",\"courier\",\"bolditalic\",\"WinAnsiEncoding\"],[\"Times-Roman\",\"times\",\"normal\",\"WinAnsiEncoding\"],[\"Times-Bold\",\"times\",\"bold\",\"WinAnsiEncoding\"],[\"Times-Italic\",\"times\",\"italic\",\"WinAnsiEncoding\"],[\"Times-BoldItalic\",\"times\",\"bolditalic\",\"WinAnsiEncoding\"],[\"ZapfDingbats\",\"zapfdingbats\",\"normal\",null],[\"Symbol\",\"symbol\",\"normal\",null]];L.__private__.getStandardFonts=function(){return ct};var ht=e.fontSize||16;L.__private__.setFontSize=L.setFontSize=function(t){return ht=k===P.ADVANCED?t/Nt:t,this};var lt,ft=L.__private__.getFontSize=L.getFontSize=function(){return k===P.COMPAT?ht:ht*Nt},dt=e.R2L||!1;L.__private__.setR2L=L.setR2L=function(t){return dt=t,this},L.__private__.getR2L=L.getR2L=function(){return dt};var pt,gt=L.__private__.setZoomMode=function(t){var e=[void 0,null,\"fullwidth\",\"fullheight\",\"fullpage\",\"original\"];if(/^\\d*\\.?\\d*%$/.test(t))lt=t;else if(isNaN(t)){if(-1===e.indexOf(t))throw new Error('zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. \"'+t+'\" is not recognized.');lt=t}else lt=parseInt(t,10)};L.__private__.getZoomMode=function(){return lt};var mt,vt=L.__private__.setPageMode=function(t){if(-1==[void 0,null,\"UseNone\",\"UseOutlines\",\"UseThumbs\",\"FullScreen\"].indexOf(t))throw new Error('Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. \"'+t+'\" is not recognized.');pt=t};L.__private__.getPageMode=function(){return pt};var bt=L.__private__.setLayoutMode=function(t){if(-1==[void 0,null,\"continuous\",\"single\",\"twoleft\",\"tworight\",\"two\"].indexOf(t))throw new Error('Layout mode must be one of continuous, single, twoleft, tworight. \"'+t+'\" is not recognized.');mt=t};L.__private__.getLayoutMode=function(){return mt},L.__private__.setDisplayMode=L.setDisplayMode=function(t,e,n){return gt(t),bt(e),vt(n),this};var yt={title:\"\",subject:\"\",author:\"\",keywords:\"\",creator:\"\"};L.__private__.getDocumentProperty=function(t){if(-1===Object.keys(yt).indexOf(t))throw new Error(\"Invalid argument passed to jsPDF.getDocumentProperty\");return yt[t]},L.__private__.getDocumentProperties=function(){return yt},L.__private__.setDocumentProperties=L.setProperties=L.setDocumentProperties=function(t){for(var e in yt)yt.hasOwnProperty(e)&&t[e]&&(yt[e]=t[e]);return this},L.__private__.setDocumentProperty=function(t,e){if(-1===Object.keys(yt).indexOf(t))throw new Error(\"Invalid arguments passed to jsPDF.setDocumentProperty\");return yt[t]=e};var wt,Nt,Lt,xt,At,_t={},St={},Pt=[],kt={},Ft={},It={},Ct={},jt=null,Bt=0,Ot=[],Mt=new h(L),Et=e.hotfixes||[],qt={},Rt={},Tt=[],Dt=function(t,e,n,r,i,a){if(!(this instanceof Dt))return new Dt(t,e,n,r,i,a);isNaN(t)&&(t=1),isNaN(e)&&(e=0),isNaN(n)&&(n=0),isNaN(r)&&(r=1),isNaN(i)&&(i=0),isNaN(a)&&(a=0),this._matrix=[t,e,n,r,i,a]};Object.defineProperty(Dt.prototype,\"sx\",{get:function(){return this._matrix[0]},set:function(t){this._matrix[0]=t}}),Object.defineProperty(Dt.prototype,\"shy\",{get:function(){return this._matrix[1]},set:function(t){this._matrix[1]=t}}),Object.defineProperty(Dt.prototype,\"shx\",{get:function(){return this._matrix[2]},set:function(t){this._matrix[2]=t}}),Object.defineProperty(Dt.prototype,\"sy\",{get:function(){return this._matrix[3]},set:function(t){this._matrix[3]=t}}),Object.defineProperty(Dt.prototype,\"tx\",{get:function(){return this._matrix[4]},set:function(t){this._matrix[4]=t}}),Object.defineProperty(Dt.prototype,\"ty\",{get:function(){return this._matrix[5]},set:function(t){this._matrix[5]=t}}),Object.defineProperty(Dt.prototype,\"a\",{get:function(){return this._matrix[0]},set:function(t){this._matrix[0]=t}}),Object.defineProperty(Dt.prototype,\"b\",{get:function(){return this._matrix[1]},set:function(t){this._matrix[1]=t}}),Object.defineProperty(Dt.prototype,\"c\",{get:function(){return this._matrix[2]},set:function(t){this._matrix[2]=t}}),Object.defineProperty(Dt.prototype,\"d\",{get:function(){return this._matrix[3]},set:function(t){this._matrix[3]=t}}),Object.defineProperty(Dt.prototype,\"e\",{get:function(){return this._matrix[4]},set:function(t){this._matrix[4]=t}}),Object.defineProperty(Dt.prototype,\"f\",{get:function(){return this._matrix[5]},set:function(t){this._matrix[5]=t}}),Object.defineProperty(Dt.prototype,\"rotation\",{get:function(){return Math.atan2(this.shx,this.sx)}}),Object.defineProperty(Dt.prototype,\"scaleX\",{get:function(){return this.decompose().scale.sx}}),Object.defineProperty(Dt.prototype,\"scaleY\",{get:function(){return this.decompose().scale.sy}}),Object.defineProperty(Dt.prototype,\"isIdentity\",{get:function(){return 1===this.sx&&(0===this.shy&&(0===this.shx&&(1===this.sy&&(0===this.tx&&0===this.ty))))}}),Dt.prototype.join=function(t){return[this.sx,this.shy,this.shx,this.sy,this.tx,this.ty].map(C).join(t)},Dt.prototype.multiply=function(t){var e=t.sx*this.sx+t.shy*this.shx,n=t.sx*this.shy+t.shy*this.sy,r=t.shx*this.sx+t.sy*this.shx,i=t.shx*this.shy+t.sy*this.sy,a=t.tx*this.sx+t.ty*this.shx+this.tx,o=t.tx*this.shy+t.ty*this.sy+this.ty;return new Dt(e,n,r,i,a,o)},Dt.prototype.decompose=function(){var t=this.sx,e=this.shy,n=this.shx,r=this.sy,i=this.tx,a=this.ty,o=Math.sqrt(t*t+e*e),s=(t/=o)*n+(e/=o)*r;n-=t*s,r-=e*s;var u=Math.sqrt(n*n+r*r);return s/=u,t*(r/=u)<e*(n/=u)&&(t=-t,e=-e,s=-s,o=-o),{scale:new Dt(o,0,0,u,0,0),translate:new Dt(1,0,0,1,i,a),rotate:new Dt(t,e,-e,t,0,0),skew:new Dt(1,0,s,1,0,0)}},Dt.prototype.toString=function(t){return this.join(\" \")},Dt.prototype.inversed=function(){var t=this.sx,e=this.shy,n=this.shx,r=this.sy,i=this.tx,a=this.ty,o=1/(t*r-e*n),s=r*o,u=-e*o,c=-n*o,h=t*o;return new Dt(s,u,c,h,-s*i-c*a,-u*i-h*a)},Dt.prototype.applyToPoint=function(t){var e=t.x*this.sx+t.y*this.shx+this.tx,n=t.x*this.shy+t.y*this.sy+this.ty;return new xn(e,n)},Dt.prototype.applyToRectangle=function(t){var e=this.applyToPoint(t),n=this.applyToPoint(new xn(t.x+t.w,t.y+t.h));return new An(e.x,e.y,n.x-e.x,n.y-e.y)},Dt.prototype.clone=function(){var t=this.sx,e=this.shy,n=this.shx,r=this.sy,i=this.tx,a=this.ty;return new Dt(t,e,n,r,i,a)},L.Matrix=Dt;var Ut=L.matrixMult=function(t,e){return e.multiply(t)},zt=new Dt(1,0,0,1,0,0);L.unitMatrix=L.identityMatrix=zt;var Ht=function(t,e){if(!Ft[t]){var n=(e instanceof d?\"Sh\":\"P\")+(Object.keys(kt).length+1).toString(10);e.id=n,Ft[t]=n,kt[n]=e,Mt.publish(\"addPattern\",e)}};L.ShadingPattern=d,L.TilingPattern=p,L.addShadingPattern=function(t,e){return j(\"addShadingPattern()\"),Ht(t,e),this},L.beginTilingPattern=function(t){j(\"beginTilingPattern()\"),Sn(t.boundingBox[0],t.boundingBox[1],t.boundingBox[2]-t.boundingBox[0],t.boundingBox[3]-t.boundingBox[1],t.matrix)},L.endTilingPattern=function(t,e){j(\"endTilingPattern()\"),e.stream=et[Y].join(\"\\n\"),Ht(t,e),Mt.publish(\"endTilingPattern\",e),Tt.pop().restore()};var Wt=L.__private__.newObject=function(){var t=Vt();return Gt(t,!0),t},Vt=L.__private__.newObjectDeferred=function(){return K++,Z[K]=function(){return Q},K},Gt=function(t,e){return e=\"boolean\"==typeof e&&e,Z[t]=Q,e&&ot(t+\" 0 obj\"),t},Yt=L.__private__.newAdditionalObject=function(){var t={objId:Vt(),content:\"\"};return tt.push(t),t},Jt=Vt(),Xt=Vt(),Kt=L.__private__.decodeColorString=function(t){var e=t.split(\" \");if(2!==e.length||\"g\"!==e[1]&&\"G\"!==e[1]){if(5===e.length&&(\"k\"===e[4]||\"K\"===e[4])){e=[(1-e[0])*(1-e[3]),(1-e[1])*(1-e[3]),(1-e[2])*(1-e[3]),\"r\"]}}else{var n=parseFloat(e[0]);e=[n,n,n,\"r\"]}for(var r=\"#\",i=0;i<3;i++)r+=(\"0\"+Math.floor(255*parseFloat(e[i])).toString(16)).slice(-2);return r},Zt=L.__private__.encodeColorString=function(t){var e;\"string\"==typeof t&&(t={ch1:t});var n=t.ch1,r=t.ch2,i=t.ch3,a=t.ch4,o=\"draw\"===t.pdfColorType?[\"G\",\"RG\",\"K\"]:[\"g\",\"rg\",\"k\"];if(\"string\"==typeof n&&\"#\"!==n.charAt(0)){var s=new c(n);if(s.ok)n=s.toHex();else if(!/^\\d*\\.?\\d*$/.test(n))throw new Error('Invalid color \"'+n+'\" passed to jsPDF.encodeColorString.')}if(\"string\"==typeof n&&/^#[0-9A-Fa-f]{3}$/.test(n)&&(n=\"#\"+n[1]+n[1]+n[2]+n[2]+n[3]+n[3]),\"string\"==typeof n&&/^#[0-9A-Fa-f]{6}$/.test(n)){var u=parseInt(n.substr(1),16);n=u>>16&255,r=u>>8&255,i=255&u}if(void 0===r||void 0===a&&n===r&&r===i)if(\"string\"==typeof n)e=n+\" \"+o[0];else switch(t.precision){case 2:e=O(n/255)+\" \"+o[0];break;case 3:default:e=M(n/255)+\" \"+o[0]}else if(void 0===a||\"object\"==typeof a){if(a&&!isNaN(a.a)&&0===a.a)return e=[\"1.\",\"1.\",\"1.\",o[1]].join(\" \");if(\"string\"==typeof n)e=[n,r,i,o[1]].join(\" \");else switch(t.precision){case 2:e=[O(n/255),O(r/255),O(i/255),o[1]].join(\" \");break;default:case 3:e=[M(n/255),M(r/255),M(i/255),o[1]].join(\" \")}}else if(\"string\"==typeof n)e=[n,r,i,a,o[2]].join(\" \");else switch(t.precision){case 2:e=[O(n),O(r),O(i),O(a),o[2]].join(\" \");break;case 3:default:e=[M(n),M(r),M(i),M(a),o[2]].join(\" \")}return e},$t=L.__private__.getFilters=function(){return m},Qt=L.__private__.putStream=function(t){var e=(t=t||{}).data||\"\",n=t.filters||$t(),r=t.alreadyAppliedFilters||[],i=t.addLength1||!1,a=e.length,o={};!0===n&&(n=[\"FlateEncode\"]);var s=t.additionalKeyValues||[],u=(o=void 0!==g.API.processDataByFilters?g.API.processDataByFilters(e,n):{data:e,reverseChain:[]}).reverseChain+(Array.isArray(r)?r.join(\" \"):r.toString());if(0!==o.data.length&&(s.push({key:\"Length\",value:o.data.length}),!0===i&&s.push({key:\"Length1\",value:a})),0!=u.length)if(u.split(\"/\").length-1==1)s.push({key:\"Filter\",value:u});else{s.push({key:\"Filter\",value:\"[\"+u+\"]\"});for(var c=0;c<s.length;c+=1)if(\"DecodeParms\"===s[c].key){for(var h=[],l=0;l<o.reverseChain.split(\"/\").length-1;l+=1)h.push(\"null\");h.push(s[c].value),s[c].value=\"[\"+h.join(\" \")+\"]\"}}ot(\"<<\");for(var f=0;f<s.length;f++)ot(\"/\"+s[f].key+\" \"+s[f].value);ot(\">>\"),0!==o.data.length&&(ot(\"stream\"),ot(o.data),ot(\"endstream\"))},te=L.__private__.putPage=function(t){var e=t.number,n=t.data,r=t.objId,i=t.contentsObjId;Gt(r,!0),ot(\"<</Type /Page\"),ot(\"/Parent \"+t.rootDictionaryObjId+\" 0 R\"),ot(\"/Resources \"+t.resourceDictionaryObjId+\" 0 R\"),ot(\"/MediaBox [\"+parseFloat(C(t.mediaBox.bottomLeftX))+\" \"+parseFloat(C(t.mediaBox.bottomLeftY))+\" \"+C(t.mediaBox.topRightX)+\" \"+C(t.mediaBox.topRightY)+\"]\"),null!==t.cropBox&&ot(\"/CropBox [\"+C(t.cropBox.bottomLeftX)+\" \"+C(t.cropBox.bottomLeftY)+\" \"+C(t.cropBox.topRightX)+\" \"+C(t.cropBox.topRightY)+\"]\"),null!==t.bleedBox&&ot(\"/BleedBox [\"+C(t.bleedBox.bottomLeftX)+\" \"+C(t.bleedBox.bottomLeftY)+\" \"+C(t.bleedBox.topRightX)+\" \"+C(t.bleedBox.topRightY)+\"]\"),null!==t.trimBox&&ot(\"/TrimBox [\"+C(t.trimBox.bottomLeftX)+\" \"+C(t.trimBox.bottomLeftY)+\" \"+C(t.trimBox.topRightX)+\" \"+C(t.trimBox.topRightY)+\"]\"),null!==t.artBox&&ot(\"/ArtBox [\"+C(t.artBox.bottomLeftX)+\" \"+C(t.artBox.bottomLeftY)+\" \"+C(t.artBox.topRightX)+\" \"+C(t.artBox.topRightY)+\"]\"),\"number\"==typeof t.userUnit&&1!==t.userUnit&&ot(\"/UserUnit \"+t.userUnit),Mt.publish(\"putPage\",{objId:r,pageContext:Ot[e],pageNumber:e,page:n}),ot(\"/Contents \"+i+\" 0 R\"),ot(\">>\"),ot(\"endobj\");var a=n.join(\"\\n\");return k===P.ADVANCED&&(a+=\"\\nQ\"),Gt(i,!0),Qt({data:a,filters:$t()}),ot(\"endobj\"),r},ee=L.__private__.putPages=function(){var t,e,n=[];for(t=1;t<=Bt;t++)Ot[t].objId=Vt(),Ot[t].contentsObjId=Vt();for(t=1;t<=Bt;t++)n.push(te({number:t,data:et[t],objId:Ot[t].objId,contentsObjId:Ot[t].contentsObjId,mediaBox:Ot[t].mediaBox,cropBox:Ot[t].cropBox,bleedBox:Ot[t].bleedBox,trimBox:Ot[t].trimBox,artBox:Ot[t].artBox,userUnit:Ot[t].userUnit,rootDictionaryObjId:Jt,resourceDictionaryObjId:Xt}));Gt(Jt,!0),ot(\"<</Type /Pages\");var r=\"/Kids [\";for(e=0;e<Bt;e++)r+=n[e]+\" 0 R \";ot(r+\"]\"),ot(\"/Count \"+Bt),ot(\">>\"),ot(\"endobj\"),Mt.publish(\"postPutPages\")},ne=function(t){var e=function(t,e){return-1!==t.indexOf(\" \")?\"(\"+_e(t,e)+\")\":_e(t,e)};Mt.publish(\"putFont\",{font:t,out:ot,newObject:Wt,putStream:Qt,pdfEscapeWithNeededParanthesis:e}),!0!==t.isAlreadyPutted&&(t.objectNumber=Wt(),ot(\"<<\"),ot(\"/Type /Font\"),ot(\"/BaseFont /\"+e(t.postScriptName)),ot(\"/Subtype /Type1\"),\"string\"==typeof t.encoding&&ot(\"/Encoding /\"+t.encoding),ot(\"/FirstChar 32\"),ot(\"/LastChar 255\"),ot(\">>\"),ot(\"endobj\"))},re=function(){for(var t in _t)_t.hasOwnProperty(t)&&(!1===w||!0===w&&N.hasOwnProperty(t))&&ne(_t[t])},ie=function(t){t.objectNumber=Wt();var e=[];e.push({key:\"Type\",value:\"/XObject\"}),e.push({key:\"Subtype\",value:\"/Form\"}),e.push({key:\"BBox\",value:\"[\"+[C(t.x),C(t.y),C(t.x+t.width),C(t.y+t.height)].join(\" \")+\"]\"}),e.push({key:\"Matrix\",value:\"[\"+t.matrix.toString()+\"]\"});var n=t.pages[1].join(\"\\n\");Qt({data:n,additionalKeyValues:e}),ot(\"endobj\")},ae=function(){for(var t in qt)qt.hasOwnProperty(t)&&ie(qt[t])},oe=function(t,e){var n,r=[],i=1/(e-1);for(n=0;n<1;n+=i)r.push(n);if(r.push(1),0!=t[0].offset){var a={offset:0,color:t[0].color};t.unshift(a)}if(1!=t[t.length-1].offset){var o={offset:1,color:t[t.length-1].color};t.push(o)}for(var s=\"\",u=0,c=0;c<r.length;c++){for(n=r[c];n>t[u+1].offset;)u++;var h=t[u].offset,l=(n-h)/(t[u+1].offset-h),f=t[u].color,d=t[u+1].color;s+=X(Math.round((1-l)*f[0]+l*d[0]).toString(16))+X(Math.round((1-l)*f[1]+l*d[1]).toString(16))+X(Math.round((1-l)*f[2]+l*d[2]).toString(16))}return s.trim()},se=function(t,e){e||(e=21);var n=Wt(),r=oe(t.colors,e),i=[];i.push({key:\"FunctionType\",value:\"0\"}),i.push({key:\"Domain\",value:\"[0.0 1.0]\"}),i.push({key:\"Size\",value:\"[\"+e+\"]\"}),i.push({key:\"BitsPerSample\",value:\"8\"}),i.push({key:\"Range\",value:\"[0.0 1.0 0.0 1.0 0.0 1.0]\"}),i.push({key:\"Decode\",value:\"[0.0 1.0 0.0 1.0 0.0 1.0]\"}),Qt({data:r,additionalKeyValues:i,alreadyAppliedFilters:[\"/ASCIIHexDecode\"]}),ot(\"endobj\"),t.objectNumber=Wt(),ot(\"<< /ShadingType \"+t.type),ot(\"/ColorSpace /DeviceRGB\");var a=\"/Coords [\"+C(parseFloat(t.coords[0]))+\" \"+C(parseFloat(t.coords[1]))+\" \";2===t.type?a+=C(parseFloat(t.coords[2]))+\" \"+C(parseFloat(t.coords[3])):a+=C(parseFloat(t.coords[2]))+\" \"+C(parseFloat(t.coords[3]))+\" \"+C(parseFloat(t.coords[4]))+\" \"+C(parseFloat(t.coords[5])),ot(a+=\"]\"),t.matrix&&ot(\"/Matrix [\"+t.matrix.toString()+\"]\"),ot(\"/Function \"+n+\" 0 R\"),ot(\"/Extend [true true]\"),ot(\">>\"),ot(\"endobj\")},ue=function(t,e){var n=Vt(),r=Wt();e.push({resourcesOid:n,objectOid:r}),t.objectNumber=r;var i=[];i.push({key:\"Type\",value:\"/Pattern\"}),i.push({key:\"PatternType\",value:\"1\"}),i.push({key:\"PaintType\",value:\"1\"}),i.push({key:\"TilingType\",value:\"1\"}),i.push({key:\"BBox\",value:\"[\"+t.boundingBox.map(C).join(\" \")+\"]\"}),i.push({key:\"XStep\",value:C(t.xStep)}),i.push({key:\"YStep\",value:C(t.yStep)}),i.push({key:\"Resources\",value:n+\" 0 R\"}),t.matrix&&i.push({key:\"Matrix\",value:\"[\"+t.matrix.toString()+\"]\"}),Qt({data:t.stream,additionalKeyValues:i}),ot(\"endobj\")},ce=function(t){var e;for(e in kt)kt.hasOwnProperty(e)&&(kt[e]instanceof d?se(kt[e]):kt[e]instanceof p&&ue(kt[e],t))},he=function(t){for(var e in t.objectNumber=Wt(),ot(\"<<\"),t)switch(e){case\"opacity\":ot(\"/ca \"+O(t[e]));break;case\"stroke-opacity\":ot(\"/CA \"+O(t[e]))}ot(\">>\"),ot(\"endobj\")},le=function(){var t;for(t in It)It.hasOwnProperty(t)&&he(It[t])},fe=function(){for(var t in ot(\"/XObject <<\"),qt)qt.hasOwnProperty(t)&&qt[t].objectNumber>=0&&ot(\"/\"+t+\" \"+qt[t].objectNumber+\" 0 R\");Mt.publish(\"putXobjectDict\"),ot(\">>\")},de=function(){for(var t in ot(\"/Font <<\"),_t)_t.hasOwnProperty(t)&&(!1===w||!0===w&&N.hasOwnProperty(t))&&ot(\"/\"+t+\" \"+_t[t].objectNumber+\" 0 R\");ot(\">>\")},pe=function(){if(Object.keys(kt).length>0){for(var t in ot(\"/Shading <<\"),kt)kt.hasOwnProperty(t)&&kt[t]instanceof d&&kt[t].objectNumber>=0&&ot(\"/\"+t+\" \"+kt[t].objectNumber+\" 0 R\");Mt.publish(\"putShadingPatternDict\"),ot(\">>\")}},ge=function(t){if(Object.keys(kt).length>0){for(var e in ot(\"/Pattern <<\"),kt)kt.hasOwnProperty(e)&&kt[e]instanceof L.TilingPattern&&kt[e].objectNumber>=0&&kt[e].objectNumber<t&&ot(\"/\"+e+\" \"+kt[e].objectNumber+\" 0 R\");Mt.publish(\"putTilingPatternDict\"),ot(\">>\")}},me=function(){if(Object.keys(It).length>0){var t;for(t in ot(\"/ExtGState <<\"),It)It.hasOwnProperty(t)&&It[t].objectNumber>=0&&ot(\"/\"+t+\" \"+It[t].objectNumber+\" 0 R\");Mt.publish(\"putGStateDict\"),ot(\">>\")}},ve=function(t){Gt(t.resourcesOid,!0),ot(\"<<\"),ot(\"/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\"),de(),pe(),ge(t.objectOid),me(),fe(),ot(\">>\"),ot(\"endobj\")},be=function(){var t=[];re(),le(),ae(),ce(t),Mt.publish(\"putResources\"),t.forEach(ve),ve({resourcesOid:Xt,objectOid:Number.MAX_SAFE_INTEGER}),Mt.publish(\"postPutResources\")},ye=function(){Mt.publish(\"putAdditionalObjects\");for(var t=0;t<tt.length;t++){var e=tt[t];Gt(e.objId,!0),ot(e.content),ot(\"endobj\")}Mt.publish(\"postPutAdditionalObjects\")},we=function(t){St[t.fontName]=St[t.fontName]||{},St[t.fontName][t.fontStyle]=t.id},Ne=function(t,e,n,r,i){var a={id:\"F\"+(Object.keys(_t).length+1).toString(10),postScriptName:t,fontName:e,fontStyle:n,encoding:r,isStandardFont:i||!1,metadata:{}};return Mt.publish(\"addFont\",{font:a,instance:this}),_t[a.id]=a,we(a),a.id},Le=function(t){for(var e=0,n=ct.length;e<n;e++){var r=Ne.call(this,t[e][0],t[e][1],t[e][2],ct[e][3],!0);!1===w&&(N[r]=!0);var i=t[e][0].split(\"-\");we({id:r,fontName:i[0],fontStyle:i[1]||\"\"})}Mt.publish(\"addFonts\",{fonts:_t,dictionary:St})},xe=function(e){return e.foo=function(){try{return e.apply(this,arguments)}catch(e){var n=e.stack||\"\";~n.indexOf(\" at \")&&(n=n.split(\" at \")[1]);var r=\"Error in function \"+n.split(\"\\n\")[0].split(\"<\")[0]+\": \"+e.message;if(!t.console)throw new Error(r);t.console.error(r,e),t.alert&&alert(r)}},e.foo.bar=e,e.foo},Ae=function(t,e){var n,r,i,a,o,s,u,c,h;if(i=(e=e||{}).sourceEncoding||\"Unicode\",o=e.outputEncoding,(e.autoencode||o)&&_t[wt].metadata&&_t[wt].metadata[i]&&_t[wt].metadata[i].encoding&&(a=_t[wt].metadata[i].encoding,!o&&_t[wt].encoding&&(o=_t[wt].encoding),!o&&a.codePages&&(o=a.codePages[0]),\"string\"==typeof o&&(o=a[o]),o)){for(u=!1,s=[],n=0,r=t.length;n<r;n++)(c=o[t.charCodeAt(n)])?s.push(String.fromCharCode(c)):s.push(t[n]),s[n].charCodeAt(0)>>8&&(u=!0);t=s.join(\"\")}for(n=t.length;void 0===u&&0!==n;)t.charCodeAt(n-1)>>8&&(u=!0),n--;if(!u)return t;for(s=e.noBOM?[]:[254,255],n=0,r=t.length;n<r;n++){if((h=(c=t.charCodeAt(n))>>8)>>8)throw new Error(\"Character at position \"+n+\" of string '\"+t+\"' exceeds 16bits. Cannot be encoded into UCS-2 BE\");s.push(h),s.push(c-(h<<8))}return String.fromCharCode.apply(void 0,s)},_e=L.__private__.pdfEscape=L.pdfEscape=function(t,e){return Ae(t,e).replace(/\\\\/g,\"\\\\\\\\\").replace(/\\(/g,\"\\\\(\").replace(/\\)/g,\"\\\\)\")},Se=L.__private__.beginPage=function(t){et[++Bt]=[],Ot[Bt]={objId:0,contentsObjId:0,userUnit:Number(v),artBox:null,bleedBox:null,cropBox:null,trimBox:null,mediaBox:{bottomLeftX:0,bottomLeftY:0,topRightX:Number(t[0]),topRightY:Number(t[1])}},Fe(Bt),at(et[Y])},Pe=function(t,e){var r,a,s;switch(i=e||i,\"string\"==typeof t&&(r=S(t.toLowerCase()),Array.isArray(r)&&(a=r[0],s=r[1])),Array.isArray(t)&&(a=t[0]*Nt,s=t[1]*Nt),isNaN(a)&&(a=o[0],s=o[1]),(a>14400||s>14400)&&(n.warn(\"A page in a PDF can not be wider or taller than 14400 userUnit. jsPDF limits the width/height to 14400\"),a=Math.min(14400,a),s=Math.min(14400,s)),o=[a,s],i.substr(0,1)){case\"l\":s>a&&(o=[s,a]);break;case\"p\":a>s&&(o=[s,a])}Se(o),on(an),ot(pn),0!==wn&&ot(wn+\" J\"),0!==Nn&&ot(Nn+\" j\"),Mt.publish(\"addPage\",{pageNumber:Bt})},ke=function(t){t>0&&t<=Bt&&(et.splice(t,1),Ot.splice(t,1),Bt--,Y>Bt&&(Y=Bt),this.setPage(Y))},Fe=function(t){t>0&&t<=Bt&&(Y=t)},Ie=L.__private__.getNumberOfPages=L.getNumberOfPages=function(){return et.length-1},Ce=function(t,e,r){var i,a=void 0;return r=r||{},t=void 0!==t?t:_t[wt].fontName,e=void 0!==e?e:_t[wt].fontStyle,i=t.toLowerCase(),void 0!==St[i]&&void 0!==St[i][e]?a=St[i][e]:void 0!==St[t]&&void 0!==St[t][e]?a=St[t][e]:!1===r.disableWarning&&n.warn(\"Unable to look up font label for font '\"+t+\"', '\"+e+\"'. Refer to getFontList() for available fonts.\"),a||r.noFallback||null==(a=St.times[e])&&(a=St.times.normal),a},je=L.__private__.putInfo=function(){for(var t in Wt(),ot(\"<<\"),ot(\"/Producer (jsPDF \"+g.version+\")\"),yt)yt.hasOwnProperty(t)&&yt[t]&&ot(\"/\"+t.substr(0,1).toUpperCase()+t.substr(1)+\" (\"+_e(yt[t])+\")\");ot(\"/CreationDate (\"+T+\")\"),ot(\">>\"),ot(\"endobj\")},Be=L.__private__.putCatalog=function(t){var e=(t=t||{}).rootDictionaryObjId||Jt;switch(Wt(),ot(\"<<\"),ot(\"/Type /Catalog\"),ot(\"/Pages \"+e+\" 0 R\"),lt||(lt=\"fullwidth\"),lt){case\"fullwidth\":ot(\"/OpenAction [3 0 R /FitH null]\");break;case\"fullheight\":ot(\"/OpenAction [3 0 R /FitV null]\");break;case\"fullpage\":ot(\"/OpenAction [3 0 R /Fit]\");break;case\"original\":ot(\"/OpenAction [3 0 R /XYZ null null 1]\");break;default:var n=\"\"+lt;\"%\"===n.substr(n.length-1)&&(lt=parseInt(lt)/100),\"number\"==typeof lt&&ot(\"/OpenAction [3 0 R /XYZ null null \"+O(lt)+\"]\")}switch(mt||(mt=\"continuous\"),mt){case\"continuous\":ot(\"/PageLayout /OneColumn\");break;case\"single\":ot(\"/PageLayout /SinglePage\");break;case\"two\":case\"twoleft\":ot(\"/PageLayout /TwoColumnLeft\");break;case\"tworight\":ot(\"/PageLayout /TwoColumnRight\")}pt&&ot(\"/PageMode /\"+pt),Mt.publish(\"putCatalog\"),ot(\">>\"),ot(\"endobj\")},Oe=L.__private__.putTrailer=function(){ot(\"trailer\"),ot(\"<<\"),ot(\"/Size \"+(K+1)),ot(\"/Root \"+K+\" 0 R\"),ot(\"/Info \"+(K-1)+\" 0 R\"),ot(\"/ID [ <\"+D+\"> <\"+D+\"> ]\"),ot(\">>\")},Me=L.__private__.putHeader=function(){ot(\"%PDF-\"+x),ot(\"%ºß¬à\")},Ee=L.__private__.putXRef=function(){var t=\"0000000000\";ot(\"xref\"),ot(\"0 \"+(K+1)),ot(\"0000000000 65535 f \");for(var e=1;e<=K;e++){\"function\"==typeof Z[e]?ot((t+Z[e]()).slice(-10)+\" 00000 n \"):void 0!==Z[e]?ot((t+Z[e]).slice(-10)+\" 00000 n \"):ot(\"0000000000 00000 n \")}},qe=L.__private__.buildDocument=function(){it(),at($),Mt.publish(\"buildDocument\"),Me(),ee(),ye(),be(),je(),Be();var t=Q;return Ee(),Oe(),ot(\"startxref\"),ot(\"\"+t),ot(\"%%EOF\"),at(et[Y]),$.join(\"\\n\")},Re=L.__private__.getBlob=function(t){return new Blob([ut(t)],{type:\"application/pdf\"})},Te=L.output=L.__private__.output=xe((function(e,r){switch(\"string\"==typeof(r=r||{})?r={filename:r}:r.filename=r.filename||\"generated.pdf\",e){case void 0:return qe();case\"save\":L.save(r.filename);break;case\"arraybuffer\":return ut(qe());case\"blob\":return Re(qe());case\"bloburi\":case\"bloburl\":if(void 0!==t.URL&&\"function\"==typeof t.URL.createObjectURL)return t.URL&&t.URL.createObjectURL(Re(qe()))||void 0;n.warn(\"bloburl is not supported by your system, because URL.createObjectURL is not supported by your browser.\");break;case\"datauristring\":case\"dataurlstring\":var i=\"\",a=qe();try{i=s(a)}catch(t){i=s(unescape(encodeURIComponent(a)))}return\"data:application/pdf;filename=\"+r.filename+\";base64,\"+i;case\"pdfobjectnewwindow\":if(\"[object Window]\"===Object.prototype.toString.call(t)){var o='<html><style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;} </style><body><script src=\"'+(r.pdfObjectUrl||\"https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js\")+'\"><\\/script><script >PDFObject.embed(\"'+this.output(\"dataurlstring\")+'\", '+JSON.stringify(r)+\");<\\/script></body></html>\",u=t.open();return null!==u&&u.document.write(o),u}throw new Error(\"The option pdfobjectnewwindow just works in a browser-environment.\");case\"pdfjsnewwindow\":if(\"[object Window]\"===Object.prototype.toString.call(t)){var c='<html><style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;} </style><body><iframe id=\"pdfViewer\" src=\"'+(r.pdfJsUrl||\"examples/PDF.js/web/viewer.html\")+\"?file=&downloadName=\"+r.filename+'\" width=\"500px\" height=\"400px\" /></body></html>',h=t.open();if(null!==h){h.document.write(c);var l=this;h.document.documentElement.querySelector(\"#pdfViewer\").onload=function(){h.document.title=r.filename,h.document.documentElement.querySelector(\"#pdfViewer\").contentWindow.PDFViewerApplication.open(l.output(\"bloburl\"))}}return h}throw new Error(\"The option pdfjsnewwindow just works in a browser-environment.\");case\"dataurlnewwindow\":if(\"[object Window]\"!==Object.prototype.toString.call(t))throw new Error(\"The option dataurlnewwindow just works in a browser-environment.\");var f='<html><style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;} </style><body><iframe src=\"'+this.output(\"datauristring\",r)+'\"></iframe></body></html>',d=t.open();if(null!==d&&(d.document.write(f),d.document.title=r.filename),d||\"undefined\"==typeof safari)return d;break;case\"datauri\":case\"dataurl\":return t.document.location.href=this.output(\"datauristring\",r);default:return null}})),De=function(t){return!0===Array.isArray(Et)&&Et.indexOf(t)>-1};switch(a){case\"pt\":Nt=1;break;case\"mm\":Nt=72/25.4;break;case\"cm\":Nt=72/2.54;break;case\"in\":Nt=72;break;case\"px\":Nt=1==De(\"px_scaling\")?.75:96/72;break;case\"pc\":case\"em\":Nt=12;break;case\"ex\":Nt=6;break;default:throw new Error(\"Invalid unit: \"+a)}V(),z();var Ue=L.__private__.getPageInfo=L.getPageInfo=function(t){if(isNaN(t)||t%1!=0)throw new Error(\"Invalid argument passed to jsPDF.getPageInfo\");return{objId:Ot[t].objId,pageNumber:t,pageContext:Ot[t]}},ze=L.__private__.getPageInfoByObjId=function(t){if(isNaN(t)||t%1!=0)throw new Error(\"Invalid argument passed to jsPDF.getPageInfoByObjId\");for(var e in Ot)if(Ot[e].objId===t)break;return Ue(e)},He=L.__private__.getCurrentPageInfo=L.getCurrentPageInfo=function(){return{objId:Ot[Y].objId,pageNumber:Y,pageContext:Ot[Y]}};L.addPage=function(){return Pe.apply(this,arguments),this},L.setPage=function(){return Fe.apply(this,arguments),at.call(this,et[Y]),this},L.insertPage=function(t){return this.addPage(),this.movePage(Y,t),this},L.movePage=function(t,e){var n,r;if(t>e){n=et[t],r=Ot[t];for(var i=t;i>e;i--)et[i]=et[i-1],Ot[i]=Ot[i-1];et[e]=n,Ot[e]=r,this.setPage(e)}else if(t<e){n=et[t],r=Ot[t];for(var a=t;a<e;a++)et[a]=et[a+1],Ot[a]=Ot[a+1];et[e]=n,Ot[e]=r,this.setPage(e)}return this},L.deletePage=function(){return ke.apply(this,arguments),this},L.__private__.text=L.text=function(t,e,n,r,i){var a,o,s,u,c,h,l,f,d=(r=r||{}).scope||this;if(\"number\"==typeof t&&\"number\"==typeof e&&(\"string\"==typeof n||Array.isArray(n))){var p=n;n=e,e=t,t=p}if(arguments[3]instanceof Dt==!1?(s=arguments[4],u=arguments[5],\"object\"==typeof(l=arguments[3])&&null!==l||(\"string\"==typeof s&&(u=s,s=null),\"string\"==typeof l&&(u=l,l=null),\"number\"==typeof l&&(s=l,l=null),r={flags:l,angle:s,align:u})):(j(\"The transform parameter of text() with a Matrix value\"),f=i),isNaN(e)||isNaN(n)||null==t)throw new Error(\"Invalid arguments passed to jsPDF.text\");if(0===t.length)return d;var g=\"\",m=!1,v=\"number\"==typeof r.lineHeightFactor?r.lineHeightFactor:rn,b=d.internal.scaleFactor;function y(t){return t=t.split(\"\\t\").join(Array(r.TabLen||9).join(\" \")),_e(t,l)}function w(t){for(var e,n=t.concat(),r=[],i=n.length;i--;)\"string\"==typeof(e=n.shift())?r.push(e):Array.isArray(t)&&(1===e.length||void 0===e[1]&&void 0===e[2])?r.push(e[0]):r.push([e[0],e[1],e[2]]);return r}function L(t,e){var n;if(\"string\"==typeof t)n=e(t)[0];else if(Array.isArray(t)){for(var r,i,a=t.concat(),o=[],s=a.length;s--;)\"string\"==typeof(r=a.shift())?o.push(e(r)[0]):Array.isArray(r)&&\"string\"==typeof r[0]&&(i=e(r[0],r[1],r[2]),o.push([i[0],i[1],i[2]]));n=o}return n}var x=!1,A=!0;if(\"string\"==typeof t)x=!0;else if(Array.isArray(t)){var _=t.concat();o=[];for(var S,F=_.length;F--;)(\"string\"!=typeof(S=_.shift())||Array.isArray(S)&&\"string\"!=typeof S[0])&&(A=!1);x=A}if(!1===x)throw new Error('Type of text must be string or Array. \"'+t+'\" is not recognized.');\"string\"==typeof t&&(t=t.match(/[\\r?\\n]/)?t.split(/\\r\\n|\\r|\\n/g):[t]);var I=ht/d.internal.scaleFactor,B=I*(rn-1);switch(r.baseline){case\"bottom\":n-=B;break;case\"top\":n+=I-B;break;case\"hanging\":n+=I-2*B;break;case\"middle\":n+=I/2-B}if((h=r.maxWidth||0)>0&&(\"string\"==typeof t?t=d.splitTextToSize(t,h):\"[object Array]\"===Object.prototype.toString.call(t)&&(t=d.splitTextToSize(t.join(\" \"),h))),a={text:t,x:e,y:n,options:r,mutex:{pdfEscape:_e,activeFontKey:wt,fonts:_t,activeFontSize:ht}},Mt.publish(\"preProcessText\",a),t=a.text,s=(r=a.options).angle,f instanceof Dt==!1&&s&&\"number\"==typeof s){s*=Math.PI/180,0===r.rotationDirection&&(s=-s),k===P.ADVANCED&&(s=-s);var O=Math.cos(s),M=Math.sin(s);f=new Dt(O,M,-M,O,0,0)}else s&&s instanceof Dt&&(f=s);k!==P.ADVANCED||f||(f=zt),void 0!==(c=r.charSpace||bn)&&(g+=C(E(c))+\" Tc\\n\",this.setCharSpace(this.getCharSpace()||0));r.lang;var q=-1,R=void 0!==r.renderingMode?r.renderingMode:r.stroke,T=d.internal.getCurrentPageInfo().pageContext;switch(R){case 0:case!1:case\"fill\":q=0;break;case 1:case!0:case\"stroke\":q=1;break;case 2:case\"fillThenStroke\":q=2;break;case 3:case\"invisible\":q=3;break;case 4:case\"fillAndAddForClipping\":q=4;break;case 5:case\"strokeAndAddPathForClipping\":q=5;break;case 6:case\"fillThenStrokeAndAddToPathForClipping\":q=6;break;case 7:case\"addToPathForClipping\":q=7}var D=void 0!==T.usedRenderingMode?T.usedRenderingMode:-1;-1!==q?g+=q+\" Tr\\n\":-1!==D&&(g+=\"0 Tr\\n\"),-1!==q&&(T.usedRenderingMode=q),u=r.align||\"left\";var U,z=ht*v,H=d.internal.pageSize.getWidth(),W=_t[wt];c=r.charSpace||bn,h=r.maxWidth||0,l={};var V=[];if(\"[object Array]\"===Object.prototype.toString.call(t)){var G;o=w(t),\"left\"!==u&&(U=o.map((function(t){return d.getStringUnitWidth(t,{font:W,charSpace:c,fontSize:ht,doKerning:!1})*ht/b})));var Y,J=0;if(\"right\"===u){e-=U[0],t=[],F=o.length;for(var X=0;X<F;X++)0===X?(Y=hn(e),G=ln(n)):(Y=E(J-U[X]),G=-z),t.push([o[X],Y,G]),J=U[X]}else if(\"center\"===u){e-=U[0]/2,t=[],F=o.length;for(var K=0;K<F;K++)0===K?(Y=hn(e),G=ln(n)):(Y=E((J-U[K])/2),G=-z),t.push([o[K],Y,G]),J=U[K]}else if(\"left\"===u){t=[],F=o.length;for(var Z=0;Z<F;Z++)t.push(o[Z])}else{if(\"justify\"!==u)throw new Error('Unrecognized alignment option, use \"left\", \"center\", \"right\" or \"justify\".');t=[],F=o.length,h=0!==h?h:H;for(var $=0;$<F;$++)G=0===$?ln(n):-z,Y=0===$?hn(e):0,$<F-1&&V.push(C(E((h-U[$])/(o[$].split(\" \").length-1)))),t.push([o[$],Y,G])}}var Q=\"boolean\"==typeof r.R2L?r.R2L:dt;!0===Q&&(t=L(t,(function(t,e,n){return[t.split(\"\").reverse().join(\"\"),e,n]}))),a={text:t,x:e,y:n,options:r,mutex:{pdfEscape:_e,activeFontKey:wt,fonts:_t,activeFontSize:ht}},Mt.publish(\"postProcessText\",a),t=a.text,m=a.mutex.isHex||!1;var tt=_t[wt].encoding;\"WinAnsiEncoding\"!==tt&&\"StandardEncoding\"!==tt||(t=L(t,(function(t,e,n){return[y(t),e,n]}))),o=w(t),t=[];for(var et,nt,rt,it=0,at=1,st=Array.isArray(o[0])?at:it,ut=\"\",ct=function(t,e,n){var i=\"\";return n instanceof Dt?(n=\"number\"==typeof r.angle?Ut(n,new Dt(1,0,0,1,t,e)):Ut(new Dt(1,0,0,1,t,e),n),k===P.ADVANCED&&(n=Ut(new Dt(1,0,0,-1,0,0),n)),i=n.join(\" \")+\" Tm\\n\"):i=C(t)+\" \"+C(e)+\" Td\\n\",i},lt=0;lt<o.length;lt++){switch(ut=\"\",st){case at:rt=(m?\"<\":\"(\")+o[lt][0]+(m?\">\":\")\"),et=parseFloat(o[lt][1]),nt=parseFloat(o[lt][2]);break;case it:rt=(m?\"<\":\"(\")+o[lt]+(m?\">\":\")\"),et=hn(e),nt=ln(n)}void 0!==V&&void 0!==V[lt]&&(ut=V[lt]+\" Tw\\n\"),0===lt?t.push(ut+ct(et,nt,f)+rt):st===it?t.push(ut+rt):st===at&&t.push(ut+ct(et,nt,f)+rt)}t=st===it?t.join(\" Tj\\nT* \"):t.join(\" Tj\\n\"),t+=\" Tj\\n\";var ft=\"BT\\n/\";return ft+=wt+\" \"+ht+\" Tf\\n\",ft+=C(ht*v)+\" TL\\n\",ft+=mn+\"\\n\",ft+=g,ft+=t,ot(ft+=\"ET\"),N[wt]=!0,d};var We=L.__private__.clip=L.clip=function(t){return ot(\"evenodd\"===t?\"W*\":\"W\"),this};L.clipEvenOdd=function(){return We(\"evenodd\")},L.__private__.discardPath=L.discardPath=function(){return ot(\"n\"),this};var Ve=L.__private__.isValidStyle=function(t){var e=!1;return-1!==[void 0,null,\"S\",\"D\",\"F\",\"DF\",\"FD\",\"f\",\"f*\",\"B\",\"B*\",\"n\"].indexOf(t)&&(e=!0),e};L.__private__.setDefaultPathOperation=L.setDefaultPathOperation=function(t){return Ve(t)&&(y=t),this};var Ge=L.__private__.getStyle=L.getStyle=function(t){var e=y;switch(t){case\"D\":case\"S\":e=\"S\";break;case\"F\":e=\"f\";break;case\"FD\":case\"DF\":e=\"B\";break;case\"f\":case\"f*\":case\"B\":case\"B*\":e=t}return e},Ye=L.close=function(){return ot(\"h\"),this};L.stroke=function(){return ot(\"S\"),this},L.fill=function(t){return Je(\"f\",t),this},L.fillEvenOdd=function(t){return Je(\"f*\",t),this},L.fillStroke=function(t){return Je(\"B\",t),this},L.fillStrokeEvenOdd=function(t){return Je(\"B*\",t),this};var Je=function(t,e){\"object\"==typeof e?Ze(e,t):ot(t)},Xe=function(t){null===t||k===P.ADVANCED&&void 0===t||(t=Ge(t),ot(t))};function Ke(t,e,n,r,i){var a=new p(e||this.boundingBox,n||this.xStep,r||this.yStep,this.gState,i||this.matrix);a.stream=this.stream;var o=t+\"$$\"+this.cloneIndex+++\"$$\";return Ht(o,a),a}var Ze=function(t,e){var n=Ft[t.key],r=kt[n];if(r instanceof d)ot(\"q\"),ot($e(e)),r.gState&&L.setGState(r.gState),ot(t.matrix.toString()+\" cm\"),ot(\"/\"+n+\" sh\"),ot(\"Q\");else if(r instanceof p){var i=new Dt(1,0,0,-1,0,Cn());t.matrix&&(i=i.multiply(t.matrix||zt),n=Ke.call(r,t.key,t.boundingBox,t.xStep,t.yStep,i).id),ot(\"q\"),ot(\"/Pattern cs\"),ot(\"/\"+n+\" scn\"),r.gState&&L.setGState(r.gState),ot(e),ot(\"Q\")}},$e=function(t){switch(t){case\"f\":case\"F\":return\"W n\";case\"f*\":return\"W* n\";case\"B\":return\"W S\";case\"B*\":return\"W* S\";case\"S\":return\"W S\";case\"n\":return\"W n\"}},Qe=L.moveTo=function(t,e){return ot(C(E(t))+\" \"+C(R(e))+\" m\"),this},tn=L.lineTo=function(t,e){return ot(C(E(t))+\" \"+C(R(e))+\" l\"),this},en=L.curveTo=function(t,e,n,r,i,a){return ot([C(E(t)),C(R(e)),C(E(n)),C(R(r)),C(E(i)),C(R(a)),\"c\"].join(\" \")),this};L.__private__.line=L.line=function(t,e,n,r,i){if(isNaN(t)||isNaN(e)||isNaN(n)||isNaN(r)||!Ve(i))throw new Error(\"Invalid arguments passed to jsPDF.line\");return k===P.COMPAT?this.lines([[n-t,r-e]],t,e,[1,1],i||\"S\"):this.lines([[n-t,r-e]],t,e,[1,1]).stroke()},L.__private__.lines=L.lines=function(t,e,n,r,i,a){var o,s,u,c,h,l,f,d,p,g,m,v;if(\"number\"==typeof t&&(v=n,n=e,e=t,t=v),r=r||[1,1],a=a||!1,isNaN(e)||isNaN(n)||!Array.isArray(t)||!Array.isArray(r)||!Ve(i)||\"boolean\"!=typeof a)throw new Error(\"Invalid arguments passed to jsPDF.lines\");for(Qe(e,n),o=r[0],s=r[1],c=t.length,g=e,m=n,u=0;u<c;u++)2===(h=t[u]).length?(g=h[0]*o+g,m=h[1]*s+m,tn(g,m)):(l=h[0]*o+g,f=h[1]*s+m,d=h[2]*o+g,p=h[3]*s+m,g=h[4]*o+g,m=h[5]*s+m,en(l,f,d,p,g,m));return a&&Ye(),Xe(i),this},L.path=function(t){for(var e=0;e<t.length;e++){var n=t[e],r=n.c;switch(n.op){case\"m\":Qe(r[0],r[1]);break;case\"l\":tn(r[0],r[1]);break;case\"c\":en.apply(this,r);break;case\"h\":Ye()}}return this},L.__private__.rect=L.rect=function(t,e,n,r,i){if(isNaN(t)||isNaN(e)||isNaN(n)||isNaN(r)||!Ve(i))throw new Error(\"Invalid arguments passed to jsPDF.rect\");return k===P.COMPAT&&(r=-r),ot([C(E(t)),C(R(e)),C(E(n)),C(E(r)),\"re\"].join(\" \")),Xe(i),this},L.__private__.triangle=L.triangle=function(t,e,n,r,i,a,o){if(isNaN(t)||isNaN(e)||isNaN(n)||isNaN(r)||isNaN(i)||isNaN(a)||!Ve(o))throw new Error(\"Invalid arguments passed to jsPDF.triangle\");return this.lines([[n-t,r-e],[i-n,a-r],[t-i,e-a]],t,e,[1,1],o,!0),this},L.__private__.roundedRect=L.roundedRect=function(t,e,n,r,i,a,o){if(isNaN(t)||isNaN(e)||isNaN(n)||isNaN(r)||isNaN(i)||isNaN(a)||!Ve(o))throw new Error(\"Invalid arguments passed to jsPDF.roundedRect\");var s=4/3*(Math.SQRT2-1);return i=Math.min(i,.5*n),a=Math.min(a,.5*r),this.lines([[n-2*i,0],[i*s,0,i,a-a*s,i,a],[0,r-2*a],[0,a*s,-i*s,a,-i,a],[2*i-n,0],[-i*s,0,-i,-a*s,-i,-a],[0,2*a-r],[0,-a*s,i*s,-a,i,-a]],t+i,e,[1,1],o,!0),this},L.__private__.ellipse=L.ellipse=function(t,e,n,r,i){if(isNaN(t)||isNaN(e)||isNaN(n)||isNaN(r)||!Ve(i))throw new Error(\"Invalid arguments passed to jsPDF.ellipse\");var a=4/3*(Math.SQRT2-1)*n,o=4/3*(Math.SQRT2-1)*r;return Qe(t+n,e),en(t+n,e-o,t+a,e-r,t,e-r),en(t-a,e-r,t-n,e-o,t-n,e),en(t-n,e+o,t-a,e+r,t,e+r),en(t+a,e+r,t+n,e+o,t+n,e),Xe(i),this},L.__private__.circle=L.circle=function(t,e,n,r){if(isNaN(t)||isNaN(e)||isNaN(n)||!Ve(r))throw new Error(\"Invalid arguments passed to jsPDF.circle\");return this.ellipse(t,e,n,n,r)},L.setFont=function(t,e){return wt=Ce(t,e,{disableWarning:!1}),this};var nn=L.__private__.getFont=L.getFont=function(){return _t[Ce.apply(L,arguments)]};L.__private__.getFontList=L.getFontList=function(){var t,e,n={};for(t in St)if(St.hasOwnProperty(t))for(e in n[t]=[],St[t])St[t].hasOwnProperty(e)&&n[t].push(e);return n},L.addFont=function(t,e,n,r){return r=r||\"Identity-H\",Ne.call(this,t,e,n,r)};var rn,an=e.lineWidth||.200025,on=L.__private__.setLineWidth=L.setLineWidth=function(t){return ot(C(E(t))+\" w\"),this};L.__private__.setLineDash=g.API.setLineDash=g.API.setLineDashPattern=function(t,e){if(t=t||[],e=e||0,isNaN(e)||!Array.isArray(t))throw new Error(\"Invalid arguments passed to jsPDF.setLineDash\");return t=t.map((function(t){return C(E(t))})).join(\" \"),e=C(E(e)),ot(\"[\"+t+\"] \"+e+\" d\"),this};var sn=L.__private__.getLineHeight=L.getLineHeight=function(){return ht*rn};L.__private__.getLineHeight=L.getLineHeight=function(){return ht*rn};var un=L.__private__.setLineHeightFactor=L.setLineHeightFactor=function(t){return\"number\"==typeof(t=t||1.15)&&(rn=t),this},cn=L.__private__.getLineHeightFactor=L.getLineHeightFactor=function(){return rn};un(e.lineHeight);var hn=L.__private__.getHorizontalCoordinate=function(t){return E(t)},ln=L.__private__.getVerticalCoordinate=function(t){return k===P.ADVANCED?t:Ot[Y].mediaBox.topRightY-Ot[Y].mediaBox.bottomLeftY-E(t)},fn=L.__private__.getHorizontalCoordinateString=L.getHorizontalCoordinateString=function(t){return C(hn(t))},dn=L.__private__.getVerticalCoordinateString=L.getVerticalCoordinateString=function(t){return C(ln(t))},pn=e.strokeColor||\"0 G\";L.__private__.getStrokeColor=L.getDrawColor=function(){return Kt(pn)},L.__private__.setStrokeColor=L.setDrawColor=function(t,e,n,r){return pn=Zt({ch1:t,ch2:e,ch3:n,ch4:r,pdfColorType:\"draw\",precision:2}),ot(pn),this};var gn=e.fillColor||\"0 g\";L.__private__.getFillColor=L.getFillColor=function(){return Kt(gn)},L.__private__.setFillColor=L.setFillColor=function(t,e,n,r){return gn=Zt({ch1:t,ch2:e,ch3:n,ch4:r,pdfColorType:\"fill\",precision:2}),ot(gn),this};var mn=e.textColor||\"0 g\",vn=L.__private__.getTextColor=L.getTextColor=function(){return Kt(mn)};L.__private__.setTextColor=L.setTextColor=function(t,e,n,r){return mn=Zt({ch1:t,ch2:e,ch3:n,ch4:r,pdfColorType:\"text\",precision:3}),this};var bn=e.charSpace,yn=L.__private__.getCharSpace=L.getCharSpace=function(){return parseFloat(bn||0)};L.__private__.setCharSpace=L.setCharSpace=function(t){if(isNaN(t))throw new Error(\"Invalid argument passed to jsPDF.setCharSpace\");return bn=t,this};var wn=0;L.CapJoinStyles={0:0,butt:0,but:0,miter:0,1:1,round:1,rounded:1,circle:1,2:2,projecting:2,project:2,square:2,bevel:2},L.__private__.setLineCap=L.setLineCap=function(t){var e=L.CapJoinStyles[t];if(void 0===e)throw new Error(\"Line cap style of '\"+t+\"' is not recognized. See or extend .CapJoinStyles property for valid styles\");return wn=e,ot(e+\" J\"),this};var Nn=0;L.__private__.setLineJoin=L.setLineJoin=function(t){var e=L.CapJoinStyles[t];if(void 0===e)throw new Error(\"Line join style of '\"+t+\"' is not recognized. See or extend .CapJoinStyles property for valid styles\");return Nn=e,ot(e+\" j\"),this},L.__private__.setLineMiterLimit=L.__private__.setMiterLimit=L.setLineMiterLimit=L.setMiterLimit=function(t){if(t=t||0,isNaN(t))throw new Error(\"Invalid argument passed to jsPDF.setLineMiterLimit\");return ot(C(E(t))+\" M\"),this},L.GState=l,L.setGState=function(t){(t=\"string\"==typeof t?It[Ct[t]]:Ln(null,t)).equals(jt)||(ot(\"/\"+t.id+\" gs\"),jt=t)};var Ln=function(t,e){if(!t||!Ct[t]){var n=!1;for(var r in It)if(It.hasOwnProperty(r)&&It[r].equals(e)){n=!0;break}if(n)e=It[r];else{var i=\"GS\"+(Object.keys(It).length+1).toString(10);It[i]=e,e.id=i}return t&&(Ct[t]=e.id),Mt.publish(\"addGState\",e),e}};L.addGState=function(t,e){return Ln(t,e),this},L.saveGraphicsState=function(){return ot(\"q\"),Pt.push({key:wt,size:ht,color:mn}),this},L.restoreGraphicsState=function(){ot(\"Q\");var t=Pt.pop();return wt=t.key,ht=t.size,mn=t.color,jt=null,this},L.setCurrentTransformationMatrix=function(t){return ot(t.toString()+\" cm\"),this},L.comment=function(t){return ot(\"#\"+t),this};var xn=function(t,e){var n=t||0;Object.defineProperty(this,\"x\",{enumerable:!0,get:function(){return n},set:function(t){isNaN(t)||(n=parseFloat(t))}});var r=e||0;Object.defineProperty(this,\"y\",{enumerable:!0,get:function(){return r},set:function(t){isNaN(t)||(r=parseFloat(t))}});var i=\"pt\";return Object.defineProperty(this,\"type\",{enumerable:!0,get:function(){return i},set:function(t){i=t.toString()}}),this},An=function(t,e,n,r){xn.call(this,t,e),this.type=\"rect\";var i=n||0;Object.defineProperty(this,\"w\",{enumerable:!0,get:function(){return i},set:function(t){isNaN(t)||(i=parseFloat(t))}});var a=r||0;return Object.defineProperty(this,\"h\",{enumerable:!0,get:function(){return a},set:function(t){isNaN(t)||(a=parseFloat(t))}}),this},_n=function(){this.page=Bt,this.currentPage=Y,this.pages=et.slice(0),this.pagesContext=Ot.slice(0),this.x=Lt,this.y=xt,this.matrix=At,this.width=Fn(Y),this.height=Cn(Y),this.outputDestination=rt,this.id=\"\",this.objectNumber=-1};_n.prototype.restore=function(){Bt=this.page,Y=this.currentPage,Ot=this.pagesContext,et=this.pages,Lt=this.x,xt=this.y,At=this.matrix,In(Y,this.width),jn(Y,this.height),rt=this.outputDestination};var Sn=function(t,e,n,r,i){Tt.push(new _n),Bt=Y=0,et=[],Lt=t,xt=e,At=i,Se([n,r])},Pn=function(t){if(!Rt[t]){var e=new _n,n=\"Xo\"+(Object.keys(qt).length+1).toString(10);e.id=n,Rt[t]=n,qt[n]=e,Mt.publish(\"addFormObject\",e),Tt.pop().restore()}};for(var kn in L.beginFormObject=function(t,e,n,r,i){return Sn(t,e,n,r,i),this},L.endFormObject=function(t){return Pn(t),this},L.doFormObject=function(t,e){var n=qt[Rt[t]];return ot(\"q\"),ot(e.toString()+\" cm\"),ot(\"/\"+n.id+\" Do\"),ot(\"Q\"),this},L.getFormObject=function(t){var e=qt[Rt[t]];return{x:e.x,y:e.y,width:e.width,height:e.height,matrix:e.matrix}},L.save=function(e,n){return e=e||\"generated.pdf\",(n=n||{}).returnPromise=n.returnPromise||!1,!1===n.returnPromise?(u(Re(qe()),e),\"function\"==typeof u.unload&&t.setTimeout&&setTimeout(u.unload,911),this):new Promise((function(n,r){try{var i=u(Re(qe()),e);\"function\"==typeof u.unload&&t.setTimeout&&setTimeout(u.unload,911),n(i)}catch(t){r(t.message)}}))},g.API)g.API.hasOwnProperty(kn)&&(\"events\"===kn&&g.API.events.length?function(t,e){var n,r,i;for(i=e.length-1;-1!==i;i--)n=e[i][0],r=e[i][1],t.subscribe.apply(t,[n].concat(\"function\"==typeof r?[r]:r))}(Mt,g.API.events):L[kn]=g.API[kn]);var Fn=L.getPageWidth=function(t){return(Ot[t=t||Y].mediaBox.topRightX-Ot[t].mediaBox.bottomLeftX)/Nt},In=L.setPageWidth=function(t,e){Ot[t].mediaBox.topRightX=e*Nt+Ot[t].mediaBox.bottomLeftX},Cn=L.getPageHeight=function(t){return(Ot[t=t||Y].mediaBox.topRightY-Ot[t].mediaBox.bottomLeftY)/Nt},jn=L.setPageHeight=function(t,e){Ot[t].mediaBox.topRightY=e*Nt+Ot[t].mediaBox.bottomLeftY};return L.internal={pdfEscape:_e,getStyle:Ge,getFont:nn,getFontSize:ft,getCharSpace:yn,getTextColor:vn,getLineHeight:sn,getLineHeightFactor:cn,write:st,getHorizontalCoordinate:hn,getVerticalCoordinate:ln,getCoordinateString:fn,getVerticalCoordinateString:dn,collections:{},newObject:Wt,newAdditionalObject:Yt,newObjectDeferred:Vt,newObjectDeferredBegin:Gt,getFilters:$t,putStream:Qt,events:Mt,scaleFactor:Nt,pageSize:{getWidth:function(){return Fn(Y)},setWidth:function(t){In(Y,t)},getHeight:function(){return Cn(Y)},setHeight:function(t){jn(Y,t)}},output:Te,getNumberOfPages:Ie,pages:et,out:ot,f2:O,f3:M,getPageInfo:Ue,getPageInfoByObjId:ze,getCurrentPageInfo:He,getPDFVersion:A,Point:xn,Rectangle:An,Matrix:Dt,hasHotfix:De},Object.defineProperty(L.internal.pageSize,\"width\",{get:function(){return Fn(Y)},set:function(t){In(Y,t)},enumerable:!0,configurable:!0}),Object.defineProperty(L.internal.pageSize,\"height\",{get:function(){return Cn(Y)},set:function(t){jn(Y,t)},enumerable:!0,configurable:!0}),Le.call(L,ct),wt=\"F1\",Pe(o,i),Mt.publish(\"initialized\"),L}o=t.atob,s=t.btoa,l.prototype.equals=function(t){var e,n=\"id,objectNumber,equals\";if(!t||typeof t!=typeof this)return!1;var r=0;for(e in this)if(!(n.indexOf(e)>=0)){if(this.hasOwnProperty(e)&&!t.hasOwnProperty(e))return!1;if(this[e]!==t[e])return!1;r++}for(e in t)t.hasOwnProperty(e)&&n.indexOf(e)<0&&r--;return 0===r},g.API={events:[]},g.version=\"2.1.0\";var m,v=g.API,b=1,y=function(t){return t.replace(/\\\\/g,\"\\\\\\\\\").replace(/\\(/g,\"\\\\(\").replace(/\\)/g,\"\\\\)\")},w=function(t){return t.replace(/\\\\\\\\/g,\"\\\\\").replace(/\\\\\\(/g,\"(\").replace(/\\\\\\)/g,\")\")},N=function(t){return t.toFixed(2)},L=function(t){return t.toFixed(5)};v.__acroform__={};var x=function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t},A=function(t){return t*b},_=function(t){var e=new J,n=ut.internal.getHeight(t)||0,r=ut.internal.getWidth(t)||0;return e.BBox=[0,0,Number(N(r)),Number(N(n))],e},S=v.__acroform__.setBit=function(t,e){if(t=t||0,e=e||0,isNaN(t)||isNaN(e))throw new Error(\"Invalid arguments passed to jsPDF.API.__acroform__.setBit\");return t|=1<<e},P=v.__acroform__.clearBit=function(t,e){if(t=t||0,e=e||0,isNaN(t)||isNaN(e))throw new Error(\"Invalid arguments passed to jsPDF.API.__acroform__.clearBit\");return t&=~(1<<e)},k=v.__acroform__.getBit=function(t,e){if(isNaN(t)||isNaN(e))throw new Error(\"Invalid arguments passed to jsPDF.API.__acroform__.getBit\");return 0==(t&1<<e)?0:1},F=v.__acroform__.getBitForPdf=function(t,e){if(isNaN(t)||isNaN(e))throw new Error(\"Invalid arguments passed to jsPDF.API.__acroform__.getBitForPdf\");return k(t,e-1)},I=v.__acroform__.setBitForPdf=function(t,e){if(isNaN(t)||isNaN(e))throw new Error(\"Invalid arguments passed to jsPDF.API.__acroform__.setBitForPdf\");return S(t,e-1)},C=v.__acroform__.clearBitForPdf=function(t,e){if(isNaN(t)||isNaN(e))throw new Error(\"Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf\");return P(t,e-1)},j=v.__acroform__.calculateCoordinates=function(t){var e=this.internal.getHorizontalCoordinate,n=this.internal.getVerticalCoordinate,r=t[0],i=t[1],a=t[2],o=t[3],s={};return s.lowerLeft_X=e(r)||0,s.lowerLeft_Y=n(i+o)||0,s.upperRight_X=e(r+a)||0,s.upperRight_Y=n(i)||0,[Number(N(s.lowerLeft_X)),Number(N(s.lowerLeft_Y)),Number(N(s.upperRight_X)),Number(N(s.upperRight_Y))]},B=function(t){if(t.appearanceStreamContent)return t.appearanceStreamContent;if(t.V||t.DV){var e=[],n=t.V||t.DV,r=O(t,n),i=m.internal.getFont(t.fontName,t.fontStyle).id;e.push(\"/Tx BMC\"),e.push(\"q\"),e.push(\"BT\"),e.push(m.__private__.encodeColorString(t.color)),e.push(\"/\"+i+\" \"+N(r.fontSize)+\" Tf\"),e.push(\"1 0 0 1 0 0 Tm\"),e.push(r.text),e.push(\"ET\"),e.push(\"Q\"),e.push(\"EMC\");var a=new _(t);return a.stream=e.join(\"\\n\"),a}},O=function(t,e){var n=0===t.fontSize?t.maxFontSize:t.fontSize,r={text:\"\",fontSize:\"\"},i=(e=\")\"==(e=\"(\"==e.substr(0,1)?e.substr(1):e).substr(e.length-1)?e.substr(0,e.length-1):e).split(\" \"),a=n,o=ut.internal.getHeight(t)||0;o=o<0?-o:o;var s=ut.internal.getWidth(t)||0;s=s<0?-s:s;var u=function(e,n,r){if(e+1<i.length){var a=n+\" \"+i[e+1];return M(a,t,r).width<=s-4}return!1};a++;t:for(;a>0;){e=\"\",a--;var c,h,l=M(\"3\",t,a).height,f=t.multiline?o-a:(o-l)/2,d=f+=2,p=0,g=0;if(a<=0){e=\"(...) Tj\\n\",e+=\"% Width of Text: \"+M(e,t,a=12).width+\", FieldWidth:\"+s+\"\\n\";break}var m=\"\",v=0;for(var b in i)if(i.hasOwnProperty(b)){m=\" \"==(m+=i[b]+\" \").substr(m.length-1)?m.substr(0,m.length-1):m;var w=parseInt(b),L=u(w,m,a),x=b>=i.length-1;if(L&&!x){m+=\" \";continue}if(L||x){if(x)g=w;else if(t.multiline&&(l+2)*(v+2)+2>o)continue t}else{if(!t.multiline)continue t;if((l+2)*(v+2)+2>o)continue t;g=w}for(var A=\"\",_=p;_<=g;_++)A+=i[_]+\" \";switch(A=\" \"==A.substr(A.length-1)?A.substr(0,A.length-1):A,h=M(A,t,a).width,t.textAlign){case\"right\":c=s-h-2;break;case\"center\":c=(s-h)/2;break;case\"left\":default:c=2}e+=N(c)+\" \"+N(d)+\" Td\\n\",e+=\"(\"+y(A)+\") Tj\\n\",e+=-N(c)+\" 0 Td\\n\",d=-(a+2),h=0,p=g+1,v++,m=\"\"}else;break}return r.text=e,r.fontSize=a,r},M=function(t,e,n){var r=m.internal.getFont(e.fontName,e.fontStyle),i=m.getStringUnitWidth(t,{font:r,fontSize:parseFloat(n),charSpace:0})*parseFloat(n);return{height:m.getStringUnitWidth(\"3\",{font:r,fontSize:parseFloat(n),charSpace:0})*parseFloat(n)*1.5,width:i}},E={fields:[],xForms:[],acroFormDictionaryRoot:null,printedOut:!1,internal:null,isInitialized:!1},q=function(){m.internal.acroformPlugin.acroFormDictionaryRoot.objId=void 0;var t=m.internal.acroformPlugin.acroFormDictionaryRoot.Fields;for(var e in t)if(t.hasOwnProperty(e)){var n=t[e];n.objId=void 0,n.hasAnnotation&&T.call(m,n)}},R=function(t){m.internal.acroformPlugin.printedOut&&(m.internal.acroformPlugin.printedOut=!1,m.internal.acroformPlugin.acroFormDictionaryRoot=null),m.internal.acroformPlugin.acroFormDictionaryRoot||W.call(m),m.internal.acroformPlugin.acroFormDictionaryRoot.Fields.push(t)},T=function(t){var e={type:\"reference\",object:t};void 0===m.internal.getPageInfo(t.page).pageContext.annotations.find((function(t){return t.type===e.type&&t.object===e.object}))&&m.internal.getPageInfo(t.page).pageContext.annotations.push(e)},D=function(){if(void 0===m.internal.acroformPlugin.acroFormDictionaryRoot)throw new Error(\"putCatalogCallback: Root missing.\");m.internal.write(\"/AcroForm \"+m.internal.acroformPlugin.acroFormDictionaryRoot.objId+\" 0 R\")},U=function(){m.internal.events.unsubscribe(m.internal.acroformPlugin.acroFormDictionaryRoot._eventID),delete m.internal.acroformPlugin.acroFormDictionaryRoot._eventID,m.internal.acroformPlugin.printedOut=!0},z=function(t){var e=!t;for(var n in t||(m.internal.newObjectDeferredBegin(m.internal.acroformPlugin.acroFormDictionaryRoot.objId,!0),m.internal.acroformPlugin.acroFormDictionaryRoot.putStream()),t=t||m.internal.acroformPlugin.acroFormDictionaryRoot.Kids)if(t.hasOwnProperty(n)){var r=t[n],i=[],a=r.Rect;if(r.Rect&&(r.Rect=j.call(this,r.Rect)),m.internal.newObjectDeferredBegin(r.objId,!0),r.DA=ut.createDefaultAppearanceStream(r),\"object\"==typeof r&&\"function\"==typeof r.getKeyValueListForStream&&(i=r.getKeyValueListForStream()),r.Rect=a,r.hasAppearanceStream&&!r.appearanceStreamContent){var o=B.call(this,r);i.push({key:\"AP\",value:\"<</N \"+o+\">>\"}),m.internal.acroformPlugin.xForms.push(o)}if(r.appearanceStreamContent){var s=\"\";for(var u in r.appearanceStreamContent)if(r.appearanceStreamContent.hasOwnProperty(u)){var c=r.appearanceStreamContent[u];if(s+=\"/\"+u+\" \",s+=\"<<\",Object.keys(c).length>=1||Array.isArray(c)){for(var n in c)if(c.hasOwnProperty(n)){var h=c[n];\"function\"==typeof h&&(h=h.call(this,r)),s+=\"/\"+n+\" \"+h+\" \",m.internal.acroformPlugin.xForms.indexOf(h)>=0||m.internal.acroformPlugin.xForms.push(h)}}else\"function\"==typeof(h=c)&&(h=h.call(this,r)),s+=\"/\"+n+\" \"+h,m.internal.acroformPlugin.xForms.indexOf(h)>=0||m.internal.acroformPlugin.xForms.push(h);s+=\">>\"}i.push({key:\"AP\",value:\"<<\\n\"+s+\">>\"})}m.internal.putStream({additionalKeyValues:i}),m.internal.out(\"endobj\")}e&&H.call(this,m.internal.acroformPlugin.xForms)},H=function(t){for(var e in t)if(t.hasOwnProperty(e)){var n=e,r=t[e];m.internal.newObjectDeferredBegin(r&&r.objId,!0),\"object\"==typeof r&&\"function\"==typeof r.putStream&&r.putStream(),delete t[n]}},W=function(){if(void 0!==this.internal&&(void 0===this.internal.acroformPlugin||!1===this.internal.acroformPlugin.isInitialized)){if(m=this,K.FieldNum=0,this.internal.acroformPlugin=JSON.parse(JSON.stringify(E)),this.internal.acroformPlugin.acroFormDictionaryRoot)throw new Error(\"Exception while creating AcroformDictionary\");b=m.internal.scaleFactor,m.internal.acroformPlugin.acroFormDictionaryRoot=new X,m.internal.acroformPlugin.acroFormDictionaryRoot._eventID=m.internal.events.subscribe(\"postPutResources\",U),m.internal.events.subscribe(\"buildDocument\",q),m.internal.events.subscribe(\"putCatalog\",D),m.internal.events.subscribe(\"postPutPages\",z),m.internal.acroformPlugin.isInitialized=!0}},V=v.__acroform__.arrayToPdfArray=function(t){if(Array.isArray(t)){for(var e=\"[\",n=0;n<t.length;n++)switch(0!==n&&(e+=\" \"),typeof t[n]){case\"boolean\":case\"number\":case\"object\":e+=t[n].toString();break;case\"string\":\"/\"!==t[n].substr(0,1)?e+=\"(\"+y(t[n].toString())+\")\":e+=t[n].toString()}return e+=\"]\"}throw new Error(\"Invalid argument passed to jsPDF.__acroform__.arrayToPdfArray\")};var G=function(t){return(t=t||\"\").toString(),t=\"(\"+y(t)+\")\"},Y=function(){var t;Object.defineProperty(this,\"objId\",{configurable:!0,get:function(){return t||(t=m.internal.newObjectDeferred()),t},set:function(e){t=e}})};Y.prototype.toString=function(){return this.objId+\" 0 R\"},Y.prototype.putStream=function(){var t=this.getKeyValueListForStream();m.internal.putStream({data:this.stream,additionalKeyValues:t}),m.internal.out(\"endobj\")},Y.prototype.getKeyValueListForStream=function(){return function(t){var e=[],n=Object.getOwnPropertyNames(t).filter((function(t){return\"content\"!=t&&\"appearanceStreamContent\"!=t&&\"_\"!=t.substring(0,1)}));for(var r in n)if(!1===Object.getOwnPropertyDescriptor(t,n[r]).configurable){var i=n[r],a=t[i];a&&(Array.isArray(a)?e.push({key:i,value:V(a)}):a instanceof Y?e.push({key:i,value:a.objId+\" 0 R\"}):\"function\"!=typeof a&&e.push({key:i,value:a}))}return e}(this)};var J=function(){Y.call(this),Object.defineProperty(this,\"Type\",{value:\"/XObject\",configurable:!1,writeable:!0}),Object.defineProperty(this,\"Subtype\",{value:\"/Form\",configurable:!1,writeable:!0}),Object.defineProperty(this,\"FormType\",{value:1,configurable:!1,writeable:!0});var t,e=[];Object.defineProperty(this,\"BBox\",{configurable:!1,writeable:!0,get:function(){return e},set:function(t){e=t}}),Object.defineProperty(this,\"Resources\",{value:\"2 0 R\",configurable:!1,writeable:!0}),Object.defineProperty(this,\"stream\",{enumerable:!1,configurable:!0,set:function(e){t=e.trim()},get:function(){return t||null}})};x(J,Y);var X=function(){Y.call(this);var t,e=[];Object.defineProperty(this,\"Kids\",{enumerable:!1,configurable:!0,get:function(){return e.length>0?e:void 0}}),Object.defineProperty(this,\"Fields\",{enumerable:!1,configurable:!1,get:function(){return e}}),Object.defineProperty(this,\"DA\",{enumerable:!1,configurable:!1,get:function(){if(t)return\"(\"+t+\")\"},set:function(e){t=e}})};x(X,Y);var K=function(){Y.call(this);var t=4;Object.defineProperty(this,\"F\",{enumerable:!1,configurable:!1,get:function(){return t},set:function(e){if(isNaN(e))throw new Error('Invalid value \"'+e+'\" for attribute F supplied.');t=e}}),Object.defineProperty(this,\"showWhenPrinted\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(t,3))},set:function(e){!0===Boolean(e)?this.F=I(t,3):this.F=C(t,3)}});var e=0;Object.defineProperty(this,\"Ff\",{enumerable:!1,configurable:!1,get:function(){return e},set:function(t){if(isNaN(t))throw new Error('Invalid value \"'+t+'\" for attribute Ff supplied.');e=t}});var n=[];Object.defineProperty(this,\"Rect\",{enumerable:!1,configurable:!1,get:function(){if(0!==n.length)return n},set:function(t){n=void 0!==t?t:[]}}),Object.defineProperty(this,\"x\",{enumerable:!0,configurable:!0,get:function(){return!n||isNaN(n[0])?0:n[0]},set:function(t){n[0]=t}}),Object.defineProperty(this,\"y\",{enumerable:!0,configurable:!0,get:function(){return!n||isNaN(n[1])?0:n[1]},set:function(t){n[1]=t}}),Object.defineProperty(this,\"width\",{enumerable:!0,configurable:!0,get:function(){return!n||isNaN(n[2])?0:n[2]},set:function(t){n[2]=t}}),Object.defineProperty(this,\"height\",{enumerable:!0,configurable:!0,get:function(){return!n||isNaN(n[3])?0:n[3]},set:function(t){n[3]=t}});var r=\"\";Object.defineProperty(this,\"FT\",{enumerable:!0,configurable:!1,get:function(){return r},set:function(t){switch(t){case\"/Btn\":case\"/Tx\":case\"/Ch\":case\"/Sig\":r=t;break;default:throw new Error('Invalid value \"'+t+'\" for attribute FT supplied.')}}});var i=null;Object.defineProperty(this,\"T\",{enumerable:!0,configurable:!1,get:function(){if(!i||i.length<1){if(this instanceof it)return;i=\"FieldObject\"+K.FieldNum++}return\"(\"+y(i)+\")\"},set:function(t){i=t.toString()}}),Object.defineProperty(this,\"fieldName\",{configurable:!0,enumerable:!0,get:function(){return i},set:function(t){i=t}});var a=\"helvetica\";Object.defineProperty(this,\"fontName\",{enumerable:!0,configurable:!0,get:function(){return a},set:function(t){a=t}});var o=\"normal\";Object.defineProperty(this,\"fontStyle\",{enumerable:!0,configurable:!0,get:function(){return o},set:function(t){o=t}});var s=0;Object.defineProperty(this,\"fontSize\",{enumerable:!0,configurable:!0,get:function(){return s},set:function(t){s=t}});var u=void 0;Object.defineProperty(this,\"maxFontSize\",{enumerable:!0,configurable:!0,get:function(){return void 0===u?50/b:u},set:function(t){u=t}});var c=\"black\";Object.defineProperty(this,\"color\",{enumerable:!0,configurable:!0,get:function(){return c},set:function(t){c=t}});var h=\"/F1 0 Tf 0 g\";Object.defineProperty(this,\"DA\",{enumerable:!0,configurable:!1,get:function(){if(!(!h||this instanceof it||this instanceof ot))return G(h)},set:function(t){t=t.toString(),h=t}});var l=null;Object.defineProperty(this,\"DV\",{enumerable:!1,configurable:!1,get:function(){if(l)return this instanceof et==!1?G(l):l},set:function(t){t=t.toString(),l=this instanceof et==!1?\"(\"===t.substr(0,1)?w(t.substr(1,t.length-2)):w(t):t}}),Object.defineProperty(this,\"defaultValue\",{enumerable:!0,configurable:!0,get:function(){return this instanceof et==!0?w(l.substr(1,l.length-1)):l},set:function(t){t=t.toString(),l=this instanceof et==!0?\"/\"+t:t}});var f=null;Object.defineProperty(this,\"V\",{enumerable:!1,configurable:!1,get:function(){if(f)return this instanceof et==!1?G(f):f},set:function(t){t=t.toString(),f=this instanceof et==!1?\"(\"===t.substr(0,1)?w(t.substr(1,t.length-2)):w(t):t}}),Object.defineProperty(this,\"value\",{enumerable:!0,configurable:!0,get:function(){return this instanceof et==!0?w(f.substr(1,f.length-1)):f},set:function(t){t=t.toString(),f=this instanceof et==!0?\"/\"+t:t}}),Object.defineProperty(this,\"hasAnnotation\",{enumerable:!0,configurable:!0,get:function(){return this.Rect}}),Object.defineProperty(this,\"Type\",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?\"/Annot\":null}}),Object.defineProperty(this,\"Subtype\",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?\"/Widget\":null}});var d,p=!1;Object.defineProperty(this,\"hasAppearanceStream\",{enumerable:!0,configurable:!0,writeable:!0,get:function(){return p},set:function(t){t=Boolean(t),p=t}}),Object.defineProperty(this,\"page\",{enumerable:!0,configurable:!0,writeable:!0,get:function(){if(d)return d},set:function(t){d=t}}),Object.defineProperty(this,\"readOnly\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,1))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,1):this.Ff=C(this.Ff,1)}}),Object.defineProperty(this,\"required\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,2))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,2):this.Ff=C(this.Ff,2)}}),Object.defineProperty(this,\"noExport\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,3))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,3):this.Ff=C(this.Ff,3)}});var g=null;Object.defineProperty(this,\"Q\",{enumerable:!0,configurable:!1,get:function(){if(null!==g)return g},set:function(t){if(-1===[0,1,2].indexOf(t))throw new Error('Invalid value \"'+t+'\" for attribute Q supplied.');g=t}}),Object.defineProperty(this,\"textAlign\",{get:function(){var t;switch(g){case 0:default:t=\"left\";break;case 1:t=\"center\";break;case 2:t=\"right\"}return t},configurable:!0,enumerable:!0,set:function(t){switch(t){case\"right\":case 2:g=2;break;case\"center\":case 1:g=1;break;case\"left\":case 0:default:g=0}}})};x(K,Y);var Z=function(){K.call(this),this.FT=\"/Ch\",this.V=\"()\",this.fontName=\"zapfdingbats\";var t=0;Object.defineProperty(this,\"TI\",{enumerable:!0,configurable:!1,get:function(){return t},set:function(e){t=e}}),Object.defineProperty(this,\"topIndex\",{enumerable:!0,configurable:!0,get:function(){return t},set:function(e){t=e}});var e=[];Object.defineProperty(this,\"Opt\",{enumerable:!0,configurable:!1,get:function(){return V(e)},set:function(t){var n,r;r=[],\"string\"==typeof(n=t)&&(r=function(t,e,n){n||(n=1);for(var r,i=[];r=e.exec(t);)i.push(r[n]);return i}(n,/\\((.*?)\\)/g)),e=r}}),this.getOptions=function(){return e},this.setOptions=function(t){e=t,this.sort&&e.sort()},this.addOption=function(t){t=(t=t||\"\").toString(),e.push(t),this.sort&&e.sort()},this.removeOption=function(t,n){for(n=n||!1,t=(t=t||\"\").toString();-1!==e.indexOf(t)&&(e.splice(e.indexOf(t),1),!1!==n););},Object.defineProperty(this,\"combo\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,18))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,18):this.Ff=C(this.Ff,18)}}),Object.defineProperty(this,\"edit\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,19))},set:function(t){!0===this.combo&&(!0===Boolean(t)?this.Ff=I(this.Ff,19):this.Ff=C(this.Ff,19))}}),Object.defineProperty(this,\"sort\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,20))},set:function(t){!0===Boolean(t)?(this.Ff=I(this.Ff,20),e.sort()):this.Ff=C(this.Ff,20)}}),Object.defineProperty(this,\"multiSelect\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,22))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,22):this.Ff=C(this.Ff,22)}}),Object.defineProperty(this,\"doNotSpellCheck\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,23))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,23):this.Ff=C(this.Ff,23)}}),Object.defineProperty(this,\"commitOnSelChange\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,27))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,27):this.Ff=C(this.Ff,27)}}),this.hasAppearanceStream=!1};x(Z,K);var $=function(){Z.call(this),this.fontName=\"helvetica\",this.combo=!1};x($,Z);var Q=function(){$.call(this),this.combo=!0};x(Q,$);var tt=function(){Q.call(this),this.edit=!0};x(tt,Q);var et=function(){K.call(this),this.FT=\"/Btn\",Object.defineProperty(this,\"noToggleToOff\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,15))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,15):this.Ff=C(this.Ff,15)}}),Object.defineProperty(this,\"radio\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,16))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,16):this.Ff=C(this.Ff,16)}}),Object.defineProperty(this,\"pushButton\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,17))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,17):this.Ff=C(this.Ff,17)}}),Object.defineProperty(this,\"radioIsUnison\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,26))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,26):this.Ff=C(this.Ff,26)}});var t,e={};Object.defineProperty(this,\"MK\",{enumerable:!1,configurable:!1,get:function(){if(0!==Object.keys(e).length){var t,n=[];for(t in n.push(\"<<\"),e)n.push(\"/\"+t+\" (\"+e[t]+\")\");return n.push(\">>\"),n.join(\"\\n\")}},set:function(t){\"object\"==typeof t&&(e=t)}}),Object.defineProperty(this,\"caption\",{enumerable:!0,configurable:!0,get:function(){return e.CA||\"\"},set:function(t){\"string\"==typeof t&&(e.CA=t)}}),Object.defineProperty(this,\"AS\",{enumerable:!1,configurable:!1,get:function(){return t},set:function(e){t=e}}),Object.defineProperty(this,\"appearanceState\",{enumerable:!0,configurable:!0,get:function(){return t.substr(1,t.length-1)},set:function(e){t=\"/\"+e}})};x(et,K);var nt=function(){et.call(this),this.pushButton=!0};x(nt,et);var rt=function(){et.call(this),this.radio=!0,this.pushButton=!1;var t=[];Object.defineProperty(this,\"Kids\",{enumerable:!0,configurable:!1,get:function(){return t},set:function(e){t=void 0!==e?e:[]}})};x(rt,et);var it=function(){var t,e;K.call(this),Object.defineProperty(this,\"Parent\",{enumerable:!1,configurable:!1,get:function(){return t},set:function(e){t=e}}),Object.defineProperty(this,\"optionName\",{enumerable:!1,configurable:!0,get:function(){return e},set:function(t){e=t}});var n,r={};Object.defineProperty(this,\"MK\",{enumerable:!1,configurable:!1,get:function(){var t,e=[];for(t in e.push(\"<<\"),r)e.push(\"/\"+t+\" (\"+r[t]+\")\");return e.push(\">>\"),e.join(\"\\n\")},set:function(t){\"object\"==typeof t&&(r=t)}}),Object.defineProperty(this,\"caption\",{enumerable:!0,configurable:!0,get:function(){return r.CA||\"\"},set:function(t){\"string\"==typeof t&&(r.CA=t)}}),Object.defineProperty(this,\"AS\",{enumerable:!1,configurable:!1,get:function(){return n},set:function(t){n=t}}),Object.defineProperty(this,\"appearanceState\",{enumerable:!0,configurable:!0,get:function(){return n.substr(1,n.length-1)},set:function(t){n=\"/\"+t}}),this.caption=\"l\",this.appearanceState=\"Off\",this._AppearanceType=ut.RadioButton.Circle,this.appearanceStreamContent=this._AppearanceType.createAppearanceStream(this.optionName)};x(it,K),rt.prototype.setAppearance=function(t){if(!(\"createAppearanceStream\"in t)||!(\"getCA\"in t))throw new Error(\"Couldn't assign Appearance to RadioButton. Appearance was Invalid!\");for(var e in this.Kids)if(this.Kids.hasOwnProperty(e)){var n=this.Kids[e];n.appearanceStreamContent=t.createAppearanceStream(n.optionName),n.caption=t.getCA()}},rt.prototype.createOption=function(t){var e=new it;return e.Parent=this,e.optionName=t,this.Kids.push(e),ct.call(this,e),e};var at=function(){et.call(this),this.fontName=\"zapfdingbats\",this.caption=\"3\",this.appearanceState=\"On\",this.value=\"On\",this.textAlign=\"center\",this.appearanceStreamContent=ut.CheckBox.createAppearanceStream()};x(at,et);var ot=function(){K.call(this),this.FT=\"/Tx\",Object.defineProperty(this,\"multiline\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,13))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,13):this.Ff=C(this.Ff,13)}}),Object.defineProperty(this,\"fileSelect\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,21))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,21):this.Ff=C(this.Ff,21)}}),Object.defineProperty(this,\"doNotSpellCheck\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,23))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,23):this.Ff=C(this.Ff,23)}}),Object.defineProperty(this,\"doNotScroll\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,24))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,24):this.Ff=C(this.Ff,24)}}),Object.defineProperty(this,\"comb\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,25))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,25):this.Ff=C(this.Ff,25)}}),Object.defineProperty(this,\"richText\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,26))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,26):this.Ff=C(this.Ff,26)}});var t=null;Object.defineProperty(this,\"MaxLen\",{enumerable:!0,configurable:!1,get:function(){return t},set:function(e){t=e}}),Object.defineProperty(this,\"maxLength\",{enumerable:!0,configurable:!0,get:function(){return t},set:function(e){Number.isInteger(e)&&(t=e)}}),Object.defineProperty(this,\"hasAppearanceStream\",{enumerable:!0,configurable:!0,get:function(){return this.V||this.DV}})};x(ot,K);var st=function(){ot.call(this),Object.defineProperty(this,\"password\",{enumerable:!0,configurable:!0,get:function(){return Boolean(F(this.Ff,14))},set:function(t){!0===Boolean(t)?this.Ff=I(this.Ff,14):this.Ff=C(this.Ff,14)}}),this.password=!0};x(st,ot);var ut={CheckBox:{createAppearanceStream:function(){return{N:{On:ut.CheckBox.YesNormal},D:{On:ut.CheckBox.YesPushDown,Off:ut.CheckBox.OffPushDown}}},YesPushDown:function(t){var e=new _(t),n=[],r=m.internal.getFont(t.fontName,t.fontStyle).id,i=m.__private__.encodeColorString(t.color),a=O(t,t.caption);return n.push(\"0.749023 g\"),n.push(\"0 0 \"+N(ut.internal.getWidth(t))+\" \"+N(ut.internal.getHeight(t))+\" re\"),n.push(\"f\"),n.push(\"BMC\"),n.push(\"q\"),n.push(\"0 0 1 rg\"),n.push(\"/\"+r+\" \"+N(a.fontSize)+\" Tf \"+i),n.push(\"BT\"),n.push(a.text),n.push(\"ET\"),n.push(\"Q\"),n.push(\"EMC\"),e.stream=n.join(\"\\n\"),e},YesNormal:function(t){var e=new _(t),n=m.internal.getFont(t.fontName,t.fontStyle).id,r=m.__private__.encodeColorString(t.color),i=[],a=ut.internal.getHeight(t),o=ut.internal.getWidth(t),s=O(t,t.caption);return i.push(\"1 g\"),i.push(\"0 0 \"+N(o)+\" \"+N(a)+\" re\"),i.push(\"f\"),i.push(\"q\"),i.push(\"0 0 1 rg\"),i.push(\"0 0 \"+N(o-1)+\" \"+N(a-1)+\" re\"),i.push(\"W\"),i.push(\"n\"),i.push(\"0 g\"),i.push(\"BT\"),i.push(\"/\"+n+\" \"+N(s.fontSize)+\" Tf \"+r),i.push(s.text),i.push(\"ET\"),i.push(\"Q\"),e.stream=i.join(\"\\n\"),e},OffPushDown:function(t){var e=new _(t),n=[];return n.push(\"0.749023 g\"),n.push(\"0 0 \"+N(ut.internal.getWidth(t))+\" \"+N(ut.internal.getHeight(t))+\" re\"),n.push(\"f\"),e.stream=n.join(\"\\n\"),e}},RadioButton:{Circle:{createAppearanceStream:function(t){var e={D:{Off:ut.RadioButton.Circle.OffPushDown},N:{}};return e.N[t]=ut.RadioButton.Circle.YesNormal,e.D[t]=ut.RadioButton.Circle.YesPushDown,e},getCA:function(){return\"l\"},YesNormal:function(t){var e=new _(t),n=[],r=ut.internal.getWidth(t)<=ut.internal.getHeight(t)?ut.internal.getWidth(t)/4:ut.internal.getHeight(t)/4;r=Number((.9*r).toFixed(5));var i=ut.internal.Bezier_C,a=Number((r*i).toFixed(5));return n.push(\"q\"),n.push(\"1 0 0 1 \"+L(ut.internal.getWidth(t)/2)+\" \"+L(ut.internal.getHeight(t)/2)+\" cm\"),n.push(r+\" 0 m\"),n.push(r+\" \"+a+\" \"+a+\" \"+r+\" 0 \"+r+\" c\"),n.push(\"-\"+a+\" \"+r+\" -\"+r+\" \"+a+\" -\"+r+\" 0 c\"),n.push(\"-\"+r+\" -\"+a+\" -\"+a+\" -\"+r+\" 0 -\"+r+\" c\"),n.push(a+\" -\"+r+\" \"+r+\" -\"+a+\" \"+r+\" 0 c\"),n.push(\"f\"),n.push(\"Q\"),e.stream=n.join(\"\\n\"),e},YesPushDown:function(t){var e=new _(t),n=[],r=ut.internal.getWidth(t)<=ut.internal.getHeight(t)?ut.internal.getWidth(t)/4:ut.internal.getHeight(t)/4,i=(r=Number((.9*r).toFixed(5)),Number((2*r).toFixed(5))),a=Number((i*ut.internal.Bezier_C).toFixed(5)),o=Number((r*ut.internal.Bezier_C).toFixed(5));return n.push(\"0.749023 g\"),n.push(\"q\"),n.push(\"1 0 0 1 \"+L(ut.internal.getWidth(t)/2)+\" \"+L(ut.internal.getHeight(t)/2)+\" cm\"),n.push(i+\" 0 m\"),n.push(i+\" \"+a+\" \"+a+\" \"+i+\" 0 \"+i+\" c\"),n.push(\"-\"+a+\" \"+i+\" -\"+i+\" \"+a+\" -\"+i+\" 0 c\"),n.push(\"-\"+i+\" -\"+a+\" -\"+a+\" -\"+i+\" 0 -\"+i+\" c\"),n.push(a+\" -\"+i+\" \"+i+\" -\"+a+\" \"+i+\" 0 c\"),n.push(\"f\"),n.push(\"Q\"),n.push(\"0 g\"),n.push(\"q\"),n.push(\"1 0 0 1 \"+L(ut.internal.getWidth(t)/2)+\" \"+L(ut.internal.getHeight(t)/2)+\" cm\"),n.push(r+\" 0 m\"),n.push(r+\" \"+o+\" \"+o+\" \"+r+\" 0 \"+r+\" c\"),n.push(\"-\"+o+\" \"+r+\" -\"+r+\" \"+o+\" -\"+r+\" 0 c\"),n.push(\"-\"+r+\" -\"+o+\" -\"+o+\" -\"+r+\" 0 -\"+r+\" c\"),n.push(o+\" -\"+r+\" \"+r+\" -\"+o+\" \"+r+\" 0 c\"),n.push(\"f\"),n.push(\"Q\"),e.stream=n.join(\"\\n\"),e},OffPushDown:function(t){var e=new _(t),n=[],r=ut.internal.getWidth(t)<=ut.internal.getHeight(t)?ut.internal.getWidth(t)/4:ut.internal.getHeight(t)/4;r=Number((.9*r).toFixed(5));var i=Number((2*r).toFixed(5)),a=Number((i*ut.internal.Bezier_C).toFixed(5));return n.push(\"0.749023 g\"),n.push(\"q\"),n.push(\"1 0 0 1 \"+L(ut.internal.getWidth(t)/2)+\" \"+L(ut.internal.getHeight(t)/2)+\" cm\"),n.push(i+\" 0 m\"),n.push(i+\" \"+a+\" \"+a+\" \"+i+\" 0 \"+i+\" c\"),n.push(\"-\"+a+\" \"+i+\" -\"+i+\" \"+a+\" -\"+i+\" 0 c\"),n.push(\"-\"+i+\" -\"+a+\" -\"+a+\" -\"+i+\" 0 -\"+i+\" c\"),n.push(a+\" -\"+i+\" \"+i+\" -\"+a+\" \"+i+\" 0 c\"),n.push(\"f\"),n.push(\"Q\"),e.stream=n.join(\"\\n\"),e}},Cross:{createAppearanceStream:function(t){var e={D:{Off:ut.RadioButton.Cross.OffPushDown},N:{}};return e.N[t]=ut.RadioButton.Cross.YesNormal,e.D[t]=ut.RadioButton.Cross.YesPushDown,e},getCA:function(){return\"8\"},YesNormal:function(t){var e=new _(t),n=[],r=ut.internal.calculateCross(t);return n.push(\"q\"),n.push(\"1 1 \"+N(ut.internal.getWidth(t)-2)+\" \"+N(ut.internal.getHeight(t)-2)+\" re\"),n.push(\"W\"),n.push(\"n\"),n.push(N(r.x1.x)+\" \"+N(r.x1.y)+\" m\"),n.push(N(r.x2.x)+\" \"+N(r.x2.y)+\" l\"),n.push(N(r.x4.x)+\" \"+N(r.x4.y)+\" m\"),n.push(N(r.x3.x)+\" \"+N(r.x3.y)+\" l\"),n.push(\"s\"),n.push(\"Q\"),e.stream=n.join(\"\\n\"),e},YesPushDown:function(t){var e=new _(t),n=ut.internal.calculateCross(t),r=[];return r.push(\"0.749023 g\"),r.push(\"0 0 \"+N(ut.internal.getWidth(t))+\" \"+N(ut.internal.getHeight(t))+\" re\"),r.push(\"f\"),r.push(\"q\"),r.push(\"1 1 \"+N(ut.internal.getWidth(t)-2)+\" \"+N(ut.internal.getHeight(t)-2)+\" re\"),r.push(\"W\"),r.push(\"n\"),r.push(N(n.x1.x)+\" \"+N(n.x1.y)+\" m\"),r.push(N(n.x2.x)+\" \"+N(n.x2.y)+\" l\"),r.push(N(n.x4.x)+\" \"+N(n.x4.y)+\" m\"),r.push(N(n.x3.x)+\" \"+N(n.x3.y)+\" l\"),r.push(\"s\"),r.push(\"Q\"),e.stream=r.join(\"\\n\"),e},OffPushDown:function(t){var e=new _(t),n=[];return n.push(\"0.749023 g\"),n.push(\"0 0 \"+N(ut.internal.getWidth(t))+\" \"+N(ut.internal.getHeight(t))+\" re\"),n.push(\"f\"),e.stream=n.join(\"\\n\"),e}}},createDefaultAppearanceStream:function(t){var e=m.internal.getFont(t.fontName,t.fontStyle).id,n=m.__private__.encodeColorString(t.color);return\"/\"+e+\" \"+t.fontSize+\" Tf \"+n}};ut.internal={Bezier_C:.551915024494,calculateCross:function(t){var e=ut.internal.getWidth(t),n=ut.internal.getHeight(t),r=Math.min(e,n);return{x1:{x:(e-r)/2,y:(n-r)/2+r},x2:{x:(e-r)/2+r,y:(n-r)/2},x3:{x:(e-r)/2,y:(n-r)/2},x4:{x:(e-r)/2+r,y:(n-r)/2+r}}}},ut.internal.getWidth=function(t){var e=0;return\"object\"==typeof t&&(e=A(t.Rect[2])),e},ut.internal.getHeight=function(t){var e=0;return\"object\"==typeof t&&(e=A(t.Rect[3])),e};var ct=v.addField=function(t){if(W.call(this),!(t instanceof K))throw new Error(\"Invalid argument passed to jsPDF.addField.\");return R.call(this,t),t.page=m.internal.getCurrentPageInfo().pageNumber,this};v.AcroFormChoiceField=Z,v.AcroFormListBox=$,v.AcroFormComboBox=Q,v.AcroFormEditBox=tt,v.AcroFormButton=et,v.AcroFormPushButton=nt,v.AcroFormRadioButton=rt,v.AcroFormCheckBox=at,v.AcroFormTextField=ot,v.AcroFormPasswordField=st,v.AcroFormAppearance=ut,v.AcroForm={ChoiceField:Z,ListBox:$,ComboBox:Q,EditBox:tt,Button:et,PushButton:nt,RadioButton:rt,CheckBox:at,TextField:ot,PasswordField:st,Appearance:ut},g.AcroForm={ChoiceField:Z,ListBox:$,ComboBox:Q,EditBox:tt,Button:et,PushButton:nt,RadioButton:rt,CheckBox:at,TextField:ot,PasswordField:st,Appearance:ut};var ht=g.AcroForm;\n/** @license\n * jsPDF addImage plugin\n * Copyright (c) 2012 Jason Siefken, https://github.com/siefkenj/\n * 2013 Chris Dowling, https://github.com/gingerchris\n * 2013 Trinh Ho, https://github.com/ineedfat\n * 2013 Edwin Alejandro Perez, https://github.com/eaparango\n * 2013 Norah Smith, https://github.com/burnburnrocket\n * 2014 Diego Casorran, https://github.com/diegocr\n * 2014 James Robb, https://github.com/jamesbrobb\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */!function(t){t.__addimage__={};var e=\"UNKNOWN\",n={PNG:[[137,80,78,71]],TIFF:[[77,77,0,42],[73,73,42,0]],JPEG:[[255,216,255,224,void 0,void 0,74,70,73,70,0],[255,216,255,225,void 0,void 0,69,120,105,102,0,0],[255,216,255,219],[255,216,255,238]],JPEG2000:[[0,0,0,12,106,80,32,32]],GIF87a:[[71,73,70,56,55,97]],GIF89a:[[71,73,70,56,57,97]],WEBP:[[82,73,70,70,void 0,void 0,void 0,void 0,87,69,66,80]],BMP:[[66,77],[66,65],[67,73],[67,80],[73,67],[80,84]]},r=t.__addimage__.getImageFileTypeByImageData=function(t,r){var i,a;r=r||e;var o,s,u,c=e;if(A(t))for(u in n)for(o=n[u],i=0;i<o.length;i+=1){for(s=!0,a=0;a<o[i].length;a+=1)if(void 0!==o[i][a]&&o[i][a]!==t[a]){s=!1;break}if(!0===s){c=u;break}}else for(u in n)for(o=n[u],i=0;i<o.length;i+=1){for(s=!0,a=0;a<o[i].length;a+=1)if(void 0!==o[i][a]&&o[i][a]!==t.charCodeAt(a)){s=!1;break}if(!0===s){c=u;break}}return c===e&&r!==e&&(c=r),c},i=function(t){for(var e=this.internal.write,n=this.internal.putStream,r=(0,this.internal.getFilters)();-1!==r.indexOf(\"FlateEncode\");)r.splice(r.indexOf(\"FlateEncode\"),1);t.objectId=this.internal.newObject();var a=[];if(a.push({key:\"Type\",value:\"/XObject\"}),a.push({key:\"Subtype\",value:\"/Image\"}),a.push({key:\"Width\",value:t.width}),a.push({key:\"Height\",value:t.height}),t.colorSpace===b.INDEXED?a.push({key:\"ColorSpace\",value:\"[/Indexed /DeviceRGB \"+(t.palette.length/3-1)+\" \"+(\"sMask\"in t&&void 0!==t.sMask?t.objectId+2:t.objectId+1)+\" 0 R]\"}):(a.push({key:\"ColorSpace\",value:\"/\"+t.colorSpace}),t.colorSpace===b.DEVICE_CMYK&&a.push({key:\"Decode\",value:\"[1 0 1 0 1 0 1 0]\"})),a.push({key:\"BitsPerComponent\",value:t.bitsPerComponent}),\"decodeParameters\"in t&&void 0!==t.decodeParameters&&a.push({key:\"DecodeParms\",value:\"<<\"+t.decodeParameters+\">>\"}),\"transparency\"in t&&Array.isArray(t.transparency)){for(var o=\"\",s=0,u=t.transparency.length;s<u;s++)o+=t.transparency[s]+\" \"+t.transparency[s]+\" \";a.push({key:\"Mask\",value:\"[\"+o+\"]\"})}void 0!==t.sMask&&a.push({key:\"SMask\",value:t.objectId+1+\" 0 R\"});var c=void 0!==t.filter?[\"/\"+t.filter]:void 0;if(n({data:t.data,additionalKeyValues:a,alreadyAppliedFilters:c}),e(\"endobj\"),\"sMask\"in t&&void 0!==t.sMask){var h=\"/Predictor \"+t.predictor+\" /Colors 1 /BitsPerComponent \"+t.bitsPerComponent+\" /Columns \"+t.width,l={width:t.width,height:t.height,colorSpace:\"DeviceGray\",bitsPerComponent:t.bitsPerComponent,decodeParameters:h,data:t.sMask};\"filter\"in t&&(l.filter=t.filter),i.call(this,l)}t.colorSpace===b.INDEXED&&(this.internal.newObject(),n({data:S(new Uint8Array(t.palette))}),e(\"endobj\"))},a=function(){var t=this.internal.collections.addImage_images;for(var e in t)i.call(this,t[e])},u=function(){var t,e=this.internal.collections.addImage_images,n=this.internal.write;for(var r in e)n(\"/I\"+(t=e[r]).index,t.objectId,\"0\",\"R\")},c=function(){this.internal.collections.addImage_images||(this.internal.collections.addImage_images={},this.internal.events.subscribe(\"putResources\",a),this.internal.events.subscribe(\"putXobjectDict\",u))},h=function(){var t=this.internal.collections.addImage_images;return c.call(this),t},l=function(){return Object.keys(this.internal.collections.addImage_images).length},f=function(e){return\"function\"==typeof t[\"process\"+e.toUpperCase()]},d=function(t){return\"object\"==typeof t&&1===t.nodeType},p=function(e,n){if(\"IMG\"===e.nodeName&&e.hasAttribute(\"src\")){var r=\"\"+e.getAttribute(\"src\");if(0===r.indexOf(\"data:image/\"))return o(unescape(r).split(\"base64,\").pop());var i=t.loadFile(r,!0);if(void 0!==i)return i}if(\"CANVAS\"===e.nodeName){var a;switch(n){case\"PNG\":a=\"image/png\";break;case\"WEBP\":a=\"image/webp\";break;case\"JPEG\":case\"JPG\":default:a=\"image/jpeg\"}return o(e.toDataURL(a,1).split(\"base64,\").pop())}},g=function(t){var e=this.internal.collections.addImage_images;if(e)for(var n in e)if(t===e[n].alias)return e[n]},m=function(t,e,n){return t||e||(t=-96,e=-96),t<0&&(t=-1*n.width*72/t/this.internal.scaleFactor),e<0&&(e=-1*n.height*72/e/this.internal.scaleFactor),0===t&&(t=e*n.width/n.height),0===e&&(e=t*n.height/n.width),[t,e]},v=function(t,e,n,r,i,a){var o=m.call(this,n,r,i),s=this.internal.getCoordinateString,u=this.internal.getVerticalCoordinateString,c=h.call(this);if(n=o[0],r=o[1],c[i.index]=i,a){a*=Math.PI/180;var l=Math.cos(a),f=Math.sin(a),d=function(t){return t.toFixed(4)},p=[d(l),d(f),d(-1*f),d(l),0,0,\"cm\"]}this.internal.write(\"q\"),a?(this.internal.write([1,\"0\",\"0\",1,s(t),u(e+r),\"cm\"].join(\" \")),this.internal.write(p.join(\" \")),this.internal.write([s(n),\"0\",\"0\",s(r),\"0\",\"0\",\"cm\"].join(\" \"))):this.internal.write([s(n),\"0\",\"0\",s(r),s(t),u(e+r),\"cm\"].join(\" \")),this.isAdvancedAPI()&&this.internal.write([1,0,0,-1,0,0,\"cm\"].join(\" \")),this.internal.write(\"/I\"+i.index+\" Do\"),this.internal.write(\"Q\")},b=t.color_spaces={DEVICE_RGB:\"DeviceRGB\",DEVICE_GRAY:\"DeviceGray\",DEVICE_CMYK:\"DeviceCMYK\",CAL_GREY:\"CalGray\",CAL_RGB:\"CalRGB\",LAB:\"Lab\",ICC_BASED:\"ICCBased\",INDEXED:\"Indexed\",PATTERN:\"Pattern\",SEPARATION:\"Separation\",DEVICE_N:\"DeviceN\"};t.decode={DCT_DECODE:\"DCTDecode\",FLATE_DECODE:\"FlateDecode\",LZW_DECODE:\"LZWDecode\",JPX_DECODE:\"JPXDecode\",JBIG2_DECODE:\"JBIG2Decode\",ASCII85_DECODE:\"ASCII85Decode\",ASCII_HEX_DECODE:\"ASCIIHexDecode\",RUN_LENGTH_DECODE:\"RunLengthDecode\",CCITT_FAX_DECODE:\"CCITTFaxDecode\"};var y=t.image_compression={NONE:\"NONE\",FAST:\"FAST\",MEDIUM:\"MEDIUM\",SLOW:\"SLOW\"},w=t.__addimage__.sHashCode=function(t){var e,n,r=0;if(\"string\"==typeof t)for(n=t.length,e=0;e<n;e++)r=(r<<5)-r+t.charCodeAt(e),r|=0;else if(A(t))for(n=t.byteLength/2,e=0;e<n;e++)r=(r<<5)-r+t[e],r|=0;return r},N=t.__addimage__.validateStringAsBase64=function(t){(t=t||\"\").toString().trim();var e=!0;return 0===t.length&&(e=!1),t.length%4!=0&&(e=!1),!1===/^[A-Za-z0-9+/]+$/.test(t.substr(0,t.length-2))&&(e=!1),!1===/^[A-Za-z0-9/][A-Za-z0-9+/]|[A-Za-z0-9+/]=|==$/.test(t.substr(-2))&&(e=!1),e},L=t.__addimage__.extractImageFromDataUrl=function(t){var e=(t=t||\"\").split(\"base64,\"),n=null;if(2===e.length){var r=/^data:(\\w*\\/\\w*);*(charset=[\\w=-]*)*;*$/.exec(e[0]);Array.isArray(r)&&(n={mimeType:r[1],charset:r[2],data:e[1]})}return n},x=t.__addimage__.supportsArrayBuffer=function(){return\"undefined\"!=typeof ArrayBuffer&&\"undefined\"!=typeof Uint8Array};t.__addimage__.isArrayBuffer=function(t){return x()&&t instanceof ArrayBuffer};var A=t.__addimage__.isArrayBufferView=function(t){return x()&&\"undefined\"!=typeof Uint32Array&&(t instanceof Int8Array||t instanceof Uint8Array||\"undefined\"!=typeof Uint8ClampedArray&&t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)},_=t.__addimage__.binaryStringToUint8Array=function(t){for(var e=t.length,n=new Uint8Array(e),r=0;r<e;r++)n[r]=t.charCodeAt(r);return n},S=t.__addimage__.arrayBufferToBinaryString=function(t){try{return o(s(String.fromCharCode.apply(null,t)))}catch(e){if(\"undefined\"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.reduce)return new Uint8Array(t).reduce((function(t,e){return t.push(String.fromCharCode(e)),t}),[]).join(\"\")}};t.addImage=function(){var t,n,r,i,a,o,s,u,h;if(\"number\"==typeof arguments[1]?(n=e,r=arguments[1],i=arguments[2],a=arguments[3],o=arguments[4],s=arguments[5],u=arguments[6],h=arguments[7]):(n=arguments[1],r=arguments[2],i=arguments[3],a=arguments[4],o=arguments[5],s=arguments[6],u=arguments[7],h=arguments[8]),\"object\"==typeof(t=arguments[0])&&!d(t)&&\"imageData\"in t){var l=t;t=l.imageData,n=l.format||n||e,r=l.x||r||0,i=l.y||i||0,a=l.w||l.width||a,o=l.h||l.height||o,s=l.alias||s,u=l.compression||u,h=l.rotation||l.angle||h}var f=this.internal.getFilters();if(void 0===u&&-1!==f.indexOf(\"FlateEncode\")&&(u=\"SLOW\"),isNaN(r)||isNaN(i))throw new Error(\"Invalid coordinates passed to jsPDF.addImage\");c.call(this);var p=P.call(this,t,n,s,u);return v.call(this,r,i,a,o,p,h),this};var P=function(n,i,a,o){var s,u,c;if(\"string\"==typeof n&&r(n)===e){n=unescape(n);var h=k(n,!1);(\"\"!==h||void 0!==(h=t.loadFile(n,!0)))&&(n=h)}if(d(n)&&(n=p(n,i)),i=r(n,i),!f(i))throw new Error(\"addImage does not support files of type '\"+i+\"', please ensure that a plugin for '\"+i+\"' support is added.\");if((null==(c=a)||0===c.length)&&(a=function(t){return\"string\"==typeof t||A(t)?w(t):null}(n)),(s=g.call(this,a))||(x()&&(n instanceof Uint8Array||(u=n,n=_(n))),s=this[\"process\"+i.toUpperCase()](n,l.call(this),a,function(e){return e&&\"string\"==typeof e&&(e=e.toUpperCase()),e in t.image_compression?e:y.NONE}(o),u)),!s)throw new Error(\"An unknown error occurred whilst processing the image.\");return s},k=t.__addimage__.convertBase64ToBinaryString=function(t,e){var n;e=\"boolean\"!=typeof e||e;var r,i=\"\";if(\"string\"==typeof t){r=null!==(n=L(t))?n.data:t;try{i=o(r)}catch(t){if(e)throw N(r)?new Error(\"atob-Error in jsPDF.convertBase64ToBinaryString \"+t.message):new Error(\"Supplied Data is not a valid base64-String jsPDF.convertBase64ToBinaryString \")}}return i};t.getImageProperties=function(n){var i,a,o=\"\";if(d(n)&&(n=p(n)),\"string\"==typeof n&&r(n)===e&&(\"\"===(o=k(n,!1))&&(o=t.loadFile(n)||\"\"),n=o),a=r(n),!f(a))throw new Error(\"addImage does not support files of type '\"+a+\"', please ensure that a plugin for '\"+a+\"' support is added.\");if(!x()||n instanceof Uint8Array||(n=_(n)),!(i=this[\"process\"+a.toUpperCase()](n)))throw new Error(\"An unknown error occurred whilst processing the image\");return i.fileType=a,i}}(g.API),\n/**\n * @license\n * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */\nfunction(t){var e=function(t){if(void 0!==t&&\"\"!=t)return!0};g.API.events.push([\"addPage\",function(t){this.internal.getPageInfo(t.pageNumber).pageContext.annotations=[]}]),t.events.push([\"putPage\",function(t){for(var n,r,i,a=this.internal.getCoordinateString,o=this.internal.getVerticalCoordinateString,s=this.internal.getPageInfoByObjId(t.objId),u=t.pageContext.annotations,c=!1,h=0;h<u.length&&!c;h++)switch((n=u[h]).type){case\"link\":(e(n.options.url)||e(n.options.pageNumber))&&(c=!0);break;case\"reference\":case\"text\":case\"freetext\":c=!0}if(0!=c){this.internal.write(\"/Annots [\");for(var l=0;l<u.length;l++)switch((n=u[l]).type){case\"reference\":this.internal.write(\" \"+n.object.objId+\" 0 R \");break;case\"text\":var f=this.internal.newAdditionalObject(),d=this.internal.newAdditionalObject(),p=n.title||\"Note\";i=\"<</Type /Annot /Subtype /Text \"+(r=\"/Rect [\"+a(n.bounds.x)+\" \"+o(n.bounds.y+n.bounds.h)+\" \"+a(n.bounds.x+n.bounds.w)+\" \"+o(n.bounds.y)+\"] \")+\"/Contents (\"+n.contents+\")\",i+=\" /Popup \"+d.objId+\" 0 R\",i+=\" /P \"+s.objId+\" 0 R\",i+=\" /T (\"+p+\") >>\",f.content=i;var g=f.objId+\" 0 R\";i=\"<</Type /Annot /Subtype /Popup \"+(r=\"/Rect [\"+a(n.bounds.x+30)+\" \"+o(n.bounds.y+n.bounds.h)+\" \"+a(n.bounds.x+n.bounds.w+30)+\" \"+o(n.bounds.y)+\"] \")+\" /Parent \"+g,n.open&&(i+=\" /Open true\"),i+=\" >>\",d.content=i,this.internal.write(f.objId,\"0 R\",d.objId,\"0 R\");break;case\"freetext\":r=\"/Rect [\"+a(n.bounds.x)+\" \"+o(n.bounds.y)+\" \"+a(n.bounds.x+n.bounds.w)+\" \"+o(n.bounds.y+n.bounds.h)+\"] \";var m=n.color||\"#000000\";i=\"<</Type /Annot /Subtype /FreeText \"+r+\"/Contents (\"+n.contents+\")\",i+=\" /DS(font: Helvetica,sans-serif 12.0pt; text-align:left; color:#\"+m+\")\",i+=\" /Border [0 0 0]\",i+=\" >>\",this.internal.write(i);break;case\"link\":if(n.options.name){var v=this.annotations._nameMap[n.options.name];n.options.pageNumber=v.page,n.options.top=v.y}else n.options.top||(n.options.top=0);if(r=\"/Rect [\"+a(n.x)+\" \"+o(n.y)+\" \"+a(n.x+n.w)+\" \"+o(n.y+n.h)+\"] \",i=\"\",n.options.url)i=\"<</Type /Annot /Subtype /Link \"+r+\"/Border [0 0 0] /A <</S /URI /URI (\"+n.options.url+\") >>\";else if(n.options.pageNumber){switch(i=\"<</Type /Annot /Subtype /Link \"+r+\"/Border [0 0 0] /Dest [\"+this.internal.getPageInfo(n.options.pageNumber).objId+\" 0 R\",n.options.magFactor=n.options.magFactor||\"XYZ\",n.options.magFactor){case\"Fit\":i+=\" /Fit]\";break;case\"FitH\":i+=\" /FitH \"+n.options.top+\"]\";break;case\"FitV\":n.options.left=n.options.left||0,i+=\" /FitV \"+n.options.left+\"]\";break;case\"XYZ\":default:var b=o(n.options.top);n.options.left=n.options.left||0,void 0===n.options.zoom&&(n.options.zoom=0),i+=\" /XYZ \"+n.options.left+\" \"+b+\" \"+n.options.zoom+\"]\"}}\"\"!=i&&(i+=\" >>\",this.internal.write(i))}this.internal.write(\"]\")}}]),t.createAnnotation=function(t){var e=this.internal.getCurrentPageInfo();switch(t.type){case\"link\":this.link(t.bounds.x,t.bounds.y,t.bounds.w,t.bounds.h,t);break;case\"text\":case\"freetext\":e.pageContext.annotations.push(t)}},t.link=function(t,e,n,r,i){this.internal.getCurrentPageInfo().pageContext.annotations.push({x:t,y:e,w:n,h:r,options:i,type:\"link\"})},t.textWithLink=function(t,e,n,r){var i=this.getTextWidth(t),a=this.internal.getLineHeight()/this.internal.scaleFactor;return this.text(t,e,n,r),n+=.2*a,this.link(e,n-a,i,a,r),i},t.getTextWidth=function(t){var e=this.internal.getFontSize();return this.getStringUnitWidth(t)*e/this.internal.scaleFactor}}(g.API),\n/**\n * @license\n * Copyright (c) 2017 Aras Abbasi\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */\nfunction(t){var e={1569:[65152],1570:[65153,65154],1571:[65155,65156],1572:[65157,65158],1573:[65159,65160],1574:[65161,65162,65163,65164],1575:[65165,65166],1576:[65167,65168,65169,65170],1577:[65171,65172],1578:[65173,65174,65175,65176],1579:[65177,65178,65179,65180],1580:[65181,65182,65183,65184],1581:[65185,65186,65187,65188],1582:[65189,65190,65191,65192],1583:[65193,65194],1584:[65195,65196],1585:[65197,65198],1586:[65199,65200],1587:[65201,65202,65203,65204],1588:[65205,65206,65207,65208],1589:[65209,65210,65211,65212],1590:[65213,65214,65215,65216],1591:[65217,65218,65219,65220],1592:[65221,65222,65223,65224],1593:[65225,65226,65227,65228],1594:[65229,65230,65231,65232],1601:[65233,65234,65235,65236],1602:[65237,65238,65239,65240],1603:[65241,65242,65243,65244],1604:[65245,65246,65247,65248],1605:[65249,65250,65251,65252],1606:[65253,65254,65255,65256],1607:[65257,65258,65259,65260],1608:[65261,65262],1609:[65263,65264,64488,64489],1610:[65265,65266,65267,65268],1649:[64336,64337],1655:[64477],1657:[64358,64359,64360,64361],1658:[64350,64351,64352,64353],1659:[64338,64339,64340,64341],1662:[64342,64343,64344,64345],1663:[64354,64355,64356,64357],1664:[64346,64347,64348,64349],1667:[64374,64375,64376,64377],1668:[64370,64371,64372,64373],1670:[64378,64379,64380,64381],1671:[64382,64383,64384,64385],1672:[64392,64393],1676:[64388,64389],1677:[64386,64387],1678:[64390,64391],1681:[64396,64397],1688:[64394,64395],1700:[64362,64363,64364,64365],1702:[64366,64367,64368,64369],1705:[64398,64399,64400,64401],1709:[64467,64468,64469,64470],1711:[64402,64403,64404,64405],1713:[64410,64411,64412,64413],1715:[64406,64407,64408,64409],1722:[64414,64415],1723:[64416,64417,64418,64419],1726:[64426,64427,64428,64429],1728:[64420,64421],1729:[64422,64423,64424,64425],1733:[64480,64481],1734:[64473,64474],1735:[64471,64472],1736:[64475,64476],1737:[64482,64483],1739:[64478,64479],1740:[64508,64509,64510,64511],1744:[64484,64485,64486,64487],1746:[64430,64431],1747:[64432,64433]},n={65247:{65154:65269,65156:65271,65160:65273,65166:65275},65248:{65154:65270,65156:65272,65160:65274,65166:65276},65165:{65247:{65248:{65258:65010}}},1617:{1612:64606,1613:64607,1614:64608,1615:64609,1616:64610}},r={1612:64606,1613:64607,1614:64608,1615:64609,1616:64610},i=[1570,1571,1573,1575];t.__arabicParser__={};var a=t.__arabicParser__.isInArabicSubstitutionA=function(t){return void 0!==e[t.charCodeAt(0)]},o=t.__arabicParser__.isArabicLetter=function(t){return\"string\"==typeof t&&/^[\\u0600-\\u06FF\\u0750-\\u077F\\u08A0-\\u08FF\\uFB50-\\uFDFF\\uFE70-\\uFEFF]+$/.test(t)},s=t.__arabicParser__.isArabicEndLetter=function(t){return o(t)&&a(t)&&e[t.charCodeAt(0)].length<=2},u=t.__arabicParser__.isArabicAlfLetter=function(t){return o(t)&&i.indexOf(t.charCodeAt(0))>=0};t.__arabicParser__.arabicLetterHasIsolatedForm=function(t){return o(t)&&a(t)&&e[t.charCodeAt(0)].length>=1};var c=t.__arabicParser__.arabicLetterHasFinalForm=function(t){return o(t)&&a(t)&&e[t.charCodeAt(0)].length>=2};t.__arabicParser__.arabicLetterHasInitialForm=function(t){return o(t)&&a(t)&&e[t.charCodeAt(0)].length>=3};var h=t.__arabicParser__.arabicLetterHasMedialForm=function(t){return o(t)&&a(t)&&4==e[t.charCodeAt(0)].length},l=t.__arabicParser__.resolveLigatures=function(t){var e=0,r=n,i=\"\",a=0;for(e=0;e<t.length;e+=1)void 0!==r[t.charCodeAt(e)]?(a++,\"number\"==typeof(r=r[t.charCodeAt(e)])&&(i+=String.fromCharCode(r),r=n,a=0),e===t.length-1&&(r=n,i+=t.charAt(e-(a-1)),e-=a-1,a=0)):(r=n,i+=t.charAt(e-a),e-=a,a=0);return i};t.__arabicParser__.isArabicDiacritic=function(t){return void 0!==t&&void 0!==r[t.charCodeAt(0)]};var f=t.__arabicParser__.getCorrectForm=function(t,e,n){return o(t)?!1===a(t)?-1:!c(t)||!o(e)&&!o(n)||!o(n)&&s(e)||s(t)&&!o(e)||s(t)&&u(e)||s(t)&&s(e)?0:h(t)&&o(e)&&!s(e)&&o(n)&&c(n)?3:s(t)||!o(n)?1:2:-1},d=function(t){var n=0,r=0,i=0,a=\"\",s=\"\",u=\"\",c=(t=t||\"\").split(\"\\\\s+\"),h=[];for(n=0;n<c.length;n+=1){for(h.push(\"\"),r=0;r<c[n].length;r+=1)a=c[n][r],s=c[n][r-1],u=c[n][r+1],o(a)?(i=f(a,s,u),h[n]+=-1!==i?String.fromCharCode(e[a.charCodeAt(0)][i]):a):h[n]+=a;h[n]=l(h[n])}return h.join(\" \")},p=t.__arabicParser__.processArabic=t.processArabic=function(){var t,e=\"string\"==typeof arguments[0]?arguments[0]:arguments[0].text,n=[];if(Array.isArray(e)){var r=0;for(n=[],r=0;r<e.length;r+=1)Array.isArray(e[r])?n.push([d(e[r][0]),e[r][1],e[r][2]]):n.push([d(e[r])]);t=n}else t=d(e);return\"string\"==typeof arguments[0]?t:(arguments[0].text=t,arguments[0])};t.events.push([\"preProcessText\",p])}(g.API),g.API.autoPrint=function(t){var e;switch((t=t||{}).variant=t.variant||\"non-conform\",t.variant){case\"javascript\":this.addJS(\"print({});\");break;case\"non-conform\":default:this.internal.events.subscribe(\"postPutResources\",(function(){e=this.internal.newObject(),this.internal.out(\"<<\"),this.internal.out(\"/S /Named\"),this.internal.out(\"/Type /Action\"),this.internal.out(\"/N /Print\"),this.internal.out(\">>\"),this.internal.out(\"endobj\")})),this.internal.events.subscribe(\"putCatalog\",(function(){this.internal.out(\"/OpenAction \"+e+\" 0 R\")}))}return this},\n/**\n * @license\n * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */\nfunction(t){var e=function(){var t=void 0;Object.defineProperty(this,\"pdf\",{get:function(){return t},set:function(e){t=e}});var e=150;Object.defineProperty(this,\"width\",{get:function(){return e},set:function(t){e=isNaN(t)||!1===Number.isInteger(t)||t<0?150:t,this.getContext(\"2d\").pageWrapXEnabled&&(this.getContext(\"2d\").pageWrapX=e+1)}});var n=300;Object.defineProperty(this,\"height\",{get:function(){return n},set:function(t){n=isNaN(t)||!1===Number.isInteger(t)||t<0?300:t,this.getContext(\"2d\").pageWrapYEnabled&&(this.getContext(\"2d\").pageWrapY=n+1)}});var r=[];Object.defineProperty(this,\"childNodes\",{get:function(){return r},set:function(t){r=t}});var i={};Object.defineProperty(this,\"style\",{get:function(){return i},set:function(t){i=t}}),Object.defineProperty(this,\"parentNode\",{})};e.prototype.getContext=function(t,e){var n;if(\"2d\"!==(t=t||\"2d\"))return null;for(n in e)this.pdf.context2d.hasOwnProperty(n)&&(this.pdf.context2d[n]=e[n]);return this.pdf.context2d._canvas=this,this.pdf.context2d},e.prototype.toDataURL=function(){throw new Error(\"toDataURL is not implemented.\")},t.events.push([\"initialized\",function(){this.canvas=new e,this.canvas.pdf=this}])}(g.API),\n/**\n * @license\n * ====================================================================\n * Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com\n * 2013 Eduardo Menezes de Morais, eduardo.morais@usp.br\n * 2013 Lee Driscoll, https://github.com/lsdriscoll\n * 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria\n * 2014 James Hall, james@parall.ax\n * 2014 Diego Casorran, https://github.com/diegocr\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n * ====================================================================\n */\nfunction(t){var e={left:0,top:0,bottom:0,right:0},n=!1,r=function(){void 0===this.internal.__cell__&&(this.internal.__cell__={},this.internal.__cell__.padding=3,this.internal.__cell__.headerFunction=void 0,this.internal.__cell__.margins=Object.assign({},e),this.internal.__cell__.margins.width=this.getPageWidth(),i.call(this))},i=function(){this.internal.__cell__.lastCell=new a,this.internal.__cell__.pages=1},a=function(){var t=arguments[0];Object.defineProperty(this,\"x\",{enumerable:!0,get:function(){return t},set:function(e){t=e}});var e=arguments[1];Object.defineProperty(this,\"y\",{enumerable:!0,get:function(){return e},set:function(t){e=t}});var n=arguments[2];Object.defineProperty(this,\"width\",{enumerable:!0,get:function(){return n},set:function(t){n=t}});var r=arguments[3];Object.defineProperty(this,\"height\",{enumerable:!0,get:function(){return r},set:function(t){r=t}});var i=arguments[4];Object.defineProperty(this,\"text\",{enumerable:!0,get:function(){return i},set:function(t){i=t}});var a=arguments[5];Object.defineProperty(this,\"lineNumber\",{enumerable:!0,get:function(){return a},set:function(t){a=t}});var o=arguments[6];return Object.defineProperty(this,\"align\",{enumerable:!0,get:function(){return o},set:function(t){o=t}}),this};a.prototype.clone=function(){return new a(this.x,this.y,this.width,this.height,this.text,this.lineNumber,this.align)},a.prototype.toArray=function(){return[this.x,this.y,this.width,this.height,this.text,this.lineNumber,this.align]},t.setHeaderFunction=function(t){return r.call(this),this.internal.__cell__.headerFunction=\"function\"==typeof t?t:void 0,this},t.getTextDimensions=function(t,e){r.call(this);var n=(e=e||{}).fontSize||this.getFontSize(),i=e.font||this.getFont(),a=e.scaleFactor||this.internal.scaleFactor,o=0,s=0,u=0;if(!Array.isArray(t)&&\"string\"!=typeof t){if(\"number\"!=typeof t)throw new Error(\"getTextDimensions expects text-parameter to be of type String or type Number or an Array of Strings.\");t=String(t)}const c=e.maxWidth;c>0?\"string\"==typeof t?t=this.splitTextToSize(t,c):\"[object Array]\"===Object.prototype.toString.call(t)&&(t=this.splitTextToSize(t.join(\" \"),c)):t=Array.isArray(t)?t:[t];for(var h=0;h<t.length;h++)o<(u=this.getStringUnitWidth(t[h],{font:i})*n)&&(o=u);return 0!==o&&(s=t.length),{w:o/=a,h:Math.max((s*n*this.getLineHeightFactor()-n*(this.getLineHeightFactor()-1))/a,0)}},t.cellAddPage=function(){r.call(this),this.addPage();var t=this.internal.__cell__.margins||e;return this.internal.__cell__.lastCell=new a(t.left,t.top,void 0,void 0),this.internal.__cell__.pages+=1,this};var o=t.cell=function(){var t;t=arguments[0]instanceof a?arguments[0]:new a(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]),r.call(this);var i=this.internal.__cell__.lastCell,o=this.internal.__cell__.padding,s=this.internal.__cell__.margins||e,u=this.internal.__cell__.tableHeaderRow,c=this.internal.__cell__.printHeaders;return void 0!==i.lineNumber&&(i.lineNumber===t.lineNumber?(t.x=(i.x||0)+(i.width||0),t.y=i.y||0):i.y+i.height+t.height+s.bottom>this.getPageHeight()?(this.cellAddPage(),t.y=s.top,c&&u&&(this.printHeaderRow(t.lineNumber,!0),t.y+=u[0].height)):t.y=i.y+i.height||t.y),void 0!==t.text[0]&&(this.rect(t.x,t.y,t.width,t.height,!0===n?\"FD\":void 0),\"right\"===t.align?this.text(t.text,t.x+t.width-o,t.y+o,{align:\"right\",baseline:\"top\"}):\"center\"===t.align?this.text(t.text,t.x+t.width/2,t.y+o,{align:\"center\",baseline:\"top\",maxWidth:t.width-o-o}):this.text(t.text,t.x+o,t.y+o,{align:\"left\",baseline:\"top\",maxWidth:t.width-o-o})),this.internal.__cell__.lastCell=t,this};t.table=function(t,n,u,c,h){if(r.call(this),!u)throw new Error(\"No data for PDF table.\");var l,f,d,p,g=[],m=[],v=[],b={},y={},w=[],N=[],L=(h=h||{}).autoSize||!1,x=!1!==h.printHeaders,A=h.css&&void 0!==h.css[\"font-size\"]?16*h.css[\"font-size\"]:h.fontSize||12,_=h.margins||Object.assign({width:this.getPageWidth()},e),S=\"number\"==typeof h.padding?h.padding:3,P=h.headerBackgroundColor||\"#c8c8c8\";if(i.call(this),this.internal.__cell__.printHeaders=x,this.internal.__cell__.margins=_,this.internal.__cell__.table_font_size=A,this.internal.__cell__.padding=S,this.internal.__cell__.headerBackgroundColor=P,this.setFontSize(A),null==c)m=g=Object.keys(u[0]),v=g.map((function(){return\"left\"}));else if(Array.isArray(c)&&\"object\"==typeof c[0])for(g=c.map((function(t){return t.name})),m=c.map((function(t){return t.prompt||t.name||\"\"})),v=g.map((function(t){return t.align||\"left\"})),l=0;l<c.length;l+=1)y[c[l].name]=c[l].width*(19.049976/25.4);else Array.isArray(c)&&\"string\"==typeof c[0]&&(m=g=c,v=g.map((function(){return\"left\"})));if(L)for(l=0;l<g.length;l+=1){for(b[p=g[l]]=u.map((function(t){return t[p]})),this.setFont(void 0,\"bold\"),w.push(this.getTextDimensions(m[l],{fontSize:this.internal.__cell__.table_font_size,scaleFactor:this.internal.scaleFactor}).w),f=b[p],this.setFont(void 0,\"normal\"),d=0;d<f.length;d+=1)w.push(this.getTextDimensions(f[d],{fontSize:this.internal.__cell__.table_font_size,scaleFactor:this.internal.scaleFactor}).w);y[p]=Math.max.apply(null,w)+S+S,w=[]}if(x){var k={};for(l=0;l<g.length;l+=1)k[g[l]]={},k[g[l]].text=m[l],k[g[l]].align=v[l];var F=s.call(this,k,y);N=g.map((function(e){return new a(t,n,y[e],F,k[e].text,void 0,k[e].align)})),this.setTableHeaderRow(N),this.printHeaderRow(1,!1)}var I=c.reduce((function(t,e){return t[e.name]=e.align,t}),{});for(l=0;l<u.length;l+=1){var C=s.call(this,u[l],y);for(d=0;d<g.length;d+=1)o.call(this,new a(t,n,y[g[d]],C,u[l][g[d]],l+2,I[g[d]]))}return this.internal.__cell__.table_x=t,this.internal.__cell__.table_y=n,this};var s=function(t,e){var n=this.internal.__cell__.padding,r=this.internal.__cell__.table_font_size,i=this.internal.scaleFactor;return Object.keys(t).map((function(e){return[e,t[e]]})).map((function(t){var e=t[0],n=t[1];return\"object\"==typeof n?[e,n.text]:[e,n]})).map((function(t){var r=t[0],i=t[1];return this.splitTextToSize(i,e[r]-n-n)}),this).map((function(t){return this.getLineHeightFactor()*t.length*r/i+n+n}),this).reduce((function(t,e){return Math.max(t,e)}),0)};t.setTableHeaderRow=function(t){r.call(this),this.internal.__cell__.tableHeaderRow=t},t.printHeaderRow=function(t,e){if(r.call(this),!this.internal.__cell__.tableHeaderRow)throw new Error(\"Property tableHeaderRow does not exist.\");var i;if(n=!0,\"function\"==typeof this.internal.__cell__.headerFunction){var s=this.internal.__cell__.headerFunction(this,this.internal.__cell__.pages);this.internal.__cell__.lastCell=new a(s[0],s[1],s[2],s[3],void 0,-1)}this.setFont(void 0,\"bold\");for(var u=[],c=0;c<this.internal.__cell__.tableHeaderRow.length;c+=1)i=this.internal.__cell__.tableHeaderRow[c].clone(),e&&(i.y=this.internal.__cell__.margins.top||0,u.push(i)),i.lineNumber=t,this.setFillColor(this.internal.__cell__.headerBackgroundColor),o.call(this,i);u.length>0&&this.setTableHeaderRow(u),this.setFont(void 0,\"normal\"),n=!1}}(g.API),function(t){var e,r,i,a,o,s,u,h,l,f=function(t){return t=t||{},this.isStrokeTransparent=t.isStrokeTransparent||!1,this.strokeOpacity=t.strokeOpacity||1,this.strokeStyle=t.strokeStyle||\"#000000\",this.fillStyle=t.fillStyle||\"#000000\",this.isFillTransparent=t.isFillTransparent||!1,this.fillOpacity=t.fillOpacity||1,this.font=t.font||\"10px sans-serif\",this.textBaseline=t.textBaseline||\"alphabetic\",this.textAlign=t.textAlign||\"left\",this.lineWidth=t.lineWidth||1,this.lineJoin=t.lineJoin||\"miter\",this.lineCap=t.lineCap||\"butt\",this.path=t.path||[],this.transform=void 0!==t.transform?t.transform.clone():new h,this.globalCompositeOperation=t.globalCompositeOperation||\"normal\",this.globalAlpha=t.globalAlpha||1,this.clip_path=t.clip_path||[],this.currentPoint=t.currentPoint||new s,this.miterLimit=t.miterLimit||10,this.lastPoint=t.lastPoint||new s,this.ignoreClearRect=\"boolean\"!=typeof t.ignoreClearRect||t.ignoreClearRect,this};t.events.push([\"initialized\",function(){this.context2d=new d(this),e=this.internal.f2,r=this.internal.getCoordinateString,i=this.internal.getVerticalCoordinateString,a=this.internal.getHorizontalCoordinate,o=this.internal.getVerticalCoordinate,s=this.internal.Point,u=this.internal.Rectangle,h=this.internal.Matrix,l=new f}]);var d=function(t){Object.defineProperty(this,\"canvas\",{get:function(){return{parentNode:!1,style:!1}}});var e=t;Object.defineProperty(this,\"pdf\",{get:function(){return e}});var n=!1;Object.defineProperty(this,\"pageWrapXEnabled\",{get:function(){return n},set:function(t){n=Boolean(t)}});var r=!1;Object.defineProperty(this,\"pageWrapYEnabled\",{get:function(){return r},set:function(t){r=Boolean(t)}});var i=0;Object.defineProperty(this,\"posX\",{get:function(){return i},set:function(t){isNaN(t)||(i=t)}});var a=0;Object.defineProperty(this,\"posY\",{get:function(){return a},set:function(t){isNaN(t)||(a=t)}});var o=!1;Object.defineProperty(this,\"autoPaging\",{get:function(){return o},set:function(t){o=Boolean(t)}});var s=0;Object.defineProperty(this,\"lastBreak\",{get:function(){return s},set:function(t){s=t}});var u=[];Object.defineProperty(this,\"pageBreaks\",{get:function(){return u},set:function(t){u=t}}),Object.defineProperty(this,\"ctx\",{get:function(){return l},set:function(t){t instanceof f&&(l=t)}}),Object.defineProperty(this,\"path\",{get:function(){return l.path},set:function(t){l.path=t}});var c=[];Object.defineProperty(this,\"ctxStack\",{get:function(){return c},set:function(t){c=t}}),Object.defineProperty(this,\"fillStyle\",{get:function(){return this.ctx.fillStyle},set:function(t){var e;e=p(t),this.ctx.fillStyle=e.style,this.ctx.isFillTransparent=0===e.a,this.ctx.fillOpacity=e.a,this.pdf.setFillColor(e.r,e.g,e.b,{a:e.a}),this.pdf.setTextColor(e.r,e.g,e.b,{a:e.a})}}),Object.defineProperty(this,\"strokeStyle\",{get:function(){return this.ctx.strokeStyle},set:function(t){var e=p(t);this.ctx.strokeStyle=e.style,this.ctx.isStrokeTransparent=0===e.a,this.ctx.strokeOpacity=e.a,0===e.a?this.pdf.setDrawColor(255,255,255):(e.a,this.pdf.setDrawColor(e.r,e.g,e.b))}}),Object.defineProperty(this,\"lineCap\",{get:function(){return this.ctx.lineCap},set:function(t){-1!==[\"butt\",\"round\",\"square\"].indexOf(t)&&(this.ctx.lineCap=t,this.pdf.setLineCap(t))}}),Object.defineProperty(this,\"lineWidth\",{get:function(){return this.ctx.lineWidth},set:function(t){isNaN(t)||(this.ctx.lineWidth=t,this.pdf.setLineWidth(t))}}),Object.defineProperty(this,\"lineJoin\",{get:function(){return this.ctx.lineJoin},set:function(t){-1!==[\"bevel\",\"round\",\"miter\"].indexOf(t)&&(this.ctx.lineJoin=t,this.pdf.setLineJoin(t))}}),Object.defineProperty(this,\"miterLimit\",{get:function(){return this.ctx.miterLimit},set:function(t){isNaN(t)||(this.ctx.miterLimit=t,this.pdf.setMiterLimit(t))}}),Object.defineProperty(this,\"textBaseline\",{get:function(){return this.ctx.textBaseline},set:function(t){this.ctx.textBaseline=t}}),Object.defineProperty(this,\"textAlign\",{get:function(){return this.ctx.textAlign},set:function(t){-1!==[\"right\",\"end\",\"center\",\"left\",\"start\"].indexOf(t)&&(this.ctx.textAlign=t)}}),Object.defineProperty(this,\"font\",{get:function(){return this.ctx.font},set:function(t){var e;if(this.ctx.font=t,null!==(e=/^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))(?:\\s*\\/\\s*(normal|[.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])))?\\s*([-_,\\\"\\'\\sa-z]+?)\\s*$/i.exec(t))){var n=e[1],r=(e[2],e[3]),i=e[4],a=(e[5],e[6]),o=/^([.\\d]+)((?:%|in|[cem]m|ex|p[ctx]))$/i.exec(i)[2];i=\"px\"===o?Math.floor(parseFloat(i)*this.pdf.internal.scaleFactor):\"em\"===o?Math.floor(parseFloat(i)*this.pdf.getFontSize()):Math.floor(parseFloat(i)*this.pdf.internal.scaleFactor),this.pdf.setFontSize(i);var s=\"\";(\"bold\"===r||parseInt(r,10)>=700||\"bold\"===n)&&(s=\"bold\"),\"italic\"===n&&(s+=\"italic\"),0===s.length&&(s=\"normal\");for(var u=\"\",c=a.replace(/\"|'/g,\"\").split(/\\s*,\\s*/),h={arial:\"Helvetica\",Arial:\"Helvetica\",verdana:\"Helvetica\",Verdana:\"Helvetica\",helvetica:\"Helvetica\",Helvetica:\"Helvetica\",\"sans-serif\":\"Helvetica\",fixed:\"Courier\",monospace:\"Courier\",terminal:\"Courier\",cursive:\"Times\",fantasy:\"Times\",serif:\"Times\"},l=0;l<c.length;l++){if(void 0!==this.pdf.internal.getFont(c[l],s,{noFallback:!0,disableWarning:!0})){u=c[l];break}if(\"bolditalic\"===s&&void 0!==this.pdf.internal.getFont(c[l],\"bold\",{noFallback:!0,disableWarning:!0}))u=c[l],s=\"bold\";else if(void 0!==this.pdf.internal.getFont(c[l],\"normal\",{noFallback:!0,disableWarning:!0})){u=c[l],s=\"normal\";break}}if(\"\"===u)for(var f=0;f<c.length;f++)if(h[c[f]]){u=h[c[f]];break}u=\"\"===u?\"Times\":u,this.pdf.setFont(u,s)}}}),Object.defineProperty(this,\"globalCompositeOperation\",{get:function(){return this.ctx.globalCompositeOperation},set:function(t){this.ctx.globalCompositeOperation=t}}),Object.defineProperty(this,\"globalAlpha\",{get:function(){return this.ctx.globalAlpha},set:function(t){this.ctx.globalAlpha=t}}),Object.defineProperty(this,\"ignoreClearRect\",{get:function(){return this.ctx.ignoreClearRect},set:function(t){this.ctx.ignoreClearRect=Boolean(t)}})};d.prototype.fill=function(){N.call(this,\"fill\",!1)},d.prototype.stroke=function(){N.call(this,\"stroke\",!1)},d.prototype.beginPath=function(){this.path=[{type:\"begin\"}]},d.prototype.moveTo=function(t,e){if(isNaN(t)||isNaN(e))throw n.error(\"jsPDF.context2d.moveTo: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.moveTo\");var r=this.ctx.transform.applyToPoint(new s(t,e));this.path.push({type:\"mt\",x:r.x,y:r.y}),this.ctx.lastPoint=new s(t,e)},d.prototype.closePath=function(){var t=new s(0,0),e=0;for(e=this.path.length-1;-1!==e;e--)if(\"begin\"===this.path[e].type&&\"object\"==typeof this.path[e+1]&&\"number\"==typeof this.path[e+1].x){t=new s(this.path[e+1].x,this.path[e+1].y),this.path.push({type:\"lt\",x:t.x,y:t.y});break}\"object\"==typeof this.path[e+2]&&\"number\"==typeof this.path[e+2].x&&this.path.push(JSON.parse(JSON.stringify(this.path[e+2]))),this.path.push({type:\"close\"}),this.ctx.lastPoint=new s(t.x,t.y)},d.prototype.lineTo=function(t,e){if(isNaN(t)||isNaN(e))throw n.error(\"jsPDF.context2d.lineTo: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.lineTo\");var r=this.ctx.transform.applyToPoint(new s(t,e));this.path.push({type:\"lt\",x:r.x,y:r.y}),this.ctx.lastPoint=new s(r.x,r.y)},d.prototype.clip=function(){this.ctx.clip_path=JSON.parse(JSON.stringify(this.path)),N.call(this,null,!0)},d.prototype.quadraticCurveTo=function(t,e,r,i){if(isNaN(r)||isNaN(i)||isNaN(t)||isNaN(e))throw n.error(\"jsPDF.context2d.quadraticCurveTo: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.quadraticCurveTo\");var a=this.ctx.transform.applyToPoint(new s(r,i)),o=this.ctx.transform.applyToPoint(new s(t,e));this.path.push({type:\"qct\",x1:o.x,y1:o.y,x:a.x,y:a.y}),this.ctx.lastPoint=new s(a.x,a.y)},d.prototype.bezierCurveTo=function(t,e,r,i,a,o){if(isNaN(a)||isNaN(o)||isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i))throw n.error(\"jsPDF.context2d.bezierCurveTo: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.bezierCurveTo\");var u=this.ctx.transform.applyToPoint(new s(a,o)),c=this.ctx.transform.applyToPoint(new s(t,e)),h=this.ctx.transform.applyToPoint(new s(r,i));this.path.push({type:\"bct\",x1:c.x,y1:c.y,x2:h.x,y2:h.y,x:u.x,y:u.y}),this.ctx.lastPoint=new s(u.x,u.y)},d.prototype.arc=function(t,e,r,i,a,o){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i)||isNaN(a))throw n.error(\"jsPDF.context2d.arc: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.arc\");if(o=Boolean(o),!this.ctx.transform.isIdentity){var u=this.ctx.transform.applyToPoint(new s(t,e));t=u.x,e=u.y;var c=this.ctx.transform.applyToPoint(new s(0,r)),h=this.ctx.transform.applyToPoint(new s(0,0));r=Math.sqrt(Math.pow(c.x-h.x,2)+Math.pow(c.y-h.y,2))}Math.abs(a-i)>=2*Math.PI&&(i=0,a=2*Math.PI),this.path.push({type:\"arc\",x:t,y:e,radius:r,startAngle:i,endAngle:a,counterclockwise:o})},d.prototype.arcTo=function(t,e,n,r,i){throw new Error(\"arcTo not implemented.\")},d.prototype.rect=function(t,e,r,i){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i))throw n.error(\"jsPDF.context2d.rect: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.rect\");this.moveTo(t,e),this.lineTo(t+r,e),this.lineTo(t+r,e+i),this.lineTo(t,e+i),this.lineTo(t,e),this.lineTo(t+r,e),this.lineTo(t,e)},d.prototype.fillRect=function(t,e,r,i){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i))throw n.error(\"jsPDF.context2d.fillRect: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.fillRect\");if(!g.call(this)){var a={};\"butt\"!==this.lineCap&&(a.lineCap=this.lineCap,this.lineCap=\"butt\"),\"miter\"!==this.lineJoin&&(a.lineJoin=this.lineJoin,this.lineJoin=\"miter\"),this.beginPath(),this.rect(t,e,r,i),this.fill(),a.hasOwnProperty(\"lineCap\")&&(this.lineCap=a.lineCap),a.hasOwnProperty(\"lineJoin\")&&(this.lineJoin=a.lineJoin)}},d.prototype.strokeRect=function(t,e,r,i){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i))throw n.error(\"jsPDF.context2d.strokeRect: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.strokeRect\");m.call(this)||(this.beginPath(),this.rect(t,e,r,i),this.stroke())},d.prototype.clearRect=function(t,e,r,i){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i))throw n.error(\"jsPDF.context2d.clearRect: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.clearRect\");this.ignoreClearRect||(this.fillStyle=\"#ffffff\",this.fillRect(t,e,r,i))},d.prototype.save=function(t){t=\"boolean\"!=typeof t||t;for(var e=this.pdf.internal.getCurrentPageInfo().pageNumber,n=0;n<this.pdf.internal.getNumberOfPages();n++)this.pdf.setPage(n+1),this.pdf.internal.out(\"q\");if(this.pdf.setPage(e),t){this.ctx.fontSize=this.pdf.internal.getFontSize();var r=new f(this.ctx);this.ctxStack.push(this.ctx),this.ctx=r}},d.prototype.restore=function(t){t=\"boolean\"!=typeof t||t;for(var e=this.pdf.internal.getCurrentPageInfo().pageNumber,n=0;n<this.pdf.internal.getNumberOfPages();n++)this.pdf.setPage(n+1),this.pdf.internal.out(\"Q\");this.pdf.setPage(e),t&&0!==this.ctxStack.length&&(this.ctx=this.ctxStack.pop(),this.fillStyle=this.ctx.fillStyle,this.strokeStyle=this.ctx.strokeStyle,this.font=this.ctx.font,this.lineCap=this.ctx.lineCap,this.lineWidth=this.ctx.lineWidth,this.lineJoin=this.ctx.lineJoin)},d.prototype.toDataURL=function(){throw new Error(\"toDataUrl not implemented.\")};var p=function(t){var e,n,r,i;if(!0===t.isCanvasGradient&&(t=t.getColor()),!t)return{r:0,g:0,b:0,a:0,style:t};if(/transparent|rgba\\s*\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*0+\\s*\\)/.test(t))e=0,n=0,r=0,i=0;else{var a=/rgb\\s*\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)/.exec(t);if(null!==a)e=parseInt(a[1]),n=parseInt(a[2]),r=parseInt(a[3]),i=1;else if(null!==(a=/rgba\\s*\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*([\\d.]+)\\s*\\)/.exec(t)))e=parseInt(a[1]),n=parseInt(a[2]),r=parseInt(a[3]),i=parseFloat(a[4]);else{if(i=1,\"string\"==typeof t&&\"#\"!==t.charAt(0)){var o=new c(t);t=o.ok?o.toHex():\"#000000\"}4===t.length?(e=t.substring(1,2),e+=e,n=t.substring(2,3),n+=n,r=t.substring(3,4),r+=r):(e=t.substring(1,3),n=t.substring(3,5),r=t.substring(5,7)),e=parseInt(e,16),n=parseInt(n,16),r=parseInt(r,16)}}return{r:e,g:n,b:r,a:i,style:t}},g=function(){return this.ctx.isFillTransparent||0==this.globalAlpha},m=function(){return Boolean(this.ctx.isStrokeTransparent||0==this.globalAlpha)};d.prototype.fillText=function(t,e,r,i){if(isNaN(e)||isNaN(r)||\"string\"!=typeof t)throw n.error(\"jsPDF.context2d.fillText: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.fillText\");if(i=isNaN(i)?void 0:i,!g.call(this)){r=x.call(this,r);var a=O(this.ctx.transform.rotation),o=this.ctx.transform.scaleX;k.call(this,{text:t,x:e,y:r,scale:o,angle:a,align:this.textAlign,maxWidth:i})}},d.prototype.strokeText=function(t,e,r,i){if(isNaN(e)||isNaN(r)||\"string\"!=typeof t)throw n.error(\"jsPDF.context2d.strokeText: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.strokeText\");if(!m.call(this)){i=isNaN(i)?void 0:i,r=x.call(this,r);var a=O(this.ctx.transform.rotation),o=this.ctx.transform.scaleX;k.call(this,{text:t,x:e,y:r,scale:o,renderingMode:\"stroke\",angle:a,align:this.textAlign,maxWidth:i})}},d.prototype.measureText=function(t){if(\"string\"!=typeof t)throw n.error(\"jsPDF.context2d.measureText: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.measureText\");var e=this.pdf,r=this.pdf.internal.scaleFactor,i=e.internal.getFontSize(),a=e.getStringUnitWidth(t)*i/e.internal.scaleFactor,o=function(t){var e=(t=t||{}).width||0;return Object.defineProperty(this,\"width\",{get:function(){return e}}),this};return new o({width:a*=Math.round(96*r/72*1e4)/1e4})},d.prototype.scale=function(t,e){if(isNaN(t)||isNaN(e))throw n.error(\"jsPDF.context2d.scale: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.scale\");var r=new h(t,0,0,e,0,0);this.ctx.transform=this.ctx.transform.multiply(r)},d.prototype.rotate=function(t){if(isNaN(t))throw n.error(\"jsPDF.context2d.rotate: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.rotate\");var e=new h(Math.cos(t),Math.sin(t),-Math.sin(t),Math.cos(t),0,0);this.ctx.transform=this.ctx.transform.multiply(e)},d.prototype.translate=function(t,e){if(isNaN(t)||isNaN(e))throw n.error(\"jsPDF.context2d.translate: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.translate\");var r=new h(1,0,0,1,t,e);this.ctx.transform=this.ctx.transform.multiply(r)},d.prototype.transform=function(t,e,r,i,a,o){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i)||isNaN(a)||isNaN(o))throw n.error(\"jsPDF.context2d.transform: Invalid arguments\",arguments),new Error(\"Invalid arguments passed to jsPDF.context2d.transform\");var s=new h(t,e,r,i,a,o);this.ctx.transform=this.ctx.transform.multiply(s)},d.prototype.setTransform=function(t,e,n,r,i,a){t=isNaN(t)?1:t,e=isNaN(e)?0:e,n=isNaN(n)?0:n,r=isNaN(r)?1:r,i=isNaN(i)?0:i,a=isNaN(a)?0:a,this.ctx.transform=new h(t,e,n,r,i,a)},d.prototype.drawImage=function(t,e,n,r,i,a,o,s,c){var l=this.pdf.getImageProperties(t),f=1,d=1,p=1,g=1;void 0!==r&&void 0!==s&&(p=s/r,g=c/i,f=l.width/r*s/r,d=l.height/i*c/i),void 0===a&&(a=e,o=n,e=0,n=0),void 0!==r&&void 0===s&&(s=r,c=i),void 0===r&&void 0===s&&(s=l.width,c=l.height);for(var m,b=this.ctx.transform.decompose(),N=O(b.rotate.shx),x=new h,A=(x=(x=(x=x.multiply(b.translate)).multiply(b.skew)).multiply(b.scale)).applyToRectangle(new u(a-e*p,o-n*g,r*f,i*d)),_=v.call(this,A),S=[],P=0;P<_.length;P+=1)-1===S.indexOf(_[P])&&S.push(_[P]);if(w(S),this.autoPaging)for(var k=S[0],F=S[S.length-1],I=k;I<F+1;I++){if(this.pdf.setPage(I),0!==this.ctx.clip_path.length){var C=this.path;m=JSON.parse(JSON.stringify(this.ctx.clip_path)),this.path=y(m,this.posX,-1*this.pdf.internal.pageSize.height*(I-1)+this.posY),L.call(this,\"fill\",!0),this.path=C}var j=JSON.parse(JSON.stringify(A));j=y([j],this.posX,-1*this.pdf.internal.pageSize.height*(I-1)+this.posY)[0],this.pdf.addImage(t,\"JPEG\",j.x,j.y,j.w,j.h,null,null,N)}else this.pdf.addImage(t,\"JPEG\",A.x,A.y,A.w,A.h,null,null,N)};var v=function(t,e,n){var r=[];switch(e=e||this.pdf.internal.pageSize.width,n=n||this.pdf.internal.pageSize.height,t.type){default:case\"mt\":case\"lt\":r.push(Math.floor((t.y+this.posY)/n)+1);break;case\"arc\":r.push(Math.floor((t.y+this.posY-t.radius)/n)+1),r.push(Math.floor((t.y+this.posY+t.radius)/n)+1);break;case\"qct\":var i=M(this.ctx.lastPoint.x,this.ctx.lastPoint.y,t.x1,t.y1,t.x,t.y);r.push(Math.floor(i.y/n)+1),r.push(Math.floor((i.y+i.h)/n)+1);break;case\"bct\":var a=E(this.ctx.lastPoint.x,this.ctx.lastPoint.y,t.x1,t.y1,t.x2,t.y2,t.x,t.y);r.push(Math.floor(a.y/n)+1),r.push(Math.floor((a.y+a.h)/n)+1);break;case\"rect\":r.push(Math.floor((t.y+this.posY)/n)+1),r.push(Math.floor((t.y+t.h+this.posY)/n)+1)}for(var o=0;o<r.length;o+=1)for(;this.pdf.internal.getNumberOfPages()<r[o];)b.call(this);return r},b=function(){var t=this.fillStyle,e=this.strokeStyle,n=this.font,r=this.lineCap,i=this.lineWidth,a=this.lineJoin;this.pdf.addPage(),this.fillStyle=t,this.strokeStyle=e,this.font=n,this.lineCap=r,this.lineWidth=i,this.lineJoin=a},y=function(t,e,n){for(var r=0;r<t.length;r++)switch(t[r].type){case\"bct\":t[r].x2+=e,t[r].y2+=n;case\"qct\":t[r].x1+=e,t[r].y1+=n;case\"mt\":case\"lt\":case\"arc\":default:t[r].x+=e,t[r].y+=n}return t},w=function(t){return t.sort((function(t,e){return t-e}))},N=function(t,e){for(var n,r,i=this.fillStyle,a=this.strokeStyle,o=this.lineCap,s=this.lineWidth,u=s*this.ctx.transform.scaleX,c=this.lineJoin,h=JSON.parse(JSON.stringify(this.path)),l=JSON.parse(JSON.stringify(this.path)),f=[],d=0;d<l.length;d++)if(void 0!==l[d].x)for(var p=v.call(this,l[d]),g=0;g<p.length;g+=1)-1===f.indexOf(p[g])&&f.push(p[g]);for(var m=0;m<f.length;m++)for(;this.pdf.internal.getNumberOfPages()<f[m];)b.call(this);if(w(f),this.autoPaging)for(var N=f[0],x=f[f.length-1],A=N;A<x+1;A++){if(this.pdf.setPage(A),this.fillStyle=i,this.strokeStyle=a,this.lineCap=o,this.lineWidth=u,this.lineJoin=c,0!==this.ctx.clip_path.length){var _=this.path;n=JSON.parse(JSON.stringify(this.ctx.clip_path)),this.path=y(n,this.posX,-1*this.pdf.internal.pageSize.height*(A-1)+this.posY),L.call(this,t,!0),this.path=_}r=JSON.parse(JSON.stringify(h)),this.path=y(r,this.posX,-1*this.pdf.internal.pageSize.height*(A-1)+this.posY),!1!==e&&0!==A||L.call(this,t,e),this.lineWidth=s}else this.lineWidth=u,L.call(this,t,e),this.lineWidth=s;this.path=h},L=function(t,e){if((\"stroke\"!==t||e||!m.call(this))&&(\"stroke\"===t||e||!g.call(this))){for(var n,r,i=[],a=this.path,o=0;o<a.length;o++){var s=a[o];switch(s.type){case\"begin\":i.push({begin:!0});break;case\"close\":i.push({close:!0});break;case\"mt\":i.push({start:s,deltas:[],abs:[]});break;case\"lt\":var u=i.length;if(!isNaN(a[o-1].x)&&(n=[s.x-a[o-1].x,s.y-a[o-1].y],u>0))for(;u>=0;u--)if(!0!==i[u-1].close&&!0!==i[u-1].begin){i[u-1].deltas.push(n),i[u-1].abs.push(s);break}break;case\"bct\":n=[s.x1-a[o-1].x,s.y1-a[o-1].y,s.x2-a[o-1].x,s.y2-a[o-1].y,s.x-a[o-1].x,s.y-a[o-1].y],i[i.length-1].deltas.push(n);break;case\"qct\":var c=a[o-1].x+2/3*(s.x1-a[o-1].x),h=a[o-1].y+2/3*(s.y1-a[o-1].y),l=s.x+2/3*(s.x1-s.x),f=s.y+2/3*(s.y1-s.y),d=s.x,p=s.y;n=[c-a[o-1].x,h-a[o-1].y,l-a[o-1].x,f-a[o-1].y,d-a[o-1].x,p-a[o-1].y],i[i.length-1].deltas.push(n);break;case\"arc\":i.push({deltas:[],abs:[],arc:!0}),Array.isArray(i[i.length-1].abs)&&i[i.length-1].abs.push(s)}}r=e?null:\"stroke\"===t?\"stroke\":\"fill\";for(var v=0;v<i.length;v++){if(i[v].arc){for(var b=i[v].abs,y=0;y<b.length;y++){var w=b[y];\"arc\"===w.type?A.call(this,w.x,w.y,w.radius,w.startAngle,w.endAngle,w.counterclockwise,void 0,e):F.call(this,w.x,w.y)}_.call(this,r),this.pdf.internal.out(\"h\")}if(!i[v].arc&&!0!==i[v].close&&!0!==i[v].begin){var N=i[v].start.x,L=i[v].start.y;I.call(this,i[v].deltas,N,L)}}r&&_.call(this,r),e&&S.call(this)}},x=function(t){var e=this.pdf.internal.getFontSize()/this.pdf.internal.scaleFactor,n=e*(this.pdf.internal.getLineHeightFactor()-1);switch(this.ctx.textBaseline){case\"bottom\":return t-n;case\"top\":return t+e-n;case\"hanging\":return t+e-2*n;case\"middle\":return t+e/2-n;case\"ideographic\":return t;case\"alphabetic\":default:return t}};d.prototype.createLinearGradient=function(){var t=function(){};return t.colorStops=[],t.addColorStop=function(t,e){this.colorStops.push([t,e])},t.getColor=function(){return 0===this.colorStops.length?\"#000000\":this.colorStops[0][1]},t.isCanvasGradient=!0,t},d.prototype.createPattern=function(){return this.createLinearGradient()},d.prototype.createRadialGradient=function(){return this.createLinearGradient()};var A=function(t,e,n,r,i,a,o,s){for(var u=j.call(this,n,r,i,a),c=0;c<u.length;c++){var h=u[c];0===c&&P.call(this,h.x1+t,h.y1+e),C.call(this,t,e,h.x2,h.y2,h.x3,h.y3,h.x4,h.y4)}s?S.call(this):_.call(this,o)},_=function(t){switch(t){case\"stroke\":this.pdf.internal.out(\"S\");break;case\"fill\":this.pdf.internal.out(\"f\")}},S=function(){this.pdf.clip(),this.pdf.discardPath()},P=function(t,e){this.pdf.internal.out(r(t)+\" \"+i(e)+\" m\")},k=function(t){var e;switch(t.align){case\"right\":case\"end\":e=\"right\";break;case\"center\":e=\"center\";break;case\"left\":case\"start\":default:e=\"left\"}var n=this.ctx.transform.applyToPoint(new s(t.x,t.y)),r=this.ctx.transform.decompose(),i=new h;i=(i=(i=i.multiply(r.translate)).multiply(r.skew)).multiply(r.scale);for(var a,o,c,l=this.pdf.getTextDimensions(t.text),f=this.ctx.transform.applyToRectangle(new u(t.x,t.y,l.w,l.h)),d=i.applyToRectangle(new u(t.x,t.y-l.h,l.w,l.h)),p=v.call(this,d),g=[],m=0;m<p.length;m+=1)-1===g.indexOf(p[m])&&g.push(p[m]);if(w(g),!0===this.autoPaging)for(var b=g[0],N=g[g.length-1],x=b;x<N+1;x++){if(this.pdf.setPage(x),0!==this.ctx.clip_path.length){var A=this.path;a=JSON.parse(JSON.stringify(this.ctx.clip_path)),this.path=y(a,this.posX,-1*this.pdf.internal.pageSize.height*(x-1)+this.posY),L.call(this,\"fill\",!0),this.path=A}var _=JSON.parse(JSON.stringify(f));_=y([_],this.posX,-1*this.pdf.internal.pageSize.height*(x-1)+this.posY)[0],t.scale>=.01&&(o=this.pdf.internal.getFontSize(),this.pdf.setFontSize(o*t.scale),c=this.lineWidth,this.lineWidth=c*t.scale),this.pdf.text(t.text,_.x,_.y,{angle:t.angle,align:e,renderingMode:t.renderingMode,maxWidth:t.maxWidth}),t.scale>=.01&&(this.pdf.setFontSize(o),this.lineWidth=c)}else t.scale>=.01&&(o=this.pdf.internal.getFontSize(),this.pdf.setFontSize(o*t.scale),c=this.lineWidth,this.lineWidth=c*t.scale),this.pdf.text(t.text,n.x+this.posX,n.y+this.posY,{angle:t.angle,align:e,renderingMode:t.renderingMode,maxWidth:t.maxWidth}),t.scale>=.01&&(this.pdf.setFontSize(o),this.lineWidth=c)},F=function(t,e,n,a){n=n||0,a=a||0,this.pdf.internal.out(r(t+n)+\" \"+i(e+a)+\" l\")},I=function(t,e,n){return this.pdf.lines(t,e,n,null,null)},C=function(t,n,r,i,s,u,c,h){this.pdf.internal.out([e(a(r+t)),e(o(i+n)),e(a(s+t)),e(o(u+n)),e(a(c+t)),e(o(h+n)),\"c\"].join(\" \"))},j=function(t,e,n,r){for(var i=2*Math.PI,a=Math.PI/2;e>n;)e-=i;var o=Math.abs(n-e);o<i&&r&&(o=i-o);for(var s=[],u=r?-1:1,c=e;o>1e-5;){var h=c+u*Math.min(o,a);s.push(B.call(this,t,c,h)),o-=Math.abs(h-c),c=h}return s},B=function(t,e,n){var r=(n-e)/2,i=t*Math.cos(r),a=t*Math.sin(r),o=i,s=-a,u=o*o+s*s,c=u+o*i+s*a,h=4/3*(Math.sqrt(2*u*c)-c)/(o*a-s*i),l=o-h*s,f=s+h*o,d=l,p=-f,g=r+e,m=Math.cos(g),v=Math.sin(g);return{x1:t*Math.cos(e),y1:t*Math.sin(e),x2:l*m-f*v,y2:l*v+f*m,x3:d*m-p*v,y3:d*v+p*m,x4:t*Math.cos(n),y4:t*Math.sin(n)}},O=function(t){return 180*t/Math.PI},M=function(t,e,n,r,i,a){var o=t+.5*(n-t),s=e+.5*(r-e),c=i+.5*(n-i),h=a+.5*(r-a),l=Math.min(t,i,o,c),f=Math.max(t,i,o,c),d=Math.min(e,a,s,h),p=Math.max(e,a,s,h);return new u(l,d,f-l,p-d)},E=function(t,e,n,r,i,a,o,s){var c,h,l,f,d,p,g,m,v,b,y,w,N,L,x=n-t,A=r-e,_=i-n,S=a-r,P=o-i,k=s-a;for(h=0;h<41;h++)v=(g=(l=t+(c=h/40)*x)+c*((d=n+c*_)-l))+c*(d+c*(i+c*P-d)-g),b=(m=(f=e+c*A)+c*((p=r+c*S)-f))+c*(p+c*(a+c*k-p)-m),0==h?(y=v,w=b,N=v,L=b):(y=Math.min(y,v),w=Math.min(w,b),N=Math.max(N,v),L=Math.max(L,b));return new u(Math.round(y),Math.round(w),Math.round(N-y),Math.round(L-w))}}(g.API);\n/**\n * @license\n Copyright (c) 2013 Gildas Lormeau. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice,\n this list of conditions and the following disclaimer.\n\n 2. Redistributions in binary form must reproduce the above copyright \n notice, this list of conditions and the following disclaimer in \n the documentation and/or other materials provided with the distribution.\n\n 3. The names of the authors may not be used to endorse or promote products\n derived from this software without specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,\n INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,\n INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,\n INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\n OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\nvar lt=[0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0,0,16,17,18,18,19,19,20,20,20,20,21,21,21,21,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29];function ft(){var t=this;function e(t,e){var n=0;do{n|=1&t,t>>>=1,n<<=1}while(--e>0);return n>>>1}t.build_tree=function(n){var r,i,a,o=t.dyn_tree,s=t.stat_desc.static_tree,u=t.stat_desc.elems,c=-1;for(n.heap_len=0,n.heap_max=573,r=0;r<u;r++)0!==o[2*r]?(n.heap[++n.heap_len]=c=r,n.depth[r]=0):o[2*r+1]=0;for(;n.heap_len<2;)o[2*(a=n.heap[++n.heap_len]=c<2?++c:0)]=1,n.depth[a]=0,n.opt_len--,s&&(n.static_len-=s[2*a+1]);for(t.max_code=c,r=Math.floor(n.heap_len/2);r>=1;r--)n.pqdownheap(o,r);a=u;do{r=n.heap[1],n.heap[1]=n.heap[n.heap_len--],n.pqdownheap(o,1),i=n.heap[1],n.heap[--n.heap_max]=r,n.heap[--n.heap_max]=i,o[2*a]=o[2*r]+o[2*i],n.depth[a]=Math.max(n.depth[r],n.depth[i])+1,o[2*r+1]=o[2*i+1]=a,n.heap[1]=a++,n.pqdownheap(o,1)}while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],function(e){var n,r,i,a,o,s,u=t.dyn_tree,c=t.stat_desc.static_tree,h=t.stat_desc.extra_bits,l=t.stat_desc.extra_base,f=t.stat_desc.max_length,d=0;for(a=0;a<=15;a++)e.bl_count[a]=0;for(u[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)(a=u[2*u[2*(r=e.heap[n])+1]+1]+1)>f&&(a=f,d++),u[2*r+1]=a,r>t.max_code||(e.bl_count[a]++,o=0,r>=l&&(o=h[r-l]),s=u[2*r],e.opt_len+=s*(a+o),c&&(e.static_len+=s*(c[2*r+1]+o)));if(0!==d){do{for(a=f-1;0===e.bl_count[a];)a--;e.bl_count[a]--,e.bl_count[a+1]+=2,e.bl_count[f]--,d-=2}while(d>0);for(a=f;0!==a;a--)for(r=e.bl_count[a];0!==r;)(i=e.heap[--n])>t.max_code||(u[2*i+1]!==a&&(e.opt_len+=(a-u[2*i+1])*u[2*i],u[2*i+1]=a),r--)}}(n),function(t,n,r){var i,a,o,s=[],u=0;for(i=1;i<=15;i++)s[i]=u=u+r[i-1]<<1;for(a=0;a<=n;a++)0!==(o=t[2*a+1])&&(t[2*a]=e(s[o]++,o))}(o,t.max_code,n.bl_count)}}function dt(t,e,n,r,i){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=r,this.max_length=i}ft._length_code=[0,1,2,3,4,5,6,7,8,8,9,9,10,10,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28],ft.base_length=[0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,0],ft.base_dist=[0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096,6144,8192,12288,16384,24576],ft.d_code=function(t){return t<256?lt[t]:lt[256+(t>>>7)]},ft.extra_lbits=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ft.extra_dbits=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],ft.extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],ft.bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],dt.static_ltree=[12,8,140,8,76,8,204,8,44,8,172,8,108,8,236,8,28,8,156,8,92,8,220,8,60,8,188,8,124,8,252,8,2,8,130,8,66,8,194,8,34,8,162,8,98,8,226,8,18,8,146,8,82,8,210,8,50,8,178,8,114,8,242,8,10,8,138,8,74,8,202,8,42,8,170,8,106,8,234,8,26,8,154,8,90,8,218,8,58,8,186,8,122,8,250,8,6,8,134,8,70,8,198,8,38,8,166,8,102,8,230,8,22,8,150,8,86,8,214,8,54,8,182,8,118,8,246,8,14,8,142,8,78,8,206,8,46,8,174,8,110,8,238,8,30,8,158,8,94,8,222,8,62,8,190,8,126,8,254,8,1,8,129,8,65,8,193,8,33,8,161,8,97,8,225,8,17,8,145,8,81,8,209,8,49,8,177,8,113,8,241,8,9,8,137,8,73,8,201,8,41,8,169,8,105,8,233,8,25,8,153,8,89,8,217,8,57,8,185,8,121,8,249,8,5,8,133,8,69,8,197,8,37,8,165,8,101,8,229,8,21,8,149,8,85,8,213,8,53,8,181,8,117,8,245,8,13,8,141,8,77,8,205,8,45,8,173,8,109,8,237,8,29,8,157,8,93,8,221,8,61,8,189,8,125,8,253,8,19,9,275,9,147,9,403,9,83,9,339,9,211,9,467,9,51,9,307,9,179,9,435,9,115,9,371,9,243,9,499,9,11,9,267,9,139,9,395,9,75,9,331,9,203,9,459,9,43,9,299,9,171,9,427,9,107,9,363,9,235,9,491,9,27,9,283,9,155,9,411,9,91,9,347,9,219,9,475,9,59,9,315,9,187,9,443,9,123,9,379,9,251,9,507,9,7,9,263,9,135,9,391,9,71,9,327,9,199,9,455,9,39,9,295,9,167,9,423,9,103,9,359,9,231,9,487,9,23,9,279,9,151,9,407,9,87,9,343,9,215,9,471,9,55,9,311,9,183,9,439,9,119,9,375,9,247,9,503,9,15,9,271,9,143,9,399,9,79,9,335,9,207,9,463,9,47,9,303,9,175,9,431,9,111,9,367,9,239,9,495,9,31,9,287,9,159,9,415,9,95,9,351,9,223,9,479,9,63,9,319,9,191,9,447,9,127,9,383,9,255,9,511,9,0,7,64,7,32,7,96,7,16,7,80,7,48,7,112,7,8,7,72,7,40,7,104,7,24,7,88,7,56,7,120,7,4,7,68,7,36,7,100,7,20,7,84,7,52,7,116,7,3,8,131,8,67,8,195,8,35,8,163,8,99,8,227,8],dt.static_dtree=[0,5,16,5,8,5,24,5,4,5,20,5,12,5,28,5,2,5,18,5,10,5,26,5,6,5,22,5,14,5,30,5,1,5,17,5,9,5,25,5,5,5,21,5,13,5,29,5,3,5,19,5,11,5,27,5,7,5,23,5],dt.static_l_desc=new dt(dt.static_ltree,ft.extra_lbits,257,286,15),dt.static_d_desc=new dt(dt.static_dtree,ft.extra_dbits,0,30,15),dt.static_bl_desc=new dt(null,ft.extra_blbits,0,19,7);function pt(t,e,n,r,i){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=r,this.func=i}var gt,mt,vt,bt=[new pt(0,0,0,0,0),new pt(4,4,8,4,1),new pt(4,5,16,8,1),new pt(4,6,32,32,1),new pt(4,4,16,16,2),new pt(8,16,32,32,2),new pt(8,16,128,128,2),new pt(8,32,128,256,2),new pt(32,128,258,1024,2),new pt(32,258,258,4096,2)],yt=[\"need dictionary\",\"stream end\",\"\",\"\",\"stream error\",\"data error\",\"\",\"buffer error\",\"\",\"\"];function wt(t,e,n,r){var i=t[2*e],a=t[2*n];return i<a||i===a&&r[e]<=r[n]}function Nt(){var t,e,n,r,i,a,o,s,u,c,h,l,f,d,p,g,m,v,b,y,w,N,L,x,A,_,S,P,k,F,I,C,j,B,O,M,E,q,R,T,D,U=this,z=new ft,H=new ft,W=new ft;function V(){var t;for(t=0;t<286;t++)I[2*t]=0;for(t=0;t<30;t++)C[2*t]=0;for(t=0;t<19;t++)j[2*t]=0;I[512]=1,U.opt_len=U.static_len=0,M=q=0}function G(t,e){var n,r,i=-1,a=t[1],o=0,s=7,u=4;for(0===a&&(s=138,u=3),t[2*(e+1)+1]=65535,n=0;n<=e;n++)r=a,a=t[2*(n+1)+1],++o<s&&r===a||(o<u?j[2*r]+=o:0!==r?(r!==i&&j[2*r]++,j[32]++):o<=10?j[34]++:j[36]++,o=0,i=r,0===a?(s=138,u=3):r===a?(s=6,u=3):(s=7,u=4))}function Y(t){U.pending_buf[U.pending++]=t}function J(t){Y(255&t),Y(t>>>8&255)}function X(t,e){var n,r=e;D>16-r?(J(T|=(n=t)<<D&65535),T=n>>>16-D,D+=r-16):(T|=t<<D&65535,D+=r)}function K(t,e){var n=2*t;X(65535&e[n],65535&e[n+1])}function Z(t,e){var n,r,i=-1,a=t[1],o=0,s=7,u=4;for(0===a&&(s=138,u=3),n=0;n<=e;n++)if(r=a,a=t[2*(n+1)+1],!(++o<s&&r===a)){if(o<u)do{K(r,j)}while(0!=--o);else 0!==r?(r!==i&&(K(r,j),o--),K(16,j),X(o-3,2)):o<=10?(K(17,j),X(o-3,3)):(K(18,j),X(o-11,7));o=0,i=r,0===a?(s=138,u=3):r===a?(s=6,u=3):(s=7,u=4)}}function $(){16===D?(J(T),T=0,D=0):D>=8&&(Y(255&T),T>>>=8,D-=8)}function Q(t,e){var n,r,i;if(U.pending_buf[E+2*M]=t>>>8&255,U.pending_buf[E+2*M+1]=255&t,U.pending_buf[B+M]=255&e,M++,0===t?I[2*e]++:(q++,t--,I[2*(ft._length_code[e]+256+1)]++,C[2*ft.d_code(t)]++),0==(8191&M)&&S>2){for(n=8*M,r=w-m,i=0;i<30;i++)n+=C[2*i]*(5+ft.extra_dbits[i]);if(n>>>=3,q<Math.floor(M/2)&&n<Math.floor(r/2))return!0}return M===O-1}function tt(t,e){var n,r,i,a,o=0;if(0!==M)do{n=U.pending_buf[E+2*o]<<8&65280|255&U.pending_buf[E+2*o+1],r=255&U.pending_buf[B+o],o++,0===n?K(r,t):(K((i=ft._length_code[r])+256+1,t),0!==(a=ft.extra_lbits[i])&&X(r-=ft.base_length[i],a),n--,K(i=ft.d_code(n),e),0!==(a=ft.extra_dbits[i])&&X(n-=ft.base_dist[i],a))}while(o<M);K(256,t),R=t[513]}function et(){D>8?J(T):D>0&&Y(255&T),T=0,D=0}function nt(t,e,n){X(0+(n?1:0),3),function(t,e,n){et(),R=8,n&&(J(e),J(~e)),U.pending_buf.set(s.subarray(t,t+e),U.pending),U.pending+=e}(t,e,!0)}function rt(t,e,n){var r,i,a=0;S>0?(z.build_tree(U),H.build_tree(U),a=function(){var t;for(G(I,z.max_code),G(C,H.max_code),W.build_tree(U),t=18;t>=3&&0===j[2*ft.bl_order[t]+1];t--);return U.opt_len+=3*(t+1)+5+5+4,t}(),r=U.opt_len+3+7>>>3,(i=U.static_len+3+7>>>3)<=r&&(r=i)):r=i=e+5,e+4<=r&&-1!==t?nt(t,e,n):i===r?(X(2+(n?1:0),3),tt(dt.static_ltree,dt.static_dtree)):(X(4+(n?1:0),3),function(t,e,n){var r;for(X(t-257,5),X(e-1,5),X(n-4,4),r=0;r<n;r++)X(j[2*ft.bl_order[r]+1],3);Z(I,t-1),Z(C,e-1)}(z.max_code+1,H.max_code+1,a+1),tt(I,C)),V(),n&&et()}function it(e){rt(m>=0?m:-1,w-m,e),m=w,t.flush_pending()}function at(){var e,n,r,a;do{if(0===(a=u-L-w)&&0===w&&0===L)a=i;else if(-1===a)a--;else if(w>=i+i-262){s.set(s.subarray(i,i+i),0),N-=i,w-=i,m-=i,r=e=f;do{n=65535&h[--r],h[r]=n>=i?n-i:0}while(0!=--e);r=e=i;do{n=65535&c[--r],c[r]=n>=i?n-i:0}while(0!=--e);a+=i}if(0===t.avail_in)return;e=t.read_buf(s,w+L,a),(L+=e)>=3&&(l=((l=255&s[w])<<g^255&s[w+1])&p)}while(L<262&&0!==t.avail_in)}function ot(t){var e,n,r=A,a=w,u=x,h=w>i-262?w-(i-262):0,l=F,f=o,d=w+258,p=s[a+u-1],g=s[a+u];x>=k&&(r>>=2),l>L&&(l=L);do{if(s[(e=t)+u]===g&&s[e+u-1]===p&&s[e]===s[a]&&s[++e]===s[a+1]){a+=2,e++;do{}while(s[++a]===s[++e]&&s[++a]===s[++e]&&s[++a]===s[++e]&&s[++a]===s[++e]&&s[++a]===s[++e]&&s[++a]===s[++e]&&s[++a]===s[++e]&&s[++a]===s[++e]&&a<d);if(n=258-(d-a),a=d-258,n>u){if(N=t,u=n,n>=l)break;p=s[a+u-1],g=s[a+u]}}}while((t=65535&c[t&f])>h&&0!=--r);return u<=L?u:L}function st(t){return t.total_in=t.total_out=0,t.msg=null,U.pending=0,U.pending_out=0,e=113,r=0,z.dyn_tree=I,z.stat_desc=dt.static_l_desc,H.dyn_tree=C,H.stat_desc=dt.static_d_desc,W.dyn_tree=j,W.stat_desc=dt.static_bl_desc,T=0,D=0,R=8,V(),function(){var t;for(u=2*i,h[f-1]=0,t=0;t<f-1;t++)h[t]=0;_=bt[S].max_lazy,k=bt[S].good_length,F=bt[S].nice_length,A=bt[S].max_chain,w=0,m=0,L=0,v=x=2,y=0,l=0}(),0}U.depth=[],U.bl_count=[],U.heap=[],I=[],C=[],j=[],U.pqdownheap=function(t,e){for(var n=U.heap,r=n[e],i=e<<1;i<=U.heap_len&&(i<U.heap_len&&wt(t,n[i+1],n[i],U.depth)&&i++,!wt(t,r,n[i],U.depth));)n[e]=n[i],e=i,i<<=1;n[e]=r},U.deflateInit=function(t,e,r,u,l,m){return u||(u=8),l||(l=8),m||(m=0),t.msg=null,-1===e&&(e=6),l<1||l>9||8!==u||r<9||r>15||e<0||e>9||m<0||m>2?-2:(t.dstate=U,o=(i=1<<(a=r))-1,p=(f=1<<(d=l+7))-1,g=Math.floor((d+3-1)/3),s=new Uint8Array(2*i),c=[],h=[],O=1<<l+6,U.pending_buf=new Uint8Array(4*O),n=4*O,E=Math.floor(O/2),B=3*O,S=e,P=m,st(t))},U.deflateEnd=function(){return 42!==e&&113!==e&&666!==e?-2:(U.pending_buf=null,h=null,c=null,s=null,U.dstate=null,113===e?-3:0)},U.deflateParams=function(t,e,n){var r=0;return-1===e&&(e=6),e<0||e>9||n<0||n>2?-2:(bt[S].func!==bt[e].func&&0!==t.total_in&&(r=t.deflate(1)),S!==e&&(_=bt[S=e].max_lazy,k=bt[S].good_length,F=bt[S].nice_length,A=bt[S].max_chain),P=n,r)},U.deflateSetDictionary=function(t,n,r){var a,u=r,f=0;if(!n||42!==e)return-2;if(u<3)return 0;for(u>i-262&&(f=r-(u=i-262)),s.set(n.subarray(f,f+u),0),w=u,m=u,l=((l=255&s[0])<<g^255&s[1])&p,a=0;a<=u-3;a++)l=(l<<g^255&s[a+2])&p,c[a&o]=h[l],h[l]=a;return 0},U.deflate=function(u,d){var A,k,F,I,C,j;if(d>4||d<0)return-2;if(!u.next_out||!u.next_in&&0!==u.avail_in||666===e&&4!==d)return u.msg=yt[4],-2;if(0===u.avail_out)return u.msg=yt[7],-5;if(t=u,I=r,r=d,42===e&&(k=8+(a-8<<4)<<8,(F=(S-1&255)>>1)>3&&(F=3),k|=F<<6,0!==w&&(k|=32),e=113,Y((j=k+=31-k%31)>>8&255),Y(255&j)),0!==U.pending){if(t.flush_pending(),0===t.avail_out)return r=-1,0}else if(0===t.avail_in&&d<=I&&4!==d)return t.msg=yt[7],-5;if(666===e&&0!==t.avail_in)return u.msg=yt[7],-5;if(0!==t.avail_in||0!==L||0!==d&&666!==e){switch(C=-1,bt[S].func){case 0:C=function(e){var r,a=65535;for(a>n-5&&(a=n-5);;){if(L<=1){if(at(),0===L&&0===e)return 0;if(0===L)break}if(w+=L,L=0,r=m+a,(0===w||w>=r)&&(L=w-r,w=r,it(!1),0===t.avail_out))return 0;if(w-m>=i-262&&(it(!1),0===t.avail_out))return 0}return it(4===e),0===t.avail_out?4===e?2:0:4===e?3:1}(d);break;case 1:C=function(e){for(var n,r=0;;){if(L<262){if(at(),L<262&&0===e)return 0;if(0===L)break}if(L>=3&&(l=(l<<g^255&s[w+2])&p,r=65535&h[l],c[w&o]=h[l],h[l]=w),0!==r&&(w-r&65535)<=i-262&&2!==P&&(v=ot(r)),v>=3)if(n=Q(w-N,v-3),L-=v,v<=_&&L>=3){v--;do{w++,l=(l<<g^255&s[w+2])&p,r=65535&h[l],c[w&o]=h[l],h[l]=w}while(0!=--v);w++}else w+=v,v=0,l=((l=255&s[w])<<g^255&s[w+1])&p;else n=Q(0,255&s[w]),L--,w++;if(n&&(it(!1),0===t.avail_out))return 0}return it(4===e),0===t.avail_out?4===e?2:0:4===e?3:1}(d);break;case 2:C=function(e){for(var n,r,a=0;;){if(L<262){if(at(),L<262&&0===e)return 0;if(0===L)break}if(L>=3&&(l=(l<<g^255&s[w+2])&p,a=65535&h[l],c[w&o]=h[l],h[l]=w),x=v,b=N,v=2,0!==a&&x<_&&(w-a&65535)<=i-262&&(2!==P&&(v=ot(a)),v<=5&&(1===P||3===v&&w-N>4096)&&(v=2)),x>=3&&v<=x){r=w+L-3,n=Q(w-1-b,x-3),L-=x-1,x-=2;do{++w<=r&&(l=(l<<g^255&s[w+2])&p,a=65535&h[l],c[w&o]=h[l],h[l]=w)}while(0!=--x);if(y=0,v=2,w++,n&&(it(!1),0===t.avail_out))return 0}else if(0!==y){if((n=Q(0,255&s[w-1]))&&it(!1),w++,L--,0===t.avail_out)return 0}else y=1,w++,L--}return 0!==y&&(n=Q(0,255&s[w-1]),y=0),it(4===e),0===t.avail_out?4===e?2:0:4===e?3:1}(d)}if(2!==C&&3!==C||(e=666),0===C||2===C)return 0===t.avail_out&&(r=-1),0;if(1===C){if(1===d)X(2,3),K(256,dt.static_ltree),$(),1+R+10-D<9&&(X(2,3),K(256,dt.static_ltree),$()),R=7;else if(nt(0,0,!1),3===d)for(A=0;A<f;A++)h[A]=0;if(t.flush_pending(),0===t.avail_out)return r=-1,0}}return 4!==d?0:1}}function Lt(){this.next_in_index=0,this.next_out_index=0,this.avail_in=0,this.total_in=0,this.avail_out=0,this.total_out=0}function xt(t){var e=new Lt,n=new Uint8Array(512),r=t?t.level:-1;void 0===r&&(r=-1),e.deflateInit(r),e.next_out=n,this.append=function(t,r){var i,a=[],o=0,s=0,u=0;if(t.length){e.next_in_index=0,e.next_in=t,e.avail_in=t.length;do{if(e.next_out_index=0,e.avail_out=512,0!==e.deflate(0))throw new Error(\"deflating: \"+e.msg);e.next_out_index&&(512===e.next_out_index?a.push(new Uint8Array(n)):a.push(new Uint8Array(n.subarray(0,e.next_out_index)))),u+=e.next_out_index,r&&e.next_in_index>0&&e.next_in_index!==o&&(r(e.next_in_index),o=e.next_in_index)}while(e.avail_in>0||0===e.avail_out);return i=new Uint8Array(u),a.forEach((function(t){i.set(t,s),s+=t.length})),i}},this.flush=function(){var t,r,i=[],a=0,o=0;do{if(e.next_out_index=0,e.avail_out=512,1!==(t=e.deflate(4))&&0!==t)throw new Error(\"deflating: \"+e.msg);512-e.avail_out>0&&i.push(new Uint8Array(n.subarray(0,e.next_out_index))),o+=e.next_out_index}while(e.avail_in>0||0===e.avail_out);return e.deflateEnd(),r=new Uint8Array(o),i.forEach((function(t){r.set(t,a),a+=t.length})),r}}\n/**\n * @license\n * jsPDF filters PlugIn\n * Copyright (c) 2014 Aras Abbasi\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */Lt.prototype={deflateInit:function(t,e){return this.dstate=new Nt,e||(e=15),this.dstate.deflateInit(this,t,e)},deflate:function(t){return this.dstate?this.dstate.deflate(this,t):-2},deflateEnd:function(){if(!this.dstate)return-2;var t=this.dstate.deflateEnd();return this.dstate=null,t},deflateParams:function(t,e){return this.dstate?this.dstate.deflateParams(this,t,e):-2},deflateSetDictionary:function(t,e){return this.dstate?this.dstate.deflateSetDictionary(this,t,e):-2},read_buf:function(t,e,n){var r=this.avail_in;return r>n&&(r=n),0===r?0:(this.avail_in-=r,t.set(this.next_in.subarray(this.next_in_index,this.next_in_index+r),e),this.next_in_index+=r,this.total_in+=r,r)},flush_pending:function(){var t=this.dstate.pending;t>this.avail_out&&(t=this.avail_out),0!==t&&(this.next_out.set(this.dstate.pending_buf.subarray(this.dstate.pending_out,this.dstate.pending_out+t),this.next_out_index),this.next_out_index+=t,this.dstate.pending_out+=t,this.total_out+=t,this.avail_out-=t,this.dstate.pending-=t,0===this.dstate.pending&&(this.dstate.pending_out=0))}},function(t){var e=function(t){var e,n,r,i,a,o,s,u,c,h;for(/[^\\x00-\\xFF]/.test(t),n=[],r=0,i=(t+=e=\"\\0\\0\\0\\0\".slice(t.length%4||4)).length;i>r;r+=4)0!==(a=(t.charCodeAt(r)<<24)+(t.charCodeAt(r+1)<<16)+(t.charCodeAt(r+2)<<8)+t.charCodeAt(r+3))?(o=(a=((a=((a=((a=(a-(h=a%85))/85)-(c=a%85))/85)-(u=a%85))/85)-(s=a%85))/85)%85,n.push(o+33,s+33,u+33,c+33,h+33)):n.push(122);return function(t,e){for(var n=e;n>0;n--)t.pop()}(n,e.length),String.fromCharCode.apply(String,n)+\"~>\"},n=function(t){var e,n,r,i,a,o=String,s=\"length\",u=255,c=\"charCodeAt\",h=\"slice\",l=\"replace\";for(t[h](-2),t=t[h](0,-2)[l](/\\s/g,\"\")[l](\"z\",\"!!!!!\"),r=[],i=0,a=(t+=e=\"uuuuu\"[h](t[s]%5||5))[s];a>i;i+=5)n=52200625*(t[c](i)-33)+614125*(t[c](i+1)-33)+7225*(t[c](i+2)-33)+85*(t[c](i+3)-33)+(t[c](i+4)-33),r.push(u&n>>24,u&n>>16,u&n>>8,u&n);return function(t,e){for(var n=e;n>0;n--)t.pop()}(r,e[s]),o.fromCharCode.apply(o,r)},r=function(t){var e=new RegExp(/^([0-9A-Fa-f]{2})+$/);if(-1!==(t=t.replace(/\\s/g,\"\")).indexOf(\">\")&&(t=t.substr(0,t.indexOf(\">\"))),t.length%2&&(t+=\"0\"),!1===e.test(t))return\"\";for(var n=\"\",r=0;r<t.length;r+=2)n+=String.fromCharCode(\"0x\"+(t[r]+t[r+1]));return n},i=function(e){for(var n,r,i,a,o,s=[],u=e.length;u--;)s[u]=e.charCodeAt(u);return n=t.adler32cs.from(e),e=(r=new xt(6)).append(new Uint8Array(s)),i=e,a=r.flush(),(o=new Uint8Array(i.byteLength+a.byteLength)).set(new Uint8Array(i),0),o.set(new Uint8Array(a),i.byteLength),e=o,(s=new Uint8Array(e.byteLength+6)).set(new Uint8Array([120,156])),s.set(e,2),s.set(new Uint8Array([255&n,n>>8&255,n>>16&255,n>>24&255]),e.byteLength+2),e=s.reduce((function(t,e){return t+String.fromCharCode(e)}),\"\")};t.processDataByFilters=function(t,a){var o=0,s=t||\"\",u=[];for(\"string\"==typeof(a=a||[])&&(a=[a]),o=0;o<a.length;o+=1)switch(a[o]){case\"ASCII85Decode\":case\"/ASCII85Decode\":s=n(s),u.push(\"/ASCII85Encode\");break;case\"ASCII85Encode\":case\"/ASCII85Encode\":s=e(s),u.push(\"/ASCII85Decode\");break;case\"ASCIIHexDecode\":case\"/ASCIIHexDecode\":s=r(s),u.push(\"/ASCIIHexEncode\");break;case\"ASCIIHexEncode\":case\"/ASCIIHexEncode\":s=s.split(\"\").map((function(t){return(\"0\"+t.charCodeAt().toString(16)).slice(-2)})).join(\"\")+\">\",u.push(\"/ASCIIHexDecode\");break;case\"FlateEncode\":case\"/FlateEncode\":s=i(s),u.push(\"/FlateDecode\");break;default:throw new Error('The filter: \"'+a[o]+'\" is not implemented')}return{data:s,reverseChain:u.reverse().join(\" \")}}}(g.API),\n/**\n * @license\n * jsPDF fileloading PlugIn\n * Copyright (c) 2018 Aras Abbasi (aras.abbasi@gmail.com)\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */\nfunction(t){t.loadFile=function(t,e,n){return function(t,e,n){e=!1!==e,n=\"function\"==typeof n?n:function(){};var r=void 0;try{r=function(t,e,n){var r=new XMLHttpRequest,i=0,a=function(t){var e=t.length,n=[],r=String.fromCharCode;for(i=0;i<e;i+=1)n.push(r(255&t.charCodeAt(i)));return n.join(\"\")};if(r.open(\"GET\",t,!e),r.overrideMimeType(\"text/plain; charset=x-user-defined\"),!1===e&&(r.onload=function(){200===r.status?n(a(this.responseText)):n(void 0)}),r.send(null),e&&200===r.status)return a(r.responseText)}(t,e,n)}catch(t){}return r}(t,e,n)},t.loadImageFile=t.loadFile}(g.API),\n/**\n * @license\n * Copyright (c) 2018 Erik Koopmans\n * Released under the MIT License.\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */\nfunction(e){function n(){return(t.html2canvas?Promise.resolve(t.html2canvas):import(\"html2canvas\")).catch((function(t){return Promise.reject(new Error(\"Could not load dompurify: \"+t))})).then((function(t){return t.default?t.default:t}))}function r(){return(t.DOMPurify?Promise.resolve(t.DOMPurify):import(\"dompurify\")).catch((function(t){return Promise.reject(new Error(\"Could not load dompurify: \"+t))})).then((function(t){return t.default?t.default:t}))}var i=function(t){var e=typeof t;return\"undefined\"===e?\"undefined\":\"string\"===e||t instanceof String?\"string\":\"number\"===e||t instanceof Number?\"number\":\"function\"===e||t instanceof Function?\"function\":t&&t.constructor===Array?\"array\":t&&1===t.nodeType?\"element\":\"object\"===e?\"object\":\"unknown\"},a=function(t,e){var n=document.createElement(t);for(var r in e.className&&(n.className=e.className),e.innerHTML&&e.dompurify&&(n.innerHTML=e.dompurify.sanitize(e.innerHTML)),e.style)n.style[r]=e.style[r];return n},o=function(t,e){for(var n=3===t.nodeType?document.createTextNode(t.nodeValue):t.cloneNode(!1),r=t.firstChild;r;r=r.nextSibling)!0!==e&&1===r.nodeType&&\"SCRIPT\"===r.nodeName||n.appendChild(o(r,e));return 1===t.nodeType&&(\"CANVAS\"===t.nodeName?(n.width=t.width,n.height=t.height,n.getContext(\"2d\").drawImage(t,0,0)):\"TEXTAREA\"!==t.nodeName&&\"SELECT\"!==t.nodeName||(n.value=t.value),n.addEventListener(\"load\",(function(){n.scrollTop=t.scrollTop,n.scrollLeft=t.scrollLeft}),!0)),n},s=function t(e){var n=Object.assign(t.convert(Promise.resolve()),JSON.parse(JSON.stringify(t.template))),r=t.convert(Promise.resolve(),n);return r=(r=r.setProgress(1,t,1,[t])).set(e)};(s.prototype=Object.create(Promise.prototype)).constructor=s,s.convert=function(t,e){return t.__proto__=e||s.prototype,t},s.template={prop:{src:null,container:null,overlay:null,canvas:null,img:null,pdf:null,pageSize:null,callback:function(){}},progress:{val:0,state:null,n:0,stack:[]},opt:{filename:\"file.pdf\",margin:[0,0,0,0],enableLinks:!0,x:0,y:0,html2canvas:{},jsPDF:{},backgroundColor:\"transparent\"}},s.prototype.from=function(t,e){return this.then((function(){switch(e=e||function(t){switch(i(t)){case\"string\":return\"string\";case\"element\":return\"canvas\"===t.nodeName.toLowerCase?\"canvas\":\"element\";default:return\"unknown\"}}(t)){case\"string\":return this.then(r).then((function(e){return this.set({src:a(\"div\",{innerHTML:t,dompurify:e})})}));case\"element\":return this.set({src:t});case\"canvas\":return this.set({canvas:t});case\"img\":return this.set({img:t});default:return this.error(\"Unknown source type.\")}}))},s.prototype.to=function(t){switch(t){case\"container\":return this.toContainer();case\"canvas\":return this.toCanvas();case\"img\":return this.toImg();case\"pdf\":return this.toPdf();default:return this.error(\"Invalid target.\")}},s.prototype.toContainer=function(){return this.thenList([function(){return this.prop.src||this.error(\"Cannot duplicate - no source HTML.\")},function(){return this.prop.pageSize||this.setPageSize()}]).then((function(){var t={position:\"relative\",display:\"inline-block\",width:Math.max(this.prop.src.clientWidth,this.prop.src.scrollWidth,this.prop.src.offsetWidth)+\"px\",left:0,right:0,top:0,margin:\"auto\",backgroundColor:this.opt.backgroundColor},e=o(this.prop.src,this.opt.html2canvas.javascriptEnabled);\"BODY\"===e.tagName&&(t.height=Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)+\"px\"),this.prop.overlay=a(\"div\",{className:\"html2pdf__overlay\",style:{position:\"fixed\",overflow:\"hidden\",zIndex:1e3,left:\"-100000px\",right:0,bottom:0,top:0}}),this.prop.container=a(\"div\",{className:\"html2pdf__container\",style:t}),this.prop.container.appendChild(e),this.prop.container.firstChild.appendChild(a(\"div\",{style:{clear:\"both\",border:\"0 none transparent\",margin:0,padding:0,height:0}})),this.prop.container.style.float=\"none\",this.prop.overlay.appendChild(this.prop.container),document.body.appendChild(this.prop.overlay),this.prop.container.firstChild.style.position=\"relative\",this.prop.container.height=Math.max(this.prop.container.firstChild.clientHeight,this.prop.container.firstChild.scrollHeight,this.prop.container.firstChild.offsetHeight)+\"px\"}))},s.prototype.toCanvas=function(){var t=[function(){return document.body.contains(this.prop.container)||this.toContainer()}];return this.thenList(t).then(n).then((function(t){var e=Object.assign({},this.opt.html2canvas);return delete e.onrendered,t(this.prop.container,e)})).then((function(t){(this.opt.html2canvas.onrendered||function(){})(t),this.prop.canvas=t,document.body.removeChild(this.prop.overlay)}))},s.prototype.toContext2d=function(){var t=[function(){return document.body.contains(this.prop.container)||this.toContainer()}];return this.thenList(t).then(n).then((function(t){var e=this.opt.jsPDF,n=Object.assign({async:!0,allowTaint:!0,scale:1,scrollX:this.opt.scrollX||0,scrollY:this.opt.scrollY||0,backgroundColor:\"#ffffff\",imageTimeout:15e3,logging:!0,proxy:null,removeContainer:!0,foreignObjectRendering:!1,useCORS:!1},this.opt.html2canvas);return delete n.onrendered,e.context2d.autoPaging=!0,e.context2d.posX=this.opt.x,e.context2d.posY=this.opt.y,n.windowHeight=n.windowHeight||0,n.windowHeight=0==n.windowHeight?Math.max(this.prop.container.clientHeight,this.prop.container.scrollHeight,this.prop.container.offsetHeight):n.windowHeight,t(this.prop.container,n)})).then((function(t){(this.opt.html2canvas.onrendered||function(){})(t),this.prop.canvas=t,document.body.removeChild(this.prop.overlay)}))},s.prototype.toImg=function(){return this.thenList([function(){return this.prop.canvas||this.toCanvas()}]).then((function(){var t=this.prop.canvas.toDataURL(\"image/\"+this.opt.image.type,this.opt.image.quality);this.prop.img=document.createElement(\"img\"),this.prop.img.src=t}))},s.prototype.toPdf=function(){return this.thenList([function(){return this.toContext2d()}]).then((function(){this.prop.pdf=this.prop.pdf||this.opt.jsPDF}))},s.prototype.output=function(t,e,n){return\"img\"===(n=n||\"pdf\").toLowerCase()||\"image\"===n.toLowerCase()?this.outputImg(t,e):this.outputPdf(t,e)},s.prototype.outputPdf=function(t,e){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).then((function(){return this.prop.pdf.output(t,e)}))},s.prototype.outputImg=function(t){return this.thenList([function(){return this.prop.img||this.toImg()}]).then((function(){switch(t){case void 0:case\"img\":return this.prop.img;case\"datauristring\":case\"dataurlstring\":return this.prop.img.src;case\"datauri\":case\"dataurl\":return document.location.href=this.prop.img.src;default:throw'Image output type \"'+t+'\" is not supported.'}}))},s.prototype.save=function(t){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).set(t?{filename:t}:null).then((function(){this.prop.pdf.save(this.opt.filename)}))},s.prototype.doCallback=function(){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).then((function(){this.prop.callback(this.prop.pdf)}))},s.prototype.set=function(t){if(\"object\"!==i(t))return this;var e=Object.keys(t||{}).map((function(e){if(e in s.template.prop)return function(){this.prop[e]=t[e]};switch(e){case\"margin\":return this.setMargin.bind(this,t.margin);case\"jsPDF\":return function(){return this.opt.jsPDF=t.jsPDF,this.setPageSize()};case\"pageSize\":return this.setPageSize.bind(this,t.pageSize);default:return function(){this.opt[e]=t[e]}}}),this);return this.then((function(){return this.thenList(e)}))},s.prototype.get=function(t,e){return this.then((function(){var n=t in s.template.prop?this.prop[t]:this.opt[t];return e?e(n):n}))},s.prototype.setMargin=function(t){return this.then((function(){switch(i(t)){case\"number\":t=[t,t,t,t];case\"array\":if(2===t.length&&(t=[t[0],t[1],t[0],t[1]]),4===t.length)break;default:return this.error(\"Invalid margin array.\")}this.opt.margin=t})).then(this.setPageSize)},s.prototype.setPageSize=function(t){function e(t,e){return Math.floor(t*e/72*96)}return this.then((function(){(t=t||g.getPageSize(this.opt.jsPDF)).hasOwnProperty(\"inner\")||(t.inner={width:t.width-this.opt.margin[1]-this.opt.margin[3],height:t.height-this.opt.margin[0]-this.opt.margin[2]},t.inner.px={width:e(t.inner.width,t.k),height:e(t.inner.height,t.k)},t.inner.ratio=t.inner.height/t.inner.width),this.prop.pageSize=t}))},s.prototype.setProgress=function(t,e,n,r){return null!=t&&(this.progress.val=t),null!=e&&(this.progress.state=e),null!=n&&(this.progress.n=n),null!=r&&(this.progress.stack=r),this.progress.ratio=this.progress.val/this.progress.state,this},s.prototype.updateProgress=function(t,e,n,r){return this.setProgress(t?this.progress.val+t:null,e||null,n?this.progress.n+n:null,r?this.progress.stack.concat(r):null)},s.prototype.then=function(t,e){var n=this;return this.thenCore(t,e,(function(t,e){return n.updateProgress(null,null,1,[t]),Promise.prototype.then.call(this,(function(e){return n.updateProgress(null,t),e})).then(t,e).then((function(t){return n.updateProgress(1),t}))}))},s.prototype.thenCore=function(t,e,n){n=n||Promise.prototype.then;t&&(t=t.bind(this)),e&&(e=e.bind(this));var r=-1!==Promise.toString().indexOf(\"[native code]\")&&\"Promise\"===Promise.name?this:s.convert(Object.assign({},this),Promise.prototype),i=n.call(r,t,e);return s.convert(i,this.__proto__)},s.prototype.thenExternal=function(t,e){return Promise.prototype.then.call(this,t,e)},s.prototype.thenList=function(t){var e=this;return t.forEach((function(t){e=e.thenCore(t)})),e},s.prototype.catch=function(t){t&&(t=t.bind(this));var e=Promise.prototype.catch.call(this,t);return s.convert(e,this)},s.prototype.catchExternal=function(t){return Promise.prototype.catch.call(this,t)},s.prototype.error=function(t){return this.then((function(){throw new Error(t)}))},s.prototype.using=s.prototype.set,s.prototype.saveAs=s.prototype.save,s.prototype.export=s.prototype.output,s.prototype.run=s.prototype.then,g.getPageSize=function(t,e,n){if(\"object\"==typeof t){var r=t;t=r.orientation,e=r.unit||e,n=r.format||n}e=e||\"mm\",n=n||\"a4\",t=(\"\"+(t||\"P\")).toLowerCase();var i,a=(\"\"+n).toLowerCase(),o={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],\"government-letter\":[576,756],legal:[612,1008],\"junior-legal\":[576,360],ledger:[1224,792],tabloid:[792,1224],\"credit-card\":[153,243]};switch(e){case\"pt\":i=1;break;case\"mm\":i=72/25.4;break;case\"cm\":i=72/2.54;break;case\"in\":i=72;break;case\"px\":i=.75;break;case\"pc\":case\"em\":i=12;break;case\"ex\":i=6;break;default:throw\"Invalid unit: \"+e}var s,u=0,c=0;if(o.hasOwnProperty(a))u=o[a][1]/i,c=o[a][0]/i;else try{u=n[1],c=n[0]}catch(t){throw new Error(\"Invalid format: \"+n)}if(\"p\"===t||\"portrait\"===t)t=\"p\",c>u&&(s=c,c=u,u=s);else{if(\"l\"!==t&&\"landscape\"!==t)throw\"Invalid orientation: \"+t;t=\"l\",u>c&&(s=c,c=u,u=s)}return{width:c,height:u,unit:e,k:i,orientation:t}},e.html=function(t,e){(e=e||{}).callback=e.callback||function(){},e.html2canvas=e.html2canvas||{},e.html2canvas.canvas=e.html2canvas.canvas||this.canvas,e.jsPDF=e.jsPDF||this;var n=new s(e);return e.worker?n:n.from(t).doCallback()}}(g.API),g.API.addJS=function(t){return vt=t,this.internal.events.subscribe(\"postPutResources\",(function(){gt=this.internal.newObject(),this.internal.out(\"<<\"),this.internal.out(\"/Names [(EmbeddedJS) \"+(gt+1)+\" 0 R]\"),this.internal.out(\">>\"),this.internal.out(\"endobj\"),mt=this.internal.newObject(),this.internal.out(\"<<\"),this.internal.out(\"/S /JavaScript\"),this.internal.out(\"/JS (\"+vt+\")\"),this.internal.out(\">>\"),this.internal.out(\"endobj\")})),this.internal.events.subscribe(\"putCatalog\",(function(){void 0!==gt&&void 0!==mt&&this.internal.out(\"/Names <</JavaScript \"+gt+\" 0 R>>\")})),this},\n/**\n * @license\n * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */\nfunction(t){var e;t.events.push([\"postPutResources\",function(){var t=this,n=/^(\\d+) 0 obj$/;if(this.outline.root.children.length>0)for(var r=t.outline.render().split(/\\r\\n/),i=0;i<r.length;i++){var a=r[i],o=n.exec(a);if(null!=o){var s=o[1];t.internal.newObjectDeferredBegin(s,!1)}t.internal.write(a)}if(this.outline.createNamedDestinations){var u=this.internal.pages.length,c=[];for(i=0;i<u;i++){var h=t.internal.newObject();c.push(h);var l=t.internal.getPageInfo(i+1);t.internal.write(\"<< /D[\"+l.objId+\" 0 R /XYZ null null null]>> endobj\")}var f=t.internal.newObject();t.internal.write(\"<< /Names [ \");for(i=0;i<c.length;i++)t.internal.write(\"(page_\"+(i+1)+\")\"+c[i]+\" 0 R\");t.internal.write(\" ] >>\",\"endobj\"),e=t.internal.newObject(),t.internal.write(\"<< /Dests \"+f+\" 0 R\"),t.internal.write(\">>\",\"endobj\")}}]),t.events.push([\"putCatalog\",function(){this.outline.root.children.length>0&&(this.internal.write(\"/Outlines\",this.outline.makeRef(this.outline.root)),this.outline.createNamedDestinations&&this.internal.write(\"/Names \"+e+\" 0 R\"))}]),t.events.push([\"initialized\",function(){var t=this;t.outline={createNamedDestinations:!1,root:{children:[]}},t.outline.add=function(t,e,n){var r={title:e,options:n,children:[]};return null==t&&(t=this.root),t.children.push(r),r},t.outline.render=function(){return this.ctx={},this.ctx.val=\"\",this.ctx.pdf=t,this.genIds_r(this.root),this.renderRoot(this.root),this.renderItems(this.root),this.ctx.val},t.outline.genIds_r=function(e){e.id=t.internal.newObjectDeferred();for(var n=0;n<e.children.length;n++)this.genIds_r(e.children[n])},t.outline.renderRoot=function(t){this.objStart(t),this.line(\"/Type /Outlines\"),t.children.length>0&&(this.line(\"/First \"+this.makeRef(t.children[0])),this.line(\"/Last \"+this.makeRef(t.children[t.children.length-1]))),this.line(\"/Count \"+this.count_r({count:0},t)),this.objEnd()},t.outline.renderItems=function(e){for(var n=this.ctx.pdf.internal.getVerticalCoordinateString,r=0;r<e.children.length;r++){var i=e.children[r];this.objStart(i),this.line(\"/Title \"+this.makeString(i.title)),this.line(\"/Parent \"+this.makeRef(e)),r>0&&this.line(\"/Prev \"+this.makeRef(e.children[r-1])),r<e.children.length-1&&this.line(\"/Next \"+this.makeRef(e.children[r+1])),i.children.length>0&&(this.line(\"/First \"+this.makeRef(i.children[0])),this.line(\"/Last \"+this.makeRef(i.children[i.children.length-1])));var a=this.count=this.count_r({count:0},i);if(a>0&&this.line(\"/Count \"+a),i.options&&i.options.pageNumber){var o=t.internal.getPageInfo(i.options.pageNumber);this.line(\"/Dest [\"+o.objId+\" 0 R /XYZ 0 \"+n(0)+\" 0]\")}this.objEnd()}for(var s=0;s<e.children.length;s++)this.renderItems(e.children[s])},t.outline.line=function(t){this.ctx.val+=t+\"\\r\\n\"},t.outline.makeRef=function(t){return t.id+\" 0 R\"},t.outline.makeString=function(e){return\"(\"+t.internal.pdfEscape(e)+\")\"},t.outline.objStart=function(t){this.ctx.val+=\"\\r\\n\"+t.id+\" 0 obj\\r\\n<<\\r\\n\"},t.outline.objEnd=function(){this.ctx.val+=\">> \\r\\nendobj\\r\\n\"},t.outline.count_r=function(t,e){for(var n=0;n<e.children.length;n++)t.count++,this.count_r(t,e.children[n]);return t.count}}])}(g.API),\n/**\n * @license\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */\nfunction(t){var e=[192,193,194,195,196,197,198,199];t.processJPEG=function(t,n,r,i,a,o){var s,u=this.decode.DCT_DECODE,c=null;if(\"string\"==typeof t||this.__addimage__.isArrayBuffer(t)||this.__addimage__.isArrayBufferView(t)){switch(t=a||t,t=this.__addimage__.isArrayBuffer(t)?new Uint8Array(t):t,(s=function(t){for(var n,r=256*t.charCodeAt(4)+t.charCodeAt(5),i=t.length,a={width:0,height:0,numcomponents:1},o=4;o<i;o+=2){if(o+=r,-1!==e.indexOf(t.charCodeAt(o+1))){n=256*t.charCodeAt(o+5)+t.charCodeAt(o+6),a={width:256*t.charCodeAt(o+7)+t.charCodeAt(o+8),height:n,numcomponents:t.charCodeAt(o+9)};break}r=256*t.charCodeAt(o+2)+t.charCodeAt(o+3)}return a}(t=this.__addimage__.isArrayBufferView(t)?this.__addimage__.arrayBufferToBinaryString(t):t)).numcomponents){case 1:o=this.color_spaces.DEVICE_GRAY;break;case 4:o=this.color_spaces.DEVICE_CMYK;break;case 3:o=this.color_spaces.DEVICE_RGB}c={data:t,width:s.width,height:s.height,colorSpace:o,bitsPerComponent:8,filter:u,index:n,alias:r}}return c}}(g.API);\n/**\n * @license\n * Extracted from pdf.js\n * https://github.com/andreasgal/pdf.js\n *\n * Copyright (c) 2011 Mozilla Foundation\n *\n * Contributors: Andreas Gal <gal@mozilla.com>\n * Chris G Jones <cjones@mozilla.com>\n * Shaon Barman <shaon.barman@gmail.com>\n * Vivien Nicolas <21@vingtetun.org>\n * Justin D'Arcangelo <justindarc@gmail.com>\n * Yury Delendik\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\nvar At,_t,St,Pt,kt,Ft=function(){function t(){this.pos=0,this.bufferLength=0,this.eof=!1,this.buffer=null}return t.prototype={ensureBuffer:function(t){var e=this.buffer,n=e?e.byteLength:0;if(t<n)return e;for(var r=512;r<t;)r<<=1;for(var i=new Uint8Array(r),a=0;a<n;++a)i[a]=e[a];return this.buffer=i},getByte:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return this.buffer[this.pos++]},getBytes:function(t){var e=this.pos;if(t){this.ensureBuffer(e+t);for(var n=e+t;!this.eof&&this.bufferLength<n;)this.readBlock();var r=this.bufferLength;n>r&&(n=r)}else{for(;!this.eof;)this.readBlock();n=this.bufferLength}return this.pos=n,this.buffer.subarray(e,n)},lookChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos])},getChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos++])},makeSubStream:function(t,e,n){for(var r=t+e;this.bufferLength<=r&&!this.eof;)this.readBlock();return new Stream(this.buffer,t,e,n)},skip:function(t){t||(t=1),this.pos+=t},reset:function(){this.pos=0}},t}(),It=(\"undefined\"!=typeof self&&self||\"undefined\"!=typeof window&&window||\"undefined\"!=typeof global&&global||Function('return typeof this === \"object\" && this.content')()||Function(\"return this\")()).FlateStream=function(){if(\"undefined\"!=typeof Uint32Array){var t=new Uint32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),e=new Uint32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),n=new Uint32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),r=[new Uint32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],i=[new Uint32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5];return o.prototype=Object.create(Ft.prototype),o.prototype.getBits=function(t){for(var e,n=this.codeSize,r=this.codeBuf,i=this.bytes,o=this.bytesPos;n<t;)void 0===(e=i[o++])&&a(\"Bad encoding in flate stream\"),r|=e<<n,n+=8;return e=r&(1<<t)-1,this.codeBuf=r>>t,this.codeSize=n-=t,this.bytesPos=o,e},o.prototype.getCode=function(t){for(var e=t[0],n=t[1],r=this.codeSize,i=this.codeBuf,o=this.bytes,s=this.bytesPos;r<n;){var u;void 0===(u=o[s++])&&a(\"Bad encoding in flate stream\"),i|=u<<r,r+=8}var c=e[i&(1<<n)-1],h=c>>16,l=65535&c;return(0==r||r<h||0==h)&&a(\"Bad encoding in flate stream\"),this.codeBuf=i>>h,this.codeSize=r-h,this.bytesPos=s,l},o.prototype.generateHuffmanTable=function(t){for(var e=t.length,n=0,r=0;r<e;++r)t[r]>n&&(n=t[r]);for(var i=1<<n,a=new Uint32Array(i),o=1,s=0,u=2;o<=n;++o,s<<=1,u<<=1)for(var c=0;c<e;++c)if(t[c]==o){var h=0,l=s;for(r=0;r<o;++r)h=h<<1|1&l,l>>=1;for(r=h;r<i;r+=u)a[r]=o<<16|c;++s}return[a,n]},o.prototype.readBlock=function(){function o(t,e,n,r,i){for(var a=t.getBits(n)+r;a-- >0;)e[p++]=i}var s=this.getBits(3);if(1&s&&(this.eof=!0),0!=(s>>=1)){var u,c;if(1==s)u=r,c=i;else if(2==s){for(var h=this.getBits(5)+257,l=this.getBits(5)+1,f=this.getBits(4)+4,d=Array(t.length),p=0;p<f;)d[t[p++]]=this.getBits(3);for(var g=this.generateHuffmanTable(d),m=0,v=(p=0,h+l),b=new Array(v);p<v;){var y=this.getCode(g);16==y?o(this,b,2,3,m):17==y?o(this,b,3,3,m=0):18==y?o(this,b,7,11,m=0):b[p++]=m=y}u=this.generateHuffmanTable(b.slice(0,h)),c=this.generateHuffmanTable(b.slice(h,v))}else a(\"Unknown block type in flate stream\");for(var w=(j=this.buffer)?j.length:0,N=this.bufferLength;;){var L=this.getCode(u);if(L<256)N+1>=w&&(w=(j=this.ensureBuffer(N+1)).length),j[N++]=L;else{if(256==L)return void(this.bufferLength=N);var x=(L=e[L-=257])>>16;x>0&&(x=this.getBits(x));m=(65535&L)+x;L=this.getCode(c),(x=(L=n[L])>>16)>0&&(x=this.getBits(x));var A=(65535&L)+x;N+m>=w&&(w=(j=this.ensureBuffer(N+m)).length);for(var _=0;_<m;++_,++N)j[N]=j[N-A]}}}else{var S,P=this.bytes,k=this.bytesPos;void 0===(S=P[k++])&&a(\"Bad block header in flate stream\");var F=S;void 0===(S=P[k++])&&a(\"Bad block header in flate stream\"),F|=S<<8,void 0===(S=P[k++])&&a(\"Bad block header in flate stream\");var I=S;void 0===(S=P[k++])&&a(\"Bad block header in flate stream\"),(I|=S<<8)!=(65535&~F)&&a(\"Bad uncompressed block length in flate stream\"),this.codeBuf=0,this.codeSize=0;var C=this.bufferLength,j=this.ensureBuffer(C+F),B=C+F;this.bufferLength=B;for(var O=C;O<B;++O){if(void 0===(S=P[k++])){this.eof=!0;break}j[O]=S}this.bytesPos=k}},o}function a(t){throw new Error(t)}function o(t){var e=0,n=t[e++],r=t[e++];-1!=n&&-1!=r||a(\"Invalid header in flate stream\"),8!=(15&n)&&a(\"Unknown compression method in flate stream\"),((n<<8)+r)%31!=0&&a(\"Bad FCHECK in flate stream\"),32&r&&a(\"FDICT bit set in flate stream\"),this.bytes=t,this.bytesPos=2,this.codeSize=0,this.codeBuf=0,Ft.call(this)}}(),Ct=function(){var e,n,r;function i(t){var e,n,r,i,a,o,s,u,c,h,l,f,d,p;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},o=null;;){switch(e=this.readUInt32(),c=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join(\"\")){case\"IHDR\":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case\"acTL\":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case\"PLTE\":this.palette=this.read(e);break;case\"fcTL\":o&&this.animation.frames.push(o),this.pos+=4,o={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},a=this.readUInt16(),i=this.readUInt16()||100,o.delay=1e3*a/i,o.disposeOp=this.data[this.pos++],o.blendOp=this.data[this.pos++],o.data=[];break;case\"IDAT\":case\"fdAT\":for(\"fdAT\"===c&&(this.pos+=4,e-=4),t=(null!=o?o.data:void 0)||this.imgData,f=0;0<=e?f<e:f>e;0<=e?++f:--f)t.push(this.data[this.pos++]);break;case\"tRNS\":switch(this.transparency={},this.colorType){case 3:if(r=this.palette.length/3,this.transparency.indexed=this.read(e),this.transparency.indexed.length>r)throw new Error(\"More transparent colors than palette size\");if((h=r-this.transparency.indexed.length)>0)for(d=0;0<=h?d<h:d>h;0<=h?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case\"tEXt\":s=(l=this.read(e)).indexOf(0),u=String.fromCharCode.apply(String,l.slice(0,s)),this.text[u]=String.fromCharCode.apply(String,l.slice(s+1));break;case\"IEND\":return o&&this.animation.frames.push(o),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(p=this.colorType)||6===p,n=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*n,this.colorSpace=function(){switch(this.colors){case 1:return\"DeviceGray\";case 3:return\"DeviceRGB\"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error(\"Incomplete or corrupt PNG file\")}}i.prototype.read=function(t){var e,n;for(n=[],e=0;0<=t?e<t:e>t;0<=t?++e:--e)n.push(this.data[this.pos++]);return n},i.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},i.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},i.prototype.decodePixels=function(t){var e=this.pixelBitlength/8,n=new Uint8Array(this.width*this.height*e),r=0,i=this;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);function a(a,o,s,u){var c,h,l,f,d,p,g,m,v,b,y,w,N,L,x,A,_,S,P,k,F,I=Math.ceil((i.width-a)/s),C=Math.ceil((i.height-o)/u),j=i.width==I&&i.height==C;for(L=e*I,w=j?n:new Uint8Array(L*C),p=t.length,N=0,h=0;N<C&&r<p;){switch(t[r++]){case 0:for(f=_=0;_<L;f=_+=1)w[h++]=t[r++];break;case 1:for(f=S=0;S<L;f=S+=1)c=t[r++],d=f<e?0:w[h-e],w[h++]=(c+d)%256;break;case 2:for(f=P=0;P<L;f=P+=1)c=t[r++],l=(f-f%e)/e,x=N&&w[(N-1)*L+l*e+f%e],w[h++]=(x+c)%256;break;case 3:for(f=k=0;k<L;f=k+=1)c=t[r++],l=(f-f%e)/e,d=f<e?0:w[h-e],x=N&&w[(N-1)*L+l*e+f%e],w[h++]=(c+Math.floor((d+x)/2))%256;break;case 4:for(f=F=0;F<L;f=F+=1)c=t[r++],l=(f-f%e)/e,d=f<e?0:w[h-e],0===N?x=A=0:(x=w[(N-1)*L+l*e+f%e],A=l&&w[(N-1)*L+(l-1)*e+f%e]),g=d+x-A,m=Math.abs(g-d),b=Math.abs(g-x),y=Math.abs(g-A),v=m<=b&&m<=y?d:b<=y?x:A,w[h++]=(c+v)%256;break;default:throw new Error(\"Invalid filter algorithm: \"+t[r-1])}if(!j){var B=((o+N*u)*i.width+a)*e,O=N*L;for(f=0;f<I;f+=1){for(var M=0;M<e;M+=1)n[B++]=w[O++];B+=(s-1)*e}}N++}}return t=(t=new It(t)).getBytes(),1==i.interlaceMethod?(a(0,0,8,8),a(4,0,8,8),a(0,4,4,8),a(2,0,4,4),a(0,2,2,4),a(1,0,2,2),a(0,1,1,2)):a(0,0,1,1),n},i.prototype.decodePalette=function(){var t,e,n,r,i,a,o,s,u;for(n=this.palette,a=this.transparency.indexed||[],i=new Uint8Array((a.length||0)+n.length),r=0,t=0,e=o=0,s=n.length;o<s;e=o+=3)i[r++]=n[e],i[r++]=n[e+1],i[r++]=n[e+2],i[r++]=null!=(u=a[t++])?u:255;return i},i.prototype.copyToImageData=function(t,e){var n,r,i,a,o,s,u,c,h,l,f;if(r=this.colors,h=null,n=this.hasAlphaChannel,this.palette.length&&(h=null!=(f=this._decodedPalette)?f:this._decodedPalette=this.decodePalette(),r=4,n=!0),c=(i=t.data||t).length,o=h||e,a=s=0,1===r)for(;a<c;)u=h?4*e[a/4]:s,l=o[u++],i[a++]=l,i[a++]=l,i[a++]=l,i[a++]=n?o[u++]:255,s=u;else for(;a<c;)u=h?4*e[a/4]:s,i[a++]=o[u++],i[a++]=o[u++],i[a++]=o[u++],i[a++]=n?o[u++]:255,s=u},i.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t};var a=function(){if(\"[object Window]\"===Object.prototype.toString.call(t)){try{n=t.document.createElement(\"canvas\"),r=n.getContext(\"2d\")}catch(t){return!1}return!0}return!1};return a(),e=function(t){var e;if(!0===a())return r.width=t.width,r.height=t.height,r.clearRect(0,0,t.width,t.height),r.putImageData(t,0,0),(e=new Image).src=n.toDataURL(),e;throw new Error(\"This method requires a Browser with Canvas-capability.\")},i.prototype.decodeFrames=function(t){var n,r,i,a,o,s,u,c;if(this.animation){for(c=[],r=o=0,s=(u=this.animation.frames).length;o<s;r=++o)n=u[r],i=t.createImageData(n.width,n.height),a=this.decodePixels(new Uint8Array(n.data)),this.copyToImageData(i,a),n.imageData=i,c.push(n.image=e(i));return c}},i.prototype.renderFrame=function(t,e){var n,r,i;return n=(r=this.animation.frames)[e],i=r[e-1],0===e&&t.clearRect(0,0,this.width,this.height),1===(null!=i?i.disposeOp:void 0)?t.clearRect(i.xOffset,i.yOffset,i.width,i.height):2===(null!=i?i.disposeOp:void 0)&&t.putImageData(i.imageData,i.xOffset,i.yOffset),0===n.blendOp&&t.clearRect(n.xOffset,n.yOffset,n.width,n.height),t.drawImage(n.image,n.xOffset,n.yOffset)},i.prototype.animate=function(t){var e,n,r,i,a,o,s=this;return n=0,o=this.animation,i=o.numFrames,r=o.frames,a=o.numPlays,(e=function(){var o,u;if(o=n++%i,u=r[o],s.renderFrame(t,o),i>1&&n/i<a)return s.animation._timeout=setTimeout(e,u.delay)})()},i.prototype.stopAnimation=function(){var t;return clearTimeout(null!=(t=this.animation)?t._timeout:void 0)},i.prototype.render=function(t){var e,n;return t._png&&t._png.stopAnimation(),t._png=this,t.width=this.width,t.height=this.height,e=t.getContext(\"2d\"),this.animation?(this.decodeFrames(e),this.animate(e)):(n=e.createImageData(this.width,this.height),this.copyToImageData(n,this.decodePixels()),e.putImageData(n,0,0))},i}();\n/**\n * @license\n * (c) Dean McNamee <dean@gmail.com>, 2013.\n *\n * https://github.com/deanm/omggif\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n *\n * omggif is a JavaScript implementation of a GIF 89a encoder and decoder,\n * including animation and compression. It does not rely on any specific\n * underlying system, so should run in the browser, Node, or Plask.\n */\nfunction jt(t){var e=0;if(71!==t[e++]||73!==t[e++]||70!==t[e++]||56!==t[e++]||56!=(t[e++]+1&253)||97!==t[e++])throw new Error(\"Invalid GIF 87a/89a header.\");var n=t[e++]|t[e++]<<8,r=t[e++]|t[e++]<<8,i=t[e++],a=i>>7,o=1<<(7&i)+1;t[e++];t[e++];var s=null,u=null;a&&(s=e,u=o,e+=3*o);var c=!0,h=[],l=0,f=null,d=0,p=null;for(this.width=n,this.height=r;c&&e<t.length;)switch(t[e++]){case 33:switch(t[e++]){case 255:if(11!==t[e]||78==t[e+1]&&69==t[e+2]&&84==t[e+3]&&83==t[e+4]&&67==t[e+5]&&65==t[e+6]&&80==t[e+7]&&69==t[e+8]&&50==t[e+9]&&46==t[e+10]&&48==t[e+11]&&3==t[e+12]&&1==t[e+13]&&0==t[e+16])e+=14,p=t[e++]|t[e++]<<8,e++;else for(e+=12;;){if(!((P=t[e++])>=0))throw Error(\"Invalid block size\");if(0===P)break;e+=P}break;case 249:if(4!==t[e++]||0!==t[e+4])throw new Error(\"Invalid graphics extension block.\");var g=t[e++];l=t[e++]|t[e++]<<8,f=t[e++],0==(1&g)&&(f=null),d=g>>2&7,e++;break;case 254:for(;;){if(!((P=t[e++])>=0))throw Error(\"Invalid block size\");if(0===P)break;e+=P}break;default:throw new Error(\"Unknown graphic control label: 0x\"+t[e-1].toString(16))}break;case 44:var m=t[e++]|t[e++]<<8,v=t[e++]|t[e++]<<8,b=t[e++]|t[e++]<<8,y=t[e++]|t[e++]<<8,w=t[e++],N=w>>6&1,L=1<<(7&w)+1,x=s,A=u,_=!1;if(w>>7){_=!0;x=e,A=L,e+=3*L}var S=e;for(e++;;){var P;if(!((P=t[e++])>=0))throw Error(\"Invalid block size\");if(0===P)break;e+=P}h.push({x:m,y:v,width:b,height:y,has_local_palette:_,palette_offset:x,palette_size:A,data_offset:S,data_length:e-S,transparent_index:f,interlaced:!!N,delay:l,disposal:d});break;case 59:c=!1;break;default:throw new Error(\"Unknown gif block: 0x\"+t[e-1].toString(16))}this.numFrames=function(){return h.length},this.loopCount=function(){return p},this.frameInfo=function(t){if(t<0||t>=h.length)throw new Error(\"Frame index out of range.\");return h[t]},this.decodeAndBlitFrameBGRA=function(e,r){var i=this.frameInfo(e),a=i.width*i.height,o=new Uint8Array(a);Bt(t,i.data_offset,o,a);var s=i.palette_offset,u=i.transparent_index;null===u&&(u=256);var c=i.width,h=n-c,l=c,f=4*(i.y*n+i.x),d=4*((i.y+i.height)*n+i.x),p=f,g=4*h;!0===i.interlaced&&(g+=4*n*7);for(var m=8,v=0,b=o.length;v<b;++v){var y=o[v];if(0===l&&(l=c,(p+=g)>=d&&(g=4*h+4*n*(m-1),p=f+(c+h)*(m<<1),m>>=1)),y===u)p+=4;else{var w=t[s+3*y],N=t[s+3*y+1],L=t[s+3*y+2];r[p++]=L,r[p++]=N,r[p++]=w,r[p++]=255}--l}},this.decodeAndBlitFrameRGBA=function(e,r){var i=this.frameInfo(e),a=i.width*i.height,o=new Uint8Array(a);Bt(t,i.data_offset,o,a);var s=i.palette_offset,u=i.transparent_index;null===u&&(u=256);var c=i.width,h=n-c,l=c,f=4*(i.y*n+i.x),d=4*((i.y+i.height)*n+i.x),p=f,g=4*h;!0===i.interlaced&&(g+=4*n*7);for(var m=8,v=0,b=o.length;v<b;++v){var y=o[v];if(0===l&&(l=c,(p+=g)>=d&&(g=4*h+4*n*(m-1),p=f+(c+h)*(m<<1),m>>=1)),y===u)p+=4;else{var w=t[s+3*y],N=t[s+3*y+1],L=t[s+3*y+2];r[p++]=w,r[p++]=N,r[p++]=L,r[p++]=255}--l}}}function Bt(t,e,r,i){for(var a=t[e++],o=1<<a,s=o+1,u=s+1,c=a+1,h=(1<<c)-1,l=0,f=0,d=0,p=t[e++],g=new Int32Array(4096),m=null;;){for(;l<16&&0!==p;)f|=t[e++]<<l,l+=8,1===p?p=t[e++]:--p;if(l<c)break;var v=f&h;if(f>>=c,l-=c,v!==o){if(v===s)break;for(var b=v<u?v:m,y=0,w=b;w>o;)w=g[w]>>8,++y;var N=w;if(d+y+(b!==v?1:0)>i)return void n.log(\"Warning, gif stream longer than expected.\");r[d++]=N;var L=d+=y;for(b!==v&&(r[d++]=N),w=b;y--;)w=g[w],r[--L]=255&w,w>>=8;null!==m&&u<4096&&(g[u++]=m<<8|N,u>=h+1&&c<12&&(++c,h=h<<1|1)),m=v}else u=s+1,h=(1<<(c=a+1))-1,m=null}return d!==i&&n.log(\"Warning, gif stream shorter than expected.\"),r}\n/**\n * @license\n Copyright (c) 2008, Adobe Systems Incorporated\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without \n modification, are permitted provided that the following conditions are\n met:\n\n * Redistributions of source code must retain the above copyright notice, \n this list of conditions and the following disclaimer.\n \n * Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the \n documentation and/or other materials provided with the distribution.\n \n * Neither the name of Adobe Systems Incorporated nor the names of its \n contributors may be used to endorse or promote products derived from \n this software without specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS\n IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\n THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR \n CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/function Ot(t){var e,n,r,i,a,o=Math.floor,s=new Array(64),u=new Array(64),c=new Array(64),h=new Array(64),l=new Array(65535),f=new Array(65535),d=new Array(64),p=new Array(64),g=[],m=0,v=7,b=new Array(64),y=new Array(64),w=new Array(64),N=new Array(256),L=new Array(2048),x=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],A=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],_=[0,1,2,3,4,5,6,7,8,9,10,11],S=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],P=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],k=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],F=[0,1,2,3,4,5,6,7,8,9,10,11],I=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],C=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function j(t,e){for(var n=0,r=0,i=new Array,a=1;a<=16;a++){for(var o=1;o<=t[a];o++)i[e[r]]=[],i[e[r]][0]=n,i[e[r]][1]=a,r++,n++;n*=2}return i}function B(t){for(var e=t[0],n=t[1]-1;n>=0;)e&1<<n&&(m|=1<<v),n--,--v<0&&(255==m?(O(255),O(0)):O(m),v=7,m=0)}function O(t){g.push(t)}function M(t){O(t>>8&255),O(255&t)}function E(t,e,n,r,i){for(var a,o=i[0],s=i[240],u=function(t,e){var n,r,i,a,o,s,u,c,h,l,f=0;for(h=0;h<8;++h){n=t[f],r=t[f+1],i=t[f+2],a=t[f+3],o=t[f+4],s=t[f+5],u=t[f+6];var p=n+(c=t[f+7]),g=n-c,m=r+u,v=r-u,b=i+s,y=i-s,w=a+o,N=a-o,L=p+w,x=p-w,A=m+b,_=m-b;t[f]=L+A,t[f+4]=L-A;var S=.707106781*(_+x);t[f+2]=x+S,t[f+6]=x-S;var P=.382683433*((L=N+y)-(_=v+g)),k=.5411961*L+P,F=1.306562965*_+P,I=.707106781*(A=y+v),C=g+I,j=g-I;t[f+5]=j+k,t[f+3]=j-k,t[f+1]=C+F,t[f+7]=C-F,f+=8}for(f=0,h=0;h<8;++h){n=t[f],r=t[f+8],i=t[f+16],a=t[f+24],o=t[f+32],s=t[f+40],u=t[f+48];var B=n+(c=t[f+56]),O=n-c,M=r+u,E=r-u,q=i+s,R=i-s,T=a+o,D=a-o,U=B+T,z=B-T,H=M+q,W=M-q;t[f]=U+H,t[f+32]=U-H;var V=.707106781*(W+z);t[f+16]=z+V,t[f+48]=z-V;var G=.382683433*((U=D+R)-(W=E+O)),Y=.5411961*U+G,J=1.306562965*W+G,X=.707106781*(H=R+E),K=O+X,Z=O-X;t[f+40]=Z+Y,t[f+24]=Z-Y,t[f+8]=K+J,t[f+56]=K-J,f++}for(h=0;h<64;++h)l=t[h]*e[h],d[h]=l>0?l+.5|0:l-.5|0;return d}(t,e),c=0;c<64;++c)p[x[c]]=u[c];var h=p[0]-n;n=p[0],0==h?B(r[0]):(B(r[f[a=32767+h]]),B(l[a]));for(var g=63;g>0&&0==p[g];)g--;if(0==g)return B(o),n;for(var m,v=1;v<=g;){for(var b=v;0==p[v]&&v<=g;)++v;var y=v-b;if(y>=16){m=y>>4;for(var w=1;w<=m;++w)B(s);y&=15}a=32767+p[v],B(i[(y<<4)+f[a]]),B(l[a]),v++}return 63!=g&&B(o),n}function q(t){(t=Math.min(Math.max(t,1),100),a!=t)&&(!function(t){for(var e=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],n=0;n<64;n++){var r=o((e[n]*t+50)/100);r=Math.min(Math.max(r,1),255),s[x[n]]=r}for(var i=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],a=0;a<64;a++){var l=o((i[a]*t+50)/100);l=Math.min(Math.max(l,1),255),u[x[a]]=l}for(var f=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],d=0,p=0;p<8;p++)for(var g=0;g<8;g++)c[d]=1/(s[x[d]]*f[p]*f[g]*8),h[d]=1/(u[x[d]]*f[p]*f[g]*8),d++}(t<50?Math.floor(5e3/t):Math.floor(200-2*t)),a=t)}this.encode=function(t,a){a&&q(a),g=new Array,m=0,v=7,M(65496),M(65504),M(16),O(74),O(70),O(73),O(70),O(0),O(1),O(1),O(0),M(1),M(1),O(0),O(0),function(){M(65499),M(132),O(0);for(var t=0;t<64;t++)O(s[t]);O(1);for(var e=0;e<64;e++)O(u[e])}(),function(t,e){M(65472),M(17),O(8),M(e),M(t),O(3),O(1),O(17),O(0),O(2),O(17),O(1),O(3),O(17),O(1)}(t.width,t.height),function(){M(65476),M(418),O(0);for(var t=0;t<16;t++)O(A[t+1]);for(var e=0;e<=11;e++)O(_[e]);O(16);for(var n=0;n<16;n++)O(S[n+1]);for(var r=0;r<=161;r++)O(P[r]);O(1);for(var i=0;i<16;i++)O(k[i+1]);for(var a=0;a<=11;a++)O(F[a]);O(17);for(var o=0;o<16;o++)O(I[o+1]);for(var s=0;s<=161;s++)O(C[s])}(),M(65498),M(12),O(3),O(1),O(0),O(2),O(17),O(3),O(17),O(0),O(63),O(0);var o=0,l=0,f=0;m=0,v=7,this.encode.displayName=\"_encode_\";for(var d,p,N,x,j,R,T,D,U,z=t.data,H=t.width,W=t.height,V=4*H,G=0;G<W;){for(d=0;d<V;){for(j=V*G+d,T=-1,D=0,U=0;U<64;U++)R=j+(D=U>>3)*V+(T=4*(7&U)),G+D>=W&&(R-=V*(G+1+D-W)),d+T>=V&&(R-=d+T-V+4),p=z[R++],N=z[R++],x=z[R++],b[U]=(L[p]+L[N+256>>0]+L[x+512>>0]>>16)-128,y[U]=(L[p+768>>0]+L[N+1024>>0]+L[x+1280>>0]>>16)-128,w[U]=(L[p+1280>>0]+L[N+1536>>0]+L[x+1792>>0]>>16)-128;o=E(b,c,o,e,r),l=E(y,h,l,n,i),f=E(w,h,f,n,i),d+=32}G+=8}if(v>=0){var Y=[];Y[1]=v+1,Y[0]=(1<<v+1)-1,B(Y)}return M(65497),new Uint8Array(g)},t=t||50,function(){for(var t=String.fromCharCode,e=0;e<256;e++)N[e]=t(e)}(),e=j(A,_),n=j(k,F),r=j(S,P),i=j(I,C),function(){for(var t=1,e=2,n=1;n<=15;n++){for(var r=t;r<e;r++)f[32767+r]=n,l[32767+r]=[],l[32767+r][1]=n,l[32767+r][0]=r;for(var i=-(e-1);i<=-t;i++)f[32767+i]=n,l[32767+i]=[],l[32767+i][1]=n,l[32767+i][0]=e-1+i;t<<=1,e<<=1}}(),function(){for(var t=0;t<256;t++)L[t]=19595*t,L[t+256>>0]=38470*t,L[t+512>>0]=7471*t+32768,L[t+768>>0]=-11059*t,L[t+1024>>0]=-21709*t,L[t+1280>>0]=32768*t+8421375,L[t+1536>>0]=-27439*t,L[t+1792>>0]=-5329*t}(),q(t)}\n/**\n * @license\n * Copyright (c) 2017 Aras Abbasi\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */function Mt(t,e){if(this.pos=0,this.buffer=t,this.datav=new DataView(t.buffer),this.is_with_alpha=!!e,this.bottom_up=!0,this.flag=String.fromCharCode(this.buffer[0])+String.fromCharCode(this.buffer[1]),this.pos+=2,-1===[\"BM\",\"BA\",\"CI\",\"CP\",\"IC\",\"PT\"].indexOf(this.flag))throw new Error(\"Invalid BMP File\");this.parseHeader(),this.parseBGR()}function Et(t){function e(t){if(!t)throw Error(\"assert :P\")}function n(t,e,n){for(var r=0;4>r;r++)if(t[e+r]!=n.charCodeAt(r))return!0;return!1}function r(t,e,n,r,i){for(var a=0;a<i;a++)t[e+a]=n[r+a]}function i(t,e,n,r){for(var i=0;i<r;i++)t[e+i]=n}function a(t){return new Int32Array(t)}function o(t,e){for(var n=[],r=0;r<t;r++)n.push(new e);return n}function s(t,e){var n=[];return function t(n,r,i){for(var a=i[r],o=0;o<a&&(n.push(i.length>r+1?[]:new e),!(i.length<r+1));o++)t(n[o],r+1,i)}(n,0,t),n}function u(t,e){for(var n=\"\",r=0;r<4;r++)n+=String.fromCharCode(t[e++]);return n}function c(t,e){return(t[e+0]<<0|t[e+1]<<8|t[e+2]<<16)>>>0}function h(t,e){return(t[e+0]<<0|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}new(Et=function(){var t=this;function u(t,e){for(var n=1<<e-1>>>0;t&n;)n>>>=1;return n?(t&n-1)+n:t}function c(t,n,r,i,a){e(!(i%r));do{t[n+(i-=r)]=a}while(0<i)}function h(t,n,r,i,o){if(e(2328>=o),512>=o)var s=a(512);else if(null==(s=a(o)))return 0;return function(t,n,r,i,o,s){var h,f,d=n,p=1<<r,g=a(16),m=a(16);for(e(0!=o),e(null!=i),e(null!=t),e(0<r),f=0;f<o;++f){if(15<i[f])return 0;++g[i[f]]}if(g[0]==o)return 0;for(m[1]=0,h=1;15>h;++h){if(g[h]>1<<h)return 0;m[h+1]=m[h]+g[h]}for(f=0;f<o;++f)h=i[f],0<i[f]&&(s[m[h]++]=f);if(1==m[15])return(i=new l).g=0,i.value=s[0],c(t,d,1,p,i),p;var v,b=-1,y=p-1,w=0,N=1,L=1,x=1<<r;for(f=0,h=1,o=2;h<=r;++h,o<<=1){if(N+=L<<=1,0>(L-=g[h]))return 0;for(;0<g[h];--g[h])(i=new l).g=h,i.value=s[f++],c(t,d+w,o,x,i),w=u(w,h)}for(h=r+1,o=2;15>=h;++h,o<<=1){if(N+=L<<=1,0>(L-=g[h]))return 0;for(;0<g[h];--g[h]){if(i=new l,(w&y)!=b){for(d+=x,v=1<<(b=h)-r;15>b&&!(0>=(v-=g[b]));)++b,v<<=1;p+=x=1<<(v=b-r),t[n+(b=w&y)].g=v+r,t[n+b].value=d-n-b}i.g=h-r,i.value=s[f++],c(t,d+(w>>r),o,x,i),w=u(w,h)}}return N!=2*m[15]-1?0:p}(t,n,r,i,o,s)}function l(){this.value=this.g=0}function f(){this.value=this.g=0}function d(){this.G=o(5,l),this.H=a(5),this.jc=this.Qb=this.qb=this.nd=0,this.pd=o(Tn,f)}function p(t,n,r,i){e(null!=t),e(null!=n),e(2147483648>i),t.Ca=254,t.I=0,t.b=-8,t.Ka=0,t.oa=n,t.pa=r,t.Jd=n,t.Yc=r+i,t.Zc=4<=i?r+i-4+1:r,S(t)}function g(t,e){for(var n=0;0<e--;)n|=k(t,128)<<e;return n}function m(t,e){var n=g(t,e);return P(t)?-n:n}function v(t,n,r,i){var a,o=0;for(e(null!=t),e(null!=n),e(4294967288>i),t.Sb=i,t.Ra=0,t.u=0,t.h=0,4<i&&(i=4),a=0;a<i;++a)o+=n[r+a]<<8*a;t.Ra=o,t.bb=i,t.oa=n,t.pa=r}function b(t){for(;8<=t.u&&t.bb<t.Sb;)t.Ra>>>=8,t.Ra+=t.oa[t.pa+t.bb]<<zn-8>>>0,++t.bb,t.u-=8;x(t)&&(t.h=1,t.u=0)}function y(t,n){if(e(0<=n),!t.h&&n<=Un){var r=L(t)&Dn[n];return t.u+=n,b(t),r}return t.h=1,t.u=0}function w(){this.b=this.Ca=this.I=0,this.oa=[],this.pa=0,this.Jd=[],this.Yc=0,this.Zc=[],this.Ka=0}function N(){this.Ra=0,this.oa=[],this.h=this.u=this.bb=this.Sb=this.pa=0}function L(t){return t.Ra>>>(t.u&zn-1)>>>0}function x(t){return e(t.bb<=t.Sb),t.h||t.bb==t.Sb&&t.u>zn}function A(t,e){t.u=e,t.h=x(t)}function _(t){t.u>=Hn&&(e(t.u>=Hn),b(t))}function S(t){e(null!=t&&null!=t.oa),t.pa<t.Zc?(t.I=(t.oa[t.pa++]|t.I<<8)>>>0,t.b+=8):(e(null!=t&&null!=t.oa),t.pa<t.Yc?(t.b+=8,t.I=t.oa[t.pa++]|t.I<<8):t.Ka?t.b=0:(t.I<<=8,t.b+=8,t.Ka=1))}function P(t){return g(t,1)}function k(t,e){var n=t.Ca;0>t.b&&S(t);var r=t.b,i=n*e>>>8,a=(t.I>>>r>i)+0;for(a?(n-=i,t.I-=i+1<<r>>>0):n=i+1,r=n,i=0;256<=r;)i+=8,r>>=8;return r=7^i+Wn[r],t.b-=r,t.Ca=(n<<r)-1,a}function F(t,e,n){t[e+0]=n>>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=n>>0&255}function I(t,e){return t[e+0]<<0|t[e+1]<<8}function C(t,e){return I(t,e)|t[e+2]<<16}function j(t,e){return I(t,e)|I(t,e+2)<<16}function B(t,n){var r=1<<n;return e(null!=t),e(0<n),t.X=a(r),null==t.X?0:(t.Mb=32-n,t.Xa=n,1)}function O(t,n){e(null!=t),e(null!=n),e(t.Xa==n.Xa),r(n.X,0,t.X,0,1<<n.Xa)}function M(){this.X=[],this.Xa=this.Mb=0}function E(t,n,r,i){e(null!=r),e(null!=i);var a=r[0],o=i[0];return 0==a&&(a=(t*o+n/2)/n),0==o&&(o=(n*a+t/2)/t),0>=a||0>=o?0:(r[0]=a,i[0]=o,1)}function q(t,e){return t+(1<<e)-1>>>e}function R(t,e){return((4278255360&t)+(4278255360&e)>>>0&4278255360)+((16711935&t)+(16711935&e)>>>0&16711935)>>>0}function T(e,n){t[n]=function(n,r,i,a,o,s,u){var c;for(c=0;c<o;++c){var h=t[e](s[u+c-1],i,a+c);s[u+c]=R(n[r+c],h)}}}function D(){this.ud=this.hd=this.jd=0}function U(t,e){return((4278124286&(t^e))>>>1)+(t&e)>>>0}function z(t){return 0<=t&&256>t?t:0>t?0:255<t?255:void 0}function H(t,e){return z(t+(t-e+.5>>1))}function W(t,e,n){return Math.abs(e-n)-Math.abs(t-n)}function V(t,e,n,r,i,a,o){for(r=a[o-1],n=0;n<i;++n)a[o+n]=r=R(t[e+n],r)}function G(t,e,n,r,i){var a;for(a=0;a<n;++a){var o=t[e+a],s=o>>8&255,u=16711935&(u=(u=16711935&o)+((s<<16)+s));r[i+a]=(4278255360&o)+u>>>0}}function Y(t,e){e.jd=t>>0&255,e.hd=t>>8&255,e.ud=t>>16&255}function J(t,e,n,r,i,a){var o;for(o=0;o<r;++o){var s=e[n+o],u=s>>>8,c=s,h=255&(h=(h=s>>>16)+((t.jd<<24>>24)*(u<<24>>24)>>>5));c=255&(c=(c=c+((t.hd<<24>>24)*(u<<24>>24)>>>5))+((t.ud<<24>>24)*(h<<24>>24)>>>5));i[a+o]=(4278255360&s)+(h<<16)+c}}function X(e,n,r,i,a){t[n]=function(t,e,n,r,o,s,u,c,h){for(r=u;r<c;++r)for(u=0;u<h;++u)o[s++]=a(n[i(t[e++])])},t[e]=function(e,n,o,s,u,c,h){var l=8>>e.b,f=e.Ea,d=e.K[0],p=e.w;if(8>l)for(e=(1<<e.b)-1,p=(1<<l)-1;n<o;++n){var g,m=0;for(g=0;g<f;++g)g&e||(m=i(s[u++])),c[h++]=a(d[m&p]),m>>=l}else t[\"VP8LMapColor\"+r](s,u,d,p,c,h,n,o,f)}}function K(t,e,n,r,i){for(n=e+n;e<n;){var a=t[e++];r[i++]=a>>16&255,r[i++]=a>>8&255,r[i++]=a>>0&255}}function Z(t,e,n,r,i){for(n=e+n;e<n;){var a=t[e++];r[i++]=a>>16&255,r[i++]=a>>8&255,r[i++]=a>>0&255,r[i++]=a>>24&255}}function $(t,e,n,r,i){for(n=e+n;e<n;){var a=(o=t[e++])>>16&240|o>>12&15,o=o>>0&240|o>>28&15;r[i++]=a,r[i++]=o}}function Q(t,e,n,r,i){for(n=e+n;e<n;){var a=(o=t[e++])>>16&248|o>>13&7,o=o>>5&224|o>>3&31;r[i++]=a,r[i++]=o}}function tt(t,e,n,r,i){for(n=e+n;e<n;){var a=t[e++];r[i++]=a>>0&255,r[i++]=a>>8&255,r[i++]=a>>16&255}}function et(t,e,n,i,a,o){if(0==o)for(n=e+n;e<n;)F(i,((o=t[e++])[0]>>24|o[1]>>8&65280|o[2]<<8&16711680|o[3]<<24)>>>0),a+=32;else r(i,a,t,e,n)}function nt(e,n){t[n][0]=t[e+\"0\"],t[n][1]=t[e+\"1\"],t[n][2]=t[e+\"2\"],t[n][3]=t[e+\"3\"],t[n][4]=t[e+\"4\"],t[n][5]=t[e+\"5\"],t[n][6]=t[e+\"6\"],t[n][7]=t[e+\"7\"],t[n][8]=t[e+\"8\"],t[n][9]=t[e+\"9\"],t[n][10]=t[e+\"10\"],t[n][11]=t[e+\"11\"],t[n][12]=t[e+\"12\"],t[n][13]=t[e+\"13\"],t[n][14]=t[e+\"0\"],t[n][15]=t[e+\"0\"]}function rt(t){return t==Hr||t==Wr||t==Vr||t==Gr}function it(){this.eb=[],this.size=this.A=this.fb=0}function at(){this.y=[],this.f=[],this.ea=[],this.F=[],this.Tc=this.Ed=this.Cd=this.Fd=this.lb=this.Db=this.Ab=this.fa=this.J=this.W=this.N=this.O=0}function ot(){this.Rd=this.height=this.width=this.S=0,this.f={},this.f.RGBA=new it,this.f.kb=new at,this.sd=null}function st(){this.width=[0],this.height=[0],this.Pd=[0],this.Qd=[0],this.format=[0]}function ut(){this.Id=this.fd=this.Md=this.hb=this.ib=this.da=this.bd=this.cd=this.j=this.v=this.Da=this.Sd=this.ob=0}function ct(t){return alert(\"todo:WebPSamplerProcessPlane\"),t.T}function ht(t,e){var n=t.T,i=e.ba.f.RGBA,a=i.eb,o=i.fb+t.ka*i.A,s=vi[e.ba.S],u=t.y,c=t.O,h=t.f,l=t.N,f=t.ea,d=t.W,p=e.cc,g=e.dc,m=e.Mc,v=e.Nc,b=t.ka,y=t.ka+t.T,w=t.U,N=w+1>>1;for(0==b?s(u,c,null,null,h,l,f,d,h,l,f,d,a,o,null,null,w):(s(e.ec,e.fc,u,c,p,g,m,v,h,l,f,d,a,o-i.A,a,o,w),++n);b+2<y;b+=2)p=h,g=l,m=f,v=d,l+=t.Rc,d+=t.Rc,o+=2*i.A,s(u,(c+=2*t.fa)-t.fa,u,c,p,g,m,v,h,l,f,d,a,o-i.A,a,o,w);return c+=t.fa,t.j+y<t.o?(r(e.ec,e.fc,u,c,w),r(e.cc,e.dc,h,l,N),r(e.Mc,e.Nc,f,d,N),n--):1&y||s(u,c,null,null,h,l,f,d,h,l,f,d,a,o+i.A,null,null,w),n}function lt(t,n,r){var i=t.F,a=[t.J];if(null!=i){var o=t.U,s=n.ba.S,u=s==Dr||s==Vr;n=n.ba.f.RGBA;var c=[0],h=t.ka;c[0]=t.T,t.Kb&&(0==h?--c[0]:(--h,a[0]-=t.width),t.j+t.ka+t.T==t.o&&(c[0]=t.o-t.j-h));var l=n.eb;h=n.fb+h*n.A;t=_r(i,a[0],t.width,o,c,l,h+(u?0:3),n.A),e(r==c),t&&rt(s)&&xr(l,h,u,o,c,n.A)}return 0}function ft(t){var e=t.ma,n=e.ba.S,r=11>n,i=n==qr||n==Tr||n==Dr||n==Ur||12==n||rt(n);if(e.memory=null,e.Ib=null,e.Jb=null,e.Nd=null,!En(e.Oa,t,i?11:12))return 0;if(i&&rt(n)&&yn(),t.da)alert(\"todo:use_scaling\");else{if(r){if(e.Ib=ct,t.Kb){if(n=t.U+1>>1,e.memory=a(t.U+2*n),null==e.memory)return 0;e.ec=e.memory,e.fc=0,e.cc=e.ec,e.dc=e.fc+t.U,e.Mc=e.cc,e.Nc=e.dc+n,e.Ib=ht,yn()}}else alert(\"todo:EmitYUV\");i&&(e.Jb=lt,r&&vn())}if(r&&!Ci){for(t=0;256>t;++t)ji[t]=89858*(t-128)+Si>>_i,Mi[t]=-22014*(t-128)+Si,Oi[t]=-45773*(t-128),Bi[t]=113618*(t-128)+Si>>_i;for(t=Pi;t<ki;++t)e=76283*(t-16)+Si>>_i,Ei[t-Pi]=Vt(e,255),qi[t-Pi]=Vt(e+8>>4,15);Ci=1}return 1}function dt(t){var n=t.ma,r=t.U,i=t.T;return e(!(1&t.ka)),0>=r||0>=i?0:(r=n.Ib(t,n),null!=n.Jb&&n.Jb(t,n,r),n.Dc+=r,1)}function pt(t){t.ma.memory=null}function gt(t,e,n,r){return 47!=y(t,8)?0:(e[0]=y(t,14)+1,n[0]=y(t,14)+1,r[0]=y(t,1),0!=y(t,3)?0:!t.h)}function mt(t,e){if(4>t)return t+1;var n=t-2>>1;return(2+(1&t)<<n)+y(e,n)+1}function vt(t,e){return 120<e?e-120:1<=(n=((n=$r[e-1])>>4)*t+(8-(15&n)))?n:1;var n}function bt(t,e,n){var r=L(n),i=t[e+=255&r].g-8;return 0<i&&(A(n,n.u+8),r=L(n),e+=t[e].value,e+=r&(1<<i)-1),A(n,n.u+t[e].g),t[e].value}function yt(t,n,r){return r.g+=t.g,r.value+=t.value<<n>>>0,e(8>=r.g),t.g}function wt(t,n,r){var i=t.xc;return e((n=0==i?0:t.vc[t.md*(r>>i)+(n>>i)])<t.Wb),t.Ya[n]}function Nt(t,n,i,a){var o=t.ab,s=t.c*n,u=t.C;n=u+n;var c=i,h=a;for(a=t.Ta,i=t.Ua;0<o--;){var l=t.gc[o],f=u,d=n,p=c,g=h,m=(h=a,c=i,l.Ea);switch(e(f<d),e(d<=l.nc),l.hc){case 2:Yn(p,g,(d-f)*m,h,c);break;case 0:var v=f,b=d,y=h,w=c,N=(S=l).Ea;0==v&&(Vn(p,g,null,null,1,y,w),V(p,g+1,0,0,N-1,y,w+1),g+=N,w+=N,++v);for(var L=1<<S.b,x=L-1,A=q(N,S.b),_=S.K,S=S.w+(v>>S.b)*A;v<b;){var P=_,k=S,F=1;for(Gn(p,g,y,w-N,1,y,w);F<N;){var I=(F&~x)+L;I>N&&(I=N),(0,$n[P[k++]>>8&15])(p,g+ +F,y,w+F-N,I-F,y,w+F),F=I}g+=N,w+=N,++v&x||(S+=A)}d!=l.nc&&r(h,c-m,h,c+(d-f-1)*m,m);break;case 1:for(m=p,b=g,N=(p=l.Ea)-(w=p&~(y=(g=1<<l.b)-1)),v=q(p,l.b),L=l.K,l=l.w+(f>>l.b)*v;f<d;){for(x=L,A=l,_=new D,S=b+w,P=b+p;b<S;)Y(x[A++],_),Qn(_,m,b,g,h,c),b+=g,c+=g;b<P&&(Y(x[A++],_),Qn(_,m,b,N,h,c),b+=N,c+=N),++f&y||(l+=v)}break;case 3:if(p==h&&g==c&&0<l.b){for(b=h,p=m=c+(d-f)*m-(w=(d-f)*q(l.Ea,l.b)),g=h,y=c,v=[],w=(N=w)-1;0<=w;--w)v[w]=g[y+w];for(w=N-1;0<=w;--w)b[p+w]=v[w];Jn(l,f,d,h,m,h,c)}else Jn(l,f,d,p,g,h,c)}c=a,h=i}h!=i&&r(a,i,c,h,s)}function Lt(t,n){var r=t.V,i=t.Ba+t.c*t.C,a=n-t.C;if(e(n<=t.l.o),e(16>=a),0<a){var o=t.l,s=t.Ta,u=t.Ua,c=o.width;if(Nt(t,a,r,i),a=u=[u],e((r=t.C)<(i=n)),e(o.v<o.va),i>o.o&&(i=o.o),r<o.j){var h=o.j-r;r=o.j;a[0]+=h*c}if(r>=i?r=0:(a[0]+=4*o.v,o.ka=r-o.j,o.U=o.va-o.v,o.T=i-r,r=1),r){if(u=u[0],11>(r=t.ca).S){var l=r.f.RGBA,f=(i=r.S,a=o.U,o=o.T,h=l.eb,l.A),d=o;for(l=l.fb+t.Ma*l.A;0<d--;){var p=s,g=u,m=a,v=h,b=l;switch(i){case Er:tr(p,g,m,v,b);break;case qr:er(p,g,m,v,b);break;case Hr:er(p,g,m,v,b),xr(v,b,0,m,1,0);break;case Rr:ir(p,g,m,v,b);break;case Tr:et(p,g,m,v,b,1);break;case Wr:et(p,g,m,v,b,1),xr(v,b,0,m,1,0);break;case Dr:et(p,g,m,v,b,0);break;case Vr:et(p,g,m,v,b,0),xr(v,b,1,m,1,0);break;case Ur:nr(p,g,m,v,b);break;case Gr:nr(p,g,m,v,b),Ar(v,b,m,1,0);break;case zr:rr(p,g,m,v,b);break;default:e(0)}u+=c,l+=f}t.Ma+=o}else alert(\"todo:EmitRescaledRowsYUVA\");e(t.Ma<=r.height)}}t.C=n,e(t.C<=t.i)}function xt(t){var e;if(0<t.ua)return 0;for(e=0;e<t.Wb;++e){var n=t.Ya[e].G,r=t.Ya[e].H;if(0<n[1][r[1]+0].g||0<n[2][r[2]+0].g||0<n[3][r[3]+0].g)return 0}return 1}function At(t,n,r,i,a,o){if(0!=t.Z){var s=t.qd,u=t.rd;for(e(null!=mi[t.Z]);n<r;++n)mi[t.Z](s,u,i,a,i,a,o),s=i,u=a,a+=o;t.qd=s,t.rd=u}}function _t(t,n){var r=t.l.ma,i=0==r.Z||1==r.Z?t.l.j:t.C;i=t.C<i?i:t.C;if(e(n<=t.l.o),n>i){var a=t.l.width,o=r.ca,s=r.tb+a*i,u=t.V,c=t.Ba+t.c*i,h=t.gc;e(1==t.ab),e(3==h[0].hc),Kn(h[0],i,n,u,c,o,s),At(r,i,n,o,s,a)}t.C=t.Ma=n}function St(t,n,r,i,a,o,s){var u=t.$/i,c=t.$%i,h=t.m,l=t.s,f=r+t.$,d=f;a=r+i*a;var p=r+i*o,g=280+l.ua,m=t.Pb?u:16777216,v=0<l.ua?l.Wa:null,b=l.wc,y=f<p?wt(l,c,u):null;e(t.C<o),e(p<=a);var w=!1;t:for(;;){for(;w||f<p;){var N=0;if(u>=m){var S=f-r;e((m=t).Pb),m.wd=m.m,m.xd=S,0<m.s.ua&&O(m.s.Wa,m.s.vb),m=u+ti}if(c&b||(y=wt(l,c,u)),e(null!=y),y.Qb&&(n[f]=y.qb,w=!0),!w)if(_(h),y.jc){N=h,S=n;var P=f,k=y.pd[L(N)&Tn-1];e(y.jc),256>k.g?(A(N,N.u+k.g),S[P]=k.value,N=0):(A(N,N.u+k.g-256),e(256<=k.value),N=k.value),0==N&&(w=!0)}else N=bt(y.G[0],y.H[0],h);if(h.h)break;if(w||256>N){if(!w)if(y.nd)n[f]=(y.qb|N<<8)>>>0;else{if(_(h),w=bt(y.G[1],y.H[1],h),_(h),S=bt(y.G[2],y.H[2],h),P=bt(y.G[3],y.H[3],h),h.h)break;n[f]=(P<<24|w<<16|N<<8|S)>>>0}if(w=!1,++f,++c>=i&&(c=0,++u,null!=s&&u<=o&&!(u%16)&&s(t,u),null!=v))for(;d<f;)N=n[d++],v.X[(506832829*N&4294967295)>>>v.Mb]=N}else if(280>N){if(N=mt(N-256,h),S=bt(y.G[4],y.H[4],h),_(h),S=vt(i,S=mt(S,h)),h.h)break;if(f-r<S||a-f<N)break t;for(P=0;P<N;++P)n[f+P]=n[f+P-S];for(f+=N,c+=N;c>=i;)c-=i,++u,null!=s&&u<=o&&!(u%16)&&s(t,u);if(e(f<=a),c&b&&(y=wt(l,c,u)),null!=v)for(;d<f;)N=n[d++],v.X[(506832829*N&4294967295)>>>v.Mb]=N}else{if(!(N<g))break t;for(w=N-280,e(null!=v);d<f;)N=n[d++],v.X[(506832829*N&4294967295)>>>v.Mb]=N;N=f,e(!(w>>>(S=v).Xa)),n[N]=S.X[w],w=!0}w||e(h.h==x(h))}if(t.Pb&&h.h&&f<a)e(t.m.h),t.a=5,t.m=t.wd,t.$=t.xd,0<t.s.ua&&O(t.s.vb,t.s.Wa);else{if(h.h)break t;null!=s&&s(t,u>o?o:u),t.a=0,t.$=f-r}return 1}return t.a=3,0}function Pt(t){e(null!=t),t.vc=null,t.yc=null,t.Ya=null;var n=t.Wa;null!=n&&(n.X=null),t.vb=null,e(null!=t)}function kt(){var e=new sn;return null==e?null:(e.a=0,e.xb=gi,nt(\"Predictor\",\"VP8LPredictors\"),nt(\"Predictor\",\"VP8LPredictors_C\"),nt(\"PredictorAdd\",\"VP8LPredictorsAdd\"),nt(\"PredictorAdd\",\"VP8LPredictorsAdd_C\"),Yn=G,Qn=J,tr=K,er=Z,nr=$,rr=Q,ir=tt,t.VP8LMapColor32b=Xn,t.VP8LMapColor8b=Zn,e)}function Ft(t,n,r,s,u){var c=1,f=[t],p=[n],g=s.m,m=s.s,v=null,b=0;t:for(;;){if(r)for(;c&&y(g,1);){var w=f,N=p,x=s,S=1,P=x.m,k=x.gc[x.ab],F=y(P,2);if(x.Oc&1<<F)c=0;else{switch(x.Oc|=1<<F,k.hc=F,k.Ea=w[0],k.nc=N[0],k.K=[null],++x.ab,e(4>=x.ab),F){case 0:case 1:k.b=y(P,3)+2,S=Ft(q(k.Ea,k.b),q(k.nc,k.b),0,x,k.K),k.K=k.K[0];break;case 3:var I,C=y(P,8)+1,j=16<C?0:4<C?1:2<C?2:3;if(w[0]=q(k.Ea,j),k.b=j,I=S=Ft(C,1,0,x,k.K)){var O,M=C,E=k,T=1<<(8>>E.b),D=a(T);if(null==D)I=0;else{var U=E.K[0],z=E.w;for(D[0]=E.K[0][0],O=1;O<1*M;++O)D[O]=R(U[z+O],D[O-1]);for(;O<4*T;++O)D[O]=0;E.K[0]=null,E.K[0]=D,I=1}}S=I;break;case 2:break;default:e(0)}c=S}}if(f=f[0],p=p[0],c&&y(g,1)&&!(c=1<=(b=y(g,4))&&11>=b)){s.a=3;break t}var H;if(H=c)e:{var W,V,G,Y=s,J=f,X=p,K=b,Z=r,$=Y.m,Q=Y.s,tt=[null],et=1,nt=0,rt=Qr[K];n:for(;;){if(Z&&y($,1)){var it=y($,3)+2,at=q(J,it),ot=q(X,it),st=at*ot;if(!Ft(at,ot,0,Y,tt))break n;for(tt=tt[0],Q.xc=it,W=0;W<st;++W){var ut=tt[W]>>8&65535;tt[W]=ut,ut>=et&&(et=ut+1)}}if($.h)break n;for(V=0;5>V;++V){var ct=Xr[V];!V&&0<K&&(ct+=1<<K),nt<ct&&(nt=ct)}var ht=o(et*rt,l),lt=et,ft=o(lt,d);if(null==ft)var dt=null;else e(65536>=lt),dt=ft;var pt=a(nt);if(null==dt||null==pt||null==ht){Y.a=1;break n}var gt=ht;for(W=G=0;W<et;++W){var mt=dt[W],vt=mt.G,bt=mt.H,wt=0,Nt=1,Lt=0;for(V=0;5>V;++V){ct=Xr[V],vt[V]=gt,bt[V]=G,!V&&0<K&&(ct+=1<<K);r:{var xt,At=ct,_t=Y,kt=pt,It=gt,Ct=G,jt=0,Bt=_t.m,Ot=y(Bt,1);if(i(kt,0,0,At),Ot){var Mt=y(Bt,1)+1,Et=y(Bt,1),qt=y(Bt,0==Et?1:8);kt[qt]=1,2==Mt&&(kt[qt=y(Bt,8)]=1);var Rt=1}else{var Tt=a(19),Dt=y(Bt,4)+4;if(19<Dt){_t.a=3;var Ut=0;break r}for(xt=0;xt<Dt;++xt)Tt[Zr[xt]]=y(Bt,3);var zt=void 0,Ht=void 0,Wt=_t,Vt=Tt,Gt=At,Yt=kt,Jt=0,Xt=Wt.m,Kt=8,Zt=o(128,l);i:for(;h(Zt,0,7,Vt,19);){if(y(Xt,1)){var $t=2+2*y(Xt,3);if((zt=2+y(Xt,$t))>Gt)break i}else zt=Gt;for(Ht=0;Ht<Gt&&zt--;){_(Xt);var Qt=Zt[0+(127&L(Xt))];A(Xt,Xt.u+Qt.g);var te=Qt.value;if(16>te)Yt[Ht++]=te,0!=te&&(Kt=te);else{var ee=16==te,ne=te-16,re=Jr[ne],ie=y(Xt,Yr[ne])+re;if(Ht+ie>Gt)break i;for(var ae=ee?Kt:0;0<ie--;)Yt[Ht++]=ae}}Jt=1;break i}Jt||(Wt.a=3),Rt=Jt}(Rt=Rt&&!Bt.h)&&(jt=h(It,Ct,8,kt,At)),Rt&&0!=jt?Ut=jt:(_t.a=3,Ut=0)}if(0==Ut)break n;if(Nt&&1==Kr[V]&&(Nt=0==gt[G].g),wt+=gt[G].g,G+=Ut,3>=V){var oe,se=pt[0];for(oe=1;oe<ct;++oe)pt[oe]>se&&(se=pt[oe]);Lt+=se}}if(mt.nd=Nt,mt.Qb=0,Nt&&(mt.qb=(vt[3][bt[3]+0].value<<24|vt[1][bt[1]+0].value<<16|vt[2][bt[2]+0].value)>>>0,0==wt&&256>vt[0][bt[0]+0].value&&(mt.Qb=1,mt.qb+=vt[0][bt[0]+0].value<<8)),mt.jc=!mt.Qb&&6>Lt,mt.jc){var ue,ce=mt;for(ue=0;ue<Tn;++ue){var he=ue,le=ce.pd[he],fe=ce.G[0][ce.H[0]+he];256<=fe.value?(le.g=fe.g+256,le.value=fe.value):(le.g=0,le.value=0,he>>=yt(fe,8,le),he>>=yt(ce.G[1][ce.H[1]+he],16,le),he>>=yt(ce.G[2][ce.H[2]+he],0,le),yt(ce.G[3][ce.H[3]+he],24,le))}}}Q.vc=tt,Q.Wb=et,Q.Ya=dt,Q.yc=ht,H=1;break e}H=0}if(!(c=H)){s.a=3;break t}if(0<b){if(m.ua=1<<b,!B(m.Wa,b)){s.a=1,c=0;break t}}else m.ua=0;var de=s,pe=f,ge=p,me=de.s,ve=me.xc;if(de.c=pe,de.i=ge,me.md=q(pe,ve),me.wc=0==ve?-1:(1<<ve)-1,r){s.xb=pi;break t}if(null==(v=a(f*p))){s.a=1,c=0;break t}c=(c=St(s,v,0,f,p,p,null))&&!g.h;break t}return c?(null!=u?u[0]=v:(e(null==v),e(r)),s.$=0,r||Pt(m)):Pt(m),c}function It(t,n){var r=t.c*t.i,i=r+n+16*n;return e(t.c<=n),t.V=a(i),null==t.V?(t.Ta=null,t.Ua=0,t.a=1,0):(t.Ta=t.V,t.Ua=t.Ba+r+n,1)}function Ct(t,n){var r=t.C,i=n-r,a=t.V,o=t.Ba+t.c*r;for(e(n<=t.l.o);0<i;){var s=16<i?16:i,u=t.l.ma,c=t.l.width,h=c*s,l=u.ca,f=u.tb+c*r,d=t.Ta,p=t.Ua;Nt(t,s,a,o),Sr(d,p,l,f,h),At(u,r,r+s,l,f,c),i-=s,a+=s*t.c,r+=s}e(r==n),t.C=t.Ma=n}function jt(){this.ub=this.yd=this.td=this.Rb=0}function Bt(){this.Kd=this.Ld=this.Ud=this.Td=this.i=this.c=0}function Ot(){this.Fb=this.Bb=this.Cb=0,this.Zb=a(4),this.Lb=a(4)}function Mt(){this.Yb=function(){var t=[];return function t(e,n,r){for(var i=r[n],a=0;a<i&&(e.push(r.length>n+1?[]:0),!(r.length<n+1));a++)t(e[a],n+1,r)}(t,0,[3,11]),t}()}function Et(){this.jb=a(3),this.Wc=s([4,8],Mt),this.Xc=s([4,17],Mt)}function qt(){this.Pc=this.wb=this.Tb=this.zd=0,this.vd=new a(4),this.od=new a(4)}function Rt(){this.ld=this.La=this.dd=this.tc=0}function Tt(){this.Na=this.la=0}function Dt(){this.Sc=[0,0],this.Eb=[0,0],this.Qc=[0,0],this.ia=this.lc=0}function Ut(){this.ad=a(384),this.Za=0,this.Ob=a(16),this.$b=this.Ad=this.ia=this.Gc=this.Hc=this.Dd=0}function zt(){this.uc=this.M=this.Nb=0,this.wa=Array(new Rt),this.Y=0,this.ya=Array(new Ut),this.aa=0,this.l=new Gt}function Ht(){this.y=a(16),this.f=a(8),this.ea=a(8)}function Wt(){this.cb=this.a=0,this.sc=\"\",this.m=new w,this.Od=new jt,this.Kc=new Bt,this.ed=new qt,this.Qa=new Ot,this.Ic=this.$c=this.Aa=0,this.D=new zt,this.Xb=this.Va=this.Hb=this.zb=this.yb=this.Ub=this.za=0,this.Jc=o(8,w),this.ia=0,this.pb=o(4,Dt),this.Pa=new Et,this.Bd=this.kc=0,this.Ac=[],this.Bc=0,this.zc=[0,0,0,0],this.Gd=Array(new Ht),this.Hd=0,this.rb=Array(new Tt),this.sb=0,this.wa=Array(new Rt),this.Y=0,this.oc=[],this.pc=0,this.sa=[],this.ta=0,this.qa=[],this.ra=0,this.Ha=[],this.B=this.R=this.Ia=0,this.Ec=[],this.M=this.ja=this.Vb=this.Fc=0,this.ya=Array(new Ut),this.L=this.aa=0,this.gd=s([4,2],Rt),this.ga=null,this.Fa=[],this.Cc=this.qc=this.P=0,this.Gb=[],this.Uc=0,this.mb=[],this.nb=0,this.rc=[],this.Ga=this.Vc=0}function Vt(t,e){return 0>t?0:t>e?e:t}function Gt(){this.T=this.U=this.ka=this.height=this.width=0,this.y=[],this.f=[],this.ea=[],this.Rc=this.fa=this.W=this.N=this.O=0,this.ma=\"void\",this.put=\"VP8IoPutHook\",this.ac=\"VP8IoSetupHook\",this.bc=\"VP8IoTeardownHook\",this.ha=this.Kb=0,this.data=[],this.hb=this.ib=this.da=this.o=this.j=this.va=this.v=this.Da=this.ob=this.w=0,this.F=[],this.J=0}function Yt(){var t=new Wt;return null!=t&&(t.a=0,t.sc=\"OK\",t.cb=0,t.Xb=0,ri||(ri=Zt)),t}function Jt(t,e,n){return 0==t.a&&(t.a=e,t.sc=n,t.cb=0),0}function Xt(t,e,n){return 3<=n&&157==t[e+0]&&1==t[e+1]&&42==t[e+2]}function Kt(t,n){if(null==t)return 0;if(t.a=0,t.sc=\"OK\",null==n)return Jt(t,2,\"null VP8Io passed to VP8GetHeaders()\");var r=n.data,a=n.w,o=n.ha;if(4>o)return Jt(t,7,\"Truncated header.\");var s=r[a+0]|r[a+1]<<8|r[a+2]<<16,u=t.Od;if(u.Rb=!(1&s),u.td=s>>1&7,u.yd=s>>4&1,u.ub=s>>5,3<u.td)return Jt(t,3,\"Incorrect keyframe parameters.\");if(!u.yd)return Jt(t,4,\"Frame not displayable.\");a+=3,o-=3;var c=t.Kc;if(u.Rb){if(7>o)return Jt(t,7,\"cannot parse picture header\");if(!Xt(r,a,o))return Jt(t,3,\"Bad code word\");c.c=16383&(r[a+4]<<8|r[a+3]),c.Td=r[a+4]>>6,c.i=16383&(r[a+6]<<8|r[a+5]),c.Ud=r[a+6]>>6,a+=7,o-=7,t.za=c.c+15>>4,t.Ub=c.i+15>>4,n.width=c.c,n.height=c.i,n.Da=0,n.j=0,n.v=0,n.va=n.width,n.o=n.height,n.da=0,n.ib=n.width,n.hb=n.height,n.U=n.width,n.T=n.height,i((s=t.Pa).jb,0,255,s.jb.length),e(null!=(s=t.Qa)),s.Cb=0,s.Bb=0,s.Fb=1,i(s.Zb,0,0,s.Zb.length),i(s.Lb,0,0,s.Lb)}if(u.ub>o)return Jt(t,7,\"bad partition length\");p(s=t.m,r,a,u.ub),a+=u.ub,o-=u.ub,u.Rb&&(c.Ld=P(s),c.Kd=P(s)),c=t.Qa;var h,l=t.Pa;if(e(null!=s),e(null!=c),c.Cb=P(s),c.Cb){if(c.Bb=P(s),P(s)){for(c.Fb=P(s),h=0;4>h;++h)c.Zb[h]=P(s)?m(s,7):0;for(h=0;4>h;++h)c.Lb[h]=P(s)?m(s,6):0}if(c.Bb)for(h=0;3>h;++h)l.jb[h]=P(s)?g(s,8):255}else c.Bb=0;if(s.Ka)return Jt(t,3,\"cannot parse segment header\");if((c=t.ed).zd=P(s),c.Tb=g(s,6),c.wb=g(s,3),c.Pc=P(s),c.Pc&&P(s)){for(l=0;4>l;++l)P(s)&&(c.vd[l]=m(s,6));for(l=0;4>l;++l)P(s)&&(c.od[l]=m(s,6))}if(t.L=0==c.Tb?0:c.zd?1:2,s.Ka)return Jt(t,3,\"cannot parse filter header\");var f=o;if(o=h=a,a=h+f,c=f,t.Xb=(1<<g(t.m,2))-1,f<3*(l=t.Xb))r=7;else{for(h+=3*l,c-=3*l,f=0;f<l;++f){var d=r[o+0]|r[o+1]<<8|r[o+2]<<16;d>c&&(d=c),p(t.Jc[+f],r,h,d),h+=d,c-=d,o+=3}p(t.Jc[+l],r,h,c),r=h<a?0:5}if(0!=r)return Jt(t,r,\"cannot parse partitions\");for(r=g(h=t.m,7),o=P(h)?m(h,4):0,a=P(h)?m(h,4):0,c=P(h)?m(h,4):0,l=P(h)?m(h,4):0,h=P(h)?m(h,4):0,f=t.Qa,d=0;4>d;++d){if(f.Cb){var v=f.Zb[d];f.Fb||(v+=r)}else{if(0<d){t.pb[d]=t.pb[0];continue}v=r}var b=t.pb[d];b.Sc[0]=ei[Vt(v+o,127)],b.Sc[1]=ni[Vt(v+0,127)],b.Eb[0]=2*ei[Vt(v+a,127)],b.Eb[1]=101581*ni[Vt(v+c,127)]>>16,8>b.Eb[1]&&(b.Eb[1]=8),b.Qc[0]=ei[Vt(v+l,117)],b.Qc[1]=ni[Vt(v+h,127)],b.lc=v+h}if(!u.Rb)return Jt(t,4,\"Not a key frame.\");for(P(s),u=t.Pa,r=0;4>r;++r){for(o=0;8>o;++o)for(a=0;3>a;++a)for(c=0;11>c;++c)l=k(s,ci[r][o][a][c])?g(s,8):si[r][o][a][c],u.Wc[r][o].Yb[a][c]=l;for(o=0;17>o;++o)u.Xc[r][o]=u.Wc[r][hi[o]]}return t.kc=P(s),t.kc&&(t.Bd=g(s,8)),t.cb=1}function Zt(t,e,n,r,i,a,o){var s=e[i].Yb[n];for(n=0;16>i;++i){if(!k(t,s[n+0]))return i;for(;!k(t,s[n+1]);)if(s=e[++i].Yb[0],n=0,16==i)return 16;var u=e[i+1].Yb;if(k(t,s[n+2])){var c=t,h=0;if(k(c,(f=s)[(l=n)+3]))if(k(c,f[l+6])){for(s=0,l=2*(h=k(c,f[l+8]))+(f=k(c,f[l+9+h])),h=0,f=ii[l];f[s];++s)h+=h+k(c,f[s]);h+=3+(8<<l)}else k(c,f[l+7])?(h=7+2*k(c,165),h+=k(c,145)):h=5+k(c,159);else h=k(c,f[l+4])?3+k(c,f[l+5]):2;s=u[2]}else h=1,s=u[1];u=o+ai[i],0>(c=t).b&&S(c);var l,f=c.b,d=(l=c.Ca>>1)-(c.I>>f)>>31;--c.b,c.Ca+=d,c.Ca|=1,c.I-=(l+1&d)<<f,a[u]=((h^d)-d)*r[(0<i)+0]}return 16}function $t(t){var e=t.rb[t.sb-1];e.la=0,e.Na=0,i(t.zc,0,0,t.zc.length),t.ja=0}function Qt(t,n){if(null==t)return 0;if(null==n)return Jt(t,2,\"NULL VP8Io parameter in VP8Decode().\");if(!t.cb&&!Kt(t,n))return 0;if(e(t.cb),null==n.ac||n.ac(n)){n.ob&&(t.L=0);var s=Ti[t.L];if(2==t.L?(t.yb=0,t.zb=0):(t.yb=n.v-s>>4,t.zb=n.j-s>>4,0>t.yb&&(t.yb=0),0>t.zb&&(t.zb=0)),t.Va=n.o+15+s>>4,t.Hb=n.va+15+s>>4,t.Hb>t.za&&(t.Hb=t.za),t.Va>t.Ub&&(t.Va=t.Ub),0<t.L){var u=t.ed;for(s=0;4>s;++s){var c;if(t.Qa.Cb){var h=t.Qa.Lb[s];t.Qa.Fb||(h+=u.Tb)}else h=u.Tb;for(c=0;1>=c;++c){var l=t.gd[s][c],f=h;if(u.Pc&&(f+=u.vd[0],c&&(f+=u.od[0])),0<(f=0>f?0:63<f?63:f)){var d=f;0<u.wb&&((d=4<u.wb?d>>2:d>>1)>9-u.wb&&(d=9-u.wb)),1>d&&(d=1),l.dd=d,l.tc=2*f+d,l.ld=40<=f?2:15<=f?1:0}else l.tc=0;l.La=c}}}s=0}else Jt(t,6,\"Frame setup failed\"),s=t.a;if(s=0==s){if(s){t.$c=0,0<t.Aa||(t.Ic=Ui);t:{s=t.Ic;u=4*(d=t.za);var p=32*d,g=d+1,m=0<t.L?d*(0<t.Aa?2:1):0,v=(2==t.Aa?2:1)*d;if((l=u+832+(c=3*(16*s+Ti[t.L])/2*p)+(h=null!=t.Fa&&0<t.Fa.length?t.Kc.c*t.Kc.i:0))!=l)s=0;else{if(l>t.Vb){if(t.Vb=0,t.Ec=a(l),t.Fc=0,null==t.Ec){s=Jt(t,1,\"no memory during frame initialization.\");break t}t.Vb=l}l=t.Ec,f=t.Fc,t.Ac=l,t.Bc=f,f+=u,t.Gd=o(p,Ht),t.Hd=0,t.rb=o(g+1,Tt),t.sb=1,t.wa=m?o(m,Rt):null,t.Y=0,t.D.Nb=0,t.D.wa=t.wa,t.D.Y=t.Y,0<t.Aa&&(t.D.Y+=d),e(!0),t.oc=l,t.pc=f,f+=832,t.ya=o(v,Ut),t.aa=0,t.D.ya=t.ya,t.D.aa=t.aa,2==t.Aa&&(t.D.aa+=d),t.R=16*d,t.B=8*d,d=(p=Ti[t.L])*t.R,p=p/2*t.B,t.sa=l,t.ta=f+d,t.qa=t.sa,t.ra=t.ta+16*s*t.R+p,t.Ha=t.qa,t.Ia=t.ra+8*s*t.B+p,t.$c=0,f+=c,t.mb=h?l:null,t.nb=h?f:null,e(f+h<=t.Fc+t.Vb),$t(t),i(t.Ac,t.Bc,0,u),s=1}}if(s){if(n.ka=0,n.y=t.sa,n.O=t.ta,n.f=t.qa,n.N=t.ra,n.ea=t.Ha,n.Vd=t.Ia,n.fa=t.R,n.Rc=t.B,n.F=null,n.J=0,!Cr){for(s=-255;255>=s;++s)Pr[255+s]=0>s?-s:s;for(s=-1020;1020>=s;++s)kr[1020+s]=-128>s?-128:127<s?127:s;for(s=-112;112>=s;++s)Fr[112+s]=-16>s?-16:15<s?15:s;for(s=-255;510>=s;++s)Ir[255+s]=0>s?0:255<s?255:s;Cr=1}ar=ce,or=ae,ur=oe,cr=se,hr=ue,sr=ie,lr=Je,fr=Xe,dr=$e,pr=Qe,gr=Ke,mr=Ze,vr=tn,br=en,yr=ze,wr=He,Nr=We,Lr=Ve,fi[0]=Ae,fi[1]=le,fi[2]=Le,fi[3]=xe,fi[4]=_e,fi[5]=Pe,fi[6]=Se,fi[7]=ke,fi[8]=Ie,fi[9]=Fe,li[0]=ve,li[1]=de,li[2]=pe,li[3]=ge,li[4]=be,li[5]=ye,li[6]=we,di[0]=Oe,di[1]=fe,di[2]=Ce,di[3]=je,di[4]=Ee,di[5]=Me,di[6]=qe,s=1}else s=0}s&&(s=function(t,n){for(t.M=0;t.M<t.Va;++t.M){var o,s=t.Jc[t.M&t.Xb],u=t.m,c=t;for(o=0;o<c.za;++o){var h=u,l=c,f=l.Ac,d=l.Bc+4*o,p=l.zc,g=l.ya[l.aa+o];if(l.Qa.Bb?g.$b=k(h,l.Pa.jb[0])?2+k(h,l.Pa.jb[2]):k(h,l.Pa.jb[1]):g.$b=0,l.kc&&(g.Ad=k(h,l.Bd)),g.Za=!k(h,145)+0,g.Za){var m=g.Ob,v=0;for(l=0;4>l;++l){var b,y=p[0+l];for(b=0;4>b;++b){y=ui[f[d+b]][y];for(var w=oi[k(h,y[0])];0<w;)w=oi[2*w+k(h,y[w])];y=-w,f[d+b]=y}r(m,v,f,d,4),v+=4,p[0+l]=y}}else y=k(h,156)?k(h,128)?1:3:k(h,163)?2:0,g.Ob[0]=y,i(f,d,y,4),i(p,0,y,4);g.Dd=k(h,142)?k(h,114)?k(h,183)?1:3:2:0}if(c.m.Ka)return Jt(t,7,\"Premature end-of-partition0 encountered.\");for(;t.ja<t.za;++t.ja){if(c=s,h=(u=t).rb[u.sb-1],f=u.rb[u.sb+u.ja],o=u.ya[u.aa+u.ja],d=u.kc?o.Ad:0)h.la=f.la=0,o.Za||(h.Na=f.Na=0),o.Hc=0,o.Gc=0,o.ia=0;else{var N,L;h=f,f=c,d=u.Pa.Xc,p=u.ya[u.aa+u.ja],g=u.pb[p.$b];if(l=p.ad,m=0,v=u.rb[u.sb-1],y=b=0,i(l,m,0,384),p.Za)var x=0,A=d[3];else{w=a(16);var _=h.Na+v.Na;if(_=ri(f,d[1],_,g.Eb,0,w,0),h.Na=v.Na=(0<_)+0,1<_)ar(w,0,l,m);else{var S=w[0]+3>>3;for(w=0;256>w;w+=16)l[m+w]=S}x=1,A=d[0]}var P=15&h.la,F=15&v.la;for(w=0;4>w;++w){var I=1&F;for(S=L=0;4>S;++S)P=P>>1|(I=(_=ri(f,A,_=I+(1&P),g.Sc,x,l,m))>x)<<7,L=L<<2|(3<_?3:1<_?2:0!=l[m+0]),m+=16;P>>=4,F=F>>1|I<<7,b=(b<<8|L)>>>0}for(A=P,x=F>>4,N=0;4>N;N+=2){for(L=0,P=h.la>>4+N,F=v.la>>4+N,w=0;2>w;++w){for(I=1&F,S=0;2>S;++S)_=I+(1&P),P=P>>1|(I=0<(_=ri(f,d[2],_,g.Qc,0,l,m)))<<3,L=L<<2|(3<_?3:1<_?2:0!=l[m+0]),m+=16;P>>=2,F=F>>1|I<<5}y|=L<<4*N,A|=P<<4<<N,x|=(240&F)<<N}h.la=A,v.la=x,p.Hc=b,p.Gc=y,p.ia=43690&y?0:g.ia,d=!(b|y)}if(0<u.L&&(u.wa[u.Y+u.ja]=u.gd[o.$b][o.Za],u.wa[u.Y+u.ja].La|=!d),c.Ka)return Jt(t,7,\"Premature end-of-file encountered.\")}if($t(t),u=n,c=1,o=(s=t).D,h=0<s.L&&s.M>=s.zb&&s.M<=s.Va,0==s.Aa)t:{if(o.M=s.M,o.uc=h,On(s,o),c=1,o=(L=s.D).Nb,h=(y=Ti[s.L])*s.R,f=y/2*s.B,w=16*o*s.R,S=8*o*s.B,d=s.sa,p=s.ta-h+w,g=s.qa,l=s.ra-f+S,m=s.Ha,v=s.Ia-f+S,F=0==(P=L.M),b=P>=s.Va-1,2==s.Aa&&On(s,L),L.uc)for(I=(_=s).D.M,e(_.D.uc),L=_.yb;L<_.Hb;++L){x=L,A=I;var C=(j=(U=_).D).Nb;N=U.R;var j=j.wa[j.Y+x],B=U.sa,O=U.ta+16*C*N+16*x,M=j.dd,E=j.tc;if(0!=E)if(e(3<=E),1==U.L)0<x&&wr(B,O,N,E+4),j.La&&Lr(B,O,N,E),0<A&&yr(B,O,N,E+4),j.La&&Nr(B,O,N,E);else{var q=U.B,R=U.qa,T=U.ra+8*C*q+8*x,D=U.Ha,U=U.Ia+8*C*q+8*x;C=j.ld;0<x&&(fr(B,O,N,E+4,M,C),pr(R,T,D,U,q,E+4,M,C)),j.La&&(mr(B,O,N,E,M,C),br(R,T,D,U,q,E,M,C)),0<A&&(lr(B,O,N,E+4,M,C),dr(R,T,D,U,q,E+4,M,C)),j.La&&(gr(B,O,N,E,M,C),vr(R,T,D,U,q,E,M,C))}}if(s.ia&&alert(\"todo:DitherRow\"),null!=u.put){if(L=16*P,P=16*(P+1),F?(u.y=s.sa,u.O=s.ta+w,u.f=s.qa,u.N=s.ra+S,u.ea=s.Ha,u.W=s.Ia+S):(L-=y,u.y=d,u.O=p,u.f=g,u.N=l,u.ea=m,u.W=v),b||(P-=y),P>u.o&&(P=u.o),u.F=null,u.J=null,null!=s.Fa&&0<s.Fa.length&&L<P&&(u.J=fn(s,u,L,P-L),u.F=s.mb,null==u.F&&0==u.F.length)){c=Jt(s,3,\"Could not decode alpha data.\");break t}L<u.j&&(y=u.j-L,L=u.j,e(!(1&y)),u.O+=s.R*y,u.N+=s.B*(y>>1),u.W+=s.B*(y>>1),null!=u.F&&(u.J+=u.width*y)),L<P&&(u.O+=u.v,u.N+=u.v>>1,u.W+=u.v>>1,null!=u.F&&(u.J+=u.v),u.ka=L-u.j,u.U=u.va-u.v,u.T=P-L,c=u.put(u))}o+1!=s.Ic||b||(r(s.sa,s.ta-h,d,p+16*s.R,h),r(s.qa,s.ra-f,g,l+8*s.B,f),r(s.Ha,s.Ia-f,m,v+8*s.B,f))}if(!c)return Jt(t,6,\"Output aborted.\")}return 1}(t,n)),null!=n.bc&&n.bc(n),s&=1}return s?(t.cb=0,s):0}function te(t,e,n,r,i){i=t[e+n+32*r]+(i>>3),t[e+n+32*r]=-256&i?0>i?0:255:i}function ee(t,e,n,r,i,a){te(t,e,0,n,r+i),te(t,e,1,n,r+a),te(t,e,2,n,r-a),te(t,e,3,n,r-i)}function ne(t){return(20091*t>>16)+t}function re(t,e,n,r){var i,o=0,s=a(16);for(i=0;4>i;++i){var u=t[e+0]+t[e+8],c=t[e+0]-t[e+8],h=(35468*t[e+4]>>16)-ne(t[e+12]),l=ne(t[e+4])+(35468*t[e+12]>>16);s[o+0]=u+l,s[o+1]=c+h,s[o+2]=c-h,s[o+3]=u-l,o+=4,e++}for(i=o=0;4>i;++i)u=(t=s[o+0]+4)+s[o+8],c=t-s[o+8],h=(35468*s[o+4]>>16)-ne(s[o+12]),te(n,r,0,0,u+(l=ne(s[o+4])+(35468*s[o+12]>>16))),te(n,r,1,0,c+h),te(n,r,2,0,c-h),te(n,r,3,0,u-l),o++,r+=32}function ie(t,e,n,r){var i=t[e+0]+4,a=35468*t[e+4]>>16,o=ne(t[e+4]),s=35468*t[e+1]>>16;ee(n,r,0,i+o,t=ne(t[e+1]),s),ee(n,r,1,i+a,t,s),ee(n,r,2,i-a,t,s),ee(n,r,3,i-o,t,s)}function ae(t,e,n,r,i){re(t,e,n,r),i&&re(t,e+16,n,r+4)}function oe(t,e,n,r){or(t,e+0,n,r,1),or(t,e+32,n,r+128,1)}function se(t,e,n,r){var i;for(t=t[e+0]+4,i=0;4>i;++i)for(e=0;4>e;++e)te(n,r,e,i,t)}function ue(t,e,n,r){t[e+0]&&cr(t,e+0,n,r),t[e+16]&&cr(t,e+16,n,r+4),t[e+32]&&cr(t,e+32,n,r+128),t[e+48]&&cr(t,e+48,n,r+128+4)}function ce(t,e,n,r){var i,o=a(16);for(i=0;4>i;++i){var s=t[e+0+i]+t[e+12+i],u=t[e+4+i]+t[e+8+i],c=t[e+4+i]-t[e+8+i],h=t[e+0+i]-t[e+12+i];o[0+i]=s+u,o[8+i]=s-u,o[4+i]=h+c,o[12+i]=h-c}for(i=0;4>i;++i)s=(t=o[0+4*i]+3)+o[3+4*i],u=o[1+4*i]+o[2+4*i],c=o[1+4*i]-o[2+4*i],h=t-o[3+4*i],n[r+0]=s+u>>3,n[r+16]=h+c>>3,n[r+32]=s-u>>3,n[r+48]=h-c>>3,r+=64}function he(t,e,n){var r,i=e-32,a=Or,o=255-t[i-1];for(r=0;r<n;++r){var s,u=a,c=o+t[e-1];for(s=0;s<n;++s)t[e+s]=u[c+t[i+s]];e+=32}}function le(t,e){he(t,e,4)}function fe(t,e){he(t,e,8)}function de(t,e){he(t,e,16)}function pe(t,e){var n;for(n=0;16>n;++n)r(t,e+32*n,t,e-32,16)}function ge(t,e){var n;for(n=16;0<n;--n)i(t,e,t[e-1],16),e+=32}function me(t,e,n){var r;for(r=0;16>r;++r)i(e,n+32*r,t,16)}function ve(t,e){var n,r=16;for(n=0;16>n;++n)r+=t[e-1+32*n]+t[e+n-32];me(r>>5,t,e)}function be(t,e){var n,r=8;for(n=0;16>n;++n)r+=t[e-1+32*n];me(r>>4,t,e)}function ye(t,e){var n,r=8;for(n=0;16>n;++n)r+=t[e+n-32];me(r>>4,t,e)}function we(t,e){me(128,t,e)}function Ne(t,e,n){return t+2*e+n+2>>2}function Le(t,e){var n,i=e-32;i=new Uint8Array([Ne(t[i-1],t[i+0],t[i+1]),Ne(t[i+0],t[i+1],t[i+2]),Ne(t[i+1],t[i+2],t[i+3]),Ne(t[i+2],t[i+3],t[i+4])]);for(n=0;4>n;++n)r(t,e+32*n,i,0,i.length)}function xe(t,e){var n=t[e-1],r=t[e-1+32],i=t[e-1+64],a=t[e-1+96];F(t,e+0,16843009*Ne(t[e-1-32],n,r)),F(t,e+32,16843009*Ne(n,r,i)),F(t,e+64,16843009*Ne(r,i,a)),F(t,e+96,16843009*Ne(i,a,a))}function Ae(t,e){var n,r=4;for(n=0;4>n;++n)r+=t[e+n-32]+t[e-1+32*n];for(r>>=3,n=0;4>n;++n)i(t,e+32*n,r,4)}function _e(t,e){var n=t[e-1+0],r=t[e-1+32],i=t[e-1+64],a=t[e-1-32],o=t[e+0-32],s=t[e+1-32],u=t[e+2-32],c=t[e+3-32];t[e+0+96]=Ne(r,i,t[e-1+96]),t[e+1+96]=t[e+0+64]=Ne(n,r,i),t[e+2+96]=t[e+1+64]=t[e+0+32]=Ne(a,n,r),t[e+3+96]=t[e+2+64]=t[e+1+32]=t[e+0+0]=Ne(o,a,n),t[e+3+64]=t[e+2+32]=t[e+1+0]=Ne(s,o,a),t[e+3+32]=t[e+2+0]=Ne(u,s,o),t[e+3+0]=Ne(c,u,s)}function Se(t,e){var n=t[e+1-32],r=t[e+2-32],i=t[e+3-32],a=t[e+4-32],o=t[e+5-32],s=t[e+6-32],u=t[e+7-32];t[e+0+0]=Ne(t[e+0-32],n,r),t[e+1+0]=t[e+0+32]=Ne(n,r,i),t[e+2+0]=t[e+1+32]=t[e+0+64]=Ne(r,i,a),t[e+3+0]=t[e+2+32]=t[e+1+64]=t[e+0+96]=Ne(i,a,o),t[e+3+32]=t[e+2+64]=t[e+1+96]=Ne(a,o,s),t[e+3+64]=t[e+2+96]=Ne(o,s,u),t[e+3+96]=Ne(s,u,u)}function Pe(t,e){var n=t[e-1+0],r=t[e-1+32],i=t[e-1+64],a=t[e-1-32],o=t[e+0-32],s=t[e+1-32],u=t[e+2-32],c=t[e+3-32];t[e+0+0]=t[e+1+64]=a+o+1>>1,t[e+1+0]=t[e+2+64]=o+s+1>>1,t[e+2+0]=t[e+3+64]=s+u+1>>1,t[e+3+0]=u+c+1>>1,t[e+0+96]=Ne(i,r,n),t[e+0+64]=Ne(r,n,a),t[e+0+32]=t[e+1+96]=Ne(n,a,o),t[e+1+32]=t[e+2+96]=Ne(a,o,s),t[e+2+32]=t[e+3+96]=Ne(o,s,u),t[e+3+32]=Ne(s,u,c)}function ke(t,e){var n=t[e+0-32],r=t[e+1-32],i=t[e+2-32],a=t[e+3-32],o=t[e+4-32],s=t[e+5-32],u=t[e+6-32],c=t[e+7-32];t[e+0+0]=n+r+1>>1,t[e+1+0]=t[e+0+64]=r+i+1>>1,t[e+2+0]=t[e+1+64]=i+a+1>>1,t[e+3+0]=t[e+2+64]=a+o+1>>1,t[e+0+32]=Ne(n,r,i),t[e+1+32]=t[e+0+96]=Ne(r,i,a),t[e+2+32]=t[e+1+96]=Ne(i,a,o),t[e+3+32]=t[e+2+96]=Ne(a,o,s),t[e+3+64]=Ne(o,s,u),t[e+3+96]=Ne(s,u,c)}function Fe(t,e){var n=t[e-1+0],r=t[e-1+32],i=t[e-1+64],a=t[e-1+96];t[e+0+0]=n+r+1>>1,t[e+2+0]=t[e+0+32]=r+i+1>>1,t[e+2+32]=t[e+0+64]=i+a+1>>1,t[e+1+0]=Ne(n,r,i),t[e+3+0]=t[e+1+32]=Ne(r,i,a),t[e+3+32]=t[e+1+64]=Ne(i,a,a),t[e+3+64]=t[e+2+64]=t[e+0+96]=t[e+1+96]=t[e+2+96]=t[e+3+96]=a}function Ie(t,e){var n=t[e-1+0],r=t[e-1+32],i=t[e-1+64],a=t[e-1+96],o=t[e-1-32],s=t[e+0-32],u=t[e+1-32],c=t[e+2-32];t[e+0+0]=t[e+2+32]=n+o+1>>1,t[e+0+32]=t[e+2+64]=r+n+1>>1,t[e+0+64]=t[e+2+96]=i+r+1>>1,t[e+0+96]=a+i+1>>1,t[e+3+0]=Ne(s,u,c),t[e+2+0]=Ne(o,s,u),t[e+1+0]=t[e+3+32]=Ne(n,o,s),t[e+1+32]=t[e+3+64]=Ne(r,n,o),t[e+1+64]=t[e+3+96]=Ne(i,r,n),t[e+1+96]=Ne(a,i,r)}function Ce(t,e){var n;for(n=0;8>n;++n)r(t,e+32*n,t,e-32,8)}function je(t,e){var n;for(n=0;8>n;++n)i(t,e,t[e-1],8),e+=32}function Be(t,e,n){var r;for(r=0;8>r;++r)i(e,n+32*r,t,8)}function Oe(t,e){var n,r=8;for(n=0;8>n;++n)r+=t[e+n-32]+t[e-1+32*n];Be(r>>4,t,e)}function Me(t,e){var n,r=4;for(n=0;8>n;++n)r+=t[e+n-32];Be(r>>3,t,e)}function Ee(t,e){var n,r=4;for(n=0;8>n;++n)r+=t[e-1+32*n];Be(r>>3,t,e)}function qe(t,e){Be(128,t,e)}function Re(t,e,n){var r=t[e-n],i=t[e+0],a=3*(i-r)+jr[1020+t[e-2*n]-t[e+n]],o=Br[112+(a+4>>3)];t[e-n]=Or[255+r+Br[112+(a+3>>3)]],t[e+0]=Or[255+i-o]}function Te(t,e,n,r){var i=t[e+0],a=t[e+n];return Mr[255+t[e-2*n]-t[e-n]]>r||Mr[255+a-i]>r}function De(t,e,n,r){return 4*Mr[255+t[e-n]-t[e+0]]+Mr[255+t[e-2*n]-t[e+n]]<=r}function Ue(t,e,n,r,i){var a=t[e-3*n],o=t[e-2*n],s=t[e-n],u=t[e+0],c=t[e+n],h=t[e+2*n],l=t[e+3*n];return 4*Mr[255+s-u]+Mr[255+o-c]>r?0:Mr[255+t[e-4*n]-a]<=i&&Mr[255+a-o]<=i&&Mr[255+o-s]<=i&&Mr[255+l-h]<=i&&Mr[255+h-c]<=i&&Mr[255+c-u]<=i}function ze(t,e,n,r){var i=2*r+1;for(r=0;16>r;++r)De(t,e+r,n,i)&&Re(t,e+r,n)}function He(t,e,n,r){var i=2*r+1;for(r=0;16>r;++r)De(t,e+r*n,1,i)&&Re(t,e+r*n,1)}function We(t,e,n,r){var i;for(i=3;0<i;--i)ze(t,e+=4*n,n,r)}function Ve(t,e,n,r){var i;for(i=3;0<i;--i)He(t,e+=4,n,r)}function Ge(t,e,n,r,i,a,o,s){for(a=2*a+1;0<i--;){if(Ue(t,e,n,a,o))if(Te(t,e,n,s))Re(t,e,n);else{var u=t,c=e,h=n,l=u[c-2*h],f=u[c-h],d=u[c+0],p=u[c+h],g=u[c+2*h],m=27*(b=jr[1020+3*(d-f)+jr[1020+l-p]])+63>>7,v=18*b+63>>7,b=9*b+63>>7;u[c-3*h]=Or[255+u[c-3*h]+b],u[c-2*h]=Or[255+l+v],u[c-h]=Or[255+f+m],u[c+0]=Or[255+d-m],u[c+h]=Or[255+p-v],u[c+2*h]=Or[255+g-b]}e+=r}}function Ye(t,e,n,r,i,a,o,s){for(a=2*a+1;0<i--;){if(Ue(t,e,n,a,o))if(Te(t,e,n,s))Re(t,e,n);else{var u=t,c=e,h=n,l=u[c-h],f=u[c+0],d=u[c+h],p=Br[112+((g=3*(f-l))+4>>3)],g=Br[112+(g+3>>3)],m=p+1>>1;u[c-2*h]=Or[255+u[c-2*h]+m],u[c-h]=Or[255+l+g],u[c+0]=Or[255+f-p],u[c+h]=Or[255+d-m]}e+=r}}function Je(t,e,n,r,i,a){Ge(t,e,n,1,16,r,i,a)}function Xe(t,e,n,r,i,a){Ge(t,e,1,n,16,r,i,a)}function Ke(t,e,n,r,i,a){var o;for(o=3;0<o;--o)Ye(t,e+=4*n,n,1,16,r,i,a)}function Ze(t,e,n,r,i,a){var o;for(o=3;0<o;--o)Ye(t,e+=4,1,n,16,r,i,a)}function $e(t,e,n,r,i,a,o,s){Ge(t,e,i,1,8,a,o,s),Ge(n,r,i,1,8,a,o,s)}function Qe(t,e,n,r,i,a,o,s){Ge(t,e,1,i,8,a,o,s),Ge(n,r,1,i,8,a,o,s)}function tn(t,e,n,r,i,a,o,s){Ye(t,e+4*i,i,1,8,a,o,s),Ye(n,r+4*i,i,1,8,a,o,s)}function en(t,e,n,r,i,a,o,s){Ye(t,e+4,1,i,8,a,o,s),Ye(n,r+4,1,i,8,a,o,s)}function nn(){this.ba=new ot,this.ec=[],this.cc=[],this.Mc=[],this.Dc=this.Nc=this.dc=this.fc=0,this.Oa=new ut,this.memory=0,this.Ib=\"OutputFunc\",this.Jb=\"OutputAlphaFunc\",this.Nd=\"OutputRowFunc\"}function rn(){this.data=[],this.offset=this.kd=this.ha=this.w=0,this.na=[],this.xa=this.gb=this.Ja=this.Sa=this.P=0}function an(){this.nc=this.Ea=this.b=this.hc=0,this.K=[],this.w=0}function on(){this.ua=0,this.Wa=new M,this.vb=new M,this.md=this.xc=this.wc=0,this.vc=[],this.Wb=0,this.Ya=new d,this.yc=new l}function sn(){this.xb=this.a=0,this.l=new Gt,this.ca=new ot,this.V=[],this.Ba=0,this.Ta=[],this.Ua=0,this.m=new N,this.Pb=0,this.wd=new N,this.Ma=this.$=this.C=this.i=this.c=this.xd=0,this.s=new on,this.ab=0,this.gc=o(4,an),this.Oc=0}function un(){this.Lc=this.Z=this.$a=this.i=this.c=0,this.l=new Gt,this.ic=0,this.ca=[],this.tb=0,this.qd=null,this.rd=0}function cn(t,e,n,r,i,a,o){for(t=null==t?0:t[e+0],e=0;e<o;++e)i[a+e]=t+n[r+e]&255,t=i[a+e]}function hn(t,e,n,r,i,a,o){var s;if(null==t)cn(null,null,n,r,i,a,o);else for(s=0;s<o;++s)i[a+s]=t[e+s]+n[r+s]&255}function ln(t,e,n,r,i,a,o){if(null==t)cn(null,null,n,r,i,a,o);else{var s,u=t[e+0],c=u,h=u;for(s=0;s<o;++s)c=h+(u=t[e+s])-c,h=n[r+s]+(-256&c?0>c?0:255:c)&255,c=u,i[a+s]=h}}function fn(t,n,i,o){var s=n.width,u=n.o;if(e(null!=t&&null!=n),0>i||0>=o||i+o>u)return null;if(!t.Cc){if(null==t.ga){var c;if(t.ga=new un,(c=null==t.ga)||(c=n.width*n.o,e(0==t.Gb.length),t.Gb=a(c),t.Uc=0,null==t.Gb?c=0:(t.mb=t.Gb,t.nb=t.Uc,t.rc=null,c=1),c=!c),!c){c=t.ga;var h=t.Fa,l=t.P,f=t.qc,d=t.mb,p=t.nb,g=l+1,m=f-1,b=c.l;if(e(null!=h&&null!=d&&null!=n),mi[0]=null,mi[1]=cn,mi[2]=hn,mi[3]=ln,c.ca=d,c.tb=p,c.c=n.width,c.i=n.height,e(0<c.c&&0<c.i),1>=f)n=0;else if(c.$a=h[l+0]>>0&3,c.Z=h[l+0]>>2&3,c.Lc=h[l+0]>>4&3,l=h[l+0]>>6&3,0>c.$a||1<c.$a||4<=c.Z||1<c.Lc||l)n=0;else if(b.put=dt,b.ac=ft,b.bc=pt,b.ma=c,b.width=n.width,b.height=n.height,b.Da=n.Da,b.v=n.v,b.va=n.va,b.j=n.j,b.o=n.o,c.$a)t:{e(1==c.$a),n=kt();e:for(;;){if(null==n){n=0;break t}if(e(null!=c),c.mc=n,n.c=c.c,n.i=c.i,n.l=c.l,n.l.ma=c,n.l.width=c.c,n.l.height=c.i,n.a=0,v(n.m,h,g,m),!Ft(c.c,c.i,1,n,null))break e;if(1==n.ab&&3==n.gc[0].hc&&xt(n.s)?(c.ic=1,h=n.c*n.i,n.Ta=null,n.Ua=0,n.V=a(h),n.Ba=0,null==n.V?(n.a=1,n=0):n=1):(c.ic=0,n=It(n,c.c)),!n)break e;n=1;break t}c.mc=null,n=0}else n=m>=c.c*c.i;c=!n}if(c)return null;1!=t.ga.Lc?t.Ga=0:o=u-i}e(null!=t.ga),e(i+o<=u);t:{if(n=(h=t.ga).c,u=h.l.o,0==h.$a){if(g=t.rc,m=t.Vc,b=t.Fa,l=t.P+1+i*n,f=t.mb,d=t.nb+i*n,e(l<=t.P+t.qc),0!=h.Z)for(e(null!=mi[h.Z]),c=0;c<o;++c)mi[h.Z](g,m,b,l,f,d,n),g=f,m=d,d+=n,l+=n;else for(c=0;c<o;++c)r(f,d,b,l,n),g=f,m=d,d+=n,l+=n;t.rc=g,t.Vc=m}else{if(e(null!=h.mc),n=i+o,e(null!=(c=h.mc)),e(n<=c.i),c.C>=n)n=1;else if(h.ic||vn(),h.ic){h=c.V,g=c.Ba,m=c.c;var y=c.i,w=(b=1,l=c.$/m,f=c.$%m,d=c.m,p=c.s,c.$),N=m*y,L=m*n,A=p.wc,S=w<L?wt(p,f,l):null;e(w<=N),e(n<=y),e(xt(p));e:for(;;){for(;!d.h&&w<L;){if(f&A||(S=wt(p,f,l)),e(null!=S),_(d),256>(y=bt(S.G[0],S.H[0],d)))h[g+w]=y,++w,++f>=m&&(f=0,++l<=n&&!(l%16)&&_t(c,l));else{if(!(280>y)){b=0;break e}y=mt(y-256,d);var P,k=bt(S.G[4],S.H[4],d);if(_(d),!(w>=(k=vt(m,k=mt(k,d)))&&N-w>=y)){b=0;break e}for(P=0;P<y;++P)h[g+w+P]=h[g+w+P-k];for(w+=y,f+=y;f>=m;)f-=m,++l<=n&&!(l%16)&&_t(c,l);w<L&&f&A&&(S=wt(p,f,l))}e(d.h==x(d))}_t(c,l>n?n:l);break e}!b||d.h&&w<N?(b=0,c.a=d.h?5:3):c.$=w,n=b}else n=St(c,c.V,c.Ba,c.c,c.i,n,Ct);if(!n){o=0;break t}}i+o>=u&&(t.Cc=1),o=1}if(!o)return null;if(t.Cc&&(null!=(o=t.ga)&&(o.mc=null),t.ga=null,0<t.Ga))return alert(\"todo:WebPDequantizeLevels\"),null}return t.nb+i*s}function dn(t,e,n,r,i,a){for(;0<i--;){var o,s=t,u=e+(n?1:0),c=t,h=e+(n?0:3);for(o=0;o<r;++o){var l=c[h+4*o];255!=l&&(l*=32897,s[u+4*o+0]=s[u+4*o+0]*l>>23,s[u+4*o+1]=s[u+4*o+1]*l>>23,s[u+4*o+2]=s[u+4*o+2]*l>>23)}e+=a}}function pn(t,e,n,r,i){for(;0<r--;){var a;for(a=0;a<n;++a){var o=t[e+2*a+0],s=15&(c=t[e+2*a+1]),u=4369*s,c=(240&c|c>>4)*u>>16;t[e+2*a+0]=(240&o|o>>4)*u>>16&240|(15&o|o<<4)*u>>16>>4&15,t[e+2*a+1]=240&c|s}e+=i}}function gn(t,e,n,r,i,a,o,s){var u,c,h=255;for(c=0;c<i;++c){for(u=0;u<r;++u){var l=t[e+u];a[o+4*u]=l,h&=l}e+=n,o+=s}return 255!=h}function mn(t,e,n,r,i){var a;for(a=0;a<i;++a)n[r+a]=t[e+a]>>8}function vn(){xr=dn,Ar=pn,_r=gn,Sr=mn}function bn(n,r,i){t[n]=function(t,n,a,o,s,u,c,h,l,f,d,p,g,m,v,b,y){var w,N=y-1>>1,L=s[u+0]|c[h+0]<<16,x=l[f+0]|d[p+0]<<16;e(null!=t);var A=3*L+x+131074>>2;for(r(t[n+0],255&A,A>>16,g,m),null!=a&&(A=3*x+L+131074>>2,r(a[o+0],255&A,A>>16,v,b)),w=1;w<=N;++w){var _=s[u+w]|c[h+w]<<16,S=l[f+w]|d[p+w]<<16,P=L+_+x+S+524296,k=P+2*(_+x)>>3;A=k+L>>1,L=(P=P+2*(L+S)>>3)+_>>1,r(t[n+2*w-1],255&A,A>>16,g,m+(2*w-1)*i),r(t[n+2*w-0],255&L,L>>16,g,m+(2*w-0)*i),null!=a&&(A=P+x>>1,L=k+S>>1,r(a[o+2*w-1],255&A,A>>16,v,b+(2*w-1)*i),r(a[o+2*w+0],255&L,L>>16,v,b+(2*w+0)*i)),L=_,x=S}1&y||(A=3*L+x+131074>>2,r(t[n+y-1],255&A,A>>16,g,m+(y-1)*i),null!=a&&(A=3*x+L+131074>>2,r(a[o+y-1],255&A,A>>16,v,b+(y-1)*i)))}}function yn(){vi[Er]=bi,vi[qr]=wi,vi[Rr]=yi,vi[Tr]=Ni,vi[Dr]=Li,vi[Ur]=xi,vi[zr]=Ai,vi[Hr]=wi,vi[Wr]=Ni,vi[Vr]=Li,vi[Gr]=xi}function wn(t){return t&~Ii?0>t?0:255:t>>Fi}function Nn(t,e){return wn((19077*t>>8)+(26149*e>>8)-14234)}function Ln(t,e,n){return wn((19077*t>>8)-(6419*e>>8)-(13320*n>>8)+8708)}function xn(t,e){return wn((19077*t>>8)+(33050*e>>8)-17685)}function An(t,e,n,r,i){r[i+0]=Nn(t,n),r[i+1]=Ln(t,e,n),r[i+2]=xn(t,e)}function _n(t,e,n,r,i){r[i+0]=xn(t,e),r[i+1]=Ln(t,e,n),r[i+2]=Nn(t,n)}function Sn(t,e,n,r,i){var a=Ln(t,e,n);e=a<<3&224|xn(t,e)>>3,r[i+0]=248&Nn(t,n)|a>>5,r[i+1]=e}function Pn(t,e,n,r,i){var a=240&xn(t,e)|15;r[i+0]=240&Nn(t,n)|Ln(t,e,n)>>4,r[i+1]=a}function kn(t,e,n,r,i){r[i+0]=255,An(t,e,n,r,i+1)}function Fn(t,e,n,r,i){_n(t,e,n,r,i),r[i+3]=255}function In(t,e,n,r,i){An(t,e,n,r,i),r[i+3]=255}function Vt(t,e){return 0>t?0:t>e?e:t}function Cn(e,n,r){t[e]=function(t,e,i,a,o,s,u,c,h){for(var l=c+(-2&h)*r;c!=l;)n(t[e+0],i[a+0],o[s+0],u,c),n(t[e+1],i[a+0],o[s+0],u,c+r),e+=2,++a,++s,c+=2*r;1&h&&n(t[e+0],i[a+0],o[s+0],u,c)}}function jn(t,e,n){return 0==n?0==t?0==e?6:5:0==e?4:0:n}function Bn(t,e,n,r,i){switch(t>>>30){case 3:or(e,n,r,i,0);break;case 2:sr(e,n,r,i);break;case 1:cr(e,n,r,i)}}function On(t,e){var n,a,o=e.M,s=e.Nb,u=t.oc,c=t.pc+40,h=t.oc,l=t.pc+584,f=t.oc,d=t.pc+600;for(n=0;16>n;++n)u[c+32*n-1]=129;for(n=0;8>n;++n)h[l+32*n-1]=129,f[d+32*n-1]=129;for(0<o?u[c-1-32]=h[l-1-32]=f[d-1-32]=129:(i(u,c-32-1,127,21),i(h,l-32-1,127,9),i(f,d-32-1,127,9)),a=0;a<t.za;++a){var p=e.ya[e.aa+a];if(0<a){for(n=-1;16>n;++n)r(u,c+32*n-4,u,c+32*n+12,4);for(n=-1;8>n;++n)r(h,l+32*n-4,h,l+32*n+4,4),r(f,d+32*n-4,f,d+32*n+4,4)}var g=t.Gd,m=t.Hd+a,v=p.ad,b=p.Hc;if(0<o&&(r(u,c-32,g[m].y,0,16),r(h,l-32,g[m].f,0,8),r(f,d-32,g[m].ea,0,8)),p.Za){var y=u,w=c-32+16;for(0<o&&(a>=t.za-1?i(y,w,g[m].y[15],4):r(y,w,g[m+1].y,0,4)),n=0;4>n;n++)y[w+128+n]=y[w+256+n]=y[w+384+n]=y[w+0+n];for(n=0;16>n;++n,b<<=2)y=u,w=c+Ri[n],fi[p.Ob[n]](y,w),Bn(b,v,16*+n,y,w)}else if(y=jn(a,o,p.Ob[0]),li[y](u,c),0!=b)for(n=0;16>n;++n,b<<=2)Bn(b,v,16*+n,u,c+Ri[n]);for(n=p.Gc,y=jn(a,o,p.Dd),di[y](h,l),di[y](f,d),b=v,y=h,w=l,255&(p=n>>0)&&(170&p?ur(b,256,y,w):hr(b,256,y,w)),p=f,b=d,255&(n>>=8)&&(170&n?ur(v,320,p,b):hr(v,320,p,b)),o<t.Ub-1&&(r(g[m].y,0,u,c+480,16),r(g[m].f,0,h,l+224,8),r(g[m].ea,0,f,d+224,8)),n=8*s*t.B,g=t.sa,m=t.ta+16*a+16*s*t.R,v=t.qa,p=t.ra+8*a+n,b=t.Ha,y=t.Ia+8*a+n,n=0;16>n;++n)r(g,m+n*t.R,u,c+32*n,16);for(n=0;8>n;++n)r(v,p+n*t.B,h,l+32*n,8),r(b,y+n*t.B,f,d+32*n,8)}}function Mn(t,r,i,a,o,s,u,c,h){var l=[0],f=[0],d=0,p=null!=h?h.kd:0,g=null!=h?h:new rn;if(null==t||12>i)return 7;g.data=t,g.w=r,g.ha=i,r=[r],i=[i],g.gb=[g.gb];t:{var m=r,b=i,y=g.gb;if(e(null!=t),e(null!=b),e(null!=y),y[0]=0,12<=b[0]&&!n(t,m[0],\"RIFF\")){if(n(t,m[0]+8,\"WEBP\")){y=3;break t}var w=j(t,m[0]+4);if(12>w||4294967286<w){y=3;break t}if(p&&w>b[0]-8){y=7;break t}y[0]=w,m[0]+=12,b[0]-=12}y=0}if(0!=y)return y;for(w=0<g.gb[0],i=i[0];;){t:{var L=t;b=r,y=i;var x=l,A=f,_=m=[0];if((k=d=[d])[0]=0,8>y[0])y=7;else{if(!n(L,b[0],\"VP8X\")){if(10!=j(L,b[0]+4)){y=3;break t}if(18>y[0]){y=7;break t}var S=j(L,b[0]+8),P=1+C(L,b[0]+12);if(2147483648<=P*(L=1+C(L,b[0]+15))){y=3;break t}null!=_&&(_[0]=S),null!=x&&(x[0]=P),null!=A&&(A[0]=L),b[0]+=18,y[0]-=18,k[0]=1}y=0}}if(d=d[0],m=m[0],0!=y)return y;if(b=!!(2&m),!w&&d)return 3;if(null!=s&&(s[0]=!!(16&m)),null!=u&&(u[0]=b),null!=c&&(c[0]=0),u=l[0],m=f[0],d&&b&&null==h){y=0;break}if(4>i){y=7;break}if(w&&d||!w&&!d&&!n(t,r[0],\"ALPH\")){i=[i],g.na=[g.na],g.P=[g.P],g.Sa=[g.Sa];t:{S=t,y=r,w=i;var k=g.gb;x=g.na,A=g.P,_=g.Sa;P=22,e(null!=S),e(null!=w),L=y[0];var F=w[0];for(e(null!=x),e(null!=_),x[0]=null,A[0]=null,_[0]=0;;){if(y[0]=L,w[0]=F,8>F){y=7;break t}var I=j(S,L+4);if(4294967286<I){y=3;break t}var B=8+I+1&-2;if(P+=B,0<k&&P>k){y=3;break t}if(!n(S,L,\"VP8 \")||!n(S,L,\"VP8L\")){y=0;break t}if(F[0]<B){y=7;break t}n(S,L,\"ALPH\")||(x[0]=S,A[0]=L+8,_[0]=I),L+=B,F-=B}}if(i=i[0],g.na=g.na[0],g.P=g.P[0],g.Sa=g.Sa[0],0!=y)break}i=[i],g.Ja=[g.Ja],g.xa=[g.xa];t:if(k=t,y=r,w=i,x=g.gb[0],A=g.Ja,_=g.xa,S=y[0],L=!n(k,S,\"VP8 \"),P=!n(k,S,\"VP8L\"),e(null!=k),e(null!=w),e(null!=A),e(null!=_),8>w[0])y=7;else{if(L||P){if(k=j(k,S+4),12<=x&&k>x-12){y=3;break t}if(p&&k>w[0]-8){y=7;break t}A[0]=k,y[0]+=8,w[0]-=8,_[0]=P}else _[0]=5<=w[0]&&47==k[S+0]&&!(k[S+4]>>5),A[0]=w[0];y=0}if(i=i[0],g.Ja=g.Ja[0],g.xa=g.xa[0],r=r[0],0!=y)break;if(4294967286<g.Ja)return 3;if(null==c||b||(c[0]=g.xa?2:1),u=[u],m=[m],g.xa){if(5>i){y=7;break}c=u,p=m,b=s,null==t||5>i?t=0:5<=i&&47==t[r+0]&&!(t[r+4]>>5)?(w=[0],k=[0],x=[0],v(A=new N,t,r,i),gt(A,w,k,x)?(null!=c&&(c[0]=w[0]),null!=p&&(p[0]=k[0]),null!=b&&(b[0]=x[0]),t=1):t=0):t=0}else{if(10>i){y=7;break}c=m,null==t||10>i||!Xt(t,r+3,i-3)?t=0:(p=t[r+0]|t[r+1]<<8|t[r+2]<<16,b=16383&(t[r+7]<<8|t[r+6]),t=16383&(t[r+9]<<8|t[r+8]),1&p||3<(p>>1&7)||!(p>>4&1)||p>>5>=g.Ja||!b||!t?t=0:(u&&(u[0]=b),c&&(c[0]=t),t=1))}if(!t)return 3;if(u=u[0],m=m[0],d&&(l[0]!=u||f[0]!=m))return 3;null!=h&&(h[0]=g,h.offset=r-h.w,e(4294967286>r-h.w),e(h.offset==h.ha-i));break}return 0==y||7==y&&d&&null==h?(null!=s&&(s[0]|=null!=g.na&&0<g.na.length),null!=a&&(a[0]=u),null!=o&&(o[0]=m),0):y}function En(t,e,n){var r=e.width,i=e.height,a=0,o=0,s=r,u=i;if(e.Da=null!=t&&0<t.Da,e.Da&&(s=t.cd,u=t.bd,a=t.v,o=t.j,11>n||(a&=-2,o&=-2),0>a||0>o||0>=s||0>=u||a+s>r||o+u>i))return 0;if(e.v=a,e.j=o,e.va=a+s,e.o=o+u,e.U=s,e.T=u,e.da=null!=t&&0<t.da,e.da){if(!E(s,u,n=[t.ib],a=[t.hb]))return 0;e.ib=n[0],e.hb=a[0]}return e.ob=null!=t&&t.ob,e.Kb=null==t||!t.Sd,e.da&&(e.ob=e.ib<3*r/4&&e.hb<3*i/4,e.Kb=0),1}function qn(t){if(null==t)return 2;if(11>t.S){var e=t.f.RGBA;e.fb+=(t.height-1)*e.A,e.A=-e.A}else e=t.f.kb,t=t.height,e.O+=(t-1)*e.fa,e.fa=-e.fa,e.N+=(t-1>>1)*e.Ab,e.Ab=-e.Ab,e.W+=(t-1>>1)*e.Db,e.Db=-e.Db,null!=e.F&&(e.J+=(t-1)*e.lb,e.lb=-e.lb);return 0}function Rn(t,e,n,r){if(null==r||0>=t||0>=e)return 2;if(null!=n){if(n.Da){var i=n.cd,o=n.bd,s=-2&n.v,u=-2&n.j;if(0>s||0>u||0>=i||0>=o||s+i>t||u+o>e)return 2;t=i,e=o}if(n.da){if(!E(t,e,i=[n.ib],o=[n.hb]))return 2;t=i[0],e=o[0]}}r.width=t,r.height=e;t:{var c=r.width,h=r.height;if(t=r.S,0>=c||0>=h||!(t>=Er&&13>t))t=2;else{if(0>=r.Rd&&null==r.sd){s=o=i=e=0;var l=(u=c*zi[t])*h;if(11>t||(o=(h+1)/2*(e=(c+1)/2),12==t&&(s=(i=c)*h)),null==(h=a(l+2*o+s))){t=1;break t}r.sd=h,11>t?((c=r.f.RGBA).eb=h,c.fb=0,c.A=u,c.size=l):((c=r.f.kb).y=h,c.O=0,c.fa=u,c.Fd=l,c.f=h,c.N=0+l,c.Ab=e,c.Cd=o,c.ea=h,c.W=0+l+o,c.Db=e,c.Ed=o,12==t&&(c.F=h,c.J=0+l+2*o),c.Tc=s,c.lb=i)}if(e=1,i=r.S,o=r.width,s=r.height,i>=Er&&13>i)if(11>i)t=r.f.RGBA,e&=(u=Math.abs(t.A))*(s-1)+o<=t.size,e&=u>=o*zi[i],e&=null!=t.eb;else{t=r.f.kb,u=(o+1)/2,l=(s+1)/2,c=Math.abs(t.fa);h=Math.abs(t.Ab);var f=Math.abs(t.Db),d=Math.abs(t.lb),p=d*(s-1)+o;e&=c*(s-1)+o<=t.Fd,e&=h*(l-1)+u<=t.Cd,e=(e&=f*(l-1)+u<=t.Ed)&c>=o&h>=u&f>=u,e&=null!=t.y,e&=null!=t.f,e&=null!=t.ea,12==i&&(e&=d>=o,e&=p<=t.Tc,e&=null!=t.F)}else e=0;t=e?0:2}}return 0!=t||null!=n&&n.fd&&(t=qn(r)),t}var Tn=64,Dn=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215],Un=24,zn=32,Hn=8,Wn=[0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7];T(\"Predictor0\",\"PredictorAdd0\"),t.Predictor0=function(){return 4278190080},t.Predictor1=function(t){return t},t.Predictor2=function(t,e,n){return e[n+0]},t.Predictor3=function(t,e,n){return e[n+1]},t.Predictor4=function(t,e,n){return e[n-1]},t.Predictor5=function(t,e,n){return U(U(t,e[n+1]),e[n+0])},t.Predictor6=function(t,e,n){return U(t,e[n-1])},t.Predictor7=function(t,e,n){return U(t,e[n+0])},t.Predictor8=function(t,e,n){return U(e[n-1],e[n+0])},t.Predictor9=function(t,e,n){return U(e[n+0],e[n+1])},t.Predictor10=function(t,e,n){return U(U(t,e[n-1]),U(e[n+0],e[n+1]))},t.Predictor11=function(t,e,n){var r=e[n+0];return 0>=W(r>>24&255,t>>24&255,(e=e[n-1])>>24&255)+W(r>>16&255,t>>16&255,e>>16&255)+W(r>>8&255,t>>8&255,e>>8&255)+W(255&r,255&t,255&e)?r:t},t.Predictor12=function(t,e,n){var r=e[n+0];return(z((t>>24&255)+(r>>24&255)-((e=e[n-1])>>24&255))<<24|z((t>>16&255)+(r>>16&255)-(e>>16&255))<<16|z((t>>8&255)+(r>>8&255)-(e>>8&255))<<8|z((255&t)+(255&r)-(255&e)))>>>0},t.Predictor13=function(t,e,n){var r=e[n-1];return(H((t=U(t,e[n+0]))>>24&255,r>>24&255)<<24|H(t>>16&255,r>>16&255)<<16|H(t>>8&255,r>>8&255)<<8|H(t>>0&255,r>>0&255))>>>0};var Vn=t.PredictorAdd0;t.PredictorAdd1=V,T(\"Predictor2\",\"PredictorAdd2\"),T(\"Predictor3\",\"PredictorAdd3\"),T(\"Predictor4\",\"PredictorAdd4\"),T(\"Predictor5\",\"PredictorAdd5\"),T(\"Predictor6\",\"PredictorAdd6\"),T(\"Predictor7\",\"PredictorAdd7\"),T(\"Predictor8\",\"PredictorAdd8\"),T(\"Predictor9\",\"PredictorAdd9\"),T(\"Predictor10\",\"PredictorAdd10\"),T(\"Predictor11\",\"PredictorAdd11\"),T(\"Predictor12\",\"PredictorAdd12\"),T(\"Predictor13\",\"PredictorAdd13\");var Gn=t.PredictorAdd2;X(\"ColorIndexInverseTransform\",\"MapARGB\",\"32b\",(function(t){return t>>8&255}),(function(t){return t})),X(\"VP8LColorIndexInverseTransformAlpha\",\"MapAlpha\",\"8b\",(function(t){return t}),(function(t){return t>>8&255}));var Yn,Jn=t.ColorIndexInverseTransform,Xn=t.MapARGB,Kn=t.VP8LColorIndexInverseTransformAlpha,Zn=t.MapAlpha,$n=t.VP8LPredictorsAdd=[];$n.length=16,(t.VP8LPredictors=[]).length=16,(t.VP8LPredictorsAdd_C=[]).length=16,(t.VP8LPredictors_C=[]).length=16;var Qn,tr,er,nr,rr,ir,ar,or,sr,ur,cr,hr,lr,fr,dr,pr,gr,mr,vr,br,yr,wr,Nr,Lr,xr,Ar,_r,Sr,Pr=a(511),kr=a(2041),Fr=a(225),Ir=a(767),Cr=0,jr=kr,Br=Fr,Or=Ir,Mr=Pr,Er=0,qr=1,Rr=2,Tr=3,Dr=4,Ur=5,zr=6,Hr=7,Wr=8,Vr=9,Gr=10,Yr=[2,3,7],Jr=[3,3,11],Xr=[280,256,256,256,40],Kr=[0,1,1,1,0],Zr=[17,18,0,1,2,3,4,5,16,6,7,8,9,10,11,12,13,14,15],$r=[24,7,23,25,40,6,39,41,22,26,38,42,56,5,55,57,21,27,54,58,37,43,72,4,71,73,20,28,53,59,70,74,36,44,88,69,75,52,60,3,87,89,19,29,86,90,35,45,68,76,85,91,51,61,104,2,103,105,18,30,102,106,34,46,84,92,67,77,101,107,50,62,120,1,119,121,83,93,17,31,100,108,66,78,118,122,33,47,117,123,49,63,99,109,82,94,0,116,124,65,79,16,32,98,110,48,115,125,81,95,64,114,126,97,111,80,113,127,96,112],Qr=[2954,2956,2958,2962,2970,2986,3018,3082,3212,3468,3980,5004],ti=8,ei=[4,5,6,7,8,9,10,10,11,12,13,14,15,16,17,17,18,19,20,20,21,21,22,22,23,23,24,25,25,26,27,28,29,30,31,32,33,34,35,36,37,37,38,39,40,41,42,43,44,45,46,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,76,77,78,79,80,81,82,83,84,85,86,87,88,89,91,93,95,96,98,100,101,102,104,106,108,110,112,114,116,118,122,124,126,128,130,132,134,136,138,140,143,145,148,151,154,157],ni=[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,119,122,125,128,131,134,137,140,143,146,149,152,155,158,161,164,167,170,173,177,181,185,189,193,197,201,205,209,213,217,221,225,229,234,239,245,249,254,259,264,269,274,279,284],ri=null,ii=[[173,148,140,0],[176,155,140,135,0],[180,157,141,134,130,0],[254,254,243,230,196,177,153,140,133,130,129,0]],ai=[0,1,4,8,5,2,3,6,9,12,13,10,7,11,14,15],oi=[-0,1,-1,2,-2,3,4,6,-3,5,-4,-5,-6,7,-7,8,-8,-9],si=[[[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]],[[253,136,254,255,228,219,128,128,128,128,128],[189,129,242,255,227,213,255,219,128,128,128],[106,126,227,252,214,209,255,255,128,128,128]],[[1,98,248,255,236,226,255,255,128,128,128],[181,133,238,254,221,234,255,154,128,128,128],[78,134,202,247,198,180,255,219,128,128,128]],[[1,185,249,255,243,255,128,128,128,128,128],[184,150,247,255,236,224,128,128,128,128,128],[77,110,216,255,236,230,128,128,128,128,128]],[[1,101,251,255,241,255,128,128,128,128,128],[170,139,241,252,236,209,255,255,128,128,128],[37,116,196,243,228,255,255,255,128,128,128]],[[1,204,254,255,245,255,128,128,128,128,128],[207,160,250,255,238,128,128,128,128,128,128],[102,103,231,255,211,171,128,128,128,128,128]],[[1,152,252,255,240,255,128,128,128,128,128],[177,135,243,255,234,225,128,128,128,128,128],[80,129,211,255,194,224,128,128,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[246,1,255,128,128,128,128,128,128,128,128],[255,128,128,128,128,128,128,128,128,128,128]]],[[[198,35,237,223,193,187,162,160,145,155,62],[131,45,198,221,172,176,220,157,252,221,1],[68,47,146,208,149,167,221,162,255,223,128]],[[1,149,241,255,221,224,255,255,128,128,128],[184,141,234,253,222,220,255,199,128,128,128],[81,99,181,242,176,190,249,202,255,255,128]],[[1,129,232,253,214,197,242,196,255,255,128],[99,121,210,250,201,198,255,202,128,128,128],[23,91,163,242,170,187,247,210,255,255,128]],[[1,200,246,255,234,255,128,128,128,128,128],[109,178,241,255,231,245,255,255,128,128,128],[44,130,201,253,205,192,255,255,128,128,128]],[[1,132,239,251,219,209,255,165,128,128,128],[94,136,225,251,218,190,255,255,128,128,128],[22,100,174,245,186,161,255,199,128,128,128]],[[1,182,249,255,232,235,128,128,128,128,128],[124,143,241,255,227,234,128,128,128,128,128],[35,77,181,251,193,211,255,205,128,128,128]],[[1,157,247,255,236,231,255,255,128,128,128],[121,141,235,255,225,227,255,255,128,128,128],[45,99,188,251,195,217,255,224,128,128,128]],[[1,1,251,255,213,255,128,128,128,128,128],[203,1,248,255,255,128,128,128,128,128,128],[137,1,177,255,224,255,128,128,128,128,128]]],[[[253,9,248,251,207,208,255,192,128,128,128],[175,13,224,243,193,185,249,198,255,255,128],[73,17,171,221,161,179,236,167,255,234,128]],[[1,95,247,253,212,183,255,255,128,128,128],[239,90,244,250,211,209,255,255,128,128,128],[155,77,195,248,188,195,255,255,128,128,128]],[[1,24,239,251,218,219,255,205,128,128,128],[201,51,219,255,196,186,128,128,128,128,128],[69,46,190,239,201,218,255,228,128,128,128]],[[1,191,251,255,255,128,128,128,128,128,128],[223,165,249,255,213,255,128,128,128,128,128],[141,124,248,255,255,128,128,128,128,128,128]],[[1,16,248,255,255,128,128,128,128,128,128],[190,36,230,255,236,255,128,128,128,128,128],[149,1,255,128,128,128,128,128,128,128,128]],[[1,226,255,128,128,128,128,128,128,128,128],[247,192,255,128,128,128,128,128,128,128,128],[240,128,255,128,128,128,128,128,128,128,128]],[[1,134,252,255,255,128,128,128,128,128,128],[213,62,250,255,255,128,128,128,128,128,128],[55,93,255,128,128,128,128,128,128,128,128]],[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]]],[[[202,24,213,235,186,191,220,160,240,175,255],[126,38,182,232,169,184,228,174,255,187,128],[61,46,138,219,151,178,240,170,255,216,128]],[[1,112,230,250,199,191,247,159,255,255,128],[166,109,228,252,211,215,255,174,128,128,128],[39,77,162,232,172,180,245,178,255,255,128]],[[1,52,220,246,198,199,249,220,255,255,128],[124,74,191,243,183,193,250,221,255,255,128],[24,71,130,219,154,170,243,182,255,255,128]],[[1,182,225,249,219,240,255,224,128,128,128],[149,150,226,252,216,205,255,171,128,128,128],[28,108,170,242,183,194,254,223,255,255,128]],[[1,81,230,252,204,203,255,192,128,128,128],[123,102,209,247,188,196,255,233,128,128,128],[20,95,153,243,164,173,255,203,128,128,128]],[[1,222,248,255,216,213,128,128,128,128,128],[168,175,246,252,235,205,255,255,128,128,128],[47,116,215,255,211,212,255,255,128,128,128]],[[1,121,236,253,212,214,255,255,128,128,128],[141,84,213,252,201,202,255,219,128,128,128],[42,80,160,240,162,185,255,205,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[244,1,255,128,128,128,128,128,128,128,128],[238,1,255,128,128,128,128,128,128,128,128]]]],ui=[[[231,120,48,89,115,113,120,152,112],[152,179,64,126,170,118,46,70,95],[175,69,143,80,85,82,72,155,103],[56,58,10,171,218,189,17,13,152],[114,26,17,163,44,195,21,10,173],[121,24,80,195,26,62,44,64,85],[144,71,10,38,171,213,144,34,26],[170,46,55,19,136,160,33,206,71],[63,20,8,114,114,208,12,9,226],[81,40,11,96,182,84,29,16,36]],[[134,183,89,137,98,101,106,165,148],[72,187,100,130,157,111,32,75,80],[66,102,167,99,74,62,40,234,128],[41,53,9,178,241,141,26,8,107],[74,43,26,146,73,166,49,23,157],[65,38,105,160,51,52,31,115,128],[104,79,12,27,217,255,87,17,7],[87,68,71,44,114,51,15,186,23],[47,41,14,110,182,183,21,17,194],[66,45,25,102,197,189,23,18,22]],[[88,88,147,150,42,46,45,196,205],[43,97,183,117,85,38,35,179,61],[39,53,200,87,26,21,43,232,171],[56,34,51,104,114,102,29,93,77],[39,28,85,171,58,165,90,98,64],[34,22,116,206,23,34,43,166,73],[107,54,32,26,51,1,81,43,31],[68,25,106,22,64,171,36,225,114],[34,19,21,102,132,188,16,76,124],[62,18,78,95,85,57,50,48,51]],[[193,101,35,159,215,111,89,46,111],[60,148,31,172,219,228,21,18,111],[112,113,77,85,179,255,38,120,114],[40,42,1,196,245,209,10,25,109],[88,43,29,140,166,213,37,43,154],[61,63,30,155,67,45,68,1,209],[100,80,8,43,154,1,51,26,71],[142,78,78,16,255,128,34,197,171],[41,40,5,102,211,183,4,1,221],[51,50,17,168,209,192,23,25,82]],[[138,31,36,171,27,166,38,44,229],[67,87,58,169,82,115,26,59,179],[63,59,90,180,59,166,93,73,154],[40,40,21,116,143,209,34,39,175],[47,15,16,183,34,223,49,45,183],[46,17,33,183,6,98,15,32,183],[57,46,22,24,128,1,54,17,37],[65,32,73,115,28,128,23,128,205],[40,3,9,115,51,192,18,6,223],[87,37,9,115,59,77,64,21,47]],[[104,55,44,218,9,54,53,130,226],[64,90,70,205,40,41,23,26,57],[54,57,112,184,5,41,38,166,213],[30,34,26,133,152,116,10,32,134],[39,19,53,221,26,114,32,73,255],[31,9,65,234,2,15,1,118,73],[75,32,12,51,192,255,160,43,51],[88,31,35,67,102,85,55,186,85],[56,21,23,111,59,205,45,37,192],[55,38,70,124,73,102,1,34,98]],[[125,98,42,88,104,85,117,175,82],[95,84,53,89,128,100,113,101,45],[75,79,123,47,51,128,81,171,1],[57,17,5,71,102,57,53,41,49],[38,33,13,121,57,73,26,1,85],[41,10,67,138,77,110,90,47,114],[115,21,2,10,102,255,166,23,6],[101,29,16,10,85,128,101,196,26],[57,18,10,102,102,213,34,20,43],[117,20,15,36,163,128,68,1,26]],[[102,61,71,37,34,53,31,243,192],[69,60,71,38,73,119,28,222,37],[68,45,128,34,1,47,11,245,171],[62,17,19,70,146,85,55,62,70],[37,43,37,154,100,163,85,160,1],[63,9,92,136,28,64,32,201,85],[75,15,9,9,64,255,184,119,16],[86,6,28,5,64,255,25,248,1],[56,8,17,132,137,255,55,116,128],[58,15,20,82,135,57,26,121,40]],[[164,50,31,137,154,133,25,35,218],[51,103,44,131,131,123,31,6,158],[86,40,64,135,148,224,45,183,128],[22,26,17,131,240,154,14,1,209],[45,16,21,91,64,222,7,1,197],[56,21,39,155,60,138,23,102,213],[83,12,13,54,192,255,68,47,28],[85,26,85,85,128,128,32,146,171],[18,11,7,63,144,171,4,4,246],[35,27,10,146,174,171,12,26,128]],[[190,80,35,99,180,80,126,54,45],[85,126,47,87,176,51,41,20,32],[101,75,128,139,118,146,116,128,85],[56,41,15,176,236,85,37,9,62],[71,30,17,119,118,255,17,18,138],[101,38,60,138,55,70,43,26,142],[146,36,19,30,171,255,97,27,20],[138,45,61,62,219,1,81,188,64],[32,41,20,117,151,142,20,21,163],[112,19,12,61,195,128,48,4,24]]],ci=[[[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[176,246,255,255,255,255,255,255,255,255,255],[223,241,252,255,255,255,255,255,255,255,255],[249,253,253,255,255,255,255,255,255,255,255]],[[255,244,252,255,255,255,255,255,255,255,255],[234,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255]],[[255,246,254,255,255,255,255,255,255,255,255],[239,253,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[251,255,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[251,254,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,254,253,255,254,255,255,255,255,255,255],[250,255,254,255,254,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[217,255,255,255,255,255,255,255,255,255,255],[225,252,241,253,255,255,254,255,255,255,255],[234,250,241,250,253,255,253,254,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[223,254,254,255,255,255,255,255,255,255,255],[238,253,254,254,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[249,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,255,255,255,255,255,255,255,255,255],[247,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[252,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[186,251,250,255,255,255,255,255,255,255,255],[234,251,244,254,255,255,255,255,255,255,255],[251,251,243,253,254,255,254,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[236,253,254,255,255,255,255,255,255,255,255],[251,253,253,254,254,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[254,254,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[254,254,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[248,255,255,255,255,255,255,255,255,255,255],[250,254,252,254,255,255,255,255,255,255,255],[248,254,249,253,255,255,255,255,255,255,255]],[[255,253,253,255,255,255,255,255,255,255,255],[246,253,253,255,255,255,255,255,255,255,255],[252,254,251,254,254,255,255,255,255,255,255]],[[255,254,252,255,255,255,255,255,255,255,255],[248,254,253,255,255,255,255,255,255,255,255],[253,255,254,254,255,255,255,255,255,255,255]],[[255,251,254,255,255,255,255,255,255,255,255],[245,251,254,255,255,255,255,255,255,255,255],[253,253,254,255,255,255,255,255,255,255,255]],[[255,251,253,255,255,255,255,255,255,255,255],[252,253,254,255,255,255,255,255,255,255,255],[255,254,255,255,255,255,255,255,255,255,255]],[[255,252,255,255,255,255,255,255,255,255,255],[249,255,254,255,255,255,255,255,255,255,255],[255,255,254,255,255,255,255,255,255,255,255]],[[255,255,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]]],hi=[0,1,2,3,6,4,5,6,6,6,6,6,6,6,6,7,0],li=[],fi=[],di=[],pi=1,gi=2,mi=[],vi=[];bn(\"UpsampleRgbLinePair\",An,3),bn(\"UpsampleBgrLinePair\",_n,3),bn(\"UpsampleRgbaLinePair\",In,4),bn(\"UpsampleBgraLinePair\",Fn,4),bn(\"UpsampleArgbLinePair\",kn,4),bn(\"UpsampleRgba4444LinePair\",Pn,2),bn(\"UpsampleRgb565LinePair\",Sn,2);var bi=t.UpsampleRgbLinePair,yi=t.UpsampleBgrLinePair,wi=t.UpsampleRgbaLinePair,Ni=t.UpsampleBgraLinePair,Li=t.UpsampleArgbLinePair,xi=t.UpsampleRgba4444LinePair,Ai=t.UpsampleRgb565LinePair,_i=16,Si=1<<_i-1,Pi=-227,ki=482,Fi=6,Ii=(256<<Fi)-1,Ci=0,ji=a(256),Bi=a(256),Oi=a(256),Mi=a(256),Ei=a(ki-Pi),qi=a(ki-Pi);Cn(\"YuvToRgbRow\",An,3),Cn(\"YuvToBgrRow\",_n,3),Cn(\"YuvToRgbaRow\",In,4),Cn(\"YuvToBgraRow\",Fn,4),Cn(\"YuvToArgbRow\",kn,4),Cn(\"YuvToRgba4444Row\",Pn,2),Cn(\"YuvToRgb565Row\",Sn,2);var Ri=[0,4,8,12,128,132,136,140,256,260,264,268,384,388,392,396],Ti=[0,2,8],Di=[8,7,6,4,4,2,2,2,1,1,1,1],Ui=1;this.WebPDecodeRGBA=function(t,n,r,i,a){var o=qr,s=new nn,u=new ot;s.ba=u,u.S=o,u.width=[u.width],u.height=[u.height];var c=u.width,h=u.height,l=new st;if(null==l||null==t)var f=2;else e(null!=l),f=Mn(t,n,r,l.width,l.height,l.Pd,l.Qd,l.format,null);if(0!=f?c=0:(null!=c&&(c[0]=l.width[0]),null!=h&&(h[0]=l.height[0]),c=1),c){u.width=u.width[0],u.height=u.height[0],null!=i&&(i[0]=u.width),null!=a&&(a[0]=u.height);t:{if(i=new Gt,(a=new rn).data=t,a.w=n,a.ha=r,a.kd=1,n=[0],e(null!=a),(0==(t=Mn(a.data,a.w,a.ha,null,null,null,n,null,a))||7==t)&&n[0]&&(t=4),0==(n=t)){if(e(null!=s),i.data=a.data,i.w=a.w+a.offset,i.ha=a.ha-a.offset,i.put=dt,i.ac=ft,i.bc=pt,i.ma=s,a.xa){if(null==(t=kt())){s=1;break t}if(function(t,n){var r=[0],i=[0],a=[0];e:for(;;){if(null==t)return 0;if(null==n)return t.a=2,0;if(t.l=n,t.a=0,v(t.m,n.data,n.w,n.ha),!gt(t.m,r,i,a)){t.a=3;break e}if(t.xb=gi,n.width=r[0],n.height=i[0],!Ft(r[0],i[0],1,t,null))break e;return 1}return e(0!=t.a),0}(t,i)){if(i=0==(n=Rn(i.width,i.height,s.Oa,s.ba))){e:{i=t;n:for(;;){if(null==i){i=0;break e}if(e(null!=i.s.yc),e(null!=i.s.Ya),e(0<i.s.Wb),e(null!=(r=i.l)),e(null!=(a=r.ma)),0!=i.xb){if(i.ca=a.ba,i.tb=a.tb,e(null!=i.ca),!En(a.Oa,r,Tr)){i.a=2;break n}if(!It(i,r.width))break n;if(r.da)break n;if((r.da||rt(i.ca.S))&&vn(),11>i.ca.S||(alert(\"todo:WebPInitConvertARGBToYUV\"),null!=i.ca.f.kb.F&&vn()),i.Pb&&0<i.s.ua&&null==i.s.vb.X&&!B(i.s.vb,i.s.Wa.Xa)){i.a=1;break n}i.xb=0}if(!St(i,i.V,i.Ba,i.c,i.i,r.o,Lt))break n;a.Dc=i.Ma,i=1;break e}e(0!=i.a),i=0}i=!i}i&&(n=t.a)}else n=t.a}else{if(null==(t=new Yt)){s=1;break t}if(t.Fa=a.na,t.P=a.P,t.qc=a.Sa,Kt(t,i)){if(0==(n=Rn(i.width,i.height,s.Oa,s.ba))){if(t.Aa=0,r=s.Oa,e(null!=(a=t)),null!=r){if(0<(c=0>(c=r.Md)?0:100<c?255:255*c/100)){for(h=l=0;4>h;++h)12>(f=a.pb[h]).lc&&(f.ia=c*Di[0>f.lc?0:f.lc]>>3),l|=f.ia;l&&(alert(\"todo:VP8InitRandom\"),a.ia=1)}a.Ga=r.Id,100<a.Ga?a.Ga=100:0>a.Ga&&(a.Ga=0)}Qt(t,i)||(n=t.a)}}else n=t.a}0==n&&null!=s.Oa&&s.Oa.fd&&(n=qn(s.ba))}s=n}o=0!=s?null:11>o?u.f.RGBA.eb:u.f.kb.y}else o=null;return o};var zi=[3,4,3,4,4,2,2,4,4,4,2,1,1]});var l=[0],f=[0],d=[],p=new Et,g=t,m=function(t,e){var n={},r=0,i=!1,a=0,o=0;if(n.frames=[],!\n/** @license\n * Copyright (c) 2017 Dominik Homberger\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nhttps://webpjs.appspot.com\nWebPRiffParser dominikhlbg@gmail.com\n*/\nfunction(t,e,n,r){for(var i=0;i<r;i++)if(t[e+i]!=n.charCodeAt(i))return!0;return!1}(t,e,\"RIFF\",4)){var s,l;h(t,e+=4);for(e+=8;e<t.length;){var f=u(t,e),d=h(t,e+=4);e+=4;var p=d+(1&d);switch(f){case\"VP8 \":case\"VP8L\":void 0===n.frames[r]&&(n.frames[r]={});(v=n.frames[r]).src_off=i?o:e-8,v.src_size=a+d+8,r++,i&&(i=!1,a=0,o=0);break;case\"VP8X\":(v=n.header={}).feature_flags=t[e];var g=e+4;v.canvas_width=1+c(t,g);g+=3;v.canvas_height=1+c(t,g);g+=3;break;case\"ALPH\":i=!0,a=p+8,o=e-8;break;case\"ANIM\":(v=n.header).bgcolor=h(t,e);g=e+4;v.loop_count=(s=t)[(l=g)+0]<<0|s[l+1]<<8;g+=2;break;case\"ANMF\":var m,v;(v=n.frames[r]={}).offset_x=2*c(t,e),e+=3,v.offset_y=2*c(t,e),e+=3,v.width=1+c(t,e),e+=3,v.height=1+c(t,e),e+=3,v.duration=c(t,e),e+=3,m=t[e++],v.dispose=1&m,v.blend=m>>1&1}\"ANMF\"!=f&&(e+=p)}return n}}(g,0);m.response=g,m.rgbaoutput=!0,m.dataurl=!1;var v=m.header?m.header:null,b=m.frames?m.frames:null;if(v){v.loop_counter=v.loop_count,l=[v.canvas_height],f=[v.canvas_width];for(var y=0;y<b.length&&0!=b[y].blend;y++);}var w=b[0],N=p.WebPDecodeRGBA(g,w.src_off,w.src_size,f,l);w.rgba=N,w.imgwidth=f[0],w.imgheight=l[0];for(var L=0;L<f[0]*l[0]*4;L++)d[L]=N[L];return this.width=f,this.height=l,this.data=d,this}\n/**\n * @license\n *\n * Copyright (c) 2014 James Robb, https://github.com/jamesbrobb\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n * ====================================================================\n */\n!function(t){var e=function(){return!0},n=function(e,n,a,h){var l=5,f=s;switch(h){case t.image_compression.FAST:l=3,f=o;break;case t.image_compression.MEDIUM:l=6,f=u;break;case t.image_compression.SLOW:l=9,f=c}e=i(e,n,a,f);var d=new Uint8Array(r(l)),p=g.API.adler32cs.fromBuffer(e.buffer),m=new xt(l),v=m.append(e),b=m.flush(),y=d.length+v.length+b.length,w=new Uint8Array(y+4);return w.set(d),w.set(v,d.length),w.set(b,d.length+v.length),w[y++]=p>>>24&255,w[y++]=p>>>16&255,w[y++]=p>>>8&255,w[y++]=255&p,t.__addimage__.arrayBufferToBinaryString(w)},r=function(t){var e=30720;return e|=Math.min(3,(t-1&255)>>1)<<6,e|=0,[120,255&(e+=31-e%31)]},i=function(t,e,n,r){for(var i,a,o,s=t.length/e,u=new Uint8Array(t.length+s),c=l(),h=0;h<s;h+=1){if(o=h*e,i=t.subarray(o,o+e),r)u.set(r(i,n,a),o+h);else{for(var d,p=c.length,g=[];d<p;d+=1)g[d]=c[d](i,n,a);var m=f(g.concat());u.set(g[m],o+h)}a=i}return u},a=function(t){var e=Array.apply([],t);return e.unshift(0),e},o=function(t,e){var n,r=[],i=t.length;r[0]=1;for(var a=0;a<i;a+=1)n=t[a-e]||0,r[a+1]=t[a]-n+256&255;return r},s=function(t,e,n){var r,i=[],a=t.length;i[0]=2;for(var o=0;o<a;o+=1)r=n&&n[o]||0,i[o+1]=t[o]-r+256&255;return i},u=function(t,e,n){var r,i,a=[],o=t.length;a[0]=3;for(var s=0;s<o;s+=1)r=t[s-e]||0,i=n&&n[s]||0,a[s+1]=t[s]+256-(r+i>>>1)&255;return a},c=function(t,e,n){var r,i,a,o,s=[],u=t.length;s[0]=4;for(var c=0;c<u;c+=1)r=t[c-e]||0,i=n&&n[c]||0,a=n&&n[c-e]||0,o=h(r,i,a),s[c+1]=t[c]-o+256&255;return s},h=function(t,e,n){if(t===e&&e===n)return t;var r=Math.abs(e-n),i=Math.abs(t-n),a=Math.abs(t+e-n-n);return r<=i&&r<=a?t:i<=a?e:n},l=function(){return[a,o,s,u,c]},f=function(t){var e=t.map((function(t){return t.reduce((function(t,e){return t+Math.abs(e)}),0)}));return e.indexOf(Math.min.apply(null,e))};t.processPNG=function(r,i,a,o){var s,u,c,h,l,f,d,p,g,m,v,b,y,w,N,L=this.decode.FLATE_DECODE,x=\"\";if(this.__addimage__.isArrayBuffer(r)&&(r=new Uint8Array(r)),this.__addimage__.isArrayBufferView(r)){if(r=(c=new Ct(r)).imgData,u=c.bits,s=c.colorSpace,l=c.colors,-1!==[4,6].indexOf(c.colorType)){if(8===c.bits){g=(p=32==c.pixelBitlength?new Uint32Array(c.decodePixels().buffer):16==c.pixelBitlength?new Uint16Array(c.decodePixels().buffer):new Uint8Array(c.decodePixels().buffer)).length,v=new Uint8Array(g*c.colors),m=new Uint8Array(g);var A,_=c.pixelBitlength-c.bits;for(w=0,N=0;w<g;w++){for(y=p[w],A=0;A<_;)v[N++]=y>>>A&255,A+=c.bits;m[w]=y>>>A&255}}if(16===c.bits){g=(p=new Uint32Array(c.decodePixels().buffer)).length,v=new Uint8Array(g*(32/c.pixelBitlength)*c.colors),m=new Uint8Array(g*(32/c.pixelBitlength)),b=c.colors>1,w=0,N=0;for(var S=0;w<g;)y=p[w++],v[N++]=y>>>0&255,b&&(v[N++]=y>>>16&255,y=p[w++],v[N++]=y>>>0&255),m[S++]=y>>>16&255;u=8}o!==t.image_compression.NONE&&e()?(r=n(v,c.width*c.colors,c.colors,o),d=n(m,c.width,1,o)):(r=v,d=m,L=void 0)}if(3===c.colorType&&(s=this.color_spaces.INDEXED,f=c.palette,c.transparency.indexed)){var P=c.transparency.indexed,k=0;for(w=0,g=P.length;w<g;++w)k+=P[w];if((k/=255)===g-1&&-1!==P.indexOf(0))h=[P.indexOf(0)];else if(k!==g){for(p=c.decodePixels(),m=new Uint8Array(p.length),w=0,g=p.length;w<g;w++)m[w]=P[p[w]];d=n(m,c.width,1)}}var F=function(e){var n;switch(e){case t.image_compression.FAST:n=11;break;case t.image_compression.MEDIUM:n=13;break;case t.image_compression.SLOW:n=14;break;default:n=12}return n}(o);return L===this.decode.FLATE_DECODE&&(x=\"/Predictor \"+F+\" \"),x+=\"/Colors \"+l+\" /BitsPerComponent \"+u+\" /Columns \"+c.width,(this.__addimage__.isArrayBuffer(r)||this.__addimage__.isArrayBufferView(r))&&(r=this.__addimage__.arrayBufferToBinaryString(r)),(d&&this.__addimage__.isArrayBuffer(d)||this.__addimage__.isArrayBufferView(d))&&(d=this.__addimage__.arrayBufferToBinaryString(d)),{alias:a,data:r,index:i,filter:L,decodeParameters:x,transparency:h,palette:f,sMask:d,predictor:F,width:c.width,height:c.height,bitsPerComponent:u,colorSpace:s}}}}(g.API),function(t){t.processGIF89A=function(e,n,r,i){var a=new jt(e),o=a.width,s=a.height,u=[];a.decodeAndBlitFrameRGBA(0,u);var c={data:u,width:o,height:s},h=new Ot(100).encode(c,100);return t.processJPEG.call(this,h,n,r,i)},t.processGIF87A=t.processGIF89A}(g.API),Mt.prototype.parseHeader=function(){if(this.fileSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.reserved=this.datav.getUint32(this.pos,!0),this.pos+=4,this.offset=this.datav.getUint32(this.pos,!0),this.pos+=4,this.headerSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.width=this.datav.getUint32(this.pos,!0),this.pos+=4,this.height=this.datav.getInt32(this.pos,!0),this.pos+=4,this.planes=this.datav.getUint16(this.pos,!0),this.pos+=2,this.bitPP=this.datav.getUint16(this.pos,!0),this.pos+=2,this.compress=this.datav.getUint32(this.pos,!0),this.pos+=4,this.rawSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.hr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.vr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.colors=this.datav.getUint32(this.pos,!0),this.pos+=4,this.importantColors=this.datav.getUint32(this.pos,!0),this.pos+=4,16===this.bitPP&&this.is_with_alpha&&(this.bitPP=15),this.bitPP<15){var t=0===this.colors?1<<this.bitPP:this.colors;this.palette=new Array(t);for(var e=0;e<t;e++){var n=this.datav.getUint8(this.pos++,!0),r=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0);this.palette[e]={red:i,green:r,blue:n,quad:a}}}this.height<0&&(this.height*=-1,this.bottom_up=!1)},Mt.prototype.parseBGR=function(){this.pos=this.offset;try{var t=\"bit\"+this.bitPP,e=this.width*this.height*4;this.data=new Uint8Array(e),this[t]()}catch(t){n.log(\"bit decode error:\"+t)}},Mt.prototype.bit1=function(){var t,e=Math.ceil(this.width/8),n=e%4;for(t=this.height-1;t>=0;t--){for(var r=this.bottom_up?t:this.height-1-t,i=0;i<e;i++)for(var a=this.datav.getUint8(this.pos++,!0),o=r*this.width*4+8*i*4,s=0;s<8&&8*i+s<this.width;s++){var u=this.palette[a>>7-s&1];this.data[o+4*s]=u.blue,this.data[o+4*s+1]=u.green,this.data[o+4*s+2]=u.red,this.data[o+4*s+3]=255}0!==n&&(this.pos+=4-n)}},Mt.prototype.bit4=function(){for(var t=Math.ceil(this.width/2),e=t%4,n=this.height-1;n>=0;n--){for(var r=this.bottom_up?n:this.height-1-n,i=0;i<t;i++){var a=this.datav.getUint8(this.pos++,!0),o=r*this.width*4+2*i*4,s=a>>4,u=15&a,c=this.palette[s];if(this.data[o]=c.blue,this.data[o+1]=c.green,this.data[o+2]=c.red,this.data[o+3]=255,2*i+1>=this.width)break;c=this.palette[u],this.data[o+4]=c.blue,this.data[o+4+1]=c.green,this.data[o+4+2]=c.red,this.data[o+4+3]=255}0!==e&&(this.pos+=4-e)}},Mt.prototype.bit8=function(){for(var t=this.width%4,e=this.height-1;e>=0;e--){for(var n=this.bottom_up?e:this.height-1-e,r=0;r<this.width;r++){var i=this.datav.getUint8(this.pos++,!0),a=n*this.width*4+4*r;if(i<this.palette.length){var o=this.palette[i];this.data[a]=o.red,this.data[a+1]=o.green,this.data[a+2]=o.blue,this.data[a+3]=255}else this.data[a]=255,this.data[a+1]=255,this.data[a+2]=255,this.data[a+3]=255}0!==t&&(this.pos+=4-t)}},Mt.prototype.bit15=function(){for(var t=this.width%3,e=parseInt(\"11111\",2),n=this.height-1;n>=0;n--){for(var r=this.bottom_up?n:this.height-1-n,i=0;i<this.width;i++){var a=this.datav.getUint16(this.pos,!0);this.pos+=2;var o=(a&e)/e*255|0,s=(a>>5&e)/e*255|0,u=(a>>10&e)/e*255|0,c=a>>15?255:0,h=r*this.width*4+4*i;this.data[h]=u,this.data[h+1]=s,this.data[h+2]=o,this.data[h+3]=c}this.pos+=t}},Mt.prototype.bit16=function(){for(var t=this.width%3,e=parseInt(\"11111\",2),n=parseInt(\"111111\",2),r=this.height-1;r>=0;r--){for(var i=this.bottom_up?r:this.height-1-r,a=0;a<this.width;a++){var o=this.datav.getUint16(this.pos,!0);this.pos+=2;var s=(o&e)/e*255|0,u=(o>>5&n)/n*255|0,c=(o>>11)/e*255|0,h=i*this.width*4+4*a;this.data[h]=c,this.data[h+1]=u,this.data[h+2]=s,this.data[h+3]=255}this.pos+=t}},Mt.prototype.bit24=function(){for(var t=this.height-1;t>=0;t--){for(var e=this.bottom_up?t:this.height-1-t,n=0;n<this.width;n++){var r=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0),o=e*this.width*4+4*n;this.data[o]=a,this.data[o+1]=i,this.data[o+2]=r,this.data[o+3]=255}this.pos+=this.width%4}},Mt.prototype.bit32=function(){for(var t=this.height-1;t>=0;t--)for(var e=this.bottom_up?t:this.height-1-t,n=0;n<this.width;n++){var r=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0),o=this.datav.getUint8(this.pos++,!0),s=e*this.width*4+4*n;this.data[s]=a,this.data[s+1]=i,this.data[s+2]=r,this.data[s+3]=o}},Mt.prototype.getData=function(){return this.data},\n/**\n * @license\n * Copyright (c) 2018 Aras Abbasi\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */\nfunction(t){t.processBMP=function(e,n,r,i){var a=new Mt(e,!1),o=a.width,s=a.height,u={data:a.getData(),width:o,height:s},c=new Ot(100).encode(u,100);return t.processJPEG.call(this,c,n,r,i)}}(g.API),Et.prototype.getData=function(){return this.data},\n/**\n * @license\n * Copyright (c) 2019 Aras Abbasi\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */\nfunction(t){t.processWEBP=function(e,n,r,i){var a=new Et(e,!1),o=a.width,s=a.height,u={data:a.getData(),width:o,height:s},c=new Ot(100).encode(u,100);return t.processJPEG.call(this,c,n,r,i)}}(g.API),g.API.setLanguage=function(t){return void 0===this.internal.languageSettings&&(this.internal.languageSettings={},this.internal.languageSettings.isSubscribed=!1),void 0!=={af:\"Afrikaans\",sq:\"Albanian\",ar:\"Arabic (Standard)\",\"ar-DZ\":\"Arabic (Algeria)\",\"ar-BH\":\"Arabic (Bahrain)\",\"ar-EG\":\"Arabic (Egypt)\",\"ar-IQ\":\"Arabic (Iraq)\",\"ar-JO\":\"Arabic (Jordan)\",\"ar-KW\":\"Arabic (Kuwait)\",\"ar-LB\":\"Arabic (Lebanon)\",\"ar-LY\":\"Arabic (Libya)\",\"ar-MA\":\"Arabic (Morocco)\",\"ar-OM\":\"Arabic (Oman)\",\"ar-QA\":\"Arabic (Qatar)\",\"ar-SA\":\"Arabic (Saudi Arabia)\",\"ar-SY\":\"Arabic (Syria)\",\"ar-TN\":\"Arabic (Tunisia)\",\"ar-AE\":\"Arabic (U.A.E.)\",\"ar-YE\":\"Arabic (Yemen)\",an:\"Aragonese\",hy:\"Armenian\",as:\"Assamese\",ast:\"Asturian\",az:\"Azerbaijani\",eu:\"Basque\",be:\"Belarusian\",bn:\"Bengali\",bs:\"Bosnian\",br:\"Breton\",bg:\"Bulgarian\",my:\"Burmese\",ca:\"Catalan\",ch:\"Chamorro\",ce:\"Chechen\",zh:\"Chinese\",\"zh-HK\":\"Chinese (Hong Kong)\",\"zh-CN\":\"Chinese (PRC)\",\"zh-SG\":\"Chinese (Singapore)\",\"zh-TW\":\"Chinese (Taiwan)\",cv:\"Chuvash\",co:\"Corsican\",cr:\"Cree\",hr:\"Croatian\",cs:\"Czech\",da:\"Danish\",nl:\"Dutch (Standard)\",\"nl-BE\":\"Dutch (Belgian)\",en:\"English\",\"en-AU\":\"English (Australia)\",\"en-BZ\":\"English (Belize)\",\"en-CA\":\"English (Canada)\",\"en-IE\":\"English (Ireland)\",\"en-JM\":\"English (Jamaica)\",\"en-NZ\":\"English (New Zealand)\",\"en-PH\":\"English (Philippines)\",\"en-ZA\":\"English (South Africa)\",\"en-TT\":\"English (Trinidad & Tobago)\",\"en-GB\":\"English (United Kingdom)\",\"en-US\":\"English (United States)\",\"en-ZW\":\"English (Zimbabwe)\",eo:\"Esperanto\",et:\"Estonian\",fo:\"Faeroese\",fj:\"Fijian\",fi:\"Finnish\",fr:\"French (Standard)\",\"fr-BE\":\"French (Belgium)\",\"fr-CA\":\"French (Canada)\",\"fr-FR\":\"French (France)\",\"fr-LU\":\"French (Luxembourg)\",\"fr-MC\":\"French (Monaco)\",\"fr-CH\":\"French (Switzerland)\",fy:\"Frisian\",fur:\"Friulian\",gd:\"Gaelic (Scots)\",\"gd-IE\":\"Gaelic (Irish)\",gl:\"Galacian\",ka:\"Georgian\",de:\"German (Standard)\",\"de-AT\":\"German (Austria)\",\"de-DE\":\"German (Germany)\",\"de-LI\":\"German (Liechtenstein)\",\"de-LU\":\"German (Luxembourg)\",\"de-CH\":\"German (Switzerland)\",el:\"Greek\",gu:\"Gujurati\",ht:\"Haitian\",he:\"Hebrew\",hi:\"Hindi\",hu:\"Hungarian\",is:\"Icelandic\",id:\"Indonesian\",iu:\"Inuktitut\",ga:\"Irish\",it:\"Italian (Standard)\",\"it-CH\":\"Italian (Switzerland)\",ja:\"Japanese\",kn:\"Kannada\",ks:\"Kashmiri\",kk:\"Kazakh\",km:\"Khmer\",ky:\"Kirghiz\",tlh:\"Klingon\",ko:\"Korean\",\"ko-KP\":\"Korean (North Korea)\",\"ko-KR\":\"Korean (South Korea)\",la:\"Latin\",lv:\"Latvian\",lt:\"Lithuanian\",lb:\"Luxembourgish\",mk:\"FYRO Macedonian\",ms:\"Malay\",ml:\"Malayalam\",mt:\"Maltese\",mi:\"Maori\",mr:\"Marathi\",mo:\"Moldavian\",nv:\"Navajo\",ng:\"Ndonga\",ne:\"Nepali\",no:\"Norwegian\",nb:\"Norwegian (Bokmal)\",nn:\"Norwegian (Nynorsk)\",oc:\"Occitan\",or:\"Oriya\",om:\"Oromo\",fa:\"Persian\",\"fa-IR\":\"Persian/Iran\",pl:\"Polish\",pt:\"Portuguese\",\"pt-BR\":\"Portuguese (Brazil)\",pa:\"Punjabi\",\"pa-IN\":\"Punjabi (India)\",\"pa-PK\":\"Punjabi (Pakistan)\",qu:\"Quechua\",rm:\"Rhaeto-Romanic\",ro:\"Romanian\",\"ro-MO\":\"Romanian (Moldavia)\",ru:\"Russian\",\"ru-MO\":\"Russian (Moldavia)\",sz:\"Sami (Lappish)\",sg:\"Sango\",sa:\"Sanskrit\",sc:\"Sardinian\",sd:\"Sindhi\",si:\"Singhalese\",sr:\"Serbian\",sk:\"Slovak\",sl:\"Slovenian\",so:\"Somani\",sb:\"Sorbian\",es:\"Spanish\",\"es-AR\":\"Spanish (Argentina)\",\"es-BO\":\"Spanish (Bolivia)\",\"es-CL\":\"Spanish (Chile)\",\"es-CO\":\"Spanish (Colombia)\",\"es-CR\":\"Spanish (Costa Rica)\",\"es-DO\":\"Spanish (Dominican Republic)\",\"es-EC\":\"Spanish (Ecuador)\",\"es-SV\":\"Spanish (El Salvador)\",\"es-GT\":\"Spanish (Guatemala)\",\"es-HN\":\"Spanish (Honduras)\",\"es-MX\":\"Spanish (Mexico)\",\"es-NI\":\"Spanish (Nicaragua)\",\"es-PA\":\"Spanish (Panama)\",\"es-PY\":\"Spanish (Paraguay)\",\"es-PE\":\"Spanish (Peru)\",\"es-PR\":\"Spanish (Puerto Rico)\",\"es-ES\":\"Spanish (Spain)\",\"es-UY\":\"Spanish (Uruguay)\",\"es-VE\":\"Spanish (Venezuela)\",sx:\"Sutu\",sw:\"Swahili\",sv:\"Swedish\",\"sv-FI\":\"Swedish (Finland)\",\"sv-SV\":\"Swedish (Sweden)\",ta:\"Tamil\",tt:\"Tatar\",te:\"Teluga\",th:\"Thai\",tig:\"Tigre\",ts:\"Tsonga\",tn:\"Tswana\",tr:\"Turkish\",tk:\"Turkmen\",uk:\"Ukrainian\",hsb:\"Upper Sorbian\",ur:\"Urdu\",ve:\"Venda\",vi:\"Vietnamese\",vo:\"Volapuk\",wa:\"Walloon\",cy:\"Welsh\",xh:\"Xhosa\",ji:\"Yiddish\",zu:\"Zulu\"}[t]&&(this.internal.languageSettings.languageCode=t,!1===this.internal.languageSettings.isSubscribed&&(this.internal.events.subscribe(\"putCatalog\",(function(){this.internal.write(\"/Lang (\"+this.internal.languageSettings.languageCode+\")\")})),this.internal.languageSettings.isSubscribed=!0)),this},\n/** @license\n * MIT license.\n * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com\n * 2014 Diego Casorran, https://github.com/diegocr\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n * ====================================================================\n */\nAt=g.API,_t=At.getCharWidthsArray=function(t,e){var n,r,i=(e=e||{}).font||this.internal.getFont(),a=e.fontSize||this.internal.getFontSize(),o=e.charSpace||this.internal.getCharSpace(),s=e.widths?e.widths:i.metadata.Unicode.widths,u=s.fof?s.fof:1,c=e.kerning?e.kerning:i.metadata.Unicode.kerning,h=c.fof?c.fof:1,l=!1!==e.doKerning,f=0,d=t.length,p=0,g=s[0]||u,m=[];for(n=0;n<d;n++)r=t.charCodeAt(n),\"function\"==typeof i.metadata.widthOfString?m.push((i.metadata.widthOfGlyph(i.metadata.characterToGlyph(r))+o*(1e3/a)||0)/1e3):(f=l&&\"object\"==typeof c[r]&&!isNaN(parseInt(c[r][p],10))?c[r][p]/h:0,m.push((s[r]||g)/u+f)),p=r;return m},St=At.getStringUnitWidth=function(t,e){var n=(e=e||{}).fontSize||this.internal.getFontSize(),r=e.font||this.internal.getFont(),i=e.charSpace||this.internal.getCharSpace();return At.processArabic&&(t=At.processArabic(t)),\"function\"==typeof r.metadata.widthOfString?r.metadata.widthOfString(t,n,i)/n:_t.apply(this,arguments).reduce((function(t,e){return t+e}),0)},Pt=function(t,e,n,r){for(var i=[],a=0,o=t.length,s=0;a!==o&&s+e[a]<n;)s+=e[a],a++;i.push(t.slice(0,a));var u=a;for(s=0;a!==o;)s+e[a]>r&&(i.push(t.slice(u,a)),s=0,u=a),s+=e[a],a++;return u!==a&&i.push(t.slice(u,a)),i},kt=function(t,e,n){n||(n={});var r,i,a,o,s,u,c,h=[],l=[h],f=n.textIndent||0,d=0,p=0,g=t.split(\" \"),m=_t.apply(this,[\" \",n])[0];if(u=-1===n.lineIndent?g[0].length+2:n.lineIndent||0){var v=Array(u).join(\" \"),b=[];g.map((function(t){(t=t.split(/\\s*\\n/)).length>1?b=b.concat(t.map((function(t,e){return(e&&t.length?\"\\n\":\"\")+t}))):b.push(t[0])})),g=b,u=St.apply(this,[v,n])}for(a=0,o=g.length;a<o;a++){var y=0;if(r=g[a],u&&\"\\n\"==r[0]&&(r=r.substr(1),y=1),f+d+(p=(i=_t.apply(this,[r,n])).reduce((function(t,e){return t+e}),0))>e||y){if(p>e){for(s=Pt.apply(this,[r,i,e-(f+d),e]),h.push(s.shift()),h=[s.pop()];s.length;)l.push([s.shift()]);p=i.slice(r.length-(h[0]?h[0].length:0)).reduce((function(t,e){return t+e}),0)}else h=[r];l.push(h),f=p+u,d=m}else h.push(r),f+=d+p,d=m}return c=u?function(t,e){return(e?v:\"\")+t.join(\" \")}:function(t){return t.join(\" \")},l.map(c)},At.splitTextToSize=function(t,e,n){var r,i=(n=n||{}).fontSize||this.internal.getFontSize(),a=function(t){if(t.widths&&t.kerning)return{widths:t.widths,kerning:t.kerning};var e=this.internal.getFont(t.fontName,t.fontStyle);return e.metadata.Unicode?{widths:e.metadata.Unicode.widths||{0:1},kerning:e.metadata.Unicode.kerning||{}}:{font:e.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}.call(this,n);r=Array.isArray(t)?t:String(t).split(/\\r?\\n/);var o=1*this.internal.scaleFactor*e/i;a.textIndent=n.textIndent?1*n.textIndent*this.internal.scaleFactor/i:0,a.lineIndent=n.lineIndent;var s,u,c=[];for(s=0,u=r.length;s<u;s++)c=c.concat(kt.apply(this,[r[s],o,a]));return c},\n/** @license\n jsPDF standard_fonts_metrics plugin\n * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com\n * MIT license.\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n * \n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n * ====================================================================\n */\nfunction(t){t.__fontmetrics__=t.__fontmetrics__||{};for(var e=\"klmnopqrstuvwxyz\",n={},r={},i=0;i<e.length;i++)n[e[i]]=\"0123456789abcdef\"[i],r[\"0123456789abcdef\"[i]]=e[i];var a=function(t){return\"0x\"+parseInt(t,10).toString(16)},o=t.__fontmetrics__.compress=function(t){var e,n,i,s,u=[\"{\"];for(var c in t){if(e=t[c],isNaN(parseInt(c,10))?n=\"'\"+c+\"'\":(c=parseInt(c,10),n=(n=a(c).slice(2)).slice(0,-1)+r[n.slice(-1)]),\"number\"==typeof e)e<0?(i=a(e).slice(3),s=\"-\"):(i=a(e).slice(2),s=\"\"),i=s+i.slice(0,-1)+r[i.slice(-1)];else{if(\"object\"!=typeof e)throw new Error(\"Don't know what to do with value type \"+typeof e+\".\");i=o(e)}u.push(n+i)}return u.push(\"}\"),u.join(\"\")},s=t.__fontmetrics__.uncompress=function(t){if(\"string\"!=typeof t)throw new Error(\"Invalid argument passed to uncompress.\");for(var e,r,i,a,o={},s=1,u=o,c=[],h=\"\",l=\"\",f=t.length-1,d=1;d<f;d+=1)\"'\"==(a=t[d])?e?(i=e.join(\"\"),e=void 0):e=[]:e?e.push(a):\"{\"==a?(c.push([u,i]),u={},i=void 0):\"}\"==a?((r=c.pop())[0][r[1]]=u,i=void 0,u=r[0]):\"-\"==a?s=-1:void 0===i?n.hasOwnProperty(a)?(h+=n[a],i=parseInt(h,16)*s,s=1,h=\"\"):h+=a:n.hasOwnProperty(a)?(l+=n[a],u[i]=parseInt(l,16)*s,s=1,i=void 0,l=\"\"):l+=a;return o},u={codePages:[\"WinAnsiEncoding\"],WinAnsiEncoding:s(\"{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}\")},c={Unicode:{Courier:u,\"Courier-Bold\":u,\"Courier-BoldOblique\":u,\"Courier-Oblique\":u,Helvetica:u,\"Helvetica-Bold\":u,\"Helvetica-BoldOblique\":u,\"Helvetica-Oblique\":u,\"Times-Roman\":u,\"Times-Bold\":u,\"Times-BoldItalic\":u,\"Times-Italic\":u}},h={Unicode:{\"Courier-Oblique\":s(\"{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}\"),\"Times-BoldItalic\":s(\"{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}\"),\"Helvetica-Bold\":s(\"{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}\"),Courier:s(\"{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}\"),\"Courier-BoldOblique\":s(\"{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}\"),\"Times-Bold\":s(\"{'widths'{k3q2q5ncx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2l202m2n2n3m2o3m2p6o202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5x4l4s4m4m4n4s4o4s4p4m4q3x4r4y4s4y4t2r4u3m4v4y4w4m4x5y4y4s4z4y5k3x5l4y5m4s5n3r5o4m5p4s5q4s5r6o5s4s5t4s5u4m5v2l5w1w5x2l5y3u5z3m6k2l6l3m6m3r6n2w6o3r6p2w6q2l6r3m6s3r6t1w6u2l6v3r6w1w6x5n6y3r6z3m7k3r7l3r7m2w7n2r7o2l7p3r7q3m7r4s7s3m7t3m7u2w7v2r7w1q7x2r7y3o202l3mcl4sal2lam3man3mao3map3mar3mas2lat4uau1yav3maw3tay4uaz2lbk2sbl3t'fof'6obo2lbp3rbr1tbs2lbu2lbv3mbz3mck4s202k3mcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3rek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3m3u2l17s4s19m3m}'kerning'{cl{4qt5ks5ot5qy5rw17sv5tv}201t{cks4lscmscnscoscpscls4wv}2k{201ts}2w{4qu5ku7mu5os5qx5ru17su5tu}2x{17su5tu5ou5qs}2y{4qv5kv7mu5ot5qz5ru17su5tu}'fof'-6o7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qu}3v{17su5tu5os5qu}fu{17su5tu5ou5qu}7p{17su5tu5ou5qu}ck{4qt5ks5ot5qy5rw17sv5tv}4l{4qt5ks5ot5qy5rw17sv5tv}cm{4qt5ks5ot5qy5rw17sv5tv}cn{4qt5ks5ot5qy5rw17sv5tv}co{4qt5ks5ot5qy5rw17sv5tv}cp{4qt5ks5ot5qy5rw17sv5tv}6l{17st5tt5ou5qu}17s{ckuclucmucnucoucpu4lu4wu}5o{ckuclucmucnucoucpu4lu4wu}5q{ckzclzcmzcnzcozcpz4lz4wu}5r{ckxclxcmxcnxcoxcpx4lx4wu}5t{ckuclucmucnucoucpu4lu4wu}7q{ckuclucmucnucoucpu4lu}6p{17sw5tw5ou5qu}ek{17st5tt5qu}el{17st5tt5ou5qu}em{17st5tt5qu}en{17st5tt5qu}eo{17st5tt5qu}ep{17st5tt5ou5qu}es{17ss5ts5qu}et{17sw5tw5ou5qu}eu{17sw5tw5ou5qu}ev{17ss5ts5qu}6z{17sw5tw5ou5qu5rs}fm{17sw5tw5ou5qu5rs}fn{17sw5tw5ou5qu5rs}fo{17sw5tw5ou5qu5rs}fp{17sw5tw5ou5qu5rs}fq{17sw5tw5ou5qu5rs}7r{cktcltcmtcntcotcpt4lt5os}fs{17sw5tw5ou5qu5rs}ft{17su5tu5ou5qu}7m{5os}fv{17su5tu5ou5qu}fw{17su5tu5ou5qu}fz{cksclscmscnscoscps4ls}}}\"),Symbol:s(\"{'widths'{k3uaw4r19m3m2k1t2l2l202m2y2n3m2p5n202q6o3k3m2s2l2t2l2v3r2w1t3m3m2y1t2z1wbk2sbl3r'fof'6o3n3m3o3m3p3m3q3m3r3m3s3m3t3m3u1w3v1w3w3r3x3r3y3r3z2wbp3t3l3m5v2l5x2l5z3m2q4yfr3r7v3k7w1o7x3k}'kerning'{'fof'-6o}}\"),Helvetica:s(\"{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}\"),\"Helvetica-BoldOblique\":s(\"{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}\"),ZapfDingbats:s(\"{'widths'{k4u2k1w'fof'6o}'kerning'{'fof'-6o}}\"),\"Courier-Bold\":s(\"{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}\"),\"Times-Italic\":s(\"{'widths'{k3n2q4ycx2l201n3m201o5t201s2l201t2l201u2l201w3r201x3r201y3r2k1t2l2l202m2n2n3m2o3m2p5n202q5t2r1p2s2l2t2l2u3m2v4n2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w4n3x4n3y4n3z3m4k5w4l3x4m3x4n4m4o4s4p3x4q3x4r4s4s4s4t2l4u2w4v4m4w3r4x5n4y4m4z4s5k3x5l4s5m3x5n3m5o3r5p4s5q3x5r5n5s3x5t3r5u3r5v2r5w1w5x2r5y2u5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q1w6r3m6s3m6t1w6u1w6v2w6w1w6x4s6y3m6z3m7k3m7l3m7m2r7n2r7o1w7p3m7q2w7r4m7s2w7t2w7u2r7v2s7w1v7x2s7y3q202l3mcl3xal2ram3man3mao3map3mar3mas2lat4wau1vav3maw4nay4waz2lbk2sbl4n'fof'6obo2lbp3mbq3obr1tbs2lbu1zbv3mbz3mck3x202k3mcm3xcn3xco3xcp3xcq5tcr4mcs3xct3xcu3xcv3xcw2l2m2ucy2lcz2ldl4mdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr4nfs3mft3mfu3mfv3mfw3mfz2w203k6o212m6m2dw2l2cq2l3t3m3u2l17s3r19m3m}'kerning'{cl{5kt4qw}201s{201sw}201t{201tw2wy2yy6q-t}201x{2wy2yy}2k{201tw}2w{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}2x{17ss5ts5os}2y{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}'fof'-6o6t{17ss5ts5qs}7t{5os}3v{5qs}7p{17su5tu5qs}ck{5kt4qw}4l{5kt4qw}cm{5kt4qw}cn{5kt4qw}co{5kt4qw}cp{5kt4qw}6l{4qs5ks5ou5qw5ru17su5tu}17s{2ks}5q{ckvclvcmvcnvcovcpv4lv}5r{ckuclucmucnucoucpu4lu}5t{2ks}6p{4qs5ks5ou5qw5ru17su5tu}ek{4qs5ks5ou5qw5ru17su5tu}el{4qs5ks5ou5qw5ru17su5tu}em{4qs5ks5ou5qw5ru17su5tu}en{4qs5ks5ou5qw5ru17su5tu}eo{4qs5ks5ou5qw5ru17su5tu}ep{4qs5ks5ou5qw5ru17su5tu}es{5ks5qs4qs}et{4qs5ks5ou5qw5ru17su5tu}eu{4qs5ks5qw5ru17su5tu}ev{5ks5qs4qs}ex{17ss5ts5qs}6z{4qv5ks5ou5qw5ru17su5tu}fm{4qv5ks5ou5qw5ru17su5tu}fn{4qv5ks5ou5qw5ru17su5tu}fo{4qv5ks5ou5qw5ru17su5tu}fp{4qv5ks5ou5qw5ru17su5tu}fq{4qv5ks5ou5qw5ru17su5tu}7r{5os}fs{4qv5ks5ou5qw5ru17su5tu}ft{17su5tu5qs}fu{17su5tu5qs}fv{17su5tu5qs}fw{17su5tu5qs}}}\"),\"Times-Roman\":s(\"{'widths'{k3n2q4ycx2l201n3m201o6o201s2l201t2l201u2l201w2w201x2w201y2w2k1t2l2l202m2n2n3m2o3m2p5n202q6o2r1m2s2l2t2l2u3m2v3s2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v1w3w3s3x3s3y3s3z2w4k5w4l4s4m4m4n4m4o4s4p3x4q3r4r4s4s4s4t2l4u2r4v4s4w3x4x5t4y4s4z4s5k3r5l4s5m4m5n3r5o3x5p4s5q4s5r5y5s4s5t4s5u3x5v2l5w1w5x2l5y2z5z3m6k2l6l2w6m3m6n2w6o3m6p2w6q2l6r3m6s3m6t1w6u1w6v3m6w1w6x4y6y3m6z3m7k3m7l3m7m2l7n2r7o1w7p3m7q3m7r4s7s3m7t3m7u2w7v3k7w1o7x3k7y3q202l3mcl4sal2lam3man3mao3map3mar3mas2lat4wau1vav3maw3say4waz2lbk2sbl3s'fof'6obo2lbp3mbq2xbr1tbs2lbu1zbv3mbz2wck4s202k3mcm4scn4sco4scp4scq5tcr4mcs3xct3xcu3xcv3xcw2l2m2tcy2lcz2ldl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek2wel2wem2wen2weo2wep2weq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr3sfs3mft3mfu3mfv3mfw3mfz3m203k6o212m6m2dw2l2cq2l3t3m3u1w17s4s19m3m}'kerning'{cl{4qs5ku17sw5ou5qy5rw201ss5tw201ws}201s{201ss}201t{ckw4lwcmwcnwcowcpwclw4wu201ts}2k{201ts}2w{4qs5kw5os5qx5ru17sx5tx}2x{17sw5tw5ou5qu}2y{4qs5kw5os5qx5ru17sx5tx}'fof'-6o7t{ckuclucmucnucoucpu4lu5os5rs}3u{17su5tu5qs}3v{17su5tu5qs}7p{17sw5tw5qs}ck{4qs5ku17sw5ou5qy5rw201ss5tw201ws}4l{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cm{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cn{4qs5ku17sw5ou5qy5rw201ss5tw201ws}co{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cp{4qs5ku17sw5ou5qy5rw201ss5tw201ws}6l{17su5tu5os5qw5rs}17s{2ktclvcmvcnvcovcpv4lv4wuckv}5o{ckwclwcmwcnwcowcpw4lw4wu}5q{ckyclycmycnycoycpy4ly4wu5ms}5r{cktcltcmtcntcotcpt4lt4ws}5t{2ktclvcmvcnvcovcpv4lv4wuckv}7q{cksclscmscnscoscps4ls}6p{17su5tu5qw5rs}ek{5qs5rs}el{17su5tu5os5qw5rs}em{17su5tu5os5qs5rs}en{17su5qs5rs}eo{5qs5rs}ep{17su5tu5os5qw5rs}es{5qs}et{17su5tu5qw5rs}eu{17su5tu5qs5rs}ev{5qs}6z{17sv5tv5os5qx5rs}fm{5os5qt5rs}fn{17sv5tv5os5qx5rs}fo{17sv5tv5os5qx5rs}fp{5os5qt5rs}fq{5os5qt5rs}7r{ckuclucmucnucoucpu4lu5os}fs{17sv5tv5os5qx5rs}ft{17ss5ts5qs}fu{17sw5tw5qs}fv{17sw5tw5qs}fw{17ss5ts5qs}fz{ckuclucmucnucoucpu4lu5os5rs}}}\"),\"Helvetica-Oblique\":s(\"{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}\")}};t.events.push([\"addFont\",function(t){var e=t.font,n=h.Unicode[e.postScriptName];n&&(e.metadata.Unicode={},e.metadata.Unicode.widths=n.widths,e.metadata.Unicode.kerning=n.kerning);var r=c.Unicode[e.postScriptName];r&&(e.metadata.Unicode.encoding=r,e.encoding=r.codePages[0])}])}(g.API),\n/**\n * @license\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */\nfunction(t){var e=function(t){for(var e=t.length,n=new Uint8Array(e),r=0;r<e;r++)n[r]=t.charCodeAt(r);return n};t.API.events.push([\"addFont\",function(n){var r=void 0,i=n.font,a=n.instance;if(!i.isStandardFont){if(void 0===a)throw new Error(\"Font does not exist in vFS, import fonts or remove declaration doc.addFont('\"+i.postScriptName+\"').\");if(\"string\"!=typeof(r=!1===a.existsFileInVFS(i.postScriptName)?a.loadFile(i.postScriptName):a.getFileFromVFS(i.postScriptName)))throw new Error(\"Font is not stored as string-data in vFS, import fonts or remove declaration doc.addFont('\"+i.postScriptName+\"').\");!function(n,r){r=/^\\x00\\x01\\x00\\x00/.test(r)?e(r):e(o(r)),n.metadata=t.API.TTFFont.open(r),n.metadata.Unicode=n.metadata.Unicode||{encoding:{},kerning:{},widths:[]},n.metadata.glyIdsUsed=[0]}(i,r)}}])}(g),\n/** @license\n * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n * ====================================================================\n */\nfunction(e){function r(){return(t.canvg?Promise.resolve(t.canvg):import(\"canvg\")).catch((function(t){return Promise.reject(new Error(\"Could not load dompurify: \"+t))})).then((function(t){return t.default?t.default:t}))}g.API.addSvgAsImage=function(t,e,i,a,o,s,u,c){if(isNaN(e)||isNaN(i))throw n.error(\"jsPDF.addSvgAsImage: Invalid coordinates\",arguments),new Error(\"Invalid coordinates passed to jsPDF.addSvgAsImage\");if(isNaN(a)||isNaN(o))throw n.error(\"jsPDF.addSvgAsImage: Invalid measurements\",arguments),new Error(\"Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage\");var h=document.createElement(\"canvas\");h.width=a,h.height=o;var l=h.getContext(\"2d\");l.fillStyle=\"#fff\",l.fillRect(0,0,h.width,h.height);var f={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},d=this;return r().then((function(e){return e.Canvg.fromString(l,t,f)}),(function(){return Promise.reject(new Error(\"Could not load canvg.\"))})).then((function(t){return t.render(f)})).then((function(){d.addImage(h.toDataURL(\"image/jpeg\",1),e,i,a,o,u,c)}))}}(),g.API.putTotalPages=function(t){var e,n=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(e=new RegExp(t,\"g\"),n=this.internal.getNumberOfPages()):(e=new RegExp(this.pdfEscape16(t,this.internal.getFont()),\"g\"),n=this.pdfEscape16(this.internal.getNumberOfPages()+\"\",this.internal.getFont()));for(var r=1;r<=this.internal.getNumberOfPages();r++)for(var i=0;i<this.internal.pages[r].length;i++)this.internal.pages[r][i]=this.internal.pages[r][i].replace(e,n);return this},g.API.viewerPreferences=function(t,e){var n;t=t||{},e=e||!1;var r,i,a,o={HideToolbar:{defaultValue:!1,value:!1,type:\"boolean\",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideMenubar:{defaultValue:!1,value:!1,type:\"boolean\",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideWindowUI:{defaultValue:!1,value:!1,type:\"boolean\",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},FitWindow:{defaultValue:!1,value:!1,type:\"boolean\",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},CenterWindow:{defaultValue:!1,value:!1,type:\"boolean\",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},DisplayDocTitle:{defaultValue:!1,value:!1,type:\"boolean\",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.4},NonFullScreenPageMode:{defaultValue:\"UseNone\",value:\"UseNone\",type:\"name\",explicitSet:!1,valueSet:[\"UseNone\",\"UseOutlines\",\"UseThumbs\",\"UseOC\"],pdfVersion:1.3},Direction:{defaultValue:\"L2R\",value:\"L2R\",type:\"name\",explicitSet:!1,valueSet:[\"L2R\",\"R2L\"],pdfVersion:1.3},ViewArea:{defaultValue:\"CropBox\",value:\"CropBox\",type:\"name\",explicitSet:!1,valueSet:[\"MediaBox\",\"CropBox\",\"TrimBox\",\"BleedBox\",\"ArtBox\"],pdfVersion:1.4},ViewClip:{defaultValue:\"CropBox\",value:\"CropBox\",type:\"name\",explicitSet:!1,valueSet:[\"MediaBox\",\"CropBox\",\"TrimBox\",\"BleedBox\",\"ArtBox\"],pdfVersion:1.4},PrintArea:{defaultValue:\"CropBox\",value:\"CropBox\",type:\"name\",explicitSet:!1,valueSet:[\"MediaBox\",\"CropBox\",\"TrimBox\",\"BleedBox\",\"ArtBox\"],pdfVersion:1.4},PrintClip:{defaultValue:\"CropBox\",value:\"CropBox\",type:\"name\",explicitSet:!1,valueSet:[\"MediaBox\",\"CropBox\",\"TrimBox\",\"BleedBox\",\"ArtBox\"],pdfVersion:1.4},PrintScaling:{defaultValue:\"AppDefault\",value:\"AppDefault\",type:\"name\",explicitSet:!1,valueSet:[\"AppDefault\",\"None\"],pdfVersion:1.6},Duplex:{defaultValue:\"\",value:\"none\",type:\"name\",explicitSet:!1,valueSet:[\"Simplex\",\"DuplexFlipShortEdge\",\"DuplexFlipLongEdge\",\"none\"],pdfVersion:1.7},PickTrayByPDFSize:{defaultValue:!1,value:!1,type:\"boolean\",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.7},PrintPageRange:{defaultValue:\"\",value:\"\",type:\"array\",explicitSet:!1,valueSet:null,pdfVersion:1.7},NumCopies:{defaultValue:1,value:1,type:\"integer\",explicitSet:!1,valueSet:null,pdfVersion:1.7}},s=Object.keys(o),u=[],c=0,h=0,l=0;function f(t,e){var n,r=!1;for(n=0;n<t.length;n+=1)t[n]===e&&(r=!0);return r}if(void 0===this.internal.viewerpreferences&&(this.internal.viewerpreferences={},this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(o)),this.internal.viewerpreferences.isSubscribed=!1),n=this.internal.viewerpreferences.configuration,\"reset\"===t||!0===e){var d=s.length;for(l=0;l<d;l+=1)n[s[l]].value=n[s[l]].defaultValue,n[s[l]].explicitSet=!1}if(\"object\"==typeof t)for(i in t)if(a=t[i],f(s,i)&&void 0!==a){if(\"boolean\"===n[i].type&&\"boolean\"==typeof a)n[i].value=a;else if(\"name\"===n[i].type&&f(n[i].valueSet,a))n[i].value=a;else if(\"integer\"===n[i].type&&Number.isInteger(a))n[i].value=a;else if(\"array\"===n[i].type){for(c=0;c<a.length;c+=1)if(r=!0,1===a[c].length&&\"number\"==typeof a[c][0])u.push(String(a[c]-1));else if(a[c].length>1){for(h=0;h<a[c].length;h+=1)\"number\"!=typeof a[c][h]&&(r=!1);!0===r&&u.push([a[c][0]-1,a[c][1]-1].join(\" \"))}n[i].value=\"[\"+u.join(\" \")+\"]\"}else n[i].value=n[i].defaultValue;n[i].explicitSet=!0}return!1===this.internal.viewerpreferences.isSubscribed&&(this.internal.events.subscribe(\"putCatalog\",(function(){var t,e=[];for(t in n)!0===n[t].explicitSet&&(\"name\"===n[t].type?e.push(\"/\"+t+\" /\"+n[t].value):e.push(\"/\"+t+\" \"+n[t].value));0!==e.length&&this.internal.write(\"/ViewerPreferences\\n<<\\n\"+e.join(\"\\n\")+\"\\n>>\")})),this.internal.viewerpreferences.isSubscribed=!0),this.internal.viewerpreferences.configuration=n,this},\n/** ====================================================================\n * @license\n * jsPDF XMP metadata plugin\n * Copyright (c) 2016 Jussi Utunen, u-jussi@suomi24.fi\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n * ====================================================================\n */\nfunction(t){var e=function(){var t='<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"><rdf:Description rdf:about=\"\" xmlns:jspdf=\"'+this.internal.__metadata__.namespaceuri+'\"><jspdf:metadata>',e=unescape(encodeURIComponent('<x:xmpmeta xmlns:x=\"adobe:ns:meta/\">')),n=unescape(encodeURIComponent(t)),r=unescape(encodeURIComponent(this.internal.__metadata__.metadata)),i=unescape(encodeURIComponent(\"</jspdf:metadata></rdf:Description></rdf:RDF>\")),a=unescape(encodeURIComponent(\"</x:xmpmeta>\")),o=n.length+r.length+i.length+e.length+a.length;this.internal.__metadata__.metadata_object_number=this.internal.newObject(),this.internal.write(\"<< /Type /Metadata /Subtype /XML /Length \"+o+\" >>\"),this.internal.write(\"stream\"),this.internal.write(e+n+r+i+a),this.internal.write(\"endstream\"),this.internal.write(\"endobj\")},n=function(){this.internal.__metadata__.metadata_object_number&&this.internal.write(\"/Metadata \"+this.internal.__metadata__.metadata_object_number+\" 0 R\")};t.addMetadata=function(t,r){return void 0===this.internal.__metadata__&&(this.internal.__metadata__={metadata:t,namespaceuri:r||\"http://jspdf.default.namespaceuri/\"},this.internal.events.subscribe(\"putCatalog\",n),this.internal.events.subscribe(\"postPutResources\",e)),this}}(g.API),function(t){var e=t.API,n=e.pdfEscape16=function(t,e){for(var n,r=e.metadata.Unicode.widths,i=[\"\",\"0\",\"00\",\"000\",\"0000\"],a=[\"\"],o=0,s=t.length;o<s;++o){if(n=e.metadata.characterToGlyph(t.charCodeAt(o)),e.metadata.glyIdsUsed.push(n),e.metadata.toUnicode[n]=t.charCodeAt(o),-1==r.indexOf(n)&&(r.push(n),r.push([parseInt(e.metadata.widthOfGlyph(n),10)])),\"0\"==n)return a.join(\"\");n=n.toString(16),a.push(i[4-n.length],n)}return a.join(\"\")},r=function(t){var e,n,r,i,a,o,s;for(a=\"/CIDInit /ProcSet findresource begin\\n12 dict begin\\nbegincmap\\n/CIDSystemInfo <<\\n /Registry (Adobe)\\n /Ordering (UCS)\\n /Supplement 0\\n>> def\\n/CMapName /Adobe-Identity-UCS def\\n/CMapType 2 def\\n1 begincodespacerange\\n<0000><ffff>\\nendcodespacerange\",r=[],o=0,s=(n=Object.keys(t).sort((function(t,e){return t-e}))).length;o<s;o++)e=n[o],r.length>=100&&(a+=\"\\n\"+r.length+\" beginbfchar\\n\"+r.join(\"\\n\")+\"\\nendbfchar\",r=[]),void 0!==t[e]&&null!==t[e]&&\"function\"==typeof t[e].toString&&(i=(\"0000\"+t[e].toString(16)).slice(-4),e=(\"0000\"+(+e).toString(16)).slice(-4),r.push(\"<\"+e+\"><\"+i+\">\"));return r.length&&(a+=\"\\n\"+r.length+\" beginbfchar\\n\"+r.join(\"\\n\")+\"\\nendbfchar\\n\"),a+=\"endcmap\\nCMapName currentdict /CMap defineresource pop\\nend\\nend\"};e.events.push([\"putFont\",function(e){!function(e){var n=e.font,i=e.out,a=e.newObject,o=e.putStream,s=e.pdfEscapeWithNeededParanthesis;if(n.metadata instanceof t.API.TTFFont&&\"Identity-H\"===n.encoding){for(var u=n.metadata.Unicode.widths,c=n.metadata.subset.encode(n.metadata.glyIdsUsed,1),h=\"\",l=0;l<c.length;l++)h+=String.fromCharCode(c[l]);var f=a();o({data:h,addLength1:!0}),i(\"endobj\");var d=a();o({data:r(n.metadata.toUnicode),addLength1:!0}),i(\"endobj\");var p=a();i(\"<<\"),i(\"/Type /FontDescriptor\"),i(\"/FontName /\"+s(n.fontName)),i(\"/FontFile2 \"+f+\" 0 R\"),i(\"/FontBBox \"+t.API.PDFObject.convert(n.metadata.bbox)),i(\"/Flags \"+n.metadata.flags),i(\"/StemV \"+n.metadata.stemV),i(\"/ItalicAngle \"+n.metadata.italicAngle),i(\"/Ascent \"+n.metadata.ascender),i(\"/Descent \"+n.metadata.decender),i(\"/CapHeight \"+n.metadata.capHeight),i(\">>\"),i(\"endobj\");var g=a();i(\"<<\"),i(\"/Type /Font\"),i(\"/BaseFont /\"+s(n.fontName)),i(\"/FontDescriptor \"+p+\" 0 R\"),i(\"/W \"+t.API.PDFObject.convert(u)),i(\"/CIDToGIDMap /Identity\"),i(\"/DW 1000\"),i(\"/Subtype /CIDFontType2\"),i(\"/CIDSystemInfo\"),i(\"<<\"),i(\"/Supplement 0\"),i(\"/Registry (Adobe)\"),i(\"/Ordering (\"+n.encoding+\")\"),i(\">>\"),i(\">>\"),i(\"endobj\"),n.objectNumber=a(),i(\"<<\"),i(\"/Type /Font\"),i(\"/Subtype /Type0\"),i(\"/ToUnicode \"+d+\" 0 R\"),i(\"/BaseFont /\"+s(n.fontName)),i(\"/Encoding /\"+n.encoding),i(\"/DescendantFonts [\"+g+\" 0 R]\"),i(\">>\"),i(\"endobj\"),n.isAlreadyPutted=!0}}(e)}]);e.events.push([\"putFont\",function(e){!function(e){var n=e.font,i=e.out,a=e.newObject,o=e.putStream,s=e.pdfEscapeWithNeededParanthesis;if(n.metadata instanceof t.API.TTFFont&&\"WinAnsiEncoding\"===n.encoding){for(var u=n.metadata.rawData,c=\"\",h=0;h<u.length;h++)c+=String.fromCharCode(u[h]);var l=a();o({data:c,addLength1:!0}),i(\"endobj\");var f=a();o({data:r(n.metadata.toUnicode),addLength1:!0}),i(\"endobj\");var d=a();i(\"<<\"),i(\"/Descent \"+n.metadata.decender),i(\"/CapHeight \"+n.metadata.capHeight),i(\"/StemV \"+n.metadata.stemV),i(\"/Type /FontDescriptor\"),i(\"/FontFile2 \"+l+\" 0 R\"),i(\"/Flags 96\"),i(\"/FontBBox \"+t.API.PDFObject.convert(n.metadata.bbox)),i(\"/FontName /\"+s(n.fontName)),i(\"/ItalicAngle \"+n.metadata.italicAngle),i(\"/Ascent \"+n.metadata.ascender),i(\">>\"),i(\"endobj\"),n.objectNumber=a();for(var p=0;p<n.metadata.hmtx.widths.length;p++)n.metadata.hmtx.widths[p]=parseInt(n.metadata.hmtx.widths[p]*(1e3/n.metadata.head.unitsPerEm));i(\"<</Subtype/TrueType/Type/Font/ToUnicode \"+f+\" 0 R/BaseFont/\"+n.fontName+\"/FontDescriptor \"+d+\" 0 R/Encoding/\"+n.encoding+\" /FirstChar 29 /LastChar 255 /Widths \"+t.API.PDFObject.convert(n.metadata.hmtx.widths)+\">>\"),i(\"endobj\"),n.isAlreadyPutted=!0}}(e)}]);var i=function(t){var e,r=t.text||\"\",i=t.x,a=t.y,o=t.options||{},s=t.mutex||{},u=s.pdfEscape,c=s.activeFontKey,h=s.fonts,l=c,f=\"\",d=0,p=\"\",g=h[l].encoding;if(\"Identity-H\"!==h[l].encoding)return{text:r,x:i,y:a,options:o,mutex:s};for(p=r,l=c,Array.isArray(r)&&(p=r[0]),d=0;d<p.length;d+=1)h[l].metadata.hasOwnProperty(\"cmap\")&&(e=h[l].metadata.cmap.unicode.codeMap[p[d].charCodeAt(0)]),e||p[d].charCodeAt(0)<256&&h[l].metadata.hasOwnProperty(\"Unicode\")?f+=p[d]:f+=\"\";var m=\"\";return parseInt(l.slice(1))<14||\"WinAnsiEncoding\"===g?m=u(f,l).split(\"\").map((function(t){return t.charCodeAt(0).toString(16)})).join(\"\"):\"Identity-H\"===g&&(m=n(f,h[l])),s.isHex=!0,{text:m,x:i,y:a,options:o,mutex:s}};e.events.push([\"postProcessText\",function(t){var e=t.text||\"\",n=[],r={text:e,x:t.x,y:t.y,options:t.options,mutex:t.mutex};if(Array.isArray(e)){var a=0;for(a=0;a<e.length;a+=1)Array.isArray(e[a])&&3===e[a].length?n.push([i(Object.assign({},r,{text:e[a][0]})).text,e[a][1],e[a][2]]):n.push(i(Object.assign({},r,{text:e[a]})).text);t.text=n}else t.text=i(Object.assign({},r,{text:e})).text}])}(g),\n/**\n * @license\n * jsPDF virtual FileSystem functionality\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */\nfunction(t){var e=function(){return void 0===this.internal.vFS&&(this.internal.vFS={}),!0};t.existsFileInVFS=function(t){return e.call(this),void 0!==this.internal.vFS[t]},t.addFileToVFS=function(t,n){return e.call(this),this.internal.vFS[t]=n,this},t.getFileFromVFS=function(t){return e.call(this),void 0!==this.internal.vFS[t]?this.internal.vFS[t]:null}}(g.API),\n/**\n * @license\n * Unicode Bidi Engine based on the work of Alex Shensis (@asthensis)\n * MIT License\n */\nfunction(t){t.__bidiEngine__=t.prototype.__bidiEngine__=function(t){var n,r,i,a,o,s,u,c=e,h=[[0,3,0,1,0,0,0],[0,3,0,1,2,2,0],[0,3,0,17,2,0,1],[0,3,5,5,4,1,0],[0,3,21,21,4,0,1],[0,3,5,5,4,2,0]],l=[[2,0,1,1,0,1,0],[2,0,1,1,0,2,0],[2,0,2,1,3,2,0],[2,0,2,33,3,1,1]],f={L:0,R:1,EN:2,AN:3,N:4,B:5,S:6},d={0:0,5:1,6:2,7:3,32:4,251:5,254:6,255:7},p=[\"(\",\")\",\"(\",\"<\",\">\",\"<\",\"[\",\"]\",\"[\",\"{\",\"}\",\"{\",\"«\",\"»\",\"«\",\"‹\",\"›\",\"‹\",\"⁅\",\"⁆\",\"⁅\",\"⁽\",\"⁾\",\"⁽\",\"₍\",\"₎\",\"₍\",\"≤\",\"≥\",\"≤\",\"〈\",\"〉\",\"〈\",\"﹙\",\"﹚\",\"﹙\",\"﹛\",\"﹜\",\"﹛\",\"﹝\",\"﹞\",\"﹝\",\"﹤\",\"﹥\",\"﹤\"],g=new RegExp(/^([1-4|9]|1[0-9]|2[0-9]|3[0168]|4[04589]|5[012]|7[78]|159|16[0-9]|17[0-2]|21[569]|22[03489]|250)$/),m=!1,v=0;this.__bidiEngine__={};var b=function(t){var e=t.charCodeAt(),n=e>>8,r=d[n];return void 0!==r?c[256*r+(255&e)]:252===n||253===n?\"AL\":g.test(n)?\"L\":8===n?\"R\":\"N\"},y=function(t){for(var e,n=0;n<t.length;n++){if(\"L\"===(e=b(t.charAt(n))))return!1;if(\"R\"===e)return!0}return!1},w=function(t,e,o,s){var u,c,h,l,f=e[s];switch(f){case\"L\":case\"R\":m=!1;break;case\"N\":case\"AN\":break;case\"EN\":m&&(f=\"AN\");break;case\"AL\":m=!0,f=\"R\";break;case\"WS\":f=\"N\";break;case\"CS\":s<1||s+1>=e.length||\"EN\"!==(u=o[s-1])&&\"AN\"!==u||\"EN\"!==(c=e[s+1])&&\"AN\"!==c?f=\"N\":m&&(c=\"AN\"),f=c===u?c:\"N\";break;case\"ES\":f=\"EN\"===(u=s>0?o[s-1]:\"B\")&&s+1<e.length&&\"EN\"===e[s+1]?\"EN\":\"N\";break;case\"ET\":if(s>0&&\"EN\"===o[s-1]){f=\"EN\";break}if(m){f=\"N\";break}for(h=s+1,l=e.length;h<l&&\"ET\"===e[h];)h++;f=h<l&&\"EN\"===e[h]?\"EN\":\"N\";break;case\"NSM\":if(i&&!a){for(l=e.length,h=s+1;h<l&&\"NSM\"===e[h];)h++;if(h<l){var d=t[s],p=d>=1425&&d<=2303||64286===d;if(u=e[h],p&&(\"R\"===u||\"AL\"===u)){f=\"R\";break}}}f=s<1||\"B\"===(u=e[s-1])?\"N\":o[s-1];break;case\"B\":m=!1,n=!0,f=v;break;case\"S\":r=!0,f=\"N\";break;case\"LRE\":case\"RLE\":case\"LRO\":case\"RLO\":case\"PDF\":m=!1;break;case\"BN\":f=\"N\"}return f},N=function(t,e,n){var r=t.split(\"\");return n&&L(r,n,{hiLevel:v}),r.reverse(),e&&e.reverse(),r.join(\"\")},L=function(t,e,i){var a,o,s,u,c,d=-1,p=t.length,g=0,y=[],N=v?l:h,L=[];for(m=!1,n=!1,r=!1,o=0;o<p;o++)L[o]=b(t[o]);for(s=0;s<p;s++){if(c=g,y[s]=w(t,L,y,s),a=240&(g=N[c][f[y[s]]]),g&=15,e[s]=u=N[g][5],a>0)if(16===a){for(o=d;o<s;o++)e[o]=1;d=-1}else d=-1;if(N[g][6])-1===d&&(d=s);else if(d>-1){for(o=d;o<s;o++)e[o]=u;d=-1}\"B\"===L[s]&&(e[s]=0),i.hiLevel|=u}r&&function(t,e,n){for(var r=0;r<n;r++)if(\"S\"===t[r]){e[r]=v;for(var i=r-1;i>=0&&\"WS\"===t[i];i--)e[i]=v}}(L,e,p)},x=function(t,e,r,i,a){if(!(a.hiLevel<t)){if(1===t&&1===v&&!n)return e.reverse(),void(r&&r.reverse());for(var o,s,u,c,h=e.length,l=0;l<h;){if(i[l]>=t){for(u=l+1;u<h&&i[u]>=t;)u++;for(c=l,s=u-1;c<s;c++,s--)o=e[c],e[c]=e[s],e[s]=o,r&&(o=r[c],r[c]=r[s],r[s]=o);l=u}l++}}},A=function(t,e,n){var r=t.split(\"\"),i={hiLevel:v};return n||(n=[]),L(r,n,i),function(t,e,n){if(0!==n.hiLevel&&u)for(var r,i=0;i<t.length;i++)1===e[i]&&(r=p.indexOf(t[i]))>=0&&(t[i]=p[r+1])}(r,n,i),x(2,r,e,n,i),x(1,r,e,n,i),r.join(\"\")};return this.__bidiEngine__.doBidiReorder=function(t,e,n){if(function(t,e){if(e)for(var n=0;n<t.length;n++)e[n]=n;void 0===a&&(a=y(t)),void 0===s&&(s=y(t))}(t,e),i||!o||s)if(i&&o&&a^s)v=a?1:0,t=N(t,e,n);else if(!i&&o&&s)v=a?1:0,t=A(t,e,n),t=N(t,e);else if(!i||a||o||s){if(i&&!o&&a^s)t=N(t,e),a?(v=0,t=A(t,e,n)):(v=1,t=A(t,e,n),t=N(t,e));else if(i&&a&&!o&&s)v=1,t=A(t,e,n),t=N(t,e);else if(!i&&!o&&a^s){var r=u;a?(v=1,t=A(t,e,n),v=0,u=!1,t=A(t,e,n),u=r):(v=0,t=A(t,e,n),t=N(t,e),v=1,u=!1,t=A(t,e,n),u=r,t=N(t,e))}}else v=0,t=A(t,e,n);else v=a?1:0,t=A(t,e,n);return t},this.__bidiEngine__.setOptions=function(t){t&&(i=t.isInputVisual,o=t.isOutputVisual,a=t.isInputRtl,s=t.isOutputRtl,u=t.isSymmetricSwapping)},this.__bidiEngine__.setOptions(t),this.__bidiEngine__};var e=[\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"S\",\"B\",\"S\",\"WS\",\"B\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"B\",\"B\",\"B\",\"S\",\"WS\",\"N\",\"N\",\"ET\",\"ET\",\"ET\",\"N\",\"N\",\"N\",\"N\",\"N\",\"ES\",\"CS\",\"ES\",\"CS\",\"CS\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"CS\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"N\",\"N\",\"N\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"B\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"CS\",\"N\",\"ET\",\"ET\",\"ET\",\"ET\",\"N\",\"N\",\"N\",\"N\",\"L\",\"N\",\"N\",\"BN\",\"N\",\"N\",\"ET\",\"ET\",\"EN\",\"EN\",\"N\",\"L\",\"N\",\"N\",\"N\",\"EN\",\"L\",\"N\",\"N\",\"N\",\"N\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"L\",\"N\",\"N\",\"N\",\"N\",\"N\",\"ET\",\"N\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"R\",\"NSM\",\"R\",\"NSM\",\"NSM\",\"R\",\"NSM\",\"NSM\",\"R\",\"NSM\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"N\",\"N\",\"N\",\"N\",\"N\",\"R\",\"R\",\"R\",\"R\",\"R\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"AN\",\"AN\",\"AN\",\"AN\",\"AN\",\"AN\",\"N\",\"N\",\"AL\",\"ET\",\"ET\",\"AL\",\"CS\",\"AL\",\"N\",\"N\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"AL\",\"AL\",\"N\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"AN\",\"AN\",\"AN\",\"AN\",\"AN\",\"AN\",\"AN\",\"AN\",\"AN\",\"AN\",\"ET\",\"AN\",\"AN\",\"AL\",\"AL\",\"AL\",\"NSM\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"AN\",\"N\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"AL\",\"AL\",\"NSM\",\"NSM\",\"N\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"AL\",\"AL\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"N\",\"AL\",\"AL\",\"NSM\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"N\",\"N\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"AL\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"R\",\"R\",\"N\",\"N\",\"N\",\"N\",\"R\",\"N\",\"N\",\"N\",\"N\",\"N\",\"WS\",\"WS\",\"WS\",\"WS\",\"WS\",\"WS\",\"WS\",\"WS\",\"WS\",\"WS\",\"WS\",\"BN\",\"BN\",\"BN\",\"L\",\"R\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"WS\",\"B\",\"LRE\",\"RLE\",\"PDF\",\"LRO\",\"RLO\",\"CS\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"CS\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"WS\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"N\",\"LRI\",\"RLI\",\"FSI\",\"PDI\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"BN\",\"EN\",\"L\",\"N\",\"N\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"ES\",\"ES\",\"N\",\"N\",\"N\",\"L\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"ES\",\"ES\",\"N\",\"N\",\"N\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"N\",\"N\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"ET\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"N\",\"N\",\"N\",\"N\",\"R\",\"NSM\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"ES\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"N\",\"R\",\"R\",\"R\",\"R\",\"R\",\"N\",\"R\",\"N\",\"R\",\"R\",\"N\",\"R\",\"R\",\"N\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"NSM\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"CS\",\"N\",\"CS\",\"N\",\"N\",\"CS\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"ET\",\"N\",\"N\",\"ES\",\"ES\",\"N\",\"N\",\"N\",\"N\",\"N\",\"ET\",\"ET\",\"N\",\"N\",\"N\",\"N\",\"N\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"N\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"AL\",\"N\",\"N\",\"BN\",\"N\",\"N\",\"N\",\"ET\",\"ET\",\"ET\",\"N\",\"N\",\"N\",\"N\",\"N\",\"ES\",\"CS\",\"ES\",\"CS\",\"CS\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"EN\",\"CS\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"N\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"N\",\"L\",\"L\",\"L\",\"L\",\"L\",\"L\",\"N\",\"N\",\"L\",\"L\",\"L\",\"N\",\"N\",\"N\",\"ET\",\"ET\",\"N\",\"N\",\"N\",\"ET\",\"ET\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\",\"N\"],n=new t.__bidiEngine__({isInputVisual:!0});t.API.events.push([\"postProcessText\",function(t){var e=t.text,r=(t.x,t.y,t.options||{}),i=(t.mutex,r.lang,[]);if(r.isInputVisual=\"boolean\"!=typeof r.isInputVisual||r.isInputVisual,n.setOptions(r),\"[object Array]\"===Object.prototype.toString.call(e)){var a=0;for(i=[],a=0;a<e.length;a+=1)\"[object Array]\"===Object.prototype.toString.call(e[a])?i.push([n.doBidiReorder(e[a][0]),e[a][1],e[a][2]]):i.push([n.doBidiReorder(e[a])]);t.text=i}else t.text=n.doBidiReorder(e);n.setOptions({isInputVisual:!0})}])}(g),g.API.TTFFont=function(){function t(t){var e;if(this.rawData=t,e=this.contents=new Rt(t),this.contents.pos=4,\"ttcf\"===e.readString(4))throw new Error(\"TTCF not supported.\");e.pos=0,this.parse(),this.subset=new re(this),this.registerTTF()}return t.open=function(e){return new t(e)},t.prototype.parse=function(){return this.directory=new Tt(this.contents),this.head=new zt(this),this.name=new Xt(this),this.cmap=new Wt(this),this.toUnicode={},this.hhea=new Vt(this),this.maxp=new Kt(this),this.hmtx=new Zt(this),this.post=new Yt(this),this.os2=new Gt(this),this.loca=new ne(this),this.glyf=new Qt(this),this.ascender=this.os2.exists&&this.os2.ascender||this.hhea.ascender,this.decender=this.os2.exists&&this.os2.decender||this.hhea.decender,this.lineGap=this.os2.exists&&this.os2.lineGap||this.hhea.lineGap,this.bbox=[this.head.xMin,this.head.yMin,this.head.xMax,this.head.yMax]},t.prototype.registerTTF=function(){var t,e,n,r,i;if(this.scaleFactor=1e3/this.head.unitsPerEm,this.bbox=function(){var e,n,r,i;for(i=[],e=0,n=(r=this.bbox).length;e<n;e++)t=r[e],i.push(Math.round(t*this.scaleFactor));return i}.call(this),this.stemV=0,this.post.exists?(n=255&(r=this.post.italic_angle),0!=(32768&(e=r>>16))&&(e=-(1+(65535^e))),this.italicAngle=+(e+\".\"+n)):this.italicAngle=0,this.ascender=Math.round(this.ascender*this.scaleFactor),this.decender=Math.round(this.decender*this.scaleFactor),this.lineGap=Math.round(this.lineGap*this.scaleFactor),this.capHeight=this.os2.exists&&this.os2.capHeight||this.ascender,this.xHeight=this.os2.exists&&this.os2.xHeight||0,this.familyClass=(this.os2.exists&&this.os2.familyClass||0)>>8,this.isSerif=1===(i=this.familyClass)||2===i||3===i||4===i||5===i||7===i,this.isScript=10===this.familyClass,this.flags=0,this.post.isFixedPitch&&(this.flags|=1),this.isSerif&&(this.flags|=2),this.isScript&&(this.flags|=8),0!==this.italicAngle&&(this.flags|=64),this.flags|=32,!this.cmap.unicode)throw new Error(\"No unicode cmap for font\")},t.prototype.characterToGlyph=function(t){var e;return(null!=(e=this.cmap.unicode)?e.codeMap[t]:void 0)||0},t.prototype.widthOfGlyph=function(t){var e;return e=1e3/this.head.unitsPerEm,this.hmtx.forGlyph(t).advance*e},t.prototype.widthOfString=function(t,e,n){var r,i,a,o;for(a=0,i=0,o=(t=\"\"+t).length;0<=o?i<o:i>o;i=0<=o?++i:--i)r=t.charCodeAt(i),a+=this.widthOfGlyph(this.characterToGlyph(r))+n*(1e3/e)||0;return a*(e/1e3)},t.prototype.lineHeight=function(t,e){var n;return null==e&&(e=!1),n=e?this.lineGap:0,(this.ascender+n-this.decender)/1e3*t},t}();var qt,Rt=function(){function t(t){this.data=null!=t?t:[],this.pos=0,this.length=this.data.length}return t.prototype.readByte=function(){return this.data[this.pos++]},t.prototype.writeByte=function(t){return this.data[this.pos++]=t},t.prototype.readUInt32=function(){return 16777216*this.readByte()+(this.readByte()<<16)+(this.readByte()<<8)+this.readByte()},t.prototype.writeUInt32=function(t){return this.writeByte(t>>>24&255),this.writeByte(t>>16&255),this.writeByte(t>>8&255),this.writeByte(255&t)},t.prototype.readInt32=function(){var t;return(t=this.readUInt32())>=2147483648?t-4294967296:t},t.prototype.writeInt32=function(t){return t<0&&(t+=4294967296),this.writeUInt32(t)},t.prototype.readUInt16=function(){return this.readByte()<<8|this.readByte()},t.prototype.writeUInt16=function(t){return this.writeByte(t>>8&255),this.writeByte(255&t)},t.prototype.readInt16=function(){var t;return(t=this.readUInt16())>=32768?t-65536:t},t.prototype.writeInt16=function(t){return t<0&&(t+=65536),this.writeUInt16(t)},t.prototype.readString=function(t){var e,n;for(n=[],e=0;0<=t?e<t:e>t;e=0<=t?++e:--e)n[e]=String.fromCharCode(this.readByte());return n.join(\"\")},t.prototype.writeString=function(t){var e,n,r;for(r=[],e=0,n=t.length;0<=n?e<n:e>n;e=0<=n?++e:--e)r.push(this.writeByte(t.charCodeAt(e)));return r},t.prototype.readShort=function(){return this.readInt16()},t.prototype.writeShort=function(t){return this.writeInt16(t)},t.prototype.readLongLong=function(){var t,e,n,r,i,a,o,s;return t=this.readByte(),e=this.readByte(),n=this.readByte(),r=this.readByte(),i=this.readByte(),a=this.readByte(),o=this.readByte(),s=this.readByte(),128&t?-1*(72057594037927940*(255^t)+281474976710656*(255^e)+1099511627776*(255^n)+4294967296*(255^r)+16777216*(255^i)+65536*(255^a)+256*(255^o)+(255^s)+1):72057594037927940*t+281474976710656*e+1099511627776*n+4294967296*r+16777216*i+65536*a+256*o+s},t.prototype.writeLongLong=function(t){var e,n;return e=Math.floor(t/4294967296),n=4294967295&t,this.writeByte(e>>24&255),this.writeByte(e>>16&255),this.writeByte(e>>8&255),this.writeByte(255&e),this.writeByte(n>>24&255),this.writeByte(n>>16&255),this.writeByte(n>>8&255),this.writeByte(255&n)},t.prototype.readInt=function(){return this.readInt32()},t.prototype.writeInt=function(t){return this.writeInt32(t)},t.prototype.read=function(t){var e,n;for(e=[],n=0;0<=t?n<t:n>t;n=0<=t?++n:--n)e.push(this.readByte());return e},t.prototype.write=function(t){var e,n,r,i;for(i=[],n=0,r=t.length;n<r;n++)e=t[n],i.push(this.writeByte(e));return i},t}(),Tt=function(){var t;function e(t){var e,n,r;for(this.scalarType=t.readInt(),this.tableCount=t.readShort(),this.searchRange=t.readShort(),this.entrySelector=t.readShort(),this.rangeShift=t.readShort(),this.tables={},n=0,r=this.tableCount;0<=r?n<r:n>r;n=0<=r?++n:--n)e={tag:t.readString(4),checksum:t.readInt(),offset:t.readInt(),length:t.readInt()},this.tables[e.tag]=e}return e.prototype.encode=function(e){var n,r,i,a,o,s,u,c,h,l,f,d,p;for(p in f=Object.keys(e).length,s=Math.log(2),h=16*Math.floor(Math.log(f)/s),a=Math.floor(h/s),c=16*f-h,(r=new Rt).writeInt(this.scalarType),r.writeShort(f),r.writeShort(h),r.writeShort(a),r.writeShort(c),i=16*f,u=r.pos+i,o=null,d=[],e)for(l=e[p],r.writeString(p),r.writeInt(t(l)),r.writeInt(u),r.writeInt(l.length),d=d.concat(l),\"head\"===p&&(o=u),u+=l.length;u%4;)d.push(0),u++;return r.write(d),n=2981146554-t(r.data),r.pos=o+8,r.writeUInt32(n),r.data},t=function(t){var e,n,r,i;for(t=$t.call(t);t.length%4;)t.push(0);for(r=new Rt(t),n=0,e=0,i=t.length;e<i;e=e+=4)n+=r.readUInt32();return 4294967295&n},e}(),Dt={}.hasOwnProperty,Ut=function(t,e){for(var n in e)Dt.call(e,n)&&(t[n]=e[n]);function r(){this.constructor=t}return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};qt=function(){function t(t){var e;this.file=t,e=this.file.directory.tables[this.tag],this.exists=!!e,e&&(this.offset=e.offset,this.length=e.length,this.parse(this.file.contents))}return t.prototype.parse=function(){},t.prototype.encode=function(){},t.prototype.raw=function(){return this.exists?(this.file.contents.pos=this.offset,this.file.contents.read(this.length)):null},t}();var zt=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return Ut(e,qt),e.prototype.tag=\"head\",e.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.revision=t.readInt(),this.checkSumAdjustment=t.readInt(),this.magicNumber=t.readInt(),this.flags=t.readShort(),this.unitsPerEm=t.readShort(),this.created=t.readLongLong(),this.modified=t.readLongLong(),this.xMin=t.readShort(),this.yMin=t.readShort(),this.xMax=t.readShort(),this.yMax=t.readShort(),this.macStyle=t.readShort(),this.lowestRecPPEM=t.readShort(),this.fontDirectionHint=t.readShort(),this.indexToLocFormat=t.readShort(),this.glyphDataFormat=t.readShort()},e.prototype.encode=function(t){var e;return(e=new Rt).writeInt(this.version),e.writeInt(this.revision),e.writeInt(this.checkSumAdjustment),e.writeInt(this.magicNumber),e.writeShort(this.flags),e.writeShort(this.unitsPerEm),e.writeLongLong(this.created),e.writeLongLong(this.modified),e.writeShort(this.xMin),e.writeShort(this.yMin),e.writeShort(this.xMax),e.writeShort(this.yMax),e.writeShort(this.macStyle),e.writeShort(this.lowestRecPPEM),e.writeShort(this.fontDirectionHint),e.writeShort(t),e.writeShort(this.glyphDataFormat),e.data},e}(),Ht=function(){function t(t,e){var n,r,i,a,o,s,u,c,h,l,f,d,p,g,m,v,b;switch(this.platformID=t.readUInt16(),this.encodingID=t.readShort(),this.offset=e+t.readInt(),h=t.pos,t.pos=this.offset,this.format=t.readUInt16(),this.length=t.readUInt16(),this.language=t.readUInt16(),this.isUnicode=3===this.platformID&&1===this.encodingID&&4===this.format||0===this.platformID&&4===this.format,this.codeMap={},this.format){case 0:for(s=0;s<256;++s)this.codeMap[s]=t.readByte();break;case 4:for(f=t.readUInt16(),l=f/2,t.pos+=6,i=function(){var e,n;for(n=[],s=e=0;0<=l?e<l:e>l;s=0<=l?++e:--e)n.push(t.readUInt16());return n}(),t.pos+=2,p=function(){var e,n;for(n=[],s=e=0;0<=l?e<l:e>l;s=0<=l?++e:--e)n.push(t.readUInt16());return n}(),u=function(){var e,n;for(n=[],s=e=0;0<=l?e<l:e>l;s=0<=l?++e:--e)n.push(t.readUInt16());return n}(),c=function(){var e,n;for(n=[],s=e=0;0<=l?e<l:e>l;s=0<=l?++e:--e)n.push(t.readUInt16());return n}(),r=(this.length-t.pos+this.offset)/2,o=function(){var e,n;for(n=[],s=e=0;0<=r?e<r:e>r;s=0<=r?++e:--e)n.push(t.readUInt16());return n}(),s=m=0,b=i.length;m<b;s=++m)for(g=i[s],n=v=d=p[s];d<=g?v<=g:v>=g;n=d<=g?++v:--v)0===c[s]?a=n+u[s]:0!==(a=o[c[s]/2+(n-d)-(l-s)]||0)&&(a+=u[s]),this.codeMap[n]=65535&a}t.pos=h}return t.encode=function(t,e){var n,r,i,a,o,s,u,c,h,l,f,d,p,g,m,v,b,y,w,N,L,x,A,_,S,P,k,F,I,C,j,B,O,M,E,q,R,T,D,U,z,H,W,V,G,Y;switch(F=new Rt,a=Object.keys(t).sort((function(t,e){return t-e})),e){case\"macroman\":for(p=0,g=function(){var t=[];for(d=0;d<256;++d)t.push(0);return t}(),v={0:0},i={},I=0,O=a.length;I<O;I++)null==v[W=t[r=a[I]]]&&(v[W]=++p),i[r]={old:t[r],new:v[t[r]]},g[r]=v[t[r]];return F.writeUInt16(1),F.writeUInt16(0),F.writeUInt32(12),F.writeUInt16(0),F.writeUInt16(262),F.writeUInt16(0),F.write(g),{charMap:i,subtable:F.data,maxGlyphID:p+1};case\"unicode\":for(P=[],h=[],b=0,v={},n={},m=u=null,C=0,M=a.length;C<M;C++)null==v[w=t[r=a[C]]]&&(v[w]=++b),n[r]={old:w,new:v[w]},o=v[w]-r,null!=m&&o===u||(m&&h.push(m),P.push(r),u=o),m=r;for(m&&h.push(m),h.push(65535),P.push(65535),_=2*(A=P.length),x=2*Math.pow(Math.log(A)/Math.LN2,2),l=Math.log(x/2)/Math.LN2,L=2*A-x,s=[],N=[],f=[],d=j=0,E=P.length;j<E;d=++j){if(S=P[d],c=h[d],65535===S){s.push(0),N.push(0);break}if(S-(k=n[S].new)>=32768)for(s.push(0),N.push(2*(f.length+A-d)),r=B=S;S<=c?B<=c:B>=c;r=S<=c?++B:--B)f.push(n[r].new);else s.push(k-S),N.push(0)}for(F.writeUInt16(3),F.writeUInt16(1),F.writeUInt32(12),F.writeUInt16(4),F.writeUInt16(16+8*A+2*f.length),F.writeUInt16(0),F.writeUInt16(_),F.writeUInt16(x),F.writeUInt16(l),F.writeUInt16(L),z=0,q=h.length;z<q;z++)r=h[z],F.writeUInt16(r);for(F.writeUInt16(0),H=0,R=P.length;H<R;H++)r=P[H],F.writeUInt16(r);for(V=0,T=s.length;V<T;V++)o=s[V],F.writeUInt16(o);for(G=0,D=N.length;G<D;G++)y=N[G],F.writeUInt16(y);for(Y=0,U=f.length;Y<U;Y++)p=f[Y],F.writeUInt16(p);return{charMap:n,subtable:F.data,maxGlyphID:b+1}}},t}(),Wt=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return Ut(e,qt),e.prototype.tag=\"cmap\",e.prototype.parse=function(t){var e,n,r;for(t.pos=this.offset,this.version=t.readUInt16(),r=t.readUInt16(),this.tables=[],this.unicode=null,n=0;0<=r?n<r:n>r;n=0<=r?++n:--n)e=new Ht(t,this.offset),this.tables.push(e),e.isUnicode&&null==this.unicode&&(this.unicode=e);return!0},e.encode=function(t,e){var n,r;return null==e&&(e=\"macroman\"),n=Ht.encode(t,e),(r=new Rt).writeUInt16(0),r.writeUInt16(1),n.table=r.data.concat(n.subtable),n},e}(),Vt=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return Ut(e,qt),e.prototype.tag=\"hhea\",e.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.ascender=t.readShort(),this.decender=t.readShort(),this.lineGap=t.readShort(),this.advanceWidthMax=t.readShort(),this.minLeftSideBearing=t.readShort(),this.minRightSideBearing=t.readShort(),this.xMaxExtent=t.readShort(),this.caretSlopeRise=t.readShort(),this.caretSlopeRun=t.readShort(),this.caretOffset=t.readShort(),t.pos+=8,this.metricDataFormat=t.readShort(),this.numberOfMetrics=t.readUInt16()},e}(),Gt=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return Ut(e,qt),e.prototype.tag=\"OS/2\",e.prototype.parse=function(t){if(t.pos=this.offset,this.version=t.readUInt16(),this.averageCharWidth=t.readShort(),this.weightClass=t.readUInt16(),this.widthClass=t.readUInt16(),this.type=t.readShort(),this.ySubscriptXSize=t.readShort(),this.ySubscriptYSize=t.readShort(),this.ySubscriptXOffset=t.readShort(),this.ySubscriptYOffset=t.readShort(),this.ySuperscriptXSize=t.readShort(),this.ySuperscriptYSize=t.readShort(),this.ySuperscriptXOffset=t.readShort(),this.ySuperscriptYOffset=t.readShort(),this.yStrikeoutSize=t.readShort(),this.yStrikeoutPosition=t.readShort(),this.familyClass=t.readShort(),this.panose=function(){var e,n;for(n=[],e=0;e<10;++e)n.push(t.readByte());return n}(),this.charRange=function(){var e,n;for(n=[],e=0;e<4;++e)n.push(t.readInt());return n}(),this.vendorID=t.readString(4),this.selection=t.readShort(),this.firstCharIndex=t.readShort(),this.lastCharIndex=t.readShort(),this.version>0&&(this.ascent=t.readShort(),this.descent=t.readShort(),this.lineGap=t.readShort(),this.winAscent=t.readShort(),this.winDescent=t.readShort(),this.codePageRange=function(){var e,n;for(n=[],e=0;e<2;e=++e)n.push(t.readInt());return n}(),this.version>1))return this.xHeight=t.readShort(),this.capHeight=t.readShort(),this.defaultChar=t.readShort(),this.breakChar=t.readShort(),this.maxContext=t.readShort()},e}(),Yt=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return Ut(e,qt),e.prototype.tag=\"post\",e.prototype.parse=function(t){var e,n,r;switch(t.pos=this.offset,this.format=t.readInt(),this.italicAngle=t.readInt(),this.underlinePosition=t.readShort(),this.underlineThickness=t.readShort(),this.isFixedPitch=t.readInt(),this.minMemType42=t.readInt(),this.maxMemType42=t.readInt(),this.minMemType1=t.readInt(),this.maxMemType1=t.readInt(),this.format){case 65536:break;case 131072:var i;for(n=t.readUInt16(),this.glyphNameIndex=[],i=0;0<=n?i<n:i>n;i=0<=n?++i:--i)this.glyphNameIndex.push(t.readUInt16());for(this.names=[],r=[];t.pos<this.offset+this.length;)e=t.readByte(),r.push(this.names.push(t.readString(e)));return r;case 151552:return n=t.readUInt16(),this.offsets=t.read(n);case 196608:break;case 262144:return this.map=function(){var e,n,r;for(r=[],i=e=0,n=this.file.maxp.numGlyphs;0<=n?e<n:e>n;i=0<=n?++e:--e)r.push(t.readUInt32());return r}.call(this)}},e}(),Jt=function(t,e){this.raw=t,this.length=t.length,this.platformID=e.platformID,this.encodingID=e.encodingID,this.languageID=e.languageID},Xt=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return Ut(e,qt),e.prototype.tag=\"name\",e.prototype.parse=function(t){var e,n,r,i,a,o,s,u,c,h,l;for(t.pos=this.offset,t.readShort(),e=t.readShort(),o=t.readShort(),n=[],i=0;0<=e?i<e:i>e;i=0<=e?++i:--i)n.push({platformID:t.readShort(),encodingID:t.readShort(),languageID:t.readShort(),nameID:t.readShort(),length:t.readShort(),offset:this.offset+o+t.readShort()});for(s={},i=c=0,h=n.length;c<h;i=++c)r=n[i],t.pos=r.offset,u=t.readString(r.length),a=new Jt(u,r),null==s[l=r.nameID]&&(s[l]=[]),s[r.nameID].push(a);this.strings=s,this.copyright=s[0],this.fontFamily=s[1],this.fontSubfamily=s[2],this.uniqueSubfamily=s[3],this.fontName=s[4],this.version=s[5];try{this.postscriptName=s[6][0].raw.replace(/[\\x00-\\x19\\x80-\\xff]/g,\"\")}catch(t){this.postscriptName=s[4][0].raw.replace(/[\\x00-\\x19\\x80-\\xff]/g,\"\")}return this.trademark=s[7],this.manufacturer=s[8],this.designer=s[9],this.description=s[10],this.vendorUrl=s[11],this.designerUrl=s[12],this.license=s[13],this.licenseUrl=s[14],this.preferredFamily=s[15],this.preferredSubfamily=s[17],this.compatibleFull=s[18],this.sampleText=s[19]},e}(),Kt=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return Ut(e,qt),e.prototype.tag=\"maxp\",e.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.numGlyphs=t.readUInt16(),this.maxPoints=t.readUInt16(),this.maxContours=t.readUInt16(),this.maxCompositePoints=t.readUInt16(),this.maxComponentContours=t.readUInt16(),this.maxZones=t.readUInt16(),this.maxTwilightPoints=t.readUInt16(),this.maxStorage=t.readUInt16(),this.maxFunctionDefs=t.readUInt16(),this.maxInstructionDefs=t.readUInt16(),this.maxStackElements=t.readUInt16(),this.maxSizeOfInstructions=t.readUInt16(),this.maxComponentElements=t.readUInt16(),this.maxComponentDepth=t.readUInt16()},e}(),Zt=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return Ut(e,qt),e.prototype.tag=\"hmtx\",e.prototype.parse=function(t){var e,n,r,i,a,o,s;for(t.pos=this.offset,this.metrics=[],e=0,o=this.file.hhea.numberOfMetrics;0<=o?e<o:e>o;e=0<=o?++e:--e)this.metrics.push({advance:t.readUInt16(),lsb:t.readInt16()});for(r=this.file.maxp.numGlyphs-this.file.hhea.numberOfMetrics,this.leftSideBearings=function(){var n,i;for(i=[],e=n=0;0<=r?n<r:n>r;e=0<=r?++n:--n)i.push(t.readInt16());return i}(),this.widths=function(){var t,e,n,r;for(r=[],t=0,e=(n=this.metrics).length;t<e;t++)i=n[t],r.push(i.advance);return r}.call(this),n=this.widths[this.widths.length-1],s=[],e=a=0;0<=r?a<r:a>r;e=0<=r?++a:--a)s.push(this.widths.push(n));return s},e.prototype.forGlyph=function(t){return t in this.metrics?this.metrics[t]:{advance:this.metrics[this.metrics.length-1].advance,lsb:this.leftSideBearings[t-this.metrics.length]}},e}(),$t=[].slice,Qt=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return Ut(e,qt),e.prototype.tag=\"glyf\",e.prototype.parse=function(){return this.cache={}},e.prototype.glyphFor=function(t){var e,n,r,i,a,o,s,u,c,h;return t in this.cache?this.cache[t]:(i=this.file.loca,e=this.file.contents,n=i.indexOf(t),0===(r=i.lengthOf(t))?this.cache[t]=null:(e.pos=this.offset+n,a=(o=new Rt(e.read(r))).readShort(),u=o.readShort(),h=o.readShort(),s=o.readShort(),c=o.readShort(),this.cache[t]=-1===a?new ee(o,u,h,s,c):new te(o,a,u,h,s,c),this.cache[t]))},e.prototype.encode=function(t,e,n){var r,i,a,o,s;for(a=[],i=[],o=0,s=e.length;o<s;o++)r=t[e[o]],i.push(a.length),r&&(a=a.concat(r.encode(n)));return i.push(a.length),{table:a,offsets:i}},e}(),te=function(){function t(t,e,n,r,i,a){this.raw=t,this.numberOfContours=e,this.xMin=n,this.yMin=r,this.xMax=i,this.yMax=a,this.compound=!1}return t.prototype.encode=function(){return this.raw.data},t}(),ee=function(){function t(t,e,n,r,i){var a,o;for(this.raw=t,this.xMin=e,this.yMin=n,this.xMax=r,this.yMax=i,this.compound=!0,this.glyphIDs=[],this.glyphOffsets=[],a=this.raw;o=a.readShort(),this.glyphOffsets.push(a.pos),this.glyphIDs.push(a.readUInt16()),32&o;)a.pos+=1&o?4:2,128&o?a.pos+=8:64&o?a.pos+=4:8&o&&(a.pos+=2)}return 1,8,32,64,128,t.prototype.encode=function(){var t,e,n;for(e=new Rt($t.call(this.raw.data)),t=0,n=this.glyphIDs.length;t<n;++t)e.pos=this.glyphOffsets[t];return e.data},t}(),ne=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return Ut(e,qt),e.prototype.tag=\"loca\",e.prototype.parse=function(t){var e,n;return t.pos=this.offset,e=this.file.head.indexToLocFormat,this.offsets=0===e?function(){var e,r;for(r=[],n=0,e=this.length;n<e;n+=2)r.push(2*t.readUInt16());return r}.call(this):function(){var e,r;for(r=[],n=0,e=this.length;n<e;n+=4)r.push(t.readUInt32());return r}.call(this)},e.prototype.indexOf=function(t){return this.offsets[t]},e.prototype.lengthOf=function(t){return this.offsets[t+1]-this.offsets[t]},e.prototype.encode=function(t,e){for(var n=new Uint32Array(this.offsets.length),r=0,i=0,a=0;a<n.length;++a)if(n[a]=r,i<e.length&&e[i]==a){++i,n[a]=r;var o=this.offsets[a],s=this.offsets[a+1]-o;s>0&&(r+=s)}for(var u=new Array(4*n.length),c=0;c<n.length;++c)u[4*c+3]=255&n[c],u[4*c+2]=(65280&n[c])>>8,u[4*c+1]=(16711680&n[c])>>16,u[4*c]=(4278190080&n[c])>>24;return u},e}(),re=function(){function t(t){this.font=t,this.subset={},this.unicodes={},this.next=33}return t.prototype.generateCmap=function(){var t,e,n,r,i;for(e in r=this.font.cmap.tables[0].codeMap,t={},i=this.subset)n=i[e],t[e]=r[n];return t},t.prototype.glyphsFor=function(t){var e,n,r,i,a,o,s;for(r={},a=0,o=t.length;a<o;a++)r[i=t[a]]=this.font.glyf.glyphFor(i);for(i in e=[],r)(null!=(n=r[i])?n.compound:void 0)&&e.push.apply(e,n.glyphIDs);if(e.length>0)for(i in s=this.glyphsFor(e))n=s[i],r[i]=n;return r},t.prototype.encode=function(t,e){var n,r,i,a,o,s,u,c,h,l,f,d,p,g,m;for(r in n=Wt.encode(this.generateCmap(),\"unicode\"),a=this.glyphsFor(t),f={0:0},m=n.charMap)f[(s=m[r]).old]=s.new;for(d in l=n.maxGlyphID,a)d in f||(f[d]=l++);return c=function(t){var e,n;for(e in n={},t)n[t[e]]=e;return n}(f),h=Object.keys(c).sort((function(t,e){return t-e})),p=function(){var t,e,n;for(n=[],t=0,e=h.length;t<e;t++)o=h[t],n.push(c[o]);return n}(),i=this.font.glyf.encode(a,p,f),u=this.font.loca.encode(i.offsets,p),g={cmap:this.font.cmap.raw(),glyf:i.table,loca:u,hmtx:this.font.hmtx.raw(),hhea:this.font.hhea.raw(),maxp:this.font.maxp.raw(),post:this.font.post.raw(),name:this.font.name.raw(),head:this.font.head.encode(e)},this.font.os2.exists&&(g[\"OS/2\"]=this.font.os2.raw()),this.font.directory.encode(g)},t}();g.API.PDFObject=function(){var t;function e(){}return t=function(t,e){return(Array(e+1).join(\"0\")+t).slice(-e)},e.convert=function(n){var r,i,a,o;if(Array.isArray(n))return\"[\"+function(){var t,i,a;for(a=[],t=0,i=n.length;t<i;t++)r=n[t],a.push(e.convert(r));return a}().join(\" \")+\"]\";if(\"string\"==typeof n)return\"/\"+n;if(null!=n?n.isString:void 0)return\"(\"+n+\")\";if(n instanceof Date)return\"(D:\"+t(n.getUTCFullYear(),4)+t(n.getUTCMonth(),2)+t(n.getUTCDate(),2)+t(n.getUTCHours(),2)+t(n.getUTCMinutes(),2)+t(n.getUTCSeconds(),2)+\"Z)\";if(\"[object Object]\"==={}.toString.call(n)){for(i in a=[\"<<\"],n)o=n[i],a.push(\"/\"+i+\" \"+e.convert(o));return a.push(\">>\"),a.join(\"\\n\")}return\"\"+n},e}(),\n/**\n * @license\n * Copyright (c) 2012 chick307 <chick307@gmail.com>\n *\n * Licensed under the MIT License.\n * http://opensource.org/licenses/mit-license\n */\nfunction(t,e){t.API.adler32cs=function(){var t=\"function\"==typeof ArrayBuffer&&\"function\"==typeof Uint8Array,e=null,n=function(){if(!t)return function(){return!1};try{var n={};\"function\"==typeof n.Buffer&&(e=n.Buffer)}catch(t){}return function(t){return t instanceof ArrayBuffer||null!==e&&t instanceof e}}(),r=null!==e?function(t){return new e(t,\"utf8\").toString(\"binary\")}:function(t){return unescape(encodeURIComponent(t))},i=function(t,e){for(var n=65535&t,r=t>>>16,i=0,a=e.length;i<a;i++)r=(r+(n=(n+(255&e.charCodeAt(i)))%65521))%65521;return(r<<16|n)>>>0},a=function(t,e){for(var n=65535&t,r=t>>>16,i=0,a=e.length;i<a;i++)r=(r+(n=(n+e[i])%65521))%65521;return(r<<16|n)>>>0},o={},s=o.Adler32=(l=function(t){if(!(this instanceof l))throw new TypeError(\"Constructor cannot called be as a function.\");if(!isFinite(t=null===t?1:+t))throw new Error(\"First arguments needs to be a finite number.\");this.checksum=t>>>0},f=l.prototype={},f.constructor=l,l.from=((u=function(t){if(!(this instanceof l))throw new TypeError(\"Constructor cannot called be as a function.\");if(null===t)throw new Error(\"First argument needs to be a string.\");this.checksum=i(1,t.toString())}).prototype=f,u),l.fromUtf8=((c=function(t){if(!(this instanceof l))throw new TypeError(\"Constructor cannot called be as a function.\");if(null===t)throw new Error(\"First argument needs to be a string.\");var e=r(t.toString());this.checksum=i(1,e)}).prototype=f,c),t&&(l.fromBuffer=((h=function(t){if(!(this instanceof l))throw new TypeError(\"Constructor cannot called be as a function.\");if(!n(t))throw new Error(\"First argument needs to be ArrayBuffer.\");var e=new Uint8Array(t);return this.checksum=a(1,e)}).prototype=f,h)),f.update=function(t){if(null===t)throw new Error(\"First argument needs to be a string.\");return t=t.toString(),this.checksum=i(this.checksum,t)},f.updateUtf8=function(t){if(null===t)throw new Error(\"First argument needs to be a string.\");var e=r(t.toString());return this.checksum=i(this.checksum,e)},t&&(f.updateBuffer=function(t){if(!n(t))throw new Error(\"First argument needs to be ArrayBuffer.\");var e=new Uint8Array(t);return this.checksum=a(this.checksum,e)}),f.clone=function(){return new s(this.checksum)},l);var u,c,h,l,f;o.from=function(t){if(null===t)throw new Error(\"First argument needs to be a string.\");return i(1,t.toString())},o.fromUtf8=function(t){if(null===t)throw new Error(\"First argument needs to be a string.\");var e=r(t.toString());return i(1,e)},t&&(o.fromBuffer=function(t){if(!n(t))throw new Error(\"First argument need to be ArrayBuffer.\");var e=new Uint8Array(t);return a(1,e)});return o}()}(g);export default g;export{ht as AcroForm,ut as AcroFormAppearance,et as AcroFormButton,at as AcroFormCheckBox,Z as AcroFormChoiceField,Q as AcroFormComboBox,tt as AcroFormEditBox,$ as AcroFormListBox,st as AcroFormPasswordField,nt as AcroFormPushButton,rt as AcroFormRadioButton,ot as AcroFormTextField,l as GState,d as ShadingPattern,p as TilingPattern,g as jsPDF};\n//# sourceMappingURL=jspdf.es.min.js.map\n","/*! https://mths.be/cssesc v3.0.0 by @mathias */\n'use strict';\n\nvar object = {};\nvar hasOwnProperty = object.hasOwnProperty;\nvar merge = function merge(options, defaults) {\n\tif (!options) {\n\t\treturn defaults;\n\t}\n\tvar result = {};\n\tfor (var key in defaults) {\n\t\t// `if (defaults.hasOwnProperty(key) { … }` is not needed here, since\n\t\t// only recognized option names are used.\n\t\tresult[key] = hasOwnProperty.call(options, key) ? options[key] : defaults[key];\n\t}\n\treturn result;\n};\n\nvar regexAnySingleEscape = /[ -,\\.\\/:-@\\[-\\^`\\{-~]/;\nvar regexSingleEscape = /[ -,\\.\\/:-@\\[\\]\\^`\\{-~]/;\nvar regexAlwaysEscape = /['\"\\\\]/;\nvar regexExcessiveSpaces = /(^|\\\\+)?(\\\\[A-F0-9]{1,6})\\x20(?![a-fA-F0-9\\x20])/g;\n\n// https://mathiasbynens.be/notes/css-escapes#css\nvar cssesc = function cssesc(string, options) {\n\toptions = merge(options, cssesc.options);\n\tif (options.quotes != 'single' && options.quotes != 'double') {\n\t\toptions.quotes = 'single';\n\t}\n\tvar quote = options.quotes == 'double' ? '\"' : '\\'';\n\tvar isIdentifier = options.isIdentifier;\n\n\tvar firstChar = string.charAt(0);\n\tvar output = '';\n\tvar counter = 0;\n\tvar length = string.length;\n\twhile (counter < length) {\n\t\tvar character = string.charAt(counter++);\n\t\tvar codePoint = character.charCodeAt();\n\t\tvar value = void 0;\n\t\t// If it’s not a printable ASCII character…\n\t\tif (codePoint < 0x20 || codePoint > 0x7E) {\n\t\t\tif (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {\n\t\t\t\t// It’s a high surrogate, and there is a next character.\n\t\t\t\tvar extra = string.charCodeAt(counter++);\n\t\t\t\tif ((extra & 0xFC00) == 0xDC00) {\n\t\t\t\t\t// next character is low surrogate\n\t\t\t\t\tcodePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;\n\t\t\t\t} else {\n\t\t\t\t\t// It’s an unmatched surrogate; only append this code unit, in case\n\t\t\t\t\t// the next code unit is the high surrogate of a surrogate pair.\n\t\t\t\t\tcounter--;\n\t\t\t\t}\n\t\t\t}\n\t\t\tvalue = '\\\\' + codePoint.toString(16).toUpperCase() + ' ';\n\t\t} else {\n\t\t\tif (options.escapeEverything) {\n\t\t\t\tif (regexAnySingleEscape.test(character)) {\n\t\t\t\t\tvalue = '\\\\' + character;\n\t\t\t\t} else {\n\t\t\t\t\tvalue = '\\\\' + codePoint.toString(16).toUpperCase() + ' ';\n\t\t\t\t}\n\t\t\t} else if (/[\\t\\n\\f\\r\\x0B]/.test(character)) {\n\t\t\t\tvalue = '\\\\' + codePoint.toString(16).toUpperCase() + ' ';\n\t\t\t} else if (character == '\\\\' || !isIdentifier && (character == '\"' && quote == character || character == '\\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {\n\t\t\t\tvalue = '\\\\' + character;\n\t\t\t} else {\n\t\t\t\tvalue = character;\n\t\t\t}\n\t\t}\n\t\toutput += value;\n\t}\n\n\tif (isIdentifier) {\n\t\tif (/^-[-\\d]/.test(output)) {\n\t\t\toutput = '\\\\-' + output.slice(1);\n\t\t} else if (/\\d/.test(firstChar)) {\n\t\t\toutput = '\\\\3' + firstChar + ' ' + output.slice(1);\n\t\t}\n\t}\n\n\t// Remove spaces after `\\HEX` escapes that are not followed by a hex digit,\n\t// since they’re redundant. Note that this is only possible if the escape\n\t// sequence isn’t preceded by an odd number of backslashes.\n\toutput = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {\n\t\tif ($1 && $1.length % 2) {\n\t\t\t// It’s not safe to remove the space, so don’t.\n\t\t\treturn $0;\n\t\t}\n\t\t// Strip the space.\n\t\treturn ($1 || '') + $2;\n\t});\n\n\tif (!isIdentifier && options.wrap) {\n\t\treturn quote + output + quote;\n\t}\n\treturn output;\n};\n\n// Expose default options (so they can be overridden globally).\ncssesc.options = {\n\t'escapeEverything': false,\n\t'isIdentifier': false,\n\t'quotes': 'single',\n\t'wrap': false\n};\n\ncssesc.version = '3.0.0';\n\nmodule.exports = cssesc;\n","// parse\n// =====\n\n// states\n// ------\n\nvar PLAIN = 0;\nvar STRINGS = 1;\nvar ESCAPING = 2;\nvar IDENTIFIER = 3;\nvar SEPARATING = 4;\nvar SPACEAFTERIDENTIFIER = 5;\n\n// patterns\n// --------\n\nvar identifierPattern = /[a-z0-9_-]/i;\nvar spacePattern = /[\\s\\t]/;\n\n// ---\n\nvar parse = function(str) {\n\n // vars\n // ----\n\n var starting = true;\n var state = PLAIN;\n var buffer = '';\n var i = 0;\n var quote;\n var c;\n\n // result\n // ------\n\n var names = [];\n\n // parse\n // -----\n\n while (true) {\n\n c = str[i];\n\n if (state === PLAIN) {\n\n if (!c && starting) {\n\n break;\n\n } else if (!c && !starting) {\n\n throw new Error('Parse error');\n\n } else if (c === '\"' || c === \"'\") {\n\n quote = c;\n state = STRINGS;\n starting = false;\n\n } else if (spacePattern.test(c)) {\n } else if (identifierPattern.test(c)) {\n\n state = IDENTIFIER;\n starting = false;\n i--;\n\n } else {\n\n throw new Error('Parse error');\n\n }\n\n } else if (state === STRINGS) {\n\n if (!c) {\n\n throw new Error('Parse Error');\n\n } else if (c === \"\\\\\") {\n\n state = ESCAPING;\n\n } else if (c === quote) {\n\n names.push(buffer);\n buffer = '';\n state = SEPARATING;\n\n } else {\n\n buffer += c;\n\n }\n\n } else if (state === ESCAPING) {\n\n if (c === quote || c === \"\\\\\") {\n\n buffer += c;\n state = STRINGS;\n\n } else {\n\n throw new Error('Parse error');\n\n }\n\n } else if (state === IDENTIFIER) {\n\n if (!c) {\n\n names.push(buffer);\n break;\n\n } else if (identifierPattern.test(c)) {\n\n buffer += c;\n\n } else if (c === ',') {\n\n names.push(buffer);\n buffer = '';\n state = PLAIN;\n\n } else if (spacePattern.test(c)) {\n\n state = SPACEAFTERIDENTIFIER;\n } else {\n\n throw new Error('Parse error');\n\n }\n } else if (state === SPACEAFTERIDENTIFIER) {\n\n if (!c) {\n\n names.push(buffer);\n break;\n\n } else if (identifierPattern.test(c)) {\n\n buffer += ' ' + c;\n state = IDENTIFIER;\n\n } else if (c === ',') {\n\n names.push(buffer);\n buffer = '';\n state = PLAIN;\n\n } else if (spacePattern.test(c)) {\n } else {\n\n throw new Error('Parse error');\n\n }\n\n } else if (state === SEPARATING) {\n\n if (!c) {\n\n break;\n\n } else if (c === ',') {\n\n state = PLAIN;\n\n } else if (spacePattern.test(c)) {\n } else {\n\n throw new Error('Parse error');\n\n }\n\n }\n\n i++;\n\n }\n\n // result\n // ------\n\n return names;\n\n};\n\n// stringify\n// =========\n\n// pattern\n// -------\n\nvar stringsPattern = /[^a-z0-9_-]/i;\n\n// ---\n\nvar stringify = function(names, options) {\n\n // quote\n // -----\n\n var quote = options && options.quote || '\"';\n if (quote !== '\"' && quote !== \"'\") {\n throw new Error('Quote must be `\\'` or `\"`');\n }\n var quotePattern = new RegExp(quote, 'g');\n\n // stringify\n // ---------\n\n var safeNames = [];\n\n for (var i = 0; i < names.length; ++i) {\n var name = names[i];\n\n if (stringsPattern.test(name)) {\n name = name\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(quotePattern, \"\\\\\" + quote);\n name = quote + name + quote;\n }\n safeNames.push(name);\n }\n\n // result\n // ------\n\n return safeNames.join(', ');\n};\n\n// export\n// ======\n\nmodule.exports = {\n parse: parse,\n stringify: stringify,\n};\n","'use strict';\n\n\nvar paramCounts = { a: 7, c: 6, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, z: 0 };\n\nvar SPECIAL_SPACES = [\n 0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006,\n 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF\n];\n\nfunction isSpace(ch) {\n return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029) || // Line terminators\n // White spaces\n (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) ||\n (ch >= 0x1680 && SPECIAL_SPACES.indexOf(ch) >= 0);\n}\n\nfunction isCommand(code) {\n /*eslint-disable no-bitwise*/\n switch (code | 0x20) {\n case 0x6D/* m */:\n case 0x7A/* z */:\n case 0x6C/* l */:\n case 0x68/* h */:\n case 0x76/* v */:\n case 0x63/* c */:\n case 0x73/* s */:\n case 0x71/* q */:\n case 0x74/* t */:\n case 0x61/* a */:\n case 0x72/* r */:\n return true;\n }\n return false;\n}\n\nfunction isArc(code) {\n return (code | 0x20) === 0x61;\n}\n\nfunction isDigit(code) {\n return (code >= 48 && code <= 57); // 0..9\n}\n\nfunction isDigitStart(code) {\n return (code >= 48 && code <= 57) || /* 0..9 */\n code === 0x2B || /* + */\n code === 0x2D || /* - */\n code === 0x2E; /* . */\n}\n\n\nfunction State(path) {\n this.index = 0;\n this.path = path;\n this.max = path.length;\n this.result = [];\n this.param = 0.0;\n this.err = '';\n this.segmentStart = 0;\n this.data = [];\n}\n\nfunction skipSpaces(state) {\n while (state.index < state.max && isSpace(state.path.charCodeAt(state.index))) {\n state.index++;\n }\n}\n\n\nfunction scanFlag(state) {\n var ch = state.path.charCodeAt(state.index);\n\n if (ch === 0x30/* 0 */) {\n state.param = 0;\n state.index++;\n return;\n }\n\n if (ch === 0x31/* 1 */) {\n state.param = 1;\n state.index++;\n return;\n }\n\n state.err = 'SvgPath: arc flag can be 0 or 1 only (at pos ' + state.index + ')';\n}\n\n\nfunction scanParam(state) {\n var start = state.index,\n index = start,\n max = state.max,\n zeroFirst = false,\n hasCeiling = false,\n hasDecimal = false,\n hasDot = false,\n ch;\n\n if (index >= max) {\n state.err = 'SvgPath: missed param (at pos ' + index + ')';\n return;\n }\n ch = state.path.charCodeAt(index);\n\n if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {\n index++;\n ch = (index < max) ? state.path.charCodeAt(index) : 0;\n }\n\n // This logic is shamelessly borrowed from Esprima\n // https://github.com/ariya/esprimas\n //\n if (!isDigit(ch) && ch !== 0x2E/* . */) {\n state.err = 'SvgPath: param should start with 0..9 or `.` (at pos ' + index + ')';\n return;\n }\n\n if (ch !== 0x2E/* . */) {\n zeroFirst = (ch === 0x30/* 0 */);\n index++;\n\n ch = (index < max) ? state.path.charCodeAt(index) : 0;\n\n if (zeroFirst && index < max) {\n // decimal number starts with '0' such as '09' is illegal.\n if (ch && isDigit(ch)) {\n state.err = 'SvgPath: numbers started with `0` such as `09` are illegal (at pos ' + start + ')';\n return;\n }\n }\n\n while (index < max && isDigit(state.path.charCodeAt(index))) {\n index++;\n hasCeiling = true;\n }\n ch = (index < max) ? state.path.charCodeAt(index) : 0;\n }\n\n if (ch === 0x2E/* . */) {\n hasDot = true;\n index++;\n while (isDigit(state.path.charCodeAt(index))) {\n index++;\n hasDecimal = true;\n }\n ch = (index < max) ? state.path.charCodeAt(index) : 0;\n }\n\n if (ch === 0x65/* e */ || ch === 0x45/* E */) {\n if (hasDot && !hasCeiling && !hasDecimal) {\n state.err = 'SvgPath: invalid float exponent (at pos ' + index + ')';\n return;\n }\n\n index++;\n\n ch = (index < max) ? state.path.charCodeAt(index) : 0;\n if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {\n index++;\n }\n if (index < max && isDigit(state.path.charCodeAt(index))) {\n while (index < max && isDigit(state.path.charCodeAt(index))) {\n index++;\n }\n } else {\n state.err = 'SvgPath: invalid float exponent (at pos ' + index + ')';\n return;\n }\n }\n\n state.index = index;\n state.param = parseFloat(state.path.slice(start, index)) + 0.0;\n}\n\n\nfunction finalizeSegment(state) {\n var cmd, cmdLC;\n\n // Process duplicated commands (without comand name)\n\n // This logic is shamelessly borrowed from Raphael\n // https://github.com/DmitryBaranovskiy/raphael/\n //\n cmd = state.path[state.segmentStart];\n cmdLC = cmd.toLowerCase();\n\n var params = state.data;\n\n if (cmdLC === 'm' && params.length > 2) {\n state.result.push([ cmd, params[0], params[1] ]);\n params = params.slice(2);\n cmdLC = 'l';\n cmd = (cmd === 'm') ? 'l' : 'L';\n }\n\n if (cmdLC === 'r') {\n state.result.push([ cmd ].concat(params));\n } else {\n\n while (params.length >= paramCounts[cmdLC]) {\n state.result.push([ cmd ].concat(params.splice(0, paramCounts[cmdLC])));\n if (!paramCounts[cmdLC]) {\n break;\n }\n }\n }\n}\n\n\nfunction scanSegment(state) {\n var max = state.max,\n cmdCode, is_arc, comma_found, need_params, i;\n\n state.segmentStart = state.index;\n cmdCode = state.path.charCodeAt(state.index);\n is_arc = isArc(cmdCode);\n\n if (!isCommand(cmdCode)) {\n state.err = 'SvgPath: bad command ' + state.path[state.index] + ' (at pos ' + state.index + ')';\n return;\n }\n\n need_params = paramCounts[state.path[state.index].toLowerCase()];\n\n state.index++;\n skipSpaces(state);\n\n state.data = [];\n\n if (!need_params) {\n // Z\n finalizeSegment(state);\n return;\n }\n\n comma_found = false;\n\n for (;;) {\n for (i = need_params; i > 0; i--) {\n if (is_arc && (i === 3 || i === 4)) scanFlag(state);\n else scanParam(state);\n\n if (state.err.length) {\n return;\n }\n state.data.push(state.param);\n\n skipSpaces(state);\n comma_found = false;\n\n if (state.index < max && state.path.charCodeAt(state.index) === 0x2C/* , */) {\n state.index++;\n skipSpaces(state);\n comma_found = true;\n }\n }\n\n // after ',' param is mandatory\n if (comma_found) {\n continue;\n }\n\n if (state.index >= state.max) {\n break;\n }\n\n // Stop on next segment\n if (!isDigitStart(state.path.charCodeAt(state.index))) {\n break;\n }\n }\n\n finalizeSegment(state);\n}\n\n\n/* Returns array of segments:\n *\n * [\n * [ command, coord1, coord2, ... ]\n * ]\n */\nmodule.exports = function pathParse(svgPath) {\n var state = new State(svgPath);\n var max = state.max;\n\n skipSpaces(state);\n\n while (state.index < max && !state.err.length) {\n scanSegment(state);\n }\n\n if (state.err.length) {\n state.result = [];\n\n } else if (state.result.length) {\n\n if ('mM'.indexOf(state.result[0][0]) < 0) {\n state.err = 'SvgPath: string should start with `M` or `m`';\n state.result = [];\n } else {\n state.result[0][0] = 'M';\n }\n }\n\n return {\n err: state.err,\n segments: state.result\n };\n};\n","'use strict';\n\n// combine 2 matrixes\n// m1, m2 - [a, b, c, d, e, g]\n//\nfunction combine(m1, m2) {\n return [\n m1[0] * m2[0] + m1[2] * m2[1],\n m1[1] * m2[0] + m1[3] * m2[1],\n m1[0] * m2[2] + m1[2] * m2[3],\n m1[1] * m2[2] + m1[3] * m2[3],\n m1[0] * m2[4] + m1[2] * m2[5] + m1[4],\n m1[1] * m2[4] + m1[3] * m2[5] + m1[5]\n ];\n}\n\n\nfunction Matrix() {\n if (!(this instanceof Matrix)) { return new Matrix(); }\n this.queue = []; // list of matrixes to apply\n this.cache = null; // combined matrix cache\n}\n\n\nMatrix.prototype.matrix = function (m) {\n if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1 && m[4] === 0 && m[5] === 0) {\n return this;\n }\n this.cache = null;\n this.queue.push(m);\n return this;\n};\n\n\nMatrix.prototype.translate = function (tx, ty) {\n if (tx !== 0 || ty !== 0) {\n this.cache = null;\n this.queue.push([ 1, 0, 0, 1, tx, ty ]);\n }\n return this;\n};\n\n\nMatrix.prototype.scale = function (sx, sy) {\n if (sx !== 1 || sy !== 1) {\n this.cache = null;\n this.queue.push([ sx, 0, 0, sy, 0, 0 ]);\n }\n return this;\n};\n\n\nMatrix.prototype.rotate = function (angle, rx, ry) {\n var rad, cos, sin;\n\n if (angle !== 0) {\n this.translate(rx, ry);\n\n rad = angle * Math.PI / 180;\n cos = Math.cos(rad);\n sin = Math.sin(rad);\n\n this.queue.push([ cos, sin, -sin, cos, 0, 0 ]);\n this.cache = null;\n\n this.translate(-rx, -ry);\n }\n return this;\n};\n\n\nMatrix.prototype.skewX = function (angle) {\n if (angle !== 0) {\n this.cache = null;\n this.queue.push([ 1, 0, Math.tan(angle * Math.PI / 180), 1, 0, 0 ]);\n }\n return this;\n};\n\n\nMatrix.prototype.skewY = function (angle) {\n if (angle !== 0) {\n this.cache = null;\n this.queue.push([ 1, Math.tan(angle * Math.PI / 180), 0, 1, 0, 0 ]);\n }\n return this;\n};\n\n\n// Flatten queue\n//\nMatrix.prototype.toArray = function () {\n if (this.cache) {\n return this.cache;\n }\n\n if (!this.queue.length) {\n this.cache = [ 1, 0, 0, 1, 0, 0 ];\n return this.cache;\n }\n\n this.cache = this.queue[0];\n\n if (this.queue.length === 1) {\n return this.cache;\n }\n\n for (var i = 1; i < this.queue.length; i++) {\n this.cache = combine(this.cache, this.queue[i]);\n }\n\n return this.cache;\n};\n\n\n// Apply list of matrixes to (x,y) point.\n// If `isRelative` set, `translate` component of matrix will be skipped\n//\nMatrix.prototype.calc = function (x, y, isRelative) {\n var m;\n\n // Don't change point on empty transforms queue\n if (!this.queue.length) { return [ x, y ]; }\n\n // Calculate final matrix, if not exists\n //\n // NB. if you deside to apply transforms to point one-by-one,\n // they should be taken in reverse order\n\n if (!this.cache) {\n this.cache = this.toArray();\n }\n\n m = this.cache;\n\n // Apply matrix to point\n return [\n x * m[0] + y * m[2] + (isRelative ? 0 : m[4]),\n x * m[1] + y * m[3] + (isRelative ? 0 : m[5])\n ];\n};\n\n\nmodule.exports = Matrix;\n","'use strict';\n\n\nvar Matrix = require('./matrix');\n\nvar operations = {\n matrix: true,\n scale: true,\n rotate: true,\n translate: true,\n skewX: true,\n skewY: true\n};\n\nvar CMD_SPLIT_RE = /\\s*(matrix|translate|scale|rotate|skewX|skewY)\\s*\\(\\s*(.+?)\\s*\\)[\\s,]*/;\nvar PARAMS_SPLIT_RE = /[\\s,]+/;\n\n\nmodule.exports = function transformParse(transformString) {\n var matrix = new Matrix();\n var cmd, params;\n\n // Split value into ['', 'translate', '10 50', '', 'scale', '2', '', 'rotate', '-45', '']\n transformString.split(CMD_SPLIT_RE).forEach(function (item) {\n\n // Skip empty elements\n if (!item.length) { return; }\n\n // remember operation\n if (typeof operations[item] !== 'undefined') {\n cmd = item;\n return;\n }\n\n // extract params & att operation to matrix\n params = item.split(PARAMS_SPLIT_RE).map(function (i) {\n return +i || 0;\n });\n\n // If params count is not correct - ignore command\n switch (cmd) {\n case 'matrix':\n if (params.length === 6) {\n matrix.matrix(params);\n }\n return;\n\n case 'scale':\n if (params.length === 1) {\n matrix.scale(params[0], params[0]);\n } else if (params.length === 2) {\n matrix.scale(params[0], params[1]);\n }\n return;\n\n case 'rotate':\n if (params.length === 1) {\n matrix.rotate(params[0], 0, 0);\n } else if (params.length === 3) {\n matrix.rotate(params[0], params[1], params[2]);\n }\n return;\n\n case 'translate':\n if (params.length === 1) {\n matrix.translate(params[0], 0);\n } else if (params.length === 2) {\n matrix.translate(params[0], params[1]);\n }\n return;\n\n case 'skewX':\n if (params.length === 1) {\n matrix.skewX(params[0]);\n }\n return;\n\n case 'skewY':\n if (params.length === 1) {\n matrix.skewY(params[0]);\n }\n return;\n }\n });\n\n return matrix;\n};\n","// Convert an arc to a sequence of cubic bézier curves\n//\n'use strict';\n\n\nvar TAU = Math.PI * 2;\n\n\n/* eslint-disable space-infix-ops */\n\n// Calculate an angle between two unit vectors\n//\n// Since we measure angle between radii of circular arcs,\n// we can use simplified math (without length normalization)\n//\nfunction unit_vector_angle(ux, uy, vx, vy) {\n var sign = (ux * vy - uy * vx < 0) ? -1 : 1;\n var dot = ux * vx + uy * vy;\n\n // Add this to work with arbitrary vectors:\n // dot /= Math.sqrt(ux * ux + uy * uy) * Math.sqrt(vx * vx + vy * vy);\n\n // rounding errors, e.g. -1.0000000000000002 can screw up this\n if (dot > 1.0) { dot = 1.0; }\n if (dot < -1.0) { dot = -1.0; }\n\n return sign * Math.acos(dot);\n}\n\n\n// Convert from endpoint to center parameterization,\n// see http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes\n//\n// Return [cx, cy, theta1, delta_theta]\n//\nfunction get_arc_center(x1, y1, x2, y2, fa, fs, rx, ry, sin_phi, cos_phi) {\n // Step 1.\n //\n // Moving an ellipse so origin will be the middlepoint between our two\n // points. After that, rotate it to line up ellipse axes with coordinate\n // axes.\n //\n var x1p = cos_phi*(x1-x2)/2 + sin_phi*(y1-y2)/2;\n var y1p = -sin_phi*(x1-x2)/2 + cos_phi*(y1-y2)/2;\n\n var rx_sq = rx * rx;\n var ry_sq = ry * ry;\n var x1p_sq = x1p * x1p;\n var y1p_sq = y1p * y1p;\n\n // Step 2.\n //\n // Compute coordinates of the centre of this ellipse (cx', cy')\n // in the new coordinate system.\n //\n var radicant = (rx_sq * ry_sq) - (rx_sq * y1p_sq) - (ry_sq * x1p_sq);\n\n if (radicant < 0) {\n // due to rounding errors it might be e.g. -1.3877787807814457e-17\n radicant = 0;\n }\n\n radicant /= (rx_sq * y1p_sq) + (ry_sq * x1p_sq);\n radicant = Math.sqrt(radicant) * (fa === fs ? -1 : 1);\n\n var cxp = radicant * rx/ry * y1p;\n var cyp = radicant * -ry/rx * x1p;\n\n // Step 3.\n //\n // Transform back to get centre coordinates (cx, cy) in the original\n // coordinate system.\n //\n var cx = cos_phi*cxp - sin_phi*cyp + (x1+x2)/2;\n var cy = sin_phi*cxp + cos_phi*cyp + (y1+y2)/2;\n\n // Step 4.\n //\n // Compute angles (theta1, delta_theta).\n //\n var v1x = (x1p - cxp) / rx;\n var v1y = (y1p - cyp) / ry;\n var v2x = (-x1p - cxp) / rx;\n var v2y = (-y1p - cyp) / ry;\n\n var theta1 = unit_vector_angle(1, 0, v1x, v1y);\n var delta_theta = unit_vector_angle(v1x, v1y, v2x, v2y);\n\n if (fs === 0 && delta_theta > 0) {\n delta_theta -= TAU;\n }\n if (fs === 1 && delta_theta < 0) {\n delta_theta += TAU;\n }\n\n return [ cx, cy, theta1, delta_theta ];\n}\n\n//\n// Approximate one unit arc segment with bézier curves,\n// see http://math.stackexchange.com/questions/873224\n//\nfunction approximate_unit_arc(theta1, delta_theta) {\n var alpha = 4/3 * Math.tan(delta_theta/4);\n\n var x1 = Math.cos(theta1);\n var y1 = Math.sin(theta1);\n var x2 = Math.cos(theta1 + delta_theta);\n var y2 = Math.sin(theta1 + delta_theta);\n\n return [ x1, y1, x1 - y1*alpha, y1 + x1*alpha, x2 + y2*alpha, y2 - x2*alpha, x2, y2 ];\n}\n\nmodule.exports = function a2c(x1, y1, x2, y2, fa, fs, rx, ry, phi) {\n var sin_phi = Math.sin(phi * TAU / 360);\n var cos_phi = Math.cos(phi * TAU / 360);\n\n // Make sure radii are valid\n //\n var x1p = cos_phi*(x1-x2)/2 + sin_phi*(y1-y2)/2;\n var y1p = -sin_phi*(x1-x2)/2 + cos_phi*(y1-y2)/2;\n\n if (x1p === 0 && y1p === 0) {\n // we're asked to draw line to itself\n return [];\n }\n\n if (rx === 0 || ry === 0) {\n // one of the radii is zero\n return [];\n }\n\n\n // Compensate out-of-range radii\n //\n rx = Math.abs(rx);\n ry = Math.abs(ry);\n\n var lambda = (x1p * x1p) / (rx * rx) + (y1p * y1p) / (ry * ry);\n if (lambda > 1) {\n rx *= Math.sqrt(lambda);\n ry *= Math.sqrt(lambda);\n }\n\n\n // Get center parameters (cx, cy, theta1, delta_theta)\n //\n var cc = get_arc_center(x1, y1, x2, y2, fa, fs, rx, ry, sin_phi, cos_phi);\n\n var result = [];\n var theta1 = cc[2];\n var delta_theta = cc[3];\n\n // Split an arc to multiple segments, so each segment\n // will be less than τ/4 (= 90°)\n //\n var segments = Math.max(Math.ceil(Math.abs(delta_theta) / (TAU / 4)), 1);\n delta_theta /= segments;\n\n for (var i = 0; i < segments; i++) {\n result.push(approximate_unit_arc(theta1, delta_theta));\n theta1 += delta_theta;\n }\n\n // We have a bezier approximation of a unit circle,\n // now need to transform back to the original ellipse\n //\n return result.map(function (curve) {\n for (var i = 0; i < curve.length; i += 2) {\n var x = curve[i + 0];\n var y = curve[i + 1];\n\n // scale\n x *= rx;\n y *= ry;\n\n // rotate\n var xp = cos_phi*x - sin_phi*y;\n var yp = sin_phi*x + cos_phi*y;\n\n // translate\n curve[i + 0] = xp + cc[0];\n curve[i + 1] = yp + cc[1];\n }\n\n return curve;\n });\n};\n","'use strict';\n\n/* eslint-disable space-infix-ops */\n\n// The precision used to consider an ellipse as a circle\n//\nvar epsilon = 0.0000000001;\n\n// To convert degree in radians\n//\nvar torad = Math.PI / 180;\n\n// Class constructor :\n// an ellipse centred at 0 with radii rx,ry and x - axis - angle ax.\n//\nfunction Ellipse(rx, ry, ax) {\n if (!(this instanceof Ellipse)) { return new Ellipse(rx, ry, ax); }\n this.rx = rx;\n this.ry = ry;\n this.ax = ax;\n}\n\n// Apply a linear transform m to the ellipse\n// m is an array representing a matrix :\n// - -\n// | m[0] m[2] |\n// | m[1] m[3] |\n// - -\n//\nEllipse.prototype.transform = function (m) {\n // We consider the current ellipse as image of the unit circle\n // by first scale(rx,ry) and then rotate(ax) ...\n // So we apply ma = m x rotate(ax) x scale(rx,ry) to the unit circle.\n var c = Math.cos(this.ax * torad), s = Math.sin(this.ax * torad);\n var ma = [\n this.rx * (m[0]*c + m[2]*s),\n this.rx * (m[1]*c + m[3]*s),\n this.ry * (-m[0]*s + m[2]*c),\n this.ry * (-m[1]*s + m[3]*c)\n ];\n\n // ma * transpose(ma) = [ J L ]\n // [ L K ]\n // L is calculated later (if the image is not a circle)\n var J = ma[0]*ma[0] + ma[2]*ma[2],\n K = ma[1]*ma[1] + ma[3]*ma[3];\n\n // the discriminant of the characteristic polynomial of ma * transpose(ma)\n var D = ((ma[0]-ma[3])*(ma[0]-ma[3]) + (ma[2]+ma[1])*(ma[2]+ma[1])) *\n ((ma[0]+ma[3])*(ma[0]+ma[3]) + (ma[2]-ma[1])*(ma[2]-ma[1]));\n\n // the \"mean eigenvalue\"\n var JK = (J + K) / 2;\n\n // check if the image is (almost) a circle\n if (D < epsilon * JK) {\n // if it is\n this.rx = this.ry = Math.sqrt(JK);\n this.ax = 0;\n return this;\n }\n\n // if it is not a circle\n var L = ma[0]*ma[1] + ma[2]*ma[3];\n\n D = Math.sqrt(D);\n\n // {l1,l2} = the two eigen values of ma * transpose(ma)\n var l1 = JK + D/2,\n l2 = JK - D/2;\n // the x - axis - rotation angle is the argument of the l1 - eigenvector\n /*eslint-disable indent*/\n this.ax = (Math.abs(L) < epsilon && Math.abs(l1 - K) < epsilon) ?\n 90\n :\n Math.atan(Math.abs(L) > Math.abs(l1 - K) ?\n (l1 - J) / L\n :\n L / (l1 - K)\n ) * 180 / Math.PI;\n /*eslint-enable indent*/\n\n // if ax > 0 => rx = sqrt(l1), ry = sqrt(l2), else exchange axes and ax += 90\n if (this.ax >= 0) {\n // if ax in [0,90]\n this.rx = Math.sqrt(l1);\n this.ry = Math.sqrt(l2);\n } else {\n // if ax in ]-90,0[ => exchange axes\n this.ax += 90;\n this.rx = Math.sqrt(l2);\n this.ry = Math.sqrt(l1);\n }\n\n return this;\n};\n\n// Check if the ellipse is (almost) degenerate, i.e. rx = 0 or ry = 0\n//\nEllipse.prototype.isDegenerate = function () {\n return (this.rx < epsilon * this.ry || this.ry < epsilon * this.rx);\n};\n\nmodule.exports = Ellipse;\n","// SVG Path transformations library\n//\n// Usage:\n//\n// SvgPath('...')\n// .translate(-150, -100)\n// .scale(0.5)\n// .translate(-150, -100)\n// .toFixed(1)\n// .toString()\n//\n\n'use strict';\n\n\nvar pathParse = require('./path_parse');\nvar transformParse = require('./transform_parse');\nvar matrix = require('./matrix');\nvar a2c = require('./a2c');\nvar ellipse = require('./ellipse');\n\n\n// Class constructor\n//\nfunction SvgPath(path) {\n if (!(this instanceof SvgPath)) { return new SvgPath(path); }\n\n var pstate = pathParse(path);\n\n // Array of path segments.\n // Each segment is array [command, param1, param2, ...]\n this.segments = pstate.segments;\n\n // Error message on parse error.\n this.err = pstate.err;\n\n // Transforms stack for lazy evaluation\n this.__stack = [];\n}\n\nSvgPath.from = function (src) {\n if (typeof src === 'string') return new SvgPath(src);\n\n if (src instanceof SvgPath) {\n // Create empty object\n var s = new SvgPath('');\n\n // Clone properies\n s.err = src.err;\n s.segments = src.segments.map(function (sgm) { return sgm.slice(); });\n s.__stack = src.__stack.map(function (m) {\n return matrix().matrix(m.toArray());\n });\n\n return s;\n }\n\n throw new Error('SvgPath.from: invalid param type ' + src);\n};\n\n\nSvgPath.prototype.__matrix = function (m) {\n var self = this, i;\n\n // Quick leave for empty matrix\n if (!m.queue.length) { return; }\n\n this.iterate(function (s, index, x, y) {\n var p, result, name, isRelative;\n\n switch (s[0]) {\n\n // Process 'assymetric' commands separately\n case 'v':\n p = m.calc(0, s[1], true);\n result = (p[0] === 0) ? [ 'v', p[1] ] : [ 'l', p[0], p[1] ];\n break;\n\n case 'V':\n p = m.calc(x, s[1], false);\n result = (p[0] === m.calc(x, y, false)[0]) ? [ 'V', p[1] ] : [ 'L', p[0], p[1] ];\n break;\n\n case 'h':\n p = m.calc(s[1], 0, true);\n result = (p[1] === 0) ? [ 'h', p[0] ] : [ 'l', p[0], p[1] ];\n break;\n\n case 'H':\n p = m.calc(s[1], y, false);\n result = (p[1] === m.calc(x, y, false)[1]) ? [ 'H', p[0] ] : [ 'L', p[0], p[1] ];\n break;\n\n case 'a':\n case 'A':\n // ARC is: ['A', rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]\n\n // Drop segment if arc is empty (end point === start point)\n /*if ((s[0] === 'A' && s[6] === x && s[7] === y) ||\n (s[0] === 'a' && s[6] === 0 && s[7] === 0)) {\n return [];\n }*/\n\n // Transform rx, ry and the x-axis-rotation\n var ma = m.toArray();\n var e = ellipse(s[1], s[2], s[3]).transform(ma);\n\n // flip sweep-flag if matrix is not orientation-preserving\n if (ma[0] * ma[3] - ma[1] * ma[2] < 0) {\n s[5] = s[5] ? '0' : '1';\n }\n\n // Transform end point as usual (without translation for relative notation)\n p = m.calc(s[6], s[7], s[0] === 'a');\n\n // Empty arcs can be ignored by renderer, but should not be dropped\n // to avoid collisions with `S A S` and so on. Replace with empty line.\n if ((s[0] === 'A' && s[6] === x && s[7] === y) ||\n (s[0] === 'a' && s[6] === 0 && s[7] === 0)) {\n result = [ s[0] === 'a' ? 'l' : 'L', p[0], p[1] ];\n break;\n }\n\n // if the resulting ellipse is (almost) a segment ...\n if (e.isDegenerate()) {\n // replace the arc by a line\n result = [ s[0] === 'a' ? 'l' : 'L', p[0], p[1] ];\n } else {\n // if it is a real ellipse\n // s[0], s[4] and s[5] are not modified\n result = [ s[0], e.rx, e.ry, e.ax, s[4], s[5], p[0], p[1] ];\n }\n\n break;\n\n case 'm':\n // Edge case. The very first `m` should be processed as absolute, if happens.\n // Make sense for coord shift transforms.\n isRelative = index > 0;\n\n p = m.calc(s[1], s[2], isRelative);\n result = [ 'm', p[0], p[1] ];\n break;\n\n default:\n name = s[0];\n result = [ name ];\n isRelative = (name.toLowerCase() === name);\n\n // Apply transformations to the segment\n for (i = 1; i < s.length; i += 2) {\n p = m.calc(s[i], s[i + 1], isRelative);\n result.push(p[0], p[1]);\n }\n }\n\n self.segments[index] = result;\n }, true);\n};\n\n\n// Apply stacked commands\n//\nSvgPath.prototype.__evaluateStack = function () {\n var m, i;\n\n if (!this.__stack.length) { return; }\n\n if (this.__stack.length === 1) {\n this.__matrix(this.__stack[0]);\n this.__stack = [];\n return;\n }\n\n m = matrix();\n i = this.__stack.length;\n\n while (--i >= 0) {\n m.matrix(this.__stack[i].toArray());\n }\n\n this.__matrix(m);\n this.__stack = [];\n};\n\n\n// Convert processed SVG Path back to string\n//\nSvgPath.prototype.toString = function () {\n var elements = [], skipCmd, cmd;\n\n this.__evaluateStack();\n\n for (var i = 0; i < this.segments.length; i++) {\n // remove repeating commands names\n cmd = this.segments[i][0];\n skipCmd = i > 0 && cmd !== 'm' && cmd !== 'M' && cmd === this.segments[i - 1][0];\n elements = elements.concat(skipCmd ? this.segments[i].slice(1) : this.segments[i]);\n }\n\n return elements.join(' ')\n // Optimizations: remove spaces around commands & before `-`\n //\n // We could also remove leading zeros for `0.5`-like values,\n // but their count is too small to spend time for.\n .replace(/ ?([achlmqrstvz]) ?/gi, '$1')\n .replace(/ \\-/g, '-')\n // workaround for FontForge SVG importing bug\n .replace(/zm/g, 'z m');\n};\n\n\n// Translate path to (x [, y])\n//\nSvgPath.prototype.translate = function (x, y) {\n this.__stack.push(matrix().translate(x, y || 0));\n return this;\n};\n\n\n// Scale path to (sx [, sy])\n// sy = sx if not defined\n//\nSvgPath.prototype.scale = function (sx, sy) {\n this.__stack.push(matrix().scale(sx, (!sy && (sy !== 0)) ? sx : sy));\n return this;\n};\n\n\n// Rotate path around point (sx [, sy])\n// sy = sx if not defined\n//\nSvgPath.prototype.rotate = function (angle, rx, ry) {\n this.__stack.push(matrix().rotate(angle, rx || 0, ry || 0));\n return this;\n};\n\n\n// Skew path along the X axis by `degrees` angle\n//\nSvgPath.prototype.skewX = function (degrees) {\n this.__stack.push(matrix().skewX(degrees));\n return this;\n};\n\n\n// Skew path along the Y axis by `degrees` angle\n//\nSvgPath.prototype.skewY = function (degrees) {\n this.__stack.push(matrix().skewY(degrees));\n return this;\n};\n\n\n// Apply matrix transform (array of 6 elements)\n//\nSvgPath.prototype.matrix = function (m) {\n this.__stack.push(matrix().matrix(m));\n return this;\n};\n\n\n// Transform path according to \"transform\" attr of SVG spec\n//\nSvgPath.prototype.transform = function (transformString) {\n if (!transformString.trim()) {\n return this;\n }\n this.__stack.push(transformParse(transformString));\n return this;\n};\n\n\n// Round coords with given decimal precition.\n// 0 by default (to integers)\n//\nSvgPath.prototype.round = function (d) {\n var contourStartDeltaX = 0, contourStartDeltaY = 0, deltaX = 0, deltaY = 0, l;\n\n d = d || 0;\n\n this.__evaluateStack();\n\n this.segments.forEach(function (s) {\n var isRelative = (s[0].toLowerCase() === s[0]);\n\n switch (s[0]) {\n case 'H':\n case 'h':\n if (isRelative) { s[1] += deltaX; }\n deltaX = s[1] - s[1].toFixed(d);\n s[1] = +s[1].toFixed(d);\n return;\n\n case 'V':\n case 'v':\n if (isRelative) { s[1] += deltaY; }\n deltaY = s[1] - s[1].toFixed(d);\n s[1] = +s[1].toFixed(d);\n return;\n\n case 'Z':\n case 'z':\n deltaX = contourStartDeltaX;\n deltaY = contourStartDeltaY;\n return;\n\n case 'M':\n case 'm':\n if (isRelative) {\n s[1] += deltaX;\n s[2] += deltaY;\n }\n\n deltaX = s[1] - s[1].toFixed(d);\n deltaY = s[2] - s[2].toFixed(d);\n\n contourStartDeltaX = deltaX;\n contourStartDeltaY = deltaY;\n\n s[1] = +s[1].toFixed(d);\n s[2] = +s[2].toFixed(d);\n return;\n\n case 'A':\n case 'a':\n // [cmd, rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]\n if (isRelative) {\n s[6] += deltaX;\n s[7] += deltaY;\n }\n\n deltaX = s[6] - s[6].toFixed(d);\n deltaY = s[7] - s[7].toFixed(d);\n\n s[1] = +s[1].toFixed(d);\n s[2] = +s[2].toFixed(d);\n s[3] = +s[3].toFixed(d + 2); // better precision for rotation\n s[6] = +s[6].toFixed(d);\n s[7] = +s[7].toFixed(d);\n return;\n\n default:\n // a c l q s t\n l = s.length;\n\n if (isRelative) {\n s[l - 2] += deltaX;\n s[l - 1] += deltaY;\n }\n\n deltaX = s[l - 2] - s[l - 2].toFixed(d);\n deltaY = s[l - 1] - s[l - 1].toFixed(d);\n\n s.forEach(function (val, i) {\n if (!i) { return; }\n s[i] = +s[i].toFixed(d);\n });\n return;\n }\n });\n\n return this;\n};\n\n\n// Apply iterator function to all segments. If function returns result,\n// current segment will be replaced to array of returned segments.\n// If empty array is returned, current regment will be deleted.\n//\nSvgPath.prototype.iterate = function (iterator, keepLazyStack) {\n var segments = this.segments,\n replacements = {},\n needReplace = false,\n lastX = 0,\n lastY = 0,\n countourStartX = 0,\n countourStartY = 0;\n var i, j, newSegments;\n\n if (!keepLazyStack) {\n this.__evaluateStack();\n }\n\n segments.forEach(function (s, index) {\n\n var res = iterator(s, index, lastX, lastY);\n\n if (Array.isArray(res)) {\n replacements[index] = res;\n needReplace = true;\n }\n\n var isRelative = (s[0] === s[0].toLowerCase());\n\n // calculate absolute X and Y\n switch (s[0]) {\n case 'm':\n case 'M':\n lastX = s[1] + (isRelative ? lastX : 0);\n lastY = s[2] + (isRelative ? lastY : 0);\n countourStartX = lastX;\n countourStartY = lastY;\n return;\n\n case 'h':\n case 'H':\n lastX = s[1] + (isRelative ? lastX : 0);\n return;\n\n case 'v':\n case 'V':\n lastY = s[1] + (isRelative ? lastY : 0);\n return;\n\n case 'z':\n case 'Z':\n // That make sence for multiple contours\n lastX = countourStartX;\n lastY = countourStartY;\n return;\n\n default:\n lastX = s[s.length - 2] + (isRelative ? lastX : 0);\n lastY = s[s.length - 1] + (isRelative ? lastY : 0);\n }\n });\n\n // Replace segments if iterator return results\n\n if (!needReplace) { return this; }\n\n newSegments = [];\n\n for (i = 0; i < segments.length; i++) {\n if (typeof replacements[i] !== 'undefined') {\n for (j = 0; j < replacements[i].length; j++) {\n newSegments.push(replacements[i][j]);\n }\n } else {\n newSegments.push(segments[i]);\n }\n }\n\n this.segments = newSegments;\n\n return this;\n};\n\n\n// Converts segments from relative to absolute\n//\nSvgPath.prototype.abs = function () {\n\n this.iterate(function (s, index, x, y) {\n var name = s[0],\n nameUC = name.toUpperCase(),\n i;\n\n // Skip absolute commands\n if (name === nameUC) { return; }\n\n s[0] = nameUC;\n\n switch (name) {\n case 'v':\n // v has shifted coords parity\n s[1] += y;\n return;\n\n case 'a':\n // ARC is: ['A', rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]\n // touch x, y only\n s[6] += x;\n s[7] += y;\n return;\n\n default:\n for (i = 1; i < s.length; i++) {\n s[i] += i % 2 ? x : y; // odd values are X, even - Y\n }\n }\n }, true);\n\n return this;\n};\n\n\n// Converts segments from absolute to relative\n//\nSvgPath.prototype.rel = function () {\n\n this.iterate(function (s, index, x, y) {\n var name = s[0],\n nameLC = name.toLowerCase(),\n i;\n\n // Skip relative commands\n if (name === nameLC) { return; }\n\n // Don't touch the first M to avoid potential confusions.\n if (index === 0 && name === 'M') { return; }\n\n s[0] = nameLC;\n\n switch (name) {\n case 'V':\n // V has shifted coords parity\n s[1] -= y;\n return;\n\n case 'A':\n // ARC is: ['A', rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]\n // touch x, y only\n s[6] -= x;\n s[7] -= y;\n return;\n\n default:\n for (i = 1; i < s.length; i++) {\n s[i] -= i % 2 ? x : y; // odd values are X, even - Y\n }\n }\n }, true);\n\n return this;\n};\n\n\n// Converts arcs to cubic bézier curves\n//\nSvgPath.prototype.unarc = function () {\n this.iterate(function (s, index, x, y) {\n var new_segments, nextX, nextY, result = [], name = s[0];\n\n // Skip anything except arcs\n if (name !== 'A' && name !== 'a') { return null; }\n\n if (name === 'a') {\n // convert relative arc coordinates to absolute\n nextX = x + s[6];\n nextY = y + s[7];\n } else {\n nextX = s[6];\n nextY = s[7];\n }\n\n new_segments = a2c(x, y, nextX, nextY, s[4], s[5], s[1], s[2], s[3]);\n\n // Degenerated arcs can be ignored by renderer, but should not be dropped\n // to avoid collisions with `S A S` and so on. Replace with empty line.\n if (new_segments.length === 0) {\n return [ [ s[0] === 'a' ? 'l' : 'L', s[6], s[7] ] ];\n }\n\n new_segments.forEach(function (s) {\n result.push([ 'C', s[2], s[3], s[4], s[5], s[6], s[7] ]);\n });\n\n return result;\n });\n\n return this;\n};\n\n\n// Converts smooth curves (with missed control point) to generic curves\n//\nSvgPath.prototype.unshort = function () {\n var segments = this.segments;\n var prevControlX, prevControlY, prevSegment;\n var curControlX, curControlY;\n\n // TODO: add lazy evaluation flag when relative commands supported\n\n this.iterate(function (s, idx, x, y) {\n var name = s[0], nameUC = name.toUpperCase(), isRelative;\n\n // First command MUST be M|m, it's safe to skip.\n // Protect from access to [-1] for sure.\n if (!idx) { return; }\n\n if (nameUC === 'T') { // quadratic curve\n isRelative = (name === 't');\n\n prevSegment = segments[idx - 1];\n\n if (prevSegment[0] === 'Q') {\n prevControlX = prevSegment[1] - x;\n prevControlY = prevSegment[2] - y;\n } else if (prevSegment[0] === 'q') {\n prevControlX = prevSegment[1] - prevSegment[3];\n prevControlY = prevSegment[2] - prevSegment[4];\n } else {\n prevControlX = 0;\n prevControlY = 0;\n }\n\n curControlX = -prevControlX;\n curControlY = -prevControlY;\n\n if (!isRelative) {\n curControlX += x;\n curControlY += y;\n }\n\n segments[idx] = [\n isRelative ? 'q' : 'Q',\n curControlX, curControlY,\n s[1], s[2]\n ];\n\n } else if (nameUC === 'S') { // cubic curve\n isRelative = (name === 's');\n\n prevSegment = segments[idx - 1];\n\n if (prevSegment[0] === 'C') {\n prevControlX = prevSegment[3] - x;\n prevControlY = prevSegment[4] - y;\n } else if (prevSegment[0] === 'c') {\n prevControlX = prevSegment[3] - prevSegment[5];\n prevControlY = prevSegment[4] - prevSegment[6];\n } else {\n prevControlX = 0;\n prevControlY = 0;\n }\n\n curControlX = -prevControlX;\n curControlY = -prevControlY;\n\n if (!isRelative) {\n curControlX += x;\n curControlY += y;\n }\n\n segments[idx] = [\n isRelative ? 'c' : 'C',\n curControlX, curControlY,\n s[1], s[2], s[3], s[4]\n ];\n }\n });\n\n return this;\n};\n\n\nmodule.exports = SvgPath;\n","'use strict';\n\nmodule.exports = require('./lib/svgpath');\n","// Calculate the specificity for a selector by dividing it into simple selectors and counting them\nvar calculate = function(input) {\n\tvar selectors,\n\t\tselector,\n\t\ti,\n\t\tlen,\n\t\tresults = [];\n\n\t// Separate input by commas\n\tselectors = input.split(',');\n\n\tfor (i = 0, len = selectors.length; i < len; i += 1) {\n\t\tselector = selectors[i];\n\t\tif (selector.length > 0) {\n\t\t\tresults.push(calculateSingle(selector));\n\t\t}\n\t}\n\n\treturn results;\n};\n\n/**\n * Calculates the specificity of CSS selectors\n * http://www.w3.org/TR/css3-selectors/#specificity\n *\n * Returns an object with the following properties:\n * - selector: the input\n * - specificity: e.g. 0,1,0,0\n * - parts: array with details about each part of the selector that counts towards the specificity\n * - specificityArray: e.g. [0, 1, 0, 0]\n */\nvar calculateSingle = function(input) {\n\tvar selector = input,\n\t\tfindMatch,\n\t\ttypeCount = {\n\t\t\t'a': 0,\n\t\t\t'b': 0,\n\t\t\t'c': 0\n\t\t},\n\t\tparts = [],\n\t\t// The following regular expressions assume that selectors matching the preceding regular expressions have been removed\n\t\tattributeRegex = /(\\[[^\\]]+\\])/g,\n\t\tidRegex = /(#[^\\#\\s\\+>~\\.\\[:\\)]+)/g,\n\t\tclassRegex = /(\\.[^\\s\\+>~\\.\\[:\\)]+)/g,\n\t\tpseudoElementRegex = /(::[^\\s\\+>~\\.\\[:]+|:first-line|:first-letter|:before|:after)/gi,\n\t\t// A regex for pseudo classes with brackets - :nth-child(), :nth-last-child(), :nth-of-type(), :nth-last-type(), :lang()\n\t\t// The negation psuedo class (:not) is filtered out because specificity is calculated on its argument\n\t\t// :global and :local are filtered out - they look like psuedo classes but are an identifier for CSS Modules\n\t\tpseudoClassWithBracketsRegex = /(:(?!not|global|local)[\\w-]+\\([^\\)]*\\))/gi,\n\t\t// A regex for other pseudo classes, which don't have brackets\n\t\tpseudoClassRegex = /(:(?!not|global|local)[^\\s\\+>~\\.\\[:]+)/g,\n\t\telementRegex = /([^\\s\\+>~\\.\\[:]+)/g;\n\n\t// Find matches for a regular expression in a string and push their details to parts\n\t// Type is \"a\" for IDs, \"b\" for classes, attributes and pseudo-classes and \"c\" for elements and pseudo-elements\n\tfindMatch = function(regex, type) {\n\t\tvar matches, i, len, match, index, length;\n\t\tif (regex.test(selector)) {\n\t\t\tmatches = selector.match(regex);\n\t\t\tfor (i = 0, len = matches.length; i < len; i += 1) {\n\t\t\t\ttypeCount[type] += 1;\n\t\t\t\tmatch = matches[i];\n\t\t\t\tindex = selector.indexOf(match);\n\t\t\t\tlength = match.length;\n\t\t\t\tparts.push({\n\t\t\t\t\tselector: input.substr(index, length),\n\t\t\t\t\ttype: type,\n\t\t\t\t\tindex: index,\n\t\t\t\t\tlength: length\n\t\t\t\t});\n\t\t\t\t// Replace this simple selector with whitespace so it won't be counted in further simple selectors\n\t\t\t\tselector = selector.replace(match, Array(length + 1).join(' '));\n\t\t\t}\n\t\t}\n\t};\n\n\t// Replace escaped characters with plain text, using the \"A\" character\n\t// https://www.w3.org/TR/CSS21/syndata.html#characters\n\t(function() {\n\t\tvar replaceWithPlainText = function(regex) {\n\t\t\t\tvar matches, i, len, match;\n\t\t\t\tif (regex.test(selector)) {\n\t\t\t\t\tmatches = selector.match(regex);\n\t\t\t\t\tfor (i = 0, len = matches.length; i < len; i += 1) {\n\t\t\t\t\t\tmatch = matches[i];\n\t\t\t\t\t\tselector = selector.replace(match, Array(match.length + 1).join('A'));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t// Matches a backslash followed by six hexadecimal digits followed by an optional single whitespace character\n\t\t\tescapeHexadecimalRegex = /\\\\[0-9A-Fa-f]{6}\\s?/g,\n\t\t\t// Matches a backslash followed by fewer than six hexadecimal digits followed by a mandatory single whitespace character\n\t\t\tescapeHexadecimalRegex2 = /\\\\[0-9A-Fa-f]{1,5}\\s/g,\n\t\t\t// Matches a backslash followed by any character\n\t\t\tescapeSpecialCharacter = /\\\\./g;\n\n\t\treplaceWithPlainText(escapeHexadecimalRegex);\n\t\treplaceWithPlainText(escapeHexadecimalRegex2);\n\t\treplaceWithPlainText(escapeSpecialCharacter);\n\t}());\n\n\t// Remove anything after a left brace in case a user has pasted in a rule, not just a selector\n\t(function() {\n\t\tvar regex = /{[^]*/gm,\n\t\t\tmatches, i, len, match;\n\t\tif (regex.test(selector)) {\n\t\t\tmatches = selector.match(regex);\n\t\t\tfor (i = 0, len = matches.length; i < len; i += 1) {\n\t\t\t\tmatch = matches[i];\n\t\t\t\tselector = selector.replace(match, Array(match.length + 1).join(' '));\n\t\t\t}\n\t\t}\n\t}());\n\n\t// Add attribute selectors to parts collection (type b)\n\tfindMatch(attributeRegex, 'b');\n\n\t// Add ID selectors to parts collection (type a)\n\tfindMatch(idRegex, 'a');\n\n\t// Add class selectors to parts collection (type b)\n\tfindMatch(classRegex, 'b');\n\n\t// Add pseudo-element selectors to parts collection (type c)\n\tfindMatch(pseudoElementRegex, 'c');\n\n\t// Add pseudo-class selectors to parts collection (type b)\n\tfindMatch(pseudoClassWithBracketsRegex, 'b');\n\tfindMatch(pseudoClassRegex, 'b');\n\n\t// Remove universal selector and separator characters\n\tselector = selector.replace(/[\\*\\s\\+>~]/g, ' ');\n\n\t// Remove any stray dots or hashes which aren't attached to words\n\t// These may be present if the user is live-editing this selector\n\tselector = selector.replace(/[#\\.]/g, ' ');\n\n\t// Remove the negation psuedo-class (:not) but leave its argument because specificity is calculated on its argument\n \t// Remove non-standard :local and :global CSS Module identifiers because they do not effect the specificity\n\tselector = selector.replace(/:not/g, ' ');\n\tselector = selector.replace(/:local/g, ' ');\n\tselector = selector.replace(/:global/g, ' ');\n\tselector = selector.replace(/[\\(\\)]/g, ' ');\n\n\t// The only things left should be element selectors (type c)\n\tfindMatch(elementRegex, 'c');\n\n\t// Order the parts in the order they appear in the original selector\n\t// This is neater for external apps to deal with\n\tparts.sort(function(a, b) {\n\t\treturn a.index - b.index;\n\t});\n\n\treturn {\n\t\tselector: input,\n\t\tspecificity: '0,' + typeCount.a.toString() + ',' + typeCount.b.toString() + ',' + typeCount.c.toString(),\n\t\tspecificityArray: [0, typeCount.a, typeCount.b, typeCount.c],\n\t\tparts: parts\n\t};\n};\n\n/**\n * Compares two CSS selectors for specificity\n * Alternatively you can replace one of the CSS selectors with a specificity array\n *\n * - it returns -1 if a has a lower specificity than b\n * - it returns 1 if a has a higher specificity than b\n * - it returns 0 if a has the same specificity than b\n */\nvar compare = function(a, b) {\n\tvar aSpecificity,\n\t\tbSpecificity,\n\t\ti;\n\n\tif (typeof a ==='string') {\n\t\tif (a.indexOf(',') !== -1) {\n\t\t\tthrow 'Invalid CSS selector';\n\t\t} else {\n\t\t\taSpecificity = calculateSingle(a)['specificityArray'];\n\t\t}\n\t} else if (Array.isArray(a)) {\n\t\tif (a.filter(function(e) { return (typeof e === 'number'); }).length !== 4) {\n\t\t\tthrow 'Invalid specificity array';\n\t\t} else {\n\t\t\taSpecificity = a;\n\t\t}\n\t} else {\n\t\tthrow 'Invalid CSS selector or specificity array';\n\t}\n\n\tif (typeof b ==='string') {\n\t\tif (b.indexOf(',') !== -1) {\n\t\t\tthrow 'Invalid CSS selector';\n\t\t} else {\n\t\t\tbSpecificity = calculateSingle(b)['specificityArray'];\n\t\t}\n\t} else if (Array.isArray(b)) {\n\t\tif (b.filter(function(e) { return (typeof e === 'number'); }).length !== 4) {\n\t\t\tthrow 'Invalid specificity array';\n\t\t} else {\n\t\t\tbSpecificity = b;\n\t\t}\n\t} else {\n\t\tthrow 'Invalid CSS selector or specificity array';\n\t}\n\n\tfor (i = 0; i < 4; i += 1) {\n\t\tif (aSpecificity[i] < bSpecificity[i]) {\n\t\t\treturn -1;\n\t\t} else if (aSpecificity[i] > bSpecificity[i]) {\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\treturn 0;\n};\n\nexport { calculate, compare };\n","/**\n * The MIT License (MIT)\n *\n * Copyright (c) 2015-2020 yWorks GmbH\n * Copyright (c) 2013-2015 by Vitaly Puzrin\n *\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport cssEsc from 'cssesc';\nimport FontFamily from 'font-family-papandreou';\nimport { GState, ShadingPattern, TilingPattern, jsPDF } from 'jspdf';\nimport SvgPath from 'svgpath';\nimport { compare } from 'specificity';\n\n/*! *****************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nfunction __extends(d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nvar __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\n\nfunction __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nfunction __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nvar RGBColor = /** @class */ (function () {\n function RGBColor(colorString) {\n this.a = undefined;\n this.r = 0;\n this.g = 0;\n this.b = 0;\n this.simpleColors = {};\n this.colorDefs = [];\n this.ok = false;\n if (!colorString) {\n return;\n }\n // strip any leading #\n if (colorString.charAt(0) == '#') {\n // remove # if any\n colorString = colorString.substr(1, 6);\n }\n colorString = colorString.replace(/ /g, '');\n colorString = colorString.toLowerCase();\n // before getting into regexps, try simple matches\n // and overwrite the input\n this.simpleColors = {\n aliceblue: 'f0f8ff',\n antiquewhite: 'faebd7',\n aqua: '00ffff',\n aquamarine: '7fffd4',\n azure: 'f0ffff',\n beige: 'f5f5dc',\n bisque: 'ffe4c4',\n black: '000000',\n blanchedalmond: 'ffebcd',\n blue: '0000ff',\n blueviolet: '8a2be2',\n brown: 'a52a2a',\n burlywood: 'deb887',\n cadetblue: '5f9ea0',\n chartreuse: '7fff00',\n chocolate: 'd2691e',\n coral: 'ff7f50',\n cornflowerblue: '6495ed',\n cornsilk: 'fff8dc',\n crimson: 'dc143c',\n cyan: '00ffff',\n darkblue: '00008b',\n darkcyan: '008b8b',\n darkgoldenrod: 'b8860b',\n darkgray: 'a9a9a9',\n darkgrey: 'a9a9a9',\n darkgreen: '006400',\n darkkhaki: 'bdb76b',\n darkmagenta: '8b008b',\n darkolivegreen: '556b2f',\n darkorange: 'ff8c00',\n darkorchid: '9932cc',\n darkred: '8b0000',\n darksalmon: 'e9967a',\n darkseagreen: '8fbc8f',\n darkslateblue: '483d8b',\n darkslategray: '2f4f4f',\n darkslategrey: '2f4f4f',\n darkturquoise: '00ced1',\n darkviolet: '9400d3',\n deeppink: 'ff1493',\n deepskyblue: '00bfff',\n dimgray: '696969',\n dimgrey: '696969',\n dodgerblue: '1e90ff',\n feldspar: 'd19275',\n firebrick: 'b22222',\n floralwhite: 'fffaf0',\n forestgreen: '228b22',\n fuchsia: 'ff00ff',\n gainsboro: 'dcdcdc',\n ghostwhite: 'f8f8ff',\n gold: 'ffd700',\n goldenrod: 'daa520',\n gray: '808080',\n grey: '808080',\n green: '008000',\n greenyellow: 'adff2f',\n honeydew: 'f0fff0',\n hotpink: 'ff69b4',\n indianred: 'cd5c5c',\n indigo: '4b0082',\n ivory: 'fffff0',\n khaki: 'f0e68c',\n lavender: 'e6e6fa',\n lavenderblush: 'fff0f5',\n lawngreen: '7cfc00',\n lemonchiffon: 'fffacd',\n lightblue: 'add8e6',\n lightcoral: 'f08080',\n lightcyan: 'e0ffff',\n lightgoldenrodyellow: 'fafad2',\n lightgray: 'd3d3d3',\n lightgrey: 'd3d3d3',\n lightgreen: '90ee90',\n lightpink: 'ffb6c1',\n lightsalmon: 'ffa07a',\n lightseagreen: '20b2aa',\n lightskyblue: '87cefa',\n lightslateblue: '8470ff',\n lightslategray: '778899',\n lightslategrey: '778899',\n lightsteelblue: 'b0c4de',\n lightyellow: 'ffffe0',\n lime: '00ff00',\n limegreen: '32cd32',\n linen: 'faf0e6',\n magenta: 'ff00ff',\n maroon: '800000',\n mediumaquamarine: '66cdaa',\n mediumblue: '0000cd',\n mediumorchid: 'ba55d3',\n mediumpurple: '9370d8',\n mediumseagreen: '3cb371',\n mediumslateblue: '7b68ee',\n mediumspringgreen: '00fa9a',\n mediumturquoise: '48d1cc',\n mediumvioletred: 'c71585',\n midnightblue: '191970',\n mintcream: 'f5fffa',\n mistyrose: 'ffe4e1',\n moccasin: 'ffe4b5',\n navajowhite: 'ffdead',\n navy: '000080',\n oldlace: 'fdf5e6',\n olive: '808000',\n olivedrab: '6b8e23',\n orange: 'ffa500',\n orangered: 'ff4500',\n orchid: 'da70d6',\n palegoldenrod: 'eee8aa',\n palegreen: '98fb98',\n paleturquoise: 'afeeee',\n palevioletred: 'd87093',\n papayawhip: 'ffefd5',\n peachpuff: 'ffdab9',\n peru: 'cd853f',\n pink: 'ffc0cb',\n plum: 'dda0dd',\n powderblue: 'b0e0e6',\n purple: '800080',\n red: 'ff0000',\n rosybrown: 'bc8f8f',\n royalblue: '4169e1',\n saddlebrown: '8b4513',\n salmon: 'fa8072',\n sandybrown: 'f4a460',\n seagreen: '2e8b57',\n seashell: 'fff5ee',\n sienna: 'a0522d',\n silver: 'c0c0c0',\n skyblue: '87ceeb',\n slateblue: '6a5acd',\n slategray: '708090',\n slategrey: '708090',\n snow: 'fffafa',\n springgreen: '00ff7f',\n steelblue: '4682b4',\n tan: 'd2b48c',\n teal: '008080',\n thistle: 'd8bfd8',\n tomato: 'ff6347',\n turquoise: '40e0d0',\n violet: 'ee82ee',\n violetred: 'd02090',\n wheat: 'f5deb3',\n white: 'ffffff',\n whitesmoke: 'f5f5f5',\n yellow: 'ffff00',\n yellowgreen: '9acd32'\n };\n for (var key in this.simpleColors) {\n if (colorString == key) {\n colorString = this.simpleColors[key];\n }\n }\n // emd of simple type-in colors\n // array of color definition objects\n this.colorDefs = [\n {\n re: /^rgb\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})\\)$/,\n example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],\n process: function (bits) {\n return [parseInt(bits[1]), parseInt(bits[2]), parseInt(bits[3])];\n }\n },\n {\n re: /^(\\w{2})(\\w{2})(\\w{2})$/,\n example: ['#00ff00', '336699'],\n process: function (bits) {\n return [parseInt(bits[1], 16), parseInt(bits[2], 16), parseInt(bits[3], 16)];\n }\n },\n {\n re: /^(\\w{1})(\\w{1})(\\w{1})$/,\n example: ['#fb0', 'f0f'],\n process: function (bits) {\n return [\n parseInt(bits[1] + bits[1], 16),\n parseInt(bits[2] + bits[2], 16),\n parseInt(bits[3] + bits[3], 16)\n ];\n }\n }\n ];\n // search through the definitions to find a match\n for (var i = 0; i < this.colorDefs.length; i++) {\n var re = this.colorDefs[i].re;\n var processor = this.colorDefs[i].process;\n var bits = re.exec(colorString);\n if (bits) {\n var channels = processor(bits);\n this.r = channels[0];\n this.g = channels[1];\n this.b = channels[2];\n this.ok = true;\n }\n }\n // validate/cleanup values\n this.r = this.r < 0 || isNaN(this.r) ? 0 : this.r > 255 ? 255 : this.r;\n this.g = this.g < 0 || isNaN(this.g) ? 0 : this.g > 255 ? 255 : this.g;\n this.b = this.b < 0 || isNaN(this.b) ? 0 : this.b > 255 ? 255 : this.b;\n }\n RGBColor.prototype.toRGB = function () {\n return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')';\n };\n RGBColor.prototype.toHex = function () {\n var r = this.r.toString(16);\n var g = this.g.toString(16);\n var b = this.b.toString(16);\n if (r.length == 1)\n r = '0' + r;\n if (g.length == 1)\n g = '0' + g;\n if (b.length == 1)\n b = '0' + b;\n return '#' + r + g + b;\n };\n // help\n RGBColor.prototype.getHelpXML = function () {\n var examples = [];\n // add regexps\n for (var i = 0; i < this.colorDefs.length; i++) {\n var example = this.colorDefs[i].example;\n for (var j = 0; j < example.length; j++) {\n examples[examples.length] = example[j];\n }\n }\n // add type-in colors\n for (var sc in this.simpleColors) {\n examples[examples.length] = sc;\n }\n var xml = document.createElement('ul');\n xml.setAttribute('id', 'rgbcolor-examples');\n for (var i = 0; i < examples.length; i++) {\n try {\n var listItem = document.createElement('li');\n var listColor = new RGBColor(examples[i]);\n var exampleDiv = document.createElement('div');\n exampleDiv.style.cssText =\n 'margin: 3px; ' +\n 'border: 1px solid black; ' +\n 'background:' +\n listColor.toHex() +\n '; ' +\n 'color:' +\n listColor.toHex();\n exampleDiv.appendChild(document.createTextNode('test'));\n var listItemValue = document.createTextNode(' ' + examples[i] + ' -> ' + listColor.toRGB() + ' -> ' + listColor.toHex());\n listItem.appendChild(exampleDiv);\n listItem.appendChild(listItemValue);\n xml.appendChild(listItem);\n }\n catch (e) { }\n }\n return xml;\n };\n return RGBColor;\n}());\n\nvar ColorFill = /** @class */ (function () {\n function ColorFill(color) {\n this.color = color;\n }\n ColorFill.prototype.getFillData = function (forNode, context) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, undefined];\n });\n });\n };\n return ColorFill;\n}());\n\nvar AttributeState = /** @class */ (function () {\n function AttributeState() {\n this.xmlSpace = '';\n this.fill = null;\n this.fillOpacity = 1.0;\n // public fillRule: string = null\n this.fontFamily = '';\n this.fontSize = 16;\n this.fontStyle = '';\n // public fontVariant: string\n this.fontWeight = '';\n this.opacity = 1.0;\n this.stroke = null;\n this.strokeDasharray = null;\n this.strokeDashoffset = 0;\n this.strokeLinecap = '';\n this.strokeLinejoin = '';\n this.strokeMiterlimit = 4.0;\n this.strokeOpacity = 1.0;\n this.strokeWidth = 1.0;\n // public textAlign: string\n this.alignmentBaseline = '';\n this.textAnchor = '';\n this.visibility = '';\n }\n AttributeState.prototype.clone = function () {\n var clone = new AttributeState();\n clone.xmlSpace = this.xmlSpace;\n clone.fill = this.fill;\n clone.fillOpacity = this.fillOpacity;\n // clone.fillRule = this.fillRule;\n clone.fontFamily = this.fontFamily;\n clone.fontSize = this.fontSize;\n clone.fontStyle = this.fontStyle;\n // clone.fontVariant = this.fontVariant;\n clone.fontWeight = this.fontWeight;\n clone.opacity = this.opacity;\n clone.stroke = this.stroke;\n clone.strokeDasharray = this.strokeDasharray;\n clone.strokeDashoffset = this.strokeDashoffset;\n clone.strokeLinecap = this.strokeLinecap;\n clone.strokeLinejoin = this.strokeLinejoin;\n clone.strokeMiterlimit = this.strokeMiterlimit;\n clone.strokeOpacity = this.strokeOpacity;\n clone.strokeWidth = this.strokeWidth;\n // clone.textAlign = this.textAlign;\n clone.textAnchor = this.textAnchor;\n clone.alignmentBaseline = this.alignmentBaseline;\n clone.visibility = this.visibility;\n return clone;\n };\n AttributeState.default = function () {\n var attributeState = new AttributeState();\n attributeState.xmlSpace = 'default';\n attributeState.fill = new ColorFill(new RGBColor('rgb(0, 0, 0)'));\n attributeState.fillOpacity = 1.0;\n // attributeState.fillRule = \"nonzero\";\n attributeState.fontFamily = 'times';\n attributeState.fontSize = 16;\n attributeState.fontStyle = 'normal';\n // attributeState.fontVariant = \"normal\";\n attributeState.fontWeight = 'normal';\n attributeState.opacity = 1.0;\n attributeState.stroke = null;\n attributeState.strokeDasharray = null;\n attributeState.strokeDashoffset = 0;\n attributeState.strokeLinecap = 'butt';\n attributeState.strokeLinejoin = 'miter';\n attributeState.strokeMiterlimit = 4.0;\n attributeState.strokeOpacity = 1.0;\n attributeState.strokeWidth = 1.0;\n // attributeState.textAlign = \"start\";\n attributeState.alignmentBaseline = 'baseline';\n attributeState.textAnchor = 'start';\n attributeState.visibility = 'visible';\n return attributeState;\n };\n return AttributeState;\n}());\n\nvar iriReference = /url\\([\"']?#([^\"']+)[\"']?\\)/;\nvar alignmentBaselineMap = {\n bottom: 'bottom',\n 'text-bottom': 'bottom',\n top: 'top',\n 'text-top': 'top',\n hanging: 'hanging',\n middle: 'middle',\n central: 'middle',\n center: 'middle',\n mathematical: 'middle',\n ideographic: 'ideographic',\n alphabetic: 'alphabetic',\n baseline: 'alphabetic'\n};\nvar svgNamespaceURI = 'http://www.w3.org/2000/svg';\n\nvar TextMeasure = /** @class */ (function () {\n function TextMeasure() {\n this.measureMethods = {};\n }\n TextMeasure.prototype.getTextOffset = function (text, attributeState) {\n var textAnchor = attributeState.textAnchor;\n if (textAnchor === 'start') {\n return 0;\n }\n var width = this.measureTextWidth(text, attributeState);\n var xOffset = 0;\n switch (textAnchor) {\n case 'end':\n xOffset = width;\n break;\n case 'middle':\n xOffset = width / 2;\n break;\n }\n return xOffset;\n };\n TextMeasure.prototype.measureTextWidth = function (text, attributeState) {\n if (text.length === 0) {\n return 0;\n }\n var fontFamily = attributeState.fontFamily;\n var measure = this.getMeasureFunction(fontFamily);\n return measure.call(this, text, attributeState.fontFamily, attributeState.fontSize + 'px', attributeState.fontStyle, attributeState.fontWeight);\n };\n TextMeasure.prototype.getMeasurementTextNode = function () {\n if (!this.textMeasuringTextElement) {\n this.textMeasuringTextElement = document.createElementNS(svgNamespaceURI, 'text');\n var svg = document.createElementNS(svgNamespaceURI, 'svg');\n svg.appendChild(this.textMeasuringTextElement);\n svg.style.setProperty('position', 'absolute');\n svg.style.setProperty('visibility', 'hidden');\n document.body.appendChild(svg);\n }\n return this.textMeasuringTextElement;\n };\n TextMeasure.prototype.canvasTextMeasure = function (text, fontFamily, fontSize, fontStyle, fontWeight) {\n var canvas = document.createElement('canvas');\n var context = canvas.getContext('2d');\n if (context != null) {\n context.font = [fontStyle, fontWeight, fontSize, fontFamily].join(' ');\n return context.measureText(text).width;\n }\n return 0;\n };\n TextMeasure.prototype.svgTextMeasure = function (text, fontFamily, fontSize, fontStyle, fontWeight, measurementTextNode) {\n if (measurementTextNode === void 0) { measurementTextNode = this.getMeasurementTextNode(); }\n var textNode = measurementTextNode;\n textNode.setAttribute('font-family', fontFamily);\n textNode.setAttribute('font-size', fontSize);\n textNode.setAttribute('font-style', fontStyle);\n textNode.setAttribute('font-weight', fontWeight);\n textNode.setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:space', 'preserve');\n textNode.textContent = text;\n return textNode.getBBox().width;\n };\n /**\n * Canvas text measuring is a lot faster than svg measuring. However, it is inaccurate for some fonts. So test each\n * font once and decide if canvas is accurate enough.\n */\n TextMeasure.prototype.getMeasureFunction = function (fontFamily) {\n var method = this.measureMethods[fontFamily];\n if (!method) {\n var fontSize = '16px';\n var fontStyle = 'normal';\n var fontWeight = 'normal';\n var canvasWidth = this.canvasTextMeasure(TextMeasure.testString, fontFamily, fontSize, fontStyle, fontWeight);\n var svgWidth = this.svgTextMeasure(TextMeasure.testString, fontFamily, fontSize, fontStyle, fontWeight);\n method =\n Math.abs(canvasWidth - svgWidth) < TextMeasure.epsilon\n ? this.canvasTextMeasure\n : this.svgTextMeasure;\n this.measureMethods[fontFamily] = method;\n }\n return method;\n };\n TextMeasure.prototype.cleanupTextMeasuring = function () {\n if (this.textMeasuringTextElement) {\n var parentNode = this.textMeasuringTextElement.parentNode;\n if (parentNode) {\n document.body.removeChild(parentNode);\n }\n this.textMeasuringTextElement = undefined;\n }\n };\n TextMeasure.testString = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789!\"$%&/()=?\\'\\\\+*-_.:,;^}][{#~|<>';\n TextMeasure.epsilon = 0.1;\n return TextMeasure;\n}());\n\n/**\n *\n * @package\n * @param values\n * @constructor\n * @property pdf\n * @property attributeState Keeps track of parent attributes that are inherited automatically\n * @property refsHandler The handler that will render references on demand\n * @property styleSheets\n * @property textMeasure\n * @property transform The current transformation matrix\n * @property withinClipPath\n */\nvar Context = /** @class */ (function () {\n function Context(pdf, values) {\n var _a, _b, _c, _d, _e, _f;\n this.pdf = pdf;\n this.svg2pdfParameters = values.svg2pdfParameters;\n this.attributeState = values.attributeState\n ? values.attributeState.clone()\n : AttributeState.default();\n this.viewport = values.viewport;\n this.refsHandler = (_a = values.refsHandler) !== null && _a !== void 0 ? _a : null;\n this.styleSheets = (_b = values.styleSheets) !== null && _b !== void 0 ? _b : null;\n this.textMeasure = (_c = values.textMeasure) !== null && _c !== void 0 ? _c : new TextMeasure();\n this.transform = (_d = values.transform) !== null && _d !== void 0 ? _d : this.pdf.unitMatrix;\n this.withinClipPath = (_e = values.withinClipPath) !== null && _e !== void 0 ? _e : false;\n this.withinUse = (_f = values.withinUse) !== null && _f !== void 0 ? _f : false;\n }\n Context.prototype.clone = function (values) {\n var _a, _b, _c, _d, _e, _f, _g, _h;\n if (values === void 0) { values = {}; }\n return new Context(this.pdf, {\n svg2pdfParameters: (_a = values.svg2pdfParameters) !== null && _a !== void 0 ? _a : this.svg2pdfParameters,\n attributeState: values.attributeState\n ? values.attributeState.clone()\n : this.attributeState.clone(),\n viewport: (_b = values.viewport) !== null && _b !== void 0 ? _b : this.viewport,\n refsHandler: (_c = values.refsHandler) !== null && _c !== void 0 ? _c : this.refsHandler,\n styleSheets: (_d = values.styleSheets) !== null && _d !== void 0 ? _d : this.styleSheets,\n textMeasure: (_e = values.textMeasure) !== null && _e !== void 0 ? _e : this.textMeasure,\n transform: (_f = values.transform) !== null && _f !== void 0 ? _f : this.transform,\n withinClipPath: (_g = values.withinClipPath) !== null && _g !== void 0 ? _g : this.withinClipPath,\n withinUse: (_h = values.withinUse) !== null && _h !== void 0 ? _h : this.withinUse\n });\n };\n return Context;\n}());\n\nvar ReferencesHandler = /** @class */ (function () {\n function ReferencesHandler(idMap) {\n this.renderedElements = {};\n this.idMap = idMap;\n }\n ReferencesHandler.prototype.getRendered = function (id, renderCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var svgNode;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (this.renderedElements.hasOwnProperty(id)) {\n return [2 /*return*/, this.renderedElements[id]];\n }\n svgNode = this.get(id);\n this.renderedElements[id] = svgNode;\n return [4 /*yield*/, renderCallback(svgNode)];\n case 1:\n _a.sent();\n return [2 /*return*/, svgNode];\n }\n });\n });\n };\n ReferencesHandler.prototype.get = function (id) {\n return this.idMap[cssEsc(id, { isIdentifier: true })];\n };\n return ReferencesHandler;\n}());\n\nfunction getAngle(from, to) {\n return Math.atan2(to[1] - from[1], to[0] - from[0]);\n}\nvar cToQ = 2 / 3; // ratio to convert quadratic bezier curves to cubic ones\n// transforms a cubic bezier control point to a quadratic one: returns from + (2/3) * (to - from)\nfunction toCubic(from, to) {\n return [cToQ * (to[0] - from[0]) + from[0], cToQ * (to[1] - from[1]) + from[1]];\n}\nfunction normalize(v) {\n var length = Math.sqrt(v[0] * v[0] + v[1] * v[1]);\n return [v[0] / length, v[1] / length];\n}\nfunction getDirectionVector(from, to) {\n var v = [to[0] - from[0], to[1] - from[1]];\n return normalize(v);\n}\nfunction addVectors(v1, v2) {\n return [v1[0] + v2[0], v1[1] + v2[1]];\n}\n// multiplies a vector with a matrix: vec' = vec * matrix\nfunction multVecMatrix(vec, matrix) {\n var x = vec[0];\n var y = vec[1];\n return [matrix.a * x + matrix.c * y + matrix.e, matrix.b * x + matrix.d * y + matrix.f];\n}\n\nvar Path = /** @class */ (function () {\n function Path() {\n this.segments = [];\n }\n Path.prototype.moveTo = function (x, y) {\n this.segments.push(new MoveTo(x, y));\n return this;\n };\n Path.prototype.lineTo = function (x, y) {\n this.segments.push(new LineTo(x, y));\n return this;\n };\n Path.prototype.curveTo = function (x1, y1, x2, y2, x, y) {\n this.segments.push(new CurveTo(x1, y1, x2, y2, x, y));\n return this;\n };\n Path.prototype.close = function () {\n this.segments.push(new Close());\n return this;\n };\n /**\n * Transforms the path in place\n */\n Path.prototype.transform = function (matrix) {\n this.segments.forEach(function (seg) {\n if (seg instanceof MoveTo || seg instanceof LineTo || seg instanceof CurveTo) {\n var p = multVecMatrix([seg.x, seg.y], matrix);\n seg.x = p[0];\n seg.y = p[1];\n }\n if (seg instanceof CurveTo) {\n var p1 = multVecMatrix([seg.x1, seg.y1], matrix);\n var p2 = multVecMatrix([seg.x2, seg.y2], matrix);\n seg.x1 = p1[0];\n seg.y1 = p1[1];\n seg.x2 = p2[0];\n seg.y2 = p2[1];\n }\n });\n };\n Path.prototype.draw = function (context) {\n var p = context.pdf;\n this.segments.forEach(function (s) {\n if (s instanceof MoveTo) {\n p.moveTo(s.x, s.y);\n }\n else if (s instanceof LineTo) {\n p.lineTo(s.x, s.y);\n }\n else if (s instanceof CurveTo) {\n p.curveTo(s.x1, s.y1, s.x2, s.y2, s.x, s.y);\n }\n else {\n p.close();\n }\n });\n };\n return Path;\n}());\nvar MoveTo = /** @class */ (function () {\n function MoveTo(x, y) {\n this.x = x;\n this.y = y;\n }\n return MoveTo;\n}());\nvar LineTo = /** @class */ (function () {\n function LineTo(x, y) {\n this.x = x;\n this.y = y;\n }\n return LineTo;\n}());\nvar CurveTo = /** @class */ (function () {\n function CurveTo(x1, y1, x2, y2, x, y) {\n this.x1 = x1;\n this.y1 = y1;\n this.x2 = x2;\n this.y2 = y2;\n this.x = x;\n this.y = y;\n }\n return CurveTo;\n}());\nvar Close = /** @class */ (function () {\n function Close() {\n }\n return Close;\n}());\n\nfunction nodeIs(node, tagsString) {\n return tagsString.split(',').indexOf((node.nodeName || node.tagName).toLowerCase()) >= 0;\n}\nfunction forEachChild(node, fn) {\n // copy list of children, as the original might be modified\n var children = [];\n for (var i = 0; i < node.childNodes.length; i++) {\n var childNode = node.childNodes[i];\n if (childNode.nodeName.charAt(0) !== '#')\n children.push(childNode);\n }\n for (var i = 0; i < children.length; i++) {\n fn(i, children[i]);\n }\n}\n// returns an attribute of a node, either from the node directly or from css\nfunction getAttribute(node, styleSheets, propertyNode, propertyCss) {\n if (propertyCss === void 0) { propertyCss = propertyNode; }\n var attribute = node.style.getPropertyValue(propertyCss);\n if (attribute) {\n return attribute;\n }\n else if (styleSheets.getPropertyValue(node, propertyCss)) {\n return styleSheets.getPropertyValue(node, propertyCss);\n }\n else if (node.hasAttribute(propertyNode)) {\n return node.getAttribute(propertyNode) || undefined;\n }\n else {\n return undefined;\n }\n}\nfunction svgNodeIsVisible(svgNode, parentVisible, context) {\n if (getAttribute(svgNode.element, context.styleSheets, 'display') === 'none') {\n return false;\n }\n var visible = parentVisible;\n var visibility = getAttribute(svgNode.element, context.styleSheets, 'visibility');\n if (visibility) {\n visible = visibility !== 'hidden';\n }\n return visible;\n}\nfunction svgNodeAndChildrenVisible(svgNode, parentVisible, context) {\n var visible = svgNodeIsVisible(svgNode, parentVisible, context);\n if (svgNode.element.childNodes.length === 0) {\n return false;\n }\n svgNode.children.forEach(function (child) {\n if (child.isVisible(visible, context)) {\n visible = true;\n }\n });\n return visible;\n}\n\n/**\n * @constructor\n * @property {Marker[]} markers\n */\nvar MarkerList = /** @class */ (function () {\n function MarkerList() {\n this.markers = [];\n }\n MarkerList.prototype.addMarker = function (markers) {\n this.markers.push(markers);\n };\n MarkerList.prototype.draw = function (context) {\n return __awaiter(this, void 0, void 0, function () {\n var i, marker, tf, angle, anchor, cos, sin;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n i = 0;\n _a.label = 1;\n case 1:\n if (!(i < this.markers.length)) return [3 /*break*/, 4];\n marker = this.markers[i];\n tf = void 0;\n angle = marker.angle, anchor = marker.anchor;\n cos = Math.cos(angle);\n sin = Math.sin(angle);\n // position at and rotate around anchor\n tf = context.pdf.Matrix(cos, sin, -sin, cos, anchor[0], anchor[1]);\n // scale with stroke-width\n tf = context.pdf.matrixMult(context.pdf.Matrix(context.attributeState.strokeWidth, 0, 0, context.attributeState.strokeWidth, 0, 0), tf);\n tf = context.pdf.matrixMult(tf, context.transform);\n // as the marker is already scaled by the current line width we must not apply the line width twice!\n context.pdf.saveGraphicsState();\n context.pdf.setLineWidth(1.0);\n return [4 /*yield*/, context.refsHandler.getRendered(marker.id, function (node) { return node.apply(context); })];\n case 2:\n _a.sent();\n context.pdf.doFormObject(marker.id, tf);\n context.pdf.restoreGraphicsState();\n _a.label = 3;\n case 3:\n i++;\n return [3 /*break*/, 1];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n return MarkerList;\n}());\n/**\n * @param {string} id\n * @param {[number,number]} anchor\n * @param {number} angle\n */\nvar Marker = /** @class */ (function () {\n function Marker(id, anchor, angle) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-ignore\n // @ts-ignore\n this.id = id;\n this.anchor = anchor;\n this.angle = angle;\n }\n return Marker;\n}());\n\n/**\n * Convert em, px and bare number attributes to pixel values\n * @param {string} value\n * @param {number} pdfFontSize\n */\nfunction toPixels(value, pdfFontSize) {\n var match;\n // em\n match = value && value.toString().match(/^([\\-0-9.]+)em$/);\n if (match) {\n return parseFloat(match[1]) * pdfFontSize;\n }\n // pixels\n match = value && value.toString().match(/^([\\-0-9.]+)(px|)$/);\n if (match) {\n return parseFloat(match[1]);\n }\n return 0;\n}\nfunction mapAlignmentBaseline(value) {\n return alignmentBaselineMap[value] || 'alphabetic';\n}\n\n/**\n * parses a comma, sign and/or whitespace separated string of floats and returns\n * the single floats in an array\n */\nfunction parseFloats(str) {\n var floats = [];\n var regex = /[+-]?(?:(?:\\d+\\.?\\d*)|(?:\\d*\\.?\\d+))(?:[eE][+-]?\\d+)?/g;\n var match;\n while ((match = regex.exec(str))) {\n floats.push(parseFloat(match[0]));\n }\n return floats;\n}\n// extends RGBColor by rgba colors as RGBColor is not capable of it\nfunction parseColor(colorString) {\n if (colorString === 'transparent') {\n var transparent = new RGBColor('rgb(0,0,0)');\n transparent.a = 0;\n return transparent;\n }\n var match = /\\s*rgba\\(((?:[^,\\)]*,){3}[^,\\)]*)\\)\\s*/.exec(colorString);\n if (match) {\n var floats = parseFloats(match[1]);\n var color = new RGBColor('rgb(' + floats.slice(0, 3).join(',') + ')');\n color.a = floats[3];\n return color;\n }\n else {\n return new RGBColor(colorString);\n }\n}\n\nvar fontAliases = {\n 'sans-serif': 'helvetica',\n verdana: 'helvetica',\n arial: 'helvetica',\n fixed: 'courier',\n monospace: 'courier',\n terminal: 'courier',\n serif: 'times',\n cursive: 'times',\n fantasy: 'times'\n};\nfunction findFirstAvailableFontFamily(attributeState, fontFamilies, context) {\n var fontType = '';\n if (attributeState.fontWeight === 'bold') {\n fontType = 'bold';\n }\n if (attributeState.fontStyle === 'italic') {\n fontType += 'italic';\n }\n if (fontType === '') {\n fontType = 'normal';\n }\n var availableFonts = context.pdf.getFontList();\n var firstAvailable = '';\n var fontIsAvailable = fontFamilies.some(function (font) {\n var availableStyles = availableFonts[font];\n if (availableStyles && availableStyles.indexOf(fontType) >= 0) {\n firstAvailable = font;\n return true;\n }\n font = font.toLowerCase();\n if (fontAliases.hasOwnProperty(font)) {\n firstAvailable = font;\n return true;\n }\n return false;\n });\n if (!fontIsAvailable) {\n firstAvailable = 'times';\n }\n return firstAvailable;\n}\n\nfunction getBoundingBoxByChildren(context, svgnode) {\n if (getAttribute(svgnode.element, context.styleSheets, 'display') === 'none') {\n return [0, 0, 0, 0];\n }\n var boundingBox = [0, 0, 0, 0];\n svgnode.children.forEach(function (child) {\n var nodeBox = child.getBoundingBox(context);\n boundingBox = [\n Math.min(boundingBox[0], nodeBox[0]),\n Math.min(boundingBox[1], nodeBox[1]),\n Math.max(boundingBox[0] + boundingBox[2], nodeBox[0] + nodeBox[2]) -\n Math.min(boundingBox[0], nodeBox[0]),\n Math.max(boundingBox[1] + boundingBox[3], nodeBox[1] + nodeBox[3]) -\n Math.min(boundingBox[1], nodeBox[1])\n ];\n });\n return boundingBox;\n}\nfunction defaultBoundingBox(element, context) {\n var pf = parseFloat;\n // TODO: check if there are other possible coordinate attributes\n var x1 = pf(element.getAttribute('x1')) ||\n pf(getAttribute(element, context.styleSheets, 'x')) ||\n pf(getAttribute(element, context.styleSheets, 'cx')) -\n pf(getAttribute(element, context.styleSheets, 'r')) ||\n 0;\n var x2 = pf(element.getAttribute('x2')) ||\n x1 + pf(getAttribute(element, context.styleSheets, 'width')) ||\n pf(getAttribute(element, context.styleSheets, 'cx')) +\n pf(getAttribute(element, context.styleSheets, 'r')) ||\n 0;\n var y1 = pf(element.getAttribute('y1')) ||\n pf(getAttribute(element, context.styleSheets, 'y')) ||\n pf(getAttribute(element, context.styleSheets, 'cy')) -\n pf(getAttribute(element, context.styleSheets, 'r')) ||\n 0;\n var y2 = pf(element.getAttribute('y2')) ||\n y1 + pf(getAttribute(element, context.styleSheets, 'height')) ||\n pf(getAttribute(element, context.styleSheets, 'cy')) +\n pf(getAttribute(element, context.styleSheets, 'r')) ||\n 0;\n return [\n Math.min(x1, x2),\n Math.min(y1, y2),\n Math.max(x1, x2) - Math.min(x1, x2),\n Math.max(y1, y2) - Math.min(y1, y2)\n ];\n}\n\nfunction computeViewBoxTransform(node, viewBox, eX, eY, eWidth, eHeight, context, noTranslate) {\n if (noTranslate === void 0) { noTranslate = false; }\n var vbX = viewBox[0];\n var vbY = viewBox[1];\n var vbWidth = viewBox[2];\n var vbHeight = viewBox[3];\n var scaleX = eWidth / vbWidth;\n var scaleY = eHeight / vbHeight;\n var align, meetOrSlice;\n var preserveAspectRatio = node.getAttribute('preserveAspectRatio');\n if (preserveAspectRatio) {\n var alignAndMeetOrSlice = preserveAspectRatio.split(' ');\n if (alignAndMeetOrSlice[0] === 'defer') {\n alignAndMeetOrSlice = alignAndMeetOrSlice.slice(1);\n }\n align = alignAndMeetOrSlice[0];\n meetOrSlice = alignAndMeetOrSlice[1] || 'meet';\n }\n else {\n align = 'xMidYMid';\n meetOrSlice = 'meet';\n }\n if (align !== 'none') {\n if (meetOrSlice === 'meet') {\n // uniform scaling with min scale\n scaleX = scaleY = Math.min(scaleX, scaleY);\n }\n else if (meetOrSlice === 'slice') {\n // uniform scaling with max scale\n scaleX = scaleY = Math.max(scaleX, scaleY);\n }\n }\n if (noTranslate) {\n return context.pdf.Matrix(scaleX, 0, 0, scaleY, 0, 0);\n }\n var translateX = eX - vbX * scaleX;\n var translateY = eY - vbY * scaleY;\n if (align.indexOf('xMid') >= 0) {\n translateX += (eWidth - vbWidth * scaleX) / 2;\n }\n else if (align.indexOf('xMax') >= 0) {\n translateX += eWidth - vbWidth * scaleX;\n }\n if (align.indexOf('YMid') >= 0) {\n translateY += (eHeight - vbHeight * scaleY) / 2;\n }\n else if (align.indexOf('YMax') >= 0) {\n translateY += eHeight - vbHeight * scaleY;\n }\n var translate = context.pdf.Matrix(1, 0, 0, 1, translateX, translateY);\n var scale = context.pdf.Matrix(scaleX, 0, 0, scaleY, 0, 0);\n return context.pdf.matrixMult(scale, translate);\n}\n// parses the \"transform\" string\nfunction parseTransform(transformString, context) {\n if (!transformString || transformString === 'none')\n return context.pdf.unitMatrix;\n var mRegex = /^[\\s,]*matrix\\(([^\\)]+)\\)\\s*/, tRegex = /^[\\s,]*translate\\(([^\\)]+)\\)\\s*/, rRegex = /^[\\s,]*rotate\\(([^\\)]+)\\)\\s*/, sRegex = /^[\\s,]*scale\\(([^\\)]+)\\)\\s*/, sXRegex = /^[\\s,]*skewX\\(([^\\)]+)\\)\\s*/, sYRegex = /^[\\s,]*skewY\\(([^\\)]+)\\)\\s*/;\n var resultMatrix = context.pdf.unitMatrix;\n var m;\n var tSLength;\n while (transformString.length > 0 && transformString.length !== tSLength) {\n tSLength = transformString.length;\n var match = mRegex.exec(transformString);\n if (match) {\n m = parseFloats(match[1]);\n resultMatrix = context.pdf.matrixMult(context.pdf.Matrix(m[0], m[1], m[2], m[3], m[4], m[5]), resultMatrix);\n transformString = transformString.substr(match[0].length);\n }\n match = rRegex.exec(transformString);\n if (match) {\n m = parseFloats(match[1]);\n var a = (Math.PI * m[0]) / 180;\n resultMatrix = context.pdf.matrixMult(context.pdf.Matrix(Math.cos(a), Math.sin(a), -Math.sin(a), Math.cos(a), 0, 0), resultMatrix);\n if (m[1] || m[2]) {\n var t1 = context.pdf.Matrix(1, 0, 0, 1, m[1], m[2]);\n var t2 = context.pdf.Matrix(1, 0, 0, 1, -m[1], -m[2]);\n resultMatrix = context.pdf.matrixMult(t2, context.pdf.matrixMult(resultMatrix, t1));\n }\n transformString = transformString.substr(match[0].length);\n }\n match = tRegex.exec(transformString);\n if (match) {\n m = parseFloats(match[1]);\n resultMatrix = context.pdf.matrixMult(context.pdf.Matrix(1, 0, 0, 1, m[0], m[1] || 0), resultMatrix);\n transformString = transformString.substr(match[0].length);\n }\n match = sRegex.exec(transformString);\n if (match) {\n m = parseFloats(match[1]);\n if (!m[1])\n m[1] = m[0];\n resultMatrix = context.pdf.matrixMult(context.pdf.Matrix(m[0], 0, 0, m[1], 0, 0), resultMatrix);\n transformString = transformString.substr(match[0].length);\n }\n match = sXRegex.exec(transformString);\n if (match) {\n m = parseFloat(match[1]);\n m *= Math.PI / 180;\n resultMatrix = context.pdf.matrixMult(context.pdf.Matrix(1, 0, Math.tan(m), 1, 0, 0), resultMatrix);\n transformString = transformString.substr(match[0].length);\n }\n match = sYRegex.exec(transformString);\n if (match) {\n m = parseFloat(match[1]);\n m *= Math.PI / 180;\n resultMatrix = context.pdf.matrixMult(context.pdf.Matrix(1, Math.tan(m), 0, 1, 0, 0), resultMatrix);\n transformString = transformString.substr(match[0].length);\n }\n }\n return resultMatrix;\n}\n\nvar SvgNode = /** @class */ (function () {\n function SvgNode(element, children) {\n this.element = element;\n this.children = children;\n }\n SvgNode.prototype.getBoundingBox = function (context) {\n if (getAttribute(this.element, context.styleSheets, 'display') === 'none') {\n return [0, 0, 0, 0];\n }\n return this.getBoundingBoxCore(context);\n };\n SvgNode.prototype.computeNodeTransform = function (context) {\n var nodeTransform = this.computeNodeTransformCore(context);\n var transformString = getAttribute(this.element, context.styleSheets, 'transform');\n if (!transformString)\n return nodeTransform;\n else\n return context.pdf.matrixMult(nodeTransform, parseTransform(transformString, context));\n };\n return SvgNode;\n}());\n\nvar NonRenderedNode = /** @class */ (function (_super) {\n __extends(NonRenderedNode, _super);\n function NonRenderedNode() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n NonRenderedNode.prototype.render = function (parentContext) {\n return Promise.resolve();\n };\n NonRenderedNode.prototype.getBoundingBoxCore = function (context) {\n return [];\n };\n NonRenderedNode.prototype.computeNodeTransformCore = function (context) {\n return context.pdf.unitMatrix;\n };\n return NonRenderedNode;\n}(SvgNode));\n\nvar Gradient = /** @class */ (function (_super) {\n __extends(Gradient, _super);\n function Gradient(pdfGradientType, element, children) {\n var _this = _super.call(this, element, children) || this;\n _this.pdfGradientType = pdfGradientType;\n return _this;\n }\n Gradient.prototype.apply = function (context) {\n return __awaiter(this, void 0, void 0, function () {\n var id, colors, opacitySum, hasOpacity, gState, pattern;\n return __generator(this, function (_a) {\n id = this.element.getAttribute('id');\n if (!id) {\n return [2 /*return*/];\n }\n colors = [];\n opacitySum = 0;\n hasOpacity = false;\n this.children.forEach(function (stop) {\n if (stop.element.tagName.toLowerCase() === 'stop') {\n var color = new RGBColor(getAttribute(stop.element, context.styleSheets, 'stop-color'));\n colors.push({\n offset: Gradient.parseGradientOffset(stop.element.getAttribute('offset') || '0'),\n color: [color.r, color.g, color.b]\n });\n var opacity = getAttribute(stop.element, context.styleSheets, 'stop-opacity');\n if (opacity && opacity !== '1') {\n opacitySum += parseFloat(opacity);\n hasOpacity = true;\n }\n }\n });\n if (hasOpacity) {\n gState = new GState({ opacity: opacitySum / colors.length });\n }\n pattern = new ShadingPattern(this.pdfGradientType, this.getCoordinates(), colors, gState);\n context.pdf.addShadingPattern(id, pattern);\n return [2 /*return*/];\n });\n });\n };\n Gradient.prototype.getBoundingBoxCore = function (context) {\n return defaultBoundingBox(this.element, context);\n };\n Gradient.prototype.computeNodeTransformCore = function (context) {\n return context.pdf.unitMatrix;\n };\n Gradient.prototype.isVisible = function (parentVisible, context) {\n return svgNodeAndChildrenVisible(this, parentVisible, context);\n };\n /**\n * Convert percentage to decimal\n */\n Gradient.parseGradientOffset = function (value) {\n var parsedValue = parseFloat(value);\n if (!isNaN(parsedValue) && value.indexOf('%') >= 0) {\n return parsedValue / 100;\n }\n return parsedValue;\n };\n return Gradient;\n}(NonRenderedNode));\n\nvar LinearGradient = /** @class */ (function (_super) {\n __extends(LinearGradient, _super);\n function LinearGradient(element, children) {\n return _super.call(this, 'axial', element, children) || this;\n }\n LinearGradient.prototype.getCoordinates = function () {\n return [\n parseFloat(this.element.getAttribute('x1') || '0'),\n parseFloat(this.element.getAttribute('y1') || '0'),\n parseFloat(this.element.getAttribute('x2') || '1'),\n parseFloat(this.element.getAttribute('y2') || '0')\n ];\n };\n return LinearGradient;\n}(Gradient));\n\nvar RadialGradient = /** @class */ (function (_super) {\n __extends(RadialGradient, _super);\n function RadialGradient(element, children) {\n return _super.call(this, 'radial', element, children) || this;\n }\n RadialGradient.prototype.getCoordinates = function () {\n var cx = this.element.getAttribute('cx');\n var cy = this.element.getAttribute('cy');\n var fx = this.element.getAttribute('fx');\n var fy = this.element.getAttribute('fy');\n return [\n parseFloat(fx || cx || '0.5'),\n parseFloat(fy || cy || '0.5'),\n 0,\n parseFloat(cx || '0.5'),\n parseFloat(cy || '0.5'),\n parseFloat(this.element.getAttribute('r') || '0.5')\n ];\n };\n return RadialGradient;\n}(Gradient));\n\nvar GradientFill = /** @class */ (function () {\n function GradientFill(key, gradient) {\n this.key = key;\n this.gradient = gradient;\n }\n GradientFill.prototype.getFillData = function (forNode, context) {\n return __awaiter(this, void 0, void 0, function () {\n var gradientUnitsMatrix, bBox, gradientTransform;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, context.refsHandler.getRendered(this.key, function (node) {\n return node.apply(new Context(context.pdf, {\n refsHandler: context.refsHandler,\n textMeasure: context.textMeasure,\n styleSheets: context.styleSheets,\n viewport: context.viewport,\n svg2pdfParameters: context.svg2pdfParameters\n }));\n })\n // matrix to convert between gradient space and user space\n // for \"userSpaceOnUse\" this is the current transformation: tfMatrix\n // for \"objectBoundingBox\" or default, the gradient gets scaled and transformed to the bounding box\n ];\n case 1:\n _a.sent();\n if (!this.gradient.element.hasAttribute('gradientUnits') ||\n // eslint-disable-next-line @typescript-eslint/ban-ts-ignore\n // @ts-ignore\n this.gradient.element.getAttribute('gradientUnits').toLowerCase() === 'objectboundingbox') {\n bBox = forNode.getBoundingBox(context);\n gradientUnitsMatrix = context.pdf.Matrix(bBox[2], 0, 0, bBox[3], bBox[0], bBox[1]);\n }\n else {\n gradientUnitsMatrix = context.pdf.unitMatrix;\n }\n gradientTransform = parseTransform(getAttribute(this.gradient.element, context.styleSheets, 'gradientTransform', 'transform'), context);\n return [2 /*return*/, {\n key: this.key,\n matrix: context.pdf.matrixMult(gradientTransform, gradientUnitsMatrix)\n }];\n }\n });\n });\n };\n return GradientFill;\n}());\n\nvar Pattern = /** @class */ (function (_super) {\n __extends(Pattern, _super);\n function Pattern() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Pattern.prototype.apply = function (context) {\n return __awaiter(this, void 0, void 0, function () {\n var id, bBox, pattern, _i, _a, child;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n id = this.element.getAttribute('id');\n if (!id) {\n return [2 /*return*/];\n }\n bBox = this.getBoundingBox(context);\n pattern = new TilingPattern([bBox[0], bBox[1], bBox[0] + bBox[2], bBox[1] + bBox[3]], bBox[2], bBox[3]);\n context.pdf.beginTilingPattern(pattern);\n _i = 0, _a = this.children;\n _b.label = 1;\n case 1:\n if (!(_i < _a.length)) return [3 /*break*/, 4];\n child = _a[_i];\n return [4 /*yield*/, child.render(new Context(context.pdf, {\n attributeState: context.attributeState,\n refsHandler: context.refsHandler,\n styleSheets: context.styleSheets,\n viewport: context.viewport,\n svg2pdfParameters: context.svg2pdfParameters\n }))];\n case 2:\n _b.sent();\n _b.label = 3;\n case 3:\n _i++;\n return [3 /*break*/, 1];\n case 4:\n context.pdf.endTilingPattern(id, pattern);\n return [2 /*return*/];\n }\n });\n });\n };\n Pattern.prototype.getBoundingBoxCore = function (context) {\n return defaultBoundingBox(this.element, context);\n };\n Pattern.prototype.computeNodeTransformCore = function (context) {\n return context.pdf.unitMatrix;\n };\n Pattern.prototype.isVisible = function (parentVisible, context) {\n return svgNodeAndChildrenVisible(this, parentVisible, context);\n };\n return Pattern;\n}(NonRenderedNode));\n\nvar PatternFill = /** @class */ (function () {\n function PatternFill(key, pattern) {\n this.key = key;\n this.pattern = pattern;\n }\n PatternFill.prototype.getFillData = function (forNode, context) {\n return __awaiter(this, void 0, void 0, function () {\n var patternData, bBox, patternUnitsMatrix, fillBBox, x, y, width, height, patternContentUnitsMatrix, fillBBox, x, y, width, height, patternTransformMatrix, patternTransform, matrix;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, context.refsHandler.getRendered(this.key, function (node) {\n return node.apply(new Context(context.pdf, {\n refsHandler: context.refsHandler,\n textMeasure: context.textMeasure,\n styleSheets: context.styleSheets,\n viewport: context.viewport,\n svg2pdfParameters: context.svg2pdfParameters\n }));\n })];\n case 1:\n _a.sent();\n patternData = {\n key: this.key,\n boundingBox: undefined,\n xStep: 0,\n yStep: 0,\n matrix: undefined\n };\n patternUnitsMatrix = context.pdf.unitMatrix;\n if (!this.pattern.element.hasAttribute('patternUnits') ||\n this.pattern.element.getAttribute('patternUnits').toLowerCase() === 'objectboundingbox') {\n bBox = forNode.getBoundingBox(context);\n patternUnitsMatrix = context.pdf.Matrix(1, 0, 0, 1, bBox[0], bBox[1]);\n fillBBox = this.pattern.getBoundingBox(context);\n x = fillBBox[0] * bBox[0] || 0;\n y = fillBBox[1] * bBox[1] || 0;\n width = fillBBox[2] * bBox[2] || 0;\n height = fillBBox[3] * bBox[3] || 0;\n patternData.boundingBox = [x, y, x + width, y + height];\n patternData.xStep = width;\n patternData.yStep = height;\n }\n patternContentUnitsMatrix = context.pdf.unitMatrix;\n if (this.pattern.element.hasAttribute('patternContentUnits') &&\n this.pattern.element.getAttribute('patternContentUnits').toLowerCase() ===\n 'objectboundingbox') {\n bBox || (bBox = forNode.getBoundingBox(context));\n patternContentUnitsMatrix = context.pdf.Matrix(bBox[2], 0, 0, bBox[3], 0, 0);\n fillBBox = patternData.boundingBox || this.pattern.getBoundingBox(context);\n x = fillBBox[0] / bBox[0] || 0;\n y = fillBBox[1] / bBox[1] || 0;\n width = fillBBox[2] / bBox[2] || 0;\n height = fillBBox[3] / bBox[3] || 0;\n patternData.boundingBox = [x, y, x + width, y + height];\n patternData.xStep = width;\n patternData.yStep = height;\n }\n patternTransformMatrix = context.pdf.unitMatrix;\n patternTransform = getAttribute(this.pattern.element, context.styleSheets, 'patternTransform', 'transform');\n if (patternTransform) {\n patternTransformMatrix = parseTransform(patternTransform, context);\n }\n matrix = patternContentUnitsMatrix;\n matrix = context.pdf.matrixMult(matrix, patternUnitsMatrix); // translate by\n matrix = context.pdf.matrixMult(matrix, patternTransformMatrix);\n matrix = context.pdf.matrixMult(matrix, context.transform);\n patternData.matrix = matrix;\n return [2 /*return*/, patternData];\n }\n });\n });\n };\n return PatternFill;\n}());\n\nfunction parseFill(fill, context) {\n var url = iriReference.exec(fill);\n if (url) {\n var fillUrl = url[1];\n var fillNode = context.refsHandler.get(fillUrl);\n if (fillNode && (fillNode instanceof LinearGradient || fillNode instanceof RadialGradient)) {\n return new GradientFill(fillUrl, fillNode);\n }\n else if (fillNode && fillNode instanceof Pattern) {\n return new PatternFill(fillUrl, fillNode);\n }\n else {\n // unsupported fill argument -> fill black\n return new ColorFill(new RGBColor('rgb(0, 0, 0)'));\n }\n }\n else {\n // plain color\n var fillColor = parseColor(fill);\n if (fillColor.ok) {\n return new ColorFill(fillColor);\n }\n else if (fill === 'none') {\n return null;\n }\n else {\n return null;\n }\n }\n}\n\nfunction parseAttributes(context, svgNode, node) {\n var domNode = node || svgNode.element;\n var visibility = getAttribute(domNode, context.styleSheets, 'visibility');\n if (visibility) {\n context.attributeState.visibility = visibility;\n }\n // fill mode\n var fill = getAttribute(domNode, context.styleSheets, 'fill');\n if (fill) {\n context.attributeState.fill = parseFill(fill, context);\n }\n // opacity is realized via a pdf graphics state\n var fillOpacity = getAttribute(domNode, context.styleSheets, 'fill-opacity');\n if (fillOpacity) {\n context.attributeState.fillOpacity = parseFloat(fillOpacity);\n }\n var strokeOpacity = getAttribute(domNode, context.styleSheets, 'stroke-opacity');\n if (strokeOpacity) {\n context.attributeState.strokeOpacity = parseFloat(strokeOpacity);\n }\n var opacity = getAttribute(domNode, context.styleSheets, 'opacity');\n if (opacity) {\n context.attributeState.opacity = parseFloat(opacity);\n }\n // stroke mode\n var strokeWidth = getAttribute(domNode, context.styleSheets, 'stroke-width');\n if (strokeWidth !== void 0 && strokeWidth !== '') {\n strokeWidth = Math.abs(parseFloat(strokeWidth));\n context.attributeState.strokeWidth = strokeWidth;\n }\n var stroke = getAttribute(domNode, context.styleSheets, 'stroke');\n if (stroke) {\n if (stroke === 'none') {\n context.attributeState.stroke = null;\n }\n else {\n // gradients, patterns not supported for strokes ...\n var strokeRGB = parseColor(stroke);\n if (strokeRGB.ok) {\n context.attributeState.stroke = new ColorFill(strokeRGB);\n }\n }\n }\n var lineCap = getAttribute(domNode, context.styleSheets, 'stroke-linecap');\n if (lineCap) {\n context.attributeState.strokeLinecap = lineCap;\n }\n var lineJoin = getAttribute(domNode, context.styleSheets, 'stroke-linejoin');\n if (lineJoin) {\n context.attributeState.strokeLinejoin = lineJoin;\n }\n var dashArray = getAttribute(domNode, context.styleSheets, 'stroke-dasharray');\n if (dashArray) {\n dashArray = parseFloats(dashArray);\n var dashOffset = parseInt(getAttribute(domNode, context.styleSheets, 'stroke-dashoffset') || '0');\n context.attributeState.strokeDasharray = dashArray;\n context.attributeState.strokeDashoffset = dashOffset;\n }\n var miterLimit = getAttribute(domNode, context.styleSheets, 'stroke-miterlimit');\n if (miterLimit !== void 0 && miterLimit !== '') {\n context.attributeState.strokeMiterlimit = parseFloat(miterLimit);\n }\n var xmlSpace = domNode.getAttribute('xml:space');\n if (xmlSpace) {\n context.attributeState.xmlSpace = xmlSpace;\n }\n var fontWeight = getAttribute(domNode, context.styleSheets, 'font-weight');\n if (fontWeight) {\n context.attributeState.fontWeight = fontWeight;\n }\n var fontStyle = getAttribute(domNode, context.styleSheets, 'font-style');\n if (fontStyle) {\n context.attributeState.fontStyle = fontStyle;\n }\n var fontFamily = getAttribute(domNode, context.styleSheets, 'font-family');\n if (fontFamily) {\n var fontFamilies = FontFamily.parse(fontFamily);\n context.attributeState.fontFamily = findFirstAvailableFontFamily(context.attributeState, fontFamilies, context);\n }\n var fontSize = getAttribute(domNode, context.styleSheets, 'font-size');\n if (fontSize) {\n var pdfFontSize = context.pdf.getFontSize();\n context.attributeState.fontSize = toPixels(fontSize, pdfFontSize);\n }\n var alignmentBaseline = getAttribute(domNode, context.styleSheets, 'vertical-align') ||\n getAttribute(domNode, context.styleSheets, 'alignment-baseline');\n if (alignmentBaseline) {\n var matchArr = alignmentBaseline.match(/(baseline|text-bottom|alphabetic|ideographic|middle|central|mathematical|text-top|bottom|center|top|hanging)/);\n if (matchArr) {\n context.attributeState.alignmentBaseline = matchArr[0];\n }\n }\n var textAnchor = getAttribute(domNode, context.styleSheets, 'text-anchor');\n if (textAnchor) {\n context.attributeState.textAnchor = textAnchor;\n }\n}\nfunction applyAttributes(childContext, parentContext, node) {\n var fillOpacity = 1.0, strokeOpacity = 1.0;\n fillOpacity *= childContext.attributeState.fillOpacity;\n fillOpacity *= childContext.attributeState.opacity;\n if (childContext.attributeState.fill instanceof ColorFill &&\n typeof childContext.attributeState.fill.color.a !== 'undefined') {\n fillOpacity *= childContext.attributeState.fill.color.a;\n }\n strokeOpacity *= childContext.attributeState.strokeOpacity;\n strokeOpacity *= childContext.attributeState.opacity;\n if (childContext.attributeState.stroke instanceof ColorFill &&\n typeof childContext.attributeState.stroke.color.a !== 'undefined') {\n strokeOpacity *= childContext.attributeState.stroke.color.a;\n }\n var hasFillOpacity = fillOpacity < 1.0;\n var hasStrokeOpacity = strokeOpacity < 1.0;\n // This is a workaround for symbols that are used multiple times with different\n // fill/stroke attributes. All paths within symbols are both filled and stroked\n // and we set the fill/stroke to transparent if the use element has\n // fill/stroke=\"none\".\n if (nodeIs(node, 'use')) {\n hasFillOpacity = true;\n hasStrokeOpacity = true;\n fillOpacity *= childContext.attributeState.fill ? 1 : 0;\n strokeOpacity *= childContext.attributeState.stroke ? 1 : 0;\n }\n else if (childContext.withinUse) {\n if (childContext.attributeState.fill !== parentContext.attributeState.fill) {\n hasFillOpacity = true;\n fillOpacity *= childContext.attributeState.fill ? 1 : 0;\n }\n else if (hasFillOpacity && !childContext.attributeState.fill) {\n fillOpacity = 0;\n }\n if (childContext.attributeState.stroke !== parentContext.attributeState.stroke) {\n hasStrokeOpacity = true;\n strokeOpacity *= childContext.attributeState.stroke ? 1 : 0;\n }\n else if (hasStrokeOpacity && !childContext.attributeState.stroke) {\n strokeOpacity = 0;\n }\n }\n if (hasFillOpacity || hasStrokeOpacity) {\n var gState = {};\n hasFillOpacity && (gState['opacity'] = fillOpacity);\n hasStrokeOpacity && (gState['stroke-opacity'] = strokeOpacity);\n childContext.pdf.setGState(new GState(gState));\n }\n if (childContext.attributeState.fill &&\n childContext.attributeState.fill !== parentContext.attributeState.fill &&\n childContext.attributeState.fill instanceof ColorFill &&\n childContext.attributeState.fill.color.ok &&\n !nodeIs(node, 'text')) {\n // text fill color will be applied through setTextColor()\n childContext.pdf.setFillColor(childContext.attributeState.fill.color.r, childContext.attributeState.fill.color.g, childContext.attributeState.fill.color.b);\n }\n if (childContext.attributeState.strokeWidth !== parentContext.attributeState.strokeWidth) {\n childContext.pdf.setLineWidth(childContext.attributeState.strokeWidth);\n }\n if (childContext.attributeState.stroke !== parentContext.attributeState.stroke &&\n childContext.attributeState.stroke instanceof ColorFill) {\n childContext.pdf.setDrawColor(childContext.attributeState.stroke.color.r, childContext.attributeState.stroke.color.g, childContext.attributeState.stroke.color.b);\n }\n if (childContext.attributeState.strokeLinecap !== parentContext.attributeState.strokeLinecap) {\n childContext.pdf.setLineCap(childContext.attributeState.strokeLinecap);\n }\n if (childContext.attributeState.strokeLinejoin !== parentContext.attributeState.strokeLinejoin) {\n childContext.pdf.setLineJoin(childContext.attributeState.strokeLinejoin);\n }\n if ((childContext.attributeState.strokeDasharray !== parentContext.attributeState.strokeDasharray ||\n childContext.attributeState.strokeDashoffset !==\n parentContext.attributeState.strokeDashoffset) &&\n childContext.attributeState.strokeDasharray) {\n childContext.pdf.setLineDashPattern(childContext.attributeState.strokeDasharray, childContext.attributeState.strokeDashoffset);\n }\n if (childContext.attributeState.strokeMiterlimit !== parentContext.attributeState.strokeMiterlimit) {\n childContext.pdf.setLineMiterLimit(childContext.attributeState.strokeMiterlimit);\n }\n var font;\n if (childContext.attributeState.fontFamily !== parentContext.attributeState.fontFamily) {\n if (fontAliases.hasOwnProperty(childContext.attributeState.fontFamily)) {\n font = fontAliases[childContext.attributeState.fontFamily];\n }\n else {\n font = childContext.attributeState.fontFamily;\n }\n }\n if (childContext.attributeState.fill &&\n childContext.attributeState.fill !== parentContext.attributeState.fill &&\n childContext.attributeState.fill instanceof ColorFill &&\n childContext.attributeState.fill.color.ok) {\n var fillColor = childContext.attributeState.fill.color;\n childContext.pdf.setTextColor(fillColor.r, fillColor.g, fillColor.b);\n }\n var fontStyle;\n if (childContext.attributeState.fontWeight !== parentContext.attributeState.fontWeight ||\n childContext.attributeState.fontStyle !== parentContext.attributeState.fontStyle) {\n fontStyle = '';\n if (childContext.attributeState.fontWeight === 'bold') {\n fontStyle = 'bold';\n }\n if (childContext.attributeState.fontStyle === 'italic') {\n fontStyle += 'italic';\n }\n if (fontStyle === '') {\n fontStyle = 'normal';\n }\n }\n if (font !== undefined || fontStyle !== undefined) {\n if (font === undefined) {\n if (fontAliases.hasOwnProperty(childContext.attributeState.fontFamily)) {\n font = fontAliases[childContext.attributeState.fontFamily];\n }\n else {\n font = childContext.attributeState.fontFamily;\n }\n }\n childContext.pdf.setFont(font, fontStyle);\n }\n if (childContext.attributeState.fontSize !== parentContext.attributeState.fontSize) {\n // correct for a jsPDF-instance measurement unit that differs from `pt`\n childContext.pdf.setFontSize(childContext.attributeState.fontSize * childContext.pdf.internal.scaleFactor);\n }\n}\n\nfunction getClipPathNode(targetNode, context) {\n var clipPathAttr = getAttribute(targetNode.element, context.styleSheets, 'clip-path');\n if (!clipPathAttr) {\n return undefined;\n }\n var match = iriReference.exec(clipPathAttr);\n if (!match) {\n return undefined;\n }\n var clipPathId = match[1];\n var clipNode = context.refsHandler.get(clipPathId);\n return clipNode || undefined;\n}\nfunction applyClipPath(targetNode, clipPathNode, context) {\n return __awaiter(this, void 0, void 0, function () {\n var clipContext, bBox;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n clipContext = context.clone();\n if (clipPathNode.element.hasAttribute('clipPathUnits') &&\n clipPathNode.element.getAttribute('clipPathUnits').toLowerCase() === 'objectboundingbox') {\n bBox = targetNode.getBoundingBox(context);\n clipContext.transform = context.pdf.matrixMult(context.pdf.Matrix(bBox[2], 0, 0, bBox[3], bBox[0], bBox[1]), context.transform);\n }\n return [4 /*yield*/, clipPathNode.apply(clipContext)];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n}\n\nvar RenderedNode = /** @class */ (function (_super) {\n __extends(RenderedNode, _super);\n function RenderedNode() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n RenderedNode.prototype.render = function (parentContext) {\n return __awaiter(this, void 0, void 0, function () {\n var context, hasClipPath, clipNode;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.isVisible(parentContext.attributeState.visibility !== 'hidden', parentContext)) {\n return [2 /*return*/];\n }\n context = parentContext.clone();\n context.transform = context.pdf.matrixMult(this.computeNodeTransform(context), parentContext.transform);\n parseAttributes(context, this);\n hasClipPath = this.element.hasAttribute('clip-path') &&\n getAttribute(this.element, context.styleSheets, 'clip-path') !== 'none';\n if (!hasClipPath) return [3 /*break*/, 3];\n clipNode = getClipPathNode(this, context);\n if (!(clipNode && clipNode.isVisible(true, context))) return [3 /*break*/, 2];\n context.pdf.saveGraphicsState();\n return [4 /*yield*/, applyClipPath(this, clipNode, context)];\n case 1:\n _a.sent();\n return [3 /*break*/, 3];\n case 2: return [2 /*return*/];\n case 3:\n if (!context.withinClipPath) {\n context.pdf.saveGraphicsState();\n }\n applyAttributes(context, parentContext, this.element);\n return [4 /*yield*/, this.renderCore(context)];\n case 4:\n _a.sent();\n if (!context.withinClipPath) {\n context.pdf.restoreGraphicsState();\n }\n if (hasClipPath) {\n context.pdf.restoreGraphicsState();\n }\n return [2 /*return*/];\n }\n });\n });\n };\n return RenderedNode;\n}(SvgNode));\n\nvar GraphicsNode = /** @class */ (function (_super) {\n __extends(GraphicsNode, _super);\n function GraphicsNode() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n return GraphicsNode;\n}(RenderedNode));\n\nvar GeometryNode = /** @class */ (function (_super) {\n __extends(GeometryNode, _super);\n function GeometryNode(hasMarkers, element, children) {\n var _this = _super.call(this, element, children) || this;\n _this.cachedPath = null;\n _this.hasMarkers = hasMarkers;\n return _this;\n }\n GeometryNode.prototype.renderCore = function (context) {\n return __awaiter(this, void 0, void 0, function () {\n var path;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n path = this.getCachedPath(context);\n if (path === null || path.segments.length === 0) {\n return [2 /*return*/];\n }\n if (context.withinClipPath) {\n path.transform(context.transform);\n }\n else {\n context.pdf.setCurrentTransformationMatrix(context.transform);\n }\n path.draw(context);\n return [4 /*yield*/, this.fillOrStroke(context)];\n case 1:\n _a.sent();\n if (!this.hasMarkers) return [3 /*break*/, 3];\n return [4 /*yield*/, this.drawMarkers(context, path)];\n case 2:\n _a.sent();\n _a.label = 3;\n case 3: return [2 /*return*/];\n }\n });\n });\n };\n GeometryNode.prototype.getCachedPath = function (context) {\n return this.cachedPath || (this.cachedPath = this.getPath(context));\n };\n GeometryNode.prototype.drawMarkers = function (context, path) {\n return __awaiter(this, void 0, void 0, function () {\n var markers;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n markers = this.getMarkers(path, context);\n return [4 /*yield*/, markers.draw(context.clone({ transform: context.pdf.unitMatrix }))];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n GeometryNode.prototype.fillOrStroke = function (context) {\n return __awaiter(this, void 0, void 0, function () {\n var fill, stroke, fillData, _a, isNodeFillRuleEvenOdd;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (context.withinClipPath) {\n return [2 /*return*/];\n }\n fill = context.attributeState.fill;\n stroke = context.attributeState.stroke && context.attributeState.strokeWidth !== 0;\n if (!fill) return [3 /*break*/, 2];\n return [4 /*yield*/, fill.getFillData(this, context)];\n case 1:\n _a = _b.sent();\n return [3 /*break*/, 3];\n case 2:\n _a = undefined;\n _b.label = 3;\n case 3:\n fillData = _a;\n isNodeFillRuleEvenOdd = getAttribute(this.element, context.styleSheets, 'fill-rule') === 'evenodd';\n // This is a workaround for symbols that are used multiple times with different\n // fill/stroke attributes. All paths within symbols are both filled and stroked\n // and we set the fill/stroke to transparent if the use element has\n // fill/stroke=\"none\".\n if ((fill && stroke) || context.withinUse) {\n if (isNodeFillRuleEvenOdd) {\n context.pdf.fillStrokeEvenOdd(fillData);\n }\n else {\n context.pdf.fillStroke(fillData);\n }\n }\n else if (fill) {\n if (isNodeFillRuleEvenOdd) {\n context.pdf.fillEvenOdd(fillData);\n }\n else {\n context.pdf.fill(fillData);\n }\n }\n else if (stroke) {\n context.pdf.stroke();\n }\n else {\n context.pdf.discardPath();\n }\n return [2 /*return*/];\n }\n });\n });\n };\n GeometryNode.prototype.getBoundingBoxCore = function (context) {\n var path = this.getCachedPath(context);\n if (!path) {\n return [0, 0, 0, 0];\n }\n var minX = Number.POSITIVE_INFINITY;\n var minY = Number.POSITIVE_INFINITY;\n var maxX = Number.NEGATIVE_INFINITY;\n var maxY = Number.NEGATIVE_INFINITY;\n var x = 0, y = 0;\n for (var i = 0; i < path.segments.length; i++) {\n var seg = path.segments[i];\n if (seg instanceof MoveTo || seg instanceof LineTo || seg instanceof CurveTo) {\n x = seg.x;\n y = seg.y;\n }\n if (seg instanceof CurveTo) {\n minX = Math.min(minX, x, seg.x1, seg.x2, seg.x);\n maxX = Math.max(maxX, x, seg.x1, seg.x2, seg.x);\n minY = Math.min(minY, y, seg.y1, seg.y2, seg.y);\n maxY = Math.max(maxY, y, seg.y1, seg.y2, seg.y);\n }\n else {\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n }\n return [minX, minY, maxX - minX, maxY - minY];\n };\n GeometryNode.prototype.getMarkers = function (path, context) {\n var markerStart = getAttribute(this.element, context.styleSheets, 'marker-start');\n var markerMid = getAttribute(this.element, context.styleSheets, 'marker-mid');\n var markerEnd = getAttribute(this.element, context.styleSheets, 'marker-end');\n var markers = new MarkerList();\n if (markerStart || markerMid || markerEnd) {\n markerEnd && (markerEnd = iri(markerEnd));\n markerStart && (markerStart = iri(markerStart));\n markerMid && (markerMid = iri(markerMid));\n var list_1 = path.segments;\n var prevAngle = [1, 0], curAngle = void 0, first = false, firstAngle = [1, 0], last_1 = false;\n var _loop_1 = function (i) {\n var curr = list_1[i];\n var hasStartMarker = markerStart &&\n (i === 1 || (!(list_1[i] instanceof MoveTo) && list_1[i - 1] instanceof MoveTo));\n if (hasStartMarker) {\n list_1.forEach(function (value, index) {\n if (!last_1 && value instanceof Close && index > i) {\n var tmp = list_1[index - 1];\n last_1 =\n (tmp instanceof MoveTo || tmp instanceof LineTo || tmp instanceof CurveTo) && tmp;\n }\n });\n }\n var hasEndMarker = markerEnd &&\n (i === list_1.length - 1 || (!(list_1[i] instanceof MoveTo) && list_1[i + 1] instanceof MoveTo));\n var hasMidMarker = markerMid && i > 0 && !(i === 1 && list_1[i - 1] instanceof MoveTo);\n var prev = list_1[i - 1] || null;\n if (prev instanceof MoveTo || prev instanceof LineTo || prev instanceof CurveTo) {\n if (curr instanceof CurveTo) {\n hasStartMarker &&\n markers.addMarker(new Marker(markerStart, [prev.x, prev.y], \n // @ts-ignore\n getAngle(last_1 ? [last_1.x, last_1.y] : [prev.x, prev.y], [curr.x1, curr.y1])));\n hasEndMarker &&\n markers.addMarker(new Marker(markerEnd, [curr.x, curr.y], getAngle([curr.x2, curr.y2], [curr.x, curr.y])));\n if (hasMidMarker) {\n curAngle = getDirectionVector([prev.x, prev.y], [curr.x1, curr.y1]);\n curAngle =\n prev instanceof MoveTo ? curAngle : normalize(addVectors(prevAngle, curAngle));\n markers.addMarker(new Marker(markerMid, [prev.x, prev.y], Math.atan2(curAngle[1], curAngle[0])));\n }\n prevAngle = getDirectionVector([curr.x2, curr.y2], [curr.x, curr.y]);\n }\n else if (curr instanceof MoveTo || curr instanceof LineTo) {\n curAngle = getDirectionVector([prev.x, prev.y], [curr.x, curr.y]);\n if (hasStartMarker) {\n // @ts-ignore\n var angle = last_1 ? getDirectionVector([last_1.x, last_1.y], [curr.x, curr.y]) : curAngle;\n markers.addMarker(new Marker(markerStart, [prev.x, prev.y], Math.atan2(angle[1], angle[0])));\n }\n hasEndMarker &&\n markers.addMarker(new Marker(markerEnd, [curr.x, curr.y], Math.atan2(curAngle[1], curAngle[0])));\n if (hasMidMarker) {\n var angle = curr instanceof MoveTo\n ? prevAngle\n : prev instanceof MoveTo\n ? curAngle\n : normalize(addVectors(prevAngle, curAngle));\n markers.addMarker(new Marker(markerMid, [prev.x, prev.y], Math.atan2(angle[1], angle[0])));\n }\n prevAngle = curAngle;\n }\n else if (curr instanceof Close) {\n // @ts-ignore\n curAngle = getDirectionVector([prev.x, prev.y], [first.x, first.y]);\n if (hasMidMarker) {\n var angle = prev instanceof MoveTo ? curAngle : normalize(addVectors(prevAngle, curAngle));\n markers.addMarker(new Marker(markerMid, [prev.x, prev.y], Math.atan2(angle[1], angle[0])));\n }\n if (hasEndMarker) {\n var angle = normalize(addVectors(curAngle, firstAngle));\n markers.addMarker(\n // @ts-ignore\n new Marker(markerEnd, [first.x, first.y], Math.atan2(angle[1], angle[0])));\n }\n prevAngle = curAngle;\n }\n }\n else {\n first = curr instanceof MoveTo && curr;\n var next = list_1[i + 1];\n if (next instanceof MoveTo || next instanceof LineTo || next instanceof CurveTo) {\n // @ts-ignore\n firstAngle = getDirectionVector([first.x, first.y], [next.x, next.y]);\n }\n }\n };\n for (var i = 0; i < list_1.length; i++) {\n _loop_1(i);\n }\n }\n return markers;\n };\n return GeometryNode;\n}(GraphicsNode));\nfunction iri(attribute) {\n var match = iriReference.exec(attribute);\n return (match && match[1]) || undefined;\n}\n\nvar Line = /** @class */ (function (_super) {\n __extends(Line, _super);\n function Line(node, children) {\n return _super.call(this, true, node, children) || this;\n }\n Line.prototype.getPath = function (context) {\n if (context.withinClipPath || context.attributeState.stroke === null) {\n return null;\n }\n var x1 = parseFloat(this.element.getAttribute('x1') || '0'), y1 = parseFloat(this.element.getAttribute('y1') || '0');\n var x2 = parseFloat(this.element.getAttribute('x2') || '0'), y2 = parseFloat(this.element.getAttribute('y2') || '0');\n if (!(x1 || x2 || y1 || y2)) {\n return null;\n }\n return new Path().moveTo(x1, y1).lineTo(x2, y2);\n };\n Line.prototype.computeNodeTransformCore = function (context) {\n return context.pdf.unitMatrix;\n };\n Line.prototype.isVisible = function (parentVisible, context) {\n return svgNodeIsVisible(this, parentVisible, context);\n };\n Line.prototype.fillOrStroke = function (context) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n context.attributeState.fill = null;\n return [4 /*yield*/, _super.prototype.fillOrStroke.call(this, context)];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n return Line;\n}(GeometryNode));\n\nvar Symbol$1 = /** @class */ (function (_super) {\n __extends(Symbol, _super);\n function Symbol() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Symbol.prototype.apply = function (parentContext) {\n return __awaiter(this, void 0, void 0, function () {\n var context, hasClipPath, clipNode, _i, _a, child;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (!this.isVisible(parentContext.attributeState.visibility !== 'hidden', parentContext)) {\n return [2 /*return*/];\n }\n context = parentContext.clone();\n context.transform = context.pdf.unitMatrix;\n parseAttributes(context, this);\n hasClipPath = this.element.hasAttribute('clip-path') &&\n getAttribute(this.element, context.styleSheets, 'clip-path') !== 'none';\n if (!hasClipPath) return [3 /*break*/, 3];\n clipNode = getClipPathNode(this, context);\n if (!(clipNode && clipNode.isVisible(true, context))) return [3 /*break*/, 2];\n return [4 /*yield*/, applyClipPath(this, clipNode, context)];\n case 1:\n _b.sent();\n return [3 /*break*/, 3];\n case 2: return [2 /*return*/];\n case 3:\n applyAttributes(context, parentContext, this.element);\n _i = 0, _a = this.children;\n _b.label = 4;\n case 4:\n if (!(_i < _a.length)) return [3 /*break*/, 7];\n child = _a[_i];\n return [4 /*yield*/, child.render(context)];\n case 5:\n _b.sent();\n _b.label = 6;\n case 6:\n _i++;\n return [3 /*break*/, 4];\n case 7: return [2 /*return*/];\n }\n });\n });\n };\n Symbol.prototype.getBoundingBoxCore = function (context) {\n return getBoundingBoxByChildren(context, this);\n };\n Symbol.prototype.isVisible = function (parentVisible, context) {\n return svgNodeAndChildrenVisible(this, parentVisible, context);\n };\n Symbol.prototype.computeNodeTransformCore = function (context) {\n var x = parseFloat(getAttribute(this.element, context.styleSheets, 'x') || '0');\n var y = parseFloat(getAttribute(this.element, context.styleSheets, 'y') || '0');\n // TODO: implement refX/refY - this is still to do because common browsers don't seem to support the feature yet\n // x += parseFloat(this.element.getAttribute(\"refX\")) || 0; ???\n // y += parseFloat(this.element.getAttribute(\"refY\")) || 0; ???\n var viewBox = this.element.getAttribute('viewBox');\n if (viewBox) {\n var box = parseFloats(viewBox);\n var width = parseFloat(getAttribute(this.element, context.styleSheets, 'width') ||\n getAttribute(this.element.ownerSVGElement, context.styleSheets, 'width') ||\n viewBox[2]);\n var height = parseFloat(getAttribute(this.element, context.styleSheets, 'height') ||\n getAttribute(this.element.ownerSVGElement, context.styleSheets, 'height') ||\n viewBox[3]);\n return computeViewBoxTransform(this.element, box, x, y, width, height, context);\n }\n else {\n return context.pdf.Matrix(1, 0, 0, 1, x, y);\n }\n };\n return Symbol;\n}(NonRenderedNode));\n\nvar Viewport = /** @class */ (function () {\n function Viewport(width, height) {\n this.width = width;\n this.height = height;\n }\n return Viewport;\n}());\n\n/**\n * Draws the element referenced by a use node, makes use of pdf's XObjects/FormObjects so nodes are only written once\n * to the pdf document. This highly reduces the file size and computation time.\n */\nvar Use = /** @class */ (function (_super) {\n __extends(Use, _super);\n function Use() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Use.prototype.renderCore = function (context) {\n return __awaiter(this, void 0, void 0, function () {\n var pf, url, id, refNode, refNodeOpensViewport, x, y, width, height, t, viewBox, refContext;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n pf = parseFloat;\n url = this.element.getAttribute('href') || this.element.getAttribute('xlink:href');\n // just in case someone has the idea to use empty use-tags, wtf???\n if (!url)\n return [2 /*return*/];\n id = url.substring(1);\n refNode = context.refsHandler.get(id);\n refNodeOpensViewport = nodeIs(refNode.element, 'symbol,svg') && refNode.element.hasAttribute('viewBox');\n x = pf(getAttribute(this.element, context.styleSheets, 'x') || '0');\n y = pf(getAttribute(this.element, context.styleSheets, 'y') || '0');\n width = undefined;\n height = undefined;\n if (refNodeOpensViewport) {\n // <use> inherits width/height only to svg/symbol\n // if there is no viewBox attribute, width/height don't have an effect\n // in theory, the default value for width/height is 100%, but we currently don't support this\n width = pf(getAttribute(this.element, context.styleSheets, 'width') ||\n getAttribute(refNode.element, context.styleSheets, 'width') ||\n '0');\n height = pf(getAttribute(this.element, context.styleSheets, 'height') ||\n getAttribute(refNode.element, context.styleSheets, 'height') ||\n '0');\n // accumulate x/y to calculate the viewBox transform\n x += pf(getAttribute(refNode.element, context.styleSheets, 'x') || '0');\n y += pf(getAttribute(refNode.element, context.styleSheets, 'y') || '0');\n viewBox = parseFloats(refNode.element.getAttribute('viewBox'));\n t = computeViewBoxTransform(refNode.element, viewBox, x, y, width, height, context);\n }\n else {\n t = context.pdf.Matrix(1, 0, 0, 1, x, y);\n }\n refContext = new Context(context.pdf, {\n refsHandler: context.refsHandler,\n styleSheets: context.styleSheets,\n withinUse: true,\n viewport: refNodeOpensViewport ? new Viewport(width, height) : context.viewport,\n svg2pdfParameters: context.svg2pdfParameters\n });\n return [4 /*yield*/, context.refsHandler.getRendered(id, function (node) { return Use.renderReferencedNode(node, refContext); })];\n case 1:\n _a.sent();\n context.pdf.saveGraphicsState();\n context.pdf.setCurrentTransformationMatrix(context.transform);\n // apply the bbox (i.e. clip) if needed\n if (refNodeOpensViewport &&\n getAttribute(refNode.element, context.styleSheets, 'overflow') !== 'visible') {\n context.pdf.rect(x, y, width, height);\n context.pdf.clip().discardPath();\n }\n context.pdf.doFormObject(id, t);\n context.pdf.restoreGraphicsState();\n return [2 /*return*/];\n }\n });\n });\n };\n Use.renderReferencedNode = function (node, refContext) {\n return __awaiter(this, void 0, void 0, function () {\n var bBox;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n bBox = node.getBoundingBox(refContext);\n // The content of a PDF form object is implicitly clipped at its /BBox property.\n // SVG, however, applies its clip rect at the <use> attribute, which may modify it.\n // So, make the bBox a lot larger than it needs to be and hope any thick strokes are\n // still within.\n bBox = [bBox[0] - 0.5 * bBox[2], bBox[1] - 0.5 * bBox[3], bBox[2] * 2, bBox[3] * 2];\n refContext.pdf.beginFormObject(bBox[0], bBox[1], bBox[2], bBox[3], refContext.pdf.unitMatrix);\n if (!(node instanceof Symbol$1)) return [3 /*break*/, 2];\n return [4 /*yield*/, node.apply(refContext)];\n case 1:\n _a.sent();\n return [3 /*break*/, 4];\n case 2: return [4 /*yield*/, node.render(refContext)];\n case 3:\n _a.sent();\n _a.label = 4;\n case 4:\n refContext.pdf.endFormObject(node.element.getAttribute('id'));\n return [2 /*return*/];\n }\n });\n });\n };\n Use.prototype.getBoundingBoxCore = function (context) {\n return defaultBoundingBox(this.element, context);\n };\n Use.prototype.isVisible = function (parentVisible, context) {\n return svgNodeIsVisible(this, parentVisible, context);\n };\n Use.prototype.computeNodeTransformCore = function (context) {\n return context.pdf.unitMatrix;\n };\n return Use;\n}(GraphicsNode));\n\nvar Rect = /** @class */ (function (_super) {\n __extends(Rect, _super);\n function Rect(element, children) {\n return _super.call(this, false, element, children) || this;\n }\n Rect.prototype.getPath = function (context) {\n var w = parseFloat(getAttribute(this.element, context.styleSheets, 'width') || '0');\n var h = parseFloat(getAttribute(this.element, context.styleSheets, 'height') || '0');\n if (!isFinite(w) || w <= 0 || !isFinite(h) || h <= 0) {\n return null;\n }\n var rxAttr = getAttribute(this.element, context.styleSheets, 'rx');\n var ryAttr = getAttribute(this.element, context.styleSheets, 'ry');\n var rx = Math.min(parseFloat(rxAttr || ryAttr || '0'), w * 0.5);\n var ry = Math.min(parseFloat(ryAttr || rxAttr || '0'), h * 0.5);\n var x = parseFloat(getAttribute(this.element, context.styleSheets, 'x') || '0');\n var y = parseFloat(getAttribute(this.element, context.styleSheets, 'y') || '0');\n var arc = (4 / 3) * (Math.SQRT2 - 1);\n if (rx === 0 && ry === 0) {\n return new Path()\n .moveTo(x, y)\n .lineTo(x + w, y)\n .lineTo(x + w, y + h)\n .lineTo(x, y + h)\n .close();\n }\n else {\n return new Path()\n .moveTo((x += rx), y)\n .lineTo((x += w - 2 * rx), y)\n .curveTo(x + rx * arc, y, x + rx, y + (ry - ry * arc), (x += rx), (y += ry))\n .lineTo(x, (y += h - 2 * ry))\n .curveTo(x, y + ry * arc, x - rx * arc, y + ry, (x -= rx), (y += ry))\n .lineTo((x += -w + 2 * rx), y)\n .curveTo(x - rx * arc, y, x - rx, y - ry * arc, (x -= rx), (y -= ry))\n .lineTo(x, (y += -h + 2 * ry))\n .curveTo(x, y - ry * arc, x + rx * arc, y - ry, (x += rx), (y -= ry))\n .close();\n }\n };\n Rect.prototype.computeNodeTransformCore = function (context) {\n return context.pdf.unitMatrix;\n };\n Rect.prototype.isVisible = function (parentVisible, context) {\n return svgNodeIsVisible(this, parentVisible, context);\n };\n return Rect;\n}(GeometryNode));\n\nvar EllipseBase = /** @class */ (function (_super) {\n __extends(EllipseBase, _super);\n function EllipseBase(element, children) {\n return _super.call(this, false, element, children) || this;\n }\n EllipseBase.prototype.getPath = function (context) {\n var rx = this.getRx(context);\n var ry = this.getRy(context);\n if (!isFinite(rx) || ry <= 0 || !isFinite(ry) || ry <= 0) {\n return null;\n }\n var x = parseFloat(getAttribute(this.element, context.styleSheets, 'cx') || '0'), y = parseFloat(getAttribute(this.element, context.styleSheets, 'cy') || '0');\n var lx = (4 / 3) * (Math.SQRT2 - 1) * rx, ly = (4 / 3) * (Math.SQRT2 - 1) * ry;\n return new Path()\n .moveTo(x + rx, y)\n .curveTo(x + rx, y - ly, x + lx, y - ry, x, y - ry)\n .curveTo(x - lx, y - ry, x - rx, y - ly, x - rx, y)\n .curveTo(x - rx, y + ly, x - lx, y + ry, x, y + ry)\n .curveTo(x + lx, y + ry, x + rx, y + ly, x + rx, y);\n };\n EllipseBase.prototype.computeNodeTransformCore = function (context) {\n return context.pdf.unitMatrix;\n };\n EllipseBase.prototype.isVisible = function (parentVisible, context) {\n return svgNodeIsVisible(this, parentVisible, context);\n };\n return EllipseBase;\n}(GeometryNode));\n\nvar Ellipse = /** @class */ (function (_super) {\n __extends(Ellipse, _super);\n function Ellipse(element, children) {\n return _super.call(this, element, children) || this;\n }\n Ellipse.prototype.getRx = function (context) {\n return parseFloat(getAttribute(this.element, context.styleSheets, 'rx') || '0');\n };\n Ellipse.prototype.getRy = function (context) {\n return parseFloat(getAttribute(this.element, context.styleSheets, 'ry') || '0');\n };\n return Ellipse;\n}(EllipseBase));\n\nfunction getTextRenderingMode(attributeState) {\n var renderingMode = 'invisible';\n if (attributeState.fill && attributeState.stroke) {\n renderingMode = 'fillThenStroke';\n }\n else if (attributeState.fill) {\n renderingMode = 'fill';\n }\n else if (attributeState.stroke) {\n renderingMode = 'stroke';\n }\n return renderingMode;\n}\nfunction transformXmlSpace(trimmedText, attributeState) {\n trimmedText = removeNewlines(trimmedText);\n trimmedText = replaceTabsBySpace(trimmedText);\n if (attributeState.xmlSpace === 'default') {\n trimmedText = trimmedText.trim();\n trimmedText = consolidateSpaces(trimmedText);\n }\n return trimmedText;\n}\nfunction removeNewlines(str) {\n return str.replace(/[\\n\\r]/g, '');\n}\nfunction replaceTabsBySpace(str) {\n return str.replace(/[\\t]/g, ' ');\n}\nfunction consolidateSpaces(str) {\n return str.replace(/ +/g, ' ');\n}\n// applies text transformations to a text node\nfunction transformText(node, text, context) {\n var textTransform = getAttribute(node, context.styleSheets, 'text-transform');\n switch (textTransform) {\n case 'uppercase':\n return text.toUpperCase();\n case 'lowercase':\n return text.toLowerCase();\n default:\n return text;\n // TODO: capitalize, full-width\n }\n}\nfunction trimLeft(str) {\n return str.replace(/^\\s+/, '');\n}\nfunction trimRight(str) {\n return str.replace(/\\s+$/, '');\n}\n\n/**\n * @param {string} textAnchor\n * @param {number} originX\n * @param {number} originY\n * @constructor\n */\nvar TextChunk = /** @class */ (function () {\n function TextChunk(parent, textAnchor, originX, originY) {\n this.textNode = parent;\n this.texts = [];\n this.textNodes = [];\n this.textAnchor = textAnchor;\n this.originX = originX;\n this.originY = originY;\n }\n TextChunk.prototype.add = function (tSpan, text) {\n this.texts.push(text);\n this.textNodes.push(tSpan);\n };\n TextChunk.prototype.put = function (context) {\n var i, textNode;\n var strokeRGB;\n var xs = [], ys = [], textNodeContexts = [];\n var currentTextX = this.originX, currentTextY = this.originY;\n var minX = currentTextX, maxX = currentTextX;\n for (i = 0; i < this.textNodes.length; i++) {\n textNode = this.textNodes[i];\n var x = currentTextX;\n var y = currentTextY;\n var textNodeContext = void 0;\n if (textNode.nodeName === '#text') {\n textNodeContext = context;\n }\n else {\n textNodeContext = context.clone();\n parseAttributes(textNodeContext, this.textNode, textNode);\n var tSpanStrokeColor = getAttribute(textNode, context.styleSheets, 'stroke');\n if (tSpanStrokeColor) {\n strokeRGB = new RGBColor(tSpanStrokeColor);\n if (strokeRGB.ok) {\n textNodeContext.attributeState.stroke = new ColorFill(strokeRGB);\n }\n }\n var strokeWidth = getAttribute(textNode, context.styleSheets, 'stroke-width');\n if (strokeWidth !== void 0) {\n textNodeContext.attributeState.strokeWidth = parseFloat(strokeWidth);\n }\n var tSpanDx = textNode.getAttribute('dx');\n if (tSpanDx !== null) {\n x += toPixels(tSpanDx, textNodeContext.attributeState.fontSize);\n }\n var tSpanDy = textNode.getAttribute('dy');\n if (tSpanDy !== null) {\n y += toPixels(tSpanDy, textNodeContext.attributeState.fontSize);\n }\n }\n textNodeContexts[i] = textNodeContext;\n xs[i] = x;\n ys[i] = y;\n currentTextX =\n x + context.textMeasure.measureTextWidth(this.texts[i], textNodeContext.attributeState);\n currentTextY = y;\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, currentTextX);\n }\n var textOffset = 0;\n switch (this.textAnchor) {\n case 'start':\n textOffset = 0;\n break;\n case 'middle':\n textOffset = (maxX - minX) / 2;\n break;\n case 'end':\n textOffset = maxX - minX;\n break;\n }\n for (i = 0; i < this.textNodes.length; i++) {\n textNode = this.textNodes[i];\n if (textNode.nodeName !== '#text') {\n var tSpanVisibility = getAttribute(textNode, context.styleSheets, 'visibility') ||\n context.attributeState.visibility;\n if (tSpanVisibility === 'hidden') {\n continue;\n }\n }\n context.pdf.saveGraphicsState();\n applyAttributes(textNodeContexts[i], context, textNode);\n var alignmentBaseline = textNodeContexts[i].attributeState.alignmentBaseline;\n var textRenderingMode = getTextRenderingMode(textNodeContexts[i].attributeState);\n context.pdf.text(this.texts[i], xs[i] - textOffset, ys[i], {\n baseline: mapAlignmentBaseline(alignmentBaseline),\n angle: context.transform,\n renderingMode: textRenderingMode === 'fill' ? void 0 : textRenderingMode\n });\n context.pdf.restoreGraphicsState();\n }\n return [currentTextX, currentTextY];\n };\n return TextChunk;\n}());\n\nvar TextNode = /** @class */ (function (_super) {\n __extends(TextNode, _super);\n function TextNode() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n TextNode.prototype.renderCore = function (context) {\n return __awaiter(this, void 0, void 0, function () {\n var xOffset, pdfFontSize, textX, textY, dx, dy, visibility, tSpanCount, trimmedText, transformedText, alignmentBaseline, textRenderingMode, currentTextSegment, i, textNode, xmlSpace, textContent, tSpan, j, lastPositions, tSpanAbsX, x, tSpanAbsY, y, tSpanXmlSpace, trimmedText, transformedText;\n return __generator(this, function (_a) {\n context.pdf.saveGraphicsState();\n xOffset = 0;\n pdfFontSize = context.pdf.getFontSize();\n textX = toPixels(this.element.getAttribute('x'), pdfFontSize);\n textY = toPixels(this.element.getAttribute('y'), pdfFontSize);\n dx = toPixels(this.element.getAttribute('dx'), pdfFontSize);\n dy = toPixels(this.element.getAttribute('dy'), pdfFontSize);\n visibility = context.attributeState.visibility;\n tSpanCount = this.element.childElementCount;\n if (tSpanCount === 0) {\n trimmedText = transformXmlSpace(this.element.textContent || '', context.attributeState);\n transformedText = transformText(this.element, trimmedText, context);\n xOffset = context.textMeasure.getTextOffset(transformedText, context.attributeState);\n if (visibility === 'visible') {\n alignmentBaseline = context.attributeState.alignmentBaseline;\n textRenderingMode = getTextRenderingMode(context.attributeState);\n context.pdf.text(transformedText, textX + dx - xOffset, textY + dy, {\n baseline: mapAlignmentBaseline(alignmentBaseline),\n angle: context.transform,\n renderingMode: textRenderingMode === 'fill' ? void 0 : textRenderingMode\n });\n }\n }\n else {\n currentTextSegment = new TextChunk(this, context.attributeState.textAnchor, textX + dx, textY + dy);\n for (i = 0; i < this.element.childNodes.length; i++) {\n textNode = this.element.childNodes[i];\n if (!textNode.textContent) {\n continue;\n }\n xmlSpace = context.attributeState.xmlSpace;\n textContent = textNode.textContent;\n if (textNode.nodeName === '#text') ;\n else if (nodeIs(textNode, 'title')) {\n continue;\n }\n else if (nodeIs(textNode, 'tspan')) {\n tSpan = textNode;\n if (tSpan.childElementCount > 0) {\n // filter <title> elements...\n textContent = '';\n for (j = 0; j < tSpan.childNodes.length; j++) {\n if (tSpan.childNodes[j].nodeName === '#text') {\n textContent += tSpan.childNodes[j].textContent;\n }\n }\n }\n lastPositions = void 0;\n tSpanAbsX = tSpan.getAttribute('x');\n if (tSpanAbsX !== null) {\n x = toPixels(tSpanAbsX, pdfFontSize);\n lastPositions = currentTextSegment.put(context);\n currentTextSegment = new TextChunk(this, getAttribute(tSpan, context.styleSheets, 'text-anchor') ||\n context.attributeState.textAnchor, x, lastPositions[1]);\n }\n tSpanAbsY = tSpan.getAttribute('y');\n if (tSpanAbsY !== null) {\n y = toPixels(tSpanAbsY, pdfFontSize);\n lastPositions = currentTextSegment.put(context);\n currentTextSegment = new TextChunk(this, getAttribute(tSpan, context.styleSheets, 'text-anchor') ||\n context.attributeState.textAnchor, lastPositions[0], y);\n }\n tSpanXmlSpace = tSpan.getAttribute('xml:space');\n if (tSpanXmlSpace) {\n xmlSpace = tSpanXmlSpace;\n }\n }\n trimmedText = removeNewlines(textContent);\n trimmedText = replaceTabsBySpace(trimmedText);\n if (xmlSpace === 'default') {\n if (i === 0) {\n trimmedText = trimLeft(trimmedText);\n }\n if (i === tSpanCount - 1) {\n trimmedText = trimRight(trimmedText);\n }\n trimmedText = consolidateSpaces(trimmedText);\n }\n transformedText = transformText(this.element, trimmedText, context);\n currentTextSegment.add(textNode, transformedText);\n }\n currentTextSegment.put(context);\n }\n context.pdf.restoreGraphicsState();\n return [2 /*return*/];\n });\n });\n };\n TextNode.prototype.isVisible = function (parentVisible, context) {\n return svgNodeAndChildrenVisible(this, parentVisible, context);\n };\n TextNode.prototype.getBoundingBoxCore = function (context) {\n return defaultBoundingBox(this.element, context);\n };\n TextNode.prototype.computeNodeTransformCore = function (context) {\n return context.pdf.unitMatrix;\n };\n return TextNode;\n}(GraphicsNode));\n\nvar PathNode = /** @class */ (function (_super) {\n __extends(PathNode, _super);\n function PathNode(node, children) {\n return _super.call(this, true, node, children) || this;\n }\n PathNode.prototype.computeNodeTransformCore = function (context) {\n return context.pdf.unitMatrix;\n };\n PathNode.prototype.isVisible = function (parentVisible, context) {\n return svgNodeIsVisible(this, parentVisible, context);\n };\n PathNode.prototype.getPath = function (context) {\n var svgPath = new SvgPath(getAttribute(this.element, context.styleSheets, 'd') || '')\n .unshort()\n .unarc()\n .abs();\n var path = new Path();\n var prevX;\n var prevY;\n svgPath.iterate(function (seg, i) {\n var type = seg[0];\n switch (type) {\n case 'M':\n path.moveTo(seg[1], seg[2]);\n break;\n case 'L':\n path.lineTo(seg[1], seg[2]);\n break;\n case 'H':\n path.lineTo(seg[1], prevY);\n break;\n case 'V':\n path.lineTo(prevX, seg[1]);\n break;\n case 'C':\n path.curveTo(seg[1], seg[2], seg[3], seg[4], seg[5], seg[6]);\n break;\n case 'Q':\n var p2 = toCubic([prevX, prevY], [seg[1], seg[2]]);\n var p3 = toCubic([seg[3], seg[4]], [seg[1], seg[2]]);\n path.curveTo(p2[0], p2[1], p3[0], p3[1], seg[3], seg[4]);\n break;\n case 'Z':\n path.close();\n break;\n }\n switch (type) {\n case 'M':\n case 'L':\n prevX = seg[1];\n prevY = seg[2];\n break;\n case 'H':\n prevX = seg[1];\n break;\n case 'V':\n prevY = seg[1];\n break;\n case 'C':\n prevX = seg[5];\n prevY = seg[6];\n break;\n case 'Q':\n prevX = seg[3];\n prevY = seg[4];\n break;\n }\n });\n return path;\n };\n return PathNode;\n}(GeometryNode));\n\n// groups: 1: mime-type (+ charset), 2: mime-type (w/o charset), 3: charset, 4: base64?, 5: body\nvar dataUriRegex = /^\\s*data:(([^/,;]+\\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*\\s*)$/i;\nvar ImageNode = /** @class */ (function (_super) {\n __extends(ImageNode, _super);\n function ImageNode(element, children) {\n var _this = _super.call(this, element, children) || this;\n _this.imageLoadingPromise = null;\n _this.imageUrl = _this.element.getAttribute('xlink:href') || _this.element.getAttribute('href');\n if (_this.imageUrl) {\n // start loading the image as early as possible\n _this.imageLoadingPromise = ImageNode.fetchImageData(_this.imageUrl);\n }\n return _this;\n }\n ImageNode.prototype.renderCore = function (context) {\n return __awaiter(this, void 0, void 0, function () {\n var width, height, x, y, _a, data, format, parser, svgElement, preserveAspectRatio, idMap, svgnode, dataUri;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (!this.imageLoadingPromise) {\n return [2 /*return*/];\n }\n context.pdf.setCurrentTransformationMatrix(context.transform);\n width = parseFloat(getAttribute(this.element, context.styleSheets, 'width') || '0'), height = parseFloat(getAttribute(this.element, context.styleSheets, 'height') || '0'), x = parseFloat(getAttribute(this.element, context.styleSheets, 'x') || '0'), y = parseFloat(getAttribute(this.element, context.styleSheets, 'y') || '0');\n if (!isFinite(width) || width <= 0 || !isFinite(height) || height <= 0) {\n return [2 /*return*/];\n }\n return [4 /*yield*/, this.imageLoadingPromise];\n case 1:\n _a = _b.sent(), data = _a.data, format = _a.format;\n if (!(format.indexOf('svg') === 0)) return [3 /*break*/, 3];\n parser = new DOMParser();\n svgElement = parser.parseFromString(data, 'image/svg+xml').firstElementChild;\n preserveAspectRatio = this.element.getAttribute('preserveAspectRatio');\n if (!preserveAspectRatio ||\n preserveAspectRatio.indexOf('defer') < 0 ||\n !svgElement.getAttribute('preserveAspectRatio')) {\n svgElement.setAttribute('preserveAspectRatio', preserveAspectRatio || '');\n }\n svgElement.setAttribute('x', String(x));\n svgElement.setAttribute('y', String(y));\n svgElement.setAttribute('width', String(width));\n svgElement.setAttribute('height', String(height));\n idMap = {};\n svgnode = parse(svgElement, idMap);\n return [4 /*yield*/, svgnode.render(new Context(context.pdf, {\n refsHandler: new ReferencesHandler(idMap),\n styleSheets: context.styleSheets,\n viewport: new Viewport(width, height),\n svg2pdfParameters: context.svg2pdfParameters\n }))];\n case 2:\n _b.sent();\n return [2 /*return*/];\n case 3:\n dataUri = \"data:image/\" + format + \";base64,\" + btoa(data);\n try {\n context.pdf.addImage(dataUri, '', // will be ignored anyways if imageUrl is a data url\n x, y, width, height);\n }\n catch (e) {\n typeof console === 'object' &&\n console.warn &&\n console.warn(\"Could not load image \" + this.imageUrl + \".\\n\" + e);\n }\n _b.label = 4;\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n ImageNode.prototype.getBoundingBoxCore = function (context) {\n return defaultBoundingBox(this.element, context);\n };\n ImageNode.prototype.computeNodeTransformCore = function (context) {\n return context.pdf.unitMatrix;\n };\n ImageNode.prototype.isVisible = function (parentVisible, context) {\n return svgNodeIsVisible(this, parentVisible, context);\n };\n ImageNode.fetchImageData = function (imageUrl) {\n return __awaiter(this, void 0, void 0, function () {\n var data, format, match, mimeType, mimeTypeParts;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n match = imageUrl.match(dataUriRegex);\n if (!match) return [3 /*break*/, 1];\n mimeType = match[2];\n mimeTypeParts = mimeType.split('/');\n if (mimeTypeParts[0] !== 'image') {\n throw new Error(\"Unsupported image URL: \" + imageUrl);\n }\n format = mimeTypeParts[1];\n data = match[5];\n if (match[4] === 'base64') {\n data = atob(data);\n }\n else {\n data = decodeURIComponent(data);\n }\n return [3 /*break*/, 3];\n case 1: return [4 /*yield*/, ImageNode.fetchImage(imageUrl)];\n case 2:\n data = _a.sent();\n format = imageUrl.substring(imageUrl.lastIndexOf('.') + 1);\n _a.label = 3;\n case 3: return [2 /*return*/, {\n data: data,\n format: format\n }];\n }\n });\n });\n };\n ImageNode.fetchImage = function (imageUrl) {\n return new Promise(function (resolve, reject) {\n var xhr = new XMLHttpRequest();\n xhr.open('GET', imageUrl, true);\n xhr.responseType = 'arraybuffer';\n xhr.onload = function () {\n if (xhr.status !== 200) {\n throw new Error(\"Error \" + xhr.status + \": Failed to load image '\" + imageUrl + \"'\");\n }\n var bytes = new Uint8Array(xhr.response);\n var data = '';\n for (var i = 0; i < bytes.length; i++) {\n data += String.fromCharCode(bytes[i]);\n }\n resolve(data);\n };\n xhr.onerror = reject;\n xhr.onabort = reject;\n xhr.send(null);\n });\n };\n ImageNode.getMimeType = function (format) {\n format = format.toLowerCase();\n switch (format) {\n case 'jpg':\n case 'jpeg':\n return 'image/jpeg';\n default:\n return \"image/\" + format;\n }\n };\n return ImageNode;\n}(GraphicsNode));\n\nvar Traverse = /** @class */ (function (_super) {\n __extends(Traverse, _super);\n function Traverse(closed, node, children) {\n var _this = _super.call(this, true, node, children) || this;\n _this.closed = closed;\n return _this;\n }\n Traverse.prototype.getPath = function (context) {\n if (!this.element.hasAttribute('points') || this.element.getAttribute('points') === '') {\n return null;\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-ignore\n // @ts-ignore\n var points = Traverse.parsePointsString(this.element.getAttribute('points'));\n var path = new Path();\n if (points.length < 1) {\n return path;\n }\n path.moveTo(points[0][0], points[0][1]);\n for (var i = 1; i < points.length; i++) {\n path.lineTo(points[i][0], points[i][1]);\n }\n if (this.closed) {\n path.close();\n }\n return path;\n };\n Traverse.prototype.isVisible = function (parentVisible, context) {\n return svgNodeIsVisible(this, parentVisible, context);\n };\n Traverse.prototype.computeNodeTransformCore = function (context) {\n return context.pdf.unitMatrix;\n };\n Traverse.parsePointsString = function (string) {\n var floats = parseFloats(string);\n var result = [];\n for (var i = 0; i < floats.length - 1; i += 2) {\n var x = floats[i];\n var y = floats[i + 1];\n result.push([x, y]);\n }\n return result;\n };\n return Traverse;\n}(GeometryNode));\n\nvar Polygon = /** @class */ (function (_super) {\n __extends(Polygon, _super);\n function Polygon(node, children) {\n return _super.call(this, true, node, children) || this;\n }\n return Polygon;\n}(Traverse));\n\nvar VoidNode = /** @class */ (function (_super) {\n __extends(VoidNode, _super);\n function VoidNode() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n VoidNode.prototype.render = function (parentContext) {\n return Promise.resolve();\n };\n VoidNode.prototype.getBoundingBoxCore = function (context) {\n return [0, 0, 0, 0];\n };\n VoidNode.prototype.computeNodeTransformCore = function (context) {\n return context.pdf.unitMatrix;\n };\n VoidNode.prototype.isVisible = function (parentVisible, context) {\n return svgNodeIsVisible(this, parentVisible, context);\n };\n return VoidNode;\n}(SvgNode));\n\nvar MarkerNode = /** @class */ (function (_super) {\n __extends(MarkerNode, _super);\n function MarkerNode() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n MarkerNode.prototype.apply = function (parentContext) {\n return __awaiter(this, void 0, void 0, function () {\n var tfMatrix, bBox, _i, _a, child;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n tfMatrix = this.computeNodeTransform(parentContext);\n bBox = this.getBoundingBox(parentContext);\n parentContext.pdf.beginFormObject(bBox[0], bBox[1], bBox[2], bBox[3], tfMatrix);\n _i = 0, _a = this.children;\n _b.label = 1;\n case 1:\n if (!(_i < _a.length)) return [3 /*break*/, 4];\n child = _a[_i];\n return [4 /*yield*/, child.render(new Context(parentContext.pdf, {\n refsHandler: parentContext.refsHandler,\n styleSheets: parentContext.styleSheets,\n viewport: parentContext.viewport,\n svg2pdfParameters: parentContext.svg2pdfParameters\n }))];\n case 2:\n _b.sent();\n _b.label = 3;\n case 3:\n _i++;\n return [3 /*break*/, 1];\n case 4:\n parentContext.pdf.endFormObject(this.element.getAttribute('id'));\n return [2 /*return*/];\n }\n });\n });\n };\n MarkerNode.prototype.getBoundingBoxCore = function (context) {\n var viewBox = this.element.getAttribute('viewBox');\n var vb;\n if (viewBox) {\n vb = parseFloats(viewBox);\n }\n return [\n (vb && vb[0]) || 0,\n (vb && vb[1]) || 0,\n (vb && vb[2]) || parseFloat(this.element.getAttribute('marker-width') || '0'),\n (vb && vb[3]) || parseFloat(this.element.getAttribute('marker-height') || '0')\n ];\n };\n MarkerNode.prototype.computeNodeTransformCore = function (context) {\n var refX = parseFloat(this.element.getAttribute('refX') || '0');\n var refY = parseFloat(this.element.getAttribute('refY') || '0');\n var viewBox = this.element.getAttribute('viewBox');\n var nodeTransform;\n if (viewBox) {\n var bounds = parseFloats(viewBox);\n // \"Markers are drawn such that their reference point (i.e., attributes ‘refX’ and ‘refY’)\n // is positioned at the given vertex.\" - The \"translate\" part of the viewBox transform is\n // ignored.\n nodeTransform = computeViewBoxTransform(this.element, bounds, 0, 0, parseFloat(this.element.getAttribute('markerWidth') || '3'), parseFloat(this.element.getAttribute('markerHeight') || '3'), context, true);\n nodeTransform = context.pdf.matrixMult(context.pdf.Matrix(1, 0, 0, 1, -refX, -refY), nodeTransform);\n }\n else {\n nodeTransform = context.pdf.Matrix(1, 0, 0, 1, -refX, -refY);\n }\n return nodeTransform;\n };\n MarkerNode.prototype.isVisible = function (parentVisible, context) {\n return svgNodeAndChildrenVisible(this, parentVisible, context);\n };\n return MarkerNode;\n}(NonRenderedNode));\n\nvar Circle = /** @class */ (function (_super) {\n __extends(Circle, _super);\n function Circle(node, children) {\n return _super.call(this, node, children) || this;\n }\n Circle.prototype.getR = function (context) {\n var _a;\n return ((_a = this.r) !== null && _a !== void 0 ? _a : (this.r = parseFloat(getAttribute(this.element, context.styleSheets, 'r') || '0')));\n };\n Circle.prototype.getRx = function (context) {\n return this.getR(context);\n };\n Circle.prototype.getRy = function (context) {\n return this.getR(context);\n };\n return Circle;\n}(EllipseBase));\n\nvar Polyline = /** @class */ (function (_super) {\n __extends(Polyline, _super);\n function Polyline(node, children) {\n return _super.call(this, false, node, children) || this;\n }\n return Polyline;\n}(Traverse));\n\nvar ContainerNode = /** @class */ (function (_super) {\n __extends(ContainerNode, _super);\n function ContainerNode() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n ContainerNode.prototype.renderCore = function (context) {\n return __awaiter(this, void 0, void 0, function () {\n var _i, _a, child;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n _i = 0, _a = this.children;\n _b.label = 1;\n case 1:\n if (!(_i < _a.length)) return [3 /*break*/, 4];\n child = _a[_i];\n return [4 /*yield*/, child.render(context)];\n case 2:\n _b.sent();\n _b.label = 3;\n case 3:\n _i++;\n return [3 /*break*/, 1];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n ContainerNode.prototype.getBoundingBoxCore = function (context) {\n return getBoundingBoxByChildren(context, this);\n };\n return ContainerNode;\n}(RenderedNode));\n\nvar Svg = /** @class */ (function (_super) {\n __extends(Svg, _super);\n function Svg() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Svg.prototype.isVisible = function (parentVisible, context) {\n return svgNodeAndChildrenVisible(this, parentVisible, context);\n };\n Svg.prototype.render = function (context) {\n return __awaiter(this, void 0, void 0, function () {\n var x, y, width, height, transform;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.isVisible(context.attributeState.visibility !== 'hidden', context)) {\n return [2 /*return*/];\n }\n x = this.getX(context);\n y = this.getY(context);\n width = this.getWidth(context);\n height = this.getHeight(context);\n context.pdf.saveGraphicsState();\n transform = context.transform;\n if (this.element.hasAttribute('transform')) {\n // SVG 2 allows transforms on SVG elements\n // \"The transform should be applied as if the ‘svg’ had a parent element with that transform set.\"\n transform = context.pdf.matrixMult(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n parseTransform(this.element.getAttribute('transform'), context), transform);\n }\n context.pdf.setCurrentTransformationMatrix(transform);\n if (!context.withinUse &&\n getAttribute(this.element, context.styleSheets, 'overflow') !== 'visible') {\n // establish a new viewport\n context.pdf\n .rect(x, y, width, height)\n .clip()\n .discardPath();\n }\n return [4 /*yield*/, _super.prototype.render.call(this, context.clone({\n transform: context.pdf.unitMatrix,\n viewport: context.withinUse ? context.viewport : new Viewport(width, height)\n }))];\n case 1:\n _a.sent();\n context.pdf.restoreGraphicsState();\n return [2 /*return*/];\n }\n });\n });\n };\n Svg.prototype.computeNodeTransform = function (context) {\n return this.computeNodeTransformCore(context);\n };\n Svg.prototype.computeNodeTransformCore = function (context) {\n if (context.withinUse) {\n return context.pdf.unitMatrix;\n }\n var x = this.getX(context);\n var y = this.getY(context);\n var viewBox = this.getViewBox();\n var nodeTransform;\n if (viewBox) {\n var width = this.getWidth(context);\n var height = this.getHeight(context);\n nodeTransform = computeViewBoxTransform(this.element, viewBox, x, y, width, height, context);\n }\n else {\n nodeTransform = context.pdf.Matrix(1, 0, 0, 1, x, y);\n }\n return nodeTransform;\n };\n Svg.prototype.getWidth = function (context) {\n if (this.width !== undefined) {\n return this.width;\n }\n var width;\n var parameters = context.svg2pdfParameters;\n if (this.isOutermostSvg(context)) {\n // special treatment for the outermost SVG element\n if (parameters.width != null) {\n // if there is a user defined width, use it\n width = parameters.width;\n }\n else {\n // otherwise check if the SVG element defines the width itself\n var widthAttr = getAttribute(this.element, context.styleSheets, 'width');\n if (widthAttr) {\n width = parseFloat(widthAttr);\n }\n else {\n // if not, check if we can figure out the aspect ratio from the viewBox attribute\n var viewBox = this.getViewBox();\n if (viewBox &&\n (parameters.height != null || getAttribute(this.element, context.styleSheets, 'height'))) {\n // if there is a viewBox and the height is defined, use the width that matches the height together with the aspect ratio\n var aspectRatio = viewBox[2] / viewBox[3];\n width = this.getHeight(context) * aspectRatio;\n }\n else {\n // if there is no viewBox use a default of 300 or the largest size that fits into the outer viewport\n // at an aspect ratio of 2:1\n width = Math.min(300, context.viewport.width, context.viewport.height * 2);\n }\n }\n }\n }\n else {\n var widthAttr = getAttribute(this.element, context.styleSheets, 'width');\n width = widthAttr ? parseFloat(widthAttr) : context.viewport.width;\n }\n return (this.width = width);\n };\n Svg.prototype.getHeight = function (context) {\n if (this.height !== undefined) {\n return this.height;\n }\n var height;\n var parameters = context.svg2pdfParameters;\n if (this.isOutermostSvg(context)) {\n // special treatment for the outermost SVG element\n if (parameters.height != null) {\n // if there is a user defined height, use it\n height = parameters.height;\n }\n else {\n // otherwise check if the SVG element defines the height itself\n var heightAttr = getAttribute(this.element, context.styleSheets, 'height');\n if (heightAttr) {\n height = parseFloat(heightAttr);\n }\n else {\n // if not, check if we can figure out the aspect ratio from the viewBox attribute\n var viewBox = this.getViewBox();\n if (viewBox) {\n // if there is a viewBox, use the height that matches the width together with the aspect ratio\n var aspectRatio = viewBox[2] / viewBox[3];\n height = this.getWidth(context) / aspectRatio;\n }\n else {\n // if there is no viewBox use a default of 150 or the largest size that fits into the outer viewport\n // at an aspect ratio of 2:1\n height = Math.min(150, context.viewport.width / 2, context.viewport.height);\n }\n }\n }\n }\n else {\n var heightAttr = getAttribute(this.element, context.styleSheets, 'height');\n height = heightAttr ? parseFloat(heightAttr) : context.viewport.height;\n }\n return (this.height = height);\n };\n Svg.prototype.getX = function (context) {\n if (this.x !== undefined) {\n return this.x;\n }\n if (this.isOutermostSvg(context)) {\n return (this.x = 0);\n }\n var xAttr = getAttribute(this.element, context.styleSheets, 'x');\n return (this.x = xAttr ? parseFloat(xAttr) : 0);\n };\n Svg.prototype.getY = function (context) {\n if (this.y !== undefined) {\n return this.y;\n }\n if (this.isOutermostSvg(context)) {\n return (this.y = 0);\n }\n var yAttr = getAttribute(this.element, context.styleSheets, 'y');\n return (this.y = yAttr ? parseFloat(yAttr) : 0);\n };\n Svg.prototype.getViewBox = function () {\n if (this.viewBox !== undefined) {\n return this.viewBox;\n }\n var viewBox = this.element.getAttribute('viewBox');\n return (this.viewBox = viewBox ? parseFloats(viewBox) : undefined);\n };\n Svg.prototype.isOutermostSvg = function (context) {\n return context.svg2pdfParameters.element === this.element;\n };\n return Svg;\n}(ContainerNode));\n\nvar Group = /** @class */ (function (_super) {\n __extends(Group, _super);\n function Group() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n Group.prototype.isVisible = function (parentVisible, context) {\n return svgNodeAndChildrenVisible(this, parentVisible, context);\n };\n Group.prototype.computeNodeTransformCore = function (context) {\n return context.pdf.unitMatrix;\n };\n return Group;\n}(ContainerNode));\n\nvar ClipPath = /** @class */ (function (_super) {\n __extends(ClipPath, _super);\n function ClipPath() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n ClipPath.prototype.apply = function (context) {\n return __awaiter(this, void 0, void 0, function () {\n var clipPathMatrix, _i, _a, child;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (!this.isVisible(true, context)) {\n return [2 /*return*/];\n }\n clipPathMatrix = context.pdf.matrixMult(this.computeNodeTransform(context), context.transform);\n context.pdf.setCurrentTransformationMatrix(clipPathMatrix);\n _i = 0, _a = this.children;\n _b.label = 1;\n case 1:\n if (!(_i < _a.length)) return [3 /*break*/, 4];\n child = _a[_i];\n return [4 /*yield*/, child.render(new Context(context.pdf, {\n refsHandler: context.refsHandler,\n styleSheets: context.styleSheets,\n viewport: context.viewport,\n withinClipPath: true,\n svg2pdfParameters: context.svg2pdfParameters\n }))];\n case 2:\n _b.sent();\n _b.label = 3;\n case 3:\n _i++;\n return [3 /*break*/, 1];\n case 4:\n context.pdf.clip().discardPath();\n // as we cannot use restoreGraphicsState() to reset the transform (this would reset the clipping path, as well),\n // we must append the inverse instead\n context.pdf.setCurrentTransformationMatrix(clipPathMatrix.inversed());\n return [2 /*return*/];\n }\n });\n });\n };\n ClipPath.prototype.getBoundingBoxCore = function (context) {\n return getBoundingBoxByChildren(context, this);\n };\n ClipPath.prototype.isVisible = function (parentVisible, context) {\n return svgNodeAndChildrenVisible(this, parentVisible, context);\n };\n return ClipPath;\n}(NonRenderedNode));\n\nfunction parse(node, idMap) {\n var svgnode;\n var children = [];\n forEachChild(node, function (i, n) { return children.push(parse(n, idMap)); });\n switch (node.tagName.toLowerCase()) {\n case 'a':\n case 'g':\n svgnode = new Group(node, children);\n break;\n case 'circle':\n svgnode = new Circle(node, children);\n break;\n case 'clippath':\n svgnode = new ClipPath(node, children);\n break;\n case 'ellipse':\n svgnode = new Ellipse(node, children);\n break;\n case 'lineargradient':\n svgnode = new LinearGradient(node, children);\n break;\n case 'image':\n svgnode = new ImageNode(node, children);\n break;\n case 'line':\n svgnode = new Line(node, children);\n break;\n case 'marker':\n svgnode = new MarkerNode(node, children);\n break;\n case 'path':\n svgnode = new PathNode(node, children);\n break;\n case 'pattern':\n svgnode = new Pattern(node, children);\n break;\n case 'polygon':\n svgnode = new Polygon(node, children);\n break;\n case 'polyline':\n svgnode = new Polyline(node, children);\n break;\n case 'radialgradient':\n svgnode = new RadialGradient(node, children);\n break;\n case 'rect':\n svgnode = new Rect(node, children);\n break;\n case 'svg':\n svgnode = new Svg(node, children);\n break;\n case 'symbol':\n svgnode = new Symbol$1(node, children);\n break;\n case 'text':\n svgnode = new TextNode(node, children);\n break;\n case 'use':\n svgnode = new Use(node, children);\n break;\n default:\n svgnode = new VoidNode(node, children);\n break;\n }\n if (idMap != undefined && svgnode.element.hasAttribute('id')) {\n var id = cssEsc(svgnode.element.id, { isIdentifier: true });\n idMap[id] = idMap[id] || svgnode;\n }\n return svgnode;\n}\n\nvar StyleSheets = /** @class */ (function () {\n function StyleSheets(rootSvg, loadExtSheets) {\n this.rootSvg = rootSvg;\n this.loadExternalSheets = loadExtSheets;\n this.styleSheets = [];\n }\n StyleSheets.prototype.load = function () {\n return __awaiter(this, void 0, void 0, function () {\n var sheetTexts;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.collectStyleSheetTexts()];\n case 1:\n sheetTexts = _a.sent();\n this.parseCssSheets(sheetTexts);\n return [2 /*return*/];\n }\n });\n });\n };\n StyleSheets.prototype.collectStyleSheetTexts = function () {\n return __awaiter(this, void 0, void 0, function () {\n var sheetTexts, i, node, styleElements, i, styleElement;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n sheetTexts = [];\n if (this.loadExternalSheets && this.rootSvg.ownerDocument) {\n for (i = 0; i < this.rootSvg.ownerDocument.childNodes.length; i++) {\n node = this.rootSvg.ownerDocument.childNodes[i];\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (node.nodeName === 'xml-stylesheet' && typeof node.data === 'string') {\n sheetTexts.push(StyleSheets.loadSheet(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n node.data\n .match(/href=[\"'].*?[\"']/)[0]\n .split('=')[1]\n .slice(1, -1)));\n }\n }\n }\n styleElements = this.rootSvg.querySelectorAll('style,link');\n for (i = 0; i < styleElements.length; i++) {\n styleElement = styleElements[i];\n if (nodeIs(styleElement, 'style')) {\n sheetTexts.push(styleElement.textContent);\n }\n else if (this.loadExternalSheets &&\n nodeIs(styleElement, 'link') &&\n styleElement.getAttribute('rel') === 'stylesheet' &&\n styleElement.hasAttribute('href')) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n sheetTexts.push(StyleSheets.loadSheet(styleElement.getAttribute('href')));\n }\n }\n return [4 /*yield*/, Promise.all(sheetTexts)];\n case 1: return [2 /*return*/, (_a.sent()).filter(function (sheet) { return sheet !== null; })];\n }\n });\n });\n };\n StyleSheets.prototype.parseCssSheets = function (sheetTexts) {\n var styleDoc = document.implementation.createHTMLDocument('');\n for (var _i = 0, sheetTexts_1 = sheetTexts; _i < sheetTexts_1.length; _i++) {\n var sheetText = sheetTexts_1[_i];\n var style = styleDoc.createElement('style');\n style.textContent = sheetText;\n styleDoc.body.appendChild(style);\n var sheet = style.sheet;\n if (sheet instanceof CSSStyleSheet) {\n for (var i = sheet.cssRules.length - 1; i >= 0; i--) {\n var cssRule = sheet.cssRules[i];\n if (!(cssRule instanceof CSSStyleRule)) {\n sheet.deleteRule(i);\n }\n var cssStyleRule = cssRule;\n if (cssStyleRule.selectorText.indexOf(',') >= 0) {\n sheet.deleteRule(i);\n var body = cssStyleRule.cssText.substring(cssStyleRule.selectorText.length);\n var selectors = StyleSheets.splitSelectorAtCommas(cssStyleRule.selectorText);\n for (var j = 0; j < selectors.length; j++) {\n sheet.insertRule(selectors[j] + body, i + j);\n }\n }\n }\n this.styleSheets.push(sheet);\n }\n }\n };\n StyleSheets.splitSelectorAtCommas = function (selectorText) {\n var initialRegex = /,|[\"']/g;\n var closingDoubleQuotesRegex = /[^\\\\][\"]/g;\n var closingSingleQuotesRegex = /[^\\\\][']/g;\n var parts = [];\n var state = 'initial';\n var match;\n var lastCommaIndex = -1;\n var closingQuotesRegex = closingDoubleQuotesRegex;\n for (var i = 0; i < selectorText.length;) {\n switch (state) {\n case 'initial':\n initialRegex.lastIndex = i;\n match = initialRegex.exec(selectorText);\n if (match) {\n if (match[0] === ',') {\n parts.push(selectorText.substring(lastCommaIndex + 1, initialRegex.lastIndex - 1).trim());\n lastCommaIndex = initialRegex.lastIndex - 1;\n }\n else {\n state = 'withinQuotes';\n closingQuotesRegex =\n match[0] === '\"' ? closingDoubleQuotesRegex : closingSingleQuotesRegex;\n }\n i = initialRegex.lastIndex;\n }\n else {\n parts.push(selectorText.substring(lastCommaIndex + 1).trim());\n i = selectorText.length;\n }\n break;\n case 'withinQuotes':\n closingQuotesRegex.lastIndex = i;\n match = closingQuotesRegex.exec(selectorText);\n if (match) {\n i = closingQuotesRegex.lastIndex;\n state = 'initial';\n }\n // else this is a syntax error - omit the last part...\n break;\n }\n }\n return parts;\n };\n StyleSheets.loadSheet = function (url) {\n return (new Promise(function (resolve, reject) {\n var xhr = new XMLHttpRequest();\n xhr.open('GET', url, true);\n xhr.responseType = 'text';\n xhr.onload = function () {\n if (xhr.status !== 200) {\n reject(new Error(\"Error \" + xhr.status + \": Failed to load '\" + url + \"'\"));\n }\n resolve(xhr.responseText);\n };\n xhr.onerror = reject;\n xhr.onabort = reject;\n xhr.send(null);\n })\n // ignore the error since some stylesheets may not be accessible\n // due to CORS policies\n .catch(function () { return null; }));\n };\n StyleSheets.prototype.getPropertyValue = function (node, propertyCss) {\n var matchingRules = [];\n for (var _i = 0, _a = this.styleSheets; _i < _a.length; _i++) {\n var sheet = _a[_i];\n for (var i = 0; i < sheet.cssRules.length; i++) {\n var rule = sheet.cssRules[i];\n if (rule.style.getPropertyValue(propertyCss) && node.matches(rule.selectorText)) {\n matchingRules.push(rule);\n }\n }\n }\n if (matchingRules.length === 0) {\n return undefined;\n }\n var compare$1 = function (a, b) {\n var priorityA = a.style.getPropertyPriority(propertyCss);\n var priorityB = b.style.getPropertyPriority(propertyCss);\n if (priorityA !== priorityB) {\n return priorityA === 'important' ? 1 : -1;\n }\n return compare(a.selectorText, b.selectorText);\n };\n var mostSpecificRule = matchingRules.reduce(function (previousValue, currentValue) {\n return compare$1(previousValue, currentValue) === 1 ? previousValue : currentValue;\n });\n return mostSpecificRule.style.getPropertyValue(propertyCss) || undefined;\n };\n return StyleSheets;\n}());\n\nfunction svg2pdf(element, pdf, options) {\n var _a, _b, _c;\n if (options === void 0) { options = {}; }\n return __awaiter(this, void 0, void 0, function () {\n var x, y, extCss, idMap, refsHandler, styleSheets, viewport, svg2pdfParameters, context, fill, node;\n return __generator(this, function (_d) {\n switch (_d.label) {\n case 0:\n x = (_a = options.x) !== null && _a !== void 0 ? _a : 0.0;\n y = (_b = options.y) !== null && _b !== void 0 ? _b : 0.0;\n extCss = (_c = options.loadExternalStyleSheets) !== null && _c !== void 0 ? _c : false;\n idMap = {};\n refsHandler = new ReferencesHandler(idMap);\n styleSheets = new StyleSheets(element, extCss);\n return [4 /*yield*/, styleSheets.load()\n // start with the entire page size as viewport\n ];\n case 1:\n _d.sent();\n viewport = new Viewport(pdf.internal.pageSize.getWidth(), pdf.internal.pageSize.getHeight());\n svg2pdfParameters = __assign(__assign({}, options), { element: element });\n context = new Context(pdf, { refsHandler: refsHandler, styleSheets: styleSheets, viewport: viewport, svg2pdfParameters: svg2pdfParameters });\n pdf.advancedAPI();\n pdf.saveGraphicsState();\n // set offsets\n pdf.setCurrentTransformationMatrix(pdf.Matrix(1, 0, 0, 1, x, y));\n // set default values that differ from pdf defaults\n pdf.setLineWidth(context.attributeState.strokeWidth);\n fill = context.attributeState.fill.color;\n pdf.setFillColor(fill.r, fill.g, fill.b);\n pdf.setFont(context.attributeState.fontFamily);\n // correct for a jsPDF-instance measurement unit that differs from `pt`\n pdf.setFontSize(context.attributeState.fontSize * pdf.internal.scaleFactor);\n node = parse(element, idMap);\n return [4 /*yield*/, node.render(context)];\n case 2:\n _d.sent();\n pdf.restoreGraphicsState();\n pdf.compatAPI();\n context.textMeasure.cleanupTextMeasuring();\n return [2 /*return*/, pdf];\n }\n });\n });\n}\njsPDF.API.svg = function (element, options) {\n if (options === void 0) { options = {}; }\n return svg2pdf(element, this, options);\n};\n\nexport { svg2pdf };\n//# sourceMappingURL=svg2pdf.es.js.map\n","/**\n * For parsing color values.\n * @module RGBColor\n * @author Stoyan Stefanov <sstoo@gmail.com>\n * @see https://www.phpied.com/rgb-color-parser-in-javascript/\n * @license MIT\n*/\nconst simpleColors = {\n aliceblue: 'f0f8ff',\n antiquewhite: 'faebd7',\n aqua: '00ffff',\n aquamarine: '7fffd4',\n azure: 'f0ffff',\n beige: 'f5f5dc',\n bisque: 'ffe4c4',\n black: '000000',\n blanchedalmond: 'ffebcd',\n blue: '0000ff',\n blueviolet: '8a2be2',\n brown: 'a52a2a',\n burlywood: 'deb887',\n cadetblue: '5f9ea0',\n chartreuse: '7fff00',\n chocolate: 'd2691e',\n coral: 'ff7f50',\n cornflowerblue: '6495ed',\n cornsilk: 'fff8dc',\n crimson: 'dc143c',\n cyan: '00ffff',\n darkblue: '00008b',\n darkcyan: '008b8b',\n darkgoldenrod: 'b8860b',\n darkgray: 'a9a9a9',\n darkgreen: '006400',\n darkkhaki: 'bdb76b',\n darkmagenta: '8b008b',\n darkolivegreen: '556b2f',\n darkorange: 'ff8c00',\n darkorchid: '9932cc',\n darkred: '8b0000',\n darksalmon: 'e9967a',\n darkseagreen: '8fbc8f',\n darkslateblue: '483d8b',\n darkslategray: '2f4f4f',\n darkturquoise: '00ced1',\n darkviolet: '9400d3',\n deeppink: 'ff1493',\n deepskyblue: '00bfff',\n dimgray: '696969',\n dodgerblue: '1e90ff',\n feldspar: 'd19275',\n firebrick: 'b22222',\n floralwhite: 'fffaf0',\n forestgreen: '228b22',\n fuchsia: 'ff00ff',\n gainsboro: 'dcdcdc',\n ghostwhite: 'f8f8ff',\n gold: 'ffd700',\n goldenrod: 'daa520',\n gray: '808080',\n green: '008000',\n greenyellow: 'adff2f',\n honeydew: 'f0fff0',\n hotpink: 'ff69b4',\n indianred: 'cd5c5c',\n indigo: '4b0082',\n ivory: 'fffff0',\n khaki: 'f0e68c',\n lavender: 'e6e6fa',\n lavenderblush: 'fff0f5',\n lawngreen: '7cfc00',\n lemonchiffon: 'fffacd',\n lightblue: 'add8e6',\n lightcoral: 'f08080',\n lightcyan: 'e0ffff',\n lightgoldenrodyellow: 'fafad2',\n lightgrey: 'd3d3d3',\n lightgreen: '90ee90',\n lightpink: 'ffb6c1',\n lightsalmon: 'ffa07a',\n lightseagreen: '20b2aa',\n lightskyblue: '87cefa',\n lightslateblue: '8470ff',\n lightslategray: '778899',\n lightsteelblue: 'b0c4de',\n lightyellow: 'ffffe0',\n lime: '00ff00',\n limegreen: '32cd32',\n linen: 'faf0e6',\n magenta: 'ff00ff',\n maroon: '800000',\n mediumaquamarine: '66cdaa',\n mediumblue: '0000cd',\n mediumorchid: 'ba55d3',\n mediumpurple: '9370d8',\n mediumseagreen: '3cb371',\n mediumslateblue: '7b68ee',\n mediumspringgreen: '00fa9a',\n mediumturquoise: '48d1cc',\n mediumvioletred: 'c71585',\n midnightblue: '191970',\n mintcream: 'f5fffa',\n mistyrose: 'ffe4e1',\n moccasin: 'ffe4b5',\n navajowhite: 'ffdead',\n navy: '000080',\n oldlace: 'fdf5e6',\n olive: '808000',\n olivedrab: '6b8e23',\n orange: 'ffa500',\n orangered: 'ff4500',\n orchid: 'da70d6',\n palegoldenrod: 'eee8aa',\n palegreen: '98fb98',\n paleturquoise: 'afeeee',\n palevioletred: 'd87093',\n papayawhip: 'ffefd5',\n peachpuff: 'ffdab9',\n peru: 'cd853f',\n pink: 'ffc0cb',\n plum: 'dda0dd',\n powderblue: 'b0e0e6',\n purple: '800080',\n red: 'ff0000',\n rosybrown: 'bc8f8f',\n royalblue: '4169e1',\n saddlebrown: '8b4513',\n salmon: 'fa8072',\n sandybrown: 'f4a460',\n seagreen: '2e8b57',\n seashell: 'fff5ee',\n sienna: 'a0522d',\n silver: 'c0c0c0',\n skyblue: '87ceeb',\n slateblue: '6a5acd',\n slategray: '708090',\n snow: 'fffafa',\n springgreen: '00ff7f',\n steelblue: '4682b4',\n tan: 'd2b48c',\n teal: '008080',\n thistle: 'd8bfd8',\n tomato: 'ff6347',\n turquoise: '40e0d0',\n violet: 'ee82ee',\n violetred: 'd02090',\n wheat: 'f5deb3',\n white: 'ffffff',\n whitesmoke: 'f5f5f5',\n yellow: 'ffff00',\n yellowgreen: '9acd32'\n};\n\n// array of color definition objects\nconst colorDefs = [\n {\n re: /^rgb\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})\\)$/,\n // re: /^rgb\\((?<r>\\d{1,3}),\\s*(?<g>\\d{1,3}),\\s*(?<b>\\d{1,3})\\)$/,\n example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],\n process (_, ...bits) {\n return bits.map((b) => Number.parseInt(b));\n }\n },\n {\n re: /^(\\w{2})(\\w{2})(\\w{2})$/,\n // re: /^(?<r>\\w{2})(?<g>\\w{2})(?<b>\\w{2})$/,\n example: ['#00ff00', '336699'],\n process (_, ...bits) {\n return bits.map((b) => Number.parseInt(b, 16));\n }\n },\n {\n re: /^(\\w)(\\w)(\\w)$/,\n // re: /^(?<r>\\w{1})(?<g>\\w{1})(?<b>\\w{1})$/,\n example: ['#fb0', 'f0f'],\n process (_, ...bits) {\n return bits.map((b) => Number.parseInt(b + b, 16));\n }\n }\n];\n\n/**\n * A class to parse color values.\n */\nexport default class RGBColor {\n /**\n * @param {string} colorString\n */\n constructor (colorString) {\n this.ok = false;\n\n // strip any leading #\n if (colorString.charAt(0) === '#') { // remove # if any\n colorString = colorString.substr(1, 6);\n }\n\n colorString = colorString.replace(/ /g, '');\n colorString = colorString.toLowerCase();\n\n // before getting into regexps, try simple matches\n // and overwrite the input\n if (colorString in simpleColors) {\n colorString = simpleColors[colorString];\n }\n // end of simple type-in colors\n\n // search through the definitions to find a match\n\n colorDefs.forEach(({re, process: processor}) => {\n const bits = re.exec(colorString);\n if (bits) {\n const [r, g, b] = processor(...bits);\n Object.assign(this, {r, g, b});\n this.ok = true;\n }\n });\n\n // validate/cleanup values\n this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r);\n this.g = (this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g);\n this.b = (this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b);\n }\n\n // some getters\n /**\n * @returns {string}\n */\n toRGB () {\n return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')';\n }\n\n /**\n * @returns {string}\n */\n toHex () {\n let r = this.r.toString(16);\n let g = this.g.toString(16);\n let b = this.b.toString(16);\n if (r.length === 1) { r = '0' + r; }\n if (g.length === 1) { g = '0' + g; }\n if (b.length === 1) { b = '0' + b; }\n return '#' + r + g + b;\n }\n\n /**\n * Offers a bulleted list of help.\n * @returns {HTMLUListElement}\n */\n static getHelpXML () {\n const examples = [\n // add regexps\n ...colorDefs.flatMap(({example}) => {\n return example;\n }),\n // add type-in colors\n ...Object.keys(simpleColors)\n ];\n\n const xml = document.createElement('ul');\n xml.setAttribute('id', 'rgbcolor-examples');\n\n xml.append(...examples.map((example) => {\n try {\n const listItem = document.createElement('li');\n const listColor = new RGBColor(example);\n const exampleDiv = document.createElement('div');\n exampleDiv.style.cssText = `\n margin: 3px;\n border: 1px solid black;\n background: ${listColor.toHex()};\n color: ${listColor.toHex()};`;\n exampleDiv.append('test');\n const listItemValue = ` ${example} -> ${listColor.toRGB()} -> ${listColor.toHex()}`;\n listItem.append(exampleDiv, listItemValue);\n return listItem;\n } catch (e) {\n return '';\n }\n }));\n return xml;\n }\n}\n","function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n _typeof = function (obj) {\n return typeof obj;\n };\n } else {\n _typeof = function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n };\n }\n\n return _typeof(obj);\n}\n\nfunction _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\n\n/* eslint-disable no-bitwise, unicorn/prefer-query-selector */\n\n/**\n* StackBlur - a fast almost Gaussian Blur For Canvas\n*\n* In case you find this class useful - especially in commercial projects -\n* I am not totally unhappy for a small donation to my PayPal account\n* mario@quasimondo.de\n*\n* Or support me on flattr:\n* {@link https://flattr.com/thing/72791/StackBlur-a-fast-almost-Gaussian-Blur-Effect-for-CanvasJavascript}.\n*\n* @module StackBlur\n* @author Mario Klingemann\n* Contact: mario@quasimondo.com\n* Website: {@link http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html}\n* Twitter: @quasimondo\n*\n* @copyright (c) 2010 Mario Klingemann\n*\n* Permission is hereby granted, free of charge, to any person\n* obtaining a copy of this software and associated documentation\n* files (the \"Software\"), to deal in the Software without\n* restriction, including without limitation the rights to use,\n* copy, modify, merge, publish, distribute, sublicense, and/or sell\n* copies of the Software, and to permit persons to whom the\n* Software is furnished to do so, subject to the following\n* conditions:\n*\n* The above copyright notice and this permission notice shall be\n* included in all copies or substantial portions of the Software.\n*\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n* OTHER DEALINGS IN THE SOFTWARE.\n*/\n\n/* eslint-disable max-len */\nvar mulTable = [512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292, 273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259, 496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292, 282, 273, 265, 512, 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278, 271, 265, 259, 507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335, 329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405, 399, 394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271, 268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388, 385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335, 332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292, 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259];\nvar shgTable = [9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24];\n/* eslint-enable max-len */\n\n/**\n * @param {string|HTMLImageElement} img\n * @param {string|HTMLCanvasElement} canvas\n * @param {Float} radius\n * @param {boolean} blurAlphaChannel\n * @returns {undefined}\n */\n\nfunction processImage(img, canvas, radius, blurAlphaChannel) {\n if (typeof img === 'string') {\n img = document.getElementById(img);\n }\n\n if (!img || !('naturalWidth' in img)) {\n return;\n }\n\n var w = img.naturalWidth;\n var h = img.naturalHeight;\n\n if (typeof canvas === 'string') {\n canvas = document.getElementById(canvas);\n }\n\n if (!canvas || !('getContext' in canvas)) {\n return;\n }\n\n canvas.style.width = w + 'px';\n canvas.style.height = h + 'px';\n canvas.width = w;\n canvas.height = h;\n var context = canvas.getContext('2d');\n context.clearRect(0, 0, w, h);\n context.drawImage(img, 0, 0);\n\n if (isNaN(radius) || radius < 1) {\n return;\n }\n\n if (blurAlphaChannel) {\n processCanvasRGBA(canvas, 0, 0, w, h, radius);\n } else {\n processCanvasRGB(canvas, 0, 0, w, h, radius);\n }\n}\n/**\n * @param {string|HTMLCanvasElement} canvas\n * @param {Integer} topX\n * @param {Integer} topY\n * @param {Integer} width\n * @param {Integer} height\n * @throws {Error|TypeError}\n * @returns {ImageData} See {@link https://html.spec.whatwg.org/multipage/canvas.html#imagedata}\n */\n\n\nfunction getImageDataFromCanvas(canvas, topX, topY, width, height) {\n if (typeof canvas === 'string') {\n canvas = document.getElementById(canvas);\n }\n\n if (!canvas || _typeof(canvas) !== 'object' || !('getContext' in canvas)) {\n throw new TypeError('Expecting canvas with `getContext` method ' + 'in processCanvasRGB(A) calls!');\n }\n\n var context = canvas.getContext('2d');\n\n try {\n return context.getImageData(topX, topY, width, height);\n } catch (e) {\n throw new Error('unable to access image data: ' + e);\n }\n}\n/**\n * @param {HTMLCanvasElement} canvas\n * @param {Integer} topX\n * @param {Integer} topY\n * @param {Integer} width\n * @param {Integer} height\n * @param {Float} radius\n * @returns {undefined}\n */\n\n\nfunction processCanvasRGBA(canvas, topX, topY, width, height, radius) {\n if (isNaN(radius) || radius < 1) {\n return;\n }\n\n radius |= 0;\n var imageData = getImageDataFromCanvas(canvas, topX, topY, width, height);\n imageData = processImageDataRGBA(imageData, topX, topY, width, height, radius);\n canvas.getContext('2d').putImageData(imageData, topX, topY);\n}\n/**\n * @param {ImageData} imageData\n * @param {Integer} topX\n * @param {Integer} topY\n * @param {Integer} width\n * @param {Integer} height\n * @param {Float} radius\n * @returns {ImageData}\n */\n\n\nfunction processImageDataRGBA(imageData, topX, topY, width, height, radius) {\n var pixels = imageData.data;\n var x, y, i, p, yp, yi, yw, rSum, gSum, bSum, aSum, rOutSum, gOutSum, bOutSum, aOutSum, rInSum, gInSum, bInSum, aInSum, pr, pg, pb, pa, rbs;\n var div = 2 * radius + 1; // const w4 = width << 2;\n\n var widthMinus1 = width - 1;\n var heightMinus1 = height - 1;\n var radiusPlus1 = radius + 1;\n var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;\n var stackStart = new BlurStack();\n var stack = stackStart;\n var stackEnd;\n\n for (i = 1; i < div; i++) {\n stack = stack.next = new BlurStack();\n\n if (i === radiusPlus1) {\n stackEnd = stack;\n }\n }\n\n stack.next = stackStart;\n var stackIn = null;\n var stackOut = null;\n yw = yi = 0;\n var mulSum = mulTable[radius];\n var shgSum = shgTable[radius];\n\n for (y = 0; y < height; y++) {\n rInSum = gInSum = bInSum = aInSum = rSum = gSum = bSum = aSum = 0;\n rOutSum = radiusPlus1 * (pr = pixels[yi]);\n gOutSum = radiusPlus1 * (pg = pixels[yi + 1]);\n bOutSum = radiusPlus1 * (pb = pixels[yi + 2]);\n aOutSum = radiusPlus1 * (pa = pixels[yi + 3]);\n rSum += sumFactor * pr;\n gSum += sumFactor * pg;\n bSum += sumFactor * pb;\n aSum += sumFactor * pa;\n stack = stackStart;\n\n for (i = 0; i < radiusPlus1; i++) {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack.a = pa;\n stack = stack.next;\n }\n\n for (i = 1; i < radiusPlus1; i++) {\n p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);\n rSum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - i);\n gSum += (stack.g = pg = pixels[p + 1]) * rbs;\n bSum += (stack.b = pb = pixels[p + 2]) * rbs;\n aSum += (stack.a = pa = pixels[p + 3]) * rbs;\n rInSum += pr;\n gInSum += pg;\n bInSum += pb;\n aInSum += pa;\n stack = stack.next;\n }\n\n stackIn = stackStart;\n stackOut = stackEnd;\n\n for (x = 0; x < width; x++) {\n pixels[yi + 3] = pa = aSum * mulSum >> shgSum;\n\n if (pa !== 0) {\n pa = 255 / pa;\n pixels[yi] = (rSum * mulSum >> shgSum) * pa;\n pixels[yi + 1] = (gSum * mulSum >> shgSum) * pa;\n pixels[yi + 2] = (bSum * mulSum >> shgSum) * pa;\n } else {\n pixels[yi] = pixels[yi + 1] = pixels[yi + 2] = 0;\n }\n\n rSum -= rOutSum;\n gSum -= gOutSum;\n bSum -= bOutSum;\n aSum -= aOutSum;\n rOutSum -= stackIn.r;\n gOutSum -= stackIn.g;\n bOutSum -= stackIn.b;\n aOutSum -= stackIn.a;\n p = yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1) << 2;\n rInSum += stackIn.r = pixels[p];\n gInSum += stackIn.g = pixels[p + 1];\n bInSum += stackIn.b = pixels[p + 2];\n aInSum += stackIn.a = pixels[p + 3];\n rSum += rInSum;\n gSum += gInSum;\n bSum += bInSum;\n aSum += aInSum;\n stackIn = stackIn.next;\n rOutSum += pr = stackOut.r;\n gOutSum += pg = stackOut.g;\n bOutSum += pb = stackOut.b;\n aOutSum += pa = stackOut.a;\n rInSum -= pr;\n gInSum -= pg;\n bInSum -= pb;\n aInSum -= pa;\n stackOut = stackOut.next;\n yi += 4;\n }\n\n yw += width;\n }\n\n for (x = 0; x < width; x++) {\n gInSum = bInSum = aInSum = rInSum = gSum = bSum = aSum = rSum = 0;\n yi = x << 2;\n rOutSum = radiusPlus1 * (pr = pixels[yi]);\n gOutSum = radiusPlus1 * (pg = pixels[yi + 1]);\n bOutSum = radiusPlus1 * (pb = pixels[yi + 2]);\n aOutSum = radiusPlus1 * (pa = pixels[yi + 3]);\n rSum += sumFactor * pr;\n gSum += sumFactor * pg;\n bSum += sumFactor * pb;\n aSum += sumFactor * pa;\n stack = stackStart;\n\n for (i = 0; i < radiusPlus1; i++) {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack.a = pa;\n stack = stack.next;\n }\n\n yp = width;\n\n for (i = 1; i <= radius; i++) {\n yi = yp + x << 2;\n rSum += (stack.r = pr = pixels[yi]) * (rbs = radiusPlus1 - i);\n gSum += (stack.g = pg = pixels[yi + 1]) * rbs;\n bSum += (stack.b = pb = pixels[yi + 2]) * rbs;\n aSum += (stack.a = pa = pixels[yi + 3]) * rbs;\n rInSum += pr;\n gInSum += pg;\n bInSum += pb;\n aInSum += pa;\n stack = stack.next;\n\n if (i < heightMinus1) {\n yp += width;\n }\n }\n\n yi = x;\n stackIn = stackStart;\n stackOut = stackEnd;\n\n for (y = 0; y < height; y++) {\n p = yi << 2;\n pixels[p + 3] = pa = aSum * mulSum >> shgSum;\n\n if (pa > 0) {\n pa = 255 / pa;\n pixels[p] = (rSum * mulSum >> shgSum) * pa;\n pixels[p + 1] = (gSum * mulSum >> shgSum) * pa;\n pixels[p + 2] = (bSum * mulSum >> shgSum) * pa;\n } else {\n pixels[p] = pixels[p + 1] = pixels[p + 2] = 0;\n }\n\n rSum -= rOutSum;\n gSum -= gOutSum;\n bSum -= bOutSum;\n aSum -= aOutSum;\n rOutSum -= stackIn.r;\n gOutSum -= stackIn.g;\n bOutSum -= stackIn.b;\n aOutSum -= stackIn.a;\n p = x + ((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width << 2;\n rSum += rInSum += stackIn.r = pixels[p];\n gSum += gInSum += stackIn.g = pixels[p + 1];\n bSum += bInSum += stackIn.b = pixels[p + 2];\n aSum += aInSum += stackIn.a = pixels[p + 3];\n stackIn = stackIn.next;\n rOutSum += pr = stackOut.r;\n gOutSum += pg = stackOut.g;\n bOutSum += pb = stackOut.b;\n aOutSum += pa = stackOut.a;\n rInSum -= pr;\n gInSum -= pg;\n bInSum -= pb;\n aInSum -= pa;\n stackOut = stackOut.next;\n yi += width;\n }\n }\n\n return imageData;\n}\n/**\n * @param {HTMLCanvasElement} canvas\n * @param {Integer} topX\n * @param {Integer} topY\n * @param {Integer} width\n * @param {Integer} height\n * @param {Float} radius\n * @returns {undefined}\n */\n\n\nfunction processCanvasRGB(canvas, topX, topY, width, height, radius) {\n if (isNaN(radius) || radius < 1) {\n return;\n }\n\n radius |= 0;\n var imageData = getImageDataFromCanvas(canvas, topX, topY, width, height);\n imageData = processImageDataRGB(imageData, topX, topY, width, height, radius);\n canvas.getContext('2d').putImageData(imageData, topX, topY);\n}\n/**\n * @param {ImageData} imageData\n * @param {Integer} topX\n * @param {Integer} topY\n * @param {Integer} width\n * @param {Integer} height\n * @param {Float} radius\n * @returns {ImageData}\n */\n\n\nfunction processImageDataRGB(imageData, topX, topY, width, height, radius) {\n var pixels = imageData.data;\n var x, y, i, p, yp, yi, yw, rSum, gSum, bSum, rOutSum, gOutSum, bOutSum, rInSum, gInSum, bInSum, pr, pg, pb, rbs;\n var div = 2 * radius + 1; // const w4 = width << 2;\n\n var widthMinus1 = width - 1;\n var heightMinus1 = height - 1;\n var radiusPlus1 = radius + 1;\n var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;\n var stackStart = new BlurStack();\n var stack = stackStart;\n var stackEnd;\n\n for (i = 1; i < div; i++) {\n stack = stack.next = new BlurStack();\n\n if (i === radiusPlus1) {\n stackEnd = stack;\n }\n }\n\n stack.next = stackStart;\n var stackIn = null;\n var stackOut = null;\n yw = yi = 0;\n var mulSum = mulTable[radius];\n var shgSum = shgTable[radius];\n\n for (y = 0; y < height; y++) {\n rInSum = gInSum = bInSum = rSum = gSum = bSum = 0;\n rOutSum = radiusPlus1 * (pr = pixels[yi]);\n gOutSum = radiusPlus1 * (pg = pixels[yi + 1]);\n bOutSum = radiusPlus1 * (pb = pixels[yi + 2]);\n rSum += sumFactor * pr;\n gSum += sumFactor * pg;\n bSum += sumFactor * pb;\n stack = stackStart;\n\n for (i = 0; i < radiusPlus1; i++) {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack = stack.next;\n }\n\n for (i = 1; i < radiusPlus1; i++) {\n p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);\n rSum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - i);\n gSum += (stack.g = pg = pixels[p + 1]) * rbs;\n bSum += (stack.b = pb = pixels[p + 2]) * rbs;\n rInSum += pr;\n gInSum += pg;\n bInSum += pb;\n stack = stack.next;\n }\n\n stackIn = stackStart;\n stackOut = stackEnd;\n\n for (x = 0; x < width; x++) {\n pixels[yi] = rSum * mulSum >> shgSum;\n pixels[yi + 1] = gSum * mulSum >> shgSum;\n pixels[yi + 2] = bSum * mulSum >> shgSum;\n rSum -= rOutSum;\n gSum -= gOutSum;\n bSum -= bOutSum;\n rOutSum -= stackIn.r;\n gOutSum -= stackIn.g;\n bOutSum -= stackIn.b;\n p = yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1) << 2;\n rInSum += stackIn.r = pixels[p];\n gInSum += stackIn.g = pixels[p + 1];\n bInSum += stackIn.b = pixels[p + 2];\n rSum += rInSum;\n gSum += gInSum;\n bSum += bInSum;\n stackIn = stackIn.next;\n rOutSum += pr = stackOut.r;\n gOutSum += pg = stackOut.g;\n bOutSum += pb = stackOut.b;\n rInSum -= pr;\n gInSum -= pg;\n bInSum -= pb;\n stackOut = stackOut.next;\n yi += 4;\n }\n\n yw += width;\n }\n\n for (x = 0; x < width; x++) {\n gInSum = bInSum = rInSum = gSum = bSum = rSum = 0;\n yi = x << 2;\n rOutSum = radiusPlus1 * (pr = pixels[yi]);\n gOutSum = radiusPlus1 * (pg = pixels[yi + 1]);\n bOutSum = radiusPlus1 * (pb = pixels[yi + 2]);\n rSum += sumFactor * pr;\n gSum += sumFactor * pg;\n bSum += sumFactor * pb;\n stack = stackStart;\n\n for (i = 0; i < radiusPlus1; i++) {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack = stack.next;\n }\n\n yp = width;\n\n for (i = 1; i <= radius; i++) {\n yi = yp + x << 2;\n rSum += (stack.r = pr = pixels[yi]) * (rbs = radiusPlus1 - i);\n gSum += (stack.g = pg = pixels[yi + 1]) * rbs;\n bSum += (stack.b = pb = pixels[yi + 2]) * rbs;\n rInSum += pr;\n gInSum += pg;\n bInSum += pb;\n stack = stack.next;\n\n if (i < heightMinus1) {\n yp += width;\n }\n }\n\n yi = x;\n stackIn = stackStart;\n stackOut = stackEnd;\n\n for (y = 0; y < height; y++) {\n p = yi << 2;\n pixels[p] = rSum * mulSum >> shgSum;\n pixels[p + 1] = gSum * mulSum >> shgSum;\n pixels[p + 2] = bSum * mulSum >> shgSum;\n rSum -= rOutSum;\n gSum -= gOutSum;\n bSum -= bOutSum;\n rOutSum -= stackIn.r;\n gOutSum -= stackIn.g;\n bOutSum -= stackIn.b;\n p = x + ((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width << 2;\n rSum += rInSum += stackIn.r = pixels[p];\n gSum += gInSum += stackIn.g = pixels[p + 1];\n bSum += bInSum += stackIn.b = pixels[p + 2];\n stackIn = stackIn.next;\n rOutSum += pr = stackOut.r;\n gOutSum += pg = stackOut.g;\n bOutSum += pb = stackOut.b;\n rInSum -= pr;\n gInSum -= pg;\n bInSum -= pb;\n stackOut = stackOut.next;\n yi += width;\n }\n }\n\n return imageData;\n}\n/**\n *\n */\n\n\nvar BlurStack =\n/**\n * Set properties.\n */\nfunction BlurStack() {\n _classCallCheck(this, BlurStack);\n\n this.r = 0;\n this.g = 0;\n this.b = 0;\n this.a = 0;\n this.next = null;\n};\n\nexport { BlurStack, processCanvasRGB as canvasRGB, processCanvasRGBA as canvasRGBA, processImage as image, processImageDataRGB as imageDataRGB, processImageDataRGBA as imageDataRGBA };\n","/* eslint-disable new-cap, class-methods-use-this, jsdoc/require-jsdoc */\n// Todo: Compare with latest canvg (add any improvements of ours) and add full JSDocs (denoting links to standard APIs and which are custom): https://github.com/canvg/canvg\n/**\n * Javascript SVG parser and renderer on Canvas.\n * @file canvg.js\n * @module canvg\n * @license MIT\n * @author Gabe Lerner <gabelerner@gmail.com>\n * @see https://github.com/canvg/canvg\n */\n\nimport RGBColor from './rgbcolor.js';\nimport {canvasRGBA} from '../../external/stackblur-canvas/dist/stackblur-es.js';\n\n/**\n * Whether a value is `null` or `undefined`.\n * @param {any} val\n * @returns {boolean}\n */\nconst isNullish = (val) => {\n return val === null || val === undefined;\n};\n\n/**\n* @callback module:canvg.ForceRedraw\n* @returns {boolean}\n*/\n\n/**\n* @typedef {PlainObject} module:canvg.CanvgOptions\n* @property {boolean} ignoreMouse true => ignore mouse events\n* @property {boolean} ignoreAnimation true => ignore animations\n* @property {boolean} ignoreDimensions true => does not try to resize canvas\n* @property {boolean} ignoreClear true => does not clear canvas\n* @property {Integer} offsetX int => draws at a x offset\n* @property {Integer} offsetY int => draws at a y offset\n* @property {Integer} scaleWidth int => scales horizontally to width\n* @property {Integer} scaleHeight int => scales vertically to height\n* @property {module:canvg.ForceRedraw} forceRedraw function => will call the function on every frame, if it returns true, will redraw\n* @property {boolean} log Adds log function\n* @property {boolean} useCORS Whether to set CORS `crossOrigin` for the image to `Anonymous`\n*/\n\n/**\n* If called with no arguments, it will replace all `<svg>` elements on the page\n* with `<canvas>` elements.\n* @function module:canvg.canvg\n* @param {HTMLCanvasElement|string} target canvas element or the id of a canvas element\n* @param {string|XMLDocument} s - svg string, url to svg file, or xml document\n* @param {module:canvg.CanvgOptions} [opts] Optional hash of options\n* @returns {Promise<XMLDocument|XMLDocument[]>} All the function after the first render is completed with dom\n*/\nexport const canvg = function (target, s, opts) {\n // no parameters\n if (isNullish(target) && isNullish(s) && isNullish(opts)) {\n const svgTags = document.querySelectorAll('svg');\n return Promise.all([...svgTags].map((svgTag) => {\n const c = document.createElement('canvas');\n c.width = svgTag.clientWidth;\n c.height = svgTag.clientHeight;\n svgTag.before(c);\n svgTag.remove();\n const div = document.createElement('div');\n div.append(svgTag);\n return canvg(c, div.innerHTML);\n }));\n }\n\n if (typeof target === 'string') {\n target = document.getElementById(target);\n }\n\n // store class on canvas\n if (!isNullish(target.svg)) target.svg.stop();\n const svg = build(opts || {});\n // on i.e. 8 for flash canvas, we can't assign the property so check for it\n if (!(target.childNodes.length === 1 && target.childNodes[0].nodeName === 'OBJECT')) {\n target.svg = svg;\n }\n\n const ctx = target.getContext('2d');\n if (typeof s.documentElement !== 'undefined') {\n // load from xml doc\n return svg.loadXmlDoc(ctx, s);\n }\n if (s.substr(0, 1) === '<') {\n // load from xml string\n return svg.loadXml(ctx, s);\n }\n // load from url\n return svg.load(ctx, s);\n};\n\n/* eslint-disable jsdoc/check-types */\n/**\n* @param {module:canvg.CanvgOptions} opts\n* @returns {object}\n* @todo Flesh out exactly what object is returned here (after updating to latest and reincluding our changes here and those of StackBlur)\n*/\nfunction build (opts) {\n /* eslint-enable jsdoc/check-types */\n const svg = {opts};\n\n svg.FRAMERATE = 30;\n svg.MAX_VIRTUAL_PIXELS = 30000;\n\n svg.log = function (msg) { /* */ };\n if (svg.opts.log === true && typeof console !== 'undefined') {\n svg.log = function (msg) { console.log(msg); }; // eslint-disable-line no-console\n }\n\n // globals\n svg.init = function (ctx) {\n let uniqueId = 0;\n svg.UniqueId = function () {\n uniqueId++;\n return 'canvg' + uniqueId;\n };\n svg.Definitions = {};\n svg.Styles = {};\n svg.Animations = [];\n svg.Images = [];\n svg.ctx = ctx;\n svg.ViewPort = {\n viewPorts: [],\n Clear () { this.viewPorts = []; },\n SetCurrent (width, height) { this.viewPorts.push({width, height}); },\n RemoveCurrent () { this.viewPorts.pop(); },\n Current () { return this.viewPorts[this.viewPorts.length - 1]; },\n width () { return this.Current().width; },\n height () { return this.Current().height; },\n ComputeSize (d) {\n if (!isNullish(d) && typeof d === 'number') return d;\n if (d === 'x') return this.width();\n if (d === 'y') return this.height();\n return Math.sqrt(\n (this.width() ** 2) + (this.height() ** 2)\n ) / Math.sqrt(2);\n }\n };\n };\n svg.init();\n\n // images loaded\n svg.ImagesLoaded = function () {\n return svg.Images.every((img) => img.loaded);\n };\n\n // trim\n svg.trim = function (s) {\n return s.replace(/^\\s+|\\s+$/g, '');\n };\n\n // compress spaces\n svg.compressSpaces = function (s) {\n return s.replace(/\\s+/gm, ' ');\n };\n\n // ajax\n // Todo: Replace with `fetch` and polyfill\n svg.ajax = function (url, asynch) {\n const AJAX = window.XMLHttpRequest\n ? new XMLHttpRequest()\n : new window.ActiveXObject('Microsoft.XMLHTTP');\n if (asynch) {\n return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new\n const req = AJAX.open('GET', url, true);\n req.addEventListener('load', () => {\n resolve(AJAX.responseText);\n });\n AJAX.send(null);\n });\n }\n\n AJAX.open('GET', url, false);\n AJAX.send(null);\n return AJAX.responseText;\n };\n\n // parse xml\n svg.parseXml = function (xml) {\n if (window.DOMParser) {\n const parser = new DOMParser();\n return parser.parseFromString(xml, 'text/xml');\n }\n xml = xml.replace(/<!DOCTYPE svg[^>]*>/, '');\n const xmlDoc = new window.ActiveXObject('Microsoft.XMLDOM');\n xmlDoc.async = 'false';\n xmlDoc.loadXML(xml);\n return xmlDoc;\n };\n\n // text extensions\n // get the text baseline\n const textBaselineMapping = {\n baseline: 'alphabetic',\n 'before-edge': 'top',\n 'text-before-edge': 'top',\n middle: 'middle',\n central: 'middle',\n 'after-edge': 'bottom',\n 'text-after-edge': 'bottom',\n ideographic: 'ideographic',\n alphabetic: 'alphabetic',\n hanging: 'hanging',\n mathematical: 'alphabetic'\n };\n\n svg.Property = class Property {\n constructor (name, value) {\n this.name = name;\n this.value = value;\n }\n\n getValue () {\n return this.value;\n }\n\n hasValue () {\n return (!isNullish(this.value) && this.value !== '');\n }\n\n // return the numerical value of the property\n numValue () {\n if (!this.hasValue()) return 0;\n\n let n = Number.parseFloat(this.value);\n if (String(this.value).endsWith('%')) {\n n /= 100.0;\n }\n return n;\n }\n\n valueOrDefault (def) {\n if (this.hasValue()) return this.value;\n return def;\n }\n\n numValueOrDefault (def) {\n if (this.hasValue()) return this.numValue();\n return def;\n }\n\n // color extensions\n // augment the current color value with the opacity\n addOpacity (opacityProp) {\n let newValue = this.value;\n if (!isNullish(opacityProp.value) && opacityProp.value !== '' && typeof this.value === 'string') { // can only add opacity to colors, not patterns\n const color = new RGBColor(this.value);\n if (color.ok) {\n newValue = 'rgba(' + color.r + ', ' + color.g + ', ' + color.b + ', ' + opacityProp.numValue() + ')';\n }\n }\n return new svg.Property(this.name, newValue);\n }\n\n // definition extensions\n // get the definition from the definitions table\n getDefinition () {\n let name = this.value.match(/#([^)'\"]+)/);\n if (name) { name = name[1]; }\n if (!name) { name = this.value; }\n return svg.Definitions[name];\n }\n\n isUrlDefinition () {\n return this.value.startsWith('url(');\n }\n\n getFillStyleDefinition (e, opacityProp) {\n let def = this.getDefinition();\n\n // gradient\n if (!isNullish(def) && def.createGradient) {\n return def.createGradient(svg.ctx, e, opacityProp);\n }\n\n // pattern\n if (!isNullish(def) && def.createPattern) {\n if (def.getHrefAttribute().hasValue()) {\n const pt = def.attribute('patternTransform');\n def = def.getHrefAttribute().getDefinition();\n if (pt.hasValue()) { def.attribute('patternTransform', true).value = pt.value; }\n }\n return def.createPattern(svg.ctx, e);\n }\n\n return null;\n }\n\n // length extensions\n getDPI (viewPort) {\n return 96.0; // TODO: compute?\n }\n\n getEM (viewPort) {\n let em = 12;\n\n const fontSize = new svg.Property('fontSize', svg.Font.Parse(svg.ctx.font).fontSize);\n if (fontSize.hasValue()) em = fontSize.toPixels(viewPort);\n\n return em;\n }\n\n getUnits () {\n return String(this.value).replace(/[\\d.-]/g, '');\n }\n\n // get the length as pixels\n toPixels (viewPort, processPercent) {\n if (!this.hasValue()) return 0;\n const s = String(this.value);\n if (s.endsWith('em')) return this.numValue() * this.getEM(viewPort);\n if (s.endsWith('ex')) return this.numValue() * this.getEM(viewPort) / 2.0;\n if (s.endsWith('px')) return this.numValue();\n if (s.endsWith('pt')) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);\n if (s.endsWith('pc')) return this.numValue() * 15;\n if (s.endsWith('cm')) return this.numValue() * this.getDPI(viewPort) / 2.54;\n if (s.endsWith('mm')) return this.numValue() * this.getDPI(viewPort) / 25.4;\n if (s.endsWith('in')) return this.numValue() * this.getDPI(viewPort);\n if (s.endsWith('%')) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);\n const n = this.numValue();\n if (processPercent && n < 1.0) return n * svg.ViewPort.ComputeSize(viewPort);\n return n;\n }\n\n // time extensions\n // get the time as milliseconds\n toMilliseconds () {\n if (!this.hasValue()) return 0;\n const s = String(this.value);\n if (s.endsWith('ms')) return this.numValue();\n if (s.endsWith('s')) return this.numValue() * 1000;\n return this.numValue();\n }\n\n // angle extensions\n // get the angle as radians\n toRadians () {\n if (!this.hasValue()) return 0;\n const s = String(this.value);\n if (s.endsWith('deg')) return this.numValue() * (Math.PI / 180.0);\n if (s.endsWith('grad')) return this.numValue() * (Math.PI / 200.0);\n if (s.endsWith('rad')) return this.numValue();\n return this.numValue() * (Math.PI / 180.0);\n }\n\n toTextBaseline () {\n if (!this.hasValue()) return null;\n return textBaselineMapping[this.value];\n }\n };\n\n // fonts\n svg.Font = {\n Styles: 'normal|italic|oblique|inherit',\n Variants: 'normal|small-caps|inherit',\n Weights: 'normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit',\n\n CreateFont (fontStyle, fontVariant, fontWeight, fontSize, fontFamily, inherit) {\n const f = !isNullish(inherit) ? this.Parse(inherit) : this.CreateFont('', '', '', '', '', svg.ctx.font);\n return {\n fontFamily: fontFamily || f.fontFamily,\n fontSize: fontSize || f.fontSize,\n fontStyle: fontStyle || f.fontStyle,\n fontWeight: fontWeight || f.fontWeight,\n fontVariant: fontVariant || f.fontVariant,\n toString () {\n return [\n this.fontStyle, this.fontVariant, this.fontWeight,\n this.fontSize, this.fontFamily\n ].join(' ');\n }\n };\n },\n\n Parse (s) {\n const f = {};\n const ds = svg.trim(svg.compressSpaces(s || '')).split(' ');\n const set = {\n fontSize: false, fontStyle: false, fontWeight: false, fontVariant: false\n };\n let ff = '';\n ds.forEach((d) => {\n if (!set.fontStyle && this.Styles.includes(d)) {\n if (d !== 'inherit') {\n f.fontStyle = d;\n }\n set.fontStyle = true;\n } else if (!set.fontVariant && this.Variants.includes(d)) {\n if (d !== 'inherit') {\n f.fontVariant = d;\n }\n set.fontStyle = set.fontVariant = true;\n } else if (!set.fontWeight && this.Weights.includes(d)) {\n if (d !== 'inherit') {\n f.fontWeight = d;\n }\n set.fontStyle = set.fontVariant = set.fontWeight = true;\n } else if (!set.fontSize) {\n if (d !== 'inherit') {\n f.fontSize = d.split('/')[0];\n }\n set.fontStyle = set.fontVariant = set.fontWeight = set.fontSize = true;\n } else if (d !== 'inherit') {\n ff += d;\n }\n });\n if (ff !== '') { f.fontFamily = ff; }\n return f;\n }\n };\n\n // points and paths\n svg.ToNumberArray = function (s) {\n const a = svg.trim(svg.compressSpaces((s || '').replace(/,/g, ' '))).split(' ');\n return a.map((_a) => Number.parseFloat(_a));\n };\n svg.Point = class {\n constructor (x, y) {\n this.x = x;\n this.y = y;\n }\n\n angleTo (p) {\n return Math.atan2(p.y - this.y, p.x - this.x);\n }\n\n applyTransform (v) {\n const xp = this.x * v[0] + this.y * v[2] + v[4];\n const yp = this.x * v[1] + this.y * v[3] + v[5];\n this.x = xp;\n this.y = yp;\n }\n };\n\n svg.CreatePoint = function (s) {\n const a = svg.ToNumberArray(s);\n return new svg.Point(a[0], a[1]);\n };\n svg.CreatePath = function (s) {\n const a = svg.ToNumberArray(s);\n const path = [];\n for (let i = 0; i < a.length; i += 2) {\n path.push(new svg.Point(a[i], a[i + 1]));\n }\n return path;\n };\n\n // bounding box\n svg.BoundingBox = class {\n constructor (x1, y1, x2, y2) { // pass in initial points if you want\n this.x1 = Number.NaN;\n this.y1 = Number.NaN;\n this.x2 = Number.NaN;\n this.y2 = Number.NaN;\n this.addPoint(x1, y1);\n this.addPoint(x2, y2);\n }\n\n x () { return this.x1; }\n y () { return this.y1; }\n width () { return this.x2 - this.x1; }\n height () { return this.y2 - this.y1; }\n\n addPoint (x, y) {\n if (!isNullish(x)) {\n if (isNaN(this.x1) || isNaN(this.x2)) {\n this.x1 = x;\n this.x2 = x;\n }\n if (x < this.x1) this.x1 = x;\n if (x > this.x2) this.x2 = x;\n }\n\n if (!isNullish(y)) {\n if (isNaN(this.y1) || isNaN(this.y2)) {\n this.y1 = y;\n this.y2 = y;\n }\n if (y < this.y1) this.y1 = y;\n if (y > this.y2) this.y2 = y;\n }\n }\n addX (x) { this.addPoint(x, null); }\n addY (y) { this.addPoint(null, y); }\n\n addBoundingBox (bb) {\n this.addPoint(bb.x1, bb.y1);\n this.addPoint(bb.x2, bb.y2);\n }\n\n addQuadraticCurve (p0x, p0y, p1x, p1y, p2x, p2y) {\n const cp1x = p0x + 2 / 3 * (p1x - p0x); // CP1 = QP0 + 2/3 *(QP1-QP0)\n const cp1y = p0y + 2 / 3 * (p1y - p0y); // CP1 = QP0 + 2/3 *(QP1-QP0)\n const cp2x = cp1x + 1 / 3 * (p2x - p0x); // CP2 = CP1 + 1/3 *(QP2-QP0)\n const cp2y = cp1y + 1 / 3 * (p2y - p0y); // CP2 = CP1 + 1/3 *(QP2-QP0)\n this.addBezierCurve(p0x, p0y, cp1x, cp2x, cp1y, cp2y, p2x, p2y);\n }\n\n addBezierCurve (p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) {\n // from http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html\n const p0 = [p0x, p0y], p1 = [p1x, p1y], p2 = [p2x, p2y], p3 = [p3x, p3y];\n this.addPoint(p0[0], p0[1]);\n this.addPoint(p3[0], p3[1]);\n\n for (let i = 0; i <= 1; i++) {\n const f = function (t) {\n return ((1 - t) ** 3) * p0[i] +\n 3 * ((1 - t) ** 2) * t * p1[i] +\n 3 * (1 - t) * (t ** 2) * p2[i] +\n (t ** 3) * p3[i];\n };\n\n const b = 6 * p0[i] - 12 * p1[i] + 6 * p2[i];\n const a = -3 * p0[i] + 9 * p1[i] - 9 * p2[i] + 3 * p3[i];\n const c = 3 * p1[i] - 3 * p0[i];\n\n if (a === 0) {\n if (b === 0) continue;\n const t = -c / b;\n if (t > 0 && t < 1) {\n if (i === 0) this.addX(f(t));\n if (i === 1) this.addY(f(t));\n }\n continue;\n }\n\n const b2ac = (b ** 2) - 4 * c * a;\n if (b2ac < 0) continue;\n const t1 = (-b + Math.sqrt(b2ac)) / (2 * a);\n if (t1 > 0 && t1 < 1) {\n if (i === 0) this.addX(f(t1));\n if (i === 1) this.addY(f(t1));\n }\n const t2 = (-b - Math.sqrt(b2ac)) / (2 * a);\n if (t2 > 0 && t2 < 1) {\n if (i === 0) this.addX(f(t2));\n if (i === 1) this.addY(f(t2));\n }\n }\n }\n\n isPointInBox (x, y) {\n return (this.x1 <= x && x <= this.x2 && this.y1 <= y && y <= this.y2);\n }\n };\n\n // transforms\n svg.Transform = class {\n constructor (v) {\n this.Type = {\n translate: class {\n constructor (s) {\n this.p = svg.CreatePoint(s);\n this.apply = function (ctx) {\n ctx.translate(this.p.x || 0.0, this.p.y || 0.0);\n };\n this.unapply = function (ctx) {\n ctx.translate(-1.0 * this.p.x || 0.0, -1.0 * this.p.y || 0.0);\n };\n this.applyToPoint = function (p) {\n p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]);\n };\n }\n },\n rotate: class {\n constructor (s) {\n const a = svg.ToNumberArray(s);\n this.angle = new svg.Property('angle', a[0]);\n this.cx = a[1] || 0;\n this.cy = a[2] || 0;\n this.apply = function (ctx) {\n ctx.translate(this.cx, this.cy);\n ctx.rotate(this.angle.toRadians());\n ctx.translate(-this.cx, -this.cy);\n };\n this.unapply = function (ctx) {\n ctx.translate(this.cx, this.cy);\n ctx.rotate(-1.0 * this.angle.toRadians());\n ctx.translate(-this.cx, -this.cy);\n };\n this.applyToPoint = function (p) {\n const _a = this.angle.toRadians();\n p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]);\n p.applyTransform([Math.cos(_a), Math.sin(_a), -Math.sin(_a), Math.cos(_a), 0, 0]);\n p.applyTransform([1, 0, 0, 1, -this.p.x || 0.0, -this.p.y || 0.0]);\n };\n }\n },\n scale: class {\n constructor (s) {\n this.p = svg.CreatePoint(s);\n this.apply = function (ctx) {\n ctx.scale(this.p.x || 1.0, this.p.y || this.p.x || 1.0);\n };\n this.unapply = function (ctx) {\n ctx.scale(1.0 / this.p.x || 1.0, 1.0 / this.p.y || this.p.x || 1.0);\n };\n this.applyToPoint = function (p) {\n p.applyTransform([this.p.x || 0.0, 0, 0, this.p.y || 0.0, 0, 0]);\n };\n }\n },\n matrix: class {\n constructor (s) {\n this.m = svg.ToNumberArray(s);\n this.apply = function (ctx) {\n ctx.transform(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5]);\n };\n this.applyToPoint = function (p) {\n p.applyTransform(this.m);\n };\n }\n }\n };\n Object.assign(this.Type, {\n SkewBase: class extends this.Type.matrix {\n constructor (s) {\n super(s);\n this.angle = new svg.Property('angle', s);\n }\n }\n });\n Object.assign(this.Type, {\n skewX: class extends this.Type.SkewBase {\n constructor (s) {\n super(s);\n this.m = [1, 0, Math.tan(this.angle.toRadians()), 1, 0, 0];\n }\n },\n skewY: class extends this.Type.SkewBase {\n constructor (s) {\n super(s);\n this.m = [1, Math.tan(this.angle.toRadians()), 0, 1, 0, 0];\n }\n }\n });\n\n const data = svg.trim(svg.compressSpaces(v)).replace(\n /\\)([a-zA-Z])/g, ') $1'\n ).replace(/\\)(\\s?,\\s?)/g, ') ').split(/\\s(?=[a-z])/);\n this.transforms = data.map((d) => {\n const type = svg.trim(d.split('(')[0]);\n const s = d.split('(')[1].replace(')', '');\n const transform = new this.Type[type](s);\n transform.type = type;\n return transform;\n });\n }\n\n apply (ctx) {\n this.transforms.forEach((transform) => {\n transform.apply(ctx);\n });\n }\n\n unapply (ctx) {\n for (let i = this.transforms.length - 1; i >= 0; i--) {\n this.transforms[i].unapply(ctx);\n }\n }\n\n applyToPoint (p) {\n this.transforms.forEach((transform) => {\n transform.applyToPoint(p);\n });\n }\n };\n\n // aspect ratio\n svg.AspectRatio = function (ctx, aspectRatio, width, desiredWidth, height, desiredHeight, minX, minY, refX, refY) {\n // aspect ratio - https://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute\n aspectRatio = svg.compressSpaces(aspectRatio);\n aspectRatio = aspectRatio.replace(/^defer\\s/, ''); // ignore defer\n const align = aspectRatio.split(' ')[0] || 'xMidYMid';\n const meetOrSlice = aspectRatio.split(' ')[1] || 'meet';\n\n // calculate scale\n const scaleX = width / desiredWidth;\n const scaleY = height / desiredHeight;\n const scaleMin = Math.min(scaleX, scaleY);\n const scaleMax = Math.max(scaleX, scaleY);\n if (meetOrSlice === 'meet') { desiredWidth *= scaleMin; desiredHeight *= scaleMin; }\n if (meetOrSlice === 'slice') { desiredWidth *= scaleMax; desiredHeight *= scaleMax; }\n\n refX = new svg.Property('refX', refX);\n refY = new svg.Property('refY', refY);\n if (refX.hasValue() && refY.hasValue()) {\n ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));\n } else {\n // align\n if (align.startsWith('xMid') &&\n ((meetOrSlice === 'meet' && scaleMin === scaleY) || (meetOrSlice === 'slice' && scaleMax === scaleY))) {\n ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);\n }\n if (align.endsWith('YMid') &&\n ((meetOrSlice === 'meet' && scaleMin === scaleX) || (meetOrSlice === 'slice' && scaleMax === scaleX))) {\n ctx.translate(0, height / 2.0 - desiredHeight / 2.0);\n }\n if (align.startsWith('xMax') &&\n ((meetOrSlice === 'meet' && scaleMin === scaleY) || (meetOrSlice === 'slice' && scaleMax === scaleY))) {\n ctx.translate(width - desiredWidth, 0);\n }\n if (align.endsWith('YMax') &&\n ((meetOrSlice === 'meet' && scaleMin === scaleX) ||\n (meetOrSlice === 'slice' && scaleMax === scaleX)\n )\n ) {\n ctx.translate(0, height - desiredHeight);\n }\n }\n\n // scale\n if (align === 'none') ctx.scale(scaleX, scaleY);\n else if (meetOrSlice === 'meet') ctx.scale(scaleMin, scaleMin);\n else if (meetOrSlice === 'slice') ctx.scale(scaleMax, scaleMax);\n\n // translate\n ctx.translate(isNullish(minX) ? 0 : -minX, isNullish(minY) ? 0 : -minY);\n };\n\n // elements\n svg.Element = {};\n\n svg.EmptyProperty = new svg.Property('EMPTY', '');\n\n svg.Element.ElementBase = class {\n constructor (node) {\n // Argument from inheriting class\n this.captureTextNodes = arguments[1]; // eslint-disable-line prefer-rest-params\n this.attributes = {};\n this.styles = {};\n this.children = [];\n if (!isNullish(node) && node.nodeType === 1) { // ELEMENT_NODE\n // add children\n [...node.childNodes].forEach((childNode) => {\n if (childNode.nodeType === 1) {\n this.addChild(childNode, true); // ELEMENT_NODE\n }\n if (this.captureTextNodes && (\n childNode.nodeType === 3 || childNode.nodeType === 4\n )) {\n const text = childNode.nodeValue || childNode.text || '';\n if (svg.trim(svg.compressSpaces(text)) !== '') {\n this.addChild(new svg.Element.tspan(childNode), false); // TEXT_NODE\n }\n }\n });\n\n // add attributes\n [...node.attributes].forEach(({nodeName, nodeValue}) => {\n this.attributes[nodeName] = new svg.Property(\n nodeName,\n nodeValue\n );\n });\n // add tag styles\n let styles = svg.Styles[node.nodeName];\n if (!isNullish(styles)) {\n Object.entries(styles).forEach(([name, styleValue]) => {\n this.styles[name] = styleValue;\n });\n }\n\n // add class styles\n if (this.attribute('class').hasValue()) {\n const classes = svg.compressSpaces(this.attribute('class').value).split(' ');\n classes.forEach((clss) => {\n styles = svg.Styles['.' + clss];\n if (!isNullish(styles)) {\n Object.entries(styles).forEach(([name, styleValue]) => {\n this.styles[name] = styleValue;\n });\n }\n styles = svg.Styles[node.nodeName + '.' + clss];\n if (!isNullish(styles)) {\n Object.entries(styles).forEach(([name, styleValue]) => {\n this.styles[name] = styleValue;\n });\n }\n });\n }\n\n // add id styles\n if (this.attribute('id').hasValue()) {\n const _styles = svg.Styles['#' + this.attribute('id').value];\n if (!isNullish(_styles)) {\n Object.entries(_styles).forEach(([name, styleValue]) => {\n this.styles[name] = styleValue;\n });\n }\n }\n\n // add inline styles\n if (this.attribute('style').hasValue()) {\n const _styles = this.attribute('style').value.split(';');\n _styles.forEach((style) => {\n if (svg.trim(style) !== '') {\n let {name, value} = style.split(':');\n name = svg.trim(name);\n value = svg.trim(value);\n this.styles[name] = new svg.Property(name, value);\n }\n });\n }\n\n // add id\n if (this.attribute('id').hasValue()) {\n if (isNullish(svg.Definitions[this.attribute('id').value])) {\n svg.Definitions[this.attribute('id').value] = this;\n }\n }\n }\n }\n\n // get or create attribute\n attribute (name, createIfNotExists) {\n let a = this.attributes[name];\n if (!isNullish(a)) return a;\n\n if (createIfNotExists === true) { a = new svg.Property(name, ''); this.attributes[name] = a; }\n return a || svg.EmptyProperty;\n }\n\n getHrefAttribute () {\n for (const a in this.attributes) {\n if (a.endsWith(':href')) {\n return this.attributes[a];\n }\n }\n return svg.EmptyProperty;\n }\n\n // get or create style, crawls up node tree\n style (name, createIfNotExists, skipAncestors) {\n let s = this.styles[name];\n if (!isNullish(s)) return s;\n\n const a = this.attribute(name);\n if (!isNullish(a) && a.hasValue()) {\n this.styles[name] = a; // move up to me to cache\n return a;\n }\n\n if (skipAncestors !== true) {\n const p = this.parent;\n if (!isNullish(p)) {\n const ps = p.style(name);\n if (!isNullish(ps) && ps.hasValue()) {\n return ps;\n }\n }\n }\n\n if (createIfNotExists === true) { s = new svg.Property(name, ''); this.styles[name] = s; }\n return s || svg.EmptyProperty;\n }\n\n // base render\n render (ctx) {\n // don't render display=none\n if (this.style('display').value === 'none') return;\n\n // don't render visibility=hidden\n if (this.style('visibility').value === 'hidden') return;\n\n ctx.save();\n if (this.attribute('mask').hasValue()) { // mask\n const mask = this.attribute('mask').getDefinition();\n if (!isNullish(mask)) mask.apply(ctx, this);\n } else if (this.style('filter').hasValue()) { // filter\n const filter = this.style('filter').getDefinition();\n if (!isNullish(filter)) filter.apply(ctx, this);\n } else {\n this.setContext(ctx);\n this.renderChildren(ctx);\n this.clearContext(ctx);\n }\n ctx.restore();\n }\n\n // base set context\n setContext (ctx) {\n // OVERRIDE ME!\n }\n\n // base clear context\n clearContext (ctx) {\n // OVERRIDE ME!\n }\n\n // base render children\n renderChildren (ctx) {\n this.children.forEach((child) => {\n child.render(ctx);\n });\n }\n\n addChild (childNode, create) {\n const child = create\n ? svg.CreateElement(childNode)\n : childNode;\n child.parent = this;\n if (child.type !== 'title') { this.children.push(child); }\n }\n };\n\n svg.Element.RenderedElementBase = class extends svg.Element.ElementBase {\n setContext (ctx) {\n // fill\n if (this.style('fill').isUrlDefinition()) {\n const fs = this.style('fill').getFillStyleDefinition(this, this.style('fill-opacity'));\n if (!isNullish(fs)) ctx.fillStyle = fs;\n } else if (this.style('fill').hasValue()) {\n const fillStyle = this.style('fill');\n if (fillStyle.value === 'currentColor') fillStyle.value = this.style('color').value;\n ctx.fillStyle = (fillStyle.value === 'none' ? 'rgba(0,0,0,0)' : fillStyle.value);\n }\n if (this.style('fill-opacity').hasValue()) {\n let fillStyle = new svg.Property('fill', ctx.fillStyle);\n fillStyle = fillStyle.addOpacity(this.style('fill-opacity'));\n ctx.fillStyle = fillStyle.value;\n }\n\n // stroke\n if (this.style('stroke').isUrlDefinition()) {\n const fs = this.style('stroke').getFillStyleDefinition(this, this.style('stroke-opacity'));\n if (!isNullish(fs)) ctx.strokeStyle = fs;\n } else if (this.style('stroke').hasValue()) {\n const strokeStyle = this.style('stroke');\n if (strokeStyle.value === 'currentColor') strokeStyle.value = this.style('color').value;\n ctx.strokeStyle = (strokeStyle.value === 'none' ? 'rgba(0,0,0,0)' : strokeStyle.value);\n }\n if (this.style('stroke-opacity').hasValue()) {\n let strokeStyle = new svg.Property('stroke', ctx.strokeStyle);\n strokeStyle = strokeStyle.addOpacity(this.style('stroke-opacity'));\n ctx.strokeStyle = strokeStyle.value;\n }\n if (this.style('stroke-width').hasValue()) {\n const newLineWidth = this.style('stroke-width').toPixels();\n ctx.lineWidth = newLineWidth === 0 ? 0.001 : newLineWidth; // browsers don't respect 0\n }\n if (this.style('stroke-linecap').hasValue()) ctx.lineCap = this.style('stroke-linecap').value;\n if (this.style('stroke-linejoin').hasValue()) ctx.lineJoin = this.style('stroke-linejoin').value;\n if (this.style('stroke-miterlimit').hasValue()) ctx.miterLimit = this.style('stroke-miterlimit').value;\n if (this.style('stroke-dasharray').hasValue() && this.style('stroke-dasharray').value !== 'none') {\n const gaps = svg.ToNumberArray(this.style('stroke-dasharray').value);\n if (typeof ctx.setLineDash !== 'undefined') {\n ctx.setLineDash(gaps);\n } else if (typeof ctx.webkitLineDash !== 'undefined') {\n ctx.webkitLineDash = gaps;\n } else if (typeof ctx.mozDash !== 'undefined' && !(gaps.length === 1 && gaps[0] === 0)) {\n ctx.mozDash = gaps;\n }\n\n const offset = this.style('stroke-dashoffset').numValueOrDefault(1);\n if (typeof ctx.lineDashOffset !== 'undefined') {\n ctx.lineDashOffset = offset;\n } else if (typeof ctx.webkitLineDashOffset !== 'undefined') {\n ctx.webkitLineDashOffset = offset;\n } else if (typeof ctx.mozDashOffset !== 'undefined') {\n ctx.mozDashOffset = offset;\n }\n }\n\n // font\n if (typeof ctx.font !== 'undefined') {\n ctx.font = svg.Font.CreateFont(\n this.style('font-style').value,\n this.style('font-variant').value,\n this.style('font-weight').value,\n this.style('font-size').hasValue() ? this.style('font-size').toPixels() + 'px' : '',\n this.style('font-family').value\n ).toString();\n }\n\n // transform\n if (this.attribute('transform').hasValue()) {\n const transform = new svg.Transform(this.attribute('transform').value);\n transform.apply(ctx);\n }\n\n // clip\n if (this.style('clip-path', false, true).hasValue()) {\n const clip = this.style('clip-path', false, true).getDefinition();\n if (!isNullish(clip)) clip.apply(ctx);\n }\n\n // opacity\n if (this.style('opacity').hasValue()) {\n ctx.globalAlpha = this.style('opacity').numValue();\n }\n }\n };\n\n svg.Element.PathElementBase = class extends svg.Element.RenderedElementBase {\n path (ctx) {\n if (!isNullish(ctx)) ctx.beginPath();\n return new svg.BoundingBox();\n }\n\n renderChildren (ctx) {\n this.path(ctx);\n svg.Mouse.checkPath(this, ctx);\n if (ctx.fillStyle !== '') {\n if (this.style('fill-rule').valueOrDefault('inherit') !== 'inherit') {\n ctx.fill(this.style('fill-rule').value);\n } else {\n ctx.fill();\n }\n }\n if (ctx.strokeStyle !== '') ctx.stroke();\n\n const markers = this.getMarkers();\n if (!isNullish(markers)) {\n if (this.style('marker-start').isUrlDefinition()) {\n const marker = this.style('marker-start').getDefinition();\n marker.render(ctx, markers[0][0], markers[0][1]);\n }\n if (this.style('marker-mid').isUrlDefinition()) {\n const marker = this.style('marker-mid').getDefinition();\n for (let i = 1; i < markers.length - 1; i++) {\n marker.render(ctx, markers[i][0], markers[i][1]);\n }\n }\n if (this.style('marker-end').isUrlDefinition()) {\n const marker = this.style('marker-end').getDefinition();\n marker.render(ctx, markers[markers.length - 1][0], markers[markers.length - 1][1]);\n }\n }\n }\n\n getBoundingBox () {\n return this.path();\n }\n\n getMarkers () {\n return null;\n }\n };\n\n // svg element\n svg.Element.svg = class extends svg.Element.RenderedElementBase {\n clearContext (ctx) {\n super.clearContext(ctx);\n svg.ViewPort.RemoveCurrent();\n }\n\n setContext (ctx) {\n // initial values and defaults\n ctx.strokeStyle = 'rgba(0,0,0,0)';\n ctx.lineCap = 'butt';\n ctx.lineJoin = 'miter';\n ctx.miterLimit = 4;\n if (typeof ctx.font !== 'undefined' && typeof window.getComputedStyle !== 'undefined') {\n ctx.font = window.getComputedStyle(ctx.canvas).getPropertyValue('font');\n }\n\n super.setContext(ctx);\n\n // create new view port\n if (!this.attribute('x').hasValue()) this.attribute('x', true).value = 0;\n if (!this.attribute('y').hasValue()) this.attribute('y', true).value = 0;\n ctx.translate(this.attribute('x').toPixels('x'), this.attribute('y').toPixels('y'));\n\n let width = svg.ViewPort.width();\n let height = svg.ViewPort.height();\n\n if (!this.attribute('width').hasValue()) this.attribute('width', true).value = '100%';\n if (!this.attribute('height').hasValue()) this.attribute('height', true).value = '100%';\n if (typeof this.root === 'undefined') {\n width = this.attribute('width').toPixels('x');\n height = this.attribute('height').toPixels('y');\n\n let x = 0;\n let y = 0;\n if (this.attribute('refX').hasValue() && this.attribute('refY').hasValue()) {\n x = -this.attribute('refX').toPixels('x');\n y = -this.attribute('refY').toPixels('y');\n }\n\n if (this.attribute('overflow').valueOrDefault('hidden') !== 'visible') {\n ctx.beginPath();\n ctx.moveTo(x, y);\n ctx.lineTo(width, y);\n ctx.lineTo(width, height);\n ctx.lineTo(x, height);\n ctx.closePath();\n ctx.clip();\n }\n }\n svg.ViewPort.SetCurrent(width, height);\n\n // viewbox\n if (this.attribute('viewBox').hasValue()) {\n const viewBox = svg.ToNumberArray(this.attribute('viewBox').value);\n const minX = viewBox[0];\n const minY = viewBox[1];\n width = viewBox[2];\n height = viewBox[3];\n\n svg.AspectRatio(\n ctx,\n this.attribute('preserveAspectRatio').value,\n svg.ViewPort.width(),\n width,\n svg.ViewPort.height(),\n height,\n minX,\n minY,\n this.attribute('refX').value,\n this.attribute('refY').value\n );\n\n svg.ViewPort.RemoveCurrent();\n svg.ViewPort.SetCurrent(viewBox[2], viewBox[3]);\n }\n }\n };\n\n // rect element\n svg.Element.rect = class extends svg.Element.PathElementBase {\n path (ctx) {\n const x = this.attribute('x').toPixels('x');\n const y = this.attribute('y').toPixels('y');\n const width = this.attribute('width').toPixels('x');\n const height = this.attribute('height').toPixels('y');\n let rx = this.attribute('rx').toPixels('x');\n let ry = this.attribute('ry').toPixels('y');\n if (this.attribute('rx').hasValue() && !this.attribute('ry').hasValue()) ry = rx;\n if (this.attribute('ry').hasValue() && !this.attribute('rx').hasValue()) rx = ry;\n rx = Math.min(rx, width / 2.0);\n ry = Math.min(ry, height / 2.0);\n if (!isNullish(ctx)) {\n ctx.beginPath();\n ctx.moveTo(x + rx, y);\n ctx.lineTo(x + width - rx, y);\n ctx.quadraticCurveTo(x + width, y, x + width, y + ry);\n ctx.lineTo(x + width, y + height - ry);\n ctx.quadraticCurveTo(x + width, y + height, x + width - rx, y + height);\n ctx.lineTo(x + rx, y + height);\n ctx.quadraticCurveTo(x, y + height, x, y + height - ry);\n ctx.lineTo(x, y + ry);\n ctx.quadraticCurveTo(x, y, x + rx, y);\n ctx.closePath();\n }\n\n return new svg.BoundingBox(x, y, x + width, y + height);\n }\n };\n\n // circle element\n svg.Element.circle = class extends svg.Element.PathElementBase {\n path (ctx) {\n const cx = this.attribute('cx').toPixels('x');\n const cy = this.attribute('cy').toPixels('y');\n const r = this.attribute('r').toPixels();\n\n if (!isNullish(ctx)) {\n ctx.beginPath();\n ctx.arc(cx, cy, r, 0, Math.PI * 2, true);\n ctx.closePath();\n }\n\n return new svg.BoundingBox(cx - r, cy - r, cx + r, cy + r);\n }\n };\n\n // ellipse element\n const KAPPA = 4 * ((Math.sqrt(2) - 1) / 3);\n svg.Element.ellipse = class extends svg.Element.PathElementBase {\n path (ctx) {\n const rx = this.attribute('rx').toPixels('x');\n const ry = this.attribute('ry').toPixels('y');\n const cx = this.attribute('cx').toPixels('x');\n const cy = this.attribute('cy').toPixels('y');\n\n if (!isNullish(ctx)) {\n ctx.beginPath();\n ctx.moveTo(cx, cy - ry);\n ctx.bezierCurveTo(cx + (KAPPA * rx), cy - ry, cx + rx, cy - (KAPPA * ry), cx + rx, cy);\n ctx.bezierCurveTo(cx + rx, cy + (KAPPA * ry), cx + (KAPPA * rx), cy + ry, cx, cy + ry);\n ctx.bezierCurveTo(cx - (KAPPA * rx), cy + ry, cx - rx, cy + (KAPPA * ry), cx - rx, cy);\n ctx.bezierCurveTo(cx - rx, cy - (KAPPA * ry), cx - (KAPPA * rx), cy - ry, cx, cy - ry);\n ctx.closePath();\n }\n\n return new svg.BoundingBox(cx - rx, cy - ry, cx + rx, cy + ry);\n }\n };\n\n // line element\n svg.Element.line = class extends svg.Element.PathElementBase {\n getPoints () {\n return [\n new svg.Point(this.attribute('x1').toPixels('x'), this.attribute('y1').toPixels('y')),\n new svg.Point(this.attribute('x2').toPixels('x'), this.attribute('y2').toPixels('y'))\n ];\n }\n\n path (ctx) {\n const points = this.getPoints();\n\n if (!isNullish(ctx)) {\n ctx.beginPath();\n ctx.moveTo(points[0].x, points[0].y);\n ctx.lineTo(points[1].x, points[1].y);\n }\n\n return new svg.BoundingBox(points[0].x, points[0].y, points[1].x, points[1].y);\n }\n\n getMarkers () {\n const points = this.getPoints();\n const a = points[0].angleTo(points[1]);\n return [[points[0], a], [points[1], a]];\n }\n };\n\n // polyline element\n svg.Element.polyline = class extends svg.Element.PathElementBase {\n constructor (node) {\n super(node);\n\n this.points = svg.CreatePath(this.attribute('points').value);\n }\n path (ctx) {\n const {x, y} = this.points[0];\n const bb = new svg.BoundingBox(x, y);\n if (!isNullish(ctx)) {\n ctx.beginPath();\n ctx.moveTo(x, y);\n }\n for (let i = 1; i < this.points.length; i++) {\n const {x: _x, y: _y} = this.points[i];\n bb.addPoint(_x, _y);\n if (!isNullish(ctx)) ctx.lineTo(_x, _y);\n }\n return bb;\n }\n\n getMarkers () {\n const markers = [];\n for (let i = 0; i < this.points.length - 1; i++) {\n markers.push([this.points[i], this.points[i].angleTo(this.points[i + 1])]);\n }\n markers.push([this.points[this.points.length - 1], markers[markers.length - 1][1]]);\n return markers;\n }\n };\n\n // polygon element\n svg.Element.polygon = class extends svg.Element.polyline {\n path (ctx) {\n const bb = super.path(ctx);\n if (!isNullish(ctx)) {\n ctx.lineTo(this.points[0].x, this.points[0].y);\n ctx.closePath();\n }\n return bb;\n }\n };\n\n // path element\n svg.Element.path = class extends svg.Element.PathElementBase {\n constructor (node) {\n super(node);\n\n let d = this.attribute('d').value\n // TODO: convert to real lexer based on https://www.w3.org/TR/SVG11/paths.html#PathDataBNF\n .replace(/,/gm, ' ') // get rid of all commas\n .replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands\n .replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands\n .replace(/([MmZzLlHhVvCcSsQqTtAa])(\\S)/gm, '$1 $2') // separate commands from points\n .replace(/(\\S)([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points\n .replace(/(\\d)([+-])/gm, '$1 $2') // separate digits when no comma\n .replace(/(\\.\\d*)(\\.)/gm, '$1 $2') // separate digits when no comma\n .replace(/([Aa](\\s+\\d+)(\\s+\\d+)(\\s+\\d+))\\s+([01])\\s*([01])/gm, '$1 $5 $6 '); // shorthand elliptical arc path syntax\n d = svg.compressSpaces(d); // compress multiple spaces\n d = svg.trim(d);\n this.PathParser = {\n tokens: d.split(' '),\n\n reset () {\n this.i = -1;\n this.command = '';\n this.previousCommand = '';\n this.start = new svg.Point(0, 0);\n this.control = new svg.Point(0, 0);\n this.current = new svg.Point(0, 0);\n this.points = [];\n this.angles = [];\n },\n\n isEnd () {\n return this.i >= this.tokens.length - 1;\n },\n\n isCommandOrEnd () {\n if (this.isEnd()) return true;\n return !isNullish(this.tokens[this.i + 1].match(/^[A-Za-z]$/));\n },\n\n isRelativeCommand () {\n switch (this.command) {\n case 'm':\n case 'l':\n case 'h':\n case 'v':\n case 'c':\n case 's':\n case 'q':\n case 't':\n case 'a':\n case 'z':\n return true;\n }\n return false;\n },\n\n getToken () {\n this.i++;\n return this.tokens[this.i];\n },\n\n getScalar () {\n return Number.parseFloat(this.getToken());\n },\n\n nextCommand () {\n this.previousCommand = this.command;\n this.command = this.getToken();\n },\n\n getPoint () {\n const p = new svg.Point(this.getScalar(), this.getScalar());\n return this.makeAbsolute(p);\n },\n\n getAsControlPoint () {\n const p = this.getPoint();\n this.control = p;\n return p;\n },\n\n getAsCurrentPoint () {\n const p = this.getPoint();\n this.current = p;\n return p;\n },\n\n getReflectedControlPoint () {\n if (this.previousCommand.toLowerCase() !== 'c' &&\n this.previousCommand.toLowerCase() !== 's' &&\n this.previousCommand.toLowerCase() !== 'q' &&\n this.previousCommand.toLowerCase() !== 't') {\n return this.current;\n }\n\n // reflect point\n const p = new svg.Point(2 * this.current.x - this.control.x, 2 * this.current.y - this.control.y);\n return p;\n },\n\n makeAbsolute (p) {\n if (this.isRelativeCommand()) {\n p.x += this.current.x;\n p.y += this.current.y;\n }\n return p;\n },\n\n addMarker (p, from, priorTo) {\n // if the last angle isn't filled in because we didn't have this point yet ...\n if (!isNullish(priorTo) && this.angles.length > 0 && isNullish(this.angles[this.angles.length - 1])) {\n this.angles[this.angles.length - 1] = this.points[this.points.length - 1].angleTo(priorTo);\n }\n this.addMarkerAngle(p, isNullish(from) ? null : from.angleTo(p));\n },\n\n addMarkerAngle (p, a) {\n this.points.push(p);\n this.angles.push(a);\n },\n\n getMarkerPoints () { return this.points; },\n getMarkerAngles () {\n for (let i = 0; i < this.angles.length; i++) {\n if (isNullish(this.angles[i])) {\n for (let j = i + 1; j < this.angles.length; j++) {\n if (!isNullish(this.angles[j])) {\n this.angles[i] = this.angles[j];\n break;\n }\n }\n }\n }\n return this.angles;\n }\n };\n }\n\n path (ctx) {\n const pp = this.PathParser;\n pp.reset();\n\n const bb = new svg.BoundingBox();\n if (!isNullish(ctx)) ctx.beginPath();\n while (!pp.isEnd()) {\n pp.nextCommand();\n switch (pp.command) {\n case 'M':\n case 'm': {\n const p = pp.getAsCurrentPoint();\n pp.addMarker(p);\n bb.addPoint(p.x, p.y);\n if (!isNullish(ctx)) ctx.moveTo(p.x, p.y);\n pp.start = pp.current;\n while (!pp.isCommandOrEnd()) {\n const _p = pp.getAsCurrentPoint();\n pp.addMarker(_p, pp.start);\n bb.addPoint(_p.x, _p.y);\n if (!isNullish(ctx)) ctx.lineTo(_p.x, _p.y);\n }\n break;\n } case 'L':\n case 'l':\n while (!pp.isCommandOrEnd()) {\n const c = pp.current;\n const p = pp.getAsCurrentPoint();\n pp.addMarker(p, c);\n bb.addPoint(p.x, p.y);\n if (!isNullish(ctx)) ctx.lineTo(p.x, p.y);\n }\n break;\n case 'H':\n case 'h':\n while (!pp.isCommandOrEnd()) {\n const newP = new svg.Point((pp.isRelativeCommand() ? pp.current.x : 0) + pp.getScalar(), pp.current.y);\n pp.addMarker(newP, pp.current);\n pp.current = newP;\n bb.addPoint(pp.current.x, pp.current.y);\n if (!isNullish(ctx)) ctx.lineTo(pp.current.x, pp.current.y);\n }\n break;\n case 'V':\n case 'v':\n while (!pp.isCommandOrEnd()) {\n const newP = new svg.Point(pp.current.x, (pp.isRelativeCommand() ? pp.current.y : 0) + pp.getScalar());\n pp.addMarker(newP, pp.current);\n pp.current = newP;\n bb.addPoint(pp.current.x, pp.current.y);\n if (!isNullish(ctx)) ctx.lineTo(pp.current.x, pp.current.y);\n }\n break;\n case 'C':\n case 'c':\n while (!pp.isCommandOrEnd()) {\n const curr = pp.current;\n const p1 = pp.getPoint();\n const cntrl = pp.getAsControlPoint();\n const cp = pp.getAsCurrentPoint();\n pp.addMarker(cp, cntrl, p1);\n bb.addBezierCurve(curr.x, curr.y, p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);\n if (!isNullish(ctx)) ctx.bezierCurveTo(p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);\n }\n break;\n case 'S':\n case 's':\n while (!pp.isCommandOrEnd()) {\n const curr = pp.current;\n const p1 = pp.getReflectedControlPoint();\n const cntrl = pp.getAsControlPoint();\n const cp = pp.getAsCurrentPoint();\n pp.addMarker(cp, cntrl, p1);\n bb.addBezierCurve(curr.x, curr.y, p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);\n if (!isNullish(ctx)) ctx.bezierCurveTo(p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);\n }\n break;\n case 'Q':\n case 'q':\n while (!pp.isCommandOrEnd()) {\n const curr = pp.current;\n const cntrl = pp.getAsControlPoint();\n const cp = pp.getAsCurrentPoint();\n pp.addMarker(cp, cntrl, cntrl);\n bb.addQuadraticCurve(curr.x, curr.y, cntrl.x, cntrl.y, cp.x, cp.y);\n if (!isNullish(ctx)) ctx.quadraticCurveTo(cntrl.x, cntrl.y, cp.x, cp.y);\n }\n break;\n case 'T':\n case 't':\n while (!pp.isCommandOrEnd()) {\n const curr = pp.current;\n const cntrl = pp.getReflectedControlPoint();\n pp.control = cntrl;\n const cp = pp.getAsCurrentPoint();\n pp.addMarker(cp, cntrl, cntrl);\n bb.addQuadraticCurve(curr.x, curr.y, cntrl.x, cntrl.y, cp.x, cp.y);\n if (!isNullish(ctx)) ctx.quadraticCurveTo(cntrl.x, cntrl.y, cp.x, cp.y);\n }\n break;\n case 'A':\n case 'a':\n while (!pp.isCommandOrEnd()) {\n const curr = pp.current;\n let rx = pp.getScalar();\n let ry = pp.getScalar();\n const xAxisRotation = pp.getScalar() * (Math.PI / 180.0);\n const largeArcFlag = pp.getScalar();\n const sweepFlag = pp.getScalar();\n const cp = pp.getAsCurrentPoint();\n\n // Conversion from endpoint to center parameterization\n // https://www.w3.org/TR/SVG11/implnote.html#ArcConversionEndpointToCenter\n\n // x1', y1'\n const currp = new svg.Point(\n Math.cos(xAxisRotation) * (curr.x - cp.x) / 2.0 + Math.sin(xAxisRotation) * (curr.y - cp.y) / 2.0,\n -Math.sin(xAxisRotation) * (curr.x - cp.x) / 2.0 + Math.cos(xAxisRotation) * (curr.y - cp.y) / 2.0\n );\n // adjust radii\n const l = (currp.x ** 2) / (rx ** 2) + (currp.y ** 2) / (ry ** 2);\n if (l > 1) {\n rx *= Math.sqrt(l);\n ry *= Math.sqrt(l);\n }\n // cx', cy'\n let s = (largeArcFlag === sweepFlag ? -1 : 1) * Math.sqrt(\n (((rx ** 2) * (ry ** 2)) - ((rx ** 2) * (currp.y ** 2)) - ((ry ** 2) * (currp.x ** 2))) /\n ((rx ** 2) * (currp.y ** 2) + (ry ** 2) * (currp.x ** 2))\n );\n if (isNaN(s)) s = 0;\n const cpp = new svg.Point(s * rx * currp.y / ry, s * -ry * currp.x / rx);\n // cx, cy\n const centp = new svg.Point(\n (curr.x + cp.x) / 2.0 + Math.cos(xAxisRotation) * cpp.x - Math.sin(xAxisRotation) * cpp.y,\n (curr.y + cp.y) / 2.0 + Math.sin(xAxisRotation) * cpp.x + Math.cos(xAxisRotation) * cpp.y\n );\n // vector magnitude\n const m = function (v) {\n return Math.sqrt((v[0] ** 2) + (v[1] ** 2));\n };\n // ratio between two vectors\n const r = function (u, v) {\n return (u[0] * v[0] + u[1] * v[1]) / (m(u) * m(v));\n };\n // angle between two vectors\n const a = function (u, v) {\n return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(r(u, v));\n };\n // initial angle\n const a1 = a([1, 0], [(currp.x - cpp.x) / rx, (currp.y - cpp.y) / ry]);\n // angle delta\n const u = [(currp.x - cpp.x) / rx, (currp.y - cpp.y) / ry];\n const v = [(-currp.x - cpp.x) / rx, (-currp.y - cpp.y) / ry];\n let ad = a(u, v);\n if (r(u, v) <= -1) ad = Math.PI;\n if (r(u, v) >= 1) ad = 0;\n\n // for markers\n const dir = 1 - sweepFlag ? 1.0 : -1.0;\n const ah = a1 + dir * (ad / 2.0);\n const halfWay = new svg.Point(\n centp.x + rx * Math.cos(ah),\n centp.y + ry * Math.sin(ah)\n );\n pp.addMarkerAngle(halfWay, ah - dir * Math.PI / 2);\n pp.addMarkerAngle(cp, ah - dir * Math.PI);\n\n bb.addPoint(cp.x, cp.y); // TODO: this is too naive, make it better\n if (!isNullish(ctx)) {\n const _r = rx > ry ? rx : ry;\n const sx = rx > ry ? 1 : rx / ry;\n const sy = rx > ry ? ry / rx : 1;\n\n ctx.translate(centp.x, centp.y);\n ctx.rotate(xAxisRotation);\n ctx.scale(sx, sy);\n ctx.arc(0, 0, _r, a1, a1 + ad, 1 - sweepFlag);\n ctx.scale(1 / sx, 1 / sy);\n ctx.rotate(-xAxisRotation);\n ctx.translate(-centp.x, -centp.y);\n }\n }\n break;\n case 'Z':\n case 'z':\n if (!isNullish(ctx)) ctx.closePath();\n pp.current = pp.start;\n }\n }\n\n return bb;\n }\n\n getMarkers () {\n const points = this.PathParser.getMarkerPoints();\n const angles = this.PathParser.getMarkerAngles();\n\n const markers = points.map((point, i) => {\n return [point, angles[i]];\n });\n return markers;\n }\n };\n\n // pattern element\n svg.Element.pattern = class extends svg.Element.ElementBase {\n createPattern (ctx, element) {\n const width = this.attribute('width').toPixels('x', true);\n const height = this.attribute('height').toPixels('y', true);\n\n // render me using a temporary svg element\n const tempSvg = new svg.Element.svg();\n tempSvg.attributes.viewBox = new svg.Property('viewBox', this.attribute('viewBox').value);\n tempSvg.attributes.width = new svg.Property('width', width + 'px');\n tempSvg.attributes.height = new svg.Property('height', height + 'px');\n tempSvg.attributes.transform = new svg.Property('transform', this.attribute('patternTransform').value);\n tempSvg.children = this.children;\n\n const c = document.createElement('canvas');\n c.width = width;\n c.height = height;\n const cctx = c.getContext('2d');\n if (this.attribute('x').hasValue() && this.attribute('y').hasValue()) {\n cctx.translate(this.attribute('x').toPixels('x', true), this.attribute('y').toPixels('y', true));\n }\n // render 3x3 grid so when we transform there's no white space on edges\n for (let x = -1; x <= 1; x++) {\n for (let y = -1; y <= 1; y++) {\n cctx.save();\n cctx.translate(x * c.width, y * c.height);\n tempSvg.render(cctx);\n cctx.restore();\n }\n }\n const pattern = ctx.createPattern(c, 'repeat');\n return pattern;\n }\n };\n\n // marker element\n svg.Element.marker = class extends svg.Element.ElementBase {\n render (ctx, point, angle) {\n ctx.translate(point.x, point.y);\n if (this.attribute('orient').valueOrDefault('auto') === 'auto') ctx.rotate(angle);\n if (this.attribute('markerUnits').valueOrDefault('strokeWidth') === 'strokeWidth') ctx.scale(ctx.lineWidth, ctx.lineWidth);\n ctx.save();\n\n // render me using a temporary svg element\n const tempSvg = new svg.Element.svg();\n tempSvg.attributes.viewBox = new svg.Property(\n 'viewBox', this.attribute('viewBox').value\n );\n tempSvg.attributes.refX = new svg.Property(\n 'refX', this.attribute('refX').value\n );\n tempSvg.attributes.refY = new svg.Property(\n 'refY', this.attribute('refY').value\n );\n tempSvg.attributes.width = new svg.Property(\n 'width', this.attribute('markerWidth').value\n );\n tempSvg.attributes.height = new svg.Property(\n 'height', this.attribute('markerHeight').value\n );\n tempSvg.attributes.fill = new svg.Property(\n 'fill', this.attribute('fill').valueOrDefault('black')\n );\n tempSvg.attributes.stroke = new svg.Property(\n 'stroke', this.attribute('stroke').valueOrDefault('none')\n );\n tempSvg.children = this.children;\n tempSvg.render(ctx);\n\n ctx.restore();\n if (this.attribute('markerUnits').valueOrDefault('strokeWidth') ===\n 'strokeWidth'\n ) ctx.scale(1 / ctx.lineWidth, 1 / ctx.lineWidth);\n if (this.attribute('orient').valueOrDefault('auto') === 'auto') {\n ctx.rotate(-angle);\n }\n ctx.translate(-point.x, -point.y);\n }\n };\n\n // definitions element\n svg.Element.defs = class extends svg.Element.ElementBase {\n render (ctx) {\n // NOOP\n }\n };\n\n // base for gradients\n svg.Element.GradientBase = class extends svg.Element.ElementBase {\n constructor (node) {\n super(node);\n\n this.gradientUnits = this.attribute('gradientUnits').valueOrDefault('objectBoundingBox');\n\n this.stops = [];\n this.children.forEach((child) => {\n if (child.type === 'stop') {\n this.stops.push(child);\n }\n });\n }\n\n getGradient () {\n // OVERRIDE ME!\n }\n\n createGradient (ctx, element, parentOpacityProp) {\n const stopsContainer = this.getHrefAttribute().hasValue()\n ? this.getHrefAttribute().getDefinition()\n : this;\n\n const addParentOpacity = function (color) {\n if (parentOpacityProp.hasValue()) {\n const p = new svg.Property('color', color);\n return p.addOpacity(parentOpacityProp).value;\n }\n return color;\n };\n\n const g = this.getGradient(ctx, element);\n if (isNullish(g)) return addParentOpacity(stopsContainer.stops[stopsContainer.stops.length - 1].color);\n stopsContainer.stops.forEach(({offset, color}) => {\n g.addColorStop(offset, addParentOpacity(color));\n });\n\n if (this.attribute('gradientTransform').hasValue()) {\n // render as transformed pattern on temporary canvas\n const rootView = svg.ViewPort.viewPorts[0];\n\n const rect = new svg.Element.rect();\n rect.attributes.x = new svg.Property('x', -svg.MAX_VIRTUAL_PIXELS / 3.0);\n rect.attributes.y = new svg.Property('y', -svg.MAX_VIRTUAL_PIXELS / 3.0);\n rect.attributes.width = new svg.Property('width', svg.MAX_VIRTUAL_PIXELS);\n rect.attributes.height = new svg.Property('height', svg.MAX_VIRTUAL_PIXELS);\n\n const group = new svg.Element.g();\n group.attributes.transform = new svg.Property('transform', this.attribute('gradientTransform').value);\n group.children = [rect];\n\n const tempSvg = new svg.Element.svg();\n tempSvg.attributes.x = new svg.Property('x', 0);\n tempSvg.attributes.y = new svg.Property('y', 0);\n tempSvg.attributes.width = new svg.Property('width', rootView.width);\n tempSvg.attributes.height = new svg.Property('height', rootView.height);\n tempSvg.children = [group];\n\n const c = document.createElement('canvas');\n c.width = rootView.width;\n c.height = rootView.height;\n const tempCtx = c.getContext('2d');\n tempCtx.fillStyle = g;\n tempSvg.render(tempCtx);\n return tempCtx.createPattern(c, 'no-repeat');\n }\n\n return g;\n }\n };\n\n // linear gradient element\n svg.Element.linearGradient = class extends svg.Element.GradientBase {\n getGradient (ctx, element) {\n const useBB = this.gradientUnits === 'objectBoundingBox' && element.getBoundingBox;\n const bb = useBB\n ? element.getBoundingBox()\n : null;\n\n if (!this.attribute('x1').hasValue() &&\n !this.attribute('y1').hasValue() &&\n !this.attribute('x2').hasValue() &&\n !this.attribute('y2').hasValue()\n ) {\n this.attribute('x1', true).value = 0;\n this.attribute('y1', true).value = 0;\n this.attribute('x2', true).value = 1;\n this.attribute('y2', true).value = 0;\n }\n\n const x1 = (useBB\n ? bb.x() + bb.width() * this.attribute('x1').numValue()\n : this.attribute('x1').toPixels('x'));\n const y1 = (useBB\n ? bb.y() + bb.height() * this.attribute('y1').numValue()\n : this.attribute('y1').toPixels('y'));\n const x2 = (useBB\n ? bb.x() + bb.width() * this.attribute('x2').numValue()\n : this.attribute('x2').toPixels('x'));\n const y2 = (useBB\n ? bb.y() + bb.height() * this.attribute('y2').numValue()\n : this.attribute('y2').toPixels('y'));\n\n if (x1 === x2 && y1 === y2) return null;\n return ctx.createLinearGradient(x1, y1, x2, y2);\n }\n };\n\n // radial gradient element\n svg.Element.radialGradient = class extends svg.Element.GradientBase {\n getGradient (ctx, element) {\n const useBB = this.gradientUnits === 'objectBoundingBox' && element.getBoundingBox;\n const bb = useBB ? element.getBoundingBox() : null;\n\n if (!this.attribute('cx').hasValue()) this.attribute('cx', true).value = '50%';\n if (!this.attribute('cy').hasValue()) this.attribute('cy', true).value = '50%';\n if (!this.attribute('r').hasValue()) this.attribute('r', true).value = '50%';\n\n const cx = (useBB\n ? bb.x() + bb.width() * this.attribute('cx').numValue()\n : this.attribute('cx').toPixels('x'));\n const cy = (useBB\n ? bb.y() + bb.height() * this.attribute('cy').numValue()\n : this.attribute('cy').toPixels('y'));\n\n let fx = cx;\n let fy = cy;\n if (this.attribute('fx').hasValue()) {\n fx = (useBB\n ? bb.x() + bb.width() * this.attribute('fx').numValue()\n : this.attribute('fx').toPixels('x'));\n }\n if (this.attribute('fy').hasValue()) {\n fy = (useBB\n ? bb.y() + bb.height() * this.attribute('fy').numValue()\n : this.attribute('fy').toPixels('y'));\n }\n\n const r = (useBB\n ? (bb.width() + bb.height()) / 2.0 * this.attribute('r').numValue()\n : this.attribute('r').toPixels());\n\n return ctx.createRadialGradient(fx, fy, 0, cx, cy, r);\n }\n };\n\n // gradient stop element\n svg.Element.stop = class extends svg.Element.ElementBase {\n constructor (node) {\n super(node);\n\n this.offset = this.attribute('offset').numValue();\n if (this.offset < 0) this.offset = 0;\n if (this.offset > 1) this.offset = 1;\n\n let stopColor = this.style('stop-color');\n if (this.style('stop-opacity').hasValue()) {\n stopColor = stopColor.addOpacity(this.style('stop-opacity'));\n }\n this.color = stopColor.value;\n }\n };\n\n // animation base element\n svg.Element.AnimateBase = class extends svg.Element.ElementBase {\n constructor (node) {\n super(node);\n\n svg.Animations.push(this);\n\n this.duration = 0.0;\n this.begin = this.attribute('begin').toMilliseconds();\n this.maxDuration = this.begin + this.attribute('dur').toMilliseconds();\n\n this.initialValue = null;\n this.initialUnits = '';\n this.removed = false;\n\n this.from = this.attribute('from');\n this.to = this.attribute('to');\n this.values = this.attribute('values');\n if (this.values.hasValue()) this.values.value = this.values.value.split(';');\n }\n\n getProperty () {\n const attributeType = this.attribute('attributeType').value;\n const attributeName = this.attribute('attributeName').value;\n\n if (attributeType === 'CSS') {\n return this.parent.style(attributeName, true);\n }\n return this.parent.attribute(attributeName, true);\n }\n\n calcValue () {\n // OVERRIDE ME!\n return '';\n }\n\n update (delta) {\n // set initial value\n if (isNullish(this.initialValue)) {\n this.initialValue = this.getProperty().value;\n this.initialUnits = this.getProperty().getUnits();\n }\n\n // if we're past the end time\n if (this.duration > this.maxDuration) {\n // loop for indefinitely repeating animations\n if (this.attribute('repeatCount').value === 'indefinite' ||\n this.attribute('repeatDur').value === 'indefinite') {\n this.duration = 0.0;\n } else if (this.attribute('fill').valueOrDefault('remove') === 'freeze' && !this.frozen) {\n this.frozen = true;\n this.parent.animationFrozen = true;\n this.parent.animationFrozenValue = this.getProperty().value;\n } else if (this.attribute('fill').valueOrDefault('remove') === 'remove' && !this.removed) {\n this.removed = true;\n this.getProperty().value = this.parent.animationFrozen ? this.parent.animationFrozenValue : this.initialValue;\n return true;\n }\n return false;\n }\n this.duration += delta;\n\n // if we're past the begin time\n let updated = false;\n if (this.begin < this.duration) {\n let newValue = this.calcValue(); // tween\n\n if (this.attribute('type').hasValue()) {\n // for transform, etc.\n const type = this.attribute('type').value;\n newValue = type + '(' + newValue + ')';\n }\n\n this.getProperty().value = newValue;\n updated = true;\n }\n\n return updated;\n }\n\n // fraction of duration we've covered\n progress () {\n const ret = {progress: (this.duration - this.begin) / (this.maxDuration - this.begin)};\n if (this.values.hasValue()) {\n const p = ret.progress * (this.values.value.length - 1);\n const lb = Math.floor(p), ub = Math.ceil(p);\n ret.from = new svg.Property('from', Number.parseFloat(this.values.value[lb]));\n ret.to = new svg.Property('to', Number.parseFloat(this.values.value[ub]));\n ret.progress = (p - lb) / (ub - lb);\n } else {\n ret.from = this.from;\n ret.to = this.to;\n }\n return ret;\n }\n };\n\n // animate element\n svg.Element.animate = class extends svg.Element.AnimateBase {\n calcValue () {\n const p = this.progress();\n\n // tween value linearly\n const newValue = p.from.numValue() + (p.to.numValue() - p.from.numValue()) * p.progress;\n return newValue + this.initialUnits;\n }\n };\n\n // animate color element\n svg.Element.animateColor = class extends svg.Element.AnimateBase {\n calcValue () {\n const p = this.progress();\n const from = new RGBColor(p.from.value);\n const to = new RGBColor(p.to.value);\n\n if (from.ok && to.ok) {\n // tween color linearly\n const r = from.r + (to.r - from.r) * p.progress;\n const g = from.g + (to.g - from.g) * p.progress;\n const b = from.b + (to.b - from.b) * p.progress;\n return 'rgb(' + Number.parseInt(r) + ',' + Number.parseInt(g) + ',' + Number.parseInt(b) + ')';\n }\n return this.attribute('from').value;\n }\n };\n\n // animate transform element\n svg.Element.animateTransform = class extends svg.Element.animate {\n calcValue () {\n const p = this.progress();\n\n // tween value linearly\n const from = svg.ToNumberArray(p.from.value);\n const to = svg.ToNumberArray(p.to.value);\n let newValue = '';\n from.forEach((fr, i) => {\n newValue += fr + (to[i] - fr) * p.progress + ' ';\n });\n return newValue;\n }\n };\n\n // font element\n svg.Element.font = class extends svg.Element.ElementBase {\n constructor (node) {\n super(node);\n\n this.horizAdvX = this.attribute('horiz-adv-x').numValue();\n\n this.isRTL = false;\n this.isArabic = false;\n this.fontFace = null;\n this.missingGlyph = null;\n this.glyphs = [];\n this.children.forEach((child) => {\n if (child.type === 'font-face') {\n this.fontFace = child;\n if (child.style('font-family').hasValue()) {\n svg.Definitions[child.style('font-family').value] = this;\n }\n } else if (child.type === 'missing-glyph') {\n this.missingGlyph = child;\n } else if (child.type === 'glyph') {\n if (child.arabicForm !== '') {\n this.isRTL = true;\n this.isArabic = true;\n if (typeof this.glyphs[child.unicode] === 'undefined') {\n this.glyphs[child.unicode] = [];\n }\n this.glyphs[child.unicode][child.arabicForm] = child;\n } else {\n this.glyphs[child.unicode] = child;\n }\n }\n });\n }\n };\n\n // font-face element\n svg.Element.fontface = class extends svg.Element.ElementBase {\n constructor (node) {\n super(node);\n\n this.ascent = this.attribute('ascent').value;\n this.descent = this.attribute('descent').value;\n this.unitsPerEm = this.attribute('units-per-em').numValue();\n }\n };\n\n // missing-glyph element\n svg.Element.missingglyph = class extends svg.Element.path {\n constructor (node) {\n super(node);\n\n this.horizAdvX = 0;\n }\n };\n\n // glyph element\n svg.Element.glyph = class extends svg.Element.path {\n constructor (node) {\n super(node);\n\n this.horizAdvX = this.attribute('horiz-adv-x').numValue();\n this.unicode = this.attribute('unicode').value;\n this.arabicForm = this.attribute('arabic-form').value;\n }\n };\n\n // text element\n svg.Element.text = class extends svg.Element.RenderedElementBase {\n constructor (node) {\n super(node, true);\n }\n\n setContext (ctx) {\n super.setContext(ctx);\n\n let textBaseline = this.style('dominant-baseline').toTextBaseline();\n if (isNullish(textBaseline)) textBaseline = this.style('alignment-baseline').toTextBaseline();\n if (!isNullish(textBaseline)) ctx.textBaseline = textBaseline;\n }\n\n getBoundingBox () {\n const x = this.attribute('x').toPixels('x');\n const y = this.attribute('y').toPixels('y');\n const fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize);\n return new svg.BoundingBox(x, y - fontSize, x + Math.floor(fontSize * 2.0 / 3.0) * this.children[0].getText().length, y);\n }\n\n renderChildren (ctx) {\n this.x = this.attribute('x').toPixels('x');\n this.y = this.attribute('y').toPixels('y');\n this.x += this.getAnchorDelta(ctx, this, 0);\n this.children.forEach((child, i) => {\n this.renderChild(ctx, this, i);\n });\n }\n\n getAnchorDelta (ctx, parent, startI) {\n const textAnchor = this.style('text-anchor').valueOrDefault('start');\n if (textAnchor !== 'start') {\n let width = 0;\n for (let i = startI; i < parent.children.length; i++) {\n const child = parent.children[i];\n if (i > startI && child.attribute('x').hasValue()) break; // new group\n width += child.measureTextRecursive(ctx);\n }\n return -1 * (textAnchor === 'end' ? width : width / 2.0);\n }\n return 0;\n }\n\n renderChild (ctx, parent, i) {\n const child = parent.children[i];\n if (child.attribute('x').hasValue()) {\n child.x = child.attribute('x').toPixels('x') + this.getAnchorDelta(ctx, parent, i);\n if (child.attribute('dx').hasValue()) child.x += child.attribute('dx').toPixels('x');\n } else {\n if (this.attribute('dx').hasValue()) this.x += this.attribute('dx').toPixels('x');\n if (child.attribute('dx').hasValue()) this.x += child.attribute('dx').toPixels('x');\n child.x = this.x;\n }\n this.x = child.x + child.measureText(ctx);\n\n if (child.attribute('y').hasValue()) {\n child.y = child.attribute('y').toPixels('y');\n if (child.attribute('dy').hasValue()) child.y += child.attribute('dy').toPixels('y');\n } else {\n if (this.attribute('dy').hasValue()) this.y += this.attribute('dy').toPixels('y');\n if (child.attribute('dy').hasValue()) this.y += child.attribute('dy').toPixels('y');\n child.y = this.y;\n }\n this.y = child.y;\n\n child.render(ctx);\n\n for (let j = 0; j < child.children.length; j++) {\n this.renderChild(ctx, child, j);\n }\n }\n };\n\n // text base\n svg.Element.TextElementBase = class extends svg.Element.RenderedElementBase {\n getGlyph (font, text, i) {\n const c = text[i];\n let glyph = null;\n if (font.isArabic) {\n let arabicForm = 'isolated';\n if ((i === 0 || text[i - 1] === ' ') && i < text.length - 2 && text[i + 1] !== ' ') arabicForm = 'terminal';\n if (i > 0 && text[i - 1] !== ' ' && i < text.length - 2 && text[i + 1] !== ' ') arabicForm = 'medial';\n if (i > 0 && text[i - 1] !== ' ' && (i === text.length - 1 || text[i + 1] === ' ')) arabicForm = 'initial';\n if (typeof font.glyphs[c] !== 'undefined') {\n glyph = font.glyphs[c][arabicForm];\n if (isNullish(glyph) && font.glyphs[c].type === 'glyph') glyph = font.glyphs[c];\n }\n } else {\n glyph = font.glyphs[c];\n }\n if (isNullish(glyph)) glyph = font.missingGlyph;\n return glyph;\n }\n\n renderChildren (ctx) {\n const customFont = this.parent.style('font-family').getDefinition();\n if (!isNullish(customFont)) {\n const fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize);\n const fontStyle = this.parent.style('font-style').valueOrDefault(svg.Font.Parse(svg.ctx.font).fontStyle);\n let text = this.getText();\n if (customFont.isRTL) text = text.split('').reverse().join('');\n\n const dx = svg.ToNumberArray(this.parent.attribute('dx').value);\n for (let i = 0; i < text.length; i++) {\n const glyph = this.getGlyph(customFont, text, i);\n const scale = fontSize / customFont.fontFace.unitsPerEm;\n ctx.translate(this.x, this.y);\n ctx.scale(scale, -scale);\n const lw = ctx.lineWidth;\n ctx.lineWidth = ctx.lineWidth * customFont.fontFace.unitsPerEm / fontSize;\n if (fontStyle === 'italic') ctx.transform(1, 0, 0.4, 1, 0, 0);\n glyph.render(ctx);\n if (fontStyle === 'italic') ctx.transform(1, 0, -0.4, 1, 0, 0);\n ctx.lineWidth = lw;\n ctx.scale(1 / scale, -1 / scale);\n ctx.translate(-this.x, -this.y);\n\n this.x += fontSize * (glyph.horizAdvX || customFont.horizAdvX) / customFont.fontFace.unitsPerEm;\n if (typeof dx[i] !== 'undefined' && !isNaN(dx[i])) {\n this.x += dx[i];\n }\n }\n return;\n }\n\n if (ctx.fillStyle !== '') ctx.fillText(svg.compressSpaces(this.getText()), this.x, this.y);\n if (ctx.strokeStyle !== '') ctx.strokeText(svg.compressSpaces(this.getText()), this.x, this.y);\n }\n\n getText () {\n // OVERRIDE ME\n }\n\n measureTextRecursive (ctx) {\n let width = this.measureText(ctx);\n this.children.forEach((child) => {\n width += child.measureTextRecursive(ctx);\n });\n return width;\n }\n\n measureText (ctx) {\n const customFont = this.parent.style('font-family').getDefinition();\n if (!isNullish(customFont)) {\n const fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize);\n let measure = 0;\n let text = this.getText();\n if (customFont.isRTL) text = text.split('').reverse().join('');\n const dx = svg.ToNumberArray(this.parent.attribute('dx').value);\n for (let i = 0; i < text.length; i++) {\n const glyph = this.getGlyph(customFont, text, i);\n measure += (glyph.horizAdvX || customFont.horizAdvX) * fontSize / customFont.fontFace.unitsPerEm;\n if (typeof dx[i] !== 'undefined' && !isNaN(dx[i])) {\n measure += dx[i];\n }\n }\n return measure;\n }\n\n const textToMeasure = svg.compressSpaces(this.getText());\n if (!ctx.measureText) return textToMeasure.length * 10;\n\n ctx.save();\n this.setContext(ctx);\n const {width} = ctx.measureText(textToMeasure);\n ctx.restore();\n return width;\n }\n };\n\n // tspan\n svg.Element.tspan = class extends svg.Element.TextElementBase {\n constructor (node) {\n super(node, true);\n\n this.text = node.nodeValue || node.text || '';\n }\n getText () {\n return this.text;\n }\n };\n\n // tref\n svg.Element.tref = class extends svg.Element.TextElementBase {\n getText () {\n const element = this.getHrefAttribute().getDefinition();\n if (!isNullish(element)) return element.children[0].getText();\n return undefined;\n }\n };\n\n // a element\n svg.Element.a = class extends svg.Element.TextElementBase {\n constructor (node) {\n super(node);\n\n this.hasText = true;\n [...node.childNodes].forEach((childNode) => {\n if (childNode.nodeType !== 3) {\n this.hasText = false;\n }\n });\n // this might contain text\n this.text = this.hasText ? node.childNodes[0].nodeValue : '';\n }\n\n getText () {\n return this.text;\n }\n\n renderChildren (ctx) {\n if (this.hasText) {\n // render as text element\n super.renderChildren(ctx);\n const fontSize = new svg.Property(\n 'fontSize', svg.Font.Parse(svg.ctx.font).fontSize\n );\n svg.Mouse.checkBoundingBox(\n this, new svg.BoundingBox(\n this.x,\n this.y - fontSize.toPixels('y'),\n this.x + this.measureText(ctx),\n this.y\n )\n );\n } else {\n // render as temporary group\n const g = new svg.Element.g();\n g.children = this.children;\n g.parent = this;\n g.render(ctx);\n }\n }\n\n onclick () {\n window.open(this.getHrefAttribute().value);\n }\n\n onmousemove () {\n svg.ctx.canvas.style.cursor = 'pointer';\n }\n };\n\n // image element\n svg.Element.image = class extends svg.Element.RenderedElementBase {\n constructor (node) {\n super(node);\n\n const href = this.getHrefAttribute().value;\n if (href === '') {\n return;\n }\n this._isSvg = href.match(/\\.svg$/);\n\n svg.Images.push(this);\n this.loaded = false;\n if (!this._isSvg) {\n this.img = document.createElement('img');\n if (svg.opts.useCORS === true) {\n this.img.crossOrigin = 'Anonymous';\n }\n this.img.addEventListener('load', () => {\n this.loaded = true;\n });\n this.img.addEventListener('error', () => {\n svg.log('ERROR: image \"' + href + '\" not found');\n this.loaded = true;\n });\n this.img.src = href;\n } else {\n svg.ajax(href, true).then((img) => { // eslint-disable-line promise/prefer-await-to-then, promise/always-return\n this.img = img;\n this.loaded = true;\n }).catch((err) => { // eslint-disable-line promise/prefer-await-to-callbacks\n this.erred = true;\n console.error('Ajax error for canvg', err); // eslint-disable-line no-console\n });\n }\n }\n renderChildren (ctx) {\n const x = this.attribute('x').toPixels('x');\n const y = this.attribute('y').toPixels('y');\n\n const width = this.attribute('width').toPixels('x');\n const height = this.attribute('height').toPixels('y');\n if (width === 0 || height === 0) return;\n\n ctx.save();\n if (this._isSvg) {\n ctx.drawSvg(this.img, x, y, width, height);\n } else {\n ctx.translate(x, y);\n svg.AspectRatio(\n ctx,\n this.attribute('preserveAspectRatio').value,\n width,\n this.img.width,\n height,\n this.img.height,\n 0,\n 0\n );\n ctx.drawImage(this.img, 0, 0);\n }\n ctx.restore();\n }\n\n getBoundingBox () {\n const x = this.attribute('x').toPixels('x');\n const y = this.attribute('y').toPixels('y');\n const width = this.attribute('width').toPixels('x');\n const height = this.attribute('height').toPixels('y');\n return new svg.BoundingBox(x, y, x + width, y + height);\n }\n };\n\n // group element\n svg.Element.g = class extends svg.Element.RenderedElementBase {\n getBoundingBox () {\n const bb = new svg.BoundingBox();\n this.children.forEach((child) => {\n bb.addBoundingBox(child.getBoundingBox());\n });\n return bb;\n }\n };\n\n // symbol element\n svg.Element.symbol = class extends svg.Element.RenderedElementBase {\n render (ctx) {\n // NO RENDER\n }\n };\n\n // style element\n svg.Element.style = class extends svg.Element.ElementBase {\n constructor (node) {\n super(node);\n\n // text, or spaces then CDATA\n let css = '';\n [...node.childNodes].forEach(({nodeValue}) => {\n css += nodeValue;\n });\n // remove comments\n css = css.replace(/(\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*+\\/)|(^\\s*\\/\\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex\n // replace whitespace\n css = svg.compressSpaces(css);\n const cssDefs = css.split('}');\n cssDefs.forEach((cssDef) => {\n if (svg.trim(cssDef) !== '') {\n let [cssClasses, cssProps] = cssDef.split('{');\n cssClasses = cssClasses.split(',');\n cssProps = cssProps.split(';');\n cssClasses.forEach((cssClass) => {\n cssClass = svg.trim(cssClass);\n if (cssClass !== '') {\n const props = {};\n cssProps.forEach((cssProp) => {\n const prop = cssProp.indexOf(':');\n const name = cssProp.substr(0, prop);\n const value = cssProp.substr(prop + 1, cssProp.length - prop);\n if (!isNullish(name) && !isNullish(value)) {\n props[svg.trim(name)] = new svg.Property(svg.trim(name), svg.trim(value));\n }\n });\n svg.Styles[cssClass] = props;\n if (cssClass === '@font-face') {\n const fontFamily = props['font-family'].value.replace(/\"/g, '');\n const srcs = props.src.value.split(',');\n srcs.forEach((src) => {\n if (src.includes('format(\"svg\")')) {\n const urlStart = src.indexOf('url');\n const urlEnd = src.indexOf(')', urlStart);\n const url = src.substr(urlStart + 5, urlEnd - urlStart - 6);\n // Can this ajax safely be converted to async?\n const doc = svg.parseXml(svg.ajax(url));\n const fonts = doc.getElementsByTagName('font');\n [...fonts].forEach((font) => {\n font = svg.CreateElement(font);\n svg.Definitions[fontFamily] = font;\n });\n }\n });\n }\n }\n });\n }\n });\n }\n };\n\n // use element\n svg.Element.use = class extends svg.Element.RenderedElementBase {\n constructor (node) {\n super(node);\n\n this._el = this.getHrefAttribute().getDefinition();\n }\n\n setContext (ctx) {\n super.setContext(ctx);\n if (this.attribute('x').hasValue()) ctx.translate(this.attribute('x').toPixels('x'), 0);\n if (this.attribute('y').hasValue()) ctx.translate(0, this.attribute('y').toPixels('y'));\n }\n\n path (ctx) {\n const {_el: element} = this;\n if (!isNullish(element)) element.path(ctx);\n }\n\n getBoundingBox () {\n const {_el: element} = this;\n if (!isNullish(element)) return element.getBoundingBox();\n return undefined;\n }\n\n renderChildren (ctx) {\n const {_el: element} = this;\n if (!isNullish(element)) {\n let tempSvg = element;\n if (element.type === 'symbol') {\n // render me using a temporary svg element in symbol cases\n // (https://www.w3.org/TR/SVG/struct.html#UseElement)\n tempSvg = new svg.Element.svg();\n tempSvg.type = 'svg';\n tempSvg.attributes.viewBox = new svg.Property(\n 'viewBox', element.attribute('viewBox').value\n );\n tempSvg.attributes.preserveAspectRatio = new svg.Property(\n 'preserveAspectRatio', element.attribute('preserveAspectRatio').value\n );\n tempSvg.attributes.overflow = new svg.Property(\n 'overflow', element.attribute('overflow').value\n );\n tempSvg.children = element.children;\n }\n if (tempSvg.type === 'svg') {\n // if symbol or svg, inherit width/height from me\n if (this.attribute('width').hasValue()) {\n tempSvg.attributes.width = new svg.Property(\n 'width', this.attribute('width').value\n );\n }\n if (this.attribute('height').hasValue()) {\n tempSvg.attributes.height = new svg.Property(\n 'height', this.attribute('height').value\n );\n }\n }\n const oldParent = tempSvg.parent;\n tempSvg.parent = null;\n tempSvg.render(ctx);\n tempSvg.parent = oldParent;\n }\n }\n };\n\n // mask element\n svg.Element.mask = class extends svg.Element.ElementBase {\n apply (ctx, element) {\n // render as temp svg\n let x = this.attribute('x').toPixels('x');\n let y = this.attribute('y').toPixels('y');\n let width = this.attribute('width').toPixels('x');\n let height = this.attribute('height').toPixels('y');\n\n if (width === 0 && height === 0) {\n const bb = new svg.BoundingBox();\n this.children.forEach((child) => {\n bb.addBoundingBox(child.getBoundingBox());\n });\n x = Math.floor(bb.x1);\n y = Math.floor(bb.y1);\n width = Math.floor(bb.width());\n height = Math.floor(bb.height());\n }\n\n // temporarily remove mask to avoid recursion\n const mask = element.attribute('mask').value;\n element.attribute('mask').value = '';\n\n const cMask = document.createElement('canvas');\n cMask.width = x + width;\n cMask.height = y + height;\n const maskCtx = cMask.getContext('2d');\n this.renderChildren(maskCtx);\n\n const c = document.createElement('canvas');\n c.width = x + width;\n c.height = y + height;\n const tempCtx = c.getContext('2d');\n element.render(tempCtx);\n tempCtx.globalCompositeOperation = 'destination-in';\n tempCtx.fillStyle = maskCtx.createPattern(cMask, 'no-repeat');\n tempCtx.fillRect(0, 0, x + width, y + height);\n\n ctx.fillStyle = tempCtx.createPattern(c, 'no-repeat');\n ctx.fillRect(0, 0, x + width, y + height);\n\n // reassign mask\n element.attribute('mask').value = mask;\n }\n\n render (ctx) {\n // NO RENDER\n }\n };\n\n // clip element\n svg.Element.clipPath = class extends svg.Element.ElementBase {\n apply (ctx) {\n this.children.forEach((child) => {\n if (typeof child.path !== 'undefined') {\n let transform = null;\n if (child.attribute('transform').hasValue()) {\n transform = new svg.Transform(child.attribute('transform').value);\n transform.apply(ctx);\n }\n child.path(ctx);\n ctx.clip();\n if (transform) { transform.unapply(ctx); }\n }\n });\n }\n render (ctx) {\n // NO RENDER\n }\n };\n\n // filters\n svg.Element.filter = class extends svg.Element.ElementBase {\n apply (ctx, element) {\n // render as temp svg\n const bb = element.getBoundingBox();\n const x = Math.floor(bb.x1);\n const y = Math.floor(bb.y1);\n const width = Math.floor(bb.width());\n const height = Math.floor(bb.height());\n\n // temporarily remove filter to avoid recursion\n const filter = element.style('filter').value;\n element.style('filter').value = '';\n\n let px = 0, py = 0;\n this.children.forEach((child) => {\n const efd = child.extraFilterDistance || 0;\n px = Math.max(px, efd);\n py = Math.max(py, efd);\n });\n\n const c = document.createElement('canvas');\n c.width = width + 2 * px;\n c.height = height + 2 * py;\n const tempCtx = c.getContext('2d');\n tempCtx.translate(-x + px, -y + py);\n element.render(tempCtx);\n\n // apply filters\n this.children.forEach((child) => {\n child.apply(tempCtx, 0, 0, width + 2 * px, height + 2 * py);\n });\n\n // render on me\n ctx.drawImage(c, 0, 0, width + 2 * px, height + 2 * py, x - px, y - py, width + 2 * px, height + 2 * py);\n\n // reassign filter\n element.style('filter', true).value = filter;\n }\n\n render (ctx) {\n // NO RENDER\n }\n };\n\n svg.Element.feMorphology = class extends svg.Element.ElementBase {\n apply (ctx, x, y, width, height) {\n // TODO: implement\n }\n };\n\n svg.Element.feComposite = class extends svg.Element.ElementBase {\n apply (ctx, x, y, width, height) {\n // TODO: implement\n }\n };\n\n /**\n * @param {Uint8ClampedArray} img\n * @param {Integer} x\n * @param {Integer} y\n * @param {Float} width\n * @param {Float} height\n * @param {Integer} rgba\n * @returns {Integer}\n */\n function imGet (img, x, y, width, height, rgba) {\n return img[y * width * 4 + x * 4 + rgba];\n }\n\n /**\n * @param {Uint8ClampedArray} img\n * @param {Integer} x\n * @param {Integer} y\n * @param {Float} width\n * @param {Float} height\n * @param {Integer} rgba\n * @param {Float} val\n * @returns {void}\n */\n function imSet (img, x, y, width, height, rgba, val) {\n img[y * width * 4 + x * 4 + rgba] = val;\n }\n\n svg.Element.feColorMatrix = class extends svg.Element.ElementBase {\n constructor (node) {\n super(node);\n\n let matrix = svg.ToNumberArray(this.attribute('values').value);\n switch (this.attribute('type').valueOrDefault('matrix')) { // https://www.w3.org/TR/SVG/filters.html#feColorMatrixElement\n case 'saturate': {\n const s = matrix[0];\n matrix = [\n 0.213 + 0.787 * s, 0.715 - 0.715 * s, 0.072 - 0.072 * s, 0, 0,\n 0.213 - 0.213 * s, 0.715 + 0.285 * s, 0.072 - 0.072 * s, 0, 0,\n 0.213 - 0.213 * s, 0.715 - 0.715 * s, 0.072 + 0.928 * s, 0, 0,\n 0, 0, 0, 1, 0,\n 0, 0, 0, 0, 1\n ];\n break;\n } case 'hueRotate': {\n const a = matrix[0] * Math.PI / 180.0;\n const c = function (m1, m2, m3) {\n return m1 + Math.cos(a) * m2 + Math.sin(a) * m3;\n };\n matrix = [\n c(0.213, 0.787, -0.213), c(0.715, -0.715, -0.715), c(0.072, -0.072, 0.928), 0, 0,\n c(0.213, -0.213, 0.143), c(0.715, 0.285, 0.140), c(0.072, -0.072, -0.283), 0, 0,\n c(0.213, -0.213, -0.787), c(0.715, -0.715, 0.715), c(0.072, 0.928, 0.072), 0, 0,\n 0, 0, 0, 1, 0,\n 0, 0, 0, 0, 1\n ];\n break;\n } case 'luminanceToAlpha':\n matrix = [\n 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0,\n 0.2125, 0.7154, 0.0721, 0, 0,\n 0, 0, 0, 0, 1\n ];\n break;\n }\n this.matrix = matrix;\n\n this._m = (i, v) => {\n const mi = matrix[i];\n return mi * (mi < 0 ? v - 255 : v);\n };\n }\n apply (ctx, x, y, width, height) {\n const {_m: m} = this;\n // assuming x==0 && y==0 for now\n const srcData = ctx.getImageData(0, 0, width, height);\n for (let _y = 0; _y < height; _y++) {\n for (let _x = 0; _x < width; _x++) {\n const r = imGet(srcData.data, _x, _y, width, height, 0);\n const g = imGet(srcData.data, _x, _y, width, height, 1);\n const b = imGet(srcData.data, _x, _y, width, height, 2);\n const a = imGet(srcData.data, _x, _y, width, height, 3);\n imSet(srcData.data, _x, _y, width, height, 0, m(0, r) + m(1, g) + m(2, b) + m(3, a) + m(4, 1));\n imSet(srcData.data, _x, _y, width, height, 1, m(5, r) + m(6, g) + m(7, b) + m(8, a) + m(9, 1));\n imSet(srcData.data, _x, _y, width, height, 2, m(10, r) + m(11, g) + m(12, b) + m(13, a) + m(14, 1));\n imSet(srcData.data, _x, _y, width, height, 3, m(15, r) + m(16, g) + m(17, b) + m(18, a) + m(19, 1));\n }\n }\n ctx.clearRect(0, 0, width, height);\n ctx.putImageData(srcData, 0, 0);\n }\n };\n\n svg.Element.feGaussianBlur = class extends svg.Element.ElementBase {\n constructor (node) {\n super(node);\n\n this.blurRadius = Math.floor(this.attribute('stdDeviation').numValue());\n this.extraFilterDistance = this.blurRadius;\n }\n\n apply (ctx, x, y, width, height) {\n // Todo: This might not be a problem anymore with out `instanceof` fix\n // StackBlur requires canvas be on document\n ctx.canvas.id = svg.UniqueId();\n ctx.canvas.style.display = 'none';\n document.body.append(ctx.canvas);\n canvasRGBA(ctx.canvas, x, y, width, height, this.blurRadius);\n ctx.canvas.remove();\n }\n };\n\n // title element, do nothing\n svg.Element.title = class extends svg.Element.ElementBase {\n constructor (node) {\n super();\n }\n };\n\n // desc element, do nothing\n svg.Element.desc = class extends svg.Element.ElementBase {\n constructor (node) {\n super();\n }\n };\n\n svg.Element.MISSING = class extends svg.Element.ElementBase {\n constructor (node) {\n super();\n svg.log('ERROR: Element \\'' + node.nodeName + '\\' not yet implemented.');\n }\n };\n\n // element factory\n svg.CreateElement = function (node) {\n const className = node.nodeName\n .replace(/^[^:]+:/, '') // remove namespace\n .replace(/-/g, ''); // remove dashes\n let e;\n if (typeof svg.Element[className] !== 'undefined') {\n e = new svg.Element[className](node);\n } else {\n e = new svg.Element.MISSING(node);\n }\n\n e.type = node.nodeName;\n return e;\n };\n\n // load from url\n svg.load = async function (ctx, url) {\n const dom = await svg.ajax(url, true);\n return svg.loadXml(ctx, dom);\n };\n\n // load from xml\n svg.loadXml = function (ctx, xml) {\n return svg.loadXmlDoc(ctx, svg.parseXml(xml));\n };\n\n svg.loadXmlDoc = function (ctx, dom) {\n let res;\n svg.init(ctx);\n\n const mapXY = function (p) {\n let e = ctx.canvas;\n while (e) {\n p.x -= e.offsetLeft;\n p.y -= e.offsetTop;\n e = e.offsetParent;\n }\n if (window.scrollX) p.x += window.scrollX;\n if (window.scrollY) p.y += window.scrollY;\n return p;\n };\n\n // bind mouse\n if (svg.opts.ignoreMouse !== true) {\n ctx.canvas.addEventListener('click', function (e) {\n const args = !isNullish(e)\n ? [e.clientX, e.clientY]\n : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals\n const {x, y} = mapXY(new svg.Point(...args));\n svg.Mouse.onclick(x, y);\n });\n ctx.canvas.addEventListener('mousemove', function (e) {\n const args = !isNullish(e)\n ? [e.clientX, e.clientY]\n : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals\n const {x, y} = mapXY(new svg.Point(...args));\n svg.Mouse.onmousemove(x, y);\n });\n }\n\n const e = svg.CreateElement(dom.documentElement);\n e.root = true;\n\n // render loop\n let isFirstRender = true;\n const draw = function (resolve) {\n svg.ViewPort.Clear();\n if (ctx.canvas.parentNode) {\n svg.ViewPort.SetCurrent(\n ctx.canvas.parentNode.clientWidth,\n ctx.canvas.parentNode.clientHeight\n );\n }\n\n if (svg.opts.ignoreDimensions !== true) {\n // set canvas size\n if (e.style('width').hasValue()) {\n ctx.canvas.width = e.style('width').toPixels('x');\n ctx.canvas.style.width = ctx.canvas.width + 'px';\n }\n if (e.style('height').hasValue()) {\n ctx.canvas.height = e.style('height').toPixels('y');\n ctx.canvas.style.height = ctx.canvas.height + 'px';\n }\n }\n let cWidth = ctx.canvas.clientWidth || ctx.canvas.width;\n let cHeight = ctx.canvas.clientHeight || ctx.canvas.height;\n if (svg.opts.ignoreDimensions === true &&\n e.style('width').hasValue() && e.style('height').hasValue()\n ) {\n cWidth = e.style('width').toPixels('x');\n cHeight = e.style('height').toPixels('y');\n }\n svg.ViewPort.SetCurrent(cWidth, cHeight);\n\n if (!isNullish(svg.opts.offsetX)) {\n e.attribute('x', true).value = svg.opts.offsetX;\n }\n if (!isNullish(svg.opts.offsetY)) {\n e.attribute('y', true).value = svg.opts.offsetY;\n }\n if (!isNullish(svg.opts.scaleWidth) || !isNullish(svg.opts.scaleHeight)) {\n const viewBox = svg.ToNumberArray(e.attribute('viewBox').value);\n let xRatio = null, yRatio = null;\n\n if (!isNullish(svg.opts.scaleWidth)) {\n if (e.attribute('width').hasValue()) {\n xRatio = e.attribute('width').toPixels('x') / svg.opts.scaleWidth;\n } else if (!isNaN(viewBox[2])) {\n xRatio = viewBox[2] / svg.opts.scaleWidth;\n }\n }\n\n if (!isNullish(svg.opts.scaleHeight)) {\n if (e.attribute('height').hasValue()) {\n yRatio = e.attribute('height').toPixels('y') / svg.opts.scaleHeight;\n } else if (!isNaN(viewBox[3])) {\n yRatio = viewBox[3] / svg.opts.scaleHeight;\n }\n }\n\n if (isNullish(xRatio)) { xRatio = yRatio; }\n if (isNullish(yRatio)) { yRatio = xRatio; }\n\n e.attribute('width', true).value = svg.opts.scaleWidth;\n e.attribute('height', true).value = svg.opts.scaleHeight;\n e.attribute('viewBox', true).value = '0 0 ' + (cWidth * xRatio) + ' ' + (cHeight * yRatio);\n e.attribute('preserveAspectRatio', true).value = 'none';\n }\n\n // clear and render\n if (svg.opts.ignoreClear !== true) {\n ctx.clearRect(0, 0, cWidth, cHeight);\n }\n e.render(ctx);\n if (isFirstRender) {\n isFirstRender = false;\n resolve(dom);\n }\n };\n\n let waitingForImages = true;\n svg.intervalID = setInterval(function () {\n let needUpdate = false;\n\n if (waitingForImages && svg.ImagesLoaded()) {\n waitingForImages = false;\n needUpdate = true;\n }\n\n // need update from mouse events?\n if (svg.opts.ignoreMouse !== true) {\n needUpdate = needUpdate || svg.Mouse.hasEvents();\n }\n\n // need update from animations?\n if (svg.opts.ignoreAnimation !== true) {\n svg.Animations.forEach((animation) => {\n const needAnimationUpdate = animation.update(1000 / svg.FRAMERATE);\n needUpdate = needUpdate || needAnimationUpdate;\n });\n }\n\n // need update from redraw?\n if (typeof svg.opts.forceRedraw === 'function') {\n if (svg.opts.forceRedraw() === true) {\n needUpdate = true;\n }\n }\n\n // render if needed\n if (needUpdate) {\n draw(res);\n svg.Mouse.runEvents(); // run and clear our events\n }\n }, 1000 / svg.FRAMERATE);\n // Todo: Replace with an image loading Promise utility?\n // eslint-disable-next-line promise/avoid-new\n return new Promise((resolve, reject) => {\n if (svg.ImagesLoaded()) {\n waitingForImages = false;\n draw(resolve);\n return;\n }\n res = resolve;\n });\n };\n\n svg.stop = () => {\n if (svg.intervalID) {\n clearInterval(svg.intervalID);\n }\n };\n\n svg.Mouse = {\n events: [],\n hasEvents () { return this.events.length !== 0; },\n\n onclick (x, y) {\n this.events.push({\n type: 'onclick', x, y,\n run (e) { if (e.onclick) e.onclick(); }\n });\n },\n\n onmousemove (x, y) {\n this.events.push({\n type: 'onmousemove', x, y,\n run (e) { if (e.onmousemove) e.onmousemove(); }\n });\n },\n\n eventElements: [],\n\n checkPath (element, ctx) {\n this.events.forEach(({x, y}, i) => {\n if (ctx.isPointInPath && ctx.isPointInPath(x, y)) {\n this.eventElements[i] = element;\n }\n });\n },\n\n checkBoundingBox (element, bb) {\n this.events.forEach(({x, y}, i) => {\n if (bb.isPointInBox(x, y)) {\n this.eventElements[i] = element;\n }\n });\n },\n\n runEvents () {\n svg.ctx.canvas.style.cursor = '';\n\n this.events.forEach((e, i) => {\n let element = this.eventElements[i];\n while (element) {\n e.run(element);\n element = element.parent;\n }\n });\n\n // done running, clear\n this.events = [];\n this.eventElements = [];\n }\n };\n\n return svg;\n}\n\nif (typeof CanvasRenderingContext2D !== 'undefined') {\n CanvasRenderingContext2D.prototype.drawSvg = function (s, dx, dy, dw, dh) {\n canvg(this.canvas, s, {\n ignoreMouse: true,\n ignoreAnimation: true,\n ignoreDimensions: true,\n ignoreClear: true,\n offsetX: dx,\n offsetY: dy,\n scaleWidth: dw,\n scaleHeight: dh\n });\n };\n}\n","/**\n * @module jQueryPluginDBox\n */\n/**\n* @param {external:jQuery} $\n* @param {PlainObject} [strings]\n* @param {PlainObject} [strings.ok]\n* @param {PlainObject} [strings.cancel]\n* @returns {external:jQuery}\n*/\nexport default function jQueryPluginDBox ($, {\n ok: okString = 'Ok',\n cancel: cancelString = 'Cancel'\n} = {}) {\n // This sets up alternative dialog boxes. They mostly work the same way as\n // their UI counterparts, expect instead of returning the result, a callback\n // needs to be included that returns the result as its first parameter.\n // In the future we may want to add additional types of dialog boxes, since\n // they should be easy to handle this way.\n $('#dialog_container').draggable({\n cancel: '#dialog_content, #dialog_buttons *',\n containment: 'window'\n }).css('position', 'absolute');\n\n const box = $('#dialog_box'),\n btnHolder = $('#dialog_buttons'),\n dialogContent = $('#dialog_content');\n\n /**\n * @typedef {PlainObject} module:jQueryPluginDBox.PromiseResultObject\n * @property {string|true} response\n * @property {boolean} checked\n */\n\n /**\n * Resolves to `false` (if cancelled), for prompts and selects\n * without checkboxes, it resolves to the value of the form control. For other\n * types without checkboxes, it resolves to `true`. For checkboxes, it resolves\n * to an object with the `response` key containing the same value as the previous\n * mentioned (string or `true`) and a `checked` (boolean) property.\n * @typedef {Promise<boolean|string|module:jQueryPluginDBox.PromiseResultObject>} module:jQueryPluginDBox.ResultPromise\n */\n /**\n * @typedef {PlainObject} module:jQueryPluginDBox.SelectOption\n * @property {string} text\n * @property {string} value\n */\n /**\n * @typedef {PlainObject} module:jQueryPluginDBox.CheckboxInfo\n * @property {string} label Label for the checkbox\n * @property {string} value Value of the checkbox\n * @property {string} tooltip Tooltip on the checkbox label\n * @property {boolean} checked Whether the checkbox is checked by default\n */\n /**\n * Triggered upon a change of value for the select pull-down.\n * @callback module:jQueryPluginDBox.SelectChangeListener\n * @returns {void}\n */\n /**\n * Creates a dialog of the specified type with a given message\n * and any defaults and type-specific metadata. Returns a `Promise`\n * which resolves differently depending on whether the dialog\n * was cancelled or okayed (with the response and any checked state).\n * @param {\"alert\"|\"prompt\"|\"select\"|\"process\"} type\n * @param {string} msg\n * @param {string} [defaultVal]\n * @param {module:jQueryPluginDBox.SelectOption[]} [opts]\n * @param {module:jQueryPluginDBox.SelectChangeListener} [changeListener]\n * @param {module:jQueryPluginDBox.CheckboxInfo} [checkbox]\n * @returns {jQueryPluginDBox.ResultPromise}\n */\n function dbox (type, msg, defaultVal, opts, changeListener, checkbox) {\n dialogContent.html('<p>' + msg.replace(/\\n/g, '</p><p>') + '</p>')\n .toggleClass('prompt', (type === 'prompt'));\n btnHolder.empty();\n\n const ok = $('<input type=\"button\" data-ok=\"\" value=\"' + okString + '\">').appendTo(btnHolder);\n\n return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new\n if (type !== 'alert') {\n $('<input type=\"button\" value=\"' + cancelString + '\">')\n .appendTo(btnHolder)\n .click(function () {\n box.hide();\n resolve(false);\n });\n }\n\n let ctrl, chkbx;\n if (type === 'prompt') {\n ctrl = $('<input type=\"text\">').prependTo(btnHolder);\n ctrl.val(defaultVal || '');\n ctrl.bind('keydown', 'return', function () { ok.click(); });\n } else if (type === 'select') {\n const div = $('<div style=\"text-align:center;\">');\n ctrl = $(`<select aria-label=\"${msg}\">`).appendTo(div);\n if (checkbox) {\n const label = $('<label>').text(checkbox.label);\n chkbx = $('<input type=\"checkbox\">').appendTo(label);\n chkbx.val(checkbox.value);\n if (checkbox.tooltip) {\n label.attr('title', checkbox.tooltip);\n }\n chkbx.prop('checked', Boolean(checkbox.checked));\n div.append($('<div>').append(label));\n }\n $.each(opts || [], function (opt, val) {\n if (typeof val === 'object') {\n ctrl.append($('<option>').val(val.value).html(val.text));\n } else {\n ctrl.append($('<option>').html(val));\n }\n });\n dialogContent.append(div);\n if (defaultVal) {\n ctrl.val(defaultVal);\n }\n if (changeListener) {\n ctrl.bind('change', 'return', changeListener);\n }\n ctrl.bind('keydown', 'return', function () { ok.click(); });\n } else if (type === 'process') {\n ok.hide();\n }\n\n box.show();\n\n ok.click(function () {\n box.hide();\n const response = (type === 'prompt' || type === 'select') ? ctrl.val() : true;\n if (chkbx) {\n resolve({response, checked: chkbx.prop('checked')});\n return;\n }\n resolve(response);\n }).focus();\n\n if (type === 'prompt' || type === 'select') {\n ctrl.focus();\n }\n });\n }\n\n /**\n * @param {string} msg Message to alert\n * @returns {jQueryPluginDBox.ResultPromise}\n */\n $.alert = function (msg) {\n return dbox('alert', msg);\n };\n /**\n * @param {string} msg Message for which to ask confirmation\n * @returns {jQueryPluginDBox.ResultPromise}\n */\n $.confirm = function (msg) {\n return dbox('confirm', msg);\n };\n /**\n * @param {string} msg Message to indicate upon cancelable indicator\n * @returns {jQueryPluginDBox.ResultPromise}\n */\n $.process_cancel = function (msg) {\n return dbox('process', msg);\n };\n /**\n * @param {string} msg Message to accompany the prompt\n * @param {string} [defaultText=''] The default text to show for the prompt\n * @returns {jQueryPluginDBox.ResultPromise}\n */\n $.prompt = function (msg, defaultText = '') {\n return dbox('prompt', msg, defaultText);\n };\n $.select = function (msg, opts, changeListener, txt, checkbox) {\n return dbox('select', msg, txt, opts, changeListener, checkbox);\n };\n return $;\n}\n","/* eslint-disable no-console */\n/**\n * For command history tracking and undo functionality.\n * @module history\n * @license MIT\n * @copyright 2010 Jeff Schiller\n */\n\nimport {getHref, setHref, getRotationAngle, isNullish} from '../common/utilities.js';\nimport {removeElementFromListMap} from '../common/svgtransformlist.js';\n\n/**\n* Group: Undo/Redo history management.\n*/\nexport const HistoryEventTypes = {\n BEFORE_APPLY: 'before_apply',\n AFTER_APPLY: 'after_apply',\n BEFORE_UNAPPLY: 'before_unapply',\n AFTER_UNAPPLY: 'after_unapply'\n};\n\n/**\n* Base class for commands.\n*/\nexport class Command {\n /**\n * @returns {string}\n */\n getText () {\n return this.text;\n }\n /**\n * @param {module:history.HistoryEventHandler} handler\n * @param {callback} applyFunction\n * @returns {void}\n */\n apply (handler, applyFunction) {\n handler && handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);\n applyFunction(handler);\n handler && handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);\n }\n\n /**\n * @param {module:history.HistoryEventHandler} handler\n * @param {callback} unapplyFunction\n * @returns {void}\n */\n unapply (handler, unapplyFunction) {\n handler && handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);\n unapplyFunction();\n handler && handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);\n }\n\n /**\n * @returns {Element[]} Array with element associated with this command\n * This function needs to be surcharged if multiple elements are returned.\n */\n elements () {\n return [this.elem];\n }\n\n /**\n * @returns {string} String with element associated with this command\n */\n type () {\n return this.constructor.name;\n }\n}\n\n// Todo: Figure out why the interface members aren't showing\n// up (with or without modules applied), despite our apparently following\n// http://usejsdoc.org/tags-interface.html#virtual-comments\n\n/**\n * An interface that all command objects must implement.\n * @interface module:history.HistoryCommand\n*/\n/**\n * Applies.\n *\n * @function module:history.HistoryCommand#apply\n * @param {module:history.HistoryEventHandler} handler\n * @fires module:history~Command#event:history\n * @returns {void|true}\n */\n/**\n *\n * Unapplies.\n * @function module:history.HistoryCommand#unapply\n * @param {module:history.HistoryEventHandler} handler\n * @fires module:history~Command#event:history\n * @returns {void|true}\n */\n/**\n * Returns the elements.\n * @function module:history.HistoryCommand#elements\n * @returns {Element[]}\n */\n/**\n * Gets the text.\n * @function module:history.HistoryCommand#getText\n * @returns {string}\n */\n/**\n * Gives the type.\n * @function module:history.HistoryCommand.type\n * @returns {string}\n */\n\n/**\n * @event module:history~Command#event:history\n * @type {module:history.HistoryCommand}\n */\n\n/**\n * An interface for objects that will handle history events.\n * @interface module:history.HistoryEventHandler\n */\n/**\n *\n * @function module:history.HistoryEventHandler#handleHistoryEvent\n * @param {string} eventType One of the HistoryEvent types\n * @param {module:history~Command#event:history} command\n * @listens module:history~Command#event:history\n * @returns {void}\n *\n */\n\n/**\n * History command for an element that had its DOM position changed.\n * @implements {module:history.HistoryCommand}\n*/\nexport class MoveElementCommand extends Command {\n /**\n * @param {Element} elem - The DOM element that was moved\n * @param {Element} oldNextSibling - The element's next sibling before it was moved\n * @param {Element} oldParent - The element's parent before it was moved\n * @param {string} [text] - An optional string visible to user related to this change\n */\n constructor (elem, oldNextSibling, oldParent, text) {\n super();\n this.elem = elem;\n this.text = text ? ('Move ' + elem.tagName + ' to ' + text) : ('Move ' + elem.tagName);\n this.oldNextSibling = oldNextSibling;\n this.oldParent = oldParent;\n this.newNextSibling = elem.nextSibling;\n this.newParent = elem.parentNode;\n }\n\n /**\n * Re-positions the element.\n * @param {module:history.HistoryEventHandler} handler\n * @fires module:history~Command#event:history\n * @returns {void}\n */\n apply (handler) {\n super.apply(handler, () => {\n this.elem = this.newParent.insertBefore(this.elem, this.newNextSibling);\n });\n }\n\n /**\n * Positions the element back to its original location.\n * @param {module:history.HistoryEventHandler} handler\n * @fires module:history~Command#event:history\n * @returns {void}\n */\n unapply (handler) {\n super.unapply(handler, () => {\n this.elem = this.oldParent.insertBefore(this.elem, this.oldNextSibling);\n });\n }\n}\n\n/**\n* History command for an element that was added to the DOM.\n* @implements {module:history.HistoryCommand}\n*/\nexport class InsertElementCommand extends Command {\n /**\n * @param {Element} elem - The newly added DOM element\n * @param {string} text - An optional string visible to user related to this change\n */\n constructor (elem, text) {\n super();\n this.elem = elem;\n this.text = text || ('Create ' + elem.tagName);\n this.parent = elem.parentNode;\n this.nextSibling = this.elem.nextSibling;\n }\n\n /**\n * Re-inserts the new element.\n * @param {module:history.HistoryEventHandler} handler\n * @fires module:history~Command#event:history\n * @returns {void}\n */\n apply (handler) {\n super.apply(handler, () => {\n this.elem = this.parent.insertBefore(this.elem, this.nextSibling);\n });\n }\n\n /**\n * Removes the element.\n * @param {module:history.HistoryEventHandler} handler\n * @fires module:history~Command#event:history\n * @returns {void}\n */\n unapply (handler) {\n super.unapply(handler, () => {\n this.parent = this.elem.parentNode;\n this.elem.remove();\n });\n }\n}\n\n/**\n* History command for an element removed from the DOM.\n* @implements {module:history.HistoryCommand}\n*/\nexport class RemoveElementCommand extends Command {\n /**\n * @param {Element} elem - The removed DOM element\n * @param {Node} oldNextSibling - The DOM element's nextSibling when it was in the DOM\n * @param {Element} oldParent - The DOM element's parent\n * @param {string} [text] - An optional string visible to user related to this change\n */\n constructor (elem, oldNextSibling, oldParent, text) {\n super();\n this.elem = elem;\n this.text = text || ('Delete ' + elem.tagName);\n this.nextSibling = oldNextSibling;\n this.parent = oldParent;\n\n // special hack for webkit: remove this element's entry in the svgTransformLists map\n removeElementFromListMap(elem);\n }\n\n /**\n * Re-removes the new element.\n * @param {module:history.HistoryEventHandler} handler\n * @fires module:history~Command#event:history\n * @returns {void}\n */\n apply (handler) {\n super.apply(handler, () => {\n removeElementFromListMap(this.elem);\n this.parent = this.elem.parentNode;\n this.elem.remove();\n });\n }\n\n /**\n * Re-adds the new element.\n * @param {module:history.HistoryEventHandler} handler\n * @fires module:history~Command#event:history\n * @returns {void}\n */\n unapply (handler) {\n super.unapply(handler, () => {\n removeElementFromListMap(this.elem);\n if (isNullish(this.nextSibling)) {\n if (window.console) {\n console.error('Reference element was lost');\n }\n }\n this.parent.insertBefore(this.elem, this.nextSibling); // Don't use `before` or `prepend` as `this.nextSibling` may be `null`\n });\n }\n}\n\n/**\n* @typedef {\"#text\"|\"#href\"|string} module:history.CommandAttributeName\n*/\n/**\n* @typedef {PlainObject<module:history.CommandAttributeName, string>} module:history.CommandAttributes\n*/\n\n/**\n* History command to make a change to an element.\n* Usually an attribute change, but can also be textcontent.\n* @implements {module:history.HistoryCommand}\n*/\nexport class ChangeElementCommand extends Command {\n /**\n * @param {Element} elem - The DOM element that was changed\n * @param {module:history.CommandAttributes} attrs - Attributes to be changed with the values they had *before* the change\n * @param {string} text - An optional string visible to user related to this change\n */\n constructor (elem, attrs, text) {\n super();\n this.elem = elem;\n this.text = text ? ('Change ' + elem.tagName + ' ' + text) : ('Change ' + elem.tagName);\n this.newValues = {};\n this.oldValues = attrs;\n for (const attr in attrs) {\n if (attr === '#text') {\n this.newValues[attr] = elem.textContent;\n } else if (attr === '#href') {\n this.newValues[attr] = getHref(elem);\n } else {\n this.newValues[attr] = elem.getAttribute(attr);\n }\n }\n }\n\n /**\n * Performs the stored change action.\n * @param {module:history.HistoryEventHandler} handler\n * @fires module:history~Command#event:history\n * @returns {void}\n */\n apply (handler) {\n super.apply(handler, () => {\n let bChangedTransform = false;\n Object.entries(this.newValues).forEach(([attr, value]) => {\n if (value) {\n if (attr === '#text') {\n this.elem.textContent = value;\n } else if (attr === '#href') {\n setHref(this.elem, value);\n } else {\n this.elem.setAttribute(attr, value);\n }\n } else if (attr === '#text') {\n this.elem.textContent = '';\n } else {\n this.elem.setAttribute(attr, '');\n this.elem.removeAttribute(attr);\n }\n\n if (attr === 'transform') { bChangedTransform = true; }\n });\n\n // relocate rotational transform, if necessary\n if (!bChangedTransform) {\n const angle = getRotationAngle(this.elem);\n if (angle) {\n const bbox = this.elem.getBBox();\n const cx = bbox.x + bbox.width / 2;\n const cy = bbox.y + bbox.height / 2;\n const rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');\n if (rotate !== this.elem.getAttribute('transform')) {\n this.elem.setAttribute('transform', rotate);\n }\n }\n }\n });\n }\n\n /**\n * Reverses the stored change action.\n * @param {module:history.HistoryEventHandler} handler\n * @fires module:history~Command#event:history\n * @returns {void}\n */\n unapply (handler) {\n super.unapply(handler, () => {\n let bChangedTransform = false;\n Object.entries(this.oldValues).forEach(([attr, value]) => {\n if (value) {\n if (attr === '#text') {\n this.elem.textContent = value;\n } else if (attr === '#href') {\n setHref(this.elem, value);\n } else {\n this.elem.setAttribute(attr, value);\n }\n } else if (attr === '#text') {\n this.elem.textContent = '';\n } else {\n this.elem.removeAttribute(attr);\n }\n if (attr === 'transform') { bChangedTransform = true; }\n });\n // relocate rotational transform, if necessary\n if (!bChangedTransform) {\n const angle = getRotationAngle(this.elem);\n if (angle) {\n const bbox = this.elem.getBBox();\n const cx = bbox.x + bbox.width / 2,\n cy = bbox.y + bbox.height / 2;\n const rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');\n if (rotate !== this.elem.getAttribute('transform')) {\n this.elem.setAttribute('transform', rotate);\n }\n }\n }\n // Remove transformlist to prevent confusion that causes bugs like 575.\n removeElementFromListMap(this.elem);\n });\n }\n}\n\n// TODO: create a 'typing' command object that tracks changes in text\n// if a new Typing command is created and the top command on the stack is also a Typing\n// and they both affect the same element, then collapse the two commands into one\n\n/**\n* History command that can contain/execute multiple other commands.\n* @implements {module:history.HistoryCommand}\n*/\nexport class BatchCommand extends Command {\n /**\n * @param {string} [text] - An optional string visible to user related to this change\n */\n constructor (text) {\n super();\n this.text = text || 'Batch Command';\n this.stack = [];\n }\n\n /**\n * Runs \"apply\" on all subcommands.\n * @param {module:history.HistoryEventHandler} handler\n * @fires module:history~Command#event:history\n * @returns {void}\n */\n apply (handler) {\n super.apply(handler, () => {\n this.stack.forEach((stackItem) => {\n console.assert(stackItem, 'stack item should not be null');\n stackItem && stackItem.apply(handler);\n });\n });\n }\n\n /**\n * Runs \"unapply\" on all subcommands.\n * @param {module:history.HistoryEventHandler} handler\n * @fires module:history~Command#event:history\n * @returns {void}\n */\n unapply (handler) {\n super.unapply(handler, () => {\n this.stack.reverse().forEach((stackItem) => {\n console.assert(stackItem, 'stack item should not be null');\n stackItem && stackItem.unapply(handler);\n });\n });\n }\n\n /**\n * Iterate through all our subcommands.\n * @returns {Element[]} All the elements we are changing\n */\n elements () {\n const elems = [];\n let cmd = this.stack.length;\n while (cmd--) {\n if (!this.stack[cmd]) continue;\n const thisElems = this.stack[cmd].elements();\n let elem = thisElems.length;\n while (elem--) {\n if (!elems.includes(thisElems[elem])) { elems.push(thisElems[elem]); }\n }\n }\n return elems;\n }\n\n /**\n * Adds a given command to the history stack.\n * @param {Command} cmd - The undo command object to add\n * @returns {void}\n */\n addSubCommand (cmd) {\n console.assert(cmd !== null, 'cmd should not be null');\n this.stack.push(cmd);\n }\n\n /**\n * @returns {boolean} Indicates whether or not the batch command is empty\n */\n isEmpty () {\n return !this.stack.length;\n }\n}\n\n/**\n*\n*/\nexport class UndoManager {\n /**\n * @param {module:history.HistoryEventHandler} historyEventHandler\n */\n constructor (historyEventHandler) {\n this.handler_ = historyEventHandler || null;\n this.undoStackPointer = 0;\n this.undoStack = [];\n\n // this is the stack that stores the original values, the elements and\n // the attribute name for begin/finish\n this.undoChangeStackPointer = -1;\n this.undoableChangeStack = [];\n }\n\n /**\n * Resets the undo stack, effectively clearing the undo/redo history.\n * @returns {void}\n */\n resetUndoStack () {\n this.undoStack = [];\n this.undoStackPointer = 0;\n }\n\n /**\n * @returns {Integer} Current size of the undo history stack\n */\n getUndoStackSize () {\n return this.undoStackPointer;\n }\n\n /**\n * @returns {Integer} Current size of the redo history stack\n */\n getRedoStackSize () {\n return this.undoStack.length - this.undoStackPointer;\n }\n\n /**\n * @returns {string} String associated with the next undo command\n */\n getNextUndoCommandText () {\n return this.undoStackPointer > 0 ? this.undoStack[this.undoStackPointer - 1].getText() : '';\n }\n\n /**\n * @returns {string} String associated with the next redo command\n */\n getNextRedoCommandText () {\n return this.undoStackPointer < this.undoStack.length ? this.undoStack[this.undoStackPointer].getText() : '';\n }\n\n /**\n * Performs an undo step.\n * @returns {void}\n */\n undo () {\n if (this.undoStackPointer > 0) {\n const cmd = this.undoStack[--this.undoStackPointer];\n cmd.unapply(this.handler_);\n }\n }\n\n /**\n * Performs a redo step.\n * @returns {void}\n */\n redo () {\n if (this.undoStackPointer < this.undoStack.length && this.undoStack.length > 0) {\n const cmd = this.undoStack[this.undoStackPointer++];\n cmd.apply(this.handler_);\n }\n }\n\n /**\n * Adds a command object to the undo history stack.\n * @param {Command} cmd - The command object to add\n * @returns {void}\n */\n addCommandToHistory (cmd) {\n // TODO: we MUST compress consecutive text changes to the same element\n // (right now each keystroke is saved as a separate command that includes the\n // entire text contents of the text element)\n // TODO: consider limiting the history that we store here (need to do some slicing)\n\n // if our stack pointer is not at the end, then we have to remove\n // all commands after the pointer and insert the new command\n if (this.undoStackPointer < this.undoStack.length && this.undoStack.length > 0) {\n this.undoStack = this.undoStack.splice(0, this.undoStackPointer);\n }\n this.undoStack.push(cmd);\n this.undoStackPointer = this.undoStack.length;\n }\n\n /**\n * This function tells the canvas to remember the old values of the\n * `attrName` attribute for each element sent in. The elements and values\n * are stored on a stack, so the next call to `finishUndoableChange()` will\n * pop the elements and old values off the stack, gets the current values\n * from the DOM and uses all of these to construct the undo-able command.\n * @param {string} attrName - The name of the attribute being changed\n * @param {Element[]} elems - Array of DOM elements being changed\n * @returns {void}\n */\n beginUndoableChange (attrName, elems) {\n const p = ++this.undoChangeStackPointer;\n let i = elems.length;\n const oldValues = new Array(i), elements = new Array(i);\n while (i--) {\n const elem = elems[i];\n if (isNullish(elem)) { continue; }\n elements[i] = elem;\n oldValues[i] = elem.getAttribute(attrName);\n }\n this.undoableChangeStack[p] = {\n attrName,\n oldValues,\n elements\n };\n }\n\n /**\n * This function returns a `BatchCommand` object which summarizes the\n * change since `beginUndoableChange` was called. The command can then\n * be added to the command history.\n * @returns {BatchCommand} Batch command object with resulting changes\n */\n finishUndoableChange () {\n const p = this.undoChangeStackPointer--;\n const changeset = this.undoableChangeStack[p];\n const {attrName} = changeset;\n const batchCmd = new BatchCommand('Change ' + attrName);\n let i = changeset.elements.length;\n while (i--) {\n const elem = changeset.elements[i];\n if (isNullish(elem)) { continue; }\n const changes = {};\n changes[attrName] = changeset.oldValues[i];\n if (changes[attrName] !== elem.getAttribute(attrName)) {\n batchCmd.addSubCommand(new ChangeElementCommand(elem, changes, attrName));\n }\n }\n this.undoableChangeStack[p] = null;\n return batchCmd;\n }\n}\n","/* globals jQuery */\n/**\n * Path functionality.\n * @module path\n * @license MIT\n *\n * @copyright 2011 Alexis Deveria, 2011 Jeff Schiller\n */\n\nimport '../common/svgpathseg.js';\nimport {NS} from '../common/namespaces.js';\nimport {getTransformList} from '../common/svgtransformlist.js';\nimport {shortFloat} from '../common/units.js';\nimport {ChangeElementCommand, BatchCommand} from './history.js';\nimport {\n transformPoint, getMatrix, snapToAngle, rectsIntersect,\n transformListToTransform\n} from '../common/math.js';\nimport {\n assignAttributes, getElem, getRotationAngle, getBBox,\n getRefElem, findDefs, snapToGrid, isNullish,\n getBBox as utilsGetBBox\n} from '../common/utilities.js';\nimport {\n supportsPathInsertItemBefore, supportsPathReplaceItem, isWebkit\n} from '../common/browser.js';\n\nconst $ = jQuery;\n\nconst segData = {\n 2: ['x', 'y'], // PATHSEG_MOVETO_ABS\n 4: ['x', 'y'], // PATHSEG_LINETO_ABS\n 6: ['x', 'y', 'x1', 'y1', 'x2', 'y2'], // PATHSEG_CURVETO_CUBIC_ABS\n 8: ['x', 'y', 'x1', 'y1'], // PATHSEG_CURVETO_QUADRATIC_ABS\n 10: ['x', 'y', 'r1', 'r2', 'angle', 'largeArcFlag', 'sweepFlag'], // PATHSEG_ARC_ABS\n 12: ['x'], // PATHSEG_LINETO_HORIZONTAL_ABS\n 14: ['y'], // PATHSEG_LINETO_VERTICAL_ABS\n 16: ['x', 'y', 'x2', 'y2'], // PATHSEG_CURVETO_CUBIC_SMOOTH_ABS\n 18: ['x', 'y'] // PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS\n};\n\n/**\n * @tutorial LocaleDocs\n * @typedef {module:locale.LocaleStrings|PlainObject} module:path.uiStrings\n * @property {PlainObject<string, string>} ui\n*/\n\nconst uiStrings = {};\n/**\n* @function module:path.setUiStrings\n* @param {module:path.uiStrings} strs\n* @returns {void}\n*/\nexport const setUiStrings = function (strs) {\n Object.assign(uiStrings, strs.ui);\n};\n\nlet pathFuncs = [];\n\nlet linkControlPts = true;\n\n// Stores references to paths via IDs.\n// TODO: Make this cross-document happy.\nlet pathData = {};\n\n/**\n* @function module:path.setLinkControlPoints\n* @param {boolean} lcp\n* @returns {void}\n*/\nexport const setLinkControlPoints = function (lcp) {\n linkControlPts = lcp;\n};\n\n/**\n * @name module:path.path\n * @type {null|module:path.Path}\n * @memberof module:path\n*/\nexport let path = null; // eslint-disable-line import/no-mutable-exports\n\nlet editorContext_ = null;\n\n/**\n* @external MouseEvent\n*/\n\n/**\n* Object with the following keys/values.\n* @typedef {PlainObject} module:path.SVGElementJSON\n* @property {string} element - Tag name of the SVG element to create\n* @property {PlainObject<string, string>} attr - Has key-value attributes to assign to the new element. An `id` should be set so that {@link module:utilities.EditorContext#addSVGElementFromJson} can later re-identify the element for modification or replacement.\n* @property {boolean} [curStyles=false] - Indicates whether current style attributes should be applied first\n* @property {module:path.SVGElementJSON[]} [children] - Data objects to be added recursively as children\n* @property {string} [namespace=\"http://www.w3.org/2000/svg\"] - Indicate a (non-SVG) namespace\n*/\n/**\n * @interface module:path.EditorContext\n * @property {module:select.SelectorManager} selectorManager\n * @property {module:svgcanvas.SvgCanvas} canvas\n */\n/**\n * @function module:path.EditorContext#call\n * @param {\"selected\"|\"changed\"} ev - String with the event name\n * @param {module:svgcanvas.SvgCanvas#event:selected|module:svgcanvas.SvgCanvas#event:changed} arg - Argument to pass through to the callback function. If the event is \"changed\", an array of `Element`s is passed; if \"selected\", a single-item array of `Element` is passed.\n * @returns {void}\n */\n/**\n * @function module:path.EditorContext#resetD\n * @param {SVGPathElement} p\n * @returns {void}\n*/\n/**\n * Note: This doesn't round to an integer necessarily.\n * @function module:path.EditorContext#round\n * @param {Float} val\n * @returns {Float} Rounded value to nearest value based on `currentZoom`\n */\n/**\n * @function module:path.EditorContext#clearSelection\n * @param {boolean} [noCall] - When `true`, does not call the \"selected\" handler\n * @returns {void}\n*/\n/**\n * @function module:path.EditorContext#addToSelection\n * @param {Element[]} elemsToAdd - An array of DOM elements to add to the selection\n * @param {boolean} showGrips - Indicates whether the resize grips should be shown\n * @returns {void}\n*/\n/**\n * @function module:path.EditorContext#addCommandToHistory\n * @param {Command} cmd\n * @returns {void}\n */\n/**\n * @function module:path.EditorContext#remapElement\n * @param {Element} selected - DOM element to be changed\n * @param {PlainObject<string, string>} changes - Object with changes to be remapped\n * @param {SVGMatrix} m - Matrix object to use for remapping coordinates\n * @returns {void}\n */\n/**\n * @function module:path.EditorContext#addSVGElementFromJson\n * @param {module:path.SVGElementJSON} data\n * @returns {Element} The new element\n*/\n/**\n * @function module:path.EditorContext#getGridSnapping\n * @returns {boolean}\n */\n/**\n * @function module:path.EditorContext#getOpacity\n * @returns {Float}\n */\n/**\n * @function module:path.EditorContext#getSelectedElements\n * @returns {Element[]} the array with selected DOM elements\n*/\n/**\n * @function module:path.EditorContext#getContainer\n * @returns {Element}\n */\n/**\n * @function module:path.EditorContext#setStarted\n * @param {boolean} s\n * @returns {void}\n */\n/**\n * @function module:path.EditorContext#getRubberBox\n * @returns {SVGRectElement}\n*/\n/**\n * @function module:path.EditorContext#setRubberBox\n * @param {SVGRectElement} rb\n * @returns {SVGRectElement} Same as parameter passed in\n */\n/**\n * @function module:path.EditorContext#addPtsToSelection\n * @param {PlainObject} cfg\n * @param {boolean} cfg.closedSubpath\n * @param {SVGCircleElement[]} cfg.grips\n * @returns {void}\n */\n/**\n * @function module:path.EditorContext#endChanges\n * @param {PlainObject} cfg\n * @param {string} cfg.cmd\n * @param {Element} cfg.elem\n * @returns {void}\n*/\n/**\n * @function module:path.EditorContext#getCurrentZoom\n * @returns {Float} The current zoom level\n */\n/**\n * Returns the last created DOM element ID string.\n * @function module:path.EditorContext#getId\n * @returns {string}\n */\n/**\n * Creates and returns a unique ID string for a DOM element.\n * @function module:path.EditorContext#getNextId\n * @returns {string}\n*/\n/**\n * Gets the desired element from a mouse event.\n * @function module:path.EditorContext#getMouseTarget\n * @param {external:MouseEvent} evt - Event object from the mouse event\n * @returns {Element} DOM element we want\n */\n/**\n * @function module:path.EditorContext#getCurrentMode\n * @returns {string}\n */\n/**\n * @function module:path.EditorContext#setCurrentMode\n * @param {string} cm The mode\n * @returns {string} The same mode as passed in\n*/\n/**\n * @function module:path.EditorContext#getDrawnPath\n * @returns {SVGPathElement|null}\n */\n/**\n * @function module:path.EditorContext#setDrawnPath\n * @param {SVGPathElement|null} dp\n * @returns {SVGPathElement|null} The same value as passed in\n */\n/**\n * @function module:path.EditorContext#getSVGRoot\n * @returns {SVGSVGElement}\n*/\n\n/**\n* @function module:path.init\n* @param {module:path.EditorContext} editorContext\n* @returns {void}\n*/\nexport const init = function (editorContext) {\n editorContext_ = editorContext;\n\n pathFuncs = [0, 'ClosePath'];\n const pathFuncsStrs = [\n 'Moveto', 'Lineto', 'CurvetoCubic', 'CurvetoQuadratic', 'Arc',\n 'LinetoHorizontal', 'LinetoVertical', 'CurvetoCubicSmooth', 'CurvetoQuadraticSmooth'\n ];\n $.each(pathFuncsStrs, function (i, s) {\n pathFuncs.push(s + 'Abs');\n pathFuncs.push(s + 'Rel');\n });\n};\n\n/**\n* @function module:path.insertItemBefore\n* @param {Element} elem\n* @param {Segment} newseg\n* @param {Integer} index\n* @returns {void}\n*/\nexport const insertItemBefore = function (elem, newseg, index) {\n // Support insertItemBefore on paths for FF2\n const list = elem.pathSegList;\n\n if (supportsPathInsertItemBefore()) {\n list.insertItemBefore(newseg, index);\n return;\n }\n const len = list.numberOfItems;\n const arr = [];\n for (let i = 0; i < len; i++) {\n const curSeg = list.getItem(i);\n arr.push(curSeg);\n }\n list.clear();\n for (let i = 0; i < len; i++) {\n if (i === index) { // index + 1\n list.appendItem(newseg);\n }\n list.appendItem(arr[i]);\n }\n};\n\n/**\n* @function module:path.ptObjToArr\n* @todo See if this should just live in `replacePathSeg`\n* @param {string} type\n* @param {SVGPathSegMovetoAbs|SVGPathSegLinetoAbs|SVGPathSegCurvetoCubicAbs|SVGPathSegCurvetoQuadraticAbs|SVGPathSegArcAbs|SVGPathSegLinetoHorizontalAbs|SVGPathSegLinetoVerticalAbs|SVGPathSegCurvetoCubicSmoothAbs|SVGPathSegCurvetoQuadraticSmoothAbs} segItem\n* @returns {ArgumentsArray}\n*/\nexport const ptObjToArr = function (type, segItem) {\n const props = segData[type];\n return props.map((prop) => {\n return segItem[prop];\n });\n};\n\n/**\n* @function module:path.getGripPt\n* @param {Segment} seg\n* @param {module:math.XYObject} altPt\n* @returns {module:math.XYObject}\n*/\nexport const getGripPt = function (seg, altPt) {\n const {path: pth} = seg;\n let out = {\n x: altPt ? altPt.x : seg.item.x,\n y: altPt ? altPt.y : seg.item.y\n };\n\n if (pth.matrix) {\n const pt = transformPoint(out.x, out.y, pth.matrix);\n out = pt;\n }\n\n const currentZoom = editorContext_.getCurrentZoom();\n out.x *= currentZoom;\n out.y *= currentZoom;\n\n return out;\n};\n\n/**\n* @function module:path.getPointFromGrip\n* @param {module:math.XYObject} pt\n* @param {module:path.Path} pth\n* @returns {module:math.XYObject}\n*/\nexport const getPointFromGrip = function (pt, pth) {\n const out = {\n x: pt.x,\n y: pt.y\n };\n\n if (pth.matrix) {\n pt = transformPoint(out.x, out.y, pth.imatrix);\n out.x = pt.x;\n out.y = pt.y;\n }\n\n const currentZoom = editorContext_.getCurrentZoom();\n out.x /= currentZoom;\n out.y /= currentZoom;\n\n return out;\n};\n\n/**\n* Requires prior call to `setUiStrings` if `xlink:title`\n* to be set on the grip.\n* @function module:path.addPointGrip\n* @param {Integer} index\n* @param {Integer} x\n* @param {Integer} y\n* @returns {SVGCircleElement}\n*/\nexport const addPointGrip = function (index, x, y) {\n // create the container of all the point grips\n const pointGripContainer = getGripContainer();\n\n let pointGrip = getElem('pathpointgrip_' + index);\n // create it\n if (!pointGrip) {\n pointGrip = document.createElementNS(NS.SVG, 'circle');\n const atts = {\n id: 'pathpointgrip_' + index,\n display: 'none',\n r: 4,\n fill: '#0FF',\n stroke: '#00F',\n 'stroke-width': 2,\n cursor: 'move',\n style: 'pointer-events:all'\n };\n if ('pathNodeTooltip' in uiStrings) { // May be empty if running path.js without svg-editor\n atts['xlink:title'] = uiStrings.pathNodeTooltip;\n }\n assignAttributes(pointGrip, atts);\n pointGrip = pointGripContainer.appendChild(pointGrip);\n\n const grip = $('#pathpointgrip_' + index);\n grip.dblclick(function () {\n if (path) {\n path.setSegType();\n }\n });\n }\n if (x && y) {\n // set up the point grip element and display it\n assignAttributes(pointGrip, {\n cx: x,\n cy: y,\n display: 'inline'\n });\n }\n return pointGrip;\n};\n\n/**\n* @function module:path.getGripContainer\n* @returns {Element}\n*/\nexport const getGripContainer = function () {\n let c = getElem('pathpointgrip_container');\n if (!c) {\n const parentElement = getElem('selectorParentGroup');\n c = parentElement.appendChild(document.createElementNS(NS.SVG, 'g'));\n c.id = 'pathpointgrip_container';\n }\n return c;\n};\n\n/**\n* Requires prior call to `setUiStrings` if `xlink:title`\n* to be set on the grip.\n* @function module:path.addCtrlGrip\n* @param {string} id\n* @returns {SVGCircleElement}\n*/\nexport const addCtrlGrip = function (id) {\n let pointGrip = getElem('ctrlpointgrip_' + id);\n if (pointGrip) { return pointGrip; }\n\n pointGrip = document.createElementNS(NS.SVG, 'circle');\n const atts = {\n id: 'ctrlpointgrip_' + id,\n display: 'none',\n r: 4,\n fill: '#0FF',\n stroke: '#55F',\n 'stroke-width': 1,\n cursor: 'move',\n style: 'pointer-events:all'\n };\n if ('pathCtrlPtTooltip' in uiStrings) { // May be empty if running path.js without svg-editor\n atts['xlink:title'] = uiStrings.pathCtrlPtTooltip;\n }\n assignAttributes(pointGrip, atts);\n getGripContainer().append(pointGrip);\n return pointGrip;\n};\n\n/**\n* @function module:path.getCtrlLine\n* @param {string} id\n* @returns {SVGLineElement}\n*/\nexport const getCtrlLine = function (id) {\n let ctrlLine = getElem('ctrlLine_' + id);\n if (ctrlLine) { return ctrlLine; }\n\n ctrlLine = document.createElementNS(NS.SVG, 'line');\n assignAttributes(ctrlLine, {\n id: 'ctrlLine_' + id,\n stroke: '#555',\n 'stroke-width': 1,\n style: 'pointer-events:none'\n });\n getGripContainer().append(ctrlLine);\n return ctrlLine;\n};\n\n/**\n* @function module:path.getPointGrip\n* @param {Segment} seg\n* @param {boolean} update\n* @returns {SVGCircleElement}\n*/\nexport const getPointGrip = function (seg, update) {\n const {index} = seg;\n const pointGrip = addPointGrip(index);\n\n if (update) {\n const pt = getGripPt(seg);\n assignAttributes(pointGrip, {\n cx: pt.x,\n cy: pt.y,\n display: 'inline'\n });\n }\n\n return pointGrip;\n};\n\n/**\n* @function module:path.getControlPoints\n* @param {Segment} seg\n* @returns {PlainObject<string, SVGLineElement|SVGCircleElement>}\n*/\nexport const getControlPoints = function (seg) {\n const {item, index} = seg;\n if (!('x1' in item) || !('x2' in item)) { return null; }\n const cpt = {};\n /* const pointGripContainer = */ getGripContainer();\n\n // Note that this is intentionally not seg.prev.item\n const prev = path.segs[index - 1].item;\n\n const segItems = [prev, item];\n\n for (let i = 1; i < 3; i++) {\n const id = index + 'c' + i;\n\n const ctrlLine = cpt['c' + i + '_line'] = getCtrlLine(id);\n\n const pt = getGripPt(seg, {x: item['x' + i], y: item['y' + i]});\n const gpt = getGripPt(seg, {x: segItems[i - 1].x, y: segItems[i - 1].y});\n\n assignAttributes(ctrlLine, {\n x1: pt.x,\n y1: pt.y,\n x2: gpt.x,\n y2: gpt.y,\n display: 'inline'\n });\n\n cpt['c' + i + '_line'] = ctrlLine;\n\n // create it\n const pointGrip = cpt['c' + i] = addCtrlGrip(id);\n\n assignAttributes(pointGrip, {\n cx: pt.x,\n cy: pt.y,\n display: 'inline'\n });\n cpt['c' + i] = pointGrip;\n }\n return cpt;\n};\n\n/**\n* This replaces the segment at the given index. Type is given as number.\n* @function module:path.replacePathSeg\n* @param {Integer} type Possible values set during {@link module:path.init}\n* @param {Integer} index\n* @param {ArgumentsArray} pts\n* @param {SVGPathElement} elem\n* @returns {void}\n*/\nexport const replacePathSeg = function (type, index, pts, elem) {\n const pth = elem || path.elem;\n\n const func = 'createSVGPathSeg' + pathFuncs[type];\n const seg = pth[func](...pts);\n\n if (supportsPathReplaceItem()) {\n pth.pathSegList.replaceItem(seg, index);\n } else {\n const segList = pth.pathSegList;\n const len = segList.numberOfItems;\n const arr = [];\n for (let i = 0; i < len; i++) {\n const curSeg = segList.getItem(i);\n arr.push(curSeg);\n }\n segList.clear();\n for (let i = 0; i < len; i++) {\n if (i === index) {\n segList.appendItem(seg);\n } else {\n segList.appendItem(arr[i]);\n }\n }\n }\n};\n\n/**\n* @function module:path.getSegSelector\n* @param {Segment} seg\n* @param {boolean} update\n* @returns {SVGPathElement}\n*/\nexport const getSegSelector = function (seg, update) {\n const {index} = seg;\n let segLine = getElem('segline_' + index);\n if (!segLine) {\n const pointGripContainer = getGripContainer();\n // create segline\n segLine = document.createElementNS(NS.SVG, 'path');\n assignAttributes(segLine, {\n id: 'segline_' + index,\n display: 'none',\n fill: 'none',\n stroke: '#0FF',\n 'stroke-width': 2,\n style: 'pointer-events:none',\n d: 'M0,0 0,0'\n });\n pointGripContainer.append(segLine);\n }\n\n if (update) {\n const {prev} = seg;\n if (!prev) {\n segLine.setAttribute('display', 'none');\n return segLine;\n }\n\n const pt = getGripPt(prev);\n // Set start point\n replacePathSeg(2, 0, [pt.x, pt.y], segLine);\n\n const pts = ptObjToArr(seg.type, seg.item); // , true);\n for (let i = 0; i < pts.length; i += 2) {\n const point = getGripPt(seg, {x: pts[i], y: pts[i + 1]});\n pts[i] = point.x;\n pts[i + 1] = point.y;\n }\n\n replacePathSeg(seg.type, 1, pts, segLine);\n }\n return segLine;\n};\n\n/**\n * @typedef {PlainObject} Point\n * @property {Integer} x The x value\n * @property {Integer} y The y value\n */\n\n/**\n* Takes three points and creates a smoother line based on them.\n* @function module:path.smoothControlPoints\n* @param {Point} ct1 - Object with x and y values (first control point)\n* @param {Point} ct2 - Object with x and y values (second control point)\n* @param {Point} pt - Object with x and y values (third point)\n* @returns {Point[]} Array of two \"smoothed\" point objects\n*/\nexport const smoothControlPoints = function (ct1, ct2, pt) {\n // each point must not be the origin\n const x1 = ct1.x - pt.x,\n y1 = ct1.y - pt.y,\n x2 = ct2.x - pt.x,\n y2 = ct2.y - pt.y;\n\n if ((x1 !== 0 || y1 !== 0) && (x2 !== 0 || y2 !== 0)) {\n const\n r1 = Math.sqrt(x1 * x1 + y1 * y1),\n r2 = Math.sqrt(x2 * x2 + y2 * y2),\n nct1 = editorContext_.getSVGRoot().createSVGPoint(),\n nct2 = editorContext_.getSVGRoot().createSVGPoint();\n let anglea = Math.atan2(y1, x1),\n angleb = Math.atan2(y2, x2);\n if (anglea < 0) { anglea += 2 * Math.PI; }\n if (angleb < 0) { angleb += 2 * Math.PI; }\n\n const angleBetween = Math.abs(anglea - angleb),\n angleDiff = Math.abs(Math.PI - angleBetween) / 2;\n\n let newAnglea, newAngleb;\n if (anglea - angleb > 0) {\n newAnglea = angleBetween < Math.PI ? (anglea + angleDiff) : (anglea - angleDiff);\n newAngleb = angleBetween < Math.PI ? (angleb - angleDiff) : (angleb + angleDiff);\n } else {\n newAnglea = angleBetween < Math.PI ? (anglea - angleDiff) : (anglea + angleDiff);\n newAngleb = angleBetween < Math.PI ? (angleb + angleDiff) : (angleb - angleDiff);\n }\n\n // rotate the points\n nct1.x = r1 * Math.cos(newAnglea) + pt.x;\n nct1.y = r1 * Math.sin(newAnglea) + pt.y;\n nct2.x = r2 * Math.cos(newAngleb) + pt.x;\n nct2.y = r2 * Math.sin(newAngleb) + pt.y;\n\n return [nct1, nct2];\n }\n return undefined;\n};\n\n/**\n*\n*/\nexport class Segment {\n /**\n * @param {Integer} index\n * @param {SVGPathSeg} item\n * @todo Is `item` be more constrained here?\n */\n constructor (index, item) {\n this.selected = false;\n this.index = index;\n this.item = item;\n this.type = item.pathSegType;\n\n this.ctrlpts = [];\n this.ptgrip = null;\n this.segsel = null;\n }\n\n /**\n * @param {boolean} y\n * @returns {void}\n */\n showCtrlPts (y) {\n for (const i in this.ctrlpts) {\n if ({}.hasOwnProperty.call(this.ctrlpts, i)) {\n this.ctrlpts[i].setAttribute('display', y ? 'inline' : 'none');\n }\n }\n }\n\n /**\n * @param {boolean} y\n * @returns {void}\n */\n selectCtrls (y) {\n $('#ctrlpointgrip_' + this.index + 'c1, #ctrlpointgrip_' + this.index + 'c2')\n .attr('fill', y ? '#0FF' : '#EEE');\n }\n\n /**\n * @param {boolean} y\n * @returns {void}\n */\n show (y) {\n if (this.ptgrip) {\n this.ptgrip.setAttribute('display', y ? 'inline' : 'none');\n this.segsel.setAttribute('display', y ? 'inline' : 'none');\n // Show/hide all control points if available\n this.showCtrlPts(y);\n }\n }\n\n /**\n * @param {boolean} y\n * @returns {void}\n */\n select (y) {\n if (this.ptgrip) {\n this.ptgrip.setAttribute('stroke', y ? '#0FF' : '#00F');\n this.segsel.setAttribute('display', y ? 'inline' : 'none');\n if (this.ctrlpts) {\n this.selectCtrls(y);\n }\n this.selected = y;\n }\n }\n\n /**\n * @returns {void}\n */\n addGrip () {\n this.ptgrip = getPointGrip(this, true);\n this.ctrlpts = getControlPoints(this); // , true);\n this.segsel = getSegSelector(this, true);\n }\n\n /**\n * @param {boolean} full\n * @returns {void}\n */\n update (full) {\n if (this.ptgrip) {\n const pt = getGripPt(this);\n assignAttributes(this.ptgrip, {\n cx: pt.x,\n cy: pt.y\n });\n\n getSegSelector(this, true);\n\n if (this.ctrlpts) {\n if (full) {\n this.item = path.elem.pathSegList.getItem(this.index);\n this.type = this.item.pathSegType;\n }\n getControlPoints(this);\n }\n // this.segsel.setAttribute('display', y ? 'inline' : 'none');\n }\n }\n\n /**\n * @param {Integer} dx\n * @param {Integer} dy\n * @returns {void}\n */\n move (dx, dy) {\n const {item} = this;\n\n const curPts = this.ctrlpts\n ? [\n item.x += dx, item.y += dy,\n item.x1, item.y1, item.x2 += dx, item.y2 += dy\n ]\n : [item.x += dx, item.y += dy];\n\n replacePathSeg(\n this.type,\n this.index,\n // type 10 means ARC\n this.type === 10 ? ptObjToArr(this.type, item) : curPts\n );\n\n if (this.next && this.next.ctrlpts) {\n const next = this.next.item;\n const nextPts = [\n next.x, next.y,\n next.x1 += dx, next.y1 += dy, next.x2, next.y2\n ];\n replacePathSeg(this.next.type, this.next.index, nextPts);\n }\n\n if (this.mate) {\n // The last point of a closed subpath has a 'mate',\n // which is the 'M' segment of the subpath\n const {item: itm} = this.mate;\n const pts = [itm.x += dx, itm.y += dy];\n replacePathSeg(this.mate.type, this.mate.index, pts);\n // Has no grip, so does not need 'updating'?\n }\n\n this.update(true);\n if (this.next) { this.next.update(true); }\n }\n\n /**\n * @param {Integer} num\n * @returns {void}\n */\n setLinked (num) {\n let seg, anum, pt;\n if (num === 2) {\n anum = 1;\n seg = this.next;\n if (!seg) { return; }\n pt = this.item;\n } else {\n anum = 2;\n seg = this.prev;\n if (!seg) { return; }\n pt = seg.item;\n }\n\n const {item} = seg;\n item['x' + anum] = pt.x + (pt.x - this.item['x' + num]);\n item['y' + anum] = pt.y + (pt.y - this.item['y' + num]);\n\n const pts = [\n item.x, item.y,\n item.x1, item.y1,\n item.x2, item.y2\n ];\n\n replacePathSeg(seg.type, seg.index, pts);\n seg.update(true);\n }\n\n /**\n * @param {Integer} num\n * @param {Integer} dx\n * @param {Integer} dy\n * @returns {void}\n */\n moveCtrl (num, dx, dy) {\n const {item} = this;\n item['x' + num] += dx;\n item['y' + num] += dy;\n\n const pts = [\n item.x, item.y,\n item.x1, item.y1, item.x2, item.y2\n ];\n\n replacePathSeg(this.type, this.index, pts);\n this.update(true);\n }\n\n /**\n * @param {Integer} newType Possible values set during {@link module:path.init}\n * @param {ArgumentsArray} pts\n * @returns {void}\n */\n setType (newType, pts) {\n replacePathSeg(newType, this.index, pts);\n this.type = newType;\n this.item = path.elem.pathSegList.getItem(this.index);\n this.showCtrlPts(newType === 6);\n this.ctrlpts = getControlPoints(this);\n this.update(true);\n }\n}\n\n/**\n*\n*/\nexport class Path {\n /**\n * @param {SVGPathElement} elem\n * @throws {Error} If constructed without a path element\n */\n constructor (elem) {\n if (!elem || elem.tagName !== 'path') {\n throw new Error('svgedit.path.Path constructed without a <path> element');\n }\n\n this.elem = elem;\n this.segs = [];\n this.selected_pts = [];\n path = this;\n\n this.init();\n }\n\n /**\n * Reset path data.\n * @returns {module:path.Path}\n */\n init () {\n // Hide all grips, etc\n\n // fixed, needed to work on all found elements, not just first\n $(getGripContainer()).find('*').each(function () {\n $(this).attr('display', 'none');\n });\n\n const segList = this.elem.pathSegList;\n const len = segList.numberOfItems;\n this.segs = [];\n this.selected_pts = [];\n this.first_seg = null;\n\n // Set up segs array\n for (let i = 0; i < len; i++) {\n const item = segList.getItem(i);\n const segment = new Segment(i, item);\n segment.path = this;\n this.segs.push(segment);\n }\n\n const {segs} = this;\n\n let startI = null;\n for (let i = 0; i < len; i++) {\n const seg = segs[i];\n const nextSeg = (i + 1) >= len ? null : segs[i + 1];\n const prevSeg = (i - 1) < 0 ? null : segs[i - 1];\n if (seg.type === 2) {\n if (prevSeg && prevSeg.type !== 1) {\n // New sub-path, last one is open,\n // so add a grip to last sub-path's first point\n const startSeg = segs[startI];\n startSeg.next = segs[startI + 1];\n startSeg.next.prev = startSeg;\n startSeg.addGrip();\n }\n // Remember that this is a starter seg\n startI = i;\n } else if (nextSeg && nextSeg.type === 1) {\n // This is the last real segment of a closed sub-path\n // Next is first seg after \"M\"\n seg.next = segs[startI + 1];\n\n // First seg after \"M\"'s prev is this\n seg.next.prev = seg;\n seg.mate = segs[startI];\n seg.addGrip();\n if (isNullish(this.first_seg)) {\n this.first_seg = seg;\n }\n } else if (!nextSeg) {\n if (seg.type !== 1) {\n // Last seg, doesn't close so add a grip\n // to last sub-path's first point\n const startSeg = segs[startI];\n startSeg.next = segs[startI + 1];\n startSeg.next.prev = startSeg;\n startSeg.addGrip();\n seg.addGrip();\n\n if (!this.first_seg) {\n // Open path, so set first as real first and add grip\n this.first_seg = segs[startI];\n }\n }\n } else if (seg.type !== 1) {\n // Regular segment, so add grip and its \"next\"\n seg.addGrip();\n\n // Don't set its \"next\" if it's an \"M\"\n if (nextSeg && nextSeg.type !== 2) {\n seg.next = nextSeg;\n seg.next.prev = seg;\n }\n }\n }\n return this;\n }\n\n /**\n * @callback module:path.PathEachSegCallback\n * @this module:path.Segment\n * @param {Integer} i The index of the seg being iterated\n * @returns {boolean|void} Will stop execution of `eachSeg` if returns `false`\n */\n /**\n * @param {module:path.PathEachSegCallback} fn\n * @returns {void}\n */\n eachSeg (fn) {\n const len = this.segs.length;\n for (let i = 0; i < len; i++) {\n const ret = fn.call(this.segs[i], i);\n if (ret === false) { break; }\n }\n }\n\n /**\n * @param {Integer} index\n * @returns {void}\n */\n addSeg (index) {\n // Adds a new segment\n const seg = this.segs[index];\n if (!seg.prev) { return; }\n\n const {prev} = seg;\n let newseg, newX, newY;\n switch (seg.item.pathSegType) {\n case 4: {\n newX = (seg.item.x + prev.item.x) / 2;\n newY = (seg.item.y + prev.item.y) / 2;\n newseg = this.elem.createSVGPathSegLinetoAbs(newX, newY);\n break;\n } case 6: { // make it a curved segment to preserve the shape (WRS)\n // https://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm#Geometric_interpretation\n const p0x = (prev.item.x + seg.item.x1) / 2;\n const p1x = (seg.item.x1 + seg.item.x2) / 2;\n const p2x = (seg.item.x2 + seg.item.x) / 2;\n const p01x = (p0x + p1x) / 2;\n const p12x = (p1x + p2x) / 2;\n newX = (p01x + p12x) / 2;\n const p0y = (prev.item.y + seg.item.y1) / 2;\n const p1y = (seg.item.y1 + seg.item.y2) / 2;\n const p2y = (seg.item.y2 + seg.item.y) / 2;\n const p01y = (p0y + p1y) / 2;\n const p12y = (p1y + p2y) / 2;\n newY = (p01y + p12y) / 2;\n newseg = this.elem.createSVGPathSegCurvetoCubicAbs(newX, newY, p0x, p0y, p01x, p01y);\n const pts = [seg.item.x, seg.item.y, p12x, p12y, p2x, p2y];\n replacePathSeg(seg.type, index, pts);\n break;\n }\n }\n\n insertItemBefore(this.elem, newseg, index);\n }\n\n /**\n * @param {Integer} index\n * @returns {void}\n */\n deleteSeg (index) {\n const seg = this.segs[index];\n const list = this.elem.pathSegList;\n\n seg.show(false);\n const {next} = seg;\n if (seg.mate) {\n // Make the next point be the \"M\" point\n const pt = [next.item.x, next.item.y];\n replacePathSeg(2, next.index, pt);\n\n // Reposition last node\n replacePathSeg(4, seg.index, pt);\n\n list.removeItem(seg.mate.index);\n } else if (!seg.prev) {\n // First node of open path, make next point the M\n // const {item} = seg;\n const pt = [next.item.x, next.item.y];\n replacePathSeg(2, seg.next.index, pt);\n list.removeItem(index);\n } else {\n list.removeItem(index);\n }\n }\n\n /**\n * @param {Integer} index\n * @returns {void}\n */\n removePtFromSelection (index) {\n const pos = this.selected_pts.indexOf(index);\n if (pos === -1) {\n return;\n }\n this.segs[index].select(false);\n this.selected_pts.splice(pos, 1);\n }\n\n /**\n * @returns {void}\n */\n clearSelection () {\n this.eachSeg(function () {\n // 'this' is the segment here\n this.select(false);\n });\n this.selected_pts = [];\n }\n\n /**\n * @returns {void}\n */\n storeD () {\n this.last_d = this.elem.getAttribute('d');\n }\n\n /**\n * @param {Integer} y\n * @returns {Path}\n */\n show (y) {\n // Shows this path's segment grips\n this.eachSeg(function () {\n // 'this' is the segment here\n this.show(y);\n });\n if (y) {\n this.selectPt(this.first_seg.index);\n }\n return this;\n }\n\n /**\n * Move selected points.\n * @param {Integer} dx\n * @param {Integer} dy\n * @returns {void}\n */\n movePts (dx, dy) {\n let i = this.selected_pts.length;\n while (i--) {\n const seg = this.segs[this.selected_pts[i]];\n seg.move(dx, dy);\n }\n }\n\n /**\n * @param {Integer} dx\n * @param {Integer} dy\n * @returns {void}\n */\n moveCtrl (dx, dy) {\n const seg = this.segs[this.selected_pts[0]];\n seg.moveCtrl(this.dragctrl, dx, dy);\n if (linkControlPts) {\n seg.setLinked(this.dragctrl);\n }\n }\n\n /**\n * @param {?Integer} newType See {@link https://www.w3.org/TR/SVG/single-page.html#paths-InterfaceSVGPathSeg}\n * @returns {void}\n */\n setSegType (newType) {\n this.storeD();\n let i = this.selected_pts.length;\n let text;\n while (i--) {\n const selPt = this.selected_pts[i];\n\n // Selected seg\n const cur = this.segs[selPt];\n const {prev} = cur;\n if (!prev) { continue; }\n\n if (!newType) { // double-click, so just toggle\n text = 'Toggle Path Segment Type';\n\n // Toggle segment to curve/straight line\n const oldType = cur.type;\n\n newType = (oldType === 6) ? 4 : 6;\n }\n\n newType = Number(newType);\n\n const curX = cur.item.x;\n const curY = cur.item.y;\n const prevX = prev.item.x;\n const prevY = prev.item.y;\n let points;\n switch (newType) {\n case 6: {\n if (cur.olditem) {\n const old = cur.olditem;\n points = [curX, curY, old.x1, old.y1, old.x2, old.y2];\n } else {\n const diffX = curX - prevX;\n const diffY = curY - prevY;\n // get control points from straight line segment\n /*\n const ct1x = (prevX + (diffY/2));\n const ct1y = (prevY - (diffX/2));\n const ct2x = (curX + (diffY/2));\n const ct2y = (curY - (diffX/2));\n */\n // create control points on the line to preserve the shape (WRS)\n const ct1x = (prevX + (diffX / 3));\n const ct1y = (prevY + (diffY / 3));\n const ct2x = (curX - (diffX / 3));\n const ct2y = (curY - (diffY / 3));\n points = [curX, curY, ct1x, ct1y, ct2x, ct2y];\n }\n break;\n } case 4: {\n points = [curX, curY];\n\n // Store original prevve segment nums\n cur.olditem = cur.item;\n break;\n }\n }\n\n cur.setType(newType, points);\n }\n path.endChanges(text);\n }\n\n /**\n * @param {Integer} pt\n * @param {Integer} ctrlNum\n * @returns {void}\n */\n selectPt (pt, ctrlNum) {\n this.clearSelection();\n if (isNullish(pt)) {\n this.eachSeg(function (i) {\n // 'this' is the segment here.\n if (this.prev) {\n pt = i;\n }\n });\n }\n this.addPtsToSelection(pt);\n if (ctrlNum) {\n this.dragctrl = ctrlNum;\n\n if (linkControlPts) {\n this.segs[pt].setLinked(ctrlNum);\n }\n }\n }\n\n /**\n * Update position of all points.\n * @returns {Path}\n */\n update () {\n const {elem} = this;\n if (getRotationAngle(elem)) {\n this.matrix = getMatrix(elem);\n this.imatrix = this.matrix.inverse();\n } else {\n this.matrix = null;\n this.imatrix = null;\n }\n\n this.eachSeg(function (i) {\n this.item = elem.pathSegList.getItem(i);\n this.update();\n });\n\n return this;\n }\n\n /**\n * @param {string} text\n * @returns {void}\n */\n endChanges (text) {\n if (isWebkit()) { editorContext_.resetD(this.elem); }\n const cmd = new ChangeElementCommand(this.elem, {d: this.last_d}, text);\n editorContext_.endChanges({cmd, elem: this.elem});\n }\n\n /**\n * @param {Integer|Integer[]} indexes\n * @returns {void}\n */\n addPtsToSelection (indexes) {\n if (!Array.isArray(indexes)) { indexes = [indexes]; }\n indexes.forEach((index) => {\n const seg = this.segs[index];\n if (seg.ptgrip) {\n if (!this.selected_pts.includes(index) && index >= 0) {\n this.selected_pts.push(index);\n }\n }\n });\n this.selected_pts.sort();\n let i = this.selected_pts.length;\n const grips = [];\n grips.length = i;\n // Loop through points to be selected and highlight each\n while (i--) {\n const pt = this.selected_pts[i];\n const seg = this.segs[pt];\n seg.select(true);\n grips[i] = seg.ptgrip;\n }\n\n const closedSubpath = Path.subpathIsClosed(this.selected_pts[0]);\n editorContext_.addPtsToSelection({grips, closedSubpath});\n }\n\n // STATIC\n /**\n * @param {Integer} index\n * @returns {boolean}\n */\n static subpathIsClosed (index) {\n let clsd = false;\n // Check if subpath is already open\n path.eachSeg(function (i) {\n if (i <= index) { return true; }\n if (this.type === 2) {\n // Found M first, so open\n return false;\n }\n if (this.type === 1) {\n // Found Z first, so closed\n clsd = true;\n return false;\n }\n return true;\n });\n\n return clsd;\n }\n}\n\n/**\n* @function module:path.getPath_\n* @param {SVGPathElement} elem\n* @returns {module:path.Path}\n*/\nexport const getPath_ = function (elem) {\n let p = pathData[elem.id];\n if (!p) {\n p = pathData[elem.id] = new Path(elem);\n }\n return p;\n};\n\n/**\n* @function module:path.removePath_\n* @param {string} id\n* @returns {void}\n*/\nexport const removePath_ = function (id) {\n if (id in pathData) { delete pathData[id]; }\n};\n\nlet newcx, newcy, oldcx, oldcy, angle;\n\nconst getRotVals = function (x, y) {\n let dx = x - oldcx;\n let dy = y - oldcy;\n\n // rotate the point around the old center\n let r = Math.sqrt(dx * dx + dy * dy);\n let theta = Math.atan2(dy, dx) + angle;\n dx = r * Math.cos(theta) + oldcx;\n dy = r * Math.sin(theta) + oldcy;\n\n // dx,dy should now hold the actual coordinates of each\n // point after being rotated\n\n // now we want to rotate them around the new center in the reverse direction\n dx -= newcx;\n dy -= newcy;\n\n r = Math.sqrt(dx * dx + dy * dy);\n theta = Math.atan2(dy, dx) - angle;\n\n return {x: r * Math.cos(theta) + newcx,\n y: r * Math.sin(theta) + newcy};\n};\n\n// If the path was rotated, we must now pay the piper:\n// Every path point must be rotated into the rotated coordinate system of\n// its old center, then determine the new center, then rotate it back\n// This is because we want the path to remember its rotation\n\n/**\n* @function module:path.recalcRotatedPath\n* @todo This is still using ye olde transform methods, can probably\n* be optimized or even taken care of by `recalculateDimensions`\n* @returns {void}\n*/\nexport const recalcRotatedPath = function () {\n const currentPath = path.elem;\n angle = getRotationAngle(currentPath, true);\n if (!angle) { return; }\n // selectedBBoxes[0] = path.oldbbox;\n const oldbox = path.oldbbox; // selectedBBoxes[0],\n oldcx = oldbox.x + oldbox.width / 2;\n oldcy = oldbox.y + oldbox.height / 2;\n const box = getBBox(currentPath);\n newcx = box.x + box.width / 2;\n newcy = box.y + box.height / 2;\n\n // un-rotate the new center to the proper position\n const dx = newcx - oldcx,\n dy = newcy - oldcy,\n r = Math.sqrt(dx * dx + dy * dy),\n theta = Math.atan2(dy, dx) + angle;\n\n newcx = r * Math.cos(theta) + oldcx;\n newcy = r * Math.sin(theta) + oldcy;\n\n const list = currentPath.pathSegList;\n\n let i = list.numberOfItems;\n while (i) {\n i -= 1;\n const seg = list.getItem(i),\n type = seg.pathSegType;\n if (type === 1) { continue; }\n\n const rvals = getRotVals(seg.x, seg.y),\n points = [rvals.x, rvals.y];\n if (!isNullish(seg.x1) && !isNullish(seg.x2)) {\n const cVals1 = getRotVals(seg.x1, seg.y1);\n const cVals2 = getRotVals(seg.x2, seg.y2);\n points.splice(points.length, 0, cVals1.x, cVals1.y, cVals2.x, cVals2.y);\n }\n replacePathSeg(type, i, points);\n } // loop for each point\n\n /* box = */ getBBox(currentPath);\n // selectedBBoxes[0].x = box.x; selectedBBoxes[0].y = box.y;\n // selectedBBoxes[0].width = box.width; selectedBBoxes[0].height = box.height;\n\n // now we must set the new transform to be rotated around the new center\n const Rnc = editorContext_.getSVGRoot().createSVGTransform(),\n tlist = getTransformList(currentPath);\n Rnc.setRotate((angle * 180.0 / Math.PI), newcx, newcy);\n tlist.replaceItem(Rnc, 0);\n};\n\n// ====================================\n// Public API starts here\n\n/**\n* @function module:path.clearData\n* @returns {void}\n*/\nexport const clearData = function () {\n pathData = {};\n};\n\n// Making public for mocking\n/**\n* @function module:path.reorientGrads\n* @param {Element} elem\n* @param {SVGMatrix} m\n* @returns {void}\n*/\nexport const reorientGrads = function (elem, m) {\n const bb = utilsGetBBox(elem);\n for (let i = 0; i < 2; i++) {\n const type = i === 0 ? 'fill' : 'stroke';\n const attrVal = elem.getAttribute(type);\n if (attrVal && attrVal.startsWith('url(')) {\n const grad = getRefElem(attrVal);\n if (grad.tagName === 'linearGradient') {\n let x1 = grad.getAttribute('x1') || 0;\n let y1 = grad.getAttribute('y1') || 0;\n let x2 = grad.getAttribute('x2') || 1;\n let y2 = grad.getAttribute('y2') || 0;\n\n // Convert to USOU points\n x1 = (bb.width * x1) + bb.x;\n y1 = (bb.height * y1) + bb.y;\n x2 = (bb.width * x2) + bb.x;\n y2 = (bb.height * y2) + bb.y;\n\n // Transform those points\n const pt1 = transformPoint(x1, y1, m);\n const pt2 = transformPoint(x2, y2, m);\n\n // Convert back to BB points\n const gCoords = {\n x1: (pt1.x - bb.x) / bb.width,\n y1: (pt1.y - bb.y) / bb.height,\n x2: (pt2.x - bb.x) / bb.width,\n y2: (pt2.y - bb.y) / bb.height\n };\n\n const newgrad = grad.cloneNode(true);\n $(newgrad).attr(gCoords);\n\n newgrad.id = editorContext_.getNextId();\n findDefs().append(newgrad);\n elem.setAttribute(type, 'url(#' + newgrad.id + ')');\n }\n }\n }\n};\n\n/**\n* This is how we map paths to our preferred relative segment types.\n* @name module:path.pathMap\n* @type {GenericArray}\n*/\nconst pathMap = [\n 0, 'z', 'M', 'm', 'L', 'l', 'C', 'c', 'Q', 'q', 'A', 'a',\n 'H', 'h', 'V', 'v', 'S', 's', 'T', 't'\n];\n\n/**\n * Convert a path to one with only absolute or relative values.\n * @todo move to pathActions.js\n * @function module:path.convertPath\n * @param {SVGPathElement} pth - the path to convert\n * @param {boolean} toRel - true of convert to relative\n * @returns {string}\n */\nexport const convertPath = function (pth, toRel) {\n const {pathSegList} = pth;\n const len = pathSegList.numberOfItems;\n let curx = 0, cury = 0;\n let d = '';\n let lastM = null;\n\n for (let i = 0; i < len; ++i) {\n const seg = pathSegList.getItem(i);\n // if these properties are not in the segment, set them to zero\n let x = seg.x || 0,\n y = seg.y || 0,\n x1 = seg.x1 || 0,\n y1 = seg.y1 || 0,\n x2 = seg.x2 || 0,\n y2 = seg.y2 || 0;\n\n const type = seg.pathSegType;\n let letter = pathMap[type][toRel ? 'toLowerCase' : 'toUpperCase']();\n\n switch (type) {\n case 1: // z,Z closepath (Z/z)\n d += 'z';\n if (lastM && !toRel) {\n curx = lastM[0];\n cury = lastM[1];\n }\n break;\n case 12: // absolute horizontal line (H)\n x -= curx;\n // Fallthrough\n case 13: // relative horizontal line (h)\n if (toRel) {\n y = 0;\n curx += x;\n letter = 'l';\n } else {\n y = cury;\n x += curx;\n curx = x;\n letter = 'L';\n }\n // Convert to \"line\" for easier editing\n d += pathDSegment(letter, [[x, y]]);\n break;\n case 14: // absolute vertical line (V)\n y -= cury;\n // Fallthrough\n case 15: // relative vertical line (v)\n if (toRel) {\n x = 0;\n cury += y;\n letter = 'l';\n } else {\n x = curx;\n y += cury;\n cury = y;\n letter = 'L';\n }\n // Convert to \"line\" for easier editing\n d += pathDSegment(letter, [[x, y]]);\n break;\n case 2: // absolute move (M)\n case 4: // absolute line (L)\n case 18: // absolute smooth quad (T)\n x -= curx;\n y -= cury;\n // Fallthrough\n case 5: // relative line (l)\n case 3: // relative move (m)\n case 19: // relative smooth quad (t)\n if (toRel) {\n curx += x;\n cury += y;\n } else {\n x += curx;\n y += cury;\n curx = x;\n cury = y;\n }\n if (type === 2 || type === 3) { lastM = [curx, cury]; }\n\n d += pathDSegment(letter, [[x, y]]);\n break;\n case 6: // absolute cubic (C)\n x -= curx; x1 -= curx; x2 -= curx;\n y -= cury; y1 -= cury; y2 -= cury;\n // Fallthrough\n case 7: // relative cubic (c)\n if (toRel) {\n curx += x;\n cury += y;\n } else {\n x += curx; x1 += curx; x2 += curx;\n y += cury; y1 += cury; y2 += cury;\n curx = x;\n cury = y;\n }\n d += pathDSegment(letter, [[x1, y1], [x2, y2], [x, y]]);\n break;\n case 8: // absolute quad (Q)\n x -= curx; x1 -= curx;\n y -= cury; y1 -= cury;\n // Fallthrough\n case 9: // relative quad (q)\n if (toRel) {\n curx += x;\n cury += y;\n } else {\n x += curx; x1 += curx;\n y += cury; y1 += cury;\n curx = x;\n cury = y;\n }\n d += pathDSegment(letter, [[x1, y1], [x, y]]);\n break;\n // eslint-disable-next-line sonarjs/no-duplicated-branches\n case 10: // absolute elliptical arc (A)\n x -= curx;\n y -= cury;\n // Fallthrough\n case 11: // relative elliptical arc (a)\n if (toRel) {\n curx += x;\n cury += y;\n } else {\n x += curx;\n y += cury;\n curx = x;\n cury = y;\n }\n d += pathDSegment(letter, [[seg.r1, seg.r2]], [\n seg.angle,\n (seg.largeArcFlag ? 1 : 0),\n (seg.sweepFlag ? 1 : 0)\n ], [x, y]);\n break;\n case 16: // absolute smooth cubic (S)\n x -= curx; x2 -= curx;\n y -= cury; y2 -= cury;\n // Fallthrough\n case 17: // relative smooth cubic (s)\n if (toRel) {\n curx += x;\n cury += y;\n } else {\n x += curx; x2 += curx;\n y += cury; y2 += cury;\n curx = x;\n cury = y;\n }\n d += pathDSegment(letter, [[x2, y2], [x, y]]);\n break;\n } // switch on path segment type\n } // for each segment\n return d;\n};\n\n/**\n * TODO: refactor callers in `convertPath` to use `getPathDFromSegments` instead of this function.\n * Legacy code refactored from `svgcanvas.pathActions.convertPath`.\n * @param {string} letter - path segment command (letter in potentially either case from {@link module:path.pathMap}; see [SVGPathSeg#pathSegTypeAsLetter]{@link https://www.w3.org/TR/SVG/single-page.html#paths-__svg__SVGPathSeg__pathSegTypeAsLetter})\n * @param {GenericArray<GenericArray<Integer>>} points - x,y points\n * @param {GenericArray<GenericArray<Integer>>} [morePoints] - x,y points\n * @param {Integer[]} [lastPoint] - x,y point\n * @returns {string}\n */\nfunction pathDSegment (letter, points, morePoints, lastPoint) {\n $.each(points, function (i, pnt) {\n points[i] = shortFloat(pnt);\n });\n let segment = letter + points.join(' ');\n if (morePoints) {\n segment += ' ' + morePoints.join(' ');\n }\n if (lastPoint) {\n segment += ' ' + shortFloat(lastPoint);\n }\n return segment;\n}\n\n/* eslint-disable jsdoc/require-property */\n/**\n* Group: Path edit functions.\n* Functions relating to editing path elements.\n* @namespace {PlainObject} pathActions\n* @memberof module:path\n*/\nexport const pathActions = (function () {\n /* eslint-enable jsdoc/require-property */\n let subpath = false;\n let newPoint, firstCtrl;\n\n let currentPath = null;\n let hasMoved = false;\n // No `editorContext_` yet but should be ok as is `null` by default\n // editorContext_.setDrawnPath(null);\n\n /**\n * This function converts a polyline (created by the fh_path tool) into\n * a path element and coverts every three line segments into a single bezier\n * curve in an attempt to smooth out the free-hand.\n * @function smoothPolylineIntoPath\n * @param {Element} element\n * @returns {Element}\n */\n const smoothPolylineIntoPath = function (element) {\n let i;\n const {points} = element;\n const N = points.numberOfItems;\n if (N >= 4) {\n // loop through every 3 points and convert to a cubic bezier curve segment\n //\n // NOTE: this is cheating, it means that every 3 points has the potential to\n // be a corner instead of treating each point in an equal manner. In general,\n // this technique does not look that good.\n //\n // I am open to better ideas!\n //\n // Reading:\n // - http://www.efg2.com/Lab/Graphics/Jean-YvesQueinecBezierCurves.htm\n // - https://www.codeproject.com/KB/graphics/BezierSpline.aspx?msg=2956963\n // - https://www.ian-ko.com/ET_GeoWizards/UserGuide/smooth.htm\n // - https://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/Bezier/bezier-der.html\n let curpos = points.getItem(0), prevCtlPt = null;\n let d = [];\n d.push(['M', curpos.x, ',', curpos.y, ' C'].join(''));\n for (i = 1; i <= (N - 4); i += 3) {\n let ct1 = points.getItem(i);\n const ct2 = points.getItem(i + 1);\n const end = points.getItem(i + 2);\n\n // if the previous segment had a control point, we want to smooth out\n // the control points on both sides\n if (prevCtlPt) {\n const newpts = smoothControlPoints(prevCtlPt, ct1, curpos);\n if (newpts && newpts.length === 2) {\n const prevArr = d[d.length - 1].split(',');\n prevArr[2] = newpts[0].x;\n prevArr[3] = newpts[0].y;\n d[d.length - 1] = prevArr.join(',');\n ct1 = newpts[1];\n }\n }\n\n d.push([ct1.x, ct1.y, ct2.x, ct2.y, end.x, end.y].join(','));\n\n curpos = end;\n prevCtlPt = ct2;\n }\n // handle remaining line segments\n d.push('L');\n while (i < N) {\n const pt = points.getItem(i);\n d.push([pt.x, pt.y].join(','));\n i++;\n }\n d = d.join(' ');\n\n // create new path element\n element = editorContext_.addSVGElementFromJson({\n element: 'path',\n curStyles: true,\n attr: {\n id: editorContext_.getId(),\n d,\n fill: 'none'\n }\n });\n // No need to call \"changed\", as this is already done under mouseUp\n }\n return element;\n };\n\n return (/** @lends module:path.pathActions */ {\n /**\n * @param {MouseEvent} evt\n * @param {Element} mouseTarget\n * @param {Float} startX\n * @param {Float} startY\n * @returns {boolean|void}\n */\n mouseDown (evt, mouseTarget, startX, startY) {\n let id;\n if (editorContext_.getCurrentMode() === 'path') {\n let mouseX = startX; // Was this meant to work with the other `mouseX`? (was defined globally so adding `let` to at least avoid a global)\n let mouseY = startY; // Was this meant to work with the other `mouseY`? (was defined globally so adding `let` to at least avoid a global)\n\n const currentZoom = editorContext_.getCurrentZoom();\n let x = mouseX / currentZoom,\n y = mouseY / currentZoom,\n stretchy = getElem('path_stretch_line');\n newPoint = [x, y];\n\n if (editorContext_.getGridSnapping()) {\n x = snapToGrid(x);\n y = snapToGrid(y);\n mouseX = snapToGrid(mouseX);\n mouseY = snapToGrid(mouseY);\n }\n\n if (!stretchy) {\n stretchy = document.createElementNS(NS.SVG, 'path');\n assignAttributes(stretchy, {\n id: 'path_stretch_line',\n stroke: '#22C',\n 'stroke-width': '0.5',\n fill: 'none'\n });\n stretchy = getElem('selectorParentGroup').appendChild(stretchy);\n }\n stretchy.setAttribute('display', 'inline');\n\n let keep = null;\n let index;\n // if pts array is empty, create path element with M at current point\n const drawnPath = editorContext_.getDrawnPath();\n if (!drawnPath) {\n const dAttr = 'M' + x + ',' + y + ' '; // Was this meant to work with the other `dAttr`? (was defined globally so adding `var` to at least avoid a global)\n /* drawnPath = */ editorContext_.setDrawnPath(editorContext_.addSVGElementFromJson({\n element: 'path',\n curStyles: true,\n attr: {\n d: dAttr,\n id: editorContext_.getNextId(),\n opacity: editorContext_.getOpacity() / 2\n }\n }));\n // set stretchy line to first point\n stretchy.setAttribute('d', ['M', mouseX, mouseY, mouseX, mouseY].join(' '));\n index = subpath ? path.segs.length : 0;\n addPointGrip(index, mouseX, mouseY);\n } else {\n // determine if we clicked on an existing point\n const seglist = drawnPath.pathSegList;\n let i = seglist.numberOfItems;\n const FUZZ = 6 / currentZoom;\n let clickOnPoint = false;\n while (i) {\n i--;\n const item = seglist.getItem(i);\n const px = item.x, py = item.y;\n // found a matching point\n if (x >= (px - FUZZ) && x <= (px + FUZZ) &&\n y >= (py - FUZZ) && y <= (py + FUZZ)\n ) {\n clickOnPoint = true;\n break;\n }\n }\n\n // get path element that we are in the process of creating\n id = editorContext_.getId();\n\n // Remove previous path object if previously created\n removePath_(id);\n\n const newpath = getElem(id);\n let newseg;\n let sSeg;\n const len = seglist.numberOfItems;\n // if we clicked on an existing point, then we are done this path, commit it\n // (i, i+1) are the x,y that were clicked on\n if (clickOnPoint) {\n // if clicked on any other point but the first OR\n // the first point was clicked on and there are less than 3 points\n // then leave the path open\n // otherwise, close the path\n if (i <= 1 && len >= 2) {\n // Create end segment\n const absX = seglist.getItem(0).x;\n const absY = seglist.getItem(0).y;\n\n sSeg = stretchy.pathSegList.getItem(1);\n if (sSeg.pathSegType === 4) {\n newseg = drawnPath.createSVGPathSegLinetoAbs(absX, absY);\n } else {\n newseg = drawnPath.createSVGPathSegCurvetoCubicAbs(\n absX,\n absY,\n sSeg.x1 / currentZoom,\n sSeg.y1 / currentZoom,\n absX,\n absY\n );\n }\n\n const endseg = drawnPath.createSVGPathSegClosePath();\n seglist.appendItem(newseg);\n seglist.appendItem(endseg);\n } else if (len < 3) {\n keep = false;\n return keep;\n }\n $(stretchy).remove();\n\n // This will signal to commit the path\n // const element = newpath; // Other event handlers define own `element`, so this was probably not meant to interact with them or one which shares state (as there were none); I therefore adding a missing `var` to avoid a global\n /* drawnPath = */ editorContext_.setDrawnPath(null);\n editorContext_.setStarted(false);\n\n if (subpath) {\n if (path.matrix) {\n editorContext_.remapElement(newpath, {}, path.matrix.inverse());\n }\n\n const newD = newpath.getAttribute('d');\n const origD = $(path.elem).attr('d');\n $(path.elem).attr('d', origD + newD);\n $(newpath).remove();\n if (path.matrix) {\n recalcRotatedPath();\n }\n init();\n pathActions.toEditMode(path.elem);\n path.selectPt();\n return false;\n }\n // else, create a new point, update path element\n } else {\n // Checks if current target or parents are #svgcontent\n if (!$.contains(\n editorContext_.getContainer(),\n editorContext_.getMouseTarget(evt)\n )) {\n // Clicked outside canvas, so don't make point\n // console.log('Clicked outside canvas');\n return false;\n }\n\n const num = drawnPath.pathSegList.numberOfItems;\n const last = drawnPath.pathSegList.getItem(num - 1);\n const lastx = last.x, lasty = last.y;\n\n if (evt.shiftKey) {\n const xya = snapToAngle(lastx, lasty, x, y);\n ({x, y} = xya);\n }\n\n // Use the segment defined by stretchy\n sSeg = stretchy.pathSegList.getItem(1);\n if (sSeg.pathSegType === 4) {\n newseg = drawnPath.createSVGPathSegLinetoAbs(\n editorContext_.round(x),\n editorContext_.round(y)\n );\n } else {\n newseg = drawnPath.createSVGPathSegCurvetoCubicAbs(\n editorContext_.round(x),\n editorContext_.round(y),\n sSeg.x1 / currentZoom,\n sSeg.y1 / currentZoom,\n sSeg.x2 / currentZoom,\n sSeg.y2 / currentZoom\n );\n }\n\n drawnPath.pathSegList.appendItem(newseg);\n\n x *= currentZoom;\n y *= currentZoom;\n\n // set stretchy line to latest point\n stretchy.setAttribute('d', ['M', x, y, x, y].join(' '));\n index = num;\n if (subpath) { index += path.segs.length; }\n addPointGrip(index, x, y);\n }\n // keep = true;\n }\n\n return undefined;\n }\n\n // TODO: Make sure currentPath isn't null at this point\n if (!path) { return undefined; }\n\n path.storeD();\n\n ({id} = evt.target);\n let curPt;\n if (id.substr(0, 14) === 'pathpointgrip_') {\n // Select this point\n curPt = path.cur_pt = Number.parseInt(id.substr(14));\n path.dragging = [startX, startY];\n const seg = path.segs[curPt];\n\n // only clear selection if shift is not pressed (otherwise, add\n // node to selection)\n if (!evt.shiftKey) {\n if (path.selected_pts.length <= 1 || !seg.selected) {\n path.clearSelection();\n }\n path.addPtsToSelection(curPt);\n } else if (seg.selected) {\n path.removePtFromSelection(curPt);\n } else {\n path.addPtsToSelection(curPt);\n }\n } else if (id.startsWith('ctrlpointgrip_')) {\n path.dragging = [startX, startY];\n\n const parts = id.split('_')[1].split('c');\n curPt = Number(parts[0]);\n const ctrlNum = Number(parts[1]);\n path.selectPt(curPt, ctrlNum);\n }\n\n // Start selection box\n if (!path.dragging) {\n let rubberBox = editorContext_.getRubberBox();\n if (isNullish(rubberBox)) {\n rubberBox = editorContext_.setRubberBox(\n editorContext_.selectorManager.getRubberBandBox()\n );\n }\n const currentZoom = editorContext_.getCurrentZoom();\n assignAttributes(rubberBox, {\n x: startX * currentZoom,\n y: startY * currentZoom,\n width: 0,\n height: 0,\n display: 'inline'\n }, 100);\n }\n return undefined;\n },\n /**\n * @param {Float} mouseX\n * @param {Float} mouseY\n * @returns {void}\n */\n mouseMove (mouseX, mouseY) {\n const currentZoom = editorContext_.getCurrentZoom();\n hasMoved = true;\n const drawnPath = editorContext_.getDrawnPath();\n if (editorContext_.getCurrentMode() === 'path') {\n if (!drawnPath) { return; }\n const seglist = drawnPath.pathSegList;\n const index = seglist.numberOfItems - 1;\n\n if (newPoint) {\n // First point\n // if (!index) { return; }\n\n // Set control points\n const pointGrip1 = addCtrlGrip('1c1');\n const pointGrip2 = addCtrlGrip('0c2');\n\n // dragging pointGrip1\n pointGrip1.setAttribute('cx', mouseX);\n pointGrip1.setAttribute('cy', mouseY);\n pointGrip1.setAttribute('display', 'inline');\n\n const ptX = newPoint[0];\n const ptY = newPoint[1];\n\n // set curve\n // const seg = seglist.getItem(index);\n const curX = mouseX / currentZoom;\n const curY = mouseY / currentZoom;\n const altX = (ptX + (ptX - curX));\n const altY = (ptY + (ptY - curY));\n\n pointGrip2.setAttribute('cx', altX * currentZoom);\n pointGrip2.setAttribute('cy', altY * currentZoom);\n pointGrip2.setAttribute('display', 'inline');\n\n const ctrlLine = getCtrlLine(1);\n assignAttributes(ctrlLine, {\n x1: mouseX,\n y1: mouseY,\n x2: altX * currentZoom,\n y2: altY * currentZoom,\n display: 'inline'\n });\n\n if (index === 0) {\n firstCtrl = [mouseX, mouseY];\n } else {\n const last = seglist.getItem(index - 1);\n let lastX = last.x;\n let lastY = last.y;\n\n if (last.pathSegType === 6) {\n lastX += (lastX - last.x2);\n lastY += (lastY - last.y2);\n } else if (firstCtrl) {\n lastX = firstCtrl[0] / currentZoom;\n lastY = firstCtrl[1] / currentZoom;\n }\n replacePathSeg(6, index, [ptX, ptY, lastX, lastY, altX, altY], drawnPath);\n }\n } else {\n const stretchy = getElem('path_stretch_line');\n if (stretchy) {\n const prev = seglist.getItem(index);\n if (prev.pathSegType === 6) {\n const prevX = prev.x + (prev.x - prev.x2);\n const prevY = prev.y + (prev.y - prev.y2);\n replacePathSeg(6, 1, [mouseX, mouseY, prevX * currentZoom, prevY * currentZoom, mouseX, mouseY], stretchy);\n } else if (firstCtrl) {\n replacePathSeg(6, 1, [mouseX, mouseY, firstCtrl[0], firstCtrl[1], mouseX, mouseY], stretchy);\n } else {\n replacePathSeg(4, 1, [mouseX, mouseY], stretchy);\n }\n }\n }\n return;\n }\n // if we are dragging a point, let's move it\n if (path.dragging) {\n const pt = getPointFromGrip({\n x: path.dragging[0],\n y: path.dragging[1]\n }, path);\n const mpt = getPointFromGrip({\n x: mouseX,\n y: mouseY\n }, path);\n const diffX = mpt.x - pt.x;\n const diffY = mpt.y - pt.y;\n path.dragging = [mouseX, mouseY];\n\n if (path.dragctrl) {\n path.moveCtrl(diffX, diffY);\n } else {\n path.movePts(diffX, diffY);\n }\n } else {\n path.selected_pts = [];\n path.eachSeg(function (i) {\n const seg = this;\n if (!seg.next && !seg.prev) { return; }\n\n // const {item} = seg;\n const rubberBox = editorContext_.getRubberBox();\n const rbb = rubberBox.getBBox();\n\n const pt = getGripPt(seg);\n const ptBb = {\n x: pt.x,\n y: pt.y,\n width: 0,\n height: 0\n };\n\n const sel = rectsIntersect(rbb, ptBb);\n\n this.select(sel);\n // Note that addPtsToSelection is not being run\n if (sel) { path.selected_pts.push(seg.index); }\n });\n }\n },\n /**\n * @typedef module:path.keepElement\n * @type {PlainObject}\n * @property {boolean} keep\n * @property {Element} element\n */\n /**\n * @param {Event} evt\n * @param {Element} element\n * @param {Float} mouseX\n * @param {Float} mouseY\n * @returns {module:path.keepElement|void}\n */\n mouseUp (evt, element, mouseX, mouseY) {\n const drawnPath = editorContext_.getDrawnPath();\n // Create mode\n if (editorContext_.getCurrentMode() === 'path') {\n newPoint = null;\n if (!drawnPath) {\n element = getElem(editorContext_.getId());\n editorContext_.setStarted(false);\n firstCtrl = null;\n }\n\n return {\n keep: true,\n element\n };\n }\n\n // Edit mode\n const rubberBox = editorContext_.getRubberBox();\n if (path.dragging) {\n const lastPt = path.cur_pt;\n\n path.dragging = false;\n path.dragctrl = false;\n path.update();\n\n if (hasMoved) {\n path.endChanges('Move path point(s)');\n }\n\n if (!evt.shiftKey && !hasMoved) {\n path.selectPt(lastPt);\n }\n } else if (rubberBox && rubberBox.getAttribute('display') !== 'none') {\n // Done with multi-node-select\n rubberBox.setAttribute('display', 'none');\n\n if (rubberBox.getAttribute('width') <= 2 && rubberBox.getAttribute('height') <= 2) {\n pathActions.toSelectMode(evt.target);\n }\n\n // else, move back to select mode\n } else {\n pathActions.toSelectMode(evt.target);\n }\n hasMoved = false;\n return undefined;\n },\n /**\n * @param {Element} element\n * @returns {void}\n */\n toEditMode (element) {\n path = getPath_(element);\n editorContext_.setCurrentMode('pathedit');\n editorContext_.clearSelection();\n path.show(true).update();\n path.oldbbox = utilsGetBBox(path.elem);\n subpath = false;\n },\n /**\n * @param {Element} elem\n * @fires module:svgcanvas.SvgCanvas#event:selected\n * @returns {void}\n */\n toSelectMode (elem) {\n const selPath = (elem === path.elem);\n editorContext_.setCurrentMode('select');\n path.show(false);\n currentPath = false;\n editorContext_.clearSelection();\n\n if (path.matrix) {\n // Rotated, so may need to re-calculate the center\n recalcRotatedPath();\n }\n\n if (selPath) {\n editorContext_.call('selected', [elem]);\n editorContext_.addToSelection([elem], true);\n }\n },\n /**\n * @param {boolean} on\n * @returns {void}\n */\n addSubPath (on) {\n if (on) {\n // Internally we go into \"path\" mode, but in the UI it will\n // still appear as if in \"pathedit\" mode.\n editorContext_.setCurrentMode('path');\n subpath = true;\n } else {\n pathActions.clear(true);\n pathActions.toEditMode(path.elem);\n }\n },\n /**\n * @param {Element} target\n * @returns {void}\n */\n select (target) {\n if (currentPath === target) {\n pathActions.toEditMode(target);\n editorContext_.setCurrentMode('pathedit');\n // going into pathedit mode\n } else {\n currentPath = target;\n }\n },\n /**\n * @fires module:svgcanvas.SvgCanvas#event:changed\n * @returns {void}\n */\n reorient () {\n const elem = editorContext_.getSelectedElements()[0];\n if (!elem) { return; }\n const angl = getRotationAngle(elem);\n if (angl === 0) { return; }\n\n const batchCmd = new BatchCommand('Reorient path');\n const changes = {\n d: elem.getAttribute('d'),\n transform: elem.getAttribute('transform')\n };\n batchCmd.addSubCommand(new ChangeElementCommand(elem, changes));\n editorContext_.clearSelection();\n this.resetOrientation(elem);\n\n editorContext_.addCommandToHistory(batchCmd);\n\n // Set matrix to null\n getPath_(elem).show(false).matrix = null;\n\n this.clear();\n\n editorContext_.addToSelection([elem], true);\n editorContext_.call('changed', editorContext_.getSelectedElements());\n },\n\n /**\n * @param {boolean} remove Not in use\n * @returns {void}\n */\n clear (remove) {\n const drawnPath = editorContext_.getDrawnPath();\n currentPath = null;\n if (drawnPath) {\n const elem = getElem(editorContext_.getId());\n $(getElem('path_stretch_line')).remove();\n $(elem).remove();\n $(getElem('pathpointgrip_container')).find('*').attr('display', 'none');\n firstCtrl = null;\n editorContext_.setDrawnPath(null);\n editorContext_.setStarted(false);\n } else if (editorContext_.getCurrentMode() === 'pathedit') {\n this.toSelectMode();\n }\n if (path) { path.init().show(false); }\n },\n /**\n * @param {?(Element|SVGPathElement)} pth\n * @returns {false|void}\n */\n resetOrientation (pth) {\n if (isNullish(pth) || pth.nodeName !== 'path') { return false; }\n const tlist = getTransformList(pth);\n const m = transformListToTransform(tlist).matrix;\n tlist.clear();\n pth.removeAttribute('transform');\n const segList = pth.pathSegList;\n\n // Opera/win/non-EN throws an error here.\n // TODO: Find out why!\n // Presumed fixed in Opera 10.5, so commented out for now\n\n // try {\n const len = segList.numberOfItems;\n // } catch(err) {\n // const fixed_d = pathActions.convertPath(pth);\n // pth.setAttribute('d', fixed_d);\n // segList = pth.pathSegList;\n // const len = segList.numberOfItems;\n // }\n // let lastX, lastY;\n for (let i = 0; i < len; ++i) {\n const seg = segList.getItem(i);\n const type = seg.pathSegType;\n if (type === 1) { continue; }\n const pts = [];\n $.each(['', 1, 2], function (j, n) {\n const x = seg['x' + n], y = seg['y' + n];\n if (x !== undefined && y !== undefined) {\n const pt = transformPoint(x, y, m);\n pts.splice(pts.length, 0, pt.x, pt.y);\n }\n });\n replacePathSeg(type, i, pts, pth);\n }\n\n reorientGrads(pth, m);\n return undefined;\n },\n /**\n * @returns {void}\n */\n zoomChange () {\n if (editorContext_.getCurrentMode() === 'pathedit') {\n path.update();\n }\n },\n /**\n * @typedef {PlainObject} module:path.NodePoint\n * @property {Float} x\n * @property {Float} y\n * @property {Integer} type\n */\n /**\n * @returns {module:path.NodePoint}\n */\n getNodePoint () {\n const selPt = path.selected_pts.length ? path.selected_pts[0] : 1;\n\n const seg = path.segs[selPt];\n return {\n x: seg.item.x,\n y: seg.item.y,\n type: seg.type\n };\n },\n /**\n * @param {boolean} linkPoints\n * @returns {void}\n */\n linkControlPoints (linkPoints) {\n setLinkControlPoints(linkPoints);\n },\n /**\n * @returns {void}\n */\n clonePathNode () {\n path.storeD();\n\n const selPts = path.selected_pts;\n // const {segs} = path;\n\n let i = selPts.length;\n const nums = [];\n\n while (i--) {\n const pt = selPts[i];\n path.addSeg(pt);\n\n nums.push(pt + i);\n nums.push(pt + i + 1);\n }\n path.init().addPtsToSelection(nums);\n\n path.endChanges('Clone path node(s)');\n },\n /**\n * @returns {void}\n */\n opencloseSubPath () {\n const selPts = path.selected_pts;\n // Only allow one selected node for now\n if (selPts.length !== 1) { return; }\n\n const {elem} = path;\n const list = elem.pathSegList;\n\n // const len = list.numberOfItems;\n\n const index = selPts[0];\n\n let openPt = null;\n let startItem = null;\n\n // Check if subpath is already open\n path.eachSeg(function (i) {\n if (this.type === 2 && i <= index) {\n startItem = this.item;\n }\n if (i <= index) { return true; }\n if (this.type === 2) {\n // Found M first, so open\n openPt = i;\n return false;\n }\n if (this.type === 1) {\n // Found Z first, so closed\n openPt = false;\n return false;\n }\n return true;\n });\n\n if (isNullish(openPt)) {\n // Single path, so close last seg\n openPt = path.segs.length - 1;\n }\n\n if (openPt !== false) {\n // Close this path\n\n // Create a line going to the previous \"M\"\n const newseg = elem.createSVGPathSegLinetoAbs(startItem.x, startItem.y);\n\n const closer = elem.createSVGPathSegClosePath();\n if (openPt === path.segs.length - 1) {\n list.appendItem(newseg);\n list.appendItem(closer);\n } else {\n insertItemBefore(elem, closer, openPt);\n insertItemBefore(elem, newseg, openPt);\n }\n\n path.init().selectPt(openPt + 1);\n return;\n }\n\n // M 1,1 L 2,2 L 3,3 L 1,1 z // open at 2,2\n // M 2,2 L 3,3 L 1,1\n\n // M 1,1 L 2,2 L 1,1 z M 4,4 L 5,5 L6,6 L 5,5 z\n // M 1,1 L 2,2 L 1,1 z [M 4,4] L 5,5 L(M)6,6 L 5,5 z\n\n const seg = path.segs[index];\n\n if (seg.mate) {\n list.removeItem(index); // Removes last \"L\"\n list.removeItem(index); // Removes the \"Z\"\n path.init().selectPt(index - 1);\n return;\n }\n\n let lastM, zSeg;\n\n // Find this sub-path's closing point and remove\n for (let i = 0; i < list.numberOfItems; i++) {\n const item = list.getItem(i);\n\n if (item.pathSegType === 2) {\n // Find the preceding M\n lastM = i;\n } else if (i === index) {\n // Remove it\n list.removeItem(lastM);\n // index--;\n } else if (item.pathSegType === 1 && index < i) {\n // Remove the closing seg of this subpath\n zSeg = i - 1;\n list.removeItem(i);\n break;\n }\n }\n\n let num = (index - lastM) - 1;\n\n while (num--) {\n insertItemBefore(elem, list.getItem(lastM), zSeg);\n }\n\n const pt = list.getItem(lastM);\n\n // Make this point the new \"M\"\n replacePathSeg(2, lastM, [pt.x, pt.y]);\n\n // i = index; // i is local here, so has no effect; what was the intent for this?\n\n path.init().selectPt(0);\n },\n /**\n * @returns {void}\n */\n deletePathNode () {\n if (!pathActions.canDeleteNodes) { return; }\n path.storeD();\n\n const selPts = path.selected_pts;\n\n let i = selPts.length;\n while (i--) {\n const pt = selPts[i];\n path.deleteSeg(pt);\n }\n\n // Cleanup\n const cleanup = function () {\n const segList = path.elem.pathSegList;\n let len = segList.numberOfItems;\n\n const remItems = function (pos, count) {\n while (count--) {\n segList.removeItem(pos);\n }\n };\n\n if (len <= 1) { return true; }\n\n while (len--) {\n const item = segList.getItem(len);\n if (item.pathSegType === 1) {\n const prev = segList.getItem(len - 1);\n const nprev = segList.getItem(len - 2);\n if (prev.pathSegType === 2) {\n remItems(len - 1, 2);\n cleanup();\n break;\n } else if (nprev.pathSegType === 2) {\n remItems(len - 2, 3);\n cleanup();\n break;\n }\n } else if (item.pathSegType === 2) {\n if (len > 0) {\n const prevType = segList.getItem(len - 1).pathSegType;\n // Path has M M\n if (prevType === 2) {\n remItems(len - 1, 1);\n cleanup();\n break;\n // Entire path ends with Z M\n } else if (prevType === 1 && segList.numberOfItems - 1 === len) {\n remItems(len, 1);\n cleanup();\n break;\n }\n }\n }\n }\n return false;\n };\n\n cleanup();\n\n // Completely delete a path with 1 or 0 segments\n if (path.elem.pathSegList.numberOfItems <= 1) {\n pathActions.toSelectMode(path.elem);\n editorContext_.canvas.deleteSelectedElements();\n return;\n }\n\n path.init();\n path.clearSelection();\n\n // TODO: Find right way to select point now\n // path.selectPt(selPt);\n if (window.opera) { // Opera repaints incorrectly\n const cp = $(path.elem);\n cp.attr('d', cp.attr('d'));\n }\n path.endChanges('Delete path node(s)');\n },\n /* eslint-disable jsdoc/require-returns */\n // Can't seem to use `@borrows` here, so using `@see`\n /**\n * Smooth polyline into path.\n * @function module:path.pathActions.smoothPolylineIntoPath\n * @see module:path~smoothPolylineIntoPath\n */\n smoothPolylineIntoPath,\n /* eslint-enable jsdoc/require-returns */\n /**\n * @param {?Integer} v See {@link https://www.w3.org/TR/SVG/single-page.html#paths-InterfaceSVGPathSeg}\n * @returns {void}\n */\n setSegType (v) {\n path.setSegType(v);\n },\n /**\n * @param {string} attr\n * @param {Float} newValue\n * @returns {void}\n */\n moveNode (attr, newValue) {\n const selPts = path.selected_pts;\n if (!selPts.length) { return; }\n\n path.storeD();\n\n // Get first selected point\n const seg = path.segs[selPts[0]];\n const diff = {x: 0, y: 0};\n diff[attr] = newValue - seg.item[attr];\n\n seg.move(diff.x, diff.y);\n path.endChanges('Move path point');\n },\n /**\n * @param {Element} elem\n * @returns {void}\n */\n fixEnd (elem) {\n // Adds an extra segment if the last seg before a Z doesn't end\n // at its M point\n // M0,0 L0,100 L100,100 z\n const segList = elem.pathSegList;\n const len = segList.numberOfItems;\n let lastM;\n for (let i = 0; i < len; ++i) {\n const item = segList.getItem(i);\n if (item.pathSegType === 2) {\n lastM = item;\n }\n\n if (item.pathSegType === 1) {\n const prev = segList.getItem(i - 1);\n if (prev.x !== lastM.x || prev.y !== lastM.y) {\n // Add an L segment here\n const newseg = elem.createSVGPathSegLinetoAbs(lastM.x, lastM.y);\n insertItemBefore(elem, newseg, i);\n // Can this be done better?\n pathActions.fixEnd(elem);\n break;\n }\n }\n }\n if (isWebkit()) { editorContext_.resetD(elem); }\n },\n /* eslint-disable jsdoc/require-returns */\n // Can't seem to use `@borrows` here, so using `@see`\n /**\n * Convert a path to one with only absolute or relative values.\n * @function module:path.pathActions.convertPath\n * @see module:path.convertPath\n */\n convertPath\n /* eslint-enable jsdoc/require-returns */\n });\n})();\n// end pathActions\n","/* globals jQuery */\n/**\n * Provides tools for the layer concept.\n * @module layer\n * @license MIT\n *\n * @copyright 2011 Jeff Schiller, 2016 Flint O'Brien\n */\n\nimport {NS} from './namespaces.js';\nimport {toXml, walkTree, isNullish} from './utilities.js';\n\nconst $ = jQuery;\n\n/**\n * This class encapsulates the concept of a layer in the drawing. It can be constructed with\n * an existing group element or, with three parameters, will create a new layer group element.\n *\n * @example\n * const l1 = new Layer('name', group); // Use the existing group for this layer.\n * const l2 = new Layer('name', group, svgElem); // Create a new group and add it to the DOM after group.\n * const l3 = new Layer('name', null, svgElem); // Create a new group and add it to the DOM as the last layer.\n * @memberof module:layer\n */\nclass Layer {\n /**\n * @param {string} name - Layer name\n * @param {SVGGElement|null} group - An existing SVG group element or null.\n * If group and no svgElem, use group for this layer.\n * If group and svgElem, create a new group element and insert it in the DOM after group.\n * If no group and svgElem, create a new group element and insert it in the DOM as the last layer.\n * @param {SVGGElement} [svgElem] - The SVG DOM element. If defined, use this to add\n * a new layer to the document.\n */\n constructor (name, group, svgElem) {\n this.name_ = name;\n this.group_ = svgElem ? null : group;\n\n if (svgElem) {\n // Create a group element with title and add it to the DOM.\n const svgdoc = svgElem.ownerDocument;\n this.group_ = svgdoc.createElementNS(NS.SVG, 'g');\n const layerTitle = svgdoc.createElementNS(NS.SVG, 'title');\n layerTitle.textContent = name;\n this.group_.append(layerTitle);\n if (group) {\n $(group).after(this.group_);\n } else {\n svgElem.append(this.group_);\n }\n }\n\n addLayerClass(this.group_);\n walkTree(this.group_, function (e) {\n e.setAttribute('style', 'pointer-events:inherit');\n });\n\n this.group_.setAttribute('style', svgElem ? 'pointer-events:all' : 'pointer-events:none');\n }\n\n /**\n * Get the layer's name.\n * @returns {string} The layer name\n */\n getName () {\n return this.name_;\n }\n\n /**\n * Get the group element for this layer.\n * @returns {SVGGElement} The layer SVG group\n */\n getGroup () {\n return this.group_;\n }\n\n /**\n * Active this layer so it takes pointer events.\n * @returns {void}\n */\n activate () {\n this.group_.setAttribute('style', 'pointer-events:all');\n }\n\n /**\n * Deactive this layer so it does NOT take pointer events.\n * @returns {void}\n */\n deactivate () {\n this.group_.setAttribute('style', 'pointer-events:none');\n }\n\n /**\n * Set this layer visible or hidden based on 'visible' parameter.\n * @param {boolean} visible - If true, make visible; otherwise, hide it.\n * @returns {void}\n */\n setVisible (visible) {\n const expected = visible === undefined || visible ? 'inline' : 'none';\n const oldDisplay = this.group_.getAttribute('display');\n if (oldDisplay !== expected) {\n this.group_.setAttribute('display', expected);\n }\n }\n\n /**\n * Is this layer visible?\n * @returns {boolean} True if visible.\n */\n isVisible () {\n return this.group_.getAttribute('display') !== 'none';\n }\n\n /**\n * Get layer opacity.\n * @returns {Float} Opacity value.\n */\n getOpacity () {\n const opacity = this.group_.getAttribute('opacity');\n if (isNullish(opacity)) {\n return 1;\n }\n return Number.parseFloat(opacity);\n }\n\n /**\n * Sets the opacity of this layer. If opacity is not a value between 0.0 and 1.0,\n * nothing happens.\n * @param {Float} opacity - A float value in the range 0.0-1.0\n * @returns {void}\n */\n setOpacity (opacity) {\n if (typeof opacity === 'number' && opacity >= 0.0 && opacity <= 1.0) {\n this.group_.setAttribute('opacity', opacity);\n }\n }\n\n /**\n * Append children to this layer.\n * @param {SVGGElement} children - The children to append to this layer.\n * @returns {void}\n */\n appendChildren (children) {\n for (const child of children) {\n this.group_.append(child);\n }\n }\n\n /**\n * @returns {SVGTitleElement|null}\n */\n getTitleElement () {\n const len = this.group_.childNodes.length;\n for (let i = 0; i < len; ++i) {\n const child = this.group_.childNodes.item(i);\n if (child && child.tagName === 'title') {\n return child;\n }\n }\n return null;\n }\n\n /**\n * Set the name of this layer.\n * @param {string} name - The new name.\n * @param {module:history.HistoryRecordingService} hrService - History recording service\n * @returns {string|null} The new name if changed; otherwise, null.\n */\n setName (name, hrService) {\n const previousName = this.name_;\n name = toXml(name);\n // now change the underlying title element contents\n const title = this.getTitleElement();\n if (title) {\n $(title).empty();\n title.textContent = name;\n this.name_ = name;\n if (hrService) {\n hrService.changeElement(title, {'#text': previousName});\n }\n return this.name_;\n }\n return null;\n }\n\n /**\n * Remove this layer's group from the DOM. No more functions on group can be called after this.\n * @returns {SVGGElement} The layer SVG group that was just removed.\n */\n removeGroup () {\n const group = this.group_;\n this.group_.remove();\n this.group_ = undefined;\n return group;\n }\n}\n/**\n * @property {string} CLASS_NAME - class attribute assigned to all layer groups.\n */\nLayer.CLASS_NAME = 'layer';\n\n/**\n * @property {RegExp} CLASS_REGEX - Used to test presence of class Layer.CLASS_NAME\n */\nLayer.CLASS_REGEX = new RegExp('(\\\\s|^)' + Layer.CLASS_NAME + '(\\\\s|$)');\n\n/**\n * Add class `Layer.CLASS_NAME` to the element (usually `class='layer'`).\n *\n * @param {SVGGElement} elem - The SVG element to update\n * @returns {void}\n */\nfunction addLayerClass (elem) {\n const classes = elem.getAttribute('class');\n if (isNullish(classes) || !classes.length) {\n elem.setAttribute('class', Layer.CLASS_NAME);\n } else if (!Layer.CLASS_REGEX.test(classes)) {\n elem.setAttribute('class', classes + ' ' + Layer.CLASS_NAME);\n }\n}\n\nexport default Layer;\n","/**\n * HistoryRecordingService component of history.\n * @module history\n * @license MIT\n * @copyright 2016 Flint O'Brien\n */\n\nimport {\n BatchCommand, MoveElementCommand, InsertElementCommand, RemoveElementCommand,\n ChangeElementCommand\n} from './history.js';\n\n/**\n * History recording service.\n *\n * A self-contained service interface for recording history. Once injected, no other dependencies\n * or globals are required (example: UndoManager, command types, etc.). Easy to mock for unit tests.\n * Built on top of history classes in history.js.\n *\n * There is a simple start/end interface for batch commands.\n *\n * HistoryRecordingService.NO_HISTORY is a singleton that can be passed in to functions\n * that record history. This helps when the caller requires that no history be recorded.\n *\n * The following will record history: insert, batch, insert.\n * @example\n * hrService = new HistoryRecordingService(this.undoMgr);\n * hrService.insertElement(elem, text); // add simple command to history.\n * hrService.startBatchCommand('create two elements');\n * hrService.changeElement(elem, attrs, text); // add to batchCommand\n * hrService.changeElement(elem, attrs2, text); // add to batchCommand\n * hrService.endBatchCommand(); // add batch command with two change commands to history.\n * hrService.insertElement(elem, text); // add simple command to history.\n *\n * @example\n * // Note that all functions return this, so commands can be chained, like so:\n * hrService\n * .startBatchCommand('create two elements')\n * .insertElement(elem, text)\n * .changeElement(elem, attrs, text)\n * .endBatchCommand();\n *\n * @memberof module:history\n */\nclass HistoryRecordingService {\n /**\n * @param {history.UndoManager|null} undoManager - The undo manager.\n * A value of `null` is valid for cases where no history recording is required.\n * See singleton: {@link module:history.HistoryRecordingService.HistoryRecordingService.NO_HISTORY}\n */\n constructor (undoManager) {\n this.undoManager_ = undoManager;\n this.currentBatchCommand_ = null;\n this.batchCommandStack_ = [];\n }\n\n /**\n * Start a batch command so multiple commands can recorded as a single history command.\n * Requires a corresponding call to endBatchCommand. Start and end commands can be nested.\n *\n * @param {string} text - Optional string describing the batch command.\n * @returns {module:history.HistoryRecordingService}\n */\n startBatchCommand (text) {\n if (!this.undoManager_) { return this; }\n this.currentBatchCommand_ = new BatchCommand(text);\n this.batchCommandStack_.push(this.currentBatchCommand_);\n return this;\n }\n\n /**\n * End a batch command and add it to the history or a parent batch command.\n * @returns {module:history.HistoryRecordingService}\n */\n endBatchCommand () {\n if (!this.undoManager_) { return this; }\n if (this.currentBatchCommand_) {\n const batchCommand = this.currentBatchCommand_;\n this.batchCommandStack_.pop();\n const {length: len} = this.batchCommandStack_;\n this.currentBatchCommand_ = len ? this.batchCommandStack_[len - 1] : null;\n this.addCommand_(batchCommand);\n }\n return this;\n }\n\n /**\n * Add a `MoveElementCommand` to the history or current batch command.\n * @param {Element} elem - The DOM element that was moved\n * @param {Element} oldNextSibling - The element's next sibling before it was moved\n * @param {Element} oldParent - The element's parent before it was moved\n * @param {string} [text] - An optional string visible to user related to this change\n * @returns {module:history.HistoryRecordingService}\n */\n moveElement (elem, oldNextSibling, oldParent, text) {\n if (!this.undoManager_) { return this; }\n this.addCommand_(new MoveElementCommand(elem, oldNextSibling, oldParent, text));\n return this;\n }\n\n /**\n * Add an `InsertElementCommand` to the history or current batch command.\n * @param {Element} elem - The DOM element that was added\n * @param {string} [text] - An optional string visible to user related to this change\n * @returns {module:history.HistoryRecordingService}\n */\n insertElement (elem, text) {\n if (!this.undoManager_) { return this; }\n this.addCommand_(new InsertElementCommand(elem, text));\n return this;\n }\n\n /**\n * Add a `RemoveElementCommand` to the history or current batch command.\n * @param {Element} elem - The DOM element that was removed\n * @param {Element} oldNextSibling - The element's next sibling before it was removed\n * @param {Element} oldParent - The element's parent before it was removed\n * @param {string} [text] - An optional string visible to user related to this change\n * @returns {module:history.HistoryRecordingService}\n */\n removeElement (elem, oldNextSibling, oldParent, text) {\n if (!this.undoManager_) { return this; }\n this.addCommand_(new RemoveElementCommand(elem, oldNextSibling, oldParent, text));\n return this;\n }\n\n /**\n * Add a `ChangeElementCommand` to the history or current batch command.\n * @param {Element} elem - The DOM element that was changed\n * @param {module:history.CommandAttributes} attrs - An object with the attributes to be changed and the values they had *before* the change\n * @param {string} [text] - An optional string visible to user related to this change\n * @returns {module:history.HistoryRecordingService}\n */\n changeElement (elem, attrs, text) {\n if (!this.undoManager_) { return this; }\n this.addCommand_(new ChangeElementCommand(elem, attrs, text));\n return this;\n }\n\n /**\n * Private function to add a command to the history or current batch command.\n * @private\n * @param {Command} cmd\n * @returns {module:history.HistoryRecordingService|void}\n */\n addCommand_ (cmd) {\n if (!this.undoManager_) { return this; }\n if (this.currentBatchCommand_) {\n this.currentBatchCommand_.addSubCommand(cmd);\n } else {\n this.undoManager_.addCommandToHistory(cmd);\n }\n return undefined;\n }\n}\n/**\n * @memberof module:history.HistoryRecordingService\n * @property {module:history.HistoryRecordingService} NO_HISTORY - Singleton that can be passed to functions that record history, but the caller requires that no history be recorded.\n */\nHistoryRecordingService.NO_HISTORY = new HistoryRecordingService();\nexport default HistoryRecordingService;\n","/* globals jQuery */\n\nimport jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr`\nimport {isWebkit} from '../common/browser.js';\nimport {convertPath} from './path.js';\nimport {preventClickDefault} from '../common/utilities.js';\n\n// Constants\nconst $ = jQueryPluginSVG(jQuery);\n\n/**\n * Create a clone of an element, updating its ID and its children's IDs when needed.\n * @function module:utilities.copyElem\n * @param {Element} el - DOM element to clone\n * @param {module:utilities.GetNextID} getNextId - The getter of the next unique ID.\n * @returns {Element} The cloned element\n */\nexport const copyElem = function (el, getNextId) {\n // manually create a copy of the element\n const newEl = document.createElementNS(el.namespaceURI, el.nodeName);\n $.each(el.attributes, function (i, attr) {\n if (attr.localName !== '-moz-math-font-style') {\n newEl.setAttributeNS(attr.namespaceURI, attr.nodeName, attr.value);\n }\n });\n // set the copied element's new id\n newEl.removeAttribute('id');\n newEl.id = getNextId();\n\n // Opera's \"d\" value needs to be reset for Opera/Win/non-EN\n // Also needed for webkit (else does not keep curved segments on clone)\n if (isWebkit() && el.nodeName === 'path') {\n const fixedD = convertPath(el);\n newEl.setAttribute('d', fixedD);\n }\n\n // now create copies of all children\n $.each(el.childNodes, function (i, child) {\n switch (child.nodeType) {\n case 1: // element node\n newEl.append(copyElem(child, getNextId));\n break;\n case 3: // text node\n newEl.textContent = child.nodeValue;\n break;\n default:\n break;\n }\n });\n\n if ($(el).data('gsvg')) {\n $(newEl).data('gsvg', newEl.firstChild);\n } else if ($(el).data('symbol')) {\n const ref = $(el).data('symbol');\n $(newEl).data('ref', ref).data('symbol', ref);\n } else if (newEl.tagName === 'image') {\n preventClickDefault(newEl);\n }\n\n return newEl;\n};\n","/* globals jQuery */\n/**\n * Tools for drawing.\n * @module draw\n * @license MIT\n * @copyright 2011 Jeff Schiller\n */\n\nimport Layer from '../common/layer.js';\nimport HistoryRecordingService from './historyrecording.js';\n\nimport {NS} from '../common/namespaces.js';\nimport {isOpera} from '../common/browser.js';\nimport {\n toXml, getElem\n} from '../common/utilities.js';\nimport {\n copyElem as utilCopyElem\n} from './copy-elem.js';\nimport {\n BatchCommand, RemoveElementCommand, MoveElementCommand, ChangeElementCommand\n} from './history.js';\n\nconst $ = jQuery;\n\nconst visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use'.split(',');\n\nconst RandomizeModes = {\n LET_DOCUMENT_DECIDE: 0,\n ALWAYS_RANDOMIZE: 1,\n NEVER_RANDOMIZE: 2\n};\nlet randIds = RandomizeModes.LET_DOCUMENT_DECIDE;\n// Array with current disabled elements (for in-group editing)\nlet disabledElems = [];\n\n/**\n * Get a HistoryRecordingService.\n * @param {module:history.HistoryRecordingService} [hrService] - if exists, return it instead of creating a new service.\n * @returns {module:history.HistoryRecordingService}\n */\nfunction historyRecordingService (hrService) {\n return hrService || new HistoryRecordingService(canvas_.undoMgr);\n}\n\n/**\n * Find the layer name in a group element.\n * @param {Element} group The group element to search in.\n * @returns {string} The layer name or empty string.\n */\nfunction findLayerNameInGroup (group) {\n return $('title', group).text() ||\n (isOpera() && group.querySelectorAll\n // Hack for Opera 10.60\n ? $(group.querySelectorAll('title')).text()\n : '');\n}\n\n/**\n * Given a set of names, return a new unique name.\n * @param {string[]} existingLayerNames - Existing layer names.\n * @returns {string} - The new name.\n */\nfunction getNewLayerName (existingLayerNames) {\n let i = 1;\n // TODO(codedread): What about internationalization of \"Layer\"?\n while (existingLayerNames.includes(('Layer ' + i))) { i++; }\n return 'Layer ' + i;\n}\n\n/**\n * This class encapsulates the concept of a SVG-edit drawing.\n */\nexport class Drawing {\n /**\n * @param {SVGSVGElement} svgElem - The SVG DOM Element that this JS object\n * encapsulates. If the svgElem has a se:nonce attribute on it, then\n * IDs will use the nonce as they are generated.\n * @param {string} [optIdPrefix=svg_] - The ID prefix to use.\n * @throws {Error} If not initialized with an SVG element\n */\n constructor (svgElem, optIdPrefix) {\n if (!svgElem || !svgElem.tagName || !svgElem.namespaceURI ||\n svgElem.tagName !== 'svg' || svgElem.namespaceURI !== NS.SVG) {\n throw new Error('Error: svgedit.draw.Drawing instance initialized without a <svg> element');\n }\n\n /**\n * The SVG DOM Element that represents this drawing.\n * @type {SVGSVGElement}\n */\n this.svgElem_ = svgElem;\n\n /**\n * The latest object number used in this drawing.\n * @type {Integer}\n */\n this.obj_num = 0;\n\n /**\n * The prefix to prepend to each element id in the drawing.\n * @type {string}\n */\n this.idPrefix = optIdPrefix || 'svg_';\n\n /**\n * An array of released element ids to immediately reuse.\n * @type {Integer[]}\n */\n this.releasedNums = [];\n\n /**\n * The z-ordered array of Layer objects. Each layer has a name\n * and group element.\n * The first layer is the one at the bottom of the rendering.\n * @type {Layer[]}\n */\n this.all_layers = [];\n\n /**\n * Map of all_layers by name.\n *\n * Note: Layers are ordered, but referenced externally by name; so, we need both container\n * types depending on which function is called (i.e. all_layers and layer_map).\n *\n * @type {PlainObject<string, Layer>}\n */\n this.layer_map = {};\n\n /**\n * The current layer being used.\n * @type {Layer}\n */\n this.current_layer = null;\n\n /**\n * The nonce to use to uniquely identify elements across drawings.\n * @type {!string}\n */\n this.nonce_ = '';\n const n = this.svgElem_.getAttributeNS(NS.SE, 'nonce');\n // If already set in the DOM, use the nonce throughout the document\n // else, if randomizeIds(true) has been called, create and set the nonce.\n if (n && randIds !== RandomizeModes.NEVER_RANDOMIZE) {\n this.nonce_ = n;\n } else if (randIds === RandomizeModes.ALWAYS_RANDOMIZE) {\n this.setNonce(Math.floor(Math.random() * 100001));\n }\n }\n\n /**\n * @param {string} id Element ID to retrieve\n * @returns {Element} SVG element within the root SVGSVGElement\n */\n getElem_ (id) {\n if (this.svgElem_.querySelector) {\n // querySelector lookup\n return this.svgElem_.querySelector('#' + id);\n }\n // jQuery lookup: twice as slow as xpath in FF\n return $(this.svgElem_).find('[id=' + id + ']')[0];\n }\n\n /**\n * @returns {SVGSVGElement}\n */\n getSvgElem () {\n return this.svgElem_;\n }\n\n /**\n * @returns {!(string|Integer)} The previously set nonce\n */\n getNonce () {\n return this.nonce_;\n }\n\n /**\n * @param {!(string|Integer)} n The nonce to set\n * @returns {void}\n */\n setNonce (n) {\n this.svgElem_.setAttributeNS(NS.XMLNS, 'xmlns:se', NS.SE);\n this.svgElem_.setAttributeNS(NS.SE, 'se:nonce', n);\n this.nonce_ = n;\n }\n\n /**\n * Clears any previously set nonce.\n * @returns {void}\n */\n clearNonce () {\n // We deliberately leave any se:nonce attributes alone,\n // we just don't use it to randomize ids.\n this.nonce_ = '';\n }\n\n /**\n * Returns the latest object id as a string.\n * @returns {string} The latest object Id.\n */\n getId () {\n return this.nonce_\n ? this.idPrefix + this.nonce_ + '_' + this.obj_num\n : this.idPrefix + this.obj_num;\n }\n\n /**\n * Returns the next object Id as a string.\n * @returns {string} The next object Id to use.\n */\n getNextId () {\n const oldObjNum = this.obj_num;\n let restoreOldObjNum = false;\n\n // If there are any released numbers in the release stack,\n // use the last one instead of the next obj_num.\n // We need to temporarily use obj_num as that is what getId() depends on.\n if (this.releasedNums.length > 0) {\n this.obj_num = this.releasedNums.pop();\n restoreOldObjNum = true;\n } else {\n // If we are not using a released id, then increment the obj_num.\n this.obj_num++;\n }\n\n // Ensure the ID does not exist.\n let id = this.getId();\n while (this.getElem_(id)) {\n if (restoreOldObjNum) {\n this.obj_num = oldObjNum;\n restoreOldObjNum = false;\n }\n this.obj_num++;\n id = this.getId();\n }\n // Restore the old object number if required.\n if (restoreOldObjNum) {\n this.obj_num = oldObjNum;\n }\n return id;\n }\n\n /**\n * Releases the object Id, letting it be used as the next id in getNextId().\n * This method DOES NOT remove any elements from the DOM, it is expected\n * that client code will do this.\n * @param {string} id - The id to release.\n * @returns {boolean} True if the id was valid to be released, false otherwise.\n */\n releaseId (id) {\n // confirm if this is a valid id for this Document, else return false\n const front = this.idPrefix + (this.nonce_ ? this.nonce_ + '_' : '');\n if (typeof id !== 'string' || !id.startsWith(front)) {\n return false;\n }\n // extract the obj_num of this id\n const num = Number.parseInt(id.substr(front.length));\n\n // if we didn't get a positive number or we already released this number\n // then return false.\n if (typeof num !== 'number' || num <= 0 || this.releasedNums.includes(num)) {\n return false;\n }\n\n // push the released number into the released queue\n this.releasedNums.push(num);\n\n return true;\n }\n\n /**\n * Returns the number of layers in the current drawing.\n * @returns {Integer} The number of layers in the current drawing.\n */\n getNumLayers () {\n return this.all_layers.length;\n }\n\n /**\n * Check if layer with given name already exists.\n * @param {string} name - The layer name to check\n * @returns {boolean}\n */\n hasLayer (name) {\n return this.layer_map[name] !== undefined;\n }\n\n /**\n * Returns the name of the ith layer. If the index is out of range, an empty string is returned.\n * @param {Integer} i - The zero-based index of the layer you are querying.\n * @returns {string} The name of the ith layer (or the empty string if none found)\n */\n getLayerName (i) {\n return i >= 0 && i < this.getNumLayers() ? this.all_layers[i].getName() : '';\n }\n\n /**\n * @returns {SVGGElement|null} The SVGGElement representing the current layer.\n */\n getCurrentLayer () {\n return this.current_layer ? this.current_layer.getGroup() : null;\n }\n\n /**\n * Get a layer by name.\n * @param {string} name\n * @returns {SVGGElement} The SVGGElement representing the named layer or null.\n */\n getLayerByName (name) {\n const layer = this.layer_map[name];\n return layer ? layer.getGroup() : null;\n }\n\n /**\n * Returns the name of the currently selected layer. If an error occurs, an empty string\n * is returned.\n * @returns {string} The name of the currently active layer (or the empty string if none found).\n */\n getCurrentLayerName () {\n return this.current_layer ? this.current_layer.getName() : '';\n }\n\n /**\n * Set the current layer's name.\n * @param {string} name - The new name.\n * @param {module:history.HistoryRecordingService} hrService - History recording service\n * @returns {string|null} The new name if changed; otherwise, null.\n */\n setCurrentLayerName (name, hrService) {\n let finalName = null;\n if (this.current_layer) {\n const oldName = this.current_layer.getName();\n finalName = this.current_layer.setName(name, hrService);\n if (finalName) {\n delete this.layer_map[oldName];\n this.layer_map[finalName] = this.current_layer;\n }\n }\n return finalName;\n }\n\n /**\n * Set the current layer's position.\n * @param {Integer} newpos - The zero-based index of the new position of the layer. Range should be 0 to layers-1\n * @returns {{title: SVGGElement, previousName: string}|null} If the name was changed, returns {title:SVGGElement, previousName:string}; otherwise null.\n */\n setCurrentLayerPosition (newpos) {\n const layerCount = this.getNumLayers();\n if (!this.current_layer || newpos < 0 || newpos >= layerCount) {\n return null;\n }\n\n let oldpos;\n for (oldpos = 0; oldpos < layerCount; ++oldpos) {\n if (this.all_layers[oldpos] === this.current_layer) { break; }\n }\n // some unknown error condition (current_layer not in all_layers)\n if (oldpos === layerCount) { return null; }\n\n if (oldpos !== newpos) {\n // if our new position is below us, we need to insert before the node after newpos\n const currentGroup = this.current_layer.getGroup();\n const oldNextSibling = currentGroup.nextSibling;\n\n let refGroup = null;\n if (newpos > oldpos) {\n if (newpos < layerCount - 1) {\n refGroup = this.all_layers[newpos + 1].getGroup();\n }\n // if our new position is above us, we need to insert before the node at newpos\n } else {\n refGroup = this.all_layers[newpos].getGroup();\n }\n this.svgElem_.insertBefore(currentGroup, refGroup); // Ok to replace with `refGroup.before(currentGroup);`?\n\n this.identifyLayers();\n this.setCurrentLayer(this.getLayerName(newpos));\n\n return {\n currentGroup,\n oldNextSibling\n };\n }\n return null;\n }\n\n /**\n * @param {module:history.HistoryRecordingService} hrService\n * @returns {void}\n */\n mergeLayer (hrService) {\n const currentGroup = this.current_layer.getGroup();\n const prevGroup = $(currentGroup).prev()[0];\n if (!prevGroup) { return; }\n\n hrService.startBatchCommand('Merge Layer');\n\n const layerNextSibling = currentGroup.nextSibling;\n hrService.removeElement(currentGroup, layerNextSibling, this.svgElem_);\n\n while (currentGroup.firstChild) {\n const child = currentGroup.firstChild;\n if (child.localName === 'title') {\n hrService.removeElement(child, child.nextSibling, currentGroup);\n child.remove();\n continue;\n }\n const oldNextSibling = child.nextSibling;\n prevGroup.append(child);\n hrService.moveElement(child, oldNextSibling, currentGroup);\n }\n\n // Remove current layer's group\n this.current_layer.removeGroup();\n // Remove the current layer and set the previous layer as the new current layer\n const index = this.all_layers.indexOf(this.current_layer);\n if (index > 0) {\n const name = this.current_layer.getName();\n this.current_layer = this.all_layers[index - 1];\n this.all_layers.splice(index, 1);\n delete this.layer_map[name];\n }\n\n hrService.endBatchCommand();\n }\n\n /**\n * @param {module:history.HistoryRecordingService} hrService\n * @returns {void}\n */\n mergeAllLayers (hrService) {\n // Set the current layer to the last layer.\n this.current_layer = this.all_layers[this.all_layers.length - 1];\n\n hrService.startBatchCommand('Merge all Layers');\n while (this.all_layers.length > 1) {\n this.mergeLayer(hrService);\n }\n hrService.endBatchCommand();\n }\n\n /**\n * Sets the current layer. If the name is not a valid layer name, then this\n * function returns `false`. Otherwise it returns `true`. This is not an\n * undo-able action.\n * @param {string} name - The name of the layer you want to switch to.\n * @returns {boolean} `true` if the current layer was switched, otherwise `false`\n */\n setCurrentLayer (name) {\n const layer = this.layer_map[name];\n if (layer) {\n if (this.current_layer) {\n this.current_layer.deactivate();\n }\n this.current_layer = layer;\n this.current_layer.activate();\n return true;\n }\n return false;\n }\n\n /**\n * Deletes the current layer from the drawing and then clears the selection.\n * This function then calls the 'changed' handler. This is an undoable action.\n * @todo Does this actually call the 'changed' handler?\n * @returns {SVGGElement} The SVGGElement of the layer removed or null.\n */\n deleteCurrentLayer () {\n if (this.current_layer && this.getNumLayers() > 1) {\n const oldLayerGroup = this.current_layer.removeGroup();\n this.identifyLayers();\n return oldLayerGroup;\n }\n return null;\n }\n\n /**\n * Updates layer system and sets the current layer to the\n * top-most layer (last `<g>` child of this drawing).\n * @returns {void}\n */\n identifyLayers () {\n this.all_layers = [];\n this.layer_map = {};\n const numchildren = this.svgElem_.childNodes.length;\n // loop through all children of SVG element\n const orphans = [], layernames = [];\n let layer = null;\n let childgroups = false;\n for (let i = 0; i < numchildren; ++i) {\n const child = this.svgElem_.childNodes.item(i);\n // for each g, find its layer name\n if (child && child.nodeType === 1) {\n if (child.tagName === 'g') {\n childgroups = true;\n const name = findLayerNameInGroup(child);\n if (name) {\n layernames.push(name);\n layer = new Layer(name, child);\n this.all_layers.push(layer);\n this.layer_map[name] = layer;\n } else {\n // if group did not have a name, it is an orphan\n orphans.push(child);\n }\n } else if (visElems.includes(child.nodeName)) {\n // Child is \"visible\" (i.e. not a <title> or <defs> element), so it is an orphan\n orphans.push(child);\n }\n }\n }\n\n // If orphans or no layers found, create a new layer and add all the orphans to it\n if (orphans.length > 0 || !childgroups) {\n layer = new Layer(getNewLayerName(layernames), null, this.svgElem_);\n layer.appendChildren(orphans);\n this.all_layers.push(layer);\n this.layer_map[name] = layer;\n } else {\n layer.activate();\n }\n this.current_layer = layer;\n }\n\n /**\n * Creates a new top-level layer in the drawing with the given name and\n * makes it the current layer.\n * @param {string} name - The given name. If the layer name exists, a new name will be generated.\n * @param {module:history.HistoryRecordingService} hrService - History recording service\n * @returns {SVGGElement} The SVGGElement of the new layer, which is\n * also the current layer of this drawing.\n */\n createLayer (name, hrService) {\n if (this.current_layer) {\n this.current_layer.deactivate();\n }\n // Check for duplicate name.\n if (name === undefined || name === null || name === '' || this.layer_map[name]) {\n name = getNewLayerName(Object.keys(this.layer_map));\n }\n\n // Crate new layer and add to DOM as last layer\n const layer = new Layer(name, null, this.svgElem_);\n // Like to assume hrService exists, but this is backwards compatible with old version of createLayer.\n if (hrService) {\n hrService.startBatchCommand('Create Layer');\n hrService.insertElement(layer.getGroup());\n hrService.endBatchCommand();\n }\n\n this.all_layers.push(layer);\n this.layer_map[name] = layer;\n this.current_layer = layer;\n return layer.getGroup();\n }\n\n /**\n * Creates a copy of the current layer with the given name and makes it the current layer.\n * @param {string} name - The given name. If the layer name exists, a new name will be generated.\n * @param {module:history.HistoryRecordingService} hrService - History recording service\n * @returns {SVGGElement} The SVGGElement of the new layer, which is\n * also the current layer of this drawing.\n */\n cloneLayer (name, hrService) {\n if (!this.current_layer) { return null; }\n this.current_layer.deactivate();\n // Check for duplicate name.\n if (name === undefined || name === null || name === '' || this.layer_map[name]) {\n name = getNewLayerName(Object.keys(this.layer_map));\n }\n\n // Create new group and add to DOM just after current_layer\n const currentGroup = this.current_layer.getGroup();\n const layer = new Layer(name, currentGroup, this.svgElem_);\n const group = layer.getGroup();\n\n // Clone children\n const children = [...currentGroup.childNodes];\n children.forEach((child) => {\n if (child.localName === 'title') { return; }\n group.append(this.copyElem(child));\n });\n\n if (hrService) {\n hrService.startBatchCommand('Duplicate Layer');\n hrService.insertElement(group);\n hrService.endBatchCommand();\n }\n\n // Update layer containers and current_layer.\n const index = this.all_layers.indexOf(this.current_layer);\n if (index >= 0) {\n this.all_layers.splice(index + 1, 0, layer);\n } else {\n this.all_layers.push(layer);\n }\n this.layer_map[name] = layer;\n this.current_layer = layer;\n return group;\n }\n\n /**\n * Returns whether the layer is visible. If the layer name is not valid,\n * then this function returns `false`.\n * @param {string} layerName - The name of the layer which you want to query.\n * @returns {boolean} The visibility state of the layer, or `false` if the layer name was invalid.\n */\n getLayerVisibility (layerName) {\n const layer = this.layer_map[layerName];\n return layer ? layer.isVisible() : false;\n }\n\n /**\n * Sets the visibility of the layer. If the layer name is not valid, this\n * function returns `null`, otherwise it returns the `SVGElement` representing\n * the layer. This is an undo-able action.\n * @param {string} layerName - The name of the layer to change the visibility\n * @param {boolean} bVisible - Whether the layer should be visible\n * @returns {?SVGGElement} The SVGGElement representing the layer if the\n * `layerName` was valid, otherwise `null`.\n */\n setLayerVisibility (layerName, bVisible) {\n if (typeof bVisible !== 'boolean') {\n return null;\n }\n const layer = this.layer_map[layerName];\n if (!layer) { return null; }\n layer.setVisible(bVisible);\n return layer.getGroup();\n }\n\n /**\n * Returns the opacity of the given layer. If the input name is not a layer, `null` is returned.\n * @param {string} layerName - name of the layer on which to get the opacity\n * @returns {?Float} The opacity value of the given layer. This will be a value between 0.0 and 1.0, or `null`\n * if `layerName` is not a valid layer\n */\n getLayerOpacity (layerName) {\n const layer = this.layer_map[layerName];\n if (!layer) { return null; }\n return layer.getOpacity();\n }\n\n /**\n * Sets the opacity of the given layer. If the input name is not a layer,\n * nothing happens. If opacity is not a value between 0.0 and 1.0, then\n * nothing happens.\n * NOTE: this function exists solely to apply a highlighting/de-emphasis\n * effect to a layer. When it is possible for a user to affect the opacity\n * of a layer, we will need to allow this function to produce an undo-able\n * action.\n * @param {string} layerName - Name of the layer on which to set the opacity\n * @param {Float} opacity - A float value in the range 0.0-1.0\n * @returns {void}\n */\n setLayerOpacity (layerName, opacity) {\n if (typeof opacity !== 'number' || opacity < 0.0 || opacity > 1.0) {\n return;\n }\n const layer = this.layer_map[layerName];\n if (layer) {\n layer.setOpacity(opacity);\n }\n }\n\n /**\n * Create a clone of an element, updating its ID and its children's IDs when needed.\n * @param {Element} el - DOM element to clone\n * @returns {Element}\n */\n copyElem (el) {\n const that = this;\n const getNextIdClosure = function () { return that.getNextId(); };\n return utilCopyElem(el, getNextIdClosure);\n }\n}\n\n/**\n * Called to ensure that drawings will or will not have randomized ids.\n * The currentDrawing will have its nonce set if it doesn't already.\n * @function module:draw.randomizeIds\n * @param {boolean} enableRandomization - flag indicating if documents should have randomized ids\n * @param {draw.Drawing} currentDrawing\n * @returns {void}\n */\nexport const randomizeIds = function (enableRandomization, currentDrawing) {\n randIds = enableRandomization === false\n ? RandomizeModes.NEVER_RANDOMIZE\n : RandomizeModes.ALWAYS_RANDOMIZE;\n\n if (randIds === RandomizeModes.ALWAYS_RANDOMIZE && !currentDrawing.getNonce()) {\n currentDrawing.setNonce(Math.floor(Math.random() * 100001));\n } else if (randIds === RandomizeModes.NEVER_RANDOMIZE && currentDrawing.getNonce()) {\n currentDrawing.clearNonce();\n }\n};\n\n// Layer API Functions\n\n/**\n* Group: Layers.\n*/\n\n/**\n * @see {@link https://api.jquery.com/jQuery.data/}\n * @name external:jQuery.data\n */\n\n/**\n * @interface module:draw.DrawCanvasInit\n * @property {module:path.pathActions} pathActions\n * @property {external:jQuery.data} elData\n * @property {module:history.UndoManager} undoMgr\n */\n/**\n * @function module:draw.DrawCanvasInit#getCurrentGroup\n * @returns {Element}\n */\n/**\n * @function module:draw.DrawCanvasInit#setCurrentGroup\n * @param {Element} cg\n * @returns {void}\n*/\n/**\n * @function module:draw.DrawCanvasInit#getSelectedElements\n * @returns {Element[]} the array with selected DOM elements\n*/\n/**\n * @function module:draw.DrawCanvasInit#getSVGContent\n * @returns {SVGSVGElement}\n */\n/**\n * @function module:draw.DrawCanvasInit#getCurrentDrawing\n * @returns {module:draw.Drawing}\n */\n/**\n * @function module:draw.DrawCanvasInit#clearSelection\n * @param {boolean} [noCall] - When `true`, does not call the \"selected\" handler\n * @returns {void}\n*/\n/**\n * Run the callback function associated with the given event.\n * @function module:draw.DrawCanvasInit#call\n * @param {\"changed\"|\"contextset\"} ev - String with the event name\n * @param {module:svgcanvas.SvgCanvas#event:changed|module:svgcanvas.SvgCanvas#event:contextset} arg - Argument to pass through to the callback\n * function. If the event is \"changed\", a (single-item) array of `Element`s is\n * passed. If the event is \"contextset\", the arg is `null` or `Element`.\n * @returns {void}\n */\n/**\n * @function module:draw.DrawCanvasInit#addCommandToHistory\n * @param {Command} cmd\n * @returns {void}\n*/\n/**\n * @function module:draw.DrawCanvasInit#changeSVGContent\n * @returns {void}\n */\n\nlet canvas_;\n/**\n* @function module:draw.init\n* @param {module:draw.DrawCanvasInit} canvas\n* @returns {void}\n*/\nexport const init = function (canvas) {\n canvas_ = canvas;\n};\n\n/**\n* Updates layer system.\n* @function module:draw.identifyLayers\n* @returns {void}\n*/\nexport const identifyLayers = function () {\n leaveContext();\n canvas_.getCurrentDrawing().identifyLayers();\n};\n\n/**\n* Creates a new top-level layer in the drawing with the given name, sets the current layer\n* to it, and then clears the selection. This function then calls the 'changed' handler.\n* This is an undoable action.\n* @function module:draw.createLayer\n* @param {string} name - The given name\n* @param {module:history.HistoryRecordingService} hrService\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {void}\n*/\nexport const createLayer = function (name, hrService) {\n const newLayer = canvas_.getCurrentDrawing().createLayer(\n name,\n historyRecordingService(hrService)\n );\n canvas_.clearSelection();\n canvas_.call('changed', [newLayer]);\n};\n\n/**\n * Creates a new top-level layer in the drawing with the given name, copies all the current layer's contents\n * to it, and then clears the selection. This function then calls the 'changed' handler.\n * This is an undoable action.\n * @function module:draw.cloneLayer\n * @param {string} name - The given name. If the layer name exists, a new name will be generated.\n * @param {module:history.HistoryRecordingService} hrService - History recording service\n * @fires module:svgcanvas.SvgCanvas#event:changed\n * @returns {void}\n */\nexport const cloneLayer = function (name, hrService) {\n // Clone the current layer and make the cloned layer the new current layer\n const newLayer = canvas_.getCurrentDrawing().cloneLayer(name, historyRecordingService(hrService));\n\n canvas_.clearSelection();\n leaveContext();\n canvas_.call('changed', [newLayer]);\n};\n\n/**\n* Deletes the current layer from the drawing and then clears the selection. This function\n* then calls the 'changed' handler. This is an undoable action.\n* @function module:draw.deleteCurrentLayer\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {boolean} `true` if an old layer group was found to delete\n*/\nexport const deleteCurrentLayer = function () {\n let currentLayer = canvas_.getCurrentDrawing().getCurrentLayer();\n const {nextSibling} = currentLayer;\n const parent = currentLayer.parentNode;\n currentLayer = canvas_.getCurrentDrawing().deleteCurrentLayer();\n if (currentLayer) {\n const batchCmd = new BatchCommand('Delete Layer');\n // store in our Undo History\n batchCmd.addSubCommand(new RemoveElementCommand(currentLayer, nextSibling, parent));\n canvas_.addCommandToHistory(batchCmd);\n canvas_.clearSelection();\n canvas_.call('changed', [parent]);\n return true;\n }\n return false;\n};\n\n/**\n* Sets the current layer. If the name is not a valid layer name, then this function returns\n* false. Otherwise it returns true. This is not an undo-able action.\n* @function module:draw.setCurrentLayer\n* @param {string} name - The name of the layer you want to switch to.\n* @returns {boolean} true if the current layer was switched, otherwise false\n*/\nexport const setCurrentLayer = function (name) {\n const result = canvas_.getCurrentDrawing().setCurrentLayer(toXml(name));\n if (result) {\n canvas_.clearSelection();\n }\n return result;\n};\n\n/**\n* Renames the current layer. If the layer name is not valid (i.e. unique), then this function\n* does nothing and returns `false`, otherwise it returns `true`. This is an undo-able action.\n* @function module:draw.renameCurrentLayer\n* @param {string} newName - the new name you want to give the current layer. This name must\n* be unique among all layer names.\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {boolean} Whether the rename succeeded\n*/\nexport const renameCurrentLayer = function (newName) {\n const drawing = canvas_.getCurrentDrawing();\n const layer = drawing.getCurrentLayer();\n if (layer) {\n const result = drawing.setCurrentLayerName(newName, historyRecordingService());\n if (result) {\n canvas_.call('changed', [layer]);\n return true;\n }\n }\n return false;\n};\n\n/**\n* Changes the position of the current layer to the new value. If the new index is not valid,\n* this function does nothing and returns false, otherwise it returns true. This is an\n* undo-able action.\n* @function module:draw.setCurrentLayerPosition\n* @param {Integer} newPos - The zero-based index of the new position of the layer. This should be between\n* 0 and (number of layers - 1)\n* @returns {boolean} `true` if the current layer position was changed, `false` otherwise.\n*/\nexport const setCurrentLayerPosition = function (newPos) {\n const drawing = canvas_.getCurrentDrawing();\n const result = drawing.setCurrentLayerPosition(newPos);\n if (result) {\n canvas_.addCommandToHistory(new MoveElementCommand(result.currentGroup, result.oldNextSibling, canvas_.getSVGContent()));\n return true;\n }\n return false;\n};\n\n/**\n* Sets the visibility of the layer. If the layer name is not valid, this function return\n* `false`, otherwise it returns `true`. This is an undo-able action.\n* @function module:draw.setLayerVisibility\n* @param {string} layerName - The name of the layer to change the visibility\n* @param {boolean} bVisible - Whether the layer should be visible\n* @returns {boolean} true if the layer's visibility was set, false otherwise\n*/\nexport const setLayerVisibility = function (layerName, bVisible) {\n const drawing = canvas_.getCurrentDrawing();\n const prevVisibility = drawing.getLayerVisibility(layerName);\n const layer = drawing.setLayerVisibility(layerName, bVisible);\n if (layer) {\n const oldDisplay = prevVisibility ? 'inline' : 'none';\n canvas_.addCommandToHistory(new ChangeElementCommand(layer, {display: oldDisplay}, 'Layer Visibility'));\n } else {\n return false;\n }\n\n if (layer === drawing.getCurrentLayer()) {\n canvas_.clearSelection();\n canvas_.pathActions.clear();\n }\n // call('changed', [selected]);\n return true;\n};\n\n/**\n* Moves the selected elements to layerName. If the name is not a valid layer name, then `false`\n* is returned. Otherwise it returns `true`. This is an undo-able action.\n* @function module:draw.moveSelectedToLayer\n* @param {string} layerName - The name of the layer you want to which you want to move the selected elements\n* @returns {boolean} Whether the selected elements were moved to the layer.\n*/\nexport const moveSelectedToLayer = function (layerName) {\n // find the layer\n const drawing = canvas_.getCurrentDrawing();\n const layer = drawing.getLayerByName(layerName);\n if (!layer) { return false; }\n\n const batchCmd = new BatchCommand('Move Elements to Layer');\n\n // loop for each selected element and move it\n const selElems = canvas_.getSelectedElements();\n let i = selElems.length;\n while (i--) {\n const elem = selElems[i];\n if (!elem) { continue; }\n const oldNextSibling = elem.nextSibling;\n // TODO: this is pretty brittle!\n const oldLayer = elem.parentNode;\n layer.append(elem);\n batchCmd.addSubCommand(new MoveElementCommand(elem, oldNextSibling, oldLayer));\n }\n\n canvas_.addCommandToHistory(batchCmd);\n\n return true;\n};\n\n/**\n* @function module:draw.mergeLayer\n* @param {module:history.HistoryRecordingService} hrService\n* @returns {void}\n*/\nexport const mergeLayer = function (hrService) {\n canvas_.getCurrentDrawing().mergeLayer(historyRecordingService(hrService));\n canvas_.clearSelection();\n leaveContext();\n canvas_.changeSVGContent();\n};\n\n/**\n* @function module:draw.mergeAllLayers\n* @param {module:history.HistoryRecordingService} hrService\n* @returns {void}\n*/\nexport const mergeAllLayers = function (hrService) {\n canvas_.getCurrentDrawing().mergeAllLayers(historyRecordingService(hrService));\n canvas_.clearSelection();\n leaveContext();\n canvas_.changeSVGContent();\n};\n\n/**\n* Return from a group context to the regular kind, make any previously\n* disabled elements enabled again.\n* @function module:draw.leaveContext\n* @fires module:svgcanvas.SvgCanvas#event:contextset\n* @returns {void}\n*/\nexport const leaveContext = function () {\n const len = disabledElems.length;\n if (len) {\n for (let i = 0; i < len; i++) {\n const elem = disabledElems[i];\n const orig = canvas_.elData(elem, 'orig_opac');\n if (orig !== 1) {\n elem.setAttribute('opacity', orig);\n } else {\n elem.removeAttribute('opacity');\n }\n elem.setAttribute('style', 'pointer-events: inherit');\n }\n disabledElems = [];\n canvas_.clearSelection(true);\n canvas_.call('contextset', null);\n }\n canvas_.setCurrentGroup(null);\n};\n\n/**\n* Set the current context (for in-group editing).\n* @function module:draw.setContext\n* @param {Element} elem\n* @fires module:svgcanvas.SvgCanvas#event:contextset\n* @returns {void}\n*/\nexport const setContext = function (elem) {\n leaveContext();\n if (typeof elem === 'string') {\n elem = getElem(elem);\n }\n\n // Edit inside this group\n canvas_.setCurrentGroup(elem);\n\n // Disable other elements\n $(elem).parentsUntil('#svgcontent').andSelf().siblings().each(function () {\n const opac = this.getAttribute('opacity') || 1;\n // Store the original's opacity\n canvas_.elData(this, 'orig_opac', opac);\n this.setAttribute('opacity', opac * 0.33);\n this.setAttribute('style', 'pointer-events: none');\n disabledElems.push(this);\n });\n\n canvas_.clearSelection();\n canvas_.call('contextset', canvas_.getCurrentGroup());\n};\n\n/**\n* @memberof module:draw\n* @class Layer\n* @see {@link module:layer.Layer}\n*/\nexport {Layer};\n","/**\n * Tools for SVG sanitization.\n * @module sanitize\n * @license MIT\n *\n * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller\n */\n\nimport {getReverseNS, NS} from '../common/namespaces.js';\nimport {isGecko} from '../common/browser.js';\nimport {getHref, setHref, getUrlFromAttr} from '../common/utilities.js';\n\nconst REVERSE_NS = getReverseNS();\n\n// Todo: Split out into core attributes, presentation attributes, etc. so consistent\n/**\n * This defines which elements and attributes that we support (or at least\n * don't remove).\n * @type {PlainObject}\n */\n/* eslint-disable max-len */\nconst svgWhiteList_ = {\n // SVG Elements\n a: ['class', 'clip-path', 'clip-rule', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'id', 'mask', 'opacity', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'xlink:href', 'xlink:title'],\n circle: ['class', 'clip-path', 'clip-rule', 'cx', 'cy', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'id', 'mask', 'opacity', 'r', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform'],\n clipPath: ['class', 'clipPathUnits', 'id'],\n defs: [],\n style: ['type'],\n desc: [],\n ellipse: ['class', 'clip-path', 'clip-rule', 'cx', 'cy', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'id', 'mask', 'opacity', 'requiredFeatures', 'rx', 'ry', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform'],\n feGaussianBlur: ['class', 'color-interpolation-filters', 'id', 'requiredFeatures', 'stdDeviation'],\n feMorphology: ['class', 'in', 'operator', 'radius'],\n filter: ['class', 'color-interpolation-filters', 'filterRes', 'filterUnits', 'height', 'id', 'primitiveUnits', 'requiredFeatures', 'width', 'x', 'xlink:href', 'y'],\n foreignObject: ['class', 'font-size', 'height', 'id', 'opacity', 'requiredFeatures', 'style', 'transform', 'width', 'x', 'y'],\n g: ['class', 'clip-path', 'clip-rule', 'id', 'display', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'mask', 'opacity', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'font-family', 'font-size', 'font-style', 'font-weight', 'text-anchor'],\n image: ['class', 'clip-path', 'clip-rule', 'filter', 'height', 'id', 'mask', 'opacity', 'requiredFeatures', 'style', 'systemLanguage', 'transform', 'width', 'x', 'xlink:href', 'xlink:title', 'y'],\n line: ['class', 'clip-path', 'clip-rule', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'id', 'marker-end', 'marker-mid', 'marker-start', 'mask', 'opacity', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'x1', 'x2', 'y1', 'y2'],\n linearGradient: ['class', 'id', 'gradientTransform', 'gradientUnits', 'requiredFeatures', 'spreadMethod', 'systemLanguage', 'x1', 'x2', 'xlink:href', 'y1', 'y2'],\n marker: ['id', 'class', 'markerHeight', 'markerUnits', 'markerWidth', 'orient', 'preserveAspectRatio', 'refX', 'refY', 'systemLanguage', 'viewBox'],\n mask: ['class', 'height', 'id', 'maskContentUnits', 'maskUnits', 'width', 'x', 'y'],\n metadata: ['class', 'id'],\n path: ['class', 'clip-path', 'clip-rule', 'd', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'id', 'marker-end', 'marker-mid', 'marker-start', 'mask', 'opacity', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform'],\n pattern: ['class', 'height', 'id', 'patternContentUnits', 'patternTransform', 'patternUnits', 'requiredFeatures', 'style', 'systemLanguage', 'viewBox', 'width', 'x', 'xlink:href', 'y'],\n polygon: ['class', 'clip-path', 'clip-rule', 'id', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'id', 'class', 'marker-end', 'marker-mid', 'marker-start', 'mask', 'opacity', 'points', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform'],\n polyline: ['class', 'clip-path', 'clip-rule', 'id', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'marker-end', 'marker-mid', 'marker-start', 'mask', 'opacity', 'points', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform'],\n radialGradient: ['class', 'cx', 'cy', 'fx', 'fy', 'gradientTransform', 'gradientUnits', 'id', 'r', 'requiredFeatures', 'spreadMethod', 'systemLanguage', 'xlink:href'],\n rect: ['class', 'clip-path', 'clip-rule', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'height', 'id', 'mask', 'opacity', 'requiredFeatures', 'rx', 'ry', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'width', 'x', 'y'],\n stop: ['class', 'id', 'offset', 'requiredFeatures', 'stop-color', 'stop-opacity', 'style', 'systemLanguage'],\n svg: ['class', 'clip-path', 'clip-rule', 'filter', 'id', 'height', 'mask', 'preserveAspectRatio', 'requiredFeatures', 'style', 'systemLanguage', 'viewBox', 'width', 'x', 'xmlns', 'xmlns:se', 'xmlns:xlink', 'y'],\n switch: ['class', 'id', 'requiredFeatures', 'systemLanguage'],\n symbol: ['class', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'font-family', 'font-size', 'font-style', 'font-weight', 'id', 'opacity', 'preserveAspectRatio', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'viewBox'],\n text: ['class', 'clip-path', 'clip-rule', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'font-family', 'font-size', 'font-style', 'font-weight', 'id', 'mask', 'opacity', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'text-anchor', 'transform', 'x', 'xml:space', 'y'],\n textPath: ['class', 'id', 'method', 'requiredFeatures', 'spacing', 'startOffset', 'style', 'systemLanguage', 'transform', 'xlink:href'],\n title: [],\n tspan: ['class', 'clip-path', 'clip-rule', 'dx', 'dy', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'font-family', 'font-size', 'font-style', 'font-weight', 'id', 'mask', 'opacity', 'requiredFeatures', 'rotate', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'text-anchor', 'textLength', 'transform', 'x', 'xml:space', 'y'],\n use: ['class', 'clip-path', 'clip-rule', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'height', 'id', 'mask', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'transform', 'width', 'x', 'xlink:href', 'y'],\n\n // MathML Elements\n annotation: ['encoding'],\n 'annotation-xml': ['encoding'],\n maction: ['actiontype', 'other', 'selection'],\n math: ['class', 'id', 'display', 'xmlns'],\n menclose: ['notation'],\n merror: [],\n mfrac: ['linethickness'],\n mi: ['mathvariant'],\n mmultiscripts: [],\n mn: [],\n mo: ['fence', 'lspace', 'maxsize', 'minsize', 'rspace', 'stretchy'],\n mover: [],\n mpadded: ['lspace', 'width', 'height', 'depth', 'voffset'],\n mphantom: [],\n mprescripts: [],\n mroot: [],\n mrow: ['xlink:href', 'xlink:type', 'xmlns:xlink'],\n mspace: ['depth', 'height', 'width'],\n msqrt: [],\n mstyle: ['displaystyle', 'mathbackground', 'mathcolor', 'mathvariant', 'scriptlevel'],\n msub: [],\n msubsup: [],\n msup: [],\n mtable: ['align', 'columnalign', 'columnlines', 'columnspacing', 'displaystyle', 'equalcolumns', 'equalrows', 'frame', 'rowalign', 'rowlines', 'rowspacing', 'width'],\n mtd: ['columnalign', 'columnspan', 'rowalign', 'rowspan'],\n mtext: [],\n mtr: ['columnalign', 'rowalign'],\n munder: [],\n munderover: [],\n none: [],\n semantics: []\n};\n/* eslint-enable max-len */\n\n// Produce a Namespace-aware version of svgWhitelist\nconst svgWhiteListNS_ = {};\nObject.entries(svgWhiteList_).forEach(function ([elt, atts]) {\n const attNS = {};\n Object.entries(atts).forEach(function ([i, att]) {\n if (att.includes(':')) {\n const v = att.split(':');\n attNS[v[1]] = NS[(v[0]).toUpperCase()];\n } else {\n attNS[att] = att === 'xmlns' ? NS.XMLNS : null;\n }\n });\n svgWhiteListNS_[elt] = attNS;\n});\n\n/**\n* Sanitizes the input node and its children.\n* It only keeps what is allowed from our whitelist defined above.\n* @function module:sanitize.sanitizeSvg\n* @param {Text|Element} node - The DOM element to be checked (we'll also check its children) or text node to be cleaned up\n* @returns {void}\n*/\nexport const sanitizeSvg = function (node) {\n // Cleanup text nodes\n if (node.nodeType === 3) { // 3 === TEXT_NODE\n // Trim whitespace\n node.nodeValue = node.nodeValue.replace(/^\\s+|\\s+$/g, '');\n // Remove if empty\n if (!node.nodeValue.length) {\n node.remove();\n }\n }\n\n // We only care about element nodes.\n // Automatically return for all non-element nodes, such as comments, etc.\n if (node.nodeType !== 1) { // 1 == ELEMENT_NODE\n return;\n }\n\n const doc = node.ownerDocument;\n const parent = node.parentNode;\n // can parent ever be null here? I think the root node's parent is the document...\n if (!doc || !parent) {\n return;\n }\n\n const allowedAttrs = svgWhiteList_[node.nodeName];\n const allowedAttrsNS = svgWhiteListNS_[node.nodeName];\n // if this element is supported, sanitize it\n if (typeof allowedAttrs !== 'undefined') {\n const seAttrs = [];\n let i = node.attributes.length;\n while (i--) {\n // if the attribute is not in our whitelist, then remove it\n // could use jQuery's inArray(), but I don't know if that's any better\n const attr = node.attributes.item(i);\n const attrName = attr.nodeName;\n const attrLocalName = attr.localName;\n const attrNsURI = attr.namespaceURI;\n // Check that an attribute with the correct localName in the correct namespace is on\n // our whitelist or is a namespace declaration for one of our allowed namespaces\n if (!({}.hasOwnProperty.call(allowedAttrsNS, attrLocalName) &&\n attrNsURI === allowedAttrsNS[attrLocalName] && attrNsURI !== NS.XMLNS\n ) &&\n !(attrNsURI === NS.XMLNS && REVERSE_NS[attr.value])) {\n // TODO(codedread): Programmatically add the se: attributes to the NS-aware whitelist.\n // Bypassing the whitelist to allow se: prefixes.\n // Is there a more appropriate way to do this?\n if (attrName.startsWith('se:') || attrName.startsWith('data-')) {\n seAttrs.push([attrName, attr.value]);\n }\n node.removeAttributeNS(attrNsURI, attrLocalName);\n }\n\n // Add spaces before negative signs where necessary\n if (isGecko()) {\n switch (attrName) {\n case 'transform':\n case 'gradientTransform':\n case 'patternTransform': {\n const val = attr.value.replace(/(\\d)-/g, '$1 -');\n // const val = attr.value.replace(/(?<digit>\\d)-/g, '$<digit> -');\n node.setAttribute(attrName, val);\n break;\n }\n }\n }\n\n // For the style attribute, rewrite it in terms of XML presentational attributes\n if (attrName === 'style') {\n const props = attr.value.split(';');\n let p = props.length;\n while (p--) {\n const [name, val] = props[p].split(':');\n const styleAttrName = (name || '').trim();\n const styleAttrVal = (val || '').trim();\n // Now check that this attribute is supported\n if (allowedAttrs.includes(styleAttrName)) {\n node.setAttribute(styleAttrName, styleAttrVal);\n }\n }\n node.removeAttribute('style');\n }\n }\n\n Object.values(seAttrs).forEach(([att, val]) => {\n node.setAttributeNS(NS.SE, att, val);\n });\n\n // for some elements that have a xlink:href, ensure the URI refers to a local element\n // (but not for links)\n const href = getHref(node);\n if (href &&\n ['filter', 'linearGradient', 'pattern',\n 'radialGradient', 'textPath', 'use'].includes(node.nodeName)) {\n // TODO: we simply check if the first character is a #, is this bullet-proof?\n if (href[0] !== '#') {\n // remove the attribute (but keep the element)\n setHref(node, '');\n node.removeAttributeNS(NS.XLINK, 'href');\n }\n }\n\n // Safari crashes on a <use> without a xlink:href, so we just remove the node here\n if (node.nodeName === 'use' && !getHref(node)) {\n node.remove();\n return;\n }\n // if the element has attributes pointing to a non-local reference,\n // need to remove the attribute\n Object.values(['clip-path', 'fill', 'filter', 'marker-end', 'marker-mid', 'marker-start', 'mask', 'stroke'], function (attr) {\n let val = node.getAttribute(attr);\n if (val) {\n val = getUrlFromAttr(val);\n // simply check for first character being a '#'\n if (val && val[0] !== '#') {\n node.setAttribute(attr, '');\n node.removeAttribute(attr);\n }\n }\n });\n\n // recurse to children\n i = node.childNodes.length;\n while (i--) { sanitizeSvg(node.childNodes.item(i)); }\n // else (element not supported), remove it\n } else {\n // remove all children from this node and insert them before this node\n // TODO: in the case of animation elements this will hardly ever be correct\n const children = [];\n while (node.hasChildNodes()) {\n children.push(parent.insertBefore(node.firstChild, node));\n }\n\n // remove this node from the document altogether\n node.remove();\n\n // call sanitizeSvg on each of those children\n let i = children.length;\n while (i--) { sanitizeSvg(children[i]); }\n }\n};\n","/* globals jQuery */\n/**\n * Manipulating coordinates.\n * @module coords\n * @license MIT\n */\n\nimport '../common/svgpathseg.js';\nimport {\n snapToGrid, assignAttributes, getBBox, getRefElem, findDefs\n} from '../common/utilities.js';\nimport {\n transformPoint, transformListToTransform, matrixMultiply, transformBox\n} from '../common/math.js';\nimport {getTransformList} from '../common/svgtransformlist.js';\n\nconst $ = jQuery;\n\n// this is how we map paths to our preferred relative segment types\nconst pathMap = [\n 0, 'z', 'M', 'm', 'L', 'l', 'C', 'c', 'Q', 'q', 'A', 'a',\n 'H', 'h', 'V', 'v', 'S', 's', 'T', 't'\n];\n\n/**\n * @interface module:coords.EditorContext\n */\n/**\n * @function module:coords.EditorContext#getGridSnapping\n * @returns {boolean}\n */\n/**\n * @function module:coords.EditorContext#getDrawing\n * @returns {module:draw.Drawing}\n*/\n/**\n * @function module:coords.EditorContext#getSVGRoot\n * @returns {SVGSVGElement}\n*/\n\nlet editorContext_ = null;\n\n/**\n* @function module:coords.init\n* @param {module:svgcanvas.SvgCanvas#event:pointsAdded} editorContext\n* @returns {void}\n*/\nexport const init = function (editorContext) {\n editorContext_ = editorContext;\n};\n\n/**\n * Applies coordinate changes to an element based on the given matrix.\n * @name module:coords.remapElement\n * @type {module:path.EditorContext#remapElement}\n*/\nexport const remapElement = function (selected, changes, m) {\n const remap = function (x, y) { return transformPoint(x, y, m); },\n scalew = function (w) { return m.a * w; },\n scaleh = function (h) { return m.d * h; },\n doSnapping = editorContext_.getGridSnapping() && selected.parentNode.parentNode.localName === 'svg',\n finishUp = function () {\n if (doSnapping) {\n Object.entries(changes).forEach(([o, value]) => {\n changes[o] = snapToGrid(value);\n });\n }\n assignAttributes(selected, changes, 1000, true);\n },\n box = getBBox(selected);\n\n for (let i = 0; i < 2; i++) {\n const type = i === 0 ? 'fill' : 'stroke';\n const attrVal = selected.getAttribute(type);\n if (attrVal && attrVal.startsWith('url(')) {\n if (m.a < 0 || m.d < 0) {\n const grad = getRefElem(attrVal);\n const newgrad = grad.cloneNode(true);\n if (m.a < 0) {\n // flip x\n const x1 = newgrad.getAttribute('x1');\n const x2 = newgrad.getAttribute('x2');\n newgrad.setAttribute('x1', -(x1 - 1));\n newgrad.setAttribute('x2', -(x2 - 1));\n }\n\n if (m.d < 0) {\n // flip y\n const y1 = newgrad.getAttribute('y1');\n const y2 = newgrad.getAttribute('y2');\n newgrad.setAttribute('y1', -(y1 - 1));\n newgrad.setAttribute('y2', -(y2 - 1));\n }\n newgrad.id = editorContext_.getDrawing().getNextId();\n findDefs().append(newgrad);\n selected.setAttribute(type, 'url(#' + newgrad.id + ')');\n }\n\n // Not really working :(\n // if (selected.tagName === 'path') {\n // reorientGrads(selected, m);\n // }\n }\n }\n\n const elName = selected.tagName;\n if (elName === 'g' || elName === 'text' || elName === 'tspan' || elName === 'use') {\n // if it was a translate, then just update x,y\n if (m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1 && (m.e !== 0 || m.f !== 0)) {\n // [T][M] = [M][T']\n // therefore [T'] = [M_inv][T][M]\n const existing = transformListToTransform(selected).matrix,\n tNew = matrixMultiply(existing.inverse(), m, existing);\n changes.x = Number.parseFloat(changes.x) + tNew.e;\n changes.y = Number.parseFloat(changes.y) + tNew.f;\n } else {\n // we just absorb all matrices into the element and don't do any remapping\n const chlist = getTransformList(selected);\n const mt = editorContext_.getSVGRoot().createSVGTransform();\n mt.setMatrix(matrixMultiply(transformListToTransform(chlist).matrix, m));\n chlist.clear();\n chlist.appendItem(mt);\n }\n }\n\n // now we have a set of changes and an applied reduced transform list\n // we apply the changes directly to the DOM\n switch (elName) {\n case 'foreignObject':\n case 'rect':\n case 'image': {\n // Allow images to be inverted (give them matrix when flipped)\n if (elName === 'image' && (m.a < 0 || m.d < 0)) {\n // Convert to matrix\n const chlist = getTransformList(selected);\n const mt = editorContext_.getSVGRoot().createSVGTransform();\n mt.setMatrix(matrixMultiply(transformListToTransform(chlist).matrix, m));\n chlist.clear();\n chlist.appendItem(mt);\n } else {\n const pt1 = remap(changes.x, changes.y);\n changes.width = scalew(changes.width);\n changes.height = scaleh(changes.height);\n changes.x = pt1.x + Math.min(0, changes.width);\n changes.y = pt1.y + Math.min(0, changes.height);\n changes.width = Math.abs(changes.width);\n changes.height = Math.abs(changes.height);\n }\n finishUp();\n break;\n } case 'ellipse': {\n const c = remap(changes.cx, changes.cy);\n changes.cx = c.x;\n changes.cy = c.y;\n changes.rx = scalew(changes.rx);\n changes.ry = scaleh(changes.ry);\n changes.rx = Math.abs(changes.rx);\n changes.ry = Math.abs(changes.ry);\n finishUp();\n break;\n } case 'circle': {\n const c = remap(changes.cx, changes.cy);\n changes.cx = c.x;\n changes.cy = c.y;\n // take the minimum of the new selected box's dimensions for the new circle radius\n const tbox = transformBox(box.x, box.y, box.width, box.height, m);\n const w = tbox.tr.x - tbox.tl.x, h = tbox.bl.y - tbox.tl.y;\n changes.r = Math.min(w / 2, h / 2);\n\n if (changes.r) { changes.r = Math.abs(changes.r); }\n finishUp();\n break;\n } case 'line': {\n const pt1 = remap(changes.x1, changes.y1);\n const pt2 = remap(changes.x2, changes.y2);\n changes.x1 = pt1.x;\n changes.y1 = pt1.y;\n changes.x2 = pt2.x;\n changes.y2 = pt2.y;\n } // Fallthrough\n case 'text':\n case 'tspan':\n case 'use': {\n finishUp();\n break;\n } case 'g': {\n const gsvg = $(selected).data('gsvg');\n if (gsvg) {\n assignAttributes(gsvg, changes, 1000, true);\n }\n break;\n } case 'polyline':\n case 'polygon': {\n const len = changes.points.length;\n for (let i = 0; i < len; ++i) {\n const pt = changes.points[i];\n const {x, y} = remap(pt.x, pt.y);\n changes.points[i].x = x;\n changes.points[i].y = y;\n }\n\n // const len = changes.points.length;\n let pstr = '';\n for (let i = 0; i < len; ++i) {\n const pt = changes.points[i];\n pstr += pt.x + ',' + pt.y + ' ';\n }\n selected.setAttribute('points', pstr);\n break;\n } case 'path': {\n const segList = selected.pathSegList;\n let len = segList.numberOfItems;\n changes.d = [];\n for (let i = 0; i < len; ++i) {\n const seg = segList.getItem(i);\n changes.d[i] = {\n type: seg.pathSegType,\n x: seg.x,\n y: seg.y,\n x1: seg.x1,\n y1: seg.y1,\n x2: seg.x2,\n y2: seg.y2,\n r1: seg.r1,\n r2: seg.r2,\n angle: seg.angle,\n largeArcFlag: seg.largeArcFlag,\n sweepFlag: seg.sweepFlag\n };\n }\n\n len = changes.d.length;\n const firstseg = changes.d[0],\n currentpt = remap(firstseg.x, firstseg.y);\n changes.d[0].x = currentpt.x;\n changes.d[0].y = currentpt.y;\n for (let i = 1; i < len; ++i) {\n const seg = changes.d[i];\n const {type} = seg;\n // if absolute or first segment, we want to remap x, y, x1, y1, x2, y2\n // if relative, we want to scalew, scaleh\n if (type % 2 === 0) { // absolute\n const thisx = (seg.x !== undefined) ? seg.x : currentpt.x, // for V commands\n thisy = (seg.y !== undefined) ? seg.y : currentpt.y; // for H commands\n const pt = remap(thisx, thisy);\n const pt1 = remap(seg.x1, seg.y1);\n const pt2 = remap(seg.x2, seg.y2);\n seg.x = pt.x;\n seg.y = pt.y;\n seg.x1 = pt1.x;\n seg.y1 = pt1.y;\n seg.x2 = pt2.x;\n seg.y2 = pt2.y;\n seg.r1 = scalew(seg.r1);\n seg.r2 = scaleh(seg.r2);\n } else { // relative\n seg.x = scalew(seg.x);\n seg.y = scaleh(seg.y);\n seg.x1 = scalew(seg.x1);\n seg.y1 = scaleh(seg.y1);\n seg.x2 = scalew(seg.x2);\n seg.y2 = scaleh(seg.y2);\n seg.r1 = scalew(seg.r1);\n seg.r2 = scaleh(seg.r2);\n }\n } // for each segment\n\n let dstr = '';\n len = changes.d.length;\n for (let i = 0; i < len; ++i) {\n const seg = changes.d[i];\n const {type} = seg;\n dstr += pathMap[type];\n switch (type) {\n case 13: // relative horizontal line (h)\n case 12: // absolute horizontal line (H)\n dstr += seg.x + ' ';\n break;\n case 15: // relative vertical line (v)\n case 14: // absolute vertical line (V)\n dstr += seg.y + ' ';\n break;\n case 3: // relative move (m)\n case 5: // relative line (l)\n case 19: // relative smooth quad (t)\n case 2: // absolute move (M)\n case 4: // absolute line (L)\n case 18: // absolute smooth quad (T)\n dstr += seg.x + ',' + seg.y + ' ';\n break;\n case 7: // relative cubic (c)\n case 6: // absolute cubic (C)\n dstr += seg.x1 + ',' + seg.y1 + ' ' + seg.x2 + ',' + seg.y2 + ' ' +\n seg.x + ',' + seg.y + ' ';\n break;\n case 9: // relative quad (q)\n case 8: // absolute quad (Q)\n dstr += seg.x1 + ',' + seg.y1 + ' ' + seg.x + ',' + seg.y + ' ';\n break;\n case 11: // relative elliptical arc (a)\n case 10: // absolute elliptical arc (A)\n dstr += seg.r1 + ',' + seg.r2 + ' ' + seg.angle + ' ' + Number(seg.largeArcFlag) +\n ' ' + Number(seg.sweepFlag) + ' ' + seg.x + ',' + seg.y + ' ';\n break;\n case 17: // relative smooth cubic (s)\n case 16: // absolute smooth cubic (S)\n dstr += seg.x2 + ',' + seg.y2 + ' ' + seg.x + ',' + seg.y + ' ';\n break;\n }\n }\n\n selected.setAttribute('d', dstr);\n break;\n }\n }\n};\n","/* globals jQuery */\n/**\n * Recalculate.\n * @module recalculate\n * @license MIT\n */\n\nimport jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr`\nimport {NS} from '../common/namespaces.js';\nimport {convertToNum} from '../common/units.js';\nimport {isWebkit} from '../common/browser.js';\nimport {getTransformList} from '../common/svgtransformlist.js';\nimport {getRotationAngle, getHref, getBBox, getRefElem, isNullish} from '../common/utilities.js';\nimport {BatchCommand, ChangeElementCommand} from './history.js';\nimport {remapElement} from './coords.js';\nimport {\n isIdentity, matrixMultiply, transformPoint, transformListToTransform,\n hasMatrixTransform\n} from '../common/math.js';\n\nconst $ = jQueryPluginSVG(jQuery);\n\nlet context_;\n\n/**\n* @interface module:recalculate.EditorContext\n*/\n/**\n * @function module:recalculate.EditorContext#getSVGRoot\n * @returns {SVGSVGElement} The root DOM element\n */\n/**\n * @function module:recalculate.EditorContext#getStartTransform\n * @returns {string}\n*/\n/**\n * @function module:recalculate.EditorContext#setStartTransform\n * @param {string} transform\n * @returns {void}\n */\n\n/**\n* @function module:recalculate.init\n* @param {module:recalculate.EditorContext} editorContext\n* @returns {void}\n*/\nexport const init = function (editorContext) {\n context_ = editorContext;\n};\n\n/**\n* Updates a `<clipPath>`s values based on the given translation of an element.\n* @function module:recalculate.updateClipPath\n* @param {string} attr - The clip-path attribute value with the clipPath's ID\n* @param {Float} tx - The translation's x value\n* @param {Float} ty - The translation's y value\n* @returns {void}\n*/\nexport const updateClipPath = function (attr, tx, ty) {\n const path = getRefElem(attr).firstChild;\n const cpXform = getTransformList(path);\n const newxlate = context_.getSVGRoot().createSVGTransform();\n newxlate.setTranslate(tx, ty);\n\n cpXform.appendItem(newxlate);\n\n // Update clipPath's dimensions\n recalculateDimensions(path);\n};\n\n/**\n* Decides the course of action based on the element's transform list.\n* @function module:recalculate.recalculateDimensions\n* @param {Element} selected - The DOM element to recalculate\n* @returns {Command} Undo command object with the resulting change\n*/\nexport const recalculateDimensions = function (selected) {\n if (isNullish(selected)) { return null; }\n\n // Firefox Issue - 1081\n if (selected.nodeName === 'svg' && navigator.userAgent.includes('Firefox/20')) {\n return null;\n }\n\n const svgroot = context_.getSVGRoot();\n const tlist = getTransformList(selected);\n\n // remove any unnecessary transforms\n if (tlist && tlist.numberOfItems > 0) {\n let k = tlist.numberOfItems;\n const noi = k;\n while (k--) {\n const xform = tlist.getItem(k);\n if (xform.type === 0) {\n tlist.removeItem(k);\n // remove identity matrices\n } else if (xform.type === 1) {\n if (isIdentity(xform.matrix)) {\n if (noi === 1) {\n // Overcome Chrome bug (though only when noi is 1) with\n // `removeItem` preventing `removeAttribute` from\n // subsequently working\n // See https://bugs.chromium.org/p/chromium/issues/detail?id=843901\n selected.removeAttribute('transform');\n return null;\n }\n tlist.removeItem(k);\n }\n // remove zero-degree rotations\n } else if (xform.type === 4) {\n if (xform.angle === 0) {\n tlist.removeItem(k);\n }\n }\n }\n // End here if all it has is a rotation\n if (tlist.numberOfItems === 1 &&\n getRotationAngle(selected)) { return null; }\n }\n\n // if this element had no transforms, we are done\n if (!tlist || tlist.numberOfItems === 0) {\n // Chrome apparently had a bug that requires clearing the attribute first.\n selected.setAttribute('transform', '');\n // However, this still next line currently doesn't work at all in Chrome\n selected.removeAttribute('transform');\n // selected.transform.baseVal.clear(); // Didn't help for Chrome bug\n return null;\n }\n\n // TODO: Make this work for more than 2\n if (tlist) {\n let mxs = [];\n let k = tlist.numberOfItems;\n while (k--) {\n const xform = tlist.getItem(k);\n if (xform.type === 1) {\n mxs.push([xform.matrix, k]);\n } else if (mxs.length) {\n mxs = [];\n }\n }\n if (mxs.length === 2) {\n const mNew = svgroot.createSVGTransformFromMatrix(matrixMultiply(mxs[1][0], mxs[0][0]));\n tlist.removeItem(mxs[0][1]);\n tlist.removeItem(mxs[1][1]);\n tlist.insertItemBefore(mNew, mxs[1][1]);\n }\n\n // combine matrix + translate\n k = tlist.numberOfItems;\n if (k >= 2 && tlist.getItem(k - 2).type === 1 && tlist.getItem(k - 1).type === 2) {\n const mt = svgroot.createSVGTransform();\n\n const m = matrixMultiply(\n tlist.getItem(k - 2).matrix,\n tlist.getItem(k - 1).matrix\n );\n mt.setMatrix(m);\n tlist.removeItem(k - 2);\n tlist.removeItem(k - 2);\n tlist.appendItem(mt);\n }\n }\n\n // If it still has a single [M] or [R][M], return null too (prevents BatchCommand from being returned).\n switch (selected.tagName) {\n // Ignore these elements, as they can absorb the [M]\n case 'line':\n case 'polyline':\n case 'polygon':\n case 'path':\n break;\n default:\n if ((tlist.numberOfItems === 1 && tlist.getItem(0).type === 1) ||\n (tlist.numberOfItems === 2 && tlist.getItem(0).type === 1 && tlist.getItem(0).type === 4)) {\n return null;\n }\n }\n\n // Grouped SVG element\n const gsvg = $(selected).data('gsvg');\n\n // we know we have some transforms, so set up return variable\n const batchCmd = new BatchCommand('Transform');\n\n // store initial values that will be affected by reducing the transform list\n let changes = {};\n let initial = null;\n let attrs = [];\n switch (selected.tagName) {\n case 'line':\n attrs = ['x1', 'y1', 'x2', 'y2'];\n break;\n case 'circle':\n attrs = ['cx', 'cy', 'r'];\n break;\n case 'ellipse':\n attrs = ['cx', 'cy', 'rx', 'ry'];\n break;\n case 'foreignObject':\n case 'rect':\n case 'image':\n attrs = ['width', 'height', 'x', 'y'];\n break;\n case 'use':\n case 'text':\n case 'tspan':\n attrs = ['x', 'y'];\n break;\n case 'polygon':\n case 'polyline': {\n initial = {};\n initial.points = selected.getAttribute('points');\n const list = selected.points;\n const len = list.numberOfItems;\n changes.points = new Array(len);\n for (let i = 0; i < len; ++i) {\n const pt = list.getItem(i);\n changes.points[i] = {x: pt.x, y: pt.y};\n }\n break;\n } case 'path':\n initial = {};\n initial.d = selected.getAttribute('d');\n changes.d = selected.getAttribute('d');\n break;\n } // switch on element type to get initial values\n\n if (attrs.length) {\n changes = $(selected).attr(attrs);\n $.each(changes, function (attr, val) {\n changes[attr] = convertToNum(attr, val);\n });\n } else if (gsvg) {\n // GSVG exception\n changes = {\n x: $(gsvg).attr('x') || 0,\n y: $(gsvg).attr('y') || 0\n };\n }\n\n // if we haven't created an initial array in polygon/polyline/path, then\n // make a copy of initial values and include the transform\n if (isNullish(initial)) {\n initial = $.extend(true, {}, changes);\n $.each(initial, function (attr, val) {\n initial[attr] = convertToNum(attr, val);\n });\n }\n // save the start transform value too\n initial.transform = context_.getStartTransform() || '';\n\n let oldcenter, newcenter;\n\n // if it's a regular group, we have special processing to flatten transforms\n if ((selected.tagName === 'g' && !gsvg) || selected.tagName === 'a') {\n const box = getBBox(selected);\n\n oldcenter = {x: box.x + box.width / 2, y: box.y + box.height / 2};\n newcenter = transformPoint(\n box.x + box.width / 2,\n box.y + box.height / 2,\n transformListToTransform(tlist).matrix\n );\n // let m = svgroot.createSVGMatrix();\n\n // temporarily strip off the rotate and save the old center\n const gangle = getRotationAngle(selected);\n if (gangle) {\n const a = gangle * Math.PI / 180;\n let s;\n if (Math.abs(a) > (1.0e-10)) {\n s = Math.sin(a) / (1 - Math.cos(a));\n } else {\n // TODO: This blows up if the angle is exactly 0!\n s = 2 / a;\n }\n for (let i = 0; i < tlist.numberOfItems; ++i) {\n const xform = tlist.getItem(i);\n if (xform.type === 4) {\n // extract old center through mystical arts\n const rm = xform.matrix;\n oldcenter.y = (s * rm.e + rm.f) / 2;\n oldcenter.x = (rm.e - s * rm.f) / 2;\n tlist.removeItem(i);\n break;\n }\n }\n }\n const N = tlist.numberOfItems;\n let tx = 0, ty = 0, operation = 0;\n\n let firstM;\n if (N) {\n firstM = tlist.getItem(0).matrix;\n }\n\n let oldStartTransform;\n // first, if it was a scale then the second-last transform will be it\n if (N >= 3 && tlist.getItem(N - 2).type === 3 &&\n tlist.getItem(N - 3).type === 2 && tlist.getItem(N - 1).type === 2) {\n operation = 3; // scale\n\n // if the children are unrotated, pass the scale down directly\n // otherwise pass the equivalent matrix() down directly\n const tm = tlist.getItem(N - 3).matrix,\n sm = tlist.getItem(N - 2).matrix,\n tmn = tlist.getItem(N - 1).matrix;\n\n const children = selected.childNodes;\n let c = children.length;\n while (c--) {\n const child = children.item(c);\n tx = 0;\n ty = 0;\n if (child.nodeType === 1) {\n const childTlist = getTransformList(child);\n\n // some children might not have a transform (<metadata>, <defs>, etc)\n if (!childTlist) { continue; }\n\n const m = transformListToTransform(childTlist).matrix;\n\n // Convert a matrix to a scale if applicable\n // if (hasMatrixTransform(childTlist) && childTlist.numberOfItems == 1) {\n // if (m.b==0 && m.c==0 && m.e==0 && m.f==0) {\n // childTlist.removeItem(0);\n // const translateOrigin = svgroot.createSVGTransform(),\n // scale = svgroot.createSVGTransform(),\n // translateBack = svgroot.createSVGTransform();\n // translateOrigin.setTranslate(0, 0);\n // scale.setScale(m.a, m.d);\n // translateBack.setTranslate(0, 0);\n // childTlist.appendItem(translateBack);\n // childTlist.appendItem(scale);\n // childTlist.appendItem(translateOrigin);\n // }\n // }\n\n const angle = getRotationAngle(child);\n oldStartTransform = context_.getStartTransform();\n // const childxforms = [];\n context_.setStartTransform(child.getAttribute('transform'));\n if (angle || hasMatrixTransform(childTlist)) {\n const e2t = svgroot.createSVGTransform();\n e2t.setMatrix(matrixMultiply(tm, sm, tmn, m));\n childTlist.clear();\n childTlist.appendItem(e2t);\n // childxforms.push(e2t);\n // if not rotated or skewed, push the [T][S][-T] down to the child\n } else {\n // update the transform list with translate,scale,translate\n\n // slide the [T][S][-T] from the front to the back\n // [T][S][-T][M] = [M][T2][S2][-T2]\n\n // (only bringing [-T] to the right of [M])\n // [T][S][-T][M] = [T][S][M][-T2]\n // [-T2] = [M_inv][-T][M]\n const t2n = matrixMultiply(m.inverse(), tmn, m);\n // [T2] is always negative translation of [-T2]\n const t2 = svgroot.createSVGMatrix();\n t2.e = -t2n.e;\n t2.f = -t2n.f;\n\n // [T][S][-T][M] = [M][T2][S2][-T2]\n // [S2] = [T2_inv][M_inv][T][S][-T][M][-T2_inv]\n const s2 = matrixMultiply(t2.inverse(), m.inverse(), tm, sm, tmn, m, t2n.inverse());\n\n const translateOrigin = svgroot.createSVGTransform(),\n scale = svgroot.createSVGTransform(),\n translateBack = svgroot.createSVGTransform();\n translateOrigin.setTranslate(t2n.e, t2n.f);\n scale.setScale(s2.a, s2.d);\n translateBack.setTranslate(t2.e, t2.f);\n childTlist.appendItem(translateBack);\n childTlist.appendItem(scale);\n childTlist.appendItem(translateOrigin);\n // childxforms.push(translateBack);\n // childxforms.push(scale);\n // childxforms.push(translateOrigin);\n // logMatrix(translateBack.matrix);\n // logMatrix(scale.matrix);\n } // not rotated\n batchCmd.addSubCommand(recalculateDimensions(child));\n // TODO: If any <use> have this group as a parent and are\n // referencing this child, then we need to impose a reverse\n // scale on it so that when it won't get double-translated\n // const uses = selected.getElementsByTagNameNS(NS.SVG, 'use');\n // const href = '#' + child.id;\n // let u = uses.length;\n // while (u--) {\n // const useElem = uses.item(u);\n // if (href == getHref(useElem)) {\n // const usexlate = svgroot.createSVGTransform();\n // usexlate.setTranslate(-tx,-ty);\n // getTransformList(useElem).insertItemBefore(usexlate,0);\n // batchCmd.addSubCommand( recalculateDimensions(useElem) );\n // }\n // }\n context_.setStartTransform(oldStartTransform);\n } // element\n } // for each child\n // Remove these transforms from group\n tlist.removeItem(N - 1);\n tlist.removeItem(N - 2);\n tlist.removeItem(N - 3);\n } else if (N >= 3 && tlist.getItem(N - 1).type === 1) {\n operation = 3; // scale\n const m = transformListToTransform(tlist).matrix;\n const e2t = svgroot.createSVGTransform();\n e2t.setMatrix(m);\n tlist.clear();\n tlist.appendItem(e2t);\n // next, check if the first transform was a translate\n // if we had [ T1 ] [ M ] we want to transform this into [ M ] [ T2 ]\n // therefore [ T2 ] = [ M_inv ] [ T1 ] [ M ]\n } else if ((N === 1 || (N > 1 && tlist.getItem(1).type !== 3)) &&\n tlist.getItem(0).type === 2) {\n operation = 2; // translate\n const T_M = transformListToTransform(tlist).matrix;\n tlist.removeItem(0);\n const mInv = transformListToTransform(tlist).matrix.inverse();\n const M2 = matrixMultiply(mInv, T_M);\n\n tx = M2.e;\n ty = M2.f;\n\n if (tx !== 0 || ty !== 0) {\n // we pass the translates down to the individual children\n const children = selected.childNodes;\n let c = children.length;\n\n const clipPathsDone = [];\n while (c--) {\n const child = children.item(c);\n if (child.nodeType === 1) {\n // Check if child has clip-path\n if (child.getAttribute('clip-path')) {\n // tx, ty\n const attr = child.getAttribute('clip-path');\n if (!clipPathsDone.includes(attr)) {\n updateClipPath(attr, tx, ty);\n clipPathsDone.push(attr);\n }\n }\n\n oldStartTransform = context_.getStartTransform();\n context_.setStartTransform(child.getAttribute('transform'));\n\n const childTlist = getTransformList(child);\n // some children might not have a transform (<metadata>, <defs>, etc)\n if (childTlist) {\n const newxlate = svgroot.createSVGTransform();\n newxlate.setTranslate(tx, ty);\n if (childTlist.numberOfItems) {\n childTlist.insertItemBefore(newxlate, 0);\n } else {\n childTlist.appendItem(newxlate);\n }\n batchCmd.addSubCommand(recalculateDimensions(child));\n // If any <use> have this group as a parent and are\n // referencing this child, then impose a reverse translate on it\n // so that when it won't get double-translated\n const uses = selected.getElementsByTagNameNS(NS.SVG, 'use');\n const href = '#' + child.id;\n let u = uses.length;\n while (u--) {\n const useElem = uses.item(u);\n if (href === getHref(useElem)) {\n const usexlate = svgroot.createSVGTransform();\n usexlate.setTranslate(-tx, -ty);\n getTransformList(useElem).insertItemBefore(usexlate, 0);\n batchCmd.addSubCommand(recalculateDimensions(useElem));\n }\n }\n context_.setStartTransform(oldStartTransform);\n }\n }\n }\n context_.setStartTransform(oldStartTransform);\n }\n // else, a matrix imposition from a parent group\n // keep pushing it down to the children\n } else if (N === 1 && tlist.getItem(0).type === 1 && !gangle) {\n operation = 1;\n const m = tlist.getItem(0).matrix,\n children = selected.childNodes;\n let c = children.length;\n while (c--) {\n const child = children.item(c);\n if (child.nodeType === 1) {\n oldStartTransform = context_.getStartTransform();\n context_.setStartTransform(child.getAttribute('transform'));\n const childTlist = getTransformList(child);\n\n if (!childTlist) { continue; }\n\n const em = matrixMultiply(m, transformListToTransform(childTlist).matrix);\n const e2m = svgroot.createSVGTransform();\n e2m.setMatrix(em);\n childTlist.clear();\n childTlist.appendItem(e2m, 0);\n\n batchCmd.addSubCommand(recalculateDimensions(child));\n context_.setStartTransform(oldStartTransform);\n\n // Convert stroke\n // TODO: Find out if this should actually happen somewhere else\n const sw = child.getAttribute('stroke-width');\n if (child.getAttribute('stroke') !== 'none' && !isNaN(sw)) {\n const avg = (Math.abs(em.a) + Math.abs(em.d)) / 2;\n child.setAttribute('stroke-width', sw * avg);\n }\n }\n }\n tlist.clear();\n // else it was just a rotate\n } else {\n if (gangle) {\n const newRot = svgroot.createSVGTransform();\n newRot.setRotate(gangle, newcenter.x, newcenter.y);\n if (tlist.numberOfItems) {\n tlist.insertItemBefore(newRot, 0);\n } else {\n tlist.appendItem(newRot);\n }\n }\n if (tlist.numberOfItems === 0) {\n selected.removeAttribute('transform');\n }\n return null;\n }\n\n // if it was a translate, put back the rotate at the new center\n if (operation === 2) {\n if (gangle) {\n newcenter = {\n x: oldcenter.x + firstM.e,\n y: oldcenter.y + firstM.f\n };\n\n const newRot = svgroot.createSVGTransform();\n newRot.setRotate(gangle, newcenter.x, newcenter.y);\n if (tlist.numberOfItems) {\n tlist.insertItemBefore(newRot, 0);\n } else {\n tlist.appendItem(newRot);\n }\n }\n // if it was a resize\n } else if (operation === 3) {\n const m = transformListToTransform(tlist).matrix;\n const roldt = svgroot.createSVGTransform();\n roldt.setRotate(gangle, oldcenter.x, oldcenter.y);\n const rold = roldt.matrix;\n const rnew = svgroot.createSVGTransform();\n rnew.setRotate(gangle, newcenter.x, newcenter.y);\n const rnewInv = rnew.matrix.inverse(),\n mInv = m.inverse(),\n extrat = matrixMultiply(mInv, rnewInv, rold, m);\n\n tx = extrat.e;\n ty = extrat.f;\n\n if (tx !== 0 || ty !== 0) {\n // now push this transform down to the children\n // we pass the translates down to the individual children\n const children = selected.childNodes;\n let c = children.length;\n while (c--) {\n const child = children.item(c);\n if (child.nodeType === 1) {\n oldStartTransform = context_.getStartTransform();\n context_.setStartTransform(child.getAttribute('transform'));\n const childTlist = getTransformList(child);\n const newxlate = svgroot.createSVGTransform();\n newxlate.setTranslate(tx, ty);\n if (childTlist.numberOfItems) {\n childTlist.insertItemBefore(newxlate, 0);\n } else {\n childTlist.appendItem(newxlate);\n }\n\n batchCmd.addSubCommand(recalculateDimensions(child));\n context_.setStartTransform(oldStartTransform);\n }\n }\n }\n\n if (gangle) {\n if (tlist.numberOfItems) {\n tlist.insertItemBefore(rnew, 0);\n } else {\n tlist.appendItem(rnew);\n }\n }\n }\n // else, it's a non-group\n } else {\n // TODO: box might be null for some elements (<metadata> etc), need to handle this\n const box = getBBox(selected);\n\n // Paths (and possbly other shapes) will have no BBox while still in <defs>,\n // but we still may need to recalculate them (see issue 595).\n // TODO: Figure out how to get BBox from these elements in case they\n // have a rotation transform\n\n if (!box && selected.tagName !== 'path') return null;\n\n let m; // = svgroot.createSVGMatrix();\n // temporarily strip off the rotate and save the old center\n const angle = getRotationAngle(selected);\n if (angle) {\n oldcenter = {x: box.x + box.width / 2, y: box.y + box.height / 2};\n newcenter = transformPoint(\n box.x + box.width / 2,\n box.y + box.height / 2,\n transformListToTransform(tlist).matrix\n );\n\n const a = angle * Math.PI / 180;\n const s = (Math.abs(a) > (1.0e-10))\n ? Math.sin(a) / (1 - Math.cos(a))\n // TODO: This blows up if the angle is exactly 0!\n : 2 / a;\n\n for (let i = 0; i < tlist.numberOfItems; ++i) {\n const xform = tlist.getItem(i);\n if (xform.type === 4) {\n // extract old center through mystical arts\n const rm = xform.matrix;\n oldcenter.y = (s * rm.e + rm.f) / 2;\n oldcenter.x = (rm.e - s * rm.f) / 2;\n tlist.removeItem(i);\n break;\n }\n }\n }\n\n // 2 = translate, 3 = scale, 4 = rotate, 1 = matrix imposition\n let operation = 0;\n const N = tlist.numberOfItems;\n\n // Check if it has a gradient with userSpaceOnUse, in which case\n // adjust it by recalculating the matrix transform.\n // TODO: Make this work in Webkit using transformlist.SVGTransformList\n if (!isWebkit()) {\n const fill = selected.getAttribute('fill');\n if (fill && fill.startsWith('url(')) {\n const paint = getRefElem(fill);\n let type = 'pattern';\n if (paint.tagName !== type) type = 'gradient';\n const attrVal = paint.getAttribute(type + 'Units');\n if (attrVal === 'userSpaceOnUse') {\n // Update the userSpaceOnUse element\n m = transformListToTransform(tlist).matrix;\n const gtlist = getTransformList(paint);\n const gmatrix = transformListToTransform(gtlist).matrix;\n m = matrixMultiply(m, gmatrix);\n const mStr = 'matrix(' + [m.a, m.b, m.c, m.d, m.e, m.f].join(',') + ')';\n paint.setAttribute(type + 'Transform', mStr);\n }\n }\n }\n\n // first, if it was a scale of a non-skewed element, then the second-last\n // transform will be the [S]\n // if we had [M][T][S][T] we want to extract the matrix equivalent of\n // [T][S][T] and push it down to the element\n if (N >= 3 && tlist.getItem(N - 2).type === 3 &&\n tlist.getItem(N - 3).type === 2 && tlist.getItem(N - 1).type === 2) {\n // Removed this so a <use> with a given [T][S][T] would convert to a matrix.\n // Is that bad?\n // && selected.nodeName != 'use'\n operation = 3; // scale\n m = transformListToTransform(tlist, N - 3, N - 1).matrix;\n tlist.removeItem(N - 1);\n tlist.removeItem(N - 2);\n tlist.removeItem(N - 3);\n // if we had [T][S][-T][M], then this was a skewed element being resized\n // Thus, we simply combine it all into one matrix\n } else if (N === 4 && tlist.getItem(N - 1).type === 1) {\n operation = 3; // scale\n m = transformListToTransform(tlist).matrix;\n const e2t = svgroot.createSVGTransform();\n e2t.setMatrix(m);\n tlist.clear();\n tlist.appendItem(e2t);\n // reset the matrix so that the element is not re-mapped\n m = svgroot.createSVGMatrix();\n // if we had [R][T][S][-T][M], then this was a rotated matrix-element\n // if we had [T1][M] we want to transform this into [M][T2]\n // therefore [ T2 ] = [ M_inv ] [ T1 ] [ M ] and we can push [T2]\n // down to the element\n } else if ((N === 1 || (N > 1 && tlist.getItem(1).type !== 3)) &&\n tlist.getItem(0).type === 2) {\n operation = 2; // translate\n const oldxlate = tlist.getItem(0).matrix,\n meq = transformListToTransform(tlist, 1).matrix,\n meqInv = meq.inverse();\n m = matrixMultiply(meqInv, oldxlate, meq);\n tlist.removeItem(0);\n // else if this child now has a matrix imposition (from a parent group)\n // we might be able to simplify\n } else if (N === 1 && tlist.getItem(0).type === 1 && !angle) {\n // Remap all point-based elements\n m = transformListToTransform(tlist).matrix;\n switch (selected.tagName) {\n case 'line':\n changes = $(selected).attr(['x1', 'y1', 'x2', 'y2']);\n // Fallthrough\n case 'polyline':\n case 'polygon':\n changes.points = selected.getAttribute('points');\n if (changes.points) {\n const list = selected.points;\n const len = list.numberOfItems;\n changes.points = new Array(len);\n for (let i = 0; i < len; ++i) {\n const pt = list.getItem(i);\n changes.points[i] = {x: pt.x, y: pt.y};\n }\n }\n // Fallthrough\n case 'path':\n changes.d = selected.getAttribute('d');\n operation = 1;\n tlist.clear();\n break;\n default:\n break;\n }\n // if it was a rotation, put the rotate back and return without a command\n // (this function has zero work to do for a rotate())\n } else {\n // operation = 4; // rotation\n if (angle) {\n const newRot = svgroot.createSVGTransform();\n newRot.setRotate(angle, newcenter.x, newcenter.y);\n\n if (tlist.numberOfItems) {\n tlist.insertItemBefore(newRot, 0);\n } else {\n tlist.appendItem(newRot);\n }\n }\n if (tlist.numberOfItems === 0) {\n selected.removeAttribute('transform');\n }\n return null;\n }\n\n // if it was a translate or resize, we need to remap the element and absorb the xform\n if (operation === 1 || operation === 2 || operation === 3) {\n remapElement(selected, changes, m);\n } // if we are remapping\n\n // if it was a translate, put back the rotate at the new center\n if (operation === 2) {\n if (angle) {\n if (!hasMatrixTransform(tlist)) {\n newcenter = {\n x: oldcenter.x + m.e,\n y: oldcenter.y + m.f\n };\n }\n const newRot = svgroot.createSVGTransform();\n newRot.setRotate(angle, newcenter.x, newcenter.y);\n if (tlist.numberOfItems) {\n tlist.insertItemBefore(newRot, 0);\n } else {\n tlist.appendItem(newRot);\n }\n }\n // We have special processing for tspans: Tspans are not transformable\n // but they can have x,y coordinates (sigh). Thus, if this was a translate,\n // on a text element, also translate any tspan children.\n if (selected.tagName === 'text') {\n const children = selected.childNodes;\n let c = children.length;\n while (c--) {\n const child = children.item(c);\n if (child.tagName === 'tspan') {\n const tspanChanges = {\n x: $(child).attr('x') || 0,\n y: $(child).attr('y') || 0\n };\n remapElement(child, tspanChanges, m);\n }\n }\n }\n // [Rold][M][T][S][-T] became [Rold][M]\n // we want it to be [Rnew][M][Tr] where Tr is the\n // translation required to re-center it\n // Therefore, [Tr] = [M_inv][Rnew_inv][Rold][M]\n } else if (operation === 3 && angle) {\n const {matrix} = transformListToTransform(tlist);\n const roldt = svgroot.createSVGTransform();\n roldt.setRotate(angle, oldcenter.x, oldcenter.y);\n const rold = roldt.matrix;\n const rnew = svgroot.createSVGTransform();\n rnew.setRotate(angle, newcenter.x, newcenter.y);\n const rnewInv = rnew.matrix.inverse();\n const mInv = matrix.inverse();\n const extrat = matrixMultiply(mInv, rnewInv, rold, matrix);\n\n remapElement(selected, changes, extrat);\n if (angle) {\n if (tlist.numberOfItems) {\n tlist.insertItemBefore(rnew, 0);\n } else {\n tlist.appendItem(rnew);\n }\n }\n }\n } // a non-group\n\n // if the transform list has been emptied, remove it\n if (tlist.numberOfItems === 0) {\n selected.removeAttribute('transform');\n }\n\n batchCmd.addSubCommand(new ChangeElementCommand(selected, initial));\n\n return batchCmd;\n};\n","/* globals jQuery */\n/**\n * DOM element selection box tools.\n * @module select\n * @license MIT\n *\n * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller\n */\n\nimport {isTouch, isWebkit} from '../common/browser.js'; // , isOpera\nimport {getRotationAngle, getBBox, getStrokedBBox, isNullish} from '../common/utilities.js';\nimport {transformListToTransform, transformBox, transformPoint} from '../common/math.js';\nimport {getTransformList} from '../common/svgtransformlist.js';\n\nconst $ = jQuery;\n\nlet svgFactory_;\nlet config_;\nlet selectorManager_; // A Singleton\nconst gripRadius = isTouch() ? 10 : 4;\n\n/**\n* Private class for DOM element selection boxes.\n*/\nexport class Selector {\n /**\n * @param {Integer} id - Internally identify the selector\n * @param {Element} elem - DOM element associated with this selector\n * @param {module:utilities.BBoxObject} [bbox] - Optional bbox to use for initialization (prevents duplicate `getBBox` call).\n */\n constructor (id, elem, bbox) {\n // this is the selector's unique number\n this.id = id;\n\n // this holds a reference to the element for which this selector is being used\n this.selectedElement = elem;\n\n // this is a flag used internally to track whether the selector is being used or not\n this.locked = true;\n\n // this holds a reference to the <g> element that holds all visual elements of the selector\n this.selectorGroup = svgFactory_.createSVGElement({\n element: 'g',\n attr: {id: ('selectorGroup' + this.id)}\n });\n\n // this holds a reference to the path rect\n this.selectorRect = this.selectorGroup.appendChild(\n svgFactory_.createSVGElement({\n element: 'path',\n attr: {\n id: ('selectedBox' + this.id),\n fill: 'none',\n stroke: '#22C',\n 'stroke-width': '1',\n 'stroke-dasharray': '5,5',\n // need to specify this so that the rect is not selectable\n style: 'pointer-events:none'\n }\n })\n );\n\n // this holds a reference to the grip coordinates for this selector\n this.gripCoords = {\n nw: null,\n n: null,\n ne: null,\n e: null,\n se: null,\n s: null,\n sw: null,\n w: null\n };\n\n this.reset(this.selectedElement, bbox);\n }\n\n /**\n * Used to reset the id and element that the selector is attached to.\n * @param {Element} e - DOM element associated with this selector\n * @param {module:utilities.BBoxObject} bbox - Optional bbox to use for reset (prevents duplicate getBBox call).\n * @returns {void}\n */\n reset (e, bbox) {\n this.locked = true;\n this.selectedElement = e;\n this.resize(bbox);\n this.selectorGroup.setAttribute('display', 'inline');\n }\n\n /**\n * Show the resize grips of this selector.\n * @param {boolean} show - Indicates whether grips should be shown or not\n * @returns {void}\n */\n showGrips (show) {\n const bShow = show ? 'inline' : 'none';\n selectorManager_.selectorGripsGroup.setAttribute('display', bShow);\n const elem = this.selectedElement;\n this.hasGrips = show;\n if (elem && show) {\n this.selectorGroup.append(selectorManager_.selectorGripsGroup);\n Selector.updateGripCursors(getRotationAngle(elem));\n }\n }\n\n /**\n * Updates the selector to match the element's size.\n * @param {module:utilities.BBoxObject} [bbox] - BBox to use for resize (prevents duplicate getBBox call).\n * @returns {void}\n */\n resize (bbox) {\n const selectedBox = this.selectorRect,\n mgr = selectorManager_,\n selectedGrips = mgr.selectorGrips,\n selected = this.selectedElement,\n sw = selected.getAttribute('stroke-width'),\n currentZoom = svgFactory_.getCurrentZoom();\n let offset = 1 / currentZoom;\n if (selected.getAttribute('stroke') !== 'none' && !isNaN(sw)) {\n offset += (sw / 2);\n }\n\n const {tagName} = selected;\n if (tagName === 'text') {\n offset += 2 / currentZoom;\n }\n\n // loop and transform our bounding box until we reach our first rotation\n const tlist = getTransformList(selected);\n const m = transformListToTransform(tlist).matrix;\n\n // This should probably be handled somewhere else, but for now\n // it keeps the selection box correctly positioned when zoomed\n m.e *= currentZoom;\n m.f *= currentZoom;\n\n if (!bbox) {\n bbox = getBBox(selected);\n }\n // TODO: getBBox (previous line) already knows to call getStrokedBBox when tagName === 'g'. Remove this?\n // TODO: getBBox doesn't exclude 'gsvg' and calls getStrokedBBox for any 'g'. Should getBBox be updated?\n if (tagName === 'g' && !$.data(selected, 'gsvg')) {\n // The bbox for a group does not include stroke vals, so we\n // get the bbox based on its children.\n const strokedBbox = getStrokedBBox([selected.childNodes]);\n if (strokedBbox) {\n bbox = strokedBbox;\n }\n }\n\n // apply the transforms\n const l = bbox.x, t = bbox.y, w = bbox.width, h = bbox.height;\n // bbox = {x: l, y: t, width: w, height: h}; // Not in use\n\n // we need to handle temporary transforms too\n // if skewed, get its transformed box, then find its axis-aligned bbox\n\n // *\n offset *= currentZoom;\n\n const nbox = transformBox(l * currentZoom, t * currentZoom, w * currentZoom, h * currentZoom, m),\n {aabox} = nbox;\n let nbax = aabox.x - offset,\n nbay = aabox.y - offset,\n nbaw = aabox.width + (offset * 2),\n nbah = aabox.height + (offset * 2);\n\n // now if the shape is rotated, un-rotate it\n const cx = nbax + nbaw / 2,\n cy = nbay + nbah / 2;\n\n const angle = getRotationAngle(selected);\n if (angle) {\n const rot = svgFactory_.svgRoot().createSVGTransform();\n rot.setRotate(-angle, cx, cy);\n const rotm = rot.matrix;\n nbox.tl = transformPoint(nbox.tl.x, nbox.tl.y, rotm);\n nbox.tr = transformPoint(nbox.tr.x, nbox.tr.y, rotm);\n nbox.bl = transformPoint(nbox.bl.x, nbox.bl.y, rotm);\n nbox.br = transformPoint(nbox.br.x, nbox.br.y, rotm);\n\n // calculate the axis-aligned bbox\n const {tl} = nbox;\n let minx = tl.x,\n miny = tl.y,\n maxx = tl.x,\n maxy = tl.y;\n\n const {min, max} = Math;\n\n minx = min(minx, min(nbox.tr.x, min(nbox.bl.x, nbox.br.x))) - offset;\n miny = min(miny, min(nbox.tr.y, min(nbox.bl.y, nbox.br.y))) - offset;\n maxx = max(maxx, max(nbox.tr.x, max(nbox.bl.x, nbox.br.x))) + offset;\n maxy = max(maxy, max(nbox.tr.y, max(nbox.bl.y, nbox.br.y))) + offset;\n\n nbax = minx;\n nbay = miny;\n nbaw = (maxx - minx);\n nbah = (maxy - miny);\n }\n\n const dstr = 'M' + nbax + ',' + nbay +\n ' L' + (nbax + nbaw) + ',' + nbay +\n ' ' + (nbax + nbaw) + ',' + (nbay + nbah) +\n ' ' + nbax + ',' + (nbay + nbah) + 'z';\n selectedBox.setAttribute('d', dstr);\n\n const xform = angle ? 'rotate(' + [angle, cx, cy].join(',') + ')' : '';\n this.selectorGroup.setAttribute('transform', xform);\n\n // TODO(codedread): Is this needed?\n // if (selected === selectedElements[0]) {\n this.gripCoords = {\n nw: [nbax, nbay],\n ne: [nbax + nbaw, nbay],\n sw: [nbax, nbay + nbah],\n se: [nbax + nbaw, nbay + nbah],\n n: [nbax + (nbaw) / 2, nbay],\n w: [nbax, nbay + (nbah) / 2],\n e: [nbax + nbaw, nbay + (nbah) / 2],\n s: [nbax + (nbaw) / 2, nbay + nbah]\n };\n Object.entries(this.gripCoords).forEach(([dir, coords]) => {\n selectedGrips[dir].setAttribute('cx', coords[0]);\n selectedGrips[dir].setAttribute('cy', coords[1]);\n });\n\n // we want to go 20 pixels in the negative transformed y direction, ignoring scale\n mgr.rotateGripConnector.setAttribute('x1', nbax + (nbaw) / 2);\n mgr.rotateGripConnector.setAttribute('y1', nbay);\n mgr.rotateGripConnector.setAttribute('x2', nbax + (nbaw) / 2);\n mgr.rotateGripConnector.setAttribute('y2', nbay - (gripRadius * 5));\n\n mgr.rotateGrip.setAttribute('cx', nbax + (nbaw) / 2);\n mgr.rotateGrip.setAttribute('cy', nbay - (gripRadius * 5));\n // }\n }\n\n // STATIC methods\n /**\n * Updates cursors for corner grips on rotation so arrows point the right way.\n * @param {Float} angle - Current rotation angle in degrees\n * @returns {void}\n */\n static updateGripCursors (angle) {\n const dirArr = Object.keys(selectorManager_.selectorGrips);\n let steps = Math.round(angle / 45);\n if (steps < 0) { steps += 8; }\n while (steps > 0) {\n dirArr.push(dirArr.shift());\n steps--;\n }\n Object.values(selectorManager_.selectorGrips).forEach((gripElement, i) => {\n gripElement.setAttribute('style', ('cursor:' + dirArr[i] + '-resize'));\n });\n }\n}\n\n/**\n* Manage all selector objects (selection boxes).\n*/\nexport class SelectorManager {\n /**\n * Sets up properties and calls `initGroup`.\n */\n constructor () {\n // this will hold the <g> element that contains all selector rects/grips\n this.selectorParentGroup = null;\n\n // this is a special rect that is used for multi-select\n this.rubberBandBox = null;\n\n // this will hold objects of type Selector (see above)\n this.selectors = [];\n\n // this holds a map of SVG elements to their Selector object\n this.selectorMap = {};\n\n // this holds a reference to the grip elements\n this.selectorGrips = {\n nw: null,\n n: null,\n ne: null,\n e: null,\n se: null,\n s: null,\n sw: null,\n w: null\n };\n\n this.selectorGripsGroup = null;\n this.rotateGripConnector = null;\n this.rotateGrip = null;\n\n this.initGroup();\n }\n\n /**\n * Resets the parent selector group element.\n * @returns {void}\n */\n initGroup () {\n // remove old selector parent group if it existed\n if (this.selectorParentGroup && this.selectorParentGroup.parentNode) {\n this.selectorParentGroup.remove();\n }\n\n // create parent selector group and add it to svgroot\n this.selectorParentGroup = svgFactory_.createSVGElement({\n element: 'g',\n attr: {id: 'selectorParentGroup'}\n });\n this.selectorGripsGroup = svgFactory_.createSVGElement({\n element: 'g',\n attr: {display: 'none'}\n });\n this.selectorParentGroup.append(this.selectorGripsGroup);\n svgFactory_.svgRoot().append(this.selectorParentGroup);\n\n this.selectorMap = {};\n this.selectors = [];\n this.rubberBandBox = null;\n\n // add the corner grips\n Object.keys(this.selectorGrips).forEach((dir) => {\n const grip = svgFactory_.createSVGElement({\n element: 'circle',\n attr: {\n id: ('selectorGrip_resize_' + dir),\n fill: '#22C',\n r: gripRadius,\n style: ('cursor:' + dir + '-resize'),\n // This expands the mouse-able area of the grips making them\n // easier to grab with the mouse.\n // This works in Opera and WebKit, but does not work in Firefox\n // see https://bugzilla.mozilla.org/show_bug.cgi?id=500174\n 'stroke-width': 2,\n 'pointer-events': 'all'\n }\n });\n\n $.data(grip, 'dir', dir);\n $.data(grip, 'type', 'resize');\n this.selectorGrips[dir] = this.selectorGripsGroup.appendChild(grip);\n });\n\n // add rotator elems\n this.rotateGripConnector = this.selectorGripsGroup.appendChild(\n svgFactory_.createSVGElement({\n element: 'line',\n attr: {\n id: ('selectorGrip_rotateconnector'),\n stroke: '#22C',\n 'stroke-width': '1'\n }\n })\n );\n\n this.rotateGrip = this.selectorGripsGroup.appendChild(\n svgFactory_.createSVGElement({\n element: 'circle',\n attr: {\n id: 'selectorGrip_rotate',\n fill: 'lime',\n r: gripRadius,\n stroke: '#22C',\n 'stroke-width': 2,\n style: 'cursor:url(' + config_.imgPath + 'rotate.png) 12 12, auto;'\n }\n })\n );\n $.data(this.rotateGrip, 'type', 'rotate');\n\n if ($('#canvasBackground').length) { return; }\n\n const [width, height] = config_.dimensions;\n const canvasbg = svgFactory_.createSVGElement({\n element: 'svg',\n attr: {\n id: 'canvasBackground',\n width,\n height,\n x: 0,\n y: 0,\n overflow: (isWebkit() ? 'none' : 'visible'), // Chrome 7 has a problem with this when zooming out\n style: 'pointer-events:none'\n }\n });\n\n const rect = svgFactory_.createSVGElement({\n element: 'rect',\n attr: {\n width: '100%',\n height: '100%',\n x: 0,\n y: 0,\n 'stroke-width': 1,\n stroke: '#000',\n fill: '#FFF',\n style: 'pointer-events:none'\n }\n });\n\n // Both Firefox and WebKit are too slow with this filter region (especially at higher\n // zoom levels) and Opera has at least one bug\n // if (!isOpera()) rect.setAttribute('filter', 'url(#canvashadow)');\n canvasbg.append(rect);\n svgFactory_.svgRoot().insertBefore(canvasbg, svgFactory_.svgContent());\n // Ok to replace above with `svgFactory_.svgContent().before(canvasbg);`?\n }\n\n /**\n *\n * @param {Element} elem - DOM element to get the selector for\n * @param {module:utilities.BBoxObject} [bbox] - Optional bbox to use for reset (prevents duplicate getBBox call).\n * @returns {Selector} The selector based on the given element\n */\n requestSelector (elem, bbox) {\n if (isNullish(elem)) { return null; }\n\n const N = this.selectors.length;\n // If we've already acquired one for this element, return it.\n if (typeof this.selectorMap[elem.id] === 'object') {\n this.selectorMap[elem.id].locked = true;\n return this.selectorMap[elem.id];\n }\n for (let i = 0; i < N; ++i) {\n if (this.selectors[i] && !this.selectors[i].locked) {\n this.selectors[i].locked = true;\n this.selectors[i].reset(elem, bbox);\n this.selectorMap[elem.id] = this.selectors[i];\n return this.selectors[i];\n }\n }\n // if we reached here, no available selectors were found, we create one\n this.selectors[N] = new Selector(N, elem, bbox);\n this.selectorParentGroup.append(this.selectors[N].selectorGroup);\n this.selectorMap[elem.id] = this.selectors[N];\n return this.selectors[N];\n }\n\n /**\n * Removes the selector of the given element (hides selection box).\n *\n * @param {Element} elem - DOM element to remove the selector for\n * @returns {void}\n */\n releaseSelector (elem) {\n if (isNullish(elem)) { return; }\n const N = this.selectors.length,\n sel = this.selectorMap[elem.id];\n if (!sel.locked) {\n // TODO(codedread): Ensure this exists in this module.\n console.log('WARNING! selector was released but was already unlocked'); // eslint-disable-line no-console\n }\n for (let i = 0; i < N; ++i) {\n if (this.selectors[i] && this.selectors[i] === sel) {\n delete this.selectorMap[elem.id];\n sel.locked = false;\n sel.selectedElement = null;\n sel.showGrips(false);\n\n // remove from DOM and store reference in JS but only if it exists in the DOM\n try {\n sel.selectorGroup.setAttribute('display', 'none');\n } catch (e) {}\n\n break;\n }\n }\n }\n\n /**\n * @returns {SVGRectElement} The rubberBandBox DOM element. This is the rectangle drawn by\n * the user for selecting/zooming\n */\n getRubberBandBox () {\n if (!this.rubberBandBox) {\n this.rubberBandBox = this.selectorParentGroup.appendChild(\n svgFactory_.createSVGElement({\n element: 'rect',\n attr: {\n id: 'selectorRubberBand',\n fill: '#22C',\n 'fill-opacity': 0.15,\n stroke: '#22C',\n 'stroke-width': 0.5,\n display: 'none',\n style: 'pointer-events:none'\n }\n })\n );\n }\n return this.rubberBandBox;\n }\n}\n\n/**\n * An object that creates SVG elements for the canvas.\n *\n * @interface module:select.SVGFactory\n */\n/**\n * @function module:select.SVGFactory#createSVGElement\n * @param {module:utilities.EditorContext#addSVGElementFromJson} jsonMap\n * @returns {SVGElement}\n */\n/**\n * @function module:select.SVGFactory#svgRoot\n * @returns {SVGSVGElement}\n */\n/**\n * @function module:select.SVGFactory#svgContent\n * @returns {SVGSVGElement}\n */\n/**\n * @function module:select.SVGFactory#getCurrentZoom\n * @returns {Float} The current zoom level\n */\n\n/**\n * @typedef {GenericArray} module:select.Dimensions\n * @property {Integer} length 2\n * @property {Float} 0 Width\n * @property {Float} 1 Height\n */\n/**\n * @typedef {PlainObject} module:select.Config\n * @property {string} imgPath\n * @property {module:select.Dimensions} dimensions\n */\n\n/**\n * Initializes this module.\n * @function module:select.init\n * @param {module:select.Config} config - An object containing configurable parameters (imgPath)\n * @param {module:select.SVGFactory} svgFactory - An object implementing the SVGFactory interface.\n * @returns {void}\n */\nexport const init = function (config, svgFactory) {\n config_ = config;\n svgFactory_ = svgFactory;\n selectorManager_ = new SelectorManager();\n};\n\n/**\n * @function module:select.getSelectorManager\n * @returns {module:select.SelectorManager} The SelectorManager instance.\n */\nexport const getSelectorManager = () => selectorManager_;\n","/* globals jQuery */\n/**\n * Numerous tools for working with the editor's \"canvas\".\n * @module svgcanvas\n *\n * @license MIT\n *\n * @copyright 2010 Alexis Deveria, 2010 Pavol Rusnak, 2010 Jeff Schiller\n *\n */\n\n/* Dependencies:\n1. Also expects jQuery UI for `svgCanvasToString` and\n`convertToGroup` use of `:data()` selector\n*/\n\nimport {jsPDF} from 'jspdf';\nimport 'svg2pdf.js/dist/svg2pdf.es.js';\n\nimport {canvg} from '../external/canvg/canvg.js';\n\nimport '../common/svgpathseg.js';\nimport jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr`\nimport jQueryPluginDBox from './dbox.js';\n\nimport * as pathModule from './path.js';\nimport * as hstry from './history.js';\nimport * as draw from './draw.js';\n// eslint-disable-next-line no-duplicate-imports\nimport {\n identifyLayers, createLayer, cloneLayer, deleteCurrentLayer,\n setCurrentLayer, renameCurrentLayer, setCurrentLayerPosition,\n setLayerVisibility, moveSelectedToLayer, mergeLayer, mergeAllLayers,\n leaveContext, setContext\n} from './draw.js';\nimport {sanitizeSvg} from './sanitize.js';\nimport {getReverseNS, NS} from '../common/namespaces.js';\nimport {\n text2xml, assignAttributes, cleanupElement, getElem, getUrlFromAttr,\n findDefs, getHref, setHref, getRefElem, getRotationAngle, getPathBBox,\n preventClickDefault, snapToGrid, walkTree, walkTreePost,\n getBBoxOfElementAsPath, convertToPath, toXml, encode64, decode64,\n dataURLToObjectURL, createObjectURL,\n getVisibleElements, dropXMLInternalSubset,\n init as utilsInit, getBBox as utilsGetBBox, getStrokedBBoxDefaultVisible,\n isNullish\n} from '../common/utilities.js';\nimport {\n transformPoint, matrixMultiply, hasMatrixTransform, transformListToTransform,\n getMatrix, snapToAngle, isIdentity, rectsIntersect, transformBox\n} from '../common/math.js';\nimport {\n convertToNum, convertAttrs, convertUnit, shortFloat, getTypeMap,\n init as unitsInit\n} from '../common/units.js';\nimport {\n isGecko, isChrome, isIE, isWebkit, supportsNonScalingStroke, supportsGoodTextCharPos\n} from '../common/browser.js'; // , supportsEditableText\nimport {\n getTransformList, resetListMap,\n SVGTransformList as SVGEditTransformList\n} from '../common/svgtransformlist.js';\nimport {\n remapElement,\n init as coordsInit\n} from './coords.js';\nimport {\n recalculateDimensions,\n init as recalculateInit\n} from './recalculate.js';\nimport {\n getSelectorManager,\n Selector,\n init as selectInit\n} from './select.js';\n\nlet $ = jQueryPluginSVG(jQuery);\nconst {\n MoveElementCommand, InsertElementCommand, RemoveElementCommand,\n ChangeElementCommand, BatchCommand, UndoManager, HistoryEventTypes\n} = hstry;\n\nif (!window.console) {\n window.console = {};\n window.console.log = function (str) { /* */ };\n window.console.dir = function (str) { /* */ };\n}\n\nif (window.opera) {\n window.console.log = function (str) { window.opera.postError(str); };\n window.console.dir = function (str) { /* */ };\n}\n\n// Reenable after fixing eslint-plugin-jsdoc to handle\n/**\n* The main SvgCanvas class that manages all SVG-related functions.\n* @memberof module:svgcanvas\n*\n* @borrows module:coords.remapElement as #remapElement\n* @borrows module:recalculate.recalculateDimensions as #recalculateDimensions\n*\n* @borrows module:utilities.cleanupElement as #cleanupElement\n* @borrows module:utilities.getStrokedBBoxDefaultVisible as #getStrokedBBox\n* @borrows module:utilities.getVisibleElements as #getVisibleElements\n* @borrows module:utilities.findDefs as #findDefs\n* @borrows module:utilities.getUrlFromAttr as #getUrlFromAttr\n* @borrows module:utilities.getHref as #getHref\n* @borrows module:utilities.setHref as #setHref\n* @borrows module:utilities.getRotationAngle as #getRotationAngle\n* @borrows module:utilities.getBBox as #getBBox\n* @borrows module:utilities.getElem as #getElem\n* @borrows module:utilities.getRefElem as #getRefElem\n* @borrows module:utilities.assignAttributes as #assignAttributes\n*\n* @borrows module:SVGTransformList.getTransformList as #getTransformList\n* @borrows module:math.matrixMultiply as #matrixMultiply\n* @borrows module:math.hasMatrixTransform as #hasMatrixTransform\n* @borrows module:math.transformListToTransform as #transformListToTransform\n* @borrows module:units.convertToNum as #convertToNum\n* @borrows module:sanitize.sanitizeSvg as #sanitizeSvg\n* @borrows module:path.pathActions.linkControlPoints as #linkControlPoints\n*/\nclass SvgCanvas {\n /**\n * @param {HTMLElement} container - The container HTML element that should hold the SVG root element\n * @param {module:SVGEditor.curConfig} config - An object that contains configuration data\n */\n constructor (container, config) {\n // Alias Namespace constants\n\n // Default configuration options\n const curConfig = {\n show_outside_canvas: true,\n selectNew: true,\n dimensions: [640, 480]\n };\n\n // Update config with new one if given\n if (config) {\n $.extend(curConfig, config);\n }\n\n // Array with width/height of canvas\n const {dimensions} = curConfig;\n\n const canvas = this;\n\n // \"document\" element associated with the container (same as window.document using default svg-editor.js)\n // NOTE: This is not actually a SVG document, but an HTML document.\n // JFH const svgdoc = container.ownerDocument;\n const svgdoc = window.document;\n\n // This is a container for the document being edited, not the document itself.\n /**\n * @name module:svgcanvas~svgroot\n * @type {SVGSVGElement}\n */\n const svgroot = svgdoc.importNode(\n text2xml(\n '<svg id=\"svgroot\" xmlns=\"' + NS.SVG + '\" xlinkns=\"' + NS.XLINK + '\" ' +\n 'width=\"' + dimensions[0] + '\" height=\"' + dimensions[1] +\n '\" x=\"' + dimensions[0] + '\" y=\"' + dimensions[1] + '\" overflow=\"visible\">' +\n '<defs>' +\n '<filter id=\"canvashadow\" filterUnits=\"objectBoundingBox\">' +\n '<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"4\" result=\"blur\"/>' +\n '<feOffset in=\"blur\" dx=\"5\" dy=\"5\" result=\"offsetBlur\"/>' +\n '<feMerge>' +\n '<feMergeNode in=\"offsetBlur\"/>' +\n '<feMergeNode in=\"SourceGraphic\"/>' +\n '</feMerge>' +\n '</filter>' +\n '</defs>' +\n '</svg>'\n ).documentElement,\n true\n );\n container.append(svgroot);\n\n /**\n * The actual element that represents the final output SVG element.\n * @name module:svgcanvas~svgcontent\n * @type {SVGSVGElement}\n */\n let svgcontent = svgdoc.createElementNS(NS.SVG, 'svg');\n\n /**\n* This function resets the svgcontent element while keeping it in the DOM.\n* @function module:svgcanvas.SvgCanvas#clearSvgContentElement\n* @returns {void}\n*/\n const clearSvgContentElement = canvas.clearSvgContentElement = function () {\n $(svgcontent).empty();\n\n // TODO: Clear out all other attributes first?\n $(svgcontent).attr({\n id: 'svgcontent',\n width: dimensions[0],\n height: dimensions[1],\n x: dimensions[0],\n y: dimensions[1],\n overflow: curConfig.show_outside_canvas ? 'visible' : 'hidden',\n xmlns: NS.SVG,\n 'xmlns:se': NS.SE,\n 'xmlns:xlink': NS.XLINK\n }).appendTo(svgroot);\n\n // TODO: make this string optional and set by the client\n const comment = svgdoc.createComment(' Created with SVG-edit - https://github.com/SVG-Edit/svgedit');\n svgcontent.append(comment);\n };\n clearSvgContentElement();\n\n // Prefix string for element IDs\n let idprefix = 'svg_';\n\n /**\n* Changes the ID prefix to the given value.\n* @function module:svgcanvas.SvgCanvas#setIdPrefix\n* @param {string} p - String with the new prefix\n* @returns {void}\n*/\n canvas.setIdPrefix = function (p) {\n idprefix = p;\n };\n\n /**\n* Current `draw.Drawing` object.\n* @type {module:draw.Drawing}\n* @name module:svgcanvas.SvgCanvas#current_drawing_\n*/\n canvas.current_drawing_ = new draw.Drawing(svgcontent, idprefix);\n\n /**\n* Returns the current Drawing.\n* @name module:svgcanvas.SvgCanvas#getCurrentDrawing\n* @type {module:draw.DrawCanvasInit#getCurrentDrawing}\n*/\n const getCurrentDrawing = canvas.getCurrentDrawing = function () {\n return canvas.current_drawing_;\n };\n\n /**\n* Float displaying the current zoom level (1 = 100%, .5 = 50%, etc.).\n* @type {Float}\n*/\n let currentZoom = 1;\n\n // pointer to current group (for in-group editing)\n let currentGroup = null;\n\n // Object containing data for the currently selected styles\n const allProperties = {\n shape: {\n fill: (curConfig.initFill.color === 'none' ? '' : '#') + curConfig.initFill.color,\n fill_paint: null,\n fill_opacity: curConfig.initFill.opacity,\n stroke: '#' + curConfig.initStroke.color,\n stroke_paint: null,\n stroke_opacity: curConfig.initStroke.opacity,\n stroke_width: curConfig.initStroke.width,\n stroke_dasharray: 'none',\n stroke_linejoin: 'miter',\n stroke_linecap: 'butt',\n opacity: curConfig.initOpacity\n }\n };\n\n allProperties.text = $.extend(true, {}, allProperties.shape);\n $.extend(allProperties.text, {\n fill: '#000000',\n stroke_width: curConfig.text && curConfig.text.stroke_width,\n font_size: curConfig.text && curConfig.text.font_size,\n font_family: curConfig.text && curConfig.text.font_family\n });\n\n // Current shape style properties\n const curShape = allProperties.shape;\n\n // Array with all the currently selected elements\n // default size of 1 until it needs to grow bigger\n let selectedElements = [];\n\n /**\n* @typedef {PlainObject} module:svgcanvas.SVGAsJSON\n* @property {string} element\n* @property {PlainObject<string, string>} attr\n* @property {module:svgcanvas.SVGAsJSON[]} children\n*/\n\n /**\n* @function module:svgcanvas.SvgCanvas#getContentElem\n* @param {Text|Element} data\n* @returns {module:svgcanvas.SVGAsJSON}\n*/\n const getJsonFromSvgElement = this.getJsonFromSvgElement = function (data) {\n // Text node\n if (data.nodeType === 3) return data.nodeValue;\n\n const retval = {\n element: data.tagName,\n // namespace: nsMap[data.namespaceURI],\n attr: {},\n children: []\n };\n\n // Iterate attributes\n for (let i = 0, attr; (attr = data.attributes[i]); i++) {\n retval.attr[attr.name] = attr.value;\n }\n\n // Iterate children\n for (let i = 0, node; (node = data.childNodes[i]); i++) {\n retval.children[i] = getJsonFromSvgElement(node);\n }\n\n return retval;\n };\n\n /**\n* This should really be an intersection implementing all rather than a union.\n* @name module:svgcanvas.SvgCanvas#addSVGElementFromJson\n* @type {module:utilities.EditorContext#addSVGElementFromJson|module:path.EditorContext#addSVGElementFromJson}\n*/\n const addSVGElementFromJson = this.addSVGElementFromJson = function (data) {\n if (typeof data === 'string') return svgdoc.createTextNode(data);\n\n let shape = getElem(data.attr.id);\n // if shape is a path but we need to create a rect/ellipse, then remove the path\n const currentLayer = getCurrentDrawing().getCurrentLayer();\n if (shape && data.element !== shape.tagName) {\n shape.remove();\n shape = null;\n }\n if (!shape) {\n const ns = data.namespace || NS.SVG;\n shape = svgdoc.createElementNS(ns, data.element);\n if (currentLayer) {\n (currentGroup || currentLayer).append(shape);\n }\n }\n if (data.curStyles) {\n assignAttributes(shape, {\n fill: curShape.fill,\n stroke: curShape.stroke,\n 'stroke-width': curShape.stroke_width,\n 'stroke-dasharray': curShape.stroke_dasharray,\n 'stroke-linejoin': curShape.stroke_linejoin,\n 'stroke-linecap': curShape.stroke_linecap,\n 'stroke-opacity': curShape.stroke_opacity,\n 'fill-opacity': curShape.fill_opacity,\n opacity: curShape.opacity / 2,\n style: 'pointer-events:inherit'\n }, 100);\n }\n assignAttributes(shape, data.attr, 100);\n cleanupElement(shape);\n\n // Children\n if (data.children) {\n data.children.forEach((child) => {\n shape.append(addSVGElementFromJson(child));\n });\n }\n\n return shape;\n };\n\n canvas.getTransformList = getTransformList;\n\n canvas.matrixMultiply = matrixMultiply;\n canvas.hasMatrixTransform = hasMatrixTransform;\n canvas.transformListToTransform = transformListToTransform;\n\n /**\n* @type {module:utilities.EditorContext#getBaseUnit}\n*/\n const getBaseUnit = () => { return curConfig.baseUnit; };\n\n /**\n* Initialize from units.js.\n* Send in an object implementing the ElementContainer interface (see units.js).\n*/\n unitsInit(\n /**\n * @implements {module:units.ElementContainer}\n */\n {\n getBaseUnit,\n getElement: getElem,\n getHeight () { return svgcontent.getAttribute('height') / currentZoom; },\n getWidth () { return svgcontent.getAttribute('width') / currentZoom; },\n getRoundDigits () { return saveOptions.round_digits; }\n }\n );\n\n canvas.convertToNum = convertToNum;\n\n /**\n* This should really be an intersection implementing all rather than a union.\n* @type {module:draw.DrawCanvasInit#getSVGContent|module:utilities.EditorContext#getSVGContent}\n*/\n const getSVGContent = () => { return svgcontent; };\n\n /**\n* Should really be an intersection with all needing to apply rather than a union.\n* @name module:svgcanvas.SvgCanvas#getSelectedElements\n* @type {module:utilities.EditorContext#getSelectedElements|module:draw.DrawCanvasInit#getSelectedElements|module:path.EditorContext#getSelectedElements}\n*/\n const getSelectedElements = this.getSelectedElems = function () {\n return selectedElements;\n };\n\n const {pathActions} = pathModule;\n\n /**\n* This should actually be an intersection as all interfaces should be met.\n* @type {module:utilities.EditorContext#getSVGRoot|module:recalculate.EditorContext#getSVGRoot|module:coords.EditorContext#getSVGRoot|module:path.EditorContext#getSVGRoot}\n*/\n const getSVGRoot = () => svgroot;\n\n utilsInit(\n /**\n * @implements {module:utilities.EditorContext}\n */\n {\n pathActions, // Ok since not modifying\n getSVGContent,\n addSVGElementFromJson,\n getSelectedElements,\n getDOMDocument () { return svgdoc; },\n getDOMContainer () { return container; },\n getSVGRoot,\n // TODO: replace this mostly with a way to get the current drawing.\n getBaseUnit,\n getSnappingStep () { return curConfig.snappingStep; }\n }\n );\n\n canvas.findDefs = findDefs;\n canvas.getUrlFromAttr = getUrlFromAttr;\n canvas.getHref = getHref;\n canvas.setHref = setHref;\n /* const getBBox = */ canvas.getBBox = utilsGetBBox;\n canvas.getRotationAngle = getRotationAngle;\n canvas.getElem = getElem;\n canvas.getRefElem = getRefElem;\n canvas.assignAttributes = assignAttributes;\n\n this.cleanupElement = cleanupElement;\n\n /**\n* This should actually be an intersection not a union as all should apply.\n* @type {module:coords.EditorContext#getGridSnapping|module:path.EditorContext#getGridSnapping}\n*/\n const getGridSnapping = () => { return curConfig.gridSnapping; };\n\n coordsInit(\n /**\n * @implements {module:coords.EditorContext}\n */\n {\n getDrawing () { return getCurrentDrawing(); },\n getSVGRoot,\n getGridSnapping\n }\n );\n this.remapElement = remapElement;\n\n recalculateInit(\n /**\n * @implements {module:recalculate.EditorContext}\n */\n {\n getSVGRoot,\n getStartTransform () { return startTransform; },\n setStartTransform (transform) { startTransform = transform; }\n }\n );\n this.recalculateDimensions = recalculateDimensions;\n\n // import from sanitize.js\n const nsMap = getReverseNS();\n canvas.sanitizeSvg = sanitizeSvg;\n\n /**\n* @name undoMgr\n* @memberof module:svgcanvas.SvgCanvas#\n* @type {module:history.HistoryEventHandler}\n*/\n const undoMgr = canvas.undoMgr = new UndoManager({\n /**\n * @param {string} eventType One of the HistoryEvent types\n * @param {module:history.HistoryCommand} cmd Fulfills the HistoryCommand interface\n * @fires module:svgcanvas.SvgCanvas#event:changed\n * @returns {void}\n */\n handleHistoryEvent (eventType, cmd) {\n const EventTypes = HistoryEventTypes;\n // TODO: handle setBlurOffsets.\n if (eventType === EventTypes.BEFORE_UNAPPLY || eventType === EventTypes.BEFORE_APPLY) {\n canvas.clearSelection();\n } else if (eventType === EventTypes.AFTER_APPLY || eventType === EventTypes.AFTER_UNAPPLY) {\n const elems = cmd.elements();\n canvas.pathActions.clear();\n call('changed', elems);\n const cmdType = cmd.type();\n const isApply = (eventType === EventTypes.AFTER_APPLY);\n if (cmdType === 'MoveElementCommand') {\n const parent = isApply ? cmd.newParent : cmd.oldParent;\n if (parent === svgcontent) {\n draw.identifyLayers();\n }\n } else if (cmdType === 'InsertElementCommand' ||\n cmdType === 'RemoveElementCommand') {\n if (cmd.parent === svgcontent) {\n draw.identifyLayers();\n }\n if (cmdType === 'InsertElementCommand') {\n if (isApply) { restoreRefElems(cmd.elem); }\n } else if (!isApply) {\n restoreRefElems(cmd.elem);\n }\n if (cmd.elem && cmd.elem.tagName === 'use') {\n setUseData(cmd.elem);\n }\n } else if (cmdType === 'ChangeElementCommand') {\n // if we are changing layer names, re-identify all layers\n if (cmd.elem.tagName === 'title' &&\n cmd.elem.parentNode.parentNode === svgcontent\n ) {\n draw.identifyLayers();\n }\n const values = isApply ? cmd.newValues : cmd.oldValues;\n // If stdDeviation was changed, update the blur.\n if (values.stdDeviation) {\n canvas.setBlurOffsets(cmd.elem.parentNode, values.stdDeviation);\n }\n // This is resolved in later versions of webkit, perhaps we should\n // have a featured detection for correct 'use' behavior?\n // ——————————\n // Remove & Re-add hack for Webkit (issue 775)\n // if (cmd.elem.tagName === 'use' && isWebkit()) {\n // const {elem} = cmd;\n // if (!elem.getAttribute('x') && !elem.getAttribute('y')) {\n // const parent = elem.parentNode;\n // const sib = elem.nextSibling;\n // elem.remove();\n // parent.insertBefore(elem, sib);\n // // Ok to replace above with this? `sib.before(elem);`\n // }\n // }\n }\n }\n }\n });\n\n /**\n* This should really be an intersection applying to all types rather than a union.\n* @name module:svgcanvas~addCommandToHistory\n* @type {module:path.EditorContext#addCommandToHistory|module:draw.DrawCanvasInit#addCommandToHistory}\n*/\n const addCommandToHistory = function (cmd) {\n canvas.undoMgr.addCommandToHistory(cmd);\n };\n\n /**\n* This should really be an intersection applying to all types rather than a union.\n* @name module:svgcanvas.SvgCanvas#getZoom\n* @type {module:path.EditorContext#getCurrentZoom|module:select.SVGFactory#getCurrentZoom}\n*/\n const getCurrentZoom = this.getZoom = function () { return currentZoom; };\n\n /**\n* This method rounds the incoming value to the nearest value based on the `currentZoom`\n* @name module:svgcanvas.SvgCanvas#round\n* @type {module:path.EditorContext#round}\n*/\n const round = this.round = function (val) {\n return Number.parseInt(val * currentZoom) / currentZoom;\n };\n\n selectInit(\n curConfig,\n /**\n * Export to select.js.\n * @implements {module:select.SVGFactory}\n */\n {\n createSVGElement (jsonMap) { return canvas.addSVGElementFromJson(jsonMap); },\n svgRoot () { return svgroot; },\n svgContent () { return svgcontent; },\n getCurrentZoom\n }\n );\n /**\n* This object manages selectors for us.\n* @name module:svgcanvas.SvgCanvas#selectorManager\n* @type {module:select.SelectorManager}\n*/\n const selectorManager = this.selectorManager = getSelectorManager();\n\n /**\n* @name module:svgcanvas.SvgCanvas#getNextId\n* @type {module:path.EditorContext#getNextId}\n*/\n const getNextId = canvas.getNextId = function () {\n return getCurrentDrawing().getNextId();\n };\n\n /**\n* @name module:svgcanvas.SvgCanvas#getId\n* @type {module:path.EditorContext#getId}\n*/\n const getId = canvas.getId = function () {\n return getCurrentDrawing().getId();\n };\n\n /**\n* The \"implements\" should really be an intersection applying to all types rather than a union.\n* @name module:svgcanvas.SvgCanvas#call\n* @type {module:draw.DrawCanvasInit#call|module:path.EditorContext#call}\n*/\n const call = function (ev, arg) {\n if (events[ev]) {\n return events[ev](window, arg);\n }\n return undefined;\n };\n\n /**\n* Clears the selection. The 'selected' handler is then optionally called.\n* This should really be an intersection applying to all types rather than a union.\n* @name module:svgcanvas.SvgCanvas#clearSelection\n* @type {module:draw.DrawCanvasInit#clearSelection|module:path.EditorContext#clearSelection}\n* @fires module:svgcanvas.SvgCanvas#event:selected\n*/\n const clearSelection = this.clearSelection = function (noCall) {\n selectedElements.forEach((elem) => {\n if (isNullish(elem)) {\n return;\n }\n selectorManager.releaseSelector(elem);\n });\n selectedElements = [];\n\n if (!noCall) { call('selected', selectedElements); }\n };\n\n /**\n* Adds a list of elements to the selection. The 'selected' handler is then called.\n* @name module:svgcanvas.SvgCanvas#addToSelection\n* @type {module:path.EditorContext#addToSelection}\n* @fires module:svgcanvas.SvgCanvas#event:selected\n*/\n const addToSelection = this.addToSelection = function (elemsToAdd, showGrips) {\n if (!elemsToAdd.length) { return; }\n // find the first null in our selectedElements array\n\n let j = 0;\n while (j < selectedElements.length) {\n if (isNullish(selectedElements[j])) {\n break;\n }\n ++j;\n }\n\n // now add each element consecutively\n let i = elemsToAdd.length;\n while (i--) {\n let elem = elemsToAdd[i];\n if (!elem) { continue; }\n const bbox = utilsGetBBox(elem);\n if (!bbox) { continue; }\n\n if (elem.tagName === 'a' && elem.childNodes.length === 1) {\n // Make \"a\" element's child be the selected element\n elem = elem.firstChild;\n }\n\n // if it's not already there, add it\n if (!selectedElements.includes(elem)) {\n selectedElements[j] = elem;\n\n // only the first selectedBBoxes element is ever used in the codebase these days\n // if (j === 0) selectedBBoxes[0] = utilsGetBBox(elem);\n j++;\n const sel = selectorManager.requestSelector(elem, bbox);\n\n if (selectedElements.length > 1) {\n sel.showGrips(false);\n }\n }\n }\n if (!selectedElements.length) {\n return;\n }\n call('selected', selectedElements);\n\n if (selectedElements.length === 1) {\n selectorManager.requestSelector(selectedElements[0]).showGrips(showGrips);\n }\n\n // make sure the elements are in the correct order\n // See: https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-compareDocumentPosition\n\n selectedElements.sort(function (a, b) {\n if (a && b && a.compareDocumentPosition) {\n return 3 - (b.compareDocumentPosition(a) & 6); // eslint-disable-line no-bitwise\n }\n if (isNullish(a)) {\n return 1;\n }\n return 0;\n });\n\n // Make sure first elements are not null\n while (isNullish(selectedElements[0])) {\n selectedElements.shift(0);\n }\n };\n\n /**\n* @type {module:path.EditorContext#getOpacity}\n*/\n const getOpacity = function () {\n return curShape.opacity;\n };\n\n /**\n* @name module:svgcanvas.SvgCanvas#getMouseTarget\n* @type {module:path.EditorContext#getMouseTarget}\n*/\n const getMouseTarget = this.getMouseTarget = function (evt) {\n if (isNullish(evt)) {\n return null;\n }\n let mouseTarget = evt.target;\n\n // if it was a <use>, Opera and WebKit return the SVGElementInstance\n if (mouseTarget.correspondingUseElement) { mouseTarget = mouseTarget.correspondingUseElement; }\n\n // for foreign content, go up until we find the foreignObject\n // WebKit browsers set the mouse target to the svgcanvas div\n if ([NS.MATH, NS.HTML].includes(mouseTarget.namespaceURI) &&\n mouseTarget.id !== 'svgcanvas'\n ) {\n while (mouseTarget.nodeName !== 'foreignObject') {\n mouseTarget = mouseTarget.parentNode;\n if (!mouseTarget) { return svgroot; }\n }\n }\n\n // Get the desired mouseTarget with jQuery selector-fu\n // If it's root-like, select the root\n const currentLayer = getCurrentDrawing().getCurrentLayer();\n if ([svgroot, container, svgcontent, currentLayer].includes(mouseTarget)) {\n return svgroot;\n }\n\n const $target = $(mouseTarget);\n\n // If it's a selection grip, return the grip parent\n if ($target.closest('#selectorParentGroup').length) {\n // While we could instead have just returned mouseTarget,\n // this makes it easier to indentify as being a selector grip\n return selectorManager.selectorParentGroup;\n }\n\n while (mouseTarget.parentNode !== (currentGroup || currentLayer)) {\n mouseTarget = mouseTarget.parentNode;\n }\n\n //\n // // go up until we hit a child of a layer\n // while (mouseTarget.parentNode.parentNode.tagName == 'g') {\n // mouseTarget = mouseTarget.parentNode;\n // }\n // Webkit bubbles the mouse event all the way up to the div, so we\n // set the mouseTarget to the svgroot like the other browsers\n // if (mouseTarget.nodeName.toLowerCase() == 'div') {\n // mouseTarget = svgroot;\n // }\n\n return mouseTarget;\n };\n\n /**\n* @namespace {module:path.pathActions} pathActions\n* @memberof module:svgcanvas.SvgCanvas#\n* @see module:path.pathActions\n*/\n canvas.pathActions = pathActions;\n /**\n* @type {module:path.EditorContext#resetD}\n*/\n function resetD (p) {\n p.setAttribute('d', pathActions.convertPath(p));\n }\n pathModule.init(\n /**\n * @implements {module:path.EditorContext}\n */\n {\n selectorManager, // Ok since not changing\n canvas, // Ok since not changing\n call,\n resetD,\n round,\n clearSelection,\n addToSelection,\n addCommandToHistory,\n remapElement,\n addSVGElementFromJson,\n getGridSnapping,\n getOpacity,\n getSelectedElements,\n getContainer () {\n return container;\n },\n setStarted (s) {\n started = s;\n },\n getRubberBox () {\n return rubberBox;\n },\n setRubberBox (rb) {\n rubberBox = rb;\n return rubberBox;\n },\n /**\n * @param {PlainObject} ptsInfo\n * @param {boolean} ptsInfo.closedSubpath\n * @param {SVGCircleElement[]} ptsInfo.grips\n * @fires module:svgcanvas.SvgCanvas#event:pointsAdded\n * @fires module:svgcanvas.SvgCanvas#event:selected\n * @returns {void}\n */\n addPtsToSelection ({closedSubpath, grips}) {\n // TODO: Correct this:\n pathActions.canDeleteNodes = true;\n pathActions.closed_subpath = closedSubpath;\n call('pointsAdded', {closedSubpath, grips});\n call('selected', grips);\n },\n /**\n * @param {PlainObject} changes\n * @param {ChangeElementCommand} changes.cmd\n * @param {SVGPathElement} changes.elem\n * @fires module:svgcanvas.SvgCanvas#event:changed\n * @returns {void}\n */\n endChanges ({cmd, elem}) {\n addCommandToHistory(cmd);\n call('changed', [elem]);\n },\n getCurrentZoom,\n getId,\n getNextId,\n getMouseTarget,\n getCurrentMode () {\n return currentMode;\n },\n setCurrentMode (cm) {\n currentMode = cm;\n return currentMode;\n },\n getDrawnPath () {\n return drawnPath;\n },\n setDrawnPath (dp) {\n drawnPath = dp;\n return drawnPath;\n },\n getSVGRoot\n }\n );\n\n // Interface strings, usually for title elements\n const uiStrings = {};\n\n const visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use';\n const refAttrs = ['clip-path', 'fill', 'filter', 'marker-end', 'marker-mid', 'marker-start', 'mask', 'stroke'];\n\n const elData = $.data;\n\n // Animation element to change the opacity of any newly created element\n const opacAni = document.createElementNS(NS.SVG, 'animate');\n $(opacAni).attr({\n attributeName: 'opacity',\n begin: 'indefinite',\n dur: 1,\n fill: 'freeze'\n }).appendTo(svgroot);\n\n const restoreRefElems = function (elem) {\n // Look for missing reference elements, restore any found\n const attrs = $(elem).attr(refAttrs);\n Object.values(attrs).forEach((val) => {\n if (val && val.startsWith('url(')) {\n const id = getUrlFromAttr(val).substr(1);\n const ref = getElem(id);\n if (!ref) {\n findDefs().append(removedElements[id]);\n delete removedElements[id];\n }\n }\n });\n\n const childs = elem.getElementsByTagName('*');\n\n if (childs.length) {\n for (let i = 0, l = childs.length; i < l; i++) {\n restoreRefElems(childs[i]);\n }\n }\n };\n\n // (function () {\n // TODO For Issue 208: this is a start on a thumbnail\n // const svgthumb = svgdoc.createElementNS(NS.SVG, 'use');\n // svgthumb.setAttribute('width', '100');\n // svgthumb.setAttribute('height', '100');\n // setHref(svgthumb, '#svgcontent');\n // svgroot.append(svgthumb);\n // }());\n\n /**\n * @typedef {PlainObject} module:svgcanvas.SaveOptions\n * @property {boolean} apply\n * @property {\"embed\"} [image]\n * @property {Integer} round_digits\n */\n\n // Object to contain image data for raster images that were found encodable\n const encodableImages = {},\n\n // Object with save options\n /**\n * @type {module:svgcanvas.SaveOptions}\n */\n saveOptions = {round_digits: 5},\n\n // Object with IDs for imported files, to see if one was already added\n importIds = {},\n\n // Current text style properties\n curText = allProperties.text,\n\n // Object to contain all included extensions\n extensions = {},\n\n // Map of deleted reference elements\n removedElements = {};\n\n let\n // String with image URL of last loadable image\n lastGoodImgUrl = curConfig.imgPath + 'logo.png',\n\n // Boolean indicating whether or not a draw action has been started\n started = false,\n\n // String with an element's initial transform attribute value\n startTransform = null,\n\n // String indicating the current editor mode\n currentMode = 'select',\n\n // String with the current direction in which an element is being resized\n currentResizeMode = 'none',\n\n // Current general properties\n curProperties = curShape,\n\n // Array with selected elements' Bounding box object\n // selectedBBoxes = new Array(1),\n\n // The DOM element that was just selected\n justSelected = null,\n\n // DOM element for selection rectangle drawn by the user\n rubberBox = null,\n\n // Array of current BBoxes, used in getIntersectionList().\n curBBoxes = [],\n\n // Canvas point for the most recent right click\n lastClickPoint = null;\n\n this.runExtension = function (name, action, vars) {\n return this.runExtensions(action, vars, false, (n) => n === name);\n };\n /**\n* @typedef {module:svgcanvas.ExtensionMouseDownStatus|module:svgcanvas.ExtensionMouseUpStatus|module:svgcanvas.ExtensionIDsUpdatedStatus|module:locale.ExtensionLocaleData[]|void} module:svgcanvas.ExtensionStatus\n* @tutorial ExtensionDocs\n*/\n /**\n* @callback module:svgcanvas.ExtensionVarBuilder\n* @param {string} name The name of the extension\n* @returns {module:svgcanvas.SvgCanvas#event:ext_addLangData}\n*/\n /**\n* @callback module:svgcanvas.ExtensionNameFilter\n* @param {string} name\n* @returns {boolean}\n*/\n /**\n* @todo Consider: Should this return an array by default, so extension results aren't overwritten?\n* @todo Would be easier to document if passing in object with key of action and vars as value; could then define an interface which tied both together\n* @function module:svgcanvas.SvgCanvas#runExtensions\n* @param {\"mouseDown\"|\"mouseMove\"|\"mouseUp\"|\"zoomChanged\"|\"IDsUpdated\"|\"canvasUpdated\"|\"toolButtonStateUpdate\"|\"selectedChanged\"|\"elementTransition\"|\"elementChanged\"|\"langReady\"|\"langChanged\"|\"addLangData\"|\"onNewDocument\"|\"workareaResized\"} action\n* @param {module:svgcanvas.SvgCanvas#event:ext_mouseDown|module:svgcanvas.SvgCanvas#event:ext_mouseMove|module:svgcanvas.SvgCanvas#event:ext_mouseUp|module:svgcanvas.SvgCanvas#event:ext_zoomChanged|module:svgcanvas.SvgCanvas#event:ext_IDsUpdated|module:svgcanvas.SvgCanvas#event:ext_canvasUpdated|module:svgcanvas.SvgCanvas#event:ext_toolButtonStateUpdate|module:svgcanvas.SvgCanvas#event:ext_selectedChanged|module:svgcanvas.SvgCanvas#event:ext_elementTransition|module:svgcanvas.SvgCanvas#event:ext_elementChanged|module:svgcanvas.SvgCanvas#event:ext_langReady|module:svgcanvas.SvgCanvas#event:ext_langChanged|module:svgcanvas.SvgCanvas#event:ext_addLangData|module:svgcanvas.SvgCanvas#event:ext_onNewDocument|module:svgcanvas.SvgCanvas#event:ext_workareaResized|module:svgcanvas.ExtensionVarBuilder} [vars]\n* @param {boolean} [returnArray]\n* @param {module:svgcanvas.ExtensionNameFilter} nameFilter\n* @returns {GenericArray<module:svgcanvas.ExtensionStatus>|module:svgcanvas.ExtensionStatus|false} See {@tutorial ExtensionDocs} on the ExtensionStatus.\n*/\n const runExtensions = this.runExtensions = function (action, vars, returnArray, nameFilter) {\n let result = returnArray ? [] : false;\n $.each(extensions, function (name, ext) {\n if (nameFilter && !nameFilter(name)) {\n return;\n }\n if (ext && action in ext) {\n if (typeof vars === 'function') {\n vars = vars(name); // ext, action\n }\n if (returnArray) {\n result.push(ext[action](vars));\n } else {\n result = ext[action](vars);\n }\n }\n });\n return result;\n };\n\n /**\n* @typedef {PlainObject} module:svgcanvas.ExtensionMouseDownStatus\n* @property {boolean} started Indicates that creating/editing has started\n*/\n /**\n* @typedef {PlainObject} module:svgcanvas.ExtensionMouseUpStatus\n* @property {boolean} keep Indicates if the current element should be kept\n* @property {boolean} started Indicates if editing should still be considered as \"started\"\n* @property {Element} element The element being affected\n*/\n /**\n* @typedef {PlainObject} module:svgcanvas.ExtensionIDsUpdatedStatus\n* @property {string[]} remove Contains string IDs (used by `ext-connector.js`)\n*/\n\n /**\n * @interface module:svgcanvas.ExtensionInitResponse\n * @property {module:SVGEditor.ContextTool[]|PlainObject<string, module:SVGEditor.ContextTool>} [context_tools]\n * @property {module:SVGEditor.Button[]|PlainObject<Integer, module:SVGEditor.Button>} [buttons]\n * @property {string} [svgicons] The location of a local SVG or SVGz file\n*/\n /**\n * @function module:svgcanvas.ExtensionInitResponse#mouseDown\n * @param {module:svgcanvas.SvgCanvas#event:ext_mouseDown} arg\n * @returns {void|module:svgcanvas.ExtensionMouseDownStatus}\n */\n /**\n * @function module:svgcanvas.ExtensionInitResponse#mouseMove\n * @param {module:svgcanvas.SvgCanvas#event:ext_mouseMove} arg\n * @returns {void}\n*/\n /**\n * @function module:svgcanvas.ExtensionInitResponse#mouseUp\n * @param {module:svgcanvas.SvgCanvas#event:ext_mouseUp} arg\n * @returns {module:svgcanvas.ExtensionMouseUpStatus}\n */\n /**\n * @function module:svgcanvas.ExtensionInitResponse#zoomChanged\n * @param {module:svgcanvas.SvgCanvas#event:ext_zoomChanged} arg\n * @returns {void}\n*/\n /**\n * @function module:svgcanvas.ExtensionInitResponse#IDsUpdated\n * @param {module:svgcanvas.SvgCanvas#event:ext_IDsUpdated} arg\n * @returns {module:svgcanvas.ExtensionIDsUpdatedStatus}\n */\n /**\n * @function module:svgcanvas.ExtensionInitResponse#canvasUpdated\n * @param {module:svgcanvas.SvgCanvas#event:ext_canvasUpdated} arg\n * @returns {void}\n*/\n /**\n * @function module:svgcanvas.ExtensionInitResponse#toolButtonStateUpdate\n * @param {module:svgcanvas.SvgCanvas#event:ext_toolButtonStateUpdate} arg\n * @returns {void}\n*/\n /**\n * @function module:svgcanvas.ExtensionInitResponse#selectedChanged\n * @param {module:svgcanvas.SvgCanvas#event:ext_selectedChanged} arg\n * @returns {void}\n*/\n /**\n * @function module:svgcanvas.ExtensionInitResponse#elementTransition\n * @param {module:svgcanvas.SvgCanvas#event:ext_elementTransition} arg\n * @returns {void}\n*/\n /**\n * @function module:svgcanvas.ExtensionInitResponse#elementChanged\n * @param {module:svgcanvas.SvgCanvas#event:ext_elementChanged} arg\n * @returns {void}\n*/\n /**\n * @function module:svgcanvas.ExtensionInitResponse#langReady\n * @param {module:svgcanvas.SvgCanvas#event:ext_langReady} arg\n * @returns {void}\n*/\n /**\n * @function module:svgcanvas.ExtensionInitResponse#langChanged\n * @param {module:svgcanvas.SvgCanvas#event:ext_langChanged} arg\n * @returns {void}\n*/\n /**\n * @function module:svgcanvas.ExtensionInitResponse#addLangData\n * @param {module:svgcanvas.SvgCanvas#event:ext_addLangData} arg\n * @returns {Promise<module:locale.ExtensionLocaleData>} Resolves to {@link module:locale.ExtensionLocaleData}\n*/\n /**\n * @function module:svgcanvas.ExtensionInitResponse#onNewDocument\n * @param {module:svgcanvas.SvgCanvas#event:ext_onNewDocument} arg\n * @returns {void}\n*/\n /**\n * @function module:svgcanvas.ExtensionInitResponse#workareaResized\n * @param {module:svgcanvas.SvgCanvas#event:ext_workareaResized} arg\n * @returns {void}\n*/\n /**\n * @function module:svgcanvas.ExtensionInitResponse#callback\n * @this module:SVGEditor\n * @param {module:svgcanvas.SvgCanvas#event:ext_callback} arg\n * @returns {void}\n*/\n\n /**\n* @callback module:svgcanvas.ExtensionInitCallback\n* @this module:SVGEditor\n* @param {module:svgcanvas.ExtensionArgumentObject} arg\n* @returns {Promise<module:svgcanvas.ExtensionInitResponse|void>} Resolves to [ExtensionInitResponse]{@link module:svgcanvas.ExtensionInitResponse} or `undefined`\n*/\n /**\n* @typedef {PlainObject} module:svgcanvas.ExtensionInitArgs\n* @property {external:jQuery} $\n* @property {module:SVGEditor~ImportLocale} importLocale\n*/\n /**\n* Add an extension to the editor.\n* @function module:svgcanvas.SvgCanvas#addExtension\n* @param {string} name - String with the ID of the extension. Used internally; no need for i18n.\n* @param {module:svgcanvas.ExtensionInitCallback} [extInitFunc] - Function supplied by the extension with its data\n* @param {module:svgcanvas.ExtensionInitArgs} initArgs\n* @fires module:svgcanvas.SvgCanvas#event:extension_added\n* @throws {TypeError|Error} `TypeError` if `extInitFunc` is not a function, `Error`\n* if extension of supplied name already exists\n* @returns {Promise<void>} Resolves to `undefined`\n*/\n this.addExtension = async function (name, extInitFunc, {$: jq, importLocale}) {\n if (typeof extInitFunc !== 'function') {\n throw new TypeError('Function argument expected for `svgcanvas.addExtension`');\n }\n if (name in extensions) {\n throw new Error('Cannot add extension \"' + name + '\", an extension by that name already exists.');\n }\n // Provide private vars/funcs here. Is there a better way to do this?\n /**\n * @typedef {module:svgcanvas.PrivateMethods} module:svgcanvas.ExtensionArgumentObject\n * @property {SVGSVGElement} svgroot See {@link module:svgcanvas~svgroot}\n * @property {SVGSVGElement} svgcontent See {@link module:svgcanvas~svgcontent}\n * @property {!(string|Integer)} nonce See {@link module:draw.Drawing#getNonce}\n * @property {module:select.SelectorManager} selectorManager\n * @property {module:SVGEditor~ImportLocale} importLocale\n */\n /**\n * @type {module:svgcanvas.ExtensionArgumentObject}\n * @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties\n */\n const argObj = $.extend(canvas.getPrivateMethods(), {\n $: jq,\n importLocale,\n svgroot,\n svgcontent,\n nonce: getCurrentDrawing().getNonce(),\n selectorManager\n });\n const extObj = await extInitFunc(argObj);\n if (extObj) {\n extObj.name = name;\n }\n\n extensions[name] = extObj;\n return call('extension_added', extObj);\n };\n\n /**\n* This method sends back an array or a NodeList full of elements that\n* intersect the multi-select rubber-band-box on the currentLayer only.\n*\n* We brute-force `getIntersectionList` for browsers that do not support it (Firefox).\n*\n* Reference:\n* Firefox does not implement `getIntersectionList()`, see {@link https://bugzilla.mozilla.org/show_bug.cgi?id=501421}.\n* @function module:svgcanvas.SvgCanvas#getIntersectionList\n* @param {SVGRect} rect\n* @returns {Element[]|NodeList} Bbox elements\n*/\n const getIntersectionList = this.getIntersectionList = function (rect) {\n if (isNullish(rubberBox)) { return null; }\n\n const parent = currentGroup || getCurrentDrawing().getCurrentLayer();\n\n let rubberBBox;\n if (!rect) {\n rubberBBox = rubberBox.getBBox();\n const bb = svgcontent.createSVGRect();\n\n ['x', 'y', 'width', 'height', 'top', 'right', 'bottom', 'left'].forEach((o) => {\n bb[o] = rubberBBox[o] / currentZoom;\n });\n rubberBBox = bb;\n } else {\n rubberBBox = svgcontent.createSVGRect();\n rubberBBox.x = rect.x;\n rubberBBox.y = rect.y;\n rubberBBox.width = rect.width;\n rubberBBox.height = rect.height;\n }\n\n let resultList = null;\n if (!isIE()) {\n if (typeof svgroot.getIntersectionList === 'function') {\n // Offset the bbox of the rubber box by the offset of the svgcontent element.\n rubberBBox.x += Number.parseInt(svgcontent.getAttribute('x'));\n rubberBBox.y += Number.parseInt(svgcontent.getAttribute('y'));\n\n resultList = svgroot.getIntersectionList(rubberBBox, parent);\n }\n }\n\n if (isNullish(resultList) || typeof resultList.item !== 'function') {\n resultList = [];\n\n if (!curBBoxes.length) {\n // Cache all bboxes\n curBBoxes = getVisibleElementsAndBBoxes(parent);\n }\n let i = curBBoxes.length;\n while (i--) {\n if (!rubberBBox.width) { continue; }\n if (rectsIntersect(rubberBBox, curBBoxes[i].bbox)) {\n resultList.push(curBBoxes[i].elem);\n }\n }\n }\n\n // addToSelection expects an array, but it's ok to pass a NodeList\n // because using square-bracket notation is allowed:\n // https://www.w3.org/TR/DOM-Level-2-Core/ecma-script-binding.html\n return resultList;\n };\n\n this.getStrokedBBox = getStrokedBBoxDefaultVisible;\n\n this.getVisibleElements = getVisibleElements;\n\n /**\n* @typedef {PlainObject} ElementAndBBox\n* @property {Element} elem - The element\n* @property {module:utilities.BBoxObject} bbox - The element's BBox as retrieved from `getStrokedBBoxDefaultVisible`\n*/\n\n /**\n* Get all elements that have a BBox (excludes `<defs>`, `<title>`, etc).\n* Note that 0-opacity, off-screen etc elements are still considered \"visible\"\n* for this function.\n* @function module:svgcanvas.SvgCanvas#getVisibleElementsAndBBoxes\n* @param {Element} parent - The parent DOM element to search within\n* @returns {ElementAndBBox[]} An array with objects that include:\n*/\n const getVisibleElementsAndBBoxes = this.getVisibleElementsAndBBoxes = function (parent) {\n if (!parent) {\n parent = $(svgcontent).children(); // Prevent layers from being included\n }\n const contentElems = [];\n $(parent).children().each(function (i, elem) {\n if (elem.getBBox) {\n contentElems.push({elem, bbox: getStrokedBBoxDefaultVisible([elem])});\n }\n });\n return contentElems.reverse();\n };\n\n /**\n* Wrap an SVG element into a group element, mark the group as 'gsvg'.\n* @function module:svgcanvas.SvgCanvas#groupSvgElem\n* @param {Element} elem - SVG element to wrap\n* @returns {void}\n*/\n const groupSvgElem = this.groupSvgElem = function (elem) {\n const g = document.createElementNS(NS.SVG, 'g');\n elem.replaceWith(g);\n $(g).append(elem).data('gsvg', elem)[0].id = getNextId();\n };\n\n // Set scope for these functions\n\n // Object to contain editor event names and callback functions\n const events = {};\n\n canvas.call = call;\n /**\n * Array of what was changed (elements, layers).\n * @event module:svgcanvas.SvgCanvas#event:changed\n * @type {Element[]}\n */\n /**\n * Array of selected elements.\n * @event module:svgcanvas.SvgCanvas#event:selected\n * @type {Element[]}\n */\n /**\n * Array of selected elements.\n * @event module:svgcanvas.SvgCanvas#event:transition\n * @type {Element[]}\n */\n /**\n * The Element is always `SVGGElement`?\n * If not `null`, will be the set current group element.\n * @event module:svgcanvas.SvgCanvas#event:contextset\n * @type {null|Element}\n */\n /**\n * @event module:svgcanvas.SvgCanvas#event:pointsAdded\n * @type {PlainObject}\n * @property {boolean} closedSubpath\n * @property {SVGCircleElement[]} grips Grips elements\n */\n\n /**\n * @event module:svgcanvas.SvgCanvas#event:zoomed\n * @type {PlainObject}\n * @property {Float} x\n * @property {Float} y\n * @property {Float} width\n * @property {Float} height\n * @property {0.5|2} factor\n * @see module:SVGEditor.BBoxObjectWithFactor\n */\n /**\n * @event module:svgcanvas.SvgCanvas#event:updateCanvas\n * @type {PlainObject}\n * @property {false} center\n * @property {module:math.XYObject} newCtr\n */\n /**\n * @typedef {PlainObject} module:svgcanvas.ExtensionInitResponsePlusName\n * @implements {module:svgcanvas.ExtensionInitResponse}\n * @property {string} name The extension's resolved ID (whether explicit or based on file name)\n */\n /**\n * Generalized extension object response of\n * [`init()`]{@link module:svgcanvas.ExtensionInitCallback}\n * along with the name of the extension.\n * @event module:svgcanvas.SvgCanvas#event:extension_added\n * @type {module:svgcanvas.ExtensionInitResponsePlusName|void}\n */\n /**\n * @event module:svgcanvas.SvgCanvas#event:extensions_added\n * @type {void}\n*/\n /**\n * @typedef {PlainObject} module:svgcanvas.Message\n * @property {any} data The data\n * @property {string} origin The origin\n */\n /**\n * @event module:svgcanvas.SvgCanvas#event:message\n * @type {module:svgcanvas.Message}\n */\n /**\n * SVG canvas converted to string.\n * @event module:svgcanvas.SvgCanvas#event:saved\n * @type {string}\n */\n /**\n * @event module:svgcanvas.SvgCanvas#event:setnonce\n * @type {!(string|Integer)}\n */\n /**\n * @event module:svgcanvas.SvgCanvas#event:unsetnonce\n * @type {void}\n */\n /**\n * @event module:svgcanvas.SvgCanvas#event:zoomDone\n * @type {void}\n*/\n /**\n * @event module:svgcanvas.SvgCanvas#event:cleared\n * @type {void}\n*/\n\n /**\n * @event module:svgcanvas.SvgCanvas#event:exported\n * @type {module:svgcanvas.ImageExportedResults}\n */\n /**\n * @event module:svgcanvas.SvgCanvas#event:exportedPDF\n * @type {module:svgcanvas.PDFExportedResults}\n */\n /**\n * Creating a cover-all class until {@link https://github.com/jsdoc3/jsdoc/issues/1545} may be supported.\n * `undefined` may be returned by {@link module:svgcanvas.SvgCanvas#event:extension_added} if the extension's `init` returns `undefined` It is also the type for the following events \"zoomDone\", \"unsetnonce\", \"cleared\", and \"extensions_added\".\n * @event module:svgcanvas.SvgCanvas#event:GenericCanvasEvent\n * @type {module:svgcanvas.SvgCanvas#event:selected|module:svgcanvas.SvgCanvas#event:changed|module:svgcanvas.SvgCanvas#event:contextset|module:svgcanvas.SvgCanvas#event:pointsAdded|module:svgcanvas.SvgCanvas#event:extension_added|module:svgcanvas.SvgCanvas#event:extensions_added|module:svgcanvas.SvgCanvas#event:message|module:svgcanvas.SvgCanvas#event:transition|module:svgcanvas.SvgCanvas#event:zoomed|module:svgcanvas.SvgCanvas#event:updateCanvas|module:svgcanvas.SvgCanvas#event:saved|module:svgcanvas.SvgCanvas#event:exported|module:svgcanvas.SvgCanvas#event:exportedPDF|module:svgcanvas.SvgCanvas#event:setnonce|module:svgcanvas.SvgCanvas#event:unsetnonce|void}\n */\n\n /**\n * The promise return, if present, resolves to `undefined`\n * (`extension_added`, `exported`, `saved`).\n * @typedef {Promise<void>|void} module:svgcanvas.EventHandlerReturn\n*/\n\n /**\n* @callback module:svgcanvas.EventHandler\n* @param {external:Window} win\n* @param {module:svgcanvas.SvgCanvas#event:GenericCanvasEvent} arg\n* @listens module:svgcanvas.SvgCanvas#event:GenericCanvasEvent\n* @returns {module:svgcanvas.EventHandlerReturn}\n*/\n\n /**\n* Attaches a callback function to an event.\n* @function module:svgcanvas.SvgCanvas#bind\n* @param {\"changed\"|\"contextset\"|\"selected\"|\"pointsAdded\"|\"extension_added\"|\"extensions_added\"|\"message\"|\"transition\"|\"zoomed\"|\"updateCanvas\"|\"zoomDone\"|\"saved\"|\"exported\"|\"exportedPDF\"|\"setnonce\"|\"unsetnonce\"|\"cleared\"} ev - String indicating the name of the event\n* @param {module:svgcanvas.EventHandler} f - The callback function to bind to the event\n* @returns {module:svgcanvas.EventHandler} The previous event\n*/\n canvas.bind = function (ev, f) {\n const old = events[ev];\n events[ev] = f;\n return old;\n };\n\n /**\n* Runs the SVG Document through the sanitizer and then updates its paths.\n* @function module:svgcanvas.SvgCanvas#prepareSvg\n* @param {XMLDocument} newDoc - The SVG DOM document\n* @returns {void}\n*/\n this.prepareSvg = function (newDoc) {\n this.sanitizeSvg(newDoc.documentElement);\n\n // convert paths into absolute commands\n const paths = [...newDoc.getElementsByTagNameNS(NS.SVG, 'path')];\n paths.forEach((path) => {\n path.setAttribute('d', pathActions.convertPath(path));\n pathActions.fixEnd(path);\n });\n };\n\n /**\n* Hack for Firefox bugs where text element features aren't updated or get\n* messed up. See issue 136 and issue 137.\n* This function clones the element and re-selects it.\n* @function module:svgcanvas~ffClone\n* @todo Test for this bug on load and add it to \"support\" object instead of\n* browser sniffing\n* @param {Element} elem - The (text) DOM element to clone\n* @returns {Element} Cloned element\n*/\n const ffClone = function (elem) {\n if (!isGecko()) { return elem; }\n const clone = elem.cloneNode(true);\n elem.before(clone);\n elem.remove();\n selectorManager.releaseSelector(elem);\n selectedElements[0] = clone;\n selectorManager.requestSelector(clone).showGrips(true);\n return clone;\n };\n\n // `this.each` is deprecated, if any extension used this it can be recreated by doing this:\n // * @example $(canvas.getRootElem()).children().each(...)\n // * @function module:svgcanvas.SvgCanvas#each\n // this.each = function (cb) {\n // $(svgroot).children().each(cb);\n // };\n\n /**\n* Removes any old rotations if present, prepends a new rotation at the\n* transformed center.\n* @function module:svgcanvas.SvgCanvas#setRotationAngle\n* @param {string|Float} val - The new rotation angle in degrees\n* @param {boolean} preventUndo - Indicates whether the action should be undoable or not\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {void}\n*/\n this.setRotationAngle = function (val, preventUndo) {\n // ensure val is the proper type\n val = Number.parseFloat(val);\n const elem = selectedElements[0];\n const oldTransform = elem.getAttribute('transform');\n const bbox = utilsGetBBox(elem);\n const cx = bbox.x + bbox.width / 2, cy = bbox.y + bbox.height / 2;\n const tlist = getTransformList(elem);\n\n // only remove the real rotational transform if present (i.e. at index=0)\n if (tlist.numberOfItems > 0) {\n const xform = tlist.getItem(0);\n if (xform.type === 4) {\n tlist.removeItem(0);\n }\n }\n // find Rnc and insert it\n if (val !== 0) {\n const center = transformPoint(cx, cy, transformListToTransform(tlist).matrix);\n const Rnc = svgroot.createSVGTransform();\n Rnc.setRotate(val, center.x, center.y);\n if (tlist.numberOfItems) {\n tlist.insertItemBefore(Rnc, 0);\n } else {\n tlist.appendItem(Rnc);\n }\n } else if (tlist.numberOfItems === 0) {\n elem.removeAttribute('transform');\n }\n\n if (!preventUndo) {\n // we need to undo it, then redo it so it can be undo-able! :)\n // TODO: figure out how to make changes to transform list undo-able cross-browser?\n const newTransform = elem.getAttribute('transform');\n elem.setAttribute('transform', oldTransform);\n changeSelectedAttribute('transform', newTransform, selectedElements);\n call('changed', selectedElements);\n }\n // const pointGripContainer = getElem('pathpointgrip_container');\n // if (elem.nodeName === 'path' && pointGripContainer) {\n // pathActions.setPointContainerTransform(elem.getAttribute('transform'));\n // }\n const selector = selectorManager.requestSelector(selectedElements[0]);\n selector.resize();\n Selector.updateGripCursors(val);\n };\n\n /**\n* Runs `recalculateDimensions` on the selected elements,\n* adding the changes to a single batch command.\n* @function module:svgcanvas.SvgCanvas#recalculateAllSelectedDimensions\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {void}\n*/\n const recalculateAllSelectedDimensions = this.recalculateAllSelectedDimensions = function () {\n const text = (currentResizeMode === 'none' ? 'position' : 'size');\n const batchCmd = new BatchCommand(text);\n\n let i = selectedElements.length;\n while (i--) {\n const elem = selectedElements[i];\n // if (getRotationAngle(elem) && !hasMatrixTransform(getTransformList(elem))) { continue; }\n const cmd = recalculateDimensions(elem);\n if (cmd) {\n batchCmd.addSubCommand(cmd);\n }\n }\n\n if (!batchCmd.isEmpty()) {\n addCommandToHistory(batchCmd);\n call('changed', selectedElements);\n }\n };\n\n /**\n * Debug tool to easily see the current matrix in the browser's console.\n * @function module:svgcanvas~logMatrix\n * @param {SVGMatrix} m The matrix\n * @returns {void}\n */\n const logMatrix = function (m) {\n console.log([m.a, m.b, m.c, m.d, m.e, m.f]); // eslint-disable-line no-console\n };\n\n // Root Current Transformation Matrix in user units\n let rootSctm = null;\n\n /**\n* Group: Selection.\n*/\n\n // TODO: do we need to worry about selectedBBoxes here?\n\n /**\n* Selects only the given elements, shortcut for `clearSelection(); addToSelection()`.\n* @function module:svgcanvas.SvgCanvas#selectOnly\n* @param {Element[]} elems - an array of DOM elements to be selected\n* @param {boolean} showGrips - Indicates whether the resize grips should be shown\n* @returns {void}\n*/\n const selectOnly = this.selectOnly = function (elems, showGrips) {\n clearSelection(true);\n addToSelection(elems, showGrips);\n };\n\n // TODO: could use slice here to make this faster?\n // TODO: should the 'selected' handler\n\n /**\n* Removes elements from the selection.\n* @function module:svgcanvas.SvgCanvas#removeFromSelection\n* @param {Element[]} elemsToRemove - An array of elements to remove from selection\n* @returns {void}\n*/\n /* const removeFromSelection = */ this.removeFromSelection = function (elemsToRemove) {\n if (isNullish(selectedElements[0])) { return; }\n if (!elemsToRemove.length) { return; }\n\n // find every element and remove it from our array copy\n const newSelectedItems = [],\n len = selectedElements.length;\n for (let i = 0; i < len; ++i) {\n const elem = selectedElements[i];\n if (elem) {\n // keep the item\n if (!elemsToRemove.includes(elem)) {\n newSelectedItems.push(elem);\n } else { // remove the item and its selector\n selectorManager.releaseSelector(elem);\n }\n }\n }\n // the copy becomes the master now\n selectedElements = newSelectedItems;\n };\n\n /**\n* Clears the selection, then adds all elements in the current layer to the selection.\n* @function module:svgcanvas.SvgCanvas#selectAllInCurrentLayer\n* @returns {void}\n*/\n this.selectAllInCurrentLayer = function () {\n const currentLayer = getCurrentDrawing().getCurrentLayer();\n if (currentLayer) {\n currentMode = 'select';\n selectOnly($(currentGroup || currentLayer).children());\n }\n };\n\n let drawnPath = null;\n\n // Mouse events\n (function () {\n const freehand = {\n minx: null,\n miny: null,\n maxx: null,\n maxy: null\n };\n const THRESHOLD_DIST = 0.8,\n STEP_COUNT = 10;\n let dAttr = null,\n startX = null,\n startY = null,\n rStartX = null,\n rStartY = null,\n initBbox = {},\n sumDistance = 0,\n controllPoint2 = {x: 0, y: 0},\n controllPoint1 = {x: 0, y: 0},\n start = {x: 0, y: 0},\n end = {x: 0, y: 0},\n bSpline = {x: 0, y: 0},\n nextPos = {x: 0, y: 0},\n parameter,\n nextParameter;\n\n const getBsplinePoint = function (t) {\n const spline = {x: 0, y: 0},\n p0 = controllPoint2,\n p1 = controllPoint1,\n p2 = start,\n p3 = end,\n S = 1.0 / 6.0,\n t2 = t * t,\n t3 = t2 * t;\n\n const m = [\n [-1, 3, -3, 1],\n [3, -6, 3, 0],\n [-3, 0, 3, 0],\n [1, 4, 1, 0]\n ];\n\n spline.x = S * (\n (p0.x * m[0][0] + p1.x * m[0][1] + p2.x * m[0][2] + p3.x * m[0][3]) * t3 +\n (p0.x * m[1][0] + p1.x * m[1][1] + p2.x * m[1][2] + p3.x * m[1][3]) * t2 +\n (p0.x * m[2][0] + p1.x * m[2][1] + p2.x * m[2][2] + p3.x * m[2][3]) * t +\n (p0.x * m[3][0] + p1.x * m[3][1] + p2.x * m[3][2] + p3.x * m[3][3])\n );\n spline.y = S * (\n (p0.y * m[0][0] + p1.y * m[0][1] + p2.y * m[0][2] + p3.y * m[0][3]) * t3 +\n (p0.y * m[1][0] + p1.y * m[1][1] + p2.y * m[1][2] + p3.y * m[1][3]) * t2 +\n (p0.y * m[2][0] + p1.y * m[2][1] + p2.y * m[2][2] + p3.y * m[2][3]) * t +\n (p0.y * m[3][0] + p1.y * m[3][1] + p2.y * m[3][2] + p3.y * m[3][3])\n );\n\n return {\n x: spline.x,\n y: spline.y\n };\n };\n /**\n * Follows these conditions:\n * - When we are in a create mode, the element is added to the canvas but the\n * action is not recorded until mousing up.\n * - When we are in select mode, select the element, remember the position\n * and do nothing else.\n * @param {MouseEvent} evt\n * @fires module:svgcanvas.SvgCanvas#event:ext_mouseDown\n * @returns {void}\n */\n const mouseDown = function (evt) {\n if (canvas.spaceKey || evt.button === 1) { return; }\n\n const rightClick = evt.button === 2;\n\n if (evt.altKey) { // duplicate when dragging\n canvas.cloneSelectedElements(0, 0);\n }\n\n rootSctm = $('#svgcontent g')[0].getScreenCTM().inverse();\n\n const pt = transformPoint(evt.pageX, evt.pageY, rootSctm),\n mouseX = pt.x * currentZoom,\n mouseY = pt.y * currentZoom;\n\n evt.preventDefault();\n\n if (rightClick) {\n currentMode = 'select';\n lastClickPoint = pt;\n }\n\n // This would seem to be unnecessary...\n // if (!['select', 'resize'].includes(currentMode)) {\n // setGradient();\n // }\n\n let x = mouseX / currentZoom,\n y = mouseY / currentZoom;\n let mouseTarget = getMouseTarget(evt);\n\n if (mouseTarget.tagName === 'a' && mouseTarget.childNodes.length === 1) {\n mouseTarget = mouseTarget.firstChild;\n }\n\n // realX/y ignores grid-snap value\n const realX = x;\n rStartX = startX = x;\n const realY = y;\n rStartY = startY = y;\n\n if (curConfig.gridSnapping) {\n x = snapToGrid(x);\n y = snapToGrid(y);\n startX = snapToGrid(startX);\n startY = snapToGrid(startY);\n }\n\n // if it is a selector grip, then it must be a single element selected,\n // set the mouseTarget to that and update the mode to rotate/resize\n\n if (mouseTarget === selectorManager.selectorParentGroup && !isNullish(selectedElements[0])) {\n const grip = evt.target;\n const griptype = elData(grip, 'type');\n // rotating\n if (griptype === 'rotate') {\n currentMode = 'rotate';\n // resizing\n } else if (griptype === 'resize') {\n currentMode = 'resize';\n currentResizeMode = elData(grip, 'dir');\n }\n mouseTarget = selectedElements[0];\n }\n\n startTransform = mouseTarget.getAttribute('transform');\n\n const tlist = getTransformList(mouseTarget);\n switch (currentMode) {\n case 'select':\n started = true;\n currentResizeMode = 'none';\n if (rightClick) { started = false; }\n\n if (mouseTarget !== svgroot) {\n // if this element is not yet selected, clear selection and select it\n if (!selectedElements.includes(mouseTarget)) {\n // only clear selection if shift is not pressed (otherwise, add\n // element to selection)\n if (!evt.shiftKey) {\n // No need to do the call here as it will be done on addToSelection\n clearSelection(true);\n }\n addToSelection([mouseTarget]);\n justSelected = mouseTarget;\n pathActions.clear();\n }\n // else if it's a path, go into pathedit mode in mouseup\n\n if (!rightClick) {\n // insert a dummy transform so if the element(s) are moved it will have\n // a transform to use for its translate\n for (const selectedElement of selectedElements) {\n if (isNullish(selectedElement)) { continue; }\n const slist = getTransformList(selectedElement);\n if (slist.numberOfItems) {\n slist.insertItemBefore(svgroot.createSVGTransform(), 0);\n } else {\n slist.appendItem(svgroot.createSVGTransform());\n }\n }\n }\n } else if (!rightClick) {\n clearSelection();\n currentMode = 'multiselect';\n if (isNullish(rubberBox)) {\n rubberBox = selectorManager.getRubberBandBox();\n }\n rStartX *= currentZoom;\n rStartY *= currentZoom;\n // console.log('p',[evt.pageX, evt.pageY]);\n // console.log('c',[evt.clientX, evt.clientY]);\n // console.log('o',[evt.offsetX, evt.offsetY]);\n // console.log('s',[startX, startY]);\n\n assignAttributes(rubberBox, {\n x: rStartX,\n y: rStartY,\n width: 0,\n height: 0,\n display: 'inline'\n }, 100);\n }\n break;\n case 'zoom':\n started = true;\n if (isNullish(rubberBox)) {\n rubberBox = selectorManager.getRubberBandBox();\n }\n assignAttributes(rubberBox, {\n x: realX * currentZoom,\n y: realX * currentZoom,\n width: 0,\n height: 0,\n display: 'inline'\n }, 100);\n break;\n case 'resize': {\n started = true;\n startX = x;\n startY = y;\n\n // Getting the BBox from the selection box, since we know we\n // want to orient around it\n initBbox = utilsGetBBox($('#selectedBox0')[0]);\n const bb = {};\n $.each(initBbox, function (key, val) {\n bb[key] = val / currentZoom;\n });\n initBbox = bb;\n\n // append three dummy transforms to the tlist so that\n // we can translate,scale,translate in mousemove\n const pos = getRotationAngle(mouseTarget) ? 1 : 0;\n\n if (hasMatrixTransform(tlist)) {\n tlist.insertItemBefore(svgroot.createSVGTransform(), pos);\n tlist.insertItemBefore(svgroot.createSVGTransform(), pos);\n tlist.insertItemBefore(svgroot.createSVGTransform(), pos);\n } else {\n tlist.appendItem(svgroot.createSVGTransform());\n tlist.appendItem(svgroot.createSVGTransform());\n tlist.appendItem(svgroot.createSVGTransform());\n\n if (supportsNonScalingStroke()) {\n // Handle crash for newer Chrome and Safari 6 (Mobile and Desktop):\n // https://code.google.com/p/svg-edit/issues/detail?id=904\n // Chromium issue: https://code.google.com/p/chromium/issues/detail?id=114625\n // TODO: Remove this workaround once vendor fixes the issue\n const iswebkit = isWebkit();\n\n let delayedStroke;\n if (iswebkit) {\n delayedStroke = function (ele) {\n const stroke_ = ele.getAttribute('stroke');\n ele.removeAttribute('stroke');\n // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker\n if (stroke_ !== null) setTimeout(function () { ele.setAttribute('stroke', stroke_); }, 0);\n };\n }\n mouseTarget.style.vectorEffect = 'non-scaling-stroke';\n if (iswebkit) { delayedStroke(mouseTarget); }\n\n const all = mouseTarget.getElementsByTagName('*'),\n len = all.length;\n for (let i = 0; i < len; i++) {\n if (!all[i].style) { // mathML\n continue;\n }\n all[i].style.vectorEffect = 'non-scaling-stroke';\n if (iswebkit) { delayedStroke(all[i]); }\n }\n }\n }\n break;\n }\n case 'fhellipse':\n case 'fhrect':\n case 'fhpath':\n start.x = realX;\n start.y = realY;\n controllPoint1 = {x: 0, y: 0};\n controllPoint2 = {x: 0, y: 0};\n started = true;\n dAttr = realX + ',' + realY + ' ';\n // Commented out as doing nothing now:\n // strokeW = parseFloat(curShape.stroke_width) === 0 ? 1 : curShape.stroke_width;\n addSVGElementFromJson({\n element: 'polyline',\n curStyles: true,\n attr: {\n points: dAttr,\n id: getNextId(),\n fill: 'none',\n opacity: curShape.opacity / 2,\n 'stroke-linecap': 'round',\n style: 'pointer-events:none'\n }\n });\n freehand.minx = realX;\n freehand.maxx = realX;\n freehand.miny = realY;\n freehand.maxy = realY;\n break;\n case 'image': {\n started = true;\n const newImage = addSVGElementFromJson({\n element: 'image',\n attr: {\n x,\n y,\n width: 0,\n height: 0,\n id: getNextId(),\n opacity: curShape.opacity / 2,\n style: 'pointer-events:inherit'\n }\n });\n setHref(newImage, lastGoodImgUrl);\n preventClickDefault(newImage);\n break;\n } case 'square':\n // TODO: once we create the rect, we lose information that this was a square\n // (for resizing purposes this could be important)\n // Fallthrough\n case 'rect':\n started = true;\n startX = x;\n startY = y;\n addSVGElementFromJson({\n element: 'rect',\n curStyles: true,\n attr: {\n x,\n y,\n width: 0,\n height: 0,\n id: getNextId(),\n opacity: curShape.opacity / 2\n }\n });\n break;\n case 'line': {\n started = true;\n const strokeW = Number(curShape.stroke_width) === 0 ? 1 : curShape.stroke_width;\n addSVGElementFromJson({\n element: 'line',\n curStyles: true,\n attr: {\n x1: x,\n y1: y,\n x2: x,\n y2: y,\n id: getNextId(),\n stroke: curShape.stroke,\n 'stroke-width': strokeW,\n 'stroke-dasharray': curShape.stroke_dasharray,\n 'stroke-linejoin': curShape.stroke_linejoin,\n 'stroke-linecap': curShape.stroke_linecap,\n 'stroke-opacity': curShape.stroke_opacity,\n fill: 'none',\n opacity: curShape.opacity / 2,\n style: 'pointer-events:none'\n }\n });\n break;\n } case 'circle':\n started = true;\n addSVGElementFromJson({\n element: 'circle',\n curStyles: true,\n attr: {\n cx: x,\n cy: y,\n r: 0,\n id: getNextId(),\n opacity: curShape.opacity / 2\n }\n });\n break;\n case 'ellipse':\n started = true;\n addSVGElementFromJson({\n element: 'ellipse',\n curStyles: true,\n attr: {\n cx: x,\n cy: y,\n rx: 0,\n ry: 0,\n id: getNextId(),\n opacity: curShape.opacity / 2\n }\n });\n break;\n case 'text':\n started = true;\n /* const newText = */ addSVGElementFromJson({\n element: 'text',\n curStyles: true,\n attr: {\n x,\n y,\n id: getNextId(),\n fill: curText.fill,\n 'stroke-width': curText.stroke_width,\n 'font-size': curText.font_size,\n 'font-family': curText.font_family,\n 'text-anchor': 'middle',\n 'xml:space': 'preserve',\n opacity: curShape.opacity\n }\n });\n // newText.textContent = 'text';\n break;\n case 'path':\n // Fall through\n case 'pathedit':\n startX *= currentZoom;\n startY *= currentZoom;\n pathActions.mouseDown(evt, mouseTarget, startX, startY);\n started = true;\n break;\n case 'textedit':\n startX *= currentZoom;\n startY *= currentZoom;\n textActions.mouseDown(evt, mouseTarget, startX, startY);\n started = true;\n break;\n case 'rotate':\n started = true;\n // we are starting an undoable change (a drag-rotation)\n canvas.undoMgr.beginUndoableChange('transform', selectedElements);\n break;\n default:\n // This could occur in an extension\n break;\n }\n\n /**\n * The main (left) mouse button is held down on the canvas area.\n * @event module:svgcanvas.SvgCanvas#event:ext_mouseDown\n * @type {PlainObject}\n * @property {MouseEvent} event The event object\n * @property {Float} start_x x coordinate on canvas\n * @property {Float} start_y y coordinate on canvas\n * @property {Element[]} selectedElements An array of the selected Elements\n */\n const extResult = runExtensions('mouseDown', /** @type {module:svgcanvas.SvgCanvas#event:ext_mouseDown} */ {\n event: evt,\n start_x: startX,\n start_y: startY,\n selectedElements\n }, true);\n\n $.each(extResult, function (i, r) {\n if (r && r.started) {\n started = true;\n }\n });\n };\n\n // in this function we do not record any state changes yet (but we do update\n // any elements that are still being created, moved or resized on the canvas)\n /**\n *\n * @param {MouseEvent} evt\n * @fires module:svgcanvas.SvgCanvas#event:transition\n * @fires module:svgcanvas.SvgCanvas#event:ext_mouseMove\n * @returns {void}\n */\n const mouseMove = function (evt) {\n if (!started) { return; }\n if (evt.button === 1 || canvas.spaceKey) { return; }\n\n let i, xya, c, cx, cy, dx, dy, len, angle, box,\n selected = selectedElements[0];\n const\n pt = transformPoint(evt.pageX, evt.pageY, rootSctm),\n mouseX = pt.x * currentZoom,\n mouseY = pt.y * currentZoom,\n shape = getElem(getId());\n\n let realX = mouseX / currentZoom;\n let x = realX;\n let realY = mouseY / currentZoom;\n let y = realY;\n\n if (curConfig.gridSnapping) {\n x = snapToGrid(x);\n y = snapToGrid(y);\n }\n\n evt.preventDefault();\n let tlist;\n switch (currentMode) {\n case 'select': {\n // we temporarily use a translate on the element(s) being dragged\n // this transform is removed upon mousing up and the element is\n // relocated to the new location\n if (selectedElements[0] !== null) {\n dx = x - startX;\n dy = y - startY;\n\n if (curConfig.gridSnapping) {\n dx = snapToGrid(dx);\n dy = snapToGrid(dy);\n }\n\n /*\n // Commenting out as currently has no effect\n if (evt.shiftKey) {\n xya = snapToAngle(startX, startY, x, y);\n ({x, y} = xya);\n }\n */\n\n if (dx !== 0 || dy !== 0) {\n len = selectedElements.length;\n for (i = 0; i < len; ++i) {\n selected = selectedElements[i];\n if (isNullish(selected)) { break; }\n // if (i === 0) {\n // const box = utilsGetBBox(selected);\n // selectedBBoxes[i].x = box.x + dx;\n // selectedBBoxes[i].y = box.y + dy;\n // }\n\n // update the dummy transform in our transform list\n // to be a translate\n const xform = svgroot.createSVGTransform();\n tlist = getTransformList(selected);\n // Note that if Webkit and there's no ID for this\n // element, the dummy transform may have gotten lost.\n // This results in unexpected behaviour\n\n xform.setTranslate(dx, dy);\n if (tlist.numberOfItems) {\n tlist.replaceItem(xform, 0);\n } else {\n tlist.appendItem(xform);\n }\n\n // update our internal bbox that we're tracking while dragging\n selectorManager.requestSelector(selected).resize();\n }\n\n call('transition', selectedElements);\n }\n }\n break;\n } case 'multiselect': {\n realX *= currentZoom;\n realY *= currentZoom;\n assignAttributes(rubberBox, {\n x: Math.min(rStartX, realX),\n y: Math.min(rStartY, realY),\n width: Math.abs(realX - rStartX),\n height: Math.abs(realY - rStartY)\n }, 100);\n\n // for each selected:\n // - if newList contains selected, do nothing\n // - if newList doesn't contain selected, remove it from selected\n // - for any newList that was not in selectedElements, add it to selected\n const elemsToRemove = selectedElements.slice(), elemsToAdd = [],\n newList = getIntersectionList();\n\n // For every element in the intersection, add if not present in selectedElements.\n len = newList.length;\n for (i = 0; i < len; ++i) {\n const intElem = newList[i];\n // Found an element that was not selected before, so we should add it.\n if (!selectedElements.includes(intElem)) {\n elemsToAdd.push(intElem);\n }\n // Found an element that was already selected, so we shouldn't remove it.\n const foundInd = elemsToRemove.indexOf(intElem);\n if (foundInd !== -1) {\n elemsToRemove.splice(foundInd, 1);\n }\n }\n\n if (elemsToRemove.length > 0) {\n canvas.removeFromSelection(elemsToRemove);\n }\n\n if (elemsToAdd.length > 0) {\n canvas.addToSelection(elemsToAdd);\n }\n\n break;\n } case 'resize': {\n // we track the resize bounding box and translate/scale the selected element\n // while the mouse is down, when mouse goes up, we use this to recalculate\n // the shape's coordinates\n tlist = getTransformList(selected);\n const hasMatrix = hasMatrixTransform(tlist);\n box = hasMatrix ? initBbox : utilsGetBBox(selected);\n let left = box.x,\n top = box.y,\n {width, height} = box;\n dx = (x - startX);\n dy = (y - startY);\n\n if (curConfig.gridSnapping) {\n dx = snapToGrid(dx);\n dy = snapToGrid(dy);\n height = snapToGrid(height);\n width = snapToGrid(width);\n }\n\n // if rotated, adjust the dx,dy values\n angle = getRotationAngle(selected);\n if (angle) {\n const r = Math.sqrt(dx * dx + dy * dy),\n theta = Math.atan2(dy, dx) - angle * Math.PI / 180.0;\n dx = r * Math.cos(theta);\n dy = r * Math.sin(theta);\n }\n\n // if not stretching in y direction, set dy to 0\n // if not stretching in x direction, set dx to 0\n if (!currentResizeMode.includes('n') && !currentResizeMode.includes('s')) {\n dy = 0;\n }\n if (!currentResizeMode.includes('e') && !currentResizeMode.includes('w')) {\n dx = 0;\n }\n\n let // ts = null,\n tx = 0, ty = 0,\n sy = height ? (height + dy) / height : 1,\n sx = width ? (width + dx) / width : 1;\n // if we are dragging on the north side, then adjust the scale factor and ty\n if (currentResizeMode.includes('n')) {\n sy = height ? (height - dy) / height : 1;\n ty = height;\n }\n\n // if we dragging on the east side, then adjust the scale factor and tx\n if (currentResizeMode.includes('w')) {\n sx = width ? (width - dx) / width : 1;\n tx = width;\n }\n\n // update the transform list with translate,scale,translate\n const translateOrigin = svgroot.createSVGTransform(),\n scale = svgroot.createSVGTransform(),\n translateBack = svgroot.createSVGTransform();\n\n if (curConfig.gridSnapping) {\n left = snapToGrid(left);\n tx = snapToGrid(tx);\n top = snapToGrid(top);\n ty = snapToGrid(ty);\n }\n\n translateOrigin.setTranslate(-(left + tx), -(top + ty));\n if (evt.shiftKey) {\n if (sx === 1) {\n sx = sy;\n } else { sy = sx; }\n }\n scale.setScale(sx, sy);\n\n translateBack.setTranslate(left + tx, top + ty);\n if (hasMatrix) {\n const diff = angle ? 1 : 0;\n tlist.replaceItem(translateOrigin, 2 + diff);\n tlist.replaceItem(scale, 1 + diff);\n tlist.replaceItem(translateBack, Number(diff));\n } else {\n const N = tlist.numberOfItems;\n tlist.replaceItem(translateBack, N - 3);\n tlist.replaceItem(scale, N - 2);\n tlist.replaceItem(translateOrigin, N - 1);\n }\n\n selectorManager.requestSelector(selected).resize();\n\n call('transition', selectedElements);\n\n break;\n } case 'zoom': {\n realX *= currentZoom;\n realY *= currentZoom;\n assignAttributes(rubberBox, {\n x: Math.min(rStartX * currentZoom, realX),\n y: Math.min(rStartY * currentZoom, realY),\n width: Math.abs(realX - rStartX * currentZoom),\n height: Math.abs(realY - rStartY * currentZoom)\n }, 100);\n break;\n } case 'text': {\n assignAttributes(shape, {\n x,\n y\n }, 1000);\n break;\n } case 'line': {\n if (curConfig.gridSnapping) {\n x = snapToGrid(x);\n y = snapToGrid(y);\n }\n\n let x2 = x;\n let y2 = y;\n\n if (evt.shiftKey) {\n xya = snapToAngle(startX, startY, x2, y2);\n x2 = xya.x;\n y2 = xya.y;\n }\n\n shape.setAttribute('x2', x2);\n shape.setAttribute('y2', y2);\n break;\n } case 'foreignObject':\n // fall through\n case 'square':\n // fall through\n case 'rect':\n // fall through\n case 'image': {\n const square = (currentMode === 'square') || evt.shiftKey;\n let\n w = Math.abs(x - startX),\n h = Math.abs(y - startY);\n let newX, newY;\n if (square) {\n w = h = Math.max(w, h);\n newX = startX < x ? startX : startX - w;\n newY = startY < y ? startY : startY - h;\n } else {\n newX = Math.min(startX, x);\n newY = Math.min(startY, y);\n }\n\n if (curConfig.gridSnapping) {\n w = snapToGrid(w);\n h = snapToGrid(h);\n newX = snapToGrid(newX);\n newY = snapToGrid(newY);\n }\n\n assignAttributes(shape, {\n width: w,\n height: h,\n x: newX,\n y: newY\n }, 1000);\n\n break;\n } case 'circle': {\n c = $(shape).attr(['cx', 'cy']);\n ({cx, cy} = c);\n let rad = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy));\n if (curConfig.gridSnapping) {\n rad = snapToGrid(rad);\n }\n shape.setAttribute('r', rad);\n break;\n } case 'ellipse': {\n c = $(shape).attr(['cx', 'cy']);\n ({cx, cy} = c);\n if (curConfig.gridSnapping) {\n x = snapToGrid(x);\n cx = snapToGrid(cx);\n y = snapToGrid(y);\n cy = snapToGrid(cy);\n }\n shape.setAttribute('rx', Math.abs(x - cx));\n const ry = Math.abs(evt.shiftKey ? (x - cx) : (y - cy));\n shape.setAttribute('ry', ry);\n break;\n }\n case 'fhellipse':\n case 'fhrect': {\n freehand.minx = Math.min(realX, freehand.minx);\n freehand.maxx = Math.max(realX, freehand.maxx);\n freehand.miny = Math.min(realY, freehand.miny);\n freehand.maxy = Math.max(realY, freehand.maxy);\n }\n // Fallthrough\n case 'fhpath': {\n // dAttr += + realX + ',' + realY + ' ';\n // shape.setAttribute('points', dAttr);\n end.x = realX; end.y = realY;\n if (controllPoint2.x && controllPoint2.y) {\n for (i = 0; i < STEP_COUNT - 1; i++) {\n parameter = i / STEP_COUNT;\n nextParameter = (i + 1) / STEP_COUNT;\n bSpline = getBsplinePoint(nextParameter);\n nextPos = bSpline;\n bSpline = getBsplinePoint(parameter);\n sumDistance += Math.sqrt((nextPos.x - bSpline.x) *\n (nextPos.x - bSpline.x) + (nextPos.y - bSpline.y) *\n (nextPos.y - bSpline.y));\n if (sumDistance > THRESHOLD_DIST) {\n sumDistance -= THRESHOLD_DIST;\n\n // Faster than completely re-writing the points attribute.\n const point = svgcontent.createSVGPoint();\n point.x = bSpline.x;\n point.y = bSpline.y;\n shape.points.appendItem(point);\n }\n }\n }\n controllPoint2 = {x: controllPoint1.x, y: controllPoint1.y};\n controllPoint1 = {x: start.x, y: start.y};\n start = {x: end.x, y: end.y};\n break;\n // update path stretch line coordinates\n } case 'path':\n // fall through\n case 'pathedit': {\n x *= currentZoom;\n y *= currentZoom;\n\n if (curConfig.gridSnapping) {\n x = snapToGrid(x);\n y = snapToGrid(y);\n startX = snapToGrid(startX);\n startY = snapToGrid(startY);\n }\n if (evt.shiftKey) {\n const {path} = pathModule;\n let x1, y1;\n if (path) {\n x1 = path.dragging ? path.dragging[0] : startX;\n y1 = path.dragging ? path.dragging[1] : startY;\n } else {\n x1 = startX;\n y1 = startY;\n }\n xya = snapToAngle(x1, y1, x, y);\n ({x, y} = xya);\n }\n\n if (rubberBox && rubberBox.getAttribute('display') !== 'none') {\n realX *= currentZoom;\n realY *= currentZoom;\n assignAttributes(rubberBox, {\n x: Math.min(rStartX * currentZoom, realX),\n y: Math.min(rStartY * currentZoom, realY),\n width: Math.abs(realX - rStartX * currentZoom),\n height: Math.abs(realY - rStartY * currentZoom)\n }, 100);\n }\n pathActions.mouseMove(x, y);\n\n break;\n } case 'textedit': {\n x *= currentZoom;\n y *= currentZoom;\n // if (rubberBox && rubberBox.getAttribute('display') !== 'none') {\n // assignAttributes(rubberBox, {\n // x: Math.min(startX, x),\n // y: Math.min(startY, y),\n // width: Math.abs(x - startX),\n // height: Math.abs(y - startY)\n // }, 100);\n // }\n\n textActions.mouseMove(mouseX, mouseY);\n\n break;\n } case 'rotate': {\n box = utilsGetBBox(selected);\n cx = box.x + box.width / 2;\n cy = box.y + box.height / 2;\n const m = getMatrix(selected),\n center = transformPoint(cx, cy, m);\n cx = center.x;\n cy = center.y;\n angle = ((Math.atan2(cy - y, cx - x) * (180 / Math.PI)) - 90) % 360;\n if (curConfig.gridSnapping) {\n angle = snapToGrid(angle);\n }\n if (evt.shiftKey) { // restrict rotations to nice angles (WRS)\n const snap = 45;\n angle = Math.round(angle / snap) * snap;\n }\n\n canvas.setRotationAngle(angle < -180 ? (360 + angle) : angle, true);\n call('transition', selectedElements);\n break;\n } default:\n break;\n }\n\n /**\n * The mouse has moved on the canvas area.\n * @event module:svgcanvas.SvgCanvas#event:ext_mouseMove\n * @type {PlainObject}\n * @property {MouseEvent} event The event object\n * @property {Float} mouse_x x coordinate on canvas\n * @property {Float} mouse_y y coordinate on canvas\n * @property {Element} selected Refers to the first selected element\n */\n runExtensions('mouseMove', /** @type {module:svgcanvas.SvgCanvas#event:ext_mouseMove} */ {\n event: evt,\n mouse_x: mouseX,\n mouse_y: mouseY,\n selected\n });\n }; // mouseMove()\n\n // - in create mode, the element's opacity is set properly, we create an InsertElementCommand\n // and store it on the Undo stack\n // - in move/resize mode, the element's attributes which were affected by the move/resize are\n // identified, a ChangeElementCommand is created and stored on the stack for those attrs\n // this is done in when we recalculate the selected dimensions()\n /**\n *\n * @param {MouseEvent} evt\n * @fires module:svgcanvas.SvgCanvas#event:zoomed\n * @fires module:svgcanvas.SvgCanvas#event:changed\n * @fires module:svgcanvas.SvgCanvas#event:ext_mouseUp\n * @returns {void}\n */\n const mouseUp = function (evt) {\n if (evt.button === 2) { return; }\n const tempJustSelected = justSelected;\n justSelected = null;\n if (!started) { return; }\n const pt = transformPoint(evt.pageX, evt.pageY, rootSctm),\n mouseX = pt.x * currentZoom,\n mouseY = pt.y * currentZoom,\n x = mouseX / currentZoom,\n y = mouseY / currentZoom;\n\n let element = getElem(getId());\n let keep = false;\n\n const realX = x;\n const realY = y;\n\n // TODO: Make true when in multi-unit mode\n const useUnit = false; // (curConfig.baseUnit !== 'px');\n started = false;\n let attrs, t;\n switch (currentMode) {\n // intentionally fall-through to select here\n case 'resize':\n case 'multiselect':\n if (!isNullish(rubberBox)) {\n rubberBox.setAttribute('display', 'none');\n curBBoxes = [];\n }\n currentMode = 'select';\n // Fallthrough\n case 'select':\n if (!isNullish(selectedElements[0])) {\n // if we only have one selected element\n if (isNullish(selectedElements[1])) {\n // set our current stroke/fill properties to the element's\n const selected = selectedElements[0];\n switch (selected.tagName) {\n case 'g':\n case 'use':\n case 'image':\n case 'foreignObject':\n break;\n default:\n curProperties.fill = selected.getAttribute('fill');\n curProperties.fill_opacity = selected.getAttribute('fill-opacity');\n curProperties.stroke = selected.getAttribute('stroke');\n curProperties.stroke_opacity = selected.getAttribute('stroke-opacity');\n curProperties.stroke_width = selected.getAttribute('stroke-width');\n curProperties.stroke_dasharray = selected.getAttribute('stroke-dasharray');\n curProperties.stroke_linejoin = selected.getAttribute('stroke-linejoin');\n curProperties.stroke_linecap = selected.getAttribute('stroke-linecap');\n }\n\n if (selected.tagName === 'text') {\n curText.font_size = selected.getAttribute('font-size');\n curText.font_family = selected.getAttribute('font-family');\n }\n selectorManager.requestSelector(selected).showGrips(true);\n\n // This shouldn't be necessary as it was done on mouseDown...\n // call('selected', [selected]);\n }\n // always recalculate dimensions to strip off stray identity transforms\n recalculateAllSelectedDimensions();\n // if it was being dragged/resized\n if (realX !== rStartX || realY !== rStartY) {\n const len = selectedElements.length;\n for (let i = 0; i < len; ++i) {\n if (isNullish(selectedElements[i])) { break; }\n if (!selectedElements[i].firstChild) {\n // Not needed for groups (incorrectly resizes elems), possibly not needed at all?\n selectorManager.requestSelector(selectedElements[i]).resize();\n }\n }\n // no change in position/size, so maybe we should move to pathedit\n } else {\n t = evt.target;\n if (selectedElements[0].nodeName === 'path' && isNullish(selectedElements[1])) {\n pathActions.select(selectedElements[0]);\n // if it was a path\n // else, if it was selected and this is a shift-click, remove it from selection\n } else if (evt.shiftKey) {\n if (tempJustSelected !== t) {\n canvas.removeFromSelection([t]);\n }\n }\n } // no change in mouse position\n\n // Remove non-scaling stroke\n if (supportsNonScalingStroke()) {\n const elem = selectedElements[0];\n if (elem) {\n elem.removeAttribute('style');\n walkTree(elem, function (el) {\n el.removeAttribute('style');\n });\n }\n }\n }\n return;\n case 'zoom': {\n if (!isNullish(rubberBox)) {\n rubberBox.setAttribute('display', 'none');\n }\n const factor = evt.shiftKey ? 0.5 : 2;\n call('zoomed', {\n x: Math.min(rStartX, realX),\n y: Math.min(rStartY, realY),\n width: Math.abs(realX - rStartX),\n height: Math.abs(realY - rStartY),\n factor\n });\n return;\n } case 'fhpath': {\n // Check that the path contains at least 2 points; a degenerate one-point path\n // causes problems.\n // Webkit ignores how we set the points attribute with commas and uses space\n // to separate all coordinates, see https://bugs.webkit.org/show_bug.cgi?id=29870\n sumDistance = 0;\n controllPoint2 = {x: 0, y: 0};\n controllPoint1 = {x: 0, y: 0};\n start = {x: 0, y: 0};\n end = {x: 0, y: 0};\n const coords = element.getAttribute('points');\n const commaIndex = coords.indexOf(',');\n if (commaIndex >= 0) {\n keep = coords.includes(',', commaIndex + 1);\n } else {\n keep = coords.includes(' ', coords.indexOf(' ') + 1);\n }\n if (keep) {\n element = pathActions.smoothPolylineIntoPath(element);\n }\n break;\n } case 'line':\n attrs = $(element).attr(['x1', 'x2', 'y1', 'y2']);\n keep = (attrs.x1 !== attrs.x2 || attrs.y1 !== attrs.y2);\n break;\n case 'foreignObject':\n case 'square':\n case 'rect':\n case 'image':\n attrs = $(element).attr(['width', 'height']);\n // Image should be kept regardless of size (use inherit dimensions later)\n keep = (attrs.width || attrs.height) || currentMode === 'image';\n break;\n case 'circle':\n keep = (element.getAttribute('r') !== '0');\n break;\n case 'ellipse':\n attrs = $(element).attr(['rx', 'ry']);\n keep = (attrs.rx || attrs.ry);\n break;\n case 'fhellipse':\n if ((freehand.maxx - freehand.minx) > 0 &&\n (freehand.maxy - freehand.miny) > 0) {\n element = addSVGElementFromJson({\n element: 'ellipse',\n curStyles: true,\n attr: {\n cx: (freehand.minx + freehand.maxx) / 2,\n cy: (freehand.miny + freehand.maxy) / 2,\n rx: (freehand.maxx - freehand.minx) / 2,\n ry: (freehand.maxy - freehand.miny) / 2,\n id: getId()\n }\n });\n call('changed', [element]);\n keep = true;\n }\n break;\n case 'fhrect':\n if ((freehand.maxx - freehand.minx) > 0 &&\n (freehand.maxy - freehand.miny) > 0) {\n element = addSVGElementFromJson({\n element: 'rect',\n curStyles: true,\n attr: {\n x: freehand.minx,\n y: freehand.miny,\n width: (freehand.maxx - freehand.minx),\n height: (freehand.maxy - freehand.miny),\n id: getId()\n }\n });\n call('changed', [element]);\n keep = true;\n }\n break;\n case 'text':\n keep = true;\n selectOnly([element]);\n textActions.start(element);\n break;\n case 'path': {\n // set element to null here so that it is not removed nor finalized\n element = null;\n // continue to be set to true so that mouseMove happens\n started = true;\n\n const res = pathActions.mouseUp(evt, element, mouseX, mouseY);\n ({element} = res);\n ({keep} = res);\n break;\n } case 'pathedit':\n keep = true;\n element = null;\n pathActions.mouseUp(evt);\n break;\n case 'textedit':\n keep = false;\n element = null;\n textActions.mouseUp(evt, mouseX, mouseY);\n break;\n case 'rotate': {\n keep = true;\n element = null;\n currentMode = 'select';\n const batchCmd = canvas.undoMgr.finishUndoableChange();\n if (!batchCmd.isEmpty()) {\n addCommandToHistory(batchCmd);\n }\n // perform recalculation to weed out any stray identity transforms that might get stuck\n recalculateAllSelectedDimensions();\n call('changed', selectedElements);\n break;\n } default:\n // This could occur in an extension\n break;\n }\n\n /**\n * The main (left) mouse button is released (anywhere).\n * @event module:svgcanvas.SvgCanvas#event:ext_mouseUp\n * @type {PlainObject}\n * @property {MouseEvent} event The event object\n * @property {Float} mouse_x x coordinate on canvas\n * @property {Float} mouse_y y coordinate on canvas\n */\n const extResult = runExtensions('mouseUp', /** @type {module:svgcanvas.SvgCanvas#event:ext_mouseUp} */ {\n event: evt,\n mouse_x: mouseX,\n mouse_y: mouseY\n }, true);\n\n $.each(extResult, function (i, r) {\n if (r) {\n keep = r.keep || keep;\n ({element} = r);\n started = r.started || started;\n }\n });\n\n if (!keep && !isNullish(element)) {\n getCurrentDrawing().releaseId(getId());\n element.remove();\n element = null;\n\n t = evt.target;\n\n // if this element is in a group, go up until we reach the top-level group\n // just below the layer groups\n // TODO: once we implement links, we also would have to check for <a> elements\n while (t && t.parentNode && t.parentNode.parentNode && t.parentNode.parentNode.tagName === 'g') {\n t = t.parentNode;\n }\n // if we are not in the middle of creating a path, and we've clicked on some shape,\n // then go to Select mode.\n // WebKit returns <div> when the canvas is clicked, Firefox/Opera return <svg>\n if ((currentMode !== 'path' || !drawnPath) &&\n t && t.parentNode &&\n t.parentNode.id !== 'selectorParentGroup' &&\n t.id !== 'svgcanvas' && t.id !== 'svgroot'\n ) {\n // switch into \"select\" mode if we've clicked on an element\n canvas.setMode('select');\n selectOnly([t], true);\n }\n } else if (!isNullish(element)) {\n /**\n * @name module:svgcanvas.SvgCanvas#addedNew\n * @type {boolean}\n */\n canvas.addedNew = true;\n\n if (useUnit) { convertAttrs(element); }\n\n let aniDur = 0.2;\n let cAni;\n if (opacAni.beginElement && Number.parseFloat(element.getAttribute('opacity')) !== curShape.opacity) {\n cAni = $(opacAni).clone().attr({\n to: curShape.opacity,\n dur: aniDur\n }).appendTo(element);\n try {\n // Fails in FF4 on foreignObject\n cAni[0].beginElement();\n } catch (e) {}\n } else {\n aniDur = 0;\n }\n\n // Ideally this would be done on the endEvent of the animation,\n // but that doesn't seem to be supported in Webkit\n setTimeout(function () {\n if (cAni) { cAni.remove(); }\n element.setAttribute('opacity', curShape.opacity);\n element.setAttribute('style', 'pointer-events:inherit');\n cleanupElement(element);\n if (currentMode === 'path') {\n pathActions.toEditMode(element);\n } else if (curConfig.selectNew) {\n selectOnly([element], true);\n }\n // we create the insert command that is stored on the stack\n // undo means to call cmd.unapply(), redo means to call cmd.apply()\n addCommandToHistory(new InsertElementCommand(element));\n\n call('changed', [element]);\n }, aniDur * 1000);\n }\n\n startTransform = null;\n };\n\n const dblClick = function (evt) {\n const evtTarget = evt.target;\n const parent = evtTarget.parentNode;\n\n let mouseTarget = getMouseTarget(evt);\n const {tagName} = mouseTarget;\n\n if (tagName === 'text' && currentMode !== 'textedit') {\n const pt = transformPoint(evt.pageX, evt.pageY, rootSctm);\n textActions.select(mouseTarget, pt.x, pt.y);\n }\n\n // Do nothing if already in current group\n if (parent === currentGroup) { return; }\n\n if ((tagName === 'g' || tagName === 'a') &&\n getRotationAngle(mouseTarget)\n ) {\n // TODO: Allow method of in-group editing without having to do\n // this (similar to editing rotated paths)\n\n // Ungroup and regroup\n pushGroupProperties(mouseTarget);\n mouseTarget = selectedElements[0];\n clearSelection(true);\n }\n // Reset context\n if (currentGroup) {\n draw.leaveContext();\n }\n\n if ((parent.tagName !== 'g' && parent.tagName !== 'a') ||\n parent === getCurrentDrawing().getCurrentLayer() ||\n mouseTarget === selectorManager.selectorParentGroup\n ) {\n // Escape from in-group edit\n return;\n }\n draw.setContext(mouseTarget);\n };\n\n // prevent links from being followed in the canvas\n const handleLinkInCanvas = function (e) {\n e.preventDefault();\n return false;\n };\n\n // Added mouseup to the container here.\n // TODO(codedread): Figure out why after the Closure compiler, the window mouseup is ignored.\n $(container).mousedown(mouseDown).mousemove(mouseMove).click(handleLinkInCanvas).dblclick(dblClick).mouseup(mouseUp);\n // $(window).mouseup(mouseUp);\n\n // TODO(rafaelcastrocouto): User preference for shift key and zoom factor\n $(container).bind(\n 'mousewheel DOMMouseScroll',\n /**\n * @param {Event} e\n * @fires module:svgcanvas.SvgCanvas#event:updateCanvas\n * @fires module:svgcanvas.SvgCanvas#event:zoomDone\n * @returns {void}\n */\n function (e) {\n if (!e.shiftKey) { return; }\n\n e.preventDefault();\n const evt = e.originalEvent;\n\n rootSctm = $('#svgcontent g')[0].getScreenCTM().inverse();\n\n const workarea = $('#workarea');\n const scrbar = 15;\n const rulerwidth = curConfig.showRulers ? 16 : 0;\n\n // mouse relative to content area in content pixels\n const pt = transformPoint(evt.pageX, evt.pageY, rootSctm);\n\n // full work area width in screen pixels\n const editorFullW = workarea.width();\n const editorFullH = workarea.height();\n\n // work area width minus scroll and ruler in screen pixels\n const editorW = editorFullW - scrbar - rulerwidth;\n const editorH = editorFullH - scrbar - rulerwidth;\n\n // work area width in content pixels\n const workareaViewW = editorW * rootSctm.a;\n const workareaViewH = editorH * rootSctm.d;\n\n // content offset from canvas in screen pixels\n const wOffset = workarea.offset();\n const wOffsetLeft = wOffset.left + rulerwidth;\n const wOffsetTop = wOffset.top + rulerwidth;\n\n const delta = (evt.wheelDelta) ? evt.wheelDelta : (evt.detail) ? -evt.detail : 0;\n if (!delta) { return; }\n\n let factor = Math.max(3 / 4, Math.min(4 / 3, (delta)));\n\n let wZoom, hZoom;\n if (factor > 1) {\n wZoom = Math.ceil(editorW / workareaViewW * factor * 100) / 100;\n hZoom = Math.ceil(editorH / workareaViewH * factor * 100) / 100;\n } else {\n wZoom = Math.floor(editorW / workareaViewW * factor * 100) / 100;\n hZoom = Math.floor(editorH / workareaViewH * factor * 100) / 100;\n }\n let zoomlevel = Math.min(wZoom, hZoom);\n zoomlevel = Math.min(10, Math.max(0.01, zoomlevel));\n if (zoomlevel === currentZoom) {\n return;\n }\n factor = zoomlevel / currentZoom;\n\n // top left of workarea in content pixels before zoom\n const topLeftOld = transformPoint(wOffsetLeft, wOffsetTop, rootSctm);\n\n // top left of workarea in content pixels after zoom\n const topLeftNew = {\n x: pt.x - (pt.x - topLeftOld.x) / factor,\n y: pt.y - (pt.y - topLeftOld.y) / factor\n };\n\n // top left of workarea in canvas pixels relative to content after zoom\n const topLeftNewCanvas = {\n x: topLeftNew.x * zoomlevel,\n y: topLeftNew.y * zoomlevel\n };\n\n // new center in canvas pixels\n const newCtr = {\n x: topLeftNewCanvas.x - rulerwidth + editorFullW / 2,\n y: topLeftNewCanvas.y - rulerwidth + editorFullH / 2\n };\n\n canvas.setZoom(zoomlevel);\n $('#zoom').val((zoomlevel * 100).toFixed(1));\n\n call('updateCanvas', {center: false, newCtr});\n call('zoomDone');\n }\n );\n }());\n\n /* eslint-disable jsdoc/require-property */\n /**\n* Group: Text edit functions\n* Functions relating to editing text elements.\n* @namespace {PlainObject} textActions\n* @memberof module:svgcanvas.SvgCanvas#\n*/\n const textActions = canvas.textActions = (function () {\n /* eslint-enable jsdoc/require-property */\n let curtext;\n let textinput;\n let cursor;\n let selblock;\n let blinker;\n let chardata = [];\n let textbb; // , transbb;\n let matrix;\n let lastX, lastY;\n let allowDbl;\n\n /**\n *\n * @param {Integer} index\n * @returns {void}\n */\n function setCursor (index) {\n const empty = (textinput.value === '');\n $(textinput).focus();\n\n if (!arguments.length) {\n if (empty) {\n index = 0;\n } else {\n if (textinput.selectionEnd !== textinput.selectionStart) { return; }\n index = textinput.selectionEnd;\n }\n }\n\n const charbb = chardata[index];\n if (!empty) {\n textinput.setSelectionRange(index, index);\n }\n cursor = getElem('text_cursor');\n if (!cursor) {\n cursor = document.createElementNS(NS.SVG, 'line');\n assignAttributes(cursor, {\n id: 'text_cursor',\n stroke: '#333',\n 'stroke-width': 1\n });\n cursor = getElem('selectorParentGroup').appendChild(cursor);\n }\n\n if (!blinker) {\n blinker = setInterval(function () {\n const show = (cursor.getAttribute('display') === 'none');\n cursor.setAttribute('display', show ? 'inline' : 'none');\n }, 600);\n }\n\n const startPt = ptToScreen(charbb.x, textbb.y);\n const endPt = ptToScreen(charbb.x, (textbb.y + textbb.height));\n\n assignAttributes(cursor, {\n x1: startPt.x,\n y1: startPt.y,\n x2: endPt.x,\n y2: endPt.y,\n visibility: 'visible',\n display: 'inline'\n });\n\n if (selblock) { selblock.setAttribute('d', ''); }\n }\n\n /**\n *\n * @param {Integer} start\n * @param {Integer} end\n * @param {boolean} skipInput\n * @returns {void}\n */\n function setSelection (start, end, skipInput) {\n if (start === end) {\n setCursor(end);\n return;\n }\n\n if (!skipInput) {\n textinput.setSelectionRange(start, end);\n }\n\n selblock = getElem('text_selectblock');\n if (!selblock) {\n selblock = document.createElementNS(NS.SVG, 'path');\n assignAttributes(selblock, {\n id: 'text_selectblock',\n fill: 'green',\n opacity: 0.5,\n style: 'pointer-events:none'\n });\n getElem('selectorParentGroup').append(selblock);\n }\n\n const startbb = chardata[start];\n const endbb = chardata[end];\n\n cursor.setAttribute('visibility', 'hidden');\n\n const tl = ptToScreen(startbb.x, textbb.y),\n tr = ptToScreen(startbb.x + (endbb.x - startbb.x), textbb.y),\n bl = ptToScreen(startbb.x, textbb.y + textbb.height),\n br = ptToScreen(startbb.x + (endbb.x - startbb.x), textbb.y + textbb.height);\n\n const dstr = 'M' + tl.x + ',' + tl.y +\n ' L' + tr.x + ',' + tr.y +\n ' ' + br.x + ',' + br.y +\n ' ' + bl.x + ',' + bl.y + 'z';\n\n assignAttributes(selblock, {\n d: dstr,\n display: 'inline'\n });\n }\n\n /**\n *\n * @param {Float} mouseX\n * @param {Float} mouseY\n * @returns {Integer}\n */\n function getIndexFromPoint (mouseX, mouseY) {\n // Position cursor here\n const pt = svgroot.createSVGPoint();\n pt.x = mouseX;\n pt.y = mouseY;\n\n // No content, so return 0\n if (chardata.length === 1) { return 0; }\n // Determine if cursor should be on left or right of character\n let charpos = curtext.getCharNumAtPosition(pt);\n if (charpos < 0) {\n // Out of text range, look at mouse coords\n charpos = chardata.length - 2;\n if (mouseX <= chardata[0].x) {\n charpos = 0;\n }\n } else if (charpos >= chardata.length - 2) {\n charpos = chardata.length - 2;\n }\n const charbb = chardata[charpos];\n const mid = charbb.x + (charbb.width / 2);\n if (mouseX > mid) {\n charpos++;\n }\n return charpos;\n }\n\n /**\n *\n * @param {Float} mouseX\n * @param {Float} mouseY\n * @returns {void}\n */\n function setCursorFromPoint (mouseX, mouseY) {\n setCursor(getIndexFromPoint(mouseX, mouseY));\n }\n\n /**\n *\n * @param {Float} x\n * @param {Float} y\n * @param {boolean} apply\n * @returns {void}\n */\n function setEndSelectionFromPoint (x, y, apply) {\n const i1 = textinput.selectionStart;\n const i2 = getIndexFromPoint(x, y);\n\n const start = Math.min(i1, i2);\n const end = Math.max(i1, i2);\n setSelection(start, end, !apply);\n }\n\n /**\n *\n * @param {Float} xIn\n * @param {Float} yIn\n * @returns {module:math.XYObject}\n */\n function screenToPt (xIn, yIn) {\n const out = {\n x: xIn,\n y: yIn\n };\n\n out.x /= currentZoom;\n out.y /= currentZoom;\n\n if (matrix) {\n const pt = transformPoint(out.x, out.y, matrix.inverse());\n out.x = pt.x;\n out.y = pt.y;\n }\n\n return out;\n }\n\n /**\n *\n * @param {Float} xIn\n * @param {Float} yIn\n * @returns {module:math.XYObject}\n */\n function ptToScreen (xIn, yIn) {\n const out = {\n x: xIn,\n y: yIn\n };\n\n if (matrix) {\n const pt = transformPoint(out.x, out.y, matrix);\n out.x = pt.x;\n out.y = pt.y;\n }\n\n out.x *= currentZoom;\n out.y *= currentZoom;\n\n return out;\n }\n\n /*\n// Not currently in use\nfunction hideCursor () {\n if (cursor) {\n cursor.setAttribute('visibility', 'hidden');\n }\n}\n*/\n\n /**\n *\n * @param {Event} evt\n * @returns {void}\n */\n function selectAll (evt) {\n setSelection(0, curtext.textContent.length);\n $(this).unbind(evt);\n }\n\n /**\n *\n * @param {Event} evt\n * @returns {void}\n */\n function selectWord (evt) {\n if (!allowDbl || !curtext) { return; }\n\n const ept = transformPoint(evt.pageX, evt.pageY, rootSctm),\n mouseX = ept.x * currentZoom,\n mouseY = ept.y * currentZoom;\n const pt = screenToPt(mouseX, mouseY);\n\n const index = getIndexFromPoint(pt.x, pt.y);\n const str = curtext.textContent;\n const first = str.substr(0, index).replace(/[a-z\\d]+$/i, '').length;\n const m = str.substr(index).match(/^[a-z\\d]+/i);\n const last = (m ? m[0].length : 0) + index;\n setSelection(first, last);\n\n // Set tripleclick\n $(evt.target).click(selectAll);\n setTimeout(function () {\n $(evt.target).unbind('click', selectAll);\n }, 300);\n }\n\n return /** @lends module:svgcanvas.SvgCanvas#textActions */ {\n /**\n * @param {Element} target\n * @param {Float} x\n * @param {Float} y\n * @returns {void}\n */\n select (target, x, y) {\n curtext = target;\n textActions.toEditMode(x, y);\n },\n /**\n * @param {Element} elem\n * @returns {void}\n */\n start (elem) {\n curtext = elem;\n textActions.toEditMode();\n },\n /**\n * @param {external:MouseEvent} evt\n * @param {Element} mouseTarget\n * @param {Float} startX\n * @param {Float} startY\n * @returns {void}\n */\n mouseDown (evt, mouseTarget, startX, startY) {\n const pt = screenToPt(startX, startY);\n\n textinput.focus();\n setCursorFromPoint(pt.x, pt.y);\n lastX = startX;\n lastY = startY;\n\n // TODO: Find way to block native selection\n },\n /**\n * @param {Float} mouseX\n * @param {Float} mouseY\n * @returns {void}\n */\n mouseMove (mouseX, mouseY) {\n const pt = screenToPt(mouseX, mouseY);\n setEndSelectionFromPoint(pt.x, pt.y);\n },\n /**\n * @param {external:MouseEvent} evt\n * @param {Float} mouseX\n * @param {Float} mouseY\n * @returns {void}\n */\n mouseUp (evt, mouseX, mouseY) {\n const pt = screenToPt(mouseX, mouseY);\n\n setEndSelectionFromPoint(pt.x, pt.y, true);\n\n // TODO: Find a way to make this work: Use transformed BBox instead of evt.target\n // if (lastX === mouseX && lastY === mouseY\n // && !rectsIntersect(transbb, {x: pt.x, y: pt.y, width: 0, height: 0})) {\n // textActions.toSelectMode(true);\n // }\n\n if (\n evt.target !== curtext &&\n mouseX < lastX + 2 &&\n mouseX > lastX - 2 &&\n mouseY < lastY + 2 &&\n mouseY > lastY - 2\n ) {\n textActions.toSelectMode(true);\n }\n },\n /**\n * @function\n * @param {Integer} index\n * @returns {void}\n */\n setCursor,\n /**\n * @param {Float} x\n * @param {Float} y\n * @returns {void}\n */\n toEditMode (x, y) {\n allowDbl = false;\n currentMode = 'textedit';\n selectorManager.requestSelector(curtext).showGrips(false);\n // Make selector group accept clicks\n /* const selector = */ selectorManager.requestSelector(curtext); // Do we need this? Has side effect of setting lock, so keeping for now, but next line wasn't being used\n // const sel = selector.selectorRect;\n\n textActions.init();\n\n $(curtext).css('cursor', 'text');\n\n // if (supportsEditableText()) {\n // curtext.setAttribute('editable', 'simple');\n // return;\n // }\n\n if (!arguments.length) {\n setCursor();\n } else {\n const pt = screenToPt(x, y);\n setCursorFromPoint(pt.x, pt.y);\n }\n\n setTimeout(function () {\n allowDbl = true;\n }, 300);\n },\n /**\n * @param {boolean|Element} selectElem\n * @fires module:svgcanvas.SvgCanvas#event:selected\n * @returns {void}\n */\n toSelectMode (selectElem) {\n currentMode = 'select';\n clearInterval(blinker);\n blinker = null;\n if (selblock) { $(selblock).attr('display', 'none'); }\n if (cursor) { $(cursor).attr('visibility', 'hidden'); }\n $(curtext).css('cursor', 'move');\n\n if (selectElem) {\n clearSelection();\n $(curtext).css('cursor', 'move');\n\n call('selected', [curtext]);\n addToSelection([curtext], true);\n }\n if (curtext && !curtext.textContent.length) {\n // No content, so delete\n canvas.deleteSelectedElements();\n }\n\n $(textinput).blur();\n\n curtext = false;\n\n // if (supportsEditableText()) {\n // curtext.removeAttribute('editable');\n // }\n },\n /**\n * @param {Element} elem\n * @returns {void}\n */\n setInputElem (elem) {\n textinput = elem;\n // $(textinput).blur(hideCursor);\n },\n /**\n * @returns {void}\n */\n clear () {\n if (currentMode === 'textedit') {\n textActions.toSelectMode();\n }\n },\n /**\n * @param {Element} inputElem Not in use\n * @returns {void}\n */\n init (inputElem) {\n if (!curtext) { return; }\n let i, end;\n // if (supportsEditableText()) {\n // curtext.select();\n // return;\n // }\n\n if (!curtext.parentNode) {\n // Result of the ffClone, need to get correct element\n curtext = selectedElements[0];\n selectorManager.requestSelector(curtext).showGrips(false);\n }\n\n const str = curtext.textContent;\n const len = str.length;\n\n const xform = curtext.getAttribute('transform');\n\n textbb = utilsGetBBox(curtext);\n\n matrix = xform ? getMatrix(curtext) : null;\n\n chardata = [];\n chardata.length = len;\n textinput.focus();\n\n $(curtext).unbind('dblclick', selectWord).dblclick(selectWord);\n\n if (!len) {\n end = {x: textbb.x + (textbb.width / 2), width: 0};\n }\n\n for (i = 0; i < len; i++) {\n const start = curtext.getStartPositionOfChar(i);\n end = curtext.getEndPositionOfChar(i);\n\n if (!supportsGoodTextCharPos()) {\n const offset = canvas.contentW * currentZoom;\n start.x -= offset;\n end.x -= offset;\n\n start.x /= currentZoom;\n end.x /= currentZoom;\n }\n\n // Get a \"bbox\" equivalent for each character. Uses the\n // bbox data of the actual text for y, height purposes\n\n // TODO: Decide if y, width and height are actually necessary\n chardata[i] = {\n x: start.x,\n y: textbb.y, // start.y?\n width: end.x - start.x,\n height: textbb.height\n };\n }\n\n // Add a last bbox for cursor at end of text\n chardata.push({\n x: end.x,\n width: 0\n });\n setSelection(textinput.selectionStart, textinput.selectionEnd, true);\n }\n };\n }());\n\n /**\n* Group: Serialization.\n*/\n\n /**\n* Looks at DOM elements inside the `<defs>` to see if they are referred to,\n* removes them from the DOM if they are not.\n* @function module:svgcanvas.SvgCanvas#removeUnusedDefElems\n* @returns {Integer} The number of elements that were removed\n*/\n const removeUnusedDefElems = this.removeUnusedDefElems = function () {\n const defs = svgcontent.getElementsByTagNameNS(NS.SVG, 'defs');\n if (!defs || !defs.length) { return 0; }\n\n // if (!defs.firstChild) { return; }\n\n const defelemUses = [];\n let numRemoved = 0;\n const attrs = ['fill', 'stroke', 'filter', 'marker-start', 'marker-mid', 'marker-end'];\n const alen = attrs.length;\n\n const allEls = svgcontent.getElementsByTagNameNS(NS.SVG, '*');\n const allLen = allEls.length;\n\n let i, j;\n for (i = 0; i < allLen; i++) {\n const el = allEls[i];\n for (j = 0; j < alen; j++) {\n const ref = getUrlFromAttr(el.getAttribute(attrs[j]));\n if (ref) {\n defelemUses.push(ref.substr(1));\n }\n }\n\n // gradients can refer to other gradients\n const href = getHref(el);\n if (href && href.startsWith('#')) {\n defelemUses.push(href.substr(1));\n }\n }\n\n const defelems = $(defs).find('linearGradient, radialGradient, filter, marker, svg, symbol');\n i = defelems.length;\n while (i--) {\n const defelem = defelems[i];\n const {id} = defelem;\n if (!defelemUses.includes(id)) {\n // Not found, so remove (but remember)\n removedElements[id] = defelem;\n defelem.remove();\n numRemoved++;\n }\n }\n\n return numRemoved;\n };\n\n /**\n* Main function to set up the SVG content for output.\n* @function module:svgcanvas.SvgCanvas#svgCanvasToString\n* @returns {string} The SVG image for output\n*/\n this.svgCanvasToString = function () {\n // keep calling it until there are none to remove\n while (removeUnusedDefElems() > 0) {} // eslint-disable-line no-empty\n\n pathActions.clear(true);\n\n // Keep SVG-Edit comment on top\n $.each(svgcontent.childNodes, function (i, node) {\n if (i && node.nodeType === 8 && node.data.includes('Created with')) {\n svgcontent.firstChild.before(node);\n }\n });\n\n // Move out of in-group editing mode\n if (currentGroup) {\n draw.leaveContext();\n selectOnly([currentGroup]);\n }\n\n const nakedSvgs = [];\n\n // Unwrap gsvg if it has no special attributes (only id and style)\n $(svgcontent).find('g:data(gsvg)').each(function () {\n const attrs = this.attributes;\n let len = attrs.length;\n for (let i = 0; i < len; i++) {\n if (attrs[i].nodeName === 'id' || attrs[i].nodeName === 'style') {\n len--;\n }\n }\n // No significant attributes, so ungroup\n if (len <= 0) {\n const svg = this.firstChild;\n nakedSvgs.push(svg);\n $(this).replaceWith(svg);\n }\n });\n const output = this.svgToString(svgcontent, 0);\n\n // Rewrap gsvg\n if (nakedSvgs.length) {\n $(nakedSvgs).each(function () {\n groupSvgElem(this);\n });\n }\n\n return output;\n };\n\n /**\n* Sub function ran on each SVG element to convert it to a string as desired.\n* @function module:svgcanvas.SvgCanvas#svgToString\n* @param {Element} elem - The SVG element to convert\n* @param {Integer} indent - Number of spaces to indent this tag\n* @returns {string} The given element as an SVG tag\n*/\n this.svgToString = function (elem, indent) {\n const out = [];\n const unit = curConfig.baseUnit;\n const unitRe = new RegExp('^-?[\\\\d\\\\.]+' + unit + '$');\n\n if (elem) {\n cleanupElement(elem);\n const attrs = [...elem.attributes];\n const childs = elem.childNodes;\n attrs.sort((a, b) => {\n return a.name > b.name ? -1 : 1;\n });\n\n for (let i = 0; i < indent; i++) { out.push(' '); }\n out.push('<'); out.push(elem.nodeName);\n if (elem.id === 'svgcontent') {\n // Process root element separately\n const res = getResolution();\n\n const vb = '';\n // TODO: Allow this by dividing all values by current baseVal\n // Note that this also means we should properly deal with this on import\n // if (curConfig.baseUnit !== 'px') {\n // const unit = curConfig.baseUnit;\n // const unitM = getTypeMap()[unit];\n // res.w = shortFloat(res.w / unitM);\n // res.h = shortFloat(res.h / unitM);\n // vb = ' viewBox=\"' + [0, 0, res.w, res.h].join(' ') + '\"';\n // res.w += unit;\n // res.h += unit;\n // }\n\n if (unit !== 'px') {\n res.w = convertUnit(res.w, unit) + unit;\n res.h = convertUnit(res.h, unit) + unit;\n }\n\n out.push(' width=\"' + res.w + '\" height=\"' + res.h + '\"' + vb + ' xmlns=\"' + NS.SVG + '\"');\n\n const nsuris = {};\n\n // Check elements for namespaces, add if found\n $(elem).find('*').andSelf().each(function () {\n // const el = this;\n // for some elements have no attribute\n const uri = this.namespaceURI;\n if (uri && !nsuris[uri] && nsMap[uri] && nsMap[uri] !== 'xmlns' && nsMap[uri] !== 'xml') {\n nsuris[uri] = true;\n out.push(' xmlns:' + nsMap[uri] + '=\"' + uri + '\"');\n }\n\n $.each(this.attributes, function (i, attr) {\n const u = attr.namespaceURI;\n if (u && !nsuris[u] && nsMap[u] !== 'xmlns' && nsMap[u] !== 'xml') {\n nsuris[u] = true;\n out.push(' xmlns:' + nsMap[u] + '=\"' + u + '\"');\n }\n });\n });\n\n let i = attrs.length;\n const attrNames = ['width', 'height', 'xmlns', 'x', 'y', 'viewBox', 'id', 'overflow'];\n while (i--) {\n const attr = attrs[i];\n const attrVal = toXml(attr.value);\n\n // Namespaces have already been dealt with, so skip\n if (attr.nodeName.startsWith('xmlns:')) { continue; }\n\n // only serialize attributes we don't use internally\n if (attrVal !== '' && !attrNames.includes(attr.localName)) {\n if (!attr.namespaceURI || nsMap[attr.namespaceURI]) {\n out.push(' ');\n out.push(attr.nodeName); out.push('=\"');\n out.push(attrVal); out.push('\"');\n }\n }\n }\n } else {\n // Skip empty defs\n if (elem.nodeName === 'defs' && !elem.firstChild) { return ''; }\n\n const mozAttrs = ['-moz-math-font-style', '_moz-math-font-style'];\n for (let i = attrs.length - 1; i >= 0; i--) {\n const attr = attrs[i];\n let attrVal = toXml(attr.value);\n // remove bogus attributes added by Gecko\n if (mozAttrs.includes(attr.localName)) { continue; }\n if (attrVal === 'null') {\n const styleName = attr.localName.replace(/-[a-z]/g, (s) => s[1].toUpperCase());\n if (Object.prototype.hasOwnProperty.call(elem.style, styleName)) { continue; }\n }\n if (attrVal !== '') {\n if (attrVal.startsWith('pointer-events')) { continue; }\n if (attr.localName === 'class' && attrVal.startsWith('se_')) { continue; }\n out.push(' ');\n if (attr.localName === 'd') { attrVal = pathActions.convertPath(elem, true); }\n if (!isNaN(attrVal)) {\n attrVal = shortFloat(attrVal);\n } else if (unitRe.test(attrVal)) {\n attrVal = shortFloat(attrVal) + unit;\n }\n\n // Embed images when saving\n if (saveOptions.apply &&\n elem.nodeName === 'image' &&\n attr.localName === 'href' &&\n saveOptions.images &&\n saveOptions.images === 'embed'\n ) {\n const img = encodableImages[attrVal];\n if (img) { attrVal = img; }\n }\n\n // map various namespaces to our fixed namespace prefixes\n // (the default xmlns attribute itself does not get a prefix)\n if (!attr.namespaceURI || attr.namespaceURI === NS.SVG || nsMap[attr.namespaceURI]) {\n out.push(attr.nodeName); out.push('=\"');\n out.push(attrVal); out.push('\"');\n }\n }\n }\n }\n\n if (elem.hasChildNodes()) {\n out.push('>');\n indent++;\n let bOneLine = false;\n\n for (let i = 0; i < childs.length; i++) {\n const child = childs.item(i);\n switch (child.nodeType) {\n case 1: // element node\n out.push('\\n');\n out.push(this.svgToString(child, indent));\n break;\n case 3: { // text node\n const str = child.nodeValue.replace(/^\\s+|\\s+$/g, '');\n if (str !== '') {\n bOneLine = true;\n out.push(String(toXml(str)));\n }\n break;\n } case 4: // cdata node\n out.push('\\n');\n out.push(new Array(indent + 1).join(' '));\n out.push('<![CDATA[');\n out.push(child.nodeValue);\n out.push(']]>');\n break;\n case 8: // comment\n out.push('\\n');\n out.push(new Array(indent + 1).join(' '));\n out.push('<!--');\n out.push(child.data);\n out.push('-->');\n break;\n } // switch on node type\n }\n indent--;\n if (!bOneLine) {\n out.push('\\n');\n for (let i = 0; i < indent; i++) { out.push(' '); }\n }\n out.push('</'); out.push(elem.nodeName); out.push('>');\n } else {\n out.push('/>');\n }\n }\n return out.join('');\n }; // end svgToString()\n\n /**\n * Function to run when image data is found.\n * @callback module:svgcanvas.ImageEmbeddedCallback\n * @param {string|false} result Data URL\n * @returns {void}\n */\n /**\n* Converts a given image file to a data URL when possible, then runs a given callback.\n* @function module:svgcanvas.SvgCanvas#embedImage\n* @param {string} src - The path/URL of the image\n* @returns {Promise<string|false>} Resolves to a Data URL (string|false)\n*/\n this.embedImage = function (src) {\n // Todo: Remove this Promise in favor of making an async/await `Image.load` utility\n // eslint-disable-next-line promise/avoid-new\n return new Promise(function (resolve, reject) {\n // load in the image and once it's loaded, get the dimensions\n $(new Image()).load(function (response, status, xhr) {\n if (status === 'error') {\n reject(new Error('Error loading image: ' + xhr.status + ' ' + xhr.statusText));\n return;\n }\n // create a canvas the same size as the raster image\n const cvs = document.createElement('canvas');\n cvs.width = this.width;\n cvs.height = this.height;\n // load the raster image into the canvas\n cvs.getContext('2d').drawImage(this, 0, 0);\n // retrieve the data: URL\n try {\n let urldata = ';svgedit_url=' + encodeURIComponent(src);\n urldata = cvs.toDataURL().replace(';base64', urldata + ';base64');\n encodableImages[src] = urldata;\n } catch (e) {\n encodableImages[src] = false;\n }\n lastGoodImgUrl = src;\n resolve(encodableImages[src]);\n }).attr('src', src);\n });\n };\n\n /**\n* Sets a given URL to be a \"last good image\" URL.\n* @function module:svgcanvas.SvgCanvas#setGoodImage\n* @param {string} val\n* @returns {void}\n*/\n this.setGoodImage = function (val) {\n lastGoodImgUrl = val;\n };\n\n /**\n* Does nothing by default, handled by optional widget/extension.\n* @function module:svgcanvas.SvgCanvas#open\n* @returns {void}\n*/\n this.open = function () {\n /* */\n };\n\n /**\n* Serializes the current drawing into SVG XML text and passes it to the 'saved' handler.\n* This function also includes the XML prolog. Clients of the `SvgCanvas` bind their save\n* function to the 'saved' event.\n* @function module:svgcanvas.SvgCanvas#save\n* @param {module:svgcanvas.SaveOptions} opts\n* @fires module:svgcanvas.SvgCanvas#event:saved\n* @returns {void}\n*/\n this.save = function (opts) {\n // remove the selected outline before serializing\n clearSelection();\n // Update save options if provided\n if (opts) { $.extend(saveOptions, opts); }\n saveOptions.apply = true;\n\n // no need for doctype, see https://jwatt.org/svg/authoring/#doctype-declaration\n const str = this.svgCanvasToString();\n call('saved', str);\n };\n\n /**\n* @typedef {PlainObject} module:svgcanvas.IssuesAndCodes\n* @property {string[]} issueCodes The locale-independent code names\n* @property {string[]} issues The localized descriptions\n*/\n\n /**\n* Codes only is useful for locale-independent detection.\n* @returns {module:svgcanvas.IssuesAndCodes}\n*/\n function getIssues () {\n // remove the selected outline before serializing\n clearSelection();\n\n // Check for known CanVG issues\n const issues = [];\n const issueCodes = [];\n\n // Selector and notice\n const issueList = {\n feGaussianBlur: uiStrings.exportNoBlur,\n foreignObject: uiStrings.exportNoforeignObject,\n '[stroke-dasharray]': uiStrings.exportNoDashArray\n };\n const content = $(svgcontent);\n\n // Add font/text check if Canvas Text API is not implemented\n if (!('font' in $('<canvas>')[0].getContext('2d'))) {\n issueList.text = uiStrings.exportNoText;\n }\n\n $.each(issueList, function (sel, descr) {\n if (content.find(sel).length) {\n issueCodes.push(sel);\n issues.push(descr);\n }\n });\n return {issues, issueCodes};\n }\n\n /**\n * @typedef {\"feGaussianBlur\"|\"foreignObject\"|\"[stroke-dasharray]\"|\"text\"} module:svgcanvas.IssueCode\n */\n /**\n* @typedef {PlainObject} module:svgcanvas.ImageExportedResults\n* @property {string} datauri Contents as a Data URL\n* @property {string} bloburl May be the empty string\n* @property {string} svg The SVG contents as a string\n* @property {string[]} issues The localization messages of `issueCodes`\n* @property {module:svgcanvas.IssueCode[]} issueCodes CanVG issues found with the SVG\n* @property {\"PNG\"|\"JPEG\"|\"BMP\"|\"WEBP\"|\"ICO\"} type The chosen image type\n* @property {\"image/png\"|\"image/jpeg\"|\"image/bmp\"|\"image/webp\"} mimeType The image MIME type\n* @property {Float} quality A decimal between 0 and 1 (for use with JPEG or WEBP)\n* @property {string} exportWindowName A convenience for passing along a `window.name` to target a window on which the export could be added\n*/\n\n /**\n* Generates a PNG (or JPG, BMP, WEBP) Data URL based on the current image,\n* then calls \"exported\" with an object including the string, image\n* information, and any issues found.\n* @function module:svgcanvas.SvgCanvas#rasterExport\n* @param {\"PNG\"|\"JPEG\"|\"BMP\"|\"WEBP\"|\"ICO\"} [imgType=\"PNG\"]\n* @param {Float} [quality] Between 0 and 1\n* @param {string} [exportWindowName]\n* @param {PlainObject} [opts]\n* @param {boolean} [opts.avoidEvent]\n* @fires module:svgcanvas.SvgCanvas#event:exported\n* @todo Confirm/fix ICO type\n* @returns {Promise<module:svgcanvas.ImageExportedResults>} Resolves to {@link module:svgcanvas.ImageExportedResults}\n*/\n this.rasterExport = async function (imgType, quality, exportWindowName, opts = {}) {\n const type = imgType === 'ICO' ? 'BMP' : (imgType || 'PNG');\n const mimeType = 'image/' + type.toLowerCase();\n const {issues, issueCodes} = getIssues();\n const svg = this.svgCanvasToString();\n\n if (!$('#export_canvas').length) {\n $('<canvas>', {id: 'export_canvas'}).hide().appendTo('body');\n }\n const c = $('#export_canvas')[0];\n c.width = canvas.contentW;\n c.height = canvas.contentH;\n\n await canvg(c, svg);\n // Todo: Make async/await utility in place of `toBlob`, so we can remove this constructor\n // eslint-disable-next-line promise/avoid-new\n return new Promise((resolve, reject) => {\n const dataURLType = type.toLowerCase();\n const datauri = quality\n ? c.toDataURL('image/' + dataURLType, quality)\n : c.toDataURL('image/' + dataURLType);\n let bloburl;\n /**\n * Called when `bloburl` is available for export.\n * @returns {void}\n */\n function done () {\n const obj = {\n datauri, bloburl, svg, issues, issueCodes, type: imgType,\n mimeType, quality, exportWindowName\n };\n if (!opts.avoidEvent) {\n call('exported', obj);\n }\n resolve(obj);\n }\n if (c.toBlob) {\n c.toBlob((blob) => {\n bloburl = createObjectURL(blob);\n done();\n }, mimeType, quality);\n return;\n }\n bloburl = dataURLToObjectURL(datauri);\n done();\n });\n };\n\n /**\n * @typedef {void|\"save\"|\"arraybuffer\"|\"blob\"|\"datauristring\"|\"dataurlstring\"|\"dataurlnewwindow\"|\"datauri\"|\"dataurl\"} external:jsPDF.OutputType\n * @todo Newer version to add also allows these `outputType` values \"bloburi\"|\"bloburl\" which return strings, so document here and for `outputType` of `module:svgcanvas.PDFExportedResults` below if added\n*/\n /**\n* @typedef {PlainObject} module:svgcanvas.PDFExportedResults\n* @property {string} svg The SVG PDF output\n* @property {string|ArrayBuffer|Blob|window} output The output based on the `outputType`;\n* if `undefined`, \"datauristring\", \"dataurlstring\", \"datauri\",\n* or \"dataurl\", will be a string (`undefined` gives a document, while the others\n* build as Data URLs; \"datauri\" and \"dataurl\" change the location of the current page); if\n* \"arraybuffer\", will return `ArrayBuffer`; if \"blob\", returns a `Blob`;\n* if \"dataurlnewwindow\", will change the current page's location and return a string\n* if in Safari and no window object is found; otherwise opens in, and returns, a new `window`\n* object; if \"save\", will have the same return as \"dataurlnewwindow\" if\n* `navigator.getUserMedia` support is found without `URL.createObjectURL` support; otherwise\n* returns `undefined` but attempts to save\n* @property {external:jsPDF.OutputType} outputType\n* @property {string[]} issues The human-readable localization messages of corresponding `issueCodes`\n* @property {module:svgcanvas.IssueCode[]} issueCodes\n* @property {string} exportWindowName\n*/\n\n /**\n* Generates a PDF based on the current image, then calls \"exportedPDF\" with\n* an object including the string, the data URL, and any issues found.\n* @function module:svgcanvas.SvgCanvas#exportPDF\n* @param {string} [exportWindowName] Will also be used for the download file name here\n* @param {external:jsPDF.OutputType} [outputType=\"dataurlstring\"]\n* @fires module:svgcanvas.SvgCanvas#event:exportedPDF\n* @returns {Promise<module:svgcanvas.PDFExportedResults>} Resolves to {@link module:svgcanvas.PDFExportedResults}\n*/\n this.exportPDF = async (\n exportWindowName,\n outputType = isChrome() ? 'save' : undefined\n ) => {\n const res = getResolution();\n const orientation = res.w > res.h ? 'landscape' : 'portrait';\n const unit = 'pt'; // curConfig.baseUnit; // We could use baseUnit, but that is presumably not intended for export purposes\n\n // Todo: Give options to use predefined jsPDF formats like \"a4\", etc. from pull-down (with option to keep customizable)\n const doc = jsPDF({\n orientation,\n unit,\n format: [res.w, res.h]\n // , compressPdf: true\n });\n const docTitle = getDocumentTitle();\n doc.setProperties({\n title: docTitle /* ,\n subject: '',\n author: '',\n keywords: '',\n creator: '' */\n });\n const {issues, issueCodes} = getIssues();\n // const svg = this.svgCanvasToString();\n // await doc.addSvgAsImage(svg)\n await doc.svg(svgcontent, {x: 0, y: 0, width: res.w, height: res.h});\n\n // doc.output('save'); // Works to open in a new\n // window; todo: configure this and other export\n // options to optionally work in this manner as\n // opposed to opening a new tab\n outputType = outputType || 'dataurlstring';\n const obj = {issues, issueCodes, exportWindowName, outputType};\n obj.output = doc.output(outputType, outputType === 'save' ? (exportWindowName || 'svg.pdf') : undefined);\n call('exportedPDF', obj);\n return obj;\n };\n\n /**\n* Returns the current drawing as raw SVG XML text.\n* @function module:svgcanvas.SvgCanvas#getSvgString\n* @returns {string} The current drawing as raw SVG XML text.\n*/\n this.getSvgString = function () {\n saveOptions.apply = false;\n return this.svgCanvasToString();\n };\n\n /**\n* This function determines whether to use a nonce in the prefix, when\n* generating IDs for future documents in SVG-Edit.\n* If you're controlling SVG-Edit externally, and want randomized IDs, call\n* this BEFORE calling `svgCanvas.setSvgString`.\n* @function module:svgcanvas.SvgCanvas#randomizeIds\n* @param {boolean} [enableRandomization] If true, adds a nonce to the prefix. Thus\n* `svgCanvas.randomizeIds() <==> svgCanvas.randomizeIds(true)`\n* @returns {void}\n*/\n this.randomizeIds = function (enableRandomization) {\n if (arguments.length > 0 && enableRandomization === false) {\n draw.randomizeIds(false, getCurrentDrawing());\n } else {\n draw.randomizeIds(true, getCurrentDrawing());\n }\n };\n\n /**\n* Ensure each element has a unique ID.\n* @function module:svgcanvas.SvgCanvas#uniquifyElems\n* @param {Element} g - The parent element of the tree to give unique IDs\n* @returns {void}\n*/\n const uniquifyElems = this.uniquifyElems = function (g) {\n const ids = {};\n // TODO: Handle markers and connectors. These are not yet re-identified properly\n // as their referring elements do not get remapped.\n //\n // <marker id='se_marker_end_svg_7'/>\n // <polyline id='svg_7' se:connector='svg_1 svg_6' marker-end='url(#se_marker_end_svg_7)'/>\n //\n // Problem #1: if svg_1 gets renamed, we do not update the polyline's se:connector attribute\n // Problem #2: if the polyline svg_7 gets renamed, we do not update the marker id nor the polyline's marker-end attribute\n const refElems = ['filter', 'linearGradient', 'pattern', 'radialGradient', 'symbol', 'textPath', 'use'];\n\n walkTree(g, function (n) {\n // if it's an element node\n if (n.nodeType === 1) {\n // and the element has an ID\n if (n.id) {\n // and we haven't tracked this ID yet\n if (!(n.id in ids)) {\n // add this id to our map\n ids[n.id] = {elem: null, attrs: [], hrefs: []};\n }\n ids[n.id].elem = n;\n }\n\n // now search for all attributes on this element that might refer\n // to other elements\n $.each(refAttrs, function (i, attr) {\n const attrnode = n.getAttributeNode(attr);\n if (attrnode) {\n // the incoming file has been sanitized, so we should be able to safely just strip off the leading #\n const url = getUrlFromAttr(attrnode.value),\n refid = url ? url.substr(1) : null;\n if (refid) {\n if (!(refid in ids)) {\n // add this id to our map\n ids[refid] = {elem: null, attrs: [], hrefs: []};\n }\n ids[refid].attrs.push(attrnode);\n }\n }\n });\n\n // check xlink:href now\n const href = getHref(n);\n // TODO: what if an <image> or <a> element refers to an element internally?\n if (href && refElems.includes(n.nodeName)) {\n const refid = href.substr(1);\n if (refid) {\n if (!(refid in ids)) {\n // add this id to our map\n ids[refid] = {elem: null, attrs: [], hrefs: []};\n }\n ids[refid].hrefs.push(n);\n }\n }\n }\n });\n\n // in ids, we now have a map of ids, elements and attributes, let's re-identify\n for (const oldid in ids) {\n if (!oldid) { continue; }\n const {elem} = ids[oldid];\n if (elem) {\n const newid = getNextId();\n\n // assign element its new id\n elem.id = newid;\n\n // remap all url() attributes\n const {attrs} = ids[oldid];\n let j = attrs.length;\n while (j--) {\n const attr = attrs[j];\n attr.ownerElement.setAttribute(attr.name, 'url(#' + newid + ')');\n }\n\n // remap all href attributes\n const hreffers = ids[oldid].hrefs;\n let k = hreffers.length;\n while (k--) {\n const hreffer = hreffers[k];\n setHref(hreffer, '#' + newid);\n }\n }\n }\n };\n\n /**\n* Assigns reference data for each use element.\n* @function module:svgcanvas.SvgCanvas#setUseData\n* @param {Element} parent\n* @returns {void}\n*/\n const setUseData = this.setUseData = function (parent) {\n let elems = $(parent);\n\n if (parent.tagName !== 'use') {\n elems = elems.find('use');\n }\n\n elems.each(function () {\n const id = getHref(this).substr(1);\n const refElem = getElem(id);\n if (!refElem) { return; }\n $(this).data('ref', refElem);\n if (refElem.tagName === 'symbol' || refElem.tagName === 'svg') {\n $(this).data('symbol', refElem).data('ref', refElem);\n }\n });\n };\n\n /**\n* Converts gradients from userSpaceOnUse to objectBoundingBox.\n* @function module:svgcanvas.SvgCanvas#convertGradients\n* @param {Element} elem\n* @returns {void}\n*/\n const convertGradients = this.convertGradients = function (elem) {\n let elems = $(elem).find('linearGradient, radialGradient');\n if (!elems.length && isWebkit()) {\n // Bug in webkit prevents regular *Gradient selector search\n elems = $(elem).find('*').filter(function () {\n return (this.tagName.includes('Gradient'));\n });\n }\n\n elems.each(function () {\n const grad = this;\n if ($(grad).attr('gradientUnits') === 'userSpaceOnUse') {\n // TODO: Support more than one element with this ref by duplicating parent grad\n const fillStrokeElems = $(svgcontent).find('[fill=\"url(#' + grad.id + ')\"],[stroke=\"url(#' + grad.id + ')\"]');\n if (!fillStrokeElems.length) { return; }\n\n // get object's bounding box\n const bb = utilsGetBBox(fillStrokeElems[0]);\n\n // This will occur if the element is inside a <defs> or a <symbol>,\n // in which we shouldn't need to convert anyway.\n if (!bb) { return; }\n\n if (grad.tagName === 'linearGradient') {\n const gCoords = $(grad).attr(['x1', 'y1', 'x2', 'y2']);\n\n // If has transform, convert\n const tlist = grad.gradientTransform.baseVal;\n if (tlist && tlist.numberOfItems > 0) {\n const m = transformListToTransform(tlist).matrix;\n const pt1 = transformPoint(gCoords.x1, gCoords.y1, m);\n const pt2 = transformPoint(gCoords.x2, gCoords.y2, m);\n\n gCoords.x1 = pt1.x;\n gCoords.y1 = pt1.y;\n gCoords.x2 = pt2.x;\n gCoords.y2 = pt2.y;\n grad.removeAttribute('gradientTransform');\n }\n\n $(grad).attr({\n x1: (gCoords.x1 - bb.x) / bb.width,\n y1: (gCoords.y1 - bb.y) / bb.height,\n x2: (gCoords.x2 - bb.x) / bb.width,\n y2: (gCoords.y2 - bb.y) / bb.height\n });\n grad.removeAttribute('gradientUnits');\n }\n // else {\n // Note: radialGradient elements cannot be easily converted\n // because userSpaceOnUse will keep circular gradients, while\n // objectBoundingBox will x/y scale the gradient according to\n // its bbox.\n //\n // For now we'll do nothing, though we should probably have\n // the gradient be updated as the element is moved, as\n // inkscape/illustrator do.\n //\n // const gCoords = $(grad).attr(['cx', 'cy', 'r']);\n //\n // $(grad).attr({\n // cx: (gCoords.cx - bb.x) / bb.width,\n // cy: (gCoords.cy - bb.y) / bb.height,\n // r: gCoords.r\n // });\n //\n // grad.removeAttribute('gradientUnits');\n // }\n }\n });\n };\n\n /**\n* Converts selected/given `<use>` or child SVG element to a group.\n* @function module:svgcanvas.SvgCanvas#convertToGroup\n* @param {Element} elem\n* @fires module:svgcanvas.SvgCanvas#event:selected\n* @returns {void}\n*/\n const convertToGroup = this.convertToGroup = function (elem) {\n if (!elem) {\n elem = selectedElements[0];\n }\n const $elem = $(elem);\n const batchCmd = new BatchCommand();\n let ts;\n\n if ($elem.data('gsvg')) {\n // Use the gsvg as the new group\n const svg = elem.firstChild;\n const pt = $(svg).attr(['x', 'y']);\n\n $(elem.firstChild.firstChild).unwrap();\n $(elem).removeData('gsvg');\n\n const tlist = getTransformList(elem);\n const xform = svgroot.createSVGTransform();\n xform.setTranslate(pt.x, pt.y);\n tlist.appendItem(xform);\n recalculateDimensions(elem);\n call('selected', [elem]);\n } else if ($elem.data('symbol')) {\n elem = $elem.data('symbol');\n\n ts = $elem.attr('transform');\n const pos = $elem.attr(['x', 'y']);\n\n const vb = elem.getAttribute('viewBox');\n\n if (vb) {\n const nums = vb.split(' ');\n pos.x -= Number(nums[0]);\n pos.y -= Number(nums[1]);\n }\n\n // Not ideal, but works\n ts += ' translate(' + (pos.x || 0) + ',' + (pos.y || 0) + ')';\n\n const prev = $elem.prev();\n\n // Remove <use> element\n batchCmd.addSubCommand(new RemoveElementCommand($elem[0], $elem[0].nextSibling, $elem[0].parentNode));\n $elem.remove();\n\n // See if other elements reference this symbol\n const hasMore = $(svgcontent).find('use:data(symbol)').length;\n\n const g = svgdoc.createElementNS(NS.SVG, 'g');\n const childs = elem.childNodes;\n\n let i;\n for (i = 0; i < childs.length; i++) {\n g.append(childs[i].cloneNode(true));\n }\n\n // Duplicate the gradients for Gecko, since they weren't included in the <symbol>\n if (isGecko()) {\n const dupeGrads = $(findDefs()).children('linearGradient,radialGradient,pattern').clone();\n $(g).append(dupeGrads);\n }\n\n if (ts) {\n g.setAttribute('transform', ts);\n }\n\n const parent = elem.parentNode;\n\n uniquifyElems(g);\n\n // Put the dupe gradients back into <defs> (after uniquifying them)\n if (isGecko()) {\n $(findDefs()).append($(g).find('linearGradient,radialGradient,pattern'));\n }\n\n // now give the g itself a new id\n g.id = getNextId();\n\n prev.after(g);\n\n if (parent) {\n if (!hasMore) {\n // remove symbol/svg element\n const {nextSibling} = elem;\n elem.remove();\n batchCmd.addSubCommand(new RemoveElementCommand(elem, nextSibling, parent));\n }\n batchCmd.addSubCommand(new InsertElementCommand(g));\n }\n\n setUseData(g);\n\n if (isGecko()) {\n convertGradients(findDefs());\n } else {\n convertGradients(g);\n }\n\n // recalculate dimensions on the top-level children so that unnecessary transforms\n // are removed\n walkTreePost(g, function (n) {\n try {\n recalculateDimensions(n);\n } catch (e) {\n console.log(e); // eslint-disable-line no-console\n }\n });\n\n // Give ID for any visible element missing one\n $(g).find(visElems).each(function () {\n if (!this.id) { this.id = getNextId(); }\n });\n\n selectOnly([g]);\n\n const cm = pushGroupProperties(g, true);\n if (cm) {\n batchCmd.addSubCommand(cm);\n }\n\n addCommandToHistory(batchCmd);\n } else {\n console.log('Unexpected element to ungroup:', elem); // eslint-disable-line no-console\n }\n };\n\n /**\n* This function sets the current drawing as the input SVG XML.\n* @function module:svgcanvas.SvgCanvas#setSvgString\n* @param {string} xmlString - The SVG as XML text.\n* @param {boolean} [preventUndo=false] - Indicates if we want to do the\n* changes without adding them to the undo stack - e.g. for initializing a\n* drawing on page load.\n* @fires module:svgcanvas.SvgCanvas#event:setnonce\n* @fires module:svgcanvas.SvgCanvas#event:unsetnonce\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {boolean} This function returns `false` if the set was\n* unsuccessful, `true` otherwise.\n*/\n this.setSvgString = function (xmlString, preventUndo) {\n try {\n // convert string into XML document\n const newDoc = text2xml(xmlString);\n if (newDoc.firstElementChild &&\n newDoc.firstElementChild.namespaceURI !== NS.SVG) {\n return false;\n }\n\n this.prepareSvg(newDoc);\n\n const batchCmd = new BatchCommand('Change Source');\n\n // remove old svg document\n const {nextSibling} = svgcontent;\n\n svgcontent.remove();\n const oldzoom = svgcontent;\n batchCmd.addSubCommand(new RemoveElementCommand(oldzoom, nextSibling, svgroot));\n\n // set new svg document\n // If DOM3 adoptNode() available, use it. Otherwise fall back to DOM2 importNode()\n if (svgdoc.adoptNode) {\n svgcontent = svgdoc.adoptNode(newDoc.documentElement);\n } else {\n svgcontent = svgdoc.importNode(newDoc.documentElement, true);\n }\n\n svgroot.append(svgcontent);\n const content = $(svgcontent);\n\n canvas.current_drawing_ = new draw.Drawing(svgcontent, idprefix);\n\n // retrieve or set the nonce\n const nonce = getCurrentDrawing().getNonce();\n if (nonce) {\n call('setnonce', nonce);\n } else {\n call('unsetnonce');\n }\n\n // change image href vals if possible\n content.find('image').each(function () {\n const image = this;\n preventClickDefault(image);\n const val = getHref(this);\n if (val) {\n if (val.startsWith('data:')) {\n // Check if an SVG-edit data URI\n const m = val.match(/svgedit_url=(.*?);/);\n // const m = val.match(/svgedit_url=(?<url>.*?);/);\n if (m) {\n const url = decodeURIComponent(m[1]);\n // const url = decodeURIComponent(m.groups.url);\n $(new Image()).load(function () {\n image.setAttributeNS(NS.XLINK, 'xlink:href', url);\n }).attr('src', url);\n }\n }\n // Add to encodableImages if it loads\n canvas.embedImage(val);\n }\n });\n\n // Wrap child SVGs in group elements\n content.find('svg').each(function () {\n // Skip if it's in a <defs>\n if ($(this).closest('defs').length) { return; }\n\n uniquifyElems(this);\n\n // Check if it already has a gsvg group\n const pa = this.parentNode;\n if (pa.childNodes.length === 1 && pa.nodeName === 'g') {\n $(pa).data('gsvg', this);\n pa.id = pa.id || getNextId();\n } else {\n groupSvgElem(this);\n }\n });\n\n // For Firefox: Put all paint elems in defs\n if (isGecko()) {\n content.find('linearGradient, radialGradient, pattern').appendTo(findDefs());\n }\n\n // Set ref element for <use> elements\n\n // TODO: This should also be done if the object is re-added through \"redo\"\n setUseData(content);\n\n convertGradients(content[0]);\n\n const attrs = {\n id: 'svgcontent',\n overflow: curConfig.show_outside_canvas ? 'visible' : 'hidden'\n };\n\n let percs = false;\n\n // determine proper size\n if (content.attr('viewBox')) {\n const vb = content.attr('viewBox').split(' ');\n attrs.width = vb[2];\n attrs.height = vb[3];\n // handle content that doesn't have a viewBox\n } else {\n $.each(['width', 'height'], function (i, dim) {\n // Set to 100 if not given\n const val = content.attr(dim) || '100%';\n\n if (String(val).substr(-1) === '%') {\n // Use user units if percentage given\n percs = true;\n } else {\n attrs[dim] = convertToNum(dim, val);\n }\n });\n }\n\n // identify layers\n draw.identifyLayers();\n\n // Give ID for any visible layer children missing one\n content.children().find(visElems).each(function () {\n if (!this.id) { this.id = getNextId(); }\n });\n\n // Percentage width/height, so let's base it on visible elements\n if (percs) {\n const bb = getStrokedBBoxDefaultVisible();\n attrs.width = bb.width + bb.x;\n attrs.height = bb.height + bb.y;\n }\n\n // Just in case negative numbers are given or\n // result from the percs calculation\n if (attrs.width <= 0) { attrs.width = 100; }\n if (attrs.height <= 0) { attrs.height = 100; }\n\n content.attr(attrs);\n this.contentW = attrs.width;\n this.contentH = attrs.height;\n\n batchCmd.addSubCommand(new InsertElementCommand(svgcontent));\n // update root to the correct size\n const changes = content.attr(['width', 'height']);\n batchCmd.addSubCommand(new ChangeElementCommand(svgroot, changes));\n\n // reset zoom\n currentZoom = 1;\n\n // reset transform lists\n resetListMap();\n clearSelection();\n pathModule.clearData();\n svgroot.append(selectorManager.selectorParentGroup);\n\n if (!preventUndo) addCommandToHistory(batchCmd);\n call('changed', [svgcontent]);\n } catch (e) {\n console.log(e); // eslint-disable-line no-console\n return false;\n }\n\n return true;\n };\n\n /**\n* This function imports the input SVG XML as a `<symbol>` in the `<defs>`, then adds a\n* `<use>` to the current layer.\n* @function module:svgcanvas.SvgCanvas#importSvgString\n* @param {string} xmlString - The SVG as XML text.\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {null|Element} This function returns null if the import was unsuccessful, or the element otherwise.\n* @todo\n* - properly handle if namespace is introduced by imported content (must add to svgcontent\n* and update all prefixes in the imported node)\n* - properly handle recalculating dimensions, `recalculateDimensions()` doesn't handle\n* arbitrary transform lists, but makes some assumptions about how the transform list\n* was obtained\n*/\n this.importSvgString = function (xmlString) {\n let j, ts, useEl;\n try {\n // Get unique ID\n const uid = encode64(xmlString.length + xmlString).substr(0, 32);\n\n let useExisting = false;\n // Look for symbol and make sure symbol exists in image\n if (importIds[uid]) {\n if ($(importIds[uid].symbol).parents('#svgroot').length) {\n useExisting = true;\n }\n }\n\n const batchCmd = new BatchCommand('Import Image');\n let symbol;\n if (useExisting) {\n ({symbol} = importIds[uid]);\n ts = importIds[uid].xform;\n } else {\n // convert string into XML document\n const newDoc = text2xml(xmlString);\n\n this.prepareSvg(newDoc);\n\n // import new svg document into our document\n let svg;\n // If DOM3 adoptNode() available, use it. Otherwise fall back to DOM2 importNode()\n if (svgdoc.adoptNode) {\n svg = svgdoc.adoptNode(newDoc.documentElement);\n } else {\n svg = svgdoc.importNode(newDoc.documentElement, true);\n }\n\n uniquifyElems(svg);\n\n const innerw = convertToNum('width', svg.getAttribute('width')),\n innerh = convertToNum('height', svg.getAttribute('height')),\n innervb = svg.getAttribute('viewBox'),\n // if no explicit viewbox, create one out of the width and height\n vb = innervb ? innervb.split(' ') : [0, 0, innerw, innerh];\n for (j = 0; j < 4; ++j) {\n vb[j] = Number(vb[j]);\n }\n\n // TODO: properly handle preserveAspectRatio\n const // canvasw = +svgcontent.getAttribute('width'),\n canvash = Number(svgcontent.getAttribute('height'));\n // imported content should be 1/3 of the canvas on its largest dimension\n\n if (innerh > innerw) {\n ts = 'scale(' + (canvash / 3) / vb[3] + ')';\n } else {\n ts = 'scale(' + (canvash / 3) / vb[2] + ')';\n }\n\n // Hack to make recalculateDimensions understand how to scale\n ts = 'translate(0) ' + ts + ' translate(0)';\n\n symbol = svgdoc.createElementNS(NS.SVG, 'symbol');\n const defs = findDefs();\n\n if (isGecko()) {\n // Move all gradients into root for Firefox, workaround for this bug:\n // https://bugzilla.mozilla.org/show_bug.cgi?id=353575\n // TODO: Make this properly undo-able.\n $(svg).find('linearGradient, radialGradient, pattern').appendTo(defs);\n }\n\n while (svg.firstChild) {\n const first = svg.firstChild;\n symbol.append(first);\n }\n const attrs = svg.attributes;\n for (const attr of attrs) { // Ok for `NamedNodeMap`\n symbol.setAttribute(attr.nodeName, attr.value);\n }\n symbol.id = getNextId();\n\n // Store data\n importIds[uid] = {\n symbol,\n xform: ts\n };\n\n findDefs().append(symbol);\n batchCmd.addSubCommand(new InsertElementCommand(symbol));\n }\n\n useEl = svgdoc.createElementNS(NS.SVG, 'use');\n useEl.id = getNextId();\n setHref(useEl, '#' + symbol.id);\n\n (currentGroup || getCurrentDrawing().getCurrentLayer()).append(useEl);\n batchCmd.addSubCommand(new InsertElementCommand(useEl));\n clearSelection();\n\n useEl.setAttribute('transform', ts);\n recalculateDimensions(useEl);\n $(useEl).data('symbol', symbol).data('ref', symbol);\n addToSelection([useEl]);\n\n // TODO: Find way to add this in a recalculateDimensions-parsable way\n // if (vb[0] !== 0 || vb[1] !== 0) {\n // ts = 'translate(' + (-vb[0]) + ',' + (-vb[1]) + ') ' + ts;\n // }\n addCommandToHistory(batchCmd);\n call('changed', [svgcontent]);\n } catch (e) {\n console.log(e); // eslint-disable-line no-console\n return null;\n }\n\n // we want to return the element so we can automatically select it\n return useEl;\n };\n\n // Could deprecate, but besides external uses, their usage makes clear that\n // canvas is a dependency for all of these\n const dr = {\n identifyLayers, createLayer, cloneLayer, deleteCurrentLayer,\n setCurrentLayer, renameCurrentLayer, setCurrentLayerPosition,\n setLayerVisibility, moveSelectedToLayer, mergeLayer, mergeAllLayers,\n leaveContext, setContext\n };\n Object.entries(dr).forEach(([prop, propVal]) => {\n canvas[prop] = propVal;\n });\n draw.init(\n /**\n * @implements {module:draw.DrawCanvasInit}\n */\n {\n pathActions,\n getCurrentGroup () {\n return currentGroup;\n },\n setCurrentGroup (cg) {\n currentGroup = cg;\n },\n getSelectedElements,\n getSVGContent,\n undoMgr,\n elData,\n getCurrentDrawing,\n clearSelection,\n call,\n addCommandToHistory,\n /**\n * @fires module:svgcanvas.SvgCanvas#event:changed\n * @returns {void}\n */\n changeSVGContent () {\n call('changed', [svgcontent]);\n }\n }\n );\n\n /**\n* Group: Document functions.\n*/\n\n /**\n* Clears the current document. This is not an undoable action.\n* @function module:svgcanvas.SvgCanvas#clear\n* @fires module:svgcanvas.SvgCanvas#event:cleared\n* @returns {void}\n*/\n this.clear = function () {\n pathActions.clear();\n\n clearSelection();\n\n // clear the svgcontent node\n canvas.clearSvgContentElement();\n\n // create new document\n canvas.current_drawing_ = new draw.Drawing(svgcontent);\n\n // create empty first layer\n canvas.createLayer('Layer 1');\n\n // clear the undo stack\n canvas.undoMgr.resetUndoStack();\n\n // reset the selector manager\n selectorManager.initGroup();\n\n // reset the rubber band box\n rubberBox = selectorManager.getRubberBandBox();\n\n call('cleared');\n };\n\n // Alias function\n this.linkControlPoints = pathActions.linkControlPoints;\n\n /**\n* @function module:svgcanvas.SvgCanvas#getContentElem\n* @returns {Element} The content DOM element\n*/\n this.getContentElem = function () { return svgcontent; };\n\n /**\n* @function module:svgcanvas.SvgCanvas#getRootElem\n* @returns {SVGSVGElement} The root DOM element\n*/\n this.getRootElem = function () { return svgroot; };\n\n /**\n* @typedef {PlainObject} DimensionsAndZoom\n* @property {Float} w Width\n* @property {Float} h Height\n* @property {Float} zoom Zoom\n*/\n\n /**\n* @function module:svgcanvas.SvgCanvas#getResolution\n* @returns {DimensionsAndZoom} The current dimensions and zoom level in an object\n*/\n const getResolution = this.getResolution = function () {\n // const vb = svgcontent.getAttribute('viewBox').split(' ');\n // return {w:vb[2], h:vb[3], zoom: currentZoom};\n\n const w = svgcontent.getAttribute('width') / currentZoom;\n const h = svgcontent.getAttribute('height') / currentZoom;\n\n return {\n w,\n h,\n zoom: currentZoom\n };\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#getSnapToGrid\n* @returns {boolean} The current snap to grid setting\n*/\n this.getSnapToGrid = function () { return curConfig.gridSnapping; };\n\n /**\n* @function module:svgcanvas.SvgCanvas#getVersion\n* @returns {string} A string which describes the revision number of SvgCanvas.\n*/\n this.getVersion = function () {\n return 'svgcanvas.js ($Rev$)';\n };\n\n /**\n* Update interface strings with given values.\n* @function module:svgcanvas.SvgCanvas#setUiStrings\n* @param {module:path.uiStrings} strs - Object with strings (see the [locales API]{@link module:locale.LocaleStrings} and the [tutorial]{@tutorial LocaleDocs})\n* @returns {void}\n*/\n this.setUiStrings = function (strs) {\n Object.assign(uiStrings, strs.notification);\n $ = jQueryPluginDBox($, strs.common);\n pathModule.setUiStrings(strs);\n };\n\n /**\n* Update configuration options with given values.\n* @function module:svgcanvas.SvgCanvas#setConfig\n* @param {module:SVGEditor.Config} opts - Object with options\n* @returns {void}\n*/\n this.setConfig = function (opts) {\n Object.assign(curConfig, opts);\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#getTitle\n* @param {Element} [elem]\n* @returns {string|void} the current group/SVG's title contents or\n* `undefined` if no element is passed nd there are no selected elements.\n*/\n this.getTitle = function (elem) {\n elem = elem || selectedElements[0];\n if (!elem) { return undefined; }\n elem = $(elem).data('gsvg') || $(elem).data('symbol') || elem;\n const childs = elem.childNodes;\n for (const child of childs) {\n if (child.nodeName === 'title') {\n return child.textContent;\n }\n }\n return '';\n };\n\n /**\n* Sets the group/SVG's title content.\n* @function module:svgcanvas.SvgCanvas#setGroupTitle\n* @param {string} val\n* @todo Combine this with `setDocumentTitle`\n* @returns {void}\n*/\n this.setGroupTitle = function (val) {\n let elem = selectedElements[0];\n elem = $(elem).data('gsvg') || elem;\n\n const ts = $(elem).children('title');\n\n const batchCmd = new BatchCommand('Set Label');\n\n let title;\n if (!val.length) {\n // Remove title element\n const tsNextSibling = ts.nextSibling;\n batchCmd.addSubCommand(new RemoveElementCommand(ts[0], tsNextSibling, elem));\n ts.remove();\n } else if (ts.length) {\n // Change title contents\n title = ts[0];\n batchCmd.addSubCommand(new ChangeElementCommand(title, {'#text': title.textContent}));\n title.textContent = val;\n } else {\n // Add title element\n title = svgdoc.createElementNS(NS.SVG, 'title');\n title.textContent = val;\n $(elem).prepend(title);\n batchCmd.addSubCommand(new InsertElementCommand(title));\n }\n\n addCommandToHistory(batchCmd);\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#getDocumentTitle\n* @returns {string|void} The current document title or an empty string if not found\n*/\n const getDocumentTitle = this.getDocumentTitle = function () {\n return canvas.getTitle(svgcontent);\n };\n\n /**\n* Adds/updates a title element for the document with the given name.\n* This is an undoable action.\n* @function module:svgcanvas.SvgCanvas#setDocumentTitle\n* @param {string} newTitle - String with the new title\n* @returns {void}\n*/\n this.setDocumentTitle = function (newTitle) {\n const childs = svgcontent.childNodes;\n let docTitle = false, oldTitle = '';\n\n const batchCmd = new BatchCommand('Change Image Title');\n\n for (const child of childs) {\n if (child.nodeName === 'title') {\n docTitle = child;\n oldTitle = docTitle.textContent;\n break;\n }\n }\n if (!docTitle) {\n docTitle = svgdoc.createElementNS(NS.SVG, 'title');\n svgcontent.insertBefore(docTitle, svgcontent.firstChild);\n // svgcontent.firstChild.before(docTitle); // Ok to replace above with this?\n }\n\n if (newTitle.length) {\n docTitle.textContent = newTitle;\n } else {\n // No title given, so element is not necessary\n docTitle.remove();\n }\n batchCmd.addSubCommand(new ChangeElementCommand(docTitle, {'#text': oldTitle}));\n addCommandToHistory(batchCmd);\n };\n\n /**\n* Returns the editor's namespace URL, optionally adding it to the root element.\n* @function module:svgcanvas.SvgCanvas#getEditorNS\n* @param {boolean} [add] - Indicates whether or not to add the namespace value\n* @returns {string} The editor's namespace URL\n*/\n this.getEditorNS = function (add) {\n if (add) {\n svgcontent.setAttribute('xmlns:se', NS.SE);\n }\n return NS.SE;\n };\n\n /**\n* Changes the document's dimensions to the given size.\n* @function module:svgcanvas.SvgCanvas#setResolution\n* @param {Float|\"fit\"} x - Number with the width of the new dimensions in user units.\n* Can also be the string \"fit\" to indicate \"fit to content\".\n* @param {Float} y - Number with the height of the new dimensions in user units.\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {boolean} Indicates if resolution change was successful.\n* It will fail on \"fit to content\" option with no content to fit to.\n*/\n this.setResolution = function (x, y) {\n const res = getResolution();\n const {w, h} = res;\n let batchCmd;\n\n if (x === 'fit') {\n // Get bounding box\n const bbox = getStrokedBBoxDefaultVisible();\n\n if (bbox) {\n batchCmd = new BatchCommand('Fit Canvas to Content');\n const visEls = getVisibleElements();\n addToSelection(visEls);\n const dx = [], dy = [];\n $.each(visEls, function (i, item) {\n dx.push(bbox.x * -1);\n dy.push(bbox.y * -1);\n });\n\n const cmd = canvas.moveSelectedElements(dx, dy, true);\n batchCmd.addSubCommand(cmd);\n clearSelection();\n\n x = Math.round(bbox.width);\n y = Math.round(bbox.height);\n } else {\n return false;\n }\n }\n if (x !== w || y !== h) {\n if (!batchCmd) {\n batchCmd = new BatchCommand('Change Image Dimensions');\n }\n\n x = convertToNum('width', x);\n y = convertToNum('height', y);\n\n svgcontent.setAttribute('width', x);\n svgcontent.setAttribute('height', y);\n\n this.contentW = x;\n this.contentH = y;\n batchCmd.addSubCommand(new ChangeElementCommand(svgcontent, {width: w, height: h}));\n\n svgcontent.setAttribute('viewBox', [0, 0, x / currentZoom, y / currentZoom].join(' '));\n batchCmd.addSubCommand(new ChangeElementCommand(svgcontent, {viewBox: ['0 0', w, h].join(' ')}));\n\n addCommandToHistory(batchCmd);\n call('changed', [svgcontent]);\n }\n return true;\n };\n\n /**\n* @typedef {module:jQueryAttr.Attributes} module:svgcanvas.ElementPositionInCanvas\n* @property {Float} x\n* @property {Float} y\n*/\n\n /**\n* @function module:svgcanvas.SvgCanvas#getOffset\n* @returns {module:svgcanvas.ElementPositionInCanvas} An object with `x`, `y` values indicating the svgcontent element's\n* position in the editor's canvas.\n*/\n this.getOffset = function () {\n return $(svgcontent).attr(['x', 'y']);\n };\n\n /**\n * @typedef {PlainObject} module:svgcanvas.ZoomAndBBox\n * @property {Float} zoom\n * @property {module:utilities.BBoxObject} bbox\n */\n /**\n* Sets the zoom level on the canvas-side based on the given value.\n* @function module:svgcanvas.SvgCanvas#setBBoxZoom\n* @param {\"selection\"|\"canvas\"|\"content\"|\"layer\"|module:SVGEditor.BBoxObjectWithFactor} val - Bounding box object to zoom to or string indicating zoom option. Note: the object value type is defined in `svg-editor.js`\n* @param {Integer} editorW - The editor's workarea box's width\n* @param {Integer} editorH - The editor's workarea box's height\n* @returns {module:svgcanvas.ZoomAndBBox|void}\n*/\n this.setBBoxZoom = function (val, editorW, editorH) {\n let spacer = 0.85;\n let bb;\n const calcZoom = function (bb) { // eslint-disable-line no-shadow\n if (!bb) { return false; }\n const wZoom = Math.round((editorW / bb.width) * 100 * spacer) / 100;\n const hZoom = Math.round((editorH / bb.height) * 100 * spacer) / 100;\n const zoom = Math.min(wZoom, hZoom);\n canvas.setZoom(zoom);\n return {zoom, bbox: bb};\n };\n\n if (typeof val === 'object') {\n bb = val;\n if (bb.width === 0 || bb.height === 0) {\n const newzoom = bb.zoom ? bb.zoom : currentZoom * bb.factor;\n canvas.setZoom(newzoom);\n return {zoom: currentZoom, bbox: bb};\n }\n return calcZoom(bb);\n }\n\n switch (val) {\n case 'selection': {\n if (!selectedElements[0]) { return undefined; }\n const selectedElems = $.map(selectedElements, function (n) {\n if (n) {\n return n;\n }\n return undefined;\n });\n bb = getStrokedBBoxDefaultVisible(selectedElems);\n break;\n } case 'canvas': {\n const res = getResolution();\n spacer = 0.95;\n bb = {width: res.w, height: res.h, x: 0, y: 0};\n break;\n } case 'content':\n bb = getStrokedBBoxDefaultVisible();\n break;\n case 'layer':\n bb = getStrokedBBoxDefaultVisible(getVisibleElements(getCurrentDrawing().getCurrentLayer()));\n break;\n default:\n return undefined;\n }\n return calcZoom(bb);\n };\n\n /**\n* The zoom level has changed. Supplies the new zoom level as a number (not percentage).\n* @event module:svgcanvas.SvgCanvas#event:ext_zoomChanged\n* @type {Float}\n*/\n /**\n* The bottom panel was updated.\n* @event module:svgcanvas.SvgCanvas#event:ext_toolButtonStateUpdate\n* @type {PlainObject}\n* @property {boolean} nofill Indicates fill is disabled\n* @property {boolean} nostroke Indicates stroke is disabled\n*/\n /**\n* The element selection has changed (elements were added/removed from selection).\n* @event module:svgcanvas.SvgCanvas#event:ext_selectedChanged\n* @type {PlainObject}\n* @property {Element[]} elems Array of the newly selected elements\n* @property {Element|null} selectedElement The single selected element\n* @property {boolean} multiselected Indicates whether one or more elements were selected\n*/\n /**\n* Called when part of element is in process of changing, generally on\n* mousemove actions like rotate, move, etc.\n* @event module:svgcanvas.SvgCanvas#event:ext_elementTransition\n* @type {PlainObject}\n* @property {Element[]} elems Array of transitioning elements\n*/\n /**\n* One or more elements were changed.\n* @event module:svgcanvas.SvgCanvas#event:ext_elementChanged\n* @type {PlainObject}\n* @property {Element[]} elems Array of the affected elements\n*/\n /**\n* Invoked as soon as the locale is ready.\n* @event module:svgcanvas.SvgCanvas#event:ext_langReady\n* @type {PlainObject}\n* @property {string} lang The two-letter language code\n* @property {module:SVGEditor.uiStrings} uiStrings\n* @property {module:SVGEditor~ImportLocale} importLocale\n*/\n /**\n* The language was changed. Two-letter code of the new language.\n* @event module:svgcanvas.SvgCanvas#event:ext_langChanged\n* @type {string}\n*/\n /**\n* Means for an extension to add locale data. The two-letter language code.\n* @event module:svgcanvas.SvgCanvas#event:ext_addLangData\n* @type {PlainObject}\n* @property {string} lang\n* @property {module:SVGEditor~ImportLocale} importLocale\n*/\n /**\n * Called when new image is created.\n * @event module:svgcanvas.SvgCanvas#event:ext_onNewDocument\n * @type {void}\n */\n /**\n * Called when sidepanel is resized or toggled.\n * @event module:svgcanvas.SvgCanvas#event:ext_workareaResized\n * @type {void}\n*/\n /**\n * Called upon addition of the extension, or, if svgicons are set,\n * after the icons are ready when extension SVG icons have loaded.\n * @event module:svgcanvas.SvgCanvas#event:ext_callback\n * @type {void}\n*/\n\n /**\n* Sets the zoom to the given level.\n* @function module:svgcanvas.SvgCanvas#setZoom\n* @param {Float} zoomLevel - Float indicating the zoom level to change to\n* @fires module:svgcanvas.SvgCanvas#event:ext_zoomChanged\n* @returns {void}\n*/\n this.setZoom = function (zoomLevel) {\n const res = getResolution();\n svgcontent.setAttribute('viewBox', '0 0 ' + res.w / zoomLevel + ' ' + res.h / zoomLevel);\n currentZoom = zoomLevel;\n $.each(selectedElements, function (i, elem) {\n if (!elem) { return; }\n selectorManager.requestSelector(elem).resize();\n });\n pathActions.zoomChange();\n runExtensions('zoomChanged', /** @type {module:svgcanvas.SvgCanvas#event:ext_zoomChanged} */ zoomLevel);\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#getMode\n* @returns {string} The current editor mode string\n*/\n this.getMode = function () {\n return currentMode;\n };\n\n /**\n* Sets the editor's mode to the given string.\n* @function module:svgcanvas.SvgCanvas#setMode\n* @param {string} name - String with the new mode to change to\n* @returns {void}\n*/\n this.setMode = function (name) {\n pathActions.clear(true);\n textActions.clear();\n curProperties = (selectedElements[0] && selectedElements[0].nodeName === 'text') ? curText : curShape;\n currentMode = name;\n };\n\n /**\n* Group: Element Styling.\n*/\n\n /**\n* @typedef {PlainObject} module:svgcanvas.PaintOptions\n* @property {\"solidColor\"} type\n*/\n\n /**\n* @function module:svgcanvas.SvgCanvas#getColor\n* @param {string} type\n* @returns {string|module:svgcanvas.PaintOptions|Float|module:jGraduate~Paint} The current fill/stroke option\n*/\n this.getColor = function (type) {\n return curProperties[type];\n };\n\n /**\n* Change the current stroke/fill color/gradient value.\n* @function module:svgcanvas.SvgCanvas#setColor\n* @param {string} type - String indicating fill or stroke\n* @param {string} val - The value to set the stroke attribute to\n* @param {boolean} preventUndo - Boolean indicating whether or not this should be an undoable option\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {void}\n*/\n this.setColor = function (type, val, preventUndo) {\n curShape[type] = val;\n curProperties[type + '_paint'] = {type: 'solidColor'};\n const elems = [];\n /**\n *\n * @param {Element} e\n * @returns {void}\n */\n function addNonG (e) {\n if (e.nodeName !== 'g') {\n elems.push(e);\n }\n }\n let i = selectedElements.length;\n while (i--) {\n const elem = selectedElements[i];\n if (elem) {\n if (elem.tagName === 'g') {\n walkTree(elem, addNonG);\n } else if (type === 'fill') {\n if (elem.tagName !== 'polyline' && elem.tagName !== 'line') {\n elems.push(elem);\n }\n } else {\n elems.push(elem);\n }\n }\n }\n if (elems.length > 0) {\n if (!preventUndo) {\n changeSelectedAttribute(type, val, elems);\n call('changed', elems);\n } else {\n changeSelectedAttributeNoUndo(type, val, elems);\n }\n }\n };\n\n /**\n* Apply the current gradient to selected element's fill or stroke.\n* @function module:svgcanvas.SvgCanvas#setGradient\n* @param {\"fill\"|\"stroke\"} type - String indicating \"fill\" or \"stroke\" to apply to an element\n* @returns {void}\n*/\n const setGradient = this.setGradient = function (type) {\n if (!curProperties[type + '_paint'] || curProperties[type + '_paint'].type === 'solidColor') { return; }\n let grad = canvas[type + 'Grad'];\n // find out if there is a duplicate gradient already in the defs\n const duplicateGrad = findDuplicateGradient(grad);\n const defs = findDefs();\n // no duplicate found, so import gradient into defs\n if (!duplicateGrad) {\n // const origGrad = grad;\n grad = defs.appendChild(svgdoc.importNode(grad, true));\n // get next id and set it on the grad\n grad.id = getNextId();\n } else { // use existing gradient\n grad = duplicateGrad;\n }\n canvas.setColor(type, 'url(#' + grad.id + ')');\n };\n\n /**\n* Check if exact gradient already exists.\n* @function module:svgcanvas~findDuplicateGradient\n* @param {SVGGradientElement} grad - The gradient DOM element to compare to others\n* @returns {SVGGradientElement} The existing gradient if found, `null` if not\n*/\n const findDuplicateGradient = function (grad) {\n const defs = findDefs();\n const existingGrads = $(defs).find('linearGradient, radialGradient');\n let i = existingGrads.length;\n const radAttrs = ['r', 'cx', 'cy', 'fx', 'fy'];\n while (i--) {\n const og = existingGrads[i];\n if (grad.tagName === 'linearGradient') {\n if (grad.getAttribute('x1') !== og.getAttribute('x1') ||\n grad.getAttribute('y1') !== og.getAttribute('y1') ||\n grad.getAttribute('x2') !== og.getAttribute('x2') ||\n grad.getAttribute('y2') !== og.getAttribute('y2')\n ) {\n continue;\n }\n } else {\n const gradAttrs = $(grad).attr(radAttrs);\n const ogAttrs = $(og).attr(radAttrs);\n\n let diff = false;\n $.each(radAttrs, function (j, attr) {\n if (gradAttrs[attr] !== ogAttrs[attr]) { diff = true; }\n });\n\n if (diff) { continue; }\n }\n\n // else could be a duplicate, iterate through stops\n const stops = grad.getElementsByTagNameNS(NS.SVG, 'stop');\n const ostops = og.getElementsByTagNameNS(NS.SVG, 'stop');\n\n if (stops.length !== ostops.length) {\n continue;\n }\n\n let j = stops.length;\n while (j--) {\n const stop = stops[j];\n const ostop = ostops[j];\n\n if (stop.getAttribute('offset') !== ostop.getAttribute('offset') ||\n stop.getAttribute('stop-opacity') !== ostop.getAttribute('stop-opacity') ||\n stop.getAttribute('stop-color') !== ostop.getAttribute('stop-color')) {\n break;\n }\n }\n\n if (j === -1) {\n return og;\n }\n } // for each gradient in defs\n\n return null;\n };\n\n /**\n* Set a color/gradient to a fill/stroke.\n* @function module:svgcanvas.SvgCanvas#setPaint\n* @param {\"fill\"|\"stroke\"} type - String with \"fill\" or \"stroke\"\n* @param {module:jGraduate.jGraduatePaintOptions} paint - The jGraduate paint object to apply\n* @returns {void}\n*/\n this.setPaint = function (type, paint) {\n // make a copy\n const p = new $.jGraduate.Paint(paint);\n this.setPaintOpacity(type, p.alpha / 100, true);\n\n // now set the current paint object\n curProperties[type + '_paint'] = p;\n switch (p.type) {\n case 'solidColor':\n this.setColor(type, p.solidColor !== 'none' ? '#' + p.solidColor : 'none');\n break;\n case 'linearGradient':\n case 'radialGradient':\n canvas[type + 'Grad'] = p[p.type];\n setGradient(type);\n break;\n }\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#setStrokePaint\n* @param {module:jGraduate~Paint} paint\n* @returns {void}\n*/\n this.setStrokePaint = function (paint) {\n this.setPaint('stroke', paint);\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#setFillPaint\n* @param {module:jGraduate~Paint} paint\n* @returns {void}\n*/\n this.setFillPaint = function (paint) {\n this.setPaint('fill', paint);\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#getStrokeWidth\n* @returns {Float|string} The current stroke-width value\n*/\n this.getStrokeWidth = function () {\n return curProperties.stroke_width;\n };\n\n /**\n* Sets the stroke width for the current selected elements.\n* When attempting to set a line's width to 0, this changes it to 1 instead.\n* @function module:svgcanvas.SvgCanvas#setStrokeWidth\n* @param {Float} val - A Float indicating the new stroke width value\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {void}\n*/\n this.setStrokeWidth = function (val) {\n if (val === 0 && ['line', 'path'].includes(currentMode)) {\n canvas.setStrokeWidth(1);\n return;\n }\n curProperties.stroke_width = val;\n\n const elems = [];\n /**\n *\n * @param {Element} e\n * @returns {void}\n */\n function addNonG (e) {\n if (e.nodeName !== 'g') {\n elems.push(e);\n }\n }\n let i = selectedElements.length;\n while (i--) {\n const elem = selectedElements[i];\n if (elem) {\n if (elem.tagName === 'g') {\n walkTree(elem, addNonG);\n } else {\n elems.push(elem);\n }\n }\n }\n if (elems.length > 0) {\n changeSelectedAttribute('stroke-width', val, elems);\n call('changed', selectedElements);\n }\n };\n\n /**\n* Set the given stroke-related attribute the given value for selected elements.\n* @function module:svgcanvas.SvgCanvas#setStrokeAttr\n* @param {string} attr - String with the attribute name\n* @param {string|Float} val - String or number with the attribute value\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {void}\n*/\n this.setStrokeAttr = function (attr, val) {\n curShape[attr.replace('-', '_')] = val;\n const elems = [];\n\n let i = selectedElements.length;\n while (i--) {\n const elem = selectedElements[i];\n if (elem) {\n if (elem.tagName === 'g') {\n walkTree(elem, function (e) { if (e.nodeName !== 'g') { elems.push(e); } });\n } else {\n elems.push(elem);\n }\n }\n }\n if (elems.length > 0) {\n changeSelectedAttribute(attr, val, elems);\n call('changed', selectedElements);\n }\n };\n\n /**\n* @typedef {PlainObject} module:svgcanvas.StyleOptions\n* @property {string} fill\n* @property {Float} fill_opacity\n* @property {string} stroke\n* @property {Float} stroke_width\n* @property {string} stroke_dasharray\n* @property {string} stroke_linejoin\n* @property {string} stroke_linecap\n* @property {Float} stroke_opacity\n* @property {Float} opacity\n*/\n\n /**\n* @function module:svgcanvas.SvgCanvas#getStyle\n* @returns {module:svgcanvas.StyleOptions} current style options\n*/\n this.getStyle = function () {\n return curShape;\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#getOpacity\n* @returns {Float} the current opacity\n*/\n this.getOpacity = getOpacity;\n\n /**\n* Sets the given opacity on the current selected elements.\n* @function module:svgcanvas.SvgCanvas#setOpacity\n* @param {string} val\n* @returns {void}\n*/\n this.setOpacity = function (val) {\n curShape.opacity = val;\n changeSelectedAttribute('opacity', val);\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#getFillOpacity\n* @returns {Float} the current fill opacity\n*/\n this.getFillOpacity = function () {\n return curShape.fill_opacity;\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#getStrokeOpacity\n* @returns {string} the current stroke opacity\n*/\n this.getStrokeOpacity = function () {\n return curShape.stroke_opacity;\n };\n\n /**\n* Sets the current fill/stroke opacity.\n* @function module:svgcanvas.SvgCanvas#setPaintOpacity\n* @param {string} type - String with \"fill\" or \"stroke\"\n* @param {Float} val - Float with the new opacity value\n* @param {boolean} preventUndo - Indicates whether or not this should be an undoable action\n* @returns {void}\n*/\n this.setPaintOpacity = function (type, val, preventUndo) {\n curShape[type + '_opacity'] = val;\n if (!preventUndo) {\n changeSelectedAttribute(type + '-opacity', val);\n } else {\n changeSelectedAttributeNoUndo(type + '-opacity', val);\n }\n };\n\n /**\n* Gets the current fill/stroke opacity.\n* @function module:svgcanvas.SvgCanvas#getPaintOpacity\n* @param {\"fill\"|\"stroke\"} type - String with \"fill\" or \"stroke\"\n* @returns {Float} Fill/stroke opacity\n*/\n this.getPaintOpacity = function (type) {\n return type === 'fill' ? this.getFillOpacity() : this.getStrokeOpacity();\n };\n\n /**\n* Gets the `stdDeviation` blur value of the given element.\n* @function module:svgcanvas.SvgCanvas#getBlur\n* @param {Element} elem - The element to check the blur value for\n* @returns {string} stdDeviation blur attribute value\n*/\n this.getBlur = function (elem) {\n let val = 0;\n // const elem = selectedElements[0];\n\n if (elem) {\n const filterUrl = elem.getAttribute('filter');\n if (filterUrl) {\n const blur = getElem(elem.id + '_blur');\n if (blur) {\n val = blur.firstChild.getAttribute('stdDeviation');\n }\n }\n }\n return val;\n };\n\n (function () {\n let curCommand = null;\n let filter = null;\n let filterHidden = false;\n\n /**\n* Sets the `stdDeviation` blur value on the selected element without being undoable.\n* @function module:svgcanvas.SvgCanvas#setBlurNoUndo\n* @param {Float} val - The new `stdDeviation` value\n* @returns {void}\n*/\n canvas.setBlurNoUndo = function (val) {\n if (!filter) {\n canvas.setBlur(val);\n return;\n }\n if (val === 0) {\n // Don't change the StdDev, as that will hide the element.\n // Instead, just remove the value for \"filter\"\n changeSelectedAttributeNoUndo('filter', '');\n filterHidden = true;\n } else {\n const elem = selectedElements[0];\n if (filterHidden) {\n changeSelectedAttributeNoUndo('filter', 'url(#' + elem.id + '_blur)');\n }\n if (isWebkit()) {\n // console.log('e', elem); // eslint-disable-line no-console\n elem.removeAttribute('filter');\n elem.setAttribute('filter', 'url(#' + elem.id + '_blur)');\n }\n changeSelectedAttributeNoUndo('stdDeviation', val, [filter.firstChild]);\n canvas.setBlurOffsets(filter, val);\n }\n };\n\n /**\n *\n * @returns {void}\n */\n function finishChange () {\n const bCmd = canvas.undoMgr.finishUndoableChange();\n curCommand.addSubCommand(bCmd);\n addCommandToHistory(curCommand);\n curCommand = null;\n filter = null;\n }\n\n /**\n* Sets the `x`, `y`, `width`, `height` values of the filter element in order to\n* make the blur not be clipped. Removes them if not neeeded.\n* @function module:svgcanvas.SvgCanvas#setBlurOffsets\n* @param {Element} filterElem - The filter DOM element to update\n* @param {Float} stdDev - The standard deviation value on which to base the offset size\n* @returns {void}\n*/\n canvas.setBlurOffsets = function (filterElem, stdDev) {\n if (stdDev > 3) {\n // TODO: Create algorithm here where size is based on expected blur\n assignAttributes(filterElem, {\n x: '-50%',\n y: '-50%',\n width: '200%',\n height: '200%'\n }, 100);\n // Removing these attributes hides text in Chrome (see Issue 579)\n } else if (!isWebkit()) {\n filterElem.removeAttribute('x');\n filterElem.removeAttribute('y');\n filterElem.removeAttribute('width');\n filterElem.removeAttribute('height');\n }\n };\n\n /**\n* Adds/updates the blur filter to the selected element.\n* @function module:svgcanvas.SvgCanvas#setBlur\n* @param {Float} val - Float with the new `stdDeviation` blur value\n* @param {boolean} complete - Whether or not the action should be completed (to add to the undo manager)\n* @returns {void}\n*/\n canvas.setBlur = function (val, complete) {\n if (curCommand) {\n finishChange();\n return;\n }\n\n // Looks for associated blur, creates one if not found\n const elem = selectedElements[0];\n const elemId = elem.id;\n filter = getElem(elemId + '_blur');\n\n val -= 0;\n\n const batchCmd = new BatchCommand();\n\n // Blur found!\n if (filter) {\n if (val === 0) {\n filter = null;\n }\n } else {\n // Not found, so create\n const newblur = addSVGElementFromJson({element: 'feGaussianBlur',\n attr: {\n in: 'SourceGraphic',\n stdDeviation: val\n }\n });\n\n filter = addSVGElementFromJson({element: 'filter',\n attr: {\n id: elemId + '_blur'\n }\n });\n\n filter.append(newblur);\n findDefs().append(filter);\n\n batchCmd.addSubCommand(new InsertElementCommand(filter));\n }\n\n const changes = {filter: elem.getAttribute('filter')};\n\n if (val === 0) {\n elem.removeAttribute('filter');\n batchCmd.addSubCommand(new ChangeElementCommand(elem, changes));\n return;\n }\n\n changeSelectedAttribute('filter', 'url(#' + elemId + '_blur)');\n batchCmd.addSubCommand(new ChangeElementCommand(elem, changes));\n canvas.setBlurOffsets(filter, val);\n\n curCommand = batchCmd;\n canvas.undoMgr.beginUndoableChange('stdDeviation', [filter ? filter.firstChild : null]);\n if (complete) {\n canvas.setBlurNoUndo(val);\n finishChange();\n }\n };\n }());\n\n /**\n* Check whether selected element is bold or not.\n* @function module:svgcanvas.SvgCanvas#getBold\n* @returns {boolean} Indicates whether or not element is bold\n*/\n this.getBold = function () {\n // should only have one element selected\n const selected = selectedElements[0];\n if (!isNullish(selected) && selected.tagName === 'text' &&\n isNullish(selectedElements[1])) {\n return (selected.getAttribute('font-weight') === 'bold');\n }\n return false;\n };\n\n /**\n* Make the selected element bold or normal.\n* @function module:svgcanvas.SvgCanvas#setBold\n* @param {boolean} b - Indicates bold (`true`) or normal (`false`)\n* @returns {void}\n*/\n this.setBold = function (b) {\n const selected = selectedElements[0];\n if (!isNullish(selected) && selected.tagName === 'text' &&\n isNullish(selectedElements[1])) {\n changeSelectedAttribute('font-weight', b ? 'bold' : 'normal');\n }\n if (!selectedElements[0].textContent) {\n textActions.setCursor();\n }\n };\n\n /**\n* Check whether selected element is in italics or not.\n* @function module:svgcanvas.SvgCanvas#getItalic\n* @returns {boolean} Indicates whether or not element is italic\n*/\n this.getItalic = function () {\n const selected = selectedElements[0];\n if (!isNullish(selected) && selected.tagName === 'text' &&\n isNullish(selectedElements[1])) {\n return (selected.getAttribute('font-style') === 'italic');\n }\n return false;\n };\n\n /**\n* Make the selected element italic or normal.\n* @function module:svgcanvas.SvgCanvas#setItalic\n* @param {boolean} i - Indicates italic (`true`) or normal (`false`)\n* @returns {void}\n*/\n this.setItalic = function (i) {\n const selected = selectedElements[0];\n if (!isNullish(selected) && selected.tagName === 'text' &&\n isNullish(selectedElements[1])) {\n changeSelectedAttribute('font-style', i ? 'italic' : 'normal');\n }\n if (!selectedElements[0].textContent) {\n textActions.setCursor();\n }\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#getFontFamily\n* @returns {string} The current font family\n*/\n this.getFontFamily = function () {\n return curText.font_family;\n };\n\n /**\n* Set the new font family.\n* @function module:svgcanvas.SvgCanvas#setFontFamily\n* @param {string} val - String with the new font family\n* @returns {void}\n*/\n this.setFontFamily = function (val) {\n curText.font_family = val;\n changeSelectedAttribute('font-family', val);\n if (selectedElements[0] && !selectedElements[0].textContent) {\n textActions.setCursor();\n }\n };\n\n /**\n* Set the new font color.\n* @function module:svgcanvas.SvgCanvas#setFontColor\n* @param {string} val - String with the new font color\n* @returns {void}\n*/\n this.setFontColor = function (val) {\n curText.fill = val;\n changeSelectedAttribute('fill', val);\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#getFontColor\n* @returns {string} The current font color\n*/\n this.getFontColor = function () {\n return curText.fill;\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#getFontSize\n* @returns {Float} The current font size\n*/\n this.getFontSize = function () {\n return curText.font_size;\n };\n\n /**\n* Applies the given font size to the selected element.\n* @function module:svgcanvas.SvgCanvas#setFontSize\n* @param {Float} val - Float with the new font size\n* @returns {void}\n*/\n this.setFontSize = function (val) {\n curText.font_size = val;\n changeSelectedAttribute('font-size', val);\n if (!selectedElements[0].textContent) {\n textActions.setCursor();\n }\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#getText\n* @returns {string} The current text (`textContent`) of the selected element\n*/\n this.getText = function () {\n const selected = selectedElements[0];\n if (isNullish(selected)) { return ''; }\n return selected.textContent;\n };\n\n /**\n* Updates the text element with the given string.\n* @function module:svgcanvas.SvgCanvas#setTextContent\n* @param {string} val - String with the new text\n* @returns {void}\n*/\n this.setTextContent = function (val) {\n changeSelectedAttribute('#text', val);\n textActions.init(val);\n textActions.setCursor();\n };\n\n /**\n* Sets the new image URL for the selected image element. Updates its size if\n* a new URL is given.\n* @function module:svgcanvas.SvgCanvas#setImageURL\n* @param {string} val - String with the image URL/path\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {void}\n*/\n this.setImageURL = function (val) {\n const elem = selectedElements[0];\n if (!elem) { return; }\n\n const attrs = $(elem).attr(['width', 'height']);\n const setsize = (!attrs.width || !attrs.height);\n\n const curHref = getHref(elem);\n\n // Do nothing if no URL change or size change\n if (curHref === val && !setsize) {\n return;\n }\n\n const batchCmd = new BatchCommand('Change Image URL');\n\n setHref(elem, val);\n batchCmd.addSubCommand(new ChangeElementCommand(elem, {\n '#href': curHref\n }));\n\n $(new Image()).load(function () {\n const changes = $(elem).attr(['width', 'height']);\n\n $(elem).attr({\n width: this.width,\n height: this.height\n });\n\n selectorManager.requestSelector(elem).resize();\n\n batchCmd.addSubCommand(new ChangeElementCommand(elem, changes));\n addCommandToHistory(batchCmd);\n call('changed', [elem]);\n }).attr('src', val);\n };\n\n /**\n* Sets the new link URL for the selected anchor element.\n* @function module:svgcanvas.SvgCanvas#setLinkURL\n* @param {string} val - String with the link URL/path\n* @returns {void}\n*/\n this.setLinkURL = function (val) {\n let elem = selectedElements[0];\n if (!elem) { return; }\n if (elem.tagName !== 'a') {\n // See if parent is an anchor\n const parentsA = $(elem).parents('a');\n if (parentsA.length) {\n elem = parentsA[0];\n } else {\n return;\n }\n }\n\n const curHref = getHref(elem);\n\n if (curHref === val) { return; }\n\n const batchCmd = new BatchCommand('Change Link URL');\n\n setHref(elem, val);\n batchCmd.addSubCommand(new ChangeElementCommand(elem, {\n '#href': curHref\n }));\n\n addCommandToHistory(batchCmd);\n };\n\n /**\n* Sets the `rx` and `ry` values to the selected `rect` element\n* to change its corner radius.\n* @function module:svgcanvas.SvgCanvas#setRectRadius\n* @param {string|Float} val - The new radius\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {void}\n*/\n this.setRectRadius = function (val) {\n const selected = selectedElements[0];\n if (!isNullish(selected) && selected.tagName === 'rect') {\n const r = selected.getAttribute('rx');\n if (r !== String(val)) {\n selected.setAttribute('rx', val);\n selected.setAttribute('ry', val);\n addCommandToHistory(new ChangeElementCommand(selected, {rx: r, ry: r}, 'Radius'));\n call('changed', [selected]);\n }\n }\n };\n\n /**\n* Wraps the selected element(s) in an anchor element or converts group to one.\n* @function module:svgcanvas.SvgCanvas#makeHyperlink\n* @param {string} url\n* @returns {void}\n*/\n this.makeHyperlink = function (url) {\n canvas.groupSelectedElements('a', url);\n\n // TODO: If element is a single \"g\", convert to \"a\"\n // if (selectedElements.length > 1 && selectedElements[1]) {\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#removeHyperlink\n* @returns {void}\n*/\n this.removeHyperlink = function () {\n canvas.ungroupSelectedElement();\n };\n\n /**\n* Group: Element manipulation.\n*/\n\n /**\n* Sets the new segment type to the selected segment(s).\n* @function module:svgcanvas.SvgCanvas#setSegType\n* @param {Integer} newType - New segment type. See {@link https://www.w3.org/TR/SVG/paths.html#InterfaceSVGPathSeg} for list\n* @returns {void}\n*/\n this.setSegType = function (newType) {\n pathActions.setSegType(newType);\n };\n\n /**\n* Convert selected element to a path, or get the BBox of an element-as-path.\n* @function module:svgcanvas.SvgCanvas#convertToPath\n* @todo (codedread): Remove the getBBox argument and split this function into two.\n* @param {Element} elem - The DOM element to be converted\n* @param {boolean} getBBox - Boolean on whether or not to only return the path's BBox\n* @returns {void|DOMRect|false|SVGPathElement|null} If the getBBox flag is true, the resulting path's bounding box object.\n* Otherwise the resulting path element is returned.\n*/\n this.convertToPath = function (elem, getBBox) {\n if (isNullish(elem)) {\n const elems = selectedElements;\n $.each(elems, function (i, el) {\n if (el) { canvas.convertToPath(el); }\n });\n return undefined;\n }\n if (getBBox) {\n return getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions);\n }\n // TODO: Why is this applying attributes from curShape, then inside utilities.convertToPath it's pulling addition attributes from elem?\n // TODO: If convertToPath is called with one elem, curShape and elem are probably the same; but calling with multiple is a bug or cool feature.\n const attrs = {\n fill: curShape.fill,\n 'fill-opacity': curShape.fill_opacity,\n stroke: curShape.stroke,\n 'stroke-width': curShape.stroke_width,\n 'stroke-dasharray': curShape.stroke_dasharray,\n 'stroke-linejoin': curShape.stroke_linejoin,\n 'stroke-linecap': curShape.stroke_linecap,\n 'stroke-opacity': curShape.stroke_opacity,\n opacity: curShape.opacity,\n visibility: 'hidden'\n };\n return convertToPath(\n elem, attrs, addSVGElementFromJson, pathActions,\n clearSelection, addToSelection, hstry, addCommandToHistory\n );\n };\n\n /**\n* This function makes the changes to the elements. It does not add the change\n* to the history stack.\n* @param {string} attr - Attribute name\n* @param {string|Float} newValue - String or number with the new attribute value\n* @param {Element[]} elems - The DOM elements to apply the change to\n* @returns {void}\n*/\n const changeSelectedAttributeNoUndo = function (attr, newValue, elems) {\n if (currentMode === 'pathedit') {\n // Editing node\n pathActions.moveNode(attr, newValue);\n }\n elems = elems || selectedElements;\n let i = elems.length;\n const noXYElems = ['g', 'polyline', 'path'];\n // const goodGAttrs = ['transform', 'opacity', 'filter'];\n\n while (i--) {\n let elem = elems[i];\n if (isNullish(elem)) { continue; }\n\n // Set x,y vals on elements that don't have them\n if ((attr === 'x' || attr === 'y') && noXYElems.includes(elem.tagName)) {\n const bbox = getStrokedBBoxDefaultVisible([elem]);\n const diffX = attr === 'x' ? newValue - bbox.x : 0;\n const diffY = attr === 'y' ? newValue - bbox.y : 0;\n canvas.moveSelectedElements(diffX * currentZoom, diffY * currentZoom, true);\n continue;\n }\n\n // only allow the transform/opacity/filter attribute to change on <g> elements, slightly hacky\n // TODO: Missing statement body\n // if (elem.tagName === 'g' && goodGAttrs.includes(attr)) {}\n let oldval = attr === '#text' ? elem.textContent : elem.getAttribute(attr);\n if (isNullish(oldval)) { oldval = ''; }\n if (oldval !== String(newValue)) {\n if (attr === '#text') {\n // const oldW = utilsGetBBox(elem).width;\n elem.textContent = newValue;\n\n // FF bug occurs on on rotated elements\n if ((/rotate/).test(elem.getAttribute('transform'))) {\n elem = ffClone(elem);\n }\n // Hoped to solve the issue of moving text with text-anchor=\"start\",\n // but this doesn't actually fix it. Hopefully on the right track, though. -Fyrd\n // const box = getBBox(elem), left = box.x, top = box.y, {width, height} = box,\n // dx = width - oldW, dy = 0;\n // const angle = getRotationAngle(elem, true);\n // if (angle) {\n // const r = Math.sqrt(dx * dx + dy * dy);\n // const theta = Math.atan2(dy, dx) - angle;\n // dx = r * Math.cos(theta);\n // dy = r * Math.sin(theta);\n //\n // elem.setAttribute('x', elem.getAttribute('x') - dx);\n // elem.setAttribute('y', elem.getAttribute('y') - dy);\n // }\n } else if (attr === '#href') {\n setHref(elem, newValue);\n } else { elem.setAttribute(attr, newValue); }\n\n // Go into \"select\" mode for text changes\n // NOTE: Important that this happens AFTER elem.setAttribute() or else attributes like\n // font-size can get reset to their old value, ultimately by svgEditor.updateContextPanel(),\n // after calling textActions.toSelectMode() below\n if (currentMode === 'textedit' && attr !== '#text' && elem.textContent.length) {\n textActions.toSelectMode(elem);\n }\n\n // if (i === 0) {\n // selectedBBoxes[0] = utilsGetBBox(elem);\n // }\n\n // Use the Firefox ffClone hack for text elements with gradients or\n // where other text attributes are changed.\n if (isGecko() && elem.nodeName === 'text' && (/rotate/).test(elem.getAttribute('transform'))) {\n if (\n String(newValue).startsWith('url') || (['font-size', 'font-family', 'x', 'y'].includes(attr) && elem.textContent)\n ) {\n elem = ffClone(elem);\n }\n }\n // Timeout needed for Opera & Firefox\n // codedread: it is now possible for this function to be called with elements\n // that are not in the selectedElements array, we need to only request a\n // selector if the element is in that array\n if (selectedElements.includes(elem)) {\n setTimeout(function () {\n // Due to element replacement, this element may no longer\n // be part of the DOM\n if (!elem.parentNode) { return; }\n selectorManager.requestSelector(elem).resize();\n }, 0);\n }\n // if this element was rotated, and we changed the position of this element\n // we need to update the rotational transform attribute\n const angle = getRotationAngle(elem);\n if (angle !== 0 && attr !== 'transform') {\n const tlist = getTransformList(elem);\n let n = tlist.numberOfItems;\n while (n--) {\n const xform = tlist.getItem(n);\n if (xform.type === 4) {\n // remove old rotate\n tlist.removeItem(n);\n\n const box = utilsGetBBox(elem);\n const center = transformPoint(\n box.x + box.width / 2, box.y + box.height / 2, transformListToTransform(tlist).matrix\n );\n const cx = center.x,\n cy = center.y;\n const newrot = svgroot.createSVGTransform();\n newrot.setRotate(angle, cx, cy);\n tlist.insertItemBefore(newrot, n);\n break;\n }\n }\n }\n } // if oldValue != newValue\n } // for each elem\n };\n\n /**\n* Change the given/selected element and add the original value to the history stack.\n* If you want to change all `selectedElements`, ignore the `elems` argument.\n* If you want to change only a subset of `selectedElements`, then send the\n* subset to this function in the `elems` argument.\n* @function module:svgcanvas.SvgCanvas#changeSelectedAttribute\n* @param {string} attr - String with the attribute name\n* @param {string|Float} val - String or number with the new attribute value\n* @param {Element[]} elems - The DOM elements to apply the change to\n* @returns {void}\n*/\n const changeSelectedAttribute = this.changeSelectedAttribute = function (attr, val, elems) {\n elems = elems || selectedElements;\n canvas.undoMgr.beginUndoableChange(attr, elems);\n // const i = elems.length;\n\n changeSelectedAttributeNoUndo(attr, val, elems);\n\n const batchCmd = canvas.undoMgr.finishUndoableChange();\n if (!batchCmd.isEmpty()) {\n addCommandToHistory(batchCmd);\n }\n };\n\n /**\n* Removes all selected elements from the DOM and adds the change to the\n* history stack.\n* @function module:svgcanvas.SvgCanvas#deleteSelectedElements\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {void}\n*/\n this.deleteSelectedElements = function () {\n const batchCmd = new BatchCommand('Delete Elements');\n const len = selectedElements.length;\n const selectedCopy = []; // selectedElements is being deleted\n\n for (let i = 0; i < len; ++i) {\n const selected = selectedElements[i];\n if (isNullish(selected)) { break; }\n\n let parent = selected.parentNode;\n let t = selected;\n\n // this will unselect the element and remove the selectedOutline\n selectorManager.releaseSelector(t);\n\n // Remove the path if present.\n pathModule.removePath_(t.id);\n\n // Get the parent if it's a single-child anchor\n if (parent.tagName === 'a' && parent.childNodes.length === 1) {\n t = parent;\n parent = parent.parentNode;\n }\n\n const {nextSibling} = t;\n t.remove();\n const elem = t;\n selectedCopy.push(selected); // for the copy\n batchCmd.addSubCommand(new RemoveElementCommand(elem, nextSibling, parent));\n }\n selectedElements = [];\n\n if (!batchCmd.isEmpty()) { addCommandToHistory(batchCmd); }\n call('changed', selectedCopy);\n clearSelection();\n };\n\n /**\n* Removes all selected elements from the DOM and adds the change to the\n* history stack. Remembers removed elements on the clipboard.\n* @function module:svgcanvas.SvgCanvas#cutSelectedElements\n* @returns {void}\n*/\n this.cutSelectedElements = function () {\n canvas.copySelectedElements();\n canvas.deleteSelectedElements();\n };\n\n const CLIPBOARD_ID = 'svgedit_clipboard';\n\n /**\n* Flash the clipboard data momentarily on localStorage so all tabs can see.\n* @returns {void}\n*/\n function flashStorage () {\n const data = sessionStorage.getItem(CLIPBOARD_ID);\n localStorage.setItem(CLIPBOARD_ID, data);\n setTimeout(function () {\n localStorage.removeItem(CLIPBOARD_ID);\n }, 1);\n }\n\n /**\n* Transfers sessionStorage from one tab to another.\n* @param {!Event} ev Storage event.\n* @returns {void}\n*/\n function storageChange (ev) {\n if (!ev.newValue) return; // This is a call from removeItem.\n if (ev.key === CLIPBOARD_ID + '_startup') {\n // Another tab asked for our sessionStorage.\n localStorage.removeItem(CLIPBOARD_ID + '_startup');\n flashStorage();\n } else if (ev.key === CLIPBOARD_ID) {\n // Another tab sent data.\n sessionStorage.setItem(CLIPBOARD_ID, ev.newValue);\n }\n }\n\n // Listen for changes to localStorage.\n window.addEventListener('storage', storageChange, false);\n // Ask other tabs for sessionStorage (this is ONLY to trigger event).\n localStorage.setItem(CLIPBOARD_ID + '_startup', Math.random());\n\n /**\n* Remembers the current selected elements on the clipboard.\n* @function module:svgcanvas.SvgCanvas#copySelectedElements\n* @returns {void}\n*/\n this.copySelectedElements = function () {\n const data =\n JSON.stringify(selectedElements.map((x) => getJsonFromSvgElement(x)));\n // Use sessionStorage for the clipboard data.\n sessionStorage.setItem(CLIPBOARD_ID, data);\n flashStorage();\n\n const menu = $('#cmenu_canvas');\n // Context menu might not exist (it is provided by editor.js).\n if (menu.enableContextMenuItems) {\n menu.enableContextMenuItems('#paste,#paste_in_place');\n }\n };\n\n /**\n* @function module:svgcanvas.SvgCanvas#pasteElements\n* @param {\"in_place\"|\"point\"|void} type\n* @param {Integer|void} x Expected if type is \"point\"\n* @param {Integer|void} y Expected if type is \"point\"\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @fires module:svgcanvas.SvgCanvas#event:ext_IDsUpdated\n* @returns {void}\n*/\n this.pasteElements = function (type, x, y) {\n let clipb = JSON.parse(sessionStorage.getItem(CLIPBOARD_ID));\n if (!clipb) return;\n let len = clipb.length;\n if (!len) return;\n\n const pasted = [];\n const batchCmd = new BatchCommand('Paste elements');\n // const drawing = getCurrentDrawing();\n /**\n * @typedef {PlainObject<string, string>} module:svgcanvas.ChangedIDs\n */\n /**\n * @type {module:svgcanvas.ChangedIDs}\n */\n const changedIDs = {};\n\n // Recursively replace IDs and record the changes\n /**\n *\n * @param {module:svgcanvas.SVGAsJSON} elem\n * @returns {void}\n */\n function checkIDs (elem) {\n if (elem.attr && elem.attr.id) {\n changedIDs[elem.attr.id] = getNextId();\n elem.attr.id = changedIDs[elem.attr.id];\n }\n if (elem.children) elem.children.forEach((child) => checkIDs(child));\n }\n clipb.forEach((elem) => checkIDs(elem));\n\n // Give extensions like the connector extension a chance to reflect new IDs and remove invalid elements\n /**\n * Triggered when `pasteElements` is called from a paste action (context menu or key).\n * @event module:svgcanvas.SvgCanvas#event:ext_IDsUpdated\n * @type {PlainObject}\n * @property {module:svgcanvas.SVGAsJSON[]} elems\n * @property {module:svgcanvas.ChangedIDs} changes Maps past ID (on attribute) to current ID\n */\n runExtensions(\n 'IDsUpdated',\n /** @type {module:svgcanvas.SvgCanvas#event:ext_IDsUpdated} */\n {elems: clipb, changes: changedIDs},\n true\n ).forEach(function (extChanges) {\n if (!extChanges || !('remove' in extChanges)) return;\n\n extChanges.remove.forEach(function (removeID) {\n clipb = clipb.filter(function (clipBoardItem) {\n return clipBoardItem.attr.id !== removeID;\n });\n });\n });\n\n // Move elements to lastClickPoint\n while (len--) {\n const elem = clipb[len];\n if (!elem) { continue; }\n\n const copy = addSVGElementFromJson(elem);\n pasted.push(copy);\n batchCmd.addSubCommand(new InsertElementCommand(copy));\n\n restoreRefElems(copy);\n }\n\n selectOnly(pasted);\n\n if (type !== 'in_place') {\n let ctrX, ctrY;\n\n if (!type) {\n ctrX = lastClickPoint.x;\n ctrY = lastClickPoint.y;\n } else if (type === 'point') {\n ctrX = x;\n ctrY = y;\n }\n\n const bbox = getStrokedBBoxDefaultVisible(pasted);\n const cx = ctrX - (bbox.x + bbox.width / 2),\n cy = ctrY - (bbox.y + bbox.height / 2),\n dx = [],\n dy = [];\n\n $.each(pasted, function (i, item) {\n dx.push(cx);\n dy.push(cy);\n });\n\n const cmd = canvas.moveSelectedElements(dx, dy, false);\n if (cmd) batchCmd.addSubCommand(cmd);\n }\n\n addCommandToHistory(batchCmd);\n call('changed', pasted);\n };\n\n /**\n* Wraps all the selected elements in a group (`g`) element.\n* @function module:svgcanvas.SvgCanvas#groupSelectedElements\n* @param {\"a\"|\"g\"} [type=\"g\"] - type of element to group into, defaults to `<g>`\n* @param {string} [urlArg]\n* @returns {void}\n*/\n this.groupSelectedElements = function (type, urlArg) {\n if (!type) { type = 'g'; }\n let cmdStr = '';\n let url;\n\n switch (type) {\n case 'a': {\n cmdStr = 'Make hyperlink';\n url = urlArg || '';\n break;\n } default: {\n type = 'g';\n cmdStr = 'Group Elements';\n break;\n }\n }\n\n const batchCmd = new BatchCommand(cmdStr);\n\n // create and insert the group element\n const g = addSVGElementFromJson({\n element: type,\n attr: {\n id: getNextId()\n }\n });\n if (type === 'a') {\n setHref(g, url);\n }\n batchCmd.addSubCommand(new InsertElementCommand(g));\n\n // now move all children into the group\n let i = selectedElements.length;\n while (i--) {\n let elem = selectedElements[i];\n if (isNullish(elem)) { continue; }\n\n if (elem.parentNode.tagName === 'a' && elem.parentNode.childNodes.length === 1) {\n elem = elem.parentNode;\n }\n\n const oldNextSibling = elem.nextSibling;\n const oldParent = elem.parentNode;\n g.append(elem);\n batchCmd.addSubCommand(new MoveElementCommand(elem, oldNextSibling, oldParent));\n }\n if (!batchCmd.isEmpty()) { addCommandToHistory(batchCmd); }\n\n // update selection\n selectOnly([g], true);\n };\n\n /**\n* Pushes all appropriate parent group properties down to its children, then\n* removes them from the group.\n* @function module:svgcanvas.SvgCanvas#pushGroupProperties\n* @param {SVGAElement|SVGGElement} g\n* @param {boolean} undoable\n* @returns {BatchCommand|void}\n*/\n const pushGroupProperties = this.pushGroupProperties = function (g, undoable) {\n const children = g.childNodes;\n const len = children.length;\n const xform = g.getAttribute('transform');\n\n const glist = getTransformList(g);\n const m = transformListToTransform(glist).matrix;\n\n const batchCmd = new BatchCommand('Push group properties');\n\n // TODO: get all fill/stroke properties from the group that we are about to destroy\n // \"fill\", \"fill-opacity\", \"fill-rule\", \"stroke\", \"stroke-dasharray\", \"stroke-dashoffset\",\n // \"stroke-linecap\", \"stroke-linejoin\", \"stroke-miterlimit\", \"stroke-opacity\",\n // \"stroke-width\"\n // and then for each child, if they do not have the attribute (or the value is 'inherit')\n // then set the child's attribute\n\n const gangle = getRotationAngle(g);\n\n const gattrs = $(g).attr(['filter', 'opacity']);\n let gfilter, gblur, changes;\n const drawing = getCurrentDrawing();\n\n for (let i = 0; i < len; i++) {\n const elem = children[i];\n\n if (elem.nodeType !== 1) { continue; }\n\n if (gattrs.opacity !== null && gattrs.opacity !== 1) {\n // const c_opac = elem.getAttribute('opacity') || 1;\n const newOpac = Math.round((elem.getAttribute('opacity') || 1) * gattrs.opacity * 100) / 100;\n changeSelectedAttribute('opacity', newOpac, [elem]);\n }\n\n if (gattrs.filter) {\n let cblur = this.getBlur(elem);\n const origCblur = cblur;\n if (!gblur) { gblur = this.getBlur(g); }\n if (cblur) {\n // Is this formula correct?\n cblur = Number(gblur) + Number(cblur);\n } else if (cblur === 0) {\n cblur = gblur;\n }\n\n // If child has no current filter, get group's filter or clone it.\n if (!origCblur) {\n // Set group's filter to use first child's ID\n if (!gfilter) {\n gfilter = getRefElem(gattrs.filter);\n } else {\n // Clone the group's filter\n gfilter = drawing.copyElem(gfilter);\n findDefs().append(gfilter);\n }\n } else {\n gfilter = getRefElem(elem.getAttribute('filter'));\n }\n\n // Change this in future for different filters\n const suffix = (gfilter.firstChild.tagName === 'feGaussianBlur') ? 'blur' : 'filter';\n gfilter.id = elem.id + '_' + suffix;\n changeSelectedAttribute('filter', 'url(#' + gfilter.id + ')', [elem]);\n\n // Update blur value\n if (cblur) {\n changeSelectedAttribute('stdDeviation', cblur, [gfilter.firstChild]);\n canvas.setBlurOffsets(gfilter, cblur);\n }\n }\n\n let chtlist = getTransformList(elem);\n\n // Don't process gradient transforms\n if (elem.tagName.includes('Gradient')) { chtlist = null; }\n\n // Hopefully not a problem to add this. Necessary for elements like <desc/>\n if (!chtlist) { continue; }\n\n // Apparently <defs> can get get a transformlist, but we don't want it to have one!\n if (elem.tagName === 'defs') { continue; }\n\n if (glist.numberOfItems) {\n // TODO: if the group's transform is just a rotate, we can always transfer the\n // rotate() down to the children (collapsing consecutive rotates and factoring\n // out any translates)\n if (gangle && glist.numberOfItems === 1) {\n // [Rg] [Rc] [Mc]\n // we want [Tr] [Rc2] [Mc] where:\n // - [Rc2] is at the child's current center but has the\n // sum of the group and child's rotation angles\n // - [Tr] is the equivalent translation that this child\n // undergoes if the group wasn't there\n\n // [Tr] = [Rg] [Rc] [Rc2_inv]\n\n // get group's rotation matrix (Rg)\n const rgm = glist.getItem(0).matrix;\n\n // get child's rotation matrix (Rc)\n let rcm = svgroot.createSVGMatrix();\n const cangle = getRotationAngle(elem);\n if (cangle) {\n rcm = chtlist.getItem(0).matrix;\n }\n\n // get child's old center of rotation\n const cbox = utilsGetBBox(elem);\n const ceqm = transformListToTransform(chtlist).matrix;\n const coldc = transformPoint(cbox.x + cbox.width / 2, cbox.y + cbox.height / 2, ceqm);\n\n // sum group and child's angles\n const sangle = gangle + cangle;\n\n // get child's rotation at the old center (Rc2_inv)\n const r2 = svgroot.createSVGTransform();\n r2.setRotate(sangle, coldc.x, coldc.y);\n\n // calculate equivalent translate\n const trm = matrixMultiply(rgm, rcm, r2.matrix.inverse());\n\n // set up tlist\n if (cangle) {\n chtlist.removeItem(0);\n }\n\n if (sangle) {\n if (chtlist.numberOfItems) {\n chtlist.insertItemBefore(r2, 0);\n } else {\n chtlist.appendItem(r2);\n }\n }\n\n if (trm.e || trm.f) {\n const tr = svgroot.createSVGTransform();\n tr.setTranslate(trm.e, trm.f);\n if (chtlist.numberOfItems) {\n chtlist.insertItemBefore(tr, 0);\n } else {\n chtlist.appendItem(tr);\n }\n }\n } else { // more complicated than just a rotate\n // transfer the group's transform down to each child and then\n // call recalculateDimensions()\n const oldxform = elem.getAttribute('transform');\n changes = {};\n changes.transform = oldxform || '';\n\n const newxform = svgroot.createSVGTransform();\n\n // [ gm ] [ chm ] = [ chm ] [ gm' ]\n // [ gm' ] = [ chmInv ] [ gm ] [ chm ]\n const chm = transformListToTransform(chtlist).matrix,\n chmInv = chm.inverse();\n const gm = matrixMultiply(chmInv, m, chm);\n newxform.setMatrix(gm);\n chtlist.appendItem(newxform);\n }\n const cmd = recalculateDimensions(elem);\n if (cmd) { batchCmd.addSubCommand(cmd); }\n }\n }\n\n // remove transform and make it undo-able\n if (xform) {\n changes = {};\n changes.transform = xform;\n g.setAttribute('transform', '');\n g.removeAttribute('transform');\n batchCmd.addSubCommand(new ChangeElementCommand(g, changes));\n }\n\n if (undoable && !batchCmd.isEmpty()) {\n return batchCmd;\n }\n return undefined;\n };\n\n /**\n* Unwraps all the elements in a selected group (`g`) element. This requires\n* significant recalculations to apply group's transforms, etc. to its children.\n* @function module:svgcanvas.SvgCanvas#ungroupSelectedElement\n* @returns {void}\n*/\n this.ungroupSelectedElement = function () {\n let g = selectedElements[0];\n if (!g) {\n return;\n }\n if ($(g).data('gsvg') || $(g).data('symbol')) {\n // Is svg, so actually convert to group\n convertToGroup(g);\n return;\n }\n if (g.tagName === 'use') {\n // Somehow doesn't have data set, so retrieve\n const symbol = getElem(getHref(g).substr(1));\n $(g).data('symbol', symbol).data('ref', symbol);\n convertToGroup(g);\n return;\n }\n const parentsA = $(g).parents('a');\n if (parentsA.length) {\n g = parentsA[0];\n }\n\n // Look for parent \"a\"\n if (g.tagName === 'g' || g.tagName === 'a') {\n const batchCmd = new BatchCommand('Ungroup Elements');\n const cmd = pushGroupProperties(g, true);\n if (cmd) { batchCmd.addSubCommand(cmd); }\n\n const parent = g.parentNode;\n const anchor = g.nextSibling;\n const children = new Array(g.childNodes.length);\n\n let i = 0;\n while (g.firstChild) {\n const elem = g.firstChild;\n const oldNextSibling = elem.nextSibling;\n const oldParent = elem.parentNode;\n\n // Remove child title elements\n if (elem.tagName === 'title') {\n const {nextSibling} = elem;\n batchCmd.addSubCommand(new RemoveElementCommand(elem, nextSibling, oldParent));\n elem.remove();\n continue;\n }\n\n if (anchor) {\n anchor.before(elem);\n } else {\n g.after(elem);\n }\n children[i++] = elem;\n batchCmd.addSubCommand(new MoveElementCommand(elem, oldNextSibling, oldParent));\n }\n\n // remove the group from the selection\n clearSelection();\n\n // delete the group element (but make undo-able)\n const gNextSibling = g.nextSibling;\n g.remove();\n batchCmd.addSubCommand(new RemoveElementCommand(g, gNextSibling, parent));\n\n if (!batchCmd.isEmpty()) { addCommandToHistory(batchCmd); }\n\n // update selection\n addToSelection(children);\n }\n };\n\n /**\n* Repositions the selected element to the bottom in the DOM to appear on top of\n* other elements.\n* @function module:svgcanvas.SvgCanvas#moveToTopSelectedElement\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {void}\n*/\n this.moveToTopSelectedElement = function () {\n const [selected] = selectedElements;\n if (!isNullish(selected)) {\n let t = selected;\n const oldParent = t.parentNode;\n const oldNextSibling = t.nextSibling;\n t = t.parentNode.appendChild(t);\n // If the element actually moved position, add the command and fire the changed\n // event handler.\n if (oldNextSibling !== t.nextSibling) {\n addCommandToHistory(new MoveElementCommand(t, oldNextSibling, oldParent, 'top'));\n call('changed', [t]);\n }\n }\n };\n\n /**\n* Repositions the selected element to the top in the DOM to appear under\n* other elements.\n* @function module:svgcanvas.SvgCanvas#moveToBottomSelectedElement\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {void}\n*/\n this.moveToBottomSelectedElement = function () {\n const [selected] = selectedElements;\n if (!isNullish(selected)) {\n let t = selected;\n const oldParent = t.parentNode;\n const oldNextSibling = t.nextSibling;\n let {firstChild} = t.parentNode;\n if (firstChild.tagName === 'title') {\n firstChild = firstChild.nextSibling;\n }\n // This can probably be removed, as the defs should not ever apppear\n // inside a layer group\n if (firstChild.tagName === 'defs') {\n firstChild = firstChild.nextSibling;\n }\n t = t.parentNode.insertBefore(t, firstChild);\n // If the element actually moved position, add the command and fire the changed\n // event handler.\n if (oldNextSibling !== t.nextSibling) {\n addCommandToHistory(new MoveElementCommand(t, oldNextSibling, oldParent, 'bottom'));\n call('changed', [t]);\n }\n }\n };\n\n /**\n* Moves the select element up or down the stack, based on the visibly\n* intersecting elements.\n* @function module:svgcanvas.SvgCanvas#moveUpDownSelected\n* @param {\"Up\"|\"Down\"} dir - String that's either 'Up' or 'Down'\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {void}\n*/\n this.moveUpDownSelected = function (dir) {\n const selected = selectedElements[0];\n if (!selected) { return; }\n\n curBBoxes = [];\n let closest, foundCur;\n // jQuery sorts this list\n const list = $(getIntersectionList(getStrokedBBoxDefaultVisible([selected]))).toArray();\n if (dir === 'Down') { list.reverse(); }\n\n $.each(list, function () {\n if (!foundCur) {\n if (this === selected) {\n foundCur = true;\n }\n return true;\n }\n closest = this;\n return false;\n });\n if (!closest) { return; }\n\n const t = selected;\n const oldParent = t.parentNode;\n const oldNextSibling = t.nextSibling;\n $(closest)[dir === 'Down' ? 'before' : 'after'](t);\n // If the element actually moved position, add the command and fire the changed\n // event handler.\n if (oldNextSibling !== t.nextSibling) {\n addCommandToHistory(new MoveElementCommand(t, oldNextSibling, oldParent, 'Move ' + dir));\n call('changed', [t]);\n }\n };\n\n /**\n* Moves selected elements on the X/Y axis.\n* @function module:svgcanvas.SvgCanvas#moveSelectedElements\n* @param {Float} dx - Float with the distance to move on the x-axis\n* @param {Float} dy - Float with the distance to move on the y-axis\n* @param {boolean} undoable - Boolean indicating whether or not the action should be undoable\n* @fires module:svgcanvas.SvgCanvas#event:changed\n* @returns {BatchCommand|void} Batch command for the move\n*/\n this.moveSelectedElements = function (dx, dy, undoable) {\n // if undoable is not sent, default to true\n // if single values, scale them to the zoom\n if (dx.constructor !== Array) {\n dx /= currentZoom;\n dy /= currentZoom;\n }\n undoable = undoable || true;\n const batchCmd = new BatchCommand('position');\n let i = selectedElements.length;\n while (i--) {\n const selected = selectedElements[i];\n if (!isNullish(selected)) {\n // if (i === 0) {\n // selectedBBoxes[0] = utilsGetBBox(selected);\n // }\n // const b = {};\n // for (const j in selectedBBoxes[i]) b[j] = selectedBBoxes[i][j];\n // selectedBBoxes[i] = b;\n\n const xform = svgroot.createSVGTransform();\n const tlist = getTransformList(selected);\n\n // dx and dy could be arrays\n if (dx.constructor === Array) {\n // if (i === 0) {\n // selectedBBoxes[0].x += dx[0];\n // selectedBBoxes[0].y += dy[0];\n // }\n xform.setTranslate(dx[i], dy[i]);\n } else {\n // if (i === 0) {\n // selectedBBoxes[0].x += dx;\n // selectedBBoxes[0].y += dy;\n // }\n xform.setTranslate(dx, dy);\n }\n\n if (tlist.numberOfItems) {\n tlist.insertItemBefore(xform, 0);\n } else {\n tlist.appendItem(xform);\n }\n\n const cmd = recalculateDimensions(selected);\n if (cmd) {\n batchCmd.addSubCommand(cmd);\n }\n\n selectorManager.requestSelector(selected).resize();\n }\n }\n if (!batchCmd.isEmpty()) {\n if (undoable) {\n addCommandToHistory(batchCmd);\n }\n call('changed', selectedElements);\n return batchCmd;\n }\n return undefined;\n };\n\n /**\n* Create deep DOM copies (clones) of all selected elements and move them slightly\n* from their originals.\n* @function module:svgcanvas.SvgCanvas#cloneSelectedElements\n* @param {Float} x Float with the distance to move on the x-axis\n* @param {Float} y Float with the distance to move on the y-axis\n* @returns {void}\n*/\n this.cloneSelectedElements = function (x, y) {\n let i, elem;\n const batchCmd = new BatchCommand('Clone Elements');\n // find all the elements selected (stop at first null)\n const len = selectedElements.length;\n /**\n * Sorts an array numerically and ascending.\n * @param {Element} a\n * @param {Element} b\n * @returns {Integer}\n */\n function sortfunction (a, b) {\n return ($(b).index() - $(a).index());\n }\n selectedElements.sort(sortfunction);\n for (i = 0; i < len; ++i) {\n elem = selectedElements[i];\n if (isNullish(elem)) { break; }\n }\n // use slice to quickly get the subset of elements we need\n const copiedElements = selectedElements.slice(0, i);\n this.clearSelection(true);\n // note that we loop in the reverse way because of the way elements are added\n // to the selectedElements array (top-first)\n const drawing = getCurrentDrawing();\n i = copiedElements.length;\n while (i--) {\n // clone each element and replace it within copiedElements\n elem = copiedElements[i] = drawing.copyElem(copiedElements[i]);\n (currentGroup || drawing.getCurrentLayer()).append(elem);\n batchCmd.addSubCommand(new InsertElementCommand(elem));\n }\n\n if (!batchCmd.isEmpty()) {\n addToSelection(copiedElements.reverse()); // Need to reverse for correct selection-adding\n this.moveSelectedElements(x, y, false);\n addCommandToHistory(batchCmd);\n }\n };\n\n /**\n* Aligns selected elements.\n* @function module:svgcanvas.SvgCanvas#alignSelectedElements\n* @param {string} type - String with single character indicating the alignment type\n* @param {\"selected\"|\"largest\"|\"smallest\"|\"page\"} relativeTo\n* @returns {void}\n*/\n this.alignSelectedElements = function (type, relativeTo) {\n const bboxes = []; // angles = [];\n const len = selectedElements.length;\n if (!len) { return; }\n let minx = Number.MAX_VALUE, maxx = Number.MIN_VALUE,\n miny = Number.MAX_VALUE, maxy = Number.MIN_VALUE;\n let curwidth = Number.MIN_VALUE, curheight = Number.MIN_VALUE;\n for (let i = 0; i < len; ++i) {\n if (isNullish(selectedElements[i])) { break; }\n const elem = selectedElements[i];\n bboxes[i] = getStrokedBBoxDefaultVisible([elem]);\n\n // now bbox is axis-aligned and handles rotation\n switch (relativeTo) {\n case 'smallest':\n if (((type === 'l' || type === 'c' || type === 'r') &&\n (curwidth === Number.MIN_VALUE || curwidth > bboxes[i].width)) ||\n ((type === 't' || type === 'm' || type === 'b') &&\n (curheight === Number.MIN_VALUE || curheight > bboxes[i].height))\n ) {\n minx = bboxes[i].x;\n miny = bboxes[i].y;\n maxx = bboxes[i].x + bboxes[i].width;\n maxy = bboxes[i].y + bboxes[i].height;\n curwidth = bboxes[i].width;\n curheight = bboxes[i].height;\n }\n break;\n case 'largest':\n if (((type === 'l' || type === 'c' || type === 'r') &&\n (curwidth === Number.MIN_VALUE || curwidth < bboxes[i].width)) ||\n ((type === 't' || type === 'm' || type === 'b') &&\n (curheight === Number.MIN_VALUE || curheight < bboxes[i].height))\n ) {\n minx = bboxes[i].x;\n miny = bboxes[i].y;\n maxx = bboxes[i].x + bboxes[i].width;\n maxy = bboxes[i].y + bboxes[i].height;\n curwidth = bboxes[i].width;\n curheight = bboxes[i].height;\n }\n break;\n default: // 'selected'\n if (bboxes[i].x < minx) { minx = bboxes[i].x; }\n if (bboxes[i].y < miny) { miny = bboxes[i].y; }\n if (bboxes[i].x + bboxes[i].width > maxx) { maxx = bboxes[i].x + bboxes[i].width; }\n if (bboxes[i].y + bboxes[i].height > maxy) { maxy = bboxes[i].y + bboxes[i].height; }\n break;\n }\n } // loop for each element to find the bbox and adjust min/max\n\n if (relativeTo === 'page') {\n minx = 0;\n miny = 0;\n maxx = canvas.contentW;\n maxy = canvas.contentH;\n }\n\n const dx = new Array(len);\n const dy = new Array(len);\n for (let i = 0; i < len; ++i) {\n if (isNullish(selectedElements[i])) { break; }\n // const elem = selectedElements[i];\n const bbox = bboxes[i];\n dx[i] = 0;\n dy[i] = 0;\n switch (type) {\n case 'l': // left (horizontal)\n dx[i] = minx - bbox.x;\n break;\n case 'c': // center (horizontal)\n dx[i] = (minx + maxx) / 2 - (bbox.x + bbox.width / 2);\n break;\n case 'r': // right (horizontal)\n dx[i] = maxx - (bbox.x + bbox.width);\n break;\n case 't': // top (vertical)\n dy[i] = miny - bbox.y;\n break;\n case 'm': // middle (vertical)\n dy[i] = (miny + maxy) / 2 - (bbox.y + bbox.height / 2);\n break;\n case 'b': // bottom (vertical)\n dy[i] = maxy - (bbox.y + bbox.height);\n break;\n }\n }\n this.moveSelectedElements(dx, dy);\n };\n\n /**\n* Group: Additional editor tools.\n*/\n\n /**\n* @name module:svgcanvas.SvgCanvas#contentW\n* @type {Float}\n*/\n this.contentW = getResolution().w;\n /**\n* @name module:svgcanvas.SvgCanvas#contentH\n* @type {Float}\n*/\n this.contentH = getResolution().h;\n\n /**\n* @typedef {PlainObject} module:svgcanvas.CanvasInfo\n* @property {Float} x - The canvas' new x coordinate\n* @property {Float} y - The canvas' new y coordinate\n* @property {string} oldX - The canvas' old x coordinate\n* @property {string} oldY - The canvas' old y coordinate\n* @property {Float} d_x - The x position difference\n* @property {Float} d_y - The y position difference\n*/\n\n /**\n* Updates the editor canvas width/height/position after a zoom has occurred.\n* @function module:svgcanvas.SvgCanvas#updateCanvas\n* @param {Float} w - Float with the new width\n* @param {Float} h - Float with the new height\n* @fires module:svgcanvas.SvgCanvas#event:ext_canvasUpdated\n* @returns {module:svgcanvas.CanvasInfo}\n*/\n this.updateCanvas = function (w, h) {\n svgroot.setAttribute('width', w);\n svgroot.setAttribute('height', h);\n const bg = $('#canvasBackground')[0];\n const oldX = svgcontent.getAttribute('x');\n const oldY = svgcontent.getAttribute('y');\n const x = ((w - this.contentW * currentZoom) / 2);\n const y = ((h - this.contentH * currentZoom) / 2);\n\n assignAttributes(svgcontent, {\n width: this.contentW * currentZoom,\n height: this.contentH * currentZoom,\n x,\n y,\n viewBox: '0 0 ' + this.contentW + ' ' + this.contentH\n });\n\n assignAttributes(bg, {\n width: svgcontent.getAttribute('width'),\n height: svgcontent.getAttribute('height'),\n x,\n y\n });\n\n const bgImg = getElem('background_image');\n if (bgImg) {\n assignAttributes(bgImg, {\n width: '100%',\n height: '100%'\n });\n }\n\n selectorManager.selectorParentGroup.setAttribute('transform', 'translate(' + x + ',' + y + ')');\n\n /**\n * Invoked upon updates to the canvas.\n * @event module:svgcanvas.SvgCanvas#event:ext_canvasUpdated\n * @type {PlainObject}\n * @property {Integer} new_x\n * @property {Integer} new_y\n * @property {string} old_x (Of Integer)\n * @property {string} old_y (Of Integer)\n * @property {Integer} d_x\n * @property {Integer} d_y\n */\n runExtensions(\n 'canvasUpdated',\n /**\n * @type {module:svgcanvas.SvgCanvas#event:ext_canvasUpdated}\n */\n {new_x: x, new_y: y, old_x: oldX, old_y: oldY, d_x: x - oldX, d_y: y - oldY}\n );\n return {x, y, old_x: oldX, old_y: oldY, d_x: x - oldX, d_y: y - oldY};\n };\n\n /**\n* Set the background of the editor (NOT the actual document).\n* @function module:svgcanvas.SvgCanvas#setBackground\n* @param {string} color - String with fill color to apply\n* @param {string} url - URL or path to image to use\n* @returns {void}\n*/\n this.setBackground = function (color, url) {\n const bg = getElem('canvasBackground');\n const border = $(bg).find('rect')[0];\n let bgImg = getElem('background_image');\n let bgPattern = getElem('background_pattern');\n border.setAttribute('fill', color === 'chessboard' ? '#fff' : color);\n if (color === 'chessboard') {\n if (!bgPattern) {\n bgPattern = svgdoc.createElementNS(NS.SVG, 'foreignObject');\n assignAttributes(bgPattern, {\n id: 'background_pattern',\n width: '100%',\n height: '100%',\n preserveAspectRatio: 'xMinYMin',\n style: 'pointer-events:none'\n });\n const div = document.createElement('div');\n assignAttributes(div, {\n style: 'pointer-events:none;width:100%;height:100%;' +\n 'background-image:url(data:image/gif;base64,' +\n 'R0lGODlhEAAQAIAAAP///9bW1iH5BAAAAAAALAAAAAAQABAAAAIfjG+' +\n 'gq4jM3IFLJgpswNly/XkcBpIiVaInlLJr9FZWAQA7);'\n });\n bgPattern.appendChild(div);\n bg.append(bgPattern);\n }\n } else if (bgPattern) {\n bgPattern.remove();\n }\n if (url) {\n if (!bgImg) {\n bgImg = svgdoc.createElementNS(NS.SVG, 'image');\n assignAttributes(bgImg, {\n id: 'background_image',\n width: '100%',\n height: '100%',\n preserveAspectRatio: 'xMinYMin',\n style: 'pointer-events:none'\n });\n }\n setHref(bgImg, url);\n bg.append(bgImg);\n } else if (bgImg) {\n bgImg.remove();\n }\n };\n\n /**\n* Select the next/previous element within the current layer.\n* @function module:svgcanvas.SvgCanvas#cycleElement\n* @param {boolean} next - true = next and false = previous element\n* @fires module:svgcanvas.SvgCanvas#event:selected\n* @returns {void}\n*/\n this.cycleElement = function (next) {\n let num;\n const curElem = selectedElements[0];\n let elem = false;\n const allElems = getVisibleElements(currentGroup || getCurrentDrawing().getCurrentLayer());\n if (!allElems.length) { return; }\n if (isNullish(curElem)) {\n num = next ? allElems.length - 1 : 0;\n elem = allElems[num];\n } else {\n let i = allElems.length;\n while (i--) {\n if (allElems[i] === curElem) {\n num = next ? i - 1 : i + 1;\n if (num >= allElems.length) {\n num = 0;\n } else if (num < 0) {\n num = allElems.length - 1;\n }\n elem = allElems[num];\n break;\n }\n }\n }\n selectOnly([elem], true);\n call('selected', selectedElements);\n };\n\n this.clear();\n\n /**\n* @interface module:svgcanvas.PrivateMethods\n* @type {PlainObject}\n* @property {module:svgcanvas~addCommandToHistory} addCommandToHistory\n* @property {module:history.HistoryCommand} BatchCommand\n* @property {module:history.HistoryCommand} ChangeElementCommand\n* @property {module:utilities.decode64} decode64\n* @property {module:utilities.dropXMLInternalSubset} dropXMLInternalSubset\n* @property {module:utilities.encode64} encode64\n* @property {module:svgcanvas~ffClone} ffClone\n* @property {module:svgcanvas~findDuplicateGradient} findDuplicateGradient\n* @property {module:utilities.getPathBBox} getPathBBox\n* @property {module:units.getTypeMap} getTypeMap\n* @property {module:draw.identifyLayers} identifyLayers\n* @property {module:history.HistoryCommand} InsertElementCommand\n* @property {module:browser.isChrome} isChrome\n* @property {module:math.isIdentity} isIdentity\n* @property {module:browser.isIE} isIE\n* @property {module:svgcanvas~logMatrix} logMatrix\n* @property {module:history.HistoryCommand} MoveElementCommand\n* @property {module:namespaces.NS} NS\n* @property {module:utilities.preventClickDefault} preventClickDefault\n* @property {module:history.HistoryCommand} RemoveElementCommand\n* @property {module:SVGTransformList.SVGEditTransformList} SVGEditTransformList\n* @property {module:utilities.text2xml} text2xml\n* @property {module:math.transformBox} transformBox\n* @property {module:math.transformPoint} transformPoint\n* @property {module:utilities.walkTree} walkTree\n*/\n /**\n* @deprecated getPrivateMethods\n* Since all methods are/should be public somehow, this function should be removed;\n* we might require `import` in place of this in the future once ES6 Modules\n* widespread\n\n* Being able to access private methods publicly seems wrong somehow,\n* but currently appears to be the best way to allow testing and provide\n* access to them to plugins.\n* @function module:svgcanvas.SvgCanvas#getPrivateMethods\n* @returns {module:svgcanvas.PrivateMethods}\n*/\n this.getPrivateMethods = function () {\n const obj = {\n addCommandToHistory,\n BatchCommand,\n ChangeElementCommand,\n decode64,\n dropXMLInternalSubset,\n encode64,\n ffClone,\n findDefs,\n findDuplicateGradient,\n getElem,\n getPathBBox,\n getTypeMap,\n getUrlFromAttr,\n identifyLayers: draw.identifyLayers,\n InsertElementCommand,\n isChrome,\n isIdentity,\n isIE,\n logMatrix,\n MoveElementCommand,\n NS,\n preventClickDefault,\n RemoveElementCommand,\n SVGEditTransformList,\n text2xml,\n transformBox,\n transformPoint,\n walkTree\n };\n return obj;\n };\n } // End constructor\n} // End class\n\nexport default SvgCanvas;\n","// Todo: Update: https://github.com/jeresig/jquery.hotkeys\n/*\n * jQuery Hotkeys Plugin\n * Copyright 2010, John Resig\n * Dual licensed under the MIT or GPL Version 2 licenses.\n *\n * http://github.com/jeresig/jquery.hotkeys\n *\n * Based upon the plugin by Tzury Bar Yochay:\n * http://github.com/tzuryby/hotkeys\n *\n * Original idea by:\n * Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/\n*/\n\n// We *do* want to allow the escape key within textareas (and possibly tab too), so add the condition `n.which !== 27`\n\nexport default function(b){b.hotkeys={version:\"0.8\",specialKeys:{8:\"backspace\",9:\"tab\",13:\"return\",16:\"shift\",17:\"ctrl\",18:\"alt\",19:\"pause\",20:\"capslock\",27:\"esc\",32:\"space\",33:\"pageup\",34:\"pagedown\",35:\"end\",36:\"home\",37:\"left\",38:\"up\",39:\"right\",40:\"down\",45:\"insert\",46:\"del\",96:\"0\",97:\"1\",98:\"2\",99:\"3\",100:\"4\",101:\"5\",102:\"6\",103:\"7\",104:\"8\",105:\"9\",106:\"*\",107:\"+\",109:\"-\",110:\".\",111:\"/\",112:\"f1\",113:\"f2\",114:\"f3\",115:\"f4\",116:\"f5\",117:\"f6\",118:\"f7\",119:\"f8\",120:\"f9\",121:\"f10\",122:\"f11\",123:\"f12\",144:\"numlock\",145:\"scroll\",191:\"/\",224:\"meta\",219:\"[\",221:\"]\"},shiftNums:{\"`\":\"~\",\"1\":\"!\",\"2\":\"@\",\"3\":\"#\",\"4\":\"$\",\"5\":\"%\",\"6\":\"^\",\"7\":\"&\",\"8\":\"*\",\"9\":\"(\",\"0\":\")\",\"-\":\"_\",\"=\":\"+\",\";\":\": \",\"'\":'\"',\",\":\"<\",\".\":\">\",\"/\":\"?\",\"\\\\\":\"|\"}};function a(d){if(typeof d.data!==\"string\"){return}var c=d.handler,e=d.data.toLowerCase().split(\" \");d.handler=function(n){if(this!==n.target&&(n.which !== 27 && (/textarea|select/i.test(n.target.nodeName)||n.target.type===\"text\"))){return}var h=n.type!==\"keypress\"&&b.hotkeys.specialKeys[n.which],o=String.fromCharCode(n.which).toLowerCase(),k,m=\"\",g={};if(n.altKey&&h!==\"alt\"){m+=\"alt+\"}if(n.ctrlKey&&h!==\"ctrl\"){m+=\"ctrl+\"}if(n.metaKey&&!n.ctrlKey&&h!==\"meta\"){m+=\"meta+\"}if(n.shiftKey&&h!==\"shift\"){m+=\"shift+\"}if(h){g[m+h]=true}else{g[m+o]=true;g[m+b.hotkeys.shiftNums[o]]=true;if(m===\"shift+\"){g[b.hotkeys.shiftNums[o]]=true}}for(var j=0,f=e.length;j<f;j++){if(g[e[j]]){return c.apply(this,arguments)}}}}b.each([\"keydown\",\"keyup\",\"keypress\"],function(){b.event.special[this]={add:a}})\n\nreturn b;\n}\n","/**\n * @file SVG Icon Loader 2.0\n *\n * jQuery Plugin for loading SVG icons from a single file\n *\n * Adds {@link external:jQuery.svgIcons}, {@link external:jQuery.getSvgIcon}, {@link external:jQuery.resizeSvgIcons}\n *\n * How to use:\n\n1. Create the SVG master file that includes all icons:\n\nThe master SVG icon-containing file is an SVG file that contains\n`<g>` elements. Each `<g>` element should contain the markup of an SVG\nicon. The `<g>` element has an ID that should\ncorrespond with the ID of the HTML element used on the page that should contain\nor optionally be replaced by the icon. Additionally, one empty element should be\nadded at the end with id \"svg_eof\".\n\n2. Optionally create fallback raster images for each SVG icon.\n\n3. Include the jQuery and the SVG Icon Loader scripts on your page.\n\n4. Run `$.svgIcons()` when the document is ready. See its signature\n\n5. To access an icon at a later point without using the callback, use this:\n `$.getSvgIcon(id (string), uniqueClone (boolean))`;\n\nThis will return the icon (as jQuery object) with a given ID.\n\n6. To resize icons at a later point without using the callback, use this:\n `$.resizeSvgIcons(resizeOptions)` (use the same way as the \"resize\" parameter)\n *\n * @module jQuerySVGIcons\n * @license MIT\n * @copyright (c) 2009 Alexis Deveria\n * {@link http://a.deveria.com}\n * @example\n $(function () {\n $.svgIcons('my_icon_set.svg'); // The SVG file that contains all icons\n // No options have been set, so all icons will automatically be inserted\n // into HTML elements that match the same IDs.\n });\n\n * @example\n $(function () {\n // The SVG file that contains all icons\n $.svgIcons('my_icon_set.svg', {\n callback (icons) { // Custom callback function that sets click\n // events for each icon\n $.each(icons, function (id, icon) {\n icon.click(function () {\n alert('You clicked on the icon with id ' + id);\n });\n });\n }\n });\n });\n\n * @example\n $(function () {\n // The SVGZ file that contains all icons\n $.svgIcons('my_icon_set.svgz', {\n w: 32, // All icons will be 32px wide\n h: 32, // All icons will be 32px high\n fallback_path: 'icons/', // All fallback files can be found here\n fallback: {\n '#open_icon': 'open.png', // The \"open.png\" will be appended to the\n // HTML element with ID \"open_icon\"\n '#close_icon': 'close.png',\n '#save_icon': 'save.png'\n },\n placement: {'.open_icon': 'open'}, // The \"open\" icon will be added\n // to all elements with class \"open_icon\"\n resize: {\n '#save_icon .svg_icon': 64 // The \"save\" icon will be resized to 64 x 64px\n },\n\n callback (icons) { // Sets background color for \"close\" icon\n icons.close.css('background', 'red');\n },\n\n svgz: true // Indicates that an SVGZ file is being used\n });\n });\n*/\n\n// Todo: Move to own module (and have it import a modular base64 encoder)\nimport {encode64} from '../../common/utilities.js';\n\nconst isOpera = Boolean(window.opera);\n\nconst fixIDs = function (svgEl, svgNum, force) {\n const defs = svgEl.find('defs');\n if (!defs.length) return svgEl;\n\n let idElems;\n if (isOpera) {\n idElems = defs.find('*').filter(function () {\n return Boolean(this.id);\n });\n } else {\n idElems = defs.find('[id]');\n }\n\n const allElems = svgEl[0].getElementsByTagName('*'),\n len = allElems.length;\n\n idElems.each(function (i) {\n const {id} = this;\n /*\n const noDupes = ($(svgdoc).find('#' + id).length <= 1);\n if (isOpera) noDupes = false; // Opera didn't clone svgEl, so not reliable\n if(!force && noDupes) return;\n */\n const newId = 'x' + id + svgNum + i;\n this.id = newId;\n\n const oldVal = 'url(#' + id + ')';\n const newVal = 'url(#' + newId + ')';\n\n // Selector method, possibly faster but fails in Opera / jQuery 1.4.3\n // svgEl.find('[fill=\"url(#' + id + ')\"]').each(function() {\n // this.setAttribute('fill', 'url(#' + newId + ')');\n // }).end().find('[stroke=\"url(#' + id + ')\"]').each(function() {\n // this.setAttribute('stroke', 'url(#' + newId + ')');\n // }).end().find('use').each(function() {\n // if(this.getAttribute('xlink:href') == '#' + id) {\n // this.setAttributeNS(xlinkns,'href','#' + newId);\n // }\n // }).end().find('[filter=\"url(#' + id + ')\"]').each(function() {\n // this.setAttribute('filter', 'url(#' + newId + ')');\n // });\n\n for (i = 0; i < len; i++) {\n const elem = allElems[i];\n if (elem.getAttribute('fill') === oldVal) {\n elem.setAttribute('fill', newVal);\n }\n if (elem.getAttribute('stroke') === oldVal) {\n elem.setAttribute('stroke', newVal);\n }\n if (elem.getAttribute('filter') === oldVal) {\n elem.setAttribute('filter', newVal);\n }\n }\n });\n return svgEl;\n};\n\n/**\n* @callback module:jQuerySVGIcons.SVGIconsLoadedCallback\n* @param {PlainObject<string, external:jQuery>} svgIcons IDs keyed to jQuery objects of images\n* @returns {void}\n*/\n\n/**\n * @function module:jQuerySVGIcons.jQuerySVGIcons\n * @param {external:jQuery} $ Its keys include all icon IDs and the values, the icon as a jQuery object\n * @returns {external:jQuery} The enhanced jQuery object\n*/\nexport default function jQueryPluginSVGIcons ($) {\n const svgIcons = {};\n\n /**\n * Map of raster images with each key being the SVG icon ID\n * to replace, and the value the image file name.\n * @typedef {PlainObject<string, string>} external:jQuery.svgIcons.Fallback\n */\n /**\n * Map of raster images with each key being the SVG icon ID\n * whose `alt` will be set, and the value being the `alt` text.\n * @typedef {PlainObject<string, string>} external:jQuery.svgIcons.Alts\n */\n /**\n * @function external:jQuery.svgIcons\n * @param {string} file The location of a local SVG or SVGz file\n * @param {PlainObject} [opts]\n * @param {Float} [opts.w] The icon widths\n * @param {Float} [opts.h] The icon heights\n * @param {external:jQuery.svgIcons.Fallback} [opts.fallback]\n * @param {string} [opts.fallback_path] The path to use for all images\n * listed under \"fallback\"\n * @param {boolean} [opts.replace] If set to `true`, HTML elements will\n * be replaced by, rather than include the SVG icon.\n * @param {PlainObject<string, string>} [opts.placement] Map with selectors\n * for keys and SVG icon ids as values. This provides a custom method of\n * adding icons.\n * @param {PlainObject<string, module:jQuerySVGIcons.Size>} [opts.resize] Map\n * with selectors for keys and numbers as values. This allows an easy way to\n * resize specific icons.\n * @param {module:jQuerySVGIcons.SVGIconsLoadedCallback} [opts.callback] A\n * function to call when all icons have been loaded.\n * @param {boolean} [opts.id_match=true] Automatically attempt to match\n * SVG icon ids with corresponding HTML id\n * @param {boolean} [opts.no_img] Prevent attempting to convert the icon\n * into an `<img>` element (may be faster, help for browser consistency)\n * @param {boolean} [opts.svgz] Indicate that the file is an SVGZ file, and\n * thus not to parse as XML. SVGZ files add compression benefits, but\n * getting data from them fails in Firefox 2 and older.\n * @param {jQuery.svgIcons.Alts} [opts.alts] Map of images with each key\n * being the SVG icon ID whose `alt` will be set, and the value being\n * the `alt` text\n * @param {string} [opts.testIconAlt=\"icon\"] Alt text for the injected test image.\n * In case wish to ensure have one for accessibility\n * @returns {void}\n */\n $.svgIcons = function (file, opts = {}) {\n const svgns = 'http://www.w3.org/2000/svg',\n xlinkns = 'http://www.w3.org/1999/xlink',\n iconW = opts.w || 24,\n iconH = opts.h || 24;\n let elems, svgdoc, testImg,\n iconsMade = false,\n dataLoaded = false,\n loadAttempts = 0;\n const // ua = navigator.userAgent,\n // isSafari = (ua.includes('Safari/') && !ua.includes('Chrome/')),\n dataPre = 'data:image/svg+xml;charset=utf-8;base64,';\n\n let dataEl;\n if (opts.svgz) {\n dataEl = $('<object data=\"' + file + '\" type=image/svg+xml>').appendTo('body').hide();\n try {\n svgdoc = dataEl[0].contentDocument;\n dataEl.load(getIcons);\n getIcons(0, true); // Opera will not run \"load\" event if file is already cached\n } catch (err1) {\n useFallback();\n }\n } else {\n const parser = new DOMParser();\n $.ajax({\n url: file,\n dataType: 'string',\n success (data) {\n if (!data) {\n $(useFallback);\n return;\n }\n svgdoc = parser.parseFromString(data, 'text/xml');\n $(function () {\n getIcons('ajax');\n });\n },\n error (err) {\n // TODO: Fix Opera widget icon bug\n if (window.opera) {\n $(function () {\n useFallback();\n });\n } else if (err.responseText) {\n svgdoc = parser.parseFromString(err.responseText, 'text/xml');\n\n if (!svgdoc.childNodes.length) {\n $(useFallback);\n }\n $(function () {\n getIcons('ajax');\n });\n } else {\n $(useFallback);\n }\n }\n });\n }\n\n /**\n *\n * @param {\"ajax\"|0|void} evt\n * @param {boolean} [noWait]\n * @returns {void}\n */\n function getIcons (evt, noWait) {\n if (evt !== 'ajax') {\n if (dataLoaded) return;\n // Webkit sometimes says svgdoc is undefined, other times\n // it fails to load all nodes. Thus we must make sure the \"eof\"\n // element is loaded.\n svgdoc = dataEl[0].contentDocument; // Needed again for Webkit\n const isReady = (svgdoc && svgdoc.getElementById('svg_eof'));\n if (!isReady && !(noWait && isReady)) {\n loadAttempts++;\n if (loadAttempts < 50) {\n setTimeout(getIcons, 20);\n } else {\n useFallback();\n dataLoaded = true;\n }\n return;\n }\n dataLoaded = true;\n }\n\n elems = $(svgdoc.firstChild).children(); // .getElementsByTagName('foreignContent');\n\n if (!opts.no_img) {\n const testSrc = dataPre +\n 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zd' +\n 'mciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D';\n\n testImg = $(new Image()).attr({\n src: testSrc,\n width: 0,\n height: 0,\n alt: opts.testIconAlt || 'icon'\n }).appendTo('body')\n .load(function () {\n // Safari 4 crashes, Opera and Chrome don't\n makeIcons(true);\n }).error(function () {\n makeIcons();\n });\n } else {\n setTimeout(function () {\n if (!iconsMade) makeIcons();\n }, 500);\n }\n }\n\n /**\n *\n * @param {external:jQuery} target\n * @param {external:jQuery} icon A wrapped `defs` or Image\n * @param {string} id SVG icon ID\n * @param {boolean} setID Whether to set the ID attribute (with `id`)\n * @returns {void}\n */\n function setIcon (target, icon, id, setID) {\n if (isOpera) icon.css('visibility', 'hidden');\n if (opts.replace) {\n if (setID) icon.attr('id', id);\n const cl = target.attr('class');\n if (cl) icon.attr('class', 'svg_icon ' + cl);\n if (!target.alt) {\n let alt = 'icon';\n if (opts.alts) {\n alt = opts.alts[id] || alt;\n }\n icon.attr('alt', alt);\n }\n target.replaceWith(icon);\n } else {\n target.append(icon);\n }\n if (isOpera) {\n setTimeout(function () {\n icon.removeAttr('style');\n }, 1);\n }\n }\n\n let holder;\n /**\n * @param {external:jQuery} icon A wrapped `defs` or Image\n * @param {string} id SVG icon ID\n * @returns {void}\n */\n function addIcon (icon, id) {\n if (opts.id_match === undefined || opts.id_match !== false) {\n setIcon(holder, icon, id, true);\n }\n svgIcons[id] = icon;\n }\n\n /**\n *\n * @param {boolean} [toImage]\n * @param {external:jQuery.svgIcons.Fallback} [fallback=false]\n * @returns {void}\n */\n function makeIcons (toImage = false, fallback = false) {\n if (iconsMade) return;\n if (opts.no_img) toImage = false;\n\n let tempHolder;\n if (toImage) {\n tempHolder = $(document.createElement('div'));\n tempHolder.hide().appendTo('body');\n }\n if (fallback) {\n const path = opts.fallback_path || '';\n $.each(fallback, function (id, imgsrc) {\n holder = $('#' + id);\n let alt = 'icon';\n if (opts.alts) {\n alt = opts.alts[id] || alt;\n }\n const icon = $(new Image())\n .attr({\n class: 'svg_icon',\n src: path + imgsrc,\n width: iconW,\n height: iconH,\n alt\n });\n\n addIcon(icon, id);\n });\n } else {\n const len = elems.length;\n for (let i = 0; i < len; i++) {\n const elem = elems[i];\n const {id} = elem;\n if (id === 'svg_eof') break;\n holder = $('#' + id);\n const svgroot = document.createElementNS(svgns, 'svg');\n // Per https://www.w3.org/TR/xml-names11/#defaulting, the namespace for\n // attributes should have no value.\n svgroot.setAttribute('viewBox', [0, 0, iconW, iconH].join(' '));\n\n let svg = elem.getElementsByTagNameNS(svgns, 'svg')[0];\n\n // Make flexible by converting width/height to viewBox\n const w = svg.getAttribute('width');\n const h = svg.getAttribute('height');\n svg.removeAttribute('width');\n svg.removeAttribute('height');\n\n const vb = svg.getAttribute('viewBox');\n if (!vb) {\n svg.setAttribute('viewBox', [0, 0, w, h].join(' '));\n }\n\n // Not using jQuery to be a bit faster\n svgroot.setAttribute('xmlns', svgns);\n svgroot.setAttribute('width', iconW);\n svgroot.setAttribute('height', iconH);\n svgroot.setAttribute('xmlns:xlink', xlinkns);\n svgroot.setAttribute('class', 'svg_icon');\n\n // Without cloning, Firefox will make another GET request.\n // With cloning, causes issue in Opera/Win/Non-EN\n if (!isOpera) svg = svg.cloneNode(true);\n\n svgroot.append(svg);\n\n let icon;\n if (toImage) {\n tempHolder.empty().append(svgroot);\n const str = dataPre + encode64(unescape(encodeURIComponent(\n new XMLSerializer().serializeToString(svgroot)\n )));\n let alt = 'icon';\n if (opts.alts) {\n alt = opts.alts[id] || alt;\n }\n icon = $(new Image())\n .attr({class: 'svg_icon', src: str, alt});\n } else {\n icon = fixIDs($(svgroot), i);\n }\n addIcon(icon, id);\n }\n }\n\n if (opts.placement) {\n $.each(opts.placement, function (sel, id) {\n if (!svgIcons[id]) return;\n $(sel).each(function (i) {\n let copy = svgIcons[id].clone();\n if (i > 0 && !toImage) copy = fixIDs(copy, i, true);\n setIcon($(this), copy, id);\n });\n });\n }\n if (!fallback) {\n if (toImage) tempHolder.remove();\n if (dataEl) dataEl.remove();\n if (testImg) testImg.remove();\n }\n if (opts.resize) $.resizeSvgIcons(opts.resize);\n iconsMade = true;\n\n if (opts.callback) opts.callback(svgIcons);\n }\n\n /**\n * @returns {void}\n */\n function useFallback () {\n if (file.includes('.svgz')) {\n const regFile = file.replace('.svgz', '.svg');\n if (window.console) {\n console.log('.svgz failed, trying with .svg'); // eslint-disable-line no-console\n }\n $.svgIcons(regFile, opts);\n } else if (opts.fallback) {\n makeIcons(false, opts.fallback);\n }\n }\n };\n\n /**\n * @function external:jQuery.getSvgIcon\n * @param {string} id\n * @param {boolean} uniqueClone Whether to clone\n * @returns {external:jQuery} The icon (optionally cloned)\n */\n $.getSvgIcon = function (id, uniqueClone) {\n let icon = svgIcons[id];\n if (uniqueClone && icon) {\n icon = fixIDs(icon, 0, true).clone(true);\n }\n return icon;\n };\n\n /**\n * @typedef {GenericArray} module:jQuerySVGIcons.Dimensions\n * @property {Integer} length 2\n * @property {Float} 0 Width\n * @property {Float} 1 Height\n */\n\n /**\n * If a Float is used, it will represent width and height. Arrays contain\n * the width and height.\n * @typedef {module:jQuerySVGIcons.Dimensions|Float} module:jQuerySVGIcons.Size\n */\n\n /**\n * @function external:jQuery.resizeSvgIcons\n * @param {PlainObject<string, module:jQuerySVGIcons.Size>} obj Object with\n * selectors as keys. The values are sizes.\n * @returns {void}\n */\n $.resizeSvgIcons = function (obj) {\n // FF2 and older don't detect .svg_icon, so we change it detect svg elems instead\n const changeSel = !$('.svg_icon:first').length;\n $.each(obj, function (sel, size) {\n const arr = Array.isArray(size);\n const w = arr ? size[0] : size,\n h = arr ? size[1] : size;\n if (changeSel) {\n sel = sel.replace(/\\.svg_icon/g, 'svg');\n }\n $(sel).each(function () {\n this.setAttribute('width', w);\n this.setAttribute('height', h);\n if (window.opera && window.widget) {\n this.parentNode.style.width = w + 'px';\n this.parentNode.style.height = h + 'px';\n }\n });\n });\n };\n return $;\n}\n","/**\n * @file jGraduate 0.4\n *\n * jQuery Plugin for a gradient picker\n *\n * @module jGraduate\n * @copyright 2010 Jeff Schiller {@link http://blog.codedread.com/}, 2010 Alexis Deveria {@link http://a.deveria.com/}\n *\n * @license Apache-2.0\n * @example\n * // The Paint object is described below.\n * $.jGraduate.Paint(); // constructs a 'none' color\n * @example $.jGraduate.Paint({copy: o}); // creates a copy of the paint o\n * @example $.jGraduate.Paint({hex: '#rrggbb'}); // creates a solid color paint with hex = \"#rrggbb\"\n * @example $.jGraduate.Paint({linearGradient: o, a: 50}); // creates a linear gradient paint with opacity=0.5\n * @example $.jGraduate.Paint({radialGradient: o, a: 7}); // creates a radial gradient paint with opacity=0.07\n * @example $.jGraduate.Paint({hex: '#rrggbb', linearGradient: o}); // throws an exception?\n*/\n\n/* eslint-disable jsdoc/require-property */\n/**\n * The jQuery namespace.\n * @external jQuery\n*/\n/**\n * The jQuery plugin namespace.\n * @namespace {PlainObject} fn\n * @memberof external:jQuery\n * @see {@link http://learn.jquery.com/plugins/|jQuery Plugins}\n */\n/* eslint-enable jsdoc/require-property */\n\nconst ns = {\n svg: 'http://www.w3.org/2000/svg',\n xlink: 'http://www.w3.org/1999/xlink'\n};\n\nif (!window.console) {\n window.console = {\n log (str) { /* */ },\n dir (str) { /* */ }\n };\n}\n\n/**\n* Adds {@link external:jQuery.jGraduate.Paint},\n* {@link external:jQuery.fn.jGraduateDefaults},\n* {@link external:jQuery.fn.jGraduate}.\n* @function module:jGraduate.jGraduate\n* @param {external:jQuery} $ The jQuery instance to wrap\n* @returns {external:jQuery}\n*/\nexport default function jQueryPluginJGraduate ($) {\n /**\n * @typedef {PlainObject} module:jGraduate.jGraduatePaintOptions\n * @property {Float} [alpha]\n * @property {module:jGraduate~Paint} [copy] Copy paint object\n * @property {SVGLinearGradientElement} [linearGradient]\n * @property {SVGRadialGradientElement} [radialGradient]\n * @property {string} [solidColor]\n */\n\n /**\n * @memberof module:jGraduate~\n */\n class Paint {\n /**\n * @param {module:jGraduate.jGraduatePaintOptions} [opt]\n */\n constructor (opt) {\n const options = opt || {};\n this.alpha = isNaN(options.alpha) ? 100 : options.alpha;\n // copy paint object\n if (options.copy) {\n /**\n * @name module:jGraduate~Paint#type\n * @type {\"none\"|\"solidColor\"|\"linearGradient\"|\"radialGradient\"}\n */\n this.type = options.copy.type;\n /**\n * Represents opacity (0-100).\n * @name module:jGraduate~Paint#alpha\n * @type {Float}\n */\n this.alpha = options.copy.alpha;\n /**\n * Represents #RRGGBB hex of color.\n * @name module:jGraduate~Paint#solidColor\n * @type {string}\n */\n this.solidColor = null;\n /**\n * @name module:jGraduate~Paint#linearGradient\n * @type {SVGLinearGradientElement}\n */\n this.linearGradient = null;\n /**\n * @name module:jGraduate~Paint#radialGradient\n * @type {SVGRadialGradientElement}\n */\n this.radialGradient = null;\n\n switch (this.type) {\n case 'none':\n break;\n case 'solidColor':\n this.solidColor = options.copy.solidColor;\n break;\n case 'linearGradient':\n this.linearGradient = options.copy.linearGradient.cloneNode(true);\n break;\n case 'radialGradient':\n this.radialGradient = options.copy.radialGradient.cloneNode(true);\n break;\n }\n // create linear gradient paint\n } else if (options.linearGradient) {\n this.type = 'linearGradient';\n this.solidColor = null;\n this.radialGradient = null;\n this.linearGradient = options.linearGradient.cloneNode(true);\n // create linear gradient paint\n } else if (options.radialGradient) {\n this.type = 'radialGradient';\n this.solidColor = null;\n this.linearGradient = null;\n this.radialGradient = options.radialGradient.cloneNode(true);\n // create solid color paint\n } else if (options.solidColor) {\n this.type = 'solidColor';\n this.solidColor = options.solidColor;\n // create empty paint\n } else {\n this.type = 'none';\n this.solidColor = null;\n this.linearGradient = null;\n this.radialGradient = null;\n }\n }\n }\n\n /* eslint-disable jsdoc/require-property */\n /**\n * @namespace {PlainObject} jGraduate\n * @memberof external:jQuery\n */\n $.jGraduate = /** @lends external:jQuery.jGraduate */ {\n /* eslint-enable jsdoc/require-property */\n /**\n * @class external:jQuery.jGraduate.Paint\n * @see module:jGraduate~Paint\n */\n Paint\n };\n\n // JSDoc doesn't show this as belonging to our `module:jGraduate.Options` type,\n // so we use `@see`\n /**\n * @namespace {module:jGraduate.Options} jGraduateDefaults\n * @memberof external:jQuery.fn\n */\n $.fn.jGraduateDefaults = /** @lends external:jQuery.fn.jGraduateDefaults */ {\n /**\n * Creates an object with a 'none' color.\n * @type {external:jQuery.jGraduate.Paint}\n * @see module:jGraduate.Options\n */\n paint: new $.jGraduate.Paint(),\n /**\n * @namespace\n */\n window: {\n /**\n * @type {string}\n * @see module:jGraduate.Options\n */\n pickerTitle: 'Drag markers to pick a paint'\n },\n /**\n * @namespace\n */\n images: {\n /**\n * @type {string}\n * @see module:jGraduate.Options\n */\n clientPath: 'images/'\n },\n /**\n * @type {string}\n * @see module:jGraduate.Options\n */\n newstop: 'inverse' // same, inverse, black, white\n };\n\n const isGecko = navigator.userAgent.includes('Gecko/');\n\n /**\n * @typedef {PlainObject<string, string>} module:jGraduate.Attrs\n */\n /**\n * @param {SVGElement} elem\n * @param {module:jGraduate.Attrs} attrs\n * @returns {void}\n */\n function setAttrs (elem, attrs) {\n if (isGecko) {\n Object.entries(attrs).forEach(([aname, val]) => {\n elem.setAttribute(aname, val);\n });\n } else {\n Object.entries(attrs).forEach(([aname, val]) => {\n const prop = elem[aname];\n if (prop && prop.constructor === 'SVGLength') {\n prop.baseVal.value = val;\n } else {\n elem.setAttribute(aname, val);\n }\n });\n }\n }\n\n /**\n * @param {string} name\n * @param {module:jGraduate.Attrs} attrs\n * @param {Element} newparent\n * @returns {SVGElement}\n */\n function mkElem (name, attrs, newparent) {\n const elem = document.createElementNS(ns.svg, name);\n setAttrs(elem, attrs);\n if (newparent) {\n newparent.append(elem);\n }\n return elem;\n }\n\n /**\n * @typedef {PlainObject} module:jGraduate.ColorOpac Object may have one or both values\n * @property {string} [color] #Hex color\n * @property {Float} [opac] 0-1\n */\n /**\n * @typedef {PlainObject} module:jGraduate.Options\n * @property {module:jGraduate~Paint} [paint] A Paint object object describing the paint to display initially; defaults to a new instance without options (defaults to opaque white)\n * @property {external:Window} [window]\n * @property {string} [window.pickerTitle='Drag markers to pick a paint']\n * @property {PlainObject} [images]\n * @property {string} [images.clientPath='images/']\n * @property {\"same\"|\"inverse\"|\"black\"|\"white\"|module:jGraduate.ColorOpac} [newstop=\"inverse\"]\n */\n\n /**\n * @callback external:jQuery.fn.jGraduate.OkCallback\n * @param {external:jQuery.jGraduate.Paint} paint\n * @returns {void}\n */\n /**\n * @callback external:jQuery.fn.jGraduate.CancelCallback\n * @returns {void}\n */\n\n /**\n * @function external:jQuery.fn.jGraduate\n * @param {module:jGraduate.Options} [options]\n * @param {external:jQuery.fn.jGraduate.OkCallback} [okCallback] Called with a Paint object when Ok is pressed\n * @param {external:jQuery.fn.jGraduate.CancelCallback} [cancelCallback] Called with no arguments when Cancel is pressed\n * @returns {external:jQuery}\n */\n $.fn.jGraduate = function (options, okCallback, cancelCallback) {\n return this.each(function () {\n const $this = $(this),\n $settings = $.extend(true, {}, $.fn.jGraduateDefaults, options || {}),\n id = $this.attr('id'),\n idref = '#' + $this.attr('id') + ' ';\n\n if (!idref) {\n /* await */ $.alert('Container element must have an id attribute to maintain unique id strings for sub-elements.');\n return;\n }\n\n const okClicked = function () {\n switch ($this.paint.type) {\n case 'radialGradient':\n $this.paint.linearGradient = null;\n break;\n case 'linearGradient':\n $this.paint.radialGradient = null;\n break;\n case 'solidColor':\n $this.paint.radialGradient = $this.paint.linearGradient = null;\n break;\n }\n typeof $this.okCallback === 'function' && $this.okCallback($this.paint);\n $this.hide();\n };\n const cancelClicked = function () {\n typeof $this.cancelCallback === 'function' && $this.cancelCallback();\n $this.hide();\n };\n\n $.extend(\n true,\n $this,\n // public properties, methods, and callbacks\n {\n // make a copy of the incoming paint\n paint: new $.jGraduate.Paint({copy: $settings.paint}),\n okCallback: typeof okCallback === 'function' ? okCallback : null,\n cancelCallback: typeof cancelCallback === 'function' ? cancelCallback : null\n }\n );\n\n let // pos = $this.position(),\n color = null;\n const $win = $(window);\n\n if ($this.paint.type === 'none') {\n $this.paint = new $.jGraduate.Paint({solidColor: 'ffffff'});\n }\n\n $this.addClass('jGraduate_Picker');\n /* eslint-disable max-len */\n $this.html(\n '<ul class=\"jGraduate_tabs\">' +\n '<li class=\"jGraduate_tab_color jGraduate_tab_current\" data-type=\"col\">Solid Color</li>' +\n '<li class=\"jGraduate_tab_lingrad\" data-type=\"lg\">Linear Gradient</li>' +\n '<li class=\"jGraduate_tab_radgrad\" data-type=\"rg\">Radial Gradient</li>' +\n '</ul>' +\n '<div class=\"jGraduate_colPick\"></div>' +\n '<div class=\"jGraduate_gradPick\"></div>' +\n '<div class=\"jGraduate_LightBox\"></div>' +\n '<div id=\"' + id + '_jGraduate_stopPicker\" class=\"jGraduate_stopPicker\"></div>'\n );\n const colPicker = $(idref + '> .jGraduate_colPick');\n const gradPicker = $(idref + '> .jGraduate_gradPick');\n\n gradPicker.html(\n '<div id=\"' + id + '_jGraduate_Swatch\" class=\"jGraduate_Swatch\">' +\n '<h2 class=\"jGraduate_Title\">' + $settings.window.pickerTitle + '</h2>' +\n '<div id=\"' + id + '_jGraduate_GradContainer\" class=\"jGraduate_GradContainer\"></div>' +\n '<div id=\"' + id + '_jGraduate_StopSlider\" class=\"jGraduate_StopSlider\"></div>' +\n '</div>' +\n '<div class=\"jGraduate_Form jGraduate_Points jGraduate_lg_field\">' +\n '<div class=\"jGraduate_StopSection\">' +\n '<label class=\"jGraduate_Form_Heading\">Begin Point</label>' +\n '<div class=\"jGraduate_Form_Section\">' +\n '<label>x:</label>' +\n '<input type=\"text\" id=\"' + id + '_jGraduate_x1\" size=\"3\" title=\"Enter starting x value between 0.0 and 1.0\"/>' +\n '<label>y:</label>' +\n '<input type=\"text\" id=\"' + id + '_jGraduate_y1\" size=\"3\" title=\"Enter starting y value between 0.0 and 1.0\"/>' +\n '</div>' +\n '</div>' +\n '<div class=\"jGraduate_StopSection\">' +\n '<label class=\"jGraduate_Form_Heading\">End Point</label>' +\n '<div class=\"jGraduate_Form_Section\">' +\n '<label>x:</label>' +\n '<input type=\"text\" id=\"' + id + '_jGraduate_x2\" size=\"3\" title=\"Enter ending x value between 0.0 and 1.0\"/>' +\n '<label>y:</label>' +\n '<input type=\"text\" id=\"' + id + '_jGraduate_y2\" size=\"3\" title=\"Enter ending y value between 0.0 and 1.0\"/>' +\n '</div>' +\n '</div>' +\n '</div>' +\n '<div class=\"jGraduate_Form jGraduate_Points jGraduate_rg_field\">' +\n '<div class=\"jGraduate_StopSection\">' +\n '<label class=\"jGraduate_Form_Heading\">Center Point</label>' +\n '<div class=\"jGraduate_Form_Section\">' +\n '<label>x:</label>' +\n '<input type=\"text\" id=\"' + id + '_jGraduate_cx\" size=\"3\" title=\"Enter x value between 0.0 and 1.0\"/>' +\n '<label>y:</label>' +\n '<input type=\"text\" id=\"' + id + '_jGraduate_cy\" size=\"3\" title=\"Enter y value between 0.0 and 1.0\"/>' +\n '</div>' +\n '</div>' +\n '<div class=\"jGraduate_StopSection\">' +\n '<label class=\"jGraduate_Form_Heading\">Focal Point</label>' +\n '<div class=\"jGraduate_Form_Section\">' +\n '<label>Match center: <input type=\"checkbox\" checked=\"checked\" id=\"' + id + '_jGraduate_match_ctr\"/></label><br/>' +\n '<label>x:</label>' +\n '<input type=\"text\" id=\"' + id + '_jGraduate_fx\" size=\"3\" title=\"Enter x value between 0.0 and 1.0\"/>' +\n '<label>y:</label>' +\n '<input type=\"text\" id=\"' + id + '_jGraduate_fy\" size=\"3\" title=\"Enter y value between 0.0 and 1.0\"/>' +\n '</div>' +\n '</div>' +\n '</div>' +\n '<div class=\"jGraduate_StopSection jGraduate_SpreadMethod\">' +\n '<label class=\"jGraduate_Form_Heading\">Spread method</label>' +\n '<div class=\"jGraduate_Form_Section\">' +\n '<select class=\"jGraduate_spreadMethod\">' +\n '<option value=pad selected>Pad</option>' +\n '<option value=reflect>Reflect</option>' +\n '<option value=repeat>Repeat</option>' +\n '</select>' +\n '</div>' +\n '</div>' +\n '<div class=\"jGraduate_Form\">' +\n '<div class=\"jGraduate_Slider jGraduate_RadiusField jGraduate_rg_field\">' +\n '<label class=\"prelabel\">Radius:</label>' +\n '<div id=\"' + id + '_jGraduate_Radius\" class=\"jGraduate_SliderBar jGraduate_Radius\" title=\"Click to set radius\">' +\n '<img id=\"' + id + '_jGraduate_RadiusArrows\" class=\"jGraduate_RadiusArrows\" src=\"' + $settings.images.clientPath + 'rangearrows2.gif\">' +\n '</div>' +\n '<label><input type=\"text\" id=\"' + id + '_jGraduate_RadiusInput\" size=\"3\" value=\"100\"/>%</label>' +\n '</div>' +\n '<div class=\"jGraduate_Slider jGraduate_EllipField jGraduate_rg_field\">' +\n '<label class=\"prelabel\">Ellip:</label>' +\n '<div id=\"' + id + '_jGraduate_Ellip\" class=\"jGraduate_SliderBar jGraduate_Ellip\" title=\"Click to set Ellip\">' +\n '<img id=\"' + id + '_jGraduate_EllipArrows\" class=\"jGraduate_EllipArrows\" src=\"' + $settings.images.clientPath + 'rangearrows2.gif\">' +\n '</div>' +\n '<label><input type=\"text\" id=\"' + id + '_jGraduate_EllipInput\" size=\"3\" value=\"0\"/>%</label>' +\n '</div>' +\n '<div class=\"jGraduate_Slider jGraduate_AngleField jGraduate_rg_field\">' +\n '<label class=\"prelabel\">Angle:</label>' +\n '<div id=\"' + id + '_jGraduate_Angle\" class=\"jGraduate_SliderBar jGraduate_Angle\" title=\"Click to set Angle\">' +\n '<img id=\"' + id + '_jGraduate_AngleArrows\" class=\"jGraduate_AngleArrows\" src=\"' + $settings.images.clientPath + 'rangearrows2.gif\">' +\n '</div>' +\n '<label><input type=\"text\" id=\"' + id + '_jGraduate_AngleInput\" size=\"3\" value=\"0\"/>deg</label>' +\n '</div>' +\n '<div class=\"jGraduate_Slider jGraduate_OpacField\">' +\n '<label class=\"prelabel\">Opac:</label>' +\n '<div id=\"' + id + '_jGraduate_Opac\" class=\"jGraduate_SliderBar jGraduate_Opac\" title=\"Click to set Opac\">' +\n '<img id=\"' + id + '_jGraduate_OpacArrows\" class=\"jGraduate_OpacArrows\" src=\"' + $settings.images.clientPath + 'rangearrows2.gif\">' +\n '</div>' +\n '<label><input type=\"text\" id=\"' + id + '_jGraduate_OpacInput\" size=\"3\" value=\"100\"/>%</label>' +\n '</div>' +\n '</div>' +\n '<div class=\"jGraduate_OkCancel\">' +\n '<input type=\"button\" id=\"' + id + '_jGraduate_Ok\" class=\"jGraduate_Ok\" value=\"OK\"/>' +\n '<input type=\"button\" id=\"' + id + '_jGraduate_Cancel\" class=\"jGraduate_Cancel\" value=\"Cancel\"/>' +\n '</div>'\n );\n /* eslint-enable max-len */\n // --------------\n // Set up all the SVG elements (the gradient, stops and rectangle)\n const MAX = 256,\n MARGINX = 0,\n MARGINY = 0,\n // STOP_RADIUS = 15 / 2,\n SIZEX = MAX - 2 * MARGINX,\n SIZEY = MAX - 2 * MARGINY;\n\n const attrInput = {};\n\n const SLIDERW = 145;\n $('.jGraduate_SliderBar').width(SLIDERW);\n\n const container = $('#' + id + '_jGraduate_GradContainer')[0];\n\n const svg = mkElem('svg', {\n id: id + '_jgraduate_svg',\n width: MAX,\n height: MAX,\n xmlns: ns.svg\n }, container);\n\n // This wasn't working as designed\n // let curType;\n // curType = curType || $this.paint.type;\n\n // if we are sent a gradient, import it\n let curType = $this.paint.type;\n\n let grad = $this.paint[curType];\n let curGradient = grad;\n\n const gradalpha = $this.paint.alpha;\n\n const isSolid = curType === 'solidColor';\n\n // Make any missing gradients\n switch (curType) {\n case 'solidColor':\n // fall through\n case 'linearGradient':\n if (!isSolid) {\n curGradient.id = id + '_lg_jgraduate_grad';\n grad = curGradient = svg.appendChild(curGradient); // .cloneNode(true));\n }\n mkElem('radialGradient', {\n id: id + '_rg_jgraduate_grad'\n }, svg);\n if (curType === 'linearGradient') { break; }\n // fall through\n case 'radialGradient':\n if (!isSolid) {\n curGradient.id = id + '_rg_jgraduate_grad';\n grad = curGradient = svg.appendChild(curGradient); // .cloneNode(true));\n }\n mkElem('linearGradient', {\n id: id + '_lg_jgraduate_grad'\n }, svg);\n }\n\n let stopGroup; // eslint-disable-line prefer-const\n if (isSolid) {\n grad = curGradient = $('#' + id + '_lg_jgraduate_grad')[0];\n color = $this.paint[curType];\n mkStop(0, '#' + color, 1);\n\n const type = typeof $settings.newstop;\n\n if (type === 'string') {\n switch ($settings.newstop) {\n case 'same':\n mkStop(1, '#' + color, 1);\n break;\n\n case 'inverse': {\n // Invert current color for second stop\n let inverted = '';\n for (let i = 0; i < 6; i += 2) {\n // const ch = color.substr(i, 2);\n let inv = (255 - Number.parseInt(color.substr(i, 2), 16)).toString(16);\n if (inv.length < 2) inv = 0 + inv;\n inverted += inv;\n }\n mkStop(1, '#' + inverted, 1);\n break;\n } case 'white':\n mkStop(1, '#ffffff', 1);\n break;\n\n case 'black':\n mkStop(1, '#000000', 1);\n break;\n }\n } else if (type === 'object') {\n const opac = ('opac' in $settings.newstop) ? $settings.newstop.opac : 1;\n mkStop(1, ($settings.newstop.color || '#' + color), opac);\n }\n }\n\n const x1 = Number.parseFloat(grad.getAttribute('x1') || 0.0),\n y1 = Number.parseFloat(grad.getAttribute('y1') || 0.0),\n x2 = Number.parseFloat(grad.getAttribute('x2') || 1.0),\n y2 = Number.parseFloat(grad.getAttribute('y2') || 0.0);\n\n const cx = Number.parseFloat(grad.getAttribute('cx') || 0.5),\n cy = Number.parseFloat(grad.getAttribute('cy') || 0.5),\n fx = Number.parseFloat(grad.getAttribute('fx') || cx),\n fy = Number.parseFloat(grad.getAttribute('fy') || cy);\n\n const previewRect = mkElem('rect', {\n id: id + '_jgraduate_rect',\n x: MARGINX,\n y: MARGINY,\n width: SIZEX,\n height: SIZEY,\n fill: 'url(#' + id + '_jgraduate_grad)',\n 'fill-opacity': gradalpha / 100\n }, svg);\n\n // stop visuals created here\n const beginCoord = $('<div/>').attr({\n class: 'grad_coord jGraduate_lg_field',\n title: 'Begin Stop'\n }).text(1).css({\n top: y1 * MAX,\n left: x1 * MAX\n }).data('coord', 'start').appendTo(container);\n\n const endCoord = beginCoord.clone().text(2).css({\n top: y2 * MAX,\n left: x2 * MAX\n }).attr('title', 'End stop').data('coord', 'end').appendTo(container);\n\n const centerCoord = $('<div/>').attr({\n class: 'grad_coord jGraduate_rg_field',\n title: 'Center stop'\n }).text('C').css({\n top: cy * MAX,\n left: cx * MAX\n }).data('coord', 'center').appendTo(container);\n\n const focusCoord = centerCoord.clone().text('F').css({\n top: fy * MAX,\n left: fx * MAX,\n display: 'none'\n }).attr('title', 'Focus point').data('coord', 'focus').appendTo(container);\n\n focusCoord[0].id = id + '_jGraduate_focusCoord';\n\n // const coords = $(idref + ' .grad_coord');\n\n // $(container).hover(function () {\n // coords.animate({\n // opacity: 1\n // }, 500);\n // }, function () {\n // coords.animate({\n // opacity: .2\n // }, 500);\n // });\n\n let showFocus;\n $.each(['x1', 'y1', 'x2', 'y2', 'cx', 'cy', 'fx', 'fy'], function (i, attr) {\n const isRadial = isNaN(attr[1]);\n\n let attrval = curGradient.getAttribute(attr);\n if (!attrval) {\n // Set defaults\n if (isRadial) {\n // For radial points\n attrval = '0.5';\n } else {\n // Only x2 is 1\n attrval = attr === 'x2' ? '1.0' : '0.0';\n }\n }\n\n attrInput[attr] = $('#' + id + '_jGraduate_' + attr)\n .val(attrval)\n .change(function () {\n // TODO: Support values < 0 and > 1 (zoomable preview?)\n if (isNaN(Number.parseFloat(this.value)) || this.value < 0) {\n this.value = 0.0;\n } else if (this.value > 1) {\n this.value = 1.0;\n }\n\n if (!(attr[0] === 'f' && !showFocus)) {\n if ((isRadial && curType === 'radialGradient') || (!isRadial && curType === 'linearGradient')) {\n curGradient.setAttribute(attr, this.value);\n }\n }\n\n const $elem = isRadial\n ? attr[0] === 'c' ? centerCoord : focusCoord\n : attr[1] === '1' ? beginCoord : endCoord;\n\n const cssName = attr.includes('x') ? 'left' : 'top';\n\n $elem.css(cssName, this.value * MAX);\n }).change();\n });\n\n /**\n *\n * @param {Float} n\n * @param {Float|string} colr\n * @param {Float} opac\n * @param {boolean} [sel]\n * @param {SVGStopElement} [stopElem]\n * @returns {SVGStopElement}\n */\n function mkStop (n, colr, opac, sel, stopElem) {\n const stop = stopElem || mkElem('stop', {\n 'stop-color': colr,\n 'stop-opacity': opac,\n offset: n\n }, curGradient);\n if (stopElem) {\n colr = stopElem.getAttribute('stop-color');\n opac = stopElem.getAttribute('stop-opacity');\n n = stopElem.getAttribute('offset');\n } else {\n curGradient.append(stop);\n }\n if (opac === null) opac = 1;\n\n const pickerD = 'M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,' +\n '3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,' +\n '2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z';\n\n const pathbg = mkElem('path', {\n d: pickerD,\n fill: 'url(#jGraduate_trans)',\n transform: 'translate(' + (10 + n * MAX) + ', 26)'\n }, stopGroup);\n\n const path = mkElem('path', {\n d: pickerD,\n fill: colr,\n 'fill-opacity': opac,\n transform: 'translate(' + (10 + n * MAX) + ', 26)',\n stroke: '#000',\n 'stroke-width': 1.5\n }, stopGroup);\n\n $(path).mousedown(function (e) {\n selectStop(this);\n drag = curStop;\n $win.mousemove(dragColor).mouseup(remDrags);\n stopOffset = stopMakerDiv.offset();\n e.preventDefault();\n return false;\n }).data('stop', stop).data('bg', pathbg).dblclick(function () {\n $('div.jGraduate_LightBox').show();\n const colorhandle = this;\n let stopOpacity = Number(stop.getAttribute('stop-opacity')) || 1;\n let stopColor = stop.getAttribute('stop-color') || 1;\n let thisAlpha = (Number.parseFloat(stopOpacity) * 255).toString(16);\n while (thisAlpha.length < 2) { thisAlpha = '0' + thisAlpha; }\n colr = stopColor.substr(1) + thisAlpha;\n $('#' + id + '_jGraduate_stopPicker').css({left: 100, bottom: 15}).jPicker({\n window: {title: 'Pick the start color and opacity for the gradient'},\n images: {clientPath: $settings.images.clientPath},\n color: {active: colr, alphaSupport: true}\n }, function (clr, arg2) {\n stopColor = clr.val('hex') ? ('#' + clr.val('hex')) : 'none';\n stopOpacity = clr.val('a') !== null ? clr.val('a') / 256 : 1;\n colorhandle.setAttribute('fill', stopColor);\n colorhandle.setAttribute('fill-opacity', stopOpacity);\n stop.setAttribute('stop-color', stopColor);\n stop.setAttribute('stop-opacity', stopOpacity);\n $('div.jGraduate_LightBox').hide();\n $('#' + id + '_jGraduate_stopPicker').hide();\n }, null, function () {\n $('div.jGraduate_LightBox').hide();\n $('#' + id + '_jGraduate_stopPicker').hide();\n });\n });\n\n $(curGradient).find('stop').each(function () {\n const curS = $(this);\n if (Number(this.getAttribute('offset')) > n) {\n if (!colr) {\n const newcolor = this.getAttribute('stop-color');\n const newopac = this.getAttribute('stop-opacity');\n stop.setAttribute('stop-color', newcolor);\n path.setAttribute('fill', newcolor);\n stop.setAttribute('stop-opacity', newopac === null ? 1 : newopac);\n path.setAttribute('fill-opacity', newopac === null ? 1 : newopac);\n }\n curS.before(stop);\n return false;\n }\n return true;\n });\n if (sel) selectStop(path);\n return stop;\n }\n\n /**\n *\n * @returns {void}\n */\n function remStop () {\n delStop.setAttribute('display', 'none');\n const path = $(curStop);\n const stop = path.data('stop');\n const bg = path.data('bg');\n $([curStop, stop, bg]).remove();\n }\n\n const stopMakerDiv = $('#' + id + '_jGraduate_StopSlider');\n\n let stops, curStop, drag;\n\n const delStop = mkElem('path', {\n d: 'm9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5',\n fill: 'none',\n stroke: '#D00',\n 'stroke-width': 5,\n display: 'none'\n }, undefined); // stopMakerSVG);\n\n /**\n * @param {Element} item\n * @returns {void}\n */\n function selectStop (item) {\n if (curStop) curStop.setAttribute('stroke', '#000');\n item.setAttribute('stroke', 'blue');\n curStop = item;\n // stops = $('stop');\n // opac_select.val(curStop.attr('fill-opacity') || 1);\n // root.append(delStop);\n }\n\n let stopOffset;\n\n /**\n *\n * @returns {void}\n */\n function remDrags () {\n $win.unbind('mousemove', dragColor);\n if (delStop.getAttribute('display') !== 'none') {\n remStop();\n }\n drag = null;\n }\n\n let scaleX = 1, scaleY = 1, angle = 0;\n\n let cX = cx;\n let cY = cy;\n /**\n *\n * @returns {void}\n */\n function xform () {\n const rot = angle ? 'rotate(' + angle + ',' + cX + ',' + cY + ') ' : '';\n if (scaleX === 1 && scaleY === 1) {\n curGradient.removeAttribute('gradientTransform');\n // $('#ang').addClass('dis');\n } else {\n const x = -cX * (scaleX - 1);\n const y = -cY * (scaleY - 1);\n curGradient.setAttribute(\n 'gradientTransform',\n rot + 'translate(' + x + ',' + y + ') scale(' +\n scaleX + ',' + scaleY + ')'\n );\n // $('#ang').removeClass('dis');\n }\n }\n\n /**\n * @param {Event} evt\n * @returns {void}\n */\n function dragColor (evt) {\n let x = evt.pageX - stopOffset.left;\n const y = evt.pageY - stopOffset.top;\n x = x < 10\n ? 10\n : x > MAX + 10\n ? MAX + 10\n : x;\n\n const xfStr = 'translate(' + x + ', 26)';\n if (y < -60 || y > 130) {\n delStop.setAttribute('display', 'block');\n delStop.setAttribute('transform', xfStr);\n } else {\n delStop.setAttribute('display', 'none');\n }\n\n drag.setAttribute('transform', xfStr);\n $.data(drag, 'bg').setAttribute('transform', xfStr);\n const stop = $.data(drag, 'stop');\n const sX = (x - 10) / MAX;\n\n stop.setAttribute('offset', sX);\n\n let last = 0;\n $(curGradient).find('stop').each(function (i) {\n const cur = this.getAttribute('offset');\n const t = $(this);\n if (cur < last) {\n t.prev().before(t);\n stops = $(curGradient).find('stop');\n }\n last = cur;\n });\n }\n\n const stopMakerSVG = mkElem('svg', {\n width: '100%',\n height: 45\n }, stopMakerDiv[0]);\n\n const transPattern = mkElem('pattern', {\n width: 16,\n height: 16,\n patternUnits: 'userSpaceOnUse',\n id: 'jGraduate_trans'\n }, stopMakerSVG);\n\n const transImg = mkElem('image', {\n width: 16,\n height: 16\n }, transPattern);\n\n const bgImage = $settings.images.clientPath + 'map-opacity.png';\n\n transImg.setAttributeNS(ns.xlink, 'xlink:href', bgImage);\n\n $(stopMakerSVG).click(function (evt) {\n stopOffset = stopMakerDiv.offset();\n const {target} = evt;\n if (target.tagName === 'path') return;\n let x = evt.pageX - stopOffset.left - 8;\n x = x < 10 ? 10 : x > MAX + 10 ? MAX + 10 : x;\n mkStop(x / MAX, 0, 0, true);\n evt.stopPropagation();\n });\n\n $(stopMakerSVG).mouseover(function () {\n stopMakerSVG.append(delStop);\n });\n\n stopGroup = mkElem('g', {}, stopMakerSVG);\n\n mkElem('line', {\n x1: 10,\n y1: 15,\n x2: MAX + 10,\n y2: 15,\n 'stroke-width': 2,\n stroke: '#000'\n }, stopMakerSVG);\n\n const spreadMethodOpt = gradPicker.find('.jGraduate_spreadMethod').change(function () {\n curGradient.setAttribute('spreadMethod', $(this).val());\n });\n\n // handle dragging the stop around the swatch\n let draggingCoord = null;\n\n const onCoordDrag = function (evt) {\n let x = evt.pageX - offset.left;\n let y = evt.pageY - offset.top;\n\n // clamp stop to the swatch\n x = x < 0 ? 0 : x > MAX ? MAX : x;\n y = y < 0 ? 0 : y > MAX ? MAX : y;\n\n draggingCoord.css('left', x).css('top', y);\n\n // calculate stop offset\n const fracx = x / SIZEX;\n const fracy = y / SIZEY;\n\n const type = draggingCoord.data('coord');\n const grd = curGradient;\n\n switch (type) {\n case 'start':\n attrInput.x1.val(fracx);\n attrInput.y1.val(fracy);\n grd.setAttribute('x1', fracx);\n grd.setAttribute('y1', fracy);\n break;\n case 'end':\n attrInput.x2.val(fracx);\n attrInput.y2.val(fracy);\n grd.setAttribute('x2', fracx);\n grd.setAttribute('y2', fracy);\n break;\n case 'center':\n attrInput.cx.val(fracx);\n attrInput.cy.val(fracy);\n grd.setAttribute('cx', fracx);\n grd.setAttribute('cy', fracy);\n cX = fracx;\n cY = fracy;\n xform();\n break;\n case 'focus':\n attrInput.fx.val(fracx);\n attrInput.fy.val(fracy);\n grd.setAttribute('fx', fracx);\n grd.setAttribute('fy', fracy);\n xform();\n }\n\n evt.preventDefault();\n };\n\n const onCoordUp = function () {\n draggingCoord = null;\n $win.unbind('mousemove', onCoordDrag).unbind('mouseup', onCoordUp);\n };\n\n // Linear gradient\n // (function () {\n\n stops = curGradient.getElementsByTagNameNS(ns.svg, 'stop');\n\n let numstops = stops.length;\n // if there are not at least two stops, then\n if (numstops < 2) {\n while (numstops < 2) {\n curGradient.append(document.createElementNS(ns.svg, 'stop'));\n ++numstops;\n }\n stops = curGradient.getElementsByTagNameNS(ns.svg, 'stop');\n }\n\n for (let i = 0; i < numstops; i++) {\n mkStop(0, 0, 0, 0, stops[i]);\n }\n\n spreadMethodOpt.val(curGradient.getAttribute('spreadMethod') || 'pad');\n\n let offset;\n\n // No match, so show focus point\n showFocus = false;\n\n previewRect.setAttribute('fill-opacity', gradalpha / 100);\n\n $('#' + id + ' div.grad_coord').mousedown(function (evt) {\n evt.preventDefault();\n draggingCoord = $(this);\n // const sPos = draggingCoord.offset();\n offset = draggingCoord.parent().offset();\n $win.mousemove(onCoordDrag).mouseup(onCoordUp);\n });\n\n // bind GUI elements\n $('#' + id + '_jGraduate_Ok').bind('click', function () {\n $this.paint.type = curType;\n $this.paint[curType] = curGradient.cloneNode(true);\n $this.paint.solidColor = null;\n okClicked();\n });\n $('#' + id + '_jGraduate_Cancel').bind('click', function (paint) {\n cancelClicked();\n });\n\n if (curType === 'radialGradient') {\n if (showFocus) {\n focusCoord.show();\n } else {\n focusCoord.hide();\n attrInput.fx.val('');\n attrInput.fy.val('');\n }\n }\n\n $('#' + id + '_jGraduate_match_ctr')[0].checked = !showFocus;\n\n let lastfx, lastfy;\n\n $('#' + id + '_jGraduate_match_ctr').change(function () {\n showFocus = !this.checked;\n focusCoord.toggle(showFocus);\n attrInput.fx.val('');\n attrInput.fy.val('');\n const grd = curGradient;\n if (!showFocus) {\n lastfx = grd.getAttribute('fx');\n lastfy = grd.getAttribute('fy');\n grd.removeAttribute('fx');\n grd.removeAttribute('fy');\n } else {\n const fX = lastfx || 0.5;\n const fY = lastfy || 0.5;\n grd.setAttribute('fx', fX);\n grd.setAttribute('fy', fY);\n attrInput.fx.val(fX);\n attrInput.fy.val(fY);\n }\n });\n\n stops = curGradient.getElementsByTagNameNS(ns.svg, 'stop');\n numstops = stops.length;\n // if there are not at least two stops, then\n if (numstops < 2) {\n while (numstops < 2) {\n curGradient.append(document.createElementNS(ns.svg, 'stop'));\n ++numstops;\n }\n stops = curGradient.getElementsByTagNameNS(ns.svg, 'stop');\n }\n\n let slider;\n\n const setSlider = function (e) {\n const {offset: {left}} = slider;\n const div = slider.parent;\n let x = (e.pageX - left - Number.parseInt(div.css('border-left-width')));\n if (x > SLIDERW) x = SLIDERW;\n if (x <= 0) x = 0;\n const posx = x - 5;\n x /= SLIDERW;\n\n switch (slider.type) {\n case 'radius':\n x = (x * 2) ** 2.5;\n if (x > 0.98 && x < 1.02) x = 1;\n if (x <= 0.01) x = 0.01;\n curGradient.setAttribute('r', x);\n break;\n case 'opacity':\n $this.paint.alpha = Number.parseInt(x * 100);\n previewRect.setAttribute('fill-opacity', x);\n break;\n case 'ellip':\n scaleX = 1;\n scaleY = 1;\n if (x < 0.5) {\n x /= 0.5; // 0.001\n scaleX = x <= 0 ? 0.01 : x;\n } else if (x > 0.5) {\n x /= 0.5; // 2\n x = 2 - x;\n scaleY = x <= 0 ? 0.01 : x;\n }\n xform();\n x -= 1;\n if (scaleY === x + 1) {\n x = Math.abs(x);\n }\n break;\n case 'angle':\n x -= 0.5;\n angle = x *= 180;\n xform();\n x /= 100;\n break;\n }\n slider.elem.css({'margin-left': posx});\n x = Math.round(x * 100);\n slider.input.val(x);\n };\n\n let ellipVal = 0, angleVal = 0;\n\n if (curType === 'radialGradient') {\n const tlist = curGradient.gradientTransform.baseVal;\n if (tlist.numberOfItems === 2) {\n const t = tlist.getItem(0);\n const s = tlist.getItem(1);\n if (t.type === 2 && s.type === 3) {\n const m = s.matrix;\n if (m.a !== 1) {\n ellipVal = Math.round(-(1 - m.a) * 100);\n } else if (m.d !== 1) {\n ellipVal = Math.round((1 - m.d) * 100);\n }\n }\n } else if (tlist.numberOfItems === 3) {\n // Assume [R][T][S]\n const r = tlist.getItem(0);\n const t = tlist.getItem(1);\n const s = tlist.getItem(2);\n\n if (r.type === 4 &&\n t.type === 2 &&\n s.type === 3\n ) {\n angleVal = Math.round(r.angle);\n const m = s.matrix;\n if (m.a !== 1) {\n ellipVal = Math.round(-(1 - m.a) * 100);\n } else if (m.d !== 1) {\n ellipVal = Math.round((1 - m.d) * 100);\n }\n }\n }\n }\n\n const sliders = {\n radius: {\n handle: '#' + id + '_jGraduate_RadiusArrows',\n input: '#' + id + '_jGraduate_RadiusInput',\n val: (curGradient.getAttribute('r') || 0.5) * 100\n },\n opacity: {\n handle: '#' + id + '_jGraduate_OpacArrows',\n input: '#' + id + '_jGraduate_OpacInput',\n val: $this.paint.alpha || 100\n },\n ellip: {\n handle: '#' + id + '_jGraduate_EllipArrows',\n input: '#' + id + '_jGraduate_EllipInput',\n val: ellipVal\n },\n angle: {\n handle: '#' + id + '_jGraduate_AngleArrows',\n input: '#' + id + '_jGraduate_AngleInput',\n val: angleVal\n }\n };\n\n $.each(sliders, function (type, data) {\n const handle = $(data.handle);\n handle.mousedown(function (evt) {\n const parent = handle.parent();\n slider = {\n type,\n elem: handle,\n input: $(data.input),\n parent,\n offset: parent.offset()\n };\n $win.mousemove(dragSlider).mouseup(stopSlider);\n evt.preventDefault();\n });\n\n $(data.input).val(data.val).change(function () {\n const isRad = curType === 'radialGradient';\n let val = Number(this.value);\n let xpos = 0;\n switch (type) {\n case 'radius':\n if (isRad) curGradient.setAttribute('r', val / 100);\n xpos = (((val / 100) ** (1 / 2.5)) / 2) * SLIDERW;\n break;\n\n case 'opacity':\n $this.paint.alpha = val;\n previewRect.setAttribute('fill-opacity', val / 100);\n xpos = val * (SLIDERW / 100);\n break;\n\n case 'ellip':\n scaleX = scaleY = 1;\n if (val === 0) {\n xpos = SLIDERW * 0.5;\n break;\n }\n if (val > 99.5) val = 99.5;\n if (val > 0) {\n scaleY = 1 - (val / 100);\n } else {\n scaleX = -(val / 100) - 1;\n }\n\n xpos = SLIDERW * ((val + 100) / 2) / 100;\n if (isRad) xform();\n break;\n\n case 'angle':\n angle = val;\n xpos = angle / 180;\n xpos += 0.5;\n xpos *= SLIDERW;\n if (isRad) xform();\n }\n if (xpos > SLIDERW) {\n xpos = SLIDERW;\n } else if (xpos < 0) {\n xpos = 0;\n }\n handle.css({'margin-left': xpos - 5});\n }).change();\n });\n\n const dragSlider = function (evt) {\n setSlider(evt);\n evt.preventDefault();\n };\n\n const stopSlider = function (evt) {\n $win.unbind('mousemove', dragSlider).unbind('mouseup', stopSlider);\n slider = null;\n };\n\n // --------------\n let thisAlpha = ($this.paint.alpha * 255 / 100).toString(16);\n while (thisAlpha.length < 2) { thisAlpha = '0' + thisAlpha; }\n thisAlpha = thisAlpha.split('.')[0];\n color = $this.paint.solidColor === 'none' ? '' : $this.paint.solidColor + thisAlpha;\n\n if (!isSolid) {\n color = stops[0].getAttribute('stop-color');\n }\n\n // This should be done somewhere else, probably\n $.extend($.fn.jPicker.defaults.window, {\n alphaSupport: true, effects: {type: 'show', speed: 0}\n });\n\n colPicker.jPicker(\n {\n window: {title: $settings.window.pickerTitle},\n images: {clientPath: $settings.images.clientPath},\n color: {active: color, alphaSupport: true}\n },\n function (clr) {\n $this.paint.type = 'solidColor';\n $this.paint.alpha = clr.val('ahex') ? Math.round((clr.val('a') / 255) * 100) : 100;\n $this.paint.solidColor = clr.val('hex') ? clr.val('hex') : 'none';\n $this.paint.radialGradient = null;\n okClicked();\n },\n null,\n function () { cancelClicked(); }\n );\n\n const tabs = $(idref + ' .jGraduate_tabs li');\n tabs.click(function () {\n tabs.removeClass('jGraduate_tab_current');\n $(this).addClass('jGraduate_tab_current');\n $(idref + ' > div').hide();\n const type = $(this).attr('data-type');\n /* const container = */ $(idref + ' .jGraduate_gradPick').show();\n if (type === 'rg' || type === 'lg') {\n // Show/hide appropriate fields\n $('.jGraduate_' + type + '_field').show();\n $('.jGraduate_' + (type === 'lg' ? 'rg' : 'lg') + '_field').hide();\n\n $('#' + id + '_jgraduate_rect')[0].setAttribute('fill', 'url(#' + id + '_' + type + '_jgraduate_grad)');\n\n // Copy stops\n\n curType = type === 'lg' ? 'linearGradient' : 'radialGradient';\n\n $('#' + id + '_jGraduate_OpacInput').val($this.paint.alpha).change();\n\n const newGrad = $('#' + id + '_' + type + '_jgraduate_grad')[0];\n\n if (curGradient !== newGrad) {\n const curStops = $(curGradient).find('stop');\n $(newGrad).empty().append(curStops);\n curGradient = newGrad;\n const sm = spreadMethodOpt.val();\n curGradient.setAttribute('spreadMethod', sm);\n }\n showFocus = type === 'rg' && curGradient.getAttribute('fx') !== null && !(cx === fx && cy === fy);\n $('#' + id + '_jGraduate_focusCoord').toggle(showFocus);\n if (showFocus) {\n $('#' + id + '_jGraduate_match_ctr')[0].checked = false;\n }\n } else {\n $(idref + ' .jGraduate_gradPick').hide();\n $(idref + ' .jGraduate_colPick').show();\n }\n });\n $(idref + ' > div').hide();\n tabs.removeClass('jGraduate_tab_current');\n let tab;\n switch ($this.paint.type) {\n case 'linearGradient':\n tab = $(idref + ' .jGraduate_tab_lingrad');\n break;\n case 'radialGradient':\n tab = $(idref + ' .jGraduate_tab_radgrad');\n break;\n default:\n tab = $(idref + ' .jGraduate_tab_color');\n break;\n }\n $this.show();\n\n // jPicker will try to show after a 0ms timeout, so need to fire this after that\n setTimeout(() => {\n tab.addClass('jGraduate_tab_current').click();\n }, 10);\n });\n };\n return $;\n}\n","/**\n * SpinButton control.\n *\n * Adds bells and whistles to any ordinary textbox to\n * make it look and feel like a SpinButton Control.\n *\n * Supplies {@link external:jQuery.fn.SpinButton}).\n *\n * Originally written by George Adamson, Software Unity (george.jquery@softwareunity.com) August 2006:\n * - Added min/max options.\n * - Added step size option.\n * - Added bigStep (page up/down) option.\n *\n * Modifications made by Mark Gibson, (mgibson@designlinks.net) September 2006:\n * - Converted to jQuery plugin.\n * - Allow limited or unlimited min/max values.\n * - Allow custom class names, and add class to input element.\n * - Removed global vars.\n * - Reset (to original or through config) when invalid value entered.\n * - Repeat whilst holding mouse button down (with initial pause, like keyboard repeat).\n * - Support mouse wheel in Firefox.\n * - Fix double click in IE.\n * - Refactored some code and renamed some vars.\n *\n * Modifications by Jeff Schiller, June 2009:\n * - provide callback function for when the value changes based on the following\n * {@link https://www.mail-archive.com/jquery-en@googlegroups.com/msg36070.html}.\n *\n * Modifications by Jeff Schiller, July 2009:\n * - improve styling for widget in Opera.\n * - consistent key-repeat handling cross-browser.\n *\n * Modifications by Alexis Deveria, October 2009:\n * - provide \"stepfunc\" callback option to allow custom function to run when changing a value.\n * - Made adjustValue(0) only run on certain keyup events, not all.\n *\n * Tested in IE6, Opera9, Firefox 1.5.\n *\n * | Version | Date | Author | Notes |\n * |---------|------|--------|-------|\n * | v1.0 | 11 Aug 2006 | George Adamson | First release |\n * | v1.1 | Aug 2006 | George Adamson | Minor enhancements |\n * | v1.2 | 27 Sep 2006 | Mark Gibson | Major enhancements |\n * | v1.3a | 28 Sep 2006 | George Adamson | Minor enhancements |\n * | v1.4 | 18 Jun 2009 | Jeff Schiller | Added callback function |\n * | v1.5 | 06 Jul 2009 | Jeff Schiller | Fixes for Opera. |\n * | v1.6 | 13 Oct 2009 | Alexis Deveria | Added stepfunc function |\n * | v1.7 | 21 Oct 2009 | Alexis Deveria | Minor fixes.<br />Fast-repeat for keys and live updating as you type. |\n * | v1.8 | 12 Jan 2010 | Benjamin Thomas | Fixes for mouseout behavior.<br />Added smallStep |\n * | v1.9 | 20 May 2018 | Brett Zamir | Avoid SVGEdit dependency via `stateObj` config;<br />convert to ES6 module |\n * .\n *\n * @module jQuerySpinButton\n * @example\n // Create group of settings to initialise spinbutton(s). (Optional)\n const myOptions = {\n min: 0, // Set lower limit.\n max: 100, // Set upper limit.\n step: 1, // Set increment size.\n smallStep: 0.5, // Set shift-click increment size.\n stateObj: {tool_scale: 1}, // Object to allow passing in live-updating scale\n spinClass: mySpinBtnClass, // CSS class to style the spinbutton. (Class also specifies url of the up/down button image.)\n upClass: mySpinUpClass, // CSS class for style when mouse over up button.\n downClass: mySpinDnClass // CSS class for style when mouse over down button.\n };\n\n $(function () {\n // Initialise INPUT element(s) as SpinButtons: (passing options if desired)\n $('#myInputElement').SpinButton(myOptions);\n });\n */\n/**\n * @function module:jQuerySpinButton.jQuerySpinButton\n * @param {external:jQuery} $ The jQuery object to which to add the plug-in\n * @returns {external:jQuery}\n*/\nexport default function jQueryPluginSpinButton ($) {\n /**\n * @callback module:jQuerySpinButton.StepCallback\n * @param {external:jQuery} thisArg Value of `this`\n * @param {Float} i Value to adjust\n * @returns {Float}\n */\n /**\n * @callback module:jQuerySpinButton.ValueCallback\n * @param {external:jQuery.fn.SpinButton} thisArg Spin Button; check its `value` to see how it was changed.\n * @returns {void}\n */\n /**\n * @typedef {PlainObject} module:jQuerySpinButton.SpinButtonConfig\n * @property {Float} min Set lower limit\n * @property {Float} max Set upper limit.\n * @property {Float} step Set increment size.\n * @property {module:jQuerySpinButton.StepCallback} stepfunc Custom function to run when changing a value; called with `this` of object and the value to adjust and returns a float.\n * @property {module:jQuerySpinButton.ValueCallback} callback Called after value adjusted (with `this` of object)\n * @property {Float} smallStep Set shift-click increment size.\n * @property {PlainObject} stateObj Object to allow passing in live-updating scale\n * @property {Float} stateObj.tool_scale\n * @property {string} spinClass CSS class to style the spinbutton. (Class also specifies url of the up/down button image.)\n * @property {string} upClass CSS class for style when mouse over up button.\n * @property {string} downClass CSS class for style when mouse over down button.\n * @property {Float} page Value to be adjusted on page up/page down\n * @property {Float} reset Reset value when invalid value entered\n * @property {Float} delay Millisecond delay\n * @property {Float} interval Millisecond interval\n */\n /**\n * @function external:jQuery.fn.SpinButton\n * @param {module:jQuerySpinButton.SpinButtonConfig} cfg\n * @returns {external:jQuery}\n */\n $.fn.SpinButton = function (cfg) {\n cfg = cfg || {};\n\n /**\n *\n * @param {Element} el\n * @param {\"offsetLeft\"|\"offsetTop\"} prop\n * @returns {Integer}\n */\n function coord (el, prop) {\n const b = document.body;\n\n let c = el[prop];\n while ((el = el.offsetParent) && (el !== b)) {\n if (!$.browser.msie || (el.currentStyle.position !== 'relative')) {\n c += el[prop];\n }\n }\n\n return c;\n }\n\n return this.each(function () {\n this.repeating = false;\n\n // Apply specified options or defaults:\n // (Ought to refactor this some day to use $.extend() instead)\n this.spinCfg = {\n // min: cfg.min ? Number(cfg.min) : null,\n // max: cfg.max ? Number(cfg.max) : null,\n min: !isNaN(Number.parseFloat(cfg.min)) ? Number(cfg.min) : null, // Fixes bug with min:0\n max: !isNaN(Number.parseFloat(cfg.max)) ? Number(cfg.max) : null,\n step: cfg.step ? Number(cfg.step) : 1,\n stepfunc: cfg.stepfunc || false,\n page: cfg.page ? Number(cfg.page) : 10,\n upClass: cfg.upClass || 'up',\n downClass: cfg.downClass || 'down',\n reset: cfg.reset || this.value,\n delay: cfg.delay ? Number(cfg.delay) : 500,\n interval: cfg.interval ? Number(cfg.interval) : 100,\n _btn_width: 20,\n _direction: null,\n _delay: null,\n _repeat: null,\n callback: cfg.callback || null\n };\n\n // if a smallStep isn't supplied, use half the regular step\n this.spinCfg.smallStep = cfg.smallStep || this.spinCfg.step / 2;\n\n this.adjustValue = function (i) {\n let v;\n if (isNaN(this.value)) {\n v = this.spinCfg.reset;\n } else if (typeof this.spinCfg.stepfunc === 'function') {\n v = this.spinCfg.stepfunc(this, i);\n } else {\n // weirdest JavaScript bug ever: 5.1 + 0.1 = 5.199999999\n v = Number((Number(this.value) + Number(i)).toFixed(5));\n }\n if (this.spinCfg.min !== null) { v = Math.max(v, this.spinCfg.min); }\n if (this.spinCfg.max !== null) { v = Math.min(v, this.spinCfg.max); }\n this.value = v;\n if (typeof this.spinCfg.callback === 'function') {\n this.spinCfg.callback(this);\n }\n };\n\n $(this)\n .addClass(cfg.spinClass || 'spin-button')\n\n .mousemove(function (e) {\n // Determine which button mouse is over, or not (spin direction):\n const x = e.pageX || e.x;\n const y = e.pageY || e.y;\n const el = e.target;\n const scale = cfg.stateObj.tool_scale || 1;\n const height = $(el).height() / 2;\n\n const direction =\n (x > coord(el, 'offsetLeft') +\n el.offsetWidth * scale - this.spinCfg._btn_width)\n ? ((y < coord(el, 'offsetTop') + height * scale) ? 1 : -1)\n : 0;\n\n if (direction !== this.spinCfg._direction) {\n // Style up/down buttons:\n switch (direction) {\n case 1: // Up arrow:\n $(this).removeClass(this.spinCfg.downClass).addClass(this.spinCfg.upClass);\n break;\n case -1: // Down arrow:\n $(this).removeClass(this.spinCfg.upClass).addClass(this.spinCfg.downClass);\n break;\n default: // Mouse is elsewhere in the textbox\n $(this).removeClass(this.spinCfg.upClass).removeClass(this.spinCfg.downClass);\n }\n\n // Set spin direction:\n this.spinCfg._direction = direction;\n }\n })\n\n .mouseout(function () {\n // Reset up/down buttons to their normal appearance when mouse moves away:\n $(this).removeClass(this.spinCfg.upClass).removeClass(this.spinCfg.downClass);\n this.spinCfg._direction = null;\n window.clearInterval(this.spinCfg._repeat);\n window.clearTimeout(this.spinCfg._delay);\n })\n\n .mousedown(function (e) {\n if (e.button === 0 && this.spinCfg._direction !== 0) {\n // Respond to click on one of the buttons:\n const stepSize = e.shiftKey ? this.spinCfg.smallStep : this.spinCfg.step;\n\n const adjust = () => {\n this.adjustValue(this.spinCfg._direction * stepSize);\n };\n\n adjust();\n\n // Initial delay before repeating adjustment\n this.spinCfg._delay = window.setTimeout(() => {\n adjust();\n // Repeat adjust at regular intervals\n this.spinCfg._repeat = window.setInterval(adjust, this.spinCfg.interval);\n }, this.spinCfg.delay);\n }\n })\n\n .mouseup(function (e) {\n // Cancel repeating adjustment\n window.clearInterval(this.spinCfg._repeat);\n window.clearTimeout(this.spinCfg._delay);\n })\n\n .dblclick(function (e) {\n if ($.browser.msie) {\n this.adjustValue(this.spinCfg._direction * this.spinCfg.step);\n }\n })\n\n .keydown(function (e) {\n // Respond to up/down arrow keys.\n switch (e.keyCode) {\n case 38: this.adjustValue(this.spinCfg.step); break; // Up\n case 40: this.adjustValue(-this.spinCfg.step); break; // Down\n case 33: this.adjustValue(this.spinCfg.page); break; // PageUp\n case 34: this.adjustValue(-this.spinCfg.page); break; // PageDown\n }\n })\n\n /*\n http://unixpapa.com/js/key.html describes the current state-of-affairs for\n key repeat events:\n - Safari 3.1 changed their model so that keydown is reliably repeated going forward\n - Firefox and Opera still only repeat the keypress event, not the keydown\n */\n .keypress(function (e) {\n if (this.repeating) {\n // Respond to up/down arrow keys.\n switch (e.keyCode) {\n case 38: this.adjustValue(this.spinCfg.step); break; // Up\n case 40: this.adjustValue(-this.spinCfg.step); break; // Down\n case 33: this.adjustValue(this.spinCfg.page); break; // PageUp\n case 34: this.adjustValue(-this.spinCfg.page); break; // PageDown\n }\n // we always ignore the first keypress event (use the keydown instead)\n } else {\n this.repeating = true;\n }\n })\n\n // clear the 'repeating' flag\n .keyup(function (e) {\n this.repeating = false;\n switch (e.keyCode) {\n case 38: // Up\n case 40: // Down\n case 33: // PageUp\n case 34: // PageDown\n case 13: this.adjustValue(0); break; // Enter/Return\n }\n })\n\n .bind('mousewheel', function (e) {\n // Respond to mouse wheel in IE. (It returns up/dn motion in multiples of 120)\n if (e.wheelDelta >= 120) {\n this.adjustValue(this.spinCfg.step);\n } else if (e.wheelDelta <= -120) {\n this.adjustValue(-this.spinCfg.step);\n }\n\n e.preventDefault();\n })\n\n .change(function (e) {\n this.adjustValue(0);\n });\n\n if (this.addEventListener) {\n // Respond to mouse wheel in Firefox\n this.addEventListener('DOMMouseScroll', function (e) {\n if (e.detail > 0) {\n this.adjustValue(-this.spinCfg.step);\n } else if (e.detail < 0) {\n this.adjustValue(this.spinCfg.step);\n }\n\n e.preventDefault();\n });\n }\n });\n };\n return $;\n}\n","/**\n * @file jQuery Context Menu Plugin\n * Cory S.N. LaViska\n * A Beautiful Site ({@link https://abeautifulsite.net/})\n * Modified by Alexis Deveria\n *\n * More info: {@link https://abeautifulsite.net/2008/09/jquery-context-menu-plugin/}\n *\n * @module jQueryContextMenu\n * @todo Update to latest version and adapt (and needs jQuery update as well): {@link https://github.com/swisnl/jQuery-contextMenu}\n * @version 1.0.1\n *\n * @license (MIT OR GPL-2.0-or-later)\n *\n * This plugin is dual-licensed under the GNU General Public License\n * and the MIT License and is copyright A Beautiful Site, LLC.\n *\n*/\nimport {isMac} from '../../common/browser.js';\n\n/**\n* @callback module:jQueryContextMenu.jQueryContextMenuListener\n* @param {string} href The `href` value after the first character (for bypassing an initial `#`)\n* @param {external:jQuery} srcElement The wrapped jQuery srcElement\n* @param {{x: Float, y: Float, docX: Float, docY: Float}} coords\n* @returns {void}\n*/\n\n/**\n* @typedef {PlainObject} module:jQueryContextMenu.jQueryContextMenuConfig\n* @property {string} menu\n* @property {Float} inSpeed\n* @property {Float} outSpeed\n* @property {boolean} allowLeft\n*/\n\n/**\n* Adds {@link external:jQuery.fn.contextMenu},\n* {@link external:jQuery.fn.disableContextMenuItems},\n* {@link external:jQuery.fn.enableContextMenuItems},\n* {@link external:jQuery.fn.disableContextMenu},\n* {@link external:jQuery.fn.enableContextMenu},\n* {@link external:jQuery.fn.destroyContextMenu}.\n* @function module:jQueryContextMenu.jQueryContextMenu\n* @param {external:jQuery} $ The jQuery object to wrap (with `contextMenu`, `disableContextMenuItems`, `enableContextMenuItems`, `disableContextMenu`, `enableContextMenu`, `destroyContextMenu`)\n* @returns {external:jQuery}\n*/\nfunction jQueryContextMenu ($) {\n const win = $(window);\n const doc = $(document);\n\n $.extend($.fn, {\n /**\n * @memberof external:jQuery.fn\n * @param {module:jQueryContextMenu.jQueryContextMenuConfig} o\n * @param {module:jQueryContextMenu.jQueryContextMenuListener} listener\n * @returns {external:jQuery}\n */\n contextMenu (o, listener) {\n // Defaults\n if (o.menu === undefined) return false;\n if (o.inSpeed === undefined) o.inSpeed = 150;\n if (o.outSpeed === undefined) o.outSpeed = 75;\n // 0 needs to be -1 for expected results (no fade)\n if (o.inSpeed === 0) o.inSpeed = -1;\n if (o.outSpeed === 0) o.outSpeed = -1;\n // Loop each context menu\n $(this).each(function () {\n const el = $(this);\n const offset = $(el).offset();\n\n const menu = $('#' + o.menu);\n\n // Add contextMenu class\n menu.addClass('contextMenu');\n // Simulate a true right click\n $(this).bind('mousedown', function (evt) {\n $(this).mouseup(function (e) {\n const srcElement = $(this);\n srcElement.unbind('mouseup');\n\n if (!(evt.button === 2 || o.allowLeft ||\n (evt.ctrlKey && isMac()))) {\n return undefined;\n }\n e.stopPropagation();\n // Hide context menus that may be showing\n $('.contextMenu').hide();\n // Get this context menu\n\n if (el.hasClass('disabled')) return false;\n\n // Detect mouse position\n let x = e.pageX, y = e.pageY;\n\n const xOff = win.width() - menu.width(),\n yOff = win.height() - menu.height();\n\n if (x > xOff - 15) x = xOff - 15;\n if (y > yOff - 30) y = yOff - 30; // 30 is needed to prevent scrollbars in FF\n\n // Show the menu\n doc.unbind('click');\n menu.css({top: y, left: x}).fadeIn(o.inSpeed);\n // Hover events\n menu.find('A').mouseover(function () {\n menu.find('LI.hover').removeClass('hover');\n $(this).parent().addClass('hover');\n }).mouseout(function () {\n menu.find('LI.hover').removeClass('hover');\n });\n\n // Keyboard\n doc.keypress(function (ev) {\n switch (ev.keyCode) {\n case 38: // up\n if (!menu.find('LI.hover').length) {\n menu.find('LI:last').addClass('hover');\n } else {\n menu.find('LI.hover').removeClass('hover').prevAll('LI:not(.disabled)').eq(0).addClass('hover');\n if (!menu.find('LI.hover').length) menu.find('LI:last').addClass('hover');\n }\n break;\n case 40: // down\n if (!menu.find('LI.hover').length) {\n menu.find('LI:first').addClass('hover');\n } else {\n menu.find('LI.hover').removeClass('hover').nextAll('LI:not(.disabled)').eq(0).addClass('hover');\n if (!menu.find('LI.hover').length) menu.find('LI:first').addClass('hover');\n }\n break;\n case 13: // enter\n menu.find('LI.hover A').trigger('click');\n break;\n case 27: // esc\n doc.trigger('click');\n break;\n }\n });\n\n // When items are selected\n menu.find('A').unbind('mouseup');\n menu.find('LI:not(.disabled) A').mouseup(function () {\n doc.unbind('click').unbind('keypress');\n $('.contextMenu').hide();\n if (listener) {\n listener($(this).attr('href').substr(1), $(srcElement), {\n x: x - offset.left, y: y - offset.top, docX: x, docY: y\n });\n }\n return false;\n });\n\n // Hide bindings\n setTimeout(function () { // Delay for Mozilla\n doc.click(function () {\n doc.unbind('click').unbind('keypress');\n menu.fadeOut(o.outSpeed);\n return false;\n });\n }, 0);\n return undefined;\n });\n });\n\n // Disable text selection\n if ($.browser.mozilla) {\n $('#' + o.menu).each(function () { $(this).css({MozUserSelect: 'none'}); });\n } else if ($.browser.msie) {\n $('#' + o.menu).each(function () { $(this).bind('selectstart.disableTextSelect', function () { return false; }); });\n } else {\n $('#' + o.menu).each(function () { $(this).bind('mousedown.disableTextSelect', function () { return false; }); });\n }\n // Disable browser context menu (requires both selectors to work in IE/Safari + FF/Chrome)\n $(el).add($('UL.contextMenu')).bind('contextmenu', function () { return false; });\n });\n return $(this);\n },\n\n /**\n * Disable context menu items on the fly.\n * @memberof external:jQuery.fn\n * @param {void|string} o Comma-separated\n * @returns {external:jQuery}\n */\n disableContextMenuItems (o) {\n if (o === undefined) {\n // Disable all\n $(this).find('LI').addClass('disabled');\n return $(this);\n }\n $(this).each(function () {\n if (o !== undefined) {\n const d = o.split(',');\n for (const href of d) {\n $(this).find('A[href=\"' + href + '\"]').parent().addClass('disabled');\n }\n }\n });\n return $(this);\n },\n\n /**\n * Enable context menu items on the fly.\n * @memberof external:jQuery.fn\n * @param {void|string} o Comma-separated\n * @returns {external:jQuery}\n */\n enableContextMenuItems (o) {\n if (o === undefined) {\n // Enable all\n $(this).find('LI.disabled').removeClass('disabled');\n return $(this);\n }\n $(this).each(function () {\n if (o !== undefined) {\n const d = o.split(',');\n for (const href of d) {\n $(this).find('A[href=\"' + href + '\"]').parent().removeClass('disabled');\n }\n }\n });\n return $(this);\n },\n\n /**\n * Disable context menu(s).\n * @memberof external:jQuery.fn\n * @returns {external:jQuery}\n */\n disableContextMenu () {\n $(this).each(function () {\n $(this).addClass('disabled');\n });\n return $(this);\n },\n\n /**\n * Enable context menu(s).\n * @memberof external:jQuery.fn\n * @returns {external:jQuery}\n */\n enableContextMenu () {\n $(this).each(function () {\n $(this).removeClass('disabled');\n });\n return $(this);\n },\n\n /**\n * Destroy context menu(s).\n * @memberof external:jQuery.fn\n * @returns {external:jQuery}\n */\n destroyContextMenu () {\n // Destroy specified context menus\n $(this).each(function () {\n // Disable action\n $(this).unbind('mousedown').unbind('mouseup');\n });\n return $(this);\n }\n });\n return $;\n}\n\nexport default jQueryContextMenu;\n","/* eslint-disable no-bitwise, max-len */\n/**\n * @file jPicker (Adapted from version 1.1.6)\n *\n * jQuery Plugin for Photoshop style color picker\n *\n * @module jPicker\n * @copyright (c) 2010 Christopher T. Tillman\n * Digital Magic Productions, Inc. ({@link http://www.digitalmagicpro.com/})\n * FREE to use, alter, copy, sell, and especially ENHANCE\n * @license MIT\n *\n * Painstakingly ported from John Dyers' excellent work on his own color picker based on the Prototype framework.\n *\n * John Dyers' website: {@link http://johndyer.name}\n * Color Picker page: {@link http://johndyer.name/photoshop-like-javascript-color-picker/}\n */\n\n/**\n* @external Math\n*/\n/**\n* @memberof external:Math\n* @param {Float} value\n* @param {Float} precision\n* @returns {Float}\n*/\nfunction toFixedNumeric (value, precision) {\n if (precision === undefined) precision = 0;\n return Math.round(value * (10 ** precision)) / (10 ** precision);\n}\n\n/**\n * Whether a value is `null` or `undefined`.\n * @param {any} val\n * @returns {boolean}\n */\nconst isNullish = (val) => {\n return val === null || val === undefined;\n};\n\n/**\n* @function module:jPicker.jPicker\n* @param {external:jQuery} $ The jQuery object, {@link external:jQuery.fn.$.fn.jPicker}, {@link external:jQuery.fn.$.fn.jPicker.defaults})\n* @returns {external:jQuery}\n*/\nconst jPicker = function ($) {\n /**\n * @typedef {PlainObject} module:jPicker.SliderOptions\n * @property {external:jQuery|PlainObject} arrow\n * @property {string} arrow.image Not in use?\n * @property {Float} arrow.width\n * @property {Float} arrow.height\n * @property {PlainObject} map\n * @property {Float} map.width\n * @property {Float} map.height\n */\n\n /**\n * Encapsulate slider functionality for the ColorMap and ColorBar -\n * could be useful to use a jQuery UI draggable for this with certain extensions.\n * @memberof module:jPicker\n */\n class Slider {\n /**\n * @param {external:jQuery} bar\n * @param {module:jPicker.SliderOptions} options\n */\n constructor (bar, options) {\n const that = this;\n /**\n * Fire events on the supplied `context`\n * @param {module:jPicker.JPickerInit} context\n * @returns {void}\n */\n function fireChangeEvents (context) {\n changeEvents.forEach((changeEvent) => {\n changeEvent.call(that, that, context);\n });\n }\n\n /**\n * Bind the mousedown to the bar not the arrow for quick snapping to the clicked location.\n * @param {external:jQuery.Event} e\n * @returns {void}\n */\n function mouseDown (e) {\n const off = bar.offset();\n offset = {l: off.left | 0, t: off.top | 0};\n clearTimeout(timeout);\n // using setTimeout for visual updates - once the style is updated the browser will re-render internally allowing the next Javascript to run\n timeout = setTimeout(function () {\n setValuesFromMousePosition.call(that, e);\n }, 0);\n // Bind mousemove and mouseup event to the document so it responds when dragged of of the bar - we will unbind these when on mouseup to save processing\n $(document).bind('mousemove', mouseMove).bind('mouseup', mouseUp);\n e.preventDefault(); // don't try to select anything or drag the image to the desktop\n }\n /**\n * Set the values as the mouse moves.\n * @param {external:jQuery.Event} e\n * @returns {false}\n */\n function mouseMove (e) {\n clearTimeout(timeout);\n timeout = setTimeout(function () {\n setValuesFromMousePosition.call(that, e);\n }, 0);\n e.stopPropagation();\n e.preventDefault();\n return false;\n }\n /**\n * Unbind the document events - they aren't needed when not dragging.\n * @param {external:jQuery.Event} e\n * @returns {false}\n */\n function mouseUp (e) {\n $(document).unbind('mouseup', mouseUp).unbind('mousemove', mouseMove);\n e.stopPropagation();\n e.preventDefault();\n return false;\n }\n\n /**\n * Calculate mouse position and set value within the current range.\n * @param {Event} e\n * @returns {void}\n */\n function setValuesFromMousePosition (e) {\n const barW = bar.w, // local copies for YUI compressor\n barH = bar.h;\n let locX = e.pageX - offset.l,\n locY = e.pageY - offset.t;\n // keep the arrow within the bounds of the bar\n if (locX < 0) locX = 0;\n else if (locX > barW) locX = barW;\n if (locY < 0) locY = 0;\n else if (locY > barH) locY = barH;\n val.call(that, 'xy', {\n x: ((locX / barW) * rangeX) + minX,\n y: ((locY / barH) * rangeY) + minY\n });\n }\n /**\n *\n * @returns {void}\n */\n function draw () {\n const\n barW = bar.w,\n barH = bar.h,\n arrowW = arrow.w,\n arrowH = arrow.h;\n let arrowOffsetX = 0,\n arrowOffsetY = 0;\n setTimeout(function () {\n if (rangeX > 0) { // range is greater than zero\n // constrain to bounds\n if (x === maxX) arrowOffsetX = barW;\n else arrowOffsetX = ((x / rangeX) * barW) | 0;\n }\n if (rangeY > 0) { // range is greater than zero\n // constrain to bounds\n if (y === maxY) arrowOffsetY = barH;\n else arrowOffsetY = ((y / rangeY) * barH) | 0;\n }\n // if arrow width is greater than bar width, center arrow and prevent horizontal dragging\n if (arrowW >= barW) arrowOffsetX = (barW >> 1) - (arrowW >> 1); // number >> 1 - superfast bitwise divide by two and truncate (move bits over one bit discarding lowest)\n else arrowOffsetX -= arrowW >> 1;\n // if arrow height is greater than bar height, center arrow and prevent vertical dragging\n if (arrowH >= barH) arrowOffsetY = (barH >> 1) - (arrowH >> 1);\n else arrowOffsetY -= arrowH >> 1;\n // set the arrow position based on these offsets\n arrow.css({left: arrowOffsetX + 'px', top: arrowOffsetY + 'px'});\n });\n }\n\n /**\n * Get or set a value.\n * @param {?(\"xy\"|\"x\"|\"y\")} name\n * @param {module:math.XYObject} value\n * @param {module:jPicker.Slider} context\n * @returns {module:math.XYObject|Float|void}\n */\n function val (name, value, context) {\n const set = value !== undefined;\n if (!set) {\n if (isNullish(name)) name = 'xy';\n switch (name.toLowerCase()) {\n case 'x': return x;\n case 'y': return y;\n case 'xy':\n default: return {x, y};\n }\n }\n if (!isNullish(context) && context === that) return undefined;\n let changed = false;\n\n let newX, newY;\n if (isNullish(name)) name = 'xy';\n switch (name.toLowerCase()) {\n case 'x':\n newX = (value && ((value.x && value.x | 0) || value | 0)) || 0;\n break;\n case 'y':\n newY = (value && ((value.y && value.y | 0) || value | 0)) || 0;\n break;\n case 'xy':\n default:\n newX = (value && value.x && value.x | 0) || 0;\n newY = (value && value.y && value.y | 0) || 0;\n break;\n }\n if (!isNullish(newX)) {\n if (newX < minX) newX = minX;\n else if (newX > maxX) newX = maxX;\n if (x !== newX) {\n x = newX;\n changed = true;\n }\n }\n if (!isNullish(newY)) {\n if (newY < minY) newY = minY;\n else if (newY > maxY) newY = maxY;\n if (y !== newY) {\n y = newY;\n changed = true;\n }\n }\n changed && fireChangeEvents.call(that, context || that);\n return undefined;\n }\n\n /**\n * @typedef {PlainObject} module:jPicker.MinMaxRangeX\n * @property {Float} minX\n * @property {Float} maxX\n * @property {Float} rangeX\n */\n /**\n * @typedef {PlainObject} module:jPicker.MinMaxRangeY\n * @property {Float} minY\n * @property {Float} maxY\n * @property {Float} rangeY\n */\n /**\n * @typedef {module:jPicker.MinMaxRangeY|module:jPicker.MinMaxRangeX} module:jPicker.MinMaxRangeXY\n */\n\n /**\n *\n * @param {\"minx\"|\"maxx\"|\"rangex\"|\"miny\"|\"maxy\"|\"rangey\"|\"all\"} name\n * @param {module:jPicker.MinMaxRangeXY} value\n * @returns {module:jPicker.MinMaxRangeXY|module:jPicker.MinMaxRangeX|module:jPicker.MinMaxRangeY|void}\n */\n function range (name, value) {\n const set = value !== undefined;\n if (!set) {\n if (isNullish(name)) name = 'all';\n switch (name.toLowerCase()) {\n case 'minx': return minX;\n case 'maxx': return maxX;\n case 'rangex': return {minX, maxX, rangeX};\n case 'miny': return minY;\n case 'maxy': return maxY;\n case 'rangey': return {minY, maxY, rangeY};\n case 'all':\n default: return {minX, maxX, rangeX, minY, maxY, rangeY};\n }\n }\n let // changed = false,\n newMinX,\n newMaxX,\n newMinY,\n newMaxY;\n if (isNullish(name)) name = 'all';\n switch (name.toLowerCase()) {\n case 'minx':\n newMinX = (value && ((value.minX && value.minX | 0) || value | 0)) || 0;\n break;\n case 'maxx':\n newMaxX = (value && ((value.maxX && value.maxX | 0) || value | 0)) || 0;\n break;\n case 'rangex':\n newMinX = (value && value.minX && value.minX | 0) || 0;\n newMaxX = (value && value.maxX && value.maxX | 0) || 0;\n break;\n case 'miny':\n newMinY = (value && ((value.minY && value.minY | 0) || value | 0)) || 0;\n break;\n case 'maxy':\n newMaxY = (value && ((value.maxY && value.maxY | 0) || value | 0)) || 0;\n break;\n case 'rangey':\n newMinY = (value && value.minY && value.minY | 0) || 0;\n newMaxY = (value && value.maxY && value.maxY | 0) || 0;\n break;\n case 'all':\n default:\n newMinX = (value && value.minX && value.minX | 0) || 0;\n newMaxX = (value && value.maxX && value.maxX | 0) || 0;\n newMinY = (value && value.minY && value.minY | 0) || 0;\n newMaxY = (value && value.maxY && value.maxY | 0) || 0;\n break;\n }\n\n if (!isNullish(newMinX) && minX !== newMinX) {\n minX = newMinX;\n rangeX = maxX - minX;\n }\n if (!isNullish(newMaxX) && maxX !== newMaxX) {\n maxX = newMaxX;\n rangeX = maxX - minX;\n }\n if (!isNullish(newMinY) && minY !== newMinY) {\n minY = newMinY;\n rangeY = maxY - minY;\n }\n if (!isNullish(newMaxY) && maxY !== newMaxY) {\n maxY = newMaxY;\n rangeY = maxY - minY;\n }\n return undefined;\n }\n /**\n * @param {GenericCallback} callback\n * @returns {void}\n */\n function bind (callback) { // eslint-disable-line promise/prefer-await-to-callbacks\n if (typeof callback === 'function') changeEvents.push(callback);\n }\n /**\n * @param {GenericCallback} callback\n * @returns {void}\n */\n function unbind (callback) { // eslint-disable-line promise/prefer-await-to-callbacks\n if (typeof callback !== 'function') return;\n let i;\n while ((i = changeEvents.includes(callback))) changeEvents.splice(i, 1);\n }\n /**\n *\n * @returns {void}\n */\n function destroy () {\n // unbind all possible events and null objects\n $(document).unbind('mouseup', mouseUp).unbind('mousemove', mouseMove);\n bar.unbind('mousedown', mouseDown);\n bar = null;\n arrow = null;\n changeEvents = null;\n }\n let offset,\n timeout,\n x = 0,\n y = 0,\n minX = 0,\n maxX = 100,\n rangeX = 100,\n minY = 0,\n maxY = 100,\n rangeY = 100,\n arrow = bar.find('img:first'), // the arrow image to drag\n changeEvents = [];\n\n $.extend(\n true,\n // public properties, methods, and event bindings - these we need\n // to access from other controls\n that,\n {\n val,\n range,\n bind,\n unbind,\n destroy\n }\n );\n // initialize this control\n arrow.src = options.arrow && options.arrow.image;\n arrow.w = (options.arrow && options.arrow.width) || arrow.width();\n arrow.h = (options.arrow && options.arrow.height) || arrow.height();\n bar.w = (options.map && options.map.width) || bar.width();\n bar.h = (options.map && options.map.height) || bar.height();\n // bind mousedown event\n bar.bind('mousedown', mouseDown);\n bind.call(that, draw);\n }\n }\n\n /**\n * Controls for all the input elements for the typing in color values.\n */\n class ColorValuePicker {\n /**\n * @param {external:jQuery} picker\n * @param {external:jQuery.jPicker.Color} color\n * @param {external:jQuery.fn.$.fn.jPicker} bindedHex\n * @param {Float} alphaPrecision\n */\n constructor (picker, color, bindedHex, alphaPrecision) {\n const that = this; // private properties and methods\n const inputs = picker.find('td.Text input');\n // input box key down - use arrows to alter color\n /**\n *\n * @param {Event} e\n * @returns {Event|false|void}\n */\n function keyDown (e) {\n if (e.target.value === '' && e.target !== hex.get(0) && ((!isNullish(bindedHex) && e.target !== bindedHex.get(0)) || isNullish(bindedHex))) return undefined;\n if (!validateKey(e)) return e;\n switch (e.target) {\n case red.get(0):\n switch (e.keyCode) {\n case 38:\n red.val(setValueInRange.call(that, (red.val() << 0) + 1, 0, 255));\n color.val('r', red.val(), e.target);\n return false;\n case 40:\n red.val(setValueInRange.call(that, (red.val() << 0) - 1, 0, 255));\n color.val('r', red.val(), e.target);\n return false;\n }\n break;\n case green.get(0):\n switch (e.keyCode) {\n case 38:\n green.val(setValueInRange.call(that, (green.val() << 0) + 1, 0, 255));\n color.val('g', green.val(), e.target);\n return false;\n case 40:\n green.val(setValueInRange.call(that, (green.val() << 0) - 1, 0, 255));\n color.val('g', green.val(), e.target);\n return false;\n }\n break;\n case blue.get(0):\n switch (e.keyCode) {\n case 38:\n blue.val(setValueInRange.call(that, (blue.val() << 0) + 1, 0, 255));\n color.val('b', blue.val(), e.target);\n return false;\n case 40:\n blue.val(setValueInRange.call(that, (blue.val() << 0) - 1, 0, 255));\n color.val('b', blue.val(), e.target);\n return false;\n }\n break;\n case alpha && alpha.get(0):\n switch (e.keyCode) {\n case 38:\n alpha.val(setValueInRange.call(that, Number.parseFloat(alpha.val()) + 1, 0, 100));\n color.val('a', toFixedNumeric((alpha.val() * 255) / 100, alphaPrecision), e.target);\n return false;\n case 40:\n alpha.val(setValueInRange.call(that, Number.parseFloat(alpha.val()) - 1, 0, 100));\n color.val('a', toFixedNumeric((alpha.val() * 255) / 100, alphaPrecision), e.target);\n return false;\n }\n break;\n case hue.get(0):\n switch (e.keyCode) {\n case 38:\n hue.val(setValueInRange.call(that, (hue.val() << 0) + 1, 0, 360));\n color.val('h', hue.val(), e.target);\n return false;\n case 40:\n hue.val(setValueInRange.call(that, (hue.val() << 0) - 1, 0, 360));\n color.val('h', hue.val(), e.target);\n return false;\n }\n break;\n case saturation.get(0):\n switch (e.keyCode) {\n case 38:\n saturation.val(setValueInRange.call(that, (saturation.val() << 0) + 1, 0, 100));\n color.val('s', saturation.val(), e.target);\n return false;\n case 40:\n saturation.val(setValueInRange.call(that, (saturation.val() << 0) - 1, 0, 100));\n color.val('s', saturation.val(), e.target);\n return false;\n }\n break;\n case value.get(0):\n switch (e.keyCode) {\n case 38:\n value.val(setValueInRange.call(that, (value.val() << 0) + 1, 0, 100));\n color.val('v', value.val(), e.target);\n return false;\n case 40:\n value.val(setValueInRange.call(that, (value.val() << 0) - 1, 0, 100));\n color.val('v', value.val(), e.target);\n return false;\n }\n break;\n }\n return undefined;\n }\n // input box key up - validate value and set color\n /**\n * @param {Event} e\n * @returns {Event|void}\n * @todo Why is this returning an event?\n */\n function keyUp (e) {\n if (e.target.value === '' && e.target !== hex.get(0) &&\n ((!isNullish(bindedHex) && e.target !== bindedHex.get(0)) ||\n isNullish(bindedHex))) return undefined;\n if (!validateKey(e)) return e;\n switch (e.target) {\n case red.get(0):\n red.val(setValueInRange.call(that, red.val(), 0, 255));\n color.val('r', red.val(), e.target);\n break;\n case green.get(0):\n green.val(setValueInRange.call(that, green.val(), 0, 255));\n color.val('g', green.val(), e.target);\n break;\n case blue.get(0):\n blue.val(setValueInRange.call(that, blue.val(), 0, 255));\n color.val('b', blue.val(), e.target);\n break;\n case alpha && alpha.get(0):\n alpha.val(setValueInRange.call(that, alpha.val(), 0, 100));\n color.val('a', toFixedNumeric((alpha.val() * 255) / 100, alphaPrecision), e.target);\n break;\n case hue.get(0):\n hue.val(setValueInRange.call(that, hue.val(), 0, 360));\n color.val('h', hue.val(), e.target);\n break;\n case saturation.get(0):\n saturation.val(setValueInRange.call(that, saturation.val(), 0, 100));\n color.val('s', saturation.val(), e.target);\n break;\n case value.get(0):\n value.val(setValueInRange.call(that, value.val(), 0, 100));\n color.val('v', value.val(), e.target);\n break;\n case hex.get(0):\n hex.val(hex.val().replace(/[^a-fA-F\\d]/g, '').toLowerCase().substring(0, 6));\n bindedHex && bindedHex.val(hex.val());\n color.val('hex', hex.val() !== '' ? hex.val() : null, e.target);\n break;\n case bindedHex && bindedHex.get(0):\n bindedHex.val(bindedHex.val().replace(/[^a-fA-F\\d]/g, '').toLowerCase().substring(0, 6));\n hex.val(bindedHex.val());\n color.val('hex', bindedHex.val() !== '' ? bindedHex.val() : null, e.target);\n break;\n case ahex && ahex.get(0):\n ahex.val(ahex.val().replace(/[^a-fA-F\\d]/g, '').toLowerCase().substring(0, 2));\n color.val('a', !isNullish(ahex.val()) ? Number.parseInt(ahex.val(), 16) : null, e.target);\n break;\n }\n return undefined;\n }\n // input box blur - reset to original if value empty\n /**\n * @param {Event} e\n * @returns {void}\n */\n function blur (e) {\n if (!isNullish(color.val())) {\n switch (e.target) {\n case red.get(0): red.val(color.val('r')); break;\n case green.get(0): green.val(color.val('g')); break;\n case blue.get(0): blue.val(color.val('b')); break;\n case alpha && alpha.get(0): alpha.val(toFixedNumeric((color.val('a') * 100) / 255, alphaPrecision)); break;\n case hue.get(0): hue.val(color.val('h')); break;\n case saturation.get(0): saturation.val(color.val('s')); break;\n case value.get(0): value.val(color.val('v')); break;\n case hex.get(0):\n case bindedHex && bindedHex.get(0):\n hex.val(color.val('hex'));\n bindedHex && bindedHex.val(color.val('hex'));\n break;\n case ahex && ahex.get(0): ahex.val(color.val('ahex').substring(6)); break;\n }\n }\n }\n /**\n * @param {Event} e\n * @returns {boolean}\n */\n function validateKey (e) {\n switch (e.keyCode) {\n case 9:\n case 16:\n case 29:\n case 37:\n case 39:\n return false;\n case 'c'.charCodeAt():\n case 'v'.charCodeAt():\n if (e.ctrlKey) return false;\n }\n return true;\n }\n\n /**\n * Constrain value within range.\n * @param {Float|string} value\n * @param {Float} min\n * @param {Float} max\n * @returns {Float|string} Returns a number or numeric string\n */\n function setValueInRange (value, min, max) {\n if (value === '' || isNaN(value)) return min;\n if (value > max) return max;\n if (value < min) return min;\n return value;\n }\n /**\n * @param {external:jQuery} ui\n * @param {Element} context\n * @returns {void}\n */\n function colorChanged (ui, context) {\n const all = ui.val('all');\n if (context !== red.get(0)) red.val(!isNullish(all) ? all.r : '');\n if (context !== green.get(0)) green.val(!isNullish(all) ? all.g : '');\n if (context !== blue.get(0)) blue.val(!isNullish(all) ? all.b : '');\n if (alpha && context !== alpha.get(0)) alpha.val(!isNullish(all) ? toFixedNumeric((all.a * 100) / 255, alphaPrecision) : '');\n if (context !== hue.get(0)) hue.val(!isNullish(all) ? all.h : '');\n if (context !== saturation.get(0)) saturation.val(!isNullish(all) ? all.s : '');\n if (context !== value.get(0)) value.val(!isNullish(all) ? all.v : '');\n if (context !== hex.get(0) && ((bindedHex && context !== bindedHex.get(0)) || !bindedHex)) hex.val(!isNullish(all) ? all.hex : '');\n if (bindedHex && context !== bindedHex.get(0) && context !== hex.get(0)) bindedHex.val(!isNullish(all) ? all.hex : '');\n if (ahex && context !== ahex.get(0)) ahex.val(!isNullish(all) ? all.ahex.substring(6) : '');\n }\n /**\n * Unbind all events and null objects.\n * @returns {void}\n */\n function destroy () {\n red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).add(hex).add(bindedHex).add(ahex).unbind('keyup', keyUp).unbind('blur', blur);\n red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).unbind('keydown', keyDown);\n color.unbind(colorChanged);\n red = null;\n green = null;\n blue = null;\n alpha = null;\n hue = null;\n saturation = null;\n value = null;\n hex = null;\n ahex = null;\n }\n let\n red = inputs.eq(3),\n green = inputs.eq(4),\n blue = inputs.eq(5),\n alpha = inputs.length > 7 ? inputs.eq(6) : null,\n hue = inputs.eq(0),\n saturation = inputs.eq(1),\n value = inputs.eq(2),\n hex = inputs.eq(inputs.length > 7 ? 7 : 6),\n ahex = inputs.length > 7 ? inputs.eq(8) : null;\n $.extend(true, that, {\n // public properties and methods\n destroy\n });\n red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).add(hex).add(bindedHex).add(ahex).bind('keyup', keyUp).bind('blur', blur);\n red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).bind('keydown', keyDown);\n color.bind(colorChanged);\n }\n }\n\n /**\n * @typedef {PlainObject} module:jPicker.JPickerInit\n * @property {Integer} [a]\n * @property {Integer} [b]\n * @property {Integer} [g]\n * @property {Integer} [h]\n * @property {Integer} [r]\n * @property {Integer} [s]\n * @property {Integer} [v]\n * @property {string} [hex]\n * @property {string} [ahex]\n */\n\n /* eslint-disable jsdoc/require-property */\n /**\n * @namespace {PlainObject} jPicker\n * @memberof external:jQuery\n */\n $.jPicker = /** @lends external:jQuery.jPicker */ {\n /* eslint-enable jsdoc/require-property */\n /**\n * Array holding references to each active instance of the jPicker control.\n * @type {external:jQuery.fn.$.fn.jPicker[]}\n */\n List: [],\n /**\n * Color object - we will be able to assign by any color space type or\n * retrieve any color space info.\n * We want this public so we can optionally assign new color objects to\n * initial values using inputs other than a string hex value (also supported)\n * Note: JSDoc didn't document when expressed here as an ES6 Class.\n * @namespace\n * @class\n * @memberof external:jQuery.jPicker\n * @param {module:jPicker.JPickerInit} init\n * @returns {external:jQuery.jPicker.Color}\n */\n Color: function (init) { // eslint-disable-line object-shorthand\n const that = this;\n /**\n *\n * @param {module:jPicker.Slider} context\n * @returns {void}\n */\n function fireChangeEvents (context) {\n for (let i = 0; i < changeEvents.length; i++) changeEvents[i].call(that, that, context);\n }\n\n /**\n * @param {string|\"ahex\"|\"hex\"|\"all\"|\"\"|null|void} name String composed of letters \"r\", \"g\", \"b\", \"a\", \"h\", \"s\", and/or \"v\"\n * @param {module:jPicker.RGBA|module:jPicker.JPickerInit|string} [value]\n * @param {external:jQuery.jPicker.Color} context\n * @returns {module:jPicker.JPickerInit|string|null|void}\n */\n function val (name, value, context) {\n // Kind of ugly\n const set = Boolean(value);\n if (set && value.ahex === '') value.ahex = '00000000';\n if (!set) {\n let ret;\n if (isNullish(name) || name === '') name = 'all';\n if (isNullish(r)) return null;\n switch (name.toLowerCase()) {\n case 'ahex': return ColorMethods.rgbaToHex({r, g, b, a});\n case 'hex': return val('ahex').substring(0, 6);\n case 'all': return {\n r, g, b, a, h, s, v,\n hex: val.call(that, 'hex'),\n ahex: val.call(that, 'ahex')\n };\n default: {\n ret = {};\n const nameLength = name.length;\n [...name].forEach((ch) => {\n switch (ch) {\n case 'r':\n if (nameLength === 1) ret = r;\n else ret.r = r;\n break;\n case 'g':\n if (nameLength === 1) ret = g;\n else ret.g = g;\n break;\n case 'b':\n if (nameLength === 1) ret = b;\n else ret.b = b;\n break;\n case 'a':\n if (nameLength === 1) ret = a;\n else ret.a = a;\n break;\n case 'h':\n if (nameLength === 1) ret = h;\n else ret.h = h;\n break;\n case 's':\n if (nameLength === 1) ret = s;\n else ret.s = s;\n break;\n case 'v':\n if (nameLength === 1) ret = v;\n else ret.v = v;\n break;\n }\n });\n }\n }\n return typeof ret === 'object' && !Object.keys(ret).length\n ? val.call(that, 'all')\n : ret;\n }\n if (!isNullish(context) && context === that) return undefined;\n if (isNullish(name)) name = '';\n\n let changed = false;\n if (isNullish(value)) {\n if (!isNullish(r)) {\n r = null;\n changed = true;\n }\n if (!isNullish(g)) {\n g = null;\n changed = true;\n }\n if (!isNullish(b)) {\n b = null;\n changed = true;\n }\n if (!isNullish(a)) {\n a = null;\n changed = true;\n }\n if (!isNullish(h)) {\n h = null;\n changed = true;\n }\n if (!isNullish(s)) {\n s = null;\n changed = true;\n }\n if (!isNullish(v)) {\n v = null;\n changed = true;\n }\n changed && fireChangeEvents.call(that, context || that);\n return undefined;\n }\n switch (name.toLowerCase()) {\n case 'ahex':\n case 'hex': {\n const ret = ColorMethods.hexToRgba((value && (value.ahex || value.hex)) || value || 'none');\n val.call(that, 'rgba', {\n r: ret.r,\n g: ret.g,\n b: ret.b,\n a: name === 'ahex'\n ? ret.a\n : !isNullish(a)\n ? a\n : 255\n }, context);\n break;\n } default: {\n if (value && (!isNullish(value.ahex) || !isNullish(value.hex))) {\n val.call(that, 'ahex', value.ahex || value.hex || '00000000', context);\n return undefined;\n }\n const newV = {};\n let rgb = false, hsv = false;\n if (value.r !== undefined && !name.includes('r')) name += 'r';\n if (value.g !== undefined && !name.includes('g')) name += 'g';\n if (value.b !== undefined && !name.includes('b')) name += 'b';\n if (value.a !== undefined && !name.includes('a')) name += 'a';\n if (value.h !== undefined && !name.includes('h')) name += 'h';\n if (value.s !== undefined && !name.includes('s')) name += 's';\n if (value.v !== undefined && !name.includes('v')) name += 'v';\n [...name].forEach((ch) => {\n switch (ch) {\n case 'r':\n if (hsv) return;\n rgb = true;\n newV.r = (value.r && value.r | 0) || (value | 0) || 0;\n if (newV.r < 0) newV.r = 0;\n else if (newV.r > 255) newV.r = 255;\n if (r !== newV.r) {\n ({r} = newV);\n changed = true;\n }\n break;\n case 'g':\n if (hsv) return;\n rgb = true;\n newV.g = (value && value.g && value.g | 0) || (value && value | 0) || 0;\n if (newV.g < 0) newV.g = 0;\n else if (newV.g > 255) newV.g = 255;\n if (g !== newV.g) {\n ({g} = newV);\n changed = true;\n }\n break;\n case 'b':\n if (hsv) return;\n rgb = true;\n newV.b = (value && value.b && value.b | 0) || (value && value | 0) || 0;\n if (newV.b < 0) newV.b = 0;\n else if (newV.b > 255) newV.b = 255;\n if (b !== newV.b) {\n ({b} = newV);\n changed = true;\n }\n break;\n case 'a':\n newV.a = value && !isNullish(value.a) ? value.a | 0 : value | 0;\n if (newV.a < 0) newV.a = 0;\n else if (newV.a > 255) newV.a = 255;\n if (a !== newV.a) {\n ({a} = newV);\n changed = true;\n }\n break;\n case 'h':\n if (rgb) return;\n hsv = true;\n newV.h = (value && value.h && value.h | 0) || (value && value | 0) || 0;\n if (newV.h < 0) newV.h = 0;\n else if (newV.h > 360) newV.h = 360;\n if (h !== newV.h) {\n ({h} = newV);\n changed = true;\n }\n break;\n case 's':\n if (rgb) return;\n hsv = true;\n newV.s = !isNullish(value.s) ? value.s | 0 : value | 0;\n if (newV.s < 0) newV.s = 0;\n else if (newV.s > 100) newV.s = 100;\n if (s !== newV.s) {\n ({s} = newV);\n changed = true;\n }\n break;\n case 'v':\n if (rgb) return;\n hsv = true;\n newV.v = !isNullish(value.v) ? value.v | 0 : value | 0;\n if (newV.v < 0) newV.v = 0;\n else if (newV.v > 100) newV.v = 100;\n if (v !== newV.v) {\n ({v} = newV);\n changed = true;\n }\n break;\n }\n });\n if (changed) {\n if (rgb) {\n r = r || 0;\n g = g || 0;\n b = b || 0;\n const ret = ColorMethods.rgbToHsv({r, g, b});\n ({h, s, v} = ret);\n } else if (hsv) {\n h = h || 0;\n s = !isNullish(s) ? s : 100;\n v = !isNullish(v) ? v : 100;\n const ret = ColorMethods.hsvToRgb({h, s, v});\n ({r, g, b} = ret);\n }\n a = !isNullish(a) ? a : 255;\n fireChangeEvents.call(that, context || that);\n }\n break;\n }\n }\n return undefined;\n }\n /**\n * @param {GenericCallback} callback\n * @returns {void}\n */\n function bind (callback) { // eslint-disable-line promise/prefer-await-to-callbacks\n if (typeof callback === 'function') changeEvents.push(callback);\n }\n /**\n * @param {GenericCallback} callback\n * @returns {void}\n */\n function unbind (callback) { // eslint-disable-line promise/prefer-await-to-callbacks\n if (typeof callback !== 'function') return;\n let i;\n while ((i = changeEvents.includes(callback))) {\n changeEvents.splice(i, 1);\n }\n }\n /**\n * Unset `changeEvents`\n * @returns {void}\n */\n function destroy () {\n changeEvents = null;\n }\n let r, g, b, a, h, s, v, changeEvents = [];\n\n $.extend(true, that, {\n // public properties and methods\n val,\n bind,\n unbind,\n destroy\n });\n if (init) {\n if (!isNullish(init.ahex)) {\n val('ahex', init);\n } else if (!isNullish(init.hex)) {\n val(\n (!isNullish(init.a) ? 'a' : '') + 'hex',\n !isNullish(init.a)\n ? {ahex: init.hex + ColorMethods.intToHex(init.a)}\n : init\n );\n } else if (!isNullish(init.r) && !isNullish(init.g) && !isNullish(init.b)) {\n val('rgb' + (!isNullish(init.a) ? 'a' : ''), init);\n } else if (!isNullish(init.h) && !isNullish(init.s) && !isNullish(init.v)) {\n val('hsv' + (!isNullish(init.a) ? 'a' : ''), init);\n }\n }\n },\n /**\n * Color conversion methods - make public to give use to external scripts.\n * @namespace\n */\n ColorMethods: {\n /**\n * @typedef {PlainObject} module:jPicker.RGBA\n * @property {Integer} r\n * @property {Integer} g\n * @property {Integer} b\n * @property {Integer} a\n */\n /**\n * @typedef {PlainObject} module:jPicker.RGB\n * @property {Integer} r\n * @property {Integer} g\n * @property {Integer} b\n */\n /**\n * @param {string} hex\n * @returns {module:jPicker.RGBA}\n */\n hexToRgba (hex) {\n if (hex === '' || hex === 'none') return {r: null, g: null, b: null, a: null};\n hex = this.validateHex(hex);\n let r = '00', g = '00', b = '00', a = '255';\n if (hex.length === 6) hex += 'ff';\n if (hex.length > 6) {\n r = hex.substring(0, 2);\n g = hex.substring(2, 4);\n b = hex.substring(4, 6);\n a = hex.substring(6, hex.length);\n } else {\n if (hex.length > 4) {\n r = hex.substring(4, hex.length);\n hex = hex.substring(0, 4);\n }\n if (hex.length > 2) {\n g = hex.substring(2, hex.length);\n hex = hex.substring(0, 2);\n }\n if (hex.length > 0) b = hex.substring(0, hex.length);\n }\n return {\n r: this.hexToInt(r), g: this.hexToInt(g), b: this.hexToInt(b), a: this.hexToInt(a)\n };\n },\n /**\n * @param {string} hex\n * @returns {string}\n */\n validateHex (hex) {\n // if (typeof hex === 'object') return '';\n hex = hex.toLowerCase().replace(/[^a-f\\d]/g, '');\n if (hex.length > 8) hex = hex.substring(0, 8);\n return hex;\n },\n /**\n * @param {module:jPicker.RGBA} rgba\n * @returns {string}\n */\n rgbaToHex (rgba) {\n return this.intToHex(rgba.r) + this.intToHex(rgba.g) + this.intToHex(rgba.b) + this.intToHex(rgba.a);\n },\n /**\n * @param {Integer} dec\n * @returns {string}\n */\n intToHex (dec) {\n let result = (dec | 0).toString(16);\n if (result.length === 1) result = ('0' + result);\n return result.toLowerCase();\n },\n /**\n * @param {string} hex\n * @returns {Integer}\n */\n hexToInt (hex) {\n return Number.parseInt(hex, 16);\n },\n /**\n * @typedef {PlainObject} module:jPicker.HSV\n * @property {Integer} h\n * @property {Integer} s\n * @property {Integer} v\n */\n /**\n * @param {module:jPicker.RGB} rgb\n * @returns {module:jPicker.HSV}\n */\n rgbToHsv (rgb) {\n const r = rgb.r / 255, g = rgb.g / 255, b = rgb.b / 255, hsv = {h: 0, s: 0, v: 0};\n let min = 0, max = 0;\n if (r >= g && r >= b) {\n max = r;\n min = g > b ? b : g;\n } else if (g >= b && g >= r) {\n max = g;\n min = r > b ? b : r;\n } else {\n max = b;\n min = g > r ? r : g;\n }\n hsv.v = max;\n hsv.s = max ? (max - min) / max : 0;\n let delta;\n if (!hsv.s) hsv.h = 0;\n else {\n delta = max - min;\n if (r === max) hsv.h = (g - b) / delta;\n else if (g === max) hsv.h = 2 + (b - r) / delta;\n else hsv.h = 4 + (r - g) / delta;\n hsv.h = Number.parseInt(hsv.h * 60);\n if (hsv.h < 0) hsv.h += 360;\n }\n hsv.s = (hsv.s * 100) | 0;\n hsv.v = (hsv.v * 100) | 0;\n return hsv;\n },\n /**\n * @param {module:jPicker.HSV} hsv\n * @returns {module:jPicker.RGB}\n */\n hsvToRgb (hsv) {\n const rgb = {r: 0, g: 0, b: 0, a: 100};\n let {h, s, v} = hsv;\n if (s === 0) {\n if (v === 0) rgb.r = rgb.g = rgb.b = 0;\n else rgb.r = rgb.g = rgb.b = (v * 255 / 100) | 0;\n } else {\n if (h === 360) h = 0;\n h /= 60;\n s /= 100;\n v /= 100;\n const i = h | 0,\n f = h - i,\n p = v * (1 - s),\n q = v * (1 - (s * f)),\n t = v * (1 - (s * (1 - f)));\n switch (i) {\n case 0:\n rgb.r = v;\n rgb.g = t;\n rgb.b = p;\n break;\n case 1:\n rgb.r = q;\n rgb.g = v;\n rgb.b = p;\n break;\n case 2:\n rgb.r = p;\n rgb.g = v;\n rgb.b = t;\n break;\n case 3:\n rgb.r = p;\n rgb.g = q;\n rgb.b = v;\n break;\n case 4:\n rgb.r = t;\n rgb.g = p;\n rgb.b = v;\n break;\n case 5:\n rgb.r = v;\n rgb.g = p;\n rgb.b = q;\n break;\n }\n rgb.r = (rgb.r * 255) | 0;\n rgb.g = (rgb.g * 255) | 0;\n rgb.b = (rgb.b * 255) | 0;\n }\n return rgb;\n }\n }\n };\n const {Color, List, ColorMethods} = $.jPicker; // local copies for YUI compressor\n /* eslint-disable jsdoc/require-returns */\n /**\n * @function external:jQuery.fn.jPicker\n * @see {@link external:jQuery.fn.$.fn.jPicker}\n */\n /* eslint-enable jsdoc/require-returns */\n\n /**\n * Will be bound to active {@link jQuery.jPicker.Color}.\n * @callback module:jPicker.LiveCallback\n * @param {external:jQuery} ui\n * @param {Element} context\n * @returns {void}\n */\n /**\n * @callback module:jPicker.CommitCallback\n * @param {external:jQuery.jPicker.Color} activeColor\n * @param {external:jQuery} okButton\n * @returns {void} Return value not used.\n */\n /**\n * @callback module:jPicker.CancelCallback\n * @param {external:jQuery.jPicker.Color} activeColor\n * @param {external:jQuery} cancelButton\n * @returns {void} Return value not used.\n */\n /**\n * While it would seem this should specify the name `jPicker` for JSDoc, that doesn't\n * get us treated as a function as well as a namespace (even with `@function name`),\n * so we use an approach to add a redundant `$.fn.` in the name.\n * @namespace\n * @memberof external:jQuery.fn\n * @param {external:jQuery.fn.jPickerOptions} options\n * @param {module:jPicker.CommitCallback} [commitCallback]\n * @param {module:jPicker.LiveCallback} [liveCallback]\n * @param {module:jPicker.CancelCallback} [cancelCallback]\n * @returns {external:jQuery}\n */\n $.fn.jPicker = function (options, commitCallback, liveCallback, cancelCallback) {\n return this.each(function () {\n const that = this,\n settings = $.extend(true, {}, $.fn.jPicker.defaults, options); // local copies for YUI compressor\n if ($(that).get(0).nodeName.toLowerCase() === 'input') { // Add color picker icon if binding to an input element and bind the events to the input\n $.extend(true, settings, {\n window: {\n bindToInput: true,\n expandable: true,\n input: $(that)\n }\n });\n if ($(that).val() === '') {\n settings.color.active = new Color({hex: null});\n settings.color.current = new Color({hex: null});\n } else if (ColorMethods.validateHex($(that).val())) {\n settings.color.active = new Color({hex: $(that).val(), a: settings.color.active.val('a')});\n settings.color.current = new Color({hex: $(that).val(), a: settings.color.active.val('a')});\n }\n }\n if (settings.window.expandable) {\n $(that).after('<span class=\"jPicker\"><span class=\"Icon\"><span class=\"Color\"> </span><span class=\"Alpha\"> </span><span class=\"Image\" title=\"Click To Open Color Picker\"> </span><span class=\"Container\"> </span></span></span>');\n } else {\n settings.window.liveUpdate = false; // Basic control binding for inline use - You will need to override the liveCallback or commitCallback function to retrieve results\n }\n const isLessThanIE7 = Number.parseFloat(navigator.appVersion.split('MSIE')[1]) < 7 && document.body.filters; // needed to run the AlphaImageLoader function for IE6\n // set color mode and update visuals for the new color mode\n /**\n *\n * @param {\"h\"|\"s\"|\"v\"|\"r\"|\"g\"|\"b\"|\"a\"} colorMode\n * @throws {Error} Invalid mode\n * @returns {void}\n */\n function setColorMode (colorMode) {\n const {active} = color, // local copies for YUI compressor\n // {clientPath} = images,\n hex = active.val('hex');\n let rgbMap, rgbBar;\n settings.color.mode = colorMode;\n switch (colorMode) {\n case 'h':\n setTimeout(function () {\n setBG.call(that, colorMapDiv, 'transparent');\n setImgLoc.call(that, colorMapL1, 0);\n setAlpha.call(that, colorMapL1, 100);\n setImgLoc.call(that, colorMapL2, 260);\n setAlpha.call(that, colorMapL2, 100);\n setBG.call(that, colorBarDiv, 'transparent');\n setImgLoc.call(that, colorBarL1, 0);\n setAlpha.call(that, colorBarL1, 100);\n setImgLoc.call(that, colorBarL2, 260);\n setAlpha.call(that, colorBarL2, 100);\n setImgLoc.call(that, colorBarL3, 260);\n setAlpha.call(that, colorBarL3, 100);\n setImgLoc.call(that, colorBarL4, 260);\n setAlpha.call(that, colorBarL4, 100);\n setImgLoc.call(that, colorBarL6, 260);\n setAlpha.call(that, colorBarL6, 100);\n }, 0);\n colorMap.range('all', {minX: 0, maxX: 100, minY: 0, maxY: 100});\n colorBar.range('rangeY', {minY: 0, maxY: 360});\n if (isNullish(active.val('ahex'))) break;\n colorMap.val('xy', {x: active.val('s'), y: 100 - active.val('v')}, colorMap);\n colorBar.val('y', 360 - active.val('h'), colorBar);\n break;\n case 's':\n setTimeout(function () {\n setBG.call(that, colorMapDiv, 'transparent');\n setImgLoc.call(that, colorMapL1, -260);\n setImgLoc.call(that, colorMapL2, -520);\n setImgLoc.call(that, colorBarL1, -260);\n setImgLoc.call(that, colorBarL2, -520);\n setImgLoc.call(that, colorBarL6, 260);\n setAlpha.call(that, colorBarL6, 100);\n }, 0);\n colorMap.range('all', {minX: 0, maxX: 360, minY: 0, maxY: 100});\n colorBar.range('rangeY', {minY: 0, maxY: 100});\n if (isNullish(active.val('ahex'))) break;\n colorMap.val('xy', {x: active.val('h'), y: 100 - active.val('v')}, colorMap);\n colorBar.val('y', 100 - active.val('s'), colorBar);\n break;\n case 'v':\n setTimeout(function () {\n setBG.call(that, colorMapDiv, '000000');\n setImgLoc.call(that, colorMapL1, -780);\n setImgLoc.call(that, colorMapL2, 260);\n setBG.call(that, colorBarDiv, hex);\n setImgLoc.call(that, colorBarL1, -520);\n setImgLoc.call(that, colorBarL2, 260);\n setAlpha.call(that, colorBarL2, 100);\n setImgLoc.call(that, colorBarL6, 260);\n setAlpha.call(that, colorBarL6, 100);\n }, 0);\n colorMap.range('all', {minX: 0, maxX: 360, minY: 0, maxY: 100});\n colorBar.range('rangeY', {minY: 0, maxY: 100});\n if (isNullish(active.val('ahex'))) break;\n colorMap.val('xy', {x: active.val('h'), y: 100 - active.val('s')}, colorMap);\n colorBar.val('y', 100 - active.val('v'), colorBar);\n break;\n case 'r':\n rgbMap = -1040;\n rgbBar = -780;\n colorMap.range('all', {minX: 0, maxX: 255, minY: 0, maxY: 255});\n colorBar.range('rangeY', {minY: 0, maxY: 255});\n if (isNullish(active.val('ahex'))) break;\n colorMap.val('xy', {x: active.val('b'), y: 255 - active.val('g')}, colorMap);\n colorBar.val('y', 255 - active.val('r'), colorBar);\n break;\n case 'g':\n rgbMap = -1560;\n rgbBar = -1820;\n colorMap.range('all', {minX: 0, maxX: 255, minY: 0, maxY: 255});\n colorBar.range('rangeY', {minY: 0, maxY: 255});\n if (isNullish(active.val('ahex'))) break;\n colorMap.val('xy', {x: active.val('b'), y: 255 - active.val('r')}, colorMap);\n colorBar.val('y', 255 - active.val('g'), colorBar);\n break;\n case 'b':\n rgbMap = -2080;\n rgbBar = -2860;\n colorMap.range('all', {minX: 0, maxX: 255, minY: 0, maxY: 255});\n colorBar.range('rangeY', {minY: 0, maxY: 255});\n if (isNullish(active.val('ahex'))) break;\n colorMap.val('xy', {x: active.val('r'), y: 255 - active.val('g')}, colorMap);\n colorBar.val('y', 255 - active.val('b'), colorBar);\n break;\n case 'a':\n setTimeout(function () {\n setBG.call(that, colorMapDiv, 'transparent');\n setImgLoc.call(that, colorMapL1, -260);\n setImgLoc.call(that, colorMapL2, -520);\n setImgLoc.call(that, colorBarL1, 260);\n setImgLoc.call(that, colorBarL2, 260);\n setAlpha.call(that, colorBarL2, 100);\n setImgLoc.call(that, colorBarL6, 0);\n setAlpha.call(that, colorBarL6, 100);\n }, 0);\n colorMap.range('all', {minX: 0, maxX: 360, minY: 0, maxY: 100});\n colorBar.range('rangeY', {minY: 0, maxY: 255});\n if (isNullish(active.val('ahex'))) break;\n colorMap.val('xy', {x: active.val('h'), y: 100 - active.val('v')}, colorMap);\n colorBar.val('y', 255 - active.val('a'), colorBar);\n break;\n default:\n throw new Error('Invalid Mode');\n }\n switch (colorMode) {\n case 'h':\n break;\n case 's':\n case 'v':\n case 'a':\n setTimeout(function () {\n setAlpha.call(that, colorMapL1, 100);\n setAlpha.call(that, colorBarL1, 100);\n setImgLoc.call(that, colorBarL3, 260);\n setAlpha.call(that, colorBarL3, 100);\n setImgLoc.call(that, colorBarL4, 260);\n setAlpha.call(that, colorBarL4, 100);\n }, 0);\n break;\n case 'r':\n case 'g':\n case 'b':\n setTimeout(function () {\n setBG.call(that, colorMapDiv, 'transparent');\n setBG.call(that, colorBarDiv, 'transparent');\n setAlpha.call(that, colorBarL1, 100);\n setAlpha.call(that, colorMapL1, 100);\n setImgLoc.call(that, colorMapL1, rgbMap);\n setImgLoc.call(that, colorMapL2, rgbMap - 260);\n setImgLoc.call(that, colorBarL1, rgbBar - 780);\n setImgLoc.call(that, colorBarL2, rgbBar - 520);\n setImgLoc.call(that, colorBarL3, rgbBar);\n setImgLoc.call(that, colorBarL4, rgbBar - 260);\n setImgLoc.call(that, colorBarL6, 260);\n setAlpha.call(that, colorBarL6, 100);\n }, 0);\n break;\n }\n if (isNullish(active.val('ahex'))) return;\n activeColorChanged.call(that, active);\n }\n /**\n * Update color when user changes text values.\n * @param {external:jQuery} ui\n * @param {?module:jPicker.Slider} context\n * @returns {void}\n */\n function activeColorChanged (ui, context) {\n if (isNullish(context) || (context !== colorBar && context !== colorMap)) positionMapAndBarArrows.call(that, ui, context);\n setTimeout(function () {\n updatePreview.call(that, ui);\n updateMapVisuals.call(that, ui);\n updateBarVisuals.call(that, ui);\n }, 0);\n }\n\n /**\n * User has dragged the ColorMap pointer.\n * @param {external:jQuery} ui\n * @param {?module:jPicker.Slider} context\n * @returns {void}\n */\n function mapValueChanged (ui, context) {\n const {active} = color;\n if (context !== colorMap && isNullish(active.val())) return;\n const xy = ui.val('all');\n switch (settings.color.mode) {\n case 'h':\n active.val('sv', {s: xy.x, v: 100 - xy.y}, context);\n break;\n case 's':\n case 'a':\n active.val('hv', {h: xy.x, v: 100 - xy.y}, context);\n break;\n case 'v':\n active.val('hs', {h: xy.x, s: 100 - xy.y}, context);\n break;\n case 'r':\n active.val('gb', {g: 255 - xy.y, b: xy.x}, context);\n break;\n case 'g':\n active.val('rb', {r: 255 - xy.y, b: xy.x}, context);\n break;\n case 'b':\n active.val('rg', {r: xy.x, g: 255 - xy.y}, context);\n break;\n }\n }\n\n /**\n * User has dragged the ColorBar slider.\n * @param {external:jQuery} ui\n * @param {?module:jPicker.Slider} context\n * @returns {void}\n */\n function colorBarValueChanged (ui, context) {\n const {active} = color;\n if (context !== colorBar && isNullish(active.val())) return;\n switch (settings.color.mode) {\n case 'h':\n active.val('h', {h: 360 - ui.val('y')}, context);\n break;\n case 's':\n active.val('s', {s: 100 - ui.val('y')}, context);\n break;\n case 'v':\n active.val('v', {v: 100 - ui.val('y')}, context);\n break;\n case 'r':\n active.val('r', {r: 255 - ui.val('y')}, context);\n break;\n case 'g':\n active.val('g', {g: 255 - ui.val('y')}, context);\n break;\n case 'b':\n active.val('b', {b: 255 - ui.val('y')}, context);\n break;\n case 'a':\n active.val('a', 255 - ui.val('y'), context);\n break;\n }\n }\n\n /**\n * Position map and bar arrows to match current color.\n * @param {external:jQuery} ui\n * @param {?module:jPicker.Slider} context\n * @returns {void}\n */\n function positionMapAndBarArrows (ui, context) {\n if (context !== colorMap) {\n switch (settings.color.mode) {\n case 'h': {\n const sv = ui.val('sv');\n colorMap.val('xy', {x: !isNullish(sv) ? sv.s : 100, y: 100 - (!isNullish(sv) ? sv.v : 100)}, context);\n break;\n } case 's':\n // Fall through\n case 'a': {\n const hv = ui.val('hv');\n colorMap.val('xy', {x: (hv && hv.h) || 0, y: 100 - (!isNullish(hv) ? hv.v : 100)}, context);\n break;\n } case 'v': {\n const hs = ui.val('hs');\n colorMap.val('xy', {x: (hs && hs.h) || 0, y: 100 - (!isNullish(hs) ? hs.s : 100)}, context);\n break;\n } case 'r': {\n const bg = ui.val('bg');\n colorMap.val('xy', {x: (bg && bg.b) || 0, y: 255 - ((bg && bg.g) || 0)}, context);\n break;\n } case 'g': {\n const br = ui.val('br');\n colorMap.val('xy', {x: (br && br.b) || 0, y: 255 - ((br && br.r) || 0)}, context);\n break;\n } case 'b': {\n const rg = ui.val('rg');\n colorMap.val('xy', {x: (rg && rg.r) || 0, y: 255 - ((rg && rg.g) || 0)}, context);\n break;\n }\n }\n }\n if (context !== colorBar) {\n switch (settings.color.mode) {\n case 'h':\n colorBar.val('y', 360 - (ui.val('h') || 0), context);\n break;\n case 's': {\n const s = ui.val('s');\n colorBar.val('y', 100 - (!isNullish(s) ? s : 100), context);\n break;\n } case 'v': {\n const v = ui.val('v');\n colorBar.val('y', 100 - (!isNullish(v) ? v : 100), context);\n break;\n } case 'r':\n colorBar.val('y', 255 - (ui.val('r') || 0), context);\n break;\n case 'g':\n colorBar.val('y', 255 - (ui.val('g') || 0), context);\n break;\n case 'b':\n colorBar.val('y', 255 - (ui.val('b') || 0), context);\n break;\n case 'a': {\n const a = ui.val('a');\n colorBar.val('y', 255 - (!isNullish(a) ? a : 255), context);\n break;\n }\n }\n }\n }\n /**\n * @param {external:jQuery} ui\n * @returns {void}\n */\n function updatePreview (ui) {\n try {\n const all = ui.val('all');\n activePreview.css({backgroundColor: (all && '#' + all.hex) || 'transparent'});\n setAlpha.call(that, activePreview, (all && toFixedNumeric((all.a * 100) / 255, 4)) || 0);\n } catch (e) { }\n }\n /**\n * @param {external:jQuery} ui\n * @returns {void}\n */\n function updateMapVisuals (ui) {\n switch (settings.color.mode) {\n case 'h':\n setBG.call(that, colorMapDiv, new Color({h: ui.val('h') || 0, s: 100, v: 100}).val('hex'));\n break;\n case 's':\n case 'a': {\n const s = ui.val('s');\n setAlpha.call(that, colorMapL2, 100 - (!isNullish(s) ? s : 100));\n break;\n } case 'v': {\n const v = ui.val('v');\n setAlpha.call(that, colorMapL1, !isNullish(v) ? v : 100);\n break;\n } case 'r':\n setAlpha.call(that, colorMapL2, toFixedNumeric((ui.val('r') || 0) / 255 * 100, 4));\n break;\n case 'g':\n setAlpha.call(that, colorMapL2, toFixedNumeric((ui.val('g') || 0) / 255 * 100, 4));\n break;\n case 'b':\n setAlpha.call(that, colorMapL2, toFixedNumeric((ui.val('b') || 0) / 255 * 100));\n break;\n }\n const a = ui.val('a');\n setAlpha.call(that, colorMapL3, toFixedNumeric(((255 - (a || 0)) * 100) / 255, 4));\n }\n /**\n * @param {external:jQuery} ui\n * @returns {void}\n */\n function updateBarVisuals (ui) {\n switch (settings.color.mode) {\n case 'h': {\n const a = ui.val('a');\n setAlpha.call(that, colorBarL5, toFixedNumeric(((255 - (a || 0)) * 100) / 255, 4));\n break;\n } case 's': {\n const hva = ui.val('hva'),\n saturatedColor = new Color({h: (hva && hva.h) || 0, s: 100, v: !isNullish(hva) ? hva.v : 100});\n setBG.call(that, colorBarDiv, saturatedColor.val('hex'));\n setAlpha.call(that, colorBarL2, 100 - (!isNullish(hva) ? hva.v : 100));\n setAlpha.call(that, colorBarL5, toFixedNumeric(((255 - ((hva && hva.a) || 0)) * 100) / 255, 4));\n break;\n } case 'v': {\n const hsa = ui.val('hsa'),\n valueColor = new Color({h: (hsa && hsa.h) || 0, s: !isNullish(hsa) ? hsa.s : 100, v: 100});\n setBG.call(that, colorBarDiv, valueColor.val('hex'));\n setAlpha.call(that, colorBarL5, toFixedNumeric(((255 - ((hsa && hsa.a) || 0)) * 100) / 255, 4));\n break;\n } case 'r':\n case 'g':\n case 'b': {\n const rgba = ui.val('rgba');\n let hValue = 0, vValue = 0;\n if (settings.color.mode === 'r') {\n hValue = (rgba && rgba.b) || 0;\n vValue = (rgba && rgba.g) || 0;\n } else if (settings.color.mode === 'g') {\n hValue = (rgba && rgba.b) || 0;\n vValue = (rgba && rgba.r) || 0;\n } else if (settings.color.mode === 'b') {\n hValue = (rgba && rgba.r) || 0;\n vValue = (rgba && rgba.g) || 0;\n }\n const middle = vValue > hValue ? hValue : vValue;\n setAlpha.call(that, colorBarL2, hValue > vValue ? toFixedNumeric(((hValue - vValue) / (255 - vValue)) * 100, 4) : 0);\n setAlpha.call(that, colorBarL3, vValue > hValue ? toFixedNumeric(((vValue - hValue) / (255 - hValue)) * 100, 4) : 0);\n setAlpha.call(that, colorBarL4, toFixedNumeric((middle / 255) * 100, 4));\n setAlpha.call(that, colorBarL5, toFixedNumeric(((255 - ((rgba && rgba.a) || 0)) * 100) / 255, 4));\n break;\n } case 'a': {\n const a = ui.val('a');\n setBG.call(that, colorBarDiv, ui.val('hex') || '000000');\n setAlpha.call(that, colorBarL5, !isNullish(a) ? 0 : 100);\n setAlpha.call(that, colorBarL6, !isNullish(a) ? 100 : 0);\n break;\n }\n }\n }\n /**\n * @param {external:jQuery} el\n * @param {string} [c=\"transparent\"]\n * @returns {void}\n */\n function setBG (el, c) {\n el.css({backgroundColor: (c && c.length === 6 && '#' + c) || 'transparent'});\n }\n\n /**\n * @param {external:jQuery} img\n * @param {string} src The image source\n * @returns {void}\n */\n function setImg (img, src) {\n if (isLessThanIE7 && (src.includes('AlphaBar.png') || src.includes('Bars.png') || src.includes('Maps.png'))) {\n img.attr('pngSrc', src);\n img.css({backgroundImage: 'none', filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\\'' + src + '\\', sizingMethod=\\'scale\\')'});\n } else img.css({backgroundImage: 'url(\\'' + src + '\\')'});\n }\n /**\n * @param {external:jQuery} img\n * @param {Float} y\n * @returns {void}\n */\n function setImgLoc (img, y) {\n img.css({top: y + 'px'});\n }\n /**\n * @param {external:jQuery} obj\n * @param {Float} alpha\n * @returns {void}\n */\n function setAlpha (obj, alpha) {\n obj.css({visibility: alpha > 0 ? 'visible' : 'hidden'});\n if (alpha > 0 && alpha < 100) {\n if (isLessThanIE7) {\n const src = obj.attr('pngSrc');\n if (!isNullish(src) && (\n src.includes('AlphaBar.png') || src.includes('Bars.png') || src.includes('Maps.png')\n )) {\n obj.css({\n filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\\'' + src +\n '\\', sizingMethod=\\'scale\\') progid:DXImageTransform.Microsoft.Alpha(opacity=' + alpha + ')'\n });\n } else obj.css({opacity: toFixedNumeric(alpha / 100, 4)});\n } else obj.css({opacity: toFixedNumeric(alpha / 100, 4)});\n } else if (alpha === 0 || alpha === 100) {\n if (isLessThanIE7) {\n const src = obj.attr('pngSrc');\n if (!isNullish(src) && (\n src.includes('AlphaBar.png') || src.includes('Bars.png') || src.includes('Maps.png')\n )) {\n obj.css({\n filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\\'' + src +\n '\\', sizingMethod=\\'scale\\')'\n });\n } else obj.css({opacity: ''});\n } else obj.css({opacity: ''});\n }\n }\n\n /**\n * Revert color to original color when opened.\n * @returns {void}\n */\n function revertColor () {\n color.active.val('ahex', color.current.val('ahex'));\n }\n /**\n * Commit the color changes.\n * @returns {void}\n */\n function commitColor () {\n color.current.val('ahex', color.active.val('ahex'));\n }\n /**\n * @param {Event} e\n * @returns {void}\n */\n function radioClicked (e) {\n $(this).parents('tbody:first').find('input:radio[value!=\"' + e.target.value + '\"]').removeAttr('checked');\n setColorMode.call(that, e.target.value);\n }\n /**\n *\n * @returns {void}\n */\n function currentClicked () {\n revertColor.call(that);\n }\n /**\n *\n * @returns {void}\n */\n function cancelClicked () {\n revertColor.call(that);\n settings.window.expandable && hide.call(that);\n typeof cancelCallback === 'function' && cancelCallback.call(that, color.active, cancelButton);\n }\n /**\n *\n * @returns {void}\n */\n function okClicked () {\n commitColor.call(that);\n settings.window.expandable && hide.call(that);\n typeof commitCallback === 'function' && commitCallback.call(that, color.active, okButton);\n }\n /**\n *\n * @returns {void}\n */\n function iconImageClicked () {\n show.call(that);\n }\n /**\n * @param {external:jQuery} ui\n * @returns {void}\n */\n function currentColorChanged (ui) {\n const hex = ui.val('hex');\n currentPreview.css({backgroundColor: (hex && '#' + hex) || 'transparent'});\n setAlpha.call(that, currentPreview, toFixedNumeric(((ui.val('a') || 0) * 100) / 255, 4));\n }\n /**\n * @param {external:jQuery} ui\n * @returns {void}\n */\n function expandableColorChanged (ui) {\n const hex = ui.val('hex');\n const va = ui.val('va');\n iconColor.css({backgroundColor: (hex && '#' + hex) || 'transparent'});\n setAlpha.call(that, iconAlpha, toFixedNumeric(((255 - ((va && va.a) || 0)) * 100) / 255, 4));\n if (settings.window.bindToInput && settings.window.updateInputColor) {\n settings.window.input.css({\n backgroundColor: (hex && '#' + hex) || 'transparent',\n color: isNullish(va) || va.v > 75 ? '#000000' : '#ffffff'\n });\n }\n }\n /**\n * @param {Event} e\n * @returns {void}\n */\n function moveBarMouseDown (e) {\n // const {element} = settings.window, // local copies for YUI compressor\n // {page} = settings.window;\n elementStartX = Number.parseInt(container.css('left'));\n elementStartY = Number.parseInt(container.css('top'));\n pageStartX = e.pageX;\n pageStartY = e.pageY;\n // bind events to document to move window - we will unbind these on mouseup\n $(document).bind('mousemove', documentMouseMove).bind('mouseup', documentMouseUp);\n e.preventDefault(); // prevent attempted dragging of the column\n }\n /**\n * @param {Event} e\n * @returns {false}\n */\n function documentMouseMove (e) {\n container.css({\n left: elementStartX - (pageStartX - e.pageX) + 'px',\n top: elementStartY - (pageStartY - e.pageY) + 'px'\n });\n if (settings.window.expandable && !$.support.boxModel) {\n container.prev().css({\n left: container.css('left'),\n top: container.css('top')\n });\n }\n e.stopPropagation();\n e.preventDefault();\n return false;\n }\n /**\n * @param {Event} e\n * @returns {false}\n */\n function documentMouseUp (e) {\n $(document).unbind('mousemove', documentMouseMove).unbind('mouseup', documentMouseUp);\n e.stopPropagation();\n e.preventDefault();\n return false;\n }\n /**\n * @param {Event} e\n * @returns {false}\n */\n function quickPickClicked (e) {\n e.preventDefault();\n e.stopPropagation();\n color.active.val('ahex', $(this).attr('title') || null, e.target);\n return false;\n }\n /**\n *\n * @returns {void}\n */\n function show () {\n color.current.val('ahex', color.active.val('ahex'));\n /**\n *\n * @returns {void}\n */\n function attachIFrame () {\n if (!settings.window.expandable || $.support.boxModel) return;\n const table = container.find('table:first');\n container.before('<iframe/>');\n container.prev().css({\n width: table.width(),\n height: container.height(),\n opacity: 0,\n position: 'absolute',\n left: container.css('left'),\n top: container.css('top')\n });\n }\n if (settings.window.expandable) {\n $(document.body).children('div.jPicker.Container').css({zIndex: 10});\n container.css({zIndex: 20});\n }\n switch (settings.window.effects.type) {\n case 'fade':\n container.fadeIn(settings.window.effects.speed.show, attachIFrame);\n break;\n case 'slide':\n container.slideDown(settings.window.effects.speed.show, attachIFrame);\n break;\n case 'show':\n default:\n container.show(settings.window.effects.speed.show, attachIFrame);\n break;\n }\n }\n /**\n *\n * @returns {void}\n */\n function hide () {\n /**\n *\n * @returns {void}\n */\n function removeIFrame () {\n if (settings.window.expandable) container.css({zIndex: 10});\n if (!settings.window.expandable || $.support.boxModel) return;\n container.prev().remove();\n }\n switch (settings.window.effects.type) {\n case 'fade':\n container.fadeOut(settings.window.effects.speed.hide, removeIFrame);\n break;\n case 'slide':\n container.slideUp(settings.window.effects.speed.hide, removeIFrame);\n break;\n case 'show':\n default:\n container.hide(settings.window.effects.speed.hide, removeIFrame);\n break;\n }\n }\n /**\n *\n * @returns {void}\n */\n function initialize () {\n const win = settings.window,\n popup = win.expandable ? $(that).next().find('.Container:first') : null;\n container = win.expandable ? $('<div/>') : $(that);\n container.addClass('jPicker Container');\n if (win.expandable) container.hide();\n container.get(0).onselectstart = function (e) {\n if (e.target.nodeName.toLowerCase() !== 'input') return false;\n return true;\n };\n // inject html source code - we are using a single table for this control - I know tables are considered bad, but it takes care of equal height columns and\n // this control really is tabular data, so I believe it is the right move\n const all = color.active.val('all');\n if (win.alphaPrecision < 0) win.alphaPrecision = 0;\n else if (win.alphaPrecision > 2) win.alphaPrecision = 2;\n const controlHtml = `<table class=\"jPicker\" cellpadding=\"0\" cellspacing=\"0\">\n <tbody>\n ${win.expandable ? '<tr><td class=\"Move\" colspan=\"5\"> </td></tr>' : ''}\n <tr>\n <td rowspan=\"9\"><h2 class=\"Title\">${win.title || localization.text.title}</h2><div class=\"Map\"><span class=\"Map1\"> </span><span class=\"Map2\"> </span><span class=\"Map3\"> </span><img src=\"${images.clientPath + images.colorMap.arrow.file}\" class=\"Arrow\"/></div></td>\n <td rowspan=\"9\"><div class=\"Bar\"><span class=\"Map1\"> </span><span class=\"Map2\"> </span><span class=\"Map3\"> </span><span class=\"Map4\"> </span><span class=\"Map5\"> </span><span class=\"Map6\"> </span><img src=\"${images.clientPath + images.colorBar.arrow.file}\" class=\"Arrow\"/></div></td>\n <td colspan=\"2\" class=\"Preview\">${localization.text.newColor}<div><span class=\"Active\" title=\"${localization.tooltips.colors.newColor}\"> </span><span class=\"Current\" title=\"${localization.tooltips.colors.currentColor}\"> </span></div>${localization.text.currentColor}</td>\n <td rowspan=\"9\" class=\"Button\"><input type=\"button\" class=\"Ok\" value=\"${localization.text.ok}\" title=\"${localization.tooltips.buttons.ok}\"/><input type=\"button\" class=\"Cancel\" value=\"${localization.text.cancel}\" title=\"${localization.tooltips.buttons.cancel}\"/><hr/><div class=\"Grid\"> </div></td>\n </tr>\n <tr class=\"Hue\">\n <td class=\"Radio\"><label title=\"${localization.tooltips.hue.radio}\"><input type=\"radio\" value=\"h\"${settings.color.mode === 'h' ? ' checked=\"checked\"' : ''}/>H:</label></td>\n <td class=\"Text\"><input type=\"text\" maxlength=\"3\" value=\"${!isNullish(all) ? all.h : ''}\" title=\"${localization.tooltips.hue.textbox}\"/> °</td>\n </tr>\n <tr class=\"Saturation\">\n <td class=\"Radio\"><label title=\"${localization.tooltips.saturation.radio}\"><input type=\"radio\" value=\"s\"${settings.color.mode === 's' ? ' checked=\"checked\"' : ''}/>S:</label></td>\n <td class=\"Text\"><input type=\"text\" maxlength=\"3\" value=\"${!isNullish(all) ? all.s : ''}\" title=\"${localization.tooltips.saturation.textbox}\"/> %</td>\n </tr>\n <tr class=\"Value\">\n <td class=\"Radio\"><label title=\"${localization.tooltips.value.radio}\"><input type=\"radio\" value=\"v\"${settings.color.mode === 'v' ? ' checked=\"checked\"' : ''}/>V:</label><br/><br/></td>\n <td class=\"Text\"><input type=\"text\" maxlength=\"3\" value=\"${!isNullish(all) ? all.v : ''}\" title=\"${localization.tooltips.value.textbox}\"/> %<br/><br/></td>\n </tr>\n <tr class=\"Red\">\n <td class=\"Radio\"><label title=\"${localization.tooltips.red.radio}\"><input type=\"radio\" value=\"r\"${settings.color.mode === 'r' ? ' checked=\"checked\"' : ''}/>R:</label></td>\n <td class=\"Text\"><input type=\"text\" maxlength=\"3\" value=\"${!isNullish(all) ? all.r : ''}\" title=\"${localization.tooltips.red.textbox}\"/></td>\n </tr>\n <tr class=\"Green\">\n <td class=\"Radio\"><label title=\"${localization.tooltips.green.radio}\"><input type=\"radio\" value=\"g\"${settings.color.mode === 'g' ? ' checked=\"checked\"' : ''}/>G:</label></td>\n <td class=\"Text\"><input type=\"text\" maxlength=\"3\" value=\"${!isNullish(all) ? all.g : ''}\" title=\"${localization.tooltips.green.textbox}\"/></td>\n </tr>\n <tr class=\"Blue\">\n <td class=\"Radio\"><label title=\"${localization.tooltips.blue.radio}\"><input type=\"radio\" value=\"b\"${settings.color.mode === 'b' ? ' checked=\"checked\"' : ''}/>B:</label></td>\n <td class=\"Text\"><input type=\"text\" maxlength=\"3\" value=\"${!isNullish(all) ? all.b : ''}\" title=\"${localization.tooltips.blue.textbox}\"/></td>\n </tr>\n <tr class=\"Alpha\">\n <td class=\"Radio\">${win.alphaSupport ? `<label title=\"${localization.tooltips.alpha.radio}\"><input type=\"radio\" value=\"a\"${settings.color.mode === 'a' ? ' checked=\"checked\"' : ''}/>A:</label>` : ' '}</td>\n <td class=\"Text\">${win.alphaSupport ? `<input type=\"text\" maxlength=\"${3 + win.alphaPrecision}\" value=\"${!isNullish(all) ? toFixedNumeric((all.a * 100) / 255, win.alphaPrecision) : ''}\" title=\"${localization.tooltips.alpha.textbox}\"/> %` : ' '}</td>\n </tr>\n <tr class=\"Hex\">\n <td colspan=\"2\" class=\"Text\"><label title=\"${localization.tooltips.hex.textbox}\">#:<input type=\"text\" maxlength=\"6\" class=\"Hex\" value=\"${!isNullish(all) ? all.hex : ''}\"/></label>${win.alphaSupport ? `<input type=\"text\" maxlength=\"2\" class=\"AHex\" value=\"${!isNullish(all) ? all.ahex.substring(6) : ''}\" title=\"${localization.tooltips.hex.alpha}\"/></td>` : ' '}\n </tr>\n </tbody></table>`;\n if (win.expandable) {\n container.html(controlHtml);\n if (!$(document.body).children('div.jPicker.Container').length) {\n $(document.body).prepend(container);\n } else {\n $(document.body).children('div.jPicker.Container:last').after(container);\n }\n container.mousedown(\n function () {\n $(document.body).children('div.jPicker.Container').css({zIndex: 10});\n container.css({zIndex: 20});\n }\n );\n container.css( // positions must be set and display set to absolute before source code injection or IE will size the container to fit the window\n {\n left:\n win.position.x === 'left'\n ? (popup.offset().left - 530 - (win.position.y === 'center' ? 25 : 0)) + 'px'\n : win.position.x === 'center'\n ? (popup.offset().left - 260) + 'px'\n : win.position.x === 'right'\n ? (popup.offset().left - 10 + (win.position.y === 'center' ? 25 : 0)) + 'px'\n : win.position.x === 'screenCenter'\n ? (($(document).width() >> 1) - 260) + 'px'\n : (popup.offset().left + Number.parseInt(win.position.x)) + 'px',\n position: 'absolute',\n top: win.position.y === 'top'\n ? (popup.offset().top - 312) + 'px'\n : win.position.y === 'center'\n ? (popup.offset().top - 156) + 'px'\n : win.position.y === 'bottom'\n ? (popup.offset().top + 25) + 'px'\n : (popup.offset().top + Number.parseInt(win.position.y)) + 'px'\n }\n );\n } else {\n container = $(that);\n container.html(controlHtml);\n }\n // initialize the objects to the source code just injected\n const tbody = container.find('tbody:first');\n colorMapDiv = tbody.find('div.Map:first');\n colorBarDiv = tbody.find('div.Bar:first');\n const MapMaps = colorMapDiv.find('span');\n const BarMaps = colorBarDiv.find('span');\n colorMapL1 = MapMaps.filter('.Map1:first');\n colorMapL2 = MapMaps.filter('.Map2:first');\n colorMapL3 = MapMaps.filter('.Map3:first');\n colorBarL1 = BarMaps.filter('.Map1:first');\n colorBarL2 = BarMaps.filter('.Map2:first');\n colorBarL3 = BarMaps.filter('.Map3:first');\n colorBarL4 = BarMaps.filter('.Map4:first');\n colorBarL5 = BarMaps.filter('.Map5:first');\n colorBarL6 = BarMaps.filter('.Map6:first');\n // create color pickers and maps\n colorMap = new Slider(\n colorMapDiv,\n {\n map: {\n width: images.colorMap.width,\n height: images.colorMap.height\n },\n arrow: {\n image: images.clientPath + images.colorMap.arrow.file,\n width: images.colorMap.arrow.width,\n height: images.colorMap.arrow.height\n }\n }\n );\n colorMap.bind(mapValueChanged);\n colorBar = new Slider(\n colorBarDiv,\n {\n map: {\n width: images.colorBar.width,\n height: images.colorBar.height\n },\n arrow: {\n image: images.clientPath + images.colorBar.arrow.file,\n width: images.colorBar.arrow.width,\n height: images.colorBar.arrow.height\n }\n }\n );\n colorBar.bind(colorBarValueChanged);\n colorPicker = new ColorValuePicker(\n tbody,\n color.active,\n win.expandable && win.bindToInput ? win.input : null,\n win.alphaPrecision\n );\n const hex = !isNullish(all) ? all.hex : null,\n preview = tbody.find('.Preview'),\n button = tbody.find('.Button');\n activePreview = preview.find('.Active:first').css({backgroundColor: (hex && '#' + hex) || 'transparent'});\n currentPreview = preview.find('.Current:first').css({backgroundColor: (hex && '#' + hex) || 'transparent'}).bind('click', currentClicked);\n setAlpha.call(that, currentPreview, toFixedNumeric((color.current.val('a') * 100) / 255, 4));\n okButton = button.find('.Ok:first').bind('click', okClicked);\n cancelButton = button.find('.Cancel:first').bind('click', cancelClicked);\n grid = button.find('.Grid:first');\n setTimeout(function () {\n setImg.call(that, colorMapL1, images.clientPath + 'Maps.png');\n setImg.call(that, colorMapL2, images.clientPath + 'Maps.png');\n setImg.call(that, colorMapL3, images.clientPath + 'map-opacity.png');\n setImg.call(that, colorBarL1, images.clientPath + 'Bars.png');\n setImg.call(that, colorBarL2, images.clientPath + 'Bars.png');\n setImg.call(that, colorBarL3, images.clientPath + 'Bars.png');\n setImg.call(that, colorBarL4, images.clientPath + 'Bars.png');\n setImg.call(that, colorBarL5, images.clientPath + 'bar-opacity.png');\n setImg.call(that, colorBarL6, images.clientPath + 'AlphaBar.png');\n setImg.call(that, preview.find('div:first'), images.clientPath + 'preview-opacity.png');\n }, 0);\n tbody.find('td.Radio input').bind('click', radioClicked);\n // initialize quick list\n if (color.quickList && color.quickList.length > 0) {\n let html = '';\n for (let i = 0; i < color.quickList.length; i++) {\n /* if default colors are hex strings, change them to color objects */\n if ((typeof (color.quickList[i])).toString().toLowerCase() === 'string') {\n color.quickList[i] = new Color({hex: color.quickList[i]});\n }\n const alpha = color.quickList[i].val('a');\n let ahex = color.quickList[i].val('ahex');\n if (!win.alphaSupport && ahex) ahex = ahex.substring(0, 6) + 'ff';\n const quickHex = color.quickList[i].val('hex');\n if (!ahex) ahex = '00000000';\n html += '<span class=\"QuickColor\"' + (' title=\"#' + ahex + '\"') + ' style=\"background-color:' + ((quickHex && '#' + quickHex) || '') + ';' + (quickHex ? '' : 'background-image:url(' + images.clientPath + 'NoColor.png)') + (win.alphaSupport && alpha && alpha < 255 ? ';opacity:' + toFixedNumeric(alpha / 255, 4) + ';filter:Alpha(opacity=' + toFixedNumeric(alpha / 2.55, 4) + ')' : '') + '\"> </span>';\n }\n setImg.call(that, grid, images.clientPath + 'bar-opacity.png');\n grid.html(html);\n grid.find('.QuickColor').click(quickPickClicked);\n }\n setColorMode.call(that, settings.color.mode);\n color.active.bind(activeColorChanged);\n typeof liveCallback === 'function' && color.active.bind(liveCallback);\n color.current.bind(currentColorChanged);\n // bind to input\n if (win.expandable) {\n that.icon = popup.parents('.Icon:first');\n iconColor = that.icon.find('.Color:first').css({backgroundColor: (hex && '#' + hex) || 'transparent'});\n iconAlpha = that.icon.find('.Alpha:first');\n setImg.call(that, iconAlpha, images.clientPath + 'bar-opacity.png');\n setAlpha.call(that, iconAlpha, toFixedNumeric(((255 - (!isNullish(all) ? all.a : 0)) * 100) / 255, 4));\n iconImage = that.icon.find('.Image:first').css({\n backgroundImage: 'url(\\'' + images.clientPath + images.picker.file + '\\')'\n }).bind('click', iconImageClicked);\n if (win.bindToInput && win.updateInputColor) {\n win.input.css({\n backgroundColor: (hex && '#' + hex) || 'transparent',\n color: isNullish(all) || all.v > 75 ? '#000000' : '#ffffff'\n });\n }\n moveBar = tbody.find('.Move:first').bind('mousedown', moveBarMouseDown);\n color.active.bind(expandableColorChanged);\n } else show.call(that);\n }\n /**\n *\n * @returns {void}\n */\n function destroy () {\n container.find('td.Radio input').unbind('click', radioClicked);\n currentPreview.unbind('click', currentClicked);\n cancelButton.unbind('click', cancelClicked);\n okButton.unbind('click', okClicked);\n if (settings.window.expandable) {\n iconImage.unbind('click', iconImageClicked);\n moveBar.unbind('mousedown', moveBarMouseDown);\n that.icon = null;\n }\n container.find('.QuickColor').unbind('click', quickPickClicked);\n colorMapDiv = null;\n colorBarDiv = null;\n colorMapL1 = null;\n colorMapL2 = null;\n colorMapL3 = null;\n colorBarL1 = null;\n colorBarL2 = null;\n colorBarL3 = null;\n colorBarL4 = null;\n colorBarL5 = null;\n colorBarL6 = null;\n colorMap.destroy();\n colorMap = null;\n colorBar.destroy();\n colorBar = null;\n colorPicker.destroy();\n colorPicker = null;\n activePreview = null;\n currentPreview = null;\n okButton = null;\n cancelButton = null;\n grid = null;\n commitCallback = null;\n cancelCallback = null;\n liveCallback = null;\n container.html('');\n for (let i = 0; i < List.length; i++) {\n if (List[i] === that) {\n List.splice(i, 1);\n i--; // Decrement to ensure we don't miss next item (lgtm warning)\n }\n }\n }\n const {images, localization} = settings; // local copies for YUI compressor\n const color = {\n active: (typeof settings.color.active).toString().toLowerCase() === 'string'\n ? new Color({ahex: !settings.window.alphaSupport && settings.color.active\n ? settings.color.active.substring(0, 6) + 'ff'\n : settings.color.active\n })\n : new Color({ahex: !settings.window.alphaSupport &&\n settings.color.active.val('ahex')\n ? settings.color.active.val('ahex').substring(0, 6) + 'ff'\n : settings.color.active.val('ahex')\n }),\n current: (typeof settings.color.active).toString().toLowerCase() === 'string'\n ? new Color({ahex: !settings.window.alphaSupport && settings.color.active\n ? settings.color.active.substring(0, 6) + 'ff'\n : settings.color.active})\n : new Color({ahex: !settings.window.alphaSupport &&\n settings.color.active.val('ahex')\n ? settings.color.active.val('ahex').substring(0, 6) + 'ff'\n : settings.color.active.val('ahex')\n }),\n quickList: settings.color.quickList\n };\n\n if (typeof commitCallback !== 'function') {\n commitCallback = null;\n }\n if (typeof liveCallback !== 'function') {\n liveCallback = null;\n }\n if (typeof cancelCallback !== 'function') {\n cancelCallback = null;\n }\n\n let elementStartX = null, // Used to record the starting css positions for dragging the control\n elementStartY = null,\n pageStartX = null, // Used to record the mousedown coordinates for dragging the control\n pageStartY = null,\n container = null,\n colorMapDiv = null,\n colorBarDiv = null,\n colorMapL1 = null, // different layers of colorMap and colorBar\n colorMapL2 = null,\n colorMapL3 = null,\n colorBarL1 = null,\n colorBarL2 = null,\n colorBarL3 = null,\n colorBarL4 = null,\n colorBarL5 = null,\n colorBarL6 = null,\n colorMap = null, // color maps\n colorBar = null,\n colorPicker = null,\n activePreview = null, // color boxes above the radio buttons\n currentPreview = null,\n okButton = null,\n cancelButton = null,\n grid = null, // preset colors grid\n iconColor = null, // iconColor for popup icon\n iconAlpha = null, // iconAlpha for popup icon\n iconImage = null, // iconImage popup icon\n moveBar = null; // drag bar\n\n $.extend(true, that, {\n // public properties, methods, and callbacks\n commitCallback, // commitCallback function can be overridden to return the selected color to a method you specify when the user clicks \"OK\"\n liveCallback, // liveCallback function can be overridden to return the selected color to a method you specify in live mode (continuous update)\n cancelCallback, // cancelCallback function can be overridden to a method you specify when the user clicks \"Cancel\"\n color,\n show,\n hide,\n destroy // destroys this control entirely, removing all events and objects, and removing itself from the List\n });\n List.push(that);\n setTimeout(function () {\n initialize.call(that);\n }, 0);\n });\n };\n /**\n * @typedef {PlainObject} external:jQuery.fn.jPickerOptionsIconInfo\n * @property {string} file Color Map/Color Bar/Color Picker arrow icon\n * @property {Float} width\n * @property {Float} height\n */\n /**\n * @typedef {PlainObject} external:jQuery.fn.jPickerOptionsImagesDimensionsArrow\n * @property {Float} width\n * @property {Float} height\n * @property {external:jQuery.fn.jPickerOptionsIconInfo} arrow\n */\n /**\n * @typedef {PlainObject} external:jQuery.fn.jPickerOptionsRadioTextboxLocale\n * @property {string} radio\n * @property {string} textbox\n */\n /**\n * @typedef {PlainObject} external:jQuery.fn.jPickerOptions\n * @property {PlainObject} window\n * @property {string|null} window.title Any title for the jPicker window itself - displays\n * \"Drag Markers To Pick A Color\" if left null\n * @property {PlainObject} window.effects\n * @property {\"slide\"|\"show\"|\"fade\"} window.effects.type Effect used to show/hide an expandable picker\n * @property {PlainObject} window.effects.speed\n * @property {\"fast\"|\"slow\"|Float} window.effects.speed.show Duration of \"show\" effect. Time in milliseconds.\n * @property {\"fast\"|\"slow\"|Float} window.effects.speed.hide Duration of \"hide\" effect. Time in milliseconds\n * @property {PlainObject} window.position\n * @property {\"left\"|\"center\"|\"right\"|\"screenCenter\"|Float} window.position.x Relative px value\n * @property {\"top\"|\"bottom\"|\"center\"|Float} window.position.y Relative px value\n * @property {boolean} window.expandable Defaults to large static picker - set to `true` to make an expandable\n * picker (small icon with popup) - set automatically when binded to input element; added by `$.fn.jPicker`\n * @property {boolean} window.liveUpdate Set `false` if you want the user to have to click \"OK\" before the\n * binded input box updates values (always `true` for expandable picker)\n * @property {boolean} window.alphaSupport Set to `true` to enable alpha picking\n * @property {Float} window.alphaPrecision Set decimal precision for alpha percentage display - hex codes do\n * not map directly to percentage integers - range 0-2\n * @property {boolean} window.updateInputColor Set to `false` to prevent binded input colors from changing\n * @property {boolean} [window.bindToInput] Added by `$.fn.jPicker`\n * @property {external:jQuery} [window.input] Added by `$.fn.jPicker`\n * @property {PlainObject} color\n * @property {\"h\"|\"s\"|\"v\"|\"r\"|\"g\"|\"b\"|\"a\"} color.mode Symbols stand for \"h\" (hue), \"s\" (saturation), \"v\" (value), \"r\" (red), \"g\" (green), \"b\" (blue), \"a\" (alpha)\n * @property {Color|string} color.active Strings are HEX values (e.g. #ffc000) WITH OR WITHOUT the \"#\" prefix\n * @property {Color[]|string[]} color.quickList The quick pick color list\n * Strings are HEX values (e.g. #ffc000) WITH OR WITHOUT the \"#\" prefix\n * @property {PlainObject} images\n * @property {string} images.clientPath Path to image files\n * @property {external:jQuery.fn.jPickerOptionsImagesDimensionsArrow} images.colorMap\n * @property {external:jQuery.fn.jPickerOptionsImagesDimensionsArrow} images.colorBar\n * @property {external:jQuery.fn.jPickerOptionsIconInfo} images.picker\n * @property {PlainObject} localization alter these to change the text presented by the picker (e.g. different language)\n * @property {PlainObject} localization.text\n * @property {string} localization.text.title\n * @property {string} localization.text.newColor\n * @property {string} localization.text.currentColor\n * @property {string} localization.text.ok\n * @property {string} localization.text.cancel\n * @property {PlainObject} localization.tooltips\n * @property {PlainObject} localization.tooltips.colors\n * @property {string} localization.tooltips.colors.newColor\n * @property {string} localization.tooltips.colors.currentColor\n * @property {PlainObject} localization.tooltips.buttons\n * @property {string} localization.tooltips.buttons.ok\n * @property {string} localization.tooltips.buttons.cancel\n * @property {external:jQuery.fn.jPickerOptionsRadioTextboxLocale} localization.tooltips.hue\n * @property {external:jQuery.fn.jPickerOptionsRadioTextboxLocale} localization.tooltips.saturation\n * @property {external:jQuery.fn.jPickerOptionsRadioTextboxLocale} localization.tooltips.value\n * @property {external:jQuery.fn.jPickerOptionsRadioTextboxLocale} localization.tooltips.red\n * @property {external:jQuery.fn.jPickerOptionsRadioTextboxLocale} localization.tooltips.green\n * @property {external:jQuery.fn.jPickerOptionsRadioTextboxLocale} localization.tooltips.blue\n * @property {external:jQuery.fn.jPickerOptionsRadioTextboxLocale} localization.tooltips.alpha\n * @property {PlainObject} localization.tooltips.hex\n * @property {string} localization.tooltips.hex.textbox\n * @property {string} localization.tooltips.hex.alpha\n */\n /**\n * The jPicker defaults - you can change anything in this section (such as the\n * clientPath to your images) without fear of breaking the program.\n * @namespace {external:jQuery.fn.jPickerOptions} defaults\n * @memberof external:jQuery.fn.$.fn.jPicker\n * @borrows external:jQuery.fn.jPickerOptions as external:jQuery.fn.jPicker.defaults\n * @see Source for all of the values\n */\n $.fn.jPicker.defaults = {\n window: {\n title: null,\n effects: {\n type: 'slide',\n speed: {\n show: 'slow',\n hide: 'fast'\n }\n },\n position: {\n x: 'screenCenter',\n y: 'top'\n },\n expandable: false,\n liveUpdate: true,\n alphaSupport: false,\n alphaPrecision: 0,\n updateInputColor: true\n },\n color: {\n mode: 'h',\n active: new Color({ahex: '#ffcc00ff'}),\n quickList: [\n new Color({h: 360, s: 33, v: 100}),\n new Color({h: 360, s: 66, v: 100}),\n new Color({h: 360, s: 100, v: 100}),\n new Color({h: 360, s: 100, v: 75}),\n new Color({h: 360, s: 100, v: 50}),\n new Color({h: 180, s: 0, v: 100}),\n new Color({h: 30, s: 33, v: 100}),\n new Color({h: 30, s: 66, v: 100}),\n new Color({h: 30, s: 100, v: 100}),\n new Color({h: 30, s: 100, v: 75}),\n new Color({h: 30, s: 100, v: 50}),\n new Color({h: 180, s: 0, v: 90}),\n new Color({h: 60, s: 33, v: 100}),\n new Color({h: 60, s: 66, v: 100}),\n new Color({h: 60, s: 100, v: 100}),\n new Color({h: 60, s: 100, v: 75}),\n new Color({h: 60, s: 100, v: 50}),\n new Color({h: 180, s: 0, v: 80}),\n new Color({h: 90, s: 33, v: 100}),\n new Color({h: 90, s: 66, v: 100}),\n new Color({h: 90, s: 100, v: 100}),\n new Color({h: 90, s: 100, v: 75}),\n new Color({h: 90, s: 100, v: 50}),\n new Color({h: 180, s: 0, v: 70}),\n new Color({h: 120, s: 33, v: 100}),\n new Color({h: 120, s: 66, v: 100}),\n new Color({h: 120, s: 100, v: 100}),\n new Color({h: 120, s: 100, v: 75}),\n new Color({h: 120, s: 100, v: 50}),\n new Color({h: 180, s: 0, v: 60}),\n new Color({h: 150, s: 33, v: 100}),\n new Color({h: 150, s: 66, v: 100}),\n new Color({h: 150, s: 100, v: 100}),\n new Color({h: 150, s: 100, v: 75}),\n new Color({h: 150, s: 100, v: 50}),\n new Color({h: 180, s: 0, v: 50}),\n new Color({h: 180, s: 33, v: 100}),\n new Color({h: 180, s: 66, v: 100}),\n new Color({h: 180, s: 100, v: 100}),\n new Color({h: 180, s: 100, v: 75}),\n new Color({h: 180, s: 100, v: 50}),\n new Color({h: 180, s: 0, v: 40}),\n new Color({h: 210, s: 33, v: 100}),\n new Color({h: 210, s: 66, v: 100}),\n new Color({h: 210, s: 100, v: 100}),\n new Color({h: 210, s: 100, v: 75}),\n new Color({h: 210, s: 100, v: 50}),\n new Color({h: 180, s: 0, v: 30}),\n new Color({h: 240, s: 33, v: 100}),\n new Color({h: 240, s: 66, v: 100}),\n new Color({h: 240, s: 100, v: 100}),\n new Color({h: 240, s: 100, v: 75}),\n new Color({h: 240, s: 100, v: 50}),\n new Color({h: 180, s: 0, v: 20}),\n new Color({h: 270, s: 33, v: 100}),\n new Color({h: 270, s: 66, v: 100}),\n new Color({h: 270, s: 100, v: 100}),\n new Color({h: 270, s: 100, v: 75}),\n new Color({h: 270, s: 100, v: 50}),\n new Color({h: 180, s: 0, v: 10}),\n new Color({h: 300, s: 33, v: 100}),\n new Color({h: 300, s: 66, v: 100}),\n new Color({h: 300, s: 100, v: 100}),\n new Color({h: 300, s: 100, v: 75}),\n new Color({h: 300, s: 100, v: 50}),\n new Color({h: 180, s: 0, v: 0}),\n new Color({h: 330, s: 33, v: 100}),\n new Color({h: 330, s: 66, v: 100}),\n new Color({h: 330, s: 100, v: 100}),\n new Color({h: 330, s: 100, v: 75}),\n new Color({h: 330, s: 100, v: 50}),\n new Color()\n ]\n },\n images: {\n clientPath: '/jPicker/images/',\n colorMap: {\n width: 256,\n height: 256,\n arrow: {\n file: 'mappoint.gif',\n width: 15,\n height: 15\n }\n },\n colorBar: {\n width: 20,\n height: 256,\n arrow: {\n file: 'rangearrows.gif',\n width: 20,\n height: 7\n }\n },\n picker: {\n file: 'picker.gif',\n width: 25,\n height: 24\n }\n },\n localization: {\n text: {\n title: 'Drag Markers To Pick A Color',\n newColor: 'new',\n currentColor: 'current',\n ok: 'OK',\n cancel: 'Cancel'\n },\n tooltips: {\n colors: {\n newColor: 'New Color - Press “OK” To Commit',\n currentColor: 'Click To Revert To Original Color'\n },\n buttons: {\n ok: 'Commit To This Color Selection',\n cancel: 'Cancel And Revert To Original Color'\n },\n hue: {\n radio: 'Set To “Hue” Color Mode',\n textbox: 'Enter A “Hue” Value (0-360°)'\n },\n saturation: {\n radio: 'Set To “Saturation” Color Mode',\n textbox: 'Enter A “Saturation” Value (0-100%)'\n },\n value: {\n radio: 'Set To “Value” Color Mode',\n textbox: 'Enter A “Value” Value (0-100%)'\n },\n red: {\n radio: 'Set To “Red” Color Mode',\n textbox: 'Enter A “Red” Value (0-255)'\n },\n green: {\n radio: 'Set To “Green” Color Mode',\n textbox: 'Enter A “Green” Value (0-255)'\n },\n blue: {\n radio: 'Set To “Blue” Color Mode',\n textbox: 'Enter A “Blue” Value (0-255)'\n },\n alpha: {\n radio: 'Set To “Alpha” Color Mode',\n textbox: 'Enter A “Alpha” Value (0-100)'\n },\n hex: {\n textbox: 'Enter A “Hex” Color Value (#000000-#ffffff)',\n alpha: 'Enter A “Alpha” Value (#00-#ff)'\n }\n }\n }\n };\n return $;\n};\n\nexport default jPicker;\n","/* globals jQuery */\n/**\n * Localizing script for SVG-edit UI.\n * @module locale\n * @license MIT\n *\n * @copyright 2010 Narendra Sisodya\n * @copyright 2010 Alexis Deveria\n *\n */\n\n/**\n * Used, for example, in the ImageLibs extension, to present libraries\n * (with name/URL/description) in order.\n * @typedef {GenericArray<module:locale.LocaleStrings>} module:locale.LocaleArray\n*/\n/**\n * The string keys of the object are two-letter language codes.\n * @tutorial LocaleDocs\n * @typedef {PlainObject<string, string|module:locale.LocaleStrings|module:locale.LocaleArray>} module:locale.LocaleStrings\n */\n// keyed to an array of objects with \"id\" and \"title\" or \"textContent\" properties\n/**\n * @typedef {PlainObject<string, string>} module:locale.LocaleSelectorValue\n */\n\nconst $ = jQuery;\n\nlet langParam;\n\n/**\n * Looks for elements to localize using the supplied `obj` to indicate\n * on which selectors (or IDs if `ids` is set to `true`) to set its\n * strings (with selectors relative to the editor root element). All\n * keys will be translated, but for each selector, only the first item\n * found matching will be modified.\n * If the type is `content`, the selector-identified element's children\n * will be checked, and the first (non-empty) text (placeholder) node\n * found will have its text replaced.\n * If the type is `title`, the element's `title`\n * property will be set.\n * If the type is `aria-label`, the element's `aria-label` attribute\n * will be set (i.e., instructions for screen readers when there is\n * otherwise no visible text to be read for the function of the form\n * control).\n * @param {\"content\"|\"title\"} type\n * @param {module:locale.LocaleSelectorValue} obj Selectors or IDs keyed to strings\n * @param {boolean} ids\n * @returns {void}\n*/\nexport const setStrings = function (type, obj, ids) {\n // Root element to look for element from\n const parent = $('#svg_editor').parent();\n Object.entries(obj).forEach(([sel, val]) => {\n if (!val) {\n console.log(sel); // eslint-disable-line no-console\n return; // keep old text when has no translation\n }\n\n if (ids) { sel = '#' + sel; }\n const $elem = parent.find(sel);\n if ($elem.length) {\n const elem = $elem[0];\n\n switch (type) {\n case 'aria-label':\n elem.setAttribute('aria-label', val);\n break;\n case 'content':\n [...elem.childNodes].some((node) => {\n if (node.nodeType === 3 /* Node.TEXT_NODE */ &&\n node.textContent.trim()\n ) {\n node.textContent = val;\n return true;\n }\n return false;\n });\n break;\n\n case 'title':\n elem.title = val;\n break;\n }\n } else {\n console.log('Missing element for localization: ' + sel); // eslint-disable-line no-console\n }\n });\n};\n\n/**\n* The \"data\" property is generally set to an an array of objects with\n* \"id\" and \"title\" or \"textContent\" properties.\n* @typedef {PlainObject} module:locale.AddLangExtensionLocaleData\n* @property {module:locale.LocaleStrings[]} data See {@tutorial LocaleDocs}\n*/\n\n/**\n* @interface module:locale.LocaleEditorInit\n*/\n/**\n * @function module:locale.LocaleEditorInit#addLangData\n * @param {string} langParam\n * @returns {module:locale.AddLangExtensionLocaleData}\n*/\n\nlet editor_;\n/**\n * Sets the current editor instance (on which `addLangData`) exists.\n * @function init\n * @memberof module:locale\n * @param {module:locale.LocaleEditorInit} editor\n * @returns {void}\n*/\nexport const init = (editor) => {\n editor_ = editor;\n};\n\n/**\n* @typedef {PlainObject} module:locale.LangAndData\n* @property {string} langParam\n* @property {module:locale.LocaleStrings} langData\n*/\n\n/**\n* @function module:locale.readLang\n* @param {module:locale.LocaleStrings} langData See {@tutorial LocaleDocs}\n* @fires module:svgcanvas.SvgCanvas#event:ext_addLangData\n* @returns {Promise<module:locale.LangAndData>} Resolves to [`LangAndData`]{@link module:locale.LangAndData}\n*/\nexport const readLang = async function (langData) {\n const more = await editor_.addLangData(langParam);\n $.each(more, function (i, m) {\n if (m.data) {\n langData = $.merge(langData, m.data);\n }\n });\n\n // Old locale file, do nothing for now.\n if (!langData.tools) { return undefined; }\n\n const {\n tools,\n // misc,\n properties, config, layers, common, ui\n } = langData;\n\n setStrings('content', {\n // Todo: Add this powered by (probably by default) but with config to remove\n // copyrightLabel: misc.powered_by, // Currently commented out in svg-editor.html\n curve_segments: properties.curve_segments,\n fitToContent: tools.fitToContent,\n fit_to_all: tools.fit_to_all,\n fit_to_canvas: tools.fit_to_canvas,\n fit_to_layer_content: tools.fit_to_layer_content,\n fit_to_sel: tools.fit_to_sel,\n\n icon_large: config.icon_large,\n icon_medium: config.icon_medium,\n icon_small: config.icon_small,\n icon_xlarge: config.icon_xlarge,\n image_opt_embed: config.image_opt_embed,\n image_opt_ref: config.image_opt_ref,\n includedImages: config.included_images,\n\n largest_object: tools.largest_object,\n\n layersLabel: layers.layers,\n page: tools.page,\n relativeToLabel: tools.relativeTo,\n selLayerLabel: layers.move_elems_to,\n selectedPredefined: config.select_predefined,\n\n selected_objects: tools.selected_objects,\n smallest_object: tools.smallest_object,\n straight_segments: properties.straight_segments,\n\n svginfo_bg_url: config.editor_img_url + ':',\n svginfo_bg_note: config.editor_bg_note,\n svginfo_change_background: config.background,\n svginfo_dim: config.doc_dims,\n svginfo_editor_prefs: config.editor_prefs,\n svginfo_height: common.height,\n svginfo_icons: config.icon_size,\n svginfo_image_props: config.image_props,\n svginfo_lang: config.language,\n svginfo_title: config.doc_title,\n svginfo_width: common.width,\n\n tool_docprops_cancel: common.cancel,\n tool_docprops_save: common.ok,\n\n tool_source_cancel: common.cancel,\n tool_source_save: common.ok,\n\n tool_prefs_cancel: common.cancel,\n tool_prefs_save: common.ok,\n\n sidepanel_handle: layers.layers.split('').join(' '),\n\n tool_clear: tools.new_doc,\n tool_docprops: tools.docprops,\n tool_export: tools.export_img,\n tool_import: tools.import_doc,\n tool_open: tools.open_doc,\n tool_save: tools.save_doc,\n tool_editor_prefs: config.editor_prefs,\n tool_editor_homepage: tools.editor_homepage,\n\n svginfo_units_rulers: config.units_and_rulers,\n svginfo_rulers_onoff: config.show_rulers,\n svginfo_unit: config.base_unit,\n\n svginfo_grid_settings: config.grid,\n svginfo_snap_onoff: config.snapping_onoff,\n svginfo_snap_step: config.snapping_stepsize,\n svginfo_grid_color: config.grid_color\n }, true);\n\n // Context menus\n const opts = {};\n [\n 'cut', 'copy', 'paste', 'paste_in_place', 'delete',\n 'group', 'ungroup', 'move_front', 'move_up',\n 'move_down', 'move_back'\n ].forEach((item) => {\n opts['#cmenu_canvas a[href=\"#' + item + '\"]'] = tools[item];\n });\n\n ['dupe', 'merge_down', 'merge_all'].forEach((item) => {\n opts['#cmenu_layers a[href=\"#' + item + '\"]'] = layers[item];\n });\n\n opts['#cmenu_layers a[href=\"#delete\"]'] = layers.del;\n\n setStrings('content', opts);\n\n const ariaLabels = {};\n Object.entries({\n tool_blur: properties.blur,\n tool_position: tools.align_to_page,\n tool_font_family: properties.font_family,\n zoom_panel: ui.zoom_level,\n stroke_linejoin: properties.linejoin_miter,\n stroke_linecap: properties.linecap_butt,\n tool_opacity: properties.opacity\n }).forEach(([id, value]) => {\n ariaLabels['#' + id + ' button'] = value;\n });\n Object.entries({\n group_opacity: properties.opacity,\n zoom: ui.zoom_level\n }).forEach(([id, value]) => {\n ariaLabels['#' + id] = value;\n });\n setStrings('aria-label', ariaLabels);\n\n setStrings('title', {\n align_relative_to: tools.align_relative_to,\n circle_cx: properties.circle_cx,\n circle_cy: properties.circle_cy,\n circle_r: properties.circle_r,\n cornerRadiusLabel: properties.corner_radius,\n ellipse_cx: properties.ellipse_cx,\n ellipse_cy: properties.ellipse_cy,\n ellipse_rx: properties.ellipse_rx,\n ellipse_ry: properties.ellipse_ry,\n fill_color: properties.fill_color,\n font_family: properties.font_family,\n idLabel: properties.id,\n image_height: properties.image_height,\n image_url: properties.image_url,\n image_width: properties.image_width,\n layer_delete: layers.del,\n layer_down: layers.move_down,\n layer_new: layers.new,\n layer_rename: layers.rename,\n layer_moreopts: common.more_opts,\n layer_up: layers.move_up,\n line_x1: properties.line_x1,\n line_x2: properties.line_x2,\n line_y1: properties.line_y1,\n line_y2: properties.line_y2,\n linecap_butt: properties.linecap_butt,\n linecap_round: properties.linecap_round,\n linecap_square: properties.linecap_square,\n linejoin_bevel: properties.linejoin_bevel,\n linejoin_miter: properties.linejoin_miter,\n linejoin_round: properties.linejoin_round,\n main_icon: tools.main_menu,\n palette: ui.palette_info,\n zoom_panel: ui.zoom_level,\n path_node_x: properties.node_x,\n path_node_y: properties.node_y,\n rect_height_tool: properties.rect_height,\n rect_width_tool: properties.rect_width,\n seg_type: properties.seg_type,\n selLayerNames: layers.move_selected,\n selected_x: properties.pos_x,\n selected_y: properties.pos_y,\n stroke_color: properties.stroke_color,\n stroke_style: properties.stroke_style,\n stroke_width: properties.stroke_width,\n svginfo_title: config.doc_title,\n text: properties.text_contents,\n toggle_stroke_tools: ui.toggle_stroke_tools,\n tool_add_subpath: tools.add_subpath,\n tool_alignbottom: tools.align_bottom,\n tool_aligncenter: tools.align_center,\n tool_alignleft: tools.align_left,\n tool_alignmiddle: tools.align_middle,\n tool_alignright: tools.align_right,\n tool_aligntop: tools.align_top,\n tool_angle: properties.angle,\n tool_blur: properties.blur,\n tool_bold: properties.bold,\n tool_circle: tools.mode_circle,\n tool_clone: tools.clone,\n tool_clone_multi: tools.clone,\n tool_delete: tools.del,\n tool_delete_multi: tools.del,\n tool_ellipse: tools.mode_ellipse,\n tool_fhellipse: tools.mode_fhellipse,\n tool_fhpath: tools.mode_fhpath,\n tool_fhrect: tools.mode_fhrect,\n tool_font_size: properties.font_size,\n tool_group_elements: tools.group_elements,\n tool_make_link: tools.make_link,\n tool_link_url: tools.set_link_url,\n tool_image: tools.mode_image,\n tool_italic: properties.italic,\n tool_line: tools.mode_line,\n tool_move_bottom: tools.move_bottom,\n tool_move_top: tools.move_top,\n tool_node_clone: tools.node_clone,\n tool_node_delete: tools.node_delete,\n tool_node_link: tools.node_link,\n tool_opacity: properties.opacity,\n tool_openclose_path: tools.openclose_path,\n tool_path: tools.mode_path,\n tool_position: tools.align_to_page,\n tool_rect: tools.mode_rect,\n tool_redo: tools.redo,\n tool_reorient: tools.reorient_path,\n tool_select: tools.mode_select,\n tool_source: tools.source_save,\n tool_square: tools.mode_square,\n tool_text: tools.mode_text,\n tool_topath: tools.to_path,\n tool_undo: tools.undo,\n tool_ungroup: tools.ungroup,\n tool_wireframe: tools.wireframe_mode,\n tool_zoom: tools.mode_zoom,\n url_notice: tools.no_embed\n\n }, true);\n\n return {langParam, langData};\n};\n\n/**\n *\n * @function module:locale.putLocale\n * @param {string} givenParam\n * @param {string[]} goodLangs\n * @param {{langPath: string}} conf\n * @fires module:svgcanvas.SvgCanvas#event:ext_addLangData\n * @fires module:svgcanvas.SvgCanvas#event:ext_langReady\n * @fires module:svgcanvas.SvgCanvas#event:ext_langChanged\n * @returns {Promise<module:locale.LangAndData>} Resolves to result of {@link module:locale.readLang}\n*/\nexport const putLocale = async function (givenParam, goodLangs, conf) {\n if (givenParam) {\n langParam = givenParam;\n } else if (navigator.userLanguage) { // Explorer\n langParam = navigator.userLanguage;\n } else if (navigator.language) { // FF, Opera, ...\n langParam = navigator.language;\n }\n\n console.log('Lang: ' + langParam); // eslint-disable-line no-console\n\n // Set to English if language is not in list of good langs\n if (!goodLangs.includes(langParam) && langParam !== 'test') {\n langParam = 'en';\n }\n const url = `${conf.langPath}lang.${langParam}.js`;\n // eslint-disable-next-line node/no-unsupported-features/es-syntax\n const module = await import(url);\n return readLang(module.default);\n};\n","/* globals jQuery */\n/**\n* The main module for the visual SVG Editor.\n*\n* @license MIT\n*\n* @copyright 2010 Alexis Deveria\n* 2010 Pavol Rusnak\n* 2010 Jeff Schiller\n* 2010 Narendra Sisodiya\n* 2014 Brett Zamir\n* @module SVGEditor\n* @borrows module:locale.putLocale as putLocale\n* @borrows module:locale.readLang as readLang\n* @borrows module:locale.setStrings as setStrings\n*/\n\nimport './touch.js';\nimport {NS} from '../common/namespaces.js';\nimport {isWebkit, isChrome, isGecko, isIE, isMac, isTouch} from '../common/browser.js';\n\n// Until we split this into smaller files, this helps distinguish utilities\n// from local methods\nimport * as Utils from '../common/utilities.js';\nimport {getTypeMap, convertUnit, isValidUnit} from '../common/units.js';\nimport {\n hasCustomHandler, getCustomHandler, injectExtendedContextMenuItemsIntoDom\n} from './contextmenu.js';\nimport deparam from '../external/deparam/deparam.esm.js';\n\nimport SvgCanvas from '../svgcanvas/svgcanvas.js';\nimport Layer from '../common/layer.js';\n\nimport jQueryPluginJSHotkeys from './js-hotkeys/jquery.hotkeys.min.js';\nimport jQueryPluginSVGIcons from './svgicons/jQuery.svgIcons.js';\nimport jQueryPluginJGraduate from './jgraduate/jQuery.jGraduate.js';\nimport jQueryPluginSpinButton from './spinbtn/jQuery.SpinButton.js';\nimport jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr`\nimport jQueryPluginContextMenu from './contextmenu/jQuery.contextMenu.js';\nimport jQueryPluginJPicker from './jgraduate/jQuery.jPicker.js';\nimport jQueryPluginDBox from '../svgcanvas/dbox.js';\n\nimport {\n readLang, putLocale,\n setStrings,\n init as localeInit\n} from './locale/locale.js';\n\nconst {$q} = Utils;\n\nconst editor = {};\n\nconst $ = [\n jQueryPluginJSHotkeys, jQueryPluginSVGIcons, jQueryPluginJGraduate,\n jQueryPluginSpinButton, jQueryPluginSVG, jQueryPluginContextMenu, jQueryPluginJPicker\n].reduce((jq, func) => func(jq), jQuery);\n\nconst homePage = 'https://github.com/SVG-Edit/svgedit';\n\n// EDITOR PROPERTIES: (defined below)\n// curPrefs, curConfig, canvas, storage, uiStrings\n//\n// STATE MAINTENANCE PROPERTIES\n/**\n* @type {Float}\n*/\neditor.tool_scale = 1; // Dependent on icon size, so any use to making configurable instead? Used by `jQuery.SpinButton.js`\n/**\n* @type {Integer}\n*/\neditor.exportWindowCt = 0;\n/**\n* @type {boolean}\n*/\neditor.langChanged = false;\n/**\n* @type {boolean}\n*/\neditor.showSaveWarning = false;\n/**\n * Will be set to a boolean by `ext-storage.js`\n * @type {\"ignore\"|\"waiting\"|\"closed\"}\n*/\neditor.storagePromptState = 'ignore';\n\nconst callbacks = [],\n /**\n * @typedef {\"s\"|\"m\"|\"l\"|\"xl\"|Float} module:SVGEditor.IconSize\n */\n /**\n * Preferences.\n * @interface module:SVGEditor.Prefs\n * @property {string} [lang=\"en\"] Two-letter language code. The language must exist in the Editor Preferences language list. Defaults to \"en\" if `locale.js` detection does not detect another language.\n * @property {module:SVGEditor.IconSize} [iconsize=\"s\"|\"m\"] Size of the toolbar icons. Will default to 's' if the window height is smaller than the minimum height and 'm' otherwise.\n * @property {string} [bkgd_color=\"#FFF\"] Color hex for canvas background color. Defaults to white.\n * @property {string} [bkgd_url=\"\"] Background raster image URL. This image will fill the background of the document; useful for tracing purposes.\n * @property {\"embed\"|\"ref\"} [img_save=\"embed\"] Defines whether included raster images should be saved as Data URIs when possible, or as URL references. Settable in the Document Properties dialog.\n * @property {boolean} [save_notice_done=false] Used to track alert status\n * @property {boolean} [export_notice_done=false] Used to track alert status\n * @todo `save_notice_done` and `export_notice_done` should be changed to flags rather than preferences\n */\n /**\n * @namespace {module:SVGEditor.Prefs} defaultPrefs\n * @memberof module:SVGEditor~\n * @implements {module:SVGEditor.Prefs}\n */\n // The iteration algorithm for defaultPrefs does not currently support array/objects\n defaultPrefs = /** @lends module:SVGEditor~defaultPrefs */ {\n // EDITOR OPTIONS (DIALOG)\n /**\n * Default to \"en\" if locale.js detection does not detect another language.\n */\n lang: '',\n /**\n * Will default to 's' if the window height is smaller than the minimum\n * height and 'm' otherwise.\n */\n iconsize: '',\n bkgd_color: '#FFF',\n bkgd_url: '',\n // DOCUMENT PROPERTIES (DIALOG)\n img_save: 'embed',\n // ALERT NOTICES\n // Only shows in UI as far as alert notices, but useful to remember, so keeping as pref\n save_notice_done: false,\n export_notice_done: false\n },\n /**\n * @name module:SVGEditor~defaultExtensions\n * @type {string[]}\n */\n defaultExtensions = [\n 'ext-connector.js',\n 'ext-eyedropper.js',\n 'ext-grid.js',\n 'ext-imagelib.js',\n 'ext-markers.js',\n 'ext-overview_window.js',\n 'ext-panning.js',\n 'ext-polygon.js',\n 'ext-shapes.js',\n 'ext-star.js',\n 'ext-storage.js'\n ],\n /**\n * @typedef {\"@default\"|string} module:SVGEditor.Stylesheet `@default` will automatically load all of the default CSS paths for SVGEditor\n */\n /**\n * @typedef {GenericArray} module:SVGEditor.XYDimensions\n * @property {Integer} length 2\n * @property {Float} 0\n * @property {Float} 1\n */\n /**\n * @tutorial ConfigOptions\n * @interface module:SVGEditor.Config\n * @property {string} [canvasName=\"default\"] Used to namespace storage provided via `ext-storage.js`; you can use this if you wish to have multiple independent instances of SVG Edit on the same domain\n * @property {boolean} [no_save_warning=false] If `true`, prevents the warning dialog box from appearing when closing/reloading the page. Mostly useful for testing.\n * @property {string} [imgPath=\"images/\"] The path where the SVG icons are located, with trailing slash. Note that as of version 2.7, this is not configurable by URL for security reasons.\n * @property {string} [langPath=\"locale/\"] The path where the language files are located, with trailing slash. Default will be changed to `../dist/locale/` if this is a modular load. Note that as of version 2.7, this is not configurable by URL for security reasons.\n * @property {string} [extPath=\"extensions/\"] The path used for extension files, with trailing slash. Default will be changed to `../dist/extensions/` if this is a modular load. Note that as of version 2.7, this is not configurable by URL for security reasons.\n * @property {string} [extIconsPath=\"extensions/\"] The path used for extension icons, with trailing slash.\n * @property {string} [jGraduatePath=\"jgraduate/images/\"] The path where jGraduate images are located. Note that as of version 2.7, this is not configurable by URL for security reasons.\n * @property {boolean} [preventAllURLConfig=false] Set to `true` to override the ability for URLs to set non-content configuration (including extension config). Must be set early, i.e., in `svgedit-config-iife.js`; extension loading is too late!\n * @property {boolean} [preventURLContentLoading=false] Set to `true` to override the ability for URLs to set URL-based SVG content. Must be set early, i.e., in `svgedit-config-iife.js`; extension loading is too late!\n * @property {boolean} [lockExtensions=false] Set to `true` to override the ability for URLs to set their own extensions; disallowed in URL setting. There is no need for this when `preventAllURLConfig` is used. Must be set early, i.e., in `svgedit-config-iife.js`; extension loading is too late!\n * @property {boolean} [noDefaultExtensions=false] If set to `true`, prohibits automatic inclusion of default extensions (though \"extensions\" can still be used to add back any desired default extensions along with any other extensions). This can only be meaningfully used in `svgedit-config-iife.js` or in the URL\n * @property {boolean} [noStorageOnLoad=false] Some interaction with `ext-storage.js`; prevent even the loading of previously saved local storage.\n * @property {boolean} [forceStorage=false] Some interaction with `ext-storage.js`; strongly discouraged from modification as it bypasses user privacy by preventing them from choosing whether to keep local storage or not (and may be required by law in some regions)\n * @property {boolean} [emptyStorageOnDecline=false] Used by `ext-storage.js`; empty any prior storage if the user declines to store\n * @property {boolean} [avoidClientSide=false] DEPRECATED (use `avoidClientSideDownload` instead); Used by `ext-server_opensave.js`; set to `true` if you wish to always save to server and not only as fallback when client support is lacking\n * @property {boolean} [avoidClientSideDownload=false] Used by `ext-server_opensave.js`; set to `true` if you wish to always save to server and not only as fallback when client support is lacking\n * @property {boolean} [avoidClientSideOpen=false] Used by `ext-server_opensave.js`; set to `true` if you wish to always open from the server and not only as fallback when FileReader client support is lacking\n * @property {string[]} [extensions=module:SVGEditor~defaultExtensions] Extensions to load on startup. Use an array in `setConfig` and comma separated file names in the URL. Extension names must begin with \"ext-\". Note that as of version 2.7, paths containing \"/\", \"\\\", or \":\", are disallowed for security reasons. Although previous versions of this list would entirely override the default list, as of version 2.7, the defaults will always be added to this explicit list unless the configuration `noDefaultExtensions` is included.\n * @property {string[]} [allowedOrigins=[]] Used by `ext-xdomain-messaging.js` to indicate which origins are permitted for cross-domain messaging (e.g., between the embedded editor and main editor code). Besides explicit domains, one might add '*' to allow all domains (not recommended for privacy/data integrity of your user's content!), `window.location.origin` for allowing the same origin (should be safe if you trust all apps on your domain), 'null' to allow `file:///` URL usage\n * @property {null|PlainObject} [colorPickerCSS=null] Object of CSS properties mapped to values (for jQuery) to apply to the color picker. See {@link http://api.jquery.com/css/#css-properties}. A `null` value (the default) will cause the CSS to default to `left` with a position equal to that of the `fill_color` or `stroke_color` element minus 140, and a `bottom` equal to 40\n * @property {string} [paramurl] This was available via URL only. Allowed an un-encoded URL within the query string (use \"url\" or \"source\" with a data: URI instead)\n * @property {Float} [canvas_expansion=3] The minimum area visible outside the canvas, as a multiple of the image dimensions. The larger the number, the more one can scroll outside the canvas.\n * @property {PlainObject} [initFill] Init fill properties\n * @property {string} [initFill.color=\"FF0000\"] The initial fill color. Must be a hex code string. Defaults to solid red.\n * @property {Float} [initFill.opacity=1] The initial fill opacity. Must be a number between 0 and 1\n * @property {PlainObject} [initStroke] Init stroke properties\n * @property {Float} [initStroke.width=5] The initial stroke width. Must be a positive number.\n * @property {string} [initStroke.color=\"000000\"] The initial stroke color. Must be a hex code. Defaults to solid black.\n * @property {Float} [initStroke.opacity=1] The initial stroke opacity. Must be a number between 0 and 1.\n * @property {PlainObject} text Text style properties\n * @property {Float} [text.stroke_width=0] Text stroke width\n * @property {Float} [text.font_size=24] Text font size\n * @property {string} [text.font_family=\"serif\"] Text font family\n * @property {Float} [initOpacity=1] Initial opacity (multiplied by 100)\n * @property {module:SVGEditor.XYDimensions} [dimensions=[640, 480]] The default width/height of a new document. Use an array in `setConfig` (e.g., `[800, 600]`) and comma separated numbers in the URL.\n * @property {boolean} [gridSnapping=false] Enable snap to grid by default. Set in Editor Options.\n * @property {string} [gridColor=\"#000\"] Accepts hex, e.g., '#000'. Set in Editor Options. Defaults to black.\n * @property {string} [baseUnit=\"px\"] Set in Editor Options.\n * @property {Float} [snappingStep=10] Set the default grid snapping value. Set in Editor Options.\n * @property {boolean} [showRulers=true] Initial state of ruler display (v2.6). Set in Editor Options.\n * @property {string} [initTool=\"select\"] The initially selected tool. Must be either the ID of the button for the tool, or the ID without `tool_` prefix (e.g., \"select\").\n * @property {boolean} [wireframe=false] Start in wireframe mode\n * @property {boolean} [showlayers=false] Open the layers side-panel by default.\n * @property {\"new\"|\"same\"} [exportWindowType=\"new\"] Can be \"new\" or \"same\" to indicate whether new windows will be generated for each export; the `window.name` of the export window is namespaced based on the `canvasName` (and incremented if \"new\" is selected as the type). Introduced 2.8.\n * @property {boolean} [showGrid=false] Set by `ext-grid.js`; determines whether or not to show the grid by default\n * @property {boolean} [show_outside_canvas=true] Defines whether or not elements outside the canvas should be visible. Set and used in `svgcanvas.js`.\n * @property {boolean} [selectNew=true] If true, will replace the selection with the current element and automatically select element objects (when not in \"path\" mode) after they are created, showing their grips (v2.6). Set and used in `svgcanvas.js` (`mouseUp`).\n * @todo Some others could be preferences as well (e.g., preventing URL changing of extensions, defaultExtensions, stylesheets, colorPickerCSS); Change the following to preferences and add pref controls where missing to the UI (e.g., `canvas_expansion`, `initFill`, `initStroke`, `text`, `initOpacity`, `dimensions`, `initTool`, `wireframe`, `showlayers`, `gridSnapping`, `gridColor`, `baseUnit`, `snappingStep`, `showRulers`, `exportWindowType`, `showGrid`, `show_outside_canvas`, `selectNew`)?\n */\n /**\n * @namespace {module:SVGEditor.Config} defaultConfig\n * @memberof module:SVGEditor~\n * @implements {module:SVGEditor.Config}\n */\n defaultConfig = {\n canvasName: 'default',\n canvas_expansion: 3,\n initFill: {\n color: 'FF0000', // solid red\n opacity: 1\n },\n initStroke: {\n width: 5,\n color: '000000', // solid black\n opacity: 1\n },\n text: {\n stroke_width: 0,\n font_size: 24,\n font_family: 'serif'\n },\n initOpacity: 1,\n colorPickerCSS: null, // Defaults to 'left' with a position equal to that of the fill_color or stroke_color element minus 140, and a 'bottom' equal to 40\n initTool: 'select',\n exportWindowType: 'new', // 'same' (todo: also support 'download')\n wireframe: false,\n showlayers: false,\n no_save_warning: false,\n // PATH CONFIGURATION\n // The following path configuration items are disallowed in the URL (as should any future path configurations)\n langPath: './locale/', // Default will be changed if this is a non-modular load\n extPath: './extensions/', // Default will be changed if this is a non-modular load\n imgPath: './images/',\n jGraduatePath: './images/',\n extIconsPath: './extensions/',\n // DOCUMENT PROPERTIES\n // Change the following to a preference (already in the Document Properties dialog)?\n dimensions: [640, 480],\n // EDITOR OPTIONS\n // Change the following to preferences (already in the Editor Options dialog)?\n gridSnapping: false,\n gridColor: '#000',\n baseUnit: 'px',\n snappingStep: 10,\n showRulers: true,\n // URL BEHAVIOR CONFIGURATION\n preventAllURLConfig: false,\n preventURLContentLoading: false,\n // EXTENSION CONFIGURATION (see also preventAllURLConfig)\n lockExtensions: false, // Disallowed in URL setting\n noDefaultExtensions: false, // noDefaultExtensions can only be meaningfully used in `svgedit-config-iife.js` or in the URL\n // EXTENSION-RELATED (GRID)\n showGrid: false, // Set by ext-grid.js\n // EXTENSION-RELATED (STORAGE)\n noStorageOnLoad: false, // Some interaction with ext-storage.js; prevent even the loading of previously saved local storage\n forceStorage: false, // Some interaction with ext-storage.js; strongly discouraged from modification as it bypasses user privacy by preventing them from choosing whether to keep local storage or not\n emptyStorageOnDecline: false, // Used by ext-storage.js; empty any prior storage if the user declines to store\n // EXTENSION (CLIENT VS. SERVER SAVING/OPENING)\n avoidClientSide: false, // Deprecated in favor of `avoidClientSideDownload`\n avoidClientSideDownload: false,\n avoidClientSideOpen: false\n },\n /**\n * LOCALE.\n * @name module:SVGEditor.uiStrings\n * @type {PlainObject}\n */\n uiStrings = editor.uiStrings = {};\n\nlet svgCanvas, urldata = {},\n isReady = false,\n customExportImage = false,\n customExportPDF = false,\n curPrefs = {},\n // Note: The difference between Prefs and Config is that Prefs\n // can be changed in the UI and are stored in the browser,\n // while config cannot\n curConfig = {\n // We do not put on defaultConfig to simplify object copying\n // procedures (we obtain instead from defaultExtensions)\n extensions: [],\n /**\n * Can use `location.origin` to indicate the current\n * origin. Can contain a '*' to allow all domains or 'null' (as\n * a string) to support all `file:///` URLs. Cannot be set by\n * URL for security reasons (not safe, at least for\n * privacy or data integrity of SVG content).\n * Might have been fairly safe to allow\n * `new URL(location.href).origin` by default but\n * avoiding it ensures some more security that even third\n * party apps on the same domain also cannot communicate\n * with this app by default.\n * For use with `ext-xdomain-messaging.js`\n * @todo We might instead make as a user-facing preference.\n */\n allowedOrigins: []\n };\n\n/**\n *\n * @param {string} str SVG string\n * @param {PlainObject} [opts={}]\n * @param {boolean} [opts.noAlert]\n * @throws {Error} Upon failure to load SVG\n * @returns {Promise<void>} Resolves to undefined upon success (or if `noAlert` is\n * falsey, though only until after the `alert` is closed); rejects if SVG\n * loading fails and `noAlert` is truthy.\n */\nasync function loadSvgString (str, {noAlert} = {}) {\n const success = svgCanvas.setSvgString(str) !== false;\n if (success) {\n return;\n }\n\n if (!noAlert) {\n await $.alert(uiStrings.notification.errorLoadingSVG);\n return;\n }\n throw new Error('Error loading SVG');\n}\n\n/**\n * @function module:SVGEditor~getImportLocale\n * @param {PlainObject} defaults\n * @param {string} defaults.defaultLang\n * @param {string} defaults.defaultName\n * @returns {module:SVGEditor~ImportLocale}\n */\nfunction getImportLocale ({defaultLang, defaultName}) {\n /**\n * @function module:SVGEditor~ImportLocale\n * @param {PlainObject} localeInfo\n * @param {string} [localeInfo.name] Defaults to `defaultName` of {@link module:SVGEditor~getImportLocale}\n * @param {string} [localeInfo.lang=defaultLang] Defaults to `defaultLang` of {@link module:SVGEditor~getImportLocale}\n * @returns {Promise<module:locale.LocaleStrings>} Resolves to {@link module:locale.LocaleStrings}\n */\n return async function importLocaleDefaulting ({name = defaultName, lang = defaultLang} = {}) {\n /**\n *\n * @param {string} language\n * @returns {Promise<module:locale.LocaleStrings>} Resolves to {@link module:locale.LocaleStrings}\n */\n async function importLocale (language) {\n const url = `${curConfig.extPath}ext-locale/${name}/${language}.js`;\n // eslint-disable-next-line node/no-unsupported-features/es-syntax\n const locale = await import(url);\n return locale.default;\n }\n try {\n return await importLocale(lang);\n } catch (err) {\n return importLocale('en');\n }\n };\n}\n\n/**\n* EXPORTS.\n*/\n\n/**\n* Store and retrieve preferences.\n* @function module:SVGEditor.pref\n* @param {string} key The preference name to be retrieved or set\n* @param {string} [val] The value. If the value supplied is missing or falsey, no change to the preference will\n* be made unless `mayBeEmpty` is set.\n* @param {boolean} [mayBeEmpty] If value may be falsey.\n* @returns {string|void} If val is missing or falsey and `mayBeEmpty` is not set, the\n* value of the previously stored preference will be returned.\n* @todo Review whether any remaining existing direct references to\n* getting `curPrefs` can be changed to use `svgEditor.pref()` getting to ensure\n* `defaultPrefs` fallback (also for sake of `allowInitialUserOverride`);\n* specifically, `bkgd_color` could be changed so that the pref dialog has a\n* button to auto-calculate background, but otherwise uses `svgEditor.pref()` to\n* be able to get default prefs or overridable settings\n*/\neditor.pref = function (key, val, mayBeEmpty) {\n if (mayBeEmpty || val) {\n curPrefs[key] = val;\n /**\n * @name curPrefs\n * @memberof module:SVGEditor\n * @implements {module:SVGEditor.Prefs}\n */\n editor.curPrefs = curPrefs; // Update exported value\n return undefined;\n }\n return (key in curPrefs) ? curPrefs[key] : defaultPrefs[key];\n};\n\n/*\n* EDITOR PUBLIC METHODS\n// Todo: Sort these methods per invocation order, ideally with init at the end\n// Todo: Prevent execution until init executes if dependent on it?\n*/\neditor.putLocale = putLocale;\neditor.readLang = readLang;\neditor.setStrings = setStrings;\n\n/**\n* Where permitted, sets canvas and/or `defaultPrefs` based on previous\n* storage. This will override URL settings (for security reasons) but\n* not `svgedit-config-iife.js` configuration (unless initial user\n* overriding is explicitly permitted there via `allowInitialUserOverride`).\n* @function module:SVGEditor.loadContentAndPrefs\n* @todo Split `allowInitialUserOverride` into `allowOverrideByURL` and\n* `allowOverrideByUserStorage` so `svgedit-config-iife.js` can disallow some\n* individual items for URL setting but allow for user storage AND/OR\n* change URL setting so that it always uses a different namespace,\n* so it won't affect pre-existing user storage (but then if users saves\n* that, it will then be subject to tampering\n* @returns {void}\n*/\neditor.loadContentAndPrefs = function () {\n if (!curConfig.forceStorage &&\n (curConfig.noStorageOnLoad ||\n !document.cookie.match(/(?:^|;\\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/)\n )\n ) {\n return;\n }\n\n // LOAD CONTENT\n if (editor.storage && // Cookies do not have enough available memory to hold large documents\n (curConfig.forceStorage ||\n (!curConfig.noStorageOnLoad &&\n document.cookie.match(/(?:^|;\\s*)svgeditstore=prefsAndContent/))\n )\n ) {\n const name = 'svgedit-' + curConfig.canvasName;\n const cached = editor.storage.getItem(name);\n if (cached) {\n editor.loadFromString(cached);\n }\n }\n\n // LOAD PREFS\n Object.keys(defaultPrefs).forEach((key) => {\n const storeKey = 'svg-edit-' + key;\n if (editor.storage) {\n const val = editor.storage.getItem(storeKey);\n if (val) {\n defaultPrefs[key] = String(val); // Convert to string for FF (.value fails in Webkit)\n }\n } else if (window.widget) {\n defaultPrefs[key] = window.widget.preferenceForKey(storeKey);\n } else {\n const result = document.cookie.match(\n new RegExp('(?:^|;\\\\s*)' + Utils.regexEscape(\n encodeURIComponent(storeKey)\n ) + '=([^;]+)')\n );\n defaultPrefs[key] = result ? decodeURIComponent(result[1]) : '';\n }\n });\n};\n\n/**\n* Allows setting of preferences or configuration (including extensions).\n* @function module:SVGEditor.setConfig\n* @param {module:SVGEditor.Config|module:SVGEditor.Prefs} opts The preferences or configuration (including extensions). See the tutorial on {@tutorial ConfigOptions} for info on config and preferences.\n* @param {PlainObject} [cfgCfg] Describes configuration which applies to the\n* particular batch of supplied options\n* @param {boolean} [cfgCfg.allowInitialUserOverride=false] Set to true if you wish\n* to allow initial overriding of settings by the user via the URL\n* (if permitted) or previously stored preferences (if permitted);\n* note that it will be too late if you make such calls in extension\n* code because the URL or preference storage settings will\n* have already taken place.\n* @param {boolean} [cfgCfg.overwrite=true] Set to false if you wish to\n* prevent the overwriting of prior-set preferences or configuration\n* (URL settings will always follow this requirement for security\n* reasons, so `svgedit-config-iife.js` settings cannot be overridden unless it\n* explicitly permits via `allowInitialUserOverride` but extension config\n* can be overridden as they will run after URL settings). Should\n* not be needed in `svgedit-config-iife.js`.\n* @returns {void}\n*/\neditor.setConfig = function (opts, cfgCfg) {\n cfgCfg = cfgCfg || {};\n /**\n *\n * @param {module:SVGEditor.Config|module:SVGEditor.Prefs} cfgObj\n * @param {string} key\n * @param {any} val See {@link module:SVGEditor.Config} or {@link module:SVGEditor.Prefs}\n * @returns {void}\n */\n function extendOrAdd (cfgObj, key, val) {\n if (cfgObj[key] && typeof cfgObj[key] === 'object') {\n $.extend(true, cfgObj[key], val);\n } else {\n cfgObj[key] = val;\n }\n }\n Object.entries(opts).forEach(function ([key, val]) {\n // Only allow prefs defined in defaultPrefs or...\n if ({}.hasOwnProperty.call(defaultPrefs, key)) {\n if (cfgCfg.overwrite === false && (\n curConfig.preventAllURLConfig ||\n {}.hasOwnProperty.call(curPrefs, key)\n )) {\n return;\n }\n if (cfgCfg.allowInitialUserOverride === true) {\n defaultPrefs[key] = val;\n } else {\n editor.pref(key, val);\n }\n } else if (['extensions', 'allowedOrigins'].includes(key)) {\n if (cfgCfg.overwrite === false &&\n (\n curConfig.preventAllURLConfig ||\n ['allowedOrigins'].includes(key) ||\n (key === 'extensions' && curConfig.lockExtensions)\n )\n ) {\n return;\n }\n curConfig[key] = curConfig[key].concat(val); // We will handle any dupes later\n // Only allow other curConfig if defined in defaultConfig\n } else if ({}.hasOwnProperty.call(defaultConfig, key)) {\n if (cfgCfg.overwrite === false && (\n curConfig.preventAllURLConfig ||\n {}.hasOwnProperty.call(curConfig, key)\n )) {\n return;\n }\n // Potentially overwriting of previously set config\n if ({}.hasOwnProperty.call(curConfig, key)) {\n if (cfgCfg.overwrite === false) {\n return;\n }\n extendOrAdd(curConfig, key, val);\n } else if (cfgCfg.allowInitialUserOverride === true) {\n extendOrAdd(defaultConfig, key, val);\n } else if (defaultConfig[key] && typeof defaultConfig[key] === 'object') {\n curConfig[key] = Array.isArray(defaultConfig[key]) ? [] : {};\n $.extend(true, curConfig[key], val); // Merge properties recursively, e.g., on initFill, initStroke objects\n } else {\n curConfig[key] = val;\n }\n }\n });\n /**\n * @name curConfig\n * @memberof module:SVGEditor\n * @implements {module:SVGEditor.Config}\n */\n editor.curConfig = curConfig; // Update exported value\n};\n\n/**\n* All methods are optional.\n* @interface module:SVGEditor.CustomHandler\n* @type {PlainObject}\n*/\n/**\n* Its responsibilities are:\n* - invoke a file chooser dialog in 'open' mode\n* - let user pick a SVG file\n* - calls [svgCanvas.setSvgString()]{@link module:svgcanvas.SvgCanvas#setSvgString} with the string contents of that file.\n* Not passed any parameters.\n* @function module:SVGEditor.CustomHandler#open\n* @returns {void}\n*/\n/**\n* Its responsibilities are:\n* - accept the string contents of the current document\n* - invoke a file chooser dialog in 'save' mode\n* - save the file to location chosen by the user.\n* @function module:SVGEditor.CustomHandler#save\n* @param {external:Window} win\n* @param {module:svgcanvas.SvgCanvas#event:saved} svgStr A string of the SVG\n* @listens module:svgcanvas.SvgCanvas#event:saved\n* @returns {void}\n*/\n/**\n* Its responsibilities (with regard to the object it is supplied in its 2nd argument) are:\n* - inform user of any issues supplied via the \"issues\" property\n* - convert the \"svg\" property SVG string into an image for export;\n* utilize the properties \"type\" (currently 'PNG', 'JPEG', 'BMP',\n* 'WEBP', 'PDF'), \"mimeType\", and \"quality\" (for 'JPEG' and 'WEBP'\n* types) to determine the proper output.\n* @function module:SVGEditor.CustomHandler#exportImage\n* @param {external:Window} win\n* @param {module:svgcanvas.SvgCanvas#event:exported} data\n* @listens module:svgcanvas.SvgCanvas#event:exported\n* @returns {void}\n*/\n/**\n* @function module:SVGEditor.CustomHandler#exportPDF\n* @param {external:Window} win\n* @param {module:svgcanvas.SvgCanvas#event:exportedPDF} data\n* @listens module:svgcanvas.SvgCanvas#event:exportedPDF\n* @returns {void}\n*/\n\n/**\n* Allows one to override default SVGEdit `open`, `save`, and\n* `export` editor behaviors.\n* @function module:SVGEditor.setCustomHandlers\n* @param {module:SVGEditor.CustomHandler} opts Extension mechanisms may call `setCustomHandlers` with three functions: `opts.open`, `opts.save`, and `opts.exportImage`\n* @returns {Promise<void>}\n*/\neditor.setCustomHandlers = function (opts) {\n return editor.ready(function () {\n if (opts.open) {\n $('#tool_open > input[type=\"file\"]').remove();\n $('#tool_open').show();\n svgCanvas.open = opts.open;\n }\n if (opts.save) {\n editor.showSaveWarning = false;\n svgCanvas.bind('saved', opts.save);\n }\n if (opts.exportImage) {\n customExportImage = opts.exportImage;\n svgCanvas.bind('exported', customExportImage); // canvg and our RGBColor will be available to the method\n }\n if (opts.exportPDF) {\n customExportPDF = opts.exportPDF;\n svgCanvas.bind('exportedPDF', customExportPDF); // jsPDF and our RGBColor will be available to the method\n }\n });\n};\n\n/**\n * @function module:SVGEditor.randomizeIds\n * @param {boolean} arg\n * @returns {void}\n */\neditor.randomizeIds = function (arg) {\n svgCanvas.randomizeIds(arg);\n};\n\n/**\n* Auto-run after a Promise microtask.\n* @function module:SVGEditor.init\n* @returns {void}\n*/\neditor.init = function () {\n // const host = location.hostname,\n // onWeb = host && host.includes('.');\n // Some FF versions throw security errors here when directly accessing\n try {\n if ('localStorage' in window) { // && onWeb removed so Webkit works locally\n /**\n * The built-in interface implemented by `localStorage`\n * @external Storage\n */\n /**\n * @name storage\n * @memberof module:SVGEditor\n * @type {external:Storage}\n */\n editor.storage = localStorage;\n }\n } catch (err) {}\n\n // Todo: Avoid const-defined functions and group functions together, etc. where possible\n const goodLangs = [];\n $('#lang_select option').each(function () {\n goodLangs.push(this.value);\n });\n\n /**\n * Sets up current preferences based on defaults.\n * @returns {void}\n */\n function setupCurPrefs () {\n curPrefs = $.extend(true, {}, defaultPrefs, curPrefs); // Now safe to merge with priority for curPrefs in the event any are already set\n // Export updated prefs\n editor.curPrefs = curPrefs;\n }\n\n /**\n * Sets up current config based on defaults.\n * @returns {void}\n */\n function setupCurConfig () {\n curConfig = $.extend(true, {}, defaultConfig, curConfig); // Now safe to merge with priority for curConfig in the event any are already set\n\n // Now deal with extensions and other array config\n if (!curConfig.noDefaultExtensions) {\n curConfig.extensions = curConfig.extensions.concat(defaultExtensions);\n }\n // ...and remove any dupes\n ['extensions', 'allowedOrigins'].forEach(function (cfg) {\n curConfig[cfg] = $.grep(curConfig[cfg], function (n, i) { // Supposedly faster than filter per http://amandeep1986.blogspot.hk/2015/02/jquery-grep-vs-js-filter.html\n return i === curConfig[cfg].indexOf(n);\n });\n });\n // Export updated config\n editor.curConfig = curConfig;\n }\n (() => {\n // Load config/data from URL if given\n const {search, searchParams} = new URL(location);\n\n if (search) {\n urldata = deparam(searchParams.toString(), true);\n\n ['initStroke', 'initFill'].forEach((prop) => {\n if (searchParams.has(`${prop}[color]`)) {\n // Restore back to original non-deparamed value to avoid color\n // strings being converted to numbers\n urldata[prop].color = searchParams.get(`${prop}[color]`);\n }\n });\n\n if (searchParams.has('bkgd_color')) {\n urldata.bkgd_color = '#' + searchParams.get('bkgd_color');\n }\n\n if (urldata.dimensions) {\n urldata.dimensions = urldata.dimensions.split(',');\n }\n\n if (urldata.extensions) {\n // For security reasons, disallow cross-domain or cross-folder\n // extensions via URL\n urldata.extensions = urldata.extensions.match(/[:/\\\\]/)\n ? ''\n : urldata.extensions.split(',');\n }\n\n // Disallowing extension paths via URL for\n // security reasons, even for same-domain\n // ones given potential to interact in undesirable\n // ways with other script resources\n ['langPath', 'extPath', 'imgPath', 'jGraduatePath', 'extIconsPath']\n .forEach(function (pathConfig) {\n if (urldata[pathConfig]) {\n delete urldata[pathConfig];\n }\n });\n\n // Note: `source` and `url` (as with `storagePrompt` later) are not\n // set on config but are used below\n editor.setConfig(urldata, {overwrite: false});\n setupCurConfig();\n\n if (!curConfig.preventURLContentLoading) {\n let {source} = urldata;\n if (!source) { // urldata.source may have been null if it ended with '='\n const src = searchParams.get('source');\n if (src && src.startsWith('data:')) {\n source = src;\n }\n }\n if (source) {\n if (source.startsWith('data:')) {\n editor.loadFromDataURI(source);\n } else {\n editor.loadFromString(source);\n }\n return;\n }\n if (urldata.url) {\n editor.loadFromURL(urldata.url);\n return;\n }\n }\n if (!urldata.noStorageOnLoad || curConfig.forceStorage) {\n editor.loadContentAndPrefs();\n }\n } else {\n setupCurConfig();\n editor.loadContentAndPrefs();\n }\n })();\n setupCurPrefs();\n\n /**\n * Called internally.\n * @function module:SVGEditor.setIcon\n * @param {string|Element|external:jQuery} elem\n * @param {string|external:jQuery} iconId\n * @param {Float} forcedSize Not in use\n * @returns {void}\n */\n const setIcon = editor.setIcon = function (elem, iconId, forcedSize) {\n const icon = (typeof iconId === 'string') ? $.getSvgIcon(iconId, true) : iconId.clone();\n if (!icon) {\n // Todo: Investigate why this still occurs in some cases\n console.log('NOTE: Icon image missing: ' + iconId); // eslint-disable-line no-console\n return;\n }\n $(elem).empty().append(icon);\n };\n\n /**\n * @fires module:svgcanvas.SvgCanvas#event:ext_addLangData\n * @fires module:svgcanvas.SvgCanvas#event:ext_langReady\n * @fires module:svgcanvas.SvgCanvas#event:ext_langChanged\n * @fires module:svgcanvas.SvgCanvas#event:extensions_added\n * @returns {Promise<module:locale.LangAndData>} Resolves to result of {@link module:locale.readLang}\n */\n const extAndLocaleFunc = async function () {\n // const lang = ('lang' in curPrefs) ? curPrefs.lang : null;\n const {langParam, langData} = await editor.putLocale(\n editor.pref('lang'), goodLangs, curConfig\n );\n await setLang(langParam, langData);\n\n const {ok, cancel} = uiStrings.common;\n jQueryPluginDBox($, {ok, cancel});\n\n setIcons(); // Wait for dbox as needed for i18n\n\n try {\n await Promise.all(\n curConfig.extensions.map(async (extname) => {\n const extensionName = extname.match(/^ext-(.+)\\.js/);\n // const {extName} = extname.match(/^ext-(?<extName>.+)\\.js/).groups;\n if (!extensionName) { // Ensure URL cannot specify some other unintended file in the extPath\n return undefined;\n }\n const url = curConfig.extPath + extname;\n\n /**\n * @tutorial ExtensionDocs\n * @typedef {PlainObject} module:SVGEditor.ExtensionObject\n * @property {string} [name] Name of the extension. Used internally; no need for i18n. Defaults to extension name without beginning \"ext-\" or ending \".js\".\n * @property {module:svgcanvas.ExtensionInitCallback} [init]\n */\n try {\n /**\n * @type {module:SVGEditor.ExtensionObject}\n */\n // eslint-disable-next-line node/no-unsupported-features/es-syntax\n const imported = await import(url);\n const {name = extensionName[1], init} = imported.default;\n // const {name = extName, init} = imported;\n const importLocale = getImportLocale({defaultLang: langParam, defaultName: name});\n return editor.addExtension(name, (init && init.bind(editor)), {$, importLocale});\n } catch (err) {\n // Todo: Add config to alert any errors\n console.log(err); // eslint-disable-line no-console\n console.error('Extension failed to load: ' + extname + '; ' + err); // eslint-disable-line no-console\n return undefined;\n }\n })\n );\n svgCanvas.bind(\n 'extensions_added',\n /**\n * @param {external:Window} win\n * @param {module:svgcanvas.SvgCanvas#event:extensions_added} data\n * @listens module:svgcanvas.SvgCanvas#event:extensions_added\n * @returns {void}\n */\n (win, data) => {\n extensionsAdded = true;\n Actions.setAll();\n\n $('.flyout_arrow_horiz:empty').each(function () {\n $(this).append($.getSvgIcon('arrow_right', true).width(5).height(5));\n });\n\n if (editor.storagePromptState === 'ignore') {\n updateCanvas(true);\n }\n\n messageQueue.forEach(\n /**\n * @param {module:svgcanvas.SvgCanvas#event:message} messageObj\n * @fires module:svgcanvas.SvgCanvas#event:message\n * @returns {void}\n */\n (messageObj) => {\n svgCanvas.call('message', messageObj);\n }\n );\n }\n );\n svgCanvas.call('extensions_added');\n } catch (err) {\n // Todo: Report errors through the UI\n console.log(err); // eslint-disable-line no-console\n }\n };\n\n const stateObj = {tool_scale: editor.tool_scale};\n\n /**\n *\n * @returns {void}\n */\n const setFlyoutPositions = function () {\n $('.tools_flyout').each(function () {\n const shower = $('#' + this.id + '_show');\n const {left, top} = shower.offset();\n const w = shower.outerWidth();\n $(this).css({left: (left + w) * editor.tool_scale, top});\n });\n };\n\n /**\n * @type {string}\n */\n const uaPrefix = (function () {\n const regex = /^(?:Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/;\n const someScript = document.getElementsByTagName('script')[0];\n for (const prop in someScript.style) {\n if (regex.test(prop)) {\n // test is faster than match, so it's better to perform\n // that on the lot and match only when necessary\n return prop.match(regex)[0];\n }\n }\n // Nothing found so far?\n if ('WebkitOpacity' in someScript.style) { return 'Webkit'; }\n if ('KhtmlOpacity' in someScript.style) { return 'Khtml'; }\n\n return '';\n }());\n\n /**\n * @param {external:jQuery} elems\n * @param {Float} scale\n * @returns {void}\n */\n const scaleElements = function (elems, scale) {\n // const prefix = '-' + uaPrefix.toLowerCase() + '-'; // Currently unused\n const sides = ['top', 'left', 'bottom', 'right'];\n\n elems.each(function () {\n // Handled in CSS\n // this.style[uaPrefix + 'Transform'] = 'scale(' + scale + ')';\n const el = $(this);\n const w = el.outerWidth() * (scale - 1);\n const h = el.outerHeight() * (scale - 1);\n // const margins = {}; // Currently unused\n\n for (let i = 0; i < 4; i++) {\n const s = sides[i];\n let cur = el.data('orig_margin-' + s);\n if (Utils.isNullish(cur)) {\n cur = Number.parseInt(el.css('margin-' + s));\n // Cache the original margin\n el.data('orig_margin-' + s, cur);\n }\n let val = cur * scale;\n if (s === 'right') {\n val += w;\n } else if (s === 'bottom') {\n val += h;\n }\n\n el.css('margin-' + s, val);\n // el.css('outline', '1px solid red');\n }\n });\n };\n\n /**\n * Called internally.\n * @function module:SVGEditor.setIconSize\n * @param {module:SVGEditor.IconSize} size\n * @returns {void}\n */\n const setIconSize = editor.setIconSize = function (size) {\n // const elems = $('.tool_button, .push_button, .tool_button_current, .disabled, .icon_label, #url_notice, #tool_open');\n const selToscale = '#tools_top .toolset, #editor_panel > *, #history_panel > *,' +\n ' #main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,' +\n ' #g_panel > *, #tool_font_size > *, .tools_flyout';\n\n const elems = $(selToscale);\n\n let scale = 1;\n if (typeof size === 'number') {\n scale = size;\n } else {\n const iconSizes = {s: 0.75, m: 1, l: 1.25, xl: 1.5};\n scale = iconSizes[size];\n }\n\n stateObj.tool_scale = editor.tool_scale = scale;\n\n setFlyoutPositions();\n // $('.tools_flyout').each(function () {\n // const pos = $(this).position();\n // console.log($(this), pos.left+(34 * scale));\n // $(this).css({left: pos.left+(34 * scale), top: pos.top+(77 * scale)});\n // console.log('l', $(this).css('left'));\n // });\n //\n // const scale = .75;\n\n const hiddenPs = elems.parents(':hidden');\n hiddenPs.css('visibility', 'hidden').show();\n scaleElements(elems, scale);\n hiddenPs.css('visibility', 'visible').hide();\n // return;\n\n editor.pref('iconsize', size);\n $('#iconsize').val(size);\n\n // Note that all rules will be prefixed with '#svg_editor' when parsed\n const cssResizeRules = {\n '#tools_top': {\n left: 50 + $('#main_button').width(),\n height: 72\n },\n '#tools_left': {\n width: 31,\n top: 74\n },\n 'div#workarea': {\n left: 38,\n top: 74\n }\n };\n\n let ruleElem = $('#tool_size_rules');\n if (!ruleElem.length) {\n ruleElem = $('<style id=\"tool_size_rules\"></style>').appendTo('head');\n } else {\n ruleElem.empty();\n }\n\n if (size !== 'm') {\n let styleStr = '';\n $.each(cssResizeRules, function (selector, rules) {\n selector = '#svg_editor ' + selector.replace(/,/g, ', #svg_editor');\n styleStr += selector + '{';\n $.each(rules, function (prop, values) {\n let val;\n if (typeof values === 'number') {\n val = (values * scale) + 'px';\n } else if (values[size] || values.all) {\n val = (values[size] || values.all);\n }\n styleStr += (prop + ':' + val + ';');\n });\n styleStr += '}';\n });\n // this.style[uaPrefix + 'Transform'] = 'scale(' + scale + ')';\n const prefix = '-' + uaPrefix.toLowerCase() + '-';\n styleStr += (selToscale + '{' + prefix + 'transform: scale(' + scale + ');}' +\n ' #svg_editor div.toolset .toolset {' + prefix + 'transform: scale(1); margin: 1px !important;}' + // Hack for markers\n ' #svg_editor .ui-slider {' + prefix + 'transform: scale(' + (1 / scale) + ');}' // Hack for sliders\n );\n ruleElem.text(styleStr);\n }\n\n setFlyoutPositions();\n };\n\n /**\n * Setup SVG icons.\n * @returns {void}\n */\n function setIcons () {\n $.svgIcons(curConfig.imgPath + 'svg_edit_icons.svg', {\n w: 24, h: 24,\n id_match: false,\n no_img: !isWebkit(), // Opera & Firefox 4 gives odd behavior w/images\n fallback_path: curConfig.imgPath,\n // Todo: Set `alts: {}` with keys as the IDs in fallback set to\n // `uiStrings` (localized) values\n fallback: {\n logo: 'logo.png',\n\n select: 'select.png',\n select_node: 'select_node.png',\n\n square: 'square.png',\n rect: 'rect.png',\n fh_rect: 'freehand-square.png',\n circle: 'circle.png',\n ellipse: 'ellipse.png',\n fh_ellipse: 'freehand-circle.png',\n pencil: 'fhpath.png',\n pen: 'line.png',\n text: 'text.png',\n path: 'path.png',\n add_subpath: 'add_subpath.png',\n close_path: 'closepath.png',\n open_path: 'openpath.png',\n\n image: 'image.png',\n zoom: 'zoom.png',\n\n arrow_right: 'flyouth.png',\n arrow_right_big: 'arrow_right_big.png',\n arrow_down: 'dropdown.gif',\n fill: 'fill.png',\n stroke: 'stroke.png',\n opacity: 'opacity.png',\n\n new_image: 'clear.png',\n save: 'save.png',\n export: 'export.png',\n open: 'open.png',\n import: 'import.png',\n docprops: 'document-properties.png',\n source: 'source.png',\n wireframe: 'wireframe.png',\n\n undo: 'undo.png',\n redo: 'redo.png',\n\n clone: 'clone.png',\n delete: 'delete.png',\n go_up: 'go-up.png',\n go_down: 'go-down.png',\n context_menu: 'context_menu.png',\n move_bottom: 'move_bottom.png',\n move_top: 'move_top.png',\n to_path: 'to_path.png',\n link_controls: 'link_controls.png',\n reorient: 'reorient.png',\n group_elements: 'shape_group_elements.png',\n\n ungroup: 'shape_ungroup.png',\n unlink_use: 'unlink_use.png',\n width: 'width.png',\n height: 'height.png',\n c_radius: 'c_radius.png',\n angle: 'angle.png',\n blur: 'blur.png',\n fontsize: 'fontsize.png',\n align: 'align.png',\n\n align_left: 'align-left.png',\n align_center: 'align-center.png',\n align_right: 'align-right.png',\n align_top: 'align-top.png',\n align_middle: 'align-middle.png',\n align_bottom: 'align-bottom.png',\n\n linecap_butt: 'linecap_butt.png',\n linecap_square: 'linecap_square.png',\n linecap_round: 'linecap_round.png',\n linejoin_miter: 'linejoin_miter.png',\n linejoin_bevel: 'linejoin_bevel.png',\n linejoin_round: 'linejoin_round.png',\n eye: 'eye.png',\n no_color: 'no_color.png',\n\n ok: 'save.png',\n cancel: 'cancel.png',\n warning: 'warning.png',\n\n node_delete: 'node_delete.png',\n node_clone: 'node_clone.png',\n\n globe_link: 'globe_link.png',\n config: 'config.png'\n },\n placement: {\n '#logo': 'logo',\n\n '#tool_clear div,#layer_new': 'new_image',\n '#tool_save div': 'save',\n '#tool_export div': 'export',\n '#tool_open div': 'open',\n '#tool_import div': 'import',\n '#tool_source': 'source',\n '#tool_docprops > div': 'docprops',\n '#tool_editor_prefs > div': 'config',\n '#tool_editor_homepage > div': 'globe_link',\n '#tool_wireframe': 'wireframe',\n\n '#tool_undo': 'undo',\n '#tool_redo': 'redo',\n\n '#tool_select': 'select',\n '#tool_fhpath': 'pencil',\n '#tool_line': 'pen',\n '#tool_rect,#tools_rect_show': 'rect',\n '#tool_square': 'square',\n '#tool_fhrect': 'fh_rect',\n '#tool_ellipse,#tools_ellipse_show': 'ellipse',\n '#tool_circle': 'circle',\n '#tool_fhellipse': 'fh_ellipse',\n '#tool_path': 'path',\n '#tool_text,#layer_rename': 'text',\n '#tool_image': 'image',\n '#tool_zoom': 'zoom',\n\n '#tool_clone,#tool_clone_multi': 'clone',\n '#tool_node_clone': 'node_clone',\n '#layer_delete,#tool_delete,#tool_delete_multi': 'delete',\n '#tool_node_delete': 'node_delete',\n '#tool_add_subpath': 'add_subpath',\n '#tool_openclose_path': 'open_path',\n '#tool_move_top': 'move_top',\n '#tool_move_bottom': 'move_bottom',\n '#tool_topath': 'to_path',\n '#tool_node_link': 'link_controls',\n '#tool_reorient': 'reorient',\n '#tool_group_elements': 'group_elements',\n '#tool_ungroup': 'ungroup',\n '#tool_unlink_use': 'unlink_use',\n\n '#tool_alignleft, #tool_posleft': 'align_left',\n '#tool_aligncenter, #tool_poscenter': 'align_center',\n '#tool_alignright, #tool_posright': 'align_right',\n '#tool_aligntop, #tool_postop': 'align_top',\n '#tool_alignmiddle, #tool_posmiddle': 'align_middle',\n '#tool_alignbottom, #tool_posbottom': 'align_bottom',\n '#cur_position': 'align',\n\n '#linecap_butt,#cur_linecap': 'linecap_butt',\n '#linecap_round': 'linecap_round',\n '#linecap_square': 'linecap_square',\n\n '#linejoin_miter,#cur_linejoin': 'linejoin_miter',\n '#linejoin_round': 'linejoin_round',\n '#linejoin_bevel': 'linejoin_bevel',\n\n '#url_notice': 'warning',\n\n '#layer_up': 'go_up',\n '#layer_down': 'go_down',\n '#layer_moreopts': 'context_menu',\n '#layerlist td.layervis': 'eye',\n\n '#tool_source_save,#tool_docprops_save,#tool_prefs_save': 'ok',\n '#tool_source_cancel,#tool_docprops_cancel,#tool_prefs_cancel': 'cancel',\n\n '#rwidthLabel, #iwidthLabel': 'width',\n '#rheightLabel, #iheightLabel': 'height',\n '#cornerRadiusLabel span': 'c_radius',\n '#angleLabel': 'angle',\n '#linkLabel,#tool_make_link,#tool_make_link_multi': 'globe_link',\n '#zoomLabel': 'zoom',\n '#tool_fill label': 'fill',\n '#tool_stroke .icon_label': 'stroke',\n '#group_opacityLabel': 'opacity',\n '#blurLabel': 'blur',\n '#font_sizeLabel': 'fontsize',\n\n '.flyout_arrow_horiz': 'arrow_right',\n '.dropdown button, #main_button .dropdown': 'arrow_down',\n '#palette .palette_item:first, #fill_bg, #stroke_bg': 'no_color'\n },\n resize: {\n '#logo .svg_icon': 28,\n '.flyout_arrow_horiz .svg_icon': 5,\n '.layer_button .svg_icon, #layerlist td.layervis .svg_icon': 14,\n '.dropdown button .svg_icon': 7,\n '#main_button .dropdown .svg_icon': 9,\n '.palette_item:first .svg_icon': 15,\n '#fill_bg .svg_icon, #stroke_bg .svg_icon': 16,\n '.toolbar_button button .svg_icon': 16,\n '.stroke_tool div div .svg_icon': 20,\n '#tools_bottom label .svg_icon': 18\n },\n async callback (icons) {\n $('.toolbar_button button > svg, .toolbar_button button > img').each(function () {\n $(this).parent().prepend(this);\n });\n\n const tleft = $('#tools_left');\n\n let minHeight;\n if (tleft.length) {\n minHeight = tleft.offset().top + tleft.outerHeight();\n }\n\n const size = editor.pref('iconsize');\n editor.setIconSize(size || ($(window).height() < minHeight ? 's' : 'm'));\n\n // Look for any missing flyout icons from plugins\n $('.tools_flyout').each(function () {\n const shower = $('#' + this.id + '_show');\n const sel = shower.attr('data-curopt');\n // Check if there's an icon here\n if (!shower.children('svg, img').length) {\n const clone = $(sel).children().clone();\n if (clone.length) {\n clone[0].removeAttribute('style'); // Needed for Opera\n shower.append(clone);\n }\n }\n });\n $('#svg_container')[0].style.visibility = 'visible';\n await editor.runCallbacks();\n }\n });\n }\n /**\n * @name module:SVGEditor.canvas\n * @type {module:svgcanvas.SvgCanvas}\n */\n editor.canvas = svgCanvas = new SvgCanvas(\n document.getElementById('svgcanvas'),\n curConfig\n );\n const palette = [\n // Todo: Make into configuration item?\n '#000000', '#3f3f3f', '#7f7f7f', '#bfbfbf', '#ffffff',\n '#ff0000', '#ff7f00', '#ffff00', '#7fff00',\n '#00ff00', '#00ff7f', '#00ffff', '#007fff',\n '#0000ff', '#7f00ff', '#ff00ff', '#ff007f',\n '#7f0000', '#7f3f00', '#7f7f00', '#3f7f00',\n '#007f00', '#007f3f', '#007f7f', '#003f7f',\n '#00007f', '#3f007f', '#7f007f', '#7f003f',\n '#ffaaaa', '#ffd4aa', '#ffffaa', '#d4ffaa',\n '#aaffaa', '#aaffd4', '#aaffff', '#aad4ff',\n '#aaaaff', '#d4aaff', '#ffaaff', '#ffaad4'\n ],\n modKey = (isMac() ? 'meta+' : 'ctrl+'), // ⌘\n path = svgCanvas.pathActions,\n {undoMgr} = svgCanvas,\n workarea = $('#workarea'),\n canvMenu = $('#cmenu_canvas'),\n // layerMenu = $('#cmenu_layers'), // Unused\n paintBox = {fill: null, stroke: null};\n\n let resizeTimer, curScrollPos;\n let exportWindow = null,\n defaultImageURL = curConfig.imgPath + 'logo.png',\n zoomInIcon = 'crosshair',\n zoomOutIcon = 'crosshair',\n uiContext = 'toolbars';\n\n // For external openers\n (function () {\n // let the opener know SVG Edit is ready (now that config is set up)\n const w = window.opener || window.parent;\n if (w) {\n try {\n /**\n * Triggered on a containing `document` (of `window.opener`\n * or `window.parent`) when the editor is loaded.\n * @event module:SVGEditor#event:svgEditorReadyEvent\n * @type {Event}\n * @property {true} bubbles\n * @property {true} cancelable\n */\n /**\n * @name module:SVGEditor.svgEditorReadyEvent\n * @type {module:SVGEditor#event:svgEditorReadyEvent}\n */\n const svgEditorReadyEvent = new w.CustomEvent('svgEditorReady', {\n bubbles: true,\n cancelable: true\n });\n w.document.documentElement.dispatchEvent(svgEditorReadyEvent);\n } catch (e) {}\n }\n }());\n\n /**\n *\n * @returns {void}\n */\n const setSelectMode = function () {\n const curr = $('.tool_button_current');\n if (curr.length && curr[0].id !== 'tool_select') {\n curr.removeClass('tool_button_current').addClass('tool_button');\n $('#tool_select').addClass('tool_button_current').removeClass('tool_button');\n $('#styleoverrides').text(`\n #svgcanvas svg * {\n cursor: move;\n pointer-events: all;\n }\n #svgcanvas svg {\n cursor: default;\n }\n `);\n }\n svgCanvas.setMode('select');\n workarea.css('cursor', 'auto');\n };\n\n // used to make the flyouts stay on the screen longer the very first time\n // const flyoutspeed = 1250; // Currently unused\n // let textBeingEntered = false; // Currently unused\n const origTitle = $('title:first').text();\n // Make [1,2,5] array\n const rIntervals = [];\n for (let i = 0.1; i < 1e5; i *= 10) {\n rIntervals.push(i);\n rIntervals.push(2 * i);\n rIntervals.push(5 * i);\n }\n\n /**\n * This function highlights the layer passed in (by fading out the other layers).\n * If no layer is passed in, this function restores the other layers.\n * @param {string} [layerNameToHighlight]\n * @returns {void}\n */\n const toggleHighlightLayer = function (layerNameToHighlight) {\n let i;\n const curNames = [], numLayers = svgCanvas.getCurrentDrawing().getNumLayers();\n for (i = 0; i < numLayers; i++) {\n curNames[i] = svgCanvas.getCurrentDrawing().getLayerName(i);\n }\n\n if (layerNameToHighlight) {\n curNames.forEach((curName) => {\n if (curName !== layerNameToHighlight) {\n svgCanvas.getCurrentDrawing().setLayerOpacity(curName, 0.5);\n }\n });\n } else {\n curNames.forEach((curName) => {\n svgCanvas.getCurrentDrawing().setLayerOpacity(curName, 1.0);\n });\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const populateLayers = function () {\n svgCanvas.clearSelection();\n const layerlist = $('#layerlist tbody').empty();\n const selLayerNames = $('#selLayerNames').empty();\n const drawing = svgCanvas.getCurrentDrawing();\n const currentLayerName = drawing.getCurrentLayerName();\n const icon = $.getSvgIcon('eye');\n let layer = svgCanvas.getCurrentDrawing().getNumLayers();\n // we get the layers in the reverse z-order (the layer rendered on top is listed first)\n while (layer--) {\n const name = drawing.getLayerName(layer);\n const layerTr = $('<tr class=\"layer\">').toggleClass('layersel', name === currentLayerName);\n const layerVis = $('<td class=\"layervis\">').toggleClass('layerinvis', !drawing.getLayerVisibility(name));\n const layerName = $('<td class=\"layername\">' + name + '</td>');\n layerlist.append(layerTr.append(layerVis, layerName));\n selLayerNames.append('<option value=\"' + name + '\">' + name + '</option>');\n }\n if (icon !== undefined) {\n const copy = icon.clone();\n $('td.layervis', layerlist).append(copy);\n $.resizeSvgIcons({'td.layervis .svg_icon': 14});\n }\n // handle selection of layer\n $('#layerlist td.layername')\n .mouseup(function (evt) {\n $('#layerlist tr.layer').removeClass('layersel');\n $(this.parentNode).addClass('layersel');\n svgCanvas.setCurrentLayer(this.textContent);\n evt.preventDefault();\n })\n .mouseover(function () {\n toggleHighlightLayer(this.textContent);\n })\n .mouseout(function () {\n toggleHighlightLayer();\n });\n $('#layerlist td.layervis').click(function () {\n const row = $(this.parentNode).prevAll().length;\n const name = $('#layerlist tr.layer:eq(' + row + ') td.layername').text();\n const vis = $(this).hasClass('layerinvis');\n svgCanvas.setLayerVisibility(name, vis);\n $(this).toggleClass('layerinvis');\n });\n\n // if there were too few rows, let's add a few to make it not so lonely\n let num = 5 - $('#layerlist tr.layer').size();\n while (num-- > 0) {\n // TODO: there must a better way to do this\n layerlist.append('<tr><td style=\"color:white\">_</td><td/></tr>');\n }\n };\n\n let editingsource = false;\n let origSource = '';\n\n /**\n * @param {Event} [e] Not used.\n * @param {boolean} forSaving\n * @returns {void}\n */\n const showSourceEditor = function (e, forSaving) {\n if (editingsource) { return; }\n\n editingsource = true;\n origSource = svgCanvas.getSvgString();\n $('#save_output_btns').toggle(Boolean(forSaving));\n $('#tool_source_back').toggle(!forSaving);\n $('#svg_source_textarea').val(origSource);\n $('#svg_source_editor').fadeIn();\n $('#svg_source_textarea').focus();\n };\n\n let selectedElement = null;\n let multiselected = false;\n\n /**\n * @param {boolean} editmode\n * @param {module:svgcanvas.SvgCanvas#event:selected} elems\n * @returns {void}\n */\n const togglePathEditMode = function (editmode, elems) {\n $('#path_node_panel').toggle(editmode);\n $('#tools_bottom_2,#tools_bottom_3').toggle(!editmode);\n if (editmode) {\n // Change select icon\n $('.tool_button_current').removeClass('tool_button_current').addClass('tool_button');\n $('#tool_select').addClass('tool_button_current').removeClass('tool_button');\n setIcon('#tool_select', 'select_node');\n multiselected = false;\n if (elems.length) {\n selectedElement = elems[0];\n }\n } else {\n setTimeout(() => {\n setIcon('#tool_select', 'select');\n }, 1000);\n }\n };\n\n /**\n * @type {module:svgcanvas.EventHandler}\n * @param {external:Window} wind\n * @param {module:svgcanvas.SvgCanvas#event:saved} svg The SVG source\n * @listens module:svgcanvas.SvgCanvas#event:saved\n * @returns {void}\n */\n const saveHandler = function (wind, svg) {\n editor.showSaveWarning = false;\n\n // by default, we add the XML prolog back, systems integrating SVG-edit (wikis, CMSs)\n // can just provide their own custom save handler and might not want the XML prolog\n svg = '<?xml version=\"1.0\"?>\\n' + svg;\n\n // IE9 doesn't allow standalone Data URLs\n // https://connect.microsoft.com/IE/feedback/details/542600/data-uri-images-fail-when-loaded-by-themselves\n if (isIE()) {\n showSourceEditor(0, true);\n return;\n }\n\n // Since saving SVGs by opening a new window was removed in Chrome use artificial link-click\n // https://stackoverflow.com/questions/45603201/window-is-not-allowed-to-navigate-top-frame-navigations-to-data-urls\n const a = document.createElement('a');\n a.href = 'data:image/svg+xml;base64,' + Utils.encode64(svg);\n a.download = 'icon.svg';\n a.style.display = 'none';\n document.body.append(a); // Need to append for Firefox\n\n a.click();\n\n // Alert will only appear the first time saved OR the\n // first time the bug is encountered\n let done = editor.pref('save_notice_done');\n\n if (done !== 'all') {\n let note = uiStrings.notification.saveFromBrowser.replace('%s', 'SVG');\n // Check if FF and has <defs/>\n if (isGecko()) {\n if (svg.includes('<defs')) {\n // warning about Mozilla bug #308590 when applicable (seems to be fixed now in Feb 2013)\n note += '\\n\\n' + uiStrings.notification.defsFailOnSave;\n editor.pref('save_notice_done', 'all');\n done = 'all';\n } else {\n editor.pref('save_notice_done', 'part');\n }\n } else {\n editor.pref('save_notice_done', 'all');\n }\n if (done !== 'part') {\n $.alert(note);\n }\n }\n };\n\n /**\n * @param {external:Window} win\n * @param {module:svgcanvas.SvgCanvas#event:exported} data\n * @listens module:svgcanvas.SvgCanvas#event:exported\n * @returns {void}\n */\n const exportHandler = function (win, data) {\n const {issues, exportWindowName} = data;\n\n exportWindow = window.open(Utils.blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one\n\n if (!exportWindow || exportWindow.closed) {\n /* await */ $.alert(uiStrings.notification.popupWindowBlocked);\n return;\n }\n\n exportWindow.location.href = data.bloburl || data.datauri;\n const done = editor.pref('export_notice_done');\n if (done !== 'all') {\n let note = uiStrings.notification.saveFromBrowser.replace('%s', data.type);\n\n // Check if there are issues\n if (issues.length) {\n const pre = '\\n \\u2022 ';\n note += ('\\n\\n' + uiStrings.notification.noteTheseIssues + pre + issues.join(pre));\n }\n\n // Note that this will also prevent the notice even though new issues may appear later.\n // May want to find a way to deal with that without annoying the user\n editor.pref('export_notice_done', 'all');\n exportWindow.alert(note);\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const operaRepaint = function () {\n // Repaints canvas in Opera. Needed for stroke-dasharray change as well as fill change\n if (!window.opera) {\n return;\n }\n $('<p/>').hide().appendTo('body').remove();\n };\n\n /**\n *\n * @param {Element} opt\n * @param {boolean} changeElem\n * @returns {void}\n */\n function setStrokeOpt (opt, changeElem) {\n const {id} = opt;\n const bits = id.split('_');\n const [pre, val] = bits;\n\n if (changeElem) {\n svgCanvas.setStrokeAttr('stroke-' + pre, val);\n }\n operaRepaint();\n setIcon('#cur_' + pre, id, 20);\n $(opt).addClass('current').siblings().removeClass('current');\n }\n\n /**\n * This is a common function used when a tool has been clicked (chosen).\n * It does several common things:\n * - Removes the `tool_button_current` class from whatever tool currently has it.\n * - Hides any flyouts.\n * - Adds the `tool_button_current` class to the button passed in.\n * @function module:SVGEditor.toolButtonClick\n * @param {string|Element} button The DOM element or string selector representing the toolbar button\n * @param {boolean} noHiding Whether not to hide any flyouts\n * @returns {boolean} Whether the button was disabled or not\n */\n const toolButtonClick = editor.toolButtonClick = function (button, noHiding) {\n if ($(button).hasClass('disabled')) { return false; }\n if ($(button).parent().hasClass('tools_flyout')) { return true; }\n const fadeFlyouts = 'normal';\n if (!noHiding) {\n $('.tools_flyout').fadeOut(fadeFlyouts);\n }\n $('#styleoverrides').text('');\n workarea.css('cursor', 'auto');\n $('.tool_button_current').removeClass('tool_button_current').addClass('tool_button');\n $(button).addClass('tool_button_current').removeClass('tool_button');\n return true;\n };\n\n /**\n * Unless the select toolbar button is disabled, sets the button\n * and sets the select mode and cursor styles.\n * @function module:SVGEditor.clickSelect\n * @returns {void}\n */\n const clickSelect = editor.clickSelect = function () {\n if (toolButtonClick('#tool_select')) {\n svgCanvas.setMode('select');\n $('#styleoverrides').text(`\n #svgcanvas svg * {\n cursor: move;\n pointer-events: all;\n }\n #svgcanvas svg {\n cursor: default;\n }\n `);\n }\n };\n\n /**\n * Set a selected image's URL.\n * @function module:SVGEditor.setImageURL\n * @param {string} url\n * @returns {void}\n */\n const setImageURL = editor.setImageURL = function (url) {\n if (!url) {\n url = defaultImageURL;\n }\n svgCanvas.setImageURL(url);\n $('#image_url').val(url);\n\n if (url.startsWith('data:')) {\n // data URI found\n $('#image_url').hide();\n $('#change_image_url').show();\n } else {\n // regular URL\n svgCanvas.embedImage(url, function (dataURI) {\n // Couldn't embed, so show warning\n $('#url_notice').toggle(!dataURI);\n defaultImageURL = url;\n });\n $('#image_url').show();\n $('#change_image_url').hide();\n }\n };\n\n /**\n *\n * @param {string} color\n * @param {string} url\n * @returns {void}\n */\n function setBackground (color, url) {\n // if (color == editor.pref('bkgd_color') && url == editor.pref('bkgd_url')) { return; }\n editor.pref('bkgd_color', color);\n editor.pref('bkgd_url', url, true);\n\n // This should be done in svgcanvas.js for the borderRect fill\n svgCanvas.setBackground(color, url);\n }\n\n /**\n * @param {PlainObject} [opts={}]\n * @param {boolean} [opts.cancelDeletes=false}]\n * @returns {Promise<void>} Resolves to `undefined`\n */\n async function promptImgURL ({cancelDeletes = false} = {}) {\n let curhref = svgCanvas.getHref(selectedElement);\n curhref = curhref.startsWith('data:') ? '' : curhref;\n const url = await $.prompt(uiStrings.notification.enterNewImgURL, curhref);\n if (url) {\n setImageURL(url);\n } else if (cancelDeletes) {\n svgCanvas.deleteSelectedElements();\n }\n }\n\n /**\n * @param {Element} elem\n * @returns {void}\n */\n const setInputWidth = function (elem) {\n const w = Math.min(Math.max(12 + elem.value.length * 6, 50), 300);\n $(elem).width(w);\n };\n\n /**\n *\n * @param {HTMLDivElement} [scanvas]\n * @param {Float} [zoom]\n * @returns {void}\n */\n function updateRulers (scanvas, zoom) {\n if (!zoom) { zoom = svgCanvas.getZoom(); }\n if (!scanvas) { scanvas = $('#svgcanvas'); }\n\n let d, i;\n const limit = 30000;\n const contentElem = svgCanvas.getContentElem();\n const units = getTypeMap();\n const unit = units[curConfig.baseUnit]; // 1 = 1px\n\n // draw x ruler then y ruler\n for (d = 0; d < 2; d++) {\n const isX = (d === 0);\n const dim = isX ? 'x' : 'y';\n const lentype = isX ? 'width' : 'height';\n const contentDim = Number(contentElem.getAttribute(dim));\n\n const $hcanvOrig = $('#ruler_' + dim + ' canvas:first');\n\n // Bit of a hack to fully clear the canvas in Safari & IE9\n const $hcanv = $hcanvOrig.clone();\n $hcanvOrig.replaceWith($hcanv);\n\n const hcanv = $hcanv[0];\n\n // Set the canvas size to the width of the container\n let rulerLen = scanvas[lentype]();\n const totalLen = rulerLen;\n hcanv.parentNode.style[lentype] = totalLen + 'px';\n let ctx = hcanv.getContext('2d');\n let ctxArr, num, ctxArrNum;\n\n ctx.fillStyle = 'rgb(200,0,0)';\n ctx.fillRect(0, 0, hcanv.width, hcanv.height);\n\n // Remove any existing canvasses\n $hcanv.siblings().remove();\n\n // Create multiple canvases when necessary (due to browser limits)\n if (rulerLen >= limit) {\n ctxArrNum = Number.parseInt(rulerLen / limit) + 1;\n ctxArr = [];\n ctxArr[0] = ctx;\n let copy;\n for (i = 1; i < ctxArrNum; i++) {\n hcanv[lentype] = limit;\n copy = hcanv.cloneNode(true);\n hcanv.parentNode.append(copy);\n ctxArr[i] = copy.getContext('2d');\n }\n\n copy[lentype] = rulerLen % limit;\n\n // set copy width to last\n rulerLen = limit;\n }\n\n hcanv[lentype] = rulerLen;\n\n const uMulti = unit * zoom;\n\n // Calculate the main number interval\n const rawM = 50 / uMulti;\n let multi = 1;\n for (i = 0; i < rIntervals.length; i++) {\n num = rIntervals[i];\n multi = num;\n if (rawM <= num) {\n break;\n }\n }\n\n const bigInt = multi * uMulti;\n\n ctx.font = '9px sans-serif';\n\n let rulerD = ((contentDim / uMulti) % multi) * uMulti;\n let labelPos = rulerD - bigInt;\n // draw big intervals\n let ctxNum = 0;\n while (rulerD < totalLen) {\n labelPos += bigInt;\n // const realD = rulerD - contentDim; // Currently unused\n\n const curD = Math.round(rulerD) + 0.5;\n if (isX) {\n ctx.moveTo(curD, 15);\n ctx.lineTo(curD, 0);\n } else {\n ctx.moveTo(15, curD);\n ctx.lineTo(0, curD);\n }\n\n num = (labelPos - contentDim) / uMulti;\n let label;\n if (multi >= 1) {\n label = Math.round(num);\n } else {\n const decs = String(multi).split('.')[1].length;\n label = num.toFixed(decs);\n }\n\n // Change 1000s to Ks\n if (label !== 0 && label !== 1000 && label % 1000 === 0) {\n label = (label / 1000) + 'K';\n }\n\n if (isX) {\n ctx.fillText(label, rulerD + 2, 8);\n } else {\n // draw label vertically\n const str = String(label).split('');\n for (i = 0; i < str.length; i++) {\n ctx.fillText(str[i], 1, (rulerD + 9) + i * 9);\n }\n }\n\n const part = bigInt / 10;\n // draw the small intervals\n for (i = 1; i < 10; i++) {\n let subD = Math.round(rulerD + part * i) + 0.5;\n if (ctxArr && subD > rulerLen) {\n ctxNum++;\n ctx.stroke();\n if (ctxNum >= ctxArrNum) {\n i = 10;\n rulerD = totalLen;\n continue;\n }\n ctx = ctxArr[ctxNum];\n rulerD -= limit;\n subD = Math.round(rulerD + part * i) + 0.5;\n }\n\n // odd lines are slighly longer\n const lineNum = (i % 2) ? 12 : 10;\n if (isX) {\n ctx.moveTo(subD, 15);\n ctx.lineTo(subD, lineNum);\n } else {\n ctx.moveTo(15, subD);\n ctx.lineTo(lineNum, subD);\n }\n }\n rulerD += bigInt;\n }\n ctx.strokeStyle = '#000';\n ctx.stroke();\n }\n }\n\n /**\n * @function module:SVGEditor.updateCanvas\n * @param {boolean} center\n * @param {module:math.XYObject} newCtr\n * @returns {void}\n */\n const updateCanvas = editor.updateCanvas = function (center, newCtr) {\n const zoom = svgCanvas.getZoom();\n const wArea = workarea;\n const cnvs = $('#svgcanvas');\n\n let w = workarea.width(), h = workarea.height();\n const wOrig = w, hOrig = h;\n const oldCtr = {\n x: wArea[0].scrollLeft + wOrig / 2,\n y: wArea[0].scrollTop + hOrig / 2\n };\n const multi = curConfig.canvas_expansion;\n w = Math.max(wOrig, svgCanvas.contentW * zoom * multi);\n h = Math.max(hOrig, svgCanvas.contentH * zoom * multi);\n\n if (w === wOrig && h === hOrig) {\n workarea.css('overflow', 'hidden');\n } else {\n workarea.css('overflow', 'scroll');\n }\n\n const oldCanY = cnvs.height() / 2;\n const oldCanX = cnvs.width() / 2;\n cnvs.width(w).height(h);\n const newCanY = h / 2;\n const newCanX = w / 2;\n const offset = svgCanvas.updateCanvas(w, h);\n\n const ratio = newCanX / oldCanX;\n\n const scrollX = w / 2 - wOrig / 2; // eslint-disable-line no-shadow\n const scrollY = h / 2 - hOrig / 2; // eslint-disable-line no-shadow\n\n if (!newCtr) {\n const oldDistX = oldCtr.x - oldCanX;\n const newX = newCanX + oldDistX * ratio;\n\n const oldDistY = oldCtr.y - oldCanY;\n const newY = newCanY + oldDistY * ratio;\n\n newCtr = {\n x: newX,\n y: newY\n };\n } else {\n newCtr.x += offset.x;\n newCtr.y += offset.y;\n }\n\n if (center) {\n // Go to top-left for larger documents\n if (svgCanvas.contentW > wArea.width()) {\n // Top-left\n workarea[0].scrollLeft = offset.x - 10;\n workarea[0].scrollTop = offset.y - 10;\n } else {\n // Center\n wArea[0].scrollLeft = scrollX;\n wArea[0].scrollTop = scrollY;\n }\n } else {\n wArea[0].scrollLeft = newCtr.x - wOrig / 2;\n wArea[0].scrollTop = newCtr.y - hOrig / 2;\n }\n if (curConfig.showRulers) {\n updateRulers(cnvs, zoom);\n workarea.scroll();\n }\n\n if (urldata.storagePrompt !== true && editor.storagePromptState === 'ignore') {\n $('#dialog_box').hide();\n }\n };\n\n /**\n * @fires module:svgcanvas.SvgCanvas#event:ext_toolButtonStateUpdate\n * @returns {void}\n */\n const updateToolButtonState = function () {\n const bNoFill = (svgCanvas.getColor('fill') === 'none');\n const bNoStroke = (svgCanvas.getColor('stroke') === 'none');\n const buttonsNeedingStroke = ['#tool_fhpath', '#tool_line'];\n const buttonsNeedingFillAndStroke = [\n '#tools_rect .tool_button', '#tools_ellipse .tool_button',\n '#tool_text', '#tool_path'\n ];\n\n if (bNoStroke) {\n buttonsNeedingStroke.forEach((btn) => {\n if ($(btn).hasClass('tool_button_current')) {\n clickSelect();\n }\n $(btn).addClass('disabled');\n });\n } else {\n buttonsNeedingStroke.forEach((btn) => {\n $(btn).removeClass('disabled');\n });\n }\n\n if (bNoStroke && bNoFill) {\n buttonsNeedingFillAndStroke.forEach((btn) => {\n if ($(btn).hasClass('tool_button_current')) {\n clickSelect();\n }\n $(btn).addClass('disabled');\n });\n } else {\n buttonsNeedingFillAndStroke.forEach((btn) => {\n $(btn).removeClass('disabled');\n });\n }\n\n svgCanvas.runExtensions(\n 'toolButtonStateUpdate',\n /** @type {module:svgcanvas.SvgCanvas#event:ext_toolButtonStateUpdate} */ {\n nofill: bNoFill,\n nostroke: bNoStroke\n }\n );\n\n // Disable flyouts if all inside are disabled\n $('.tools_flyout').each(function () {\n const shower = $('#' + this.id + '_show');\n let hasEnabled = false;\n $(this).children().each(function () {\n if (!$(this).hasClass('disabled')) {\n hasEnabled = true;\n }\n });\n shower.toggleClass('disabled', !hasEnabled);\n });\n\n operaRepaint();\n };\n\n /**\n * Updates the toolbar (colors, opacity, etc) based on the selected element.\n * This function also updates the opacity and id elements that are in the\n * context panel.\n * @returns {void}\n */\n const updateToolbar = function () {\n let i, len;\n if (!Utils.isNullish(selectedElement)) {\n switch (selectedElement.tagName) {\n case 'use':\n case 'image':\n case 'foreignObject':\n break;\n case 'g':\n case 'a': {\n // Look for common styles\n const childs = selectedElement.getElementsByTagName('*');\n let gWidth = null;\n for (i = 0, len = childs.length; i < len; i++) {\n const swidth = childs[i].getAttribute('stroke-width');\n\n if (i === 0) {\n gWidth = swidth;\n } else if (gWidth !== swidth) {\n gWidth = null;\n }\n }\n\n $('#stroke_width').val(gWidth === null ? '' : gWidth);\n\n paintBox.fill.update(true);\n paintBox.stroke.update(true);\n\n break;\n } default: {\n paintBox.fill.update(true);\n paintBox.stroke.update(true);\n\n $('#stroke_width').val(selectedElement.getAttribute('stroke-width') || 1);\n $('#stroke_style').val(selectedElement.getAttribute('stroke-dasharray') || 'none');\n\n let attr = selectedElement.getAttribute('stroke-linejoin') || 'miter';\n\n if ($('#linejoin_' + attr).length) {\n setStrokeOpt($('#linejoin_' + attr)[0]);\n }\n\n attr = selectedElement.getAttribute('stroke-linecap') || 'butt';\n\n if ($('#linecap_' + attr).length) {\n setStrokeOpt($('#linecap_' + attr)[0]);\n }\n }\n }\n }\n\n // All elements including image and group have opacity\n if (!Utils.isNullish(selectedElement)) {\n const opacPerc = (selectedElement.getAttribute('opacity') || 1.0) * 100;\n $('#group_opacity').val(opacPerc);\n $('#opac_slider').slider('option', 'value', opacPerc);\n $('#elem_id').val(selectedElement.id);\n $('#elem_class').val(selectedElement.getAttribute('class'));\n }\n\n updateToolButtonState();\n };\n\n /**\n * Updates the context panel tools based on the selected element.\n * @returns {void}\n */\n const updateContextPanel = function () {\n let elem = selectedElement;\n // If element has just been deleted, consider it null\n if (!Utils.isNullish(elem) && !elem.parentNode) { elem = null; }\n const currentLayerName = svgCanvas.getCurrentDrawing().getCurrentLayerName();\n const currentMode = svgCanvas.getMode();\n const unit = curConfig.baseUnit !== 'px' ? curConfig.baseUnit : null;\n\n const isNode = currentMode === 'pathedit'; // elem ? (elem.id && elem.id.startsWith('pathpointgrip')) : false;\n const menuItems = $('#cmenu_canvas li');\n $('#selected_panel, #multiselected_panel, #g_panel, #rect_panel, #circle_panel,' +\n '#ellipse_panel, #line_panel, #text_panel, #image_panel, #container_panel,' +\n ' #use_panel, #a_panel').hide();\n if (!Utils.isNullish(elem)) {\n const elname = elem.nodeName;\n // If this is a link with no transform and one child, pretend\n // its child is selected\n // if (elname === 'a') { // && !$(elem).attr('transform')) {\n // elem = elem.firstChild;\n // }\n\n const angle = svgCanvas.getRotationAngle(elem);\n $('#angle').val(angle);\n\n const blurval = svgCanvas.getBlur(elem);\n $('#blur').val(blurval);\n $('#blur_slider').slider('option', 'value', blurval);\n\n if (svgCanvas.addedNew) {\n if (elname === 'image' && svgCanvas.getMode() === 'image') {\n // Prompt for URL if not a data URL\n if (!svgCanvas.getHref(elem).startsWith('data:')) {\n /* await */ promptImgURL({cancelDeletes: true});\n }\n }\n /* else if (elname == 'text') {\n // TODO: Do something here for new text\n } */\n }\n\n if (!isNode && currentMode !== 'pathedit') {\n $('#selected_panel').show();\n // Elements in this array already have coord fields\n if (['line', 'circle', 'ellipse'].includes(elname)) {\n $('#xy_panel').hide();\n } else {\n let x, y;\n\n // Get BBox vals for g, polyline and path\n if (['g', 'polyline', 'path'].includes(elname)) {\n const bb = svgCanvas.getStrokedBBox([elem]);\n if (bb) {\n ({x, y} = bb);\n }\n } else {\n x = elem.getAttribute('x');\n y = elem.getAttribute('y');\n }\n\n if (unit) {\n x = convertUnit(x);\n y = convertUnit(y);\n }\n\n $('#selected_x').val(x || 0);\n $('#selected_y').val(y || 0);\n $('#xy_panel').show();\n }\n\n // Elements in this array cannot be converted to a path\n const noPath = !['image', 'text', 'path', 'g', 'use'].includes(elname);\n $('#tool_topath').toggle(noPath);\n $('#tool_reorient').toggle(elname === 'path');\n $('#tool_reorient').toggleClass('disabled', angle === 0);\n } else {\n const point = path.getNodePoint();\n $('#tool_add_subpath').removeClass('push_button_pressed').addClass('tool_button');\n $('#tool_node_delete').toggleClass('disabled', !path.canDeleteNodes);\n\n // Show open/close button based on selected point\n setIcon('#tool_openclose_path', path.closed_subpath ? 'open_path' : 'close_path');\n\n if (point) {\n const segType = $('#seg_type');\n if (unit) {\n point.x = convertUnit(point.x);\n point.y = convertUnit(point.y);\n }\n $('#path_node_x').val(point.x);\n $('#path_node_y').val(point.y);\n if (point.type) {\n segType.val(point.type).removeAttr('disabled');\n } else {\n segType.val(4).attr('disabled', 'disabled');\n }\n }\n return;\n }\n\n // update contextual tools here\n const panels = {\n g: [],\n a: [],\n rect: ['rx', 'width', 'height'],\n image: ['width', 'height'],\n circle: ['cx', 'cy', 'r'],\n ellipse: ['cx', 'cy', 'rx', 'ry'],\n line: ['x1', 'y1', 'x2', 'y2'],\n text: [],\n use: []\n };\n\n const {tagName} = elem;\n\n // if ($(elem).data('gsvg')) {\n // $('#g_panel').show();\n // }\n\n let linkHref = null;\n if (tagName === 'a') {\n linkHref = svgCanvas.getHref(elem);\n $('#g_panel').show();\n }\n\n if (elem.parentNode.tagName === 'a') {\n if (!$(elem).siblings().length) {\n $('#a_panel').show();\n linkHref = svgCanvas.getHref(elem.parentNode);\n }\n }\n\n // Hide/show the make_link buttons\n $('#tool_make_link, #tool_make_link').toggle(!linkHref);\n\n if (linkHref) {\n $('#link_url').val(linkHref);\n }\n\n if (panels[tagName]) {\n const curPanel = panels[tagName];\n\n $('#' + tagName + '_panel').show();\n\n $.each(curPanel, function (i, item) {\n let attrVal = elem.getAttribute(item);\n if (curConfig.baseUnit !== 'px' && elem[item]) {\n const bv = elem[item].baseVal.value;\n attrVal = convertUnit(bv);\n }\n $('#' + tagName + '_' + item).val(attrVal || 0);\n });\n\n if (tagName === 'text') {\n $('#text_panel').css('display', 'inline');\n $('#tool_font_size').css('display', 'inline');\n if (svgCanvas.getItalic()) {\n $('#tool_italic').addClass('push_button_pressed').removeClass('tool_button');\n } else {\n $('#tool_italic').removeClass('push_button_pressed').addClass('tool_button');\n }\n if (svgCanvas.getBold()) {\n $('#tool_bold').addClass('push_button_pressed').removeClass('tool_button');\n } else {\n $('#tool_bold').removeClass('push_button_pressed').addClass('tool_button');\n }\n $('#font_family').val(elem.getAttribute('font-family'));\n $('#font_size').val(elem.getAttribute('font-size'));\n $('#text').val(elem.textContent);\n if (svgCanvas.addedNew) {\n // Timeout needed for IE9\n setTimeout(function () {\n $('#text').focus().select();\n }, 100);\n }\n // text\n } else if (tagName === 'image' && svgCanvas.getMode() === 'image') {\n setImageURL(svgCanvas.getHref(elem));\n // image\n } else if (tagName === 'g' || tagName === 'use') {\n $('#container_panel').show();\n const title = svgCanvas.getTitle();\n const label = $('#g_title')[0];\n label.value = title;\n setInputWidth(label);\n $('#g_title').prop('disabled', tagName === 'use');\n }\n }\n menuItems[(tagName === 'g' ? 'en' : 'dis') + 'ableContextMenuItems']('#ungroup');\n menuItems[((tagName === 'g' || !multiselected) ? 'dis' : 'en') + 'ableContextMenuItems']('#group');\n // if (!Utils.isNullish(elem))\n } else if (multiselected) {\n $('#multiselected_panel').show();\n menuItems\n .enableContextMenuItems('#group')\n .disableContextMenuItems('#ungroup');\n } else {\n menuItems.disableContextMenuItems('#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back');\n }\n\n // update history buttons\n $('#tool_undo').toggleClass('disabled', undoMgr.getUndoStackSize() === 0);\n $('#tool_redo').toggleClass('disabled', undoMgr.getRedoStackSize() === 0);\n\n svgCanvas.addedNew = false;\n\n if ((elem && !isNode) || multiselected) {\n // update the selected elements' layer\n $('#selLayerNames').removeAttr('disabled').val(currentLayerName);\n\n // Enable regular menu options\n canvMenu.enableContextMenuItems(\n '#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back'\n );\n } else {\n $('#selLayerNames').attr('disabled', 'disabled');\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const updateWireFrame = function () {\n // Test support\n if (supportsNonSS) { return; }\n\n const rule = `\n #workarea.wireframe #svgcontent * {\n stroke-width: ${1 / svgCanvas.getZoom()}px;\n }\n `;\n $('#wireframe_rules').text(workarea.hasClass('wireframe') ? rule : '');\n };\n\n let curContext = '';\n\n /**\n * @param {string} [title=svgCanvas.getDocumentTitle()]\n * @returns {void}\n */\n const updateTitle = function (title) {\n title = title || svgCanvas.getDocumentTitle();\n const newTitle = origTitle + (title ? ': ' + title : '');\n\n // Remove title update with current context info, isn't really necessary\n // if (curContext) {\n // new_title = new_title + curContext;\n // }\n $('title:first').text(newTitle);\n };\n\n // called when we've selected a different element\n /**\n *\n * @param {external:Window} win\n * @param {module:svgcanvas.SvgCanvas#event:selected} elems Array of elements that were selected\n * @listens module:svgcanvas.SvgCanvas#event:selected\n * @fires module:svgcanvas.SvgCanvas#event:ext_selectedChanged\n * @returns {void}\n */\n const selectedChanged = function (win, elems) {\n const mode = svgCanvas.getMode();\n if (mode === 'select') {\n setSelectMode();\n }\n const isNode = mode === 'pathedit';\n // if elems[1] is present, then we have more than one element\n selectedElement = (elems.length === 1 || Utils.isNullish(elems[1]) ? elems[0] : null);\n multiselected = (elems.length >= 2 && !Utils.isNullish(elems[1]));\n if (!Utils.isNullish(selectedElement)) {\n // unless we're already in always set the mode of the editor to select because\n // upon creation of a text element the editor is switched into\n // select mode and this event fires - we need our UI to be in sync\n\n if (!isNode) {\n updateToolbar();\n }\n } // if (!Utils.isNullish(elem))\n\n // Deal with pathedit mode\n togglePathEditMode(isNode, elems);\n updateContextPanel();\n svgCanvas.runExtensions('selectedChanged', /** @type {module:svgcanvas.SvgCanvas#event:ext_selectedChanged} */ {\n elems,\n selectedElement,\n multiselected\n });\n };\n\n // Call when part of element is in process of changing, generally\n // on mousemove actions like rotate, move, etc.\n /**\n * @param {external:Window} win\n * @param {module:svgcanvas.SvgCanvas#event:transition} elems\n * @listens module:svgcanvas.SvgCanvas#event:transition\n * @fires module:svgcanvas.SvgCanvas#event:ext_elementTransition\n * @returns {void}\n */\n const elementTransition = function (win, elems) {\n const mode = svgCanvas.getMode();\n const elem = elems[0];\n\n if (!elem) {\n return;\n }\n\n multiselected = (elems.length >= 2 && !Utils.isNullish(elems[1]));\n // Only updating fields for single elements for now\n if (!multiselected) {\n switch (mode) {\n case 'rotate': {\n const ang = svgCanvas.getRotationAngle(elem);\n $('#angle').val(ang);\n $('#tool_reorient').toggleClass('disabled', ang === 0);\n break;\n\n // TODO: Update values that change on move/resize, etc\n // } case 'select': {\n // } case 'resize': {\n // break;\n // }\n }\n }\n }\n svgCanvas.runExtensions('elementTransition', /** @type {module:svgcanvas.SvgCanvas#event:ext_elementTransition} */ {\n elems\n });\n };\n\n /**\n * Test whether an element is a layer or not.\n * @param {SVGGElement} elem - The SVGGElement to test.\n * @returns {boolean} True if the element is a layer\n */\n function isLayer (elem) {\n return elem && elem.tagName === 'g' && Layer.CLASS_REGEX.test(elem.getAttribute('class'));\n }\n\n // called when any element has changed\n /**\n * @param {external:Window} win\n * @param {module:svgcanvas.SvgCanvas#event:changed} elems\n * @listens module:svgcanvas.SvgCanvas#event:changed\n * @fires module:svgcanvas.SvgCanvas#event:ext_elementChanged\n * @returns {void}\n */\n const elementChanged = function (win, elems) {\n const mode = svgCanvas.getMode();\n if (mode === 'select') {\n setSelectMode();\n }\n\n elems.forEach((elem) => {\n const isSvgElem = (elem && elem.tagName === 'svg');\n if (isSvgElem || isLayer(elem)) {\n populateLayers();\n // if the element changed was the svg, then it could be a resolution change\n if (isSvgElem) {\n updateCanvas();\n }\n // Update selectedElement if element is no longer part of the image.\n // This occurs for the text elements in Firefox\n } else if (elem && selectedElement && Utils.isNullish(selectedElement.parentNode)) {\n // || elem && elem.tagName == \"path\" && !multiselected) { // This was added in r1430, but not sure why\n selectedElement = elem;\n }\n });\n\n editor.showSaveWarning = true;\n\n // we update the contextual panel with potentially new\n // positional/sizing information (we DON'T want to update the\n // toolbar here as that creates an infinite loop)\n // also this updates the history buttons\n\n // we tell it to skip focusing the text control if the\n // text element was previously in focus\n updateContextPanel();\n\n // In the event a gradient was flipped:\n if (selectedElement && mode === 'select') {\n paintBox.fill.update();\n paintBox.stroke.update();\n }\n\n svgCanvas.runExtensions('elementChanged', /** @type {module:svgcanvas.SvgCanvas#event:ext_elementChanged} */ {\n elems\n });\n };\n\n /**\n * @returns {void}\n */\n const zoomDone = function () {\n updateWireFrame();\n // updateCanvas(); // necessary?\n };\n\n /**\n * @typedef {PlainObject} module:SVGEditor.BBoxObjectWithFactor (like `DOMRect`)\n * @property {Float} x\n * @property {Float} y\n * @property {Float} width\n * @property {Float} height\n * @property {Float} [factor] Needed if width or height are 0\n * @property {Float} [zoom]\n * @see module:svgcanvas.SvgCanvas#event:zoomed\n */\n\n /**\n * @function module:svgcanvas.SvgCanvas#zoomChanged\n * @param {external:Window} win\n * @param {module:svgcanvas.SvgCanvas#event:zoomed} bbox\n * @param {boolean} autoCenter\n * @listens module:svgcanvas.SvgCanvas#event:zoomed\n * @returns {void}\n */\n const zoomChanged = svgCanvas.zoomChanged = function (win, bbox, autoCenter) {\n const scrbar = 15,\n // res = svgCanvas.getResolution(), // Currently unused\n wArea = workarea;\n // const canvasPos = $('#svgcanvas').position(); // Currently unused\n const zInfo = svgCanvas.setBBoxZoom(bbox, wArea.width() - scrbar, wArea.height() - scrbar);\n if (!zInfo) { return; }\n const zoomlevel = zInfo.zoom,\n bb = zInfo.bbox;\n\n if (zoomlevel < 0.001) {\n changeZoom({value: 0.1});\n return;\n }\n\n $('#zoom').val((zoomlevel * 100).toFixed(1));\n\n if (autoCenter) {\n updateCanvas();\n } else {\n updateCanvas(false, {x: bb.x * zoomlevel + (bb.width * zoomlevel) / 2, y: bb.y * zoomlevel + (bb.height * zoomlevel) / 2});\n }\n\n if (svgCanvas.getMode() === 'zoom' && bb.width) {\n // Go to select if a zoom box was drawn\n setSelectMode();\n }\n\n zoomDone();\n };\n\n /**\n * @type {module:jQuerySpinButton.ValueCallback}\n */\n const changeZoom = function (ctl) {\n const zoomlevel = ctl.value / 100;\n if (zoomlevel < 0.001) {\n ctl.value = 0.1;\n return;\n }\n const zoom = svgCanvas.getZoom();\n const wArea = workarea;\n\n zoomChanged(window, {\n width: 0,\n height: 0,\n // center pt of scroll position\n x: (wArea[0].scrollLeft + wArea.width() / 2) / zoom,\n y: (wArea[0].scrollTop + wArea.height() / 2) / zoom,\n zoom: zoomlevel\n }, true);\n };\n\n $('#cur_context_panel').delegate('a', 'click', function () {\n const link = $(this);\n if (link.attr('data-root')) {\n svgCanvas.leaveContext();\n } else {\n svgCanvas.setContext(link.text());\n }\n svgCanvas.clearSelection();\n return false;\n });\n\n /**\n * @param {external:Window} win\n * @param {module:svgcanvas.SvgCanvas#event:contextset} context\n * @listens module:svgcanvas.SvgCanvas#event:contextset\n * @returns {void}\n */\n const contextChanged = function (win, context) {\n let linkStr = '';\n if (context) {\n let str = '';\n linkStr = '<a href=\"#\" data-root=\"y\">' + svgCanvas.getCurrentDrawing().getCurrentLayerName() + '</a>';\n\n $(context).parentsUntil('#svgcontent > g').andSelf().each(function () {\n if (this.id) {\n str += ' > ' + this.id;\n if (this !== context) {\n linkStr += ' > <a href=\"#\">' + this.id + '</a>';\n } else {\n linkStr += ' > ' + this.id;\n }\n }\n });\n\n curContext = str;\n } else {\n curContext = null;\n }\n $('#cur_context_panel').toggle(Boolean(context)).html(linkStr);\n\n updateTitle();\n };\n\n /**\n * Makes sure the current selected paint is available to work with.\n * @returns {void}\n */\n const prepPaints = function () {\n paintBox.fill.prep();\n paintBox.stroke.prep();\n };\n\n const flyoutFuncs = {};\n\n /**\n *\n * @returns {void}\n */\n const setFlyoutTitles = function () {\n $('.tools_flyout').each(function () {\n const shower = $('#' + this.id + '_show');\n if (shower.data('isLibrary')) {\n return;\n }\n\n const tooltips = $(this).children().map(function () {\n return this.title;\n }).get();\n shower[0].title = tooltips.join(' / ');\n });\n };\n\n const allHolders = {};\n /**\n * @param {PlainObject<string, module:SVGEditor.ToolButton>} holders Key is a selector\n * @returns {void}\n */\n const setupFlyouts = function (holders) {\n $.each(holders, function (holdSel, btnOpts) {\n if (!allHolders[holdSel]) {\n allHolders[holdSel] = [];\n }\n allHolders[holdSel].push(...btnOpts);\n\n const buttons = $(holdSel).children().not('.tool_button_evt_handled');\n const showSel = holdSel + '_show';\n const shower = $(showSel);\n let def = false;\n buttons.addClass('tool_button tool_button_evt_handled')\n .unbind('click mousedown mouseup') // may not be necessary\n .each(function () {\n // Get this button's options\n const idSel = '#' + this.getAttribute('id');\n const [i, opts] = Object.entries(btnOpts).find(([_, {sel}]) => {\n return sel === idSel;\n });\n\n // Remember the function that goes with this ID\n flyoutFuncs[opts.sel] = opts.fn;\n\n if (opts.isDefault) { def = i; }\n\n /**\n * Clicking the icon in flyout should set this set's icon.\n * @param {Event} ev\n * @returns {boolean}\n */\n const flyoutAction = function (ev) {\n let options = opts;\n // Find the currently selected tool if comes from keystroke\n if (ev.type === 'keydown') {\n const flyoutIsSelected = $(options.parent + '_show').hasClass('tool_button_current');\n const currentOperation = $(options.parent + '_show').attr('data-curopt');\n Object.entries(holders[opts.parent]).some(([j, tool]) => {\n if (tool.sel !== currentOperation) {\n return false;\n }\n if (!ev.shiftKey || !flyoutIsSelected) {\n options = tool;\n } else {\n // If flyout is selected, allow shift key to iterate through subitems\n j = Number.parseInt(j);\n // Use `allHolders` to include both extension `includeWith` and toolbarButtons\n options = allHolders[opts.parent][j + 1] ||\n holders[opts.parent][0];\n }\n return true;\n });\n }\n if ($(this).hasClass('disabled')) { return false; }\n if (toolButtonClick(showSel)) {\n options.fn();\n }\n let icon;\n if (options.icon) {\n icon = $.getSvgIcon(options.icon, true);\n } else {\n icon = $(options.sel).children().eq(0).clone();\n }\n\n icon[0].setAttribute('width', shower.width());\n icon[0].setAttribute('height', shower.height());\n shower.children(':not(.flyout_arrow_horiz)').remove();\n shower.append(icon).attr('data-curopt', options.sel); // This sets the current mode\n return true;\n };\n\n $(this).mouseup(flyoutAction);\n\n if (opts.key) {\n $(document).bind('keydown', opts.key[0] + ' shift+' + opts.key[0], flyoutAction);\n }\n return true;\n });\n\n if (def) {\n shower.attr('data-curopt', btnOpts[def].sel);\n } else if (!shower.attr('data-curopt')) {\n // Set first as default\n shower.attr('data-curopt', btnOpts[0].sel);\n }\n\n let timer;\n\n // Clicking the \"show\" icon should set the current mode\n shower.mousedown(function (evt) {\n if (shower.hasClass('disabled')) {\n return false;\n }\n const holder = $(holdSel);\n const pos = $(showSel).position();\n const l = pos.left + 34;\n const w = holder.width() * -1;\n const time = holder.data('shown_popop') ? 200 : 0;\n timer = setTimeout(function () {\n // Show corresponding menu\n if (!shower.data('isLibrary')) {\n holder.css('left', w).show().animate({\n left: l\n }, 150);\n } else {\n holder.css('left', l).show();\n }\n holder.data('shown_popop', true);\n }, time);\n evt.preventDefault();\n return true;\n }).mouseup(function (evt) {\n clearTimeout(timer);\n const opt = $(this).attr('data-curopt');\n // Is library and popped up, so do nothing\n if (shower.data('isLibrary') && $(showSel.replace('_show', '')).is(':visible')) {\n toolButtonClick(showSel, true);\n return;\n }\n if (toolButtonClick(showSel) && flyoutFuncs[opt]) {\n flyoutFuncs[opt]();\n }\n });\n // $('#tools_rect').mouseleave(function () { $('#tools_rect').fadeOut(); });\n });\n setFlyoutTitles();\n setFlyoutPositions();\n };\n\n /**\n * @param {string} id\n * @param {external:jQuery} child\n * @returns {external:jQuery}\n */\n const makeFlyoutHolder = function (id, child) {\n const div = $('<div>', {\n class: 'tools_flyout',\n id\n }).appendTo('#svg_editor').append(child);\n\n return div;\n };\n\n /**\n * @param {string} elemSel\n * @param {string} listSel\n * @param {external:jQuery.Function} callback\n * @param {PlainObject} opts\n * @param {boolean} opts.dropUp\n * @param {boolean} opts.seticon\n * @param {boolean} opts.multiclick\n * @todo Combine this with `addDropDown` or find other way to optimize.\n * @returns {void}\n */\n const addAltDropDown = function (elemSel, listSel, callback, opts) {\n const button = $(elemSel);\n const {dropUp} = opts;\n const list = $(listSel);\n if (dropUp) {\n $(elemSel).addClass('dropup');\n }\n list.find('li').bind('mouseup', function (...args) {\n if (opts.seticon) {\n setIcon('#cur_' + button[0].id, $(this).children());\n $(this).addClass('current').siblings().removeClass('current');\n }\n callback.apply(this, ...args);\n });\n\n let onButton = false;\n $(window).mouseup(function (evt) {\n if (!onButton) {\n button.removeClass('down');\n list.hide();\n list.css({top: 0, left: 0});\n }\n onButton = false;\n });\n\n // const height = list.height(); // Currently unused\n button.bind('mousedown', function () {\n const off = button.offset();\n if (dropUp) {\n off.top -= list.height();\n off.left += 8;\n } else {\n off.top += button.height();\n }\n list.offset(off);\n\n if (!button.hasClass('down')) {\n list.show();\n onButton = true;\n } else {\n // CSS position must be reset for Webkit\n list.hide();\n list.css({top: 0, left: 0});\n }\n button.toggleClass('down');\n }).hover(function () {\n onButton = true;\n }).mouseout(function () {\n onButton = false;\n });\n\n if (opts.multiclick) {\n list.mousedown(function () {\n onButton = true;\n });\n }\n };\n\n const extsPreLang = [];\n /**\n * @param {external:Window} win\n * @param {module:svgcanvas.SvgCanvas#event:extension_added} ext\n * @listens module:svgcanvas.SvgCanvas#event:extension_added\n * @returns {Promise<void>|void} Resolves to `undefined`\n */\n const extAdded = async function (win, ext) {\n if (!ext) {\n return undefined;\n }\n let cbCalled = false;\n let resizeDone = false;\n\n if (ext.langReady) {\n if (editor.langChanged) { // We check for this since the \"lang\" pref could have been set by storage\n const lang = editor.pref('lang');\n await ext.langReady({\n lang,\n uiStrings,\n importLocale: getImportLocale({defaultLang: lang, defaultName: ext.name})\n });\n loadedExtensionNames.push(ext.name);\n } else {\n extsPreLang.push(ext);\n }\n }\n\n /**\n * Clear resize timer if present and if not previously performed,\n * perform an icon resize.\n * @returns {void}\n */\n function prepResize () {\n if (resizeTimer) {\n clearTimeout(resizeTimer);\n resizeTimer = null;\n }\n if (!resizeDone) {\n resizeTimer = setTimeout(function () {\n resizeDone = true;\n setIconSize(editor.pref('iconsize'));\n }, 50);\n }\n }\n\n /**\n *\n * @returns {void}\n */\n const runCallback = function () {\n if (ext.callback && !cbCalled) {\n cbCalled = true;\n ext.callback.call(editor);\n }\n };\n\n const btnSelects = [];\n\n /**\n * @typedef {PlainObject} module:SVGEditor.ContextTool\n * @property {string} panel The ID of the existing panel to which the tool is being added. Required.\n * @property {string} id The ID of the actual tool element. Required.\n * @property {PlainObject<string, external:jQuery.Function>|PlainObject<\"change\", external:jQuery.Function>} events DOM event names keyed to associated functions. Example: `{change () { alert('Option was changed') } }`. \"change\" event is one specifically handled for the \"button-select\" type. Required.\n * @property {string} title The tooltip text that will appear when the user hovers over the tool. Required.\n * @property {\"tool_button\"|\"select\"|\"button-select\"|\"input\"|string} type The type of tool being added. Expected.\n * @property {PlainObject<string, string>} [options] List of options and their labels for select tools. Example: `{1: 'One', 2: 'Two', all: 'All' }`. Required by \"select\" tools.\n * @property {string} [container_id] The ID to be given to the tool's container element.\n * @property {string} [defval] Default value\n * @property {string|Integer} [colnum] Added as part of the option list class.\n * @property {string} [label] Label associated with the tool, visible in the UI\n * @property {Integer} [size] Value of the \"size\" attribute of the tool input\n * @property {module:jQuerySpinButton.SpinButtonConfig} [spindata] When added to a tool of type \"input\", this tool becomes a \"spinner\" which allows the number to be in/decreased.\n */\n if (ext.context_tools) {\n $.each(ext.context_tools, function (i, tool) {\n // Add select tool\n const contId = tool.container_id ? (' id=\"' + tool.container_id + '\"') : '';\n\n let panel = $('#' + tool.panel);\n // create the panel if it doesn't exist\n if (!panel.length) {\n panel = $('<div>', {id: tool.panel}).appendTo('#tools_top');\n }\n\n let html;\n // TODO: Allow support for other types, or adding to existing tool\n switch (tool.type) {\n case 'tool_button': {\n html = '<div class=\"tool_button\">' + tool.id + '</div>';\n const div = $(html).appendTo(panel);\n if (tool.events) {\n $.each(tool.events, function (evt, func) {\n $(div).bind(evt, func);\n });\n }\n break;\n } case 'select': {\n html = '<label' + contId + '>' +\n '<select id=\"' + tool.id + '\">';\n $.each(tool.options, function (val, text) {\n const sel = (val === tool.defval) ? ' selected' : '';\n html += '<option value=\"' + val + '\"' + sel + '>' + text + '</option>';\n });\n html += '</select></label>';\n // Creates the tool, hides & adds it, returns the select element\n const sel = $(html).appendTo(panel).find('select');\n\n $.each(tool.events, function (evt, func) {\n $(sel).bind(evt, func);\n });\n break;\n } case 'button-select': {\n html = '<div id=\"' + tool.id + '\" class=\"dropdown toolset\" title=\"' + tool.title + '\">' +\n '<div id=\"cur_' + tool.id + '\" class=\"icon_label\"></div><button></button></div>';\n\n const list = $('<ul id=\"' + tool.id + '_opts\"></ul>').appendTo('#option_lists');\n\n if (tool.colnum) {\n list.addClass('optcols' + tool.colnum);\n }\n\n // Creates the tool, hides & adds it, returns the select element\n /* const dropdown = */ $(html).appendTo(panel).children();\n\n btnSelects.push({\n elem: ('#' + tool.id),\n list: ('#' + tool.id + '_opts'),\n title: tool.title,\n callback: tool.events.change,\n cur: ('#cur_' + tool.id)\n });\n\n break;\n } case 'input': {\n html = '<label' + contId + '>' +\n '<span id=\"' + tool.id + '_label\">' +\n tool.label + ':</span>' +\n '<input id=\"' + tool.id + '\" title=\"' + tool.title +\n '\" size=\"' + (tool.size || '4') +\n '\" value=\"' + (tool.defval || '') + '\" type=\"text\"/></label>';\n\n // Creates the tool, hides & adds it, returns the select element\n\n // Add to given tool.panel\n const inp = $(html).appendTo(panel).find('input');\n\n if (tool.spindata) {\n inp.SpinButton(tool.spindata);\n }\n\n if (tool.events) {\n $.each(tool.events, function (evt, func) {\n inp.bind(evt, func);\n });\n }\n break;\n } default:\n break;\n }\n });\n }\n\n const {svgicons} = ext;\n if (ext.buttons) {\n const fallbackObj = {},\n altsObj = {},\n placementObj = {},\n holders = {};\n\n /**\n * @typedef {GenericArray} module:SVGEditor.KeyArray\n * @property {string} 0 The key to bind (on `keydown`)\n * @property {boolean} 1 Whether to `preventDefault` on the `keydown` event\n * @property {boolean} 2 Not apparently in use (NoDisableInInput)\n */\n /**\n * @typedef {string|module:SVGEditor.KeyArray} module:SVGEditor.Key\n */\n /**\n * @typedef {PlainObject} module:SVGEditor.Button\n * @property {string} id A unique identifier for this button. If SVG icons are used, this must match the ID used in the icon file. Required.\n * @property {\"mode_flyout\"|\"mode\"|\"context\"|\"app_menu\"} type Type of button. Required.\n * @property {string} title The tooltip text that will appear when the user hovers over the icon. Required.\n * @property {PlainObject<string, external:jQuery.Function>|PlainObject<\"click\", external:jQuery.Function>} events DOM event names with associated functions. Example: `{click () { alert('Button was clicked') } }`. Click is used with `includeWith` and `type` of \"mode_flyout\" (and \"mode\"); any events may be added if `list` is not present. Expected.\n * @property {string} panel The ID of the context panel to be included, if type is \"context\". Required only if type is \"context\".\n * @property {string} icon The file path to the raster version of the icon image source. Required only if no `svgicons` is supplied from [ExtensionInitResponse]{@link module:svgcanvas.ExtensionInitResponse}.\n * @property {string} [svgicon] If absent, will utilize the button \"id\"; used to set \"placement\" on the `svgIcons` call\n * @property {string} [list] Points to the \"id\" of a `context_tools` item of type \"button-select\" into which the button will be added as a panel list item\n * @property {Integer} [position] The numeric index for placement; defaults to last position (as of the time of extension addition) if not present. For use with {@link http://api.jquery.com/eq/}.\n * @property {boolean} [isDefault] Whether or not the button is the default. Used with `list`.\n * @property {PlainObject} [includeWith] Object with flyout menu data\n * @property {boolean} [includeWith.isDefault] Indicates whether button is default in flyout list or not.\n * @property {string} includeWith.button jQuery selector of the existing button to be joined. Example: '#tool_line'. Required if `includeWith` is used.\n * @property {\"last\"|Integer} [includeWith.position] Position of icon in flyout list; will be added to end if not indicated. Integer is for use with {@link http://api.jquery.com/eq/}.\n * @property {module:SVGEditor.Key} [key] The key to bind to the button\n */\n // Add buttons given by extension\n $.each(ext.buttons, function (i, /** @type {module:SVGEditor.Button} */ btn) {\n let {id} = btn;\n let num = i;\n // Give button a unique ID\n while ($('#' + id).length) {\n id = btn.id + '_' + (++num);\n }\n\n let icon;\n if (!svgicons) {\n icon = $(\n '<img src=\"' + btn.icon +\n (btn.title ? '\" alt=\"' + btn.title : '') +\n '\">'\n );\n } else {\n fallbackObj[id] = btn.icon;\n altsObj[id] = btn.title;\n const svgicon = btn.svgicon || btn.id;\n if (btn.type === 'app_menu') {\n placementObj['#' + id + ' > div'] = svgicon;\n } else {\n placementObj['#' + id] = svgicon;\n }\n }\n\n let cls, parent;\n\n // Set button up according to its type\n switch (btn.type) {\n case 'mode_flyout':\n case 'mode':\n cls = 'tool_button';\n parent = '#tools_left';\n break;\n case 'context':\n cls = 'tool_button';\n parent = '#' + btn.panel;\n // create the panel if it doesn't exist\n if (!$(parent).length) {\n $('<div>', {id: btn.panel}).appendTo('#tools_top');\n }\n break;\n case 'app_menu':\n cls = '';\n parent = '#main_menu ul';\n break;\n }\n let flyoutHolder, showBtn, refData, refBtn;\n const button = $((btn.list || btn.type === 'app_menu') ? '<li/>' : '<div/>')\n .attr('id', id)\n .attr('title', btn.title)\n .addClass(cls);\n if (!btn.includeWith && !btn.list) {\n if ('position' in btn) {\n if ($(parent).children().eq(btn.position).length) {\n $(parent).children().eq(btn.position).before(button);\n } else {\n $(parent).children().last().after(button);\n }\n } else {\n button.appendTo(parent);\n }\n\n if (btn.type === 'mode_flyout') {\n // Add to flyout menu / make flyout menu\n // const opts = btn.includeWith;\n // // opts.button, default, position\n refBtn = $(button);\n\n flyoutHolder = refBtn.parent();\n // Create a flyout menu if there isn't one already\n let tlsId;\n if (!refBtn.parent().hasClass('tools_flyout')) {\n // Create flyout placeholder\n tlsId = refBtn[0].id.replace('tool_', 'tools_');\n showBtn = refBtn.clone()\n .attr('id', tlsId + '_show')\n .append($('<div>', {class: 'flyout_arrow_horiz'}));\n\n refBtn.before(showBtn);\n\n // Create a flyout div\n flyoutHolder = makeFlyoutHolder(tlsId, refBtn);\n flyoutHolder.data('isLibrary', true);\n showBtn.data('isLibrary', true);\n }\n // refData = Actions.getButtonData(opts.button);\n\n placementObj['#' + tlsId + '_show'] = btn.id;\n // TODO: Find way to set the current icon using the iconloader if this is not default\n\n // Include data for extension button as well as ref button\n /* curH = */ holders['#' + flyoutHolder[0].id] = [{\n sel: '#' + id,\n fn: btn.events.click,\n icon: btn.id,\n // key: btn.key,\n isDefault: true\n }]; // , refData\n //\n // // {sel:'#tool_rect', fn: clickRect, evt: 'mouseup', key: 4, parent: '#tools_rect', icon: 'rect'}\n //\n // const pos = ('position' in opts)?opts.position:'last';\n // const len = flyoutHolder.children().length;\n //\n // // Add at given position or end\n // if (!isNaN(pos) && pos >= 0 && pos < len) {\n // flyoutHolder.children().eq(pos).before(button);\n // } else {\n // flyoutHolder.append(button);\n // curH.reverse();\n // }\n } else if (btn.type === 'app_menu') {\n button.append('<div>').append(btn.title);\n }\n } else if (btn.list) {\n // Add button to list\n button.addClass('push_button');\n $('#' + btn.list + '_opts').append(button);\n if (btn.isDefault) {\n $('#cur_' + btn.list).append(button.children().clone());\n const svgicon = btn.svgicon || btn.id;\n placementObj['#cur_' + btn.list] = svgicon;\n }\n } else if (btn.includeWith) {\n // Add to flyout menu / make flyout menu\n const opts = btn.includeWith;\n // opts.button, default, position\n refBtn = $(opts.button);\n\n flyoutHolder = refBtn.parent();\n // Create a flyout menu if there isn't one already\n let tlsId;\n if (!refBtn.parent().hasClass('tools_flyout')) {\n // Create flyout placeholder\n tlsId = refBtn[0].id.replace('tool_', 'tools_');\n showBtn = refBtn.clone()\n .attr('id', tlsId + '_show')\n .append($('<div>', {class: 'flyout_arrow_horiz'}));\n\n refBtn.before(showBtn);\n // Create a flyout div\n flyoutHolder = makeFlyoutHolder(tlsId, refBtn);\n }\n\n refData = Actions.getButtonData(opts.button);\n\n if (opts.isDefault) {\n placementObj['#' + tlsId + '_show'] = btn.id;\n }\n // TODO: Find way to set the current icon using the iconloader if this is not default\n\n // Include data for extension button as well as ref button\n const curH = holders['#' + flyoutHolder[0].id] = [{\n sel: '#' + id,\n fn: btn.events.click,\n icon: btn.id,\n key: btn.key,\n isDefault: Boolean(btn.includeWith && btn.includeWith.isDefault)\n }, refData];\n\n // {sel:'#tool_rect', fn: clickRect, evt: 'mouseup', key: 4, parent: '#tools_rect', icon: 'rect'}\n\n const pos = ('position' in opts) ? opts.position : 'last';\n const len = flyoutHolder.children().length;\n\n // Add at given position or end\n if (!isNaN(pos) && pos >= 0 && pos < len) {\n flyoutHolder.children().eq(pos).before(button);\n } else {\n flyoutHolder.append(button);\n curH.reverse();\n }\n }\n\n if (!svgicons) {\n button.append(icon);\n }\n\n if (!btn.list) {\n // Add given events to button\n $.each(btn.events, function (name, func) {\n if (name === 'click' && btn.type === 'mode') {\n // `touch.js` changes `touchstart` to `mousedown`,\n // so we must map extension click events as well\n if (isTouch() && name === 'click') {\n name = 'mousedown';\n }\n if (btn.includeWith) {\n button.bind(name, func);\n } else {\n button.bind(name, function () {\n if (toolButtonClick(button)) {\n func();\n }\n });\n }\n if (btn.key) {\n $(document).bind('keydown', btn.key, func);\n if (btn.title) {\n button.attr('title', btn.title + ' [' + btn.key + ']');\n }\n }\n } else {\n button.bind(name, func);\n }\n });\n }\n\n setupFlyouts(holders);\n });\n\n $.each(btnSelects, function () {\n addAltDropDown(this.elem, this.list, this.callback, {seticon: true});\n });\n\n if (svgicons) {\n return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new\n $.svgIcons(svgicons, {\n w: 24, h: 24,\n id_match: false,\n no_img: (!isWebkit()),\n fallback: fallbackObj,\n placement: placementObj,\n callback (icons) {\n // Non-ideal hack to make the icon match the current size\n // if (curPrefs.iconsize && curPrefs.iconsize !== 'm') {\n if (editor.pref('iconsize') !== 'm') {\n prepResize();\n }\n runCallback();\n resolve();\n }\n });\n });\n }\n }\n return runCallback();\n };\n\n /**\n * @param {string} color\n * @param {Float} opac\n * @param {string} type\n * @returns {module:jGraduate~Paint}\n */\n const getPaint = function (color, opac, type) {\n // update the editor's fill paint\n const opts = {alpha: opac};\n if (color.startsWith('url(#')) {\n let refElem = svgCanvas.getRefElem(color);\n if (refElem) {\n refElem = refElem.cloneNode(true);\n } else {\n refElem = $('#' + type + '_color defs *')[0];\n }\n opts[refElem.tagName] = refElem;\n } else if (color.startsWith('#')) {\n opts.solidColor = color.substr(1);\n } else {\n opts.solidColor = 'none';\n }\n return new $.jGraduate.Paint(opts);\n };\n\n // $('#text').focus(function () { textBeingEntered = true; });\n // $('#text').blur(function () { textBeingEntered = false; });\n\n // bind the selected event to our function that handles updates to the UI\n svgCanvas.bind('selected', selectedChanged);\n svgCanvas.bind('transition', elementTransition);\n svgCanvas.bind('changed', elementChanged);\n svgCanvas.bind('saved', saveHandler);\n svgCanvas.bind('exported', exportHandler);\n svgCanvas.bind('exportedPDF', function (win, data) {\n if (!data.output) { // Ignore Chrome\n return;\n }\n const {exportWindowName} = data;\n if (exportWindowName) {\n exportWindow = window.open('', exportWindowName); // A hack to get the window via JSON-able name without opening a new one\n }\n if (!exportWindow || exportWindow.closed) {\n /* await */ $.alert(uiStrings.notification.popupWindowBlocked);\n return;\n }\n exportWindow.location.href = data.output;\n });\n svgCanvas.bind('zoomed', zoomChanged);\n svgCanvas.bind('zoomDone', zoomDone);\n svgCanvas.bind(\n 'updateCanvas',\n /**\n * @param {external:Window} win\n * @param {PlainObject} centerInfo\n * @param {false} centerInfo.center\n * @param {module:math.XYObject} centerInfo.newCtr\n * @listens module:svgcanvas.SvgCanvas#event:updateCanvas\n * @returns {void}\n */\n function (win, {center, newCtr}) {\n updateCanvas(center, newCtr);\n }\n );\n svgCanvas.bind('contextset', contextChanged);\n svgCanvas.bind('extension_added', extAdded);\n svgCanvas.textActions.setInputElem($('#text')[0]);\n\n let str = '<div class=\"palette_item\" data-rgb=\"none\"></div>';\n $.each(palette, function (i, item) {\n str += '<div class=\"palette_item\" style=\"background-color: ' + item +\n ';\" data-rgb=\"' + item + '\"></div>';\n });\n $('#palette').append(str);\n\n // Set up editor background functionality\n const colorBlocks = ['#FFF', '#888', '#000', 'chessboard'];\n str = '';\n $.each(colorBlocks, function (i, e) {\n if (e === 'chessboard') {\n str += '<div class=\"color_block\" data-bgcolor=\"' + e +\n '\" style=\"background-image:url(data:image/gif;base64,' +\n 'R0lGODlhEAAQAIAAAP///9bW1iH5BAAAAAAALAAAAAAQABAAAAIfjG+' +\n 'gq4jM3IFLJgpswNly/XkcBpIiVaInlLJr9FZWAQA7);\"></div>';\n } else {\n str += '<div class=\"color_block\" data-bgcolor=\"' + e + '\" style=\"background-color:' + e + ';\"></div>';\n }\n });\n $('#bg_blocks').append(str);\n const blocks = $('#bg_blocks div');\n const curBg = 'cur_background';\n blocks.each(function () {\n const blk = $(this);\n blk.click(function () {\n blocks.removeClass(curBg);\n $(this).addClass(curBg);\n });\n });\n\n setBackground(editor.pref('bkgd_color'), editor.pref('bkgd_url'));\n\n $('#image_save_opts input').val([editor.pref('img_save')]);\n\n /**\n * @type {module:jQuerySpinButton.ValueCallback}\n */\n const changeRectRadius = function (ctl) {\n svgCanvas.setRectRadius(ctl.value);\n };\n\n /**\n * @type {module:jQuerySpinButton.ValueCallback}\n */\n const changeFontSize = function (ctl) {\n svgCanvas.setFontSize(ctl.value);\n };\n\n /**\n * @type {module:jQuerySpinButton.ValueCallback}\n */\n const changeStrokeWidth = function (ctl) {\n let val = ctl.value;\n if (val === 0 && selectedElement && ['line', 'polyline'].includes(selectedElement.nodeName)) {\n val = ctl.value = 1;\n }\n svgCanvas.setStrokeWidth(val);\n };\n\n /**\n * @type {module:jQuerySpinButton.ValueCallback}\n */\n const changeRotationAngle = function (ctl) {\n svgCanvas.setRotationAngle(ctl.value);\n $('#tool_reorient').toggleClass('disabled', Number.parseInt(ctl.value) === 0);\n };\n\n /**\n * @param {external:jQuery.fn.SpinButton} ctl Spin Button\n * @param {string} [val=ctl.value]\n * @returns {void}\n */\n const changeOpacity = function (ctl, val) {\n if (Utils.isNullish(val)) { val = ctl.value; }\n $('#group_opacity').val(val);\n if (!ctl || !ctl.handle) {\n $('#opac_slider').slider('option', 'value', val);\n }\n svgCanvas.setOpacity(val / 100);\n };\n\n /**\n * @param {external:jQuery.fn.SpinButton} ctl Spin Button\n * @param {string} [val=ctl.value]\n * @param {boolean} noUndo\n * @returns {void}\n */\n const changeBlur = function (ctl, val, noUndo) {\n if (Utils.isNullish(val)) { val = ctl.value; }\n $('#blur').val(val);\n let complete = false;\n if (!ctl || !ctl.handle) {\n $('#blur_slider').slider('option', 'value', val);\n complete = true;\n }\n if (noUndo) {\n svgCanvas.setBlurNoUndo(val);\n } else {\n svgCanvas.setBlur(val, complete);\n }\n };\n\n $('#stroke_style').change(function () {\n svgCanvas.setStrokeAttr('stroke-dasharray', $(this).val());\n operaRepaint();\n });\n\n $('#stroke_linejoin').change(function () {\n svgCanvas.setStrokeAttr('stroke-linejoin', $(this).val());\n operaRepaint();\n });\n\n // Lose focus for select elements when changed (Allows keyboard shortcuts to work better)\n $('select').change(function () { $(this).blur(); });\n\n // fired when user wants to move elements to another layer\n let promptMoveLayerOnce = false;\n $('#selLayerNames').change(async function () {\n const destLayer = this.options[this.selectedIndex].value;\n const confirmStr = uiStrings.notification.QmoveElemsToLayer.replace('%s', destLayer);\n /**\n * @param {boolean} ok\n * @returns {void}\n */\n const moveToLayer = function (ok) {\n if (!ok) { return; }\n promptMoveLayerOnce = true;\n svgCanvas.moveSelectedToLayer(destLayer);\n svgCanvas.clearSelection();\n populateLayers();\n };\n if (destLayer) {\n if (promptMoveLayerOnce) {\n moveToLayer(true);\n } else {\n const ok = await $.confirm(confirmStr);\n if (!ok) {\n return;\n }\n moveToLayer(true);\n }\n }\n });\n\n $('#font_family').change(function () {\n svgCanvas.setFontFamily(this.value);\n });\n\n $('#seg_type').change(function () {\n svgCanvas.setSegType($(this).val());\n });\n\n $('#text').bind('keyup input', function () {\n svgCanvas.setTextContent(this.value);\n });\n\n $('#image_url').change(function () {\n setImageURL(this.value);\n });\n\n $('#link_url').change(function () {\n if (this.value.length) {\n svgCanvas.setLinkURL(this.value);\n } else {\n svgCanvas.removeHyperlink();\n }\n });\n\n $('#g_title').change(function () {\n svgCanvas.setGroupTitle(this.value);\n });\n\n $('.attr_changer').change(function () {\n const attr = this.getAttribute('data-attr');\n let val = this.value;\n const valid = isValidUnit(attr, val, selectedElement);\n\n if (!valid) {\n this.value = selectedElement.getAttribute(attr);\n /* await */ $.alert(uiStrings.notification.invalidAttrValGiven);\n return false;\n }\n\n if (attr !== 'id' && attr !== 'class') {\n if (isNaN(val)) {\n val = svgCanvas.convertToNum(attr, val);\n } else if (curConfig.baseUnit !== 'px') {\n // Convert unitless value to one with given unit\n\n const unitData = getTypeMap();\n\n if (selectedElement[attr] || svgCanvas.getMode() === 'pathedit' || attr === 'x' || attr === 'y') {\n val *= unitData[curConfig.baseUnit];\n }\n }\n }\n\n // if the user is changing the id, then de-select the element first\n // change the ID, then re-select it with the new ID\n if (attr === 'id') {\n const elem = selectedElement;\n svgCanvas.clearSelection();\n elem.id = val;\n svgCanvas.addToSelection([elem], true);\n } else {\n svgCanvas.changeSelectedAttribute(attr, val);\n }\n this.blur();\n return true;\n });\n\n // Prevent selection of elements when shift-clicking\n $('#palette').mouseover(function () {\n const inp = $('<input type=\"hidden\">');\n $(this).append(inp);\n inp.focus().remove();\n });\n\n $('.palette_item').mousedown(function (evt) {\n // shift key or right click for stroke\n const picker = evt.shiftKey || evt.button === 2 ? 'stroke' : 'fill';\n let color = $(this).data('rgb');\n let paint;\n\n // Webkit-based browsers returned 'initial' here for no stroke\n if (color === 'none' || color === 'transparent' || color === 'initial') {\n color = 'none';\n paint = new $.jGraduate.Paint();\n } else {\n paint = new $.jGraduate.Paint({alpha: 100, solidColor: color.substr(1)});\n }\n\n paintBox[picker].setPaint(paint);\n svgCanvas.setColor(picker, color);\n\n if (color !== 'none' && svgCanvas.getPaintOpacity(picker) !== 1) {\n svgCanvas.setPaintOpacity(picker, 1.0);\n }\n updateToolButtonState();\n }).bind('contextmenu', function (e) { e.preventDefault(); });\n\n $('#toggle_stroke_tools').on('click', function () {\n $('#tools_bottom').toggleClass('expanded');\n });\n\n (function () {\n const wArea = workarea[0];\n\n let lastX = null, lastY = null,\n panning = false, keypan = false;\n\n $('#svgcanvas').bind('mousemove mouseup', function (evt) {\n if (panning === false) { return true; }\n\n wArea.scrollLeft -= (evt.clientX - lastX);\n wArea.scrollTop -= (evt.clientY - lastY);\n\n lastX = evt.clientX;\n lastY = evt.clientY;\n\n if (evt.type === 'mouseup') { panning = false; }\n return false;\n }).mousedown(function (evt) {\n if (evt.button === 1 || keypan === true) {\n panning = true;\n lastX = evt.clientX;\n lastY = evt.clientY;\n return false;\n }\n return true;\n });\n\n $(window).mouseup(function () {\n panning = false;\n });\n\n $(document).bind('keydown', 'space', function (evt) {\n svgCanvas.spaceKey = keypan = true;\n evt.preventDefault();\n }).bind('keyup', 'space', function (evt) {\n evt.preventDefault();\n svgCanvas.spaceKey = keypan = false;\n }).bind('keydown', 'shift', function (evt) {\n if (svgCanvas.getMode() === 'zoom') {\n workarea.css('cursor', zoomOutIcon);\n }\n }).bind('keyup', 'shift', function (evt) {\n if (svgCanvas.getMode() === 'zoom') {\n workarea.css('cursor', zoomInIcon);\n }\n });\n\n /**\n * @function module:SVGEditor.setPanning\n * @param {boolean} active\n * @returns {void}\n */\n editor.setPanning = function (active) {\n svgCanvas.spaceKey = keypan = active;\n };\n }());\n\n (function () {\n const button = $('#main_icon');\n const overlay = $('#main_icon span');\n const list = $('#main_menu');\n\n let onButton = false;\n let height = 0;\n let jsHover = true;\n let setClick = false;\n\n /*\n // Currently unused\n const hideMenu = function () {\n list.fadeOut(200);\n };\n */\n\n $(window).mouseup(function (evt) {\n if (!onButton) {\n button.removeClass('buttondown');\n // do not hide if it was the file input as that input needs to be visible\n // for its change event to fire\n if (evt.target.tagName !== 'INPUT') {\n list.fadeOut(200);\n } else if (!setClick) {\n setClick = true;\n $(evt.target).click(function () {\n list.css('margin-left', '-9999px').show();\n });\n }\n }\n onButton = false;\n }).mousedown(function (evt) {\n // $('.contextMenu').hide();\n const islib = $(evt.target).closest('div.tools_flyout, .contextMenu').length;\n if (!islib) {\n $('.tools_flyout:visible,.contextMenu').fadeOut(250);\n }\n });\n\n overlay.bind('mousedown', function () {\n if (!button.hasClass('buttondown')) {\n // Margin must be reset in case it was changed before;\n list.css('margin-left', 0).show();\n if (!height) {\n height = list.height();\n }\n // Using custom animation as slideDown has annoying 'bounce effect'\n list.css('height', 0).animate({\n height\n }, 200);\n onButton = true;\n } else {\n list.fadeOut(200);\n }\n button.toggleClass('buttondown buttonup');\n }).hover(function () {\n onButton = true;\n }).mouseout(function () {\n onButton = false;\n });\n\n const listItems = $('#main_menu li');\n\n // Check if JS method of hovering needs to be used (Webkit bug)\n listItems.mouseover(function () {\n jsHover = ($(this).css('background-color') === 'rgba(0, 0, 0, 0)');\n\n listItems.unbind('mouseover');\n if (jsHover) {\n listItems.mouseover(function () {\n this.style.backgroundColor = '#FFC';\n }).mouseout(function () {\n this.style.backgroundColor = 'transparent';\n return true;\n });\n }\n });\n }());\n // Made public for UI customization.\n // TODO: Group UI functions into a public editor.ui interface.\n /**\n * See {@link http://api.jquery.com/bind/#bind-eventType-eventData-handler}.\n * @callback module:SVGEditor.DropDownCallback\n * @param {external:jQuery.Event} ev See {@link http://api.jquery.com/Types/#Event}\n * @listens external:jQuery.Event\n * @returns {void|boolean} Calls `preventDefault()` and `stopPropagation()`\n */\n /**\n * @function module:SVGEditor.addDropDown\n * @param {Element|string} elem DOM Element or selector\n * @param {module:SVGEditor.DropDownCallback} callback Mouseup callback\n * @param {boolean} dropUp\n * @returns {void}\n */\n editor.addDropDown = function (elem, callback, dropUp) {\n if (!$(elem).length) { return; } // Quit if called on non-existent element\n const button = $(elem).find('button');\n const list = $(elem).find('ul').attr('id', $(elem)[0].id + '-list');\n if (dropUp) {\n $(elem).addClass('dropup');\n } else {\n // Move list to place where it can overflow container\n $('#option_lists').append(list);\n }\n list.find('li').bind('mouseup', callback);\n\n let onButton = false;\n $(window).mouseup(function (evt) {\n if (!onButton) {\n button.removeClass('down');\n list.hide();\n }\n onButton = false;\n });\n\n button.bind('mousedown', function () {\n if (!button.hasClass('down')) {\n if (!dropUp) {\n const pos = $(elem).position();\n list.css({\n top: pos.top + 24,\n left: pos.left - 10\n });\n }\n list.show();\n onButton = true;\n } else {\n list.hide();\n }\n button.toggleClass('down');\n }).hover(function () {\n onButton = true;\n }).mouseout(function () {\n onButton = false;\n });\n };\n\n editor.addDropDown('#font_family_dropdown', function () {\n $('#font_family').val($(this).text()).change();\n });\n\n editor.addDropDown('#opacity_dropdown', function () {\n if ($(this).find('div').length) { return; }\n const perc = Number.parseInt($(this).text().split('%')[0]);\n changeOpacity(false, perc);\n }, true);\n\n // For slider usage, see: http://jqueryui.com/demos/slider/\n $('#opac_slider').slider({\n start () {\n $('#opacity_dropdown li:not(.special)').hide();\n },\n stop () {\n $('#opacity_dropdown li').show();\n $(window).mouseup();\n },\n slide (evt, ui) {\n changeOpacity(ui);\n }\n });\n\n editor.addDropDown('#blur_dropdown', $.noop);\n\n let slideStart = false;\n $('#blur_slider').slider({\n max: 10,\n step: 0.1,\n stop (evt, ui) {\n slideStart = false;\n changeBlur(ui);\n $('#blur_dropdown li').show();\n $(window).mouseup();\n },\n start () {\n slideStart = true;\n },\n slide (evt, ui) {\n changeBlur(ui, null, slideStart);\n }\n });\n\n editor.addDropDown('#zoom_dropdown', function () {\n const item = $(this);\n const val = item.data('val');\n if (val) {\n zoomChanged(window, val);\n } else {\n changeZoom({value: Number.parseFloat(item.text())});\n }\n }, true);\n\n addAltDropDown('#stroke_linecap', '#linecap_opts', function () {\n setStrokeOpt(this, true);\n }, {dropUp: true});\n\n addAltDropDown('#stroke_linejoin', '#linejoin_opts', function () {\n setStrokeOpt(this, true);\n }, {dropUp: true});\n\n addAltDropDown('#tool_position', '#position_opts', function () {\n const letter = this.id.replace('tool_pos', '').charAt(0);\n svgCanvas.alignSelectedElements(letter, 'page');\n }, {multiclick: true});\n\n /*\n\n When a flyout icon is selected\n (if flyout) {\n - Change the icon\n - Make pressing the button run its stuff\n }\n - Run its stuff\n\n When its shortcut key is pressed\n - If not current in list, do as above\n , else:\n - Just run its stuff\n\n */\n\n // Unfocus text input when workarea is mousedowned.\n (function () {\n let inp;\n /**\n *\n * @returns {void}\n */\n const unfocus = function () {\n $(inp).blur();\n };\n\n $('#svg_editor').find('button, select, input:not(#text)').focus(function () {\n inp = this;\n uiContext = 'toolbars';\n workarea.mousedown(unfocus);\n }).blur(function () {\n uiContext = 'canvas';\n workarea.unbind('mousedown', unfocus);\n // Go back to selecting text if in textedit mode\n if (svgCanvas.getMode() === 'textedit') {\n $('#text').focus();\n }\n });\n }());\n\n /**\n *\n * @returns {void}\n */\n const clickFHPath = function () {\n if (toolButtonClick('#tool_fhpath')) {\n svgCanvas.setMode('fhpath');\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const clickLine = function () {\n if (toolButtonClick('#tool_line')) {\n svgCanvas.setMode('line');\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const clickSquare = function () {\n if (toolButtonClick('#tool_square')) {\n svgCanvas.setMode('square');\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const clickRect = function () {\n if (toolButtonClick('#tool_rect')) {\n svgCanvas.setMode('rect');\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const clickFHRect = function () {\n if (toolButtonClick('#tool_fhrect')) {\n svgCanvas.setMode('fhrect');\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const clickCircle = function () {\n if (toolButtonClick('#tool_circle')) {\n svgCanvas.setMode('circle');\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const clickEllipse = function () {\n if (toolButtonClick('#tool_ellipse')) {\n svgCanvas.setMode('ellipse');\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const clickFHEllipse = function () {\n if (toolButtonClick('#tool_fhellipse')) {\n svgCanvas.setMode('fhellipse');\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const clickImage = function () {\n if (toolButtonClick('#tool_image')) {\n svgCanvas.setMode('image');\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const clickZoom = function () {\n if (toolButtonClick('#tool_zoom')) {\n svgCanvas.setMode('zoom');\n workarea.css('cursor', zoomInIcon);\n }\n };\n\n /**\n * @param {Float} multiplier\n * @returns {void}\n */\n const zoomImage = function (multiplier) {\n const res = svgCanvas.getResolution();\n multiplier = multiplier ? res.zoom * multiplier : 1;\n // setResolution(res.w * multiplier, res.h * multiplier, true);\n $('#zoom').val(multiplier * 100);\n svgCanvas.setZoom(multiplier);\n zoomDone();\n updateCanvas(true);\n };\n\n /**\n *\n * @returns {void}\n */\n const dblclickZoom = function () {\n if (toolButtonClick('#tool_zoom')) {\n zoomImage();\n setSelectMode();\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const clickText = function () {\n if (toolButtonClick('#tool_text')) {\n svgCanvas.setMode('text');\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const clickPath = function () {\n if (toolButtonClick('#tool_path')) {\n svgCanvas.setMode('path');\n }\n };\n\n /**\n * Delete is a contextual tool that only appears in the ribbon if\n * an element has been selected.\n * @returns {void}\n */\n const deleteSelected = function () {\n if (!Utils.isNullish(selectedElement) || multiselected) {\n svgCanvas.deleteSelectedElements();\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const cutSelected = function () {\n if (!Utils.isNullish(selectedElement) || multiselected) {\n svgCanvas.cutSelectedElements();\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const copySelected = function () {\n if (!Utils.isNullish(selectedElement) || multiselected) {\n svgCanvas.copySelectedElements();\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const pasteInCenter = function () {\n const zoom = svgCanvas.getZoom();\n const x = (workarea[0].scrollLeft + workarea.width() / 2) / zoom - svgCanvas.contentW;\n const y = (workarea[0].scrollTop + workarea.height() / 2) / zoom - svgCanvas.contentH;\n svgCanvas.pasteElements('point', x, y);\n };\n\n /**\n *\n * @returns {void}\n */\n const moveToTopSelected = function () {\n if (!Utils.isNullish(selectedElement)) {\n svgCanvas.moveToTopSelectedElement();\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const moveToBottomSelected = function () {\n if (!Utils.isNullish(selectedElement)) {\n svgCanvas.moveToBottomSelectedElement();\n }\n };\n\n /**\n * @param {\"Up\"|\"Down\"} dir\n * @returns {void}\n */\n const moveUpDownSelected = function (dir) {\n if (!Utils.isNullish(selectedElement)) {\n svgCanvas.moveUpDownSelected(dir);\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const convertToPath = function () {\n if (!Utils.isNullish(selectedElement)) {\n svgCanvas.convertToPath();\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const reorientPath = function () {\n if (!Utils.isNullish(selectedElement)) {\n path.reorient();\n }\n };\n\n /**\n *\n * @returns {Promise<void>} Resolves to `undefined`\n */\n const makeHyperlink = async function () {\n if (!Utils.isNullish(selectedElement) || multiselected) {\n const url = await $.prompt(uiStrings.notification.enterNewLinkURL, 'http://');\n if (url) {\n svgCanvas.makeHyperlink(url);\n }\n }\n };\n\n /**\n * @param {Float} dx\n * @param {Float} dy\n * @returns {void}\n */\n const moveSelected = function (dx, dy) {\n if (!Utils.isNullish(selectedElement) || multiselected) {\n if (curConfig.gridSnapping) {\n // Use grid snap value regardless of zoom level\n const multi = svgCanvas.getZoom() * curConfig.snappingStep;\n dx *= multi;\n dy *= multi;\n }\n svgCanvas.moveSelectedElements(dx, dy);\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const linkControlPoints = function () {\n $('#tool_node_link').toggleClass('push_button_pressed tool_button');\n const linked = $('#tool_node_link').hasClass('push_button_pressed');\n path.linkControlPoints(linked);\n };\n\n /**\n *\n * @returns {void}\n */\n const clonePathNode = function () {\n if (path.getNodePoint()) {\n path.clonePathNode();\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const deletePathNode = function () {\n if (path.getNodePoint()) {\n path.deletePathNode();\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const addSubPath = function () {\n const button = $('#tool_add_subpath');\n const sp = !button.hasClass('push_button_pressed');\n button.toggleClass('push_button_pressed tool_button');\n path.addSubPath(sp);\n };\n\n /**\n *\n * @returns {void}\n */\n const opencloseSubPath = function () {\n path.opencloseSubPath();\n };\n\n /**\n *\n * @returns {void}\n */\n const selectNext = function () {\n svgCanvas.cycleElement(1);\n };\n\n /**\n *\n * @returns {void}\n */\n const selectPrev = function () {\n svgCanvas.cycleElement(0);\n };\n\n /**\n * @param {0|1} cw\n * @param {Integer} step\n * @returns {void}\n */\n const rotateSelected = function (cw, step) {\n if (Utils.isNullish(selectedElement) || multiselected) { return; }\n if (!cw) { step *= -1; }\n const angle = Number.parseFloat($('#angle').val()) + step;\n svgCanvas.setRotationAngle(angle);\n updateContextPanel();\n };\n\n /**\n * @fires module:svgcanvas.SvgCanvas#event:ext_onNewDocument\n * @returns {Promise<void>} Resolves to `undefined`\n */\n const clickClear = async function () {\n const [x, y] = curConfig.dimensions;\n const ok = await $.confirm(uiStrings.notification.QwantToClear);\n if (!ok) {\n return;\n }\n setSelectMode();\n svgCanvas.clear();\n svgCanvas.setResolution(x, y);\n updateCanvas(true);\n zoomImage();\n populateLayers();\n updateContextPanel();\n prepPaints();\n svgCanvas.runExtensions('onNewDocument');\n };\n\n /**\n *\n * @returns {false}\n */\n const clickBold = function () {\n svgCanvas.setBold(!svgCanvas.getBold());\n updateContextPanel();\n return false;\n };\n\n /**\n *\n * @returns {false}\n */\n const clickItalic = function () {\n svgCanvas.setItalic(!svgCanvas.getItalic());\n updateContextPanel();\n return false;\n };\n\n /**\n *\n * @returns {void}\n */\n const clickSave = function () {\n // In the future, more options can be provided here\n const saveOpts = {\n images: editor.pref('img_save'),\n round_digits: 6\n };\n svgCanvas.save(saveOpts);\n };\n\n let loadingURL;\n /**\n *\n * @returns {Promise<void>} Resolves to `undefined`\n */\n const clickExport = async function () {\n const imgType = await $.select('Select an image type for export: ', [\n // See http://kangax.github.io/jstests/toDataUrl_mime_type_test/ for a useful list of MIME types and browser support\n // 'ICO', // Todo: Find a way to preserve transparency in SVG-Edit if not working presently and do full packaging for x-icon; then switch back to position after 'PNG'\n 'PNG',\n 'JPEG', 'BMP', 'WEBP', 'PDF'\n ], function () {\n const sel = $(this);\n if (sel.val() === 'JPEG' || sel.val() === 'WEBP') {\n if (!$('#image-slider').length) {\n $(`<div><label>${uiStrings.ui.quality}\n <input id=\"image-slider\"\n type=\"range\" min=\"1\" max=\"100\" value=\"92\" />\n </label></div>`).appendTo(sel.parent());\n }\n } else {\n $('#image-slider').parent().remove();\n }\n }); // todo: replace hard-coded msg with uiStrings.notification.\n if (!imgType) {\n return;\n }\n // Open placeholder window (prevents popup)\n let exportWindowName;\n\n /**\n *\n * @returns {void}\n */\n function openExportWindow () {\n const {loadingImage} = uiStrings.notification;\n if (curConfig.exportWindowType === 'new') {\n editor.exportWindowCt++;\n }\n exportWindowName = curConfig.canvasName + editor.exportWindowCt;\n let popHTML, popURL;\n if (loadingURL) {\n popURL = loadingURL;\n } else {\n popHTML = `<!DOCTYPE html><html>\n <head>\n <meta charset=\"utf-8\">\n <title>${loadingImage}\n \n

${loadingImage}

\n `;\n if (typeof URL !== 'undefined' && URL.createObjectURL) {\n const blob = new Blob([popHTML], {type: 'text/html'});\n popURL = URL.createObjectURL(blob);\n } else {\n popURL = 'data:text/html;base64;charset=utf-8,' + Utils.encode64(popHTML);\n }\n loadingURL = popURL;\n }\n exportWindow = window.open(popURL, exportWindowName);\n }\n const chrome = isChrome();\n if (imgType === 'PDF') {\n if (!customExportPDF && !chrome) {\n openExportWindow();\n }\n svgCanvas.exportPDF(exportWindowName);\n } else {\n if (!customExportImage) {\n openExportWindow();\n }\n const quality = Number.parseInt($('#image-slider').val()) / 100;\n /* const results = */ await svgCanvas.rasterExport(imgType, quality, exportWindowName);\n }\n };\n\n /**\n * By default, svgCanvas.open() is a no-op. It is up to an extension\n * mechanism (opera widget, etc.) to call `setCustomHandlers()` which\n * will make it do something.\n * @returns {void}\n */\n const clickOpen = function () {\n svgCanvas.open();\n };\n\n /**\n *\n * @returns {void}\n */\n const clickImport = function () {\n /* */\n };\n\n /**\n *\n * @returns {void}\n */\n const clickUndo = function () {\n if (undoMgr.getUndoStackSize() > 0) {\n undoMgr.undo();\n populateLayers();\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const clickRedo = function () {\n if (undoMgr.getRedoStackSize() > 0) {\n undoMgr.redo();\n populateLayers();\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const clickGroup = function () {\n // group\n if (multiselected) {\n svgCanvas.groupSelectedElements();\n // ungroup\n } else if (selectedElement) {\n svgCanvas.ungroupSelectedElement();\n }\n };\n\n /**\n *\n * @returns {void}\n */\n const clickClone = function () {\n svgCanvas.cloneSelectedElements(20, 20);\n };\n\n /**\n *\n * @returns {void}\n */\n const clickAlign = function () {\n const letter = this.id.replace('tool_align', '').charAt(0);\n svgCanvas.alignSelectedElements(letter, $('#align_relative_to').val());\n };\n\n /**\n *\n * @returns {void}\n */\n const clickWireframe = function () {\n $('#tool_wireframe').toggleClass('push_button_pressed tool_button');\n workarea.toggleClass('wireframe');\n\n if (supportsNonSS) { return; }\n const wfRules = $('#wireframe_rules');\n if (!wfRules.length) {\n /* wfRules = */ $('').appendTo('head');\n } else {\n wfRules.empty();\n }\n\n updateWireFrame();\n };\n\n $('#svg_docprops_container, #svg_prefs_container').draggable({\n cancel: 'button,fieldset',\n containment: 'window'\n }).css('position', 'absolute');\n\n let docprops = false;\n let preferences = false;\n\n /**\n *\n * @returns {void}\n */\n const showDocProperties = function () {\n if (docprops) { return; }\n docprops = true;\n\n // This selects the correct radio button by using the array notation\n $('#image_save_opts input').val([editor.pref('img_save')]);\n\n // update resolution option with actual resolution\n const res = svgCanvas.getResolution();\n if (curConfig.baseUnit !== 'px') {\n res.w = convertUnit(res.w) + curConfig.baseUnit;\n res.h = convertUnit(res.h) + curConfig.baseUnit;\n }\n\n $('#canvas_width').val(res.w);\n $('#canvas_height').val(res.h);\n $('#canvas_title').val(svgCanvas.getDocumentTitle());\n\n $('#svg_docprops').show();\n };\n\n /**\n *\n * @returns {void}\n */\n const showPreferences = function () {\n if (preferences) { return; }\n preferences = true;\n $('#main_menu').hide();\n\n // Update background color with current one\n const canvasBg = curPrefs.bkgd_color;\n const url = editor.pref('bkgd_url');\n blocks.each(function () {\n const blk = $(this);\n const isBg = blk.data('bgcolor') === canvasBg;\n blk.toggleClass(curBg, isBg);\n });\n if (!canvasBg) { blocks.eq(0).addClass(curBg); }\n if (url) {\n $('#canvas_bg_url').val(url);\n }\n $('#grid_snapping_on').prop('checked', curConfig.gridSnapping);\n $('#grid_snapping_step').attr('value', curConfig.snappingStep);\n $('#grid_color').attr('value', curConfig.gridColor);\n\n $('#svg_prefs').show();\n };\n\n /**\n *\n * @returns {void}\n */\n const openHomePage = function () {\n window.open(homePage, '_blank');\n };\n\n /**\n *\n * @returns {void}\n */\n const hideSourceEditor = function () {\n $('#svg_source_editor').hide();\n editingsource = false;\n $('#svg_source_textarea').blur();\n };\n\n /**\n *\n * @returns {Promise} Resolves to `undefined`\n */\n const saveSourceEditor = async function () {\n if (!editingsource) { return; }\n\n const saveChanges = function () {\n svgCanvas.clearSelection();\n hideSourceEditor();\n zoomImage();\n populateLayers();\n updateTitle();\n prepPaints();\n };\n\n if (!svgCanvas.setSvgString($('#svg_source_textarea').val())) {\n const ok = await $.confirm(uiStrings.notification.QerrorsRevertToSource);\n if (!ok) {\n return;\n }\n saveChanges();\n return;\n }\n saveChanges();\n setSelectMode();\n };\n\n /**\n *\n * @returns {void}\n */\n const hideDocProperties = function () {\n $('#svg_docprops').hide();\n $('#canvas_width,#canvas_height').removeAttr('disabled');\n $('#resolution')[0].selectedIndex = 0;\n $('#image_save_opts input').val([editor.pref('img_save')]);\n docprops = false;\n };\n\n /**\n *\n * @returns {void}\n */\n const hidePreferences = function () {\n $('#svg_prefs').hide();\n preferences = false;\n };\n\n /**\n *\n * @returns {boolean} Whether there were problems saving the document properties\n */\n const saveDocProperties = function () {\n // set title\n const newTitle = $('#canvas_title').val();\n updateTitle(newTitle);\n svgCanvas.setDocumentTitle(newTitle);\n\n // update resolution\n const width = $('#canvas_width'), w = width.val();\n const height = $('#canvas_height'), h = height.val();\n\n if (w !== 'fit' && !isValidUnit('width', w)) {\n width.parent().addClass('error');\n /* await */ $.alert(uiStrings.notification.invalidAttrValGiven);\n return false;\n }\n\n width.parent().removeClass('error');\n\n if (h !== 'fit' && !isValidUnit('height', h)) {\n height.parent().addClass('error');\n /* await */ $.alert(uiStrings.notification.invalidAttrValGiven);\n return false;\n }\n\n height.parent().removeClass('error');\n\n if (!svgCanvas.setResolution(w, h)) {\n /* await */ $.alert(uiStrings.notification.noContentToFitTo);\n return false;\n }\n\n // Set image save option\n editor.pref('img_save', $('#image_save_opts :checked').val());\n updateCanvas();\n hideDocProperties();\n return true;\n };\n\n /**\n * Save user preferences based on current values in the UI.\n * @function module:SVGEditor.savePreferences\n * @returns {Promise}\n */\n const savePreferences = editor.savePreferences = async function () {\n // Set background\n const color = $('#bg_blocks div.cur_background').data('bgcolor') || '#FFF';\n setBackground(color, $('#canvas_bg_url').val());\n\n // set language\n const lang = $('#lang_select').val();\n if (lang && lang !== editor.pref('lang')) {\n const {langParam, langData} = await editor.putLocale(lang, goodLangs, curConfig);\n await setLang(langParam, langData);\n }\n\n // set icon size\n setIconSize($('#iconsize').val());\n\n // set grid setting\n curConfig.gridSnapping = $('#grid_snapping_on')[0].checked;\n curConfig.snappingStep = $('#grid_snapping_step').val();\n curConfig.gridColor = $('#grid_color').val();\n curConfig.showRulers = $('#show_rulers')[0].checked;\n\n $('#rulers').toggle(curConfig.showRulers);\n if (curConfig.showRulers) { updateRulers(); }\n curConfig.baseUnit = $('#base_unit').val();\n\n svgCanvas.setConfig(curConfig);\n\n updateCanvas();\n hidePreferences();\n };\n\n let resetScrollPos = $.noop;\n\n /**\n *\n * @returns {Promise} Resolves to `undefined`\n */\n const cancelOverlays = async function () {\n $('#dialog_box').hide();\n if (!editingsource && !docprops && !preferences) {\n if (curContext) {\n svgCanvas.leaveContext();\n }\n return;\n }\n\n if (editingsource) {\n if (origSource !== $('#svg_source_textarea').val()) {\n const ok = await $.confirm(uiStrings.notification.QignoreSourceChanges);\n if (ok) {\n hideSourceEditor();\n }\n } else {\n hideSourceEditor();\n }\n } else if (docprops) {\n hideDocProperties();\n } else if (preferences) {\n hidePreferences();\n }\n resetScrollPos();\n };\n\n const winWh = {width: $(window).width(), height: $(window).height()};\n\n // Fix for Issue 781: Drawing area jumps to top-left corner on window resize (IE9)\n if (isIE()) {\n resetScrollPos = function () {\n if (workarea[0].scrollLeft === 0 && workarea[0].scrollTop === 0) {\n workarea[0].scrollLeft = curScrollPos.left;\n workarea[0].scrollTop = curScrollPos.top;\n }\n };\n\n curScrollPos = {\n left: workarea[0].scrollLeft,\n top: workarea[0].scrollTop\n };\n\n $(window).resize(resetScrollPos);\n editor.ready(function () {\n // TODO: Find better way to detect when to do this to minimize\n // flickering effect\n return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new\n setTimeout(function () {\n resetScrollPos();\n resolve();\n }, 500);\n });\n });\n\n workarea.scroll(function () {\n curScrollPos = {\n left: workarea[0].scrollLeft,\n top: workarea[0].scrollTop\n };\n });\n }\n\n $(window).resize(function (evt) {\n $.each(winWh, function (type, val) {\n const curval = $(window)[type]();\n workarea[0]['scroll' + (type === 'width' ? 'Left' : 'Top')] -= (curval - val) / 2;\n winWh[type] = curval;\n });\n setFlyoutPositions();\n });\n\n workarea.scroll(function () {\n // TODO: jQuery's scrollLeft/Top() wouldn't require a null check\n if ($('#ruler_x').length) {\n $('#ruler_x')[0].scrollLeft = workarea[0].scrollLeft;\n }\n if ($('#ruler_y').length) {\n $('#ruler_y')[0].scrollTop = workarea[0].scrollTop;\n }\n });\n\n $('#url_notice').click(function () {\n /* await */ $.alert(this.title);\n });\n\n $('#change_image_url').click(promptImgURL);\n\n // added these event handlers for all the push buttons so they\n // behave more like buttons being pressed-in and not images\n (function () {\n const toolnames = [\n 'clear', 'open', 'save', 'source', 'delete',\n 'delete_multi', 'paste', 'clone', 'clone_multi',\n 'move_top', 'move_bottom'\n ];\n const curClass = 'tool_button_current';\n\n let allTools = '';\n\n $.each(toolnames, function (i, item) {\n allTools += (i ? ',' : '') + '#tool_' + item;\n });\n\n $(allTools).mousedown(function () {\n $(this).addClass(curClass);\n }).bind('mousedown mouseout', function () {\n $(this).removeClass(curClass);\n });\n\n $('#tool_undo, #tool_redo').mousedown(function () {\n if (!$(this).hasClass('disabled')) { $(this).addClass(curClass); }\n }).bind('mousedown mouseout', function () {\n $(this).removeClass(curClass);\n });\n }());\n\n // switch modifier key in tooltips if mac\n // NOTE: This code is not used yet until I can figure out how to successfully bind ctrl/meta\n // in Opera and Chrome\n if (isMac() && !window.opera) {\n const shortcutButtons = [\n 'tool_clear', 'tool_save', 'tool_source',\n 'tool_undo', 'tool_redo', 'tool_clone'\n ];\n let i = shortcutButtons.length;\n while (i--) {\n const button = document.getElementById(shortcutButtons[i]);\n if (button) {\n const {title} = button;\n const index = title.indexOf('Ctrl+');\n button.title = [\n title.substr(0, index),\n 'Cmd+',\n title.substr(index + 5)\n ].join('');\n }\n }\n }\n\n /**\n * @param {external:jQuery} elem\n * @todo Go back to the color boxes having white background-color and then setting\n * background-image to none.png (otherwise partially transparent gradients look weird)\n * @returns {void}\n */\n const colorPicker = function (elem) {\n const picker = elem.attr('id') === 'stroke_color' ? 'stroke' : 'fill';\n // const opacity = (picker == 'stroke' ? $('#stroke_opacity') : $('#fill_opacity'));\n const title = picker === 'stroke'\n ? uiStrings.ui.pick_stroke_paint_opacity\n : uiStrings.ui.pick_fill_paint_opacity;\n // let wasNone = false; // Currently unused\n const pos = elem.offset();\n let {paint} = paintBox[picker];\n $('#color_picker')\n .draggable({\n cancel: '.jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker',\n containment: 'window'\n })\n .css(curConfig.colorPickerCSS || {left: pos.left - 140, bottom: 40})\n .jGraduate(\n {\n paint,\n window: {pickerTitle: title},\n images: {clientPath: curConfig.jGraduatePath},\n newstop: 'inverse'\n },\n function (p) {\n paint = new $.jGraduate.Paint(p);\n paintBox[picker].setPaint(paint);\n svgCanvas.setPaint(picker, paint);\n $('#color_picker').hide();\n },\n function () {\n $('#color_picker').hide();\n }\n );\n };\n\n /**\n * Paint box class.\n */\n class PaintBox {\n /**\n * @param {string|Element|external:jQuery} container\n * @param {\"fill\"} type\n */\n constructor (container, type) {\n const cur = curConfig[type === 'fill' ? 'initFill' : 'initStroke'];\n // set up gradients to be used for the buttons\n const svgdocbox = new DOMParser().parseFromString(\n `\n \n \n `,\n 'text/xml'\n );\n\n let docElem = svgdocbox.documentElement;\n docElem = $(container)[0].appendChild(document.importNode(docElem, true));\n docElem.setAttribute('width', 16.5);\n\n this.rect = docElem.firstElementChild;\n this.defs = docElem.getElementsByTagName('defs')[0];\n this.grad = this.defs.firstElementChild;\n this.paint = new $.jGraduate.Paint({solidColor: cur.color});\n this.type = type;\n }\n\n /**\n * @param {module:jGraduate~Paint} paint\n * @param {boolean} apply\n * @returns {void}\n */\n setPaint (paint, apply) {\n this.paint = paint;\n\n const ptype = paint.type;\n const opac = paint.alpha / 100;\n\n let fillAttr = 'none';\n switch (ptype) {\n case 'solidColor':\n fillAttr = (paint[ptype] !== 'none') ? '#' + paint[ptype] : paint[ptype];\n break;\n case 'linearGradient':\n case 'radialGradient': {\n this.grad.remove();\n this.grad = this.defs.appendChild(paint[ptype]);\n const id = this.grad.id = 'gradbox_' + this.type;\n fillAttr = 'url(#' + id + ')';\n break;\n }\n }\n\n this.rect.setAttribute('fill', fillAttr);\n this.rect.setAttribute('opacity', opac);\n\n if (apply) {\n svgCanvas.setColor(this.type, this._paintColor, true);\n svgCanvas.setPaintOpacity(this.type, this._paintOpacity, true);\n }\n }\n\n /**\n * @param {boolean} apply\n * @returns {void}\n */\n update (apply) {\n if (!selectedElement) { return; }\n\n const {type} = this;\n switch (selectedElement.tagName) {\n case 'use':\n case 'image':\n case 'foreignObject':\n // These elements don't have fill or stroke, so don't change\n // the current value\n return;\n case 'g':\n case 'a': {\n const childs = selectedElement.getElementsByTagName('*');\n\n let gPaint = null;\n for (let i = 0, len = childs.length; i < len; i++) {\n const elem = childs[i];\n const p = elem.getAttribute(type);\n if (i === 0) {\n gPaint = p;\n } else if (gPaint !== p) {\n gPaint = null;\n break;\n }\n }\n\n if (gPaint === null) {\n // No common color, don't update anything\n this._paintColor = null;\n return;\n }\n this._paintColor = gPaint;\n this._paintOpacity = 1;\n break;\n } default: {\n this._paintOpacity = Number.parseFloat(selectedElement.getAttribute(type + '-opacity'));\n if (Number.isNaN(this._paintOpacity)) {\n this._paintOpacity = 1.0;\n }\n\n const defColor = type === 'fill' ? 'black' : 'none';\n this._paintColor = selectedElement.getAttribute(type) || defColor;\n }\n }\n\n if (apply) {\n svgCanvas.setColor(type, this._paintColor, true);\n svgCanvas.setPaintOpacity(type, this._paintOpacity, true);\n }\n\n this._paintOpacity *= 100;\n\n const paint = getPaint(this._paintColor, this._paintOpacity, type);\n // update the rect inside #fill_color/#stroke_color\n this.setPaint(paint);\n }\n\n /**\n * @returns {void}\n */\n prep () {\n const ptype = this.paint.type;\n\n switch (ptype) {\n case 'linearGradient':\n case 'radialGradient': {\n const paint = new $.jGraduate.Paint({copy: this.paint});\n svgCanvas.setPaint(this.type, paint);\n break;\n }\n }\n }\n }\n PaintBox.ctr = 0;\n\n paintBox.fill = new PaintBox('#fill_color', 'fill');\n paintBox.stroke = new PaintBox('#stroke_color', 'stroke');\n\n $('#stroke_width').val(curConfig.initStroke.width);\n $('#group_opacity').val(curConfig.initOpacity * 100);\n\n // Use this SVG elem to test vectorEffect support\n const testEl = paintBox.fill.rect.cloneNode(false);\n testEl.setAttribute('style', 'vector-effect:non-scaling-stroke');\n const supportsNonSS = (testEl.style.vectorEffect === 'non-scaling-stroke');\n testEl.removeAttribute('style');\n const svgdocbox = paintBox.fill.rect.ownerDocument;\n // Use this to test support for blur element. Seems to work to test support in Webkit\n const blurTest = svgdocbox.createElementNS(NS.SVG, 'feGaussianBlur');\n if (blurTest.stdDeviationX === undefined) {\n $('#tool_blur').hide();\n }\n $(blurTest).remove();\n\n // Test for zoom icon support\n (function () {\n const pre = '-' + uaPrefix.toLowerCase() + '-zoom-';\n const zoom = pre + 'in';\n workarea.css('cursor', zoom);\n if (workarea.css('cursor') === zoom) {\n zoomInIcon = zoom;\n zoomOutIcon = pre + 'out';\n }\n workarea.css('cursor', 'auto');\n }());\n\n // Test for embedImage support (use timeout to not interfere with page load)\n setTimeout(function () {\n svgCanvas.embedImage('images/logo.png', function (datauri) {\n if (!datauri) {\n // Disable option\n $('#image_save_opts [value=embed]').attr('disabled', 'disabled');\n $('#image_save_opts input').val(['ref']);\n editor.pref('img_save', 'ref');\n $('#image_opt_embed').css('color', '#666').attr(\n 'title',\n uiStrings.notification.featNotSupported\n );\n }\n });\n }, 1000);\n\n $('#fill_color, #tool_fill .icon_label').click(function () {\n colorPicker($('#fill_color'));\n updateToolButtonState();\n });\n\n $('#stroke_color, #tool_stroke .icon_label').click(function () {\n colorPicker($('#stroke_color'));\n updateToolButtonState();\n });\n\n $('#group_opacityLabel').click(function () {\n $('#opacity_dropdown button').mousedown();\n $(window).mouseup();\n });\n\n $('#zoomLabel').click(function () {\n $('#zoom_dropdown button').mousedown();\n $(window).mouseup();\n });\n\n $('#tool_move_top').mousedown(function (evt) {\n $('#tools_stacking').show();\n evt.preventDefault();\n });\n\n $('.layer_button').mousedown(function () {\n $(this).addClass('layer_buttonpressed');\n }).mouseout(function () {\n $(this).removeClass('layer_buttonpressed');\n }).mouseup(function () {\n $(this).removeClass('layer_buttonpressed');\n });\n\n $('.push_button').mousedown(function () {\n if (!$(this).hasClass('disabled')) {\n $(this).addClass('push_button_pressed').removeClass('push_button');\n }\n }).mouseout(function () {\n $(this).removeClass('push_button_pressed').addClass('push_button');\n }).mouseup(function () {\n $(this).removeClass('push_button_pressed').addClass('push_button');\n });\n\n // ask for a layer name\n $('#layer_new').click(async function () {\n let uniqName,\n i = svgCanvas.getCurrentDrawing().getNumLayers();\n do {\n uniqName = uiStrings.layers.layer + ' ' + (++i);\n } while (svgCanvas.getCurrentDrawing().hasLayer(uniqName));\n\n const newName = await $.prompt(uiStrings.notification.enterUniqueLayerName, uniqName);\n if (!newName) { return; }\n if (svgCanvas.getCurrentDrawing().hasLayer(newName)) {\n /* await */ $.alert(uiStrings.notification.dupeLayerName);\n return;\n }\n svgCanvas.createLayer(newName);\n updateContextPanel();\n populateLayers();\n });\n\n /**\n *\n * @returns {void}\n */\n function deleteLayer () {\n if (svgCanvas.deleteCurrentLayer()) {\n updateContextPanel();\n populateLayers();\n // This matches what SvgCanvas does\n // TODO: make this behavior less brittle (svg-editor should get which\n // layer is selected from the canvas and then select that one in the UI)\n $('#layerlist tr.layer').removeClass('layersel');\n $('#layerlist tr.layer:first').addClass('layersel');\n }\n }\n\n /**\n *\n * @returns {Promise}\n */\n async function cloneLayer () {\n const name = svgCanvas.getCurrentDrawing().getCurrentLayerName() + ' copy';\n\n const newName = await $.prompt(uiStrings.notification.enterUniqueLayerName, name);\n if (!newName) { return; }\n if (svgCanvas.getCurrentDrawing().hasLayer(newName)) {\n /* await */ $.alert(uiStrings.notification.dupeLayerName);\n return;\n }\n svgCanvas.cloneLayer(newName);\n updateContextPanel();\n populateLayers();\n }\n\n /**\n *\n * @returns {void}\n */\n function mergeLayer () {\n if ($('#layerlist tr.layersel').index() === svgCanvas.getCurrentDrawing().getNumLayers() - 1) {\n return;\n }\n svgCanvas.mergeLayer();\n updateContextPanel();\n populateLayers();\n }\n\n /**\n * @param {Integer} pos\n * @returns {void}\n */\n function moveLayer (pos) {\n const total = svgCanvas.getCurrentDrawing().getNumLayers();\n\n let curIndex = $('#layerlist tr.layersel').index();\n if (curIndex > 0 || curIndex < total - 1) {\n curIndex += pos;\n svgCanvas.setCurrentLayerPosition(total - curIndex - 1);\n populateLayers();\n }\n }\n\n $('#layer_delete').click(deleteLayer);\n\n $('#layer_up').click(() => {\n moveLayer(-1);\n });\n\n $('#layer_down').click(() => {\n moveLayer(1);\n });\n\n $('#layer_rename').click(async function () {\n // const curIndex = $('#layerlist tr.layersel').prevAll().length; // Currently unused\n const oldName = $('#layerlist tr.layersel td.layername').text();\n const newName = await $.prompt(uiStrings.notification.enterNewLayerName, '');\n if (!newName) { return; }\n if (oldName === newName || svgCanvas.getCurrentDrawing().hasLayer(newName)) {\n /* await */ $.alert(uiStrings.notification.layerHasThatName);\n return;\n }\n\n svgCanvas.renameCurrentLayer(newName);\n populateLayers();\n });\n\n const SIDEPANEL_MAXWIDTH = 300;\n const SIDEPANEL_OPENWIDTH = 150;\n let sidedrag = -1, sidedragging = false, allowmove = false;\n\n /**\n * @param {Float} delta\n * @fires module:svgcanvas.SvgCanvas#event:ext_workareaResized\n * @returns {void}\n */\n const changeSidePanelWidth = function (delta) {\n const rulerX = $('#ruler_x');\n $('#sidepanels').width('+=' + delta);\n $('#layerpanel').width('+=' + delta);\n rulerX.css('right', Number.parseInt(rulerX.css('right')) + delta);\n workarea.css('right', Number.parseInt(workarea.css('right')) + delta);\n svgCanvas.runExtensions('workareaResized');\n };\n\n /**\n * @param {Event} evt\n * @returns {void}\n */\n const resizeSidePanel = function (evt) {\n if (!allowmove) { return; }\n if (sidedrag === -1) { return; }\n sidedragging = true;\n let deltaX = sidedrag - evt.pageX;\n const sideWidth = $('#sidepanels').width();\n if (sideWidth + deltaX > SIDEPANEL_MAXWIDTH) {\n deltaX = SIDEPANEL_MAXWIDTH - sideWidth;\n // sideWidth = SIDEPANEL_MAXWIDTH;\n } else if (sideWidth + deltaX < 2) {\n deltaX = 2 - sideWidth;\n // sideWidth = 2;\n }\n if (deltaX === 0) { return; }\n sidedrag -= deltaX;\n changeSidePanelWidth(deltaX);\n };\n\n /**\n * If width is non-zero, then fully close it; otherwise fully open it.\n * @param {boolean} close Forces the side panel closed\n * @returns {void}\n */\n const toggleSidePanel = function (close) {\n const dpr = window.devicePixelRatio || 1;\n const w = $('#sidepanels').width();\n const isOpened = (dpr < 1 ? w : w / dpr) > 2;\n const zoomAdjustedSidepanelWidth = (dpr < 1 ? 1 : dpr) * SIDEPANEL_OPENWIDTH;\n const deltaX = (isOpened || close ? 0 : zoomAdjustedSidepanelWidth) - w;\n changeSidePanelWidth(deltaX);\n };\n\n $('#sidepanel_handle')\n .mousedown(function (evt) {\n sidedrag = evt.pageX;\n $(window).mousemove(resizeSidePanel);\n allowmove = false;\n // Silly hack for Chrome, which always runs mousemove right after mousedown\n setTimeout(function () {\n allowmove = true;\n }, 20);\n })\n .mouseup(function (evt) {\n if (!sidedragging) { toggleSidePanel(); }\n sidedrag = -1;\n sidedragging = false;\n });\n\n $(window).mouseup(function () {\n sidedrag = -1;\n sidedragging = false;\n $('#svg_editor').unbind('mousemove', resizeSidePanel);\n });\n\n populateLayers();\n\n // function changeResolution (x,y) {\n // const {zoom} = svgCanvas.getResolution();\n // setResolution(x * zoom, y * zoom);\n // }\n\n const centerCanvas = () => {\n // this centers the canvas vertically in the workarea (horizontal handled in CSS)\n workarea.css('line-height', workarea.height() + 'px');\n };\n\n $(window).bind('load resize', centerCanvas);\n\n /**\n * @type {module:jQuerySpinButton.StepCallback}\n */\n function stepFontSize (elem, step) {\n const origVal = Number(elem.value);\n const sugVal = origVal + step;\n const increasing = sugVal >= origVal;\n if (step === 0) { return origVal; }\n\n if (origVal >= 24) {\n if (increasing) {\n return Math.round(origVal * 1.1);\n }\n return Math.round(origVal / 1.1);\n }\n if (origVal <= 1) {\n if (increasing) {\n return origVal * 2;\n }\n return origVal / 2;\n }\n return sugVal;\n }\n\n /**\n * @type {module:jQuerySpinButton.StepCallback}\n */\n function stepZoom (elem, step) {\n const origVal = Number(elem.value);\n if (origVal === 0) { return 100; }\n const sugVal = origVal + step;\n if (step === 0) { return origVal; }\n\n if (origVal >= 100) {\n return sugVal;\n }\n if (sugVal >= origVal) {\n return origVal * 2;\n }\n return origVal / 2;\n }\n\n // function setResolution (w, h, center) {\n // updateCanvas();\n // // w -= 0; h -= 0;\n // // $('#svgcanvas').css({width: w, height: h});\n // // $('#canvas_width').val(w);\n // // $('#canvas_height').val(h);\n // //\n // // if (center) {\n // // const wArea = workarea;\n // // const scrollY = h/2 - wArea.height()/2;\n // // const scrollX = w/2 - wArea.width()/2;\n // // wArea[0].scrollTop = scrollY;\n // // wArea[0].scrollLeft = scrollX;\n // // }\n // }\n\n $('#resolution').change(function () {\n const wh = $('#canvas_width,#canvas_height');\n if (!this.selectedIndex) {\n if ($('#canvas_width').val() === 'fit') {\n wh.removeAttr('disabled').val(100);\n }\n } else if (this.value === 'content') {\n wh.val('fit').attr('disabled', 'disabled');\n } else {\n const dims = this.value.split('x');\n $('#canvas_width').val(dims[0]);\n $('#canvas_height').val(dims[1]);\n wh.removeAttr('disabled');\n }\n });\n\n // Prevent browser from erroneously repopulating fields\n $('input,select').attr('autocomplete', 'off');\n\n const dialogSelectors = [\n '#tool_source_cancel', '#tool_docprops_cancel',\n '#tool_prefs_cancel', '.overlay'\n ];\n /* eslint-disable jsdoc/require-property */\n /**\n * Associate all button actions as well as non-button keyboard shortcuts.\n * @namespace {PlainObject} module:SVGEditor~Actions\n */\n const Actions = (function () {\n /* eslint-enable jsdoc/require-property */\n /**\n * @typedef {PlainObject} module:SVGEditor.ToolButton\n * @property {string} sel The CSS selector for the tool\n * @property {external:jQuery.Function} fn A handler to be attached to the `evt`\n * @property {string} evt The event for which the `fn` listener will be added\n * @property {module:SVGEditor.Key} [key] [key, preventDefault, NoDisableInInput]\n * @property {string} [parent] Selector\n * @property {boolean} [hidekey] Whether to show key value in title\n * @property {string} [icon] The button ID\n * @property {boolean} isDefault For flyout holders\n */\n /**\n *\n * @name module:SVGEditor~ToolButtons\n * @type {module:SVGEditor.ToolButton[]}\n */\n const toolButtons = [\n {sel: '#tool_select', fn: clickSelect, evt: 'click', key: ['V', true]},\n {sel: '#tool_fhpath', fn: clickFHPath, evt: 'click', key: ['Q', true]},\n {sel: '#tool_line', fn: clickLine, evt: 'click', key: ['L', true],\n parent: '#tools_line', prepend: true},\n {sel: '#tool_rect', fn: clickRect, evt: 'mouseup',\n key: ['R', true], parent: '#tools_rect', icon: 'rect'},\n {sel: '#tool_square', fn: clickSquare, evt: 'mouseup',\n parent: '#tools_rect', icon: 'square'},\n {sel: '#tool_fhrect', fn: clickFHRect, evt: 'mouseup',\n parent: '#tools_rect', icon: 'fh_rect'},\n {sel: '#tool_ellipse', fn: clickEllipse, evt: 'mouseup',\n key: ['E', true], parent: '#tools_ellipse', icon: 'ellipse'},\n {sel: '#tool_circle', fn: clickCircle, evt: 'mouseup',\n parent: '#tools_ellipse', icon: 'circle'},\n {sel: '#tool_fhellipse', fn: clickFHEllipse, evt: 'mouseup',\n parent: '#tools_ellipse', icon: 'fh_ellipse'},\n {sel: '#tool_path', fn: clickPath, evt: 'click', key: ['P', true]},\n {sel: '#tool_text', fn: clickText, evt: 'click', key: ['T', true]},\n {sel: '#tool_image', fn: clickImage, evt: 'mouseup'},\n {sel: '#tool_zoom', fn: clickZoom, evt: 'mouseup', key: ['Z', true]},\n {sel: '#tool_clear', fn: clickClear, evt: 'mouseup', key: ['N', true]},\n {sel: '#tool_save', fn () {\n if (editingsource) {\n saveSourceEditor();\n } else {\n clickSave();\n }\n }, evt: 'mouseup', key: ['S', true]},\n {sel: '#tool_export', fn: clickExport, evt: 'mouseup'},\n {sel: '#tool_open', fn: clickOpen, evt: 'mouseup', key: ['O', true]},\n {sel: '#tool_import', fn: clickImport, evt: 'mouseup'},\n {sel: '#tool_source', fn: showSourceEditor, evt: 'click', key: ['U', true]},\n {sel: '#tool_wireframe', fn: clickWireframe, evt: 'click', key: ['F', true]},\n {\n key: ['esc', false, false],\n fn () {\n if (dialogSelectors.every((sel) => {\n return $(sel + ':hidden').length;\n })) {\n svgCanvas.clearSelection();\n }\n },\n hidekey: true\n },\n {sel: dialogSelectors.join(','), fn: cancelOverlays, evt: 'click',\n key: ['esc', false, false], hidekey: true},\n {sel: '#tool_source_save', fn: saveSourceEditor, evt: 'click'},\n {sel: '#tool_docprops_save', fn: saveDocProperties, evt: 'click'},\n {sel: '#tool_docprops', fn: showDocProperties, evt: 'click'},\n {sel: '#tool_prefs_save', fn: savePreferences, evt: 'click'},\n {sel: '#tool_editor_prefs', fn: showPreferences, evt: 'click'},\n {sel: '#tool_editor_homepage', fn: openHomePage, evt: 'click'},\n {sel: '#tool_open', fn () { window.dispatchEvent(new CustomEvent('openImage')); }, evt: 'click'},\n {sel: '#tool_import', fn () { window.dispatchEvent(new CustomEvent('importImage')); }, evt: 'click'},\n {sel: '#tool_delete,#tool_delete_multi', fn: deleteSelected,\n evt: 'click', key: ['del/backspace', true]},\n {sel: '#tool_reorient', fn: reorientPath, evt: 'click'},\n {sel: '#tool_node_link', fn: linkControlPoints, evt: 'click'},\n {sel: '#tool_node_clone', fn: clonePathNode, evt: 'click'},\n {sel: '#tool_node_delete', fn: deletePathNode, evt: 'click'},\n {sel: '#tool_openclose_path', fn: opencloseSubPath, evt: 'click'},\n {sel: '#tool_add_subpath', fn: addSubPath, evt: 'click'},\n {sel: '#tool_move_top', fn: moveToTopSelected, evt: 'click', key: 'ctrl+shift+]'},\n {sel: '#tool_move_bottom', fn: moveToBottomSelected, evt: 'click', key: 'ctrl+shift+['},\n {sel: '#tool_topath', fn: convertToPath, evt: 'click'},\n {sel: '#tool_make_link,#tool_make_link_multi', fn: makeHyperlink, evt: 'click'},\n {sel: '#tool_undo', fn: clickUndo, evt: 'click'},\n {sel: '#tool_redo', fn: clickRedo, evt: 'click'},\n {sel: '#tool_clone,#tool_clone_multi', fn: clickClone, evt: 'click', key: ['D', true]},\n {sel: '#tool_group_elements', fn: clickGroup, evt: 'click', key: ['G', true]},\n {sel: '#tool_ungroup', fn: clickGroup, evt: 'click'},\n {sel: '#tool_unlink_use', fn: clickGroup, evt: 'click'},\n {sel: '[id^=tool_align]', fn: clickAlign, evt: 'click'},\n // these two lines are required to make Opera work properly with the flyout mechanism\n // {sel: '#tools_rect_show', fn: clickRect, evt: 'click'},\n // {sel: '#tools_ellipse_show', fn: clickEllipse, evt: 'click'},\n {sel: '#tool_bold', fn: clickBold, evt: 'mousedown'},\n {sel: '#tool_italic', fn: clickItalic, evt: 'mousedown'},\n {sel: '#sidepanel_handle', fn: toggleSidePanel, key: ['X']},\n {sel: '#copy_save_done', fn: cancelOverlays, evt: 'click'},\n\n // Shortcuts not associated with buttons\n\n {key: 'ctrl+left', fn () { rotateSelected(0, 1); }},\n {key: 'ctrl+right', fn () { rotateSelected(1, 1); }},\n {key: 'ctrl+shift+left', fn () { rotateSelected(0, 5); }},\n {key: 'ctrl+shift+right', fn () { rotateSelected(1, 5); }},\n {key: 'shift+O', fn: selectPrev},\n {key: 'shift+P', fn: selectNext},\n {key: [modKey + 'up', true], fn () { zoomImage(2); }},\n {key: [modKey + 'down', true], fn () { zoomImage(0.5); }},\n {key: [modKey + ']', true], fn () { moveUpDownSelected('Up'); }},\n {key: [modKey + '[', true], fn () { moveUpDownSelected('Down'); }},\n {key: ['up', true], fn () { moveSelected(0, -1); }},\n {key: ['down', true], fn () { moveSelected(0, 1); }},\n {key: ['left', true], fn () { moveSelected(-1, 0); }},\n {key: ['right', true], fn () { moveSelected(1, 0); }},\n {key: 'shift+up', fn () { moveSelected(0, -10); }},\n {key: 'shift+down', fn () { moveSelected(0, 10); }},\n {key: 'shift+left', fn () { moveSelected(-10, 0); }},\n {key: 'shift+right', fn () { moveSelected(10, 0); }},\n {key: ['alt+up', true], fn () { svgCanvas.cloneSelectedElements(0, -1); }},\n {key: ['alt+down', true], fn () { svgCanvas.cloneSelectedElements(0, 1); }},\n {key: ['alt+left', true], fn () { svgCanvas.cloneSelectedElements(-1, 0); }},\n {key: ['alt+right', true], fn () { svgCanvas.cloneSelectedElements(1, 0); }},\n {key: ['alt+shift+up', true], fn () { svgCanvas.cloneSelectedElements(0, -10); }},\n {key: ['alt+shift+down', true], fn () { svgCanvas.cloneSelectedElements(0, 10); }},\n {key: ['alt+shift+left', true], fn () { svgCanvas.cloneSelectedElements(-10, 0); }},\n {key: ['alt+shift+right', true], fn () { svgCanvas.cloneSelectedElements(10, 0); }},\n {key: 'a', fn () { svgCanvas.selectAllInCurrentLayer(); }},\n {key: modKey + 'a', fn () { svgCanvas.selectAllInCurrentLayer(); }},\n\n // Standard shortcuts\n {key: modKey + 'z', fn: clickUndo},\n {key: modKey + 'shift+z', fn: clickRedo},\n {key: modKey + 'y', fn: clickRedo},\n\n {key: modKey + 'x', fn: cutSelected},\n {key: modKey + 'c', fn: copySelected},\n {key: modKey + 'v', fn: pasteInCenter}\n ];\n\n // Tooltips not directly associated with a single function\n const keyAssocs = {\n '4/Shift+4': '#tools_rect_show',\n '5/Shift+5': '#tools_ellipse_show'\n };\n\n return {\n /** @lends module:SVGEditor~Actions */\n /**\n * @returns {void}\n */\n setAll () {\n const flyouts = {};\n const keyHandler = {}; // will contain the action for each pressed key\n\n toolButtons.forEach((opts) => {\n // Bind function to button\n let btn;\n if (opts.sel) {\n btn = $q(opts.sel);\n if (btn === null) { return true; } // Skip if markup does not exist\n if (opts.evt) {\n // `touch.js` changes `touchstart` to `mousedown`,\n // so we must map tool button click events as well\n if (isTouch() && opts.evt === 'click') {\n opts.evt = 'mousedown';\n }\n btn.addEventListener(opts.evt, opts.fn);\n }\n\n // Add to parent flyout menu, if able to be displayed\n if (opts.parent && $(opts.parent + '_show').length) {\n let fH = $(opts.parent);\n if (!fH.length) {\n fH = makeFlyoutHolder(opts.parent.substr(1));\n }\n if (opts.prepend) {\n btn.style.margin = 'initial';\n }\n fH[opts.prepend ? 'prepend' : 'append'](btn);\n\n if (!Array.isArray(flyouts[opts.parent])) {\n flyouts[opts.parent] = [];\n }\n flyouts[opts.parent].push(opts);\n }\n }\n\n // Bind function to shortcut key\n if (opts.key) {\n // Set shortcut based on options\n let keyval = opts.key;\n let pd = false;\n if (Array.isArray(opts.key)) {\n keyval = opts.key[0];\n if (opts.key.length > 1) { pd = opts.key[1]; }\n }\n keyval = String(keyval);\n const {fn} = opts;\n keyval.split('/').forEach((key) => { keyHandler[key] = {fn, pd}; });\n\n // Put shortcut in title\n if (opts.sel && !opts.hidekey && btn.title) {\n const newTitle = `${btn.title.split('[')[0]} (${keyval})`;\n keyAssocs[keyval] = opts.sel;\n // Disregard for menu items\n if (btn.closest('#main_menu') === null) {\n btn.title = newTitle;\n }\n }\n }\n return true;\n });\n // register the keydown event\n document.addEventListener('keydown', (e) => {\n // only track keyboard shortcuts for the body containing the SVG-Editor\n if (e.target.nodeName !== 'BODY') return;\n // normalize key\n const key = `${(e.metaKey) ? 'meta+' : ''}${(e.ctrlKey) ? 'ctrl+' : ''}${e.key.toLowerCase()}`;\n // return if no shortcut defined for this key\n if (!keyHandler[key]) return;\n // launch associated handler and preventDefault if necessary\n keyHandler[key].fn();\n if (keyHandler[key].pd) {\n e.preventDefault();\n }\n });\n\n // Setup flyouts\n setupFlyouts(flyouts);\n\n // Misc additional actions\n\n // Make 'return' keypress trigger the change event\n $('.attr_changer, #image_url').bind(\n 'keydown',\n 'return',\n function (evt) {\n $(this).change();\n evt.preventDefault();\n }\n );\n\n $(window).bind('keydown', 'tab', function (e) {\n if (uiContext === 'canvas') {\n e.preventDefault();\n selectNext();\n }\n }).bind('keydown', 'shift+tab', function (e) {\n if (uiContext === 'canvas') {\n e.preventDefault();\n selectPrev();\n }\n });\n\n $('#tool_zoom').dblclick(dblclickZoom);\n },\n /**\n * @returns {void}\n */\n setTitles () {\n $.each(keyAssocs, function (keyval, sel) {\n const menu = ($(sel).parents('#main_menu').length);\n\n $(sel).each(function () {\n let t;\n if (menu) {\n t = $(this).text().split(' [')[0];\n } else {\n t = this.title.split(' [')[0];\n }\n let keyStr = '';\n // Shift+Up\n $.each(keyval.split('/'), function (i, key) {\n const modBits = key.split('+');\n let mod = '';\n if (modBits.length > 1) {\n mod = modBits[0] + '+';\n key = modBits[1];\n }\n keyStr += (i ? '/' : '') + mod + (uiStrings['key_' + key] || key);\n });\n if (menu) {\n this.lastChild.textContent = t + ' [' + keyStr + ']';\n } else {\n this.title = t + ' [' + keyStr + ']';\n }\n });\n });\n },\n /**\n * @param {string} sel Selector to match\n * @returns {module:SVGEditor.ToolButton}\n */\n getButtonData (sel) {\n return Object.values(toolButtons).find((btn) => {\n return btn.sel === sel;\n });\n }\n };\n }());\n\n // Select given tool\n editor.ready(function () {\n let tool;\n const itool = curConfig.initTool,\n container = $('#tools_left, #svg_editor .tools_flyout'),\n preTool = container.find('#tool_' + itool),\n regTool = container.find('#' + itool);\n if (preTool.length) {\n tool = preTool;\n } else if (regTool.length) {\n tool = regTool;\n } else {\n tool = $('#tool_select');\n }\n tool.click().mouseup();\n\n if (curConfig.wireframe) {\n $('#tool_wireframe').click();\n }\n\n if (curConfig.showlayers) {\n toggleSidePanel();\n }\n\n $('#rulers').toggle(Boolean(curConfig.showRulers));\n\n if (curConfig.showRulers) {\n $('#show_rulers')[0].checked = true;\n }\n\n if (curConfig.baseUnit) {\n $('#base_unit').val(curConfig.baseUnit);\n }\n\n if (curConfig.gridSnapping) {\n $('#grid_snapping_on')[0].checked = true;\n }\n\n if (curConfig.snappingStep) {\n $('#grid_snapping_step').val(curConfig.snappingStep);\n }\n\n if (curConfig.gridColor) {\n $('#grid_color').val(curConfig.gridColor);\n }\n });\n\n // init SpinButtons\n $('#rect_rx').SpinButton({\n min: 0, max: 1000, stateObj, callback: changeRectRadius\n });\n $('#stroke_width').SpinButton({\n min: 0, max: 99, smallStep: 0.1, stateObj, callback: changeStrokeWidth\n });\n $('#angle').SpinButton({\n min: -180, max: 180, step: 5, stateObj, callback: changeRotationAngle\n });\n $('#font_size').SpinButton({\n min: 0.001, stepfunc: stepFontSize, stateObj, callback: changeFontSize\n });\n $('#group_opacity').SpinButton({\n min: 0, max: 100, step: 5, stateObj, callback: changeOpacity\n });\n $('#blur').SpinButton({\n min: 0, max: 10, step: 0.1, stateObj, callback: changeBlur\n });\n $('#zoom').SpinButton({\n min: 0.001, max: 10000, step: 50, stepfunc: stepZoom,\n stateObj, callback: changeZoom\n // Set default zoom\n }).val(\n svgCanvas.getZoom() * 100\n );\n\n $('#workarea').contextMenu(\n {\n menu: 'cmenu_canvas',\n inSpeed: 0\n },\n function (action, el, pos) {\n switch (action) {\n case 'delete':\n deleteSelected();\n break;\n case 'cut':\n cutSelected();\n break;\n case 'copy':\n copySelected();\n break;\n case 'paste':\n svgCanvas.pasteElements();\n break;\n case 'paste_in_place':\n svgCanvas.pasteElements('in_place');\n break;\n case 'group':\n case 'group_elements':\n svgCanvas.groupSelectedElements();\n break;\n case 'ungroup':\n svgCanvas.ungroupSelectedElement();\n break;\n case 'move_front':\n moveToTopSelected();\n break;\n case 'move_up':\n moveUpDownSelected('Up');\n break;\n case 'move_down':\n moveUpDownSelected('Down');\n break;\n case 'move_back':\n moveToBottomSelected();\n break;\n default:\n if (hasCustomHandler(action)) {\n getCustomHandler(action).call();\n }\n break;\n }\n }\n );\n\n /**\n * Implements {@see module:jQueryContextMenu.jQueryContextMenuListener}.\n * @param {\"dupe\"|\"delete\"|\"merge_down\"|\"merge_all\"} action\n * @param {external:jQuery} el\n * @param {{x: Float, y: Float, docX: Float, docY: Float}} pos\n * @returns {void}\n */\n const lmenuFunc = function (action, el, pos) {\n switch (action) {\n case 'dupe':\n /* await */ cloneLayer();\n break;\n case 'delete':\n deleteLayer();\n break;\n case 'merge_down':\n mergeLayer();\n break;\n case 'merge_all':\n svgCanvas.mergeAllLayers();\n updateContextPanel();\n populateLayers();\n break;\n }\n };\n\n $('#layerlist').contextMenu(\n {\n menu: 'cmenu_layers',\n inSpeed: 0\n },\n lmenuFunc\n );\n\n $('#layer_moreopts').contextMenu(\n {\n menu: 'cmenu_layers',\n inSpeed: 0,\n allowLeft: true\n },\n lmenuFunc\n );\n\n $('.contextMenu li').mousedown(function (ev) {\n ev.preventDefault();\n });\n\n $('#cmenu_canvas li').disableContextMenu();\n canvMenu.enableContextMenuItems('#delete,#cut,#copy');\n\n /**\n * @returns {void}\n */\n function enableOrDisableClipboard () {\n let svgeditClipboard;\n try {\n svgeditClipboard = localStorage.getItem('svgedit_clipboard');\n } catch (err) {}\n canvMenu[(svgeditClipboard ? 'en' : 'dis') + 'ableContextMenuItems'](\n '#paste,#paste_in_place'\n );\n }\n enableOrDisableClipboard();\n\n window.addEventListener('storage', function (e) {\n if (e.key !== 'svgedit_clipboard') { return; }\n\n enableOrDisableClipboard();\n });\n\n window.addEventListener('beforeunload', function (e) {\n // Suppress warning if page is empty\n if (undoMgr.getUndoStackSize() === 0) {\n editor.showSaveWarning = false;\n }\n\n // showSaveWarning is set to 'false' when the page is saved.\n if (!curConfig.no_save_warning && editor.showSaveWarning) {\n // Browser already asks question about closing the page\n e.returnValue = uiStrings.notification.unsavedChanges; // Firefox needs this when beforeunload set by addEventListener (even though message is not used)\n return uiStrings.notification.unsavedChanges;\n }\n return true;\n });\n\n /**\n * Expose the `uiStrings`.\n * @function module:SVGEditor.canvas.getUIStrings\n * @returns {module:SVGEditor.uiStrings}\n */\n editor.canvas.getUIStrings = function () {\n return uiStrings;\n };\n\n /**\n * @function module:SVGEditor.openPrep\n * @returns {boolean|Promise} Resolves to boolean indicating `true` if there were no changes\n * and `false` after the user confirms.\n */\n editor.openPrep = function () {\n $('#main_menu').hide();\n if (undoMgr.getUndoStackSize() === 0) {\n return true;\n }\n return $.confirm(uiStrings.notification.QwantToOpen);\n };\n\n /**\n *\n * @param {Event} e\n * @returns {void}\n */\n function onDragEnter (e) {\n e.stopPropagation();\n e.preventDefault();\n // and indicator should be displayed here, such as \"drop files here\"\n }\n\n /**\n *\n * @param {Event} e\n * @returns {void}\n */\n function onDragOver (e) {\n e.stopPropagation();\n e.preventDefault();\n }\n\n /**\n *\n * @param {Event} e\n * @returns {void}\n */\n function onDragLeave (e) {\n e.stopPropagation();\n e.preventDefault();\n // hypothetical indicator should be removed here\n }\n // Use HTML5 File API: http://www.w3.org/TR/FileAPI/\n // if browser has HTML5 File API support, then we will show the open menu item\n // and provide a file input to click. When that change event fires, it will\n // get the text contents of the file and send it to the canvas\n if (window.FileReader) {\n /**\n * @param {Event} e\n * @returns {void}\n */\n const importImage = function (e) {\n $.process_cancel(uiStrings.notification.loadingImage);\n e.stopPropagation();\n e.preventDefault();\n $('#main_menu').hide();\n const file = (e.type === 'drop') ? e.dataTransfer.files[0] : this.files[0];\n if (!file) {\n $('#dialog_box').hide();\n return;\n }\n /* if (file.type === 'application/pdf') { // Todo: Handle PDF imports\n\n }\n else */\n if (!file.type.includes('image')) {\n return;\n }\n // Detected an image\n // svg handling\n let reader;\n if (file.type.includes('svg')) {\n reader = new FileReader();\n reader.onloadend = function (ev) {\n const newElement = svgCanvas.importSvgString(ev.target.result, true);\n svgCanvas.ungroupSelectedElement();\n svgCanvas.ungroupSelectedElement();\n svgCanvas.groupSelectedElements();\n svgCanvas.alignSelectedElements('m', 'page');\n svgCanvas.alignSelectedElements('c', 'page');\n // highlight imported element, otherwise we get strange empty selectbox\n svgCanvas.selectOnly([newElement]);\n $('#dialog_box').hide();\n };\n reader.readAsText(file);\n } else {\n // bitmap handling\n reader = new FileReader();\n reader.onloadend = function ({target: {result}}) {\n /**\n * Insert the new image until we know its dimensions.\n * @param {Float} width\n * @param {Float} height\n * @returns {void}\n */\n const insertNewImage = function (width, height) {\n const newImage = svgCanvas.addSVGElementFromJson({\n element: 'image',\n attr: {\n x: 0,\n y: 0,\n width,\n height,\n id: svgCanvas.getNextId(),\n style: 'pointer-events:inherit'\n }\n });\n svgCanvas.setHref(newImage, result);\n svgCanvas.selectOnly([newImage]);\n svgCanvas.alignSelectedElements('m', 'page');\n svgCanvas.alignSelectedElements('c', 'page');\n updateContextPanel();\n $('#dialog_box').hide();\n };\n // create dummy img so we know the default dimensions\n let imgWidth = 100;\n let imgHeight = 100;\n const img = new Image();\n img.style.opacity = 0;\n img.addEventListener('load', function () {\n imgWidth = img.offsetWidth || img.naturalWidth || img.width;\n imgHeight = img.offsetHeight || img.naturalHeight || img.height;\n insertNewImage(imgWidth, imgHeight);\n });\n img.src = result;\n };\n reader.readAsDataURL(file);\n }\n };\n\n workarea[0].addEventListener('dragenter', onDragEnter);\n workarea[0].addEventListener('dragover', onDragOver);\n workarea[0].addEventListener('dragleave', onDragLeave);\n workarea[0].addEventListener('drop', importImage);\n\n const open = $('').change(async function (e) {\n const ok = await editor.openPrep();\n if (!ok) { return; }\n svgCanvas.clear();\n if (this.files.length === 1) {\n $.process_cancel(uiStrings.notification.loadingImage);\n const reader = new FileReader();\n reader.onloadend = async function ({target}) {\n await loadSvgString(target.result);\n updateCanvas();\n };\n reader.readAsText(this.files[0]);\n }\n });\n $('#tool_open').show();\n $(window).on('openImage', () => open.click());\n\n const imgImport = $('').change(importImage);\n $('#tool_import').show();\n $(window).on('importImage', () => imgImport.click());\n }\n\n updateCanvas(true);\n // const revnums = 'svg-editor.js ($Rev$) ';\n // revnums += svgCanvas.getVersion();\n // $('#copyright')[0].setAttribute('title', revnums);\n\n const loadedExtensionNames = [];\n /**\n * @function module:SVGEditor.setLang\n * @param {string} lang The language code\n * @param {module:locale.LocaleStrings} allStrings See {@tutorial LocaleDocs}\n * @fires module:svgcanvas.SvgCanvas#event:ext_langReady\n * @fires module:svgcanvas.SvgCanvas#event:ext_langChanged\n * @returns {Promise} A Promise which resolves to `undefined`\n */\n const setLang = editor.setLang = async function (lang, allStrings) {\n editor.langChanged = true;\n editor.pref('lang', lang);\n $('#lang_select').val(lang);\n if (!allStrings) {\n return;\n }\n // Todo: Remove `allStrings.lang` property in locale in\n // favor of just `lang`?\n document.documentElement.lang = allStrings.lang; // lang;\n // Todo: Add proper RTL Support!\n // Todo: Use RTL detection instead and take out of locales?\n // document.documentElement.dir = allStrings.dir;\n $.extend(uiStrings, allStrings);\n\n // const notif = allStrings.notification; // Currently unused\n // $.extend will only replace the given strings\n const oldLayerName = $('#layerlist tr.layersel td.layername').text();\n const renameLayer = (oldLayerName === uiStrings.common.layer + ' 1');\n\n svgCanvas.setUiStrings(allStrings);\n Actions.setTitles();\n\n if (renameLayer) {\n svgCanvas.renameCurrentLayer(uiStrings.common.layer + ' 1');\n populateLayers();\n }\n\n // In case extensions loaded before the locale, now we execute a callback on them\n if (extsPreLang.length) {\n await Promise.all(extsPreLang.map((ext) => {\n loadedExtensionNames.push(ext.name);\n return ext.langReady({\n lang,\n uiStrings,\n importLocale: getImportLocale({defaultLang: lang, defaultName: ext.name})\n });\n }));\n extsPreLang.length = 0;\n } else {\n loadedExtensionNames.forEach((loadedExtensionName) => {\n svgCanvas.runExtension(\n loadedExtensionName,\n 'langReady',\n /** @type {module:svgcanvas.SvgCanvas#event:ext_langReady} */ {\n lang, uiStrings, importLocale: getImportLocale({defaultLang: lang, defaultName: loadedExtensionName})\n }\n );\n });\n }\n svgCanvas.runExtensions('langChanged', /** @type {module:svgcanvas.SvgCanvas#event:ext_langChanged} */ lang);\n\n // Update flyout tooltips\n setFlyoutTitles();\n\n // Copy title for certain tool elements\n const elems = {\n '#stroke_color': '#tool_stroke .icon_label, #tool_stroke .color_block',\n '#fill_color': '#tool_fill label, #tool_fill .color_block',\n '#linejoin_miter': '#cur_linejoin',\n '#linecap_butt': '#cur_linecap'\n };\n\n $.each(elems, function (source, dest) {\n $(dest).attr('title', $(source)[0].title);\n });\n\n // Copy alignment titles\n $('#multiselected_panel div[id^=tool_align]').each(function () {\n $('#tool_pos' + this.id.substr(10))[0].title = this.title;\n });\n };\n localeInit(\n /**\n * @implements {module:locale.LocaleEditorInit}\n */\n {\n /**\n * Gets an array of results from extensions with a `addLangData` method,\n * returning an object with a `data` property set to its locales (to be\n * merged with regular locales).\n * @param {string} langParam\n * @fires module:svgcanvas.SvgCanvas#event:ext_addLangData\n * @todo Can we forego this in favor of `langReady` (or forego `langReady`)?\n * @returns {module:locale.AddLangExtensionLocaleData[]}\n */\n addLangData (langParam) {\n return svgCanvas.runExtensions(\n 'addLangData',\n /**\n * @function\n * @type {module:svgcanvas.ExtensionVarBuilder}\n * @param {string} name\n * @returns {module:svgcanvas.SvgCanvas#event:ext_addLangData}\n */\n (name) => { // We pass in a function as we don't know the extension name here when defining this `addLangData` method\n return {\n lang: langParam,\n importLocale: getImportLocale({defaultLang: langParam, defaultName: name})\n };\n },\n true\n );\n },\n curConfig\n }\n );\n // Load extensions\n // Bit of a hack to run extensions in local Opera/IE9\n if (document.location.protocol === 'file:') {\n setTimeout(extAndLocaleFunc, 100);\n } else {\n // Returns a promise (if we wanted to fire 'extensions-loaded' event,\n // potentially useful to hide interface as some extension locales\n // are only available after this)\n extAndLocaleFunc();\n }\n};\n\n/**\n* @callback module:SVGEditor.ReadyCallback\n* @returns {Promise|void}\n*/\n/**\n* Queues a callback to be invoked when the editor is ready (or\n* to be invoked immediately if it is already ready--i.e.,\n* if `runCallbacks` has been run).\n* @function module:SVGEditor.ready\n* @param {module:SVGEditor.ReadyCallback} cb Callback to be queued to invoke\n* @returns {Promise} Resolves when all callbacks, including the supplied have resolved\n*/\neditor.ready = function (cb) { // eslint-disable-line promise/prefer-await-to-callbacks\n return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new\n if (isReady) {\n resolve(cb()); // eslint-disable-line node/callback-return, promise/prefer-await-to-callbacks\n return;\n }\n callbacks.push([cb, resolve, reject]);\n });\n};\n\n/**\n* Invokes the callbacks previous set by `svgEditor.ready`\n* @function module:SVGEditor.runCallbacks\n* @returns {Promise} Resolves to `undefined` if all callbacks succeeded and rejects otherwise\n*/\neditor.runCallbacks = async function () {\n try {\n await Promise.all(callbacks.map(([cb]) => {\n return cb(); // eslint-disable-line promise/prefer-await-to-callbacks\n }));\n } catch (err) {\n callbacks.forEach(([, , reject]) => {\n reject();\n });\n throw err;\n }\n callbacks.forEach(([, resolve]) => {\n resolve();\n });\n isReady = true;\n};\n\n/**\n * @function module:SVGEditor.loadFromString\n * @param {string} str The SVG string to load\n * @param {PlainObject} [opts={}]\n * @param {boolean} [opts.noAlert=false] Option to avoid alert to user and instead get rejected promise\n * @returns {Promise}\n */\neditor.loadFromString = function (str, {noAlert} = {}) {\n return editor.ready(async function () {\n try {\n await loadSvgString(str, {noAlert});\n } catch (err) {\n if (noAlert) {\n throw err;\n }\n }\n });\n};\n\n/**\n* Not presently in use.\n* @function module:SVGEditor.disableUI\n* @param {PlainObject} featList\n* @returns {void}\n*/\neditor.disableUI = function (featList) {\n // $(function () {\n // $('#tool_wireframe, #tool_image, #main_button, #tool_source, #sidepanels').remove();\n // $('#tools_top').css('left', 5);\n // });\n};\n\n/**\n * @callback module:SVGEditor.URLLoadCallback\n * @param {boolean} success\n * @returns {void}\n */\n/**\n * @function module:SVGEditor.loadFromURL\n * @param {string} url URL from which to load an SVG string via Ajax\n * @param {PlainObject} [opts={}] May contain properties: `cache`, `callback`\n * @param {boolean} [opts.cache]\n * @param {boolean} [opts.noAlert]\n * @returns {Promise} Resolves to `undefined` or rejects upon bad loading of\n * the SVG (or upon failure to parse the loaded string) when `noAlert` is\n * enabled\n */\neditor.loadFromURL = function (url, {cache, noAlert} = {}) {\n return editor.ready(function () {\n return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new\n $.ajax({\n url,\n dataType: 'text',\n cache: Boolean(cache),\n beforeSend () {\n $.process_cancel(uiStrings.notification.loadingImage);\n },\n success (str) {\n resolve(loadSvgString(str, {noAlert}));\n },\n error (xhr, stat, err) {\n if (xhr.status !== 404 && xhr.responseText) {\n resolve(loadSvgString(xhr.responseText, {noAlert}));\n return;\n }\n if (noAlert) {\n reject(new Error('URLLoadFail'));\n return;\n }\n $.alert(uiStrings.notification.URLLoadFail + ': \\n' + err);\n resolve();\n },\n complete () {\n $('#dialog_box').hide();\n }\n });\n });\n });\n};\n\n/**\n* @function module:SVGEditor.loadFromDataURI\n* @param {string} str The Data URI to base64-decode (if relevant) and load\n* @param {PlainObject} [opts={}]\n* @param {boolean} [opts.noAlert]\n* @returns {Promise} Resolves to `undefined` and rejects if loading SVG string fails and `noAlert` is enabled\n*/\neditor.loadFromDataURI = function (str, {noAlert} = {}) {\n return editor.ready(function () {\n let base64 = false;\n let pre = str.match(/^data:image\\/svg\\+xml;base64,/);\n if (pre) {\n base64 = true;\n } else {\n pre = str.match(/^data:image\\/svg\\+xml(?:;|;utf8)?,/);\n }\n if (pre) {\n pre = pre[0];\n }\n const src = str.slice(pre.length);\n return loadSvgString(base64 ? Utils.decode64(src) : decodeURIComponent(src), {noAlert});\n });\n};\n\n/**\n * @function module:SVGEditor.addExtension\n * @param {string} name Used internally; no need for i18n.\n * @param {module:svgcanvas.ExtensionInitCallback} init Config to be invoked on this module\n * @param {module:svgcanvas.ExtensionInitArgs} initArgs\n * @throws {Error} If called too early\n * @returns {Promise} Resolves to `undefined`\n*/\neditor.addExtension = function (name, init, initArgs) {\n // Note that we don't want this on editor.ready since some extensions\n // may want to run before then (like server_opensave).\n // $(function () {\n if (!svgCanvas) {\n throw new Error('Extension added too early');\n }\n return svgCanvas.addExtension.call(this, name, init, initArgs);\n // });\n};\n\n// Defer injection to wait out initial menu processing. This probably goes\n// away once all context menu behavior is brought to context menu.\neditor.ready(() => {\n injectExtendedContextMenuItemsIntoDom();\n});\n\nlet extensionsAdded = false;\nconst messageQueue = [];\n/**\n * @param {PlainObject} info\n * @param {any} info.data\n * @param {string} info.origin\n * @fires module:svgcanvas.SvgCanvas#event:message\n * @returns {void}\n */\nconst messageListener = ({data, origin}) => { // eslint-disable-line no-shadow\n // console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);\n const messageObj = {data, origin};\n if (!extensionsAdded) {\n messageQueue.push(messageObj);\n } else {\n // Extensions can handle messages at this stage with their own\n // canvas `message` listeners\n svgCanvas.call('message', messageObj);\n }\n};\nwindow.addEventListener('message', messageListener);\n\n// Run init once DOM is loaded\n// jQuery(editor.init);\n\n(async () => {\ntry {\n // We wait a micro-task to let the svgEditor variable be defined for module checks\n await Promise.resolve();\n editor.init();\n} catch (err) {\n console.error(err); // eslint-disable-line no-console\n}\n})();\n\nexport default editor;\n","// TO BUILD AN IIFE VERSION OF THIS FILE (AS CAN WORK ON OLDER BROWSERS),\n// RUN THE FOLLOWING ON THE COMMAND LINE FROM THE PROJECT ROOT:\n// `npm run build-by-config`. REPEAT AFTER ANY MODIFICATIONS\n// TO svgedit-config-es.js.\n\n/*\nThe svgedit-config-es.js file is intended for the setting of configuration\n or preferences which must run early on; if this is not needed, it is\n recommended that you create an extension instead (for greater\n reusability and modularity). This file needs to be in the parent\n folder of the editor folder. It is referenced in the code as\n '../svgedit-config-es.js'.\n*/\n\n// CONFIG AND EXTENSION SETTING\n/*\nFor default config and extensions (and available options) available to\n`setConfig()`, see the file `docs/tutorials/ConfigOptions.md`\n*/\n\nimport 'core-js/stable/index.js';\nimport 'regenerator-runtime/runtime.js';\nimport svgEditor from './svgedit.js';\n\n// URL OVERRIDE CONFIG\nsvgEditor.setConfig({\n /* To override the ability for URLs to set URL-based SVG content,\n uncomment the following: */\n // preventURLContentLoading: true,\n /* To override the ability for URLs to set other configuration (including\n extension config), uncomment the following: */\n // preventAllURLConfig: true,\n /* To override the ability for URLs to set their own extensions, uncomment the\n following (note that if `setConfig()` is used in extension code, it will still\n be additive to extensions, however): */\n // lockExtensions: true,\n});\n\nsvgEditor.setConfig({\n /*\n Provide default values here which differ from that of the editor but\n which the URL can override\n */\n}, {allowInitialUserOverride: true});\n\n// EXTENSION CONFIG\nsvgEditor.setConfig({\n extensions: [\n // 'ext-overview_window.js', 'ext-markers.js', 'ext-connector.js',\n // 'ext-eyedropper.js', 'ext-shapes.js', 'ext-imagelib.js',\n // 'ext-grid.js', 'ext-polygon.js', 'ext-star.js', 'ext-panning.js',\n // 'ext-storage.js'\n ],\n // noDefaultExtensions can only be meaningfully used in\n // `svgedit-config-es.js` or in the URL\n noDefaultExtensions: false\n});\n\n// OTHER CONFIG\nsvgEditor.setConfig({\n // canvasName: 'default',\n // canvas_expansion: 3,\n // initFill: {\n // color: 'FF0000', // solid red\n // opacity: 1\n // },\n // initStroke: {\n // width: 5,\n // color: '000000', // solid black\n // opacity: 1\n // },\n // initOpacity: 1,\n // colorPickerCSS: null,\n // initTool: 'select',\n // exportWindowType: 'new', // 'same'\n // wireframe: false,\n // showlayers: false,\n // no_save_warning: false,\n // PATH CONFIGURATION\n // imgPath: 'images/',\n // langPath: './locale/',\n // extPath: 'extensions/',\n // jGraduatePath: 'jgraduate/images/',\n /*\n Uncomment the following to allow at least same domain (embedded) access,\n including `file:///` access.\n Setting as `['*']` would allow any domain to access but would be unsafe to\n data privacy and integrity.\n */\n // May be 'null' (as a string) when used as a `file:///` URL\n // allowedOrigins: [location.origin || 'null'],\n // DOCUMENT PROPERTIES\n // dimensions: [640, 480],\n // EDITOR OPTIONS\n // gridSnapping: false,\n // gridColor: '#000',\n // baseUnit: 'px',\n // snappingStep: 10,\n // showRulers: true,\n // EXTENSION-RELATED (GRID)\n // showGrid: false, // Set by ext-grid.js\n // EXTENSION-RELATED (STORAGE)\n // Some interaction with `ext-storage.js`; prevent even the loading of\n // previously saved local storage\n // noStorageOnLoad: false,\n // Some interaction with `ext-storage.js`; strongly discouraged from\n // modification as it bypasses user privacy by preventing them from\n // choosing whether to keep local storage or not\n // forceStorage: false,\n // Used by `ext-storage.js`; empty any prior storage if the user\n // declines to store\n // emptyStorageOnDecline: true,\n});\n\n// PREF CHANGES\n/*\nsetConfig() can also be used to set preferences in addition to\n configuration (see defaultPrefs in svg-editor.js for a list of\n possible settings), but at least if you are using ext-storage.js\n to store preferences, it will probably be better to let your\n users control these.\nAs with configuration, one may use allowInitialUserOverride, but\n in the case of preferences, any previously stored preferences\n will also thereby be enabled to override this setting (and at a\n higher priority than any URL preference setting overrides).\n Failing to use allowInitialUserOverride will ensure preferences\n are hard-coded here regardless of URL or prior user storage setting.\n*/\nsvgEditor.setConfig({\n // Set dynamically within locale.js if not previously set\n // lang: '',\n // Will default to 's' if the window height is smaller than the minimum\n // height and 'm' otherwise\n // iconsize: '',\n /**\n * When showing the preferences dialog, svg-editor.js currently relies\n * on `curPrefs` instead of `svgEditor.pref`, so allowing an override for\n * `bkgd_color` means that this value won't have priority over block\n * auto-detection as far as determining which color shows initially\n * in the preferences dialog (though it can be changed and saved).\n */\n // bkgd_color: '#FFF',\n // bkgd_url: '',\n // img_save: 'embed',\n // Only shows in UI as far as alert notices\n // save_notice_done: false,\n // export_notice_done: false\n});\nsvgEditor.setConfig(\n {\n // Indicate pref settings here if you wish to allow user storage or URL\n // settings to be able to override your default preferences (unless\n // other config options have already explicitly prevented one or the\n // other)\n },\n {allowInitialUserOverride: true}\n);\n","/*!\n * html2canvas 1.0.0-rc.7 \n * Copyright (c) 2020 Niklas von Hertzen \n * Released under MIT License\n */\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (global = global || self, global.html2canvas = factory());\n}(this, function () { 'use strict';\n\n /*! *****************************************************************************\r\n Copyright (c) Microsoft Corporation. All rights reserved.\r\n Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\n this file except in compliance with the License. You may obtain a copy of the\r\n License at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\n THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\n KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\n WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\n MERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\n See the Apache Version 2.0 License for specific language governing permissions\r\n and limitations under the License.\r\n ***************************************************************************** */\r\n /* global Reflect, Promise */\r\n\r\n var extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n\r\n function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n }\r\n\r\n var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n };\r\n\r\n function __awaiter(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n }\r\n\r\n function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n }\n\n var Bounds = /** @class */ (function () {\r\n function Bounds(x, y, w, h) {\r\n this.left = x;\r\n this.top = y;\r\n this.width = w;\r\n this.height = h;\r\n }\r\n Bounds.prototype.add = function (x, y, w, h) {\r\n return new Bounds(this.left + x, this.top + y, this.width + w, this.height + h);\r\n };\r\n Bounds.fromClientRect = function (clientRect) {\r\n return new Bounds(clientRect.left, clientRect.top, clientRect.width, clientRect.height);\r\n };\r\n return Bounds;\r\n }());\r\n var parseBounds = function (node) {\r\n return Bounds.fromClientRect(node.getBoundingClientRect());\r\n };\r\n var parseDocumentSize = function (document) {\r\n var body = document.body;\r\n var documentElement = document.documentElement;\r\n if (!body || !documentElement) {\r\n throw new Error(\"Unable to get document size\");\r\n }\r\n var width = Math.max(Math.max(body.scrollWidth, documentElement.scrollWidth), Math.max(body.offsetWidth, documentElement.offsetWidth), Math.max(body.clientWidth, documentElement.clientWidth));\r\n var height = Math.max(Math.max(body.scrollHeight, documentElement.scrollHeight), Math.max(body.offsetHeight, documentElement.offsetHeight), Math.max(body.clientHeight, documentElement.clientHeight));\r\n return new Bounds(0, 0, width, height);\r\n };\n\n /*\n * css-line-break 1.1.1 \n * Copyright (c) 2019 Niklas von Hertzen \n * Released under MIT License\n */\n var toCodePoints = function (str) {\r\n var codePoints = [];\r\n var i = 0;\r\n var length = str.length;\r\n while (i < length) {\r\n var value = str.charCodeAt(i++);\r\n if (value >= 0xd800 && value <= 0xdbff && i < length) {\r\n var extra = str.charCodeAt(i++);\r\n if ((extra & 0xfc00) === 0xdc00) {\r\n codePoints.push(((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000);\r\n }\r\n else {\r\n codePoints.push(value);\r\n i--;\r\n }\r\n }\r\n else {\r\n codePoints.push(value);\r\n }\r\n }\r\n return codePoints;\r\n };\r\n var fromCodePoint = function () {\r\n var codePoints = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n codePoints[_i] = arguments[_i];\r\n }\r\n if (String.fromCodePoint) {\r\n return String.fromCodePoint.apply(String, codePoints);\r\n }\r\n var length = codePoints.length;\r\n if (!length) {\r\n return '';\r\n }\r\n var codeUnits = [];\r\n var index = -1;\r\n var result = '';\r\n while (++index < length) {\r\n var codePoint = codePoints[index];\r\n if (codePoint <= 0xffff) {\r\n codeUnits.push(codePoint);\r\n }\r\n else {\r\n codePoint -= 0x10000;\r\n codeUnits.push((codePoint >> 10) + 0xd800, codePoint % 0x400 + 0xdc00);\r\n }\r\n if (index + 1 === length || codeUnits.length > 0x4000) {\r\n result += String.fromCharCode.apply(String, codeUnits);\r\n codeUnits.length = 0;\r\n }\r\n }\r\n return result;\r\n };\r\n var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\r\n // Use a lookup table to find the index.\r\n var lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\r\n for (var i = 0; i < chars.length; i++) {\r\n lookup[chars.charCodeAt(i)] = i;\r\n }\r\n var decode = function (base64) {\r\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\r\n if (base64[base64.length - 1] === '=') {\r\n bufferLength--;\r\n if (base64[base64.length - 2] === '=') {\r\n bufferLength--;\r\n }\r\n }\r\n var buffer = typeof ArrayBuffer !== 'undefined' &&\r\n typeof Uint8Array !== 'undefined' &&\r\n typeof Uint8Array.prototype.slice !== 'undefined'\r\n ? new ArrayBuffer(bufferLength)\r\n : new Array(bufferLength);\r\n var bytes = Array.isArray(buffer) ? buffer : new Uint8Array(buffer);\r\n for (i = 0; i < len; i += 4) {\r\n encoded1 = lookup[base64.charCodeAt(i)];\r\n encoded2 = lookup[base64.charCodeAt(i + 1)];\r\n encoded3 = lookup[base64.charCodeAt(i + 2)];\r\n encoded4 = lookup[base64.charCodeAt(i + 3)];\r\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\r\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\r\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\r\n }\r\n return buffer;\r\n };\r\n var polyUint16Array = function (buffer) {\r\n var length = buffer.length;\r\n var bytes = [];\r\n for (var i = 0; i < length; i += 2) {\r\n bytes.push((buffer[i + 1] << 8) | buffer[i]);\r\n }\r\n return bytes;\r\n };\r\n var polyUint32Array = function (buffer) {\r\n var length = buffer.length;\r\n var bytes = [];\r\n for (var i = 0; i < length; i += 4) {\r\n bytes.push((buffer[i + 3] << 24) | (buffer[i + 2] << 16) | (buffer[i + 1] << 8) | buffer[i]);\r\n }\r\n return bytes;\r\n };\n\n /** Shift size for getting the index-2 table offset. */\r\n var UTRIE2_SHIFT_2 = 5;\r\n /** Shift size for getting the index-1 table offset. */\r\n var UTRIE2_SHIFT_1 = 6 + 5;\r\n /**\r\n * Shift size for shifting left the index array values.\r\n * Increases possible data size with 16-bit index values at the cost\r\n * of compactability.\r\n * This requires data blocks to be aligned by UTRIE2_DATA_GRANULARITY.\r\n */\r\n var UTRIE2_INDEX_SHIFT = 2;\r\n /**\r\n * Difference between the two shift sizes,\r\n * for getting an index-1 offset from an index-2 offset. 6=11-5\r\n */\r\n var UTRIE2_SHIFT_1_2 = UTRIE2_SHIFT_1 - UTRIE2_SHIFT_2;\r\n /**\r\n * The part of the index-2 table for U+D800..U+DBFF stores values for\r\n * lead surrogate code _units_ not code _points_.\r\n * Values for lead surrogate code _points_ are indexed with this portion of the table.\r\n * Length=32=0x20=0x400>>UTRIE2_SHIFT_2. (There are 1024=0x400 lead surrogates.)\r\n */\r\n var UTRIE2_LSCP_INDEX_2_OFFSET = 0x10000 >> UTRIE2_SHIFT_2;\r\n /** Number of entries in a data block. 32=0x20 */\r\n var UTRIE2_DATA_BLOCK_LENGTH = 1 << UTRIE2_SHIFT_2;\r\n /** Mask for getting the lower bits for the in-data-block offset. */\r\n var UTRIE2_DATA_MASK = UTRIE2_DATA_BLOCK_LENGTH - 1;\r\n var UTRIE2_LSCP_INDEX_2_LENGTH = 0x400 >> UTRIE2_SHIFT_2;\r\n /** Count the lengths of both BMP pieces. 2080=0x820 */\r\n var UTRIE2_INDEX_2_BMP_LENGTH = UTRIE2_LSCP_INDEX_2_OFFSET + UTRIE2_LSCP_INDEX_2_LENGTH;\r\n /**\r\n * The 2-byte UTF-8 version of the index-2 table follows at offset 2080=0x820.\r\n * Length 32=0x20 for lead bytes C0..DF, regardless of UTRIE2_SHIFT_2.\r\n */\r\n var UTRIE2_UTF8_2B_INDEX_2_OFFSET = UTRIE2_INDEX_2_BMP_LENGTH;\r\n var UTRIE2_UTF8_2B_INDEX_2_LENGTH = 0x800 >> 6; /* U+0800 is the first code point after 2-byte UTF-8 */\r\n /**\r\n * The index-1 table, only used for supplementary code points, at offset 2112=0x840.\r\n * Variable length, for code points up to highStart, where the last single-value range starts.\r\n * Maximum length 512=0x200=0x100000>>UTRIE2_SHIFT_1.\r\n * (For 0x100000 supplementary code points U+10000..U+10ffff.)\r\n *\r\n * The part of the index-2 table for supplementary code points starts\r\n * after this index-1 table.\r\n *\r\n * Both the index-1 table and the following part of the index-2 table\r\n * are omitted completely if there is only BMP data.\r\n */\r\n var UTRIE2_INDEX_1_OFFSET = UTRIE2_UTF8_2B_INDEX_2_OFFSET + UTRIE2_UTF8_2B_INDEX_2_LENGTH;\r\n /**\r\n * Number of index-1 entries for the BMP. 32=0x20\r\n * This part of the index-1 table is omitted from the serialized form.\r\n */\r\n var UTRIE2_OMITTED_BMP_INDEX_1_LENGTH = 0x10000 >> UTRIE2_SHIFT_1;\r\n /** Number of entries in an index-2 block. 64=0x40 */\r\n var UTRIE2_INDEX_2_BLOCK_LENGTH = 1 << UTRIE2_SHIFT_1_2;\r\n /** Mask for getting the lower bits for the in-index-2-block offset. */\r\n var UTRIE2_INDEX_2_MASK = UTRIE2_INDEX_2_BLOCK_LENGTH - 1;\r\n var slice16 = function (view, start, end) {\r\n if (view.slice) {\r\n return view.slice(start, end);\r\n }\r\n return new Uint16Array(Array.prototype.slice.call(view, start, end));\r\n };\r\n var slice32 = function (view, start, end) {\r\n if (view.slice) {\r\n return view.slice(start, end);\r\n }\r\n return new Uint32Array(Array.prototype.slice.call(view, start, end));\r\n };\r\n var createTrieFromBase64 = function (base64) {\r\n var buffer = decode(base64);\r\n var view32 = Array.isArray(buffer) ? polyUint32Array(buffer) : new Uint32Array(buffer);\r\n var view16 = Array.isArray(buffer) ? polyUint16Array(buffer) : new Uint16Array(buffer);\r\n var headerLength = 24;\r\n var index = slice16(view16, headerLength / 2, view32[4] / 2);\r\n var data = view32[5] === 2\r\n ? slice16(view16, (headerLength + view32[4]) / 2)\r\n : slice32(view32, Math.ceil((headerLength + view32[4]) / 4));\r\n return new Trie(view32[0], view32[1], view32[2], view32[3], index, data);\r\n };\r\n var Trie = /** @class */ (function () {\r\n function Trie(initialValue, errorValue, highStart, highValueIndex, index, data) {\r\n this.initialValue = initialValue;\r\n this.errorValue = errorValue;\r\n this.highStart = highStart;\r\n this.highValueIndex = highValueIndex;\r\n this.index = index;\r\n this.data = data;\r\n }\r\n /**\r\n * Get the value for a code point as stored in the Trie.\r\n *\r\n * @param codePoint the code point\r\n * @return the value\r\n */\r\n Trie.prototype.get = function (codePoint) {\r\n var ix;\r\n if (codePoint >= 0) {\r\n if (codePoint < 0x0d800 || (codePoint > 0x0dbff && codePoint <= 0x0ffff)) {\r\n // Ordinary BMP code point, excluding leading surrogates.\r\n // BMP uses a single level lookup. BMP index starts at offset 0 in the Trie2 index.\r\n // 16 bit data is stored in the index array itself.\r\n ix = this.index[codePoint >> UTRIE2_SHIFT_2];\r\n ix = (ix << UTRIE2_INDEX_SHIFT) + (codePoint & UTRIE2_DATA_MASK);\r\n return this.data[ix];\r\n }\r\n if (codePoint <= 0xffff) {\r\n // Lead Surrogate Code Point. A Separate index section is stored for\r\n // lead surrogate code units and code points.\r\n // The main index has the code unit data.\r\n // For this function, we need the code point data.\r\n // Note: this expression could be refactored for slightly improved efficiency, but\r\n // surrogate code points will be so rare in practice that it's not worth it.\r\n ix = this.index[UTRIE2_LSCP_INDEX_2_OFFSET + ((codePoint - 0xd800) >> UTRIE2_SHIFT_2)];\r\n ix = (ix << UTRIE2_INDEX_SHIFT) + (codePoint & UTRIE2_DATA_MASK);\r\n return this.data[ix];\r\n }\r\n if (codePoint < this.highStart) {\r\n // Supplemental code point, use two-level lookup.\r\n ix = UTRIE2_INDEX_1_OFFSET - UTRIE2_OMITTED_BMP_INDEX_1_LENGTH + (codePoint >> UTRIE2_SHIFT_1);\r\n ix = this.index[ix];\r\n ix += (codePoint >> UTRIE2_SHIFT_2) & UTRIE2_INDEX_2_MASK;\r\n ix = this.index[ix];\r\n ix = (ix << UTRIE2_INDEX_SHIFT) + (codePoint & UTRIE2_DATA_MASK);\r\n return this.data[ix];\r\n }\r\n if (codePoint <= 0x10ffff) {\r\n return this.data[this.highValueIndex];\r\n }\r\n }\r\n // Fall through. The code point is outside of the legal range of 0..0x10ffff.\r\n return this.errorValue;\r\n };\r\n return Trie;\r\n }());\n\n var base64 = 'KwAAAAAAAAAACA4AIDoAAPAfAAACAAAAAAAIABAAGABAAEgAUABYAF4AZgBeAGYAYABoAHAAeABeAGYAfACEAIAAiACQAJgAoACoAK0AtQC9AMUAXgBmAF4AZgBeAGYAzQDVAF4AZgDRANkA3gDmAOwA9AD8AAQBDAEUARoBIgGAAIgAJwEvATcBPwFFAU0BTAFUAVwBZAFsAXMBewGDATAAiwGTAZsBogGkAawBtAG8AcIBygHSAdoB4AHoAfAB+AH+AQYCDgIWAv4BHgImAi4CNgI+AkUCTQJTAlsCYwJrAnECeQKBAk0CiQKRApkCoQKoArACuALAAsQCzAIwANQC3ALkAjAA7AL0AvwCAQMJAxADGAMwACADJgMuAzYDPgOAAEYDSgNSA1IDUgNaA1oDYANiA2IDgACAAGoDgAByA3YDfgOAAIQDgACKA5IDmgOAAIAAogOqA4AAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAK8DtwOAAIAAvwPHA88D1wPfAyAD5wPsA/QD/AOAAIAABAQMBBIEgAAWBB4EJgQuBDMEIAM7BEEEXgBJBCADUQRZBGEEaQQwADAAcQQ+AXkEgQSJBJEEgACYBIAAoASoBK8EtwQwAL8ExQSAAIAAgACAAIAAgACgAM0EXgBeAF4AXgBeAF4AXgBeANUEXgDZBOEEXgDpBPEE+QQBBQkFEQUZBSEFKQUxBTUFPQVFBUwFVAVcBV4AYwVeAGsFcwV7BYMFiwWSBV4AmgWgBacFXgBeAF4AXgBeAKsFXgCyBbEFugW7BcIFwgXIBcIFwgXQBdQF3AXkBesF8wX7BQMGCwYTBhsGIwYrBjMGOwZeAD8GRwZNBl4AVAZbBl4AXgBeAF4AXgBeAF4AXgBeAF4AXgBeAGMGXgBqBnEGXgBeAF4AXgBeAF4AXgBeAF4AXgB5BoAG4wSGBo4GkwaAAIADHgR5AF4AXgBeAJsGgABGA4AAowarBrMGswagALsGwwbLBjAA0wbaBtoG3QbaBtoG2gbaBtoG2gblBusG8wb7BgMHCwcTBxsHCwcjBysHMAc1BzUHOgdCB9oGSgdSB1oHYAfaBloHaAfaBlIH2gbaBtoG2gbaBtoG2gbaBjUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHbQdeAF4ANQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQd1B30HNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1B4MH2gaKB68EgACAAIAAgACAAIAAgACAAI8HlwdeAJ8HpweAAIAArwe3B14AXgC/B8UHygcwANAH2AfgB4AA6AfwBz4B+AcACFwBCAgPCBcIogEYAR8IJwiAAC8INwg/CCADRwhPCFcIXwhnCEoDGgSAAIAAgABvCHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIhAiLCI4IMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlggwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAANQc1BzUHNQc1BzUHNQc1BzUHNQc1B54INQc1B6II2gaqCLIIugiAAIAAvgjGCIAAgACAAIAAgACAAIAAgACAAIAAywiHAYAA0wiAANkI3QjlCO0I9Aj8CIAAgACAAAIJCgkSCRoJIgknCTYHLwk3CZYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiAAIAAAAFAAXgBeAGAAcABeAHwAQACQAKAArQC9AJ4AXgBeAE0A3gBRAN4A7AD8AMwBGgEAAKcBNwEFAUwBXAF4QkhCmEKnArcCgAHHAsABz4LAAcABwAHAAd+C6ABoAG+C/4LAAcABwAHAAc+DF4MAAcAB54M3gweDV4Nng3eDaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAEeDqABVg6WDqABoQ6gAaABoAHXDvcONw/3DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DncPAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcAB7cPPwlGCU4JMACAAIAAgABWCV4JYQmAAGkJcAl4CXwJgAkwADAAMAAwAIgJgACLCZMJgACZCZ8JowmrCYAAswkwAF4AXgB8AIAAuwkABMMJyQmAAM4JgADVCTAAMAAwADAAgACAAIAAgACAAIAAgACAAIAAqwYWBNkIMAAwADAAMADdCeAJ6AnuCR4E9gkwAP4JBQoNCjAAMACAABUK0wiAAB0KJAosCjQKgAAwADwKQwqAAEsKvQmdCVMKWwowADAAgACAALcEMACAAGMKgABrCjAAMAAwADAAMAAwADAAMAAwADAAMAAeBDAAMAAwADAAMAAwADAAMAAwADAAMAAwAIkEPQFzCnoKiQSCCooKkAqJBJgKoAqkCokEGAGsCrQKvArBCjAAMADJCtEKFQHZCuEK/gHpCvEKMAAwADAAMACAAIwE+QowAIAAPwEBCzAAMAAwADAAMACAAAkLEQswAIAAPwEZCyELgAAOCCkLMAAxCzkLMAAwADAAMAAwADAAXgBeAEELMAAwADAAMAAwADAAMAAwAEkLTQtVC4AAXAtkC4AAiQkwADAAMAAwADAAMAAwADAAbAtxC3kLgAuFC4sLMAAwAJMLlwufCzAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAApwswADAAMACAAIAAgACvC4AAgACAAIAAgACAALcLMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAvwuAAMcLgACAAIAAgACAAIAAyguAAIAAgACAAIAA0QswADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAANkLgACAAIAA4AswADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACJCR4E6AswADAAhwHwC4AA+AsADAgMEAwwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMACAAIAAGAwdDCUMMAAwAC0MNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQw1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHPQwwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADUHNQc1BzUHNQc1BzUHNQc2BzAAMAA5DDUHNQc1BzUHNQc1BzUHNQc1BzUHNQdFDDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAgACAAIAATQxSDFoMMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAF4AXgBeAF4AXgBeAF4AYgxeAGoMXgBxDHkMfwxeAIUMXgBeAI0MMAAwADAAMAAwAF4AXgCVDJ0MMAAwADAAMABeAF4ApQxeAKsMswy7DF4Awgy9DMoMXgBeAF4AXgBeAF4AXgBeAF4AXgDRDNkMeQBqCeAM3Ax8AOYM7Az0DPgMXgBeAF4AXgBeAF4AXgBeAF4AXgBeAF4AXgBeAF4AXgCgAAANoAAHDQ4NFg0wADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAeDSYNMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIAAgACAAIAAgACAAC4NMABeAF4ANg0wADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAD4NRg1ODVYNXg1mDTAAbQ0wADAAMAAwADAAMAAwADAA2gbaBtoG2gbaBtoG2gbaBnUNeg3CBYANwgWFDdoGjA3aBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gaUDZwNpA2oDdoG2gawDbcNvw3HDdoG2gbPDdYN3A3fDeYN2gbsDfMN2gbaBvoN/g3aBgYODg7aBl4AXgBeABYOXgBeACUG2gYeDl4AJA5eACwO2w3aBtoGMQ45DtoG2gbaBtoGQQ7aBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gZJDjUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1B1EO2gY1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQdZDjUHNQc1BzUHNQc1B2EONQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHaA41BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1B3AO2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gY1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1B2EO2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gZJDtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBkkOeA6gAKAAoAAwADAAMAAwAKAAoACgAKAAoACgAKAAgA4wADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAD//wQABAAEAAQABAAEAAQABAAEAA0AAwABAAEAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAKABMAFwAeABsAGgAeABcAFgASAB4AGwAYAA8AGAAcAEsASwBLAEsASwBLAEsASwBLAEsAGAAYAB4AHgAeABMAHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAFgAbABIAHgAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABYADQARAB4ABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAkAFgAaABsAGwAbAB4AHQAdAB4ATwAXAB4ADQAeAB4AGgAbAE8ATwAOAFAAHQAdAB0ATwBPABcATwBPAE8AFgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAB4AUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAFAATwBAAE8ATwBPAEAATwBQAFAATwBQAB4AHgAeAB4AHgAeAB0AHQAdAB0AHgAdAB4ADgBQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgBQAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAJAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAkACQAJAAkACQAJAAkABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAFAAHgAeAB4AKwArAFAAUABQAFAAGABQACsAKwArACsAHgAeAFAAHgBQAFAAUAArAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUAAeAB4AHgAeAB4AHgArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAYAA0AKwArAB4AHgAbACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAB4ABAAEAB4ABAAEABMABAArACsAKwArACsAKwArACsAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAKwArACsAKwArAFYAVgBWAB4AHgArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AGgAaABoAGAAYAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQAEwAEACsAEwATAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABLAEsASwBLAEsASwBLAEsASwBLABoAGQAZAB4AUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABMAUAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABABQAFAABAAEAB4ABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUAAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAFAABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQAUABQAB4AHgAYABMAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAFAABAAEAAQABAAEAFAABAAEAAQAUAAEAAQABAAEAAQAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArACsAHgArAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAAQABAANAA0ASwBLAEsASwBLAEsASwBLAEsASwAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQAKwBQAFAAUABQAFAAUABQAFAAKwArAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAKwArACsAUABQAFAAUAArACsABABQAAQABAAEAAQABAAEAAQAKwArAAQABAArACsABAAEAAQAUAArACsAKwArACsAKwArACsABAArACsAKwArAFAAUAArAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAGgAaAFAAUABQAFAAUABMAB4AGwBQAB4AKwArACsABAAEAAQAKwBQAFAAUABQAFAAUAArACsAKwArAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAUAArAFAAUAArAFAAUAArACsABAArAAQABAAEAAQABAArACsAKwArAAQABAArACsABAAEAAQAKwArACsABAArACsAKwArACsAKwArAFAAUABQAFAAKwBQACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwAEAAQAUABQAFAABAArACsAKwArACsAKwArACsAKwArACsABAAEAAQAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAUAArAFAAUABQAFAAUAArACsABABQAAQABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQAKwArAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwAeABsAKwArACsAKwArACsAKwBQAAQABAAEAAQABAAEACsABAAEAAQAKwBQAFAAUABQAFAAUABQAFAAKwArAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAKwArAAQABAArACsABAAEAAQAKwArACsAKwArACsAKwArAAQABAArACsAKwArAFAAUAArAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwAeAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwAEAFAAKwBQAFAAUABQAFAAUAArACsAKwBQAFAAUAArAFAAUABQAFAAKwArACsAUABQACsAUAArAFAAUAArACsAKwBQAFAAKwArACsAUABQAFAAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAAQABAAEAAQAKwArACsABAAEAAQAKwAEAAQABAAEACsAKwBQACsAKwArACsAKwArAAQAKwArACsAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAB4AHgAeAB4AHgAeABsAHgArACsAKwArACsABAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABAArACsAKwArACsAKwArAAQABAArAFAAUABQACsAKwArACsAKwBQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAB4AUAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABAArACsAKwArACsAKwArAAQABAArACsAKwArACsAKwArAFAAKwBQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABABQAB4AKwArACsAKwBQAFAAUAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQABoAUABQAFAAUABQAFAAKwArAAQABAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQACsAUAArACsAUABQAFAAUABQAFAAUAArACsAKwAEACsAKwArACsABAAEAAQABAAEAAQAKwAEACsABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArAAQABAAeACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAXAAqACoAKgAqACoAKgAqACsAKwArACsAGwBcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAeAEsASwBLAEsASwBLAEsASwBLAEsADQANACsAKwArACsAKwBcAFwAKwBcACsAKwBcAFwAKwBcACsAKwBcACsAKwArACsAKwArAFwAXABcAFwAKwBcAFwAXABcAFwAXABcACsAXABcAFwAKwBcACsAXAArACsAXABcACsAXABcAFwAXAAqAFwAXAAqACoAKgAqACoAKgArACoAKgBcACsAKwBcAFwAXABcAFwAKwBcACsAKgAqACoAKgAqACoAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArAFwAXABcAFwAUAAOAA4ADgAOAB4ADgAOAAkADgAOAA0ACQATABMAEwATABMACQAeABMAHgAeAB4ABAAEAB4AHgAeAB4AHgAeAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUAANAAQAHgAEAB4ABAAWABEAFgARAAQABABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAANAAQABAAEAAQABAANAAQABABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsADQANAB4AHgAeAB4AHgAeAAQAHgAeAB4AHgAeAB4AKwAeAB4ADgAOAA0ADgAeAB4AHgAeAB4ACQAJACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqAFwASwBLAEsASwBLAEsASwBLAEsASwANAA0AHgAeAB4AHgBcAFwAXABcAFwAXAAqACoAKgAqAFwAXABcAFwAKgAqACoAXAAqACoAKgBcAFwAKgAqACoAKgAqACoAKgBcAFwAXAAqACoAKgAqAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgAqACoAXAAqAEsASwBLAEsASwBLAEsASwBLAEsAKgAqACoAKgAqACoAUABQAFAAUABQAFAAKwBQACsAKwArACsAKwBQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQACsAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwAEAAQABAAeAA0AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQACsAKwANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABYAEQArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAADQANAA0AUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAABAAEAAQAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAA0ADQArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQACsABAAEACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoADQANABUAXAANAB4ADQAbAFwAKgArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArAB4AHgATABMADQANAA4AHgATABMAHgAEAAQABAAJACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAUABQAFAAUABQAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABABQACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwAeACsAKwArABMAEwBLAEsASwBLAEsASwBLAEsASwBLAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAKwBcAFwAXABcAFwAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBcACsAKwArACoAKgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEACsAKwAeAB4AXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgArACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgArACsABABLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKgAqACoAKgAqACoAKgBcACoAKgAqACoAKgAqACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAUABQAFAAUABQAFAAUAArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsADQANAB4ADQANAA0ADQAeAB4AHgAeAB4AHgAeAB4AHgAeAAQABAAEAAQABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAUABQAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAHgAeAB4AHgBQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwANAA0ADQANAA0ASwBLAEsASwBLAEsASwBLAEsASwArACsAKwBQAFAAUABLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAA0AUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsABAAEAAQAHgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAUABQAFAABABQAFAAUABQAAQABAAEAFAAUAAEAAQABAArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwAEAAQABAAEAAQAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUAArAFAAKwBQACsAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAHgAeAB4AHgAeAB4AHgAeAFAAHgAeAB4AUABQAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAKwArAB4AHgAeAB4AHgAeACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAUABQAFAAKwAeAB4AHgAeAB4AHgAeAA4AHgArAA0ADQANAA0ADQANAA0ACQANAA0ADQAIAAQACwAEAAQADQAJAA0ADQAMAB0AHQAeABcAFwAWABcAFwAXABYAFwAdAB0AHgAeABQAFAAUAA0AAQABAAQABAAEAAQABAAJABoAGgAaABoAGgAaABoAGgAeABcAFwAdABUAFQAeAB4AHgAeAB4AHgAYABYAEQAVABUAFQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgANAB4ADQANAA0ADQAeAA0ADQANAAcAHgAeAB4AHgArAAQABAAEAAQABAAEAAQABAAEAAQAUABQACsAKwBPAFAAUABQAFAAUAAeAB4AHgAWABEATwBQAE8ATwBPAE8AUABQAFAAUABQAB4AHgAeABYAEQArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAGwAbABsAGwAbABsAGwAaABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAaABsAGwAbABsAGgAbABsAGgAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgBQABoAHgAdAB4AUAAeABoAHgAeAB4AHgAeAB4AHgAeAB4ATwAeAFAAGwAeAB4AUABQAFAAUABQAB4AHgAeAB0AHQAeAFAAHgBQAB4AUAAeAFAATwBQAFAAHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AUABQAFAAUABPAE8AUABQAFAAUABQAE8AUABQAE8AUABPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBQAFAAUABQAE8ATwBPAE8ATwBPAE8ATwBPAE8AUABQAFAAUABQAFAAUABQAFAAHgAeAFAAUABQAFAATwAeAB4AKwArACsAKwAdAB0AHQAdAB0AHQAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAeAB0AHQAeAB4AHgAdAB0AHgAeAB0AHgAeAB4AHQAeAB0AGwAbAB4AHQAeAB4AHgAeAB0AHgAeAB0AHQAdAB0AHgAeAB0AHgAdAB4AHQAdAB0AHQAdAB0AHgAdAB4AHgAeAB4AHgAdAB0AHQAdAB4AHgAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAeAB4AHgAdAB4AHgAeAB4AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB4AHgAdAB0AHQAdAB4AHgAdAB0AHgAeAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAeAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHQAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABQAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAFgARAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAlACUAHgAeAB4AHgAeAB4AHgAeAB4AFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBQAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB4AHgAeAB4AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAdAB0AHQAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAeAB0AHQAeAB4AHgAeAB0AHQAeAB4AHgAeAB0AHQAdAB4AHgAdAB4AHgAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAeAB0AHQAeAB4AHQAeAB4AHgAeAB0AHQAeAB4AHgAeACUAJQAdAB0AJQAeACUAJQAlACAAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAHgAeAB4AHgAdAB4AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB4AHQAdAB0AHgAdACUAHQAdAB4AHQAdAB4AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAHQAdAB0AHQAlAB4AJQAlACUAHQAlACUAHQAdAB0AJQAlAB0AHQAlAB0AHQAlACUAJQAeAB0AHgAeAB4AHgAdAB0AJQAdAB0AHQAdAB0AHQAlACUAJQAlACUAHQAlACUAIAAlAB0AHQAlACUAJQAlACUAJQAlACUAHgAeAB4AJQAlACAAIAAgACAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHgAeABcAFwAXABcAFwAXAB4AEwATACUAHgAeAB4AFgARABYAEQAWABEAFgARABYAEQAWABEAFgARAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARABYAEQAWABEAFgARABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAEAAQABAAeAB4AKwArACsAKwArABMADQANAA0AUAATAA0AUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUAANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAA0ADQANAA0ADQANAA0ADQAeAA0AFgANAB4AHgAXABcAHgAeABcAFwAWABEAFgARABYAEQAWABEADQANAA0ADQATAFAADQANAB4ADQANAB4AHgAeAB4AHgAMAAwADQANAA0AHgANAA0AFgANAA0ADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArAA0AEQARACUAJQBHAFcAVwAWABEAFgARABYAEQAWABEAFgARACUAJQAWABEAFgARABYAEQAWABEAFQAWABEAEQAlAFcAVwBXAFcAVwBXAFcAVwBXAAQABAAEAAQABAAEACUAVwBXAFcAVwA2ACUAJQBXAFcAVwBHAEcAJQAlACUAKwBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBRAFcAUQBXAFEAVwBXAFcAVwBXAFcAUQBXAFcAVwBXAFcAVwBRAFEAKwArAAQABAAVABUARwBHAFcAFQBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBRAFcAVwBXAFcAVwBXAFEAUQBXAFcAVwBXABUAUQBHAEcAVwArACsAKwArACsAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwArACUAJQBXAFcAVwBXACUAJQAlACUAJQAlACUAJQAlACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArACsAKwArACUAJQAlACUAKwArACsAKwArACsAKwArACsAKwArACsAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACsAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAE8ATwBPAE8ATwBPAE8ATwAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlACUAJQAlACUAJQAlACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADQATAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABLAEsASwBLAEsASwBLAEsASwBLAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAABAAEAAQABAAeAAQABAAEAAQABAAEAAQABAAEAAQAHgBQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUABQAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAeAA0ADQANAA0ADQArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAAQAUABQAFAABABQAFAAUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAeAB4AHgAeACsAKwArACsAUABQAFAAUABQAFAAHgAeABoAHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADgAOABMAEwArACsAKwArACsAKwArACsABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwANAA0ASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUAAeAB4AHgBQAA4AUAArACsAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArAB4AWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYACsAKwArAAQAHgAeAB4AHgAeAB4ADQANAA0AHgAeAB4AHgArAFAASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArAB4AHgBcAFwAXABcAFwAKgBcAFwAXABcAFwAXABcAFwAXABcAEsASwBLAEsASwBLAEsASwBLAEsAXABcAFwAXABcACsAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAFAAUABQAAQAUABQAFAAUABQAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAHgANAA0ADQBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAXAAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAKgAqACoAXABcACoAKgBcAFwAXABcAFwAKgAqAFwAKgBcACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcACoAKgBQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAA0ADQBQAFAAUAAEAAQAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQADQAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAVABVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBUAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVACsAKwArACsAKwArACsAKwArACsAKwArAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAKwArACsAKwBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAKwArACsAKwAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAKwArACsAKwArAFYABABWAFYAVgBWAFYAVgBWAFYAVgBWAB4AVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgArAFYAVgBWAFYAVgArAFYAKwBWAFYAKwBWAFYAKwBWAFYAVgBWAFYAVgBWAFYAVgBWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAEQAWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAaAB4AKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAGAARABEAGAAYABMAEwAWABEAFAArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACUAJQAlACUAJQAWABEAFgARABYAEQAWABEAFgARABYAEQAlACUAFgARACUAJQAlACUAJQAlACUAEQAlABEAKwAVABUAEwATACUAFgARABYAEQAWABEAJQAlACUAJQAlACUAJQAlACsAJQAbABoAJQArACsAKwArAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAcAKwATACUAJQAbABoAJQAlABYAEQAlACUAEQAlABEAJQBXAFcAVwBXAFcAVwBXAFcAVwBXABUAFQAlACUAJQATACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXABYAJQARACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAWACUAEQAlABYAEQARABYAEQARABUAVwBRAFEAUQBRAFEAUQBRAFEAUQBRAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcARwArACsAVwBXAFcAVwBXAFcAKwArAFcAVwBXAFcAVwBXACsAKwBXAFcAVwBXAFcAVwArACsAVwBXAFcAKwArACsAGgAbACUAJQAlABsAGwArAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAAQAB0AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsADQANAA0AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsADQBQAFAAUABQACsAKwArACsAUABQAFAAUABQAFAAUABQAA0AUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAArACsAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQACsAKwArAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgBQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwBQAFAAUABQAFAABAAEAAQAKwAEAAQAKwArACsAKwArAAQABAAEAAQAUABQAFAAUAArAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsABAAEAAQAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsADQANAA0ADQANAA0ADQANAB4AKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AUABQAFAAUABQAFAAUABQAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwArACsAUABQAFAAUABQAA0ADQANAA0ADQANABQAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwANAA0ADQANAA0ADQANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAA0ADQAeAB4AHgAeAB4AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsASwBLAEsASwBLAEsASwBLAEsASwANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAeAA4AUAArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAADQANAB4ADQAeAAQABAAEAB4AKwArAEsASwBLAEsASwBLAEsASwBLAEsAUAAOAFAADQANAA0AKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAANAA0AHgANAA0AHgAEACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAA0AKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsABAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAUAArACsAKwArACsAKwAEACsAKwArACsAKwBQAFAAUABQAFAABAAEACsAKwAEAAQABAAEAAQABAAEACsAKwArAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABABQAFAAUABQAA0ADQANAA0AHgBLAEsASwBLAEsASwBLAEsASwBLACsADQArAB4AKwArAAQABAAEAAQAUABQAB4AUAArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEACsAKwAEAAQABAAEAAQABAAEAAQABAAOAA0ADQATABMAHgAeAB4ADQANAA0ADQANAA0ADQANAA0ADQANAA0ADQANAA0AUABQAFAAUAAEAAQAKwArAAQADQANAB4AUAArACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAKwAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAXABcAA0ADQANACoASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAFAABAAEAAQABAAOAB4ADQANAA0ADQAOAB4ABAArACsAKwArACsAKwArACsAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAUABQAFAAUAArACsAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAA0ADQANACsADgAOAA4ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAAQABAAEAFAADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAOABMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAArACsAKwAEACsABAAEACsABAAEAAQABAAEAAQABABQAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABIAEgAQwBDAEMAUABQAFAAUABDAFAAUABQAEgAQwBIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABDAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwANAA0AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAANACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAA0ADQANAB4AHgAeAB4AHgAeAFAAUABQAFAADQAeACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAEcARwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwArACsAKwArACsAKwArACsAKwArACsAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQACsAKwAeAAQABAANAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAB4AHgAeAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAHgAeAAQABAAEAAQABAAEAAQAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAEAAQABAAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAFAAUAArACsAUAArACsAUABQACsAKwBQAFAAUABQACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQACsAUABQAFAAUABQAFAAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAKwAeAB4AUABQAFAAUABQACsAUAArACsAKwBQAFAAUABQAFAAUABQACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AKwArAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAEAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAeAB4ADQANAA0ADQAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABAArAAQABAArAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAEAAQABAAEAAQABAAEACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAFgAWAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArAFAAKwArAFAAKwBQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArAFAAKwBQACsAKwArACsAKwArAFAAKwArACsAKwBQACsAUAArAFAAKwBQAFAAUAArAFAAUAArAFAAKwArAFAAKwBQACsAUAArAFAAKwBQACsAUABQACsAUAArACsAUABQAFAAUAArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQACsAUABQAFAAUAArAFAAKwBQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwBQAFAAUAArAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwAlACUAJQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAeACUAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeACUAJQAlACUAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeACUAJQAlACUAJQAeACUAJQAlACUAJQAgACAAIAAlACUAIAAlACUAIAAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAIQAhACEAIQAhACUAJQAgACAAJQAlACAAIAAgACAAIAAgACAAIAAgACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAIAAgACAAIAAlACUAJQAlACAAJQAgACAAIAAgACAAIAAgACAAIAAlACUAJQAgACUAJQAlACUAIAAgACAAJQAgACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeACUAHgAlAB4AJQAlACUAJQAlACAAJQAlACUAJQAeACUAHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAIAAgACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAIAAlACUAJQAlACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAIAAgACAAJQAlACUAIAAgACAAIAAgAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFwAXABcAFQAVABUAHgAeAB4AHgAlACUAJQAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAIAAgACAAJQAlACUAJQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAlACAAIAAlACUAJQAlACUAJQAgACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAIAAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACsAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsA';\n\n /* @flow */\r\n var LETTER_NUMBER_MODIFIER = 50;\r\n // Non-tailorable Line Breaking Classes\r\n var BK = 1; // Cause a line break (after)\r\n var CR = 2; // Cause a line break (after), except between CR and LF\r\n var LF = 3; // Cause a line break (after)\r\n var CM = 4; // Prohibit a line break between the character and the preceding character\r\n var NL = 5; // Cause a line break (after)\r\n var WJ = 7; // Prohibit line breaks before and after\r\n var ZW = 8; // Provide a break opportunity\r\n var GL = 9; // Prohibit line breaks before and after\r\n var SP = 10; // Enable indirect line breaks\r\n var ZWJ = 11; // Prohibit line breaks within joiner sequences\r\n // Break Opportunities\r\n var B2 = 12; // Provide a line break opportunity before and after the character\r\n var BA = 13; // Generally provide a line break opportunity after the character\r\n var BB = 14; // Generally provide a line break opportunity before the character\r\n var HY = 15; // Provide a line break opportunity after the character, except in numeric context\r\n var CB = 16; // Provide a line break opportunity contingent on additional information\r\n // Characters Prohibiting Certain Breaks\r\n var CL = 17; // Prohibit line breaks before\r\n var CP = 18; // Prohibit line breaks before\r\n var EX = 19; // Prohibit line breaks before\r\n var IN = 20; // Allow only indirect line breaks between pairs\r\n var NS = 21; // Allow only indirect line breaks before\r\n var OP = 22; // Prohibit line breaks after\r\n var QU = 23; // Act like they are both opening and closing\r\n // Numeric Context\r\n var IS = 24; // Prevent breaks after any and before numeric\r\n var NU = 25; // Form numeric expressions for line breaking purposes\r\n var PO = 26; // Do not break following a numeric expression\r\n var PR = 27; // Do not break in front of a numeric expression\r\n var SY = 28; // Prevent a break before; and allow a break after\r\n // Other Characters\r\n var AI = 29; // Act like AL when the resolvedEAW is N; otherwise; act as ID\r\n var AL = 30; // Are alphabetic characters or symbols that are used with alphabetic characters\r\n var CJ = 31; // Treat as NS or ID for strict or normal breaking.\r\n var EB = 32; // Do not break from following Emoji Modifier\r\n var EM = 33; // Do not break from preceding Emoji Base\r\n var H2 = 34; // Form Korean syllable blocks\r\n var H3 = 35; // Form Korean syllable blocks\r\n var HL = 36; // Do not break around a following hyphen; otherwise act as Alphabetic\r\n var ID = 37; // Break before or after; except in some numeric context\r\n var JL = 38; // Form Korean syllable blocks\r\n var JV = 39; // Form Korean syllable blocks\r\n var JT = 40; // Form Korean syllable blocks\r\n var RI = 41; // Keep pairs together. For pairs; break before and after other classes\r\n var SA = 42; // Provide a line break opportunity contingent on additional, language-specific context analysis\r\n var XX = 43; // Have as yet unknown line breaking behavior or unassigned code positions\r\n var BREAK_MANDATORY = '!';\r\n var BREAK_NOT_ALLOWED = '×';\r\n var BREAK_ALLOWED = '÷';\r\n var UnicodeTrie = createTrieFromBase64(base64);\r\n var ALPHABETICS = [AL, HL];\r\n var HARD_LINE_BREAKS = [BK, CR, LF, NL];\r\n var SPACE = [SP, ZW];\r\n var PREFIX_POSTFIX = [PR, PO];\r\n var LINE_BREAKS = HARD_LINE_BREAKS.concat(SPACE);\r\n var KOREAN_SYLLABLE_BLOCK = [JL, JV, JT, H2, H3];\r\n var HYPHEN = [HY, BA];\r\n var codePointsToCharacterClasses = function (codePoints, lineBreak) {\r\n if (lineBreak === void 0) { lineBreak = 'strict'; }\r\n var types = [];\r\n var indicies = [];\r\n var categories = [];\r\n codePoints.forEach(function (codePoint, index) {\r\n var classType = UnicodeTrie.get(codePoint);\r\n if (classType > LETTER_NUMBER_MODIFIER) {\r\n categories.push(true);\r\n classType -= LETTER_NUMBER_MODIFIER;\r\n }\r\n else {\r\n categories.push(false);\r\n }\r\n if (['normal', 'auto', 'loose'].indexOf(lineBreak) !== -1) {\r\n // U+2010, – U+2013, 〜 U+301C, ゠ U+30A0\r\n if ([0x2010, 0x2013, 0x301c, 0x30a0].indexOf(codePoint) !== -1) {\r\n indicies.push(index);\r\n return types.push(CB);\r\n }\r\n }\r\n if (classType === CM || classType === ZWJ) {\r\n // LB10 Treat any remaining combining mark or ZWJ as AL.\r\n if (index === 0) {\r\n indicies.push(index);\r\n return types.push(AL);\r\n }\r\n // LB9 Do not break a combining character sequence; treat it as if it has the line breaking class of\r\n // the base character in all of the following rules. Treat ZWJ as if it were CM.\r\n var prev = types[index - 1];\r\n if (LINE_BREAKS.indexOf(prev) === -1) {\r\n indicies.push(indicies[index - 1]);\r\n return types.push(prev);\r\n }\r\n indicies.push(index);\r\n return types.push(AL);\r\n }\r\n indicies.push(index);\r\n if (classType === CJ) {\r\n return types.push(lineBreak === 'strict' ? NS : ID);\r\n }\r\n if (classType === SA) {\r\n return types.push(AL);\r\n }\r\n if (classType === AI) {\r\n return types.push(AL);\r\n }\r\n // For supplementary characters, a useful default is to treat characters in the range 10000..1FFFD as AL\r\n // and characters in the ranges 20000..2FFFD and 30000..3FFFD as ID, until the implementation can be revised\r\n // to take into account the actual line breaking properties for these characters.\r\n if (classType === XX) {\r\n if ((codePoint >= 0x20000 && codePoint <= 0x2fffd) || (codePoint >= 0x30000 && codePoint <= 0x3fffd)) {\r\n return types.push(ID);\r\n }\r\n else {\r\n return types.push(AL);\r\n }\r\n }\r\n types.push(classType);\r\n });\r\n return [indicies, types, categories];\r\n };\r\n var isAdjacentWithSpaceIgnored = function (a, b, currentIndex, classTypes) {\r\n var current = classTypes[currentIndex];\r\n if (Array.isArray(a) ? a.indexOf(current) !== -1 : a === current) {\r\n var i = currentIndex;\r\n while (i <= classTypes.length) {\r\n i++;\r\n var next = classTypes[i];\r\n if (next === b) {\r\n return true;\r\n }\r\n if (next !== SP) {\r\n break;\r\n }\r\n }\r\n }\r\n if (current === SP) {\r\n var i = currentIndex;\r\n while (i > 0) {\r\n i--;\r\n var prev = classTypes[i];\r\n if (Array.isArray(a) ? a.indexOf(prev) !== -1 : a === prev) {\r\n var n = currentIndex;\r\n while (n <= classTypes.length) {\r\n n++;\r\n var next = classTypes[n];\r\n if (next === b) {\r\n return true;\r\n }\r\n if (next !== SP) {\r\n break;\r\n }\r\n }\r\n }\r\n if (prev !== SP) {\r\n break;\r\n }\r\n }\r\n }\r\n return false;\r\n };\r\n var previousNonSpaceClassType = function (currentIndex, classTypes) {\r\n var i = currentIndex;\r\n while (i >= 0) {\r\n var type = classTypes[i];\r\n if (type === SP) {\r\n i--;\r\n }\r\n else {\r\n return type;\r\n }\r\n }\r\n return 0;\r\n };\r\n var _lineBreakAtIndex = function (codePoints, classTypes, indicies, index, forbiddenBreaks) {\r\n if (indicies[index] === 0) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n var currentIndex = index - 1;\r\n if (Array.isArray(forbiddenBreaks) && forbiddenBreaks[currentIndex] === true) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n var beforeIndex = currentIndex - 1;\r\n var afterIndex = currentIndex + 1;\r\n var current = classTypes[currentIndex];\r\n // LB4 Always break after hard line breaks.\r\n // LB5 Treat CR followed by LF, as well as CR, LF, and NL as hard line breaks.\r\n var before = beforeIndex >= 0 ? classTypes[beforeIndex] : 0;\r\n var next = classTypes[afterIndex];\r\n if (current === CR && next === LF) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n if (HARD_LINE_BREAKS.indexOf(current) !== -1) {\r\n return BREAK_MANDATORY;\r\n }\r\n // LB6 Do not break before hard line breaks.\r\n if (HARD_LINE_BREAKS.indexOf(next) !== -1) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB7 Do not break before spaces or zero width space.\r\n if (SPACE.indexOf(next) !== -1) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB8 Break before any character following a zero-width space, even if one or more spaces intervene.\r\n if (previousNonSpaceClassType(currentIndex, classTypes) === ZW) {\r\n return BREAK_ALLOWED;\r\n }\r\n // LB8a Do not break between a zero width joiner and an ideograph, emoji base or emoji modifier.\r\n if (UnicodeTrie.get(codePoints[currentIndex]) === ZWJ && (next === ID || next === EB || next === EM)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB11 Do not break before or after Word joiner and related characters.\r\n if (current === WJ || next === WJ) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB12 Do not break after NBSP and related characters.\r\n if (current === GL) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB12a Do not break before NBSP and related characters, except after spaces and hyphens.\r\n if ([SP, BA, HY].indexOf(current) === -1 && next === GL) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB13 Do not break before ‘]’ or ‘!’ or ‘;’ or ‘/’, even after spaces.\r\n if ([CL, CP, EX, IS, SY].indexOf(next) !== -1) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB14 Do not break after ‘[’, even after spaces.\r\n if (previousNonSpaceClassType(currentIndex, classTypes) === OP) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB15 Do not break within ‘”[’, even with intervening spaces.\r\n if (isAdjacentWithSpaceIgnored(QU, OP, currentIndex, classTypes)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB16 Do not break between closing punctuation and a nonstarter (lb=NS), even with intervening spaces.\r\n if (isAdjacentWithSpaceIgnored([CL, CP], NS, currentIndex, classTypes)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB17 Do not break within ‘——’, even with intervening spaces.\r\n if (isAdjacentWithSpaceIgnored(B2, B2, currentIndex, classTypes)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB18 Break after spaces.\r\n if (current === SP) {\r\n return BREAK_ALLOWED;\r\n }\r\n // LB19 Do not break before or after quotation marks, such as ‘ ” ’.\r\n if (current === QU || next === QU) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB20 Break before and after unresolved CB.\r\n if (next === CB || current === CB) {\r\n return BREAK_ALLOWED;\r\n }\r\n // LB21 Do not break before hyphen-minus, other hyphens, fixed-width spaces, small kana, and other non-starters, or after acute accents.\r\n if ([BA, HY, NS].indexOf(next) !== -1 || current === BB) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB21a Don't break after Hebrew + Hyphen.\r\n if (before === HL && HYPHEN.indexOf(current) !== -1) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB21b Don’t break between Solidus and Hebrew letters.\r\n if (current === SY && next === HL) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB22 Do not break between two ellipses, or between letters, numbers or exclamations and ellipsis.\r\n if (next === IN && ALPHABETICS.concat(IN, EX, NU, ID, EB, EM).indexOf(current) !== -1) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB23 Do not break between digits and letters.\r\n if ((ALPHABETICS.indexOf(next) !== -1 && current === NU) || (ALPHABETICS.indexOf(current) !== -1 && next === NU)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB23a Do not break between numeric prefixes and ideographs, or between ideographs and numeric postfixes.\r\n if ((current === PR && [ID, EB, EM].indexOf(next) !== -1) ||\r\n ([ID, EB, EM].indexOf(current) !== -1 && next === PO)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB24 Do not break between numeric prefix/postfix and letters, or between letters and prefix/postfix.\r\n if ((ALPHABETICS.indexOf(current) !== -1 && PREFIX_POSTFIX.indexOf(next) !== -1) ||\r\n (PREFIX_POSTFIX.indexOf(current) !== -1 && ALPHABETICS.indexOf(next) !== -1)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB25 Do not break between the following pairs of classes relevant to numbers:\r\n if (\r\n // (PR | PO) × ( OP | HY )? NU\r\n ([PR, PO].indexOf(current) !== -1 &&\r\n (next === NU || ([OP, HY].indexOf(next) !== -1 && classTypes[afterIndex + 1] === NU))) ||\r\n // ( OP | HY ) × NU\r\n ([OP, HY].indexOf(current) !== -1 && next === NU) ||\r\n // NU ×\t(NU | SY | IS)\r\n (current === NU && [NU, SY, IS].indexOf(next) !== -1)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // NU (NU | SY | IS)* × (NU | SY | IS | CL | CP)\r\n if ([NU, SY, IS, CL, CP].indexOf(next) !== -1) {\r\n var prevIndex = currentIndex;\r\n while (prevIndex >= 0) {\r\n var type = classTypes[prevIndex];\r\n if (type === NU) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n else if ([SY, IS].indexOf(type) !== -1) {\r\n prevIndex--;\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n // NU (NU | SY | IS)* (CL | CP)? × (PO | PR))\r\n if ([PR, PO].indexOf(next) !== -1) {\r\n var prevIndex = [CL, CP].indexOf(current) !== -1 ? beforeIndex : currentIndex;\r\n while (prevIndex >= 0) {\r\n var type = classTypes[prevIndex];\r\n if (type === NU) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n else if ([SY, IS].indexOf(type) !== -1) {\r\n prevIndex--;\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n // LB26 Do not break a Korean syllable.\r\n if ((JL === current && [JL, JV, H2, H3].indexOf(next) !== -1) ||\r\n ([JV, H2].indexOf(current) !== -1 && [JV, JT].indexOf(next) !== -1) ||\r\n ([JT, H3].indexOf(current) !== -1 && next === JT)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB27 Treat a Korean Syllable Block the same as ID.\r\n if ((KOREAN_SYLLABLE_BLOCK.indexOf(current) !== -1 && [IN, PO].indexOf(next) !== -1) ||\r\n (KOREAN_SYLLABLE_BLOCK.indexOf(next) !== -1 && current === PR)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB28 Do not break between alphabetics (“at”).\r\n if (ALPHABETICS.indexOf(current) !== -1 && ALPHABETICS.indexOf(next) !== -1) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB29 Do not break between numeric punctuation and alphabetics (“e.g.”).\r\n if (current === IS && ALPHABETICS.indexOf(next) !== -1) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB30 Do not break between letters, numbers, or ordinary symbols and opening or closing parentheses.\r\n if ((ALPHABETICS.concat(NU).indexOf(current) !== -1 && next === OP) ||\r\n (ALPHABETICS.concat(NU).indexOf(next) !== -1 && current === CP)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB30a Break between two regional indicator symbols if and only if there are an even number of regional\r\n // indicators preceding the position of the break.\r\n if (current === RI && next === RI) {\r\n var i = indicies[currentIndex];\r\n var count = 1;\r\n while (i > 0) {\r\n i--;\r\n if (classTypes[i] === RI) {\r\n count++;\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n if (count % 2 !== 0) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n }\r\n // LB30b Do not break between an emoji base and an emoji modifier.\r\n if (current === EB && next === EM) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n return BREAK_ALLOWED;\r\n };\r\n var cssFormattedClasses = function (codePoints, options) {\r\n if (!options) {\r\n options = { lineBreak: 'normal', wordBreak: 'normal' };\r\n }\r\n var _a = codePointsToCharacterClasses(codePoints, options.lineBreak), indicies = _a[0], classTypes = _a[1], isLetterNumber = _a[2];\r\n if (options.wordBreak === 'break-all' || options.wordBreak === 'break-word') {\r\n classTypes = classTypes.map(function (type) { return ([NU, AL, SA].indexOf(type) !== -1 ? ID : type); });\r\n }\r\n var forbiddenBreakpoints = options.wordBreak === 'keep-all'\r\n ? isLetterNumber.map(function (letterNumber, i) {\r\n return letterNumber && codePoints[i] >= 0x4e00 && codePoints[i] <= 0x9fff;\r\n })\r\n : undefined;\r\n return [indicies, classTypes, forbiddenBreakpoints];\r\n };\r\n var Break = /** @class */ (function () {\r\n function Break(codePoints, lineBreak, start, end) {\r\n this.codePoints = codePoints;\r\n this.required = lineBreak === BREAK_MANDATORY;\r\n this.start = start;\r\n this.end = end;\r\n }\r\n Break.prototype.slice = function () {\r\n return fromCodePoint.apply(void 0, this.codePoints.slice(this.start, this.end));\r\n };\r\n return Break;\r\n }());\r\n var LineBreaker = function (str, options) {\r\n var codePoints = toCodePoints(str);\r\n var _a = cssFormattedClasses(codePoints, options), indicies = _a[0], classTypes = _a[1], forbiddenBreakpoints = _a[2];\r\n var length = codePoints.length;\r\n var lastEnd = 0;\r\n var nextIndex = 0;\r\n return {\r\n next: function () {\r\n if (nextIndex >= length) {\r\n return { done: true, value: null };\r\n }\r\n var lineBreak = BREAK_NOT_ALLOWED;\r\n while (nextIndex < length &&\r\n (lineBreak = _lineBreakAtIndex(codePoints, classTypes, indicies, ++nextIndex, forbiddenBreakpoints)) ===\r\n BREAK_NOT_ALLOWED) { }\r\n if (lineBreak !== BREAK_NOT_ALLOWED || nextIndex === length) {\r\n var value = new Break(codePoints, lineBreak, lastEnd, nextIndex);\r\n lastEnd = nextIndex;\r\n return { value: value, done: false };\r\n }\r\n return { done: true, value: null };\r\n },\r\n };\r\n };\n\n // https://www.w3.org/TR/css-syntax-3\r\n var TokenType;\r\n (function (TokenType) {\r\n TokenType[TokenType[\"STRING_TOKEN\"] = 0] = \"STRING_TOKEN\";\r\n TokenType[TokenType[\"BAD_STRING_TOKEN\"] = 1] = \"BAD_STRING_TOKEN\";\r\n TokenType[TokenType[\"LEFT_PARENTHESIS_TOKEN\"] = 2] = \"LEFT_PARENTHESIS_TOKEN\";\r\n TokenType[TokenType[\"RIGHT_PARENTHESIS_TOKEN\"] = 3] = \"RIGHT_PARENTHESIS_TOKEN\";\r\n TokenType[TokenType[\"COMMA_TOKEN\"] = 4] = \"COMMA_TOKEN\";\r\n TokenType[TokenType[\"HASH_TOKEN\"] = 5] = \"HASH_TOKEN\";\r\n TokenType[TokenType[\"DELIM_TOKEN\"] = 6] = \"DELIM_TOKEN\";\r\n TokenType[TokenType[\"AT_KEYWORD_TOKEN\"] = 7] = \"AT_KEYWORD_TOKEN\";\r\n TokenType[TokenType[\"PREFIX_MATCH_TOKEN\"] = 8] = \"PREFIX_MATCH_TOKEN\";\r\n TokenType[TokenType[\"DASH_MATCH_TOKEN\"] = 9] = \"DASH_MATCH_TOKEN\";\r\n TokenType[TokenType[\"INCLUDE_MATCH_TOKEN\"] = 10] = \"INCLUDE_MATCH_TOKEN\";\r\n TokenType[TokenType[\"LEFT_CURLY_BRACKET_TOKEN\"] = 11] = \"LEFT_CURLY_BRACKET_TOKEN\";\r\n TokenType[TokenType[\"RIGHT_CURLY_BRACKET_TOKEN\"] = 12] = \"RIGHT_CURLY_BRACKET_TOKEN\";\r\n TokenType[TokenType[\"SUFFIX_MATCH_TOKEN\"] = 13] = \"SUFFIX_MATCH_TOKEN\";\r\n TokenType[TokenType[\"SUBSTRING_MATCH_TOKEN\"] = 14] = \"SUBSTRING_MATCH_TOKEN\";\r\n TokenType[TokenType[\"DIMENSION_TOKEN\"] = 15] = \"DIMENSION_TOKEN\";\r\n TokenType[TokenType[\"PERCENTAGE_TOKEN\"] = 16] = \"PERCENTAGE_TOKEN\";\r\n TokenType[TokenType[\"NUMBER_TOKEN\"] = 17] = \"NUMBER_TOKEN\";\r\n TokenType[TokenType[\"FUNCTION\"] = 18] = \"FUNCTION\";\r\n TokenType[TokenType[\"FUNCTION_TOKEN\"] = 19] = \"FUNCTION_TOKEN\";\r\n TokenType[TokenType[\"IDENT_TOKEN\"] = 20] = \"IDENT_TOKEN\";\r\n TokenType[TokenType[\"COLUMN_TOKEN\"] = 21] = \"COLUMN_TOKEN\";\r\n TokenType[TokenType[\"URL_TOKEN\"] = 22] = \"URL_TOKEN\";\r\n TokenType[TokenType[\"BAD_URL_TOKEN\"] = 23] = \"BAD_URL_TOKEN\";\r\n TokenType[TokenType[\"CDC_TOKEN\"] = 24] = \"CDC_TOKEN\";\r\n TokenType[TokenType[\"CDO_TOKEN\"] = 25] = \"CDO_TOKEN\";\r\n TokenType[TokenType[\"COLON_TOKEN\"] = 26] = \"COLON_TOKEN\";\r\n TokenType[TokenType[\"SEMICOLON_TOKEN\"] = 27] = \"SEMICOLON_TOKEN\";\r\n TokenType[TokenType[\"LEFT_SQUARE_BRACKET_TOKEN\"] = 28] = \"LEFT_SQUARE_BRACKET_TOKEN\";\r\n TokenType[TokenType[\"RIGHT_SQUARE_BRACKET_TOKEN\"] = 29] = \"RIGHT_SQUARE_BRACKET_TOKEN\";\r\n TokenType[TokenType[\"UNICODE_RANGE_TOKEN\"] = 30] = \"UNICODE_RANGE_TOKEN\";\r\n TokenType[TokenType[\"WHITESPACE_TOKEN\"] = 31] = \"WHITESPACE_TOKEN\";\r\n TokenType[TokenType[\"EOF_TOKEN\"] = 32] = \"EOF_TOKEN\";\r\n })(TokenType || (TokenType = {}));\r\n var FLAG_UNRESTRICTED = 1 << 0;\r\n var FLAG_ID = 1 << 1;\r\n var FLAG_INTEGER = 1 << 2;\r\n var FLAG_NUMBER = 1 << 3;\r\n var LINE_FEED = 0x000a;\r\n var SOLIDUS = 0x002f;\r\n var REVERSE_SOLIDUS = 0x005c;\r\n var CHARACTER_TABULATION = 0x0009;\r\n var SPACE$1 = 0x0020;\r\n var QUOTATION_MARK = 0x0022;\r\n var EQUALS_SIGN = 0x003d;\r\n var NUMBER_SIGN = 0x0023;\r\n var DOLLAR_SIGN = 0x0024;\r\n var PERCENTAGE_SIGN = 0x0025;\r\n var APOSTROPHE = 0x0027;\r\n var LEFT_PARENTHESIS = 0x0028;\r\n var RIGHT_PARENTHESIS = 0x0029;\r\n var LOW_LINE = 0x005f;\r\n var HYPHEN_MINUS = 0x002d;\r\n var EXCLAMATION_MARK = 0x0021;\r\n var LESS_THAN_SIGN = 0x003c;\r\n var GREATER_THAN_SIGN = 0x003e;\r\n var COMMERCIAL_AT = 0x0040;\r\n var LEFT_SQUARE_BRACKET = 0x005b;\r\n var RIGHT_SQUARE_BRACKET = 0x005d;\r\n var CIRCUMFLEX_ACCENT = 0x003d;\r\n var LEFT_CURLY_BRACKET = 0x007b;\r\n var QUESTION_MARK = 0x003f;\r\n var RIGHT_CURLY_BRACKET = 0x007d;\r\n var VERTICAL_LINE = 0x007c;\r\n var TILDE = 0x007e;\r\n var CONTROL = 0x0080;\r\n var REPLACEMENT_CHARACTER = 0xfffd;\r\n var ASTERISK = 0x002a;\r\n var PLUS_SIGN = 0x002b;\r\n var COMMA = 0x002c;\r\n var COLON = 0x003a;\r\n var SEMICOLON = 0x003b;\r\n var FULL_STOP = 0x002e;\r\n var NULL = 0x0000;\r\n var BACKSPACE = 0x0008;\r\n var LINE_TABULATION = 0x000b;\r\n var SHIFT_OUT = 0x000e;\r\n var INFORMATION_SEPARATOR_ONE = 0x001f;\r\n var DELETE = 0x007f;\r\n var EOF = -1;\r\n var ZERO = 0x0030;\r\n var a = 0x0061;\r\n var e = 0x0065;\r\n var f = 0x0066;\r\n var u = 0x0075;\r\n var z = 0x007a;\r\n var A = 0x0041;\r\n var E = 0x0045;\r\n var F = 0x0046;\r\n var U = 0x0055;\r\n var Z = 0x005a;\r\n var isDigit = function (codePoint) { return codePoint >= ZERO && codePoint <= 0x0039; };\r\n var isSurrogateCodePoint = function (codePoint) { return codePoint >= 0xd800 && codePoint <= 0xdfff; };\r\n var isHex = function (codePoint) {\r\n return isDigit(codePoint) || (codePoint >= A && codePoint <= F) || (codePoint >= a && codePoint <= f);\r\n };\r\n var isLowerCaseLetter = function (codePoint) { return codePoint >= a && codePoint <= z; };\r\n var isUpperCaseLetter = function (codePoint) { return codePoint >= A && codePoint <= Z; };\r\n var isLetter = function (codePoint) { return isLowerCaseLetter(codePoint) || isUpperCaseLetter(codePoint); };\r\n var isNonASCIICodePoint = function (codePoint) { return codePoint >= CONTROL; };\r\n var isWhiteSpace = function (codePoint) {\r\n return codePoint === LINE_FEED || codePoint === CHARACTER_TABULATION || codePoint === SPACE$1;\r\n };\r\n var isNameStartCodePoint = function (codePoint) {\r\n return isLetter(codePoint) || isNonASCIICodePoint(codePoint) || codePoint === LOW_LINE;\r\n };\r\n var isNameCodePoint = function (codePoint) {\r\n return isNameStartCodePoint(codePoint) || isDigit(codePoint) || codePoint === HYPHEN_MINUS;\r\n };\r\n var isNonPrintableCodePoint = function (codePoint) {\r\n return ((codePoint >= NULL && codePoint <= BACKSPACE) ||\r\n codePoint === LINE_TABULATION ||\r\n (codePoint >= SHIFT_OUT && codePoint <= INFORMATION_SEPARATOR_ONE) ||\r\n codePoint === DELETE);\r\n };\r\n var isValidEscape = function (c1, c2) {\r\n if (c1 !== REVERSE_SOLIDUS) {\r\n return false;\r\n }\r\n return c2 !== LINE_FEED;\r\n };\r\n var isIdentifierStart = function (c1, c2, c3) {\r\n if (c1 === HYPHEN_MINUS) {\r\n return isNameStartCodePoint(c2) || isValidEscape(c2, c3);\r\n }\r\n else if (isNameStartCodePoint(c1)) {\r\n return true;\r\n }\r\n else if (c1 === REVERSE_SOLIDUS && isValidEscape(c1, c2)) {\r\n return true;\r\n }\r\n return false;\r\n };\r\n var isNumberStart = function (c1, c2, c3) {\r\n if (c1 === PLUS_SIGN || c1 === HYPHEN_MINUS) {\r\n if (isDigit(c2)) {\r\n return true;\r\n }\r\n return c2 === FULL_STOP && isDigit(c3);\r\n }\r\n if (c1 === FULL_STOP) {\r\n return isDigit(c2);\r\n }\r\n return isDigit(c1);\r\n };\r\n var stringToNumber = function (codePoints) {\r\n var c = 0;\r\n var sign = 1;\r\n if (codePoints[c] === PLUS_SIGN || codePoints[c] === HYPHEN_MINUS) {\r\n if (codePoints[c] === HYPHEN_MINUS) {\r\n sign = -1;\r\n }\r\n c++;\r\n }\r\n var integers = [];\r\n while (isDigit(codePoints[c])) {\r\n integers.push(codePoints[c++]);\r\n }\r\n var int = integers.length ? parseInt(fromCodePoint.apply(void 0, integers), 10) : 0;\r\n if (codePoints[c] === FULL_STOP) {\r\n c++;\r\n }\r\n var fraction = [];\r\n while (isDigit(codePoints[c])) {\r\n fraction.push(codePoints[c++]);\r\n }\r\n var fracd = fraction.length;\r\n var frac = fracd ? parseInt(fromCodePoint.apply(void 0, fraction), 10) : 0;\r\n if (codePoints[c] === E || codePoints[c] === e) {\r\n c++;\r\n }\r\n var expsign = 1;\r\n if (codePoints[c] === PLUS_SIGN || codePoints[c] === HYPHEN_MINUS) {\r\n if (codePoints[c] === HYPHEN_MINUS) {\r\n expsign = -1;\r\n }\r\n c++;\r\n }\r\n var exponent = [];\r\n while (isDigit(codePoints[c])) {\r\n exponent.push(codePoints[c++]);\r\n }\r\n var exp = exponent.length ? parseInt(fromCodePoint.apply(void 0, exponent), 10) : 0;\r\n return sign * (int + frac * Math.pow(10, -fracd)) * Math.pow(10, expsign * exp);\r\n };\r\n var LEFT_PARENTHESIS_TOKEN = {\r\n type: TokenType.LEFT_PARENTHESIS_TOKEN\r\n };\r\n var RIGHT_PARENTHESIS_TOKEN = {\r\n type: TokenType.RIGHT_PARENTHESIS_TOKEN\r\n };\r\n var COMMA_TOKEN = { type: TokenType.COMMA_TOKEN };\r\n var SUFFIX_MATCH_TOKEN = { type: TokenType.SUFFIX_MATCH_TOKEN };\r\n var PREFIX_MATCH_TOKEN = { type: TokenType.PREFIX_MATCH_TOKEN };\r\n var COLUMN_TOKEN = { type: TokenType.COLUMN_TOKEN };\r\n var DASH_MATCH_TOKEN = { type: TokenType.DASH_MATCH_TOKEN };\r\n var INCLUDE_MATCH_TOKEN = { type: TokenType.INCLUDE_MATCH_TOKEN };\r\n var LEFT_CURLY_BRACKET_TOKEN = {\r\n type: TokenType.LEFT_CURLY_BRACKET_TOKEN\r\n };\r\n var RIGHT_CURLY_BRACKET_TOKEN = {\r\n type: TokenType.RIGHT_CURLY_BRACKET_TOKEN\r\n };\r\n var SUBSTRING_MATCH_TOKEN = { type: TokenType.SUBSTRING_MATCH_TOKEN };\r\n var BAD_URL_TOKEN = { type: TokenType.BAD_URL_TOKEN };\r\n var BAD_STRING_TOKEN = { type: TokenType.BAD_STRING_TOKEN };\r\n var CDO_TOKEN = { type: TokenType.CDO_TOKEN };\r\n var CDC_TOKEN = { type: TokenType.CDC_TOKEN };\r\n var COLON_TOKEN = { type: TokenType.COLON_TOKEN };\r\n var SEMICOLON_TOKEN = { type: TokenType.SEMICOLON_TOKEN };\r\n var LEFT_SQUARE_BRACKET_TOKEN = {\r\n type: TokenType.LEFT_SQUARE_BRACKET_TOKEN\r\n };\r\n var RIGHT_SQUARE_BRACKET_TOKEN = {\r\n type: TokenType.RIGHT_SQUARE_BRACKET_TOKEN\r\n };\r\n var WHITESPACE_TOKEN = { type: TokenType.WHITESPACE_TOKEN };\r\n var EOF_TOKEN = { type: TokenType.EOF_TOKEN };\r\n var Tokenizer = /** @class */ (function () {\r\n function Tokenizer() {\r\n this._value = [];\r\n }\r\n Tokenizer.prototype.write = function (chunk) {\r\n this._value = this._value.concat(toCodePoints(chunk));\r\n };\r\n Tokenizer.prototype.read = function () {\r\n var tokens = [];\r\n var token = this.consumeToken();\r\n while (token !== EOF_TOKEN) {\r\n tokens.push(token);\r\n token = this.consumeToken();\r\n }\r\n return tokens;\r\n };\r\n Tokenizer.prototype.consumeToken = function () {\r\n var codePoint = this.consumeCodePoint();\r\n switch (codePoint) {\r\n case QUOTATION_MARK:\r\n return this.consumeStringToken(QUOTATION_MARK);\r\n case NUMBER_SIGN:\r\n var c1 = this.peekCodePoint(0);\r\n var c2 = this.peekCodePoint(1);\r\n var c3 = this.peekCodePoint(2);\r\n if (isNameCodePoint(c1) || isValidEscape(c2, c3)) {\r\n var flags = isIdentifierStart(c1, c2, c3) ? FLAG_ID : FLAG_UNRESTRICTED;\r\n var value = this.consumeName();\r\n return { type: TokenType.HASH_TOKEN, value: value, flags: flags };\r\n }\r\n break;\r\n case DOLLAR_SIGN:\r\n if (this.peekCodePoint(0) === EQUALS_SIGN) {\r\n this.consumeCodePoint();\r\n return SUFFIX_MATCH_TOKEN;\r\n }\r\n break;\r\n case APOSTROPHE:\r\n return this.consumeStringToken(APOSTROPHE);\r\n case LEFT_PARENTHESIS:\r\n return LEFT_PARENTHESIS_TOKEN;\r\n case RIGHT_PARENTHESIS:\r\n return RIGHT_PARENTHESIS_TOKEN;\r\n case ASTERISK:\r\n if (this.peekCodePoint(0) === EQUALS_SIGN) {\r\n this.consumeCodePoint();\r\n return SUBSTRING_MATCH_TOKEN;\r\n }\r\n break;\r\n case PLUS_SIGN:\r\n if (isNumberStart(codePoint, this.peekCodePoint(0), this.peekCodePoint(1))) {\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeNumericToken();\r\n }\r\n break;\r\n case COMMA:\r\n return COMMA_TOKEN;\r\n case HYPHEN_MINUS:\r\n var e1 = codePoint;\r\n var e2 = this.peekCodePoint(0);\r\n var e3 = this.peekCodePoint(1);\r\n if (isNumberStart(e1, e2, e3)) {\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeNumericToken();\r\n }\r\n if (isIdentifierStart(e1, e2, e3)) {\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeIdentLikeToken();\r\n }\r\n if (e2 === HYPHEN_MINUS && e3 === GREATER_THAN_SIGN) {\r\n this.consumeCodePoint();\r\n this.consumeCodePoint();\r\n return CDC_TOKEN;\r\n }\r\n break;\r\n case FULL_STOP:\r\n if (isNumberStart(codePoint, this.peekCodePoint(0), this.peekCodePoint(1))) {\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeNumericToken();\r\n }\r\n break;\r\n case SOLIDUS:\r\n if (this.peekCodePoint(0) === ASTERISK) {\r\n this.consumeCodePoint();\r\n while (true) {\r\n var c = this.consumeCodePoint();\r\n if (c === ASTERISK) {\r\n c = this.consumeCodePoint();\r\n if (c === SOLIDUS) {\r\n return this.consumeToken();\r\n }\r\n }\r\n if (c === EOF) {\r\n return this.consumeToken();\r\n }\r\n }\r\n }\r\n break;\r\n case COLON:\r\n return COLON_TOKEN;\r\n case SEMICOLON:\r\n return SEMICOLON_TOKEN;\r\n case LESS_THAN_SIGN:\r\n if (this.peekCodePoint(0) === EXCLAMATION_MARK &&\r\n this.peekCodePoint(1) === HYPHEN_MINUS &&\r\n this.peekCodePoint(2) === HYPHEN_MINUS) {\r\n this.consumeCodePoint();\r\n this.consumeCodePoint();\r\n return CDO_TOKEN;\r\n }\r\n break;\r\n case COMMERCIAL_AT:\r\n var a1 = this.peekCodePoint(0);\r\n var a2 = this.peekCodePoint(1);\r\n var a3 = this.peekCodePoint(2);\r\n if (isIdentifierStart(a1, a2, a3)) {\r\n var value = this.consumeName();\r\n return { type: TokenType.AT_KEYWORD_TOKEN, value: value };\r\n }\r\n break;\r\n case LEFT_SQUARE_BRACKET:\r\n return LEFT_SQUARE_BRACKET_TOKEN;\r\n case REVERSE_SOLIDUS:\r\n if (isValidEscape(codePoint, this.peekCodePoint(0))) {\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeIdentLikeToken();\r\n }\r\n break;\r\n case RIGHT_SQUARE_BRACKET:\r\n return RIGHT_SQUARE_BRACKET_TOKEN;\r\n case CIRCUMFLEX_ACCENT:\r\n if (this.peekCodePoint(0) === EQUALS_SIGN) {\r\n this.consumeCodePoint();\r\n return PREFIX_MATCH_TOKEN;\r\n }\r\n break;\r\n case LEFT_CURLY_BRACKET:\r\n return LEFT_CURLY_BRACKET_TOKEN;\r\n case RIGHT_CURLY_BRACKET:\r\n return RIGHT_CURLY_BRACKET_TOKEN;\r\n case u:\r\n case U:\r\n var u1 = this.peekCodePoint(0);\r\n var u2 = this.peekCodePoint(1);\r\n if (u1 === PLUS_SIGN && (isHex(u2) || u2 === QUESTION_MARK)) {\r\n this.consumeCodePoint();\r\n this.consumeUnicodeRangeToken();\r\n }\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeIdentLikeToken();\r\n case VERTICAL_LINE:\r\n if (this.peekCodePoint(0) === EQUALS_SIGN) {\r\n this.consumeCodePoint();\r\n return DASH_MATCH_TOKEN;\r\n }\r\n if (this.peekCodePoint(0) === VERTICAL_LINE) {\r\n this.consumeCodePoint();\r\n return COLUMN_TOKEN;\r\n }\r\n break;\r\n case TILDE:\r\n if (this.peekCodePoint(0) === EQUALS_SIGN) {\r\n this.consumeCodePoint();\r\n return INCLUDE_MATCH_TOKEN;\r\n }\r\n break;\r\n case EOF:\r\n return EOF_TOKEN;\r\n }\r\n if (isWhiteSpace(codePoint)) {\r\n this.consumeWhiteSpace();\r\n return WHITESPACE_TOKEN;\r\n }\r\n if (isDigit(codePoint)) {\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeNumericToken();\r\n }\r\n if (isNameStartCodePoint(codePoint)) {\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeIdentLikeToken();\r\n }\r\n return { type: TokenType.DELIM_TOKEN, value: fromCodePoint(codePoint) };\r\n };\r\n Tokenizer.prototype.consumeCodePoint = function () {\r\n var value = this._value.shift();\r\n return typeof value === 'undefined' ? -1 : value;\r\n };\r\n Tokenizer.prototype.reconsumeCodePoint = function (codePoint) {\r\n this._value.unshift(codePoint);\r\n };\r\n Tokenizer.prototype.peekCodePoint = function (delta) {\r\n if (delta >= this._value.length) {\r\n return -1;\r\n }\r\n return this._value[delta];\r\n };\r\n Tokenizer.prototype.consumeUnicodeRangeToken = function () {\r\n var digits = [];\r\n var codePoint = this.consumeCodePoint();\r\n while (isHex(codePoint) && digits.length < 6) {\r\n digits.push(codePoint);\r\n codePoint = this.consumeCodePoint();\r\n }\r\n var questionMarks = false;\r\n while (codePoint === QUESTION_MARK && digits.length < 6) {\r\n digits.push(codePoint);\r\n codePoint = this.consumeCodePoint();\r\n questionMarks = true;\r\n }\r\n if (questionMarks) {\r\n var start_1 = parseInt(fromCodePoint.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? ZERO : digit); })), 16);\r\n var end = parseInt(fromCodePoint.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? F : digit); })), 16);\r\n return { type: TokenType.UNICODE_RANGE_TOKEN, start: start_1, end: end };\r\n }\r\n var start = parseInt(fromCodePoint.apply(void 0, digits), 16);\r\n if (this.peekCodePoint(0) === HYPHEN_MINUS && isHex(this.peekCodePoint(1))) {\r\n this.consumeCodePoint();\r\n codePoint = this.consumeCodePoint();\r\n var endDigits = [];\r\n while (isHex(codePoint) && endDigits.length < 6) {\r\n endDigits.push(codePoint);\r\n codePoint = this.consumeCodePoint();\r\n }\r\n var end = parseInt(fromCodePoint.apply(void 0, endDigits), 16);\r\n return { type: TokenType.UNICODE_RANGE_TOKEN, start: start, end: end };\r\n }\r\n else {\r\n return { type: TokenType.UNICODE_RANGE_TOKEN, start: start, end: start };\r\n }\r\n };\r\n Tokenizer.prototype.consumeIdentLikeToken = function () {\r\n var value = this.consumeName();\r\n if (value.toLowerCase() === 'url' && this.peekCodePoint(0) === LEFT_PARENTHESIS) {\r\n this.consumeCodePoint();\r\n return this.consumeUrlToken();\r\n }\r\n else if (this.peekCodePoint(0) === LEFT_PARENTHESIS) {\r\n this.consumeCodePoint();\r\n return { type: TokenType.FUNCTION_TOKEN, value: value };\r\n }\r\n return { type: TokenType.IDENT_TOKEN, value: value };\r\n };\r\n Tokenizer.prototype.consumeUrlToken = function () {\r\n var value = [];\r\n this.consumeWhiteSpace();\r\n if (this.peekCodePoint(0) === EOF) {\r\n return { type: TokenType.URL_TOKEN, value: '' };\r\n }\r\n var next = this.peekCodePoint(0);\r\n if (next === APOSTROPHE || next === QUOTATION_MARK) {\r\n var stringToken = this.consumeStringToken(this.consumeCodePoint());\r\n if (stringToken.type === TokenType.STRING_TOKEN) {\r\n this.consumeWhiteSpace();\r\n if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {\r\n this.consumeCodePoint();\r\n return { type: TokenType.URL_TOKEN, value: stringToken.value };\r\n }\r\n }\r\n this.consumeBadUrlRemnants();\r\n return BAD_URL_TOKEN;\r\n }\r\n while (true) {\r\n var codePoint = this.consumeCodePoint();\r\n if (codePoint === EOF || codePoint === RIGHT_PARENTHESIS) {\r\n return { type: TokenType.URL_TOKEN, value: fromCodePoint.apply(void 0, value) };\r\n }\r\n else if (isWhiteSpace(codePoint)) {\r\n this.consumeWhiteSpace();\r\n if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {\r\n this.consumeCodePoint();\r\n return { type: TokenType.URL_TOKEN, value: fromCodePoint.apply(void 0, value) };\r\n }\r\n this.consumeBadUrlRemnants();\r\n return BAD_URL_TOKEN;\r\n }\r\n else if (codePoint === QUOTATION_MARK ||\r\n codePoint === APOSTROPHE ||\r\n codePoint === LEFT_PARENTHESIS ||\r\n isNonPrintableCodePoint(codePoint)) {\r\n this.consumeBadUrlRemnants();\r\n return BAD_URL_TOKEN;\r\n }\r\n else if (codePoint === REVERSE_SOLIDUS) {\r\n if (isValidEscape(codePoint, this.peekCodePoint(0))) {\r\n value.push(this.consumeEscapedCodePoint());\r\n }\r\n else {\r\n this.consumeBadUrlRemnants();\r\n return BAD_URL_TOKEN;\r\n }\r\n }\r\n else {\r\n value.push(codePoint);\r\n }\r\n }\r\n };\r\n Tokenizer.prototype.consumeWhiteSpace = function () {\r\n while (isWhiteSpace(this.peekCodePoint(0))) {\r\n this.consumeCodePoint();\r\n }\r\n };\r\n Tokenizer.prototype.consumeBadUrlRemnants = function () {\r\n while (true) {\r\n var codePoint = this.consumeCodePoint();\r\n if (codePoint === RIGHT_PARENTHESIS || codePoint === EOF) {\r\n return;\r\n }\r\n if (isValidEscape(codePoint, this.peekCodePoint(0))) {\r\n this.consumeEscapedCodePoint();\r\n }\r\n }\r\n };\r\n Tokenizer.prototype.consumeStringSlice = function (count) {\r\n var SLICE_STACK_SIZE = 60000;\r\n var value = '';\r\n while (count > 0) {\r\n var amount = Math.min(SLICE_STACK_SIZE, count);\r\n value += fromCodePoint.apply(void 0, this._value.splice(0, amount));\r\n count -= amount;\r\n }\r\n this._value.shift();\r\n return value;\r\n };\r\n Tokenizer.prototype.consumeStringToken = function (endingCodePoint) {\r\n var value = '';\r\n var i = 0;\r\n do {\r\n var codePoint = this._value[i];\r\n if (codePoint === EOF || codePoint === undefined || codePoint === endingCodePoint) {\r\n value += this.consumeStringSlice(i);\r\n return { type: TokenType.STRING_TOKEN, value: value };\r\n }\r\n if (codePoint === LINE_FEED) {\r\n this._value.splice(0, i);\r\n return BAD_STRING_TOKEN;\r\n }\r\n if (codePoint === REVERSE_SOLIDUS) {\r\n var next = this._value[i + 1];\r\n if (next !== EOF && next !== undefined) {\r\n if (next === LINE_FEED) {\r\n value += this.consumeStringSlice(i);\r\n i = -1;\r\n this._value.shift();\r\n }\r\n else if (isValidEscape(codePoint, next)) {\r\n value += this.consumeStringSlice(i);\r\n value += fromCodePoint(this.consumeEscapedCodePoint());\r\n i = -1;\r\n }\r\n }\r\n }\r\n i++;\r\n } while (true);\r\n };\r\n Tokenizer.prototype.consumeNumber = function () {\r\n var repr = [];\r\n var type = FLAG_INTEGER;\r\n var c1 = this.peekCodePoint(0);\r\n if (c1 === PLUS_SIGN || c1 === HYPHEN_MINUS) {\r\n repr.push(this.consumeCodePoint());\r\n }\r\n while (isDigit(this.peekCodePoint(0))) {\r\n repr.push(this.consumeCodePoint());\r\n }\r\n c1 = this.peekCodePoint(0);\r\n var c2 = this.peekCodePoint(1);\r\n if (c1 === FULL_STOP && isDigit(c2)) {\r\n repr.push(this.consumeCodePoint(), this.consumeCodePoint());\r\n type = FLAG_NUMBER;\r\n while (isDigit(this.peekCodePoint(0))) {\r\n repr.push(this.consumeCodePoint());\r\n }\r\n }\r\n c1 = this.peekCodePoint(0);\r\n c2 = this.peekCodePoint(1);\r\n var c3 = this.peekCodePoint(2);\r\n if ((c1 === E || c1 === e) && (((c2 === PLUS_SIGN || c2 === HYPHEN_MINUS) && isDigit(c3)) || isDigit(c2))) {\r\n repr.push(this.consumeCodePoint(), this.consumeCodePoint());\r\n type = FLAG_NUMBER;\r\n while (isDigit(this.peekCodePoint(0))) {\r\n repr.push(this.consumeCodePoint());\r\n }\r\n }\r\n return [stringToNumber(repr), type];\r\n };\r\n Tokenizer.prototype.consumeNumericToken = function () {\r\n var _a = this.consumeNumber(), number = _a[0], flags = _a[1];\r\n var c1 = this.peekCodePoint(0);\r\n var c2 = this.peekCodePoint(1);\r\n var c3 = this.peekCodePoint(2);\r\n if (isIdentifierStart(c1, c2, c3)) {\r\n var unit = this.consumeName();\r\n return { type: TokenType.DIMENSION_TOKEN, number: number, flags: flags, unit: unit };\r\n }\r\n if (c1 === PERCENTAGE_SIGN) {\r\n this.consumeCodePoint();\r\n return { type: TokenType.PERCENTAGE_TOKEN, number: number, flags: flags };\r\n }\r\n return { type: TokenType.NUMBER_TOKEN, number: number, flags: flags };\r\n };\r\n Tokenizer.prototype.consumeEscapedCodePoint = function () {\r\n var codePoint = this.consumeCodePoint();\r\n if (isHex(codePoint)) {\r\n var hex = fromCodePoint(codePoint);\r\n while (isHex(this.peekCodePoint(0)) && hex.length < 6) {\r\n hex += fromCodePoint(this.consumeCodePoint());\r\n }\r\n if (isWhiteSpace(this.peekCodePoint(0))) {\r\n this.consumeCodePoint();\r\n }\r\n var hexCodePoint = parseInt(hex, 16);\r\n if (hexCodePoint === 0 || isSurrogateCodePoint(hexCodePoint) || hexCodePoint > 0x10ffff) {\r\n return REPLACEMENT_CHARACTER;\r\n }\r\n return hexCodePoint;\r\n }\r\n if (codePoint === EOF) {\r\n return REPLACEMENT_CHARACTER;\r\n }\r\n return codePoint;\r\n };\r\n Tokenizer.prototype.consumeName = function () {\r\n var result = '';\r\n while (true) {\r\n var codePoint = this.consumeCodePoint();\r\n if (isNameCodePoint(codePoint)) {\r\n result += fromCodePoint(codePoint);\r\n }\r\n else if (isValidEscape(codePoint, this.peekCodePoint(0))) {\r\n result += fromCodePoint(this.consumeEscapedCodePoint());\r\n }\r\n else {\r\n this.reconsumeCodePoint(codePoint);\r\n return result;\r\n }\r\n }\r\n };\r\n return Tokenizer;\r\n }());\n\n var Parser = /** @class */ (function () {\r\n function Parser(tokens) {\r\n this._tokens = tokens;\r\n }\r\n Parser.create = function (value) {\r\n var tokenizer = new Tokenizer();\r\n tokenizer.write(value);\r\n return new Parser(tokenizer.read());\r\n };\r\n Parser.parseValue = function (value) {\r\n return Parser.create(value).parseComponentValue();\r\n };\r\n Parser.parseValues = function (value) {\r\n return Parser.create(value).parseComponentValues();\r\n };\r\n Parser.prototype.parseComponentValue = function () {\r\n var token = this.consumeToken();\r\n while (token.type === TokenType.WHITESPACE_TOKEN) {\r\n token = this.consumeToken();\r\n }\r\n if (token.type === TokenType.EOF_TOKEN) {\r\n throw new SyntaxError(\"Error parsing CSS component value, unexpected EOF\");\r\n }\r\n this.reconsumeToken(token);\r\n var value = this.consumeComponentValue();\r\n do {\r\n token = this.consumeToken();\r\n } while (token.type === TokenType.WHITESPACE_TOKEN);\r\n if (token.type === TokenType.EOF_TOKEN) {\r\n return value;\r\n }\r\n throw new SyntaxError(\"Error parsing CSS component value, multiple values found when expecting only one\");\r\n };\r\n Parser.prototype.parseComponentValues = function () {\r\n var values = [];\r\n while (true) {\r\n var value = this.consumeComponentValue();\r\n if (value.type === TokenType.EOF_TOKEN) {\r\n return values;\r\n }\r\n values.push(value);\r\n values.push();\r\n }\r\n };\r\n Parser.prototype.consumeComponentValue = function () {\r\n var token = this.consumeToken();\r\n switch (token.type) {\r\n case TokenType.LEFT_CURLY_BRACKET_TOKEN:\r\n case TokenType.LEFT_SQUARE_BRACKET_TOKEN:\r\n case TokenType.LEFT_PARENTHESIS_TOKEN:\r\n return this.consumeSimpleBlock(token.type);\r\n case TokenType.FUNCTION_TOKEN:\r\n return this.consumeFunction(token);\r\n }\r\n return token;\r\n };\r\n Parser.prototype.consumeSimpleBlock = function (type) {\r\n var block = { type: type, values: [] };\r\n var token = this.consumeToken();\r\n while (true) {\r\n if (token.type === TokenType.EOF_TOKEN || isEndingTokenFor(token, type)) {\r\n return block;\r\n }\r\n this.reconsumeToken(token);\r\n block.values.push(this.consumeComponentValue());\r\n token = this.consumeToken();\r\n }\r\n };\r\n Parser.prototype.consumeFunction = function (functionToken) {\r\n var cssFunction = {\r\n name: functionToken.value,\r\n values: [],\r\n type: TokenType.FUNCTION\r\n };\r\n while (true) {\r\n var token = this.consumeToken();\r\n if (token.type === TokenType.EOF_TOKEN || token.type === TokenType.RIGHT_PARENTHESIS_TOKEN) {\r\n return cssFunction;\r\n }\r\n this.reconsumeToken(token);\r\n cssFunction.values.push(this.consumeComponentValue());\r\n }\r\n };\r\n Parser.prototype.consumeToken = function () {\r\n var token = this._tokens.shift();\r\n return typeof token === 'undefined' ? EOF_TOKEN : token;\r\n };\r\n Parser.prototype.reconsumeToken = function (token) {\r\n this._tokens.unshift(token);\r\n };\r\n return Parser;\r\n }());\r\n var isDimensionToken = function (token) { return token.type === TokenType.DIMENSION_TOKEN; };\r\n var isNumberToken = function (token) { return token.type === TokenType.NUMBER_TOKEN; };\r\n var isIdentToken = function (token) { return token.type === TokenType.IDENT_TOKEN; };\r\n var isStringToken = function (token) { return token.type === TokenType.STRING_TOKEN; };\r\n var isIdentWithValue = function (token, value) {\r\n return isIdentToken(token) && token.value === value;\r\n };\r\n var nonWhiteSpace = function (token) { return token.type !== TokenType.WHITESPACE_TOKEN; };\r\n var nonFunctionArgSeparator = function (token) {\r\n return token.type !== TokenType.WHITESPACE_TOKEN && token.type !== TokenType.COMMA_TOKEN;\r\n };\r\n var parseFunctionArgs = function (tokens) {\r\n var args = [];\r\n var arg = [];\r\n tokens.forEach(function (token) {\r\n if (token.type === TokenType.COMMA_TOKEN) {\r\n if (arg.length === 0) {\r\n throw new Error(\"Error parsing function args, zero tokens for arg\");\r\n }\r\n args.push(arg);\r\n arg = [];\r\n return;\r\n }\r\n if (token.type !== TokenType.WHITESPACE_TOKEN) {\r\n arg.push(token);\r\n }\r\n });\r\n if (arg.length) {\r\n args.push(arg);\r\n }\r\n return args;\r\n };\r\n var isEndingTokenFor = function (token, type) {\r\n if (type === TokenType.LEFT_CURLY_BRACKET_TOKEN && token.type === TokenType.RIGHT_CURLY_BRACKET_TOKEN) {\r\n return true;\r\n }\r\n if (type === TokenType.LEFT_SQUARE_BRACKET_TOKEN && token.type === TokenType.RIGHT_SQUARE_BRACKET_TOKEN) {\r\n return true;\r\n }\r\n return type === TokenType.LEFT_PARENTHESIS_TOKEN && token.type === TokenType.RIGHT_PARENTHESIS_TOKEN;\r\n };\n\n var isLength = function (token) {\r\n return token.type === TokenType.NUMBER_TOKEN || token.type === TokenType.DIMENSION_TOKEN;\r\n };\n\n var isLengthPercentage = function (token) {\r\n return token.type === TokenType.PERCENTAGE_TOKEN || isLength(token);\r\n };\r\n var parseLengthPercentageTuple = function (tokens) {\r\n return tokens.length > 1 ? [tokens[0], tokens[1]] : [tokens[0]];\r\n };\r\n var ZERO_LENGTH = {\r\n type: TokenType.NUMBER_TOKEN,\r\n number: 0,\r\n flags: FLAG_INTEGER\r\n };\r\n var FIFTY_PERCENT = {\r\n type: TokenType.PERCENTAGE_TOKEN,\r\n number: 50,\r\n flags: FLAG_INTEGER\r\n };\r\n var HUNDRED_PERCENT = {\r\n type: TokenType.PERCENTAGE_TOKEN,\r\n number: 100,\r\n flags: FLAG_INTEGER\r\n };\r\n var getAbsoluteValueForTuple = function (tuple, width, height) {\r\n var x = tuple[0], y = tuple[1];\r\n return [getAbsoluteValue(x, width), getAbsoluteValue(typeof y !== 'undefined' ? y : x, height)];\r\n };\r\n var getAbsoluteValue = function (token, parent) {\r\n if (token.type === TokenType.PERCENTAGE_TOKEN) {\r\n return (token.number / 100) * parent;\r\n }\r\n if (isDimensionToken(token)) {\r\n switch (token.unit) {\r\n case 'rem':\r\n case 'em':\r\n return 16 * token.number; // TODO use correct font-size\r\n case 'px':\r\n default:\r\n return token.number;\r\n }\r\n }\r\n return token.number;\r\n };\n\n var DEG = 'deg';\r\n var GRAD = 'grad';\r\n var RAD = 'rad';\r\n var TURN = 'turn';\r\n var angle = {\r\n name: 'angle',\r\n parse: function (value) {\r\n if (value.type === TokenType.DIMENSION_TOKEN) {\r\n switch (value.unit) {\r\n case DEG:\r\n return (Math.PI * value.number) / 180;\r\n case GRAD:\r\n return (Math.PI / 200) * value.number;\r\n case RAD:\r\n return value.number;\r\n case TURN:\r\n return Math.PI * 2 * value.number;\r\n }\r\n }\r\n throw new Error(\"Unsupported angle type\");\r\n }\r\n };\r\n var isAngle = function (value) {\r\n if (value.type === TokenType.DIMENSION_TOKEN) {\r\n if (value.unit === DEG || value.unit === GRAD || value.unit === RAD || value.unit === TURN) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n };\r\n var parseNamedSide = function (tokens) {\r\n var sideOrCorner = tokens\r\n .filter(isIdentToken)\r\n .map(function (ident) { return ident.value; })\r\n .join(' ');\r\n switch (sideOrCorner) {\r\n case 'to bottom right':\r\n case 'to right bottom':\r\n case 'left top':\r\n case 'top left':\r\n return [ZERO_LENGTH, ZERO_LENGTH];\r\n case 'to top':\r\n case 'bottom':\r\n return deg(0);\r\n case 'to bottom left':\r\n case 'to left bottom':\r\n case 'right top':\r\n case 'top right':\r\n return [ZERO_LENGTH, HUNDRED_PERCENT];\r\n case 'to right':\r\n case 'left':\r\n return deg(90);\r\n case 'to top left':\r\n case 'to left top':\r\n case 'right bottom':\r\n case 'bottom right':\r\n return [HUNDRED_PERCENT, HUNDRED_PERCENT];\r\n case 'to bottom':\r\n case 'top':\r\n return deg(180);\r\n case 'to top right':\r\n case 'to right top':\r\n case 'left bottom':\r\n case 'bottom left':\r\n return [HUNDRED_PERCENT, ZERO_LENGTH];\r\n case 'to left':\r\n case 'right':\r\n return deg(270);\r\n }\r\n return 0;\r\n };\r\n var deg = function (deg) { return (Math.PI * deg) / 180; };\n\n var color = {\r\n name: 'color',\r\n parse: function (value) {\r\n if (value.type === TokenType.FUNCTION) {\r\n var colorFunction = SUPPORTED_COLOR_FUNCTIONS[value.name];\r\n if (typeof colorFunction === 'undefined') {\r\n throw new Error(\"Attempting to parse an unsupported color function \\\"\" + value.name + \"\\\"\");\r\n }\r\n return colorFunction(value.values);\r\n }\r\n if (value.type === TokenType.HASH_TOKEN) {\r\n if (value.value.length === 3) {\r\n var r = value.value.substring(0, 1);\r\n var g = value.value.substring(1, 2);\r\n var b = value.value.substring(2, 3);\r\n return pack(parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), 1);\r\n }\r\n if (value.value.length === 4) {\r\n var r = value.value.substring(0, 1);\r\n var g = value.value.substring(1, 2);\r\n var b = value.value.substring(2, 3);\r\n var a = value.value.substring(3, 4);\r\n return pack(parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), parseInt(a + a, 16) / 255);\r\n }\r\n if (value.value.length === 6) {\r\n var r = value.value.substring(0, 2);\r\n var g = value.value.substring(2, 4);\r\n var b = value.value.substring(4, 6);\r\n return pack(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), 1);\r\n }\r\n if (value.value.length === 8) {\r\n var r = value.value.substring(0, 2);\r\n var g = value.value.substring(2, 4);\r\n var b = value.value.substring(4, 6);\r\n var a = value.value.substring(6, 8);\r\n return pack(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), parseInt(a, 16) / 255);\r\n }\r\n }\r\n if (value.type === TokenType.IDENT_TOKEN) {\r\n var namedColor = COLORS[value.value.toUpperCase()];\r\n if (typeof namedColor !== 'undefined') {\r\n return namedColor;\r\n }\r\n }\r\n return COLORS.TRANSPARENT;\r\n }\r\n };\r\n var isTransparent = function (color) { return (0xff & color) === 0; };\r\n var asString = function (color) {\r\n var alpha = 0xff & color;\r\n var blue = 0xff & (color >> 8);\r\n var green = 0xff & (color >> 16);\r\n var red = 0xff & (color >> 24);\r\n return alpha < 255 ? \"rgba(\" + red + \",\" + green + \",\" + blue + \",\" + alpha / 255 + \")\" : \"rgb(\" + red + \",\" + green + \",\" + blue + \")\";\r\n };\r\n var pack = function (r, g, b, a) {\r\n return ((r << 24) | (g << 16) | (b << 8) | (Math.round(a * 255) << 0)) >>> 0;\r\n };\r\n var getTokenColorValue = function (token, i) {\r\n if (token.type === TokenType.NUMBER_TOKEN) {\r\n return token.number;\r\n }\r\n if (token.type === TokenType.PERCENTAGE_TOKEN) {\r\n var max = i === 3 ? 1 : 255;\r\n return i === 3 ? (token.number / 100) * max : Math.round((token.number / 100) * max);\r\n }\r\n return 0;\r\n };\r\n var rgb = function (args) {\r\n var tokens = args.filter(nonFunctionArgSeparator);\r\n if (tokens.length === 3) {\r\n var _a = tokens.map(getTokenColorValue), r = _a[0], g = _a[1], b = _a[2];\r\n return pack(r, g, b, 1);\r\n }\r\n if (tokens.length === 4) {\r\n var _b = tokens.map(getTokenColorValue), r = _b[0], g = _b[1], b = _b[2], a = _b[3];\r\n return pack(r, g, b, a);\r\n }\r\n return 0;\r\n };\r\n function hue2rgb(t1, t2, hue) {\r\n if (hue < 0) {\r\n hue += 1;\r\n }\r\n if (hue >= 1) {\r\n hue -= 1;\r\n }\r\n if (hue < 1 / 6) {\r\n return (t2 - t1) * hue * 6 + t1;\r\n }\r\n else if (hue < 1 / 2) {\r\n return t2;\r\n }\r\n else if (hue < 2 / 3) {\r\n return (t2 - t1) * 6 * (2 / 3 - hue) + t1;\r\n }\r\n else {\r\n return t1;\r\n }\r\n }\r\n var hsl = function (args) {\r\n var tokens = args.filter(nonFunctionArgSeparator);\r\n var hue = tokens[0], saturation = tokens[1], lightness = tokens[2], alpha = tokens[3];\r\n var h = (hue.type === TokenType.NUMBER_TOKEN ? deg(hue.number) : angle.parse(hue)) / (Math.PI * 2);\r\n var s = isLengthPercentage(saturation) ? saturation.number / 100 : 0;\r\n var l = isLengthPercentage(lightness) ? lightness.number / 100 : 0;\r\n var a = typeof alpha !== 'undefined' && isLengthPercentage(alpha) ? getAbsoluteValue(alpha, 1) : 1;\r\n if (s === 0) {\r\n return pack(l * 255, l * 255, l * 255, 1);\r\n }\r\n var t2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;\r\n var t1 = l * 2 - t2;\r\n var r = hue2rgb(t1, t2, h + 1 / 3);\r\n var g = hue2rgb(t1, t2, h);\r\n var b = hue2rgb(t1, t2, h - 1 / 3);\r\n return pack(r * 255, g * 255, b * 255, a);\r\n };\r\n var SUPPORTED_COLOR_FUNCTIONS = {\r\n hsl: hsl,\r\n hsla: hsl,\r\n rgb: rgb,\r\n rgba: rgb\r\n };\r\n var COLORS = {\r\n ALICEBLUE: 0xf0f8ffff,\r\n ANTIQUEWHITE: 0xfaebd7ff,\r\n AQUA: 0x00ffffff,\r\n AQUAMARINE: 0x7fffd4ff,\r\n AZURE: 0xf0ffffff,\r\n BEIGE: 0xf5f5dcff,\r\n BISQUE: 0xffe4c4ff,\r\n BLACK: 0x000000ff,\r\n BLANCHEDALMOND: 0xffebcdff,\r\n BLUE: 0x0000ffff,\r\n BLUEVIOLET: 0x8a2be2ff,\r\n BROWN: 0xa52a2aff,\r\n BURLYWOOD: 0xdeb887ff,\r\n CADETBLUE: 0x5f9ea0ff,\r\n CHARTREUSE: 0x7fff00ff,\r\n CHOCOLATE: 0xd2691eff,\r\n CORAL: 0xff7f50ff,\r\n CORNFLOWERBLUE: 0x6495edff,\r\n CORNSILK: 0xfff8dcff,\r\n CRIMSON: 0xdc143cff,\r\n CYAN: 0x00ffffff,\r\n DARKBLUE: 0x00008bff,\r\n DARKCYAN: 0x008b8bff,\r\n DARKGOLDENROD: 0xb886bbff,\r\n DARKGRAY: 0xa9a9a9ff,\r\n DARKGREEN: 0x006400ff,\r\n DARKGREY: 0xa9a9a9ff,\r\n DARKKHAKI: 0xbdb76bff,\r\n DARKMAGENTA: 0x8b008bff,\r\n DARKOLIVEGREEN: 0x556b2fff,\r\n DARKORANGE: 0xff8c00ff,\r\n DARKORCHID: 0x9932ccff,\r\n DARKRED: 0x8b0000ff,\r\n DARKSALMON: 0xe9967aff,\r\n DARKSEAGREEN: 0x8fbc8fff,\r\n DARKSLATEBLUE: 0x483d8bff,\r\n DARKSLATEGRAY: 0x2f4f4fff,\r\n DARKSLATEGREY: 0x2f4f4fff,\r\n DARKTURQUOISE: 0x00ced1ff,\r\n DARKVIOLET: 0x9400d3ff,\r\n DEEPPINK: 0xff1493ff,\r\n DEEPSKYBLUE: 0x00bfffff,\r\n DIMGRAY: 0x696969ff,\r\n DIMGREY: 0x696969ff,\r\n DODGERBLUE: 0x1e90ffff,\r\n FIREBRICK: 0xb22222ff,\r\n FLORALWHITE: 0xfffaf0ff,\r\n FORESTGREEN: 0x228b22ff,\r\n FUCHSIA: 0xff00ffff,\r\n GAINSBORO: 0xdcdcdcff,\r\n GHOSTWHITE: 0xf8f8ffff,\r\n GOLD: 0xffd700ff,\r\n GOLDENROD: 0xdaa520ff,\r\n GRAY: 0x808080ff,\r\n GREEN: 0x008000ff,\r\n GREENYELLOW: 0xadff2fff,\r\n GREY: 0x808080ff,\r\n HONEYDEW: 0xf0fff0ff,\r\n HOTPINK: 0xff69b4ff,\r\n INDIANRED: 0xcd5c5cff,\r\n INDIGO: 0x4b0082ff,\r\n IVORY: 0xfffff0ff,\r\n KHAKI: 0xf0e68cff,\r\n LAVENDER: 0xe6e6faff,\r\n LAVENDERBLUSH: 0xfff0f5ff,\r\n LAWNGREEN: 0x7cfc00ff,\r\n LEMONCHIFFON: 0xfffacdff,\r\n LIGHTBLUE: 0xadd8e6ff,\r\n LIGHTCORAL: 0xf08080ff,\r\n LIGHTCYAN: 0xe0ffffff,\r\n LIGHTGOLDENRODYELLOW: 0xfafad2ff,\r\n LIGHTGRAY: 0xd3d3d3ff,\r\n LIGHTGREEN: 0x90ee90ff,\r\n LIGHTGREY: 0xd3d3d3ff,\r\n LIGHTPINK: 0xffb6c1ff,\r\n LIGHTSALMON: 0xffa07aff,\r\n LIGHTSEAGREEN: 0x20b2aaff,\r\n LIGHTSKYBLUE: 0x87cefaff,\r\n LIGHTSLATEGRAY: 0x778899ff,\r\n LIGHTSLATEGREY: 0x778899ff,\r\n LIGHTSTEELBLUE: 0xb0c4deff,\r\n LIGHTYELLOW: 0xffffe0ff,\r\n LIME: 0x00ff00ff,\r\n LIMEGREEN: 0x32cd32ff,\r\n LINEN: 0xfaf0e6ff,\r\n MAGENTA: 0xff00ffff,\r\n MAROON: 0x800000ff,\r\n MEDIUMAQUAMARINE: 0x66cdaaff,\r\n MEDIUMBLUE: 0x0000cdff,\r\n MEDIUMORCHID: 0xba55d3ff,\r\n MEDIUMPURPLE: 0x9370dbff,\r\n MEDIUMSEAGREEN: 0x3cb371ff,\r\n MEDIUMSLATEBLUE: 0x7b68eeff,\r\n MEDIUMSPRINGGREEN: 0x00fa9aff,\r\n MEDIUMTURQUOISE: 0x48d1ccff,\r\n MEDIUMVIOLETRED: 0xc71585ff,\r\n MIDNIGHTBLUE: 0x191970ff,\r\n MINTCREAM: 0xf5fffaff,\r\n MISTYROSE: 0xffe4e1ff,\r\n MOCCASIN: 0xffe4b5ff,\r\n NAVAJOWHITE: 0xffdeadff,\r\n NAVY: 0x000080ff,\r\n OLDLACE: 0xfdf5e6ff,\r\n OLIVE: 0x808000ff,\r\n OLIVEDRAB: 0x6b8e23ff,\r\n ORANGE: 0xffa500ff,\r\n ORANGERED: 0xff4500ff,\r\n ORCHID: 0xda70d6ff,\r\n PALEGOLDENROD: 0xeee8aaff,\r\n PALEGREEN: 0x98fb98ff,\r\n PALETURQUOISE: 0xafeeeeff,\r\n PALEVIOLETRED: 0xdb7093ff,\r\n PAPAYAWHIP: 0xffefd5ff,\r\n PEACHPUFF: 0xffdab9ff,\r\n PERU: 0xcd853fff,\r\n PINK: 0xffc0cbff,\r\n PLUM: 0xdda0ddff,\r\n POWDERBLUE: 0xb0e0e6ff,\r\n PURPLE: 0x800080ff,\r\n REBECCAPURPLE: 0x663399ff,\r\n RED: 0xff0000ff,\r\n ROSYBROWN: 0xbc8f8fff,\r\n ROYALBLUE: 0x4169e1ff,\r\n SADDLEBROWN: 0x8b4513ff,\r\n SALMON: 0xfa8072ff,\r\n SANDYBROWN: 0xf4a460ff,\r\n SEAGREEN: 0x2e8b57ff,\r\n SEASHELL: 0xfff5eeff,\r\n SIENNA: 0xa0522dff,\r\n SILVER: 0xc0c0c0ff,\r\n SKYBLUE: 0x87ceebff,\r\n SLATEBLUE: 0x6a5acdff,\r\n SLATEGRAY: 0x708090ff,\r\n SLATEGREY: 0x708090ff,\r\n SNOW: 0xfffafaff,\r\n SPRINGGREEN: 0x00ff7fff,\r\n STEELBLUE: 0x4682b4ff,\r\n TAN: 0xd2b48cff,\r\n TEAL: 0x008080ff,\r\n THISTLE: 0xd8bfd8ff,\r\n TOMATO: 0xff6347ff,\r\n TRANSPARENT: 0x00000000,\r\n TURQUOISE: 0x40e0d0ff,\r\n VIOLET: 0xee82eeff,\r\n WHEAT: 0xf5deb3ff,\r\n WHITE: 0xffffffff,\r\n WHITESMOKE: 0xf5f5f5ff,\r\n YELLOW: 0xffff00ff,\r\n YELLOWGREEN: 0x9acd32ff\r\n };\n\n var PropertyDescriptorParsingType;\r\n (function (PropertyDescriptorParsingType) {\r\n PropertyDescriptorParsingType[PropertyDescriptorParsingType[\"VALUE\"] = 0] = \"VALUE\";\r\n PropertyDescriptorParsingType[PropertyDescriptorParsingType[\"LIST\"] = 1] = \"LIST\";\r\n PropertyDescriptorParsingType[PropertyDescriptorParsingType[\"IDENT_VALUE\"] = 2] = \"IDENT_VALUE\";\r\n PropertyDescriptorParsingType[PropertyDescriptorParsingType[\"TYPE_VALUE\"] = 3] = \"TYPE_VALUE\";\r\n PropertyDescriptorParsingType[PropertyDescriptorParsingType[\"TOKEN_VALUE\"] = 4] = \"TOKEN_VALUE\";\r\n })(PropertyDescriptorParsingType || (PropertyDescriptorParsingType = {}));\n\n var BACKGROUND_CLIP;\r\n (function (BACKGROUND_CLIP) {\r\n BACKGROUND_CLIP[BACKGROUND_CLIP[\"BORDER_BOX\"] = 0] = \"BORDER_BOX\";\r\n BACKGROUND_CLIP[BACKGROUND_CLIP[\"PADDING_BOX\"] = 1] = \"PADDING_BOX\";\r\n BACKGROUND_CLIP[BACKGROUND_CLIP[\"CONTENT_BOX\"] = 2] = \"CONTENT_BOX\";\r\n })(BACKGROUND_CLIP || (BACKGROUND_CLIP = {}));\r\n var backgroundClip = {\r\n name: 'background-clip',\r\n initialValue: 'border-box',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n return tokens.map(function (token) {\r\n if (isIdentToken(token)) {\r\n switch (token.value) {\r\n case 'padding-box':\r\n return BACKGROUND_CLIP.PADDING_BOX;\r\n case 'content-box':\r\n return BACKGROUND_CLIP.CONTENT_BOX;\r\n }\r\n }\r\n return BACKGROUND_CLIP.BORDER_BOX;\r\n });\r\n }\r\n };\n\n var backgroundColor = {\r\n name: \"background-color\",\r\n initialValue: 'transparent',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TYPE_VALUE,\r\n format: 'color'\r\n };\n\n var parseColorStop = function (args) {\r\n var color$1 = color.parse(args[0]);\r\n var stop = args[1];\r\n return stop && isLengthPercentage(stop) ? { color: color$1, stop: stop } : { color: color$1, stop: null };\r\n };\r\n var processColorStops = function (stops, lineLength) {\r\n var first = stops[0];\r\n var last = stops[stops.length - 1];\r\n if (first.stop === null) {\r\n first.stop = ZERO_LENGTH;\r\n }\r\n if (last.stop === null) {\r\n last.stop = HUNDRED_PERCENT;\r\n }\r\n var processStops = [];\r\n var previous = 0;\r\n for (var i = 0; i < stops.length; i++) {\r\n var stop_1 = stops[i].stop;\r\n if (stop_1 !== null) {\r\n var absoluteValue = getAbsoluteValue(stop_1, lineLength);\r\n if (absoluteValue > previous) {\r\n processStops.push(absoluteValue);\r\n }\r\n else {\r\n processStops.push(previous);\r\n }\r\n previous = absoluteValue;\r\n }\r\n else {\r\n processStops.push(null);\r\n }\r\n }\r\n var gapBegin = null;\r\n for (var i = 0; i < processStops.length; i++) {\r\n var stop_2 = processStops[i];\r\n if (stop_2 === null) {\r\n if (gapBegin === null) {\r\n gapBegin = i;\r\n }\r\n }\r\n else if (gapBegin !== null) {\r\n var gapLength = i - gapBegin;\r\n var beforeGap = processStops[gapBegin - 1];\r\n var gapValue = (stop_2 - beforeGap) / (gapLength + 1);\r\n for (var g = 1; g <= gapLength; g++) {\r\n processStops[gapBegin + g - 1] = gapValue * g;\r\n }\r\n gapBegin = null;\r\n }\r\n }\r\n return stops.map(function (_a, i) {\r\n var color = _a.color;\r\n return { color: color, stop: Math.max(Math.min(1, processStops[i] / lineLength), 0) };\r\n });\r\n };\r\n var getAngleFromCorner = function (corner, width, height) {\r\n var centerX = width / 2;\r\n var centerY = height / 2;\r\n var x = getAbsoluteValue(corner[0], width) - centerX;\r\n var y = centerY - getAbsoluteValue(corner[1], height);\r\n return (Math.atan2(y, x) + Math.PI * 2) % (Math.PI * 2);\r\n };\r\n var calculateGradientDirection = function (angle, width, height) {\r\n var radian = typeof angle === 'number' ? angle : getAngleFromCorner(angle, width, height);\r\n var lineLength = Math.abs(width * Math.sin(radian)) + Math.abs(height * Math.cos(radian));\r\n var halfWidth = width / 2;\r\n var halfHeight = height / 2;\r\n var halfLineLength = lineLength / 2;\r\n var yDiff = Math.sin(radian - Math.PI / 2) * halfLineLength;\r\n var xDiff = Math.cos(radian - Math.PI / 2) * halfLineLength;\r\n return [lineLength, halfWidth - xDiff, halfWidth + xDiff, halfHeight - yDiff, halfHeight + yDiff];\r\n };\r\n var distance = function (a, b) { return Math.sqrt(a * a + b * b); };\r\n var findCorner = function (width, height, x, y, closest) {\r\n var corners = [[0, 0], [0, height], [width, 0], [width, height]];\r\n return corners.reduce(function (stat, corner) {\r\n var cx = corner[0], cy = corner[1];\r\n var d = distance(x - cx, y - cy);\r\n if (closest ? d < stat.optimumDistance : d > stat.optimumDistance) {\r\n return {\r\n optimumCorner: corner,\r\n optimumDistance: d\r\n };\r\n }\r\n return stat;\r\n }, {\r\n optimumDistance: closest ? Infinity : -Infinity,\r\n optimumCorner: null\r\n }).optimumCorner;\r\n };\r\n var calculateRadius = function (gradient, x, y, width, height) {\r\n var rx = 0;\r\n var ry = 0;\r\n switch (gradient.size) {\r\n case CSSRadialExtent.CLOSEST_SIDE:\r\n // The ending shape is sized so that that it exactly meets the side of the gradient box closest to the gradient’s center.\r\n // If the shape is an ellipse, it exactly meets the closest side in each dimension.\r\n if (gradient.shape === CSSRadialShape.CIRCLE) {\r\n rx = ry = Math.min(Math.abs(x), Math.abs(x - width), Math.abs(y), Math.abs(y - height));\r\n }\r\n else if (gradient.shape === CSSRadialShape.ELLIPSE) {\r\n rx = Math.min(Math.abs(x), Math.abs(x - width));\r\n ry = Math.min(Math.abs(y), Math.abs(y - height));\r\n }\r\n break;\r\n case CSSRadialExtent.CLOSEST_CORNER:\r\n // The ending shape is sized so that that it passes through the corner of the gradient box closest to the gradient’s center.\r\n // If the shape is an ellipse, the ending shape is given the same aspect-ratio it would have if closest-side were specified.\r\n if (gradient.shape === CSSRadialShape.CIRCLE) {\r\n rx = ry = Math.min(distance(x, y), distance(x, y - height), distance(x - width, y), distance(x - width, y - height));\r\n }\r\n else if (gradient.shape === CSSRadialShape.ELLIPSE) {\r\n // Compute the ratio ry/rx (which is to be the same as for \"closest-side\")\r\n var c = Math.min(Math.abs(y), Math.abs(y - height)) / Math.min(Math.abs(x), Math.abs(x - width));\r\n var _a = findCorner(width, height, x, y, true), cx = _a[0], cy = _a[1];\r\n rx = distance(cx - x, (cy - y) / c);\r\n ry = c * rx;\r\n }\r\n break;\r\n case CSSRadialExtent.FARTHEST_SIDE:\r\n // Same as closest-side, except the ending shape is sized based on the farthest side(s)\r\n if (gradient.shape === CSSRadialShape.CIRCLE) {\r\n rx = ry = Math.max(Math.abs(x), Math.abs(x - width), Math.abs(y), Math.abs(y - height));\r\n }\r\n else if (gradient.shape === CSSRadialShape.ELLIPSE) {\r\n rx = Math.max(Math.abs(x), Math.abs(x - width));\r\n ry = Math.max(Math.abs(y), Math.abs(y - height));\r\n }\r\n break;\r\n case CSSRadialExtent.FARTHEST_CORNER:\r\n // Same as closest-corner, except the ending shape is sized based on the farthest corner.\r\n // If the shape is an ellipse, the ending shape is given the same aspect ratio it would have if farthest-side were specified.\r\n if (gradient.shape === CSSRadialShape.CIRCLE) {\r\n rx = ry = Math.max(distance(x, y), distance(x, y - height), distance(x - width, y), distance(x - width, y - height));\r\n }\r\n else if (gradient.shape === CSSRadialShape.ELLIPSE) {\r\n // Compute the ratio ry/rx (which is to be the same as for \"farthest-side\")\r\n var c = Math.max(Math.abs(y), Math.abs(y - height)) / Math.max(Math.abs(x), Math.abs(x - width));\r\n var _b = findCorner(width, height, x, y, false), cx = _b[0], cy = _b[1];\r\n rx = distance(cx - x, (cy - y) / c);\r\n ry = c * rx;\r\n }\r\n break;\r\n }\r\n if (Array.isArray(gradient.size)) {\r\n rx = getAbsoluteValue(gradient.size[0], width);\r\n ry = gradient.size.length === 2 ? getAbsoluteValue(gradient.size[1], height) : rx;\r\n }\r\n return [rx, ry];\r\n };\n\n var linearGradient = function (tokens) {\r\n var angle$1 = deg(180);\r\n var stops = [];\r\n parseFunctionArgs(tokens).forEach(function (arg, i) {\r\n if (i === 0) {\r\n var firstToken = arg[0];\r\n if (firstToken.type === TokenType.IDENT_TOKEN && firstToken.value === 'to') {\r\n angle$1 = parseNamedSide(arg);\r\n return;\r\n }\r\n else if (isAngle(firstToken)) {\r\n angle$1 = angle.parse(firstToken);\r\n return;\r\n }\r\n }\r\n var colorStop = parseColorStop(arg);\r\n stops.push(colorStop);\r\n });\r\n return { angle: angle$1, stops: stops, type: CSSImageType.LINEAR_GRADIENT };\r\n };\n\n var prefixLinearGradient = function (tokens) {\r\n var angle$1 = deg(180);\r\n var stops = [];\r\n parseFunctionArgs(tokens).forEach(function (arg, i) {\r\n if (i === 0) {\r\n var firstToken = arg[0];\r\n if (firstToken.type === TokenType.IDENT_TOKEN &&\r\n ['top', 'left', 'right', 'bottom'].indexOf(firstToken.value) !== -1) {\r\n angle$1 = parseNamedSide(arg);\r\n return;\r\n }\r\n else if (isAngle(firstToken)) {\r\n angle$1 = (angle.parse(firstToken) + deg(270)) % deg(360);\r\n return;\r\n }\r\n }\r\n var colorStop = parseColorStop(arg);\r\n stops.push(colorStop);\r\n });\r\n return {\r\n angle: angle$1,\r\n stops: stops,\r\n type: CSSImageType.LINEAR_GRADIENT\r\n };\r\n };\n\n var testRangeBounds = function (document) {\r\n var TEST_HEIGHT = 123;\r\n if (document.createRange) {\r\n var range = document.createRange();\r\n if (range.getBoundingClientRect) {\r\n var testElement = document.createElement('boundtest');\r\n testElement.style.height = TEST_HEIGHT + \"px\";\r\n testElement.style.display = 'block';\r\n document.body.appendChild(testElement);\r\n range.selectNode(testElement);\r\n var rangeBounds = range.getBoundingClientRect();\r\n var rangeHeight = Math.round(rangeBounds.height);\r\n document.body.removeChild(testElement);\r\n if (rangeHeight === TEST_HEIGHT) {\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n };\r\n var testCORS = function () { return typeof new Image().crossOrigin !== 'undefined'; };\r\n var testResponseType = function () { return typeof new XMLHttpRequest().responseType === 'string'; };\r\n var testSVG = function (document) {\r\n var img = new Image();\r\n var canvas = document.createElement('canvas');\r\n var ctx = canvas.getContext('2d');\r\n if (!ctx) {\r\n return false;\r\n }\r\n img.src = \"data:image/svg+xml,\";\r\n try {\r\n ctx.drawImage(img, 0, 0);\r\n canvas.toDataURL();\r\n }\r\n catch (e) {\r\n return false;\r\n }\r\n return true;\r\n };\r\n var isGreenPixel = function (data) {\r\n return data[0] === 0 && data[1] === 255 && data[2] === 0 && data[3] === 255;\r\n };\r\n var testForeignObject = function (document) {\r\n var canvas = document.createElement('canvas');\r\n var size = 100;\r\n canvas.width = size;\r\n canvas.height = size;\r\n var ctx = canvas.getContext('2d');\r\n if (!ctx) {\r\n return Promise.reject(false);\r\n }\r\n ctx.fillStyle = 'rgb(0, 255, 0)';\r\n ctx.fillRect(0, 0, size, size);\r\n var img = new Image();\r\n var greenImageSrc = canvas.toDataURL();\r\n img.src = greenImageSrc;\r\n var svg = createForeignObjectSVG(size, size, 0, 0, img);\r\n ctx.fillStyle = 'red';\r\n ctx.fillRect(0, 0, size, size);\r\n return loadSerializedSVG(svg)\r\n .then(function (img) {\r\n ctx.drawImage(img, 0, 0);\r\n var data = ctx.getImageData(0, 0, size, size).data;\r\n ctx.fillStyle = 'red';\r\n ctx.fillRect(0, 0, size, size);\r\n var node = document.createElement('div');\r\n node.style.backgroundImage = \"url(\" + greenImageSrc + \")\";\r\n node.style.height = size + \"px\";\r\n // Firefox 55 does not render inline tags\r\n return isGreenPixel(data)\r\n ? loadSerializedSVG(createForeignObjectSVG(size, size, 0, 0, node))\r\n : Promise.reject(false);\r\n })\r\n .then(function (img) {\r\n ctx.drawImage(img, 0, 0);\r\n // Edge does not render background-images\r\n return isGreenPixel(ctx.getImageData(0, 0, size, size).data);\r\n })\r\n .catch(function () { return false; });\r\n };\r\n var createForeignObjectSVG = function (width, height, x, y, node) {\r\n var xmlns = 'http://www.w3.org/2000/svg';\r\n var svg = document.createElementNS(xmlns, 'svg');\r\n var foreignObject = document.createElementNS(xmlns, 'foreignObject');\r\n svg.setAttributeNS(null, 'width', width.toString());\r\n svg.setAttributeNS(null, 'height', height.toString());\r\n foreignObject.setAttributeNS(null, 'width', '100%');\r\n foreignObject.setAttributeNS(null, 'height', '100%');\r\n foreignObject.setAttributeNS(null, 'x', x.toString());\r\n foreignObject.setAttributeNS(null, 'y', y.toString());\r\n foreignObject.setAttributeNS(null, 'externalResourcesRequired', 'true');\r\n svg.appendChild(foreignObject);\r\n foreignObject.appendChild(node);\r\n return svg;\r\n };\r\n var loadSerializedSVG = function (svg) {\r\n return new Promise(function (resolve, reject) {\r\n var img = new Image();\r\n img.onload = function () { return resolve(img); };\r\n img.onerror = reject;\r\n img.src = \"data:image/svg+xml;charset=utf-8,\" + encodeURIComponent(new XMLSerializer().serializeToString(svg));\r\n });\r\n };\r\n var FEATURES = {\r\n get SUPPORT_RANGE_BOUNDS() {\r\n var value = testRangeBounds(document);\r\n Object.defineProperty(FEATURES, 'SUPPORT_RANGE_BOUNDS', { value: value });\r\n return value;\r\n },\r\n get SUPPORT_SVG_DRAWING() {\r\n var value = testSVG(document);\r\n Object.defineProperty(FEATURES, 'SUPPORT_SVG_DRAWING', { value: value });\r\n return value;\r\n },\r\n get SUPPORT_FOREIGNOBJECT_DRAWING() {\r\n var value = typeof Array.from === 'function' && typeof window.fetch === 'function'\r\n ? testForeignObject(document)\r\n : Promise.resolve(false);\r\n Object.defineProperty(FEATURES, 'SUPPORT_FOREIGNOBJECT_DRAWING', { value: value });\r\n return value;\r\n },\r\n get SUPPORT_CORS_IMAGES() {\r\n var value = testCORS();\r\n Object.defineProperty(FEATURES, 'SUPPORT_CORS_IMAGES', { value: value });\r\n return value;\r\n },\r\n get SUPPORT_RESPONSE_TYPE() {\r\n var value = testResponseType();\r\n Object.defineProperty(FEATURES, 'SUPPORT_RESPONSE_TYPE', { value: value });\r\n return value;\r\n },\r\n get SUPPORT_CORS_XHR() {\r\n var value = 'withCredentials' in new XMLHttpRequest();\r\n Object.defineProperty(FEATURES, 'SUPPORT_CORS_XHR', { value: value });\r\n return value;\r\n }\r\n };\n\n var Logger = /** @class */ (function () {\r\n function Logger(_a) {\r\n var id = _a.id, enabled = _a.enabled;\r\n this.id = id;\r\n this.enabled = enabled;\r\n this.start = Date.now();\r\n }\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n Logger.prototype.debug = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n if (this.enabled) {\r\n // eslint-disable-next-line no-console\r\n if (typeof window !== 'undefined' && window.console && typeof console.debug === 'function') {\r\n // eslint-disable-next-line no-console\r\n console.debug.apply(console, [this.id, this.getTime() + \"ms\"].concat(args));\r\n }\r\n else {\r\n this.info.apply(this, args);\r\n }\r\n }\r\n };\r\n Logger.prototype.getTime = function () {\r\n return Date.now() - this.start;\r\n };\r\n Logger.create = function (options) {\r\n Logger.instances[options.id] = new Logger(options);\r\n };\r\n Logger.destroy = function (id) {\r\n delete Logger.instances[id];\r\n };\r\n Logger.getInstance = function (id) {\r\n var instance = Logger.instances[id];\r\n if (typeof instance === 'undefined') {\r\n throw new Error(\"No logger instance found with id \" + id);\r\n }\r\n return instance;\r\n };\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n Logger.prototype.info = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n if (this.enabled) {\r\n // eslint-disable-next-line no-console\r\n if (typeof window !== 'undefined' && window.console && typeof console.info === 'function') {\r\n // eslint-disable-next-line no-console\r\n console.info.apply(console, [this.id, this.getTime() + \"ms\"].concat(args));\r\n }\r\n }\r\n };\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n Logger.prototype.error = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n if (this.enabled) {\r\n // eslint-disable-next-line no-console\r\n if (typeof window !== 'undefined' && window.console && typeof console.error === 'function') {\r\n // eslint-disable-next-line no-console\r\n console.error.apply(console, [this.id, this.getTime() + \"ms\"].concat(args));\r\n }\r\n else {\r\n this.info.apply(this, args);\r\n }\r\n }\r\n };\r\n Logger.instances = {};\r\n return Logger;\r\n }());\n\n var CacheStorage = /** @class */ (function () {\r\n function CacheStorage() {\r\n }\r\n CacheStorage.create = function (name, options) {\r\n return (CacheStorage._caches[name] = new Cache(name, options));\r\n };\r\n CacheStorage.destroy = function (name) {\r\n delete CacheStorage._caches[name];\r\n };\r\n CacheStorage.open = function (name) {\r\n var cache = CacheStorage._caches[name];\r\n if (typeof cache !== 'undefined') {\r\n return cache;\r\n }\r\n throw new Error(\"Cache with key \\\"\" + name + \"\\\" not found\");\r\n };\r\n CacheStorage.getOrigin = function (url) {\r\n var link = CacheStorage._link;\r\n if (!link) {\r\n return 'about:blank';\r\n }\r\n link.href = url;\r\n link.href = link.href; // IE9, LOL! - http://jsfiddle.net/niklasvh/2e48b/\r\n return link.protocol + link.hostname + link.port;\r\n };\r\n CacheStorage.isSameOrigin = function (src) {\r\n return CacheStorage.getOrigin(src) === CacheStorage._origin;\r\n };\r\n CacheStorage.setContext = function (window) {\r\n CacheStorage._link = window.document.createElement('a');\r\n CacheStorage._origin = CacheStorage.getOrigin(window.location.href);\r\n };\r\n CacheStorage.getInstance = function () {\r\n var current = CacheStorage._current;\r\n if (current === null) {\r\n throw new Error(\"No cache instance attached\");\r\n }\r\n return current;\r\n };\r\n CacheStorage.attachInstance = function (cache) {\r\n CacheStorage._current = cache;\r\n };\r\n CacheStorage.detachInstance = function () {\r\n CacheStorage._current = null;\r\n };\r\n CacheStorage._caches = {};\r\n CacheStorage._origin = 'about:blank';\r\n CacheStorage._current = null;\r\n return CacheStorage;\r\n }());\r\n var Cache = /** @class */ (function () {\r\n function Cache(id, options) {\r\n this.id = id;\r\n this._options = options;\r\n this._cache = {};\r\n }\r\n Cache.prototype.addImage = function (src) {\r\n var result = Promise.resolve();\r\n if (this.has(src)) {\r\n return result;\r\n }\r\n if (isBlobImage(src) || isRenderable(src)) {\r\n this._cache[src] = this.loadImage(src);\r\n return result;\r\n }\r\n return result;\r\n };\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n Cache.prototype.match = function (src) {\r\n return this._cache[src];\r\n };\r\n Cache.prototype.loadImage = function (key) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var isSameOrigin, useCORS, useProxy, src;\r\n var _this = this;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n isSameOrigin = CacheStorage.isSameOrigin(key);\r\n useCORS = !isInlineImage(key) && this._options.useCORS === true && FEATURES.SUPPORT_CORS_IMAGES && !isSameOrigin;\r\n useProxy = !isInlineImage(key) &&\r\n !isSameOrigin &&\r\n typeof this._options.proxy === 'string' &&\r\n FEATURES.SUPPORT_CORS_XHR &&\r\n !useCORS;\r\n if (!isSameOrigin && this._options.allowTaint === false && !isInlineImage(key) && !useProxy && !useCORS) {\r\n return [2 /*return*/];\r\n }\r\n src = key;\r\n if (!useProxy) return [3 /*break*/, 2];\r\n return [4 /*yield*/, this.proxy(src)];\r\n case 1:\r\n src = _a.sent();\r\n _a.label = 2;\r\n case 2:\r\n Logger.getInstance(this.id).debug(\"Added image \" + key.substring(0, 256));\r\n return [4 /*yield*/, new Promise(function (resolve, reject) {\r\n var img = new Image();\r\n img.onload = function () { return resolve(img); };\r\n img.onerror = reject;\r\n //ios safari 10.3 taints canvas with data urls unless crossOrigin is set to anonymous\r\n if (isInlineBase64Image(src) || useCORS) {\r\n img.crossOrigin = 'anonymous';\r\n }\r\n img.src = src;\r\n if (img.complete === true) {\r\n // Inline XML images may fail to parse, throwing an Error later on\r\n setTimeout(function () { return resolve(img); }, 500);\r\n }\r\n if (_this._options.imageTimeout > 0) {\r\n setTimeout(function () { return reject(\"Timed out (\" + _this._options.imageTimeout + \"ms) loading image\"); }, _this._options.imageTimeout);\r\n }\r\n })];\r\n case 3: return [2 /*return*/, _a.sent()];\r\n }\r\n });\r\n });\r\n };\r\n Cache.prototype.has = function (key) {\r\n return typeof this._cache[key] !== 'undefined';\r\n };\r\n Cache.prototype.keys = function () {\r\n return Promise.resolve(Object.keys(this._cache));\r\n };\r\n Cache.prototype.proxy = function (src) {\r\n var _this = this;\r\n var proxy = this._options.proxy;\r\n if (!proxy) {\r\n throw new Error('No proxy defined');\r\n }\r\n var key = src.substring(0, 256);\r\n return new Promise(function (resolve, reject) {\r\n var responseType = FEATURES.SUPPORT_RESPONSE_TYPE ? 'blob' : 'text';\r\n var xhr = new XMLHttpRequest();\r\n xhr.onload = function () {\r\n if (xhr.status === 200) {\r\n if (responseType === 'text') {\r\n resolve(xhr.response);\r\n }\r\n else {\r\n var reader_1 = new FileReader();\r\n reader_1.addEventListener('load', function () { return resolve(reader_1.result); }, false);\r\n reader_1.addEventListener('error', function (e) { return reject(e); }, false);\r\n reader_1.readAsDataURL(xhr.response);\r\n }\r\n }\r\n else {\r\n reject(\"Failed to proxy resource \" + key + \" with status code \" + xhr.status);\r\n }\r\n };\r\n xhr.onerror = reject;\r\n xhr.open('GET', proxy + \"?url=\" + encodeURIComponent(src) + \"&responseType=\" + responseType);\r\n if (responseType !== 'text' && xhr instanceof XMLHttpRequest) {\r\n xhr.responseType = responseType;\r\n }\r\n if (_this._options.imageTimeout) {\r\n var timeout_1 = _this._options.imageTimeout;\r\n xhr.timeout = timeout_1;\r\n xhr.ontimeout = function () { return reject(\"Timed out (\" + timeout_1 + \"ms) proxying \" + key); };\r\n }\r\n xhr.send();\r\n });\r\n };\r\n return Cache;\r\n }());\r\n var INLINE_SVG = /^data:image\\/svg\\+xml/i;\r\n var INLINE_BASE64 = /^data:image\\/.*;base64,/i;\r\n var INLINE_IMG = /^data:image\\/.*/i;\r\n var isRenderable = function (src) { return FEATURES.SUPPORT_SVG_DRAWING || !isSVG(src); };\r\n var isInlineImage = function (src) { return INLINE_IMG.test(src); };\r\n var isInlineBase64Image = function (src) { return INLINE_BASE64.test(src); };\r\n var isBlobImage = function (src) { return src.substr(0, 4) === 'blob'; };\r\n var isSVG = function (src) { return src.substr(-3).toLowerCase() === 'svg' || INLINE_SVG.test(src); };\n\n var webkitGradient = function (tokens) {\r\n var angle = deg(180);\r\n var stops = [];\r\n var type = CSSImageType.LINEAR_GRADIENT;\r\n var shape = CSSRadialShape.CIRCLE;\r\n var size = CSSRadialExtent.FARTHEST_CORNER;\r\n var position = [];\r\n parseFunctionArgs(tokens).forEach(function (arg, i) {\r\n var firstToken = arg[0];\r\n if (i === 0) {\r\n if (isIdentToken(firstToken) && firstToken.value === 'linear') {\r\n type = CSSImageType.LINEAR_GRADIENT;\r\n return;\r\n }\r\n else if (isIdentToken(firstToken) && firstToken.value === 'radial') {\r\n type = CSSImageType.RADIAL_GRADIENT;\r\n return;\r\n }\r\n }\r\n if (firstToken.type === TokenType.FUNCTION) {\r\n if (firstToken.name === 'from') {\r\n var color$1 = color.parse(firstToken.values[0]);\r\n stops.push({ stop: ZERO_LENGTH, color: color$1 });\r\n }\r\n else if (firstToken.name === 'to') {\r\n var color$1 = color.parse(firstToken.values[0]);\r\n stops.push({ stop: HUNDRED_PERCENT, color: color$1 });\r\n }\r\n else if (firstToken.name === 'color-stop') {\r\n var values = firstToken.values.filter(nonFunctionArgSeparator);\r\n if (values.length === 2) {\r\n var color$1 = color.parse(values[1]);\r\n var stop_1 = values[0];\r\n if (isNumberToken(stop_1)) {\r\n stops.push({\r\n stop: { type: TokenType.PERCENTAGE_TOKEN, number: stop_1.number * 100, flags: stop_1.flags },\r\n color: color$1\r\n });\r\n }\r\n }\r\n }\r\n }\r\n });\r\n return type === CSSImageType.LINEAR_GRADIENT\r\n ? {\r\n angle: (angle + deg(180)) % deg(360),\r\n stops: stops,\r\n type: type\r\n }\r\n : { size: size, shape: shape, stops: stops, position: position, type: type };\r\n };\n\n var CLOSEST_SIDE = 'closest-side';\r\n var FARTHEST_SIDE = 'farthest-side';\r\n var CLOSEST_CORNER = 'closest-corner';\r\n var FARTHEST_CORNER = 'farthest-corner';\r\n var CIRCLE = 'circle';\r\n var ELLIPSE = 'ellipse';\r\n var COVER = 'cover';\r\n var CONTAIN = 'contain';\r\n var radialGradient = function (tokens) {\r\n var shape = CSSRadialShape.CIRCLE;\r\n var size = CSSRadialExtent.FARTHEST_CORNER;\r\n var stops = [];\r\n var position = [];\r\n parseFunctionArgs(tokens).forEach(function (arg, i) {\r\n var isColorStop = true;\r\n if (i === 0) {\r\n var isAtPosition_1 = false;\r\n isColorStop = arg.reduce(function (acc, token) {\r\n if (isAtPosition_1) {\r\n if (isIdentToken(token)) {\r\n switch (token.value) {\r\n case 'center':\r\n position.push(FIFTY_PERCENT);\r\n return acc;\r\n case 'top':\r\n case 'left':\r\n position.push(ZERO_LENGTH);\r\n return acc;\r\n case 'right':\r\n case 'bottom':\r\n position.push(HUNDRED_PERCENT);\r\n return acc;\r\n }\r\n }\r\n else if (isLengthPercentage(token) || isLength(token)) {\r\n position.push(token);\r\n }\r\n }\r\n else if (isIdentToken(token)) {\r\n switch (token.value) {\r\n case CIRCLE:\r\n shape = CSSRadialShape.CIRCLE;\r\n return false;\r\n case ELLIPSE:\r\n shape = CSSRadialShape.ELLIPSE;\r\n return false;\r\n case 'at':\r\n isAtPosition_1 = true;\r\n return false;\r\n case CLOSEST_SIDE:\r\n size = CSSRadialExtent.CLOSEST_SIDE;\r\n return false;\r\n case COVER:\r\n case FARTHEST_SIDE:\r\n size = CSSRadialExtent.FARTHEST_SIDE;\r\n return false;\r\n case CONTAIN:\r\n case CLOSEST_CORNER:\r\n size = CSSRadialExtent.CLOSEST_CORNER;\r\n return false;\r\n case FARTHEST_CORNER:\r\n size = CSSRadialExtent.FARTHEST_CORNER;\r\n return false;\r\n }\r\n }\r\n else if (isLength(token) || isLengthPercentage(token)) {\r\n if (!Array.isArray(size)) {\r\n size = [];\r\n }\r\n size.push(token);\r\n return false;\r\n }\r\n return acc;\r\n }, isColorStop);\r\n }\r\n if (isColorStop) {\r\n var colorStop = parseColorStop(arg);\r\n stops.push(colorStop);\r\n }\r\n });\r\n return { size: size, shape: shape, stops: stops, position: position, type: CSSImageType.RADIAL_GRADIENT };\r\n };\n\n var prefixRadialGradient = function (tokens) {\r\n var shape = CSSRadialShape.CIRCLE;\r\n var size = CSSRadialExtent.FARTHEST_CORNER;\r\n var stops = [];\r\n var position = [];\r\n parseFunctionArgs(tokens).forEach(function (arg, i) {\r\n var isColorStop = true;\r\n if (i === 0) {\r\n isColorStop = arg.reduce(function (acc, token) {\r\n if (isIdentToken(token)) {\r\n switch (token.value) {\r\n case 'center':\r\n position.push(FIFTY_PERCENT);\r\n return false;\r\n case 'top':\r\n case 'left':\r\n position.push(ZERO_LENGTH);\r\n return false;\r\n case 'right':\r\n case 'bottom':\r\n position.push(HUNDRED_PERCENT);\r\n return false;\r\n }\r\n }\r\n else if (isLengthPercentage(token) || isLength(token)) {\r\n position.push(token);\r\n return false;\r\n }\r\n return acc;\r\n }, isColorStop);\r\n }\r\n else if (i === 1) {\r\n isColorStop = arg.reduce(function (acc, token) {\r\n if (isIdentToken(token)) {\r\n switch (token.value) {\r\n case CIRCLE:\r\n shape = CSSRadialShape.CIRCLE;\r\n return false;\r\n case ELLIPSE:\r\n shape = CSSRadialShape.ELLIPSE;\r\n return false;\r\n case CONTAIN:\r\n case CLOSEST_SIDE:\r\n size = CSSRadialExtent.CLOSEST_SIDE;\r\n return false;\r\n case FARTHEST_SIDE:\r\n size = CSSRadialExtent.FARTHEST_SIDE;\r\n return false;\r\n case CLOSEST_CORNER:\r\n size = CSSRadialExtent.CLOSEST_CORNER;\r\n return false;\r\n case COVER:\r\n case FARTHEST_CORNER:\r\n size = CSSRadialExtent.FARTHEST_CORNER;\r\n return false;\r\n }\r\n }\r\n else if (isLength(token) || isLengthPercentage(token)) {\r\n if (!Array.isArray(size)) {\r\n size = [];\r\n }\r\n size.push(token);\r\n return false;\r\n }\r\n return acc;\r\n }, isColorStop);\r\n }\r\n if (isColorStop) {\r\n var colorStop = parseColorStop(arg);\r\n stops.push(colorStop);\r\n }\r\n });\r\n return { size: size, shape: shape, stops: stops, position: position, type: CSSImageType.RADIAL_GRADIENT };\r\n };\n\n var CSSImageType;\r\n (function (CSSImageType) {\r\n CSSImageType[CSSImageType[\"URL\"] = 0] = \"URL\";\r\n CSSImageType[CSSImageType[\"LINEAR_GRADIENT\"] = 1] = \"LINEAR_GRADIENT\";\r\n CSSImageType[CSSImageType[\"RADIAL_GRADIENT\"] = 2] = \"RADIAL_GRADIENT\";\r\n })(CSSImageType || (CSSImageType = {}));\r\n var isLinearGradient = function (background) {\r\n return background.type === CSSImageType.LINEAR_GRADIENT;\r\n };\r\n var isRadialGradient = function (background) {\r\n return background.type === CSSImageType.RADIAL_GRADIENT;\r\n };\r\n var CSSRadialShape;\r\n (function (CSSRadialShape) {\r\n CSSRadialShape[CSSRadialShape[\"CIRCLE\"] = 0] = \"CIRCLE\";\r\n CSSRadialShape[CSSRadialShape[\"ELLIPSE\"] = 1] = \"ELLIPSE\";\r\n })(CSSRadialShape || (CSSRadialShape = {}));\r\n var CSSRadialExtent;\r\n (function (CSSRadialExtent) {\r\n CSSRadialExtent[CSSRadialExtent[\"CLOSEST_SIDE\"] = 0] = \"CLOSEST_SIDE\";\r\n CSSRadialExtent[CSSRadialExtent[\"FARTHEST_SIDE\"] = 1] = \"FARTHEST_SIDE\";\r\n CSSRadialExtent[CSSRadialExtent[\"CLOSEST_CORNER\"] = 2] = \"CLOSEST_CORNER\";\r\n CSSRadialExtent[CSSRadialExtent[\"FARTHEST_CORNER\"] = 3] = \"FARTHEST_CORNER\";\r\n })(CSSRadialExtent || (CSSRadialExtent = {}));\r\n var image = {\r\n name: 'image',\r\n parse: function (value) {\r\n if (value.type === TokenType.URL_TOKEN) {\r\n var image_1 = { url: value.value, type: CSSImageType.URL };\r\n CacheStorage.getInstance().addImage(value.value);\r\n return image_1;\r\n }\r\n if (value.type === TokenType.FUNCTION) {\r\n var imageFunction = SUPPORTED_IMAGE_FUNCTIONS[value.name];\r\n if (typeof imageFunction === 'undefined') {\r\n throw new Error(\"Attempting to parse an unsupported image function \\\"\" + value.name + \"\\\"\");\r\n }\r\n return imageFunction(value.values);\r\n }\r\n throw new Error(\"Unsupported image type\");\r\n }\r\n };\r\n function isSupportedImage(value) {\r\n return value.type !== TokenType.FUNCTION || SUPPORTED_IMAGE_FUNCTIONS[value.name];\r\n }\r\n var SUPPORTED_IMAGE_FUNCTIONS = {\r\n 'linear-gradient': linearGradient,\r\n '-moz-linear-gradient': prefixLinearGradient,\r\n '-ms-linear-gradient': prefixLinearGradient,\r\n '-o-linear-gradient': prefixLinearGradient,\r\n '-webkit-linear-gradient': prefixLinearGradient,\r\n 'radial-gradient': radialGradient,\r\n '-moz-radial-gradient': prefixRadialGradient,\r\n '-ms-radial-gradient': prefixRadialGradient,\r\n '-o-radial-gradient': prefixRadialGradient,\r\n '-webkit-radial-gradient': prefixRadialGradient,\r\n '-webkit-gradient': webkitGradient\r\n };\n\n var backgroundImage = {\r\n name: 'background-image',\r\n initialValue: 'none',\r\n type: PropertyDescriptorParsingType.LIST,\r\n prefix: false,\r\n parse: function (tokens) {\r\n if (tokens.length === 0) {\r\n return [];\r\n }\r\n var first = tokens[0];\r\n if (first.type === TokenType.IDENT_TOKEN && first.value === 'none') {\r\n return [];\r\n }\r\n return tokens.filter(function (value) { return nonFunctionArgSeparator(value) && isSupportedImage(value); }).map(image.parse);\r\n }\r\n };\n\n var backgroundOrigin = {\r\n name: 'background-origin',\r\n initialValue: 'border-box',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n return tokens.map(function (token) {\r\n if (isIdentToken(token)) {\r\n switch (token.value) {\r\n case 'padding-box':\r\n return 1 /* PADDING_BOX */;\r\n case 'content-box':\r\n return 2 /* CONTENT_BOX */;\r\n }\r\n }\r\n return 0 /* BORDER_BOX */;\r\n });\r\n }\r\n };\n\n var backgroundPosition = {\r\n name: 'background-position',\r\n initialValue: '0% 0%',\r\n type: PropertyDescriptorParsingType.LIST,\r\n prefix: false,\r\n parse: function (tokens) {\r\n return parseFunctionArgs(tokens)\r\n .map(function (values) { return values.filter(isLengthPercentage); })\r\n .map(parseLengthPercentageTuple);\r\n }\r\n };\n\n var BACKGROUND_REPEAT;\r\n (function (BACKGROUND_REPEAT) {\r\n BACKGROUND_REPEAT[BACKGROUND_REPEAT[\"REPEAT\"] = 0] = \"REPEAT\";\r\n BACKGROUND_REPEAT[BACKGROUND_REPEAT[\"NO_REPEAT\"] = 1] = \"NO_REPEAT\";\r\n BACKGROUND_REPEAT[BACKGROUND_REPEAT[\"REPEAT_X\"] = 2] = \"REPEAT_X\";\r\n BACKGROUND_REPEAT[BACKGROUND_REPEAT[\"REPEAT_Y\"] = 3] = \"REPEAT_Y\";\r\n })(BACKGROUND_REPEAT || (BACKGROUND_REPEAT = {}));\r\n var backgroundRepeat = {\r\n name: 'background-repeat',\r\n initialValue: 'repeat',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n return parseFunctionArgs(tokens)\r\n .map(function (values) {\r\n return values\r\n .filter(isIdentToken)\r\n .map(function (token) { return token.value; })\r\n .join(' ');\r\n })\r\n .map(parseBackgroundRepeat);\r\n }\r\n };\r\n var parseBackgroundRepeat = function (value) {\r\n switch (value) {\r\n case 'no-repeat':\r\n return BACKGROUND_REPEAT.NO_REPEAT;\r\n case 'repeat-x':\r\n case 'repeat no-repeat':\r\n return BACKGROUND_REPEAT.REPEAT_X;\r\n case 'repeat-y':\r\n case 'no-repeat repeat':\r\n return BACKGROUND_REPEAT.REPEAT_Y;\r\n case 'repeat':\r\n default:\r\n return BACKGROUND_REPEAT.REPEAT;\r\n }\r\n };\n\n var BACKGROUND_SIZE;\r\n (function (BACKGROUND_SIZE) {\r\n BACKGROUND_SIZE[\"AUTO\"] = \"auto\";\r\n BACKGROUND_SIZE[\"CONTAIN\"] = \"contain\";\r\n BACKGROUND_SIZE[\"COVER\"] = \"cover\";\r\n })(BACKGROUND_SIZE || (BACKGROUND_SIZE = {}));\r\n var backgroundSize = {\r\n name: 'background-size',\r\n initialValue: '0',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n return parseFunctionArgs(tokens).map(function (values) { return values.filter(isBackgroundSizeInfoToken); });\r\n }\r\n };\r\n var isBackgroundSizeInfoToken = function (value) {\r\n return isIdentToken(value) || isLengthPercentage(value);\r\n };\n\n var borderColorForSide = function (side) { return ({\r\n name: \"border-\" + side + \"-color\",\r\n initialValue: 'transparent',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TYPE_VALUE,\r\n format: 'color'\r\n }); };\r\n var borderTopColor = borderColorForSide('top');\r\n var borderRightColor = borderColorForSide('right');\r\n var borderBottomColor = borderColorForSide('bottom');\r\n var borderLeftColor = borderColorForSide('left');\n\n var borderRadiusForSide = function (side) { return ({\r\n name: \"border-radius-\" + side,\r\n initialValue: '0 0',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) { return parseLengthPercentageTuple(tokens.filter(isLengthPercentage)); }\r\n }); };\r\n var borderTopLeftRadius = borderRadiusForSide('top-left');\r\n var borderTopRightRadius = borderRadiusForSide('top-right');\r\n var borderBottomRightRadius = borderRadiusForSide('bottom-right');\r\n var borderBottomLeftRadius = borderRadiusForSide('bottom-left');\n\n var BORDER_STYLE;\r\n (function (BORDER_STYLE) {\r\n BORDER_STYLE[BORDER_STYLE[\"NONE\"] = 0] = \"NONE\";\r\n BORDER_STYLE[BORDER_STYLE[\"SOLID\"] = 1] = \"SOLID\";\r\n })(BORDER_STYLE || (BORDER_STYLE = {}));\r\n var borderStyleForSide = function (side) { return ({\r\n name: \"border-\" + side + \"-style\",\r\n initialValue: 'solid',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (style) {\r\n switch (style) {\r\n case 'none':\r\n return BORDER_STYLE.NONE;\r\n }\r\n return BORDER_STYLE.SOLID;\r\n }\r\n }); };\r\n var borderTopStyle = borderStyleForSide('top');\r\n var borderRightStyle = borderStyleForSide('right');\r\n var borderBottomStyle = borderStyleForSide('bottom');\r\n var borderLeftStyle = borderStyleForSide('left');\n\n var borderWidthForSide = function (side) { return ({\r\n name: \"border-\" + side + \"-width\",\r\n initialValue: '0',\r\n type: PropertyDescriptorParsingType.VALUE,\r\n prefix: false,\r\n parse: function (token) {\r\n if (isDimensionToken(token)) {\r\n return token.number;\r\n }\r\n return 0;\r\n }\r\n }); };\r\n var borderTopWidth = borderWidthForSide('top');\r\n var borderRightWidth = borderWidthForSide('right');\r\n var borderBottomWidth = borderWidthForSide('bottom');\r\n var borderLeftWidth = borderWidthForSide('left');\n\n var color$1 = {\r\n name: \"color\",\r\n initialValue: 'transparent',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TYPE_VALUE,\r\n format: 'color'\r\n };\n\n var display = {\r\n name: 'display',\r\n initialValue: 'inline-block',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n return tokens.filter(isIdentToken).reduce(function (bit, token) {\r\n return bit | parseDisplayValue(token.value);\r\n }, 0 /* NONE */);\r\n }\r\n };\r\n var parseDisplayValue = function (display) {\r\n switch (display) {\r\n case 'block':\r\n return 2 /* BLOCK */;\r\n case 'inline':\r\n return 4 /* INLINE */;\r\n case 'run-in':\r\n return 8 /* RUN_IN */;\r\n case 'flow':\r\n return 16 /* FLOW */;\r\n case 'flow-root':\r\n return 32 /* FLOW_ROOT */;\r\n case 'table':\r\n return 64 /* TABLE */;\r\n case 'flex':\r\n case '-webkit-flex':\r\n return 128 /* FLEX */;\r\n case 'grid':\r\n case '-ms-grid':\r\n return 256 /* GRID */;\r\n case 'ruby':\r\n return 512 /* RUBY */;\r\n case 'subgrid':\r\n return 1024 /* SUBGRID */;\r\n case 'list-item':\r\n return 2048 /* LIST_ITEM */;\r\n case 'table-row-group':\r\n return 4096 /* TABLE_ROW_GROUP */;\r\n case 'table-header-group':\r\n return 8192 /* TABLE_HEADER_GROUP */;\r\n case 'table-footer-group':\r\n return 16384 /* TABLE_FOOTER_GROUP */;\r\n case 'table-row':\r\n return 32768 /* TABLE_ROW */;\r\n case 'table-cell':\r\n return 65536 /* TABLE_CELL */;\r\n case 'table-column-group':\r\n return 131072 /* TABLE_COLUMN_GROUP */;\r\n case 'table-column':\r\n return 262144 /* TABLE_COLUMN */;\r\n case 'table-caption':\r\n return 524288 /* TABLE_CAPTION */;\r\n case 'ruby-base':\r\n return 1048576 /* RUBY_BASE */;\r\n case 'ruby-text':\r\n return 2097152 /* RUBY_TEXT */;\r\n case 'ruby-base-container':\r\n return 4194304 /* RUBY_BASE_CONTAINER */;\r\n case 'ruby-text-container':\r\n return 8388608 /* RUBY_TEXT_CONTAINER */;\r\n case 'contents':\r\n return 16777216 /* CONTENTS */;\r\n case 'inline-block':\r\n return 33554432 /* INLINE_BLOCK */;\r\n case 'inline-list-item':\r\n return 67108864 /* INLINE_LIST_ITEM */;\r\n case 'inline-table':\r\n return 134217728 /* INLINE_TABLE */;\r\n case 'inline-flex':\r\n return 268435456 /* INLINE_FLEX */;\r\n case 'inline-grid':\r\n return 536870912 /* INLINE_GRID */;\r\n }\r\n return 0 /* NONE */;\r\n };\n\n var FLOAT;\r\n (function (FLOAT) {\r\n FLOAT[FLOAT[\"NONE\"] = 0] = \"NONE\";\r\n FLOAT[FLOAT[\"LEFT\"] = 1] = \"LEFT\";\r\n FLOAT[FLOAT[\"RIGHT\"] = 2] = \"RIGHT\";\r\n FLOAT[FLOAT[\"INLINE_START\"] = 3] = \"INLINE_START\";\r\n FLOAT[FLOAT[\"INLINE_END\"] = 4] = \"INLINE_END\";\r\n })(FLOAT || (FLOAT = {}));\r\n var float = {\r\n name: 'float',\r\n initialValue: 'none',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (float) {\r\n switch (float) {\r\n case 'left':\r\n return FLOAT.LEFT;\r\n case 'right':\r\n return FLOAT.RIGHT;\r\n case 'inline-start':\r\n return FLOAT.INLINE_START;\r\n case 'inline-end':\r\n return FLOAT.INLINE_END;\r\n }\r\n return FLOAT.NONE;\r\n }\r\n };\n\n var letterSpacing = {\r\n name: 'letter-spacing',\r\n initialValue: '0',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.VALUE,\r\n parse: function (token) {\r\n if (token.type === TokenType.IDENT_TOKEN && token.value === 'normal') {\r\n return 0;\r\n }\r\n if (token.type === TokenType.NUMBER_TOKEN) {\r\n return token.number;\r\n }\r\n if (token.type === TokenType.DIMENSION_TOKEN) {\r\n return token.number;\r\n }\r\n return 0;\r\n }\r\n };\n\n var LINE_BREAK;\r\n (function (LINE_BREAK) {\r\n LINE_BREAK[\"NORMAL\"] = \"normal\";\r\n LINE_BREAK[\"STRICT\"] = \"strict\";\r\n })(LINE_BREAK || (LINE_BREAK = {}));\r\n var lineBreak = {\r\n name: 'line-break',\r\n initialValue: 'normal',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (lineBreak) {\r\n switch (lineBreak) {\r\n case 'strict':\r\n return LINE_BREAK.STRICT;\r\n case 'normal':\r\n default:\r\n return LINE_BREAK.NORMAL;\r\n }\r\n }\r\n };\n\n var lineHeight = {\r\n name: 'line-height',\r\n initialValue: 'normal',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TOKEN_VALUE\r\n };\r\n var computeLineHeight = function (token, fontSize) {\r\n if (isIdentToken(token) && token.value === 'normal') {\r\n return 1.2 * fontSize;\r\n }\r\n else if (token.type === TokenType.NUMBER_TOKEN) {\r\n return fontSize * token.number;\r\n }\r\n else if (isLengthPercentage(token)) {\r\n return getAbsoluteValue(token, fontSize);\r\n }\r\n return fontSize;\r\n };\n\n var listStyleImage = {\r\n name: 'list-style-image',\r\n initialValue: 'none',\r\n type: PropertyDescriptorParsingType.VALUE,\r\n prefix: false,\r\n parse: function (token) {\r\n if (token.type === TokenType.IDENT_TOKEN && token.value === 'none') {\r\n return null;\r\n }\r\n return image.parse(token);\r\n }\r\n };\n\n var LIST_STYLE_POSITION;\r\n (function (LIST_STYLE_POSITION) {\r\n LIST_STYLE_POSITION[LIST_STYLE_POSITION[\"INSIDE\"] = 0] = \"INSIDE\";\r\n LIST_STYLE_POSITION[LIST_STYLE_POSITION[\"OUTSIDE\"] = 1] = \"OUTSIDE\";\r\n })(LIST_STYLE_POSITION || (LIST_STYLE_POSITION = {}));\r\n var listStylePosition = {\r\n name: 'list-style-position',\r\n initialValue: 'outside',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (position) {\r\n switch (position) {\r\n case 'inside':\r\n return LIST_STYLE_POSITION.INSIDE;\r\n case 'outside':\r\n default:\r\n return LIST_STYLE_POSITION.OUTSIDE;\r\n }\r\n }\r\n };\n\n var LIST_STYLE_TYPE;\r\n (function (LIST_STYLE_TYPE) {\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"NONE\"] = -1] = \"NONE\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"DISC\"] = 0] = \"DISC\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"CIRCLE\"] = 1] = \"CIRCLE\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"SQUARE\"] = 2] = \"SQUARE\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"DECIMAL\"] = 3] = \"DECIMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"CJK_DECIMAL\"] = 4] = \"CJK_DECIMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"DECIMAL_LEADING_ZERO\"] = 5] = \"DECIMAL_LEADING_ZERO\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"LOWER_ROMAN\"] = 6] = \"LOWER_ROMAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"UPPER_ROMAN\"] = 7] = \"UPPER_ROMAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"LOWER_GREEK\"] = 8] = \"LOWER_GREEK\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"LOWER_ALPHA\"] = 9] = \"LOWER_ALPHA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"UPPER_ALPHA\"] = 10] = \"UPPER_ALPHA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"ARABIC_INDIC\"] = 11] = \"ARABIC_INDIC\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"ARMENIAN\"] = 12] = \"ARMENIAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"BENGALI\"] = 13] = \"BENGALI\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"CAMBODIAN\"] = 14] = \"CAMBODIAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"CJK_EARTHLY_BRANCH\"] = 15] = \"CJK_EARTHLY_BRANCH\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"CJK_HEAVENLY_STEM\"] = 16] = \"CJK_HEAVENLY_STEM\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"CJK_IDEOGRAPHIC\"] = 17] = \"CJK_IDEOGRAPHIC\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"DEVANAGARI\"] = 18] = \"DEVANAGARI\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"ETHIOPIC_NUMERIC\"] = 19] = \"ETHIOPIC_NUMERIC\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"GEORGIAN\"] = 20] = \"GEORGIAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"GUJARATI\"] = 21] = \"GUJARATI\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"GURMUKHI\"] = 22] = \"GURMUKHI\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"HEBREW\"] = 22] = \"HEBREW\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"HIRAGANA\"] = 23] = \"HIRAGANA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"HIRAGANA_IROHA\"] = 24] = \"HIRAGANA_IROHA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"JAPANESE_FORMAL\"] = 25] = \"JAPANESE_FORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"JAPANESE_INFORMAL\"] = 26] = \"JAPANESE_INFORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"KANNADA\"] = 27] = \"KANNADA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"KATAKANA\"] = 28] = \"KATAKANA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"KATAKANA_IROHA\"] = 29] = \"KATAKANA_IROHA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"KHMER\"] = 30] = \"KHMER\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"KOREAN_HANGUL_FORMAL\"] = 31] = \"KOREAN_HANGUL_FORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"KOREAN_HANJA_FORMAL\"] = 32] = \"KOREAN_HANJA_FORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"KOREAN_HANJA_INFORMAL\"] = 33] = \"KOREAN_HANJA_INFORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"LAO\"] = 34] = \"LAO\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"LOWER_ARMENIAN\"] = 35] = \"LOWER_ARMENIAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"MALAYALAM\"] = 36] = \"MALAYALAM\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"MONGOLIAN\"] = 37] = \"MONGOLIAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"MYANMAR\"] = 38] = \"MYANMAR\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"ORIYA\"] = 39] = \"ORIYA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"PERSIAN\"] = 40] = \"PERSIAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"SIMP_CHINESE_FORMAL\"] = 41] = \"SIMP_CHINESE_FORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"SIMP_CHINESE_INFORMAL\"] = 42] = \"SIMP_CHINESE_INFORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"TAMIL\"] = 43] = \"TAMIL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"TELUGU\"] = 44] = \"TELUGU\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"THAI\"] = 45] = \"THAI\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"TIBETAN\"] = 46] = \"TIBETAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"TRAD_CHINESE_FORMAL\"] = 47] = \"TRAD_CHINESE_FORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"TRAD_CHINESE_INFORMAL\"] = 48] = \"TRAD_CHINESE_INFORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"UPPER_ARMENIAN\"] = 49] = \"UPPER_ARMENIAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"DISCLOSURE_OPEN\"] = 50] = \"DISCLOSURE_OPEN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"DISCLOSURE_CLOSED\"] = 51] = \"DISCLOSURE_CLOSED\";\r\n })(LIST_STYLE_TYPE || (LIST_STYLE_TYPE = {}));\r\n var listStyleType = {\r\n name: 'list-style-type',\r\n initialValue: 'none',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (type) {\r\n switch (type) {\r\n case 'disc':\r\n return LIST_STYLE_TYPE.DISC;\r\n case 'circle':\r\n return LIST_STYLE_TYPE.CIRCLE;\r\n case 'square':\r\n return LIST_STYLE_TYPE.SQUARE;\r\n case 'decimal':\r\n return LIST_STYLE_TYPE.DECIMAL;\r\n case 'cjk-decimal':\r\n return LIST_STYLE_TYPE.CJK_DECIMAL;\r\n case 'decimal-leading-zero':\r\n return LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO;\r\n case 'lower-roman':\r\n return LIST_STYLE_TYPE.LOWER_ROMAN;\r\n case 'upper-roman':\r\n return LIST_STYLE_TYPE.UPPER_ROMAN;\r\n case 'lower-greek':\r\n return LIST_STYLE_TYPE.LOWER_GREEK;\r\n case 'lower-alpha':\r\n return LIST_STYLE_TYPE.LOWER_ALPHA;\r\n case 'upper-alpha':\r\n return LIST_STYLE_TYPE.UPPER_ALPHA;\r\n case 'arabic-indic':\r\n return LIST_STYLE_TYPE.ARABIC_INDIC;\r\n case 'armenian':\r\n return LIST_STYLE_TYPE.ARMENIAN;\r\n case 'bengali':\r\n return LIST_STYLE_TYPE.BENGALI;\r\n case 'cambodian':\r\n return LIST_STYLE_TYPE.CAMBODIAN;\r\n case 'cjk-earthly-branch':\r\n return LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH;\r\n case 'cjk-heavenly-stem':\r\n return LIST_STYLE_TYPE.CJK_HEAVENLY_STEM;\r\n case 'cjk-ideographic':\r\n return LIST_STYLE_TYPE.CJK_IDEOGRAPHIC;\r\n case 'devanagari':\r\n return LIST_STYLE_TYPE.DEVANAGARI;\r\n case 'ethiopic-numeric':\r\n return LIST_STYLE_TYPE.ETHIOPIC_NUMERIC;\r\n case 'georgian':\r\n return LIST_STYLE_TYPE.GEORGIAN;\r\n case 'gujarati':\r\n return LIST_STYLE_TYPE.GUJARATI;\r\n case 'gurmukhi':\r\n return LIST_STYLE_TYPE.GURMUKHI;\r\n case 'hebrew':\r\n return LIST_STYLE_TYPE.HEBREW;\r\n case 'hiragana':\r\n return LIST_STYLE_TYPE.HIRAGANA;\r\n case 'hiragana-iroha':\r\n return LIST_STYLE_TYPE.HIRAGANA_IROHA;\r\n case 'japanese-formal':\r\n return LIST_STYLE_TYPE.JAPANESE_FORMAL;\r\n case 'japanese-informal':\r\n return LIST_STYLE_TYPE.JAPANESE_INFORMAL;\r\n case 'kannada':\r\n return LIST_STYLE_TYPE.KANNADA;\r\n case 'katakana':\r\n return LIST_STYLE_TYPE.KATAKANA;\r\n case 'katakana-iroha':\r\n return LIST_STYLE_TYPE.KATAKANA_IROHA;\r\n case 'khmer':\r\n return LIST_STYLE_TYPE.KHMER;\r\n case 'korean-hangul-formal':\r\n return LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL;\r\n case 'korean-hanja-formal':\r\n return LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL;\r\n case 'korean-hanja-informal':\r\n return LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL;\r\n case 'lao':\r\n return LIST_STYLE_TYPE.LAO;\r\n case 'lower-armenian':\r\n return LIST_STYLE_TYPE.LOWER_ARMENIAN;\r\n case 'malayalam':\r\n return LIST_STYLE_TYPE.MALAYALAM;\r\n case 'mongolian':\r\n return LIST_STYLE_TYPE.MONGOLIAN;\r\n case 'myanmar':\r\n return LIST_STYLE_TYPE.MYANMAR;\r\n case 'oriya':\r\n return LIST_STYLE_TYPE.ORIYA;\r\n case 'persian':\r\n return LIST_STYLE_TYPE.PERSIAN;\r\n case 'simp-chinese-formal':\r\n return LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL;\r\n case 'simp-chinese-informal':\r\n return LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL;\r\n case 'tamil':\r\n return LIST_STYLE_TYPE.TAMIL;\r\n case 'telugu':\r\n return LIST_STYLE_TYPE.TELUGU;\r\n case 'thai':\r\n return LIST_STYLE_TYPE.THAI;\r\n case 'tibetan':\r\n return LIST_STYLE_TYPE.TIBETAN;\r\n case 'trad-chinese-formal':\r\n return LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL;\r\n case 'trad-chinese-informal':\r\n return LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL;\r\n case 'upper-armenian':\r\n return LIST_STYLE_TYPE.UPPER_ARMENIAN;\r\n case 'disclosure-open':\r\n return LIST_STYLE_TYPE.DISCLOSURE_OPEN;\r\n case 'disclosure-closed':\r\n return LIST_STYLE_TYPE.DISCLOSURE_CLOSED;\r\n case 'none':\r\n default:\r\n return LIST_STYLE_TYPE.NONE;\r\n }\r\n }\r\n };\n\n var marginForSide = function (side) { return ({\r\n name: \"margin-\" + side,\r\n initialValue: '0',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TOKEN_VALUE\r\n }); };\r\n var marginTop = marginForSide('top');\r\n var marginRight = marginForSide('right');\r\n var marginBottom = marginForSide('bottom');\r\n var marginLeft = marginForSide('left');\n\n var OVERFLOW;\r\n (function (OVERFLOW) {\r\n OVERFLOW[OVERFLOW[\"VISIBLE\"] = 0] = \"VISIBLE\";\r\n OVERFLOW[OVERFLOW[\"HIDDEN\"] = 1] = \"HIDDEN\";\r\n OVERFLOW[OVERFLOW[\"SCROLL\"] = 2] = \"SCROLL\";\r\n OVERFLOW[OVERFLOW[\"AUTO\"] = 3] = \"AUTO\";\r\n })(OVERFLOW || (OVERFLOW = {}));\r\n var overflow = {\r\n name: 'overflow',\r\n initialValue: 'visible',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n return tokens.filter(isIdentToken).map(function (overflow) {\r\n switch (overflow.value) {\r\n case 'hidden':\r\n return OVERFLOW.HIDDEN;\r\n case 'scroll':\r\n return OVERFLOW.SCROLL;\r\n case 'auto':\r\n return OVERFLOW.AUTO;\r\n case 'visible':\r\n default:\r\n return OVERFLOW.VISIBLE;\r\n }\r\n });\r\n }\r\n };\n\n var OVERFLOW_WRAP;\r\n (function (OVERFLOW_WRAP) {\r\n OVERFLOW_WRAP[\"NORMAL\"] = \"normal\";\r\n OVERFLOW_WRAP[\"BREAK_WORD\"] = \"break-word\";\r\n })(OVERFLOW_WRAP || (OVERFLOW_WRAP = {}));\r\n var overflowWrap = {\r\n name: 'overflow-wrap',\r\n initialValue: 'normal',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (overflow) {\r\n switch (overflow) {\r\n case 'break-word':\r\n return OVERFLOW_WRAP.BREAK_WORD;\r\n case 'normal':\r\n default:\r\n return OVERFLOW_WRAP.NORMAL;\r\n }\r\n }\r\n };\n\n var paddingForSide = function (side) { return ({\r\n name: \"padding-\" + side,\r\n initialValue: '0',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TYPE_VALUE,\r\n format: 'length-percentage'\r\n }); };\r\n var paddingTop = paddingForSide('top');\r\n var paddingRight = paddingForSide('right');\r\n var paddingBottom = paddingForSide('bottom');\r\n var paddingLeft = paddingForSide('left');\n\n var TEXT_ALIGN;\r\n (function (TEXT_ALIGN) {\r\n TEXT_ALIGN[TEXT_ALIGN[\"LEFT\"] = 0] = \"LEFT\";\r\n TEXT_ALIGN[TEXT_ALIGN[\"CENTER\"] = 1] = \"CENTER\";\r\n TEXT_ALIGN[TEXT_ALIGN[\"RIGHT\"] = 2] = \"RIGHT\";\r\n })(TEXT_ALIGN || (TEXT_ALIGN = {}));\r\n var textAlign = {\r\n name: 'text-align',\r\n initialValue: 'left',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (textAlign) {\r\n switch (textAlign) {\r\n case 'right':\r\n return TEXT_ALIGN.RIGHT;\r\n case 'center':\r\n case 'justify':\r\n return TEXT_ALIGN.CENTER;\r\n case 'left':\r\n default:\r\n return TEXT_ALIGN.LEFT;\r\n }\r\n }\r\n };\n\n var POSITION;\r\n (function (POSITION) {\r\n POSITION[POSITION[\"STATIC\"] = 0] = \"STATIC\";\r\n POSITION[POSITION[\"RELATIVE\"] = 1] = \"RELATIVE\";\r\n POSITION[POSITION[\"ABSOLUTE\"] = 2] = \"ABSOLUTE\";\r\n POSITION[POSITION[\"FIXED\"] = 3] = \"FIXED\";\r\n POSITION[POSITION[\"STICKY\"] = 4] = \"STICKY\";\r\n })(POSITION || (POSITION = {}));\r\n var position = {\r\n name: 'position',\r\n initialValue: 'static',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (position) {\r\n switch (position) {\r\n case 'relative':\r\n return POSITION.RELATIVE;\r\n case 'absolute':\r\n return POSITION.ABSOLUTE;\r\n case 'fixed':\r\n return POSITION.FIXED;\r\n case 'sticky':\r\n return POSITION.STICKY;\r\n }\r\n return POSITION.STATIC;\r\n }\r\n };\n\n var textShadow = {\r\n name: 'text-shadow',\r\n initialValue: 'none',\r\n type: PropertyDescriptorParsingType.LIST,\r\n prefix: false,\r\n parse: function (tokens) {\r\n if (tokens.length === 1 && isIdentWithValue(tokens[0], 'none')) {\r\n return [];\r\n }\r\n return parseFunctionArgs(tokens).map(function (values) {\r\n var shadow = {\r\n color: COLORS.TRANSPARENT,\r\n offsetX: ZERO_LENGTH,\r\n offsetY: ZERO_LENGTH,\r\n blur: ZERO_LENGTH\r\n };\r\n var c = 0;\r\n for (var i = 0; i < values.length; i++) {\r\n var token = values[i];\r\n if (isLength(token)) {\r\n if (c === 0) {\r\n shadow.offsetX = token;\r\n }\r\n else if (c === 1) {\r\n shadow.offsetY = token;\r\n }\r\n else {\r\n shadow.blur = token;\r\n }\r\n c++;\r\n }\r\n else {\r\n shadow.color = color.parse(token);\r\n }\r\n }\r\n return shadow;\r\n });\r\n }\r\n };\n\n var TEXT_TRANSFORM;\r\n (function (TEXT_TRANSFORM) {\r\n TEXT_TRANSFORM[TEXT_TRANSFORM[\"NONE\"] = 0] = \"NONE\";\r\n TEXT_TRANSFORM[TEXT_TRANSFORM[\"LOWERCASE\"] = 1] = \"LOWERCASE\";\r\n TEXT_TRANSFORM[TEXT_TRANSFORM[\"UPPERCASE\"] = 2] = \"UPPERCASE\";\r\n TEXT_TRANSFORM[TEXT_TRANSFORM[\"CAPITALIZE\"] = 3] = \"CAPITALIZE\";\r\n })(TEXT_TRANSFORM || (TEXT_TRANSFORM = {}));\r\n var textTransform = {\r\n name: 'text-transform',\r\n initialValue: 'none',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (textTransform) {\r\n switch (textTransform) {\r\n case 'uppercase':\r\n return TEXT_TRANSFORM.UPPERCASE;\r\n case 'lowercase':\r\n return TEXT_TRANSFORM.LOWERCASE;\r\n case 'capitalize':\r\n return TEXT_TRANSFORM.CAPITALIZE;\r\n }\r\n return TEXT_TRANSFORM.NONE;\r\n }\r\n };\n\n var transform = {\r\n name: 'transform',\r\n initialValue: 'none',\r\n prefix: true,\r\n type: PropertyDescriptorParsingType.VALUE,\r\n parse: function (token) {\r\n if (token.type === TokenType.IDENT_TOKEN && token.value === 'none') {\r\n return null;\r\n }\r\n if (token.type === TokenType.FUNCTION) {\r\n var transformFunction = SUPPORTED_TRANSFORM_FUNCTIONS[token.name];\r\n if (typeof transformFunction === 'undefined') {\r\n throw new Error(\"Attempting to parse an unsupported transform function \\\"\" + token.name + \"\\\"\");\r\n }\r\n return transformFunction(token.values);\r\n }\r\n return null;\r\n }\r\n };\r\n var matrix = function (args) {\r\n var values = args.filter(function (arg) { return arg.type === TokenType.NUMBER_TOKEN; }).map(function (arg) { return arg.number; });\r\n return values.length === 6 ? values : null;\r\n };\r\n // doesn't support 3D transforms at the moment\r\n var matrix3d = function (args) {\r\n var values = args.filter(function (arg) { return arg.type === TokenType.NUMBER_TOKEN; }).map(function (arg) { return arg.number; });\r\n var a1 = values[0], b1 = values[1], _a = values[2], _b = values[3], a2 = values[4], b2 = values[5], _c = values[6], _d = values[7], _e = values[8], _f = values[9], _g = values[10], _h = values[11], a4 = values[12], b4 = values[13], _j = values[14], _k = values[15];\r\n return values.length === 16 ? [a1, b1, a2, b2, a4, b4] : null;\r\n };\r\n var SUPPORTED_TRANSFORM_FUNCTIONS = {\r\n matrix: matrix,\r\n matrix3d: matrix3d\r\n };\n\n var DEFAULT_VALUE = {\r\n type: TokenType.PERCENTAGE_TOKEN,\r\n number: 50,\r\n flags: FLAG_INTEGER\r\n };\r\n var DEFAULT = [DEFAULT_VALUE, DEFAULT_VALUE];\r\n var transformOrigin = {\r\n name: 'transform-origin',\r\n initialValue: '50% 50%',\r\n prefix: true,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n var origins = tokens.filter(isLengthPercentage);\r\n if (origins.length !== 2) {\r\n return DEFAULT;\r\n }\r\n return [origins[0], origins[1]];\r\n }\r\n };\n\n var VISIBILITY;\r\n (function (VISIBILITY) {\r\n VISIBILITY[VISIBILITY[\"VISIBLE\"] = 0] = \"VISIBLE\";\r\n VISIBILITY[VISIBILITY[\"HIDDEN\"] = 1] = \"HIDDEN\";\r\n VISIBILITY[VISIBILITY[\"COLLAPSE\"] = 2] = \"COLLAPSE\";\r\n })(VISIBILITY || (VISIBILITY = {}));\r\n var visibility = {\r\n name: 'visible',\r\n initialValue: 'none',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (visibility) {\r\n switch (visibility) {\r\n case 'hidden':\r\n return VISIBILITY.HIDDEN;\r\n case 'collapse':\r\n return VISIBILITY.COLLAPSE;\r\n case 'visible':\r\n default:\r\n return VISIBILITY.VISIBLE;\r\n }\r\n }\r\n };\n\n var WORD_BREAK;\r\n (function (WORD_BREAK) {\r\n WORD_BREAK[\"NORMAL\"] = \"normal\";\r\n WORD_BREAK[\"BREAK_ALL\"] = \"break-all\";\r\n WORD_BREAK[\"KEEP_ALL\"] = \"keep-all\";\r\n })(WORD_BREAK || (WORD_BREAK = {}));\r\n var wordBreak = {\r\n name: 'word-break',\r\n initialValue: 'normal',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (wordBreak) {\r\n switch (wordBreak) {\r\n case 'break-all':\r\n return WORD_BREAK.BREAK_ALL;\r\n case 'keep-all':\r\n return WORD_BREAK.KEEP_ALL;\r\n case 'normal':\r\n default:\r\n return WORD_BREAK.NORMAL;\r\n }\r\n }\r\n };\n\n var zIndex = {\r\n name: 'z-index',\r\n initialValue: 'auto',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.VALUE,\r\n parse: function (token) {\r\n if (token.type === TokenType.IDENT_TOKEN) {\r\n return { auto: true, order: 0 };\r\n }\r\n if (isNumberToken(token)) {\r\n return { auto: false, order: token.number };\r\n }\r\n throw new Error(\"Invalid z-index number parsed\");\r\n }\r\n };\n\n var opacity = {\r\n name: 'opacity',\r\n initialValue: '1',\r\n type: PropertyDescriptorParsingType.VALUE,\r\n prefix: false,\r\n parse: function (token) {\r\n if (isNumberToken(token)) {\r\n return token.number;\r\n }\r\n return 1;\r\n }\r\n };\n\n var textDecorationColor = {\r\n name: \"text-decoration-color\",\r\n initialValue: 'transparent',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TYPE_VALUE,\r\n format: 'color'\r\n };\n\n var textDecorationLine = {\r\n name: 'text-decoration-line',\r\n initialValue: 'none',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n return tokens\r\n .filter(isIdentToken)\r\n .map(function (token) {\r\n switch (token.value) {\r\n case 'underline':\r\n return 1 /* UNDERLINE */;\r\n case 'overline':\r\n return 2 /* OVERLINE */;\r\n case 'line-through':\r\n return 3 /* LINE_THROUGH */;\r\n case 'none':\r\n return 4 /* BLINK */;\r\n }\r\n return 0 /* NONE */;\r\n })\r\n .filter(function (line) { return line !== 0 /* NONE */; });\r\n }\r\n };\n\n var fontFamily = {\r\n name: \"font-family\",\r\n initialValue: '',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n var accumulator = [];\r\n var results = [];\r\n tokens.forEach(function (token) {\r\n switch (token.type) {\r\n case TokenType.IDENT_TOKEN:\r\n case TokenType.STRING_TOKEN:\r\n accumulator.push(token.value);\r\n break;\r\n case TokenType.NUMBER_TOKEN:\r\n accumulator.push(token.number.toString());\r\n break;\r\n case TokenType.COMMA_TOKEN:\r\n results.push(accumulator.join(' '));\r\n accumulator.length = 0;\r\n break;\r\n }\r\n });\r\n if (accumulator.length) {\r\n results.push(accumulator.join(' '));\r\n }\r\n return results.map(function (result) { return (result.indexOf(' ') === -1 ? result : \"'\" + result + \"'\"); });\r\n }\r\n };\n\n var fontSize = {\r\n name: \"font-size\",\r\n initialValue: '0',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TYPE_VALUE,\r\n format: 'length'\r\n };\n\n var fontWeight = {\r\n name: 'font-weight',\r\n initialValue: 'normal',\r\n type: PropertyDescriptorParsingType.VALUE,\r\n prefix: false,\r\n parse: function (token) {\r\n if (isNumberToken(token)) {\r\n return token.number;\r\n }\r\n if (isIdentToken(token)) {\r\n switch (token.value) {\r\n case 'bold':\r\n return 700;\r\n case 'normal':\r\n default:\r\n return 400;\r\n }\r\n }\r\n return 400;\r\n }\r\n };\n\n var fontVariant = {\r\n name: 'font-variant',\r\n initialValue: 'none',\r\n type: PropertyDescriptorParsingType.LIST,\r\n prefix: false,\r\n parse: function (tokens) {\r\n return tokens.filter(isIdentToken).map(function (token) { return token.value; });\r\n }\r\n };\n\n var FONT_STYLE;\r\n (function (FONT_STYLE) {\r\n FONT_STYLE[\"NORMAL\"] = \"normal\";\r\n FONT_STYLE[\"ITALIC\"] = \"italic\";\r\n FONT_STYLE[\"OBLIQUE\"] = \"oblique\";\r\n })(FONT_STYLE || (FONT_STYLE = {}));\r\n var fontStyle = {\r\n name: 'font-style',\r\n initialValue: 'normal',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (overflow) {\r\n switch (overflow) {\r\n case 'oblique':\r\n return FONT_STYLE.OBLIQUE;\r\n case 'italic':\r\n return FONT_STYLE.ITALIC;\r\n case 'normal':\r\n default:\r\n return FONT_STYLE.NORMAL;\r\n }\r\n }\r\n };\n\n var contains = function (bit, value) { return (bit & value) !== 0; };\n\n var content = {\r\n name: 'content',\r\n initialValue: 'none',\r\n type: PropertyDescriptorParsingType.LIST,\r\n prefix: false,\r\n parse: function (tokens) {\r\n if (tokens.length === 0) {\r\n return [];\r\n }\r\n var first = tokens[0];\r\n if (first.type === TokenType.IDENT_TOKEN && first.value === 'none') {\r\n return [];\r\n }\r\n return tokens;\r\n }\r\n };\n\n var counterIncrement = {\r\n name: 'counter-increment',\r\n initialValue: 'none',\r\n prefix: true,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n if (tokens.length === 0) {\r\n return null;\r\n }\r\n var first = tokens[0];\r\n if (first.type === TokenType.IDENT_TOKEN && first.value === 'none') {\r\n return null;\r\n }\r\n var increments = [];\r\n var filtered = tokens.filter(nonWhiteSpace);\r\n for (var i = 0; i < filtered.length; i++) {\r\n var counter = filtered[i];\r\n var next = filtered[i + 1];\r\n if (counter.type === TokenType.IDENT_TOKEN) {\r\n var increment = next && isNumberToken(next) ? next.number : 1;\r\n increments.push({ counter: counter.value, increment: increment });\r\n }\r\n }\r\n return increments;\r\n }\r\n };\n\n var counterReset = {\r\n name: 'counter-reset',\r\n initialValue: 'none',\r\n prefix: true,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n if (tokens.length === 0) {\r\n return [];\r\n }\r\n var resets = [];\r\n var filtered = tokens.filter(nonWhiteSpace);\r\n for (var i = 0; i < filtered.length; i++) {\r\n var counter = filtered[i];\r\n var next = filtered[i + 1];\r\n if (isIdentToken(counter) && counter.value !== 'none') {\r\n var reset = next && isNumberToken(next) ? next.number : 0;\r\n resets.push({ counter: counter.value, reset: reset });\r\n }\r\n }\r\n return resets;\r\n }\r\n };\n\n var quotes = {\r\n name: 'quotes',\r\n initialValue: 'none',\r\n prefix: true,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n if (tokens.length === 0) {\r\n return null;\r\n }\r\n var first = tokens[0];\r\n if (first.type === TokenType.IDENT_TOKEN && first.value === 'none') {\r\n return null;\r\n }\r\n var quotes = [];\r\n var filtered = tokens.filter(isStringToken);\r\n if (filtered.length % 2 !== 0) {\r\n return null;\r\n }\r\n for (var i = 0; i < filtered.length; i += 2) {\r\n var open_1 = filtered[i].value;\r\n var close_1 = filtered[i + 1].value;\r\n quotes.push({ open: open_1, close: close_1 });\r\n }\r\n return quotes;\r\n }\r\n };\r\n var getQuote = function (quotes, depth, open) {\r\n if (!quotes) {\r\n return '';\r\n }\r\n var quote = quotes[Math.min(depth, quotes.length - 1)];\r\n if (!quote) {\r\n return '';\r\n }\r\n return open ? quote.open : quote.close;\r\n };\n\n var boxShadow = {\r\n name: 'box-shadow',\r\n initialValue: 'none',\r\n type: PropertyDescriptorParsingType.LIST,\r\n prefix: false,\r\n parse: function (tokens) {\r\n if (tokens.length === 1 && isIdentWithValue(tokens[0], 'none')) {\r\n return [];\r\n }\r\n return parseFunctionArgs(tokens).map(function (values) {\r\n var shadow = {\r\n color: 0x000000ff,\r\n offsetX: ZERO_LENGTH,\r\n offsetY: ZERO_LENGTH,\r\n blur: ZERO_LENGTH,\r\n spread: ZERO_LENGTH,\r\n inset: false\r\n };\r\n var c = 0;\r\n for (var i = 0; i < values.length; i++) {\r\n var token = values[i];\r\n if (isIdentWithValue(token, 'inset')) {\r\n shadow.inset = true;\r\n }\r\n else if (isLength(token)) {\r\n if (c === 0) {\r\n shadow.offsetX = token;\r\n }\r\n else if (c === 1) {\r\n shadow.offsetY = token;\r\n }\r\n else if (c === 2) {\r\n shadow.blur = token;\r\n }\r\n else {\r\n shadow.spread = token;\r\n }\r\n c++;\r\n }\r\n else {\r\n shadow.color = color.parse(token);\r\n }\r\n }\r\n return shadow;\r\n });\r\n }\r\n };\n\n var CSSParsedDeclaration = /** @class */ (function () {\r\n function CSSParsedDeclaration(declaration) {\r\n this.backgroundClip = parse(backgroundClip, declaration.backgroundClip);\r\n this.backgroundColor = parse(backgroundColor, declaration.backgroundColor);\r\n this.backgroundImage = parse(backgroundImage, declaration.backgroundImage);\r\n this.backgroundOrigin = parse(backgroundOrigin, declaration.backgroundOrigin);\r\n this.backgroundPosition = parse(backgroundPosition, declaration.backgroundPosition);\r\n this.backgroundRepeat = parse(backgroundRepeat, declaration.backgroundRepeat);\r\n this.backgroundSize = parse(backgroundSize, declaration.backgroundSize);\r\n this.borderTopColor = parse(borderTopColor, declaration.borderTopColor);\r\n this.borderRightColor = parse(borderRightColor, declaration.borderRightColor);\r\n this.borderBottomColor = parse(borderBottomColor, declaration.borderBottomColor);\r\n this.borderLeftColor = parse(borderLeftColor, declaration.borderLeftColor);\r\n this.borderTopLeftRadius = parse(borderTopLeftRadius, declaration.borderTopLeftRadius);\r\n this.borderTopRightRadius = parse(borderTopRightRadius, declaration.borderTopRightRadius);\r\n this.borderBottomRightRadius = parse(borderBottomRightRadius, declaration.borderBottomRightRadius);\r\n this.borderBottomLeftRadius = parse(borderBottomLeftRadius, declaration.borderBottomLeftRadius);\r\n this.borderTopStyle = parse(borderTopStyle, declaration.borderTopStyle);\r\n this.borderRightStyle = parse(borderRightStyle, declaration.borderRightStyle);\r\n this.borderBottomStyle = parse(borderBottomStyle, declaration.borderBottomStyle);\r\n this.borderLeftStyle = parse(borderLeftStyle, declaration.borderLeftStyle);\r\n this.borderTopWidth = parse(borderTopWidth, declaration.borderTopWidth);\r\n this.borderRightWidth = parse(borderRightWidth, declaration.borderRightWidth);\r\n this.borderBottomWidth = parse(borderBottomWidth, declaration.borderBottomWidth);\r\n this.borderLeftWidth = parse(borderLeftWidth, declaration.borderLeftWidth);\r\n this.boxShadow = parse(boxShadow, declaration.boxShadow);\r\n this.color = parse(color$1, declaration.color);\r\n this.display = parse(display, declaration.display);\r\n this.float = parse(float, declaration.cssFloat);\r\n this.fontFamily = parse(fontFamily, declaration.fontFamily);\r\n this.fontSize = parse(fontSize, declaration.fontSize);\r\n this.fontStyle = parse(fontStyle, declaration.fontStyle);\r\n this.fontVariant = parse(fontVariant, declaration.fontVariant);\r\n this.fontWeight = parse(fontWeight, declaration.fontWeight);\r\n this.letterSpacing = parse(letterSpacing, declaration.letterSpacing);\r\n this.lineBreak = parse(lineBreak, declaration.lineBreak);\r\n this.lineHeight = parse(lineHeight, declaration.lineHeight);\r\n this.listStyleImage = parse(listStyleImage, declaration.listStyleImage);\r\n this.listStylePosition = parse(listStylePosition, declaration.listStylePosition);\r\n this.listStyleType = parse(listStyleType, declaration.listStyleType);\r\n this.marginTop = parse(marginTop, declaration.marginTop);\r\n this.marginRight = parse(marginRight, declaration.marginRight);\r\n this.marginBottom = parse(marginBottom, declaration.marginBottom);\r\n this.marginLeft = parse(marginLeft, declaration.marginLeft);\r\n this.opacity = parse(opacity, declaration.opacity);\r\n var overflowTuple = parse(overflow, declaration.overflow);\r\n this.overflowX = overflowTuple[0];\r\n this.overflowY = overflowTuple[overflowTuple.length > 1 ? 1 : 0];\r\n this.overflowWrap = parse(overflowWrap, declaration.overflowWrap);\r\n this.paddingTop = parse(paddingTop, declaration.paddingTop);\r\n this.paddingRight = parse(paddingRight, declaration.paddingRight);\r\n this.paddingBottom = parse(paddingBottom, declaration.paddingBottom);\r\n this.paddingLeft = parse(paddingLeft, declaration.paddingLeft);\r\n this.position = parse(position, declaration.position);\r\n this.textAlign = parse(textAlign, declaration.textAlign);\r\n this.textDecorationColor = parse(textDecorationColor, declaration.textDecorationColor || declaration.color);\r\n this.textDecorationLine = parse(textDecorationLine, declaration.textDecorationLine);\r\n this.textShadow = parse(textShadow, declaration.textShadow);\r\n this.textTransform = parse(textTransform, declaration.textTransform);\r\n this.transform = parse(transform, declaration.transform);\r\n this.transformOrigin = parse(transformOrigin, declaration.transformOrigin);\r\n this.visibility = parse(visibility, declaration.visibility);\r\n this.wordBreak = parse(wordBreak, declaration.wordBreak);\r\n this.zIndex = parse(zIndex, declaration.zIndex);\r\n }\r\n CSSParsedDeclaration.prototype.isVisible = function () {\r\n return this.display > 0 && this.opacity > 0 && this.visibility === VISIBILITY.VISIBLE;\r\n };\r\n CSSParsedDeclaration.prototype.isTransparent = function () {\r\n return isTransparent(this.backgroundColor);\r\n };\r\n CSSParsedDeclaration.prototype.isTransformed = function () {\r\n return this.transform !== null;\r\n };\r\n CSSParsedDeclaration.prototype.isPositioned = function () {\r\n return this.position !== POSITION.STATIC;\r\n };\r\n CSSParsedDeclaration.prototype.isPositionedWithZIndex = function () {\r\n return this.isPositioned() && !this.zIndex.auto;\r\n };\r\n CSSParsedDeclaration.prototype.isFloating = function () {\r\n return this.float !== FLOAT.NONE;\r\n };\r\n CSSParsedDeclaration.prototype.isInlineLevel = function () {\r\n return (contains(this.display, 4 /* INLINE */) ||\r\n contains(this.display, 33554432 /* INLINE_BLOCK */) ||\r\n contains(this.display, 268435456 /* INLINE_FLEX */) ||\r\n contains(this.display, 536870912 /* INLINE_GRID */) ||\r\n contains(this.display, 67108864 /* INLINE_LIST_ITEM */) ||\r\n contains(this.display, 134217728 /* INLINE_TABLE */));\r\n };\r\n return CSSParsedDeclaration;\r\n }());\r\n var CSSParsedPseudoDeclaration = /** @class */ (function () {\r\n function CSSParsedPseudoDeclaration(declaration) {\r\n this.content = parse(content, declaration.content);\r\n this.quotes = parse(quotes, declaration.quotes);\r\n }\r\n return CSSParsedPseudoDeclaration;\r\n }());\r\n var CSSParsedCounterDeclaration = /** @class */ (function () {\r\n function CSSParsedCounterDeclaration(declaration) {\r\n this.counterIncrement = parse(counterIncrement, declaration.counterIncrement);\r\n this.counterReset = parse(counterReset, declaration.counterReset);\r\n }\r\n return CSSParsedCounterDeclaration;\r\n }());\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n var parse = function (descriptor, style) {\r\n var tokenizer = new Tokenizer();\r\n var value = style !== null && typeof style !== 'undefined' ? style.toString() : descriptor.initialValue;\r\n tokenizer.write(value);\r\n var parser = new Parser(tokenizer.read());\r\n switch (descriptor.type) {\r\n case PropertyDescriptorParsingType.IDENT_VALUE:\r\n var token = parser.parseComponentValue();\r\n return descriptor.parse(isIdentToken(token) ? token.value : descriptor.initialValue);\r\n case PropertyDescriptorParsingType.VALUE:\r\n return descriptor.parse(parser.parseComponentValue());\r\n case PropertyDescriptorParsingType.LIST:\r\n return descriptor.parse(parser.parseComponentValues());\r\n case PropertyDescriptorParsingType.TOKEN_VALUE:\r\n return parser.parseComponentValue();\r\n case PropertyDescriptorParsingType.TYPE_VALUE:\r\n switch (descriptor.format) {\r\n case 'angle':\r\n return angle.parse(parser.parseComponentValue());\r\n case 'color':\r\n return color.parse(parser.parseComponentValue());\r\n case 'image':\r\n return image.parse(parser.parseComponentValue());\r\n case 'length':\r\n var length_1 = parser.parseComponentValue();\r\n return isLength(length_1) ? length_1 : ZERO_LENGTH;\r\n case 'length-percentage':\r\n var value_1 = parser.parseComponentValue();\r\n return isLengthPercentage(value_1) ? value_1 : ZERO_LENGTH;\r\n }\r\n }\r\n throw new Error(\"Attempting to parse unsupported css format type \" + descriptor.format);\r\n };\n\n var ElementContainer = /** @class */ (function () {\r\n function ElementContainer(element) {\r\n this.styles = new CSSParsedDeclaration(window.getComputedStyle(element, null));\r\n this.textNodes = [];\r\n this.elements = [];\r\n if (this.styles.transform !== null && isHTMLElementNode(element)) {\r\n // getBoundingClientRect takes transforms into account\r\n element.style.transform = 'none';\r\n }\r\n this.bounds = parseBounds(element);\r\n this.flags = 0;\r\n }\r\n return ElementContainer;\r\n }());\n\n var TextBounds = /** @class */ (function () {\r\n function TextBounds(text, bounds) {\r\n this.text = text;\r\n this.bounds = bounds;\r\n }\r\n return TextBounds;\r\n }());\r\n var parseTextBounds = function (value, styles, node) {\r\n var textList = breakText(value, styles);\r\n var textBounds = [];\r\n var offset = 0;\r\n textList.forEach(function (text) {\r\n if (styles.textDecorationLine.length || text.trim().length > 0) {\r\n if (FEATURES.SUPPORT_RANGE_BOUNDS) {\r\n textBounds.push(new TextBounds(text, getRangeBounds(node, offset, text.length)));\r\n }\r\n else {\r\n var replacementNode = node.splitText(text.length);\r\n textBounds.push(new TextBounds(text, getWrapperBounds(node)));\r\n node = replacementNode;\r\n }\r\n }\r\n else if (!FEATURES.SUPPORT_RANGE_BOUNDS) {\r\n node = node.splitText(text.length);\r\n }\r\n offset += text.length;\r\n });\r\n return textBounds;\r\n };\r\n var getWrapperBounds = function (node) {\r\n var ownerDocument = node.ownerDocument;\r\n if (ownerDocument) {\r\n var wrapper = ownerDocument.createElement('html2canvaswrapper');\r\n wrapper.appendChild(node.cloneNode(true));\r\n var parentNode = node.parentNode;\r\n if (parentNode) {\r\n parentNode.replaceChild(wrapper, node);\r\n var bounds = parseBounds(wrapper);\r\n if (wrapper.firstChild) {\r\n parentNode.replaceChild(wrapper.firstChild, wrapper);\r\n }\r\n return bounds;\r\n }\r\n }\r\n return new Bounds(0, 0, 0, 0);\r\n };\r\n var getRangeBounds = function (node, offset, length) {\r\n var ownerDocument = node.ownerDocument;\r\n if (!ownerDocument) {\r\n throw new Error('Node has no owner document');\r\n }\r\n var range = ownerDocument.createRange();\r\n range.setStart(node, offset);\r\n range.setEnd(node, offset + length);\r\n return Bounds.fromClientRect(range.getBoundingClientRect());\r\n };\r\n var breakText = function (value, styles) {\r\n return styles.letterSpacing !== 0 ? toCodePoints(value).map(function (i) { return fromCodePoint(i); }) : breakWords(value, styles);\r\n };\r\n var breakWords = function (str, styles) {\r\n var breaker = LineBreaker(str, {\r\n lineBreak: styles.lineBreak,\r\n wordBreak: styles.overflowWrap === OVERFLOW_WRAP.BREAK_WORD ? 'break-word' : styles.wordBreak\r\n });\r\n var words = [];\r\n var bk;\r\n while (!(bk = breaker.next()).done) {\r\n if (bk.value) {\r\n words.push(bk.value.slice());\r\n }\r\n }\r\n return words;\r\n };\n\n var TextContainer = /** @class */ (function () {\r\n function TextContainer(node, styles) {\r\n this.text = transform$1(node.data, styles.textTransform);\r\n this.textBounds = parseTextBounds(this.text, styles, node);\r\n }\r\n return TextContainer;\r\n }());\r\n var transform$1 = function (text, transform) {\r\n switch (transform) {\r\n case TEXT_TRANSFORM.LOWERCASE:\r\n return text.toLowerCase();\r\n case TEXT_TRANSFORM.CAPITALIZE:\r\n return text.replace(CAPITALIZE, capitalize);\r\n case TEXT_TRANSFORM.UPPERCASE:\r\n return text.toUpperCase();\r\n default:\r\n return text;\r\n }\r\n };\r\n var CAPITALIZE = /(^|\\s|:|-|\\(|\\))([a-z])/g;\r\n var capitalize = function (m, p1, p2) {\r\n if (m.length > 0) {\r\n return p1 + p2.toUpperCase();\r\n }\r\n return m;\r\n };\n\n var ImageElementContainer = /** @class */ (function (_super) {\r\n __extends(ImageElementContainer, _super);\r\n function ImageElementContainer(img) {\r\n var _this = _super.call(this, img) || this;\r\n _this.src = img.currentSrc || img.src;\r\n _this.intrinsicWidth = img.naturalWidth;\r\n _this.intrinsicHeight = img.naturalHeight;\r\n CacheStorage.getInstance().addImage(_this.src);\r\n return _this;\r\n }\r\n return ImageElementContainer;\r\n }(ElementContainer));\n\n var CanvasElementContainer = /** @class */ (function (_super) {\r\n __extends(CanvasElementContainer, _super);\r\n function CanvasElementContainer(canvas) {\r\n var _this = _super.call(this, canvas) || this;\r\n _this.canvas = canvas;\r\n _this.intrinsicWidth = canvas.width;\r\n _this.intrinsicHeight = canvas.height;\r\n return _this;\r\n }\r\n return CanvasElementContainer;\r\n }(ElementContainer));\n\n var SVGElementContainer = /** @class */ (function (_super) {\r\n __extends(SVGElementContainer, _super);\r\n function SVGElementContainer(img) {\r\n var _this = _super.call(this, img) || this;\r\n var s = new XMLSerializer();\r\n _this.svg = \"data:image/svg+xml,\" + encodeURIComponent(s.serializeToString(img));\r\n _this.intrinsicWidth = img.width.baseVal.value;\r\n _this.intrinsicHeight = img.height.baseVal.value;\r\n CacheStorage.getInstance().addImage(_this.svg);\r\n return _this;\r\n }\r\n return SVGElementContainer;\r\n }(ElementContainer));\n\n var LIElementContainer = /** @class */ (function (_super) {\r\n __extends(LIElementContainer, _super);\r\n function LIElementContainer(element) {\r\n var _this = _super.call(this, element) || this;\r\n _this.value = element.value;\r\n return _this;\r\n }\r\n return LIElementContainer;\r\n }(ElementContainer));\n\n var OLElementContainer = /** @class */ (function (_super) {\r\n __extends(OLElementContainer, _super);\r\n function OLElementContainer(element) {\r\n var _this = _super.call(this, element) || this;\r\n _this.start = element.start;\r\n _this.reversed = typeof element.reversed === 'boolean' && element.reversed === true;\r\n return _this;\r\n }\r\n return OLElementContainer;\r\n }(ElementContainer));\n\n var CHECKBOX_BORDER_RADIUS = [\r\n {\r\n type: TokenType.DIMENSION_TOKEN,\r\n flags: 0,\r\n unit: 'px',\r\n number: 3\r\n }\r\n ];\r\n var RADIO_BORDER_RADIUS = [\r\n {\r\n type: TokenType.PERCENTAGE_TOKEN,\r\n flags: 0,\r\n number: 50\r\n }\r\n ];\r\n var reformatInputBounds = function (bounds) {\r\n if (bounds.width > bounds.height) {\r\n return new Bounds(bounds.left + (bounds.width - bounds.height) / 2, bounds.top, bounds.height, bounds.height);\r\n }\r\n else if (bounds.width < bounds.height) {\r\n return new Bounds(bounds.left, bounds.top + (bounds.height - bounds.width) / 2, bounds.width, bounds.width);\r\n }\r\n return bounds;\r\n };\r\n var getInputValue = function (node) {\r\n var value = node.type === PASSWORD ? new Array(node.value.length + 1).join('\\u2022') : node.value;\r\n return value.length === 0 ? node.placeholder || '' : value;\r\n };\r\n var CHECKBOX = 'checkbox';\r\n var RADIO = 'radio';\r\n var PASSWORD = 'password';\r\n var INPUT_COLOR = 0x2a2a2aff;\r\n var InputElementContainer = /** @class */ (function (_super) {\r\n __extends(InputElementContainer, _super);\r\n function InputElementContainer(input) {\r\n var _this = _super.call(this, input) || this;\r\n _this.type = input.type.toLowerCase();\r\n _this.checked = input.checked;\r\n _this.value = getInputValue(input);\r\n if (_this.type === CHECKBOX || _this.type === RADIO) {\r\n _this.styles.backgroundColor = 0xdededeff;\r\n _this.styles.borderTopColor = _this.styles.borderRightColor = _this.styles.borderBottomColor = _this.styles.borderLeftColor = 0xa5a5a5ff;\r\n _this.styles.borderTopWidth = _this.styles.borderRightWidth = _this.styles.borderBottomWidth = _this.styles.borderLeftWidth = 1;\r\n _this.styles.borderTopStyle = _this.styles.borderRightStyle = _this.styles.borderBottomStyle = _this.styles.borderLeftStyle =\r\n BORDER_STYLE.SOLID;\r\n _this.styles.backgroundClip = [BACKGROUND_CLIP.BORDER_BOX];\r\n _this.styles.backgroundOrigin = [0 /* BORDER_BOX */];\r\n _this.bounds = reformatInputBounds(_this.bounds);\r\n }\r\n switch (_this.type) {\r\n case CHECKBOX:\r\n _this.styles.borderTopRightRadius = _this.styles.borderTopLeftRadius = _this.styles.borderBottomRightRadius = _this.styles.borderBottomLeftRadius = CHECKBOX_BORDER_RADIUS;\r\n break;\r\n case RADIO:\r\n _this.styles.borderTopRightRadius = _this.styles.borderTopLeftRadius = _this.styles.borderBottomRightRadius = _this.styles.borderBottomLeftRadius = RADIO_BORDER_RADIUS;\r\n break;\r\n }\r\n return _this;\r\n }\r\n return InputElementContainer;\r\n }(ElementContainer));\n\n var SelectElementContainer = /** @class */ (function (_super) {\r\n __extends(SelectElementContainer, _super);\r\n function SelectElementContainer(element) {\r\n var _this = _super.call(this, element) || this;\r\n var option = element.options[element.selectedIndex || 0];\r\n _this.value = option ? option.text || '' : '';\r\n return _this;\r\n }\r\n return SelectElementContainer;\r\n }(ElementContainer));\n\n var TextareaElementContainer = /** @class */ (function (_super) {\r\n __extends(TextareaElementContainer, _super);\r\n function TextareaElementContainer(element) {\r\n var _this = _super.call(this, element) || this;\r\n _this.value = element.value;\r\n return _this;\r\n }\r\n return TextareaElementContainer;\r\n }(ElementContainer));\n\n var parseColor = function (value) { return color.parse(Parser.create(value).parseComponentValue()); };\r\n var IFrameElementContainer = /** @class */ (function (_super) {\r\n __extends(IFrameElementContainer, _super);\r\n function IFrameElementContainer(iframe) {\r\n var _this = _super.call(this, iframe) || this;\r\n _this.src = iframe.src;\r\n _this.width = parseInt(iframe.width, 10) || 0;\r\n _this.height = parseInt(iframe.height, 10) || 0;\r\n _this.backgroundColor = _this.styles.backgroundColor;\r\n try {\r\n if (iframe.contentWindow &&\r\n iframe.contentWindow.document &&\r\n iframe.contentWindow.document.documentElement) {\r\n _this.tree = parseTree(iframe.contentWindow.document.documentElement);\r\n // http://www.w3.org/TR/css3-background/#special-backgrounds\r\n var documentBackgroundColor = iframe.contentWindow.document.documentElement\r\n ? parseColor(getComputedStyle(iframe.contentWindow.document.documentElement)\r\n .backgroundColor)\r\n : COLORS.TRANSPARENT;\r\n var bodyBackgroundColor = iframe.contentWindow.document.body\r\n ? parseColor(getComputedStyle(iframe.contentWindow.document.body).backgroundColor)\r\n : COLORS.TRANSPARENT;\r\n _this.backgroundColor = isTransparent(documentBackgroundColor)\r\n ? isTransparent(bodyBackgroundColor)\r\n ? _this.styles.backgroundColor\r\n : bodyBackgroundColor\r\n : documentBackgroundColor;\r\n }\r\n }\r\n catch (e) { }\r\n return _this;\r\n }\r\n return IFrameElementContainer;\r\n }(ElementContainer));\n\n var LIST_OWNERS = ['OL', 'UL', 'MENU'];\r\n var parseNodeTree = function (node, parent, root) {\r\n for (var childNode = node.firstChild, nextNode = void 0; childNode; childNode = nextNode) {\r\n nextNode = childNode.nextSibling;\r\n if (isTextNode(childNode) && childNode.data.trim().length > 0) {\r\n parent.textNodes.push(new TextContainer(childNode, parent.styles));\r\n }\r\n else if (isElementNode(childNode)) {\r\n var container = createContainer(childNode);\r\n if (container.styles.isVisible()) {\r\n if (createsRealStackingContext(childNode, container, root)) {\r\n container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;\r\n }\r\n else if (createsStackingContext(container.styles)) {\r\n container.flags |= 2 /* CREATES_STACKING_CONTEXT */;\r\n }\r\n if (LIST_OWNERS.indexOf(childNode.tagName) !== -1) {\r\n container.flags |= 8 /* IS_LIST_OWNER */;\r\n }\r\n parent.elements.push(container);\r\n if (!isTextareaElement(childNode) && !isSVGElement(childNode) && !isSelectElement(childNode)) {\r\n parseNodeTree(childNode, container, root);\r\n }\r\n }\r\n }\r\n }\r\n };\r\n var createContainer = function (element) {\r\n if (isImageElement(element)) {\r\n return new ImageElementContainer(element);\r\n }\r\n if (isCanvasElement(element)) {\r\n return new CanvasElementContainer(element);\r\n }\r\n if (isSVGElement(element)) {\r\n return new SVGElementContainer(element);\r\n }\r\n if (isLIElement(element)) {\r\n return new LIElementContainer(element);\r\n }\r\n if (isOLElement(element)) {\r\n return new OLElementContainer(element);\r\n }\r\n if (isInputElement(element)) {\r\n return new InputElementContainer(element);\r\n }\r\n if (isSelectElement(element)) {\r\n return new SelectElementContainer(element);\r\n }\r\n if (isTextareaElement(element)) {\r\n return new TextareaElementContainer(element);\r\n }\r\n if (isIFrameElement(element)) {\r\n return new IFrameElementContainer(element);\r\n }\r\n return new ElementContainer(element);\r\n };\r\n var parseTree = function (element) {\r\n var container = createContainer(element);\r\n container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;\r\n parseNodeTree(element, container, container);\r\n return container;\r\n };\r\n var createsRealStackingContext = function (node, container, root) {\r\n return (container.styles.isPositionedWithZIndex() ||\r\n container.styles.opacity < 1 ||\r\n container.styles.isTransformed() ||\r\n (isBodyElement(node) && root.styles.isTransparent()));\r\n };\r\n var createsStackingContext = function (styles) { return styles.isPositioned() || styles.isFloating(); };\r\n var isTextNode = function (node) { return node.nodeType === Node.TEXT_NODE; };\r\n var isElementNode = function (node) { return node.nodeType === Node.ELEMENT_NODE; };\r\n var isHTMLElementNode = function (node) {\r\n return isElementNode(node) && typeof node.style !== 'undefined' && !isSVGElementNode(node);\r\n };\r\n var isSVGElementNode = function (element) {\r\n return typeof element.className === 'object';\r\n };\r\n var isLIElement = function (node) { return node.tagName === 'LI'; };\r\n var isOLElement = function (node) { return node.tagName === 'OL'; };\r\n var isInputElement = function (node) { return node.tagName === 'INPUT'; };\r\n var isHTMLElement = function (node) { return node.tagName === 'HTML'; };\r\n var isSVGElement = function (node) { return node.tagName === 'svg'; };\r\n var isBodyElement = function (node) { return node.tagName === 'BODY'; };\r\n var isCanvasElement = function (node) { return node.tagName === 'CANVAS'; };\r\n var isImageElement = function (node) { return node.tagName === 'IMG'; };\r\n var isIFrameElement = function (node) { return node.tagName === 'IFRAME'; };\r\n var isStyleElement = function (node) { return node.tagName === 'STYLE'; };\r\n var isScriptElement = function (node) { return node.tagName === 'SCRIPT'; };\r\n var isTextareaElement = function (node) { return node.tagName === 'TEXTAREA'; };\r\n var isSelectElement = function (node) { return node.tagName === 'SELECT'; };\n\n var CounterState = /** @class */ (function () {\r\n function CounterState() {\r\n this.counters = {};\r\n }\r\n CounterState.prototype.getCounterValue = function (name) {\r\n var counter = this.counters[name];\r\n if (counter && counter.length) {\r\n return counter[counter.length - 1];\r\n }\r\n return 1;\r\n };\r\n CounterState.prototype.getCounterValues = function (name) {\r\n var counter = this.counters[name];\r\n return counter ? counter : [];\r\n };\r\n CounterState.prototype.pop = function (counters) {\r\n var _this = this;\r\n counters.forEach(function (counter) { return _this.counters[counter].pop(); });\r\n };\r\n CounterState.prototype.parse = function (style) {\r\n var _this = this;\r\n var counterIncrement = style.counterIncrement;\r\n var counterReset = style.counterReset;\r\n var canReset = true;\r\n if (counterIncrement !== null) {\r\n counterIncrement.forEach(function (entry) {\r\n var counter = _this.counters[entry.counter];\r\n if (counter && entry.increment !== 0) {\r\n canReset = false;\r\n counter[Math.max(0, counter.length - 1)] += entry.increment;\r\n }\r\n });\r\n }\r\n var counterNames = [];\r\n if (canReset) {\r\n counterReset.forEach(function (entry) {\r\n var counter = _this.counters[entry.counter];\r\n counterNames.push(entry.counter);\r\n if (!counter) {\r\n counter = _this.counters[entry.counter] = [];\r\n }\r\n counter.push(entry.reset);\r\n });\r\n }\r\n return counterNames;\r\n };\r\n return CounterState;\r\n }());\r\n var ROMAN_UPPER = {\r\n integers: [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1],\r\n values: ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']\r\n };\r\n var ARMENIAN = {\r\n integers: [\r\n 9000,\r\n 8000,\r\n 7000,\r\n 6000,\r\n 5000,\r\n 4000,\r\n 3000,\r\n 2000,\r\n 1000,\r\n 900,\r\n 800,\r\n 700,\r\n 600,\r\n 500,\r\n 400,\r\n 300,\r\n 200,\r\n 100,\r\n 90,\r\n 80,\r\n 70,\r\n 60,\r\n 50,\r\n 40,\r\n 30,\r\n 20,\r\n 10,\r\n 9,\r\n 8,\r\n 7,\r\n 6,\r\n 5,\r\n 4,\r\n 3,\r\n 2,\r\n 1\r\n ],\r\n values: [\r\n 'Ք',\r\n 'Փ',\r\n 'Ւ',\r\n 'Ց',\r\n 'Ր',\r\n 'Տ',\r\n 'Վ',\r\n 'Ս',\r\n 'Ռ',\r\n 'Ջ',\r\n 'Պ',\r\n 'Չ',\r\n 'Ո',\r\n 'Շ',\r\n 'Ն',\r\n 'Յ',\r\n 'Մ',\r\n 'Ճ',\r\n 'Ղ',\r\n 'Ձ',\r\n 'Հ',\r\n 'Կ',\r\n 'Ծ',\r\n 'Խ',\r\n 'Լ',\r\n 'Ի',\r\n 'Ժ',\r\n 'Թ',\r\n 'Ը',\r\n 'Է',\r\n 'Զ',\r\n 'Ե',\r\n 'Դ',\r\n 'Գ',\r\n 'Բ',\r\n 'Ա'\r\n ]\r\n };\r\n var HEBREW = {\r\n integers: [\r\n 10000,\r\n 9000,\r\n 8000,\r\n 7000,\r\n 6000,\r\n 5000,\r\n 4000,\r\n 3000,\r\n 2000,\r\n 1000,\r\n 400,\r\n 300,\r\n 200,\r\n 100,\r\n 90,\r\n 80,\r\n 70,\r\n 60,\r\n 50,\r\n 40,\r\n 30,\r\n 20,\r\n 19,\r\n 18,\r\n 17,\r\n 16,\r\n 15,\r\n 10,\r\n 9,\r\n 8,\r\n 7,\r\n 6,\r\n 5,\r\n 4,\r\n 3,\r\n 2,\r\n 1\r\n ],\r\n values: [\r\n 'י׳',\r\n 'ט׳',\r\n 'ח׳',\r\n 'ז׳',\r\n 'ו׳',\r\n 'ה׳',\r\n 'ד׳',\r\n 'ג׳',\r\n 'ב׳',\r\n 'א׳',\r\n 'ת',\r\n 'ש',\r\n 'ר',\r\n 'ק',\r\n 'צ',\r\n 'פ',\r\n 'ע',\r\n 'ס',\r\n 'נ',\r\n 'מ',\r\n 'ל',\r\n 'כ',\r\n 'יט',\r\n 'יח',\r\n 'יז',\r\n 'טז',\r\n 'טו',\r\n 'י',\r\n 'ט',\r\n 'ח',\r\n 'ז',\r\n 'ו',\r\n 'ה',\r\n 'ד',\r\n 'ג',\r\n 'ב',\r\n 'א'\r\n ]\r\n };\r\n var GEORGIAN = {\r\n integers: [\r\n 10000,\r\n 9000,\r\n 8000,\r\n 7000,\r\n 6000,\r\n 5000,\r\n 4000,\r\n 3000,\r\n 2000,\r\n 1000,\r\n 900,\r\n 800,\r\n 700,\r\n 600,\r\n 500,\r\n 400,\r\n 300,\r\n 200,\r\n 100,\r\n 90,\r\n 80,\r\n 70,\r\n 60,\r\n 50,\r\n 40,\r\n 30,\r\n 20,\r\n 10,\r\n 9,\r\n 8,\r\n 7,\r\n 6,\r\n 5,\r\n 4,\r\n 3,\r\n 2,\r\n 1\r\n ],\r\n values: [\r\n 'ჵ',\r\n 'ჰ',\r\n 'ჯ',\r\n 'ჴ',\r\n 'ხ',\r\n 'ჭ',\r\n 'წ',\r\n 'ძ',\r\n 'ც',\r\n 'ჩ',\r\n 'შ',\r\n 'ყ',\r\n 'ღ',\r\n 'ქ',\r\n 'ფ',\r\n 'ჳ',\r\n 'ტ',\r\n 'ს',\r\n 'რ',\r\n 'ჟ',\r\n 'პ',\r\n 'ო',\r\n 'ჲ',\r\n 'ნ',\r\n 'მ',\r\n 'ლ',\r\n 'კ',\r\n 'ი',\r\n 'თ',\r\n 'ჱ',\r\n 'ზ',\r\n 'ვ',\r\n 'ე',\r\n 'დ',\r\n 'გ',\r\n 'ბ',\r\n 'ა'\r\n ]\r\n };\r\n var createAdditiveCounter = function (value, min, max, symbols, fallback, suffix) {\r\n if (value < min || value > max) {\r\n return createCounterText(value, fallback, suffix.length > 0);\r\n }\r\n return (symbols.integers.reduce(function (string, integer, index) {\r\n while (value >= integer) {\r\n value -= integer;\r\n string += symbols.values[index];\r\n }\r\n return string;\r\n }, '') + suffix);\r\n };\r\n var createCounterStyleWithSymbolResolver = function (value, codePointRangeLength, isNumeric, resolver) {\r\n var string = '';\r\n do {\r\n if (!isNumeric) {\r\n value--;\r\n }\r\n string = resolver(value) + string;\r\n value /= codePointRangeLength;\r\n } while (value * codePointRangeLength >= codePointRangeLength);\r\n return string;\r\n };\r\n var createCounterStyleFromRange = function (value, codePointRangeStart, codePointRangeEnd, isNumeric, suffix) {\r\n var codePointRangeLength = codePointRangeEnd - codePointRangeStart + 1;\r\n return ((value < 0 ? '-' : '') +\r\n (createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, isNumeric, function (codePoint) {\r\n return fromCodePoint(Math.floor(codePoint % codePointRangeLength) + codePointRangeStart);\r\n }) +\r\n suffix));\r\n };\r\n var createCounterStyleFromSymbols = function (value, symbols, suffix) {\r\n if (suffix === void 0) { suffix = '. '; }\r\n var codePointRangeLength = symbols.length;\r\n return (createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, false, function (codePoint) { return symbols[Math.floor(codePoint % codePointRangeLength)]; }) + suffix);\r\n };\r\n var CJK_ZEROS = 1 << 0;\r\n var CJK_TEN_COEFFICIENTS = 1 << 1;\r\n var CJK_TEN_HIGH_COEFFICIENTS = 1 << 2;\r\n var CJK_HUNDRED_COEFFICIENTS = 1 << 3;\r\n var createCJKCounter = function (value, numbers, multipliers, negativeSign, suffix, flags) {\r\n if (value < -9999 || value > 9999) {\r\n return createCounterText(value, LIST_STYLE_TYPE.CJK_DECIMAL, suffix.length > 0);\r\n }\r\n var tmp = Math.abs(value);\r\n var string = suffix;\r\n if (tmp === 0) {\r\n return numbers[0] + string;\r\n }\r\n for (var digit = 0; tmp > 0 && digit <= 4; digit++) {\r\n var coefficient = tmp % 10;\r\n if (coefficient === 0 && contains(flags, CJK_ZEROS) && string !== '') {\r\n string = numbers[coefficient] + string;\r\n }\r\n else if (coefficient > 1 ||\r\n (coefficient === 1 && digit === 0) ||\r\n (coefficient === 1 && digit === 1 && contains(flags, CJK_TEN_COEFFICIENTS)) ||\r\n (coefficient === 1 && digit === 1 && contains(flags, CJK_TEN_HIGH_COEFFICIENTS) && value > 100) ||\r\n (coefficient === 1 && digit > 1 && contains(flags, CJK_HUNDRED_COEFFICIENTS))) {\r\n string = numbers[coefficient] + (digit > 0 ? multipliers[digit - 1] : '') + string;\r\n }\r\n else if (coefficient === 1 && digit > 0) {\r\n string = multipliers[digit - 1] + string;\r\n }\r\n tmp = Math.floor(tmp / 10);\r\n }\r\n return (value < 0 ? negativeSign : '') + string;\r\n };\r\n var CHINESE_INFORMAL_MULTIPLIERS = '十百千萬';\r\n var CHINESE_FORMAL_MULTIPLIERS = '拾佰仟萬';\r\n var JAPANESE_NEGATIVE = 'マイナス';\r\n var KOREAN_NEGATIVE = '마이너스';\r\n var createCounterText = function (value, type, appendSuffix) {\r\n var defaultSuffix = appendSuffix ? '. ' : '';\r\n var cjkSuffix = appendSuffix ? '、' : '';\r\n var koreanSuffix = appendSuffix ? ', ' : '';\r\n var spaceSuffix = appendSuffix ? ' ' : '';\r\n switch (type) {\r\n case LIST_STYLE_TYPE.DISC:\r\n return '•' + spaceSuffix;\r\n case LIST_STYLE_TYPE.CIRCLE:\r\n return '◦' + spaceSuffix;\r\n case LIST_STYLE_TYPE.SQUARE:\r\n return '◾' + spaceSuffix;\r\n case LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO:\r\n var string = createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);\r\n return string.length < 4 ? \"0\" + string : string;\r\n case LIST_STYLE_TYPE.CJK_DECIMAL:\r\n return createCounterStyleFromSymbols(value, '〇一二三四五六七八九', cjkSuffix);\r\n case LIST_STYLE_TYPE.LOWER_ROMAN:\r\n return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, LIST_STYLE_TYPE.DECIMAL, defaultSuffix).toLowerCase();\r\n case LIST_STYLE_TYPE.UPPER_ROMAN:\r\n return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);\r\n case LIST_STYLE_TYPE.LOWER_GREEK:\r\n return createCounterStyleFromRange(value, 945, 969, false, defaultSuffix);\r\n case LIST_STYLE_TYPE.LOWER_ALPHA:\r\n return createCounterStyleFromRange(value, 97, 122, false, defaultSuffix);\r\n case LIST_STYLE_TYPE.UPPER_ALPHA:\r\n return createCounterStyleFromRange(value, 65, 90, false, defaultSuffix);\r\n case LIST_STYLE_TYPE.ARABIC_INDIC:\r\n return createCounterStyleFromRange(value, 1632, 1641, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.ARMENIAN:\r\n case LIST_STYLE_TYPE.UPPER_ARMENIAN:\r\n return createAdditiveCounter(value, 1, 9999, ARMENIAN, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);\r\n case LIST_STYLE_TYPE.LOWER_ARMENIAN:\r\n return createAdditiveCounter(value, 1, 9999, ARMENIAN, LIST_STYLE_TYPE.DECIMAL, defaultSuffix).toLowerCase();\r\n case LIST_STYLE_TYPE.BENGALI:\r\n return createCounterStyleFromRange(value, 2534, 2543, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.CAMBODIAN:\r\n case LIST_STYLE_TYPE.KHMER:\r\n return createCounterStyleFromRange(value, 6112, 6121, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH:\r\n return createCounterStyleFromSymbols(value, '子丑寅卯辰巳午未申酉戌亥', cjkSuffix);\r\n case LIST_STYLE_TYPE.CJK_HEAVENLY_STEM:\r\n return createCounterStyleFromSymbols(value, '甲乙丙丁戊己庚辛壬癸', cjkSuffix);\r\n case LIST_STYLE_TYPE.CJK_IDEOGRAPHIC:\r\n case LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL:\r\n return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);\r\n case LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL:\r\n return createCJKCounter(value, '零壹貳參肆伍陸柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);\r\n case LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL:\r\n return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);\r\n case LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL:\r\n return createCJKCounter(value, '零壹贰叁肆伍陆柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);\r\n case LIST_STYLE_TYPE.JAPANESE_INFORMAL:\r\n return createCJKCounter(value, '〇一二三四五六七八九', '十百千万', JAPANESE_NEGATIVE, cjkSuffix, 0);\r\n case LIST_STYLE_TYPE.JAPANESE_FORMAL:\r\n return createCJKCounter(value, '零壱弐参四伍六七八九', '拾百千万', JAPANESE_NEGATIVE, cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);\r\n case LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL:\r\n return createCJKCounter(value, '영일이삼사오육칠팔구', '십백천만', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);\r\n case LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL:\r\n return createCJKCounter(value, '零一二三四五六七八九', '十百千萬', KOREAN_NEGATIVE, koreanSuffix, 0);\r\n case LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL:\r\n return createCJKCounter(value, '零壹貳參四五六七八九', '拾百千', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);\r\n case LIST_STYLE_TYPE.DEVANAGARI:\r\n return createCounterStyleFromRange(value, 0x966, 0x96f, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.GEORGIAN:\r\n return createAdditiveCounter(value, 1, 19999, GEORGIAN, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);\r\n case LIST_STYLE_TYPE.GUJARATI:\r\n return createCounterStyleFromRange(value, 0xae6, 0xaef, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.GURMUKHI:\r\n return createCounterStyleFromRange(value, 0xa66, 0xa6f, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.HEBREW:\r\n return createAdditiveCounter(value, 1, 10999, HEBREW, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);\r\n case LIST_STYLE_TYPE.HIRAGANA:\r\n return createCounterStyleFromSymbols(value, 'あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん');\r\n case LIST_STYLE_TYPE.HIRAGANA_IROHA:\r\n return createCounterStyleFromSymbols(value, 'いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす');\r\n case LIST_STYLE_TYPE.KANNADA:\r\n return createCounterStyleFromRange(value, 0xce6, 0xcef, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.KATAKANA:\r\n return createCounterStyleFromSymbols(value, 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン', cjkSuffix);\r\n case LIST_STYLE_TYPE.KATAKANA_IROHA:\r\n return createCounterStyleFromSymbols(value, 'イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス', cjkSuffix);\r\n case LIST_STYLE_TYPE.LAO:\r\n return createCounterStyleFromRange(value, 0xed0, 0xed9, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.MONGOLIAN:\r\n return createCounterStyleFromRange(value, 0x1810, 0x1819, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.MYANMAR:\r\n return createCounterStyleFromRange(value, 0x1040, 0x1049, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.ORIYA:\r\n return createCounterStyleFromRange(value, 0xb66, 0xb6f, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.PERSIAN:\r\n return createCounterStyleFromRange(value, 0x6f0, 0x6f9, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.TAMIL:\r\n return createCounterStyleFromRange(value, 0xbe6, 0xbef, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.TELUGU:\r\n return createCounterStyleFromRange(value, 0xc66, 0xc6f, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.THAI:\r\n return createCounterStyleFromRange(value, 0xe50, 0xe59, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.TIBETAN:\r\n return createCounterStyleFromRange(value, 0xf20, 0xf29, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.DECIMAL:\r\n default:\r\n return createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);\r\n }\r\n };\n\n var IGNORE_ATTRIBUTE = 'data-html2canvas-ignore';\r\n var DocumentCloner = /** @class */ (function () {\r\n function DocumentCloner(element, options) {\r\n this.options = options;\r\n this.scrolledElements = [];\r\n this.referenceElement = element;\r\n this.counters = new CounterState();\r\n this.quoteDepth = 0;\r\n if (!element.ownerDocument) {\r\n throw new Error('Cloned element does not have an owner document');\r\n }\r\n this.documentElement = this.cloneNode(element.ownerDocument.documentElement);\r\n }\r\n DocumentCloner.prototype.toIFrame = function (ownerDocument, windowSize) {\r\n var _this = this;\r\n var iframe = createIFrameContainer(ownerDocument, windowSize);\r\n if (!iframe.contentWindow) {\r\n return Promise.reject(\"Unable to find iframe window\");\r\n }\r\n var scrollX = ownerDocument.defaultView.pageXOffset;\r\n var scrollY = ownerDocument.defaultView.pageYOffset;\r\n var cloneWindow = iframe.contentWindow;\r\n var documentClone = cloneWindow.document;\r\n /* Chrome doesn't detect relative background-images assigned in inline