// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
define("dojo/_base/declare dojo/_base/lang dojo/_base/config dojo/Evented dijit/_WidgetBase dojo/when dojo/promise/all dojo/Deferred esri/request ./utils moment/moment dojo/date/locale dojo/i18n esri/lang esri/TimeExtent".split(" "),function(v,f,w,x,y,q,r,z,A,g,t,l,u,B,C){var n=v([y,x],{nls:null,config:null,map:null,layerInfosObj:null,_INIT_TIME_STEAMP:null,setLayerInfosObj:function(a){this.layerInfosObj=a},_getUpdatedFullTime:function(){var a=0,b,c=[];a=0;for(b=this.map.layerIds.length;a<b;a++){var d=
this.map.layerIds[a];d=this.map.getLayer(d);c.push(this._getUpdatedTime(d))}a=0;for(b=this.map.graphicsLayerIds.length;a<b;a++)d=this.map.graphicsLayerIds[a],d=this.map.getLayer(d),c.push(this._getUpdatedTime(d));return r(c).then(f.hitch(this,function(e){return this._getFullTimeExtent(e)}))},_getFullTimeExtent:function(a){return g.getFullTimeExtent(a)},_getUpdatedTime:function(a){if(a&&a.url&&g.hasLiveData(a)){var b=null;return A({url:a.url,callbackParamName:"callback",content:{f:"json",returnUpdates:!0}}).then(f.hitch(this,
function(c){c.timeExtent&&2===c.timeExtent.length&&(b=new C,b.startTime=new Date(c.timeExtent[0]),b.endTime=new Date(c.timeExtent[1]),a.timeInfo.timeExtent=b)})).always(f.hitch(this,function(){return q(b||f.getObject("timeInfo.timeExtent",!1,a)||null)}))}return q(f.getObject("timeInfo.timeExtent",!1,a)||null)},getUpdatedFullTime:function(){var a=0,b,c=[];a=0;for(b=this.map.layerIds.length;a<b;a++){var d=this.map.layerIds[a];d=this.map.getLayer(d);c.push(this._getUpdatedTime(d))}a=0;for(b=this.map.graphicsLayerIds.length;a<
b;a++)d=this.map.graphicsLayerIds[a],d=this.map.getLayer(d),c.push(this._getUpdatedTime(d));return r(c).then(f.hitch(this,function(e){return this._getFullTimeExtent(e)}))},setTimeSlider:function(a){this.timeSlider=a;this._INIT_TIME_STEAMP=(new Date).getTime()},_getTimeFormatLabel:function(a){var b=this.nls.timeExtent,c=null,d=null,e="",h="";if(!a&&this.timeSlider)2===this.timeSlider.thumbCount?(c=this.timeSlider.timeStops[this.timeSlider.thumbIndexes[0]],d=this.timeSlider.timeStops[this.timeSlider.thumbIndexes[1]]):
c=this.timeSlider.timeStops[this.timeSlider.thumbIndexes[0]];else if(a||this.timeSlider)c=a.startTime,0<a.endTime.getTime()-a.startTime.getTime()&&(d=a.endTime);else return"";if("auto"===this.config.timeFormat||"Custom"===this.config.timeFormat&&""===this.config.customDateFormat){var p=null,m=a=null,k=!1;e=n.localeDic[w.locale]||n.localeDic.en;d&&c.getFullYear()===d.getFullYear()?(c.getMonth()===d.getMonth()?c.getDate()===d.getDate()?a=c.getHours()===d.getHours()?c.getMinutes()===d.getMinutes()?c.getSeconds()===
d.getSeconds()?e.millisecondTimePattern:e.secondTimePattern:e.minuteTimePattern:e.minuteTimePattern:(2>d.getDate()-c.getDate()&&(a=e.minuteTimePattern),k=!0):k=!0,m="long"):d&&10<d.getFullYear()-c.getFullYear()?(p=e.yearPattern,k=!0):(k=!0,m="long");e=l.format(c,{datePattern:p,formatLength:m,selector:"date"});a&&(c=l.format(c,{timePattern:a,selector:"time"}),e=u.getLocalization("dojo.cldr","gregorian")["dateTimeFormat-medium"].replace(/\{1\}/g,e).replace(/\{0\}/g,c));g.isValidDataStrByDateLocale(e)||
(e="");d&&(k&&(h=l.format(d,{datePattern:p,formatLength:m,selector:"date"})),a&&(c=l.format(d,{timePattern:a,selector:"time"}),h=k&&a?u.getLocalization("dojo.cldr","gregorian")["dateTimeFormat-medium"].replace(/\{1\}/g,h).replace(/\{0\}/g,c):c));g.isValidDataStrByDateLocale(h)||(h="")}else a="Custom"===this.config.timeFormat?this.config.customDateFormat:this.config.timeFormat,e=t(c.getTime()).format(a),d&&(h=t(d.getTime()).format(a));return b=d?B.substitute({FROMTIME:e,ENDTIME:h},b):e+""},findDefaultInterval:function(a){a=
(a.endTime.getTime()-a.startTime.getTime())/10;if(31104E8<a){a=Math.round(a/31104E8);var b="esriTimeUnitsCenturies"}else 31104E7<a?(a=Math.round(a/31104E7),b="esriTimeUnitsDecades"):31104E6<a?(a=Math.round(a/31104E6),b="esriTimeUnitsYears"):2592E6<a?(a=Math.round(a/2592E6),b="esriTimeUnitsMonths"):6048E5<a?(a=Math.round(a/6048E5),b="esriTimeUnitsWeeks"):864E5<a?(a=Math.round(a/864E5),b="esriTimeUnitsDays"):36E5<a?(a=Math.round(a/36E5),b="esriTimeUnitsHours"):6E4<a?(a=Math.round(a/6E4),b="esriTimeUnitsMinutes"):
1E3<a?(a=Math.round(a/1E3),b="esriTimeUnitsSeconds"):(a=Math.round(a),b="esriTimeUnitsMilliseconds");0===a&&(a=1);return{interval:a,units:b}},getPropsFromMultiLayerInfos:function(a,b){var c={};null===b?(c=a,c.thumbCount=2,c.thumbMovingRate=2E3):(c=b,a.timeExtent[0]<c.timeExtent[0]&&(c.timeExtent[0]=a.timeExtent[0]),a.timeExtent[1]>c.timeExtent[1]&&(c.timeExtent[1]=a.timeExtent[1]));return c},getTsPros:function(){var a=new z,b=f.getObject("itemData.widgets.timeSlider.properties",!1,this.map&&this.map.itemInfo),
c={};b?(c=f.clone(b),a.resolve(c)):a.resolve(null);return a},findClosestThumbIndex:function(a,b){a=a.timeStops;var c=a[0];if(b<c)return 0;for(var d=1;d<a.length;d++){if(a[d]>=b)return b-c<a[d]-b?d-1:d;if(d<a.length-1)c=a[d];else return d}},getCurrentTimeStops:function(a){var b=null,c=null;1===this.timeSlider.thumbCount?b=this.timeSlider.timeStops[this.timeSlider.thumbIndexes[0]]:2===this.timeSlider.thumbCount&&(b=this.timeSlider.timeStops[this.timeSlider.thumbIndexes[0]],c=this.timeSlider.timeStops[this.timeSlider.thumbIndexes[1]]);
return{timeStamp:a,thumbCount:this.timeSlider.thumbCount,startTime:(new Date(b)).getTime(),endTime:(new Date(c)).getTime()}},setAutoRefreshTimer:function(a){var b=this.config;if(b&&b.autoRefresh&&!0===b.autoRefresh.isAutoRefresh){if(this._autoRefreshFlag=!0,b=g.getAutoRefreshTime(b))this._autoRefreshTimer=setTimeout(f.hitch(this,function(){var c=this.getCurrentTimeStops(this._INIT_TIME_STEAMP);g.saveToLocalCache(this.widgetId,c);a._closeHanlder();a._openHanlder()}),b)}else this._autoRefreshFlag=!1,
this.clearAutoRefreshTimer()},clearAutoRefreshTimer:function(){this._autoRefreshTimer&&clearTimeout(this._autoRefreshTimer)},restoreAutoRefreshTimer:function(a){var b=g.getCacheByKeys(this.widgetId);if(b&&b.timeStamp&&this._INIT_TIME_STEAMP===b.timeStamp){a.setThumbCount(b.thumbCount);var c=this.findClosestThumbIndex(a,b.startTime);1===a.thumbCount?a.setThumbIndexes([c]):2===a.thumbCount&&(b=this.findClosestThumbIndex(a,b.endTime),a.setThumbIndexes([c,b]))}}});n.localeDic={ar:{datePattern:"dd MMMM, yyyy",
yearPattern:"yyyy",hourTimePattern:"h a",minuteTimePattern:"h:mm a",secondTimePattern:"h:mm:ss a",millisecondTimePattern:"h:mm:ss:SSS a"},cs:{datePattern:"MMMM d, yyyy",yearPattern:"yyyy",hourTimePattern:"H",minuteTimePattern:"h:mm",secondTimePattern:"H:mm:ss",millisecondTimePattern:"H:mm:ss:SSS"},da:{datePattern:"d. MMMM yyyy",yearPattern:"yyyy",hourTimePattern:"H",minuteTimePattern:"H:mm",secondTimePattern:"H:mm:ss",millisecondTimePattern:"H:mm:ss:SSS"},de:{datePattern:"d. MMMM yyyy",yearPattern:"yyyy",
hourTimePattern:"H",minuteTimePattern:"H:mm",secondTimePattern:"H:mm:ss",millisecondTimePattern:"H:mm:ss:SSS"},el:{datePattern:"d MMMM yyyy",yearPattern:"yyyy",hourTimePattern:"h",minuteTimePattern:"hh:mm",secondTimePattern:"hh:mm:ss",millisecondTimePattern:"hh:mm:ss:SSS"},es:{datePattern:"d' de 'MMMM' de 'yyyy",yearPattern:"yyyy",hourTimePattern:"H",minuteTimePattern:"H:mm",secondTimePattern:"H:mm:ss",millisecondTimePattern:"H:mm:ss:SSS"},et:{datePattern:"d. MMMM yyyy",yearPattern:"yyyy",hourTimePattern:"H",
minuteTimePattern:"H:mm",secondTimePattern:"H:mm:ss",millisecondTimePattern:"H:mm:ss:SSS"},fi:{datePattern:"d. MMMM yyyy",yearPattern:"yyyy",hourTimePattern:"t",minuteTimePattern:"t:mm a",secondTimePattern:"t:mm:ss",millisecondTimePattern:"h:mm:ss:SSS"},fr:{datePattern:"d MMMM yyyy",yearPattern:"yyyy",hourTimePattern:"HH",minuteTimePattern:"HH:mm",secondTimePattern:"HH:mm:ss",millisecondTimePattern:"HH:mm:ss:SSS"},he:{datePattern:"d, MMMM ,yyyy",yearPattern:"yyyy",hourTimePattern:"h a",minuteTimePattern:"h:mm a",
secondTimePattern:"h:mm:ss a",millisecondTimePattern:"h:mm:ss:SSS a"},it:{datePattern:"d MMMM yyyy",yearPattern:"yyyy",hourTimePattern:"H",minuteTimePattern:"H.mm",secondTimePattern:"H.mm.ss",millisecondTimePattern:"H.mm.ss.SSS"},ja:{datePattern:"yyyy'\u5e74'M'\u6708'd'\u65e5'",yearPattern:"yyyy'\u5e74'",hourTimePattern:"h a",minuteTimePattern:"h:mm a",secondTimePattern:"h:mm:ss a",millisecondTimePattern:"h:mm:ss:SSS a"},ko:{datePattern:"yyyy\ub144 M\uc6d4 d\uc77c",yearPattern:"yyyy\ub144",hourTimePattern:"a h\uc2dc",
minuteTimePattern:"a h:mm",secondTimePattern:"a h:mm:ss",millisecondTimePattern:"a h:mm:ss:SSS"},lt:{datePattern:"yyyy MMMM dd",yearPattern:"yyyy",hourTimePattern:"H a",minuteTimePattern:"HH:mm",secondTimePattern:"HH:mm:ss",millisecondTimePattern:"HH:mm:ss:SSS"},lv:{datePattern:"dd.MM.yyyy",yearPattern:"yyyy",hourTimePattern:"H a",minuteTimePattern:"HH:mm",secondTimePattern:"HH:mm:ss",millisecondTimePattern:"HH:mm:ss:SSS"},nb:{datePattern:"d. MMMM yyyy",yearPattern:"yyyy",hourTimePattern:"H",minuteTimePattern:"H.mm",
secondTimePattern:"H.mm.ss",millisecondTimePattern:"H.mm.ss.SSS"},nl:{datePattern:"d. MMMM yyyy",yearPattern:"yyyy",hourTimePattern:"H",minuteTimePattern:"H:mm",secondTimePattern:"H:mm:ss",millisecondTimePattern:"H:mm:ss:SSS"},pl:{datePattern:"dd-mm-yyyy",yearPattern:"yyyy",hourTimePattern:"hh",minuteTimePattern:"hh:mm",secondTimePattern:"hh:mm:ss",millisecondTimePattern:"hh:mm:ss:SSS"},"pt-br":{datePattern:"d' de 'MMMM' de 'yyyy",yearPattern:"yyyy",hourTimePattern:"H",minuteTimePattern:"h:mm a",
secondTimePattern:"H:mm:ss",millisecondTimePattern:"H:mm:ss:SSS"},"pt-pt":{datePattern:"d' de 'MMMM' de 'yyyy",yearPattern:"yyyy",hourTimePattern:"H",minuteTimePattern:"H:mm",secondTimePattern:"H:mm:ss",millisecondTimePattern:"H:mm:ss:SSS"},ro:{datePattern:"d. MMMM yyyy",yearPattern:"yyyy",hourTimePattern:"H",minuteTimePattern:"H:mm",secondTimePattern:"H:mm:ss",millisecondTimePattern:"H:mm:ss:SSS"},ru:{datePattern:"MMMM d, yyyy",yearPattern:"yyyy",hourTimePattern:"H",minuteTimePattern:"h:mm",secondTimePattern:"h:mm:ss",
millisecondTimePattern:"h:mm:ss:SSS"},sv:{datePattern:"MMMM d, yyyy",yearPattern:"yyyy",hourTimePattern:"h a",minuteTimePattern:"h:mm a",secondTimePattern:"h:mm:ss a",millisecondTimePattern:"h:mm:ss:SSS a"},th:{datePattern:"d MMMM,yyyy",yearPattern:"yyyy",hourTimePattern:"H a",minuteTimePattern:"h:mm a",secondTimePattern:"h:mm:ss a",millisecondTimePattern:"h:mm:ss:SSS a"},tr:{datePattern:"d MMMM yyyy",yearPattern:"yyyy",hourTimePattern:"h a",minuteTimePattern:"h:mm a",secondTimePattern:"h:mm:ss a",
millisecondTimePattern:"h:mm:ss:SSS a"},vi:{datePattern:"d MMMM, yyyy",yearPattern:"yyyy",hourTimePattern:"h a",minuteTimePattern:"h:mm a",secondTimePattern:"h:mm:ss a",millisecondTimePattern:"h:mm:ss:SSS a"},"zh-cn":{datePattern:"yyyy'\u5e74'M'\u6708'd'\u65e5'",yearPattern:"yyyy'\u5e74'",hourTimePattern:"H",minuteTimePattern:"H:mm",secondTimePattern:"H:mm:ss",millisecondTimePattern:"H:mm:ss:SSS"},"zh-hk":{datePattern:"\u5e74\u6708\u65e5",yearPattern:"yyyy",hourTimePattern:"h a",minuteTimePattern:"h:mm a",
secondTimePattern:"h:mm:ss a",millisecondTimePattern:"h:mm:ss:SSS a"},"zh-tw":{datePattern:"\u5e74\u6708\u65e5",yearPattern:"yyyy",hourTimePattern:"h a",minuteTimePattern:"h:mm a",secondTimePattern:"h:mm:ss a",millisecondTimePattern:"h:mm:ss:SSS a"},en:{datePattern:"MMMM d, yyyy",yearPattern:"yyyy",hourTimePattern:"h a",minuteTimePattern:"h:mm a",secondTimePattern:"h:mm:ss a",millisecondTimePattern:"h:mm:ss:SSS a"}};return n});