lizMap.events.on({uicreated:function(e){var t,a=lizMap.config,n=(lizMap.layers,!1),i=0;if(!("timemanagerLayers"in a))return-1;t=Object.keys(lizMap.config.timemanagerLayers).length,$("#timemanager-menu button.btn-timemanager-clear").click((function(){$("#button-timemanager").click()})),lizMap.events.on({minidockopened:function(e){"timemanager"==e.id&&(n||($("#timemanager-menu").show(),function(){var e=1/0,n=-1/0;for(var r in a.timemanagerLayers)d(a.timemanagerLayers[r],(function(l,s){a.timemanagerLayers[r].min=l,a.timemanagerLayers[r].max=s;var f=moment(l).startOf(c.slice(0,-1)),d=moment(s).endOf(c.slice(0,-1));f&&f<e&&(e=f),d&&d>n&&(n=d),u=moment(e),o=moment(n),m=moment(u),$("#tmCurrentValue").html(x(u,c)),$("#tmNextValue").html(x(o,c)),Y(),$("#tmSlider").slider({min:u.valueOf(),max:o.startOf(c.slice(0,-1)).valueOf(),value:u.valueOf()}),v((i+=1)==t)}));b()}(),n=!0))},minidockclosed:function(e){"timemanager"==e.id&&n&&(h(!0),$("#timemanager-menu").hide(),n=!1,function(){for(var e in lizMap.config.timemanagerLayers)lizMap.deactivateMaplayerFilter(e),lizMap.config.layers[e].request_params.filtertoken=null,lizMap.events.triggerEvent("layerFilterParamChanged",{featureType:e,filter:null,updateDrawing:!1})}())}}),$("#tmSlider").slider();var r,m,l=null,u=-1/0,o=1/0,s=a.options.tmTimeFrameSize,c=a.options.tmTimeFrameType,f=a.options.tmAnimationFrameLength;function d(e,t){var a=e.startAttribute;if(e.endAttribute&&""!=e.endAttribute&&e.endAttribute!=e.startAttribute&&(a+=","+e.endAttribute),"min_timestamp"in e&&e.min_timestamp&&""!=e.min_timestamp&&"max_timestamp"in e&&e.max_timestamp&&""!=e.max_timestamp){var n=e.min_timestamp,i=e.max_timestamp;return t(n,i),!0}var r={request:"getMinAndMaxValues",layerId:e.layerId,fieldname:a,filter:""};$.get(filterConfigData.url,r,(function(e){if(!e)return!1;if("status"in e&&"error"==e.status)return console.log(e.title+": "+e.detail),!1;var a=null,n=null;for(var i in e){var r=e[i];a=r.min,n=r.max}t(a,n)}),"json")}function g(e,t,a,n,i){var r=moment(e).startOf(a),m=n*s*i;return r.add(m,a),r}function v(e){if(!e)return!0;b()}function p(e,t,a){var n=[];if(t==e.min&&a==e.max)return e.data={min_date:null,max_date:null},e.filter=null,null;var i=e.startAttribute,r=e.endAttribute,m=e.attributeResolution;if(t&&Date.parse(t)){var l='( "'+i+"\" >= '"+x(t,m)+"'";r&&""!=r&&r!=i&&(l+=' OR  "'+r+"\" >= '"+x(t,m)+"'"),l+=" )",n.push(l)}else t=null;if(a&&Date.parse(a)){var u='( "'+i+"\" <= '"+x(a,m)+"'";r&&""!=r&&r!=i&&(u+=' OR  "'+r+"\" <= '"+x(a,m)+"'"),u+=" )",n.push(u)}else a=null;var o=null;return n.length&&(o=" ( ",o+=n.join(" AND "),o+=" ) "),e.data={min_date:t,max_date:a},e.filter=o,o}function y(){var e=g(m,0,c,1,1);e.startOf(c.slice(0,-1))<=o.startOf(c.slice(0,-1))?M(e,g(m,0,c,2,1)):(h(!0),b())}function Y(){var e=$("#tmCurrentValue").text()==$("#tmNextValue").text();$("#tmNextValue").toggle(!e),$("#tmNextValue").prev("span").toggle(!e)}function M(e,t){!function(e,t){for(var n in t.subtract(1,"milliseconds"),a.timemanagerLayers)l=p(a.timemanagerLayers[n],e,t),lizMap.triggerLayerFilter(n,l)}(e,t),m=moment(e),$("#tmCurrentValue").html(x(m,c)),$("#tmNextValue").html(x(moment(t),c)),Y(),$("#tmSlider").slider("option","value",m.valueOf())}function b(){var e=$("#tmSlider").slider("option","value"),t=moment(e);M(t=t.startOf(c.slice(0,-1)),g(t,0,c,1,1))}function h(e){if(window.clearInterval(r),r=null,$("#tmTogglePlay").html(lizDict["timemanager.toolbar.play"]),!0===e){m=moment(u),$("#tmCurrentValue").html(x(m,c)),$("#tmSlider").slider("option","value",m.valueOf());var t=g(m,0,c,1,1);$("#tmNextValue").html(x(t,c)),Y()}}function x(e,t){var a=moment(e),n=null;switch(t){case"milliseconds":case"seconds":n="YYYY-MM-DD HH:mm:ss";break;case"minutes":n="YYYY-MM-DD HH:mm:00";break;case"hours":n="YYYY-MM-DD HH:00";break;case"days":case"weeks":n="YYYY-MM-DD";break;case"months":n="YYYY-MM";break;case"years":n="YYYY"}return a.format(n)}f<1e3&&(f=1e3),$("#tmSlider").on("slide",(function(e,t){$("#tmSlider").slider("option","value")})),$("#tmSlider").on("slidestop",(function(e,t){b()})),$("#tmTogglePlay").click((function(){$(this).html()==lizDict["timemanager.toolbar.play"]?function(){r&&h(!0),$("#tmTogglePlay").html(lizDict["timemanager.toolbar.pause"]),m||(m=u);r=window.setInterval((function(){y()}),f)}():h()})),$("#tmPrev").click((function(){var e;h(!1),(e=g(m,0,c,1,-1)).startOf(c.slice(0,-1))>=u.startOf(c.slice(0,-1))?M(e,moment(m)):(h(!0),b())})),$("#tmNext").click((function(){h(!1),y()}))}});
//# sourceMappingURL=timemanager.js.map