Template:Fudan-CHINA/sf2

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.functionPlot=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){module.exports=require("./lib/")},{"./lib/":14}],2:[function(require,module,exports){var isObject=require("is-object");module.exports=function(d){if(!isObject(d)){throw Error("datum is not an object")}if(!d.hasOwnProperty("graphType")){d.graphType="interval"}if(!d.hasOwnProperty("sampler")){d.sampler=d.graphType!=="interval"?"builtIn":"interval"}if(!d.hasOwnProperty("fnType")){d.fnType="linear"}return d}},{"is-object":52}],3:[function(require,module,exports){"use strict";var globals=require("./globals");var evalTypeFn={interval:require("./samplers/interval"),builtIn:require("./samplers/builtIn")};function computeEndpoints(chart,d){var range=d.range||[-Infinity,Infinity];var scale=chart.meta.xScale;var start=Math.max(scale.domain()[0],range[0]);var end=Math.min(scale.domain()[1],range[1]);return[start,end]}function evaluate(chart,d){var range=computeEndpoints(chart,d);var data;var evalFn=evalTypeFn[d.sampler];var nSamples=d.nSamples||Math.min(globals.MAX_ITERATIONS,globals.DEFAULT_ITERATIONS||chart.meta.width*2);data=evalFn(chart,d,range,nSamples);chart.emit("eval",data,d.index,d.isHelper);return data}module.exports=evaluate},{"./globals":4,"./samplers/builtIn":19,"./samplers/interval":20}],4:[function(require,module,exports){"use strict";var d3=window.d3;var Globals={COLORS:["steelblue","red","#05b378","orange","#4040e8","yellow","brown","magenta","cyan"].map(function(v){return d3.hsl(v)}),DEFAULT_WIDTH:550,DEFAULT_HEIGHT:350,TIP_X_EPS:1};Globals.DEFAULT_ITERATIONS=null;Globals.MAX_ITERATIONS=Globals.DEFAULT_WIDTH*4;module.exports=Globals},{}],5:[function(require,module,exports){"use strict";module.exports={polyline:require("./polyline"),interval:require("./interval"),scatter:require("./scatter")}},{"./interval":6,"./polyline":7,"./scatter":8}],6:[function(require,module,exports){"use strict";var d3=window.d3;var evaluate=require("../evaluate");var utils=require("../utils");module.exports=function(chart){var minWidthHeight;var xScale=chart.meta.xScale;var yScale=chart.meta.yScale;function clampRange(vLo,vHi,gLo,gHi){if(gLo>gHi){var t=gLo;gLo=gHi;gHi=t}var hi=Math.min(vHi,gHi);var lo=Math.max(vLo,gLo);if(lo>hi){return[-minWidthHeight,0]}return[lo,hi]}var line=function(points,closed){var path="";var range=yScale.range();var minY=Math.min.apply(Math,range);var maxY=Math.max.apply(Math,range);for(var i=0,length=points.length;i<length;i+=1){if(points[i]){var x=points[i][0];var y=points[i][1];var yLo=y.lo;var yHi=y.hi;if(closed){yLo=Math.min(yLo,0);yHi=Math.max(yHi,0)}var moveX=xScale(x.lo)+points.scaledDx/2;var viewportY=clampRange(minY,maxY,isFinite(yHi)?yScale(yHi):-Infinity,isFinite(yLo)?yScale(yLo):Infinity);var vLo=viewportY[0];var vHi=viewportY[1];path+=" M "+moveX+" "+vLo;path+=" v "+Math.max(vHi-vLo,minWidthHeight)}}return path};function plotLine(selection){selection.each(function(d){var el=plotLine.el=d3.select(this);var index=d.index;var closed=d.closed;var evaluatedData=evaluate(chart,d);var innerSelection=el.selectAll(":scope > path.line").data(evaluatedData);minWidthHeight=Math.max(evaluatedData[0].scaledDx,1);innerSelection.enter().append("path").attr("class","line line-"+index).attr("fill","none");innerSelection.attr("stroke-width",minWidthHeight).attr("stroke",utils.color(d,index)).attr("opacity",closed?.5:1).attr("d",function(d){return line(d,closed)}).attr(d.attr);innerSelection.exit().remove()})}return plotLine}},{"../evaluate":3,"../utils":22}],7:[function(require,module,exports){"use strict";var d3=window.d3;var evaluate=require("../evaluate");var utils=require("../utils");var clamp=require("clamp");module.exports=function(chart){var xScale=chart.meta.xScale;var yScale=chart.meta.yScale;function plotLine(selection){selection.each(function(d){var el=plotLine.el=d3.select(this);var index=d.index;var evaluatedData=evaluate(chart,d);var color=utils.color(d,index);var innerSelection=el.selectAll(":scope > path.line").data(evaluatedData);var yRange=yScale.range();var yMax=yRange[0]+1;var yMin=yRange[1]-1;if(d.skipBoundsCheck){yMax=Infinity;yMin=-Infinity}function y(d){return clamp(yScale(d[1]),yMin,yMax)}var line=d3.svg.line().interpolate("linear").x(function(d){return xScale(d[0])}).y(y);var area=d3.svg.area().x(function(d){return xScale(d[0])}).y0(yScale(0)).y1(y);innerSelection.enter().append("path").attr("class","line line-"+index).attr("stroke-width",1).attr("stroke-linecap","round");innerSelection.each(function(){var path=d3.select(this);var pathD;if(d.closed){path.attr("fill",color);path.attr("fill-opacity",.3);pathD=area}else{path.attr("fill","none");pathD=line}path.attr("stroke",color).attr("marker-end",function(){return d.fnType==="vector"?"url(#"+chart.markerId+")":null}).attr("d",pathD)}).attr(d.attr);innerSelection.exit().remove()})}return plotLine}},{"../evaluate":3,"../utils":22,clamp:29}],8:[function(require,module,exports){"use strict";var d3=window.d3;var evaluate=require("../evaluate");var utils=require("../utils");module.exports=function(chart){var xScale=chart.meta.xScale;var yScale=chart.meta.yScale;function scatter(selection){selection.each(function(d){var i,j;var index=d.index;var color=utils.color(d,index);var evaluatedData=evaluate(chart,d);var joined=[];for(i=0;i<evaluatedData.length;i+=1){for(j=0;j<evaluatedData[i].length;j+=1){joined.push(evaluatedData[i][j])}}var innerSelection=d3.select(this).selectAll(":scope > circle").data(joined);innerSelection.enter().append("circle");innerSelection.attr("fill",d3.hsl(color.toString()).brighter(1.5)).attr("stroke",color).attr("opacity",.7).attr("r",1).attr("cx",function(d){return xScale(d[0])}).attr("cy",function(d){return yScale(d[1])}).attr(d.attr);innerSelection.exit().remove()})}return scatter}},{"../evaluate":3,"../utils":22}],9:[function(require,module,exports){"use strict";var d3=window.d3;module.exports=function(options){var annotations;var xScale=options.owner.meta.xScale;var yScale=options.owner.meta.yScale;var line=d3.svg.line().x(function(d){return d[0]}).y(function(d){return d[1]});annotations=function(parentSelection){parentSelection.each(function(){var current=d3.select(this);var selection=current.selectAll("g.annotations").data(function(d){return d.annotations||[]});selection.enter().append("g").attr("class","annotations");var yRange=yScale.range();var xRange=xScale.range();var path=selection.selectAll("path").data(function(d){if(d.hasOwnProperty("x")){return[[[0,yRange[0]],[0,yRange[1]]]]}else{return[[[xRange[0],0],[xRange[1],0]]]}});path.enter().append("path").attr("stroke","#eee").attr("d",line);path.exit().remove();var text=selection.selectAll("text").data(function(d){return[{text:d.text||"",hasX:d.hasOwnProperty("x")}]});text.enter().append("text").attr("y",function(d){return d.hasX?3:0}).attr("x",function(d){return d.hasX?0:3}).attr("dy",function(d){return d.hasX?5:-5}).attr("text-anchor",function(d){return d.hasX?"end":""}).attr("transform",function(d){return d.hasX?"rotate(-90)":""}).text(function(d){return d.text});text.exit().remove();selection.attr("transform",function(d){if(d.hasOwnProperty("x")){return"translate("+xScale(d.x)+", 0)"}else{return"translate(0, "+yScale(d.y)+")"}});selection.exit().remove()})};return annotations}},{}],10:[function(require,module,exports){"use strict";var d3=window.d3;var builtInEvaluator=require("./eval").builtIn;var polyline=require("../graph-types/polyline");var datumDefaults=require("../datum-defaults");module.exports=function(chart){var derivativeDatum=datumDefaults({isHelper:true,skipTip:true,skipBoundsCheck:true,nSamples:2,graphType:"polyline"});var derivative;function computeLine(d){if(!d.derivative){return[]}var x0=typeof d.derivative.x0==="number"?d.derivative.x0:Infinity;derivativeDatum.index=d.index;derivativeDatum.scope={m:builtInEvaluator(d.derivative,"fn",{x:x0}),x0:x0,y0:builtInEvaluator(d,"fn",{x:x0})};derivativeDatum.fn="m * (x - x0) + y0";return[derivativeDatum]}function checkAutoUpdate(d){var self=this;if(!d.derivative){return}if(d.derivative.updateOnMouseMove&&!d.derivative.$$mouseListener){d.derivative.$$mouseListener=function(x0){if(d.derivative){d.derivative.x0=x0}derivative(self)};chart.on("tip:update",d.derivative.$$mouseListener)}}derivative=function(selection){selection.each(function(d){var el=d3.select(this);var data=computeLine.call(selection,d);checkAutoUpdate.call(selection,d);var innerSelection=el.selectAll("g.derivative").data(data);innerSelection.enter().append("g").attr("class","derivative");innerSelection.call(polyline(chart));innerSelection.selectAll("path").attr("opacity",.5);innerSelection.exit().remove()})};return derivative}},{"../datum-defaults":2,"../graph-types/polyline":7,"./eval":11}],11:[function(require,module,exports){"use strict";var samplers={interval:require("interval-arithmetic-eval"),builtIn:require("built-in-math-eval")};var extend=require("extend");window.math&&(samplers.builtIn=window.math.compile);function generateEvaluator(samplerName){function doCompile(expression){if(typeof expression==="string"){var compile=samplers[samplerName];return compile(expression)}else if(typeof expression==="function"){return{eval:expression}}else{throw Error("expression must be a string or a function")}}function compileIfPossible(meta,property){var expression=meta[property];var hiddenProperty=samplerName+"_Expression_"+property;var hiddenCompiled=samplerName+"_Compiled_"+property;if(expression!==meta[hiddenProperty]){meta[hiddenProperty]=expression;meta[hiddenCompiled]=doCompile(expression)}}function getCompiledExpression(meta,property){return meta[samplerName+"_Compiled_"+property]}function evaluate(meta,property,variables){compileIfPossible(meta,property);return getCompiledExpression(meta,property).eval(extend({},meta.scope||{},variables))}return evaluate}module.exports.builtIn=generateEvaluator("builtIn");module.exports.interval=generateEvaluator("interval")},{"built-in-math-eval":26,extend:32,"interval-arithmetic-eval":36}],12:[function(require,module,exports){"use strict";var d3=window.d3;var derivative=require("./derivative");var secant=require("./secant");module.exports=function(chart){function helper(selection){selection.each(function(){var el=d3.select(this);el.call(derivative(chart));el.call(secant(chart))})}return helper}},{"./derivative":10,"./secant":13}],13:[function(require,module,exports){"use strict";var d3=window.d3;var extend=require("extend");var builtInEvaluator=require("./eval").builtIn;var datumDefaults=require("../datum-defaults");var polyline=require("../graph-types/polyline");module.exports=function(chart){var secantDefaults=datumDefaults({isHelper:true,skipTip:true,skipBoundsCheck:true,nSamples:2,graphType:"polyline"});var secant;function computeSlope(scope){scope.m=(scope.y1-scope.y0)/(scope.x1-scope.x0)}function updateLine(d,secant){if(!secant.hasOwnProperty("x0")){throw Error("secant must have the property `x0` defined")}secant.scope=secant.scope||{};var x0=secant.x0;var x1=typeof secant.x1==="number"?secant.x1:Infinity;extend(secant.scope,{x0:x0,x1:x1,y0:builtInEvaluator(d,"fn",{x:x0}),y1:builtInEvaluator(d,"fn",{x:x1})});computeSlope(secant.scope)}function setFn(d,secant){updateLine(d,secant);secant.fn="m * (x - x0) + y0"}function setMouseListener(d,secantObject){var self=this;if(secantObject.updateOnMouseMove&&!secantObject.$$mouseListener){secantObject.$$mouseListener=function(x1){secantObject.x1=x1;updateLine(d,secantObject);secant(self)};chart.on("tip:update",secantObject.$$mouseListener)}}function computeLines(d){var self=this;var data=[];d.secants=d.secants||[];for(var i=0;i<d.secants.length;i+=1){var secant=d.secants[i]=extend({},secantDefaults,d.secants[i]);secant.index=d.index;if(!secant.fn){setFn.call(self,d,secant);setMouseListener.call(self,d,secant)}data.push(secant)}return data}secant=function(selection){selection.each(function(d){var el=d3.select(this);var data=computeLines.call(selection,d);var innerSelection=el.selectAll("g.secant").data(data);innerSelection.enter().append("g").attr("class","secant");innerSelection.call(polyline(chart));innerSelection.selectAll("path").attr("opacity",.5);innerSelection.exit().remove()})};return secant}},{"../datum-defaults":2,"../graph-types/polyline":7,"./eval":11,extend:32}],14:[function(require,module,exports){"use strict";require("./polyfills");var d3=window.d3;var events=require("events");var extend=require("extend");var mousetip=require("./tip");var helpers=require("./helpers/");var annotations=require("./helpers/annotations");var datumDefaults=require("./datum-defaults");var globals;var graphTypes;var cache=[];module.exports=function(options){options=options||{};options.data=options.data||[];var width,height;var margin;var zoomBehavior;var xScale,yScale;var line=d3.svg.line().x(function(d){return xScale(d[0])}).y(function(d){return yScale(d[1])});function Chart(){var n=Math.random();var letter=String.fromCharCode(Math.floor(n*26)+97);this.id=options.id=letter+n.toString(16).substr(2);this.linkedGraphs=[this];this.options=options;cache[this.id]=this;this.setUpEventListeners()}Chart.prototype=Object.create(events.prototype);Chart.prototype.build=function(){this.internalVars();this.drawGraphWrapper();return this};Chart.prototype.initializeAxes=function(){var integerFormat=d3.format("s");var format=function(scale){return function(d){var decimalFormat=scale.tickFormat(10);var isInteger=d===+d&&d===(d|0);return isInteger?integerFormat(d):decimalFormat(d)}};function computeYScale(xScale){var xDiff=xScale[1]-xScale[0];return height*xDiff/width}options.xAxis=options.xAxis||{};options.xAxis.type=options.xAxis.type||"linear";options.yAxis=options.yAxis||{};options.yAxis.type=options.yAxis.type||"linear";var xDomain=this.meta.xDomain=function(axis){if(axis.domain){return axis.domain}if(axis.type==="linear"){var xLimit=12;return[-xLimit/2,xLimit/2]}else if(axis.type==="log"){return[1,10]}throw Error("axis type "+axis.type+" unsupported")}(options.xAxis);var yDomain=this.meta.yDomain=function(axis){if(axis.domain){return axis.domain}var yLimit=computeYScale(xDomain);if(axis.type==="linear"){return[-yLimit/2,yLimit/2]}else if(axis.type==="log"){return[1,10]}throw Error("axis type "+axis.type+" unsupported")}(options.yAxis);if(xDomain[0]>=xDomain[1]){throw Error("the pair defining the x-domain is inverted")}if(yDomain[0]>=yDomain[1]){throw Error("the pair defining the y-domain is inverted")}xScale=this.meta.xScale=d3.scale[options.xAxis.type]().domain(xDomain).range(options.xAxis.invert?[width,0]:[0,width]);yScale=this.meta.yScale=d3.scale[options.yAxis.type]().domain(yDomain).range(options.yAxis.invert?[0,height]:[height,0]);this.meta.xAxis=d3.svg.axis().scale(xScale).tickSize(options.grid?-height:0).tickFormat(format(xScale)).orient("bottom");this.meta.yAxis=d3.svg.axis().scale(yScale).tickSize(options.grid?-width:0).tickFormat(format(yScale)).orient("left")};Chart.prototype.internalVars=function(){this.meta={};margin=this.meta.margin={left:30,right:30,top:20,bottom:20};if(options.title){this.meta.margin.top=40}zoomBehavior=this.meta.zoomBehavior=d3.behavior.zoom();width=this.meta.width=(options.width||globals.DEFAULT_WIDTH)-margin.left-margin.right;height=this.meta.height=(options.height||globals.DEFAULT_HEIGHT)-margin.top-margin.bottom;this.initializeAxes()};Chart.prototype.drawGraphWrapper=function(){var root=this.root=d3.select(options.target).selectAll("svg").data([options]);this.root.enter=root.enter().append("svg").attr("class","function-plot").attr("font-size",this.getFontSize());root.attr("width",width+margin.left+margin.right).attr("height",height+margin.top+margin.bottom);this.buildTitle();this.buildLegend();this.buildCanvas();this.buildClip();this.buildAxis();this.buildAxisLabel();this.draw();var tip=this.tip=mousetip(extend(options.tip,{owner:this}));this.canvas.call(tip);this.buildZoomHelper();this.setUpPlugins()};Chart.prototype.buildTitle=function(){var selection=this.root.selectAll("text.title").data(function(d){return[d.title].filter(Boolean)});selection.enter().append("text").attr("class","title").attr("y",margin.top/2).attr("x",margin.left+width/2).attr("font-size",25).attr("text-anchor","middle").attr("alignment-baseline","middle").text(options.title);selection.exit().remove()};Chart.prototype.buildLegend=function(){this.root.enter.append("text").attr("class","top-right-legend").attr("text-anchor","end");this.root.select(".top-right-legend").attr("y",margin.top/2).attr("x",width+margin.left)};Chart.prototype.buildCanvas=function(){var self=this;this.meta.zoomBehavior.x(xScale).y(yScale).on("zoom",function onZoom(){self.emit("all:zoom",d3.event.translate,d3.event.scale)});var canvas=this.canvas=this.root.selectAll(".canvas").data(function(d){return[d]});this.canvas.enter=canvas.enter().append("g").attr("class","canvas")};Chart.prototype.buildClip=function(){var id=this.id;var defs=this.canvas.enter.append("defs");defs.append("clipPath").attr("id","function-plot-clip-"+id).append("rect").attr("class","clip static-clip");this.canvas.selectAll(".clip").attr("width",width).attr("height",height);this.markerId=this.id+"-marker";defs.append("clipPath").append("marker").attr("id",this.markerId).attr("viewBox","0 -5 10 10").attr("refX",10).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("svg:path").attr("d","M0,-5L10,0L0,5L0,0").attr("stroke-width","0px").attr("fill-opacity",1).attr("fill","#777")};Chart.prototype.buildAxis=function(){var canvasEnter=this.canvas.enter;canvasEnter.append("g").attr("class","x axis");canvasEnter.append("g").attr("class","y axis");this.canvas.select(".x.axis").attr("transform","translate(0,"+height+")").call(this.meta.xAxis);this.canvas.select(".y.axis").call(this.meta.yAxis)};Chart.prototype.buildAxisLabel=function(){var xLabel,yLabel;var canvas=this.canvas;xLabel=canvas.selectAll("text.x.axis-label").data(function(d){return[d.xAxis.label].filter(Boolean)});xLabel.enter().append("text").attr("class","x axis-label").attr("text-anchor","end");xLabel.attr("x",width).attr("y",height-6).text(function(d){return d});xLabel.exit().remove();yLabel=canvas.selectAll("text.y.axis-label").data(function(d){return[d.yAxis.label].filter(Boolean)});yLabel.enter().append("text").attr("class","y axis-label").attr("y",6).attr("dy",".75em").attr("text-anchor","end").attr("transform","rotate(-90)");yLabel.text(function(d){return d});yLabel.exit().remove()};Chart.prototype.buildContent=function(){var self=this;var canvas=this.canvas;canvas.attr("transform","translate("+margin.left+","+margin.top+")").call(zoomBehavior).each(function(){var el=d3.select(this);var listeners=["mousedown","touchstart","onwheel"in document?"wheel":"ononmousewheel"in document?"mousewheel":"MozMousePixelScroll"].map(function(d){return d+".zoom"});if(!el._zoomListenersCache){listeners.forEach(function(l){el["_"+l]=el.on(l)});el._zoomListenersCache=true}function setState(state){listeners.forEach(function(l){state?el.on(l,el["_"+l]):el.on(l,null)})}setState(!options.disableZoom)});var content=this.content=canvas.selectAll(":scope > g.content").data(function(d){return[d]});content.enter().append("g").attr("clip-path","url(#function-plot-clip-"+this.id+")").attr("class","content");if(options.xAxis.type==="linear"){var yOrigin=content.selectAll(":scope > path.y.origin").data([[[0,yScale.domain()[0]],[0,yScale.domain()[1]]]]);yOrigin.enter().append("path").attr("class","y origin").attr("stroke","black").attr("opacity",.2);yOrigin.attr("d",line)}if(options.yAxis.type==="linear"){var xOrigin=content.selectAll(":scope > path.x.origin").data([[[xScale.domain()[0],0],[xScale.domain()[1],0]]]);xOrigin.enter().append("path").attr("class","x origin").attr("stroke","black").attr("opacity",.2);xOrigin.attr("d",line)}content.call(annotations({owner:self}));var graphs=content.selectAll(":scope > g.graph").data(function(d){return d.data.map(datumDefaults)});graphs.enter().append("g").attr("class","graph");graphs.each(function(d,index){d.index=index;d3.select(this).call(graphTypes[d.graphType](self));d3.select(this).call(helpers(self))})};Chart.prototype.buildZoomHelper=function(){var self=this;this.draggable=this.canvas.enter.append("rect").attr("class","zoom-and-drag").style("fill","none").style("pointer-events","all");this.canvas.select(".zoom-and-drag").attr("width",width).attr("height",height).on("mouseover",function(){self.emit("all:mouseover")}).on("mouseout",function(){self.emit("all:mouseout")}).on("mousemove",function(){self.emit("all:mousemove")})};Chart.prototype.setUpPlugins=function(){var plugins=options.plugins||[];var self=this;plugins.forEach(function(plugin){plugin(self)})};Chart.prototype.addLink=function(){for(var i=0;i<arguments.length;i+=1){this.linkedGraphs.push(arguments[i])}};Chart.prototype.updateAxes=function(){var instance=this;var canvas=instance.canvas;canvas.select(".x.axis").call(instance.meta.xAxis);canvas.select(".y.axis").call(instance.meta.yAxis);canvas.selectAll(".axis path, .axis line").attr("fill","none").attr("stroke","black").attr("shape-rendering","crispedges").attr("opacity",.1)};Chart.prototype.syncOptions=function(){this.options.xAxis.domain=this.meta.xScale.domain();this.options.yAxis.domain=this.meta.yScale.domain()};Chart.prototype.programmaticZoom=function(xDomain,yDomain){var instance=this;d3.transition().duration(750).tween("zoom",function(){var ix=d3.interpolate(xScale.domain(),xDomain);var iy=d3.interpolate(yScale.domain(),yDomain);return function(t){zoomBehavior.x(xScale.domain(ix(t))).y(yScale.domain(iy(t)));instance.draw()}}).each("end",function(){instance.emit("programmatic-zoom")})};Chart.prototype.getFontSize=function(){return Math.max(Math.max(width,height)/50,8)};Chart.prototype.draw=function(){var instance=this;instance.emit("before:draw");instance.syncOptions();instance.updateAxes();instance.buildContent();instance.emit("after:draw")};Chart.prototype.setUpEventListeners=function(){var instance=this;var events={mousemove:function(coordinates){instance.tip.move(coordinates)},mouseover:function(){instance.tip.show()},mouseout:function(){instance.tip.hide()},zoom:function(translate,scale){zoomBehavior.translate(translate).scale(scale)},"tip:update":function(x,y,index){var meta=instance.root.datum().data[index];var title=meta.title||"";var format=meta.renderer||function(x,y){return x.toFixed(3)+", "+y.toFixed(3)};var text=[];title&&text.push(title);text.push(format(x,y));instance.root.select(".top-right-legend").attr("fill",globals.COLORS[index]).text(text.join(" "))}};var all={mousemove:function(){var mouse=d3.mouse(instance.root.select("rect.zoom-and-drag").node());var coordinates={x:xScale.invert(mouse[0]),y:yScale.invert(mouse[1])};instance.linkedGraphs.forEach(function(graph){graph.emit("before:mousemove",coordinates);graph.emit("mousemove",coordinates)})},zoom:function(translate,scale){instance.linkedGraphs.forEach(function(graph,i){graph.emit("zoom",translate,scale);graph.draw()});instance.emit("all:mousemove")}};Object.keys(events).forEach(function(e){instance.on(e,events[e]);!all[e]&&instance.on("all:"+e,function(){var args=Array.prototype.slice.call(arguments);instance.linkedGraphs.forEach(function(graph){var localArgs=args.slice();localArgs.unshift(e);graph.emit.apply(graph,localArgs)})})});Object.keys(all).forEach(function(e){instance.on("all:"+e,all[e])})};var instance=cache[options.id];if(!instance){instance=new Chart}return instance.build()};globals=module.exports.globals=require("./globals");graphTypes=module.exports.graphTypes=require("./graph-types/");module.exports.plugins=require("./plugins/");module.exports.eval=require("./helpers/eval")},{"./datum-defaults":2,"./globals":4,"./graph-types/":5,"./helpers/":12,"./helpers/annotations":9,"./helpers/eval":11,"./plugins/":16,"./polyfills":18,"./tip":21,events:31,extend:32}],15:[function(require,module,exports){var d3=window.d3;var extend=require("extend");var pressed=require("key-pressed");var keydown=require("keydown");var integrateSimpson=require("integrate-adaptive-simpson");module.exports=function(options){options=extend({key:"<shift>",toggle:false},options);var brush=d3.svg.brush();var kd=keydown(options.key);var visible=false;var cachedInstance;function wrapper(datum){return function(x){var functionPlot=window.functionPlot;return functionPlot.eval.builtIn(datum,"fn",{x:x})}}function setBrushState(visible){var brushEl=cachedInstance.canvas.selectAll(".definite-integral");brushEl.style("display",visible?null:"none")}function inner(instance){cachedInstance=instance;var oldDisableZoom;brush.x(instance.meta.xScale).on("brushstart",function(){if(!d3.event.sourceEvent)return;oldDisableZoom=!!instance.options.disableZoom;instance.options.disableZoom=true;instance.emit("draw")}).on("brushend",function(){if(!d3.event.sourceEvent)return;instance.options.disableZoom=oldDisableZoom;if(!brush.empty()){var a=brush.extent()[0];var b=brush.extent()[1];instance.options.data.forEach(function(datum,i){var value=integrateSimpson(wrapper(datum),a,b,options.tol,options.maxdepth);instance.emit("definite-integral",datum,i,value,a,b)})}instance.draw()});var brushEl=instance.canvas.append("g").attr("class","brush definite-integral");brushEl.call(brush).call(brush.event);instance.canvas.selectAll(".brush .extent").attr("stroke","#fff").attr("fill-opacity",.125).attr("shape-rendering","crispEdges");brushEl.selectAll("rect").attr("height",instance.meta.height);instance.canvas.on("mousemove.definiteIntegral",function(){if(!options.toggle){inner.visible(pressed(options.key))}});kd.on("pressed",function(){inner.visible(options.toggle?!inner.visible():true)});inner.visible(false)}inner.visible=function(_){if(!arguments.length){return visible}visible=_;setBrushState(_);return inner};return inner}},{extend:32,"integrate-adaptive-simpson":35,"key-pressed":54,keydown:55}],16:[function(require,module,exports){module.exports={zoomBox:require("./zoom-box"),definiteIntegral:require("./definite-integral")}},{"./definite-integral":15,"./zoom-box":17}],17:[function(require,module,exports){var d3=window.d3;var extend=require("extend");var pressed=require("key-pressed");var keydown=require("keydown");module.exports=function(options){options=extend({key:"<shift>",toggle:false},options);var brush=d3.svg.brush();var kd=keydown(options.key);var cachedInstance;var visible=false;function setBrushState(visible){var brushEl=cachedInstance.canvas.selectAll(".zoom-box");brushEl.style("display",visible?null:"none")}function inner(instance){cachedInstance=instance;var oldDisableZoom;brush.x(instance.meta.xScale).y(instance.meta.yScale).on("brushstart",function(){if(!d3.event.sourceEvent)return;oldDisableZoom=!!instance.options.disableZoom;instance.options.disableZoom=true;instance.draw()}).on("brushend",function(){if(!d3.event.sourceEvent)return;instance.options.disableZoom=oldDisableZoom;if(!brush.empty()){var lo=brush.extent()[0];var hi=brush.extent()[1];var x=[lo[0],hi[0]];var y=[lo[1],hi[1]];instance.programmaticZoom(x,y)}d3.select(this).transition().duration(1).call(brush.clear()).call(brush.event)});var brushEl=instance.canvas.append("g").attr("class","brush zoom-box");brushEl.call(brush).call(brush.event);instance.canvas.selectAll(".brush .extent").attr("stroke","#fff").attr("fill-opacity",.125).attr("shape-rendering","crispEdges");instance.canvas.on("mousemove.zoombox",function(){if(!options.toggle){inner.visible(pressed(options.key))}});kd.on("pressed",function(){inner.visible(options.toggle?!inner.visible():true)});inner.visible(false)}inner.visible=function(_){if(!arguments.length){return visible}visible=_;setBrushState(_);return inner};return inner}},{extend:32,"key-pressed":54,keydown:55}],18:[function(require,module,exports){(function(doc,proto){try{doc.querySelector(":scope body")}catch(err){["querySelector","querySelectorAll"].forEach(function(method){var native=proto[method];proto[method]=function(selectors){if(/(^|,)\s*:scope/.test(selectors)){var id=this.id;this.id="ID_"+Date.now();selectors=selectors.replace(/((^|,)\s*):scope/g,"$1#"+this.id);var result=doc[method](selectors);this.id=id;return result}else{return native.call(this,selectors)}}})}})(window.document,Element.prototype)},{}],19:[function(require,module,exports){"use strict";var clamp=require("clamp");var linspace=require("linspace");var utils=require("../utils");var evaluate=require("../helpers/eval").builtIn;function checkAsymptote(d0,d1,meta,sign,level){if(!level){return{asymptote:true,d0:d0,d1:d1}}var i;var n=10;var x0=d0[0];var x1=d1[0];var samples=linspace(x0,x1,n);var oldY,oldX;for(i=0;i<n;i+=1){var x=samples[i];var y=evaluate(meta,"fn",{x:x});if(i){var deltaY=y-oldY;var newSign=utils.sgn(deltaY);if(newSign===sign){return checkAsymptote([oldX,oldY],[x,y],meta,sign,level-1)}}oldY=y;oldX=x}return{asymptote:false,d0:d0,d1:d1}}function split(chart,meta,data){var i,oldSign;var deltaX;var st=[];var sets=[];var domain=chart.meta.yScale.domain();var zoomScale=chart.meta.zoomBehavior.scale();var yMin=domain[0];var yMax=domain[1];if(data[0]){st.push(data[0]);deltaX=data[1][0]-data[0][0];oldSign=utils.sgn(data[1][1]-data[0][1])}function updateY(d){d[1]=Math.min(d[1],yMax);d[1]=Math.max(d[1],yMin);return d}i=1;while(i<data.length){var y0=data[i-1][1];var y1=data[i][1];var deltaY=y1-y0;var newSign=utils.sgn(deltaY);if(oldSign!==newSign&&Math.abs(deltaY/deltaX)>1/zoomScale){var check=checkAsymptote(data[i-1],data[i],meta,newSign,3);if(check.asymptote){st.push(updateY(check.d0));sets.push(st);st=[updateY(check.d1)]}}oldSign=newSign;st.push(data[i]);++i}if(st.length){sets.push(st)}return sets}function linear(chart,meta,range,n){var allX=utils.space(chart,range,n);var yDomain=chart.meta.yScale.domain();var yDomainMargin=yDomain[1]-yDomain[0];var yMin=yDomain[0]-yDomainMargin*1e5;var yMax=yDomain[1]+yDomainMargin*1e5;var data=[];var i;for(i=0;i<allX.length;i+=1){var x=allX[i];var y=evaluate(meta,"fn",{x:x});if(utils.isValidNumber(x)&&utils.isValidNumber(y)){data.push([x,clamp(y,yMin,yMax)])}}data=split(chart,meta,data);return data}function parametric(chart,meta,range,nSamples){var parametricRange=meta.range||[0,2*Math.PI];var tCoords=utils.space(chart,parametricRange,nSamples);var samples=[];for(var i=0;i<tCoords.length;i+=1){var t=tCoords[i];var x=evaluate(meta,"x",{t:t});var y=evaluate(meta,"y",{t:t});samples.push([x,y])}return[samples]}function polar(chart,meta,range,nSamples){var polarRange=meta.range||[-Math.PI,Math.PI];var thetaSamples=utils.space(chart,polarRange,nSamples);var samples=[];for(var i=0;i<thetaSamples.length;i+=1){var theta=thetaSamples[i];var r=evaluate(meta,"r",{theta:theta});var x=r*Math.cos(theta);var y=r*Math.sin(theta);samples.push([x,y])}return[samples]}function points(chart,meta,range,nSamples){return[meta.points]}function vector(chart,meta,range,nSamples){meta.offset=meta.offset||[0,0];return[[meta.offset,[meta.vector[0]+meta.offset[0],meta.vector[1]+meta.offset[1]]]]}var sampler=function(chart,d,range,nSamples){var fnTypes={parametric:parametric,polar:polar,points:points,vector:vector,linear:linear};if(!(d.fnType in fnTypes)){throw Error(d.fnType+" is not supported in the `builtIn` sampler")}return fnTypes[d.fnType].apply(null,arguments)};module.exports=sampler},{"../helpers/eval":11,"../utils":22,clamp:29,linspace:56}],20:[function(require,module,exports){ "use strict";var intervalArithmeticEval=require("interval-arithmetic-eval");var Interval=intervalArithmeticEval.Interval;var evaluate=require("../helpers/eval").interval;var utils=require("../utils");intervalArithmeticEval.policies.disableRounding();function interval1d(chart,meta,range,nSamples){var xCoords=utils.space(chart,range,nSamples);var xScale=chart.meta.xScale;var yScale=chart.meta.yScale;var yMin=yScale.domain()[0];var yMax=yScale.domain()[1];var samples=[];var i;for(i=0;i<xCoords.length-1;i+=1){var x={lo:xCoords[i],hi:xCoords[i+1]};var y=evaluate(meta,"fn",{x:x});if(!Interval.isEmpty(y)&&!Interval.isWhole(y)){samples.push([x,y])}if(Interval.isWhole(y)){samples.push(null)}}for(i=1;i<samples.length-1;i+=1){if(!samples[i]){var prev=samples[i-1];var next=samples[i+1];if(prev&&next&&!Interval.intervalsOverlap(prev[1],next[1])){if(prev[1].lo>next[1].hi){prev[1].hi=Math.max(yMax,prev[1].hi);next[1].lo=Math.min(yMin,next[1].lo)}if(prev[1].hi<next[1].lo){prev[1].lo=Math.min(yMin,prev[1].lo);next[1].hi=Math.max(yMax,next[1].hi)}}}}samples.scaledDx=xScale(xCoords[1])-xScale(xCoords[0]);return[samples]}var rectEps;function smallRect(x,y){return Interval.width(x)<rectEps}function quadTree(x,y,meta){var sample=evaluate(meta,"fn",{x:x,y:y});var fulfills=Interval.zeroIn(sample);if(!fulfills){return this}if(smallRect(x,y)){this.push([x,y]);return this}var midX=x.lo+(x.hi-x.lo)/2;var midY=y.lo+(y.hi-y.lo)/2;var east={lo:midX,hi:x.hi};var west={lo:x.lo,hi:midX};var north={lo:midY,hi:y.hi};var south={lo:y.lo,hi:midY};quadTree.call(this,east,north,meta);quadTree.call(this,east,south,meta);quadTree.call(this,west,north,meta);quadTree.call(this,west,south,meta)}function interval2d(chart,meta){var xScale=chart.meta.xScale;var xDomain=chart.meta.xScale.domain();var yDomain=chart.meta.yScale.domain();var x={lo:xDomain[0],hi:xDomain[1]};var y={lo:yDomain[0],hi:yDomain[1]};var samples=[];rectEps=xScale.invert(1)-xScale.invert(0);quadTree.call(samples,x,y,meta);samples.scaledDx=1;return[samples]}var sampler=function(chart,d,range,nSamples){var fnTypes={implicit:interval2d,linear:interval1d};if(!fnTypes.hasOwnProperty(d.fnType)){throw Error(d.fnType+" is not supported in the `interval` sampler")}return fnTypes[d.fnType].apply(null,arguments)};module.exports=sampler},{"../helpers/eval":11,"../utils":22,"interval-arithmetic-eval":36}],21:[function(require,module,exports){"use strict";var d3=window.d3;var extend=require("extend");var utils=require("./utils");var clamp=require("clamp");var globals=require("./globals");var builtInEvaluator=require("./helpers/eval").builtIn;module.exports=function(config){config=extend({xLine:false,yLine:false,renderer:function(x,y,index){return"("+x.toFixed(3)+", "+y.toFixed(3)+")"},owner:null},config);var MARGIN=20;var line=d3.svg.line().x(function(d){return d[0]}).y(function(d){return d[1]});function lineGenerator(el,data){return el.append("path").datum(data).attr("stroke","grey").attr("stroke-dasharray","5,5").attr("opacity",.5).attr("d",line)}function tip(selection){var innerSelection=selection.selectAll("g.tip").data(function(d){return[d]});innerSelection.enter().append("g").attr("class","tip").attr("clip-path","url(#function-plot-clip-"+config.owner.id+")");tip.el=innerSelection.selectAll("g.inner-tip").data(function(d){return[d]});tip.el.enter().append("g").attr("class","inner-tip").style("display","none").each(function(){var el=d3.select(this);lineGenerator(el,[[0,-config.owner.meta.height-MARGIN],[0,config.owner.meta.height+MARGIN]]).attr("class","tip-x-line").style("display","none");lineGenerator(el,[[-config.owner.meta.width-MARGIN,0],[config.owner.meta.width+MARGIN,0]]).attr("class","tip-y-line").style("display","none");el.append("circle").attr("r",3);el.append("text").attr("transform","translate(5,-5)")});selection.selectAll(".tip-x-line").style("display",config.xLine?null:"none");selection.selectAll(".tip-y-line").style("display",config.yLine?null:"none")}tip.move=function(coordinates){var i;var minDist=Infinity;var closestIndex=-1;var x,y;var el=tip.el;var inf=1e8;var meta=config.owner.meta;var data=el.data()[0].data;var xScale=meta.xScale;var yScale=meta.yScale;var width=meta.width;var height=meta.height;var x0=coordinates.x;var y0=coordinates.y;for(i=0;i<data.length;i+=1){if(data[i].skipTip||data[i].fnType!=="linear"){continue}var range=data[i].range||[-inf,inf];if(x0>range[0]-globals.TIP_X_EPS&&x0<range[1]+globals.TIP_X_EPS){try{var candidateY=builtInEvaluator(data[i],"fn",{x:x0})}catch(e){}if(utils.isValidNumber(candidateY)){var tDist=Math.abs(candidateY-y0);if(tDist<minDist){minDist=tDist;closestIndex=i}}}}if(closestIndex!==-1){x=x0;if(data[closestIndex].range){x=Math.max(x,data[closestIndex].range[0]);x=Math.min(x,data[closestIndex].range[1])}y=builtInEvaluator(data[closestIndex],"fn",{x:x});tip.show();config.owner.emit("tip:update",x,y,closestIndex);var clampX=clamp(x,xScale.invert(-MARGIN),xScale.invert(width+MARGIN));var clampY=clamp(y,yScale.invert(height+MARGIN),yScale.invert(-MARGIN));var color=utils.color(data[closestIndex],closestIndex);el.attr("transform","translate("+xScale(clampX)+","+yScale(clampY)+")");el.select("circle").attr("fill",color);el.select("text").attr("fill",color).text(config.renderer(x,y,closestIndex))}else{tip.hide()}};tip.show=function(){this.el.style("display",null)};tip.hide=function(){this.el.style("display","none")};Object.keys(config).forEach(function(option){utils.getterSetter.call(tip,config,option)});return tip}},{"./globals":4,"./helpers/eval":11,"./utils":22,clamp:29,extend:32}],22:[function(require,module,exports){"use strict";var linspace=require("linspace");var logspace=require("logspace");var log10=require("log10");var globals=require("./globals");module.exports={isValidNumber:function(v){return typeof v==="number"&&!isNaN(v)},space:function(chart,range,n){var lo=range[0];var hi=range[1];if(chart.options.xAxis.type==="log"){return logspace(log10(lo),log10(hi),n)}return linspace(lo,hi,n)},getterSetter:function(config,option){var me=this;this[option]=function(value){if(!arguments.length){return config[option]}config[option]=value;return me}},sgn:function(v){if(v<0){return-1}if(v>0){return 1}return 0},color:function(data,index){return data.color||globals.COLORS[index]}}},{"./globals":4,linspace:56,log10:57,logspace:58}],23:[function(require,module,exports){"use strict";exports.byteLength=byteLength;exports.toByteArray=toByteArray;exports.fromByteArray=fromByteArray;var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i=0,len=code.length;i<len;++i){lookup[i]=code[i];revLookup[code.charCodeAt(i)]=i}revLookup["-".charCodeAt(0)]=62;revLookup["_".charCodeAt(0)]=63;function placeHoldersCount(b64){var len=b64.length;if(len%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}return b64[len-2]==="="?2:b64[len-1]==="="?1:0}function byteLength(b64){return b64.length*3/4-placeHoldersCount(b64)}function toByteArray(b64){var i,j,l,tmp,placeHolders,arr;var len=b64.length;placeHolders=placeHoldersCount(b64);arr=new Arr(len*3/4-placeHolders);l=placeHolders>0?len-4:len;var L=0;for(i=0,j=0;i<l;i+=4,j+=3){tmp=revLookup[b64.charCodeAt(i)]<<18|revLookup[b64.charCodeAt(i+1)]<<12|revLookup[b64.charCodeAt(i+2)]<<6|revLookup[b64.charCodeAt(i+3)];arr[L++]=tmp>>16&255;arr[L++]=tmp>>8&255;arr[L++]=tmp&255}if(placeHolders===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[L++]=tmp&255}else if(placeHolders===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[L++]=tmp>>8&255;arr[L++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;i<end;i+=3){tmp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2];output.push(tripletToBase64(tmp))}return output.join("")}function fromByteArray(uint8){var tmp;var len=uint8.length;var extraBytes=len%3;var output="";var parts=[];var maxChunkLength=16383;for(var i=0,len2=len-extraBytes;i<len2;i+=maxChunkLength){parts.push(encodeChunk(uint8,i,i+maxChunkLength>len2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];output+=lookup[tmp>>2];output+=lookup[tmp<<4&63];output+="=="}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];output+=lookup[tmp>>10];output+=lookup[tmp>>4&63];output+=lookup[tmp<<2&63];output+="="}parts.push(output);return parts.join("")}},{}],24:[function(require,module,exports){(function(global){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");var isArray=require("isarray");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=global.TYPED_ARRAY_SUPPORT!==undefined?global.TYPED_ARRAY_SUPPORT:typedArraySupport();exports.kMaxLength=kMaxLength();function typedArraySupport(){try{var arr=new Uint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return arr.foo()===42&&typeof arr.subarray==="function"&&arr.subarray(1,1).byteLength===0}catch(e){return false}}function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(that,length){if(kMaxLength()<length){throw new RangeError("Invalid typed array length")}if(Buffer.TYPED_ARRAY_SUPPORT){that=new Uint8Array(length);that.__proto__=Buffer.prototype}else{if(that===null){that=new Buffer(length)}that.length=length}return that}function Buffer(arg,encodingOrOffset,length){if(!Buffer.TYPED_ARRAY_SUPPORT&&!(this instanceof Buffer)){return new Buffer(arg,encodingOrOffset,length)}if(typeof arg==="number"){if(typeof encodingOrOffset==="string"){throw new Error("If encoding is specified then the first argument must be a string")}return allocUnsafe(this,arg)}return from(this,arg,encodingOrOffset,length)}Buffer.poolSize=8192;Buffer._augment=function(arr){arr.__proto__=Buffer.prototype;return arr};function from(that,value,encodingOrOffset,length){if(typeof value==="number"){throw new TypeError('"value" argument must not be a number')}if(typeof ArrayBuffer!=="undefined"&&value instanceof ArrayBuffer){return fromArrayBuffer(that,value,encodingOrOffset,length)}if(typeof value==="string"){return fromString(that,value,encodingOrOffset)}return fromObject(that,value)}Buffer.from=function(value,encodingOrOffset,length){return from(null,value,encodingOrOffset,length)};if(Buffer.TYPED_ARRAY_SUPPORT){Buffer.prototype.__proto__=Uint8Array.prototype;Buffer.__proto__=Uint8Array;if(typeof Symbol!=="undefined"&&Symbol.species&&Buffer[Symbol.species]===Buffer){Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:true})}}function assertSize(size){if(typeof size!=="number"){throw new TypeError('"size" argument must be a number')}else if(size<0){throw new RangeError('"size" argument must not be negative')}}function alloc(that,size,fill,encoding){assertSize(size);if(size<=0){return createBuffer(that,size)}if(fill!==undefined){return typeof encoding==="string"?createBuffer(that,size).fill(fill,encoding):createBuffer(that,size).fill(fill)}return createBuffer(that,size)}Buffer.alloc=function(size,fill,encoding){return alloc(null,size,fill,encoding)};function allocUnsafe(that,size){assertSize(size);that=createBuffer(that,size<0?0:checked(size)|0);if(!Buffer.TYPED_ARRAY_SUPPORT){for(var i=0;i<size;++i){that[i]=0}}return that}Buffer.allocUnsafe=function(size){return allocUnsafe(null,size)};Buffer.allocUnsafeSlow=function(size){return allocUnsafe(null,size)};function fromString(that,string,encoding){if(typeof encoding!=="string"||encoding===""){encoding="utf8"}if(!Buffer.isEncoding(encoding)){throw new TypeError('"encoding" must be a valid string encoding')}var length=byteLength(string,encoding)|0;that=createBuffer(that,length);var actual=that.write(string,encoding);if(actual!==length){that=that.slice(0,actual)}return that}function fromArrayLike(that,array){var length=array.length<0?0:checked(array.length)|0;that=createBuffer(that,length);for(var i=0;i<length;i+=1){that[i]=array[i]&255}return that}function fromArrayBuffer(that,array,byteOffset,length){array.byteLength;if(byteOffset<0||array.byteLength<byteOffset){throw new RangeError("'offset' is out of bounds")}if(array.byteLength<byteOffset+(length||0)){throw new RangeError("'length' is out of bounds")}if(byteOffset===undefined&&length===undefined){array=new Uint8Array(array)}else if(length===undefined){array=new Uint8Array(array,byteOffset)}else{array=new Uint8Array(array,byteOffset,length)}if(Buffer.TYPED_ARRAY_SUPPORT){that=array;that.__proto__=Buffer.prototype}else{that=fromArrayLike(that,array)}return that}function fromObject(that,obj){if(Buffer.isBuffer(obj)){var len=checked(obj.length)|0;that=createBuffer(that,len);if(that.length===0){return that}obj.copy(that,0,0,len);return that}if(obj){if(typeof ArrayBuffer!=="undefined"&&obj.buffer instanceof ArrayBuffer||"length"in obj){if(typeof obj.length!=="number"||isnan(obj.length)){return createBuffer(that,0)}return fromArrayLike(that,obj)}if(obj.type==="Buffer"&&isArray(obj.data)){return fromArrayLike(that,obj.data)}}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function checked(length){if(length>=kMaxLength()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength().toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function compare(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError("Arguments must be Buffers")}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i<len;++i){if(a[i]!==b[i]){x=a[i];y=b[i];break}}if(x<y)return-1;if(y<x)return 1;return 0};Buffer.isEncoding=function isEncoding(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};Buffer.concat=function concat(list,length){if(!isArray(list)){throw new TypeError('"list" argument must be an Array of Buffers')}if(list.length===0){return Buffer.alloc(0)}var i;if(length===undefined){length=0;for(i=0;i<list.length;++i){length+=list[i].length}}var buffer=Buffer.allocUnsafe(length);var pos=0;for(i=0;i<list.length;++i){var buf=list[i];if(!Buffer.isBuffer(buf)){throw new TypeError('"list" argument must be an Array of Buffers')}buf.copy(buffer,pos);pos+=buf.length}return buffer};function byteLength(string,encoding){if(Buffer.isBuffer(string)){return string.length}if(typeof ArrayBuffer!=="undefined"&&typeof ArrayBuffer.isView==="function"&&(ArrayBuffer.isView(string)||string instanceof ArrayBuffer)){return string.byteLength}if(typeof string!=="string"){string=""+string}var len=string.length;if(len===0)return 0;var loweredCase=false;for(;;){switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":case undefined:return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return len*2;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;i<len;i+=2){swap(this,i,i+1)}return this};Buffer.prototype.swap32=function swap32(){var len=this.length;if(len%4!==0){throw new RangeError("Buffer size must be a multiple of 32-bits")}for(var i=0;i<len;i+=4){swap(this,i,i+3);swap(this,i+1,i+2)}return this};Buffer.prototype.swap64=function swap64(){var len=this.length;if(len%8!==0){throw new RangeError("Buffer size must be a multiple of 64-bits")}for(var i=0;i<len;i+=8){swap(this,i,i+7);swap(this,i+1,i+6);swap(this,i+2,i+5);swap(this,i+3,i+4)}return this};Buffer.prototype.toString=function toString(){var length=this.length|0;if(length===0)return"";if(arguments.length===0)return utf8Slice(this,0,length);return slowToString.apply(this,arguments)};Buffer.prototype.equals=function equals(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");if(this===b)return true;return Buffer.compare(this,b)===0};Buffer.prototype.inspect=function inspect(){var str="";var max=exports.INSPECT_MAX_BYTES;if(this.length>0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return"<Buffer "+str+">"};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(!Buffer.isBuffer(target)){throw new TypeError("Argument must be a Buffer")}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i<len;++i){if(thisCopy[i]!==targetCopy[i]){x=thisCopy[i];y=targetCopy[i];break}}if(x<y)return-1;if(y<x)return 1;return 0};function bidirectionalIndexOf(buffer,val,byteOffset,encoding,dir){if(buffer.length===0)return-1;if(typeof byteOffset==="string"){encoding=byteOffset;byteOffset=0}else if(byteOffset>2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(isNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;i<arrLength;i++){if(read(arr,i)===read(val,foundIndex===-1?0:i-foundIndex)){if(foundIndex===-1)foundIndex=i;if(i-foundIndex+1===valLength)return foundIndex*indexSize}else{if(foundIndex!==-1)i-=i-foundIndex;foundIndex=-1}}}else{if(byteOffset+valLength>arrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;j<valLength;j++){if(read(arr,i+j)!==read(val,j)){found=false;break}}if(found)return i}}return-1}Buffer.prototype.includes=function includes(val,byteOffset,encoding){return this.indexOf(val,byteOffset,encoding)!==-1};Buffer.prototype.indexOf=function indexOf(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,true)};Buffer.prototype.lastIndexOf=function lastIndexOf(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,false)};function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new TypeError("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;i<length;++i){var parsed=parseInt(string.substr(i*2,2),16);if(isNaN(parsed))return i;buf[offset+i]=parsed}return i}function utf8Write(buf,string,offset,length){return blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length)}function asciiWrite(buf,string,offset,length){return blitBuffer(asciiToBytes(string),buf,offset,length)}function latin1Write(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){return blitBuffer(base64ToBytes(string),buf,offset,length)}function ucs2Write(buf,string,offset,length){return blitBuffer(utf16leToBytes(string,buf.length-offset),buf,offset,length)}Buffer.prototype.write=function write(string,offset,length,encoding){if(offset===undefined){encoding="utf8";length=this.length;offset=0}else if(length===undefined&&typeof offset==="string"){encoding=offset;length=this.length;offset=0}else if(isFinite(offset)){offset=offset|0;if(isFinite(length)){length=length|0;if(encoding===undefined)encoding="utf8"}else{encoding=length;length=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var remaining=this.length-offset;if(length===undefined||length>remaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i<end){var firstByte=buf[i];var codePoint=null;var bytesPerSequence=firstByte>239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(i<len){res+=String.fromCharCode.apply(String,codePoints.slice(i,i+=MAX_ARGUMENTS_LENGTH))}return res}function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i){ret+=String.fromCharCode(buf[i]&127)}return ret}function latin1Slice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i){ret+=String.fromCharCode(buf[i])}return ret}function hexSlice(buf,start,end){var len=buf.length;if(!start||start<0)start=0;if(!end||end<0||end>len)end=len;var out="";for(var i=start;i<end;++i){out+=toHex(buf[i])}return out}function utf16leSlice(buf,start,end){var bytes=buf.slice(start,end);var res="";for(var i=0;i<bytes.length;i+=2){res+=String.fromCharCode(bytes[i]+bytes[i+1]*256)}return res}Buffer.prototype.slice=function slice(start,end){var len=this.length;start=~~start;end=end===undefined?len:~~end;if(start<0){start+=len;if(start<0)start=0}else if(start>len){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(end<start)end=start;var newBuf;if(Buffer.TYPED_ARRAY_SUPPORT){newBuf=this.subarray(start,end);newBuf.__proto__=Buffer.prototype}else{var sliceLen=end-start;newBuf=new Buffer(sliceLen,undefined);for(var i=0;i<sliceLen;++i){newBuf[i]=this[i+start]}}return newBuf};function checkOffset(offset,ext,length){if(offset%1!==0||offset<0)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256)){val+=this[offset+i]*mul}return val};Buffer.prototype.readUIntBE=function readUIntBE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert){checkOffset(offset,byteLength,this.length)}var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256)){val+=this[offset+i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||value<min)throw new RangeError('"value" argument is out of bounds');if(offset+ext>buf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;byteLength=byteLength|0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i<byteLength&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUIntBE=function writeUIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;byteLength=byteLength|0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value&255;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i<j;++i){buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset|0; if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i<j;++i){buf[offset+i]=value>>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i<byteLength&&(mul*=256)){if(value<0&&sub===0&&this[offset+i-1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end<start)end=start;if(end===start)return 0;if(target.length===0||this.length===0)return 0;if(targetStart<0){throw new RangeError("targetStart out of bounds")}if(start<0||start>=this.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart<end-start){end=target.length-targetStart+start}var len=end-start;var i;if(this===target&&start<targetStart&&targetStart<end){for(i=len-1;i>=0;--i){target[i+targetStart]=this[i+start]}}else if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(i=0;i<len;++i){target[i+targetStart]=this[i+start]}}else{Uint8Array.prototype.set.call(target,this.subarray(start,start+len),targetStart)}return len};Buffer.prototype.fill=function fill(val,start,end,encoding){if(typeof val==="string"){if(typeof start==="string"){encoding=start;start=0;end=this.length}else if(typeof end==="string"){encoding=end;end=this.length}if(val.length===1){var code=val.charCodeAt(0);if(code<256){val=code}}if(encoding!==undefined&&typeof encoding!=="string"){throw new TypeError("encoding must be a string")}if(typeof encoding==="string"&&!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}}else if(typeof val==="number"){val=val&255}if(start<0||this.length<start||this.length<end){throw new RangeError("Out of range index")}if(end<=start){return this}start=start>>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i<end;++i){this[i]=val}}else{var bytes=Buffer.isBuffer(val)?val:utf8ToBytes(new Buffer(val,encoding).toString());var len=bytes.length;for(i=0;i<end-start;++i){this[i+start]=bytes[i%len]}}return this};var INVALID_BASE64_RE=/[^+\/0-9A-Za-z-_]/g;function base64clean(str){str=stringtrim(str).replace(INVALID_BASE64_RE,"");if(str.length<2)return"";while(str.length%4!==0){str=str+"="}return str}function stringtrim(str){if(str.trim)return str.trim();return str.replace(/^\s+|\s+$/g,"")}function toHex(n){if(n<16)return"0"+n.toString(16);return n.toString(16)}function utf8ToBytes(string,units){units=units||Infinity;var codePoint;var length=string.length;var leadSurrogate=null;var bytes=[];for(var i=0;i<length;++i){codePoint=string.charCodeAt(i);if(codePoint>55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i<str.length;++i){byteArray.push(str.charCodeAt(i)&255)}return byteArray}function utf16leToBytes(str,units){var c,hi,lo;var byteArray=[];for(var i=0;i<str.length;++i){if((units-=2)<0)break;c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i<length;++i){if(i+offset>=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isnan(val){return val!==val}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"base64-js":23,ieee754:33,isarray:25}],25:[function(require,module,exports){var toString={}.toString;module.exports=Array.isArray||function(arr){return toString.call(arr)=="[object Array]"}},{}],26:[function(require,module,exports){"use strict";module.exports=require("./lib/eval")},{"./lib/eval":28}],27:[function(require,module,exports){"use strict";module.exports=function(){var math=Object.create(Math);math.factory=function(a){if(typeof a!=="number"){throw new TypeError("built-in math factory only accepts numbers")}return Number(a)};math.add=function(a,b){return a+b};math.sub=function(a,b){return a-b};math.mul=function(a,b){return a*b};math.div=function(a,b){return a/b};math.mod=function(a,b){return a%b};math.factorial=function(a){var res=1;for(var i=2;i<=a;i+=1){res*=i}return res};math.nthRoot=function(a,root){var inv=root<0;if(inv){root=-root}if(root===0){throw new Error("Root must be non-zero")}if(a<0&&Math.abs(root)%2!==1){throw new Error("Root must be odd when a is negative.")}if(a===0){return 0}if(!isFinite(a)){return inv?0:a}var x=Math.pow(Math.abs(a),1/root);x=a<0?-x:x;return inv?1/x:x};math.logicalOR=function(a,b){return a||b};math.logicalXOR=function(a,b){return a!=b};math.logicalAND=function(a,b){return a&&b};math.bitwiseOR=function(a,b){return a|b};math.bitwiseXOR=function(a,b){return a^b};math.bitwiseAND=function(a,b){return a&b};math.lessThan=function(a,b){return a<b};math.lessEqualThan=function(a,b){return a<=b};math.greaterThan=function(a,b){return a>b};math.greaterEqualThan=function(a,b){return a>=b};math.equal=function(a,b){return a==b};math.strictlyEqual=function(a,b){return a===b};math.notEqual=function(a,b){return a!=b};math.strictlyNotEqual=function(a,b){return a!==b};math.shiftRight=function(a,b){return a>>b};math.shiftLeft=function(a,b){return a<<b};math.unsignedRightShift=function(a,b){return a>>>b};math.negative=function(a){return-a};math.positive=function(a){return a};return math}},{}],28:[function(require,module,exports){"use strict";var CodeGenerator=require("math-codegen");var math=require("./adapter")();function processScope(scope){Object.keys(scope).forEach(function(k){var value=scope[k];scope[k]=math.factory(value)})}module.exports=function(expression){return(new CodeGenerator).setDefs({$$processScope:processScope}).parse(expression).compile(math)};module.exports.math=math},{"./adapter":27,"math-codegen":59}],29:[function(require,module,exports){module.exports=clamp;function clamp(value,min,max){return min<max?value<min?min:value>max?max:value:value<max?max:value>min?min:value}},{}],30:[function(require,module,exports){(function(Buffer){var hasTypedArrays=false;if(typeof Float64Array!=="undefined"){var DOUBLE_VIEW=new Float64Array(1),UINT_VIEW=new Uint32Array(DOUBLE_VIEW.buffer);DOUBLE_VIEW[0]=1;hasTypedArrays=true;if(UINT_VIEW[1]===1072693248){module.exports=function doubleBitsLE(n){DOUBLE_VIEW[0]=n;return[UINT_VIEW[0],UINT_VIEW[1]]};function toDoubleLE(lo,hi){UINT_VIEW[0]=lo;UINT_VIEW[1]=hi;return DOUBLE_VIEW[0]}module.exports.pack=toDoubleLE;function lowUintLE(n){DOUBLE_VIEW[0]=n;return UINT_VIEW[0]}module.exports.lo=lowUintLE;function highUintLE(n){DOUBLE_VIEW[0]=n;return UINT_VIEW[1]}module.exports.hi=highUintLE}else if(UINT_VIEW[0]===1072693248){module.exports=function doubleBitsBE(n){DOUBLE_VIEW[0]=n;return[UINT_VIEW[1],UINT_VIEW[0]]};function toDoubleBE(lo,hi){UINT_VIEW[1]=lo;UINT_VIEW[0]=hi;return DOUBLE_VIEW[0]}module.exports.pack=toDoubleBE;function lowUintBE(n){DOUBLE_VIEW[0]=n;return UINT_VIEW[1]}module.exports.lo=lowUintBE;function highUintBE(n){DOUBLE_VIEW[0]=n;return UINT_VIEW[0]}module.exports.hi=highUintBE}else{hasTypedArrays=false}}if(!hasTypedArrays){var buffer=new Buffer(8);module.exports=function doubleBits(n){buffer.writeDoubleLE(n,0,true);return[buffer.readUInt32LE(0,true),buffer.readUInt32LE(4,true)]};function toDouble(lo,hi){buffer.writeUInt32LE(lo,0,true);buffer.writeUInt32LE(hi,4,true);return buffer.readDoubleLE(0,true)}module.exports.pack=toDouble;function lowUint(n){buffer.writeDoubleLE(n,0,true);return buffer.readUInt32LE(0,true)}module.exports.lo=lowUint;function highUint(n){buffer.writeDoubleLE(n,0,true);return buffer.readUInt32LE(4,true)}module.exports.hi=highUint}module.exports.sign=function(n){return module.exports.hi(n)>>>31};module.exports.exponent=function(n){var b=module.exports.hi(n);return(b<<1>>>21)-1023};module.exports.fraction=function(n){var lo=module.exports.lo(n);var hi=module.exports.hi(n);var b=hi&(1<<20)-1;if(hi&2146435072){b+=1<<20}return[lo,b]};module.exports.denormalized=function(n){var hi=module.exports.hi(n);return!(hi&2146435072)}}).call(this,require("buffer").Buffer)},{buffer:24}],31:[function(require,module,exports){function EventEmitter(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}module.exports=EventEmitter;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._maxListeners=undefined;EventEmitter.defaultMaxListeners=10;EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||n<0||isNaN(n))throw TypeError("n must be a positive number");this._maxListeners=n;return this};EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(!this._events)this._events={};if(type==="error"){if(!this._events.error||isObject(this._events.error)&&!this._events.error.length){er=arguments[1];if(er instanceof Error){throw er}else{var err=new Error('Uncaught, unspecified "error" event. ('+er+")");err.context=er;throw err}}}handler=this._events[type];if(isUndefined(handler))return false;if(isFunction(handler)){switch(arguments.length){case 1:handler.call(this);break;case 2:handler