/*
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","./Accessor","./maybe","./promiseUtils","./accessorSupport/decorators/subclass"],(function(s,e,i,r,t,o,n){"use strict";var l;!function(s){s[s.PENDING=0]="PENDING",s[s.RESOLVED=1]="RESOLVED",s[s.REJECTED=2]="REJECTED"}(l||(l={}));let u=function(){function s(s){this.instance=s,this._resolver=o.createDeferred(),this._status=l.PENDING,this._resolvingPromises=[],this._resolver.promise.then((()=>{this._status=l.RESOLVED,this._cleanUp()}),(()=>{this._status=l.REJECTED,this._cleanUp()}))}var e=s.prototype;return e.addResolvingPromise=function(s){this._resolvingPromises.push(s),this._tryResolve()},e.isResolved=function(){return this._status===l.RESOLVED},e.isRejected=function(){return this._status===l.REJECTED},e.isFulfilled=function(){return this._status!==l.PENDING},e.abort=function(){this._resolver.reject(o.createAbortError())},e.when=function(s,e){return this._resolver.promise.then(s,e)},e._cleanUp=function(){this._allPromise=this._resolvingPromises=this._allPromise=null},e._tryResolve=function(){if(this.isFulfilled())return;const s=o.createDeferred(),e=[...this._resolvingPromises,t.assumeNonNull(s.promise)],i=this._allPromise=Promise.all(e);i.then((()=>{this.isFulfilled()||this._allPromise!==i||this._resolver.resolve(this.instance)}),(s=>{this.isFulfilled()||this._allPromise!==i||o.isAbortError(s)||this._resolver.reject(s)})),s.resolve()},s}();const c=s=>{let r=function(s){function i(...i){var r;return(r=s.call(this,...i)||this)._promiseProps=new u(e._assertThisInitialized(r)),r.addResolvingPromise(Promise.resolve()),r}e._inheritsLoose(i,s);var r=i.prototype;return r.isResolved=function(){return this._promiseProps.isResolved()},r.isRejected=function(){return this._promiseProps.isRejected()},r.isFulfilled=function(){return this._promiseProps.isFulfilled()},r.when=function(s,e){return new Promise(((s,e)=>{this._promiseProps.when(s,e)})).then(s,e)},r.catch=function(s){return this.when(null,s)},r.addResolvingPromise=function(s){s&&!this._promiseProps.isFulfilled()&&this._promiseProps.addResolvingPromise("_promiseProps"in s?s.when():s)},i}(s);return r=i.__decorate([n.subclass("esri.core.Promise")],r),r};s.EsriPromise=function(s){function i(){return s.apply(this,arguments)||this}return e._inheritsLoose(i,s),i}(c(r)),s.EsriPromise=i.__decorate([n.subclass("esri.core.Promise")],s.EsriPromise),s.EsriPromiseMixin=c,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
