@arcgis/core 4.25.0-next.20220708 → 4.25.0-next.20220711

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/40d9c753be00b81d9e79.js +1 -0
  3. package/assets/esri/core/workers/chunks/{8cdeccb6b67098d6a8d7.js → 54b01d2a4aba08d7e16b.js} +1 -1
  4. package/assets/esri/core/workers/chunks/5db5afec37f69c4acaaf.js +1 -0
  5. package/assets/esri/core/workers/chunks/63922dadaa642a959164.js +1 -0
  6. package/assets/esri/core/workers/chunks/{35d46e4eeb43c256a63b.js → 8d6fb50fff035f21878b.js} +1 -1
  7. package/assets/esri/core/workers/chunks/937eed1e51055f730270.js +1 -0
  8. package/assets/esri/core/workers/chunks/9b802fcf571c91347da4.js +1 -0
  9. package/assets/esri/core/workers/chunks/b02a43cf767d8ee13313.js +1 -0
  10. package/assets/esri/core/workers/chunks/ba6c6957830b3f0c4ec8.js +1 -0
  11. package/assets/esri/core/workers/chunks/fc6423ca92289c739e19.js +1 -0
  12. package/interfaces.d.ts +8395 -6016
  13. package/layers/BaseElevationLayer.js +1 -1
  14. package/layers/BaseTileLayer.js +1 -1
  15. package/layers/support/ElevationQuery.js +1 -1
  16. package/layers/support/ExportImageServiceParameters.js +1 -1
  17. package/layers/support/Sublayer.js +1 -1
  18. package/layers/support/TileInfo.js +1 -1
  19. package/layers/support/TileKey.js +5 -0
  20. package/layers/support/TilemapCache.js +1 -1
  21. package/package.json +1 -1
  22. package/renderers/DotDensityRenderer.js +1 -1
  23. package/support/revision.js +1 -1
  24. package/views/2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js +1 -1
  25. package/views/3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js +1 -1
  26. package/views/3d/layers/graphics/Graphics3DScaleVisibility.js +1 -1
  27. package/views/3d/terrain/TerrainSurface.js +1 -1
  28. package/views/DOMContainer.js +1 -1
  29. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  30. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js +1 -1
  31. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTilesSimple.js +1 -1
  32. package/views/interactive/snapping/snappingUtils.js +1 -1
  33. package/widgets/AreaMeasurement3D.js +1 -1
  34. package/widgets/Daylight.js +1 -1
  35. package/widgets/DirectLineMeasurement3D.js +1 -1
  36. package/widgets/ElevationProfile/ElevationProfileViewModel.js +1 -1
  37. package/widgets/ElevationProfile.js +1 -1
  38. package/widgets/Measurement.js +1 -1
  39. package/widgets/Popup.js +1 -1
  40. package/widgets/ShadowCast.js +1 -1
  41. package/widgets/Spinner.js +1 -1
  42. package/widgets/Weather.js +1 -1
  43. package/widgets/Widget.js +1 -1
  44. package/assets/esri/core/workers/chunks/009386ed70740f87a014.js +0 -1
  45. package/assets/esri/core/workers/chunks/1970d7a65832b70f7f5c.js +0 -1
  46. package/assets/esri/core/workers/chunks/4a364bc073fdc7c1b563.js +0 -1
  47. package/assets/esri/core/workers/chunks/4ca6ada7a4ccde5b5a24.js +0 -1
  48. package/assets/esri/core/workers/chunks/95451d6405729a9f50c7.js +0 -1
  49. package/assets/esri/core/workers/chunks/a9a459639c82c35ada1f.js +0 -1
  50. package/assets/esri/core/workers/chunks/beead2b06c994b4e61af.js +0 -1
  51. package/assets/esri/core/workers/chunks/ecaf8f030026e41e1d1a.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as p,isSome as u}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{isAbortError as g,isAborted as m,createAbortError as f}from"../../../core/promiseUtils.js";import{watch as T,syncAndInitial as y,sync as v,initial as w}from"../../../core/reactiveUtils.js";import{property as L}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{m as b}from"../../../chunks/mat4.js";import{c as E}from"../../../chunks/mat4f64.js";import{c as D}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{c as x}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as C}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as P,projectPointToVector as R}from"../../../geometry/projection.js";import{getReferenceEllipsoid as M}from"../../../geometry/projectionEllipsoid.js";import{create as j,equals as A,intersection as I,intersectsSphere as V}from"../../../geometry/support/aaBoundingRect.js";import{create as O,copy as N}from"../../../geometry/support/frustum.js";import{isPlateCarree as k}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as B}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as q}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as G}from"../../../layers/support/layerUtils.js";import{acquireDecoder as W}from"../../../layers/support/LercDecoder.js";import{printAllocations as F}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as H,scaleToZoom as Q}from"../support/cameraUtils.js";import X from"../support/debugFlags.js";import{toBoundingRect as z}from"../support/extentUtils.js";import{ClientType as Y}from"../support/index.js";import{updatingProgress as $}from"../support/updatingProperties.js";import{ElevationBounds as K}from"./ElevationBounds.js";import{sampleElevation as J,ElevationData as Z}from"./ElevationData.js";import{create as ee}from"./ExtentHelper.js";import{LODSnapping as te,TextureUpdate as ie}from"./interfaces.js";import{LayerClass as re,LayerClasses as se}from"./LayerClass.js";import{OverlayManager as ae}from"./OverlayManager.js";import{PlanarPatch as ne}from"./PlanarPatch.js";import{RenderOrder as le}from"./RenderOrder.js";import{SphericalPatch as oe}from"./SphericalPatch.js";import{MAX_ROOT_TILES as he,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as de,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as pe,MAX_MEMORY_LOD_BIAS as ue,ELEVATION_NODATA_VALUE as ce}from"./TerrainConst.js";import _e from"./TerrainRenderer.js";import ge from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as me,internalAssert as fe,isSurfaceLayerView as Te,isMapTileLayerView as ye,isBlendableLayerView as ve,isGroupLayer as we,isElevationLayerView as Le,isVectorTileLayerView as Se,useFetchTileForLayer as be,isImageryTileLayerView as Ee,isTileLayerView as De,releaseTileData as Ue,ENABLE_WATERPROOFNESS_TESTS as xe,enableTerrainInternalChecks as Ce,enableTerrainWaterproofnessChecks as Pe}from"./terrainUtils.js";import{SplitLimits as Re,Tile as Me}from"./Tile.js";import{printAllocations as je}from"./TilePerLayerInfo.js";import{TileUpdate as Ae}from"./TileUpdate.js";import{IteratorPreorder as Ie,IteratorPostorder as Ve,hasLoadableSiblings as Oe,sortTilesByPOI as Ne,sortTiles as ke}from"./tileUtils.js";import{TilingSchemeLogic as Be}from"./TilingSchemeLogic.js";import{UpsampleInfo as qe}from"./UpsampleInfo.js";import{isCompositeBlendMode as Ge,blendModeFromString as We}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{RenderRequestType as Fe}from"../webgl-engine/lib/basicInterfaces.js";import{ImmediateTask as He,TaskPriority as Qe,noBudget as Xe}from"../../support/Scheduler.js";const ze=.25;let Ye=class extends(a.EventedMixin(i)){constructor(e){super(e),this._elevationBounds=new K,this._iteratorPool=new c(Ie,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Ve,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visibleCached=!1,this._usedMemory=null,this._performanceInfo=new ge,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=U(),this._eyePosSurfaceSR=U(),this._splitLimits=new Re,this._snapLevel=1/0,this._frustum=O(),this._viewProjectionMatrix=E(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new C,this._frameTask=He,this._allTiles=new _,this._upsampleInfoPool=new c(qe),this._rootTilesExtent=j(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.backgroundColor=null,this._updatingRootTiles=!1,this.deferTileNeighborUpdate=!1,this.neighborTilesToUpdate=new Set,this.enableBatchTileGeometryUpdates=!0,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=W(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(ne):new c(oe);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new q(e.newCache("elevation-query")),this._set("overlayManager",new ae({surface:this})),this._handles.add([T((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),T((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new _e({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:M(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles}),this._handles.add([T((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),y),T((()=>this.hasCompositeBlendMode),(()=>{this._updateBaseOpacity(this.baseOpacity)}),y),T((()=>this.renderingDisabled),(()=>this._updateTransparentTerrain()),v),T((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),y),T((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),T((()=>X.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&X.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),w)]),this._extentHelper=ee(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new Be({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(Y.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(Y.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(Qe.TERRAIN_SURFACE,this),this._handles.add([T((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),w),T((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),v),T((()=>this.extent),(()=>this._updateRootTiles()),w),this.view.on("resize",(()=>this._viewChangeUpdate())),T((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.resourceController?.memoryController?.memoryFactor,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),T((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),w),T((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),v)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache),this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),this._extentHelper=d(this._extentHelper),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Me.prune(),this._treeDebugger&&(this._treeDebugger.destroy(),this._treeDebugger=null),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),F(),je()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){const e=this.view.pointsOfInterest?.contentCameraOnSurface?.scale;if(e){const t=this.view.state.contentCamera;let i=H(this.view,t.eye,t.viewForward,t.up).tilt;i>90&&(i=180-i);const r=2*(i/90)**2,s=Q(this.view,e)-r;Math.abs(this._snapLevel-s)>ze&&(Math.round(s)!==Math.round(this._snapLevel)&&(this._viewChanged=!0),this._snapLevel=s)}return Math.round(this._snapLevel)}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?te.ON:te.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(p(t)||p(e))return null;const i=j(),r=z(t,i,e)?i:null,s=this._get("extent");return A(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=I(this.groundExtent,this._userClippingExtent,j()),t=this._get("extent");return A(e,t)?t:e}get groundExtent(){return u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this._watchUpdatingTracking.updating||this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||this._asyncWorkItems>0||!this._allTilesSorted||this._layerViewsDirty)&&this.ready&&!this.suspended||this.overlayManager.updating||this._frameTask.updating)}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get viewingMode(){return this.view.state.viewingMode}get ready(){return u(this.rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get spatialReference(){return this.tilingScheme?.spatialReference??null}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._updateTransparentTerrain()}_updateTransparentTerrain(){const e=!this.renderingDisabled&&!this.opaque;this.view?._stage?.renderView.setRenderParameters({transparentTerrain:e})}set velvetOverground(e){e!==this.velvetOverground&&(this._renderer.velvetOverground=e),this._set("velvetOverground",e)}get wireframe(){return this._renderer.wireframe}set wireframe(e){this._renderer.wireframe=e}set _visible(e){e!==this._visibleCached&&(this._visibleCached=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this.getTileWithElevation(e,t,i,r,et);return p(s)?null:J(et[0],et[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=et){const a=this.rootTiles;if(p(a)||!a.length)return null;if(0===a[0].layerInfo[re.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!P(s,r,s,this.tilingScheme?.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let n of a){if(!n.containsPoint(s))continue;for(;n&&!n.rendered&&!n.isLeaf;){let e=0;s[0]>.5*(n.extent[0]+n.extent[2])&&(e+=1),s[1]<.5*(n.extent[1]+n.extent[3])&&(e+=2),n=n.children[e]}const e=n.renderData;return(e?e.geometryState.samplerData:null)?n:null}return null}get elevationBounds(){return this._elevationBounds}getScale(e){if(this.tilingScheme){if(!R(e,et,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this.rootTiles;if(u(t))for(let e of t)if(e?.containsPoint(et)){for(;!e.isLeaf&&!e.rendered;){let t=0;et[0]>e.children[0].extent[2]&&(t+=1),et[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereElevationBounds(e,t,i,r,s){if(et[0]=e,et[1]=t,et[2]=i,et[3]=r,!P(et,s,et,this.tilingScheme?.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let a=1/0,n=-1/0;const o=e=>{if(e&&V(e.extent,et))if(e.isLeaf||e.rendered)a=Math.min(a,e.elevationBounds[0]),n=Math.max(n,e.elevationBounds[1]);else for(const t of e.children)o(t)},h=this.rootTiles;if(u(h))for(const l of h)o(l);return{min:a,max:n}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!R(e,et,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;et[3]=t;let i=null;const r=e=>{if(e&&V(e.extent,et))if(e.isLeaf||e.rendered){const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}else for(const t of e.children)r(t)},s=this.rootTiles;if(u(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_updateBaseOpacity(e){const t=this._renderer.opaque;this._renderer.opaque=e>=1&&!this.hasCompositeBlendMode,this._renderer.isTransparent=this._allSurfaceLayersTransparent();const i=t!==this._renderer.opaque;i&&this._updateTransparentTerrain(),this._updateTileTextures(i?ie.UNFADED:ie.IMMEDIATE)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(me(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles(),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles()))}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return it[0]=e,it[1]=t,it[2]=i,s.init(it,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=tt;let s=t.rootTilesInExtent(e,i,5*he);if(u(this.rootTiles)){if(s.length>he)return void l.getLogger(this.declaredClass).warn(de);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,Ke);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>Ke(t,e.lij)))>-1)||(this._purgeTile(e,!0),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>he&&(l.getLogger(this.declaredClass).warn(pe),s=t.rootTilesInExtent(e,i,he)),this._setRootTiles(s.map((e=>this._newRootTile(e))));A(i,this._rootTilesExtent)||(this._rootTilesExtent=j(i)),this._visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._allTiles.forEach((e=>{e.isLoaded&&this._prepareToLoadTile(e)})),this._allTiles.forAll((e=>{e.isLoaded&&(this._updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e))})),this._updatingRootTiles=!1,this.checkAllTileWaterproofness()}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return t.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Ae.SPLIT&&t.setPendingUpdate(Ae.SPLIT),this._loadTile(t),this.deferTileNeighborUpdate||t.checkGeometryWaterproofness(),t}_setRootTiles(e){if(this._set("rootTiles",e),this._allTiles.clear(),u(e)){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this.rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visibleCached&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this.rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Ae.GEOMETRY)&&this._updateTileGeometry(e)}_updateTilesVisibility(e){if(p(e))return;const t=Oe(e);let i=t?this._elevationBounds.min:1/0,r=t?this._elevationBounds.max:-1/0;const s=this.extent,a=this._viewProjectionMatrix;this.setTileTreeDirty();const n=this._iteratorPool.acquire();for(n.reset(e);!n.done;){const e=n.next();e.updateClippingStatus(s)&&e.resetPendingUpdate(Ae.GEOMETRY)&&this._updateTileGeometry(e),e.setPendingUpdate(Ae.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(a),e.renderData&&(i=Math.min(e.elevationBounds[0],i),r=Math.max(e.elevationBounds[1],r))}n.remove(),this._viewChanged=!0,this._allTilesDirty=!0,isFinite(i)&&isFinite(r)&&(this._elevationBounds.min===i&&this._elevationBounds.max===r||(this._elevationBounds.min=i,this._elevationBounds.max=r,this.emit("elevation-bounds-change",null)))}_updateViewDependentParameters(){const e=this.view.state.camera,t=this.view.state.contentCamera,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?(p(this._splitLimits.frustum)&&(this._splitLimits.frustum=O()),N(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,N(this._frustum,e.frustum),b(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),D(this._eyePosRenderSR,t.eye),P(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(Je(e)?(this._loadChildren(e),this.deferTileNeighborUpdate||(this._checkTileNeighborsWaterproofness(e),e.children.forEach((e=>e.checkGeometryWaterproofness())))):Ze(e)&&this._loadParent(e))}_updateTileGeometry(e){e.updateVisibility(),this._renderer.updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e),this._elevationUpdate(e),this._usedMemory=null,this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e)}_updateTileNeighborsAfterGeometryChange(e,t){if(this.deferTileNeighborUpdate){const t=this.neighborTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}else e.updateNeighborsAfterGeometryChange(t)}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Ae.TEXTURE_FADING)?Ae.TEXTURE_FADING:!!e.resetPendingUpdate(Ae.TEXTURE_NOFADING)&&Ae.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_elevationUpdate(e){st.spatialReference=this.spatialReference,st.tile=e,st.extent=e.extent,this.emit("elevation-change",st)}get running(){return this.updating&&this.ready&&!this.suspended}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateTileStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),e.run((()=>this._updateElevation(e))),e.run((()=>this._updateTextures(e))),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),e.done?this.requestUpdate():this._usedMemory=this._recalculateUsedMemory(),this.notifyChange("updatingProgressValue")}_updateTileStatus(e){if(!this._viewChanged||!this.rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();for(t.reset(this.rootTiles);!t.done;){const e=t.next(),i=e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping);if(i!==Ae.SPLIT){if(e.resetPendingUpdate(Ae.SPLIT)&&e.updateAgentSuspension(),i===Ae.VSPLITMERGE&&e.updateAgents(re.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Ae.MERGE),e.resetPendingUpdate(Ae.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(this._viewProjectionMatrix);t.remove()}}else e.resetPendingUpdate(Ae.MERGE),e.isLeaf&&(e.setPendingUpdate(Ae.SPLIT),t.skipSubtree())}t.remove(),this.requestUpdate(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Ne(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_prepareBatchTileGeometryUpdate(){fe(0===this.neighborTilesToUpdate.size),this.enableBatchTileGeometryUpdates&&(this.deferTileNeighborUpdate=!0)}_batchUpdateUpdatedTileNeighbors(){if(this.enableBatchTileGeometryUpdates){this.deferTileNeighborUpdate=!1;const e=this.neighborTilesToUpdate;(()=>{const t=()=>{for(const t of e)t.updateNeighborsWithChangedEdgeResolution()};(()=>{for(const t of e)t.updateNeighborDataAndGeometryIfNeeded()})(),t(),e.clear()})()}}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate(),this._prepareBatchTileGeometryUpdate();let i=!1,r=!1;for(;!e.done;){r=!0;let s=!1;const a=!this._allTiles.some((r=>{if(!i&&!r.loadable)return e.done;let a=r;if(r.resetPendingUpdate(Ae.MERGE)){if(!t)return r.setPendingUpdate(Ae.MERGE),e.done;for(;a.parent?.resetPendingUpdate(Ae.MERGE);)a=a.parent;this._mergeTile(a),s=!0,e.madeProgress()}else r.resetPendingUpdate(Ae.SPLIT)&&(this._splitTile(r),s=!0,e.madeProgress());return!e.done&&a===r&&r.resetPendingUpdate(Ae.RENDERDATA)&&(this._updateRenderData(r),e.madeProgress()),e.done}));if(s&&(this._allTilesSorted=!1,this._allTilesDirty=!0),a){if(!i){i=!0;continue}if(!s)break;this._updateTilesVisibility(this.rootTiles)}else this._allTilesDirty=!0}r||(this._allTilesDirty=!0),this._batchUpdateUpdatedTileNeighbors(),this._sortTiles(e)}_updateElevation(e){return this._prepareBatchTileGeometryUpdate(),this._allTiles.some((t=>(t.resetPendingUpdate(Ae.GEOMETRY)&&(this._updateTileGeometry(t),this._updateTileTexture(t,e),e.madeProgress()),e.done))),this._batchUpdateUpdatedTileNeighbors(),e.hasProgressed}_updateTextures(e){return this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done))),e.hasProgressed}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(Fe.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ue}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){u(this.rootTiles)&&(this.rootTiles.forEach((e=>this._purgeTile(e,!1))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this._visible=!1}_purgeDescendantTiles(e){if(e.isLeaf)return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i],!1)||t;return e.unsetChildren(),t}_purgeTile(e,t){const i=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),t&&this._updateTileNeighborsAfterGeometryChange(e),this._tilePool.release(e),i}_unloadTile(e){this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e),e.unload(this._renderer)}_splitTile(e){me(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Ae.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,this._emitTileScaleChange(e,t),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){at.spatialReference=this.spatialReference,at.extent=e.extent,at.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",at)}_createTile(e,t,i,r){me(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),s.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Ae.SPLIT&&s.setPendingUpdate(Ae.SPLIT),s}_mergeTile(e){me(!e.hasPendingUpdate(Ae.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(me(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._updateTileNeighborsAfterGeometryChange(e),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e)),this._allTilesDirty=!0,++this._performanceInfo.numMerged,this._emitTileScaleChange(e)}_checkTileAndNeighborsWaterproofness(e){e.checkGeometryWaterproofness(),this._checkTileNeighborsWaterproofness(e)}_checkTileNeighborsWaterproofness(e){xe&&e.forallNeighbors((e=>!!e.isLoaded&&(e.checkGeometryWaterproofness(),!0)))}_loadChildren(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e),me(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._prepareToLoadTile(e))),t.forEach((e=>this._loadTilePrepared(e))),this._updateTileNeighborsAfterGeometryChange(e,e.level+1),this.deferTileNeighborUpdate||(t.forEach((e=>e.updateNeighborsWithChangedEdgeResolution())),t.forEach((e=>e.checkGeometryWaterproofness())),this._checkTileNeighborsWaterproofness(e))}_loadParent(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e);const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._updateTileNeighborsAfterGeometryChange(t),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(t)}_unloadChildren(e){if(!e.isLeaf)for(let t=0;t<4;++t){const i=e.children[t];this._unloadChildren(i),this._unloadTile(i)}}_postLoadTile(e){e.setPendingUpdate(Ae.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e),this._elevationUpdate(e)}_loadTile(e){e.load(this._renderer),this._postLoadTile(e)}_loadTilePrepared(e){e.loadPrepared(this._renderer),this._postLoadTile(e)}_prepareToLoadTile(e){e.prepareToLoad(this._renderer)}_elevationDataArrived(e,t,i){const r=new Z(e.lij,e.extent,i);e.dataArrived(t,re.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=Xe){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),Te(s))if(this._basemapLayerViewHandles.has(s.uid)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);u(i)&&((i<r||p(r))&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this._renderer.isTransparent=this._allSurfaceLayersTransparent(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(ye(t)&&!G(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if(ve(e)){const t=we(e.layer.parent)?"normal":e.layer.blendMode;if(Ge(We[t]))return!0}return!1}_layerClassFromLayerView(e){return Le(e)?re.ELEVATION:re.MAP}_registerTiledLayerView(e){const t=[],i=this._layerClassFromLayerView(e);t.push(T((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(T((()=>e.fullOpacity),(()=>this._updateTileTextures(ie.UNFADED)))),t.push(T((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),ve(e)&&t.push(T((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(ie.UNFADED)}))),e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);u(t)&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!Te(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===re.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of se){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this.rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this.rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this.rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===re.ELEVATION&&i.computeElevationBounds()}}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(re.MAP),e===ie.IMMEDIATE?this.renderer.updateTileTexture(t,Ae.TEXTURE_NOFADING):t.updateRenderData(re.MAP,e)})),this._renderer.isTransparent=this._allSurfaceLayersTransparent()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=Fe.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||Se(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,g(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===re.ELEVATION?Le(i)?this._requestElevationTileData(e,i,r):Promise.reject():ye(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(m(i))return;const s=this._layerIndexByUid[re.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer %d %s",re.ELEVATION,e.lij.toString())},s=i=>{g(i)||(this._dataMissing(e,re.ELEVATION,t,i),this.requestUpdate())};if(be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:ce,signal:i.signal}).then((e=>{if(!m(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:ce},i.signal))).then((e=>{e?r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue}):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ue(s),m(i)||(this._dataMissing(e,re.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),m(i)?Ue(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(Se(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(Ee(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(De(t)&&be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(m(i))return l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(f());a(e)}),n);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);B(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const h=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,h,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(re.MAP,t.uid);u(r)?e.dataArrived(r,re.MAP,i):(Ue(i),l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);u(s)?e.dataMissing(s,t,r):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this.rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}getUsedMemory(){return this.tilingScheme?(p(this._usedMemory)&&(this._usedMemory=this._recalculateUsedMemory()),u(this._usedMemory)?this._usedMemory:0):0}_recalculateUsedMemory(){return this.tilingScheme?this._allTiles.reduce(((e,t)=>e+t.usedMemory),0):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return u(r)&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(p(e)||p(this.rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this.rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this.rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return me(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{u(e.rootTiles)&&(e._mergeTile(e.rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){rt.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&rt.push(e)}));const t=rt.toArray();return ke(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTileWaterproofness(){if(!xe)return;const e=this.rootTiles;if(p(e))return;const t=e=>e?.renderData?.geometryInfo?.indices?.length>0??!1,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometryInfo||(e.renderData.geometryInfo.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get shadingEnabled(){return this._renderer.shadingEnabled}get isWebMercator(){return!!this.tilingScheme?.spatialReference.isWebMercator}get isWebMercatorOnPlateeCarree(){return this.isWebMercator&&k(this.view?.renderSpatialReference)}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(u(this.spatialReference)&&this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Ce(e)}enableWaterproofnessChecks(e){Pe(e)}};e([L()],Ye.prototype,"_renderer",void 0),e([L()],Ye.prototype,"_hasPendingUpdates",void 0),e([L()],Ye.prototype,"_asyncWorkItems",void 0),e([L()],Ye.prototype,"_allTilesDirty",void 0),e([L()],Ye.prototype,"_allTilesSorted",void 0),e([L()],Ye.prototype,"_viewChanged",void 0),e([L({readOnly:!0})],Ye.prototype,"_watchUpdatingTracking",void 0),e([L()],Ye.prototype,"_frameTask",void 0),e([L({readOnly:!0})],Ye.prototype,"snapLevel",null),e([L({readOnly:!0})],Ye.prototype,"lodSnapping",null),e([L({constructOnly:!0})],Ye.prototype,"view",void 0),e([L()],Ye.prototype,"_userClippingExtent",null),e([L()],Ye.prototype,"_rootTilesExtent",void 0),e([L({readOnly:!0})],Ye.prototype,"extent",null),e([L({readOnly:!0})],Ye.prototype,"groundExtent",null),e([L({readOnly:!0})],Ye.prototype,"_tilingSchemeExtent",null),e([L({readOnly:!0})],Ye.prototype,"updating",null),e([L($)],Ye.prototype,"updatingProgress",void 0),e([L({readOnly:!0})],Ye.prototype,"updatingProgressValue",null),e([L()],Ye.prototype,"_maxNumUpdating",void 0),e([L({aliasOf:"view.map.ground.opacity"})],Ye.prototype,"baseOpacity",void 0),e([L()],Ye.prototype,"hasCompositeBlendMode",void 0),e([L({readOnly:!0})],Ye.prototype,"overlayManager",void 0),e([L({readOnly:!0})],Ye.prototype,"viewingMode",null),e([L()],Ye.prototype,"maxTextureScale",void 0),e([L({readOnly:!0})],Ye.prototype,"ready",null),e([L({value:le.FRONT_TO_BACK})],Ye.prototype,"renderOrder",null),e([L({readOnly:!0})],Ye.prototype,"rootTiles",void 0),e([L({readOnly:!0})],Ye.prototype,"spatialReference",null),e([L({type:t,aliasOf:"view.map.ground.surfaceColor"})],Ye.prototype,"backgroundColor",void 0),e([L({value:!1})],Ye.prototype,"slicePlaneEnabled",null),e([L({readOnly:!0})],Ye.prototype,"tilingScheme",void 0),e([L({readOnly:!0,aliasOf:"tilingSchemeLogic.tilingSchemeLocked"})],Ye.prototype,"tilingSchemeLocked",void 0),e([L({readOnly:!0})],Ye.prototype,"tilingSchemeLogic",void 0),e([L({value:!0})],Ye.prototype,"velvetOverground",null),e([L()],Ye.prototype,"wireframe",null),e([L({value:!1})],Ye.prototype,"suspended",null),e([L({readOnly:!0,aliasOf:"view.qualitySettings.tiledSurface.textureFadeDuration"})],Ye.prototype,"textureFadeDuration",void 0),e([L()],Ye.prototype,"_layerViewsDirty",void 0),e([L()],Ye.prototype,"renderPatchBorders",null),e([L()],Ye.prototype,"renderingDisabled",null),Ye=e([S("esri.views.3d.terrain.TerrainSurface")],Ye);const $e=Ye;function Ke(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Je(e){return!e.isLeaf&&(e.children.some((e=>e.shouldLoad))||e.children.some((e=>Je(e))))}function Ze(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const et=x(),tt=j(),it=[0,0,0],rt=new _,st={spatialReference:null,tile:null,extent:null,context:"ground"},at={spatialReference:null,extent:null,scale:0};export{$e as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as p,isSome as u}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{isAbortError as g,isAborted as m,createAbortError as f}from"../../../core/promiseUtils.js";import{watch as T,syncAndInitial as y,sync as v,initial as w}from"../../../core/reactiveUtils.js";import{property as L}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{m as b}from"../../../chunks/mat4.js";import{c as E}from"../../../chunks/mat4f64.js";import{c as D}from"../../../chunks/vec3.js";import{c as C}from"../../../chunks/vec3f64.js";import{c as U}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as x}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as P,projectPointToVector as R}from"../../../geometry/projection.js";import{getReferenceEllipsoid as M}from"../../../geometry/projectionEllipsoid.js";import{create as j,equals as A,intersection as I,intersectsSphere as V}from"../../../geometry/support/aaBoundingRect.js";import{create as O,copy as N}from"../../../geometry/support/frustum.js";import{isPlateCarree as k}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as B}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as q}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as G}from"../../../layers/support/layerUtils.js";import{acquireDecoder as W}from"../../../layers/support/LercDecoder.js";import{printAllocations as F}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as H,scaleToZoom as Q}from"../support/cameraUtils.js";import X from"../support/debugFlags.js";import{toBoundingRect as z}from"../support/extentUtils.js";import{ClientType as Y}from"../support/index.js";import{updatingProgress as $}from"../support/updatingProperties.js";import{ElevationBounds as K}from"./ElevationBounds.js";import{sampleElevation as J,ElevationData as Z}from"./ElevationData.js";import{create as ee}from"./ExtentHelper.js";import{LODSnapping as te,TextureUpdate as ie}from"./interfaces.js";import{LayerClass as re,LayerClasses as se}from"./LayerClass.js";import{OverlayManager as ae}from"./OverlayManager.js";import{PlanarPatch as ne}from"./PlanarPatch.js";import{RenderOrder as le}from"./RenderOrder.js";import{SphericalPatch as oe}from"./SphericalPatch.js";import{MAX_ROOT_TILES as he,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as de,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as pe,MAX_MEMORY_LOD_BIAS as ue,ELEVATION_NODATA_VALUE as ce}from"./TerrainConst.js";import _e from"./TerrainRenderer.js";import ge from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as me,internalAssert as fe,isSurfaceLayerView as Te,isMapTileLayerView as ye,isBlendableLayerView as ve,isGroupLayer as we,isElevationLayerView as Le,isVectorTileLayerView as Se,useFetchTileForLayer as be,isImageryTileLayerView as Ee,isTileLayerView as De,releaseTileData as Ce,ENABLE_WATERPROOFNESS_TESTS as Ue,enableTerrainInternalChecks as xe,enableTerrainWaterproofnessChecks as Pe}from"./terrainUtils.js";import{SplitLimits as Re,Tile as Me}from"./Tile.js";import{printAllocations as je}from"./TilePerLayerInfo.js";import{TileUpdate as Ae}from"./TileUpdate.js";import{IteratorPreorder as Ie,IteratorPostorder as Ve,hasLoadableSiblings as Oe,sortTilesByPOI as Ne,sortTiles as ke}from"./tileUtils.js";import{TilingSchemeLogic as Be}from"./TilingSchemeLogic.js";import{UpsampleInfo as qe}from"./UpsampleInfo.js";import{isCompositeBlendMode as Ge,blendModeFromString as We}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{RenderRequestType as Fe}from"../webgl-engine/lib/basicInterfaces.js";import{ImmediateTask as He,TaskPriority as Qe,noBudget as Xe}from"../../support/Scheduler.js";const ze=.25;let Ye=class extends(a.EventedMixin(i)){constructor(e){super(e),this._elevationBounds=new K,this._iteratorPool=new c(Ie,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Ve,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visibleCached=!1,this._usedMemory=null,this._performanceInfo=new ge,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=C(),this._eyePosSurfaceSR=C(),this._splitLimits=new Re,this._snapLevel=1/0,this._frustum=O(),this._viewProjectionMatrix=E(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new x,this._frameTask=He,this._allTiles=new _,this._upsampleInfoPool=new c(qe),this._rootTilesExtent=j(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.backgroundColor=null,this._updatingRootTiles=!1,this.deferTileNeighborUpdate=!1,this.neighborTilesToUpdate=new Set,this.enableBatchTileGeometryUpdates=!0,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=W(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(ne):new c(oe);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new q(e.newCache("elevation-query")),this._set("overlayManager",new ae({surface:this})),this._handles.add([T((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),T((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new _e({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:M(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles}),this._handles.add([T((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),y),T((()=>this.hasCompositeBlendMode),(()=>{this._updateBaseOpacity(this.baseOpacity)}),y),T((()=>this.renderingDisabled),(()=>this._updateTransparentTerrain()),v),T((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),y),T((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),T((()=>X.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&X.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),w)]),this._extentHelper=ee(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new Be({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(Y.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(Y.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(Qe.TERRAIN_SURFACE,this),this._handles.add([T((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),w),T((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),v),T((()=>this.extent),(()=>this._updateRootTiles()),w),this.view.on("resize",(()=>this._viewChangeUpdate())),T((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.resourceController?.memoryController?.memoryFactor,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),T((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),w),T((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),v)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache),this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),this._extentHelper=d(this._extentHelper),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Me.prune(),this._treeDebugger&&(this._treeDebugger.destroy(),this._treeDebugger=null),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),F(),je()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){const e=this.view.pointsOfInterest?.contentCameraOnSurface?.scale;if(e){const t=this.view.state.contentCamera;let i=H(this.view,t.eye,t.viewForward,t.up).tilt;i>90&&(i=180-i);const r=2*(i/90)**2,s=Q(this.view,e)-r;Math.abs(this._snapLevel-s)>ze&&(Math.round(s)!==Math.round(this._snapLevel)&&(this._viewChanged=!0),this._snapLevel=s)}return Math.round(this._snapLevel)}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?te.ON:te.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(p(t)||p(e))return null;const i=j(),r=z(t,i,e)?i:null,s=this._get("extent");return A(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=I(this.groundExtent,this._userClippingExtent,j()),t=this._get("extent");return A(e,t)?t:e}get groundExtent(){return u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this._watchUpdatingTracking.updating||this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||this._asyncWorkItems>0||!this._allTilesSorted||this._layerViewsDirty)&&this.ready&&!this.suspended||this.overlayManager.updating||this._frameTask.updating)}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get viewingMode(){return this.view.state.viewingMode}get ready(){return u(this.rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get spatialReference(){return this.tilingScheme?.spatialReference??null}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._updateTransparentTerrain()}_updateTransparentTerrain(){const e=!this.renderingDisabled&&!this.opaque;this.view?._stage?.renderView.setRenderParameters({transparentTerrain:e})}set velvetOverground(e){e!==this.velvetOverground&&(this._renderer.velvetOverground=e),this._set("velvetOverground",e)}get wireframe(){return this._renderer.wireframe}set wireframe(e){this._renderer.wireframe=e}set _visible(e){e!==this._visibleCached&&(this._visibleCached=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this.getTileWithElevation(e,t,i,r,et);return p(s)?null:J(et[0],et[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=et){const a=this.rootTiles;if(p(a)||!a.length)return null;if(0===a[0].layerInfo[re.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!P(s,r,s,this.tilingScheme?.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let n of a){if(!n.containsPoint(s))continue;for(;n&&!n.rendered&&!n.isLeaf;){let e=0;s[0]>.5*(n.extent[0]+n.extent[2])&&(e+=1),s[1]<.5*(n.extent[1]+n.extent[3])&&(e+=2),n=n.children[e]}const e=n.renderData;return(e?e.geometryState.samplerData:null)?n:null}return null}get elevationBounds(){return this._elevationBounds}getScale(e){if(this.tilingScheme){if(!R(e,et,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this.rootTiles;if(u(t))for(let e of t)if(e?.containsPoint(et)){for(;!e.isLeaf&&!e.rendered;){let t=0;et[0]>e.children[0].extent[2]&&(t+=1),et[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereElevationBounds(e,t,i,r,s){if(et[0]=e,et[1]=t,et[2]=i,et[3]=r,!P(et,s,et,this.tilingScheme?.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let a=1/0,n=-1/0;const o=e=>{if(e&&V(e.extent,et))if(e.isLeaf||e.rendered)a=Math.min(a,e.elevationBounds[0]),n=Math.max(n,e.elevationBounds[1]);else for(const t of e.children)o(t)},h=this.rootTiles;if(u(h))for(const l of h)o(l);return{min:a,max:n}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!R(e,et,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;et[3]=t;let i=null;const r=e=>{if(e&&V(e.extent,et))if(e.isLeaf||e.rendered){const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}else for(const t of e.children)r(t)},s=this.rootTiles;if(u(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_updateBaseOpacity(e){const t=this._renderer.opaque;this._renderer.opaque=e>=1&&!this.hasCompositeBlendMode,this._renderer.isTransparent=this._allSurfaceLayersTransparent();const i=t!==this._renderer.opaque;i&&this._updateTransparentTerrain(),this._updateTileTextures(i?ie.UNFADED:ie.IMMEDIATE)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(me(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles(),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles()))}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return it[0]=e,it[1]=t,it[2]=i,s.init(it,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=tt;let s=t.rootTilesInExtent(e,i,5*he);if(u(this.rootTiles)){if(s.length>he)return void l.getLogger(this.declaredClass).warn(de);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,Ke);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>Ke(t,e.lij)))>-1)||(this._purgeTile(e,!0),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>he&&(l.getLogger(this.declaredClass).warn(pe),s=t.rootTilesInExtent(e,i,he)),this._setRootTiles(s.map((e=>this._newRootTile(e))));A(i,this._rootTilesExtent)||(this._rootTilesExtent=j(i)),this._visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._allTiles.forEach((e=>{e.isLoaded&&this._prepareToLoadTile(e)})),this._allTiles.forAll((e=>{e.isLoaded&&(this._updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e))})),this._updatingRootTiles=!1,this.checkAllTileWaterproofness()}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return t.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Ae.SPLIT&&t.setPendingUpdate(Ae.SPLIT),this._loadTile(t),this.deferTileNeighborUpdate||t.checkGeometryWaterproofness(),t}_setRootTiles(e){if(this._set("rootTiles",e),this._allTiles.clear(),u(e)){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this.rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visibleCached&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this.rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Ae.GEOMETRY)&&this._updateTileGeometry(e)}_updateTilesVisibility(e){if(p(e))return;const t=Oe(e);let i=t?this._elevationBounds.min:1/0,r=t?this._elevationBounds.max:-1/0;const s=this.extent,a=this._viewProjectionMatrix;this.setTileTreeDirty();const n=this._iteratorPool.acquire();for(n.reset(e);!n.done;){const e=n.next();e.updateClippingStatus(s)&&e.resetPendingUpdate(Ae.GEOMETRY)&&this._updateTileGeometry(e),e.setPendingUpdate(Ae.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(a),e.renderData&&(i=Math.min(e.elevationBounds[0],i),r=Math.max(e.elevationBounds[1],r))}n.remove(),this._viewChanged=!0,this._allTilesDirty=!0,isFinite(i)&&isFinite(r)&&(this._elevationBounds.min===i&&this._elevationBounds.max===r||(this._elevationBounds.min=i,this._elevationBounds.max=r,this.emit("elevation-bounds-change",null)))}_updateViewDependentParameters(){const e=this.view.state.camera,t=this.view.state.contentCamera,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?(p(this._splitLimits.frustum)&&(this._splitLimits.frustum=O()),N(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,N(this._frustum,e.frustum),b(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),D(this._eyePosRenderSR,t.eye),P(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(Je(e)?(this._loadChildren(e),this.deferTileNeighborUpdate||(this._checkTileNeighborsWaterproofness(e),e.children.forEach((e=>e.checkGeometryWaterproofness())))):Ze(e)&&this._loadParent(e))}_updateTileGeometry(e){e.updateVisibility(),this._renderer.updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e),this._elevationUpdate(e),this._usedMemory=null,this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e)}_updateTileNeighborsAfterGeometryChange(e,t){if(this.deferTileNeighborUpdate){const t=this.neighborTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}else e.updateNeighborsAfterGeometryChange(t)}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Ae.TEXTURE_FADING)?Ae.TEXTURE_FADING:!!e.resetPendingUpdate(Ae.TEXTURE_NOFADING)&&Ae.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_elevationUpdate(e){st.spatialReference=this.spatialReference,st.tile=e,st.extent=e.extent,this.emit("elevation-change",st)}get running(){return this.updating&&this.ready&&!this.suspended}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateTileStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),e.run((()=>this._updateElevation(e))),e.run((()=>this._updateTextures(e))),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),e.done?this.requestUpdate():this._usedMemory=this._recalculateUsedMemory(),this.notifyChange("updatingProgressValue")}_updateTileStatus(e){if(!this._viewChanged||!this.rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();for(t.reset(this.rootTiles);!t.done;){const e=t.next(),i=e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping);if(i!==Ae.SPLIT){if(e.resetPendingUpdate(Ae.SPLIT)&&e.updateAgentSuspension(),i===Ae.VSPLITMERGE&&e.updateAgents(re.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Ae.MERGE),e.resetPendingUpdate(Ae.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(this._viewProjectionMatrix);t.remove()}}else e.resetPendingUpdate(Ae.MERGE),e.isLeaf&&(e.setPendingUpdate(Ae.SPLIT),t.skipSubtree())}t.remove(),this.requestUpdate(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Ne(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_prepareBatchTileGeometryUpdate(){fe(0===this.neighborTilesToUpdate.size),this.enableBatchTileGeometryUpdates&&(this.deferTileNeighborUpdate=!0)}_batchUpdateUpdatedTileNeighbors(){if(this.enableBatchTileGeometryUpdates){this.deferTileNeighborUpdate=!1;const e=this.neighborTilesToUpdate;(()=>{const t=()=>{for(const t of e)t.updateNeighborsWithChangedEdgeResolution()};(()=>{for(const t of e)t.updateNeighborDataAndGeometryIfNeeded()})(),t(),e.clear()})()}}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate(),this._prepareBatchTileGeometryUpdate();let i=!1,r=!1;for(;!e.done;){r=!0;let s=!1;const a=!this._allTiles.some((r=>{if(!i&&!r.loadable)return e.done;let a=r;if(r.resetPendingUpdate(Ae.MERGE)){if(!t)return r.setPendingUpdate(Ae.MERGE),e.done;for(;a.parent?.resetPendingUpdate(Ae.MERGE);)a=a.parent;this._mergeTile(a),s=!0,e.madeProgress()}else r.resetPendingUpdate(Ae.SPLIT)&&(this._splitTile(r),s=!0,e.madeProgress());return!e.done&&a===r&&r.resetPendingUpdate(Ae.RENDERDATA)&&(this._updateRenderData(r),e.madeProgress()),e.done}));if(s&&(this._allTilesSorted=!1,this._allTilesDirty=!0),a){if(!i){i=!0;continue}if(!s)break;this._updateTilesVisibility(this.rootTiles)}else this._allTilesDirty=!0}r||(this._allTilesDirty=!0),this._batchUpdateUpdatedTileNeighbors(),this._sortTiles(e)}_updateElevation(e){return this._prepareBatchTileGeometryUpdate(),this._allTiles.some((t=>(t.resetPendingUpdate(Ae.GEOMETRY)&&(this._updateTileGeometry(t),this._updateTileTexture(t,e),e.madeProgress()),e.done))),this._batchUpdateUpdatedTileNeighbors(),e.hasProgressed}_updateTextures(e){return this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done))),e.hasProgressed}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(Fe.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ue}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){u(this.rootTiles)&&(this.rootTiles.forEach((e=>this._purgeTile(e,!1))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this._visible=!1}_purgeDescendantTiles(e){if(e.isLeaf)return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i],!1)||t;return e.unsetChildren(),t}_purgeTile(e,t){const i=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),t&&this._updateTileNeighborsAfterGeometryChange(e),this._tilePool.release(e),i}_unloadTile(e){this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e),e.unload(this._renderer)}_splitTile(e){me(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Ae.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){at.spatialReference=this.spatialReference,at.extent=e.extent,at.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",at)}_createTile(e,t,i,r){me(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),s.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Ae.SPLIT&&s.setPendingUpdate(Ae.SPLIT),s}_mergeTile(e){me(!e.hasPendingUpdate(Ae.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(me(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._updateTileNeighborsAfterGeometryChange(e),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e),this._emitTileScaleChange(e)),this._allTilesDirty=!0,++this._performanceInfo.numMerged}_checkTileAndNeighborsWaterproofness(e){e.checkGeometryWaterproofness(),this._checkTileNeighborsWaterproofness(e)}_checkTileNeighborsWaterproofness(e){Ue&&e.forallNeighbors((e=>!!e.isLoaded&&(e.checkGeometryWaterproofness(),!0)))}_loadChildren(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e),me(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._prepareToLoadTile(e))),t.forEach((e=>this._loadTilePrepared(e))),this._updateTileNeighborsAfterGeometryChange(e,e.level+1),this.deferTileNeighborUpdate||(t.forEach((e=>e.updateNeighborsWithChangedEdgeResolution())),t.forEach((e=>e.checkGeometryWaterproofness())),this._checkTileNeighborsWaterproofness(e)),this._emitTileScaleChange(e,e.level+1)}_loadParent(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e);const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._updateTileNeighborsAfterGeometryChange(t),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(t),this._emitTileScaleChange(t,t.level)}_unloadChildren(e){if(!e.isLeaf)for(let t=0;t<4;++t){const i=e.children[t];this._unloadChildren(i),this._unloadTile(i)}}_postLoadTile(e){e.setPendingUpdate(Ae.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e),this._elevationUpdate(e)}_loadTile(e){e.load(this._renderer),this._postLoadTile(e)}_loadTilePrepared(e){e.loadPrepared(this._renderer),this._postLoadTile(e)}_prepareToLoadTile(e){e.prepareToLoad(this._renderer)}_elevationDataArrived(e,t,i){const r=new Z(e.lij,e.extent,i);e.dataArrived(t,re.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=Xe){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),Te(s))if(this._basemapLayerViewHandles.has(s.uid)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);u(i)&&((i<r||p(r))&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this._renderer.isTransparent=this._allSurfaceLayersTransparent(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(ye(t)&&!G(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if(ve(e)){const t=we(e.layer.parent)?"normal":e.layer.blendMode;if(Ge(We[t]))return!0}return!1}_layerClassFromLayerView(e){return Le(e)?re.ELEVATION:re.MAP}_registerTiledLayerView(e){const t=[],i=this._layerClassFromLayerView(e);t.push(T((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(T((()=>e.fullOpacity),(()=>this._updateTileTextures(ie.UNFADED)))),t.push(T((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),ve(e)&&t.push(T((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(ie.UNFADED)}))),e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);u(t)&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!Te(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===re.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of se){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this.rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this.rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this.rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===re.ELEVATION&&i.computeElevationBounds()}}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(re.MAP),e===ie.IMMEDIATE?this.renderer.updateTileTexture(t,Ae.TEXTURE_NOFADING):t.updateRenderData(re.MAP,e)})),this._renderer.isTransparent=this._allSurfaceLayersTransparent()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=Fe.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||Se(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,g(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===re.ELEVATION?Le(i)?this._requestElevationTileData(e,i,r):Promise.reject():ye(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(m(i))return;const s=this._layerIndexByUid[re.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer %d %s",re.ELEVATION,e.lij.toString())},s=i=>{g(i)||(this._dataMissing(e,re.ELEVATION,t,i),this.requestUpdate())};if(be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:ce,signal:i.signal}).then((e=>{if(!m(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:ce},i.signal))).then((e=>{e?r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue}):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ce(s),m(i)||(this._dataMissing(e,re.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),m(i)?Ce(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(Se(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(Ee(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(De(t)&&be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(m(i))return l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(f());a(e)}),n);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);B(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const h=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,h,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(re.MAP,t.uid);u(r)?e.dataArrived(r,re.MAP,i):(Ce(i),l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);u(s)?e.dataMissing(s,t,r):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this.rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}getUsedMemory(){return this.tilingScheme?(p(this._usedMemory)&&(this._usedMemory=this._recalculateUsedMemory()),u(this._usedMemory)?this._usedMemory:0):0}_recalculateUsedMemory(){return this.tilingScheme?this._allTiles.reduce(((e,t)=>e+t.usedMemory),0):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return u(r)&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(p(e)||p(this.rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this.rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this.rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return me(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{u(e.rootTiles)&&(e._mergeTile(e.rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){rt.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&rt.push(e)}));const t=rt.toArray();return ke(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTileWaterproofness(){if(!Ue)return;const e=this.rootTiles;if(p(e))return;const t=e=>e?.renderData?.geometryInfo?.indices?.length>0??!1,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometryInfo||(e.renderData.geometryInfo.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get shadingEnabled(){return this._renderer.shadingEnabled}get isWebMercator(){return!!this.tilingScheme?.spatialReference.isWebMercator}get isWebMercatorOnPlateeCarree(){return this.isWebMercator&&k(this.view?.renderSpatialReference)}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(u(this.spatialReference)&&this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){xe(e)}enableWaterproofnessChecks(e){Pe(e)}};e([L()],Ye.prototype,"_renderer",void 0),e([L()],Ye.prototype,"_hasPendingUpdates",void 0),e([L()],Ye.prototype,"_asyncWorkItems",void 0),e([L()],Ye.prototype,"_allTilesDirty",void 0),e([L()],Ye.prototype,"_allTilesSorted",void 0),e([L()],Ye.prototype,"_viewChanged",void 0),e([L({readOnly:!0})],Ye.prototype,"_watchUpdatingTracking",void 0),e([L()],Ye.prototype,"_frameTask",void 0),e([L({readOnly:!0})],Ye.prototype,"snapLevel",null),e([L({readOnly:!0})],Ye.prototype,"lodSnapping",null),e([L({constructOnly:!0})],Ye.prototype,"view",void 0),e([L()],Ye.prototype,"_userClippingExtent",null),e([L()],Ye.prototype,"_rootTilesExtent",void 0),e([L({readOnly:!0})],Ye.prototype,"extent",null),e([L({readOnly:!0})],Ye.prototype,"groundExtent",null),e([L({readOnly:!0})],Ye.prototype,"_tilingSchemeExtent",null),e([L({readOnly:!0})],Ye.prototype,"updating",null),e([L($)],Ye.prototype,"updatingProgress",void 0),e([L({readOnly:!0})],Ye.prototype,"updatingProgressValue",null),e([L()],Ye.prototype,"_maxNumUpdating",void 0),e([L({aliasOf:"view.map.ground.opacity"})],Ye.prototype,"baseOpacity",void 0),e([L()],Ye.prototype,"hasCompositeBlendMode",void 0),e([L({readOnly:!0})],Ye.prototype,"overlayManager",void 0),e([L({readOnly:!0})],Ye.prototype,"viewingMode",null),e([L()],Ye.prototype,"maxTextureScale",void 0),e([L({readOnly:!0})],Ye.prototype,"ready",null),e([L({value:le.FRONT_TO_BACK})],Ye.prototype,"renderOrder",null),e([L({readOnly:!0})],Ye.prototype,"rootTiles",void 0),e([L({readOnly:!0})],Ye.prototype,"spatialReference",null),e([L({type:t,aliasOf:"view.map.ground.surfaceColor"})],Ye.prototype,"backgroundColor",void 0),e([L({value:!1})],Ye.prototype,"slicePlaneEnabled",null),e([L({readOnly:!0})],Ye.prototype,"tilingScheme",void 0),e([L({readOnly:!0,aliasOf:"tilingSchemeLogic.tilingSchemeLocked"})],Ye.prototype,"tilingSchemeLocked",void 0),e([L({readOnly:!0})],Ye.prototype,"tilingSchemeLogic",void 0),e([L({value:!0})],Ye.prototype,"velvetOverground",null),e([L()],Ye.prototype,"wireframe",null),e([L({value:!1})],Ye.prototype,"suspended",null),e([L({readOnly:!0,aliasOf:"view.qualitySettings.tiledSurface.textureFadeDuration"})],Ye.prototype,"textureFadeDuration",void 0),e([L()],Ye.prototype,"_layerViewsDirty",void 0),e([L()],Ye.prototype,"renderPatchBorders",null),e([L()],Ye.prototype,"renderingDisabled",null),Ye=e([S("esri.views.3d.terrain.TerrainSurface")],Ye);const $e=Ye;function Ke(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Je(e){return!e.isLeaf&&(e.children.some((e=>e.shouldLoad))||e.children.some((e=>Je(e))))}function Ze(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const et=U(),tt=j(),it=[0,0,0],rt=new _,st={spatialReference:null,tile:null,extent:null,context:"ground"},at={spatialReference:null,extent:null,scale:0};export{$e as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{reparent as t,byId as s,empty as i}from"../core/domUtils.js";import{watch as o,initial as r}from"../core/reactiveUtils.js";import{addFrameTask as n}from"../core/scheduling.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import d from"./overlay/ViewOverlay.js";import u from"../widgets/Popup.js";const l=[0,0];function p(e){const t=(e.ownerDocument||window.document).defaultView,s=e.getBoundingClientRect();return l[0]=s.left+t.pageXOffset,l[1]=s.top+t.pageYOffset,l}function c(e){e&&(i(e),e.parentNode&&e.parentNode.removeChild(e))}function m(e){const t=document.createElement("div");return e.appendChild(t),t}const f=16,y=750,v=512,_=2,g=i=>{let l=class extends i{constructor(...e){super(...e),this._freqInfo={freq:f,time:y},this._overlayRenderTaskHandle=null,this.height=0,this.position=null,this.resizing=!1,this.root=null,this.surface=null,this.suspended=!0,this.ui=null,this.userContent=null,this.width=0,this.widthBreakpoint=null,this.handles.add([o((()=>this.cursor),(e=>{const{surface:t}=this;t&&t.setAttribute("data-cursor",e)})),o((()=>this.interacting),(e=>{const{surface:t}=this;t&&t.setAttribute("data-interacting",e.toString())}))])}initialize(){this.handles.add(o((()=>this.ui),((e,t)=>this._handleUIChange(e,t)))),this._wireUI(this.ui),this.handles.add([this.on("focus",(()=>this.notifyChange("focused"))),this.on("blur",(()=>this.notifyChange("focused")))])}destroy(){this.destroyed||(this.ui&&(this.ui.destroy(),this.ui=null),this.popup&&!this.popup.destroyed&&this.popup.destroy(),this.container=null)}set container(e){const s=this._get("container");if(s===e)return;const i="dom-size";if(this.handles.remove(i),this._stopMeasuring(),s&&(s.classList.remove("esri-view"),this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null),this.overlay.destroy(),this._set("overlay",null),c(this.root),this._set("root",null),t(this.userContent,s),c(this.userContent),this._set("userContent",null)),e){e.classList.add("esri-view");const s=document.createElement("div");s.className="esri-view-user-storage",t(e,s),e.appendChild(s),this._set("userContent",s);const h=document.createElement("div");h.className="esri-view-root",e.insertBefore(h,e.firstChild),this._set("root",h);const a=document.createElement("div");a.className="esri-view-surface",a.setAttribute("role","application"),a.tabIndex=0,h.appendChild(a),this._set("surface",a);const u=new d;h.appendChild(u.surface),this._set("overlay",u),o((()=>u.needsRender),(e=>{e&&!this._overlayRenderTaskHandle?this._overlayRenderTaskHandle=n({render:()=>{this.overlay.render()}}):this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null)})),this.forceDOMReadyCycle(),this.handles.add(o((()=>this.size),(e=>{const[t,s]=e,i="esri-view-surface--inset-outline";t>=document.body.clientWidth||s>=document.body.clientHeight?a.classList.add(i):a.classList.remove(i)}),r),i),this._set("container",e),this._startMeasuring()}else this._set("width",0),this._set("height",0),this._set("position",null),this._set("suspended",!0),this._set("surface",null),this._set("container",null)}get focused(){const e=document.activeElement===this.surface;return document.hasFocus()&&e}get popup(){return this._get("popup")||new u({view:this})}set popup(e){const t=this._get("popup");t&&t!==e&&t.destroy(),this._set("popup",e)}get size(){return[this.width,this.height]}blur(){this.surface&&this.surface.blur()}focus(){this.surface&&this.surface.focus()}pageToContainer(e,t,s){const i=this.position;return e-=i[0],t-=i[1],s?(s[0]=e,s[1]=t):s=[e,t],s}containerToPage(e,t,s){const i=this.position;return e+=i[0],t+=i[1],s?(s[0]=e,s[1]=t):s=[e,t],s}_handleUIChange(e,t){t&&(this.handles.remove("ui"),t.destroy()),e&&this._wireUI(e),this._set("ui",e)}_wireUI(e){this.handles.remove("ui"),e&&(e.view=this,this.handles.add([o((()=>this.root),(t=>{e.container=t?m(t):null}),r),o((()=>this.popup),((t,s)=>{const i="popup",o="manual";s&&e.remove(s,i),t&&(t.view=e.view,e.add(t,{key:i,position:o}))}),r)],"ui"))}_stopMeasuring(){this.handles.remove("measuring"),this._get("resizing")&&this._set("resizing",!1)}_startMeasuring(){const e=this._freqInfo;e.freq=f,e.time=y,this.handles.add([(()=>{const t=()=>{e.freq=f,e.time=y};return window.addEventListener("resize",t),{remove(){window.removeEventListener("resize",t)}}})(),n({prepare:e=>{const t=this._measure(),s=this._freqInfo;if(s.time+=e.deltaTime,t&&(s.freq=f,this._get("resizing")||this._set("resizing",!0)),s.time<s.freq)return;s.time=0;const i=this._position();s.freq=i||t?f:Math.min(y,s.freq*_),!t&&s.freq>=v&&this._get("resizing")&&this._set("resizing",!1)}})],"measuring"),this._measure(),this._position()}_measure(){const e=this.container,t=e?e.clientWidth:0,s=e?e.clientHeight:0;if(0===t||0===s)return this.suspended||this._set("suspended",!0),!1;const i=this.width,o=this.height;return t===i&&s===o?(this.suspended&&this._set("suspended",!1),!1):(this._set("width",t),this._set("height",s),this.suspended&&this._set("suspended",!1),this.emit("resize",{oldWidth:i,oldHeight:o,width:t,height:s}),!0)}_position(){const e=this.container,t=this.position,s=p(e);return(!t||s[0]!==t[0]||s[1]!==t[1])&&(this._set("position",[s[0],s[1]]),!0)}forceDOMReadyCycle(){}};return e([h({value:null,cast:e=>s(e)})],l.prototype,"container",null),e([h({readOnly:!0})],l.prototype,"focused",null),e([h({readOnly:!0})],l.prototype,"height",void 0),e([h({type:u})],l.prototype,"popup",null),e([h({type:d})],l.prototype,"overlay",void 0),e([h({readOnly:!0})],l.prototype,"position",void 0),e([h({readOnly:!0})],l.prototype,"resizing",void 0),e([h({readOnly:!0})],l.prototype,"root",void 0),e([h({value:null,readOnly:!0})],l.prototype,"size",null),e([h({readOnly:!0})],l.prototype,"surface",void 0),e([h({readOnly:!0})],l.prototype,"suspended",void 0),e([h()],l.prototype,"ui",void 0),e([h({readOnly:!0})],l.prototype,"userContent",void 0),e([h({readOnly:!0})],l.prototype,"width",void 0),e([h()],l.prototype,"widthBreakpoint",void 0),l=e([a("esri.views.DOMContainer")],l),l};function w(e){return e&&"focus"in e}export{g as DOMContainer,w as isDOMContainer};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{reparent as t,byId as s,empty as i}from"../core/domUtils.js";import{destroyMaybe as o,removeMaybe as r}from"../core/maybe.js";import{watch as n,initial as h}from"../core/reactiveUtils.js";import{addFrameTask as a}from"../core/scheduling.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import l from"./overlay/ViewOverlay.js";import p from"../widgets/Popup.js";const c=[0,0];function m(e){const t=(e.ownerDocument||window.document).defaultView,s=e.getBoundingClientRect();return c[0]=s.left+(t?.pageXOffset??0),c[1]=s.top+(t?.pageYOffset??0),c}function f(e){e&&(i(e),e.parentNode&&e.parentNode.removeChild(e))}function y(e){const t=document.createElement("div");return e.appendChild(t),t}const v=16,_=750,g=512,w=2,C=i=>{let c=class extends i{constructor(...e){super(...e),this._freqInfo={freq:v,time:_},this._overlayRenderTaskHandle=null,this.height=0,this.overlay=null,this.position=null,this.resizing=!1,this.root=null,this.surface=null,this.suspended=!0,this.ui=null,this.userContent=null,this.width=0,this.widthBreakpoint=null,0!==e.length&&void 0!==e[0]?.popup||(this.popup=new p({view:this})),this.handles.add([n((()=>this.cursor),(e=>{const{surface:t}=this;t&&t.setAttribute("data-cursor",e)})),n((()=>this.interacting),(e=>{const{surface:t}=this;t&&t.setAttribute("data-interacting",e.toString())}))])}initialize(){this.handles.add(n((()=>this.ui),((e,t)=>this._handleUIChange(e,t)))),this._wireUI(this.ui),this.handles.add([this.on("focus",(()=>this.notifyChange("focused"))),this.on("blur",(()=>this.notifyChange("focused")))])}destroy(){this.destroyed||(this.ui=o(this.ui),this.popup&&!this.popup.destroyed&&this.popup.destroy(),this.container=null)}set container(e){const s=this._get("container");if(s===e)return;const i="dom-size";if(this.handles.remove(i),this._stopMeasuring(),s&&(s.classList.remove("esri-view"),this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null),this.overlay&&(this.overlay.destroy(),this._set("overlay",null)),this.root&&(f(this.root),this._set("root",null)),this.userContent&&(t(this.userContent,s),f(this.userContent),this._set("userContent",null))),e){e.classList.add("esri-view");const s=document.createElement("div");s.className="esri-view-user-storage",t(e,s),e.appendChild(s),this._set("userContent",s);const o=document.createElement("div");o.className="esri-view-root",e.insertBefore(o,e.firstChild),this._set("root",o);const d=document.createElement("div");d.className="esri-view-surface",d.setAttribute("role","application"),d.tabIndex=0,o.appendChild(d),this._set("surface",d);const u=new l;o.appendChild(u.surface),this._set("overlay",u),n((()=>u.needsRender),(e=>{e&&!this._overlayRenderTaskHandle?this._overlayRenderTaskHandle=a({render:()=>this.overlay?.render()}):this._overlayRenderTaskHandle=r(this._overlayRenderTaskHandle)})),this.forceDOMReadyCycle(),this.handles.add(n((()=>this.size),(e=>{const[t,s]=e,i="esri-view-surface--inset-outline";t>=document.body.clientWidth||s>=document.body.clientHeight?d.classList.add(i):d.classList.remove(i)}),h),i),this._set("container",e),this._startMeasuring()}else this._set("width",0),this._set("height",0),this._set("position",null),this._set("suspended",!0),this._set("surface",null),this._set("container",null)}get focused(){const e=document.activeElement===this.surface;return document.hasFocus()&&e}set popup(e){const t=this._get("popup");t&&t!==e&&t.destroy(),this._set("popup",e)}get size(){return[this.width,this.height]}blur(){this.surface&&this.surface.blur()}focus(){this.surface&&this.surface.focus()}pageToContainer(e,t,s){const i=this.position;return e-=i?i[0]:0,t-=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}containerToPage(e,t,s){const i=this.position;return e+=i?i[0]:0,t+=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}_handleUIChange(e,t){t&&(this.handles.remove("ui"),t.destroy()),e&&this._wireUI(e),this._set("ui",e)}_wireUI(e){this.handles.remove("ui"),e&&(e.view=this,this.handles.add([n((()=>this.root),(t=>{e.container=t?y(t):null}),h),n((()=>this.popup),((t,s)=>{const i="popup",o="manual";s&&e.remove(s,i),t&&(t.view=e.view,e.add(t,{key:i,position:o}))}),h)],"ui"))}_stopMeasuring(){this.handles.remove("measuring"),this._get("resizing")&&this._set("resizing",!1)}_startMeasuring(){const e=this._freqInfo;e.freq=v,e.time=_,this.handles.add([(()=>{const t=()=>{e.freq=v,e.time=_};return window.addEventListener("resize",t),{remove(){window.removeEventListener("resize",t)}}})(),a({prepare:e=>{const t=this._measure(),s=this._freqInfo;if(s.time+=e.deltaTime,t&&(s.freq=v,this._get("resizing")||this._set("resizing",!0)),s.time<s.freq)return;s.time=0;const i=this._position();s.freq=i||t?v:Math.min(_,s.freq*w),!t&&s.freq>=g&&this._get("resizing")&&this._set("resizing",!1)}})],"measuring"),this._measure(),this._position()}_measure(){const e=this.container,t=e?e.clientWidth:0,s=e?e.clientHeight:0;if(0===t||0===s)return this.suspended||this._set("suspended",!0),!1;const i=this.width,o=this.height;return t===i&&s===o?(this.suspended&&this._set("suspended",!1),!1):(this._set("width",t),this._set("height",s),this.suspended&&this._set("suspended",!1),this.emit("resize",{oldWidth:i,oldHeight:o,width:t,height:s}),!0)}_position(){const e=this.container,t=this.position,s=e&&m(e);return!!s&&((!t||s[0]!==t[0]||s[1]!==t[1])&&(this._set("position",[s[0],s[1]]),!0))}forceDOMReadyCycle(){}};return e([d({value:null,cast:e=>s(e)})],c.prototype,"container",null),e([d({readOnly:!0})],c.prototype,"focused",null),e([d({readOnly:!0})],c.prototype,"height",void 0),e([d({type:p})],c.prototype,"popup",null),e([d({type:l})],c.prototype,"overlay",void 0),e([d({readOnly:!0})],c.prototype,"position",void 0),e([d({readOnly:!0})],c.prototype,"resizing",void 0),e([d({readOnly:!0})],c.prototype,"root",void 0),e([d({value:null,readOnly:!0})],c.prototype,"size",null),e([d({readOnly:!0})],c.prototype,"surface",void 0),e([d({readOnly:!0})],c.prototype,"suspended",void 0),e([d()],c.prototype,"ui",void 0),e([d({readOnly:!0})],c.prototype,"userContent",void 0),e([d({readOnly:!0})],c.prototype,"width",void 0),e([d()],c.prototype,"widthBreakpoint",void 0),c=e([u("esri.views.DOMContainer")],c),c};function z(e){return e&&"focus"in e}export{C as DOMContainer,z as isDOMContainer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as r}from"../../../../core/arrayUtils.js";import{createTask as s}from"../../../../core/asyncUtils.js";import{HandleOwnerMixin as o}from"../../../../core/HandleOwner.js";import{isSome as i,isNone as a}from"../../../../core/maybe.js";import{eachAlwaysValues as n}from"../../../../core/promiseUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import c from"../../../../geometry/Polygon.js";import{initializeProjection as l,canProjectWithoutEngine as u,project as h}from"../../../../geometry/projection.js";import{normalizeCentralMeridianForDisplay as m}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as y}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as f}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as g}from"../../../../layers/graphics/OptimizedFeature.js";import _ from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as S}from"../../../../layers/graphics/data/QueryEngine.js";import{sortCandidatesInPlace as j}from"../snappingUtils.js";import{convertSnappingCandidate as v}from"./queryEngineUtils.js";let w=class extends(o(t)){constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[]}get updating(){return this.updatingHandles.updating}get _layer(){return this.layerSource.layer}destroy(){const e=this._pendingAdds;this._pendingAdds.length=0;for(const t of e)t.task.abort();this._mapSources((e=>this._destroySource(e)))}initialize(){this.handles.add([this._layer.on("graphic-update",(e=>this._onGraphicUpdate(e))),this.updatingHandles.addOnCollectionChange((()=>this._layer.graphics),(e=>this._onGraphicsChanged(e)))]),this._addMany(this._layer.graphics.toArray())}async fetchCandidates(e,t){const r=await n(this._mapSources((r=>r.queryEngine.executeQueryForSnapping({point:e.coordinateHelper.vectorToPoint(e.point).toJSON(),distance:e.distance,types:e.types,query:i(e.filter)?e.filter.createQuery().toJSON():{where:"1=1"}},t).then((({candidates:e})=>e))))),s=r.flat().map((t=>v(t,e.coordinateHelper,e.elevationInfo)));return j(e.point,s),s}refresh(){}_onGraphicUpdate(e){switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],r=new Map;for(const s of e)a(s.geometry)||(this._needsInitializeProjection(s.geometry.spatialReference)?(t.push(s.geometry.spatialReference),r.set(s.uid,s)):this._add(s));this._createPendingAdd(t,r)}_createPendingAdd(e,t){if(!e.length)return;const o=s((async r=>{await l(e.map((e=>({source:e,dest:this.spatialReference}))),{signal:r}),this._markLoadedSpatialReferences(e);for(const[,e]of t)this._add(e)}));this.updatingHandles.addPromise(o.promise);const i={task:o,graphics:t},a=()=>r(this._pendingAdds,i);o.promise.then(a,a),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e)null!=t.wkid&&this._loadedWkids.add(t.wkid),null!=t.wkt&&this._loadedWkts.add(t.wkt)}_add(e){if(a(e.geometry)||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=c.fromExtent(t));const r=this._ensureSource(t.type);if(a(r))return;const s=this._createOptimizedFeature(e.uid,t);i(s)&&r.featureStore.add(s)}_needsInitializeProjection(e){return(null==e.wkid||!this._loadedWkids.has(e.wkid))&&((null==e.wkt||!this._loadedWkts.has(e.wkt))&&!u(e,this.spatialReference))}_createOptimizedFeature(e,t){const r=h(m(t),this.spatialReference);return r?new g(f(r,!1,!1),{[k]:e},null,e):null}_ensureSource(e){const t=this._sources[e];if(i(t))return t;const r=this._createSource(e);return this._sources[e]=r,r}_createSource(e){const t=y.toJSON(e),r=new _({geometryType:t,hasZ:!1,hasM:!1});return{featureStore:r,queryEngine:new S({featureStore:r,fields:[{name:k,type:"esriFieldTypeOID",alias:k}],geometryType:t,hasM:!1,hasZ:!1,objectIdField:k,spatialReference:this.spatialReference,scheduler:i(this.view)&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources((t=>this._removeFromSource(t,e)));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const r=t.uid;e.featureStore.has(r)&&e.featureStore.removeById(t.uid)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:r,polyline:s,multipoint:o}=this._sources,a=[];return i(t)&&a.push(e(t)),i(r)&&a.push(e(r)),i(s)&&a.push(e(s)),i(o)&&a.push(e(o)),a}};e([p({constructOnly:!0})],w.prototype,"spatialReference",void 0),e([p({constructOnly:!0})],w.prototype,"layerSource",void 0),e([p({constructOnly:!0})],w.prototype,"view",void 0),e([p({readOnly:!0})],w.prototype,"updating",null),e([p({readOnly:!0})],w.prototype,"availability",void 0),w=e([d("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],w);const k="OBJECTID";export{w as GraphicsSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as r}from"../../../../core/arrayUtils.js";import{createTask as s}from"../../../../core/asyncUtils.js";import{HandleOwnerMixin as o}from"../../../../core/HandleOwner.js";import{isSome as i,isNone as a}from"../../../../core/maybe.js";import{eachAlwaysValues as n}from"../../../../core/promiseUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import c from"../../../../geometry/Polygon.js";import{initializeProjection as l,canProjectWithoutEngine as u,project as h}from"../../../../geometry/projection.js";import{normalizeCentralMeridianForDisplay as m}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as y}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as f}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as g}from"../../../../layers/graphics/OptimizedFeature.js";import _ from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as S}from"../../../../layers/graphics/data/QueryEngine.js";import{sortCandidatesInPlace as j}from"../snappingUtils.js";import{convertSnappingCandidate as v}from"./queryEngineUtils.js";let w=class extends(o(t)){constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[]}get updating(){return this.updatingHandles.updating}get _layer(){return this.layerSource.layer}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources((e=>this._destroySource(e)))}initialize(){this.handles.add([this._layer.on("graphic-update",(e=>this._onGraphicUpdate(e))),this.updatingHandles.addOnCollectionChange((()=>this._layer.graphics),(e=>this._onGraphicsChanged(e)))]),this._addMany(this._layer.graphics.toArray())}async fetchCandidates(e,t){const r=await n(this._mapSources((r=>r.queryEngine.executeQueryForSnapping({point:e.coordinateHelper.vectorToPoint(e.point).toJSON(),distance:e.distance,types:e.types,query:i(e.filter)?e.filter.createQuery().toJSON():{where:"1=1"}},t).then((({candidates:e})=>e))))),s=r.flat().map((t=>v(t,e.coordinateHelper,e.elevationInfo)));return j(e.point,s),s}refresh(){}_onGraphicUpdate(e){switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],r=new Map;for(const s of e)a(s.geometry)||(this._needsInitializeProjection(s.geometry.spatialReference)?(t.push(s.geometry.spatialReference),r.set(s.uid,s)):this._add(s));this._createPendingAdd(t,r)}_createPendingAdd(e,t){if(!e.length)return;const o=s((async r=>{await l(e.map((e=>({source:e,dest:this.spatialReference}))),{signal:r}),this._markLoadedSpatialReferences(e);for(const[,e]of t)this._add(e)}));this.updatingHandles.addPromise(o.promise);const i={task:o,graphics:t},a=()=>r(this._pendingAdds,i);o.promise.then(a,a),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e)null!=t.wkid&&this._loadedWkids.add(t.wkid),null!=t.wkt&&this._loadedWkts.add(t.wkt)}_add(e){if(a(e.geometry)||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=c.fromExtent(t));const r=this._ensureSource(t.type);if(a(r))return;const s=this._createOptimizedFeature(e.uid,t);i(s)&&r.featureStore.add(s)}_needsInitializeProjection(e){return(null==e.wkid||!this._loadedWkids.has(e.wkid))&&((null==e.wkt||!this._loadedWkts.has(e.wkt))&&!u(e,this.spatialReference))}_createOptimizedFeature(e,t){const r=h(m(t),this.spatialReference);return r?new g(f(r,!1,!1),{[k]:e},null,e):null}_ensureSource(e){const t=this._sources[e];if(i(t))return t;const r=this._createSource(e);return this._sources[e]=r,r}_createSource(e){const t=y.toJSON(e),r=new _({geometryType:t,hasZ:!1,hasM:!1});return{featureStore:r,queryEngine:new S({featureStore:r,fields:[{name:k,type:"esriFieldTypeOID",alias:k}],geometryType:t,hasM:!1,hasZ:!1,objectIdField:k,spatialReference:this.spatialReference,scheduler:i(this.view)&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources((t=>this._removeFromSource(t,e)));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const r=t.uid;e.featureStore.has(r)&&e.featureStore.removeById(t.uid)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:r,polyline:s,multipoint:o}=this._sources,a=[];return i(t)&&a.push(e(t)),i(r)&&a.push(e(r)),i(s)&&a.push(e(s)),i(o)&&a.push(e(o)),a}};e([p({constructOnly:!0})],w.prototype,"spatialReference",void 0),e([p({constructOnly:!0})],w.prototype,"layerSource",void 0),e([p({constructOnly:!0})],w.prototype,"view",void 0),e([p({readOnly:!0})],w.prototype,"updating",null),e([p({readOnly:!0})],w.prototype,"availability",void 0),w=e([d("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],w);const k="OBJECTID";export{w as GraphicsSnappingSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{ByteSizeUnit as s,estimateAttributesObjectSize as i,estimateFixedArraySize as r}from"../../../../../core/byteSizeEstimations.js";import{isNone as o,isSome as n}from"../../../../../core/maybe.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as c,intersects as h,fromExtent as u,area as d}from"../../../../../geometry/support/aaBoundingRect.js";import{getBoundsOptimizedGeometry as f}from"../../../../../layers/graphics/featureConversionUtils.js";import{BoundsStore as _}from"../../../../../layers/graphics/data/BoundsStore.js";import p from"../../../../../layers/support/TileInfo.js";import{executeQueryForCount as m}from"../../../../../rest/query/operations/query.js";import{FeatureServiceTileCache as g}from"./FeatureServiceTileCache.js";let v=class extends t{constructor(e){super(e),this.tileInfo=null,this.extent=null,this.maximumByteSize=10*s.MEGABYTES,this._tileBounds=new _,this._tiles=new g,this._refCounts=new Map,this._tileFeatureCounts=new Map,this._tmpBoundingRect=c()}add(e,t){const s=[];for(const i of t)this._referenceFeature(i.objectId)===w.ADDED&&s.push(i);this._addTileStorage(e,new Set(t.map((({objectId:e})=>e))),y(t)),this.featureStore.addMany(s),this._tiles.applyByteSizeLimit(this.maximumByteSize,(e=>this._removeTileStorage(e)))}destroy(){this.clear(),this._tileFeatureCounts.clear()}clear(){this.featureStore.clear(),this._tileBounds.clear(),this._tiles.clear(),this._refCounts.clear()}refresh(){this.clear(),this._tileFeatureCounts.clear()}processEdits(e,t,s){return this._processEditsDelete(e.deletedFeatures.concat(e.updatedFeatures)),this._processEditsRefetch(e.addedFeatures.concat(e.updatedFeatures),t,s)}_addTileStorage(e,t,s){this._tiles.set(e.id,new S(e,t,s)),this._tileBounds.set(e.id,e.extent),this._tileFeatureCounts.set(e.id,t.size)}_remove({id:e}){const t=this._tiles.get(e);t&&this._removeTileStorage(t)}_removeTileStorage(e){const t=[];for(const i of e.objectIds)this._unreferenceFeature(i)===w.REMOVED&&t.push(i);this.featureStore.removeManyById(t);const s=e.data.id;this._tiles.delete(s),this._tileBounds.delete(s)}_processEditsDelete(e){this.featureStore.removeManyById(e);for(const[,t]of this._tiles){for(const s of e)t.objectIds.delete(s);this._tileFeatureCounts.set(t.data.id,t.objectIds.size)}for(const t of e)this._refCounts.delete(t)}async _processEditsRefetch(e,t,s){const i=(await t(e,s)).features,{hasZ:r,hasM:n}=this.featureStore;for(const l of i){const e=f(this._tmpBoundingRect,l.geometry,r,n);o(e)||this._tileBounds.forEachInBounds(e,(e=>{const t=this._tiles.get(e);this.featureStore.add(l),t.objectIds.has(l.objectId)||(t.objectIds.add(l.objectId),this._referenceFeature(l.objectId),this._tileFeatureCounts.set(t.data.id,t.objectIds.size))}))}}process(e,t=(()=>!0)){if(o(this.tileInfo)||!e.extent||n(this.extent)&&!h(u(this.extent,this._tmpBoundingRect),e.extent))return new I(e);if(this._tiles.has(e.id))return new I(e);const s=this._createTileTree(e,this.tileInfo);return this._simplify(s,t,null,0,1),this._collectMissingTiles(e,s,this.tileInfo)}get debugInfo(){return Array.from(this._tiles.values()).map((({data:e})=>({data:e,featureCount:this._tileFeatureCounts.get(e.id)||0})))}getFeatureCount(e){return this._tileFeatureCounts.get(e.id)??0}async fetchCount(e,t,s,i){const r=this._tileFeatureCounts.get(e.id);if(null!=r)return r;const o=await m(t,s,i);return this._tileFeatureCounts.set(e.id,o.data.count),o.data.count}_createTileTree(e,t){const s=new T(e.level,e.row,e.col);return t.updateTileInfo(s,p.ExtrapolateOptions.POWER_OF_TWO),this._tileBounds.forEachInBounds(e.extent,(i=>{const r=this._tiles.get(i).data;this._tilesAreRelated(e,r)&&this._populateChildren(s,r,t,this._tileFeatureCounts.get(r.id)||0)})),s}_tilesAreRelated(e,t){if(!e||!t)return!1;if(e.level===t.level)return e.row===t.row&&e.col===t.col;const s=e.level<t.level,i=s?e:t,r=s?t:e,o=1<<r.level-i.level;return Math.floor(r.row/o)===i.row&&Math.floor(r.col/o)===i.col}_populateChildren(e,t,s,i){const r=t.level-e.level-1;if(r<0)return void(e.isLeaf=!0);const o=t.row>>r,l=t.col>>r,a=e.row<<1,c=l-(e.col<<1)+(o-a<<1),h=e.children[c];if(n(h))this._populateChildren(h,t,s,i);else{const r=new T(e.level+1,o,l);s.updateTileInfo(r,p.ExtrapolateOptions.POWER_OF_TWO),e.children[c]=r,this._populateChildren(r,t,s,i)}}_simplify(e,t,s,i,r){const o=r*r;if(e.isLeaf)return t(this.getFeatureCount(e),r)?0:(this._remove(e),n(s)&&(s.children[i]=null),o);const l=r/2,a=l*l;let c=0;for(let h=0;h<e.children.length;h++){const s=e.children[h];c+=n(s)?this._simplify(s,t,e,h,l):a}return 0===c?this._mergeChildren(e):1-c/o<F&&(this._purge(e),n(s)&&(s.children[i]=null),c=o),c}_mergeChildren(e){const t=new Set;let s=0;this._forEachLeaf(e,(e=>{const i=this._tiles.get(e.id);if(i){s+=i.byteSize;for(const e of i.objectIds)t.has(e)||(t.add(e),this._referenceFeature(e));this._remove(e)}})),this._addTileStorage(e,t,s),e.isLeaf=!0,e.children[0]=e.children[1]=e.children[2]=e.children[3]=null,this._tileFeatureCounts.set(e.id,t.size)}_forEachLeaf(e,t){for(const s of e.children)o(s)||(s.isLeaf?t(s):this._forEachLeaf(s,t))}_purge(e){if(!o(e))if(e.isLeaf)this._remove(e);else for(let t=0;t<e.children.length;t++){const s=e.children[t];this._purge(s),e.children[t]=null}}_collectMissingTiles(e,t,s){const i=new j(s,e,this.extent);return this._collectMissingTilesRecurse(t,i,1),i.info}_collectMissingTilesRecurse(e,t,s){if(e.isLeaf)return;if(!e.hasChildren)return void t.addMissing(e.level,e.row,e.col,s);const i=s/2;for(let r=0;r<e.children.length;r++){const s=e.children[r];o(s)?t.addMissing(e.level+1,(e.row<<1)+((2&r)>>1),(e.col<<1)+(1&r),i):this._collectMissingTilesRecurse(s,t,i)}}_referenceFeature(e){const t=(this._refCounts.get(e)||0)+1;return this._refCounts.set(e,t),1===t?w.ADDED:w.UNCHANGED}_unreferenceFeature(e){const t=(this._refCounts.get(e)||0)-1;return 0===t?(this._refCounts.delete(e),w.REMOVED):(t>0&&this._refCounts.set(e,t),w.UNCHANGED)}get test(){return{tiles:Array.from(this._tiles.values()).map((e=>`${e.data.id}:[${Array.from(e.objectIds)}]`)),featureReferences:Array.from(this._refCounts.keys()).map((e=>`${e}:${this._refCounts.get(e)}`))}}};function y(e){return e.reduce(((e,t)=>e+C(t)),0)}function C(e){return 32+E(e.geometry)+i(e.attributes)}function E(e){if(o(e))return 0;const t=r(e.lengths,4);return 32+r(e.coords,8)+t}e([l({constructOnly:!0})],v.prototype,"featureStore",void 0),e([l()],v.prototype,"tileInfo",void 0),e([l()],v.prototype,"extent",void 0),e([l()],v.prototype,"maximumByteSize",void 0),v=e([a("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTileStore")],v);class S{constructor(e,t,s){this.data=e,this.objectIds=t,this.byteSize=s}}class T{constructor(e,t,s){this.level=e,this.row=t,this.col=s,this.isLeaf=!1,this.extent=null,this.children=[null,null,null,null]}get hasChildren(){return!this.isLeaf&&(n(this.children[0])||n(this.children[1])||n(this.children[2])||n(this.children[3]))}}class I{constructor(e,t=[]){this.missingTiles=t,this.fullArea=0,this.coveredArea=0,this.fullArea=d(e.extent),this.coveredArea=this.fullArea}prepend(e){this.missingTiles=e.missingTiles.concat(this.missingTiles),this.coveredArea+=e.coveredArea,this.fullArea+=e.fullArea}}class j{constructor(e,t,s){this._tileInfo=e,this._extent=null,this.info=new I(t),n(s)&&(this._extent=u(s))}addMissing(e,t,s,i){const r={id:null,level:e,row:t,col:s};this._tileInfo.updateTileInfo(r,p.ExtrapolateOptions.POWER_OF_TWO),o(r.extent)||n(this._extent)&&!h(this._extent,r.extent)||(this.info.missingTiles.push({data:r,resolution:i}),this.info.coveredArea-=d(r.extent))}}const F=.18751;var w;!function(e){e[e.ADDED=0]="ADDED",e[e.REMOVED=1]="REMOVED",e[e.UNCHANGED=2]="UNCHANGED"}(w||(w={}));export{v as FeatureServiceTileStore,I as ProcessResult};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{ByteSizeUnit as s,estimateAttributesObjectSize as i,estimateFixedArraySize as r}from"../../../../../core/byteSizeEstimations.js";import{isNone as o,isSome as n}from"../../../../../core/maybe.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as c,intersects as h,fromExtent as u,area as d}from"../../../../../geometry/support/aaBoundingRect.js";import{getBoundsOptimizedGeometry as f}from"../../../../../layers/graphics/featureConversionUtils.js";import{BoundsStore as _}from"../../../../../layers/graphics/data/BoundsStore.js";import p from"../../../../../layers/support/TileInfo.js";import{TileKey as m}from"../../../../../layers/support/TileKey.js";import{executeQueryForCount as g}from"../../../../../rest/query/operations/query.js";import{FeatureServiceTileCache as y}from"./FeatureServiceTileCache.js";let v=class extends t{constructor(e){super(e),this.tileInfo=null,this.extent=null,this.maximumByteSize=10*s.MEGABYTES,this._tileBounds=new _,this._tiles=new y,this._refCounts=new Map,this._tileFeatureCounts=new Map,this._tmpBoundingRect=c()}add(e,t){const s=[];for(const i of t)this._referenceFeature(i.objectId)===x.ADDED&&s.push(i);this._addTileStorage(e,new Set(t.map((({objectId:e})=>e))),C(t)),this.featureStore.addMany(s),this._tiles.applyByteSizeLimit(this.maximumByteSize,(e=>this._removeTileStorage(e)))}destroy(){this.clear(),this._tileFeatureCounts.clear()}clear(){this.featureStore.clear(),this._tileBounds.clear(),this._tiles.clear(),this._refCounts.clear()}refresh(){this.clear(),this._tileFeatureCounts.clear()}processEdits(e,t,s){return this._processEditsDelete(e.deletedFeatures.concat(e.updatedFeatures)),this._processEditsRefetch(e.addedFeatures.concat(e.updatedFeatures),t,s)}_addTileStorage(e,t,s){this._tiles.set(e.id,new T(e,t,s)),this._tileBounds.set(e.id,e.extent),this._tileFeatureCounts.set(e.id,t.size)}_remove({id:e}){const t=this._tiles.get(e);t&&this._removeTileStorage(t)}_removeTileStorage(e){const t=[];for(const i of e.objectIds)this._unreferenceFeature(i)===x.REMOVED&&t.push(i);this.featureStore.removeManyById(t);const s=e.data.id;this._tiles.delete(s),this._tileBounds.delete(s)}_processEditsDelete(e){this.featureStore.removeManyById(e);for(const[,t]of this._tiles){for(const s of e)t.objectIds.delete(s);this._tileFeatureCounts.set(t.data.id,t.objectIds.size)}for(const t of e)this._refCounts.delete(t)}async _processEditsRefetch(e,t,s){const i=(await t(e,s)).features,{hasZ:r,hasM:n}=this.featureStore;for(const l of i){const e=f(this._tmpBoundingRect,l.geometry,r,n);o(e)||this._tileBounds.forEachInBounds(e,(e=>{const t=this._tiles.get(e);this.featureStore.add(l),t.objectIds.has(l.objectId)||(t.objectIds.add(l.objectId),this._referenceFeature(l.objectId),this._tileFeatureCounts.set(t.data.id,t.objectIds.size))}))}}process(e,t=(()=>!0)){if(o(this.tileInfo)||!e.extent||n(this.extent)&&!h(u(this.extent,this._tmpBoundingRect),e.extent))return new I(e);if(this._tiles.has(e.id))return new I(e);const s=this._createTileTree(e,this.tileInfo);return this._simplify(s,t,null,0,1),this._collectMissingTiles(e,s,this.tileInfo)}get debugInfo(){return Array.from(this._tiles.values()).map((({data:e})=>({data:e,featureCount:this._tileFeatureCounts.get(e.id)||0})))}getFeatureCount(e){return this._tileFeatureCounts.get(e.id)??0}async fetchCount(e,t,s,i){const r=this._tileFeatureCounts.get(e.id);if(null!=r)return r;const o=await g(t,s,i);return this._tileFeatureCounts.set(e.id,o.data.count),o.data.count}_createTileTree(e,t){const s=new j(e.level,e.row,e.col);return t.updateTileInfo(s,p.ExtrapolateOptions.POWER_OF_TWO),this._tileBounds.forEachInBounds(e.extent,(i=>{const r=this._tiles.get(i).data;this._tilesAreRelated(e,r)&&this._populateChildren(s,r,t,this._tileFeatureCounts.get(r.id)||0)})),s}_tilesAreRelated(e,t){if(!e||!t)return!1;if(e.level===t.level)return e.row===t.row&&e.col===t.col;const s=e.level<t.level,i=s?e:t,r=s?t:e,o=1<<r.level-i.level;return Math.floor(r.row/o)===i.row&&Math.floor(r.col/o)===i.col}_populateChildren(e,t,s,i){const r=t.level-e.level-1;if(r<0)return void(e.isLeaf=!0);const o=t.row>>r,l=t.col>>r,a=e.row<<1,c=l-(e.col<<1)+(o-a<<1),h=e.children[c];if(n(h))this._populateChildren(h,t,s,i);else{const r=new j(e.level+1,o,l);s.updateTileInfo(r,p.ExtrapolateOptions.POWER_OF_TWO),e.children[c]=r,this._populateChildren(r,t,s,i)}}_simplify(e,t,s,i,r){const o=r*r;if(e.isLeaf)return t(this.getFeatureCount(e),r)?0:(this._remove(e),n(s)&&(s.children[i]=null),o);const l=r/2,a=l*l;let c=0;for(let h=0;h<e.children.length;h++){const s=e.children[h];c+=n(s)?this._simplify(s,t,e,h,l):a}return 0===c?this._mergeChildren(e):1-c/o<w&&(this._purge(e),n(s)&&(s.children[i]=null),c=o),c}_mergeChildren(e){const t=new Set;let s=0;this._forEachLeaf(e,(e=>{const i=this._tiles.get(e.id);if(i){s+=i.byteSize;for(const e of i.objectIds)t.has(e)||(t.add(e),this._referenceFeature(e));this._remove(e)}})),this._addTileStorage(e,t,s),e.isLeaf=!0,e.children[0]=e.children[1]=e.children[2]=e.children[3]=null,this._tileFeatureCounts.set(e.id,t.size)}_forEachLeaf(e,t){for(const s of e.children)o(s)||(s.isLeaf?t(s):this._forEachLeaf(s,t))}_purge(e){if(!o(e))if(e.isLeaf)this._remove(e);else for(let t=0;t<e.children.length;t++){const s=e.children[t];this._purge(s),e.children[t]=null}}_collectMissingTiles(e,t,s){const i=new F(s,e,this.extent);return this._collectMissingTilesRecurse(t,i,1),i.info}_collectMissingTilesRecurse(e,t,s){if(e.isLeaf)return;if(!e.hasChildren)return void t.addMissing(e.level,e.row,e.col,s);const i=s/2;for(let r=0;r<e.children.length;r++){const s=e.children[r];o(s)?t.addMissing(e.level+1,(e.row<<1)+((2&r)>>1),(e.col<<1)+(1&r),i):this._collectMissingTilesRecurse(s,t,i)}}_referenceFeature(e){const t=(this._refCounts.get(e)||0)+1;return this._refCounts.set(e,t),1===t?x.ADDED:x.UNCHANGED}_unreferenceFeature(e){const t=(this._refCounts.get(e)||0)-1;return 0===t?(this._refCounts.delete(e),x.REMOVED):(t>0&&this._refCounts.set(e,t),x.UNCHANGED)}get test(){return{tiles:Array.from(this._tiles.values()).map((e=>`${e.data.id}:[${Array.from(e.objectIds)}]`)),featureReferences:Array.from(this._refCounts.keys()).map((e=>`${e}:${this._refCounts.get(e)}`))}}};function C(e){return e.reduce(((e,t)=>e+E(t)),0)}function E(e){return 32+S(e.geometry)+i(e.attributes)}function S(e){if(o(e))return 0;const t=r(e.lengths,4);return 32+r(e.coords,8)+t}e([l({constructOnly:!0})],v.prototype,"featureStore",void 0),e([l()],v.prototype,"tileInfo",void 0),e([l()],v.prototype,"extent",void 0),e([l()],v.prototype,"maximumByteSize",void 0),v=e([a("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTileStore")],v);class T{constructor(e,t,s){this.data=e,this.objectIds=t,this.byteSize=s}}class j{constructor(e,t,s){this.level=e,this.row=t,this.col=s,this.isLeaf=!1,this.extent=null,this.children=[null,null,null,null]}get hasChildren(){return!this.isLeaf&&(n(this.children[0])||n(this.children[1])||n(this.children[2])||n(this.children[3]))}}class I{constructor(e,t=[]){this.missingTiles=t,this.fullArea=0,this.coveredArea=0,this.fullArea=d(e.extent),this.coveredArea=this.fullArea}prepend(e){this.missingTiles=e.missingTiles.concat(this.missingTiles),this.coveredArea+=e.coveredArea,this.fullArea+=e.fullArea}}class F{constructor(e,t,s){this._tileInfo=e,this._extent=null,this.info=new I(t),n(s)&&(this._extent=u(s))}addMissing(e,t,s,i){const r=new m(null,e,t,s);this._tileInfo.updateTileInfo(r,p.ExtrapolateOptions.POWER_OF_TWO),o(r.extent)||n(this._extent)&&!h(this._extent,r.extent)||(this.info.missingTiles.push({data:r,resolution:i}),this.info.coveredArea-=d(r.extent))}}const w=.18751;var x;!function(e){e[e.ADDED=0]="ADDED",e[e.REMOVED=1]="REMOVED",e[e.UNCHANGED=2]="UNCHANGED"}(x||(x={}));export{v as FeatureServiceTileStore,I as ProcessResult};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import r from"../../../../../core/Accessor.js";import{property as t}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import s from"../../../../../geometry/Point.js";import{fromValues as i}from"../../../../../geometry/support/aaBoundingRect.js";import p from"../../../../../layers/support/LOD.js";import l from"../../../../../layers/support/TileInfo.js";let n=class extends r{constructor(e){super(e),this.pointOfInterest=null}get tiles(){return[{id:"0/0/0",level:0,row:0,col:0,extent:i(-1e8,-1e8,1e8,1e8)}]}get tileInfo(){return new l({origin:new s({x:-1e8,y:1e8,spatialReference:this.layer.spatialReference}),size:[512,512],lods:[new p({level:0,scale:1,resolution:390625})],spatialReference:this.layer.spatialReference})}get tileSize(){return this.tileInfo.size[0]}};e([t({readOnly:!0})],n.prototype,"tiles",null),e([t({readOnly:!0})],n.prototype,"tileInfo",null),e([t({readOnly:!0})],n.prototype,"tileSize",null),e([t({constructOnly:!0})],n.prototype,"layer",void 0),e([t()],n.prototype,"pointOfInterest",void 0),n=e([o("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTilesSimple")],n);export{n as FeatureServiceTilesSimple};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import r from"../../../../../core/Accessor.js";import{property as t}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import s from"../../../../../geometry/Point.js";import{fromValues as i}from"../../../../../geometry/support/aaBoundingRect.js";import p from"../../../../../layers/support/LOD.js";import l from"../../../../../layers/support/TileInfo.js";import{TileKey as n}from"../../../../../layers/support/TileKey.js";let a=class extends r{constructor(e){super(e),this.pointOfInterest=null}get tiles(){return[new n("0/0/0",0,0,0,i(-1e8,-1e8,1e8,1e8))]}get tileInfo(){return new l({origin:new s({x:-1e8,y:1e8,spatialReference:this.layer.spatialReference}),size:[512,512],lods:[new p({level:0,scale:1,resolution:390625})],spatialReference:this.layer.spatialReference})}get tileSize(){return this.tileInfo.size[0]}};e([t({readOnly:!0})],a.prototype,"tiles",null),e([t({readOnly:!0})],a.prototype,"tileInfo",null),e([t({readOnly:!0})],a.prototype,"tileSize",null),e([t({constructOnly:!0})],a.prototype,"layer",void 0),e([t()],a.prototype,"pointOfInterest",void 0),a=e([o("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTilesSimple")],a);export{a as FeatureServiceTilesSimple};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{k as t}from"../../../chunks/vec2.js";function E(t,E){const n=t.x-E.x,r=t.y-E.y;return n*n+r*r}function n(t,E){const n=t.length===E.length&&t[0]===E[0]&&t[1]===E[1];switch(t.length){case 2:return n;case 3:return n&&t[2]===E[2];case 4:return n&&t[3]===E[3]}return!1}function r(E,n){n.sort(((n,r)=>t(n.targetPoint,E)-t(r.targetPoint,E)))}var e;!function(t){t[t.TARGET=0]="TARGET",t[t.REFERENCE=1]="REFERENCE",t[t.REFERENCE_EXTENSION=2]="REFERENCE_EXTENSION"}(e||(e={}));export{e as LineSegmentHintType,n as objectEqual,r as sortCandidatesInPlace,E as squareDistance};
5
+ import{k as t}from"../../../chunks/vec2.js";function E(t,E){const n=t.x-E.x,r=t.y-E.y;return n*n+r*r}function n(t,E){const n=t.length===E.length&&t[0]===E[0]&&t[1]===E[1];switch(t.length){case 2:return n;case 3:return n&&t[2]===E[2];case 4:return n&&t[2]===E[2]&&t[3]===E[3]}return!1}function r(E,n){n.sort(((n,r)=>t(n.targetPoint,E)-t(r.targetPoint,E)))}var e;!function(t){t[t.TARGET=0]="TARGET",t[t.REFERENCE=1]="REFERENCE",t[t.REFERENCE_EXTENSION=2]="REFERENCE_EXTENSION"}(e||(e={}));export{e as LineSegmentHintType,n as objectEqual,r as sortCandidatesInPlace,E as squareDistance};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{isMeasurementSystem as s}from"../core/unitUtils.js";import{aliasOf as i}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import o from"./AreaMeasurement3D/AreaMeasurement3DViewModel.js";import{accessibleHandler as l}from"./support/decorators/accessibleHandler.js";import{messageBundle as u}from"./support/decorators/messageBundle.js";import{tsx as m}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const p="esri-area-measurement-3d",c={buttonDisabled:"esri-button--disabled",base:`${p} esri-widget esri-widget--panel`,container:`${p}__container`,hint:`${p}__hint`,hintText:`${p}__hint-text`,panelError:`${p}__panel--error`,measurement:`${p}__measurement`,measurementItem:`${p}__measurement-item`,measurementItemDisabled:`${p}__measurement-item--disabled`,measurementItemTitle:`${p}__measurement-item-title`,measurementItemValue:`${p}__measurement-item-value`,settings:`${p}__settings`,units:`${p}__units`,unitsLabel:`${p}__units-label`,unitsSelect:`${p}__units-select esri-select`,unitsSelectWrapper:`${p}__units-select-wrapper`,actionSection:`${p}__actions`,newMeasurementButton:`${p}__clear-button esri-button esri-button--primary`,widgetIcon:"esri-icon-measure-area"};let d=class extends n{constructor(e,t){super(e,t),this.view=null,this.visible=null,this.iconClass=c.widgetIcon,this.label=void 0,this.messages=null,this.messagesUnits=null,this.viewModel=new o,this.unitOptions=null,this.unit=null}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}render(){const{supported:e,active:t,measurement:i,state:a,unit:r}=this.viewModel,n="disabled"===a,o="ready"===a,l="measuring"===a||"measured"===a,{messages:u,messagesUnits:p}=this,d=t&&o?m("section",{key:"esri-area-measurement-3d__hint",class:c.hint},m("p",{class:c.hintText},u.hint)):null,v=e?null:m("section",{key:"esri-area-measurement-3d__unsupported",class:c.panelError},m("p",null,u.unsupported)),_=(e,t,s)=>{switch(t.state){case"available":return m("div",{key:`${s}-enabled`,class:c.measurementItem},m("span",{class:c.measurementItemTitle},e),m("span",{class:c.measurementItemValue},t.text));case"unavailable":return m("div",{key:`${s}-disabled`,class:this.classes(c.measurementItem,c.measurementItemDisabled)},m("span",{class:c.measurementItemTitle},e));case"invalid":return m("div",{key:`${s}-enabled`,class:c.measurementItem},m("span",{class:c.measurementItemTitle},e),m("span",{class:c.measurementItemValue},u.notApplicable))}},h=l?m("section",{key:"esri-area-measurement-3d__measurement",class:c.measurement},_(u.area,i.area,"area"),_(u.perimeterLength,i.perimeterLength,"perimeter-length")):null,b=`${this.id}__units`,y=m("label",{class:c.unitsLabel,for:b},u.unit),w=m("div",{class:c.unitsSelectWrapper},m("select",{class:c.unitsSelect,id:b,onchange:this._changeUnit,bind:this,value:r},this.viewModel.unitOptions.map((e=>m("option",{key:e,value:e},s(e)?p.systems[e]:p.units[e]?.pluralCapitalized))))),g=l?m("section",{key:"esri-area-measurement-3d__units",class:c.units},y,w):null,M=l?m("div",{key:"settings",class:c.settings},g):null,$=!e||t&&!l?null:m("div",{class:c.actionSection},m("button",{disabled:n,class:this.classes(c.newMeasurementButton,n&&c.buttonDisabled),bind:this,onclick:this._newMeasurement,type:"button"},u.newMeasurement)),j=this.visible?m("div",{class:c.container},v,d,M,h,$):null;return m("div",{key:this,class:c.base,role:"presentation"},j)}_newMeasurement(){t(this.viewModel.start())}_changeUnit(e){const t=e.target,s=t.options[t.selectedIndex];s&&(this.unit=s.value)}};e([i("viewModel.view")],d.prototype,"view",void 0),e([i("viewModel.visible")],d.prototype,"visible",void 0),e([i("viewModel.active")],d.prototype,"active",void 0),e([a({constructOnly:!0,nonNullable:!0})],d.prototype,"analysis",null),e([a()],d.prototype,"iconClass",void 0),e([a({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],d.prototype,"label",void 0),e([a(),u("esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D")],d.prototype,"messages",void 0),e([a(),u("esri/core/t9n/Units")],d.prototype,"messagesUnits",void 0),e([a()],d.prototype,"uiStrings",void 0),e([a({type:o})],d.prototype,"viewModel",void 0),e([i("viewModel.unitOptions")],d.prototype,"unitOptions",void 0),e([i("viewModel.unit")],d.prototype,"unit",void 0),e([l()],d.prototype,"_newMeasurement",null),e([l()],d.prototype,"_changeUnit",null),d=e([r("esri.widgets.AreaMeasurement3D")],d);const v=d;export{v as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{isMeasurementSystem as s}from"../core/unitUtils.js";import{aliasOf as i}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import o from"./AreaMeasurement3D/AreaMeasurement3DViewModel.js";import{accessibleHandler as l}from"./support/decorators/accessibleHandler.js";import{messageBundle as u}from"./support/decorators/messageBundle.js";import{tsx as m}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const p="esri-area-measurement-3d",c={buttonDisabled:"esri-button--disabled",base:`${p} esri-widget esri-widget--panel`,container:`${p}__container`,hint:`${p}__hint`,hintText:`${p}__hint-text`,panelError:`${p}__panel--error`,measurement:`${p}__measurement`,measurementItem:`${p}__measurement-item`,measurementItemDisabled:`${p}__measurement-item--disabled`,measurementItemTitle:`${p}__measurement-item-title`,measurementItemValue:`${p}__measurement-item-value`,settings:`${p}__settings`,units:`${p}__units`,unitsLabel:`${p}__units-label`,unitsSelect:`${p}__units-select esri-select`,unitsSelectWrapper:`${p}__units-select-wrapper`,actionSection:`${p}__actions`,newMeasurementButton:`${p}__clear-button esri-button esri-button--primary`,widgetIcon:"esri-icon-measure-area"};let d=class extends n{constructor(e,t){super(e,t),this.view=null,this.iconClass=c.widgetIcon,this.label=void 0,this.messages=null,this.messagesUnits=null,this.viewModel=new o,this.unitOptions=null,this.unit=null}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}render(){const{supported:e,active:t,measurement:i,state:a,unit:r}=this.viewModel,n="disabled"===a,o="ready"===a,l="measuring"===a||"measured"===a,{messages:u,messagesUnits:p}=this,d=t&&o?m("section",{key:"esri-area-measurement-3d__hint",class:c.hint},m("p",{class:c.hintText},u.hint)):null,v=e?null:m("section",{key:"esri-area-measurement-3d__unsupported",class:c.panelError},m("p",null,u.unsupported)),_=(e,t,s)=>{switch(t.state){case"available":return m("div",{key:`${s}-enabled`,class:c.measurementItem},m("span",{class:c.measurementItemTitle},e),m("span",{class:c.measurementItemValue},t.text));case"unavailable":return m("div",{key:`${s}-disabled`,class:this.classes(c.measurementItem,c.measurementItemDisabled)},m("span",{class:c.measurementItemTitle},e));case"invalid":return m("div",{key:`${s}-enabled`,class:c.measurementItem},m("span",{class:c.measurementItemTitle},e),m("span",{class:c.measurementItemValue},u.notApplicable))}},h=l?m("section",{key:"esri-area-measurement-3d__measurement",class:c.measurement},_(u.area,i.area,"area"),_(u.perimeterLength,i.perimeterLength,"perimeter-length")):null,b=`${this.id}__units`,y=m("label",{class:c.unitsLabel,for:b},u.unit),w=m("div",{class:c.unitsSelectWrapper},m("select",{class:c.unitsSelect,id:b,onchange:this._changeUnit,bind:this,value:r},this.viewModel.unitOptions.map((e=>m("option",{key:e,value:e},s(e)?p.systems[e]:p.units[e]?.pluralCapitalized))))),g=l?m("section",{key:"esri-area-measurement-3d__units",class:c.units},y,w):null,M=l?m("div",{key:"settings",class:c.settings},g):null,$=!e||t&&!l?null:m("div",{class:c.actionSection},m("button",{disabled:n,class:this.classes(c.newMeasurementButton,n&&c.buttonDisabled),bind:this,onclick:this._newMeasurement,type:"button"},u.newMeasurement)),j=this.visible?m("div",{class:c.container},v,d,M,h,$):null;return m("div",{key:this,class:c.base,role:"presentation"},j)}_newMeasurement(){t(this.viewModel.start())}_changeUnit(e){const t=e.target,s=t.options[t.selectedIndex];s&&(this.unit=s.value)}};e([i("viewModel.view")],d.prototype,"view",void 0),e([i("viewModel.visible")],d.prototype,"visible",void 0),e([i("viewModel.active")],d.prototype,"active",void 0),e([a({constructOnly:!0,nonNullable:!0})],d.prototype,"analysis",null),e([a()],d.prototype,"iconClass",void 0),e([a({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],d.prototype,"label",void 0),e([a(),u("esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D")],d.prototype,"messages",void 0),e([a(),u("esri/core/t9n/Units")],d.prototype,"messagesUnits",void 0),e([a()],d.prototype,"uiStrings",void 0),e([a({type:o})],d.prototype,"viewModel",void 0),e([i("viewModel.unitOptions")],d.prototype,"unitOptions",void 0),e([i("viewModel.unit")],d.prototype,"unit",void 0),e([l()],d.prototype,"_newMeasurement",null),e([l()],d.prototype,"_changeUnit",null),d=e([r("esri.widgets.AreaMeasurement3D")],d);const v=d;export{v as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Logger.js";import{applySome as i,isNone as s}from"../core/maybe.js";import{watch as o,syncAndInitial as l,when as a}from"../core/reactiveUtils.js";import{aliasOf as r}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import c from"./Widget.js";import{CSS as h}from"./Daylight/css.js";import p from"./Daylight/DaylightViewModel.js";import m from"./Daylight/VisibleElements.js";import{ORDERED_SEASONS as g}from"./Daylight/support/daylightUtils.js";import u from"./Daylight/support/SliderWithDropdown.js";import y from"./support/DatePicker.js";import{Heading as b}from"./support/Heading.js";import{getTimezoneInfos as v}from"./support/timeWidgetUtils.js";import"./support/widgetUtils.js";import{messageBundle as w}from"./support/decorators/messageBundle.js";import{tsx as _,tsxFragment as k}from"./support/jsxFactory.js";const f=/(.*)\s(.*)/,S="date",C="esri.widgets.Daylight";let M=class extends c{constructor(e,t){super(e,t),this.headingLevel=3,this.iconClass=h.widgetIcon,this.label=void 0,this.playSpeedMultiplier=1,this.timeSliderSteps=5,this.view=null,this.viewModel=new p,this.visibleElements=new m,this.dateOrSeason=S,this._timeSlider=new u({viewModel:this.viewModel.timeSliderViewModel,steps:this.timeSliderSteps??5,labelInputsEnabled:!1,visibleElements:{labels:!0},tickConfigs:[{mode:"position",values:[0,360,720,1080,1439],labelsVisible:!0,tickCreatedFunction:this._onPrimaryTickCreated.bind(this)},{mode:"position",values:[120,240,480,600,840,960,1200,1320],tickCreatedFunction:this._onSecondaryTickCreated.bind(this)}],items:[]}),this._datePicker=new y({viewModel:this.viewModel.datePickerViewModel,commitOnMonthChange:!0}),this._onPlayDayClick=()=>{this.viewModel.toggleDayPlaying()},this._onYearPlayClick=()=>{this.viewModel.toggleYearPlaying()},this._onSeasonChange=e=>{const t=e.target;this.viewModel.currentSeason=t.value},this._onSunLightingCheckboxChange=()=>{this.viewModel.toggleSunLightingEnabled()},this._onShadowCheckboxChange=()=>{this.viewModel.toggleDirectShadowsEnabled()}}get gmtOffsets(){return i(this.timezoneMessages,v)}get _useAmPm(){const e=this._timeSlider.viewModel.getLabelForValue(0,"tick");return f.test(e)}get _labelAlignmentClass(){const e=this.viewModel.timeSliderViewModel.values?.[0]??0,t=60*(this._useAmPm?4:3),i=60*(this._useAmPm?21:21.5);return e<t?h.sliderAlignLeft:e>i?h.sliderAlignRight:null}postInitialize(){this.viewModel.isSupported&&this.addHandles([o((()=>this.viewModel.datePickerViewModel),(e=>this._datePicker.viewModel=e),l),o((()=>this.viewModel.timeSliderViewModel),(e=>this._timeSlider.viewModel=e),l),o((()=>this.timezoneMessages?.chooseTimezone),(e=>this._timeSlider.buttonTooltip=e),l),o((()=>this.visibleElements?.timezone),(e=>this._timeSlider.showDropDown=e),l),o((()=>!this.viewModel.sunLightingEnabled),(e=>{this._datePicker.disabled=e,this._timeSlider.disabled=e}),l),a((()=>this.gmtOffsets),(e=>{this._timeSlider.items=e.map((e=>({utcOffset:e.utcOffset,name:e.short,label:[e.shortWithUTC,e.long]})))}),l),o((()=>[this.viewModel.utcOffset,this.gmtOffsets]),(()=>this._onUTCOffsetChange()),l)])}destroy(){this._datePicker.destroy(),this._timeSlider.destroy()}render(){const{messages:e,viewModel:t,visibleElements:i}=this,s=t.isSupported;return _("div",{class:this.classes(h.base,h.widget)},s?_(k,null,i.header&&_(b,{level:this.headingLevel},e.title),this._renderTimeOptions(),i.datePicker&&this._renderDateOrSeason(),i.sunLightingToggle&&this._renderSunLightingToggle(),i.shadowsToggle&&this._renderShadowsToggle()):_("div",{key:"unsupported",class:h.panelError},_("p",null,e.unsupported)))}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-checkbox.js"),import("@esri/calcite-components/dist/components/calcite-label.js")])}_renderTimeOptions(){const{viewModel:e,visibleElements:t,messages:i}=this,{directShadowsEnabled:s,dayPlaying:o}=e,l=!e.sunLightingEnabled;return _("div",{class:this.classes(h.dayContainer,this._labelAlignmentClass,{[h.shadowOn]:s,[h.shadowOff]:!s,[h.sliderDateOn]:t.datePicker,[h.sliderDateOff]:!t.datePicker,[h.sliderAmPmOn]:this._useAmPm,[h.containerDisabled]:l}),key:"daylight-time-options"},this._timeSlider.render(),t.playButtons&&this._renderPlayPauseButton({playing:o,disabled:l,label:i?.playDay,onClick:this._onPlayDayClick}))}_renderDateOptions(){const{viewModel:e,visibleElements:t,messages:i}=this,{yearPlaying:s}=e,o=!e.sunLightingEnabled;return _("div",{key:"daylight-date-options",class:this.classes(h.dateContainer,o&&h.containerDisabled)},this._datePicker.render(),t.playButtons&&this._renderPlayPauseButton({playing:s,disabled:o,label:i?.playYear,onClick:this._onYearPlayClick}))}_renderPlayPauseButton({playing:e,disabled:t,label:i,onClick:s}){return _("calcite-button",{appearance:"solid",class:h.playPauseButton,disabled:t,"icon-start":e?"pause-f":"play-f",label:i,round:!0,title:i,type:"button",onclick:s})}_renderSeasonOptions(){const{messages:e,viewModel:t}=this,i=!t.sunLightingEnabled;return _("select",{class:this.classes(h.select,h.seasonPicker,i&&h.seasonPickerDisabled),disabled:i,value:t.currentSeason,"aria-label":e.season,onchange:this._onSeasonChange},g.map((t=>_("option",{value:t},e[t]))))}_renderDateOrSeason(){return"date"===this.dateOrSeason?this._renderDateOptions():this._renderSeasonOptions()}_renderSunLightingToggle(){const e=this.messages?.sunLightingToggle;return _("calcite-label",{key:"date-time-toggle",layout:"inline",title:e?.tooltip,scale:"s"},_("calcite-checkbox",{class:h.sunLightingCheckbox,checked:this.viewModel.sunLightingEnabled,onCalciteCheckboxChange:this._onSunLightingCheckboxChange}),e?.label)}_renderShadowsToggle(){const e=this.messages?.shadowsToggle;return _("calcite-label",{key:"shadow-toggle",layout:"inline",title:e?.tooltip,scale:"s"},_("calcite-checkbox",{class:h.shadowsCheckbox,checked:this.viewModel.directShadowsEnabled,onCalciteCheckboxChange:this._onShadowCheckboxChange}),e.label)}_onUTCOffsetChange(){const e=this.viewModel.utcOffset,t=this._timeSlider.currentItem?.utcOffset,i=this.gmtOffsets;if(s(i)||t===e)return;const o=i.findIndex((({utcOffset:t})=>t===e));o>-1&&(this._timeSlider.currentIndex=o)}_onPrimaryTickCreated(e,t,i){t.classList.add(...P,h.primaryTick),i.classList.add(...P,h.primaryTickLabel),i.onclick=t.onclick=this._makeGoToTime(e);const s=i.textContent.match(f);s&&(i.innerHTML=`${s[1]}<br><div class=${h.primaryTickAmPm}>${s[2]}</div>`)}_onSecondaryTickCreated(e,t){t.classList.add(...P,h.secondaryTick),t.onclick=this._makeGoToTime(e)}_makeGoToTime(e){return()=>{this.viewModel.timeSliderPosition=e}}};e([n({readOnly:!0})],M.prototype,"gmtOffsets",null),e([n(),w("esri/widgets/Daylight/t9n/Daylight")],M.prototype,"messages",void 0),e([n(),w("esri/widgets/support/t9n/timezone")],M.prototype,"timezoneMessages",void 0),e([n()],M.prototype,"headingLevel",void 0),e([n()],M.prototype,"iconClass",void 0),e([n({aliasOf:{source:"messages.title",overridable:!0}})],M.prototype,"label",void 0),e([r("viewModel.playSpeedMultiplier")],M.prototype,"playSpeedMultiplier",void 0),e([r("_timeSlider.steps")],M.prototype,"timeSliderSteps",void 0),e([r("viewModel.view")],M.prototype,"view",void 0),e([n({type:p})],M.prototype,"viewModel",void 0),e([n({type:m,nonNullable:!0})],M.prototype,"visibleElements",void 0),e([n({cast:e=>"season"===e||"date"===e?e:(t.getLogger(C).warn(`"${e}" is not a valid option. Acceptable values are only "date" or "season". Defaulting to "${S}".`),S)})],M.prototype,"dateOrSeason",void 0),e([n()],M.prototype,"_timeSlider",void 0),e([n()],M.prototype,"_useAmPm",null),e([n()],M.prototype,"_labelAlignmentClass",null),e([n()],M.prototype,"_datePicker",void 0),M=e([d(C)],M);const P=["esri-interactive","esri-widget__anchor"],O=M;export{O as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Logger.js";import{applySome as i,isNone as s}from"../core/maybe.js";import{watch as o,syncAndInitial as l,when as r}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import{CSS as c}from"./Daylight/css.js";import h from"./Daylight/DaylightViewModel.js";import p from"./Daylight/VisibleElements.js";import{ORDERED_SEASONS as m}from"./Daylight/support/daylightUtils.js";import g from"./Daylight/support/SliderWithDropdown.js";import u from"./support/DatePicker.js";import{Heading as y}from"./support/Heading.js";import{getTimezoneInfos as b}from"./support/timeWidgetUtils.js";import"./support/widgetUtils.js";import{messageBundle as v}from"./support/decorators/messageBundle.js";import{tsx as w,tsxFragment as _}from"./support/jsxFactory.js";const S=/(.*)\s(.*)/,k="date",f="esri.widgets.Daylight";let M=class extends d{constructor(e,t){super(e,t),this.headingLevel=3,this.iconClass=c.widgetIcon,this.viewModel=new h,this.visibleElements=new p,this.dateOrSeason=k,this._timeSlider=new g({viewModel:this.viewModel.timeSliderViewModel,steps:this.timeSliderSteps,labelInputsEnabled:!1,visibleElements:{labels:!0},tickConfigs:[{mode:"position",values:[0,360,720,1080,1439],labelsVisible:!0,tickCreatedFunction:this._onPrimaryTickCreated.bind(this)},{mode:"position",values:[120,240,480,600,840,960,1200,1320],tickCreatedFunction:this._onSecondaryTickCreated.bind(this)}],items:[]}),this._datePicker=new u({viewModel:this.viewModel.datePickerViewModel,commitOnMonthChange:!0}),this._onPlayDayClick=()=>{this.viewModel.toggleDayPlaying()},this._onYearPlayClick=()=>{this.viewModel.toggleYearPlaying()},this._onSeasonChange=e=>{const t=e.target;this.viewModel.currentSeason=t.value},this._onSunLightingCheckboxChange=()=>{this.viewModel.toggleSunLightingEnabled()},this._onShadowCheckboxChange=()=>{this.viewModel.toggleDirectShadowsEnabled()}}get gmtOffsets(){return i(this.timezoneMessages,b)}get label(){return this._get("label")??this.messages?.title}set label(e){this._set("label",e)}get playSpeedMultiplier(){return this.viewModel.playSpeedMultiplier}set playSpeedMultiplier(e){this.viewModel.playSpeedMultiplier=e}get timeSliderSteps(){return this._timeSlider?.steps??5}set timeSliderSteps(e){this._timeSlider.steps=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get _useAmPm(){const e=this._timeSlider.viewModel.getLabelForValue(0,"tick");return S.test(e)}get _labelAlignmentClass(){const e=this.viewModel.timeSliderViewModel.values?.[0]??0,t=60*(this._useAmPm?4:3),i=60*(this._useAmPm?21:21.5);return e<t?c.sliderAlignLeft:e>i?c.sliderAlignRight:null}postInitialize(){this.viewModel.isSupported&&this.addHandles([o((()=>this.viewModel.datePickerViewModel),(e=>this._datePicker.viewModel=e),l),o((()=>this.viewModel.timeSliderViewModel),(e=>this._timeSlider.viewModel=e),l),o((()=>this.timezoneMessages.chooseTimezone),(e=>this._timeSlider.buttonTooltip=e),l),o((()=>this.visibleElements?.timezone),(e=>this._timeSlider.showDropDown=e),l),o((()=>!this.viewModel.sunLightingEnabled),(e=>{this._datePicker.disabled=e,this._timeSlider.disabled=e}),l),r((()=>this.gmtOffsets),(e=>{this._timeSlider.items=e.map((e=>({utcOffset:e.utcOffset,name:e.short,label:[e.shortWithUTC,e.long]})))}),l),o((()=>[this.viewModel.utcOffset,this.gmtOffsets]),(()=>this._onUTCOffsetChange()),l)])}destroy(){this._datePicker.destroy(),this._timeSlider.destroy()}render(){const{messages:e,viewModel:t,visibleElements:i}=this,s=t.isSupported;return w("div",{class:this.classes(c.base,c.widget)},s?w(_,null,i.header&&w(y,{level:this.headingLevel},e.title),this._renderTimeOptions(),i.datePicker&&this._renderDateOrSeason(),i.sunLightingToggle&&this._renderSunLightingToggle(),i.shadowsToggle&&this._renderShadowsToggle()):w("div",{key:"unsupported",class:c.panelError},w("p",null,e.unsupported)))}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-checkbox.js"),import("@esri/calcite-components/dist/components/calcite-label.js")])}_renderTimeOptions(){const{viewModel:e,visibleElements:t,messages:i}=this,{directShadowsEnabled:s,dayPlaying:o}=e,l=!e.sunLightingEnabled;return w("div",{class:this.classes(c.dayContainer,this._labelAlignmentClass,{[c.shadowOn]:s,[c.shadowOff]:!s,[c.sliderDateOn]:t.datePicker,[c.sliderDateOff]:!t.datePicker,[c.sliderAmPmOn]:this._useAmPm,[c.containerDisabled]:l}),key:"daylight-time-options"},this._timeSlider.render(),t.playButtons&&this._renderPlayPauseButton({playing:o,disabled:l,label:i.playDay,onClick:this._onPlayDayClick}))}_renderDateOptions(){const{viewModel:e,visibleElements:t,messages:i}=this,{yearPlaying:s}=e,o=!e.sunLightingEnabled;return w("div",{key:"daylight-date-options",class:this.classes(c.dateContainer,o&&c.containerDisabled)},this._datePicker.render(),t.playButtons&&this._renderPlayPauseButton({playing:s,disabled:o,label:i.playYear,onClick:this._onYearPlayClick}))}_renderPlayPauseButton({playing:e,disabled:t,label:i,onClick:s}){return w("calcite-button",{appearance:"solid",class:c.playPauseButton,disabled:t,"icon-start":e?"pause-f":"play-f",label:i,round:!0,title:i,type:"button",onclick:s})}_renderSeasonOptions(){const{messages:e,viewModel:t}=this,i=!t.sunLightingEnabled;return w("select",{class:this.classes(c.select,c.seasonPicker,i&&c.seasonPickerDisabled),disabled:i,value:t.currentSeason,"aria-label":e.season,onchange:this._onSeasonChange},m.map((t=>w("option",{value:t},e[t]))))}_renderDateOrSeason(){return"date"===this.dateOrSeason?this._renderDateOptions():this._renderSeasonOptions()}_renderSunLightingToggle(){const e=this.messages?.sunLightingToggle;return w("calcite-label",{key:"date-time-toggle",layout:"inline",title:e?.tooltip,scale:"s"},w("calcite-checkbox",{class:c.sunLightingCheckbox,checked:this.viewModel.sunLightingEnabled,onCalciteCheckboxChange:this._onSunLightingCheckboxChange}),e?.label)}_renderShadowsToggle(){const e=this.messages.shadowsToggle;return w("calcite-label",{key:"shadow-toggle",layout:"inline",title:e?.tooltip,scale:"s"},w("calcite-checkbox",{class:c.shadowsCheckbox,checked:this.viewModel.directShadowsEnabled,onCalciteCheckboxChange:this._onShadowCheckboxChange}),e.label)}_onUTCOffsetChange(){const e=this.viewModel.utcOffset,t=this._timeSlider.currentItem?.utcOffset,i=this.gmtOffsets;if(s(i)||t===e)return;const o=i.findIndex((({utcOffset:t})=>t===e));o>-1&&(this._timeSlider.currentIndex=o)}_onPrimaryTickCreated(e,t,i){t.classList.add(...C,c.primaryTick),i.classList.add(...C,c.primaryTickLabel),i.onclick=t.onclick=this._makeGoToTime(e);const s=S.exec(i.textContent);s&&(i.innerHTML=`${s[1]}<br><div class=${c.primaryTickAmPm}>${s[2]}</div>`)}_onSecondaryTickCreated(e,t){t.classList.add(...C,c.secondaryTick),t.onclick=this._makeGoToTime(e)}_makeGoToTime(e){return()=>{this.viewModel.timeSliderPosition=e}}};e([a({readOnly:!0})],M.prototype,"gmtOffsets",null),e([a(),v("esri/widgets/Daylight/t9n/Daylight")],M.prototype,"messages",void 0),e([a(),v("esri/widgets/support/t9n/timezone")],M.prototype,"timezoneMessages",void 0),e([a()],M.prototype,"headingLevel",void 0),e([a()],M.prototype,"iconClass",void 0),e([a()],M.prototype,"label",null),e([a()],M.prototype,"playSpeedMultiplier",null),e([a()],M.prototype,"timeSliderSteps",null),e([a()],M.prototype,"view",null),e([a({type:h})],M.prototype,"viewModel",void 0),e([a({type:p,nonNullable:!0})],M.prototype,"visibleElements",void 0),e([a({cast:e=>"season"===e||"date"===e?e:(t.getLogger(f).warn(`"${e}" is not a valid option. Acceptable values are only "date" or "season". Defaulting to "${k}".`),k)})],M.prototype,"dateOrSeason",void 0),e([a()],M.prototype,"_timeSlider",void 0),e([a()],M.prototype,"_useAmPm",null),e([a()],M.prototype,"_labelAlignmentClass",null),e([a()],M.prototype,"_datePicker",void 0),M=e([n(f)],M);const C=["esri-interactive","esri-widget__anchor"],P=M;export{P as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{isMeasurementSystem as s}from"../core/unitUtils.js";import{aliasOf as i}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import a from"./Widget.js";import o from"./DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js";import{accessibleHandler as l}from"./support/decorators/accessibleHandler.js";import{messageBundle as u}from"./support/decorators/messageBundle.js";import{tsx as c}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const m="esri-direct-line-measurement-3d",p={buttonDisabled:"esri-button--disabled",base:`${m} esri-widget esri-widget--panel`,container:`${m}__container`,hint:`${m}__hint`,hintText:`${m}__hint-text`,panelError:`${m}__panel--error`,measurement:`${m}__measurement`,measurementItem:`${m}__measurement-item`,measurementItemDisabled:`${m}__measurement-item--disabled`,measurementItemTitle:`${m}__measurement-item-title`,measurementItemValue:`${m}__measurement-item-value`,settings:`${m}__settings`,units:`${m}__units`,unitsLabel:`${m}__units-label`,unitsSelect:`${m}__units-select esri-select`,unitsSelectWrapper:`${m}__units-select-wrapper`,actionSection:`${m}__actions`,newMeasurementButton:`${m}__clear-button esri-button esri-button--primary`,widgetIcon:"esri-icon-measure-line"};let d=class extends a{constructor(e,t){super(e,t),this.view=null,this.visible=null,this.iconClass=p.widgetIcon,this.label=void 0,this.messages=null,this.messagesUnits=null,this.viewModel=new o,this.unitOptions=null,this.unit=null}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}render(){const{supported:e,active:t,state:i,measurement:n,unit:r}=this.viewModel,a="disabled"===i,o="ready"===i,l="measuring"===i||"measured"===i,{messages:u,messagesUnits:m}=this,d=t&&o?c("section",{key:"esri-direct-line-measurement-3d__hint",class:p.hint},c("p",{class:p.hintText},u.hint)):null,v=e?null:c("section",{key:"esri-direct-line-measurement-3d__unsupported",class:p.panelError},c("p",null,u.unsupported)),_=(e,t,s)=>{switch(t.state){case"available":return c("div",{key:`${s}-enabled`,class:p.measurementItem},c("span",{class:p.measurementItemTitle},e),c("span",{class:p.measurementItemValue},t.text));case"unavailable":return c("div",{key:`${s}-disabled`,class:this.classes(p.measurementItem,p.measurementItemDisabled)},c("span",{class:p.measurementItemTitle},e))}},h=l?c("section",{key:"esri-direct-line-measurement-3d__measurement",class:p.measurement},_(u.direct,n.directDistance,"direct"),_(u.horizontal,n.horizontalDistance,"horizontal"),_(u.vertical,n.verticalDistance,"vertical")):null,b=`${this.id}__units`,y=c("label",{class:p.unitsLabel,for:b},u.unit),w=c("div",{class:p.unitsSelectWrapper},c("select",{class:p.unitsSelect,id:b,onchange:this._changeUnit,bind:this,value:r},this.viewModel.unitOptions.map((e=>c("option",{key:e,value:e},s(e)?m.systems[e]:m.units[e]?.pluralCapitalized))))),g=c("section",{key:"esri-direct-line-measurement-3d__units",class:p.units},y,w),M=l?c("div",{key:"settings",class:p.settings},g):null,$=!e||t&&!l?null:c("div",{class:p.actionSection},c("button",{disabled:a,class:this.classes(p.newMeasurementButton,a&&p.buttonDisabled),bind:this,onclick:this._newMeasurement,type:"button"},u.newMeasurement)),D=this.visible?c("div",{class:p.container},v,d,M,h,$):null;return c("div",{key:this,class:p.base,role:"presentation"},D)}_newMeasurement(){t(this.viewModel.start())}_changeUnit(e){const t=e.target,s=t.options[t.selectedIndex];s&&(this.unit=s.value)}};e([i("viewModel.view")],d.prototype,"view",void 0),e([i("viewModel.visible")],d.prototype,"visible",void 0),e([i("viewModel.active")],d.prototype,"active",void 0),e([n({constructOnly:!0,nonNullable:!0})],d.prototype,"analysis",null),e([n()],d.prototype,"iconClass",void 0),e([n({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],d.prototype,"label",void 0),e([n(),u("esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D")],d.prototype,"messages",void 0),e([n(),u("esri/core/t9n/Units")],d.prototype,"messagesUnits",void 0),e([n()],d.prototype,"uiStrings",void 0),e([n({type:o})],d.prototype,"viewModel",void 0),e([i("viewModel.unitOptions")],d.prototype,"unitOptions",void 0),e([i("viewModel.unit")],d.prototype,"unit",void 0),e([l()],d.prototype,"_newMeasurement",null),e([l()],d.prototype,"_changeUnit",null),d=e([r("esri.widgets.DirectLineMeasurement3D")],d);const v=d;export{v as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{isMeasurementSystem as s}from"../core/unitUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import r from"./Widget.js";import a from"./DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js";import{accessibleHandler as l}from"./support/decorators/accessibleHandler.js";import{messageBundle as o}from"./support/decorators/messageBundle.js";import{tsx as u}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const c="esri-direct-line-measurement-3d",m={buttonDisabled:"esri-button--disabled",base:`${c} esri-widget esri-widget--panel`,container:`${c}__container`,hint:`${c}__hint`,hintText:`${c}__hint-text`,panelError:`${c}__panel--error`,measurement:`${c}__measurement`,measurementItem:`${c}__measurement-item`,measurementItemDisabled:`${c}__measurement-item--disabled`,measurementItemTitle:`${c}__measurement-item-title`,measurementItemValue:`${c}__measurement-item-value`,settings:`${c}__settings`,units:`${c}__units`,unitsLabel:`${c}__units-label`,unitsSelect:`${c}__units-select esri-select`,unitsSelectWrapper:`${c}__units-select-wrapper`,actionSection:`${c}__actions`,newMeasurementButton:`${c}__clear-button esri-button esri-button--primary`,widgetIcon:"esri-icon-measure-line"};let p=class extends r{constructor(e,t){super(e,t),this.iconClass=m.widgetIcon,this.viewModel=new a}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get label(){return this._get("label")??this.messages?.widgetLabel}set label(e){this._set("label",e)}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}render(){const{supported:e,active:t,state:i,measurement:n,unit:r}=this.viewModel,a="disabled"===i,l="ready"===i,o="measuring"===i||"measured"===i,{messages:c,messagesUnits:p}=this,d=t&&l?u("section",{key:"esri-direct-line-measurement-3d__hint",class:m.hint},u("p",{class:m.hintText},c.hint)):null,v=e?null:u("section",{key:"esri-direct-line-measurement-3d__unsupported",class:m.panelError},u("p",null,c.unsupported)),_=(e,t,s)=>{switch(t.state){case"available":return u("div",{key:`${s}-enabled`,class:m.measurementItem},u("span",{class:m.measurementItemTitle},e),u("span",{class:m.measurementItemValue},t.text));case"unavailable":return u("div",{key:`${s}-disabled`,class:this.classes(m.measurementItem,m.measurementItemDisabled)},u("span",{class:m.measurementItemTitle},e))}},h=o?u("section",{key:"esri-direct-line-measurement-3d__measurement",class:m.measurement},_(c.direct,n.directDistance,"direct"),_(c.horizontal,n.horizontalDistance,"horizontal"),_(c.vertical,n.verticalDistance,"vertical")):null,b=`${this.id}__units`,w=u("label",{class:m.unitsLabel,for:b},c.unit),y=u("div",{class:m.unitsSelectWrapper},u("select",{class:m.unitsSelect,id:b,onchange:this._changeUnit,bind:this,value:r},this.viewModel.unitOptions.map((e=>u("option",{key:e,value:e},s(e)?p.systems[e]:p.units[e]?.pluralCapitalized))))),g=u("section",{key:"esri-direct-line-measurement-3d__units",class:m.units},w,y),M=o?u("div",{key:"settings",class:m.settings},g):null,$=!e||t&&!o?null:u("div",{class:m.actionSection},u("button",{disabled:a,class:this.classes(m.newMeasurementButton,a&&m.buttonDisabled),bind:this,onclick:this._newMeasurement,type:"button"},c.newMeasurement)),D=this.visible?u("div",{class:m.container},v,d,M,h,$):null;return u("div",{key:this,class:m.base,role:"presentation"},D)}_newMeasurement(){t(this.viewModel.start())}_changeUnit(e){const t=e.target,s=t.options[t.selectedIndex];s&&(this.unit=s.value)}};e([i()],p.prototype,"view",null),e([i()],p.prototype,"visible",null),e([i()],p.prototype,"active",null),e([i({constructOnly:!0,nonNullable:!0})],p.prototype,"analysis",null),e([i()],p.prototype,"iconClass",void 0),e([i()],p.prototype,"label",null),e([i(),o("esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D")],p.prototype,"messages",void 0),e([i(),o("esri/core/t9n/Units")],p.prototype,"messagesUnits",void 0),e([i()],p.prototype,"uiStrings",void 0),e([i({type:a})],p.prototype,"viewModel",void 0),e([i()],p.prototype,"unitOptions",null),e([i()],p.prototype,"unit",null),e([l()],p.prototype,"_newMeasurement",null),e([l()],p.prototype,"_changeUnit",null),p=e([n("esri.widgets.DirectLineMeasurement3D")],p);const d=p;export{d as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import i from"../../core/Accessor.js";import{min as o}from"../../core/arrayUtils.js";import{ByteSizeUnit as r}from"../../core/byteSizeEstimations.js";import s from"../../core/Collection.js";import{referenceSetter as n}from"../../core/collectionUtils.js";import l from"../../core/Handles.js";import a from"../../core/Logger.js";import p from"../../core/LRUCache.js";import{isNone as u,destroyMaybe as h,isSome as c,applySome as d}from"../../core/maybe.js";import{memoize as f}from"../../core/memoize.js";import{watch as m,syncAndInitial as v}from"../../core/reactiveUtils.js";import{preferredLengthUnit as y,preferredVerticalLengthUnit as g,measurementLengthUnits as _}from"../../core/unitUtils.js";import{aliasOf as U}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as b}from"../../core/accessorSupport/decorators/property.js";import{subclass as P}from"../../core/accessorSupport/decorators/subclass.js";import{ElevationQueryTileCache as j}from"../../layers/support/ElevationQueryTileCache.js";import{defaultUnitPropertyMetadata as w}from"../../properties/defaultUnit.js";import{ElevationProfileController as C}from"./ElevationProfileController.js";import E from"./ElevationProfileLineGround.js";import{ElevationProfileLineCollection as O}from"./elevationProfileLineTypes.js";import{ElevationProfileTool as S}from"./ElevationProfileTool.js";import{ElevationProfileState as T,ElevationProfileErrorState as D}from"./support/constants.js";import{isPolyline as G,isValidInputPath as I}from"./support/geometryUtils.js";import{isProfileGenerationError as L,ProfileGenerationErrorCause as k}from"./support/ProfileGenerationError.js";import{createProfileQueue as R}from"./support/profileUtils.js";import{getBoundsInMeters as z,mergeStatistics as N}from"./support/statisticsUtils.js";let V=class extends i{constructor(t){super(t),this.view=null,this.input=null,this._getEffectiveUnitsMemoized=f(((t,e)=>({distance:t,elevation:e}))),this.geodesicDistanceThreshold=1e5,this.hoveredChartPosition=null,this.uniformChartScaling=!1,this.highlightEnabled=!0,this.defaultUnit=null,this.queue=null,this._currentTileCache=null,this.error=null,this._handles=new l,this._defaultProfileLineGround=new E,this._userUnitOptions=null,this._userUnit=null,t?.profiles||(this.profiles=new s([this._defaultProfileLineGround]))}initialize(){this._handles.add(m((()=>this.view),(t=>{u(t)?a.getLogger(this.declaredClass).warnOnce("no view. Widget will be disabled until a view is provided."):this.queue=R("3d"===t.type?t.resourceController?.scheduler:void 0)}),v)),this.tool=new S({viewModel:this}),this._controller=new C({viewModel:this})}destroy(){this._handles=h(this._handles),this._defaultProfileLineGround=h(this._defaultProfileLineGround),this._controller=h(this._controller),this._currentTileCache=h(this._currentTileCache),this.tool=h(this.tool),this.queue=h(this.queue)}set profiles(t){const e=this._get("profiles"),i=t??new s;this._set("profiles",n(i,e))}get state(){const t=this.view;return c(t)&&t.ready?this.tool.state:T.Disabled}get progress(){let t=0,e=0;for(const i of this.visibleProfiles)t++,e+=i.progress;return t>0?e/t:0}set unitOptions(t){this._userUnitOptions=t,this._set("unitOptions",this._filteredOrAllUnits(this._userUnitOptions))}get unitOptions(){return this._filteredOrAllUnits(this._userUnitOptions)}set unit(t){this._userUnit=t?this._findSelectableUnit(t,this._userUnit):null,this.notifyChange("unit")}get unit(){return this._userUnit?(this._userUnit=this._findSelectableUnit(this._userUnit,this.defaultUnit),this._userUnit):this._findSelectableUnit(this.defaultUnit)}get effectiveUnits(){const t=z(this.visibleProfiles.map((t=>t.result))),e=y(t.maxDistance,"meters",this.unit),i=g(t.maxElevation,"meters",this.unit);return this._getEffectiveUnitsMemoized(e,i)}get hasVertices(){const t=d(this.input,(t=>t.geometry));return G(t)&&t.paths.reduce(((t,e)=>t+e.length),0)>0}get hoveredPoints(){return!u(this.input)&&this.visible&&this.tool.editable?this.visibleProfiles.map((t=>{const e=t.hoveredPoint;return c(e)?{hoveredPoint:e,color:t.color}:null})).filter(c):[]}get statistics(){return N(this.visibleProfiles.map((t=>t.statistics)))}get chartData(){if(u(this.input))return null;const{effectiveUnits:t,progress:e,statistics:i,visibleProfiles:o,uniformChartScaling:r}=this,s=o.filter((t=>t.hasZ)).map((t=>({id:t.id,type:t.type,title:t.title,color:t.color,samples:t.samples,progress:t.progress,chartFillEnabled:t.chartFillEnabled,chartStrokeWidth:t.chartStrokeWidth,chartStrokeOffsetY:t.chartStrokeOffsetY,viewVisualizationEnabled:t.viewVisualizationEnabled})));return 0===s.length?null:{lines:s,effectiveUnits:t,statistics:i,refined:1===e,dynamicElevationRange:o.some((t=>"view"===t.type)),uniformScaling:r}}get visibleProfiles(){return this.profiles.toArray().filter((t=>t.available&&t.visible))}get minDemResolutions(){const t=[];for(const{minDemResolution:e}of this.visibleProfiles)c(e)&&t.push(e);return t}get minDemResolution(){return o(this.minDemResolutions)}get errorState(){const t=d(this.input,(t=>t.geometry));if(!I(t))return D.NoValidInput;if(c(this.error)){if(L(this.error))switch(this.error.cause){case k.TooComplex:return D.TooComplex;case k.InvalidGeometry:return D.InvalidGeometry;case k.InvalidElevationInfo:return D.InvalidElevationInfo;case k.ElevationQueryError:return D.NoValidInput}return D.UnknownError}return 0===this.visibleProfiles.length?D.NoVisibleProfiles:u(this.chartData)&&1===this.progress?D.RefinedButNoChartData:D.None}get tileCache(){this._currentTileCache=h(this._currentTileCache);const t=this.view;if(c(t)&&"3d"===t?.type){const e=t.basemapTerrain?.elevationQueryCache;if(c(e))return e}return u(this._currentTileCache)&&(this._currentTileCache=new j(new p(20*r.MEGABYTES))),this._currentTileCache}get inputIsSketched(){return this.tool.interaction.isSketchedGraphic(this.input)}get elevationProvider(){const t=this.view;return c(t)&&"3d"===t.type?t.elevationProvider:null}start(t){this.tool.interaction.start(t)}stop(){this.tool.interaction.stop()}cancel(){this.tool.interaction.cancel()}clear(){this.tool.interaction.clear()}_findSelectableUnit(t,e){const i=this.unitOptions;return c(t)&&i.includes(t)?t:e?this._findSelectableUnit(e):i[0]}_filteredOrAllUnits(t){const e=(c(t)?t:[]).filter((t=>_.includes(t)));return 0===e.length?_.slice():e}};t([b()],V.prototype,"view",void 0),t([b({type:e})],V.prototype,"input",void 0),t([b({type:O,nonNullable:!0})],V.prototype,"profiles",null),t([b({readOnly:!0})],V.prototype,"state",null),t([b({readOnly:!0})],V.prototype,"progress",null),t([b()],V.prototype,"unitOptions",null),t([b()],V.prototype,"unit",null),t([b({readOnly:!0})],V.prototype,"effectiveUnits",null),t([b({type:Number})],V.prototype,"geodesicDistanceThreshold",void 0),t([b()],V.prototype,"hoveredChartPosition",void 0),t([b()],V.prototype,"uniformChartScaling",void 0),t([U("tool.highlightEnabled")],V.prototype,"highlightEnabled",void 0),t([b({readOnly:!0})],V.prototype,"hoveredPoints",null),t([b({readOnly:!0})],V.prototype,"statistics",null),t([b()],V.prototype,"chartData",null),t([b()],V.prototype,"visibleProfiles",null),t([b()],V.prototype,"minDemResolutions",null),t([b({readOnly:!0})],V.prototype,"minDemResolution",null),t([b({readOnly:!0})],V.prototype,"errorState",null),t([b(w)],V.prototype,"defaultUnit",void 0),t([b()],V.prototype,"queue",void 0),t([b()],V.prototype,"tileCache",null),t([b()],V.prototype,"tool",void 0),t([U("tool.visible")],V.prototype,"visible",void 0),t([b()],V.prototype,"error",void 0),t([b()],V.prototype,"inputIsSketched",null),t([b()],V.prototype,"elevationProvider",null),t([b()],V.prototype,"_defaultProfileLineGround",void 0),t([b()],V.prototype,"_userUnitOptions",void 0),t([b()],V.prototype,"_controller",void 0),t([b()],V.prototype,"_userUnit",void 0),V=t([P("esri.widgets.ElevationProfile.ElevationProfileViewModel")],V);const x=V;export{x as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import i from"../../core/Accessor.js";import{min as r}from"../../core/arrayUtils.js";import{ByteSizeUnit as o}from"../../core/byteSizeEstimations.js";import s from"../../core/Collection.js";import{referenceSetter as l}from"../../core/collectionUtils.js";import n from"../../core/Handles.js";import a from"../../core/Logger.js";import p from"../../core/LRUCache.js";import{isNone as h,destroyMaybe as u,isSome as c,applySome as d}from"../../core/maybe.js";import{memoize as f}from"../../core/memoize.js";import{watch as m,syncAndInitial as v}from"../../core/reactiveUtils.js";import{preferredLengthUnit as y,preferredVerticalLengthUnit as g,measurementLengthUnits as _}from"../../core/unitUtils.js";import{property as b}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as U}from"../../core/accessorSupport/decorators/subclass.js";import{ElevationQueryTileCache as P}from"../../layers/support/ElevationQueryTileCache.js";import{defaultUnitPropertyMetadata as j}from"../../properties/defaultUnit.js";import{ElevationProfileController as E}from"./ElevationProfileController.js";import w from"./ElevationProfileLineGround.js";import{ElevationProfileLineCollection as C}from"./elevationProfileLineTypes.js";import{ElevationProfileTool as O}from"./ElevationProfileTool.js";import{ElevationProfileState as S,ElevationProfileErrorState as T}from"./support/constants.js";import{isPolyline as D,isValidInputPath as G}from"./support/geometryUtils.js";import{isProfileGenerationError as I,ProfileGenerationErrorCause as L}from"./support/ProfileGenerationError.js";import{createProfileQueue as k}from"./support/profileUtils.js";import{getBoundsInMeters as R,mergeStatistics as z}from"./support/statisticsUtils.js";let N=class extends i{constructor(t){super(t),this.view=null,this.input=null,this._getEffectiveUnitsMemoized=f(((t,e)=>({distance:t,elevation:e}))),this.geodesicDistanceThreshold=1e5,this.hoveredChartPosition=null,this.uniformChartScaling=!1,this.defaultUnit=null,this.queue=null,this._currentTileCache=null,this.error=null,this._handles=new n,this._defaultProfileLineGround=new w,this._userUnitOptions=null,this._userUnit=null,t?.profiles||(this.profiles=new s([this._defaultProfileLineGround]))}initialize(){this._handles.add(m((()=>this.view),(t=>{h(t)?a.getLogger(this.declaredClass).warnOnce("no view. Widget will be disabled until a view is provided."):this.queue=k("3d"===t.type?t.resourceController?.scheduler:void 0)}),v)),this.tool=new O({viewModel:this}),this._controller=new E({viewModel:this})}destroy(){this._handles=u(this._handles),this._defaultProfileLineGround=u(this._defaultProfileLineGround),this._controller=u(this._controller),this._currentTileCache=u(this._currentTileCache),this.tool=u(this.tool),this.queue=u(this.queue)}get profiles(){return this._get("profiles")}set profiles(t){const e=this._get("profiles"),i=t??new s;this._set("profiles",l(i,e))}get state(){const t=this.view;return c(t)&&t.ready?this.tool.state:S.Disabled}get progress(){let t=0,e=0;for(const i of this.visibleProfiles)t++,e+=i.progress;return t>0?e/t:0}set unitOptions(t){this._userUnitOptions=t,this._set("unitOptions",this._filteredOrAllUnits(this._userUnitOptions))}get unitOptions(){return this._filteredOrAllUnits(this._userUnitOptions)}set unit(t){this._userUnit=t?this._findSelectableUnit(t,this._userUnit):null,this.notifyChange("unit")}get unit(){return this._userUnit?(this._userUnit=this._findSelectableUnit(this._userUnit,this.defaultUnit),this._userUnit):this._findSelectableUnit(this.defaultUnit)}get effectiveUnits(){const t=R(this.visibleProfiles.map((t=>t.result))),e=y(t.maxDistance,"meters",this.unit),i=g(t.maxElevation,"meters",this.unit);return this._getEffectiveUnitsMemoized(e,i)}get highlightEnabled(){return this.tool.highlightEnabled}set highlightEnabled(t){this.tool.highlightEnabled=t}get hasVertices(){const t=d(this.input,(t=>t.geometry));return D(t)&&t.paths.reduce(((t,e)=>t+e.length),0)>0}get hoveredPoints(){return!h(this.input)&&this.visible&&this.tool.editable?this.visibleProfiles.map((t=>{const e=t.hoveredPoint;return c(e)?{hoveredPoint:e,color:t.color}:null})).filter(c):[]}get statistics(){return z(this.visibleProfiles.map((t=>t.statistics)))}get chartData(){if(h(this.input))return null;const{effectiveUnits:t,progress:e,statistics:i,visibleProfiles:r,uniformChartScaling:o}=this,s=r.filter((t=>t.hasZ)).map((t=>({id:t.id,type:t.type,title:t.title,color:t.color,samples:t.samples,progress:t.progress,chartFillEnabled:t.chartFillEnabled,chartStrokeWidth:t.chartStrokeWidth,chartStrokeOffsetY:t.chartStrokeOffsetY,viewVisualizationEnabled:t.viewVisualizationEnabled})));return 0===s.length?null:{lines:s,effectiveUnits:t,statistics:i,refined:1===e,dynamicElevationRange:r.some((t=>"view"===t.type)),uniformScaling:o}}get visibleProfiles(){return this.profiles.toArray().filter((t=>t.available&&t.visible))}get minDemResolutions(){const t=[];for(const{minDemResolution:e}of this.visibleProfiles)c(e)&&t.push(e);return t}get minDemResolution(){return r(this.minDemResolutions)}get errorState(){const t=d(this.input,(t=>t.geometry));if(!G(t))return T.NoValidInput;if(c(this.error)){if(I(this.error))switch(this.error.cause){case L.TooComplex:return T.TooComplex;case L.InvalidGeometry:return T.InvalidGeometry;case L.InvalidElevationInfo:return T.InvalidElevationInfo;case L.ElevationQueryError:return T.NoValidInput}return T.UnknownError}return 0===this.visibleProfiles.length?T.NoVisibleProfiles:h(this.chartData)&&1===this.progress?T.RefinedButNoChartData:T.None}get tileCache(){this._currentTileCache=u(this._currentTileCache);const t=this.view;if(c(t)&&"3d"===t?.type){const e=t.basemapTerrain?.elevationQueryCache;if(c(e))return e}return h(this._currentTileCache)&&(this._currentTileCache=new P(new p(20*o.MEGABYTES))),this._currentTileCache}get visible(){return this.tool.visible}set visible(t){this.tool.visible=t}get inputIsSketched(){return this.tool.interaction.isSketchedGraphic(this.input)}get elevationProvider(){const t=this.view;return c(t)&&"3d"===t.type?t.elevationProvider:null}start(t){this.tool.interaction.start(t)}stop(){this.tool.interaction.stop()}cancel(){this.tool.interaction.cancel()}clear(){this.tool.interaction.clear()}_findSelectableUnit(t,e){const i=this.unitOptions;return c(t)&&i.includes(t)?t:e?this._findSelectableUnit(e):i[0]}_filteredOrAllUnits(t){const e=(c(t)?t:[]).filter((t=>_.includes(t)));return 0===e.length?_.slice():e}};t([b()],N.prototype,"view",void 0),t([b({type:e})],N.prototype,"input",void 0),t([b({type:C,nonNullable:!0})],N.prototype,"profiles",null),t([b({readOnly:!0})],N.prototype,"state",null),t([b({readOnly:!0})],N.prototype,"progress",null),t([b()],N.prototype,"unitOptions",null),t([b()],N.prototype,"unit",null),t([b({readOnly:!0})],N.prototype,"effectiveUnits",null),t([b({type:Number})],N.prototype,"geodesicDistanceThreshold",void 0),t([b()],N.prototype,"hoveredChartPosition",void 0),t([b()],N.prototype,"uniformChartScaling",void 0),t([b()],N.prototype,"highlightEnabled",null),t([b({readOnly:!0})],N.prototype,"hoveredPoints",null),t([b({readOnly:!0})],N.prototype,"statistics",null),t([b()],N.prototype,"chartData",null),t([b()],N.prototype,"visibleProfiles",null),t([b()],N.prototype,"minDemResolutions",null),t([b({readOnly:!0})],N.prototype,"minDemResolution",null),t([b({readOnly:!0})],N.prototype,"errorState",null),t([b(j)],N.prototype,"defaultUnit",void 0),t([b()],N.prototype,"queue",void 0),t([b()],N.prototype,"tileCache",null),t([b()],N.prototype,"tool",void 0),t([b()],N.prototype,"visible",null),t([b()],N.prototype,"error",void 0),t([b()],N.prototype,"inputIsSketched",null),t([b()],N.prototype,"elevationProvider",null),t([b()],N.prototype,"_defaultProfileLineGround",void 0),t([b()],N.prototype,"_userUnitOptions",void 0),t([b()],N.prototype,"_controller",void 0),t([b()],N.prototype,"_userUnit",void 0),N=t([U("esri.widgets.ElevationProfile.ElevationProfileViewModel")],N);const V=N;export{V as default};