text: var SvgCanvas=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function n(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var r=[],n=!0,i=!1,a=void 0;try{for(var s,o=e[Symbol.iterator]();!(n=(s=o.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,a=e}finally{try{n||null==o.return||o.return()}finally{if(i)throw a}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function l(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function h(t){var r=t.fn.attr;return t.fn.attr=function(t,n){var i=this.length;if(!i)return r.call(this,t,n);for(var a=0;a<i;++a){var s=this[a];if("http://www.w3.org/2000/svg"!==s.namespaceURI)return r.call(this,t,n);if(void 0!==n)s.setAttribute(t,n);else if(Array.isArray(t)){for(var o={},l=t.length;l--;){var h=t[l],c=s.getAttribute(h);(c||"0"===c)&&(c=isNaN(c)?c:c-0),o[h]=c}return o}if("object"!==e(t)){var d=s.getAttribute(t);return(d||"0"===d)&&(d=isNaN(d)?d:d-0),d}for(var m=0,f=Object.entries(t);m<f.length;m++){var g=u(f[m],2),p=g[0],y=g[1];s.setAttribute(p,y)}}return this},t}!function(){if(!("SVGPathSeg"in window)){var e=function(){function e(r,n,i){t(this,e),this.pathSegType=r,this.pathSegTypeAsLetter=n,this._owningPathSegList=i}return n(e,[{key:"_segmentChanged",value:function(){this._owningPathSegList&&this._owningPathSegList.segmentChanged(this)}}]),e}();e.prototype.classname="SVGPathSeg",e.PATHSEG_UNKNOWN=0,e.PATHSEG_CLOSEPATH=1,e.PATHSEG_MOVETO_ABS=2,e.PATHSEG_MOVETO_REL=3,e.PATHSEG_LINETO_ABS=4,e.PATHSEG_LINETO_REL=5,e.PATHSEG_CURVETO_CUBIC_ABS=6,e.PATHSEG_CURVETO_CUBIC_REL=7,e.PATHSEG_CURVETO_QUADRATIC_ABS=8,e.PATHSEG_CURVETO_QUADRATIC_REL=9,e.PATHSEG_ARC_ABS=10,e.PATHSEG_ARC_REL=11,e.PATHSEG_LINETO_HORIZONTAL_ABS=12,e.PATHSEG_LINETO_HORIZONTAL_REL=13,e.PATHSEG_LINETO_VERTICAL_ABS=14,e.PATHSEG_LINETO_VERTICAL_REL=15,e.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS=16,e.PATHSEG_CURVETO_CUBIC_SMOOTH_REL=17,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS=18,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL=19;var r=function(r){function s(r){return t(this,s),o(this,a(s).call(this,e.PATHSEG_CLOSEPATH,"z",r))}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegClosePath]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter}},{key:"clone",value:function(){return new s(void 0)}}]),s}(e),s=function(r){function s(r,n,i){var u;return t(this,s),(u=o(this,a(s).call(this,e.PATHSEG_MOVETO_ABS,"M",r)))._x=n,u._y=i,u}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegMovetoAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._x,this._y)}}]),s}(e);Object.defineProperties(s.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var u=function(r){function s(r,n,i){var u;return t(this,s),(u=o(this,a(s).call(this,e.PATHSEG_MOVETO_REL,"m",r)))._x=n,u._y=i,u}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegMovetoRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._x,this._y)}}]),s}(e);Object.defineProperties(u.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var l=function(r){function s(r,n,i){var u;return t(this,s),(u=o(this,a(s).call(this,e.PATHSEG_LINETO_ABS,"L",r)))._x=n,u._y=i,u}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegLinetoAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._x,this._y)}}]),s}(e);Object.defineProperties(l.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var h=function(r){function s(r,n,i){var u;return t(this,s),(u=o(this,a(s).call(this,e.PATHSEG_LINETO_REL,"l",r)))._x=n,u._y=i,u}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegLinetoRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._x,this._y)}}]),s}(e);Object.defineProperties(h.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var c=function(r){function s(r,n,i,u,l,h,c){var d;return t(this,s),(d=o(this,a(s).call(this,e.PATHSEG_CURVETO_CUBIC_ABS,"C",r)))._x=n,d._y=i,d._x1=u,d._y1=l,d._x2=h,d._y2=c,d}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)}}]),s}(e);Object.defineProperties(c.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var d=function(r){function s(r,n,i,u,l,h,c){var d;return t(this,s),(d=o(this,a(s).call(this,e.PATHSEG_CURVETO_CUBIC_REL,"c",r)))._x=n,d._y=i,d._x1=u,d._y1=l,d._x2=h,d._y2=c,d}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)}}]),s}(e);Object.defineProperties(d.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var m=function(r){function s(r,n,i,u,l){var h;return t(this,s),(h=o(this,a(s).call(this,e.PATHSEG_CURVETO_QUADRATIC_ABS,"Q",r)))._x=n,h._y=i,h._x1=u,h._y1=l,h}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._x,this._y,this._x1,this._y1)}}]),s}(e);Object.defineProperties(m.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0}});var f=function(r){function s(r,n,i,u,l){var h;return t(this,s),(h=o(this,a(s).call(this,e.PATHSEG_CURVETO_QUADRATIC_REL,"q",r)))._x=n,h._y=i,h._x1=u,h._y1=l,h}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._x,this._y,this._x1,this._y1)}}]),s}(e);Object.defineProperties(f.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0}});var g=function(r){function s(r,n,i,u,l,h,c,d){var m;return t(this,s),(m=o(this,a(s).call(this,e.PATHSEG_ARC_ABS,"A",r)))._x=n,m._y=i,m._r1=u,m._r2=l,m._angle=h,m._largeArcFlag=c,m._sweepFlag=d,m}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegArcAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)}}]),s}(e);Object.defineProperties(g.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},r1:{get:function(){return this._r1},set:function(e){this._r1=e,this._segmentChanged()},enumerable:!0},r2:{get:function(){return this._r2},set:function(e){this._r2=e,this._segmentChanged()},enumerable:!0},angle:{get:function(){return this._angle},set:function(e){this._angle=e,this._segmentChanged()},enumerable:!0},largeArcFlag:{get:function(){return this._largeArcFlag},set:function(e){this._largeArcFlag=e,this._segmentChanged()},enumerable:!0},sweepFlag:{get:function(){return this._sweepFlag},set:function(e){this._sweepFlag=e,this._segmentChanged()},enumerable:!0}});var p=function(r){function s(r,n,i,u,l,h,c,d){var m;return t(this,s),(m=o(this,a(s).call(this,e.PATHSEG_ARC_REL,"a",r)))._x=n,m._y=i,m._r1=u,m._r2=l,m._angle=h,m._largeArcFlag=c,m._sweepFlag=d,m}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegArcRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)}}]),s}(e);Object.defineProperties(p.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},r1:{get:function(){return this._r1},set:function(e){this._r1=e,this._segmentChanged()},enumerable:!0},r2:{get:function(){return this._r2},set:function(e){this._r2=e,this._segmentChanged()},enumerable:!0},angle:{get:function(){return this._angle},set:function(e){this._angle=e,this._segmentChanged()},enumerable:!0},largeArcFlag:{get:function(){return this._largeArcFlag},set:function(e){this._largeArcFlag=e,this._segmentChanged()},enumerable:!0},sweepFlag:{get:function(){return this._sweepFlag},set:function(e){this._sweepFlag=e,this._segmentChanged()},enumerable:!0}});var y=function(r){function s(r,n){var i;return t(this,s),(i=o(this,a(s).call(this,e.PATHSEG_LINETO_HORIZONTAL_ABS,"H",r)))._x=n,i}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegLinetoHorizontalAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x}},{key:"clone",value:function(){return new s(void 0,this._x)}}]),s}(e);Object.defineProperty(y.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0});var v=function(r){function s(r,n){var i;return t(this,s),(i=o(this,a(s).call(this,e.PATHSEG_LINETO_HORIZONTAL_REL,"h",r)))._x=n,i}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegLinetoHorizontalRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x}},{key:"clone",value:function(){return new s(void 0,this._x)}}]),s}(e);Object.defineProperty(v.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0});var x=function(r){function s(r,n){var i;return t(this,s),(i=o(this,a(s).call(this,e.PATHSEG_LINETO_VERTICAL_ABS,"V",r)))._y=n,i}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegLinetoVerticalAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._y)}}]),s}(e);Object.defineProperty(x.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0});var _=function(r){function s(r,n){var i;return t(this,s),(i=o(this,a(s).call(this,e.PATHSEG_LINETO_VERTICAL_REL,"v",r)))._y=n,i}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegLinetoVerticalRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._y)}}]),s}(e);Object.defineProperty(_.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0});var S=function(r){function s(r,n,i,u,l){var h;return t(this,s),(h=o(this,a(s).call(this,e.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS,"S",r)))._x=n,h._y=i,h._x2=u,h._y2=l,h}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicSmoothAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._x,this._y,this._x2,this._y2)}}]),s}(e);Object.defineProperties(S.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var b=function(r){function s(r,n,i,u,l){var h;return t(this,s),(h=o(this,a(s).call(this,e.PATHSEG_CURVETO_CUBIC_SMOOTH_REL,"s",r)))._x=n,h._y=i,h._x2=u,h._y2=l,h}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicSmoothRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._x,this._y,this._x2,this._y2)}}]),s}(e);Object.defineProperties(b.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var w=function(r){function s(r,n,i){var u;return t(this,s),(u=o(this,a(s).call(this,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS,"T",r)))._x=n,u._y=i,u}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticSmoothAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._x,this._y)}}]),s}(e);Object.defineProperties(w.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var A=function(r){function s(r,n,i){var u;return t(this,s),(u=o(this,a(s).call(this,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL,"t",r)))._x=n,u._y=i,u}return i(s,r),n(s,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticSmoothRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new s(void 0,this._x,this._y)}}]),s}(e);Object.defineProperties(A.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}}),SVGPathElement.prototype.createSVGPathSegClosePath=function(){return new r(void 0)},SVGPathElement.prototype.createSVGPathSegMovetoAbs=function(e,t){return new s(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegMovetoRel=function(e,t){return new u(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegLinetoAbs=function(e,t){return new l(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegLinetoRel=function(e,t){return new h(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs=function(e,t,r,n,i,a){return new c(void 0,e,t,r,n,i,a)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel=function(e,t,r,n,i,a){return new d(void 0,e,t,r,n,i,a)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs=function(e,t,r,n){return new m(void 0,e,t,r,n)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel=function(e,t,r,n){return new f(void 0,e,t,r,n)},SVGPathElement.prototype.createSVGPathSegArcAbs=function(e,t,r,n,i,a,s){return new g(void 0,e,t,r,n,i,a,s)},SVGPathElement.prototype.createSVGPathSegArcRel=function(e,t,r,n,i,a,s){return new p(void 0,e,t,r,n,i,a,s)},SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs=function(e){return new y(void 0,e)},SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel=function(e){return new v(void 0,e)},SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs=function(e){return new x(void 0,e)},SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel=function(e){return new _(void 0,e)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs=function(e,t,r,n){return new S(void 0,e,t,r,n)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel=function(e,t,r,n){return new b(void 0,e,t,r,n)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs=function(e,t){return new w(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel=function(e,t){return new A(void 0,e,t)},"getPathSegAtLength"in SVGPathElement.prototype||(SVGPathElement.prototype.getPathSegAtLength=function(e){if(void 0===e||!isFinite(e))throw new Error("Invalid arguments.");var t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d",this.getAttribute("d"));var r=t.pathSegList.numberOfItems-1;if(r<=0)return 0;do{if(t.pathSegList.removeItem(r),e>t.getTotalLength())break;r--}while(r>0);return r}),window.SVGPathSeg=e,window.SVGPathSegClosePath=r,window.SVGPathSegMovetoAbs=s,window.SVGPathSegMovetoRel=u,window.SVGPathSegLinetoAbs=l,window.SVGPathSegLinetoRel=h,window.SVGPathSegCurvetoCubicAbs=c,window.SVGPathSegCurvetoCubicRel=d,window.SVGPathSegCurvetoQuadraticAbs=m,window.SVGPathSegCurvetoQuadraticRel=f,window.SVGPathSegArcAbs=g,window.SVGPathSegArcRel=p,window.SVGPathSegLinetoHorizontalAbs=y,window.SVGPathSegLinetoHorizontalRel=v,window.SVGPathSegLinetoVerticalAbs=x,window.SVGPathSegLinetoVerticalRel=_,window.SVGPathSegCurvetoCubicSmoothAbs=S,window.SVGPathSegCurvetoCubicSmoothRel=b,window.SVGPathSegCurvetoQuadraticSmoothAbs=w,window.SVGPathSegCurvetoQuadraticSmoothRel=A}if(!("SVGPathSegList"in window&&"appendItem"in window.SVGPathSegList.prototype)){var k=function(){function e(r){t(this,e),this._pathElement=r,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 n(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 r=this,i=function(){function e(){t(this,e),this.pathSegList=[]}return n(e,[{key:"appendSegment",value:function(e){this.pathSegList.push(e)}}]),e}(),a=function(){function e(r){t(this,e),this._string=r,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()}return n(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<this._endIndex&&this._isCurrentSpace();)this._currentIndex++;return this._currentIndex<this._endIndex}},{key:"_skipOptionalSpacesOrDelimiter",value:function(){return!(this._currentIndex<this._endIndex&&!this._isCurrentSpace()&&","!==this._string.charAt(this._currentIndex))&&(this._skipOptionalSpaces()&&this._currentIndex<this._endIndex&&","===this._string.charAt(this._currentIndex)&&(this._currentIndex++,this._skipOptionalSpaces()),this._currentIndex<this._endIndex)}},{key:"hasMoreData",value:function(){return this._currentIndex<this._endIndex}},{key:"peekSegmentType",value:function(){var e=this._string[this._currentIndex];return this._pathSegTypeFromChar(e)}},{key:"_pathSegTypeFromChar",value:function(e){switch(e){case"Z":case"z":return SVGPathSeg.PATHSEG_CLOSEPATH;case"M":return SVGPathSeg.PATHSEG_MOVETO_ABS;case"m":return SVGPathSeg.PATHSEG_MOVETO_REL;case"L":return SVGPathSeg.PATHSEG_LINETO_ABS;case"l":return SVGPathSeg.PATHSEG_LINETO_REL;case"C":return SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS;case"c":return SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL;case"Q":return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;case"q":return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;case"A":return SVGPathSeg.PATHSEG_ARC_ABS;case"a":return SVGPathSeg.PATHSEG_ARC_REL;case"H":return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;case"h":return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;case"V":return SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;case"v":return SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;case"S":return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;case"s":return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;case"T":return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;case"t":return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;default:return SVGPathSeg.PATHSEG_UNKNOWN}}},{key:"_nextCommandHelper",value:function(e,t){return("+"===e||"-"===e||"."===e||e>="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,r=1,n=0,i=1,a=1,s=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex<this._endIndex&&"+"===this._string.charAt(this._currentIndex)?this._currentIndex++:this._currentIndex<this._endIndex&&"-"===this._string.charAt(this._currentIndex)&&(this._currentIndex++,i=-1),!(this._currentIndex===this._endIndex||(this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")&&"."!==this._string.charAt(this._currentIndex))){for(var o=this._currentIndex;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!==o)for(var u=this._currentIndex-1,l=1;u>=o;)t+=l*(this._string.charAt(u--)-"0"),l*=10;if(this._currentIndex<this._endIndex&&"."===this._string.charAt(this._currentIndex)){if(this._currentIndex++,this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)r*=10,n+=(this._string.charAt(this._currentIndex)-"0")/r,this._currentIndex+=1}if(this._currentIndex!==s&&this._currentIndex+1<this._endIndex&&("e"===this._string.charAt(this._currentIndex)||"E"===this._string.charAt(this._currentIndex))&&"x"!==this._string.charAt(this._currentIndex+1)&&"m"!==this._string.charAt(this._currentIndex+1)){if(this._currentIndex++,"+"===this._string.charAt(this._currentIndex)?this._currentIndex++:"-"===this._string.charAt(this._currentIndex)&&(this._currentIndex++,a=-1),this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)e*=10,e+=this._string.charAt(this._currentIndex)-"0",this._currentIndex++}var h=t+n;if(h*=i,e&&(h*=Math.pow(10,a*e)),s!==this._currentIndex)return this._skipOptionalSpacesOrDelimiter(),h}}},{key:"_parseArcFlag",value:function(){if(!(this._currentIndex>=this._endIndex)){var e=!1,t=this._string.charAt(this._currentIndex++);if("0"===t)e=!1;else{if("1"!==t)return;e=!0}return this._skipOptionalSpacesOrDelimiter(),e}}},{key:"parseSegment",value:function(){var e=this._string[this._currentIndex],t=this._pathSegTypeFromChar(e);if(t===SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand===SVGPathSeg.PATHSEG_UNKNOWN)return null;if((t=this._nextCommandHelper(e,this._previousCommand))===SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=t,t){case SVGPathSeg.PATHSEG_MOVETO_REL:return new SVGPathSegMovetoRel(r,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_MOVETO_ABS:return new SVGPathSegMovetoAbs(r,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_REL:return new SVGPathSegLinetoRel(r,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_ABS:return new SVGPathSegLinetoAbs(r,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new SVGPathSegLinetoHorizontalRel(r,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new SVGPathSegLinetoHorizontalAbs(r,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new SVGPathSegLinetoVerticalRel(r,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new SVGPathSegLinetoVerticalAbs(r,this._parseNumber());case SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new SVGPathSegClosePath(r);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:var n={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicRel(r,n.x,n.y,n.x1,n.y1,n.x2,n.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:var i={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicAbs(r,i.x,i.y,i.x1,i.y1,i.x2,i.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:var a={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothRel(r,a.x,a.y,a.x2,a.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:var s={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothAbs(r,s.x,s.y,s.x2,s.y2);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:var o={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticRel(r,o.x,o.y,o.x1,o.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:var u={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticAbs(r,u.x,u.y,u.x1,u.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new SVGPathSegCurvetoQuadraticSmoothRel(r,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new SVGPathSegCurvetoQuadraticSmoothAbs(r,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_ARC_REL:var l={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegArcRel(r,l.x,l.y,l.x1,l.y1,l.arcAngle,l.arcLarge,l.arcSweep);case SVGPathSeg.PATHSEG_ARC_ABS:var h={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegArcAbs(r,h.x,h.y,h.x1,h.y1,h.arcAngle,h.arcLarge,h.arcSweep);default:throw new Error("Unknown path seg type.")}}}]),e}(),s=new i,o=new a(e);if(!o.initialCommandIsMoveTo())return[];for(;o.hasMoreData();){var u=o.parseSegment();if(!u)return[];s.appendSegment(u)}return s.pathSegList}}],[{key:"_pathSegArrayAsString",value:function(e){var t="",r=!0;return e.forEach((function(e){r?(r=!1,t+=e._asPathString()):t+=" "+e._asPathString()})),t}}]),e}();k.prototype.classname="SVGPathSegList",Object.defineProperty(k.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperties(SVGPathElement.prototype,{pathSegList:{get:function(){return this._pathSegList||(this._pathSegList=new k(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=k}}();var c,d={HTML:"http://www.w3.org/1999/xhtml",MATH:"http://www.w3.org/1998/Math/MathML",SE:"http://svg-edit.googlecode.com",SVG:"http://www.w3.org/2000/svg",XLINK:"http://www.w3.org/1999/xlink",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"},m=function(){var e={};return Object.entries(d).forEach((function(t){var r=u(t,2),n=r[0],i=r[1];e[i]=n.toLowerCase()})),e},f=jQuery,g=(Boolean(document.createElementNS&&document.createElementNS(d.SVG,"svg").createSVGRect),navigator.userAgent),p=document.createElementNS(d.SVG,"svg"),y=Boolean(window.opera),v=g.includes("AppleWebKit"),x=g.includes("Gecko/"),_=g.includes("MSIE"),S=g.includes("Chrome/"),b=(g.includes("Windows"),g.includes("Macintosh"),"ontouchstart"in window),w=Boolean(p.querySelector),A=Boolean(document.evaluate),k=function(){var e=document.createElementNS(d.SVG,"path");e.setAttribute("d","M0,0 10,10");var t=e.pathSegList,r=e.createSVGPathSegLinetoAbs(5,5);try{return t.replaceItem(r,1),!0}catch(e){}return!1}(),C=function(){var e=document.createElementNS(d.SVG,"path");e.setAttribute("d","M0,0 10,10");var t=e.pathSegList,r=e.createSVGPathSegLinetoAbs(5,5);try{return t.insertItemBefore(r,1),!0}catch(e){}return!1}(),E=function(){var e=document.createElementNS(d.SVG,"svg"),t=document.createElementNS(d.SVG,"svg");document.documentElement.append(e),t.setAttribute("x",5),e.append(t);var r=document.createElementNS(d.SVG,"text");r.textContent="a",t.append(r);try{return 0===r.getStartPositionOfChar(0).x}catch(e){return!1}finally{e.remove()}}(),P=function(){var e=document.createElementNS(d.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(d.SVG,"path");t.setAttribute("d","M0,0 C0,0 10,10 10,0"),e.append(t);var r=t.getBBox();return e.remove(),r.height>4&&r.height<5}(),G=function(){var e=document.createElementNS(d.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(d.SVG,"path");t.setAttribute("d","M0,0 10,0");var r=document.createElementNS(d.SVG,"path");r.setAttribute("d","M5,0 15,0");var n=document.createElementNS(d.SVG,"g");n.append(t,r),e.append(n);var i=n.getBBox();return e.remove(),15===i.width}(),N=(function(){var e=document.createElementNS(d.SVG,"rect");e.setAttribute("x",.1);var t=!e.cloneNode(!1).getAttribute("x").includes(",");t||f.alert('NOTE: This version of Opera is known to contain bugs in SVG-edit.\nPlease upgrade to the <a href="http://opera.com">latest version</a> in which the problems have been fixed.')}(),(c=document.createElementNS(d.SVG,"rect")).setAttribute("style","vector-effect:non-scaling-stroke"),"non-scaling-stroke"===c.style.vectorEffect),I=function(){var t=document.createElementNS(d.SVG,"rect").transform.baseVal,r=p.createSVGTransform();t.appendItem(r);var n=t.getItem(0),i=function(t){return t&&"object"===e(t)&&"function"==typeof t.setMatrix&&"angle"in t};return i(n)&&i(r)&&n.type===r.type&&n.angle===r.angle&&n.matrix.a===r.matrix.a&&n.matrix.b===r.matrix.b&&n.matrix.c===r.matrix.c&&n.matrix.d===r.matrix.d&&n.matrix.e===r.matrix.e&&n.matrix.f===r.matrix.f}(),T=function(){return y},L=function(){return v},V=function(){return x},O=function(){return _},M=function(){return S},R=function(){return G},B=function(){return N},U=document.createElementNS(d.SVG,"svg");function H(e){var t=e.matrix,r="";switch(e.type){case 1:r="matrix("+[t.a,t.b,t.c,t.d,t.e,t.f].join(",")+")";break;case 2:r="translate("+t.e+","+t.f+")";break;case 3:r=t.a===t.d?"scale("+t.a+")":"scale("+t.a+","+t.d+")";break;case 4:var n=0,i=0;if(0!==e.angle){var a=1-t.a;i=(a*t.f+t.b*t.e)/(a*a+t.b*t.b),n=(t.e-t.b*i)/a}r="rotate("+e.angle+" "+n+","+i+")"}return r}var j,F={},D=function(){function e(r){t(this,e),this._elem=r||null,this._xforms=[],this._update=function(){for(var e="",t=0;t<this.numberOfItems;++t){e+=H(this._list.getItem(t))+" "}this._elem.setAttribute("transform",e)},this._list=this,this._init=function(){var e=this,t=this._elem.getAttribute("transform");if(t)for(var r=/\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/,n=!0;n;)n=t.match(r),t=t.replace(r,""),n&&n[1]&&function(){var t=n[1].split(/\s*\(/),r=t[0],i=t[1].match(/\s*(.*?)\s*\)/);i[1]=i[1].replace(/(\d)-/g,"$1 -");var a=i[1].split(/[, ]+/),s="abcdef".split(""),o=U.createSVGMatrix();Object.values(a).forEach((function(e,t){a[t]=parseFloat(e),"matrix"===r&&(o[s[t]]=a[t])}));var u=U.createSVGTransform(),h="set"+r.charAt(0).toUpperCase()+r.slice(1),c="matrix"===r?[o]:a;"scale"===r&&1===c.length?c.push(c[0]):"translate"===r&&1===c.length?c.push(0):"rotate"===r&&1===c.length&&c.push(0,0),u[h].apply(u,l(c)),e._list.appendItem(u)}()},this._removeFromOtherLists=function(e){e&&Object.values(F).some((function(t){for(var r=0,n=t._xforms.length;r<n;++r)if(t._xforms[r]===e)return t.removeItem(r),!0;return!1}))},this.numberOfItems=0}return n(e,[{key:"clear",value:function(){this.numberOfItems=0,this._xforms=[]}},{key:"initialize",value:function(e){this.numberOfItems=1,this._removeFromOtherLists(e),this._xforms=[e]}},{key:"getItem",value:function(e){if(e<this.numberOfItems&&e>=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 r=null;if(t>=0)if(t<this.numberOfItems){this._removeFromOtherLists(e);var n,i=new Array(this.numberOfItems+1);for(n=0;n<t;++n)i[n]=this._xforms[n];i[n]=e;for(var a=n+1;n<this.numberOfItems;++a,++n)i[a]=this._xforms[n];this.numberOfItems++,this._xforms=i,r=e,this._list._update()}else r=this._list.appendItem(e);return r}},{key:"replaceItem",value:function(e,t){var r=null;return t<this.numberOfItems&&t>=0&&(this._removeFromOtherLists(e),this._xforms[t]=e,r=e,this._list._update()),r}},{key:"removeItem",value:function(e){if(e<this.numberOfItems&&e>=0){var t,r=this._xforms[e],n=new Array(this.numberOfItems-1);for(t=0;t<e;++t)n[t]=this._xforms[t];for(var i=t;i<this.numberOfItems-1;++i,++t)n[i]=this._xforms[t+1];return this.numberOfItems--,this._xforms=n,this._list._update(),r}var a=new Error("DOMException with code=INDEX_SIZE_ERR");throw a.code=1,a}},{key:"appendItem",value:function(e){return this._removeFromOtherLists(e),this._xforms.push(e),this.numberOfItems++,this._list._update(),e}}]),e}(),z=function(e){e.id&&F[e.id]&&delete F[e.id]},q=function(e){if(!I){var t=e.id||"temp",r=F[t];return r&&"temp"!==t||(F[t]=new D(e),F[t]._init(),r=F[t]),r}return e.transform?e.transform.baseVal:e.gradientTransform?e.gradientTransform.baseVal:e.patternTransform?e.patternTransform.baseVal:null},W=["x","x1","cx","rx","width"],Q=["y","y1","cy","ry","height"],Y={},Z=function(){return Y},X=function e(t){var r=j.getRoundDigits();return isNaN(t)?Array.isArray(t)?e(t[0])+","+e(t[1]):parseFloat(t).toFixed(r)-0:Number(Number(t).toFixed(r))},K=function(e,t){return t=t||j.getBaseUnit(),X(e/Y[t])},$=function(e,t,r){e.setAttribute(t,r)},J=function(e,t){if(!isNaN(t))return t-0;if("%"===t.substr(-1)){var r=t.substr(0,t.length-1)/100,n=j.getWidth(),i=j.getHeight();return W.includes(e)?r*n:Q.includes(e)?r*i:r*Math.sqrt(n*n+i*i)/Math.sqrt(2)}var a=t.substr(-2);return t.substr(0,t.length-2)*Y[a]},ee={BEFORE_APPLY:"before_apply",AFTER_APPLY:"after_apply",BEFORE_UNAPPLY:"before_unapply",AFTER_UNAPPLY:"after_unapply"},te=function(){function e(){t(this,e)}return n(e,[{key:"getText",value:function(){return this.text}}]),e}(),re=function(e){function r(e,n,i,s){var u;return t(this,r),(u=o(this,a(r).call(this))).elem=e,u.text=s?"Move "+e.tagName+" to "+s:"Move "+e.tagName,u.oldNextSibling=n,u.oldParent=i,u.newNextSibling=e.nextSibling,u.newParent=e.parentNode,u}return i(r,e),n(r,[{key:"type",value:function(){return"svgedit.history.MoveElementCommand"}},{key:"apply",value:function(e){e&&e.handleHistoryEvent(ee.BEFORE_APPLY,this),this.elem=this.newParent.insertBefore(this.elem,this.newNextSibling),e&&e.handleHistoryEvent(ee.AFTER_APPLY,this)}},{key:"unapply",value:function(e){e&&e.handleHistoryEvent(ee.BEFORE_UNAPPLY,this),this.elem=this.oldParent.insertBefore(this.elem,this.oldNextSibling),e&&e.handleHistoryEvent(ee.AFTER_UNAPPLY,this)}},{key:"elements",value:function(){return[this.elem]}}]),r}(te);re.type=re.prototype.type;var ne=function(e){function r(e,n){var i;return t(this,r),(i=o(this,a(r).call(this))).elem=e,i.text=n||"Create "+e.tagName,i.parent=e.parentNode,i.nextSibling=i.elem.nextSibling,i}return i(r,e),n(r,[{key:"type",value:function(){return"svgedit.history.InsertElementCommand"}},{key:"apply",value:function(e){e&&e.handleHistoryEvent(ee.BEFORE_APPLY,this),this.elem=this.parent.insertBefore(this.elem,this.nextSibling),e&&e.handleHistoryEvent(ee.AFTER_APPLY,this)}},{key:"unapply",value:function(e){e&&e.handleHistoryEvent(ee.BEFORE_UNAPPLY,this),this.parent=this.elem.parentNode,this.elem=this.elem.parentNode.removeChild(this.elem),e&&e.handleHistoryEvent(ee.AFTER_UNAPPLY,this)}},{key:"elements",value:function(){return[this.elem]}}]),r}(te);ne.type=ne.prototype.type;var ie=function(e){function r(e,n,i,s){var u;return t(this,r),(u=o(this,a(r).call(this))).elem=e,u.text=s||"Delete "+e.tagName,u.nextSibling=n,u.parent=i,z(e),u}return i(r,e),n(r,[{key:"type",value:function(){return"svgedit.history.RemoveElementCommand"}},{key:"apply",value:function(e){e&&e.handleHistoryEvent(ee.BEFORE_APPLY,this),z(this.elem),this.parent=this.elem.parentNode,this.elem=this.parent.removeChild(this.elem),e&&e.handleHistoryEvent(ee.AFTER_APPLY,this)}},{key:"unapply",value:function(e){e&&e.handleHistoryEvent(ee.BEFORE_UNAPPLY,this),z(this.elem),Yt(this.nextSibling)&&window.console&&console.log("Error: reference element was lost"),this.parent.insertBefore(this.elem,this.nextSibling),e&&e.handleHistoryEvent(ee.AFTER_UNAPPLY,this)}},{key:"elements",value:function(){return[this.elem]}}]),r}(te);ie.type=ie.prototype.type;var ae=function(e){function r(e,n,i){var s;for(var u in t(this,r),(s=o(this,a(r).call(this))).elem=e,s.text=i?"Change "+e.tagName+" "+i:"Change "+e.tagName,s.newValues={},s.oldValues=n,n)s.newValues[u]="#text"===u?e.textContent:"#href"===u?kt(e):e.getAttribute(u);return s}return i(r,e),n(r,[{key:"type",value:function(){return"svgedit.history.ChangeElementCommand"}},{key:"apply",value:function(e){var t=this;e&&e.handleHistoryEvent(ee.BEFORE_APPLY,this);var r=!1;if(Object.entries(this.newValues).forEach((function(e){var n=u(e,2),i=n[0],a=n[1];a?"#text"===i?t.elem.textContent=a:"#href"===i?Ct(t.elem,a):t.elem.setAttribute(i,a):"#text"===i?t.elem.textContent="":(t.elem.setAttribute(i,""),t.elem.removeAttribute(i)),"transform"===i&&(r=!0)})),!r){var n=jt(this.elem);if(n){var i=this.elem.getBBox(),a=["rotate(",n," ",i.x+i.width/2,",",i.y+i.height/2,")"].join("");a!==this.elem.getAttribute("transform")&&this.elem.setAttribute("transform",a)}}return e&&e.handleHistoryEvent(ee.AFTER_APPLY,this),!0}},{key:"unapply",value:function(e){var t=this;e&&e.handleHistoryEvent(ee.BEFORE_UNAPPLY,this);var r=!1;if(Object.entries(this.oldValues).forEach((function(e){var n=u(e,2),i=n[0],a=n[1];a?"#text"===i?t.elem.textContent=a:"#href"===i?Ct(t.elem,a):t.elem.setAttribute(i,a):"#text"===i?t.elem.textContent="":t.elem.removeAttribute(i),"transform"===i&&(r=!0)})),!r){var n=jt(this.elem);if(n){var i=this.elem.getBBox(),a=["rotate(",n," ",i.x+i.width/2,",",i.y+i.height/2,")"].join("");a!==this.elem.getAttribute("transform")&&this.elem.setAttribute("transform",a)}}return z(this.elem),e&&e.handleHistoryEvent(ee.AFTER_UNAPPLY,this),!0}},{key:"elements",value:function(){return[this.elem]}}]),r}(te);ae.type=ae.prototype.type;var se=function(e){function r(e){var n;return t(this,r),(n=o(this,a(r).call(this))).text=e||"Batch Command",n.stack=[],n}return i(r,e),n(r,[{key:"type",value:function(){return"svgedit.history.BatchCommand"}},{key:"apply",value:function(e){e&&e.handleHistoryEvent(ee.BEFORE_APPLY,this);for(var t=this.stack.length,r=0;r<t;++r)this.stack[r].apply(e);e&&e.handleHistoryEvent(ee.AFTER_APPLY,this)}},{key:"unapply",value:function(e){e&&e.handleHistoryEvent(ee.BEFORE_UNAPPLY,this);for(var t=this.stack.length-1;t>=0;t--)this.stack[t].unapply(e);e&&e.handleHistoryEvent(ee.AFTER_UNAPPLY,this)}},{key:"elements",value:function(){for(var e=[],t=this.stack.length;t--;)for(var r=this.stack[t].elements(),n=r.length;n--;)e.includes(r[n])||e.push(r[n]);return e}},{key:"addSubCommand",value:function(e){this.stack.push(e)}},{key:"isEmpty",value:function(){return!this.stack.length}}]),r}(te);se.type=se.prototype.type;var oe,ue,le,he,ce,de=function(){function e(r){t(this,e),this.handler_=r||null,this.undoStackPointer=0,this.undoStack=[],this.undoChangeStackPointer=-1,this.undoableChangeStack=[]}return n(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.undoStackPointer<this.undoStack.length?this.undoStack[this.undoStackPointer].getText():""}},{key:"undo",value:function(){this.undoStackPointer>0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)}},{key:"redo",value:function(){this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)}},{key:"addCommandToHistory",value:function(e){this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0&&(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 r=++this.undoChangeStackPointer,n=t.length,i=new Array(n),a=new Array(n);n--;){var s=t[n];Yt(s)||(a[n]=s,i[n]=s.getAttribute(e))}this.undoableChangeStack[r]={attrName:e,oldValues:i,elements:a}}},{key:"finishUndoableChange",value:function(){for(var e=this.undoChangeStackPointer--,t=this.undoableChangeStack[e],r=t.attrName,n=new se("Change "+r),i=t.elements.length;i--;){var a=t.elements[i];if(!Yt(a)){var s={};s[r]=t.oldValues[i],s[r]!==a.getAttribute(r)&&n.addSubCommand(new ae(a,s,r))}}return this.undoableChangeStack[e]=null,n}}]),e}(),me=Object.freeze({__proto__:null,HistoryEventTypes:ee,MoveElementCommand:re,InsertElementCommand:ne,RemoveElementCommand:ie,ChangeElementCommand:ae,BatchCommand:se,UndoManager:de}),fe=document.createElementNS(d.SVG,"svg"),ge=function(e,t,r){return{x:r.a*e+r.c*t+r.e,y:r.b*e+r.d*t+r.f}},pe=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},ye=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=t.reduceRight((function(e,t){return t.multiply(e)}));return Math.abs(n.a)<1e-14&&(n.a=0),Math.abs(n.b)<1e-14&&(n.b=0),Math.abs(n.c)<1e-14&&(n.c=0),Math.abs(n.d)<1e-14&&(n.d=0),Math.abs(n.e)<1e-14&&(n.e=0),Math.abs(n.f)<1e-14&&(n.f=0),n},ve=function(e){if(!e)return!1;for(var t=e.numberOfItems;t--;){var r=e.getItem(t);if(1===r.type&&!pe(r.matrix))return!0}return!1},xe=function(e,t,r,n,i){var a=ge(e,t,i),s=ge(e+r,t,i),o=ge(e,t+n,i),u=ge(e+r,t+n,i),l=Math.min(a.x,s.x,o.x,u.x),h=Math.max(a.x,s.x,o.x,u.x),c=Math.min(a.y,s.y,o.y,u.y);return{tl:a,tr:s,bl:o,br:u,aabox:{x:l,y:c,width:h-l,height:Math.max(a.y,s.y,o.y,u.y)-c}}},_e=function(e,t,r){if(Yt(e))return fe.createSVGTransformFromMatrix(fe.createSVGMatrix());if(t=t||0,r=r||e.numberOfItems-1,(t=parseInt(t))>(r=parseInt(r))){var n=r;r=t,t=n}for(var i=fe.createSVGMatrix(),a=t;a<=r;++a){var s=a>=0&&a<e.numberOfItems?e.getItem(a).matrix:fe.createSVGMatrix();i=ye(i,s)}return fe.createSVGTransformFromMatrix(i)},Se=function(e){var t=q(e);return _e(t).matrix},be=function(e,t,r,n){var i=Math.PI/4,a=r-e,s=n-t,o=Math.atan2(s,a),u=Math.sqrt(a*a+s*s),l=Math.round(o/i)*i;return{x:e+u*Math.cos(l),y:t+u*Math.sin(l),a:l}},we=function(e,t){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y},Ae=jQuery,ke={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"]},Ce={},Ee=function(e){Object.assign(Ce,e.ui)},Pe=[],Ge=!0,Ne={},Ie=null,Te=null,Le=function(e){Te=e,Pe=[0,"ClosePath"];Ae.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],(function(e,t){Pe.push(t+"Abs"),Pe.push(t+"Rel")}))},Ve=function(e,t,r){var n=e.pathSegList;if(C)n.insertItemBefore(t,r);else{for(var i=n.numberOfItems,a=[],s=0;s<i;s++){var o=n.getItem(s);a.push(o)}n.clear();for(var u=0;u<i;u++)u===r&&n.appendItem(t),n.appendItem(a[u])}},Oe=function(e,t){return ke[e].map((function(e){return t[e]}))},Me=function(e,t){var r=e.path,n={x:t?t.x:e.item.x,y:t?t.y:e.item.y};r.matrix&&(n=ge(n.x,n.y,r.matrix));var i=Te.getCurrentZoom();return n.x*=i,n.y*=i,n},Re=function(e,t){var r={x:e.x,y:e.y};t.matrix&&(e=ge(r.x,r.y,t.imatrix),r.x=e.x,r.y=e.y);var n=Te.getCurrentZoom();return r.x/=n,r.y/=n,r},Be=function(e,t,r){var n=Ue(),i=Dt("pathpointgrip_"+e);if(!i){i=document.createElementNS(d.SVG,"circle");var a={id:"pathpointgrip_"+e,display:"none",r:4,fill:"#0FF",stroke:"#00F","stroke-width":2,cursor:"move",style:"pointer-events:all"};"pathNodeTooltip"in Ce&&(a["xlink:title"]=Ce.pathNodeTooltip),zt(i,a),i=n.appendChild(i),Ae("#pathpointgrip_"+e).dblclick((function(){Ie&&Ie.setSegType()}))}return t&&r&&zt(i,{cx:t,cy:r,display:"inline"}),i},Ue=function(){var e=Dt("pathpointgrip_container");e||((e=Dt("selectorParentGroup").appendChild(document.createElementNS(d.SVG,"g"))).id="pathpointgrip_container");return e},He=function(e){var t=Dt("ctrlpointgrip_"+e);if(t)return t;t=document.createElementNS(d.SVG,"circle");var r={id:"ctrlpointgrip_"+e,display:"none",r:4,fill:"#0FF",stroke:"#55F","stroke-width":1,cursor:"move",style:"pointer-events:all"};return"pathCtrlPtTooltip"in Ce&&(r["xlink:title"]=Ce.pathCtrlPtTooltip),zt(t,r),Ue().append(t),t},je=function(e){var t=Dt("ctrlLine_"+e);return t||(t=document.createElementNS(d.SVG,"line"),zt(t,{id:"ctrlLine_"+e,stroke:"#555","stroke-width":1,style:"pointer-events:none"}),Ue().append(t),t)},Fe=function(e){var t=e.item,r=e.index;if(!("x1"in t&&"x2"in t))return null;var n={};Ue();for(var i=[Ie.segs[r-1].item,t],a=1;a<3;a++){var s=r+"c"+a,o=n["c"+a+"_line"]=je(s),u=Me(e,{x:t["x"+a],y:t["y"+a]}),l=Me(e,{x:i[a-1].x,y:i[a-1].y});zt(o,{x1:u.x,y1:u.y,x2:l.x,y2:l.y,display:"inline"}),n["c"+a+"_line"]=o;var h=n["c"+a]=He(s);zt(h,{cx:u.x,cy:u.y,display:"inline"}),n["c"+a]=h}return n},De=function(e,t,r,n){var i=n||Ie.elem,a=i["createSVGPathSeg"+Pe[e]].apply(i,l(r));if(k)i.pathSegList.replaceItem(a,t);else{for(var s=i.pathSegList,o=s.numberOfItems,u=[],h=0;h<o;h++){var c=s.getItem(h);u.push(c)}s.clear();for(var d=0;d<o;d++)d===t?s.appendItem(a):s.appendItem(u[d])}},ze=function(e,t){var r=e.index,n=Dt("segline_"+r);if(!n){var i=Ue();n=document.createElementNS(d.SVG,"path"),zt(n,{id:"segline_"+r,display:"none",fill:"none",stroke:"#0FF","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"}),i.append(n)}if(t){var a=e.prev;if(!a)return n.setAttribute("display","none"),n;var s=Me(a);De(2,0,[s.x,s.y],n);for(var o=Oe(e.type,e.item),u=0;u<o.length;u+=2){var l=Me(e,{x:o[u],y:o[u+1]});o[u]=l.x,o[u+1]=l.y}De(e.type,1,o,n)}return n},qe=function(e,t,r){var n=e.x-r.x,i=e.y-r.y,a=t.x-r.x,s=t.y-r.y;if(!(0===n&&0===i||0===a&&0===s)){var o=Math.sqrt(n*n+i*i),u=Math.sqrt(a*a+s*s),l=Te.getSVGRoot().createSVGPoint(),h=Te.getSVGRoot().createSVGPoint(),c=Math.atan2(i,n),d=Math.atan2(s,a);c<0&&(c+=2*Math.PI),d<0&&(d+=2*Math.PI);var m,f,g=Math.abs(c-d),p=Math.abs(Math.PI-g)/2;return c-d>0?(m=g<Math.PI?c+p:c-p,f=g<Math.PI?d-p:d+p):(m=g<Math.PI?c-p:c+p,f=g<Math.PI?d+p:d-p),l.x=o*Math.cos(m)+r.x,l.y=o*Math.sin(m)+r.y,h.x=u*Math.cos(f)+r.x,h.y=u*Math.sin(f)+r.y,[l,h]}},We=function(){function e(r,n){t(this,e),this.selected=!1,this.index=r,this.item=n,this.type=n.pathSegType,this.ctrlpts=[],this.ptgrip=null,this.segsel=null}return n(e,[{key:"showCtrlPts",value:function(e){for(var t in this.ctrlpts)({}).hasOwnProperty.call(this.ctrlpts,t)&&this.ctrlpts[t].setAttribute("display",e?"inline":"none")}},{key:"selectCtrls",value:function(e){Ae("#ctrlpointgrip_"+this.index+"c1, #ctrlpointgrip_"+this.index+"c2").attr("fill",e?"#0FF":"#EEE")}},{key:"show",value:function(e){this.ptgrip&&(this.ptgrip.setAttribute("display",e?"inline":"none"),this.segsel.setAttribute("display",e?"inline":"none"),this.showCtrlPts(e))}},{key:"select",value:function(e){this.ptgrip&&(this.ptgrip.setAttribute("stroke",e?"#0FF":"#00F"),this.segsel.setAttribute("display",e?"inline":"none"),this.ctrlpts&&this.selectCtrls(e),this.selected=e)}},{key:"addGrip",value:function(){this.ptgrip=function(e,t){var r=e.index,n=Be(r);if(t){var i=Me(e);zt(n,{cx:i.x,cy:i.y,display:"inline"})}return n}(this,!0),this.ctrlpts=Fe(this),this.segsel=ze(this,!0)}},{key:"update",value:function(e){if(this.ptgrip){var t=Me(this);zt(this.ptgrip,{cx:t.x,cy:t.y}),ze(this,!0),this.ctrlpts&&(e&&(this.item=Ie.elem.pathSegList.getItem(this.index),this.type=this.item.pathSegType),Fe(this))}}},{key:"move",value:function(e,t){var r=this.item,n=this.ctrlpts?[r.x+=e,r.y+=t,r.x1,r.y1,r.x2+=e,r.y2+=t]:[r.x+=e,r.y+=t];if(De(this.type,this.index,10===this.type?Oe(this.type,r):n),this.next&&this.next.ctrlpts){var i=this.next.item,a=[i.x,i.y,i.x1+=e,i.y1+=t,i.x2,i.y2];De(this.next.type,this.next.index,a)}if(this.mate){var s=this.mate.item,o=[s.x+=e,s.y+=t];De(this.mate.type,this.mate.index,o)}this.update(!0),this.next&&this.next.update(!0)}},{key:"setLinked",value:function(e){var t,r,n;if(2===e){if(r=1,!(t=this.next))return;n=this.item}else{if(r=2,!(t=this.prev))return;n=t.item}var i=t.item;i["x"+r]=n.x+(n.x-this.item["x"+e]),i["y"+r]=n.y+(n.y-this.item["y"+e]);var a=[i.x,i.y,i.x1,i.y1,i.x2,i.y2];De(t.type,t.index,a),t.update(!0)}},{key:"moveCtrl",value:function(e,t,r){var n=this.item;n["x"+e]+=t,n["y"+e]+=r;var i=[n.x,n.y,n.x1,n.y1,n.x2,n.y2];De(this.type,this.index,i),this.update(!0)}},{key:"setType",value:function(e,t){De(e,this.index,t),this.type=e,this.item=Ie.elem.pathSegList.getItem(this.index),this.showCtrlPts(6===e),this.ctrlpts=Fe(this),this.update(!0)}}]),e}(),Qe=function(){function e(r){if(t(this,e),!r||"path"!==r.tagName)throw new Error("svgedit.path.Path constructed without a <path> element");this.elem=r,this.segs=[],this.selected_pts=[],Ie=this,this.init()}return n(e,[{key:"init",value:function(){Ae(Ue()).find("*").each((function(){Ae(this).attr("display","none")}));var e=this.elem.pathSegList,t=e.numberOfItems;this.segs=[],this.selected_pts=[],this.first_seg=null;for(var r=0;r<t;r++){var n=e.getItem(r),i=new We(r,n);i.path=this,this.segs.push(i)}for(var a=this.segs,s=null,o=0;o<t;o++){var u=a[o],l=o+1>=t?null:a[o+1],h=o-1<0?null:a[o-1];if(2===u.type){if(h&&1!==h.type){var c=a[s];c.next=a[s+1],c.next.prev=c,c.addGrip()}s=o}else if(l&&1===l.type)u.next=a[s+1],u.next.prev=u,u.mate=a[s],u.addGrip(),Yt(this.first_seg)&&(this.first_seg=u);else if(l)1!==u.type&&(u.addGrip(),l&&2!==l.type&&(u.next=l,u.next.prev=u));else if(1!==u.type){var d=a[s];d.next=a[s+1],d.next.prev=d,d.addGrip(),u.addGrip(),this.first_seg||(this.first_seg=a[s])}}return this}},{key:"eachSeg",value:function(e){for(var t=this.segs.length,r=0;r<t;r++){if(!1===e.call(this.segs[r],r))break}}},{key:"addSeg",value:function(e){var t=this.segs[e];if(t.prev){var r,n,i,a=t.prev;switch(t.item.pathSegType){case 4:n=(t.item.x+a.item.x)/2,i=(t.item.y+a.item.y)/2,r=this.elem.createSVGPathSegLinetoAbs(n,i);break;case 6:var s=(a.item.x+t.item.x1)/2,o=(t.item.x1+t.item.x2)/2,u=(t.item.x2+t.item.x)/2,l=(s+o)/2,h=(o+u)/2;n=(l+h)/2;var c=(a.item.y+t.item.y1)/2,d=(t.item.y1+t.item.y2)/2,m=(t.item.y2+t.item.y)/2,f=(c+d)/2,g=(d+m)/2;i=(f+g)/2,r=this.elem.createSVGPathSegCurvetoCubicAbs(n,i,s,c,l,f);var p=[t.item.x,t.item.y,h,g,u,m];De(t.type,e,p)}Ve(this.elem,r,e)}}},{key:"deleteSeg",value:function(e){var t=this.segs[e],r=this.elem.pathSegList;t.show(!1);var n=t.next;if(t.mate){var i=[n.item.x,n.item.y];De(2,n.index,i),De(4,t.index,i),r.removeItem(t.mate.index)}else if(t.prev)r.removeItem(e);else{var a=[n.item.x,n.item.y];De(2,t.next.index,a),r.removeItem(e)}}},{key:"removePtFromSelection",value:function(e){var t=this.selected_pts.indexOf(e);-1!==t&&(this.segs[e].select(!1),this.selected_pts.splice(t,1))}},{key:"clearSelection",value:function(){this.eachSeg((function(){this.select(!1)})),this.selected_pts=[]}},{key:"storeD",value:function(){this.last_d=this.elem.getAttribute("d")}},{key:"show",value:function(e){return this.eachSeg((function(){this.show(e)})),e&&this.selectPt(this.first_seg.index),this}},{key:"movePts",value:function(e,t){for(var r=this.selected_pts.length;r--;){this.segs[this.selected_pts[r]].move(e,t)}}},{key:"moveCtrl",value:function(e,t){var r=this.segs[this.selected_pts[0]];r.moveCtrl(this.dragctrl,e,t),Ge&&r.setLinked(this.dragctrl)}},{key:"setSegType",value:function(e){this.storeD();for(var t,r=this.selected_pts.length;r--;){var n=this.selected_pts[r],i=this.segs[n],a=i.prev;if(a){if(!e)t="Toggle Path Segment Type",e=6===i.type?4:6;e=Number(e);var s=i.item.x,o=i.item.y,u=a.item.x,l=a.item.y,h=void 0;switch(e){case 6:if(i.olditem){var c=i.olditem;h=[s,o,c.x1,c.y1,c.x2,c.y2]}else{var d=s-u,m=o-l;h=[s,o,u+d/3,l+m/3,s-d/3,o-m/3]}break;case 4:h=[s,o],i.olditem=i.item}i.setType(e,h)}}Ie.endChanges(t)}},{key:"selectPt",value:function(e,t){this.clearSelection(),Yt(e)&&this.eachSeg((function(t){this.prev&&(e=t)})),this.addPtsToSelection(e),t&&(this.dragctrl=t,Ge&&this.segs[e].setLinked(t))}},{key:"update",value:function(){var e=this.elem;return jt(e)?(this.matrix=Se(e),this.imatrix=this.matrix.inverse()):(this.matrix=null,this.imatrix=null),this.eachSeg((function(t){this.item=e.pathSegList.getItem(t),this.update()})),this}},{key:"endChanges",value:function(e){L()&&Te.resetD(this.elem);var t=new ae(this.elem,{d:this.last_d},e);Te.endChanges({cmd:t,elem:this.elem})}},{key:"addPtsToSelection",value:function(t){var r=this;Array.isArray(t)||(t=[t]),t.forEach((function(e){r.segs[e].ptgrip&&!r.selected_pts.includes(e)&&e>=0&&r.selected_pts.push(e)})),this.selected_pts.sort();var n=this.selected_pts.length,i=[];for(i.length=n;n--;){var a=this.selected_pts[n],s=this.segs[a];s.select(!0),i[n]=s.ptgrip}var o=e.subpathIsClosed(this.selected_pts[0]);Te.addPtsToSelection({grips:i,closedSubpath:o})}}],[{key:"subpathIsClosed",value:function(e){var t=!1;return Ie.eachSeg((function(r){return r<=e||2!==this.type&&(1!==this.type||(t=!0,!1))})),t}}]),e}(),Ye=function(e){var t=Ne[e.id];return t||(t=Ne[e.id]=new Qe(e)),t},Ze=function(e){e in Ne&&delete Ne[e]},Xe=function(e,t){var r=e-le,n=t-he,i=Math.sqrt(r*r+n*n),a=Math.atan2(n,r)+ce;return r=i*Math.cos(a)+le,n=i*Math.sin(a)+he,r-=oe,n-=ue,i=Math.sqrt(r*r+n*n),a=Math.atan2(n,r)-ce,{x:i*Math.cos(a)+oe,y:i*Math.sin(a)+ue}},Ke=function(){var e=Ie.elem;if(ce=jt(e,!0)){var t=Ie.oldbbox;le=t.x+t.width/2,he=t.y+t.height/2;var r=Nt(e);oe=r.x+r.width/2,ue=r.y+r.height/2;var n=oe-le,i=ue-he,a=Math.sqrt(n*n+i*i),s=Math.atan2(i,n)+ce;oe=a*Math.cos(s)+le,ue=a*Math.sin(s)+he;for(var o=e.pathSegList,u=o.numberOfItems;u;){u-=1;var l=o.getItem(u),h=l.pathSegType;if(1!==h){var c=Xe(l.x,l.y),d=[c.x,c.y];if(!Yt(l.x1)&&!Yt(l.x2)){var m=Xe(l.x1,l.y1),f=Xe(l.x2,l.y2);d.splice(d.length,0,m.x,m.y,f.x,f.y)}De(h,u,d)}}Nt(e);var g=Te.getSVGRoot().createSVGTransform(),p=q(e);g.setRotate(180*ce/Math.PI,oe,ue),p.replaceItem(g,0)}},$e=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Je=function(e,t){for(var r=e.pathSegList,n=r.numberOfItems,i=0,a=0,s="",o=null,u=0;u<n;++u){var l=r.getItem(u),h=l.x||0,c=l.y||0,d=l.x1||0,m=l.y1||0,f=l.x2||0,g=l.y2||0,p=l.pathSegType,y=$e[p]["to"+(t?"Lower":"Upper")+"Case"]();switch(p){case 1:s+="z",o&&!t&&(i=o[0],a=o[1]);break;case 12:h-=i;case 13:t?(i+=h,y="l"):(i=h+=i,y="L"),s+=et(y,[[h,a]]);break;case 14:c-=a;case 15:t?(a+=c,y="l"):(a=c+=a,y="L"),s+=et(y,[[i,c]]);break;case 2:case 4:case 18:h-=i,c-=a;case 5:case 3:case 19:t?(i+=h,a+=c):(i=h+=i,a=c+=a),2!==p&&3!==p||(o=[i,a]),s+=et(y,[[h,c]]);break;case 6:h-=i,d-=i,f-=i,c-=a,m-=a,g-=a;case 7:t?(i+=h,a+=c):(d+=i,f+=i,m+=a,g+=a,i=h+=i,a=c+=a),s+=et(y,[[d,m],[f,g],[h,c]]);break;case 8:h-=i,d-=i,c-=a,m-=a;case 9:t?(i+=h,a+=c):(d+=i,m+=a,i=h+=i,a=c+=a),s+=et(y,[[d,m],[h,c]]);break;case 10:h-=i,c-=a;case 11:t?(i+=h,a+=c):(i=h+=i,a=c+=a),s+=et(y,[[l.r1,l.r2]],[l.angle,l.largeArcFlag?1:0,l.sweepFlag?1:0],[h,c]);break;case 16:h-=i,f-=i,c-=a,g-=a;case 17:t?(i+=h,a+=c):(f+=i,g+=a,i=h+=i,a=c+=a),s+=et(y,[[f,g],[h,c]])}}return s};function et(e,t,r,n){Ae.each(t,(function(e,r){t[e]=X(r)}));var i=e+t.join(" ");return r&&(i+=" "+r.join(" ")),n&&(i+=" "+X(n)),i}var tt,rt,nt,it,at,st=(nt=!1,it=null,at=!1,{mouseDown:function(e,t,r,n){var i;if("path"!==Te.getCurrentMode()){if(Ie){var a;if(Ie.storeD(),"pathpointgrip_"===(i=e.target.id).substr(0,14)){a=Ie.cur_pt=parseInt(i.substr(14)),Ie.dragging=[r,n];var s=Ie.segs[a];e.shiftKey?s.selected?Ie.removePtFromSelection(a):Ie.addPtsToSelection(a):((Ie.selected_pts.length<=1||!s.selected)&&Ie.clearSelection(),Ie.addPtsToSelection(a))}else if(i.startsWith("ctrlpointgrip_")){Ie.dragging=[r,n];var o=i.split("_")[1].split("c");a=Number(o[0]);var u=Number(o[1]);Ie.selectPt(a,u)}if(!Ie.dragging){var l=Te.getRubberBox();Yt(l)&&(l=Te.setRubberBox(Te.selectorManager.getRubberBandBox()));var h=Te.getCurrentZoom();zt(l,{x:r*h,y:n*h,width:0,height:0,display:"inline"})}}}else{var c=r,m=n,f=Te.getCurrentZoom(),g=c/f,p=m/f,y=Dt("path_stretch_line");tt=[g,p],Te.getGridSnapping()&&(g=Wt(g),p=Wt(p),c=Wt(c),m=Wt(m)),y||(y=document.createElementNS(d.SVG,"path"),zt(y,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"}),y=Dt("selectorParentGroup").appendChild(y)),y.setAttribute("display","inline");var v,x=Te.getDrawnPath();if(x){for(var _=x.pathSegList,S=_.numberOfItems,b=6/f,w=!1;S;){S--;var A=_.getItem(S),k=A.x,C=A.y;if(g>=k-b&&g<=k+b&&p>=C-b&&p<=C+b){w=!0;break}}i=Te.getId(),Ze(i);var E,P,G=Dt(i),N=_.numberOfItems;if(w){if(S<=1&&N>=2){var I=_.getItem(0).x,T=_.getItem(0).y;E=4===(P=y.pathSegList.getItem(1)).pathSegType?x.createSVGPathSegLinetoAbs(I,T):x.createSVGPathSegCurvetoCubicAbs(I,T,P.x1/f,P.y1/f,I,T);var L=x.createSVGPathSegClosePath();_.appendItem(E),_.appendItem(L)}else if(N<3)return!1;if(Ae(y).remove(),Te.setDrawnPath(null),Te.setStarted(!1),nt){Ie.matrix&&Te.remapElement(G,{},Ie.matrix.inverse());var V=G.getAttribute("d"),O=Ae(Ie.elem).attr("d");return Ae(Ie.elem).attr("d",O+V),Ae(G).remove(),Ie.matrix&&Ke(),Le(),st.toEditMode(Ie.elem),Ie.selectPt(),!1}}else{if(!Ae.contains(Te.getContainer(),Te.getMouseTarget(e)))return!1;var M=x.pathSegList.numberOfItems,R=x.pathSegList.getItem(M-1),B=R.x,U=R.y;if(e.shiftKey){var H=be(B,U,g,p);g=H.x,p=H.y}E=4===(P=y.pathSegList.getItem(1)).pathSegType?x.createSVGPathSegLinetoAbs(Te.round(g),Te.round(p)):x.createSVGPathSegCurvetoCubicAbs(Te.round(g),Te.round(p),P.x1/f,P.y1/f,P.x2/f,P.y2/f),x.pathSegList.appendItem(E),g*=f,p*=f,y.setAttribute("d",["M",g,p,g,p].join(" ")),v=M,nt&&(v+=Ie.segs.length),Be(v,g,p)}}else{var j="M"+g+","+p+" ";Te.setDrawnPath(Te.addSVGElementFromJson({element:"path",curStyles:!0,attr:{d:j,id:Te.getNextId(),opacity:Te.getOpacity()/2}})),y.setAttribute("d",["M",c,m,c,m].join(" ")),v=nt?Ie.segs.length:0,Be(v,c,m)}}},mouseMove:function(e,t){var r=Te.getCurrentZoom();at=!0;var n=Te.getDrawnPath();if("path"!==Te.getCurrentMode())if(Ie.dragging){var i=Re({x:Ie.dragging[0],y:Ie.dragging[1]},Ie),a=Re({x:e,y:t},Ie),s=a.x-i.x,o=a.y-i.y;Ie.dragging=[e,t],Ie.dragctrl?Ie.moveCtrl(s,o):Ie.movePts(s,o)}else Ie.selected_pts=[],Ie.eachSeg((function(e){if(this.next||this.prev){var t=Te.getRubberBox().getBBox(),r=Me(this),n={x:r.x,y:r.y,width:0,height:0},i=we(t,n);this.select(i),i&&Ie.selected_pts.push(this.index)}}));else{if(!n)return;var u=n.pathSegList,l=u.numberOfItems-1;if(tt){var h=He("1c1"),c=He("0c2");h.setAttribute("cx",e),h.setAttribute("cy",t),h.setAttribute("display","inline");var d=tt[0],m=tt[1],f=d+(d-e/r),g=m+(m-t/r);c.setAttribute("cx",f*r),c.setAttribute("cy",g*r),c.setAttribute("display","inline");var p=je(1);if(zt(p,{x1:e,y1:t,x2:f*r,y2:g*r,display:"inline"}),0===l)rt=[e,t];else{var y=u.getItem(l-1),v=y.x,x=y.y;6===y.pathSegType?(v+=v-y.x2,x+=x-y.y2):rt&&(v=rt[0]/r,x=rt[1]/r),De(6,l,[d,m,v,x,f,g],n)}}else{var _=Dt("path_stretch_line");if(_){var S=u.getItem(l);if(6===S.pathSegType){var b=S.x+(S.x-S.x2),w=S.y+(S.y-S.y2);De(6,1,[e,t,b*r,w*r,e,t],_)}else rt?De(6,1,[e,t,rt[0],rt[1],e,t],_):De(4,1,[e,t],_)}}}},mouseUp:function(e,t,r,n){var i=Te.getDrawnPath();if("path"===Te.getCurrentMode())return tt=null,i||(t=Dt(Te.getId()),Te.setStarted(!1),rt=null),{keep:!0,element:t};var a=Te.getRubberBox();if(Ie.dragging){var s=Ie.cur_pt;Ie.dragging=!1,Ie.dragctrl=!1,Ie.update(),at&&Ie.endChanges("Move path point(s)"),e.shiftKey||at||Ie.selectPt(s)}else a&&"none"!==a.getAttribute("display")?(a.setAttribute("display","none"),a.getAttribute("width")<=2&&a.getAttribute("height")<=2&&st.toSelectMode(e.target)):st.toSelectMode(e.target);at=!1},toEditMode:function(e){Ie=Ye(e),Te.setCurrentMode("pathedit"),Te.clearSelection(),Ie.show(!0).update(),Ie.oldbbox=Nt(Ie.elem),nt=!1},toSelectMode:function(e){var t=e===Ie.elem;Te.setCurrentMode("select"),Ie.show(!1),it=!1,Te.clearSelection(),Ie.matrix&&Ke(),t&&(Te.call("selected",[e]),Te.addToSelection([e],!0))},addSubPath:function(e){e?(Te.setCurrentMode("path"),nt=!0):(st.clear(!0),st.toEditMode(Ie.elem))},select:function(e){it===e?(st.toEditMode(e),Te.setCurrentMode("pathedit")):it=e},reorient:function(){var e=Te.getSelectedElements()[0];if(e&&0!==jt(e)){var t=new se("Reorient path"),r={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new ae(e,r)),Te.clearSelection(),this.resetOrientation(e),Te.addCommandToHistory(t),Ye(e).show(!1).matrix=null,this.clear(),Te.addToSelection([e],!0),Te.call("changed",Te.getSelectedElements())}},clear:function(e){var t=Te.getDrawnPath();if(it=null,t){var r=Dt(Te.getId());Ae(Dt("path_stretch_line")).remove(),Ae(r).remove(),Ae(Dt("pathpointgrip_container")).find("*").attr("display","none"),rt=null,Te.setDrawnPath(null),Te.setStarted(!1)}else"pathedit"===Te.getCurrentMode()&&this.toSelectMode();Ie&&Ie.init().show(!1)},resetOrientation:function(e){if(Yt(e)||"path"!==e.nodeName)return!1;var t=q(e),r=_e(t).matrix;t.clear(),e.removeAttribute("transform");for(var n=e.pathSegList,i=n.numberOfItems,a=function(t){var i=n.getItem(t),a=i.pathSegType;if(1===a)return"continue";var s=[];Ae.each(["",1,2],(function(e,t){var n=i["x"+t],a=i["y"+t];if(void 0!==n&&void 0!==a){var o=ge(n,a,r);s.splice(s.length,0,o.x,o.y)}})),De(a,t,s,e)},s=0;s<i;++s)a(s);!function(e,t){for(var r=Nt(e),n=0;n<2;n++){var i=0===n?"fill":"stroke",a=e.getAttribute(i);if(a&&a.startsWith("url(")){var s=Ft(a);if("linearGradient"===s.tagName){var o=s.getAttribute("x1")||0,u=s.getAttribute("y1")||0,l=s.getAttribute("x2")||1,h=s.getAttribute("y2")||0;o=r.width*o+r.x,u=r.height*u+r.y,l=r.width*l+r.x,h=r.height*h+r.y;var c=ge(o,u,t),d=ge(l,h,t),m={x1:(c.x-r.x)/r.width,y1:(c.y-r.y)/r.height,x2:(d.x-r.x)/r.width,y2:(d.y-r.y)/r.height},f=s.cloneNode(!0);Ae(f).attr(m),f.id=Te.getNextId(),Et().append(f),e.setAttribute(i,"url(#"+f.id+")")}}}}(e,r)},zoomChange:function(){"pathedit"===Te.getCurrentMode()&&Ie.update()},getNodePoint:function(){var e=Ie.selected_pts.length?Ie.selected_pts[0]:1,t=Ie.segs[e];return{x:t.item.x,y:t.item.y,type:t.type}},linkControlPoints:function(e){Ge=e},clonePathNode:function(){Ie.storeD();for(var e=Ie.selected_pts,t=e.length,r=[];t--;){var n=e[t];Ie.addSeg(n),r.push(n+t),r.push(n+t+1)}Ie.init().addPtsToSelection(r),Ie.endChanges("Clone path node(s)")},opencloseSubPath:function(){var e=Ie.selected_pts;if(1===e.length){var t,r,n=Ie.elem,i=n.pathSegList,a=e[0],s=null,o=null;if(Ie.eachSeg((function(e){return 2===this.type&&e<=a&&(o=this.item),e<=a||(2===this.type?(s=e,!1):1!==this.type||(s=!1,!1))})),Yt(s)&&(s=Ie.segs.length-1),!1!==s){var u=n.createSVGPathSegLinetoAbs(o.x,o.y),l=n.createSVGPathSegClosePath();return s===Ie.segs.length-1?(i.appendItem(u),i.appendItem(l)):(Ve(n,l,s),Ve(n,u,s)),void Ie.init().selectPt(s+1)}if(Ie.segs[a].mate)return i.removeItem(a),i.removeItem(a),void Ie.init().selectPt(a-1);for(var h=0;h<i.numberOfItems;h++){var c=i.getItem(h);if(2===c.pathSegType)t=h;else if(h===a)i.removeItem(t);else if(1===c.pathSegType&&a<h){r=h-1,i.removeItem(h);break}}for(var d=a-t-1;d--;)Ve(n,i.getItem(t),r);var m=i.getItem(t);De(2,t,[m.x,m.y]),Ie.init().selectPt(0)}},deletePathNode:function(){if(st.canDeleteNodes){Ie.storeD();for(var e=Ie.selected_pts,t=e.length;t--;){var r=e[t];Ie.deleteSeg(r)}if(function e(){var t=Ie.elem.pathSegList,r=t.numberOfItems,n=function(e,r){for(;r--;)t.removeItem(e)};if(r<=1)return!0;for(;r--;){var i=t.getItem(r);if(1===i.pathSegType){var a=t.getItem(r-1),s=t.getItem(r-2);if(2===a.pathSegType){n(r-1,2),e();break}if(2===s.pathSegType){n(r-2,3),e();break}}else if(2===i.pathSegType&&r>0){var o=t.getItem(r-1).pathSegType;if(2===o){n(r-1,1),e();break}if(1===o&&t.numberOfItems-1===r){n(r,1),e();break}}}return!1}(),Ie.elem.pathSegList.numberOfItems<=1)return st.toSelectMode(Ie.elem),void Te.canvas.deleteSelectedElements();if(Ie.init(),Ie.clearSelection(),window.opera){var n=Ae(Ie.elem);n.attr("d",n.attr("d"))}Ie.endChanges("Delete path node(s)")}},smoothPolylineIntoPath:function(e){var t,r=e.points,n=r.numberOfItems;if(n>=4){var i=r.getItem(0),a=null,s=[];for(s.push(["M",i.x,",",i.y," C"].join("")),t=1;t<=n-4;t+=3){var o=r.getItem(t),u=r.getItem(t+1),l=r.getItem(t+2);if(a){var h=qe(a,o,i);if(h&&2===h.length){var c=s[s.length-1].split(",");c[2]=h[0].x,c[3]=h[0].y,s[s.length-1]=c.join(","),o=h[1]}}s.push([o.x,o.y,u.x,u.y,l.x,l.y].join(",")),i=l,a=u}for(s.push("L");t<n;){var d=r.getItem(t);s.push([d.x,d.y].join(",")),t++}s=s.join(" "),e=Te.addSVGElementFromJson({element:"path",curStyles:!0,attr:{id:Te.getId(),d:s,fill:"none"}})}return e},setSegType:function(e){Ie.setSegType(e)},moveNode:function(e,t){var r=Ie.selected_pts;if(r.length){Ie.storeD();var n=Ie.segs[r[0]],i={x:0,y:0};i[e]=t-n.item[e],n.move(i.x,i.y),Ie.endChanges("Move path point")}},fixEnd:function(e){for(var t,r=e.pathSegList,n=r.numberOfItems,i=0;i<n;++i){var a=r.getItem(i);if(2===a.pathSegType&&(t=a),1===a.pathSegType){var s=r.getItem(i-1);if(s.x!==t.x||s.y!==t.y){var o=e.createSVGPathSegLinetoAbs(t.x,t.y);Ve(e,o,i),st.fixEnd(e);break}}}L()&&Te.resetD(e)},convertPath:Je}),ot=h(jQuery),ut="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",lt="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),ht=null,ct=null,dt=null,mt=null,ft=function(e){return e.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/,"$1$2")},gt=function(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")};function pt(e){if(e=xt(e),window.btoa)return window.btoa(e);var t=new Array(4*Math.floor((e.length+2)/3)),r=0,n=0;do{var i=e.charCodeAt(r++),a=e.charCodeAt(r++),s=e.charCodeAt(r++),o=i>>2,u=(3&i)<<4|a>>4,l=(15&a)<<2|s>>6,h=63&s;isNaN(a)?(l=64,h=64):isNaN(s)&&(h=64),t[n++]=ut.charAt(o),t[n++]=ut.charAt(u),t[n++]=ut.charAt(l),t[n++]=ut.charAt(h)}while(r<e.length);return t.join("")}function yt(e){if(window.atob)return vt(window.atob(e));e=e.replace(/[^A-Za-z\d+\/=]/g,"");var t="",r=0;do{var n=ut.indexOf(e.charAt(r++)),i=ut.indexOf(e.charAt(r++)),a=ut.indexOf(e.charAt(r++)),s=ut.indexOf(e.charAt(r++)),o=n<<2|i>>4,u=(15&i)<<4|a>>2,l=(3&a)<<6|s;t+=String.fromCharCode(o),64!==a&&(t+=String.fromCharCode(u)),64!==s&&(t+=String.fromCharCode(l))}while(r<e.length);return vt(t)}function vt(e){return decodeURIComponent(escape(e))}var xt=function(e){return unescape(encodeURIComponent(e))},_t=function(e){if("undefined"==typeof Uint8Array||"undefined"==typeof Blob||"undefined"==typeof URL||!URL.createObjectURL)return"";for(var t=e.split(","),r=t[0].match(/:(.*?);/)[1],n=atob(t[1]),i=n.length,a=new Uint8Array(i);i--;)a[i]=n.charCodeAt(i);var s=new Blob([a],{type:r});return URL.createObjectURL(s)},St=function(e){return e&&"undefined"!=typeof URL&&URL.createObjectURL?URL.createObjectURL(e):""},bt=(function(){if("undefined"==typeof Blob)return"";var e=new Blob(["<html><head><title>SVG-edit</title></head><body>&nbsp;</body></html>"],{type:"text/html"});St(e)}(),function(e){var t,r;e.includes("<svg:svg")&&(e=e.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns"));try{(r=window.DOMParser?new DOMParser:new window.ActiveXObject("Microsoft.XMLDOM")).async=!1}catch(e){throw new Error("XML Parser could not be instantiated")}try{t=r.loadXML?!!r.loadXML(e)&&r:r.parseFromString(e,"text/xml")}catch(e){throw new Error("Error parsing XML string")}return t}),wt=function e(t,r){if(t&&1===t.nodeType){r(t);for(var n=t.childNodes.length;n--;)e(t.childNodes.item(n),r)}},At=function(e){if(e){if(e.startsWith('url("'))return e.substring(5,e.indexOf('"',6));if(e.startsWith("url('"))return e.substring(5,e.indexOf("'",6));if(e.startsWith("url("))return e.substring(4,e.indexOf(")"))}return null},kt=function(e){return e.getAttributeNS(d.XLINK,"href")},Ct=function(e,t){e.setAttributeNS(d.XLINK,"xlink:href",t)},Et=function(){var e=ht.getSVGContent(),t=e.getElementsByTagNameNS(d.SVG,"defs");return t.length>0?t=t[0]:(t=e.ownerDocument.createElementNS(d.SVG,"defs"),e.firstChild?e.insertBefore(t,e.firstChild.nextSibling):e.append(t)),t},Pt=function(e){for(var t=e.pathSegList,r=t.numberOfItems,n=[[],[]],i=t.getItem(0),a=[i.x,i.y],s=function(e,t,r,n){return function(i){return 1-Math.pow(i,3)*a[e]+3-Math.pow(i,2)*i*t[e]+3*(1-i)*Math.pow(i,2)*r[e]+Math.pow(i,3)*n[e]}},o=0;o<r;o++){var u=t.getItem(o);if(void 0!==u.x)if(n[0].push(a[0]),n[1].push(a[1]),u.x1){for(var l=[u.x1,u.y1],h=[u.x2,u.y2],c=[u.x,u.y],d=0;d<2;d++){var m=s(d,l,h,c),f=6*a[d]-12*l[d]+6*h[d],g=-3*a[d]+9*l[d]-9*h[d]+3*c[d],p=3*l[d]-3*a[d];if(0!==g){var y=Math.pow(f,2)-4*p*g;if(!(y<0)){var v=(-f+Math.sqrt(y))/(2*g);v>0&&v<1&&n[d].push(m(v));var x=(-f-Math.sqrt(y))/(2*g);x>0&&x<1&&n[d].push(m(x))}}else{if(0===f)continue;var _=-p/f;_>0&&_<1&&n[d].push(m(_))}}a=c}else n[0].push(u.x),n[1].push(u.y)}var S=Math.min.apply(null,n[0]),b=Math.max.apply(null,n[0])-S,w=Math.min.apply(null,n[1]);return{x:S,y:w,width:b,height:Math.max.apply(null,n[1])-w}};function Gt(e){if(R())try{return e.getBBox()}catch(e){}var t,r,n=ot.data(e,"ref"),i=null;n?(r=ot(n).children().clone().attr("visibility","hidden"),ot(mt).append(r),i=r.filter("line, path")):i=ot(e).find("line, path");var a=!1;if(i.length)if(i.each((function(){var e=this.getBBox();e.width&&e.height||(a=!0)})),a){var s=n?r:ot(e).children();t=Rt(s)}else t=e.getBBox();else t=e.getBBox();return n&&r.remove(),t}var Nt=function(e){var t=e||ht.geSelectedElements()[0];if(1!==e.nodeType)return null;var r,n=t.nodeName,i=null;switch(n){case"text":""===t.textContent?(t.textContent="a",i=t.getBBox(),t.textContent=""):t.getBBox&&(i=t.getBBox());break;case"path":P?t.getBBox&&(i=t.getBBox()):i=Pt(t);break;case"g":case"a":i=Gt(t);break;default:if("use"===n&&(i=Gt(t)),"use"===n||"foreignObject"===n&&L()){if(i||(i=t.getBBox()),!L()){var a=i,s=a.x,o=a.y;i={width:a.width,height:a.height,x:s+parseFloat(t.getAttribute("x")||0),y:o+parseFloat(t.getAttribute("y")||0)}}}else if(lt.includes(n))if(t)try{i=t.getBBox()}catch(e){var u=t.getExtentOfChar(0),l=t.getComputedTextLength();i={x:u.x,y:u.y,width:l,height:u.height}}else{var h=ot(t).closest("foreignObject");h.length&&h[0].getBBox&&(i=h[0].getBBox())}}return i&&(i={x:(r=i).x,y:r.y,width:r.width,height:r.height}),i},It=function(e){var t="";return ot.each(e,(function(e,r){var n=u(r,2),i=n[0],a=n[1];t+=i;for(var s=0;s<a.length;s+=2)t+=a[s]+","+a[s+1]+" "})),t},Tt=function(e){var t,r,n,i,a=1.81;switch(e.tagName){case"ellipse":case"circle":var s=r=ot(e).attr(["rx","ry","cx","cy"]),o=s.cx,u=s.cy,l=r;n=l.rx,i=l.ry,"circle"===e.tagName&&(n=i=ot(e).attr("r")),t=It([["M",[o-n,u]],["C",[o-n,u-i/a,o-n/a,u-i,o,u-i]],["C",[o+n/a,u-i,o+n,u-i/a,o+n,u]],["C",[o+n,u+i/a,o+n/a,u+i,o,u+i]],["C",[o-n/a,u+i,o-n,u+i/a,o-n,u]],["Z",[]]]);break;case"path":t=e.getAttribute("d");break;case"line":t="M"+(r=ot(e).attr(["x1","y1","x2","y2"])).x1+","+r.y1+"L"+r.x2+","+r.y2;break;case"polyline":t="M"+e.getAttribute("points");break;case"polygon":t="M"+e.getAttribute("points")+" Z";break;case"rect":var h=ot(e).attr(["rx","ry"]);n=h.rx,i=h.ry;var c=e.getBBox(),d=c.x,m=c.y,f=c.width,g=c.height;a=4-a,t=It(n||i?[["M",[d,m+i]],["C",[d,m+i/a,d+n/a,m,d+n,m]],["L",[d+f-n,m]],["C",[d+f-n/a,m,d+f,m+i/a,d+f,m+i]],["L",[d+f,m+g-i]],["C",[d+f,m+g-i/a,d+f-n/a,m+g,d+f-n,m+g]],["L",[d+n,m+g]],["C",[d+n/a,m+g,d,m+g-i/a,d,m+g-i]],["L",[d,m+i]],["Z",[]]]:[["M",[d,m]],["L",[d+f,m]],["L",[d+f,m+g]],["L",[d,m+g]],["L",[d,m]],["Z",[]]])}return t},Lt=function(e){var t={};return ot.each(["marker-start","marker-end","marker-mid","filter","clip-path"],(function(){var r=e.getAttribute(this);r&&(t[this]=r)})),t},Vt=function(e,t,r){var n=t({element:"path",attr:Lt(e)}),i=e.getAttribute("transform");i&&n.setAttribute("transform",i);var a=e.parentNode;e.nextSibling?e.before(n):a.append(n);var s=Tt(e);s?n.setAttribute("d",s):n.remove(),r.resetOrientation(n);var o=!1;try{o=n.getBBox()}catch(e){}return n.remove(),o};var Ot=function(e,t,r){var n=Nt(e);if(!n)return null;var i=q(e),a=Ht(i),s=ve(i);if(a||s){var o=!1;if(function(e,t){var r=e%90;return t||!(r>-.001&&r<.001||(r<-89.99||r>89.99))}(a,s)){if(["ellipse","path","line","polyline","polygon"].includes(e.tagName))n=o=Vt(e,t,r);else if("rect"===e.tagName){var u=e.getAttribute("rx"),l=e.getAttribute("ry");(u||l)&&(n=o=Vt(e,t,r))}}if(!o){var h=_e(i).matrix;n=xe(n.x,n.y,n.width,n.height,h).aabox}}return n};function Mt(e){var t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}var Rt=function(e,t,r){if(!e||!e.length)return!1;var n;if(ot.each(e,(function(){n||this.parentNode&&(n=Ot(this,t,r))})),void 0===n)return null;var i=n.x+n.width,a=n.y+n.height,s=n.x,o=n.y;if(1===e.length){var u=Mt(e[0]);s-=u,o-=u,i+=u,a+=u}else ot.each(e,(function(e,n){var u=Ot(n,t,r);if(u){var l=Mt(n);s=Math.min(s,u.x-l),o=Math.min(o,u.y-l),1===n.nodeType&&(i=Math.max(i,u.x+u.width+l),a=Math.max(a,u.y+u.height+l))}}));return n.x=s,n.y=o,n.width=i-s,n.height=a-o,n},Bt=function(e){e||(e=ot(ht.getSVGContent()).children());var t=[];return ot(e).children().each((function(e,r){r.getBBox&&t.push(r)})),t.reverse()},Ut=function(e){return e||(e=Bt()),Rt(e,ht.addSVGElementFromJson,ht.pathActions)},Ht=function(e,t){if(!e)return 0;for(var r=e.numberOfItems,n=0;n<r;++n){var i=e.getItem(n);if(4===i.type)return t?i.angle*Math.PI/180:i.angle}return 0},jt=function(e,t){var r=e||ht.getSelectedElements()[0],n=q(r);return Ht(n,t)},Ft=function(e){return Dt(At(e).substr(1))},Dt=w?function(e){return mt.querySelector("#"+e)}:A?function(e){return ct.evaluate('svg:svg[@id="svgroot"]//svg:*[@id="'+e+'"]',dt,(function(){return d.SVG}),9,null).singleNodeValue}:function(e){return ot(mt).find("[id="+e+"]")[0]},zt=function(e,t,r,n){for(var i=0,a=Object.entries(t);i<a.length;i++){var s=u(a[i],2),o=s[0],l=s[1],h="xml:"===o.substr(0,4)?d.XML:"xlink:"===o.substr(0,6)?d.XLINK:null;h?e.setAttributeNS(h,o,l):n?$(e,o,l):e.setAttribute(o,l)}},qt=function(e){var t={"fill-opacity":1,"stop-opacity":1,opacity:1,stroke:"none","stroke-dasharray":"none","stroke-linejoin":"miter","stroke-linecap":"butt","stroke-opacity":1,"stroke-width":1,rx:0,ry:0};"ellipse"===e.nodeName&&(delete t.rx,delete t.ry),Object.entries(t).forEach((function(t){var r=u(t,2),n=r[0],i=r[1];e.getAttribute(n)===String(i)&&e.removeAttribute(n)}))},Wt=function(e){var t=ht.getBaseUnit(),r=ht.getSnappingStep();return"px"!==t&&(r*=Z()[t]),e=Math.round(e/r)*r},Qt=function(e){ot(e).click((function(e){e.preventDefault()}))},Yt=function(e){return null==e},Zt=jQuery,Xt=function(){function e(r,n,i){if(t(this,e),this.name_=r,this.group_=i?null:n,i){var a=i.ownerDocument;this.group_=a.createElementNS(d.SVG,"g");var s=a.createElementNS(d.SVG,"title");s.textContent=r,this.group_.append(s),n?Zt(n).after(this.group_):i.append(this.group_)}Kt(this.group_),wt(this.group_,(function(e){e.setAttribute("style","pointer-events:inherit")})),this.group_.setAttribute("style",i?"pointer-events:all":"pointer-events:none")}return n(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 Yt(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){var t=!0,r=!1,n=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var s=i.value;this.group_.append(s)}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}}},{key:"getTitleElement",value:function(){for(var e=this.group_.childNodes.length,t=0;t<e;++t){var r=this.group_.childNodes.item(t);if(r&&"title"===r.tagName)return r}return null}},{key:"setName",value:function(e,t){var r=this.name_;e=gt(e);var n=this.getTitleElement();return n?(Zt(n).empty(),n.textContent=e,this.name_=e,t&&t.changeElement(n,{"#text":r}),this.name_):null}},{key:"removeGroup",value:function(){var e=this.group_.parentNode.removeChild(this.group_);return this.group_=void 0,e}}]),e}();function Kt(e){var t=e.getAttribute("class");Yt(t)||!t.length?e.setAttribute("class",Xt.CLASS_NAME):Xt.CLASS_REGEX.test(t)||e.setAttribute("class",t+" "+Xt.CLASS_NAME)}Xt.CLASS_NAME="layer",Xt.CLASS_REGEX=new RegExp("(\\s|^)"+Xt.CLASS_NAME+"(\\s|$)");var $t=function(){function e(r){t(this,e),this.undoManager_=r,this.currentBatchCommand_=null,this.batchCommandStack_=[]}return n(e,[{key:"startBatchCommand",value:function(e){return this.undoManager_?(this.currentBatchCommand_=new se(e),this.batchCommandStack_.push(this.currentBatchCommand_),this):this}},{key:"endBatchCommand",value:function(){if(!this.undoManager_)return this;if(this.currentBatchCommand_){var e=this.currentBatchCommand_;this.batchCommandStack_.pop();var t=this.batchCommandStack_.length;this.currentBatchCommand_=t?this.batchCommandStack_[t-1]:null,this.addCommand_(e)}return this}},{key:"moveElement",value:function(e,t,r,n){return this.undoManager_?(this.addCommand_(new re(e,t,r,n)),this):this}},{key:"insertElement",value:function(e,t){return this.undoManager_?(this.addCommand_(new ne(e,t)),this):this}},{key:"removeElement",value:function(e,t,r,n){return this.undoManager_?(this.addCommand_(new ie(e,t,r,n)),this):this}},{key:"changeElement",value:function(e,t,r){return this.undoManager_?(this.addCommand_(new ae(e,t,r)),this):this}},{key:"addCommand_",value:function(e){if(!this.undoManager_)return this;this.currentBatchCommand_?this.currentBatchCommand_.addSubCommand(e):this.undoManager_.addCommandToHistory(e)}}]),e}();$t.NO_HISTORY=new $t;var Jt=jQuery,er="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),tr={LET_DOCUMENT_DECIDE:0,ALWAYS_RANDOMIZE:1,NEVER_RANDOMIZE:2},rr=tr.LET_DOCUMENT_DECIDE,nr=[];function ir(e){return e||new $t(sr.undoMgr)}function ar(e){for(var t=1;e.includes("Layer "+t);)t++;return"Layer "+t}var sr,or=function(){function e(r,n){if(t(this,e),!r||!r.tagName||!r.namespaceURI||"svg"!==r.tagName||r.namespaceURI!==d.SVG)throw new Error("Error: svgedit.draw.Drawing instance initialized without a <svg> element");this.svgElem_=r,this.obj_num=0,this.idPrefix=n||"svg_",this.releasedNums=[],this.all_layers=[],this.layer_map={},this.current_layer=null,this.nonce_="";var i=this.svgElem_.getAttributeNS(d.SE,"nonce");i&&rr!==tr.NEVER_RANDOMIZE?this.nonce_=i:rr===tr.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(100001*Math.random()))}return n(e,[{key:"getElem_",value:function(e){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+e):Jt(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(d.XMLNS,"xmlns:se",d.SE),this.svgElem_.setAttributeNS(d.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 r=this.getId();this.getElem_(r);)t&&(this.obj_num=e,t=!1),this.obj_num++,r=this.getId();return t&&(this.obj_num=e),r}},{key:"releaseId",value:function(e){var t=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if("string"!=typeof e||!e.startsWith(t))return!1;var r=parseInt(e.substr(t.length));return!("number"!=typeof r||r<=0||this.releasedNums.includes(r))&&(this.releasedNums.push(r),!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<this.getNumLayers()?this.all_layers[e].getName():""}},{key:"getCurrentLayer",value:function(){return this.current_layer?this.current_layer.getGroup():null}},{key:"getLayerByName",value:function(e){var t=this.layer_map[e];return t?t.getGroup():null}},{key:"getCurrentLayerName",value:function(){return this.current_layer?this.current_layer.getName():""}},{key:"setCurrentLayerName",value:function(e,t){var r=null;if(this.current_layer){var n=this.current_layer.getName();(r=this.current_layer.setName(e,t))&&(delete this.layer_map[n],this.layer_map[r]=this.current_layer)}return r}},{key:"setCurrentLayerPosition",value:function(e){var t,r=this.getNumLayers();if(!this.current_layer||e<0||e>=r)return null;for(t=0;t<r&&this.all_layers[t]!==this.current_layer;++t);if(t===r)return null;if(t!==e){var n=this.current_layer.getGroup(),i=n.nextSibling,a=null;return e>t?e<r-1&&(a=this.all_layers[e+1].getGroup()):a=this.all_layers[e].getGroup(),this.svgElem_.insertBefore(n,a),this.identifyLayers(),this.setCurrentLayer(this.getLayerName(e)),{currentGroup:n,oldNextSibling:i}}return null}},{key:"mergeLayer",value:function(e){var t=this.current_layer.getGroup(),r=Jt(t).prev()[0];if(r){e.startBatchCommand("Merge Layer");var n=t.nextSibling;for(e.removeElement(t,n,this.svgElem_);t.firstChild;){var i=t.firstChild;if("title"!==i.localName){var a=i.nextSibling;r.append(i),e.moveElement(i,a,t)}else e.removeElement(i,i.nextSibling,t),i.remove()}this.current_layer.removeGroup();var s=this.all_layers.indexOf(this.current_layer);if(s>0){var o=this.current_layer.getName();this.current_layer=this.all_layers[s-1],this.all_layers.splice(s,1),delete this.layer_map[o]}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,t=this.svgElem_.childNodes.length,r=[],n=[],i=null,a=!1,s=0;s<t;++s){var o=this.svgElem_.childNodes.item(s);if(o&&1===o.nodeType)if("g"===o.tagName){a=!0;var u=Jt("title",e=o).text()||(T()&&e.querySelectorAll?Jt(e.querySelectorAll("title")).text():"");u?(n.push(u),i=new Xt(u,o),this.all_layers.push(i),this.layer_map[u]=i):r.push(o)}else er.includes(o.nodeName)&&r.push(o)}r.length>0||!a?((i=new Xt(ar(n),null,this.svgElem_)).appendChildren(r),this.all_layers.push(i),this.layer_map[name]=i):i.activate(),this.current_layer=i}},{key:"createLayer",value:function(e,t){this.current_layer&&this.current_layer.deactivate(),(null==e||""===e||this.layer_map[e])&&(e=ar(Object.keys(this.layer_map)));var r=new Xt(e,null,this.svgElem_);return t&&(t.startBatchCommand("Create Layer"),t.insertElement(r.getGroup()),t.endBatchCommand()),this.all_layers.push(r),this.layer_map[e]=r,this.current_layer=r,r.getGroup()}},{key:"cloneLayer",value:function(e,t){var r=this;if(!this.current_layer)return null;this.current_layer.deactivate(),(null==e||""===e||this.layer_map[e])&&(e=ar(Object.keys(this.layer_map)));var n=this.current_layer.getGroup(),i=new Xt(e,n,this.svgElem_),a=i.getGroup();l(n.childNodes).forEach((function(e){"title"!==e.localName&&a.append(r.copyElem(e))})),t&&(t.startBatchCommand("Duplicate Layer"),t.insertElement(a),t.endBatchCommand());var s=this.all_layers.indexOf(this.current_layer);return s>=0?this.all_layers.splice(s+1,0,i):this.all_layers.push(i),this.layer_map[e]=i,this.current_layer=i,a}},{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 r=this.layer_map[e];return r?(r.setVisible(t),r.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 r=this.layer_map[e];r&&r.setOpacity(t)}}},{key:"copyElem",value:function(e){var t=this;return function e(t,r){var n=document.createElementNS(t.namespaceURI,t.nodeName);if(ot.each(t.attributes,(function(e,t){"-moz-math-font-style"!==t.localName&&n.setAttributeNS(t.namespaceURI,t.nodeName,t.value)})),n.removeAttribute("id"),n.id=r(),L()&&"path"===t.nodeName){var i=Je(t);n.setAttribute("d",i)}if(ot.each(t.childNodes,(function(t,i){switch(i.nodeType){case 1:n.append(e(i,r));break;case 3:n.textContent=i.nodeValue}})),ot(t).data("gsvg"))ot(n).data("gsvg",n.firstChild);else if(ot(t).data("symbol")){var a=ot(t).data("symbol");ot(n).data("ref",a).data("symbol",a)}else"image"===n.tagName&&Qt(n);return n}(e,(function(){return t.getNextId()}))}}]),e}(),ur=function(e,t){(rr=!1===e?tr.NEVER_RANDOMIZE:tr.ALWAYS_RANDOMIZE)!==tr.ALWAYS_RANDOMIZE||t.getNonce()?rr===tr.NEVER_RANDOMIZE&&t.getNonce()&&t.clearNonce():t.setNonce(Math.floor(100001*Math.random()))},lr=function(){_r(),sr.getCurrentDrawing().identifyLayers()},hr=function(e,t){var r=sr.getCurrentDrawing().createLayer(e,ir(t));sr.clearSelection(),sr.call("changed",[r])},cr=function(e,t){var r=sr.getCurrentDrawing().cloneLayer(e,ir(t));sr.clearSelection(),_r(),sr.call("changed",[r])},dr=function(){var e=sr.getCurrentDrawing().getCurrentLayer(),t=e.nextSibling,r=e.parentNode;if(e=sr.getCurrentDrawing().deleteCurrentLayer()){var n=new se("Delete Layer");return n.addSubCommand(new ie(e,t,r)),sr.addCommandToHistory(n),sr.clearSelection(),sr.call("changed",[r]),!0}return!1},mr=function(e){var t=sr.getCurrentDrawing().setCurrentLayer(gt(e));return t&&sr.clearSelection(),t},fr=function(e){var t=sr.getCurrentDrawing(),r=t.getCurrentLayer();if(r&&t.setCurrentLayerName(e,ir()))return sr.call("changed",[r]),!0;return!1},gr=function(e){var t=sr.getCurrentDrawing().setCurrentLayerPosition(e);return!!t&&(sr.addCommandToHistory(new re(t.currentGroup,t.oldNextSibling,sr.getSVGContent())),!0)},pr=function(e,t){var r=sr.getCurrentDrawing(),n=r.getLayerVisibility(e),i=r.setLayerVisibility(e,t);if(!i)return!1;var a=n?"inline":"none";return sr.addCommandToHistory(new ae(i,{display:a},"Layer Visibility")),i===r.getCurrentLayer()&&(sr.clearSelection(),sr.pathActions.clear()),!0},yr=function(e){var t=sr.getCurrentDrawing().getLayerByName(e);if(!t)return!1;for(var r=new se("Move Elements to Layer"),n=sr.getSelectedElements(),i=n.length;i--;){var a=n[i];if(a){var s=a.nextSibling,o=a.parentNode;t.append(a),r.addSubCommand(new re(a,s,o))}}return sr.addCommandToHistory(r),!0},vr=function(e){sr.getCurrentDrawing().mergeLayer(ir(e)),sr.clearSelection(),_r(),sr.changeSVGContent()},xr=function(e){sr.getCurrentDrawing().mergeAllLayers(ir(e)),sr.clearSelection(),_r(),sr.changeSVGContent()},_r=function(){var e=nr.length;if(e){for(var t=0;t<e;t++){var r=nr[t],n=sr.elData(r,"orig_opac");1!==n?r.setAttribute("opacity",n):r.removeAttribute("opacity"),r.setAttribute("style","pointer-events: inherit")}nr=[],sr.clearSelection(!0),sr.call("contextset",null)}sr.setCurrentGroup(null)},Sr=function(e){_r(),"string"==typeof e&&(e=Dt(e)),sr.setCurrentGroup(e),Jt(e).parentsUntil("#svgcontent").andSelf().siblings().each((function(){var e=this.getAttribute("opacity")||1;sr.elData(this,"orig_opac",e),this.setAttribute("opacity",.33*e),this.setAttribute("style","pointer-events: none"),nr.push(this)})),sr.clearSelection(),sr.call("contextset",sr.getCurrentGroup())},br=m(),wr={a:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","mask","opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","xlink:href","xlink:title"],circle:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","r","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],clipPath:["class","clipPathUnits","id"],defs:[],style:["type"],desc:[],ellipse:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],feGaussianBlur:["class","color-interpolation-filters","id","requiredFeatures","stdDeviation"],feMorphology:["class","in","operator","radius"],filter:["class","color-interpolation-filters","filterRes","filterUnits","height","id","primitiveUnits","requiredFeatures","width","x","xlink:href","y"],foreignObject:["class","font-size","height","id","opacity","requiredFeatures","style","transform","width","x","y"],g:["class","clip-path","clip-rule","id","display","fill","fill-opacity","fill-rule","filter","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","font-family","font-size","font-style","font-weight","text-anchor"],image:["class","clip-path","clip-rule","filter","height","id","mask","opacity","requiredFeatures","style","systemLanguage","transform","width","x","xlink:href","xlink:title","y"],line:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","x1","x2","y1","y2"],linearGradient:["class","id","gradientTransform","gradientUnits","requiredFeatures","spreadMethod","systemLanguage","x1","x2","xlink:href","y1","y2"],marker:["id","class","markerHeight","markerUnits","markerWidth","orient","preserveAspectRatio","refX","refY","systemLanguage","viewBox"],mask:["class","height","id","maskContentUnits","maskUnits","width","x","y"],metadata:["class","id"],path:["class","clip-path","clip-rule","d","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],pattern:["class","height","id","patternContentUnits","patternTransform","patternUnits","requiredFeatures","style","systemLanguage","viewBox","width","x","xlink:href","y"],polygon:["class","clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","id","class","marker-end","marker-mid","marker-start","mask","opacity","points","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],polyline:["class","clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","marker-end","marker-mid","marker-start","mask","opacity","points","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],radialGradient:["class","cx","cy","fx","fy","gradientTransform","gradientUnits","id","r","requiredFeatures","spreadMethod","systemLanguage","xlink:href"],rect:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","width","x","y"],stop:["class","id","offset","requiredFeatures","stop-color","stop-opacity","style","systemLanguage"],svg:["class","clip-path","clip-rule","filter","id","height","mask","preserveAspectRatio","requiredFeatures","style","systemLanguage","viewBox","width","x","xmlns","xmlns:se","xmlns:xlink","y"],switch:["class","id","requiredFeatures","systemLanguage"],symbol:["class","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","opacity","preserveAspectRatio","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","viewBox"],text:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","transform","x","xml:space","y"],textPath:["class","id","method","requiredFeatures","spacing","startOffset","style","systemLanguage","transform","xlink:href"],title:[],tspan:["class","clip-path","clip-rule","dx","dy","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","mask","opacity","requiredFeatures","rotate","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","textLength","transform","x","xml:space","y"],use:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","transform","width","x","xlink:href","y"],annotation:["encoding"],"annotation-xml":["encoding"],maction:["actiontype","other","selection"],math:["class","id","display","xmlns"],menclose:["notation"],merror:[],mfrac:["linethickness"],mi:["mathvariant"],mmultiscripts:[],mn:[],mo:["fence","lspace","maxsize","minsize","rspace","stretchy"],mover:[],mpadded:["lspace","width","height","depth","voffset"],mphantom:[],mprescripts:[],mroot:[],mrow:["xlink:href","xlink:type","xmlns:xlink"],mspace:["depth","height","width"],msqrt:[],mstyle:["displaystyle","mathbackground","mathcolor","mathvariant","scriptlevel"],msub:[],msubsup:[],msup:[],mtable:["align","columnalign","columnlines","columnspacing","displaystyle","equalcolumns","equalrows","frame","rowalign","rowlines","rowspacing","width"],mtd:["columnalign","columnspan","rowalign","rowspan"],mtext:[],mtr:["columnalign","rowalign"],munder:[],munderover:[],none:[],semantics:[]},Ar={};Object.entries(wr).forEach((function(e){var t=u(e,2),r=t[0],n=t[1],i={};Object.entries(n).forEach((function(e){var t=u(e,2),r=(t[0],t[1]);if(r.includes(":")){var n=r.split(":");i[n[1]]=d[n[0].toUpperCase()]}else i[r]="xmlns"===r?d.XMLNS:null})),Ar[r]=i}));var kr=function e(t){if(3===t.nodeType&&(t.nodeValue=t.nodeValue.replace(/^\s+|\s+$/g,""),t.nodeValue.length||t.remove()),1===t.nodeType){var r=t.ownerDocument,n=t.parentNode;if(r&&n){var i=wr[t.nodeName],a=Ar[t.nodeName];if(void 0!==i){for(var s=[],o=t.attributes.length;o--;){var l=t.attributes.item(o),h=l.nodeName,c=l.localName,m=l.namespaceURI;if({}.hasOwnProperty.call(a,c)&&m===a[c]&&m!==d.XMLNS||m===d.XMLNS&&br[l.value]||((h.startsWith("se:")||h.startsWith("data-"))&&s.push([h,l.value]),t.removeAttributeNS(m,c)),V())switch(h){case"transform":case"gradientTransform":case"patternTransform":var f=l.value.replace(/(\d)-/g,"$1 -");t.setAttribute(h,f)}if("style"===h){for(var g=l.value.split(";"),p=g.length;p--;){var y=u(g[p].split(":"),2),v=y[0],x=y[1],_=(v||"").trim(),S=(x||"").trim();i.includes(_)&&t.setAttribute(_,S)}t.removeAttribute("style")}}Object.values(s).forEach((function(e){var r=u(e,2),n=r[0],i=r[1];t.setAttributeNS(d.SE,n,i)}));var b=kt(t);if(b&&["filter","linearGradient","pattern","radialGradient","textPath","use"].includes(t.nodeName)&&"#"!==b[0]&&(Ct(t,""),t.removeAttributeNS(d.XLINK,"href")),"use"===t.nodeName&&!kt(t))return void t.remove();for(Object.values(["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],(function(e){var r=t.getAttribute(e);r&&(r=At(r))&&"#"!==r[0]&&(t.setAttribute(e,""),t.removeAttribute(e))})),o=t.childNodes.length;o--;)e(t.childNodes.item(o))}else{for(var w=[];t.hasChildNodes();)w.push(n.insertBefore(t.firstChild,t));t.remove();for(var A=w.length;A--;)e(w[A])}}}};function Cr(e,t){["id","class","type"].forEach((function(r){r in t&&(e[r]=t[r])}))}function Er(e,t){var r,n;return regeneratorRuntime.async((function(i){for(;;)switch(i.prev=i.next){case 0:if(r=t.global,n=t.returnDefault,!!("svgEditor"in window&&window.svgEditor&&!1===window.svgEditor.modules)){i.next=4;break}return i.abrupt("return",Gr(e,void 0,{returnDefault:n}));case 4:return i.next=6,regeneratorRuntime.awrap(Pr(e));case 6:return i.abrupt("return",window[r]);case 7:case"end":return i.stop()}}))}function Pr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Array.isArray(e)?Promise.all(e.map((function(e){return Pr(e,t)}))):new Promise((function(r,n){var i=document.createElement("script");function a(){n(new Error("Failed to import: ".concat(e))),o()}function s(){r(),o()}var o=function(){i.removeEventListener("error",a),i.removeEventListener("load",s),i.remove(),i.src=""};i.defer="defer",Cr(i,t),i.addEventListener("error",a),i.addEventListener("load",s),i.src=e,document.head.append(i)}))}function Gr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).returnDefault,n=void 0!==r&&r;return Array.isArray(e)?Promise.all(e.map((function(e){return Gr(e,t)}))):new Promise((function(r,i){var a="$importModule$"+Math.random().toString(32).slice(2),s=document.createElement("script");function o(){i(new Error("Failed to import: ".concat(e))),l()}function u(){r(window[a]),l()}var l=function(){delete window[a],s.removeEventListener("error",o),s.removeEventListener("load",u),s.remove(),URL.revokeObjectURL(s.src),s.src=""};Cr(s,t),s.defer="defer",s.type="module",s.addEventListener("error",o),s.addEventListener("load",u);var h=function(e){var t=document.createElement("a");return t.setAttribute("href",e),t.cloneNode(!1).href}(e),c="import * as m from '".concat(h.replace(/'/g,"\\'"),"'; window.").concat(a," = ").concat(n?"m.default || ":"","m;"),d=new Blob([c],{type:"text/javascript"});s.src=URL.createObjectURL(d),document.head.append(s)}))}var Nr,Ir,Tr,Lr,Vr=jQuery,Or=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Mr=null,Rr=function(e,t,r){for(var n=function(e,t){return ge(e,t,r)},i=function(e){return r.a*e},a=function(e){return r.d*e},s=Mr.getGridSnapping()&&"svg"===e.parentNode.parentNode.localName,o=function(){s&&Object.entries(t).forEach((function(e){var r=u(e,2),n=r[0],i=r[1];t[n]=Wt(i)})),zt(e,t,1e3,!0)},l=Nt(e),h=0;h<2;h++){var c=0===h?"fill":"stroke",d=e.getAttribute(c);if(d&&d.startsWith("url(")&&(r.a<0||r.d<0)){var m=Ft(d).cloneNode(!0);if(r.a<0){var f=m.getAttribute("x1"),g=m.getAttribute("x2");m.setAttribute("x1",-(f-1)),m.setAttribute("x2",-(g-1))}if(r.d<0){var p=m.getAttribute("y1"),y=m.getAttribute("y2");m.setAttribute("y1",-(p-1)),m.setAttribute("y2",-(y-1))}m.id=Mr.getDrawing().getNextId(),Et().append(m),e.setAttribute(c,"url(#"+m.id+")")}}var v=e.tagName;if("g"===v||"text"===v||"tspan"===v||"use"===v)if(1!==r.a||0!==r.b||0!==r.c||1!==r.d||0===r.e&&0===r.f){var x=q(e),_=Mr.getSVGRoot().createSVGTransform();_.setMatrix(ye(_e(x).matrix,r)),x.clear(),x.appendItem(_)}else{var S=_e(e).matrix,b=ye(S.inverse(),r,S);t.x=parseFloat(t.x)+b.e,t.y=parseFloat(t.y)+b.f}switch(v){case"foreignObject":case"rect":case"image":if("image"===v&&(r.a<0||r.d<0)){var w=q(e),A=Mr.getSVGRoot().createSVGTransform();A.setMatrix(ye(_e(w).matrix,r)),w.clear(),w.appendItem(A)}else{var k=n(t.x,t.y);t.width=i(t.width),t.height=a(t.height),t.x=k.x+Math.min(0,t.width),t.y=k.y+Math.min(0,t.height),t.width=Math.abs(t.width),t.height=Math.abs(t.height)}o();break;case"ellipse":var C=n(t.cx,t.cy);t.cx=C.x,t.cy=C.y,t.rx=i(t.rx),t.ry=a(t.ry),t.rx=Math.abs(t.rx),t.ry=Math.abs(t.ry),o();break;case"circle":var E=n(t.cx,t.cy);t.cx=E.x,t.cy=E.y;var P=xe(l.x,l.y,l.width,l.height,r),G=P.tr.x-P.tl.x,N=P.bl.y-P.tl.y;t.r=Math.min(G/2,N/2),t.r&&(t.r=Math.abs(t.r)),o();break;case"line":var I=n(t.x1,t.y1),T=n(t.x2,t.y2);t.x1=I.x,t.y1=I.y,t.x2=T.x,t.y2=T.y;case"text":case"tspan":case"use":o();break;case"g":var L=Vr(e).data("gsvg");L&&zt(L,t,1e3,!0);break;case"polyline":case"polygon":for(var V=t.points.length,O=0;O<V;++O){var M=t.points[O],R=n(M.x,M.y),B=R.x,U=R.y;t.points[O].x=B,t.points[O].y=U}for(var H="",j=0;j<V;++j){var F=t.points[j];H+=F.x+","+F.y+" "}e.setAttribute("points",H);break;case"path":var D=e.pathSegList,z=D.numberOfItems;t.d=[];for(var W=0;W<z;++W){var Q=D.getItem(W);t.d[W]={type:Q.pathSegType,x:Q.x,y:Q.y,x1:Q.x1,y1:Q.y1,x2:Q.x2,y2:Q.y2,r1:Q.r1,r2:Q.r2,angle:Q.angle,largeArcFlag:Q.largeArcFlag,sweepFlag:Q.sweepFlag}}z=t.d.length;var Y=t.d[0],Z=n(Y.x,Y.y);t.d[0].x=Z.x,t.d[0].y=Z.y;for(var X=1;X<z;++X){var K=t.d[X];if(K.type%2==0){var $=n(void 0!==K.x?K.x:Z.x,void 0!==K.y?K.y:Z.y),J=n(K.x1,K.y1),ee=n(K.x2,K.y2);K.x=$.x,K.y=$.y,K.x1=J.x,K.y1=J.y,K.x2=ee.x,K.y2=ee.y,K.r1=i(K.r1),K.r2=a(K.r2)}else K.x=i(K.x),K.y=a(K.y),K.x1=i(K.x1),K.y1=a(K.y1),K.x2=i(K.x2),K.y2=a(K.y2),K.r1=i(K.r1),K.r2=a(K.r2)}var te="";z=t.d.length;for(var re=0;re<z;++re){var ne=t.d[re],ie=ne.type;switch(te+=Or[ie],ie){case 13:case 12:te+=ne.x+" ";break;case 15:case 14:te+=ne.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:te+=ne.x+","+ne.y+" ";break;case 7:case 6:te+=ne.x1+","+ne.y1+" "+ne.x2+","+ne.y2+" "+ne.x+","+ne.y+" ";break;case 9:case 8:te+=ne.x1+","+ne.y1+" "+ne.x+","+ne.y+" ";break;case 11:case 10:te+=ne.r1+","+ne.r2+" "+ne.angle+" "+Number(ne.largeArcFlag)+" "+Number(ne.sweepFlag)+" "+ne.x+","+ne.y+" ";break;case 17:case 16:te+=ne.x2+","+ne.y2+" "+ne.x+","+ne.y+" "}}e.setAttribute("d",te)}},Br=h(jQuery),Ur=function(e,t,r){var n=Ft(e).firstChild,i=q(n),a=Nr.getSVGRoot().createSVGTransform();a.setTranslate(t,r),i.appendItem(a),Hr(n)},Hr=function e(t){if(Yt(t))return null;if("svg"===t.nodeName&&navigator.userAgent.includes("Firefox/20"))return null;var r=Nr.getSVGRoot(),n=q(t);if(n&&n.numberOfItems>0){for(var i=n.numberOfItems,a=i;i--;){var s=n.getItem(i);if(0===s.type)n.removeItem(i);else if(1===s.type){if(pe(s.matrix)){if(1===a)return t.removeAttribute("transform"),null;n.removeItem(i)}}else 4===s.type&&0===s.angle&&n.removeItem(i)}if(1===n.numberOfItems&&jt(t))return null}if(!n||0===n.numberOfItems)return t.setAttribute("transform",""),t.removeAttribute("transform"),null;if(n){for(var o=[],u=n.numberOfItems;u--;){var l=n.getItem(u);1===l.type?o.push([l.matrix,u]):o.length&&(o=[])}if(2===o.length){var h=r.createSVGTransformFromMatrix(ye(o[1][0],o[0][0]));n.removeItem(o[0][1]),n.removeItem(o[1][1]),n.insertItemBefore(h,o[1][1])}if((u=n.numberOfItems)>=2&&1===n.getItem(u-2).type&&2===n.getItem(u-1).type){var c=r.createSVGTransform(),m=ye(n.getItem(u-2).matrix,n.getItem(u-1).matrix);c.setMatrix(m),n.removeItem(u-2),n.removeItem(u-2),n.appendItem(c)}}switch(t.tagName){case"line":case"polyline":case"polygon":case"path":break;default:if(1===n.numberOfItems&&1===n.getItem(0).type||2===n.numberOfItems&&1===n.getItem(0).type&&4===n.getItem(0).type)return null}var f,g,p=Br(t).data("gsvg"),y=new se("Transform"),v={},x=null,_=[];switch(t.tagName){case"line":_=["x1","y1","x2","y2"];break;case"circle":_=["cx","cy","r"];break;case"ellipse":_=["cx","cy","rx","ry"];break;case"foreignObject":case"rect":case"image":_=["width","height","x","y"];break;case"use":case"text":case"tspan":_=["x","y"];break;case"polygon":case"polyline":(x={}).points=t.getAttribute("points");var S=t.points,b=S.numberOfItems;v.points=new Array(b);for(var w=0;w<b;++w){var A=S.getItem(w);v.points[w]={x:A.x,y:A.y}}break;case"path":(x={}).d=t.getAttribute("d"),v.d=t.getAttribute("d")}if(_.length?(v=Br(t).attr(_),Br.each(v,(function(e,t){v[e]=J(e,t)}))):p&&(v={x:Br(p).attr("x")||0,y:Br(p).attr("y")||0}),Yt(x)&&(x=Br.extend(!0,{},v),Br.each(x,(function(e,t){x[e]=J(e,t)}))),x.transform=Nr.getStartTransform()||"","g"===t.tagName&&!p||"a"===t.tagName){var k=Nt(t);f={x:k.x+k.width/2,y:k.y+k.height/2},g=ge(k.x+k.width/2,k.y+k.height/2,_e(n).matrix);var C=jt(t);if(C){var E,P=C*Math.PI/180;E=Math.abs(P)>1e-10?Math.sin(P)/(1-Math.cos(P)):2/P;for(var G=0;G<n.numberOfItems;++G){var N=n.getItem(G);if(4===N.type){var I=N.matrix;f.y=(E*I.e+I.f)/2,f.x=(I.e-E*I.f)/2,n.removeItem(G);break}}}var T,V,O=n.numberOfItems,M=0,R=0,B=0;if(O&&(T=n.getItem(0).matrix),O>=3&&3===n.getItem(O-2).type&&2===n.getItem(O-3).type&&2===n.getItem(O-1).type){B=3;for(var U=n.getItem(O-3).matrix,H=n.getItem(O-2).matrix,j=n.getItem(O-1).matrix,F=t.childNodes,D=F.length;D--;){var z=F.item(D);if(M=0,R=0,1===z.nodeType){var W=q(z);if(!W)continue;var Q=_e(W).matrix,Y=jt(z);if(V=Nr.getStartTransform(),Nr.setStartTransform(z.getAttribute("transform")),Y||ve(W)){var Z=r.createSVGTransform();Z.setMatrix(ye(U,H,j,Q)),W.clear(),W.appendItem(Z)}else{var X=ye(Q.inverse(),j,Q),K=r.createSVGMatrix();K.e=-X.e,K.f=-X.f;var $=ye(K.inverse(),Q.inverse(),U,H,j,Q,X.inverse()),ee=r.createSVGTransform(),te=r.createSVGTransform(),re=r.createSVGTransform();ee.setTranslate(X.e,X.f),te.setScale($.a,$.d),re.setTranslate(K.e,K.f),W.appendItem(re),W.appendItem(te),W.appendItem(ee)}y.addSubCommand(e(z)),Nr.setStartTransform(V)}}n.removeItem(O-1),n.removeItem(O-2),n.removeItem(O-3)}else if(O>=3&&1===n.getItem(O-1).type){B=3;var ne=_e(n).matrix,ie=r.createSVGTransform();ie.setMatrix(ne),n.clear(),n.appendItem(ie)}else if((1===O||O>1&&3!==n.getItem(1).type)&&2===n.getItem(0).type){B=2;var oe=_e(n).matrix;n.removeItem(0);var ue=_e(n).matrix.inverse(),le=ye(ue,oe);if(M=le.e,R=le.f,0!==M||0!==R){for(var he=t.childNodes,ce=he.length,de=[];ce--;){var me=he.item(ce);if(1===me.nodeType){if(me.getAttribute("clip-path")){var fe=me.getAttribute("clip-path");de.includes(fe)||(Ur(fe,M,R),de.push(fe))}V=Nr.getStartTransform(),Nr.setStartTransform(me.getAttribute("transform"));var xe=q(me);if(xe){var Se=r.createSVGTransform();Se.setTranslate(M,R),xe.numberOfItems?xe.insertItemBefore(Se,0):xe.appendItem(Se),y.addSubCommand(e(me));for(var be=t.getElementsByTagNameNS(d.SVG,"use"),we="#"+me.id,Ae=be.length;Ae--;){var ke=be.item(Ae);if(we===kt(ke)){var Ce=r.createSVGTransform();Ce.setTranslate(-M,-R),q(ke).insertItemBefore(Ce,0),y.addSubCommand(e(ke))}}Nr.setStartTransform(V)}}}Nr.setStartTransform(V)}}else{if(1!==O||1!==n.getItem(0).type||C){if(C){var Ee=r.createSVGTransform();Ee.setRotate(C,g.x,g.y),n.numberOfItems?n.insertItemBefore(Ee,0):n.appendItem(Ee)}return 0===n.numberOfItems&&t.removeAttribute("transform"),null}B=1;for(var Pe=n.getItem(0).matrix,Ge=t.childNodes,Ne=Ge.length;Ne--;){var Ie=Ge.item(Ne);if(1===Ie.nodeType){V=Nr.getStartTransform(),Nr.setStartTransform(Ie.getAttribute("transform"));var Te=q(Ie);if(!Te)continue;var Le=ye(Pe,_e(Te).matrix),Ve=r.createSVGTransform();Ve.setMatrix(Le),Te.clear(),Te.appendItem(Ve,0),y.addSubCommand(e(Ie)),Nr.setStartTransform(V);var Oe=Ie.getAttribute("stroke-width");if("none"!==Ie.getAttribute("stroke")&&!isNaN(Oe)){var Me=(Math.abs(Le.a)+Math.abs(Le.d))/2;Ie.setAttribute("stroke-width",Oe*Me)}}}n.clear()}if(2===B){if(C){g={x:f.x+T.e,y:f.y+T.f};var Re=r.createSVGTransform();Re.setRotate(C,g.x,g.y),n.numberOfItems?n.insertItemBefore(Re,0):n.appendItem(Re)}}else if(3===B){var Be=_e(n).matrix,Ue=r.createSVGTransform();Ue.setRotate(C,f.x,f.y);var He=Ue.matrix,je=r.createSVGTransform();je.setRotate(C,g.x,g.y);var Fe=je.matrix.inverse(),De=Be.inverse(),ze=ye(De,Fe,He,Be);if(M=ze.e,R=ze.f,0!==M||0!==R)for(var qe=t.childNodes,We=qe.length;We--;){var Qe=qe.item(We);if(1===Qe.nodeType){V=Nr.getStartTransform(),Nr.setStartTransform(Qe.getAttribute("transform"));var Ye=q(Qe),Ze=r.createSVGTransform();Ze.setTranslate(M,R),Ye.numberOfItems?Ye.insertItemBefore(Ze,0):Ye.appendItem(Ze),y.addSubCommand(e(Qe)),Nr.setStartTransform(V)}}C&&(n.numberOfItems?n.insertItemBefore(je,0):n.appendItem(je))}}else{var Xe,Ke=Nt(t);if(!Ke&&"path"!==t.tagName)return null;var $e=jt(t);if($e){f={x:Ke.x+Ke.width/2,y:Ke.y+Ke.height/2},g=ge(Ke.x+Ke.width/2,Ke.y+Ke.height/2,_e(n).matrix);for(var Je=$e*Math.PI/180,et=Math.abs(Je)>1e-10?Math.sin(Je)/(1-Math.cos(Je)):2/Je,tt=0;tt<n.numberOfItems;++tt){var rt=n.getItem(tt);if(4===rt.type){var nt=rt.matrix;f.y=(et*nt.e+nt.f)/2,f.x=(nt.e-et*nt.f)/2,n.removeItem(tt);break}}}var it=0,at=n.numberOfItems;if(!L()){var st=t.getAttribute("fill");if(st&&st.startsWith("url(")){var ot=Ft(st),ut="pattern";if(ot.tagName!==ut&&(ut="gradient"),"userSpaceOnUse"===ot.getAttribute(ut+"Units")){Xe=_e(n).matrix;var lt=q(ot),ht=_e(lt).matrix,ct="matrix("+[(Xe=ye(Xe,ht)).a,Xe.b,Xe.c,Xe.d,Xe.e,Xe.f].join(",")+")";ot.setAttribute(ut+"Transform",ct)}}}if(at>=3&&3===n.getItem(at-2).type&&2===n.getItem(at-3).type&&2===n.getItem(at-1).type)it=3,Xe=_e(n,at-3,at-1).matrix,n.removeItem(at-1),n.removeItem(at-2),n.removeItem(at-3);else if(4===at&&1===n.getItem(at-1).type){it=3,Xe=_e(n).matrix;var dt=r.createSVGTransform();dt.setMatrix(Xe),n.clear(),n.appendItem(dt),Xe=r.createSVGMatrix()}else if((1===at||at>1&&3!==n.getItem(1).type)&&2===n.getItem(0).type){it=2;var mt=n.getItem(0).matrix,ft=_e(n,1).matrix,gt=ft.inverse();Xe=ye(gt,mt,ft),n.removeItem(0)}else{if(1!==at||1!==n.getItem(0).type||$e){if($e){var pt=r.createSVGTransform();pt.setRotate($e,g.x,g.y),n.numberOfItems?n.insertItemBefore(pt,0):n.appendItem(pt)}return 0===n.numberOfItems&&t.removeAttribute("transform"),null}switch(Xe=_e(n).matrix,t.tagName){case"line":v=Br(t).attr(["x1","y1","x2","y2"]);case"polyline":case"polygon":if(v.points=t.getAttribute("points"),v.points){var yt=t.points,vt=yt.numberOfItems;v.points=new Array(vt);for(var xt=0;xt<vt;++xt){var _t=yt.getItem(xt);v.points[xt]={x:_t.x,y:_t.y}}}case"path":v.d=t.getAttribute("d"),it=1,n.clear()}}if(1!==it&&2!==it&&3!==it||Rr(t,v,Xe),2===it){if($e){ve(n)||(g={x:f.x+Xe.e,y:f.y+Xe.f});var St=r.createSVGTransform();St.setRotate($e,g.x,g.y),n.numberOfItems?n.insertItemBefore(St,0):n.appendItem(St)}if("text"===t.tagName)for(var bt=t.childNodes,wt=bt.length;wt--;){var At=bt.item(wt);if("tspan"===At.tagName){var Ct={x:Br(At).attr("x")||0,y:Br(At).attr("y")||0};Rr(At,Ct,Xe)}}}else if(3===it&&$e){var Et=_e(n).matrix,Pt=r.createSVGTransform();Pt.setRotate($e,f.x,f.y);var Gt=Pt.matrix,It=r.createSVGTransform();It.setRotate($e,g.x,g.y);var Tt=It.matrix.inverse(),Lt=Et.inverse(),Vt=ye(Lt,Tt,Gt,Et);Rr(t,v,Vt),$e&&(n.numberOfItems?n.insertItemBefore(It,0):n.appendItem(It))}}return 0===n.numberOfItems&&t.removeAttribute("transform"),y.addSubCommand(new ae(t,x)),y},jr=jQuery,Fr=b?10:4,Dr=function(){function e(r,n,i){t(this,e),this.id=r,this.selectedElement=n,this.locked=!0,this.selectorGroup=Ir.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}}),this.selectorRect=this.selectorGroup.appendChild(Ir.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#22C","stroke-width":"1","stroke-dasharray":"5,5",style:"pointer-events:none"}})),this.gripCoords={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null},this.reset(this.selectedElement,i)}return n(e,[{key:"reset",value:function(e,t){this.locked=!0,this.selectedElement=e,this.resize(t),this.selectorGroup.setAttribute("display","inline")}},{key:"showGrips",value:function(t){var r=t?"inline":"none";Lr.selectorGripsGroup.setAttribute("display",r);var n=this.selectedElement;this.hasGrips=t,n&&t&&(this.selectorGroup.append(Lr.selectorGripsGroup),e.updateGripCursors(jt(n)))}},{key:"resize",value:function(e){var t=this.selectorRect,r=Lr,n=r.selectorGrips,i=this.selectedElement,a=i.getAttribute("stroke-width"),s=Ir.getCurrentZoom(),o=1/s;"none"===i.getAttribute("stroke")||isNaN(a)||(o+=a/2);var l=i.tagName;"text"===l&&(o+=2/s);var h=q(i),c=_e(h).matrix;if(c.e*=s,c.f*=s,e||(e=Nt(i)),"g"===l&&!jr.data(i,"gsvg")){var d=Rt([i.childNodes]);d&&(e=d)}var m=e.x,f=e.y,g=e.width,p=e.height;o*=s;var y=xe(m*s,f*s,g*s,p*s,c),v=y.aabox,x=v.x-o,_=v.y-o,S=v.width+2*o,b=v.height+2*o,w=x+S/2,A=_+b/2,k=jt(i);if(k){var C=Ir.svgRoot().createSVGTransform();C.setRotate(-k,w,A);var E=C.matrix;y.tl=ge(y.tl.x,y.tl.y,E),y.tr=ge(y.tr.x,y.tr.y,E),y.bl=ge(y.bl.x,y.bl.y,E),y.br=ge(y.br.x,y.br.y,E);var P=y.tl,G=P.x,N=P.y,I=P.x,T=P.y,L=Math.min,V=Math.max;x=G=L(G,L(y.tr.x,L(y.bl.x,y.br.x)))-o,_=N=L(N,L(y.tr.y,L(y.bl.y,y.br.y)))-o,S=(I=V(I,V(y.tr.x,V(y.bl.x,y.br.x)))+o)-G,b=(T=V(T,V(y.tr.y,V(y.bl.y,y.br.y)))+o)-N}var O="M"+x+","+_+" L"+(x+S)+","+_+" "+(x+S)+","+(_+b)+" "+x+","+(_+b)+"z";t.setAttribute("d",O);var M=k?"rotate("+[k,w,A].join(",")+")":"";this.selectorGroup.setAttribute("transform",M),this.gripCoords={nw:[x,_],ne:[x+S,_],sw:[x,_+b],se:[x+S,_+b],n:[x+S/2,_],w:[x,_+b/2],e:[x+S,_+b/2],s:[x+S/2,_+b]},Object.entries(this.gripCoords).forEach((function(e){var t=u(e,2),r=t[0],i=t[1];n[r].setAttribute("cx",i[0]),n[r].setAttribute("cy",i[1])})),r.rotateGripConnector.setAttribute("x1",x+S/2),r.rotateGripConnector.setAttribute("y1",_),r.rotateGripConnector.setAttribute("x2",x+S/2),r.rotateGripConnector.setAttribute("y2",_-5*Fr),r.rotateGrip.setAttribute("cx",x+S/2),r.rotateGrip.setAttribute("cy",_-5*Fr)}}],[{key:"updateGripCursors",value:function(e){var t=Object.keys(Lr.selectorGrips),r=Math.round(e/45);for(r<0&&(r+=8);r>0;)t.push(t.shift()),r--;Object.values(Lr.selectorGrips).forEach((function(e,r){e.setAttribute("style","cursor:"+t[r]+"-resize")}))}}]),e}(),zr=function(){function r(){t(this,r),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 n(r,[{key:"initGroup",value:function(){var e=this;if(this.selectorParentGroup&&this.selectorParentGroup.parentNode&&this.selectorParentGroup.remove(),this.selectorParentGroup=Ir.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}}),this.selectorGripsGroup=Ir.createSVGElement({element:"g",attr:{display:"none"}}),this.selectorParentGroup.append(this.selectorGripsGroup),Ir.svgRoot().append(this.selectorParentGroup),this.selectorMap={},this.selectors=[],this.rubberBandBox=null,Object.keys(this.selectorGrips).forEach((function(t){var r=Ir.createSVGElement({element:"circle",attr:{id:"selectorGrip_resize_"+t,fill:"#22C",r:Fr,style:"cursor:"+t+"-resize","stroke-width":2,"pointer-events":"all"}});jr.data(r,"dir",t),jr.data(r,"type","resize"),e.selectorGrips[t]=e.selectorGripsGroup.appendChild(r)})),this.rotateGripConnector=this.selectorGripsGroup.appendChild(Ir.createSVGElement({element:"line",attr:{id:"selectorGrip_rotateconnector",stroke:"#22C","stroke-width":"1"}})),this.rotateGrip=this.selectorGripsGroup.appendChild(Ir.createSVGElement({element:"circle",attr:{id:"selectorGrip_rotate",fill:"lime",r:Fr,stroke:"#22C","stroke-width":2,style:"cursor:url("+Tr.imgPath+"rotate.png) 12 12, auto;"}})),jr.data(this.rotateGrip,"type","rotate"),!jr("#canvasBackground").length){var t=u(Tr.dimensions,2),r=t[0],n=t[1],i=Ir.createSVGElement({element:"svg",attr:{id:"canvasBackground",width:r,height:n,x:0,y:0,overflow:L()?"none":"visible",style:"pointer-events:none"}}),a=Ir.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(a),Ir.svgRoot().insertBefore(i,Ir.svgContent())}}},{key:"requestSelector",value:function(t,r){if(Yt(t))return null;var n=this.selectors.length;if("object"===e(this.selectorMap[t.id]))return this.selectorMap[t.id].locked=!0,this.selectorMap[t.id];for(var i=0;i<n;++i)if(this.selectors[i]&&!this.selectors[i].locked)return this.selectors[i].locked=!0,this.selectors[i].reset(t,r),this.selectorMap[t.id]=this.selectors[i],this.selectors[i];return this.selectors[n]=new Dr(n,t,r),this.selectorParentGroup.append(this.selectors[n].selectorGroup),this.selectorMap[t.id]=this.selectors[n],this.selectors[n]}},{key:"releaseSelector",value:function(e){if(!Yt(e)){var t=this.selectors.length,r=this.selectorMap[e.id];r.locked||console.log("WARNING! selector was released but was already unlocked");for(var n=0;n<t;++n)if(this.selectors[n]&&this.selectors[n]===r){delete this.selectorMap[e.id],r.locked=!1,r.selectedElement=null,r.showGrips(!1);try{r.selectorGroup.setAttribute("display","none")}catch(e){}break}}}},{key:"getRubberBandBox",value:function(){return this.rubberBandBox||(this.rubberBandBox=this.selectorParentGroup.appendChild(Ir.createSVGElement({element:"rect",attr:{id:"selectorRubberBand",fill:"#22C","fill-opacity":.15,stroke:"#22C","stroke-width":.5,display:"none",style:"pointer-events:none"}}))),this.rubberBandBox}}]),r}(),qr=h(jQuery),Wr=re,Qr=ne,Yr=ie,Zr=ae,Xr=se,Kr=de,$r=ee;window.console||(window.console={},window.console.log=function(e){},window.console.dir=function(e){}),window.opera&&(window.console.log=function(e){window.opera.postError(e)},window.console.dir=function(e){});return function r(n,i){t(this,r);var a={show_outside_canvas:!0,selectNew:!0,dimensions:[640,480]};i&&qr.extend(a,i);var s=a.dimensions,o=this,h=n.ownerDocument,c=h.importNode(bt('<svg id="svgroot" xmlns="'+d.SVG+'" xlinkns="'+d.XLINK+'" width="'+s[0]+'" height="'+s[1]+'" x="'+s[0]+'" y="'+s[1]+'" overflow="visible"><defs><filter id="canvashadow" filterUnits="objectBoundingBox"><feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/><feOffset in="blur" dx="5" dy="5" result="offsetBlur"/><feMerge><feMergeNode in="offsetBlur"/><feMergeNode in="SourceGraphic"/></feMerge></filter></defs></svg>').documentElement,!0);n.append(c);var f=h.createElementNS(d.SVG,"svg");(o.clearSvgContentElement=function(){qr(f).empty(),qr(f).attr({id:"svgcontent",width:s[0],height:s[1],x:s[0],y:s[1],overflow:a.show_outside_canvas?"visible":"hidden",xmlns:d.SVG,"xmlns:se":d.SE,"xmlns:xlink":d.XLINK}).appendTo(c);var e=h.createComment(" Created with SVG-edit - https://github.com/SVG-Edit/svgedit");f.append(e)})();var g="svg_";o.setIdPrefix=function(e){g=e},o.current_drawing_=new or(f,g);var p=o.getCurrentDrawing=function(){return o.current_drawing_},y=1,v=null,x={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}};x.text=qr.extend(!0,{},x.shape),qr.extend(x.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 _=x.shape,S=[],b=this.getJsonFromSvgElement=function(e){if(3===e.nodeType)return e.nodeValue;for(var t,r={element:e.tagName,attr:{},children:[]},n=0;t=e.attributes[n];n++)r.attr[t.name]=t.value;for(var i,a=0;i=e.childNodes[a];a++)r.children[a]=b(i);return r},w=this.addSVGElementFromJson=function(e){if("string"==typeof e)return h.createTextNode(e);var t=Dt(e.attr.id),r=p().getCurrentLayer();if(t&&e.element!==t.tagName&&(t.remove(),t=null),!t){var n=e.namespace||d.SVG;t=h.createElementNS(n,e.element),r&&(v||r).append(t)}return e.curStyles&&zt(t,{fill:_.fill,stroke:_.stroke,"stroke-width":_.stroke_width,"stroke-dasharray":_.stroke_dasharray,"stroke-linejoin":_.stroke_linejoin,"stroke-linecap":_.stroke_linecap,"stroke-opacity":_.stroke_opacity,"fill-opacity":_.fill_opacity,opacity:_.opacity/2,style:"pointer-events:inherit"}),zt(t,e.attr),qt(t),e.children&&e.children.forEach((function(e){t.append(w(e))})),t};o.getTransformList=q,o.matrixMultiply=ye,o.hasMatrixTransform=ve,o.transformListToTransform=_e;var A=function(){return a.baseUnit};!function(e){j=e;var t=document.createElementNS(d.SVG,"svg");document.body.append(t);var r=document.createElementNS(d.SVG,"rect");r.setAttribute("width","1em"),r.setAttribute("height","1ex"),r.setAttribute("x","1in"),t.append(r);var n=r.getBBox();t.remove();var i=n.x;Y={em:n.width,ex:n.height,in:i,cm:i/2.54,mm:i/25.4,pt:i/72,pc:i/6,px:1,"%":0}}({getBaseUnit:A,getElement:Dt,getHeight:function(){return f.getAttribute("height")/y},getWidth:function(){return f.getAttribute("width")/y},getRoundDigits:function(){return de.round_digits}}),o.convertToNum=J;var k,C=function(){return f},P=this.getSelectedElems=function(){return S},G=st,N=function(){return c};ht=k={pathActions:G,getSVGContent:C,addSVGElementFromJson:w,getSelectedElements:P,getDOMDocument:function(){return h},getDOMContainer:function(){return n},getSVGRoot:N,getBaseUnit:A,getSnappingStep:function(){return a.snappingStep}},ct=k.getDOMDocument(),dt=k.getDOMContainer(),mt=k.getSVGRoot(),o.findDefs=Et,o.getUrlFromAttr=At,o.getHref=kt,o.setHref=Ct,o.getBBox=Nt,o.getRotationAngle=jt,o.getElem=Dt,o.getRefElem=Ft,o.assignAttributes=zt,this.cleanupElement=qt;var I=function(){return a.gridSnapping};!function(e){Mr=e}({getDrawing:function(){return p()},getSVGRoot:N,getGridSnapping:I}),this.remapElement=Rr,function(e){Nr=e}({getSVGRoot:N,getStartTransform:function(){return Te},setStartTransform:function(e){Te=e}}),this.recalculateDimensions=Hr;var T=m();o.sanitizeSvg=kr;var R=o.undoMgr=new Kr({handleHistoryEvent:function(e,t){var r=$r;if(e===r.BEFORE_UNAPPLY||e===r.BEFORE_APPLY)o.clearSelection();else if(e===r.AFTER_APPLY||e===r.AFTER_UNAPPLY){var n=t.elements();o.pathActions.clear(),ee("changed",n);var i=t.type(),a=e===r.AFTER_APPLY;if(i===Wr.type())(a?t.newParent:t.oldParent)===f&&lr();else if(i===Qr.type()||i===Yr.type())t.parent===f&&lr(),i===Qr.type()?a&&he(t.elem):a||he(t.elem),"use"===t.elem.tagName&&$t(t.elem);else if(i===Zr.type()){"title"===t.elem.tagName&&t.elem.parentNode.parentNode===f&&lr();var s=a?t.newValues:t.oldValues;s.stdDeviation&&o.setBlurOffsets(t.elem.parentNode,s.stdDeviation)}}}}),U=function(e){o.undoMgr.addCommandToHistory(e)},H=this.getZoom=function(){return y},z=this.round=function(e){return parseInt(e*y)/y};!function(e,t){Tr=e,Ir=t,Lr=new zr}(a,{createSVGElement:function(e){return o.addSVGElementFromJson(e)},svgRoot:function(){return c},svgContent:function(){return f},getCurrentZoom:H});var W=this.selectorManager=Lr,Q=o.getNextId=function(){return p().getNextId()},$=o.getId=function(){return p().getId()},ee=function(e,t){if(qe[e])return qe[e](window,t)},te=this.clearSelection=function(e){S.forEach((function(e){Yt(e)||W.releaseSelector(e)})),S=[],e||ee("selected",S)},re=this.addToSelection=function(e,t){if(e.length){for(var r=0;r<S.length&&!Yt(S[r]);)++r;for(var n=e.length;n--;){var i=e[n];if(i){var a=Nt(i);if(a&&("a"===i.tagName&&1===i.childNodes.length&&(i=i.firstChild),!S.includes(i))){S[r]=i,r++;var s=W.requestSelector(i,a);S.length>1&&s.showGrips(!1)}}}for(ee("selected",S),t||1===S.length?W.requestSelector(S[0]).showGrips(!0):W.requestSelector(S[0]).showGrips(!1),S.sort((function(e,t){return e&&t&&e.compareDocumentPosition?3-(6&t.compareDocumentPosition(e)):Yt(e)?1:0}));Yt(S[0]);)S.shift(0)}},ne=function(){return _.opacity},ie=this.getMouseTarget=function(e){if(Yt(e))return null;var t=e.target;if(t.correspondingUseElement&&(t=t.correspondingUseElement),[d.MATH,d.HTML].includes(t.namespaceURI)&&"svgcanvas"!==t.id)for(;"foreignObject"!==t.nodeName;)if(!(t=t.parentNode))return c;var r=p().getCurrentLayer();if([c,n,f,r].includes(t))return c;if(qr(t).closest("#selectorParentGroup").length)return W.selectorParentGroup;for(;t.parentNode!==(v||r);)t=t.parentNode;return t};o.pathActions=G,Le({selectorManager:W,canvas:o,call:ee,resetD:function(e){e.setAttribute("d",G.convertPath(e))},round:z,clearSelection:te,addToSelection:re,addCommandToHistory:U,remapElement:Rr,addSVGElementFromJson:w,getGridSnapping:I,getOpacity:ne,getSelectedElements:P,getContainer:function(){return n},setStarted:function(e){Ge=e},getRubberBox:function(){return Be},setRubberBox:function(e){return Be=e},addPtsToSelection:function(e){var t=e.closedSubpath,r=e.grips;G.canDeleteNodes=!0,G.closed_subpath=t,ee("pointsAdded",{closedSubpath:t,grips:r}),ee("selected",r)},endChanges:function(e){var t=e.cmd,r=e.elem;U(t),ee("changed",[r])},getCurrentZoom:H,getId:$,getNextId:Q,getMouseTarget:ie,getCurrentMode:function(){return Ve},setCurrentMode:function(e){return Ve=e},getDrawnPath:function(){return Mt},setDrawnPath:function(e){return Mt=e},getSVGRoot:N});var ae={},se="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use",oe=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],ue=qr.data,le=document.createElementNS(d.SVG,"animate");qr(le).attr({attributeName:"opacity",begin:"indefinite",dur:1,fill:"freeze"}).appendTo(c);var he=function e(t){var r=qr(t).attr(oe);Object.values(r).forEach((function(e){if(e&&e.startsWith("url(")){var t=At(e).substr(1);Dt(t)||(Et().append(Ce[t]),delete Ce[t])}}));var n=t.getElementsByTagName("*");if(n.length)for(var i=0,a=n.length;i<a;i++)e(n[i])},ce={},de={round_digits:5},fe={},Ae=x.text,ke={},Ce={},Pe=a.imgPath+"logo.png",Ge=!1,Te=null,Ve="select",Oe="none",Me=_,Re=null,Be=null,Ue=[],He=null;this.runExtension=function(e,t,r){return this.runExtensions(t,r,!1,(function(t){return t===e}))};var je=this.runExtensions=function(e,t,r,n){var i=!!r&&[];return qr.each(ke,(function(a,s){n&&!n(a)||s&&e in s&&("function"==typeof t&&(t=t(a)),r?i.push(s[e](t)):i=s[e](t))})),i};this.addExtension=function(e,t,r){var n,i,a,s;return regeneratorRuntime.async((function(u){for(;;)switch(u.prev=u.next){case 0:if(n=r.$,i=r.importLocale,"function"==typeof t){u.next=3;break}throw new TypeError("Function argument expected for `svgcanvas.addExtension`");case 3:if(!(e in ke)){u.next=5;break}throw new Error('Cannot add extension "'+e+'", an extension by that name already exists.');case 5:return a=qr.extend(o.getPrivateMethods(),{$:n,importLocale:i,svgroot:c,svgcontent:f,nonce:p().getNonce(),selectorManager:W}),u.next=8,regeneratorRuntime.awrap(t(a));case 8:return(s=u.sent)&&(s.name=e),ke[e]=s,u.abrupt("return",ee("extension_added",s));case 12:case"end":return u.stop()}}))};var Fe=this.getIntersectionList=function(e){if(Yt(Be))return null;var t,r=v||p().getCurrentLayer();if(e)(t=f.createSVGRect()).x=e.x,t.y=e.y,t.width=e.width,t.height=e.height;else{t=Be.getBBox();var n=f.createSVGRect();["x","y","width","height","top","right","bottom","left"].forEach((function(e){n[e]=t[e]/y})),t=n}var i=null;if(O()||"function"==typeof c.getIntersectionList&&(t.x+=parseInt(f.getAttribute("x")),t.y+=parseInt(f.getAttribute("y")),i=c.getIntersectionList(t,r)),Yt(i)||"function"!=typeof i.item){i=[],Ue.length||(Ue=De(r));for(var a=Ue.length;a--;)t.width&&we(t,Ue[a].bbox)&&i.push(Ue[a].elem)}return i};this.getStrokedBBox=Ut,this.getVisibleElements=Bt;var De=this.getVisibleElementsAndBBoxes=function(e){e||(e=qr(f).children());var t=[];return qr(e).children().each((function(e,r){r.getBBox&&t.push({elem:r,bbox:Ut([r])})})),t.reverse()},ze=this.groupSvgElem=function(e){var t=document.createElementNS(d.SVG,"g");e.replaceWith(t),qr(t).append(e).data("gsvg",e)[0].id=Q()},qe={};o.call=ee,o.bind=function(e,t){var r=qe[e];return qe[e]=t,r},this.prepareSvg=function(e){this.sanitizeSvg(e.documentElement),l(e.getElementsByTagNameNS(d.SVG,"path")).forEach((function(e){e.setAttribute("d",G.convertPath(e)),G.fixEnd(e)}))};var We=function(e){if(!V())return e;var t=e.cloneNode(!0);return e.before(t),e.remove(),W.releaseSelector(e),S[0]=t,W.requestSelector(t).showGrips(!0),t};this.setRotationAngle=function(e,t){e=parseFloat(e);var r=S[0],n=r.getAttribute("transform"),i=Nt(r),a=i.x+i.width/2,s=i.y+i.height/2,o=q(r);o.numberOfItems>0&&(4===o.getItem(0).type&&o.removeItem(0));if(0!==e){var u=ge(a,s,_e(o).matrix),l=c.createSVGTransform();l.setRotate(e,u.x,u.y),o.numberOfItems?o.insertItemBefore(l,0):o.appendItem(l)}else 0===o.numberOfItems&&r.removeAttribute("transform");if(!t){var h=r.getAttribute("transform");r.setAttribute("transform",n),wr("transform",h,S),ee("changed",S)}W.requestSelector(S[0]).resize(),Dr.updateGripCursors(e)};var Qe=this.recalculateAllSelectedDimensions=function(){for(var e=new Xr("none"===Oe?"position":"size"),t=S.length;t--;){var r=S[t],n=Hr(r);n&&e.addSubCommand(n)}e.isEmpty()||(U(e),ee("changed",S))},Ye=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},Xe=null,Ke=this.selectOnly=function(e,t){te(!0),re(e,t)};this.removeFromSelection=function(e){if(!Yt(S[0])&&e.length){for(var t=[],r=S.length,n=0;n<r;++n){var i=S[n];i&&(e.includes(i)?W.releaseSelector(i):t.push(i))}S=t}},this.selectAllInCurrentLayer=function(){var e=p().getCurrentLayer();e&&(Ve="select",Ke(qr(v||e).children()))};var $e,Je,et,tt,rt,nt,it,at,ut,lt,vt,xt,Gt,It,Ot,Mt=null;Je={minx:null,miny:null,maxx:null,maxy:null},et=null,tt=null,rt=null,nt=null,it={},at=0,ut={x:0,y:0},lt={x:0,y:0},vt={x:0,y:0},xt={x:0,y:0},Gt={x:0,y:0},It={x:0,y:0},Ot=function(e){var t={x:0,y:0},r=ut,n=lt,i=vt,a=xt,s=e*e,o=s*e,u=[[-1,3,-3,1],[3,-6,3,0],[-3,0,3,0],[1,4,1,0]];return t.x=1/6*((r.x*u[0][0]+n.x*u[0][1]+i.x*u[0][2]+a.x*u[0][3])*o+(r.x*u[1][0]+n.x*u[1][1]+i.x*u[1][2]+a.x*u[1][3])*s+(r.x*u[2][0]+n.x*u[2][1]+i.x*u[2][2]+a.x*u[2][3])*e+(r.x*u[3][0]+n.x*u[3][1]+i.x*u[3][2]+a.x*u[3][3])),t.y=1/6*((r.y*u[0][0]+n.y*u[0][1]+i.y*u[0][2]+a.y*u[0][3])*o+(r.y*u[1][0]+n.y*u[1][1]+i.y*u[1][2]+a.y*u[1][3])*s+(r.y*u[2][0]+n.y*u[2][1]+i.y*u[2][2]+a.y*u[2][3])*e+(r.y*u[3][0]+n.y*u[3][1]+i.y*u[3][2]+a.y*u[3][3])),{x:t.x,y:t.y}},qr(n).mousedown((function(e){if(!o.spaceKey&&1!==e.button){var t=2===e.button;e.altKey&&o.cloneSelectedElements(0,0),Xe=qr("#svgcontent g")[0].getScreenCTM().inverse();var r=ge(e.pageX,e.pageY,Xe),n=r.x*y,i=r.y*y;e.preventDefault(),t&&(Ve="select",He=r);var s=n/y,u=i/y,l=ie(e);"a"===l.tagName&&1===l.childNodes.length&&(l=l.firstChild);var h=s;rt=et=s;var d=u;if(nt=tt=u,a.gridSnapping&&(s=Wt(s),u=Wt(u),et=Wt(et),tt=Wt(tt)),l===W.selectorParentGroup&&!Yt(S[0])){var m=e.target,f=ue(m,"type");"rotate"===f?Ve="rotate":"resize"===f&&(Ve="resize",Oe=ue(m,"dir")),l=S[0]}Te=l.getAttribute("transform");var g=q(l);switch(Ve){case"select":if(Ge=!0,Oe="none",t&&(Ge=!1),l!==c){if(S.includes(l)||(e.shiftKey||te(!0),re([l]),Re=l,G.clear()),!t){var p=!0,v=!1,x=void 0;try{for(var b,A=S[Symbol.iterator]();!(p=(b=A.next()).done);p=!0){var k=b.value;if(!Yt(k)){var C=q(k);C.numberOfItems?C.insertItemBefore(c.createSVGTransform(),0):C.appendItem(c.createSVGTransform())}}}catch(e){v=!0,x=e}finally{try{p||null==A.return||A.return()}finally{if(v)throw x}}}}else t||(te(),Ve="multiselect",Yt(Be)&&(Be=W.getRubberBandBox()),zt(Be,{x:rt*=y,y:nt*=y,width:0,height:0,display:"inline"}));break;case"zoom":Ge=!0,Yt(Be)&&(Be=W.getRubberBandBox()),zt(Be,{x:h*y,y:h*y,width:0,height:0,display:"inline"});break;case"resize":Ge=!0,et=s,tt=u,it=Nt(qr("#selectedBox0")[0]);var E={};qr.each(it,(function(e,t){E[e]=t/y})),it=E;var P=jt(l)?1:0;if(ve(g))g.insertItemBefore(c.createSVGTransform(),P),g.insertItemBefore(c.createSVGTransform(),P),g.insertItemBefore(c.createSVGTransform(),P);else if(g.appendItem(c.createSVGTransform()),g.appendItem(c.createSVGTransform()),g.appendItem(c.createSVGTransform()),B()){var N,I=L();I&&(N=function(e){var t=e.getAttribute("stroke");e.removeAttribute("stroke"),null!==t&&setTimeout((function(){e.setAttribute("stroke",t)}),0)}),l.style.vectorEffect="non-scaling-stroke",I&&N(l);for(var T=l.getElementsByTagName("*"),V=T.length,O=0;O<V;O++)T[O].style&&(T[O].style.vectorEffect="non-scaling-stroke",I&&N(T[O]))}break;case"fhellipse":case"fhrect":case"fhpath":vt.x=h,vt.y=d,Ge=!0,w({element:"polyline",curStyles:!0,attr:{points:h+","+d+" ",id:Q(),fill:"none",opacity:_.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}}),Je.minx=h,Je.maxx=h,Je.miny=d,Je.maxy=d;break;case"image":Ge=!0;var M=w({element:"image",attr:{x:s,y:u,width:0,height:0,id:Q(),opacity:_.opacity/2,style:"pointer-events:inherit"}});Ct(M,Pe),Qt(M);break;case"square":case"rect":Ge=!0,et=s,tt=u,w({element:"rect",curStyles:!0,attr:{x:s,y:u,width:0,height:0,id:Q(),opacity:_.opacity/2}});break;case"line":Ge=!0;var R=0===Number(_.stroke_width)?1:_.stroke_width;w({element:"line",curStyles:!0,attr:{x1:s,y1:u,x2:s,y2:u,id:Q(),stroke:_.stroke,"stroke-width":R,"stroke-dasharray":_.stroke_dasharray,"stroke-linejoin":_.stroke_linejoin,"stroke-linecap":_.stroke_linecap,"stroke-opacity":_.stroke_opacity,fill:"none",opacity:_.opacity/2,style:"pointer-events:none"}});break;case"circle":Ge=!0,w({element:"circle",curStyles:!0,attr:{cx:s,cy:u,r:0,id:Q(),opacity:_.opacity/2}});break;case"ellipse":Ge=!0,w({element:"ellipse",curStyles:!0,attr:{cx:s,cy:u,rx:0,ry:0,id:Q(),opacity:_.opacity/2}});break;case"text":Ge=!0,w({element:"text",curStyles:!0,attr:{x:s,y:u,id:Q(),fill:Ae.fill,"stroke-width":Ae.stroke_width,"font-size":Ae.font_size,"font-family":Ae.font_family,"text-anchor":"middle","xml:space":"preserve",opacity:_.opacity}});break;case"path":case"pathedit":et*=y,tt*=y,G.mouseDown(e,l,et,tt),Ge=!0;break;case"textedit":et*=y,tt*=y,Ht.mouseDown(e,l,et,tt),Ge=!0;break;case"rotate":Ge=!0,o.undoMgr.beginUndoableChange("transform",S)}var U=je("mouseDown",{event:e,start_x:et,start_y:tt,selectedElements:S},!0);qr.each(U,(function(e,t){t&&t.started&&(Ge=!0)}))}})).mousemove((function(e){if(Ge&&1!==e.button&&!o.spaceKey){var t,r,n,i,s,u,l,h,d,m,g=S[0],p=ge(e.pageX,e.pageY,Xe),v=p.x*y,x=p.y*y,_=Dt($()),b=v/y,w=b,A=x/y,k=A;switch(a.gridSnapping&&(w=Wt(w),k=Wt(k)),e.preventDefault(),Ve){case"select":if(null!==S[0]&&(s=w-et,u=k-tt,a.gridSnapping&&(s=Wt(s),u=Wt(u)),0!==s||0!==u)){for(l=S.length,t=0;t<l&&(g=S[t],!Yt(g));++t){var C=c.createSVGTransform();m=q(g),C.setTranslate(s,u),m.numberOfItems?m.replaceItem(C,0):m.appendItem(C),W.requestSelector(g).resize()}ee("transition",S)}break;case"multiselect":b*=y,A*=y,zt(Be,{x:Math.min(rt,b),y:Math.min(nt,A),width:Math.abs(b-rt),height:Math.abs(A-nt)});var E=S.slice(),P=[],N=Fe();for(l=N.length,t=0;t<l;++t){var I=N[t];S.includes(I)||P.push(I);var T=E.indexOf(I);-1!==T&&E.splice(T,1)}E.length>0&&o.removeFromSelection(E),P.length>0&&o.addToSelection(P);break;case"resize":m=q(g);var L=ve(m),V=(d=L?it:Nt(g)).x,O=d.y,M=d,R=M.width,B=M.height;if(s=w-et,u=k-tt,a.gridSnapping&&(s=Wt(s),u=Wt(u),B=Wt(B),R=Wt(R)),h=jt(g)){var U=Math.sqrt(s*s+u*u),H=Math.atan2(u,s)-h*Math.PI/180;s=U*Math.cos(H),u=U*Math.sin(H)}Oe.includes("n")||Oe.includes("s")||(u=0),Oe.includes("e")||Oe.includes("w")||(s=0);var j=0,F=0,D=B?(B+u)/B:1,z=R?(R+s)/R:1;Oe.includes("n")&&(D=B?(B-u)/B:1,F=B),Oe.includes("w")&&(z=R?(R-s)/R:1,j=R);var Q=c.createSVGTransform(),Y=c.createSVGTransform(),Z=c.createSVGTransform();if(a.gridSnapping&&(V=Wt(V),j=Wt(j),O=Wt(O),F=Wt(F)),Q.setTranslate(-(V+j),-(O+F)),e.shiftKey&&(1===z?z=D:D=z),Y.setScale(z,D),Z.setTranslate(V+j,O+F),L){var X=h?1:0;m.replaceItem(Q,2+X),m.replaceItem(Y,1+X),m.replaceItem(Z,Number(X))}else{var K=m.numberOfItems;m.replaceItem(Z,K-3),m.replaceItem(Y,K-2),m.replaceItem(Q,K-1)}W.requestSelector(g).resize(),ee("transition",S);break;case"zoom":b*=y,A*=y,zt(Be,{x:Math.min(rt*y,b),y:Math.min(nt*y,A),width:Math.abs(b-rt*y),height:Math.abs(A-nt*y)});break;case"text":zt(_,{x:w,y:k});break;case"line":a.gridSnapping&&(w=Wt(w),k=Wt(k));var J=w,te=k;e.shiftKey&&(J=(r=be(et,tt,J,te)).x,te=r.y),_.setAttribute("x2",J),_.setAttribute("y2",te);break;case"foreignObject":case"square":case"rect":case"image":var re,ne,ie="square"===Ve||e.shiftKey,ae=Math.abs(w-et),se=Math.abs(k-tt);ie?(ae=se=Math.max(ae,se),re=et<w?et:et-ae,ne=tt<k?tt:tt-se):(re=Math.min(et,w),ne=Math.min(tt,k)),a.gridSnapping&&(ae=Wt(ae),se=Wt(se),re=Wt(re),ne=Wt(ne)),zt(_,{width:ae,height:se,x:re,y:ne});break;case"circle":var oe=qr(_).attr(["cx","cy"]);n=oe.cx,i=oe.cy;var ue=Math.sqrt((w-n)*(w-n)+(k-i)*(k-i));a.gridSnapping&&(ue=Wt(ue)),_.setAttribute("r",ue);break;case"ellipse":var le=qr(_).attr(["cx","cy"]);n=le.cx,i=le.cy,a.gridSnapping&&(w=Wt(w),n=Wt(n),k=Wt(k),i=Wt(i)),_.setAttribute("rx",Math.abs(w-n));var he=Math.abs(e.shiftKey?w-n:k-i);_.setAttribute("ry",he);break;case"fhellipse":case"fhrect":Je.minx=Math.min(b,Je.minx),Je.maxx=Math.max(b,Je.maxx),Je.miny=Math.min(A,Je.miny),Je.maxy=Math.max(A,Je.maxy);case"fhpath":if(xt.x=b,xt.y=A,ut.x&&ut.y)for(t=0;t<9;t++)if($e=t/10,Gt=Ot((t+1)/10),It=Gt,Gt=Ot($e),(at+=Math.sqrt((It.x-Gt.x)*(It.x-Gt.x)+(It.y-Gt.y)*(It.y-Gt.y)))>.8){at-=.8;var ce=f.createSVGPoint();ce.x=Gt.x,ce.y=Gt.y,_.points.appendItem(ce)}ut={x:lt.x,y:lt.y},lt={x:vt.x,y:vt.y},vt={x:xt.x,y:xt.y};break;case"path":case"pathedit":if(w*=y,k*=y,a.gridSnapping&&(w=Wt(w),k=Wt(k),et=Wt(et),tt=Wt(tt)),e.shiftKey){var de,me,fe=Ie;fe?(de=fe.dragging?fe.dragging[0]:et,me=fe.dragging?fe.dragging[1]:tt):(de=et,me=tt);var pe=r=be(de,me,w,k);w=pe.x,k=pe.y}Be&&"none"!==Be.getAttribute("display")&&(b*=y,A*=y,zt(Be,{x:Math.min(rt*y,b),y:Math.min(nt*y,A),width:Math.abs(b-rt*y),height:Math.abs(A-nt*y)})),G.mouseMove(w,k);break;case"textedit":w*=y,k*=y,Ht.mouseMove(v,x);break;case"rotate":n=(d=Nt(g)).x+d.width/2,i=d.y+d.height/2;var ye=Se(g),xe=ge(n,i,ye);n=xe.x,i=xe.y,h=(Math.atan2(i-k,n-w)*(180/Math.PI)-90)%360,a.gridSnapping&&(h=Wt(h)),e.shiftKey&&(h=45*Math.round(h/45)),o.setRotationAngle(h<-180?360+h:h,!0),ee("transition",S)}je("mouseMove",{event:e,mouse_x:v,mouse_y:x,selected:g})}})).click((function(e){return e.preventDefault(),!1})).dblclick((function(e){var t=e.target.parentNode;if(t!==v){var r=ie(e),n=r.tagName;if("text"===n&&"textedit"!==Ve){var i=ge(e.pageX,e.pageY,Xe);Ht.select(r,i.x,i.y)}"g"!==n&&"a"!==n||!jt(r)||(Ar(r),r=S[0],te(!0)),v&&_r(),"g"!==t.tagName&&"a"!==t.tagName||t===p().getCurrentLayer()||r===W.selectorParentGroup||Sr(r)}})).mouseup((function(e){if(2!==e.button){var t=Re;if(Re=null,Ge){var r,n,i=ge(e.pageX,e.pageY,Xe),s=i.x*y,u=i.y*y,l=s/y,h=u/y,c=Dt($()),d=!1,m=l,f=h;switch(Ge=!1,Ve){case"resize":case"multiselect":Yt(Be)||(Be.setAttribute("display","none"),Ue=[]),Ve="select";case"select":if(!Yt(S[0])){if(Yt(S[1])){var g=S[0];switch(g.tagName){case"g":case"use":case"image":case"foreignObject":break;default:Me.fill=g.getAttribute("fill"),Me.fill_opacity=g.getAttribute("fill-opacity"),Me.stroke=g.getAttribute("stroke"),Me.stroke_opacity=g.getAttribute("stroke-opacity"),Me.stroke_width=g.getAttribute("stroke-width"),Me.stroke_dasharray=g.getAttribute("stroke-dasharray"),Me.stroke_linejoin=g.getAttribute("stroke-linejoin"),Me.stroke_linecap=g.getAttribute("stroke-linecap")}"text"===g.tagName&&(Ae.font_size=g.getAttribute("font-size"),Ae.font_family=g.getAttribute("font-family")),W.requestSelector(g).showGrips(!0)}if(Qe(),m!==rt||f!==nt)for(var v=S.length,x=0;x<v&&!Yt(S[x]);++x)S[x].firstChild||W.requestSelector(S[x]).resize();else n=e.target,"path"===S[0].nodeName&&Yt(S[1])?G.select(S[0]):e.shiftKey&&t!==n&&o.removeFromSelection([n]);if(B()){var b=S[0];b&&(b.removeAttribute("style"),wt(b,(function(e){e.removeAttribute("style")})))}}return;case"zoom":Yt(Be)||Be.setAttribute("display","none");var A=e.shiftKey?.5:2;return void ee("zoomed",{x:Math.min(rt,m),y:Math.min(nt,f),width:Math.abs(m-rt),height:Math.abs(f-nt),factor:A});case"fhpath":at=0,ut={x:0,y:0},lt={x:0,y:0},vt={x:0,y:0},xt={x:0,y:0};var k=c.getAttribute("points"),C=k.indexOf(",");(d=C>=0?k.includes(",",C+1):k.includes(" ",k.indexOf(" ")+1))&&(c=G.smoothPolylineIntoPath(c));break;case"line":r=qr(c).attr(["x1","x2","y1","y2"]),d=r.x1!==r.x2||r.y1!==r.y2;break;case"foreignObject":case"square":case"rect":case"image":r=qr(c).attr(["width","height"]),d=r.width||r.height||"image"===Ve;break;case"circle":d="0"!==c.getAttribute("r");break;case"ellipse":r=qr(c).attr(["rx","ry"]),d=r.rx||r.ry;break;case"fhellipse":Je.maxx-Je.minx>0&&Je.maxy-Je.miny>0&&(c=w({element:"ellipse",curStyles:!0,attr:{cx:(Je.minx+Je.maxx)/2,cy:(Je.miny+Je.maxy)/2,rx:(Je.maxx-Je.minx)/2,ry:(Je.maxy-Je.miny)/2,id:$()}}),ee("changed",[c]),d=!0);break;case"fhrect":Je.maxx-Je.minx>0&&Je.maxy-Je.miny>0&&(c=w({element:"rect",curStyles:!0,attr:{x:Je.minx,y:Je.miny,width:Je.maxx-Je.minx,height:Je.maxy-Je.miny,id:$()}}),ee("changed",[c]),d=!0);break;case"text":d=!0,Ke([c]),Ht.start(c);break;case"path":c=null,Ge=!0;var E=G.mouseUp(e,c,s,u);c=E.element,d=E.keep;break;case"pathedit":d=!0,c=null,G.mouseUp(e);break;case"textedit":d=!1,c=null,Ht.mouseUp(e,s,u);break;case"rotate":d=!0,c=null,Ve="select";var P=o.undoMgr.finishUndoableChange();P.isEmpty()||U(P),Qe(),ee("changed",S)}var N=je("mouseUp",{event:e,mouse_x:s,mouse_y:u},!0);if(qr.each(N,(function(e,t){t&&(d=t.keep||d,c=t.element,Ge=t.started||Ge)})),d||Yt(c)){if(!Yt(c)){o.addedNew=!0;var I,T=.2;if(le.beginElement&&parseFloat(c.getAttribute("opacity"))!==_.opacity){I=qr(le).clone().attr({to:_.opacity,dur:T}).appendTo(c);try{I[0].beginElement()}catch(e){}}else T=0;setTimeout((function(){I&&I.remove(),c.setAttribute("opacity",_.opacity),c.setAttribute("style","pointer-events:inherit"),qt(c),"path"===Ve?G.toEditMode(c):a.selectNew&&Ke([c],!0),U(new Qr(c)),ee("changed",[c])}),1e3*T)}}else{for(p().releaseId($()),c.remove(),c=null,n=e.target;n&&n.parentNode&&n.parentNode.parentNode&&"g"===n.parentNode.parentNode.tagName;)n=n.parentNode;"path"===Ve&&Mt||!n||!n.parentNode||"selectorParentGroup"===n.parentNode.id||"svgcanvas"===n.id||"svgroot"===n.id||(o.setMode("select"),Ke([n],!0))}Te=null}}})),qr(n).bind("mousewheel DOMMouseScroll",(function(e){if(e.shiftKey){e.preventDefault();var t=e.originalEvent;Xe=qr("#svgcontent g")[0].getScreenCTM().inverse();var r=qr("#workarea"),n=a.showRulers?16:0,i=ge(t.pageX,t.pageY,Xe),s=r.width(),u=r.height(),l=s-15-n,h=u-15-n,c=l*Xe.a,d=h*Xe.d,m=r.offset(),f=m.left+n,g=m.top+n,p=t.wheelDelta?t.wheelDelta:t.detail?-t.detail:0;if(p){var v,x,_=Math.max(.75,Math.min(4/3,p));_>1?(v=Math.ceil(l/c*_*100)/100,x=Math.ceil(h/d*_*100)/100):(v=Math.floor(l/c*_*100)/100,x=Math.floor(h/d*_*100)/100);var S=Math.min(v,x);if((S=Math.min(10,Math.max(.01,S)))!==y){_=S/y;var b=ge(f,g,Xe),w={x:(i.x-(i.x-b.x)/_)*S-n+s/2,y:(i.y-(i.y-b.y)/_)*S-n+u/2};o.setZoom(S),qr("#zoom").val((100*S).toFixed(1)),ee("updateCanvas",{center:!1,newCtr:w}),ee("zoomDone")}}}}));var Rt,Ht=o.textActions=function(){var e,t,r,n,i,a,s,u,l,h,m=[];function f(e){var s=""===t.value;if(qr(t).focus(),!arguments.length)if(s)e=0;else{if(t.selectionEnd!==t.selectionStart)return;e=t.selectionEnd}var o=m[e];s||t.setSelectionRange(e,e),(r=Dt("text_cursor"))||(r=document.createElementNS(d.SVG,"line"),zt(r,{id:"text_cursor",stroke:"#333","stroke-width":1}),r=Dt("selectorParentGroup").appendChild(r)),i||(i=setInterval((function(){var e="none"===r.getAttribute("display");r.setAttribute("display",e?"inline":"none")}),600));var u=b(o.x,a.y),l=b(o.x,a.y+a.height);zt(r,{x1:u.x,y1:u.y,x2:l.x,y2:l.y,visibility:"visible",display:"inline"}),n&&n.setAttribute("d","")}function g(e,i,s){if(e!==i){s||t.setSelectionRange(e,i),(n=Dt("text_selectblock"))||(n=document.createElementNS(d.SVG,"path"),zt(n,{id:"text_selectblock",fill:"green",opacity:.5,style:"pointer-events:none"}),Dt("selectorParentGroup").append(n));var o=m[e],u=m[i];r.setAttribute("visibility","hidden");var l=b(o.x,a.y),h=b(o.x+(u.x-o.x),a.y),c=b(o.x,a.y+a.height),g=b(o.x+(u.x-o.x),a.y+a.height),p="M"+l.x+","+l.y+" L"+h.x+","+h.y+" "+g.x+","+g.y+" "+c.x+","+c.y+"z";zt(n,{d:p,display:"inline"})}else f(i)}function p(t,r){var n=c.createSVGPoint();if(n.x=t,n.y=r,1===m.length)return 0;var i=e.getCharNumAtPosition(n);i<0?(i=m.length-2,t<=m[0].x&&(i=0)):i>=m.length-2&&(i=m.length-2);var a=m[i];return t>a.x+a.width/2&&i++,i}function v(e,t){f(p(e,t))}function x(e,r,n){var i=t.selectionStart,a=p(e,r);g(Math.min(i,a),Math.max(i,a),!n)}function _(e,t){var r={x:e,y:t};if(r.x/=y,r.y/=y,s){var n=ge(r.x,r.y,s.inverse());r.x=n.x,r.y=n.y}return r}function b(e,t){var r={x:e,y:t};if(s){var n=ge(r.x,r.y,s);r.x=n.x,r.y=n.y}return r.x*=y,r.y*=y,r}function w(t){g(0,e.textContent.length),qr(this).unbind(t)}function A(t){if(h&&e){var r=ge(t.pageX,t.pageY,Xe),n=_(r.x*y,r.y*y),i=p(n.x,n.y),a=e.textContent,s=a.substr(0,i).replace(/[a-z\d]+$/i,"").length,o=a.substr(i).match(/^[a-z\d]+/i);g(s,(o?o[0].length:0)+i),qr(t.target).click(w),setTimeout((function(){qr(t.target).unbind("click",w)}),300)}}return{select:function(t,r,n){e=t,Ht.toEditMode(r,n)},start:function(t){e=t,Ht.toEditMode()},mouseDown:function(e,r,n,i){var a=_(n,i);t.focus(),v(a.x,a.y),u=n,l=i},mouseMove:function(e,t){var r=_(e,t);x(r.x,r.y)},mouseUp:function(t,r,n){var i=_(r,n);x(i.x,i.y,!0),t.target!==e&&r<u+2&&r>u-2&&n<l+2&&n>l-2&&Ht.toSelectMode(!0)},setCursor:f,toEditMode:function(t,r){if(h=!1,Ve="textedit",W.requestSelector(e).showGrips(!1),W.requestSelector(e),Ht.init(),qr(e).css("cursor","text"),arguments.length){var n=_(t,r);v(n.x,n.y)}else f();setTimeout((function(){h=!0}),300)},toSelectMode:function(a){Ve="select",clearInterval(i),i=null,n&&qr(n).attr("display","none"),r&&qr(r).attr("visibility","hidden"),qr(e).css("cursor","move"),a&&(te(),qr(e).css("cursor","move"),ee("selected",[e]),re([e],!0)),e&&!e.textContent.length&&o.deleteSelectedElements(),qr(t).blur(),e=!1},setInputElem:function(e){t=e},clear:function(){"textedit"===Ve&&Ht.toSelectMode()},init:function(r){if(e){var n,i;e.parentNode||(e=S[0],W.requestSelector(e).showGrips(!1));var u=e.textContent.length,l=e.getAttribute("transform");for(a=Nt(e),s=l?Se(e):null,(m=[]).length=u,t.focus(),qr(e).unbind("dblclick",A).dblclick(A),u||(i={x:a.x+a.width/2,width:0}),n=0;n<u;n++){var h=e.getStartPositionOfChar(n);if(i=e.getEndPositionOfChar(n),!E){var c=o.contentW*y;h.x-=c,i.x-=c,h.x/=y,i.x/=y}m[n]={x:h.x,y:a.y,width:i.x-h.x,height:a.height}}m.push({x:i.x,width:0}),g(t.selectionStart,t.selectionEnd,!0)}}}}(),Zt=this.removeUnusedDefElems=function(){var e=f.getElementsByTagNameNS(d.SVG,"defs");if(!e||!e.length)return 0;var t,r,n=[],i=0,a=["fill","stroke","filter","marker-start","marker-mid","marker-end"],s=a.length,o=f.getElementsByTagNameNS(d.SVG,"*"),u=o.length;for(t=0;t<u;t++){var l=o[t];for(r=0;r<s;r++){var h=At(l.getAttribute(a[r]));h&&n.push(h.substr(1))}var c=kt(l);c&&c.startsWith("#")&&n.push(c.substr(1))}var m=qr(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");for(t=m.length;t--;){var g=m[t],p=g.id;n.includes(p)||(Ce[p]=g,g.remove(),i++)}return i};function Xt(){te();var e=[],t=[],r={feGaussianBlur:ae.exportNoBlur,foreignObject:ae.exportNoforeignObject,"[stroke-dasharray]":ae.exportNoDashArray},n=qr(f);return"font"in qr("<canvas>")[0].getContext("2d")||(r.text=ae.exportNoText),qr.each(r,(function(r,i){n.find(r).length&&(t.push(r),e.push(i))})),{issues:e,issueCodes:t}}this.svgCanvasToString=function(){for(;Zt()>0;);G.clear(!0),qr.each(f.childNodes,(function(e,t){e&&8===t.nodeType&&t.data.includes("Created with")&&f.firstChild.before(t)})),v&&(_r(),Ke([v]));var e=[];qr(f).find("g:data(gsvg)").each((function(){for(var t=this.attributes,r=t.length,n=0;n<r;n++)"id"!==t[n].nodeName&&"style"!==t[n].nodeName||r--;if(r<=0){var i=this.firstChild;e.push(i),qr(this).replaceWith(i)}}));var t=this.svgToString(f,0);return e.length&&qr(e).each((function(){ze(this)})),t},this.svgToString=function(e,t){var r=[],n=a.baseUnit,i=new RegExp("^-?[\\d\\.]+"+n+"$");if(e){qt(e);var s=l(e.attributes),o=e.childNodes;s.sort((function(e,t){return e.name>t.name?-1:1}));for(var u=0;u<t;u++)r.push(" ");if(r.push("<"),r.push(e.nodeName),"svgcontent"===e.id){var h=rr();"px"!==n&&(h.w=K(h.w,n)+n,h.h=K(h.h,n)+n),r.push(' width="'+h.w+'" height="'+h.h+'" xmlns="'+d.SVG+'"');var c={};qr(e).find("*").andSelf().each((function(){var e=this.namespaceURI;e&&!c[e]&&T[e]&&"xmlns"!==T[e]&&"xml"!==T[e]&&(c[e]=!0,r.push(" xmlns:"+T[e]+'="'+e+'"')),qr.each(this.attributes,(function(e,t){var n=t.namespaceURI;n&&!c[n]&&"xmlns"!==T[n]&&"xml"!==T[n]&&(c[n]=!0,r.push(" xmlns:"+T[n]+'="'+n+'"'))}))}));for(var m=s.length,f=["width","height","xmlns","x","y","viewBox","id","overflow"];m--;){var g=s[m],p=gt(g.value);g.nodeName.startsWith("xmlns:")||(""===p||f.includes(g.localName)||g.namespaceURI&&!T[g.namespaceURI]||(r.push(" "),r.push(g.nodeName),r.push('="'),r.push(p),r.push('"')))}}else{if("defs"===e.nodeName&&!e.firstChild)return"";for(var y=["-moz-math-font-style","_moz-math-font-style"],v=s.length-1;v>=0;v--){var x=s[v],_=gt(x.value);if(!y.includes(x.localName)&&""!==_){if(_.startsWith("pointer-events"))continue;if("class"===x.localName&&_.startsWith("se_"))continue;if(r.push(" "),"d"===x.localName&&(_=G.convertPath(e,!0)),isNaN(_)?i.test(_)&&(_=X(_)+n):_=X(_),de.apply&&"image"===e.nodeName&&"href"===x.localName&&de.images&&"embed"===de.images){var S=ce[_];S&&(_=S)}x.namespaceURI&&x.namespaceURI!==d.SVG&&!T[x.namespaceURI]||(r.push(x.nodeName),r.push('="'),r.push(_),r.push('"'))}}}if(e.hasChildNodes()){r.push(">"),t++;for(var b=!1,w=0;w<o.length;w++){var A=o.item(w);switch(A.nodeType){case 1:r.push("\n"),r.push(this.svgToString(o.item(w),t));break;case 3:var k=A.nodeValue.replace(/^\s+|\s+$/g,"");""!==k&&(b=!0,r.push(String(gt(k))));break;case 4:r.push("\n"),r.push(new Array(t+1).join(" ")),r.push("<![CDATA["),r.push(A.nodeValue),r.push("]]>");break;case 8:r.push("\n"),r.push(new Array(t+1).join(" ")),r.push("\x3c!--"),r.push(A.data),r.push("--\x3e")}}if(t--,!b){r.push("\n");for(var C=0;C<t;C++)r.push(" ")}r.push("</"),r.push(e.nodeName),r.push(">")}else r.push("/>")}return r.join("")},this.embedImage=function(e){return new Promise((function(t,r){qr(new Image).load((function(n,i,a){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 o=";svgedit_url="+encodeURIComponent(e);o=s.toDataURL().replace(";base64",o+";base64"),ce[e]=o}catch(t){ce[e]=!1}Pe=e,t(ce[e])}else r(new Error("Error loading image: "+a.status+" "+a.statusText))})).attr("src",e)}))},this.setGoodImage=function(e){Pe=e},this.open=function(){},this.save=function(e){te(),e&&qr.extend(de,e),de.apply=!0;var t=this.svgCanvasToString();ee("saved",t)},this.rasterExport=function(e,t,r){var n,i,s,u,l,h,c,d,m,f=arguments;return regeneratorRuntime.async((function(g){for(;;)switch(g.prev=g.next){case 0:if(n=f.length>3&&void 0!==f[3]?f[3]:{},s="image/"+(i="ICO"===e?"BMP":e||"PNG").toLowerCase(),u=Xt(),l=u.issues,h=u.issueCodes,c=this.svgCanvasToString(),Rt){g.next=10;break}return g.next=8,regeneratorRuntime.awrap(Er(a.canvgPath+"canvg.js",{global:"canvg"}));case 8:d=g.sent,Rt=d.canvg;case 10:return qr("#export_canvas").length||qr("<canvas>",{id:"export_canvas"}).hide().appendTo("body"),(m=qr("#export_canvas")[0]).width=o.contentW,m.height=o.contentH,g.next=16,regeneratorRuntime.awrap(Rt(m,c));case 16:return g.abrupt("return",new Promise((function(a,o){var u,d=i.toLowerCase(),f=t?m.toDataURL("image/"+d,t):m.toDataURL("image/"+d);function g(){var i={datauri:f,bloburl:u,svg:c,issues:l,issueCodes:h,type:e,mimeType:s,quality:t,exportWindowName:r};n.avoidEvent||ee("exported",i),a(i)}m.toBlob?m.toBlob((function(e){u=St(e),g()}),s,t):(u=_t(f),g())})));case 17:case"end":return g.stop()}}),null,this)},this.exportPDF=function(e){var t,r,n,i,s,o,u,l,h,c,d,m,f=arguments;return regeneratorRuntime.async((function(g){for(;;)switch(g.prev=g.next){case 0:if(t=f.length>1&&void 0!==f[1]?f[1]:M()?"save":void 0,window.jsPDF){g.next=7;break}return g.next=4,regeneratorRuntime.awrap(Pr(["jspdf/underscore-min.js","jspdf/jspdf.min.js"]));case 4:return r=!("svgEditor"in window&&window.svgEditor&&!1===window.svgEditor.modules),g.next=7,regeneratorRuntime.awrap(Pr(a.jspdfPath+"jspdf.plugin.svgToPdf.js",{type:r?"module":"text/javascript"}));case 7:return n=rr(),i=n.w>n.h?"landscape":"portrait",s="pt",o=jsPDF({orientation:i,unit:s,format:[n.w,n.h]}),u=nr(),o.setProperties({title:u}),l=Xt(),h=l.issues,c=l.issueCodes,d=this.svgCanvasToString(),o.addSVG(d,0,0),(m={svg:d,issues:h,issueCodes:c,exportWindowName:e,outputType:t=t||"dataurlstring"}).output=o.output(t,"save"===t?e||"svg.pdf":void 0),ee("exportedPDF",m),g.abrupt("return",m);case 21:case"end":return g.stop()}}),null,this)},this.getSvgString=function(){return de.apply=!1,this.svgCanvasToString()},this.randomizeIds=function(e){arguments.length>0&&!1===e?ur(!1,p()):ur(!0,p())};var Kt=this.uniquifyElems=function(e){var t={},r=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];for(var n in wt(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),qr.each(oe,(function(r,n){var i=e.getAttributeNode(n);if(i){var a=At(i.value),s=a?a.substr(1):null;s&&(s in t||(t[s]={elem:null,attrs:[],hrefs:[]}),t[s].attrs.push(i))}}));var n=kt(e);if(n&&r.includes(e.nodeName)){var i=n.substr(1);i&&(i in t||(t[i]={elem:null,attrs:[],hrefs:[]}),t[i].hrefs.push(e))}}})),t)if(n){var i=t[n].elem;if(i){var a=Q();i.id=a;for(var s=t[n].attrs,o=s.length;o--;){var u=s[o];u.ownerElement.setAttribute(u.name,"url(#"+a+")")}for(var l=t[n].hrefs,h=l.length;h--;){var c=l[h];Ct(c,"#"+a)}}}},$t=this.setUseData=function(e){var t=qr(e);"use"!==e.tagName&&(t=t.find("use")),t.each((function(){var e=kt(this).substr(1),t=Dt(e);t&&(qr(this).data("ref",t),"symbol"!==t.tagName&&"svg"!==t.tagName||qr(this).data("symbol",t).data("ref",t))}))},Jt=this.convertGradients=function(e){var t=qr(e).find("linearGradient, radialGradient");!t.length&&L()&&(t=qr(e).find("*").filter((function(){return this.tagName.includes("Gradient")}))),t.each((function(){if("userSpaceOnUse"===qr(this).attr("gradientUnits")){var e=qr(f).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(!e.length)return;var t=Nt(e[0]);if(!t)return;if("linearGradient"===this.tagName){var r=qr(this).attr(["x1","y1","x2","y2"]),n=this.gradientTransform.baseVal;if(n&&n.numberOfItems>0){var i=_e(n).matrix,a=ge(r.x1,r.y1,i),s=ge(r.x2,r.y2,i);r.x1=a.x,r.y1=a.y,r.x2=s.x,r.y2=s.y,this.removeAttribute("gradientTransform")}qr(this).attr({x1:(r.x1-t.x)/t.width,y1:(r.y1-t.y)/t.height,x2:(r.x2-t.x)/t.width,y2:(r.y2-t.y)/t.height}),this.removeAttribute("gradientUnits")}}}))},er=this.convertToGroup=function(e){e||(e=S[0]);var t,r=qr(e),n=new Xr;if(r.data("gsvg")){var i=e.firstChild,a=qr(i).attr(["x","y"]);qr(e.firstChild.firstChild).unwrap(),qr(e).removeData("gsvg");var s=q(e),o=c.createSVGTransform();o.setTranslate(a.x,a.y),s.appendItem(o),Hr(e),ee("selected",[e])}else if(r.data("symbol")){e=r.data("symbol"),t=r.attr("transform");var u=r.attr(["x","y"]),l=e.getAttribute("viewBox");if(l){var m=l.split(" ");u.x-=Number(m[0]),u.y-=Number(m[1])}t+=" translate("+(u.x||0)+","+(u.y||0)+")";var g=r.prev();n.addSubCommand(new Yr(r[0],r[0].nextSibling,r[0].parentNode)),r.remove();var p,y=qr(f).find("use:data(symbol)").length,v=h.createElementNS(d.SVG,"g"),x=e.childNodes;for(p=0;p<x.length;p++)v.append(x[p].cloneNode(!0));if(V()){var _=qr(Et()).children("linearGradient,radialGradient,pattern").clone();qr(v).append(_)}t&&v.setAttribute("transform",t);var b=e.parentNode;if(Kt(v),V()&&qr(Et()).append(qr(v).find("linearGradient,radialGradient,pattern")),v.id=Q(),g.after(v),b){if(!y){var w=e.nextSibling;e.remove(),n.addSubCommand(new Yr(e,w,b))}n.addSubCommand(new Qr(v))}$t(v),V()?Jt(Et()):Jt(v),function(e,t){if(e&&1===e.nodeType){for(var r=e.childNodes.length;r--;)wt(e.childNodes.item(r),t);t(e)}}(v,(function(e){try{Hr(e)}catch(e){console.log(e)}})),qr(v).find(se).each((function(){this.id||(this.id=Q())})),Ke([v]);var A=Ar(v,!0);A&&n.addSubCommand(A),U(n)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e,t){try{var r=bt(e);if(r.firstElementChild&&r.firstElementChild.namespaceURI!==d.SVG)return!1;this.prepareSvg(r);var n=new Xr("Change Source"),i=f.nextSibling,s=c.removeChild(f);n.addSubCommand(new Yr(s,i,c)),f=h.adoptNode?h.adoptNode(r.documentElement):h.importNode(r.documentElement,!0),c.append(f);var u=qr(f);o.current_drawing_=new or(f,g);var l=p().getNonce();l?ee("setnonce",l):ee("unsetnonce"),u.find("image").each((function(){var e=this;Qt(e);var t=kt(this);if(t){if(t.startsWith("data:")){var r=t.match(/svgedit_url=(.*?);/);if(r){var n=decodeURIComponent(r[1]);qr(new Image).load((function(){e.setAttributeNS(d.XLINK,"xlink:href",n)})).attr("src",n)}}o.embedImage(t)}})),u.find("svg").each((function(){if(!qr(this).closest("defs").length){Kt(this);var e=this.parentNode;1===e.childNodes.length&&"g"===e.nodeName?(qr(e).data("gsvg",this),e.id=e.id||Q()):ze(this)}})),V()&&u.find("linearGradient, radialGradient, pattern").appendTo(Et()),$t(u),Jt(u[0]);var m={id:"svgcontent",overflow:a.show_outside_canvas?"visible":"hidden"},v=!1;if(u.attr("viewBox")){var x=u.attr("viewBox").split(" ");m.width=x[2],m.height=x[3]}else qr.each(["width","height"],(function(e,t){var r=u.attr(t)||"100%";"%"===String(r).substr(-1)?v=!0:m[t]=J(t,r)}));if(lr(),u.children().find(se).each((function(){this.id||(this.id=Q())})),v){var _=Ut();m.width=_.width+_.x,m.height=_.height+_.y}m.width<=0&&(m.width=100),m.height<=0&&(m.height=100),u.attr(m),this.contentW=m.width,this.contentH=m.height,n.addSubCommand(new Qr(f));var S=u.attr(["width","height"]);n.addSubCommand(new Zr(c,S)),y=1,F={},te(),Ne={},c.append(W.selectorParentGroup),t||U(n),ee("changed",[f])}catch(e){return console.log(e),!1}return!0},this.importSvgString=function(e){var t,r,n;try{var i=pt(e.length+e).substr(0,32),a=!1;fe[i]&&qr(fe[i].symbol).parents("#svgroot").length&&(a=!0);var s,o=new Xr("Import Image");if(a)s=fe[i].symbol,r=fe[i].xform;else{var u,l=bt(e);this.prepareSvg(l),u=h.adoptNode?h.adoptNode(l.documentElement):h.importNode(l.documentElement,!0),Kt(u);var c=J("width",u.getAttribute("width")),m=J("height",u.getAttribute("height")),g=u.getAttribute("viewBox"),y=g?g.split(" "):[0,0,c,m];for(t=0;t<4;++t)y[t]=Number(y[t]);var x=Number(f.getAttribute("height"));r="translate(0) "+(r=m>c?"scale("+x/3/y[3]+")":"scale("+x/3/y[2]+")")+" translate(0)",s=h.createElementNS(d.SVG,"symbol");var _=Et();for(V()&&qr(u).find("linearGradient, radialGradient, pattern").appendTo(_);u.firstChild;){var S=u.firstChild;s.append(S)}var b=u.attributes,w=!0,A=!1,k=void 0;try{for(var C,E=b[Symbol.iterator]();!(w=(C=E.next()).done);w=!0){var P=C.value;s.setAttribute(P.nodeName,P.value)}}catch(e){A=!0,k=e}finally{try{w||null==E.return||E.return()}finally{if(A)throw k}}s.id=Q(),fe[i]={symbol:s,xform:r},Et().append(s),o.addSubCommand(new Qr(s))}(n=h.createElementNS(d.SVG,"use")).id=Q(),Ct(n,"#"+s.id),(v||p().getCurrentLayer()).append(n),o.addSubCommand(new Qr(n)),te(),n.setAttribute("transform",r),Hr(n),qr(n).data("symbol",s).data("ref",s),re([n]),U(o),ee("changed",[f])}catch(e){return console.log(e),null}return n};var tr={identifyLayers:lr,createLayer:hr,cloneLayer:cr,deleteCurrentLayer:dr,setCurrentLayer:mr,renameCurrentLayer:fr,setCurrentLayerPosition:gr,setLayerVisibility:pr,moveSelectedToLayer:yr,mergeLayer:vr,mergeAllLayers:xr,leaveContext:_r,setContext:Sr};Object.entries(tr).forEach((function(e){var t=u(e,2),r=t[0],n=t[1];o[r]=n})),function(e){sr=e}({pathActions:G,getCurrentGroup:function(){return v},setCurrentGroup:function(e){v=e},getSelectedElements:P,getSVGContent:C,undoMgr:R,elData:ue,getCurrentDrawing:p,clearSelection:te,call:ee,addCommandToHistory:U,changeSVGContent:function(){ee("changed",[f])}}),this.clear=function(){G.clear(),te(),o.clearSvgContentElement(),o.current_drawing_=new or(f),o.createLayer("Layer 1"),o.undoMgr.resetUndoStack(),W.initGroup(),Be=W.getRubberBandBox(),ee("cleared")},this.linkControlPoints=G.linkControlPoints,this.getContentElem=function(){return f},this.getRootElem=function(){return c};var rr=this.getResolution=function(){return{w:f.getAttribute("width")/y,h:f.getAttribute("height")/y,zoom:y}};this.getSnapToGrid=function(){return a.gridSnapping},this.getVersion=function(){return"svgcanvas.js ($Rev$)"},this.setUiStrings=function(t){Object.assign(ae,t.notification),qr=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ok:"Ok",cancel:"Cancel"};t("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"}).css("position","absolute");var n=t("#dialog_box"),i=t("#dialog_buttons"),a=t("#dialog_content");function s(s,o,u,l,h,c){a.html("<p>"+o.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt","prompt"===s),i.empty();var d=t('<input type="button" data-ok="" value="'+r.ok+'">').appendTo(i);return new Promise((function(m,f){var g,p;if("alert"!==s&&t('<input type="button" value="'+r.cancel+'">').appendTo(i).click((function(){n.hide(),m(!1)})),"prompt"===s)(g=t('<input type="text">').prependTo(i)).val(u||""),g.bind("keydown","return",(function(){d.click()}));else if("select"===s){var y=t('<div style="text-align:center;">');if(g=t('<select aria-label="'.concat(o,'">')).appendTo(y),c){var v=t("<label>").text(c.label);(p=t('<input type="checkbox">').appendTo(v)).val(c.value),c.tooltip&&v.attr("title",c.tooltip),p.prop("checked",Boolean(c.checked)),y.append(t("<div>").append(v))}t.each(l||[],(function(r,n){"object"===e(n)?g.append(t("<option>").val(n.value).html(n.text)):g.append(t("<option>").html(n))})),a.append(y),u&&g.val(u),h&&g.bind("change","return",h),g.bind("keydown","return",(function(){d.click()}))}else"process"===s&&d.hide();n.show(),d.click((function(){n.hide();var e="prompt"!==s&&"select"!==s||g.val();m(p?{response:e,checked:p.prop("checked")}:e)})).focus(),"prompt"!==s&&"select"!==s||g.focus()}))}return t.alert=function(e){return s("alert",e)},t.confirm=function(e){return s("confirm",e)},t.process_cancel=function(e){return s("process",e)},t.prompt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return s("prompt",e,t)},t.select=function(e,t,r,n,i){return s("select",e,n,t,r,i)},t}(qr,t.common),Ee(t)},this.setConfig=function(e){Object.assign(a,e)},this.getTitle=function(e){if(e=e||S[0]){var t=(e=qr(e).data("gsvg")||qr(e).data("symbol")||e).childNodes,r=!0,n=!1,i=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var o=a.value;if("title"===o.nodeName)return o.textContent}}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}return""}},this.setGroupTitle=function(e){var t=S[0];t=qr(t).data("gsvg")||t;var r,n=qr(t).children("title"),i=new Xr("Set Label");if(e.length)n.length?(r=n[0],i.addSubCommand(new Zr(r,{"#text":r.textContent})),r.textContent=e):((r=h.createElementNS(d.SVG,"title")).textContent=e,qr(t).prepend(r),i.addSubCommand(new Qr(r)));else{var a=n.nextSibling;i.addSubCommand(new Yr(n[0],a,t)),n.remove()}U(i)};var nr=this.getDocumentTitle=function(){return o.getTitle(f)};this.setDocumentTitle=function(e){var t=f.childNodes,r=!1,n="",i=new Xr("Change Image Title"),a=!0,s=!1,o=void 0;try{for(var u,l=t[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){var c=u.value;if("title"===c.nodeName){n=(r=c).textContent;break}}}catch(e){s=!0,o=e}finally{try{a||null==l.return||l.return()}finally{if(s)throw o}}r||(r=h.createElementNS(d.SVG,"title"),f.insertBefore(r,f.firstChild)),e.length?r.textContent=e:r.remove(),i.addSubCommand(new Zr(r,{"#text":n})),U(i)},this.getEditorNS=function(e){return e&&f.setAttribute("xmlns:se",d.SE),d.SE},this.setResolution=function(e,t){var r,n=rr(),i=n.w,a=n.h;if("fit"===e){var s=Ut();if(!s)return!1;r=new Xr("Fit Canvas to Content");var u=Bt();re(u);var l=[],h=[];qr.each(u,(function(e,t){l.push(-1*s.x),h.push(-1*s.y)}));var c=o.moveSelectedElements(l,h,!0);r.addSubCommand(c),te(),e=Math.round(s.width),t=Math.round(s.height)}return e===i&&t===a||(r||(r=new Xr("Change Image Dimensions")),e=J("width",e),t=J("height",t),f.setAttribute("width",e),f.setAttribute("height",t),this.contentW=e,this.contentH=t,r.addSubCommand(new Zr(f,{width:i,height:a})),f.setAttribute("viewBox",[0,0,e/y,t/y].join(" ")),r.addSubCommand(new Zr(f,{viewBox:["0 0",i,a].join(" ")})),U(r),ee("changed",[f])),!0},this.getOffset=function(){return qr(f).attr(["x","y"])},this.setBBoxZoom=function(t,r,n){var i,a=.85,s=function(e){if(!e)return!1;var t=Math.round(r/e.width*100*a)/100,i=Math.round(n/e.height*100*a)/100,s=Math.min(t,i);return o.setZoom(s),{zoom:s,bbox:e}};if("object"===e(t)){if(0===(i=t).width||0===i.height){var u=i.zoom?i.zoom:y*i.factor;return o.setZoom(u),{zoom:y,bbox:i}}return s(i)}switch(t){case"selection":if(!S[0])return;var l=qr.map(S,(function(e){if(e)return e}));i=Ut(l);break;case"canvas":var h=rr();a=.95,i={width:h.w,height:h.h,x:0,y:0};break;case"content":i=Ut();break;case"layer":i=Ut(Bt(p().getCurrentLayer()));break;default:return}return s(i)},this.setZoom=function(e){var t=rr();f.setAttribute("viewBox","0 0 "+t.w/e+" "+t.h/e),y=e,qr.each(S,(function(e,t){t&&W.requestSelector(t).resize()})),G.zoomChange(),je("zoomChanged",e)},this.getMode=function(){return Ve},this.setMode=function(e){G.clear(!0),Ht.clear(),Me=S[0]&&"text"===S[0].nodeName?Ae:_,Ve=e},this.getColor=function(e){return Me[e]},this.setColor=function(e,t,r){_[e]=t,Me[e+"_paint"]={type:"solidColor"};var n=[];function i(e){"g"!==e.nodeName&&n.push(e)}for(var a=S.length;a--;){var s=S[a];s&&("g"===s.tagName?wt(s,i):"fill"===e?"polyline"!==s.tagName&&"line"!==s.tagName&&n.push(s):n.push(s))}n.length>0&&(r?br(e,t,n):(wr(e,t,n),ee("changed",n)))};var ir=this.setGradient=function(e){if(Me[e+"_paint"]&&"solidColor"!==Me[e+"_paint"].type){var t=o[e+"Grad"],r=ar(t),n=Et();r?t=r:(t=n.appendChild(h.importNode(t,!0))).id=Q(),o.setColor(e,"url(#"+t.id+")")}},ar=function(e){for(var t=Et(),r=qr(t).find("linearGradient, radialGradient"),n=r.length,i=["r","cx","cy","fx","fy"];n--;){var a=r[n];if("linearGradient"===e.tagName){if(e.getAttribute("x1")!==a.getAttribute("x1")||e.getAttribute("y1")!==a.getAttribute("y1")||e.getAttribute("x2")!==a.getAttribute("x2")||e.getAttribute("y2")!==a.getAttribute("y2"))continue}else if("continue"===function(){var t=qr(e).attr(i),r=qr(a).attr(i),n=!1;if(qr.each(i,(function(e,i){t[i]!==r[i]&&(n=!0)})),n)return"continue"}())continue;var s=e.getElementsByTagNameNS(d.SVG,"stop"),o=a.getElementsByTagNameNS(d.SVG,"stop");if(s.length===o.length){for(var u=s.length;u--;){var l=s[u],h=o[u];if(l.getAttribute("offset")!==h.getAttribute("offset")||l.getAttribute("stop-opacity")!==h.getAttribute("stop-opacity")||l.getAttribute("stop-color")!==h.getAttribute("stop-color"))break}if(-1===u)return a}}return null};this.setPaint=function(e,t){var r=new qr.jGraduate.Paint(t);switch(this.setPaintOpacity(e,r.alpha/100,!0),Me[e+"_paint"]=r,r.type){case"solidColor":this.setColor(e,"none"!==r.solidColor?"#"+r.solidColor:"none");break;case"linearGradient":case"radialGradient":o[e+"Grad"]=r[r.type],ir(e)}},this.setStrokePaint=function(e){this.setPaint("stroke",e)},this.setFillPaint=function(e){this.setPaint("fill",e)},this.getStrokeWidth=function(){return Me.stroke_width},this.setStrokeWidth=function(e){if(0===e&&["line","path"].includes(Ve))o.setStrokeWidth(1);else{Me.stroke_width=e;for(var t=[],r=S.length;r--;){var n=S[r];n&&("g"===n.tagName?wt(n,i):t.push(n))}t.length>0&&(wr("stroke-width",e,t),ee("changed",S))}function i(e){"g"!==e.nodeName&&t.push(e)}},this.setStrokeAttr=function(e,t){_[e.replace("-","_")]=t;for(var r=[],n=S.length;n--;){var i=S[n];i&&("g"===i.tagName?wt(i,(function(e){"g"!==e.nodeName&&r.push(e)})):r.push(i))}r.length>0&&(wr(e,t,r),ee("changed",S))},this.getStyle=function(){return _},this.getOpacity=ne,this.setOpacity=function(e){_.opacity=e,wr("opacity",e)},this.getFillOpacity=function(){return _.fill_opacity},this.getStrokeOpacity=function(){return _.stroke_opacity},this.setPaintOpacity=function(e,t,r){_[e+"_opacity"]=t,r?br(e+"-opacity",t):wr(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 r=Dt(e.id+"_blur");r&&(t=r.firstChild.getAttribute("stdDeviation"))}return t},function(){var e=null,t=null,r=!1;function n(){var r=o.undoMgr.finishUndoableChange();e.addSubCommand(r),U(e),e=null,t=null}o.setBlurNoUndo=function(e){if(t)if(0===e)br("filter",""),r=!0;else{var n=S[0];r&&br("filter","url(#"+n.id+"_blur)"),L()&&(n.removeAttribute("filter"),n.setAttribute("filter","url(#"+n.id+"_blur)")),br("stdDeviation",e,[t.firstChild]),o.setBlurOffsets(t,e)}else o.setBlur(e)},o.setBlurOffsets=function(e,t){t>3?zt(e,{x:"-50%",y:"-50%",width:"200%",height:"200%"}):L()||(e.removeAttribute("x"),e.removeAttribute("y"),e.removeAttribute("width"),e.removeAttribute("height"))},o.setBlur=function(r,i){if(e)n();else{var a=S[0],s=a.id;t=Dt(s+"_blur"),r-=0;var u=new Xr;if(t)0===r&&(t=null);else{var l=w({element:"feGaussianBlur",attr:{in:"SourceGraphic",stdDeviation:r}});(t=w({element:"filter",attr:{id:s+"_blur"}})).append(l),Et().append(t),u.addSubCommand(new Qr(t))}var h={filter:a.getAttribute("filter")};if(0===r)return a.removeAttribute("filter"),void u.addSubCommand(new Zr(a,h));wr("filter","url(#"+s+"_blur)"),u.addSubCommand(new Zr(a,h)),o.setBlurOffsets(t,r),e=u,o.undoMgr.beginUndoableChange("stdDeviation",[t?t.firstChild:null]),i&&(o.setBlurNoUndo(r),n())}}}(),this.getBold=function(){var e=S[0];return!(Yt(e)||"text"!==e.tagName||!Yt(S[1]))&&"bold"===e.getAttribute("font-weight")},this.setBold=function(e){var t=S[0];!Yt(t)&&"text"===t.tagName&&Yt(S[1])&&wr("font-weight",e?"bold":"normal"),S[0].textContent||Ht.setCursor()},this.getItalic=function(){var e=S[0];return!(Yt(e)||"text"!==e.tagName||!Yt(S[1]))&&"italic"===e.getAttribute("font-style")},this.setItalic=function(e){var t=S[0];!Yt(t)&&"text"===t.tagName&&Yt(S[1])&&wr("font-style",e?"italic":"normal"),S[0].textContent||Ht.setCursor()},this.getFontFamily=function(){return Ae.font_family},this.setFontFamily=function(e){Ae.font_family=e,wr("font-family",e),S[0]&&!S[0].textContent&&Ht.setCursor()},this.setFontColor=function(e){Ae.fill=e,wr("fill",e)},this.getFontColor=function(){return Ae.fill},this.getFontSize=function(){return Ae.font_size},this.setFontSize=function(e){Ae.font_size=e,wr("font-size",e),S[0].textContent||Ht.setCursor()},this.getText=function(){var e=S[0];return Yt(e)?"":e.textContent},this.setTextContent=function(e){wr("#text",e),Ht.init(e),Ht.setCursor()},this.setImageURL=function(e){var t=S[0];if(t){var r=qr(t).attr(["width","height"]),n=!r.width||!r.height,i=kt(t);if(i!==e||n){var a=new Xr("Change Image URL");Ct(t,e),a.addSubCommand(new Zr(t,{"#href":i})),qr(new Image).load((function(){var e=qr(t).attr(["width","height"]);qr(t).attr({width:this.width,height:this.height}),W.requestSelector(t).resize(),a.addSubCommand(new Zr(t,e)),U(a),ee("changed",[t])})).attr("src",e)}}},this.setLinkURL=function(e){var t=S[0];if(t){if("a"!==t.tagName){var r=qr(t).parents("a");if(!r.length)return;t=r[0]}var n=kt(t);if(n!==e){var i=new Xr("Change Link URL");Ct(t,e),i.addSubCommand(new Zr(t,{"#href":n})),U(i)}}},this.setRectRadius=function(e){var t=S[0];if(!Yt(t)&&"rect"===t.tagName){var r=t.getAttribute("rx");r!==String(e)&&(t.setAttribute("rx",e),t.setAttribute("ry",e),U(new Zr(t,{rx:r,ry:r},"Radius")),ee("changed",[t]))}},this.makeHyperlink=function(e){o.groupSelectedElements("a",e)},this.removeHyperlink=function(){o.ungroupSelectedElement()},this.setSegType=function(e){G.setSegType(e)},this.convertToPath=function(e,t){if(!Yt(e))return t?Vt(e,w,G):function(e,t,r,n,i,a,s,o){var u=new s.BatchCommand("Convert element to Path"),l=r({element:"path",attr:t=ot.extend({},t,Lt(e))}),h=e.getAttribute("transform");h&&l.setAttribute("transform",h);var c=e.id,d=e.parentNode;e.nextSibling?e.before(l):d.append(l);var m=Tt(e);if(m){if(l.setAttribute("d",m),h){var f=q(l);ve(f)&&n.resetOrientation(l)}var g=e.nextSibling;return u.addSubCommand(new s.RemoveElementCommand(e,g,parent)),u.addSubCommand(new s.InsertElementCommand(l)),i(),e.remove(),l.setAttribute("id",c),l.removeAttribute("visibility"),a([l],!0),o(u),l}return l.remove(),null}(e,{fill:_.fill,"fill-opacity":_.fill_opacity,stroke:_.stroke,"stroke-width":_.stroke_width,"stroke-dasharray":_.stroke_dasharray,"stroke-linejoin":_.stroke_linejoin,"stroke-linecap":_.stroke_linecap,"stroke-opacity":_.stroke_opacity,opacity:_.opacity,visibility:"hidden"},w,G,te,re,me,U);var r=S;qr.each(r,(function(e,t){t&&o.convertToPath(t)}))};var br=function(e,t,r){"pathedit"===Ve&&G.moveNode(e,t);for(var n=(r=r||S).length,i=["g","polyline","path"],a=function(){var a=r[n];if(Yt(a))return"continue";if(("x"===e||"y"===e)&&i.includes(a.tagName)){var s=Ut([a]),u="x"===e?t-s.x:0,l="y"===e?t-s.y:0;return o.moveSelectedElements(u*y,l*y,!0),"continue"}var h="#text"===e?a.textContent:a.getAttribute(e);if(Yt(h)&&(h=""),h!==String(t)){"#text"===e?(a.textContent=t,/rotate/.test(a.getAttribute("transform"))&&(a=We(a))):"#href"===e?Ct(a,t):a.setAttribute(e,t),"textedit"===Ve&&"#text"!==e&&a.textContent.length&&Ht.toSelectMode(a),V()&&"text"===a.nodeName&&/rotate/.test(a.getAttribute("transform"))&&(String(t).startsWith("url")||["font-size","font-family","x","y"].includes(e)&&a.textContent)&&(a=We(a)),S.includes(a)&&setTimeout((function(){a.parentNode&&W.requestSelector(a).resize()}),0);var d=jt(a);if(0!==d&&"transform"!==e)for(var m=q(a),f=m.numberOfItems;f--;){if(4===m.getItem(f).type){m.removeItem(f);var g=Nt(a),p=ge(g.x+g.width/2,g.y+g.height/2,_e(m).matrix),v=p.x,x=p.y,_=c.createSVGTransform();_.setRotate(d,v,x),m.insertItemBefore(_,f);break}}}};n--;)a()},wr=this.changeSelectedAttribute=function(e,t,r){r=r||S,o.undoMgr.beginUndoableChange(e,r),br(e,t,r);var n=o.undoMgr.finishUndoableChange();n.isEmpty()||U(n)};this.deleteSelectedElements=function(){for(var e=new Xr("Delete Elements"),t=S.length,r=[],n=0;n<t;++n){var i=S[n];if(Yt(i))break;var a=i.parentNode,s=i;W.releaseSelector(s),Ze(s.id),"a"===a.tagName&&1===a.childNodes.length&&(s=a,a=a.parentNode);var o=s.nextSibling,u=a.removeChild(s);r.push(i),e.addSubCommand(new Yr(u,o,a))}S=[],e.isEmpty()||U(e),ee("changed",r),te()},this.cutSelectedElements=function(){o.copySelectedElements(),o.deleteSelectedElements()},this.copySelectedElements=function(){localStorage.setItem("svgedit_clipboard",JSON.stringify(S.map((function(e){return b(e)})))),qr("#cmenu_canvas").enableContextMenuItems("#paste,#paste_in_place")},this.pasteElements=function(e,t,r){var n=JSON.parse(localStorage.getItem("svgedit_clipboard")),i=n.length;if(i){var a=[],s=new Xr("Paste elements"),u={};for(n.forEach((function e(t){t.attr&&t.attr.id&&(u[t.attr.id]=Q(),t.attr.id=u[t.attr.id]),t.children&&t.children.forEach(e)})),je("IDsUpdated",{elems:n,changes:u},!0).forEach((function(e){e&&"remove"in e&&e.remove.forEach((function(e){n=n.filter((function(t){return t.attr.id!==e}))}))}));i--;){var l=n[i];if(l){var h=w(l);a.push(h),s.addSubCommand(new Qr(h)),he(h)}}if(Ke(a),"in_place"!==e){var c,d;e?"point"===e&&(c=t,d=r):(c=He.x,d=He.y);var m=Ut(a),f=c-(m.x+m.width/2),g=d-(m.y+m.height/2),p=[],y=[];qr.each(a,(function(e,t){p.push(f),y.push(g)}));var v=o.moveSelectedElements(p,y,!1);v&&s.addSubCommand(v)}U(s),ee("changed",a)}},this.groupSelectedElements=function(e,t){e||(e="g");var r,n="";switch(e){case"a":n="Make hyperlink",r=t||"";break;default:e="g",n="Group Elements"}var i=new Xr(n),a=w({element:e,attr:{id:Q()}});"a"===e&&Ct(a,r),i.addSubCommand(new Qr(a));for(var s=S.length;s--;){var o=S[s];if(!Yt(o)){"a"===o.parentNode.tagName&&1===o.parentNode.childNodes.length&&(o=o.parentNode);var u=o.nextSibling,l=o.parentNode;a.append(o),i.addSubCommand(new Wr(o,u,l))}}i.isEmpty()||U(i),Ke([a],!0)};var Ar=this.pushGroupProperties=function(e,t){for(var r,n,i,a=e.childNodes,s=a.length,u=e.getAttribute("transform"),l=q(e),h=_e(l).matrix,d=new Xr("Push group properties"),m=jt(e),f=qr(e).attr(["filter","opacity"]),g=p(),y=0;y<s;y++){var v=a[y];if(1===v.nodeType){if(null!==f.opacity&&1!==f.opacity){var x=Math.round((v.getAttribute("opacity")||1)*f.opacity*100)/100;wr("opacity",x,[v])}if(f.filter){var _=this.getBlur(v),S=_;n||(n=this.getBlur(e)),_?_=Number(n)+Number(_):0===_&&(_=n),S?r=Ft(v.getAttribute("filter")):r?(r=g.copyElem(r),Et().append(r)):r=Ft(f.filter);var b="feGaussianBlur"===r.firstChild.tagName?"blur":"filter";r.id=v.id+"_"+b,wr("filter","url(#"+r.id+")",[v]),_&&(wr("stdDeviation",_,[r.firstChild]),o.setBlurOffsets(r,_))}var w=q(v);if(v.tagName.includes("Gradient")&&(w=null),w&&"defs"!==v.tagName&&l.numberOfItems){if(m&&1===l.numberOfItems){var A=l.getItem(0).matrix,k=c.createSVGMatrix(),C=jt(v);C&&(k=w.getItem(0).matrix);var E=Nt(v),P=_e(w).matrix,G=ge(E.x+E.width/2,E.y+E.height/2,P),N=m+C,I=c.createSVGTransform();I.setRotate(N,G.x,G.y);var T=ye(A,k,I.matrix.inverse());if(C&&w.removeItem(0),N&&(w.numberOfItems?w.insertItemBefore(I,0):w.appendItem(I)),T.e||T.f){var L=c.createSVGTransform();L.setTranslate(T.e,T.f),w.numberOfItems?w.insertItemBefore(L,0):w.appendItem(L)}}else{var V=v.getAttribute("transform");(i={}).transform=V||"";var O=c.createSVGTransform(),M=_e(w).matrix,R=M.inverse(),B=ye(R,h,M);O.setMatrix(B),w.appendItem(O)}var U=Hr(v);U&&d.addSubCommand(U)}}}if(u&&((i={}).transform=u,e.setAttribute("transform",""),e.removeAttribute("transform"),d.addSubCommand(new Zr(e,i))),t&&!d.isEmpty())return d};this.ungroupSelectedElement=function(){var e=S[0];if(e)if(qr(e).data("gsvg")||qr(e).data("symbol"))er(e);else{if("use"===e.tagName){var t=Dt(kt(e).substr(1));return qr(e).data("symbol",t).data("ref",t),void er(e)}var r=qr(e).parents("a");if(r.length&&(e=r[0]),"g"===e.tagName||"a"===e.tagName){var n=new Xr("Ungroup Elements"),i=Ar(e,!0);i&&n.addSubCommand(i);for(var a=e.parentNode,s=e.nextSibling,o=new Array(e.childNodes.length),u=0;e.firstChild;){var l=e.firstChild,h=l.nextSibling,c=l.parentNode;if("title"!==l.tagName)o[u++]=l=a.insertBefore(l,s),n.addSubCommand(new Wr(l,h,c));else{var d=l.nextSibling;n.addSubCommand(new Yr(l,d,c)),l.remove()}}te();var m=e.nextSibling;e=a.removeChild(e),n.addSubCommand(new Yr(e,m,a)),n.isEmpty()||U(n),re(o)}}},this.moveToTopSelectedElement=function(){var e=u(S,1)[0];if(!Yt(e)){var t=e,r=t.parentNode,n=t.nextSibling;n!==(t=t.parentNode.appendChild(t)).nextSibling&&(U(new Wr(t,n,r,"top")),ee("changed",[t]))}},this.moveToBottomSelectedElement=function(){var e=u(S,1)[0];if(!Yt(e)){var t=e,r=t.parentNode,n=t.nextSibling,i=t.parentNode.firstChild;"title"===i.tagName&&(i=i.nextSibling),"defs"===i.tagName&&(i=i.nextSibling),n!==(t=t.parentNode.insertBefore(t,i)).nextSibling&&(U(new Wr(t,n,r,"bottom")),ee("changed",[t]))}},this.moveUpDownSelected=function(e){var t=S[0];if(t){var r,n;Ue=[];var i=qr(Fe(Ut([t]))).toArray();if("Down"===e&&i.reverse(),qr.each(i,(function(){return n?(r=this,!1):(this===t&&(n=!0),!0)})),r){var a=t,s=a.parentNode,o=a.nextSibling;qr(r)["Down"===e?"before":"after"](a),o!==a.nextSibling&&(U(new Wr(a,o,s,"Move "+e)),ee("changed",[a]))}}},this.moveSelectedElements=function(e,t,r){e.constructor!==Array&&(e/=y,t/=y),r=r||!0;for(var n=new Xr("position"),i=S.length;i--;){var a=S[i];if(!Yt(a)){var s=c.createSVGTransform(),o=q(a);e.constructor===Array?s.setTranslate(e[i],t[i]):s.setTranslate(e,t),o.numberOfItems?o.insertItemBefore(s,0):o.appendItem(s);var u=Hr(a);u&&n.addSubCommand(u),W.requestSelector(a).resize()}}if(!n.isEmpty())return r&&U(n),ee("changed",S),n},this.cloneSelectedElements=function(e,t){var r,n,i=new Xr("Clone Elements"),a=S.length;for(S.sort((function(e,t){return qr(t).index()-qr(e).index()})),r=0;r<a&&(n=S[r],!Yt(n));++r);var s=S.slice(0,r);this.clearSelection(!0);var o=p();for(r=s.length;r--;)n=s[r]=o.copyElem(s[r]),(v||o.getCurrentLayer()).append(n),i.addSubCommand(new Qr(n));i.isEmpty()||(re(s.reverse()),this.moveSelectedElements(e,t,!1),U(i))},this.alignSelectedElements=function(e,t){var r=[],n=S.length;if(n){for(var i=Number.MAX_VALUE,a=Number.MIN_VALUE,s=Number.MAX_VALUE,u=Number.MIN_VALUE,l=Number.MIN_VALUE,h=Number.MIN_VALUE,c=0;c<n&&!Yt(S[c]);++c){var d=S[c];switch(r[c]=Ut([d]),t){case"smallest":(("l"===e||"c"===e||"r"===e)&&(l===Number.MIN_VALUE||l>r[c].width)||("t"===e||"m"===e||"b"===e)&&(h===Number.MIN_VALUE||h>r[c].height))&&(i=r[c].x,s=r[c].y,a=r[c].x+r[c].width,u=r[c].y+r[c].height,l=r[c].width,h=r[c].height);break;case"largest":(("l"===e||"c"===e||"r"===e)&&(l===Number.MIN_VALUE||l<r[c].width)||("t"===e||"m"===e||"b"===e)&&(h===Number.MIN_VALUE||h<r[c].height))&&(i=r[c].x,s=r[c].y,a=r[c].x+r[c].width,u=r[c].y+r[c].height,l=r[c].width,h=r[c].height);break;default:r[c].x<i&&(i=r[c].x),r[c].y<s&&(s=r[c].y),r[c].x+r[c].width>a&&(a=r[c].x+r[c].width),r[c].y+r[c].height>u&&(u=r[c].y+r[c].height)}}"page"===t&&(i=0,s=0,a=o.contentW,u=o.contentH);for(var m=new Array(n),f=new Array(n),g=0;g<n&&!Yt(S[g]);++g){var p=r[g];switch(m[g]=0,f[g]=0,e){case"l":m[g]=i-p.x;break;case"c":m[g]=(i+a)/2-(p.x+p.width/2);break;case"r":m[g]=a-(p.x+p.width);break;case"t":f[g]=s-p.y;break;case"m":f[g]=(s+u)/2-(p.y+p.height/2);break;case"b":f[g]=u-(p.y+p.height)}}this.moveSelectedElements(m,f)}},this.contentW=rr().w,this.contentH=rr().h,this.updateCanvas=function(e,t){c.setAttribute("width",e),c.setAttribute("height",t);var r=qr("#canvasBackground")[0],n=f.getAttribute("x"),i=f.getAttribute("y"),a=(e-this.contentW*y)/2,s=(t-this.contentH*y)/2;zt(f,{width:this.contentW*y,height:this.contentH*y,x:a,y:s,viewBox:"0 0 "+this.contentW+" "+this.contentH}),zt(r,{width:f.getAttribute("width"),height:f.getAttribute("height"),x:a,y:s});var o=Dt("background_image");return o&&zt(o,{width:"100%",height:"100%"}),W.selectorParentGroup.setAttribute("transform","translate("+a+","+s+")"),je("canvasUpdated",{new_x:a,new_y:s,old_x:n,old_y:i,d_x:a-n,d_y:s-i}),{x:a,y:s,old_x:n,old_y:i,d_x:a-n,d_y:s-i}},this.setBackground=function(e,t){var r=Dt("canvasBackground"),n=qr(r).find("rect")[0],i=Dt("background_image");n.setAttribute("fill",e),t?(i||(i=h.createElementNS(d.SVG,"image"),zt(i,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})),Ct(i,t),r.append(i)):i&&i.remove()},this.cycleElement=function(e){var t,r=S[0],n=!1,i=Bt(v||p().getCurrentLayer());if(i.length){if(Yt(r))n=i[t=e?i.length-1:0];else for(var a=i.length;a--;)if(i[a]===r){(t=e?a-1:a+1)>=i.length?t=0:t<0&&(t=i.length-1),n=i[t];break}Ke([n],!0),ee("selected",S)}},this.clear(),this.getPrivateMethods=function(){return{addCommandToHistory:U,BatchCommand:Xr,ChangeElementCommand:Zr,decode64:yt,dropXMLInteralSubset:ft,encode64:pt,ffClone:We,findDefs:Et,findDuplicateGradient:ar,getElem:Dt,getPathBBox:Pt,getTypeMap:Z,getUrlFromAttr:At,identifyLayers:lr,InsertElementCommand:Qr,isChrome:M,isIdentity:pe,isIE:O,logMatrix:Ye,MoveElementCommand:Wr,NS:d,preventClickDefault:Qt,RemoveElementCommand:Yr,SVGEditTransformList:D,text2xml:bt,transformBox:xe,transformPoint:ge,walkTree:wt}}}}();
  //# sourceMappingURL=svgcanvas-iife.min.js.map
  