diff --git a/dist/extensions/imagelib/openclipart.js b/dist/extensions/imagelib/openclipart.js index aabec645..62771217 100644 --- a/dist/extensions/imagelib/openclipart.js +++ b/dist/extensions/imagelib/openclipart.js @@ -574,11 +574,12 @@ 0. Support JsonML empty string element name to represent fragments? 0. Redo browser testing of jml (including ensuring IE7 can work even if test framework can't work) */ + // istanbul ignore next - var win = typeof window !== 'undefined' && window; - var doc = typeof document !== 'undefined' && document; - var XmlSerializer = typeof XMLSerializer !== 'undefined' && XMLSerializer; // STATIC PROPERTIES + var win = typeof window !== 'undefined' && window; // istanbul ignore next + + var doc = typeof document !== 'undefined' && document || win && win.document; // STATIC PROPERTIES var possibleOptions = ['$plugins', // '$mode', // Todo (SVG/XML) // 'state', // Used internally @@ -635,9 +636,12 @@ function _applyAnyStylesheet(node) { + // Only used in IE + // istanbul ignore else if (!doc.createStyleSheet) { return; - } + } // istanbul ignore next + if (_getHTMLNodeName(node) === 'style') { // IE @@ -659,7 +663,9 @@ function _appendNode(parent, child) { var parentName = _getHTMLNodeName(parent); - var childName = _getHTMLNodeName(child); + var childName = _getHTMLNodeName(child); // IE only + // istanbul ignore if + if (doc.createStyleSheet) { if (parentName === 'script') { @@ -682,6 +688,7 @@ try { parent.append(child); // IE9 is now ok with this } catch (e) { + // istanbul ignore next if (parentName === 'select' && childName === 'option') { try { // Since this is now DOM Level 4 standard behavior (and what IE7+ can handle), we try it first @@ -692,7 +699,8 @@ } return; - } + } // istanbul ignore next + throw e; } @@ -722,12 +730,14 @@ function _createSafeReference(type, prefix, arg) { - // For security reasons related to innerHTML, we ensure this string only contains potential entity characters + // For security reasons related to innerHTML, we ensure this string only + // contains potential entity characters if (!arg.match(/^[0-9A-Z_a-z]+$/)) { throw new TypeError('Bad ' + type); } var elContainer = doc.createElement('div'); // Todo: No workaround for XML? + // eslint-disable-next-line no-unsanitized/property elContainer.innerHTML = '&' + prefix + arg + ';'; return doc.createTextNode(elContainer.innerHTML); @@ -757,38 +767,44 @@ * @private * @static * @param {string|JamilihAttributes|JamilihArray|Element|DocumentFragment} item - * @returns {"string"|"null"|"array"|"element"|"fragment"|"object"} + * @returns {"string"|"null"|"array"|"element"|"fragment"|"object"|"symbol"|"function"|"number"|"boolean"} */ function _getType(item) { - if (typeof item === 'string') { - return 'string'; - } + var type = _typeof$1(item); - if (_typeof$1(item) === 'object') { - if (item === null) { - return 'null'; - } - - if (Array.isArray(item)) { - return 'array'; - } - - if ('nodeType' in item) { - if (item.nodeType === 1) { - return 'element'; + switch (type) { + case 'object': + if (item === null) { + return 'null'; } - if (item.nodeType === 11) { - return 'fragment'; + if (Array.isArray(item)) { + return 'array'; } - } - return 'object'; + if ('nodeType' in item) { + switch (item.nodeType) { + case 1: + return 'element'; + + case 9: + return 'document'; + + case 11: + return 'fragment'; + + default: + return 'non-container node'; + } + } + + // Fallthrough + + default: + return type; } - - return undefined; } /** * @private @@ -813,13 +829,15 @@ function _replaceDefiner(xmlnsObj) { return function (n0) { - var retStr = xmlnsObj[''] ? ' xmlns="' + xmlnsObj[''] + '"' : n0 || ''; // Preserve XHTML + var retStr = xmlnsObj[''] ? ' xmlns="' + xmlnsObj[''] + '"' : n0; // Preserve XHTML - for (var ns in xmlnsObj) { - if ({}.hasOwnProperty.call(xmlnsObj, ns)) { - if (ns !== '') { - retStr += ' xmlns:' + ns + '="' + xmlnsObj[ns] + '"'; - } + for (var _i = 0, _Object$entries = Object.entries(xmlnsObj); _i < _Object$entries.length; _i++) { + var _Object$entries$_i = _slicedToArray$1(_Object$entries[_i], 2), + ns = _Object$entries$_i[0], + xmlnsVal = _Object$entries$_i[1]; + + if (ns !== '') { + retStr += ' xmlns:' + ns + '="' + xmlnsVal + '"'; } } @@ -841,42 +859,16 @@ return jml.apply(void 0, _toConsumableArray$1(args[0] === undefined ? args.slice(1) : args)); } /** - * @private - * @static - * @param {string} arg - * @returns {Element} - */ - - - function _jmlSingleArg(arg) { - return jml(arg); - } - /** * @typedef {JamilihAttributes} AttributeArray * @property {string} 0 The key * @property {string} 1 The value */ - /** - * @private - * @static - * @todo Deprecate as now there is predictable iteration order? - * @param {AttributeArray} attArr - * @returns {PlainObject} - */ - - - function _copyOrderedAtts(attArr) { - var obj = {}; // Todo: Fix if allow prefixed attributes - - obj[attArr[0]] = attArr[1]; // array of ordered attribute-value arrays - - return obj; - } /** * @callback ChildrenToJMLCallback * @param {JamilihArray|Jamilih} childNodeJML * @param {Integer} i + * @returns {void} */ /** @@ -941,8 +933,8 @@ * @static */ - /** - * function _DOMfromJMLOrString (childNodeJML) { + /* + function _DOMfromJMLOrString (childNodeJML) { if (typeof childNodeJML === 'string') { return doc.createTextNode(childNodeJML); } @@ -955,7 +947,7 @@ */ /** - * @typedef {PlainObject} JamilihAttributes + * @typedef {PlainObject} JamilihAttributes */ /** @@ -997,14 +989,11 @@ */ function _checkAtts(atts) { - var att; + var _loop = function _loop() { + var _Object$entries2$_i = _slicedToArray$1(_Object$entries2[_i2], 2), + att = _Object$entries2$_i[0], + attVal = _Object$entries2$_i[1]; - for (att in atts) { - if (!{}.hasOwnProperty.call(atts, att)) { - continue; - } - - var attVal = atts[att]; att = att in ATTR_MAP ? ATTR_MAP[att] : att; if (NULLABLES.includes(att)) { @@ -1012,10 +1001,10 @@ elem[att] = attVal; } - continue; + return "continue"; } else if (ATTR_DOM.includes(att)) { elem[att] = attVal; - continue; + return "continue"; } switch (att) { @@ -1081,7 +1070,7 @@ case 'is': { - // Not yet supported in browsers + // Currently only in Chrome // Handled during element creation break; } @@ -1092,113 +1081,136 @@ break; } + /* istanbul ignore next */ + case '$define': { - var _ret = function () { - var localName = elem.localName.toLowerCase(); // Note: customized built-ins sadly not working yet + var localName = elem.localName.toLowerCase(); // Note: customized built-ins sadly not working yet - var customizedBuiltIn = !localName.includes('-'); - var def = customizedBuiltIn ? elem.getAttribute('is') : localName; + var customizedBuiltIn = !localName.includes('-'); // We check attribute in case this is a preexisting DOM element + // const {is} = atts; - if (customElements.get(def)) { - return "break"; - } + var is; - var getConstructor = function getConstructor(cnstrct) { - var baseClass = options && options["extends"] ? doc.createElement(options["extends"]).constructor : customizedBuiltIn ? doc.createElement(localName).constructor : HTMLElement; - return cnstrct ? - /*#__PURE__*/ - function (_baseClass) { - _inherits$1(_class, _baseClass); + if (customizedBuiltIn) { + is = elem.getAttribute('is'); - function _class() { - var _this; - - _classCallCheck$1(this, _class); - - _this = _possibleConstructorReturn$1(this, _getPrototypeOf$1(_class).call(this)); - cnstrct.call(_assertThisInitialized$1(_this)); - return _this; - } - - return _class; - }(baseClass) : - /*#__PURE__*/ - function (_baseClass2) { - _inherits$1(_class2, _baseClass2); - - function _class2() { - _classCallCheck$1(this, _class2); - - return _possibleConstructorReturn$1(this, _getPrototypeOf$1(_class2).apply(this, arguments)); - } - - return _class2; - }(baseClass); - }; - - var cnstrctr = void 0, - options = void 0, - prototype = void 0; - - if (Array.isArray(attVal)) { - if (attVal.length <= 2) { - var _attVal = _slicedToArray$1(attVal, 2); - - cnstrctr = _attVal[0]; - options = _attVal[1]; - - if (typeof options === 'string') { - options = { - "extends": options - }; - } else if (!{}.hasOwnProperty.call(options, 'extends')) { - prototype = options; - } - - if (_typeof$1(cnstrctr) === 'object') { - prototype = cnstrctr; - cnstrctr = getConstructor(); - } - } else { - var _attVal2 = _slicedToArray$1(attVal, 3); - - cnstrctr = _attVal2[0]; - prototype = _attVal2[1]; - options = _attVal2[2]; - - if (typeof options === 'string') { - options = { - "extends": options - }; - } + if (!is) { + if (!{}.hasOwnProperty.call(atts, 'is')) { + throw new TypeError('Expected `is` with `$define` on built-in'); + } + + elem.setAttribute('is', atts.is); + is = atts.is; + } + } + + var def = customizedBuiltIn ? is : localName; + + if (customElements.get(def)) { + break; + } + + var getConstructor = function getConstructor(cnstrct) { + var baseClass = options && options["extends"] ? doc.createElement(options["extends"]).constructor : customizedBuiltIn ? doc.createElement(localName).constructor : HTMLElement; + return cnstrct ? + /*#__PURE__*/ + function (_baseClass) { + _inherits$1(_class, _baseClass); + + function _class() { + var _this; + + _classCallCheck$1(this, _class); + + _this = _possibleConstructorReturn$1(this, _getPrototypeOf$1(_class).call(this)); + cnstrct.call(_assertThisInitialized$1(_this)); + return _this; + } + + return _class; + }(baseClass) : + /*#__PURE__*/ + function (_baseClass2) { + _inherits$1(_class2, _baseClass2); + + function _class2() { + _classCallCheck$1(this, _class2); + + return _possibleConstructorReturn$1(this, _getPrototypeOf$1(_class2).apply(this, arguments)); + } + + return _class2; + }(baseClass); + }; + + var cnstrctr, options, mixin; + + if (Array.isArray(attVal)) { + if (attVal.length <= 2) { + var _attVal = _slicedToArray$1(attVal, 2); + + cnstrctr = _attVal[0]; + options = _attVal[1]; + + if (typeof options === 'string') { + // Todo: Allow creating a definition without using it; + // that may be the only reason to have a string here which + // differs from the `localName` anyways + options = { + "extends": options + }; + } else if (options && !{}.hasOwnProperty.call(options, 'extends')) { + mixin = options; + } + + if (_typeof$1(cnstrctr) === 'object') { + mixin = cnstrctr; + cnstrctr = getConstructor(); } - } else if (typeof attVal === 'function') { - cnstrctr = attVal; } else { - prototype = attVal; - cnstrctr = getConstructor(); + var _attVal2 = _slicedToArray$1(attVal, 3); + + cnstrctr = _attVal2[0]; + mixin = _attVal2[1]; + options = _attVal2[2]; + + if (typeof options === 'string') { + options = { + "extends": options + }; + } } + } else if (typeof attVal === 'function') { + cnstrctr = attVal; + } else { + mixin = attVal; + cnstrctr = getConstructor(); + } - if (!cnstrctr.toString().startsWith('class')) { - cnstrctr = getConstructor(cnstrctr); - } + if (!cnstrctr.toString().startsWith('class')) { + cnstrctr = getConstructor(cnstrctr); + } - if (!options && customizedBuiltIn) { - options = { - "extends": localName - }; - } + if (!options && customizedBuiltIn) { + options = { + "extends": localName + }; + } - if (prototype) { - Object.assign(cnstrctr.prototype, prototype); - } + if (mixin) { + Object.entries(mixin).forEach(function (_ref) { + var _ref2 = _slicedToArray$1(_ref, 2), + methodName = _ref2[0], + method = _ref2[1]; - customElements.define(def, cnstrctr, customizedBuiltIn ? options : undefined); - return "break"; - }(); + cnstrctr.prototype[methodName] = method; + }); + } // console.log('def', def, '::', typeof options === 'object' ? options : undefined); - if (_ret === "break") break; + + customElements.define(def, cnstrctr, _typeof$1(options) === 'object' ? options : undefined); + break; } case '$symbol': @@ -1259,16 +1271,16 @@ var _node2 = doc.implementation.createHTMLDocument(); if (attVal.childNodes) { - // eslint-disable-next-line unicorn/no-fn-reference-in-iterator - attVal.childNodes.forEach(_childrenToJML(_node2)); // Remove any extra nodes created by createHTMLDocument(). - + // Remove any extra nodes created by createHTMLDocument(). var j = attVal.childNodes.length; while (_node2.childNodes[j]) { var cn = _node2.childNodes[j]; - cn.remove(); - j++; - } + cn.remove(); // `j` should stay the same as removing will cause node to be present + } // eslint-disable-next-line unicorn/no-fn-reference-in-iterator + + + attVal.childNodes.forEach(_childrenToJML(_node2)); } else { if (attVal.$DOCTYPE) { var dt = { @@ -1287,15 +1299,15 @@ var meta = doc.createElement('meta'); meta.setAttribute('charset', 'utf-8'); head.append(meta); - } - if (attVal.title) { - _node2.title = attVal.title; // Appends after meta - } + if (attVal.title) { + _node2.title = attVal.title; // Appends after meta + } - if (attVal.head) { - // eslint-disable-next-line unicorn/no-fn-reference-in-iterator - attVal.head.forEach(_appendJML(head)); + if (attVal.head) { + // eslint-disable-next-line unicorn/no-fn-reference-in-iterator + attVal.head.forEach(_appendJML(head)); + } } if (attVal.body) { @@ -1310,84 +1322,30 @@ case '$DOCTYPE': { - /* - // Todo: - if (attVal.internalSubset) { - node = {}; - } - else - */ - var _node3 = void 0; - - if (attVal.entities || attVal.notations) { - _node3 = { - name: attVal.name, - nodeName: attVal.name, - nodeValue: null, - nodeType: 10, - // eslint-disable-next-line unicorn/no-fn-reference-in-iterator - entities: attVal.entities.map(_jmlSingleArg), - // eslint-disable-next-line unicorn/no-fn-reference-in-iterator - notations: attVal.notations.map(_jmlSingleArg), - publicId: attVal.publicId, - systemId: attVal.systemId // internalSubset: // Todo - - }; - } else { - _node3 = doc.implementation.createDocumentType(attVal.name, attVal.publicId || '', attVal.systemId || ''); - } + var _node3 = doc.implementation.createDocumentType(attVal.name, attVal.publicId || '', attVal.systemId || ''); nodes[nodes.length] = _node3; break; } - case '$ENTITY': - { - /* - // Todo: Should we auto-copy another node's properties/methods (like DocumentType) excluding or changing its non-entity node values? - const node = { - nodeName: attVal.name, - nodeValue: null, - publicId: attVal.publicId, - systemId: attVal.systemId, - notationName: attVal.notationName, - nodeType: 6, - childNodes: attVal.childNodes.map(_DOMfromJMLOrString) - }; - */ - break; - } - - case '$NOTATION': - { - // Todo: We could add further properties/methods, but unlikely to be used as is. - var _node4 = { - nodeName: attVal[0], - publicID: attVal[1], - systemID: attVal[2], - nodeValue: null, - nodeType: 12 - }; - nodes[nodes.length] = _node4; - break; - } - case '$on': { // Events - for (var p2 in attVal) { - if ({}.hasOwnProperty.call(attVal, p2)) { - var val = attVal[p2]; + for (var _i3 = 0, _Object$entries3 = Object.entries(attVal); _i3 < _Object$entries3.length; _i3++) { + var _Object$entries3$_i = _slicedToArray$1(_Object$entries3[_i3], 2), + p2 = _Object$entries3$_i[0], + val = _Object$entries3$_i[1]; - if (typeof val === 'function') { - val = [val, false]; - } - - if (typeof val[0] === 'function') { - _addEvent(elem, p2, val[0], val[1]); // element, event name, handler, capturing - - } + if (typeof val === 'function') { + val = [val, false]; } + + if (typeof val[0] !== 'function') { + throw new TypeError('Expect a function for `$on`'); + } + + _addEvent(elem, p2, val[0], val[1]); // element, event name, handler, capturing + } break; @@ -1403,44 +1361,41 @@ case 'dataset': { - var _ret2 = function () { - // Map can be keyed with hyphenated or camel-cased properties - var recurse = function recurse(atVal, startProp) { - var prop = ''; - var pastInitialProp = startProp !== ''; - Object.keys(atVal).forEach(function (key) { - var value = atVal[key]; + // Map can be keyed with hyphenated or camel-cased properties + var recurse = function recurse(atVal, startProp) { + var prop = ''; + var pastInitialProp = startProp !== ''; + Object.keys(atVal).forEach(function (key) { + var value = atVal[key]; - if (pastInitialProp) { - prop = startProp + key.replace(hyphenForCamelCase, _upperCase).replace(/^([a-z])/, _upperCase); - } else { - prop = startProp + key.replace(hyphenForCamelCase, _upperCase); + if (pastInitialProp) { + prop = startProp + key.replace(hyphenForCamelCase, _upperCase).replace(/^([a-z])/, _upperCase); + } else { + prop = startProp + key.replace(hyphenForCamelCase, _upperCase); + } + + if (value === null || _typeof$1(value) !== 'object') { + if (!_isNullish(value)) { + elem.dataset[prop] = value; } - if (value === null || _typeof$1(value) !== 'object') { - if (!_isNullish(value)) { - elem.dataset[prop] = value; - } + prop = startProp; + return; + } - prop = startProp; - return; - } + recurse(value, prop); + }); + }; - recurse(value, prop); - }); - }; - - recurse(attVal, ''); - return "break"; // Todo: Disable this by default unless configuration explicitly allows (for security) - }(); - - if (_ret2 === "break") break; + recurse(attVal, ''); + break; // Todo: Disable this by default unless configuration explicitly allows (for security) } // #if IS_REMOVE // Don't remove this `if` block (for sake of no-innerHTML build) case 'innerHTML': if (!_isNullish(attVal)) { + // eslint-disable-next-line no-unsanitized/property elem.innerHTML = attVal; } @@ -1478,14 +1433,18 @@ } if (_typeof$1(attVal) === 'object') { - for (var _p in attVal) { - if ({}.hasOwnProperty.call(attVal, _p) && !_isNullish(attVal[_p])) { + for (var _i4 = 0, _Object$entries4 = Object.entries(attVal); _i4 < _Object$entries4.length; _i4++) { + var _Object$entries4$_i = _slicedToArray$1(_Object$entries4[_i4], 2), + _p = _Object$entries4$_i[0], + styleVal = _Object$entries4$_i[1]; + + if (!_isNullish(styleVal)) { // Todo: Handle aggregate properties like "border" if (_p === 'float') { - elem.style.cssFloat = attVal[_p]; - elem.style.styleFloat = attVal[_p]; // Harmless though we could make conditional on older IE instead + elem.style.cssFloat = styleVal; + elem.style.styleFloat = styleVal; // Harmless though we could make conditional on older IE instead } else { - elem.style[_p.replace(hyphenForCamelCase, _upperCase)] = attVal[_p]; + elem.style[_p.replace(hyphenForCamelCase, _upperCase)] = styleVal; } } } @@ -1526,6 +1485,12 @@ break; } } + }; + + for (var _i2 = 0, _Object$entries2 = Object.entries(atts); _i2 < _Object$entries2.length; _i2++) { + var _ret = _loop(); + + if (_ret === "continue") continue; } } @@ -1556,7 +1521,7 @@ } opts.$plugins.forEach(function (pluginObj) { - if (!pluginObj) { + if (!pluginObj || _typeof$1(pluginObj) !== 'object') { throw new TypeError('Plugin must be an object'); } @@ -1589,12 +1554,12 @@ if (typeof dataVal[0] === 'string') { dataVal.forEach(function (dVal) { setMap(opts.$map[dVal]); - }); // Array of Map and non-map data object - } else { - map = dataVal[0] || defaultMap[0]; - obj = dataVal[1] || defaultMap[1]; - } // Map + }); + return; // Array of Map and non-map data object + } + map = dataVal[0] || defaultMap[0]; + obj = dataVal[1] || defaultMap[1]; // Map } else if (/^\[object (?:Weak)?Map\]$/.test([].toString.call(dataVal))) { map = dataVal; obj = defaultMap[1]; // Non-map data object @@ -1609,10 +1574,11 @@ for (var i = 0; i < argc; i++) { var arg = args[i]; - switch (_getType(arg)) { + var type = _getType(arg); + + switch (type) { default: - // Todo: Throw here instead? - break; + throw new TypeError('Unexpected type: ' + type); case 'null': // null always indicates a place-holder (only needed for last argument if want array returned) @@ -1625,10 +1591,10 @@ : nodes.reduce(_fragReducer, doc.createDocumentFragment()); // nodes; } - break; + throw new TypeError('`null` values not allowed except as final Jamilih argument'); case 'string': - // Strings indicate elements + // Strings normally indicate elements switch (arg) { case '!': nodes[nodes.length] = doc.createComment(args[++i]); @@ -1640,14 +1606,16 @@ var procValue = args[++i]; var val = procValue; - if (_typeof$1(val) === 'object') { + if (val && _typeof$1(val) === 'object') { procValue = []; - for (var p in val) { - if ({}.hasOwnProperty.call(val, p)) { - procValue.push(p + '=' + '"' + // https://www.w3.org/TR/xml-stylesheet/#NT-PseudoAttValue - val[p].replace(/"/g, '"') + '"'); - } + for (var _i5 = 0, _Object$entries5 = Object.entries(val); _i5 < _Object$entries5.length; _i5++) { + var _Object$entries5$_i = _slicedToArray$1(_Object$entries5[_i5], 2), + p = _Object$entries5$_i[0], + procInstVal = _Object$entries5$_i[1]; + + procValue.push(p + '=' + '"' + // https://www.w3.org/TR/xml-stylesheet/#NT-PseudoAttValue + procInstVal.replace(/"/g, '"') + '"'); } procValue = procValue.join(' '); @@ -1696,17 +1664,17 @@ break; case '': - nodes[nodes.length] = doc.createDocumentFragment(); + nodes[nodes.length] = elem = doc.createDocumentFragment(); break; default: { // An element elStr = arg; - var atts = args[i + 1]; // Todo: Fix this to depend on XML/config, not availability of methods + var atts = args[i + 1]; if (_getType(atts) === 'object' && atts.is) { - var is = atts.is; + var is = atts.is; // istanbul ignore else if (doc.createElementNS) { elem = doc.createElementNS(NS_HTML, elStr, { @@ -1717,11 +1685,13 @@ is: is }); } - } else if (doc.createElementNS) { - elem = doc.createElementNS(NS_HTML, elStr); - } else { - elem = doc.createElement(elStr); - } + } else + /* istanbul ignore else */ + if (doc.createElementNS) { + elem = doc.createElementNS(NS_HTML, elStr); + } else { + elem = doc.createElement(elStr); + } nodes[nodes.length] = elem; // Add to parent @@ -1751,17 +1721,16 @@ // Also fix DOMParser to work with text/html - elem = nodes[nodes.length - 1] = new DOMParser().parseFromString(new XmlSerializer().serializeToString(elem) // Mozilla adds XHTML namespace + elem = nodes[nodes.length - 1] = new win.DOMParser().parseFromString(new win.XMLSerializer().serializeToString(elem) // Mozilla adds XHTML namespace .replace(' xmlns="' + NS_HTML + '"', replacer), 'application/xml').documentElement; // }catch(e) {alert(elem.outerHTML);throw e;} - } // eslint-disable-next-line unicorn/no-fn-reference-in-iterator + } + _checkAtts(_atts); - var orderedArr = _atts.$a ? _atts.$a.map(_copyOrderedAtts) : [_atts]; // eslint-disable-next-line unicorn/no-fn-reference-in-iterator - - orderedArr.forEach(_checkAtts); break; } + case 'document': case 'fragment': case 'element': /* @@ -1769,7 +1738,7 @@ 2) Individual elements (DOM elements or sequences of string[/object/array]) get added to parent first-in, first-added */ if (i === 0) { - // Allow wrapping of element + // Allow wrapping of element, fragment, or document elem = arg; } @@ -1802,8 +1771,8 @@ var childContentType = _typeof$1(childContent); - if (childContent === undefined) { - throw String('Parent array:' + JSON.stringify(args) + '; child: ' + child + '; index:' + j); + if (_isNullish(childContent)) { + throw new TypeError('Bad children (parent array: ' + JSON.stringify(args) + '; child: ' + child + '; index:' + j + ')'); } switch (childContentType) { @@ -1846,51 +1815,71 @@ }; /** * Converts a DOM object or a string of HTML into a Jamilih object (or string). - * @param {string|HTMLElement} [dom=document.documentElement] Defaults to converting the current document. + * @param {string|HTMLElement} dom If a string, will parse as document * @param {PlainObject} [config] Configuration object * @param {boolean} [config.stringOutput=false] Whether to output the Jamilih object as a string. + * @param {boolean} [config.reportInvalidState=true] If true (the default), will report invalid state errors + * @param {boolean} [config.stripWhitespace=false] Strip whitespace for text nodes * @returns {JamilihArray|string} Array containing the elements which represent * a Jamilih object, or, if `stringOutput` is true, it will be the stringified * version of such an object */ - jml.toJML = function (dom, config) { - config = config || { - stringOutput: false - }; + jml.toJML = function (dom) { + var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref3$stringOutput = _ref3.stringOutput, + stringOutput = _ref3$stringOutput === void 0 ? false : _ref3$stringOutput, + _ref3$reportInvalidSt = _ref3.reportInvalidState, + reportInvalidState = _ref3$reportInvalidSt === void 0 ? true : _ref3$reportInvalidSt, + _ref3$stripWhitespace = _ref3.stripWhitespace, + stripWhitespace = _ref3$stripWhitespace === void 0 ? false : _ref3$stripWhitespace; if (typeof dom === 'string') { - dom = new DOMParser().parseFromString(dom, 'text/html'); // todo: Give option for XML once implemented and change JSDoc to allow for Element + dom = new win.DOMParser().parseFromString(dom, 'text/html'); // todo: Give option for XML once implemented and change JSDoc to allow for Element } var ret = []; var parent = ret; var parentIdx = 0; /** - * + * @param {string} msg * @throws {DOMException} * @returns {void} */ - function invalidStateError() { + function invalidStateError(msg) { // These are probably only necessary if working with text/html - // eslint-disable-next-line no-shadow - var DOMException = function DOMException() { - _classCallCheck$1(this, DOMException); - }; + // eslint-disable-next-line no-shadow, unicorn/custom-error-definition + var DOMException = + /*#__PURE__*/ + function (_Error) { + _inherits$1(DOMException, _Error); - { + function DOMException(message, name) { + var _this2; + + _classCallCheck$1(this, DOMException); + + _this2 = _possibleConstructorReturn$1(this, _getPrototypeOf$1(DOMException).call(this, message)); // eslint-disable-next-line unicorn/custom-error-definition + + _this2.name = name; + return _this2; + } + + return DOMException; + }(_wrapNativeSuper$1(Error)); + + if (reportInvalidState) { // INVALID_STATE_ERR per section 9.3 XHTML 5: http://www.w3.org/TR/html5/the-xhtml-syntax.html - // Since we can't instantiate without this (at least in Mozilla), this mimicks at least (good idea?) - var e = new DOMException(); + var e = new DOMException(msg, 'INVALID_STATE_ERR'); e.code = 11; throw e; } } /** * - * @param {DocumentType|Entity|Notation} obj + * @param {DocumentType|Entity} obj * @param {Node} node * @returns {void} */ @@ -1898,7 +1887,7 @@ function addExternalID(obj, node) { if (node.systemId.includes('"') && node.systemId.includes("'")) { - invalidStateError(); + invalidStateError('systemId cannot have both single and double quotes.'); } var publicId = node.publicId, @@ -1962,18 +1951,18 @@ /* if ((node.prefix && node.prefix.includes(':')) || (node.localName && node.localName.includes(':'))) { - invalidStateError(); + invalidStateError('Prefix cannot have a colon'); } */ var type = 'nodeType' in node ? node.nodeType : null; namespaces = _objectSpread2({}, namespaces); - var xmlChars = /([\t\n\r -\uD7FF\uE000-\uFFFD]|(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF]))(?:(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))*$/; // eslint-disable-line no-control-regex + var xmlChars = /^([\t\n\r -\uD7FF\uE000-\uFFFD]|(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF]))(?:(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))*$/; // eslint-disable-line no-control-regex if ([2, 3, 4, 7, 8].includes(type) && !xmlChars.test(node.nodeValue)) { - invalidStateError(); + invalidStateError('Node has bad XML character value'); } - var children, start, tmpParent, tmpParentIdx; + var tmpParent, tmpParentIdx; /** * @returns {void} */ @@ -2003,7 +1992,7 @@ setChildren(); // Build child array since elements are, except at the top level, encapsulated in arrays set(nodeName); - start = {}; + var start = {}; var hasNamespaceDeclaration = false; if (namespaces[node.prefix || ''] !== node.namespaceURI) { @@ -2013,6 +2002,8 @@ start['xmlns:' + node.prefix] = node.namespaceURI; } else if (node.namespaceURI) { start.xmlns = node.namespaceURI; + } else { + start.xmlns = null; } hasNamespaceDeclaration = true; @@ -2028,12 +2019,12 @@ set(start); } - children = node.childNodes; + var childNodes = node.childNodes; - if (children.length) { + if (childNodes.length) { setChildren(); // Element children array container - _toConsumableArray$1(children).forEach(function (childNode) { + _toConsumableArray$1(childNodes).forEach(function (childNode) { parseDOM(childNode, namespaces); }); } @@ -2053,7 +2044,8 @@ case 3: // TEXT - if (config.stripWhitespace && /^[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+$/.test(node.nodeValue)) { + if (stripWhitespace && /^[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+$/.test(node.nodeValue)) { + set(''); return; } @@ -2063,76 +2055,34 @@ case 4: // CDATA if (node.nodeValue.includes(']]' + '>')) { - invalidStateError(); + invalidStateError('CDATA cannot end with closing ]]>'); } set(['![', node.nodeValue]); break; case 5: - // ENTITY REFERENCE (probably not used in browsers since already resolved) + // ENTITY REFERENCE (though not in browsers (was already resolved + // anyways), ok to keep for parity with our "entity" shorthand) set(['&', node.nodeName]); break; - case 6: - // ENTITY (would need to pass in directly) - setTemp(); - start = {}; - - if (node.xmlEncoding || node.xmlVersion) { - // an external entity file? - start.$ENTITY = { - name: node.nodeName, - version: node.xmlVersion, - encoding: node.xmlEncoding - }; - } else { - start.$ENTITY = { - name: node.nodeName - }; - - if (node.publicId || node.systemId) { - // External Entity? - addExternalID(start.$ENTITY, node); - - if (node.notationName) { - start.$ENTITY.NDATA = node.notationName; - } - } - } - - set(start); - children = node.childNodes; - - if (children.length) { - start.$ENTITY.childNodes = []; // Set position to $ENTITY's childNodes array children - - setObj('$ENTITY', 'childNodes'); - - _toConsumableArray$1(children).forEach(function (childNode) { - parseDOM(childNode, namespaces); - }); - } - - resetTemp(); - break; - case 7: // PROCESSING INSTRUCTION if (/^xml$/i.test(node.target)) { - invalidStateError(); + invalidStateError('Processing instructions cannot be "xml".'); } if (node.target.includes('?>')) { - invalidStateError(); + invalidStateError('Processing instruction targets cannot include ?>'); } if (node.target.includes(':')) { - invalidStateError(); + invalidStateError('The processing instruction target cannot include ":"'); } if (node.data.includes('?>')) { - invalidStateError(); + invalidStateError('Processing instruction data cannot include ?>'); } set(['?', node.target, node.data]); // Todo: Could give option to attempt to convert value back into object if has pseudo-attributes @@ -2142,7 +2092,7 @@ case 8: // COMMENT if (node.nodeValue.includes('--') || node.nodeValue.length && node.nodeValue.lastIndexOf('-') === node.nodeValue.length - 1) { - invalidStateError(); + invalidStateError('Comments cannot include --'); } set(['!', node.nodeValue]); @@ -2157,27 +2107,18 @@ childNodes: [] } }; - - if (config.xmlDeclaration) { - docObj.$document.xmlDeclaration = { - version: doc.xmlVersion, - encoding: doc.xmlEncoding, - standAlone: doc.xmlStandalone - }; - } - set(docObj); // doc.implementation.createHTMLDocument // Set position to fragment's array children setObj('$document', 'childNodes'); - children = node.childNodes; + var _childNodes = node.childNodes; - if (!children.length) { - invalidStateError(); + if (!_childNodes.length) { + invalidStateError('Documents must have a child node'); } // set({$xmlDocument: []}); // doc.implementation.createDocument // Todo: use this conditionally - _toConsumableArray$1(children).forEach(function (childNode) { + _toConsumableArray$1(_childNodes).forEach(function (childNode) { // Can't just do documentElement as there may be doctype, comments, etc. // No need for setChildren, as we have already built the container array parseDOM(childNode, namespaces); @@ -2192,84 +2133,44 @@ // DOCUMENT TYPE setTemp(); // Can create directly by doc.implementation.createDocumentType - start = { + var _start = { $DOCTYPE: { name: node.name } }; - - if (node.internalSubset) { - start.internalSubset = node.internalSubset; - } - var pubIdChar = /^( |\r|\n|[0-9A-Za-z]|[!#-%'-\/:;=\?@_])*$/; // eslint-disable-line no-control-regex if (!pubIdChar.test(node.publicId)) { - invalidStateError(); + invalidStateError('A publicId must have valid characters.'); } - addExternalID(start.$DOCTYPE, node); // Fit in internal subset along with entities?: probably don't need as these would only differ if from DTD, and we're not rebuilding the DTD + addExternalID(_start.$DOCTYPE, node); // Fit in internal subset along with entities?: probably don't need as these would only differ if from DTD, and we're not rebuilding the DTD - set(start); // Auto-generate the internalSubset instead? Avoid entities/notations in favor of array to preserve order? - - var entities = node.entities; // Currently deprecated - - if (entities && entities.length) { - start.$DOCTYPE.entities = []; - setObj('$DOCTYPE', 'entities'); - - _toConsumableArray$1(entities).forEach(function (entity) { - parseDOM(entity, namespaces); - }); // Reset for notations - - - parent = tmpParent; - parentIdx = tmpParentIdx + 1; - } - - var notations = node.notations; // Currently deprecated - - if (notations && notations.length) { - start.$DOCTYPE.notations = []; - setObj('$DOCTYPE', 'notations'); - - _toConsumableArray$1(notations).forEach(function (notation) { - parseDOM(notation, namespaces); - }); - } + set(_start); // Auto-generate the internalSubset instead? resetTemp(); break; } case 11: - // DOCUMENT FRAGMENT - setTemp(); - set({ - '#': [] - }); // Set position to fragment's array children + { + // DOCUMENT FRAGMENT + setTemp(); + set({ + '#': [] + }); // Set position to fragment's array children - setObj('#'); - children = node.childNodes; + setObj('#'); + var _childNodes2 = node.childNodes; - _toConsumableArray$1(children).forEach(function (childNode) { - // No need for setChildren, as we have already built the container array - parseDOM(childNode, namespaces); - }); + _toConsumableArray$1(_childNodes2).forEach(function (childNode) { + // No need for setChildren, as we have already built the container array + parseDOM(childNode, namespaces); + }); - resetTemp(); - break; - - case 12: - // NOTATION - start = { - $NOTATION: { - name: node.nodeName - } - }; - addExternalID(start.$NOTATION, node); - set(start); - break; + resetTemp(); + break; + } default: throw new TypeError('Not an XML type'); @@ -2278,7 +2179,7 @@ parseDOM(dom, {}); - if (config.stringOutput) { + if (stringOutput) { return JSON.stringify(ret[0]); } @@ -2310,7 +2211,9 @@ jml.toHTML = function () { // Todo: Replace this with version of jml() that directly builds a string - var ret = jml.apply(void 0, arguments); // Todo: deal with serialization of properties like 'selected', 'checked', 'value', 'defaultValue', 'for', 'dataset', 'on*', 'style'! (i.e., need to build a string ourselves) + var ret = jml.apply(void 0, arguments); // Todo: deal with serialization of properties like 'selected', + // 'checked', 'value', 'defaultValue', 'for', 'dataset', 'on*', + // 'style'! (i.e., need to build a string ourselves) return ret.outerHTML; }; @@ -2334,7 +2237,7 @@ jml.toXML = function () { var ret = jml.apply(void 0, arguments); - return new XmlSerializer().serializeToString(ret); + return new win.XMLSerializer().serializeToString(ret); }; /** * @@ -2432,6 +2335,17 @@ jml.Map = JamilihMap; jml.WeakMap = JamilihWeakMap; + /** + * @typedef {GenericArray} MapAndElementArray + * @property {JamilihWeakMap|JamilihMap} 0 + * @property {Element} 1 + */ + + /** + * @param {GenericObject} obj + * @param {...JamilihArray} args + * @returns {MapAndElementArray} + */ jml.weak = function (obj) { var map = new JamilihWeakMap(); @@ -2445,6 +2359,12 @@ }].concat(args)); return [map, elem]; }; + /** + * @param {any} obj + * @param {...JamilihArray} args + * @returns {MapAndElementArray} + */ + jml.strong = function (obj) { var map = new JamilihMap(); @@ -2458,11 +2378,26 @@ }].concat(args)); return [map, elem]; }; + /** + * @param {string|Element} elem If a string, will be interpreted as a selector + * @param {symbol|string} sym If a string, will be used with `Symbol.for` + * @returns {any} The value associated with the symbol + */ + jml.symbol = jml.sym = jml["for"] = function (elem, sym) { elem = typeof elem === 'string' ? $(elem) : elem; return elem[_typeof$1(sym) === 'symbol' ? sym : Symbol["for"](sym)]; }; + /** + * @param {string|Element} elem If a string, will be interpreted as a selector + * @param {symbol|string|Map|WeakMap} symOrMap If a string, will be used with `Symbol.for` + * @param {string|any} methodName Can be `any` if the symbol or map directly + * points to a function (it is then used as the first argument). + * @param {any[]} args + * @returns {any} + */ + jml.command = function (elem, symOrMap, methodName) { var _func3; @@ -2496,34 +2431,32 @@ return (_func3 = func)[methodName].apply(_func3, [elem].concat(args)); // return func[methodName].call(elem, ...args); }; + /** + * Expects properties `document`, `XMLSerializer`, and `DOMParser`. + * Also updates `body` with `document.body`. + * @param {Window} wind + * @returns {void} + */ + jml.setWindow = function (wind) { win = wind; - }; + doc = win.document; - jml.setDocument = function (docum) { - doc = docum; - - if (docum && docum.body) { - body = docum.body; + if (doc && doc.body) { + var _doc = doc; + body = _doc.body; } }; + /** + * @returns {Window} + */ - jml.setXMLSerializer = function (xmls) { - XmlSerializer = xmls; - }; jml.getWindow = function () { return win; }; - jml.getDocument = function () { - return doc; - }; - - jml.getXMLSerializer = function () { - return XmlSerializer; - }; var body = doc && doc.body; // eslint-disable-line import/no-mutable-exports diff --git a/dist/index-es.js b/dist/index-es.js index 86be013f..a3b010c3 100644 --- a/dist/index-es.js +++ b/dist/index-es.js @@ -6582,7 +6582,7 @@ var convertPath = function convertPath(pth, toRel) { x2 = seg.x2 || 0, y2 = seg.y2 || 0; var type = seg.pathSegType; - var letter = pathMap[type]['to' + (toRel ? 'Lower' : 'Upper') + 'Case'](); + var letter = pathMap[type][toRel ? 'toLowerCase' : 'toUpperCase'](); switch (type) { case 1: @@ -6604,16 +6604,18 @@ var convertPath = function convertPath(pth, toRel) { case 13: // relative horizontal line (h) if (toRel) { + y = 0; curx += x; letter = 'l'; } else { + y = cury; x += curx; curx = x; letter = 'L'; } // Convert to "line" for easier editing - d += pathDSegment(letter, [[x, cury]]); + d += pathDSegment(letter, [[x, y]]); break; case 14: @@ -6624,16 +6626,18 @@ var convertPath = function convertPath(pth, toRel) { case 15: // relative vertical line (v) if (toRel) { + x = 0; cury += y; letter = 'l'; } else { + x = curx; y += cury; cury = y; letter = 'L'; } // Convert to "line" for easier editing - d += pathDSegment(letter, [[curx, y]]); + d += pathDSegment(letter, [[x, y]]); break; case 2: // absolute move (M) @@ -9163,6 +9167,16 @@ var assignAttributes = function assignAttributes(elem, attrs, suspendLength, uni var ns = key.substr(0, 4) === 'xml:' ? NS.XML : key.substr(0, 6) === 'xlink:' ? NS.XLINK : null; + if (isNullish(value)) { + if (ns) { + elem.removeAttributeNS(ns, key); + } else { + elem.removeAttribute(key); + } + + continue; + } + if (ns) { elem.setAttributeNS(ns, key, value); } else if (!unitCheck) { @@ -14317,6 +14331,10 @@ function SvgCanvas(container, config) { } } + if (!selectedElements.length) { + return; + } + call('selected', selectedElements); if (showGrips || selectedElements.length === 1) { @@ -17741,6 +17759,16 @@ function SvgCanvas(container, config) { continue; } + if (_attrVal === 'null') { + var styleName = _attr.localName.replace(/-[a-z]/g, function (s) { + return s[1].toUpperCase(); + }); + + if (Object.prototype.hasOwnProperty.call(elem.style, styleName)) { + continue; + } + } + if (_attrVal !== '') { if (_attrVal.startsWith('pointer-events')) { continue; @@ -17795,7 +17823,7 @@ function SvgCanvas(container, config) { case 1: // element node out.push('\n'); - out.push(this.svgToString(childs.item(_i4), indent)); + out.push(this.svgToString(child, indent)); break; case 3: @@ -18201,7 +18229,8 @@ function SvgCanvas(container, config) { _context3.next = 4; return importScript([// We do not currently have these paths configurable as they are // currently global-only, so not Rolled-up - 'jspdf/underscore-min.js', 'jspdf/jspdf.min.js']); + 'jspdf/underscore-min.js', // 'jspdf/jspdf.min.js', + '../../svgedit-myfix/editor/jspdf/jspdf-1.0.150.debug.js']); case 4: modularVersion = !('svgEditor' in window) || !window.svgEditor || window.svgEditor.modules !== false; // Todo: Switch to `import()` when widely supported and available (also allow customization of path) diff --git a/dist/index-es.min.js b/dist/index-es.min.js index 974934f0..a7e873b8 100644 --- a/dist/index-es.min.js +++ b/dist/index-es.min.js @@ -4,19 +4,19 @@ function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterat * @module namespaces * @license MIT */ -var f={HTML:"http://www.w3.org/1999/xhtml",MATH:"http://www.w3.org/1998/Math/MathML",SE:"http://svg-edit.googlecode.com",SVG:"http://www.w3.org/2000/svg",XLINK:"http://www.w3.org/1999/xlink",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"},g=function(){var e={};return Object.entries(f).forEach((function(t){var n=d(t,2),r=n[0],a=n[1];e[a]=r.toLowerCase()})),e};!function(){if(!("SVGPathSeg"in window)){var e=function(){function e(t,n,a){r(this,e),this.pathSegType=t,this.pathSegTypeAsLetter=n,this._owningPathSegList=a}return i(e,[{key:"_segmentChanged",value:function(){this._owningPathSegList&&this._owningPathSegList.segmentChanged(this)}}]),e}();e.prototype.classname="SVGPathSeg",e.PATHSEG_UNKNOWN=0,e.PATHSEG_CLOSEPATH=1,e.PATHSEG_MOVETO_ABS=2,e.PATHSEG_MOVETO_REL=3,e.PATHSEG_LINETO_ABS=4,e.PATHSEG_LINETO_REL=5,e.PATHSEG_CURVETO_CUBIC_ABS=6,e.PATHSEG_CURVETO_CUBIC_REL=7,e.PATHSEG_CURVETO_QUADRATIC_ABS=8,e.PATHSEG_CURVETO_QUADRATIC_REL=9,e.PATHSEG_ARC_ABS=10,e.PATHSEG_ARC_REL=11,e.PATHSEG_LINETO_HORIZONTAL_ABS=12,e.PATHSEG_LINETO_HORIZONTAL_REL=13,e.PATHSEG_LINETO_VERTICAL_ABS=14,e.PATHSEG_LINETO_VERTICAL_REL=15,e.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS=16,e.PATHSEG_CURVETO_CUBIC_SMOOTH_REL=17,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS=18,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL=19;var t=function(t){function n(t){return r(this,n),u(this,l(n).call(this,e.PATHSEG_CLOSEPATH,"z",t))}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegClosePath]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter}},{key:"clone",value:function(){return new n(void 0)}}]),n}(e),n=function(t){function n(t,a,i){var o;return r(this,n),(o=u(this,l(n).call(this,e.PATHSEG_MOVETO_ABS,"M",t)))._x=a,o._y=i,o}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegMovetoAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y)}}]),n}(e);Object.defineProperties(n.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var a=function(t){function n(t,a,i){var o;return r(this,n),(o=u(this,l(n).call(this,e.PATHSEG_MOVETO_REL,"m",t)))._x=a,o._y=i,o}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegMovetoRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y)}}]),n}(e);Object.defineProperties(a.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var o=function(t){function n(t,a,i){var o;return r(this,n),(o=u(this,l(n).call(this,e.PATHSEG_LINETO_ABS,"L",t)))._x=a,o._y=i,o}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegLinetoAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y)}}]),n}(e);Object.defineProperties(o.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var c=function(t){function n(t,a,i){var o;return r(this,n),(o=u(this,l(n).call(this,e.PATHSEG_LINETO_REL,"l",t)))._x=a,o._y=i,o}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegLinetoRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y)}}]),n}(e);Object.defineProperties(c.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var d=function(t){function n(t,a,i,o,s,c,d){var h;return r(this,n),(h=u(this,l(n).call(this,e.PATHSEG_CURVETO_CUBIC_ABS,"C",t)))._x=a,h._y=i,h._x1=o,h._y1=s,h._x2=c,h._y2=d,h}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)}}]),n}(e);Object.defineProperties(d.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var h=function(t){function n(t,a,i,o,s,c,d){var h;return r(this,n),(h=u(this,l(n).call(this,e.PATHSEG_CURVETO_CUBIC_REL,"c",t)))._x=a,h._y=i,h._x1=o,h._y1=s,h._x2=c,h._y2=d,h}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)}}]),n}(e);Object.defineProperties(h.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var p=function(t){function n(t,a,i,o,s){var c;return r(this,n),(c=u(this,l(n).call(this,e.PATHSEG_CURVETO_QUADRATIC_ABS,"Q",t)))._x=a,c._y=i,c._x1=o,c._y1=s,c}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._x1,this._y1)}}]),n}(e);Object.defineProperties(p.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0}});var f=function(t){function n(t,a,i,o,s){var c;return r(this,n),(c=u(this,l(n).call(this,e.PATHSEG_CURVETO_QUADRATIC_REL,"q",t)))._x=a,c._y=i,c._x1=o,c._y1=s,c}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._x1,this._y1)}}]),n}(e);Object.defineProperties(f.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0}});var g=function(t){function n(t,a,i,o,s,c,d,h){var p;return r(this,n),(p=u(this,l(n).call(this,e.PATHSEG_ARC_ABS,"A",t)))._x=a,p._y=i,p._r1=o,p._r2=s,p._angle=c,p._largeArcFlag=d,p._sweepFlag=h,p}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegArcAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)}}]),n}(e);Object.defineProperties(g.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},r1:{get:function(){return this._r1},set:function(e){this._r1=e,this._segmentChanged()},enumerable:!0},r2:{get:function(){return this._r2},set:function(e){this._r2=e,this._segmentChanged()},enumerable:!0},angle:{get:function(){return this._angle},set:function(e){this._angle=e,this._segmentChanged()},enumerable:!0},largeArcFlag:{get:function(){return this._largeArcFlag},set:function(e){this._largeArcFlag=e,this._segmentChanged()},enumerable:!0},sweepFlag:{get:function(){return this._sweepFlag},set:function(e){this._sweepFlag=e,this._segmentChanged()},enumerable:!0}});var m=function(t){function n(t,a,i,o,s,c,d,h){var p;return r(this,n),(p=u(this,l(n).call(this,e.PATHSEG_ARC_REL,"a",t)))._x=a,p._y=i,p._r1=o,p._r2=s,p._angle=c,p._largeArcFlag=d,p._sweepFlag=h,p}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegArcRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)}}]),n}(e);Object.defineProperties(m.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},r1:{get:function(){return this._r1},set:function(e){this._r1=e,this._segmentChanged()},enumerable:!0},r2:{get:function(){return this._r2},set:function(e){this._r2=e,this._segmentChanged()},enumerable:!0},angle:{get:function(){return this._angle},set:function(e){this._angle=e,this._segmentChanged()},enumerable:!0},largeArcFlag:{get:function(){return this._largeArcFlag},set:function(e){this._largeArcFlag=e,this._segmentChanged()},enumerable:!0},sweepFlag:{get:function(){return this._sweepFlag},set:function(e){this._sweepFlag=e,this._segmentChanged()},enumerable:!0}});var v=function(t){function n(t,a){var i;return r(this,n),(i=u(this,l(n).call(this,e.PATHSEG_LINETO_HORIZONTAL_ABS,"H",t)))._x=a,i}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegLinetoHorizontalAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x}},{key:"clone",value:function(){return new n(void 0,this._x)}}]),n}(e);Object.defineProperty(v.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0});var y=function(t){function n(t,a){var i;return r(this,n),(i=u(this,l(n).call(this,e.PATHSEG_LINETO_HORIZONTAL_REL,"h",t)))._x=a,i}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegLinetoHorizontalRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x}},{key:"clone",value:function(){return new n(void 0,this._x)}}]),n}(e);Object.defineProperty(y.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0});var _=function(t){function n(t,a){var i;return r(this,n),(i=u(this,l(n).call(this,e.PATHSEG_LINETO_VERTICAL_ABS,"V",t)))._y=a,i}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegLinetoVerticalAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._y)}}]),n}(e);Object.defineProperty(_.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0});var b=function(t){function n(t,a){var i;return r(this,n),(i=u(this,l(n).call(this,e.PATHSEG_LINETO_VERTICAL_REL,"v",t)))._y=a,i}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegLinetoVerticalRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._y)}}]),n}(e);Object.defineProperty(b.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0});var x=function(t){function n(t,a,i,o,s){var c;return r(this,n),(c=u(this,l(n).call(this,e.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS,"S",t)))._x=a,c._y=i,c._x2=o,c._y2=s,c}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicSmoothAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._x2,this._y2)}}]),n}(e);Object.defineProperties(x.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var w=function(t){function n(t,a,i,o,s){var c;return r(this,n),(c=u(this,l(n).call(this,e.PATHSEG_CURVETO_CUBIC_SMOOTH_REL,"s",t)))._x=a,c._y=i,c._x2=o,c._y2=s,c}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicSmoothRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._x2,this._y2)}}]),n}(e);Object.defineProperties(w.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var S=function(t){function n(t,a,i){var o;return r(this,n),(o=u(this,l(n).call(this,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS,"T",t)))._x=a,o._y=i,o}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticSmoothAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y)}}]),n}(e);Object.defineProperties(S.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var k=function(t){function n(t,a,i){var o;return r(this,n),(o=u(this,l(n).call(this,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL,"t",t)))._x=a,o._y=i,o}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticSmoothRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y)}}]),n}(e);Object.defineProperties(k.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}}),SVGPathElement.prototype.createSVGPathSegClosePath=function(){return new t(void 0)},SVGPathElement.prototype.createSVGPathSegMovetoAbs=function(e,t){return new n(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegMovetoRel=function(e,t){return new a(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegLinetoAbs=function(e,t){return new o(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegLinetoRel=function(e,t){return new c(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs=function(e,t,n,r,a,i){return new d(void 0,e,t,n,r,a,i)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel=function(e,t,n,r,a,i){return new h(void 0,e,t,n,r,a,i)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs=function(e,t,n,r){return new p(void 0,e,t,n,r)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel=function(e,t,n,r){return new f(void 0,e,t,n,r)},SVGPathElement.prototype.createSVGPathSegArcAbs=function(e,t,n,r,a,i,o){return new g(void 0,e,t,n,r,a,i,o)},SVGPathElement.prototype.createSVGPathSegArcRel=function(e,t,n,r,a,i,o){return new m(void 0,e,t,n,r,a,i,o)},SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs=function(e){return new v(void 0,e)},SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel=function(e){return new y(void 0,e)},SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs=function(e){return new _(void 0,e)},SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel=function(e){return new b(void 0,e)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs=function(e,t,n,r){return new x(void 0,e,t,n,r)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel=function(e,t,n,r){return new w(void 0,e,t,n,r)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs=function(e,t){return new S(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel=function(e,t){return new k(void 0,e,t)},"getPathSegAtLength"in SVGPathElement.prototype||(SVGPathElement.prototype.getPathSegAtLength=function(e){if(void 0===e||!isFinite(e))throw new Error("Invalid arguments.");var t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d",this.getAttribute("d"));var n=t.pathSegList.numberOfItems-1;if(n<=0)return 0;do{if(t.pathSegList.removeItem(n),e>t.getTotalLength())break;n--}while(n>0);return n}),window.SVGPathSeg=e,window.SVGPathSegClosePath=t,window.SVGPathSegMovetoAbs=n,window.SVGPathSegMovetoRel=a,window.SVGPathSegLinetoAbs=o,window.SVGPathSegLinetoRel=c,window.SVGPathSegCurvetoCubicAbs=d,window.SVGPathSegCurvetoCubicRel=h,window.SVGPathSegCurvetoQuadraticAbs=p,window.SVGPathSegCurvetoQuadraticRel=f,window.SVGPathSegArcAbs=g,window.SVGPathSegArcRel=m,window.SVGPathSegLinetoHorizontalAbs=v,window.SVGPathSegLinetoHorizontalRel=y,window.SVGPathSegLinetoVerticalAbs=_,window.SVGPathSegLinetoVerticalRel=b,window.SVGPathSegCurvetoCubicSmoothAbs=x,window.SVGPathSegCurvetoCubicSmoothRel=w,window.SVGPathSegCurvetoQuadraticSmoothAbs=S,window.SVGPathSegCurvetoQuadraticSmoothRel=k}if(!("SVGPathSegList"in window&&"appendItem"in window.SVGPathSegList.prototype)){var C=function(){function e(t){r(this,e),this._pathElement=t,this._list=this._parsePath(this._pathElement.getAttribute("d")),this._mutationObserverConfig={attributes:!0,attributeFilter:["d"]},this._pathElementMutationObserver=new MutationObserver(this._updateListFromPathMutations.bind(this)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)}return i(e,[{key:"_checkPathSynchronizedToList",value:function(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())}},{key:"_updateListFromPathMutations",value:function(e){if(this._pathElement){var t=!1;e.forEach((function(e){"d"===e.attributeName&&(t=!0)})),t&&(this._list=this._parsePath(this._pathElement.getAttribute("d")))}}},{key:"_writeListToPath",value:function(){this._pathElementMutationObserver.disconnect(),this._pathElement.setAttribute("d",e._pathSegArrayAsString(this._list)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)}},{key:"segmentChanged",value:function(e){this._writeListToPath()}},{key:"clear",value:function(){this._checkPathSynchronizedToList(),this._list.forEach((function(e){e._owningPathSegList=null})),this._list=[],this._writeListToPath()}},{key:"initialize",value:function(e){return this._checkPathSynchronizedToList(),this._list=[e],e._owningPathSegList=this,this._writeListToPath(),e}},{key:"_checkValidIndex",value:function(e){if(isNaN(e)||e<0||e>=this.numberOfItems)throw new Error("INDEX_SIZE_ERR")}},{key:"getItem",value:function(e){return this._checkPathSynchronizedToList(),this._checkValidIndex(e),this._list[e]}},{key:"insertItemBefore",value:function(e,t){return this._checkPathSynchronizedToList(),t>this.numberOfItems&&(t=this.numberOfItems),e._owningPathSegList&&(e=e.clone()),this._list.splice(t,0,e),e._owningPathSegList=this,this._writeListToPath(),e}},{key:"replaceItem",value:function(e,t){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._checkValidIndex(t),this._list[t]=e,e._owningPathSegList=this,this._writeListToPath(),e}},{key:"removeItem",value:function(e){this._checkPathSynchronizedToList(),this._checkValidIndex(e);var t=this._list[e];return this._list.splice(e,1),this._writeListToPath(),t}},{key:"appendItem",value:function(e){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._list.push(e),e._owningPathSegList=this,this._writeListToPath(),e}},{key:"_parsePath",value:function(e){if(!e||!e.length)return[];var t=this,n=function(){function e(){r(this,e),this.pathSegList=[]}return i(e,[{key:"appendSegment",value:function(e){this.pathSegList.push(e)}}]),e}(),a=function(){function e(t){r(this,e),this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()}return i(e,[{key:"_isCurrentSpace",value:function(){var e=this._string[this._currentIndex];return e<=" "&&(" "===e||"\n"===e||"\t"===e||"\r"===e||"\f"===e)}},{key:"_skipOptionalSpaces",value:function(){for(;this._currentIndex="0"&&e<="9")&&t!==SVGPathSeg.PATHSEG_CLOSEPATH?t===SVGPathSeg.PATHSEG_MOVETO_ABS?SVGPathSeg.PATHSEG_LINETO_ABS:t===SVGPathSeg.PATHSEG_MOVETO_REL?SVGPathSeg.PATHSEG_LINETO_REL:t:SVGPathSeg.PATHSEG_UNKNOWN}},{key:"initialCommandIsMoveTo",value:function(){if(!this.hasMoreData())return!0;var e=this.peekSegmentType();return e===SVGPathSeg.PATHSEG_MOVETO_ABS||e===SVGPathSeg.PATHSEG_MOVETO_REL}},{key:"_parseNumber",value:function(){var e=0,t=0,n=1,r=0,a=1,i=1,o=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex"9")&&"."!==this._string.charAt(this._currentIndex))){for(var s=this._currentIndex;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!==s)for(var l=this._currentIndex-1,c=1;l>=s;)t+=c*(this._string.charAt(l--)-"0"),c*=10;if(this._currentIndex=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)n*=10,r+=(this._string.charAt(this._currentIndex)-"0")/n,this._currentIndex+=1}if(this._currentIndex!==o&&this._currentIndex+1=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)e*=10,e+=this._string.charAt(this._currentIndex)-"0",this._currentIndex++}var u=t+r;if(u*=a,e&&(u*=Math.pow(10,i*e)),o!==this._currentIndex)return this._skipOptionalSpacesOrDelimiter(),u}}},{key:"_parseArcFlag",value:function(){if(!(this._currentIndex>=this._endIndex)){var e=!1,t=this._string.charAt(this._currentIndex++);if("0"===t)e=!1;else{if("1"!==t)return;e=!0}return this._skipOptionalSpacesOrDelimiter(),e}}},{key:"parseSegment",value:function(){var e=this._string[this._currentIndex],n=this._pathSegTypeFromChar(e);if(n===SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand===SVGPathSeg.PATHSEG_UNKNOWN)return null;if((n=this._nextCommandHelper(e,this._previousCommand))===SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=n,n){case SVGPathSeg.PATHSEG_MOVETO_REL:return new SVGPathSegMovetoRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_MOVETO_ABS:return new SVGPathSegMovetoAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_REL:return new SVGPathSegLinetoRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_ABS:return new SVGPathSegLinetoAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new SVGPathSegLinetoHorizontalRel(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new SVGPathSegLinetoHorizontalAbs(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new SVGPathSegLinetoVerticalRel(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new SVGPathSegLinetoVerticalAbs(t,this._parseNumber());case SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new SVGPathSegClosePath(t);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:var r={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicRel(t,r.x,r.y,r.x1,r.y1,r.x2,r.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:var a={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicAbs(t,a.x,a.y,a.x1,a.y1,a.x2,a.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:var i={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothRel(t,i.x,i.y,i.x2,i.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:var o={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothAbs(t,o.x,o.y,o.x2,o.y2);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:var s={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticRel(t,s.x,s.y,s.x1,s.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:var l={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticAbs(t,l.x,l.y,l.x1,l.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new SVGPathSegCurvetoQuadraticSmoothRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new SVGPathSegCurvetoQuadraticSmoothAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_ARC_REL:var c={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegArcRel(t,c.x,c.y,c.x1,c.y1,c.arcAngle,c.arcLarge,c.arcSweep);case SVGPathSeg.PATHSEG_ARC_ABS:var u={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegArcAbs(t,u.x,u.y,u.x1,u.y1,u.arcAngle,u.arcLarge,u.arcSweep);default:throw new Error("Unknown path seg type.")}}}]),e}(),o=new n,s=new a(e);if(!s.initialCommandIsMoveTo())return[];for(;s.hasMoreData();){var l=s.parseSegment();if(!l)return[];o.appendSegment(l)}return o.pathSegList}}],[{key:"_pathSegArrayAsString",value:function(e){var t="",n=!0;return e.forEach((function(e){n?(n=!1,t+=e._asPathString()):t+=" "+e._asPathString()})),t}}]),e}();C.prototype.classname="SVGPathSegList",Object.defineProperty(C.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperties(SVGPathElement.prototype,{pathSegList:{get:function(){return this._pathSegList||(this._pathSegList=new C(this)),this._pathSegList},enumerable:!0},normalizedPathSegList:{get:function(){return this.pathSegList},enumerable:!0},animatedPathSegList:{get:function(){return this.pathSegList},enumerable:!0},animatedNormalizedPathSegList:{get:function(){return this.pathSegList},enumerable:!0}}),window.SVGPathSegList=C}}();var m,v=jQuery,y=(Boolean(document.createElementNS&&document.createElementNS(f.SVG,"svg").createSVGRect),navigator.userAgent),_=document.createElementNS(f.SVG,"svg"),b=Boolean(window.opera),x=y.includes("AppleWebKit"),w=y.includes("Gecko/"),S=y.includes("MSIE"),k=y.includes("Chrome/"),C=(y.includes("Windows"),y.includes("Macintosh")),A="ontouchstart"in window,E=Boolean(_.querySelector),G=Boolean(document.evaluate),P=function(){var e=document.createElementNS(f.SVG,"path");e.setAttribute("d","M0,0 10,10");var t=e.pathSegList,n=e.createSVGPathSegLinetoAbs(5,5);try{return t.replaceItem(n,1),!0}catch(e){}return!1}(),I=function(){var e=document.createElementNS(f.SVG,"path");e.setAttribute("d","M0,0 10,10");var t=e.pathSegList,n=e.createSVGPathSegLinetoAbs(5,5);try{return t.insertItemBefore(n,1),!0}catch(e){}return!1}(),T=function(){var e=document.createElementNS(f.SVG,"svg"),t=document.createElementNS(f.SVG,"svg");document.documentElement.append(e),t.setAttribute("x",5),e.append(t);var n=document.createElementNS(f.SVG,"text");n.textContent="a",t.append(n);try{return 0===n.getStartPositionOfChar(0).x}catch(e){return!1}finally{e.remove()}}(),N=function(){var e=document.createElementNS(f.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(f.SVG,"path");t.setAttribute("d","M0,0 C0,0 10,10 10,0"),e.append(t);var n=t.getBBox();return e.remove(),n.height>4&&n.height<5}(),L=function(){var e=document.createElementNS(f.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(f.SVG,"path");t.setAttribute("d","M0,0 10,0");var n=document.createElementNS(f.SVG,"path");n.setAttribute("d","M5,0 15,0");var r=document.createElementNS(f.SVG,"g");r.append(t,n),e.append(r);var a=r.getBBox();return e.remove(),15===a.width}(),M=(function(){var e=document.createElementNS(f.SVG,"rect");e.setAttribute("x",.1);var t=!e.cloneNode(!1).getAttribute("x").includes(",");t||v.alert('NOTE: This version of Opera is known to contain bugs in SVG-edit.\nPlease upgrade to the latest version in which the problems have been fixed.')}(),(m=document.createElementNS(f.SVG,"rect")).setAttribute("style","vector-effect:non-scaling-stroke"),"non-scaling-stroke"===m.style.vectorEffect),O=function(){var t=document.createElementNS(f.SVG,"rect").transform.baseVal,n=_.createSVGTransform();t.appendItem(n);var r=t.getItem(0),a=function(t){return t&&"object"===e(t)&&"function"==typeof t.setMatrix&&"angle"in t};return a(r)&&a(n)&&r.type===n.type&&r.angle===n.angle&&r.matrix.a===n.matrix.a&&r.matrix.b===n.matrix.b&&r.matrix.c===n.matrix.c&&r.matrix.d===n.matrix.d&&r.matrix.e===n.matrix.e&&r.matrix.f===n.matrix.f}(),j=function(){return x},V=function(){return w},R=function(){return S},B=function(){return k},U=function(){return C},F=function(){return A},D=function(){return M}; +var f={HTML:"http://www.w3.org/1999/xhtml",MATH:"http://www.w3.org/1998/Math/MathML",SE:"http://svg-edit.googlecode.com",SVG:"http://www.w3.org/2000/svg",XLINK:"http://www.w3.org/1999/xlink",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"},g=function(){var e={};return Object.entries(f).forEach((function(t){var n=d(t,2),r=n[0],a=n[1];e[a]=r.toLowerCase()})),e};!function(){if(!("SVGPathSeg"in window)){var e=function(){function e(t,n,a){r(this,e),this.pathSegType=t,this.pathSegTypeAsLetter=n,this._owningPathSegList=a}return i(e,[{key:"_segmentChanged",value:function(){this._owningPathSegList&&this._owningPathSegList.segmentChanged(this)}}]),e}();e.prototype.classname="SVGPathSeg",e.PATHSEG_UNKNOWN=0,e.PATHSEG_CLOSEPATH=1,e.PATHSEG_MOVETO_ABS=2,e.PATHSEG_MOVETO_REL=3,e.PATHSEG_LINETO_ABS=4,e.PATHSEG_LINETO_REL=5,e.PATHSEG_CURVETO_CUBIC_ABS=6,e.PATHSEG_CURVETO_CUBIC_REL=7,e.PATHSEG_CURVETO_QUADRATIC_ABS=8,e.PATHSEG_CURVETO_QUADRATIC_REL=9,e.PATHSEG_ARC_ABS=10,e.PATHSEG_ARC_REL=11,e.PATHSEG_LINETO_HORIZONTAL_ABS=12,e.PATHSEG_LINETO_HORIZONTAL_REL=13,e.PATHSEG_LINETO_VERTICAL_ABS=14,e.PATHSEG_LINETO_VERTICAL_REL=15,e.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS=16,e.PATHSEG_CURVETO_CUBIC_SMOOTH_REL=17,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS=18,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL=19;var t=function(t){function n(t){return r(this,n),u(this,l(n).call(this,e.PATHSEG_CLOSEPATH,"z",t))}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegClosePath]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter}},{key:"clone",value:function(){return new n(void 0)}}]),n}(e),n=function(t){function n(t,a,i){var o;return r(this,n),(o=u(this,l(n).call(this,e.PATHSEG_MOVETO_ABS,"M",t)))._x=a,o._y=i,o}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegMovetoAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y)}}]),n}(e);Object.defineProperties(n.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var a=function(t){function n(t,a,i){var o;return r(this,n),(o=u(this,l(n).call(this,e.PATHSEG_MOVETO_REL,"m",t)))._x=a,o._y=i,o}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegMovetoRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y)}}]),n}(e);Object.defineProperties(a.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var o=function(t){function n(t,a,i){var o;return r(this,n),(o=u(this,l(n).call(this,e.PATHSEG_LINETO_ABS,"L",t)))._x=a,o._y=i,o}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegLinetoAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y)}}]),n}(e);Object.defineProperties(o.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var c=function(t){function n(t,a,i){var o;return r(this,n),(o=u(this,l(n).call(this,e.PATHSEG_LINETO_REL,"l",t)))._x=a,o._y=i,o}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegLinetoRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y)}}]),n}(e);Object.defineProperties(c.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var d=function(t){function n(t,a,i,o,s,c,d){var h;return r(this,n),(h=u(this,l(n).call(this,e.PATHSEG_CURVETO_CUBIC_ABS,"C",t)))._x=a,h._y=i,h._x1=o,h._y1=s,h._x2=c,h._y2=d,h}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)}}]),n}(e);Object.defineProperties(d.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var h=function(t){function n(t,a,i,o,s,c,d){var h;return r(this,n),(h=u(this,l(n).call(this,e.PATHSEG_CURVETO_CUBIC_REL,"c",t)))._x=a,h._y=i,h._x1=o,h._y1=s,h._x2=c,h._y2=d,h}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)}}]),n}(e);Object.defineProperties(h.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var p=function(t){function n(t,a,i,o,s){var c;return r(this,n),(c=u(this,l(n).call(this,e.PATHSEG_CURVETO_QUADRATIC_ABS,"Q",t)))._x=a,c._y=i,c._x1=o,c._y1=s,c}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._x1,this._y1)}}]),n}(e);Object.defineProperties(p.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0}});var f=function(t){function n(t,a,i,o,s){var c;return r(this,n),(c=u(this,l(n).call(this,e.PATHSEG_CURVETO_QUADRATIC_REL,"q",t)))._x=a,c._y=i,c._x1=o,c._y1=s,c}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._x1,this._y1)}}]),n}(e);Object.defineProperties(f.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0}});var g=function(t){function n(t,a,i,o,s,c,d,h){var p;return r(this,n),(p=u(this,l(n).call(this,e.PATHSEG_ARC_ABS,"A",t)))._x=a,p._y=i,p._r1=o,p._r2=s,p._angle=c,p._largeArcFlag=d,p._sweepFlag=h,p}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegArcAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)}}]),n}(e);Object.defineProperties(g.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},r1:{get:function(){return this._r1},set:function(e){this._r1=e,this._segmentChanged()},enumerable:!0},r2:{get:function(){return this._r2},set:function(e){this._r2=e,this._segmentChanged()},enumerable:!0},angle:{get:function(){return this._angle},set:function(e){this._angle=e,this._segmentChanged()},enumerable:!0},largeArcFlag:{get:function(){return this._largeArcFlag},set:function(e){this._largeArcFlag=e,this._segmentChanged()},enumerable:!0},sweepFlag:{get:function(){return this._sweepFlag},set:function(e){this._sweepFlag=e,this._segmentChanged()},enumerable:!0}});var m=function(t){function n(t,a,i,o,s,c,d,h){var p;return r(this,n),(p=u(this,l(n).call(this,e.PATHSEG_ARC_REL,"a",t)))._x=a,p._y=i,p._r1=o,p._r2=s,p._angle=c,p._largeArcFlag=d,p._sweepFlag=h,p}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegArcRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)}}]),n}(e);Object.defineProperties(m.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},r1:{get:function(){return this._r1},set:function(e){this._r1=e,this._segmentChanged()},enumerable:!0},r2:{get:function(){return this._r2},set:function(e){this._r2=e,this._segmentChanged()},enumerable:!0},angle:{get:function(){return this._angle},set:function(e){this._angle=e,this._segmentChanged()},enumerable:!0},largeArcFlag:{get:function(){return this._largeArcFlag},set:function(e){this._largeArcFlag=e,this._segmentChanged()},enumerable:!0},sweepFlag:{get:function(){return this._sweepFlag},set:function(e){this._sweepFlag=e,this._segmentChanged()},enumerable:!0}});var v=function(t){function n(t,a){var i;return r(this,n),(i=u(this,l(n).call(this,e.PATHSEG_LINETO_HORIZONTAL_ABS,"H",t)))._x=a,i}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegLinetoHorizontalAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x}},{key:"clone",value:function(){return new n(void 0,this._x)}}]),n}(e);Object.defineProperty(v.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0});var y=function(t){function n(t,a){var i;return r(this,n),(i=u(this,l(n).call(this,e.PATHSEG_LINETO_HORIZONTAL_REL,"h",t)))._x=a,i}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegLinetoHorizontalRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x}},{key:"clone",value:function(){return new n(void 0,this._x)}}]),n}(e);Object.defineProperty(y.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0});var _=function(t){function n(t,a){var i;return r(this,n),(i=u(this,l(n).call(this,e.PATHSEG_LINETO_VERTICAL_ABS,"V",t)))._y=a,i}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegLinetoVerticalAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._y)}}]),n}(e);Object.defineProperty(_.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0});var b=function(t){function n(t,a){var i;return r(this,n),(i=u(this,l(n).call(this,e.PATHSEG_LINETO_VERTICAL_REL,"v",t)))._y=a,i}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegLinetoVerticalRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._y)}}]),n}(e);Object.defineProperty(b.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0});var x=function(t){function n(t,a,i,o,s){var c;return r(this,n),(c=u(this,l(n).call(this,e.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS,"S",t)))._x=a,c._y=i,c._x2=o,c._y2=s,c}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicSmoothAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._x2,this._y2)}}]),n}(e);Object.defineProperties(x.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var w=function(t){function n(t,a,i,o,s){var c;return r(this,n),(c=u(this,l(n).call(this,e.PATHSEG_CURVETO_CUBIC_SMOOTH_REL,"s",t)))._x=a,c._y=i,c._x2=o,c._y2=s,c}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicSmoothRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y,this._x2,this._y2)}}]),n}(e);Object.defineProperties(w.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var S=function(t){function n(t,a,i){var o;return r(this,n),(o=u(this,l(n).call(this,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS,"T",t)))._x=a,o._y=i,o}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticSmoothAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y)}}]),n}(e);Object.defineProperties(S.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var k=function(t){function n(t,a,i){var o;return r(this,n),(o=u(this,l(n).call(this,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL,"t",t)))._x=a,o._y=i,o}return s(n,t),i(n,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticSmoothRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new n(void 0,this._x,this._y)}}]),n}(e);Object.defineProperties(k.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}}),SVGPathElement.prototype.createSVGPathSegClosePath=function(){return new t(void 0)},SVGPathElement.prototype.createSVGPathSegMovetoAbs=function(e,t){return new n(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegMovetoRel=function(e,t){return new a(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegLinetoAbs=function(e,t){return new o(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegLinetoRel=function(e,t){return new c(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs=function(e,t,n,r,a,i){return new d(void 0,e,t,n,r,a,i)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel=function(e,t,n,r,a,i){return new h(void 0,e,t,n,r,a,i)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs=function(e,t,n,r){return new p(void 0,e,t,n,r)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel=function(e,t,n,r){return new f(void 0,e,t,n,r)},SVGPathElement.prototype.createSVGPathSegArcAbs=function(e,t,n,r,a,i,o){return new g(void 0,e,t,n,r,a,i,o)},SVGPathElement.prototype.createSVGPathSegArcRel=function(e,t,n,r,a,i,o){return new m(void 0,e,t,n,r,a,i,o)},SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs=function(e){return new v(void 0,e)},SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel=function(e){return new y(void 0,e)},SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs=function(e){return new _(void 0,e)},SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel=function(e){return new b(void 0,e)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs=function(e,t,n,r){return new x(void 0,e,t,n,r)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel=function(e,t,n,r){return new w(void 0,e,t,n,r)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs=function(e,t){return new S(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel=function(e,t){return new k(void 0,e,t)},"getPathSegAtLength"in SVGPathElement.prototype||(SVGPathElement.prototype.getPathSegAtLength=function(e){if(void 0===e||!isFinite(e))throw new Error("Invalid arguments.");var t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d",this.getAttribute("d"));var n=t.pathSegList.numberOfItems-1;if(n<=0)return 0;do{if(t.pathSegList.removeItem(n),e>t.getTotalLength())break;n--}while(n>0);return n}),window.SVGPathSeg=e,window.SVGPathSegClosePath=t,window.SVGPathSegMovetoAbs=n,window.SVGPathSegMovetoRel=a,window.SVGPathSegLinetoAbs=o,window.SVGPathSegLinetoRel=c,window.SVGPathSegCurvetoCubicAbs=d,window.SVGPathSegCurvetoCubicRel=h,window.SVGPathSegCurvetoQuadraticAbs=p,window.SVGPathSegCurvetoQuadraticRel=f,window.SVGPathSegArcAbs=g,window.SVGPathSegArcRel=m,window.SVGPathSegLinetoHorizontalAbs=v,window.SVGPathSegLinetoHorizontalRel=y,window.SVGPathSegLinetoVerticalAbs=_,window.SVGPathSegLinetoVerticalRel=b,window.SVGPathSegCurvetoCubicSmoothAbs=x,window.SVGPathSegCurvetoCubicSmoothRel=w,window.SVGPathSegCurvetoQuadraticSmoothAbs=S,window.SVGPathSegCurvetoQuadraticSmoothRel=k}if(!("SVGPathSegList"in window&&"appendItem"in window.SVGPathSegList.prototype)){var C=function(){function e(t){r(this,e),this._pathElement=t,this._list=this._parsePath(this._pathElement.getAttribute("d")),this._mutationObserverConfig={attributes:!0,attributeFilter:["d"]},this._pathElementMutationObserver=new MutationObserver(this._updateListFromPathMutations.bind(this)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)}return i(e,[{key:"_checkPathSynchronizedToList",value:function(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())}},{key:"_updateListFromPathMutations",value:function(e){if(this._pathElement){var t=!1;e.forEach((function(e){"d"===e.attributeName&&(t=!0)})),t&&(this._list=this._parsePath(this._pathElement.getAttribute("d")))}}},{key:"_writeListToPath",value:function(){this._pathElementMutationObserver.disconnect(),this._pathElement.setAttribute("d",e._pathSegArrayAsString(this._list)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)}},{key:"segmentChanged",value:function(e){this._writeListToPath()}},{key:"clear",value:function(){this._checkPathSynchronizedToList(),this._list.forEach((function(e){e._owningPathSegList=null})),this._list=[],this._writeListToPath()}},{key:"initialize",value:function(e){return this._checkPathSynchronizedToList(),this._list=[e],e._owningPathSegList=this,this._writeListToPath(),e}},{key:"_checkValidIndex",value:function(e){if(isNaN(e)||e<0||e>=this.numberOfItems)throw new Error("INDEX_SIZE_ERR")}},{key:"getItem",value:function(e){return this._checkPathSynchronizedToList(),this._checkValidIndex(e),this._list[e]}},{key:"insertItemBefore",value:function(e,t){return this._checkPathSynchronizedToList(),t>this.numberOfItems&&(t=this.numberOfItems),e._owningPathSegList&&(e=e.clone()),this._list.splice(t,0,e),e._owningPathSegList=this,this._writeListToPath(),e}},{key:"replaceItem",value:function(e,t){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._checkValidIndex(t),this._list[t]=e,e._owningPathSegList=this,this._writeListToPath(),e}},{key:"removeItem",value:function(e){this._checkPathSynchronizedToList(),this._checkValidIndex(e);var t=this._list[e];return this._list.splice(e,1),this._writeListToPath(),t}},{key:"appendItem",value:function(e){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._list.push(e),e._owningPathSegList=this,this._writeListToPath(),e}},{key:"_parsePath",value:function(e){if(!e||!e.length)return[];var t=this,n=function(){function e(){r(this,e),this.pathSegList=[]}return i(e,[{key:"appendSegment",value:function(e){this.pathSegList.push(e)}}]),e}(),a=function(){function e(t){r(this,e),this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()}return i(e,[{key:"_isCurrentSpace",value:function(){var e=this._string[this._currentIndex];return e<=" "&&(" "===e||"\n"===e||"\t"===e||"\r"===e||"\f"===e)}},{key:"_skipOptionalSpaces",value:function(){for(;this._currentIndex="0"&&e<="9")&&t!==SVGPathSeg.PATHSEG_CLOSEPATH?t===SVGPathSeg.PATHSEG_MOVETO_ABS?SVGPathSeg.PATHSEG_LINETO_ABS:t===SVGPathSeg.PATHSEG_MOVETO_REL?SVGPathSeg.PATHSEG_LINETO_REL:t:SVGPathSeg.PATHSEG_UNKNOWN}},{key:"initialCommandIsMoveTo",value:function(){if(!this.hasMoreData())return!0;var e=this.peekSegmentType();return e===SVGPathSeg.PATHSEG_MOVETO_ABS||e===SVGPathSeg.PATHSEG_MOVETO_REL}},{key:"_parseNumber",value:function(){var e=0,t=0,n=1,r=0,a=1,i=1,o=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex"9")&&"."!==this._string.charAt(this._currentIndex))){for(var s=this._currentIndex;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!==s)for(var l=this._currentIndex-1,c=1;l>=s;)t+=c*(this._string.charAt(l--)-"0"),c*=10;if(this._currentIndex=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)n*=10,r+=(this._string.charAt(this._currentIndex)-"0")/n,this._currentIndex+=1}if(this._currentIndex!==o&&this._currentIndex+1=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)e*=10,e+=this._string.charAt(this._currentIndex)-"0",this._currentIndex++}var u=t+r;if(u*=a,e&&(u*=Math.pow(10,i*e)),o!==this._currentIndex)return this._skipOptionalSpacesOrDelimiter(),u}}},{key:"_parseArcFlag",value:function(){if(!(this._currentIndex>=this._endIndex)){var e=!1,t=this._string.charAt(this._currentIndex++);if("0"===t)e=!1;else{if("1"!==t)return;e=!0}return this._skipOptionalSpacesOrDelimiter(),e}}},{key:"parseSegment",value:function(){var e=this._string[this._currentIndex],n=this._pathSegTypeFromChar(e);if(n===SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand===SVGPathSeg.PATHSEG_UNKNOWN)return null;if((n=this._nextCommandHelper(e,this._previousCommand))===SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=n,n){case SVGPathSeg.PATHSEG_MOVETO_REL:return new SVGPathSegMovetoRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_MOVETO_ABS:return new SVGPathSegMovetoAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_REL:return new SVGPathSegLinetoRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_ABS:return new SVGPathSegLinetoAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new SVGPathSegLinetoHorizontalRel(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new SVGPathSegLinetoHorizontalAbs(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new SVGPathSegLinetoVerticalRel(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new SVGPathSegLinetoVerticalAbs(t,this._parseNumber());case SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new SVGPathSegClosePath(t);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:var r={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicRel(t,r.x,r.y,r.x1,r.y1,r.x2,r.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:var a={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicAbs(t,a.x,a.y,a.x1,a.y1,a.x2,a.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:var i={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothRel(t,i.x,i.y,i.x2,i.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:var o={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothAbs(t,o.x,o.y,o.x2,o.y2);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:var s={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticRel(t,s.x,s.y,s.x1,s.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:var l={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticAbs(t,l.x,l.y,l.x1,l.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new SVGPathSegCurvetoQuadraticSmoothRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new SVGPathSegCurvetoQuadraticSmoothAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_ARC_REL:var c={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegArcRel(t,c.x,c.y,c.x1,c.y1,c.arcAngle,c.arcLarge,c.arcSweep);case SVGPathSeg.PATHSEG_ARC_ABS:var u={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegArcAbs(t,u.x,u.y,u.x1,u.y1,u.arcAngle,u.arcLarge,u.arcSweep);default:throw new Error("Unknown path seg type.")}}}]),e}(),o=new n,s=new a(e);if(!s.initialCommandIsMoveTo())return[];for(;s.hasMoreData();){var l=s.parseSegment();if(!l)return[];o.appendSegment(l)}return o.pathSegList}}],[{key:"_pathSegArrayAsString",value:function(e){var t="",n=!0;return e.forEach((function(e){n?(n=!1,t+=e._asPathString()):t+=" "+e._asPathString()})),t}}]),e}();C.prototype.classname="SVGPathSegList",Object.defineProperty(C.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperties(SVGPathElement.prototype,{pathSegList:{get:function(){return this._pathSegList||(this._pathSegList=new C(this)),this._pathSegList},enumerable:!0},normalizedPathSegList:{get:function(){return this.pathSegList},enumerable:!0},animatedPathSegList:{get:function(){return this.pathSegList},enumerable:!0},animatedNormalizedPathSegList:{get:function(){return this.pathSegList},enumerable:!0}}),window.SVGPathSegList=C}}();var m,v=jQuery,y=(Boolean(document.createElementNS&&document.createElementNS(f.SVG,"svg").createSVGRect),navigator.userAgent),_=document.createElementNS(f.SVG,"svg"),b=Boolean(window.opera),x=y.includes("AppleWebKit"),w=y.includes("Gecko/"),S=y.includes("MSIE"),k=y.includes("Chrome/"),C=(y.includes("Windows"),y.includes("Macintosh")),A="ontouchstart"in window,E=Boolean(_.querySelector),G=Boolean(document.evaluate),P=function(){var e=document.createElementNS(f.SVG,"path");e.setAttribute("d","M0,0 10,10");var t=e.pathSegList,n=e.createSVGPathSegLinetoAbs(5,5);try{return t.replaceItem(n,1),!0}catch(e){}return!1}(),I=function(){var e=document.createElementNS(f.SVG,"path");e.setAttribute("d","M0,0 10,10");var t=e.pathSegList,n=e.createSVGPathSegLinetoAbs(5,5);try{return t.insertItemBefore(n,1),!0}catch(e){}return!1}(),N=function(){var e=document.createElementNS(f.SVG,"svg"),t=document.createElementNS(f.SVG,"svg");document.documentElement.append(e),t.setAttribute("x",5),e.append(t);var n=document.createElementNS(f.SVG,"text");n.textContent="a",t.append(n);try{return 0===n.getStartPositionOfChar(0).x}catch(e){return!1}finally{e.remove()}}(),T=function(){var e=document.createElementNS(f.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(f.SVG,"path");t.setAttribute("d","M0,0 C0,0 10,10 10,0"),e.append(t);var n=t.getBBox();return e.remove(),n.height>4&&n.height<5}(),L=function(){var e=document.createElementNS(f.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(f.SVG,"path");t.setAttribute("d","M0,0 10,0");var n=document.createElementNS(f.SVG,"path");n.setAttribute("d","M5,0 15,0");var r=document.createElementNS(f.SVG,"g");r.append(t,n),e.append(r);var a=r.getBBox();return e.remove(),15===a.width}(),M=(function(){var e=document.createElementNS(f.SVG,"rect");e.setAttribute("x",.1);var t=!e.cloneNode(!1).getAttribute("x").includes(",");t||v.alert('NOTE: This version of Opera is known to contain bugs in SVG-edit.\nPlease upgrade to the latest version in which the problems have been fixed.')}(),(m=document.createElementNS(f.SVG,"rect")).setAttribute("style","vector-effect:non-scaling-stroke"),"non-scaling-stroke"===m.style.vectorEffect),O=function(){var t=document.createElementNS(f.SVG,"rect").transform.baseVal,n=_.createSVGTransform();t.appendItem(n);var r=t.getItem(0),a=function(t){return t&&"object"===e(t)&&"function"==typeof t.setMatrix&&"angle"in t};return a(r)&&a(n)&&r.type===n.type&&r.angle===n.angle&&r.matrix.a===n.matrix.a&&r.matrix.b===n.matrix.b&&r.matrix.c===n.matrix.c&&r.matrix.d===n.matrix.d&&r.matrix.e===n.matrix.e&&r.matrix.f===n.matrix.f}(),j=function(){return x},V=function(){return w},R=function(){return S},B=function(){return k},U=function(){return C},F=function(){return A},D=function(){return M}; /** * A jQuery module to work with SVG attributes. * @module jQueryAttr * @license MIT */ -function H(t){var n=t.fn.attr;return t.fn.attr=function(t,r){var a=this.length;if(!a)return n.call(this,t,r);for(var i=0;i=0)return this._xforms[e];var t=new Error("DOMException with code=INDEX_SIZE_ERR");throw t.code=1,t}},{key:"insertItemBefore",value:function(e,t){var n=null;if(t>=0)if(t=0&&(this._removeFromOtherLists(e),this._xforms[t]=e,n=e,this._list._update()),n}},{key:"removeItem",value:function(e){if(e=0){var t,n=this._xforms[e],r=new Array(this.numberOfItems-1);for(t=0;t=0;t--)this.stack[t].unapply(e);e&&e.handleHistoryEvent(se.AFTER_UNAPPLY,this)}},{key:"elements",value:function(){for(var e=[],t=this.stack.length;t--;)for(var n=this.stack[t].elements(),r=n.length;r--;)e.includes(n[r])||e.push(n[r]);return e}},{key:"addSubCommand",value:function(e){this.stack.push(e)}},{key:"isEmpty",value:function(){return!this.stack.length}}]),t}();pe.type=pe.prototype.type;var fe,ge,me,ve,ye,_e=function(){function e(t){r(this,e),this.handler_=t||null,this.undoStackPointer=0,this.undoStack=[],this.undoChangeStackPointer=-1,this.undoableChangeStack=[]}return i(e,[{key:"resetUndoStack",value:function(){this.undoStack=[],this.undoStackPointer=0}},{key:"getUndoStackSize",value:function(){return this.undoStackPointer}},{key:"getRedoStackSize",value:function(){return this.undoStack.length-this.undoStackPointer}},{key:"getNextUndoCommandText",value:function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():""}},{key:"getNextRedoCommandText",value:function(){return this.undoStackPointer0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)}},{key:"redo",value:function(){this.undoStackPointer0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)}},{key:"addCommandToHistory",value:function(e){this.undoStackPointer0&&(this.undoStack=this.undoStack.splice(0,this.undoStackPointer)),this.undoStack.push(e),this.undoStackPointer=this.undoStack.length}},{key:"beginUndoableChange",value:function(e,t){for(var n=++this.undoChangeStackPointer,r=t.length,a=new Array(r),i=new Array(r);r--;){var o=t[r];nn(o)||(i[r]=o,a[r]=o.getAttribute(e))}this.undoableChangeStack[n]={attrName:e,oldValues:a,elements:i}}},{key:"finishUndoableChange",value:function(){for(var e=this.undoChangeStackPointer--,t=this.undoableChangeStack[e],n=t.attrName,r=new pe("Change "+n),a=t.elements.length;a--;){var i=t.elements[a];if(!nn(i)){var o={};o[n]=t.oldValues[a],o[n]!==i.getAttribute(n)&&r.addSubCommand(new he(i,o,n))}}return this.undoableChangeStack[e]=null,r}}]),e}(),be=Object.freeze({__proto__:null,HistoryEventTypes:se,MoveElementCommand:ce,InsertElementCommand:ue,RemoveElementCommand:de,ChangeElementCommand:he,BatchCommand:pe,UndoManager:_e}),xe=document.createElementNS(f.SVG,"svg"),we=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},Se=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},ke=function(){for(var e=arguments.length,t=new Array(e),n=0;n(n=parseInt(n))){var r=n;n=t,t=r}for(var a=xe.createSVGMatrix(),i=t;i<=n;++i){var o=i>=0&&ie.x&&t.ye.y},Te=jQuery,Ne={2:["x","y"],4:["x","y"],6:["x","y","x1","y1","x2","y2"],8:["x","y","x1","y1"],10:["x","y","r1","r2","angle","largeArcFlag","sweepFlag"],12:["x"],14:["y"],16:["x","y","x2","y2"],18:["x","y"]},Le={},Me=function(e){Object.assign(Le,e.ui)},Oe=[],je=!0,Ve={},Re=null,Be=null,Ue=function(e){Be=e,Oe=[0,"ClosePath"];Te.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],(function(e,t){Oe.push(t+"Abs"),Oe.push(t+"Rel")}))},Fe=function(e,t,n){var r=e.pathSegList;if(I)r.insertItemBefore(t,n);else{for(var a=r.numberOfItems,i=[],o=0;o0?(p=g element");this.elem=t,this.segs=[],this.selected_pts=[],Re=this,this.init()}return i(e,[{key:"init",value:function(){Te(Ye()).find("*").each((function(){Te(this).attr("display","none")}));var e=this.elem.pathSegList,t=e.numberOfItems;this.segs=[],this.selected_pts=[],this.first_seg=null;for(var n=0;n=t?null:i[s+1],u=s-1<0?null:i[s-1];if(2===l.type){if(u&&1!==u.type){var d=i[o];d.next=i[o+1],d.next.prev=d,d.addGrip()}o=s}else if(c&&1===c.type)l.next=i[o+1],l.next.prev=l,l.mate=i[o],l.addGrip(),nn(this.first_seg)&&(this.first_seg=l);else if(c)1!==l.type&&(l.addGrip(),c&&2!==c.type&&(l.next=c,l.next.prev=l));else if(1!==l.type){var h=i[o];h.next=i[o+1],h.next.prev=h,h.addGrip(),l.addGrip(),this.first_seg||(this.first_seg=i[o])}}return this}},{key:"eachSeg",value:function(e){for(var t=this.segs.length,n=0;n=0&&n.selected_pts.push(e)})),this.selected_pts.sort();var r=this.selected_pts.length,a=[];for(a.length=r;r--;){var i=this.selected_pts[r],o=this.segs[i];o.select(!0),a[r]=o.ptgrip}var s=e.subpathIsClosed(this.selected_pts[0]);Be.addPtsToSelection({grips:a,closedSubpath:s})}}],[{key:"subpathIsClosed",value:function(e){var t=!1;return Re.eachSeg((function(n){return n<=e||2!==this.type&&(1!==this.type||(t=!0,!1))})),t}}]),e}(),tt=function(e){var t=Ve[e.id];return t||(t=Ve[e.id]=new et(e)),t},nt=function(e){e in Ve&&delete Ve[e]},rt=function(e,t){var n=e-me,r=t-ve,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)+ye;return n=a*Math.cos(i)+me,r=a*Math.sin(i)+ve,n-=fe,r-=ge,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)-ye,{x:a*Math.cos(i)+fe,y:a*Math.sin(i)+ge}},at=function(){var e=Re.elem;if(ye=Qt(e,!0)){var t=Re.oldbbox;me=t.x+t.width/2,ve=t.y+t.height/2;var n=Rt(e);fe=n.x+n.width/2,ge=n.y+n.height/2;var r=fe-me,a=ge-ve,i=Math.sqrt(r*r+a*a),o=Math.atan2(a,r)+ye;fe=i*Math.cos(o)+me,ge=i*Math.sin(o)+ve;for(var s=e.pathSegList,l=s.numberOfItems;l;){l-=1;var c=s.getItem(l),u=c.pathSegType;if(1!==u){var d=rt(c.x,c.y),h=[d.x,d.y];if(!nn(c.x1)&&!nn(c.x2)){var p=rt(c.x1,c.y1),f=rt(c.x2,c.y2);h.splice(h.length,0,p.x,p.y,f.x,f.y)}Ke(u,l,h)}}Rt(e);var g=Be.getSVGRoot().createSVGTransform(),m=K(e);g.setRotate(180*ye/Math.PI,fe,ge),m.replaceItem(g,0)}},it=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],ot=function(e,t){for(var n=e.pathSegList,r=n.numberOfItems,a=0,i=0,o="",s=null,l=0;l=C-w&&g<=C+w&&m>=A-w&&m<=A+w){S=!0;break}}a=Be.getId(),nt(a);var E,G,P=Zt(a),I=b.numberOfItems;if(S){if(x<=1&&I>=2){var T=b.getItem(0).x,N=b.getItem(0).y;E=4===(G=v.pathSegList.getItem(1)).pathSegType?_.createSVGPathSegLinetoAbs(T,N):_.createSVGPathSegCurvetoCubicAbs(T,N,G.x1/p,G.y1/p,T,N);var L=_.createSVGPathSegClosePath();b.appendItem(E),b.appendItem(L)}else if(I<3)return!1;if(Te(v).remove(),Be.setDrawnPath(null),Be.setStarted(!1),ut){Re.matrix&&Be.remapElement(P,{},Re.matrix.inverse());var M=P.getAttribute("d"),O=Te(Re.elem).attr("d");return Te(Re.elem).attr("d",O+M),Te(P).remove(),Re.matrix&&at(),Ue(),pt.toEditMode(Re.elem),Re.selectPt(),!1}}else{if(!Te.contains(Be.getContainer(),Be.getMouseTarget(e)))return!1;var j=_.pathSegList.numberOfItems,V=_.pathSegList.getItem(j-1),R=V.x,B=V.y;if(e.shiftKey){var U=Pe(R,B,g,m);g=U.x,m=U.y}E=4===(G=v.pathSegList.getItem(1)).pathSegType?_.createSVGPathSegLinetoAbs(Be.round(g),Be.round(m)):_.createSVGPathSegCurvetoCubicAbs(Be.round(g),Be.round(m),G.x1/p,G.y1/p,G.x2/p,G.y2/p),_.pathSegList.appendItem(E),g*=p,m*=p,v.setAttribute("d",["M",g,m,g,m].join(" ")),y=j,ut&&(y+=Re.segs.length),qe(y,g,m)}}else{var F="M"+g+","+m+" ";Be.setDrawnPath(Be.addSVGElementFromJson({element:"path",curStyles:!0,attr:{d:F,id:Be.getNextId(),opacity:Be.getOpacity()/2}})),v.setAttribute("d",["M",d,h,d,h].join(" ")),y=ut?Re.segs.length:0,qe(y,d,h)}}},mouseMove:function(e,t){var n=Be.getCurrentZoom();ht=!0;var r=Be.getDrawnPath();if("path"!==Be.getCurrentMode())if(Re.dragging){var a=ze({x:Re.dragging[0],y:Re.dragging[1]},Re),i=ze({x:e,y:t},Re),o=i.x-a.x,s=i.y-a.y;Re.dragging=[e,t],Re.dragctrl?Re.moveCtrl(o,s):Re.movePts(o,s)}else Re.selected_pts=[],Re.eachSeg((function(e){if(this.next||this.prev){var t=Be.getRubberBox().getBBox(),n=He(this),r={x:n.x,y:n.y,width:0,height:0},a=Ie(t,r);this.select(a),a&&Re.selected_pts.push(this.index)}}));else{if(!r)return;var l=r.pathSegList,c=l.numberOfItems-1;if(lt){var u=We("1c1"),d=We("0c2");u.setAttribute("cx",e),u.setAttribute("cy",t),u.setAttribute("display","inline");var h=lt[0],p=lt[1],f=h+(h-e/n),g=p+(p-t/n);d.setAttribute("cx",f*n),d.setAttribute("cy",g*n),d.setAttribute("display","inline");var m=Xe(1);if($t(m,{x1:e,y1:t,x2:f*n,y2:g*n,display:"inline"}),0===c)ct=[e,t];else{var v=l.getItem(c-1),y=v.x,_=v.y;6===v.pathSegType?(y+=y-v.x2,_+=_-v.y2):ct&&(y=ct[0]/n,_=ct[1]/n),Ke(6,c,[h,p,y,_,f,g],r)}}else{var b=Zt("path_stretch_line");if(b){var x=l.getItem(c);if(6===x.pathSegType){var w=x.x+(x.x-x.x2),S=x.y+(x.y-x.y2);Ke(6,1,[e,t,w*n,S*n,e,t],b)}else ct?Ke(6,1,[e,t,ct[0],ct[1],e,t],b):Ke(4,1,[e,t],b)}}}},mouseUp:function(e,t,n,r){var a=Be.getDrawnPath();if("path"===Be.getCurrentMode())return lt=null,a||(t=Zt(Be.getId()),Be.setStarted(!1),ct=null),{keep:!0,element:t};var i=Be.getRubberBox();if(Re.dragging){var o=Re.cur_pt;Re.dragging=!1,Re.dragctrl=!1,Re.update(),ht&&Re.endChanges("Move path point(s)"),e.shiftKey||ht||Re.selectPt(o)}else i&&"none"!==i.getAttribute("display")?(i.setAttribute("display","none"),i.getAttribute("width")<=2&&i.getAttribute("height")<=2&&pt.toSelectMode(e.target)):pt.toSelectMode(e.target);ht=!1},toEditMode:function(e){Re=tt(e),Be.setCurrentMode("pathedit"),Be.clearSelection(),Re.show(!0).update(),Re.oldbbox=Rt(Re.elem),ut=!1},toSelectMode:function(e){var t=e===Re.elem;Be.setCurrentMode("select"),Re.show(!1),dt=!1,Be.clearSelection(),Re.matrix&&at(),t&&(Be.call("selected",[e]),Be.addToSelection([e],!0))},addSubPath:function(e){e?(Be.setCurrentMode("path"),ut=!0):(pt.clear(!0),pt.toEditMode(Re.elem))},select:function(e){dt===e?(pt.toEditMode(e),Be.setCurrentMode("pathedit")):dt=e},reorient:function(){var e=Be.getSelectedElements()[0];if(e&&0!==Qt(e)){var t=new pe("Reorient path"),n={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new he(e,n)),Be.clearSelection(),this.resetOrientation(e),Be.addCommandToHistory(t),tt(e).show(!1).matrix=null,this.clear(),Be.addToSelection([e],!0),Be.call("changed",Be.getSelectedElements())}},clear:function(e){var t=Be.getDrawnPath();if(dt=null,t){var n=Zt(Be.getId());Te(Zt("path_stretch_line")).remove(),Te(n).remove(),Te(Zt("pathpointgrip_container")).find("*").attr("display","none"),ct=null,Be.setDrawnPath(null),Be.setStarted(!1)}else"pathedit"===Be.getCurrentMode()&&this.toSelectMode();Re&&Re.init().show(!1)},resetOrientation:function(e){if(nn(e)||"path"!==e.nodeName)return!1;var t=K(e),n=Ee(t).matrix;t.clear(),e.removeAttribute("transform");for(var r=e.pathSegList,a=r.numberOfItems,i=function(t){var a=r.getItem(t),i=a.pathSegType;if(1===i)return"continue";var o=[];Te.each(["",1,2],(function(e,t){var r=a["x"+t],i=a["y"+t];if(void 0!==r&&void 0!==i){var s=we(r,i,n);o.splice(o.length,0,s.x,s.y)}})),Ke(i,t,o,e)},o=0;o0){var s=t.getItem(n-1).pathSegType;if(2===s){r(n-1,1),e();break}if(1===s&&t.numberOfItems-1===n){r(n,1),e();break}}}return!1}(),Re.elem.pathSegList.numberOfItems<=1)return pt.toSelectMode(Re.elem),void Be.canvas.deleteSelectedElements();if(Re.init(),Re.clearSelection(),window.opera){var r=Te(Re.elem);r.attr("d",r.attr("d"))}Re.endChanges("Delete path node(s)")}},smoothPolylineIntoPath:function(e){var t,n=e.points,r=n.numberOfItems;if(r>=4){var a=n.getItem(0),i=null,o=[];for(o.push(["M",a.x,",",a.y," C"].join("")),t=1;t<=r-4;t+=3){var s=n.getItem(t),l=n.getItem(t+1),c=n.getItem(t+2);if(i){var u=$e(i,s,a);if(u&&2===u.length){var d=o[o.length-1].split(",");d[2]=u[0].x,d[3]=u[0].y,o[o.length-1]=d.join(","),s=u[1]}}o.push([s.x,s.y,l.x,l.y,c.x,c.y].join(",")),a=c,i=l}for(o.push("L");t)/,"$1$2")},wt=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")};function St(e){if(e=At(e),window.btoa)return window.btoa(e);var t=new Array(4*Math.floor((e.length+2)/3)),n=0,r=0;do{var a=e.charCodeAt(n++),i=e.charCodeAt(n++),o=e.charCodeAt(n++),s=a>>2,l=(3&a)<<4|i>>4,c=(15&i)<<2|o>>6,u=63&o;isNaN(i)?(c=64,u=64):isNaN(o)&&(u=64),t[r++]=gt.charAt(s),t[r++]=gt.charAt(l),t[r++]=gt.charAt(c),t[r++]=gt.charAt(u)}while(n>4,l=(15&a)<<4|i>>2,c=(3&i)<<6|o;t+=String.fromCharCode(s),64!==i&&(t+=String.fromCharCode(l)),64!==o&&(t+=String.fromCharCode(c))}while(nSVG-edit "],{type:"text/html"});return Gt(e)}(),It=function(e){var t,n;e.includes("0?t=t[0]:(t=e.ownerDocument.createElementNS(f.SVG,"defs"),e.firstChild?e.insertBefore(t,e.firstChild.nextSibling):e.append(t)),t},jt=function(e){for(var t=e.pathSegList,n=t.numberOfItems,r=[[],[]],a=t.getItem(0),i=[a.x,a.y],o=function(e,t,n,r){return function(a){return 1-Math.pow(a,3)*i[e]+3-Math.pow(a,2)*a*t[e]+3*(1-a)*Math.pow(a,2)*n[e]+Math.pow(a,3)*r[e]}},s=0;s0&&y<1&&r[h].push(p(y));var _=(-f-Math.sqrt(v))/(2*g);_>0&&_<1&&r[h].push(p(_))}}else{if(0===f)continue;var b=-m/f;b>0&&b<1&&r[h].push(p(b))}}i=d}else r[0].push(l.x),r[1].push(l.y)}var x=Math.min.apply(null,r[0]),w=Math.max.apply(null,r[0])-x,S=Math.min.apply(null,r[1]);return{x:x,y:S,width:w,height:Math.max.apply(null,r[1])-S}};function Vt(e){if(L)try{return e.getBBox()}catch(e){}var t,n,r=ft.data(e,"ref"),a=null;r?(n=ft(r).children().clone().attr("visibility","hidden"),ft(bt).append(n),a=n.filter("line, path")):a=ft(e).find("line, path");var i=!1;if(a.length)if(a.each((function(){var e=this.getBBox();e.width&&e.height||(i=!0)})),i){var o=r?n:ft(e).children();t=qt(o)}else t=e.getBBox();else t=e.getBBox();return r&&n.remove(),t}var Rt=function(e){var t=e||vt.geSelectedElements()[0];if(1!==e.nodeType)return null;var n,r=t.nodeName,a=null;switch(r){case"text":""===t.textContent?(t.textContent="a",a=t.getBBox(),t.textContent=""):t.getBBox&&(a=t.getBBox());break;case"path":N?t.getBBox&&(a=t.getBBox()):a=jt(t);break;case"g":case"a":a=Vt(t);break;default:if("use"===r&&(a=Vt(t)),"use"===r||"foreignObject"===r&&j()){if(a||(a=t.getBBox()),!j()){var i=a,o=i.x,s=i.y;a={width:i.width,height:i.height,x:o+parseFloat(t.getAttribute("x")||0),y:s+parseFloat(t.getAttribute("y")||0)}}}else if(mt.includes(r))if(t)try{a=t.getBBox()}catch(e){var l=t.getExtentOfChar(0),c=t.getComputedTextLength();a={x:l.x,y:l.y,width:c,height:l.height}}else{var u=ft(t).closest("foreignObject");u.length&&u[0].getBBox&&(a=u[0].getBBox())}}return a&&(a={x:(n=a).x,y:n.y,width:n.width,height:n.height}),a},Bt=function(e){var t="";return ft.each(e,(function(e,n){var r=d(n,2),a=r[0],i=r[1];t+=a;for(var o=0;o-.001&&n<.001||(n<-89.99||n>89.99))}(i,o)){if(["ellipse","path","line","polyline","polygon"].includes(e.tagName))r=s=Dt(e,t,n);else if("rect"===e.tagName){var l=e.getAttribute("rx"),c=e.getAttribute("ry");(l||c)&&(r=s=Dt(e,t,n))}}if(!s){var u=Ee(a).matrix;r=Ae(r.x,r.y,r.width,r.height,u).aabox}}return r};function zt(e){var t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}var qt=function(e,t,n){if(!e||!e.length)return!1;var r;if(ft.each(e,(function(){r||this.parentNode&&(r=Ht(this,t,n))})),void 0===r)return null;var a=r.x+r.width,i=r.y+r.height,o=r.x,s=r.y;if(1===e.length){var l=zt(e[0]);o-=l,s-=l,a+=l,i+=l}else ft.each(e,(function(e,r){var l=Ht(r,t,n);if(l){var c=zt(r);o=Math.min(o,l.x-c),s=Math.min(s,l.y-c),1===r.nodeType&&(a=Math.max(a,l.x+l.width+c),i=Math.max(i,l.y+l.height+c))}}));return r.x=o,r.y=s,r.width=a-o,r.height=i-s,r},Yt=function(e){e||(e=ft(vt.getSVGContent()).children());var t=[];return ft(e).children().each((function(e,n){n.getBBox&&t.push(n)})),t.reverse()},Wt=function(e){return e||(e=Yt()),qt(e,vt.addSVGElementFromJson,vt.pathActions)},Xt=function(e,t){if(!e)return 0;for(var n=e.numberOfItems,r=0;r");var t=e.shortcut||"";rn("#cmenu_canvas").append("
  • "+e.label+""+t+"
  • ")}(e)}))}; +function H(t){var n=t.fn.attr;return t.fn.attr=function(t,r){var a=this.length;if(!a)return n.call(this,t,r);for(var i=0;i=0)return this._xforms[e];var t=new Error("DOMException with code=INDEX_SIZE_ERR");throw t.code=1,t}},{key:"insertItemBefore",value:function(e,t){var n=null;if(t>=0)if(t=0&&(this._removeFromOtherLists(e),this._xforms[t]=e,n=e,this._list._update()),n}},{key:"removeItem",value:function(e){if(e=0){var t,n=this._xforms[e],r=new Array(this.numberOfItems-1);for(t=0;t=0;t--)this.stack[t].unapply(e);e&&e.handleHistoryEvent(se.AFTER_UNAPPLY,this)}},{key:"elements",value:function(){for(var e=[],t=this.stack.length;t--;)for(var n=this.stack[t].elements(),r=n.length;r--;)e.includes(n[r])||e.push(n[r]);return e}},{key:"addSubCommand",value:function(e){this.stack.push(e)}},{key:"isEmpty",value:function(){return!this.stack.length}}]),t}();pe.type=pe.prototype.type;var fe,ge,me,ve,ye,_e=function(){function e(t){r(this,e),this.handler_=t||null,this.undoStackPointer=0,this.undoStack=[],this.undoChangeStackPointer=-1,this.undoableChangeStack=[]}return i(e,[{key:"resetUndoStack",value:function(){this.undoStack=[],this.undoStackPointer=0}},{key:"getUndoStackSize",value:function(){return this.undoStackPointer}},{key:"getRedoStackSize",value:function(){return this.undoStack.length-this.undoStackPointer}},{key:"getNextUndoCommandText",value:function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():""}},{key:"getNextRedoCommandText",value:function(){return this.undoStackPointer0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)}},{key:"redo",value:function(){this.undoStackPointer0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)}},{key:"addCommandToHistory",value:function(e){this.undoStackPointer0&&(this.undoStack=this.undoStack.splice(0,this.undoStackPointer)),this.undoStack.push(e),this.undoStackPointer=this.undoStack.length}},{key:"beginUndoableChange",value:function(e,t){for(var n=++this.undoChangeStackPointer,r=t.length,a=new Array(r),i=new Array(r);r--;){var o=t[r];nn(o)||(i[r]=o,a[r]=o.getAttribute(e))}this.undoableChangeStack[n]={attrName:e,oldValues:a,elements:i}}},{key:"finishUndoableChange",value:function(){for(var e=this.undoChangeStackPointer--,t=this.undoableChangeStack[e],n=t.attrName,r=new pe("Change "+n),a=t.elements.length;a--;){var i=t.elements[a];if(!nn(i)){var o={};o[n]=t.oldValues[a],o[n]!==i.getAttribute(n)&&r.addSubCommand(new he(i,o,n))}}return this.undoableChangeStack[e]=null,r}}]),e}(),be=Object.freeze({__proto__:null,HistoryEventTypes:se,MoveElementCommand:ce,InsertElementCommand:ue,RemoveElementCommand:de,ChangeElementCommand:he,BatchCommand:pe,UndoManager:_e}),xe=document.createElementNS(f.SVG,"svg"),we=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},Se=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},ke=function(){for(var e=arguments.length,t=new Array(e),n=0;n(n=parseInt(n))){var r=n;n=t,t=r}for(var a=xe.createSVGMatrix(),i=t;i<=n;++i){var o=i>=0&&ie.x&&t.ye.y},Ne=jQuery,Te={2:["x","y"],4:["x","y"],6:["x","y","x1","y1","x2","y2"],8:["x","y","x1","y1"],10:["x","y","r1","r2","angle","largeArcFlag","sweepFlag"],12:["x"],14:["y"],16:["x","y","x2","y2"],18:["x","y"]},Le={},Me=function(e){Object.assign(Le,e.ui)},Oe=[],je=!0,Ve={},Re=null,Be=null,Ue=function(e){Be=e,Oe=[0,"ClosePath"];Ne.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],(function(e,t){Oe.push(t+"Abs"),Oe.push(t+"Rel")}))},Fe=function(e,t,n){var r=e.pathSegList;if(I)r.insertItemBefore(t,n);else{for(var a=r.numberOfItems,i=[],o=0;o0?(p=g element");this.elem=t,this.segs=[],this.selected_pts=[],Re=this,this.init()}return i(e,[{key:"init",value:function(){Ne(Ye()).find("*").each((function(){Ne(this).attr("display","none")}));var e=this.elem.pathSegList,t=e.numberOfItems;this.segs=[],this.selected_pts=[],this.first_seg=null;for(var n=0;n=t?null:i[s+1],u=s-1<0?null:i[s-1];if(2===l.type){if(u&&1!==u.type){var d=i[o];d.next=i[o+1],d.next.prev=d,d.addGrip()}o=s}else if(c&&1===c.type)l.next=i[o+1],l.next.prev=l,l.mate=i[o],l.addGrip(),nn(this.first_seg)&&(this.first_seg=l);else if(c)1!==l.type&&(l.addGrip(),c&&2!==c.type&&(l.next=c,l.next.prev=l));else if(1!==l.type){var h=i[o];h.next=i[o+1],h.next.prev=h,h.addGrip(),l.addGrip(),this.first_seg||(this.first_seg=i[o])}}return this}},{key:"eachSeg",value:function(e){for(var t=this.segs.length,n=0;n=0&&n.selected_pts.push(e)})),this.selected_pts.sort();var r=this.selected_pts.length,a=[];for(a.length=r;r--;){var i=this.selected_pts[r],o=this.segs[i];o.select(!0),a[r]=o.ptgrip}var s=e.subpathIsClosed(this.selected_pts[0]);Be.addPtsToSelection({grips:a,closedSubpath:s})}}],[{key:"subpathIsClosed",value:function(e){var t=!1;return Re.eachSeg((function(n){return n<=e||2!==this.type&&(1!==this.type||(t=!0,!1))})),t}}]),e}(),tt=function(e){var t=Ve[e.id];return t||(t=Ve[e.id]=new et(e)),t},nt=function(e){e in Ve&&delete Ve[e]},rt=function(e,t){var n=e-me,r=t-ve,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)+ye;return n=a*Math.cos(i)+me,r=a*Math.sin(i)+ve,n-=fe,r-=ge,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)-ye,{x:a*Math.cos(i)+fe,y:a*Math.sin(i)+ge}},at=function(){var e=Re.elem;if(ye=Qt(e,!0)){var t=Re.oldbbox;me=t.x+t.width/2,ve=t.y+t.height/2;var n=Rt(e);fe=n.x+n.width/2,ge=n.y+n.height/2;var r=fe-me,a=ge-ve,i=Math.sqrt(r*r+a*a),o=Math.atan2(a,r)+ye;fe=i*Math.cos(o)+me,ge=i*Math.sin(o)+ve;for(var s=e.pathSegList,l=s.numberOfItems;l;){l-=1;var c=s.getItem(l),u=c.pathSegType;if(1!==u){var d=rt(c.x,c.y),h=[d.x,d.y];if(!nn(c.x1)&&!nn(c.x2)){var p=rt(c.x1,c.y1),f=rt(c.x2,c.y2);h.splice(h.length,0,p.x,p.y,f.x,f.y)}Ke(u,l,h)}}Rt(e);var g=Be.getSVGRoot().createSVGTransform(),m=K(e);g.setRotate(180*ye/Math.PI,fe,ge),m.replaceItem(g,0)}},it=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],ot=function(e,t){for(var n=e.pathSegList,r=n.numberOfItems,a=0,i=0,o="",s=null,l=0;l=C-w&&g<=C+w&&m>=A-w&&m<=A+w){S=!0;break}}a=Be.getId(),nt(a);var E,G,P=Zt(a),I=b.numberOfItems;if(S){if(x<=1&&I>=2){var N=b.getItem(0).x,T=b.getItem(0).y;E=4===(G=v.pathSegList.getItem(1)).pathSegType?_.createSVGPathSegLinetoAbs(N,T):_.createSVGPathSegCurvetoCubicAbs(N,T,G.x1/p,G.y1/p,N,T);var L=_.createSVGPathSegClosePath();b.appendItem(E),b.appendItem(L)}else if(I<3)return!1;if(Ne(v).remove(),Be.setDrawnPath(null),Be.setStarted(!1),ut){Re.matrix&&Be.remapElement(P,{},Re.matrix.inverse());var M=P.getAttribute("d"),O=Ne(Re.elem).attr("d");return Ne(Re.elem).attr("d",O+M),Ne(P).remove(),Re.matrix&&at(),Ue(),pt.toEditMode(Re.elem),Re.selectPt(),!1}}else{if(!Ne.contains(Be.getContainer(),Be.getMouseTarget(e)))return!1;var j=_.pathSegList.numberOfItems,V=_.pathSegList.getItem(j-1),R=V.x,B=V.y;if(e.shiftKey){var U=Pe(R,B,g,m);g=U.x,m=U.y}E=4===(G=v.pathSegList.getItem(1)).pathSegType?_.createSVGPathSegLinetoAbs(Be.round(g),Be.round(m)):_.createSVGPathSegCurvetoCubicAbs(Be.round(g),Be.round(m),G.x1/p,G.y1/p,G.x2/p,G.y2/p),_.pathSegList.appendItem(E),g*=p,m*=p,v.setAttribute("d",["M",g,m,g,m].join(" ")),y=j,ut&&(y+=Re.segs.length),qe(y,g,m)}}else{var F="M"+g+","+m+" ";Be.setDrawnPath(Be.addSVGElementFromJson({element:"path",curStyles:!0,attr:{d:F,id:Be.getNextId(),opacity:Be.getOpacity()/2}})),v.setAttribute("d",["M",d,h,d,h].join(" ")),y=ut?Re.segs.length:0,qe(y,d,h)}}},mouseMove:function(e,t){var n=Be.getCurrentZoom();ht=!0;var r=Be.getDrawnPath();if("path"!==Be.getCurrentMode())if(Re.dragging){var a=ze({x:Re.dragging[0],y:Re.dragging[1]},Re),i=ze({x:e,y:t},Re),o=i.x-a.x,s=i.y-a.y;Re.dragging=[e,t],Re.dragctrl?Re.moveCtrl(o,s):Re.movePts(o,s)}else Re.selected_pts=[],Re.eachSeg((function(e){if(this.next||this.prev){var t=Be.getRubberBox().getBBox(),n=He(this),r={x:n.x,y:n.y,width:0,height:0},a=Ie(t,r);this.select(a),a&&Re.selected_pts.push(this.index)}}));else{if(!r)return;var l=r.pathSegList,c=l.numberOfItems-1;if(lt){var u=We("1c1"),d=We("0c2");u.setAttribute("cx",e),u.setAttribute("cy",t),u.setAttribute("display","inline");var h=lt[0],p=lt[1],f=h+(h-e/n),g=p+(p-t/n);d.setAttribute("cx",f*n),d.setAttribute("cy",g*n),d.setAttribute("display","inline");var m=Xe(1);if($t(m,{x1:e,y1:t,x2:f*n,y2:g*n,display:"inline"}),0===c)ct=[e,t];else{var v=l.getItem(c-1),y=v.x,_=v.y;6===v.pathSegType?(y+=y-v.x2,_+=_-v.y2):ct&&(y=ct[0]/n,_=ct[1]/n),Ke(6,c,[h,p,y,_,f,g],r)}}else{var b=Zt("path_stretch_line");if(b){var x=l.getItem(c);if(6===x.pathSegType){var w=x.x+(x.x-x.x2),S=x.y+(x.y-x.y2);Ke(6,1,[e,t,w*n,S*n,e,t],b)}else ct?Ke(6,1,[e,t,ct[0],ct[1],e,t],b):Ke(4,1,[e,t],b)}}}},mouseUp:function(e,t,n,r){var a=Be.getDrawnPath();if("path"===Be.getCurrentMode())return lt=null,a||(t=Zt(Be.getId()),Be.setStarted(!1),ct=null),{keep:!0,element:t};var i=Be.getRubberBox();if(Re.dragging){var o=Re.cur_pt;Re.dragging=!1,Re.dragctrl=!1,Re.update(),ht&&Re.endChanges("Move path point(s)"),e.shiftKey||ht||Re.selectPt(o)}else i&&"none"!==i.getAttribute("display")?(i.setAttribute("display","none"),i.getAttribute("width")<=2&&i.getAttribute("height")<=2&&pt.toSelectMode(e.target)):pt.toSelectMode(e.target);ht=!1},toEditMode:function(e){Re=tt(e),Be.setCurrentMode("pathedit"),Be.clearSelection(),Re.show(!0).update(),Re.oldbbox=Rt(Re.elem),ut=!1},toSelectMode:function(e){var t=e===Re.elem;Be.setCurrentMode("select"),Re.show(!1),dt=!1,Be.clearSelection(),Re.matrix&&at(),t&&(Be.call("selected",[e]),Be.addToSelection([e],!0))},addSubPath:function(e){e?(Be.setCurrentMode("path"),ut=!0):(pt.clear(!0),pt.toEditMode(Re.elem))},select:function(e){dt===e?(pt.toEditMode(e),Be.setCurrentMode("pathedit")):dt=e},reorient:function(){var e=Be.getSelectedElements()[0];if(e&&0!==Qt(e)){var t=new pe("Reorient path"),n={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new he(e,n)),Be.clearSelection(),this.resetOrientation(e),Be.addCommandToHistory(t),tt(e).show(!1).matrix=null,this.clear(),Be.addToSelection([e],!0),Be.call("changed",Be.getSelectedElements())}},clear:function(e){var t=Be.getDrawnPath();if(dt=null,t){var n=Zt(Be.getId());Ne(Zt("path_stretch_line")).remove(),Ne(n).remove(),Ne(Zt("pathpointgrip_container")).find("*").attr("display","none"),ct=null,Be.setDrawnPath(null),Be.setStarted(!1)}else"pathedit"===Be.getCurrentMode()&&this.toSelectMode();Re&&Re.init().show(!1)},resetOrientation:function(e){if(nn(e)||"path"!==e.nodeName)return!1;var t=K(e),n=Ee(t).matrix;t.clear(),e.removeAttribute("transform");for(var r=e.pathSegList,a=r.numberOfItems,i=function(t){var a=r.getItem(t),i=a.pathSegType;if(1===i)return"continue";var o=[];Ne.each(["",1,2],(function(e,t){var r=a["x"+t],i=a["y"+t];if(void 0!==r&&void 0!==i){var s=we(r,i,n);o.splice(o.length,0,s.x,s.y)}})),Ke(i,t,o,e)},o=0;o0){var s=t.getItem(n-1).pathSegType;if(2===s){r(n-1,1),e();break}if(1===s&&t.numberOfItems-1===n){r(n,1),e();break}}}return!1}(),Re.elem.pathSegList.numberOfItems<=1)return pt.toSelectMode(Re.elem),void Be.canvas.deleteSelectedElements();if(Re.init(),Re.clearSelection(),window.opera){var r=Ne(Re.elem);r.attr("d",r.attr("d"))}Re.endChanges("Delete path node(s)")}},smoothPolylineIntoPath:function(e){var t,n=e.points,r=n.numberOfItems;if(r>=4){var a=n.getItem(0),i=null,o=[];for(o.push(["M",a.x,",",a.y," C"].join("")),t=1;t<=r-4;t+=3){var s=n.getItem(t),l=n.getItem(t+1),c=n.getItem(t+2);if(i){var u=$e(i,s,a);if(u&&2===u.length){var d=o[o.length-1].split(",");d[2]=u[0].x,d[3]=u[0].y,o[o.length-1]=d.join(","),s=u[1]}}o.push([s.x,s.y,l.x,l.y,c.x,c.y].join(",")),a=c,i=l}for(o.push("L");t)/,"$1$2")},wt=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")};function St(e){if(e=At(e),window.btoa)return window.btoa(e);var t=new Array(4*Math.floor((e.length+2)/3)),n=0,r=0;do{var a=e.charCodeAt(n++),i=e.charCodeAt(n++),o=e.charCodeAt(n++),s=a>>2,l=(3&a)<<4|i>>4,c=(15&i)<<2|o>>6,u=63&o;isNaN(i)?(c=64,u=64):isNaN(o)&&(u=64),t[r++]=gt.charAt(s),t[r++]=gt.charAt(l),t[r++]=gt.charAt(c),t[r++]=gt.charAt(u)}while(n>4,l=(15&a)<<4|i>>2,c=(3&i)<<6|o;t+=String.fromCharCode(s),64!==i&&(t+=String.fromCharCode(l)),64!==o&&(t+=String.fromCharCode(c))}while(nSVG-edit "],{type:"text/html"});return Gt(e)}(),It=function(e){var t,n;e.includes("0?t=t[0]:(t=e.ownerDocument.createElementNS(f.SVG,"defs"),e.firstChild?e.insertBefore(t,e.firstChild.nextSibling):e.append(t)),t},jt=function(e){for(var t=e.pathSegList,n=t.numberOfItems,r=[[],[]],a=t.getItem(0),i=[a.x,a.y],o=function(e,t,n,r){return function(a){return 1-Math.pow(a,3)*i[e]+3-Math.pow(a,2)*a*t[e]+3*(1-a)*Math.pow(a,2)*n[e]+Math.pow(a,3)*r[e]}},s=0;s0&&y<1&&r[h].push(p(y));var _=(-f-Math.sqrt(v))/(2*g);_>0&&_<1&&r[h].push(p(_))}}else{if(0===f)continue;var b=-m/f;b>0&&b<1&&r[h].push(p(b))}}i=d}else r[0].push(l.x),r[1].push(l.y)}var x=Math.min.apply(null,r[0]),w=Math.max.apply(null,r[0])-x,S=Math.min.apply(null,r[1]);return{x:x,y:S,width:w,height:Math.max.apply(null,r[1])-S}};function Vt(e){if(L)try{return e.getBBox()}catch(e){}var t,n,r=ft.data(e,"ref"),a=null;r?(n=ft(r).children().clone().attr("visibility","hidden"),ft(bt).append(n),a=n.filter("line, path")):a=ft(e).find("line, path");var i=!1;if(a.length)if(a.each((function(){var e=this.getBBox();e.width&&e.height||(i=!0)})),i){var o=r?n:ft(e).children();t=qt(o)}else t=e.getBBox();else t=e.getBBox();return r&&n.remove(),t}var Rt=function(e){var t=e||vt.geSelectedElements()[0];if(1!==e.nodeType)return null;var n,r=t.nodeName,a=null;switch(r){case"text":""===t.textContent?(t.textContent="a",a=t.getBBox(),t.textContent=""):t.getBBox&&(a=t.getBBox());break;case"path":T?t.getBBox&&(a=t.getBBox()):a=jt(t);break;case"g":case"a":a=Vt(t);break;default:if("use"===r&&(a=Vt(t)),"use"===r||"foreignObject"===r&&j()){if(a||(a=t.getBBox()),!j()){var i=a,o=i.x,s=i.y;a={width:i.width,height:i.height,x:o+parseFloat(t.getAttribute("x")||0),y:s+parseFloat(t.getAttribute("y")||0)}}}else if(mt.includes(r))if(t)try{a=t.getBBox()}catch(e){var l=t.getExtentOfChar(0),c=t.getComputedTextLength();a={x:l.x,y:l.y,width:c,height:l.height}}else{var u=ft(t).closest("foreignObject");u.length&&u[0].getBBox&&(a=u[0].getBBox())}}return a&&(a={x:(n=a).x,y:n.y,width:n.width,height:n.height}),a},Bt=function(e){var t="";return ft.each(e,(function(e,n){var r=d(n,2),a=r[0],i=r[1];t+=a;for(var o=0;o-.001&&n<.001||(n<-89.99||n>89.99))}(i,o)){if(["ellipse","path","line","polyline","polygon"].includes(e.tagName))r=s=Dt(e,t,n);else if("rect"===e.tagName){var l=e.getAttribute("rx"),c=e.getAttribute("ry");(l||c)&&(r=s=Dt(e,t,n))}}if(!s){var u=Ee(a).matrix;r=Ae(r.x,r.y,r.width,r.height,u).aabox}}return r};function zt(e){var t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}var qt=function(e,t,n){if(!e||!e.length)return!1;var r;if(ft.each(e,(function(){r||this.parentNode&&(r=Ht(this,t,n))})),void 0===r)return null;var a=r.x+r.width,i=r.y+r.height,o=r.x,s=r.y;if(1===e.length){var l=zt(e[0]);o-=l,s-=l,a+=l,i+=l}else ft.each(e,(function(e,r){var l=Ht(r,t,n);if(l){var c=zt(r);o=Math.min(o,l.x-c),s=Math.min(s,l.y-c),1===r.nodeType&&(a=Math.max(a,l.x+l.width+c),i=Math.max(i,l.y+l.height+c))}}));return r.x=o,r.y=s,r.width=a-o,r.height=i-s,r},Yt=function(e){e||(e=ft(vt.getSVGContent()).children());var t=[];return ft(e).children().each((function(e,n){n.getBBox&&t.push(n)})),t.reverse()},Wt=function(e){return e||(e=Yt()),qt(e,vt.addSVGElementFromJson,vt.pathActions)},Xt=function(e,t){if(!e)return 0;for(var n=e.numberOfItems,r=0;r");var t=e.shortcut||"";rn("#cmenu_canvas").append("
  • "+e.label+""+t+"
  • ")}(e)}))}; /** * Adapted from {@link https://github.com/uupaa/dynamic-import-polyfill/blob/master/importModule.js}. * @module importModule * @license MIT */ -function sn(e){var t=document.createElement("a");return t.setAttribute("href",e),t.cloneNode(!1).href}function ln(e,t){["id","class","type"].forEach((function(n){n in t&&(e[n]=t[n])}))}function cn(e,t){return un(e,o({},t,{returnDefault:!0}))}function un(e,t){return dn.apply(this,arguments)}function dn(){return(dn=n(regeneratorRuntime.mark((function e(t,n){var r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.global,a=n.returnDefault,!!("svgEditor"in window&&window.svgEditor&&!1===window.svgEditor.modules)){e.next=4;break}return e.abrupt("return",pn(t,void 0,{returnDefault:a}));case 4:return e.next=6,hn(t);case 6:return e.abrupt("return",window[r]);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function hn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Array.isArray(e)?Promise.all(e.map((function(e){return hn(e,t)}))):new Promise((function(n,r){var a=document.createElement("script");function i(){r(new Error("Failed to import: ".concat(e))),s()}function o(){n(),s()}var s=function(){a.removeEventListener("error",i),a.removeEventListener("load",o),a.remove(),a.src=""};a.defer="defer",ln(a,t),a.addEventListener("error",i),a.addEventListener("load",o),a.src=e,document.head.append(a)}))}function pn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.returnDefault,a=void 0!==r&&r;return Array.isArray(e)?Promise.all(e.map((function(e){return pn(e,t)}))):new Promise((function(n,r){var i="$importModule$"+Math.random().toString(32).slice(2),o=document.createElement("script");function s(){r(new Error("Failed to import: ".concat(e))),c()}function l(){n(window[i]),c()}var c=function(){delete window[i],o.removeEventListener("error",s),o.removeEventListener("load",l),o.remove(),URL.revokeObjectURL(o.src),o.src=""};ln(o,t),o.defer="defer",o.type="module",o.addEventListener("error",s),o.addEventListener("load",l);var u=sn(e),d="import * as m from '".concat(u.replace(/'/g,"\\'"),"'; window.").concat(i," = ").concat(a?"m.default || ":"","m;"),h=new Blob([d],{type:"text/javascript"});o.src=URL.createObjectURL(h),document.head.append(o)}))}var fn={true:!0,false:!1,null:null};function gn(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ok:"Ok",cancel:"Cancel"};t("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"}).css("position","absolute");var r=t("#dialog_box"),a=t("#dialog_buttons"),i=t("#dialog_content");function o(o,s,l,c,u,d){i.html("

    "+s.replace(/\n/g,"

    ")+"

    ").toggleClass("prompt","prompt"===o),a.empty();var h=t('').appendTo(a);return new Promise((function(p,f){var g,m;if("alert"!==o&&t('').appendTo(a).click((function(){r.hide(),p(!1)})),"prompt"===o)(g=t('').prependTo(a)).val(l||""),g.bind("keydown","return",(function(){h.click()}));else if("select"===o){var v=t('
    ');if(g=t('').appendTo(y)).val(d.value),d.tooltip&&y.attr("title",d.tooltip),m.prop("checked",Boolean(d.checked)),v.append(t("
    ").append(y))}t.each(c||[],(function(n,r){"object"===e(r)?g.append(t("