svgedit/dist/editor/system/extensions/ext-server_moinsave/ext-server_moinsave.js

9 lines
80 KiB
JavaScript

System.register([],(function(t,e){"use strict";return{execute:function(){function asyncGeneratorStep(t,e,i,n,s,l,o){try{var u=t[l](o),h=u.value}catch(t){return void i(t)}u.done?e(h):Promise.resolve(h).then(n,s)}function _asyncToGenerator(t){return function(){var e=this,i=arguments;return new Promise((function(n,s){var l=t.apply(e,i);function _next(t){asyncGeneratorStep(l,n,s,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(l,n,s,_next,_throw,"throw",t)}_next(void 0)}))}}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _createClass(t,e,i){return e&&_defineProperties(t.prototype,e),i&&_defineProperties(t,i),t}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_setPrototypeOf(t,e)}function _getPrototypeOf(t){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function _setPrototypeOf(t,e){return(_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(t,e){return t.__proto__=e,t})(t,e)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function _construct(t,e,i){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function _construct(t,e,i){var n=[null];n.push.apply(n,e);var s=new(Function.bind.apply(t,n));return i&&_setPrototypeOf(s,i.prototype),s}).apply(null,arguments)}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _possibleConstructorReturn(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?_assertThisInitialized(t):e}function _createSuper(t){var e=_isNativeReflectConstruct();return function _createSuperInternal(){var i,n=_getPrototypeOf(t);if(e){var s=_getPrototypeOf(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return _possibleConstructorReturn(this,i)}}function _get(t,e,i){return(_get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function _get(t,e,i){var n=function _superPropBase(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=_getPrototypeOf(t)););return t}(t,e);if(n){var s=Object.getOwnPropertyDescriptor(n,e);return s.get?s.get.call(i):s.value}})(t,e,i||t)}function _slicedToArray(t,e){return function _arrayWithHoles(t){if(Array.isArray(t))return t}(t)||function _iterableToArrayLimit(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var i=[],n=!0,s=!1,l=void 0;try{for(var o,u=t[Symbol.iterator]();!(n=(o=u.next()).done)&&(i.push(o.value),!e||i.length!==e);n=!0);}catch(t){s=!0,l=t}finally{try{n||null==u.return||u.return()}finally{if(s)throw l}}return i}(t,e)||_unsupportedIterableToArray(t,e)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}
/**
* For parsing color values.
* @module RGBColor
* @author Stoyan Stefanov <sstoo@gmail.com>
* @see https://www.phpied.com/rgb-color-parser-in-javascript/
* @license MIT
*/()}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||_unsupportedIterableToArray(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var i={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"},n=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function process(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];return i.map((function(t){return Number.parseInt(t)}))}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function process(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];return i.map((function(t){return Number.parseInt(t,16)}))}},{re:/^(\w)(\w)(\w)$/,example:["#fb0","f0f"],process:function process(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];return i.map((function(t){return Number.parseInt(t+t,16)}))}}],s=function(){function RGBColor(t){var e=this;_classCallCheck(this,RGBColor),this.ok=!1,"#"===t.charAt(0)&&(t=t.substr(1,6)),(t=(t=t.replace(/ /g,"")).toLowerCase())in i&&(t=i[t]),n.forEach((function(i){var n=i.re,s=i.process,l=n.exec(t);if(l){var o=_slicedToArray(s.apply(void 0,_toConsumableArray(l)),3),u=o[0],h=o[1],d=o[2];Object.assign(e,{r:u,g:h,b:d}),e.ok=!0}})),this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b}return _createClass(RGBColor,[{key:"toRGB",value:function toRGB(){return"rgb("+this.r+", "+this.g+", "+this.b+")"}},{key:"toHex",value:function toHex(){var t=this.r.toString(16),e=this.g.toString(16),i=this.b.toString(16);return 1===t.length&&(t="0"+t),1===e.length&&(e="0"+e),1===i.length&&(i="0"+i),"#"+t+e+i}}],[{key:"getHelpXML",value:function getHelpXML(){var t=[].concat(_toConsumableArray(n.flatMap((function(t){return t.example}))),_toConsumableArray(Object.keys(i))),e=document.createElement("ul");return e.setAttribute("id","rgbcolor-examples"),e.append.apply(e,_toConsumableArray(t.map((function(t){try{var e=document.createElement("li"),i=new RGBColor(t),n=document.createElement("div");n.style.cssText="\n margin: 3px;\n border: 1px solid black;\n background: ".concat(i.toHex(),";\n color: ").concat(i.toHex(),";"),n.append("test");var s=" ".concat(t," -> ").concat(i.toRGB()," -> ").concat(i.toHex());return e.append(n,s),e}catch(t){return""}})))),e}}]),RGBColor}();function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function _typeof(t){return typeof t}:function _typeof(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var l=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],o=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function processCanvasRGBA(t,e,i,n,s,h){if(!(isNaN(h)||h<1)){h|=0;var d=function getImageDataFromCanvas(t,e,i,n,s){if("string"==typeof t&&(t=document.getElementById(t)),!t||"object"!==_typeof(t)||!("getContext"in t))throw new TypeError("Expecting canvas with `getContext` method in processCanvasRGB(A) calls!");var l=t.getContext("2d");try{return l.getImageData(e,i,n,s)}catch(t){throw new Error("unable to access image data: "+t)}}(t,e,i,n,s);d=function processImageDataRGBA(t,e,i,n,s,h){var d,p,v,g,_,b,C,k,P,w,E,S,T,V,B,M,A,R,D,O,N,I,z,X,L,W=t.data,G=2*h+1,F=n-1,H=s-1,j=h+1,q=j*(j+1)/2,Y=new u,U=Y;for(v=1;v<G;v++)U=U.next=new u,v===j&&(L=U);U.next=Y;var $=null,Q=null;C=b=0;var Z=l[h],J=o[h];for(p=0;p<s;p++){for(M=A=R=D=k=P=w=E=0,S=j*(O=W[b]),T=j*(N=W[b+1]),V=j*(I=W[b+2]),B=j*(z=W[b+3]),k+=q*O,P+=q*N,w+=q*I,E+=q*z,U=Y,v=0;v<j;v++)U.r=O,U.g=N,U.b=I,U.a=z,U=U.next;for(v=1;v<j;v++)g=b+((F<v?F:v)<<2),k+=(U.r=O=W[g])*(X=j-v),P+=(U.g=N=W[g+1])*X,w+=(U.b=I=W[g+2])*X,E+=(U.a=z=W[g+3])*X,M+=O,A+=N,R+=I,D+=z,U=U.next;for($=Y,Q=L,d=0;d<n;d++)W[b+3]=z=E*Z>>J,0!==z?(z=255/z,W[b]=(k*Z>>J)*z,W[b+1]=(P*Z>>J)*z,W[b+2]=(w*Z>>J)*z):W[b]=W[b+1]=W[b+2]=0,k-=S,P-=T,w-=V,E-=B,S-=$.r,T-=$.g,V-=$.b,B-=$.a,g=C+((g=d+h+1)<F?g:F)<<2,k+=M+=$.r=W[g],P+=A+=$.g=W[g+1],w+=R+=$.b=W[g+2],E+=D+=$.a=W[g+3],$=$.next,S+=O=Q.r,T+=N=Q.g,V+=I=Q.b,B+=z=Q.a,M-=O,A-=N,R-=I,D-=z,Q=Q.next,b+=4;C+=n}for(d=0;d<n;d++){for(A=R=D=M=P=w=E=k=0,S=j*(O=W[b=d<<2]),T=j*(N=W[b+1]),V=j*(I=W[b+2]),B=j*(z=W[b+3]),k+=q*O,P+=q*N,w+=q*I,E+=q*z,U=Y,v=0;v<j;v++)U.r=O,U.g=N,U.b=I,U.a=z,U=U.next;for(_=n,v=1;v<=h;v++)b=_+d<<2,k+=(U.r=O=W[b])*(X=j-v),P+=(U.g=N=W[b+1])*X,w+=(U.b=I=W[b+2])*X,E+=(U.a=z=W[b+3])*X,M+=O,A+=N,R+=I,D+=z,U=U.next,v<H&&(_+=n);for(b=d,$=Y,Q=L,p=0;p<s;p++)W[(g=b<<2)+3]=z=E*Z>>J,z>0?(z=255/z,W[g]=(k*Z>>J)*z,W[g+1]=(P*Z>>J)*z,W[g+2]=(w*Z>>J)*z):W[g]=W[g+1]=W[g+2]=0,k-=S,P-=T,w-=V,E-=B,S-=$.r,T-=$.g,V-=$.b,B-=$.a,g=d+((g=p+j)<H?g:H)*n<<2,k+=M+=$.r=W[g],P+=A+=$.g=W[g+1],w+=R+=$.b=W[g+2],E+=D+=$.a=W[g+3],$=$.next,S+=O=Q.r,T+=N=Q.g,V+=I=Q.b,B+=z=Q.a,M-=O,A-=N,R-=I,D-=z,Q=Q.next,b+=n}return t}(d,0,0,n,s,h),t.getContext("2d").putImageData(d,e,i)}}var u=function BlurStack(){!function _classCallCheck$1(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,BlurStack),this.r=0,this.g=0,this.b=0,this.a=0,this.next=null},h=function isNullish(t){return null==t},d=function canvg(t,e,i){if(h(t)&&h(e)&&h(i)){var n=document.querySelectorAll("svg");return Promise.all(_toConsumableArray(n).map((function(t){var e=document.createElement("canvas");e.width=t.clientWidth,e.height=t.clientHeight,t.before(e),t.remove();var i=document.createElement("div");return i.append(t),canvg(e,i.innerHTML)})))}"string"==typeof t&&(t=document.getElementById(t)),h(t.svg)||t.svg.stop();var l=function build(t){var e={opts:t,FRAMERATE:30,MAX_VIRTUAL_PIXELS:3e4,log:function(t){}};!0===e.opts.log&&"undefined"!=typeof console&&(e.log=function(t){console.log(t)});e.init=function(t){var i=0;e.UniqueId=function(){return"canvg"+ ++i},e.Definitions={},e.Styles={},e.Animations=[],e.Images=[],e.ctx=t,e.ViewPort={viewPorts:[],Clear:function Clear(){this.viewPorts=[]},SetCurrent:function SetCurrent(t,e){this.viewPorts.push({width:t,height:e})},RemoveCurrent:function RemoveCurrent(){this.viewPorts.pop()},Current:function Current(){return this.viewPorts[this.viewPorts.length-1]},width:function width(){return this.Current().width},height:function height(){return this.Current().height},ComputeSize:function ComputeSize(t){return h(t)||"number"!=typeof t?"x"===t?this.width():"y"===t?this.height():Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2):t}}},e.init(),e.ImagesLoaded=function(){return e.Images.every((function(t){return t.loaded}))},e.trim=function(t){return t.replace(/^\s+|\s+$/g,"")},e.compressSpaces=function(t){return t.replace(/\s+/gm," ")},e.ajax=function(t,e){var i=window.XMLHttpRequest?new XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");return e?new Promise((function(e,n){i.open("GET",t,!0).addEventListener("load",(function(){e(i.responseText)})),i.send(null)})):(i.open("GET",t,!1),i.send(null),i.responseText)},e.parseXml=function(t){if(window.DOMParser)return(new DOMParser).parseFromString(t,"text/xml");t=t.replace(/<!DOCTYPE svg[^>]*>/,"");var e=new window.ActiveXObject("Microsoft.XMLDOM");return e.async="false",e.loadXML(t),e};var i={baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"};e.Property=function(){function Property(t,e){_classCallCheck(this,Property),this.name=t,this.value=e}return _createClass(Property,[{key:"getValue",value:function getValue(){return this.value}},{key:"hasValue",value:function hasValue(){return!h(this.value)&&""!==this.value}},{key:"numValue",value:function numValue(){if(!this.hasValue())return 0;var t=Number.parseFloat(this.value);return String(this.value).endsWith("%")&&(t/=100),t}},{key:"valueOrDefault",value:function valueOrDefault(t){return this.hasValue()?this.value:t}},{key:"numValueOrDefault",value:function numValueOrDefault(t){return this.hasValue()?this.numValue():t}},{key:"addOpacity",value:function addOpacity(t){var i=this.value;if(!h(t.value)&&""!==t.value&&"string"==typeof this.value){var n=new s(this.value);n.ok&&(i="rgba("+n.r+", "+n.g+", "+n.b+", "+t.numValue()+")")}return new e.Property(this.name,i)}},{key:"getDefinition",value:function getDefinition(){var t=this.value.match(/#([^)'"]+)/);return t&&(t=t[1]),t||(t=this.value),e.Definitions[t]}},{key:"isUrlDefinition",value:function isUrlDefinition(){return this.value.startsWith("url(")}},{key:"getFillStyleDefinition",value:function getFillStyleDefinition(t,i){var n=this.getDefinition();if(!h(n)&&n.createGradient)return n.createGradient(e.ctx,t,i);if(!h(n)&&n.createPattern){if(n.getHrefAttribute().hasValue()){var s=n.attribute("patternTransform");n=n.getHrefAttribute().getDefinition(),s.hasValue()&&(n.attribute("patternTransform",!0).value=s.value)}return n.createPattern(e.ctx,t)}return null}},{key:"getDPI",value:function getDPI(t){return 96}},{key:"getEM",value:function getEM(t){var i=12,n=new e.Property("fontSize",e.Font.Parse(e.ctx.font).fontSize);return n.hasValue()&&(i=n.toPixels(t)),i}},{key:"getUnits",value:function getUnits(){return String(this.value).replace(/[\d.-]/g,"")}},{key:"toPixels",value:function toPixels(t,i){if(!this.hasValue())return 0;var n=String(this.value);if(n.endsWith("em"))return this.numValue()*this.getEM(t);if(n.endsWith("ex"))return this.numValue()*this.getEM(t)/2;if(n.endsWith("px"))return this.numValue();if(n.endsWith("pt"))return this.numValue()*this.getDPI(t)*(1/72);if(n.endsWith("pc"))return 15*this.numValue();if(n.endsWith("cm"))return this.numValue()*this.getDPI(t)/2.54;if(n.endsWith("mm"))return this.numValue()*this.getDPI(t)/25.4;if(n.endsWith("in"))return this.numValue()*this.getDPI(t);if(n.endsWith("%"))return this.numValue()*e.ViewPort.ComputeSize(t);var s=this.numValue();return i&&s<1?s*e.ViewPort.ComputeSize(t):s}},{key:"toMilliseconds",value:function toMilliseconds(){if(!this.hasValue())return 0;var t=String(this.value);return t.endsWith("ms")?this.numValue():t.endsWith("s")?1e3*this.numValue():this.numValue()}},{key:"toRadians",value:function toRadians(){if(!this.hasValue())return 0;var t=String(this.value);return t.endsWith("deg")?this.numValue()*(Math.PI/180):t.endsWith("grad")?this.numValue()*(Math.PI/200):t.endsWith("rad")?this.numValue():this.numValue()*(Math.PI/180)}},{key:"toTextBaseline",value:function toTextBaseline(){return this.hasValue()?i[this.value]:null}}]),Property}(),e.Font={Styles:"normal|italic|oblique|inherit",Variants:"normal|small-caps|inherit",Weights:"normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit",CreateFont:function CreateFont(t,i,n,s,l,o){var u=h(o)?this.CreateFont("","","","","",e.ctx.font):this.Parse(o);return{fontFamily:l||u.fontFamily,fontSize:s||u.fontSize,fontStyle:t||u.fontStyle,fontWeight:n||u.fontWeight,fontVariant:i||u.fontVariant,toString:function toString(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}},Parse:function Parse(t){var i=this,n={},s=e.trim(e.compressSpaces(t||"")).split(" "),l={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1},o="";return s.forEach((function(t){!l.fontStyle&&i.Styles.includes(t)?("inherit"!==t&&(n.fontStyle=t),l.fontStyle=!0):!l.fontVariant&&i.Variants.includes(t)?("inherit"!==t&&(n.fontVariant=t),l.fontStyle=l.fontVariant=!0):!l.fontWeight&&i.Weights.includes(t)?("inherit"!==t&&(n.fontWeight=t),l.fontStyle=l.fontVariant=l.fontWeight=!0):l.fontSize?"inherit"!==t&&(o+=t):("inherit"!==t&&(n.fontSize=t.split("/")[0]),l.fontStyle=l.fontVariant=l.fontWeight=l.fontSize=!0)})),""!==o&&(n.fontFamily=o),n}},e.ToNumberArray=function(t){return e.trim(e.compressSpaces((t||"").replace(/,/g," "))).split(" ").map((function(t){return Number.parseFloat(t)}))},e.Point=function(){function _class(t,e){_classCallCheck(this,_class),this.x=t,this.y=e}return _createClass(_class,[{key:"angleTo",value:function angleTo(t){return Math.atan2(t.y-this.y,t.x-this.x)}},{key:"applyTransform",value:function applyTransform(t){var e=this.x*t[0]+this.y*t[2]+t[4],i=this.x*t[1]+this.y*t[3]+t[5];this.x=e,this.y=i}}]),_class}(),e.CreatePoint=function(t){var i=e.ToNumberArray(t);return new e.Point(i[0],i[1])},e.CreatePath=function(t){for(var i=e.ToNumberArray(t),n=[],s=0;s<i.length;s+=2)n.push(new e.Point(i[s],i[s+1]));return n},e.BoundingBox=function(){function _class2(t,e,i,n){_classCallCheck(this,_class2),this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN,this.addPoint(t,e),this.addPoint(i,n)}return _createClass(_class2,[{key:"x",value:function x(){return this.x1}},{key:"y",value:function y(){return this.y1}},{key:"width",value:function width(){return this.x2-this.x1}},{key:"height",value:function height(){return this.y2-this.y1}},{key:"addPoint",value:function addPoint(t,e){h(t)||((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),t<this.x1&&(this.x1=t),t>this.x2&&(this.x2=t)),h(e)||((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))}},{key:"addX",value:function addX(t){this.addPoint(t,null)}},{key:"addY",value:function addY(t){this.addPoint(null,t)}},{key:"addBoundingBox",value:function addBoundingBox(t){this.addPoint(t.x1,t.y1),this.addPoint(t.x2,t.y2)}},{key:"addQuadraticCurve",value:function addQuadraticCurve(t,e,i,n,s,l){var o=t+2/3*(i-t),u=e+2/3*(n-e),h=o+1/3*(s-t),d=u+1/3*(l-e);this.addBezierCurve(t,e,o,h,u,d,s,l)}},{key:"addBezierCurve",value:function addBezierCurve(t,e,i,n,s,l,o,u){var h=this,d=[t,e],p=[i,n],v=[s,l],g=[o,u];this.addPoint(d[0],d[1]),this.addPoint(g[0],g[1]);for(var _=function _loop(t){var e=function f(e){return Math.pow(1-e,3)*d[t]+3*Math.pow(1-e,2)*e*p[t]+3*(1-e)*Math.pow(e,2)*v[t]+Math.pow(e,3)*g[t]},i=6*d[t]-12*p[t]+6*v[t],n=-3*d[t]+9*p[t]-9*v[t]+3*g[t],s=3*p[t]-3*d[t];if(0===n){if(0===i)return"continue";var l=-s/i;return l>0&&l<1&&(0===t&&h.addX(e(l)),1===t&&h.addY(e(l))),"continue"}var o=Math.pow(i,2)-4*s*n;if(o<0)return"continue";var u=(-i+Math.sqrt(o))/(2*n);u>0&&u<1&&(0===t&&h.addX(e(u)),1===t&&h.addY(e(u)));var _=(-i-Math.sqrt(o))/(2*n);_>0&&_<1&&(0===t&&h.addX(e(_)),1===t&&h.addY(e(_)))},b=0;b<=1;b++)_(b)}},{key:"isPointInBox",value:function isPointInBox(t,e){return this.x1<=t&&t<=this.x2&&this.y1<=e&&e<=this.y2}}]),_class2}(),e.Transform=function(){function _class3(t){var i=this;_classCallCheck(this,_class3),this.Type={translate:function translate(t){_classCallCheck(this,translate),this.p=e.CreatePoint(t),this.apply=function(t){t.translate(this.p.x||0,this.p.y||0)},this.unapply=function(t){t.translate(-1*this.p.x||0,-1*this.p.y||0)},this.applyToPoint=function(t){t.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0])}},rotate:function rotate(t){_classCallCheck(this,rotate);var i=e.ToNumberArray(t);this.angle=new e.Property("angle",i[0]),this.cx=i[1]||0,this.cy=i[2]||0,this.apply=function(t){t.translate(this.cx,this.cy),t.rotate(this.angle.toRadians()),t.translate(-this.cx,-this.cy)},this.unapply=function(t){t.translate(this.cx,this.cy),t.rotate(-1*this.angle.toRadians()),t.translate(-this.cx,-this.cy)},this.applyToPoint=function(t){var e=this.angle.toRadians();t.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0]),t.applyTransform([Math.cos(e),Math.sin(e),-Math.sin(e),Math.cos(e),0,0]),t.applyTransform([1,0,0,1,-this.p.x||0,-this.p.y||0])}},scale:function scale(t){_classCallCheck(this,scale),this.p=e.CreatePoint(t),this.apply=function(t){t.scale(this.p.x||1,this.p.y||this.p.x||1)},this.unapply=function(t){t.scale(1/this.p.x||1,1/this.p.y||this.p.x||1)},this.applyToPoint=function(t){t.applyTransform([this.p.x||0,0,0,this.p.y||0,0,0])}},matrix:function matrix(t){_classCallCheck(this,matrix),this.m=e.ToNumberArray(t),this.apply=function(t){t.transform(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5])},this.applyToPoint=function(t){t.applyTransform(this.m)}}},Object.assign(this.Type,{SkewBase:function(t){_inherits(SkewBase,t);var i=_createSuper(SkewBase);function SkewBase(t){var n;return _classCallCheck(this,SkewBase),(n=i.call(this,t)).angle=new e.Property("angle",t),n}return SkewBase}(this.Type.matrix)}),Object.assign(this.Type,{skewX:function(t){_inherits(skewX,t);var e=_createSuper(skewX);function skewX(t){var i;return _classCallCheck(this,skewX),(i=e.call(this,t)).m=[1,0,Math.tan(i.angle.toRadians()),1,0,0],i}return skewX}(this.Type.SkewBase),skewY:function(t){_inherits(skewY,t);var e=_createSuper(skewY);function skewY(t){var i;return _classCallCheck(this,skewY),(i=e.call(this,t)).m=[1,Math.tan(i.angle.toRadians()),0,1,0,0],i}return skewY}(this.Type.SkewBase)});var n=e.trim(e.compressSpaces(t)).replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/);this.transforms=n.map((function(t){var n=e.trim(t.split("(")[0]),s=t.split("(")[1].replace(")",""),l=new i.Type[n](s);return l.type=n,l}))}return _createClass(_class3,[{key:"apply",value:function apply(t){this.transforms.forEach((function(e){e.apply(t)}))}},{key:"unapply",value:function unapply(t){for(var e=this.transforms.length-1;e>=0;e--)this.transforms[e].unapply(t)}},{key:"applyToPoint",value:function applyToPoint(t){this.transforms.forEach((function(e){e.applyToPoint(t)}))}}]),_class3}(),e.AspectRatio=function(t,i,n,s,l,o,u,d,p,v){var g=(i=(i=e.compressSpaces(i)).replace(/^defer\s/,"")).split(" ")[0]||"xMidYMid",_=i.split(" ")[1]||"meet",b=n/s,C=l/o,k=Math.min(b,C),P=Math.max(b,C);"meet"===_&&(s*=k,o*=k),"slice"===_&&(s*=P,o*=P),p=new e.Property("refX",p),v=new e.Property("refY",v),p.hasValue()&&v.hasValue()?t.translate(-k*p.toPixels("x"),-k*v.toPixels("y")):(g.startsWith("xMid")&&("meet"===_&&k===C||"slice"===_&&P===C)&&t.translate(n/2-s/2,0),g.endsWith("YMid")&&("meet"===_&&k===b||"slice"===_&&P===b)&&t.translate(0,l/2-o/2),g.startsWith("xMax")&&("meet"===_&&k===C||"slice"===_&&P===C)&&t.translate(n-s,0),g.endsWith("YMax")&&("meet"===_&&k===b||"slice"===_&&P===b)&&t.translate(0,l-o)),"none"===g?t.scale(b,C):"meet"===_?t.scale(k,k):"slice"===_&&t.scale(P,P),t.translate(h(u)?0:-u,h(d)?0:-d)},e.Element={},e.EmptyProperty=new e.Property("EMPTY",""),e.Element.ElementBase=function(){function _class4(t){var i=this;if(_classCallCheck(this,_class4),this.captureTextNodes=arguments[1],this.attributes={},this.styles={},this.children=[],!h(t)&&1===t.nodeType){_toConsumableArray(t.childNodes).forEach((function(t){if(1===t.nodeType&&i.addChild(t,!0),i.captureTextNodes&&(3===t.nodeType||4===t.nodeType)){var n=t.nodeValue||t.text||"";""!==e.trim(e.compressSpaces(n))&&i.addChild(new e.Element.tspan(t),!1)}})),_toConsumableArray(t.attributes).forEach((function(t){var n=t.nodeName,s=t.nodeValue;i.attributes[n]=new e.Property(n,s)}));var n=e.Styles[t.nodeName];if(h(n)||Object.entries(n).forEach((function(t){var e=_slicedToArray(t,2),n=e[0],s=e[1];i.styles[n]=s})),this.attribute("class").hasValue())e.compressSpaces(this.attribute("class").value).split(" ").forEach((function(s){n=e.Styles["."+s],h(n)||Object.entries(n).forEach((function(t){var e=_slicedToArray(t,2),n=e[0],s=e[1];i.styles[n]=s})),n=e.Styles[t.nodeName+"."+s],h(n)||Object.entries(n).forEach((function(t){var e=_slicedToArray(t,2),n=e[0],s=e[1];i.styles[n]=s}))}));if(this.attribute("id").hasValue()){var s=e.Styles["#"+this.attribute("id").value];h(s)||Object.entries(s).forEach((function(t){var e=_slicedToArray(t,2),n=e[0],s=e[1];i.styles[n]=s}))}if(this.attribute("style").hasValue())this.attribute("style").value.split(";").forEach((function(t){if(""!==e.trim(t)){var n=t.split(":"),s=n.name,l=n.value;s=e.trim(s),l=e.trim(l),i.styles[s]=new e.Property(s,l)}}));this.attribute("id").hasValue()&&h(e.Definitions[this.attribute("id").value])&&(e.Definitions[this.attribute("id").value]=this)}}return _createClass(_class4,[{key:"attribute",value:function attribute(t,i){var n=this.attributes[t];return h(n)?(!0===i&&(n=new e.Property(t,""),this.attributes[t]=n),n||e.EmptyProperty):n}},{key:"getHrefAttribute",value:function getHrefAttribute(){for(var t in this.attributes)if(t.endsWith(":href"))return this.attributes[t];return e.EmptyProperty}},{key:"style",value:function style(t,i,n){var s=this.styles[t];if(!h(s))return s;var l=this.attribute(t);if(!h(l)&&l.hasValue())return this.styles[t]=l,l;if(!0!==n){var o=this.parent;if(!h(o)){var u=o.style(t);if(!h(u)&&u.hasValue())return u}}return!0===i&&(s=new e.Property(t,""),this.styles[t]=s),s||e.EmptyProperty}},{key:"render",value:function render(t){if("none"!==this.style("display").value&&"hidden"!==this.style("visibility").value){if(t.save(),this.attribute("mask").hasValue()){var e=this.attribute("mask").getDefinition();h(e)||e.apply(t,this)}else if(this.style("filter").hasValue()){var i=this.style("filter").getDefinition();h(i)||i.apply(t,this)}else this.setContext(t),this.renderChildren(t),this.clearContext(t);t.restore()}}},{key:"setContext",value:function setContext(t){}},{key:"clearContext",value:function clearContext(t){}},{key:"renderChildren",value:function renderChildren(t){this.children.forEach((function(e){e.render(t)}))}},{key:"addChild",value:function addChild(t,i){var n=i?e.CreateElement(t):t;n.parent=this,"title"!==n.type&&this.children.push(n)}}]),_class4}(),e.Element.RenderedElementBase=function(t){_inherits(_class5,t);var i=_createSuper(_class5);function _class5(){return _classCallCheck(this,_class5),i.apply(this,arguments)}return _createClass(_class5,[{key:"setContext",value:function setContext(t){if(this.style("fill").isUrlDefinition()){var i=this.style("fill").getFillStyleDefinition(this,this.style("fill-opacity"));h(i)||(t.fillStyle=i)}else if(this.style("fill").hasValue()){var n=this.style("fill");"currentColor"===n.value&&(n.value=this.style("color").value),t.fillStyle="none"===n.value?"rgba(0,0,0,0)":n.value}if(this.style("fill-opacity").hasValue()){var s=new e.Property("fill",t.fillStyle);s=s.addOpacity(this.style("fill-opacity")),t.fillStyle=s.value}if(this.style("stroke").isUrlDefinition()){var l=this.style("stroke").getFillStyleDefinition(this,this.style("stroke-opacity"));h(l)||(t.strokeStyle=l)}else if(this.style("stroke").hasValue()){var o=this.style("stroke");"currentColor"===o.value&&(o.value=this.style("color").value),t.strokeStyle="none"===o.value?"rgba(0,0,0,0)":o.value}if(this.style("stroke-opacity").hasValue()){var u=new e.Property("stroke",t.strokeStyle);u=u.addOpacity(this.style("stroke-opacity")),t.strokeStyle=u.value}if(this.style("stroke-width").hasValue()){var d=this.style("stroke-width").toPixels();t.lineWidth=0===d?.001:d}if(this.style("stroke-linecap").hasValue()&&(t.lineCap=this.style("stroke-linecap").value),this.style("stroke-linejoin").hasValue()&&(t.lineJoin=this.style("stroke-linejoin").value),this.style("stroke-miterlimit").hasValue()&&(t.miterLimit=this.style("stroke-miterlimit").value),this.style("stroke-dasharray").hasValue()&&"none"!==this.style("stroke-dasharray").value){var p=e.ToNumberArray(this.style("stroke-dasharray").value);void 0!==t.setLineDash?t.setLineDash(p):void 0!==t.webkitLineDash?t.webkitLineDash=p:void 0===t.mozDash||1===p.length&&0===p[0]||(t.mozDash=p);var v=this.style("stroke-dashoffset").numValueOrDefault(1);void 0!==t.lineDashOffset?t.lineDashOffset=v:void 0!==t.webkitLineDashOffset?t.webkitLineDashOffset=v:void 0!==t.mozDashOffset&&(t.mozDashOffset=v)}(void 0!==t.font&&(t.font=e.Font.CreateFont(this.style("font-style").value,this.style("font-variant").value,this.style("font-weight").value,this.style("font-size").hasValue()?this.style("font-size").toPixels()+"px":"",this.style("font-family").value).toString()),this.attribute("transform").hasValue())&&new e.Transform(this.attribute("transform").value).apply(t);if(this.style("clip-path",!1,!0).hasValue()){var g=this.style("clip-path",!1,!0).getDefinition();h(g)||g.apply(t)}this.style("opacity").hasValue()&&(t.globalAlpha=this.style("opacity").numValue())}}]),_class5}(e.Element.ElementBase),e.Element.PathElementBase=function(t){_inherits(_class6,t);var i=_createSuper(_class6);function _class6(){return _classCallCheck(this,_class6),i.apply(this,arguments)}return _createClass(_class6,[{key:"path",value:function path(t){return h(t)||t.beginPath(),new e.BoundingBox}},{key:"renderChildren",value:function renderChildren(t){this.path(t),e.Mouse.checkPath(this,t),""!==t.fillStyle&&("inherit"!==this.style("fill-rule").valueOrDefault("inherit")?t.fill(this.style("fill-rule").value):t.fill()),""!==t.strokeStyle&&t.stroke();var i=this.getMarkers();if(!h(i)){if(this.style("marker-start").isUrlDefinition())this.style("marker-start").getDefinition().render(t,i[0][0],i[0][1]);if(this.style("marker-mid").isUrlDefinition())for(var n=this.style("marker-mid").getDefinition(),s=1;s<i.length-1;s++)n.render(t,i[s][0],i[s][1]);if(this.style("marker-end").isUrlDefinition())this.style("marker-end").getDefinition().render(t,i[i.length-1][0],i[i.length-1][1])}}},{key:"getBoundingBox",value:function getBoundingBox(){return this.path()}},{key:"getMarkers",value:function getMarkers(){return null}}]),_class6}(e.Element.RenderedElementBase),e.Element.svg=function(t){_inherits(_class7,t);var i=_createSuper(_class7);function _class7(){return _classCallCheck(this,_class7),i.apply(this,arguments)}return _createClass(_class7,[{key:"clearContext",value:function clearContext(t){_get(_getPrototypeOf(_class7.prototype),"clearContext",this).call(this,t),e.ViewPort.RemoveCurrent()}},{key:"setContext",value:function setContext(t){t.strokeStyle="rgba(0,0,0,0)",t.lineCap="butt",t.lineJoin="miter",t.miterLimit=4,void 0!==t.font&&void 0!==window.getComputedStyle&&(t.font=window.getComputedStyle(t.canvas).getPropertyValue("font")),_get(_getPrototypeOf(_class7.prototype),"setContext",this).call(this,t),this.attribute("x").hasValue()||(this.attribute("x",!0).value=0),this.attribute("y").hasValue()||(this.attribute("y",!0).value=0),t.translate(this.attribute("x").toPixels("x"),this.attribute("y").toPixels("y"));var i=e.ViewPort.width(),n=e.ViewPort.height();if(this.attribute("width").hasValue()||(this.attribute("width",!0).value="100%"),this.attribute("height").hasValue()||(this.attribute("height",!0).value="100%"),void 0===this.root){i=this.attribute("width").toPixels("x"),n=this.attribute("height").toPixels("y");var s=0,l=0;this.attribute("refX").hasValue()&&this.attribute("refY").hasValue()&&(s=-this.attribute("refX").toPixels("x"),l=-this.attribute("refY").toPixels("y")),"visible"!==this.attribute("overflow").valueOrDefault("hidden")&&(t.beginPath(),t.moveTo(s,l),t.lineTo(i,l),t.lineTo(i,n),t.lineTo(s,n),t.closePath(),t.clip())}if(e.ViewPort.SetCurrent(i,n),this.attribute("viewBox").hasValue()){var o=e.ToNumberArray(this.attribute("viewBox").value),u=o[0],h=o[1];i=o[2],n=o[3],e.AspectRatio(t,this.attribute("preserveAspectRatio").value,e.ViewPort.width(),i,e.ViewPort.height(),n,u,h,this.attribute("refX").value,this.attribute("refY").value),e.ViewPort.RemoveCurrent(),e.ViewPort.SetCurrent(o[2],o[3])}}}]),_class7}(e.Element.RenderedElementBase),e.Element.rect=function(t){_inherits(_class8,t);var i=_createSuper(_class8);function _class8(){return _classCallCheck(this,_class8),i.apply(this,arguments)}return _createClass(_class8,[{key:"path",value:function path(t){var i=this.attribute("x").toPixels("x"),n=this.attribute("y").toPixels("y"),s=this.attribute("width").toPixels("x"),l=this.attribute("height").toPixels("y"),o=this.attribute("rx").toPixels("x"),u=this.attribute("ry").toPixels("y");return this.attribute("rx").hasValue()&&!this.attribute("ry").hasValue()&&(u=o),this.attribute("ry").hasValue()&&!this.attribute("rx").hasValue()&&(o=u),o=Math.min(o,s/2),u=Math.min(u,l/2),h(t)||(t.beginPath(),t.moveTo(i+o,n),t.lineTo(i+s-o,n),t.quadraticCurveTo(i+s,n,i+s,n+u),t.lineTo(i+s,n+l-u),t.quadraticCurveTo(i+s,n+l,i+s-o,n+l),t.lineTo(i+o,n+l),t.quadraticCurveTo(i,n+l,i,n+l-u),t.lineTo(i,n+u),t.quadraticCurveTo(i,n,i+o,n),t.closePath()),new e.BoundingBox(i,n,i+s,n+l)}}]),_class8}(e.Element.PathElementBase),e.Element.circle=function(t){_inherits(_class9,t);var i=_createSuper(_class9);function _class9(){return _classCallCheck(this,_class9),i.apply(this,arguments)}return _createClass(_class9,[{key:"path",value:function path(t){var i=this.attribute("cx").toPixels("x"),n=this.attribute("cy").toPixels("y"),s=this.attribute("r").toPixels();return h(t)||(t.beginPath(),t.arc(i,n,s,0,2*Math.PI,!0),t.closePath()),new e.BoundingBox(i-s,n-s,i+s,n+s)}}]),_class9}(e.Element.PathElementBase);var n=(Math.sqrt(2)-1)/3*4;function imGet(t,e,i,n,s,l){return t[i*n*4+4*e+l]}function imSet(t,e,i,n,s,l,o){t[i*n*4+4*e+l]=o}return e.Element.ellipse=function(t){_inherits(_class10,t);var i=_createSuper(_class10);function _class10(){return _classCallCheck(this,_class10),i.apply(this,arguments)}return _createClass(_class10,[{key:"path",value:function path(t){var i=this.attribute("rx").toPixels("x"),s=this.attribute("ry").toPixels("y"),l=this.attribute("cx").toPixels("x"),o=this.attribute("cy").toPixels("y");return h(t)||(t.beginPath(),t.moveTo(l,o-s),t.bezierCurveTo(l+n*i,o-s,l+i,o-n*s,l+i,o),t.bezierCurveTo(l+i,o+n*s,l+n*i,o+s,l,o+s),t.bezierCurveTo(l-n*i,o+s,l-i,o+n*s,l-i,o),t.bezierCurveTo(l-i,o-n*s,l-n*i,o-s,l,o-s),t.closePath()),new e.BoundingBox(l-i,o-s,l+i,o+s)}}]),_class10}(e.Element.PathElementBase),e.Element.line=function(t){_inherits(_class11,t);var i=_createSuper(_class11);function _class11(){return _classCallCheck(this,_class11),i.apply(this,arguments)}return _createClass(_class11,[{key:"getPoints",value:function getPoints(){return[new e.Point(this.attribute("x1").toPixels("x"),this.attribute("y1").toPixels("y")),new e.Point(this.attribute("x2").toPixels("x"),this.attribute("y2").toPixels("y"))]}},{key:"path",value:function path(t){var i=this.getPoints();return h(t)||(t.beginPath(),t.moveTo(i[0].x,i[0].y),t.lineTo(i[1].x,i[1].y)),new e.BoundingBox(i[0].x,i[0].y,i[1].x,i[1].y)}},{key:"getMarkers",value:function getMarkers(){var t=this.getPoints(),e=t[0].angleTo(t[1]);return[[t[0],e],[t[1],e]]}}]),_class11}(e.Element.PathElementBase),e.Element.polyline=function(t){_inherits(_class12,t);var i=_createSuper(_class12);function _class12(t){var n;return _classCallCheck(this,_class12),(n=i.call(this,t)).points=e.CreatePath(n.attribute("points").value),n}return _createClass(_class12,[{key:"path",value:function path(t){var i=this.points[0],n=i.x,s=i.y,l=new e.BoundingBox(n,s);h(t)||(t.beginPath(),t.moveTo(n,s));for(var o=1;o<this.points.length;o++){var u=this.points[o],d=u.x,p=u.y;l.addPoint(d,p),h(t)||t.lineTo(d,p)}return l}},{key:"getMarkers",value:function getMarkers(){for(var t=[],e=0;e<this.points.length-1;e++)t.push([this.points[e],this.points[e].angleTo(this.points[e+1])]);return t.push([this.points[this.points.length-1],t[t.length-1][1]]),t}}]),_class12}(e.Element.PathElementBase),e.Element.polygon=function(t){_inherits(_class13,t);var e=_createSuper(_class13);function _class13(){return _classCallCheck(this,_class13),e.apply(this,arguments)}return _createClass(_class13,[{key:"path",value:function path(t){var e=_get(_getPrototypeOf(_class13.prototype),"path",this).call(this,t);return h(t)||(t.lineTo(this.points[0].x,this.points[0].y),t.closePath()),e}}]),_class13}(e.Element.polyline),e.Element.path=function(t){_inherits(_class14,t);var i=_createSuper(_class14);function _class14(t){var n;_classCallCheck(this,_class14);var s=(n=i.call(this,t)).attribute("d").value.replace(/,/gm," ").replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2").replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2").replace(/([MmZzLlHhVvCcSsQqTtAa])(\S)/gm,"$1 $2").replace(/(\S)([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2").replace(/(\d)([+-])/gm,"$1 $2").replace(/(\.\d*)(\.)/gm,"$1 $2").replace(/([Aa](\s+\d+)(\s+\d+)(\s+\d+))\s+([01])\s*([01])/gm,"$1 $5 $6 ");return s=e.compressSpaces(s),s=e.trim(s),n.PathParser={tokens:s.split(" "),reset:function reset(){this.i=-1,this.command="",this.previousCommand="",this.start=new e.Point(0,0),this.control=new e.Point(0,0),this.current=new e.Point(0,0),this.points=[],this.angles=[]},isEnd:function isEnd(){return this.i>=this.tokens.length-1},isCommandOrEnd:function isCommandOrEnd(){return!!this.isEnd()||!h(this.tokens[this.i+1].match(/^[A-Za-z]$/))},isRelativeCommand:function isRelativeCommand(){switch(this.command){case"m":case"l":case"h":case"v":case"c":case"s":case"q":case"t":case"a":case"z":return!0}return!1},getToken:function getToken(){return this.i++,this.tokens[this.i]},getScalar:function getScalar(){return Number.parseFloat(this.getToken())},nextCommand:function nextCommand(){this.previousCommand=this.command,this.command=this.getToken()},getPoint:function getPoint(){var t=new e.Point(this.getScalar(),this.getScalar());return this.makeAbsolute(t)},getAsControlPoint:function getAsControlPoint(){var t=this.getPoint();return this.control=t,t},getAsCurrentPoint:function getAsCurrentPoint(){var t=this.getPoint();return this.current=t,t},getReflectedControlPoint:function getReflectedControlPoint(){return"c"!==this.previousCommand.toLowerCase()&&"s"!==this.previousCommand.toLowerCase()&&"q"!==this.previousCommand.toLowerCase()&&"t"!==this.previousCommand.toLowerCase()?this.current:new e.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y)},makeAbsolute:function makeAbsolute(t){return this.isRelativeCommand()&&(t.x+=this.current.x,t.y+=this.current.y),t},addMarker:function addMarker(t,e,i){!h(i)&&this.angles.length>0&&h(this.angles[this.angles.length-1])&&(this.angles[this.angles.length-1]=this.points[this.points.length-1].angleTo(i)),this.addMarkerAngle(t,h(e)?null:e.angleTo(t))},addMarkerAngle:function addMarkerAngle(t,e){this.points.push(t),this.angles.push(e)},getMarkerPoints:function getMarkerPoints(){return this.points},getMarkerAngles:function getMarkerAngles(){for(var t=0;t<this.angles.length;t++)if(h(this.angles[t]))for(var e=t+1;e<this.angles.length;e++)if(!h(this.angles[e])){this.angles[t]=this.angles[e];break}return this.angles}},n}return _createClass(_class14,[{key:"path",value:function path(t){var i=this.PathParser;i.reset();var n=new e.BoundingBox;for(h(t)||t.beginPath();!i.isEnd();)switch(i.nextCommand(),i.command){case"M":case"m":var s=i.getAsCurrentPoint();for(i.addMarker(s),n.addPoint(s.x,s.y),h(t)||t.moveTo(s.x,s.y),i.start=i.current;!i.isCommandOrEnd();){var l=i.getAsCurrentPoint();i.addMarker(l,i.start),n.addPoint(l.x,l.y),h(t)||t.lineTo(l.x,l.y)}break;case"L":case"l":for(;!i.isCommandOrEnd();){var o=i.current,u=i.getAsCurrentPoint();i.addMarker(u,o),n.addPoint(u.x,u.y),h(t)||t.lineTo(u.x,u.y)}break;case"H":case"h":for(;!i.isCommandOrEnd();){var d=new e.Point((i.isRelativeCommand()?i.current.x:0)+i.getScalar(),i.current.y);i.addMarker(d,i.current),i.current=d,n.addPoint(i.current.x,i.current.y),h(t)||t.lineTo(i.current.x,i.current.y)}break;case"V":case"v":for(;!i.isCommandOrEnd();){var p=new e.Point(i.current.x,(i.isRelativeCommand()?i.current.y:0)+i.getScalar());i.addMarker(p,i.current),i.current=p,n.addPoint(i.current.x,i.current.y),h(t)||t.lineTo(i.current.x,i.current.y)}break;case"C":case"c":for(;!i.isCommandOrEnd();){var v=i.current,g=i.getPoint(),_=i.getAsControlPoint(),b=i.getAsCurrentPoint();i.addMarker(b,_,g),n.addBezierCurve(v.x,v.y,g.x,g.y,_.x,_.y,b.x,b.y),h(t)||t.bezierCurveTo(g.x,g.y,_.x,_.y,b.x,b.y)}break;case"S":case"s":for(;!i.isCommandOrEnd();){var C=i.current,k=i.getReflectedControlPoint(),P=i.getAsControlPoint(),w=i.getAsCurrentPoint();i.addMarker(w,P,k),n.addBezierCurve(C.x,C.y,k.x,k.y,P.x,P.y,w.x,w.y),h(t)||t.bezierCurveTo(k.x,k.y,P.x,P.y,w.x,w.y)}break;case"Q":case"q":for(;!i.isCommandOrEnd();){var E=i.current,S=i.getAsControlPoint(),T=i.getAsCurrentPoint();i.addMarker(T,S,S),n.addQuadraticCurve(E.x,E.y,S.x,S.y,T.x,T.y),h(t)||t.quadraticCurveTo(S.x,S.y,T.x,T.y)}break;case"T":case"t":for(;!i.isCommandOrEnd();){var V=i.current,B=i.getReflectedControlPoint();i.control=B;var M=i.getAsCurrentPoint();i.addMarker(M,B,B),n.addQuadraticCurve(V.x,V.y,B.x,B.y,M.x,M.y),h(t)||t.quadraticCurveTo(B.x,B.y,M.x,M.y)}break;case"A":case"a":for(var A=function _loop2(){var s=i.current,l=i.getScalar(),o=i.getScalar(),u=i.getScalar()*(Math.PI/180),d=i.getScalar(),p=i.getScalar(),v=i.getAsCurrentPoint(),g=new e.Point(Math.cos(u)*(s.x-v.x)/2+Math.sin(u)*(s.y-v.y)/2,-Math.sin(u)*(s.x-v.x)/2+Math.cos(u)*(s.y-v.y)/2),_=Math.pow(g.x,2)/Math.pow(l,2)+Math.pow(g.y,2)/Math.pow(o,2);_>1&&(l*=Math.sqrt(_),o*=Math.sqrt(_));var b=(d===p?-1:1)*Math.sqrt((Math.pow(l,2)*Math.pow(o,2)-Math.pow(l,2)*Math.pow(g.y,2)-Math.pow(o,2)*Math.pow(g.x,2))/(Math.pow(l,2)*Math.pow(g.y,2)+Math.pow(o,2)*Math.pow(g.x,2)));isNaN(b)&&(b=0);var C=new e.Point(b*l*g.y/o,b*-o*g.x/l),k=new e.Point((s.x+v.x)/2+Math.cos(u)*C.x-Math.sin(u)*C.y,(s.y+v.y)/2+Math.sin(u)*C.x+Math.cos(u)*C.y),P=function m(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))},w=function r(t,e){return(t[0]*e[0]+t[1]*e[1])/(P(t)*P(e))},E=function a(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(w(t,e))},S=E([1,0],[(g.x-C.x)/l,(g.y-C.y)/o]),T=[(g.x-C.x)/l,(g.y-C.y)/o],V=[(-g.x-C.x)/l,(-g.y-C.y)/o],B=E(T,V);w(T,V)<=-1&&(B=Math.PI),w(T,V)>=1&&(B=0);var M=1-p?1:-1,A=S+M*(B/2),R=new e.Point(k.x+l*Math.cos(A),k.y+o*Math.sin(A));if(i.addMarkerAngle(R,A-M*Math.PI/2),i.addMarkerAngle(v,A-M*Math.PI),n.addPoint(v.x,v.y),!h(t)){var D=l>o?l:o,O=l>o?1:l/o,N=l>o?o/l:1;t.translate(k.x,k.y),t.rotate(u),t.scale(O,N),t.arc(0,0,D,S,S+B,1-p),t.scale(1/O,1/N),t.rotate(-u),t.translate(-k.x,-k.y)}};!i.isCommandOrEnd();)A();break;case"Z":case"z":h(t)||t.closePath(),i.current=i.start}return n}},{key:"getMarkers",value:function getMarkers(){var t=this.PathParser.getMarkerPoints(),e=this.PathParser.getMarkerAngles();return t.map((function(t,i){return[t,e[i]]}))}}]),_class14}(e.Element.PathElementBase),e.Element.pattern=function(t){_inherits(_class15,t);var i=_createSuper(_class15);function _class15(){return _classCallCheck(this,_class15),i.apply(this,arguments)}return _createClass(_class15,[{key:"createPattern",value:function createPattern(t,i){var n=this.attribute("width").toPixels("x",!0),s=this.attribute("height").toPixels("y",!0),l=new e.Element.svg;l.attributes.viewBox=new e.Property("viewBox",this.attribute("viewBox").value),l.attributes.width=new e.Property("width",n+"px"),l.attributes.height=new e.Property("height",s+"px"),l.attributes.transform=new e.Property("transform",this.attribute("patternTransform").value),l.children=this.children;var o=document.createElement("canvas");o.width=n,o.height=s;var u=o.getContext("2d");this.attribute("x").hasValue()&&this.attribute("y").hasValue()&&u.translate(this.attribute("x").toPixels("x",!0),this.attribute("y").toPixels("y",!0));for(var h=-1;h<=1;h++)for(var d=-1;d<=1;d++)u.save(),u.translate(h*o.width,d*o.height),l.render(u),u.restore();return t.createPattern(o,"repeat")}}]),_class15}(e.Element.ElementBase),e.Element.marker=function(t){_inherits(_class16,t);var i=_createSuper(_class16);function _class16(){return _classCallCheck(this,_class16),i.apply(this,arguments)}return _createClass(_class16,[{key:"render",value:function render(t,i,n){t.translate(i.x,i.y),"auto"===this.attribute("orient").valueOrDefault("auto")&&t.rotate(n),"strokeWidth"===this.attribute("markerUnits").valueOrDefault("strokeWidth")&&t.scale(t.lineWidth,t.lineWidth),t.save();var s=new e.Element.svg;s.attributes.viewBox=new e.Property("viewBox",this.attribute("viewBox").value),s.attributes.refX=new e.Property("refX",this.attribute("refX").value),s.attributes.refY=new e.Property("refY",this.attribute("refY").value),s.attributes.width=new e.Property("width",this.attribute("markerWidth").value),s.attributes.height=new e.Property("height",this.attribute("markerHeight").value),s.attributes.fill=new e.Property("fill",this.attribute("fill").valueOrDefault("black")),s.attributes.stroke=new e.Property("stroke",this.attribute("stroke").valueOrDefault("none")),s.children=this.children,s.render(t),t.restore(),"strokeWidth"===this.attribute("markerUnits").valueOrDefault("strokeWidth")&&t.scale(1/t.lineWidth,1/t.lineWidth),"auto"===this.attribute("orient").valueOrDefault("auto")&&t.rotate(-n),t.translate(-i.x,-i.y)}}]),_class16}(e.Element.ElementBase),e.Element.defs=function(t){_inherits(_class17,t);var e=_createSuper(_class17);function _class17(){return _classCallCheck(this,_class17),e.apply(this,arguments)}return _createClass(_class17,[{key:"render",value:function render(t){}}]),_class17}(e.Element.ElementBase),e.Element.GradientBase=function(t){_inherits(_class18,t);var i=_createSuper(_class18);function _class18(t){var e;return _classCallCheck(this,_class18),(e=i.call(this,t)).gradientUnits=e.attribute("gradientUnits").valueOrDefault("objectBoundingBox"),e.stops=[],e.children.forEach((function(t){"stop"===t.type&&e.stops.push(t)})),e}return _createClass(_class18,[{key:"getGradient",value:function getGradient(){}},{key:"createGradient",value:function createGradient(t,i,n){var s=this.getHrefAttribute().hasValue()?this.getHrefAttribute().getDefinition():this,l=function addParentOpacity(t){return n.hasValue()?new e.Property("color",t).addOpacity(n).value:t},o=this.getGradient(t,i);if(h(o))return l(s.stops[s.stops.length-1].color);if(s.stops.forEach((function(t){var e=t.offset,i=t.color;o.addColorStop(e,l(i))})),this.attribute("gradientTransform").hasValue()){var u=e.ViewPort.viewPorts[0],d=new e.Element.rect;d.attributes.x=new e.Property("x",-e.MAX_VIRTUAL_PIXELS/3),d.attributes.y=new e.Property("y",-e.MAX_VIRTUAL_PIXELS/3),d.attributes.width=new e.Property("width",e.MAX_VIRTUAL_PIXELS),d.attributes.height=new e.Property("height",e.MAX_VIRTUAL_PIXELS);var p=new e.Element.g;p.attributes.transform=new e.Property("transform",this.attribute("gradientTransform").value),p.children=[d];var v=new e.Element.svg;v.attributes.x=new e.Property("x",0),v.attributes.y=new e.Property("y",0),v.attributes.width=new e.Property("width",u.width),v.attributes.height=new e.Property("height",u.height),v.children=[p];var g=document.createElement("canvas");g.width=u.width,g.height=u.height;var _=g.getContext("2d");return _.fillStyle=o,v.render(_),_.createPattern(g,"no-repeat")}return o}}]),_class18}(e.Element.ElementBase),e.Element.linearGradient=function(t){_inherits(_class19,t);var e=_createSuper(_class19);function _class19(){return _classCallCheck(this,_class19),e.apply(this,arguments)}return _createClass(_class19,[{key:"getGradient",value:function getGradient(t,e){var i="objectBoundingBox"===this.gradientUnits&&e.getBoundingBox,n=i?e.getBoundingBox():null;this.attribute("x1").hasValue()||this.attribute("y1").hasValue()||this.attribute("x2").hasValue()||this.attribute("y2").hasValue()||(this.attribute("x1",!0).value=0,this.attribute("y1",!0).value=0,this.attribute("x2",!0).value=1,this.attribute("y2",!0).value=0);var s=i?n.x()+n.width()*this.attribute("x1").numValue():this.attribute("x1").toPixels("x"),l=i?n.y()+n.height()*this.attribute("y1").numValue():this.attribute("y1").toPixels("y"),o=i?n.x()+n.width()*this.attribute("x2").numValue():this.attribute("x2").toPixels("x"),u=i?n.y()+n.height()*this.attribute("y2").numValue():this.attribute("y2").toPixels("y");return s===o&&l===u?null:t.createLinearGradient(s,l,o,u)}}]),_class19}(e.Element.GradientBase),e.Element.radialGradient=function(t){_inherits(_class20,t);var e=_createSuper(_class20);function _class20(){return _classCallCheck(this,_class20),e.apply(this,arguments)}return _createClass(_class20,[{key:"getGradient",value:function getGradient(t,e){var i="objectBoundingBox"===this.gradientUnits&&e.getBoundingBox,n=i?e.getBoundingBox():null;this.attribute("cx").hasValue()||(this.attribute("cx",!0).value="50%"),this.attribute("cy").hasValue()||(this.attribute("cy",!0).value="50%"),this.attribute("r").hasValue()||(this.attribute("r",!0).value="50%");var s=i?n.x()+n.width()*this.attribute("cx").numValue():this.attribute("cx").toPixels("x"),l=i?n.y()+n.height()*this.attribute("cy").numValue():this.attribute("cy").toPixels("y"),o=s,u=l;this.attribute("fx").hasValue()&&(o=i?n.x()+n.width()*this.attribute("fx").numValue():this.attribute("fx").toPixels("x")),this.attribute("fy").hasValue()&&(u=i?n.y()+n.height()*this.attribute("fy").numValue():this.attribute("fy").toPixels("y"));var h=i?(n.width()+n.height())/2*this.attribute("r").numValue():this.attribute("r").toPixels();return t.createRadialGradient(o,u,0,s,l,h)}}]),_class20}(e.Element.GradientBase),e.Element.stop=function(t){_inherits(_class21,t);var e=_createSuper(_class21);function _class21(t){var i;_classCallCheck(this,_class21),(i=e.call(this,t)).offset=i.attribute("offset").numValue(),i.offset<0&&(i.offset=0),i.offset>1&&(i.offset=1);var n=i.style("stop-color");return i.style("stop-opacity").hasValue()&&(n=n.addOpacity(i.style("stop-opacity"))),i.color=n.value,i}return _class21}(e.Element.ElementBase),e.Element.AnimateBase=function(t){_inherits(_class22,t);var i=_createSuper(_class22);function _class22(t){var n;return _classCallCheck(this,_class22),n=i.call(this,t),e.Animations.push(_assertThisInitialized(n)),n.duration=0,n.begin=n.attribute("begin").toMilliseconds(),n.maxDuration=n.begin+n.attribute("dur").toMilliseconds(),n.initialValue=null,n.initialUnits="",n.removed=!1,n.from=n.attribute("from"),n.to=n.attribute("to"),n.values=n.attribute("values"),n.values.hasValue()&&(n.values.value=n.values.value.split(";")),n}return _createClass(_class22,[{key:"getProperty",value:function getProperty(){var t=this.attribute("attributeType").value,e=this.attribute("attributeName").value;return"CSS"===t?this.parent.style(e,!0):this.parent.attribute(e,!0)}},{key:"calcValue",value:function calcValue(){return""}},{key:"update",value:function update(t){if(h(this.initialValue)&&(this.initialValue=this.getProperty().value,this.initialUnits=this.getProperty().getUnits()),this.duration>this.maxDuration){if("indefinite"===this.attribute("repeatCount").value||"indefinite"===this.attribute("repeatDur").value)this.duration=0;else if("freeze"!==this.attribute("fill").valueOrDefault("remove")||this.frozen){if("remove"===this.attribute("fill").valueOrDefault("remove")&&!this.removed)return this.removed=!0,this.getProperty().value=this.parent.animationFrozen?this.parent.animationFrozenValue:this.initialValue,!0}else this.frozen=!0,this.parent.animationFrozen=!0,this.parent.animationFrozenValue=this.getProperty().value;return!1}this.duration+=t;var e=!1;if(this.begin<this.duration){var i=this.calcValue();if(this.attribute("type").hasValue())i=this.attribute("type").value+"("+i+")";this.getProperty().value=i,e=!0}return e}},{key:"progress",value:function progress(){var t={progress:(this.duration-this.begin)/(this.maxDuration-this.begin)};if(this.values.hasValue()){var i=t.progress*(this.values.value.length-1),n=Math.floor(i),s=Math.ceil(i);t.from=new e.Property("from",Number.parseFloat(this.values.value[n])),t.to=new e.Property("to",Number.parseFloat(this.values.value[s])),t.progress=(i-n)/(s-n)}else t.from=this.from,t.to=this.to;return t}}]),_class22}(e.Element.ElementBase),e.Element.animate=function(t){_inherits(_class23,t);var e=_createSuper(_class23);function _class23(){return _classCallCheck(this,_class23),e.apply(this,arguments)}return _createClass(_class23,[{key:"calcValue",value:function calcValue(){var t=this.progress();return t.from.numValue()+(t.to.numValue()-t.from.numValue())*t.progress+this.initialUnits}}]),_class23}(e.Element.AnimateBase),e.Element.animateColor=function(t){_inherits(_class24,t);var e=_createSuper(_class24);function _class24(){return _classCallCheck(this,_class24),e.apply(this,arguments)}return _createClass(_class24,[{key:"calcValue",value:function calcValue(){var t=this.progress(),e=new s(t.from.value),i=new s(t.to.value);if(e.ok&&i.ok){var n=e.r+(i.r-e.r)*t.progress,l=e.g+(i.g-e.g)*t.progress,o=e.b+(i.b-e.b)*t.progress;return"rgb("+Number.parseInt(n)+","+Number.parseInt(l)+","+Number.parseInt(o)+")"}return this.attribute("from").value}}]),_class24}(e.Element.AnimateBase),e.Element.animateTransform=function(t){_inherits(_class25,t);var i=_createSuper(_class25);function _class25(){return _classCallCheck(this,_class25),i.apply(this,arguments)}return _createClass(_class25,[{key:"calcValue",value:function calcValue(){var t=this.progress(),i=e.ToNumberArray(t.from.value),n=e.ToNumberArray(t.to.value),s="";return i.forEach((function(e,i){s+=e+(n[i]-e)*t.progress+" "})),s}}]),_class25}(e.Element.animate),e.Element.font=function(t){_inherits(_class26,t);var i=_createSuper(_class26);function _class26(t){var n;return _classCallCheck(this,_class26),(n=i.call(this,t)).horizAdvX=n.attribute("horiz-adv-x").numValue(),n.isRTL=!1,n.isArabic=!1,n.fontFace=null,n.missingGlyph=null,n.glyphs=[],n.children.forEach((function(t){"font-face"===t.type?(n.fontFace=t,t.style("font-family").hasValue()&&(e.Definitions[t.style("font-family").value]=_assertThisInitialized(n))):"missing-glyph"===t.type?n.missingGlyph=t:"glyph"===t.type&&(""!==t.arabicForm?(n.isRTL=!0,n.isArabic=!0,void 0===n.glyphs[t.unicode]&&(n.glyphs[t.unicode]=[]),n.glyphs[t.unicode][t.arabicForm]=t):n.glyphs[t.unicode]=t)})),n}return _class26}(e.Element.ElementBase),e.Element.fontface=function(t){_inherits(_class27,t);var e=_createSuper(_class27);function _class27(t){var i;return _classCallCheck(this,_class27),(i=e.call(this,t)).ascent=i.attribute("ascent").value,i.descent=i.attribute("descent").value,i.unitsPerEm=i.attribute("units-per-em").numValue(),i}return _class27}(e.Element.ElementBase),e.Element.missingglyph=function(t){_inherits(_class28,t);var e=_createSuper(_class28);function _class28(t){var i;return _classCallCheck(this,_class28),(i=e.call(this,t)).horizAdvX=0,i}return _class28}(e.Element.path),e.Element.glyph=function(t){_inherits(_class29,t);var e=_createSuper(_class29);function _class29(t){var i;return _classCallCheck(this,_class29),(i=e.call(this,t)).horizAdvX=i.attribute("horiz-adv-x").numValue(),i.unicode=i.attribute("unicode").value,i.arabicForm=i.attribute("arabic-form").value,i}return _class29}(e.Element.path),e.Element.text=function(t){_inherits(_class30,t);var i=_createSuper(_class30);function _class30(t){return _classCallCheck(this,_class30),i.call(this,t,!0)}return _createClass(_class30,[{key:"setContext",value:function setContext(t){_get(_getPrototypeOf(_class30.prototype),"setContext",this).call(this,t);var e=this.style("dominant-baseline").toTextBaseline();h(e)&&(e=this.style("alignment-baseline").toTextBaseline()),h(e)||(t.textBaseline=e)}},{key:"getBoundingBox",value:function getBoundingBox(){var t=this.attribute("x").toPixels("x"),i=this.attribute("y").toPixels("y"),n=this.parent.style("font-size").numValueOrDefault(e.Font.Parse(e.ctx.font).fontSize);return new e.BoundingBox(t,i-n,t+Math.floor(2*n/3)*this.children[0].getText().length,i)}},{key:"renderChildren",value:function renderChildren(t){var e=this;this.x=this.attribute("x").toPixels("x"),this.y=this.attribute("y").toPixels("y"),this.x+=this.getAnchorDelta(t,this,0),this.children.forEach((function(i,n){e.renderChild(t,e,n)}))}},{key:"getAnchorDelta",value:function getAnchorDelta(t,e,i){var n=this.style("text-anchor").valueOrDefault("start");if("start"!==n){for(var s=0,l=i;l<e.children.length;l++){var o=e.children[l];if(l>i&&o.attribute("x").hasValue())break;s+=o.measureTextRecursive(t)}return-1*("end"===n?s:s/2)}return 0}},{key:"renderChild",value:function renderChild(t,e,i){var n=e.children[i];n.attribute("x").hasValue()?(n.x=n.attribute("x").toPixels("x")+this.getAnchorDelta(t,e,i),n.attribute("dx").hasValue()&&(n.x+=n.attribute("dx").toPixels("x"))):(this.attribute("dx").hasValue()&&(this.x+=this.attribute("dx").toPixels("x")),n.attribute("dx").hasValue()&&(this.x+=n.attribute("dx").toPixels("x")),n.x=this.x),this.x=n.x+n.measureText(t),n.attribute("y").hasValue()?(n.y=n.attribute("y").toPixels("y"),n.attribute("dy").hasValue()&&(n.y+=n.attribute("dy").toPixels("y"))):(this.attribute("dy").hasValue()&&(this.y+=this.attribute("dy").toPixels("y")),n.attribute("dy").hasValue()&&(this.y+=n.attribute("dy").toPixels("y")),n.y=this.y),this.y=n.y,n.render(t);for(var s=0;s<n.children.length;s++)this.renderChild(t,n,s)}}]),_class30}(e.Element.RenderedElementBase),e.Element.TextElementBase=function(t){_inherits(_class31,t);var i=_createSuper(_class31);function _class31(){return _classCallCheck(this,_class31),i.apply(this,arguments)}return _createClass(_class31,[{key:"getGlyph",value:function getGlyph(t,e,i){var n=e[i],s=null;if(t.isArabic){var l="isolated";(0===i||" "===e[i-1])&&i<e.length-2&&" "!==e[i+1]&&(l="terminal"),i>0&&" "!==e[i-1]&&i<e.length-2&&" "!==e[i+1]&&(l="medial"),i>0&&" "!==e[i-1]&&(i===e.length-1||" "===e[i+1])&&(l="initial"),void 0!==t.glyphs[n]&&(s=t.glyphs[n][l],h(s)&&"glyph"===t.glyphs[n].type&&(s=t.glyphs[n]))}else s=t.glyphs[n];return h(s)&&(s=t.missingGlyph),s}},{key:"renderChildren",value:function renderChildren(t){var i=this.parent.style("font-family").getDefinition();if(h(i))""!==t.fillStyle&&t.fillText(e.compressSpaces(this.getText()),this.x,this.y),""!==t.strokeStyle&&t.strokeText(e.compressSpaces(this.getText()),this.x,this.y);else{var n=this.parent.style("font-size").numValueOrDefault(e.Font.Parse(e.ctx.font).fontSize),s=this.parent.style("font-style").valueOrDefault(e.Font.Parse(e.ctx.font).fontStyle),l=this.getText();i.isRTL&&(l=l.split("").reverse().join(""));for(var o=e.ToNumberArray(this.parent.attribute("dx").value),u=0;u<l.length;u++){var d=this.getGlyph(i,l,u),p=n/i.fontFace.unitsPerEm;t.translate(this.x,this.y),t.scale(p,-p);var v=t.lineWidth;t.lineWidth=t.lineWidth*i.fontFace.unitsPerEm/n,"italic"===s&&t.transform(1,0,.4,1,0,0),d.render(t),"italic"===s&&t.transform(1,0,-.4,1,0,0),t.lineWidth=v,t.scale(1/p,-1/p),t.translate(-this.x,-this.y),this.x+=n*(d.horizAdvX||i.horizAdvX)/i.fontFace.unitsPerEm,void 0===o[u]||isNaN(o[u])||(this.x+=o[u])}}}},{key:"getText",value:function getText(){}},{key:"measureTextRecursive",value:function measureTextRecursive(t){var e=this.measureText(t);return this.children.forEach((function(i){e+=i.measureTextRecursive(t)})),e}},{key:"measureText",value:function measureText(t){var i=this.parent.style("font-family").getDefinition();if(!h(i)){var n=this.parent.style("font-size").numValueOrDefault(e.Font.Parse(e.ctx.font).fontSize),s=0,l=this.getText();i.isRTL&&(l=l.split("").reverse().join(""));for(var o=e.ToNumberArray(this.parent.attribute("dx").value),u=0;u<l.length;u++){s+=(this.getGlyph(i,l,u).horizAdvX||i.horizAdvX)*n/i.fontFace.unitsPerEm,void 0===o[u]||isNaN(o[u])||(s+=o[u])}return s}var d=e.compressSpaces(this.getText());if(!t.measureText)return 10*d.length;t.save(),this.setContext(t);var p=t.measureText(d).width;return t.restore(),p}}]),_class31}(e.Element.RenderedElementBase),e.Element.tspan=function(t){_inherits(_class32,t);var e=_createSuper(_class32);function _class32(t){var i;return _classCallCheck(this,_class32),(i=e.call(this,t,!0)).text=t.nodeValue||t.text||"",i}return _createClass(_class32,[{key:"getText",value:function getText(){return this.text}}]),_class32}(e.Element.TextElementBase),e.Element.tref=function(t){_inherits(_class33,t);var e=_createSuper(_class33);function _class33(){return _classCallCheck(this,_class33),e.apply(this,arguments)}return _createClass(_class33,[{key:"getText",value:function getText(){var t=this.getHrefAttribute().getDefinition();if(!h(t))return t.children[0].getText()}}]),_class33}(e.Element.TextElementBase),e.Element.a=function(t){_inherits(_class34,t);var i=_createSuper(_class34);function _class34(t){var e;return _classCallCheck(this,_class34),(e=i.call(this,t)).hasText=!0,_toConsumableArray(t.childNodes).forEach((function(t){3!==t.nodeType&&(e.hasText=!1)})),e.text=e.hasText?t.childNodes[0].nodeValue:"",e}return _createClass(_class34,[{key:"getText",value:function getText(){return this.text}},{key:"renderChildren",value:function renderChildren(t){if(this.hasText){_get(_getPrototypeOf(_class34.prototype),"renderChildren",this).call(this,t);var i=new e.Property("fontSize",e.Font.Parse(e.ctx.font).fontSize);e.Mouse.checkBoundingBox(this,new e.BoundingBox(this.x,this.y-i.toPixels("y"),this.x+this.measureText(t),this.y))}else{var n=new e.Element.g;n.children=this.children,n.parent=this,n.render(t)}}},{key:"onclick",value:function onclick(){window.open(this.getHrefAttribute().value)}},{key:"onmousemove",value:function onmousemove(){e.ctx.canvas.style.cursor="pointer"}}]),_class34}(e.Element.TextElementBase),e.Element.image=function(t){_inherits(_class35,t);var i=_createSuper(_class35);function _class35(t){var n;_classCallCheck(this,_class35);var s=(n=i.call(this,t)).getHrefAttribute().value;return""===s?_possibleConstructorReturn(n):(n._isSvg=s.match(/\.svg$/),e.Images.push(_assertThisInitialized(n)),n.loaded=!1,n._isSvg?e.ajax(s,!0).then((function(t){n.img=t,n.loaded=!0})).catch((function(t){n.erred=!0,console.error("Ajax error for canvg",t)})):(n.img=document.createElement("img"),!0===e.opts.useCORS&&(n.img.crossOrigin="Anonymous"),n.img.addEventListener("load",(function(){n.loaded=!0})),n.img.addEventListener("error",(function(){e.log('ERROR: image "'+s+'" not found'),n.loaded=!0})),n.img.src=s),n)}return _createClass(_class35,[{key:"renderChildren",value:function renderChildren(t){var i=this.attribute("x").toPixels("x"),n=this.attribute("y").toPixels("y"),s=this.attribute("width").toPixels("x"),l=this.attribute("height").toPixels("y");0!==s&&0!==l&&(t.save(),this._isSvg?t.drawSvg(this.img,i,n,s,l):(t.translate(i,n),e.AspectRatio(t,this.attribute("preserveAspectRatio").value,s,this.img.width,l,this.img.height,0,0),t.drawImage(this.img,0,0)),t.restore())}},{key:"getBoundingBox",value:function getBoundingBox(){var t=this.attribute("x").toPixels("x"),i=this.attribute("y").toPixels("y"),n=this.attribute("width").toPixels("x"),s=this.attribute("height").toPixels("y");return new e.BoundingBox(t,i,t+n,i+s)}}]),_class35}(e.Element.RenderedElementBase),e.Element.g=function(t){_inherits(_class36,t);var i=_createSuper(_class36);function _class36(){return _classCallCheck(this,_class36),i.apply(this,arguments)}return _createClass(_class36,[{key:"getBoundingBox",value:function getBoundingBox(){var t=new e.BoundingBox;return this.children.forEach((function(e){t.addBoundingBox(e.getBoundingBox())})),t}}]),_class36}(e.Element.RenderedElementBase),e.Element.symbol=function(t){_inherits(_class37,t);var e=_createSuper(_class37);function _class37(){return _classCallCheck(this,_class37),e.apply(this,arguments)}return _createClass(_class37,[{key:"render",value:function render(t){}}]),_class37}(e.Element.RenderedElementBase),e.Element.style=function(t){_inherits(_class38,t);var i=_createSuper(_class38);function _class38(t){var n;_classCallCheck(this,_class38),n=i.call(this,t);var s="";return _toConsumableArray(t.childNodes).forEach((function(t){var e=t.nodeValue;s+=e})),s=s.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^\s*\/\/.*)/gm,""),(s=e.compressSpaces(s)).split("}").forEach((function(t){if(""!==e.trim(t)){var i=_slicedToArray(t.split("{"),2),n=i[0],s=i[1];n=n.split(","),s=s.split(";"),n.forEach((function(t){if(""!==(t=e.trim(t))){var i={};if(s.forEach((function(t){var n=t.indexOf(":"),s=t.substr(0,n),l=t.substr(n+1,t.length-n);h(s)||h(l)||(i[e.trim(s)]=new e.Property(e.trim(s),e.trim(l)))})),e.Styles[t]=i,"@font-face"===t){var n=i["font-family"].value.replace(/"/g,"");i.src.value.split(",").forEach((function(t){if(t.includes('format("svg")')){var i=t.indexOf("url"),s=t.indexOf(")",i),l=t.substr(i+5,s-i-6);_toConsumableArray(e.parseXml(e.ajax(l)).getElementsByTagName("font")).forEach((function(t){t=e.CreateElement(t),e.Definitions[n]=t}))}}))}}}))}})),n}return _class38}(e.Element.ElementBase),e.Element.use=function(t){_inherits(_class39,t);var i=_createSuper(_class39);function _class39(t){var e;return _classCallCheck(this,_class39),(e=i.call(this,t))._el=e.getHrefAttribute().getDefinition(),e}return _createClass(_class39,[{key:"setContext",value:function setContext(t){_get(_getPrototypeOf(_class39.prototype),"setContext",this).call(this,t),this.attribute("x").hasValue()&&t.translate(this.attribute("x").toPixels("x"),0),this.attribute("y").hasValue()&&t.translate(0,this.attribute("y").toPixels("y"))}},{key:"path",value:function path(t){var e=this._el;h(e)||e.path(t)}},{key:"getBoundingBox",value:function getBoundingBox(){var t=this._el;if(!h(t))return t.getBoundingBox()}},{key:"renderChildren",value:function renderChildren(t){var i=this._el;if(!h(i)){var n=i;"symbol"===i.type&&((n=new e.Element.svg).type="svg",n.attributes.viewBox=new e.Property("viewBox",i.attribute("viewBox").value),n.attributes.preserveAspectRatio=new e.Property("preserveAspectRatio",i.attribute("preserveAspectRatio").value),n.attributes.overflow=new e.Property("overflow",i.attribute("overflow").value),n.children=i.children),"svg"===n.type&&(this.attribute("width").hasValue()&&(n.attributes.width=new e.Property("width",this.attribute("width").value)),this.attribute("height").hasValue()&&(n.attributes.height=new e.Property("height",this.attribute("height").value)));var s=n.parent;n.parent=null,n.render(t),n.parent=s}}}]),_class39}(e.Element.RenderedElementBase),e.Element.mask=function(t){_inherits(_class40,t);var i=_createSuper(_class40);function _class40(){return _classCallCheck(this,_class40),i.apply(this,arguments)}return _createClass(_class40,[{key:"apply",value:function apply(t,i){var n=this.attribute("x").toPixels("x"),s=this.attribute("y").toPixels("y"),l=this.attribute("width").toPixels("x"),o=this.attribute("height").toPixels("y");if(0===l&&0===o){var u=new e.BoundingBox;this.children.forEach((function(t){u.addBoundingBox(t.getBoundingBox())})),n=Math.floor(u.x1),s=Math.floor(u.y1),l=Math.floor(u.width()),o=Math.floor(u.height())}var h=i.attribute("mask").value;i.attribute("mask").value="";var d=document.createElement("canvas");d.width=n+l,d.height=s+o;var p=d.getContext("2d");this.renderChildren(p);var v=document.createElement("canvas");v.width=n+l,v.height=s+o;var g=v.getContext("2d");i.render(g),g.globalCompositeOperation="destination-in",g.fillStyle=p.createPattern(d,"no-repeat"),g.fillRect(0,0,n+l,s+o),t.fillStyle=g.createPattern(v,"no-repeat"),t.fillRect(0,0,n+l,s+o),i.attribute("mask").value=h}},{key:"render",value:function render(t){}}]),_class40}(e.Element.ElementBase),e.Element.clipPath=function(t){_inherits(_class41,t);var i=_createSuper(_class41);function _class41(){return _classCallCheck(this,_class41),i.apply(this,arguments)}return _createClass(_class41,[{key:"apply",value:function apply(t){this.children.forEach((function(i){if(void 0!==i.path){var n=null;i.attribute("transform").hasValue()&&(n=new e.Transform(i.attribute("transform").value)).apply(t),i.path(t),t.clip(),n&&n.unapply(t)}}))}},{key:"render",value:function render(t){}}]),_class41}(e.Element.ElementBase),e.Element.filter=function(t){_inherits(_class42,t);var e=_createSuper(_class42);function _class42(){return _classCallCheck(this,_class42),e.apply(this,arguments)}return _createClass(_class42,[{key:"apply",value:function apply(t,e){var i=e.getBoundingBox(),n=Math.floor(i.x1),s=Math.floor(i.y1),l=Math.floor(i.width()),o=Math.floor(i.height()),u=e.style("filter").value;e.style("filter").value="";var h=0,d=0;this.children.forEach((function(t){var e=t.extraFilterDistance||0;h=Math.max(h,e),d=Math.max(d,e)}));var p=document.createElement("canvas");p.width=l+2*h,p.height=o+2*d;var v=p.getContext("2d");v.translate(-n+h,-s+d),e.render(v),this.children.forEach((function(t){t.apply(v,0,0,l+2*h,o+2*d)})),t.drawImage(p,0,0,l+2*h,o+2*d,n-h,s-d,l+2*h,o+2*d),e.style("filter",!0).value=u}},{key:"render",value:function render(t){}}]),_class42}(e.Element.ElementBase),e.Element.feMorphology=function(t){_inherits(_class43,t);var e=_createSuper(_class43);function _class43(){return _classCallCheck(this,_class43),e.apply(this,arguments)}return _createClass(_class43,[{key:"apply",value:function apply(t,e,i,n,s){}}]),_class43}(e.Element.ElementBase),e.Element.feComposite=function(t){_inherits(_class44,t);var e=_createSuper(_class44);function _class44(){return _classCallCheck(this,_class44),e.apply(this,arguments)}return _createClass(_class44,[{key:"apply",value:function apply(t,e,i,n,s){}}]),_class44}(e.Element.ElementBase),e.Element.feColorMatrix=function(t){_inherits(_class45,t);var i=_createSuper(_class45);function _class45(t){var n;_classCallCheck(this,_class45),n=i.call(this,t);var s=e.ToNumberArray(n.attribute("values").value);switch(n.attribute("type").valueOrDefault("matrix")){case"saturate":var l=s[0];s=[.213+.787*l,.715-.715*l,.072-.072*l,0,0,.213-.213*l,.715+.285*l,.072-.072*l,0,0,.213-.213*l,.715-.715*l,.072+.928*l,0,0,0,0,0,1,0,0,0,0,0,1];break;case"hueRotate":var o=s[0]*Math.PI/180,u=function c(t,e,i){return t+Math.cos(o)*e+Math.sin(o)*i};s=[u(.213,.787,-.213),u(.715,-.715,-.715),u(.072,-.072,.928),0,0,u(.213,-.213,.143),u(.715,.285,.14),u(.072,-.072,-.283),0,0,u(.213,-.213,-.787),u(.715,-.715,.715),u(.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break;case"luminanceToAlpha":s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.2125,.7154,.0721,0,0,0,0,0,0,1]}return n.matrix=s,n._m=function(t,e){var i=s[t];return i*(i<0?e-255:e)},n}return _createClass(_class45,[{key:"apply",value:function apply(t,e,i,n,s){for(var l=this._m,o=t.getImageData(0,0,n,s),u=0;u<s;u++)for(var h=0;h<n;h++){var d=imGet(o.data,h,u,n,s,0),p=imGet(o.data,h,u,n,s,1),v=imGet(o.data,h,u,n,s,2),g=imGet(o.data,h,u,n,s,3);imSet(o.data,h,u,n,s,0,l(0,d)+l(1,p)+l(2,v)+l(3,g)+l(4,1)),imSet(o.data,h,u,n,s,1,l(5,d)+l(6,p)+l(7,v)+l(8,g)+l(9,1)),imSet(o.data,h,u,n,s,2,l(10,d)+l(11,p)+l(12,v)+l(13,g)+l(14,1)),imSet(o.data,h,u,n,s,3,l(15,d)+l(16,p)+l(17,v)+l(18,g)+l(19,1))}t.clearRect(0,0,n,s),t.putImageData(o,0,0)}}]),_class45}(e.Element.ElementBase),e.Element.feGaussianBlur=function(t){_inherits(_class46,t);var i=_createSuper(_class46);function _class46(t){var e;return _classCallCheck(this,_class46),(e=i.call(this,t)).blurRadius=Math.floor(e.attribute("stdDeviation").numValue()),e.extraFilterDistance=e.blurRadius,e}return _createClass(_class46,[{key:"apply",value:function apply(t,i,n,s,l){t.canvas.id=e.UniqueId(),t.canvas.style.display="none",document.body.append(t.canvas),processCanvasRGBA(t.canvas,i,n,s,l,this.blurRadius),t.canvas.remove()}}]),_class46}(e.Element.ElementBase),e.Element.title=function(t){_inherits(_class47,t);var e=_createSuper(_class47);function _class47(t){return _classCallCheck(this,_class47),e.call(this)}return _class47}(e.Element.ElementBase),e.Element.desc=function(t){_inherits(_class48,t);var e=_createSuper(_class48);function _class48(t){return _classCallCheck(this,_class48),e.call(this)}return _class48}(e.Element.ElementBase),e.Element.MISSING=function(t){_inherits(_class49,t);var i=_createSuper(_class49);function _class49(t){var n;return _classCallCheck(this,_class49),n=i.call(this),e.log("ERROR: Element '"+t.nodeName+"' not yet implemented."),n}return _class49}(e.Element.ElementBase),e.CreateElement=function(t){var i,n=t.nodeName.replace(/^[^:]+:/,"").replace(/-/g,"");return(i=void 0!==e.Element[n]?new e.Element[n](t):new e.Element.MISSING(t)).type=t.nodeName,i},e.load=function(){var t=_asyncToGenerator(regeneratorRuntime.mark((function _callee(t,i){var n;return regeneratorRuntime.wrap((function _callee$(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,e.ajax(i,!0);case 2:return n=s.sent,s.abrupt("return",e.loadXml(t,n));case 4:case"end":return s.stop()}}),_callee)})));return function(e,i){return t.apply(this,arguments)}}(),e.loadXml=function(t,i){return e.loadXmlDoc(t,e.parseXml(i))},e.loadXmlDoc=function(t,i){var n;e.init(t);var s=function mapXY(e){for(var i=t.canvas;i;)e.x-=i.offsetLeft,e.y-=i.offsetTop,i=i.offsetParent;return window.scrollX&&(e.x+=window.scrollX),window.scrollY&&(e.y+=window.scrollY),e};!0!==e.opts.ignoreMouse&&(t.canvas.addEventListener("click",(function(t){var i=h(t)?[event.clientX,event.clientY]:[t.clientX,t.clientY],n=s(_construct(e.Point,i)),l=n.x,o=n.y;e.Mouse.onclick(l,o)})),t.canvas.addEventListener("mousemove",(function(t){var i=h(t)?[event.clientX,event.clientY]:[t.clientX,t.clientY],n=s(_construct(e.Point,i)),l=n.x,o=n.y;e.Mouse.onmousemove(l,o)})));var l=e.CreateElement(i.documentElement);l.root=!0;var o=!0,u=function draw(n){e.ViewPort.Clear(),t.canvas.parentNode&&e.ViewPort.SetCurrent(t.canvas.parentNode.clientWidth,t.canvas.parentNode.clientHeight),!0!==e.opts.ignoreDimensions&&(l.style("width").hasValue()&&(t.canvas.width=l.style("width").toPixels("x"),t.canvas.style.width=t.canvas.width+"px"),l.style("height").hasValue()&&(t.canvas.height=l.style("height").toPixels("y"),t.canvas.style.height=t.canvas.height+"px"));var s=t.canvas.clientWidth||t.canvas.width,u=t.canvas.clientHeight||t.canvas.height;if(!0===e.opts.ignoreDimensions&&l.style("width").hasValue()&&l.style("height").hasValue()&&(s=l.style("width").toPixels("x"),u=l.style("height").toPixels("y")),e.ViewPort.SetCurrent(s,u),h(e.opts.offsetX)||(l.attribute("x",!0).value=e.opts.offsetX),h(e.opts.offsetY)||(l.attribute("y",!0).value=e.opts.offsetY),!h(e.opts.scaleWidth)||!h(e.opts.scaleHeight)){var d=e.ToNumberArray(l.attribute("viewBox").value),p=null,v=null;h(e.opts.scaleWidth)||(l.attribute("width").hasValue()?p=l.attribute("width").toPixels("x")/e.opts.scaleWidth:isNaN(d[2])||(p=d[2]/e.opts.scaleWidth)),h(e.opts.scaleHeight)||(l.attribute("height").hasValue()?v=l.attribute("height").toPixels("y")/e.opts.scaleHeight:isNaN(d[3])||(v=d[3]/e.opts.scaleHeight)),h(p)&&(p=v),h(v)&&(v=p),l.attribute("width",!0).value=e.opts.scaleWidth,l.attribute("height",!0).value=e.opts.scaleHeight,l.attribute("viewBox",!0).value="0 0 "+s*p+" "+u*v,l.attribute("preserveAspectRatio",!0).value="none"}!0!==e.opts.ignoreClear&&t.clearRect(0,0,s,u),l.render(t),o&&(o=!1,n(i))},d=!0;return e.intervalID=setInterval((function(){var t=!1;d&&e.ImagesLoaded()&&(d=!1,t=!0),!0!==e.opts.ignoreMouse&&(t=t||e.Mouse.hasEvents()),!0!==e.opts.ignoreAnimation&&e.Animations.forEach((function(i){var n=i.update(1e3/e.FRAMERATE);t=t||n})),"function"==typeof e.opts.forceRedraw&&!0===e.opts.forceRedraw()&&(t=!0),t&&(u(n),e.Mouse.runEvents())}),1e3/e.FRAMERATE),new Promise((function(t,i){if(e.ImagesLoaded())return d=!1,void u(t);n=t}))},e.stop=function(){e.intervalID&&clearInterval(e.intervalID)},e.Mouse={events:[],hasEvents:function hasEvents(){return 0!==this.events.length},onclick:function onclick(t,e){this.events.push({type:"onclick",x:t,y:e,run:function run(t){t.onclick&&t.onclick()}})},onmousemove:function onmousemove(t,e){this.events.push({type:"onmousemove",x:t,y:e,run:function run(t){t.onmousemove&&t.onmousemove()}})},eventElements:[],checkPath:function checkPath(t,e){var i=this;this.events.forEach((function(n,s){var l=n.x,o=n.y;e.isPointInPath&&e.isPointInPath(l,o)&&(i.eventElements[s]=t)}))},checkBoundingBox:function checkBoundingBox(t,e){var i=this;this.events.forEach((function(n,s){var l=n.x,o=n.y;e.isPointInBox(l,o)&&(i.eventElements[s]=t)}))},runEvents:function runEvents(){var t=this;e.ctx.canvas.style.cursor="",this.events.forEach((function(e,i){for(var n=t.eventElements[i];n;)e.run(n),n=n.parent})),this.events=[],this.eventElements=[]}},e}(i||{});1===t.childNodes.length&&"OBJECT"===t.childNodes[0].nodeName||(t.svg=l);var o=t.getContext("2d");return void 0!==e.documentElement?l.loadXmlDoc(o,e):"<"===e.substr(0,1)?l.loadXml(o,e):l.load(o,e)};"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.drawSvg=function(t,e,i,n,s){d(this.canvas,t,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:e,offsetY:i,scaleWidth:n,scaleHeight:s})});t("default",{name:"server_moinsave",init:function init(t){var i=this;return _asyncToGenerator(regeneratorRuntime.mark((function _callee2(){var n,s,l,o,u,h;return regeneratorRuntime.wrap((function _callee2$(p){for(;;)switch(p.prev=p.next){case 0:return n=t.$,s=t.encode64,t.importLocale,l=i,p.next=4,e.import("./locale/".concat(l.curPrefs.lang,".js"));case 4:o=p.sent,u=o.default,h=l.canvas,"/+modify",n('<iframe name="output_frame" title="'.concat(u.hiddenframe,'"\n style="width: 0; height: 0;" src="data:text/html;base64,PGh0bWw+PC9odG1sPg=="/>')).appendTo("body"),l.setCustomHandlers({save:function save(t,e){return _asyncToGenerator(regeneratorRuntime.mark((function _callee(){var t,i,l,o,p,v,g,_;return regeneratorRuntime.wrap((function _callee$(b){for(;;)switch(b.prev=b.next){case 0:return t='<?xml version="1.0"?>\n'+e,i=new URL(location),l=i.pathname,o=l.replace(/\/+get\//,""),p=s(t),n("#export_canvas").length||n("<canvas>",{id:"export_canvas"}).hide().appendTo("body"),(v=n("#export_canvas")[0]).width=h.contentW,v.height=h.contentH,b.next=10,d(v,t);case 10:g=v.toDataURL("image/png"),_=s(g),n("<form>").attr({method:"post",action:"/+modify/"+o,target:"output_frame"}).append('\n <input type="hidden" name="png_data" value="'.concat(_,'">\n <input type="hidden" name="filepath" value="').concat(p,'">\n <input type="hidden" name="filename" value="drawing.svg">\n <input type="hidden" name="contenttype" value="application/x-svgdraw">\n ')).appendTo("body").submit().remove(),n.alert(u.saved),top.window.location="/"+o;case 15:case"end":return b.stop()}}),_callee)})))()}});case 10:case"end":return p.stop()}}),_callee2)})))()}})}}}));