ed-frame-vue
Version:
easydata 基础组件
1,572 lines (1,281 loc) • 349 kB
JavaScript
((typeof self !== 'undefined' ? self : this)["webpackJsonped_frame_vue"] = (typeof self !== 'undefined' ? self : this)["webpackJsonped_frame_vue"] || []).push([[1],{
/***/ "01b4":
/***/ (function(module, exports) {
var Queue = function () {
this.head = null;
this.tail = null;
};
Queue.prototype = {
add: function (item) {
var entry = { item: item, next: null };
var tail = this.tail;
if (tail) tail.next = entry;
else this.head = entry;
this.tail = entry;
},
get: function () {
var entry = this.head;
if (entry) {
var next = this.head = entry.next;
if (next === null) this.tail = null;
return entry.item;
}
}
};
module.exports = Queue;
/***/ }),
/***/ "0366":
/***/ (function(module, exports, __webpack_require__) {
var uncurryThis = __webpack_require__("4625");
var aCallable = __webpack_require__("59ed");
var NATIVE_BIND = __webpack_require__("40d5");
var bind = uncurryThis(uncurryThis.bind);
// optional / simple context binding
module.exports = function (fn, that) {
aCallable(fn);
return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) {
return fn.apply(that, arguments);
};
};
/***/ }),
/***/ "0cb2":
/***/ (function(module, exports, __webpack_require__) {
var uncurryThis = __webpack_require__("e330");
var toObject = __webpack_require__("7b0b");
var floor = Math.floor;
var charAt = uncurryThis(''.charAt);
var replace = uncurryThis(''.replace);
var stringSlice = uncurryThis(''.slice);
// eslint-disable-next-line redos/no-vulnerable -- safe
var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g;
var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g;
// `GetSubstitution` abstract operation
// https://tc39.es/ecma262/#sec-getsubstitution
module.exports = function (matched, str, position, captures, namedCaptures, replacement) {
var tailPos = position + matched.length;
var m = captures.length;
var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
if (namedCaptures !== undefined) {
namedCaptures = toObject(namedCaptures);
symbols = SUBSTITUTION_SYMBOLS;
}
return replace(replacement, symbols, function (match, ch) {
var capture;
switch (charAt(ch, 0)) {
case '$': return '$';
case '&': return matched;
case '`': return stringSlice(str, 0, position);
case "'": return stringSlice(str, tailPos);
case '<':
capture = namedCaptures[stringSlice(ch, 1, -1)];
break;
default: // \d\d?
var n = +ch;
if (n === 0) return match;
if (n > m) {
var f = floor(n / 10);
if (f === 0) return match;
if (f <= m) return captures[f - 1] === undefined ? charAt(ch, 1) : captures[f - 1] + charAt(ch, 1);
return match;
}
capture = captures[n - 1];
}
return capture === undefined ? '' : capture;
});
};
/***/ }),
/***/ "0d73":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* WEBPACK VAR INJECTION */(function(process) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AElement", function() { return AElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimateColorElement", function() { return AnimateColorElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimateElement", function() { return AnimateElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimateTransformElement", function() { return AnimateTransformElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CB1", function() { return CB1; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CB2", function() { return CB2; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CB3", function() { return CB3; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CB4", function() { return CB4; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Canvg", function() { return Canvg; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleElement", function() { return CircleElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipPathElement", function() { return ClipPathElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefsElement", function() { return DefsElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DescElement", function() { return DescElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Document", function() { return Document; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Element", function() { return Element; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EllipseElement", function() { return EllipseElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FeColorMatrixElement", function() { return FeColorMatrixElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FeCompositeElement", function() { return FeCompositeElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FeDropShadowElement", function() { return FeDropShadowElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FeGaussianBlurElement", function() { return FeGaussianBlurElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FeMorphologyElement", function() { return FeMorphologyElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterElement", function() { return FilterElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Font", function() { return Font; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FontElement", function() { return FontElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FontFaceElement", function() { return FontFaceElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GElement", function() { return GElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlyphElement", function() { return GlyphElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GradientElement", function() { return GradientElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageElement", function() { return ImageElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineElement", function() { return LineElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinearGradientElement", function() { return LinearGradientElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkerElement", function() { return MarkerElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaskElement", function() { return MaskElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MissingGlyphElement", function() { return MissingGlyphElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mouse", function() { return Mouse; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PSEUDO_ZERO", function() { return PSEUDO_ZERO; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Parser", function() { return Parser; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PathElement", function() { return PathElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PathParser", function() { return PathParser; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PatternElement", function() { return PatternElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Point", function() { return Point; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonElement", function() { return PolygonElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolylineElement", function() { return PolylineElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Property", function() { return Property; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QB1", function() { return QB1; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QB2", function() { return QB2; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QB3", function() { return QB3; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadialGradientElement", function() { return RadialGradientElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RectElement", function() { return RectElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderedElement", function() { return RenderedElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rotate", function() { return Rotate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SVGElement", function() { return SVGElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SVGFontLoader", function() { return SVGFontLoader; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scale", function() { return Scale; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Screen", function() { return Screen; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skew", function() { return Skew; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkewX", function() { return SkewX; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkewY", function() { return SkewY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopElement", function() { return StopElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StyleElement", function() { return StyleElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolElement", function() { return SymbolElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TRefElement", function() { return TRefElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TSpanElement", function() { return TSpanElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextElement", function() { return TextElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextPathElement", function() { return TextPathElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TitleElement", function() { return TitleElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Transform", function() { return Transform; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Translate", function() { return Translate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UnknownElement", function() { return UnknownElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UseElement", function() { return UseElement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViewPort", function() { return ViewPort; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "compressSpaces", function() { return compressSpaces; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Canvg; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getSelectorSpecificity", function() { return getSelectorSpecificity; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalizeAttributeName", function() { return normalizeAttributeName; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalizeColor", function() { return normalizeColor; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseExternalUrl", function() { return parseExternalUrl; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "presets", function() { return index; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toNumbers", function() { return toNumbers; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "trimLeft", function() { return trimLeft; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "trimRight", function() { return trimRight; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vectorMagnitude", function() { return vectorMagnitude; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vectorsAngle", function() { return vectorsAngle; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vectorsRatio", function() { return vectorsRatio; });
/* harmony import */ var core_js_modules_es_promise_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("e6cf");
/* harmony import */ var core_js_modules_es_promise_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_promise_js__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("c973");
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var core_js_modules_es_string_match_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("466d");
/* harmony import */ var core_js_modules_es_string_match_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_match_js__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("5319");
/* harmony import */ var core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var core_js_modules_es_string_starts_with_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("2ca0");
/* harmony import */ var core_js_modules_es_string_starts_with_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_starts_with_js__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("e260");
/* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("ddb0");
/* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__("9523");
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7__);
/* harmony import */ var core_js_modules_es_array_reduce_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__("13d5");
/* harmony import */ var core_js_modules_es_array_reduce_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_reduce_js__WEBPACK_IMPORTED_MODULE_8__);
/* harmony import */ var core_js_modules_es_string_ends_with_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__("8a79");
/* harmony import */ var core_js_modules_es_string_ends_with_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_ends_with_js__WEBPACK_IMPORTED_MODULE_9__);
/* harmony import */ var core_js_modules_es_string_split_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__("1276");
/* harmony import */ var core_js_modules_es_string_split_js__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_split_js__WEBPACK_IMPORTED_MODULE_10__);
/* harmony import */ var raf__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__("c449");
/* harmony import */ var raf__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(raf__WEBPACK_IMPORTED_MODULE_11__);
/* harmony import */ var core_js_modules_es_string_trim_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__("498a");
/* harmony import */ var core_js_modules_es_string_trim_js__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_trim_js__WEBPACK_IMPORTED_MODULE_12__);
/* harmony import */ var rgbcolor__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__("58e1");
/* harmony import */ var rgbcolor__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(rgbcolor__WEBPACK_IMPORTED_MODULE_13__);
/* harmony import */ var core_js_modules_es_array_index_of_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__("c975");
/* harmony import */ var core_js_modules_es_array_index_of_js__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_index_of_js__WEBPACK_IMPORTED_MODULE_14__);
/* harmony import */ var core_js_modules_es_string_includes_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__("2532");
/* harmony import */ var core_js_modules_es_string_includes_js__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_includes_js__WEBPACK_IMPORTED_MODULE_15__);
/* harmony import */ var core_js_modules_es_array_reverse_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__("26e9");
/* harmony import */ var core_js_modules_es_array_reverse_js__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_reverse_js__WEBPACK_IMPORTED_MODULE_16__);
/* harmony import */ var svg_pathdata__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__("d01f");
/* harmony import */ var core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__("25f0");
/* harmony import */ var core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_18___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_18__);
/* harmony import */ var stackblur_canvas__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__("5e9e");
/**
* Options preset for `OffscreenCanvas`.
* @param config - Preset requirements.
* @param config.DOMParser - XML/HTML parser from string into DOM Document.
* @returns Preset object.
*/
function offscreen() {
var {
DOMParser: DOMParserFallback
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var preset = {
window: null,
ignoreAnimation: true,
ignoreMouse: true,
DOMParser: DOMParserFallback,
createCanvas(width, height) {
return new OffscreenCanvas(width, height);
},
createImage(url) {
return _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(function* () {
var response = yield fetch(url);
var blob = yield response.blob();
var img = yield createImageBitmap(blob);
return img;
})();
}
};
if (typeof DOMParser !== 'undefined' || typeof DOMParserFallback === 'undefined') {
Reflect.deleteProperty(preset, 'DOMParser');
}
return preset;
}
/**
* Options preset for `node-canvas`.
* @param config - Preset requirements.
* @param config.DOMParser - XML/HTML parser from string into DOM Document.
* @param config.canvas - `node-canvas` exports.
* @param config.fetch - WHATWG-compatible `fetch` function.
* @returns Preset object.
*/
function node(_ref) {
var {
DOMParser,
canvas,
fetch
} = _ref;
return {
window: null,
ignoreAnimation: true,
ignoreMouse: true,
DOMParser,
fetch,
createCanvas: canvas.createCanvas,
createImage: canvas.loadImage
};
}
var index = /*#__PURE__*/Object.freeze({
__proto__: null,
offscreen: offscreen,
node: node
});
/**
* HTML-safe compress white-spaces.
* @param str - String to compress.
* @returns String.
*/
function compressSpaces(str) {
return str.replace(/(?!\u3000)\s+/gm, ' ');
}
/**
* HTML-safe left trim.
* @param str - String to trim.
* @returns String.
*/
function trimLeft(str) {
return str.replace(/^[\n \t]+/, '');
}
/**
* HTML-safe right trim.
* @param str - String to trim.
* @returns String.
*/
function trimRight(str) {
return str.replace(/[\n \t]+$/, '');
}
/**
* String to numbers array.
* @param str - Numbers string.
* @returns Numbers array.
*/
function toNumbers(str) {
var matches = (str || '').match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm) || [];
return matches.map(parseFloat);
} // Microsoft Edge fix
var allUppercase = /^[A-Z-]+$/;
/**
* Normalize attribute name.
* @param name - Attribute name.
* @returns Normalized attribute name.
*/
function normalizeAttributeName(name) {
if (allUppercase.test(name)) {
return name.toLowerCase();
}
return name;
}
/**
* Parse external URL.
* @param url - CSS url string.
* @returns Parsed URL.
*/
function parseExternalUrl(url) {
// single quotes [2]
// v double quotes [3]
// v v no quotes [4]
// v v v
var urlMatch = /url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(url) || [];
return urlMatch[2] || urlMatch[3] || urlMatch[4];
}
/**
* Transform floats to integers in rgb colors.
* @param color - Color to normalize.
* @returns Normalized color.
*/
function normalizeColor(color) {
if (!color.startsWith('rgb')) {
return color;
}
var rgbParts = 3;
var normalizedColor = color.replace(/\d+(\.\d+)?/g, (num, isFloat) => rgbParts-- && isFloat ? String(Math.round(parseFloat(num))) : num);
return normalizedColor;
}
// slightly modified version of https://github.com/keeganstreet/specificity/blob/master/specificity.js
var attributeRegex = /(\[[^\]]+\])/g;
var idRegex = /(#[^\s+>~.[:]+)/g;
var classRegex = /(\.[^\s+>~.[:]+)/g;
var pseudoElementRegex = /(::[^\s+>~.[:]+|:first-line|:first-letter|:before|:after)/gi;
var pseudoClassWithBracketsRegex = /(:[\w-]+\([^)]*\))/gi;
var pseudoClassRegex = /(:[^\s+>~.[:]+)/g;
var elementRegex = /([^\s+>~.[:]+)/g;
function findSelectorMatch(selector, regex) {
var matches = regex.exec(selector);
if (!matches) {
return [selector, 0];
}
return [selector.replace(regex, ' '), matches.length];
}
/**
* Measure selector specificity.
* @param selector - Selector to measure.
* @returns Specificity.
*/
function getSelectorSpecificity(selector) {
var specificity = [0, 0, 0];
var currentSelector = selector.replace(/:not\(([^)]*)\)/g, ' $1 ').replace(/{[\s\S]*/gm, ' ');
var delta = 0;
[currentSelector, delta] = findSelectorMatch(currentSelector, attributeRegex);
specificity[1] += delta;
[currentSelector, delta] = findSelectorMatch(currentSelector, idRegex);
specificity[0] += delta;
[currentSelector, delta] = findSelectorMatch(currentSelector, classRegex);
specificity[1] += delta;
[currentSelector, delta] = findSelectorMatch(currentSelector, pseudoElementRegex);
specificity[2] += delta;
[currentSelector, delta] = findSelectorMatch(currentSelector, pseudoClassWithBracketsRegex);
specificity[1] += delta;
[currentSelector, delta] = findSelectorMatch(currentSelector, pseudoClassRegex);
specificity[1] += delta;
currentSelector = currentSelector.replace(/[*\s+>~]/g, ' ').replace(/[#.]/g, ' ');
[currentSelector, delta] = findSelectorMatch(currentSelector, elementRegex); // lgtm [js/useless-assignment-to-local]
specificity[2] += delta;
return specificity.join('');
}
var PSEUDO_ZERO = .00000001;
/**
* Vector magnitude.
* @param v
* @returns Number result.
*/
function vectorMagnitude(v) {
return Math.sqrt(Math.pow(v[0], 2) + Math.pow(v[1], 2));
}
/**
* Ratio between two vectors.
* @param u
* @param v
* @returns Number result.
*/
function vectorsRatio(u, v) {
return (u[0] * v[0] + u[1] * v[1]) / (vectorMagnitude(u) * vectorMagnitude(v));
}
/**
* Angle between two vectors.
* @param u
* @param v
* @returns Number result.
*/
function vectorsAngle(u, v) {
return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vectorsRatio(u, v));
}
function CB1(t) {
return t * t * t;
}
function CB2(t) {
return 3 * t * t * (1 - t);
}
function CB3(t) {
return 3 * t * (1 - t) * (1 - t);
}
function CB4(t) {
return (1 - t) * (1 - t) * (1 - t);
}
function QB1(t) {
return t * t;
}
function QB2(t) {
return 2 * t * (1 - t);
}
function QB3(t) {
return (1 - t) * (1 - t);
}
class Property {
constructor(document, name, value) {
this.document = document;
this.name = name;
this.value = value;
this.isNormalizedColor = false;
}
static empty(document) {
return new Property(document, 'EMPTY', '');
}
split() {
var separator = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
var {
document,
name
} = this;
return compressSpaces(this.getString()).trim().split(separator).map(value => new Property(document, name, value));
}
hasValue(zeroIsValue) {
var {
value
} = this;
return value !== null && value !== '' && (zeroIsValue || value !== 0) && typeof value !== 'undefined';
}
isString(regexp) {
var {
value
} = this;
var result = typeof value === 'string';
if (!result || !regexp) {
return result;
}
return regexp.test(value);
}
isUrlDefinition() {
return this.isString(/^url\(/);
}
isPixels() {
if (!this.hasValue()) {
return false;
}
var asString = this.getString();
switch (true) {
case asString.endsWith('px'):
case /^[0-9]+$/.test(asString):
return true;
default:
return false;
}
}
setValue(value) {
this.value = value;
return this;
}
getValue(def) {
if (typeof def === 'undefined' || this.hasValue()) {
return this.value;
}
return def;
}
getNumber(def) {
if (!this.hasValue()) {
if (typeof def === 'undefined') {
return 0;
}
return parseFloat(def);
}
var {
value
} = this;
var n = parseFloat(value);
if (this.isString(/%$/)) {
n /= 100.0;
}
return n;
}
getString(def) {
if (typeof def === 'undefined' || this.hasValue()) {
return typeof this.value === 'undefined' ? '' : String(this.value);
}
return String(def);
}
getColor(def) {
var color = this.getString(def);
if (this.isNormalizedColor) {
return color;
}
this.isNormalizedColor = true;
color = normalizeColor(color);
this.value = color;
return color;
}
getDpi() {
return 96.0; // TODO: compute?
}
getRem() {
return this.document.rootEmSize;
}
getEm() {
return this.document.emSize;
}
getUnits() {
return this.getString().replace(/[0-9.-]/g, '');
}
getPixels(axisOrIsFontSize) {
var processPercent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
if (!this.hasValue()) {
return 0;
}
var [axis, isFontSize] = typeof axisOrIsFontSize === 'boolean' ? [undefined, axisOrIsFontSize] : [axisOrIsFontSize];
var {
viewPort
} = this.document.screen;
switch (true) {
case this.isString(/vmin$/):
return this.getNumber() / 100.0 * Math.min(viewPort.computeSize('x'), viewPort.computeSize('y'));
case this.isString(/vmax$/):
return this.getNumber() / 100.0 * Math.max(viewPort.computeSize('x'), viewPort.computeSize('y'));
case this.isString(/vw$/):
return this.getNumber() / 100.0 * viewPort.computeSize('x');
case this.isString(/vh$/):
return this.getNumber() / 100.0 * viewPort.computeSize('y');
case this.isString(/rem$/):
return this.getNumber() * this.getRem();
case this.isString(/em$/):
return this.getNumber() * this.getEm();
case this.isString(/ex$/):
return this.getNumber() * this.getEm() / 2.0;
case this.isString(/px$/):
return this.getNumber();
case this.isString(/pt$/):
return this.getNumber() * this.getDpi() * (1.0 / 72.0);
case this.isString(/pc$/):
return this.getNumber() * 15;
case this.isString(/cm$/):
return this.getNumber() * this.getDpi() / 2.54;
case this.isString(/mm$/):
return this.getNumber() * this.getDpi() / 25.4;
case this.isString(/in$/):
return this.getNumber() * this.getDpi();
case this.isString(/%$/) && isFontSize:
return this.getNumber() * this.getEm();
case this.isString(/%$/):
return this.getNumber() * viewPort.computeSize(axis);
default:
{
var n = this.getNumber();
if (processPercent && n < 1.0) {
return n * viewPort.computeSize(axis);
}
return n;
}
}
}
getMilliseconds() {
if (!this.hasValue()) {
return 0;
}
if (this.isString(/ms$/)) {
return this.getNumber();
}
return this.getNumber() * 1000;
}
getRadians() {
if (!this.hasValue()) {
return 0;
}
switch (true) {
case this.isString(/deg$/):
return this.getNumber() * (Math.PI / 180.0);
case this.isString(/grad$/):
return this.getNumber() * (Math.PI / 200.0);
case this.isString(/rad$/):
return this.getNumber();
default:
return this.getNumber() * (Math.PI / 180.0);
}
}
getDefinition() {
var asString = this.getString();
var name = /#([^)'"]+)/.exec(asString);
if (name) {
name = name[1];
}
if (!name) {
name = asString;
}
return this.document.definitions[name];
}
getFillStyleDefinition(element, opacity) {
var def = this.getDefinition();
if (!def) {
return null;
} // gradient
if (typeof def.createGradient === 'function') {
return def.createGradient(this.document.ctx, element, opacity);
} // pattern
if (typeof def.createPattern === 'function') {
if (def.getHrefAttribute().hasValue()) {
var patternTransform = def.getAttribute('patternTransform');
def = def.getHrefAttribute().getDefinition();
if (patternTransform.hasValue()) {
def.getAttribute('patternTransform', true).setValue(patternTransform.value);
}
}
return def.createPattern(this.document.ctx, element, opacity);
}
return null;
}
getTextBaseline() {
if (!this.hasValue()) {
return null;
}
return Property.textBaselineMapping[this.getString()];
}
addOpacity(opacity) {
var value = this.getColor();
var len = value.length;
var commas = 0; // Simulate old RGBColor version, which can't parse rgba.
for (var i = 0; i < len; i++) {
if (value[i] === ',') {
commas++;
}
if (commas === 3) {
break;
}
}
if (opacity.hasValue() && this.isString() && commas !== 3) {
var color = new rgbcolor__WEBPACK_IMPORTED_MODULE_13___default.a(value);
if (color.ok) {
color.alpha = opacity.getNumber();
value = color.toRGBA();
}
}
return new Property(this.document, this.name, value);
}
}
Property.textBaselineMapping = {
'baseline': 'alphabetic',
'before-edge': 'top',
'text-before-edge': 'top',
'middle': 'middle',
'central': 'middle',
'after-edge': 'bottom',
'text-after-edge': 'bottom',
'ideographic': 'ideographic',
'alphabetic': 'alphabetic',
'hanging': 'hanging',
'mathematical': 'alphabetic'
};
class ViewPort {
constructor() {
this.viewPorts = [];
}
clear() {
this.viewPorts = [];
}
setCurrent(width, height) {
this.viewPorts.push({
width,
height
});
}
removeCurrent() {
this.viewPorts.pop();
}
getCurrent() {
var {
viewPorts
} = this;
return viewPorts[viewPorts.length - 1];
}
get width() {
return this.getCurrent().width;
}
get height() {
return this.getCurrent().height;
}
computeSize(d) {
if (typeof d === 'number') {
return d;
}
if (d === 'x') {
return this.width;
}
if (d === 'y') {
return this.height;
}
return Math.sqrt(Math.pow(this.width, 2) + Math.pow(this.height, 2)) / Math.sqrt(2);
}
}
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
static parse(point) {
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var [x = defaultValue, y = defaultValue] = toNumbers(point);
return new Point(x, y);
}
static parseScale(scale) {
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var [x = defaultValue, y = x] = toNumbers(scale);
return new Point(x, y);
}
static parsePath(path) {
var points = toNumbers(path);
var len = points.length;
var pathPoints = [];
for (var i = 0; i < len; i += 2) {
pathPoints.push(new Point(points[i], points[i + 1]));
}
return pathPoints;
}
angleTo(point) {
return Math.atan2(point.y - this.y, point.x - this.x);
}
applyTransform(transform) {
var {
x,
y
} = this;
var xp = x * transform[0] + y * transform[2] + transform[4];
var yp = x * transform[1] + y * transform[3] + transform[5];
this.x = xp;
this.y = yp;
}
}
class Mouse {
constructor(screen) {
this.screen = screen;
this.working = false;
this.events = [];
this.eventElements = []; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
this.onClick = this.onClick.bind(this); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
this.onMouseMove = this.onMouseMove.bind(this);
}
isWorking() {
return this.working;
}
start() {
if (this.working) {
return;
}
var {
screen,
onClick,
onMouseMove
} = this;
var canvas = screen.ctx.canvas;
canvas.onclick = onClick;
canvas.onmousemove = onMouseMove;
this.working = true;
}
stop() {
if (!this.working) {
return;
}
var canvas = this.screen.ctx.canvas;
this.working = false;
canvas.onclick = null;
canvas.onmousemove = null;
}
hasEvents() {
return this.working && this.events.length > 0;
}
runEvents() {
if (!this.working) {
return;
}
var {
screen: document,
events,
eventElements
} = this;
var {
style
} = document.ctx.canvas;
if (style) {
style.cursor = '';
}
events.forEach((_ref, i) => {
var {
run
} = _ref;
var element = eventElements[i];
while (element) {
run(element);
element = element.parent;
}
}); // done running, clear
this.events = [];
this.eventElements = [];
}
checkPath(element, ctx) {
if (!this.working || !ctx) {
return;
}
var {
events,
eventElements
} = this;
events.forEach((_ref2, i) => {
var {
x,
y
} = _ref2;
if (!eventElements[i] && ctx.isPointInPath && ctx.isPointInPath(x, y)) {
eventElements[i] = element;
}
});
}
checkBoundingBox(element, boundingBox) {
if (!this.working || !boundingBox) {
return;
}
var {
events,
eventElements
} = this;
events.forEach((_ref3, i) => {
var {
x,
y
} = _ref3;
if (!eventElements[i] && boundingBox.isPointInBox(x, y)) {
eventElements[i] = element;
}
});
}
mapXY(x, y) {
var {
window,
ctx
} = this.screen;
var point = new Point(x, y);
var element = ctx.canvas;
while (element) {
point.x -= element.offsetLeft;
point.y -= element.offsetTop;
element = element.offsetParent;
}
if (window.scrollX) {
point.x += window.scrollX;
}
if (window.scrollY) {
point.y += window.scrollY;
}
return point;
}
onClick(event) {
var {
x,
y
} = this.mapXY(event.clientX, event.clientY);
this.events.push({
type: 'onclick',
x,
y,
run(eventTarget) {
if (eventTarget.onClick) {
eventTarget.onClick();
}
}
});
}
onMouseMove(event) {
var {
x,
y
} = this.mapXY(event.clientX, event.clientY);
this.events.push({
type: 'onmousemove',
x,
y,
run(eventTarget) {
if (eventTarget.onMouseMove) {
eventTarget.onMouseMove();
}
}
});
}
}
var defaultWindow = typeof window !== 'undefined' ? window : null;
var defaultFetch$1 = typeof fetch !== 'undefined' ? fetch.bind(undefined) // `fetch` depends on context: `someObject.fetch(...)` will throw error.
: null;
class Screen {
constructor(ctx) {
var {
fetch = defaultFetch$1,
window = defaultWindow
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
this.ctx = ctx;
this.FRAMERATE = 30;
this.MAX_VIRTUAL_PIXELS = 30000;
this.CLIENT_WIDTH = 800;
this.CLIENT_HEIGHT = 600;
this.viewPort = new ViewPort();
this.mouse = new Mouse(this);
this.animations = [];
this.waits = [];
this.frameDuration = 0;
this.isReadyLock = false;
this.isFirstRender = true;
this.intervalId = null;
this.window = window;
this.fetch = fetch;
}
wait(checker) {
this.waits.push(checker);
}
ready() {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
if (!this.readyPromise) {
return Promise.resolve();
}
return this.readyPromise;
}
isReady() {
if (this.isReadyLock) {
return true;
}
var isReadyLock = this.waits.every(_ => _());
if (isReadyLock) {
this.waits = [];
if (this.resolveReady) {
this.resolveReady();
}
}
this.isReadyLock = isReadyLock;
return isReadyLock;
}
setDefaults(ctx) {
// initial values and defaults
ctx.strokeStyle = 'rgba(0,0,0,0)';
ctx.lineCap = 'butt';
ctx.lineJoin = 'miter';
ctx.miterLimit = 4;
}
setViewBox(_ref) {
var {
document,
ctx,
aspectRatio,
width,
desiredWidth,
height,
desiredHeight,
minX = 0,
minY = 0,
refX,
refY,
clip = false,
clipX = 0,
clipY = 0
} = _ref;
// aspect ratio - http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute
var cleanAspectRatio = compressSpaces(aspectRatio).replace(/^defer\s/, ''); // ignore defer
var [aspectRatioAlign, aspectRatioMeetOrSlice] = cleanAspectRatio.split(' ');
var align = aspectRatioAlign || 'xMidYMid';
var meetOrSlice = aspectRatioMeetOrSlice || 'meet'; // calculate scale
var scaleX = width / desiredWidth;
var scaleY = height / desiredHeight;
var scaleMin = Math.min(scaleX, scaleY);
var scaleMax = Math.max(scaleX, scaleY);
var finalDesiredWidth = desiredWidth;
var finalDesiredHeight = desiredHeight;
if (meetOrSlice === 'meet') {
finalDesiredWidth *= scaleMin;
finalDesiredHeight *= scaleMin;
}
if (meetOrSlice === 'slice') {
finalDesiredWidth *= scaleMax;
finalDesiredHeight *= scaleMax;
}
var refXProp = new Property(document, 'refX', refX);
var refYProp = new Property(document, 'refY', refY);
var hasRefs = refXProp.hasValue() && refYProp.hasValue();
if (hasRefs) {
ctx.translate(-scaleMin * refXProp.getPixels('x'), -scaleMin * refYProp.getPixels('y'));
}
if (clip) {
var scaledClipX = scaleMin * clipX;
var scaledClipY = scaleMin * clipY;
ctx.beginPath();
ctx.moveTo(scaledClipX, scaledClipY);
ctx.lineTo(width, scaledClipY);
ctx.lineTo(width, height);
ctx.lineTo(scaledClipX, height);
ctx.closePath();
ctx.clip();
}
if (!hasRefs) {
var isMeetMinY = meetOrSlice === 'meet' && scaleMin === scaleY;
var isSliceMaxY = meetOrSlice === 'slice' && scaleMax === scaleY;
var isMeetMinX = meetOrSlice === 'meet' && scaleMin === scaleX;
var isSliceMaxX = meetOrSlice === 'slice' && scaleMax === scaleX;
if (align.startsWith('xMid') && (isMeetMinY || isSliceMaxY)) {
ctx.translate(width / 2.0 - finalDesiredWidth / 2.0, 0);
}
if (align.endsWith('YMid') && (isMeetMinX || isSliceMaxX)) {
ctx.translate(0, height / 2.0 - finalDesiredHeight / 2.0);
}
if (align.startsWith('xMax') && (isMeetMinY || isSliceMaxY)) {
ctx.translate(width - finalDesiredWidth, 0);
}
if (align.endsWith('YMax') && (isMeetMinX || isSliceMaxX)) {
ctx.translate(0, height - finalDesiredHeight);
}
} // scale
switch (true) {
case align === 'none':
ctx.scale(scaleX, scaleY);
break;
case meetOrSlice === 'meet':
ctx.scale(scaleMin, scaleMin);
break;
case meetOrSlice === 'slice':
ctx.scale(scaleMax, scaleMax);
break;
} // translate
ctx.translate(-minX, -minY);
}
start(element) {
var {
enableRedraw = false,
ignoreMouse = false,
ignoreAnimation = false,
ignoreDimensions = false,
ignoreClear = false,
forceRedraw,
scaleWidth,
scaleHeight,
offsetX,
offsetY
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var {
FRAMERATE,
mouse
} = this;
var frameDuration = 1000 / FRAMERATE;
this.frameDuration = frameDuration;
this.readyPromise = new Promise(resolve => {
this.resolveReady = resolve;
});
if (this.isReady()) {
this.render(element, ignoreDimensions, ignoreClear, scaleWidth, scaleHeight, offsetX, offsetY);
}
if (!enableRedraw) {
return;
}
var now = Date.now();
var then = now;
var delta = 0;
var tick = () => {
now = Date.now();
delta = now - then;
if (delta >= frameDuration) {
then = now - delta % frameDuration;
if (this.shouldUpdate(ignoreAnimation, forceRedraw)) {
this.render(element, ignoreDimensions, ignoreClear, scaleWidth, scaleHeight, offsetX, offsetY);
mouse.runEvents();
}
}
this.intervalId = raf__WEBPACK_IMPORTED_MODULE_11___default()(tick);
};
if (!ignoreMouse) {
mouse.start();
}
this.intervalId = raf__WEBPACK_IMPORTED_MODULE_11___default()(tick);
}
stop() {
if (this.intervalId) {
raf__WEBPACK_IMPORTED_MODULE_11___default.a.cancel(this.intervalId);
this.intervalId = null;
}
this.mouse.stop();
}
shouldUpdate(ignoreAnimation, forceRedraw) {
// need update from animations?
if (!ignoreAnimation) {
var {
frameDuration
} = this;
var shouldUpdate = this.animations.reduce((shouldUpdate, animation) => animation.update(frameDuration) || shouldUpdate, false);
if (shouldUpdate) {
return true;
}
} // need update from redraw?
if (typeof forceRedraw === 'function' && forceRedraw()) {
return true;
}
if (!this.isReadyLock && this.isReady()) {
return true;
} // need update from mouse events?
if (this.mouse.hasEvents()) {
return true;
}
return false;
}
render(element, ignoreDimensions, ignoreClear, scaleWidth, scaleHeight, offsetX, offsetY) {
var {
CLIENT_WIDTH,
CLIENT_HEIGHT,
viewPort,
ctx,
isFirstRender
} = this;
var canvas = ctx.canvas;
viewPort.clear();
if (canvas.width && canvas.height) {
viewPort.setCurrent(canvas.width, canvas.height);
} else {
viewPort.setCurrent(CLIENT_WIDTH, CLIENT_HEIGHT);
}
var widthStyle = element.getStyle('width');
var heightStyle = element.getStyle('height');
if (!ignoreDimensions && (isFirstRender || typeof scaleWidth !== 'number' && typeof scaleHeight !== 'number')) {
// set canvas size
if (widthStyle.hasValue()) {
canvas.width = widthStyle.getPixels('x');
if (canvas.style) {
canvas.style.width = "".concat(canvas.width, "px");
}
}
if (heightStyle.hasValue()) {
canvas.height = heightStyle.getPixels('y');
if (canvas.style) {
canvas.style.height = "".concat(canvas.height, "px");
}
}
}
var cWidth = canvas.clientWidth || canvas.width;
var cHeight = canvas.clientHeight || canvas.height;
if (ignoreDimensions && widthStyle.hasValue() && heightStyle.hasValue()) {
cWidth = widthStyle.getPixels('x');
cHeight = heightStyle.getPixels('y');
}
viewPort.setCurrent(cWidth, cHeight);
if (typeof offsetX === 'number') {
element.getAttribute('x', true).setValue(offsetX);
}
if (typeof offsetY === 'number') {
element.getAttribute('y', true).setValue(offsetY);
}
if (typeof scaleWidth === 'number' || typeof scaleHeight === 'number') {
var viewBox = toNumbers(element.getAttribute('viewBox').getString());
var xRatio = 0;
var yRatio = 0;
if (typeof scaleWidth === 'number') {
var _widthStyle = element.getStyle('width');
if (_widthStyle.hasValue()) {
xRatio = _widthStyle.getPixels('x') / scaleWidth;
} else if (!isNaN(viewBox[2])) {
xRatio = viewBox[2] / scaleWidth;
}
}
if (typeof scaleHeight === 'number') {
var _heightStyle = element.getStyle('height');
if (_heightStyle.hasValue()) {
yRatio = _heightStyle.getPixels('y') / scaleHeight;
} else if (!isNaN(viewBox[3])) {
yRatio = viewBox[3] / scaleHeight;
}
}
if (!xRatio) {
xRatio = yRatio;
}
if (!yRatio) {
yRatio = xRatio;
}
element.getAttribute('width', true).setValue(scaleWidth);
element.getAttribute('height', true).setValue(scaleHeight);
var transformStyle = element.getStyle('transform', true, true);
transformStyle.setValue("".concat(transformStyle.getString(), " scale(").concat(1.0 / xRatio, ", ").concat(1.0 / yRatio, ")"));
} // clear and render
if (!ignoreClear) {
ctx.clearRect(0, 0, cWidth, cHeight);
}
element.render(ctx);
if (isFirstRender) {
this.isFirstRender = false;
}
}
}
Screen.defaultWindow = defaultWindow;
Screen.defaultFetch = defaultFetch$1;
var {
defaultFetch
} = Screen;
var DefaultDOMParser = typeof DOMParser !== 'undefined' ? DOMParser : null;
class Parser {
constructor() {
var {
fetch = defaultFetch,
DOMParser = DefaultDOMParser
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
this.fetch = fetch;
this.DOMParser = DOMParser;
}
parse(resource) {
var _this = this;
return _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(function* () {
if (resource.startsWith('<')) {
return _this.parseFromString(resource);
}
return _this.load(resource);
})();
}
parseFromString(xml) {
var parser = new this.DOMParser();
try {
return this.checkDocument(parser.parseFromString(xml, 'image/svg+xml'));
} catch (err) {
return this.checkDocument(parser.parseFromString(xml, 'text/xml'));
}
}
checkDocument(document) {
var parserError = document.getElementsByTagName('parsererror')[0];
if (parserError) {
throw new Error(parserError.textContent);
}
return document;
}
load(url) {
var _this2 = this;
return _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(function* () {
var response = yield _this2.fetch(url);
var xml = yield response.text();
return _this2.parseFromString(xml);
})();
}
}
class Translate {
constructor(_, point) {
this.type = 'translate';
this.point = null;
this.point = Point.parse(point);
}
apply(ctx) {
var {
x,
y
} = this.point;
ctx.t