/*
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","../../chunks/tslib.es6","../../core/Logger","../../core/promiseUtils","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","./refresh"],(function(e,r,t,s,a,o,n,i,c,h,u){"use strict";function p(e){return e&&"object"==typeof e&&"refreshTimestamp"in e&&"refresh"in e}const l=e=>{let n=function(e){function t(...t){var s;return(s=e.call(this,...t)||this).refreshInterval=0,s.refreshTimestamp=0,s._debounceHasDataChanged=a.debounce((()=>s.hasDataChanged())),s.when().then((()=>{u.registerLayer(r._assertThisInitialized(s))}),(()=>{})),s}r._inheritsLoose(t,e);var o=t.prototype;return o.destroy=function(){u.unregisterLayer(this)},o.refresh=function(e=Date.now()){a.ignoreAbortErrors(this._debounceHasDataChanged()).then((r=>{r&&this._set("refreshTimestamp",e),this.emit("refresh",{dataChanged:r})}),(e=>{s.getLogger(this.declaredClass).error(e),this.emit("refresh",{dataChanged:!1,error:e})}))},o.hasDataChanged=function(){var e=r._asyncToGenerator((function*(){return!0}));function t(){return e.apply(this,arguments)}return t}(),r._createClass(t,[{key:"refreshParameters",get:function(){return{_ts:this.refreshTimestamp||null}}}]),t}(e);return t.__decorate([o.property({type:Number,cast:e=>e>=.1?e:e<=0?0:.1,json:{write:!0}})],n.prototype,"refreshInterval",void 0),t.__decorate([o.property({readOnly:!0})],n.prototype,"refreshTimestamp",void 0),t.__decorate([o.property()],n.prototype,"refreshParameters",null),n=t.__decorate([h.subclass("esri.layers.mixins.RefreshableLayer")],n),n};e.RefreshableLayer=l,e.isRefreshableLayer=p,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
