/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../chunks/_rollupPluginBabelHelpers","../TimeExtent","../core/maybe","../core/promiseUtils","../core/timeUtils"],(function(e,t,n,i,o,r){"use strict";function s(e){return void 0!==e.timeInfo}function u(e,t){return a.apply(this,arguments)}function a(){return a=t._asyncToGenerator((function*(e,r){if(0===e.length)return n.allTime;const u=e.filter(s);yield Promise.all(u.map((e=>e.load({signal:r}))));const a=[],f=[];for(const t of u)"feature"!==(null==t?void 0:t.type)&&"map-image"!==(null==t?void 0:t.type)||!t.timeInfo.hasLiveData?f.push(t):a.push(t);const l=e=>i.isNone(e)||e.isAllTime,m=f.map((e=>e.timeInfo.fullTimeExtent));if(m.some(l))return n.allTime;const c=a.map(function(){var e=t._asyncToGenerator((function*(e){const{timeExtent:t}=yield e.fetchRecomputedExtents({signal:r});return t||i.unwrap(e.timeInfo.fullTimeExtent)}));return function(t){return e.apply(this,arguments)}}()),p=(yield o.eachAlways(c)).map((e=>e.value));if(p.some(l))return n.allTime;return p.concat(m).reduce(((e,t)=>e.union(t)))})),a.apply(this,arguments)}function f(e){if(!e)return e;const{start:t,end:o}=e;return new n({start:i.isSome(t)?r.offsetDate(t,-t.getTimezoneOffset(),"minutes"):t,end:i.isSome(o)?r.offsetDate(o,-o.getTimezoneOffset(),"minutes"):o})}function l(e){if(!e)return e;const{start:t,end:o}=e;return new n({start:i.isSome(t)?r.offsetDate(t,t.getTimezoneOffset(),"minutes"):t,end:i.isSome(o)?r.offsetDate(o,o.getTimezoneOffset(),"minutes"):o})}e.getTimeExtentFromLayers=u,e.toLocalTimeExtent=l,e.toUTCTimeExtent=f,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
