/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../core/Error.js";import{EsriPromise as s}from"../core/Promise.js";import{isPromiseLike as i}from"../core/promiseUtils.js";import{property as r,subclass as o}from"../core/accessorSupport/decorators.js";let n=class extends s{constructor(t){super(t),this.state="running",this.target=null,this._resolver=null}initialize(){this._resolver=Promise.withResolvers(),this.addResolvingPromise(this._resolver.promise)}get done(){return"finished"===this.state||"stopped"===this.state}stop(){"stopped"!==this.state&&"finished"!==this.state&&(this._set("state","stopped"),this._resolver?.reject(new e("view:animation-stopped","ViewAnimation stopped")))}finish(){"stopped"!==this.state&&"finished"!==this.state&&(this._set("state","finished"),this._resolver?.resolve(void 0))}update(t,e){e||(e=i(t)?"waiting-for-target":"running"),this._set("target",t),this._set("state",e)}static{this.state={RUNNING:"running",STOPPED:"stopped",FINISHED:"finished",WAITING_FOR_TARGET:"waiting-for-target"}}};t([r({readOnly:!0})],n.prototype,"done",null),t([r({readOnly:!0,type:String})],n.prototype,"state",void 0),t([r()],n.prototype,"target",void 0),n=t([o("esri.views.ViewAnimation")],n);const a=n;export{a as default};
