!function(e){if("object"==typeofexports&&"undefined"!=typeofmodule)module.exports=e();elseif("function"==typeofdefine&&define.amd)define([],e);else{vart;"undefined"!=typeofwindow?t=window:"undefined"!=typeofglobal?t=global:"undefined"!=typeofself&&(t=self),t.torque=e()}}(function(){vare,t,n;returnfunctioni(e,t,n){functionr(o,u){if(!t[o]){if(!e[o]){vara=typeofrequire=="function"&&require;if(!u&&a)returna(o,!0);if(s)returns(o,!0);varf=newError("Cannot find module '"+o+"'");throwf.code="MODULE_NOT_FOUND",f}varl=t[o]={exports:{}};e[o][0].call(l.exports,function(t){varn=e[o][1][t];returnr(n?n:t)},l,l.exports,i,e,t,n)}returnt[o].exports}vars=typeofrequire=="function"&&require;for(varo=0;o<n.length;o++)r(n[o]);returnr}({1:[function(e,t,n){varr=function(e,t){if(e<0)thrownewError("start must be a positive number");if(e>=t)thrownewError("start must be smaller than end");this.start=e,this.end=t};r.prototype={diff:function(){returnthis.end-this.start},isLast:function(e){return(e|0)===this.end}},t.exports=r},{}],2:[function(e,t,n){(function(n){functionu(e,t){if(!t.steps)thrownewError("steps option missing");this.options=t,this.running=!1,this._tick=this._tick.bind(this),this._t0=+(newDate),this.callback=e,this._time=0,this.itemsReady=!1,this.options=r.extend({animationDelay:0,maxDelta:.2,loop:t.loop===undefined?!0:t.loop},this.options),this.steps(t.steps)}varr=e("./"),i=e("./animator-steps-range"),s=n.requestAnimationFrame||n.mozRequestAnimationFrame||n.webkitRequestAnimationFrame||n.msRequestAnimationFrame||function(e){returnn.setTimeout(e,1e3/60)},o=n.cancelAnimationFrame||n.mozCancelAnimationFrame||n.webkitCancelAnimationFrame||n.msCancelAnimationFrame||function(e){clearTimeout(e)};u.prototype={start:function(){this.running=!0,s(this._tick),this.options.onStart&&this.options.onStart(),this.stepsRange().diff()===1&&(this.running=!1)},isRunning:function(){returnthis.running},stop:function(){this.pause(),this.time(this.stepsRange().start),this.options.onStop&&this.options.onStop()},time:function(e){if(!arguments.length)returnthis._time;this._time=e;vart=this.range(this.domain(this._time));this.callback(t)},toggle:function(){this.running?this.pause():this.start()},rescale:function(){returnthis.domainInv=r.math.linear(this.options.animationDelay,this.options.animationDelay+this.options.animationDuration),this.domain=this.domainInv.invert(),this.range=r.math.linear(0,this._defaultStepsRange.end),this.rangeInv=this.range.invert(),this.time(this._time),this.running?this.start():this.pause(),this},duration:function(e){returnarguments.length?(this.options.animationDuration=e,this.time()>e&&this.time(0),this.rescale(),this):this.options.animationDuration},steps:function(e){returnthis.options.steps=e,this._defaultStepsRange=newi(0,e),this.rescale()},stepsRange:function(e,t){if(arguments.length===2){if(e<this._defaultStepsRange.start)thrownewError("start must be within default steps range");if(t>this._defaultStepsRange.end)thrownewError("end must be within default steps range");this._customStepsRange=newi(e,t),this.options.onStepsRange&&this.options.onStepsRange();varn=this.step()|0;(n<e||n>t)&&this.step(e)}returnthis._customStepsRange||this._defaultStepsRange},removeCustomStepsRange:function(){this._customStepsRange=undefined,this.options.onStepsRange&&this.options.onStepsRange()},step:function(e){if(arguments.length===0)returnthis.range(this.domain(this._time));this._time=this.domainInv(this.rangeInv(e))},pause:function(){this.running=!1,o(this._tick),this.options.onPause&&this.options.onPause()},_tick:function(){vare=+(newDate),t=(e-this._t0)*.001;t=Math.min(this.options.maxDelta,t),this._t0=e,this._time+=t;varn=this.stepsRange();n.isLast(this.step())&&(this.options.loop?this.step(n.start):(this.time(this.options.animationDuration),this.pause())),this.running&&(this.time(this._time),s(this._tick))}},t.exports=u}).call(this,typeofglobal!="undefined"?global:typeofself!="undefined"?self:typeofwindow!="undefined"?window:{})},{"./":11,"./animator-steps-range":1}],3:[function(e,t,n){var
.getKey());this.renderer.renderTileAccum(n,0,0)},setKey:function(e){this.keys=[e],this.redraw()},setCartoCSS:function(e){if(!this.renderer)thrownewError("renderer is not valid");returnthis.renderer.setCartoCSS(e)},setStepsRange:function(e,t){this.animator.stepsRange(e,t)},removeStepsRange:function(){this.animator.removeCustomStepsRange()},getStepsRange:function(){returnthis.animator.stepsRange()}}),t.exports={GMapsTiledTorqueLayer:f,GMapsTorqueLayer:a}}).call(this,typeofglobal!="undefined"?global:typeofself!="undefined"?self:typeofwindow!="undefined"?window:{})},{"../":11,"./CanvasLayer":6,"./canvas_tile_layer":7,"./gmaps_tileloader_mixin":8,carto:undefined}],11:[function(e,t,n){t.exports=e("./core"),t.exports.Animator=e("./animator"),t.exports.cartocss_reference=e("./cartocss_reference"),t.exports.common=e("./common"),t.exports.math=e("./math"),t.exports.Mercator=e("./mercator"),t.exports.net=e("./request"),t.exports.renderer=e("./renderer"),t.exports.providers=e("./provider"),e("./leaflet");varr=e("./gmaps");t.exports.GMapsTileLoader=r.GMapsTileLoader,t.exports.GMapsTorqueLayer=r.GMapsTorqueLayer,t.exports.GMapsTiledTorqueLayer=r.GMapsTiledTorqueLayer},{"./animator":2,"./cartocss_reference":3,"./common":4,"./core":5,"./gmaps":9,"./leaflet":13,"./math":16,"./mercator":17,"./provider":19,"./renderer":25,"./request":29}],12:[function(e,t,n){e("./leaflet_tileloader_mixin"),L.CanvasLayer=L.Class.extend({includes:[L.Mixin.Events,L.Mixin.TileLoader],options:{minZoom:0,maxZoom:28,tileSize:256,subdomains:"abc",errorTileUrl:"",attribution:"",zoomOffset:0,opacity:1,unloadInvisibleTiles:L.Browser.mobile,updateWhenIdle:L.Browser.mobile,tileLoader:!1,zoomAnimation:!0},initialize:function(e){vart=this;e=e||{},this.render=this.render.bind(this),L.Util.setOptions(this,e),this._canvas=this._createCanvas(),this.options.zoomAnimation&&(this._backCanvas=this._createCanvas()),this._ctx=this._canvas.getContext("2d"),this.currentAnimationFrame=-1,this.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(e){returnwindow.setTimeout(e,1e3/60)},this.cancelAnimationFrame=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame||function(e){clearTimeout(e)}},_createCanvas:function(){vare;e=document.createElement("canvas"),e.style.position="absolute",e.style.top=0,e.style.left=0,e.style.pointerEvents="none",e.style.zIndex=this.options.zIndex||0;vart="leaflet-tile-container";returnthis.options.zoomAnimation&&(t+=" leaflet-zoom-animated"),e.setAttribute("class",t),e},onAdd:function(e){this._map=e;vart=this._map._panes.tilePane,n=L.DomUtil.create("div","leaflet-layer");n.appendChild(this._canvas),this.options.zoomAnimation&&(n.appendChild(this._backCanvas),this._backCanvas.style.display="none"),t.appendChild(n),this._container=n,e.dragging._draggable.on("predrag",function(){vart=e.dragging._draggable;L.DomUtil.setPosition(this._canvas,{x:-t._newPos.x,y:-t._newPos.y})},this),e.on({viewreset:this._reset},this),e.on("move",this.redraw,this),e.on("resize",this._reset,this),this.options.zoomAnimation&&e.on({zoomanim:this._animateZoom,zoomend:this._endZoomAnim,moveend:this._reset},this),this.options.tileLoader&&this._initTileLoader(),this._reset()},_animateZoom:function(e){this._animating||(this._animating=!0);vart=this._backCanvas;t.width=this._canvas.width,t.height=this._canvas.height;varn=this._canvas._leaflet_pos||{x:0,y:0};t.getContext("2d").drawImage(this._canvas,0,0),L.DomUtil.setPosition(t,L.DomUtil.getPosition(this._canvas)),this._canvas.style.display="none",t.style.display="block";varr=this._map,i=r.getZoomScale(e.zoom),s=r._latLngToNewLayerPoint(r.getCenter(),e.zoom,e.center),o=r._latLngToNewLayerPoint(e.center,e.zoom,e.center),u={x:s.x-o.x+n.x,y:s.y-o.y+n.y},a=t,f=L.DomUtil.TRANSFORM;setTimeout(function(){a.style[f]=L.DomUtil.getTranslateString(u)+" scale("+e.scale+") "},0)},_endZoomAnim:function(){this._animating=!1,this._canvas.style.display="block",t
,s=this.options.subdomains||"0123",o=Math.pow(2,t),u=(e.x%o+o)%o,a=Math.abs(u+e.y)%s.length,f=this._extraParams(),l=this.templateUrl.replace("{x}",u).replace("{y}",e.y).replace("{z}",t).replace("{s}",s[a]);l+=f,r.net.get(l,function(r){if(r&&r.responseText){vars=JSON.parse(r.responseText);n(i.proccessTile(s,e,t))}elsen(null)})},getKeySpan:function(){return{start:this.options.start,end:this.options.end,step:this.options.step,steps:this.options.steps,columnType:this.options.column_type}},setColumn:function(e,t){this.options.column=e,this.options.is_time=t===undefined?!0:!1,this.reload()},reload:function(){this._ready=!1,this._fetchMap()},getSteps:function(){returnMath.min(this.options.steps,this.options.data_steps)},getBounds:function(){returnthis.options.bounds},getSQL:function(){returnthis.options.sql||"select * from "+this.options.table},setSQL:function(e){this.options.sql!=e&&(this.options.sql=e,this.reload())},_isUserTemplateUrl:function(e){returne&&e.indexOf("{user}")!==-1},isHttps:function(){returnthis.options.maps_api_template.indexOf("https")===0},_fetchMap:function(e){vart=this;r.net.get(this.options.tileJSON,function(e){e=JSON.parse(e.response);if(e){if(e.errors){t.options.errorCallback&&t.options.errorCallback(e.errors);return}for(varnine)t.options[n]=e[n];t.templateUrl=e.tiles[0],t.templateUrl.indexOf("http")!==0&&(t.templateUrl=t.options.tileJSON.substring(0,t.options.tileJSON.lastIndexOf("/")+1)+t.templateUrl),t._setReady(!0)}})}},t.exports=f},{"../":11}],23:[function(e,t,n){functionf(e){for(vart=1;t<arguments.length;++t){varn=arguments[t];for(varrinn)e=e.replace(RegExp("\\{"+r+"\\}","g"),n[r])}returne}varr=e("../"),i=e("../profiler"),s=r.types.Uint8Array,o=r.types.Int32Array,u=r.types.Uint32Array,a=r.types.Uint8ClampedArray,l=function(e){this._ready=!1,this._tileQueue=[],this.options=e,this.options.is_time=this.options.is_time===undefined?!0:this.options.is_time,this.options.tiler_protocol=e.tiler_protocol||"http",this.options.tiler_domain=e.tiler_domain||"cartodb.com",this.options.tiler_port=e.tiler_port||80,e.maps_api_template?this.options.maps_api_template=e.maps_api_template:this._buildMapsApiTemplate(this.options),this.options.coordinates_data_type=this.options.coordinates_data_type||s,this.options.data_aggregation&&(this.options.cumulative=this.options.data_aggregation==="cumulative");if(this.options.auth_token){vart=this.options.extra_params||(this.options.extra_params={});t.auth_token=this.options.auth_token}this.options.no_fetch_map||this._fetchMap()};l.prototype={proccessTile:function(e,t,n){varr,s=newthis.options.coordinates_data_type(e.length),f=newthis.options.coordinates_data_type(e.length),l=i.metric("torque.provider.windshaft.mem"),c=i.metric("torque.provider.windshaft.points"),h=i.metric("torque.provider.windshaft.process_time").start(),p=0,d=-1;for(r=0;r<e.length;++r){varv=e[r];p+=v.dates__uint16.length;for(varm=0;m<v.dates__uint16.length;++m)d=Math.max(d,v.dates__uint16[m])}this.options.cumulative&&(p=(1+d)*e.length);varg=this.options.cumulative?u:a,y=newo(d+1),b=newo(d+1),w=new(this.options.valueDataType||g)(p),E=newu(p);l.inc(4*d+4*d+p+p*4),c.inc(e.length);varS={};for(varr=0;r<e.length;++r){varv=e[r];s[r]=v.x__uint8*this.options.resolution,f[r]=v.y__uint8*this.options.resolution;varp=v.dates__uint16,x=v.vals__uint8;if(!this.options.cumulative)for(varT=0,N=p.length;T<N;++T){varC=S[p[T]]||(S[p[T]]=[]);this.options.cumulative&&(x[T]+=prev_val),prev_val=x[T],C.push([r,x[T]])}else{vark={};for(varT=0,N=p.length;T<N;++T)k[p[T]]=x[T];varL=0;for(varT=p[0];T<=d;++T){varC=S[T]||(S[T]=[]),A=k[T];A&&(L+=A),C.push([r,L])}}}varO=0,M=0,_=0;for(var_=0;_<=d;++_){varD=0,P=S[_];if(P)for(varr=0;r<P.length;++r){varC=P[r];++D,E[O]=C[0],w[O]=C[1],++O}y[_]=M,b[_]=D,M+=D}returnh.end(),{x:s,y:f,z:n,coord:{x:t.x,y:t.y,z:n},timeCount:b,timeIndex:y,renderDataPos:E,renderData:w,maxDate:d}},setSteps:function(e,t){t=t||{},this.options.steps!==e&&(this.options.steps=e,this.options.step=(this.options.end-this.options.start)/this.getSteps(),this.options.step=this.options.step|