From d13f99bb5efcc11d0ff64940b19f2e0c3e34a400 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 21 Oct 2018 18:33:23 +0800 Subject: [PATCH] - Breaking change: Remove `storagePromptClosed` state boolean in favor of `storagePromptState`; used by `ext-storage.js` - Fix (regression): Ensure storage dialog will not be blocked because of canvas updating done for sake of centering background - Fix (extensions): Ensure `langReady` changes are available by time prefs dialog is closed and that its changes have occurred by time extensions have first loaded (`setLang` now returns a Promise rather than `undefined` as it waits for extension's `langReady` to resolve); this is also useful with `ext-storage.js` so we know that `extensions_loaded` (which conditionally updates the canvas based on `storagePromptState`) has seen `langReady` and the storage extension hasn't set a `storagePromptState` of "waiting" --- CHANGES.md | 10 + dist/extensions/ext-storage.js | 7 +- dist/index-es.js | 1173 +++++++++++++------------ dist/index-es.min.js | 2 +- dist/index-es.min.js.map | 2 +- dist/index-umd.js | 1173 +++++++++++++------------ dist/index-umd.min.js | 2 +- dist/index-umd.min.js.map | 2 +- editor/extensions/ext-storage.js | 6 +- editor/svg-editor.js | 28 +- editor/xdomain-svgedit-config-iife.js | 1173 +++++++++++++------------ svgedit-config-iife.js | 1173 +++++++++++++------------ 12 files changed, 2580 insertions(+), 2171 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index fd90988f..e7ad8bd7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,8 @@ - Breaking change: For checkbox for persisting choice of initial use storage approval in storage extension dialog, turn on by default for convenience of most users (must still hit "ok" and users can still turn off the checkbox) +- Breaking change: Remove `storagePromptClosed` state boolean in favor of + `storagePromptState`; used by `ext-storage.js` - Fix: Map extension click events to "mousedown" so they can be received on touch devices (since `touch.js` changes `touchstart` to `mousedown`) (@ClemArt); closes #168 @@ -13,6 +15,14 @@ retaining preference (and ensure language changes are available before dialog closed) - Fix: Centering of canvas wasn't being set at proper time; fixes #272 +- Fix (extensions): Ensure `langReady` changes are available by time prefs + dialog is closed and that its changes have occurred by time extensions + have first loaded (`setLang` now returns a Promise rather than `undefined` + as it waits for extension's `langReady` to resolve); this is also useful + with `ext-storage.js` so we know that `extensions_loaded` (which + conditionally updates the canvas based on `storagePromptState`) has seen + `langReady` and the storage extension hasn't set a `storagePromptState` + of "waiting" - Fix (regression): Extension locale loading for non-English locales - Enhancement: Allow "Escape" to work with hotkeys within text boxes; allows escaping out of source textarea (part of #291) diff --git a/dist/extensions/ext-storage.js b/dist/extensions/ext-storage.js index 361ca1f9..c593bc0c 100644 --- a/dist/extensions/ext-storage.js +++ b/dist/extensions/ext-storage.js @@ -76,7 +76,8 @@ var svgEditorExtension_storage = (function () { emptyStorageOnDecline = _svgEditor$curConfig.emptyStorageOnDecline, noStorageOnLoad = _svgEditor$curConfig.noStorageOnLoad, forceStorage = _svgEditor$curConfig.forceStorage; - var storage = svgEditor.storage; + var storage = svgEditor.storage, + updateCanvas = svgEditor.updateCanvas; function replaceStoragePrompt(val) { val = val ? 'storagePrompt=' + val : ''; @@ -304,12 +305,14 @@ var svgEditorExtension_storage = (function () { // the prompt gives the user the option to store data setupBeforeUnloadListener(); - svgEditor.storagePromptClosed = true; + svgEditor.storagePromptState = 'closed'; + updateCanvas(true); }, null, null, { label: rememberLabel, checked: true, tooltip: rememberTooltip }); + svgEditor.storagePromptState = 'waiting'; } else if (!noStorageOnLoad || forceStorage) { setupBeforeUnloadListener(); } diff --git a/dist/index-es.js b/dist/index-es.js index 97fa724b..00926a49 100644 --- a/dist/index-es.js +++ b/dist/index-es.js @@ -27561,11 +27561,11 @@ editor.langChanged = false; editor.showSaveWarning = false; /** -* @type {boolean} + * Will be set to a boolean by `ext-storage.js` + * @type {"ignore"|"waiting"|"closed"} */ -editor.storagePromptClosed = false; // For use with ext-storage.js - +editor.storagePromptState = 'ignore'; var callbacks = [], /** @@ -28367,9 +28367,12 @@ editor.init = function () { _ref6 = _context4.sent; langParam = _ref6.langParam; langData = _ref6.langData; - setLang(langParam, langData); - _context4.prev = 6; - _context4.next = 9; + _context4.next = 7; + return setLang(langParam, langData); + + case 7: + _context4.prev = 7; + _context4.next = 10; return Promise.all(curConfig.extensions.map( /*#__PURE__*/ function () { @@ -28436,7 +28439,7 @@ editor.init = function () { }; }())); - case 9: + case 10: svgCanvas.bind('extensions_added', /** * @param {external:Window} win @@ -28450,7 +28453,11 @@ editor.init = function () { $$b('.flyout_arrow_horiz:empty').each(function () { $$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5)); }); - updateCanvas(true); + + if (editor.storagePromptState === 'ignore') { + updateCanvas(true); + } + messageQueue.forEach( /** * @param {module:svgcanvas.SvgCanvas#event:message} messageObj @@ -28462,20 +28469,20 @@ editor.init = function () { }); }); svgCanvas.call('extensions_added'); - _context4.next = 16; + _context4.next = 17; break; - case 13: - _context4.prev = 13; - _context4.t0 = _context4["catch"](6); + case 14: + _context4.prev = 14; + _context4.t0 = _context4["catch"](7); console.log(_context4.t0); - case 16: + case 17: case "end": return _context4.stop(); } } - }, _callee4, this, [[6, 13]]); + }, _callee4, this, [[7, 14]]); })); return function extAndLocaleFunc() { @@ -29797,7 +29804,7 @@ editor.init = function () { workarea.scroll(); } - if (urldata.storagePrompt !== true && !editor.storagePromptClosed) { + if (urldata.storagePrompt !== true && editor.storagePromptState === 'ignore') { $$b('#dialog_box').hide(); } }; @@ -30725,440 +30732,484 @@ editor.init = function () { * @returns {Promise} Resolves to `undefined` */ - var extAdded = function extAdded(win, ext) { - if (!ext) { - return; - } - - var cbCalled = false; - var resizeDone = false; - - if (ext.langReady) { - if (editor.langChanged) { - // We check for this since the "lang" pref could have been set by storage - var lang = $$b.pref('lang'); - ext.langReady({ - lang: lang, - uiStrings: uiStrings$1, - importLocale: getImportLocale({ - defaultLang: lang, - defaultName: ext.name - }) - }); - loadedExtensionNames.push(ext.name); - } else { - extsPreLang.push(ext); - } - } - - function prepResize() { - if (resizeTimer) { - clearTimeout(resizeTimer); - resizeTimer = null; - } - - if (!resizeDone) { - resizeTimer = setTimeout(function () { - resizeDone = true; - setIconSize($$b.pref('iconsize')); - }, 50); - } - } - - var runCallback = function runCallback() { - if (ext.callback && !cbCalled) { - cbCalled = true; - ext.callback.call(editor); - } - }; - - var btnSelects = []; - /** - * @typedef {PlainObject} module:SVGEditor.ContextTool - * @property {string} panel The ID of the existing panel to which the tool is being added. Required. - * @property {string} id The ID of the actual tool element. Required. - * @property {PlainObject.|PlainObject.<"change", external:jQuery.Function>} events DOM event names keyed to associated functions. Example: `{change () { alert('Option was changed') } }`. "change" event is one specifically handled for the "button-select" type. Required. - * @property {string} title The tooltip text that will appear when the user hovers over the tool. Required. - * @property {"tool_button"|"select"|"button-select"|"input"|string} type The type of tool being added. Expected. - * @property {PlainObject.} [options] List of options and their labels for select tools. Example: `{1: 'One', 2: 'Two', all: 'All' }`. Required by "select" tools. - * @property {string} [container_id] The ID to be given to the tool's container element. - * @property {string} [defval] Default value - * @property {string|Integer} [colnum] Added as part of the option list class. - * @property {string} [label] Label associated with the tool, visible in the UI - * @property {Integer} [size] Value of the "size" attribute of the tool input - * @property {module:jQuerySpinButton.SpinButtonConfig} [spindata] When added to a tool of type "input", this tool becomes a "spinner" which allows the number to be in/decreased. - */ - - if (ext.context_tools) { - $$b.each(ext.context_tools, function (i, tool) { - // Add select tool - var contId = tool.container_id ? ' id="' + tool.container_id + '"' : ''; - var panel = $$b('#' + tool.panel); // create the panel if it doesn't exist - - if (!panel.length) { - panel = $$b('
', { - id: tool.panel - }).appendTo('#tools_top'); - } - - var html; // TODO: Allow support for other types, or adding to existing tool - - switch (tool.type) { - case 'tool_button': - html = '
' + tool.id + '
'; - var div = $$b(html).appendTo(panel); - - if (tool.events) { - $$b.each(tool.events, function (evt, func) { - $$b(div).bind(evt, func); - }); - } - - break; - - case 'select': - html = '' + ''; // Creates the tool, hides & adds it, returns the select element - - var sel = $$b(html).appendTo(panel).find('select'); - $$b.each(tool.events, function (evt, func) { - $$b(sel).bind(evt, func); - }); - break; - - case 'button-select': - html = ''; - var list = $$b('
    ').appendTo('#option_lists'); - - if (tool.colnum) { - list.addClass('optcols' + tool.colnum); - } // Creates the tool, hides & adds it, returns the select element - - /* const dropdown = */ - - - $$b(html).appendTo(panel).children(); - btnSelects.push({ - elem: '#' + tool.id, - list: '#' + tool.id + '_opts', - title: tool.title, - callback: tool.events.change, - cur: '#cur_' + tool.id - }); - break; - - case 'input': - html = '' + '' + tool.label + ':' + ''; // Creates the tool, hides & adds it, returns the select element - // Add to given tool.panel - - var inp = $$b(html).appendTo(panel).find('input'); - - if (tool.spindata) { - inp.SpinButton(tool.spindata); - } - - if (tool.events) { - $$b.each(tool.events, function (evt, func) { - inp.bind(evt, func); - }); - } - - break; - - default: - break; - } - }); - } - - var svgicons = ext.svgicons; - - if (ext.buttons) { - var fallbackObj = {}, - placementObj = {}, - holders = {}; - /** - * @typedef {GenericArray} module:SVGEditor.KeyArray - * @property {string} 0 The key to bind (on `keydown`) - * @property {boolean} 1 Whether to `preventDefault` on the `keydown` event - * @property {boolean} 2 Not apparently in use (NoDisableInInput) - */ - - /** - * @typedef {string|module:SVGEditor.KeyArray} module:SVGEditor.Key - */ - - /** - * @typedef {PlainObject} module:SVGEditor.Button - * @property {string} id A unique identifier for this button. If SVG icons are used, this must match the ID used in the icon file. Required. - * @property {"mode_flyout"|"mode"|"context"|"app_menu"} type Type of button. Required. - * @property {string} title The tooltip text that will appear when the user hovers over the icon. Required. - * @property {PlainObject.|PlainObject.<"click", external:jQuery.Function>} events DOM event names with associated functions. Example: `{click () { alert('Button was clicked') } }`. Click is used with `includeWith` and `type` of "mode_flyout" (and "mode"); any events may be added if `list` is not present. Expected. - * @property {string} panel The ID of the context panel to be included, if type is "context". Required only if type is "context". - * @property {string} icon The file path to the raster version of the icon image source. Required only if no `svgicons` is supplied from [ExtensionInitResponse]{@link module:svgcanvas.ExtensionInitResponse}. - * @property {string} [svgicon] If absent, will utilize the button "id"; used to set "placement" on the `svgIcons` call - * @property {string} [list] Points to the "id" of a `context_tools` item of type "button-select" into which the button will be added as a panel list item - * @property {Integer} [position] The numeric index for placement; defaults to last position (as of the time of extension addition) if not present. For use with {@link http://api.jquery.com/eq/}. - * @property {boolean} [isDefault] Whether or not the button is the default. Used with `list`. - * @property {PlainObject} [includeWith] Object with flyout menu data - * @property {boolean} [includeWith.isDefault] Indicates whether button is default in flyout list or not. - * @property {string} includeWith.button jQuery selector of the existing button to be joined. Example: '#tool_line'. Required if `includeWith` is used. - * @property {"last"|Integer} [includeWith.position] Position of icon in flyout list; will be added to end if not indicated. Integer is for use with {@link http://api.jquery.com/eq/}. - * @property {module:SVGEditor.Key} [key] The key to bind to the button - */ - // Add buttons given by extension - - $$b.each(ext.buttons, function (i, - /** @type {module:SVGEditor.Button} */ - btn) { - var id = btn.id; - var num = i; // Give button a unique ID - - while ($$b('#' + id).length) { - id = btn.id + '_' + ++num; - } - - var icon; - - if (!svgicons) { - icon = $$b(''); - } else { - fallbackObj[id] = btn.icon; - var svgicon = btn.svgicon || btn.id; - - if (btn.type === 'app_menu') { - placementObj['#' + id + ' > div'] = svgicon; - } else { - placementObj['#' + id] = svgicon; - } - } - - var cls, parent; // Set button up according to its type - - switch (btn.type) { - case 'mode_flyout': - case 'mode': - cls = 'tool_button'; - parent = '#tools_left'; - break; - - case 'context': - cls = 'tool_button'; - parent = '#' + btn.panel; // create the panel if it doesn't exist - - if (!$$b(parent).length) { - $$b('
    ', { - id: btn.panel - }).appendTo('#tools_top'); - } - - break; - - case 'app_menu': - cls = ''; - parent = '#main_menu ul'; - break; - } - - var flyoutHolder, showBtn, refData, refBtn; - var button = $$b(btn.list || btn.type === 'app_menu' ? '
  • ' : '
    ').attr('id', id).attr('title', btn.title).addClass(cls); - - if (!btn.includeWith && !btn.list) { - if ('position' in btn) { - if ($$b(parent).children().eq(btn.position).length) { - $$b(parent).children().eq(btn.position).before(button); - } else { - $$b(parent).children().last().before(button); - } - } else { - button.appendTo(parent); - } - - if (btn.type === 'mode_flyout') { - // Add to flyout menu / make flyout menu - // const opts = btn.includeWith; - // // opts.button, default, position - refBtn = $$b(button); - flyoutHolder = refBtn.parent(); // Create a flyout menu if there isn't one already - - var tlsId; - - if (!refBtn.parent().hasClass('tools_flyout')) { - // Create flyout placeholder - tlsId = refBtn[0].id.replace('tool_', 'tools_'); - showBtn = refBtn.clone().attr('id', tlsId + '_show').append($$b('
    ', { - class: 'flyout_arrow_horiz' - })); - refBtn.before(showBtn); // Create a flyout div - - flyoutHolder = makeFlyoutHolder(tlsId, refBtn); - flyoutHolder.data('isLibrary', true); - showBtn.data('isLibrary', true); - } // refData = Actions.getButtonData(opts.button); - - - placementObj['#' + tlsId + '_show'] = btn.id; // TODO: Find way to set the current icon using the iconloader if this is not default - // Include data for extension button as well as ref button - - /* curH = */ - - holders['#' + flyoutHolder[0].id] = [{ - sel: '#' + id, - fn: btn.events.click, - icon: btn.id, - // key: btn.key, - isDefault: true - }]; // , refData - // - // // {sel:'#tool_rect', fn: clickRect, evt: 'mouseup', key: 4, parent: '#tools_rect', icon: 'rect'} - // - // const pos = ('position' in opts)?opts.position:'last'; - // const len = flyoutHolder.children().length; - // - // // Add at given position or end - // if (!isNaN(pos) && pos >= 0 && pos < len) { - // flyoutHolder.children().eq(pos).before(button); - // } else { - // flyoutHolder.append(button); - // curH.reverse(); - // } - } else if (btn.type === 'app_menu') { - button.append('
    ').append(btn.title); - } - } else if (btn.list) { - // Add button to list - button.addClass('push_button'); - $$b('#' + btn.list + '_opts').append(button); - - if (btn.isDefault) { - $$b('#cur_' + btn.list).append(button.children().clone()); - - var _svgicon = btn.svgicon || btn.id; - - placementObj['#cur_' + btn.list] = _svgicon; - } - } else if (btn.includeWith) { - // Add to flyout menu / make flyout menu - var opts = btn.includeWith; // opts.button, default, position - - refBtn = $$b(opts.button); - flyoutHolder = refBtn.parent(); // Create a flyout menu if there isn't one already - - var _tlsId; - - if (!refBtn.parent().hasClass('tools_flyout')) { - // Create flyout placeholder - _tlsId = refBtn[0].id.replace('tool_', 'tools_'); - showBtn = refBtn.clone().attr('id', _tlsId + '_show').append($$b('
    ', { - class: 'flyout_arrow_horiz' - })); - refBtn.before(showBtn); // Create a flyout div - - flyoutHolder = makeFlyoutHolder(_tlsId, refBtn); - } - - refData = Actions.getButtonData(opts.button); - - if (opts.isDefault) { - placementObj['#' + _tlsId + '_show'] = btn.id; - } // TODO: Find way to set the current icon using the iconloader if this is not default - // Include data for extension button as well as ref button - - - var curH = holders['#' + flyoutHolder[0].id] = [{ - sel: '#' + id, - fn: btn.events.click, - icon: btn.id, - key: btn.key, - isDefault: Boolean(btn.includeWith && btn.includeWith.isDefault) - }, refData]; // {sel:'#tool_rect', fn: clickRect, evt: 'mouseup', key: 4, parent: '#tools_rect', icon: 'rect'} - - var pos = 'position' in opts ? opts.position : 'last'; - var len = flyoutHolder.children().length; // Add at given position or end - - if (!isNaN(pos) && pos >= 0 && pos < len) { - flyoutHolder.children().eq(pos).before(button); - } else { - flyoutHolder.append(button); - curH.reverse(); - } - } - - if (!svgicons) { - button.append(icon); - } - - if (!btn.list) { - // Add given events to button - $$b.each(btn.events, function (name, func) { - if (name === 'click' && btn.type === 'mode') { - // `touch.js` changes `touchstart` to `mousedown`, - // so we must map extension click events as well - if (isTouch() && name === 'click') { - name = 'mousedown'; + var extAdded = + /*#__PURE__*/ + function () { + var _ref14 = _asyncToGenerator( + /*#__PURE__*/ + regeneratorRuntime.mark(function _callee5(win, ext) { + var cbCalled, resizeDone, lang, prepResize, runCallback, btnSelects, svgicons, fallbackObj, placementObj, holders; + return regeneratorRuntime.wrap(function _callee5$(_context5) { + while (1) { + switch (_context5.prev = _context5.next) { + case 0: + prepResize = function _ref15() { + if (resizeTimer) { + clearTimeout(resizeTimer); + resizeTimer = null; + } + + if (!resizeDone) { + resizeTimer = setTimeout(function () { + resizeDone = true; + setIconSize($$b.pref('iconsize')); + }, 50); + } + }; + + if (ext) { + _context5.next = 3; + break; } - if (btn.includeWith) { - button.bind(name, func); - } else { - button.bind(name, function () { - if (toolButtonClick(button)) { - func(); + return _context5.abrupt("return"); + + case 3: + cbCalled = false; + resizeDone = false; + + if (!ext.langReady) { + _context5.next = 14; + break; + } + + if (!editor.langChanged) { + _context5.next = 13; + break; + } + + // We check for this since the "lang" pref could have been set by storage + lang = $$b.pref('lang'); + _context5.next = 10; + return ext.langReady({ + lang: lang, + uiStrings: uiStrings$1, + importLocale: getImportLocale({ + defaultLang: lang, + defaultName: ext.name + }) + }); + + case 10: + loadedExtensionNames.push(ext.name); + _context5.next = 14; + break; + + case 13: + extsPreLang.push(ext); + + case 14: + runCallback = function runCallback() { + if (ext.callback && !cbCalled) { + cbCalled = true; + ext.callback.call(editor); + } + }; + + btnSelects = []; + /** + * @typedef {PlainObject} module:SVGEditor.ContextTool + * @property {string} panel The ID of the existing panel to which the tool is being added. Required. + * @property {string} id The ID of the actual tool element. Required. + * @property {PlainObject.|PlainObject.<"change", external:jQuery.Function>} events DOM event names keyed to associated functions. Example: `{change () { alert('Option was changed') } }`. "change" event is one specifically handled for the "button-select" type. Required. + * @property {string} title The tooltip text that will appear when the user hovers over the tool. Required. + * @property {"tool_button"|"select"|"button-select"|"input"|string} type The type of tool being added. Expected. + * @property {PlainObject.} [options] List of options and their labels for select tools. Example: `{1: 'One', 2: 'Two', all: 'All' }`. Required by "select" tools. + * @property {string} [container_id] The ID to be given to the tool's container element. + * @property {string} [defval] Default value + * @property {string|Integer} [colnum] Added as part of the option list class. + * @property {string} [label] Label associated with the tool, visible in the UI + * @property {Integer} [size] Value of the "size" attribute of the tool input + * @property {module:jQuerySpinButton.SpinButtonConfig} [spindata] When added to a tool of type "input", this tool becomes a "spinner" which allows the number to be in/decreased. + */ + + if (ext.context_tools) { + $$b.each(ext.context_tools, function (i, tool) { + // Add select tool + var contId = tool.container_id ? ' id="' + tool.container_id + '"' : ''; + var panel = $$b('#' + tool.panel); // create the panel if it doesn't exist + + if (!panel.length) { + panel = $$b('
    ', { + id: tool.panel + }).appendTo('#tools_top'); + } + + var html; // TODO: Allow support for other types, or adding to existing tool + + switch (tool.type) { + case 'tool_button': + html = '
    ' + tool.id + '
    '; + var div = $$b(html).appendTo(panel); + + if (tool.events) { + $$b.each(tool.events, function (evt, func) { + $$b(div).bind(evt, func); + }); + } + + break; + + case 'select': + html = '' + ''; // Creates the tool, hides & adds it, returns the select element + + var sel = $$b(html).appendTo(panel).find('select'); + $$b.each(tool.events, function (evt, func) { + $$b(sel).bind(evt, func); + }); + break; + + case 'button-select': + html = ''; + var list = $$b('
      ').appendTo('#option_lists'); + + if (tool.colnum) { + list.addClass('optcols' + tool.colnum); + } // Creates the tool, hides & adds it, returns the select element + + /* const dropdown = */ + + + $$b(html).appendTo(panel).children(); + btnSelects.push({ + elem: '#' + tool.id, + list: '#' + tool.id + '_opts', + title: tool.title, + callback: tool.events.change, + cur: '#cur_' + tool.id + }); + break; + + case 'input': + html = '' + '' + tool.label + ':' + ''; // Creates the tool, hides & adds it, returns the select element + // Add to given tool.panel + + var inp = $$b(html).appendTo(panel).find('input'); + + if (tool.spindata) { + inp.SpinButton(tool.spindata); + } + + if (tool.events) { + $$b.each(tool.events, function (evt, func) { + inp.bind(evt, func); + }); + } + + break; + + default: + break; } }); } - if (btn.key) { - $$b(document).bind('keydown', btn.key, func); + svgicons = ext.svgicons; - if (btn.title) { - button.attr('title', btn.title + ' [' + btn.key + ']'); + if (!ext.buttons) { + _context5.next = 24; + break; + } + + fallbackObj = {}, placementObj = {}, holders = {}; + /** + * @typedef {GenericArray} module:SVGEditor.KeyArray + * @property {string} 0 The key to bind (on `keydown`) + * @property {boolean} 1 Whether to `preventDefault` on the `keydown` event + * @property {boolean} 2 Not apparently in use (NoDisableInInput) + */ + + /** + * @typedef {string|module:SVGEditor.KeyArray} module:SVGEditor.Key + */ + + /** + * @typedef {PlainObject} module:SVGEditor.Button + * @property {string} id A unique identifier for this button. If SVG icons are used, this must match the ID used in the icon file. Required. + * @property {"mode_flyout"|"mode"|"context"|"app_menu"} type Type of button. Required. + * @property {string} title The tooltip text that will appear when the user hovers over the icon. Required. + * @property {PlainObject.|PlainObject.<"click", external:jQuery.Function>} events DOM event names with associated functions. Example: `{click () { alert('Button was clicked') } }`. Click is used with `includeWith` and `type` of "mode_flyout" (and "mode"); any events may be added if `list` is not present. Expected. + * @property {string} panel The ID of the context panel to be included, if type is "context". Required only if type is "context". + * @property {string} icon The file path to the raster version of the icon image source. Required only if no `svgicons` is supplied from [ExtensionInitResponse]{@link module:svgcanvas.ExtensionInitResponse}. + * @property {string} [svgicon] If absent, will utilize the button "id"; used to set "placement" on the `svgIcons` call + * @property {string} [list] Points to the "id" of a `context_tools` item of type "button-select" into which the button will be added as a panel list item + * @property {Integer} [position] The numeric index for placement; defaults to last position (as of the time of extension addition) if not present. For use with {@link http://api.jquery.com/eq/}. + * @property {boolean} [isDefault] Whether or not the button is the default. Used with `list`. + * @property {PlainObject} [includeWith] Object with flyout menu data + * @property {boolean} [includeWith.isDefault] Indicates whether button is default in flyout list or not. + * @property {string} includeWith.button jQuery selector of the existing button to be joined. Example: '#tool_line'. Required if `includeWith` is used. + * @property {"last"|Integer} [includeWith.position] Position of icon in flyout list; will be added to end if not indicated. Integer is for use with {@link http://api.jquery.com/eq/}. + * @property {module:SVGEditor.Key} [key] The key to bind to the button + */ + // Add buttons given by extension + + $$b.each(ext.buttons, function (i, + /** @type {module:SVGEditor.Button} */ + btn) { + var id = btn.id; + var num = i; // Give button a unique ID + + while ($$b('#' + id).length) { + id = btn.id + '_' + ++num; } + + var icon; + + if (!svgicons) { + icon = $$b(''); + } else { + fallbackObj[id] = btn.icon; + var svgicon = btn.svgicon || btn.id; + + if (btn.type === 'app_menu') { + placementObj['#' + id + ' > div'] = svgicon; + } else { + placementObj['#' + id] = svgicon; + } + } + + var cls, parent; // Set button up according to its type + + switch (btn.type) { + case 'mode_flyout': + case 'mode': + cls = 'tool_button'; + parent = '#tools_left'; + break; + + case 'context': + cls = 'tool_button'; + parent = '#' + btn.panel; // create the panel if it doesn't exist + + if (!$$b(parent).length) { + $$b('
      ', { + id: btn.panel + }).appendTo('#tools_top'); + } + + break; + + case 'app_menu': + cls = ''; + parent = '#main_menu ul'; + break; + } + + var flyoutHolder, showBtn, refData, refBtn; + var button = $$b(btn.list || btn.type === 'app_menu' ? '
    • ' : '
      ').attr('id', id).attr('title', btn.title).addClass(cls); + + if (!btn.includeWith && !btn.list) { + if ('position' in btn) { + if ($$b(parent).children().eq(btn.position).length) { + $$b(parent).children().eq(btn.position).before(button); + } else { + $$b(parent).children().last().before(button); + } + } else { + button.appendTo(parent); + } + + if (btn.type === 'mode_flyout') { + // Add to flyout menu / make flyout menu + // const opts = btn.includeWith; + // // opts.button, default, position + refBtn = $$b(button); + flyoutHolder = refBtn.parent(); // Create a flyout menu if there isn't one already + + var tlsId; + + if (!refBtn.parent().hasClass('tools_flyout')) { + // Create flyout placeholder + tlsId = refBtn[0].id.replace('tool_', 'tools_'); + showBtn = refBtn.clone().attr('id', tlsId + '_show').append($$b('
      ', { + class: 'flyout_arrow_horiz' + })); + refBtn.before(showBtn); // Create a flyout div + + flyoutHolder = makeFlyoutHolder(tlsId, refBtn); + flyoutHolder.data('isLibrary', true); + showBtn.data('isLibrary', true); + } // refData = Actions.getButtonData(opts.button); + + + placementObj['#' + tlsId + '_show'] = btn.id; // TODO: Find way to set the current icon using the iconloader if this is not default + // Include data for extension button as well as ref button + + /* curH = */ + + holders['#' + flyoutHolder[0].id] = [{ + sel: '#' + id, + fn: btn.events.click, + icon: btn.id, + // key: btn.key, + isDefault: true + }]; // , refData + // + // // {sel:'#tool_rect', fn: clickRect, evt: 'mouseup', key: 4, parent: '#tools_rect', icon: 'rect'} + // + // const pos = ('position' in opts)?opts.position:'last'; + // const len = flyoutHolder.children().length; + // + // // Add at given position or end + // if (!isNaN(pos) && pos >= 0 && pos < len) { + // flyoutHolder.children().eq(pos).before(button); + // } else { + // flyoutHolder.append(button); + // curH.reverse(); + // } + } else if (btn.type === 'app_menu') { + button.append('
      ').append(btn.title); + } + } else if (btn.list) { + // Add button to list + button.addClass('push_button'); + $$b('#' + btn.list + '_opts').append(button); + + if (btn.isDefault) { + $$b('#cur_' + btn.list).append(button.children().clone()); + + var _svgicon = btn.svgicon || btn.id; + + placementObj['#cur_' + btn.list] = _svgicon; + } + } else if (btn.includeWith) { + // Add to flyout menu / make flyout menu + var opts = btn.includeWith; // opts.button, default, position + + refBtn = $$b(opts.button); + flyoutHolder = refBtn.parent(); // Create a flyout menu if there isn't one already + + var _tlsId; + + if (!refBtn.parent().hasClass('tools_flyout')) { + // Create flyout placeholder + _tlsId = refBtn[0].id.replace('tool_', 'tools_'); + showBtn = refBtn.clone().attr('id', _tlsId + '_show').append($$b('
      ', { + class: 'flyout_arrow_horiz' + })); + refBtn.before(showBtn); // Create a flyout div + + flyoutHolder = makeFlyoutHolder(_tlsId, refBtn); + } + + refData = Actions.getButtonData(opts.button); + + if (opts.isDefault) { + placementObj['#' + _tlsId + '_show'] = btn.id; + } // TODO: Find way to set the current icon using the iconloader if this is not default + // Include data for extension button as well as ref button + + + var curH = holders['#' + flyoutHolder[0].id] = [{ + sel: '#' + id, + fn: btn.events.click, + icon: btn.id, + key: btn.key, + isDefault: Boolean(btn.includeWith && btn.includeWith.isDefault) + }, refData]; // {sel:'#tool_rect', fn: clickRect, evt: 'mouseup', key: 4, parent: '#tools_rect', icon: 'rect'} + + var pos = 'position' in opts ? opts.position : 'last'; + var len = flyoutHolder.children().length; // Add at given position or end + + if (!isNaN(pos) && pos >= 0 && pos < len) { + flyoutHolder.children().eq(pos).before(button); + } else { + flyoutHolder.append(button); + curH.reverse(); + } + } + + if (!svgicons) { + button.append(icon); + } + + if (!btn.list) { + // Add given events to button + $$b.each(btn.events, function (name, func) { + if (name === 'click' && btn.type === 'mode') { + // `touch.js` changes `touchstart` to `mousedown`, + // so we must map extension click events as well + if (isTouch() && name === 'click') { + name = 'mousedown'; + } + + if (btn.includeWith) { + button.bind(name, func); + } else { + button.bind(name, function () { + if (toolButtonClick(button)) { + func(); + } + }); + } + + if (btn.key) { + $$b(document).bind('keydown', btn.key, func); + + if (btn.title) { + button.attr('title', btn.title + ' [' + btn.key + ']'); + } + } + } else { + button.bind(name, func); + } + }); + } + + setupFlyouts(holders); + }); + $$b.each(btnSelects, function () { + addAltDropDown(this.elem, this.list, this.callback, { + seticon: true + }); + }); + + if (!svgicons) { + _context5.next = 24; + break; } - } else { - button.bind(name, func); - } - }); + + return _context5.abrupt("return", new Promise(function (resolve, reject) { + $$b.svgIcons(svgicons, { + w: 24, + h: 24, + id_match: false, + no_img: !isWebkit(), + fallback: fallbackObj, + placement: placementObj, + callback: function callback(icons) { + // Non-ideal hack to make the icon match the current size + // if (curPrefs.iconsize && curPrefs.iconsize !== 'm') { + if ($$b.pref('iconsize') !== 'm') { + prepResize(); + } + + runCallback(); + resolve(); + } + }); + })); + + case 24: + return _context5.abrupt("return", runCallback()); + + case 25: + case "end": + return _context5.stop(); + } } + }, _callee5, this); + })); - setupFlyouts(holders); - }); - $$b.each(btnSelects, function () { - addAltDropDown(this.elem, this.list, this.callback, { - seticon: true - }); - }); - - if (svgicons) { - return new Promise(function (resolve, reject) { - $$b.svgIcons(svgicons, { - w: 24, - h: 24, - id_match: false, - no_img: !isWebkit(), - fallback: fallbackObj, - placement: placementObj, - callback: function callback(icons) { - // Non-ideal hack to make the icon match the current size - // if (curPrefs.iconsize && curPrefs.iconsize !== 'm') { - if ($$b.pref('iconsize') !== 'm') { - prepResize(); - } - - runCallback(); - resolve(); - } - }); - }); - } - } - - return runCallback(); - }; + return function extAdded(_x3, _x4) { + return _ref14.apply(this, arguments); + }; + }(); var getPaint = function getPaint(color, opac, type) { // update the editor's fill paint @@ -31222,9 +31273,9 @@ editor.init = function () { * @listens module:svgcanvas.SvgCanvas#event:updateCanvas * @returns {undefined} */ - function (win, _ref14) { - var center = _ref14.center, - newCtr = _ref14.newCtr; + function (win, _ref16) { + var center = _ref16.center, + newCtr = _ref16.newCtr; updateCanvas(center, newCtr); }); svgCanvas.bind('contextset', contextChanged); @@ -32032,15 +32083,15 @@ editor.init = function () { 'PNG', 'JPEG', 'BMP', 'WEBP', 'PDF'], /*#__PURE__*/ function () { - var _ref15 = _asyncToGenerator( + var _ref17 = _asyncToGenerator( /*#__PURE__*/ - regeneratorRuntime.mark(function _callee5(imgType) { + regeneratorRuntime.mark(function _callee6(imgType) { var exportWindowName, openExportWindow, chrome, quality; - return regeneratorRuntime.wrap(function _callee5$(_context5) { + return regeneratorRuntime.wrap(function _callee6$(_context6) { while (1) { - switch (_context5.prev = _context5.next) { + switch (_context6.prev = _context6.next) { case 0: - openExportWindow = function _ref16() { + openExportWindow = function _ref18() { var str = uiStrings$1.notification.loadingImage; if (curConfig.exportWindowType === 'new') { @@ -32071,17 +32122,17 @@ editor.init = function () { }; if (imgType) { - _context5.next = 3; + _context6.next = 3; break; } - return _context5.abrupt("return"); + return _context6.abrupt("return"); case 3: chrome = isChrome(); if (!(imgType === 'PDF')) { - _context5.next = 9; + _context6.next = 9; break; } @@ -32090,7 +32141,7 @@ editor.init = function () { } svgCanvas.exportPDF(exportWindowName, chrome ? 'save' : undefined); - _context5.next = 13; + _context6.next = 13; break; case 9: @@ -32101,19 +32152,19 @@ editor.init = function () { quality = parseInt($$b('#image-slider').val(), 10) / 100; /* const results = */ - _context5.next = 13; + _context6.next = 13; return svgCanvas.rasterExport(imgType, quality, exportWindowName); case 13: case "end": - return _context5.stop(); + return _context6.stop(); } } - }, _callee5, this); + }, _callee6, this); })); - return function (_x3) { - return _ref15.apply(this, arguments); + return function (_x5) { + return _ref17.apply(this, arguments); }; }(), function () { var sel = $$b(this); @@ -32350,12 +32401,12 @@ editor.init = function () { /*#__PURE__*/ _asyncToGenerator( /*#__PURE__*/ - regeneratorRuntime.mark(function _callee6() { - var color, lang, _ref18, langParam, langData; + regeneratorRuntime.mark(function _callee7() { + var color, lang, _ref20, langParam, langData; - return regeneratorRuntime.wrap(function _callee6$(_context6) { + return regeneratorRuntime.wrap(function _callee7$(_context7) { while (1) { - switch (_context6.prev = _context6.next) { + switch (_context7.prev = _context7.next) { case 0: // Set background color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF'; @@ -32364,20 +32415,21 @@ editor.init = function () { lang = $$b('#lang_select').val(); if (!(lang !== $$b.pref('lang'))) { - _context6.next = 10; + _context7.next = 11; break; } - _context6.next = 6; + _context7.next = 6; return editor.putLocale(lang, goodLangs, curConfig); case 6: - _ref18 = _context6.sent; - langParam = _ref18.langParam; - langData = _ref18.langData; - setLang(langParam, langData); + _ref20 = _context7.sent; + langParam = _ref20.langParam; + langData = _ref20.langData; + _context7.next = 11; + return setLang(langParam, langData); - case 10: + case 11: // set icon size setIconSize($$b('#iconsize').val()); // set grid setting @@ -32396,12 +32448,12 @@ editor.init = function () { updateCanvas(); hidePreferences(); - case 21: + case 22: case "end": - return _context6.stop(); + return _context7.stop(); } } - }, _callee6, this); + }, _callee7, this); })); var resetScrollPos = $$b.noop; @@ -33969,8 +34021,8 @@ editor.init = function () { // bitmap handling reader = new FileReader(); - reader.onloadend = function (_ref19) { - var result = _ref19.target.result; + reader.onloadend = function (_ref21) { + var result = _ref21.target.result; // let's insert the new image until we know its dimensions var insertNewImage = function insertNewImage(width, height) { @@ -34042,11 +34094,12 @@ editor.init = function () { $$b('#tool_open').show().prepend(open); var imgImport = $$b('').change(importImage); $$b('#tool_import').show().prepend(imgImport); - } // const revnums = 'svg-editor.js ($Rev$) '; + } + + updateCanvas(true); // const revnums = 'svg-editor.js ($Rev$) '; // revnums += svgCanvas.getVersion(); // $('#copyright')[0].setAttribute('title', revnums); - var loadedExtensionNames = []; /** * @function module:SVGEditor.setLang @@ -34054,80 +34107,124 @@ editor.init = function () { * @param {module:locale.LocaleStrings} allStrings See {@tutorial LocaleDocs} * @fires module:svgcanvas.SvgCanvas#event:ext-langReady * @fires module:svgcanvas.SvgCanvas#event:ext-langChanged - * @returns {undefined} + * @returns {Promise} A Promise which resolves to `undefined` */ - var setLang = editor.setLang = function (lang, allStrings) { - editor.langChanged = true; - $$b.pref('lang', lang); - $$b('#lang_select').val(lang); + var setLang = editor.setLang = + /*#__PURE__*/ + function () { + var _ref22 = _asyncToGenerator( + /*#__PURE__*/ + regeneratorRuntime.mark(function _callee8(lang, allStrings) { + var oldLayerName, renameLayer, ext, elems; + return regeneratorRuntime.wrap(function _callee8$(_context8) { + while (1) { + switch (_context8.prev = _context8.next) { + case 0: + editor.langChanged = true; + $$b.pref('lang', lang); + $$b('#lang_select').val(lang); - if (!allStrings) { - return; - } + if (allStrings) { + _context8.next = 5; + break; + } - $$b.extend(uiStrings$1, allStrings); // const notif = allStrings.notification; // Currently unused - // $.extend will only replace the given strings + return _context8.abrupt("return"); - var oldLayerName = $$b('#layerlist tr.layersel td.layername').text(); - var renameLayer = oldLayerName === uiStrings$1.common.layer + ' 1'; - svgCanvas.setUiStrings(allStrings); - Actions.setTitles(); + case 5: + $$b.extend(uiStrings$1, allStrings); // const notif = allStrings.notification; // Currently unused + // $.extend will only replace the given strings - if (renameLayer) { - svgCanvas.renameCurrentLayer(uiStrings$1.common.layer + ' 1'); - populateLayers(); - } // In case extensions loaded before the locale, now we execute a callback on them + oldLayerName = $$b('#layerlist tr.layersel td.layername').text(); + renameLayer = oldLayerName === uiStrings$1.common.layer + ' 1'; + svgCanvas.setUiStrings(allStrings); + Actions.setTitles(); + + if (renameLayer) { + svgCanvas.renameCurrentLayer(uiStrings$1.common.layer + ' 1'); + populateLayers(); + } // In case extensions loaded before the locale, now we execute a callback on them - if (extsPreLang.length) { - while (extsPreLang.length) { - var ext = extsPreLang.shift(); - loadedExtensionNames.push(ext.name); - ext.langReady({ - lang: lang, - uiStrings: uiStrings$1, - importLocale: getImportLocale({ - defaultLang: lang, - defaultName: ext.name - }) - }); - } - } else { - loadedExtensionNames.forEach(function (loadedExtensionName) { - svgCanvas.runExtensions('langReady', - /** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */ - { - lang: lang, - uiStrings: uiStrings$1, - importLocale: getImportLocale({ - defaultLang: lang, - defaultName: loadedExtensionName - }) - }); - }); - } + if (!extsPreLang.length) { + _context8.next = 21; + break; + } - svgCanvas.runExtensions('langChanged', - /** @type {module:svgcanvas.SvgCanvas#event:ext-langChanged} */ - lang); // Update flyout tooltips + case 12: + if (!extsPreLang.length) { + _context8.next = 19; + break; + } - setFlyoutTitles(); // Copy title for certain tool elements + ext = extsPreLang.shift(); + loadedExtensionNames.push(ext.name); + _context8.next = 17; + return ext.langReady({ + lang: lang, + uiStrings: uiStrings$1, + importLocale: getImportLocale({ + defaultLang: lang, + defaultName: ext.name + }) + }); - var elems = { - '#stroke_color': '#tool_stroke .icon_label, #tool_stroke .color_block', - '#fill_color': '#tool_fill label, #tool_fill .color_block', - '#linejoin_miter': '#cur_linejoin', - '#linecap_butt': '#cur_linecap' + case 17: + _context8.next = 12; + break; + + case 19: + _context8.next = 22; + break; + + case 21: + loadedExtensionNames.forEach(function (loadedExtensionName) { + svgCanvas.runExtensions('langReady', + /** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */ + { + lang: lang, + uiStrings: uiStrings$1, + importLocale: getImportLocale({ + defaultLang: lang, + defaultName: loadedExtensionName + }) + }); + }); + + case 22: + svgCanvas.runExtensions('langChanged', + /** @type {module:svgcanvas.SvgCanvas#event:ext-langChanged} */ + lang); // Update flyout tooltips + + setFlyoutTitles(); // Copy title for certain tool elements + + elems = { + '#stroke_color': '#tool_stroke .icon_label, #tool_stroke .color_block', + '#fill_color': '#tool_fill label, #tool_fill .color_block', + '#linejoin_miter': '#cur_linejoin', + '#linecap_butt': '#cur_linecap' + }; + $$b.each(elems, function (source, dest) { + $$b(dest).attr('title', $$b(source)[0].title); + }); // Copy alignment titles + + $$b('#multiselected_panel div[id^=tool_align]').each(function () { + $$b('#tool_pos' + this.id.substr(10))[0].title = this.title; + }); + + case 27: + case "end": + return _context8.stop(); + } + } + }, _callee8, this); + })); + + return function (_x6, _x7) { + return _ref22.apply(this, arguments); }; - $$b.each(elems, function (source, dest) { - $$b(dest).attr('title', $$b(source)[0].title); - }); // Copy alignment titles - - $$b('#multiselected_panel div[id^=tool_align]').each(function () { - $$b('#tool_pos' + this.id.substr(10))[0].title = this.title; - }); - }; + }(); init$7( /** @@ -34336,9 +34433,9 @@ var messageQueue = []; * @returns {undefined} */ -var messageListener = function messageListener(_ref20) { - var data = _ref20.data, - origin = _ref20.origin; +var messageListener = function messageListener(_ref23) { + var data = _ref23.data, + origin = _ref23.origin; // console.log('data, origin, extensionsAdded', data, origin, extensionsAdded); var messageObj = { data: data, diff --git a/dist/index-es.min.js b/dist/index-es.min.js index 430ce654..9624d96b 100644 --- a/dist/index-es.min.js +++ b/dist/index-es.min.js @@ -1,2 +1,2 @@ -function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function asyncGeneratorStep(e,t,n,a,r,i,o){try{var s=e[i](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(a,r)}function _asyncToGenerator(e){return function(){var t=this,n=arguments;return new Promise(function(a,r){var i=e.apply(t,n);function o(e){asyncGeneratorStep(i,a,r,o,s,"next",e)}function s(e){asyncGeneratorStep(i,a,r,o,s,"throw",e)}o(void 0)})}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;nt.getTotalLength())break;n--}while(n>0);return n}),window.SVGPathSeg=e,window.SVGPathSegClosePath=t,window.SVGPathSegMovetoAbs=n,window.SVGPathSegMovetoRel=a,window.SVGPathSegLinetoAbs=r,window.SVGPathSegLinetoRel=i,window.SVGPathSegCurvetoCubicAbs=o,window.SVGPathSegCurvetoCubicRel=s,window.SVGPathSegCurvetoQuadraticAbs=l,window.SVGPathSegCurvetoQuadraticRel=c,window.SVGPathSegArcAbs=u,window.SVGPathSegArcRel=d,window.SVGPathSegLinetoHorizontalAbs=h,window.SVGPathSegLinetoHorizontalRel=g,window.SVGPathSegLinetoVerticalAbs=p,window.SVGPathSegLinetoVerticalRel=f,window.SVGPathSegCurvetoCubicSmoothAbs=m,window.SVGPathSegCurvetoCubicSmoothRel=v,window.SVGPathSegCurvetoQuadraticSmoothAbs=_,window.SVGPathSegCurvetoQuadraticSmoothRel=b}if(!("SVGPathSegList"in window&&"appendItem"in window.SVGPathSegList.prototype)){var y=function(){function e(t){_classCallCheck(this,e),this._pathElement=t,this._list=this._parsePath(this._pathElement.getAttribute("d")),this._mutationObserverConfig={attributes:!0,attributeFilter:["d"]},this._pathElementMutationObserver=new MutationObserver(this._updateListFromPathMutations.bind(this)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)}return _createClass(e,[{key:"_checkPathSynchronizedToList",value:function(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())}},{key:"_updateListFromPathMutations",value:function(e){if(this._pathElement){var t=!1;e.forEach(function(e){"d"===e.attributeName&&(t=!0)}),t&&(this._list=this._parsePath(this._pathElement.getAttribute("d")))}}},{key:"_writeListToPath",value:function(){this._pathElementMutationObserver.disconnect(),this._pathElement.setAttribute("d",e._pathSegArrayAsString(this._list)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)}},{key:"segmentChanged",value:function(e){this._writeListToPath()}},{key:"clear",value:function(){this._checkPathSynchronizedToList(),this._list.forEach(function(e){e._owningPathSegList=null}),this._list=[],this._writeListToPath()}},{key:"initialize",value:function(e){return this._checkPathSynchronizedToList(),this._list=[e],e._owningPathSegList=this,this._writeListToPath(),e}},{key:"_checkValidIndex",value:function(e){if(isNaN(e)||e<0||e>=this.numberOfItems)throw new Error("INDEX_SIZE_ERR")}},{key:"getItem",value:function(e){return this._checkPathSynchronizedToList(),this._checkValidIndex(e),this._list[e]}},{key:"insertItemBefore",value:function(e,t){return this._checkPathSynchronizedToList(),t>this.numberOfItems&&(t=this.numberOfItems),e._owningPathSegList&&(e=e.clone()),this._list.splice(t,0,e),e._owningPathSegList=this,this._writeListToPath(),e}},{key:"replaceItem",value:function(e,t){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._checkValidIndex(t),this._list[t]=e,e._owningPathSegList=this,this._writeListToPath(),e}},{key:"removeItem",value:function(e){this._checkPathSynchronizedToList(),this._checkValidIndex(e);var t=this._list[e];return this._list.splice(e,1),this._writeListToPath(),t}},{key:"appendItem",value:function(e){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._list.push(e),e._owningPathSegList=this,this._writeListToPath(),e}},{key:"_parsePath",value:function(e){if(!e||!e.length)return[];var t=this,n=function(){function e(){_classCallCheck(this,e),this.pathSegList=[]}return _createClass(e,[{key:"appendSegment",value:function(e){this.pathSegList.push(e)}}]),e}(),a=function(){function e(t){_classCallCheck(this,e),this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()}return _createClass(e,[{key:"_isCurrentSpace",value:function(){var e=this._string[this._currentIndex];return e<=" "&&(" "===e||"\n"===e||"\t"===e||"\r"===e||"\f"===e)}},{key:"_skipOptionalSpaces",value:function(){for(;this._currentIndex="0"&&e<="9")&&t!==SVGPathSeg.PATHSEG_CLOSEPATH?t===SVGPathSeg.PATHSEG_MOVETO_ABS?SVGPathSeg.PATHSEG_LINETO_ABS:t===SVGPathSeg.PATHSEG_MOVETO_REL?SVGPathSeg.PATHSEG_LINETO_REL:t:SVGPathSeg.PATHSEG_UNKNOWN}},{key:"initialCommandIsMoveTo",value:function(){if(!this.hasMoreData())return!0;var e=this.peekSegmentType();return e===SVGPathSeg.PATHSEG_MOVETO_ABS||e===SVGPathSeg.PATHSEG_MOVETO_REL}},{key:"_parseNumber",value:function(){var e=0,t=0,n=1,a=0,r=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,a+=(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+a;if(u*=r,e&&(u*=Math.pow(10,i*e)),o!==this._currentIndex)return this._skipOptionalSpacesOrDelimiter(),u}}},{key:"_parseArcFlag",value:function(){if(!(this._currentIndex>=this._endIndex)){var e=!1,t=this._string.charAt(this._currentIndex++);if("0"===t)e=!1;else{if("1"!==t)return;e=!0}return this._skipOptionalSpacesOrDelimiter(),e}}},{key:"parseSegment",value:function(){var e=this._string[this._currentIndex],n=this._pathSegTypeFromChar(e);if(n===SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand===SVGPathSeg.PATHSEG_UNKNOWN)return null;if((n=this._nextCommandHelper(e,this._previousCommand))===SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=n,n){case SVGPathSeg.PATHSEG_MOVETO_REL:return new SVGPathSegMovetoRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_MOVETO_ABS:return new SVGPathSegMovetoAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_REL:return new SVGPathSegLinetoRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_ABS:return new SVGPathSegLinetoAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new SVGPathSegLinetoHorizontalRel(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new SVGPathSegLinetoHorizontalAbs(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new SVGPathSegLinetoVerticalRel(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new SVGPathSegLinetoVerticalAbs(t,this._parseNumber());case SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new SVGPathSegClosePath(t);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:var a={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicRel(t,a.x,a.y,a.x1,a.y1,a.x2,a.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:var r={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicAbs(t,r.x,r.y,r.x1,r.y1,r.x2,r.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:var i={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothRel(t,i.x,i.y,i.x2,i.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:var o={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothAbs(t,o.x,o.y,o.x2,o.y2);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:var s={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticRel(t,s.x,s.y,s.x1,s.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:var l={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticAbs(t,l.x,l.y,l.x1,l.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new SVGPathSegCurvetoQuadraticSmoothRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new SVGPathSegCurvetoQuadraticSmoothAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_ARC_REL:var c={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegArcRel(t,c.x,c.y,c.x1,c.y1,c.arcAngle,c.arcLarge,c.arcSweep);case SVGPathSeg.PATHSEG_ARC_ABS:var u={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegArcAbs(t,u.x,u.y,u.x1,u.y1,u.arcAngle,u.arcLarge,u.arcSweep);default:throw new Error("Unknown path seg type.")}}}]),e}(),r=new n,i=new a(e);if(!i.initialCommandIsMoveTo())return[];for(;i.hasMoreData();){var o=i.parseSegment();if(!o)return[];r.appendSegment(o)}return r.pathSegList}}]),e}();y.prototype.classname="SVGPathSegList",Object.defineProperty(y.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),y._pathSegArrayAsString=function(e){var t="",n=!0;return e.forEach(function(e){n?(n=!1,t+=e._asPathString()):t+=" "+e._asPathString()}),t},Object.defineProperties(SVGPathElement.prototype,{pathSegList:{get:function(){return this._pathSegList||(this._pathSegList=new y(this)),this._pathSegList},enumerable:!0},normalizedPathSegList:{get:function(){return this.pathSegList},enumerable:!0},animatedPathSegList:{get:function(){return this.pathSegList},enumerable:!0},animatedNormalizedPathSegList:{get:function(){return this.pathSegList},enumerable:!0}}),window.SVGPathSegList=y}}();var $=jQuery,supportsSVG_=!!document.createElementNS&&!!document.createElementNS(NS.SVG,"svg").createSVGRect,_navigator=navigator,userAgent=_navigator.userAgent,svg=document.createElementNS(NS.SVG,"svg"),isOpera_=!!window.opera,isWebkit_=userAgent.includes("AppleWebKit"),isGecko_=userAgent.includes("Gecko/"),isIE_=userAgent.includes("MSIE"),isChrome_=userAgent.includes("Chrome/"),isWindows_=userAgent.includes("Windows"),isMac_=userAgent.includes("Macintosh"),isTouch_="ontouchstart"in window,supportsSelectors_=!!svg.querySelector,supportsXpath_=!!document.evaluate,supportsPathReplaceItem_=function(){var e=document.createElementNS(NS.SVG,"path");e.setAttribute("d","M0,0 10,10");var t=e.pathSegList,n=e.createSVGPathSegLinetoAbs(5,5);try{return t.replaceItem(n,1),!0}catch(e){}return!1}(),supportsPathInsertItemBefore_=function(){var e=document.createElementNS(NS.SVG,"path");e.setAttribute("d","M0,0 10,10");var t=e.pathSegList,n=e.createSVGPathSegLinetoAbs(5,5);try{return t.insertItemBefore(n,1),!0}catch(e){}return!1}(),supportsGoodTextCharPos_=function(){var e=document.createElementNS(NS.SVG,"svg"),t=document.createElementNS(NS.SVG,"svg");document.documentElement.append(e),t.setAttribute("x",5),e.append(t);var n=document.createElementNS(NS.SVG,"text");n.textContent="a",t.append(n);try{return 0===n.getStartPositionOfChar(0).x}catch(e){return!1}finally{e.remove()}}(),supportsPathBBox_=function(){var e=document.createElementNS(NS.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(NS.SVG,"path");t.setAttribute("d","M0,0 C0,0 10,10 10,0"),e.append(t);var n=t.getBBox();return e.remove(),n.height>4&&n.height<5}(),supportsHVLineContainerBBox_=function(){var e=document.createElementNS(NS.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(NS.SVG,"path");t.setAttribute("d","M0,0 10,0");var n=document.createElementNS(NS.SVG,"path");n.setAttribute("d","M5,0 15,0");var a=document.createElementNS(NS.SVG,"g");a.append(t,n),e.append(a);var r=a.getBBox();return e.remove(),15===r.width}(),supportsGoodDecimals_=function(){var e=document.createElementNS(NS.SVG,"rect");e.setAttribute("x",.1);var t=!e.cloneNode(!1).getAttribute("x").includes(",");return t||$.alert('NOTE: This version of Opera is known to contain bugs in SVG-edit.\nPlease upgrade to the latest version in which the problems have been fixed.'),t}(),supportsNonScalingStroke_=function(){var e=document.createElementNS(NS.SVG,"rect");return e.setAttribute("style","vector-effect:non-scaling-stroke"),"non-scaling-stroke"===e.style.vectorEffect}(),supportsNativeSVGTransformLists_=function(){var e=document.createElementNS(NS.SVG,"rect").transform.baseVal,t=svg.createSVGTransform();e.appendItem(t);var n=e.getItem(0);return n instanceof SVGTransform&&t instanceof SVGTransform&&n.type===t.type&&n.angle===t.angle&&n.matrix.a===t.matrix.a&&n.matrix.b===t.matrix.b&&n.matrix.c===t.matrix.c&&n.matrix.d===t.matrix.d&&n.matrix.e===t.matrix.e&&n.matrix.f===t.matrix.f}(),isOpera=function(){return isOpera_},isWebkit=function(){return isWebkit_},isGecko=function(){return isGecko_},isIE=function(){return isIE_},isChrome=function(){return isChrome_},isMac=function(){return isMac_},isTouch=function(){return isTouch_},supportsSelectors=function(){return supportsSelectors_},supportsXpath=function(){return supportsXpath_},supportsPathReplaceItem=function(){return supportsPathReplaceItem_},supportsPathInsertItemBefore=function(){return supportsPathInsertItemBefore_},supportsPathBBox=function(){return supportsPathBBox_},supportsHVLineContainerBBox=function(){return supportsHVLineContainerBBox_},supportsGoodTextCharPos=function(){return supportsGoodTextCharPos_},supportsNonScalingStroke=function(){return supportsNonScalingStroke_},supportsNativeTransformLists=function(){return supportsNativeSVGTransformLists_};function jqPluginSVG(e){var t=e.fn.attr;return e.fn.attr=function(e,n){var a=this.length;if(!a)return t.apply(this,arguments);for(var r=0;r=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],a=new Array(this.numberOfItems-1);for(t=0;t=0;t--)this.stack[t].unapply(e);e&&e.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY,this)}},{key:"elements",value:function(){for(var e=[],t=this.stack.length;t--;)for(var n=this.stack[t].elements(),a=n.length;a--;)e.includes(n[a])||e.push(n[a]);return e}},{key:"addSubCommand",value:function(e){this.stack.push(e)}},{key:"isEmpty",value:function(){return!this.stack.length}}]),t}();BatchCommand.type=BatchCommand.prototype.type;var newcx,newcy,oldcx,oldcy,angle,UndoManager=function(){function e(t){_classCallCheck(this,e),this.handler_=t||null,this.undoStackPointer=0,this.undoStack=[],this.undoChangeStackPointer=-1,this.undoableChangeStack=[]}return _createClass(e,[{key:"resetUndoStack",value:function(){this.undoStack=[],this.undoStackPointer=0}},{key:"getUndoStackSize",value:function(){return this.undoStackPointer}},{key:"getRedoStackSize",value:function(){return this.undoStack.length-this.undoStackPointer}},{key:"getNextUndoCommandText",value:function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():""}},{key:"getNextRedoCommandText",value:function(){return this.undoStackPointer0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)}},{key:"redo",value:function(){this.undoStackPointer0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)}},{key:"addCommandToHistory",value:function(e){this.undoStackPointer0&&(this.undoStack=this.undoStack.splice(0,this.undoStackPointer)),this.undoStack.push(e),this.undoStackPointer=this.undoStack.length}},{key:"beginUndoableChange",value:function(e,t){for(var n=++this.undoChangeStackPointer,a=t.length,r=new Array(a),i=new Array(a);a--;){var o=t[a];null!=o&&(i[a]=o,r[a]=o.getAttribute(e))}this.undoableChangeStack[n]={attrName:e,oldValues:r,elements:i}}},{key:"finishUndoableChange",value:function(){for(var e=this.undoChangeStackPointer--,t=this.undoableChangeStack[e],n=t.attrName,a=new BatchCommand("Change "+n),r=t.elements.length;r--;){var i=t.elements[r];if(null!=i){var o={};o[n]=t.oldValues[r],o[n]!==i.getAttribute(n)&&a.addSubCommand(new ChangeElementCommand(i,o,n))}}return this.undoableChangeStack[e]=null,a}}]),e}(),history=Object.freeze({HistoryEventTypes:HistoryEventTypes,MoveElementCommand:MoveElementCommand,InsertElementCommand:InsertElementCommand,RemoveElementCommand:RemoveElementCommand,ChangeElementCommand:ChangeElementCommand,BatchCommand:BatchCommand,UndoManager:UndoManager}),NEAR_ZERO=1e-14,svg$1=document.createElementNS(NS.SVG,"svg"),transformPoint=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},isIdentity=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},matrixMultiply=function(){for(var e=arguments.length,t=new Array(e),n=0;n(n=parseInt(n,10))){var a=n;n=t,t=a}for(var r=svg$1.createSVGMatrix(),i=t;i<=n;++i){var o=i>=0&&ie.x&&t.ye.y},$$1=jQuery,segData={2:["x","y"],4:["x","y"],6:["x","y","x1","y1","x2","y2"],8:["x","y","x1","y1"],10:["x","y","r1","r2","angle","largeArcFlag","sweepFlag"],12:["x"],14:["y"],16:["x","y","x2","y2"],18:["x","y"]},uiStrings={},setUiStrings=function(e){Object.assign(uiStrings,e.ui)},pathFuncs=[],linkControlPts=!0,pathData={},setLinkControlPoints=function(e){linkControlPts=e},path=null,editorContext_=null,init$1=function(e){editorContext_=e,pathFuncs=[0,"ClosePath"];$$1.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],function(e,t){pathFuncs.push(t+"Abs"),pathFuncs.push(t+"Rel")})},insertItemBefore=function(e,t,n){var a=e.pathSegList;if(supportsPathInsertItemBefore())a.insertItemBefore(t,n);else{for(var r=a.numberOfItems,i=[],o=0;o0?(g=f element");this.elem=t,this.segs=[],this.selected_pts=[],path=this,this.init()}return _createClass(e,[{key:"init",value:function(){$$1(getGripContainer()).find("*").each(function(){$$1(this).attr("display","none")});var e=this.elem.pathSegList,t=e.numberOfItems;this.segs=[],this.selected_pts=[],this.first_seg=null;for(var n=0;n=t?null:i[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(),null==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&&this.selected_pts.push(n)}this.selected_pts.sort();var a=this.selected_pts.length,r=[];for(r.length=a;a--;){var i=this.selected_pts[a],o=this.segs[i];o.select(!0),r[a]=o.ptgrip}var s=this.subpathIsClosed(this.selected_pts[0]);editorContext_.addPtsToSelection({grips:r,closedSubpath:s})}}]),e}(),getPath_=function(e){var t=pathData[e.id];return t||(t=pathData[e.id]=new Path(e)),t},removePath_=function(e){e in pathData&&delete pathData[e]},getRotVals=function(e,t){var n=e-oldcx,a=t-oldcy,r=Math.sqrt(n*n+a*a),i=Math.atan2(a,n)+angle;return n=r*Math.cos(i)+oldcx,a=r*Math.sin(i)+oldcy,n-=newcx,a-=newcy,r=Math.sqrt(n*n+a*a),i=Math.atan2(a,n)-angle,{x:r*Math.cos(i)+newcx,y:r*Math.sin(i)+newcy}},recalcRotatedPath=function(){var e=path.elem;if(angle=getRotationAngle(e,!0)){var t=path.oldbbox;oldcx=t.x+t.width/2,oldcy=t.y+t.height/2;var n=getBBox(e);newcx=n.x+n.width/2,newcy=n.y+n.height/2;var a=newcx-oldcx,r=newcy-oldcy,i=Math.sqrt(a*a+r*r),o=Math.atan2(r,a)+angle;newcx=i*Math.cos(o)+oldcx,newcy=i*Math.sin(o)+oldcy;for(var s=e.pathSegList,l=s.numberOfItems;l;){l-=1;var c=s.getItem(l),u=c.pathSegType;if(1!==u){var d=getRotVals(c.x,c.y),h=[d.x,d.y];if(null!=c.x1&&null!=c.x2){var g=getRotVals(c.x1,c.y1),p=getRotVals(c.x2,c.y2);h.splice(h.length,0,g.x,g.y,p.x,p.y)}replacePathSeg(u,l,h)}}getBBox(e);var f=editorContext_.getSVGRoot().createSVGTransform(),m=getTransformList(e);f.setRotate(180*angle/Math.PI,newcx,newcy),m.replaceItem(f,0)}},clearData=function(){pathData={}},reorientGrads=function(e,t){for(var n=getBBox(e),a=0;a<2;a++){var r=0===a?"fill":"stroke",i=e.getAttribute(r);if(i&&i.startsWith("url(")){var o=getRefElem(i);if("linearGradient"===o.tagName){var s=o.getAttribute("x1")||0,l=o.getAttribute("y1")||0,c=o.getAttribute("x2")||1,u=o.getAttribute("y2")||0;s=n.width*s+n.x,l=n.height*l+n.y,c=n.width*c+n.x,u=n.height*u+n.y;var d=transformPoint(s,l,t),h=transformPoint(c,u,t),g={};g.x1=(d.x-n.x)/n.width,g.y1=(d.y-n.y)/n.height,g.x2=(h.x-n.x)/n.width,g.y2=(h.y-n.y)/n.height;var p=o.cloneNode(!0);$$1(p).attr(g),p.id=editorContext_.getNextId(),findDefs().append(p),e.setAttribute(r,"url(#"+p.id+")")}}}},pathMap=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],convertPath=function(e,t){for(var n=e.pathSegList,a=n.numberOfItems,r=0,i=0,o="",s=null,l=0;l=k-S&&m<=k+S&&v>=A-S&&v<=A+S){w=!0;break}}o=editorContext_.getId(),removePath_(o);var E,P,T=getElem(o),G=x.numberOfItems;if(w){if(C<=1&&G>=2){var N=x.getItem(0).x,L=x.getItem(0).y;E=4===(P=_.pathSegList.getItem(1)).pathSegType?y.createSVGPathSegLinetoAbs(N,L):y.createSVGPathSegCurvetoCubicAbs(N,L,P.x1/f,P.y1/f,N,L);var I=y.createSVGPathSegClosePath();x.appendItem(E),x.appendItem(I)}else if(G<3)return!1;if($$1(_).remove(),editorContext_.setDrawnPath(null),editorContext_.setStarted(!1),n){path.matrix&&editorContext_.remapElement(T,{},path.matrix.inverse());var M=T.getAttribute("d"),R=$$1(path.elem).attr("d");return $$1(path.elem).attr("d",R+M),$$1(T).remove(),path.matrix&&recalcRotatedPath(),init$1(),pathActions.toEditMode(path.elem),path.selectPt(),!1}}else{if(!$$1.contains(editorContext_.getContainer(),editorContext_.getMouseTarget(t)))return console.log("Clicked outside canvas"),!1;var O=y.pathSegList.numberOfItems,B=y.pathSegList.getItem(O-1),V=B.x,j=B.y;if(t.shiftKey){var D=snapToAngle(V,j,m,v);m=D.x,v=D.y}E=4===(P=_.pathSegList.getItem(1)).pathSegType?y.createSVGPathSegLinetoAbs(editorContext_.round(m),editorContext_.round(v)):y.createSVGPathSegCurvetoCubicAbs(editorContext_.round(m),editorContext_.round(v),P.x1/f,P.y1/f,P.x2/f,P.y2/f),y.pathSegList.appendItem(E),m*=f,v*=f,_.setAttribute("d",["M",m,v,m,v].join(" ")),b=O,n&&(b+=path.segs.length),addPointGrip(b,m,v)}}else{var F="M"+m+","+v+" ";editorContext_.setDrawnPath(editorContext_.addSVGElementFromJson({element:"path",curStyles:!0,attr:{d:F,id:editorContext_.getNextId(),opacity:editorContext_.getOpacity()/2}})),_.setAttribute("d",["M",g,p,g,p].join(" ")),b=n?path.segs.length:0,addPointGrip(b,g,p)}}},mouseMove:function(n,a){var i=editorContext_.getCurrentZoom();r=!0;var o=editorContext_.getDrawnPath();if("path"!==editorContext_.getCurrentMode())if(path.dragging){var s=getPointFromGrip({x:path.dragging[0],y:path.dragging[1]},path),l=getPointFromGrip({x:n,y:a},path),c=l.x-s.x,u=l.y-s.y;path.dragging=[n,a],path.dragctrl?path.moveCtrl(c,u):path.movePts(c,u)}else path.selected_pts=[],path.eachSeg(function(e){if(this.next||this.prev){var t=editorContext_.getRubberBox().getBBox(),n=getGripPt(this),a={x:n.x,y:n.y,width:0,height:0},r=rectsIntersect(t,a);this.select(r),r&&path.selected_pts.push(this.index)}});else{if(!o)return;var d=o.pathSegList,h=d.numberOfItems-1;if(e){var g=addCtrlGrip("1c1"),p=addCtrlGrip("0c2");g.setAttribute("cx",n),g.setAttribute("cy",a),g.setAttribute("display","inline");var f=e[0],m=e[1],v=f+(f-n/i),_=m+(m-a/i);p.setAttribute("cx",v*i),p.setAttribute("cy",_*i),p.setAttribute("display","inline");var b=getCtrlLine(1);if(assignAttributes(b,{x1:n,y1:a,x2:v*i,y2:_*i,display:"inline"}),0===h)t=[n,a];else{var y=d.getItem(h-1),x=y.x,C=y.y;6===y.pathSegType?(x+=x-y.x2,C+=C-y.y2):t&&(x=t[0]/i,C=t[1]/i),replacePathSeg(6,h,[f,m,x,C,v,_],o)}}else{var S=getElem("path_stretch_line");if(S){var w=d.getItem(h);if(6===w.pathSegType){var $=w.x+(w.x-w.x2),k=w.y+(w.y-w.y2);replacePathSeg(6,1,[n,a,$*i,k*i,n,a],S)}else t?replacePathSeg(6,1,[n,a,t[0],t[1],n,a],S):replacePathSeg(4,1,[n,a],S)}}}},mouseUp:function(n,a,i,o){var s=editorContext_.getDrawnPath();if("path"===editorContext_.getCurrentMode())return e=null,s||(a=getElem(editorContext_.getId()),editorContext_.setStarted(!1),t=null),{keep:!0,element:a};var l=editorContext_.getRubberBox();if(path.dragging){var c=path.cur_pt;path.dragging=!1,path.dragctrl=!1,path.update(),r&&path.endChanges("Move path point(s)"),n.shiftKey||r||path.selectPt(c)}else l&&"none"!==l.getAttribute("display")?(l.setAttribute("display","none"),l.getAttribute("width")<=2&&l.getAttribute("height")<=2&&pathActions.toSelectMode(n.target)):pathActions.toSelectMode(n.target);r=!1},toEditMode:function(e){path=getPath_(e),editorContext_.setCurrentMode("pathedit"),editorContext_.clearSelection(),path.show(!0).update(),path.oldbbox=getBBox(path.elem),n=!1},toSelectMode:function(e){var t=e===path.elem;editorContext_.setCurrentMode("select"),path.show(!1),a=!1,editorContext_.clearSelection(),path.matrix&&recalcRotatedPath(),t&&(editorContext_.call("selected",[e]),editorContext_.addToSelection([e],!0))},addSubPath:function(e){e?(editorContext_.setCurrentMode("path"),n=!0):(pathActions.clear(!0),pathActions.toEditMode(path.elem))},select:function(e){a===e?(pathActions.toEditMode(e),editorContext_.setCurrentMode("pathedit")):a=e},reorient:function(){var e=editorContext_.getSelectedElements()[0];if(e&&0!==getRotationAngle(e)){var t=new BatchCommand("Reorient path"),n={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new ChangeElementCommand(e,n)),editorContext_.clearSelection(),this.resetOrientation(e),editorContext_.addCommandToHistory(t),getPath_(e).show(!1).matrix=null,this.clear(),editorContext_.addToSelection([e],!0),editorContext_.call("changed",editorContext_.getSelectedElements())}},clear:function(e){var n=editorContext_.getDrawnPath();if(a=null,n){var r=getElem(editorContext_.getId());$$1(getElem("path_stretch_line")).remove(),$$1(r).remove(),$$1(getElem("pathpointgrip_container")).find("*").attr("display","none"),t=null,editorContext_.setDrawnPath(null),editorContext_.setStarted(!1)}else"pathedit"===editorContext_.getCurrentMode()&&this.toSelectMode();path&&path.init().show(!1)},resetOrientation:function(e){if(null==e||"path"!==e.nodeName)return!1;var t=getTransformList(e),n=transformListToTransform(t).matrix;t.clear(),e.removeAttribute("transform");for(var a=e.pathSegList,r=a.numberOfItems,i=function(t){var r=a.getItem(t),i=r.pathSegType;if(1===i)return"continue";var o=[];$$1.each(["",1,2],function(e,t){var a=r["x"+t],i=r["y"+t];if(void 0!==a&&void 0!==i){var s=transformPoint(a,i,n);o.splice(o.length,0,s.x,s.y)}}),replacePathSeg(i,t,o,e)},o=0;o0){var s=t.getItem(n-1).pathSegType;if(2===s){a(n-1,1),e();break}if(1===s&&t.numberOfItems-1===n){a(n,1),e();break}}}return!1}(),path.elem.pathSegList.numberOfItems<=1)return pathActions.toSelectMode(path.elem),void editorContext_.canvas.deleteSelectedElements();if(path.init(),path.clearSelection(),window.opera){var a=$$1(path.elem);a.attr("d",a.attr("d"))}path.endChanges("Delete path node(s)")}},smoothPolylineIntoPath:function(e){var t,n=e.points,a=n.numberOfItems;if(a>=4){var r=n.getItem(0),i=null,o=[];for(o.push(["M",r.x,",",r.y," C"].join("")),t=1;t<=a-4;t+=3){var s=n.getItem(t),l=n.getItem(t+1),c=n.getItem(t+2);if(i){var u=smoothControlPoints(i,s,r);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(",")),r=c,i=l}for(o.push("L");t)/,"$1$2")},toXml=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")},encode64=function(e){if(e=encodeUTF8(e),window.btoa)return window.btoa(e);var t=[];t.length=4*Math.floor((e.length+2)/3);var n=0,a=0;do{var r=e.charCodeAt(n++),i=e.charCodeAt(n++),o=e.charCodeAt(n++),s=r>>2,l=(3&r)<<4|i>>4,c=(15&i)<<2|o>>6,u=63&o;isNaN(i)?c=u=64:isNaN(o)&&(u=64),t[a++]=KEYSTR.charAt(s),t[a++]=KEYSTR.charAt(l),t[a++]=KEYSTR.charAt(c),t[a++]=KEYSTR.charAt(u)}while(n>4,l=(15&r)<<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 createObjectURL(e)}(),text2xml=function(e){var t,n;e.includes("0?t=t[0]:(t=e.ownerDocument.createElementNS(NS.SVG,"defs"),e.firstChild?e.insertBefore(t,e.firstChild.nextSibling):e.append(t)),t},getPathBBox=function(e){for(var t=e.pathSegList,n=t.numberOfItems,a=[[],[]],r=t.getItem(0),i=[r.x,r.y],o=0;o0&&u<1&&a[r].push(o(u)),"continue"}var d=Math.pow(s,2)-4*c*l;if(d<0)return"continue";var h=(-s+Math.sqrt(d))/(2*l);h>0&&h<1&&a[r].push(o(h));var g=(-s-Math.sqrt(d))/(2*l);g>0&&g<1&&a[r].push(o(g))},o=0;o<2;o++)r(o);i=n}():(a[0].push(s.x),a[1].push(s.y)))}var l=Math.min.apply(null,a[0]),c=Math.max.apply(null,a[0])-l,u=Math.min.apply(null,a[1]);return{x:l,y:u,width:c,height:Math.max.apply(null,a[1])-u}};function groupBBFix(e){if(supportsHVLineContainerBBox())try{return e.getBBox()}catch(e){}var t,n,a=$$2.data(e,"ref"),r=null;a?(n=$$2(a).children().clone().attr("visibility","hidden"),$$2(svgroot_).append(n),r=n.filter("line, path")):r=$$2(e).find("line, path");var i=!1;if(r.length)if(r.each(function(){var e=this.getBBox();e.width&&e.height||(i=!0)}),i){var o=a?n:$$2(e).children();t=getStrokedBBox(o)}else t=e.getBBox();else t=e.getBBox();return a&&n.remove(),t}var getBBox=function(e){var t=e||editorContext_$1.geSelectedElements()[0];if(1!==e.nodeType)return null;var n=t.nodeName,a=null;switch(n){case"text":""===t.textContent?(t.textContent="a",a=t.getBBox(),t.textContent=""):t.getBBox&&(a=t.getBBox());break;case"path":supportsPathBBox()?t.getBBox&&(a=t.getBBox()):a=getPathBBox(t);break;case"g":case"a":a=groupBBFix(t);break;default:if("use"===n&&(a=groupBBFix(t)),"use"===n||"foreignObject"===n&&isWebkit()){if(a||(a=t.getBBox()),!isWebkit()){var r={};r.width=a.width,r.height=a.height,r.x=a.x+parseFloat(t.getAttribute("x")||0),r.y=a.y+parseFloat(t.getAttribute("y")||0),a=r}}else if(visElemsArr.includes(n))if(t)try{a=t.getBBox()}catch(e){var i=t.getExtentOfChar(0),o=t.getComputedTextLength();a={x:i.x,y:i.y,width:o,height:i.height}}else{var s=$$2(t).closest("foreignObject");s.length&&s[0].getBBox&&(a=s[0].getBBox())}}return a&&(a=bboxToObj(a)),a},getPathDFromSegments=function(e){var t="";return $$2.each(e,function(e,n){var a=_slicedToArray(n,2),r=a[0],i=a[1];t+=r;for(var o=0;o-.001&&n<.001||(n<-89.99||n>89.99))}var getBBoxWithTransform=function(e,t,n){var a=getBBox(e);if(!a)return null;var r=getTransformList(e),i=getRotationAngleFromTransformList(r),o=hasMatrixTransform(r);if(i||o){var s=!1;if(bBoxCanBeOptimizedOverNativeGetBBox(i,o)){if(["ellipse","path","line","polyline","polygon"].includes(e.tagName))a=s=getBBoxOfElementAsPath(e,t,n);else if("rect"===e.tagName){var l=e.getAttribute("rx"),c=e.getAttribute("ry");(l||c)&&(a=s=getBBoxOfElementAsPath(e,t,n))}}if(!s){var u=transformListToTransform(r).matrix;a=transformBox(a.x,a.y,a.width,a.height,u).aabox}}return a};function getStrokeOffsetForBBox(e){var t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}var getStrokedBBox=function(e,t,n){if(!e||!e.length)return!1;var a;if($$2.each(e,function(){a||this.parentNode&&(a=getBBoxWithTransform(this,t,n))}),void 0===a)return null;var r=a.x+a.width,i=a.y+a.height,o=a.x,s=a.y;if(1===e.length){var l=getStrokeOffsetForBBox(e[0]);o-=l,s-=l,r+=l,i+=l}else $$2.each(e,function(e,a){var l=getBBoxWithTransform(a,t,n);if(l){var c=getStrokeOffsetForBBox(a);o=Math.min(o,l.x-c),s=Math.min(s,l.y-c),1===a.nodeType&&(r=Math.max(r,l.x+l.width+c),i=Math.max(i,l.y+l.height+c))}});return a.x=o,a.y=s,a.width=r-o,a.height=i-s,a},getVisibleElements=function(e){e||(e=$$2(editorContext_$1.getSVGContent()).children());var t=[];return $$2(e).children().each(function(e,n){n.getBBox&&t.push(n)}),t.reverse()},getStrokedBBoxDefaultVisible=function(e){return e||(e=getVisibleElements()),getStrokedBBox(e,editorContext_$1.addSVGElementFromJson,editorContext_$1.pathActions)},getRotationAngleFromTransformList=function(e,t){if(!e)return 0;for(var n=e.numberOfItems,a=0;a|:\\-]","g"),"\\$&")},preventClickDefault=function(e){$$2(e).click(function(e){e.preventDefault()})},copyElem=function e(t,n){var a=document.createElementNS(t.namespaceURI,t.nodeName);if($$2.each(t.attributes,function(e,t){"-moz-math-font-style"!==t.localName&&a.setAttributeNS(t.namespaceURI,t.nodeName,t.value)}),a.removeAttribute("id"),a.id=n(),isWebkit()&&"path"===t.nodeName){var r=convertPath(t);a.setAttribute("d",r)}if($$2.each(t.childNodes,function(t,r){switch(r.nodeType){case 1:a.append(e(r,n));break;case 3:a.textContent=r.nodeValue}}),$$2(t).data("gsvg"))$$2(a).data("gsvg",a.firstChild);else if($$2(t).data("symbol")){var i=$$2(t).data("symbol");$$2(a).data("ref",i).data("symbol",i)}else"image"===a.tagName&&preventClickDefault(a);return a},$$3=jQuery,contextMenuExtensions={},hasCustomHandler=function(e){return Boolean(contextMenuExtensions[e])},getCustomHandler=function(e){return contextMenuExtensions[e].action},injectExtendedContextMenuItemIntoDom=function(e){Object.keys(contextMenuExtensions).length||$$3("#cmenu_canvas").append("
    • ");var t=e.shortcut||"";$$3("#cmenu_canvas").append("
    • "+e.label+""+t+"
    • ")},injectExtendedContextMenuItemsIntoDom=function(){for(var e in contextMenuExtensions)injectExtendedContextMenuItemIntoDom(contextMenuExtensions[e])};function toAbsoluteURL(e){var t=document.createElement("a");return t.setAttribute("href",e),t.cloneNode(!1).href}function addScriptAtts(e,t){["id","class","type"].forEach(function(n){n in t&&(e[n]=t[n])})}function importSetGlobalDefault(e,t){return _importSetGlobalDefault.apply(this,arguments)}function _importSetGlobalDefault(){return(_importSetGlobalDefault=_asyncToGenerator(regeneratorRuntime.mark(function e(t,n){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",importSetGlobal(t,_extends({},n,{returnDefault:!0})));case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function importSetGlobal(e,t){return _importSetGlobal.apply(this,arguments)}function _importSetGlobal(){return(_importSetGlobal=_asyncToGenerator(regeneratorRuntime.mark(function e(t,n){var a,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n.global,r=n.returnDefault,!!("svgEditor"in window&&window.svgEditor&&!1===window.svgEditor.modules)){e.next=4;break}return e.abrupt("return",importModule(t,void 0,{returnDefault:r}));case 4:return e.next=6,importScript(t);case 6:return e.abrupt("return",window[a]);case 7:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function importScript(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Array.isArray(e)?Promise.all(e.map(function(e){return importScript(e,t)})):new Promise(function(n,a){var r=document.createElement("script"),i=function(){r.onerror=null,r.onload=null,r.remove(),r.src=""};r.defer="defer",addScriptAtts(r,t),r.onerror=function(){a(new Error("Failed to import: ".concat(e))),i()},r.onload=function(){n(),i()},r.src=e,document.head.append(r)})}function importModule(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).returnDefault,a=void 0!==n&&n;return Array.isArray(e)?Promise.all(e.map(function(e){return importModule(e,t)})):new Promise(function(n,r){var i="$importModule$"+Math.random().toString(32).slice(2),o=document.createElement("script"),s=function(){delete window[i],o.onerror=null,o.onload=null,o.remove(),URL.revokeObjectURL(o.src),o.src=""};addScriptAtts(o,t),o.defer="defer",o.type="module",o.onerror=function(){r(new Error("Failed to import: ".concat(e))),s()},o.onload=function(){n(window[i]),s()};var l=toAbsoluteURL(e),c="import * as m from '".concat(l.replace(/'/g,"\\'"),"'; window.").concat(i," = ").concat(a?"m.default || ":"","m;"),u=new Blob([c],{type:"text/javascript"});o.src=URL.createObjectURL(u),document.head.append(o)})}var $$4=jQuery,Layer=function(){function e(t,n,a){if(_classCallCheck(this,e),this.name_=t,this.group_=a?null:n,a){var r=a.ownerDocument;this.group_=r.createElementNS(NS.SVG,"g");var i=r.createElementNS(NS.SVG,"title");i.textContent=t,this.group_.append(i),n?$$4(n).after(this.group_):a.append(this.group_)}addLayerClass(this.group_),walkTree(this.group_,function(e){e.setAttribute("style","pointer-events:inherit")}),this.group_.setAttribute("style",a?"pointer-events:all":"pointer-events:none")}return _createClass(e,[{key:"getName",value:function(){return this.name_}},{key:"getGroup",value:function(){return this.group_}},{key:"activate",value:function(){this.group_.setAttribute("style","pointer-events:all")}},{key:"deactivate",value:function(){this.group_.setAttribute("style","pointer-events:none")}},{key:"setVisible",value:function(e){var t=void 0===e||e?"inline":"none";this.group_.getAttribute("display")!==t&&this.group_.setAttribute("display",t)}},{key:"isVisible",value:function(){return"none"!==this.group_.getAttribute("display")}},{key:"getOpacity",value:function(){var e=this.group_.getAttribute("opacity");return null==e?1:parseFloat(e)}},{key:"setOpacity",value:function(e){"number"==typeof e&&e>=0&&e<=1&&this.group_.setAttribute("opacity",e)}},{key:"appendChildren",value:function(e){for(var t=0;t element");this.svgElem_=t,this.obj_num=0,this.idPrefix=n||"svg_",this.releasedNums=[],this.all_layers=[],this.layer_map={},this.current_layer=null,this.nonce_="";var a=this.svgElem_.getAttributeNS(NS.SE,"nonce");a&&randIds!==RandomizeModes.NEVER_RANDOMIZE?this.nonce_=a:randIds===RandomizeModes.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(100001*Math.random()))}return _createClass(e,[{key:"getElem_",value:function(e){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+e):$$5(this.svgElem_).find("[id="+e+"]")[0]}},{key:"getSvgElem",value:function(){return this.svgElem_}},{key:"getNonce",value:function(){return this.nonce_}},{key:"setNonce",value:function(e){this.svgElem_.setAttributeNS(NS.XMLNS,"xmlns:se",NS.SE),this.svgElem_.setAttributeNS(NS.SE,"se:nonce",e),this.nonce_=e}},{key:"clearNonce",value:function(){this.nonce_=""}},{key:"getId",value:function(){return this.nonce_?this.idPrefix+this.nonce_+"_"+this.obj_num:this.idPrefix+this.obj_num}},{key:"getNextId",value:function(){var e=this.obj_num,t=!1;this.releasedNums.length>0?(this.obj_num=this.releasedNums.pop(),t=!0):this.obj_num++;for(var n=this.getId();this.getElem_(n);)t&&(this.obj_num=e,t=!1),this.obj_num++,n=this.getId();return t&&(this.obj_num=e),n}},{key:"releaseId",value:function(e){var t=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if("string"!=typeof e||!e.startsWith(t))return!1;var n=parseInt(e.substr(t.length),10);return!("number"!=typeof n||n<=0||this.releasedNums.includes(n))&&(this.releasedNums.push(n),!0)}},{key:"getNumLayers",value:function(){return this.all_layers.length}},{key:"hasLayer",value:function(e){return void 0!==this.layer_map[e]}},{key:"getLayerName",value:function(e){return e>=0&&e=n)return null;for(t=0;tt?e0){var s=this.current_layer.getName();this.current_layer=this.all_layers[o-1],this.all_layers.splice(o,1),delete this.layer_map[s]}e.endBatchCommand()}}},{key:"mergeAllLayers",value:function(e){for(this.current_layer=this.all_layers[this.all_layers.length-1],e.startBatchCommand("Merge all Layers");this.all_layers.length>1;)this.mergeLayer(e);e.endBatchCommand()}},{key:"setCurrentLayer",value:function(e){var t=this.layer_map[e];return!!t&&(this.current_layer&&this.current_layer.deactivate(),this.current_layer=t,this.current_layer.activate(),!0)}},{key:"deleteCurrentLayer",value:function(){if(this.current_layer&&this.getNumLayers()>1){var e=this.current_layer.removeGroup();return this.identifyLayers(),e}return null}},{key:"identifyLayers",value:function(){this.all_layers=[],this.layer_map={};for(var e=this.svgElem_.childNodes.length,t=[],n=[],a=null,r=!1,i=0;i0||!r?((a=new Layer(getNewLayerName(n),null,this.svgElem_)).appendChildren(t),this.all_layers.push(a),this.layer_map[name]=a):a.activate(),this.current_layer=a}},{key:"createLayer",value:function(e,t){this.current_layer&&this.current_layer.deactivate(),(null==e||""===e||this.layer_map[e])&&(e=getNewLayerName(Object.keys(this.layer_map)));var n=new Layer(e,null,this.svgElem_);return t&&(t.startBatchCommand("Create Layer"),t.insertElement(n.getGroup()),t.endBatchCommand()),this.all_layers.push(n),this.layer_map[e]=n,this.current_layer=n,n.getGroup()}},{key:"cloneLayer",value:function(e,t){if(!this.current_layer)return null;this.current_layer.deactivate(),(null==e||""===e||this.layer_map[e])&&(e=getNewLayerName(Object.keys(this.layer_map)));for(var n=this.current_layer.getGroup(),a=new Layer(e,n,this.svgElem_),r=a.getGroup(),i=n.childNodes,o=0;o=0?this.all_layers.splice(l+1,0,a):this.all_layers.push(a),this.layer_map[e]=a,this.current_layer=a,r}},{key:"getLayerVisibility",value:function(e){var t=this.layer_map[e];return!!t&&t.isVisible()}},{key:"setLayerVisibility",value:function(e,t){if("boolean"!=typeof t)return null;var n=this.layer_map[e];return n?(n.setVisible(t),n.getGroup()):null}},{key:"getLayerOpacity",value:function(e){var t=this.layer_map[e];return t?t.getOpacity():null}},{key:"setLayerOpacity",value:function(e,t){if(!("number"!=typeof t||t<0||t>1)){var n=this.layer_map[e];n&&n.setOpacity(t)}}},{key:"copyElem",value:function(e){var t=this;return copyElem(e,function(){return t.getNextId()})}}]),e}(),randomizeIds=function(e,t){(randIds=!1===e?RandomizeModes.NEVER_RANDOMIZE:RandomizeModes.ALWAYS_RANDOMIZE)!==RandomizeModes.ALWAYS_RANDOMIZE||t.getNonce()?randIds===RandomizeModes.NEVER_RANDOMIZE&&t.getNonce()&&t.clearNonce():t.setNonce(Math.floor(100001*Math.random()))},init$3=function(e){canvas_=e},identifyLayers=function(){leaveContext(),canvas_.getCurrentDrawing().identifyLayers()},createLayer=function(e,t){var n=canvas_.getCurrentDrawing().createLayer(e,historyRecordingService(t));canvas_.clearSelection(),canvas_.call("changed",[n])},cloneLayer=function(e,t){var n=canvas_.getCurrentDrawing().cloneLayer(e,historyRecordingService(t));canvas_.clearSelection(),leaveContext(),canvas_.call("changed",[n])},deleteCurrentLayer=function(){var e=canvas_.getCurrentDrawing().getCurrentLayer(),t=e.nextSibling,n=e.parentNode;if(e=canvas_.getCurrentDrawing().deleteCurrentLayer()){var a=new BatchCommand("Delete Layer");return a.addSubCommand(new RemoveElementCommand(e,t,n)),canvas_.addCommandToHistory(a),canvas_.clearSelection(),canvas_.call("changed",[n]),!0}return!1},setCurrentLayer=function(e){var t=canvas_.getCurrentDrawing().setCurrentLayer(toXml(e));return t&&canvas_.clearSelection(),t},renameCurrentLayer=function(e){var t=canvas_.getCurrentDrawing(),n=t.getCurrentLayer();if(n&&t.setCurrentLayerName(e,historyRecordingService()))return canvas_.call("changed",[n]),!0;return!1},setCurrentLayerPosition=function(e){var t=canvas_.getCurrentDrawing().setCurrentLayerPosition(e);return!!t&&(canvas_.addCommandToHistory(new MoveElementCommand(t.currentGroup,t.oldNextSibling,canvas_.getSVGContent())),!0)},setLayerVisibility=function(e,t){var n=canvas_.getCurrentDrawing(),a=n.getLayerVisibility(e),r=n.setLayerVisibility(e,t);if(!r)return!1;var i=a?"inline":"none";return canvas_.addCommandToHistory(new ChangeElementCommand(r,{display:i},"Layer Visibility")),r===n.getCurrentLayer()&&(canvas_.clearSelection(),canvas_.pathActions.clear()),!0},moveSelectedToLayer=function(e){var t=canvas_.getCurrentDrawing().getLayerByName(e);if(!t)return!1;for(var n=new BatchCommand("Move Elements to Layer"),a=canvas_.getSelectedElements(),r=a.length;r--;){var i=a[r];if(i){var o=i.nextSibling,s=i.parentNode;t.append(i),n.addSubCommand(new MoveElementCommand(i,o,s))}}return canvas_.addCommandToHistory(n),!0},mergeLayer=function(e){canvas_.getCurrentDrawing().mergeLayer(historyRecordingService(e)),canvas_.clearSelection(),leaveContext(),canvas_.changeSVGContent()},mergeAllLayers=function(e){canvas_.getCurrentDrawing().mergeAllLayers(historyRecordingService(e)),canvas_.clearSelection(),leaveContext(),canvas_.changeSVGContent()},leaveContext=function(){var e=disabledElems.length;if(e){for(var t=0;t0){for(var r=a.numberOfItems,i=r;r--;){var o=a.getItem(r);if(0===o.type)a.removeItem(r);else if(1===o.type){if(isIdentity(o.matrix)){if(1===i)return t.removeAttribute("transform"),null;a.removeItem(r)}}else 4===o.type&&0===o.angle&&a.removeItem(r)}if(1===a.numberOfItems&&getRotationAngle(t))return null}if(!a||0===a.numberOfItems)return t.setAttribute("transform",""),t.removeAttribute("transform"),null;if(a){for(var s=[],l=a.numberOfItems;l--;){var c=a.getItem(l);1===c.type?s.push([c.matrix,l]):s.length&&(s=[])}if(2===s.length){var u=n.createSVGTransformFromMatrix(matrixMultiply(s[1][0],s[0][0]));a.removeItem(s[0][1]),a.removeItem(s[1][1]),a.insertItemBefore(u,s[1][1])}if((l=a.numberOfItems)>=2&&1===a.getItem(l-2).type&&2===a.getItem(l-1).type){var d=n.createSVGTransform(),h=matrixMultiply(a.getItem(l-2).matrix,a.getItem(l-1).matrix);d.setMatrix(h),a.removeItem(l-2),a.removeItem(l-2),a.appendItem(d)}}switch(t.tagName){case"line":case"polyline":case"polygon":case"path":break;default:if(1===a.numberOfItems&&1===a.getItem(0).type||2===a.numberOfItems&&1===a.getItem(0).type&&4===a.getItem(0).type)return null}var g,p,f=$$7(t).data("gsvg"),m=new BatchCommand("Transform"),v={},_=null,b=[];switch(t.tagName){case"line":b=["x1","y1","x2","y2"];break;case"circle":b=["cx","cy","r"];break;case"ellipse":b=["cx","cy","rx","ry"];break;case"foreignObject":case"rect":case"image":b=["width","height","x","y"];break;case"use":case"text":case"tspan":b=["x","y"];break;case"polygon":case"polyline":(_={}).points=t.getAttribute("points");var y=t.points,x=y.numberOfItems;v.points=new Array(x);for(var C=0;C1e-10?Math.sin(A)/(1-Math.cos(A)):2/A;for(var E=0;E=3&&3===a.getItem(L-2).type&&2===a.getItem(L-3).type&&2===a.getItem(L-1).type){R=3;for(var O=a.getItem(L-3).matrix,B=a.getItem(L-2).matrix,V=a.getItem(L-1).matrix,j=t.childNodes,D=j.length;D--;){var F=j.item(D);if(I=0,M=0,1===F.nodeType){var U=getTransformList(F);if(!U)continue;var H=transformListToTransform(U).matrix,z=getRotationAngle(F);if(N=context_.getStartTransform(),context_.setStartTransform(F.getAttribute("transform")),z||hasMatrixTransform(U)){var q=n.createSVGTransform();q.setMatrix(matrixMultiply(O,B,V,H)),U.clear(),U.appendItem(q)}else{var W=matrixMultiply(H.inverse(),V,H),Y=n.createSVGMatrix();Y.e=-W.e,Y.f=-W.f;var X=matrixMultiply(Y.inverse(),H.inverse(),O,B,V,H,W.inverse()),Q=n.createSVGTransform(),K=n.createSVGTransform(),Z=n.createSVGTransform();Q.setTranslate(W.e,W.f),K.setScale(X.a,X.d),Z.setTranslate(Y.e,Y.f),U.appendItem(Z),U.appendItem(K),U.appendItem(Q)}m.addSubCommand(e(F)),context_.setStartTransform(N)}}a.removeItem(L-1),a.removeItem(L-2),a.removeItem(L-3)}else if(L>=3&&1===a.getItem(L-1).type){R=3;var J=transformListToTransform(a).matrix,ee=n.createSVGTransform();ee.setMatrix(J),a.clear(),a.appendItem(ee)}else if((1===L||L>1&&3!==a.getItem(1).type)&&2===a.getItem(0).type){R=2;var te=transformListToTransform(a).matrix;a.removeItem(0);var ne=transformListToTransform(a).matrix.inverse(),ae=matrixMultiply(ne,te);if(I=ae.e,M=ae.f,0!==I||0!==M){for(var re=t.childNodes,ie=re.length,oe=[];ie--;){var se=re.item(ie);if(1===se.nodeType){if(se.getAttribute("clip-path")){var le=se.getAttribute("clip-path");oe.includes(le)||(updateClipPath(le,I,M),oe.push(le))}N=context_.getStartTransform(),context_.setStartTransform(se.getAttribute("transform"));var ce=getTransformList(se);if(ce){var ue=n.createSVGTransform();ue.setTranslate(I,M),ce.numberOfItems?ce.insertItemBefore(ue,0):ce.appendItem(ue),m.addSubCommand(e(se));for(var de=t.getElementsByTagNameNS(NS.SVG,"use"),he="#"+se.id,ge=de.length;ge--;){var pe=de.item(ge);if(he===getHref(pe)){var fe=n.createSVGTransform();fe.setTranslate(-I,-M),getTransformList(pe).insertItemBefore(fe,0),m.addSubCommand(e(pe))}}context_.setStartTransform(N)}}}context_.setStartTransform(N)}}else{if(1!==L||1!==a.getItem(0).type||$){if($){var me=n.createSVGTransform();me.setRotate($,p.x,p.y),a.numberOfItems?a.insertItemBefore(me,0):a.appendItem(me)}return 0===a.numberOfItems&&t.removeAttribute("transform"),null}R=1;for(var ve=a.getItem(0).matrix,_e=t.childNodes,be=_e.length;be--;){var ye=_e.item(be);if(1===ye.nodeType){N=context_.getStartTransform(),context_.setStartTransform(ye.getAttribute("transform"));var xe=getTransformList(ye);if(!xe)continue;var Ce=matrixMultiply(ve,transformListToTransform(xe).matrix),Se=n.createSVGTransform();Se.setMatrix(Ce),xe.clear(),xe.appendItem(Se,0),m.addSubCommand(e(ye)),context_.setStartTransform(N);var we=ye.getAttribute("stroke-width");if("none"!==ye.getAttribute("stroke")&&!isNaN(we)){var $e=(Math.abs(Ce.a)+Math.abs(Ce.d))/2;ye.setAttribute("stroke-width",we*$e)}}}a.clear()}if(2===R){if($){p={x:g.x+G.e,y:g.y+G.f};var ke=n.createSVGTransform();ke.setRotate($,p.x,p.y),a.numberOfItems?a.insertItemBefore(ke,0):a.appendItem(ke)}}else if(3===R){var Ae=transformListToTransform(a).matrix,Ee=n.createSVGTransform();Ee.setRotate($,g.x,g.y);var Pe=Ee.matrix,Te=n.createSVGTransform();Te.setRotate($,p.x,p.y);var Ge=Te.matrix.inverse(),Ne=Ae.inverse(),Le=matrixMultiply(Ne,Ge,Pe,Ae);if(I=Le.e,M=Le.f,0!==I||0!==M)for(var Ie=t.childNodes,Me=Ie.length;Me--;){var Re=Ie.item(Me);if(1===Re.nodeType){N=context_.getStartTransform(),context_.setStartTransform(Re.getAttribute("transform"));var Oe=getTransformList(Re),Be=n.createSVGTransform();Be.setTranslate(I,M),Oe.numberOfItems?Oe.insertItemBefore(Be,0):Oe.appendItem(Be),m.addSubCommand(e(Re)),context_.setStartTransform(N)}}$&&(a.numberOfItems?a.insertItemBefore(Te,0):a.appendItem(Te))}}else{var Ve,je=getBBox(t);if(!je&&"path"!==t.tagName)return null;var De=getRotationAngle(t);if(De){g={x:je.x+je.width/2,y:je.y+je.height/2},p=transformPoint(je.x+je.width/2,je.y+je.height/2,transformListToTransform(a).matrix);for(var Fe=De*Math.PI/180,Ue=Math.abs(Fe)>1e-10?Math.sin(Fe)/(1-Math.cos(Fe)):2/Fe,He=0;He=3&&3===a.getItem(Ye-2).type&&2===a.getItem(Ye-3).type&&2===a.getItem(Ye-1).type)We=3,Ve=transformListToTransform(a,Ye-3,Ye-1).matrix,a.removeItem(Ye-1),a.removeItem(Ye-2),a.removeItem(Ye-3);else if(4===Ye&&1===a.getItem(Ye-1).type){We=3,Ve=transformListToTransform(a).matrix;var tt=n.createSVGTransform();tt.setMatrix(Ve),a.clear(),a.appendItem(tt),Ve=n.createSVGMatrix()}else if((1===Ye||Ye>1&&3!==a.getItem(1).type)&&2===a.getItem(0).type){We=2;var nt=a.getItem(0).matrix,at=transformListToTransform(a,1).matrix,rt=at.inverse();Ve=matrixMultiply(rt,nt,at),a.removeItem(0)}else{if(1!==Ye||1!==a.getItem(0).type||De){if(De){var it=n.createSVGTransform();it.setRotate(De,p.x,p.y),a.numberOfItems?a.insertItemBefore(it,0):a.appendItem(it)}return 0===a.numberOfItems&&t.removeAttribute("transform"),null}switch(Ve=transformListToTransform(a).matrix,t.tagName){case"line":v=$$7(t).attr(["x1","y1","x2","y2"]);case"polyline":case"polygon":if(v.points=t.getAttribute("points"),v.points){var ot=t.points,st=ot.numberOfItems;v.points=new Array(st);for(var lt=0;lt0;)n.push(n.shift()),a--;var r=0;for(t in selectorManager_.selectorGrips)selectorManager_.selectorGrips[t].setAttribute("style","cursor:"+n[r]+"-resize"),r++}},{key:"showGrips",value:function(e){var t=e?"inline":"none";selectorManager_.selectorGripsGroup.setAttribute("display",t);var n=this.selectedElement;this.hasGrips=e,n&&e&&(this.selectorGroup.append(selectorManager_.selectorGripsGroup),this.updateGripCursors(getRotationAngle(n)))}},{key:"resize",value:function(e){var t=this.selectorRect,n=selectorManager_,a=n.selectorGrips,r=this.selectedElement,i=r.getAttribute("stroke-width"),o=svgFactory_.getCurrentZoom(),s=1/o;"none"===r.getAttribute("stroke")||isNaN(i)||(s+=i/2);var l=r.tagName;"text"===l&&(s+=2/o);var c=getTransformList(r),u=transformListToTransform(c).matrix;if(u.e*=o,u.f*=o,e||(e=getBBox(r)),"g"===l&&!$$8.data(r,"gsvg")){var d=getStrokedBBox([r.childNodes]);d&&(e=d)}var h=e.x,g=e.y,p=e.width,f=e.height;s*=o;var m=transformBox(h*o,g*o,p*o,f*o,u),v=m.aabox,_=v.x-s,b=v.y-s,y=v.width+2*s,x=v.height+2*s,C=_+y/2,S=b+x/2,w=getRotationAngle(r);if(w){var $=svgFactory_.svgRoot().createSVGTransform();$.setRotate(-w,C,S);var k=$.matrix;m.tl=transformPoint(m.tl.x,m.tl.y,k),m.tr=transformPoint(m.tr.x,m.tr.y,k),m.bl=transformPoint(m.bl.x,m.bl.y,k),m.br=transformPoint(m.br.x,m.br.y,k);var A=m.tl,E=A.x,P=A.y,T=A.x,G=A.y,N=Math.min,L=Math.max;_=E=N(E,N(m.tr.x,N(m.bl.x,m.br.x)))-s,b=P=N(P,N(m.tr.y,N(m.bl.y,m.br.y)))-s,y=(T=L(T,L(m.tr.x,L(m.bl.x,m.br.x)))+s)-E,x=(G=L(G,L(m.tr.y,L(m.bl.y,m.br.y)))+s)-P}var I="M"+_+","+b+" L"+(_+y)+","+b+" "+(_+y)+","+(b+x)+" "+_+","+(b+x)+"z";t.setAttribute("d",I);var M=w?"rotate("+[w,C,S].join(",")+")":"";for(var R in this.selectorGroup.setAttribute("transform",M),this.gripCoords={nw:[_,b],ne:[_+y,b],sw:[_,b+x],se:[_+y,b+x],n:[_+y/2,b],w:[_,b+x/2],e:[_+y,b+x/2],s:[_+y/2,b+x]},this.gripCoords){var O=this.gripCoords[R];a[R].setAttribute("cx",O[0]),a[R].setAttribute("cy",O[1])}n.rotateGripConnector.setAttribute("x1",_+y/2),n.rotateGripConnector.setAttribute("y1",b),n.rotateGripConnector.setAttribute("x2",_+y/2),n.rotateGripConnector.setAttribute("y2",b-5*gripRadius),n.rotateGrip.setAttribute("cx",_+y/2),n.rotateGrip.setAttribute("cy",b-5*gripRadius)}}]),e}(),SelectorManager=function(){function e(){_classCallCheck(this,e),this.selectorParentGroup=null,this.rubberBandBox=null,this.selectors=[],this.selectorMap={},this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null},this.selectorGripsGroup=null,this.rotateGripConnector=null,this.rotateGrip=null,this.initGroup()}return _createClass(e,[{key:"initGroup",value:function(){for(var e in this.selectorParentGroup&&this.selectorParentGroup.parentNode&&this.selectorParentGroup.remove(),this.selectorParentGroup=svgFactory_.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}}),this.selectorGripsGroup=svgFactory_.createSVGElement({element:"g",attr:{display:"none"}}),this.selectorParentGroup.append(this.selectorGripsGroup),svgFactory_.svgRoot().append(this.selectorParentGroup),this.selectorMap={},this.selectors=[],this.rubberBandBox=null,this.selectorGrips){var t=svgFactory_.createSVGElement({element:"circle",attr:{id:"selectorGrip_resize_"+e,fill:"#22C",r:gripRadius,style:"cursor:"+e+"-resize","stroke-width":2,"pointer-events":"all"}});$$8.data(t,"dir",e),$$8.data(t,"type","resize"),this.selectorGrips[e]=this.selectorGripsGroup.appendChild(t)}if(this.rotateGripConnector=this.selectorGripsGroup.appendChild(svgFactory_.createSVGElement({element:"line",attr:{id:"selectorGrip_rotateconnector",stroke:"#22C","stroke-width":"1"}})),this.rotateGrip=this.selectorGripsGroup.appendChild(svgFactory_.createSVGElement({element:"circle",attr:{id:"selectorGrip_rotate",fill:"lime",r:gripRadius,stroke:"#22C","stroke-width":2,style:"cursor:url("+config_.imgPath+"rotate.png) 12 12, auto;"}})),$$8.data(this.rotateGrip,"type","rotate"),!$$8("#canvasBackground").length){var n=_slicedToArray(config_.dimensions,2),a=n[0],r=n[1],i=svgFactory_.createSVGElement({element:"svg",attr:{id:"canvasBackground",width:a,height:r,x:0,y:0,overflow:isWebkit()?"none":"visible",style:"pointer-events:none"}}),o=svgFactory_.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,stroke:"#000",fill:"#FFF",style:"pointer-events:none"}});i.append(o),svgFactory_.svgRoot().insertBefore(i,svgFactory_.svgContent())}}},{key:"requestSelector",value:function(e,t){if(null==e)return null;var n=this.selectors.length;if("object"===_typeof(this.selectorMap[e.id]))return this.selectorMap[e.id].locked=!0,this.selectorMap[e.id];for(var a=0;a').documentElement,!0);t.append(s);var l=o.createElementNS(NS.SVG,"svg");(i.clearSvgContentElement=function(){$$9(l).empty(),$$9(l).attr({id:"svgcontent",width:r[0],height:r[1],x:r[0],y:r[1],overflow:a.show_outside_canvas?"visible":"hidden",xmlns:NS.SVG,"xmlns:se":NS.SE,"xmlns:xlink":NS.XLINK}).appendTo(s);var e=o.createComment(" Created with SVG-edit - https://github.com/SVG-Edit/svgedit");l.append(e)})();var c="svg_";i.setIdPrefix=function(e){c=e},i.current_drawing_=new Drawing(l,c);var u=i.getCurrentDrawing=function(){return i.current_drawing_},d=1,h=null,g={shape:{fill:("none"===a.initFill.color?"":"#")+a.initFill.color,fill_paint:null,fill_opacity:a.initFill.opacity,stroke:"#"+a.initStroke.color,stroke_paint:null,stroke_opacity:a.initStroke.opacity,stroke_width:a.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:a.initOpacity}};g.text=$$9.extend(!0,{},g.shape),$$9.extend(g.text,{fill:"#000000",stroke_width:a.text&&a.text.stroke_width,font_size:a.text&&a.text.font_size,font_family:a.text&&a.text.font_family});var p=g.shape,f=[],m=this.getJsonFromSvgElement=function(e){if(3===e.nodeType)return e.nodeValue;for(var t,n={element:e.tagName,attr:{},children:[]},a=0;t=e.attributes[a];a++)n.attr[t.name]=t.value;for(var r,i=0;r=e.childNodes[i];i++)n.children[i]=m(r);return n},v=this.addSVGElementFromJson=function(e){if("string"==typeof e)return o.createTextNode(e);var t=getElem(e.attr.id),n=u().getCurrentLayer();if(t&&e.element!==t.tagName&&(t.remove(),t=null),!t){var a=e.namespace||NS.SVG;t=o.createElementNS(a,e.element),n&&(h||n).append(t)}return e.curStyles&&assignAttributes(t,{fill:p.fill,stroke:p.stroke,"stroke-width":p.stroke_width,"stroke-dasharray":p.stroke_dasharray,"stroke-linejoin":p.stroke_linejoin,"stroke-linecap":p.stroke_linecap,"stroke-opacity":p.stroke_opacity,"fill-opacity":p.fill_opacity,opacity:p.opacity/2,style:"pointer-events:inherit"},100),assignAttributes(t,e.attr,100),cleanupElement(t),e.children&&e.children.forEach(function(e){t.append(v(e))}),t};i.getTransformList=getTransformList,i.matrixMultiply=matrixMultiply,i.hasMatrixTransform=hasMatrixTransform,i.transformListToTransform=transformListToTransform;var _=function(){return a.baseUnit};init({getBaseUnit:_,getElement:getElem,getHeight:function(){return l.getAttribute("height")/d},getWidth:function(){return l.getAttribute("width")/d},getRoundDigits:function(){return H.round_digits}}),i.convertToNum=convertToNum;var b=function(){return l},y=this.getSelectedElems=function(){return f},x=pathActions,C=function(){return s};init$2({pathActions:x,getSVGContent:b,addSVGElementFromJson:v,getSelectedElements:y,getDOMDocument:function(){return o},getDOMContainer:function(){return t},getSVGRoot:C,getBaseUnit:_,getSnappingStep:function(){return a.snappingStep}}),i.findDefs=findDefs,i.getUrlFromAttr=getUrlFromAttr,i.getHref=getHref,i.setHref=setHref,i.getBBox=getBBox,i.getRotationAngle=getRotationAngle,i.getElem=getElem,i.getRefElem=getRefElem,i.assignAttributes=assignAttributes,this.cleanupElement=cleanupElement;var S=function(){return a.gridSnapping};init$4({getDrawing:function(){return u()},getSVGRoot:C,getGridSnapping:S}),this.remapElement=remapElement,init$5({getSVGRoot:C,getStartTransform:function(){return K},setStartTransform:function(e){K=e}}),this.recalculateDimensions=recalculateDimensions;var w=getReverseNS();i.sanitizeSvg=sanitizeSvg;var $=i.undoMgr=new UndoManager$1({handleHistoryEvent:function(e,t){var n=HistoryEventTypes$1;if(e===n.BEFORE_UNAPPLY||e===n.BEFORE_APPLY)i.clearSelection();else if(e===n.AFTER_APPLY||e===n.AFTER_UNAPPLY){var a=t.elements();i.pathActions.clear(),N("changed",a);var r=t.type(),o=e===n.AFTER_APPLY;if(r===MoveElementCommand$1.type())(o?t.newParent:t.oldParent)===l&&identifyLayers();else if(r===InsertElementCommand$1.type()||r===RemoveElementCommand$1.type())t.parent===l&&identifyLayers(),r===InsertElementCommand$1.type()?o&&F(t.elem):o||F(t.elem),"use"===t.elem.tagName&&Re(t.elem);else if(r===ChangeElementCommand$1.type()){"title"===t.elem.tagName&&t.elem.parentNode.parentNode===l&&identifyLayers();var s=o?t.newValues:t.oldValues;s.stdDeviation&&i.setBlurOffsets(t.elem.parentNode,s.stdDeviation)}}}}),k=function(e){i.undoMgr.addCommandToHistory(e)},A=this.getZoom=function(){return d},E=this.round=function(e){return parseInt(e*d,10)/d};init$6(a,{createSVGElement:function(e){return i.addSVGElementFromJson(e)},svgRoot:function(){return s},svgContent:function(){return l},getCurrentZoom:A});var P=this.selectorManager=getSelectorManager(),T=i.getNextId=function(){return u().getNextId()},G=i.getId=function(){return u().getId()},N=function(e,t){if(ce[e])return ce[e](window,t)},L=this.clearSelection=function(e){f.forEach(function(e){null!=e&&P.releaseSelector(e)}),f=[],e||N("selected",f)},I=this.addToSelection=function(e,t){if(e.length){for(var n=0;n1&&o.showGrips(!1)}}}for(N("selected",f),t||1===f.length?P.requestSelector(f[0]).showGrips(!0):P.requestSelector(f[0]).showGrips(!1),f.sort(function(e,t){return e&&t&&e.compareDocumentPosition?3-(6&t.compareDocumentPosition(e)):null==e?1:void 0});null==f[0];)f.shift(0)}},M=function(){return p.opacity},R=this.getMouseTarget=function(e){if(null==e)return null;var n=e.target;if(n.correspondingUseElement&&(n=n.correspondingUseElement),[NS.MATH,NS.HTML].includes(n.namespaceURI)&&"svgcanvas"!==n.id)for(;"foreignObject"!==n.nodeName;)if(!(n=n.parentNode))return s;var a=u().getCurrentLayer();if([s,t,l,a].includes(n))return s;if($$9(n).closest("#selectorParentGroup").length)return P.selectorParentGroup;for(;n.parentNode!==(h||a);)n=n.parentNode;return n};i.pathActions=x,init$1({selectorManager:P,canvas:i,call:N,resetD:function(e){e.setAttribute("d",x.convertPath(e))},round:E,clearSelection:L,addToSelection:I,addCommandToHistory:k,remapElement:remapElement,addSVGElementFromJson:v,getGridSnapping:S,getOpacity:M,getSelectedElements:y,getContainer:function(){return t},setStarted:function(e){Q=e},getRubberBox:function(){return ne},setRubberBox:function(e){return ne=e},addPtsToSelection:function(e){var t=e.closedSubpath,n=e.grips;x.canDeleteNodes=!0,x.closed_subpath=t,N("pointsAdded",{closedSubpath:t,grips:n}),N("selected",n)},endChanges:function(e){var t=e.cmd,n=e.elem;k(t),N("changed",[n])},getCurrentZoom:A,getId:G,getNextId:T,getMouseTarget:R,getCurrentMode:function(){return Z},setCurrentMode:function(e){return Z=e},getDrawnPath:function(){return Te},setDrawnPath:function(e){return Te=e},getSVGRoot:C});var O={},B="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use",V=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],j=$$9.data,D=document.createElementNS(NS.SVG,"animate");$$9(D).attr({attributeName:"opacity",begin:"indefinite",dur:1,fill:"freeze"}).appendTo(s);var F=function e(t){var n=$$9(t).attr(V);for(var a in n){var r=n[a];if(r&&r.startsWith("url(")){var i=getUrlFromAttr(r).substr(1);getElem(i)||(findDefs().append(Y[i]),delete Y[i])}}var o=t.getElementsByTagName("*");if(o.length)for(var s=0,l=o.length;s0&&(4===l.getItem(0).type&&l.removeItem(0));if(0!==e){var c=transformPoint(i,o,transformListToTransform(l).matrix),u=s.createSVGTransform();u.setRotate(e,c.x,c.y),l.numberOfItems?l.insertItemBefore(u,0):l.appendItem(u)}else 0===l.numberOfItems&&n.removeAttribute("transform");if(!t){var d=n.getAttribute("transform");n.setAttribute("transform",a),He("transform",d,f),N("changed",f)}var h=P.requestSelector(f[0]);h.resize(),h.updateGripCursors(e)};var de=this.recalculateAllSelectedDimensions=function(){for(var e=new BatchCommand$1("none"===J?"position":"size"),t=f.length;t--;){var n=f[t],a=recalculateDimensions(n);a&&e.addSubCommand(a)}e.isEmpty()||(k(e),N("changed",f))},he=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},ge=null,pe=this.selectOnly=function(e,t){L(!0),I(e,t)};this.removeFromSelection=function(e){if(null!=f[0]&&e.length){for(var t=[],n=f.length,a=0;a0&&i.removeFromSelection(E),T.length>0&&i.addToSelection(T);break;case"resize":m=getTransformList(v);var R=hasMatrixTransform(m),O=(p=R?xe:getBBox(v)).x,B=p.y,V=p,j=V.width,D=V.height;if(c=w-ve,u=k-_e,a.gridSnapping&&(c=snapToGrid(c),u=snapToGrid(u),D=snapToGrid(D),j=snapToGrid(j)),g=getRotationAngle(v)){var F=Math.sqrt(c*c+u*u),U=Math.atan2(u,c)-g*Math.PI/180;c=F*Math.cos(U),u=F*Math.sin(U)}J.includes("n")||J.includes("s")||(u=0),J.includes("e")||J.includes("w")||(c=0);var H=0,z=0,q=D?(D+u)/D:1,W=j?(j+c)/j:1;J.includes("n")&&(q=D?(D-u)/D:1,z=D),J.includes("w")&&(W=j?(j-c)/j:1,H=j);var Y=s.createSVGTransform(),X=s.createSVGTransform(),K=s.createSVGTransform();if(a.gridSnapping&&(O=snapToGrid(O),H=snapToGrid(H),B=snapToGrid(B),z=snapToGrid(z)),Y.setTranslate(-(O+H),-(B+z)),e.shiftKey&&(1===W?W=q:q=W),X.setScale(W,q),K.setTranslate(O+H,B+z),R){var ee=g?1:0;m.replaceItem(Y,2+ee),m.replaceItem(X,1+ee),m.replaceItem(K,Number(ee))}else{var te=m.numberOfItems;m.replaceItem(K,te-3),m.replaceItem(X,te-2),m.replaceItem(Y,te-1)}P.requestSelector(v).resize(),N("transition",f);break;case"zoom":S*=d,$*=d,assignAttributes(ne,{x:Math.min(be*d,S),y:Math.min(ye*d,$),width:Math.abs(S-be*d),height:Math.abs($-ye*d)},100);break;case"text":assignAttributes(C,{x:w,y:k},1e3);break;case"line":a.gridSnapping&&(w=snapToGrid(w),k=snapToGrid(k));var ae=w,re=k;e.shiftKey&&(ae=(n=snapToAngle(ve,_e,ae,re)).x,re=n.y),C.setAttributeNS(null,"x2",ae),C.setAttributeNS(null,"y2",re);break;case"foreignObject":case"square":case"rect":case"image":var se,le,ce="square"===Z||e.shiftKey,ue=Math.abs(w-ve),de=Math.abs(k-_e);ce?(ue=de=Math.max(ue,de),se=ve.8){Ce-=.8;var Le=l.createSVGPoint();Le.x=Ae.x,Le.y=Ae.y,C.points.appendItem(Le)}Se={x:we.x,y:we.y},we={x:$e.x,y:$e.y},$e={x:ke.x,y:ke.y};break;case"path":case"pathedit":if(w*=d,k*=d,a.gridSnapping&&(w=snapToGrid(w),k=snapToGrid(k),ve=snapToGrid(ve),_e=snapToGrid(_e)),e.shiftKey){var Ie,Me,Re=path;Re?(Ie=Re.dragging?Re.dragging[0]:ve,Me=Re.dragging?Re.dragging[1]:_e):(Ie=ve,Me=_e);var Oe=n=snapToAngle(Ie,Me,w,k);w=Oe.x,k=Oe.y}ne&&"none"!==ne.getAttribute("display")&&(S*=d,$*=d,assignAttributes(ne,{x:Math.min(be*d,S),y:Math.min(ye*d,$),width:Math.abs(S-be*d),height:Math.abs($-ye*d)},100)),x.mouseMove(w,k);break;case"textedit":w*=d,k*=d,Ne.mouseMove(b,y);break;case"rotate":r=(p=getBBox(v)).x+p.width/2,o=p.y+p.height/2;var Be=getMatrix(v),Ve=transformPoint(r,o,Be);r=Ve.x,o=Ve.y,g=(Math.atan2(o-k,r-w)*(180/Math.PI)-90)%360,a.gridSnapping&&(g=snapToGrid(g)),e.shiftKey&&(g=45*Math.round(g/45)),i.setRotationAngle(g<-180?360+g:g,!0),N("transition",f)}ie("mouseMove",{event:e,mouse_x:b,mouse_y:y,selected:v})}}).click(function(e){return e.preventDefault(),!1}).dblclick(function(e){var t=e.target.parentNode;if(t!==h){var n=R(e),a=n.tagName;if("text"===a&&"textedit"!==Z){var r=transformPoint(e.pageX,e.pageY,ge);Ne.select(n,r.x,r.y)}"g"!==a&&"a"!==a||!getRotationAngle(n)||(ze(n),n=f[0],L(!0)),h&&leaveContext(),"g"!==t.tagName&&"a"!==t.tagName||t===u().getCurrentLayer()||n===P.selectorParentGroup||setContext(n)}}).mouseup(function(e){if(2!==e.button){var t=te;if(te=null,Q){var n,r,o=transformPoint(e.pageX,e.pageY,ge),s=o.x*d,l=o.y*d,c=s/d,h=l/d,g=getElem(G()),m=!1,_=c,b=h;switch(Q=!1,Z){case"resize":case"multiselect":null!=ne&&(ne.setAttribute("display","none"),ae=[]),Z="select";case"select":if(null!=f[0]){if(null==f[1]){var y=f[0];switch(y.tagName){case"g":case"use":case"image":case"foreignObject":break;default:ee.fill=y.getAttribute("fill"),ee.fill_opacity=y.getAttribute("fill-opacity"),ee.stroke=y.getAttribute("stroke"),ee.stroke_opacity=y.getAttribute("stroke-opacity"),ee.stroke_width=y.getAttribute("stroke-width"),ee.stroke_dasharray=y.getAttribute("stroke-dasharray"),ee.stroke_linejoin=y.getAttribute("stroke-linejoin"),ee.stroke_linecap=y.getAttribute("stroke-linecap")}"text"===y.tagName&&(q.font_size=y.getAttribute("font-size"),q.font_family=y.getAttribute("font-family")),P.requestSelector(y).showGrips(!0)}if(de(),_!==be||b!==ye)for(var C=f.length,S=0;S=0?A.indexOf(",",E+1)>=0:A.indexOf(" ",A.indexOf(" ")+1)>=0)&&(g=x.smoothPolylineIntoPath(g));break;case"line":n=$$9(g).attr(["x1","x2","y1","y2"]),m=n.x1!==n.x2||n.y1!==n.y2;break;case"foreignObject":case"square":case"rect":case"image":n=$$9(g).attr(["width","height"]),m=n.width||n.height||"image"===Z;break;case"circle":m="0"!==g.getAttribute("r");break;case"ellipse":n=$$9(g).attr(["rx","ry"]),m=n.rx||n.ry;break;case"fhellipse":me.maxx-me.minx>0&&me.maxy-me.miny>0&&(g=v({element:"ellipse",curStyles:!0,attr:{cx:(me.minx+me.maxx)/2,cy:(me.miny+me.maxy)/2,rx:(me.maxx-me.minx)/2,ry:(me.maxy-me.miny)/2,id:G()}}),N("changed",[g]),m=!0);break;case"fhrect":me.maxx-me.minx>0&&me.maxy-me.miny>0&&(g=v({element:"rect",curStyles:!0,attr:{x:me.minx,y:me.miny,width:me.maxx-me.minx,height:me.maxy-me.miny,id:G()}}),N("changed",[g]),m=!0);break;case"text":m=!0,pe([g]),Ne.start(g);break;case"path":g=null,Q=!0;var T=x.mouseUp(e,g,s,l);g=T.element,m=T.keep;break;case"pathedit":m=!0,g=null,x.mouseUp(e);break;case"textedit":m=!1,g=null,Ne.mouseUp(e,s,l);break;case"rotate":m=!0,g=null,Z="select";var L=i.undoMgr.finishUndoableChange();L.isEmpty()||k(L),de(),N("changed",f)}var I=ie("mouseUp",{event:e,mouse_x:s,mouse_y:l},!0);if($$9.each(I,function(e,t){t&&(m=t.keep||m,g=t.element,Q=t.started||Q)}),m||null==g){if(null!=g){i.addedNew=!0;var M,R=.2;if(D.beginElement&&parseFloat(g.getAttribute("opacity"))!==p.opacity){M=$$9(D).clone().attr({to:p.opacity,dur:R}).appendTo(g);try{M[0].beginElement()}catch(e){}}else R=0;setTimeout(function(){M&&M.remove(),g.setAttribute("opacity",p.opacity),g.setAttribute("style","pointer-events:inherit"),cleanupElement(g),"path"===Z?x.toEditMode(g):a.selectNew&&pe([g],!0),k(new InsertElementCommand$1(g)),N("changed",[g])},1e3*R)}}else{for(u().releaseId(G()),g.remove(),g=null,r=e.target;r&&r.parentNode&&r.parentNode.parentNode&&"g"===r.parentNode.parentNode.tagName;)r=r.parentNode;"path"===Z&&Te||!r||!r.parentNode||"selectorParentGroup"===r.parentNode.id||"svgcanvas"===r.id||"svgroot"===r.id||(i.setMode("select"),pe([r],!0))}K=null}}}),$$9(t).bind("mousewheel DOMMouseScroll",function(e){if(e.shiftKey){e.preventDefault();var t=e.originalEvent;ge=$$9("#svgcontent g")[0].getScreenCTM().inverse();var n=$$9("#workarea"),r=a.showRulers?16:0,o=transformPoint(t.pageX,t.pageY,ge),s=n.width(),l=n.height(),c=s-15-r,u=l-15-r,h=c*ge.a,g=u*ge.d,p=n.offset(),f=p.left+r,m=p.top+r,v=t.wheelDelta?t.wheelDelta:t.detail?-t.detail:0;if(v){var _,b,y=Math.max(.75,Math.min(4/3,v));y>1?(_=Math.ceil(c/h*y*100)/100,b=Math.ceil(u/g*y*100)/100):(_=Math.floor(c/h*y*100)/100,b=Math.floor(u/g*y*100)/100);var x=Math.min(_,b);if((x=Math.min(10,Math.max(.01,x)))!==d){y=x/d;var C=transformPoint(f,m,ge),S={x:(o.x-(o.x-C.x)/y)*x-r+s/2,y:(o.y-(o.y-C.y)/y)*x-r+l/2};i.setZoom(x),$$9("#zoom").val((100*x).toFixed(1)),N("updateCanvas",{center:!1,newCtr:S}),N("zoomDone")}}}});var Ge,Ne=i.textActions=function(){var e,t,n,a,r,o,l,c,u,h,g=[];function p(e){var i=""===t.value;if($$9(t).focus(),!arguments.length)if(i)e=0;else{if(t.selectionEnd!==t.selectionStart)return;e=t.selectionEnd}var s=g[e];i||t.setSelectionRange(e,e),(n=getElem("text_cursor"))||(n=document.createElementNS(NS.SVG,"line"),assignAttributes(n,{id:"text_cursor",stroke:"#333","stroke-width":1}),n=getElem("selectorParentGroup").appendChild(n)),r||(r=setInterval(function(){var e="none"===n.getAttribute("display");n.setAttribute("display",e?"inline":"none")},600));var l=x(s.x,o.y),c=x(s.x,o.y+o.height);assignAttributes(n,{x1:l.x,y1:l.y,x2:c.x,y2:c.y,visibility:"visible",display:"inline"}),a&&a.setAttribute("d","")}function m(e,r,i){if(e!==r){i||t.setSelectionRange(e,r),(a=getElem("text_selectblock"))||(a=document.createElementNS(NS.SVG,"path"),assignAttributes(a,{id:"text_selectblock",fill:"green",opacity:.5,style:"pointer-events:none"}),getElem("selectorParentGroup").append(a));var s=g[e],l=g[r];n.setAttribute("visibility","hidden");var c=x(s.x,o.y),u=x(s.x+(l.x-s.x),o.y),d=x(s.x,o.y+o.height),h=x(s.x+(l.x-s.x),o.y+o.height),f="M"+c.x+","+c.y+" L"+u.x+","+u.y+" "+h.x+","+h.y+" "+d.x+","+d.y+"z";assignAttributes(a,{d:f,display:"inline"})}else p(r)}function v(t,n){var a=s.createSVGPoint();if(a.x=t,a.y=n,1===g.length)return 0;var r=e.getCharNumAtPosition(a);r<0?(r=g.length-2,t<=g[0].x&&(r=0)):r>=g.length-2&&(r=g.length-2);var i=g[r];return t>i.x+i.width/2&&r++,r}function _(e,t){p(v(e,t))}function b(e,n,a){var r=t.selectionStart,i=v(e,n);m(Math.min(r,i),Math.max(r,i),!a)}function y(e,t){var n={x:e,y:t};if(n.x/=d,n.y/=d,l){var a=transformPoint(n.x,n.y,l.inverse());n.x=a.x,n.y=a.y}return n}function x(e,t){var n={x:e,y:t};if(l){var a=transformPoint(n.x,n.y,l);n.x=a.x,n.y=a.y}return n.x*=d,n.y*=d,n}function C(t){m(0,e.textContent.length),$$9(this).unbind(t)}function S(t){if(h&&e){var n=transformPoint(t.pageX,t.pageY,ge),a=y(n.x*d,n.y*d),r=v(a.x,a.y),i=e.textContent,o=i.substr(0,r).replace(/[a-z0-9]+$/i,"").length,s=i.substr(r).match(/^[a-z0-9]+/i);m(o,(s?s[0].length:0)+r),$$9(t.target).click(C),setTimeout(function(){$$9(t.target).unbind("click",C)},300)}}return{select:function(t,n,a){e=t,Ne.toEditMode(n,a)},start:function(t){e=t,Ne.toEditMode()},mouseDown:function(e,n,a,r){var i=y(a,r);t.focus(),_(i.x,i.y),c=a,u=r},mouseMove:function(e,t){var n=y(e,t);b(n.x,n.y)},mouseUp:function(t,n,a){var r=y(n,a);b(r.x,r.y,!0),t.target!==e&&nc-2&&au-2&&Ne.toSelectMode(!0)},setCursor:p,toEditMode:function(t,n){if(h=!1,Z="textedit",P.requestSelector(e).showGrips(!1),P.requestSelector(e),Ne.init(),$$9(e).css("cursor","text"),arguments.length){var a=y(t,n);_(a.x,a.y)}else p();setTimeout(function(){h=!0},300)},toSelectMode:function(o){Z="select",clearInterval(r),r=null,a&&$$9(a).attr("display","none"),n&&$$9(n).attr("visibility","hidden"),$$9(e).css("cursor","move"),o&&(L(),$$9(e).css("cursor","move"),N("selected",[e]),I([e],!0)),e&&!e.textContent.length&&i.deleteSelectedElements(),$$9(t).blur(),e=!1},setInputElem:function(e){t=e},clear:function(){"textedit"===Z&&Ne.toSelectMode()},init:function(n){if(e){var a,r;e.parentNode||(e=f[0],P.requestSelector(e).showGrips(!1));var s=e.textContent.length,c=e.getAttribute("transform");for(o=getBBox(e),l=c?getMatrix(e):null,(g=[]).length=s,t.focus(),$$9(e).unbind("dblclick",S).dblclick(S),s||(r={x:o.x+o.width/2,width:0}),a=0;a")[0].getContext("2d")||(n.text=O.exportNoText),$$9.each(n,function(n,r){a.find(n).length&&(t.push(n),e.push(r))}),{issues:e,issueCodes:t}}this.svgCanvasToString=function(){for(;Le()>0;);x.clear(!0),$$9.each(l.childNodes,function(e,t){e&&8===t.nodeType&&t.data.includes("Created with")&&l.firstChild.before(t)}),h&&(leaveContext(),pe([h]));var e=[];$$9(l).find("g:data(gsvg)").each(function(){for(var t=this.attributes,n=t.length,a=0;at.name?-1:1}),o=0;o=0;o--){var f=s[o],m=toXml(f.value);if(!p.includes(f.localName)&&""!==m){if(m.startsWith("pointer-events"))continue;if("class"===f.localName&&m.startsWith("se_"))continue;if(n.push(" "),"d"===f.localName&&(m=x.convertPath(e,!0)),isNaN(m)?i.test(m)&&(m=shortFloat(m)+r):m=shortFloat(m),H.apply&&"image"===e.nodeName&&"href"===f.localName&&H.images&&"embed"===H.images){var v=U[m];v&&(m=v)}f.namespaceURI&&f.namespaceURI!==NS.SVG&&!w[f.namespaceURI]||(n.push(f.nodeName),n.push('="'),n.push(m),n.push('"'))}}}if(e.hasChildNodes()){n.push(">"),t++;var _=!1;for(o=0;o");break;case 8:n.push("\n"),n.push(new Array(t+1).join(" ")),n.push("\x3c!--"),n.push(b.data),n.push("--\x3e")}}if(t--,!_)for(n.push("\n"),o=0;o")}else n.push("/>")}return n.join("")},this.embedImage=function(e,t){return new Promise(function(n,a){$$9(new Image).load(function(r,i,o){if("error"!==i){var s=document.createElement("canvas");s.width=this.width,s.height=this.height,s.getContext("2d").drawImage(this,0,0);try{var l=";svgedit_url="+encodeURIComponent(e);l=s.toDataURL().replace(";base64",l+";base64"),U[e]=l}catch(t){U[e]=!1}X=e,t&&t(U[e]),n(U[e])}else a(new Error("Error loading image: "+o.status+" "+o.statusText))}).attr("src",e)})},this.setGoodImage=function(e){X=e},this.open=function(){},this.save=function(e){L(),e&&$$9.extend(H,e),H.apply=!0;var t=this.svgCanvasToString();N("saved",t)},this.rasterExport=function(e,t,n,r){var o="ICO"===e?"BMP":e||"PNG",s="image/"+o.toLowerCase(),l=Ie(),c=l.issues,u=l.issueCodes,d=this.svgCanvasToString();return new Promise(function(){var l=_asyncToGenerator(regeneratorRuntime.mark(function l(h,g){var p,f,m,v,_,b;return regeneratorRuntime.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(b=function(){var a={datauri:v,bloburl:_,svg:d,issues:c,issueCodes:u,type:e,mimeType:s,quality:t,exportWindowName:n};N("exported",a),r&&r(a),h(a)},Ge){l.next=6;break}return l.next=4,importSetGlobal(a.canvgPath+"canvg.js",{global:"canvg"});case 4:p=l.sent,Ge=p.canvg;case 6:return $$9("#export_canvas").length||$$9("",{id:"export_canvas"}).hide().appendTo("body"),(f=$$9("#export_canvas")[0]).width=i.contentW,f.height=i.contentH,l.next=12,Ge(f,d);case 12:if(m=o.toLowerCase(),v=t?f.toDataURL("image/"+m,t):f.toDataURL("image/"+m),!f.toBlob){l.next=17;break}return f.toBlob(function(e){_=createObjectURL(e),b()},s,t),l.abrupt("return");case 17:_=dataURLToObjectURL(v),b();case 19:case"end":return l.stop()}},l,this)}));return function(e,t){return l.apply(this,arguments)}}())},this.exportPDF=function(e,t,n){var r=this;return new Promise(function(){var i=_asyncToGenerator(regeneratorRuntime.mark(function i(o,s){var l,c,u,d,h,g,p,f,m,v;return regeneratorRuntime.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(window.jsPDF){i.next=6;break}return i.next=3,importScript(["jspdf/underscore-min.js","jspdf/jspdf.min.js"]);case 3:return l=!("svgEditor"in window&&window.svgEditor&&!1===window.svgEditor.modules),i.next=6,importScript(a.jspdfPath+"jspdf.plugin.svgToPdf.js",{type:l?"module":"text/javascript"});case 6:c=Ve(),u=c.w>c.h?"landscape":"portrait","pt",d=jsPDF({orientation:u,unit:"pt",format:[c.w,c.h]}),h=je(),d.setProperties({title:h}),g=Ie(),p=g.issues,f=g.issueCodes,m=r.svgCanvasToString(),d.addSVG(m,0,0),(v={svg:m,issues:p,issueCodes:f,exportWindowName:e,outputType:t=t||"dataurlstring"}).output=d.output(t,"save"===t?e||"svg.pdf":void 0),n&&n(v),o(v),N("exportedPDF",v);case 21:case"end":return i.stop()}},i,this)}));return function(e,t){return i.apply(this,arguments)}}())},this.getSvgString=function(){return H.apply=!1,this.svgCanvasToString()},this.randomizeIds=function(e){arguments.length>0&&!1===e?randomizeIds(!1,u()):randomizeIds(!0,u())};var Me=this.uniquifyElems=function(e){var t={},n=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];for(var a in walkTree(e,function(e){if(1===e.nodeType){e.id&&(e.id in t||(t[e.id]={elem:null,attrs:[],hrefs:[]}),t[e.id].elem=e),$$9.each(V,function(n,a){var r=e.getAttributeNode(a);if(r){var i=getUrlFromAttr(r.value),o=i?i.substr(1):null;o&&(o in t||(t[o]={elem:null,attrs:[],hrefs:[]}),t[o].attrs.push(r))}});var a=getHref(e);if(a&&n.includes(e.nodeName)){var r=a.substr(1);r&&(r in t||(t[r]={elem:null,attrs:[],hrefs:[]}),t[r].hrefs.push(e))}}}),t)if(a){var r=t[a].elem;if(r){var i=T();r.id=i;for(var o=t[a].attrs,s=o.length;s--;){var l=o[s];l.ownerElement.setAttribute(l.name,"url(#"+i+")")}for(var c=t[a].hrefs,u=c.length;u--;){var d=c[u];setHref(d,"#"+i)}}}},Re=this.setUseData=function(e){var t=$$9(e);"use"!==e.tagName&&(t=t.find("use")),t.each(function(){var e=getHref(this).substr(1),t=getElem(e);t&&($$9(this).data("ref",t),"symbol"!==t.tagName&&"svg"!==t.tagName||$$9(this).data("symbol",t).data("ref",t))})},Oe=this.convertGradients=function(e){var t=$$9(e).find("linearGradient, radialGradient");!t.length&&isWebkit()&&(t=$$9(e).find("*").filter(function(){return this.tagName.includes("Gradient")})),t.each(function(){if("userSpaceOnUse"===$$9(this).attr("gradientUnits")){var e=$$9(l).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(!e.length)return;var t=getBBox(e[0]);if(!t)return;if("linearGradient"===this.tagName){var n=$$9(this).attr(["x1","y1","x2","y2"]),a=this.gradientTransform.baseVal;if(a&&a.numberOfItems>0){var r=transformListToTransform(a).matrix,i=transformPoint(n.x1,n.y1,r),o=transformPoint(n.x2,n.y2,r);n.x1=i.x,n.y1=i.y,n.x2=o.x,n.y2=o.y,this.removeAttribute("gradientTransform")}$$9(this).attr({x1:(n.x1-t.x)/t.width,y1:(n.y1-t.y)/t.height,x2:(n.x2-t.x)/t.width,y2:(n.y2-t.y)/t.height}),this.removeAttribute("gradientUnits")}}})},Be=this.convertToGroup=function(e){e||(e=f[0]);var t,n=$$9(e),a=new BatchCommand$1;if(n.data("gsvg")){var r=e.firstChild,i=$$9(r).attr(["x","y"]);$$9(e.firstChild.firstChild).unwrap(),$$9(e).removeData("gsvg");var c=getTransformList(e),u=s.createSVGTransform();u.setTranslate(i.x,i.y),c.appendItem(u),recalculateDimensions(e),N("selected",[e])}else if(n.data("symbol")){e=n.data("symbol"),t=n.attr("transform");var d=n.attr(["x","y"]),h=e.getAttribute("viewBox");if(h){var g=h.split(" ");d.x-=+g[0],d.y-=+g[1]}t+=" translate("+(d.x||0)+","+(d.y||0)+")";var p=n.prev();a.addSubCommand(new RemoveElementCommand$1(n[0],n[0].nextSibling,n[0].parentNode)),n.remove();var m,v=$$9(l).find("use:data(symbol)").length,_=o.createElementNS(NS.SVG,"g"),b=e.childNodes;for(m=0;mp?"scale("+_/3/v[3]+")":"scale("+_/3/v[2]+")")+" translate(0)",s=o.createElementNS(NS.SVG,"symbol");var b=findDefs();for(isGecko()&&$$9(d).find("linearGradient, radialGradient, pattern").appendTo(b);d.firstChild;){var y=d.firstChild;s.append(y)}for(var x=d.attributes,C=0;C0&&(n?Ue(e,t,a):(He(e,t,a),N("changed",a)))};var De=this.setGradient=function(e){if(ee[e+"_paint"]&&"solidColor"!==ee[e+"_paint"].type){var t=i[e+"Grad"],n=Fe(t),a=findDefs();n?t=n:(t=a.appendChild(o.importNode(t,!0))).id=T(),i.setColor(e,"url(#"+t.id+")")}},Fe=function(e){for(var t=findDefs(),n=$$9(t).find("linearGradient, radialGradient"),a=n.length,r=["r","cx","cy","fx","fy"];a--;){var i=n[a];if("linearGradient"===e.tagName){if(e.getAttribute("x1")!==i.getAttribute("x1")||e.getAttribute("y1")!==i.getAttribute("y1")||e.getAttribute("x2")!==i.getAttribute("x2")||e.getAttribute("y2")!==i.getAttribute("y2"))continue}else if("continue"===function(){var t=$$9(e).attr(r),n=$$9(i).attr(r),a=!1;if($$9.each(r,function(e,r){t[r]!==n[r]&&(a=!0)}),a)return"continue"}())continue;var o=e.getElementsByTagNameNS(NS.SVG,"stop"),s=i.getElementsByTagNameNS(NS.SVG,"stop");if(o.length===s.length){for(var l=o.length;l--;){var c=o[l],u=s[l];if(c.getAttribute("offset")!==u.getAttribute("offset")||c.getAttribute("stop-opacity")!==u.getAttribute("stop-opacity")||c.getAttribute("stop-color")!==u.getAttribute("stop-color"))break}if(-1===l)return i}}return null};this.setPaint=function(e,t){var n=new $$9.jGraduate.Paint(t);switch(this.setPaintOpacity(e,n.alpha/100,!0),ee[e+"_paint"]=n,n.type){case"solidColor":this.setColor(e,"none"!==n.solidColor?"#"+n.solidColor:"none");break;case"linearGradient":case"radialGradient":i[e+"Grad"]=n[n.type],De(e)}},this.setStrokePaint=function(e){this.setPaint("stroke",e)},this.setFillPaint=function(e){this.setPaint("fill",e)},this.getStrokeWidth=function(){return ee.stroke_width},this.setStrokeWidth=function(e){if(0===e&&["line","path"].includes(Z))i.setStrokeWidth(1);else{ee.stroke_width=e;for(var t=[],n=f.length;n--;){var a=f[n];a&&("g"===a.tagName?walkTree(a,r):t.push(a))}t.length>0&&(He("stroke-width",e,t),N("changed",f))}function r(e){"g"!==e.nodeName&&t.push(e)}},this.setStrokeAttr=function(e,t){p[e.replace("-","_")]=t;for(var n=[],a=f.length;a--;){var r=f[a];r&&("g"===r.tagName?walkTree(r,function(e){"g"!==e.nodeName&&n.push(e)}):n.push(r))}n.length>0&&(He(e,t,n),N("changed",f))},this.getStyle=function(){return p},this.getOpacity=M,this.setOpacity=function(e){p.opacity=e,He("opacity",e)},this.getFillOpacity=function(){return p.fill_opacity},this.getStrokeOpacity=function(){return p.stroke_opacity},this.setPaintOpacity=function(e,t,n){p[e+"_opacity"]=t,n?Ue(e+"-opacity",t):He(e+"-opacity",t)},this.getPaintOpacity=function(e){return"fill"===e?this.getFillOpacity():this.getStrokeOpacity()},this.getBlur=function(e){var t=0;if(e&&e.getAttribute("filter")){var n=getElem(e.id+"_blur");n&&(t=n.firstChild.getAttribute("stdDeviation"))}return t},function(){var e=null,t=null,n=!1;function a(){var n=i.undoMgr.finishUndoableChange();e.addSubCommand(n),k(e),e=null,t=null}i.setBlurNoUndo=function(e){if(t)if(0===e)Ue("filter",""),n=!0;else{var a=f[0];n&&Ue("filter","url(#"+a.id+"_blur)"),isWebkit()&&(console.log("e",a),a.removeAttribute("filter"),a.setAttribute("filter","url(#"+a.id+"_blur)")),Ue("stdDeviation",e,[t.firstChild]),i.setBlurOffsets(t,e)}else i.setBlur(e)},i.setBlurOffsets=function(e,t){t>3?assignAttributes(e,{x:"-50%",y:"-50%",width:"200%",height:"200%"},100):isWebkit()||(e.removeAttribute("x"),e.removeAttribute("y"),e.removeAttribute("width"),e.removeAttribute("height"))},i.setBlur=function(n,r){if(e)a();else{var o=f[0],s=o.id;t=getElem(s+"_blur"),n-=0;var l=new BatchCommand$1;if(t)0===n&&(t=null);else{var c=v({element:"feGaussianBlur",attr:{in:"SourceGraphic",stdDeviation:n}});(t=v({element:"filter",attr:{id:s+"_blur"}})).append(c),findDefs().append(t),l.addSubCommand(new InsertElementCommand$1(t))}var u={filter:o.getAttribute("filter")};if(0===n)return o.removeAttribute("filter"),void l.addSubCommand(new ChangeElementCommand$1(o,u));He("filter","url(#"+s+"_blur)"),l.addSubCommand(new ChangeElementCommand$1(o,u)),i.setBlurOffsets(t,n),e=l,i.undoMgr.beginUndoableChange("stdDeviation",[t?t.firstChild:null]),r&&(i.setBlurNoUndo(n),a())}}}(),this.getBold=function(){var e=f[0];return null!=e&&"text"===e.tagName&&null==f[1]&&"bold"===e.getAttribute("font-weight")},this.setBold=function(e){var t=f[0];null!=t&&"text"===t.tagName&&null==f[1]&&He("font-weight",e?"bold":"normal"),f[0].textContent||Ne.setCursor()},this.getItalic=function(){var e=f[0];return null!=e&&"text"===e.tagName&&null==f[1]&&"italic"===e.getAttribute("font-style")},this.setItalic=function(e){var t=f[0];null!=t&&"text"===t.tagName&&null==f[1]&&He("font-style",e?"italic":"normal"),f[0].textContent||Ne.setCursor()},this.getFontFamily=function(){return q.font_family},this.setFontFamily=function(e){q.font_family=e,He("font-family",e),f[0]&&!f[0].textContent&&Ne.setCursor()},this.setFontColor=function(e){q.fill=e,He("fill",e)},this.getFontColor=function(){return q.fill},this.getFontSize=function(){return q.font_size},this.setFontSize=function(e){q.font_size=e,He("font-size",e),f[0].textContent||Ne.setCursor()},this.getText=function(){var e=f[0];return null==e?"":e.textContent},this.setTextContent=function(e){He("#text",e),Ne.init(e),Ne.setCursor()},this.setImageURL=function(e){var t=f[0];if(t){var n=$$9(t).attr(["width","height"]),a=!n.width||!n.height,r=getHref(t);if(r!==e||a){var i=new BatchCommand$1("Change Image URL");setHref(t,e),i.addSubCommand(new ChangeElementCommand$1(t,{"#href":r})),$$9(new Image).load(function(){var e=$$9(t).attr(["width","height"]);$$9(t).attr({width:this.width,height:this.height}),P.requestSelector(t).resize(),i.addSubCommand(new ChangeElementCommand$1(t,e)),k(i),N("changed",[t])}).attr("src",e)}}},this.setLinkURL=function(e){var t=f[0];if(t){if("a"!==t.tagName){var n=$$9(t).parents("a");if(!n.length)return;t=n[0]}var a=getHref(t);if(a!==e){var r=new BatchCommand$1("Change Link URL");setHref(t,e),r.addSubCommand(new ChangeElementCommand$1(t,{"#href":a})),k(r)}}},this.setRectRadius=function(e){var t=f[0];if(null!=t&&"rect"===t.tagName){var n=t.getAttribute("rx");n!==String(e)&&(t.setAttribute("rx",e),t.setAttribute("ry",e),k(new ChangeElementCommand$1(t,{rx:n,ry:n},"Radius")),N("changed",[t]))}},this.makeHyperlink=function(e){i.groupSelectedElements("a",e)},this.removeHyperlink=function(){i.ungroupSelectedElement()},this.setSegType=function(e){x.setSegType(e)},this.convertToPath=function(e,t){if(null!=e){if(t)return getBBoxOfElementAsPath(e,v,x);var n={fill:p.fill,"fill-opacity":p.fill_opacity,stroke:p.stroke,"stroke-width":p.stroke_width,"stroke-dasharray":p.stroke_dasharray,"stroke-linejoin":p.stroke_linejoin,"stroke-linecap":p.stroke_linecap,"stroke-opacity":p.stroke_opacity,opacity:p.opacity,visibility:"hidden"};return convertToPath(e,n,v,x,L,I,history,k)}var a=f;$$9.each(a,function(e,t){t&&i.convertToPath(t)})};var Ue=function(e,t,n){"pathedit"===Z&&x.moveNode(e,t);for(var a=(n=n||f).length,r=["g","polyline","path"],o=["transform","opacity","filter"],l=function(){var l=n[a];if(null==l)return"continue";if(("x"===e||"y"===e)&&r.includes(l.tagName)){var c=getStrokedBBoxDefaultVisible([l]),u="x"===e?t-c.x:0,h="y"===e?t-c.y:0;return i.moveSelectedElements(u*d,h*d,!0),"continue"}"g"===l.tagName&&o.includes(e);var g="#text"===e?l.textContent:l.getAttribute(e);if(null==g&&(g=""),g!==String(t)){"#text"===e?(l.textContent=t,/rotate/.test(l.getAttribute("transform"))&&(l=ue(l))):"#href"===e?setHref(l,t):l.setAttribute(e,t),"textedit"===Z&&"#text"!==e&&l.textContent.length&&Ne.toSelectMode(l),isGecko()&&"text"===l.nodeName&&/rotate/.test(l.getAttribute("transform"))&&(String(t).startsWith("url")||["font-size","font-family","x","y"].includes(e)&&l.textContent)&&(l=ue(l)),f.includes(l)&&setTimeout(function(){l.parentNode&&P.requestSelector(l).resize()},0);var p=getRotationAngle(l);if(0!==p&&"transform"!==e)for(var m=getTransformList(l),v=m.numberOfItems;v--;){if(4===m.getItem(v).type){m.removeItem(v);var _=getBBox(l),b=transformPoint(_.x+_.width/2,_.y+_.height/2,transformListToTransform(m).matrix),y=b.x,x=b.y,C=s.createSVGTransform();C.setRotate(p,y,x),m.insertItemBefore(C,v);break}}}};a--;)l()},He=this.changeSelectedAttribute=function(e,t,n){n=n||f,i.undoMgr.beginUndoableChange(e,n),Ue(e,t,n);var a=i.undoMgr.finishUndoableChange();a.isEmpty()||k(a)};this.deleteSelectedElements=function(){for(var e=new BatchCommand$1("Delete Elements"),t=f.length,n=[],a=0;an[d].width)||("t"===e||"m"===e||"b"===e)&&(u===Number.MIN_VALUE||u>n[d].height))&&(r=n[d].x,s=n[d].y,o=n[d].x+n[d].width,l=n[d].y+n[d].height,c=n[d].width,u=n[d].height);break;case"largest":(("l"===e||"c"===e||"r"===e)&&(c===Number.MIN_VALUE||co&&(o=n[d].x+n[d].width),n[d].y+n[d].height>l&&(l=n[d].y+n[d].height)}}"page"===t&&(r=0,s=0,o=i.contentW,l=i.contentH);for(var g=new Array(a),p=new Array(a),m=0;m=r.length?t=0:t<0&&(t=r.length-1),a=r[t];break}pe([a],!0),N("selected",f)}},this.clear(),this.getPrivateMethods=function(){return{addCommandToHistory:k,BatchCommand:BatchCommand$1,ChangeElementCommand:ChangeElementCommand$1,decode64:decode64,dropXMLInteralSubset:dropXMLInteralSubset,encode64:encode64,ffClone:ue,findDefs:findDefs,findDuplicateGradient:Fe,getElem:getElem,getPathBBox:getPathBBox,getTypeMap:getTypeMap,getUrlFromAttr:getUrlFromAttr,identifyLayers:identifyLayers,InsertElementCommand:InsertElementCommand$1,isChrome:isChrome,isIdentity:isIdentity,isIE:isIE,logMatrix:he,MoveElementCommand:MoveElementCommand$1,NS:NS,preventClickDefault:preventClickDefault,RemoveElementCommand:RemoveElementCommand$1,SVGEditTransformList:SVGTransformList,text2xml:text2xml,transformBox:transformBox,transformPoint:transformPoint,walkTree:walkTree}}};function jqPluginJSHotkeys(e){function t(t){if("string"==typeof t.data){var n=t.handler,a=t.data.toLowerCase().split(" ");t.handler=function(t){if(this===t.target||27===t.which||!/textarea|select/i.test(t.target.nodeName)&&"text"!==t.target.type){var r="keypress"!==t.type&&e.hotkeys.specialKeys[t.which],i=String.fromCharCode(t.which).toLowerCase(),o="",s={};t.altKey&&"alt"!==r&&(o+="alt+"),t.ctrlKey&&"ctrl"!==r&&(o+="ctrl+"),t.metaKey&&!t.ctrlKey&&"meta"!==r&&(o+="meta+"),t.shiftKey&&"shift"!==r&&(o+="shift+"),r?s[o+r]=!0:(s[o+i]=!0,s[o+e.hotkeys.shiftNums[i]]=!0,"shift+"===o&&(s[e.hotkeys.shiftNums[i]]=!0));for(var l=0,c=a.length;l","/":"?","\\":"|"}},e.each(["keydown","keyup","keypress"],function(){e.event.special[this]={add:t}}),e}function jqPluginBBQ(e){return function(e,t){var n,a,r,i,o,s,l,c,u=Array.prototype.slice,d=decodeURIComponent,h=e.param,g=e.bbq=e.bbq||{},p=e.event.special,f="hashchange",m="querystring",v="fragment",_="elemUrlAttr",b="location",y="href",x="src",C=/^.*\?|#.*$/g,S=/^.*\#/,w={};function $(e){return"string"==typeof e}function k(e){var t=u.call(arguments,1);return function(){return e.apply(this,t.concat(u.call(arguments)))}}function A(a,i,o,s,l){var u,g,p,f,_;return s!==n?(_=(p=o.match(a?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/))[3]||"",2===l&&$(s)?g=s.replace(a?S:C,""):(f=r(p[2]),s=$(s)?r[a?v:m](s):s,g=2===l?s:1===l?e.extend({},s,f):e.extend({},f,s),g=h(g),a&&(g=g.replace(c,d))),u=p[1]+(a?"#":g||!p[1]?"?":"")+g+_):u=i(o!==n?o:t[b][y]),u}function E(e,t,a){return t===n||"boolean"==typeof t?(a=t,t=h[e?v:m]()):t=$(t)?t.replace(e?S:C,""):t,r(t,a)}function P(t,a,r,i){return $(r)||"object"===_typeof(r)||(i=r,r=a,a=n),this.each(function(){var n=e(this),o=a||l()[(this.nodeName||"").toLowerCase()]||"",s=o&&n.attr(o)||"";n.attr(o,h[t](s,r,i))})}h[m]=k(A,0,function(e){return e.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}),h[v]=a=k(A,1,function(e){return e.replace(/^[^#]*#?(.*)$/,"$1")}),a.noEscape=function(t){t=t||"";var n=e.map(t.split(""),encodeURIComponent);c=new RegExp(n.join("|"),"g")},a.noEscape(",/"),e.deparam=r=function(t,a){var r={},i={true:!0,false:!1,null:null};return e.each(t.replace(/\+/g," ").split("&"),function(t,o){var s,l=o.split("="),c=d(l[0]),u=r,h=0,g=c.split("]["),p=g.length-1;if(/\[/.test(g[0])&&/\]$/.test(g[p])?(g[p]=g[p].replace(/\]$/,""),p=(g=g.shift().split("[").concat(g)).length-1):p=0,2===l.length)if(s=d(l[1]),a&&(s=s&&!isNaN(s)?+s:"undefined"===s?n:i[s]!==n?i[s]:s),p)for(;h<=p;h++)u=u[c=""===g[h]?u.length:g[h]]=h').hide().insertAfter("body")[0].contentWindow,l=function(){return h(a.document[i][s])},(r=function(e,t){if(e!==t){var n=a.document;n.open().close(),n[i].hash="#"+e}})(h()))),function a(){var u=h(),d=l(c);u!==c?(r(c=u,d),e(t).trigger(o)):d!==c&&(t[i][s]=t[i][s].replace(/#.*/,"")+"#"+d),n=setTimeout(a,e[o+"Delay"])}()}},c.stop=function(){a||(n&&clearTimeout(n),n=0)},c}()}(e,window),e}function jqPluginSVGIcons(e){var t,n={};return e.svgIcons=function(a){var r,i,o,s,l,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u="http://www.w3.org/2000/svg",d="http://www.w3.org/1999/xlink",h=c.w||24,g=c.h||24,p=!1,f=!1,m=0,v=!!window.opera,_="data:image/svg+xml;charset=utf-8;base64,";if(c.svgz){s=e('').appendTo("body").hide();try{i=s[0].contentDocument,s.load(y),y(0,!0)}catch(e){w()}}else{var b=new DOMParser;e.ajax({url:a,dataType:"string",success:function(t){t?(i=b.parseFromString(t,"text/xml"),e(function(){y("ajax")})):e(w)},error:function(t){window.opera?e(function(){w()}):t.responseText?((i=b.parseFromString(t.responseText,"text/xml")).childNodes.length||e(w),e(function(){y("ajax")})):e(w)}})}function y(t,n){if("ajax"!==t){if(f)return;var a=(i=s[0].contentDocument)&&i.getElementById("svg_eof");if(!(a||n&&a))return void(++m<50?setTimeout(y,20):(w(),f=!0));f=!0}if(r=e(i.firstChild).children(),c.no_img)setTimeout(function(){p||S()},500);else{var l=_+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";o=e(new Image).attr({src:l,width:0,height:0}).appendTo("body").load(function(){S(!0)}).error(function(){S()})}}function x(e,t,n,a){if(v&&t.css("visibility","hidden"),c.replace){a&&t.attr("id",n);var r=e.attr("class");r&&t.attr("class","svg_icon "+r),e.replaceWith(t)}else e.append(t);v&&setTimeout(function(){t.removeAttr("style")},1)}function C(e,t){void 0!==c.id_match&&!1===c.id_match||x(l,e,t,!0),n[t]=e}function S(a,i){if(!p){var f;if(c.no_img&&(a=!1),a&&(f=e(document.createElement("div"))).hide().appendTo("body"),i){var m=c.fallback_path||"";e.each(i,function(t,n){l=e("#"+t),C(e(new Image).attr({class:"svg_icon",src:m+n,width:h,height:g,alt:"icon"}),t)})}else for(var b=r.length,y=0;y0&&!a&&(o=t(o,r,!0)),x(e(this),o,i)})}),i||(a&&f.remove(),s&&s.remove(),o&&o.remove()),c.resize&&e.resizeSvgIcons(c.resize),p=!0,c.callback&&c.callback(n)}}function w(){if(a.includes(".svgz")){var t=a.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg"),e.svgIcons(t,c)}else c.fallback&&S(!1,c.fallback)}function $(e){if(window.btoa)return window.btoa(e);var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n=new Array(4*Math.floor((e.length+2)/3)),a=0,r=0;do{var i=e.charCodeAt(a++),o=e.charCodeAt(a++),s=e.charCodeAt(a++),l=i>>2,c=(3&i)<<4|o>>4,u=(15&o)<<2|s>>6,d=63&s;isNaN(o)?u=d=64:isNaN(s)&&(d=64),n[r++]=t.charAt(l),n[r++]=t.charAt(c),n[r++]=t.charAt(u),n[r++]=t.charAt(d)}while(a
    • Solid Color
    • Linear Gradient
    • Radial Gradient
    • ');var g=e(l+"> .jGraduate_colPick"),p=e(l+"> .jGraduate_gradPick");p.html('

      '+o.window.pickerTitle+'


      ');var f=256,m=f-0,v=f-0,_={};e(".jGraduate_SliderBar").width(145);var b,y=e("#"+s+"_jGraduate_GradContainer")[0],x=n("svg",{id:s+"_jgraduate_svg",width:f,height:f,xmlns:ns.svg},y),C=i.paint.type,S=i.paint[C],w=S,$=i.paint.alpha,k="solidColor"===C;switch(C){case"solidColor":case"linearGradient":if(k||(w.id=s+"_lg_jgraduate_grad",S=w=x.appendChild(w)),n("radialGradient",{id:s+"_rg_jgraduate_grad"},x),"linearGradient"===C)break;case"radialGradient":k||(w.id=s+"_rg_jgraduate_grad",S=w=x.appendChild(w)),n("linearGradient",{id:s+"_lg_jgraduate_grad"},x)}if(k){S=w=e("#"+s+"_lg_jgraduate_grad")[0],Le(0,"#"+(d=i.paint[C]),1);var A=_typeof(o.newstop);if("string"===A)switch(o.newstop){case"same":Le(1,"#"+d,1);break;case"inverse":for(var E="",P=0;P<6;P+=2){var T=(255-parseInt(d.substr(P,2),16)).toString(16);T.length<2&&(T=0+T),E+=T}Le(1,"#"+E,1);break;case"white":Le(1,"#ffffff",1);break;case"black":Le(1,"#000000",1)}else if("object"===A){var G="opac"in o.newstop?o.newstop.opac:1;Le(1,o.newstop.color||"#"+d,G)}}var N,L=parseFloat(S.getAttribute("x1")||0),I=parseFloat(S.getAttribute("y1")||0),M=parseFloat(S.getAttribute("x2")||1),R=parseFloat(S.getAttribute("y2")||0),O=parseFloat(S.getAttribute("cx")||.5),B=parseFloat(S.getAttribute("cy")||.5),V=parseFloat(S.getAttribute("fx")||O),j=parseFloat(S.getAttribute("fy")||B),D=n("rect",{id:s+"_jgraduate_rect",x:0,y:0,width:m,height:v,fill:"url(#"+s+"_jgraduate_grad)","fill-opacity":$/100},x),F=e("
      ").attr({class:"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:I*f,left:L*f}).data("coord","start").appendTo(y),U=F.clone().text(2).css({top:R*f,left:M*f}).attr("title","End stop").data("coord","end").appendTo(y),H=e("
      ").attr({class:"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:B*f,left:O*f}).data("coord","center").appendTo(y),z=H.clone().text("F").css({top:j*f,left:V*f,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(y);z[0].id=s+"_jGraduate_focusCoord",e.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(t,n){var a=isNaN(n[1]),r=w.getAttribute(n);r||(r=a?"0.5":"x2"===n?"1.0":"0.0"),_[n]=e("#"+s+"_jGraduate_"+n).val(r).change(function(){isNaN(parseFloat(this.value))||this.value<0?this.value=0:this.value>1&&(this.value=1),("f"!==n[0]||N)&&(a&&"radialGradient"===C||!a&&"linearGradient"===C)&&w.setAttribute(n,this.value);var e=a?"c"===n[0]?H:z:"1"===n[1]?F:U,t=n.includes("x")?"left":"top";e.css(t,this.value*f)}).change()});var q,W,Y,X,Q=e("#"+s+"_jGraduate_StopSlider"),K=n("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},void 0),Z=1,J=1,ee=0,te=O,ne=B,ae=n("svg",{width:"100%",height:45},Q[0]),re=n("pattern",{width:16,height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},ae),ie=n("image",{width:16,height:16},re),oe=o.images.clientPath+"map-opacity.png";ie.setAttributeNS(ns.xlink,"xlink:href",oe),e(ae).click(function(e){if(X=Q.offset(),"path"!==e.target.tagName){var t=e.pageX-X.left-8;Le((t=t<10?10:t>f+10?f+10:t)/f,0,0,!0),e.stopPropagation()}}),e(ae).mouseover(function(){ae.append(K)}),b=n("g",{},ae),n("line",{x1:10,y1:15,x2:f+10,y2:15,"stroke-width":2,stroke:"#000"},ae);var se,le,ce,ue,de=p.find(".jGraduate_spreadMethod").change(function(){w.setAttribute("spreadMethod",e(this).val())}),he=null,ge=function(e){var t=e.pageX-se.left,n=e.pageY-se.top;t=t<0?0:t>f?f:t,n=n<0?0:n>f?f:n,he.css("left",t).css("top",n);var a=t/m,r=n/v,i=he.data("coord"),o=w;switch(i){case"start":_.x1.val(a),_.y1.val(r),o.setAttribute("x1",a),o.setAttribute("y1",r);break;case"end":_.x2.val(a),_.y2.val(r),o.setAttribute("x2",a),o.setAttribute("y2",r);break;case"center":_.cx.val(a),_.cy.val(r),o.setAttribute("cx",a),o.setAttribute("cy",r),te=a,ne=r,Re();break;case"focus":_.fx.val(a),_.fy.val(r),o.setAttribute("fx",a),o.setAttribute("fy",r),Re()}e.preventDefault()},pe=function e(){he=null,h.unbind("mousemove",ge).unbind("mouseup",e)},fe=(q=w.getElementsByTagNameNS(ns.svg,"stop")).length;if(fe<2){for(;fe<2;)w.append(document.createElementNS(ns.svg,"stop")),++fe;q=w.getElementsByTagNameNS(ns.svg,"stop")}for(var me=0;me99.5&&(n=99.5),n>0?J=1-n/100:Z=-n/100-1,r=(n+100)/2*145/100,e&&Re();break;case"angle":r=(ee=n)/180,r+=.5,r*=145,e&&Re()}r>145?r=145:r<0&&(r=0),a.css({"margin-left":r-5})}).change()});for(var Ee=function(e){!function(e){var t=ue.offset,n=ue.parent,a=e.pageX-t.left-parseInt(n.css("border-left-width"));a>145&&(a=145),a<=0&&(a=0);var r=a-5;switch(a/=145,ue.type){case"radius":(a=Math.pow(2*a,2.5))>.98&&a<1.02&&(a=1),a<=.01&&(a=.01),w.setAttribute("r",a);break;case"opacity":i.paint.alpha=parseInt(100*a),D.setAttribute("fill-opacity",a);break;case"ellip":Z=1,J=1,a<.5?Z=(a/=.5)<=0?.01:a:a>.5&&(J=(a=2-(a/=.5))<=0?.01:a),Re(),J===1+(a-=1)&&(a=Math.abs(a));break;case"angle":a-=.5,ee=a*=180,Re(),a/=100}ue.elem.css({"margin-left":r}),a=Math.round(100*a),ue.input.val(a)}(e),e.preventDefault()},Pe=function e(t){h.unbind("mousemove",Ee).unbind("mouseup",e),ue=null},Te=(255*i.paint.alpha/100).toString(16);Te.length<2;)Te="0"+Te;Te=Te.split(".")[0],d="none"===i.paint.solidColor?"":i.paint.solidColor+Te,k||(d=q[0].getAttribute("stop-color")),e.extend(e.fn.jPicker.defaults.window,{alphaSupport:!0,effects:{type:"show",speed:0}}),g.jPicker({window:{title:o.window.pickerTitle},images:{clientPath:o.images.clientPath},color:{active:d,alphaSupport:!0}},function(e){i.paint.type="solidColor",i.paint.alpha=e.val("ahex")?Math.round(e.val("a")/255*100):100,i.paint.solidColor=e.val("hex")?e.val("hex"):"none",i.paint.radialGradient=null,c()},null,function(){u()});var Ge,Ne=e(l+" .jGraduate_tabs li");switch(Ne.click(function(){Ne.removeClass("jGraduate_tab_current"),e(this).addClass("jGraduate_tab_current"),e(l+" > div").hide();var t=e(this).attr("data-type");if(e(l+" .jGraduate_gradPick").show(),"rg"===t||"lg"===t){e(".jGraduate_"+t+"_field").show(),e(".jGraduate_"+("lg"===t?"rg":"lg")+"_field").hide(),e("#"+s+"_jgraduate_rect")[0].setAttribute("fill","url(#"+s+"_"+t+"_jgraduate_grad)"),C="lg"===t?"linearGradient":"radialGradient",e("#"+s+"_jGraduate_OpacInput").val(i.paint.alpha).change();var n=e("#"+s+"_"+t+"_jgraduate_grad")[0];if(w!==n){var a=e(w).find("stop");e(n).empty().append(a),w=n;var r=de.val();w.setAttribute("spreadMethod",r)}N="rg"===t&&null!=w.getAttribute("fx")&&!(O===V&&B===j),e("#"+s+"_jGraduate_focusCoord").toggle(N),N&&(e("#"+s+"_jGraduate_match_ctr")[0].checked=!1)}else e(l+" .jGraduate_gradPick").hide(),e(l+" .jGraduate_colPick").show()}),e(l+" > div").hide(),Ne.removeClass("jGraduate_tab_current"),i.paint.type){case"linearGradient":Ge=e(l+" .jGraduate_tab_lingrad");break;case"radialGradient":Ge=e(l+" .jGraduate_tab_radgrad");break;default:Ge=e(l+" .jGraduate_tab_color")}i.show(),setTimeout(function(){Ge.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.");function Le(t,a,r,i,l){var c=l||n("stop",{"stop-color":a,"stop-opacity":r,offset:t},w);l?(a=l.getAttribute("stop-color"),r=l.getAttribute("stop-opacity"),t=l.getAttribute("offset")):w.append(c),null===r&&(r=1);var u="M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",d=n("path",{d:u,fill:"url(#jGraduate_trans)",transform:"translate("+(10+t*f)+", 26)"},b),g=n("path",{d:u,fill:a,"fill-opacity":r,transform:"translate("+(10+t*f)+", 26)",stroke:"#000","stroke-width":1.5},b);return e(g).mousedown(function(e){return Ie(this),Y=W,h.mousemove(Oe).mouseup(Me),X=Q.offset(),e.preventDefault(),!1}).data("stop",c).data("bg",d).dblclick(function(){e("div.jGraduate_LightBox").show();for(var t=this,n=+c.getAttribute("stop-opacity")||1,r=c.getAttribute("stop-color")||1,i=(255*parseFloat(n)).toString(16);i.length<2;)i="0"+i;a=r.substr(1)+i,e("#"+s+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:o.images.clientPath},color:{active:a,alphaSupport:!0}},function(a,i){r=a.val("hex")?"#"+a.val("hex"):"none",n=null!==a.val("a")?a.val("a")/256:1,t.setAttribute("fill",r),t.setAttribute("fill-opacity",n),c.setAttribute("stop-color",r),c.setAttribute("stop-opacity",n),e("div.jGraduate_LightBox").hide(),e("#"+s+"_jGraduate_stopPicker").hide()},null,function(){e("div.jGraduate_LightBox").hide(),e("#"+s+"_jGraduate_stopPicker").hide()})}),e(w).find("stop").each(function(){var n=e(this);if(+this.getAttribute("offset")>t){if(!a){var r=this.getAttribute("stop-color"),i=this.getAttribute("stop-opacity");c.setAttribute("stop-color",r),g.setAttribute("fill",r),c.setAttribute("stop-opacity",null===i?1:i),g.setAttribute("fill-opacity",null===i?1:i)}return n.before(c),!1}}),i&&Ie(g),c}function Ie(e){W&&W.setAttribute("stroke","#000"),e.setAttribute("stroke","blue"),(W=e).parentNode.append(W)}function Me(){h.unbind("mousemove",Oe),"none"!==K.getAttribute("display")&&function(){K.setAttribute("display","none");var t=e(W),n=t.data("stop"),a=t.data("bg");e([W,n,a]).remove()}(),Y=null}function Re(){var e=ee?"rotate("+ee+","+te+","+ne+") ":"";if(1===Z&&1===J)w.removeAttribute("gradientTransform");else{var t=-te*(Z-1),n=-ne*(J-1);w.setAttribute("gradientTransform",e+"translate("+t+","+n+") scale("+Z+","+J+")")}}function Oe(t){var n=t.pageX-X.left,a=t.pageY-X.top,r="translate("+(n=n<10?10:n>f+10?f+10:n)+", 26)";a<-60||a>130?(K.setAttribute("display","block"),K.setAttribute("transform",r)):K.setAttribute("display","none"),Y.setAttribute("transform",r),e.data(Y,"bg").setAttribute("transform",r);var i=e.data(Y,"stop"),o=(n-10)/f;i.setAttribute("offset",o);var s=0;e(w).find("stop").each(function(t){var n=this.getAttribute("offset"),a=e(this);nn(o,"offsetLeft")+o.offsetWidth*s-this.spinCfg._btn_width?i=120?this.adjustValue(this.spinCfg.step):e.wheelDelta<=-120&&this.adjustValue(-this.spinCfg.step),e.preventDefault()}).change(function(e){this.adjustValue(0)}),this.addEventListener&&this.addEventListener("DOMMouseScroll",function(e){e.detail>0?this.adjustValue(-this.spinCfg.step):e.detail<0&&this.adjustValue(this.spinCfg.step),e.preventDefault()},!1)})},e}function jQueryContextMenu(e){var t=e(window),n=e(document);return e.extend(e.fn,{contextMenu:function(a,r){return void 0!==a.menu&&(void 0===a.inSpeed&&(a.inSpeed=150),void 0===a.outSpeed&&(a.outSpeed=75),0===a.inSpeed&&(a.inSpeed=-1),0===a.outSpeed&&(a.outSpeed=-1),e(this).each(function(){var i=e(this),o=e(i).offset(),s=e("#"+a.menu);s.addClass("contextMenu"),e(this).bind("mousedown",function(l){var c=l;e(this).mouseup(function(l){var u=e(this);if(u.unbind("mouseup"),2===c.button||a.allowLeft||c.ctrlKey&&isMac()){if(l.stopPropagation(),e(".contextMenu").hide(),i.hasClass("disabled"))return!1;var d=l.pageX,h=l.pageY,g=t.width()-s.width(),p=t.height()-s.height();d>g-15&&(d=g-15),h>p-30&&(h=p-30),n.unbind("click"),s.css({top:h,left:d}).fadeIn(a.inSpeed),s.find("A").mouseover(function(){s.find("LI.hover").removeClass("hover"),e(this).parent().addClass("hover")}).mouseout(function(){s.find("LI.hover").removeClass("hover")}),n.keypress(function(e){switch(e.keyCode){case 38:s.find("LI.hover").length?(s.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover"),s.find("LI.hover").length||s.find("LI:last").addClass("hover")):s.find("LI:last").addClass("hover");break;case 40:s.find("LI.hover").length?(s.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover"),s.find("LI.hover").length||s.find("LI:first").addClass("hover")):s.find("LI:first").addClass("hover");break;case 13:s.find("LI.hover A").trigger("click");break;case 27:n.trigger("click")}}),s.find("A").unbind("mouseup"),s.find("LI:not(.disabled) A").mouseup(function(){return n.unbind("click").unbind("keypress"),e(".contextMenu").hide(),r&&r(e(this).attr("href").substr(1),e(u),{x:d-o.left,y:h-o.top,docX:d,docY:h}),!1}),setTimeout(function(){n.click(function(){return n.unbind("click").unbind("keypress"),s.fadeOut(a.outSpeed),!1})},0)}})}),e.browser.mozilla?e("#"+a.menu).each(function(){e(this).css({MozUserSelect:"none"})}):e.browser.msie?e("#"+a.menu).each(function(){e(this).bind("selectstart.disableTextSelect",function(){return!1})}):e("#"+a.menu).each(function(){e(this).bind("mousedown.disableTextSelect",function(){return!1})}),e(i).add(e("UL.contextMenu")).bind("contextmenu",function(){return!1})}),e(this))},disableContextMenuItems:function(t){return void 0===t?(e(this).find("LI").addClass("disabled"),e(this)):(e(this).each(function(){if(void 0!==t)for(var n=t.split(","),a=0;an&&(i=n),o<0?o=0:o>r&&(o=r),l.call(a,"xy",{x:i/n*m+p,y:o/r*b+v})}function l(e,t,n){if(!(void 0!==t))switch(void 0!==e&&null!=e||(e="xy"),e.toLowerCase()){case"x":return h;case"y":return g;case"xy":default:return{x:h,y:g}}if(null==n||n!==a){var r,i,o=!1;switch(null==e&&(e="xy"),e.toLowerCase()){case"x":r=t&&(t.x&&0|t.x||0|t)||0;break;case"y":i=t&&(t.y&&0|t.y||0|t)||0;break;case"xy":default:r=t&&t.x&&0|t.x||0,i=t&&t.y&&0|t.y||0}null!=r&&(rf&&(r=f),h!==r&&(h=r,o=!0)),null!=i&&(i_&&(i=_),g!==i&&(g=i,o=!0)),o&&function(e){for(var t=0;t0&&(i=h===f?e:h/m*e|0),b>0&&(o=g===_?n:g/b*n|0),a>=e?i=(e>>1)-(a>>1):i-=a>>1,r>=n?o=(n>>1)-(r>>1):o-=r>>1,y.css({left:i+"px",top:o+"px"})},0)})}function n(t,n,a,r){var i=this,o=t.find("td.Text input");function s(e){if(""!==e.target.value||e.target===y.get(0)||(null==a||e.target===a.get(0))&&null!=a){if(!u(e))return e;switch(e.target){case g.get(0):switch(e.keyCode){case 38:return g.val(d.call(i,1+(g.val()<<0),0,255)),n.val("r",g.val(),e.target),!1;case 40:return g.val(d.call(i,(g.val()<<0)-1,0,255)),n.val("r",g.val(),e.target),!1}break;case p.get(0):switch(e.keyCode){case 38:return p.val(d.call(i,1+(p.val()<<0),0,255)),n.val("g",p.val(),e.target),!1;case 40:return p.val(d.call(i,(p.val()<<0)-1,0,255)),n.val("g",p.val(),e.target),!1}break;case f.get(0):switch(e.keyCode){case 38:return f.val(d.call(i,1+(f.val()<<0),0,255)),n.val("b",f.val(),e.target),!1;case 40:return f.val(d.call(i,(f.val()<<0)-1,0,255)),n.val("b",f.val(),e.target),!1}break;case m&&m.get(0):switch(e.keyCode){case 38:return m.val(d.call(i,parseFloat(m.val())+1,0,100)),n.val("a",toFixedNumeric(255*m.val()/100,r),e.target),!1;case 40:return m.val(d.call(i,parseFloat(m.val())-1,0,100)),n.val("a",toFixedNumeric(255*m.val()/100,r),e.target),!1}break;case v.get(0):switch(e.keyCode){case 38:return v.val(d.call(i,1+(v.val()<<0),0,360)),n.val("h",v.val(),e.target),!1;case 40:return v.val(d.call(i,(v.val()<<0)-1,0,360)),n.val("h",v.val(),e.target),!1}break;case _.get(0):switch(e.keyCode){case 38:return _.val(d.call(i,1+(_.val()<<0),0,100)),n.val("s",_.val(),e.target),!1;case 40:return _.val(d.call(i,(_.val()<<0)-1,0,100)),n.val("s",_.val(),e.target),!1}break;case b.get(0):switch(e.keyCode){case 38:return b.val(d.call(i,1+(b.val()<<0),0,100)),n.val("v",b.val(),e.target),!1;case 40:return b.val(d.call(i,(b.val()<<0)-1,0,100)),n.val("v",b.val(),e.target),!1}}}}function l(e){if(""!==e.target.value||e.target===y.get(0)||(null==a||e.target===a.get(0))&&null!=a){if(!u(e))return e;switch(e.target){case g.get(0):g.val(d.call(i,g.val(),0,255)),n.val("r",g.val(),e.target);break;case p.get(0):p.val(d.call(i,p.val(),0,255)),n.val("g",p.val(),e.target);break;case f.get(0):f.val(d.call(i,f.val(),0,255)),n.val("b",f.val(),e.target);break;case m&&m.get(0):m.val(d.call(i,m.val(),0,100)),n.val("a",toFixedNumeric(255*m.val()/100,r),e.target);break;case v.get(0):v.val(d.call(i,v.val(),0,360)),n.val("h",v.val(),e.target);break;case _.get(0):_.val(d.call(i,_.val(),0,100)),n.val("s",_.val(),e.target);break;case b.get(0):b.val(d.call(i,b.val(),0,100)),n.val("v",b.val(),e.target);break;case y.get(0):y.val(y.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6)),a&&a.val(y.val()),n.val("hex",""!==y.val()?y.val():null,e.target);break;case a&&a.get(0):a.val(a.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6)),y.val(a.val()),n.val("hex",""!==a.val()?a.val():null,e.target);break;case x&&x.get(0):x.val(x.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,2)),n.val("a",null!=x.val()?parseInt(x.val(),16):null,e.target)}}}function c(e){if(null!=n.val())switch(e.target){case g.get(0):g.val(n.val("r"));break;case p.get(0):p.val(n.val("g"));break;case f.get(0):f.val(n.val("b"));break;case m&&m.get(0):m.val(toFixedNumeric(100*n.val("a")/255,r));break;case v.get(0):v.val(n.val("h"));break;case _.get(0):_.val(n.val("s"));break;case b.get(0):b.val(n.val("v"));break;case y.get(0):case a&&a.get(0):y.val(n.val("hex")),a&&a.val(n.val("hex"));break;case x&&x.get(0):x.val(n.val("ahex").substring(6))}}function u(e){switch(e.keyCode){case 9:case 16:case 29:case 37:case 39:return!1;case"c".charCodeAt():case"v".charCodeAt():if(e.ctrlKey)return!1}return!0}function d(e,t,n){return""===e||isNaN(e)?t:e>n?n:e7?o.eq(6):null,v=o.eq(0),_=o.eq(1),b=o.eq(2),y=o.eq(o.length>7?7:6),x=o.length>7?o.eq(8):null;e.extend(!0,i,{destroy:function(){g.add(p).add(f).add(m).add(v).add(_).add(b).add(y).add(a).add(x).unbind("keyup",l).unbind("blur",c),g.add(p).add(f).add(m).add(v).add(_).add(b).unbind("keydown",s),n.unbind(h),g=null,p=null,f=null,m=null,v=null,_=null,b=null,y=null,x=null}}),g.add(p).add(f).add(m).add(v).add(_).add(b).add(y).add(a).add(x).bind("keyup",l).bind("blur",c),g.add(p).add(f).add(m).add(v).add(_).add(b).bind("keydown",s),n.bind(h)}e.loadingStylesheets.includes("jgraduate/css/jPicker.css")||e.loadingStylesheets.push("jgraduate/css/jPicker.css"),e.jPicker={List:[],Color:function(t){var n=this;function a(e){for(var t=0;t255&&(b.r=255),i!==b.r&&(i=b.r,v=!0);break;case"g":if(x)continue;y=!0,b.g=t&&t.g&&0|t.g||t&&0|t||0,b.g<0?b.g=0:b.g>255&&(b.g=255),s!==b.g&&(s=b.g,v=!0);break;case"b":if(x)continue;y=!0,b.b=t&&t.b&&0|t.b||t&&0|t||0,b.b<0?b.b=0:b.b>255&&(b.b=255),l!==b.b&&(l=b.b,v=!0);break;case"a":b.a=t&&null!=t.a?0|t.a:0|t,b.a<0?b.a=0:b.a>255&&(b.a=255),c!==b.a&&(c=b.a,v=!0);break;case"h":if(y)continue;x=!0,b.h=t&&t.h&&0|t.h||t&&0|t||0,b.h<0?b.h=0:b.h>360&&(b.h=360),u!==b.h&&(u=b.h,v=!0);break;case"s":if(y)continue;x=!0,b.s=null!=t.s?0|t.s:0|t,b.s<0?b.s=0:b.s>100&&(b.s=100),d!==b.s&&(d=b.s,v=!0);break;case"v":if(y)continue;x=!0,b.v=null!=t.v?0|t.v:0|t,b.v<0?b.v=0:b.v>100&&(b.v=100),h!==b.v&&(h=b.v,v=!0)}if(v){if(y){i=i||0,s=s||0,l=l||0;var S=o.rgbToHsv({r:i,g:s,b:l});u=S.h,d=S.s,h=S.v}else if(x){u=u||0,d=null!=d?d:100,h=null!=h?h:100;var w=o.hsvToRgb({h:u,s:d,v:h});i=w.r,s=w.g,l=w.b}c=null!=c?c:255,a.call(n,g||n)}}}}var i,s,l,c,u,d,h,g=[];e.extend(!0,n,{val:r,bind:function(e){"function"==typeof e&&g.push(e)},unbind:function(e){if("function"==typeof e)for(var t;t=g.includes(e);)g.splice(t,1)},destroy:function(){g=null}}),t&&(null!=t.ahex?r("ahex",t):null!=t.hex?r((null!=t.a?"a":"")+"hex",null!=t.a?{ahex:t.hex+o.intToHex(t.a)}:t):null!=t.r&&null!=t.g&&null!=t.b?r("rgb"+(null!=t.a?"a":""),t):null!=t.h&&null!=t.s&&null!=t.v&&r("hsv"+(null!=t.a?"a":""),t))},ColorMethods:{hexToRgba:function(e){if(""===e||"none"===e)return{r:null,g:null,b:null,a:null};var t="00",n="00",a="00",r="255";return 6===(e=this.validateHex(e)).length&&(e+="ff"),e.length>6?(t=e.substring(0,2),n=e.substring(2,4),a=e.substring(4,6),r=e.substring(6,e.length)):(e.length>4&&(t=e.substring(4,e.length),e=e.substring(0,4)),e.length>2&&(n=e.substring(2,e.length),e=e.substring(0,2)),e.length>0&&(a=e.substring(0,e.length))),{r:this.hexToInt(t),g:this.hexToInt(n),b:this.hexToInt(a),a:this.hexToInt(r)}},validateHex:function(e){return(e=e.toLowerCase().replace(/[^a-f0-9]/g,"")).length>8&&(e=e.substring(0,8)),e},rgbaToHex:function(e){return this.intToHex(e.r)+this.intToHex(e.g)+this.intToHex(e.b)+this.intToHex(e.a)},intToHex:function(e){var t=(0|e).toString(16);return 1===t.length&&(t="0"+t),t.toLowerCase()},hexToInt:function(e){return parseInt(e,16)},rgbToHsv:function(e){var t,n=e.r/255,a=e.g/255,r=e.b/255,i={h:0,s:0,v:0},o=0,s=0;return n>=a&&n>=r?(s=n,o=a>r?r:a):a>=r&&a>=n?(s=a,o=n>r?r:n):(s=r,o=a>n?n:a),i.v=s,i.s=s?(s-o)/s:0,i.s?(t=s-o,i.h=n===s?(a-r)/t:a===s?2+(r-n)/t:4+(n-a)/t,i.h=parseInt(60*i.h),i.h<0&&(i.h+=360)):i.h=0,i.s=100*i.s|0,i.v=100*i.v|0,i},hsvToRgb:function(e){var t={r:0,g:0,b:0,a:100},n=e.h,a=e.s,r=e.v;if(0===a)t.r=t.g=t.b=0===r?0:255*r/100|0;else{360===n&&(n=0);var i=0|(n/=60),o=n-i,s=(r/=100)*(1-(a/=100)),l=r*(1-a*o),c=r*(1-a*(1-o));switch(i){case 0:t.r=r,t.g=c,t.b=s;break;case 1:t.r=l,t.g=r,t.b=s;break;case 2:t.r=s,t.g=r,t.b=c;break;case 3:t.r=s,t.g=l,t.b=r;break;case 4:t.r=c,t.g=s,t.b=r;break;case 5:t.r=r,t.g=s,t.b=l}t.r=255*t.r|0,t.g=255*t.g|0,t.b=255*t.b|0}return t}}};var a=e.jPicker,r=a.Color,i=a.List,o=a.ColorMethods;return e.fn.jPicker=function(a){var s=arguments;return this.each(function(){var l=this,c=e.extend(!0,{},e.fn.jPicker.defaults,a);"input"===e(l).get(0).nodeName.toLowerCase()&&(e.extend(!0,c,{window:{bindToInput:!0,expandable:!0,input:e(l)}}),""===e(l).val()?(c.color.active=new r({hex:null}),c.color.current=new r({hex:null})):o.validateHex(e(l).val())&&(c.color.active=new r({hex:e(l).val(),a:c.color.active.val("a")}),c.color.current=new r({hex:e(l).val(),a:c.color.active.val("a")}))),c.window.expandable?e(l).after('    '):c.window.liveUpdate=!1;var u=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters;function d(e){var t,n,a=M.active,r=a.val("hex");switch(c.color.mode=e,e){case"h":if(setTimeout(function(){f.call(l,D,"transparent"),v.call(l,U,0),_.call(l,U,100),v.call(l,H,260),_.call(l,H,100),f.call(l,F,"transparent"),v.call(l,q,0),_.call(l,q,100),v.call(l,W,260),_.call(l,W,100),v.call(l,Y,260),_.call(l,Y,100),v.call(l,X,260),_.call(l,X,100),v.call(l,K,260),_.call(l,K,100)},0),Z.range("all",{minX:0,maxX:100,minY:0,maxY:100}),J.range("rangeY",{minY:0,maxY:360}),null==a.val("ahex"))break;Z.val("xy",{x:a.val("s"),y:100-a.val("v")},Z),J.val("y",360-a.val("h"),J);break;case"s":if(setTimeout(function(){f.call(l,D,"transparent"),v.call(l,U,-260),v.call(l,H,-520),v.call(l,q,-260),v.call(l,W,-520),v.call(l,K,260),_.call(l,K,100)},0),Z.range("all",{minX:0,maxX:360,minY:0,maxY:100}),J.range("rangeY",{minY:0,maxY:100}),null==a.val("ahex"))break;Z.val("xy",{x:a.val("h"),y:100-a.val("v")},Z),J.val("y",100-a.val("s"),J);break;case"v":if(setTimeout(function(){f.call(l,D,"000000"),v.call(l,U,-780),v.call(l,H,260),f.call(l,F,r),v.call(l,q,-520),v.call(l,W,260),_.call(l,W,100),v.call(l,K,260),_.call(l,K,100)},0),Z.range("all",{minX:0,maxX:360,minY:0,maxY:100}),J.range("rangeY",{minY:0,maxY:100}),null==a.val("ahex"))break;Z.val("xy",{x:a.val("h"),y:100-a.val("s")},Z),J.val("y",100-a.val("v"),J);break;case"r":if(t=-1040,n=-780,Z.range("all",{minX:0,maxX:255,minY:0,maxY:255}),J.range("rangeY",{minY:0,maxY:255}),null==a.val("ahex"))break;Z.val("xy",{x:a.val("b"),y:255-a.val("g")},Z),J.val("y",255-a.val("r"),J);break;case"g":if(t=-1560,n=-1820,Z.range("all",{minX:0,maxX:255,minY:0,maxY:255}),J.range("rangeY",{minY:0,maxY:255}),null==a.val("ahex"))break;Z.val("xy",{x:a.val("b"),y:255-a.val("r")},Z),J.val("y",255-a.val("g"),J);break;case"b":if(t=-2080,n=-2860,Z.range("all",{minX:0,maxX:255,minY:0,maxY:255}),J.range("rangeY",{minY:0,maxY:255}),null==a.val("ahex"))break;Z.val("xy",{x:a.val("r"),y:255-a.val("g")},Z),J.val("y",255-a.val("b"),J);break;case"a":if(setTimeout(function(){f.call(l,D,"transparent"),v.call(l,U,-260),v.call(l,H,-520),v.call(l,q,260),v.call(l,W,260),_.call(l,W,100),v.call(l,K,0),_.call(l,K,100)},0),Z.range("all",{minX:0,maxX:360,minY:0,maxY:100}),J.range("rangeY",{minY:0,maxY:255}),null==a.val("ahex"))break;Z.val("xy",{x:a.val("h"),y:100-a.val("v")},Z),J.val("y",255-a.val("a"),J);break;default:throw new Error("Invalid Mode")}switch(e){case"h":break;case"s":case"v":case"a":setTimeout(function(){_.call(l,U,100),_.call(l,q,100),v.call(l,Y,260),_.call(l,Y,100),v.call(l,X,260),_.call(l,X,100)},0);break;case"r":case"g":case"b":setTimeout(function(){f.call(l,D,"transparent"),f.call(l,F,"transparent"),_.call(l,q,100),_.call(l,U,100),v.call(l,U,t),v.call(l,H,t-260),v.call(l,q,n-780),v.call(l,W,n-520),v.call(l,Y,n),v.call(l,X,n-260),v.call(l,K,260),_.call(l,K,100)},0)}null!=a.val("ahex")&&h.call(l,a)}function h(e,t){(null==t||t!==J&&t!==Z)&&function(e,t){if(t!==Z)switch(c.color.mode){case"h":var n=e.val("sv");Z.val("xy",{x:null!=n?n.s:100,y:100-(null!=n?n.v:100)},t);break;case"s":case"a":var a=e.val("hv");Z.val("xy",{x:a&&a.h||0,y:100-(null!=a?a.v:100)},t);break;case"v":var r=e.val("hs");Z.val("xy",{x:r&&r.h||0,y:100-(null!=r?r.s:100)},t);break;case"r":var i=e.val("bg");Z.val("xy",{x:i&&i.b||0,y:255-(i&&i.g||0)},t);break;case"g":var o=e.val("br");Z.val("xy",{x:o&&o.b||0,y:255-(o&&o.r||0)},t);break;case"b":var s=e.val("rg");Z.val("xy",{x:s&&s.r||0,y:255-(s&&s.g||0)},t)}if(t!==J)switch(c.color.mode){case"h":J.val("y",360-(e.val("h")||0),t);break;case"s":var l=e.val("s");J.val("y",100-(null!=l?l:100),t);break;case"v":var u=e.val("v");J.val("y",100-(null!=u?u:100),t);break;case"r":J.val("y",255-(e.val("r")||0),t);break;case"g":J.val("y",255-(e.val("g")||0),t);break;case"b":J.val("y",255-(e.val("b")||0),t);break;case"a":var d=e.val("a");J.val("y",255-(null!=d?d:255),t)}}.call(l,e,t),setTimeout(function(){(function(e){try{var t=e.val("all");te.css({backgroundColor:t&&"#"+t.hex||"transparent"}),_.call(l,te,t&&toFixedNumeric(100*t.a/255,4)||0)}catch(e){}}).call(l,e),function(e){switch(c.color.mode){case"h":f.call(l,D,new r({h:e.val("h")||0,s:100,v:100}).val("hex"));break;case"s":case"a":var t=e.val("s");_.call(l,H,100-(null!=t?t:100));break;case"v":var n=e.val("v");_.call(l,U,null!=n?n:100);break;case"r":_.call(l,H,toFixedNumeric((e.val("r")||0)/255*100,4));break;case"g":_.call(l,H,toFixedNumeric((e.val("g")||0)/255*100,4));break;case"b":_.call(l,H,toFixedNumeric((e.val("b")||0)/255*100))}var a=e.val("a");_.call(l,z,toFixedNumeric(100*(255-(a||0))/255,4))}.call(l,e),function(e){switch(c.color.mode){case"h":var t=e.val("a");_.call(l,Q,toFixedNumeric(100*(255-(t||0))/255,4));break;case"s":var n=e.val("hva"),a=new r({h:n&&n.h||0,s:100,v:null!=n?n.v:100});f.call(l,F,a.val("hex")),_.call(l,W,100-(null!=n?n.v:100)),_.call(l,Q,toFixedNumeric(100*(255-(n&&n.a||0))/255,4));break;case"v":var i=e.val("hsa"),o=new r({h:i&&i.h||0,s:null!=i?i.s:100,v:100});f.call(l,F,o.val("hex")),_.call(l,Q,toFixedNumeric(100*(255-(i&&i.a||0))/255,4));break;case"r":case"g":case"b":var s=e.val("rgba"),u=0,d=0;"r"===c.color.mode?(u=s&&s.b||0,d=s&&s.g||0):"g"===c.color.mode?(u=s&&s.b||0,d=s&&s.r||0):"b"===c.color.mode&&(u=s&&s.r||0,d=s&&s.g||0);var h=d>u?u:d;_.call(l,W,u>d?toFixedNumeric((u-d)/(255-d)*100,4):0),_.call(l,Y,d>u?toFixedNumeric((d-u)/(255-u)*100,4):0),_.call(l,X,toFixedNumeric(h/255*100,4)),_.call(l,Q,toFixedNumeric(100*(255-(s&&s.a||0))/255,4));break;case"a":var g=e.val("a");f.call(l,F,e.val("hex")||"000000"),_.call(l,Q,null!=g?0:100),_.call(l,K,null!=g?100:0)}}.call(l,e)},0)}function g(e,t){var n=M.active;if(t===Z||null!=n.val()){var a=e.val("all");switch(c.color.mode){case"h":n.val("sv",{s:a.x,v:100-a.y},t);break;case"s":case"a":n.val("hv",{h:a.x,v:100-a.y},t);break;case"v":n.val("hs",{h:a.x,s:100-a.y},t);break;case"r":n.val("gb",{g:255-a.y,b:a.x},t);break;case"g":n.val("rb",{r:255-a.y,b:a.x},t);break;case"b":n.val("rg",{r:a.x,g:255-a.y},t)}}}function p(e,t){var n=M.active;if(t===J||null!=n.val())switch(c.color.mode){case"h":n.val("h",{h:360-e.val("y")},t);break;case"s":n.val("s",{s:100-e.val("y")},t);break;case"v":n.val("v",{v:100-e.val("y")},t);break;case"r":n.val("r",{r:255-e.val("y")},t);break;case"g":n.val("g",{g:255-e.val("y")},t);break;case"b":n.val("b",{b:255-e.val("y")},t);break;case"a":n.val("a",255-e.val("y"),t)}}function f(e,t){e.css({backgroundColor:t&&6===t.length&&"#"+t||"transparent"})}function m(e,t){u&&(t.includes("AlphaBar.png")||t.includes("Bars.png")||t.includes("Maps.png"))?(e.attr("pngSrc",t),e.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+t+"', sizingMethod='scale')"})):e.css({backgroundImage:"url('"+t+"')"})}function v(e,t){e.css({top:t+"px"})}function _(e,t){if(e.css({visibility:t>0?"visible":"hidden"}),t>0&&t<100)if(u){var n=e.attr("pngSrc");null!=n&&(n.includes("AlphaBar.png")||n.includes("Bars.png")||n.includes("Maps.png"))?e.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+n+"', sizingMethod='scale') progid:DXImageTransform.Microsoft.Alpha(opacity="+t+")"}):e.css({opacity:toFixedNumeric(t/100,4)})}else e.css({opacity:toFixedNumeric(t/100,4)});else if(0===t||100===t)if(u){var a=e.attr("pngSrc");null!=a&&(a.includes("AlphaBar.png")||a.includes("Bars.png")||a.includes("Maps.png"))?e.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+a+"', sizingMethod='scale')"}):e.css({opacity:""})}else e.css({opacity:""})}function b(){M.active.val("ahex",M.current.val("ahex"))}function y(t){e(this).parents("tbody:first").find('input:radio[value!="'+t.target.value+'"]').removeAttr("checked"),d.call(l,t.target.value)}function x(){b.call(l)}function C(){b.call(l),c.window.expandable&&N.call(l),"function"==typeof he&&he.call(l,M.active,re)}function S(){(function(){M.current.val("ahex",M.active.val("ahex"))}).call(l),c.window.expandable&&N.call(l),"function"==typeof ue&&ue.call(l,M.active,ae)}function w(){G.call(l)}function $(e,t){var n=e.val("hex");ne.css({backgroundColor:n&&"#"+n||"transparent"}),_.call(l,ne,toFixedNumeric(100*(e.val("a")||0)/255,4))}function k(e,t){var n=e.val("hex"),a=e.val("va");oe.css({backgroundColor:n&&"#"+n||"transparent"}),_.call(l,se,toFixedNumeric(100*(255-(a&&a.a||0))/255,4)),c.window.bindToInput&&c.window.updateInputColor&&c.window.input.css({backgroundColor:n&&"#"+n||"transparent",color:null==a||a.v>75?"#000000":"#ffffff"})}function A(t){R=parseInt(j.css("left")),O=parseInt(j.css("top")),B=t.pageX,V=t.pageY,e(document).bind("mousemove",E).bind("mouseup",P),t.preventDefault()}function E(t){return j.css({left:R-(B-t.pageX)+"px",top:O-(V-t.pageY)+"px"}),c.window.expandable&&!e.support.boxModel&&j.prev().css({left:j.css("left"),top:j.css("top")}),t.stopPropagation(),t.preventDefault(),!1}function P(t){return e(document).unbind("mousemove",E).unbind("mouseup",P),t.stopPropagation(),t.preventDefault(),!1}function T(t){return t.preventDefault(),t.stopPropagation(),M.active.val("ahex",e(this).attr("title")||null,t.target),!1}function G(){function t(){if(c.window.expandable&&!e.support.boxModel){var t=j.find("table:first");j.before("