').append(svg.clone()).html(), true);\n svgCanvas.ungroupSelectedElement();\n // TODO: To undo the adding of the Formula you now have to undo twice.\n // This should only be once!\n svgCanvas.moveSelectedElements(locationX, locationY, true);\n }\n );\n }\n\n const buttons = [{\n id: 'tool_mathjax',\n type: 'mode',\n icon: 'mathjax.png',\n events: {\n async click () {\n // Set the mode.\n svgCanvas.setMode('mathjax');\n\n // Only load Mathjax when needed, we don't want to strain Svg-Edit any more.\n // From this point on it is very probable that it will be needed, so load it.\n if (mathjaxLoaded === false) {\n $(\n '
' +\n '' +\n '
' +\n '$${}$$' +\n '
' +\n '
' +\n '
' +\n '
' +\n '' +\n '' +\n '
' +\n '
' +\n '
' +\n '
'\n ).insertAfter('#svg_prefs').hide();\n\n // Make the MathEditor draggable.\n $('#mathjax_container').draggable({\n cancel: 'button,fieldset',\n containment: 'window'\n });\n\n // Add functionality and picture to cancel button.\n $('#tool_mathjax_cancel').prepend($.getSvgIcon('cancel', true))\n .on('click touched', function () {\n $('#mathjax').hide();\n });\n\n // Add functionality and picture to the save button.\n $('#tool_mathjax_save').prepend($.getSvgIcon('ok', true))\n .on('click touched', function () {\n saveMath();\n $('#mathjax').hide();\n });\n\n // MathJax preprocessing has to ignore most of the page.\n $('body').addClass('tex2jax_ignore');\n\n try {\n // eslint-disable-next-line node/no-unsupported-features/es-syntax\n await import(mathjaxSrcSecure);\n // When MathJax is loaded get the div where the math will be rendered.\n MathJax.Hub.queue.Push(function () {\n math = MathJax.Hub.getAllJax('#mathjax_creator')[0];\n console.log(math); // eslint-disable-line no-console\n mathjaxLoaded = true;\n console.log('MathJax Loaded'); // eslint-disable-line no-console\n });\n } catch (e) {\n console.log('Failed loading MathJax.'); // eslint-disable-line no-console\n $.alert('Failed loading MathJax. You will not be able to change the mathematics.');\n }\n }\n }\n }\n }];\n\n return {\n name: strings.name,\n svgicons: 'mathjax-icons.xml',\n buttons: strings.buttons.map((button, i) => {\n return Object.assign(buttons[i], button);\n }),\n\n mouseDown () {\n if (svgCanvas.getMode() === 'mathjax') {\n return {started: true};\n }\n return undefined;\n },\n mouseUp (opts) {\n if (svgCanvas.getMode() === 'mathjax') {\n // Get the coordinates from your mouse.\n const zoom = svgCanvas.getZoom();\n // Get the actual coordinate by dividing by the zoom value\n locationX = opts.mouse_x / zoom;\n locationY = opts.mouse_y / zoom;\n\n $('#mathjax').show();\n return {started: false}; // Otherwise the last selected object dissapears.\n }\n return undefined;\n },\n callback () {\n $('').appendTo("head")),t.text(e?" #tool_topath { display: none !important; }":""),r("#polygon_panel").toggle(e)},o=(n=t).canvas,r=e.$,!1,_.next=9,import("./locale/".concat(n.curPrefs.lang,".js"));case 9:return a=_.sent,s=a.default,f=[{id:"tool_polygon",icon:"polygon.png",type:"mode",position:11,events:{click:function click(){o.setMode("polygon"),u(!0)}}}],h=[{type:"input",panel:"polygon_panel",id:"polySides",size:3,defval:5,events:{change:function change(){d("sides",this.value)}}}],_.abrupt("return",{name:s.name,svgicons:"polygon-icons.svg",buttons:s.buttons.map((function(e,t){return Object.assign(f[t],e)})),context_tools:s.contextTools.map((function(e,t){return Object.assign(h[t],e)})),callback:function callback(){r("#polygon_panel").hide(),setTimeout((function(){r("#tool_source_save").clone().hide().attr("id","polygon_save").unbind().appendTo("#tool_source_back").click((function(){})),r("#tool_source_cancel").clone().hide().attr("id","polygon_cancel").unbind().appendTo("#tool_source_back").click((function(){}))}),3e3)},mouseDown:function mouseDown(e){if("polygon"===o.getMode()){var t=o.getColor("fill"),n=o.getColor("stroke"),r=o.getStrokeWidth();return c=!0,i=o.addSVGElementFromJson({element:"polygon",attr:{cx:e.start_x,cy:e.start_y,id:o.getNextId(),shape:"regularPoly",sides:document.getElementById("polySides").value,orient:"x",edge:0,fill:t,strokecolor:n,strokeWidth:r}}),{started:!0}}},mouseMove:function mouseMove(e){if(c&&"polygon"===o.getMode()){var t=r(i).attr(["cx","cy","sides","orient","fill","strokecolor","strokeWidth"]),n=e.mouse_x,a=e.mouse_y,s=t.cx,l=t.cy,u=t.fill,d=t.strokecolor,f=t.strokeWidth,h=t.sides,_=Math.sqrt((n-s)*(n-s)+(a-l)*(a-l))/1.5;i.setAttribute("edge",_);for(var y=_/2*p(Math.PI/h)*g(Math.PI/h),m="",v=0;h>=v;v++){var k=2*Math.PI*v/h;m+=(n=y*Math.cos(k)+s)+","+(a=y*Math.sin(k)+l)+" "}return i.setAttribute("points",m),i.setAttribute("fill",u),i.setAttribute("stroke",d),i.setAttribute("stroke-width",f),{started:!0}}},mouseUp:function mouseUp(e){if("polygon"===o.getMode())return{keep:"0"!==r(i).attr("edge").edge,element:i}},selectedChanged:function selectedChanged(e){for(var t=(l=e.elems).length;t--;){var n=l[t];n&&"regularPoly"===n.getAttribute("shape")&&e.selectedElement&&!e.multiselected?(r("#polySides").val(n.getAttribute("sides")),u(!0)):u(!1)}},elementChanged:function elementChanged(e){}});case 14:case"end":return _.stop()}}),_callee)})))()}};export default e;
+var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}var check=function(t){return t&&t.Math==Math&&t},e=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof t&&t)||Function("return this")(),fails=function(t){try{return!!t()}catch(t){return!0}},r=!fails((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),n={}.propertyIsEnumerable,o=Object.getOwnPropertyDescriptor,i={f:o&&!n.call({1:2},1)?function propertyIsEnumerable(t){var e=o(this,t);return!!e&&e.enumerable}:n},createPropertyDescriptor=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},c={}.toString,classofRaw=function(t){return c.call(t).slice(8,-1)},a="".split,u=fails((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==classofRaw(t)?a.call(t,""):Object(t)}:Object,requireObjectCoercible=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},toIndexedObject=function(t){return u(requireObjectCoercible(t))},isObject=function(t){return"object"==typeof t?null!==t:"function"==typeof t},toPrimitive=function(t,e){if(!isObject(t))return t;var r,n;if(e&&"function"==typeof(r=t.toString)&&!isObject(n=r.call(t)))return n;if("function"==typeof(r=t.valueOf)&&!isObject(n=r.call(t)))return n;if(!e&&"function"==typeof(r=t.toString)&&!isObject(n=r.call(t)))return n;throw TypeError("Can't convert object to primitive value")},f={}.hasOwnProperty,has=function(t,e){return f.call(t,e)},s=e.document,l=isObject(s)&&isObject(s.createElement),documentCreateElement=function(t){return l?s.createElement(t):{}},p=!r&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),h=Object.getOwnPropertyDescriptor,y={f:r?h:function getOwnPropertyDescriptor(t,e){if(t=toIndexedObject(t),e=toPrimitive(e,!0),p)try{return h(t,e)}catch(t){}if(has(t,e))return createPropertyDescriptor(!i.f.call(t,e),t[e])}},anObject=function(t){if(!isObject(t))throw TypeError(String(t)+" is not an object");return t},d=Object.defineProperty,v={f:r?d:function defineProperty(t,e,r){if(anObject(t),e=toPrimitive(e,!0),anObject(r),p)try{return d(t,e,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported");return"value"in r&&(t[e]=r.value),t}},g=r?function(t,e,r){return v.f(t,e,createPropertyDescriptor(1,r))}:function(t,e,r){return t[e]=r,t},setGlobal=function(t,r){try{g(e,t,r)}catch(n){e[t]=r}return r},m=e["__core-js_shared__"]||setGlobal("__core-js_shared__",{}),b=Function.toString;"function"!=typeof m.inspectSource&&(m.inspectSource=function(t){return b.call(t)});var w,S,O,j=m.inspectSource,x=e.WeakMap,E="function"==typeof x&&/native code/.test(j(x)),P=createCommonjsModule((function(t){(t.exports=function(t,e){return m[t]||(m[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),_=0,A=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++_+A).toString(36)},k=P("keys"),sharedKey=function(t){return k[t]||(k[t]=uid(t))},T={},L=e.WeakMap;if(E){var I=new L,M=I.get,C=I.has,G=I.set;w=function(t,e){return G.call(I,t,e),e},S=function(t){return M.call(I,t)||{}},O=function(t){return C.call(I,t)}}else{var N=sharedKey("state");T[N]=!0,w=function(t,e){return g(t,N,e),e},S=function(t){return has(t,N)?t[N]:{}},O=function(t){return has(t,N)}}var R,D={set:w,get:S,has:O,enforce:function(t){return O(t)?S(t):w(t,{})},getterFor:function(t){return function(e){var r;if(!isObject(e)||(r=S(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return r}}},W=createCommonjsModule((function(t){var r=D.get,n=D.enforce,o=String(String).split("String");(t.exports=function(t,r,i,c){var a=!!c&&!!c.unsafe,u=!!c&&!!c.enumerable,f=!!c&&!!c.noTargetGet;"function"==typeof i&&("string"!=typeof r||has(i,"name")||g(i,"name",r),n(i).source=o.join("string"==typeof r?r:"")),t!==e?(a?!f&&t[r]&&(u=!0):delete t[r],u?t[r]=i:g(t,r,i)):u?t[r]=i:setGlobal(r,i)})(Function.prototype,"toString",(function toString(){return"function"==typeof this&&r(this).source||j(this)}))})),q=e,aFunction=function(t){return"function"==typeof t?t:void 0},getBuiltIn=function(t,r){return arguments.length<2?aFunction(q[t])||aFunction(e[t]):q[t]&&q[t][r]||e[t]&&e[t][r]},V=Math.ceil,z=Math.floor,toInteger=function(t){return isNaN(t=+t)?0:(t>0?z:V)(t)},B=Math.min,toLength=function(t){return t>0?B(toInteger(t),9007199254740991):0},U=Math.max,Y=Math.min,toAbsoluteIndex=function(t,e){var r=toInteger(t);return r<0?U(r+e,0):Y(r,e)},createMethod=function(t){return function(e,r,n){var o,i=toIndexedObject(e),c=toLength(i.length),a=toAbsoluteIndex(n,c);if(t&&r!=r){for(;c>a;)if((o=i[a++])!=o)return!0}else for(;c>a;a++)if((t||a in i)&&i[a]===r)return t||a||0;return!t&&-1}},H={includes:createMethod(!0),indexOf:createMethod(!1)}.indexOf,objectKeysInternal=function(t,e){var r,n=toIndexedObject(t),o=0,i=[];for(r in n)!has(T,r)&&has(n,r)&&i.push(r);for(;e.length>o;)has(n,r=e[o++])&&(~H(i,r)||i.push(r));return i},J=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],$=J.concat("length","prototype"),K={f:Object.getOwnPropertyNames||function getOwnPropertyNames(t){return objectKeysInternal(t,$)}},Q={f:Object.getOwnPropertySymbols},X=getBuiltIn("Reflect","ownKeys")||function ownKeys(t){var e=K.f(anObject(t)),r=Q.f;return r?e.concat(r(t)):e},copyConstructorProperties=function(t,e){for(var r=X(e),n=v.f,o=y.f,i=0;i
i;)v.f(t,r=n[i++],e[r]);return t},ht=getBuiltIn("document","documentElement"),yt=sharedKey("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(t){return"