11 lines
81 KiB
JavaScript
11 lines
81 KiB
JavaScript
function _AwaitValue(t){this.wrapped=t}function _AsyncGenerator(t){var e,n;function resume(e,n){try{var i=t[e](n),s=i.value,l=s instanceof _AwaitValue;Promise.resolve(l?s.wrapped:s).then((function(t){l?resume("return"===e?"return":"next",t):settle(i.done?"return":"normal",t)}),(function(t){resume("throw",t)}))}catch(t){settle("throw",t)}}function settle(t,i){switch(t){case"return":e.resolve({value:i,done:!0});break;case"throw":e.reject(i);break;default:e.resolve({value:i,done:!1})}(e=e.next)?resume(e.key,e.arg):n=null}this._invoke=function send(t,i){return new Promise((function(s,l){var o={key:t,arg:i,resolve:s,reject:l,next:null};n?n=n.next=o:(e=n=o,resume(t,i))}))},"function"!=typeof t.return&&(this.return=void 0)}function asyncGeneratorStep(t,e,n,i,s,l,o){try{var u=t[l](o),h=u.value}catch(t){return void n(t)}u.done?e(h):Promise.resolve(h).then(i,s)}function _asyncToGenerator(t){return function(){var e=this,n=arguments;return new Promise((function(i,s){var l=t.apply(e,n);function _next(t){asyncGeneratorStep(l,i,s,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(l,i,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 n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function _createClass(t,e,n){return e&&_defineProperties(t.prototype,e),n&&_defineProperties(t,n),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,n){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function _construct(t,e,n){var i=[null];i.push.apply(i,e);var s=new(Function.bind.apply(t,i));return n&&_setPrototypeOf(s,n.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 n,i=_getPrototypeOf(t);if(e){var s=_getPrototypeOf(this).constructor;n=Reflect.construct(i,arguments,s)}else n=i.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _superPropBase(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=_getPrototypeOf(t)););return t}function _get(t,e,n){return(_get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function _get(t,e,n){var i=_superPropBase(t,e);if(i){var s=Object.getOwnPropertyDescriptor(i,e);return s.get?s.get.call(n):s.value}})(t,e,n||t)}function _slicedToArray(t,e){return _arrayWithHoles(t)||function _iterableToArrayLimit(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],i=!0,s=!1,l=void 0;try{for(var o,u=t[Symbol.iterator]();!(i=(o=u.next()).done)&&(n.push(o.value),!e||n.length!==e);i=!0);}catch(t){s=!0,l=t}finally{try{i||null==u.return||u.return()}finally{if(s)throw l}}return n}(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||_iterableToArray(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 _arrayWithHoles(t){if(Array.isArray(t))return t}function _iterableToArray(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}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.")}"function"==typeof Symbol&&Symbol.asyncIterator&&(_AsyncGenerator.prototype[Symbol.asyncIterator]=function(){return this}),_AsyncGenerator.prototype.next=function(t){return this._invoke("next",t)},_AsyncGenerator.prototype.throw=function(t){return this._invoke("throw",t)},_AsyncGenerator.prototype.return=function(t){return this._invoke("return",t)};
|
|
/**
|
|
* For parsing color values.
|
|
* @module RGBColor
|
|
* @author Stoyan Stefanov <sstoo@gmail.com>
|
|
* @see https://www.phpied.com/rgb-color-parser-in-javascript/
|
|
* @license MIT
|
|
*/
|
|
var t={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"},e=[{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,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return n.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,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return n.map((function(t){return Number.parseInt(t,16)}))}},{re:/^(\w)(\w)(\w)$/,example:["#fb0","f0f"],process:function process(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return n.map((function(t){return Number.parseInt(t+t,16)}))}}],n=function(){function RGBColor(n){var i=this;_classCallCheck(this,RGBColor),this.ok=!1,"#"===n.charAt(0)&&(n=n.substr(1,6)),(n=(n=n.replace(/ /g,"")).toLowerCase())in t&&(n=t[n]),e.forEach((function(t){var e=t.re,s=t.process,l=e.exec(n);if(l){var o=_slicedToArray(s.apply(void 0,_toConsumableArray(l)),3),u=o[0],h=o[1],d=o[2];Object.assign(i,{r:u,g:h,b:d}),i.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),n=this.b.toString(16);return 1===t.length&&(t="0"+t),1===e.length&&(e="0"+e),1===n.length&&(n="0"+n),"#"+t+e+n}}],[{key:"getHelpXML",value:function getHelpXML(){var n=[].concat(_toConsumableArray(e.flatMap((function(t){return t.example}))),_toConsumableArray(Object.keys(t))),i=document.createElement("ul");return i.setAttribute("id","rgbcolor-examples"),i.append.apply(i,_toConsumableArray(n.map((function(t){try{var e=document.createElement("li"),n=new RGBColor(t),i=document.createElement("div");i.style.cssText="\n margin: 3px;\n border: 1px solid black;\n background: ".concat(n.toHex(),";\n color: ").concat(n.toHex(),";"),i.append("test");var s=" ".concat(t," -> ").concat(n.toRGB()," -> ").concat(n.toHex());return e.append(i,s),e}catch(t){return""}})))),i}}]),RGBColor}();function _typeof$1(t){return(_typeof$1="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 i=[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],s=[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 getImageDataFromCanvas(t,e,n,i,s){if("string"==typeof t&&(t=document.getElementById(t)),!t||"object"!==_typeof$1(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,n,i,s)}catch(t){throw new Error("unable to access image data: "+t)}}function processCanvasRGBA(t,e,n,o,u,h){if(!(isNaN(h)||h<1)){h|=0;var d=getImageDataFromCanvas(t,e,n,o,u);d=function processImageDataRGBA(t,e,n,o,u,h){var d,p,v,g,_,b,C,k,w,P,E,S,T,V,B,M,A,R,D,O,N,I,z,X,G,L=t.data,W=2*h+1,F=o-1,H=u-1,j=h+1,q=j*(j+1)/2,Y=new l,$=Y;for(v=1;v<W;v++)$=$.next=new l,v===j&&(G=$);$.next=Y;var U=null,Q=null;C=b=0;var Z=i[h],J=s[h];for(p=0;p<u;p++){for(M=A=R=D=k=w=P=E=0,S=j*(O=L[b]),T=j*(N=L[b+1]),V=j*(I=L[b+2]),B=j*(z=L[b+3]),k+=q*O,w+=q*N,P+=q*I,E+=q*z,$=Y,v=0;v<j;v++)$.r=O,$.g=N,$.b=I,$.a=z,$=$.next;for(v=1;v<j;v++)g=b+((F<v?F:v)<<2),k+=($.r=O=L[g])*(X=j-v),w+=($.g=N=L[g+1])*X,P+=($.b=I=L[g+2])*X,E+=($.a=z=L[g+3])*X,M+=O,A+=N,R+=I,D+=z,$=$.next;for(U=Y,Q=G,d=0;d<o;d++)L[b+3]=z=E*Z>>J,0!==z?(z=255/z,L[b]=(k*Z>>J)*z,L[b+1]=(w*Z>>J)*z,L[b+2]=(P*Z>>J)*z):L[b]=L[b+1]=L[b+2]=0,k-=S,w-=T,P-=V,E-=B,S-=U.r,T-=U.g,V-=U.b,B-=U.a,g=C+((g=d+h+1)<F?g:F)<<2,k+=M+=U.r=L[g],w+=A+=U.g=L[g+1],P+=R+=U.b=L[g+2],E+=D+=U.a=L[g+3],U=U.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+=o}for(d=0;d<o;d++){for(A=R=D=M=w=P=E=k=0,S=j*(O=L[b=d<<2]),T=j*(N=L[b+1]),V=j*(I=L[b+2]),B=j*(z=L[b+3]),k+=q*O,w+=q*N,P+=q*I,E+=q*z,$=Y,v=0;v<j;v++)$.r=O,$.g=N,$.b=I,$.a=z,$=$.next;for(_=o,v=1;v<=h;v++)b=_+d<<2,k+=($.r=O=L[b])*(X=j-v),w+=($.g=N=L[b+1])*X,P+=($.b=I=L[b+2])*X,E+=($.a=z=L[b+3])*X,M+=O,A+=N,R+=I,D+=z,$=$.next,v<H&&(_+=o);for(b=d,U=Y,Q=G,p=0;p<u;p++)L[(g=b<<2)+3]=z=E*Z>>J,z>0?(z=255/z,L[g]=(k*Z>>J)*z,L[g+1]=(w*Z>>J)*z,L[g+2]=(P*Z>>J)*z):L[g]=L[g+1]=L[g+2]=0,k-=S,w-=T,P-=V,E-=B,S-=U.r,T-=U.g,V-=U.b,B-=U.a,g=d+((g=p+j)<H?g:H)*o<<2,k+=M+=U.r=L[g],w+=A+=U.g=L[g+1],P+=R+=U.b=L[g+2],E+=D+=U.a=L[g+3],U=U.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+=o}return t}(d,0,0,o,u,h),t.getContext("2d").putImageData(d,e,n)}}var l=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},o=function isNullish(t){return null==t},u=function canvg(t,e,i){if(o(t)&&o(e)&&o(i)){var s=document.querySelectorAll("svg");return Promise.all(_toConsumableArray(s).map((function(t){var e=document.createElement("canvas");e.width=t.clientWidth,e.height=t.clientHeight,t.before(e),t.remove();var n=document.createElement("div");return n.append(t),canvg(e,n.innerHTML)})))}"string"==typeof t&&(t=document.getElementById(t)),o(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 n=0;e.UniqueId=function(){return"canvg"+ ++n},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 o(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 n=window.XMLHttpRequest?new XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");return e?new Promise((function(e,i){n.open("GET",t,!0).addEventListener("load",(function(){e(n.responseText)})),n.send(null)})):(n.open("GET",t,!1),n.send(null),n.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!o(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(!o(t.value)&&""!==t.value&&"string"==typeof this.value){var s=new n(this.value);s.ok&&(i="rgba("+s.r+", "+s.g+", "+s.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,n){var i=this.getDefinition();if(!o(i)&&i.createGradient)return i.createGradient(e.ctx,t,n);if(!o(i)&&i.createPattern){if(i.getHrefAttribute().hasValue()){var s=i.attribute("patternTransform");i=i.getHrefAttribute().getDefinition(),s.hasValue()&&(i.attribute("patternTransform",!0).value=s.value)}return i.createPattern(e.ctx,t)}return null}},{key:"getDPI",value:function getDPI(t){return 96}},{key:"getEM",value:function getEM(t){var n=12,i=new e.Property("fontSize",e.Font.Parse(e.ctx.font).fontSize);return i.hasValue()&&(n=i.toPixels(t)),n}},{key:"getUnits",value:function getUnits(){return String(this.value).replace(/[\d.-]/g,"")}},{key:"toPixels",value:function toPixels(t,n){if(!this.hasValue())return 0;var i=String(this.value);if(i.endsWith("em"))return this.numValue()*this.getEM(t);if(i.endsWith("ex"))return this.numValue()*this.getEM(t)/2;if(i.endsWith("px"))return this.numValue();if(i.endsWith("pt"))return this.numValue()*this.getDPI(t)*(1/72);if(i.endsWith("pc"))return 15*this.numValue();if(i.endsWith("cm"))return this.numValue()*this.getDPI(t)/2.54;if(i.endsWith("mm"))return this.numValue()*this.getDPI(t)/25.4;if(i.endsWith("in"))return this.numValue()*this.getDPI(t);if(i.endsWith("%"))return this.numValue()*e.ViewPort.ComputeSize(t);var s=this.numValue();return n&&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,n,i,s,l,u){var h=o(u)?this.CreateFont("","","","","",e.ctx.font):this.Parse(u);return{fontFamily:l||h.fontFamily,fontSize:s||h.fontSize,fontStyle:t||h.fontStyle,fontWeight:i||h.fontWeight,fontVariant:n||h.fontVariant,toString:function toString(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}},Parse:function Parse(t){var n=this,i={},s=e.trim(e.compressSpaces(t||"")).split(" "),l={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1},o="";return s.forEach((function(t){!l.fontStyle&&n.Styles.includes(t)?("inherit"!==t&&(i.fontStyle=t),l.fontStyle=!0):!l.fontVariant&&n.Variants.includes(t)?("inherit"!==t&&(i.fontVariant=t),l.fontStyle=l.fontVariant=!0):!l.fontWeight&&n.Weights.includes(t)?("inherit"!==t&&(i.fontWeight=t),l.fontStyle=l.fontVariant=l.fontWeight=!0):l.fontSize?"inherit"!==t&&(o+=t):("inherit"!==t&&(i.fontSize=t.split("/")[0]),l.fontStyle=l.fontVariant=l.fontWeight=l.fontSize=!0)})),""!==o&&(i.fontFamily=o),i}},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],n=this.x*t[1]+this.y*t[3]+t[5];this.x=e,this.y=n}}]),_class}(),e.CreatePoint=function(t){var n=e.ToNumberArray(t);return new e.Point(n[0],n[1])},e.CreatePath=function(t){for(var n=e.ToNumberArray(t),i=[],s=0;s<n.length;s+=2)i.push(new e.Point(n[s],n[s+1]));return i},e.BoundingBox=function(){function _class2(t,e,n,i){_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(n,i)}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){o(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)),o(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,n,i,s,l){var o=t+2/3*(n-t),u=e+2/3*(i-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,n,i,s,l,o,u){var h=this,d=[t,e],p=[n,i],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]},n=6*d[t]-12*p[t]+6*v[t],i=-3*d[t]+9*p[t]-9*v[t]+3*g[t],s=3*p[t]-3*d[t];if(0===i){if(0===n)return"continue";var l=-s/n;return l>0&&l<1&&(0===t&&h.addX(e(l)),1===t&&h.addY(e(l))),"continue"}var o=Math.pow(n,2)-4*s*i;if(o<0)return"continue";var u=(-n+Math.sqrt(o))/(2*i);u>0&&u<1&&(0===t&&h.addX(e(u)),1===t&&h.addY(e(u)));var _=(-n-Math.sqrt(o))/(2*i);_>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 n=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 n=e.ToNumberArray(t);this.angle=new e.Property("angle",n[0]),this.cx=n[1]||0,this.cy=n[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 n=_createSuper(SkewBase);function SkewBase(t){var i;return _classCallCheck(this,SkewBase),(i=n.call(this,t)).angle=new e.Property("angle",t),i}return SkewBase}(this.Type.matrix)}),Object.assign(this.Type,{skewX:function(t){_inherits(skewX,t);var e=_createSuper(skewX);function skewX(t){var n;return _classCallCheck(this,skewX),(n=e.call(this,t)).m=[1,0,Math.tan(n.angle.toRadians()),1,0,0],n}return skewX}(this.Type.SkewBase),skewY:function(t){_inherits(skewY,t);var e=_createSuper(skewY);function skewY(t){var n;return _classCallCheck(this,skewY),(n=e.call(this,t)).m=[1,Math.tan(n.angle.toRadians()),0,1,0,0],n}return skewY}(this.Type.SkewBase)});var i=e.trim(e.compressSpaces(t)).replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/);this.transforms=i.map((function(t){var i=e.trim(t.split("(")[0]),s=t.split("(")[1].replace(")",""),l=new n.Type[i](s);return l.type=i,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,n,i,s,l,u,h,d,p,v){var g=(n=(n=e.compressSpaces(n)).replace(/^defer\s/,"")).split(" ")[0]||"xMidYMid",_=n.split(" ")[1]||"meet",b=i/s,C=l/u,k=Math.min(b,C),w=Math.max(b,C);"meet"===_&&(s*=k,u*=k),"slice"===_&&(s*=w,u*=w),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"===_&&w===C)&&t.translate(i/2-s/2,0),g.endsWith("YMid")&&("meet"===_&&k===b||"slice"===_&&w===b)&&t.translate(0,l/2-u/2),g.startsWith("xMax")&&("meet"===_&&k===C||"slice"===_&&w===C)&&t.translate(i-s,0),g.endsWith("YMax")&&("meet"===_&&k===b||"slice"===_&&w===b)&&t.translate(0,l-u)),"none"===g?t.scale(b,C):"meet"===_?t.scale(k,k):"slice"===_&&t.scale(w,w),t.translate(o(h)?0:-h,o(d)?0:-d)},e.Element={},e.EmptyProperty=new e.Property("EMPTY",""),e.Element.ElementBase=function(){function _class4(t){var n=this;if(_classCallCheck(this,_class4),this.captureTextNodes=arguments[1],this.attributes={},this.styles={},this.children=[],!o(t)&&1===t.nodeType){_toConsumableArray(t.childNodes).forEach((function(t){if(1===t.nodeType&&n.addChild(t,!0),n.captureTextNodes&&(3===t.nodeType||4===t.nodeType)){var i=t.nodeValue||t.text||"";""!==e.trim(e.compressSpaces(i))&&n.addChild(new e.Element.tspan(t),!1)}})),_toConsumableArray(t.attributes).forEach((function(t){var i=t.nodeName,s=t.nodeValue;n.attributes[i]=new e.Property(i,s)}));var i=e.Styles[t.nodeName];if(o(i)||Object.entries(i).forEach((function(t){var e=_slicedToArray(t,2),i=e[0],s=e[1];n.styles[i]=s})),this.attribute("class").hasValue())e.compressSpaces(this.attribute("class").value).split(" ").forEach((function(s){i=e.Styles["."+s],o(i)||Object.entries(i).forEach((function(t){var e=_slicedToArray(t,2),i=e[0],s=e[1];n.styles[i]=s})),i=e.Styles[t.nodeName+"."+s],o(i)||Object.entries(i).forEach((function(t){var e=_slicedToArray(t,2),i=e[0],s=e[1];n.styles[i]=s}))}));if(this.attribute("id").hasValue()){var s=e.Styles["#"+this.attribute("id").value];o(s)||Object.entries(s).forEach((function(t){var e=_slicedToArray(t,2),i=e[0],s=e[1];n.styles[i]=s}))}if(this.attribute("style").hasValue())this.attribute("style").value.split(";").forEach((function(t){if(""!==e.trim(t)){var i=t.split(":"),s=i.name,l=i.value;s=e.trim(s),l=e.trim(l),n.styles[s]=new e.Property(s,l)}}));this.attribute("id").hasValue()&&o(e.Definitions[this.attribute("id").value])&&(e.Definitions[this.attribute("id").value]=this)}}return _createClass(_class4,[{key:"attribute",value:function attribute(t,n){var i=this.attributes[t];return o(i)?(!0===n&&(i=new e.Property(t,""),this.attributes[t]=i),i||e.EmptyProperty):i}},{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,n,i){var s=this.styles[t];if(!o(s))return s;var l=this.attribute(t);if(!o(l)&&l.hasValue())return this.styles[t]=l,l;if(!0!==i){var u=this.parent;if(!o(u)){var h=u.style(t);if(!o(h)&&h.hasValue())return h}}return!0===n&&(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();o(e)||e.apply(t,this)}else if(this.style("filter").hasValue()){var n=this.style("filter").getDefinition();o(n)||n.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,n){var i=n?e.CreateElement(t):t;i.parent=this,"title"!==i.type&&this.children.push(i)}}]),_class4}(),e.Element.RenderedElementBase=function(t){_inherits(_class5,t);var n=_createSuper(_class5);function _class5(){return _classCallCheck(this,_class5),n.apply(this,arguments)}return _createClass(_class5,[{key:"setContext",value:function setContext(t){if(this.style("fill").isUrlDefinition()){var n=this.style("fill").getFillStyleDefinition(this,this.style("fill-opacity"));o(n)||(t.fillStyle=n)}else if(this.style("fill").hasValue()){var i=this.style("fill");"currentColor"===i.value&&(i.value=this.style("color").value),t.fillStyle="none"===i.value?"rgba(0,0,0,0)":i.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"));o(l)||(t.strokeStyle=l)}else if(this.style("stroke").hasValue()){var u=this.style("stroke");"currentColor"===u.value&&(u.value=this.style("color").value),t.strokeStyle="none"===u.value?"rgba(0,0,0,0)":u.value}if(this.style("stroke-opacity").hasValue()){var h=new e.Property("stroke",t.strokeStyle);h=h.addOpacity(this.style("stroke-opacity")),t.strokeStyle=h.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();o(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 n=_createSuper(_class6);function _class6(){return _classCallCheck(this,_class6),n.apply(this,arguments)}return _createClass(_class6,[{key:"path",value:function path(t){return o(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 n=this.getMarkers();if(!o(n)){if(this.style("marker-start").isUrlDefinition())this.style("marker-start").getDefinition().render(t,n[0][0],n[0][1]);if(this.style("marker-mid").isUrlDefinition())for(var i=this.style("marker-mid").getDefinition(),s=1;s<n.length-1;s++)i.render(t,n[s][0],n[s][1]);if(this.style("marker-end").isUrlDefinition())this.style("marker-end").getDefinition().render(t,n[n.length-1][0],n[n.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 n=_createSuper(_class7);function _class7(){return _classCallCheck(this,_class7),n.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 n=e.ViewPort.width(),i=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){n=this.attribute("width").toPixels("x"),i=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(n,l),t.lineTo(n,i),t.lineTo(s,i),t.closePath(),t.clip())}if(e.ViewPort.SetCurrent(n,i),this.attribute("viewBox").hasValue()){var o=e.ToNumberArray(this.attribute("viewBox").value),u=o[0],h=o[1];n=o[2],i=o[3],e.AspectRatio(t,this.attribute("preserveAspectRatio").value,e.ViewPort.width(),n,e.ViewPort.height(),i,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 n=_createSuper(_class8);function _class8(){return _classCallCheck(this,_class8),n.apply(this,arguments)}return _createClass(_class8,[{key:"path",value:function path(t){var n=this.attribute("x").toPixels("x"),i=this.attribute("y").toPixels("y"),s=this.attribute("width").toPixels("x"),l=this.attribute("height").toPixels("y"),u=this.attribute("rx").toPixels("x"),h=this.attribute("ry").toPixels("y");return this.attribute("rx").hasValue()&&!this.attribute("ry").hasValue()&&(h=u),this.attribute("ry").hasValue()&&!this.attribute("rx").hasValue()&&(u=h),u=Math.min(u,s/2),h=Math.min(h,l/2),o(t)||(t.beginPath(),t.moveTo(n+u,i),t.lineTo(n+s-u,i),t.quadraticCurveTo(n+s,i,n+s,i+h),t.lineTo(n+s,i+l-h),t.quadraticCurveTo(n+s,i+l,n+s-u,i+l),t.lineTo(n+u,i+l),t.quadraticCurveTo(n,i+l,n,i+l-h),t.lineTo(n,i+h),t.quadraticCurveTo(n,i,n+u,i),t.closePath()),new e.BoundingBox(n,i,n+s,i+l)}}]),_class8}(e.Element.PathElementBase),e.Element.circle=function(t){_inherits(_class9,t);var n=_createSuper(_class9);function _class9(){return _classCallCheck(this,_class9),n.apply(this,arguments)}return _createClass(_class9,[{key:"path",value:function path(t){var n=this.attribute("cx").toPixels("x"),i=this.attribute("cy").toPixels("y"),s=this.attribute("r").toPixels();return o(t)||(t.beginPath(),t.arc(n,i,s,0,2*Math.PI,!0),t.closePath()),new e.BoundingBox(n-s,i-s,n+s,i+s)}}]),_class9}(e.Element.PathElementBase);var s=(Math.sqrt(2)-1)/3*4;function imGet(t,e,n,i,s,l){return t[n*i*4+4*e+l]}function imSet(t,e,n,i,s,l,o){t[n*i*4+4*e+l]=o}return e.Element.ellipse=function(t){_inherits(_class10,t);var n=_createSuper(_class10);function _class10(){return _classCallCheck(this,_class10),n.apply(this,arguments)}return _createClass(_class10,[{key:"path",value:function path(t){var n=this.attribute("rx").toPixels("x"),i=this.attribute("ry").toPixels("y"),l=this.attribute("cx").toPixels("x"),u=this.attribute("cy").toPixels("y");return o(t)||(t.beginPath(),t.moveTo(l,u-i),t.bezierCurveTo(l+s*n,u-i,l+n,u-s*i,l+n,u),t.bezierCurveTo(l+n,u+s*i,l+s*n,u+i,l,u+i),t.bezierCurveTo(l-s*n,u+i,l-n,u+s*i,l-n,u),t.bezierCurveTo(l-n,u-s*i,l-s*n,u-i,l,u-i),t.closePath()),new e.BoundingBox(l-n,u-i,l+n,u+i)}}]),_class10}(e.Element.PathElementBase),e.Element.line=function(t){_inherits(_class11,t);var n=_createSuper(_class11);function _class11(){return _classCallCheck(this,_class11),n.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 n=this.getPoints();return o(t)||(t.beginPath(),t.moveTo(n[0].x,n[0].y),t.lineTo(n[1].x,n[1].y)),new e.BoundingBox(n[0].x,n[0].y,n[1].x,n[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 n=_createSuper(_class12);function _class12(t){var i;return _classCallCheck(this,_class12),(i=n.call(this,t)).points=e.CreatePath(i.attribute("points").value),i}return _createClass(_class12,[{key:"path",value:function path(t){var n=this.points[0],i=n.x,s=n.y,l=new e.BoundingBox(i,s);o(t)||(t.beginPath(),t.moveTo(i,s));for(var u=1;u<this.points.length;u++){var h=this.points[u],d=h.x,p=h.y;l.addPoint(d,p),o(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 o(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 n=_createSuper(_class14);function _class14(t){var i;_classCallCheck(this,_class14);var s=(i=n.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),i.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()||!o(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,n){!o(n)&&this.angles.length>0&&o(this.angles[this.angles.length-1])&&(this.angles[this.angles.length-1]=this.points[this.points.length-1].angleTo(n)),this.addMarkerAngle(t,o(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(o(this.angles[t]))for(var e=t+1;e<this.angles.length;e++)if(!o(this.angles[e])){this.angles[t]=this.angles[e];break}return this.angles}},i}return _createClass(_class14,[{key:"path",value:function path(t){var n=this.PathParser;n.reset();var i=new e.BoundingBox;for(o(t)||t.beginPath();!n.isEnd();)switch(n.nextCommand(),n.command){case"M":case"m":var s=n.getAsCurrentPoint();for(n.addMarker(s),i.addPoint(s.x,s.y),o(t)||t.moveTo(s.x,s.y),n.start=n.current;!n.isCommandOrEnd();){var l=n.getAsCurrentPoint();n.addMarker(l,n.start),i.addPoint(l.x,l.y),o(t)||t.lineTo(l.x,l.y)}break;case"L":case"l":for(;!n.isCommandOrEnd();){var u=n.current,h=n.getAsCurrentPoint();n.addMarker(h,u),i.addPoint(h.x,h.y),o(t)||t.lineTo(h.x,h.y)}break;case"H":case"h":for(;!n.isCommandOrEnd();){var d=new e.Point((n.isRelativeCommand()?n.current.x:0)+n.getScalar(),n.current.y);n.addMarker(d,n.current),n.current=d,i.addPoint(n.current.x,n.current.y),o(t)||t.lineTo(n.current.x,n.current.y)}break;case"V":case"v":for(;!n.isCommandOrEnd();){var p=new e.Point(n.current.x,(n.isRelativeCommand()?n.current.y:0)+n.getScalar());n.addMarker(p,n.current),n.current=p,i.addPoint(n.current.x,n.current.y),o(t)||t.lineTo(n.current.x,n.current.y)}break;case"C":case"c":for(;!n.isCommandOrEnd();){var v=n.current,g=n.getPoint(),_=n.getAsControlPoint(),b=n.getAsCurrentPoint();n.addMarker(b,_,g),i.addBezierCurve(v.x,v.y,g.x,g.y,_.x,_.y,b.x,b.y),o(t)||t.bezierCurveTo(g.x,g.y,_.x,_.y,b.x,b.y)}break;case"S":case"s":for(;!n.isCommandOrEnd();){var C=n.current,k=n.getReflectedControlPoint(),w=n.getAsControlPoint(),P=n.getAsCurrentPoint();n.addMarker(P,w,k),i.addBezierCurve(C.x,C.y,k.x,k.y,w.x,w.y,P.x,P.y),o(t)||t.bezierCurveTo(k.x,k.y,w.x,w.y,P.x,P.y)}break;case"Q":case"q":for(;!n.isCommandOrEnd();){var E=n.current,S=n.getAsControlPoint(),T=n.getAsCurrentPoint();n.addMarker(T,S,S),i.addQuadraticCurve(E.x,E.y,S.x,S.y,T.x,T.y),o(t)||t.quadraticCurveTo(S.x,S.y,T.x,T.y)}break;case"T":case"t":for(;!n.isCommandOrEnd();){var V=n.current,B=n.getReflectedControlPoint();n.control=B;var M=n.getAsCurrentPoint();n.addMarker(M,B,B),i.addQuadraticCurve(V.x,V.y,B.x,B.y,M.x,M.y),o(t)||t.quadraticCurveTo(B.x,B.y,M.x,M.y)}break;case"A":case"a":for(var A=function _loop2(){var s=n.current,l=n.getScalar(),u=n.getScalar(),h=n.getScalar()*(Math.PI/180),d=n.getScalar(),p=n.getScalar(),v=n.getAsCurrentPoint(),g=new e.Point(Math.cos(h)*(s.x-v.x)/2+Math.sin(h)*(s.y-v.y)/2,-Math.sin(h)*(s.x-v.x)/2+Math.cos(h)*(s.y-v.y)/2),_=Math.pow(g.x,2)/Math.pow(l,2)+Math.pow(g.y,2)/Math.pow(u,2);_>1&&(l*=Math.sqrt(_),u*=Math.sqrt(_));var b=(d===p?-1:1)*Math.sqrt((Math.pow(l,2)*Math.pow(u,2)-Math.pow(l,2)*Math.pow(g.y,2)-Math.pow(u,2)*Math.pow(g.x,2))/(Math.pow(l,2)*Math.pow(g.y,2)+Math.pow(u,2)*Math.pow(g.x,2)));isNaN(b)&&(b=0);var C=new e.Point(b*l*g.y/u,b*-u*g.x/l),k=new e.Point((s.x+v.x)/2+Math.cos(h)*C.x-Math.sin(h)*C.y,(s.y+v.y)/2+Math.sin(h)*C.x+Math.cos(h)*C.y),w=function m(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))},P=function r(t,e){return(t[0]*e[0]+t[1]*e[1])/(w(t)*w(e))},E=function a(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(P(t,e))},S=E([1,0],[(g.x-C.x)/l,(g.y-C.y)/u]),T=[(g.x-C.x)/l,(g.y-C.y)/u],V=[(-g.x-C.x)/l,(-g.y-C.y)/u],B=E(T,V);P(T,V)<=-1&&(B=Math.PI),P(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+u*Math.sin(A));if(n.addMarkerAngle(R,A-M*Math.PI/2),n.addMarkerAngle(v,A-M*Math.PI),i.addPoint(v.x,v.y),!o(t)){var D=l>u?l:u,O=l>u?1:l/u,N=l>u?u/l:1;t.translate(k.x,k.y),t.rotate(h),t.scale(O,N),t.arc(0,0,D,S,S+B,1-p),t.scale(1/O,1/N),t.rotate(-h),t.translate(-k.x,-k.y)}};!n.isCommandOrEnd();)A();break;case"Z":case"z":o(t)||t.closePath(),n.current=n.start}return i}},{key:"getMarkers",value:function getMarkers(){var t=this.PathParser.getMarkerPoints(),e=this.PathParser.getMarkerAngles();return t.map((function(t,n){return[t,e[n]]}))}}]),_class14}(e.Element.PathElementBase),e.Element.pattern=function(t){_inherits(_class15,t);var n=_createSuper(_class15);function _class15(){return _classCallCheck(this,_class15),n.apply(this,arguments)}return _createClass(_class15,[{key:"createPattern",value:function createPattern(t,n){var i=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",i+"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=i,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 n=_createSuper(_class16);function _class16(){return _classCallCheck(this,_class16),n.apply(this,arguments)}return _createClass(_class16,[{key:"render",value:function render(t,n,i){t.translate(n.x,n.y),"auto"===this.attribute("orient").valueOrDefault("auto")&&t.rotate(i),"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(-i),t.translate(-n.x,-n.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 n=_createSuper(_class18);function _class18(t){var e;return _classCallCheck(this,_class18),(e=n.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,n,i){var s=this.getHrefAttribute().hasValue()?this.getHrefAttribute().getDefinition():this,l=function addParentOpacity(t){return i.hasValue()?new e.Property("color",t).addOpacity(i).value:t},u=this.getGradient(t,n);if(o(u))return l(s.stops[s.stops.length-1].color);if(s.stops.forEach((function(t){var e=t.offset,n=t.color;u.addColorStop(e,l(n))})),this.attribute("gradientTransform").hasValue()){var h=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",h.width),v.attributes.height=new e.Property("height",h.height),v.children=[p];var g=document.createElement("canvas");g.width=h.width,g.height=h.height;var _=g.getContext("2d");return _.fillStyle=u,v.render(_),_.createPattern(g,"no-repeat")}return u}}]),_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 n="objectBoundingBox"===this.gradientUnits&&e.getBoundingBox,i=n?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=n?i.x()+i.width()*this.attribute("x1").numValue():this.attribute("x1").toPixels("x"),l=n?i.y()+i.height()*this.attribute("y1").numValue():this.attribute("y1").toPixels("y"),o=n?i.x()+i.width()*this.attribute("x2").numValue():this.attribute("x2").toPixels("x"),u=n?i.y()+i.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 n="objectBoundingBox"===this.gradientUnits&&e.getBoundingBox,i=n?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=n?i.x()+i.width()*this.attribute("cx").numValue():this.attribute("cx").toPixels("x"),l=n?i.y()+i.height()*this.attribute("cy").numValue():this.attribute("cy").toPixels("y"),o=s,u=l;this.attribute("fx").hasValue()&&(o=n?i.x()+i.width()*this.attribute("fx").numValue():this.attribute("fx").toPixels("x")),this.attribute("fy").hasValue()&&(u=n?i.y()+i.height()*this.attribute("fy").numValue():this.attribute("fy").toPixels("y"));var h=n?(i.width()+i.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 n;_classCallCheck(this,_class21),(n=e.call(this,t)).offset=n.attribute("offset").numValue(),n.offset<0&&(n.offset=0),n.offset>1&&(n.offset=1);var i=n.style("stop-color");return n.style("stop-opacity").hasValue()&&(i=i.addOpacity(n.style("stop-opacity"))),n.color=i.value,n}return _class21}(e.Element.ElementBase),e.Element.AnimateBase=function(t){_inherits(_class22,t);var n=_createSuper(_class22);function _class22(t){var i;return _classCallCheck(this,_class22),i=n.call(this,t),e.Animations.push(_assertThisInitialized(i)),i.duration=0,i.begin=i.attribute("begin").toMilliseconds(),i.maxDuration=i.begin+i.attribute("dur").toMilliseconds(),i.initialValue=null,i.initialUnits="",i.removed=!1,i.from=i.attribute("from"),i.to=i.attribute("to"),i.values=i.attribute("values"),i.values.hasValue()&&(i.values.value=i.values.value.split(";")),i}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(o(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 n=this.calcValue();if(this.attribute("type").hasValue())n=this.attribute("type").value+"("+n+")";this.getProperty().value=n,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 n=t.progress*(this.values.value.length-1),i=Math.floor(n),s=Math.ceil(n);t.from=new e.Property("from",Number.parseFloat(this.values.value[i])),t.to=new e.Property("to",Number.parseFloat(this.values.value[s])),t.progress=(n-i)/(s-i)}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 n(t.from.value),i=new n(t.to.value);if(e.ok&&i.ok){var s=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(s)+","+Number.parseInt(l)+","+Number.parseInt(o)+")"}return this.attribute("from").value}}]),_class24}(e.Element.AnimateBase),e.Element.animateTransform=function(t){_inherits(_class25,t);var n=_createSuper(_class25);function _class25(){return _classCallCheck(this,_class25),n.apply(this,arguments)}return _createClass(_class25,[{key:"calcValue",value:function calcValue(){var t=this.progress(),n=e.ToNumberArray(t.from.value),i=e.ToNumberArray(t.to.value),s="";return n.forEach((function(e,n){s+=e+(i[n]-e)*t.progress+" "})),s}}]),_class25}(e.Element.animate),e.Element.font=function(t){_inherits(_class26,t);var n=_createSuper(_class26);function _class26(t){var i;return _classCallCheck(this,_class26),(i=n.call(this,t)).horizAdvX=i.attribute("horiz-adv-x").numValue(),i.isRTL=!1,i.isArabic=!1,i.fontFace=null,i.missingGlyph=null,i.glyphs=[],i.children.forEach((function(t){"font-face"===t.type?(i.fontFace=t,t.style("font-family").hasValue()&&(e.Definitions[t.style("font-family").value]=_assertThisInitialized(i))):"missing-glyph"===t.type?i.missingGlyph=t:"glyph"===t.type&&(""!==t.arabicForm?(i.isRTL=!0,i.isArabic=!0,void 0===i.glyphs[t.unicode]&&(i.glyphs[t.unicode]=[]),i.glyphs[t.unicode][t.arabicForm]=t):i.glyphs[t.unicode]=t)})),i}return _class26}(e.Element.ElementBase),e.Element.fontface=function(t){_inherits(_class27,t);var e=_createSuper(_class27);function _class27(t){var n;return _classCallCheck(this,_class27),(n=e.call(this,t)).ascent=n.attribute("ascent").value,n.descent=n.attribute("descent").value,n.unitsPerEm=n.attribute("units-per-em").numValue(),n}return _class27}(e.Element.ElementBase),e.Element.missingglyph=function(t){_inherits(_class28,t);var e=_createSuper(_class28);function _class28(t){var n;return _classCallCheck(this,_class28),(n=e.call(this,t)).horizAdvX=0,n}return _class28}(e.Element.path),e.Element.glyph=function(t){_inherits(_class29,t);var e=_createSuper(_class29);function _class29(t){var n;return _classCallCheck(this,_class29),(n=e.call(this,t)).horizAdvX=n.attribute("horiz-adv-x").numValue(),n.unicode=n.attribute("unicode").value,n.arabicForm=n.attribute("arabic-form").value,n}return _class29}(e.Element.path),e.Element.text=function(t){_inherits(_class30,t);var n=_createSuper(_class30);function _class30(t){return _classCallCheck(this,_class30),n.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();o(e)&&(e=this.style("alignment-baseline").toTextBaseline()),o(e)||(t.textBaseline=e)}},{key:"getBoundingBox",value:function getBoundingBox(){var t=this.attribute("x").toPixels("x"),n=this.attribute("y").toPixels("y"),i=this.parent.style("font-size").numValueOrDefault(e.Font.Parse(e.ctx.font).fontSize);return new e.BoundingBox(t,n-i,t+Math.floor(2*i/3)*this.children[0].getText().length,n)}},{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(n,i){e.renderChild(t,e,i)}))}},{key:"getAnchorDelta",value:function getAnchorDelta(t,e,n){var i=this.style("text-anchor").valueOrDefault("start");if("start"!==i){for(var s=0,l=n;l<e.children.length;l++){var o=e.children[l];if(l>n&&o.attribute("x").hasValue())break;s+=o.measureTextRecursive(t)}return-1*("end"===i?s:s/2)}return 0}},{key:"renderChild",value:function renderChild(t,e,n){var i=e.children[n];i.attribute("x").hasValue()?(i.x=i.attribute("x").toPixels("x")+this.getAnchorDelta(t,e,n),i.attribute("dx").hasValue()&&(i.x+=i.attribute("dx").toPixels("x"))):(this.attribute("dx").hasValue()&&(this.x+=this.attribute("dx").toPixels("x")),i.attribute("dx").hasValue()&&(this.x+=i.attribute("dx").toPixels("x")),i.x=this.x),this.x=i.x+i.measureText(t),i.attribute("y").hasValue()?(i.y=i.attribute("y").toPixels("y"),i.attribute("dy").hasValue()&&(i.y+=i.attribute("dy").toPixels("y"))):(this.attribute("dy").hasValue()&&(this.y+=this.attribute("dy").toPixels("y")),i.attribute("dy").hasValue()&&(this.y+=i.attribute("dy").toPixels("y")),i.y=this.y),this.y=i.y,i.render(t);for(var s=0;s<i.children.length;s++)this.renderChild(t,i,s)}}]),_class30}(e.Element.RenderedElementBase),e.Element.TextElementBase=function(t){_inherits(_class31,t);var n=_createSuper(_class31);function _class31(){return _classCallCheck(this,_class31),n.apply(this,arguments)}return _createClass(_class31,[{key:"getGlyph",value:function getGlyph(t,e,n){var i=e[n],s=null;if(t.isArabic){var l="isolated";(0===n||" "===e[n-1])&&n<e.length-2&&" "!==e[n+1]&&(l="terminal"),n>0&&" "!==e[n-1]&&n<e.length-2&&" "!==e[n+1]&&(l="medial"),n>0&&" "!==e[n-1]&&(n===e.length-1||" "===e[n+1])&&(l="initial"),void 0!==t.glyphs[i]&&(s=t.glyphs[i][l],o(s)&&"glyph"===t.glyphs[i].type&&(s=t.glyphs[i]))}else s=t.glyphs[i];return o(s)&&(s=t.missingGlyph),s}},{key:"renderChildren",value:function renderChildren(t){var n=this.parent.style("font-family").getDefinition();if(o(n))""!==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 i=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();n.isRTL&&(l=l.split("").reverse().join(""));for(var u=e.ToNumberArray(this.parent.attribute("dx").value),h=0;h<l.length;h++){var d=this.getGlyph(n,l,h),p=i/n.fontFace.unitsPerEm;t.translate(this.x,this.y),t.scale(p,-p);var v=t.lineWidth;t.lineWidth=t.lineWidth*n.fontFace.unitsPerEm/i,"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+=i*(d.horizAdvX||n.horizAdvX)/n.fontFace.unitsPerEm,void 0===u[h]||isNaN(u[h])||(this.x+=u[h])}}}},{key:"getText",value:function getText(){}},{key:"measureTextRecursive",value:function measureTextRecursive(t){var e=this.measureText(t);return this.children.forEach((function(n){e+=n.measureTextRecursive(t)})),e}},{key:"measureText",value:function measureText(t){var n=this.parent.style("font-family").getDefinition();if(!o(n)){var i=this.parent.style("font-size").numValueOrDefault(e.Font.Parse(e.ctx.font).fontSize),s=0,l=this.getText();n.isRTL&&(l=l.split("").reverse().join(""));for(var u=e.ToNumberArray(this.parent.attribute("dx").value),h=0;h<l.length;h++){s+=(this.getGlyph(n,l,h).horizAdvX||n.horizAdvX)*i/n.fontFace.unitsPerEm,void 0===u[h]||isNaN(u[h])||(s+=u[h])}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 n;return _classCallCheck(this,_class32),(n=e.call(this,t,!0)).text=t.nodeValue||t.text||"",n}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(!o(t))return t.children[0].getText()}}]),_class33}(e.Element.TextElementBase),e.Element.a=function(t){_inherits(_class34,t);var n=_createSuper(_class34);function _class34(t){var e;return _classCallCheck(this,_class34),(e=n.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 n=new e.Property("fontSize",e.Font.Parse(e.ctx.font).fontSize);e.Mouse.checkBoundingBox(this,new e.BoundingBox(this.x,this.y-n.toPixels("y"),this.x+this.measureText(t),this.y))}else{var i=new e.Element.g;i.children=this.children,i.parent=this,i.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 n=_createSuper(_class35);function _class35(t){var i;_classCallCheck(this,_class35);var s=(i=n.call(this,t)).getHrefAttribute().value;return""===s?_possibleConstructorReturn(i):(i._isSvg=s.match(/\.svg$/),e.Images.push(_assertThisInitialized(i)),i.loaded=!1,i._isSvg?e.ajax(s,!0).then((function(t){i.img=t,i.loaded=!0})).catch((function(t){i.erred=!0,console.error("Ajax error for canvg",t)})):(i.img=document.createElement("img"),!0===e.opts.useCORS&&(i.img.crossOrigin="Anonymous"),i.img.addEventListener("load",(function(){i.loaded=!0})),i.img.addEventListener("error",(function(){e.log('ERROR: image "'+s+'" not found'),i.loaded=!0})),i.img.src=s),i)}return _createClass(_class35,[{key:"renderChildren",value:function renderChildren(t){var n=this.attribute("x").toPixels("x"),i=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,n,i,s,l):(t.translate(n,i),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"),n=this.attribute("y").toPixels("y"),i=this.attribute("width").toPixels("x"),s=this.attribute("height").toPixels("y");return new e.BoundingBox(t,n,t+i,n+s)}}]),_class35}(e.Element.RenderedElementBase),e.Element.g=function(t){_inherits(_class36,t);var n=_createSuper(_class36);function _class36(){return _classCallCheck(this,_class36),n.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 n=_createSuper(_class38);function _class38(t){var i;_classCallCheck(this,_class38),i=n.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 n=_slicedToArray(t.split("{"),2),i=n[0],s=n[1];i=i.split(","),s=s.split(";"),i.forEach((function(t){if(""!==(t=e.trim(t))){var n={};if(s.forEach((function(t){var i=t.indexOf(":"),s=t.substr(0,i),l=t.substr(i+1,t.length-i);o(s)||o(l)||(n[e.trim(s)]=new e.Property(e.trim(s),e.trim(l)))})),e.Styles[t]=n,"@font-face"===t){var i=n["font-family"].value.replace(/"/g,"");n.src.value.split(",").forEach((function(t){if(t.includes('format("svg")')){var n=t.indexOf("url"),s=t.indexOf(")",n),l=t.substr(n+5,s-n-6);_toConsumableArray(e.parseXml(e.ajax(l)).getElementsByTagName("font")).forEach((function(t){t=e.CreateElement(t),e.Definitions[i]=t}))}}))}}}))}})),i}return _class38}(e.Element.ElementBase),e.Element.use=function(t){_inherits(_class39,t);var n=_createSuper(_class39);function _class39(t){var e;return _classCallCheck(this,_class39),(e=n.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;o(e)||e.path(t)}},{key:"getBoundingBox",value:function getBoundingBox(){var t=this._el;if(!o(t))return t.getBoundingBox()}},{key:"renderChildren",value:function renderChildren(t){var n=this._el;if(!o(n)){var i=n;"symbol"===n.type&&((i=new e.Element.svg).type="svg",i.attributes.viewBox=new e.Property("viewBox",n.attribute("viewBox").value),i.attributes.preserveAspectRatio=new e.Property("preserveAspectRatio",n.attribute("preserveAspectRatio").value),i.attributes.overflow=new e.Property("overflow",n.attribute("overflow").value),i.children=n.children),"svg"===i.type&&(this.attribute("width").hasValue()&&(i.attributes.width=new e.Property("width",this.attribute("width").value)),this.attribute("height").hasValue()&&(i.attributes.height=new e.Property("height",this.attribute("height").value)));var s=i.parent;i.parent=null,i.render(t),i.parent=s}}}]),_class39}(e.Element.RenderedElementBase),e.Element.mask=function(t){_inherits(_class40,t);var n=_createSuper(_class40);function _class40(){return _classCallCheck(this,_class40),n.apply(this,arguments)}return _createClass(_class40,[{key:"apply",value:function apply(t,n){var i=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())})),i=Math.floor(u.x1),s=Math.floor(u.y1),l=Math.floor(u.width()),o=Math.floor(u.height())}var h=n.attribute("mask").value;n.attribute("mask").value="";var d=document.createElement("canvas");d.width=i+l,d.height=s+o;var p=d.getContext("2d");this.renderChildren(p);var v=document.createElement("canvas");v.width=i+l,v.height=s+o;var g=v.getContext("2d");n.render(g),g.globalCompositeOperation="destination-in",g.fillStyle=p.createPattern(d,"no-repeat"),g.fillRect(0,0,i+l,s+o),t.fillStyle=g.createPattern(v,"no-repeat"),t.fillRect(0,0,i+l,s+o),n.attribute("mask").value=h}},{key:"render",value:function render(t){}}]),_class40}(e.Element.ElementBase),e.Element.clipPath=function(t){_inherits(_class41,t);var n=_createSuper(_class41);function _class41(){return _classCallCheck(this,_class41),n.apply(this,arguments)}return _createClass(_class41,[{key:"apply",value:function apply(t){this.children.forEach((function(n){if(void 0!==n.path){var i=null;n.attribute("transform").hasValue()&&(i=new e.Transform(n.attribute("transform").value)).apply(t),n.path(t),t.clip(),i&&i.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 n=e.getBoundingBox(),i=Math.floor(n.x1),s=Math.floor(n.y1),l=Math.floor(n.width()),o=Math.floor(n.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(-i+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,i-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,n,i,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,n,i,s){}}]),_class44}(e.Element.ElementBase),e.Element.feColorMatrix=function(t){_inherits(_class45,t);var n=_createSuper(_class45);function _class45(t){var i;_classCallCheck(this,_class45),i=n.call(this,t);var s=e.ToNumberArray(i.attribute("values").value);switch(i.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,n){return t+Math.cos(o)*e+Math.sin(o)*n};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 i.matrix=s,i._m=function(t,e){var n=s[t];return n*(n<0?e-255:e)},i}return _createClass(_class45,[{key:"apply",value:function apply(t,e,n,i,s){for(var l=this._m,o=t.getImageData(0,0,i,s),u=0;u<s;u++)for(var h=0;h<i;h++){var d=imGet(o.data,h,u,i,s,0),p=imGet(o.data,h,u,i,s,1),v=imGet(o.data,h,u,i,s,2),g=imGet(o.data,h,u,i,s,3);imSet(o.data,h,u,i,s,0,l(0,d)+l(1,p)+l(2,v)+l(3,g)+l(4,1)),imSet(o.data,h,u,i,s,1,l(5,d)+l(6,p)+l(7,v)+l(8,g)+l(9,1)),imSet(o.data,h,u,i,s,2,l(10,d)+l(11,p)+l(12,v)+l(13,g)+l(14,1)),imSet(o.data,h,u,i,s,3,l(15,d)+l(16,p)+l(17,v)+l(18,g)+l(19,1))}t.clearRect(0,0,i,s),t.putImageData(o,0,0)}}]),_class45}(e.Element.ElementBase),e.Element.feGaussianBlur=function(t){_inherits(_class46,t);var n=_createSuper(_class46);function _class46(t){var e;return _classCallCheck(this,_class46),(e=n.call(this,t)).blurRadius=Math.floor(e.attribute("stdDeviation").numValue()),e.extraFilterDistance=e.blurRadius,e}return _createClass(_class46,[{key:"apply",value:function apply(t,n,i,s,l){t.canvas.id=e.UniqueId(),t.canvas.style.display="none",document.body.append(t.canvas),processCanvasRGBA(t.canvas,n,i,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 n=_createSuper(_class49);function _class49(t){var i;return _classCallCheck(this,_class49),i=n.call(this),e.log("ERROR: Element '"+t.nodeName+"' not yet implemented."),i}return _class49}(e.Element.ElementBase),e.CreateElement=function(t){var n,i=t.nodeName.replace(/^[^:]+:/,"").replace(/-/g,"");return(n=void 0!==e.Element[i]?new e.Element[i](t):new e.Element.MISSING(t)).type=t.nodeName,n},e.load=function(){var t=_asyncToGenerator(regeneratorRuntime.mark((function _callee(t,n){var i;return regeneratorRuntime.wrap((function _callee$(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,e.ajax(n,!0);case 2:return i=s.sent,s.abrupt("return",e.loadXml(t,i));case 4:case"end":return s.stop()}}),_callee)})));return function(e,n){return t.apply(this,arguments)}}(),e.loadXml=function(t,n){return e.loadXmlDoc(t,e.parseXml(n))},e.loadXmlDoc=function(t,n){var i;e.init(t);var s=function mapXY(e){for(var n=t.canvas;n;)e.x-=n.offsetLeft,e.y-=n.offsetTop,n=n.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 n=o(t)?[event.clientX,event.clientY]:[t.clientX,t.clientY],i=s(_construct(e.Point,n)),l=i.x,u=i.y;e.Mouse.onclick(l,u)})),t.canvas.addEventListener("mousemove",(function(t){var n=o(t)?[event.clientX,event.clientY]:[t.clientX,t.clientY],i=s(_construct(e.Point,n)),l=i.x,u=i.y;e.Mouse.onmousemove(l,u)})));var l=e.CreateElement(n.documentElement);l.root=!0;var u=!0,h=function draw(i){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,h=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"),h=l.style("height").toPixels("y")),e.ViewPort.SetCurrent(s,h),o(e.opts.offsetX)||(l.attribute("x",!0).value=e.opts.offsetX),o(e.opts.offsetY)||(l.attribute("y",!0).value=e.opts.offsetY),!o(e.opts.scaleWidth)||!o(e.opts.scaleHeight)){var d=e.ToNumberArray(l.attribute("viewBox").value),p=null,v=null;o(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)),o(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)),o(p)&&(p=v),o(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+" "+h*v,l.attribute("preserveAspectRatio",!0).value="none"}!0!==e.opts.ignoreClear&&t.clearRect(0,0,s,h),l.render(t),u&&(u=!1,i(n))},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(n){var i=n.update(1e3/e.FRAMERATE);t=t||i})),"function"==typeof e.opts.forceRedraw&&!0===e.opts.forceRedraw()&&(t=!0),t&&(h(i),e.Mouse.runEvents())}),1e3/e.FRAMERATE),new Promise((function(t,n){if(e.ImagesLoaded())return d=!1,void h(t);i=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 n=this;this.events.forEach((function(i,s){var l=i.x,o=i.y;e.isPointInPath&&e.isPointInPath(l,o)&&(n.eventElements[s]=t)}))},checkBoundingBox:function checkBoundingBox(t,e){var n=this;this.events.forEach((function(i,s){var l=i.x,o=i.y;e.isPointInBox(l,o)&&(n.eventElements[s]=t)}))},runEvents:function runEvents(){var t=this;e.ctx.canvas.style.cursor="",this.events.forEach((function(e,n){for(var i=t.eventElements[n];i;)e.run(i),i=i.parent})),this.events=[],this.eventElements=[]}},e}(i||{});1===t.childNodes.length&&"OBJECT"===t.childNodes[0].nodeName||(t.svg=l);var u=t.getContext("2d");return void 0!==e.documentElement?l.loadXmlDoc(u,e):"<"===e.substr(0,1)?l.loadXml(u,e):l.load(u,e)};"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.drawSvg=function(t,e,n,i,s){u(this.canvas,t,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:e,offsetY:n,scaleWidth:i,scaleHeight:s})});var h={name:"server_moinsave",init:function init(t){var e=this;return _asyncToGenerator(regeneratorRuntime.mark((function _callee2(){var n,i,s,l,o,h;return regeneratorRuntime.wrap((function _callee2$(d){for(;;)switch(d.prev=d.next){case 0:return n=t.$,i=t.encode64,s=t.importLocale,d.next=3,s();case 3:l=d.sent,h=(o=e).canvas,"/+modify",n('<iframe name="output_frame" title="'.concat(l.hiddenframe,'"\n style="width: 0; height: 0;" src="data:text/html;base64,PGh0bWw+PC9odG1sPg=="/>')).appendTo("body"),o.setCustomHandlers({save:function save(t,e){return _asyncToGenerator(regeneratorRuntime.mark((function _callee(){var t,s,o,d,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,s=new URL(location),o=s.pathname,d=o.replace(/\/+get\//,""),p=i(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,u(v,t);case 10:g=v.toDataURL("image/png"),_=i(g),n("<form>").attr({method:"post",action:"/+modify/"+d,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(l.saved),top.window.location="/"+d;case 15:case"end":return b.stop()}}),_callee)})))()}});case 9:case"end":return d.stop()}}),_callee2)})))()}};export default h;
|
|
//# sourceMappingURL=ext-server_moinsave.js.map
|