baizonghao
2023-08-04 8fee5b265eaa379b7a1cc51cd060a368c046de46
1
function RGBColor(t){this.ok=!1,"#"==t.charAt(0)&&(t=t.substr(1,6));t=(t=t.replace(/ /g,"")).toLowerCase();var e,h={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"};for(e in h)t==e&&(t=h[e]);var u=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(t){return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}}];for(e=0;e<u.length;e++){var i=u[e].process,n=u[e].re.exec(t);n&&(channels=i(n),this.r=channels[0],this.g=channels[1],this.b=channels[2],this.ok=!0)}this.r=this.r<0||isNaN(this.r)?0:255<this.r?255:this.r,this.g=this.g<0||isNaN(this.g)?0:255<this.g?255:this.g,this.b=this.b<0||isNaN(this.b)?0:255<this.b?255:this.b,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toHex=function(){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},this.getHelpXML=function(){for(var t=[],e=0;e<u.length;e++)for(var i=u[e].example,n=0;n<i.length;n++)t[t.length]=i[n];for(var s in h)t[t.length]=s;for((i=document.createElement("ul")).setAttribute("id","rgbcolor-examples"),e=0;e<t.length;e++)try{var a=document.createElement("li"),r=new RGBColor(t[e]),o=document.createElement("div");o.style.cssText="margin: 3px; border: 1px solid black; background:"+r.toHex()+"; color:"+r.toHex(),o.appendChild(document.createTextNode("test"));var l=document.createTextNode(" "+t[e]+" -> "+r.toRGB()+" -> "+r.toHex());a.appendChild(o),a.appendChild(l),i.appendChild(a)}catch(t){}return i}}window.console||(window.console={},window.console.log=function(){},window.console.dir=function(){}),Array.prototype.indexOf||(Array.prototype.indexOf=function(t){for(var e=0;e<this.length;e++)if(this[e]==t)return e;return-1}),function(){function a(){var p={FRAMERATE:30,MAX_VIRTUAL_PIXELS:3e4,init:function(t){p.Definitions={},p.Styles={},p.Animations=[],p.Images=[],p.ctx=t,p.ViewPort=new function(){this.viewPorts=[],this.Clear=function(){this.viewPorts=[]},this.SetCurrent=function(t,e){this.viewPorts.push({width:t,height:e})},this.RemoveCurrent=function(){this.viewPorts.pop()},this.Current=function(){return this.viewPorts[this.viewPorts.length-1]},this.width=function(){return this.Current().width},this.height=function(){return this.Current().height},this.ComputeSize=function(t){return null!=t&&"number"==typeof t?t:"x"==t?this.width():"y"==t?this.height():Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2)}}}};return p.init(),p.ImagesLoaded=function(){for(var t=0;t<p.Images.length;t++)if(!p.Images[t].loaded)return!1;return!0},p.trim=function(t){return t.replace(/^\s+|\s+$/g,"")},p.compressSpaces=function(t){return t.replace(/[\s\r\t\n]+/gm," ")},p.ajax=function(t){var e;return(e=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"))?(e.open("GET",t,!1),e.send(null),e.responseText):null},p.parseXml=function(t){if(window.DOMParser)return(new DOMParser).parseFromString(t,"text/xml");t=t.replace(/<!DOCTYPE svg[^>]*>/,"");var e=new ActiveXObject("Microsoft.XMLDOM");return e.async="false",e.loadXML(t),e},p.Property=function(t,e){this.name=t,this.value=e,this.hasValue=function(){return null!=this.value&&""!==this.value},this.numValue=function(){if(!this.hasValue())return 0;var t=parseFloat(this.value);return(this.value+"").match(/%$/)&&(t/=100),t},this.valueOrDefault=function(t){return this.hasValue()?this.value:t},this.numValueOrDefault=function(t){return this.hasValue()?this.numValue():t};var n=this;this.Color={addOpacity:function(t){var e=n.value;if(null!=t&&""!=t){var i=new RGBColor(n.value);i.ok&&(e="rgba("+i.r+", "+i.g+", "+i.b+", "+t+")")}return new p.Property(n.name,e)}},this.Definition={getDefinition:function(){var t=n.value.replace(/^(url\()?#([^\)]+)\)?$/,"$2");return p.Definitions[t]},isUrl:function(){return 0==n.value.indexOf("url(")},getFillStyle:function(t){var e=this.getDefinition();return null!=e&&e.createGradient?e.createGradient(p.ctx,t):null!=e&&e.createPattern?e.createPattern(p.ctx,t):null}},this.Length={DPI:function(){return 96},EM:function(t){var e=12,i=new p.Property("fontSize",p.Font.Parse(p.ctx.font).fontSize);return i.hasValue()&&(e=i.Length.toPixels(t)),e},toPixels:function(t){if(!n.hasValue())return 0;var e=n.value+"";return e.match(/em$/)?n.numValue()*this.EM(t):e.match(/ex$/)?n.numValue()*this.EM(t)/2:e.match(/px$/)?n.numValue():e.match(/pt$/)?1.25*n.numValue():e.match(/pc$/)?15*n.numValue():e.match(/cm$/)?n.numValue()*this.DPI(t)/2.54:e.match(/mm$/)?n.numValue()*this.DPI(t)/25.4:e.match(/in$/)?n.numValue()*this.DPI(t):e.match(/%$/)?n.numValue()*p.ViewPort.ComputeSize(t):n.numValue()}},this.Time={toMilliseconds:function(){if(!n.hasValue())return 0;var t=n.value+"";return t.match(/s$/)?1e3*n.numValue():(t.match(/ms$/),n.numValue())}},this.Angle={toRadians:function(){if(!n.hasValue())return 0;var t=n.value+"";return t.match(/deg$/)?n.numValue()*(Math.PI/180):t.match(/grad$/)?n.numValue()*(Math.PI/200):t.match(/rad$/)?n.numValue():n.numValue()*(Math.PI/180)}}},p.Font=new function(){this.Styles=["normal","italic","oblique","inherit"],this.Variants=["normal","small-caps","inherit"],this.Weights="normal,bold,bolder,lighter,100,200,300,400,500,600,700,800,900,inherit".split(","),this.CreateFont=function(t,e,i,n,s,a){return a=null!=a?this.Parse(a):this.CreateFont("","","","","",p.ctx.font),{fontFamily:s||a.fontFamily,fontSize:n||a.fontSize,fontStyle:t||a.fontStyle,fontWeight:i||a.fontWeight,fontVariant:e||a.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var l=this;this.Parse=function(t){for(var e={},i=(t=p.trim(p.compressSpaces(t||"")).split(" "),!1),n=!1,s=!1,a=!1,r="",o=0;o<t.length;o++)n||-1==l.Styles.indexOf(t[o])?a||-1==l.Variants.indexOf(t[o])?s||-1==l.Weights.indexOf(t[o])?i?"inherit"!=t[o]&&(r+=t[o]):("inherit"!=t[o]&&(e.fontSize=t[o].split("/")[0]),n=a=s=i=!0):("inherit"!=t[o]&&(e.fontWeight=t[o]),n=a=s=!0):("inherit"!=t[o]&&(e.fontVariant=t[o]),n=a=!0):("inherit"!=t[o]&&(e.fontStyle=t[o]),n=!0);return""!=r&&(e.fontFamily=r),e}},p.ToNumberArray=function(t){t=p.trim(p.compressSpaces((t||"").replace(/,/g," "))).split(" ");for(var e=0;e<t.length;e++)t[e]=parseFloat(t[e]);return t},p.Point=function(t,e){this.x=t,this.y=e,this.angleTo=function(t){return Math.atan2(t.y-this.y,t.x-this.x)},this.applyTransform=function(t){var e=this.x*t[1]+this.y*t[3]+t[5];this.x=this.x*t[0]+this.y*t[2]+t[4],this.y=e}},p.CreatePoint=function(t){return t=p.ToNumberArray(t),new p.Point(t[0],t[1])},p.CreatePath=function(t){t=p.ToNumberArray(t);for(var e=[],i=0;i<t.length;i+=2)e.push(new p.Point(t[i],t[i+1]));return e},p.BoundingBox=function(t,e,n,s){this.y2=this.x2=this.y1=this.x1=Number.NaN,this.x=function(){return this.x1},this.y=function(){return this.y1},this.width=function(){return this.x2-this.x1},this.height=function(){return this.y2-this.y1},this.addPoint=function(t,e){null!=t&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x2=this.x1=t),t<this.x1&&(this.x1=t),t>this.x2&&(this.x2=t)),null!=e&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y2=this.y1=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))},this.addX=function(t){this.addPoint(t,null)},this.addY=function(t){this.addPoint(null,t)},this.addBoundingBox=function(t){this.addPoint(t.x1,t.y1),this.addPoint(t.x2,t.y2)},this.addQuadraticCurve=function(t,e,i,n,s,a){i=t+2/3*(i-t),n=e+2/3*(n-e),this.addBezierCurve(t,e,i,i+1/3*(s-t),n,n+1/3*(a-e),s,a)},this.addBezierCurve=function(t,e,n,s,a,r,o,l){var h=[t,e],u=[n,s],c=[a,r],d=[o,l];for(this.addPoint(h[0],h[1]),this.addPoint(d[0],d[1]),i=0;i<=1;i++)t=function(t){return Math.pow(1-t,3)*h[i]+3*Math.pow(1-t,2)*t*u[i]+3*(1-t)*Math.pow(t,2)*c[i]+Math.pow(t,3)*d[i]},e=6*h[i]-12*u[i]+6*c[i],n=-3*h[i]+9*u[i]-9*c[i]+3*d[i],s=3*u[i]-3*h[i],0==n?0!=e&&(0<(e=-s/e)&&e<1&&(0==i&&this.addX(t(e)),1==i&&this.addY(t(e)))):(s=Math.pow(e,2)-4*s*n)<0||(0<(a=(-e+Math.sqrt(s))/(2*n))&&a<1&&(0==i&&this.addX(t(a)),1==i&&this.addY(t(a))),0<(e=(-e-Math.sqrt(s))/(2*n))&&e<1&&(0==i&&this.addX(t(e)),1==i&&this.addY(t(e))))},this.isPointInBox=function(t,e){return this.x1<=t&&t<=this.x2&&this.y1<=e&&e<=this.y2},this.addPoint(t,e),this.addPoint(n,s)},p.Transform=function(t){var e=this;this.Type={},this.Type.translate=function(t){this.p=p.CreatePoint(t),this.apply=function(t){t.translate(this.p.x||0,this.p.y||0)},this.applyToPoint=function(t){t.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0])}},this.Type.rotate=function(t){t=p.ToNumberArray(t),this.angle=new p.Property("angle",t[0]),this.cx=t[1]||0,this.cy=t[2]||0,this.apply=function(t){t.translate(this.cx,this.cy),t.rotate(this.angle.Angle.toRadians()),t.translate(-this.cx,-this.cy)},this.applyToPoint=function(t){var e=this.angle.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])}},this.Type.scale=function(t){this.p=p.CreatePoint(t),this.apply=function(t){t.scale(this.p.x||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])}},this.Type.matrix=function(t){this.m=p.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)}},this.Type.SkewBase=function(t){this.base=e.Type.matrix,this.base(t),this.angle=new p.Property("angle",t)},this.Type.SkewBase.prototype=new this.Type.matrix,this.Type.skewX=function(t){this.base=e.Type.SkewBase,this.base(t),this.m=[1,0,Math.tan(this.angle.Angle.toRadians()),1,0,0]},this.Type.skewX.prototype=new this.Type.SkewBase,this.Type.skewY=function(t){this.base=e.Type.SkewBase,this.base(t),this.m=[1,Math.tan(this.angle.Angle.toRadians()),0,1,0,0]},this.Type.skewY.prototype=new this.Type.SkewBase,this.transforms=[],this.apply=function(t){for(var e=0;e<this.transforms.length;e++)this.transforms[e].apply(t)},this.applyToPoint=function(t){for(var e=0;e<this.transforms.length;e++)this.transforms[e].applyToPoint(t)};t=p.trim(p.compressSpaces(t)).split(/\s(?=[a-z])/);for(var i=0;i<t.length;i++){var n=t[i].split("(")[0],s=t[i].split("(")[1].replace(")","");this.transforms.push(new this.Type[n](s))}},p.AspectRatio=function(t,e,i,n,s,a,r,o,l,h){var u=(e=(e=p.compressSpaces(e)).replace(/^defer\s/,"")).split(" ")[0]||"xMidYMid",c=(e=e.split(" ")[1]||"meet",i/n),d=s/a,f=Math.min(c,d),m=Math.max(c,d);"meet"==e&&(n*=f,a*=f),"slice"==e&&(n*=m,a*=m),l=new p.Property("refX",l),h=new p.Property("refY",h),l.hasValue()&&h.hasValue()?t.translate(-f*l.Length.toPixels("x"),-f*h.Length.toPixels("y")):(u.match(/^xMid/)&&("meet"==e&&f==d||"slice"==e&&m==d)&&t.translate(i/2-n/2,0),u.match(/YMid$/)&&("meet"==e&&f==c||"slice"==e&&m==c)&&t.translate(0,s/2-a/2),u.match(/^xMax/)&&("meet"==e&&f==d||"slice"==e&&m==d)&&t.translate(i-n,0),u.match(/YMax$/)&&("meet"==e&&f==c||"slice"==e&&m==c)&&t.translate(0,s-a)),"none"==u?t.scale(c,d):"meet"==e?t.scale(f,f):"slice"==e&&t.scale(m,m),t.translate(null==r?0:-r,null==o?0:-o)},p.Element={},p.Element.ElementBase=function(t){if(this.attributes={},this.styles={},this.children=[],this.attribute=function(t,e){var i=this.attributes[t];return null!=i||(i=new p.Property(t,""),1==e&&(this.attributes[t]=i)),i},this.style=function(t,e){var i=this.styles[t];return null!=i||null!=(i=this.attribute(t))&&i.hasValue()||null!=(i=this.parent)&&(null!=(i=i.style(t))&&i.hasValue())||(i=new p.Property(t,""),1==e&&(this.styles[t]=i)),i},this.render=function(t){if("none"!=this.style("display").value&&"hidden"!=this.attribute("visibility").value){if(t.save(),this.setContext(t),this.attribute("mask").hasValue()){var e=this.attribute("mask").Definition.getDefinition();null!=e&&e.apply(t,this)}else this.style("filter").hasValue()?null!=(e=this.style("filter").Definition.getDefinition())&&e.apply(t,this):this.renderChildren(t);this.clearContext(t),t.restore()}},this.setContext=function(){},this.clearContext=function(){},this.renderChildren=function(t){for(var e=0;e<this.children.length;e++)this.children[e].render(t)},this.addChild=function(t,e){var i=t;e&&(i=p.CreateElement(t)),(i.parent=this).children.push(i)},null!=t&&1==t.nodeType){for(var e=0;e<t.childNodes.length;e++){var i=t.childNodes[e];1==i.nodeType&&this.addChild(i,!0)}for(e=0;e<t.attributes.length;e++)i=t.attributes[e],this.attributes[i.nodeName]=new p.Property(i.nodeName,i.nodeValue);if(null!=(i=p.Styles[t.nodeName]))for(var n in i)this.styles[n]=i[n];if(this.attribute("class").hasValue()){e=p.compressSpaces(this.attribute("class").value).split(" ");for(var s=0;s<e.length;s++){if(null!=(i=p.Styles["."+e[s]]))for(n in i)this.styles[n]=i[n];if(null!=(i=p.Styles[t.nodeName+"."+e[s]]))for(n in i)this.styles[n]=i[n]}}if(this.attribute("style").hasValue())for(i=this.attribute("style").value.split(";"),e=0;e<i.length;e++)""!=p.trim(i[e])&&(t=i[e].split(":"),n=p.trim(t[0]),t=p.trim(t[1]),this.styles[n]=new p.Property(n,t));this.attribute("id").hasValue()&&null==p.Definitions[this.attribute("id").value]&&(p.Definitions[this.attribute("id").value]=this)}},p.Element.RenderedElementBase=function(t){this.base=p.Element.ElementBase,this.base(t),this.setContext=function(t){if(this.style("fill").Definition.isUrl()){var e=this.style("fill").Definition.getFillStyle(this);null!=e&&(t.fillStyle=e)}else this.style("fill").hasValue()&&(e=this.style("fill"),this.style("fill-opacity").hasValue()&&(e=e.Color.addOpacity(this.style("fill-opacity").value)),t.fillStyle="none"==e.value?"rgba(0,0,0,0)":e.value);this.style("stroke").Definition.isUrl()?null!=(e=this.style("stroke").Definition.getFillStyle(this))&&(t.strokeStyle=e):this.style("stroke").hasValue()&&(e=this.style("stroke"),this.style("stroke-opacity").hasValue()&&(e=e.Color.addOpacity(this.style("stroke-opacity").value)),t.strokeStyle="none"==e.value?"rgba(0,0,0,0)":e.value),this.style("stroke-width").hasValue()&&(t.lineWidth=this.style("stroke-width").Length.toPixels()),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),void 0!==t.font&&(t.font=p.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").Length.toPixels()+"px":"",this.style("font-family").value).toString()),this.attribute("transform").hasValue()&&new p.Transform(this.attribute("transform").value).apply(t),!this.attribute("clip-path").hasValue()||null!=(e=this.attribute("clip-path").Definition.getDefinition())&&e.apply(t),this.style("opacity").hasValue()&&(t.globalAlpha=this.style("opacity").numValue())}},p.Element.RenderedElementBase.prototype=new p.Element.ElementBase,p.Element.PathElementBase=function(t){this.base=p.Element.RenderedElementBase,this.base(t),this.path=function(t){return null!=t&&t.beginPath(),new p.BoundingBox},this.renderChildren=function(t){this.path(t),p.Mouse.checkPath(this,t),""!=t.fillStyle&&t.fill(),""!=t.strokeStyle&&t.stroke();var e=this.getMarkers();if(null!=e){if(this.style("marker-start").Definition.isUrl())(i=this.style("marker-start").Definition.getDefinition()).render(t,e[0][0],e[0][1]);if(this.style("marker-mid").Definition.isUrl())for(var i=this.style("marker-mid").Definition.getDefinition(),n=1;n<e.length-1;n++)i.render(t,e[n][0],e[n][1]);this.style("marker-end").Definition.isUrl()&&(i=this.style("marker-end").Definition.getDefinition()).render(t,e[e.length-1][0],e[e.length-1][1])}},this.getBoundingBox=function(){return this.path()},this.getMarkers=function(){return null}},p.Element.PathElementBase.prototype=new p.Element.RenderedElementBase,p.Element.svg=function(t){this.base=p.Element.RenderedElementBase,this.base(t),this.baseClearContext=this.clearContext,this.clearContext=function(t){this.baseClearContext(t),p.ViewPort.RemoveCurrent()},this.baseSetContext=this.setContext,this.setContext=function(t){t.strokeStyle="rgba(0,0,0,0)",t.lineCap="butt",t.lineJoin="miter",t.miterLimit=4,this.baseSetContext(t),this.attribute("x").hasValue()&&this.attribute("y").hasValue()&&t.translate(this.attribute("x").Length.toPixels("x"),this.attribute("y").Length.toPixels("y"));var e=p.ViewPort.width(),i=p.ViewPort.height();if(void 0===this.root&&this.attribute("width").hasValue()&&this.attribute("height").hasValue()){e=this.attribute("width").Length.toPixels("x"),i=this.attribute("height").Length.toPixels("y");var n=0,s=0;this.attribute("refX").hasValue()&&this.attribute("refY").hasValue()&&(n=-this.attribute("refX").Length.toPixels("x"),s=-this.attribute("refY").Length.toPixels("y")),t.beginPath(),t.moveTo(n,s),t.lineTo(e,s),t.lineTo(e,i),t.lineTo(n,i),t.closePath(),t.clip()}if(p.ViewPort.SetCurrent(e,i),this.attribute("viewBox").hasValue()){s=(n=p.ToNumberArray(this.attribute("viewBox").value))[0];var a=n[1];e=n[2],i=n[3];p.AspectRatio(t,this.attribute("preserveAspectRatio").value,p.ViewPort.width(),e,p.ViewPort.height(),i,s,a,this.attribute("refX").value,this.attribute("refY").value),p.ViewPort.RemoveCurrent(),p.ViewPort.SetCurrent(n[2],n[3])}}},p.Element.svg.prototype=new p.Element.RenderedElementBase,p.Element.rect=function(t){this.base=p.Element.PathElementBase,this.base(t),this.path=function(t){var e=this.attribute("x").Length.toPixels("x"),i=this.attribute("y").Length.toPixels("y"),n=this.attribute("width").Length.toPixels("x"),s=this.attribute("height").Length.toPixels("y"),a=this.attribute("rx").Length.toPixels("x"),r=this.attribute("ry").Length.toPixels("y");return this.attribute("rx").hasValue()&&!this.attribute("ry").hasValue()&&(r=a),this.attribute("ry").hasValue()&&!this.attribute("rx").hasValue()&&(a=r),null!=t&&(t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+n-a,i),t.quadraticCurveTo(e+n,i,e+n,i+r),t.lineTo(e+n,i+s-r),t.quadraticCurveTo(e+n,i+s,e+n-a,i+s),t.lineTo(e+a,i+s),t.quadraticCurveTo(e,i+s,e,i+s-r),t.lineTo(e,i+r),t.quadraticCurveTo(e,i,e+a,i),t.closePath()),new p.BoundingBox(e,i,e+n,i+s)}},p.Element.rect.prototype=new p.Element.PathElementBase,p.Element.circle=function(t){this.base=p.Element.PathElementBase,this.base(t),this.path=function(t){var e=this.attribute("cx").Length.toPixels("x"),i=this.attribute("cy").Length.toPixels("y"),n=this.attribute("r").Length.toPixels();return null!=t&&(t.beginPath(),t.arc(e,i,n,0,2*Math.PI,!0),t.closePath()),new p.BoundingBox(e-n,i-n,e+n,i+n)}},p.Element.circle.prototype=new p.Element.PathElementBase,p.Element.ellipse=function(t){this.base=p.Element.PathElementBase,this.base(t),this.path=function(t){var e=(Math.sqrt(2)-1)/3*4,i=this.attribute("rx").Length.toPixels("x"),n=this.attribute("ry").Length.toPixels("y"),s=this.attribute("cx").Length.toPixels("x"),a=this.attribute("cy").Length.toPixels("y");return null!=t&&(t.beginPath(),t.moveTo(s,a-n),t.bezierCurveTo(s+e*i,a-n,s+i,a-e*n,s+i,a),t.bezierCurveTo(s+i,a+e*n,s+e*i,a+n,s,a+n),t.bezierCurveTo(s-e*i,a+n,s-i,a+e*n,s-i,a),t.bezierCurveTo(s-i,a-e*n,s-e*i,a-n,s,a-n),t.closePath()),new p.BoundingBox(s-i,a-n,s+i,a+n)}},p.Element.ellipse.prototype=new p.Element.PathElementBase,p.Element.line=function(t){this.base=p.Element.PathElementBase,this.base(t),this.getPoints=function(){return[new p.Point(this.attribute("x1").Length.toPixels("x"),this.attribute("y1").Length.toPixels("y")),new p.Point(this.attribute("x2").Length.toPixels("x"),this.attribute("y2").Length.toPixels("y"))]},this.path=function(t){var e=this.getPoints();return null!=t&&(t.beginPath(),t.moveTo(e[0].x,e[0].y),t.lineTo(e[1].x,e[1].y)),new p.BoundingBox(e[0].x,e[0].y,e[1].x,e[1].y)},this.getMarkers=function(){var t=this.getPoints(),e=t[0].angleTo(t[1]);return[[t[0],e],[t[1],e]]}},p.Element.line.prototype=new p.Element.PathElementBase,p.Element.polyline=function(t){this.base=p.Element.PathElementBase,this.base(t),this.points=p.CreatePath(this.attribute("points").value),this.path=function(t){var e=new p.BoundingBox(this.points[0].x,this.points[0].y);null!=t&&(t.beginPath(),t.moveTo(this.points[0].x,this.points[0].y));for(var i=1;i<this.points.length;i++)e.addPoint(this.points[i].x,this.points[i].y),null!=t&&t.lineTo(this.points[i].x,this.points[i].y);return e},this.getMarkers=function(){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}},p.Element.polyline.prototype=new p.Element.PathElementBase,p.Element.polygon=function(t){this.base=p.Element.polyline,this.base(t),this.basePath=this.path,this.path=function(t){var e=this.basePath(t);return null!=t&&(t.lineTo(this.points[0].x,this.points[0].y),t.closePath()),e}},p.Element.polygon.prototype=new p.Element.polyline,p.Element.path=function(t){this.base=p.Element.PathElementBase,this.base(t),t=(t=(t=(t=(t=(t=(t=(t=(t=this.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(/([0-9])([+\-])/gm,"$1 $2")).replace(/(\.[0-9]*)(\.)/gm,"$1 $2")).replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,"$1 $3 $4 "),t=p.compressSpaces(t),t=p.trim(t),this.PathParser=new function(t){this.tokens=t.split(" "),this.reset=function(){this.i=-1,this.previousCommand=this.command="",this.start=new p.Point(0,0),this.control=new p.Point(0,0),this.current=new p.Point(0,0),this.points=[],this.angles=[]},this.isEnd=function(){return this.i>=this.tokens.length-1},this.isCommandOrEnd=function(){return!!this.isEnd()||null!=this.tokens[this.i+1].match(/^[A-Za-z]$/)},this.isRelativeCommand=function(){return this.command==this.command.toLowerCase()},this.getToken=function(){return this.i+=1,this.tokens[this.i]},this.getScalar=function(){return parseFloat(this.getToken())},this.nextCommand=function(){this.previousCommand=this.command,this.command=this.getToken()},this.getPoint=function(){return this.makeAbsolute(new p.Point(this.getScalar(),this.getScalar()))},this.getAsControlPoint=function(){var t=this.getPoint();return this.control=t},this.getAsCurrentPoint=function(){var t=this.getPoint();return this.current=t},this.getReflectedControlPoint=function(){return"c"!=this.previousCommand.toLowerCase()&&"s"!=this.previousCommand.toLowerCase()?this.current:new p.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y)},this.makeAbsolute=function(t){return this.isRelativeCommand()&&(t.x=this.current.x+t.x,t.y=this.current.y+t.y),t},this.addMarker=function(t,e,i){null!=i&&0<this.angles.length&&null==this.angles[this.angles.length-1]&&(this.angles[this.angles.length-1]=this.points[this.points.length-1].angleTo(i)),this.addMarkerAngle(t,null==e?null:e.angleTo(t))},this.addMarkerAngle=function(t,e){this.points.push(t),this.angles.push(e)},this.getMarkerPoints=function(){return this.points},this.getMarkerAngles=function(){for(var t=0;t<this.angles.length;t++)if(null==this.angles[t])for(var e=t+1;e<this.angles.length;e++)if(null!=this.angles[e]){this.angles[t]=this.angles[e];break}return this.angles}}(t),this.path=function(t){var e=this.PathParser;e.reset();var i=new p.BoundingBox;for(null!=t&&t.beginPath();!e.isEnd();)switch(e.nextCommand(),e.command.toUpperCase()){case"M":var n=e.getAsCurrentPoint();for(e.addMarker(n),i.addPoint(n.x,n.y),null!=t&&t.moveTo(n.x,n.y),e.start=e.current;!e.isCommandOrEnd();)n=e.getAsCurrentPoint(),e.addMarker(n,e.start),i.addPoint(n.x,n.y),null!=t&&t.lineTo(n.x,n.y);break;case"L":for(;!e.isCommandOrEnd();){var s=e.current;n=e.getAsCurrentPoint();e.addMarker(n,s),i.addPoint(n.x,n.y),null!=t&&t.lineTo(n.x,n.y)}break;case"H":for(;!e.isCommandOrEnd();)n=new p.Point((e.isRelativeCommand()?e.current.x:0)+e.getScalar(),e.current.y),e.addMarker(n,e.current),e.current=n,i.addPoint(e.current.x,e.current.y),null!=t&&t.lineTo(e.current.x,e.current.y);break;case"V":for(;!e.isCommandOrEnd();)n=new p.Point(e.current.x,(e.isRelativeCommand()?e.current.y:0)+e.getScalar()),e.addMarker(n,e.current),e.current=n,i.addPoint(e.current.x,e.current.y),null!=t&&t.lineTo(e.current.x,e.current.y);break;case"C":for(;!e.isCommandOrEnd();){var a=e.current,r=(s=e.getPoint(),e.getAsControlPoint());n=e.getAsCurrentPoint();e.addMarker(n,r,s),i.addBezierCurve(a.x,a.y,s.x,s.y,r.x,r.y,n.x,n.y),null!=t&&t.bezierCurveTo(s.x,s.y,r.x,r.y,n.x,n.y)}break;case"S":for(;!e.isCommandOrEnd();)a=e.current,s=e.getReflectedControlPoint(),r=e.getAsControlPoint(),n=e.getAsCurrentPoint(),e.addMarker(n,r,s),i.addBezierCurve(a.x,a.y,s.x,s.y,r.x,r.y,n.x,n.y),null!=t&&t.bezierCurveTo(s.x,s.y,r.x,r.y,n.x,n.y);break;case"Q":for(;!e.isCommandOrEnd();)a=e.current,r=e.getAsControlPoint(),n=e.getAsCurrentPoint(),e.addMarker(n,r,r),i.addQuadraticCurve(a.x,a.y,r.x,r.y,n.x,n.y),null!=t&&t.quadraticCurveTo(r.x,r.y,n.x,n.y);break;case"T":for(;!e.isCommandOrEnd();)a=e.current,r=e.getReflectedControlPoint(),e.control=r,n=e.getAsCurrentPoint(),e.addMarker(n,r,r),i.addQuadraticCurve(a.x,a.y,r.x,r.y,n.x,n.y),null!=t&&t.quadraticCurveTo(r.x,r.y,n.x,n.y);break;case"A":for(;!e.isCommandOrEnd();){a=e.current;var o=e.getScalar(),l=e.getScalar(),h=(s=e.getScalar()*(Math.PI/180),e.getScalar()),u=(r=e.getScalar(),n=e.getAsCurrentPoint(),new p.Point(Math.cos(s)*(a.x-n.x)/2+Math.sin(s)*(a.y-n.y)/2,-Math.sin(s)*(a.x-n.x)/2+Math.cos(s)*(a.y-n.y)/2));1<(d=Math.pow(u.x,2)/Math.pow(o,2)+Math.pow(u.y,2)/Math.pow(l,2))&&(o*=Math.sqrt(d),l*=Math.sqrt(d)),h=(h==r?-1:1)*Math.sqrt((Math.pow(o,2)*Math.pow(l,2)-Math.pow(o,2)*Math.pow(u.y,2)-Math.pow(l,2)*Math.pow(u.x,2))/(Math.pow(o,2)*Math.pow(u.y,2)+Math.pow(l,2)*Math.pow(u.x,2))),isNaN(h)&&(h=0);function c(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(m(t,e))}var d,f=new p.Point(h*o*u.y/l,h*-l*u.x/o),m=(a=new p.Point((a.x+n.x)/2+Math.cos(s)*f.x-Math.sin(s)*f.y,(a.y+n.y)/2+Math.sin(s)*f.x+Math.cos(s)*f.y),function(t,e){return(t[0]*e[0]+t[1]*e[1])/(Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))*Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)))});h=c([1,0],[(u.x-f.x)/o,(u.y-f.y)/l]),u=c(d=[(u.x-f.x)/o,(u.y-f.y)/l],f=[(-u.x-f.x)/o,(-u.y-f.y)/l]);m(d,f)<=-1&&(u=Math.PI),1<=m(d,f)&&(u=0),0==r&&0<u&&(u-=2*Math.PI),1==r&&u<0&&(u+=2*Math.PI),d=new p.Point(a.x-o*Math.cos((h+u)/2),a.y-l*Math.sin((h+u)/2)),e.addMarkerAngle(d,(h+u)/2+(0==r?1:-1)*Math.PI/2),e.addMarkerAngle(n,u+(0==r?1:-1)*Math.PI/2),i.addPoint(n.x,n.y),null!=t&&(m=l<o?o:l,n=l<o?1:o/l,o=l<o?l/o:1,t.translate(a.x,a.y),t.rotate(s),t.scale(n,o),t.arc(0,0,m,h,h+u,1-r),t.scale(1/n,1/o),t.rotate(-s),t.translate(-a.x,-a.y))}break;case"Z":null!=t&&t.closePath(),e.current=e.start}return i},this.getMarkers=function(){for(var t=this.PathParser.getMarkerPoints(),e=this.PathParser.getMarkerAngles(),i=[],n=0;n<t.length;n++)i.push([t[n],e[n]]);return i}},p.Element.path.prototype=new p.Element.PathElementBase,p.Element.pattern=function(t){this.base=p.Element.ElementBase,this.base(t),this.createPattern=function(t){var e=new p.Element.svg;e.attributes.viewBox=new p.Property("viewBox",this.attribute("viewBox").value),e.attributes.x=new p.Property("x",this.attribute("x").value),e.attributes.y=new p.Property("y",this.attribute("y").value),e.attributes.width=new p.Property("width",this.attribute("width").value),e.attributes.height=new p.Property("height",this.attribute("height").value),e.children=this.children;var i=document.createElement("canvas");return i.width=this.attribute("width").Length.toPixels("x"),i.height=this.attribute("height").Length.toPixels("y"),e.render(i.getContext("2d")),t.createPattern(i,"repeat")}},p.Element.pattern.prototype=new p.Element.ElementBase,p.Element.marker=function(t){this.base=p.Element.ElementBase,this.base(t),this.baseRender=this.render,this.render=function(t,e,i){t.translate(e.x,e.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 n=new p.Element.svg;n.attributes.viewBox=new p.Property("viewBox",this.attribute("viewBox").value),n.attributes.refX=new p.Property("refX",this.attribute("refX").value),n.attributes.refY=new p.Property("refY",this.attribute("refY").value),n.attributes.width=new p.Property("width",this.attribute("markerWidth").value),n.attributes.height=new p.Property("height",this.attribute("markerHeight").value),n.attributes.fill=new p.Property("fill",this.attribute("fill").valueOrDefault("black")),n.attributes.stroke=new p.Property("stroke",this.attribute("stroke").valueOrDefault("none")),n.children=this.children,n.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(-e.x,-e.y)}},p.Element.marker.prototype=new p.Element.ElementBase,p.Element.defs=function(t){this.base=p.Element.ElementBase,this.base(t),this.render=function(){}},p.Element.defs.prototype=new p.Element.ElementBase,p.Element.GradientBase=function(t){for(this.base=p.Element.ElementBase,this.base(t),this.gradientUnits=this.attribute("gradientUnits").valueOrDefault("objectBoundingBox"),this.stops=[],t=0;t<this.children.length;t++)this.stops.push(this.children[t]);this.getGradient=function(){},this.createGradient=function(t,e){var i=this;this.attribute("xlink:href").hasValue()&&(i=this.attribute("xlink:href").Definition.getDefinition());for(var n=this.getGradient(t,e),s=0;s<i.stops.length;s++)n.addColorStop(i.stops[s].offset,i.stops[s].color);if(this.attribute("gradientTransform").hasValue()){i=p.ViewPort.viewPorts[0],(s=new p.Element.rect).attributes.x=new p.Property("x",-p.MAX_VIRTUAL_PIXELS/3),s.attributes.y=new p.Property("y",-p.MAX_VIRTUAL_PIXELS/3),s.attributes.width=new p.Property("width",p.MAX_VIRTUAL_PIXELS),s.attributes.height=new p.Property("height",p.MAX_VIRTUAL_PIXELS);var a=new p.Element.g;return a.attributes.transform=new p.Property("transform",this.attribute("gradientTransform").value),a.children=[s],(s=new p.Element.svg).attributes.x=new p.Property("x",0),s.attributes.y=new p.Property("y",0),s.attributes.width=new p.Property("width",i.width),s.attributes.height=new p.Property("height",i.height),s.children=[a],(a=document.createElement("canvas")).width=i.width,a.height=i.height,(i=a.getContext("2d")).fillStyle=n,s.render(i),i.createPattern(a,"no-repeat")}return n}},p.Element.GradientBase.prototype=new p.Element.ElementBase,p.Element.linearGradient=function(t){this.base=p.Element.GradientBase,this.base(t),this.getGradient=function(t,e){var i=e.getBoundingBox(),n="objectBoundingBox"==this.gradientUnits?i.x()+i.width()*this.attribute("x1").numValue():this.attribute("x1").Length.toPixels("x"),s="objectBoundingBox"==this.gradientUnits?i.y()+i.height()*this.attribute("y1").numValue():this.attribute("y1").Length.toPixels("y"),a="objectBoundingBox"==this.gradientUnits?i.x()+i.width()*this.attribute("x2").numValue():this.attribute("x2").Length.toPixels("x");i="objectBoundingBox"==this.gradientUnits?i.y()+i.height()*this.attribute("y2").numValue():this.attribute("y2").Length.toPixels("y");return t.createLinearGradient(n,s,a,i)}},p.Element.linearGradient.prototype=new p.Element.GradientBase,p.Element.radialGradient=function(t){this.base=p.Element.GradientBase,this.base(t),this.getGradient=function(t,e){var i=e.getBoundingBox(),n="objectBoundingBox"==this.gradientUnits?i.x()+i.width()*this.attribute("cx").numValue():this.attribute("cx").Length.toPixels("x"),s="objectBoundingBox"==this.gradientUnits?i.y()+i.height()*this.attribute("cy").numValue():this.attribute("cy").Length.toPixels("y"),a=n,r=s;return this.attribute("fx").hasValue()&&(a="objectBoundingBox"==this.gradientUnits?i.x()+i.width()*this.attribute("fx").numValue():this.attribute("fx").Length.toPixels("x")),this.attribute("fy").hasValue()&&(r="objectBoundingBox"==this.gradientUnits?i.y()+i.height()*this.attribute("fy").numValue():this.attribute("fy").Length.toPixels("y")),i="objectBoundingBox"==this.gradientUnits?(i.width()+i.height())/2*this.attribute("r").numValue():this.attribute("r").Length.toPixels(),t.createRadialGradient(a,r,0,n,s,i)}},p.Element.radialGradient.prototype=new p.Element.GradientBase,p.Element.stop=function(t){this.base=p.Element.ElementBase,this.base(t),this.offset=this.attribute("offset").numValue(),t=this.style("stop-color"),this.style("stop-opacity").hasValue()&&(t=t.Color.addOpacity(this.style("stop-opacity").value)),this.color=t.value},p.Element.stop.prototype=new p.Element.ElementBase,p.Element.AnimateBase=function(t){this.base=p.Element.ElementBase,this.base(t),p.Animations.push(this),this.duration=0,this.begin=this.attribute("begin").Time.toMilliseconds(),this.maxDuration=this.begin+this.attribute("dur").Time.toMilliseconds(),this.getProperty=function(){var t=this.attribute("attributeType").value,e=this.attribute("attributeName").value;return"CSS"==t?this.parent.style(e,!0):this.parent.attribute(e,!0)},this.initialValue=null,this.removed=!1,this.calcValue=function(){return""},this.update=function(t){if(null==this.initialValue&&(this.initialValue=this.getProperty().value),this.duration>this.maxDuration){if("indefinite"!=this.attribute("repeatCount").value)return"remove"==this.attribute("fill").valueOrDefault("remove")&&!this.removed&&(this.removed=!0,this.getProperty().value=this.initialValue,!0);this.duration=0}return this.duration+=t,t=!1,this.begin<this.duration&&(t=this.calcValue(),this.attribute("type").hasValue()&&(t=this.attribute("type").value+"("+t+")"),this.getProperty().value=t,t=!0),t},this.progress=function(){return(this.duration-this.begin)/(this.maxDuration-this.begin)}},p.Element.AnimateBase.prototype=new p.Element.ElementBase,p.Element.animate=function(t){this.base=p.Element.AnimateBase,this.base(t),this.calcValue=function(){var t=this.attribute("from").numValue();return t+(this.attribute("to").numValue()-t)*this.progress()}},p.Element.animate.prototype=new p.Element.AnimateBase,p.Element.animateColor=function(t){this.base=p.Element.AnimateBase,this.base(t),this.calcValue=function(){var t=new RGBColor(this.attribute("from").value),e=new RGBColor(this.attribute("to").value);if(t.ok&&e.ok){var i=t.r+(e.r-t.r)*this.progress(),n=t.g+(e.g-t.g)*this.progress();t=t.b+(e.b-t.b)*this.progress();return"rgb("+parseInt(i,10)+","+parseInt(n,10)+","+parseInt(t,10)+")"}return this.attribute("from").value}},p.Element.animateColor.prototype=new p.Element.AnimateBase,p.Element.animateTransform=function(t){this.base=p.Element.animate,this.base(t)},p.Element.animateTransform.prototype=new p.Element.animate,p.Element.font=function(t){for(this.base=p.Element.ElementBase,this.base(t),this.horizAdvX=this.attribute("horiz-adv-x").numValue(),this.isArabic=this.isRTL=!1,this.missingGlyph=this.fontFace=null,this.glyphs=[],t=0;t<this.children.length;t++){var e=this.children[t];"font-face"==e.type?(this.fontFace=e).style("font-family").hasValue()&&(p.Definitions[e.style("font-family").value]=this):"missing-glyph"==e.type?this.missingGlyph=e:"glyph"==e.type&&(""!=e.arabicForm?(this.isArabic=this.isRTL=!0,void 0===this.glyphs[e.unicode]&&(this.glyphs[e.unicode]=[]),this.glyphs[e.unicode][e.arabicForm]=e):this.glyphs[e.unicode]=e)}},p.Element.font.prototype=new p.Element.ElementBase,p.Element.fontface=function(t){this.base=p.Element.ElementBase,this.base(t),this.ascent=this.attribute("ascent").value,this.descent=this.attribute("descent").value,this.unitsPerEm=this.attribute("units-per-em").numValue()},p.Element.fontface.prototype=new p.Element.ElementBase,p.Element.missingglyph=function(t){this.base=p.Element.path,this.base(t),this.horizAdvX=0},p.Element.missingglyph.prototype=new p.Element.path,p.Element.glyph=function(t){this.base=p.Element.path,this.base(t),this.horizAdvX=this.attribute("horiz-adv-x").numValue(),this.unicode=this.attribute("unicode").value,this.arabicForm=this.attribute("arabic-form").value},p.Element.glyph.prototype=new p.Element.path,p.Element.text=function(t){if(this.base=p.Element.RenderedElementBase,this.base(t),null!=t){this.children=[];for(var e=0;e<t.childNodes.length;e++){var i=t.childNodes[e];1==i.nodeType?this.addChild(i,!0):3==i.nodeType&&this.addChild(new p.Element.tspan(i),!1)}}this.baseSetContext=this.setContext,this.setContext=function(t){this.baseSetContext(t),this.style("dominant-baseline").hasValue()&&(t.textBaseline=this.style("dominant-baseline").value),this.style("alignment-baseline").hasValue()&&(t.textBaseline=this.style("alignment-baseline").value)},this.renderChildren=function(t){for(var e=this.style("text-anchor").valueOrDefault("start"),i=this.attribute("x").Length.toPixels("x"),n=this.attribute("y").Length.toPixels("y"),s=0;s<this.children.length;s++){var a=this.children[s];if(a.attribute("x").hasValue()?a.x=a.attribute("x").Length.toPixels("x"):(a.attribute("dx").hasValue()&&(i+=a.attribute("dx").Length.toPixels("x")),a.x=i),i=a.measureText(t),"start"!=e&&(0==s||a.attribute("x").hasValue())){for(var r=i,o=s+1;o<this.children.length;o++){var l=this.children[o];if(l.attribute("x").hasValue())break;r+=l.measureText(t)}a.x-="end"==e?r:r/2}i=a.x+i,a.attribute("y").hasValue()?a.y=a.attribute("y").Length.toPixels("y"):(a.attribute("dy").hasValue()&&(n+=a.attribute("dy").Length.toPixels("y")),a.y=n),n=a.y,a.render(t)}}},p.Element.text.prototype=new p.Element.RenderedElementBase,p.Element.TextElementBase=function(t){this.base=p.Element.RenderedElementBase,this.base(t),this.getGlyph=function(t,e,i){var n=e[i],s=null;if(t.isArabic){var a="isolated";(0==i||" "==e[i-1])&&i<e.length-2&&" "!=e[i+1]&&(a="terminal"),0<i&&" "!=e[i-1]&&i<e.length-2&&" "!=e[i+1]&&(a="medial"),0<i&&" "!=e[i-1]&&(i==e.length-1||" "==e[i+1])&&(a="initial"),void 0!==t.glyphs[n]&&(null==(s=t.glyphs[n][a])&&"glyph"==t.glyphs[n].type&&(s=t.glyphs[n]))}else s=t.glyphs[n];return null==s&&(s=t.missingGlyph),s},this.renderChildren=function(t){var e=this.parent.style("font-family").Definition.getDefinition();if(null!=e){var i=this.parent.style("font-size").numValueOrDefault(p.Font.Parse(p.ctx.font).fontSize),n=this.parent.style("font-style").valueOrDefault(p.Font.Parse(p.ctx.font).fontStyle),s=this.getText();e.isRTL&&(s=s.split("").reverse().join(""));for(var a=p.ToNumberArray(this.parent.attribute("dx").value),r=0;r<s.length;r++){var o=this.getGlyph(e,s,r),l=i/e.fontFace.unitsPerEm;t.translate(this.x,this.y),t.scale(l,-l);var h=t.lineWidth;t.lineWidth=t.lineWidth*e.fontFace.unitsPerEm/i,"italic"==n&&t.transform(1,0,.4,1,0,0),o.render(t),"italic"==n&&t.transform(1,0,-.4,1,0,0),t.lineWidth=h,t.scale(1/l,-1/l),t.translate(-this.x,-this.y),this.x+=i*(o.horizAdvX||e.horizAdvX)/e.fontFace.unitsPerEm,void 0===a[r]||isNaN(a[r])||(this.x+=a[r])}}else""!=t.strokeStyle&&t.strokeText(p.compressSpaces(this.getText()),this.x,this.y),""!=t.fillStyle&&t.fillText(p.compressSpaces(this.getText()),this.x,this.y)},this.getText=function(){},this.measureText=function(t){var e=this.parent.style("font-family").Definition.getDefinition();if(null==e)return e=p.compressSpaces(this.getText()),t.measureText?(t.save(),this.setContext(t),e=t.measureText(e).width,t.restore(),e):10*e.length;t=this.parent.style("font-size").numValueOrDefault(p.Font.Parse(p.ctx.font).fontSize);var i=0,n=this.getText();e.isRTL&&(n=n.split("").reverse().join(""));for(var s=p.ToNumberArray(this.parent.attribute("dx").value),a=0;a<n.length;a++){i+=(this.getGlyph(e,n,a).horizAdvX||e.horizAdvX)*t/e.fontFace.unitsPerEm,void 0===s[a]||isNaN(s[a])||(i+=s[a])}return i}},p.Element.TextElementBase.prototype=new p.Element.RenderedElementBase,p.Element.tspan=function(t){this.base=p.Element.TextElementBase,this.base(t),this.text=3==t.nodeType?t.nodeValue:0<t.childNodes.length?t.childNodes[0].nodeValue:t.text,this.getText=function(){return this.text}},p.Element.tspan.prototype=new p.Element.TextElementBase,p.Element.tref=function(t){this.base=p.Element.TextElementBase,this.base(t),this.getText=function(){var t=this.attribute("xlink:href").Definition.getDefinition();if(null!=t)return t.children[0].getText()}},p.Element.tref.prototype=new p.Element.TextElementBase,p.Element.a=function(t){this.base=p.Element.TextElementBase,this.base(t),this.hasText=!0;for(var e=0;e<t.childNodes.length;e++)3!=t.childNodes[e].nodeType&&(this.hasText=!1);this.text=this.hasText?t.childNodes[0].nodeValue:"",this.getText=function(){return this.text},this.baseRenderChildren=this.renderChildren,this.renderChildren=function(t){if(this.hasText){this.baseRenderChildren(t);var e=new p.Property("fontSize",p.Font.Parse(p.ctx.font).fontSize);p.Mouse.checkBoundingBox(this,new p.BoundingBox(this.x,this.y-e.Length.toPixels("y"),this.x+this.measureText(t),this.y))}else(e=new p.Element.g).children=this.children,e.parent=this,e.render(t)},this.onclick=function(){window.open(this.attribute("xlink:href").value)},this.onmousemove=function(){p.ctx.canvas.style.cursor="pointer"}},p.Element.a.prototype=new p.Element.TextElementBase,p.Element.image=function(t){this.base=p.Element.RenderedElementBase,this.base(t),p.Images.push(this),this.img=document.createElement("img"),this.loaded=!1;var e=this;this.img.onload=function(){e.loaded=!0},this.img.src=this.attribute("xlink:href").value,this.renderChildren=function(t){var e=this.attribute("x").Length.toPixels("x"),i=this.attribute("y").Length.toPixels("y"),n=this.attribute("width").Length.toPixels("x"),s=this.attribute("height").Length.toPixels("y");0==n||0==s||(t.save(),t.translate(e,i),p.AspectRatio(t,this.attribute("preserveAspectRatio").value,n,this.img.width,s,this.img.height,0,0),t.drawImage(this.img,0,0),t.restore())}},p.Element.image.prototype=new p.Element.RenderedElementBase,p.Element.g=function(t){this.base=p.Element.RenderedElementBase,this.base(t),this.getBoundingBox=function(){for(var t=new p.BoundingBox,e=0;e<this.children.length;e++)t.addBoundingBox(this.children[e].getBoundingBox());return t}},p.Element.g.prototype=new p.Element.RenderedElementBase,p.Element.symbol=function(t){this.base=p.Element.RenderedElementBase,this.base(t),this.baseSetContext=this.setContext,this.setContext=function(t){if(this.baseSetContext(t),this.attribute("viewBox").hasValue()){var e=p.ToNumberArray(this.attribute("viewBox").value),i=e[0],n=e[1];width=e[2],height=e[3],p.AspectRatio(t,this.attribute("preserveAspectRatio").value,this.attribute("width").Length.toPixels("x"),width,this.attribute("height").Length.toPixels("y"),height,i,n),p.ViewPort.SetCurrent(e[2],e[3])}}},p.Element.symbol.prototype=new p.Element.RenderedElementBase,p.Element.style=function(t){this.base=p.Element.ElementBase,this.base(t);t=(t=t.childNodes[0].nodeValue+(1<t.childNodes.length?t.childNodes[1].nodeValue:"")).replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,""),t=(t=p.compressSpaces(t)).split("}");for(var e=0;e<t.length;e++)if(""!=p.trim(t[e]))for(var i=(n=t[e].split("{"))[0].split(","),n=n[1].split(";"),s=0;s<i.length;s++){var a=p.trim(i[s]);if(""!=a){for(var r={},o=0;o<n.length;o++){var l=n[o].indexOf(":"),h=n[o].substr(0,l);l=n[o].substr(l+1,n[o].length-l);null!=h&&null!=l&&(r[p.trim(h)]=new p.Property(p.trim(h),p.trim(l)))}if(p.Styles[a]=r,"@font-face"==a)for(a=r["font-family"].value.replace(/"/g,""),r=r.src.value.split(","),o=0;o<r.length;o++)if(0<r[o].indexOf('format("svg")'))for(h=r[o].indexOf("url"),l=r[o].indexOf(")",h),h=r[o].substr(h+5,l-h-6),h=p.parseXml(p.ajax(h)).getElementsByTagName("font"),l=0;l<h.length;l++){var u=p.CreateElement(h[l]);p.Definitions[a]=u}}}},p.Element.style.prototype=new p.Element.ElementBase,p.Element.use=function(t){this.base=p.Element.RenderedElementBase,this.base(t),this.baseSetContext=this.setContext,this.setContext=function(t){this.baseSetContext(t),this.attribute("x").hasValue()&&t.translate(this.attribute("x").Length.toPixels("x"),0),this.attribute("y").hasValue()&&t.translate(0,this.attribute("y").Length.toPixels("y"))},this.getDefinition=function(){var t=this.attribute("xlink:href").Definition.getDefinition();return this.attribute("width").hasValue()&&(t.attribute("width",!0).value=this.attribute("width").value),this.attribute("height").hasValue()&&(t.attribute("height",!0).value=this.attribute("height").value),t},this.path=function(t){var e=this.getDefinition();null!=e&&e.path(t)},this.renderChildren=function(t){var e=this.getDefinition();null!=e&&e.render(t)}},p.Element.use.prototype=new p.Element.RenderedElementBase,p.Element.mask=function(t){this.base=p.Element.ElementBase,this.base(t),this.apply=function(t,e){var i=this.attribute("x").Length.toPixels("x"),n=this.attribute("y").Length.toPixels("y"),s=this.attribute("width").Length.toPixels("x"),a=this.attribute("height").Length.toPixels("y"),r=e.attribute("mask").value;e.attribute("mask").value="";var o=document.createElement("canvas");o.width=i+s,o.height=n+a;var l=o.getContext("2d");this.renderChildren(l);var h=document.createElement("canvas");h.width=i+s,h.height=n+a;var u=h.getContext("2d");e.render(u),u.globalCompositeOperation="destination-in",u.fillStyle=l.createPattern(o,"no-repeat"),u.fillRect(0,0,i+s,n+a),t.fillStyle=u.createPattern(h,"no-repeat"),t.fillRect(0,0,i+s,n+a),e.attribute("mask").value=r},this.render=function(){}},p.Element.mask.prototype=new p.Element.ElementBase,p.Element.clipPath=function(t){this.base=p.Element.ElementBase,this.base(t),this.apply=function(t){for(var e=0;e<this.children.length;e++)this.children[e].path&&(this.children[e].path(t),t.clip())},this.render=function(){}},p.Element.clipPath.prototype=new p.Element.ElementBase,p.Element.filter=function(t){this.base=p.Element.ElementBase,this.base(t),this.apply=function(t,e){var i=e.getBoundingBox(),n=this.attribute("x").Length.toPixels("x"),s=this.attribute("y").Length.toPixels("y");0!=n&&0!=s||(n=i.x1,s=i.y1);var a=this.attribute("width").Length.toPixels("x"),r=this.attribute("height").Length.toPixels("y");0!=a&&0!=r||(a=i.width(),r=i.height()),i=e.style("filter").value,e.style("filter").value="";var o=.2*a,l=.2*r,h=document.createElement("canvas");h.width=a+2*o,h.height=r+2*l;var u=h.getContext("2d");u.translate(o-n,l-s),e.render(u);for(var c=0;c<this.children.length;c++)this.children[c].apply(u,0,0,a+2*o,r+2*l);t.drawImage(h,0,0,a+2*o,r+2*l,n-o,s-l,a+2*o,r+2*l),e.style("filter",!0).value=i},this.render=function(){}},p.Element.filter.prototype=new p.Element.ElementBase,p.Element.feGaussianBlur=function(t){function o(t,e,i,n,s){for(var a=0;a<s;a++)for(var r=0;r<n;r++)for(var o=t[a*n*4+4*r+3]/255,l=0;l<4;l++){for(var h=i[0]*(0==o?255:t[a*n*4+4*r+l])*(0==o||3==l?1:o),u=1;u<i.length;u++){var c=t[a*n*4+4*(d=Math.max(r-u,0))+3]/255,d=t[a*n*4+4*(d=Math.min(r+u,n-1))+3]/255;h+=i[u]*((c=(0==c?255:t[a*n*4+4*Math.max(r-u,0)+l])*(0==c||3==l?1:c))+(0==d?255:t[a*n*4+4*Math.min(r+u,n-1)+l])*(0==d||3==l?1:d))}e[r*s*4+4*a+l]=h}}this.base=p.Element.ElementBase,this.base(t),this.apply=function(t,e,i,n,s){i=this.attribute("stdDeviation").numValue(),e=t.getImageData(0,0,n,s),i=Math.max(i,.01);var a=Math.ceil(4*i)+1;mask=[];for(var r=0;r<a;r++)mask[r]=Math.exp(r/i*-.5*(r/i));for(i=mask,a=0,r=1;r<i.length;r++)a+=Math.abs(i[r]);for(a=2*a+Math.abs(i[0]),r=0;r<i.length;r++)i[r]/=a;tmp=[],o(e.data,tmp,i,n,s),o(tmp,e.data,i,s,n),t.clearRect(0,0,n,s),t.putImageData(e,0,0)}},p.Element.filter.prototype=new p.Element.feGaussianBlur,p.Element.title=function(){},p.Element.title.prototype=new p.Element.ElementBase,p.Element.desc=function(){},p.Element.desc.prototype=new p.Element.ElementBase,p.Element.MISSING=function(t){console.log("ERROR: Element '"+t.nodeName+"' not yet implemented.")},p.Element.MISSING.prototype=new p.Element.ElementBase,p.CreateElement=function(t){var e=(e=t.nodeName.replace(/^[^:]+:/,"")).replace(/\-/g,""),i=null;return(i=void 0!==p.Element[e]?new p.Element[e](t):new p.Element.MISSING(t)).type=t.nodeName,i},p.load=function(t,e){p.loadXml(t,p.ajax(e))},p.loadXml=function(t,e){p.loadXmlDoc(t,p.parseXml(e))},p.loadXmlDoc=function(s,t){p.init(s);function e(t){for(var e=s.canvas;e;)t.x-=e.offsetLeft,t.y-=e.offsetTop,e=e.offsetParent;return window.scrollX&&(t.x+=window.scrollX),window.scrollY&&(t.y+=window.scrollY),t}1!=p.opts.ignoreMouse&&(s.canvas.onclick=function(t){t=e(new p.Point(null!=t?t.clientX:event.clientX,null!=t?t.clientY:event.clientY)),p.Mouse.onclick(t.x,t.y)},s.canvas.onmousemove=function(t){t=e(new p.Point(null!=t?t.clientX:event.clientX,null!=t?t.clientY:event.clientY)),p.Mouse.onmousemove(t.x,t.y)});function i(){p.ViewPort.Clear(),s.canvas.parentNode&&p.ViewPort.SetCurrent(s.canvas.parentNode.clientWidth,s.canvas.parentNode.clientHeight),1!=p.opts.ignoreDimensions&&(a.style("width").hasValue()&&(s.canvas.width=a.style("width").Length.toPixels("x"),s.canvas.style.width=s.canvas.width+"px"),a.style("height").hasValue()&&(s.canvas.height=a.style("height").Length.toPixels("y"),s.canvas.style.height=s.canvas.height+"px"));var t=s.canvas.clientWidth||s.canvas.width,e=s.canvas.clientHeight||s.canvas.height;if(p.ViewPort.SetCurrent(t,e),null!=p.opts&&null!=p.opts.offsetX&&(a.attribute("x",!0).value=p.opts.offsetX),null!=p.opts&&null!=p.opts.offsetY&&(a.attribute("y",!0).value=p.opts.offsetY),null!=p.opts&&null!=p.opts.scaleWidth&&null!=p.opts.scaleHeight){var i=1,n=1;a.attribute("width").hasValue()&&(i=a.attribute("width").Length.toPixels("x")/p.opts.scaleWidth),a.attribute("height").hasValue()&&(n=a.attribute("height").Length.toPixels("y")/p.opts.scaleHeight),a.attribute("width",!0).value=p.opts.scaleWidth,a.attribute("height",!0).value=p.opts.scaleHeight,a.attribute("viewBox",!0).value="0 0 "+t*i+" "+e*n,a.attribute("preserveAspectRatio",!0).value="none"}1!=p.opts.ignoreClear&&s.clearRect(0,0,t,e),a.render(s),r&&(r=!1,null!=p.opts&&"function"==typeof p.opts.renderCallback&&p.opts.renderCallback())}var a=p.CreateElement(t.documentElement),r=a.root=!0,n=!0;p.ImagesLoaded()&&(n=!1,i()),p.intervalID=setInterval(function(){var t=!1;if(n&&p.ImagesLoaded()&&(t=!(n=!1)),1!=p.opts.ignoreMouse&&(t|=p.Mouse.hasEvents()),1!=p.opts.ignoreAnimation)for(var e=0;e<p.Animations.length;e++)t|=p.Animations[e].update(1e3/p.FRAMERATE);null!=p.opts&&"function"==typeof p.opts.forceRedraw&&1==p.opts.forceRedraw()&&(t=!0),t&&(i(),p.Mouse.runEvents())},1e3/p.FRAMERATE)},p.stop=function(){p.intervalID&&clearInterval(p.intervalID)},p.Mouse=new function(){this.events=[],this.hasEvents=function(){return 0!=this.events.length},this.onclick=function(t,e){this.events.push({type:"onclick",x:t,y:e,run:function(t){t.onclick&&t.onclick()}})},this.onmousemove=function(t,e){this.events.push({type:"onmousemove",x:t,y:e,run:function(t){t.onmousemove&&t.onmousemove()}})},this.eventElements=[],this.checkPath=function(t,e){for(var i=0;i<this.events.length;i++){var n=this.events[i];e.isPointInPath&&e.isPointInPath(n.x,n.y)&&(this.eventElements[i]=t)}},this.checkBoundingBox=function(t,e){for(var i=0;i<this.events.length;i++){var n=this.events[i];e.isPointInBox(n.x,n.y)&&(this.eventElements[i]=t)}},this.runEvents=function(){p.ctx.canvas.style.cursor="";for(var t=0;t<this.events.length;t++)for(var e=this.events[t],i=this.eventElements[t];i;)e.run(i),i=i.parent;this.events=[],this.eventElements=[]}},p}this.canvg=function(t,e,i){if(null==t&&null==e&&null==i){e=document.getElementsByTagName("svg");for(var n=0;n<e.length;n++){t=e[n],(i=document.createElement("canvas")).width=t.clientWidth,i.height=t.clientHeight,t.parentNode.insertBefore(i,t),t.parentNode.removeChild(t);var s=document.createElement("div");s.appendChild(t),canvg(i,s.innerHTML)}}else i=i||{},"string"==typeof t&&(t=document.getElementById(t)),null==t.svg?(n=a(),t.svg=n):(n=t.svg).stop(),n.opts=i,t=t.getContext("2d"),void 0!==e.documentElement?n.loadXmlDoc(t,e):"<"==e.substr(0,1)?n.loadXml(t,e):n.load(t,e)}}(),CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.drawSvg=function(t,e,i,n,s){canvg(this.canvas,t,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:e,offsetY:i,scaleWidth:n,scaleHeight:s})}),function(t){var l=t.css,e=t.CanVGRenderer,n=t.SVGRenderer,i=t.extend,h=t.merge,u=t.addEvent,c=t.createElement,s=t.discardElement;i(e.prototype,n.prototype),i(e.prototype,{create:function(t,e,i,n){this.setContainer(e,i,n),this.configure(t)},setContainer:function(t,e,i){var n=t.style,s=t.parentNode,a=n.left,r=(n=n.top,t.offsetWidth),o=t.offsetHeight,l={visibility:"hidden",position:"absolute"};this.init.apply(this,[t,e,i]),this.canvas=c("canvas",{width:r,height:o},{position:"relative",left:a,top:n},t),this.ttLine=c("div",null,l,s),this.ttDiv=c("div",null,l,s),this.ttTimer=void 0,this.hiddenSvg=t=c("div",{width:r,height:o},{visibility:"hidden",left:a,top:n},s),t.appendChild(this.box)},configure:function(s){var a=this,t=s.options.tooltip,e=t.borderWidth,r=a.ttDiv,i=t.style,o=a.ttLine,n=parseInt(i.padding,10);i=h(i,{padding:n+"px","background-color":t.backgroundColor,"border-style":"solid","border-width":e+"px","border-radius":t.borderRadius+"px"});t.shadow&&(i=h(i,{"box-shadow":"1px 1px 3px gray","-webkit-box-shadow":"1px 1px 3px gray"})),l(r,i),l(o,{"border-left":"1px solid darkgray"}),u(s,"tooltipRefresh",function(t){var e,i=(n=s.container).offsetLeft,n=n.offsetTop;r.innerHTML=t.text,e=s.tooltip.getPosition(r.offsetWidth,r.offsetHeight,{plotX:t.x,plotY:t.y}),l(r,{visibility:"visible",left:e.x+"px",top:e.y+"px","border-color":t.borderColor}),l(o,{visibility:"visible",left:i+t.x+"px",top:n+s.plotTop+"px",height:s.plotHeight+"px"}),void 0!==a.ttTimer&&clearTimeout(a.ttTimer),a.ttTimer=setTimeout(function(){l(r,{visibility:"hidden"}),l(o,{visibility:"hidden"})},3e3)})},destroy:function(){return s(this.canvas),void 0!==this.ttTimer&&clearTimeout(this.ttTimer),s(this.ttLine),s(this.ttDiv),s(this.hiddenSvg),n.prototype.destroy.apply(this)},color:function(t,e,i){return t&&t.linearGradient&&(t=t.stops[t.stops.length-1][1]),n.prototype.color.call(this,t,e,i)},draw:function(){window.canvg(this.canvas,this.hiddenSvg.innerHTML)}})}(Highcharts);