!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
this,i=1<<n,s={x:(t.x%i+i)%i,y:t.y};this.provider.getTileData(s,n,function(t){r._tileLoaded(e,t)})},drawTile:function(e){vart=e.canvas;if(!e.data)return;t.width=t.width,this.renderer.setCanvas(t);varn=this.renderer.accumulate(e.data,this.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,e("./ol")},{"./animator":2,"./cartocss_reference":3,"./common":4,"./core":5,"./gmaps":9,"./leaflet":13,"./math":16,"./mercator":17,"./ol":19,"./provider":23,"./renderer":30,"./request":34}],12:[function(e,t,n){e("./leaflet_tileloader_mixin"),L.CanvasLayer=L.Layer.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._latLngToNewLayerPoi
;++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,f=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,this.options.data_aggregation&&(this.options.cumulative=this.options.data_aggregation==="cumulative");if(e.resolution===undefined)thrownewError("resolution should be provided");if(e.steps===undefined)thrownewError("steps should be provided");e.start===undefined?this._fetchKeySpan():this._setReady(!0)};f.prototype={proccessTile:function(e,t,n){varr,a=news(e.length),f=news(e.length),l=i.metric("ProviderJSON:mem"),c=i.metric("ProviderJSON:point_count"),h=i.metric("ProviderJSON: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:s,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];a[r]=v.x__uint8*this.options.resolution,v.y__uint8===-1?f[r]=0: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:a,y:f,z:n,coord:{x:t.x,y:t.y,z:n},timeCount:b,timeIndex:y,renderDataPos:E,renderData:w,maxDate:d}},_host:function(){vare=this.options,t=e.sql_api_port,n=(e.user_name||e.user)+"."+(e.sql_api_domain||"cartodb.com")+(t?":"+t:""),r=e.sql_api_protocol||"http";returnthis.options.url||r+"://"+n+"/api/v2/sql"},url:function(e){vart=this.options,n=t.sql_api_protocol||"http";if(!this.options.cdn_url)returnthis._host();varr=n+"://";e&&(r+=e+".");vari=t.cdn_url;if(!i.http&&!i.https)thrownewError("cdn_host should contain http and/or https entries");returnr+=i[n]+"/"+(t.user_name||t.user)+"/api/v2/sql",r},_hash:function(e){vart=0;if(!e||e.length==0)returnt;for(varn=0,r=e.length;n<r;++n)t=(t<<5)-t+e.charCodeAt(n)|0;returnt},_extraParams:function(){if(this.options.extra_params){vare=[];for(vartinthis.options.extra_params){varn=this.options.extra_params[t];n&&e.push(t+"="+encodeURIComponent(n))}returne.join("&")}returnnull},isHttps:function(){returnthis.options.sql_api_protocol&&this.options.sql_api_protocol==="https"},sql:function(e,t,n){n=n||{};vari=this.options.subdomains||"0123";this.isHttps()&&(i=[null]);vars;n.no_cdn?s=this._host():s=this.url(i[Math.abs(this._hash(e))%i.length]);varo=this._extraParams();r.net.get(s+"?q="+encodeURIComponent(e)+(o?"&"+o:""),function(e){n.parseJSON&&(e=JSON.parse(e&&e.responseText)),t&&t(e)})},getTileData:function(e,t,n){this._ready?this._getTileData(e,t,n):this._tileQueue.push([e,t,n])},_setReady:function(e){this._ready=!0,this._processQueue(),this.options.ready&&this.options.ready()},_processQueue:function(){vare;while(e=this._tileQueue.pop())this._getTileData.apply(this,e)},_getTileData:function(e,t,n){varr=i.metric("ProviderJSON:tile_fetch_time").start();this.table=this.options.table;vars=1<<t,o=this.options.column;this.options.is_time&&(o=a("date_part('epoch', {column})",this.options));varu="WITHparAS(SELECTCDB_XYZ_Resolution({zoom})*{resolution}asres,256/{resolution}astile_size,CDB_XYZ_Extent({x},{y},{zoom})asext),cteAS(SELECTST_SnapToGrid(i.the_geom_webmercator,p.res)g,{countby}c,floor(({colu