From 19f7962c4a45458dfd6d58c6b16829db6127fc3d Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sat, 16 Nov 2019 10:08:38 +0800 Subject: [PATCH] - Revert `prefer-named-capture-group` due to apparently problematic Babel plugin --- .eslintrc.js | 3 +- dist/canvg.js | 124 +------------- dist/extensions/ext-arrows.js | 173 +------------------ dist/extensions/ext-markers.js | 173 +------------------ dist/extensions/ext-placemark.js | 176 +------------------- dist/extensions/ext-server_moinsave.js | 124 +------------- dist/extensions/ext-server_opensave.js | 124 +------------- dist/extensions/ext-storage.js | 176 +------------------- dist/index-es.js | 222 +++++-------------------- dist/index-es.min.js | 2 +- dist/index-es.min.js.map | 2 +- dist/index-umd.js | 222 +++++-------------------- dist/index-umd.min.js | 2 +- dist/index-umd.min.js.map | 2 +- dist/jspdf.plugin.svgToPdf.js | 185 +-------------------- dist/svgcanvas-iife.js | 208 ++++------------------- dist/svgcanvas-iife.min.js | 2 +- dist/svgcanvas-iife.min.js.map | 2 +- editor/canvg/canvg.js | 2 +- editor/canvg/rgbcolor.js | 9 +- editor/embedapi-dom.js | 1 - editor/extensions/ext-arrows.js | 9 +- editor/extensions/ext-markers.js | 9 +- editor/extensions/ext-placemark.js | 10 +- editor/extensions/ext-storage.js | 5 + editor/sanitize.js | 3 +- editor/svg-editor.js | 12 +- editor/svgcanvas.js | 6 +- editor/svgtransformlist.js | 13 +- editor/utilities.js | 9 +- editor/xdomain-svgedit-config-iife.js | 222 +++++-------------------- rollup.config.js | 7 +- svgedit-config-iife.js | 222 +++++-------------------- 33 files changed, 315 insertions(+), 2146 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 83fa8c1f..1a647263 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -140,7 +140,6 @@ module.exports = { root: "off" }, rules: { - "node/no-unsupported-features/es-syntax": "off", "node/no-unsupported-features/node-builtins": "off" } }, @@ -188,6 +187,8 @@ module.exports = { } ], rules: { + // The Babel transform seems to have a problem converting these + "prefer-named-capture-group": "off", // Override these `ash-nazg/sauron` rules which are difficult for us // to apply at this time "unicorn/prefer-string-slice": "off", diff --git a/dist/canvg.js b/dist/canvg.js index 9296533b..38992de2 100644 --- a/dist/canvg.js +++ b/dist/canvg.js @@ -98,44 +98,6 @@ var canvg = (function (exports) { return _construct.apply(null, arguments); } - function _isNativeFunction(fn) { - return Function.toString.call(fn).indexOf("[native code]") !== -1; - } - - function _wrapNativeSuper(Class) { - var _cache = typeof Map === "function" ? new Map() : undefined; - - _wrapNativeSuper = function _wrapNativeSuper(Class) { - if (Class === null || !_isNativeFunction(Class)) return Class; - - if (typeof Class !== "function") { - throw new TypeError("Super expression must either be null or a function"); - } - - if (typeof _cache !== "undefined") { - if (_cache.has(Class)) return _cache.get(Class); - - _cache.set(Class, Wrapper); - } - - function Wrapper() { - return _construct(Class, arguments, _getPrototypeOf(this).constructor); - } - - Wrapper.prototype = Object.create(Class.prototype, { - constructor: { - value: Wrapper, - enumerable: false, - writable: true, - configurable: true - } - }); - return _setPrototypeOf(Wrapper, Class); - }; - - return _wrapNativeSuper(Class); - } - function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); @@ -244,71 +206,6 @@ var canvg = (function (exports) { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } - function _wrapRegExp(re, groups) { - _wrapRegExp = function (re, groups) { - return new BabelRegExp(re, undefined, groups); - }; - - var _RegExp = _wrapNativeSuper(RegExp); - - var _super = RegExp.prototype; - - var _groups = new WeakMap(); - - function BabelRegExp(re, flags, groups) { - var _this = _RegExp.call(this, re, flags); - - _groups.set(_this, groups || _groups.get(re)); - - return _this; - } - - _inherits(BabelRegExp, _RegExp); - - BabelRegExp.prototype.exec = function (str) { - var result = _super.exec.call(this, str); - - if (result) result.groups = buildGroups(result, this); - return result; - }; - - BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { - if (typeof substitution === "string") { - var groups = _groups.get(this); - - return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { - return "$" + groups[name]; - })); - } else if (typeof substitution === "function") { - var _this = this; - - return _super[Symbol.replace].call(this, str, function () { - var args = []; - args.push.apply(args, arguments); - - if (typeof args[args.length - 1] !== "object") { - args.push(buildGroups(args, _this)); - } - - return substitution.apply(this, args); - }); - } else { - return _super[Symbol.replace].call(this, str, substitution); - } - }; - - function buildGroups(result, re) { - var g = _groups.get(re); - - return Object.keys(g).reduce(function (groups, name) { - groups[name] = result[g[name]]; - return groups; - }, Object.create(null)); - } - - return _wrapRegExp.apply(this, arguments); - } - /** * For parsing color values * @module RGBColor @@ -463,11 +360,8 @@ var canvg = (function (exports) { }; // array of color definition objects var colorDefs = [{ - re: _wrapRegExp(/^rgb\(([0-9]{1,3}),[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*([0-9]{1,3}),[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*([0-9]{1,3})\)$/, { - r: 1, - g: 2, - b: 3 - }), + re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/, + // re: /^rgb\((?\d{1,3}),\s*(?\d{1,3}),\s*(?\d{1,3})\)$/, example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'], process: function process(_) { for (var _len = arguments.length, bits = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { @@ -479,11 +373,8 @@ var canvg = (function (exports) { }); } }, { - re: _wrapRegExp(/^([0-9A-Z_a-z]{2})([0-9A-Z_a-z]{2})([0-9A-Z_a-z]{2})$/, { - r: 1, - g: 2, - b: 3 - }), + re: /^(\w{2})(\w{2})(\w{2})$/, + // re: /^(?\w{2})(?\w{2})(?\w{2})$/, example: ['#00ff00', '336699'], process: function process(_) { for (var _len2 = arguments.length, bits = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { @@ -495,11 +386,8 @@ var canvg = (function (exports) { }); } }, { - re: _wrapRegExp(/^([0-9A-Z_a-z]{1})([0-9A-Z_a-z]{1})([0-9A-Z_a-z]{1})$/, { - r: 1, - g: 2, - b: 3 - }), + re: /^(\w{1})(\w{1})(\w{1})$/, + // re: /^(?\w{1})(?\w{1})(?\w{1})$/, example: ['#fb0', 'f0f'], process: function process(_) { for (var _len3 = arguments.length, bits = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { diff --git a/dist/extensions/ext-arrows.js b/dist/extensions/ext-arrows.js index 76e7c98b..c4def664 100644 --- a/dist/extensions/ext-arrows.js +++ b/dist/extensions/ext-arrows.js @@ -1,170 +1,6 @@ var svgEditorExtension_arrows = (function () { 'use strict'; - function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } - }); - if (superClass) _setPrototypeOf(subClass, superClass); - } - - function _getPrototypeOf(o) { - _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return _getPrototypeOf(o); - } - - function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - - return _setPrototypeOf(o, p); - } - - function isNativeReflectConstruct() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - if (Reflect.construct.sham) return false; - if (typeof Proxy === "function") return true; - - try { - Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); - return true; - } catch (e) { - return false; - } - } - - function _construct(Parent, args, Class) { - if (isNativeReflectConstruct()) { - _construct = Reflect.construct; - } else { - _construct = function _construct(Parent, args, Class) { - var a = [null]; - a.push.apply(a, args); - var Constructor = Function.bind.apply(Parent, a); - var instance = new Constructor(); - if (Class) _setPrototypeOf(instance, Class.prototype); - return instance; - }; - } - - return _construct.apply(null, arguments); - } - - function _isNativeFunction(fn) { - return Function.toString.call(fn).indexOf("[native code]") !== -1; - } - - function _wrapNativeSuper(Class) { - var _cache = typeof Map === "function" ? new Map() : undefined; - - _wrapNativeSuper = function _wrapNativeSuper(Class) { - if (Class === null || !_isNativeFunction(Class)) return Class; - - if (typeof Class !== "function") { - throw new TypeError("Super expression must either be null or a function"); - } - - if (typeof _cache !== "undefined") { - if (_cache.has(Class)) return _cache.get(Class); - - _cache.set(Class, Wrapper); - } - - function Wrapper() { - return _construct(Class, arguments, _getPrototypeOf(this).constructor); - } - - Wrapper.prototype = Object.create(Class.prototype, { - constructor: { - value: Wrapper, - enumerable: false, - writable: true, - configurable: true - } - }); - return _setPrototypeOf(Wrapper, Class); - }; - - return _wrapNativeSuper(Class); - } - - function _wrapRegExp(re, groups) { - _wrapRegExp = function (re, groups) { - return new BabelRegExp(re, undefined, groups); - }; - - var _RegExp = _wrapNativeSuper(RegExp); - - var _super = RegExp.prototype; - - var _groups = new WeakMap(); - - function BabelRegExp(re, flags, groups) { - var _this = _RegExp.call(this, re, flags); - - _groups.set(_this, groups || _groups.get(re)); - - return _this; - } - - _inherits(BabelRegExp, _RegExp); - - BabelRegExp.prototype.exec = function (str) { - var result = _super.exec.call(this, str); - - if (result) result.groups = buildGroups(result, this); - return result; - }; - - BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { - if (typeof substitution === "string") { - var groups = _groups.get(this); - - return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { - return "$" + groups[name]; - })); - } else if (typeof substitution === "function") { - var _this = this; - - return _super[Symbol.replace].call(this, str, function () { - var args = []; - args.push.apply(args, arguments); - - if (typeof args[args.length - 1] !== "object") { - args.push(buildGroups(args, _this)); - } - - return substitution.apply(this, args); - }); - } else { - return _super[Symbol.replace].call(this, str, substitution); - } - }; - - function buildGroups(result, re) { - var g = _groups.get(re); - - return Object.keys(g).reduce(function (groups, name) { - groups[name] = result[g[name]]; - return groups; - }, Object.create(null)); - } - - return _wrapRegExp.apply(this, arguments); - } - /** * ext-arrows.js * @@ -362,15 +198,14 @@ var svgEditorExtension_arrows = (function () { return null; } - var m = str.match(_wrapRegExp(/\(#(.+)\)/, { - id: 1 - })); + var m = str.match(/\(#(.*)\)/); // const m = str.match(/\(#(?.+)\)/); + // if (!m || !m.groups.id) { - if (!m || !m.groups.id) { + if (!m || m.length !== 2) { return null; } - return svgCanvas.getElem(m.groups.id); + return svgCanvas.getElem(m[1]); // return svgCanvas.getElem(m.groups.id); }; unsetArrowNonce = function _ref4(win) { diff --git a/dist/extensions/ext-markers.js b/dist/extensions/ext-markers.js index eaf03880..e63c612e 100644 --- a/dist/extensions/ext-markers.js +++ b/dist/extensions/ext-markers.js @@ -1,170 +1,6 @@ var svgEditorExtension_markers = (function () { 'use strict'; - function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } - }); - if (superClass) _setPrototypeOf(subClass, superClass); - } - - function _getPrototypeOf(o) { - _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return _getPrototypeOf(o); - } - - function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - - return _setPrototypeOf(o, p); - } - - function isNativeReflectConstruct() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - if (Reflect.construct.sham) return false; - if (typeof Proxy === "function") return true; - - try { - Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); - return true; - } catch (e) { - return false; - } - } - - function _construct(Parent, args, Class) { - if (isNativeReflectConstruct()) { - _construct = Reflect.construct; - } else { - _construct = function _construct(Parent, args, Class) { - var a = [null]; - a.push.apply(a, args); - var Constructor = Function.bind.apply(Parent, a); - var instance = new Constructor(); - if (Class) _setPrototypeOf(instance, Class.prototype); - return instance; - }; - } - - return _construct.apply(null, arguments); - } - - function _isNativeFunction(fn) { - return Function.toString.call(fn).indexOf("[native code]") !== -1; - } - - function _wrapNativeSuper(Class) { - var _cache = typeof Map === "function" ? new Map() : undefined; - - _wrapNativeSuper = function _wrapNativeSuper(Class) { - if (Class === null || !_isNativeFunction(Class)) return Class; - - if (typeof Class !== "function") { - throw new TypeError("Super expression must either be null or a function"); - } - - if (typeof _cache !== "undefined") { - if (_cache.has(Class)) return _cache.get(Class); - - _cache.set(Class, Wrapper); - } - - function Wrapper() { - return _construct(Class, arguments, _getPrototypeOf(this).constructor); - } - - Wrapper.prototype = Object.create(Class.prototype, { - constructor: { - value: Wrapper, - enumerable: false, - writable: true, - configurable: true - } - }); - return _setPrototypeOf(Wrapper, Class); - }; - - return _wrapNativeSuper(Class); - } - - function _wrapRegExp(re, groups) { - _wrapRegExp = function (re, groups) { - return new BabelRegExp(re, undefined, groups); - }; - - var _RegExp = _wrapNativeSuper(RegExp); - - var _super = RegExp.prototype; - - var _groups = new WeakMap(); - - function BabelRegExp(re, flags, groups) { - var _this = _RegExp.call(this, re, flags); - - _groups.set(_this, groups || _groups.get(re)); - - return _this; - } - - _inherits(BabelRegExp, _RegExp); - - BabelRegExp.prototype.exec = function (str) { - var result = _super.exec.call(this, str); - - if (result) result.groups = buildGroups(result, this); - return result; - }; - - BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { - if (typeof substitution === "string") { - var groups = _groups.get(this); - - return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { - return "$" + groups[name]; - })); - } else if (typeof substitution === "function") { - var _this = this; - - return _super[Symbol.replace].call(this, str, function () { - var args = []; - args.push.apply(args, arguments); - - if (typeof args[args.length - 1] !== "object") { - args.push(buildGroups(args, _this)); - } - - return substitution.apply(this, args); - }); - } else { - return _super[Symbol.replace].call(this, str, substitution); - } - }; - - function buildGroups(result, re) { - var g = _groups.get(re); - - return Object.keys(g).reduce(function (groups, name) { - groups[name] = result[g[name]]; - return groups; - }, Object.create(null)); - } - - return _wrapRegExp.apply(this, arguments); - } - /** * ext-markers.js * @@ -641,15 +477,14 @@ var svgEditorExtension_markers = (function () { return null; } - var m = str.match(_wrapRegExp(/\(#(.+)\)/, { - id: 1 - })); + var m = str.match(/\(#(.*)\)/); // const m = str.match(/\(#(?.+)\)/); + // if (!m || !m.groups.id) { - if (!m || !m.groups.id) { + if (!m || m.length !== 2) { return null; } - return svgCanvas.getElem(m.groups.id); + return svgCanvas.getElem(m[1]); // return svgCanvas.getElem(m.groups.id); }; _context3.next = 15; diff --git a/dist/extensions/ext-placemark.js b/dist/extensions/ext-placemark.js index de9fe0ed..304d0c56 100644 --- a/dist/extensions/ext-placemark.js +++ b/dist/extensions/ext-placemark.js @@ -1,105 +1,6 @@ var svgEditorExtension_placemark = (function () { 'use strict'; - function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } - }); - if (superClass) _setPrototypeOf(subClass, superClass); - } - - function _getPrototypeOf(o) { - _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return _getPrototypeOf(o); - } - - function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - - return _setPrototypeOf(o, p); - } - - function isNativeReflectConstruct() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - if (Reflect.construct.sham) return false; - if (typeof Proxy === "function") return true; - - try { - Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); - return true; - } catch (e) { - return false; - } - } - - function _construct(Parent, args, Class) { - if (isNativeReflectConstruct()) { - _construct = Reflect.construct; - } else { - _construct = function _construct(Parent, args, Class) { - var a = [null]; - a.push.apply(a, args); - var Constructor = Function.bind.apply(Parent, a); - var instance = new Constructor(); - if (Class) _setPrototypeOf(instance, Class.prototype); - return instance; - }; - } - - return _construct.apply(null, arguments); - } - - function _isNativeFunction(fn) { - return Function.toString.call(fn).indexOf("[native code]") !== -1; - } - - function _wrapNativeSuper(Class) { - var _cache = typeof Map === "function" ? new Map() : undefined; - - _wrapNativeSuper = function _wrapNativeSuper(Class) { - if (Class === null || !_isNativeFunction(Class)) return Class; - - if (typeof Class !== "function") { - throw new TypeError("Super expression must either be null or a function"); - } - - if (typeof _cache !== "undefined") { - if (_cache.has(Class)) return _cache.get(Class); - - _cache.set(Class, Wrapper); - } - - function Wrapper() { - return _construct(Class, arguments, _getPrototypeOf(this).constructor); - } - - Wrapper.prototype = Object.create(Class.prototype, { - constructor: { - value: Wrapper, - enumerable: false, - writable: true, - configurable: true - } - }); - return _setPrototypeOf(Wrapper, Class); - }; - - return _wrapNativeSuper(Class); - } - function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } @@ -142,71 +43,6 @@ var svgEditorExtension_placemark = (function () { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } - function _wrapRegExp(re, groups) { - _wrapRegExp = function (re, groups) { - return new BabelRegExp(re, undefined, groups); - }; - - var _RegExp = _wrapNativeSuper(RegExp); - - var _super = RegExp.prototype; - - var _groups = new WeakMap(); - - function BabelRegExp(re, flags, groups) { - var _this = _RegExp.call(this, re, flags); - - _groups.set(_this, groups || _groups.get(re)); - - return _this; - } - - _inherits(BabelRegExp, _RegExp); - - BabelRegExp.prototype.exec = function (str) { - var result = _super.exec.call(this, str); - - if (result) result.groups = buildGroups(result, this); - return result; - }; - - BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { - if (typeof substitution === "string") { - var groups = _groups.get(this); - - return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { - return "$" + groups[name]; - })); - } else if (typeof substitution === "function") { - var _this = this; - - return _super[Symbol.replace].call(this, str, function () { - var args = []; - args.push.apply(args, arguments); - - if (typeof args[args.length - 1] !== "object") { - args.push(buildGroups(args, _this)); - } - - return substitution.apply(this, args); - }); - } else { - return _super[Symbol.replace].call(this, str, substitution); - } - }; - - function buildGroups(result, re) { - var g = _groups.get(re); - - return Object.keys(g).reduce(function (groups, name) { - groups[name] = result[g[name]]; - return groups; - }, Object.create(null)); - } - - return _wrapRegExp.apply(this, arguments); - } - /** * ext-placemark.js * @@ -448,17 +284,17 @@ var svgEditorExtension_placemark = (function () { if (!str) { return null; - } + } // const m = str.match(/\(#(?.+)\)/); + // if (!m || !m.groups.id) { - var m = str.match(_wrapRegExp(/\(#(.+)\)/, { - id: 1 - })); - if (!m || !m.groups.id) { + var m = str.match(/\(#(.*)\)/); + + if (!m || m.length !== 2) { return null; } - return svgCanvas.getElem(m.groups.id); + return svgCanvas.getElem(m[1]); // return svgCanvas.getElem(m.groups.id); }; showPanel = function _ref(on) { diff --git a/dist/extensions/ext-server_moinsave.js b/dist/extensions/ext-server_moinsave.js index fc95afb5..a1c08a3f 100644 --- a/dist/extensions/ext-server_moinsave.js +++ b/dist/extensions/ext-server_moinsave.js @@ -98,44 +98,6 @@ var svgEditorExtension_server_moinsave = (function () { return _construct.apply(null, arguments); } - function _isNativeFunction(fn) { - return Function.toString.call(fn).indexOf("[native code]") !== -1; - } - - function _wrapNativeSuper(Class) { - var _cache = typeof Map === "function" ? new Map() : undefined; - - _wrapNativeSuper = function _wrapNativeSuper(Class) { - if (Class === null || !_isNativeFunction(Class)) return Class; - - if (typeof Class !== "function") { - throw new TypeError("Super expression must either be null or a function"); - } - - if (typeof _cache !== "undefined") { - if (_cache.has(Class)) return _cache.get(Class); - - _cache.set(Class, Wrapper); - } - - function Wrapper() { - return _construct(Class, arguments, _getPrototypeOf(this).constructor); - } - - Wrapper.prototype = Object.create(Class.prototype, { - constructor: { - value: Wrapper, - enumerable: false, - writable: true, - configurable: true - } - }); - return _setPrototypeOf(Wrapper, Class); - }; - - return _wrapNativeSuper(Class); - } - function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); @@ -244,71 +206,6 @@ var svgEditorExtension_server_moinsave = (function () { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } - function _wrapRegExp(re, groups) { - _wrapRegExp = function (re, groups) { - return new BabelRegExp(re, undefined, groups); - }; - - var _RegExp = _wrapNativeSuper(RegExp); - - var _super = RegExp.prototype; - - var _groups = new WeakMap(); - - function BabelRegExp(re, flags, groups) { - var _this = _RegExp.call(this, re, flags); - - _groups.set(_this, groups || _groups.get(re)); - - return _this; - } - - _inherits(BabelRegExp, _RegExp); - - BabelRegExp.prototype.exec = function (str) { - var result = _super.exec.call(this, str); - - if (result) result.groups = buildGroups(result, this); - return result; - }; - - BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { - if (typeof substitution === "string") { - var groups = _groups.get(this); - - return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { - return "$" + groups[name]; - })); - } else if (typeof substitution === "function") { - var _this = this; - - return _super[Symbol.replace].call(this, str, function () { - var args = []; - args.push.apply(args, arguments); - - if (typeof args[args.length - 1] !== "object") { - args.push(buildGroups(args, _this)); - } - - return substitution.apply(this, args); - }); - } else { - return _super[Symbol.replace].call(this, str, substitution); - } - }; - - function buildGroups(result, re) { - var g = _groups.get(re); - - return Object.keys(g).reduce(function (groups, name) { - groups[name] = result[g[name]]; - return groups; - }, Object.create(null)); - } - - return _wrapRegExp.apply(this, arguments); - } - /** * For parsing color values * @module RGBColor @@ -463,11 +360,8 @@ var svgEditorExtension_server_moinsave = (function () { }; // array of color definition objects var colorDefs = [{ - re: _wrapRegExp(/^rgb\(([0-9]{1,3}),[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*([0-9]{1,3}),[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*([0-9]{1,3})\)$/, { - r: 1, - g: 2, - b: 3 - }), + re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/, + // re: /^rgb\((?\d{1,3}),\s*(?\d{1,3}),\s*(?\d{1,3})\)$/, example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'], process: function process(_) { for (var _len = arguments.length, bits = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { @@ -479,11 +373,8 @@ var svgEditorExtension_server_moinsave = (function () { }); } }, { - re: _wrapRegExp(/^([0-9A-Z_a-z]{2})([0-9A-Z_a-z]{2})([0-9A-Z_a-z]{2})$/, { - r: 1, - g: 2, - b: 3 - }), + re: /^(\w{2})(\w{2})(\w{2})$/, + // re: /^(?\w{2})(?\w{2})(?\w{2})$/, example: ['#00ff00', '336699'], process: function process(_) { for (var _len2 = arguments.length, bits = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { @@ -495,11 +386,8 @@ var svgEditorExtension_server_moinsave = (function () { }); } }, { - re: _wrapRegExp(/^([0-9A-Z_a-z]{1})([0-9A-Z_a-z]{1})([0-9A-Z_a-z]{1})$/, { - r: 1, - g: 2, - b: 3 - }), + re: /^(\w{1})(\w{1})(\w{1})$/, + // re: /^(?\w{1})(?\w{1})(?\w{1})$/, example: ['#fb0', 'f0f'], process: function process(_) { for (var _len3 = arguments.length, bits = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { diff --git a/dist/extensions/ext-server_opensave.js b/dist/extensions/ext-server_opensave.js index 5a9a742a..66651866 100644 --- a/dist/extensions/ext-server_opensave.js +++ b/dist/extensions/ext-server_opensave.js @@ -98,44 +98,6 @@ var svgEditorExtension_server_opensave = (function () { return _construct.apply(null, arguments); } - function _isNativeFunction(fn) { - return Function.toString.call(fn).indexOf("[native code]") !== -1; - } - - function _wrapNativeSuper(Class) { - var _cache = typeof Map === "function" ? new Map() : undefined; - - _wrapNativeSuper = function _wrapNativeSuper(Class) { - if (Class === null || !_isNativeFunction(Class)) return Class; - - if (typeof Class !== "function") { - throw new TypeError("Super expression must either be null or a function"); - } - - if (typeof _cache !== "undefined") { - if (_cache.has(Class)) return _cache.get(Class); - - _cache.set(Class, Wrapper); - } - - function Wrapper() { - return _construct(Class, arguments, _getPrototypeOf(this).constructor); - } - - Wrapper.prototype = Object.create(Class.prototype, { - constructor: { - value: Wrapper, - enumerable: false, - writable: true, - configurable: true - } - }); - return _setPrototypeOf(Wrapper, Class); - }; - - return _wrapNativeSuper(Class); - } - function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); @@ -244,71 +206,6 @@ var svgEditorExtension_server_opensave = (function () { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } - function _wrapRegExp(re, groups) { - _wrapRegExp = function (re, groups) { - return new BabelRegExp(re, undefined, groups); - }; - - var _RegExp = _wrapNativeSuper(RegExp); - - var _super = RegExp.prototype; - - var _groups = new WeakMap(); - - function BabelRegExp(re, flags, groups) { - var _this = _RegExp.call(this, re, flags); - - _groups.set(_this, groups || _groups.get(re)); - - return _this; - } - - _inherits(BabelRegExp, _RegExp); - - BabelRegExp.prototype.exec = function (str) { - var result = _super.exec.call(this, str); - - if (result) result.groups = buildGroups(result, this); - return result; - }; - - BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { - if (typeof substitution === "string") { - var groups = _groups.get(this); - - return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { - return "$" + groups[name]; - })); - } else if (typeof substitution === "function") { - var _this = this; - - return _super[Symbol.replace].call(this, str, function () { - var args = []; - args.push.apply(args, arguments); - - if (typeof args[args.length - 1] !== "object") { - args.push(buildGroups(args, _this)); - } - - return substitution.apply(this, args); - }); - } else { - return _super[Symbol.replace].call(this, str, substitution); - } - }; - - function buildGroups(result, re) { - var g = _groups.get(re); - - return Object.keys(g).reduce(function (groups, name) { - groups[name] = result[g[name]]; - return groups; - }, Object.create(null)); - } - - return _wrapRegExp.apply(this, arguments); - } - /** * For parsing color values * @module RGBColor @@ -463,11 +360,8 @@ var svgEditorExtension_server_opensave = (function () { }; // array of color definition objects var colorDefs = [{ - re: _wrapRegExp(/^rgb\(([0-9]{1,3}),[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*([0-9]{1,3}),[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*([0-9]{1,3})\)$/, { - r: 1, - g: 2, - b: 3 - }), + re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/, + // re: /^rgb\((?\d{1,3}),\s*(?\d{1,3}),\s*(?\d{1,3})\)$/, example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'], process: function process(_) { for (var _len = arguments.length, bits = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { @@ -479,11 +373,8 @@ var svgEditorExtension_server_opensave = (function () { }); } }, { - re: _wrapRegExp(/^([0-9A-Z_a-z]{2})([0-9A-Z_a-z]{2})([0-9A-Z_a-z]{2})$/, { - r: 1, - g: 2, - b: 3 - }), + re: /^(\w{2})(\w{2})(\w{2})$/, + // re: /^(?\w{2})(?\w{2})(?\w{2})$/, example: ['#00ff00', '336699'], process: function process(_) { for (var _len2 = arguments.length, bits = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { @@ -495,11 +386,8 @@ var svgEditorExtension_server_opensave = (function () { }); } }, { - re: _wrapRegExp(/^([0-9A-Z_a-z]{1})([0-9A-Z_a-z]{1})([0-9A-Z_a-z]{1})$/, { - r: 1, - g: 2, - b: 3 - }), + re: /^(\w{1})(\w{1})(\w{1})$/, + // re: /^(?\w{1})(?\w{1})(?\w{1})$/, example: ['#fb0', 'f0f'], process: function process(_) { for (var _len3 = arguments.length, bits = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { diff --git a/dist/extensions/ext-storage.js b/dist/extensions/ext-storage.js index 6bfd7729..88e04afa 100644 --- a/dist/extensions/ext-storage.js +++ b/dist/extensions/ext-storage.js @@ -1,105 +1,6 @@ var svgEditorExtension_storage = (function () { 'use strict'; - function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } - }); - if (superClass) _setPrototypeOf(subClass, superClass); - } - - function _getPrototypeOf(o) { - _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return _getPrototypeOf(o); - } - - function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - - return _setPrototypeOf(o, p); - } - - function isNativeReflectConstruct() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - if (Reflect.construct.sham) return false; - if (typeof Proxy === "function") return true; - - try { - Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); - return true; - } catch (e) { - return false; - } - } - - function _construct(Parent, args, Class) { - if (isNativeReflectConstruct()) { - _construct = Reflect.construct; - } else { - _construct = function _construct(Parent, args, Class) { - var a = [null]; - a.push.apply(a, args); - var Constructor = Function.bind.apply(Parent, a); - var instance = new Constructor(); - if (Class) _setPrototypeOf(instance, Class.prototype); - return instance; - }; - } - - return _construct.apply(null, arguments); - } - - function _isNativeFunction(fn) { - return Function.toString.call(fn).indexOf("[native code]") !== -1; - } - - function _wrapNativeSuper(Class) { - var _cache = typeof Map === "function" ? new Map() : undefined; - - _wrapNativeSuper = function _wrapNativeSuper(Class) { - if (Class === null || !_isNativeFunction(Class)) return Class; - - if (typeof Class !== "function") { - throw new TypeError("Super expression must either be null or a function"); - } - - if (typeof _cache !== "undefined") { - if (_cache.has(Class)) return _cache.get(Class); - - _cache.set(Class, Wrapper); - } - - function Wrapper() { - return _construct(Class, arguments, _getPrototypeOf(this).constructor); - } - - Wrapper.prototype = Object.create(Class.prototype, { - constructor: { - value: Wrapper, - enumerable: false, - writable: true, - configurable: true - } - }); - return _setPrototypeOf(Wrapper, Class); - }; - - return _wrapNativeSuper(Class); - } - function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } @@ -142,71 +43,6 @@ var svgEditorExtension_storage = (function () { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } - function _wrapRegExp(re, groups) { - _wrapRegExp = function (re, groups) { - return new BabelRegExp(re, undefined, groups); - }; - - var _RegExp = _wrapNativeSuper(RegExp); - - var _super = RegExp.prototype; - - var _groups = new WeakMap(); - - function BabelRegExp(re, flags, groups) { - var _this = _RegExp.call(this, re, flags); - - _groups.set(_this, groups || _groups.get(re)); - - return _this; - } - - _inherits(BabelRegExp, _RegExp); - - BabelRegExp.prototype.exec = function (str) { - var result = _super.exec.call(this, str); - - if (result) result.groups = buildGroups(result, this); - return result; - }; - - BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { - if (typeof substitution === "string") { - var groups = _groups.get(this); - - return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { - return "$" + groups[name]; - })); - } else if (typeof substitution === "function") { - var _this = this; - - return _super[Symbol.replace].call(this, str, function () { - var args = []; - args.push.apply(args, arguments); - - if (typeof args[args.length - 1] !== "object") { - args.push(buildGroups(args, _this)); - } - - return substitution.apply(this, args); - }); - } else { - return _super[Symbol.replace].call(this, str, substitution); - } - }; - - function buildGroups(result, re) { - var g = _groups.get(re); - - return Object.keys(g).reduce(function (groups, name) { - groups[name] = result[g[name]]; - return groups; - }, Object.create(null)); - } - - return _wrapRegExp.apply(this, arguments); - } - /** * ext-storage.js * @@ -257,11 +93,13 @@ var svgEditorExtension_storage = (function () { var loc = top.location; // Allow this to work with the embedded editor as well if (loc.href.includes('storagePrompt=')) { - loc.href = loc.href.replace(_wrapRegExp(/([&\?])storagePrompt=[\0-%'-\uFFFF]*(&?)/, { - sep: 1, - amp: 2 - }), function (n0, sep, amp) { - return (val ? sep : '') + val + (!val && amp ? sep : amp || ''); + /* + loc.href = loc.href.replace(/(?[&?])storagePrompt=[^&]*(?&?)/, function (n0, sep, amp) { + return (val ? sep : '') + val + (!val && amp ? sep : (amp || '')); + }); + */ + loc.href = loc.href.replace(/([&?])storagePrompt=[^&]*(&?)/, function (n0, n1, amp) { + return (val ? n1 : '') + val + (!val && amp ? n1 : amp || ''); }); } else { loc.href += (loc.href.includes('?') ? '&' : '?') + val; diff --git a/dist/index-es.js b/dist/index-es.js index 9cd69ae3..f35c57b3 100644 --- a/dist/index-es.js +++ b/dist/index-es.js @@ -83,74 +83,6 @@ function _setPrototypeOf(o, p) { return _setPrototypeOf(o, p); } -function isNativeReflectConstruct() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - if (Reflect.construct.sham) return false; - if (typeof Proxy === "function") return true; - - try { - Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); - return true; - } catch (e) { - return false; - } -} - -function _construct(Parent, args, Class) { - if (isNativeReflectConstruct()) { - _construct = Reflect.construct; - } else { - _construct = function _construct(Parent, args, Class) { - var a = [null]; - a.push.apply(a, args); - var Constructor = Function.bind.apply(Parent, a); - var instance = new Constructor(); - if (Class) _setPrototypeOf(instance, Class.prototype); - return instance; - }; - } - - return _construct.apply(null, arguments); -} - -function _isNativeFunction(fn) { - return Function.toString.call(fn).indexOf("[native code]") !== -1; -} - -function _wrapNativeSuper(Class) { - var _cache = typeof Map === "function" ? new Map() : undefined; - - _wrapNativeSuper = function _wrapNativeSuper(Class) { - if (Class === null || !_isNativeFunction(Class)) return Class; - - if (typeof Class !== "function") { - throw new TypeError("Super expression must either be null or a function"); - } - - if (typeof _cache !== "undefined") { - if (_cache.has(Class)) return _cache.get(Class); - - _cache.set(Class, Wrapper); - } - - function Wrapper() { - return _construct(Class, arguments, _getPrototypeOf(this).constructor); - } - - Wrapper.prototype = Object.create(Class.prototype, { - constructor: { - value: Wrapper, - enumerable: false, - writable: true, - configurable: true - } - }); - return _setPrototypeOf(Wrapper, Class); - }; - - return _wrapNativeSuper(Class); -} - function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); @@ -229,71 +161,6 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } -function _wrapRegExp(re, groups) { - _wrapRegExp = function (re, groups) { - return new BabelRegExp(re, undefined, groups); - }; - - var _RegExp = _wrapNativeSuper(RegExp); - - var _super = RegExp.prototype; - - var _groups = new WeakMap(); - - function BabelRegExp(re, flags, groups) { - var _this = _RegExp.call(this, re, flags); - - _groups.set(_this, groups || _groups.get(re)); - - return _this; - } - - _inherits(BabelRegExp, _RegExp); - - BabelRegExp.prototype.exec = function (str) { - var result = _super.exec.call(this, str); - - if (result) result.groups = buildGroups(result, this); - return result; - }; - - BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { - if (typeof substitution === "string") { - var groups = _groups.get(this); - - return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { - return "$" + groups[name]; - })); - } else if (typeof substitution === "function") { - var _this = this; - - return _super[Symbol.replace].call(this, str, function () { - var args = []; - args.push.apply(args, arguments); - - if (typeof args[args.length - 1] !== "object") { - args.push(buildGroups(args, _this)); - } - - return substitution.apply(this, args); - }); - } else { - return _super[Symbol.replace].call(this, str, substitution); - } - }; - - function buildGroups(result, re) { - var g = _groups.get(re); - - return Object.keys(g).reduce(function (groups, name) { - groups[name] = result[g[name]]; - return groups; - }, Object.create(null)); - } - - return _wrapRegExp.apply(this, arguments); -} - // http://ross.posterous.com/2008/08/19/iphone-touch-events-in-javascript/ /** @@ -3268,9 +3135,7 @@ function () { } // TODO: Add skew support in future - var re = _wrapRegExp(/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*((?:scale|matrix|rotate|translate)[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*\(.*?\))[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*,?[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*/, { - xform: 1 - }); + var re = /\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/; // const re = /\s*(?(?:scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/; var m = true; @@ -3278,24 +3143,26 @@ function () { m = str.match(re); str = str.replace(re, ''); - if (m && m.groups.xform) { + if (m && m[1]) { (function () { - var x = m.groups.xform; - - var _x$split = x.split(/\s*\(/), - _x$split2 = _slicedToArray(_x$split, 2), - name = _x$split2[0], - bits = _x$split2[1]; - - var valBits = bits.match(_wrapRegExp(/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(.*?)[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*\)/, { - nonWhitespace: 1 - })); - valBits.groups.nonWhitespace = valBits.groups.nonWhitespace.replace(_wrapRegExp(/([0-9])\x2D/g, { - digit: 1 - }), '$ -'); - var valArr = valBits.groups.nonWhitespace.split(/[, ]+/); - - var letters = _toConsumableArray('abcdef'); + var x = m[1]; + var bits = x.split(/\s*\(/); + var name = bits[0]; + var valBits = bits[1].match(/\s*(.*?)\s*\)/); + valBits[1] = valBits[1].replace(/(\d)-/g, '$1 -'); + var valArr = valBits[1].split(/[, ]+/); + var letters = 'abcdef'.split(''); + /* + if (m && m.groups.xform) { + const x = m.groups.xform; + const [name, bits] = x.split(/\s*\(/); + const valBits = bits.match(/\s*(?.*?)\s*\)/); + valBits.groups.nonWhitespace = valBits.groups.nonWhitespace.replace( + /(?\d)-/g, '$ -' + ); + const valArr = valBits.groups.nonWhitespace.split(/[, ]+/); + const letters = [...'abcdef']; + */ var mtx = svgroot.createSVGMatrix(); Object.values(valArr).forEach(function (item, i) { @@ -8067,10 +7934,7 @@ var init$2 = function init(editorContext) { */ var dropXMLInteralSubset = function dropXMLInteralSubset(str) { - return str.replace(_wrapRegExp(/()/, { - doctypeOpen: 1, - doctypeClose: 2 - }), '$$'); + return str.replace(/()/, '$1$2'); // return str.replace(/(?\?\]>)/, '$$'); }; /** * Converts characters in a string to XML-friendly entities. @@ -8210,15 +8074,14 @@ var dataURLToObjectURL = function dataURLToObjectURL(dataurl) { return ''; } - var _dataurl$split = dataurl.split(','), - _dataurl$split2 = _slicedToArray(_dataurl$split, 2), - prefix = _dataurl$split2[0], - suffix = _dataurl$split2[1], - _prefix$match = prefix.match(_wrapRegExp(/:(.*?);/, { - mime: 1 - })), - mime = _prefix$match.groups.mime, - bstr = atob(suffix); + var arr = dataurl.split(','), + mime = arr[0].match(/:(.*?);/)[1], + bstr = atob(arr[1]); + /* + const [prefix, suffix] = dataurl.split(','), + {groups: {mime}} = prefix.match(/:(?.*?);/), + bstr = atob(suffix); + */ var n = bstr.length; var u8arr = new Uint8Array(n); @@ -8271,7 +8134,6 @@ var blankPageObjectURL = function () { var text2xml = function text2xml(sXML) { if (sXML.includes(' -'); + var val = attr.value.replace(/(\d)-/g, '$1 -'); // const val = attr.value.replace(/(?\d)-/g, '$ -'); + node.setAttribute(attrName, val); break; } @@ -18663,12 +18524,11 @@ function SvgCanvas(container, config) { if (val) { if (val.startsWith('data:')) { // Check if an SVG-edit data URI - var m = val.match(_wrapRegExp(/svgedit_url=(.*?);/, { - url: 1 - })); + var m = val.match(/svgedit_url=(.*?);/); // const m = val.match(/svgedit_url=(?.*?);/); if (m) { - var url = decodeURIComponent(m.groups.url); + var url = decodeURIComponent(m[1]); // const url = decodeURIComponent(m.groups.url); + $$9(new Image()).load(function () { image.setAttributeNS(NS.XLINK, 'xlink:href', url); }).attr('src', url); @@ -29663,9 +29523,7 @@ editor.init = function () { if (!src) { // urldata.source may have been null if it ended with '=' if (qstr.includes('source=data:')) { - src = qstr.match(_wrapRegExp(/source=(data:[\0-%'-\uFFFF]*)/, { - src: 1 - })).groups.src; + src = qstr.match(/source=(data:[^&]*)/)[1]; // ({src} = qstr.match(/source=(?data:[^&]*)/).groups); } } @@ -29759,9 +29617,7 @@ editor.init = function () { while (1) { switch (_context3.prev = _context3.next) { case 0: - extName = extname.match(_wrapRegExp(/^ext\x2D(.+)\.js/, { - extName: 1 - })).groups.extName; + extName = extname.match(/^ext-(.+)\.js/); // const {extName} = extname.match(/^ext-(?.+)\.js/).groups; if (extName) { _context3.next = 3; @@ -29784,12 +29640,14 @@ editor.init = function () { _context3.prev = 4; _context3.next = 7; return regeneratorRuntime.awrap(importSetGlobalDefault(url, { - global: 'svgEditorExtension_' + extName.replace(/-/g, '_') + global: 'svgEditorExtension_' + extName[1].replace(/-/g, '_') // global: 'svgEditorExtension_' + extName.replace(/-/g, '_') + })); case 7: imported = _context3.sent; - _imported$name = imported.name, _name2 = _imported$name === void 0 ? extName : _imported$name, init = imported.init; + _imported$name = imported.name, _name2 = _imported$name === void 0 ? extName[1] : _imported$name, init = imported.init; // const {name = extName, init} = imported; + importLocale = getImportLocale({ defaultLang: langParam, defaultName: _name2 diff --git a/dist/index-es.min.js b/dist/index-es.min.js index 243b2400..34a82d43 100644 --- a/dist/index-es.min.js +++ b/dist/index-es.min.js @@ -1,2 +1,2 @@ -function e(t){return(e="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})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n]+)>/g,(function(e,t){return"$"+n[t]})))}if("function"==typeof t){var i=this;return r[Symbol.replace].call(this,e,(function(){var e=[];return e.push.apply(e,arguments),"object"!=typeof e[e.length-1]&&e.push(s(e,i)),t.apply(this,e)}))}return r[Symbol.replace].call(this,e,t)},p.apply(this,arguments)}function f(e){var t=e.changedTouches,n=t[0],r="";switch(e.type){case"touchstart":r="mousedown";break;case"touchmove":r="mousemove";break;case"touchend":r="mouseup";break;default:return}var a=n.screenX,i=n.screenY,o=n.clientX,s=n.clientY,l=new MouseEvent(r,{bubbles:!0,cancelable:!0,view:window,detail:1,screenX:a,screenY:i,clientX:o,clientY:s,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:null});t.length<2&&(n.target.dispatchEvent(l),e.preventDefault())}document.addEventListener("touchstart",f,!0),document.addEventListener("touchmove",f,!0),document.addEventListener("touchend",f,!0),document.addEventListener("touchcancel",f,!0);var g={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/"},m=function(){var e={};return Object.entries(g).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(n,r,a){t(this,e),this.pathSegType=n,this.pathSegTypeAsLetter=r,this._owningPathSegList=a}return r(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 n=function(n){function a(n){return t(this,a),u(this,o(a).call(this,e.PATHSEG_CLOSEPATH,"z",n))}return i(a,n),r(a,[{key:"toString",value:function(){return"[object SVGPathSegClosePath]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter}},{key:"clone",value:function(){return new a(void 0)}}]),a}(e),a=function(n){function a(n,r,i){var s;return t(this,a),(s=u(this,o(a).call(this,e.PATHSEG_MOVETO_ABS,"M",n)))._x=r,s._y=i,s}return i(a,n),r(a,[{key:"toString",value:function(){return"[object SVGPathSegMovetoAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new a(void 0,this._x,this._y)}}]),a}(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 s=function(n){function a(n,r,i){var s;return t(this,a),(s=u(this,o(a).call(this,e.PATHSEG_MOVETO_REL,"m",n)))._x=r,s._y=i,s}return i(a,n),r(a,[{key:"toString",value:function(){return"[object SVGPathSegMovetoRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new a(void 0,this._x,this._y)}}]),a}(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 l=function(n){function a(n,r,i){var s;return t(this,a),(s=u(this,o(a).call(this,e.PATHSEG_LINETO_ABS,"L",n)))._x=r,s._y=i,s}return i(a,n),r(a,[{key:"toString",value:function(){return"[object SVGPathSegLinetoAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new a(void 0,this._x,this._y)}}]),a}(e);Object.defineProperties(l.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(n){function a(n,r,i){var s;return t(this,a),(s=u(this,o(a).call(this,e.PATHSEG_LINETO_REL,"l",n)))._x=r,s._y=i,s}return i(a,n),r(a,[{key:"toString",value:function(){return"[object SVGPathSegLinetoRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new a(void 0,this._x,this._y)}}]),a}(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(n){function a(n,r,i,s,l,c,d){var h;return t(this,a),(h=u(this,o(a).call(this,e.PATHSEG_CURVETO_CUBIC_ABS,"C",n)))._x=r,h._y=i,h._x1=s,h._y1=l,h._x2=c,h._y2=d,h}return i(a,n),r(a,[{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 a(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)}}]),a}(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(n){function a(n,r,i,s,l,c,d){var h;return t(this,a),(h=u(this,o(a).call(this,e.PATHSEG_CURVETO_CUBIC_REL,"c",n)))._x=r,h._y=i,h._x1=s,h._y1=l,h._x2=c,h._y2=d,h}return i(a,n),r(a,[{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 a(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)}}]),a}(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(n){function a(n,r,i,s,l){var c;return t(this,a),(c=u(this,o(a).call(this,e.PATHSEG_CURVETO_QUADRATIC_ABS,"Q",n)))._x=r,c._y=i,c._x1=s,c._y1=l,c}return i(a,n),r(a,[{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 a(void 0,this._x,this._y,this._x1,this._y1)}}]),a}(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(n){function a(n,r,i,s,l){var c;return t(this,a),(c=u(this,o(a).call(this,e.PATHSEG_CURVETO_QUADRATIC_REL,"q",n)))._x=r,c._y=i,c._x1=s,c._y1=l,c}return i(a,n),r(a,[{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 a(void 0,this._x,this._y,this._x1,this._y1)}}]),a}(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(n){function a(n,r,i,s,l,c,d,h){var p;return t(this,a),(p=u(this,o(a).call(this,e.PATHSEG_ARC_ABS,"A",n)))._x=r,p._y=i,p._r1=s,p._r2=l,p._angle=c,p._largeArcFlag=d,p._sweepFlag=h,p}return i(a,n),r(a,[{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 a(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)}}]),a}(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(n){function a(n,r,i,s,l,c,d,h){var p;return t(this,a),(p=u(this,o(a).call(this,e.PATHSEG_ARC_REL,"a",n)))._x=r,p._y=i,p._r1=s,p._r2=l,p._angle=c,p._largeArcFlag=d,p._sweepFlag=h,p}return i(a,n),r(a,[{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 a(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)}}]),a}(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(n){function a(n,r){var i;return t(this,a),(i=u(this,o(a).call(this,e.PATHSEG_LINETO_HORIZONTAL_ABS,"H",n)))._x=r,i}return i(a,n),r(a,[{key:"toString",value:function(){return"[object SVGPathSegLinetoHorizontalAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x}},{key:"clone",value:function(){return new a(void 0,this._x)}}]),a}(e);Object.defineProperty(v.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0});var y=function(n){function a(n,r){var i;return t(this,a),(i=u(this,o(a).call(this,e.PATHSEG_LINETO_HORIZONTAL_REL,"h",n)))._x=r,i}return i(a,n),r(a,[{key:"toString",value:function(){return"[object SVGPathSegLinetoHorizontalRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x}},{key:"clone",value:function(){return new a(void 0,this._x)}}]),a}(e);Object.defineProperty(y.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0});var _=function(n){function a(n,r){var i;return t(this,a),(i=u(this,o(a).call(this,e.PATHSEG_LINETO_VERTICAL_ABS,"V",n)))._y=r,i}return i(a,n),r(a,[{key:"toString",value:function(){return"[object SVGPathSegLinetoVerticalAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._y}},{key:"clone",value:function(){return new a(void 0,this._y)}}]),a}(e);Object.defineProperty(_.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0});var b=function(n){function a(n,r){var i;return t(this,a),(i=u(this,o(a).call(this,e.PATHSEG_LINETO_VERTICAL_REL,"v",n)))._y=r,i}return i(a,n),r(a,[{key:"toString",value:function(){return"[object SVGPathSegLinetoVerticalRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._y}},{key:"clone",value:function(){return new a(void 0,this._y)}}]),a}(e);Object.defineProperty(b.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0});var x=function(n){function a(n,r,i,s,l){var c;return t(this,a),(c=u(this,o(a).call(this,e.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS,"S",n)))._x=r,c._y=i,c._x2=s,c._y2=l,c}return i(a,n),r(a,[{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 a(void 0,this._x,this._y,this._x2,this._y2)}}]),a}(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(n){function a(n,r,i,s,l){var c;return t(this,a),(c=u(this,o(a).call(this,e.PATHSEG_CURVETO_CUBIC_SMOOTH_REL,"s",n)))._x=r,c._y=i,c._x2=s,c._y2=l,c}return i(a,n),r(a,[{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 a(void 0,this._x,this._y,this._x2,this._y2)}}]),a}(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(n){function a(n,r,i){var s;return t(this,a),(s=u(this,o(a).call(this,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS,"T",n)))._x=r,s._y=i,s}return i(a,n),r(a,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticSmoothAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new a(void 0,this._x,this._y)}}]),a}(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(n){function a(n,r,i){var s;return t(this,a),(s=u(this,o(a).call(this,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL,"t",n)))._x=r,s._y=i,s}return i(a,n),r(a,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticSmoothRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new a(void 0,this._x,this._y)}}]),a}(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 n(void 0)},SVGPathElement.prototype.createSVGPathSegMovetoAbs=function(e,t){return new a(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegMovetoRel=function(e,t){return new s(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegLinetoAbs=function(e,t){return new l(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=n,window.SVGPathSegMovetoAbs=a,window.SVGPathSegMovetoRel=s,window.SVGPathSegLinetoAbs=l,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(n){t(this,e),this._pathElement=n,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 r(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 n=this,a=function(){function e(){t(this,e),this.pathSegList=[]}return r(e,[{key:"appendSegment",value:function(e){this.pathSegList.push(e)}}]),e}(),i=function(){function e(n){t(this,e),this._string=n,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()}return r(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],t=this._pathSegTypeFromChar(e);if(t===SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand===SVGPathSeg.PATHSEG_UNKNOWN)return null;if((t=this._nextCommandHelper(e,this._previousCommand))===SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=t,t){case SVGPathSeg.PATHSEG_MOVETO_REL:return new SVGPathSegMovetoRel(n,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_MOVETO_ABS:return new SVGPathSegMovetoAbs(n,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_REL:return new SVGPathSegLinetoRel(n,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_ABS:return new SVGPathSegLinetoAbs(n,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new SVGPathSegLinetoHorizontalRel(n,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new SVGPathSegLinetoHorizontalAbs(n,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new SVGPathSegLinetoVerticalRel(n,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new SVGPathSegLinetoVerticalAbs(n,this._parseNumber());case SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new SVGPathSegClosePath(n);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(n,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(n,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(n,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(n,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(n,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(n,l.x,l.y,l.x1,l.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new SVGPathSegCurvetoQuadraticSmoothRel(n,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new SVGPathSegCurvetoQuadraticSmoothAbs(n,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(n,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(n,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 a,s=new i(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 v,y=jQuery,_=(Boolean(document.createElementNS&&document.createElementNS(g.SVG,"svg").createSVGRect),navigator.userAgent),b=document.createElementNS(g.SVG,"svg"),x=Boolean(window.opera),w=_.includes("AppleWebKit"),S=_.includes("Gecko/"),k=_.includes("MSIE"),C=_.includes("Chrome/"),A=(_.includes("Windows"),_.includes("Macintosh")),E="ontouchstart"in window,G=Boolean(b.querySelector),P=Boolean(document.evaluate),I=function(){var e=document.createElementNS(g.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}(),N=function(){var e=document.createElementNS(g.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(g.SVG,"svg"),t=document.createElementNS(g.SVG,"svg");document.documentElement.append(e),t.setAttribute("x",5),e.append(t);var n=document.createElementNS(g.SVG,"text");n.textContent="a",t.append(n);try{return 0===n.getStartPositionOfChar(0).x}catch(e){return!1}finally{e.remove()}}(),L=function(){var e=document.createElementNS(g.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(g.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}(),M=function(){var e=document.createElementNS(g.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(g.SVG,"path");t.setAttribute("d","M0,0 10,0");var n=document.createElementNS(g.SVG,"path");n.setAttribute("d","M5,0 15,0");var r=document.createElementNS(g.SVG,"g");r.append(t,n),e.append(r);var a=r.getBBox();return e.remove(),15===a.width}(),O=(function(){var e=document.createElementNS(g.SVG,"rect");e.setAttribute("x",.1);var t=!e.cloneNode(!1).getAttribute("x").includes(",");t||y.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.')}(),(v=document.createElementNS(g.SVG,"rect")).setAttribute("style","vector-effect:non-scaling-stroke"),"non-scaling-stroke"===v.style.vectorEffect),j=function(){var t=document.createElementNS(g.SVG,"rect").transform.baseVal,n=b.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}(),V=function(){return x},R=function(){return w},B=function(){return S},F=function(){return k},D=function(){return C},U=function(){return A},H=function(){return E},z=function(){return M},q=function(){return O};function Y(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 -");var i=a.groups.nonWhitespace.split(/[, ]+/),o=h("abcdef"),s=W.createSVGMatrix();Object.values(i).forEach((function(e,t){i[t]=parseFloat(e),"matrix"===n&&(s[o[t]]=i[t])}));var l=W.createSVGTransform(),c="set"+n.charAt(0).toUpperCase()+n.slice(1),u="matrix"===n?[s]:i;"scale"===n&&1===u.length?u.push(u[0]):"translate"===n&&1===u.length?u.push(0):"rotate"===n&&1===u.length&&u.push(0,0),l[c].apply(l,h(u)),e._list.appendItem(l)}()},this._removeFromOtherLists=function(e){e&&Object.values(K).some((function(t){for(var n=0,r=t._xforms.length;n=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(ue.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}}]),n}();me.type=me.prototype.type;var ve,ye,_e,be,xe,we=function(){function e(n){t(this,e),this.handler_=n||null,this.undoStackPointer=0,this.undoStack=[],this.undoChangeStackPointer=-1,this.undoableChangeStack=[]}return r(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];on(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 me("Change "+n),a=t.elements.length;a--;){var i=t.elements[a];if(!on(i)){var o={};o[n]=t.oldValues[a],o[n]!==i.getAttribute(n)&&r.addSubCommand(new ge(i,o,n))}}return this.undoableChangeStack[e]=null,r}}]),e}(),Se=Object.freeze({__proto__:null,HistoryEventTypes:ue,MoveElementCommand:he,InsertElementCommand:pe,RemoveElementCommand:fe,ChangeElementCommand:ge,BatchCommand:me,UndoManager:we}),ke=document.createElementNS(g.SVG,"svg"),Ce=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},Ae=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},Ee=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=ke.createSVGMatrix(),i=t;i<=n;++i){var o=i>=0&&ie.x&&t.ye.y},Me=jQuery,Oe={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"]},je={},Ve=function(e){Object.assign(je,e.ui)},Re=[],Be=!0,Fe={},De=null,Ue=null,He=function(e){Ue=e,Re=[0,"ClosePath"];Me.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],(function(e,t){Re.push(t+"Abs"),Re.push(t+"Rel")}))},ze=function(e,t,n){var r=e.pathSegList;if(N)r.insertItemBefore(t,n);else{for(var a=r.numberOfItems,i=[],o=0;o0?(p=g element");this.elem=n,this.segs=[],this.selected_pts=[],De=this,this.init()}return r(e,[{key:"init",value:function(){Me(Qe()).find("*").each((function(){Me(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(),on(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]);Ue.addPtsToSelection({grips:a,closedSubpath:s})}}],[{key:"subpathIsClosed",value:function(e){var t=!1;return De.eachSeg((function(n){return n<=e||2!==this.type&&(1!==this.type||(t=!0,!1))})),t}}]),e}(),at=function(e){var t=Fe[e.id];return t||(t=Fe[e.id]=new rt(e)),t},it=function(e){e in Fe&&delete Fe[e]},ot=function(e,t){var n=e-_e,r=t-be,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)+xe;return n=a*Math.cos(i)+_e,r=a*Math.sin(i)+be,n-=ve,r-=ye,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)-xe,{x:a*Math.cos(i)+ve,y:a*Math.sin(i)+ye}},st=function(){var e=De.elem;if(xe=$t(e,!0)){var t=De.oldbbox;_e=t.x+t.width/2,be=t.y+t.height/2;var n=Dt(e);ve=n.x+n.width/2,ye=n.y+n.height/2;var r=ve-_e,a=ye-be,i=Math.sqrt(r*r+a*a),o=Math.atan2(a,r)+xe;ve=i*Math.cos(o)+_e,ye=i*Math.sin(o)+be;for(var s=e.pathSegList,l=s.numberOfItems;l;){l-=1;var c=s.getItem(l),u=c.pathSegType;if(1!==u){var d=ot(c.x,c.y),h=[d.x,d.y];if(!on(c.x1)&&!on(c.x2)){var p=ot(c.x1,c.y1),f=ot(c.x2,c.y2);h.splice(h.length,0,p.x,p.y,f.x,f.y)}Je(u,l,h)}}Dt(e);var g=Ue.getSVGRoot().createSVGTransform(),m=J(e);g.setRotate(180*xe/Math.PI,ve,ye),m.replaceItem(g,0)}},lt=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],ct=function(e,t){for(var n=e.pathSegList,r=n.numberOfItems,a=0,i=0,o="",s=null,l=0;l=C-w&&f<=C+w&&m>=A-w&&m<=A+w){S=!0;break}}a=Ue.getId(),it(a);var E,G,P=en(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(Me(v).remove(),Ue.setDrawnPath(null),Ue.setStarted(!1),pt){De.matrix&&Ue.remapElement(P,{},De.matrix.inverse());var M=P.getAttribute("d"),O=Me(De.elem).attr("d");return Me(De.elem).attr("d",O+M),Me(P).remove(),De.matrix&&st(),He(),mt.toEditMode(De.elem),De.selectPt(),!1}}else{if(!Me.contains(Ue.getContainer(),Ue.getMouseTarget(e)))return!1;var j=_.pathSegList.numberOfItems,V=_.pathSegList.getItem(j-1),R=V.x,B=V.y;if(e.shiftKey){var F=Te(R,B,f,m);f=F.x,m=F.y}E=4===(G=v.pathSegList.getItem(1)).pathSegType?_.createSVGPathSegLinetoAbs(Ue.round(f),Ue.round(m)):_.createSVGPathSegCurvetoCubicAbs(Ue.round(f),Ue.round(m),G.x1/p,G.y1/p,G.x2/p,G.y2/p),_.pathSegList.appendItem(E),f*=p,m*=p,v.setAttribute("d",["M",f,m,f,m].join(" ")),y=j,pt&&(y+=De.segs.length),Xe(y,f,m)}}else{var D="M"+f+","+m+" ";Ue.setDrawnPath(Ue.addSVGElementFromJson({element:"path",curStyles:!0,attr:{d:D,id:Ue.getNextId(),opacity:Ue.getOpacity()/2}})),v.setAttribute("d",["M",d,h,d,h].join(" ")),y=pt?De.segs.length:0,Xe(y,d,h)}}},mouseMove:function(e,t){var n=Ue.getCurrentZoom();gt=!0;var r=Ue.getDrawnPath();if("path"!==Ue.getCurrentMode())if(De.dragging){var a=We({x:De.dragging[0],y:De.dragging[1]},De),i=We({x:e,y:t},De),o=i.x-a.x,s=i.y-a.y;De.dragging=[e,t],De.dragctrl?De.moveCtrl(o,s):De.movePts(o,s)}else De.selected_pts=[],De.eachSeg((function(e){if(this.next||this.prev){var t=Ue.getRubberBox().getBBox(),n=Ye(this),r={x:n.x,y:n.y,width:0,height:0},a=Le(t,r);this.select(a),a&&De.selected_pts.push(this.index)}}));else{if(!r)return;var l=r.pathSegList,c=l.numberOfItems-1;if(dt){var u=Ke("1c1"),d=Ke("0c2");u.setAttribute("cx",e),u.setAttribute("cy",t),u.setAttribute("display","inline");var h=dt[0],p=dt[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=Ze(1);if(tn(m,{x1:e,y1:t,x2:f*n,y2:g*n,display:"inline"}),0===c)ht=[e,t];else{var v=l.getItem(c-1),y=v.x,_=v.y;6===v.pathSegType?(y+=y-v.x2,_+=_-v.y2):ht&&(y=ht[0]/n,_=ht[1]/n),Je(6,c,[h,p,y,_,f,g],r)}}else{var b=en("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);Je(6,1,[e,t,w*n,S*n,e,t],b)}else ht?Je(6,1,[e,t,ht[0],ht[1],e,t],b):Je(4,1,[e,t],b)}}}},mouseUp:function(e,t,n,r){var a=Ue.getDrawnPath();if("path"===Ue.getCurrentMode())return dt=null,a||(t=en(Ue.getId()),Ue.setStarted(!1),ht=null),{keep:!0,element:t};var i=Ue.getRubberBox();if(De.dragging){var o=De.cur_pt;De.dragging=!1,De.dragctrl=!1,De.update(),gt&&De.endChanges("Move path point(s)"),e.shiftKey||gt||De.selectPt(o)}else i&&"none"!==i.getAttribute("display")?(i.setAttribute("display","none"),i.getAttribute("width")<=2&&i.getAttribute("height")<=2&&mt.toSelectMode(e.target)):mt.toSelectMode(e.target);gt=!1},toEditMode:function(e){De=at(e),Ue.setCurrentMode("pathedit"),Ue.clearSelection(),De.show(!0).update(),De.oldbbox=Dt(De.elem),pt=!1},toSelectMode:function(e){var t=e===De.elem;Ue.setCurrentMode("select"),De.show(!1),ft=!1,Ue.clearSelection(),De.matrix&&st(),t&&(Ue.call("selected",[e]),Ue.addToSelection([e],!0))},addSubPath:function(e){e?(Ue.setCurrentMode("path"),pt=!0):(mt.clear(!0),mt.toEditMode(De.elem))},select:function(e){ft===e?(mt.toEditMode(e),Ue.setCurrentMode("pathedit")):ft=e},reorient:function(){var e=Ue.getSelectedElements()[0];if(e&&0!==$t(e)){var t=new me("Reorient path"),n={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new ge(e,n)),Ue.clearSelection(),this.resetOrientation(e),Ue.addCommandToHistory(t),at(e).show(!1).matrix=null,this.clear(),Ue.addToSelection([e],!0),Ue.call("changed",Ue.getSelectedElements())}},clear:function(e){var t=Ue.getDrawnPath();if(ft=null,t){var n=en(Ue.getId());Me(en("path_stretch_line")).remove(),Me(n).remove(),Me(en("pathpointgrip_container")).find("*").attr("display","none"),ht=null,Ue.setDrawnPath(null),Ue.setStarted(!1)}else"pathedit"===Ue.getCurrentMode()&&this.toSelectMode();De&&De.init().show(!1)},resetOrientation:function(e){if(on(e)||"path"!==e.nodeName)return!1;var t=J(e),n=Ie(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=[];Me.each(["",1,2],(function(e,t){var r=a["x"+t],i=a["y"+t];if(void 0!==r&&void 0!==i){var s=Ce(r,i,n);o.splice(o.length,0,s.x,s.y)}})),Je(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}(),De.elem.pathSegList.numberOfItems<=1)return mt.toSelectMode(De.elem),void Ue.canvas.deleteSelectedElements();if(De.init(),De.clearSelection(),window.opera){var r=Me(De.elem);r.attr("d",r.attr("d"))}De.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=tt(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)/,{doctypeOpen:1,doctypeClose:2}),"$$")},Ct=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")};function At(e){if(e=Pt(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++]=yt.charAt(s),t[r++]=yt.charAt(l),t[r++]=yt.charAt(c),t[r++]=yt.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 Nt(e)}(),Lt=function(e){var t,n;e.includes("0?t=t[0]:(t=e.ownerDocument.createElementNS(g.SVG,"defs"),e.firstChild?e.insertBefore(t,e.firstChild.nextSibling):e.append(t)),t},Bt=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 Ft(e){if(z())try{return e.getBBox()}catch(e){}var t,n,r=vt.data(e,"ref"),a=null;r?(n=vt(r).children().clone().attr("visibility","hidden"),vt(St).append(n),a=n.filter("line, path")):a=vt(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:vt(e).children();t=Xt(o)}else t=e.getBBox();else t=e.getBBox();return r&&n.remove(),t}var Dt=function(e){var t=e||bt.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":L?t.getBBox&&(a=t.getBBox()):a=Bt(t);break;case"g":case"a":a=Ft(t);break;default:if("use"===r&&(a=Ft(t)),"use"===r||"foreignObject"===r&&R()){if(a||(a=t.getBBox()),!R()){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(_t.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=vt(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},Ut=function(e){var t="";return vt.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=qt(e,t,n);else if("rect"===e.tagName){var l=e.getAttribute("rx"),c=e.getAttribute("ry");(l||c)&&(r=s=qt(e,t,n))}}if(!s){var u=Ie(a).matrix;r=Pe(r.x,r.y,r.width,r.height,u).aabox}}return r};function Wt(e){var t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}var Xt=function(e,t,n){if(!e||!e.length)return!1;var r;if(vt.each(e,(function(){r||this.parentNode&&(r=Yt(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=Wt(e[0]);o-=l,s-=l,a+=l,i+=l}else vt.each(e,(function(e,r){var l=Yt(r,t,n);if(l){var c=Wt(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},Qt=function(e){e||(e=vt(bt.getSVGContent()).children());var t=[];return vt(e).children().each((function(e,n){n.getBBox&&t.push(n)})),t.reverse()},Kt=function(e){return e||(e=Qt()),Xt(e,bt.addSVGElementFromJson,bt.pathActions)},Zt=function(e,t){if(!e)return 0;for(var n=e.numberOfItems,r=0;r");var t=e.shortcut||"";sn("#cmenu_canvas").append("
  • "+e.label+""+t+"
  • ")}(e)}))};function un(e,t){["id","class","type"].forEach((function(n){n in t&&(e[n]=t[n])}))}function dn(e,t){return hn(e,a({},t,{returnDefault:!0}))}function hn(e,t){var n,r;return regeneratorRuntime.async((function(a){for(;;)switch(a.prev=a.next){case 0:if(n=t.global,r=t.returnDefault,!!("svgEditor"in window&&window.svgEditor&&!1===window.svgEditor.modules)){a.next=4;break}return a.abrupt("return",fn(e,void 0,{returnDefault:r}));case 4:return a.next=6,regeneratorRuntime.awrap(pn(e));case 6:return a.abrupt("return",window[n]);case 7:case"end":return a.stop()}}))}function pn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Array.isArray(e)?Promise.all(e.map((function(e){return pn(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",un(a,t),a.addEventListener("error",i),a.addEventListener("load",o),a.src=e,document.head.append(a)}))}function fn(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 fn(e,t)}))):new Promise((function(n,a){var i="$importModule$"+Math.random().toString(32).slice(2),o=document.createElement("script");function s(){a(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=""};un(o,t),o.defer="defer",o.type="module",o.addEventListener("error",s),o.addEventListener("load",l);var u=function(e){var t=document.createElement("a");return t.setAttribute("href",e),t.cloneNode(!1).href}(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"});o.src=URL.createObjectURL(h),document.head.append(o)}))}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("