@arcgis/core 4.27.0-next.20230419 → 4.27.0-next.20230421

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 (203) hide show
  1. package/WebMap.js +1 -1
  2. package/WebScene.js +1 -1
  3. package/arcade/arcadeAsyncRuntime.js +1 -1
  4. package/arcade/arcadeCompiler.js +1 -1
  5. package/arcade/arcadeRuntime.js +1 -1
  6. package/arcade/executionError.js +1 -1
  7. package/assets/esri/core/workers/RemoteClient.js +1 -1
  8. package/assets/esri/core/workers/chunks/{f64f95623d9296a91f95.js → 059ec6fd9b971de4b4c1.js} +1 -1
  9. package/assets/esri/core/workers/chunks/0d805fd9cd9ff3a636ca.js +1 -0
  10. package/assets/esri/core/workers/chunks/{1fe31a412479815e5e2d.js → 10770939900946feb20d.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{5252f3cc244204edc299.js → 1216e939d363f96b6cc6.js} +1 -1
  12. package/assets/esri/core/workers/chunks/156dad2b7fed6749bae7.js +1 -0
  13. package/assets/esri/core/workers/chunks/15a97d3e42b00ac42984.js +1 -0
  14. package/assets/esri/core/workers/chunks/{d72c0c97cc4e30f1e4f2.js → 18704903814b9d73c708.js} +1 -1
  15. package/assets/esri/core/workers/chunks/1db5e4c8244dbc21590c.js +1 -0
  16. package/assets/esri/core/workers/chunks/2a1a5a1969e80a10dcca.js +1 -0
  17. package/assets/esri/core/workers/chunks/33b735faa582e6f39e9a.js +1 -0
  18. package/assets/esri/core/workers/chunks/34025ac04ca02531923a.js +1 -0
  19. package/assets/esri/core/workers/chunks/3e9f3479fd8558d9e3e3.js +1 -0
  20. package/assets/esri/core/workers/chunks/{d59274ac695dfcff1143.js → 46090b69e9161bc05141.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{f7aa972cb3903847b3bf.js → 47bf38d910e71ac39bb8.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{3978f4f68ada540ee3a3.js → 4f8a09b61267e5e26712.js} +1 -1
  23. package/assets/esri/core/workers/chunks/5183ecab7eddae7b70e8.js +1 -0
  24. package/assets/esri/core/workers/chunks/{a5c33b24b7ee042cb473.js → 51a0d1dabe7415515c77.js} +2 -2
  25. package/assets/esri/core/workers/chunks/541e6efc3b491e507410.js +1 -0
  26. package/assets/esri/core/workers/chunks/588256e65685ff21d2e9.js +1 -0
  27. package/assets/esri/core/workers/chunks/5c64fd3bf057a1a5527f.js +1 -0
  28. package/assets/esri/core/workers/chunks/6047bdaf4855506f8fdb.js +1 -0
  29. package/assets/esri/core/workers/chunks/6adb58f1bffc5d1c03bd.js +1 -0
  30. package/assets/esri/core/workers/chunks/770940417e6ddbdbb9d6.js +1 -0
  31. package/assets/esri/core/workers/chunks/{1c1d8be85297c483a606.js → 77c98121223a144170e3.js} +1 -1
  32. package/assets/esri/core/workers/chunks/80117007d86be4eb3bc3.js +1 -0
  33. package/assets/esri/core/workers/chunks/812cba53143565a825f1.js +1 -0
  34. package/assets/esri/core/workers/chunks/838849b751805615833a.js +1 -0
  35. package/assets/esri/core/workers/chunks/{9ca395f7bc8d397b5240.js → 88197520501fcc20b6e8.js} +1 -1
  36. package/assets/esri/core/workers/chunks/88f9dededcf60fd011ef.js +1 -0
  37. package/assets/esri/core/workers/chunks/88fdd288ef799a7ac48a.js +1 -0
  38. package/assets/esri/core/workers/chunks/8ae7fea9f7fda38dd207.js +1 -0
  39. package/assets/esri/core/workers/chunks/{0d080dd1ca6a71597409.js → 9265d4e9cfab2c7bbce5.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{8d41305509fedb3603ac.js → 94041a9ced04aa281d40.js} +1 -1
  41. package/assets/esri/core/workers/chunks/98540791fcef86069e44.js +1 -0
  42. package/assets/esri/core/workers/chunks/9c1b2f82877ff79969f5.js +1 -0
  43. package/assets/esri/core/workers/chunks/a7b3cd537c9127b5e65e.js +1 -0
  44. package/assets/esri/core/workers/chunks/{3d1c697182237807ab49.js → abea316f2eac0f3086ab.js} +1 -1
  45. package/assets/esri/core/workers/chunks/ad85ade6a2cfb56cf328.js +1 -0
  46. package/assets/esri/core/workers/chunks/b833b4ea2973bb16792e.js +1 -0
  47. package/assets/esri/core/workers/chunks/be4aa835a7abfc809126.js +1 -0
  48. package/assets/esri/core/workers/chunks/c2ec6e904f96173a7b83.js +1 -0
  49. package/assets/esri/core/workers/chunks/{c25aa08b869f2777dc26.js → c4488a8d857c765da30e.js} +1 -1
  50. package/assets/esri/core/workers/chunks/c5c56b6d99db96a6755a.js +2 -0
  51. package/assets/esri/core/workers/chunks/{7f3b0856f594df2b044e.js → c727d38f71e52bee17e1.js} +1 -1
  52. package/assets/esri/core/workers/chunks/cf315d255f0dc8d50f21.js +1 -0
  53. package/assets/esri/core/workers/chunks/cf7676fdc09ad4835680.js +1 -0
  54. package/assets/esri/core/workers/chunks/cfad34c949cbe8a31ef8.js +1 -0
  55. package/assets/esri/core/workers/chunks/{edb4568fe281b5609092.js → d244e50c981146f018d2.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{a2c9cb23f3e35e88da1d.js → d399b1b9cbf0737d1735.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{df7dcd035997881cf2ef.js → d5c8119d6d34628d3126.js} +1 -1
  58. package/assets/esri/core/workers/chunks/d6b6bb8aecc85d2a3f6b.js +1 -0
  59. package/assets/esri/core/workers/chunks/{8dfa32cc8453f85faab0.js → dd1f8bade9c5c3b7929b.js} +1 -1
  60. package/assets/esri/core/workers/chunks/e11e60759821746259c6.js +1 -0
  61. package/assets/esri/core/workers/chunks/{e4b65c5a4575a5c1c49f.js → e356c576f9a7521a49b3.js} +1 -1
  62. package/assets/esri/core/workers/chunks/f02edf71645eb33bf92f.js +1 -0
  63. package/assets/esri/core/workers/chunks/f1a4165c2710ca90e5ea.js +1 -0
  64. package/assets/esri/core/workers/chunks/f57a3ee17869ced3dd33.js +1 -0
  65. package/assets/esri/core/workers/chunks/fc07f6e103d7f69a9909.js +1 -0
  66. package/chunks/WaterSurface.glsl.js +35 -20
  67. package/chunks/index.js +1 -1
  68. package/core/Loadable.js +1 -1
  69. package/core/Promise.js +1 -1
  70. package/core/accessorSupport/ensureType.js +1 -1
  71. package/core/accessorSupport/watch.js +1 -1
  72. package/core/accessorSupport/write.js +1 -1
  73. package/core/promiseUtils.js +1 -1
  74. package/core/watchUtils.js +1 -1
  75. package/core/workers/Connection.js +1 -1
  76. package/core/workers/RemoteClient.js +1 -1
  77. package/core/workers/workerFactory.js +1 -1
  78. package/geometry/support/geodesicUtils.js +1 -1
  79. package/geometry/support/meshUtils/External.js +1 -1
  80. package/geometry/support/meshUtils/Metadata.js +1 -1
  81. package/intl/messages.js +1 -1
  82. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  83. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  84. package/layers/graphics/data/attributeSupport.js +1 -1
  85. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  86. package/layers/mixins/ArcGISMapService.js +1 -1
  87. package/layers/support/PromiseQueue.js +1 -1
  88. package/layers/support/Sublayer.js +1 -1
  89. package/layers/support/TileKey.js +1 -1
  90. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  91. package/networks/Network.js +1 -1
  92. package/package.json +1 -1
  93. package/portal/schemas/definitions.js +1 -1
  94. package/renderers/support/RasterSymbolizer.js +1 -1
  95. package/renderers/support/rasterRendererChecks.js +5 -0
  96. package/renderers/support/rasterRendererHelper.js +1 -1
  97. package/request.js +1 -1
  98. package/rest/query/operations/query.js +1 -1
  99. package/smartMapping/raster/renderers/uniqueValue.js +1 -1
  100. package/support/featureFlags.js +1 -1
  101. package/support/revision.js +1 -1
  102. package/symbols/support/previewSymbol3D.js +1 -1
  103. package/symbols/support/styleUtils.js +1 -1
  104. package/symbols/support/symbolLayerUtils.js +1 -1
  105. package/symbols/support/utils.js +1 -1
  106. package/symbols/support/webStyleSymbolUtils.js +1 -1
  107. package/views/2d/engine/webgl/TextureManager.js +1 -1
  108. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  109. package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
  110. package/views/2d/layers/features/sources/DataTileSource.js +1 -1
  111. package/views/2d/layers/features/sources/DataTileSubscription.js +1 -1
  112. package/views/2d/layers/features/sources/DrillDownFeatureSource.js +1 -1
  113. package/views/2d/layers/features/sources/PagedFeatureSource.js +1 -1
  114. package/views/2d/layers/features/support/FeatureSetReaderPBFHeader.js +1 -1
  115. package/views/2d/layers/features/tileRenderers/HeatmapTileRenderer.js +1 -1
  116. package/views/2d/layers/features/tileRenderers/SymbolTileRenderer.js +1 -1
  117. package/views/2d/layers/features/tileRenderers.js +1 -1
  118. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  119. package/views/2d/layers/support/webStyleUtils.js +1 -1
  120. package/views/3d/input/SceneInputManager.js +1 -1
  121. package/views/3d/interactive/manipulatorUtils.js +1 -1
  122. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  123. package/views/3d/layers/GraphicsView3D.js +1 -1
  124. package/views/3d/layers/I3SMeshView3D.js +1 -1
  125. package/views/3d/layers/graphics/ElevationQuery.js +1 -1
  126. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  127. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  128. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  129. package/views/3d/layers/graphics/polygonUtils.js +1 -1
  130. package/views/3d/layers/graphics/symbolComplexity.js +1 -1
  131. package/views/3d/layers/graphics/webStyleUtils.js +5 -0
  132. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  133. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  134. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  135. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  136. package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
  137. package/views/3d/webgl-engine/shaders/WaterSurface.glsl.js +1 -1
  138. package/views/LayerViewManager.js +1 -1
  139. package/views/PopupView.js +1 -1
  140. package/views/SceneView.js +1 -1
  141. package/views/ViewAnimation.js +1 -1
  142. package/views/input/BrowserEventSource.js +1 -1
  143. package/views/input/InputManager.js +1 -1
  144. package/views/interactive/coordinateHelper.js +1 -1
  145. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  146. package/views/layers/support/MapServiceLayerViewHelper.js +1 -1
  147. package/views/support/QueueProcessor.js +1 -1
  148. package/views/ui/DefaultUI.js +1 -1
  149. package/views/ui/UI.js +1 -1
  150. package/widgets/BasemapGallery/support/PortalBasemapsSource.js +1 -1
  151. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  152. package/widgets/Editor/Upload.js +1 -1
  153. package/widgets/Editor/deprecationUtils.js +1 -1
  154. package/widgets/Editor/modelUploadUtils.js +1 -1
  155. package/widgets/Editor.js +1 -1
  156. package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
  157. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  158. package/widgets/Feature/FeatureViewModel.js +1 -1
  159. package/widgets/Feature/support/featureUtils.js +1 -1
  160. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  161. package/widgets/Popup.js +1 -1
  162. package/widgets/support/decorators/accessibleHandler.js +1 -1
  163. package/assets/esri/core/workers/chunks/0948a40569b2408edefb.js +0 -1
  164. package/assets/esri/core/workers/chunks/192e3eeed50768c77c65.js +0 -1
  165. package/assets/esri/core/workers/chunks/1d1b9856f2f44d0c2144.js +0 -1
  166. package/assets/esri/core/workers/chunks/203115cc836e7b364eec.js +0 -1
  167. package/assets/esri/core/workers/chunks/20ad44b1a7adfed4c6c4.js +0 -1
  168. package/assets/esri/core/workers/chunks/27353056c3e4e8d8b8d3.js +0 -1
  169. package/assets/esri/core/workers/chunks/41ae9037c70461d5fdc7.js +0 -1
  170. package/assets/esri/core/workers/chunks/4b6a903d4aeeb4eeb615.js +0 -1
  171. package/assets/esri/core/workers/chunks/4bf9bc8b52d618f395c5.js +0 -1
  172. package/assets/esri/core/workers/chunks/5ec4fedbbcbb0053cf74.js +0 -2
  173. package/assets/esri/core/workers/chunks/60e29d172a2dcf45e8d0.js +0 -1
  174. package/assets/esri/core/workers/chunks/68a15cc7c51645d31572.js +0 -1
  175. package/assets/esri/core/workers/chunks/6b065e581bcf743079cf.js +0 -1
  176. package/assets/esri/core/workers/chunks/6c54579981a7bd483f1a.js +0 -1
  177. package/assets/esri/core/workers/chunks/778ecf61f07dafc51bbc.js +0 -1
  178. package/assets/esri/core/workers/chunks/7da1fd3629362b81b43c.js +0 -1
  179. package/assets/esri/core/workers/chunks/80d335bec34d60b7bbdc.js +0 -1
  180. package/assets/esri/core/workers/chunks/810da30f13151b72a293.js +0 -1
  181. package/assets/esri/core/workers/chunks/81485a5056aed94b3d8d.js +0 -1
  182. package/assets/esri/core/workers/chunks/8374d89e995f0d15c042.js +0 -1
  183. package/assets/esri/core/workers/chunks/8ebda132068f6b962dd9.js +0 -1
  184. package/assets/esri/core/workers/chunks/8f553ae2f1aba4e0371f.js +0 -1
  185. package/assets/esri/core/workers/chunks/8fec9979ae2b0e3a878f.js +0 -1
  186. package/assets/esri/core/workers/chunks/979ea2e3b1b164334634.js +0 -1
  187. package/assets/esri/core/workers/chunks/a0e92dd27c8f6b642dbf.js +0 -1
  188. package/assets/esri/core/workers/chunks/a6240bf258b3886a6661.js +0 -1
  189. package/assets/esri/core/workers/chunks/b059cd03f31ead61abb4.js +0 -1
  190. package/assets/esri/core/workers/chunks/b1a8024bf8cdd0cd3884.js +0 -1
  191. package/assets/esri/core/workers/chunks/b366e0db9b5f27dd53a3.js +0 -1
  192. package/assets/esri/core/workers/chunks/b976d5599672665561ec.js +0 -1
  193. package/assets/esri/core/workers/chunks/c260ac058e63a5c0cf60.js +0 -1
  194. package/assets/esri/core/workers/chunks/c646dc9da08b509e39d6.js +0 -1
  195. package/assets/esri/core/workers/chunks/db5598944b691e43f13e.js +0 -1
  196. package/assets/esri/core/workers/chunks/eb163a2ddeb27c690308.js +0 -1
  197. package/assets/esri/core/workers/chunks/eec12b5666819bf2119d.js +0 -1
  198. package/assets/esri/core/workers/chunks/ef05496c1faf08d247f1.js +0 -1
  199. package/assets/esri/core/workers/chunks/f05634909c9449533193.js +0 -1
  200. package/assets/esri/core/workers/chunks/fcebd70b089dea833c75.js +0 -1
  201. package/views/layers/GraphicsView.js +0 -5
  202. /package/assets/esri/core/workers/chunks/{a5c33b24b7ee042cb473.js.LICENSE.txt → 51a0d1dabe7415515c77.js.LICENSE.txt} +0 -0
  203. /package/assets/esri/core/workers/chunks/{5ec4fedbbcbb0053cf74.js.LICENSE.txt → c5c56b6d99db96a6755a.js.LICENSE.txt} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{l as i}from"../../../../chunks/vec3.js";import{projectBoundingSphere as n}from"../../../../geometry/projection.js";import{f as s,h as o,u as r,c as l}from"../../../../chunks/sphere.js";import{i3sPatchingEnabled as a}from"../../../../support/featureFlags.js";import{LodMetric as d,NodeBase as h,Node as u,ElevationRange as c,NodeFilterImpact as _,NodeIMModificationImpact as g,NodeTraversalState as f}from"./I3SNode.js";import{invalidateMbs as m,invalidateObb as v,addWraparound as b}from"./I3SUtil.js";import{clone as p}from"../../support/orientedBoundingBox.js";class y{constructor(e,t,i,n,s){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=n,this.node=s,this.useAsHole=0,this.filterImpact=_.NotChecked}}class N{constructor(t,i,n,s,o,r,l,h,u,c,_,g,f,m,v){this._layer=t,this._streamDataController=n,this._clientNodeLoader=s,this._viewportQueries=o,this._logger=r,this.holeFilling=l,this._isLoaded=h,this._isReloading=u,this._isSelected=c,this._enable=_,this._needsUpdate=g,this._canRequest=f,this._computeVisibilityObb=m,this._computeNodeFiltering=v,this._dirty=!0,this._nodePages=[],this._clientNodePage=null,this._nodeCount=0,this._nodesPerPage=0,this._rootIndex=0,this._lodMetric=d.None,this._lodConversion=e=>e,this._isEditable=!1,this._urlPrefix="",this._loading=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._nodeTraversalState=new Map,this._version=w(0),this._visibilityCacheVersion=w(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missing=new e({deallocator:null}),this._prefetch=new e({deallocator:null}),this._updates=new x(this._missing),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=[],this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._isEditable=a()&&null!=t.associatedLayer&&null!=t.associatedLayer.infoFor3D,t.serviceUpdateTimeStamp&&t.serviceUpdateTimeStamp.lastUpdate&&(this._lastUpdate=`${t.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(i)}_init(e){if("page"===e.type){const t=e.rootPage;switch(this._urlPrefix=e.urlPrefix,this._nodesPerPage=e.pageSize,e.lodMetric){case"maxScreenThreshold":this._lodMetric=d.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=d.MaxScreenThreshold,this._lodConversion=T}if(this._isEditable){this._rootIndex=-1;const i=V(e.rootIndex,e.pageSize),n=t.nodes[i],s={nodes:[{index:this._rootIndex,children:[e.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(E(this._rootIndex,this._nodesPerPage),s),this.getNode(-1).serviceObb=void 0}else this._rootIndex=e.rootIndex;this._addPage(E(e.rootIndex,this._nodesPerPage),t),this._updateParentsAndLevel()}else if("node"===e.type){if(this._urlPrefix=e.urlPrefix,this._nodePages.push(O()),this._isEditable){this._clientNodePage=O();const t={id:"-1",version:null,mbs:e.rootNode.mbs,obb:e.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:e.rootNode.mbs,obb:e.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new h(t.id,null),-1);const i=this._validateNode(t.id,t);i&&this._addNode(i,this._rootIndex)}else this._rootIndex=this._makeRefNode(new h(e.rootNode.id,null),-1);const t=this._validateNode(e.rootNode.id,e.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){const i=-1,n=new h(e,t),s=this._makeClientRefNode(n,i);return this._linkChildToParentNode(i,s),this.requestUpdate(),s}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_loadPage(e){this._loading.add(e);const i=this._urlPrefix+e;this._streamDataController.request(i,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((i=>{this._loading.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loading.delete(t),e.madeProgress()}this._updateParentsAndLevel()}_addPage(e,t){const n=[],o=[],r=t.nodes.map(((t,r)=>{const l=n.length,a=t.children?t.children.length:0;o.push(this._rootIndex);for(let e=0;e<a;e++)n.push(t.children[e]);const d=`${t.index}`,h=p(t.obb),c=s(h.center[0],h.center[1],h.center[2],i(h.halfSize)),_=t.mesh&&t.mesh.attribute,g=t.mesh&&t.mesh.geometry,f=t.mesh&&t.mesh.material,m={hasSharedResource:!1,isEmpty:null==g,attributes:_&&null!=_.resource?`${_.resource}`:void 0,geometry:g&&null!=g.resource?`${g.resource}`:void 0,texture:f&&null!=f.resource?`${f.resource}`:void 0,geometryDefinition:g?g.definition:-1,materialDefinition:f?f.definition:-1},v=new u(d,L(r,e,this._nodesPerPage),c,a,0,m,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),g?g.featureCount:null);return v.serviceObb=h,v.visibilityObb=this._computeVisibilityObb(v),v.vertexCount=g?g.vertexCount:0,new y(l,a,C(this._visibilityCacheVersion),null,v)}));if(-1===e)this._clientNodePage=O(r,n,o);else{for(let t=this._nodePages.length;t<e;t++)this._nodePages[t]=null;this._nodePages[e]=O(r,n,o)}this._nodeCount+=r.length}_updateParentsAndLevel(){const e=new Array,t=(t,i,n)=>{const s=this._getPage(t);if(null!=s){const o=V(t,this._nodesPerPage);s.parents[o]=null!=i?i:-1;const r=s.nodes[o].node;null!=r&&(r.level=n,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),n=this.getNode(i);if(null!=n)for(let e=0;e<n.childCount;e++){t(this.getChildIndex(n.index,e),i,n.level+1),this._maxLevel=Math.max(this._maxLevel,n.level+1)}}}_getPage(e){const t=E(e,this._nodesPerPage);return t<0?this._clientNodePage:this._nodePages[t]}_getNodeInternal(e){const t=this._getPage(e);return null==t?null:t.nodes[V(e,this._nodesPerPage)]}_addNode(e,t){null!=e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),n=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?n+1:n);const{lodMetric:s,maxError:o}=A(e.lodSelection),r=this._getNodeInternal(t);return r.node=new u(e.id,t,e.mbs,r.childCount,n,e.resources,e.version,s,o,e.numFeatures),e.obb&&(r.node.serviceObb=p(e.obb)),r.node.visibilityObb=this._computeVisibilityObb(r.node),null!=r.ref&&(null==r.ref.mbs&&(r.ref.mbs=e.mbs),r.node.renderMbs=r.ref.renderMbs,r.node.serviceObbInRenderSR=r.ref.serviceObbInRenderSR,r.ref.visibilityObb=r.node.visibilityObb),r.node}_makeRefNode(e,t){const i=this._nodePages[0];if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const n=i.nodes.length;return i.nodes.push(new y(0,0,C(this._visibilityCacheVersion),e,null)),this._nodeCount++,i.parents.push(t),m(e.renderMbs),v(e.serviceObbInRenderSR),n}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const n=-(i.nodes.length+1);return i.nodes.push(new y(0,0,C(this._visibilityCacheVersion),e,null)),this._nodeCount++,i.parents.push(t),m(e.renderMbs),v(e.serviceObbInRenderSR),n}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const n=V(e,this._nodesPerPage),s=V(t,this._nodesPerPage),o=i.nodes[n],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const l=1;o.childCount+=l,null!=o.node&&(o.node.childCount+=l);for(const a of i.nodes)a.childOffset>r&&(a.childOffset+=l);i.parents[s]=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const n=this._clientNodePage;if(null==n)return;const s=this.getParentIndex(e);if(null==s)return;const o=new Set,r=new Map,l=e=>{const i=V(e,this._nodesPerPage),s=n.nodes[i];if(s.childCount>0)for(let t=s.childOffset;t<s.childOffset+s.childCount;++t)l(n.children[t]);t(s.node?.id,e),o.add(s),this._nodeTraversalState.delete(e)};l(e);const a=n.nodes,d=n.children,h=n.parents;n.nodes=[],n.children=[],n.parents=[];const u=n.nodes.map((()=>-1));for(let c=0;c<a.length;++c){const e=a[c];if(o.has(e))continue;const t=n.nodes.length,s=L(c,-1,this._nodesPerPage),l=L(t,-1,this._nodesPerPage);e.node&&(e.node.index=l),u[c]=l,n.nodes.push(e),s!==l&&(i(e.node?.id,s,l),r.set(s,l))}this._nodeCount-=a.length-n.nodes.length;for(let c=0;c<n.nodes.length;++c){const e=n.nodes[c],t=n.children.length;for(let s=e.childOffset;s<e.childOffset+e.childCount;++s){const e=d[s];if(e>=0)n.children.push(e);else{const t=V(e,this._nodesPerPage),i=a[t];if(o.has(i))continue;n.children.push(u[t])}}e.childOffset=t,e.childCount=n.children.length-t;const i=h[c];n.parents.push(u[V(i,this._nodesPerPage)])}this._updateParentBoundingInformation(u[V(s,this._nodesPerPage)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const i=this._clientNodeLoader.indexSR,s=this._clientNodeLoader.renderSR,a=this._getNodeInternal(t);if(null==a)return;for(let l=0;l<a.childCount;l++){const a=this.getChildIndex(t,l),d=this._getNodeInternal(a),h=null!=d?d.ref||d.node:null;if(null!=h&&h.mbs[3]>0)if(null==e)e=o(h.mbs,D);else{const t=U,o=Q,l=$;n(h.mbs,i,t,s),n(e,i,o,s),r(t,o,l),n(l,s,e,i)}}const d=a.ref||a.node;null!=d&&(null!=e?d.mbs=o(e,null!=d.mbs?d.mbs:l()):m(d.mbs),m(d.renderMbs),v(d.serviceObbInRenderSR),d.geometryObb=null),this.invalidateNodeVisibilityCacheInternal(a),t=this.getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeInternal(e),n=this._getPage(e);i.childOffset=n.children.length,i.childCount=t.length;for(let s=0;s<t.length;s++){const i=this._makeRefNode(t[s],e);n.children.push(i)}}getNode(e){const t=this._getNodeInternal(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes(((i,n)=>{(null!=i.node&&i.node.id===e||null!=i.ref&&i.ref.id===e)&&(t=n)})),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const n=i.nodes[V(e,this._nodesPerPage)];return i.children[n.childOffset+t]}getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.parents[V(e,this._nodesPerPage)]:null}getParent(e){const t=this.getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeInternal(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get size(){return this._nodeCount}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes((e=>{null!=e.node&&(e.node.geometryObb=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=w(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeInternal(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=C(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeInternal(e);null!=t&&(I(t),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeInternal(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.ref;if(null==i)return;const n=i.elevationRange;null!=n&&(n.valid=!1)}invalidateGeometryVisibility(e){const t=this._getNodeInternal(e);null!=t&&null!=t.node&&(t.node.geometryObb=null,m(t.node.renderMbs),v(t.node.serviceObbInRenderSR))}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}_updateElevationRange(e){const t=this._getNodeInternal(e);if(null==t)return null;const i=null!=t.node?t.node:t.ref;if(null==i)return null;const n=i.elevationRange;if(null!=n&&n.valid)return n;const s=new c;let o=!1;for(let r=0;r<t.childCount;r++){const t=this._updateElevationRange(this.getChildIndex(e,r));null!=t?(s.min=Math.min(s.min,t.min),s.max=Math.max(s.max,t.max)):o=!0}if(0===t.childCount||o&&null!=t.node&&t.node.resources.geometry){const e=this._viewportQueries.getElevationRange(i);null!=e&&(s.min=Math.min(s.min,e.min),s.max=Math.max(s.max,e.max))}return null!=n&&n.min===s.min&&n.max===s.max?(n.valid=!0,n):(s.valid=!0,null!=t.node&&(t.node.elevationRange=s),null!=t.ref&&(t.ref.elevationRange=s),this.invalidateBoundingVolumeCache(e),s)}isNodeVisible(e){const t=this._getNodeInternal(e);if(null==t||null!=t.ref&&!t.ref.mbs)return!0;if(this.needNodeElevationRange&&this._updateElevationRange(e),!S(t.visibilityCache,this._visibilityCacheVersion)){const e=t.node,i=!e||t.ref&&!e.visibilityObb?t.ref??null:e;if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=e||null!=t.ref)&&t.filterImpact===_.NotChecked){const i=null!=e?e.mbs:null!=t.ref?t.ref.mbs:null;t.filterImpact=null!=i?this._computeNodeFiltering(i):_.Unmodified}const n=null!=e&&t.filterImpact===_.Culled,s=!(null!=e&&e.imModificationImpact===g.Culled)&&(!i||this._viewportQueries.isNodeVisible(i))&&!n;return t.visibilityCache=M(s,this._visibilityCacheVersion),s}return R(t.visibilityCache)}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeInternal(e);return!!(null==t||null==t.node||null==t.node.geometryObb||this.layerHasModifications&&t.node.imModificationImpact===g.NotChecked)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,n,s){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,l=new Array;for(let a=t.childOffset;a<r;++a){const e=o.children[a],t=this._getNodeInternal(e);null!=t&&null!=t.node&&this.isGeometryVisible(e)&&l.push(t)}n/=l.length;for(const a of l){const e=a.node.index;this._isLoaded(e)||this._isReloading(e)?(s.delta=Math.max(s.delta,i),s.coverage+=n):this._traverseCoverage(e,a,i+1,n,s)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeInternal(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(S(t.useAsHole,this._version))return R(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const n=i.delta*i.coverage<=.5;return t.useAsHole=M(n,this._version),n}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=w(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes((({node:e})=>{null!=e&&(e.imModificationImpact=g.NotChecked,e.visibilityObb=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))})),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes((e=>{if(null!=e){e.filterImpact=_.NotChecked;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}})),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missing.clear(),this._prefetch.clear(),this._updates.reset(e),P.clear();let n=!0;const s=new F,o=new F,r=this._imModificationUncategorized;r.clear();const l=new Set,a=(a,d,h)=>{if(null==d){let e=this._entryPriority(a);e===1/0&&(e=this._entryPriority(h));const t=E(a,this._nodesPerPage);return P.set(t,Math.max(e,P.get(t)||0)),this._loading.has(t)||this._failedPages.has(t)||this._missing.push(t),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const u=d.node;if(this._updateNodeFeatureEstimate(u,o),null==u){const e=this._entryPriority(a);return this._loading.has(a)||this._failedNodes.has(a)||(this._missing.push(a),P.set(a,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const c=this._getPage(a);if(0===this._missing.length&&0===this._nodesPerPage)for(let e=0;e<d.childCount;e++){const t=c.children[d.childOffset+e],i=this._getNodeInternal(t);null==i||i.node||this._loading.has(t)||this._failedNodes.has(t)||(P.set(t,this._entryPriority(t)),this._prefetch.push(t))}if(u.failed||u.resources.isEmpty)return void(n&&d.childCount>0&&this._isSelected(u)&&(n=!1));if(l.add(u.id),this._isLoaded(a)){if(s.known+=u.memory,++s.knownNodes,this._isSelected(u)?d.childCount>0&&(n=!1):(s.unremoved+=u.memory,n=!1),this._needsUpdate(u)){const e=this._entryPriority(a);P.set(a,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(a)}return}if(u.memory&&(s.known+=u.memory,++s.knownNodes),!this._isSelected(u))return void(this._isReloading(a)&&this._updates.remove.push(a));if(d.childCount>0&&(n=!1),u.memory?(s.missing+=u.memory,s.known+=u.memory,++s.knownNodes):++s.missingNodes,e.includes(u.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(a)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==u.index)));if(!t.done&&this._enable(u))return void t.madeProgress();const _=this._entryPriority(a);P.set(a,_),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,_),this._updates.add.push(a),this.layerHasModifications&&i&&null!=u&&u.imModificationImpact===g.NotChecked&&r.push(a)};this.traverseVisible(a);const d=this._updates.add;d.length>0&&this.layerHasModifications&&(r.length>0&&i?.(r),d.filterInPlace((e=>{const t=this._getNodeInternal(e),i=null==t||null==t.node||t.node.imModificationImpact!==g.Culled;return i||this.invalidateNodeVisibilityCache(e),i}))),this._unloadedMemoryEstimate=s.missing-s.unremoved,s.knownNodes>3&&s.missingNodes>0&&(this._unloadedMemoryEstimate+=s.known/s.knownNodes*s.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=n,this._missing.sort(((e,t)=>e-t)),this._missing.filterInPlace(((e,t)=>t<1||this._missing.data[t-1]!==e)),this._missing.sort(((e,t)=>P.get(e)-P.get(t))),this._missing.length>0&&(this._maxUnloadedPrio=P.get(this._missing.back()),this._prefetch.clear()),this._updates.add.filterInPlace((e=>P.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>P.get(e)-P.get(t))),this._updates.update.sort(((e,t)=>P.get(e)-P.get(t))),this._indexMissing=this._loading.size+this._missing.length,this._dirty=this._indexMissing>0,P.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let n=t,s=t,o=i,r=10;for(;r--;){const i=new F;this._updateFeatureEstimate(n,i);if(this._computeFeatureEstimate(i)<=e){if(n>=t||i.missingNodes>0||0===r)break;o=n,n=.5*(n+s)}else s=n,n=.5*(n+o)}return this._version=w(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,n)}_updateFeatureEstimate(e,t){this._version=w(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible(((e,i)=>this._updateNodeFeatureEstimate(null!=i?i.node:void 0,t)))}_updateNodeFeatureEstimate(e,t){if(null!=e&&!e.failed&&null!=e.numFeatures)return this._isLoaded(e.index)?(t.known+=e.numFeatures,++t.knownNodes,void(this._isSelected(e)||(t.unremoved+=e.numFeatures))):void(this._isSelected(e)&&(null!=e.numFeatures?(t.missing+=e.numFeatures,t.known+=e.numFeatures,++t.knownNodes):++t.missingNodes))}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missing)}prefetch(){return this._prefetch.sort(((e,t)=>P.get(e)-P.get(t))),this._load(this._prefetch)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();)if(0===this._nodesPerPage)this._loadNode(e.pop());else{const t=e.pop();t>=0?this._loadPage(t):this._loadNode(t)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetch.length>0}get indexLoading(){return this._loading.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(null==e)return null;let t=this._nodeTraversalState.get(e.index);if(t&&S(t.version,this._version))return t;const i=this._viewportQueries.getLodLevel(e),n=this._viewportQueries.hasLOD(e);let s=!0;if(n){const t=this.getParentIndex(e.index);if(null!=t){const e=this._nodeTraversalState.get(t);s=!!e&&i>e.lodLevel}else s=i>0}else s=0===e.childCount;return t?(t.lodLevel=i,t.isChosen=s,t.version=M(!0,this._version),t):(t=new f(n,s,i,M(!0,this._version)),this._nodeTraversalState.set(e.index,t),t)}async _loadNode(e){this._loading.add(e);const i=this._getNodeInternal(e).ref;if(null==i)return void this._failedNodes.add(e);const n=i.id,s=this._urlPrefix+n,o=()=>{this._loading.delete(e),0===this._missing.length&&0===this._loading.size&&this.requestUpdate()};let r=null;try{r=e>=0?await this._streamDataController.request(s,"json"):await this._clientNodeLoader.loadNodeJSON(n)}catch(d){o(),t(d)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+s),this._failedNodes.add(e))}o();const l=this._validateNode(n,r);if(null==l)return;l.obb&&this.invalidateNodeVisibilityCache(e);const a=this._addNode(l,e);this.nodeTraversalState(a)}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const n=t.attributeData,s=this._layer.attributeStorageInfo;null==n||Array.isArray(n)&&!n.some(((e,t)=>e.href!==`./attributes/${s?.[t]?.key??`f_${t}`}/0`))||this._logger.warn("#validateNode()",this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const o=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,r=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,l=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._layer,`Invalid node href on node "${e}"`);const n=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,s=new h(`${t.id}`,t.mbs);return s.serviceObb=n,s.visibilityObb=this._computeVisibilityObb(s),s},a=Array.isArray(t.children)?t.children.map(l).filter((e=>null!=e)):null,d=t.featureData&&t.featureData.length>1,u=t.isEmpty&&!0===t.isEmpty;return{id:e,mbs:t.mbs,obb:o,children:a,resources:{isEmpty:!d&&u,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:r}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((e=>{null!=e.node&&(e.node.failed=!1)}))}_entryPriority(e){const t=this._getNodeInternal(e),i=this.getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._entryPriority(i);let n=0;if(t.node&&null!=i){const e=this._nodeTraversalState.get(i);null!=e&&(n=e.lodLevel)}let s=this.progressiveLoadPenalty;for(let r=e;null!=r;r=this.getParentIndex(r))if(this._isLoaded(r)){s=0;break}const o=null!=t.ref?this._viewportQueries.distToPOI(t.ref):null!=t.node?this._viewportQueries.distToPOI(t.node):0;return-o-n*(o+this.progressiveLoadPenalty)+s}traverseVisible(e){const t=this._getNodeInternal(this._rootIndex);null!=t?this._traverseVisible(this._rootIndex,null,t,e):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,n){if(i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&n(e,i,t));if(!this.isNodeVisible(e))return;if(n(e,i,t),null==i.node)return;const s=this.nodeTraversalState(i.node);if(s?.nodeHasLOD&&s.lodLevel===this._maxLodLevel)return;const o=this._getPage(e);for(let r=0;r<i.childCount;r++){const t=o.children[i.childOffset+r],s=this._getNodeInternal(t);null!=s?this._traverseVisible(t,e,s,n):n(t,null,e)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(e,t){const i=e.index,n=this._getNodeInternal(i);null!=n&&this._traverseChildren(i,n,t)}_traverseChildren(e,t,i){const n=this._getPage(e);if(null==n)return;const s=t.childOffset+t.childCount;for(let o=t.childOffset;o<s;++o){const e=n.children[o],t=this._getNodeInternal(e);null!=t&&null!=t.node&&i(t.node)&&this._traverseChildren(e,t,i)}}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;)i.childrenLoaded+=t,i=this.getParent(i.index)}checkChildrenLoadedInvariant(){if(null==this.rootNode)return!0;const e=[],t=i=>{let n=this._isLoaded(i.index)||this._isReloading(i.index)?1:0;return this.traverseChildren(i,(e=>(n+=t(e),!1))),i.childrenLoaded!==n&&e.push(i.index),n};return t(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),(this._indexMissing||this._prefetch.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetch.length),e.prio=this._maxProcessingPrio,this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes((e=>{I(e),null!=e.node&&(e.node.elevationRange=null),null!=e.ref&&(e.ref.elevationRange=null)}))}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(let t=0;t<this._nodePages.length;t++){const i=this._nodePages[t];if(i){const n=t*this._nodesPerPage;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],n+t)}}}get test(){return{addNode:(e,t)=>this._addNode(e,t)}}}const P=new Map;class x{constructor(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function I(e){null!=e.node&&(m(e.node.renderMbs),v(e.node.serviceObbInRenderSR)),null!=e.ref&&(m(e.ref.renderMbs),v(e.ref.serviceObbInRenderSR))}function C(e){return b(e,-2)}function w(e){return b(e,2)}function M(e,t){return t+(e?1:0)}function S(e,t){return(-2&e)===t}function R(e){return 1==(1&e)}function E(e,t){return e<0?-1:0===t?0:e/t|0}function O(e=[],t=[],i=[]){return{nodes:e,children:t,parents:i}}function V(e,t){return e<0?-e-1:0===t?e:e%t}function L(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const k=[["maxScreenThreshold",d.MaxScreenThreshold],["screenSpaceRelative",d.ScreenSpaceRelative],["removedFeatureDiameter",d.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",d.DistanceRangeFromDefaultCamera]];function A(e){if(e)for(let t=0;t<e.length;t++)for(const i of k)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:d.None,maxError:0}}class F{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function T(e){return Math.sqrt(e*(4/Math.PI))}const D=l(),U=l(),Q=l(),$=l();export{N as I3SIndex,A as selectErrorMetric};
5
+ import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{l as i}from"../../../../chunks/vec3.js";import{projectBoundingSphere as n}from"../../../../geometry/projection.js";import{f as s,h as o,u as r,c as l}from"../../../../chunks/sphere.js";import{i3sPatchingEnabled as d}from"../../../../support/featureFlags.js";import{LodMetric as a,NodeBase as h,Node as u,ElevationRange as c,NodeFilterImpact as _,NodeIMModificationImpact as g,NodeTraversalState as f}from"./I3SNode.js";import{invalidateMbs as m,invalidateObb as v,addWraparound as b}from"./I3SUtil.js";import{clone as p}from"../../support/orientedBoundingBox.js";class y{constructor(e,t,i,n,s){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=n,this.node=s,this.useAsHole=0,this.filterImpact=_.NotChecked}}class N{constructor(t,i,n,s,o,r,l,h,u,c,_,g,f,m,v){this._layer=t,this._streamDataController=n,this._clientNodeLoader=s,this._viewportQueries=o,this._logger=r,this.holeFilling=l,this._isLoaded=h,this._isReloading=u,this._isSelected=c,this._enable=_,this._needsUpdate=g,this._canRequest=f,this._computeVisibilityObb=m,this._computeNodeFiltering=v,this._dirty=!0,this._nodePages=[],this._clientNodePage=null,this._nodeCount=0,this._nodesPerPage=0,this._rootIndex=0,this._lodMetric=a.None,this._lodConversion=e=>e,this._isEditable=!1,this._urlPrefix="",this._loading=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._nodeTraversalState=new Map,this._version=w(0),this._visibilityCacheVersion=w(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missing=new e({deallocator:null}),this._prefetch=new e({deallocator:null}),this._updates=new x(this._missing),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=[],this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._isEditable=d()&&null!=t.associatedLayer&&null!=t.associatedLayer.infoFor3D,t.serviceUpdateTimeStamp&&t.serviceUpdateTimeStamp.lastUpdate&&(this._lastUpdate=`${t.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(i)}_init(e){if("page"===e.type){const t=e.rootPage;switch(this._urlPrefix=e.urlPrefix,this._nodesPerPage=e.pageSize,e.lodMetric){case"maxScreenThreshold":this._lodMetric=a.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=a.MaxScreenThreshold,this._lodConversion=T}if(this._isEditable){this._rootIndex=-1;const i=V(e.rootIndex,e.pageSize),n=t.nodes[i],s={nodes:[{index:this._rootIndex,children:[e.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(E(this._rootIndex,this._nodesPerPage),s),this.getNode(-1).serviceObb=void 0}else this._rootIndex=e.rootIndex;this._addPage(E(e.rootIndex,this._nodesPerPage),t),this._updateParentsAndLevel()}else if("node"===e.type){if(this._urlPrefix=e.urlPrefix,this._nodePages.push(O()),this._isEditable){this._clientNodePage=O();const t={id:"-1",version:null,mbs:e.rootNode.mbs,obb:e.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:e.rootNode.mbs,obb:e.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new h(t.id,null),-1);const i=this._validateNode(t.id,t);i&&this._addNode(i,this._rootIndex)}else this._rootIndex=this._makeRefNode(new h(e.rootNode.id,null),-1);const t=this._validateNode(e.rootNode.id,e.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){const i=-1,n=new h(e,t),s=this._makeClientRefNode(n,i);return this._linkChildToParentNode(i,s),this.requestUpdate(),s}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_loadPage(e){this._loading.add(e);const i=this._urlPrefix+e;this._streamDataController.request(i,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((i=>{this._loading.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loading.delete(t),e.madeProgress()}this._updateParentsAndLevel()}_addPage(e,t){const n=[],o=[],r=t.nodes.map(((t,r)=>{const l=n.length,d=t.children?t.children.length:0;o.push(this._rootIndex);for(let e=0;e<d;e++)n.push(t.children[e]);const a=`${t.index}`,h=p(t.obb),c=s(h.center[0],h.center[1],h.center[2],i(h.halfSize)),_=t.mesh&&t.mesh.attribute,g=t.mesh&&t.mesh.geometry,f=t.mesh&&t.mesh.material,m={hasSharedResource:!1,isEmpty:null==g,attributes:_&&null!=_.resource?`${_.resource}`:void 0,geometry:g&&null!=g.resource?`${g.resource}`:void 0,texture:f&&null!=f.resource?`${f.resource}`:void 0,geometryDefinition:g?g.definition:-1,materialDefinition:f?f.definition:-1},v=new u(a,L(r,e,this._nodesPerPage),c,d,0,m,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),g?g.featureCount:null);return v.serviceObb=h,v.visibilityObb=this._computeVisibilityObb(v),v.vertexCount=g?g.vertexCount:0,new y(l,d,C(this._visibilityCacheVersion),null,v)}));if(-1===e)this._clientNodePage=O(r,n,o);else{for(let t=this._nodePages.length;t<e;t++)this._nodePages[t]=null;this._nodePages[e]=O(r,n,o)}this._nodeCount+=r.length}_updateParentsAndLevel(){const e=new Array,t=(t,i,n)=>{const s=this._getPage(t);if(null!=s){const o=V(t,this._nodesPerPage);s.parents[o]=null!=i?i:-1;const r=s.nodes[o].node;null!=r&&(r.level=n,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),n=this.getNode(i);if(null!=n)for(let e=0;e<n.childCount;e++){t(this.getChildIndex(n.index,e),i,n.level+1),this._maxLevel=Math.max(this._maxLevel,n.level+1)}}}_getPage(e){const t=E(e,this._nodesPerPage);return t<0?this._clientNodePage:this._nodePages[t]}_getNodeInternal(e){const t=this._getPage(e);return null==t?null:t.nodes[V(e,this._nodesPerPage)]}_addNode(e,t){null!=e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),n=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?n+1:n);const{lodMetric:s,maxError:o}=A(e.lodSelection),r=this._getNodeInternal(t);return r.node=new u(e.id,t,e.mbs,r.childCount,n,e.resources,e.version,s,o,e.numFeatures),e.obb&&(r.node.serviceObb=p(e.obb)),r.node.visibilityObb=this._computeVisibilityObb(r.node),null!=r.ref&&(null==r.ref.mbs&&(r.ref.mbs=e.mbs),r.node.renderMbs=r.ref.renderMbs,r.node.serviceObbInRenderSR=r.ref.serviceObbInRenderSR,r.ref.visibilityObb=r.node.visibilityObb),r.node}_makeRefNode(e,t){const i=this._nodePages[0];if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const n=i.nodes.length;return i.nodes.push(new y(0,0,C(this._visibilityCacheVersion),e,null)),this._nodeCount++,i.parents.push(t),m(e.renderMbs),v(e.serviceObbInRenderSR),n}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const n=-(i.nodes.length+1);return i.nodes.push(new y(0,0,C(this._visibilityCacheVersion),e,null)),this._nodeCount++,i.parents.push(t),m(e.renderMbs),v(e.serviceObbInRenderSR),n}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const n=V(e,this._nodesPerPage),s=V(t,this._nodesPerPage),o=i.nodes[n],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const l=1;o.childCount+=l,null!=o.node&&(o.node.childCount+=l);for(const d of i.nodes)d.childOffset>r&&(d.childOffset+=l);i.parents[s]=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const n=this._clientNodePage;if(null==n)return;const s=this.getParentIndex(e);if(null==s)return;const o=new Set,r=new Map,l=e=>{const i=V(e,this._nodesPerPage),s=n.nodes[i];if(s.childCount>0)for(let t=s.childOffset;t<s.childOffset+s.childCount;++t)l(n.children[t]);t(s.node?.id,e),o.add(s),this._nodeTraversalState.delete(e)};l(e);const d=n.nodes,a=n.children,h=n.parents;n.nodes=[],n.children=[],n.parents=[];const u=n.nodes.map((()=>-1));for(let c=0;c<d.length;++c){const e=d[c];if(o.has(e))continue;const t=n.nodes.length,s=L(c,-1,this._nodesPerPage),l=L(t,-1,this._nodesPerPage);e.node&&(e.node.index=l),u[c]=l,n.nodes.push(e),s!==l&&(i(e.node?.id,s,l),r.set(s,l))}this._nodeCount-=d.length-n.nodes.length;for(let c=0;c<n.nodes.length;++c){const e=n.nodes[c],t=n.children.length;for(let s=e.childOffset;s<e.childOffset+e.childCount;++s){const e=a[s];if(e>=0)n.children.push(e);else{const t=V(e,this._nodesPerPage),i=d[t];if(o.has(i))continue;n.children.push(u[t])}}e.childOffset=t,e.childCount=n.children.length-t;const i=h[c];n.parents.push(u[V(i,this._nodesPerPage)]),e.node&&(e.node.childrenLoaded-=e.node.childCount-e.childCount,e.node.childCount=e.childCount)}this._updateParentBoundingInformation(u[V(s,this._nodesPerPage)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const i=this._clientNodeLoader.indexSR,s=this._clientNodeLoader.renderSR,d=this._getNodeInternal(t);if(null==d)return;for(let l=0;l<d.childCount;l++){const d=this.getChildIndex(t,l),a=this._getNodeInternal(d),h=null!=a?a.ref||a.node:null;if(null!=h&&h.mbs[3]>0)if(null==e)e=o(h.mbs,D);else{const t=U,o=Q,l=$;n(h.mbs,i,t,s),n(e,i,o,s),r(t,o,l),n(l,s,e,i)}}const a=d.ref||d.node;null!=a&&(null!=e?a.mbs=o(e,null!=a.mbs?a.mbs:l()):m(a.mbs),m(a.renderMbs),v(a.serviceObbInRenderSR),a.geometryObb=null),this.invalidateNodeVisibilityCacheInternal(d),t=this.getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeInternal(e),n=this._getPage(e);i.childOffset=n.children.length,i.childCount=t.length;for(let s=0;s<t.length;s++){const i=this._makeRefNode(t[s],e);n.children.push(i)}}getNode(e){const t=this._getNodeInternal(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes(((i,n)=>{(null!=i.node&&i.node.id===e||null!=i.ref&&i.ref.id===e)&&(t=n)})),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const n=i.nodes[V(e,this._nodesPerPage)];return i.children[n.childOffset+t]}getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.parents[V(e,this._nodesPerPage)]:null}getParent(e){const t=this.getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeInternal(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get size(){return this._nodeCount}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes((e=>{null!=e.node&&(e.node.geometryObb=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=w(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeInternal(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=C(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeInternal(e);null!=t&&(I(t),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeInternal(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.ref;if(null==i)return;const n=i.elevationRange;null!=n&&(n.valid=!1)}invalidateGeometryVisibility(e){const t=this._getNodeInternal(e);null!=t&&null!=t.node&&(t.node.geometryObb=null,m(t.node.renderMbs),v(t.node.serviceObbInRenderSR))}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}_updateElevationRange(e){const t=this._getNodeInternal(e);if(null==t)return null;const i=null!=t.node?t.node:t.ref;if(null==i)return null;const n=i.elevationRange;if(null!=n&&n.valid)return n;const s=new c;let o=!1;for(let r=0;r<t.childCount;r++){const t=this._updateElevationRange(this.getChildIndex(e,r));null!=t?(s.min=Math.min(s.min,t.min),s.max=Math.max(s.max,t.max)):o=!0}if(0===t.childCount||o&&null!=t.node&&t.node.resources.geometry){const e=this._viewportQueries.getElevationRange(i);null!=e&&(s.min=Math.min(s.min,e.min),s.max=Math.max(s.max,e.max))}return null!=n&&n.min===s.min&&n.max===s.max?(n.valid=!0,n):(s.valid=!0,null!=t.node&&(t.node.elevationRange=s),null!=t.ref&&(t.ref.elevationRange=s),this.invalidateBoundingVolumeCache(e),s)}isNodeVisible(e){const t=this._getNodeInternal(e);if(null==t||null!=t.ref&&!t.ref.mbs)return!0;if(this.needNodeElevationRange&&this._updateElevationRange(e),!S(t.visibilityCache,this._visibilityCacheVersion)){const e=t.node,i=!e||t.ref&&!e.visibilityObb?t.ref??null:e;if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=e||null!=t.ref)&&t.filterImpact===_.NotChecked){const i=null!=e?e.mbs:null!=t.ref?t.ref.mbs:null;t.filterImpact=null!=i?this._computeNodeFiltering(i):_.Unmodified}const n=null!=e&&t.filterImpact===_.Culled,s=!(null!=e&&e.imModificationImpact===g.Culled)&&(!i||this._viewportQueries.isNodeVisible(i))&&!n;return t.visibilityCache=M(s,this._visibilityCacheVersion),s}return R(t.visibilityCache)}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeInternal(e);return!!(null==t||null==t.node||null==t.node.geometryObb||this.layerHasModifications&&t.node.imModificationImpact===g.NotChecked)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,n,s){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,l=new Array;for(let d=t.childOffset;d<r;++d){const e=o.children[d],t=this._getNodeInternal(e);null!=t&&null!=t.node&&this.isGeometryVisible(e)&&l.push(t)}n/=l.length;for(const d of l){const e=d.node.index;this._isLoaded(e)||this._isReloading(e)?(s.delta=Math.max(s.delta,i),s.coverage+=n):this._traverseCoverage(e,d,i+1,n,s)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeInternal(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(S(t.useAsHole,this._version))return R(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const n=i.delta*i.coverage<=.5;return t.useAsHole=M(n,this._version),n}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=w(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes((({node:e})=>{null!=e&&(e.imModificationImpact=g.NotChecked,e.visibilityObb=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))})),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes((e=>{if(null!=e){e.filterImpact=_.NotChecked;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}})),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missing.clear(),this._prefetch.clear(),this._updates.reset(e),P.clear();let n=!0;const s=new F,o=new F,r=this._imModificationUncategorized;r.clear();const l=new Set,d=(d,a,h)=>{if(null==a){let e=this._entryPriority(d);e===1/0&&(e=this._entryPriority(h));const t=E(d,this._nodesPerPage);return P.set(t,Math.max(e,P.get(t)||0)),this._loading.has(t)||this._failedPages.has(t)||this._missing.push(t),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const u=a.node;if(this._updateNodeFeatureEstimate(u,o),null==u){const e=this._entryPriority(d);return this._loading.has(d)||this._failedNodes.has(d)||(this._missing.push(d),P.set(d,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const c=this._getPage(d);if(0===this._missing.length&&0===this._nodesPerPage)for(let e=0;e<a.childCount;e++){const t=c.children[a.childOffset+e],i=this._getNodeInternal(t);null==i||i.node||this._loading.has(t)||this._failedNodes.has(t)||(P.set(t,this._entryPriority(t)),this._prefetch.push(t))}if(u.failed||u.resources.isEmpty)return void(n&&a.childCount>0&&this._isSelected(u)&&(n=!1));if(l.add(u.id),this._isLoaded(d)){if(s.known+=u.memory,++s.knownNodes,this._isSelected(u)?a.childCount>0&&(n=!1):(s.unremoved+=u.memory,n=!1),this._needsUpdate(u)){const e=this._entryPriority(d);P.set(d,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(d)}return}if(u.memory&&(s.known+=u.memory,++s.knownNodes),!this._isSelected(u))return void(this._isReloading(d)&&this._updates.remove.push(d));if(a.childCount>0&&(n=!1),u.memory?(s.missing+=u.memory,s.known+=u.memory,++s.knownNodes):++s.missingNodes,e.includes(u.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(d)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==u.index)));if(!t.done&&this._enable(u))return void t.madeProgress();const _=this._entryPriority(d);P.set(d,_),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,_),this._updates.add.push(d),this.layerHasModifications&&i&&null!=u&&u.imModificationImpact===g.NotChecked&&r.push(d)};this.traverseVisible(d);const a=this._updates.add;a.length>0&&this.layerHasModifications&&(r.length>0&&i?.(r),a.filterInPlace((e=>{const t=this._getNodeInternal(e),i=null==t||null==t.node||t.node.imModificationImpact!==g.Culled;return i||this.invalidateNodeVisibilityCache(e),i}))),this._unloadedMemoryEstimate=s.missing-s.unremoved,s.knownNodes>3&&s.missingNodes>0&&(this._unloadedMemoryEstimate+=s.known/s.knownNodes*s.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=n,this._missing.sort(((e,t)=>e-t)),this._missing.filterInPlace(((e,t)=>t<1||this._missing.data[t-1]!==e)),this._missing.sort(((e,t)=>P.get(e)-P.get(t))),this._missing.length>0&&(this._maxUnloadedPrio=P.get(this._missing.back()),this._prefetch.clear()),this._updates.add.filterInPlace((e=>P.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>P.get(e)-P.get(t))),this._updates.update.sort(((e,t)=>P.get(e)-P.get(t))),this._indexMissing=this._loading.size+this._missing.length,this._dirty=this._indexMissing>0,P.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let n=t,s=t,o=i,r=10;for(;r--;){const i=new F;this._updateFeatureEstimate(n,i);if(this._computeFeatureEstimate(i)<=e){if(n>=t||i.missingNodes>0||0===r)break;o=n,n=.5*(n+s)}else s=n,n=.5*(n+o)}return this._version=w(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,n)}_updateFeatureEstimate(e,t){this._version=w(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible(((e,i)=>this._updateNodeFeatureEstimate(null!=i?i.node:void 0,t)))}_updateNodeFeatureEstimate(e,t){if(null!=e&&!e.failed&&null!=e.numFeatures)return this._isLoaded(e.index)?(t.known+=e.numFeatures,++t.knownNodes,void(this._isSelected(e)||(t.unremoved+=e.numFeatures))):void(this._isSelected(e)&&(null!=e.numFeatures?(t.missing+=e.numFeatures,t.known+=e.numFeatures,++t.knownNodes):++t.missingNodes))}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missing)}prefetch(){return this._prefetch.sort(((e,t)=>P.get(e)-P.get(t))),this._load(this._prefetch)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();)if(0===this._nodesPerPage)this._loadNode(e.pop());else{const t=e.pop();t>=0?this._loadPage(t):this._loadNode(t)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetch.length>0}get indexLoading(){return this._loading.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(null==e)return null;let t=this._nodeTraversalState.get(e.index);if(t&&S(t.version,this._version))return t;const i=this._viewportQueries.getLodLevel(e),n=this._viewportQueries.hasLOD(e);let s=!0;if(n){const t=this.getParentIndex(e.index);if(null!=t){const e=this._nodeTraversalState.get(t);s=!!e&&i>e.lodLevel}else s=i>0}else s=0===e.childCount;return t?(t.lodLevel=i,t.isChosen=s,t.version=M(!0,this._version),t):(t=new f(n,s,i,M(!0,this._version)),this._nodeTraversalState.set(e.index,t),t)}async _loadNode(e){this._loading.add(e);const i=this._getNodeInternal(e).ref;if(null==i)return void this._failedNodes.add(e);const n=i.id,s=this._urlPrefix+n,o=()=>{this._loading.delete(e),0===this._missing.length&&0===this._loading.size&&this.requestUpdate()};let r=null;try{r=e>=0?await this._streamDataController.request(s,"json"):await this._clientNodeLoader.loadNodeJSON(n)}catch(a){o(),t(a)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+s),this._failedNodes.add(e))}o();const l=this._validateNode(n,r);if(null==l)return;l.obb&&this.invalidateNodeVisibilityCache(e);const d=this._addNode(l,e);this.nodeTraversalState(d)}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const n=t.attributeData,s=this._layer.attributeStorageInfo;null==n||Array.isArray(n)&&!n.some(((e,t)=>e.href!==`./attributes/${s?.[t]?.key??`f_${t}`}/0`))||this._logger.warn("#validateNode()",this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const o=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,r=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,l=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._layer,`Invalid node href on node "${e}"`);const n=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,s=new h(`${t.id}`,t.mbs);return s.serviceObb=n,s.visibilityObb=this._computeVisibilityObb(s),s},d=Array.isArray(t.children)?t.children.map(l).filter((e=>null!=e)):null,a=t.featureData&&t.featureData.length>1,u=t.isEmpty&&!0===t.isEmpty;return{id:e,mbs:t.mbs,obb:o,children:d,resources:{isEmpty:!a&&u,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:r}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((e=>{null!=e.node&&(e.node.failed=!1)}))}_entryPriority(e){const t=this._getNodeInternal(e),i=this.getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._entryPriority(i);let n=0;if(t.node&&null!=i){const e=this._nodeTraversalState.get(i);null!=e&&(n=e.lodLevel)}let s=this.progressiveLoadPenalty;for(let r=e;null!=r;r=this.getParentIndex(r))if(this._isLoaded(r)){s=0;break}const o=null!=t.ref?this._viewportQueries.distToPOI(t.ref):null!=t.node?this._viewportQueries.distToPOI(t.node):0;return-o-n*(o+this.progressiveLoadPenalty)+s}traverseVisible(e){const t=this._getNodeInternal(this._rootIndex);null!=t?this._traverseVisible(this._rootIndex,null,t,e):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,n){if(i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&n(e,i,t));if(!this.isNodeVisible(e))return;if(n(e,i,t),null==i.node)return;const s=this.nodeTraversalState(i.node);if(s?.nodeHasLOD&&s.lodLevel===this._maxLodLevel)return;const o=this._getPage(e);for(let r=0;r<i.childCount;r++){const t=o.children[i.childOffset+r],s=this._getNodeInternal(t);null!=s?this._traverseVisible(t,e,s,n):n(t,null,e)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(e,t){const i=e.index,n=this._getNodeInternal(i);null!=n&&this._traverseChildren(i,n,t)}_traverseChildren(e,t,i){const n=this._getPage(e);if(null==n)return;const s=t.childOffset+t.childCount;for(let o=t.childOffset;o<s;++o){const e=n.children[o],t=this._getNodeInternal(e);null!=t&&null!=t.node&&i(t.node)&&this._traverseChildren(e,t,i)}}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;)i.childrenLoaded+=t,i=this.getParent(i.index)}checkChildrenLoadedInvariant(){if(null==this.rootNode)return!0;const e=[],t=i=>{let n=this._isLoaded(i.index)||this._isReloading(i.index)?1:0;return this.traverseChildren(i,(e=>(n+=t(e),!1))),i.childrenLoaded!==n&&e.push(i.index),n};return t(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),(this._indexMissing||this._prefetch.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetch.length),e.prio=this._maxProcessingPrio,this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes((e=>{I(e),null!=e.node&&(e.node.elevationRange=null),null!=e.ref&&(e.ref.elevationRange=null)}))}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(let t=0;t<this._nodePages.length;t++){const i=this._nodePages[t];if(i){const n=t*this._nodesPerPage;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],n+t)}}}get test(){return{addNode:(e,t)=>this._addNode(e,t)}}}const P=new Map;class x{constructor(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function I(e){null!=e.node&&(m(e.node.renderMbs),v(e.node.serviceObbInRenderSR)),null!=e.ref&&(m(e.ref.renderMbs),v(e.ref.serviceObbInRenderSR))}function C(e){return b(e,-2)}function w(e){return b(e,2)}function M(e,t){return t+(e?1:0)}function S(e,t){return(-2&e)===t}function R(e){return 1==(1&e)}function E(e,t){return e<0?-1:0===t?0:e/t|0}function O(e=[],t=[],i=[]){return{nodes:e,children:t,parents:i}}function V(e,t){return e<0?-e-1:0===t?e:e%t}function L(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const k=[["maxScreenThreshold",a.MaxScreenThreshold],["screenSpaceRelative",a.ScreenSpaceRelative],["removedFeatureDiameter",a.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",a.DistanceRangeFromDefaultCamera]];function A(e){if(e)for(let t=0;t<e.length;t++)for(const i of k)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:a.None,maxError:0}}class F{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function T(e){return Math.sqrt(e*(4/Math.PI))}const D=l(),U=l(),Q=l(),$=l();export{N as I3SIndex,A as selectErrorMetric};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{splitIntoChunks as i}from"../../../../core/arrayUtils.js";import{resultOrAbort as r,result as o}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as n,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import c from"../../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as l}from"../../../../core/maybe.js";import{whenOrAbort as u}from"../../../../core/promiseUtils.js";import{watch as m,initial as g}from"../../../../core/reactiveUtils.js";import{property as y}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as _}from"../../../../intl/number.js";import{getMaximumQuerySize as b,queryAllJSON as O}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as f,extractMesh as C}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as j,i3sPatchingEnabled as I,sceneLayerEditingEnabled as v}from"../../../../support/featureFlags.js";import F from"../FeatureLayerView3D.js";let L=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=G,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new Set,this._geometryChangedObjectIds=new Set,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController}initialize(){this._memCache=this.memoryController.newCache(`${this.layer.uid}-attribute-overrides`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.then((async()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(j()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(m((()=>this._definitionExpression),(t=>e.definitionExpression=t),g)),this._associatedLayerView=new F({layer:this._associatedLayer,view:this.view}))})):I())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(j()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):I()),this._set("layer",null),this._memCache=h(this._memCache),this._pendingFetchAbortController=l(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null}get is3DOFL(){return v()&&null!=this._associatedLayer&&null!=this._associatedLayer.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get editSessionGeometryChangedObjectIds(){return this.is3DOFL?this._interactiveEditingSessions.toArray().map((e=>e.objectId)).sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(j()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return I(),!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e),this.notifyChange("_attributeChangedObjectIds");const t=v()&&I()&&null!=this.is3DOFL,s=this._clientGeometryCache.get(e);t&&(this._geometryChangedObjectIds.add(e),this.notifyChange("_geometryChangedObjectIds"));const i=this._interactiveEditingSessions,r=new A(e,{rollback:()=>{i.remove(r),t&&this.updateGeometry(e,null!=s?s.mesh:null)},commit:(s,i)=>{for(const[t,r]of s)this.updateAttributeValue(e,t,r);t&&void 0!==i&&this.updateGeometry(e,i)}});return i.unshift(r),r}async applyAttributeOverrides(e,t,s){if(null==t)return;const{loadedAttributes:i,attributeData:r}=t;if(null==i||0===i.length||null==r)return;if(this._pendingFetchChangedObjectIds&&await u(this._pendingFetchChangedObjectIds,s),0===this._attributeChangedObjectIds.size)return;const o={loadedAttributes:i,attributeData:r},n=this._getOverridesFromCache(e,o,this._attributeChangedObjectIds),{objectIds:a,fieldNames:d}=n;if(0===a.length||0===d.length)return;const c=await this._queryOverridesFromAssociatedLayer(a,d,!1,s);null!=c&&this._processOverridesFromAssociatedLayer(e,c,d,o)}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const s=this._clientGeometryCache.get(e);if(null!=s&&(this.geometryOverrides.remove(s),this._clientGeometryCache.delete(e)),null!=t){const s={oid:e,mesh:t};this.geometryOverrides.add(s),this._clientGeometryCache.set(e,s)}this.notifyChange("_geometryChangedObjectIds")}updateAttributeValue(e,t,s){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,s),this.notifyChange("_attributeChangedObjectIds")}_cacheAttributeValue(e,t,s){this._memCache.put(this._getAttributeCacheKey(e,t),s,this._memCacheAttributeValueSize(s))}_cacheGeometry(e,t){this._memCache.put(this._getGeometryCacheKey(e),t,this._memCacheGeometrySize(t))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},i){const r=new Set,o=new Array;for(const a of t)o[a.index]=s[a.name];const n=new Set;for(let a=0;a<e.length;a++){const s=e[a];if(i.has(s))for(const e of t){const t=this._attributeFromCache(s,e.index);void 0===t?(r.add(s),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(r),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const i=this._getAttributeCacheKey(e,t);return this._memCache.get(i)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const s of this._interactiveEditingSessions){if(s.objectId!==e)continue;const i=s.getAttribute(t);if(void 0!==i)return i}}_getAttributeCacheKey(e,t){return`${e}-${t}`}_getGeometryCacheKey(e){return`${e}-geometry`}async _queryOverridesFromAssociatedLayer(e,t,s,o){if(0===e.length||!1===s&&0===t.length)return null;e=e.sort(((e,t)=>e-t)),this._warnMaximumChangedObjectsExceeded&&(this._warnMaximumChangedObjectsExceeded=!1,this._logMaximumObjectsExceededWarning());const n=this.layer.associatedLayer;if(null==n)return null;const a=s&&this.is3DOFL&&I(),d=[n.objectIdField,...t];a&&null!=n.globalIdField&&d.push(n.globalIdField);const c=n.createQuery();c.where="1=1",c.returnGeometry=s,c.outFields=d,c.cacheHint=!0,c.objectIds=e;const h=b(n),l=e.length>h?i(e,h).map((e=>{const t=c.clone();return t.objectIds=e,r(O(n,t,{signal:o}))})):[r(O(n,c,{signal:o}))],u=await Promise.all(l);if(a&&null!=n.infoFor3D){const e=n.infoFor3D,t=n.spatialReference,s=[];for(const i of u){if(!i.ok)continue;const r=i.value;if(null==r.assetMaps)continue;const o=f(e,r.assetMaps);for(const i of r.features){const n=C(i,r.globalIdFieldName,t,e,o),a=i;null!=n?(a.geometry=n,s.push(a)):a.geometry=null}}return s}return u.reduce(((e,t)=>e.concat(t.ok?t.value.features:[])),[])}_logMaximumObjectsExceededWarning(){let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${_(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,c.getLogger("esri.views.3d.layers.i3s.I3SOverrides").warn("#queryOverrides()",this.layer.title,`${e}.`)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:i,attributeData:r}){const o=this.layer.associatedLayer;if(null==o)return;const n=o.objectIdField,a=s.map((e=>r[e])),d=new Map(i.map((e=>[e.name,e.index]))),c=s.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<s.length;t++){const i=c[t],r=h.get(e),o=l.attributes[s[t]];a[t][r]=o,this._cacheAttributeValue(e,i,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?n(e):a()}_memCacheGeometrySize(e){return 256}async _fetchChangedObjectIds(e){const s=this.layer;if(await s.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear(),null==s.associatedLayer||!s.associatedLayer.capabilities?.operations?.supportsChangeTracking)return;const i=this._getFetchChangedObjectIdsServerGen();if(null==i)return;const r=s.associatedLayer.layerId,n=this.is3DOFL,a=await o(t(`${s.associatedLayer.url}/extractChanges`,{method:"post",query:{f:"json",returnIdsOnly:!0,layers:`[${r}]`,returnUpdates:!0,returnDeletes:n,returnInserts:n,layerServerGens:JSON.stringify([{id:r,serverGen:i}])},timeout:w,signal:e}));if(a.ok&&1===a.value.data?.edits?.length){const t=a.value.data.edits[0]?.objectIds,i=t?.adds,r=t?.updates,o=t?.deletes;let n=[];null!=i&&(n=n.concat(i)),null!=r&&(n=n.concat(r)),null!=o&&(n=n.concat(o));const d=Math.min(this._maximumNumberOfEditOVerrides,n.length);d<n.length&&(this._warnMaximumChangedObjectsExceeded=!0);const c=n.sort(((e,t)=>e-t));for(let e=0;e<d;e++)this._attributeChangedObjectIds.add(c[e]),this._geometryChangedObjectIds.add(c[e]);if(this.is3DOFL&&I()&&this._geometryChangedObjectIds.size>0){const t=await this._queryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),[],!0,e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[s.associatedLayer.objectIdField],e.geometry)}}this.notifyChange("_attributeChangedObjectIds"),this.notifyChange("_geometryChangedObjectIds")}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp&&null!=e.serviceUpdateTimeStamp.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t&&null!=t.serverGens&&null!=t.serverGens.minServerGen?t.serverGens.minServerGen:null}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}};e([y({constructOnly:!0})],L.prototype,"view",void 0),e([y({constructOnly:!0})],L.prototype,"layer",void 0),e([y({readOnly:!0})],L.prototype,"is3DOFL",null),e([y()],L.prototype,"_interactiveEditingSessions",void 0),e([y({readOnly:!0})],L.prototype,"sortedGeometryChangedObjectIds",null),e([y({readOnly:!0})],L.prototype,"editSessionGeometryChangedObjectIds",null),e([y({readOnly:!0})],L.prototype,"geometryOverrides",void 0),e([y()],L.prototype,"_clientGeometryCache",void 0),e([y()],L.prototype,"_associatedLayer",null),e([y()],L.prototype,"_associatedLayerView",void 0),e([y({constructOnly:!0})],L.prototype,"memoryController",void 0),e([y()],L.prototype,"_attributeChangedObjectIds",void 0),e([y()],L.prototype,"_geometryChangedObjectIds",void 0),e([y()],L.prototype,"_pendingFetchChangedObjectIds",void 0),e([y()],L.prototype,"_definitionExpression",null),e([y()],L.prototype,"updating",null),e([y()],L.prototype,"isEmpty",null),L=e([p("esri.views.3d.layers.i3s.I3SOverrides")],L);class A{constructor(e,t){this.objectId=e,this._options=t,this._updates=new Map,this._updatedGeometry=void 0,this._state=E.ACTIVE}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this._isActive&&this._updates.set(e,t)}getGeometry(){return this._updatedGeometry}setGeometry(e){this._isActive&&(this._updatedGeometry=e)}rollback(){this._isActive&&(this._state=E.ROLLED_BACK,this._options.rollback(),this._updatedGeometry=void 0)}commit(){this._isActive&&(this._state=E.COMMITTED,this._options.commit(this._updates,this._updatedGeometry),this._updates.clear(),this._updatedGeometry=void 0)}get _isActive(){return this._state===E.ACTIVE}}var E;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(E||(E={}));const w=1e4,G=5e4;export{L as I3SOverrides};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{splitIntoChunks as i}from"../../../../core/arrayUtils.js";import{resultOrAbort as r,result as n}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as o,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import c from"../../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as l}from"../../../../core/maybe.js";import{whenOrAbort as u}from"../../../../core/promiseUtils.js";import{watch as m,initial as g}from"../../../../core/reactiveUtils.js";import{property as y}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as _}from"../../../../intl/number.js";import{getMaximumQuerySize as b,queryAllJSON as O}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as f,extractMesh as C}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as j,i3sPatchingEnabled as I,sceneLayerEditingEnabled as v}from"../../../../support/featureFlags.js";import F from"../FeatureLayerView3D.js";let L=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=G,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new Set,this._geometryChangedObjectIds=new Set,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController}initialize(){this._memCache=this.memoryController.newCache(`${this.layer.uid}-attribute-overrides`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.then((async()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(j()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(m((()=>this._definitionExpression),(t=>e.definitionExpression=t),g)),this._associatedLayerView=new F({layer:this._associatedLayer,view:this.view}))})):I())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(j()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):I()),this._set("layer",null),this._memCache=h(this._memCache),this._pendingFetchAbortController=l(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null}get is3DOFL(){return v()&&null!=this._associatedLayer&&null!=this._associatedLayer.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get editSessionGeometryChangedObjectIds(){return this.is3DOFL?this._interactiveEditingSessions.toArray().filter((e=>e.isActive)).map((e=>e.objectId)).sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(j()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return I(),!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e),this.notifyChange("_attributeChangedObjectIds");const t=v()&&I()&&null!=this.is3DOFL,s=this._clientGeometryCache.get(e);t&&(this._geometryChangedObjectIds.add(e),this.notifyChange("_geometryChangedObjectIds"));const i=this._interactiveEditingSessions,r=new A(e,{rollback:()=>{i.remove(r),t&&this.updateGeometry(e,null!=s?s.mesh:null)},commit:(s,i)=>{for(const[t,r]of s)this.updateAttributeValue(e,t,r);t&&void 0!==i&&this.updateGeometry(e,i),this.notifyChange("editSessionGeometryChangedObjectIds")}});return i.unshift(r),r}async applyAttributeOverrides(e,t,s){if(null==t)return;const{loadedAttributes:i,attributeData:r}=t;if(null==i||0===i.length||null==r)return;if(this._pendingFetchChangedObjectIds&&await u(this._pendingFetchChangedObjectIds,s),0===this._attributeChangedObjectIds.size)return;const n={loadedAttributes:i,attributeData:r},o=this._getOverridesFromCache(e,n,this._attributeChangedObjectIds),{objectIds:a,fieldNames:d}=o;if(0===a.length||0===d.length)return;const c=await this._queryOverridesFromAssociatedLayer(a,d,!1,s);null!=c&&this._processOverridesFromAssociatedLayer(e,c,d,n)}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const s=this._clientGeometryCache.get(e);if(null!=s&&(this.geometryOverrides.remove(s),this._clientGeometryCache.delete(e)),null!=t){const s={oid:e,mesh:t};this.geometryOverrides.add(s),this._clientGeometryCache.set(e,s)}this.notifyChange("_geometryChangedObjectIds")}updateAttributeValue(e,t,s){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,s),this.notifyChange("_attributeChangedObjectIds")}_cacheAttributeValue(e,t,s){this._memCache.put(this._getAttributeCacheKey(e,t),s,this._memCacheAttributeValueSize(s))}_cacheGeometry(e,t){this._memCache.put(this._getGeometryCacheKey(e),t,this._memCacheGeometrySize(t))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},i){const r=new Set,n=new Array;for(const a of t)n[a.index]=s[a.name];const o=new Set;for(let a=0;a<e.length;a++){const s=e[a];if(i.has(s))for(const e of t){const t=this._attributeFromCache(s,e.index);void 0===t?(r.add(s),o.add(e.name)):n[e.index][a]=t}}return{objectIds:Array.from(r),fieldNames:Array.from(o)}}_attributeFromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const i=this._getAttributeCacheKey(e,t);return this._memCache.get(i)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const s of this._interactiveEditingSessions){if(s.objectId!==e)continue;const i=s.getAttribute(t);if(void 0!==i)return i}}_getAttributeCacheKey(e,t){return`${e}-${t}`}_getGeometryCacheKey(e){return`${e}-geometry`}async _queryOverridesFromAssociatedLayer(e,t,s,n){if(0===e.length||!1===s&&0===t.length)return null;e=e.sort(((e,t)=>e-t)),this._warnMaximumChangedObjectsExceeded&&(this._warnMaximumChangedObjectsExceeded=!1,this._logMaximumObjectsExceededWarning());const o=this.layer.associatedLayer;if(null==o)return null;const a=s&&this.is3DOFL&&I(),d=[o.objectIdField,...t];a&&null!=o.globalIdField&&d.push(o.globalIdField);const c=o.createQuery();c.where="1=1",c.returnGeometry=s,c.outFields=d,c.cacheHint=!0,c.objectIds=e;const h=b(o),l=e.length>h?i(e,h).map((e=>{const t=c.clone();return t.objectIds=e,r(O(o,t,{signal:n}))})):[r(O(o,c,{signal:n}))],u=await Promise.all(l);if(a&&null!=o.infoFor3D){const e=o.infoFor3D,t=o.spatialReference,s=[];for(const i of u){if(!i.ok)continue;const r=i.value;if(null==r.assetMaps)continue;const n=f(e,r.assetMaps);for(const i of r.features){const o=C(i,r.globalIdFieldName,t,e,n),a=i;null!=o?(a.geometry=o,s.push(a)):a.geometry=null}}return s}return u.reduce(((e,t)=>e.concat(t.ok?t.value.features:[])),[])}_logMaximumObjectsExceededWarning(){let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${_(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,c.getLogger("esri.views.3d.layers.i3s.I3SOverrides").warn("#queryOverrides()",this.layer.title,`${e}.`)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:i,attributeData:r}){const n=this.layer.associatedLayer;if(null==n)return;const o=n.objectIdField,a=s.map((e=>r[e])),d=new Map(i.map((e=>[e.name,e.index]))),c=s.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[o];for(let t=0;t<s.length;t++){const i=c[t],r=h.get(e),n=l.attributes[s[t]];a[t][r]=n,this._cacheAttributeValue(e,i,n)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?o(e):a()}_memCacheGeometrySize(e){return 256}async _fetchChangedObjectIds(e){const s=this.layer;if(await s.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear(),null==s.associatedLayer||!s.associatedLayer.capabilities?.operations?.supportsChangeTracking)return;const i=this._getFetchChangedObjectIdsServerGen();if(null==i)return;const r=s.associatedLayer.layerId,o=this.is3DOFL,a=await n(t(`${s.associatedLayer.url}/extractChanges`,{method:"post",query:{f:"json",returnIdsOnly:!0,layers:`[${r}]`,returnUpdates:!0,returnDeletes:o,returnInserts:o,layerServerGens:JSON.stringify([{id:r,serverGen:i}])},timeout:w,signal:e}));if(a.ok&&1===a.value.data?.edits?.length){const t=a.value.data.edits[0]?.objectIds,i=t?.adds,r=t?.updates,n=t?.deletes;let o=[];null!=i&&(o=o.concat(i)),null!=r&&(o=o.concat(r)),null!=n&&(o=o.concat(n));const d=Math.min(this._maximumNumberOfEditOVerrides,o.length);d<o.length&&(this._warnMaximumChangedObjectsExceeded=!0);const c=o.sort(((e,t)=>e-t));for(let e=0;e<d;e++)this._attributeChangedObjectIds.add(c[e]),this._geometryChangedObjectIds.add(c[e]);if(this.is3DOFL&&I()&&this._geometryChangedObjectIds.size>0){const t=await this._queryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),[],!0,e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[s.associatedLayer.objectIdField],e.geometry)}}this.notifyChange("_attributeChangedObjectIds"),this.notifyChange("_geometryChangedObjectIds")}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp&&null!=e.serviceUpdateTimeStamp.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t&&null!=t.serverGens&&null!=t.serverGens.minServerGen?t.serverGens.minServerGen:null}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}};e([y({constructOnly:!0})],L.prototype,"view",void 0),e([y({constructOnly:!0})],L.prototype,"layer",void 0),e([y({readOnly:!0})],L.prototype,"is3DOFL",null),e([y()],L.prototype,"_interactiveEditingSessions",void 0),e([y({readOnly:!0})],L.prototype,"sortedGeometryChangedObjectIds",null),e([y({readOnly:!0})],L.prototype,"editSessionGeometryChangedObjectIds",null),e([y({readOnly:!0})],L.prototype,"geometryOverrides",void 0),e([y()],L.prototype,"_clientGeometryCache",void 0),e([y()],L.prototype,"_associatedLayer",null),e([y()],L.prototype,"_associatedLayerView",void 0),e([y({constructOnly:!0})],L.prototype,"memoryController",void 0),e([y()],L.prototype,"_attributeChangedObjectIds",void 0),e([y()],L.prototype,"_geometryChangedObjectIds",void 0),e([y()],L.prototype,"_pendingFetchChangedObjectIds",void 0),e([y()],L.prototype,"_definitionExpression",null),e([y()],L.prototype,"updating",null),e([y()],L.prototype,"isEmpty",null),L=e([p("esri.views.3d.layers.i3s.I3SOverrides")],L);class A{constructor(e,t){this.objectId=e,this._options=t,this._updates=new Map,this._updatedGeometry=void 0,this._state=E.ACTIVE}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}getGeometry(){return this._updatedGeometry}setGeometry(e){this.isActive&&(this._updatedGeometry=e)}rollback(){this.isActive&&(this._state=E.ROLLED_BACK,this._options.rollback(),this._updatedGeometry=void 0)}commit(){this.isActive&&(this._state=E.COMMITTED,this._options.commit(this._updates,this._updatedGeometry),this._updates.clear(),this._updatedGeometry=void 0)}get isActive(){return this._state===E.ACTIVE}}var E;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(E||(E={}));const w=1e4,G=5e4;export{L as I3SOverrides};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{secondsFromMilliseconds as e}from"../../../../core/time.js";import{f as t}from"../../../../chunks/vec2f64.js";import{f as r}from"../../../../chunks/vec4f64.js";import{ShaderOutput as i}from"../core/shaderLibrary/ShaderOutput.js";import{AnimationTimer as a}from"../lib/AnimationTimer.js";import{MaterialParameters as s}from"../lib/Material.js";import{OITPolygonOffsetLimit as n}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as o}from"../lib/RenderSlot.js";import{DefaultBufferWriter as h}from"./DefaultBufferWriter.js";import{PositionUVLayout as c}from"./DefaultLayouts.js";import{TriangleMaterial as p}from"./TriangleMaterial.js";import{WaterGLMaterial as m}from"./WaterGLMaterial.js";import{WaterTechniqueConfiguration as l}from"./WaterTechnique.js";class u extends p{constructor(e){super(e,new f),this._configuration=new l,this.animation=new a}getConfiguration(e,t){return this._configuration.output=e,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.receiveShadows=this.parameters.receiveShadows,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.parameters.transparent,this._configuration.hasScreenSpaceReflections=this.parameters.hasScreenSpaceReflections,this._configuration.hasCloudsReflections=this.parameters.hasCloudsReflections,this._configuration.isDraped=this.parameters.isDraped,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.enableOffset=t.camera.relativeElevation<n,this._configuration.hasMultipassTerrain=t.multipassTerrain.enabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration}update(t){const r=Math.min(t.camera.relativeElevation,t.camera.distance);this.animation.enabled=Math.sqrt(this.parameters.waveTextureRepeat/this.parameters.waveStrength)*r<d;const i=this.animation.advance(t);return this.setParameters({timeElapsed:e(this.animation.time)*this.parameters.animationSpeed},!1),this.animation.enabled&&i}requiresSlot(e,t){switch(t){case i.Normal:return e===o.DRAPED_WATER;case i.Color:if(this.parameters.isDraped)return e===o.DRAPED_MATERIAL;break;case i.Alpha:break;case i.Highlight:return e===o.OPAQUE_MATERIAL||e===o.DRAPED_MATERIAL;default:return!1}let r=o.OPAQUE_MATERIAL;return this.parameters.transparent&&(r=this.parameters.writeDepth?o.TRANSPARENT_MATERIAL:o.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),e===r}createGLMaterial(e){return new m(e)}createBufferWriter(){return new h(c)}}class f extends s{constructor(){super(...arguments),this.waveStrength=.06,this.waveTextureRepeat=32,this.waveDirection=t(1,0),this.waveVelocity=.05,this.flowStrength=.015,this.flowOffset=-.5,this.animationSpeed=.35,this.timeElapsed=0,this.color=r(0,0,0,0),this.transparent=!0,this.writeDepth=!0,this.hasSlicePlane=!1,this.isDraped=!1,this.receiveShadows=!0,this.hasScreenSpaceReflections=!1,this.hasCloudsReflections=!1}}const d=35e3;export{u as WaterMaterial,f as WaterMaterialParameters};
5
+ import has from"../../../../core/has.js";import{secondsFromMilliseconds as e}from"../../../../core/time.js";import{f as t}from"../../../../chunks/vec2f64.js";import{f as r}from"../../../../chunks/vec4f64.js";import{ShaderOutput as a}from"../core/shaderLibrary/ShaderOutput.js";import{AnimationTimer as i}from"../lib/AnimationTimer.js";import{MaterialParameters as s}from"../lib/Material.js";import{OITPolygonOffsetLimit as n}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as o}from"../lib/RenderSlot.js";import{DefaultBufferWriter as h}from"./DefaultBufferWriter.js";import{PositionUVLayoutObjectAndLayerId as c,PositionUVLayout as p}from"./DefaultLayouts.js";import{TriangleMaterial as m}from"./TriangleMaterial.js";import{WaterGLMaterial as l}from"./WaterGLMaterial.js";import{WaterTechniqueConfiguration as u}from"./WaterTechnique.js";class f extends m{constructor(e){super(e,new d),this._configuration=new u,this.animation=new i}getConfiguration(e,t){return this._configuration.output=e,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.receiveShadows=this.parameters.receiveShadows,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.parameters.transparent,this._configuration.hasScreenSpaceReflections=this.parameters.hasScreenSpaceReflections,this._configuration.hasCloudsReflections=this.parameters.hasCloudsReflections,this._configuration.isDraped=this.parameters.isDraped,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.enableOffset=t.camera.relativeElevation<n,this._configuration.hasMultipassTerrain=t.multipassTerrain.enabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration}update(t){const r=Math.min(t.camera.relativeElevation,t.camera.distance);this.animation.enabled=Math.sqrt(this.parameters.waveTextureRepeat/this.parameters.waveStrength)*r<A;const a=this.animation.advance(t);return this.setParameters({timeElapsed:e(this.animation.time)*this.parameters.animationSpeed},!1),this.animation.enabled&&a}requiresSlot(e,t){switch(t){case a.Normal:return e===o.DRAPED_WATER;case a.Color:if(this.parameters.isDraped)return e===o.DRAPED_MATERIAL;break;case a.Alpha:break;case a.Highlight:case a.ObjectAndLayerIdColor:return e===o.OPAQUE_MATERIAL||e===o.DRAPED_MATERIAL;default:return!1}let r=o.OPAQUE_MATERIAL;return this.parameters.transparent&&(r=this.parameters.writeDepth?o.TRANSPARENT_MATERIAL:o.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),e===r}createGLMaterial(e){return new l(e)}createBufferWriter(){return new h(has("enable-feature:objectAndLayerId-rendering")?c:p)}}class d extends s{constructor(){super(...arguments),this.waveStrength=.06,this.waveTextureRepeat=32,this.waveDirection=t(1,0),this.waveVelocity=.05,this.flowStrength=.015,this.flowOffset=-.5,this.animationSpeed=.35,this.timeElapsed=0,this.color=r(0,0,0,0),this.transparent=!0,this.writeDepth=!0,this.hasSlicePlane=!1,this.isDraped=!1,this.receiveShadows=!0,this.hasScreenSpaceReflections=!1,this.hasCloudsReflections=!1}}const A=35e3;export{f as WaterMaterial,d as WaterMaterialParameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{ViewingMode as t}from"../../../ViewingMode.js";import{ShaderOutput as r}from"../core/shaderLibrary/ShaderOutput.js";import{PBRMode as o}from"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{WaterDistortionPassParameters as i}from"../core/shaderLibrary/shading/WaterDistortion.glsl.js";import{ReloadableShaderModule as s}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as a}from"../core/shaderTechnique/ShaderTechnique.js";import{parameter as n}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{Default3D as p}from"../lib/DefaultVertexAttributeLocations.js";import{blendingDefault as l,oitBlending as u,oitDepthTest as c,oitDepthWrite as h,getOITPolygonOffset as d}from"../lib/OrderIndependentTransparency.js";import{Program as f}from"../lib/Program.js";import{TransparencyPassType as m}from"../lib/TransparencyPassType.js";import{DefaultTechniqueConfiguration as y}from"./DefaultTechniqueConfiguration.js";import{W as b}from"../../../../chunks/WaterSurface.glsl.js";import{makePipelineState as g,defaultDepthWriteParams as v,defaultColorWriteParams as T}from"../../../webgl/renderState.js";class S extends i{}class P extends a{initializeConfiguration(e,r){r.spherical=e.viewingMode===t.Global,r.doublePrecisionRequiresObfuscation=e.rctx.driverTest.doublePrecisionRequiresObfuscation.result}initializeProgram(e){return new f(e.rctx,P.shader.get().build(this.configuration),p)}_setPipelineState(e){const t=this.configuration,o=e===m.NONE,i=e===m.FrontFace;return g({blending:t.output!==r.Normal&&t.output!==r.Highlight&&t.transparent?o?l:u(e):null,depthTest:{func:c(e)},depthWrite:o?t.writeDepth?v:null:h(e),colorWrite:T,polygonOffset:o||i?null:d(t.enableOffset)})}initializePipeline(){return this._setPipelineState(this.configuration.transparencyPassType)}}P.shader=new s(b,(()=>import("../shaders/WaterSurface.glsl.js")));class j extends y{constructor(){super(...arguments),this.output=r.Color,this.transparencyPassType=m.NONE,this.spherical=!1,this.receiveShadows=!1,this.hasSlicePlane=!1,this.transparent=!1,this.enableOffset=!0,this.writeDepth=!1,this.hasScreenSpaceReflections=!1,this.doublePrecisionRequiresObfuscation=!1,this.hasCloudsReflections=!1,this.isDraped=!1,this.hasMultipassTerrain=!1,this.cullAboveGround=!1}}e([n({count:r.COUNT})],j.prototype,"output",void 0),e([n({count:m.COUNT})],j.prototype,"transparencyPassType",void 0),e([n()],j.prototype,"spherical",void 0),e([n()],j.prototype,"receiveShadows",void 0),e([n()],j.prototype,"hasSlicePlane",void 0),e([n()],j.prototype,"transparent",void 0),e([n()],j.prototype,"enableOffset",void 0),e([n()],j.prototype,"writeDepth",void 0),e([n()],j.prototype,"hasScreenSpaceReflections",void 0),e([n()],j.prototype,"doublePrecisionRequiresObfuscation",void 0),e([n()],j.prototype,"hasCloudsReflections",void 0),e([n()],j.prototype,"isDraped",void 0),e([n()],j.prototype,"hasMultipassTerrain",void 0),e([n()],j.prototype,"cullAboveGround",void 0),e([n({constValue:o.Water})],j.prototype,"pbrMode",void 0),e([n({constValue:!0})],j.prototype,"useCustomDTRExponentForWater",void 0),e([n({constValue:!0})],j.prototype,"highStepCount",void 0),e([n({constValue:!1})],j.prototype,"useFillLights",void 0);export{S as WaterMaterialPassParameters,P as WaterTechnique,j as WaterTechniqueConfiguration};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{ViewingMode as t}from"../../../ViewingMode.js";import{ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{PBRMode as r}from"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{WaterDistortionPassParameters as i}from"../core/shaderLibrary/shading/WaterDistortion.glsl.js";import{ReloadableShaderModule as s}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as a}from"../core/shaderTechnique/ShaderTechnique.js";import{parameter as n}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{Default3D as p}from"../lib/DefaultVertexAttributeLocations.js";import{blendingDefault as l,oitBlending as c,oitDepthTest as d,oitDepthWrite as u,getOITPolygonOffset as h}from"../lib/OrderIndependentTransparency.js";import{Program as f}from"../lib/Program.js";import{TransparencyPassType as y}from"../lib/TransparencyPassType.js";import{DefaultTechniqueConfiguration as m}from"./DefaultTechniqueConfiguration.js";import{W as b}from"../../../../chunks/WaterSurface.glsl.js";import{makePipelineState as g,defaultDepthWriteParams as v,defaultColorWriteParams as j}from"../../../webgl/renderState.js";class T extends i{}class S extends a{initializeConfiguration(e,o){o.spherical=e.viewingMode===t.Global,o.doublePrecisionRequiresObfuscation=e.rctx.driverTest.doublePrecisionRequiresObfuscation.result}initializeProgram(e){return new f(e.rctx,S.shader.get().build(this.configuration),p)}_setPipelineState(e){const t=this.configuration,r=e===y.NONE,i=e===y.FrontFace;return g({blending:t.output!==o.Normal&&t.output!==o.Highlight&&t.output!==o.ObjectAndLayerIdColor&&t.transparent?r?l:c(e):null,depthTest:{func:d(e)},depthWrite:r?t.writeDepth?v:null:u(e),colorWrite:j,polygonOffset:r||i?null:h(t.enableOffset)})}initializePipeline(){return this._setPipelineState(this.configuration.transparencyPassType)}}S.shader=new s(b,(()=>import("../shaders/WaterSurface.glsl.js")));class P extends m{constructor(){super(...arguments),this.output=o.Color,this.transparencyPassType=y.NONE,this.spherical=!1,this.receiveShadows=!1,this.hasSlicePlane=!1,this.transparent=!1,this.enableOffset=!0,this.writeDepth=!1,this.hasScreenSpaceReflections=!1,this.doublePrecisionRequiresObfuscation=!1,this.hasCloudsReflections=!1,this.objectAndLayerIdColorInstanced=!1,this.isDraped=!1,this.hasMultipassTerrain=!1,this.cullAboveGround=!1}}e([n({count:o.COUNT})],P.prototype,"output",void 0),e([n({count:y.COUNT})],P.prototype,"transparencyPassType",void 0),e([n()],P.prototype,"spherical",void 0),e([n()],P.prototype,"receiveShadows",void 0),e([n()],P.prototype,"hasSlicePlane",void 0),e([n()],P.prototype,"transparent",void 0),e([n()],P.prototype,"enableOffset",void 0),e([n()],P.prototype,"writeDepth",void 0),e([n()],P.prototype,"hasScreenSpaceReflections",void 0),e([n()],P.prototype,"doublePrecisionRequiresObfuscation",void 0),e([n()],P.prototype,"hasCloudsReflections",void 0),e([n()],P.prototype,"objectAndLayerIdColorInstanced",void 0),e([n()],P.prototype,"isDraped",void 0),e([n()],P.prototype,"hasMultipassTerrain",void 0),e([n()],P.prototype,"cullAboveGround",void 0),e([n({constValue:r.Water})],P.prototype,"pbrMode",void 0),e([n({constValue:!0})],P.prototype,"useCustomDTRExponentForWater",void 0),e([n({constValue:!0})],P.prototype,"highStepCount",void 0),e([n({constValue:!1})],P.prototype,"useFillLights",void 0);export{T as WaterMaterialPassParameters,S as WaterTechnique,P as WaterTechniqueConfiguration};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import"../core/shaderLibrary/ForwardLinearDepth.glsl.js";import"../core/shaderLibrary/ShaderOutput.js";import"../core/shaderLibrary/Slice.glsl.js";import"../core/shaderLibrary/Transform.glsl.js";import"../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../core/shaderLibrary/shading/EvaluateAmbientLighting.glsl.js";import"../core/shaderLibrary/shading/MainLighting.glsl.js";import"../core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import"../core/shaderLibrary/shading/NormalUtils.glsl.js";import"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import"../core/shaderLibrary/shading/Water.glsl.js";import"../core/shaderLibrary/shading/WaterDistortion.glsl.js";import"../core/shaderLibrary/util/AlphaCutoff.js";import"../core/shaderLibrary/util/ColorConversion.glsl.js";import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/Float4PassUniform.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/interfaces.js";import"../core/shaderModules/ShaderBuilder.js";import"../lib/TransparencyPassType.js";import"../lib/VertexAttribute.js";export{b as build}from"../../../../chunks/WaterSurface.glsl.js";
5
+ import"../core/shaderLibrary/ForwardLinearDepth.glsl.js";import"../core/shaderLibrary/ShaderOutput.js";import"../core/shaderLibrary/Slice.glsl.js";import"../core/shaderLibrary/Transform.glsl.js";import"../core/shaderLibrary/attributes/ObjectAndLayerIdColor.glsl.js";import"../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../core/shaderLibrary/shading/EvaluateAmbientLighting.glsl.js";import"../core/shaderLibrary/shading/MainLighting.glsl.js";import"../core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import"../core/shaderLibrary/shading/NormalUtils.glsl.js";import"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import"../core/shaderLibrary/shading/Water.glsl.js";import"../core/shaderLibrary/shading/WaterDistortion.glsl.js";import"../core/shaderLibrary/util/AlphaCutoff.js";import"../core/shaderLibrary/util/ColorConversion.glsl.js";import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/Float4PassUniform.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/interfaces.js";import"../core/shaderModules/ShaderBuilder.js";import"../lib/TransparencyPassType.js";import"../lib/VertexAttribute.js";export{b as build}from"../../../../chunks/WaterSurface.glsl.js";
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import r from"../core/Accessor.js";import i from"../core/Error.js";import t from"../core/Logger.js";import{someMap as s}from"../core/MapUtils.js";import{removeMaybe as a}from"../core/maybe.js";import{createDeferred as o,createAbortError as l,isAbortError as n,onAbort as y,throwIfAborted as h}from"../core/promiseUtils.js";import{on as c,watch as w,syncAndInitial as p}from"../core/reactiveUtils.js";import{schedule as d}from"../core/scheduling.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as f}from"../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as u}from"../core/support/WatchUpdatingTracking.js";import{destroyMap as _}from"../support/collectionUtils.js";function g(e){return"tryRecycleWith"in e}class v{constructor(e,r,t){this.layer=e,this.view=r,this.layerViewImporter=t,this._controller=new AbortController,this._deferred=o(),this._started=!1,this.done=!1,this.promise=this._deferred.promise,y(this._controller.signal,(()=>{const r=new i("cancelled:layerview-create","layerview creation cancelled",{layer:e});this._deferred.reject(r)}))}tryRecycle(e){if(!this.done||!this.layerView||!g(this.layerView))return null;const r=this.layer.type,i=this._controller.signal;for(let t=0;t<e.length;t++){const s=e[t];if(s.type!==r)continue;const a=this.layerView.tryRecycleWith(s,{signal:i});if(a){e.splice(t,1),this.layer=s;const r=this.layerView,i=r.view;return this.promise=Promise.race([a.then((()=>(h(this._controller.signal),s.emit("layerview-destroy",{view:i,layerView:r}),i.emit("layerview-destroy",{view:i,layerView:r}),s.emit("layerview-create",{view:i,layerView:r}),i.emit("layerview-create",{view:i,layerView:r}),r))),new Promise(((e,r)=>y(this._controller.signal,(()=>r(l())))))]),this.promise}}return null}destroy(){this._controller.abort();const{layerView:e}=this;if(e){const{layer:r,view:i}=this;r.emit("layerview-destroy",{view:i,layerView:e}),i.emit("layerview-destroy",{layer:r,layerView:e})}this.done=!0,this.layer=null,this.layerView=null,this.view=null,this.layerViewImporter=null,this._map=null}async start(){if(this._started)return;this._started=!0;const{_controller:{signal:e},layer:r,view:t}=this;this._map=t.map;try{let o,l;if(await r.load({signal:e}),"prefetchResources"in r&&await(r.prefetchResources?.({signal:e})),M(r))o=await r.createLayerView(t,{signal:e});else{if(!this.layerViewImporter.hasLayerViewModule(r))throw new i("layer:view-not-supported","No layerview implementation was found");const s=await this.layerViewImporter.importLayerView(r);h(e),o="default"in s?new s.default({layer:r,view:t}):new s({layer:r,view:t})}const n=()=>{l=a(l),o.destroyed||o.destroy(),o.layer=null,o.parent=null,o.view=null,this.done=!0};l=y(e,n),h(e);try{await o.when()}catch(s){throw n(),s}const c=this._map?.allLayers?.includes(r);if(!c)return n(),void this._deferred.reject(new i("view:no-layerview-for-layer","The layer has been removed from the map",{layer:r}));this.layerView=o,r.emit("layerview-create",{view:t,layerView:o}),t.emit("layerview-create",{layer:r,layerView:o}),this.done=!0,this._deferred.resolve(o)}catch(s){r.emit("layerview-create-error",{view:t,error:s}),t.emit("layerview-create-error",{layer:r,error:s}),this.done=!0,this._deferred.reject(new i("layerview:create-error","layerview creation failed",{layer:r,error:s}))}}}let V=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new u,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=o(),this._workPromise.promise.catch((()=>{}))),this.removeHandles("reschedule"),this.addHandles(d(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{if(this.destroyed)return;const e=this.view.map;if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,i=[],t=this.view.ready,s=e=>{if(null!=e)for(const a of e)if(a){r.add(a);const e=this._layerLayerViewInfoMap.get(a);e&&t?e.start():e||this._recyclingInfoMap.has(a)||i.push(a),"layers"in a&&a.layers&&s(a.layers)}};for(const o of this._rootCollectionNames)s(this.get(o));for(const[o,l]of this._layerLayerViewInfoMap)if(!r.has(o)){this._layerLayerViewInfoMap.delete(l.layer);const e=l.tryRecycle(i);e?(this._recyclingInfoMap.set(l.layer,l),e.then((()=>{this._recyclingInfoMap.delete(l.layer),this._layerLayerViewInfoMap.set(l.layer,l),this._reschedule()})).catch((()=>{this._recyclingInfoMap.delete(l.layer),l.destroy(),this._reschedule()}))):l.destroy()}for(const[o,l]of this._recyclingInfoMap)r.has(o)||(this._recyclingInfoMap.delete(l.layer),l.destroy());for(const o of i)this._createLayerView(o);this._refreshCollections();const a=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.referenceLayers,e?.layers].filter((e=>!!e));r.forEach((e=>"layers"in e&&a.push(e.layers))),this.addHandles(a.map((e=>this._watchUpdatingTracking.addOnCollectionChange((()=>e),this._reschedule))),"collection-change"),this._workPromise.resolve(),this._workPromise=null}}initialize(){this.own([c((()=>this.view?.map?.allLayers),"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),w((()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]}),(()=>this._reschedule()),p)]),this._preloadLayerViewModules(),this._reschedule()}destroy(){this.clear(),_(this._recyclingInfoMap),_(this._layerLayerViewInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(l()),this._workPromise=null)}get _layersToLayerViews(){const e=[["view.map.basemap.baseLayers","view.basemapView.baseLayerViews"],["view.map.layers","view.layerViews"],["view.map.basemap.referenceLayers","view.basemapView.referenceLayerViews"]];return this.supportsGround&&e.push(["view.map.ground.layers","view.groundView.layerViews"]),new Map(e)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||s(this._layerLayerViewInfoMap,(e=>!e.done))}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){this.destroyed||(_(this._layerLayerViewInfoMap),this._refreshCollections())}async whenLayerView(e){if(await this._reschedule(),!this._layerLayerViewInfoMap.has(e)){if(this._recyclingInfoMap.has(e))return this._recyclingInfoMap.get(e).promise;throw new i("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e})}return this._layerLayerViewInfoMap.get(e).promise}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(this.get(e),this.get(r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_populateLayerViewsOwners(e,r,i){if(!e||!r)return void(r&&r.removeAll());let t=0;for(const s of e){const e=this._layerLayerViewInfoMap.get(s);if(!e||!e.layerView)continue;const a=e.layerView;a.layer=s,a.parent=i,r.getItemAt(t)!==a&&r.splice(t,0,a),s.layers&&this._populateLayerViewsOwners(s.layers,a.layerViews,a),t+=1}t<r.length&&r.splice(t,r.length)}_createLayerView(e){e.load().catch((()=>{})),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new v(e,this.view,this.layerViewImporter);r.promise.then((()=>this._refreshCollections()),(r=>{r&&(n(r)||"cancelled:layerview-create"===r.name)||t.getLogger(this.declaredClass).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this._refreshCollections()})),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([m()],V.prototype,"_workPromise",void 0),e([m({readOnly:!0})],V.prototype,"_watchUpdatingTracking",void 0),e([m({readOnly:!0})],V.prototype,"_layersToLayerViews",null),e([m({readOnly:!0})],V.prototype,"_rootCollectionNames",null),e([m()],V.prototype,"layerViewImporter",void 0),e([m()],V.prototype,"supportsGround",void 0),e([m({readOnly:!0})],V.prototype,"updating",null),e([m({readOnly:!0})],V.prototype,"updatingRemaining",null),e([m({constructOnly:!0})],V.prototype,"view",void 0),V=e([f("esri.views.LayerViewManager")],V);const L=V;function M(e){return"createLayerView"in e&&null!=e.createLayerView}export{L as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import r from"../core/Accessor.js";import i from"../core/Error.js";import t from"../core/Logger.js";import{someMap as s}from"../core/MapUtils.js";import{removeMaybe as a}from"../core/maybe.js";import{createResolver as o,createAbortError as l,isAbortError as n,onAbort as y,throwIfAborted as h}from"../core/promiseUtils.js";import{on as c,watch as w,syncAndInitial as p}from"../core/reactiveUtils.js";import{schedule as d}from"../core/scheduling.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as f}from"../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as u}from"../core/support/WatchUpdatingTracking.js";import{destroyMap as _}from"../support/collectionUtils.js";function g(e){return"tryRecycleWith"in e}class v{constructor(e,r,t){this.layer=e,this.view=r,this.layerViewImporter=t,this._controller=new AbortController,this._deferred=o(),this._started=!1,this.done=!1,this.promise=this._deferred.promise,y(this._controller.signal,(()=>{const r=new i("cancelled:layerview-create","layerview creation cancelled",{layer:e});this._deferred.reject(r)}))}tryRecycle(e){if(!this.done||!this.layerView||!g(this.layerView))return null;const r=this.layer.type,i=this._controller.signal;for(let t=0;t<e.length;t++){const s=e[t];if(s.type!==r)continue;const a=this.layerView.tryRecycleWith(s,{signal:i});if(a){e.splice(t,1),this.layer=s;const r=this.layerView,i=r.view;return this.promise=Promise.race([a.then((()=>(h(this._controller.signal),s.emit("layerview-destroy",{view:i,layerView:r}),i.emit("layerview-destroy",{view:i,layerView:r}),s.emit("layerview-create",{view:i,layerView:r}),i.emit("layerview-create",{view:i,layerView:r}),r))),new Promise(((e,r)=>y(this._controller.signal,(()=>r(l())))))]),this.promise}}return null}destroy(){this._controller.abort();const{layerView:e}=this;if(e){const{layer:r,view:i}=this;r.emit("layerview-destroy",{view:i,layerView:e}),i.emit("layerview-destroy",{layer:r,layerView:e})}this.done=!0,this.layer=null,this.layerView=null,this.view=null,this.layerViewImporter=null,this._map=null}async start(){if(this._started)return;this._started=!0;const{_controller:{signal:e},layer:r,view:t}=this;this._map=t.map;try{let o,l;if(await r.load({signal:e}),"prefetchResources"in r&&await(r.prefetchResources?.({signal:e})),M(r))o=await r.createLayerView(t,{signal:e});else{if(!this.layerViewImporter.hasLayerViewModule(r))throw new i("layer:view-not-supported","No layerview implementation was found");const s=await this.layerViewImporter.importLayerView(r);h(e),o="default"in s?new s.default({layer:r,view:t}):new s({layer:r,view:t})}const n=()=>{l=a(l),o.destroyed||o.destroy(),o.layer=null,o.parent=null,o.view=null,this.done=!0};l=y(e,n),h(e);try{await o.when()}catch(s){throw n(),s}const c=this._map?.allLayers?.includes(r);if(!c)return n(),void this._deferred.reject(new i("view:no-layerview-for-layer","The layer has been removed from the map",{layer:r}));this.layerView=o,r.emit("layerview-create",{view:t,layerView:o}),t.emit("layerview-create",{layer:r,layerView:o}),this.done=!0,this._deferred.resolve(o)}catch(s){r.emit("layerview-create-error",{view:t,error:s}),t.emit("layerview-create-error",{layer:r,error:s}),this.done=!0,this._deferred.reject(new i("layerview:create-error","layerview creation failed",{layer:r,error:s}))}}}let V=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new u,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=o(),this._workPromise.promise.catch((()=>{}))),this.removeHandles("reschedule"),this.addHandles(d(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{if(this.destroyed)return;const e=this.view.map;if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,i=[],t=this.view.ready,s=e=>{if(null!=e)for(const a of e)if(a){r.add(a);const e=this._layerLayerViewInfoMap.get(a);e&&t?e.start():e||this._recyclingInfoMap.has(a)||i.push(a),"layers"in a&&a.layers&&s(a.layers)}};for(const o of this._rootCollectionNames)s(this.get(o));for(const[o,l]of this._layerLayerViewInfoMap)if(!r.has(o)){this._layerLayerViewInfoMap.delete(l.layer);const e=l.tryRecycle(i);e?(this._recyclingInfoMap.set(l.layer,l),e.then((()=>{this._recyclingInfoMap.delete(l.layer),this._layerLayerViewInfoMap.set(l.layer,l),this._reschedule()})).catch((()=>{this._recyclingInfoMap.delete(l.layer),l.destroy(),this._reschedule()}))):l.destroy()}for(const[o,l]of this._recyclingInfoMap)r.has(o)||(this._recyclingInfoMap.delete(l.layer),l.destroy());for(const o of i)this._createLayerView(o);this._refreshCollections();const a=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.referenceLayers,e?.layers].filter((e=>!!e));r.forEach((e=>"layers"in e&&a.push(e.layers))),this.addHandles(a.map((e=>this._watchUpdatingTracking.addOnCollectionChange((()=>e),this._reschedule))),"collection-change"),this._workPromise.resolve(),this._workPromise=null}}initialize(){this.own([c((()=>this.view?.map?.allLayers),"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),w((()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]}),(()=>this._reschedule()),p)]),this._preloadLayerViewModules(),this._reschedule()}destroy(){this.clear(),_(this._recyclingInfoMap),_(this._layerLayerViewInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(l()),this._workPromise=null)}get _layersToLayerViews(){const e=[["view.map.basemap.baseLayers","view.basemapView.baseLayerViews"],["view.map.layers","view.layerViews"],["view.map.basemap.referenceLayers","view.basemapView.referenceLayerViews"]];return this.supportsGround&&e.push(["view.map.ground.layers","view.groundView.layerViews"]),new Map(e)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||s(this._layerLayerViewInfoMap,(e=>!e.done))}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){this.destroyed||(_(this._layerLayerViewInfoMap),this._refreshCollections())}async whenLayerView(e){if(await this._reschedule(),!this._layerLayerViewInfoMap.has(e)){if(this._recyclingInfoMap.has(e))return this._recyclingInfoMap.get(e).promise;throw new i("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e})}return this._layerLayerViewInfoMap.get(e).promise}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(this.get(e),this.get(r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_populateLayerViewsOwners(e,r,i){if(!e||!r)return void(r&&r.removeAll());let t=0;for(const s of e){const e=this._layerLayerViewInfoMap.get(s);if(!e||!e.layerView)continue;const a=e.layerView;a.layer=s,a.parent=i,r.getItemAt(t)!==a&&r.splice(t,0,a),s.layers&&this._populateLayerViewsOwners(s.layers,a.layerViews,a),t+=1}t<r.length&&r.splice(t,r.length)}_createLayerView(e){e.load().catch((()=>{})),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new v(e,this.view,this.layerViewImporter);r.promise.then((()=>this._refreshCollections()),(r=>{r&&(n(r)||"cancelled:layerview-create"===r.name)||t.getLogger(this.declaredClass).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this._refreshCollections()})),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([m()],V.prototype,"_workPromise",void 0),e([m({readOnly:!0})],V.prototype,"_watchUpdatingTracking",void 0),e([m({readOnly:!0})],V.prototype,"_layersToLayerViews",null),e([m({readOnly:!0})],V.prototype,"_rootCollectionNames",null),e([m()],V.prototype,"layerViewImporter",void 0),e([m()],V.prototype,"supportsGround",void 0),e([m({readOnly:!0})],V.prototype,"updating",null),e([m({readOnly:!0})],V.prototype,"updatingRemaining",null),e([m({constructOnly:!0})],V.prototype,"view",void 0),V=e([f("esri.views.LayerViewManager")],V);const L=V;function M(e){return"createLayerView"in e&&null!=e.createLayerView}export{L 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.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{createTask as p}from"../core/asyncUtils.js";import{deprecated as t}from"../core/deprecate.js";import s from"../core/Error.js";import i from"../core/Logger.js";import{eachAlwaysValues as o,throwIfAborted as r}from"../core/promiseUtils.js";import{watch as a,initial as u,whenOnce as n}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{ViewEventPriorities as h}from"./input/InputManager.js";function d(e){return null!=e&&"open"in e&&"declaredClass"in e}const y=y=>{let w=class extends y{constructor(){super(...arguments),this._popupSetupTask=null,this.popup={},this.popupEnabled=!0}initialize(){this.addHandles([a((()=>[this.ui,this.popup]),(([e,p],t)=>{const s="popup",i="manual";if(t){const[e,p]=t;e&&d(p)&&(p.view=null,e.remove(p,s))}e&&d(p)&&(p.view=this,e.add(p,{key:s,position:i}))}),u),this.on("click",(e=>{this.popup&&this.popupEnabled&&("mouse"!==e.pointerType||0===e.button)&&(d(this.popup)||!1!==this.popup?.autoOpenEnabled)&&(d(this.popup)?this.popup.viewModel.handleViewClick(e):e.async((()=>this.setupPopup())).then((()=>{d(this.popup)&&!this.destroyed&&this.ready&&this.popupEnabled&&this.popup.viewModel.handleViewClick(e)}),(()=>{})))}),h.WIDGET)]),n((()=>this.ready&&this.popupEnabled&&!this.updating)).then((()=>{import("../widgets/Popup.js")}))}destroy(){this.destroyed||this.closePopup()}async openPopup(e){d(this.popup)&&this.popup.open(e);try{if(await this.setupPopup(),!this.popup)return void i.getLogger(this.declaredClass).error(new s("view:null-popup","Popup is null and can't be opened"));this.popup.open(e)}catch{}}closePopup(){this._popupSetupTask?.abort(),d(this.popup)&&this.popup.close()}async fetchPopupFeatures(e,p){await this.when();const{location:t,queryArea:s,layerViewsAndGraphics:i,clientOnlyGraphics:r}=await this._prepareFetchPopupFeatures(e,p),a=Promise.resolve(r),u=this._queryLayerPopupFeatures(s,i,p),n=u.map((e=>e.promise));return{location:t,clientOnlyGraphics:r,allGraphicsPromise:o([a,...n]).then((e=>Array.from(new Set(e.flat())))),promisesPerLayerView:u}}async setupPopup(){if(this._popupSetupTask?.abort(),this.popup&&!d(this.popup))return this._popupSetupTask=p((async e=>{const{default:p}=await import("../widgets/Popup.js");if(r(e),!this.popup||d(this.popup))return;const t=this.popup;delete t.open,delete t.close,this.popup=new p(t)})),this._popupSetupTask.promise}_queryLayerPopupFeatures(e,p,t){return p.map((({layerView:p,graphics:s})=>{const i={clientGraphics:s,event:null!=t?t.event:void 0,signal:null!=t?t.signal:void 0,defaultPopupTemplateEnabled:null!=t&&!!t.defaultPopupTemplateEnabled},o=p.fetchPopupFeatures(e,i);return{layerView:p,promise:o}}))}_isValidPopupGraphic(e,p){return e&&!!e.getEffectivePopupTemplate(null!=p&&p.defaultPopupTemplateEnabled)}async _prepareFetchPopupFeatures(e,p){const{clientGraphics:t,queryArea:s,location:i}=await this._popupHitTestGraphics(e,p),o=this._getFetchPopupLayerViews(),{layerViewsAndGraphics:r,clientOnlyGraphics:a}=this._graphicsPerFetchPopupLayerView(t,o);return{clientOnlyGraphics:a,layerViewsAndGraphics:r,queryArea:s,location:i}}async _popupHitTestGraphics(e,p){const t=await this.popupHitTest(e),s=t.results,i=t.mapPoint,o=s.filter((e=>"graphic"===e.type&&this._isValidPopupGraphic(e.graphic,p))),r=o.length?o[0].mapPoint:null;return{clientGraphics:o.map((e=>e.graphic)),queryArea:i,location:i||r}}_getFetchPopupLayerViews(){const e=[];return this.allLayerViews.forEach((p=>{this._isValidPopupLayerView(p)&&e.push(p)})),null!=this.graphicsView&&this._isValidPopupLayerView(this.graphicsView)&&e.push(this.graphicsView),e.reverse()}_isValidPopupLayerView(e){return null!=e&&(!("layer"in e)||!e.suspended)&&"fetchPopupFeatures"in e}_graphicsPerFetchPopupLayerView(e,p){const t=[],s=new Map,i=p.map((e=>{const p=[];return"layer"in e?s.set(e.layer,p):s.set(e.graphics,p),{layerView:e,graphics:p}}));for(const o of e){const e=s.get(o.layer)||s.get(o.sourceLayer)||null;e?e.push(o):t.push(o)}return{layerViewsAndGraphics:i,clientOnlyGraphics:t}}};return e([l({cast(e){return!e||d(e)||"object"==typeof e&&(e.open=e=>(t(i.getLogger(this.declaredClass),"view.popup is no longer created by default. view.popup.open() will stop working when the popup isn't created",{replacement:"Use view.openPopup() instead.",version:"4.27"}),this.openPopup(e)),e.close=()=>(t(i.getLogger(this.declaredClass),"view.popup is no longer created by default. view.popup.close() will stop working when the popup isn't created",{replacement:"Use view.closePopup() instead.",version:"4.27"}),this.closePopup())),e}})],w.prototype,"popup",void 0),e([l()],w.prototype,"popupEnabled",void 0),w=e([c("esri.views.PopupView")],w),w};export{y as PopupView};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{createTask as p}from"../core/asyncUtils.js";import{deprecated as t}from"../core/deprecate.js";import s from"../core/Error.js";import i from"../core/Logger.js";import{eachAlwaysValues as o,throwIfAborted as r}from"../core/promiseUtils.js";import{watch as a,initial as u,whenOnce as n}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{ViewEventPriorities as h}from"./input/InputManager.js";function d(e){return null!=e&&"open"in e&&"declaredClass"in e}const y=y=>{let w=class extends y{constructor(){super(...arguments),this._popupSetupTask=null,this.popup={},this.popupEnabled=!0}initialize(){this.addHandles([a((()=>[this.ui,this.popup]),(([e,p],t)=>{const s="popup",i="manual";if(t){const[e,p]=t;e&&d(p)&&(p.view=null,e.remove(p,s))}e&&d(p)&&(p.view=this,e.add(p,{key:s,position:i}))}),u),this.on("click",(e=>{this.popup&&this.popupEnabled&&("mouse"!==e.pointerType||0===e.button)&&(d(this.popup)||!1!==this.popup?.autoOpenEnabled)&&(d(this.popup)?this.popup.viewModel.handleViewClick(e):e.async((async()=>{await this.setupPopup(),d(this.popup)&&!this.destroyed&&this.ready&&this.popupEnabled&&this.popup.viewModel.handleViewClick(e)})))}),h.WIDGET)]),n((()=>this.ready&&this.popupEnabled&&!this.updating)).then((()=>{import("../widgets/Popup.js")}))}destroy(){this.destroyed||this.closePopup()}async openPopup(e){d(this.popup)&&this.popup.open(e);try{if(await this.setupPopup(),!this.popup)return void i.getLogger(this.declaredClass).error(new s("view:null-popup","Popup is null and can't be opened"));this.popup.open(e)}catch{}}closePopup(){this._popupSetupTask?.abort(),d(this.popup)&&this.popup.close()}async fetchPopupFeatures(e,p){await this.when();const{location:t,queryArea:s,layerViewsAndGraphics:i,clientOnlyGraphics:r}=await this._prepareFetchPopupFeatures(e,p),a=Promise.resolve(r),u=this._queryLayerPopupFeatures(s,i,p),n=u.map((e=>e.promise));return{location:t,clientOnlyGraphics:r,allGraphicsPromise:o([a,...n]).then((e=>Array.from(new Set(e.flat())))),promisesPerLayerView:u}}async setupPopup(){if(this._popupSetupTask?.abort(),this.popup&&!d(this.popup))return this._popupSetupTask=p((async e=>{const{default:p}=await import("../widgets/Popup.js");if(r(e),!this.popup||d(this.popup))return;const t=this.popup;delete t.open,delete t.close,this.popup=new p(t)})),this._popupSetupTask.promise}_queryLayerPopupFeatures(e,p,t){return p.map((({layerView:p,graphics:s})=>{const i={clientGraphics:s,event:null!=t?t.event:void 0,signal:null!=t?t.signal:void 0,defaultPopupTemplateEnabled:null!=t&&!!t.defaultPopupTemplateEnabled},o=p.fetchPopupFeatures(e,i);return{layerView:p,promise:o}}))}_isValidPopupGraphic(e,p){return e&&!!e.getEffectivePopupTemplate(null!=p&&p.defaultPopupTemplateEnabled)}async _prepareFetchPopupFeatures(e,p){const{clientGraphics:t,queryArea:s,location:i}=await this._popupHitTestGraphics(e,p),o=this._getFetchPopupLayerViews(),{layerViewsAndGraphics:r,clientOnlyGraphics:a}=this._graphicsPerFetchPopupLayerView(t,o);return{clientOnlyGraphics:a,layerViewsAndGraphics:r,queryArea:s,location:i}}async _popupHitTestGraphics(e,p){const t=await this.popupHitTest(e),s=t.results,i=t.mapPoint,o=s.filter((e=>"graphic"===e.type&&this._isValidPopupGraphic(e.graphic,p))),r=o.length?o[0].mapPoint:null;return{clientGraphics:o.map((e=>e.graphic)),queryArea:i,location:i||r}}_getFetchPopupLayerViews(){const e=[];return this.allLayerViews.forEach((p=>{this._isValidPopupLayerView(p)&&e.push(p)})),null!=this.graphicsView&&this._isValidPopupLayerView(this.graphicsView)&&e.push(this.graphicsView),e.reverse()}_isValidPopupLayerView(e){return null!=e&&(!("layer"in e)||!e.suspended)&&"fetchPopupFeatures"in e}_graphicsPerFetchPopupLayerView(e,p){const t=[],s=new Map,i=p.map((e=>{const p=[];return"layer"in e?s.set(e.layer,p):s.set(e.graphics,p),{layerView:e,graphics:p}}));for(const o of e){const e=s.get(o.layer)||s.get(o.sourceLayer)||null;e?e.push(o):t.push(o)}return{layerViewsAndGraphics:i,clientOnlyGraphics:t}}};return e([l({cast(e){return!e||d(e)||"object"==typeof e&&(e.open=e=>(t(i.getLogger(this.declaredClass),"view.popup is no longer created by default. view.popup.open() will stop working when the popup isn't created",{replacement:"Use view.openPopup() instead.",version:"4.27"}),this.openPopup(e)),e.close=()=>(t(i.getLogger(this.declaredClass),"view.popup is no longer created by default. view.popup.close() will stop working when the popup isn't created",{replacement:"Use view.closePopup() instead.",version:"4.27"}),this.closePopup())),e}})],w.prototype,"popup",void 0),e([l()],w.prototype,"popupEnabled",void 0),w=e([c("esri.views.PopupView")],w),w};export{y as PopupView};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Camera.js";import"../geometry.js";import i from"../Graphic.js";import r from"../Viewpoint.js";import s from"../core/Collection.js";import{byId as n}from"../core/domUtils.js";import a from"../core/Error.js";import{on as o}from"../core/events.js";import{handlesGroup as l,makeHandle as p}from"../core/handleUtils.js";import has from"../core/has.js";import{isIterable as h}from"../core/iteratorUtils.js";import d from"../core/Logger.js";import{destroyMaybe as c}from"../core/maybe.js";import{ObservableChangesType as u}from"../core/ObservableChangesType.js";import{throwIfAborted as g}from"../core/promiseUtils.js";import{on as m,watch as y,initial as f,syncAndInitial as w,whenOnce as v,sync as _}from"../core/reactiveUtils.js";import{setFrameDuration as b}from"../core/scheduling.js";import{screenPointObjectToArray as M,createScreenPoint as S,createScreenPointArray as C}from"../core/screenUtils.js";import{initialize as R}from"../core/workers/workers.js";import{property as V}from"../core/accessorSupport/decorators/property.js";import{cast as x}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import{subclass as T}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as O,ensureClass as j}from"../core/accessorSupport/ensureType.js";import{c as E}from"../chunks/vec3f64.js";import{owningCollectionProperty as I}from"../core/support/OwningCollection.js";import L from"../geometry/HeightModelInfo.js";import{projectPointToVector as P,projectVectorToVector as H,canProjectWithoutEngine as A,project as G,projectBoundingRect as U}from"../geometry/projection.js";import{create as W,toExtent as D}from"../geometry/support/aaBoundingRect.js";import{B as F,c as k}from"../chunks/boundedPlane.js";import{renderSRFromViewSR as q}from"../geometry/support/coordinateSystem.js";import{getResolutionForScale as z}from"../geometry/support/scaleUtils.js";import{fallbackObjectIDAttribute as B}from"../layers/LayerConstants.js";import{isImageryTileLayer as N,isTiledLayer as Q,isVoxelLayer as $}from"../layers/support/layerUtils.js";import{AnalysesCollection as X}from"../support/AnalysesCollection.js";import{BreakpointsOwner as Y}from"./BreakpointsOwner.js";import{DOMContainer as Z}from"./DOMContainer.js";import J from"./GroundView.js";import{PopupView as K}from"./PopupView.js";import ee from"./View.js";import te from"./ViewAnimation.js";import{ViewingMode as ie,stringFromViewingMode as re,viewingModeFromString as se}from"./ViewingMode.js";import{layerView3DImporter as ne}from"./3d/layerViewModuleImportUtils.js";import ae from"./3d/analysis/AnalysisViewManager3D.js";import{Constraints as oe}from"./3d/constraints/Constraints.js";import le from"./3d/environment/SceneViewEnvironment.js";import{SceneViewEnvironmentManager as pe}from"./3d/environment/SceneViewEnvironmentManager.js";import he from"./3d/input/SceneInputManager.js";import{GraphicsDeconflictor as de}from"./3d/layers/graphics/GraphicsDeconflictor.js";import{Labeler as ce}from"./3d/layers/graphics/Labeler.js";import{FeatureTileTree3D as ue}from"./3d/layers/support/FeatureTileTree3D.js";import ge from"./3d/state/ViewState.js";import{ViewStateManager as me}from"./3d/state/ViewStateManager.js";import{SceneIntersectionHelper as ye}from"./3d/state/helpers/SceneIntersectionHelper.js";import{CombinedElevationProvider as fe}from"./3d/support/CombinedElevationProvider.js";import we from"./3d/support/debugFlags.js";import ve from"./3d/support/DisplayQualityProfile.js";import{getElevationAtPoint as _e}from"./3d/support/ElevationProvider.js";import be from"./3d/support/HighlightOptions.js";import{MapCoordsHelper as Me}from"./3d/support/MapCoordsHelper.js";import{PropertiesPool as Se}from"./3d/support/PropertiesPool.js";import Ce from"./3d/support/QualitySettings.js";import{RenderCoordsHelper as Re}from"./3d/support/RenderCoordsHelper.js";import{newResourceController as Ve}from"./3d/support/ResourceController.js";import xe from"./3d/support/SceneViewPerformanceInfo.js";import{SharedSymbolResources as Te}from"./3d/support/SharedSymbolResources.js";import{PointsOfInterest as Oe}from"./3d/support/pointsOfInterest/PointsOfInterest.js";import je from"./3d/terrain/TerrainSurface.js";import{isSurfaceLayerView as Ee,getTiledLayerInfo as Ie,checkIfTileInfoSupportedForView as Le}from"./3d/terrain/terrainUtils.js";import{Stage as Pe}from"./3d/webgl-engine/Stage.js";import{newIntersector as He,DEFAULT_TOLERANCE as Ae}from"./3d/webgl-engine/lib/Intersector.js";import{StoreResults as Ge,IntersectorType as Ue}from"./3d/webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as We}from"./3d/webgl-engine/lib/intersectorUtils.js";import{toHit as De,toOwner as Fe}from"./3d/webgl-engine/lib/intersectorUtilsConversions.js";import{TERRAIN_ID as ke}from"./3d/webgl-engine/lib/verticalOffsetUtils.js";import{hitTestSelectSimilarDistance as qe}from"./support/hitTestSelectUtils.js";import{occludeesSupported as ze}from"./support/layerViewUtils.js";import{encode as Be,encodeData as Ne,toRenderSettings as Qe,screenshotSuperSampleSettings as $e}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as Xe,createScreenPointFromSupportedEvent as Ye}from"./support/screenUtils.js";import{isSpatialReferenceSupported as Ze}from"./support/spatialReferenceSupport.js";import{check as Je}from"./support/WebGLRequirements.js";import Ke from"./ui/DefaultUI.js";import et from"./ui/3d/DefaultUI3D.js";import tt from"../webscene/Environment.js";import it from"../geometry/Extent.js";import rt from"../geometry/SpatialReference.js";import st from"../geometry/Point.js";let nt=class extends(Y(K(Z(ee)))){constructor(e){super(e),this._userClippingArea=null,this._clippingArea=null,this._initialDefaultSpatialReference=null,this._defaults={},this._externallySet={environment:!1},this._createGraphicsViewController=null,this._resolveWhenReady=[],this._propertiesPool=new Se({slicePlane:F},this),this._resourceController=Ve(this),this._defaultToMapOptions={include:new Set},this._defaultHitTestOptions={exclude:new Set},this.deconflictor=new de({view:this}),this.labeler=new ce({view:this,deconflictor:this.deconflictor.labels}),this.sharedSymbolResources=null,this.analyses=new X,this.basemapTerrain=null,this.elevationProvider=null,this.canvas=null,this.constraints=new oe,this.environmentManager=new pe,this.floors=new s,this.fullOpacity=1,this.graphicsView=null,this.analysisViewManager=new ae({view:this}),this.groundView=null,this.map=null,this.screenSizePerspectiveEnabled=!0,this.state=new ge,this.spatialReference=null,this.alphaCompositingEnabled=!1,this.preserveDrawingBufferEnabled=!1,this.supersampleScreenshotsEnabled=!0,this.type="3d",this.ui=new et,this._numUpdating=0,this._lastUpdateTime=0,this.updatingProgress=.5,this.highlightOptions=new be,this.voxelWasm=null,this.voxelWasmPromise=null,R(),e&&e.environment||(this._defaults.environment=new le,this.environment=this._defaults.environment);const t=(e=null)=>{null!=e&&e.type===u.MOVE||(this._updatingChanged(),this.map&&this.map.allLayers.forEach((async e=>{try{await e.when()}catch{}this._updatingChanged()})))};this.addHandles([m((()=>this.map?.allLayers),"after-changes",(e=>t(e)),{onListenerAdd:()=>t(),onListenerRemove:()=>t(),sync:!0}),this.allLayerViews.on("after-changes",(e=>this._updateUpdatingMonitors(e))),y((()=>this.map),(e=>{e&&"load"in e&&e.load&&e.load().catch((()=>{}))}))]),this.inputManager=new he({view:this}),this.stateManager=new me({view:this})}initialize(){this.groundView=new J({view:this}),this._updateUpdatingMonitors();const e=()=>this._updateDefaultToMapOptions();this.addHandles(m((()=>this.map?.allLayers),"after-changes",e,{onListenerAdd:e,onListenerRemove:e})),this.updatingHandles.add((()=>this.qualitySettings.memoryLimit),(e=>{this.resourceController&&(this.resourceController.memoryController.maxMemory=e)}),f),this.updatingHandles.add((()=>this.qualitySettings.additionalCacheMemory),(e=>{this.resourceController&&(this.resourceController.memoryController.additionalCacheMemory=e)}),f),this.updatingHandles.add((()=>this.qualitySettings.frameRate??0),(e=>b(e>0?1e3/Math.ceil(e):0)),f),this.updatingHandles.add((()=>this.map?.ground),e,w),this.updatingHandles.add((()=>this.map?.ground?.opacity),(()=>this._updateDefaultHitTestOptions()),w),this.addHandles(y((()=>this.spatialReference),(()=>this.notifyChange("clippingArea")),_))}destroy(){this.destroyed||(this.updatingHandles.removeAll(),this.removeAllHandles(),this.invalidate(),this.activeTool=null,this.layerViewManager.clear(),this._exitSurface(),this._disposeGraphicsView(),this.sharedSymbolResources=c(this.sharedSymbolResources),this._set("labeler",c(this.labeler)),this._set("deconflictor",c(this.deconflictor)),this._resourceController=c(this._resourceController),this._set("stateManager",c(this.stateManager)),this._set("inputManager",c(this.inputManager)),this.state.destroy(),this._propertiesPool.destroy(),this.removeHandles("updatingMonitors"),this._set("environmentManager",c(this.environmentManager)),this.groundView=c(this.groundView),this._exitBasemapTerrain(),this._stage?.destroy(),this.removeAllHandles(),this.updatingHandles.removeAll(),this.handles.removeAll())}get renderSpatialReference(){return this.renderCoordsHelper&&this.renderCoordsHelper.spatialReference}get basemapSpatialReference(){return this.basemapTerrain?.spatialReference}get animation(){return this.state?.animation}get camera(){return this.stateManager?.camera}set camera(e){this.stateManager&&(this.stateManager.camera=e)}get contentCamera(){return this.stateManager?.contentCamera}set contentCamera(e){this.stateManager&&(this.stateManager.contentCamera=e)}installContentCameraReset(e={sticky:!1}){return this.stateManager.installContentCameraReset(e)}get center(){return this.stateManager?.center}set center(e){this.stateManager&&(this.stateManager.center=e)}get clippingArea(){if("global"===this.viewingMode)return null;let e=this._userClippingArea||("clippingArea"in this.map?this.map?.clippingArea:void 0);return!this._userClippingArea&&!this.get("map.clippingEnabled")||null==e?(this._clippingArea=null,null):e instanceof it?this.spatialReference&&(e=lt(e,this.spatialReference),null==e)?(d.getLogger(this.declaredClass).error("#clippingArea","setting clippingArea with incompatible SpatialReference"),this._clippingArea):(e=e.clone(),null==e.intersection(this._groundAndLayersExtent)&&(e.xmin=e.xmax,e.ymin=e.ymax),e.zmin=void 0,e.zmax=void 0,e.equals(this._clippingArea)||(this._clippingArea=e),this._clippingArea):(d.getLogger(this.declaredClass).error("#clippingArea","only clippingArea geometries of type Extent are supported"),this._clippingArea)}set clippingArea(e){this.ready&&"global"===this.viewingMode&&null!=e?d.getLogger(this.declaredClass).error("#clippingArea=","Clipping area is only supported in local viewingMode"):this._userClippingArea=e}get renderDataExtent(){if(this.state.viewingMode===ie.Global)return null;const e=this.renderSpatialReference,t=this.dataExtent;return null==t||null==e||t.spatialReference.equals(e)?t:lt(t,e)}get dataExtent(){let e=this._groundAndLayersExtent;const t=this.spatialReference||rt.WGS84,i=lt(this.clippingArea,t);null!=i&&(e=null!=e?e.intersection(i):i);const r=this._get("dataExtent");return null!=e&&e.equals(r)?r:e}get _groundAndLayersExtent(){const e=this.spatialReference||rt.WGS84;let t;const i=i=>{const r=lt(i,e);null!=r&&(null!=t?t.union(r):t=r.clone())},r=this.basemapTerrain;if(r?.spatialReference){const e=r.groundExtent;i(new it({xmin:e[0],ymin:e[1],zmin:0,xmax:e[2],ymax:e[3],zmax:0,spatialReference:r.spatialReference}))}if(this.map){const e=e=>{null==e.fullExtent||"graphics"===e.type&&e.internal||i(e.fullExtent)};this.map.allLayers.forEach((t=>e(t)))}if(null==t)return null;t.hasZ?(t.zmin=Math.min(0,t.zmin??0),t.zmax=Math.max(0,t.zmax??0)):(t.zmin=0,t.zmax=0);const s=this._get("_groundAndLayersExtent");return t.equals(s)?s:t}set environment(e){e!==this._defaults.environment&&(this._externallySet.environment=!0),this._set("environment",e)}castEnvironment(e){return e?e instanceof le?e:e instanceof tt?null!=this.environment?this.environment.cloneWithWebsceneEnvironment(e):le.fromWebsceneEnvironment(e):O(le,e):new le}get extent(){return this.stateManager?.extent}set extent(e){this.stateManager&&(this.stateManager.extent=e)}get screenCenter(){return this.stateManager?.screenCenter}get frustum(){return this.stateManager?.frustum}get initialExtentRequired(){return this.stateManager&&!this.stateManager.hasInitialView}get _defaultsFromMapSettings(){return{required:{tileInfo:!1,heightModelInfo:!0,extent:!1}}}get interacting(){return this.navigating||(this.toolViewManager?.interacting??!1)}get stationary(){return!this.animation&&!this.resizing&&(null==this.state||this.state.stationary)}get navigating(){return this.state?.navigating??!1}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}set qualityProfile(e){ve.isValidProfile(e)&&(ve.apply(e,this.qualitySettings),this._set("qualityProfile",e))}get qualityProfile(){return this._get("qualityProfile")||ve.getDefaultProfile()}set slicePlane(e){if(null!=this._stage&&this._stage.renderer.setParameters({slicePlane:e}),null==e)return void this._set("slicePlane",null);const t=this._propertiesPool.get("slicePlane");k(e,t),this._set("slicePlane",t)}get typeSpecificPreconditionsReady(){return!!this.viewingMode}get resolution(){return null!=this.spatialReference?z(this.scale,this.spatialReference):0}get scale(){return this.stateManager?.scale}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get heightModelInfo(){const e=this.getDefaultHeightModelInfo();return null!=e?L.deriveUnitFromSR(e,this.spatialReference):null}get updating(){if(this.destroyed)return!1;let e=0,t=this.layerViewManager.updating,i=t?this.layerViewManager.updatingRemaining:0;this.allLayerViews.forEach((r=>{if(r.isFulfilled()){if(r.updating){if(t=!0,r.suspended||Ee(r))return;++i,e+=r.updatingProgress}}else++i}));for(const s of this._updatingObjects)if(null!=s&&s.updating){const t=.1;i+=t,e+=.5*t}for(const s of this._updatingObjectsWithProgress)null!=s&&s.updating&&(++i,e+=s.updatingProgress);const r=!this.stateManager.test.updatingIgnoreRenderState&&this.state.updating;if(t=!!(t||i>0||this.updatingHandles.updating||!this.ready||!this.stationary||r||this._createGraphicsViewController||this.inputManager?.hasPendingInputs||this.map?.allLayers?.some((e=>!e.isFulfilled()))),t?(this._numUpdating=Math.max(i,this._numUpdating),e+=this._numUpdating-i):this._numUpdating=0,this._numUpdating>0?e/=this._numUpdating:e=t?0:1,this._get("updatingProgress")!==e){const i=performance.now();if(e<1){const t=Math.min((i-this._lastUpdateTime)/2e3,1);e=this.updatingProgress*(1-t)+e*t}this._set("updatingProgress",e),this._lastUpdateTime=t&&e<1?i:0}return t}get _updatingObjects(){return[this.graphicsView,this.basemapView,this._resourceController,this._stage,this.featureTiles,this.pointsOfInterest,this.environmentManager,this.overlay,this._featureTreeDebugger,this.toolViewManager,this.analysisViewManager]}get _updatingObjectsWithProgress(){return[this.deconflictor,this.labeler,this.basemapTerrain]}get viewingMode(){const e=this._predeterminedViewingMode;if(null!=e)return re(e);const t=this.spatialReference;return t?null!=this.defaultsFromMap?.viewingMode&&t.equals(this.defaultsFromMap.spatialReference)?re(this.defaultsFromMap.viewingMode):Ze(t,ie.Global)?"global":"local":"global"}set viewingMode(e){this.ready?d.getLogger(this.declaredClass).error("#viewingMode","viewingMode cannot be set once view is ready"):this._overrideIfSome("viewingMode",e)}get viewpoint(){return this.stateManager?.viewpoint}set viewpoint(e){this.stateManager&&(this.stateManager.viewpoint=e)}get zoom(){return this.stateManager.zoom}set zoom(e){this.stateManager&&(this.stateManager.zoom=e)}get resourceController(){return this._resourceController}get performanceInfo(){return new xe(this)}on(e,t,i,r){const s=this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}toMap(e,t){if(!this.ready)return d.getLogger(this.declaredClass).error("#toMap()","Scene view cannot be used before it is ready"),null;const i=t?this.externalToInternalIntersectOptions(t):this._defaultToMapOptions,r=null!=i.graphics&&(null!=i.graphics.include||null!=i.graphics.exclude),s=Xe(e)?Ye(this,e):e,n=M(s);i.enableDraped=i.include&&!i.include.has(ke)||i.exclude&&i.exclude.has(ke);const a=this.sceneIntersectionHelper,o=He(this.state.viewingMode);if(o.options.selectionMode=!0,o.options.store=r?Ge.ALL:Ge.MIN,a.intersectIntersectorScreen(n,o,i),r){for(const e of o.results.all){const t=De(e,this);if(null==t)return this._intersectResultToMapPoint(e);if("graphic"!==t.type||this._testGraphicUidFilter(i.graphics,t.graphic))return this._intersectResultToMapPoint(e)}return null}return this._intersectResultToMapPoint(o.results.min)}toScreen(e){if(!this.ready)return d.getLogger(this.declaredClass).error("#toScreen()","Scene view cannot be used before it is ready"),null;const t=(null==e.z?_e(this.elevationProvider,e):null)??0;return P(e,ht,this.renderSpatialReference,t),this.state.camera.projectToScreen(ht,dt),S(dt[0],dt[1])}pixelSizeAt(e){return this.ready?e?(P(e,ht,this.renderSpatialReference),this.state.camera.computeScreenPixelSizeAt(ht)):0:(d.getLogger(this.declaredClass).error("#pixelSizeAt()","Scene view cannot be used before it is ready"),null)}overlayPixelSizeInMapUnits(e){const t=this.basemapTerrain.overlayManager;return t?t.overlayPixelSizeInMapUnits(e):1}hitTest(e,t){if(!this.ready)return d.getLogger(this.declaredClass).error("#hitTest()","Scene view cannot be used before it is ready"),null;const i=Xe(e)?Ye(this,e):e,r=C(i.x,i.y),s=t?this.externalToInternalIntersectOptions(t):this._defaultHitTestOptions;s.requiresGroundFeedback=!0,s.enableDraped=!0;const n=He(this.state.viewingMode);n.options.selectionMode=!0,n.options.store=Ge.ALL,this.sceneIntersectionHelper.intersectIntersectorScreen(r,n,s);const a=this._intersectResultsToHits(n.results.all,s.graphics),o=n.results.ground,l=Fe(o,this),p=null!=l&&"type"in l&&"integrated-mesh"===l.type?l:null,h={screenPoint:i,results:a,ground:{mapPoint:this._intersectResultToMapPoint(o),distance:We(o)?o.distanceInRenderSpace:0,layer:p}};return we.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(h.intersector=n),Promise.resolve(h)}async popupHitTest(e){const{results:t,ground:i}=await qe(this,e);let r=null;return!(0===t.length||Math.abs((t[0].distance??0)-i.distance)<1e-5)||i.layer&&"integrated-mesh"===i.layer.type||(r=i.mapPoint),{results:t,screenPoint:e,mapPoint:r}}goTo(e,t){return this.updatingHandles.addPromise(this.stateManager.goTo(e,t))}async whenAnalysisView(e){if(null==e.parent)throw new a("view:no-analysisview-for-analysis","The analysis has not been added to view.analyses",{analysis:e});switch(e.parent.type){case"line-of-sight":case"dimension":return(await this.whenLayerView(e.parent)).whenAnalysisView();default:return this.analysisViewManager.whenAnalysisView(e)}}whenLayerView(e){return super.whenLayerView(e)}async takeScreenshot(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshot(t);return Be(i,t,this._pixelFormat())}async _takeScreenshot(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshot(t);return Ne(i,this._pixelFormat())}async _takeScreenshotWithObjectAndLayerId(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshotWithOID(t);return[Ne(i[0],this._pixelFormat()),Ne(i[1],this._pixelFormat())]}_completeSettings(e){const t=Qe(e,this);return t.pixelRatio/=this.state.pixelRatio,$e(t,this.supersampleScreenshotsEnabled,this.padding)}_pixelFormat(){return{flipY:!0,premultipliedAlpha:this._stage.renderView.getAlpha()}}get test(){return{takeScreenshot:e=>this._takeScreenshot(e),takeScreenshotWithObjectAndLayerId:e=>this._takeScreenshotWithObjectAndLayerId(e)}}async takeScreenshotWithObjectAndLayerId(e){if(!has("enable-feature:objectAndLayerId-rendering"))throw new Error("has enable-feature:objectAndLayerId-rendering must be true");const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshotWithOID(t),r=Be(i[0],t,this._pixelFormat()),s=this._completeSettings(e);s.format="png";return[r,Be(i[1],s,this._pixelFormat())]}getColorToObjectAndLayerIdMapping(){if(null==this._stage.renderView.objectAndLayerIdRenderHelper)throw new Error("has enable-feature:objectAndLayerId-rendering must be true");return this._stage.renderView.objectAndLayerIdRenderHelper.getColorToObjectAndLayerIdMapping()}addUpdatingPromise(e){return this.updatingHandles.addPromise(e)}importLayerView(e){return ne.importLayerView(e)}hasLayerViewModule(e){return ne.hasLayerViewModule(e)}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map?.initialViewProperties?.spatialReference||this.defaultsFromMap?.spatialReference||this.defaultsFromMap?.ready&&this._initialDefaultSpatialReference||null}async validate(){let e=Je(this.type);const t=has("safari");if(t&&t<9&&(e=new a("sceneview:browser-not-supported","This browser is not supported by SceneView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:t})),null!=e)throw d.getLogger(this.declaredClass).warn("#validate()",e.message),e}get _predeterminedViewingMode(){const e=this._isOverridden("viewingMode")?this._get("viewingMode"):(this.map&&"initialViewProperties"in this.map?this.map.initialViewProperties?.viewingMode:null)??null;return null!=e?se(e):null}getSpatialReferenceSupport({spatialReference:e,layer:t}){const i=this._predeterminedViewingMode;if(null!=i)return this._validateSpatialReferenceForViewingMode(e,t,i)?{constraints:this._makeSpatialReferenceConstraints(e,t,i)}:null;const r=this._validateSpatialReferenceForViewingMode(e,t,ie.Local),s=this._validateSpatialReferenceForViewingMode(e,t,ie.Global);return r||s?r&&s?{constraints:this._makeSpatialReferenceConstraints(e,t,null)}:r?{constraints:this._makeSpatialReferenceConstraints(e,t,ie.Local)}:{constraints:this._makeSpatialReferenceConstraints(e,t,ie.Global)}:null}_validateSpatialReferenceForViewingMode(e,t,i){return!!Ze(e,i)&&(null==t||(!!N(t)||(!Q(t)||null!=Ie(t,e,i))&&(!$(t)||i!==ie.Global)))}_makeSpatialReferenceConstraints(e,t,i){if(null==t)return[{spatialReference:e,viewingMode:i}];const r=e.isWebMercator,s=e.isWGS84;if(N(t)&&(r||s)){return!s||i===ie.Local||null===Le(t.tileInfo,t.fullExtent,e,ie.Global)?[{spatialReference:e,viewingMode:i},{spatialReference:rt.WebMercator,viewingMode:i}]:[{spatialReference:r?rt.WGS84:rt.WebMercator,viewingMode:i}]}return Q(t)||$(t)||!r&&!s?Q(t)&&r&&i!==ie.Global?[{spatialReference:e,viewingMode:i},{spatialReference:rt.WGS84,viewingMode:ie.Local}]:[{spatialReference:e,viewingMode:i}]:[{spatialReference:e,viewingMode:i},{spatialReference:r?rt.WGS84:rt.WebMercator,viewingMode:i}]}_validateSpatialReference(e){const t=null!=this.getSpatialReferenceSupport({spatialReference:e}),i=this._predeterminedViewingMode;return t||(null!=i?d.getLogger(this.declaredClass).warnOnce(`Spatial reference defined on view not supported in ${re(i)} viewing mode.`):e.isGeographic&&d.getLogger(this.declaredClass).warnOnce("Spatial reference is geographic but not supported.")),t}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}computeMapPointFromVec3d(e,t){let i=this.spatialReference||rt.WGS84;return H(e,this.renderSpatialReference,e,i)||(i=rt.WGS84,H(e,this.renderSpatialReference,e,i)),t?(t.x=e[0],t.y=e[1],t.z=e[2],t.spatialReference=i):t=new st(e,i),t}trackGraphicState(e){if(!e.graphic)return d.getLogger(this.declaredClass).error("trackGraphicState","GraphicState.graphic must not be null or undefined to start tracking"),null;const t=this.getViewForGraphic(e.graphic);let i=null,r=!1;const s=t=>{!r&&null!=t&&"processor"in t&&"graphics-3d"===t.processor?.type&&t.processor.graphicsCore&&(i=t.processor.graphicsCore.trackGraphicState(e))};return null!=t?s(t):this.whenViewForGraphic(e.graphic,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,null!=i&&(i.remove(),i=null)}}}highlight(e){if(Array.isArray(e))return l(e.map((e=>this.highlight(e))));if(s.isCollection(e))return l(e.toArray().map((e=>this.highlight(e))));const t=this.getViewForGraphic(e);return t&&"highlight"in t?t.highlight(e):p()}maskOccludee(e){if(!e)return d.getLogger(this.declaredClass).error("maskOccludee","GraphicState.graphic must not be null or undefined to mask an occludee"),null;const t=this.getViewForGraphic(e);let i=null,r=!1;const s=t=>{!r&&null!=t&&ze(t)&&(i=t.maskOccludee(e))};return null!=t?s(t):this.whenViewForGraphic(e,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,null!=i&&(i.remove(),i=null)}}}getViewForGraphic(e){return e.layer===this.graphics?this.graphicsView:e.layer?this.allLayerViews.find((t=>t.layer===e.layer)):null}graphicChanged(e){null!=this.graphicsView&&this.graphicsView.graphicChanged(e)}async whenViewForGraphic(e,t){if(e.layer===this)return await v((()=>this.graphicsView)),this.graphicsView;if(!e.layer||!this.map)throw new a("no-view-for-graphic");return t&&t.waitForLayer&&!this.map.allLayers.includes(e.layer)?new Promise(((t,i)=>{const r=this.map.allLayers.on("change",(s=>{s.added.includes(e.layer)&&(r.remove(),this.whenLayerView(e.layer).then(t,i))}))})):this.whenLayerView(e.layer)}externalToInternalIntersectOptions(e){const t=this._externalToInternalRenderItems(e.include,pt.INCLUDE),i=this._externalToInternalRenderItems(e.exclude,pt.EXCLUDE);return{include:t.layerUids,exclude:i.layerUids,graphics:{include:t.graphicUids,exclude:i.graphicUids}}}_intersectResultToMapPoint(e,t){return e.getIntersectionPoint(ht)?(t=this.computeMapPointFromVec3d(ht,t),e.intersector===Ue.TERRAIN&&this.basemapTerrain&&(t.z=_e(this.basemapTerrain,t)??0),t):null}_intersectResultsToHits(e,t){const i=new Array;let r=null;for(let s=0;s<e.length;s++){const n=e[s],a=Fe(n,this);if(null!=a&&(a===this.map.ground||"type"in a&&"integrated-mesh"===a.type))break;const o=De(n,this);if(null==o)continue;if("graphic"===o.type){if(null==r&&s!==e.length-1&&(r=new Set),null!=r){const e=this._getGraphicFilterUid(o.graphic);if(r.has(e))continue;r.add(e)}if(!this._testGraphicUidFilter(t,o.graphic))continue}const l=this._intersectResultToMapPoint(n),p=n.distanceInRenderSpace;i.push({...o,mapPoint:l,distance:p})}return i}_getGraphicFilterUid(e){const t=e.sourceLayer,i=e.layer,r=t&&"objectIdField"in t?t:i&&"objectIdField"in i?i:t;if(r){const t=r.objectIdField??B,i=e.attributes?.[t];if(i)return`o-${r.id}-${i}`}return`u-${e.uid}`}_testGraphicUidFilter(e,t){const i=this._getGraphicFilterUid(t);return null==e||(null==e.include||e.include.has(i))&&(null==e.exclude||!e.exclude.has(i))}_externalToInternalRenderItems(e,t,r={layerUids:void 0,graphicUids:void 0}){if(!e)return r;if(e instanceof i)ot(r,this._getGraphicFilterUid(e)),t===pt.INCLUDE&&(null!=this.graphicsView&&e.layer===this?at(r,this.graphicsView.processor.layer.id):e.layer&&at(r,e.layer.uid));else if(h(e))for(const i of e)i===this.graphics&&null!=this.graphicsView?at(r,this.graphicsView.processor.layer.id):i===this.map.ground?at(r,ke):this._externalToInternalRenderItems(i,t,r);else"uid"in e&&at(r,e.uid);return r}_initBasemapTerrain(){this._set("basemapTerrain",new je({view:this})),this._set("elevationProvider",new fe({view:this})),this.elevationProvider.register("ground",this.basemapTerrain)}_exitBasemapTerrain(){this.basemapTerrain&&(this.elevationProvider.unregister(this.basemapTerrain),this.elevationProvider.destroy(),this._set("elevationProvider",null),this.basemapTerrain.destroy(),this._set("basemapTerrain",null))}_initGlobe(){this._initCoordinateSystem(),this.state.createInitialCamera(),this._initBasemapTerrain(),this._set("pointsOfInterest",new Oe({view:this})),this._set("featureTiles",new ue({renderCoordsHelper:this.renderCoordsHelper,cameraOnSurface:this.pointsOfInterest.cameraOnSurface,focus:this.pointsOfInterest.focus,tilingSchemeOwner:this.basemapTerrain,viewState:this.state,scheduler:this._resourceController.scheduler,terrain:this.basemapTerrain}));const e=()=>{const e=this.basemapTerrain?.extent;if(this.clippingArea||e)if(e&&this.basemapTerrain.spatialReference){const e=null!=this.basemapTerrain.extent&&null!=this.basemapTerrain.spatialReference?G(D(this.basemapTerrain.extent,this.basemapTerrain.spatialReference),this.spatialReference):null;null!=this.clippingArea?this.featureTiles.filterExtent=this.clippingArea.intersection(e):this.featureTiles.filterExtent=e}else this.featureTiles.filterExtent=this.clippingArea;else this.featureTiles.filterExtent=null};this.addHandles([this.updatingHandles.add((()=>we.FEATURE_TILE_TREE_SHOW_TILES),(e=>{e&&this.featureTiles&&!this._featureTreeDebugger?this.updatingHandles.addPromise(import("./3d/layers/support/FeatureTileTree3DDebugger.js")).then((({FeatureTileTree3DDebugger:e})=>{!this._featureTreeDebugger&&we.FEATURE_TILE_TREE_SHOW_TILES&&(this._featureTreeDebugger=new e({view:this}))})):e||!this._featureTreeDebugger||we.FEATURE_TILE_TREE_SHOW_TILES||(this._featureTreeDebugger.destroy(),this._featureTreeDebugger=null)}),w),this.updatingHandles.add((()=>this.clippingArea),e,w),this.updatingHandles.add((()=>this.basemapTerrain.extent),e,w)],"feature-tiles"),this.stateManager.init()}_exitGlobe(){this.state&&(this.stateManager.exit(),this.removeHandles("render-coords-helper"),this.removeHandles("feature-tiles"),this.featureTiles.destroy(),this._set("featureTiles",null),this.pointsOfInterest.destroy(),this._set("pointsOfInterest",null),this._exitBasemapTerrain(),this.state.exit(),this._exitCoordinateSystem())}_initCoordinateSystem(){if(this.spatialReference){const e=this.spatialReference;this.mapCoordsHelper&&this.mapCoordsHelper.spatialReference.equals(e)||this._set("mapCoordsHelper",new Me(this.map,e));const t=this.state.isGlobal,i=q(t,e);i!==this.renderSpatialReference&&(this._set("renderCoordsHelper",Re.create(this.state.viewingMode,i)),t||this.addHandles(y((()=>this.basemapTerrain?.extent),(e=>{const t=this.renderCoordsHelper.spatialReference;null==e||0===e[0]&&0===e[1]&&0===e[2]&&0===e[3]||!U(e,this.basemapTerrain.spatialReference,ct,t)||(this.renderCoordsHelper.extent=ct)}),_),"render-coords-helper"),this.sceneIntersectionHelper&&this.sceneIntersectionHelper.setTolerance(Ae/this.renderCoordsHelper.unitInMeters))}else this._set("mapCoordsHelper",null),this._set("renderCoordsHelper",null)}_exitCoordinateSystem(){this.mapCoordsHelper&&(this.removeHandles("render-coords-helper"),this._set("renderCoordsHelper",null),this._set("mapCoordsHelper",null))}_updatingChanged(){this.notifyChange("updating")}_updateUpdatingMonitors(e=null){null!=e&&e.type===u.MOVE||(this.removeHandles("updatingMonitors"),this.allLayerViews.forEach((e=>{e.destroyed||(this.addHandles(y((()=>[e.updating,e.updatingProgress]),(()=>this._updatingChanged()),_),"updatingMonitors"),e.when((()=>this._updatingChanged()),(()=>this._updatingChanged())))})),this._updatingChanged())}async _prepareScreenshotOverlay(){this.overlay&&await this.overlay.prepare()}_renderScreenshotOverlay(e,t){if(!this.overlay||!this.overlay.hasVisibleItems)return t;const i=e.getContext("2d");return i.putImageData(t,0,0),this.overlay.renderCanvas(e),i.getImageData(0,0,t.width,t.height)}_initStage(){const e={deactivatedWebGLExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions,alpha:this.alphaCompositingEnabled,preserveDrawingBuffer:this.preserveDrawingBufferEnabled,canvas:this.renderCanvas,screenshot:{prepareOverlay:()=>this._prepareScreenshotOverlay(),renderOverlay:(e,t)=>this._renderScreenshotOverlay(e,t)}},t=new ye(this.state.viewingMode,(e=>this._stage.layers.forAll(e)),this);this._set("sceneIntersectionHelper",t);const i=n(this.surface);this._stage=new Pe({view:this,options:e,container:i}),this._stage.renderer.setParameters({slicePlane:this.slicePlane}),this.addHandles([this.updatingHandles.add((()=>this.qualitySettings.antialiasingEnabled),(()=>this._stage.renderer.setParameters({antialiasingEnabled:this.qualitySettings.antialiasingEnabled})),f),this.updatingHandles.add((()=>this.qualitySettings.highQualityTransparency),(e=>this._stage.renderer.setParameters({highQualityTransparency:e})),f),y((()=>this.magnifier),(e=>this._stage.renderView.magnifier=e),w),this.on("pointer-move",(()=>this._stage?.renderer.resetAnimation())),o(this._stage.renderView.canvas,"webglcontextlost",(e=>this.fatalError=new a("webgl-context-lost",e.statusMessage)))],"stage");const r=()=>{this._stage.renderer.setParameters({defaultHighlightOptions:be.toEngineOptions(this.highlightOptions)})};this.addHandles(this.updatingHandles.add((()=>[this.highlightOptions.color,this.highlightOptions.haloColor,this.highlightOptions.haloOpacity,this.highlightOptions.fillOpacity,this.highlightOptions.shadowOpacity,this.highlightOptions.shadowColor,this.highlightOptions.shadowDifference]),r),"stage"),r(),this.renderCoordsHelper&&this.sceneIntersectionHelper.setTolerance(Ae/this.renderCoordsHelper.unitInMeters),this._set("canvas",this._stage.renderView.canvas)}_exitStage(){this._set("sceneIntersectionHelper",null),this._stage=c(this._stage),this.removeHandles("stage"),this._set("canvas",null)}_initSurface(e){this._exitSurface(),this.state.init(e,this.spatialReference),this._initStage(),this._initGlobe(),this.sharedSymbolResources=new Te({view:this,viewingMode:e,resourceController:this._resourceController,pointsOfInterest:this.pointsOfInterest,viewState:this.state})}_exitSurface(){this.sharedSymbolResources&&(this.sharedSymbolResources.objectResourceCache.destroy(),this.sharedSymbolResources.destroy(),this.sharedSymbolResources=null,this._exitGlobe(),this._exitStage())}_createGraphicsViewIfNeeded(){if(this.graphicsView||this._createGraphicsViewController)return;if(0===this.graphics.length)return;this.removeHandles("graphics-view"),this._createGraphicsViewController=new AbortController;const e=()=>{this._createGraphicsViewController=null,this._updatingChanged()};this._createGraphicsViewAsync(this._createGraphicsViewController.signal).then(e,e),this._updatingChanged()}async _createGraphicsViewAsync(e){const t=(await import("./3d/layers/GraphicsView3D.js")).default;g(e),await v((()=>this.basemapTerrain?.ready),e),this._set("graphicsView",new t({view:this}))}_disposeGraphicsView(){this._createGraphicsViewController&&(this._createGraphicsViewController.abort(),this._createGraphicsViewController=null),this.removeHandles("graphics-view"),null!=this.graphicsView&&(this.removeHandles(this.graphicsView.processor.layer.id),this.graphicsView.destroy(),this._set("graphicsView",null))}_startup(){const e=se(this.viewingMode);if(e===ie.Global&&(this._clippingArea=null),this._initSurface(e),this._set("ready",!0),this.addHandles(m((()=>this.graphics),"after-changes",(()=>this._createGraphicsViewIfNeeded())),"graphics-view"),this._createGraphicsViewIfNeeded(),!this._externallySet.environment){const e=this.get("map.initialViewProperties.environment");e&&(this.environment=e)}this.labeler.setup(),this.environmentManager.connectView(this),this.inputManager.connect();const t=this._resolveWhenReady;this._resolveWhenReady=[],t.forEach((e=>e(this)))}_teardown(){this._initialDefaultSpatialReference=null,this.inputManager.disconnect(),this.environmentManager.disconnectView(),this.labeler.dispose(),this._disposeGraphicsView(),this.removeHandles("graphics-view"),this._exitSurface(),this._set("ready",!1)}_updateDefaultToMapOptions(){if(this._defaultToMapOptions.include.clear(),this.map){this.map.ground&&this._defaultToMapOptions.include.add(ke);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&this._defaultToMapOptions.include.add(e.uid)}}_updateDefaultHitTestOptions(){if(this._defaultHitTestOptions.exclude.clear(),this.map){this.map.ground&&this.map.ground.opacity<1&&this._defaultHitTestOptions.exclude.add(ke);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&e.opacity<1&&this._defaultHitTestOptions.exclude.add(e.uid)}}addVoxelLayerViewToWasm(e){return null==this.voxelWasm?(null==this.voxelWasmPromise&&(this.voxelWasmPromise=import("../layers/VoxelWasmPerSceneView.js").then((e=>(this.voxelWasm=new e.default(this),this.voxelWasm)))),this.voxelWasmPromise.then((t=>t.addVoxelLayer(e)))):this.voxelWasm.addVoxelLayer(e)}removeVoxelLayerViewFromWasm(e){if(null!=this.voxelWasm){this.voxelWasm.removeVoxelLayer(e)<1&&(this.voxelWasm=null,this.voxelWasmPromise=null)}}};function at(e,t){e.layerUids||(e.layerUids=new Set),e.layerUids.add(t)}function ot(e,t){e.graphicUids||(e.graphicUids=new Set),e.graphicUids.add(t)}function lt(e,t){return null!=e&&A(e.spatialReference,t)?G(e,t):null}var pt;nt.type="3d",e([V()],nt.prototype,"_userClippingArea",void 0),e([V()],nt.prototype,"_resourceController",void 0),e([V()],nt.prototype,"_stage",void 0),e([V({readOnly:!0})],nt.prototype,"deconflictor",void 0),e([V({readOnly:!0})],nt.prototype,"labeler",void 0),e([V(I(X,"analyses"))],nt.prototype,"analyses",void 0),e([V({type:te,readOnly:!0})],nt.prototype,"animation",null),e([V({readOnly:!0})],nt.prototype,"basemapTerrain",void 0),e([V({readOnly:!0})],nt.prototype,"elevationProvider",void 0),e([V()],nt.prototype,"camera",null),e([V({type:t})],nt.prototype,"contentCamera",null),e([V({readOnly:!0})],nt.prototype,"canvas",void 0),e([V({type:st})],nt.prototype,"center",null),e([V({type:it})],nt.prototype,"clippingArea",null),e([V({type:oe})],nt.prototype,"constraints",void 0),e([V({type:it,readOnly:!0})],nt.prototype,"renderDataExtent",null),e([V({type:it,readOnly:!0})],nt.prototype,"dataExtent",null),e([V({type:it,readOnly:!0})],nt.prototype,"_groundAndLayersExtent",null),e([V({value:null,type:le})],nt.prototype,"environment",null),e([x("environment")],nt.prototype,"castEnvironment",null),e([V({readOnly:!0})],nt.prototype,"environmentManager",void 0),e([V({type:it})],nt.prototype,"extent",null),e([V()],nt.prototype,"floors",void 0),e([V()],nt.prototype,"screenCenter",null),e([V()],nt.prototype,"frustum",null),e([V({type:Number,readOnly:!0})],nt.prototype,"fullOpacity",void 0),e([V({readOnly:!0})],nt.prototype,"graphicsView",void 0),e([V({readOnly:!0})],nt.prototype,"analysisViewManager",void 0),e([V()],nt.prototype,"groundView",void 0),e([V({type:Boolean})],nt.prototype,"initialExtentRequired",null),e([V()],nt.prototype,"_defaultsFromMapSettings",null),e([V()],nt.prototype,"interacting",null),e([V()],nt.prototype,"stationary",null),e([V()],nt.prototype,"navigating",null),e([V()],nt.prototype,"map",void 0),e([V({readOnly:!0})],nt.prototype,"mapCoordsHelper",void 0),e([V()],nt.prototype,"padding",null),e([V({type:Oe,readOnly:!0})],nt.prototype,"pointsOfInterest",void 0),e([V({type:ue,readOnly:!0})],nt.prototype,"featureTiles",void 0),e([V()],nt.prototype,"_featureTreeDebugger",void 0),e([V({type:Boolean})],nt.prototype,"screenSizePerspectiveEnabled",void 0),e([V({constructOnly:!0})],nt.prototype,"deactivatedWebGLExtensions",void 0),e([V({constructOnly:!0})],nt.prototype,"debugWebGLExtensions",void 0),e([V({constructOnly:!0})],nt.prototype,"renderCanvas",void 0),e([V({constructOnly:!0})],nt.prototype,"state",void 0),e([V({readOnly:!0})],nt.prototype,"inputManager",void 0),e([V({readOnly:!0})],nt.prototype,"stateManager",void 0),e([V({type:["low","medium","high"]})],nt.prototype,"qualityProfile",null),e([V({type:Ce,get(){let e=this._get("qualitySettings");return e||(e=new Ce,ve.apply(this.qualityProfile,e)),e}})],nt.prototype,"qualitySettings",void 0),e([V()],nt.prototype,"slicePlane",null),e([V({readOnly:!0})],nt.prototype,"typeSpecificPreconditionsReady",null),e([V({readOnly:!0})],nt.prototype,"renderCoordsHelper",void 0),e([V({readOnly:!0})],nt.prototype,"sceneIntersectionHelper",void 0),e([V({type:Number,dependsOn:["scale","spatialReference"],readOnly:!0})],nt.prototype,"resolution",null),e([V({type:Number})],nt.prototype,"scale",null),e([V()],nt.prototype,"heightModelInfo",null),e([V()],nt.prototype,"spatialReference",void 0),e([V({type:Boolean,constructOnly:!0})],nt.prototype,"alphaCompositingEnabled",void 0),e([V({constructOnly:!0})],nt.prototype,"preserveDrawingBufferEnabled",void 0),e([V({type:Boolean})],nt.prototype,"supersampleScreenshotsEnabled",void 0),e([V({readOnly:!0})],nt.prototype,"type",void 0),e([V(),x((e=>e instanceof Ke?e:j(et,e)))],nt.prototype,"ui",void 0),e([V({type:Boolean,readOnly:!0,dependsOn:["graphicsView.updating","basemapView.updating","basemapTerrain.updating","layerViewManager.updating","layerViewManager.updatingRemaining","_resourceController.updating","_stage.updating","featureTiles.updating","pointsOfInterest.updating","environmentManager.updating","overlay.updating","updatingHandles.updating","featureTreeDebugger.updating","labeler.updating","deconflictor.updating","ready","stationary","inputManager.hasPendingInputs","toolViewManager.updating","analysisViewManager.updating","state.updating"]})],nt.prototype,"updating",null),e([V()],nt.prototype,"_updatingObjects",null),e([V()],nt.prototype,"_updatingObjectsWithProgress",null),e([V({type:Number,readOnly:!0,dependsOn:["updating"]})],nt.prototype,"updatingProgress",void 0),e([V({type:["global","local"]})],nt.prototype,"viewingMode",null),e([V({type:r})],nt.prototype,"viewpoint",null),e([V({type:Number})],nt.prototype,"zoom",null),e([V({type:be})],nt.prototype,"highlightOptions",void 0),nt=e([T("esri.views.SceneView")],nt),function(e){e[e.INCLUDE=0]="INCLUDE",e[e.EXCLUDE=1]="EXCLUDE"}(pt||(pt={}));const ht=E(),dt=C(),ct=W(),ut=nt;export{ut as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Camera.js";import"../geometry.js";import i from"../Graphic.js";import r from"../Viewpoint.js";import s from"../core/Collection.js";import{byId as n}from"../core/domUtils.js";import a from"../core/Error.js";import{on as o}from"../core/events.js";import{handlesGroup as l,makeHandle as p}from"../core/handleUtils.js";import has from"../core/has.js";import{isIterable as h}from"../core/iteratorUtils.js";import d from"../core/Logger.js";import{destroyMaybe as c}from"../core/maybe.js";import{ObservableChangesType as u}from"../core/ObservableChangesType.js";import{throwIfAborted as g}from"../core/promiseUtils.js";import{on as m,watch as y,initial as f,syncAndInitial as w,whenOnce as v,sync as _}from"../core/reactiveUtils.js";import{setFrameDuration as b}from"../core/scheduling.js";import{screenPointObjectToArray as M,createScreenPoint as S,createScreenPointArray as C}from"../core/screenUtils.js";import{initialize as R}from"../core/workers/workers.js";import{property as V}from"../core/accessorSupport/decorators/property.js";import{cast as x}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import{subclass as T}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as O,ensureClass as j}from"../core/accessorSupport/ensureType.js";import{c as E}from"../chunks/vec3f64.js";import{owningCollectionProperty as I}from"../core/support/OwningCollection.js";import L from"../geometry/HeightModelInfo.js";import{projectPointToVector as P,projectVectorToVector as H,canProjectWithoutEngine as A,project as G,projectBoundingRect as U}from"../geometry/projection.js";import{create as W,toExtent as D}from"../geometry/support/aaBoundingRect.js";import{B as F,c as k}from"../chunks/boundedPlane.js";import{renderSRFromViewSR as q}from"../geometry/support/coordinateSystem.js";import{getResolutionForScale as z}from"../geometry/support/scaleUtils.js";import{fallbackObjectIDAttribute as B}from"../layers/LayerConstants.js";import{isImageryTileLayer as N,isTiledLayer as Q,isVoxelLayer as $}from"../layers/support/layerUtils.js";import{AnalysesCollection as X}from"../support/AnalysesCollection.js";import{BreakpointsOwner as Y}from"./BreakpointsOwner.js";import{DOMContainer as Z}from"./DOMContainer.js";import J from"./GroundView.js";import{PopupView as K}from"./PopupView.js";import ee from"./View.js";import te from"./ViewAnimation.js";import{ViewingMode as ie,stringFromViewingMode as re,viewingModeFromString as se}from"./ViewingMode.js";import{layerView3DImporter as ne}from"./3d/layerViewModuleImportUtils.js";import ae from"./3d/analysis/AnalysisViewManager3D.js";import{Constraints as oe}from"./3d/constraints/Constraints.js";import le from"./3d/environment/SceneViewEnvironment.js";import{SceneViewEnvironmentManager as pe}from"./3d/environment/SceneViewEnvironmentManager.js";import he from"./3d/input/SceneInputManager.js";import{GraphicsDeconflictor as de}from"./3d/layers/graphics/GraphicsDeconflictor.js";import{Labeler as ce}from"./3d/layers/graphics/Labeler.js";import{FeatureTileTree3D as ue}from"./3d/layers/support/FeatureTileTree3D.js";import ge from"./3d/state/ViewState.js";import{ViewStateManager as me}from"./3d/state/ViewStateManager.js";import{SceneIntersectionHelper as ye}from"./3d/state/helpers/SceneIntersectionHelper.js";import{CombinedElevationProvider as fe}from"./3d/support/CombinedElevationProvider.js";import we from"./3d/support/debugFlags.js";import ve from"./3d/support/DisplayQualityProfile.js";import{getElevationAtPoint as _e}from"./3d/support/ElevationProvider.js";import be from"./3d/support/HighlightOptions.js";import{MapCoordsHelper as Me}from"./3d/support/MapCoordsHelper.js";import{PropertiesPool as Se}from"./3d/support/PropertiesPool.js";import Ce from"./3d/support/QualitySettings.js";import{RenderCoordsHelper as Re}from"./3d/support/RenderCoordsHelper.js";import{newResourceController as Ve}from"./3d/support/ResourceController.js";import xe from"./3d/support/SceneViewPerformanceInfo.js";import{SharedSymbolResources as Te}from"./3d/support/SharedSymbolResources.js";import{PointsOfInterest as Oe}from"./3d/support/pointsOfInterest/PointsOfInterest.js";import je from"./3d/terrain/TerrainSurface.js";import{isSurfaceLayerView as Ee,getTiledLayerInfo as Ie,checkIfTileInfoSupportedForView as Le}from"./3d/terrain/terrainUtils.js";import{Stage as Pe}from"./3d/webgl-engine/Stage.js";import{newIntersector as He,DEFAULT_TOLERANCE as Ae}from"./3d/webgl-engine/lib/Intersector.js";import{StoreResults as Ge,IntersectorType as Ue}from"./3d/webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as We}from"./3d/webgl-engine/lib/intersectorUtils.js";import{toHit as De,toOwner as Fe}from"./3d/webgl-engine/lib/intersectorUtilsConversions.js";import{TERRAIN_ID as ke}from"./3d/webgl-engine/lib/verticalOffsetUtils.js";import{hitTestSelectSimilarDistance as qe}from"./support/hitTestSelectUtils.js";import{occludeesSupported as ze}from"./support/layerViewUtils.js";import{encode as Be,encodeData as Ne,toRenderSettings as Qe,screenshotSuperSampleSettings as $e}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as Xe,createScreenPointFromSupportedEvent as Ye}from"./support/screenUtils.js";import{isSpatialReferenceSupported as Ze}from"./support/spatialReferenceSupport.js";import{check as Je}from"./support/WebGLRequirements.js";import Ke from"./ui/DefaultUI.js";import et from"./ui/3d/DefaultUI3D.js";import tt from"../webscene/Environment.js";import it from"../geometry/Extent.js";import rt from"../geometry/SpatialReference.js";import st from"../geometry/Point.js";let nt=class extends(Y(K(Z(ee)))){constructor(e){super(e),this._userClippingArea=null,this._clippingArea=null,this._initialDefaultSpatialReference=null,this._defaults={},this._externallySet={environment:!1},this._createGraphicsViewController=null,this._resolveWhenReady=[],this._propertiesPool=new Se({slicePlane:F},this),this._resourceController=Ve(this),this._defaultToMapOptions={include:new Set},this._defaultHitTestOptions={exclude:new Set},this.deconflictor=new de({view:this}),this.labeler=new ce({view:this,deconflictor:this.deconflictor.labels}),this.sharedSymbolResources=null,this.analyses=new X,this.basemapTerrain=null,this.elevationProvider=null,this.canvas=null,this.constraints=new oe,this.environmentManager=new pe,this.floors=new s,this.fullOpacity=1,this.graphicsView=null,this.analysisViewManager=new ae({view:this}),this.groundView=null,this.map=null,this.screenSizePerspectiveEnabled=!0,this.state=new ge,this.spatialReference=null,this.alphaCompositingEnabled=!1,this.preserveDrawingBufferEnabled=!1,this.supersampleScreenshotsEnabled=!0,this.type="3d",this.ui=new et,this._numUpdating=0,this._lastUpdateTime=0,this.updatingProgress=.5,this.highlightOptions=new be,this.voxelWasm=null,this.voxelWasmPromise=null,R(),e&&e.environment||(this._defaults.environment=new le,this.environment=this._defaults.environment);const t=(e=null)=>{null!=e&&e.type===u.MOVE||(this._updatingChanged(),this.map&&this.map.allLayers.forEach((async e=>{try{await e.when()}catch{}this._updatingChanged()})))};this.addHandles([m((()=>this.map?.allLayers),"after-changes",(e=>t(e)),{onListenerAdd:()=>t(),onListenerRemove:()=>t(),sync:!0}),this.allLayerViews.on("after-changes",(e=>this._updateUpdatingMonitors(e))),y((()=>this.map),(e=>{e&&"load"in e&&e.load&&e.load().catch((()=>{}))}))]),this.inputManager=new he({view:this}),this.stateManager=new me({view:this})}initialize(){this.groundView=new J({view:this}),this._updateUpdatingMonitors();const e=()=>this._updateDefaultToMapOptions();this.addHandles(m((()=>this.map?.allLayers),"after-changes",e,{onListenerAdd:e,onListenerRemove:e})),this.updatingHandles.add((()=>this.qualitySettings.memoryLimit),(e=>{this.resourceController&&(this.resourceController.memoryController.maxMemory=e)}),f),this.updatingHandles.add((()=>this.qualitySettings.additionalCacheMemory),(e=>{this.resourceController&&(this.resourceController.memoryController.additionalCacheMemory=e)}),f),this.updatingHandles.add((()=>this.qualitySettings.frameRate??0),(e=>b(e>0?1e3/Math.ceil(e):0)),f),this.updatingHandles.add((()=>this.map?.ground),e,w),this.updatingHandles.add((()=>this.map?.ground?.opacity),(()=>this._updateDefaultHitTestOptions()),w),this.addHandles(y((()=>this.spatialReference),(()=>this.notifyChange("clippingArea")),_))}destroy(){this.destroyed||(this.updatingHandles.removeAll(),this.removeAllHandles(),this.invalidate(),this.activeTool=null,this.layerViewManager.clear(),this._exitSurface(),this._disposeGraphicsView(),this.sharedSymbolResources=c(this.sharedSymbolResources),this._set("labeler",c(this.labeler)),this._set("deconflictor",c(this.deconflictor)),this._resourceController=c(this._resourceController),this._set("stateManager",c(this.stateManager)),this._set("inputManager",c(this.inputManager)),this.state.destroy(),this._propertiesPool.destroy(),this.removeHandles("updatingMonitors"),this._set("environmentManager",c(this.environmentManager)),this.groundView=c(this.groundView),this._exitBasemapTerrain(),this._stage?.destroy(),this.removeAllHandles(),this.updatingHandles.removeAll(),this.handles.removeAll())}get renderSpatialReference(){return this.renderCoordsHelper&&this.renderCoordsHelper.spatialReference}get basemapSpatialReference(){return this.basemapTerrain?.spatialReference}get animation(){return this.state?.animation}get camera(){return this.stateManager?.camera}set camera(e){this.stateManager&&(this.stateManager.camera=e)}get contentCamera(){return this.stateManager?.contentCamera}set contentCamera(e){this.stateManager&&(this.stateManager.contentCamera=e)}installContentCameraReset(e={sticky:!1}){return this.stateManager.installContentCameraReset(e)}get center(){return this.stateManager?.center}set center(e){this.stateManager&&(this.stateManager.center=e)}get clippingArea(){if("global"===this.viewingMode)return null;let e=this._userClippingArea||("clippingArea"in this.map?this.map?.clippingArea:void 0);return!this._userClippingArea&&!this.get("map.clippingEnabled")||null==e?(this._clippingArea=null,null):e instanceof it?this.spatialReference&&(e=lt(e,this.spatialReference),null==e)?(d.getLogger(this.declaredClass).error("#clippingArea","setting clippingArea with incompatible SpatialReference"),this._clippingArea):(e=e.clone(),null==e.intersection(this._groundAndLayersExtent)&&(e.xmin=e.xmax,e.ymin=e.ymax),e.zmin=void 0,e.zmax=void 0,e.equals(this._clippingArea)||(this._clippingArea=e),this._clippingArea):(d.getLogger(this.declaredClass).error("#clippingArea","only clippingArea geometries of type Extent are supported"),this._clippingArea)}set clippingArea(e){this.ready&&"global"===this.viewingMode&&null!=e?d.getLogger(this.declaredClass).error("#clippingArea=","Clipping area is only supported in local viewingMode"):this._userClippingArea=e}get renderDataExtent(){if(this.state.viewingMode===ie.Global)return null;const e=this.renderSpatialReference,t=this.dataExtent;return null==t||null==e||t.spatialReference.equals(e)?t:lt(t,e)}get dataExtent(){let e=this._groundAndLayersExtent;const t=this.spatialReference||rt.WGS84,i=lt(this.clippingArea,t);null!=i&&(e=null!=e?e.intersection(i):i);const r=this._get("dataExtent");return null!=e&&e.equals(r)?r:e}get _groundAndLayersExtent(){const e=this.spatialReference||rt.WGS84;let t;const i=i=>{const r=lt(i,e);null!=r&&(null!=t?t.union(r):t=r.clone())},r=this.basemapTerrain;if(r?.spatialReference){const e=r.groundExtent;i(new it({xmin:e[0],ymin:e[1],zmin:0,xmax:e[2],ymax:e[3],zmax:0,spatialReference:r.spatialReference}))}if(this.map){const e=e=>{null==e.fullExtent||"graphics"===e.type&&e.internal||i(e.fullExtent)};this.map.allLayers.forEach((t=>e(t)))}if(null==t)return null;t.hasZ?(t.zmin=Math.min(0,t.zmin??0),t.zmax=Math.max(0,t.zmax??0)):(t.zmin=0,t.zmax=0);const s=this._get("_groundAndLayersExtent");return t.equals(s)?s:t}set environment(e){e!==this._defaults.environment&&(this._externallySet.environment=!0),this._set("environment",e)}castEnvironment(e){return e?e instanceof le?e:e instanceof tt?null!=this.environment?this.environment.cloneWithWebsceneEnvironment(e):le.fromWebsceneEnvironment(e):O(le,e):new le}get extent(){return this.stateManager?.extent}set extent(e){this.stateManager&&(this.stateManager.extent=e)}get screenCenter(){return this.stateManager?.screenCenter}get frustum(){return this.stateManager?.frustum}get initialExtentRequired(){return this.stateManager&&!this.stateManager.hasInitialView}get _defaultsFromMapSettings(){return{required:{tileInfo:!1,heightModelInfo:!0,extent:!1}}}get interacting(){return this.navigating||(this.toolViewManager?.interacting??!1)}get stationary(){return!this.animation&&!this.resizing&&(null==this.state||this.state.stationary)}get navigating(){return this.state?.navigating??!1}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}set qualityProfile(e){ve.isValidProfile(e)&&(ve.apply(e,this.qualitySettings),this._set("qualityProfile",e))}get qualityProfile(){return this._get("qualityProfile")||ve.getDefaultProfile()}set slicePlane(e){if(null!=this._stage&&this._stage.renderer.setParameters({slicePlane:e}),null==e)return void this._set("slicePlane",null);const t=this._propertiesPool.get("slicePlane");k(e,t),this._set("slicePlane",t)}get typeSpecificPreconditionsReady(){return!!this.viewingMode}get resolution(){return null!=this.spatialReference?z(this.scale,this.spatialReference):0}get scale(){return this.stateManager?.scale}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get heightModelInfo(){const e=this.getDefaultHeightModelInfo();return null!=e?L.deriveUnitFromSR(e,this.spatialReference):null}get updating(){if(this.destroyed)return!1;let e=0,t=this.layerViewManager.updating,i=t?this.layerViewManager.updatingRemaining:0;this.allLayerViews.forEach((r=>{if(r.isFulfilled()){if(r.updating){if(t=!0,r.suspended||Ee(r))return;++i,e+=r.updatingProgress}}else++i}));for(const s of this._updatingObjects)if(null!=s&&s.updating){const t=.1;i+=t,e+=.5*t}for(const s of this._updatingObjectsWithProgress)null!=s&&s.updating&&(++i,e+=s.updatingProgress);const r=!this.stateManager.test.updatingIgnoreRenderState&&this.state.updating;if(t=!!(t||i>0||this.updatingHandles.updating||!this.ready||!this.stationary||r||this._createGraphicsViewController||this.inputManager?.updating||this.map?.allLayers?.some((e=>!e.isFulfilled()))),t?(this._numUpdating=Math.max(i,this._numUpdating),e+=this._numUpdating-i):this._numUpdating=0,this._numUpdating>0?e/=this._numUpdating:e=t?0:1,this._get("updatingProgress")!==e){const i=performance.now();if(e<1){const t=Math.min((i-this._lastUpdateTime)/2e3,1);e=this.updatingProgress*(1-t)+e*t}this._set("updatingProgress",e),this._lastUpdateTime=t&&e<1?i:0}return t}get _updatingObjects(){return[this.graphicsView,this.basemapView,this._resourceController,this._stage,this.featureTiles,this.pointsOfInterest,this.environmentManager,this.overlay,this._featureTreeDebugger,this.toolViewManager,this.analysisViewManager]}get _updatingObjectsWithProgress(){return[this.deconflictor,this.labeler,this.basemapTerrain]}get viewingMode(){const e=this._predeterminedViewingMode;if(null!=e)return re(e);const t=this.spatialReference;return t?null!=this.defaultsFromMap?.viewingMode&&t.equals(this.defaultsFromMap.spatialReference)?re(this.defaultsFromMap.viewingMode):Ze(t,ie.Global)?"global":"local":"global"}set viewingMode(e){this.ready?d.getLogger(this.declaredClass).error("#viewingMode","viewingMode cannot be set once view is ready"):this._overrideIfSome("viewingMode",e)}get viewpoint(){return this.stateManager?.viewpoint}set viewpoint(e){this.stateManager&&(this.stateManager.viewpoint=e)}get zoom(){return this.stateManager.zoom}set zoom(e){this.stateManager&&(this.stateManager.zoom=e)}get resourceController(){return this._resourceController}get performanceInfo(){return new xe(this)}on(e,t,i,r){const s=this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}toMap(e,t){if(!this.ready)return d.getLogger(this.declaredClass).error("#toMap()","Scene view cannot be used before it is ready"),null;const i=t?this.externalToInternalIntersectOptions(t):this._defaultToMapOptions,r=null!=i.graphics&&(null!=i.graphics.include||null!=i.graphics.exclude),s=Xe(e)?Ye(this,e):e,n=M(s);i.enableDraped=i.include&&!i.include.has(ke)||i.exclude&&i.exclude.has(ke);const a=this.sceneIntersectionHelper,o=He(this.state.viewingMode);if(o.options.selectionMode=!0,o.options.store=r?Ge.ALL:Ge.MIN,a.intersectIntersectorScreen(n,o,i),r){for(const e of o.results.all){const t=De(e,this);if(null==t)return this._intersectResultToMapPoint(e);if("graphic"!==t.type||this._testGraphicUidFilter(i.graphics,t.graphic))return this._intersectResultToMapPoint(e)}return null}return this._intersectResultToMapPoint(o.results.min)}toScreen(e){if(!this.ready)return d.getLogger(this.declaredClass).error("#toScreen()","Scene view cannot be used before it is ready"),null;const t=(null==e.z?_e(this.elevationProvider,e):null)??0;return P(e,ht,this.renderSpatialReference,t),this.state.camera.projectToScreen(ht,dt),S(dt[0],dt[1])}pixelSizeAt(e){return this.ready?e?(P(e,ht,this.renderSpatialReference),this.state.camera.computeScreenPixelSizeAt(ht)):0:(d.getLogger(this.declaredClass).error("#pixelSizeAt()","Scene view cannot be used before it is ready"),null)}overlayPixelSizeInMapUnits(e){const t=this.basemapTerrain.overlayManager;return t?t.overlayPixelSizeInMapUnits(e):1}hitTest(e,t){if(!this.ready)return d.getLogger(this.declaredClass).error("#hitTest()","Scene view cannot be used before it is ready"),null;const i=Xe(e)?Ye(this,e):e,r=C(i.x,i.y),s=t?this.externalToInternalIntersectOptions(t):this._defaultHitTestOptions;s.requiresGroundFeedback=!0,s.enableDraped=!0;const n=He(this.state.viewingMode);n.options.selectionMode=!0,n.options.store=Ge.ALL,this.sceneIntersectionHelper.intersectIntersectorScreen(r,n,s);const a=this._intersectResultsToHits(n.results.all,s.graphics),o=n.results.ground,l=Fe(o,this),p=null!=l&&"type"in l&&"integrated-mesh"===l.type?l:null,h={screenPoint:i,results:a,ground:{mapPoint:this._intersectResultToMapPoint(o),distance:We(o)?o.distanceInRenderSpace:0,layer:p}};return we.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(h.intersector=n),Promise.resolve(h)}async popupHitTest(e){const{results:t,ground:i}=await qe(this,e);let r=null;return!(0===t.length||Math.abs((t[0].distance??0)-i.distance)<1e-5)||i.layer&&"integrated-mesh"===i.layer.type||(r=i.mapPoint),{results:t,screenPoint:e,mapPoint:r}}goTo(e,t){return this.updatingHandles.addPromise(this.stateManager.goTo(e,t))}async whenAnalysisView(e){if(null==e.parent)throw new a("view:no-analysisview-for-analysis","The analysis has not been added to view.analyses",{analysis:e});switch(e.parent.type){case"line-of-sight":case"dimension":return(await this.whenLayerView(e.parent)).whenAnalysisView();default:return this.analysisViewManager.whenAnalysisView(e)}}whenLayerView(e){return super.whenLayerView(e)}async takeScreenshot(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshot(t);return Be(i,t,this._pixelFormat())}async _takeScreenshot(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshot(t);return Ne(i,this._pixelFormat())}async _takeScreenshotWithObjectAndLayerId(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshotWithOID(t);return[Ne(i[0],this._pixelFormat()),Ne(i[1],this._pixelFormat())]}_completeSettings(e){const t=Qe(e,this);return t.pixelRatio/=this.state.pixelRatio,$e(t,this.supersampleScreenshotsEnabled,this.padding)}_pixelFormat(){return{flipY:!0,premultipliedAlpha:this._stage.renderView.getAlpha()}}get test(){return{takeScreenshot:e=>this._takeScreenshot(e),takeScreenshotWithObjectAndLayerId:e=>this._takeScreenshotWithObjectAndLayerId(e)}}async takeScreenshotWithObjectAndLayerId(e){if(!has("enable-feature:objectAndLayerId-rendering"))throw new Error("has enable-feature:objectAndLayerId-rendering must be true");const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshotWithOID(t),r=Be(i[0],t,this._pixelFormat()),s=this._completeSettings(e);s.format="png";return[r,Be(i[1],s,this._pixelFormat())]}getColorToObjectAndLayerIdMapping(){if(null==this._stage.renderView.objectAndLayerIdRenderHelper)throw new Error("has enable-feature:objectAndLayerId-rendering must be true");return this._stage.renderView.objectAndLayerIdRenderHelper.getColorToObjectAndLayerIdMapping()}addUpdatingPromise(e){return this.updatingHandles.addPromise(e)}importLayerView(e){return ne.importLayerView(e)}hasLayerViewModule(e){return ne.hasLayerViewModule(e)}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map?.initialViewProperties?.spatialReference||this.defaultsFromMap?.spatialReference||this.defaultsFromMap?.ready&&this._initialDefaultSpatialReference||null}async validate(){let e=Je(this.type);const t=has("safari");if(t&&t<9&&(e=new a("sceneview:browser-not-supported","This browser is not supported by SceneView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:t})),null!=e)throw d.getLogger(this.declaredClass).warn("#validate()",e.message),e}get _predeterminedViewingMode(){const e=this._isOverridden("viewingMode")?this._get("viewingMode"):(this.map&&"initialViewProperties"in this.map?this.map.initialViewProperties?.viewingMode:null)??null;return null!=e?se(e):null}getSpatialReferenceSupport({spatialReference:e,layer:t}){const i=this._predeterminedViewingMode;if(null!=i)return this._validateSpatialReferenceForViewingMode(e,t,i)?{constraints:this._makeSpatialReferenceConstraints(e,t,i)}:null;const r=this._validateSpatialReferenceForViewingMode(e,t,ie.Local),s=this._validateSpatialReferenceForViewingMode(e,t,ie.Global);return r||s?r&&s?{constraints:this._makeSpatialReferenceConstraints(e,t,null)}:r?{constraints:this._makeSpatialReferenceConstraints(e,t,ie.Local)}:{constraints:this._makeSpatialReferenceConstraints(e,t,ie.Global)}:null}_validateSpatialReferenceForViewingMode(e,t,i){return!!Ze(e,i)&&(null==t||(!!N(t)||(!Q(t)||null!=Ie(t,e,i))&&(!$(t)||i!==ie.Global)))}_makeSpatialReferenceConstraints(e,t,i){if(null==t)return[{spatialReference:e,viewingMode:i}];const r=e.isWebMercator,s=e.isWGS84;if(N(t)&&(r||s)){return!s||i===ie.Local||null===Le(t.tileInfo,t.fullExtent,e,ie.Global)?[{spatialReference:e,viewingMode:i},{spatialReference:rt.WebMercator,viewingMode:i}]:[{spatialReference:r?rt.WGS84:rt.WebMercator,viewingMode:i}]}return Q(t)||$(t)||!r&&!s?Q(t)&&r&&i!==ie.Global?[{spatialReference:e,viewingMode:i},{spatialReference:rt.WGS84,viewingMode:ie.Local}]:[{spatialReference:e,viewingMode:i}]:[{spatialReference:e,viewingMode:i},{spatialReference:r?rt.WGS84:rt.WebMercator,viewingMode:i}]}_validateSpatialReference(e){const t=null!=this.getSpatialReferenceSupport({spatialReference:e}),i=this._predeterminedViewingMode;return t||(null!=i?d.getLogger(this.declaredClass).warnOnce(`Spatial reference defined on view not supported in ${re(i)} viewing mode.`):e.isGeographic&&d.getLogger(this.declaredClass).warnOnce("Spatial reference is geographic but not supported.")),t}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}computeMapPointFromVec3d(e,t){let i=this.spatialReference||rt.WGS84;return H(e,this.renderSpatialReference,e,i)||(i=rt.WGS84,H(e,this.renderSpatialReference,e,i)),t?(t.x=e[0],t.y=e[1],t.z=e[2],t.spatialReference=i):t=new st(e,i),t}trackGraphicState(e){if(!e.graphic)return d.getLogger(this.declaredClass).error("trackGraphicState","GraphicState.graphic must not be null or undefined to start tracking"),null;const t=this.getViewForGraphic(e.graphic);let i=null,r=!1;const s=t=>{!r&&null!=t&&"processor"in t&&"graphics-3d"===t.processor?.type&&t.processor.graphicsCore&&(i=t.processor.graphicsCore.trackGraphicState(e))};return null!=t?s(t):this.whenViewForGraphic(e.graphic,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,null!=i&&(i.remove(),i=null)}}}highlight(e){if(Array.isArray(e))return l(e.map((e=>this.highlight(e))));if(s.isCollection(e))return l(e.toArray().map((e=>this.highlight(e))));const t=this.getViewForGraphic(e);return t&&"highlight"in t?t.highlight(e):p()}maskOccludee(e){if(!e)return d.getLogger(this.declaredClass).error("maskOccludee","GraphicState.graphic must not be null or undefined to mask an occludee"),null;const t=this.getViewForGraphic(e);let i=null,r=!1;const s=t=>{!r&&null!=t&&ze(t)&&(i=t.maskOccludee(e))};return null!=t?s(t):this.whenViewForGraphic(e,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,null!=i&&(i.remove(),i=null)}}}getViewForGraphic(e){return e.layer===this.graphics?this.graphicsView:e.layer?this.allLayerViews.find((t=>t.layer===e.layer)):null}graphicChanged(e){null!=this.graphicsView&&this.graphicsView.graphicChanged(e)}async whenViewForGraphic(e,t){if(e.layer===this)return await v((()=>this.graphicsView)),this.graphicsView;if(!e.layer||!this.map)throw new a("no-view-for-graphic");return t&&t.waitForLayer&&!this.map.allLayers.includes(e.layer)?new Promise(((t,i)=>{const r=this.map.allLayers.on("change",(s=>{s.added.includes(e.layer)&&(r.remove(),this.whenLayerView(e.layer).then(t,i))}))})):this.whenLayerView(e.layer)}externalToInternalIntersectOptions(e){const t=this._externalToInternalRenderItems(e.include,pt.INCLUDE),i=this._externalToInternalRenderItems(e.exclude,pt.EXCLUDE);return{include:t.layerUids,exclude:i.layerUids,graphics:{include:t.graphicUids,exclude:i.graphicUids}}}_intersectResultToMapPoint(e,t){return e.getIntersectionPoint(ht)?(t=this.computeMapPointFromVec3d(ht,t),e.intersector===Ue.TERRAIN&&this.basemapTerrain&&(t.z=_e(this.basemapTerrain,t)??0),t):null}_intersectResultsToHits(e,t){const i=new Array;let r=null;for(let s=0;s<e.length;s++){const n=e[s],a=Fe(n,this);if(null!=a&&(a===this.map.ground||"type"in a&&"integrated-mesh"===a.type))break;const o=De(n,this);if(null==o)continue;if("graphic"===o.type){if(null==r&&s!==e.length-1&&(r=new Set),null!=r){const e=this._getGraphicFilterUid(o.graphic);if(r.has(e))continue;r.add(e)}if(!this._testGraphicUidFilter(t,o.graphic))continue}const l=this._intersectResultToMapPoint(n),p=n.distanceInRenderSpace;i.push({...o,mapPoint:l,distance:p})}return i}_getGraphicFilterUid(e){const t=e.sourceLayer,i=e.layer,r=t&&"objectIdField"in t?t:i&&"objectIdField"in i?i:t;if(r){const t=r.objectIdField??B,i=e.attributes?.[t];if(i)return`o-${r.id}-${i}`}return`u-${e.uid}`}_testGraphicUidFilter(e,t){const i=this._getGraphicFilterUid(t);return null==e||(null==e.include||e.include.has(i))&&(null==e.exclude||!e.exclude.has(i))}_externalToInternalRenderItems(e,t,r={layerUids:void 0,graphicUids:void 0}){if(!e)return r;if(e instanceof i)ot(r,this._getGraphicFilterUid(e)),t===pt.INCLUDE&&(null!=this.graphicsView&&e.layer===this?at(r,this.graphicsView.processor.layer.id):e.layer&&at(r,e.layer.uid));else if(h(e))for(const i of e)i===this.graphics&&null!=this.graphicsView?at(r,this.graphicsView.processor.layer.id):i===this.map.ground?at(r,ke):this._externalToInternalRenderItems(i,t,r);else"uid"in e&&at(r,e.uid);return r}_initBasemapTerrain(){this._set("basemapTerrain",new je({view:this})),this._set("elevationProvider",new fe({view:this})),this.elevationProvider.register("ground",this.basemapTerrain)}_exitBasemapTerrain(){this.basemapTerrain&&(this.elevationProvider.unregister(this.basemapTerrain),this.elevationProvider.destroy(),this._set("elevationProvider",null),this.basemapTerrain.destroy(),this._set("basemapTerrain",null))}_initGlobe(){this._initCoordinateSystem(),this.state.createInitialCamera(),this._initBasemapTerrain(),this._set("pointsOfInterest",new Oe({view:this})),this._set("featureTiles",new ue({renderCoordsHelper:this.renderCoordsHelper,cameraOnSurface:this.pointsOfInterest.cameraOnSurface,focus:this.pointsOfInterest.focus,tilingSchemeOwner:this.basemapTerrain,viewState:this.state,scheduler:this._resourceController.scheduler,terrain:this.basemapTerrain}));const e=()=>{const e=this.basemapTerrain?.extent;if(this.clippingArea||e)if(e&&this.basemapTerrain.spatialReference){const e=null!=this.basemapTerrain.extent&&null!=this.basemapTerrain.spatialReference?G(D(this.basemapTerrain.extent,this.basemapTerrain.spatialReference),this.spatialReference):null;null!=this.clippingArea?this.featureTiles.filterExtent=this.clippingArea.intersection(e):this.featureTiles.filterExtent=e}else this.featureTiles.filterExtent=this.clippingArea;else this.featureTiles.filterExtent=null};this.addHandles([this.updatingHandles.add((()=>we.FEATURE_TILE_TREE_SHOW_TILES),(e=>{e&&this.featureTiles&&!this._featureTreeDebugger?this.updatingHandles.addPromise(import("./3d/layers/support/FeatureTileTree3DDebugger.js")).then((({FeatureTileTree3DDebugger:e})=>{!this._featureTreeDebugger&&we.FEATURE_TILE_TREE_SHOW_TILES&&(this._featureTreeDebugger=new e({view:this}))})):e||!this._featureTreeDebugger||we.FEATURE_TILE_TREE_SHOW_TILES||(this._featureTreeDebugger.destroy(),this._featureTreeDebugger=null)}),w),this.updatingHandles.add((()=>this.clippingArea),e,w),this.updatingHandles.add((()=>this.basemapTerrain.extent),e,w)],"feature-tiles"),this.stateManager.init()}_exitGlobe(){this.state&&(this.stateManager.exit(),this.removeHandles("render-coords-helper"),this.removeHandles("feature-tiles"),this.featureTiles.destroy(),this._set("featureTiles",null),this.pointsOfInterest.destroy(),this._set("pointsOfInterest",null),this._exitBasemapTerrain(),this.state.exit(),this._exitCoordinateSystem())}_initCoordinateSystem(){if(this.spatialReference){const e=this.spatialReference;this.mapCoordsHelper&&this.mapCoordsHelper.spatialReference.equals(e)||this._set("mapCoordsHelper",new Me(this.map,e));const t=this.state.isGlobal,i=q(t,e);i!==this.renderSpatialReference&&(this._set("renderCoordsHelper",Re.create(this.state.viewingMode,i)),t||this.addHandles(y((()=>this.basemapTerrain?.extent),(e=>{const t=this.renderCoordsHelper.spatialReference;null==e||0===e[0]&&0===e[1]&&0===e[2]&&0===e[3]||!U(e,this.basemapTerrain.spatialReference,ct,t)||(this.renderCoordsHelper.extent=ct)}),_),"render-coords-helper"),this.sceneIntersectionHelper&&this.sceneIntersectionHelper.setTolerance(Ae/this.renderCoordsHelper.unitInMeters))}else this._set("mapCoordsHelper",null),this._set("renderCoordsHelper",null)}_exitCoordinateSystem(){this.mapCoordsHelper&&(this.removeHandles("render-coords-helper"),this._set("renderCoordsHelper",null),this._set("mapCoordsHelper",null))}_updatingChanged(){this.notifyChange("updating")}_updateUpdatingMonitors(e=null){null!=e&&e.type===u.MOVE||(this.removeHandles("updatingMonitors"),this.allLayerViews.forEach((e=>{e.destroyed||(this.addHandles(y((()=>[e.updating,e.updatingProgress]),(()=>this._updatingChanged()),_),"updatingMonitors"),e.when((()=>this._updatingChanged()),(()=>this._updatingChanged())))})),this._updatingChanged())}async _prepareScreenshotOverlay(){this.overlay&&await this.overlay.prepare()}_renderScreenshotOverlay(e,t){if(!this.overlay||!this.overlay.hasVisibleItems)return t;const i=e.getContext("2d");return i.putImageData(t,0,0),this.overlay.renderCanvas(e),i.getImageData(0,0,t.width,t.height)}_initStage(){const e={deactivatedWebGLExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions,alpha:this.alphaCompositingEnabled,preserveDrawingBuffer:this.preserveDrawingBufferEnabled,canvas:this.renderCanvas,screenshot:{prepareOverlay:()=>this._prepareScreenshotOverlay(),renderOverlay:(e,t)=>this._renderScreenshotOverlay(e,t)}},t=new ye(this.state.viewingMode,(e=>this._stage.layers.forAll(e)),this);this._set("sceneIntersectionHelper",t);const i=n(this.surface);this._stage=new Pe({view:this,options:e,container:i}),this._stage.renderer.setParameters({slicePlane:this.slicePlane}),this.addHandles([this.updatingHandles.add((()=>this.qualitySettings.antialiasingEnabled),(()=>this._stage.renderer.setParameters({antialiasingEnabled:this.qualitySettings.antialiasingEnabled})),f),this.updatingHandles.add((()=>this.qualitySettings.highQualityTransparency),(e=>this._stage.renderer.setParameters({highQualityTransparency:e})),f),y((()=>this.magnifier),(e=>this._stage.renderView.magnifier=e),w),this.on("pointer-move",(()=>this._stage?.renderer.resetAnimation())),o(this._stage.renderView.canvas,"webglcontextlost",(e=>this.fatalError=new a("webgl-context-lost",e.statusMessage)))],"stage");const r=()=>{this._stage.renderer.setParameters({defaultHighlightOptions:be.toEngineOptions(this.highlightOptions)})};this.addHandles(this.updatingHandles.add((()=>[this.highlightOptions.color,this.highlightOptions.haloColor,this.highlightOptions.haloOpacity,this.highlightOptions.fillOpacity,this.highlightOptions.shadowOpacity,this.highlightOptions.shadowColor,this.highlightOptions.shadowDifference]),r),"stage"),r(),this.renderCoordsHelper&&this.sceneIntersectionHelper.setTolerance(Ae/this.renderCoordsHelper.unitInMeters),this._set("canvas",this._stage.renderView.canvas)}_exitStage(){this._set("sceneIntersectionHelper",null),this._stage=c(this._stage),this.removeHandles("stage"),this._set("canvas",null)}_initSurface(e){this._exitSurface(),this.state.init(e,this.spatialReference),this._initStage(),this._initGlobe(),this.sharedSymbolResources=new Te({view:this,viewingMode:e,resourceController:this._resourceController,pointsOfInterest:this.pointsOfInterest,viewState:this.state})}_exitSurface(){this.sharedSymbolResources&&(this.sharedSymbolResources.objectResourceCache.destroy(),this.sharedSymbolResources.destroy(),this.sharedSymbolResources=null,this._exitGlobe(),this._exitStage())}_createGraphicsViewIfNeeded(){if(this.graphicsView||this._createGraphicsViewController)return;if(0===this.graphics.length)return;this.removeHandles("graphics-view"),this._createGraphicsViewController=new AbortController;const e=()=>{this._createGraphicsViewController=null,this._updatingChanged()};this._createGraphicsViewAsync(this._createGraphicsViewController.signal).then(e,e),this._updatingChanged()}async _createGraphicsViewAsync(e){const t=(await import("./3d/layers/GraphicsView3D.js")).default;g(e),await v((()=>this.basemapTerrain?.ready),e),this._set("graphicsView",new t({view:this}))}_disposeGraphicsView(){this._createGraphicsViewController&&(this._createGraphicsViewController.abort(),this._createGraphicsViewController=null),this.removeHandles("graphics-view"),null!=this.graphicsView&&(this.removeHandles(this.graphicsView.processor.layer.id),this.graphicsView.destroy(),this._set("graphicsView",null))}_startup(){const e=se(this.viewingMode);if(e===ie.Global&&(this._clippingArea=null),this._initSurface(e),this._set("ready",!0),this.addHandles(m((()=>this.graphics),"after-changes",(()=>this._createGraphicsViewIfNeeded())),"graphics-view"),this._createGraphicsViewIfNeeded(),!this._externallySet.environment){const e=this.get("map.initialViewProperties.environment");e&&(this.environment=e)}this.labeler.setup(),this.environmentManager.connectView(this),this.inputManager.connect();const t=this._resolveWhenReady;this._resolveWhenReady=[],t.forEach((e=>e(this)))}_teardown(){this._initialDefaultSpatialReference=null,this.inputManager.disconnect(),this.environmentManager.disconnectView(),this.labeler.dispose(),this._disposeGraphicsView(),this.removeHandles("graphics-view"),this._exitSurface(),this._set("ready",!1)}_updateDefaultToMapOptions(){if(this._defaultToMapOptions.include.clear(),this.map){this.map.ground&&this._defaultToMapOptions.include.add(ke);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&this._defaultToMapOptions.include.add(e.uid)}}_updateDefaultHitTestOptions(){if(this._defaultHitTestOptions.exclude.clear(),this.map){this.map.ground&&this.map.ground.opacity<1&&this._defaultHitTestOptions.exclude.add(ke);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&e.opacity<1&&this._defaultHitTestOptions.exclude.add(e.uid)}}addVoxelLayerViewToWasm(e){return null==this.voxelWasm?(null==this.voxelWasmPromise&&(this.voxelWasmPromise=import("../layers/VoxelWasmPerSceneView.js").then((e=>(this.voxelWasm=new e.default(this),this.voxelWasm)))),this.voxelWasmPromise.then((t=>t.addVoxelLayer(e)))):this.voxelWasm.addVoxelLayer(e)}removeVoxelLayerViewFromWasm(e){if(null!=this.voxelWasm){this.voxelWasm.removeVoxelLayer(e)<1&&(this.voxelWasm=null,this.voxelWasmPromise=null)}}};function at(e,t){e.layerUids||(e.layerUids=new Set),e.layerUids.add(t)}function ot(e,t){e.graphicUids||(e.graphicUids=new Set),e.graphicUids.add(t)}function lt(e,t){return null!=e&&A(e.spatialReference,t)?G(e,t):null}var pt;nt.type="3d",e([V()],nt.prototype,"_userClippingArea",void 0),e([V()],nt.prototype,"_resourceController",void 0),e([V()],nt.prototype,"_stage",void 0),e([V({readOnly:!0})],nt.prototype,"deconflictor",void 0),e([V({readOnly:!0})],nt.prototype,"labeler",void 0),e([V(I(X,"analyses"))],nt.prototype,"analyses",void 0),e([V({type:te,readOnly:!0})],nt.prototype,"animation",null),e([V({readOnly:!0})],nt.prototype,"basemapTerrain",void 0),e([V({readOnly:!0})],nt.prototype,"elevationProvider",void 0),e([V()],nt.prototype,"camera",null),e([V({type:t})],nt.prototype,"contentCamera",null),e([V({readOnly:!0})],nt.prototype,"canvas",void 0),e([V({type:st})],nt.prototype,"center",null),e([V({type:it})],nt.prototype,"clippingArea",null),e([V({type:oe})],nt.prototype,"constraints",void 0),e([V({type:it,readOnly:!0})],nt.prototype,"renderDataExtent",null),e([V({type:it,readOnly:!0})],nt.prototype,"dataExtent",null),e([V({type:it,readOnly:!0})],nt.prototype,"_groundAndLayersExtent",null),e([V({value:null,type:le})],nt.prototype,"environment",null),e([x("environment")],nt.prototype,"castEnvironment",null),e([V({readOnly:!0})],nt.prototype,"environmentManager",void 0),e([V({type:it})],nt.prototype,"extent",null),e([V()],nt.prototype,"floors",void 0),e([V()],nt.prototype,"screenCenter",null),e([V()],nt.prototype,"frustum",null),e([V({type:Number,readOnly:!0})],nt.prototype,"fullOpacity",void 0),e([V({readOnly:!0})],nt.prototype,"graphicsView",void 0),e([V({readOnly:!0})],nt.prototype,"analysisViewManager",void 0),e([V()],nt.prototype,"groundView",void 0),e([V({type:Boolean})],nt.prototype,"initialExtentRequired",null),e([V()],nt.prototype,"_defaultsFromMapSettings",null),e([V()],nt.prototype,"interacting",null),e([V()],nt.prototype,"stationary",null),e([V()],nt.prototype,"navigating",null),e([V()],nt.prototype,"map",void 0),e([V({readOnly:!0})],nt.prototype,"mapCoordsHelper",void 0),e([V()],nt.prototype,"padding",null),e([V({type:Oe,readOnly:!0})],nt.prototype,"pointsOfInterest",void 0),e([V({type:ue,readOnly:!0})],nt.prototype,"featureTiles",void 0),e([V()],nt.prototype,"_featureTreeDebugger",void 0),e([V({type:Boolean})],nt.prototype,"screenSizePerspectiveEnabled",void 0),e([V({constructOnly:!0})],nt.prototype,"deactivatedWebGLExtensions",void 0),e([V({constructOnly:!0})],nt.prototype,"debugWebGLExtensions",void 0),e([V({constructOnly:!0})],nt.prototype,"renderCanvas",void 0),e([V({constructOnly:!0})],nt.prototype,"state",void 0),e([V({readOnly:!0})],nt.prototype,"inputManager",void 0),e([V({readOnly:!0})],nt.prototype,"stateManager",void 0),e([V({type:["low","medium","high"]})],nt.prototype,"qualityProfile",null),e([V({type:Ce,get(){let e=this._get("qualitySettings");return e||(e=new Ce,ve.apply(this.qualityProfile,e)),e}})],nt.prototype,"qualitySettings",void 0),e([V()],nt.prototype,"slicePlane",null),e([V({readOnly:!0})],nt.prototype,"typeSpecificPreconditionsReady",null),e([V({readOnly:!0})],nt.prototype,"renderCoordsHelper",void 0),e([V({readOnly:!0})],nt.prototype,"sceneIntersectionHelper",void 0),e([V({type:Number,dependsOn:["scale","spatialReference"],readOnly:!0})],nt.prototype,"resolution",null),e([V({type:Number})],nt.prototype,"scale",null),e([V()],nt.prototype,"heightModelInfo",null),e([V()],nt.prototype,"spatialReference",void 0),e([V({type:Boolean,constructOnly:!0})],nt.prototype,"alphaCompositingEnabled",void 0),e([V({constructOnly:!0})],nt.prototype,"preserveDrawingBufferEnabled",void 0),e([V({type:Boolean})],nt.prototype,"supersampleScreenshotsEnabled",void 0),e([V({readOnly:!0})],nt.prototype,"type",void 0),e([V(),x((e=>e instanceof Ke?e:j(et,e)))],nt.prototype,"ui",void 0),e([V({type:Boolean,readOnly:!0,dependsOn:["graphicsView.updating","basemapView.updating","basemapTerrain.updating","layerViewManager.updating","layerViewManager.updatingRemaining","_resourceController.updating","_stage.updating","featureTiles.updating","pointsOfInterest.updating","environmentManager.updating","overlay.updating","updatingHandles.updating","featureTreeDebugger.updating","labeler.updating","deconflictor.updating","ready","stationary","inputManager.updating","toolViewManager.updating","analysisViewManager.updating","state.updating"]})],nt.prototype,"updating",null),e([V()],nt.prototype,"_updatingObjects",null),e([V()],nt.prototype,"_updatingObjectsWithProgress",null),e([V({type:Number,readOnly:!0,dependsOn:["updating"]})],nt.prototype,"updatingProgress",void 0),e([V({type:["global","local"]})],nt.prototype,"viewingMode",null),e([V({type:r})],nt.prototype,"viewpoint",null),e([V({type:Number})],nt.prototype,"zoom",null),e([V({type:be})],nt.prototype,"highlightOptions",void 0),nt=e([T("esri.views.SceneView")],nt),function(e){e[e.INCLUDE=0]="INCLUDE",e[e.EXCLUDE=1]="EXCLUDE"}(pt||(pt={}));const ht=E(),dt=C(),ct=W(),ut=nt;export{ut as default};