12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{createTask as o}from"../../core/asyncUtils.js";import i from"../../core/Handles.js";import{makeHandle as s}from"../../core/handleUtils.js";import{abortMaybe as a,isSome as r,destroyMaybe as n}from"../../core/maybe.js";import{watch as d,syncAndInitial as c}from"../../core/reactiveUtils.js";import{createScreenPoint as h}from"../../core/screenUtils.js";import{throttle as l}from"../../core/throttle.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";var p;!function(t){t.PointerMove="pointer-move",t.Main="main"}(p||(p={}));const T=300;let _=class extends e{constructor(t){super(t),this._handles=new i,this._screenPoint=null,this._accumulatedShadowTime=null,this._shadowTimeTask=null,this._updateAccumulatedShadowTime=(t,e)=>{this._shadowTimeTask=a(this._shadowTimeTask),this._shadowTimeTask=o((async o=>{const{results:i,ground:s}=await t.hitTest(e);if(0===i.length&&!s.mapPoint)return void(this._accumulatedShadowTime=null);const a=await this.getDuration(e,o);this._accumulatedShadowTime=a}))},this._throttledUpdateAccumulatedShadowTime=l(this._updateAccumulatedShadowTime,T)}initialize(){this._handles.add(d((()=>({enabled:this.enabled,view:this.view})),(({enabled:t,view:e})=>{t&&r(e)?this._startTracking(e):this._stopTracking()}),c))}destroy(){this._handles=n(this._handles)}get screenPoint(){return this.enabled?this._screenPoint:null}get accumulatedShadowTime(){return this.enabled?this._accumulatedShadowTime:null}get testData(){return{setThrottleDelay:t=>{this._throttledUpdateAccumulatedShadowTime.remove(),this._throttledUpdateAccumulatedShadowTime=l(this._updateAccumulatedShadowTime,t)}}}_startTracking(t){const e=this._handles;if(e.has(p.Main))return;const o=()=>{e.has(p.PointerMove)||e.add(t.on("pointer-move",(e=>{const o=h(e.x,e.y);this._screenPoint=o,this._throttledUpdateAccumulatedShadowTime(t,o)})),p.PointerMove)},i=()=>{e.remove(p.PointerMove),this._screenPoint=null,this._accumulatedShadowTime=null};e.add([this._throttledUpdateAccumulatedShadowTime,t.on("pointer-enter",o),t.on("pointer-leave",i),t.on("pointer-down",i),t.on("pointer-drag",i),t.on("pointer-up",o),t.on("click",(e=>{const o=h(e.x,e.y);this._screenPoint=o,this._updateAccumulatedShadowTime(t,o)})),s((()=>{this._shadowTimeTask=a(this._shadowTimeTask)}))],p.Main),o()}_stopTracking(){this._handles.remove(p.Main)}};t([m()],_.prototype,"getDuration",void 0),t([m()],_.prototype,"view",void 0),t([m()],_.prototype,"enabled",void 0),t([m()],_.prototype,"screenPoint",null),t([m()],_.prototype,"accumulatedShadowTime",null),t([m()],_.prototype,"_screenPoint",void 0),t([m()],_.prototype,"_accumulatedShadowTime",void 0),t([m()],_.prototype,"_shadowTimeTask",void 0),_=t([u("esri.widgets.ShadowCast.ShadowTooltipViewModel")],_);export{_ as ShadowTooltipViewModel};
|