/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import has from"../../../../core/has.js";import{property as i,subclass as s}from"../../../../core/accessorSupport/decorators.js";let o=class extends t{constructor(e){super(e),this.computedOpacity=1,this.computedVisible=!0,this.opacity=1,this.visible=!0,this._fadeOutResolver=null,this._fadeInResolver=null}get transitioning(){return this._targetOpacity!==this.computedOpacity}get _targetOpacity(){return!this.visible||this._fadeOutResolver?0:this.opacity}endTransition(){this._fadeInResolver?.resolve(),this._fadeOutResolver?.resolve(),this._fadeInResolver=this._fadeOutResolver=null,this.computedOpacity=this._targetOpacity}fadeIn(){return this._fadeInResolver||(this.opacity=1,this.computedOpacity=0,this._fadeOutResolver?.resolve(),this._fadeOutResolver=null,this._fadeInResolver=Promise.withResolvers()),this._fadeInResolver.promise}fadeOut(){return this._fadeOutResolver||(this.opacity=0,this._fadeInResolver?.resolve(),this._fadeInResolver=null,this._fadeOutResolver=Promise.withResolvers()),this._fadeOutResolver.promise}transitionStep(e,t){const i=has("mapview-transitions-duration"),s=i?1/i:0,o=this._targetOpacity;if(0===s)this.computedOpacity=o,this.computedVisible=this.visible;else{const t=this.computedOpacity;if(t===o)this.computedVisible=this.visible;else{const i=e*s;this.computedOpacity=t>o?Math.max(o,t-i):Math.min(o,t+i),this.computedVisible=this.computedOpacity>0}}this.transitioning||(this._fadeInResolver?.resolve(),this._fadeOutResolver?.resolve(),this._fadeOutResolver=this._fadeInResolver=null)}};e([i()],o.prototype,"computedOpacity",void 0),e([i()],o.prototype,"computedVisible",void 0),e([i()],o.prototype,"opacity",void 0),e([i()],o.prototype,"visible",void 0),e([i()],o.prototype,"transitioning",null),e([i()],o.prototype,"_fadeOutResolver",void 0),e([i()],o.prototype,"_fadeInResolver",void 0),o=e([s("esri.views.2d.engine.transitions.FadeTransition")],o);export{o as FadeTransition};
