diff --git a/.eslintrc.js b/.eslintrc.js index 2932a3c6..f768c89a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -12,7 +12,7 @@ module.exports = { browser: true }, settings: { - polyfills: ["url", "promises", "fetch", "queryselector"], + polyfills: ["url", "promises", "fetch", "queryselector", "object-values"], jsdoc: { additionalTagNames: { // In case we need to extend @@ -145,6 +145,8 @@ module.exports = { "max-len": ["off", { ignoreUrls: true, ignoreRegExpLiterals: true - }] + }], + "unicorn/prefer-query-selector": ["off"], + "unicorn/prefer-node-append": ["off"] } }; diff --git a/dist/canvg.js b/dist/canvg.js index 625a4bcb..f9c3c748 100644 --- a/dist/canvg.js +++ b/dist/canvg.js @@ -527,11 +527,10 @@ var canvg = (function (exports) { }(); RGBColor.getHelpXML = function () { - var examples = _toConsumableArray(colorDefs.flatMap(function (_ref2) { + var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) { var example = _ref2.example; return example; - })).concat(_toConsumableArray(Object.keys(simpleColors))); - + })), _toConsumableArray(Object.keys(simpleColors))); var xml = document.createElement('ul'); xml.setAttribute('id', 'rgbcolor-examples'); xml.append.apply(xml, _toConsumableArray(examples.map(function (example) { @@ -553,11 +552,11 @@ var canvg = (function (exports) { function _typeof$1(obj) { if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") { - _typeof$1 = function _typeof$$1(obj) { + _typeof$1 = function _typeof$1(obj) { return _typeof(obj); }; } else { - _typeof$1 = function _typeof$$1(obj) { + _typeof$1 = function _typeof$1(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj); }; } @@ -3225,7 +3224,7 @@ var canvg = (function (exports) { _classCallCheck(this, _class22); _this12 = _possibleConstructorReturn(this, _getPrototypeOf(_class22).call(this, node)); - svg.Animations.push(_assertThisInitialized(_assertThisInitialized(_this12))); + svg.Animations.push(_assertThisInitialized(_this12)); _this12.duration = 0.0; _this12.begin = _this12.attribute('begin').toMilliseconds(); _this12.maxDuration = _this12.begin + _this12.attribute('dur').toMilliseconds(); @@ -3443,7 +3442,7 @@ var canvg = (function (exports) { _this13.fontFace = child; if (child.style('font-family').hasValue()) { - svg.Definitions[child.style('font-family').value] = _assertThisInitialized(_assertThisInitialized(_this13)); + svg.Definitions[child.style('font-family').value] = _assertThisInitialized(_this13); } } else if (child.type === 'missing-glyph') { _this13.missingGlyph = child; @@ -3886,7 +3885,7 @@ var canvg = (function (exports) { } _this20._isSvg = href.match(/\.svg$/); - svg.Images.push(_assertThisInitialized(_assertThisInitialized(_this20))); + svg.Images.push(_assertThisInitialized(_this20)); _this20.loaded = false; if (!_this20._isSvg) { @@ -4020,12 +4019,13 @@ var canvg = (function (exports) { _toConsumableArray(node.childNodes).forEach(function (_ref11) { var nodeValue = _ref11.nodeValue; css += nodeValue; - }); + }); // remove comments - css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // remove comments - css = svg.compressSpaces(css); // replace whitespace + css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex + // replace whitespace + css = svg.compressSpaces(css); var cssDefs = css.split('}'); cssDefs.forEach(function (cssDef) { if (svg.trim(cssDef) !== '') { diff --git a/dist/extensions/ext-server_moinsave.js b/dist/extensions/ext-server_moinsave.js index 5522de8c..a6f5973c 100644 --- a/dist/extensions/ext-server_moinsave.js +++ b/dist/extensions/ext-server_moinsave.js @@ -527,11 +527,10 @@ var svgEditorExtension_server_moinsave = (function () { }(); RGBColor.getHelpXML = function () { - var examples = _toConsumableArray(colorDefs.flatMap(function (_ref2) { + var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) { var example = _ref2.example; return example; - })).concat(_toConsumableArray(Object.keys(simpleColors))); - + })), _toConsumableArray(Object.keys(simpleColors))); var xml = document.createElement('ul'); xml.setAttribute('id', 'rgbcolor-examples'); xml.append.apply(xml, _toConsumableArray(examples.map(function (example) { @@ -553,11 +552,11 @@ var svgEditorExtension_server_moinsave = (function () { function _typeof$1(obj) { if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") { - _typeof$1 = function _typeof$$1(obj) { + _typeof$1 = function _typeof$1(obj) { return _typeof(obj); }; } else { - _typeof$1 = function _typeof$$1(obj) { + _typeof$1 = function _typeof$1(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj); }; } @@ -3225,7 +3224,7 @@ var svgEditorExtension_server_moinsave = (function () { _classCallCheck(this, _class22); _this12 = _possibleConstructorReturn(this, _getPrototypeOf(_class22).call(this, node)); - svg.Animations.push(_assertThisInitialized(_assertThisInitialized(_this12))); + svg.Animations.push(_assertThisInitialized(_this12)); _this12.duration = 0.0; _this12.begin = _this12.attribute('begin').toMilliseconds(); _this12.maxDuration = _this12.begin + _this12.attribute('dur').toMilliseconds(); @@ -3443,7 +3442,7 @@ var svgEditorExtension_server_moinsave = (function () { _this13.fontFace = child; if (child.style('font-family').hasValue()) { - svg.Definitions[child.style('font-family').value] = _assertThisInitialized(_assertThisInitialized(_this13)); + svg.Definitions[child.style('font-family').value] = _assertThisInitialized(_this13); } } else if (child.type === 'missing-glyph') { _this13.missingGlyph = child; @@ -3886,7 +3885,7 @@ var svgEditorExtension_server_moinsave = (function () { } _this20._isSvg = href.match(/\.svg$/); - svg.Images.push(_assertThisInitialized(_assertThisInitialized(_this20))); + svg.Images.push(_assertThisInitialized(_this20)); _this20.loaded = false; if (!_this20._isSvg) { @@ -4020,12 +4019,13 @@ var svgEditorExtension_server_moinsave = (function () { _toConsumableArray(node.childNodes).forEach(function (_ref11) { var nodeValue = _ref11.nodeValue; css += nodeValue; - }); + }); // remove comments - css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // remove comments - css = svg.compressSpaces(css); // replace whitespace + css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex + // replace whitespace + css = svg.compressSpaces(css); var cssDefs = css.split('}'); cssDefs.forEach(function (cssDef) { if (svg.trim(cssDef) !== '') { diff --git a/dist/extensions/ext-server_opensave.js b/dist/extensions/ext-server_opensave.js index 14ce64a4..0c00a533 100644 --- a/dist/extensions/ext-server_opensave.js +++ b/dist/extensions/ext-server_opensave.js @@ -527,11 +527,10 @@ var svgEditorExtension_server_opensave = (function () { }(); RGBColor.getHelpXML = function () { - var examples = _toConsumableArray(colorDefs.flatMap(function (_ref2) { + var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) { var example = _ref2.example; return example; - })).concat(_toConsumableArray(Object.keys(simpleColors))); - + })), _toConsumableArray(Object.keys(simpleColors))); var xml = document.createElement('ul'); xml.setAttribute('id', 'rgbcolor-examples'); xml.append.apply(xml, _toConsumableArray(examples.map(function (example) { @@ -553,11 +552,11 @@ var svgEditorExtension_server_opensave = (function () { function _typeof$1(obj) { if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") { - _typeof$1 = function _typeof$$1(obj) { + _typeof$1 = function _typeof$1(obj) { return _typeof(obj); }; } else { - _typeof$1 = function _typeof$$1(obj) { + _typeof$1 = function _typeof$1(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj); }; } @@ -3225,7 +3224,7 @@ var svgEditorExtension_server_opensave = (function () { _classCallCheck(this, _class22); _this12 = _possibleConstructorReturn(this, _getPrototypeOf(_class22).call(this, node)); - svg.Animations.push(_assertThisInitialized(_assertThisInitialized(_this12))); + svg.Animations.push(_assertThisInitialized(_this12)); _this12.duration = 0.0; _this12.begin = _this12.attribute('begin').toMilliseconds(); _this12.maxDuration = _this12.begin + _this12.attribute('dur').toMilliseconds(); @@ -3443,7 +3442,7 @@ var svgEditorExtension_server_opensave = (function () { _this13.fontFace = child; if (child.style('font-family').hasValue()) { - svg.Definitions[child.style('font-family').value] = _assertThisInitialized(_assertThisInitialized(_this13)); + svg.Definitions[child.style('font-family').value] = _assertThisInitialized(_this13); } } else if (child.type === 'missing-glyph') { _this13.missingGlyph = child; @@ -3886,7 +3885,7 @@ var svgEditorExtension_server_opensave = (function () { } _this20._isSvg = href.match(/\.svg$/); - svg.Images.push(_assertThisInitialized(_assertThisInitialized(_this20))); + svg.Images.push(_assertThisInitialized(_this20)); _this20.loaded = false; if (!_this20._isSvg) { @@ -4020,12 +4019,13 @@ var svgEditorExtension_server_opensave = (function () { _toConsumableArray(node.childNodes).forEach(function (_ref11) { var nodeValue = _ref11.nodeValue; css += nodeValue; - }); + }); // remove comments - css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // remove comments - css = svg.compressSpaces(css); // replace whitespace + css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex + // replace whitespace + css = svg.compressSpaces(css); var cssDefs = css.split('}'); cssDefs.forEach(function (cssDef) { if (svg.trim(cssDef) !== '') { diff --git a/dist/extensions/imagelib/openclipart.js b/dist/extensions/imagelib/openclipart.js index 2906d4cb..a6aad9ba 100644 --- a/dist/extensions/imagelib/openclipart.js +++ b/dist/extensions/imagelib/openclipart.js @@ -250,11 +250,11 @@ function _typeof$1(obj) { if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") { - _typeof$1 = function _typeof$$1(obj) { + _typeof$1 = function _typeof$1(obj) { return _typeof(obj); }; } else { - _typeof$1 = function _typeof$$1(obj) { + _typeof$1 = function _typeof$1(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj); }; } @@ -268,7 +268,7 @@ } } - function _defineProperties$1(target, props) { + function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; @@ -278,9 +278,9 @@ } } - function _createClass$1(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); - if (staticProps) _defineProperties$1(Constructor, staticProps); + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } @@ -300,14 +300,14 @@ } function _getPrototypeOf$1(o) { - _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf$$1(o) { + _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf$1(o); } function _setPrototypeOf$1(o, p) { - _setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf$$1(o, p) { + _setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; @@ -332,7 +332,7 @@ if (isNativeReflectConstruct$1()) { _construct$1 = Reflect.construct; } else { - _construct$1 = function _construct$$1(Parent, args, Class) { + _construct$1 = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); @@ -352,7 +352,7 @@ function _wrapNativeSuper$1(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; - _wrapNativeSuper$1 = function _wrapNativeSuper$$1(Class) { + _wrapNativeSuper$1 = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction$1(Class)) return Class; if (typeof Class !== "function") { @@ -399,7 +399,7 @@ return _assertThisInitialized$1(self); } - function _superPropBase$1(object, property) { + function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf$1(object); if (object === null) break; @@ -408,12 +408,12 @@ return object; } - function _get$1(target, property, receiver) { + function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { - _get$1 = Reflect.get; + _get = Reflect.get; } else { - _get$1 = function _get$$1(target, property, receiver) { - var base = _superPropBase$1(target, property); + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); @@ -426,7 +426,7 @@ }; } - return _get$1(target, property, receiver || target); + return _get(target, property, receiver || target); } function _slicedToArray$1(arr, i) { @@ -2112,17 +2112,17 @@ return _possibleConstructorReturn$1(this, _getPrototypeOf$1(JamilihMap).apply(this, arguments)); } - _createClass$1(JamilihMap, [{ + _createClass(JamilihMap, [{ key: "get", value: function get$$1(elem) { elem = typeof elem === 'string' ? $(elem) : elem; - return _get$1(_getPrototypeOf$1(JamilihMap.prototype), "get", this).call(this, elem); + return _get(_getPrototypeOf$1(JamilihMap.prototype), "get", this).call(this, elem); } }, { key: "set", value: function set(elem, value) { elem = typeof elem === 'string' ? $(elem) : elem; - return _get$1(_getPrototypeOf$1(JamilihMap.prototype), "set", this).call(this, elem, value); + return _get(_getPrototypeOf$1(JamilihMap.prototype), "set", this).call(this, elem, value); } }, { key: "invoke", @@ -2153,17 +2153,17 @@ return _possibleConstructorReturn$1(this, _getPrototypeOf$1(JamilihWeakMap).apply(this, arguments)); } - _createClass$1(JamilihWeakMap, [{ + _createClass(JamilihWeakMap, [{ key: "get", value: function get$$1(elem) { elem = typeof elem === 'string' ? $(elem) : elem; - return _get$1(_getPrototypeOf$1(JamilihWeakMap.prototype), "get", this).call(this, elem); + return _get(_getPrototypeOf$1(JamilihWeakMap.prototype), "get", this).call(this, elem); } }, { key: "set", value: function set(elem, value) { elem = typeof elem === 'string' ? $(elem) : elem; - return _get$1(_getPrototypeOf$1(JamilihWeakMap.prototype), "set", this).call(this, elem, value); + return _get(_getPrototypeOf$1(JamilihWeakMap.prototype), "set", this).call(this, elem, value); } }, { key: "invoke", @@ -2456,11 +2456,11 @@ function _typeof$2(obj) { if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") { - _typeof$2 = function _typeof$$1(obj) { + _typeof$2 = function _typeof$1(obj) { return _typeof(obj); }; } else { - _typeof$2 = function _typeof$$1(obj) { + _typeof$2 = function _typeof$1(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj); }; } @@ -3311,13 +3311,13 @@ }, [// Todo: i18nize first values ['Date', 'date'], ['Downloads', 'downloads'], ['Favorited', 'favorites']].map(function (_ref) { var _ref2 = _slicedToArray(_ref, 2), - text$$1 = _ref2[0], + text = _ref2[0], _ref2$ = _ref2[1], - value = _ref2$ === void 0 ? text$$1 : _ref2$; + value = _ref2$ === void 0 ? text : _ref2$; return ['option', { value: value - }, [text$$1]]; + }, [text]]; })]]]]], ['div', { class: 'control' }, [['label', ['Results per page: ', ['input', { diff --git a/dist/index-es.js b/dist/index-es.js index 928d86a0..21d02815 100644 --- a/dist/index-es.js +++ b/dist/index-es.js @@ -5119,7 +5119,7 @@ var editorContext_ = null; * @returns {undefined} */ -var init$1 = function init$$1(editorContext) { +var init$1 = function init(editorContext) { editorContext_ = editorContext; pathFuncs = [0, 'ClosePath']; var pathFuncsStrs = ['Moveto', 'Lineto', 'CurvetoCubic', 'CurvetoQuadratic', 'Arc', 'LinetoHorizontal', 'LinetoVertical', 'CurvetoCubicSmooth', 'CurvetoQuadraticSmooth']; @@ -5844,7 +5844,7 @@ function () { _createClass(Path, [{ key: "init", - value: function init$$1() { + value: function init() { // Hide all grips, etc // fixed, needed to work on all found elements, not just first $$1(getGripContainer()).find('*').each(function () { @@ -7934,7 +7934,7 @@ var svgroot_ = null; * @returns {undefined} */ -var init$2 = function init$$1(editorContext) { +var init$2 = function init(editorContext) { editorContext_$1 = editorContext; domdoc_ = editorContext.getDOMDocument(); domcontainer_ = editorContext.getDOMContainer(); @@ -8323,8 +8323,8 @@ var findDefs = function findDefs() { * @returns {module:utilities.BBoxObject} A BBox-like object */ -var getPathBBox = function getPathBBox(path$$1) { - var seglist = path$$1.pathSegList; +var getPathBBox = function getPathBBox(path) { + var seglist = path.pathSegList; var tot = seglist.numberOfItems; var bounds = [[], []]; var start = seglist.getItem(0); @@ -8707,43 +8707,43 @@ var getExtraAttributesForConvertToPath = function getExtraAttributesForConvertTo * @returns {DOMRect|false} The resulting path's bounding box object. */ -var getBBoxOfElementAsPath = function getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1) { - var path$$1 = addSVGElementFromJson({ +var getBBoxOfElementAsPath = function getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions) { + var path = addSVGElementFromJson({ element: 'path', attr: getExtraAttributesForConvertToPath(elem) }); var eltrans = elem.getAttribute('transform'); if (eltrans) { - path$$1.setAttribute('transform', eltrans); + path.setAttribute('transform', eltrans); } var parentNode = elem.parentNode; if (elem.nextSibling) { - elem.before(path$$1); + elem.before(path); } else { - parentNode.append(path$$1); + parentNode.append(path); } var d = getPathDFromElement(elem); if (d) { - path$$1.setAttribute('d', d); + path.setAttribute('d', d); } else { - path$$1.remove(); + path.remove(); } // Get the correct BBox of the new path, then discard it - pathActions$$1.resetOrientation(path$$1); + pathActions.resetOrientation(path); var bb = false; try { - bb = path$$1.getBBox(); + bb = path.getBBox(); } catch (e) {// Firefox fails } - path$$1.remove(); + path.remove(); return bb; }; /** @@ -8760,57 +8760,57 @@ var getBBoxOfElementAsPath = function getBBoxOfElementAsPath(elem, addSVGElement * @returns {SVGPathElement|null} The converted path element or null if the DOM element was not recognized. */ -var convertToPath = function convertToPath(elem, attrs, addSVGElementFromJson, pathActions$$1, clearSelection, addToSelection, hstry, addCommandToHistory) { +var convertToPath = function convertToPath(elem, attrs, addSVGElementFromJson, pathActions, clearSelection, addToSelection, hstry, addCommandToHistory) { var batchCmd = new hstry.BatchCommand('Convert element to Path'); // Any attribute on the element not covered by the passed-in attributes attrs = $$2.extend({}, attrs, getExtraAttributesForConvertToPath(elem)); - var path$$1 = addSVGElementFromJson({ + var path = addSVGElementFromJson({ element: 'path', attr: attrs }); var eltrans = elem.getAttribute('transform'); if (eltrans) { - path$$1.setAttribute('transform', eltrans); + path.setAttribute('transform', eltrans); } var id = elem.id; var parentNode = elem.parentNode; if (elem.nextSibling) { - elem.before(path$$1); + elem.before(path); } else { - parentNode.append(path$$1); + parentNode.append(path); } var d = getPathDFromElement(elem); if (d) { - path$$1.setAttribute('d', d); // Replace the current element with the converted one + path.setAttribute('d', d); // Replace the current element with the converted one // Reorient if it has a matrix if (eltrans) { - var tlist = getTransformList(path$$1); + var tlist = getTransformList(path); if (hasMatrixTransform(tlist)) { - pathActions$$1.resetOrientation(path$$1); + pathActions.resetOrientation(path); } } var nextSibling = elem.nextSibling; batchCmd.addSubCommand(new hstry.RemoveElementCommand(elem, nextSibling, parent)); - batchCmd.addSubCommand(new hstry.InsertElementCommand(path$$1)); + batchCmd.addSubCommand(new hstry.InsertElementCommand(path)); clearSelection(); elem.remove(); - path$$1.setAttribute('id', id); - path$$1.removeAttribute('visibility'); - addToSelection([path$$1], true); + path.setAttribute('id', id); + path.removeAttribute('visibility'); + addToSelection([path], true); addCommandToHistory(batchCmd); - return path$$1; + return path; } // the elem.tagName was not recognized, so no "d" attribute. Remove it, so we've haven't changed anything. - path$$1.remove(); + path.remove(); return null; }; /** @@ -8850,7 +8850,7 @@ function bBoxCanBeOptimizedOverNativeGetBBox(angle, hasAMatrixTransform) { */ -var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFromJson, pathActions$$1) { +var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFromJson, pathActions) { // TODO: Fix issue with rotated groups. Currently they work // fine in FF, but not in other browsers (same problem mentioned // in Issue 339 comment #2). @@ -8873,7 +8873,7 @@ var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFrom var elemNames = ['ellipse', 'path', 'line', 'polyline', 'polygon']; if (elemNames.includes(elem.tagName)) { - goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1); + goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions); bb = goodBb; } else if (elem.tagName === 'rect') { // Look for radius @@ -8881,7 +8881,7 @@ var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFrom var ry = elem.getAttribute('ry'); if (rx || ry) { - goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1); + goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions); bb = goodBb; } } @@ -8938,7 +8938,7 @@ function getStrokeOffsetForBBox(elem) { */ -var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathActions$$1) { +var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathActions) { if (!elems || !elems.length) { return false; } @@ -8953,7 +8953,7 @@ var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathA return; } - fullBb = getBBoxWithTransform(this, addSVGElementFromJson, pathActions$$1); + fullBb = getBBoxWithTransform(this, addSVGElementFromJson, pathActions); }); // This shouldn't ever happen... if (fullBb === undefined) { @@ -8975,7 +8975,7 @@ var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathA maxY += offset; } else { $$2.each(elems, function (i, elem) { - var curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions$$1); + var curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions); if (curBb) { var _offset = getStrokeOffsetForBBox(elem); @@ -10979,7 +10979,7 @@ function () { }, { key: "copyElem", - value: function copyElem$$1(el) { + value: function copyElem$1(el) { var that = this; var getNextIdClosure = function getNextIdClosure() { @@ -11380,7 +11380,13 @@ var setContext = function setContext(elem) { canvas_.call('contextset', canvas_.getCurrentGroup()); }; -var REVERSE_NS = getReverseNS(); // this defines which elements and attributes that we support +var REVERSE_NS = getReverseNS(); // Todo: Split out into core attributes, presentation attributes, etc. so consistent + +/** + * This defines which elements and attributes that we support (or at least + * don't remove) + * @type {PlainObject} + */ var svgWhiteList_ = { // SVG Elements @@ -11392,6 +11398,7 @@ var svgWhiteList_ = { desc: [], ellipse: ['class', 'clip-path', 'clip-rule', 'cx', 'cy', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'id', 'mask', 'opacity', 'requiredFeatures', 'rx', 'ry', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform'], feGaussianBlur: ['class', 'color-interpolation-filters', 'id', 'requiredFeatures', 'stdDeviation'], + feMorphology: ['class', 'in', 'operator', 'radius'], filter: ['class', 'color-interpolation-filters', 'filterRes', 'filterUnits', 'height', 'id', 'primitiveUnits', 'requiredFeatures', 'width', 'x', 'xlink:href', 'y'], foreignObject: ['class', 'font-size', 'height', 'id', 'opacity', 'requiredFeatures', 'style', 'transform', 'width', 'x', 'y'], g: ['class', 'clip-path', 'clip-rule', 'id', 'display', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'mask', 'opacity', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'font-family', 'font-size', 'font-style', 'font-weight', 'text-anchor'], @@ -12056,7 +12063,7 @@ var context_; * @returns {undefined} */ -var init$5 = function init$$1(editorContext) { +var init$5 = function init(editorContext) { context_ = editorContext; }; /** @@ -12371,6 +12378,7 @@ var recalculateDimensions = function recalculateDimensions(selected) { var angle = getRotationAngle(child); oldStartTransform = context_.getStartTransform(); + var childxforms = []; context_.setStartTransform(child.getAttribute('transform')); if (angle || hasMatrixTransform(childTlist)) { @@ -12378,6 +12386,7 @@ var recalculateDimensions = function recalculateDimensions(selected) { e2t.setMatrix(matrixMultiply(tm, sm, tmn, _m)); childTlist.clear(); childTlist.appendItem(e2t); + childxforms.push(e2t); // if not rotated or skewed, push the [T][S][-T] down to the child } else { // update the transform list with translate,scale,translate // slide the [T][S][-T] from the front to the back @@ -12402,6 +12411,9 @@ var recalculateDimensions = function recalculateDimensions(selected) { childTlist.appendItem(translateBack); childTlist.appendItem(scale); childTlist.appendItem(translateOrigin); + childxforms.push(translateBack); + childxforms.push(scale); + childxforms.push(translateOrigin); // logMatrix(translateBack.matrix); // logMatrix(scale.matrix); } // not rotated @@ -13822,7 +13834,7 @@ function SvgCanvas(container, config) { return selectedElements; }; - var pathActions$$1 = pathActions; + var pathActions$1 = pathActions; /** * This should actually be an intersection as all interfaces should be met. * @implements {module:utilities.EditorContext#getSVGRoot|module:recalculate.EditorContext#getSVGRoot|module:coords.EditorContext#getSVGRoot|module:path.EditorContext#getSVGRoot} @@ -13837,7 +13849,7 @@ function SvgCanvas(container, config) { * @implements {module:utilities.EditorContext} */ { - pathActions: pathActions$$1, + pathActions: pathActions$1, // Ok since not modifying getSVGContent: getSVGContent, addSVGElementFromJson: addSVGElementFromJson, @@ -14253,13 +14265,13 @@ function SvgCanvas(container, config) { */ - canvas.pathActions = pathActions$$1; + canvas.pathActions = pathActions$1; /** * @implements {module:path.EditorContext#resetD} */ function resetD(p) { - p.setAttribute('d', pathActions$$1.convertPath(p)); + p.setAttribute('d', pathActions$1.convertPath(p)); } init$1( @@ -14308,8 +14320,8 @@ function SvgCanvas(container, config) { var closedSubpath = _ref.closedSubpath, grips = _ref.grips; // TODO: Correct this: - pathActions$$1.canDeleteNodes = true; - pathActions$$1.closed_subpath = closedSubpath; + pathActions$1.canDeleteNodes = true; + pathActions$1.closed_subpath = closedSubpath; call('pointsAdded', { closedSubpath: closedSubpath, grips: grips @@ -15011,9 +15023,9 @@ function SvgCanvas(container, config) { var paths = _toConsumableArray(newDoc.getElementsByTagNameNS(NS.SVG, 'path')); - paths.forEach(function (path$$1) { - path$$1.setAttribute('d', pathActions$$1.convertPath(path$$1)); - pathActions$$1.fixEnd(path$$1); + paths.forEach(function (path) { + path.setAttribute('d', pathActions$1.convertPath(path)); + pathActions$1.fixEnd(path); }); }; /** @@ -15391,7 +15403,7 @@ function SvgCanvas(container, config) { addToSelection([mouseTarget]); justSelected = mouseTarget; - pathActions$$1.clear(); + pathActions$1.clear(); } // else if it's a path, go into pathedit mode in mouseup @@ -15489,12 +15501,11 @@ function SvgCanvas(container, config) { if (iswebkit) { delayedStroke = function delayedStroke(ele) { - var _stroke = ele.getAttribute('stroke'); - + var stroke_ = ele.getAttribute('stroke'); ele.removeAttribute('stroke'); // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker - if (_stroke !== null) setTimeout(function () { - ele.setAttribute('stroke', _stroke); + if (stroke_ !== null) setTimeout(function () { + ele.setAttribute('stroke', stroke_); }, 0); }; } @@ -15681,7 +15692,7 @@ function SvgCanvas(container, config) { case 'pathedit': startX *= currentZoom; startY *= currentZoom; - pathActions$$1.mouseDown(evt, mouseTarget, startX, startY); + pathActions$1.mouseDown(evt, mouseTarget, startX, startY); started = true; break; @@ -16171,12 +16182,12 @@ function SvgCanvas(container, config) { } if (evt.shiftKey) { - var path$$1 = path; + var path$1 = path; var x1, y1; - if (path$$1) { - x1 = path$$1.dragging ? path$$1.dragging[0] : startX; - y1 = path$$1.dragging ? path$$1.dragging[1] : startY; + if (path$1) { + x1 = path$1.dragging ? path$1.dragging[0] : startX; + y1 = path$1.dragging ? path$1.dragging[1] : startY; } else { x1 = startX; y1 = startY; @@ -16199,7 +16210,7 @@ function SvgCanvas(container, config) { }, 100); } - pathActions$$1.mouseMove(x, y); + pathActions$1.mouseMove(x, y); break; } @@ -16376,7 +16387,7 @@ function SvgCanvas(container, config) { t = evt.target; if (selectedElements[0].nodeName === 'path' && isNullish(selectedElements[1])) { - pathActions$$1.select(selectedElements[0]); // if it was a path + pathActions$1.select(selectedElements[0]); // if it was a path // else, if it was selected and this is a shift-click, remove it from selection } else if (evt.shiftKey) { if (tempJustSelected !== t) { @@ -16451,7 +16462,7 @@ function SvgCanvas(container, config) { } if (keep) { - element = pathActions$$1.smoothPolylineIntoPath(element); + element = pathActions$1.smoothPolylineIntoPath(element); } break; @@ -16530,7 +16541,7 @@ function SvgCanvas(container, config) { element = null; // continue to be set to true so that mouseMove happens started = true; - var res = pathActions$$1.mouseUp(evt, element, mouseX, mouseY); + var res = pathActions$1.mouseUp(evt, element, mouseX, mouseY); element = res.element; keep = res.keep; break; @@ -16539,7 +16550,7 @@ function SvgCanvas(container, config) { case 'pathedit': keep = true; element = null; - pathActions$$1.mouseUp(evt); + pathActions$1.mouseUp(evt); break; case 'textedit': @@ -16650,7 +16661,7 @@ function SvgCanvas(container, config) { cleanupElement(element); if (currentMode === 'path') { - pathActions$$1.toEditMode(element); + pathActions$1.toEditMode(element); } else if (curConfig.selectNew) { selectOnly([element], true); } // we create the insert command that is stored on the stack @@ -17257,7 +17268,7 @@ function SvgCanvas(container, config) { * @param {Element} inputElem Not in use * @returns {undefined} */ - init: function init$$1(inputElem) { + init: function init(inputElem) { if (!curtext) { return; } @@ -17400,7 +17411,7 @@ function SvgCanvas(container, config) { while (removeUnusedDefElems() > 0) {} // eslint-disable-line no-empty - pathActions$$1.clear(true); // Keep SVG-Edit comment on top + pathActions$1.clear(true); // Keep SVG-Edit comment on top $$9.each(svgcontent.childNodes, function (i, node) { if (i && node.nodeType === 8 && node.data.includes('Created with')) { @@ -17567,7 +17578,7 @@ function SvgCanvas(container, config) { out.push(' '); if (_attr.localName === 'd') { - _attrVal = pathActions$$1.convertPath(elem, true); + _attrVal = pathActions$1.convertPath(elem, true); } if (!isNaN(_attrVal)) { @@ -18796,7 +18807,7 @@ function SvgCanvas(container, config) { * @implements {module:draw.DrawCanvasInit} */ { - pathActions: pathActions$$1, + pathActions: pathActions$1, getCurrentGroup: function getCurrentGroup() { return currentGroup; }, @@ -18832,7 +18843,7 @@ function SvgCanvas(container, config) { */ this.clear = function () { - pathActions$$1.clear(); + pathActions$1.clear(); clearSelection(); // clear the svgcontent node canvas.clearSvgContentElement(); // create new document @@ -18850,7 +18861,7 @@ function SvgCanvas(container, config) { }; // Alias function - this.linkControlPoints = pathActions$$1.linkControlPoints; + this.linkControlPoints = pathActions$1.linkControlPoints; /** * @function module:svgcanvas.SvgCanvas#getContentElem * @returns {Element} The content DOM element @@ -19341,7 +19352,7 @@ function SvgCanvas(container, config) { selectorManager.requestSelector(elem).resize(); }); - pathActions$$1.zoomChange(); + pathActions$1.zoomChange(); runExtensions('zoomChanged', /** @type {module:svgcanvas.SvgCanvas#event:ext-zoomChanged} */ zoomLevel); @@ -19364,7 +19375,7 @@ function SvgCanvas(container, config) { this.setMode = function (name) { - pathActions$$1.clear(true); + pathActions$1.clear(true); textActions.clear(); curProperties = selectedElements[0] && selectedElements[0].nodeName === 'text' ? curText : curShape; currentMode = name; @@ -20255,7 +20266,7 @@ function SvgCanvas(container, config) { this.setSegType = function (newType) { - pathActions$$1.setSegType(newType); + pathActions$1.setSegType(newType); }; /** * Convert selected element to a path, or get the BBox of an element-as-path. @@ -20268,7 +20279,7 @@ function SvgCanvas(container, config) { */ - this.convertToPath = function (elem, getBBox$$1) { + this.convertToPath = function (elem, getBBox) { if (isNullish(elem)) { var elems = selectedElements; $$9.each(elems, function (i, el) { @@ -20279,8 +20290,8 @@ function SvgCanvas(container, config) { return undefined; } - if (getBBox$$1) { - return getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1); + if (getBBox) { + return getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$1); } // TODO: Why is this applying attributes from curShape, then inside utilities.convertToPath it's pulling addition attributes from elem? // TODO: If convertToPath is called with one elem, curShape and elem are probably the same; but calling with multiple is a bug or cool feature. @@ -20297,7 +20308,7 @@ function SvgCanvas(container, config) { opacity: curShape.opacity, visibility: 'hidden' }; - return convertToPath(elem, attrs, addSVGElementFromJson, pathActions$$1, clearSelection, addToSelection, hstry, addCommandToHistory); + return convertToPath(elem, attrs, addSVGElementFromJson, pathActions$1, clearSelection, addToSelection, hstry, addCommandToHistory); }; /** * This function makes the changes to the elements. It does not add the change @@ -20312,7 +20323,7 @@ function SvgCanvas(container, config) { var changeSelectedAttributeNoUndo = function changeSelectedAttributeNoUndo(attr, newValue, elems) { if (currentMode === 'pathedit') { // Editing node - pathActions$$1.moveNode(attr, newValue); + pathActions$1.moveNode(attr, newValue); } elems = elems || selectedElements; @@ -24662,6 +24673,8 @@ function jQueryContextMenu($) { return $; } +/* eslint-disable no-bitwise */ + /** * jPicker (Adapted from version 1.1.6) * @@ -24773,8 +24786,7 @@ var jPicker = function jPicker($) { offset = { l: off.left | 0, t: off.top | 0 - }; // eslint-disable-line no-bitwise - + }; clearTimeout(timeout); // using setTimeout for visual updates - once the style is updated the browser will re-render internally allowing the next Javascript to run timeout = setTimeout(function () { @@ -24848,7 +24860,6 @@ var jPicker = function jPicker($) { var arrowOffsetX = 0, arrowOffsetY = 0; setTimeout(function () { - /* eslint-disable no-bitwise */ if (rangeX > 0) { // range is greater than zero // constrain to bounds @@ -24871,7 +24882,6 @@ var jPicker = function jPicker($) { left: arrowOffsetX + 'px', top: arrowOffsetY + 'px' }); - /* eslint no-bitwise: ["error"] */ }); } /** @@ -25022,7 +25032,6 @@ var jPicker = function jPicker($) { var // changed = false, newMinX, newMaxX, newMinY, newMaxY; if (isNullish$1(name)) name = 'all'; - /* eslint-disable no-bitwise */ switch (name.toLowerCase()) { case 'minx': @@ -25059,8 +25068,6 @@ var jPicker = function jPicker($) { newMaxY = value && value.maxY && value.maxY | 0 || 0; break; } - /* eslint no-bitwise: ["error"] */ - if (!isNullish$1(newMinX) && minX !== newMinX) { minX = newMinX; @@ -29421,7 +29428,7 @@ editor.init = function () { var _ref6 = _asyncToGenerator( /*#__PURE__*/ regeneratorRuntime.mark(function _callee2(extname) { - var extName, url, imported, _imported$name, name, init$$1, importLocale; + var extName, url, imported, _imported$name, name, init, importLocale; return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { @@ -29455,12 +29462,12 @@ editor.init = function () { case 7: imported = _context2.sent; - _imported$name = imported.name, name = _imported$name === void 0 ? extName[1] : _imported$name, init$$1 = imported.init; + _imported$name = imported.name, name = _imported$name === void 0 ? extName[1] : _imported$name, init = imported.init; importLocale = getImportLocale({ defaultLang: langParam, defaultName: name }); - return _context2.abrupt("return", editor.addExtension(name, init$$1 && init$$1.bind(editor), { + return _context2.abrupt("return", editor.addExtension(name, init && init.bind(editor), { $: $$b, importLocale: importLocale })); @@ -33277,7 +33284,7 @@ editor.init = function () { */ - var convertToPath$$1 = function convertToPath$$1() { + var convertToPath = function convertToPath() { if (!isNullish(selectedElement)) { svgCanvas.convertToPath(); } @@ -35113,7 +35120,7 @@ editor.init = function () { key: 'ctrl+shift+[' }, { sel: '#tool_topath', - fn: convertToPath$$1, + fn: convertToPath, evt: 'click' }, { sel: '#tool_make_link,#tool_make_link_multi', @@ -36386,7 +36393,7 @@ editor.loadFromDataURI = function (str) { */ -editor.addExtension = function (name, init$$1, initArgs) { +editor.addExtension = function (name, init, initArgs) { // Note that we don't want this on editor.ready since some extensions // may want to run before then (like server_opensave). // $(function () { @@ -36394,7 +36401,7 @@ editor.addExtension = function (name, init$$1, initArgs) { throw new Error('Extension added too early'); } - return svgCanvas.addExtension.call(this, name, init$$1, initArgs); // }); + return svgCanvas.addExtension.call(this, name, init, initArgs); // }); }; // Defer injection to wait out initial menu processing. This probably goes // away once all context menu behavior is brought to context menu. diff --git a/dist/index-es.min.js b/dist/index-es.min.js index bb34d068..492c0157 100644 --- a/dist/index-es.min.js +++ b/dist/index-es.min.js @@ -1,2 +1,2 @@ -function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function asyncGeneratorStep(e,t,n,r,a,i,s){try{var o=e[i](s),l=o.value}catch(e){return void n(e)}o.done?t(l):Promise.resolve(l).then(r,a)}function _asyncToGenerator(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var i=e.apply(t,n);function s(e){asyncGeneratorStep(i,r,a,s,o,"next",e)}function o(e){asyncGeneratorStep(i,r,a,s,o,"throw",e)}s(void 0)})}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;nt.getTotalLength())break;n--}while(n>0);return n}),window.SVGPathSeg=e,window.SVGPathSegClosePath=t,window.SVGPathSegMovetoAbs=n,window.SVGPathSegMovetoRel=r,window.SVGPathSegLinetoAbs=a,window.SVGPathSegLinetoRel=i,window.SVGPathSegCurvetoCubicAbs=s,window.SVGPathSegCurvetoCubicRel=o,window.SVGPathSegCurvetoQuadraticAbs=l,window.SVGPathSegCurvetoQuadraticRel=c,window.SVGPathSegArcAbs=u,window.SVGPathSegArcRel=d,window.SVGPathSegLinetoHorizontalAbs=h,window.SVGPathSegLinetoHorizontalRel=p,window.SVGPathSegLinetoVerticalAbs=g,window.SVGPathSegLinetoVerticalRel=f,window.SVGPathSegCurvetoCubicSmoothAbs=m,window.SVGPathSegCurvetoCubicSmoothRel=v,window.SVGPathSegCurvetoQuadraticSmoothAbs=_,window.SVGPathSegCurvetoQuadraticSmoothRel=b}if(!("SVGPathSegList"in window&&"appendItem"in window.SVGPathSegList.prototype)){var y=function(){function e(t){_classCallCheck(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 _createClass(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(){_classCallCheck(this,e),this.pathSegList=[]}return _createClass(e,[{key:"appendSegment",value:function(e){this.pathSegList.push(e)}}]),e}(),r=function(){function e(t){_classCallCheck(this,e),this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()}return _createClass(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,s=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex"9")&&"."!==this._string.charAt(this._currentIndex))){for(var o=this._currentIndex;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!==o)for(var l=this._currentIndex-1,c=1;l>=o;)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!==s&&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)),s!==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 s={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothAbs(t,s.x,s.y,s.x2,s.y2);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:var o={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticRel(t,o.x,o.y,o.x1,o.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}(),a=new n,i=new r(e);if(!i.initialCommandIsMoveTo())return[];for(;i.hasMoreData();){var s=i.parseSegment();if(!s)return[];a.appendSegment(s)}return a.pathSegList}}]),e}();y.prototype.classname="SVGPathSegList",Object.defineProperty(y.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),y._pathSegArrayAsString=function(e){var t="",n=!0;return e.forEach(function(e){n?(n=!1,t+=e._asPathString()):t+=" "+e._asPathString()}),t},Object.defineProperties(SVGPathElement.prototype,{pathSegList:{get:function(){return this._pathSegList||(this._pathSegList=new y(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=y}}();var $=jQuery,supportsSVG_=Boolean(document.createElementNS&&document.createElementNS(NS.SVG,"svg").createSVGRect),_navigator=navigator,userAgent=_navigator.userAgent,svg=document.createElementNS(NS.SVG,"svg"),isOpera_=Boolean(window.opera),isWebkit_=userAgent.includes("AppleWebKit"),isGecko_=userAgent.includes("Gecko/"),isIE_=userAgent.includes("MSIE"),isChrome_=userAgent.includes("Chrome/"),isWindows_=userAgent.includes("Windows"),isMac_=userAgent.includes("Macintosh"),isTouch_="ontouchstart"in window,supportsSelectors_=Boolean(svg.querySelector),supportsXpath_=Boolean(document.evaluate),supportsPathReplaceItem_=function(){var e=document.createElementNS(NS.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}(),supportsPathInsertItemBefore_=function(){var e=document.createElementNS(NS.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}(),supportsGoodTextCharPos_=function(){var e=document.createElementNS(NS.SVG,"svg"),t=document.createElementNS(NS.SVG,"svg");document.documentElement.append(e),t.setAttribute("x",5),e.append(t);var n=document.createElementNS(NS.SVG,"text");n.textContent="a",t.append(n);try{return 0===n.getStartPositionOfChar(0).x}catch(e){return!1}finally{e.remove()}}(),supportsPathBBox_=function(){var e=document.createElementNS(NS.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(NS.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}(),supportsHVLineContainerBBox_=function(){var e=document.createElementNS(NS.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(NS.SVG,"path");t.setAttribute("d","M0,0 10,0");var n=document.createElementNS(NS.SVG,"path");n.setAttribute("d","M5,0 15,0");var r=document.createElementNS(NS.SVG,"g");r.append(t,n),e.append(r);var a=r.getBBox();return e.remove(),15===a.width}(),supportsGoodDecimals_=function(){var e=document.createElementNS(NS.SVG,"rect");e.setAttribute("x",.1);var t=!e.cloneNode(!1).getAttribute("x").includes(",");return t||$.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.'),t}(),supportsNonScalingStroke_=function(){var e=document.createElementNS(NS.SVG,"rect");return e.setAttribute("style","vector-effect:non-scaling-stroke"),"non-scaling-stroke"===e.style.vectorEffect}(),supportsNativeSVGTransformLists_=function(){var e=document.createElementNS(NS.SVG,"rect").transform.baseVal,t=svg.createSVGTransform();e.appendItem(t);var n=e.getItem(0),r=function(e){return e&&"object"===_typeof(e)&&"function"==typeof e.setMatrix&&"angle"in e};return r(n)&&r(t)&&n.type===t.type&&n.angle===t.angle&&n.matrix.a===t.matrix.a&&n.matrix.b===t.matrix.b&&n.matrix.c===t.matrix.c&&n.matrix.d===t.matrix.d&&n.matrix.e===t.matrix.e&&n.matrix.f===t.matrix.f}(),isOpera=function(){return isOpera_},isWebkit=function(){return isWebkit_},isGecko=function(){return isGecko_},isIE=function(){return isIE_},isChrome=function(){return isChrome_},isMac=function(){return isMac_},isTouch=function(){return isTouch_},supportsSelectors=function(){return supportsSelectors_},supportsXpath=function(){return supportsXpath_},supportsPathReplaceItem=function(){return supportsPathReplaceItem_},supportsPathInsertItemBefore=function(){return supportsPathInsertItemBefore_},supportsPathBBox=function(){return supportsPathBBox_},supportsHVLineContainerBBox=function(){return supportsHVLineContainerBBox_},supportsGoodTextCharPos=function(){return supportsGoodTextCharPos_},supportsNonScalingStroke=function(){return supportsNonScalingStroke_},supportsNativeTransformLists=function(){return supportsNativeSVGTransformLists_};function jQueryPluginSVG(e){var t=e.fn.attr;return e.fn.attr=function(e,n){var r=this.length;if(!r)return t.call(this,e,n);for(var a=0;a=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(HistoryEventTypes.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}();BatchCommand.type=BatchCommand.prototype.type;var UndoManager=function(){function e(t){_classCallCheck(this,e),this.handler_=t||null,this.undoStackPointer=0,this.undoStack=[],this.undoChangeStackPointer=-1,this.undoableChangeStack=[]}return _createClass(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 s=t[r];isNullish(s)||(i[r]=s,a[r]=s.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 BatchCommand("Change "+n),a=t.elements.length;a--;){var i=t.elements[a];if(!isNullish(i)){var s={};s[n]=t.oldValues[a],s[n]!==i.getAttribute(n)&&r.addSubCommand(new ChangeElementCommand(i,s,n))}}return this.undoableChangeStack[e]=null,r}}]),e}(),hstry=Object.freeze({HistoryEventTypes:HistoryEventTypes,MoveElementCommand:MoveElementCommand,InsertElementCommand:InsertElementCommand,RemoveElementCommand:RemoveElementCommand,ChangeElementCommand:ChangeElementCommand,BatchCommand:BatchCommand,UndoManager:UndoManager}),NEAR_ZERO=1e-14,svg$1=document.createElementNS(NS.SVG,"svg"),transformPoint=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},isIdentity=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},matrixMultiply=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=svg$1.createSVGMatrix(),i=t;i<=n;++i){var s=i>=0&&ie.x&&t.ye.y},$$1=jQuery,segData={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"]},uiStrings={},setUiStrings=function(e){Object.assign(uiStrings,e.ui)},pathFuncs=[],linkControlPts=!0,pathData={},setLinkControlPoints=function(e){linkControlPts=e},path=null,editorContext_=null,init$1=function(e){editorContext_=e,pathFuncs=[0,"ClosePath"];$$1.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],function(e,t){pathFuncs.push(t+"Abs"),pathFuncs.push(t+"Rel")})},insertItemBefore=function(e,t,n){var r=e.pathSegList;if(supportsPathInsertItemBefore())r.insertItemBefore(t,n);else{for(var a=r.numberOfItems,i=[],s=0;s0?(p=f element");this.elem=t,this.segs=[],this.selected_pts=[],path=this,this.init()}return _createClass(e,[{key:"init",value:function(){$$1(getGripContainer()).find("*").each(function(){$$1(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[o+1],u=o-1<0?null:i[o-1];if(2===l.type){if(u&&1!==u.type){var d=i[s];d.next=i[s+1],d.next.prev=d,d.addGrip()}s=o}else if(c&&1===c.type)l.next=i[s+1],l.next.prev=l,l.mate=i[s],l.addGrip(),isNullish(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[s];h.next=i[s+1],h.next.prev=h,h.addGrip(),l.addGrip(),this.first_seg||(this.first_seg=i[s])}}return this}},{key:"eachSeg",value:function(e){for(var t=this.segs.length,n=0;n=0&&this.selected_pts.push(r)}this.selected_pts.sort();var a=this.selected_pts.length,i=[];for(i.length=a;a--;){var s=this.selected_pts[a],o=this.segs[s];o.select(!0),i[a]=o.ptgrip}var l=e.subpathIsClosed(this.selected_pts[0]);editorContext_.addPtsToSelection({grips:i,closedSubpath:l})}}]),e}();Path.subpathIsClosed=function(e){var t=!1;return path.eachSeg(function(n){return n<=e||2!==this.type&&(1!==this.type||(t=!0,!1))}),t};var newcx,newcy,oldcx,oldcy,angle,getPath_=function(e){var t=pathData[e.id];return t||(t=pathData[e.id]=new Path(e)),t},removePath_=function(e){e in pathData&&delete pathData[e]},getRotVals=function(e,t){var n=e-oldcx,r=t-oldcy,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)+angle;return n=a*Math.cos(i)+oldcx,r=a*Math.sin(i)+oldcy,n-=newcx,r-=newcy,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)-angle,{x:a*Math.cos(i)+newcx,y:a*Math.sin(i)+newcy}},recalcRotatedPath=function(){var e=path.elem;if(angle=getRotationAngle(e,!0)){var t=path.oldbbox;oldcx=t.x+t.width/2,oldcy=t.y+t.height/2;var n=getBBox(e);newcx=n.x+n.width/2,newcy=n.y+n.height/2;var r=newcx-oldcx,a=newcy-oldcy,i=Math.sqrt(r*r+a*a),s=Math.atan2(a,r)+angle;newcx=i*Math.cos(s)+oldcx,newcy=i*Math.sin(s)+oldcy;for(var o=e.pathSegList,l=o.numberOfItems;l;){l-=1;var c=o.getItem(l),u=c.pathSegType;if(1!==u){var d=getRotVals(c.x,c.y),h=[d.x,d.y];if(!isNullish(c.x1)&&!isNullish(c.x2)){var p=getRotVals(c.x1,c.y1),g=getRotVals(c.x2,c.y2);h.splice(h.length,0,p.x,p.y,g.x,g.y)}replacePathSeg(u,l,h)}}getBBox(e);var f=editorContext_.getSVGRoot().createSVGTransform(),m=getTransformList(e);f.setRotate(180*angle/Math.PI,newcx,newcy),m.replaceItem(f,0)}},clearData=function(){pathData={}},reorientGrads=function(e,t){for(var n=getBBox(e),r=0;r<2;r++){var a=0===r?"fill":"stroke",i=e.getAttribute(a);if(i&&i.startsWith("url(")){var s=getRefElem(i);if("linearGradient"===s.tagName){var o=s.getAttribute("x1")||0,l=s.getAttribute("y1")||0,c=s.getAttribute("x2")||1,u=s.getAttribute("y2")||0;o=n.width*o+n.x,l=n.height*l+n.y,c=n.width*c+n.x,u=n.height*u+n.y;var d=transformPoint(o,l,t),h=transformPoint(c,u,t),p={};p.x1=(d.x-n.x)/n.width,p.y1=(d.y-n.y)/n.height,p.x2=(h.x-n.x)/n.width,p.y2=(h.y-n.y)/n.height;var g=s.cloneNode(!0);$$1(g).attr(p),g.id=editorContext_.getNextId(),findDefs().append(g),e.setAttribute(a,"url(#"+g.id+")")}}}},pathMap=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],convertPath=function(e,t){for(var n=e.pathSegList,r=n.numberOfItems,a=0,i=0,s="",o=null,l=0;l=k-S&&m<=k+S&&v>=A-S&&v<=A+S){w=!0;break}}s=editorContext_.getId(),removePath_(s);var E,N,T=getElem(s),P=x.numberOfItems;if(w){if(C<=1&&P>=2){var G=x.getItem(0).x,L=x.getItem(0).y;E=4===(N=_.pathSegList.getItem(1)).pathSegType?y.createSVGPathSegLinetoAbs(G,L):y.createSVGPathSegCurvetoCubicAbs(G,L,N.x1/f,N.y1/f,G,L);var I=y.createSVGPathSegClosePath();x.appendItem(E),x.appendItem(I)}else if(P<3)return!1;if($$1(_).remove(),editorContext_.setDrawnPath(null),editorContext_.setStarted(!1),n){path.matrix&&editorContext_.remapElement(T,{},path.matrix.inverse());var M=T.getAttribute("d"),R=$$1(path.elem).attr("d");return $$1(path.elem).attr("d",R+M),$$1(T).remove(),path.matrix&&recalcRotatedPath(),init$1(),pathActions.toEditMode(path.elem),path.selectPt(),!1}}else{if(!$$1.contains(editorContext_.getContainer(),editorContext_.getMouseTarget(t)))return!1;var O=y.pathSegList.numberOfItems,B=y.pathSegList.getItem(O-1),V=B.x,j=B.y;if(t.shiftKey){var F=snapToAngle(V,j,m,v);m=F.x,v=F.y}E=4===(N=_.pathSegList.getItem(1)).pathSegType?y.createSVGPathSegLinetoAbs(editorContext_.round(m),editorContext_.round(v)):y.createSVGPathSegCurvetoCubicAbs(editorContext_.round(m),editorContext_.round(v),N.x1/f,N.y1/f,N.x2/f,N.y2/f),y.pathSegList.appendItem(E),m*=f,v*=f,_.setAttribute("d",["M",m,v,m,v].join(" ")),b=O,n&&(b+=path.segs.length),addPointGrip(b,m,v)}}else{var D="M"+m+","+v+" ";editorContext_.setDrawnPath(editorContext_.addSVGElementFromJson({element:"path",curStyles:!0,attr:{d:D,id:editorContext_.getNextId(),opacity:editorContext_.getOpacity()/2}})),_.setAttribute("d",["M",p,g,p,g].join(" ")),b=n?path.segs.length:0,addPointGrip(b,p,g)}}},mouseMove:function(n,r){var i=editorContext_.getCurrentZoom();a=!0;var s=editorContext_.getDrawnPath();if("path"!==editorContext_.getCurrentMode())if(path.dragging){var o=getPointFromGrip({x:path.dragging[0],y:path.dragging[1]},path),l=getPointFromGrip({x:n,y:r},path),c=l.x-o.x,u=l.y-o.y;path.dragging=[n,r],path.dragctrl?path.moveCtrl(c,u):path.movePts(c,u)}else path.selected_pts=[],path.eachSeg(function(e){if(this.next||this.prev){var t=editorContext_.getRubberBox().getBBox(),n=getGripPt(this),r={x:n.x,y:n.y,width:0,height:0},a=rectsIntersect(t,r);this.select(a),a&&path.selected_pts.push(this.index)}});else{if(!s)return;var d=s.pathSegList,h=d.numberOfItems-1;if(e){var p=addCtrlGrip("1c1"),g=addCtrlGrip("0c2");p.setAttribute("cx",n),p.setAttribute("cy",r),p.setAttribute("display","inline");var f=e[0],m=e[1],v=f+(f-n/i),_=m+(m-r/i);g.setAttribute("cx",v*i),g.setAttribute("cy",_*i),g.setAttribute("display","inline");var b=getCtrlLine(1);if(assignAttributes(b,{x1:n,y1:r,x2:v*i,y2:_*i,display:"inline"}),0===h)t=[n,r];else{var y=d.getItem(h-1),x=y.x,C=y.y;6===y.pathSegType?(x+=x-y.x2,C+=C-y.y2):t&&(x=t[0]/i,C=t[1]/i),replacePathSeg(6,h,[f,m,x,C,v,_],s)}}else{var S=getElem("path_stretch_line");if(S){var w=d.getItem(h);if(6===w.pathSegType){var $=w.x+(w.x-w.x2),k=w.y+(w.y-w.y2);replacePathSeg(6,1,[n,r,$*i,k*i,n,r],S)}else t?replacePathSeg(6,1,[n,r,t[0],t[1],n,r],S):replacePathSeg(4,1,[n,r],S)}}}},mouseUp:function(n,r,i,s){var o=editorContext_.getDrawnPath();if("path"===editorContext_.getCurrentMode())return e=null,o||(r=getElem(editorContext_.getId()),editorContext_.setStarted(!1),t=null),{keep:!0,element:r};var l=editorContext_.getRubberBox();if(path.dragging){var c=path.cur_pt;path.dragging=!1,path.dragctrl=!1,path.update(),a&&path.endChanges("Move path point(s)"),n.shiftKey||a||path.selectPt(c)}else l&&"none"!==l.getAttribute("display")?(l.setAttribute("display","none"),l.getAttribute("width")<=2&&l.getAttribute("height")<=2&&pathActions.toSelectMode(n.target)):pathActions.toSelectMode(n.target);a=!1},toEditMode:function(e){path=getPath_(e),editorContext_.setCurrentMode("pathedit"),editorContext_.clearSelection(),path.show(!0).update(),path.oldbbox=getBBox(path.elem),n=!1},toSelectMode:function(e){var t=e===path.elem;editorContext_.setCurrentMode("select"),path.show(!1),r=!1,editorContext_.clearSelection(),path.matrix&&recalcRotatedPath(),t&&(editorContext_.call("selected",[e]),editorContext_.addToSelection([e],!0))},addSubPath:function(e){e?(editorContext_.setCurrentMode("path"),n=!0):(pathActions.clear(!0),pathActions.toEditMode(path.elem))},select:function(e){r===e?(pathActions.toEditMode(e),editorContext_.setCurrentMode("pathedit")):r=e},reorient:function(){var e=editorContext_.getSelectedElements()[0];if(e&&0!==getRotationAngle(e)){var t=new BatchCommand("Reorient path"),n={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new ChangeElementCommand(e,n)),editorContext_.clearSelection(),this.resetOrientation(e),editorContext_.addCommandToHistory(t),getPath_(e).show(!1).matrix=null,this.clear(),editorContext_.addToSelection([e],!0),editorContext_.call("changed",editorContext_.getSelectedElements())}},clear:function(e){var n=editorContext_.getDrawnPath();if(r=null,n){var a=getElem(editorContext_.getId());$$1(getElem("path_stretch_line")).remove(),$$1(a).remove(),$$1(getElem("pathpointgrip_container")).find("*").attr("display","none"),t=null,editorContext_.setDrawnPath(null),editorContext_.setStarted(!1)}else"pathedit"===editorContext_.getCurrentMode()&&this.toSelectMode();path&&path.init().show(!1)},resetOrientation:function(e){if(isNullish(e)||"path"!==e.nodeName)return!1;var t=getTransformList(e),n=transformListToTransform(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 s=[];$$1.each(["",1,2],function(e,t){var r=a["x"+t],i=a["y"+t];if(void 0!==r&&void 0!==i){var o=transformPoint(r,i,n);s.splice(s.length,0,o.x,o.y)}}),replacePathSeg(i,t,s,e)},s=0;s0){var o=t.getItem(n-1).pathSegType;if(2===o){r(n-1,1),e();break}if(1===o&&t.numberOfItems-1===n){r(n,1),e();break}}}return!1}(),path.elem.pathSegList.numberOfItems<=1)return pathActions.toSelectMode(path.elem),void editorContext_.canvas.deleteSelectedElements();if(path.init(),path.clearSelection(),window.opera){var r=$$1(path.elem);r.attr("d",r.attr("d"))}path.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,s=[];for(s.push(["M",a.x,",",a.y," C"].join("")),t=1;t<=r-4;t+=3){var o=n.getItem(t),l=n.getItem(t+1),c=n.getItem(t+2);if(i){var u=smoothControlPoints(i,o,a);if(u&&2===u.length){var d=s[s.length-1].split(",");d[2]=u[0].x,d[3]=u[0].y,s[s.length-1]=d.join(","),o=u[1]}}s.push([o.x,o.y,l.x,l.y,c.x,c.y].join(",")),a=c,i=l}for(s.push("L");t)/,"$1$2")},toXml=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")};function encode64(e){if(e=encodeUTF8(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++),s=e.charCodeAt(n++),o=a>>2,l=(3&a)<<4|i>>4,c=(15&i)<<2|s>>6,u=63&s;isNaN(i)?(c=64,u=64):isNaN(s)&&(u=64),t[r++]=KEYSTR.charAt(o),t[r++]=KEYSTR.charAt(l),t[r++]=KEYSTR.charAt(c),t[r++]=KEYSTR.charAt(u)}while(n>4,l=(15&a)<<4|i>>2,c=(3&i)<<6|s;t+=String.fromCharCode(o),64!==i&&(t+=String.fromCharCode(l)),64!==s&&(t+=String.fromCharCode(c))}while(nSVG-edit "],{type:"text/html"});return createObjectURL(e)}(),text2xml=function(e){var t,n;e.includes("0?t=t[0]:(t=e.ownerDocument.createElementNS(NS.SVG,"defs"),e.firstChild?e.insertBefore(t,e.firstChild.nextSibling):e.append(t)),t},getPathBBox=function(e){for(var t=e.pathSegList,n=t.numberOfItems,r=[[],[]],a=t.getItem(0),i=[a.x,a.y],s=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]}},o=0;o0&&_<1&&r[h].push(p(_));var b=(-g-Math.sqrt(v))/(2*f);b>0&&b<1&&r[h].push(p(b))}}else{if(0===g)continue;var y=-m/g;y>0&&y<1&&r[h].push(p(y))}}i=d}else r[0].push(l.x),r[1].push(l.y)}var x=Math.min.apply(null,r[0]),C=Math.max.apply(null,r[0])-x,S=Math.min.apply(null,r[1]);return{x:x,y:S,width:C,height:Math.max.apply(null,r[1])-S}};function groupBBFix(e){if(supportsHVLineContainerBBox())try{return e.getBBox()}catch(e){}var t,n,r=$$2.data(e,"ref"),a=null;r?(n=$$2(r).children().clone().attr("visibility","hidden"),$$2(svgroot_).append(n),a=n.filter("line, path")):a=$$2(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 s=r?n:$$2(e).children();t=getStrokedBBox(s)}else t=e.getBBox();else t=e.getBBox();return r&&n.remove(),t}var getBBox=function(e){var t=e||editorContext_$1.geSelectedElements()[0];if(1!==e.nodeType)return null;var n=t.nodeName,r=null;switch(n){case"text":""===t.textContent?(t.textContent="a",r=t.getBBox(),t.textContent=""):t.getBBox&&(r=t.getBBox());break;case"path":supportsPathBBox()?t.getBBox&&(r=t.getBBox()):r=getPathBBox(t);break;case"g":case"a":r=groupBBFix(t);break;default:if("use"===n&&(r=groupBBFix(t)),"use"===n||"foreignObject"===n&&isWebkit()){if(r||(r=t.getBBox()),!isWebkit()){var a={};a.width=r.width,a.height=r.height,a.x=r.x+parseFloat(t.getAttribute("x")||0),a.y=r.y+parseFloat(t.getAttribute("y")||0),r=a}}else if(visElemsArr.includes(n))if(t)try{r=t.getBBox()}catch(e){var i=t.getExtentOfChar(0),s=t.getComputedTextLength();r={x:i.x,y:i.y,width:s,height:i.height}}else{var o=$$2(t).closest("foreignObject");o.length&&o[0].getBBox&&(r=o[0].getBBox())}}return r&&(r=bboxToObj(r)),r},getPathDFromSegments=function(e){var t="";return $$2.each(e,function(e,n){var r=_slicedToArray(n,2),a=r[0],i=r[1];t+=a;for(var s=0;s-.001&&n<.001||(n<-89.99||n>89.99))}var getBBoxWithTransform=function(e,t,n){var r=getBBox(e);if(!r)return null;var a=getTransformList(e),i=getRotationAngleFromTransformList(a),s=hasMatrixTransform(a);if(i||s){var o=!1;if(bBoxCanBeOptimizedOverNativeGetBBox(i,s)){if(["ellipse","path","line","polyline","polygon"].includes(e.tagName))r=o=getBBoxOfElementAsPath(e,t,n);else if("rect"===e.tagName){var l=e.getAttribute("rx"),c=e.getAttribute("ry");(l||c)&&(r=o=getBBoxOfElementAsPath(e,t,n))}}if(!o){var u=transformListToTransform(a).matrix;r=transformBox(r.x,r.y,r.width,r.height,u).aabox}}return r};function getStrokeOffsetForBBox(e){var t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}var getStrokedBBox=function(e,t,n){if(!e||!e.length)return!1;var r;if($$2.each(e,function(){r||this.parentNode&&(r=getBBoxWithTransform(this,t,n))}),void 0===r)return null;var a=r.x+r.width,i=r.y+r.height,s=r.x,o=r.y;if(1===e.length){var l=getStrokeOffsetForBBox(e[0]);s-=l,o-=l,a+=l,i+=l}else $$2.each(e,function(e,r){var l=getBBoxWithTransform(r,t,n);if(l){var c=getStrokeOffsetForBBox(r);s=Math.min(s,l.x-c),o=Math.min(o,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=s,r.y=o,r.width=a-s,r.height=i-o,r},getVisibleElements=function(e){e||(e=$$2(editorContext_$1.getSVGContent()).children());var t=[];return $$2(e).children().each(function(e,n){n.getBBox&&t.push(n)}),t.reverse()},getStrokedBBoxDefaultVisible=function(e){return e||(e=getVisibleElements()),getStrokedBBox(e,editorContext_$1.addSVGElementFromJson,editorContext_$1.pathActions)},getRotationAngleFromTransformList=function(e,t){if(!e)return 0;for(var n=e.numberOfItems,r=0;r|:\\-]","g"),"\\$&")},preventClickDefault=function(e){$$2(e).click(function(e){e.preventDefault()})},copyElem=function e(t,n){var r=document.createElementNS(t.namespaceURI,t.nodeName);if($$2.each(t.attributes,function(e,t){"-moz-math-font-style"!==t.localName&&r.setAttributeNS(t.namespaceURI,t.nodeName,t.value)}),r.removeAttribute("id"),r.id=n(),isWebkit()&&"path"===t.nodeName){var a=convertPath(t);r.setAttribute("d",a)}if($$2.each(t.childNodes,function(t,a){switch(a.nodeType){case 1:r.append(e(a,n));break;case 3:r.textContent=a.nodeValue}}),$$2(t).data("gsvg"))$$2(r).data("gsvg",r.firstChild);else if($$2(t).data("symbol")){var i=$$2(t).data("symbol");$$2(r).data("ref",i).data("symbol",i)}else"image"===r.tagName&&preventClickDefault(r);return r},isNullish=function(e){return null==e},$$3=jQuery,contextMenuExtensions={},hasCustomHandler=function(e){return Boolean(contextMenuExtensions[e])},getCustomHandler=function(e){return contextMenuExtensions[e].action},injectExtendedContextMenuItemIntoDom=function(e){Object.keys(contextMenuExtensions).length||$$3("#cmenu_canvas").append("
  • ");var t=e.shortcut||"";$$3("#cmenu_canvas").append("
  • "+e.label+""+t+"
  • ")},injectExtendedContextMenuItemsIntoDom=function(){Object.values(contextMenuExtensions).forEach(function(e){injectExtendedContextMenuItemIntoDom(e)})};function toAbsoluteURL(e){var t=document.createElement("a");return t.setAttribute("href",e),t.cloneNode(!1).href}function addScriptAtts(e,t){["id","class","type"].forEach(function(n){n in t&&(e[n]=t[n])})}function importSetGlobalDefault(e,t){return importSetGlobal(e,_extends({},t,{returnDefault:!0}))}function importSetGlobal(e,t){return _importSetGlobal.apply(this,arguments)}function _importSetGlobal(){return(_importSetGlobal=_asyncToGenerator(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",importModule(t,void 0,{returnDefault:a}));case 4:return e.next=6,importScript(t);case 6:return e.abrupt("return",window[r]);case 7:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function importScript(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Array.isArray(e)?Promise.all(e.map(function(e){return importScript(e,t)})):new Promise(function(n,r){var a=document.createElement("script");function i(){r(new Error("Failed to import: ".concat(e))),o()}function s(){n(),o()}var o=function(){a.removeEventListener("error",i),a.removeEventListener("load",s),a.remove(),a.src=""};a.defer="defer",addScriptAtts(a,t),a.addEventListener("error",i),a.addEventListener("load",s),a.src=e,document.head.append(a)})}function importModule(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).returnDefault,r=void 0!==n&&n;return Array.isArray(e)?Promise.all(e.map(function(e){return importModule(e,t)})):new Promise(function(n,a){var i="$importModule$"+Math.random().toString(32).slice(2),s=document.createElement("script");function o(){a(new Error("Failed to import: ".concat(e))),c()}function l(){n(window[i]),c()}var c=function(){delete window[i],s.removeEventListener("error",o),s.removeEventListener("load",l),s.remove(),URL.revokeObjectURL(s.src),s.src=""};addScriptAtts(s,t),s.defer="defer",s.type="module",s.addEventListener("error",o),s.addEventListener("load",l);var u=toAbsoluteURL(e),d="import * as m from '".concat(u.replace(/'/g,"\\'"),"'; window.").concat(i," = ").concat(r?"m.default || ":"","m;"),h=new Blob([d],{type:"text/javascript"});s.src=URL.createObjectURL(h),document.head.append(s)})}function jQueryPluginDBox(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ok:"Ok",cancel:"Cancel"};e("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"}).css("position","absolute");var n=e("#dialog_box"),r=e("#dialog_buttons"),a=e("#dialog_content");function i(i,s,o,l,c,u){a.html("

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

    ")+"

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