/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{clamp as s,lerp as i}from"../../../core/mathUtils.js";import{Milliseconds as a}from"../../../core/time.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";let d=class extends e{constructor(t){super(t),this.idleOpacity=.8,this.navigatingOpacity=.4,this.maxDelta=.1,this.tiltFadeStart=20,this.tiltFadeEnd=30,this.altitudeStart=1e4,this.altitudeEnd=2e4,this._value=1,this._needsRenderRequest=!1,this._lastFrameTime=a(0)}get value(){return this._needsRenderRequest&&(this.requestRender(),this._needsRenderRequest=!1),this._value}update(t,e,a){const{idleOpacity:r,navigatingOpacity:o,maxDelta:d,tiltFadeStart:n,tiltFadeEnd:h,altitudeStart:l,altitudeEnd:m}=this,{camera:u}=t,c=t.qualitySettings.fadeDuration;if(!u)return;const p=2===e?r:o,_=s((u.tilt-n)/(h-n),0,1),R=s(((u.position.z??0)-l)/(m-l),0,1),v=i(i(1,p,_),1,R),F=this.value;if(c<=0||F===v||0===this._lastFrameTime||this._lastFrameTime>a)return this._value=v,this._lastFrameTime=a,void(this._needsRenderRequest=!1);const f=a-this._lastFrameTime;this._lastFrameTime=a;const q=Math.max(1-r,Math.abs(r-o)),g=Math.min(q*f/c,d);if(g>=Math.abs(v-F))return this._value=v,void(this._needsRenderRequest=!1);this._value=F+Math.sign(v-F)*g,this._needsRenderRequest=!0}};t([r()],d.prototype,"requestRender",void 0),d=t([o("esri.views.3d.state.HUDOccludedFragmentOpacity")],d);export{d as HUDOccludedFragmentOpacity};
