@arcgis/core 4.33.0-next.20250218 → 4.33.0-next.20250220

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 (216) hide show
  1. package/applications/ExperienceBuilder/sketchUtils.d.ts +1 -0
  2. package/applications/ExperienceBuilder/sketchUtils.js +1 -1
  3. package/arcade/treeAnalysis.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/{f5ce6af342c02a4b0d15.js → 030384851fa745908a6e.js} +13 -12
  6. package/assets/esri/core/workers/chunks/0c3930e40fc9f8a84599.js +2 -0
  7. package/assets/esri/core/workers/chunks/{ccee343fb8c415b59ce3.js.LICENSE.txt → 0c3930e40fc9f8a84599.js.LICENSE.txt} +1 -1
  8. package/assets/esri/core/workers/chunks/0e6762d69b7449f8a997.js +1 -0
  9. package/assets/esri/core/workers/chunks/{5ad51a68d20b0d0d404f.js → 1661ac4e1b6c6af6ee0f.js} +1 -1
  10. package/assets/esri/core/workers/chunks/186db99d05ca1183d4e9.js +1 -0
  11. package/assets/esri/core/workers/chunks/{a42ae5d5e5f66d120b4d.js → 21c7265f1f2a718de7c6.js} +1 -1
  12. package/assets/esri/core/workers/chunks/2a88909a03600349dff9.js +1 -0
  13. package/assets/esri/core/workers/chunks/333bb93a28209c997d8b.js +314 -0
  14. package/assets/esri/core/workers/chunks/469c50c49447f0d602c0.js +1 -0
  15. package/assets/esri/core/workers/chunks/486df1e042204b90b0dd.js.LICENSE.txt +1 -1
  16. package/assets/esri/core/workers/chunks/{c2d539359f321bba3432.js → 52c13b3c074c9f6dadde.js} +2 -2
  17. package/assets/esri/core/workers/chunks/{c2d539359f321bba3432.js.LICENSE.txt → 52c13b3c074c9f6dadde.js.LICENSE.txt} +1 -1
  18. package/assets/esri/core/workers/chunks/5352b374454bc4f73d55.js +1 -0
  19. package/assets/esri/core/workers/chunks/5693d9ce4472a4c5959f.js.LICENSE.txt +1 -1
  20. package/assets/esri/core/workers/chunks/5984ab09ea8010f8a874.js +1 -0
  21. package/assets/esri/core/workers/chunks/5b56b271afb0fadf48b4.js.LICENSE.txt +1 -1
  22. package/assets/esri/core/workers/chunks/6518954889df2e781c47.js.LICENSE.txt +1 -1
  23. package/assets/esri/core/workers/chunks/68322a63ec92d33701ea.js +1 -0
  24. package/assets/esri/core/workers/chunks/{ec62fffe07c4382e8796.js → 6c64ccf5f64b5025b239.js} +1 -1
  25. package/assets/esri/core/workers/chunks/717d7e9912d948e44d8d.js +1 -0
  26. package/assets/esri/core/workers/chunks/aacebda644be06ad1a61.js +1 -0
  27. package/assets/esri/core/workers/chunks/ac11b2168feee63d2f09.js +1 -0
  28. package/assets/esri/core/workers/chunks/b0952b81d5be214262dd.js.LICENSE.txt +1 -1
  29. package/assets/esri/core/workers/chunks/b9292cd91005137a2094.js +1 -0
  30. package/assets/esri/core/workers/chunks/b9d2f60b2d587a2b6cd7.js +1 -0
  31. package/assets/esri/core/workers/chunks/cf285e45c18cd4399dde.js +1 -0
  32. package/assets/esri/core/workers/chunks/{42f21349f488a14198e4.js → d4a08800c75051a5131d.js} +1 -1
  33. package/assets/esri/core/workers/chunks/e2df18662cc4d6e47715.js +1 -0
  34. package/assets/esri/core/workers/chunks/e96f4c76c8bc78a7f80f.js +1 -0
  35. package/assets/esri/core/workers/chunks/f24aef061e60d2c2f597.js +1 -0
  36. package/assets/esri/core/workers/chunks/f664cc15238c8e9856a0.js +1 -0
  37. package/assets/esri/themes/base/widgets/_Editor.scss +3 -0
  38. package/assets/esri/themes/base/widgets/_Print.scss +1 -0
  39. package/assets/esri/themes/base/widgets/_ResponsiveToolbar.scss +23 -3
  40. package/assets/esri/themes/base/widgets/_Sketch.scss +32 -24
  41. package/assets/esri/themes/dark/main.css +1 -1
  42. package/assets/esri/themes/light/main.css +1 -1
  43. package/assets/esri/themes/light/view.css +1 -1
  44. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm.json +1 -1
  45. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ar.json +1 -1
  46. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bg.json +1 -1
  47. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bs.json +1 -1
  48. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ca.json +1 -1
  49. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_cs.json +1 -1
  50. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_da.json +1 -1
  51. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_de.json +1 -1
  52. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_el.json +1 -1
  53. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_en.json +1 -1
  54. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_es.json +1 -1
  55. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_et.json +1 -1
  56. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fi.json +1 -1
  57. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fr.json +1 -1
  58. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_he.json +1 -1
  59. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hr.json +1 -1
  60. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hu.json +1 -1
  61. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_id.json +1 -1
  62. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_it.json +1 -1
  63. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ja.json +1 -1
  64. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ko.json +1 -1
  65. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lt.json +1 -1
  66. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lv.json +1 -1
  67. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_nl.json +1 -1
  68. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_no.json +1 -1
  69. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pl.json +1 -1
  70. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-BR.json +1 -1
  71. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-PT.json +1 -1
  72. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ro.json +1 -1
  73. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ru.json +1 -1
  74. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sk.json +1 -1
  75. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sl.json +1 -1
  76. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sr.json +1 -1
  77. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sv.json +1 -1
  78. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_th.json +1 -1
  79. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_tr.json +1 -1
  80. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_uk.json +1 -1
  81. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_vi.json +1 -1
  82. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-CN.json +1 -1
  83. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-HK.json +1 -1
  84. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-TW.json +1 -1
  85. package/chunks/RealisticTree.glsl.js +18 -17
  86. package/copyright.txt +91 -0
  87. package/geometry/support/meshUtils/elevation.js +1 -1
  88. package/interfaces.d.ts +493 -131
  89. package/layers/BuildingSceneLayer.js +1 -1
  90. package/layers/FeatureLayer.js +1 -1
  91. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  92. package/layers/IntegratedMeshLayer.js +1 -1
  93. package/layers/OrientedImageryLayer.js +1 -1
  94. package/layers/PointCloudLayer.js +1 -1
  95. package/layers/RouteLayer.js +1 -1
  96. package/layers/SceneLayer.js +1 -1
  97. package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
  98. package/layers/graphics/OptimizedGeometry.js +1 -1
  99. package/layers/graphics/featureConversionUtils.js +1 -1
  100. package/layers/support/featureLayerUtils.js +1 -1
  101. package/layers/support/rasterFunctionUtils.d.ts +11 -0
  102. package/networks/UtilityNetwork.js +1 -1
  103. package/package.json +2 -2
  104. package/portal/Portal.js +1 -1
  105. package/rest/route.js +1 -1
  106. package/rest/support/AttributeBinsGrouping.js +1 -1
  107. package/rest/support/AttributeBinsQuery.js +1 -1
  108. package/rest/support/RouteParameters.js +1 -1
  109. package/rest/support/RouteSolveResult.js +1 -1
  110. package/support/revision.js +1 -1
  111. package/symbols/cim/CIMEffects.js +1 -1
  112. package/symbols/cim/cimAnalyzer.js +1 -1
  113. package/symbols/cim/effects/EffectAddControlPoints.js +1 -1
  114. package/symbols/cim/effects/EffectBuffer.js +1 -1
  115. package/symbols/cim/effects/EffectDonut.js +1 -1
  116. package/symbols/cim/effects/EffectOffset.js +1 -1
  117. package/views/2d/FrameTask.js +1 -1
  118. package/views/2d/engine/webgl/TextureManager.js +1 -1
  119. package/views/2d/engine/webgl/Utils.js +1 -1
  120. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelTechnique.js +1 -1
  121. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  122. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  123. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  124. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  125. package/views/2d/layers/features/sources/FeatureCache.js +1 -1
  126. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  127. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
  128. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  129. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  130. package/views/2d/viewpointUtils.js +1 -1
  131. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  132. package/views/3d/layers/I3SMeshView3D.js +1 -1
  133. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
  134. package/views/3d/layers/graphics/pipeline/Tile.js +1 -1
  135. package/views/3d/layers/graphics/pipeline/Tile3DManager.js +1 -1
  136. package/views/3d/layers/graphics/pipeline/featureData/FeatureData.js +1 -1
  137. package/views/3d/layers/graphics/pipeline/featureData/FeatureDataSubset.js +5 -0
  138. package/views/3d/layers/graphics/pipeline/featureData/processingUtils.js +1 -1
  139. package/views/3d/layers/graphics/pipeline/featureSet/PBFPointFeatureSetView.js +1 -1
  140. package/views/3d/layers/graphics/pipeline/featureSet/TiledFeatureStore.js +1 -1
  141. package/views/3d/layers/graphics/pipeline/fetching/Tile3DFetcher.js +1 -1
  142. package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
  143. package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
  144. package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
  145. package/views/3d/layers/support/FeatureTile.js +1 -1
  146. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  147. package/views/3d/terrain/TileRenderer.js +1 -1
  148. package/views/3d/webgl-engine/collections/Component/ComponentData.js +1 -1
  149. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  150. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticComponentBVH.js +1 -1
  151. package/views/3d/webgl-engine/collections/Component/IndexRange/ComponentRange.js +5 -0
  152. package/views/3d/webgl-engine/lib/ComponentUtils.js +1 -1
  153. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  154. package/views/3d/webgl-engine/materials/renderers/BufferRange.js +1 -1
  155. package/views/VideoView.js +1 -1
  156. package/views/View2D.js +1 -1
  157. package/views/Viewport2DMixin.js +5 -0
  158. package/views/webgl/Texture.js +1 -1
  159. package/webmap/utils.js +1 -1
  160. package/widgets/BasemapLayerList.js +1 -1
  161. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  162. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  163. package/widgets/BatchAttributeForm/templates/support/contingentValuesUtils.js +5 -0
  164. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  165. package/widgets/BatchAttributeForm.js +1 -1
  166. package/widgets/CatalogLayerList.js +1 -1
  167. package/widgets/DirectionalPad/DirectionalPadViewModel.js +1 -1
  168. package/widgets/Directions/DirectionsViewModel.js +1 -1
  169. package/widgets/Directions.js +1 -1
  170. package/widgets/ElevationProfile/components/LegendItem.js +1 -1
  171. package/widgets/ElevationProfile/components/SettingsButton.js +1 -1
  172. package/widgets/Feature/FeatureUtilityNetworkAssociations.js +1 -1
  173. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  174. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  175. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  176. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  177. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  178. package/widgets/LayerList.js +1 -1
  179. package/widgets/Legend/styles/support/utils.js +1 -1
  180. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  181. package/widgets/OrientedImageryViewer/components/ImageOverlays.js +1 -1
  182. package/widgets/OrientedImageryViewer/digitizationUtils.js +1 -1
  183. package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
  184. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  185. package/widgets/OrientedImageryViewer.js +1 -1
  186. package/widgets/Print.js +1 -1
  187. package/widgets/ShadowCast.js +1 -1
  188. package/widgets/Sketch/SketchViewModel.js +1 -1
  189. package/widgets/Sketch/support/ResponsiveToolbar/OverflowGroup.js +1 -1
  190. package/widgets/Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js +1 -1
  191. package/widgets/Sketch/support/ResponsiveToolbar/SplitButton.js +1 -1
  192. package/widgets/Sketch/support/sketchUtils.js +1 -1
  193. package/widgets/Sketch.js +1 -1
  194. package/widgets/VideoPlayer.js +1 -1
  195. package/widgets/support/UtilityNetworkAssociations/utilityNetworkUtils.js +1 -1
  196. package/assets/esri/core/workers/chunks/1cbea0c0b20a2963a86d.js +0 -1
  197. package/assets/esri/core/workers/chunks/238bcf6514a1f214cc8a.js +0 -1
  198. package/assets/esri/core/workers/chunks/26b5397f63dc602612f2.js +0 -1
  199. package/assets/esri/core/workers/chunks/290f613ef70590de9f15.js +0 -314
  200. package/assets/esri/core/workers/chunks/33c6fd524711efd8ef13.js +0 -1
  201. package/assets/esri/core/workers/chunks/3f077176c03a360e1edd.js +0 -1
  202. package/assets/esri/core/workers/chunks/544ad8fa4777ba8ec177.js +0 -1
  203. package/assets/esri/core/workers/chunks/6039da57a2adedd3b83f.js +0 -1
  204. package/assets/esri/core/workers/chunks/842db06ce62758fab1e7.js +0 -1
  205. package/assets/esri/core/workers/chunks/916f0ca8e3aaed5a9508.js +0 -1
  206. package/assets/esri/core/workers/chunks/bdc9dec6a359d2e3705c.js +0 -1
  207. package/assets/esri/core/workers/chunks/bf127fe767174e2715b5.js +0 -1
  208. package/assets/esri/core/workers/chunks/cb3148cf11a420d6e9ab.js +0 -1
  209. package/assets/esri/core/workers/chunks/ccee343fb8c415b59ce3.js +0 -2
  210. package/assets/esri/core/workers/chunks/d342c56558f164e9e786.js +0 -1
  211. package/assets/esri/core/workers/chunks/d3f7ff03ab5b40062d89.js +0 -1
  212. package/assets/esri/core/workers/chunks/ed89a108b032b982b12f.js +0 -1
  213. package/assets/esri/core/workers/chunks/ef6279f5c63ab1e88c71.js +0 -1
  214. package/assets/esri/core/workers/chunks/f088e7db4e7ac85aaff1.js +0 -1
  215. package/views/3d/layers/graphics/pipeline/featureData/FeatureDataStore.js +0 -5
  216. package/views/3d/webgl-engine/collections/Component/IndexRange/ComponentRangeRunLengthEncoded.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{shuffle as t}from"../../../../core/arrayUtils.js";import{signal as e}from"../../../../core/signal.js";import{create as s,fromExtent as i,intersects as r,copy as u,positiveInfinity as a,intersection as h}from"../../../../geometry/support/aaBoundingRect.js";import{numVertices as n,estimateSize as f,getObjectId as l}from"../../../../layers/graphics/dehydratedFeatures.js";import{computeMaxZ as _}from"../graphics/graphicUtils.js";const d=16438;class m{constructor(t){this.descriptor=t,this.fetchStatus=F.FETCH_NEEDED,this._numVertices=0,this._featuresMissing=e(!0),this._fetchFailed=e(!1),this._shuffled=!1,this._numFeatures=c,this._emptyFeatureRatio=e(0),this._estimatedSize=-1,this._estimatedUnusedSize=0,this._estimatedUnusedSizeDirty=!1,this._displayingFeatures=null,this.alive=!0,this.filtered=!1,this._features=null,this._featuresLength=e(0),this._featureLimit=e(0),this.fetchingResolution=this.displayingResolution=t.resolution}get featuresMissing(){return this._featuresMissing.value}set featuresMissing(t){this._featuresMissing.value=t}get missingAttributes(){return this._missingAttributes}get fetchFailed(){return this._fetchFailed.value}set fetchFailed(t){this._fetchFailed.value=t}get displayingFeatures(){return this._displayingFeatures}set displayingFeatures(t){this._displayingFeatures=t,this.extentIncludingBorrowedFeatures=null}get perTileMaximumNumberOfFeaturesExceeded(){const t=(this.fetchStatus===F.DONE||this.fetchStatus===F.FULL)&&this.featuresMissing;return!this.filtered&&(t||this.hasFeatureLimit)}get features(){return this._features}get featureLimit(){return this._featureLimit.value}set featureLimit(t){this._featureLimit.value!==t&&(this._featureLimit.value=t,this._estimatedUnusedSizeDirty=!0)}get hasFeatureLimit(){return this.featureLimit!==this._featuresLength.value}get hasAllFeatures(){return!(this.featuresMissing||this.fetchFailed||this.hasFeatureLimit)}get availableFields(){return this._availableFields}setFeatures(t,e,s,i){this._availableFields=s,this._features=t,this._featuresLength.value=t?.length??0,this._shuffled=!1,this._estimatedSize=-1,this._estimatedUnusedSizeDirty=!0,this._missingAttributes=i,t&&t.length>0?(this._emptyFeatureRatio.value=e/(t.length+e),this._numVertices=t.reduce(((t,e)=>t+n(e.geometry)),0)):(this._emptyFeatureRatio.value=0,this._numVertices=0)}computeZQuantizationFactor(){if(this._features&&this._features.length>0){const t=this._features.reduce(((t,{geometry:e})=>Math.max(t,_(e)??0)),0);return Math.floor(t/this.descriptor.planetRadius)+1}return 1}get emptyFeatureRatio(){return this._emptyFeatureRatio.value}get numFeatures(){return this.hasPreciseFeatureCount?this._numFeatures:this._features?this._features.length:0}set numFeatures(t){this._numFeatures=t}get hasPreciseFeatureCount(){return this._numFeatures>c}get needsFeatureCount(){return this._numFeatures===c}get numVertices(){return this._numVertices}get id(){return this.descriptor.id}get estimatedSize(){return this.updateMemoryEstimates(),this._estimatedSize}get estimatedUnusedSize(){return this._estimatedUnusedSize}updateMemoryEstimates(){if(this._estimatedSize<0){if(this._estimatedSize=0,this._estimatedUnusedSize=0,this._features)for(let t=0;t<this._features.length;++t){const e=f(this._features[t]);this._estimatedSize+=e,t>=this.featureLimit&&(this._estimatedUnusedSize+=e)}return!0}if(this._estimatedUnusedSizeDirty){if(this._estimatedUnusedSize=0,this._estimatedUnusedSizeDirty=!1,this._features)for(let t=this.featureLimit;t<this._features.length;++t)this._estimatedUnusedSize+=f(this._features[t]);return!0}return!1}get isFetching(){return this.fetchStatus===F.FETCHING||this.fetchStatus===F.REFETCHING}get isRefetching(){return this.fetchStatus===F.REFETCHING}get needsFetching(){return this.fetchStatus===F.FETCH_NEEDED||this.fetchStatus===F.REFETCH_NEEDED}get needsRefetching(){return this.fetchStatus===F.REFETCH_NEEDED}get isFetched(){return this.fetchStatus===F.DONE||this.fetchStatus===F.FULL}resetFetching(){this.fetchStatus=this.fetchStatus===F.REFETCHING?F.REFETCH_NEEDED:F.FETCH_NEEDED}get needsDisplayUpdate(){return!!this._features&&!E(this._features,this.displayingFeatures,this.featureLimit)}intersects(t){return null==t||!this.descriptor.extent||(i(t,S),r(this.descriptor.extent,S))}intersectionIncludingBorrowed(t,e){const s=null!=this.extentIncludingBorrowedFeatures?this.extentIncludingBorrowedFeatures:this.descriptor.extent;return t||s?(null!=t?(i(t,e),h(e,s,e)):u(e,s),e):(u(e,a),e)}_shuffle(e){this._features&&(this._features.sort(((t,s)=>l(t,e)-l(s,e))),t(this._features,d),this._shuffled=!0,this._estimatedUnusedSizeDirty=!0)}reduceFeatures(t,e,s){if(t<=0)return!1;if(!this._features)return this.featureLimit=0,!1;let i=!1;this.featureLimit=Math.ceil(this.numFeatures*t),this.featureLimit>this._features.length&&(this.featureLimit=this._features.length,this.fetchStatus===F.DONE&&this._features.length>0&&(this.fetchStatus=F.REFETCH_NEEDED,i=!0)),!this._shuffled&&t<1&&this._shuffle(s);const r=Math.max(this.featureLimit,Math.ceil(e*this.numFeatures));return this._features.length>r&&(this._features.length=r,this._featuresLength.value=r,this.featuresMissing=!0,this.fetchStatus===F.FULL&&(this.fetchStatus=F.DONE)),i}get cache(){return new o(this,this._features,this._numFeatures,this._emptyFeatureRatio.value)}set cache(t){this.requestController=null,this._availableFields=t.availableFields,this._features=t.features,this._featuresLength.value=t.features?.length??0,this._numFeatures=t.numFeatures,this._emptyFeatureRatio.value=t.emptyFeatureRatio,this.fetchStatus=t.fetchStatus,this.featuresMissing=t.featuresMissing,this._estimatedSize=-1,this._estimatedUnusedSizeDirty=!0}}const c=-1,g=-2;var F;!function(t){t[t.FETCH_NEEDED=0]="FETCH_NEEDED",t[t.REFETCH_NEEDED=1]="REFETCH_NEEDED",t[t.FETCHING=2]="FETCHING",t[t.REFETCHING=3]="REFETCHING",t[t.DONE=4]="DONE",t[t.FULL=5]="FULL"}(F||(F={}));class o{constructor(t,e,s,i){this.features=e,this.numFeatures=s,this.emptyFeatureRatio=i,this.cachedMemory=16+t.estimatedSize,this.availableFields=t.availableFields,this.fetchStatus=t.fetchStatus,this.featuresMissing=t.featuresMissing}}function E(t,e,s){if(null==e||null==t||s!==e.length||s>t.length)return!1;for(let i=0;i<s;++i)if(t[i]!==e[i])return!1;return!0}const S=s();export{m as FeatureTile,o as FeatureTileCacheItem,F as FetchStatus,g as failedFeatureCount};
5
+ import{shuffle as t}from"../../../../core/arrayUtils.js";import{signal as e}from"../../../../core/signal.js";import{create as s,fromExtent as i,intersects as r,copy as u,positiveInfinity as a,intersection as h}from"../../../../geometry/support/aaBoundingRect.js";import{numVertices as n,estimateSize as f,getObjectId as l}from"../../../../layers/graphics/dehydratedFeatures.js";import{computeMaxZ as _}from"../graphics/graphicUtils.js";const d=16438;class m{constructor(t){this.descriptor=t,this.fetchStatus=g.FETCH_NEEDED,this._numVertices=0,this._featuresMissing=e(!0),this._fetchFailed=e(!1),this._shuffled=!1,this._numFeatures=c,this._emptyFeatureRatio=e(0),this._estimatedSize=-1,this._estimatedUnusedSize=0,this._estimatedUnusedSizeDirty=!1,this._displayingFeatures=null,this.alive=!0,this.filtered=!1,this._features=null,this._featuresLength=e(0),this._featureLimit=e(0),this.fetchingResolution=this.displayingResolution=t.resolution}get featuresMissing(){return this._featuresMissing.value}set featuresMissing(t){this._featuresMissing.value=t}get missingAttributes(){return this._missingAttributes}get fetchFailed(){return this._fetchFailed.value}set fetchFailed(t){this._fetchFailed.value=t}get displayingFeatures(){return this._displayingFeatures}set displayingFeatures(t){this._displayingFeatures=t,this.extentIncludingBorrowedFeatures=null}get perTileMaximumNumberOfFeaturesExceeded(){const t=(this.fetchStatus===g.DONE||this.fetchStatus===g.FULL)&&this.featuresMissing;return!this.filtered&&(t||this.hasFeatureLimit)}get features(){return this._features}get featureLimit(){return this._featureLimit.value}set featureLimit(t){this._featureLimit.value!==t&&(this._featureLimit.value=t,this._estimatedUnusedSizeDirty=!0)}get hasFeatureLimit(){return this.featureLimit!==this._featuresLength.value}get hasAllFeatures(){return!(this.featuresMissing||this.fetchFailed||this.hasFeatureLimit)}get availableFields(){return this._availableFields}setFeatures(t,e,s,i){this._availableFields=s,this._features=t,this._featuresLength.value=t?.length??0,this._shuffled=!1,this._estimatedSize=-1,this._estimatedUnusedSizeDirty=!0,this._missingAttributes=i,t&&t.length>0?(this._emptyFeatureRatio.value=e/(t.length+e),this._numVertices=t.reduce(((t,e)=>t+n(e.geometry)),0)):(this._emptyFeatureRatio.value=0,this._numVertices=0)}computeZQuantizationFactor(){if(this._features&&this._features.length>0){const t=this._features.reduce(((t,{geometry:e})=>Math.max(t,_(e)??0)),0);return Math.floor(t/this.descriptor.planetRadius)+1}return 1}get emptyFeatureRatio(){return this._emptyFeatureRatio.value}get numFeatures(){return this.hasPreciseFeatureCount?this._numFeatures:this._features?this._features.length:0}set numFeatures(t){this._numFeatures=t}get hasPreciseFeatureCount(){return this._numFeatures>c}get needsFeatureCount(){return this._numFeatures===c}get numVertices(){return this._numVertices}get id(){return this.descriptor.id}get estimatedSize(){return this.updateMemoryEstimates(),this._estimatedSize}get estimatedUnusedSize(){return this._estimatedUnusedSize}updateMemoryEstimates(){if(this._estimatedSize<0){if(this._estimatedSize=0,this._estimatedUnusedSize=0,this._features)for(let t=0;t<this._features.length;++t){const e=f(this._features[t]);this._estimatedSize+=e,t>=this.featureLimit&&(this._estimatedUnusedSize+=e)}return!0}if(this._estimatedUnusedSizeDirty){if(this._estimatedUnusedSize=0,this._estimatedUnusedSizeDirty=!1,this._features)for(let t=this.featureLimit;t<this._features.length;++t)this._estimatedUnusedSize+=f(this._features[t]);return!0}return!1}get isFetching(){return this.fetchStatus===g.FETCHING||this.fetchStatus===g.REFETCHING}get isRefetching(){return this.fetchStatus===g.REFETCHING}get needsFetch(){return this.fetchStatus===g.FETCH_NEEDED||this.fetchStatus===g.REFETCH_NEEDED}get needsRefetch(){return this.fetchStatus===g.REFETCH_NEEDED}get isFetched(){return this.fetchStatus===g.DONE||this.fetchStatus===g.FULL}resetFetching(){this.fetchStatus=this.fetchStatus===g.REFETCHING?g.REFETCH_NEEDED:g.FETCH_NEEDED}get needsDisplayUpdate(){return!!this._features&&!E(this._features,this.displayingFeatures,this.featureLimit)}intersects(t){return null==t||!this.descriptor.extent||(i(t,S),r(this.descriptor.extent,S))}intersectionIncludingBorrowed(t,e){const s=null!=this.extentIncludingBorrowedFeatures?this.extentIncludingBorrowedFeatures:this.descriptor.extent;return t||s?(null!=t?(i(t,e),h(e,s,e)):u(e,s),e):(u(e,a),e)}_shuffle(e){this._features&&(this._features.sort(((t,s)=>l(t,e)-l(s,e))),t(this._features,d),this._shuffled=!0,this._estimatedUnusedSizeDirty=!0)}reduceFeatures(t,e,s){if(t<=0)return!1;if(!this._features)return this.featureLimit=0,!1;let i=!1;this.featureLimit=Math.ceil(this.numFeatures*t),this.featureLimit>this._features.length&&(this.featureLimit=this._features.length,this.fetchStatus===g.DONE&&this._features.length>0&&(this.fetchStatus=g.REFETCH_NEEDED,i=!0)),!this._shuffled&&t<1&&this._shuffle(s);const r=Math.max(this.featureLimit,Math.ceil(e*this.numFeatures));return this._features.length>r&&(this._features.length=r,this._featuresLength.value=r,this.featuresMissing=!0,this.fetchStatus===g.FULL&&(this.fetchStatus=g.DONE)),i}get cache(){return new o(this,this._features,this._numFeatures,this._emptyFeatureRatio.value)}set cache(t){this.requestController=null,this._availableFields=t.availableFields,this._features=t.features,this._featuresLength.value=t.features?.length??0,this._numFeatures=t.numFeatures,this._emptyFeatureRatio.value=t.emptyFeatureRatio,this.fetchStatus=t.fetchStatus,this.featuresMissing=t.featuresMissing,this._estimatedSize=-1,this._estimatedUnusedSizeDirty=!0}}const c=-1,F=-2;var g;!function(t){t[t.FETCH_NEEDED=0]="FETCH_NEEDED",t[t.REFETCH_NEEDED=1]="REFETCH_NEEDED",t[t.FETCHING=2]="FETCHING",t[t.REFETCHING=3]="REFETCHING",t[t.DONE=4]="DONE",t[t.FULL=5]="FULL"}(g||(g={}));class o{constructor(t,e,s,i){this.features=e,this.numFeatures=s,this.emptyFeatureRatio=i,this.cachedMemory=16+t.estimatedSize,this.availableFields=t.availableFields,this.fetchStatus=t.fetchStatus,this.featuresMissing=t.featuresMissing}}function E(t,e,s){if(null==e||null==t||s!==e.length||s>t.length)return!1;for(let i=0;i<s;++i)if(t[i]!==e[i])return!1;return!0}const S=s();export{m as FeatureTile,o as FeatureTileCacheItem,g as FetchStatus,F as failedFeatureCount};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import s from"../../../../core/Logger.js";import{getOrCreateMapValue as i}from"../../../../core/MapUtils.js";import{isAbortError as r,throwIfAborted as a}from"../../../../core/promiseUtils.js";import n from"../../../../core/ReactiveMap.js";import{on as o,watch as u}from"../../../../core/reactiveUtils.js";import{schedule as l}from"../../../../core/scheduling.js";import{signal as h}from"../../../../core/signal.js";import{sqlAnd as d}from"../../../../core/sql.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as f,equals as _,clone as m,expand as g,toExtent as F}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as y,hasVertices as T}from"../../../../layers/graphics/dehydratedFeatures.js";import x from"../../../../rest/support/QuantizationParameters.js";import E from"../../../../rest/support/Query.js";import{ViewingMode as R}from"../../../ViewingMode.js";import{MultiFeatureReference as v,SingleFeatureReference as C}from"./featureReference.js";import{failedFeatureCount as b,FetchStatus as D,FeatureTile as w}from"./FeatureTile.js";import{tilesAreRelated as M}from"../../terrain/tileUtils.js";import{ImmediateTask as U,TaskPriority as O}from"../../../support/Scheduler.js";let j=class extends t{set maximumNumberOfFeatures(e){e=e||1/0;const t=this._get("maximumNumberOfFeatures");e===t||e<1||(this._set("maximumNumberOfFeatures",e),this._maximumFeaturesUpdated(t,e))}set memoryFactor(e){this.memoryFactor!==e&&(this._set("memoryFactor",e),this._setDirty())}set lodFactor(e){this.lodFactor!==e&&(this._set("lodFactor",e),this._supportsResolution&&this.refetch())}get useTileCount(){return this._useTileCount&&null!=this.context.query.queryFeatureCount}set useTileCount(e){this._useTileCount=e,this.notifyChange("useTileCount")}get updating(){return this._dirty||!!this._pendingEdits||this._isFetching||(this.tileDescriptors?.updating??!1)}get memoryForUnusedFeatures(){let e=0;return this._featureTiles.forEach((t=>e+=t.estimatedUnusedSize)),e}get totalVertices(){let e=0;return this._featureTiles.forEach((t=>e+=t.numVertices)),e}get totalFeatures(){let e=0;return this._featureTiles.forEach((t=>e+=t.numFeatures)),e}get hasAllFeatures(){if(this._paused||this.dataUpdating)return!1;for(const e of this._featureTiles.values())if(!this.hasFullGeometries&&0!==e.emptyFeatureRatio||!e.hasAllFeatures)return!1;return!0}get hasFullGeometries(){if(!this._supportsResolution)return!0;return this.tileDescriptors.some(A)||!this.context.capabilities.supportsQuantization&&"polyline"!==this.context.geometryType}set filterExtent(e){if(null!=e&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference))return void s.getLogger(this).error("#filterExtent=","extent needs to be in the same spatial reference as the tiling scheme");const t=this._get("filterExtent");if(t===e||null!=t&&e&&t.equals(e))return;const i=null!=e?e.clone():null;this._set("filterExtent",i),this._reclip(i,t)}_updateTileZQuantization(e){if(this.context.viewingMode===R.Global){const t=e.computeZQuantizationFactor();this._zQuantizationFactor.value<t&&(this._zQuantizationFactor.value=t)}}get _tileZQuantization(){return this.context.isDraped?1:this._zQuantizationFactor.value}constructor(e){super(e),this._useTileCount=!1,this.dataUpdating=!1,this.running=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this._fullRatio=1,this._farRatio=1,this._zQuantizationFactor=h(1),this._changes={updates:{adds:new Array,removes:new Array},adds:new Array,removes:new Array},this._frameTask=U,this._featureTiles=new n,this._displayingFeatureReferences=new Map,this._numDisplayingFeatureReferences=0,this._dirty=!1,this._suspended=!0,this._pendingEdits=null,this._applyEditsTilesUpdated=!1,this._isFetching=!1}initialize(){this.addHandles([o((()=>this.tileDescriptors),"change",(()=>this._setDirty()),{sync:!0,onListenerAdd:()=>this._setDirty()}),u((()=>this._tileZQuantization),(()=>this.refetch()))]),this._objectIdField=this.context.objectIdField,this.FeatureReferenceClass=this.context.capabilities.supportsMultipleResolutions?v:C;const e=this.context.scheduler;null!=e&&(this._frameTask=e.registerTask(O.FEATURE_TILE_FETCHER,this)),this._setDirty()}destroy(){this._frameTask.remove(),this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._removeTile(e)})),this._featureTiles.clear(),this._displayingFeatureReferences.clear(),this._pendingEdits?.controller.abort(),this._pendingEdits=null}get _paused(){return this._suspended||!!this._pendingEdits}restart(){this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._clearTile(e),this._resetFetchTile(e)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._resetFetchTile(e)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}suspend(){this._suspended||(this._suspended=!0,this._pause(),this._setDirty())}resume(){this._suspended&&(this._suspended=!1,this._unpause())}getMissingAttributesForFeature(e){for(const t of this._featureTiles.values()){const s=t.missingAttributes?.get(e);if(null!=s)return s}}_pause(){this._paused&&(this._featureTiles.forEach((e=>this._cancelFetchTile(e))),this._updated())}_unpause(){this._paused||this._setDirty()}get availableFields(){let e=null;return this._featureTiles.forEach((t=>{null!=t.displayingFeatures&&0!==t.displayingFeatures.length&&(null==e?e=new Set(t.availableFields):e.forEach((s=>{t.availableFields?.has(s)||e.delete(s)})))})),null!=e?e:new Set}applyEdits(e){this._pendingEdits||(this._pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());const t=this._pendingEdits;t.count++;const s=t.edits.then((()=>e.result.catch((e=>{if(r(e))throw e;return null})).then((e=>e?(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then((()=>e))):e)).then((e=>(0==--t.count&&(this._pendingEdits===t&&(this._pendingEdits=null),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._applyEditsTilesUpdated=!1,this._unpause()),e)))));return t.edits=s,this._updated(),s}_applyEditsDeleteFeatures(e){if(0===e.length)return;const t=this.context.globalIdField,i=t&&this.availableFields.has(t),r=new Set,a=this._objectIdField;e.forEach((({objectId:e,globalId:n})=>{(!e||e<0)&&t&&n&&(i||s.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(n,a,t)),null!=e&&e>=0&&r.add(e)})),this._featureTiles.forEach((e=>{if(!e.features)return;const t=e.features.filter((e=>!r.has(y(e,this._objectIdField))));t.length!==e.features.length&&(this._applyEditsTileUpdated(),e.setFeatures(t,0,e.availableFields,e.missingAttributes),this._updateTileZQuantization(e),this._invalidateCounts())}))}_objectIdFromGlobalId(e,t,s){if(null==e)return null;const i=this.features.find((t=>t.attributes?.[s]===e));return i?y(i,t):null}async _applyEditsAddUpdateFeatures(e,t,i){const{objectIdField:r,globalIdField:a}=this.context,n=a&&this.availableFields.has(a),o=new Set,u=new Set;for(const s of e){const e=s.objectId;null!=e&&o.add(e)}for(const{objectId:h,globalId:d}of t){let e=h;(null==e||e<0)&&a&&(n||s.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${a} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(d,r,a)),null!=e&&e>=0&&(o.add(e),u.add(e))}if(0===o.size)return;const l=[];this._featureTiles.forEach((e=>{const t=this._applyEditsAddUpdateTile(e,o,u,i);t&&l.push(t)})),this._updated(),await Promise.allSettled(l)}async _applyEditsAddUpdateTile(e,t,s,i){if(!e.features)return;e.fetchingResolution=e.descriptor.resolution;const r=this._createQuery(e);r.resultType=void 0,r.cacheHint=!1,r.objectIds=Array.from(t);const a=await this._queryFeatures(r,i);let n=null;if(s.size>0){const t=e.features.filter((e=>!s.has(y(e,this._objectIdField))));t.length!==e.features.length&&(n=t)}if(a.features.length>0){n||(n=e.features.slice());for(const e of a.features)n.push(e)}n&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,n.length)),this._applyEditsTileUpdated(),e.setFeatures(n,0,Q(e.availableFields,a.fields),z(e.missingAttributes,a.missingAttributes)),this._updateTileZQuantization(e),this._invalidateCounts())}_applyEditsTileUpdated(){this._applyEditsTilesUpdated||(this._applyEditsTilesUpdated=!0,this._updated())}_queryFeatures(e,t){return this.context.query.queryFeaturesDehydrated(e,{signal:t,timeout:H})}_setDirty(){this._dirty=!0,this._updated()}runTask(e){const t=this._frameTask.processQueue(e);if(!this._dirty||!this.initialized)return t;this._dirty=!1;const s=this._getListOfTiles();if(this._markTilesNotAlive(s),!e.run((()=>this._addTiles(s,e)))||!e.run((()=>this._filterExtentTiles(s,e)))||!e.run((()=>this._removeTiles(s,e)))||e.done)return void this._setDirty();const i=this._sortTiles(s);e.run((()=>this._showTiles(i,e)))&&e.run((()=>this._fetchTiles(i,e)))&&e.run((()=>this._updateMemoryEstimates(i,e)))||this._setDirty(),this._updated(),this.updating||this._updateMaximumNumberOfFeaturesExceeded()}_markTilesNotAlive(e){for(const t of e)t.alive=!1}_addTiles(e,t){return!(this._suspended||!this.tileDescriptors)&&(this.tileDescriptors.forEach((s=>{const i=this._featureTiles.get(s.id);i?i.alive=!0:t.done||(e.push(this._addTile(s)),t.madeProgress())})),t.hasProgressed)}_filterExtentTiles(e,t){for(const s of e){if(t.done)break;s.alive&&(s.filtered=!s.intersects(this.filterExtent),s.filtered&&(this._clearTile(s),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let s=e.length-1;s>=0&&!t.done;s--){const i=e[s];i.alive||(this._removeTile(i),s!==e.length-1&&(e[s]=e[e.length-1]),e.pop(),t.madeProgress())}return t.hasProgressed}_sortTiles(e){return e.sort(((e,t)=>e.descriptor.loadPriority-t.descriptor.loadPriority)),e}_showTiles(e,t){const s=this._updateRatio(e),i=e=>{const t=this._fullRatio<1?s(e)*this._farRatio:1;return e.reduceFeatures(t,this.memoryFactor,this._objectIdField)&&this._setDirty(),(e.features?.length??0)>0&&e.fetchingResolution!==e.descriptor.resolution&&e.fetchStatus===D.DONE&&(e.fetchStatus=D.REFETCH_NEEDED,this._setDirty()),this._showTile(e)};for(const r of e)if(!t.run((()=>i(r)))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this._paused)return!1;let i=!1;for(const s of e){if(!s.needsFetching)continue;const e=null!=this.context.memoryCache?this.context.memoryCache.pop(s.id):null;if(null==e){if(this._needsNumFeatures(s)){const e=new AbortController,r=this._fetchTileCount(s,e.signal);this._handleRequest(s,r,e,(()=>s.numFeatures=b)),i=!0,t.madeProgress()}if(t.done)return!0}else s.cache=e,s.numFeatures&&this._notifyDataUpdating(),this._setDirty(),this._scheduleUpdated(),t.madeProgress()}if(i)return t.hasProgressed;for(const r of e)if(r.needsFetching){const e=new AbortController,i=this._fetchTile(r,e.signal);if(this._handleRequest(r,i,e,(e=>{r.setFeatures([],0,null,void 0),this._invalidateCounts(),r.featuresMissing=!1,r.fetchFailed=!0,this.context.logFetchError(s.getLogger(this),e)})),t.madeProgress())return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some((e=>!t.run((()=>e.updateMemoryEstimates()))&&(this._setDirty(),!0))),t.hasProgressed}_reclip(e,t){if(!this.initialized)return;const s=new Array;this._featureTiles.forEach((i=>{null!=i.displayingFeatures&&0!==i.displayingFeatures.length&&(i.intersectionIncludingBorrowed(t,L),i.intersectionIncludingBorrowed(e,q),_(L,q)||s.push(i))})),this._refreshDisplayingFeatures(s),this._updated()}_refreshDisplayingFeatures(e){const t=new Set,s=this._changes.updates;for(const i of e)if(null!=i.displayingFeatures)for(const e of i.displayingFeatures){const i=y(e,this._objectIdField);if(t.has(i))continue;t.add(i);const r=this._displayingFeatureReferences.get(i).feature;s.removes.push(r),s.adds.push(r)}this._applyChanges()}_updated(){let e=0;if(this._paused||this._featureTiles.forEach((t=>t.isFetching?++e:0)),this._isFetching=e>0,this._set("running",this._dirty),e>0||this._applyEditsTilesUpdated?this._notifyDataUpdating():this._dirty||this._set("dataUpdating",!1),this.updating){let t=0,s=0,i=0,r=0,a=0;const n=this._displayingFeatureReferences.size/this._numDisplayingFeatureReferences;this._featureTiles.forEach((e=>{if(++s,e.isFetching&&e.hasPreciseFeatureCount){const t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),s=null!=e.displayingFeatures?e.displayingFeatures.length*n:0;a+=t-s}e.needsFetching?++r:e.numFeatures>0&&(++i,t+=e.numFeatures)})),r+=e;let o=0,u=0;t?(u=t,o=Math.min(r*t/i,t)):(u=s,o=r),a=Math.min(this.maximumNumberOfFeatures-this.features.length,a),this._set("updatingTotal",u),this._set("updatingRemaining",o),this._set("expectedFeatureDiff",a)}else this._set("updatingTotal",0),this._set("updatingRemaining",0),this._set("expectedFeatureDiff",0);this.debugger&&this.debugger.update()}_updateMaximumNumberOfFeaturesExceeded(){for(const{perTileMaximumNumberOfFeaturesExceeded:e}of this._featureTiles.values())if(e)return void this._set("maximumNumberOfFeaturesExceeded",!0);this._set("maximumNumberOfFeaturesExceeded",!1)}_updateRatio(e){const t=I(e),s=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0]));let i=0,r=0;for(const a of e){const e=a.numFeatures;i+=e,r+=e*s(a)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/i),this._farRatio=this.maximumNumberOfFeatures/r,this._scheduleUpdated(),s}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this._featureTiles.forEach((e=>{if(!e.featuresMissing)return;const t=this._maximumFeaturesForTile(e);e.features&&(e.features.length>=t||e.fetchStatus===D.FULL)||(this._cancelFetchTile(e),this._resetFetchTile(e))})),this._setDirty())}_addTile(e){const t=new w(e);return this._featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){const t=e.displayingResolution;this._featureTiles.forEach((s=>{if(null!=s.displayingFeatures&&e!==s&&M(e.descriptor.lij,s.descriptor.lij)){null==e.displayingFeatures&&(e.displayingFeatures=[]),e.descriptor.extent&&s.descriptor.extent&&(null==e.extentIncludingBorrowedFeatures&&(e.extentIncludingBorrowedFeatures=m(e.descriptor.extent)),g(e.extentIncludingBorrowedFeatures,s.descriptor.extent,e.extentIncludingBorrowedFeatures));for(const i of s.displayingFeatures){e.displayingFeatures.push(i);const s=this._displayingFeatureReferences.get(y(i,this._objectIdField));s.ref(s.feature,t),this._numDisplayingFeatureReferences++}}})),e.featureLimit=null!=e.displayingFeatures?e.displayingFeatures.length:0}_removeTile(e){this._clearTile(e),this._featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetching&&(e.fetchStatus=D.DONE):e.fetchStatus=D.FETCH_NEEDED}_cancelFetchTile(e){const t=e.requestController;null!=t&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){return e.numFeatures=await this._fetchCount(e,t),this._updateRatio(this._getListOfTiles()),e.fetchStatus===D.REFETCHING?D.REFETCH_NEEDED:D.FETCH_NEEDED}async _fetchTile(e,t){e.fetchFailed=!1;const s=this._maximumFeaturesForTile(e);if(s<=0)return e.hasPreciseFeatureCount&&0===e.numFeatures||(e.fetchFailed=!0),P(e);const i=this._getMaxRecordCount(e),r=Math.ceil(s/i);if(e.fetchingResolution=e.descriptor.resolution,A(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=s&&r>E.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);const n=this._createQuery(e);if(n.maxRecordCountFactor=r,e.isRefetching&&e.features&&e.features.length>0){const t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/i);n.maxRecordCountFactor=Math.max(t+1,n.maxRecordCountFactor)}const{features:o,exceededTransferLimit:u,fields:l,missingAttributes:h}=await this._queryFeatures(n,t),d=u?n.maxRecordCountFactor>=E.MAX_MAX_RECORD_COUNT_FACTOR?D.FULL:D.DONE:D.FULL;return await this._frameTask.schedule((()=>{e.featuresMissing=e.hasPreciseFeatureCount&&o.length<e.numFeatures||!!u;const t=this._removeEmptyFeatures(o);e.setFeatures(o,t,N(l),z(void 0,h)),this._updateTileZQuantization(e)}),t),a(t),this._invalidateCounts(),d}async _fetchCount(e,t){return this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t})}async _fetchPagedTile(e,t){let s,i=0,r=0,n=0,o=this._maximumFeaturesForTile(e)-n;const u=this._getMaxRecordCount(e);let l,h=null;for(;;){const d=this._createQuery(e),c=this._setPagingParameters(d,i,o,u),{features:p,exceededTransferLimit:f,fields:_,missingAttributes:m}=await this._queryFeatures(d,t);if(await this._frameTask.schedule((()=>{c&&(i+=d.num),n+=p.length,r+=this._removeEmptyFeatures(p),e.featuresMissing=c&&e.hasPreciseFeatureCount&&i<e.numFeatures||!!f,s=s?s.concat(p):p,h=Q(h,_),l=z(l,m),e.setFeatures(s,r,h,l),this._updateTileZQuantization(e)}),t),a(t),this._invalidateCounts(),this._setDirty(),o=this._maximumFeaturesForTile(e)-n,!c||!f||o<=0)return f?D.DONE:D.FULL}}_createFeatureCountQuery(e){const t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e){const t=this.context.createQuery(),s=A(e);return s||(t.geometry=F(e.descriptor.extent,this.context.tilingScheme.spatialReference)),this._setResolutionParams(t,e),this._useTileQuery(e)?t.resultType="tile":this.context.capabilities.supportsCacheHint&&(t.cacheHint=!0),!s&&this.context.effectiveDisplayFilter&&(t.where=d(t.where,this.context.effectiveDisplayFilter.where)),t}_setPagingParameters(e,t,s,i){return!!this.context.capabilities.supportsPagination&&(e.start=t,s>0&&this.context.capabilities.supportsMaxRecordCountFactor?(e.maxRecordCountFactor=Math.ceil(s/i),e.num=Math.min(e.maxRecordCountFactor*i,s)):e.num=Math.min(i),!0)}_getEffectiveTileResolution(e){if(A(e))return null;const t=this.context.viewingMode===R.Global?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.fetchingResolution,t)/this.lodFactor/this._tileZQuantization}get _supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&"point"!==this.context.geometryType}_setResolutionParams(e,t){if(!this._supportsResolution)return;const s=this._getEffectiveTileResolution(t);null!=s&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new x({mode:"view",originPosition:"upper-left",tolerance:s,extent:this.context.fullExtent}):"polyline"===this.context.geometryType&&(e.maxAllowableOffset=s))}_removeEmptyFeatures(e){const t=e.length;for(let s=0;s<e.length;){const t=e[s];T(t.geometry)?++s:(e[s]=e[e.length-1],--e.length)}return t-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!A(e)}_getMaxRecordCount(e){const{tileMaxRecordCount:t,maxRecordCount:s}=this.context;return this._useTileQuery(e)&&null!=t&&t>0&&this.context.capabilities.supportsResultType?t:null!=s&&s>0?s:S}_useTileQuery(e){return(!A(e)||!this.context.capabilities.supportsCacheHint)&&this.context.capabilities.supportsResultType}_handleRequest(e,t,s,i){e.fetchStatus=e.needsRefetching?D.REFETCHING:D.FETCHING,e.requestController=s;let a=!1;t.then((t=>{e.requestController=null,e.fetchStatus=t})).catch((t=>{e.requestController===s&&(e.requestController=null,e.fetchStatus=D.DONE),r(t)?a=!0:i(t)})).then((()=>{a||this._setDirty(),this._scheduleUpdated()}))}_scheduleUpdated(){this.hasHandles("scheduleUpdated")||this.addHandles(l((()=>{this.removeHandles("scheduleUpdated"),this._updated()})),"scheduleUpdated")}_showTile(e){if(null!=e.displayingFeatures&&!e.needsDisplayUpdate)return!1;const{features:t}=e;if(0===e.featureLimit||!t){const t=null!=e.displayingFeatures&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}const s=e.fetchingResolution,{adds:i,updates:r}=this._changes,a=Math.min(e.featureLimit,t.length);e.featureLimit=a;for(let n=0;n<a;++n){const e=t[n],a=y(e,this._objectIdField),o=this._displayingFeatureReferences.get(a);if(o){const{oldVersion:t,newVersion:i}=o.ref(e,s);t!==i&&(t&&r.removes.push(t),i&&r.adds.push(i))}else this._displayingFeatureReferences.set(a,new this.FeatureReferenceClass(e,s)),i.push(e);this._numDisplayingFeatureReferences++}return this._hideTileFeatures(e),e.displayingResolution=e.fetchingResolution,this._applyChanges(),e.displayingFeatures=t.slice(0,a),!0}_hideTile(e){this._cancelFetchTile(e),this._hideTileFeatures(e)}_hideTileFeatures(e){if(null==e.displayingFeatures)return;const{updates:t,removes:s}=this._changes;for(const i of e.displayingFeatures){const r=y(i,this._objectIdField),a=this._displayingFeatureReferences.get(r);if(!a)continue;const{oldVersion:n,newVersion:o}=a.unref(e.displayingResolution);this._numDisplayingFeatureReferences--,n!==o&&(null==o?(this._displayingFeatureReferences.delete(r),n&&s.push(n)):(t.adds.push(o),n&&t.removes.push(n)))}this._applyChanges(),e.displayingFeatures=null}_notifyDataUpdating(){this._get("dataUpdating")||this._set("dataUpdating",!0)}_applyChanges(){const e=this._changes.updates;e.removes.length>0&&(this._notifyDataUpdating(),this.features.removeMany(e.removes),e.removes.length=0),e.adds.length>0&&(this._notifyDataUpdating(),this.features.addMany(e.adds),e.adds.length=0);const t=this._changes.adds,s=this._changes.removes,i=Math.min(t.length,s.length);let r=0;for(;r<i;){const e=Math.min(r+k,i);this._notifyDataUpdating(),this.features.addMany(t.slice(r,e)),this.features.removeMany(s.slice(r,e)),r=e}t.length>i&&(this._notifyDataUpdating(),this.features.addMany(0===r?t:t.slice(r))),s.length>i&&(this._notifyDataUpdating(),this.features.removeMany(0===r?s:s.slice(r))),t.length=0,s.length=0}_clearTile(e){this._hideTile(e),e.features&&null!=this.context.memoryCache&&this.context.memoryCache.put(e.id,e.cache),e.setFeatures(null,0,null,void 0),this._invalidateCounts()}_invalidateCounts(){this.notifyChange("totalVertices"),this.notifyChange("totalFeatures"),this.notifyChange("memoryForUnusedFeatures")}_getListOfTiles(){return Array.from(this._featureTiles.values())}get storedFeatures(){return this._getListOfTiles().reduce(((e,t)=>e+(t.features?t.features.length:0)),0)}get missingTiles(){return Array.from(this._featureTiles.values()).reduce(((e,t)=>e+(t.needsFetching||t.isFetching?1:0)),0)}_maximumFeaturesForTile(e){const t=e.hasPreciseFeatureCount?e.numFeatures:1/0,s=e.hasPreciseFeatureCount?t:this.maximumNumberOfFeatures,i=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(s*i/(1-e.emptyFeatureRatio)),t)}get test(){}};function A(e){return"dummy-tile-full-extent"===e.id}function I(e){let t=0;for(const s of e)s.features&&s.features.length>0&&s.alive&&(t=Math.max(t,s.descriptor.lij[0]));return t}function P(e){return e.setFeatures([],0,null,void 0),e.featuresMissing=!1,D.DONE}function N(e){return null==e?new Set:new Set(e.map((e=>e.name)))}function Q(e,t){if(null==e||null==t)return N(t);const s=new Set;for(const{name:i}of t)e.has(i)&&s.add(i);return s}function z(e,t){if(!t?.length)return e;e??=new Map;const s=()=>new Set;for(const{objectId:r,attribute:a}of t)i(e,r,s).add(a);return e}e([c({constructOnly:!0})],j.prototype,"features",void 0),e([c()],j.prototype,"tileDescriptors",void 0),e([c({value:1/0})],j.prototype,"maximumNumberOfFeatures",null),e([c({value:1})],j.prototype,"memoryFactor",null),e([c({value:1})],j.prototype,"lodFactor",null),e([c()],j.prototype,"useTileCount",null),e([c({readOnly:!0})],j.prototype,"updating",null),e([c({readOnly:!0})],j.prototype,"dataUpdating",void 0),e([c({readOnly:!0})],j.prototype,"running",void 0),e([c({readOnly:!0})],j.prototype,"updatingTotal",void 0),e([c({readOnly:!0})],j.prototype,"updatingRemaining",void 0),e([c({readOnly:!0})],j.prototype,"expectedFeatureDiff",void 0),e([c({readOnly:!0})],j.prototype,"memoryForUnusedFeatures",null),e([c({readOnly:!0})],j.prototype,"maximumNumberOfFeaturesExceeded",void 0),e([c({readOnly:!0})],j.prototype,"totalVertices",null),e([c({readOnly:!0})],j.prototype,"totalFeatures",null),e([c({readOnly:!0})],j.prototype,"hasAllFeatures",null),e([c({readOnly:!0})],j.prototype,"hasFullGeometries",null),e([c()],j.prototype,"filterExtent",null),e([c({constructOnly:!0})],j.prototype,"context",void 0),e([c()],j.prototype,"_dirty",void 0),e([c()],j.prototype,"_suspended",void 0),e([c()],j.prototype,"_pendingEdits",void 0),e([c()],j.prototype,"_applyEditsTilesUpdated",void 0),e([c()],j.prototype,"_paused",null),e([c()],j.prototype,"_isFetching",void 0),j=e([p("esri.views.3d.layers.support.FeatureTileFetcher3D")],j);const S=2e3,L=f(),q=f(),H=6e5,k=200;export{j as FeatureTileFetcher3D};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import s from"../../../../core/Logger.js";import{getOrCreateMapValue as i}from"../../../../core/MapUtils.js";import{isAbortError as r,throwIfAborted as a}from"../../../../core/promiseUtils.js";import n from"../../../../core/ReactiveMap.js";import{on as o,watch as u}from"../../../../core/reactiveUtils.js";import{schedule as l}from"../../../../core/scheduling.js";import{signal as h}from"../../../../core/signal.js";import{sqlAnd as d}from"../../../../core/sql.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as f,equals as _,clone as m,expand as g,toExtent as F}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as y,hasVertices as T}from"../../../../layers/graphics/dehydratedFeatures.js";import x from"../../../../rest/support/QuantizationParameters.js";import E from"../../../../rest/support/Query.js";import{ViewingMode as R}from"../../../ViewingMode.js";import{MultiFeatureReference as v,SingleFeatureReference as C}from"./featureReference.js";import{failedFeatureCount as b,FetchStatus as D,FeatureTile as w}from"./FeatureTile.js";import{tilesAreRelated as M}from"../../terrain/tileUtils.js";import{ImmediateTask as U,TaskPriority as O}from"../../../support/Scheduler.js";let j=class extends t{set maximumNumberOfFeatures(e){e=e||1/0;const t=this._get("maximumNumberOfFeatures");e===t||e<1||(this._set("maximumNumberOfFeatures",e),this._maximumFeaturesUpdated(t,e))}set memoryFactor(e){this.memoryFactor!==e&&(this._set("memoryFactor",e),this._setDirty())}set lodFactor(e){this.lodFactor!==e&&(this._set("lodFactor",e),this._supportsResolution&&this.refetch())}get useTileCount(){return this._useTileCount&&null!=this.context.query.queryFeatureCount}set useTileCount(e){this._useTileCount=e,this.notifyChange("useTileCount")}get updating(){return this._dirty||!!this._pendingEdits||this._isFetching||(this.tileDescriptors?.updating??!1)}get memoryForUnusedFeatures(){let e=0;return this._featureTiles.forEach((t=>e+=t.estimatedUnusedSize)),e}get totalVertices(){let e=0;return this._featureTiles.forEach((t=>e+=t.numVertices)),e}get totalFeatures(){let e=0;return this._featureTiles.forEach((t=>e+=t.numFeatures)),e}get hasAllFeatures(){if(this._paused||this.dataUpdating)return!1;for(const e of this._featureTiles.values())if(!this.hasFullGeometries&&0!==e.emptyFeatureRatio||!e.hasAllFeatures)return!1;return!0}get hasFullGeometries(){if(!this._supportsResolution)return!0;return this.tileDescriptors.some(A)||!this.context.capabilities.supportsQuantization&&"polyline"!==this.context.geometryType}set filterExtent(e){if(null!=e&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference))return void s.getLogger(this).error("#filterExtent=","extent needs to be in the same spatial reference as the tiling scheme");const t=this._get("filterExtent");if(t===e||null!=t&&e&&t.equals(e))return;const i=null!=e?e.clone():null;this._set("filterExtent",i),this._reclip(i,t)}_updateTileZQuantization(e){if(this.context.viewingMode===R.Global){const t=e.computeZQuantizationFactor();this._zQuantizationFactor.value<t&&(this._zQuantizationFactor.value=t)}}get _tileZQuantization(){return this.context.isDraped?1:this._zQuantizationFactor.value}constructor(e){super(e),this._useTileCount=!1,this.dataUpdating=!1,this.running=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this._fullRatio=1,this._farRatio=1,this._zQuantizationFactor=h(1),this._changes={updates:{adds:new Array,removes:new Array},adds:new Array,removes:new Array},this._frameTask=U,this._featureTiles=new n,this._displayingFeatureReferences=new Map,this._numDisplayingFeatureReferences=0,this._dirty=!1,this._suspended=!0,this._pendingEdits=null,this._applyEditsTilesUpdated=!1,this._isFetching=!1}initialize(){this.addHandles([o((()=>this.tileDescriptors),"change",(()=>this._setDirty()),{sync:!0,onListenerAdd:()=>this._setDirty()}),u((()=>this._tileZQuantization),(()=>this.refetch()))]),this._objectIdField=this.context.objectIdField,this.FeatureReferenceClass=this.context.capabilities.supportsMultipleResolutions?v:C;const e=this.context.scheduler;null!=e&&(this._frameTask=e.registerTask(O.FEATURE_TILE_FETCHER,this)),this._setDirty()}destroy(){this._frameTask.remove(),this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._removeTile(e)})),this._featureTiles.clear(),this._displayingFeatureReferences.clear(),this._pendingEdits?.controller.abort(),this._pendingEdits=null}get _paused(){return this._suspended||!!this._pendingEdits}restart(){this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._clearTile(e),this._resetFetchTile(e)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._resetFetchTile(e)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}suspend(){this._suspended||(this._suspended=!0,this._pause(),this._setDirty())}resume(){this._suspended&&(this._suspended=!1,this._unpause())}getMissingAttributesForFeature(e){for(const t of this._featureTiles.values()){const s=t.missingAttributes?.get(e);if(null!=s)return s}}_pause(){this._paused&&(this._featureTiles.forEach((e=>this._cancelFetchTile(e))),this._updated())}_unpause(){this._paused||this._setDirty()}get availableFields(){let e=null;return this._featureTiles.forEach((t=>{null!=t.displayingFeatures&&0!==t.displayingFeatures.length&&(null==e?e=new Set(t.availableFields):e.forEach((s=>{t.availableFields?.has(s)||e.delete(s)})))})),null!=e?e:new Set}applyEdits(e){this._pendingEdits||(this._pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());const t=this._pendingEdits;t.count++;const s=t.edits.then((()=>e.result.catch((e=>{if(r(e))throw e;return null})).then((e=>e?(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then((()=>e))):e)).then((e=>(0==--t.count&&(this._pendingEdits===t&&(this._pendingEdits=null),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._applyEditsTilesUpdated=!1,this._unpause()),e)))));return t.edits=s,this._updated(),s}_applyEditsDeleteFeatures(e){if(0===e.length)return;const t=this.context.globalIdField,i=t&&this.availableFields.has(t),r=new Set,a=this._objectIdField;e.forEach((({objectId:e,globalId:n})=>{(!e||e<0)&&t&&n&&(i||s.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(n,a,t)),null!=e&&e>=0&&r.add(e)})),this._featureTiles.forEach((e=>{if(!e.features)return;const t=e.features.filter((e=>!r.has(y(e,this._objectIdField))));t.length!==e.features.length&&(this._applyEditsTileUpdated(),e.setFeatures(t,0,e.availableFields,e.missingAttributes),this._updateTileZQuantization(e),this._invalidateCounts())}))}_objectIdFromGlobalId(e,t,s){if(null==e)return null;const i=this.features.find((t=>t.attributes?.[s]===e));return i?y(i,t):null}async _applyEditsAddUpdateFeatures(e,t,i){const{objectIdField:r,globalIdField:a}=this.context,n=a&&this.availableFields.has(a),o=new Set,u=new Set;for(const s of e){const e=s.objectId;null!=e&&o.add(e)}for(const{objectId:h,globalId:d}of t){let e=h;(null==e||e<0)&&a&&(n||s.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${a} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(d,r,a)),null!=e&&e>=0&&(o.add(e),u.add(e))}if(0===o.size)return;const l=[];this._featureTiles.forEach((e=>{const t=this._applyEditsAddUpdateTile(e,o,u,i);t&&l.push(t)})),this._updated(),await Promise.allSettled(l)}async _applyEditsAddUpdateTile(e,t,s,i){if(!e.features)return;e.fetchingResolution=e.descriptor.resolution;const r=this._createQuery(e);r.resultType=void 0,r.cacheHint=!1,r.objectIds=Array.from(t);const a=await this._queryFeatures(r,i);let n=null;if(s.size>0){const t=e.features.filter((e=>!s.has(y(e,this._objectIdField))));t.length!==e.features.length&&(n=t)}if(a.features.length>0){n||(n=e.features.slice());for(const e of a.features)n.push(e)}n&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,n.length)),this._applyEditsTileUpdated(),e.setFeatures(n,0,Q(e.availableFields,a.fields),z(e.missingAttributes,a.missingAttributes)),this._updateTileZQuantization(e),this._invalidateCounts())}_applyEditsTileUpdated(){this._applyEditsTilesUpdated||(this._applyEditsTilesUpdated=!0,this._updated())}_queryFeatures(e,t){return this.context.query.queryFeaturesDehydrated(e,{signal:t,timeout:H})}_setDirty(){this._dirty=!0,this._updated()}runTask(e){const t=this._frameTask.processQueue(e);if(!this._dirty||!this.initialized)return t;this._dirty=!1;const s=this._getListOfTiles();if(this._markTilesNotAlive(s),!e.run((()=>this._addTiles(s,e)))||!e.run((()=>this._filterExtentTiles(s,e)))||!e.run((()=>this._removeTiles(s,e)))||e.done)return void this._setDirty();const i=this._sortTiles(s);e.run((()=>this._showTiles(i,e)))&&e.run((()=>this._fetchTiles(i,e)))&&e.run((()=>this._updateMemoryEstimates(i,e)))||this._setDirty(),this._updated(),this.updating||this._updateMaximumNumberOfFeaturesExceeded()}_markTilesNotAlive(e){for(const t of e)t.alive=!1}_addTiles(e,t){return!(this._suspended||!this.tileDescriptors)&&(this.tileDescriptors.forEach((s=>{const i=this._featureTiles.get(s.id);i?i.alive=!0:t.done||(e.push(this._addTile(s)),t.madeProgress())})),t.hasProgressed)}_filterExtentTiles(e,t){for(const s of e){if(t.done)break;s.alive&&(s.filtered=!s.intersects(this.filterExtent),s.filtered&&(this._clearTile(s),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let s=e.length-1;s>=0&&!t.done;s--){const i=e[s];i.alive||(this._removeTile(i),s!==e.length-1&&(e[s]=e[e.length-1]),e.pop(),t.madeProgress())}return t.hasProgressed}_sortTiles(e){return e.sort(((e,t)=>e.descriptor.loadPriority-t.descriptor.loadPriority)),e}_showTiles(e,t){const s=this._updateRatio(e),i=e=>{const t=this._fullRatio<1?s(e)*this._farRatio:1;return e.reduceFeatures(t,this.memoryFactor,this._objectIdField)&&this._setDirty(),e.numFeatures>0&&e.fetchingResolution!==e.descriptor.resolution&&e.isFetched&&(e.fetchStatus=D.REFETCH_NEEDED,this._setDirty()),this._showTile(e)};for(const r of e)if(!t.run((()=>i(r)))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this._paused)return!1;let i=!1;for(const s of e){if(!s.needsFetch)continue;const e=null!=this.context.memoryCache?this.context.memoryCache.pop(s.id):null;if(null==e){if(this._needsNumFeatures(s)){const e=new AbortController,r=this._fetchTileCount(s,e.signal);this._handleRequest(s,r,e,(()=>s.numFeatures=b)),i=!0,t.madeProgress()}if(t.done)return!0}else s.cache=e,s.numFeatures&&this._notifyDataUpdating(),this._setDirty(),this._scheduleUpdated(),t.madeProgress()}if(i)return t.hasProgressed;for(const r of e)if(r.needsFetch){const e=new AbortController,i=this._fetchTile(r,e.signal);if(this._handleRequest(r,i,e,(e=>{r.setFeatures([],0,null,void 0),this._invalidateCounts(),r.featuresMissing=!1,r.fetchFailed=!0,this.context.logFetchError(s.getLogger(this),e)})),t.madeProgress())return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some((e=>!t.run((()=>e.updateMemoryEstimates()))&&(this._setDirty(),!0))),t.hasProgressed}_reclip(e,t){if(!this.initialized)return;const s=new Array;this._featureTiles.forEach((i=>{null!=i.displayingFeatures&&0!==i.displayingFeatures.length&&(i.intersectionIncludingBorrowed(t,S),i.intersectionIncludingBorrowed(e,q),_(S,q)||s.push(i))})),this._refreshDisplayingFeatures(s),this._updated()}_refreshDisplayingFeatures(e){const t=new Set,s=this._changes.updates;for(const i of e)if(null!=i.displayingFeatures)for(const e of i.displayingFeatures){const i=y(e,this._objectIdField);if(t.has(i))continue;t.add(i);const r=this._displayingFeatureReferences.get(i).feature;s.removes.push(r),s.adds.push(r)}this._applyChanges()}_updated(){let e=0;if(this._paused||this._featureTiles.forEach((t=>t.isFetching?++e:0)),this._isFetching=e>0,this._set("running",this._dirty),e>0||this._applyEditsTilesUpdated?this._notifyDataUpdating():this._dirty||this._set("dataUpdating",!1),this.updating){let t=0,s=0,i=0,r=0,a=0;const n=this._displayingFeatureReferences.size/this._numDisplayingFeatureReferences;this._featureTiles.forEach((e=>{if(++s,e.isFetching&&e.hasPreciseFeatureCount){const t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),s=null!=e.displayingFeatures?e.displayingFeatures.length*n:0;a+=t-s}e.needsFetch?++r:e.numFeatures>0&&(++i,t+=e.numFeatures)})),r+=e;let o=0,u=0;t?(u=t,o=Math.min(r*t/i,t)):(u=s,o=r),a=Math.min(this.maximumNumberOfFeatures-this.features.length,a),this._set("updatingTotal",u),this._set("updatingRemaining",o),this._set("expectedFeatureDiff",a)}else this._set("updatingTotal",0),this._set("updatingRemaining",0),this._set("expectedFeatureDiff",0);this.debugger&&this.debugger.update()}_updateMaximumNumberOfFeaturesExceeded(){for(const{perTileMaximumNumberOfFeaturesExceeded:e}of this._featureTiles.values())if(e)return void this._set("maximumNumberOfFeaturesExceeded",!0);this._set("maximumNumberOfFeaturesExceeded",!1)}_updateRatio(e){const t=I(e),s=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0]));let i=0,r=0;for(const a of e){const e=a.numFeatures;i+=e,r+=e*s(a)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/i),this._farRatio=this.maximumNumberOfFeatures/r,this._scheduleUpdated(),s}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this._featureTiles.forEach((e=>{if(!e.featuresMissing)return;const t=this._maximumFeaturesForTile(e);e.features&&(e.features.length>=t||e.fetchStatus===D.FULL)||(this._cancelFetchTile(e),this._resetFetchTile(e))})),this._setDirty())}_addTile(e){const t=new w(e);return this._featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){const t=e.displayingResolution;this._featureTiles.forEach((s=>{if(null!=s.displayingFeatures&&e!==s&&M(e.descriptor.lij,s.descriptor.lij)){null==e.displayingFeatures&&(e.displayingFeatures=[]),e.descriptor.extent&&s.descriptor.extent&&(null==e.extentIncludingBorrowedFeatures&&(e.extentIncludingBorrowedFeatures=m(e.descriptor.extent)),g(e.extentIncludingBorrowedFeatures,s.descriptor.extent,e.extentIncludingBorrowedFeatures));for(const i of s.displayingFeatures){e.displayingFeatures.push(i);const s=this._displayingFeatureReferences.get(y(i,this._objectIdField));s.ref(s.feature,t),this._numDisplayingFeatureReferences++}}})),e.featureLimit=null!=e.displayingFeatures?e.displayingFeatures.length:0}_removeTile(e){this._clearTile(e),this._featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetch&&(e.fetchStatus=D.DONE):e.fetchStatus=D.FETCH_NEEDED}_cancelFetchTile(e){const t=e.requestController;null!=t&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){return e.numFeatures=await this._fetchCount(e,t),this._updateRatio(this._getListOfTiles()),e.fetchStatus===D.REFETCHING?D.REFETCH_NEEDED:D.FETCH_NEEDED}async _fetchTile(e,t){e.fetchFailed=!1;const s=this._maximumFeaturesForTile(e);if(s<=0)return e.hasPreciseFeatureCount&&0===e.numFeatures||(e.fetchFailed=!0),P(e);const i=this._getMaxRecordCount(e),r=Math.ceil(s/i);if(e.fetchingResolution=e.descriptor.resolution,A(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=s&&r>E.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);const n=this._createQuery(e);if(n.maxRecordCountFactor=r,e.isRefetching&&e.features&&e.features.length>0){const t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/i);n.maxRecordCountFactor=Math.max(t+1,n.maxRecordCountFactor)}const{features:o,exceededTransferLimit:u,fields:l,missingAttributes:h}=await this._queryFeatures(n,t),d=u?n.maxRecordCountFactor>=E.MAX_MAX_RECORD_COUNT_FACTOR?D.FULL:D.DONE:D.FULL;return await this._frameTask.schedule((()=>{e.featuresMissing=e.hasPreciseFeatureCount&&o.length<e.numFeatures||!!u;const t=this._removeEmptyFeatures(o);e.setFeatures(o,t,N(l),z(void 0,h)),this._updateTileZQuantization(e)}),t),a(t),this._invalidateCounts(),d}async _fetchCount(e,t){return this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t})}async _fetchPagedTile(e,t){let s,i=0,r=0,n=0,o=this._maximumFeaturesForTile(e)-n;const u=this._getMaxRecordCount(e);let l,h=null;for(;;){const d=this._createQuery(e),c=this._setPagingParameters(d,i,o,u),{features:p,exceededTransferLimit:f,fields:_,missingAttributes:m}=await this._queryFeatures(d,t);if(await this._frameTask.schedule((()=>{c&&(i+=d.num),n+=p.length,r+=this._removeEmptyFeatures(p),e.featuresMissing=c&&e.hasPreciseFeatureCount&&i<e.numFeatures||!!f,s=s?s.concat(p):p,h=Q(h,_),l=z(l,m),e.setFeatures(s,r,h,l),this._updateTileZQuantization(e)}),t),a(t),this._invalidateCounts(),this._setDirty(),o=this._maximumFeaturesForTile(e)-n,!c||!f||o<=0)return f?D.DONE:D.FULL}}_createFeatureCountQuery(e){const t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e){const t=this.context.createQuery(),s=A(e);return s||(t.geometry=F(e.descriptor.extent,this.context.tilingScheme.spatialReference)),this._setResolutionParams(t,e),this._useTileQuery(e)?t.resultType="tile":this.context.capabilities.supportsCacheHint&&(t.cacheHint=!0),!s&&this.context.effectiveDisplayFilter&&(t.where=d(t.where,this.context.effectiveDisplayFilter.where)),t}_setPagingParameters(e,t,s,i){return!!this.context.capabilities.supportsPagination&&(e.start=t,s>0&&this.context.capabilities.supportsMaxRecordCountFactor?(e.maxRecordCountFactor=Math.ceil(s/i),e.num=Math.min(e.maxRecordCountFactor*i,s)):e.num=Math.min(i),!0)}_getEffectiveTileResolution(e){if(A(e))return null;const t=this.context.viewingMode===R.Global?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.fetchingResolution,t)/this.lodFactor/this._tileZQuantization}get _supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&"point"!==this.context.geometryType}_setResolutionParams(e,t){if(!this._supportsResolution)return;const s=this._getEffectiveTileResolution(t);null!=s&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new x({mode:"view",originPosition:"upper-left",tolerance:s,extent:this.context.fullExtent}):"polyline"===this.context.geometryType&&(e.maxAllowableOffset=s))}_removeEmptyFeatures(e){const t=e.length;for(let s=0;s<e.length;){const t=e[s];T(t.geometry)?++s:(e[s]=e[e.length-1],--e.length)}return t-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!A(e)}_getMaxRecordCount(e){const{tileMaxRecordCount:t,maxRecordCount:s}=this.context;return this._useTileQuery(e)&&null!=t&&t>0&&this.context.capabilities.supportsResultType?t:null!=s&&s>0?s:L}_useTileQuery(e){return(!A(e)||!this.context.capabilities.supportsCacheHint)&&this.context.capabilities.supportsResultType}_handleRequest(e,t,s,i){e.fetchStatus=e.needsRefetch?D.REFETCHING:D.FETCHING,e.requestController=s;let a=!1;t.then((t=>{e.requestController=null,e.fetchStatus=t})).catch((t=>{e.requestController===s&&(e.requestController=null,e.fetchStatus=D.DONE),r(t)?a=!0:i(t)})).then((()=>{a||this._setDirty(),this._scheduleUpdated()}))}_scheduleUpdated(){this.hasHandles("scheduleUpdated")||this.addHandles(l((()=>{this.removeHandles("scheduleUpdated"),this._updated()})),"scheduleUpdated")}_showTile(e){if(null!=e.displayingFeatures&&!e.needsDisplayUpdate)return!1;const{features:t}=e;if(0===e.featureLimit||!t){const t=null!=e.displayingFeatures&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}const s=e.fetchingResolution,{adds:i,updates:r}=this._changes,a=Math.min(e.featureLimit,t.length);e.featureLimit=a;for(let n=0;n<a;++n){const e=t[n],a=y(e,this._objectIdField),o=this._displayingFeatureReferences.get(a);if(o){const{oldVersion:t,newVersion:i}=o.ref(e,s);t!==i&&(t&&r.removes.push(t),i&&r.adds.push(i))}else this._displayingFeatureReferences.set(a,new this.FeatureReferenceClass(e,s)),i.push(e);this._numDisplayingFeatureReferences++}return this._hideTileFeatures(e),e.displayingResolution=e.fetchingResolution,this._applyChanges(),e.displayingFeatures=t.slice(0,a),!0}_hideTile(e){this._cancelFetchTile(e),this._hideTileFeatures(e)}_hideTileFeatures(e){if(null==e.displayingFeatures)return;const{updates:t,removes:s}=this._changes;for(const i of e.displayingFeatures){const r=y(i,this._objectIdField),a=this._displayingFeatureReferences.get(r);if(!a)continue;const{oldVersion:n,newVersion:o}=a.unref(e.displayingResolution);this._numDisplayingFeatureReferences--,n!==o&&(null==o?(this._displayingFeatureReferences.delete(r),n&&s.push(n)):(t.adds.push(o),n&&t.removes.push(n)))}this._applyChanges(),e.displayingFeatures=null}_notifyDataUpdating(){this._get("dataUpdating")||this._set("dataUpdating",!0)}_applyChanges(){const e=this._changes.updates;e.removes.length>0&&(this._notifyDataUpdating(),this.features.removeMany(e.removes),e.removes.length=0),e.adds.length>0&&(this._notifyDataUpdating(),this.features.addMany(e.adds),e.adds.length=0);const t=this._changes.adds,s=this._changes.removes,i=Math.min(t.length,s.length);let r=0;for(;r<i;){const e=Math.min(r+k,i);this._notifyDataUpdating(),this.features.addMany(t.slice(r,e)),this.features.removeMany(s.slice(r,e)),r=e}t.length>i&&(this._notifyDataUpdating(),this.features.addMany(0===r?t:t.slice(r))),s.length>i&&(this._notifyDataUpdating(),this.features.removeMany(0===r?s:s.slice(r))),t.length=0,s.length=0}_clearTile(e){this._hideTile(e),e.features&&null!=this.context.memoryCache&&this.context.memoryCache.put(e.id,e.cache),e.setFeatures(null,0,null,void 0),this._invalidateCounts()}_invalidateCounts(){this.notifyChange("totalVertices"),this.notifyChange("totalFeatures"),this.notifyChange("memoryForUnusedFeatures")}_getListOfTiles(){return Array.from(this._featureTiles.values())}get storedFeatures(){return this._getListOfTiles().reduce(((e,t)=>e+(t.features?t.features.length:0)),0)}get missingTiles(){return Array.from(this._featureTiles.values()).reduce(((e,t)=>e+(t.needsFetch||t.isFetching?1:0)),0)}_maximumFeaturesForTile(e){const t=e.hasPreciseFeatureCount?e.numFeatures:1/0,s=e.hasPreciseFeatureCount?t:this.maximumNumberOfFeatures,i=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(s*i/(1-e.emptyFeatureRatio)),t)}get test(){}};function A(e){return"dummy-tile-full-extent"===e.id}function I(e){let t=0;for(const s of e)s.features&&s.features.length>0&&s.alive&&(t=Math.max(t,s.descriptor.lij[0]));return t}function P(e){return e.setFeatures([],0,null,void 0),e.featuresMissing=!1,D.DONE}function N(e){return null==e?new Set:new Set(e.map((e=>e.name)))}function Q(e,t){if(null==e||null==t)return N(t);const s=new Set;for(const{name:i}of t)e.has(i)&&s.add(i);return s}function z(e,t){if(!t?.length)return e;e??=new Map;const s=()=>new Set;for(const{objectId:r,attribute:a}of t)i(e,r,s).add(a);return e}e([c({constructOnly:!0})],j.prototype,"features",void 0),e([c()],j.prototype,"tileDescriptors",void 0),e([c({value:1/0})],j.prototype,"maximumNumberOfFeatures",null),e([c({value:1})],j.prototype,"memoryFactor",null),e([c({value:1})],j.prototype,"lodFactor",null),e([c()],j.prototype,"useTileCount",null),e([c({readOnly:!0})],j.prototype,"updating",null),e([c({readOnly:!0})],j.prototype,"dataUpdating",void 0),e([c({readOnly:!0})],j.prototype,"running",void 0),e([c({readOnly:!0})],j.prototype,"updatingTotal",void 0),e([c({readOnly:!0})],j.prototype,"updatingRemaining",void 0),e([c({readOnly:!0})],j.prototype,"expectedFeatureDiff",void 0),e([c({readOnly:!0})],j.prototype,"memoryForUnusedFeatures",null),e([c({readOnly:!0})],j.prototype,"maximumNumberOfFeaturesExceeded",void 0),e([c({readOnly:!0})],j.prototype,"totalVertices",null),e([c({readOnly:!0})],j.prototype,"totalFeatures",null),e([c({readOnly:!0})],j.prototype,"hasAllFeatures",null),e([c({readOnly:!0})],j.prototype,"hasFullGeometries",null),e([c()],j.prototype,"filterExtent",null),e([c({constructOnly:!0})],j.prototype,"context",void 0),e([c()],j.prototype,"_dirty",void 0),e([c()],j.prototype,"_suspended",void 0),e([c()],j.prototype,"_pendingEdits",void 0),e([c()],j.prototype,"_applyEditsTilesUpdated",void 0),e([c()],j.prototype,"_paused",null),e([c()],j.prototype,"_isFetching",void 0),j=e([p("esri.views.3d.layers.support.FeatureTileFetcher3D")],j);const L=2e3,S=f(),q=f(),H=6e5,k=200;export{j as FeatureTileFetcher3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{disposeMaybe as r,releaseMaybe as s}from"../../../core/maybe.js";import{watch as o,sync as i}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{set as c,copy as u}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as p}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as l}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isBaseLayer as d,isGroupLayer as m}from"../../../layers/support/layerUtils.js";import{BlendLayersPassParameters as h}from"./BlendLayersTechnique.js";import{TextureUpdate as f}from"./interfaces.js";import{LayerClass as _}from"./LayerClass.js";import{NeighborIndex as T}from"./NeighborIndex.js";import{isImageWithType as y}from"./TerrainData.js";import{isBlendableLayerView as g,isVectorTileLayerView as b,isVectorTileRenderInfo as x,isImageryTileRenderInfo as I,isImageSourceRenderInfo as w,isTextureTileRenderInfo as A,isVectorTilePerLayerInfo as j}from"./terrainUtils.js";import{ActivationTime as P}from"./TextureFader.js";import{TextureReference as O}from"./TextureReference.js";import{TileCompositor as C}from"./TileCompositor.js";import{TileRenderInfo as k}from"./TileRenderInfo.js";import E from"./TileTexture.js";import{TileUpdate as L}from"./TileUpdate.js";import{fallsWithinLayerView as R}from"./tileUtils.js";import{blendModeFromString as D}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{BlendLayersOutput as M}from"../webgl-engine/core/shaderLibrary/terrain/BlendLayersOutput.js";import{createEmptyTexture as N}from"../webgl-engine/lib/glUtil3D.js";import{isCompressible as B}from"../../support/TextureCompressionHelper.js";import{TextureSamplingMode as S,TextureWrapMode as U,PixelFormat as G}from"../../webgl/enums.js";import{Texture as v}from"../../webgl/Texture.js";import{TextureDescriptor as F}from"../../webgl/TextureDescriptor.js";class H{constructor(e,t,r,s,o,i){this.start=e,this.end=t,this.blendMode=r,this.opacity=s,this.output=o,this.baseOpacity=i}}let q=class extends t{constructor(e){super(e),this._passParameters=new h,this._backgroundTexture=null,this._backgroundColor=null,this._backgroundDirty=!1}initialize(){this._maxAnisotropy=this.rctx.parameters.maxMaxAnisotropy,this._compositor=new C(this.rctx,this.techniques),this._ensureBackgroundTexture(this.tileSize),this.texturesBeingCompressed=0}dispose(){this._compositor=r(this._compositor),this._backgroundTexture=s(this._backgroundTexture)}get backgroundIsGrid(){return null==this._backgroundColor}get backgroundColor(){return this._backgroundColor}updateHeading(e){this._compositor?.updateHeading(e)}updateTileTexture(e,t){if(!e.renderData)return;const r=e.surface,s=r.baseOpacity;let o=0,i=0,a=this.tileSize,n=!1,c=!1;const u=r.view.state.contentPixelRatio;let p=!1;J.clear(),K.length=0;const l=e.layerInfo[_.MAP];let h=0,T=null;for(;h<l.length;h++){const t=r.layerViewByIndex(h,_.MAP),f=t.layer,y=!R(e,t),x=f.opacity,I=t.fullOpacity;if(c=c||d(f),g(t)){let e="normal"!==t.layer.blendMode;if(m(f.parent)){const t=f.parent.uid;null!=t&&""!==t&&(e=X(f.parent)||e)}e&&(p=e,n=!1)}if((y||0===x)&&!p){l[h].pendingUpdates&=~(L.TEXTURE_NOFADING&L.TEXTURE_FADING);continue}++i;const w=b(t),A=z(e,h,w);if(A){if(l[h].pendingUpdates&=~(L.TEXTURE_NOFADING&L.TEXTURE_FADING),m(f.parent)){const e=f.parent.uid;null!=e&&""!==e&&W(f.parent,h)}w?a=Math.max(a,this.tileSize*u):1===s&&1===I&&(t.isOpaque||this._dataToTexture(A)&&A.sourceLayerInfo.data.descriptor.isOpaque)&&(n=!0),++o,null===T&&(T=h)}}const y=a/this.tileSize,x=this._ensureBackgroundTexture(this.tileSize);0!==o&&null!==T?1===o&&!p&&this._useLayerTexture(e,T)||this._composeLayers(e,t,h-1,c,a,y,!n||p,J,p):$(e,i,x,t!==f.FADING)}_ensureBackgroundTexture(e){return null==this._backgroundTexture&&(this._backgroundTexture=this._buildTexture(e,!1),this._backgroundDirty=!0),this._backgroundDirty&&(this._compositor.bind(e),this._passParameters.offset=p,this._passParameters.scale=1,this._passParameters.opacity=1,this.backgroundColor&&(this._passParameters.backgroundColor=this.backgroundColor),this._compositor.drawBackground(this._passParameters,null!=this.backgroundColor),this._compositor.copyFBOToTexture(this._backgroundTexture),this._compositor.unbind(),this._backgroundDirty=!1),this._backgroundTexture}_useLayerTexture(e,t){const r=e.surface.layerViewByIndex(t,_.MAP),s=d(r.layer),o=s?e.surface.baseOpacity:1,i=s?1:e.surface.baseOpacity,a=r.fullOpacity,n=z(e,t,!1);return!!this._dataToTexture(n)&&(e.renderData.setTextureReference(new O(n.sourceLayerInfo.data,f.FADING,l(n.offset[0],n.offset[1],n.scale,n.scale),o,i,a)),!0)}_composeLayers(e,t,r,s,o,i,a,n,c){this._compositor.ensureBuffer(o);const u=e.surface.baseOpacity;let l=!1,m=S.LINEAR_MIPMAP_LINEAR,h=!1,f=0;for(let A=r;A>=0;A--){const t=e.surface.layerViewByIndex(A,_.MAP),r=t.layer,T=b(t),y=z(e,A,T),w=r.opacity,j=!R(e,t);if(!y||(0===w||j)&&!c)continue;const P=!d(r)&&!l;P&&(l=!0);let O=!1;n.forEach((e=>{e.start===A&&(e.output=s?M.Composite:a&&P?this.backgroundIsGrid?M.GridComposite:M.ColorComposite:M.Composite,e.baseOpacity=P?u:1,K.push(e),this._compositor.openGroup(o),O=!0)}));const C=0===f,k=O?M.GroupBackgroundComposite:a&&C?this.backgroundIsGrid?M.GridComposite:M.ColorComposite:M.Composite,E=D[g(t)?t.layer.blendMode:"normal"];for(this._passParameters.baseOpacity=P&&!O&&u<1?u:1,this._passParameters.opacity=w,x(y)?h=this._compositor.drawVectorData(this._passParameters,k,o,E,y,i,this.tileSize,h):I(y)?(this._compositor.drawRasterData(this._passParameters,k,o,E,y),V(y)&&(m=S.NEAREST)):this._dataToTexture(y)&&(this._passParameters.texture=y.sourceLayerInfo.data.texture,this._passParameters.offset=y.offset,this._passParameters.scale=y.scale,this._compositor.drawImageData(this._passParameters,k,o,E));K.length>0&&K[K.length-1].end===A;){const e=K.pop();this._passParameters.baseOpacity=e.baseOpacity,this._passParameters.opacity=e.opacity,this._passParameters.offset=p,this._passParameters.scale=1,this._compositor.drawGroup(this._passParameters,e.output,o,D[e.blendMode])}f++}const T=e.renderData,y=c||l&&u<1,w=T.ensureTexture(o,y,t,(()=>this._buildTexture(o,y,m)));this._compositor.copyFBOToTexture(w),this._compositor.unbind(),T.setTextureReference(new O(w,t,Y,l?1:u,0,1))}_dataToTexture(e){if(w(e)){const t=e.sourceLayerInfo,r=1===e.scale;t.data=this._buildTexture(t.data,!0,r),e.tile.setMemoryDirty()}return A(e)}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundDirty=!0)}_buildTexture(e,t,r=S.LINEAR_MIPMAP_LINEAR){if(null==e)return null;const s=new F;s.wrapMode=U.CLAMP_TO_EDGE,s.samplingMode="boolean"==typeof r?S.LINEAR_MIPMAP_LINEAR:r,s.maxAnisotropy=this._maxAnisotropy,s.preMultiplyAlpha=!0,s.flipped=!0,s.hasMipmap=!0,t||(s.pixelFormat=G.RGB);const o=this.rctx,i="boolean"==typeof r&&r;let a;if("number"==typeof e)s.width=s.height=e,a=this._buildTileTexture(s,e);else if(y(e))s.isOpaque=e.isOpaque,s.isOpaque&&(s.pixelFormat=G.RGB),a=this._buildTileTexture(s,e.element.width,i,e.element);else try{s.width=e.width,s.height=e.height,a=this._buildTileTexture(s,e.width,i,e)}catch(c){a=new E(N(o)),console.warn("TileRenderer: failed to execute 'texImage2D', cross-origin image may not be loaded.")}const n=o.bindTexture(a.texture,v.TEXTURE_UNIT_FOR_UPDATES);return a.generateMipmap(),o.bindTexture(n,v.TEXTURE_UNIT_FOR_UPDATES),a}_buildTileTexture(e,t,r=!1,s){const a=`${t} ${e.pixelFormat}`,n=this.cache.pop(a)??this.cache.pop(a+"compressed");if(r&&=B(s),n)return n.retain(),r&&n.texture.enableCompression(!0),n.texture.setData(s),n;e.shouldCompress=r;const c=new v(this.rctx,e);return c.setData(s)&&(this.texturesBeingCompressed++,this.addHandles([o((()=>c.isCompressing),(e=>{e?this.texturesBeingCompressed++:this.texturesBeingCompressed--}),i)])),new E(c,this.cache)}get test(){}};function z(e,t,r){Q.layerIndex=t,Q.vtlNeighborInfos.clear();const s=e.layerInfo[_.MAP][t];if(c(Q.offset,0,0),Q.tile=e,Q.scale=1,Q.sourceLod=e.lij,Q.sourceLayerInfo=s,Q.isVTLBackground=r,s.data)return r&&e.forEachLoadedNeighbor(((r,o)=>{if(r.level!==e.level)return;const i=r.layerInfo[_.MAP][t];if(!j(i)||s.data===i.data)return;const a=Q.vtlNeighborInfos.pushNew();a.offset=Z[o],a.sourceLod=r.lij,a.sourceLayerInfo=i})),Q;const o=s.upsampleInfo,i=o?.tile?.layerInfo[_.MAP][t];return i&&o.tile?(Q.tile=o.tile,u(Q.offset,o.offset),Q.scale=o.scale,Q.sourceLod=o.tile.lij,Q.sourceLayerInfo=i,Q):r?Q:null}function V(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}function X(e){let t="normal"!==e.blendMode;return m(e.parent)&&(t=X(e.parent)||t),t}function W(e,t){m(e.parent)&&W(e.parent,t);const r=e.uid;if(null!=r&&""!==r){const s=J.get(r);s?s.start=t:J.set(r,new H(t,t,e.blendMode,e.opacity,M.Composite,1))}}function $(e,t,r,s){const o=e.renderData,i=!s&&null!=o.textureReference&&(e.surface.view.layerViewManager.updating||t>0)?P.Delayed:P.Immediate;o.setTextureReference(new O(r,f.FADING,Y,e.surface.baseOpacity,0,1),i)}e([a({constructOnly:!0})],q.prototype,"rctx",void 0),e([a({constructOnly:!0})],q.prototype,"techniques",void 0),e([a({constructOnly:!0})],q.prototype,"cache",void 0),e([a()],q.prototype,"tileSize",void 0),e([a()],q.prototype,"texturesBeingCompressed",void 0),q=e([n("esri.views.3d.terrain.TileRenderer")],q);const J=new Map,K=new Array,Q=new k,Y=l(0,0,1,1),Z=new Array;Z[T.NORTH]=[0,-1],Z[T.NORTH_EAST]=[-1,-1],Z[T.EAST]=[-1,0],Z[T.SOUTH_EAST]=[-1,1],Z[T.SOUTH]=[0,1],Z[T.SOUTH_WEST]=[1,1],Z[T.WEST]=[1,0],Z[T.NORTH_WEST]=[1,-1];export{H as GroupInfo,q as TileRenderer};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{disposeMaybe as r,releaseMaybe as s}from"../../../core/maybe.js";import{watch as o,sync as i}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{set as c,copy as u}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as p}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as l}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isBaseLayer as d,isGroupLayer as m}from"../../../layers/support/layerUtils.js";import{BlendLayersPassParameters as h}from"./BlendLayersTechnique.js";import{TextureUpdate as f}from"./interfaces.js";import{LayerClass as _}from"./LayerClass.js";import{NeighborIndex as T}from"./NeighborIndex.js";import{isImageWithType as y}from"./TerrainData.js";import{isBlendableLayerView as g,isVectorTileLayerView as b,isVectorTileRenderInfo as x,isImageryTileRenderInfo as I,isImageSourceRenderInfo as w,isTextureTileRenderInfo as A,isVectorTilePerLayerInfo as j}from"./terrainUtils.js";import{ActivationTime as P}from"./TextureFader.js";import{TextureReference as C}from"./TextureReference.js";import{TileCompositor as O}from"./TileCompositor.js";import{TileRenderInfo as k}from"./TileRenderInfo.js";import E from"./TileTexture.js";import{TileUpdate as L}from"./TileUpdate.js";import{fallsWithinLayerView as R}from"./tileUtils.js";import{blendModeFromString as M}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{BlendLayersOutput as D}from"../webgl-engine/core/shaderLibrary/terrain/BlendLayersOutput.js";import{createEmptyTexture as N}from"../webgl-engine/lib/glUtil3D.js";import{isCompressible as B}from"../../support/TextureCompressionHelper.js";import{TextureSamplingMode as S,TextureWrapMode as U,PixelFormat as G}from"../../webgl/enums.js";import{Texture as v}from"../../webgl/Texture.js";import{TextureDescriptor as F}from"../../webgl/TextureDescriptor.js";class H{constructor(e,t,r,s,o,i){this.start=e,this.end=t,this.blendMode=r,this.opacity=s,this.output=o,this.baseOpacity=i}}let q=class extends t{constructor(e){super(e),this._passParameters=new h,this._backgroundTexture=null,this._backgroundColor=null,this._backgroundDirty=!1}initialize(){this._maxAnisotropy=this.rctx.parameters.maxMaxAnisotropy,this._compositor=new O(this.rctx,this.techniques),this._ensureBackgroundTexture(this.tileSize),this.texturesBeingCompressed=0}dispose(){this._compositor=r(this._compositor),this._backgroundTexture=s(this._backgroundTexture)}get backgroundIsGrid(){return null==this._backgroundColor}get backgroundColor(){return this._backgroundColor}updateHeading(e){this._compositor?.updateHeading(e)}updateTileTexture(e,t){if(!e.renderData)return;const r=e.surface,s=r.baseOpacity;let o=0,i=0,a=this.tileSize,n=!1,c=!1;const u=r.view.state.contentPixelRatio;let p=!1;J.clear(),K.length=0;const l=e.layerInfo[_.MAP];let h=0,T=null;for(;h<l.length;h++){const t=r.layerViewByIndex(h,_.MAP),f=t.layer,y=!R(e,t),x=f.opacity,I=t.fullOpacity;if(c=c||d(f),g(t)){let e="normal"!==t.layer.blendMode;if(m(f.parent)){const t=f.parent.uid;null!=t&&""!==t&&(e=X(f.parent)||e)}e&&(p=e,n=!1)}if((y||0===x)&&!p){l[h].pendingUpdates&=~(L.TEXTURE_NOFADING&L.TEXTURE_FADING);continue}++i;const w=b(t),A=z(e,h,w);if(A){if(l[h].pendingUpdates&=~(L.TEXTURE_NOFADING&L.TEXTURE_FADING),m(f.parent)){const e=f.parent.uid;null!=e&&""!==e&&W(f.parent,h)}w?a=Math.max(a,this.tileSize*u):1===s&&1===I&&(t.isOpaque||this._dataToTexture(A)&&A.sourceLayerInfo.data.descriptor.isOpaque)&&(n=!0),++o,null===T&&(T=h)}}const y=a/this.tileSize,x=this._ensureBackgroundTexture(this.tileSize);0!==o&&null!==T?1===o&&!p&&this._useLayerTexture(e,T)||this._composeLayers(e,t,h-1,c,a,y,!n||p,J,p):$(e,i,x,t!==f.FADING)}_ensureBackgroundTexture(e){return null==this._backgroundTexture&&(this._backgroundTexture=this._buildTexture(e,!1),this._backgroundDirty=!0),this._backgroundDirty&&(this._compositor.bind(e),this._passParameters.offset=p,this._passParameters.scale=1,this._passParameters.opacity=1,this.backgroundColor&&(this._passParameters.backgroundColor=this.backgroundColor),this._compositor.drawBackground(this._passParameters,null!=this.backgroundColor),this._compositor.copyFBOToTexture(this._backgroundTexture),this._compositor.unbind(),this._backgroundDirty=!1),this._backgroundTexture}_useLayerTexture(e,t){const r=e.surface.layerViewByIndex(t,_.MAP),s=d(r.layer),o=s?e.surface.baseOpacity:1,i=s?1:e.surface.baseOpacity,a=r.fullOpacity,n=z(e,t,!1);return!!this._dataToTexture(n)&&(e.renderData.setTextureReference(new C(n.sourceLayerInfo.data,f.FADING,l(n.offset[0],n.offset[1],n.scale,n.scale),o,i,a)),!0)}_composeLayers(e,t,r,s,o,i,a,n,c){this._compositor.ensureBuffer(o);const u=e.surface.baseOpacity;let l=!1,m=S.LINEAR_MIPMAP_LINEAR,h=!1,f=0;for(let A=r;A>=0;A--){const t=e.surface.layerViewByIndex(A,_.MAP),r=t.layer,T=b(t),y=z(e,A,T),w=r.opacity,j=!R(e,t);if(!y||(0===w||j)&&!c)continue;const P=!d(r)&&!l;P&&(l=!0);let C=!1;n.forEach((e=>{e.start===A&&(e.output=s?D.Composite:a&&P?this.backgroundIsGrid?D.GridComposite:D.ColorComposite:D.Composite,e.baseOpacity=P?u:1,K.push(e),this._compositor.openGroup(o),C=!0)}));const O=0===f,k=C?D.GroupBackgroundComposite:a&&O?this.backgroundIsGrid?D.GridComposite:D.ColorComposite:D.Composite,E=M[g(t)?t.layer.blendMode:"normal"];for(this._passParameters.baseOpacity=P&&!C&&u<1?u:1,this._passParameters.opacity=w,x(y)?h=this._compositor.drawVectorData(this._passParameters,k,o,E,y,i,this.tileSize,h):I(y)?(this._compositor.drawRasterData(this._passParameters,k,o,E,y),V(y)&&(m=S.NEAREST)):this._dataToTexture(y)&&(this._passParameters.texture=y.sourceLayerInfo.data.texture,this._passParameters.offset=y.offset,this._passParameters.scale=y.scale,this._compositor.drawImageData(this._passParameters,k,o,E));K.length>0&&K[K.length-1].end===A;){const e=K.pop();this._passParameters.baseOpacity=e.baseOpacity,this._passParameters.opacity=e.opacity,this._passParameters.offset=p,this._passParameters.scale=1,this._compositor.drawGroup(this._passParameters,e.output,o,M[e.blendMode])}f++}const T=e.renderData,y=c||l&&u<1,w=T.ensureTexture(o,y,t,(()=>this._buildTexture(o,y,m)));this._compositor.copyFBOToTexture(w),this._compositor.unbind(),T.setTextureReference(new C(w,t,Y,l?1:u,0,1))}_dataToTexture(e){if(w(e)){const t=e.sourceLayerInfo,r=1===e.scale;t.data=this._buildTexture(t.data,!0,r),e.tile.setMemoryDirty()}return A(e)}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundDirty=!0)}_buildTexture(e,t,r=S.LINEAR_MIPMAP_LINEAR){if(null==e)return null;const s=new F;s.wrapMode=U.CLAMP_TO_EDGE,s.samplingMode="boolean"==typeof r?S.LINEAR_MIPMAP_LINEAR:r,s.maxAnisotropy=this._maxAnisotropy,s.preMultiplyAlpha=!0,s.flipped=!0,s.hasMipmap=!0,t||(s.pixelFormat=G.RGB);const o=this.rctx,i="boolean"==typeof r&&r;let a;if("number"==typeof e)s.width=s.height=e,a=this._buildTileTexture(s,e);else if(y(e))s.isOpaque=e.isOpaque,s.isOpaque&&(s.pixelFormat=G.RGB),a=this._buildTileTexture(s,e.element.width,i,e.element);else try{s.width=e.width,s.height=e.height,a=this._buildTileTexture(s,e.width,i,e)}catch(c){a=new E(N(o)),console.warn("TileRenderer: failed to execute 'texImage2D', cross-origin image may not be loaded.")}const n=o.bindTexture(a.texture,v.TEXTURE_UNIT_FOR_UPDATES);return a.generateMipmap(),o.bindTexture(n,v.TEXTURE_UNIT_FOR_UPDATES),a}_buildTileTexture(e,t,r=!1,s){const a=`${t} ${e.pixelFormat}`,n=this.cache.pop(a)??this.cache.pop(a+"compressed");if(r&&=B(s),n)return n.retain(),r&&n.texture.enableCompression(!0),n.texture.setData(s),n;e.shouldCompress=r;const c=new v(this.rctx,e,s);return c.isCompressing&&(this.texturesBeingCompressed++,this.addHandles([o((()=>c.isCompressing),(e=>{e?this.texturesBeingCompressed++:this.texturesBeingCompressed--}),i)])),new E(c,this.cache)}get test(){}};function z(e,t,r){Q.layerIndex=t,Q.vtlNeighborInfos.clear();const s=e.layerInfo[_.MAP][t];if(c(Q.offset,0,0),Q.tile=e,Q.scale=1,Q.sourceLod=e.lij,Q.sourceLayerInfo=s,Q.isVTLBackground=r,s.data)return r&&e.forEachLoadedNeighbor(((r,o)=>{if(r.level!==e.level)return;const i=r.layerInfo[_.MAP][t];if(!j(i)||s.data===i.data)return;const a=Q.vtlNeighborInfos.pushNew();a.offset=Z[o],a.sourceLod=r.lij,a.sourceLayerInfo=i})),Q;const o=s.upsampleInfo,i=o?.tile?.layerInfo[_.MAP][t];return i&&o.tile?(Q.tile=o.tile,u(Q.offset,o.offset),Q.scale=o.scale,Q.sourceLod=o.tile.lij,Q.sourceLayerInfo=i,Q):r?Q:null}function V(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}function X(e){let t="normal"!==e.blendMode;return m(e.parent)&&(t=X(e.parent)||t),t}function W(e,t){m(e.parent)&&W(e.parent,t);const r=e.uid;if(null!=r&&""!==r){const s=J.get(r);s?s.start=t:J.set(r,new H(t,t,e.blendMode,e.opacity,D.Composite,1))}}function $(e,t,r,s){const o=e.renderData,i=!s&&null!=o.textureReference&&(e.surface.view.layerViewManager.updating||t>0)?P.Delayed:P.Immediate;o.setTextureReference(new C(r,f.FADING,Y,e.surface.baseOpacity,0,1),i)}e([a({constructOnly:!0})],q.prototype,"rctx",void 0),e([a({constructOnly:!0})],q.prototype,"techniques",void 0),e([a({constructOnly:!0})],q.prototype,"cache",void 0),e([a()],q.prototype,"tileSize",void 0),e([a()],q.prototype,"texturesBeingCompressed",void 0),q=e([n("esri.views.3d.terrain.TileRenderer")],q);const J=new Map,K=new Array,Q=new k,Y=l(0,0,1,1),Z=new Array;Z[T.NORTH]=[0,-1],Z[T.NORTH_EAST]=[-1,-1],Z[T.EAST]=[-1,0],Z[T.SOUTH_EAST]=[-1,1],Z[T.SOUTH]=[0,1],Z[T.SOUTH_WEST]=[1,1],Z[T.WEST]=[1,0],Z[T.NORTH_WEST]=[1,-1];export{H as GroupInfo,q as TileRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import{ComponentRangeRunLengthEncoded as e}from"./IndexRange/ComponentRangeRunLengthEncoded.js";import{defaultHighlightName as h}from"../../../../support/HighlightDefaults.js";class i{constructor(t,h){this.offsets=h,this._highlightsInOrder=[],this.pickability=null,this.componentHighlights=new Map,this.verticalOffsets=null,this.cachedGeometryRanges=null,this.cachedHighlightRangesMap=null,this.cachedShadowmapRanges=null;const i=this.count;this.visibility=new e(i),this.materialDataBuffer=t.getBuffer(i),this.materialDataIndices=new Uint16Array(i);for(let e=0;e<i;e++)this.materialDataIndices[e]=this.materialDataBuffer.acquireIndex()}destroy(){for(let t=0;t<this.count;t++)this.materialDataBuffer.releaseIndex(this.materialDataIndices[t])}get count(){return this.offsets.length-1}get geometryRanges(){return null==this.cachedGeometryRanges&&(this.cachedGeometryRanges=this.visibility.computeOffsetRanges(this.offsets)),this.cachedGeometryRanges}get highlightRangesMap(){return 0===this.componentHighlights.size?null:(this._updateCachedHighlightRanges(),this.cachedHighlightRangesMap)}get shadowmapRanges(){return 0===this.componentHighlights.size?this.geometryRanges:(this._updateCachedHighlightRanges(),this.cachedShadowmapRanges)}markHighlightsDirty(){this.cachedHighlightRangesMap=null,this.cachedShadowmapRanges=null}markVisibilityDirty(){this.cachedGeometryRanges=null,this.markHighlightsDirty()}updateHighlights(t){this._updateHighlightOrder(t)&&(this.markHighlightsDirty(),this._updateCachedHighlightRanges())}_updateHighlightOrder(t){const{_highlightsInOrder:e}=this;let h=e.length!==t.length;e.length=Math.min(t.length,8);for(let i=0;i<t.length;++i){const s=t.at(i).name;e.length<i?(h=!0,e.push(s)):e[i]!==s&&(e[i]=s,h=!0)}return h}_updateCachedHighlightRanges(){if(null==this.cachedHighlightRangesMap||null==this.cachedShadowmapRanges){const{highlightRangesMap:t,shadowmapRangesMap:e}=s(this.componentHighlights,this.visibility,this.offsets,this._highlightsInOrder);this.cachedHighlightRangesMap=t,this.cachedShadowmapRanges=e}}}function s(e,i,s,a){const n=new Map,g=[];if(e.size>0){let l=s.length;i.forEachComponent((i=>{let r=!1;for(let g=a.length-1;g>=0;--g){const l=a[g],c=e.get(l);if((c?.[i]??0)>0){const e=t(n,l,(()=>[])),a=s[i],g=s[i+1];e.push(a),e.push(g-a),r||=l===h;break}}return r||(l!==i-1&&(g.length>0&&g.push(s[l+1]-g[g.length-1]),g.push(s[i])),l=i),!0})),g.length>0&&g.push(s[l+1]-g[g.length-1])}return{highlightRangesMap:n,shadowmapRangesMap:g}}export{i as default};
5
+ import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import{ComponentRange as e}from"./IndexRange/ComponentRange.js";import{defaultHighlightName as h}from"../../../../support/HighlightDefaults.js";class i{constructor(t,h){this.offsets=h,this._highlightsInOrder=[],this.pickability=null,this.componentHighlights=new Map,this.verticalOffsets=null,this._cachedGeometryRanges=null,this._cachedHighlightRangesMap=null,this._cachedShadowmapRanges=null;const i=this.count;this.visibility=new e(i),this.materialDataBuffer=t.getBuffer(i),this.materialDataIndices=new Uint16Array(i);for(let e=0;e<i;e++)this.materialDataIndices[e]=this.materialDataBuffer.acquireIndex()}destroy(){for(let t=0;t<this.count;t++)this.materialDataBuffer.releaseIndex(this.materialDataIndices[t])}get count(){return this.offsets.length-1}get geometryRanges(){return null==this._cachedGeometryRanges&&(this._cachedGeometryRanges=this.visibility.computeOffsetRanges(this.offsets)),this._cachedGeometryRanges}get highlightRangesMap(){return 0===this.componentHighlights.size?null:(this._updateCachedHighlightRanges(),this._cachedHighlightRangesMap)}get shadowmapRanges(){return 0===this.componentHighlights.size?this.geometryRanges:(this._updateCachedHighlightRanges(),this._cachedShadowmapRanges)}markHighlightsDirty(){this._cachedHighlightRangesMap=null,this._cachedShadowmapRanges=null}markVisibilityDirty(){this._cachedGeometryRanges=null,this.markHighlightsDirty()}updateHighlights(t){this._updateHighlightOrder(t)&&(this.markHighlightsDirty(),this._updateCachedHighlightRanges())}_updateHighlightOrder(t){const{_highlightsInOrder:e}=this;let h=e.length!==t.length;e.length=Math.min(t.length,8);for(let i=0;i<t.length;++i){const s=t.at(i).name;e.length<i?(h=!0,e.push(s)):e[i]!==s&&(e[i]=s,h=!0)}return h}_updateCachedHighlightRanges(){if(null==this._cachedHighlightRangesMap||null==this._cachedShadowmapRanges){const{highlightRangesMap:t,shadowmapRangesMap:e}=s(this.componentHighlights,this.visibility,this.offsets,this._highlightsInOrder);this._cachedHighlightRangesMap=t,this._cachedShadowmapRanges=e}}}function s(e,i,s,a){const g=new Map,n=[];if(e.size>0){let l=s.length;i.forEachComponent((i=>{let r=!1;for(let n=a.length-1;n>=0;--n){const l=a[n],c=e.get(l);if((c?.[i]??0)>0){const e=t(g,l,(()=>[])),a=s[i],n=s[i+1];e.push(a),e.push(n-a),r||=l===h;break}}return r||(l!==i-1&&(n.length>0&&n.push(s[l+1]-n[n.length-1]),n.push(s[i])),l=i),!0})),n.length>0&&n.push(s[l+1]-n[n.length-1])}return{highlightRangesMap:g,shadowmapRangesMap:n}}export{i as ComponentData};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import i from"../../../../../core/PooledArray.js";import{isTypedArray as o}from"../../../../../core/typedArrayUtil.js";import{s as n}from"../../../../../chunks/vec32.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as a}from"../../../../../geometry/support/Indices.js";import{c as l}from"../../../../../chunks/vec3.js";import{c}from"../../../../../chunks/vec33.js";import{ViewingMode as m}from"../../../../ViewingMode.js";import{ColorMixModeEnum as p,encodeSymbolColor as f}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as h}from"../../../support/orientedBoundingBox.js";import{glLayout as g}from"../../../support/buffer/glUtil.js";import{newLayout as d}from"../../../support/buffer/InterleavedLayout.js";import u from"./ComponentData.js";import{ComponentObject as b}from"./ComponentObject.js";import{IntersectionGeometry as y}from"./IntersectionGeometry.js";import{Renderable as v}from"./Renderable.js";import{RenderGeometry as _}from"./RenderGeometry.js";import{RenderSubmitSystem as C}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as M}from"./SourceGeometry.js";import{UniformComponentParameters as j}from"./UniformComponentParameters.js";import{ComponentParametersVarying as w,ComponentParametersUniform as x,ComponentParameterSummary as O,ComponentMaterial as D}from"./Material/ComponentMaterial.js";import{vertexAttributeLocations as A}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as R}from"./Material/shader/ComponentData.glsl.js";import{olidEnabled as S}from"../../effects/geometry/olidUtils.js";import{getVisibility as E,updateVisibilityWithCount as I}from"../../lib/ComponentUtils.js";import{assert as H}from"../../lib/Util.js";import{VertexAttribute as V}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as U}from"../../lib/verticalOffsetUtils.js";import{BufferManager as B}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as P}from"../../../../webgl/BufferObject.js";import{Usage as N,PrimitiveType as T}from"../../../../webgl/enums.js";import{VertexArrayObject as k}from"../../../../webgl/VertexArrayObject.js";const L=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class G{constructor(e,t){this._renderManager=e,this._viewingMode=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._activeHighlightOptions=new Map,this._visible=new i,this._hidden=new i,this._renderSubmit=new C(this),this._renderManager.register(this._renderSubmit),this._componentBufferManager=new B(e.rctx,2+(S()?1:0))}destroy(){H(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._visible.forAll((e=>e.destroy())),this._visible.clear(),this._hidden.forAll((e=>e.destroy())),this._hidden.clear()}createObject(e){const t=e.geometry,i=new u(this._componentBufferManager,a(t.componentOffsets)),o=this._createRenderable(e,i),n=new y(this._viewingMode,t.positionData,i),r=new b(e.transform,e.toMapSpace,e.obb.clone(),i,o,n);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const i=e;t!==i.visible&&(t?(this._hidden.removeUnordered(i),this._visible.push(i)):(this._visible.removeUnordered(i),this._hidden.push(i)),i.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=n(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const i=e.renderable.material;t(i),i.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const i=e;i.componentData.visibility.reset(t),i.componentData.markVisibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){const t=e,i=t.componentData.visibility.componentCount;return{visible:i,invisible:t.componentData.count-i}}setComponentData(e,t){const i=e,{renderable:o,componentData:n}=i,r=o.material,s=n.materialDataBuffer,a=n.materialDataIndices,l=new j,c=s.textureBuffer,m=new Uint8Array(4),g=new Uint32Array(m.buffer);let d=0,u=0,b=0,y=n.verticalOffsets,v=1/0,_=-1/0,C=!1,M=!1,D=0;for(let h=0;h<n.count;h++){t(h,l),d+=+(l.externalColor[3]<1),u+=+(l.externalColorMixMode===p.Replace&&1===l.externalColor[3]),b+=+l.castShadows,f(l.externalColor,l.externalColorMixMode,m),m[2]=254&m[2]|+l.castShadows,c.setData(a[h],0,m[0],m[1],m[2],m[3]),C||=h>0&&D!==g[0],D=g[0],M||=0!==l.elevationOffset,M&&null==y&&(y=new Array(h).fill(0)),null!=y&&(y[h]=l.elevationOffset),v=Math.min(v,l.elevationOffset),_=Math.max(_,l.elevationOffset),R(l.elevationOffset,m),c.setData(a[h],1,m[0],m[1],m[2],m[3]);const e=l.objectAndLayerIdColor;null!=e&&c.setData(a[h],2,e[0],e[1],e[2],e[3]),l.pickable!==E(n.pickability,h)&&(n.pickability=I(n.pickability,n.count,h,l.pickable))}n.verticalOffsets=M?y:null,i.offsetObb=M?h(i.obb,v,_,this._viewingMode,i.offsetObb??i.obb.clone()):null,C||M||S()?(r.componentParameters=new w,r.componentParameters.castShadows=W(b,n.count),r.componentParameters.transparent=W(d,n.count),r.componentParameters.opaqueOverride=W(u,n.count),r.componentParameters.texture=c,c.updateTexture()):(r.componentParameters=new x,r.componentParameters.castShadows=l.castShadows?O.All:O.None,r.componentParameters.externalColor=l.externalColor,r.componentParameters.externalColorMixMode=l.externalColorMixMode),this._elevationRangeCacheVerticalOffset=NaN,this._notifyDirty()}getComponentAabb(e,t,i,o=!1){e.intersectionGeometry.getComponentAabb(t,i);const n=e,r=n.componentData.verticalOffsets;if(o||null==r)return i;const s=r[t];if(this._viewingMode===m.Local||0===s)return i[2]+=s,i[5]+=s,i;const a=U(s);return a.localOrigin=n.transform.position,a.applyToAabb(i)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,i){return e.intersectionGeometry.getComponentPositions(t,i)}expandRangeWithComponentObjectElevationRange(e,t,i,o){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||o.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const n=e,r=n.componentData,s=r.count,a=r.verticalOffsets,l=n.intersectionGeometry,c=this._viewingMode===m.Local,p=l.getComponentAabbs(),f=z;let h=1/0,g=-1/0;for(let m=0;m<s;m++){const e=6*m,r=a?.[m]??0;let s=1/0,l=-1/0;if(c)s=p[e+2]+r+t,l=p[e+5]+r+t;else{if(f[0]=p[e],f[1]=p[e+1],f[2]=p[e+2],f[3]=p[e+3],f[4]=p[e+4],f[5]=p[e+5],0!==r){const e=U(r);e.localOrigin=n.transform.position,e.applyToAabb(f)}const s=Math.max(Math.abs(f[3]),Math.abs(f[0])),a=Math.max(Math.abs(f[4]),Math.abs(f[1])),l=t+f[5]+i;o.expandElevationRangeValues(t+f[2],Math.sqrt(s*s+a*a+l*l)-i)}o.expandElevationRangeValues(s,l),h=Math.min(h,s),g=Math.max(g,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=h,this._elevationRangeCacheMax=g}intersect(e,t,i,o,n,r,s){const a=e,{transform:l}=a,{position:c}=l;return null!=n&&(n.localOrigin=c),a.intersectionGeometry.intersect(t,i,o,n,a.componentData.verticalOffsets,l,r,s)}addEdges(e,t,i,o,n){const r=e,{indices:s,positions:a}=r.intersectionGeometry,l=r.componentData.offsets;return t.addComponentObject(r,a,s,l,i,o,n)}async extractEdgeInformation(e,t,i){const o=e,n=o.componentData.visibility;if(n.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:s,positions:a}=o.intersectionGeometry,m=o.componentData.offsets,{EdgeInputBufferLayout:p}=await import("../../lib/edgeRendering/bufferLayouts.js"),f=p.createBuffer(a.length/3);c(f.position.typedBuffer,a,f.position.typedBufferStride,3),l(f.position,f.position,o.transform.rotationScale),this._setComponentIndices(f.componentIndex,s,m);const h=f.count,g=this._computeVisibilityIndices(s,n,m,h);return{origin:r(o.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:g,indicesLength:g.length,skipDeduplicate:!0,data:f,writerSettings:{reducedPrecision:!1,variants:0}},i)}}_setComponentIndices(e,t,i){let o=0;for(let n=0;n<i.length-1;n++){const r=i[n],s=i[n+1];for(let i=r;i<s;i++){const n=t?t[i]:i;e.set(n,o)}o++}}_computeVisibilityIndices(e,t,i,n){if(e&&t.allVisible())return e;let r=0;t.forEachComponentRange(((e,t)=>(r+=i[t]-i[e],!0)));const s=o(e)?2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(r):new Uint32Array(r):new Array(r);let a=0;return t.forEachComponentRange(((t,o)=>{const n=i[t],r=i[o];for(let i=n;i<r;i++)s[a++]=e?e[i]:i;return!0})),s}addComponentHighlight(e,i,o){const n=e.componentData,r=t(n.componentHighlights,o,(()=>new Uint32Array(n.count+1)));{const e=this._activeHighlightOptions.get(o)??0;this._activeHighlightOptions.set(o,e+1)}0===r[i]++&&(n.markHighlightsDirty(),this._notifyDirty()),r[n.count]++}removeComponentHighlight(e,t,i){const{componentData:o}=e,n=o.componentHighlights.get(i);if(void 0===n)return void L().warn("Removing non-existing highlight.");const r=n[t];if(0===r)return void L().warn("Removing non-existing highlight.");this._removeActiveHighlight(i);const s=n[o.count];if(r>1)return n[t]=r-1,void(n[o.count]=s-1);n[t]=0,1===s?o.componentHighlights.delete(i):n[o.count]=s-1,o.markHighlightsDirty(),this._notifyDirty()}_removeActiveHighlight(e,t=1){const i=this._activeHighlightOptions.get(e);if(void 0===i)L().warn("Removing non-existing highlight.");else{const o=i-t;o<0&&L().warn("Removing non-existing highlight."),o<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,o)}}clearHighlights(e){const{componentData:t}=e,{componentHighlights:i}=t;if(i.size>0){for(const e of i)this._removeActiveHighlight(e[0],e[1][t.count]);i.clear(),t.markHighlightsDirty(),this._notifyDirty()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t){const i=this._renderManager.rctx,o=e.geometry,n=o.vertices.layoutParameters,r=P.createVertex(i,N.STATIC_DRAW,o.vertices.data),s=o.indices?P.createIndex(i,N.STATIC_DRAW,o.indices):null,a=g(M(n)),l=new Uint16Array(o.vertices.count);for(let g=0;g<t.count;g++){const e=t.offsets[g],i=t.offsets[g+1],n=t.materialDataIndices[g];if(null!=o.indices)for(let t=e;t<i;t++){l[o.indices[t]]=n}else for(let t=e;t<i;t++)l[t]=n}const c=P.createVertex(i,N.STATIC_DRAW,l.buffer),m=new D(e.transform,e.toMapSpace),p=new k(i,A,new Map([["data",a],["componentIndices",q]]),new Map([["data",r],["componentIndices",c]]),s),f=new _(p,T.TRIANGLES,n,null!=s),h={cameraDepthSquared:.5,gpuMemoryEstimate:r.usedMemory+c.usedMemory+(null!=s?s.usedMemory:0)};return new v(m,f,h)}_notifyDirty(){this._renderManager.notifyDirty()}}const q=g(d().u16(V.COMPONENTINDEX));function W(e,t){return e===t?O.All:0===e?O.None:O.Some}const z=s();export{G as ComponentObjectCollection};
5
+ import e from"../../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import o from"../../../../../core/PooledArray.js";import{isTypedArray as i}from"../../../../../core/typedArrayUtil.js";import{s as n}from"../../../../../chunks/vec32.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as a}from"../../../../../geometry/support/Indices.js";import{c as l}from"../../../../../chunks/vec3.js";import{c}from"../../../../../chunks/vec33.js";import{ViewingMode as m}from"../../../../ViewingMode.js";import{ColorMixModeEnum as f,encodeSymbolColor as h}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as p}from"../../../support/orientedBoundingBox.js";import{glLayout as g}from"../../../support/buffer/glUtil.js";import{newLayout as d}from"../../../support/buffer/InterleavedLayout.js";import{ComponentData as u}from"./ComponentData.js";import{ComponentObject as b}from"./ComponentObject.js";import{IntersectionGeometry as v}from"./IntersectionGeometry.js";import{Renderable as y}from"./Renderable.js";import{RenderGeometry as _}from"./RenderGeometry.js";import{RenderSubmitSystem as C}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as M}from"./SourceGeometry.js";import{UniformComponentParameters as j}from"./UniformComponentParameters.js";import{ComponentParametersVarying as w,ComponentParametersUniform as x,ComponentParameterSummary as O,ComponentMaterial as D}from"./Material/ComponentMaterial.js";import{vertexAttributeLocations as A}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as R}from"./Material/shader/ComponentData.glsl.js";import{olidEnabled as S}from"../../effects/geometry/olidUtils.js";import{getVisibility as E,updatePickabilityWithCount as I}from"../../lib/ComponentUtils.js";import{assert as H}from"../../lib/Util.js";import{VertexAttribute as V}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as U}from"../../lib/verticalOffsetUtils.js";import{BufferManager as B}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as P}from"../../../../webgl/BufferObject.js";import{Usage as N,PrimitiveType as T}from"../../../../webgl/enums.js";import{VertexArrayObject as L}from"../../../../webgl/VertexArrayObject.js";const k=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class G{constructor(e,t){this._renderManager=e,this._viewingMode=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._activeHighlightOptions=new Map,this._visible=new o,this._hidden=new o,this._renderSubmit=new C(this),this._renderManager.register(this._renderSubmit),this._componentBufferManager=new B(e.rctx,2+(S()?1:0))}destroy(){H(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._visible.forAll((e=>e.destroy())),this._visible.clear(),this._hidden.forAll((e=>e.destroy())),this._hidden.clear()}createObject(e){const t=e.geometry,o=new u(this._componentBufferManager,a(t.componentOffsets)),i=this._createRenderable(e,o),n=new v(this._viewingMode,t.positionData,o),r=new b(e.transform,e.toMapSpace,e.obb.clone(),o,i,n);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const o=e;t!==o.visible&&(t?(this._hidden.removeUnordered(o),this._visible.push(o)):(this._visible.removeUnordered(o),this._hidden.push(o)),o.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=n(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const o=e.renderable.material;t(o),o.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const o=e;o.componentData.visibility.reset(t),o.componentData.markVisibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){const t=e,o=t.componentData.visibility.componentCount;return{visible:o,invisible:t.componentData.count-o}}setComponentData(e,t){const o=e,{renderable:i,componentData:n}=o,r=i.material,s=n.materialDataBuffer,a=n.materialDataIndices,l=new j,c=s.textureBuffer,m=new Uint8Array(4),g=new Uint32Array(m.buffer);let d=0,u=0,b=0,v=n.verticalOffsets,y=1/0,_=-1/0,C=!1,M=!1,D=0;for(let p=0;p<n.count;p++){t(p,l),d+=+(l.externalColor[3]<1),u+=+(l.externalColorMixMode===f.Replace&&1===l.externalColor[3]),b+=+l.castShadows,h(l.externalColor,l.externalColorMixMode,m),m[2]=254&m[2]|+l.castShadows,c.setData(a[p],0,m[0],m[1],m[2],m[3]),C||=p>0&&D!==g[0],D=g[0],M||=0!==l.elevationOffset,M&&null==v&&(v=new Array(p).fill(0)),null!=v&&(v[p]=l.elevationOffset),y=Math.min(y,l.elevationOffset),_=Math.max(_,l.elevationOffset),R(l.elevationOffset,m),c.setData(a[p],1,m[0],m[1],m[2],m[3]);const e=l.objectAndLayerIdColor;null!=e&&c.setData(a[p],2,e[0],e[1],e[2],e[3]),l.pickable!==E(n.pickability,p)&&I(n,p,l.pickable)}n.verticalOffsets=M?v:null,o.offsetObb=M?p(o.obb,y,_,this._viewingMode,o.offsetObb??o.obb.clone()):null,C||M||S()?(r.componentParameters=new w,r.componentParameters.castShadows=W(b,n.count),r.componentParameters.transparent=W(d,n.count),r.componentParameters.opaqueOverride=W(u,n.count),r.componentParameters.texture=c,c.updateTexture()):(r.componentParameters=new x,r.componentParameters.castShadows=l.castShadows?O.All:O.None,r.componentParameters.externalColor=l.externalColor,r.componentParameters.externalColorMixMode=l.externalColorMixMode),this._elevationRangeCacheVerticalOffset=NaN,this._notifyDirty()}getComponentAabb(e,t,o,i=!1){e.intersectionGeometry.getComponentAabb(t,o);const n=e,r=n.componentData.verticalOffsets;if(i||null==r)return o;const s=r[t];if(this._viewingMode===m.Local||0===s)return o[2]+=s,o[5]+=s,o;const a=U(s);return a.localOrigin=n.transform.position,a.applyToAabb(o)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,o){return e.intersectionGeometry.getComponentPositions(t,o)}expandRangeWithComponentObjectElevationRange(e,t,o,i){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||i.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const n=e,r=n.componentData,s=r.count,a=r.verticalOffsets,l=n.intersectionGeometry,c=this._viewingMode===m.Local,f=l.getComponentAabbs(),h=z;let p=1/0,g=-1/0;for(let m=0;m<s;m++){const e=6*m,r=a?.[m]??0;let s=1/0,l=-1/0;if(c)s=f[e+2]+r+t,l=f[e+5]+r+t;else{if(h[0]=f[e],h[1]=f[e+1],h[2]=f[e+2],h[3]=f[e+3],h[4]=f[e+4],h[5]=f[e+5],0!==r){const e=U(r);e.localOrigin=n.transform.position,e.applyToAabb(h)}const s=Math.max(Math.abs(h[3]),Math.abs(h[0])),a=Math.max(Math.abs(h[4]),Math.abs(h[1])),l=t+h[5]+o;i.expandElevationRangeValues(t+h[2],Math.sqrt(s*s+a*a+l*l)-o)}i.expandElevationRangeValues(s,l),p=Math.min(p,s),g=Math.max(g,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=p,this._elevationRangeCacheMax=g}intersect(e,t,o,i,n,r,s){const a=e,{transform:l,componentData:c,intersectionGeometry:m}=a;return null!=n&&(n.localOrigin=l.position),m.intersect(t,o,i,n,c.verticalOffsets,l,r,s)}addEdges(e,t,o,i,n){const r=e,{indices:s,positions:a}=r.intersectionGeometry,l=r.componentData.offsets;return t.addComponentObject(r,a,s,l,o,i,n)}async extractEdgeInformation(e,t,o){const i=e,n=i.componentData.visibility;if(n.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:s,positions:a}=i.intersectionGeometry,m=i.componentData.offsets,{EdgeInputBufferLayout:f}=await import("../../lib/edgeRendering/bufferLayouts.js"),h=f.createBuffer(a.length/3);c(h.position.typedBuffer,a,h.position.typedBufferStride,3),l(h.position,h.position,i.transform.rotationScale),this._setComponentIndices(h.componentIndex,s,m);const p=h.count,g=this._computeVisibilityIndices(s,n,m,p);return{origin:r(i.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:g,indicesLength:g.length,skipDeduplicate:!0,data:h,writerSettings:{reducedPrecision:!1,variants:0}},o)}}_setComponentIndices(e,t,o){let i=0;for(let n=0;n<o.length-1;n++){const r=o[n],s=o[n+1];for(let o=r;o<s;o++){const n=t?t[o]:o;e.set(n,i)}i++}}_computeVisibilityIndices(e,t,o,n){if(e&&t.allVisible())return e;let r=0;t.forEachComponentRange(((e,t)=>(r+=o[t]-o[e],!0)));const s=i(e)?2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(r):new Uint32Array(r):new Array(r);let a=0;return t.forEachComponentRange(((t,i)=>{const n=o[t],r=o[i];for(let o=n;o<r;o++)s[a++]=e?e[o]:o;return!0})),s}addComponentHighlight(e,o,i){const n=e.componentData,r=t(n.componentHighlights,i,(()=>new Uint32Array(n.count+1)));{const e=this._activeHighlightOptions.get(i)??0;this._activeHighlightOptions.set(i,e+1)}0===r[o]++&&(n.markHighlightsDirty(),this._notifyDirty()),r[n.count]++}removeComponentHighlight(e,t,o){const{componentData:i}=e,n=i.componentHighlights.get(o);if(void 0===n)return void k().warn("Removing non-existing highlight.");const r=n[t];if(0===r)return void k().warn("Removing non-existing highlight.");this._removeActiveHighlight(o);const s=n[i.count];if(r>1)return n[t]=r-1,void(n[i.count]=s-1);n[t]=0,1===s?i.componentHighlights.delete(o):n[i.count]=s-1,i.markHighlightsDirty(),this._notifyDirty()}_removeActiveHighlight(e,t=1){const o=this._activeHighlightOptions.get(e);if(void 0===o)k().warn("Removing non-existing highlight.");else{const i=o-t;i<0&&k().warn("Removing non-existing highlight."),i<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,i)}}clearHighlights(e){const{componentData:t}=e,{componentHighlights:o}=t;if(o.size>0){for(const e of o)this._removeActiveHighlight(e[0],e[1][t.count]);o.clear(),t.markHighlightsDirty(),this._notifyDirty()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t){const o=this._renderManager.rctx,i=e.geometry,n=i.vertices.layoutParameters,r=P.createVertex(o,N.STATIC_DRAW,i.vertices.data),s=i.indices?P.createIndex(o,N.STATIC_DRAW,i.indices):null,a=g(M(n)),l=new Uint16Array(i.vertices.count);for(let g=0;g<t.count;g++){const e=t.offsets[g],o=t.offsets[g+1],n=t.materialDataIndices[g];if(null!=i.indices)for(let t=e;t<o;t++){l[i.indices[t]]=n}else for(let t=e;t<o;t++)l[t]=n}const c=P.createVertex(o,N.STATIC_DRAW,l.buffer),m=new D(e.transform,e.toMapSpace),f=new L(o,A,new Map([["data",a],["componentIndices",q]]),new Map([["data",r],["componentIndices",c]]),s),h=new _(f,T.TRIANGLES,n,null!=s),p={cameraDepthSquared:.5,gpuMemoryEstimate:r.usedMemory+c.usedMemory+(null!=s?s.usedMemory:0)};return new y(m,h,p)}_notifyDirty(){this._renderManager.notifyDirty()}}const q=g(d().u16(V.COMPONENTINDEX));function W(e,t){return e===t?O.All:0===e?O.None:O.Some}const z=s();export{G as ComponentObjectCollection};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{c as t,a as e}from"../../../../../chunks/vec32.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as o}from"../../../../../geometry/support/aaBoundingBox.js";import{ComponentObjectElevationAgnosticComponentGeometryBVH as s,intersectTriangleRangeForComponent as i}from"./ComponentObjectElevationAgnosticComponentGeometryBVH.js";import{ElevationAgnosticBVH as r}from"./ElevationAgnosticBVH.js";import{getVisibility as a}from"../../lib/ComponentUtils.js";import{computeInvDir as c,intersectAabbInvDir as l,MeshIntersectionOptions as h}from"../../lib/RayIntersections.js";class m{constructor(t,e,o,s,i,a,c,l){this.vertexData=t,this.vertexStride=e,this.indexData=o,this._components=s,this._componentAabbs3D=i,this.geometryMinZ=a,this.planetCenterZ=c,this.localMode=l,this.maxBspNodeDepth=6,this.minElementCountForBVH=10,this.minBspNodeElementCount=3,this._ray0=f,this._ray1=u,this._invDir=n(),this._componentVerticalOffsets=null,this._verticalOffset=null,this._tolerance=0,this._intersectionOptions=D,this._callback=y,this.rayDirectionC=n(),this._componentIndexMap=null,this._bvh=new r(s.count,this),this.componentIntersectionData=new Array(s.count)}get numComponents(){return this._components.count}get minZGlobal(){return this.geometryMinZ-this.planetCenterZ}getAabbs2D(){return this.localMode?this.getAabbs2DLocal():this.getAabbs2DGlobal()}getAabbs2DGlobal(){const{numComponents:t,planetCenterZ:e,minZGlobal:n}=this,o=new Float64Array(4*t),s=this._componentAabbs3D;for(let i=0;i<t;++i){const t=6*i,r=s[t+0],a=s[t+1],c=s[t+2],l=s[t+3],h=s[t+4],m=n/(c-e),p=n/(s[t+5]-e),_=Math.min(r*m,r*p),b=Math.min(a*m,a*p),f=Math.max(l*m,l*p),u=Math.max(h*m,h*p),y=4*i;o[y+0]=_,o[y+1]=b,o[y+2]=f,o[y+3]=u}return o}getAabbs2DLocal(){const{numComponents:t}=this,e=new Float64Array(4*t),n=this._componentAabbs3D;for(let o=0;o<t;++o){const t=6*o,s=n[t+0],i=n[t+1],r=n[t+3],a=n[t+4],c=4*o;e[c+0]=s,e[c+1]=i,e[c+2]=r,e[c+3]=a}return e}intersectRay(t,e,n,o,s,i,r){const{isVerticalRay:a}=r;this._ray0=t,this._ray1=e,this._componentVerticalOffsets=n,this._verticalOffset=o,this._tolerance=i,this._intersectionOptions=r,this._componentIndexMap=this._bvh.elementIndexMap,c(t,e,this._invDir),this._callback=s,this._bvh.intersectRay(t,e,a),this._callback=y}intersectRange(t,e){const n=this._componentIndexMap,o=this._components,s=o.pickability,i=o.visibility;for(let r=t;r<e;++r){const t=n?n[r]:r;a(s,t)&&i.isVisible(t)&&this._intersectComponent(t)}}getComponentTriangleCount(t){const e=this._components.offsets,n=e[t]/3;return e[t+1]/3-n}getComponentAabb3D(t,e){const n=this._componentAabbs3D,o=6*t;return e[0]=n[o],e[1]=n[o+1],e[2]=n[o+2],e[3]=n[o+3],e[4]=n[o+4],e[5]=n[o+5],e}_intersectComponent(n){if(!a(this._components.pickability,n))return;const o=this.getComponentAabb3D(n,p);let r=!1;const{localMode:c,_componentVerticalOffsets:h,_verticalOffset:m,_ray0:f,_ray1:u,_invDir:y,planetCenterZ:D,_tolerance:C,rayDirectionC:v,componentIntersectionData:A}=this,{isVerticalRay:x}=this._intersectionOptions,d=this._components.offsets,M=t(_,f),O=t(b,u),V=h?.[n]??0,Z=V+(m?.offset??0);if(0!==Z&&(c?(M[2]=f[2]-Z,O[2]=u[2]-Z,r=!0):null!=m&&(m.componentOffset=V)),null==m||r||0===Z||m.applyToAabb(o),!l(o,M,y,C))return;e(v,O,M);const j=d[n]/3,R=d[n+1]/3,k=R-j,B=(t,e,o)=>{this._callback(t,e,n,o)},{vertexData:I,vertexStride:w,indexData:G,_intersectionOptions:E}=this,{normalRequired:F}=E;if(k>g){let t=A[n];null==t&&(t=new s(n,I,w,G,j,R,this.geometryMinZ,D,c),A[n]=t),t.intersectRay(M,O,x,r?0:Z,B,F)}else{i(M,v,j,R,G,I,w,r?0:Z,D,F,B)}}}const p=o(),_=n(),b=n(),f=n(),u=n(),y=()=>{},D=new h,g=40;export{m as ComponentObjectElevationAgnosticComponentBVH};
5
+ import{c as t,a as e}from"../../../../../chunks/vec32.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as o}from"../../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as s}from"../../../../../geometry/support/DoubleArray.js";import{ComponentObjectElevationAgnosticComponentGeometryBVH as i,intersectTriangleRangeForComponent as r}from"./ComponentObjectElevationAgnosticComponentGeometryBVH.js";import{ElevationAgnosticBVH as a}from"./ElevationAgnosticBVH.js";import{getVisibility as c}from"../../lib/ComponentUtils.js";import{computeInvDir as l,intersectAabbInvDir as m,MeshIntersectionOptions as h}from"../../lib/RayIntersections.js";class p{constructor(t,e,o,s,i,r,c,l){this.vertexData=t,this.vertexStride=e,this.indexData=o,this._components=s,this._componentAabbs3D=i,this.geometryMinZ=r,this.planetCenterZ=c,this.localMode=l,this.maxBspNodeDepth=6,this.minElementCountForBVH=10,this.minBspNodeElementCount=3,this._ray0=u,this._ray1=y,this._invDir=n(),this._componentVerticalOffsets=null,this._verticalOffset=null,this._tolerance=0,this._intersectionOptions=g,this._callback=D,this.rayDirectionC=n(),this._componentIndexMap=null,this._bvh=new a(s.count,this),this.componentIntersectionData=new Array(s.count)}get numComponents(){return this._components.count}get minZGlobal(){return this.geometryMinZ-this.planetCenterZ}getAabbs2D(){return this.localMode?this.getAabbs2DLocal():this.getAabbs2DGlobal()}getAabbs2DGlobal(){const{numComponents:t,planetCenterZ:e,minZGlobal:n}=this,o=s(4*t),i=this._componentAabbs3D;for(let s=0;s<t;++s){const t=6*s,r=i[t+0],a=i[t+1],c=i[t+2],l=i[t+3],m=i[t+4],h=n/(c-e),p=n/(i[t+5]-e),b=Math.min(r*h,r*p),_=Math.min(a*h,a*p),f=Math.max(l*h,l*p),u=Math.max(m*h,m*p),y=4*s;o[y+0]=b,o[y+1]=_,o[y+2]=f,o[y+3]=u}return o}getAabbs2DLocal(){const{numComponents:t}=this,e=s(4*t),n=this._componentAabbs3D;for(let o=0;o<t;++o){const t=6*o,s=n[t+0],i=n[t+1],r=n[t+3],a=n[t+4],c=4*o;e[c+0]=s,e[c+1]=i,e[c+2]=r,e[c+3]=a}return e}intersectRay(t,e,n,o,s,i,r){const{isVerticalRay:a}=r;this._ray0=t,this._ray1=e,this._componentVerticalOffsets=n,this._verticalOffset=o,this._tolerance=i,this._intersectionOptions=r,this._componentIndexMap=this._bvh.elementIndexMap,l(t,e,this._invDir),this._callback=s,this._bvh.intersectRay(t,e,a),this._callback=D}intersectRange(t,e){const n=this._componentIndexMap,{pickability:o,visibility:s}=this._components;for(let i=t;i<e;++i){const t=n?n[i]:i;c(o,t)&&s.isVisible(t)&&this._intersectComponent(t)}}getComponentTriangleCount(t){const e=this._components.offsets,n=e[t]/3;return e[t+1]/3-n}getComponentAabb3D(t,e){const n=this._componentAabbs3D,o=6*t;return e[0]=n[o],e[1]=n[o+1],e[2]=n[o+2],e[3]=n[o+3],e[4]=n[o+4],e[5]=n[o+5],e}_intersectComponent(n){const o=this.getComponentAabb3D(n,b);let s=!1;const{localMode:a,_componentVerticalOffsets:c,_verticalOffset:l,_ray0:h,_ray1:p,_invDir:u,planetCenterZ:y,_tolerance:D,rayDirectionC:g,componentIntersectionData:v}=this,{isVerticalRay:x}=this._intersectionOptions,A=this._components.offsets,d=t(_,h),M=t(f,p),O=c?.[n]??0,j=O+(l?.offset??0);if(0!==j&&(a?(d[2]=h[2]-j,M[2]=p[2]-j,s=!0):null!=l&&(l.componentOffset=O)),null==l||s||0===j||l.applyToAabb(o),!m(o,d,u,D))return;e(g,M,d);const V=A[n]/3,Z=A[n+1]/3,R=Z-V,B=(t,e,o)=>{this._callback(t,e,n,o)},{vertexData:I,vertexStride:k,indexData:G,_intersectionOptions:w}=this,{normalRequired:E}=w;if(R>C){let t=v[n];null==t&&(t=new i(n,I,k,G,V,Z,this.geometryMinZ,y,a),v[n]=t),t.intersectRay(d,M,x,s?0:j,B,E)}else{r(d,g,V,Z,G,I,k,s?0:j,y,E,B)}}}const b=o(),_=n(),f=n(),u=n(),y=n(),D=()=>{},g=new h,C=40;export{p as ComponentObjectElevationAgnosticComponentBVH};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
+ */
5
+ class t{constructor(t){this._totalCount=t,this._componentCountCache=-1,this._indexRanges=[0,t]}allVisible(){return this.componentCount===this._totalCount}allInvisible(){return 0===this._indexRanges.length}isVisible(t){if(t<0||t>=this._totalCount)return!1;if(this.allVisible())return!0;const n=this._indexRanges;let e=0,o=n.length/2;if(t<n[2*e]||t>n[2*o]+n[2*o+1])return!1;for(;o-e>0;){const s=Math.floor(.5*(e+o)),i=n[2*s];if(t<i){if(o-e==1)return!1;o=s;continue}if(t<i+n[2*s+1])return!0;if(o-e==1)return!1;e=s+1}return!1}get componentCount(){if(-1===this._componentCountCache){const t=this._indexRanges;let n=0;for(let e=0;e<t.length;e+=2)n+=t[e+1];this._componentCountCache=n}return this._componentCountCache}reset(t){"all"===t||t.length===this._totalCount?this._indexRanges=[0,this._totalCount]:this._indexRanges=n(t),this._componentCountCache=-1}forEachComponent(t){const n=this._indexRanges;for(let e=0;e<n.length;e+=2){const o=n[e],s=o+n[e+1];for(let n=o;n<s;n++)if(!t(n))return!1}return!0}forEachComponentRange(t){const n=this._indexRanges;for(let e=0;e<n.length;e+=2){const o=n[e];if(!t(o,o+n[e+1]))return!1}return!0}computeOffsetRanges(t){const n=new Array(this._indexRanges.length),e=this._indexRanges;for(let o=0;o<e.length;o+=2){const s=e[o],i=s+e[o+1],r=t[s],h=t[i];n[o]=r,n[o+1]=h-r}return n}}function n(t){const n=new Array;if(0===t.length)return n;let e=t[0],o=1;for(let s=1;s<t.length;s++){const i=t[s];e+o===i?o+=1:(n.push(e),n.push(o),e=i,o=1)}return n.push(e),n.push(o),n}export{t as ComponentRange};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{reallocGrowthFactor as t}from"../../../../core/arrayUtils.js";function n(n,i,e,s){if(e>=i)return n;null==n&&(n=r());const a=n.isVisibleBit;let l=n.data;const c=u(l),f=e/c|0,h=e-c*f,B=(i-1)/c|0,E=l,b=s===a;if(!(e<E.length*c)&&b){const n=f+1,i=Math.ceil(E.length*t),r=B+1;let e=Math.max(n,i);e=Math.min(e,r),l=new Uint32Array(e),l.set(E)}return f<l.length&&(l[f]=o(l[f],h,b)),n.data=l,n}function i(t,n){if(null==t)return!0;const{isVisibleBit:i,data:r}=t,o=u(r);return n<r.length*o?e(i,r,n,o):!t.isVisibleBit}function r(t=!0){return{isVisibleBit:!t,data:new Uint32Array(0)}}function e(t,n,i,r){const e=i/r|0,u=i-e*r;return s(n[e],u)===t}function u(t){const n=8;return t.BYTES_PER_ELEMENT*n}function o(t,n,i){return t&~(1<<n)|(i?1:0)<<n}function s(t,n){return!!(t&1<<n)}export{r as defaultVisibilities,i as getVisibility,n as updateVisibilityWithCount};
5
+ import{reallocGrowthFactor as t}from"../../../../core/arrayUtils.js";function n(n,i,r){const o=n.count;if(i>=o)return;n.pickability??=new Uint32Array(0);let u=n.pickability;const l=e(u),a=i/l|0,f=i-l*a,s=(o-1)/l|0,h=u;if(!(i<h.length*l)&&r){const i=a+1,r=Math.ceil(h.length*t),e=s+1;let c=Math.max(i,r);c=Math.min(c,e),n.pickability=u=new Uint32Array(c),u.set(h)}a<u.length&&(u[a]=c(u[a],f,r))}function i(t,n){if(null==t)return!0;const i=e(t);return n<t.length*i&&r(t,n,i)}function r(t,n,i){const r=n/i|0,e=n-r*i;return!!o(t[r],e)}function e(t){const n=8;return t.BYTES_PER_ELEMENT*n}function c(t,n,i){return t&~(1<<n)|(i?1:0)<<n}function o(t,n){return!!(t&1<<n)}export{i as getVisibility,n as updatePickabilityWithCount};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{isSome as t}from"../../../../../core/arrayUtils.js";import r from"../../../../../core/Error.js";import{someMap as n,getOrCreateMapValue as s}from"../../../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{isAborted as i,throwIfAborted as o}from"../../../../../core/promiseUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as c}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d,f as u,t as m}from"../../../../../chunks/vec32.js";import{create as p}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as f,fromValues as _}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{debugFlags as g}from"../../../support/debugFlags.js";import{glLayout as I}from"../../../support/buffer/glUtil.js";import{newLayout as y}from"../../../support/buffer/InterleavedLayout.js";import v from"../../../webgl/RenderCamera.js";import{ShaderOutput as C}from"../../core/shaderLibrary/ShaderOutput.js";import{AsyncRenderPlugin as E}from"../../effects/RenderPlugin.js";import{Default3D as R}from"../DefaultVertexAttributeLocations.js";import{DepthRange as D}from"../DepthRange.js";import{IntersectorType as A}from"../IntersectorInterfaces.js";import b from"../Octree.js";import{RenderSlot as T}from"../RenderSlot.js";import{assert as L}from"../Util.js";import{VertexAttribute as S}from"../VertexAttribute.js";import{InstanceData as O,StateFlags as j}from"./InstanceData.js";import{InstanceOctree as x}from"./InstanceOctree.js";import{LevelSelector as M}from"./LevelSelector.js";import{LodLevel as N}from"./LodLevel.js";import{RenderInstanceData as w}from"./RenderInstanceData.js";import{colorMixModes as H}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as U}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as F}from"../../shaders/DefaultMaterialTechnique.js";import{defaultHighlightName as V}from"../../../../support/HighlightDefaults.js";import{TaskPriority as B,noBudget as q}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as G,unbindVertexBufferLayout as P}from"../../../../webgl/Util.js";const z=e=>{const t=e.baseBoundingSphere.radius,r=e.levels.map((e=>e.minScreenSpaceRadius));return new M(t,r)};let k=class extends E{constructor(e,t){super(e),this.type=A.LOD,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=new Array,this._highlightRenderInstanceDataMap=new Map,this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new v,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.produces=new Map([[T.OPAQUE_MATERIAL,e=>this._produces(e)],[T.TRANSPARENT_MATERIAL,e=>!!this._hasTransparentLevels()&&this._produces(e)]]),this._instanceData=new O({shaderTransformation:e.shaderTransformation},e.optionalFields),this.addHandles(t.registerTask(B.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=Y(this.optionalFields),this._glInstanceBufferLayout=I(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",(()=>this._requestUpdateCycle())),this._instanceData.events.on("instance-transform-changed",(({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)})),this._instanceData.events.on("instance-visibility-changed",(({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)})),this._instanceData.events.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0)))])}get _allRenderInstanceData(){return[this._defaultRenderInstanceData,...this._highlightRenderInstanceDataMap.values()]}get _allRenderInstanceDataExceptHighlightShadow(){const e=[this._defaultRenderInstanceData];for(const t of this._highlightRenderInstanceDataMap)t[0]!==V&&e.push(t[1]);return e}hasHighlight(e){return this._highlightRenderInstanceDataMap.has(e)}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this.metadata.layerUid}get instanceData(){return this._instanceData}get hasEmissions(){return this._levels.some((e=>e.components.some((e=>e.material.hasEmissions))))}get usedMemory(){return this._allRenderInstanceData.reduce(((e,t)=>t.reduce(((e,t)=>e+t.usedMemory),e)),this._levels.reduce(((e,t)=>e+t.components.reduce(((e,t)=>e+t.usedMemory),0)),0))}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,r)=>{const n=this._allRenderInstanceData[0][r].size+this._allRenderInstanceData[1][r].size,s=e.triangleCount;t.push({renderedInstances:n,renderedTriangles:n*s,trianglesPerInstance:s})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}_createRenderInstanceDataArray(e=[]){const{rctx:t}=this._context.renderContext;return this.symbol.levels.map((r=>{e.push(new w(t,this._instanceBufferLayout))})),e}async initializeRenderContext(e,r){this._context=e,this._createRenderInstanceDataArray(this._defaultRenderInstanceData);const n=await Promise.allSettled(this.symbol.levels.map((t=>N.create(e,t,r)))),s=n.map((e=>"fulfilled"===e.status?e.value:null)).filter(t);if(i(r)||s.length!==n.length){s.forEach((e=>e.destroy())),o(r);for(const e of n)if("rejected"===e.status)throw e.reason}this._levels=s,this._levelSelector=z(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData.forEach((e=>e.destroy())),this._highlightRenderInstanceDataMap.forEach((e=>e.forEach((e=>e.destroy()))))}_hasTransparentLevels(){return this._levels.some((e=>e.components.some((e=>{const t=e.material.produces.get(T.TRANSPARENT_MATERIAL);return t?.(C.Color)}))))}hasHighlights(){return n(this._highlightRenderInstanceDataMap,(e=>e.some((e=>e.size>0))))}_produces(e){return(e!==C.Highlight||this.hasHighlights())&&(e!==C.ShadowHighlight||this.hasHighlight(V))}prepareRender(e){if(!g.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bind.contentCamera.equals(this._camera);this._camera.copyFrom(e.bind.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(q),this._needFullCycle=!1)}}acquireTechniques(e){if(!this.baseMaterial.visible||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e);if(!t)return null;const r=new Array,n=this.levels;return t.forEach((t=>n.forEach((({components:n},s)=>n.forEach((n=>r.push(this._beginComponent(e,t[s],n)))))))),r}render(e,t){const r=this._getInstanceDatas(e);if(!r||null==t)return;let n=0;e.rctx.bindVAO();const s=this.levels;r.forEach((r=>s.forEach((({components:s},a)=>s.forEach((s=>this._renderComponent(e,t[n++],r[a],s,a)))))))}_getInstanceDatas(e){const{output:t,bind:r}=e,n=t===C.Highlight,s=!n&&t!==C.ShadowHighlight,a=t!==C.ShadowExcludeHighlight;if(s)return a?this._allRenderInstanceData:this._allRenderInstanceDataExceptHighlightShadow;if(a){if(n){const e=r.highlight?.name;if(!e)return null;const t=this._highlightRenderInstanceDataMap.get(e);return t?[t]:null}return Array.from(this._highlightRenderInstanceDataMap.values())}return null}intersect(e,t,r,n){if(!this.baseMaterial.visible||null==this._octree)return;const s=p();d(s,n,r);const a=s=>{this._instanceData.getCombinedModelTransform(s,Z),e.transform.set(Z),m($,r,e.transform.inverse),m(X,n,e.transform.inverse);const a=this._instanceData.getState(s),i=this._instanceData.getLodLevel(s),o=this._levels.length;L(!!(a&j.ACTIVE),"invalid instance state"),L(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,$,X,s,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(a):this._octree.forEachAlongRay(r,s,a)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new x(e,this.baseBoundingSphere);for(let r=0;r<e.capacity;++r)t.get(r)&j.ACTIVE&&this._octreeCached.addInstance(r)}return this._octreeCached}_invalidateOctree(){this._octreeCached=a(this._octreeCached)}queryDepthRange(e){if(null==this._octree)return new D;const t=e.viewForward,r=this._octree.findClosest(t,b.DepthOrder.FRONT_TO_BACK,e.frustum),n=this._octree.findClosest(t,b.DepthOrder.BACK_TO_FRONT,e.frustum);if(null==r||null==n)return new D;const s=e.eye,a=this._instanceData.view;a.boundingSphere.getVec(r,Q),d(Q,Q,s);const i=u(Q,t)-Q[3];a.boundingSphere.getVec(n,Q),d(Q,Q,s);const o=u(Q,t)+Q[3];return new D(i,o)}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.startUpdateCycle()))))}get running(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:n,_levelSelector:a}=this;this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.beginUpdate()))));const i=this._instanceData,o=i.view;let l=i.size;const c=i.capacity;let h=this._instanceIndex;const d=Math.ceil(c/500);for(let u=0;u<l&&!e.done;++u){h===this._cycleStartIndex&&this._startUpdateCycle();const u=o.state.get(h);let m=0;if(!(u&j.ALLOCATED)){h=h+1===c?0:h+1,l++;continue}const p=o.lodLevel.get(h);if(u&j.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[p].freeTail(),u&j.HIGHLIGHT_ACTIVE){const e=i.geHighlightOptionsPrev(h);if(e){const t=this._highlightRenderInstanceDataMap.get(e);if(!t)throw new r("Internal error in lodRenderer");t[p].freeTail()}}if(u&j.REMOVE)i.freeInstance(h);else if(u&j.VISIBLE){let e=0;if(t&&(o.modelOrigin.getVec(h,J),e=a.selectLevel(J,i.getCombinedMedianScaleFactor(h),n)),m=u&~(j.ACTIVE|j.TRANSFORM_CHANGED),e>=0)if(u&j.HIGHLIGHT){const t=i.getHighlightName(h);if(t){const n=()=>{const e=this._createRenderInstanceDataArray();return e.forEach((e=>e.beginUpdate())),e},a=s(this._highlightRenderInstanceDataMap,t,n);if(e>=a.length)throw new r(`LodRenderer internal error - missing lodLevel ${e}`);W(a[e],o,h)}m|=j.HIGHLIGHT_ACTIVE}else W(this._defaultRenderInstanceData[e],o,h),m|=j.DEFAULT_ACTIVE;o.state.set(h,m),o.lodLevel.set(h,e)}else m=u&~(j.ACTIVE|j.TRANSFORM_CHANGED),o.state.set(h,m);if(null!=this._octreeCached){const e=!!(u&j.ACTIVE),t=!!(m&j.ACTIVE);!e&&t?this._octreeCached.addInstance(h):e&&!t?this._octreeCached.removeInstance(h):e&&t&&u&j.TRANSFORM_CHANGED&&(this._octreeCached.removeInstance(h),this._octreeCached.addInstance(h))}h=h+1===c?0:h+1,h%d==0&&e.madeProgress()}this._instanceIndex=h,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.endUpdate())))),this._context.requestRender()}_beginComponent(e,t,r){if(0===t.size)return null;const n=r.glMaterials.load(e.rctx,e.bind.slot,e.output);return n?.beginSlot(e.bind)}_renderComponent(e,t,r,n,s){if(!t)return;const{bind:a,rctx:i}=e;i.runAppleAmdDriverHelper();const o=i.bindTechnique(t,a,n.material.parameters,te);i.bindVAO(n.vao),t.ensureAttributeLocations(n.vao),g.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&e.output===C.Color&&(o.setUniform4fv("externalColor",ee[Math.min(s,ee.length-1)]),o.setUniform1i("colorMixMode",H.replace));const l=r.capacity,c=r.headIndex,h=r.tailIndex,d=r.firstIndex,u=this._glInstanceBufferLayout,m=(e,s)=>{G(i,R,r.buffer,u,e),i.drawArraysInstanced(t.primitiveType,0,n.vertexCount,s-e),P(i,R,r.buffer,u)};n.material.parameters.transparent&&null!=d?c>h?(L(d>=h&&d<=c,"invalid firstIndex"),m(d,c),m(h,d)):c<h&&(d<=c?(L(d>=0&&d<=c,"invalid firstIndex"),m(d,c),m(h,l),m(0,d)):(L(d>=h&&d<=l,"invalid firstIndex"),m(d,l),m(0,c),m(h,d))):c>h?m(h,c):c<h&&(m(0,c),m(h,l)),i.bindVAO(null)}};function W(e,t,r){const n=e.allocateHead();K(t,r,e.view,n)}function K(e,t,r,n){U(e.modelOrigin,t,r.modelOriginHi,r.modelOriginLo,n),r.model.copyFrom(n,e.model,t),r.modelNormal.copyFrom(n,e.modelNormal,t),e.color&&r.color&&r.color.copyFrom(n,e.color,t),e.objectAndLayerIdColor&&r.objectAndLayerIdColor&&r.objectAndLayerIdColor.copyFrom(n,e.objectAndLayerIdColor,t),e.featureAttribute&&r.featureAttribute&&r.featureAttribute.copyFrom(n,e.featureAttribute,t)}function Y(e){let t=y().vec3f(S.INSTANCEMODELORIGINHI).vec3f(S.INSTANCEMODELORIGINLO).mat3f(S.INSTANCEMODEL).mat3f(S.INSTANCEMODELNORMAL);return null!=e&&e.includes("featureAttribute")&&(t=t.vec4f(S.INSTANCEFEATUREATTRIBUTE)),null!=e&&e.includes("color")&&(t=t.vec4u8(S.INSTANCECOLOR)),null!=e&&e.includes("objectAndLayerIdColor")&&(t=t.vec4u8(S.INSTANCEOBJECTANDLAYERIDCOLOR)),t}e([l({constructOnly:!0})],k.prototype,"symbol",void 0),e([l({constructOnly:!0})],k.prototype,"optionalFields",void 0),e([l({constructOnly:!0})],k.prototype,"metadata",void 0),e([l({constructOnly:!0})],k.prototype,"shaderTransformation",void 0),e([l()],k.prototype,"_instanceData",void 0),e([l()],k.prototype,"_cycleStartIndex",void 0),e([l({readOnly:!0})],k.prototype,"_enableLevelSelection",null),e([l()],k.prototype,"_updateCyclesWithStaticCamera",void 0),e([l({readOnly:!0})],k.prototype,"running",null),k=e([c("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],k);const J=p(),Q=f(),Z=h(),$=p(),X=p(),ee=[_(1,0,1,1),_(0,0,1,1),_(0,1,0,1),_(1,1,0,1),_(1,0,0,1)],te=new F;export{k as LodRenderer};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{isSome as t}from"../../../../../core/arrayUtils.js";import r from"../../../../../core/Error.js";import{someMap as n,getOrCreateMapValue as s}from"../../../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{isAborted as i,throwIfAborted as o}from"../../../../../core/promiseUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as c}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d,f as u,t as m}from"../../../../../chunks/vec32.js";import{create as p}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as f,fromValues as _}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{debugFlags as g}from"../../../support/debugFlags.js";import{glLayout as I}from"../../../support/buffer/glUtil.js";import{newLayout as y}from"../../../support/buffer/InterleavedLayout.js";import v from"../../../webgl/RenderCamera.js";import{ShaderOutput as C}from"../../core/shaderLibrary/ShaderOutput.js";import{AsyncRenderPlugin as E}from"../../effects/RenderPlugin.js";import{Default3D as R}from"../DefaultVertexAttributeLocations.js";import{DepthRange as D}from"../DepthRange.js";import{IntersectorType as A}from"../IntersectorInterfaces.js";import b from"../Octree.js";import{RenderSlot as T}from"../RenderSlot.js";import{assert as L}from"../Util.js";import{VertexAttribute as S}from"../VertexAttribute.js";import{InstanceData as O,StateFlags as j}from"./InstanceData.js";import{InstanceOctree as M}from"./InstanceOctree.js";import{LevelSelector as x}from"./LevelSelector.js";import{LodLevel as N}from"./LodLevel.js";import{RenderInstanceData as w}from"./RenderInstanceData.js";import{colorMixModes as H}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as U}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as F}from"../../shaders/DefaultMaterialTechnique.js";import{defaultHighlightName as V}from"../../../../support/HighlightDefaults.js";import{TaskPriority as B,noBudget as q}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as G,unbindVertexBufferLayout as P}from"../../../../webgl/Util.js";const z=e=>{const t=e.baseBoundingSphere.radius,r=e.levels.map((e=>e.minScreenSpaceRadius));return new x(t,r)};let k=class extends E{constructor(e,t){super(e),this.type=A.LOD,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=new Array,this._highlightRenderInstanceDataMap=new Map,this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new v,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.produces=new Map([[T.OPAQUE_MATERIAL,e=>this._produces(e)],[T.TRANSPARENT_MATERIAL,e=>!!this._hasTransparentLevels()&&this._produces(e)]]),this._instanceData=new O({shaderTransformation:e.shaderTransformation},e.optionalFields),this.addHandles(t.registerTask(B.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=Y(this.optionalFields),this._glInstanceBufferLayout=I(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",(()=>this._requestUpdateCycle())),this._instanceData.events.on("instance-transform-changed",(({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)})),this._instanceData.events.on("instance-visibility-changed",(({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)})),this._instanceData.events.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0)))])}get _allRenderInstanceData(){return[this._defaultRenderInstanceData,...this._highlightRenderInstanceDataMap.values()]}get _allRenderInstanceDataExceptHighlightShadow(){const e=[this._defaultRenderInstanceData];for(const t of this._highlightRenderInstanceDataMap)t[0]!==V&&e.push(t[1]);return e}hasHighlight(e){return this._highlightRenderInstanceDataMap.has(e)}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this.metadata.layerUid}get instanceData(){return this._instanceData}get hasEmissions(){return this._levels.some((e=>e.components.some((e=>e.material.hasEmissions))))}get usedMemory(){return this._allRenderInstanceData.reduce(((e,t)=>t.reduce(((e,t)=>e+t.usedMemory),e)),this._levels.reduce(((e,t)=>e+t.components.reduce(((e,t)=>e+t.usedMemory),0)),0))}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,r)=>{const n=this._allRenderInstanceData[0][r].size+this._allRenderInstanceData[1][r].size,s=e.triangleCount;t.push({renderedInstances:n,renderedTriangles:n*s,trianglesPerInstance:s})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}_createRenderInstanceDataArray(e=[]){const{rctx:t}=this._context.renderContext;return this.symbol.levels.map((r=>{e.push(new w(t,this._instanceBufferLayout))})),e}async initializeRenderContext(e,r){this._context=e,this._createRenderInstanceDataArray(this._defaultRenderInstanceData);const n=await Promise.allSettled(this.symbol.levels.map((t=>N.create(e,t,r)))),s=n.map((e=>"fulfilled"===e.status?e.value:null)).filter(t);if(i(r)||s.length!==n.length){s.forEach((e=>e.destroy())),o(r);for(const e of n)if("rejected"===e.status)throw e.reason}this._levels=s,this._levelSelector=z(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData.forEach((e=>e.destroy())),this._highlightRenderInstanceDataMap.forEach((e=>e.forEach((e=>e.destroy()))))}_hasTransparentLevels(){return this._levels.some((e=>e.components.some((e=>{const t=e.material.produces.get(T.TRANSPARENT_MATERIAL);return t?.(C.Color)}))))}hasHighlights(){return n(this._highlightRenderInstanceDataMap,(e=>e.some((e=>e.size>0))))}_produces(e){return(e!==C.Highlight||this.hasHighlights())&&(e!==C.ShadowHighlight||this.hasHighlight(V))}prepareRender(e){if(!g.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bind.contentCamera.equals(this._camera);this._camera.copyFrom(e.bind.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(q),this._needFullCycle=!1)}}acquireTechniques(e){if(!this.baseMaterial.visible||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e);if(!t)return null;const r=new Array,n=this.levels;return t.forEach((t=>n.forEach((({components:n},s)=>n.forEach((n=>r.push(this._beginComponent(e,t[s],n)))))))),r}render(e,t){const r=this._getInstanceDatas(e);if(!r||null==t)return;let n=0;e.rctx.bindVAO();const s=this.levels;r.forEach((r=>s.forEach((({components:s},a)=>s.forEach((s=>this._renderComponent(e,t[n++],r[a],s,a)))))))}_getInstanceDatas(e){const{output:t,bind:r}=e,n=t===C.Highlight,s=t===C.ShadowHighlight,a=!n&&!s,i=t!==C.ShadowExcludeHighlight;if(a)return i?this._allRenderInstanceData:this._allRenderInstanceDataExceptHighlightShadow;if(i){if(n){const e=r.highlight?.name;if(!e)return null;const t=this._highlightRenderInstanceDataMap.get(e);return t?[t]:null}const e=this._highlightRenderInstanceDataMap.get(V);return s?e?[e]:null:Array.from(this._highlightRenderInstanceDataMap.values())}return null}intersect(e,t,r,n){if(!this.baseMaterial.visible||null==this._octree)return;const s=p();d(s,n,r);const a=s=>{this._instanceData.getCombinedModelTransform(s,Z),e.transform.set(Z),m($,r,e.transform.inverse),m(X,n,e.transform.inverse);const a=this._instanceData.getState(s),i=this._instanceData.getLodLevel(s),o=this._levels.length;L(!!(a&j.ACTIVE),"invalid instance state"),L(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,$,X,s,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(a):this._octree.forEachAlongRay(r,s,a)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new M(e,this.baseBoundingSphere);for(let r=0;r<e.capacity;++r)t.get(r)&j.ACTIVE&&this._octreeCached.addInstance(r)}return this._octreeCached}_invalidateOctree(){this._octreeCached=a(this._octreeCached)}queryDepthRange(e){if(null==this._octree)return new D;const t=e.viewForward,r=this._octree.findClosest(t,b.DepthOrder.FRONT_TO_BACK,e.frustum),n=this._octree.findClosest(t,b.DepthOrder.BACK_TO_FRONT,e.frustum);if(null==r||null==n)return new D;const s=e.eye,a=this._instanceData.view;a.boundingSphere.getVec(r,Q),d(Q,Q,s);const i=u(Q,t)-Q[3];a.boundingSphere.getVec(n,Q),d(Q,Q,s);const o=u(Q,t)+Q[3];return new D(i,o)}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.startUpdateCycle()))))}get running(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:n,_levelSelector:a}=this;this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.beginUpdate()))));const i=this._instanceData,o=i.view;let l=i.size;const c=i.capacity;let h=this._instanceIndex;const d=Math.ceil(c/500);for(let u=0;u<l&&!e.done;++u){h===this._cycleStartIndex&&this._startUpdateCycle();const u=o.state.get(h);let m=0;if(!(u&j.ALLOCATED)){h=h+1===c?0:h+1,l++;continue}const p=o.lodLevel.get(h);if(u&j.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[p].freeTail(),u&j.HIGHLIGHT_ACTIVE){const e=i.geHighlightOptionsPrev(h);if(e){const t=this._highlightRenderInstanceDataMap.get(e);if(!t)throw new r("Internal error in lodRenderer");t[p].freeTail()}}if(u&j.REMOVE)i.freeInstance(h);else if(u&j.VISIBLE){let e=0;if(t&&(o.modelOrigin.getVec(h,J),e=a.selectLevel(J,i.getCombinedMedianScaleFactor(h),n)),m=u&~(j.ACTIVE|j.TRANSFORM_CHANGED),e>=0)if(u&j.HIGHLIGHT){const t=i.getHighlightName(h);if(t){const n=()=>{const e=this._createRenderInstanceDataArray();return e.forEach((e=>e.beginUpdate())),e},a=s(this._highlightRenderInstanceDataMap,t,n);if(e>=a.length)throw new r(`LodRenderer internal error - missing lodLevel ${e}`);W(a[e],o,h)}m|=j.HIGHLIGHT_ACTIVE}else W(this._defaultRenderInstanceData[e],o,h),m|=j.DEFAULT_ACTIVE;o.state.set(h,m),o.lodLevel.set(h,e)}else m=u&~(j.ACTIVE|j.TRANSFORM_CHANGED),o.state.set(h,m);if(null!=this._octreeCached){const e=!!(u&j.ACTIVE),t=!!(m&j.ACTIVE);!e&&t?this._octreeCached.addInstance(h):e&&!t?this._octreeCached.removeInstance(h):e&&t&&u&j.TRANSFORM_CHANGED&&(this._octreeCached.removeInstance(h),this._octreeCached.addInstance(h))}h=h+1===c?0:h+1,h%d==0&&e.madeProgress()}this._instanceIndex=h,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.endUpdate())))),this._context.requestRender()}_beginComponent(e,t,r){if(0===t.size)return null;const n=r.glMaterials.load(e.rctx,e.bind.slot,e.output);return n?.beginSlot(e.bind)}_renderComponent(e,t,r,n,s){if(!t)return;const{bind:a,rctx:i}=e;i.runAppleAmdDriverHelper();const o=i.bindTechnique(t,a,n.material.parameters,te);i.bindVAO(n.vao),t.ensureAttributeLocations(n.vao),g.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&e.output===C.Color&&(o.setUniform4fv("externalColor",ee[Math.min(s,ee.length-1)]),o.setUniform1i("colorMixMode",H.replace));const l=r.capacity,c=r.headIndex,h=r.tailIndex,d=r.firstIndex,u=this._glInstanceBufferLayout,m=(e,s)=>{G(i,R,r.buffer,u,e),i.drawArraysInstanced(t.primitiveType,0,n.vertexCount,s-e),P(i,R,r.buffer,u)};n.material.parameters.transparent&&null!=d?c>h?(L(d>=h&&d<=c,"invalid firstIndex"),m(d,c),m(h,d)):c<h&&(d<=c?(L(d>=0&&d<=c,"invalid firstIndex"),m(d,c),m(h,l),m(0,d)):(L(d>=h&&d<=l,"invalid firstIndex"),m(d,l),m(0,c),m(h,d))):c>h?m(h,c):c<h&&(m(0,c),m(h,l)),i.bindVAO(null)}};function W(e,t,r){const n=e.allocateHead();K(t,r,e.view,n)}function K(e,t,r,n){U(e.modelOrigin,t,r.modelOriginHi,r.modelOriginLo,n),r.model.copyFrom(n,e.model,t),r.modelNormal.copyFrom(n,e.modelNormal,t),e.color&&r.color&&r.color.copyFrom(n,e.color,t),e.objectAndLayerIdColor&&r.objectAndLayerIdColor&&r.objectAndLayerIdColor.copyFrom(n,e.objectAndLayerIdColor,t),e.featureAttribute&&r.featureAttribute&&r.featureAttribute.copyFrom(n,e.featureAttribute,t)}function Y(e){let t=y().vec3f(S.INSTANCEMODELORIGINHI).vec3f(S.INSTANCEMODELORIGINLO).mat3f(S.INSTANCEMODEL).mat3f(S.INSTANCEMODELNORMAL);return null!=e&&e.includes("featureAttribute")&&(t=t.vec4f(S.INSTANCEFEATUREATTRIBUTE)),null!=e&&e.includes("color")&&(t=t.vec4u8(S.INSTANCECOLOR)),null!=e&&e.includes("objectAndLayerIdColor")&&(t=t.vec4u8(S.INSTANCEOBJECTANDLAYERIDCOLOR)),t}e([l({constructOnly:!0})],k.prototype,"symbol",void 0),e([l({constructOnly:!0})],k.prototype,"optionalFields",void 0),e([l({constructOnly:!0})],k.prototype,"metadata",void 0),e([l({constructOnly:!0})],k.prototype,"shaderTransformation",void 0),e([l()],k.prototype,"_instanceData",void 0),e([l()],k.prototype,"_cycleStartIndex",void 0),e([l({readOnly:!0})],k.prototype,"_enableLevelSelection",null),e([l()],k.prototype,"_updateCyclesWithStaticCamera",void 0),e([l({readOnly:!0})],k.prototype,"running",null),k=e([c("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],k);const J=p(),Q=f(),Z=h(),$=p(),X=p(),ee=[_(1,0,1,1),_(0,0,1,1),_(0,1,0,1),_(1,1,0,1),_(1,0,0,1)],te=new F;export{k as LodRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- class t{constructor(t=0,o=0){this.from=t,this.to=o}get numElements(){return this.to-this.from}}function o(t){const o=new Map;t.forAll((t=>o.set(t.from,t)));let e=!0;for(;e;){e=!1;for(let r=0;r<t.length;++r){const n=t.data[r],s=o.get(n.to);if(!s)return;n.to=s.to,o.delete(s.from),t.removeUnordered(s),e=!0}}}export{t as BufferRange,o as mergeAdjacentRanges};
5
+ class t{constructor(t=0,e=0){this.from=t,this.to=e}get numElements(){return this.to-this.from}}function e(t){if(t.length<2)return;const e=new Map;t.forAll((t=>e.set(t.from,t)));let o=!0;for(;o;){o=!1;for(let r=0;r<t.length;++r){const n=t.data[r],s=e.get(n.to);s&&(n.to=s.to,e.delete(s.from),t.removeUnordered(s),o=!0)}}}export{t as BufferRange,e as mergeAdjacentRanges};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Color.js";import i from"../Viewpoint.js";import s from"../core/Accessor.js";import r from"../core/Evented.js";import o from"../core/Promise.js";import{watch as a,whenOnce as n,initial as d,syncAndInitial as l}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import p from"../geometry/Extent.js";import c from"../geometry/SpatialReference.js";import y from"../layers/support/ExtentAndRotationGeoreference.js";import{MediaElementView as g}from"../layers/support/MediaElementView.js";import w from"../layers/support/VideoElement.js";import{DOMContainer as v}from"./DOMContainer.js";import{extentToScale as u}from"./2d/viewpointUtils.js";import{ViewStateManager as f}from"./2d/ViewStateManager.js";import j from"./2d/engine/webgl/Overlay.js";import V from"./2d/engine/webgl/OverlayContainer.js";const _=new t("#000");let C;async function E(){const[,{Stage:e}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);C=e}function x(e,t){const[i,s]=e,[r,o]=t,a=r/o,n=s*a,d=i/a;return i/s>=1?a>=1?n<=i?[n,s]:[i,d]:d<=s?[i,d]:[n,s]:a>=1?d<=s?[i,d]:[n,s]:n<=i?[n,s]:[i,d]}function M(e,t){const s=e&&u(e,t);return new i({targetGeometry:e.center,scale:s})}function b(e){return new p({xmin:0,ymin:0,xmax:e[0],ymax:e[1],spatialReference:{wkid:0}})}let R=class extends s{};R=e([m("esri.views.VideoView.Base")],R);let H=class extends(v(r.EventedMixin(o.EsriPromiseMixin(R)))){constructor(e){super(e),this.stateManager=new f,this._isValid=!1,this.layer=null,this.ready=!1,this.addHandles([a((()=>this.preconditionsReady),(e=>{e?this._startup():this._teardown()})),a((()=>this.layer),(()=>this.addResolvingPromise(n((()=>this.ready)))),d)])}initialize(){this.addResolvingPromise(E().then((()=>(this._isValid=!0,n((()=>this.ready))))))}destroy(){this._teardown()}get state(){return this.stateManager.state}get preconditionsReady(){return!(!this._isValid||0===this.width||0===this.height||0===this.videoWidth||0===this.videoHeight)}get videoHeight(){return this.layer?.videoHeight||0}get videoWidth(){return this.layer?.videoWidth||0}_startup(){if(!this.layer)return;const e=x(this.size,[this.videoWidth,this.videoHeight]),t=b(e),i=M(t,e);this._mediaElementView=new g({element:new w({video:this.layer.videoElement,georeference:new y({extent:t}),autoplay:!1}),spatialReference:new c({wkid:0})}),this.stateManager.startup(i,this.size,i.targetGeometry.spatialReference);const s=new C(this.surface,{renderingOptions:{samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},backgroundColor:_});this.stage=s,this.addHandles([a((()=>this.state.id),(()=>s.state=this.state),l),this.on("resize",(({width:e,height:t})=>{if(this._mediaElementView){const i=x([e,t],[this.videoWidth,this.videoHeight]),s=b(i);this._mediaElementView.element.georeference=new y({extent:s}),this.stateManager.viewpoint=M(s,i),this.stateManager.resize(e,t)}}))],"video-view");const r=new j(this._mediaElementView);this.overlayContainer=new V,this.overlayContainer.addChild(r),this.stage.addChild(this.overlayContainer),this._set("ready",!0)}_teardown(){this.stage.destroy(),this.stage=null,this._mediaElementView=null,this.overlayContainer.removeAllChildren(),this.overlayContainer=null,this.removeHandles("video-view"),this._set("ready",!1),this.stateManager.teardown()}};e([h()],H.prototype,"stateManager",void 0),e([h({readOnly:!0})],H.prototype,"state",null),e([h()],H.prototype,"_isValid",void 0),e([h()],H.prototype,"layer",void 0),e([h({readOnly:!0})],H.prototype,"preconditionsReady",null),e([h({readOnly:!0})],H.prototype,"ready",void 0),e([h({readOnly:!0})],H.prototype,"videoHeight",null),e([h({readOnly:!0})],H.prototype,"videoWidth",null),H=e([m("esri.views.VideoView")],H);const O=H;export{O as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Color.js";import i from"../Viewpoint.js";import s from"../core/Accessor.js";import r from"../core/Evented.js";import{destroyMaybe as o}from"../core/maybe.js";import n from"../core/Promise.js";import{watch as a,whenOnce as m,initial as l,syncAndInitial as p}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{cast as h}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{ensureClass as g}from"../core/accessorSupport/ensureType.js";import f from"../geometry/Extent.js";import j from"../geometry/Point.js";import y from"../geometry/SpatialReference.js";import u from"../layers/support/ExtentAndRotationGeoreference.js";import{MediaElementView as w}from"../layers/support/MediaElementView.js";import b from"../layers/support/TileInfo.js";import v from"../layers/support/VideoElement.js";import{DOMContainer as M}from"./DOMContainer.js";import{Viewport2DMixin as _}from"./Viewport2DMixin.js";import x from"./2d/AnimationManager.js";import G from"./2d/MapViewConstraints.js";import"../core/Error.js";import"../core/scheduling.js";import"../core/Logger.js";import"../core/accessorSupport/tracking/Flags.js";import"../core/colorUtils.js";import"../config.js";import"../symbols/cim/defaultCIMValues.js";import"../symbols/cim/enums.js";import"../core/floatRGBA.js";import"../geometry/Geometry.js";import"../geometry/Multipoint.js";import"../geometry/Polygon.js";import"../geometry/Polyline.js";import"./2d/engine/webgl/definitions.js";import"./2d/engine/webgl/animations/instructions.js";import"../core/mathUtils.js";import"../symbols/Font.js";import"../core/ObjectPool.js";import"../geometry/support/Axis.js";import"../geometry/support/spatialReferenceUtils.js";import"../geometry/support/TileClipper.js";import"../symbols/cim/effects/EffectAddControlPoints.js";import"../symbols/cim/effects/EffectArrow.js";import"../symbols/cim/effects/EffectBuffer.js";import"../symbols/cim/effects/EffectControlMeasureLine.js";import"../symbols/cim/effects/EffectCut.js";import"../symbols/cim/effects/EffectDashes.js";import"../symbols/cim/effects/EffectDonut.js";import"../symbols/cim/effects/EffectJog.js";import"../symbols/cim/effects/EffectMove.js";import"../symbols/cim/effects/EffectOffset.js";import"../symbols/cim/effects/EffectReverse.js";import"../symbols/cim/effects/EffectRotate.js";import"../symbols/cim/effects/EffectScale.js";import"../symbols/cim/effects/EffectWave.js";import"../symbols/cim/placements/PlacementAlongLineSameSize.js";import"../symbols/cim/placements/PlacementAtExtremities.js";import"../symbols/cim/placements/PlacementAtRatioPositions.js";import"../symbols/cim/placements/PlacementInsidePolygon.js";import"../symbols/cim/placements/PlacementOnLine.js";import"../symbols/cim/placements/PlacementOnVertices.js";import"../symbols/cim/placements/PlacementPolygonCenter.js";import"../core/libs/gl-matrix-2/factories/vec2f32.js";import"./2d/engine/webgl/alignmentUtils.js";import"../symbols/support/defaults.js";import"../symbols/cim/OverrideHelper.js";import"../layers/effects/EffectView.js";import"./2d/engine/transitions/FadeTransition.js";import"./2d/engine/webgl/enums.js";import"../core/libs/gl-matrix-2/factories/vec4f32.js";import"./webgl/checkWebGLError.js";import"./webgl/enums.js";import"./webgl/FramebufferObject.js";import"./webgl/GLObjectType.js";import"./webgl/Texture.js";import"./2d/engine/webgl/shaders/BackgroundPrograms.js";import"./2d/engine/webgl/DefaultVertexAttributeLayouts.js";import"./2d/engine/webgl/AFeatureTile.js";import"./2d/engine/webgl/DisplayEntity.js";import"./2d/engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js";import"./2d/engine/webgl/number.js";import"./2d/engine/webgl/PooledUint32Array.js";import"./2d/engine/webgl/shaders/TileInfoPrograms.js";import"./2d/engine/vectorTiles/style/StyleDefinition.js";import"./2d/engine/vectorTiles/enums.js";import"./2d/engine/webgl/shaders/BitBlitPrograms.js";import"../request.js";import"../core/urlUtils.js";import"../core/pbf.js";import"./2d/engine/webgl/shaders/StencilPrograms.js";import"./2d/engine/webgl/shaderGraph/techniques/TechniqueType.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BlendShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/OpacityShader.js";import"./2d/engine/webgl/shaders/HighlightPrograms.js";import"./2d/engine/webgl/meshing/SimpleMesh.js";import"./2d/engine/webgl/Profiler.js";import"./2d/engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/constants.js";import"./2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/ComplexFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/FillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/OutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/PatternFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapMeshWriter.js";import"../geometry/support/aaBoundingBox.js";import"./2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/line/TexturedLineMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js";import"../arcade/ArcadeDate.js";import"./2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js";import"./webgl/renderState.js";import"./3d/webgl-engine/core/shaderModules/glsl.js";import"./webgl/testSVGPremultipliedAlpha.js";import"./2d/LabelManager.js";import"./2d/layers/graphics/GraphicsView2D.js";import"../chunks/earcut.js";import"../core/libs/gl-matrix-2/factories/vec3f32.js";import"../geometry/support/normalizeUtilsCommon.js";import"../geometry/support/Ellipsoid.js";import"../kernel.js";import"./2d/layers/support/util.js";import C from"./2d/navigation/MapViewNavigation.js";import"../core/asyncUtils.js";import"../core/support/UpdatingHandles.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/MagnifierShader.js";import"../core/unitUtils.js";import"../geometry/ellipsoidUtils.js";import"../chunks/pe.js";import"../geometry/projection/projectors.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/GridShader.js";import"../geometry/support/geodesicConstants.js";import{ViewStateManager as S}from"./2d/ViewStateManager.js";import P from"./2d/engine/webgl/Overlay.js";import E from"./2d/engine/webgl/OverlayContainer.js";import q from"./navigation/Navigation.js";import V from"./ui/DefaultUI.js";import R from"./ui/2d/DefaultUI2D.js";const O=new t("#000");let T;async function W(){const[,{Stage:e}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);T=e}const z=.01;let k=class extends s{};k=e([d("esri.views.VideoView.Base")],k);let A=class extends(_(M(r.EventedMixin(n.EsriPromiseMixin(k))))){constructor(e){super(e),this._isValid=!1,this.stage=null,this.layer=null,this.navigation=new q,this.ready=!1,this.stateManager=new S({constraints:new G({view:this,minScale:1,maxScale:z})}),this.spatialReference=new y({wkid:0}),this.type="2d",this.ui=new R,this.addHandles([a((()=>this.preconditionsReady),(e=>e?this._startup():this._teardown())),a((()=>this.layer),(()=>this.addResolvingPromise(m((()=>this.ready)))),l),a((()=>[this.layer?.effect,this._overlayContainer,this.effect]),(()=>{this._overlayContainer&&(this._overlayContainer.effect=this.effect??this.layer?.effect??null)}),p),a((()=>this.videoSize),(([e,t])=>{this._extent&&e&&t&&(this._extent.xmax=e,this._extent.ymax=t)}))])}initialize(){this.addResolvingPromise(W().then((()=>(this._isValid=!0,m((()=>this.ready))))))}destroy(){this._teardown()}get constraintsInfo(){return{lods:null,spatialReference:this.spatialReference}}get effect(){return this.layer?.effect}set effect(e){this._override("effect",e)}get preconditionsReady(){return!(!this._isValid||0===this.width||0===this.height||0===this.videoSize[0]||0===this.videoSize[1])}get rendering(){return this.stage?.renderRequested??!1}get videoSize(){if(!this.layer?.videoWidth||!this.layer?.videoHeight)return[0,0];const[e,t]=this.size,i=(this.layer?.videoWidth||0)/(this.layer?.videoHeight||0),s=t*i,r=e/i;return e/t>=1?i>=1?s<=e?[s,t]:[e,r]:r<=t?[e,r]:[s,t]:i>=1?r<=t?[e,r]:[s,t]:s<=e?[s,t]:[e,r]}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}_startup(){if(!this.layer)return;const e=this._getViewpoint();this.stateManager.startup(e,this.size,e.targetGeometry.spatialReference),this.stage=new T(this.surface,{renderingOptions:this.renderingOptions,backgroundColor:O}),this._prepareStage(this.stage);const t=new x({view:this});this._set("animationManager",t);const i=new C({view:this,animationManager:t});this._set("mapViewNavigation",i),this._updateConstraints(),this.frameTask.start(),this._set("ready",!0)}_teardown(){this.stage.destroy(),this.stage=null,this._videoElementView=null,this._overlayContainer.removeAllChildren(),this._overlayContainer=null,this.removeAllHandles(),this._set("ready",!1),this.stateManager.teardown(),this.frameTask.stop(),this.stationaryManager.clear(),this.frameTask=o(this.frameTask),this.goToManager.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}_getViewpoint(){return new i({targetGeometry:new j({x:this.videoSize[0]/2,y:this.videoSize[1]/2,spatialReference:this.spatialReference}),scale:1})}_prepareStage(e){this.addHandles([a((()=>this.stationary),(t=>e.stationary=t),p),a((()=>this.state.id),(()=>e.state=this.state),p),a((()=>this.renderingOptions),(t=>e.renderingOptions=t),p)],"video-view"),this._extent=new f({xmin:0,ymin:0,xmax:this.videoSize[0],ymax:this.videoSize[1],spatialReference:{wkid:0}}),this._videoElementView=new w({element:new v({video:this.layer?.videoElement,georeference:new u({extent:this._extent}),autoplay:!1}),spatialReference:this.spatialReference});const t=new P(this._videoElementView);this._overlayContainer=new E,this._overlayContainer.addChild(t),this.stage.addChild(this._overlayContainer)}_updateConstraints(){this._updateZoomConstraints(),this._updatePanConstraints()}_updateZoomConstraints(){const e=this.videoSize,t=Math.max(e[0]/this.size[0],e[1]/this.size[1]),i=[];for(let r=t;r>z;r/=2)i.push(r);i.push(z);const{lods:s}=b.create({scales:i});this.constraints.set({lods:s,minScale:t})}_updatePanConstraints(){const e=e=>{if(!e.targetGeometry)return e;const[t,i]=this.videoSize,s=t*e.scale/2,r=i*e.scale/2,o=e.targetGeometry.clone();return o.x=Math.max(s,Math.min(t-s,o.x)),o.y=Math.max(r,Math.min(i-r,o.y)),e.targetGeometry=o,e};this.constraints.customConstraints.add({constrain:e,applyPanConstraint:e})}};e([c()],A.prototype,"_overlayContainer",void 0),e([c()],A.prototype,"_isValid",void 0),e([c()],A.prototype,"constraintsInfo",null),e([c()],A.prototype,"effect",null),e([c()],A.prototype,"layer",void 0),e([c({type:q,nonNullable:!0})],A.prototype,"navigation",void 0),e([c({readOnly:!0})],A.prototype,"preconditionsReady",null),e([c({readOnly:!0})],A.prototype,"ready",void 0),e([c({readOnly:!0})],A.prototype,"rendering",null),e([c()],A.prototype,"stateManager",void 0),e([c({readOnly:!0})],A.prototype,"videoSize",null),e([c()],A.prototype,"scale",null),e([c()],A.prototype,"spatialReference",void 0),e([c()],A.prototype,"type",void 0),e([c(),h((e=>e instanceof V?e:g(R,e)))],A.prototype,"ui",void 0),A=e([d("esri.views.VideoView")],A);const D=A;export{D as default};