@arcgis/core 6.0.0-next.8 → 6.0.0-next.9

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 (330) hide show
  1. package/arcade/featureSetUtils.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{85908e6e9c50749cee60.js → 037a8cc19debbaaa4e10.js} +1 -1
  4. package/assets/esri/core/workers/chunks/066550852483ab8f77bc.js +1 -0
  5. package/assets/esri/core/workers/chunks/0f725cf79ce00e790a7d.js +1 -0
  6. package/assets/esri/core/workers/chunks/12a7997a40c77f5c9160.js +1 -0
  7. package/assets/esri/core/workers/chunks/1b077c92345ffb5916c2.js +1 -0
  8. package/assets/esri/core/workers/chunks/{6dd0b79fa3a629ab4f27.js → 1bca39e0e651426bdbb5.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{1b35ec54968fbeec17ce.js → 2686fe5b62dd0be699c0.js} +1 -1
  10. package/assets/esri/core/workers/chunks/2a97268000c6d03ef720.js +1 -0
  11. package/assets/esri/core/workers/chunks/2e2e33ec50e97b91b178.js +1 -0
  12. package/assets/esri/core/workers/chunks/{7a05b18f655c1167ce0a.js → 2ef5237e4c876d6a4ee0.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{776ae25a34352d3468bc.js → 3081ee6d8019494fc21e.js} +1 -1
  14. package/assets/esri/core/workers/chunks/37d6a264a3f1d8072aa0.js +1 -0
  15. package/assets/esri/core/workers/chunks/3df5500a85345577480a.js +1 -0
  16. package/assets/esri/core/workers/chunks/{ded8b64a46992c3ae693.js → 40a584cb952e94326e9e.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{1ba0dfbe0958cdbd7c9f.js → 42fd2a7b22b03dacc6a7.js} +1 -1
  18. package/assets/esri/core/workers/chunks/444e5f214abce3d607cd.js +1 -0
  19. package/assets/esri/core/workers/chunks/{d201fbf3ceff946d2bd6.js → 44d5508042cacdfcac47.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{09a63cc1987f8636c5b0.js → 4503b20ca6a80fb63d72.js} +1 -1
  21. package/assets/esri/core/workers/chunks/45367aa8e5c5d574de94.js +1 -0
  22. package/assets/esri/core/workers/chunks/45800373650fbc8262e6.js +1 -0
  23. package/assets/esri/core/workers/chunks/{6a7ab1ef9a37e87db5ae.js → 46a7da93a63663878583.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{f43a50d4bd9636e68ae5.js → 46b4fb6a7fe4877b0efc.js} +63 -61
  25. package/assets/esri/core/workers/chunks/47d074136a7f8e551a9a.js +1 -0
  26. package/assets/esri/core/workers/chunks/{257910cca66dc5df465e.js → 4911ce62421a6c3320b0.js} +1 -1
  27. package/assets/esri/core/workers/chunks/4a1e23e021bac37a88ab.js +1 -0
  28. package/assets/esri/core/workers/chunks/4debf2d9c3465250ef7a.js +1 -0
  29. package/assets/esri/core/workers/chunks/4e8e322b469657ac22e2.js +1 -0
  30. package/assets/esri/core/workers/chunks/54b18559280a7d2a8d93.js +1 -0
  31. package/assets/esri/core/workers/chunks/567a65f4203f6e81f4b4.js +1 -0
  32. package/assets/esri/core/workers/chunks/5c7780f804d789cb37f5.js +1 -0
  33. package/assets/esri/core/workers/chunks/{ceb680688fe7e570a774.js → 608be1172a908e92b9f1.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{6f358116f79021ff9687.js → 612104dff305ff062dfa.js} +2 -2
  35. package/assets/esri/core/workers/chunks/6299be5e7e26bf3c6859.js +1 -0
  36. package/assets/esri/core/workers/chunks/6400446b7615b97c3521.js +1 -0
  37. package/assets/esri/core/workers/chunks/6431480ba0fa8c8d487f.js +1 -0
  38. package/assets/esri/core/workers/chunks/6c9acd9e4e201dc380e9.js +1 -0
  39. package/assets/esri/core/workers/chunks/7449568eb2305bf2d650.js +1 -0
  40. package/assets/esri/core/workers/chunks/745a153d0cd34faa124e.js +1 -0
  41. package/assets/esri/core/workers/chunks/7572c2bc5062e66f6330.js +1 -0
  42. package/assets/esri/core/workers/chunks/78472a57c2ba146fec65.js +1 -0
  43. package/assets/esri/core/workers/chunks/7f0f9dddc44b1f1600f0.js +1 -0
  44. package/assets/esri/core/workers/chunks/{56a24061589f4a968818.js → 814751e705c05099f864.js} +1 -1
  45. package/assets/esri/core/workers/chunks/8293600f94553afc8c38.js +1 -0
  46. package/assets/esri/core/workers/chunks/836bb3673ab30fc66f1e.js +1 -0
  47. package/assets/esri/core/workers/chunks/8487727f1197cf7dbf50.js +1 -0
  48. package/assets/esri/core/workers/chunks/{ceb112fe7aef354f8051.js → 88e54449261ef94e390d.js} +1 -1
  49. package/assets/esri/core/workers/chunks/8b0d5551978ab0aac0d1.js +1 -0
  50. package/assets/esri/core/workers/chunks/8d0c2de92770a1567536.js +1 -0
  51. package/assets/esri/core/workers/chunks/{c76c42c74eedd43263d3.js → 9dd1fc56eb1ea6eb705e.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{86a051e9fe71aa356108.js → 9e3e442a9874ed23a043.js} +1 -1
  53. package/assets/esri/core/workers/chunks/a40b6d8b5c73e06e14d4.js +1 -0
  54. package/assets/esri/core/workers/chunks/aaba33611753c6aada68.js +1 -0
  55. package/assets/esri/core/workers/chunks/aeaaff7a4b1a99540f52.js +1 -0
  56. package/assets/esri/core/workers/chunks/{ecaac39dde7ec4213264.js → af75747b06d79446a855.js} +1 -1
  57. package/assets/esri/core/workers/chunks/b564ec4e03478f5659db.js +1 -0
  58. package/assets/esri/core/workers/chunks/bc0f54a2c15502b630ec.js +1 -0
  59. package/assets/esri/core/workers/chunks/c1c534e08fc21842670b.js +1 -0
  60. package/assets/esri/core/workers/chunks/{9ab25ee06041f907b9a2.js → c2c1f51a4668055c2838.js} +1 -1
  61. package/assets/esri/core/workers/chunks/c337fc0e6dc69c233e6d.js +1 -0
  62. package/assets/esri/core/workers/chunks/{a7985d20fa6e8d4878e7.js → d0f5bee9db1ad51ae687.js} +1 -1
  63. package/assets/esri/core/workers/chunks/dba280c370df13196711.js +1 -0
  64. package/assets/esri/core/workers/chunks/{19b9d393046a780e6c3f.js → de5ecb567bd69c613e9d.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{534186fc921a0ccf58dc.js → e1f5d00878f27e1d413e.js} +1 -1
  66. package/assets/esri/core/workers/chunks/e65dfa19f030ec298437.js +1 -0
  67. package/assets/esri/core/workers/chunks/e932951598499befabf5.js +1 -0
  68. package/assets/esri/core/workers/chunks/f1df76f098a3cc924832.js +1 -0
  69. package/assets/esri/core/workers/chunks/f1f90adae13b04898008.js +1 -0
  70. package/assets/esri/core/workers/chunks/f4f9d08b2df856e3b694.js +1 -0
  71. package/assets/esri/core/workers/chunks/fc44227c1756f65b95df.js +1 -0
  72. package/assets/esri/core/workers/chunks/{3b737dae6efed627406e.js → fc44d45598a7476bc606.js} +1 -1
  73. package/assets/esri/themes/base/_mixins.scss +2 -2
  74. package/assets/esri/themes/base/widgets/_Attribution.scss +1 -1
  75. package/assets/esri/themes/base/widgets/_BasemapLayerList.scss +2 -2
  76. package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +5 -5
  77. package/assets/esri/themes/base/widgets/_Bookmarks.scss +1 -1
  78. package/assets/esri/themes/base/widgets/_BuildingLevelPicker.scss +2 -2
  79. package/assets/esri/themes/base/widgets/_BuildingPhasePicker.scss +5 -5
  80. package/assets/esri/themes/base/widgets/_CatalogLayerList.scss +1 -1
  81. package/assets/esri/themes/base/widgets/_Compass.scss +0 -2
  82. package/assets/esri/themes/base/widgets/_DirectionalPad.scss +4 -10
  83. package/assets/esri/themes/base/widgets/_Directions.scss +40 -40
  84. package/assets/esri/themes/base/widgets/_Editor.scss +7 -7
  85. package/assets/esri/themes/base/widgets/_Expand.scss +1 -1
  86. package/assets/esri/themes/base/widgets/_Feature.scss +1 -1
  87. package/assets/esri/themes/base/widgets/_FeatureForm.scss +6 -6
  88. package/assets/esri/themes/base/widgets/_FeatureFormUtilityNetworkAssociationLayers.scss +1 -1
  89. package/assets/esri/themes/base/widgets/_FeatureFormUtilityNetworkAssociationList.scss +1 -1
  90. package/assets/esri/themes/base/widgets/_FeatureFormUtilityNetworkAssociationSettings.scss +3 -3
  91. package/assets/esri/themes/base/widgets/_FeatureTable.scss +27 -27
  92. package/assets/esri/themes/base/widgets/_FeatureTemplates.scss +1 -1
  93. package/assets/esri/themes/base/widgets/_Features.scss +5 -5
  94. package/assets/esri/themes/base/widgets/_FilterBuilder.scss +1 -1
  95. package/assets/esri/themes/base/widgets/_FilterCondition.scss +1 -1
  96. package/assets/esri/themes/base/widgets/_Grid.scss +18 -18
  97. package/assets/esri/themes/base/widgets/_GridControls.scss +11 -11
  98. package/assets/esri/themes/base/widgets/_LayerList.scss +1 -1
  99. package/assets/esri/themes/base/widgets/_Legend.scss +5 -5
  100. package/assets/esri/themes/base/widgets/_NavigationToggle.scss +4 -1
  101. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +18 -19
  102. package/assets/esri/themes/base/widgets/_ResponsiveToolbar.scss +0 -2
  103. package/assets/esri/themes/base/widgets/_SearchResultRenderer.scss +1 -1
  104. package/assets/esri/themes/base/widgets/_SelectionList.scss +15 -15
  105. package/assets/esri/themes/base/widgets/_SelectionToolbar.scss +2 -2
  106. package/assets/esri/themes/base/widgets/_ShadowCast.scss +11 -11
  107. package/assets/esri/themes/base/widgets/_Sketch.scss +1 -1
  108. package/assets/esri/themes/base/widgets/_Slice.scss +3 -3
  109. package/assets/esri/themes/base/widgets/_SnappingControls.scss +1 -1
  110. package/assets/esri/themes/base/widgets/_TimeSlider.scss +5 -5
  111. package/assets/esri/themes/base/widgets/_TimeZoneLabel.scss +5 -4
  112. package/assets/esri/themes/base/widgets/_Tooltip.scss +14 -17
  113. package/assets/esri/themes/base/widgets/_UtilityNetworkAssociations.scss +2 -2
  114. package/assets/esri/themes/base/widgets/_UtilityNetworkTrace.scss +1 -1
  115. package/assets/esri/themes/base/widgets/_UtilityNetworkValidateTopology.scss +2 -2
  116. package/assets/esri/themes/base/widgets/_ValuePicker.scss +2 -2
  117. package/assets/esri/themes/base/widgets/_VideoPlayer.scss +5 -5
  118. package/assets/esri/themes/base/widgets/_Widget.scss +5 -1
  119. package/assets/esri/themes/dark/main.css +1 -1
  120. package/assets/esri/themes/light/main.css +1 -1
  121. package/assets/esri/themes/light/view.css +1 -1
  122. package/chunks/AtmosphereCompositing.glsl.js +1 -1
  123. package/chunks/ChapmanAtmosphere.glsl.js +3 -3
  124. package/chunks/CloudsComposition.glsl.js +1 -1
  125. package/chunks/Component.glsl.js +41 -41
  126. package/chunks/DefaultMaterial.glsl.js +2 -2
  127. package/chunks/EdgeShader.glsl.js +9 -9
  128. package/chunks/Fog.glsl.js +5 -5
  129. package/chunks/GaussianSplat.glsl.js +2 -2
  130. package/chunks/GlobalIllumination.glsl.js +9 -9
  131. package/chunks/HUDMaterial.glsl.js +13 -13
  132. package/chunks/Haze.glsl.js +6 -6
  133. package/chunks/HazeCompositing.glsl.js +1 -1
  134. package/chunks/LaserlinePath.glsl.js +6 -6
  135. package/chunks/LineCallout.glsl.js +1 -1
  136. package/chunks/LineMarker.glsl.js +5 -5
  137. package/chunks/NavigationDepth.glsl.js +2 -2
  138. package/chunks/Path.glsl.js +1 -1
  139. package/chunks/Pattern.glsl.js +26 -26
  140. package/chunks/Precipitation.glsl.js +7 -7
  141. package/chunks/RealisticTree.glsl.js +2 -2
  142. package/chunks/RibbonLine.glsl.js +60 -60
  143. package/chunks/ShadowCastAccumulate.glsl.js +1 -1
  144. package/chunks/ShadowHighlight.glsl.js +5 -5
  145. package/chunks/ShadowHighlightBuffer.glsl.js +1 -1
  146. package/chunks/SimpleAtmosphere.glsl.js +4 -4
  147. package/chunks/Terrain.glsl.js +29 -32
  148. package/chunks/Viewshed.glsl.js +2 -2
  149. package/chunks/Water.glsl.js +2 -2
  150. package/config.js +1 -1
  151. package/core/Loadable.js +1 -1
  152. package/geometry/HeightModelInfo.js +1 -1
  153. package/geometry/support/meshUtils.d.ts +1 -1
  154. package/kernel.js +1 -1
  155. package/layers/BaseDynamicLayer.d.ts +1 -0
  156. package/layers/BaseElevationLayer.d.ts +2 -0
  157. package/layers/BaseTileLayer.d.ts +12 -9
  158. package/layers/CSVLayer.d.ts +0 -15
  159. package/layers/FeatureLayer.d.ts +2 -15
  160. package/layers/GeoJSONLayer.d.ts +0 -52
  161. package/layers/GeoRSSLayer.d.ts +0 -44
  162. package/layers/ParquetLayer.d.ts +92 -12
  163. package/layers/ParquetLayer.js +1 -1
  164. package/layers/SketchLayer.d.ts +0 -1
  165. package/layers/VectorTileLayer.d.ts +2 -12
  166. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  167. package/layers/mixins/PortalLayer.js +1 -1
  168. package/layers/mixins/RefreshableLayer.d.ts +1 -3
  169. package/layers/raster/datasets/GeospatialPDFRaster.js +1 -1
  170. package/layers/raster/datasets/TIFFRaster.js +1 -1
  171. package/layers/raster/formats/tiffParser.js +1 -1
  172. package/layers/support/ParquetPortalItemData.d.ts +2 -0
  173. package/layers/support/ParquetPortalItemData.js +1 -1
  174. package/layers/support/PortalItemData.d.ts +21 -0
  175. package/layers/support/PortalItemData.js +1 -1
  176. package/layers/support/layersLoader.js +1 -1
  177. package/layers/support/parquetUtils.d.ts +1 -1
  178. package/layers/support/types.d.ts +1 -1
  179. package/package.json +2 -2
  180. package/popup/FeaturesModel.d.ts +1 -1
  181. package/popup/FeaturesModel.js +1 -1
  182. package/portal/support/layersLoader.js +1 -1
  183. package/portal/support/portalLayers.js +1 -1
  184. package/rest/print.js +1 -1
  185. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  186. package/views/3d/analysis/ShadowCast/ShadowCastTooltip.js +1 -1
  187. package/views/3d/interactive/editingTools/originGeometryVisualElementUtils.js +1 -1
  188. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  189. package/views/3d/layers/graphics/ElevationAligners.js +1 -1
  190. package/views/3d/layers/graphics/Graphics3DBufferGraphicLayer.js +2 -0
  191. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  192. package/views/3d/layers/graphics/Graphics3DDrapedBufferGraphicLayer.js +2 -0
  193. package/views/3d/layers/graphics/Graphics3DDrapedGraphicLayer.js +1 -1
  194. package/views/3d/layers/graphics/Graphics3DDrapedGraphicLayerBase.js +2 -0
  195. package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
  196. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  197. package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
  198. package/views/3d/layers/graphics/Graphics3DStageObjectGraphicLayer.js +2 -0
  199. package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
  200. package/views/3d/layers/graphics/LabelInfo.js +1 -1
  201. package/views/3d/layers/graphics/elevationAlignmentUtils.js +1 -1
  202. package/views/3d/layers/graphics/pointUtils.js +1 -1
  203. package/views/3d/terrain/OverlayManager.js +1 -1
  204. package/views/3d/terrain/OverlayRenderer.js +1 -1
  205. package/views/3d/webgl-engine/collections/Component/Material/Component.glsl.js +1 -1
  206. package/views/3d/webgl-engine/core/shaderLibrary/Laserline.glsl.js +5 -5
  207. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js +13 -13
  208. package/views/3d/webgl-engine/core/shaderLibrary/bindUniforms.js +2 -0
  209. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +2 -2
  210. package/views/3d/webgl-engine/core/shaderLibrary/lastFrameUniforms.js +2 -0
  211. package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +7 -7
  212. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +29 -27
  213. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +4 -4
  214. package/views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js +2 -2
  215. package/views/3d/webgl-engine/core/shaderLibrary/shading/MarkerSizing.glsl.js +14 -14
  216. package/views/3d/webgl-engine/core/shaderLibrary/shading/NormalUtils.glsl.js +1 -1
  217. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceRayMarching.glsl.js +5 -5
  218. package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterColor.glsl.js +8 -8
  219. package/views/3d/webgl-engine/core/shaderLibrary/shading/evaluateSceneLightingFragment.glsl.js +1 -1
  220. package/views/3d/webgl-engine/core/shaderLibrary/shading/lightingUniforms.js +2 -0
  221. package/views/3d/webgl-engine/core/shaderLibrary/shading/pbrGlobals.glsl.js +1 -1
  222. package/views/3d/webgl-engine/core/shaderLibrary/shading/readShadow.glsl.js +6 -6
  223. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +1 -1
  224. package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +3 -3
  225. package/views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js +1 -1
  226. package/views/3d/webgl-engine/core/shaderLibrary/util/cameraUniforms.js +1 -1
  227. package/views/3d/webgl-engine/effects/atmosphere/ChapmanApproximation.glsl.js +3 -3
  228. package/views/3d/webgl-engine/effects/atmosphere/ChapmanAtmosphere.glsl.js +1 -1
  229. package/views/3d/webgl-engine/effects/atmosphere/ChapmanRaymarching.glsl.js +1 -1
  230. package/views/3d/webgl-engine/effects/atmosphere/SimpleAtmosphere.glsl.js +1 -1
  231. package/views/3d/webgl-engine/effects/clouds/CloudsComposition.glsl.js +1 -1
  232. package/views/3d/webgl-engine/effects/fog/Fog.glsl.js +1 -1
  233. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.glsl.js +1 -1
  234. package/views/3d/webgl-engine/effects/glow/applyEmissiveGlow.glsl.js +5 -5
  235. package/views/3d/webgl-engine/effects/haze/Haze.glsl.js +1 -1
  236. package/views/3d/webgl-engine/effects/haze/HazeCompositing.glsl.js +1 -1
  237. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.glsl.js +1 -1
  238. package/views/3d/webgl-engine/effects/highlight/ShadowHighlightBuffer.glsl.js +1 -1
  239. package/views/3d/webgl-engine/effects/laserlines/LaserlinePath.glsl.js +1 -1
  240. package/views/3d/webgl-engine/effects/raymarching/DistanceFalloff.glsl.js +1 -1
  241. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastAccumulate.glsl.js +1 -1
  242. package/views/3d/webgl-engine/lib/BufferGeometry.js +1 -1
  243. package/views/3d/webgl-engine/lib/BufferObject3D.js +1 -1
  244. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  245. package/views/3d/webgl-engine/lib/affectsGeometry.js +1 -1
  246. package/views/3d/webgl-engine/lib/bufferGeometryUtils.js +2 -0
  247. package/views/3d/webgl-engine/lib/edgeRendering/AdjustProjectedPosition.glsl.js +5 -5
  248. package/views/3d/webgl-engine/lib/edgeRendering/EdgeShader.glsl.js +1 -1
  249. package/views/3d/webgl-engine/lib/edgeRendering/EdgeUtil.glsl.js +11 -11
  250. package/views/3d/webgl-engine/materials/Path.glsl.js +1 -1
  251. package/views/3d/webgl-engine/materials/Water.glsl.js +1 -1
  252. package/views/3d/webgl-engine/shaders/AtmosphereCompositing.glsl.js +1 -1
  253. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  254. package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
  255. package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
  256. package/views/3d/webgl-engine/shaders/LineCallout.glsl.js +1 -1
  257. package/views/3d/webgl-engine/shaders/Pattern.glsl.js +1 -1
  258. package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
  259. package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
  260. package/views/3d/webgl-engine/shaders/SphereDepthInterpolate.glsl.js +1 -1
  261. package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
  262. package/views/3d/webgl-engine/shaders/Viewshed.glsl.js +1 -1
  263. package/views/3d/webgl-engine/shaders/lineUniforms.js +2 -0
  264. package/views/DOMContainer.d.ts +27 -9
  265. package/views/DOMContainer.js +1 -1
  266. package/views/PopupView.d.ts +6 -0
  267. package/views/VideoView.d.ts +27 -9
  268. package/views/View.d.ts +16 -7
  269. package/views/View.js +1 -1
  270. package/views/View2D.d.ts +1 -1
  271. package/views/interactive/snapping/SnappingManagerPool.js +1 -1
  272. package/views/interactive/snapping/SnappingOptions.d.ts +1 -1
  273. package/views/interactive/tooltip/components/ElevationModeSelect.js +1 -1
  274. package/views/interactive/tooltip/components/TooltipEditableField.js +1 -1
  275. package/views/layers/FeatureLikeLayerView.d.ts +1 -2
  276. package/views/layers/ParquetLayerView.d.ts +15 -0
  277. package/views/layers/ParquetLayerView.js +1 -1
  278. package/webdoc/support/saveUtils.js +1 -1
  279. package/webdoc/support/unsupportedErrors.js +1 -1
  280. package/widgets/Legend.d.ts +1 -0
  281. package/widgets/support/SnappingControls.d.ts +1 -1
  282. package/assets/esri/core/workers/chunks/05963f57cbe5a5249496.js +0 -1
  283. package/assets/esri/core/workers/chunks/06ab24a083c3229228dd.js +0 -1
  284. package/assets/esri/core/workers/chunks/122111703528381539cc.js +0 -1
  285. package/assets/esri/core/workers/chunks/15cc2c295682f48030f9.js +0 -1
  286. package/assets/esri/core/workers/chunks/17b76e0d401c7e396d10.js +0 -1
  287. package/assets/esri/core/workers/chunks/2164fcaced72b0fda31f.js +0 -1
  288. package/assets/esri/core/workers/chunks/25b0885d3bc190b28c04.js +0 -1
  289. package/assets/esri/core/workers/chunks/27da9ece2afaeec39f59.js +0 -1
  290. package/assets/esri/core/workers/chunks/2b6c74646ff475a6e302.js +0 -1
  291. package/assets/esri/core/workers/chunks/340621182db9e8edbec2.js +0 -1
  292. package/assets/esri/core/workers/chunks/347bf269c2b1583d2dca.js +0 -1
  293. package/assets/esri/core/workers/chunks/384ae10053d35940de73.js +0 -1
  294. package/assets/esri/core/workers/chunks/451d7d456df0f4466563.js +0 -1
  295. package/assets/esri/core/workers/chunks/4cddd217383b9333f32e.js +0 -1
  296. package/assets/esri/core/workers/chunks/4fa59f8ed3b7b6239548.js +0 -1
  297. package/assets/esri/core/workers/chunks/5a5d80c2519aa3ea8878.js +0 -1
  298. package/assets/esri/core/workers/chunks/5b434e8c98e7119d4a3b.js +0 -1
  299. package/assets/esri/core/workers/chunks/5e4d6c283c2fa28db022.js +0 -1
  300. package/assets/esri/core/workers/chunks/5ea8809b6519c05ad9f6.js +0 -1
  301. package/assets/esri/core/workers/chunks/604344e45c0f27497188.js +0 -1
  302. package/assets/esri/core/workers/chunks/64770e2cf41211b63fd2.js +0 -1
  303. package/assets/esri/core/workers/chunks/658b2642ab6880770e4e.js +0 -1
  304. package/assets/esri/core/workers/chunks/6ef647b7769d27529f9c.js +0 -1
  305. package/assets/esri/core/workers/chunks/8313c626596a76c7449d.js +0 -1
  306. package/assets/esri/core/workers/chunks/841f67baf6a1634ada48.js +0 -1
  307. package/assets/esri/core/workers/chunks/84e9258a57d8c365f361.js +0 -1
  308. package/assets/esri/core/workers/chunks/8730e7e6e0296f43f10b.js +0 -1
  309. package/assets/esri/core/workers/chunks/87b4e916b2668203a6b0.js +0 -1
  310. package/assets/esri/core/workers/chunks/8fcfd515ee1b18c902e5.js +0 -1
  311. package/assets/esri/core/workers/chunks/9001e9a1e81bce175ddd.js +0 -1
  312. package/assets/esri/core/workers/chunks/966d0832a3c1f03668a0.js +0 -1
  313. package/assets/esri/core/workers/chunks/97dbbedea9fe03bd1306.js +0 -1
  314. package/assets/esri/core/workers/chunks/9a28a66807a1e3557018.js +0 -1
  315. package/assets/esri/core/workers/chunks/9bf48a907f91ea004648.js +0 -1
  316. package/assets/esri/core/workers/chunks/9c0fd8baa00ee9733ba4.js +0 -1
  317. package/assets/esri/core/workers/chunks/9c7fa9d324fa0bf64d9c.js +0 -1
  318. package/assets/esri/core/workers/chunks/a20526996d01386ec3b7.js +0 -1
  319. package/assets/esri/core/workers/chunks/a7edf7541569fef77cb3.js +0 -1
  320. package/assets/esri/core/workers/chunks/b1008bdfca995ebf98ed.js +0 -1
  321. package/assets/esri/core/workers/chunks/bfd85e8d54062a590f0e.js +0 -1
  322. package/assets/esri/core/workers/chunks/c8ba0673d1b87216e619.js +0 -1
  323. package/assets/esri/core/workers/chunks/d4926545193414cf2f16.js +0 -1
  324. package/assets/esri/core/workers/chunks/da18d96b35af20e73b3b.js +0 -1
  325. package/assets/esri/core/workers/chunks/df0481bcc1613ee4b7af.js +0 -1
  326. package/assets/esri/core/workers/chunks/e1af43e2a8f2ef1059e3.js +0 -1
  327. package/assets/esri/core/workers/chunks/eaf6d587477399a83088.js +0 -1
  328. package/assets/esri/core/workers/chunks/ec28e18275d36e71b438.js +0 -1
  329. package/assets/esri/core/workers/chunks/f05de08e194a3f9b96f2.js +0 -1
  330. package/assets/esri/core/workers/chunks/f31b424a3667686af10c.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../core/Error.js";import{EventedAccessor as n}from"../core/Evented.js";import r from"../core/Logger.js";import{abortMaybe as i,removeMaybe as a}from"../core/maybe.js";import{debounce as o,logOnError as s,isAbortError as c}from"../core/promiseUtils.js";import{watch as l,when as u}from"../core/reactiveUtils.js";import{throttle as d}from"../core/throttle.js";import{property as f,subclass as p}from"../core/accessorSupport/decorators.js";import m from"../geometry/Point.js";import{project as h}from"../geometry/projectionUtils.js";import g from"../geometry/SpatialReference.js";import{geographicToWebMercator as _}from"../geometry/support/webMercatorUtils.js";import{getGraphicLayer as v}from"../graphic/graphicOriginUtils.js";import{fallbackObjectIDAttribute as y}from"../layers/LayerConstants.js";import{ActionsCollection as b,createDefaultActions as x}from"./actions.js";import{getSelectedTarget as S}from"./actionUtils.js";import C from"./FeatureModel.js";import w from"./support/FeatureAbilities.js";import{getDisplayedSymbol as T}from"../symbols/support/symbolUtils.js";import{system as E}from"../time/constants.js";import{highlightsSupported as D}from"../views/support/layerViewUtils.js";import{GoTo as O}from"../widgets/support/GoTo.js";let k=null;function A(e,t){switch(e){case`building-scene`:case`map-image`:case`tile`:case`imagery`:return!0;case`imagery-tile`:return t===`2d`;default:return!1}}let j=class extends O(n){constructor(e){super(e),this._centerAtLocationController=null,this._locationUpdateController=null,this._featureStreamFlush=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._defaultFeatureAbilities=new w,this._activeFeatureStream=null,this._featureStreamHasYielded=!1,this.actions=new b,this.activeFeature=null,this.aggregatedFeaturesEnabled=!1,this.defaultPopupTemplateEnabled=!1,this.diagnostics=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureItemAbilities=null,this.featureModels=[],this.heading=null,this.highlightEnabled=!0,this.includeDefaultActions=!0,this.open=!1,this.updateLocationEnabled=!1,this.view=null,this.zoomFactor=4,this._debouncedLocationUpdate=o(async()=>{this._cancelLocationUpdate();let e=new AbortController,{signal:t}=e;this._locationUpdateController=e,await this._locationUpdate({signal:t}).catch(()=>{}).finally(()=>{this._locationUpdateController===e&&(this._locationUpdateController=null)})})}initialize(){this.addHandles([l(()=>this.view?.scale,()=>{this.open&&s(this._debouncedLocationUpdate(),r.getLogger(this))}),l(()=>[this.highlightEnabled,this.selectedFeature,this.open,this.view],()=>this._highlightSelectedFeature()),l(()=>[this.highlightEnabled,this.activeFeature,this.open,this.view],()=>this._highlightActiveFeature()),l(()=>this.location,e=>this._locationChange(e)),l(()=>this.selectedFeature,e=>this._selectedFeatureChange(e)),l(()=>[this.featurePage,this.selectedFeatureIndex,this.featuresPerPage,this.featureMenuOpen,this.open,this.initialDisplayMode,this.featureItemAbilities?.attachmentsContent,this.featureItemAbilities?.chartAnimation,this.featureItemAbilities?.customContent,this.featureItemAbilities?.expressionContent,this.featureItemAbilities?.fieldsContent,this.featureItemAbilities?.mediaContent,this.featureItemAbilities?.relationshipContent,this.featureItemAbilities?.textContent,this.featureItemAbilities?.utilityNetworkAssociationsContent,this.actions,this.defaultPopupTemplateEnabled,this.includeDefaultActions,this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureModels(),{initial:!0}),u(()=>!this.open,()=>this.aggregatedFeaturesEnabled=!1)])}destroy(){this._cancelLocationUpdate(),this._cancelCenterAtLocation(),this._cancelFeatureStream(),this._destroyFeatureModels(),this.aggregatedFeaturesEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get defaultActions(){let e=this._get(`defaultActions`)||new b;return e.removeAll(),e.addMany(this.selectedFeatureItem?.defaultActions.toArray()??x()),e}get active(){return this.open&&!this.waitingForResult}set content(e){this.featureStream=null,this._set(`diagnostics`,null),this.features=[],this._set(`content`,e)}get effectiveHeading(){return this.selectedFeatureItem?.heading??this.heading}get featureCount(){return this.features.length}get featurePage(){return this._get(`featurePage`)}set featurePage(e){e==null?this.featureCount||this._set(`featurePage`,null):!Number.isInteger(e)||e<1||e>Math.ceil(this.featureCount/this.featuresPerPage)||e!==1&&e!==(this.featurePage??0)+1||(this._set(`featurePage`,e),this._updateFeatureModels(!0))}set features(e){if(this._get(`features`)===e)return;let t=e||[];this._set(`features`,t),(!this._activeFeatureStream||!t.length||this.featurePage==null)&&this._set(`featurePage`,t.length?1:null),this._syncSelectedFeatureIndex(t)}get featureStream(){return this._get(`featureStream`)||null}set featureStream(e){this._setFeatureStream(e)}_setFeatureStream(e,t,n){this._set(`diagnostics`,n??null),this._get(`featureStream`)!==e&&(this._set(`featureStream`,e),this._cancelFeatureStream(),e&&(this._featureStreamHasYielded=!1,this._set(`pendingLocation`,t??null),this._activeFeatureStream=e,this._consumeFeatureStream(e,t).catch(()=>{})))}get initialDisplayMode(){return this._initialDisplayMode??(this.view?.focusRegionEnabled?`list`:`feature`)}set initialDisplayMode(e){this._initialDisplayMode=e,this._syncSelectedFeatureIndex(this.features)}set location(e){let t=e?.spatialReference?.isWGS84&&this.spatialReference?.isWebMercator?_(e):e;this._set(`location`,t)}get map(){return this.view?.map??null}set map(e){this._override(`map`,e)}get pendingLocation(){return this._get(`pendingLocation`)??null}get streamingFeatures(){return this._activeFeatureStream!=null}get selectedFeature(){return this.selectedFeatureIndex===-1?null:this.features[this.selectedFeatureIndex]??null}get selectedFeatureIndex(){let e=this._get(`selectedFeatureIndex`);return typeof e==`number`?e:-1}set selectedFeatureIndex(e){let{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set(`selectedFeatureIndex`,e)}get selectedFeatureItem(){return this.featureModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override(`spatialReference`,e)}get state(){return this.view?this.view.ready?`ready`:`disabled`:this.map?`ready`:`disabled`}get timeZone(){return this.view?.timeZone??E}set timeZone(e){this._overrideIfSome(`timeZone`,e)}get waitingForContents(){return this.featureModels.some(e=>e.waitingForContent)}get waitingForResult(){return this.streamingFeatures&&!this._featureStreamHasYielded}zoomTo(e){return this.callGoTo(e)}clear(){this._cancelFeatureStream(),this._set(`diagnostics`,null),this.set({featureStream:null,features:[],content:null,heading:null,location:null,activeFeature:null})}openFeatureStream(e){this._setFeatureStream(e.featureStream,e.location??null,e.diagnostics),this.open=!0}async fetchFeatures(e,n){let{view:r}=this;if(!r||!e)throw new t(`fetch-features:invalid-screenpoint-or-view`,`Cannot fetch features without a screen point/screen area and view.`,{screenPoint:e,view:r});let i={},a=r.fetchPopupFeatures(e,{diagnostics:i,pointerType:n?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:n?.signal});this._setFeatureStream(a,void 0,i)}next(){this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount)}previous(){this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount)}_syncSelectedFeatureIndex(e){let{selectedFeatureIndex:t}=this,n=this._activeFeatureStream!=null&&e.length>0;this.initialDisplayMode===`list`?n||(this.selectedFeatureIndex=-1):n&&t===-1?this.selectedFeatureIndex=0:n&&t!==-1||(this.selectedFeatureIndex=e.length?0:-1)}_centerAtLocation(){let{view:e}=this,n=S(this);this._cancelCenterAtLocation();let i=new AbortController,{signal:a}=i;return this._centerAtLocationController=i,!n||!e?Promise.reject(new t(`center-at-location:invalid-target-or-view`,`Cannot center at a location without a target and view.`,{target:n,view:e})):this.callGoTo({target:{target:n,scale:e.scale},options:{signal:a}}).catch(e=>{c(e)||r.getLogger(this).error(e)})}_getRoundRobinIndex(e,t){return(e+t)%t}_locationChange(e){let{selectedFeature:t,updateLocationEnabled:n,view:r}=this;r&&!this._locationUpdateController&&n&&e&&(!t||t.geometry)&&this._centerAtLocation()}async _selectedFeatureChange(e){let{location:t,updateLocationEnabled:n,view:r}=this;if(this.aggregatedFeaturesEnabled=!1,!e||!r)return;let i=v(e)?.type;if((i===`map-image`||i===`imagery`||i===`imagery-tile`)&&(e.symbol=await T(e)),(n||!t)&&e.geometry){if(e.geometry.type===`point`){this.location=e.geometry;return}let{labelPointExecute:t}=await import(`../geometry/operators/labelPointOperator.js`);this.location=t(e.geometry)}else if(n&&!e.geometry){await this._centerAtLocation();let e=r.center?.clone();e&&(this.location=e)}}_waitingForResultChange(){!this.featureCount&&this.featureStream&&(this.open=!1)}_destroyFeatureModels(){this.featureModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set(`featureModels`,[])}_reconcileFeatureModels(e){let t=[],n=new Map,r=[];if(this.featureModels.forEach((i,a)=>{let o=i?.graphic;!o||i.destroyed?i.destroy():e[a]===o?t[a]=i:(r.push(i),n.has(o)||n.set(o,[]))}),r.length){for(let r=e.length-1;r>=0;r--)t[r]||n.get(e[r])?.push(r);r.forEach(e=>{let r=n.get(e.graphic)?.pop();r==null?e.destroy():t[r]=e})}return t}_updateFeatureModels(e=!1){let{selectedFeature:t,features:n}=this;if(!n.length){this._destroyFeatureModels();return}let r={abilities:this.featureItemAbilities??this._defaultFeatureAbilities,actions:this.actions,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,includeDefaultActions:this.includeDefaultActions,spatialReference:this.spatialReference,location:this.location,map:this.map,view:this.view,timeZone:this.timeZone},i=this._reconcileFeatureModels(n);i.forEach(e=>e.set(r));let a=e=>{let t=n[e];t&&!i[e]&&(i[e]=new C({...r,graphic:t}))};if(t&&a(this.selectedFeatureIndex),e||(this.featurePage??0)>1||this.open&&(this.featureMenuOpen||this.initialDisplayMode===`list`)){let e=Math.min((this.featurePage??0)*this.featuresPerPage,n.length);for(let t=0;t<e;t++)a(t)}this._set(`featureModels`,i)}_cancelCenterAtLocation(){this._centerAtLocationController=i(this._centerAtLocationController)}_cancelFeatureStream(){this._featureStreamFlush=a(this._featureStreamFlush);let e=this._activeFeatureStream;this._activeFeatureStream=null,this._set(`pendingLocation`,null),this._get(`featureStream`)===e&&this._set(`featureStream`,null),e?.return&&e.return(void 0).catch(()=>{})}async _locationUpdate(e){let{spatialReference:t}=this,n=this.selectedFeature,i=n?.geometry?.type,a=this.location;if(i&&i!==`mesh`&&t&&a&&n){if(i===`point`){let{labelPointExecute:t}=await import(`../geometry/operators/labelPointOperator.js`);if(e?.signal?.aborted||this.selectedFeature!==n||!n.geometry)return;this.location=t(n.geometry)}else try{let r=n.geometry,i=this._getHighlightLayer(n),o=n.getObjectId();if(!i||!this.view)return;if(o!=null){let n=this.view?.allLayerViews.find(e=>e.layer.uid===i.uid);if(!n||!(`queryFeatures`in n))return;let a=n.createQuery();a.outSpatialReference=t,a.objectIds=[o],a.returnGeometry=!0;let{features:s}=await n.queryFeatures(a,e);if(e?.signal?.aborted)return;r=s[0]?.geometry}if(!r||r.type===`mesh`)return;r=h(r,t),k??=await Promise.all([import(`../geometry/operators/intersectsOperator.js`),import(`../geometry/operators/proximityOperator.js`)]);let[{intersectsExecute:s},{proximityGetNearestCoordinate:c}]=k;if(!s(r,a)){let e=c(r,a).coordinate??a;this.selectedFeature===n&&(this.location=e)}}catch(e){c(e)||r.getLogger(this).error(e)}}}_cancelLocationUpdate(){this._locationUpdateController=i(this._locationUpdateController)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){let t=v(e),{layer:n}=e;return t&&`layer`in t&&t.layer?t.layer:t?.type===`map-notes`||t?.type===`sketch`||t?.type===`subtype-group`?t:n??t}_getHighlightLayerView(e,t){return t.type===`subtype-sublayer`&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,n){if(A(t.type,n))return e;let r=e.getObjectId();if(r!=null)return r;let i=t.type===`imagery`?void 0:`objectIdField`in t?t.objectIdField||y:null,a=e.attributes;return a&&i&&a[i]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);let n=this[t];if(!n)return;let{highlightEnabled:r,view:i,open:a}=this;if(!i||!r||!a)return;let o=this._getHighlightLayer(n);if(!o)return;let s=this._getHighlightLayerView(i,o);if(!s)return;this._highlightPromises[e]=s;let c=await s;if(!c||!D(c)||this._highlightPromises[e]!==s||!this[t]||!this.highlightEnabled)return;let l=c.highlight(this._getHighlightTarget(n,o,i.type));this.addHandles(l,e)}async _highlightActiveFeature(){return this._highlightFeature(`highlight-active-feature`,`activeFeature`)}async _highlightSelectedFeature(){return this._highlightFeature(`highlight-selected-feature`,`selectedFeature`)}async _consumeFeatureStream(e,t){if(e!==this._activeFeatureStream)return;let n=[],r=d(()=>{let t=n;n=[],e===this._activeFeatureStream&&t.length&&this._addFeatures(t)},16),i={remove:()=>{r.remove(),n=[]}};this._featureStreamFlush=i;try{for await(let i of e){if(e!==this._activeFeatureStream)return;let a=!this._featureStreamHasYielded;a&&(this.features=[]),t!==void 0&&(this.location=t,t=void 0),this._set(`pendingLocation`,null),a?(this._addFeatures([i]),e===this._activeFeatureStream&&(this._featureStreamHasYielded=!0)):(n.push(i),r())}}finally{this._activeFeatureStream===e&&r.forceUpdate(),i.remove(),this._featureStreamFlush===i&&(this._featureStreamFlush=null),this._activeFeatureStream===e&&(this._featureStreamHasYielded||(this.features=[]),this._activeFeatureStream=null,this._set(`pendingLocation`,null),this._waitingForResultChange())}}_addFeatures(e){let{features:t}=this,n=new Set(t),r=e.filter(e=>!n.has(e)&&(n.add(e),!0));r.length&&(this.features=t.concat(r))}};e([f()],j.prototype,`_initialDisplayMode`,void 0),e([f()],j.prototype,`_activeFeatureStream`,void 0),e([f()],j.prototype,`_featureStreamHasYielded`,void 0),e([f({type:b})],j.prototype,`actions`,void 0),e([f({type:b,readOnly:!0})],j.prototype,`defaultActions`,null),e([f({readOnly:!0})],j.prototype,`active`,null),e([f()],j.prototype,`activeFeature`,void 0),e([f()],j.prototype,`aggregatedFeaturesEnabled`,void 0),e([f({value:null})],j.prototype,`content`,null),e([f({type:Boolean})],j.prototype,`defaultPopupTemplateEnabled`,void 0),e([f({readOnly:!0})],j.prototype,`diagnostics`,void 0),e([f({readOnly:!0})],j.prototype,`effectiveHeading`,null),e([f({readOnly:!0})],j.prototype,`featureCount`,null),e([f({value:null})],j.prototype,`featurePage`,null),e([f({value:[]})],j.prototype,`features`,null),e([f()],j.prototype,`featureStream`,null),e([f()],j.prototype,`featuresPerPage`,void 0),e([f()],j.prototype,`featureMenuOpen`,void 0),e([f({type:w})],j.prototype,`featureItemAbilities`,void 0),e([f({readOnly:!0})],j.prototype,`featureModels`,void 0),e([f()],j.prototype,`heading`,void 0),e([f()],j.prototype,`highlightEnabled`,void 0),e([f()],j.prototype,`includeDefaultActions`,void 0),e([f()],j.prototype,`initialDisplayMode`,null),e([f({type:m})],j.prototype,`location`,null),e([f()],j.prototype,`map`,null),e([f()],j.prototype,`open`,void 0),e([f({readOnly:!0})],j.prototype,`pendingLocation`,null),e([f({readOnly:!0})],j.prototype,`streamingFeatures`,null),e([f({value:null,readOnly:!0})],j.prototype,`selectedFeature`,null),e([f({value:-1})],j.prototype,`selectedFeatureIndex`,null),e([f({readOnly:!0})],j.prototype,`selectedFeatureItem`,null),e([f({type:g})],j.prototype,`spatialReference`,null),e([f({readOnly:!0})],j.prototype,`state`,null),e([f()],j.prototype,`timeZone`,null),e([f()],j.prototype,`updateLocationEnabled`,void 0),e([f()],j.prototype,`view`,void 0),e([f({readOnly:!0})],j.prototype,`waitingForContents`,null),e([f({readOnly:!0})],j.prototype,`waitingForResult`,null),e([f()],j.prototype,`zoomFactor`,void 0),j=e([p(`esri.popup.FeaturesModel`)],j);const M=j;export{M as default};
2
+ import{__decorate as e}from"tslib";import t from"../core/Error.js";import{EventedAccessor as n}from"../core/Evented.js";import r from"../core/Logger.js";import{abortMaybe as i}from"../core/maybe.js";import{debounce as a,logOnError as o,isAbortError as s}from"../core/promiseUtils.js";import{watch as c,when as l}from"../core/reactiveUtils.js";import{throttle as u}from"../core/throttle.js";import{property as d,subclass as f}from"../core/accessorSupport/decorators.js";import p from"../geometry/Point.js";import{project as m}from"../geometry/projectionUtils.js";import h from"../geometry/SpatialReference.js";import{geographicToWebMercator as g}from"../geometry/support/webMercatorUtils.js";import{getGraphicLayer as _}from"../graphic/graphicOriginUtils.js";import{fallbackObjectIDAttribute as v}from"../layers/LayerConstants.js";import{ActionsCollection as y,createDefaultActions as b}from"./actions.js";import{getSelectedTarget as x}from"./actionUtils.js";import S from"./FeatureModel.js";import C from"./support/FeatureAbilities.js";import{getDisplayedSymbol as w}from"../symbols/support/symbolUtils.js";import{system as T}from"../time/constants.js";import{highlightsSupported as E}from"../views/support/layerViewUtils.js";import{GoTo as D}from"../widgets/support/GoTo.js";const O=Symbol(`feature-stream-flush`);let k=null;function A(e,t){switch(e){case`building-scene`:case`map-image`:case`tile`:case`imagery`:return!0;case`imagery-tile`:return t===`2d`;default:return!1}}let j=class extends D(n){constructor(e){super(e),this._centerAtLocationController=null,this._locationUpdateController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._defaultFeatureAbilities=new C,this._activeFeatureStream=null,this._featureStreamHasYielded=!1,this.actions=new y,this.activeFeature=null,this.aggregatedFeaturesEnabled=!1,this.defaultPopupTemplateEnabled=!1,this.diagnostics=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureItemAbilities=null,this.featureModels=[],this.heading=null,this.highlightEnabled=!0,this.includeDefaultActions=!0,this.open=!1,this.updateLocationEnabled=!1,this.view=null,this.zoomFactor=4,this._debouncedLocationUpdate=a(async()=>{this._cancelLocationUpdate();let e=new AbortController,{signal:t}=e;this._locationUpdateController=e,await this._locationUpdate({signal:t}).catch(()=>{}).finally(()=>{this._locationUpdateController===e&&(this._locationUpdateController=null)})})}initialize(){this.addHandles([c(()=>this.view?.scale,()=>{this.open&&o(this._debouncedLocationUpdate(),r.getLogger(this))}),c(()=>[this.highlightEnabled,this.selectedFeature,this.open,this.view],()=>this._highlightSelectedFeature()),c(()=>[this.highlightEnabled,this.activeFeature,this.open,this.view],()=>this._highlightActiveFeature()),c(()=>this.location,e=>this._locationChange(e)),c(()=>this.selectedFeature,e=>this._selectedFeatureChange(e)),c(()=>[this.featurePage,this.selectedFeatureIndex,this.featuresPerPage,this.featureMenuOpen,this.open,this.initialDisplayMode,this.featureItemAbilities?.attachmentsContent,this.featureItemAbilities?.chartAnimation,this.featureItemAbilities?.customContent,this.featureItemAbilities?.expressionContent,this.featureItemAbilities?.fieldsContent,this.featureItemAbilities?.mediaContent,this.featureItemAbilities?.relationshipContent,this.featureItemAbilities?.textContent,this.featureItemAbilities?.utilityNetworkAssociationsContent,this.actions,this.defaultPopupTemplateEnabled,this.includeDefaultActions,this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureModels(),{initial:!0}),l(()=>!this.open,()=>this.aggregatedFeaturesEnabled=!1)])}destroy(){this._cancelLocationUpdate(),this._cancelCenterAtLocation(),this._cancelFeatureStream(),this._destroyFeatureModels(),this.aggregatedFeaturesEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get defaultActions(){let e=this._get(`defaultActions`)||new y;return e.removeAll(),e.addMany(this.selectedFeatureItem?.defaultActions.toArray()??b()),e}get active(){return this.open&&!this.waitingForResult}set content(e){this.featureStream=null,this._set(`diagnostics`,null),this.features=[],this._set(`content`,e)}get effectiveHeading(){return this.selectedFeatureItem?.heading??this.heading}get featureCount(){return this.features.length}get featurePage(){return this._get(`featurePage`)}set featurePage(e){e==null?this.featureCount||this._set(`featurePage`,null):!Number.isInteger(e)||e<1||e>Math.ceil(this.featureCount/this.featuresPerPage)||e!==1&&e!==(this.featurePage??0)+1||this._set(`featurePage`,e)}set features(e){if(this._get(`features`)===e)return;let t=e||[];this._set(`features`,t),(!this._activeFeatureStream||!t.length||this.featurePage==null)&&(this.featurePage=t.length?1:null),this._syncSelectedFeatureIndex(t)}get featureStream(){return this._get(`featureStream`)||null}set featureStream(e){this._setFeatureStream(e)}_setFeatureStream(e,t,n){this._set(`diagnostics`,n??null),this._get(`featureStream`)!==e&&(this._set(`featureStream`,e),this._cancelFeatureStream(),e&&(this._featureStreamHasYielded=!1,this._set(`pendingLocation`,t??null),this._activeFeatureStream=e,this._consumeFeatureStream(e,t).catch(()=>{})))}get initialDisplayMode(){return this._initialDisplayMode??(this.view?.focusRegionVisible?`list`:`feature`)}set initialDisplayMode(e){this._initialDisplayMode=e,this._syncSelectedFeatureIndex(this.features)}set location(e){let t=e?.spatialReference?.isWGS84&&this.spatialReference?.isWebMercator?g(e):e;this._set(`location`,t)}get map(){return this.view?.map??null}set map(e){this._override(`map`,e)}get pendingLocation(){return this._get(`pendingLocation`)??null}get streamingFeatures(){return this._activeFeatureStream!=null}get selectedFeature(){return this.selectedFeatureIndex===-1?null:this.features[this.selectedFeatureIndex]??null}get selectedFeatureIndex(){let e=this._get(`selectedFeatureIndex`);return typeof e==`number`?e:-1}set selectedFeatureIndex(e){let{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set(`selectedFeatureIndex`,e)}get selectedFeatureItem(){return this.featureModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override(`spatialReference`,e)}get state(){return this.view?this.view.ready?`ready`:`disabled`:this.map?`ready`:`disabled`}get timeZone(){return this.view?.timeZone??T}set timeZone(e){this._overrideIfSome(`timeZone`,e)}get waitingForContents(){return this.featureModels.some(e=>e.waitingForContent)}get waitingForResult(){return this.streamingFeatures&&!this._featureStreamHasYielded}zoomTo(e){return this.callGoTo(e)}clear(){this._cancelFeatureStream(),this._set(`diagnostics`,null),this.set({featureStream:null,features:[],content:null,heading:null,location:null,activeFeature:null})}openFeatureStream(e){this._setFeatureStream(e.featureStream,e.location??null,e.diagnostics),this.open=!0}async fetchFeatures(e,n){let{view:r}=this;if(!r||!e)throw new t(`fetch-features:invalid-screenpoint-or-view`,`Cannot fetch features without a screen point/screen area and view.`,{screenPoint:e,view:r});let i={},a=r.fetchPopupFeatures(e,{diagnostics:i,pointerType:n?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:n?.signal});this._setFeatureStream(a,void 0,i)}next(){this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount)}previous(){this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount)}_syncSelectedFeatureIndex(e){let{selectedFeatureIndex:t}=this,n=this._activeFeatureStream!=null&&e.length>0;this.initialDisplayMode===`list`?n||(this.selectedFeatureIndex=-1):n&&t===-1?this.selectedFeatureIndex=0:n&&t!==-1||(this.selectedFeatureIndex=e.length?0:-1)}_centerAtLocation(){let{view:e}=this,n=x(this);this._cancelCenterAtLocation();let i=new AbortController,{signal:a}=i;return this._centerAtLocationController=i,!n||!e?Promise.reject(new t(`center-at-location:invalid-target-or-view`,`Cannot center at a location without a target and view.`,{target:n,view:e})):this.callGoTo({target:{target:n,scale:e.scale},options:{signal:a}}).catch(e=>{s(e)||r.getLogger(this).error(e)})}_getRoundRobinIndex(e,t){return(e+t)%t}_locationChange(e){let{selectedFeature:t,updateLocationEnabled:n,view:r}=this;r&&!this._locationUpdateController&&n&&e&&(!t||t.geometry)&&this._centerAtLocation()}async _selectedFeatureChange(e){let{location:t,updateLocationEnabled:n,view:r}=this;if(this.aggregatedFeaturesEnabled=!1,!e||!r)return;let i=_(e)?.type;if((i===`map-image`||i===`imagery`||i===`imagery-tile`)&&(e.symbol=await w(e)),(n||!t)&&e.geometry){if(e.geometry.type===`point`){this.location=e.geometry;return}let{labelPointExecute:t}=await import(`../geometry/operators/labelPointOperator.js`);this.location=t(e.geometry)}else if(n&&!e.geometry){await this._centerAtLocation();let e=r.center?.clone();e&&(this.location=e)}}_waitingForResultChange(){!this.featureCount&&this.featureStream&&(this.open=!1)}_destroyFeatureModels(){this.featureModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set(`featureModels`,[])}_reconcileFeatureModels(e){let t=[],n=new Map,r=[];if(this.featureModels.forEach((i,a)=>{let o=i?.graphic;!o||i.destroyed?i.destroy():e[a]===o?t[a]=i:(r.push(i),n.has(o)||n.set(o,[]))}),r.length){for(let r=e.length-1;r>=0;r--)t[r]||n.get(e[r])?.push(r);r.forEach(e=>{let r=n.get(e.graphic)?.pop();r==null?e.destroy():t[r]=e})}return t}_updateFeatureModels(){let{selectedFeature:e,features:t}=this;if(!t.length){this._destroyFeatureModels();return}let n={abilities:this.featureItemAbilities??this._defaultFeatureAbilities,actions:this.actions,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,includeDefaultActions:this.includeDefaultActions,spatialReference:this.spatialReference,location:this.location,map:this.map,view:this.view,timeZone:this.timeZone},r=this._reconcileFeatureModels(t);r.forEach(e=>e.set(n));let i=e=>{let i=t[e];i&&!r[e]&&(r[e]=new S({...n,graphic:i}))};if(e&&i(this.selectedFeatureIndex),(this.featurePage??0)>1||this.open&&(this.featureMenuOpen||this.initialDisplayMode===`list`)){let e=Math.min((this.featurePage??0)*this.featuresPerPage,t.length);for(let t=0;t<e;t++)i(t)}this._set(`featureModels`,r)}_cancelCenterAtLocation(){this._centerAtLocationController=i(this._centerAtLocationController)}_cancelFeatureStream(){this.removeHandles(O);let e=this._activeFeatureStream;this._activeFeatureStream=null,this._set(`pendingLocation`,null),this._get(`featureStream`)===e&&this._set(`featureStream`,null),e?.return&&e.return(void 0).catch(()=>{})}async _locationUpdate(e){let{spatialReference:t}=this,n=this.selectedFeature,i=n?.geometry?.type,a=this.location;if(i&&i!==`mesh`&&t&&a&&n){if(i===`point`){let{labelPointExecute:t}=await import(`../geometry/operators/labelPointOperator.js`);if(e?.signal?.aborted||this.selectedFeature!==n||!n.geometry)return;this.location=t(n.geometry)}else try{let r=n.geometry,i=this._getHighlightLayer(n),o=n.getObjectId();if(!i||!this.view)return;if(o!=null){let n=this.view?.allLayerViews.find(e=>e.layer.uid===i.uid);if(!n||!(`queryFeatures`in n))return;let a=n.createQuery();a.outSpatialReference=t,a.objectIds=[o],a.returnGeometry=!0;let{features:s}=await n.queryFeatures(a,e);if(e?.signal?.aborted)return;r=s[0]?.geometry}if(!r||r.type===`mesh`)return;r=m(r,t),k??=await Promise.all([import(`../geometry/operators/intersectsOperator.js`),import(`../geometry/operators/proximityOperator.js`)]);let[{intersectsExecute:s},{proximityGetNearestCoordinate:c}]=k;if(!s(r,a)){let e=c(r,a).coordinate??a;this.selectedFeature===n&&(this.location=e)}}catch(e){s(e)||r.getLogger(this).error(e)}}}_cancelLocationUpdate(){this._locationUpdateController=i(this._locationUpdateController)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){let t=_(e),{layer:n}=e;return t&&`layer`in t&&t.layer?t.layer:t?.type===`map-notes`||t?.type===`sketch`||t?.type===`subtype-group`?t:n??t}_getHighlightLayerView(e,t){return t.type===`subtype-sublayer`&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,n){if(A(t.type,n))return e;let r=e.getObjectId();if(r!=null)return r;let i=t.type===`imagery`?void 0:`objectIdField`in t?t.objectIdField||v:null,a=e.attributes;return a&&i&&a[i]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);let n=this[t];if(!n)return;let{highlightEnabled:r,view:i,open:a}=this;if(!i||!r||!a)return;let o=this._getHighlightLayer(n);if(!o)return;let s=this._getHighlightLayerView(i,o);if(!s)return;this._highlightPromises[e]=s;let c=await s;if(!c||!E(c)||this._highlightPromises[e]!==s||!this[t]||!this.highlightEnabled)return;let l=c.highlight(this._getHighlightTarget(n,o,i.type));this.addHandles(l,e)}async _highlightActiveFeature(){return this._highlightFeature(`highlight-active-feature`,`activeFeature`)}async _highlightSelectedFeature(){return this._highlightFeature(`highlight-selected-feature`,`selectedFeature`)}async _consumeFeatureStream(e,t){if(e!==this._activeFeatureStream)return;let n=[],r=u(()=>{let t=n;n=[],e===this._activeFeatureStream&&t.length&&this._addFeatures(t)},16);this.addHandles({remove:()=>{r.remove(),n=[]}},O);try{for await(let i of e){if(e!==this._activeFeatureStream)return;let a=!this._featureStreamHasYielded;a&&(this.features=[]),t!==void 0&&(this.location=t,t=void 0),this._set(`pendingLocation`,null),a?(this._addFeatures([i]),e===this._activeFeatureStream&&(this._featureStreamHasYielded=!0)):(n.push(i),r())}}finally{this._activeFeatureStream===e&&r.forceUpdate(),this._activeFeatureStream===e&&(this.removeHandles(O),this._featureStreamHasYielded||(this.features=[]),this._activeFeatureStream=null,this._set(`pendingLocation`,null),this._waitingForResultChange())}}_addFeatures(e){let{features:t}=this,n=new Set(t),r=e.filter(e=>!n.has(e)&&(n.add(e),!0));r.length&&(this.features=t.concat(r))}};e([d()],j.prototype,`_initialDisplayMode`,void 0),e([d()],j.prototype,`_activeFeatureStream`,void 0),e([d()],j.prototype,`_featureStreamHasYielded`,void 0),e([d({type:y})],j.prototype,`actions`,void 0),e([d({type:y,readOnly:!0})],j.prototype,`defaultActions`,null),e([d({readOnly:!0})],j.prototype,`active`,null),e([d()],j.prototype,`activeFeature`,void 0),e([d()],j.prototype,`aggregatedFeaturesEnabled`,void 0),e([d({value:null})],j.prototype,`content`,null),e([d({type:Boolean})],j.prototype,`defaultPopupTemplateEnabled`,void 0),e([d({readOnly:!0})],j.prototype,`diagnostics`,void 0),e([d({readOnly:!0})],j.prototype,`effectiveHeading`,null),e([d({readOnly:!0})],j.prototype,`featureCount`,null),e([d({value:null})],j.prototype,`featurePage`,null),e([d({value:[]})],j.prototype,`features`,null),e([d()],j.prototype,`featureStream`,null),e([d()],j.prototype,`featuresPerPage`,void 0),e([d()],j.prototype,`featureMenuOpen`,void 0),e([d({type:C})],j.prototype,`featureItemAbilities`,void 0),e([d({readOnly:!0})],j.prototype,`featureModels`,void 0),e([d()],j.prototype,`heading`,void 0),e([d()],j.prototype,`highlightEnabled`,void 0),e([d()],j.prototype,`includeDefaultActions`,void 0),e([d()],j.prototype,`initialDisplayMode`,null),e([d({type:p})],j.prototype,`location`,null),e([d()],j.prototype,`map`,null),e([d()],j.prototype,`open`,void 0),e([d({readOnly:!0})],j.prototype,`pendingLocation`,null),e([d({readOnly:!0})],j.prototype,`streamingFeatures`,null),e([d({value:null,readOnly:!0})],j.prototype,`selectedFeature`,null),e([d({value:-1})],j.prototype,`selectedFeatureIndex`,null),e([d({readOnly:!0})],j.prototype,`selectedFeatureItem`,null),e([d({type:h})],j.prototype,`spatialReference`,null),e([d({readOnly:!0})],j.prototype,`state`,null),e([d()],j.prototype,`timeZone`,null),e([d()],j.prototype,`updateLocationEnabled`,void 0),e([d()],j.prototype,`view`,void 0),e([d({readOnly:!0})],j.prototype,`waitingForContents`,null),e([d({readOnly:!0})],j.prototype,`waitingForResult`,null),e([d()],j.prototype,`zoomFactor`,void 0),j=e([f(`esri.popup.FeaturesModel`)],j);const M=j;export{M as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../core/Error.js";import{parse as t}from"../../layers/support/arcgisLayerUrl.js";import{fetchFeatureService as n}from"../../layers/support/fetchService.js";import{LayerLoadContext as r}from"../../layers/support/LayerLoadContext.js";import{applyPreferredHostToPortalItem as i,isPreferredUrlApplicable as a,getPreferredHost as o}from"../../layers/support/layerUtils.js";import s from"../Portal.js";import{createForItemRead as c}from"./jsonContext.js";import{normalizeFSItemData as l,getSublayersByLayerType as u,getFirstLayerOrTable as d,preprocessFSItemData as f,populateSceneServiceItemData as p,getNumLayersAndTables as m,instanceTypeToLayerTypes as h,layerTypeToLayerModuleType as g,createSublayerData as _}from"./loadUtils.js";import{hasTypeKeyword as v}from"./portalItemUtils.js";import{loadStyleRenderer as y}from"../../renderers/support/styleUtils.js";import{requestServiceJSON as b}from"../../request/serviceJSON.js";async function x(e,t){let n=e.instance.portalItem;if(n?.id)return await n.load(t),C(e),e.validateItem&&e.validateItem(n),w(e,t)}async function S(e,t){let n=e.instance.portalItem;if(!n?.id||!n.loaded)return!1;let r=n.modified;return await n.reload(),t?.signal?.throwIfAborted(),r?.getTime()!==n.modified?.getTime()&&(C(e),e.validateItem&&e.validateItem(n),await w(e,t),!0)}function C(t){let n=t.instance.portalItem;if(!n?.type||!t.supportedTypes.includes(n.type))throw new e(`portal:invalid-layer-item-type`,"Invalid layer item type '${type}', expected '${expectedType}'",{type:n?.type,expectedType:t.supportedTypes.join(`, `)})}async function w(e,t){let n=e.instance,{portalItem:i,type:a}=n;if(!i)return;let{url:o}=i,{title:s}=i,l=c(i,`portal-item`);if(a===`group`)return T(n,l,e);o&&a!==`media`&&n.read({url:o},l);let{data:u,preferredHost:d}=await M(e,new r,t);return o=i.url,`isUrlHostModified`in n&&(d?n.applyPreferredHost({preferredHost:d}):n.applyHostFromPortalItem()),u&&n.read(u,l),n.resourceReferences={portalItem:i,paths:l.readResourcePaths??[]},a!==`subtype-group`&&n.read({title:s},l),y(n,l)}async function T(t,n,r){let i=t.portalItem;if(!t.sourceIsPortalItem)return;let{title:a,type:o}=i;if(o===`Group Layer`){if(!v(i,`Map`))throw new e(`portal:invalid-layer-item-typekeyword`,`'Group Layer' item without 'Map' type keyword is not supported`);return E(t,r)}return t.read({title:a},n),D(t,r)}async function E(t,n){let r=t.portalItem,i=await r.fetchData(`json`);if(!i)return;if(!n.populateGroupLayer)throw new e(`portal:missing-populate-group-layer`,`Missing populate group layer`);let a=c(r,`web-map`);t.read(i,a),await n.populateGroupLayer(t,i,{context:a}),t.resourceReferences={portalItem:r,paths:a.readResourcePaths??[]}}async function D(t,n){let a,{portalItem:o}=t;if(!o)return;let{type:s,url:c}=o,l=n.layerModuleTypeMap;if(!l)throw new e(`portal:missing-layer-module-type-map`,`Layer module type map is required to construct sub layers`);switch(s){case`Feature Service`:a=l.FeatureLayer;break;case`Stream Service`:a=l.StreamLayer;break;case`Scene Service`:a=l.SceneLayer;break;case`Feature Collection`:a=l.FeatureLayer;break;case`Video Service`:a=l.VideoLayer;break;default:throw new e(`portal:unsupported-item-type-as-group`,`The item type '${s}' is not supported as a 'GroupLayer'`)}let u=s===`Video Service`,h=new r,[g,{data:_}]=await Promise.all([a(),u?{data:null}:M(n,h)]),v=()=>g;if(u)return k(t,v,l);if(s===`Feature Service`){let e=d(_)?.customParameters,n=(await f(_,c,h)).data;v=await R(n,l)??v;let{provider:r,preferredHost:a}=await L(c,{customParameters:e,loadContext:h});return i(o,a),await A(t,v,v,n,l,r)}return s===`Scene Service`&&c&&(_=await p(o,_,h)),m(_)>0?await A(t,v,null,_,l):await O(t,v,l)}async function O(e,t,n){let{portalItem:r}=e;if(!r?.url)return;let i=await b(r.url);i&&A(e,t,null,{layers:i.layers?.map(e=>_(e)),tables:i.tables?.map(e=>_(e,!0))},n)}async function k(e,t,n){let{portalItem:r}=e;if(!r?.url)return;let i=await b(r.url);i&&A(e,t,null,{layers:i.layers?.map(({id:e,name:t})=>({id:e,name:t}))},n)}async function A(e,t,n,r,i,a){let o=r.layers??[],s=r.tables??[];if(e.portalItem?.type===`Feature Collection`?(o.forEach((e,t)=>{e.id=t,e?.layerDefinition?.type===`Table`&&s.push(e)}),o=o.filter(e=>e?.layerDefinition?.type!==`Table`)):(o.reverse(),s.reverse()),o.forEach(n=>{let i=a?.(n);if(i||!a){let a=j(e,t(n),r,n,i);e.add(a)}}),s.length){let t=n?null:await i.FeatureLayer();s.forEach(i=>{let o=a?.(i);if(o||!a){let a=j(e,n?n(i):t,r,i,o);e.tables.add(a)}})}}function j(e,t,n,r,i){let a=e.portalItem,o={portalItem:a.clone(),layerId:r.id};r.url!=null&&(o.url=r.url);let c=new t(o);if(`sourceJSON`in c&&(c.sourceJSON=i),c.type!==`subtype-group`&&c.type!==`catalog`&&(c.sublayerTitleMode=`service-name`),a.type===`Feature Collection`){let e={origin:`portal-item`,portal:a.portal??s.getDefault()};c.read(r,e);let t=n.showLegend;t!=null&&c.read({showLegend:t},e)}return c}async function M(e,t,n){if(e.supportsData===!1)return{data:void 0};let r=e.instance,{portalItem:a,type:o}=r;if(!a)return{data:void 0};let s=null;try{s=o===`video`?null:await a.fetchData(`json`,n)}catch{}if(F(r)){let{type:e,url:n}=a;if(e===`Feature Service`&&n)try{await l(s,n,t)}catch{}let c=null,{count:f,preferredHost:p}=await N(a,s,t);if(i(a,p),(s?.layers||s?.tables)&&f>0){if(r.layerId==null){let e=h(o),t=e?.length?u(s,e)[0]:d(s);t&&(r.layerId=t.id)}c=P(s,r),c?.layerType===`OrientedImageryLayer`&&o===`oriented-imagery`&&r.supportedSourceTypes.add(`Feature Layer`),c&&s.showLegend!=null&&(c.showLegend=s.showLegend)}return f>1&&`sublayerTitleMode`in r&&r.sublayerTitleMode!==`service-name`&&(r.sublayerTitleMode=`item-title-and-service-name`),{data:c,preferredHost:p}}return{data:s}}async function N(e,n,r){if(n?.layers&&n?.tables)return{count:m(n)};let i=t(e.url);if(!i)return{count:1};let s=i.url.path,c=await r.fetchServiceMetadata(s,{customParameters:d(n)?.customParameters}).catch(()=>null);return{count:(n?.layers?.length??c?.layers?.length??0)+(n?.tables?.length??c?.tables?.length??0),preferredHost:a(e)?o():null}}function P(e,t){let{layerId:n}=t,r=e.layers?.find(({id:e})=>e===n)??e.tables?.find(({id:e})=>e===n);return r&&I(r,t)?r:null}function F(e){return e.type!==`stream`&&`layerId`in e}function I(e,t){let{layerType:n}=e;switch(t.type){case`annotation-feature`:return n===`ArcGISAnnotationLayer`;case`catalog`:return n===`CatalogLayer`;case`dimension-feature`:return n===`ArcGISDimensionLayer`;case`feature`:return!n||n===`ArcGISFeatureLayer`||n===`Table`;case`oriented-imagery`:return n===`OrientedImageryLayer`;case`subtype-group`:return n===`SubtypeGroupLayer`||n===`SubtypeGroupTable`}return!0}async function L(e,t){let{layersJSON:r,preferredHost:i}=await n(e,t);if(!r)return{provider:null,preferredHost:i};let a=[...r.layers,...r.tables];return{provider:e=>a.find(t=>t.id===e.id),preferredHost:i}}async function R(e,t){let{layers:n,tables:r}=e,i=[...n,...r];if(!i.length)return;let a=new Set,o=[];for(let{layerType:e}of i){if(a.has(e))continue;a.add(e);let n=t[g(e)];o.push(n())}let s=await Promise.all(o),c=new Map;return Array.from(a).forEach((e,t)=>{c.set(e,s[t])}),({layerType:e})=>c.get(e)}export{x as load,S as reload};
2
+ import e from"../../core/Error.js";import{parse as t}from"../../layers/support/arcgisLayerUrl.js";import{fetchFeatureService as n}from"../../layers/support/fetchService.js";import{LayerLoadContext as r}from"../../layers/support/LayerLoadContext.js";import{applyPreferredHostToPortalItem as i,isPreferredUrlApplicable as a,getPreferredHost as o}from"../../layers/support/layerUtils.js";import s from"../Portal.js";import{createForItemRead as c}from"./jsonContext.js";import{normalizeFSItemData as l,getSublayersByLayerType as u,getFirstLayerOrTable as d,preprocessFSItemData as f,populateSceneServiceItemData as p,getNumLayersAndTables as m,instanceTypeToLayerTypes as h,layerTypeToLayerModuleType as g,createSublayerData as _}from"./loadUtils.js";import{hasTypeKeyword as v}from"./portalItemUtils.js";import{loadStyleRenderer as y}from"../../renderers/support/styleUtils.js";import{requestServiceJSON as b}from"../../request/serviceJSON.js";async function x(e,t){let n=e.instance.portalItem;if(n?.id)return await n.load(t),C(e),e.validateItem&&e.validateItem(n),w(e,t)}async function S(e,t){let n=e.instance.portalItem;if(!n?.id||!n.loaded)return!1;let r=n.modified;return await n.reload(),t?.signal?.throwIfAborted(),r?.getTime()!==n.modified?.getTime()&&(C(e),e.validateItem&&e.validateItem(n),await w(e,t),!0)}function C(t){let n=t.instance.portalItem;if(!n?.type||!t.supportedTypes.includes(n.type))throw new e(`portal:invalid-layer-item-type`,"Invalid layer item type '${type}', expected '${expectedType}'",{type:n?.type,expectedType:t.supportedTypes.join(`, `)})}async function w(e,t){let n=e.instance,{portalItem:i,type:a}=n;if(!i)return;let{url:o}=i,{title:s}=i,l=c(i,`portal-item`);if(a===`group`)return T(n,l,e);o&&a!==`media`&&a!==`parquet`&&n.read({url:o},l);let{data:u,preferredHost:d}=await M(e,new r,t);return o=i.url,`isUrlHostModified`in n&&(d?n.applyPreferredHost({preferredHost:d}):n.applyHostFromPortalItem()),u&&n.read(u,l),n.resourceReferences={portalItem:i,paths:l.readResourcePaths??[]},a!==`subtype-group`&&n.read({title:s},l),y(n,l)}async function T(t,n,r){let i=t.portalItem;if(!t.sourceIsPortalItem)return;let{title:a,type:o}=i;if(o===`Group Layer`){if(!v(i,`Map`))throw new e(`portal:invalid-layer-item-typekeyword`,`'Group Layer' item without 'Map' type keyword is not supported`);return E(t,r)}return t.read({title:a},n),D(t,r)}async function E(t,n){let r=t.portalItem,i=await r.fetchData(`json`);if(!i)return;if(!n.populateGroupLayer)throw new e(`portal:missing-populate-group-layer`,`Missing populate group layer`);let a=c(r,`web-map`);t.read(i,a),await n.populateGroupLayer(t,i,{context:a}),t.resourceReferences={portalItem:r,paths:a.readResourcePaths??[]}}async function D(t,n){let a,{portalItem:o}=t;if(!o)return;let{type:s,url:c}=o,l=n.layerModuleTypeMap;if(!l)throw new e(`portal:missing-layer-module-type-map`,`Layer module type map is required to construct sub layers`);switch(s){case`Feature Service`:a=l.FeatureLayer;break;case`Stream Service`:a=l.StreamLayer;break;case`Scene Service`:a=l.SceneLayer;break;case`Feature Collection`:a=l.FeatureLayer;break;case`Video Service`:a=l.VideoLayer;break;default:throw new e(`portal:unsupported-item-type-as-group`,`The item type '${s}' is not supported as a 'GroupLayer'`)}let u=s===`Video Service`,h=new r,[g,{data:_}]=await Promise.all([a(),u?{data:null}:M(n,h)]),v=()=>g;if(u)return k(t,v,l);if(s===`Feature Service`){let e=d(_)?.customParameters,n=(await f(_,c,h)).data;v=await R(n,l)??v;let{provider:r,preferredHost:a}=await L(c,{customParameters:e,loadContext:h});return i(o,a),await A(t,v,v,n,l,r)}return s===`Scene Service`&&c&&(_=await p(o,_,h)),m(_)>0?await A(t,v,null,_,l):await O(t,v,l)}async function O(e,t,n){let{portalItem:r}=e;if(!r?.url)return;let i=await b(r.url);i&&A(e,t,null,{layers:i.layers?.map(e=>_(e)),tables:i.tables?.map(e=>_(e,!0))},n)}async function k(e,t,n){let{portalItem:r}=e;if(!r?.url)return;let i=await b(r.url);i&&A(e,t,null,{layers:i.layers?.map(({id:e,name:t})=>({id:e,name:t}))},n)}async function A(e,t,n,r,i,a){let o=r.layers??[],s=r.tables??[];if(e.portalItem?.type===`Feature Collection`?(o.forEach((e,t)=>{e.id=t,e?.layerDefinition?.type===`Table`&&s.push(e)}),o=o.filter(e=>e?.layerDefinition?.type!==`Table`)):(o.reverse(),s.reverse()),o.forEach(n=>{let i=a?.(n);if(i||!a){let a=j(e,t(n),r,n,i);e.add(a)}}),s.length){let t=n?null:await i.FeatureLayer();s.forEach(i=>{let o=a?.(i);if(o||!a){let a=j(e,n?n(i):t,r,i,o);e.tables.add(a)}})}}function j(e,t,n,r,i){let a=e.portalItem,o={portalItem:a.clone(),layerId:r.id};r.url!=null&&(o.url=r.url);let c=new t(o);if(`sourceJSON`in c&&(c.sourceJSON=i),c.type!==`subtype-group`&&c.type!==`catalog`&&(c.sublayerTitleMode=`service-name`),a.type===`Feature Collection`){let e={origin:`portal-item`,portal:a.portal??s.getDefault()};c.read(r,e);let t=n.showLegend;t!=null&&c.read({showLegend:t},e)}return c}async function M(e,t,n){if(e.supportsData===!1)return{data:void 0};let r=e.instance,{portalItem:a,type:o}=r;if(!a)return{data:void 0};let s=null;try{s=o===`video`?null:await a.fetchData(`json`,n)}catch{}if(F(r)){let{type:e,url:n}=a;if(e===`Feature Service`&&n)try{await l(s,n,t)}catch{}let c=null,{count:f,preferredHost:p}=await N(a,s,t);if(i(a,p),(s?.layers||s?.tables)&&f>0){if(r.layerId==null){let e=h(o),t=e?.length?u(s,e)[0]:d(s);t&&(r.layerId=t.id)}c=P(s,r),c?.layerType===`OrientedImageryLayer`&&o===`oriented-imagery`&&r.supportedSourceTypes.add(`Feature Layer`),c&&s.showLegend!=null&&(c.showLegend=s.showLegend)}return f>1&&`sublayerTitleMode`in r&&r.sublayerTitleMode!==`service-name`&&(r.sublayerTitleMode=`item-title-and-service-name`),{data:c,preferredHost:p}}return{data:s}}async function N(e,n,r){if(n?.layers&&n?.tables)return{count:m(n)};let i=t(e.url);if(!i)return{count:1};let s=i.url.path,c=await r.fetchServiceMetadata(s,{customParameters:d(n)?.customParameters}).catch(()=>null);return{count:(n?.layers?.length??c?.layers?.length??0)+(n?.tables?.length??c?.tables?.length??0),preferredHost:a(e)?o():null}}function P(e,t){let{layerId:n}=t,r=e.layers?.find(({id:e})=>e===n)??e.tables?.find(({id:e})=>e===n);return r&&I(r,t)?r:null}function F(e){return e.type!==`stream`&&`layerId`in e}function I(e,t){let{layerType:n}=e;switch(t.type){case`annotation-feature`:return n===`ArcGISAnnotationLayer`;case`catalog`:return n===`CatalogLayer`;case`dimension-feature`:return n===`ArcGISDimensionLayer`;case`feature`:return!n||n===`ArcGISFeatureLayer`||n===`Table`;case`oriented-imagery`:return n===`OrientedImageryLayer`;case`subtype-group`:return n===`SubtypeGroupLayer`||n===`SubtypeGroupTable`}return!0}async function L(e,t){let{layersJSON:r,preferredHost:i}=await n(e,t);if(!r)return{provider:null,preferredHost:i};let a=[...r.layers,...r.tables];return{provider:e=>a.find(t=>t.id===e.id),preferredHost:i}}async function R(e,t){let{layers:n,tables:r}=e,i=[...n,...r];if(!i.length)return;let a=new Set,o=[];for(let{layerType:e}of i){if(a.has(e))continue;a.add(e);let n=t[g(e)];o.push(n())}let s=await Promise.all(o),c=new Map;return Array.from(a).forEach((e,t)=>{c.set(e,s[t])}),({layerType:e})=>c.get(e)}export{x as load,S as reload};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../core/Error.js";import has from"../../core/has.js";import{findAssociatedFeatureService as t}from"../../layers/support/associatedFeatureServiceUtils.js";import{getLayerModuleTypeStrict as n}from"../../layers/support/fetchService.js";import{LayerLoadContext as r}from"../../layers/support/LayerLoadContext.js";import{layersLoaderMap as i}from"../../layers/support/layersLoader.js";import{sceneServiceLayerTypeToClassName as a,applyPreferredHostToPortalItem as o,getPreferredHost as s}from"../../layers/support/layerUtils.js";import c from"../PortalItem.js";import{getFirstLayerOrTable as l,getNumLayersAndTables as u,preprocessFSItemData as d,getLayerOrTable as f,layerTypeToLayerModuleType as p,populateSceneServiceItemData as m}from"./loadUtils.js";import{hasTypeKeyword as h}from"./portalItemUtils.js";async function g(e){let{portalItem:t}=e;t&&!(t instanceof c)&&(t=new c(t));let n=await _(t),r=n.constructor;return new r({portalItem:t,...n.properties})}async function _(e){return await e.load(),y(await v(e,new r))}async function v(t,n){switch(t.type){case`3DTiles Service`:return t.typeKeywords.includes(`3DObject`)?j():t.typeKeywords.includes(`GaussianSplat`)?A():k();case`CSV`:return M();case`Feature Collection`:return C(t);case`Feature Service`:return x(t,n);case`Feed`:return B();case`GeoJson`:return O();case`Group Layer`:return V();case`Image Service`:return w(t,n);case`KML`:return P();case`Knowledge Graph Layer`:return F();case`Map Service`:return b(t,n);case`Media Layer`:return H();case`PDF`:return N();case`Scene Service`:return S(t,n);case`Stream Service`:return T();case`Video Service`:return E(t,n);case`Vector Tile Service`:return D();case`WCS`:return I();case`WFS`:return L();case`WMS`:return R();case`WMTS`:return z();default:throw new e(`portal:unknown-item-type`,"Unknown item type '${type}'",{type:t.type})}}async function y(e){let t=e.className,n=i[t];return{constructor:await n(),properties:e.properties}}async function b(e,t){return await U(e,t)?{className:`TileLayer`}:{className:`MapImageLayer`}}async function x(e,t){let n=await W(e,t);if(typeof n==`object`){let{sourceJSON:e,className:t}=n,r={sourceJSON:e};return n.id!=null&&(r.layerId=n.id),{className:t||`FeatureLayer`,properties:r}}return{className:`GroupLayer`}}async function S(e,n){let r=await W(e,n,async()=>{try{if(!e.url)return[];let{serverUrl:r}=await t(e.url,{sceneLayerItem:e});return(await n.fetchServiceMetadata(r))?.tables??[]}catch{return[]}});if(typeof r==`object`){let t={},i;if(r.id==null?i=e.url:(t.layerId=r.id,i=`${e.url}/layers/${r.id}`),e.typeKeywords?.length){for(let t of Object.keys(a))if(e.typeKeywords.includes(t))return{className:a[t]}}let o=await n.fetchServiceMetadata(i,{customParameters:await n.fetchCustomParameters(e,e=>l(e)?.customParameters)});return{className:a[o?.layerType]||`SceneLayer`,properties:t}}return r===!1&&(await n.fetchServiceMetadata(e.url))?.layerType===`Voxel`?{className:`VoxelLayer`}:{className:`GroupLayer`}}async function C(e){await e.load();let t=h(e,`Map Notes`),n=h(e,`Markup`);if(t||n)return{className:has(`sketch-layer-enabled`)?`SketchLayer`:`MapNotesLayer`};if(h(e,`Route Layer`))return{className:`RouteLayer`};let r=await e.fetchData();return u(r)===1?{className:`FeatureLayer`}:{className:`GroupLayer`}}async function w(e,t){await e.load();let n=e.typeKeywords?.map(e=>e.toLowerCase())??[];if(n.includes(`elevation 3d layer`))return{className:`ElevationLayer`};if(n.includes(`tiled imagery`))return{className:`ImageryTileLayer`};let r=(await t.fetchItemData(e))?.layerType;if(r===`ArcGISTiledImageServiceLayer`)return{className:`ImageryTileLayer`};if(r===`ArcGISImageServiceLayer`)return{className:`ImageryLayer`};let i=await t.fetchServiceMetadata(e.url,{customParameters:await t.fetchCustomParameters(e)}),a=i.cacheType?.toLowerCase(),o=i.capabilities?.toLowerCase().includes(`tilesonly`),s=i.tileInfo?.format?.toLowerCase()??``,c=a==null&&[`jpg`,`jpeg`,`png`,`png8`,`png24`,`png32`,`mixed`].includes(s);return a===`map`||c||o?{className:`ImageryTileLayer`}:{className:`ImageryLayer`}}function T(){return{className:`StreamLayer`}}async function E(e,t){return typeof await W(e,t)==`object`?{className:`VideoLayer`}:{className:`GroupLayer`}}function D(){return{className:`VectorTileLayer`}}function O(){return{className:`GeoJSONLayer`}}function k(){return{className:`IntegratedMesh3DTilesLayer`}}function A(){return{className:`GaussianSplatLayer`}}function j(){return{className:`UnsupportedLayer`}}function M(){return{className:`CSVLayer`}}function N(){return{className:`GeospatialPDFLayer`}}function P(){return{className:`KMLLayer`}}function F(){return{className:`KnowledgeGraphLayer`}}function I(){return{className:`WCSLayer`}}function L(){return{className:`WFSLayer`}}function R(){return{className:`WMSLayer`}}function z(){return{className:`WMTSLayer`}}function B(){return{className:`StreamLayer`}}function V(){return{className:`GroupLayer`}}function H(){return{className:`MediaLayer`}}async function U(e,t){let{tileInfo:n}=await t.fetchServiceMetadata(e.url,{customParameters:await t.fetchCustomParameters(e)});return n}async function W(t,r,i){let{url:a,type:c}=t,h=c===`Feature Service`;if(!a)return{};if(/\/\d+$/.test(a)){if(h){let i=await r.fetchServiceMetadata(a,{customParameters:await r.fetchCustomParameters(t,e=>l(e)?.customParameters)});o(t,s());let{id:c,type:u}=i,d=n(u);if(!d)throw new e(`from-portal-item:unsupported`,`'${a}' has unsupported type: '${u}'`);return{id:c,className:d,sourceJSON:i}}return{}}if(c===`Video Service`)return((await r.fetchServiceMetadata(a)).layers?.length??0)>1?!1:{};await t.load();let g=await r.fetchItemData(t);if(h){let{data:n,preferredHost:i}=await d(g,a,r);if(u(n)===0)throw new e(`from-portal-item:no-data`,`The feature service '${a}' does not have any supported layers or tables`);o(t,i);let s=G(n);if(typeof s==`object`){let e=f(n,s.id);return{id:s.id,className:p(e?.layerType)}}return s}if(c===`Scene Service`&&(g=await m(t,g,r)),u(g)>0)return G(g);let _=await r.fetchServiceMetadata(a);return i&&(_.tables=await i()),G(_)}function G(e){return u(e)===1&&{id:l(e)?.id}}export{g as fromItem,v as selectLayerClassPath};
2
+ import e from"../../core/Error.js";import has from"../../core/has.js";import{findAssociatedFeatureService as t}from"../../layers/support/associatedFeatureServiceUtils.js";import{getLayerModuleTypeStrict as n}from"../../layers/support/fetchService.js";import{LayerLoadContext as r}from"../../layers/support/LayerLoadContext.js";import{layersLoaderMap as i}from"../../layers/support/layersLoader.js";import{sceneServiceLayerTypeToClassName as a,applyPreferredHostToPortalItem as o,getPreferredHost as s}from"../../layers/support/layerUtils.js";import c from"../PortalItem.js";import{getFirstLayerOrTable as l,getNumLayersAndTables as u,preprocessFSItemData as d,getLayerOrTable as f,layerTypeToLayerModuleType as p,populateSceneServiceItemData as m}from"./loadUtils.js";import{hasTypeKeyword as h}from"./portalItemUtils.js";async function g(e){let{portalItem:t}=e;t&&!(t instanceof c)&&(t=new c(t));let n=await _(t),r=n.constructor;return new r({portalItem:t,...n.properties})}async function _(e){return await e.load(),y(await v(e,new r))}async function v(t,n){switch(t.type){case`3DTiles Service`:return t.typeKeywords.includes(`3DObject`)?j():t.typeKeywords.includes(`GaussianSplat`)?A():k();case`CSV`:return M();case`Feature Collection`:return C(t);case`Feature Service`:return x(t,n);case`Feed`:return z();case`GeoJson`:return O();case`Group Layer`:return B();case`Image Service`:return w(t,n);case`KML`:return N();case`Knowledge Graph Layer`:return P();case`Map Service`:return b(t,n);case`Media Layer`:return V();case`Parquet Feature Layer`:return H();case`Scene Service`:return S(t,n);case`Stream Service`:return T();case`Video Service`:return E(t,n);case`Vector Tile Service`:return D();case`WCS`:return F();case`WFS`:return I();case`WMS`:return L();case`WMTS`:return R();default:throw new e(`portal:unknown-item-type`,"Unknown item type '${type}'",{type:t.type})}}async function y(e){let t=e.className,n=i[t];return{constructor:await n(),properties:e.properties}}async function b(e,t){return await U(e,t)?{className:`TileLayer`}:{className:`MapImageLayer`}}async function x(e,t){let n=await W(e,t);if(typeof n==`object`){let{sourceJSON:e,className:t}=n,r={sourceJSON:e};return n.id!=null&&(r.layerId=n.id),{className:t||`FeatureLayer`,properties:r}}return{className:`GroupLayer`}}async function S(e,n){let r=await W(e,n,async()=>{try{if(!e.url)return[];let{serverUrl:r}=await t(e.url,{sceneLayerItem:e});return(await n.fetchServiceMetadata(r))?.tables??[]}catch{return[]}});if(typeof r==`object`){let t={},i;if(r.id==null?i=e.url:(t.layerId=r.id,i=`${e.url}/layers/${r.id}`),e.typeKeywords?.length){for(let t of Object.keys(a))if(e.typeKeywords.includes(t))return{className:a[t]}}let o=await n.fetchServiceMetadata(i,{customParameters:await n.fetchCustomParameters(e,e=>l(e)?.customParameters)});return{className:a[o?.layerType]||`SceneLayer`,properties:t}}return r===!1&&(await n.fetchServiceMetadata(e.url))?.layerType===`Voxel`?{className:`VoxelLayer`}:{className:`GroupLayer`}}async function C(e){await e.load();let t=h(e,`Map Notes`),n=h(e,`Markup`);if(t||n)return{className:has(`sketch-layer-enabled`)?`SketchLayer`:`MapNotesLayer`};if(h(e,`Route Layer`))return{className:`RouteLayer`};let r=await e.fetchData();return u(r)===1?{className:`FeatureLayer`}:{className:`GroupLayer`}}async function w(e,t){await e.load();let n=e.typeKeywords?.map(e=>e.toLowerCase())??[];if(n.includes(`elevation 3d layer`))return{className:`ElevationLayer`};if(n.includes(`tiled imagery`))return{className:`ImageryTileLayer`};let r=(await t.fetchItemData(e))?.layerType;if(r===`ArcGISTiledImageServiceLayer`)return{className:`ImageryTileLayer`};if(r===`ArcGISImageServiceLayer`)return{className:`ImageryLayer`};let i=await t.fetchServiceMetadata(e.url,{customParameters:await t.fetchCustomParameters(e)}),a=i.cacheType?.toLowerCase(),o=i.capabilities?.toLowerCase().includes(`tilesonly`),s=i.tileInfo?.format?.toLowerCase()??``,c=a==null&&[`jpg`,`jpeg`,`png`,`png8`,`png24`,`png32`,`mixed`].includes(s);return a===`map`||c||o?{className:`ImageryTileLayer`}:{className:`ImageryLayer`}}function T(){return{className:`StreamLayer`}}async function E(e,t){return typeof await W(e,t)==`object`?{className:`VideoLayer`}:{className:`GroupLayer`}}function D(){return{className:`VectorTileLayer`}}function O(){return{className:`GeoJSONLayer`}}function k(){return{className:`IntegratedMesh3DTilesLayer`}}function A(){return{className:`GaussianSplatLayer`}}function j(){return{className:`UnsupportedLayer`}}function M(){return{className:`CSVLayer`}}function N(){return{className:`KMLLayer`}}function P(){return{className:`KnowledgeGraphLayer`}}function F(){return{className:`WCSLayer`}}function I(){return{className:`WFSLayer`}}function L(){return{className:`WMSLayer`}}function R(){return{className:`WMTSLayer`}}function z(){return{className:`StreamLayer`}}function B(){return{className:`GroupLayer`}}function V(){return{className:`MediaLayer`}}function H(){return{className:`ParquetLayer`}}async function U(e,t){let{tileInfo:n}=await t.fetchServiceMetadata(e.url,{customParameters:await t.fetchCustomParameters(e)});return n}async function W(t,r,i){let{url:a,type:c}=t,h=c===`Feature Service`;if(!a)return{};if(/\/\d+$/.test(a)){if(h){let i=await r.fetchServiceMetadata(a,{customParameters:await r.fetchCustomParameters(t,e=>l(e)?.customParameters)});o(t,s());let{id:c,type:u}=i,d=n(u);if(!d)throw new e(`from-portal-item:unsupported`,`'${a}' has unsupported type: '${u}'`);return{id:c,className:d,sourceJSON:i}}return{}}if(c===`Video Service`)return((await r.fetchServiceMetadata(a)).layers?.length??0)>1?!1:{};await t.load();let g=await r.fetchItemData(t);if(h){let{data:n,preferredHost:i}=await d(g,a,r);if(u(n)===0)throw new e(`from-portal-item:no-data`,`The feature service '${a}' does not have any supported layers or tables`);o(t,i);let s=G(n);if(typeof s==`object`){let e=f(n,s.id);return{id:s.id,className:p(e?.layerType)}}return s}if(c===`Scene Service`&&(g=await m(t,g,r)),u(g)>0)return G(g);let _=await r.fetchServiceMetadata(a);return i&&(_.tables=await i()),G(_)}function G(e){return u(e)===1&&{id:l(e)?.id}}export{g as fromItem,v as selectLayerClassPath};
package/rest/print.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{id as e}from"../kernel.js";import t from"../request.js";import{JSONMap as n}from"../core/jsonMap.js";import{createScreenPoint as r,pt2px as i,px2pt as a}from"../core/screenUtils.js";import{dataComponents as o,normalize as s}from"../core/urlUtils.js";import c from"../geometry/Polygon.js";import{collectLabelingFields as l}from"../layers/support/fieldUtils.js";import{getFloorFilterClause as u}from"../layers/support/floorFilterUtils.js";import{getSizeRangeAtScale as d}from"../renderers/visualVariables/support/visualVariableUtils.js";import{asValidOptions as f,findToken as p}from"./utils.js";import{execute as m}from"./geoprocessor/execute.js";import{submitJob as h}from"./geoprocessor/submitJob.js";import{formatJsonMap as g}from"./support/fileFormat.js";import{toJSON as _}from"./support/layoutTemplate.js";import{getVisibleLayerViews as ee,isScreenshotRequired as v,isBingMapsLayer as y,isBlendLayer as te,getCopyright as b,getSelectionSymbol as ne,createPointLayer as x,getContextBoundingBox as re,createPolygonLayer as ie,createPolylineLayer as ae,createMultipointLayer as S}from"./support/printTaskUtils.js";import oe from"./support/PrintTemplate.js";import{toJSON as se}from"./support/reportTemplate.js";import ce from"../symbols/WebStyleSymbol.js";import le from"../views/support/HighlightOptions.js";const C={Feet:`ft`,Kilometers:`km`,Meters:`m`,Miles:`mi`},w=new n({esriFeet:`Feet`,esriKilometers:`Kilometers`,esriMeters:`Meters`,esriMiles:`Miles`}),T=new n({esriExecutionTypeSynchronous:`sync`,esriExecutionTypeAsynchronous:`async`}),E=new Map;async function D(e,t,n){let r=await N(t,await O(e,n));if(await k(e,n)===`sync`){let{results:t}=await m(e,r,void 0,n);return t?.[0]?.value}let i=await h(e,r,void 0,n);await i.waitForJobCompletion({interval:t.updateDelay});let{value:a}=await i.fetchResultData(`Output_File`,null,n);return a}async function O(e,n){let r=F(e),i=E.get(r)??{gpServerUrl:r,legendLayerNameMap:{},legendLayers:[],screenshotLayers:[]};return i.gpMetadata??=(await t(r,f({f:`json`},n))).data,i.cimVersion=i.gpMetadata.cimVersion,E.set(r,i),i}async function k(e,t){return we(await O(e,t))}async function A(e,n){let r=await O(e,n),i=r.gpMetadata.tasks,a=r.gpServerUrl;if(r.taskInfos)return r.taskInfos;let o=(await t(e,f({f:`json`},n))).data;r.taskInfos={ExportWebMap:o};let s=i?.filter(e=>e!==o.name)??[];return await Promise.all(s.map(async e=>{let i=(await t(`${a}/${e}`,f({f:`json`},n))).data,o=i.name.startsWith(`GetLayoutTemplatesInfo`)?`GetLayoutTemplatesInfo`:null;o&&(r.taskInfos[o]??=i)})),r.taskInfos}async function j(e,t,n){return(await A(e,n))[t]??null}async function M(e,t,n){let r=await j(e,t,n);return r?.executionType?T.fromJSON(r.executionType):`sync`}async function N(t,n){n||={is11xService:!1,legendLayerNameMap:{},legendLayers:[]};let r=t.template||new oe;r.showLabels??=!0;let i;r.format===`pdf`&&(i={enablePdfAccessibility:!0});let a=_(r.layout),o=r.exportOptions;if(o){let e=o.dpi;if(i??={},i.dpi=e,a?.toLowerCase()===`map_only`||a===``){let{width:e,height:t}=o;i.outputSize=e!=null&&t!=null?[e,t]:void 0}}let s=r.layoutOptions,c;if(s){let e,t;s.scalebarUnit===`Miles`||s.scalebarUnit===`Kilometers`?(e=`Kilometers`,t=`Miles`):(s.scalebarUnit===`Meters`||s.scalebarUnit===`Feet`)&&(e=`Meters`,t=`Feet`),c={titleText:s.titleText,authorText:s.authorText,copyrightText:s.copyrightText,customTextElements:s.customTextElements,elementOverrides:s.elementOverrides,scaleBarOptions:e||t?{metricUnit:w.toJSON(e)??void 0,metricLabel:e?C[e]:void 0,nonMetricUnit:w.toJSON(t)??void 0,nonMetricLabel:t?C[t]:void 0}:void 0}}let l=await P(t,r,n);if(l.operationalLayers){let e=RegExp(`[\\u4E00-\\u9FFF\\u0E00-\\u0E7F\\u0900-\\u097F\\u3040-\\u309F\\u30A0-\\u30FF\\u31F0-\\u31FF]`),t=/[\u0600-\u06FF]/,n=n=>{let r=n.text,i=n.font,a=i?.family?.toLowerCase();r&&i&&(a===`arial`||a===`arial unicode ms`)&&(i.family=e.test(r)?`Arial Unicode MS`:`Arial`,i.style!==`normal`&&t.test(r)&&(i.family=`Arial Unicode MS`))};for(let e of l.operationalLayers)if(e.featureCollection?.layers)for(let t of e.featureCollection.layers){if(t.layerDefinition?.drawingInfo?.renderer?.symbol){let e=t.layerDefinition.drawingInfo.renderer;e.symbol.type===`esriTS`&&n(e.symbol)}if(t.featureSet?.features)for(let e of t.featureSet.features)e.symbol&&e.symbol.type===`esriTS`&&n(e.symbol)}}let u=null;s?.legendLayers&&(u=s.legendLayers.filter(e=>!n.screenshotLayers.includes(e.layerId)).map(e=>{let t=e.layerId;n.legendLayerNameMap[t]=e.title;let r={id:t};if(e.subLayerIds){r.subLayerIds=e.subLayerIds;let t=e.dynamicLegend;t!=null&&(r.subLayerDynamicLegends=e.subLayerIds.map(()=>t))}return e.dynamicLegend!=null&&(r.dynamicLegend=e.dynamicLegend),r})),t.outSpatialReference&&(l.mapOptions.spatialReference=t.outSpatialReference.toJSON()),t.datumTransformations?.length&&(l.mapOptions.datumTransformations=t.datumTransformations.map(e=>e.toJSON())),Object.assign(l,{exportOptions:i,layoutOptions:c||{}}),Object.assign(l.layoutOptions,{legendOptions:{operationalLayers:u??n.legendLayers.slice()}}),n.legendLayers.length=0,n.screenshotLayers.length=0,E.set(n.gpServerUrl,n);let d={Web_Map_as_JSON:JSON.stringify(l),Format:g.toJSON(r.format),Layout_Template:a,Layout_Item_ID:void 0,Report_Template:se(r.report),Report_Item_ID:void 0};if(r.layoutItem){delete d.Layout_Template;let t=r.layoutItem;await t.load(),t.access!==`public`&&e&&await e.getCredential(n.gpServerUrl),d.Layout_Item_ID=JSON.stringify({id:t.id})}if(r.reportItem){delete d.Report_Template;let t=r.reportItem;await t.load(),t.access!==`public`&&e&&await e.getCredential(n.gpServerUrl),d.Report_Item_ID=JSON.stringify({id:t.id})}return t.extraParameters&&Object.assign(d,t.extraParameters),d}async function P(e,t,n){let r=e.view,i=r.spatialReference,a={operationalLayers:await I(r,t,n)};t.includeTables&&(a.tables=await _e(r));let o=e.extent||n.ssExtent||r.extent;if(i?.isWrappable&&(o=o.clone()._normalize(!0),i=o.spatialReference),a.mapOptions={extent:o&&o.toJSON(),spatialReference:i&&i.toJSON(),showAttribution:t.attributionVisible},n.ssExtent=null,r.background&&(a.background=r.background.toJSON()),r.rotation&&(a.mapOptions.rotation=-r.rotation),t.scalePreserved&&(a.mapOptions.scale=t.outScale||r.scale),r.timeExtent!=null){let e=r.timeExtent.start==null?null:r.timeExtent.start.getTime(),t=r.timeExtent.end==null?null:r.timeExtent.end.getTime();a.mapOptions.time=[e,t]}return t.reportOptions&&(a.reportOptions=t.reportOptions),a}function F(e){let t=e,n=t.lastIndexOf(`/GPServer/`);return n>0&&(t=t.slice(0,n+9)),t}async function I(e,t,n){let r=[],i=0;t.scalePreserved&&(i=t.outScale||e.scale);let a={layerView:null,outScale:i,printTemplate:t,view:e},o=ee(e,i);for(let e of o){let t=e.layer;if(!t.loaded||`layers`in t)continue;let i;a.layerView=e,i=v(e)?await G(t,a,n):y(t)?L(t):t?.type===`csv`?await z(t,a,n):t?.type===`catalog-footprint`?await R(t,a,n):t?.type===`feature`?await V(t,a,n):t?.type===`geojson`?await H(t,a,n):t?.type===`graphics`?await U(t,a,n):t?.type===`imagery`?W(t,n):t?.type===`imagery-tile`?await ue(t,a,n):t?.type===`kml`?await de(t,a,n):t?.type===`map-image`?fe(t,a,n):t?.type===`map-notes`?await pe(a,n):t?.type===`open-street-map`?me():t?.type===`stream`?await he(t,a,n):t?.type===`subtype-group`?await ge(t,n):t?.type===`tile`?ve(t,n):t?.type===`vector-tile`?await ye(t,a,n):t?.type===`web-tile`?be(t):t?.type===`wfs`?await xe(t,a,n):t?.type===`wms`?Se(t,n):t?.type===`wmts`?Ce(t):await G(t,a,n),i&&(Array.isArray(i)?r.push(...i):(i.id=t.id,i.title=n.legendLayerNameMap[t.id]||t.title,i.opacity=e.fullOpacity,i.minScale=t.minScale||0,i.maxScale=t.maxScale||0,te(t)&&t.blendMode&&t.blendMode!==`normal`&&(i.blendMode=t.blendMode),r.push(i)))}if(i)for(let e of r)e.minScale=0,e.maxScale=0;if(e.graphics?.length){let i=await B(null,e.graphics,t,n);i&&r.push(i)}return r}function L(e){return{culture:e.culture,key:e.key,type:`BingMaps${e.style===`aerial`?`Aerial`:e.style===`hybrid`?`Hybrid`:`Road`}`}}async function R(e,{layerView:t,printTemplate:n},r){if(parseFloat(r.cimVersion)<3.1)return B(e,await Z(t),n,r);let i=e.parent,a=(e=>({id:e.id,url:e.url,layerType:e.layerType,customParameters:e.customParameters,dynamicGroupLayer:{visibility:!1},footprintLayer:e.footprintLayer,layerDefinition:e.layerDefinition}))(Q(i,`web-map`));return K(a,i),a}async function z(e,t,n){e.legendEnabled&&n.legendLayers.push({id:e.id});let r=t.layerView,i=t.printTemplate;if(!r.filter&&(!e.portalItem||e.portalItem.access===`public`)){let t=Q(e,`web-map`);return t.type=`CSV`,delete t.popupInfo,delete t.layerType,t.showLabels=i.showLabels&&e.labelsVisible,t}return B(e,await Z(r),i,n)}async function B(e,t,n,r){let i,a=ie(),o=ae(),s=x(),u=S(),d=x();if(d.layerDefinition.name=`textLayer`,delete d.layerDefinition.drawingInfo,e){if(e.declaredClass===`esri.layers.FeatureLayer`||e.declaredClass===`esri.layers.StreamLayer`?a.layerDefinition.name=o.layerDefinition.name=s.layerDefinition.name=u.layerDefinition.name=r.legendLayerNameMap[e.id]||e.arcgisProps?.title||e.title:e.declaredClass===`esri.layers.GraphicsLayer`&&(t=e.graphics.items),e.renderer){let t=e.renderer.toJSON(),n=a.layerDefinition.drawingInfo;n&&(n.renderer=t);let r=o.layerDefinition.drawingInfo;r&&(r.renderer=t);let i=s.layerDefinition.drawingInfo;i&&(i.renderer=t);let c=u.layerDefinition.drawingInfo;c&&(c.renderer=t)}if(n.showLabels&&e.labelsVisible&&typeof e.write==`function`){let t=Q(e).layerDefinition?.drawingInfo?.labelingInfo;if(t){i=!0;let e=a.layerDefinition.drawingInfo;e&&(e.labelingInfo=t);let n=o.layerDefinition.drawingInfo;n&&(n.labelingInfo=t);let r=s.layerDefinition.drawingInfo;r&&(r.labelingInfo=t);let c=u.layerDefinition.drawingInfo;c&&(c.labelingInfo=t)}}}!e?.renderer&&!i&&(delete a.layerDefinition.drawingInfo,delete o.layerDefinition.drawingInfo,delete s.layerDefinition.drawingInfo,delete u.layerDefinition.drawingInfo);let f,p=e?.fieldsIndex,m=e?.renderer;if(p){let t=new Set;i&&await l(t,e),m&&typeof m.collectRequiredFields==`function`&&await m.collectRequiredFields(t,p),f=Array.from(t);let n=p.fields.map(e=>e.toJSON());a.layerDefinition.fields=n,o.layerDefinition.fields=n,s.layerDefinition.fields=n,u.layerDefinition.fields=n}let h=t?.length,g;for(let e=0;e<h;e++){let i=t[e]||t.at(e);if(i.visible!==!1&&i.geometry){if(g=i.toJSON(),g.hasOwnProperty(`popupTemplate`)&&delete g.popupTemplate,g.geometry?.z&&delete g.geometry.z,g.symbol&&(g.symbol.angle||delete g.symbol.angle,$(g.symbol)?g.symbol=await q(g.symbol,r):g.symbol.text&&delete g.attributes),(!n||!n.forceFeatureAttributes)&&f?.length){let e={};for(let t of f)g.attributes?.hasOwnProperty(t)&&(e[t]=g.attributes[t]);g.attributes=e}i.geometry.type===`polygon`?a.featureSet.features.push(g):i.geometry.type===`polyline`?o.featureSet.features.push(g):i.geometry.type===`point`?g.symbol?.text?d.featureSet.features.push(g):s.featureSet.features.push(g):i.geometry.type===`multipoint`?u.featureSet.features.push(g):i.geometry.type===`extent`&&(g.geometry=c.fromExtent(i.geometry).toJSON(),a.featureSet.features.push(g))}}let _=[a,o,u,s,d].filter(e=>e.featureSet.features.length>0);for(let e of _){let t=e.featureSet.features.every(e=>e.symbol);if(t&&(!n||!n.forceFeatureAttributes))for(let t of e.featureSet.features)delete t.attributes;t&&delete e.layerDefinition.drawingInfo,e.layerDefinition.drawingInfo?.renderer&&(await X(e.layerDefinition.drawingInfo.renderer),await J(e.layerDefinition.drawingInfo.renderer,r))}return _.length?{featureCollection:{layers:_},showLabels:i}:null}async function V(e,t,n){let r,i=e.renderer,a=parseFloat(n.cimVersion);if(e.featureReduction?.type===`binning`||e.featureReduction?.type===`cluster`&&(a<2.9||e.featureReduction.renderer?.type===`pie-chart`)||i?.type===`pie-chart`&&a<3.1||i?.type===`dot-density`&&a<2.6||e.geometryType===`polygon`&&i?.authoringInfo?.visualVariables?.some(e=>e.theme===`spike`))return G(e,t,n);e.legendEnabled&&n.legendLayers.push({id:e.id});let o=t.layerView,{printTemplate:s,view:c}=t,l=e.source?.type!==`feature-layer`&&e.source?.type!==`ogc-feature`;if(!o.filter&&!l&&i&&(!(`field`in i)||i.field==null||e.getField(i.field))){if(r=(e=>({id:e.id,title:e.title,url:e.url,layerType:e.layerType,customParameters:e.customParameters,layerDefinition:e.layerDefinition,charts:s.includeCharts?e.charts:void 0}))(Q(e)),s.attributionVisible&&(r.credits=b(e)),r.showLabels=s.showLabels&&e.labelsVisible&&!!e.labelingInfo&&e.labelingInfo.length>0,K(r,e),delete r.layerDefinition?.featureReduction?.disablePopup,delete r.layerDefinition?.featureReduction?.popupInfo,o.displayFilterEnabled||delete r.layerDefinition?.displayFilterInfo,r.layerDefinition?.drawingInfo?.renderer&&(delete r.layerDefinition.minScale,delete r.layerDefinition.maxScale,await X(r.layerDefinition.drawingInfo.renderer),await J(r.layerDefinition.drawingInfo.renderer,n),`visualVariables`in i&&i.visualVariables?.[0])){let e=i.visualVariables[0];if(e.type===`size`&&e.maxSize&&typeof e.maxSize!=`number`&&e.minSize&&typeof e.minSize!=`number`){let t=d(e,c.scale);r.layerDefinition.drawingInfo.renderer.visualVariables[0].minSize=t.minSize,r.layerDefinition.drawingInfo.renderer.visualVariables[0].maxSize=t.maxSize}}let t=u(o);if(t&&(r.layerDefinition??={},r.layerDefinition.definitionExpression=r.layerDefinition.definitionExpression?`(${r.layerDefinition.definitionExpression}) AND (${t})`:t),e.gdbVersion&&(r.layerDefinition??={},r.layerDefinition.gdbVersion=e.gdbVersion),o.hasHighlight&&`highlightIds`in o){let t=o;r.selectionObjectIds=t.highlightIds;let n=t.highlightOptions??c.defaultHighlight??new le;r.selectionSymbol=ne(e.geometryType,n)}}else r=await B(e,await Z(o),s,n);return r}async function H(e,t,n){return e.featureReduction?.type===`binning`||e.featureReduction?.type===`cluster`?G(e,t,n):(e.legendEnabled&&n.legendLayers.push({id:e.id}),B(e,await Z(t.layerView),t.printTemplate,n))}async function U(e,{printTemplate:t},n){return B(e,null,t,n)}function W(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});let n=(e=>({layerType:e.layerType,customParameters:e.customParameters}))(Q(e));return n.bandIds=e.bandIds,n.compressionQuality=e.compressionQuality,n.format=e.format,n.interpolation=e.interpolation,(e.mosaicRule||e.definitionExpression)&&(n.mosaicRule=e.exportImageServiceParameters.mosaicRule.toJSON()),e.rasterFunction&&(n.renderingRule=e.rasterFunction.toJSON()),e.renderer&&(n.layerDefinition??={},n.layerDefinition.drawingInfo??={},n.layerDefinition.drawingInfo.renderer=e.renderer.toJSON()),K(n,e),n}async function ue(e,t,n){if(e.renderer?.type===`flow`||!e.supportsWrite())return G(e,t,n);e.legendEnabled&&n.legendLayers.push({id:e.id});let r=(e=>({bandIds:e.bandIds,customParameters:e.customParameters,interpolation:e.interpolation,layerDefinition:e.layerDefinition}))(Q(e));return r.layerType=`ArcGISImageServiceLayer`,K(r,e),r}async function de(e,t,n){let r=t.printTemplate;if(!e.portalItem||e.portalItem.access===`public`){let t=Q(e,`web-map`);return t.type=`kml`,delete t.layerType,t.url=s(e.url),t}let i=[],a=t.layerView;a.allVisibleMapImages.forEach((t,n)=>{let r={id:`${e.id}_image${n}`,type:`image`,title:e.id,minScale:e.minScale||0,maxScale:e.maxScale||0,opacity:a.fullOpacity,extent:t.extent};t.href.startsWith(`data:image/png;base64,`)?r.imageData=t.href.slice(22):r.url=t.href,i.push(r)});let o=[...a.allVisiblePoints.items,...a.allVisiblePolylines.items,...a.allVisiblePolygons.items],c={id:e.id,...await B(null,o,r,n)};return i.push(c),i}function fe(e,{outScale:t,printTemplate:n,view:r},i){let a,o={id:e.id,subLayerIds:[]},s=[],c=t||r.scale,l=e=>{let t=c===0,n=e.minScale===0||c<=e.minScale,r=e.maxScale===0||c>=e.maxScale;if(e.visible&&(t||n&&r)){if(e.sublayers)e.sublayers.forEach(l);else{let t=e.toExportImageJSON(),n={id:e.id,name:e.title,layerDefinition:{definitionExpression:t.definitionExpression,drawingInfo:t.drawingInfo,orderBy:t.orderBy,source:t.source}};s.unshift(n),o.subLayerIds.push(e.id)}}};return e.sublayers?.forEach(l),s.length&&(s=s.map(({id:e,name:t,layerDefinition:n})=>({id:e,name:t,layerDefinition:n})),a=(e=>({layerType:e.layerType,customParameters:e.customParameters}))(Q(e)),a.layers=s,a.visibleLayers=e.capabilities?.exportMap?.supportsDynamicLayers?void 0:o.subLayerIds,n.attributionVisible&&(a.credits=b(e)),e.gdbVersion&&(a.gdbVersion=e.gdbVersion),K(a,e),e.legendEnabled&&i.legendLayers.push(o)),a}async function pe({layerView:e,printTemplate:t},n){let r=[],i=e.layer;if(i.featureCollections!=null)for(let e of i.featureCollections){let i=await B(e,e.source,t,n);i&&r.push(...i.featureCollection.layers)}else if(i.sublayers!=null)for(let e of i.sublayers){let i=await B(null,e.graphics,t,n);i&&r.push(...i.featureCollection.layers)}return{featureCollection:{layers:r}}}function me(){return{type:`OpenStreetMap`}}async function G(e,{printTemplate:t,view:n},i){let a={type:`image`};i.screenshotLayers.push(e.id);let s={format:`png`,ignoreBackground:!0,ignorePadding:!0,layers:[e]};n.rotation!==0&&(s.rotation=0);let c=i.ssExtent||n.state.extent.clone(),l=96,u=!0,d=!0;if(t.exportOptions){let e=t.exportOptions;e.dpi!=null&&e.dpi>0&&(l=e.dpi),e.width!=null&&e.width>0&&(u=e.width%2==n.width%2),e.height!=null&&e.height>0&&(d=e.height%2==n.height%2)}if(t.layout===`map-only`&&t.scalePreserved&&(!t.outScale||t.outScale===n.scale)&&l===96&&(!u||!d)&&n.state.extent.equals(n.extent)&&(s.area={x:0,y:0,width:n.width,height:n.height},u||--s.area.width,d||--s.area.height,!i.ssExtent)){let e=n.toMap(r(s.area.width,s.area.height));c.ymin=e.y,c.xmax=e.x,i.ssExtent=c}a.extent=c.clone()._normalize(!0).toJSON();let f=await n.takeScreenshot(s);return a.imageData=o(f.dataUrl)?.data,a}async function he(e,{layerView:t,printTemplate:n},r){return e.legendEnabled&&r.legendLayers.push({id:e.id}),B(e,await Z(t),n,r)}async function ge(e,t){if(e.legendEnabled)for(let n of e.sublayers)n.legendEnabled&&t.legendLayers.push({id:n.id});let n=(e=>({customParameters:e.customParameters,effect:e.effect,layerDefinition:e.layerDefinition,layerType:e.layerType,layers:e.layers,url:e.url}))(Q(e));if(K(n,e),Array.isArray(n.layers)){for(let e of n.layers)delete e.popupInfo;n.token&&n.layers.length>0&&(n.layers[n.layers.length-1].token=n.token,delete n.token)}return n}async function _e(e){let t=[],n=[];for(let t of e.map.allTables)t.type===`feature`&&!t.loaded&&n.push(t.load());n.length&&await Promise.allSettled(n);for(let n of e.map.allTables)if(n.type===`feature`&&n.loaded&&n.isTable&&n.source?.type===`feature-layer`){let e=(e=>({id:e.id,title:e.title,customParameters:e.customParameters,layerDefinition:{definitionExpression:e.layerDefinition?.definitionExpression},url:e.url}))(Q(n));K(e,n),t.push(e)}return t.length?t:void 0}function ve(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});let n=(e=>({layerType:e.layerType,customParameters:e.customParameters}))(Q(e));return K(n,e),n}async function ye(e,t,n){let r=t.layerView;if(e.serviceUrl&&e.styleUrl&&!r.spriteSourceChanged&&!r.styleChanged){let t=p(e.styleUrl,e.apiKey),r=p(e.serviceUrl,e.apiKey);if(!t&&!r||n.cimVersion!==`2.1.0`){let n={type:`VectorTileLayer`};return n.styleUrl=s(e.styleUrl),n.token=t,r!==t&&(n.additionalTokens=[{url:e.serviceUrl,token:r}]),n}}return G(e,t,n)}function be(e){let t={type:`WebTiledLayer`,urlTemplate:e.urlTemplate?.replaceAll("${",`{`),credits:e.copyright};return e.subDomains&&e.subDomains.length>0&&(t.subDomains=e.subDomains),t}async function xe(e,t,n){return parseFloat(n.cimVersion)<3.5?G(e,t,n):(e.legendEnabled&&n.legendLayers.push({id:e.id}),(e=>({layerType:e.layerType,layerDefinition:e.layerDefinition,url:e.url,wfsInfo:e.wfsInfo}))(Q(e,`web-map`)))}function Se(e,t){let n,r=[],i=e=>{e.visible&&(e.sublayers?e.sublayers.forEach(i):e.name&&r.unshift(e.name))};return e.sublayers&&e.sublayers.forEach(i),r.length&&(e.legendEnabled&&t.legendLayers.push({id:e.id,subLayerIds:r}),n={type:`wms`,customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,transparentBackground:e.imageTransparency,visibleLayers:r,url:s(e.url),version:e.version}),n}function Ce(e){let t=e.activeLayer;return{type:`wmts`,customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,format:t.imageFormat,layer:t.id,style:t.styleId,tileMatrixSet:t.tileMatrixSetId,url:s(e.url)}}function K(e,t){t.url&&(e.url=s(e.url||t.url),e.token=p(e.url,t.apiKey))}async function q(e,n){n.canvas||=document.createElement(`canvas`);let r=1024;n.canvas.width=r,n.canvas.height=r;let o=n.canvas.getContext(`2d`),s,c;if(e.path){let t=new Path2D(e.path);t.closePath(),o.fillStyle=Array.isArray(e.color)?`rgba(${e.color[0]},${e.color[1]},${e.color[2]},${e.color[3]/255})`:`rgb(0,0,0)`,o.fill(t);let n=re(o);if(!n)return null;o.clearRect(0,0,r,r);let a=i(e.size)/Math.max(n.width,n.height);o.scale(a,a);let l=r/a,u=l/2-n.width/2-n.x,d=l/2-n.height/2-n.y;if(o.translate(u,d),Array.isArray(e.color)&&o.fill(t),e.outline?.width&&Array.isArray(e.outline.color)){let r=e.outline;o.lineWidth=i(r.width)/a,o.lineJoin=`round`,o.strokeStyle=`rgba(${r.color[0]},${r.color[1]},${r.color[2]},${r.color[3]/255})`,o.stroke(t),n.width+=o.lineWidth,n.height+=o.lineWidth}n.width*=a,n.height*=a;let f=o.getImageData(r/2-n.width/2,r/2-n.height/2,Math.ceil(n.width),Math.ceil(n.height));s=f.width,c=f.height,o.canvas.width=s,o.canvas.height=c,o.putImageData(f,0,0)}else{let n=e.contentType===`image/svg+xml`?`data:image/svg+xml;base64,`+e.imageData:e.url,r=(await t(n,{responseType:`image`})).data;s=i(e.width),c=i(e.height),o.canvas.width=s,o.canvas.height=c,o.drawImage(r,0,0,o.canvas.width,o.canvas.height)}return{type:`esriPMS`,imageData:o.canvas.toDataURL(`image/png`).slice(22),angle:e.angle,contentType:`image/png`,height:a(c),width:a(s),xoffset:e.xoffset,yoffset:e.yoffset}}async function J(e,t){let n=e.type;if(n===`simple`&&$(e.symbol))e.symbol=await q(e.symbol,t)??{type:`esriSMS`,color:[0,0,0,0],size:0,style:`esriSMSSquare`};else if(n===`uniqueValue`){if($(e.defaultSymbol)&&(e.defaultSymbol=await q(e.defaultSymbol,t)),`uniqueValueInfos`in e&&e.uniqueValueInfos)for(let n of e.uniqueValueInfos)$(n.symbol)&&(n.symbol=await q(n.symbol,t));if(`uniqueValueGroups`in e&&e.uniqueValueGroups)for(let n of e.uniqueValueGroups)for(let e of n.classes)$(e.symbol)&&(e.symbol=await q(e.symbol,t))}else if(n===`classBreaks`){$(e.defaultSymbol)&&(e.defaultSymbol=await q(e.defaultSymbol,t));for(let n of e.classBreakInfos)$(n.symbol)&&(n.symbol=await q(n.symbol,t))}}async function Y(e){if(e?.type!==`styleSymbolReference`)return e;try{return(await ce.fromJSON(e).fetchSymbol())?.toJSON()??e}catch{return e}}async function X(e){if(e.type===`simple`&&e.symbol)e.symbol=await Y(e.symbol);else if(e.type===`uniqueValue`){if(e.defaultSymbol=await Y(e.defaultSymbol),`uniqueValueInfos`in e&&e.uniqueValueInfos)for(let t of e.uniqueValueInfos)t.symbol=await Y(t.symbol);if(`uniqueValueGroups`in e&&e.uniqueValueGroups)for(let t of e.uniqueValueGroups)for(let e of t.classes)e.symbol=await Y(e.symbol)}else if(e.type===`classBreaks`){e.defaultSymbol=await Y(e.defaultSymbol);for(let t of e.classBreakInfos)t.symbol=await Y(t.symbol)}}async function Z(e){return e.queryFeatures(e.createQuery()).then(e=>e.features)}function Q(e,t){return e.write({},{ignorePersistenceEnabled:!0,origin:t})??{}}function we(e){return e.gpMetadata?.executionType?T.fromJSON(e.gpMetadata.executionType):`sync`}function $(e){return e&&(e.path||e.contentType===`image/svg+xml`||e.url?.endsWith(`.svg`))}export{D as execute,N as getGpPrintParams,F as getGpServerUrl,k as getMode,O as getPrintCache,M as getTaskExecutionMode,j as getTaskInfo,A as getTaskInfos,E as printCacheMap};
2
+ import{id as e}from"../kernel.js";import t from"../request.js";import{JSONMap as n}from"../core/jsonMap.js";import{createScreenPoint as r,pt2px as i,px2pt as a}from"../core/screenUtils.js";import{dataComponents as o,normalize as s}from"../core/urlUtils.js";import c from"../geometry/Polygon.js";import{collectLabelingFields as l}from"../layers/support/fieldUtils.js";import{getFloorFilterClause as u}from"../layers/support/floorFilterUtils.js";import{getSizeRangeAtScale as d}from"../renderers/visualVariables/support/visualVariableUtils.js";import{asValidOptions as f,findToken as p}from"./utils.js";import{execute as m}from"./geoprocessor/execute.js";import{submitJob as h}from"./geoprocessor/submitJob.js";import{formatJsonMap as g}from"./support/fileFormat.js";import{toJSON as _}from"./support/layoutTemplate.js";import{getVisibleLayerViews as ee,isScreenshotRequired as te,isBingMapsLayer as ne,isBlendLayer as re,getCopyright as v,getSelectionSymbol as y,createPointLayer as b,getContextBoundingBox as ie,createPolygonLayer as ae,createPolylineLayer as oe,createMultipointLayer as se}from"./support/printTaskUtils.js";import x from"./support/PrintTemplate.js";import{toJSON as S}from"./support/reportTemplate.js";import ce from"../symbols/WebStyleSymbol.js";import le from"../views/support/HighlightOptions.js";const C={Feet:`ft`,Kilometers:`km`,Meters:`m`,Miles:`mi`},w=new n({esriFeet:`Feet`,esriKilometers:`Kilometers`,esriMeters:`Meters`,esriMiles:`Miles`}),T=new n({esriExecutionTypeSynchronous:`sync`,esriExecutionTypeAsynchronous:`async`}),E=new Map;async function D(e,t,n){let r=await N(t,await O(e,n));if(await k(e,n)===`sync`){let{results:t}=await m(e,r,void 0,n);return t?.[0]?.value}let i=await h(e,r,void 0,n);await i.waitForJobCompletion({interval:t.updateDelay});let{value:a}=await i.fetchResultData(`Output_File`,null,n);return a}async function O(e,n){let r=F(e),i=E.get(r)??{gpServerUrl:r,legendLayerNameMap:{},legendLayers:[],screenshotLayers:[]};return i.gpMetadata??=(await t(r,f({f:`json`},n))).data,i.cimVersion=i.gpMetadata.cimVersion,E.set(r,i),i}async function k(e,t){return Te(await O(e,t))}async function A(e,n){let r=await O(e,n),i=r.gpMetadata?.tasks,a=r.gpServerUrl;if(r.taskInfos)return r.taskInfos;let o=(await t(e,f({f:`json`},n))).data;r.taskInfos={ExportWebMap:o};let s=i?.filter(e=>e!==o.name)??[];return await Promise.all(s.map(async e=>{let i=(await t(`${a}/${e}`,f({f:`json`},n))).data,o=i.name.startsWith(`GetLayoutTemplatesInfo`)?`GetLayoutTemplatesInfo`:null;o&&(r.taskInfos[o]??=i)})),r.taskInfos}async function j(e,t,n){return(await A(e,n))[t]??null}async function M(e,t,n){let r=await j(e,t,n);return r?.executionType?T.fromJSON(r.executionType):`sync`}async function N(t,n){let r=t.template||new x;r.showLabels??=!0;let i;r.format===`pdf`&&(i={enablePdfAccessibility:!0});let a=_(r.layout),o=r.exportOptions;if(o){let e=o.dpi;if(i??={},i.dpi=e,a?.toLowerCase()===`map_only`||a===``){let{width:e,height:t}=o;i.outputSize=e!=null&&t!=null?[e,t]:void 0}}let s=r.layoutOptions,c;if(s){let e,t;s.scalebarUnit===`Miles`||s.scalebarUnit===`Kilometers`?(e=`Kilometers`,t=`Miles`):(s.scalebarUnit===`Meters`||s.scalebarUnit===`Feet`)&&(e=`Meters`,t=`Feet`),c={titleText:s.titleText,authorText:s.authorText,copyrightText:s.copyrightText,customTextElements:s.customTextElements,elementOverrides:s.elementOverrides,scaleBarOptions:e||t?{metricUnit:w.toJSON(e)??void 0,metricLabel:e?C[e]:void 0,nonMetricUnit:w.toJSON(t)??void 0,nonMetricLabel:t?C[t]:void 0}:void 0}}let l=await P(t,r,n);if(l.operationalLayers){let e=RegExp(`[\\u4E00-\\u9FFF\\u0E00-\\u0E7F\\u0900-\\u097F\\u3040-\\u309F\\u30A0-\\u30FF\\u31F0-\\u31FF]`),t=/[\u0600-\u06FF]/,n=n=>{let r=n.text,i=n.font,a=i?.family?.toLowerCase();r&&i&&(a===`arial`||a===`arial unicode ms`)&&(i.family=e.test(r)?`Arial Unicode MS`:`Arial`,i.style!==`normal`&&t.test(r)&&(i.family=`Arial Unicode MS`))};for(let e of l.operationalLayers)if(e.featureCollection?.layers)for(let t of e.featureCollection.layers){let e=t.layerDefinition?.drawingInfo?.renderer;if(e&&`symbol`in e&&e.symbol?.type===`esriTS`&&n(e.symbol),t.featureSet?.features)for(let e of t.featureSet.features){let t=e.symbol;t?.type===`esriTS`&&n(t)}}}let u=null;s?.legendLayers&&(u=s.legendLayers.filter(e=>!n.screenshotLayers.includes(e.layerId)).map(e=>{let t=e.layerId;n.legendLayerNameMap[t]=e.title;let r={id:t};if(e.subLayerIds){r.subLayerIds=e.subLayerIds;let t=e.dynamicLegend;t!=null&&(r.subLayerDynamicLegends=e.subLayerIds.map(()=>t))}return e.dynamicLegend!=null&&(r.dynamicLegend=e.dynamicLegend),r})),t.outSpatialReference&&(l.mapOptions.spatialReference=t.outSpatialReference.toJSON()),t.datumTransformations?.length&&(l.mapOptions.datumTransformations=t.datumTransformations.map(e=>e.toJSON())),l.exportOptions=i,l.layoutOptions={...c,legendOptions:{operationalLayers:u??n.legendLayers.slice()}},n.legendLayers.length=0,n.screenshotLayers.length=0,E.set(n.gpServerUrl,n);let d={Web_Map_as_JSON:JSON.stringify(l),Format:g.toJSON(r.format),Layout_Template:a,Report_Template:S(r.report)};if(r.layoutItem){delete d.Layout_Template;let t=r.layoutItem;await t.load(),t.access!==`public`&&e&&await e.getCredential(n.gpServerUrl),d.Layout_Item_ID=JSON.stringify({id:t.id})}if(r.reportItem){delete d.Report_Template;let t=r.reportItem;await t.load(),t.access!==`public`&&e&&await e.getCredential(n.gpServerUrl),d.Report_Item_ID=JSON.stringify({id:t.id})}return t.extraParameters&&Object.assign(d,t.extraParameters),d}async function P(e,t,n){let r=e.view,i=r.spatialReference,a={operationalLayers:await I(r,t,n),mapOptions:{extent:null,spatialReference:null,showAttribution:t.attributionVisible}};t.includeTables&&(a.tables=await ve(r));let o=e.extent||n.ssExtent||r.extent;if(i?.isWrappable&&(o=o.clone().shiftCentralMeridian(),i=o.spatialReference),a.mapOptions={extent:o&&o.toJSON(),spatialReference:i&&i.toJSON(),showAttribution:t.attributionVisible},n.ssExtent=null,r.background&&(a.background=r.background.toJSON()),r.rotation&&(a.mapOptions.rotation=-r.rotation),t.scalePreserved&&(a.mapOptions.scale=t.outScale||r.scale),r.timeExtent!=null){let e=r.timeExtent.start==null?null:r.timeExtent.start.getTime(),t=r.timeExtent.end==null?null:r.timeExtent.end.getTime();a.mapOptions.time=[e,t]}return t.reportOptions&&(a.reportOptions=t.reportOptions),a}function F(e){let t=e,n=t.lastIndexOf(`/GPServer/`);return n>0&&(t=t.slice(0,n+9)),t}async function I(e,t,n){let r=[],i=0;t.scalePreserved&&(i=t.outScale||e.scale);let a={layerView:null,outScale:i,printTemplate:t,view:e},o=ee(e,i);for(let e of o){let t=e.layer;if(!t.loaded||`layers`in t)continue;let i;a.layerView=e,i=te(e)?await G(t,a,n):ne(t)?L(t):t?.type===`csv`?await z(t,a,n):t?.type===`catalog-footprint`?await R(t,a,n):t?.type===`feature`?await V(t,a,n):t?.type===`geojson`?await H(t,a,n):t?.type===`graphics`?await U(t,a,n):t?.type===`imagery`?W(t,n):t?.type===`imagery-tile`?await ue(t,a,n):t?.type===`kml`?await de(t,a,n):t?.type===`map-image`?fe(t,a,n):t?.type===`map-notes`?await pe(a,n):t?.type===`open-street-map`?me():t?.type===`sketch`?await he(t,a,n):t?.type===`stream`?await ge(t,a,n):t?.type===`subtype-group`?await _e(t,n):t?.type===`tile`?ye(t,n):t?.type===`vector-tile`?await be(t,a,n):t?.type===`web-tile`?xe(t):t?.type===`wfs`?await Se(t,a,n):t?.type===`wms`?Ce(t,n):t?.type===`wmts`?we(t):await G(t,a,n),i&&(Array.isArray(i)?r.push(...i):(i.id=t.id,i.title=n.legendLayerNameMap[t.id]||t.title,i.opacity=e.fullOpacity,i.minScale=t.minScale||0,i.maxScale=t.maxScale||0,re(t)&&t.blendMode&&t.blendMode!==`normal`&&(i.blendMode=t.blendMode),r.push(i)))}if(i)for(let e of r)e.minScale=0,e.maxScale=0;if(e.graphics?.length){let i=await B(null,e.graphics,t,n);i&&r.push(i)}return r}function L(e){return{culture:e.culture,key:e.key,type:`BingMaps${e.style===`aerial`?`Aerial`:e.style===`hybrid`?`Hybrid`:`Road`}`}}async function R(e,{layerView:t,printTemplate:n},r){if(parseFloat(r.cimVersion)<3.1)return B(e,await Z(t),n,r);let i=e.parent,{id:a,url:o,layerType:s,customParameters:c,footprintLayer:l,layerDefinition:u}=Q(i,`web-map`),d={id:a,url:o,layerType:s,customParameters:c,dynamicGroupLayer:{visibility:!1},footprintLayer:l,layerDefinition:u};return K(d,i),d}async function z(e,t,n){e.legendEnabled&&n.legendLayers.push({id:e.id});let r=t.layerView,i=t.printTemplate;if(!r.filter&&(!e.portalItem||e.portalItem.access===`public`)){let t=Q(e,`web-map`);return t.type=`CSV`,delete t.popupInfo,delete t.layerType,t.showLabels=i.showLabels&&e.labelsVisible,t}return B(e,await Z(r),i,n)}async function B(e,t,n,r){let i,a=ae(),o=oe(),s=b(),u=se(),d=b();if(d.layerDefinition.name=`textLayer`,delete d.layerDefinition.drawingInfo,e){if((e.type===`feature`||e.type===`stream`)&&(a.layerDefinition.name=o.layerDefinition.name=s.layerDefinition.name=u.layerDefinition.name=r.legendLayerNameMap[e.id]||e.title||void 0),`renderer`in e&&e.renderer){let t=e.renderer.toJSON(),n=a.layerDefinition.drawingInfo;n&&(n.renderer=t);let r=o.layerDefinition.drawingInfo;r&&(r.renderer=t);let i=s.layerDefinition.drawingInfo;i&&(i.renderer=t);let c=u.layerDefinition.drawingInfo;c&&(c.renderer=t)}if(n.showLabels&&`labelsVisible`in e&&e.labelsVisible&&`write`in e){let t=Q(e).layerDefinition?.drawingInfo?.labelingInfo;if(t){i=!0;let e=a.layerDefinition.drawingInfo;e&&(e.labelingInfo=t);let n=o.layerDefinition.drawingInfo;n&&(n.labelingInfo=t);let r=s.layerDefinition.drawingInfo;r&&(r.labelingInfo=t);let c=u.layerDefinition.drawingInfo;c&&(c.labelingInfo=t)}}}!(e&&`renderer`in e&&e.renderer)&&!i&&(delete a.layerDefinition.drawingInfo,delete o.layerDefinition.drawingInfo,delete s.layerDefinition.drawingInfo,delete u.layerDefinition.drawingInfo);let f,p=e&&`fieldsIndex`in e?e.fieldsIndex:void 0,m=e&&`renderer`in e?e.renderer:null;if(p){let t=new Set;i&&e&&`fieldsIndex`in e&&await l(t,e),m&&typeof m.collectRequiredFields==`function`&&await m.collectRequiredFields(t,p),f=Array.from(t);let n=p.fields.map(e=>e.toJSON());a.layerDefinition.fields=n,o.layerDefinition.fields=n,s.layerDefinition.fields=n,u.layerDefinition.fields=n}for(let e of t??[]){let t=e.geometry;if(e.visible===!1||!t)continue;let i=e.toJSON();if(Object.hasOwn(i,`popupTemplate`)&&delete i.popupTemplate,i.geometry&&`z`in i.geometry&&i.geometry.z&&delete i.geometry.z,i.symbol){if(`angle`in i.symbol&&!i.symbol.angle){let e=i.symbol;delete e.angle}$(i.symbol)?i.symbol=await q(i.symbol,r):`text`in i.symbol&&i.symbol.text&&delete i.attributes}if((!n||!n.forceFeatureAttributes)&&f?.length){let e={};for(let t of f)i.attributes&&Object.hasOwn(i.attributes,t)&&(e[t]=i.attributes[t]);i.attributes=e}let l=i;t.type===`polygon`?a.featureSet.features.push(l):t.type===`polyline`?o.featureSet.features.push(l):t.type===`point`?i.symbol&&`text`in i.symbol&&i.symbol.text?d.featureSet.features.push(l):s.featureSet.features.push(l):t.type===`multipoint`?u.featureSet.features.push(l):t.type===`extent`&&(i.geometry=c.fromExtent(t).toJSON(),a.featureSet.features.push(l))}let h=[a,o,u,s,d].filter(e=>e.featureSet.features.length>0);for(let e of h){let t=e.featureSet.features.every(e=>`symbol`in e&&e.symbol);if(t&&(!n||!n.forceFeatureAttributes))for(let t of e.featureSet.features)delete t.attributes;t&&delete e.layerDefinition.drawingInfo,e.layerDefinition.drawingInfo?.renderer&&(await X(e.layerDefinition.drawingInfo.renderer),await J(e.layerDefinition.drawingInfo.renderer,r))}return h.length?{featureCollection:{layers:h},showLabels:i}:null}async function V(e,t,n){let r=e.renderer,i=parseFloat(n.cimVersion);if(e.featureReduction?.type===`binning`||e.featureReduction?.type===`cluster`&&(i<2.9||e.featureReduction.renderer?.type===`pie-chart`)||r?.type===`pie-chart`&&i<3.1||r?.type===`dot-density`&&i<2.6||e.geometryType===`polygon`&&r?.authoringInfo?.visualVariables?.some(e=>e.theme===`spike`))return G(e,t,n);e.legendEnabled&&n.legendLayers.push({id:e.id});let a=t.layerView,{printTemplate:o,view:s}=t,c=e.source?.type!==`feature-layer`&&e.source?.type!==`ogc-feature`;if(!a.filter&&!c&&r&&(!(`field`in r)||r.field==null||e.getField(r.field))){let{id:t,title:i,url:c,layerType:l,customParameters:f,layerDefinition:p,charts:m}=Q(e),h={id:t,title:i,url:c,layerType:l,customParameters:f,layerDefinition:p,charts:o.includeCharts?m:void 0};o.attributionVisible&&(h.credits=v(e)),h.showLabels=o.showLabels&&e.labelsVisible&&!!e.labelingInfo&&e.labelingInfo.length>0,K(h,e);let g=h.layerDefinition?.featureReduction;if(delete g?.disablePopup,delete g?.popupInfo,a.displayFilterEnabled||delete h.layerDefinition?.displayFilterInfo,h.layerDefinition?.drawingInfo?.renderer&&(delete h.layerDefinition.minScale,delete h.layerDefinition.maxScale,await X(h.layerDefinition.drawingInfo.renderer),await J(h.layerDefinition.drawingInfo.renderer,n),`visualVariables`in r&&r.visualVariables?.[0])){let e=r.visualVariables[0];if(e.type===`size`&&e.maxSize&&typeof e.maxSize!=`number`&&e.minSize&&typeof e.minSize!=`number`){let t=d(e,s.scale),n=h.layerDefinition.drawingInfo.renderer;if(`visualVariables`in n&&n.visualVariables?.[0]?.type===`sizeInfo`){let e=n.visualVariables[0];e.minSize=t.minSize,e.maxSize=t.maxSize}}}let _=u(a);if(_&&(h.layerDefinition??={},h.layerDefinition.definitionExpression=h.layerDefinition.definitionExpression?`(${h.layerDefinition.definitionExpression}) AND (${_})`:_),e.gdbVersion&&(h.layerDefinition??={},h.layerDefinition.gdbVersion=e.gdbVersion),a.hasHighlight&&`highlightIds`in a){let t=a;h.selectionObjectIds=t.highlightIds;let n=t.highlightOptions??s.defaultHighlight??new le;h.selectionSymbol=y(e.geometryType,n)}return h}return B(e,await Z(a),o,n)}async function H(e,t,n){return e.featureReduction?.type===`binning`||e.featureReduction?.type===`cluster`?G(e,t,n):(e.legendEnabled&&n.legendLayers.push({id:e.id}),B(e,await Z(t.layerView),t.printTemplate,n))}async function U(e,{printTemplate:t},n){return B(e,e.graphics,t,n)}function W(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});let{layerType:n,customParameters:r}=Q(e),i={layerType:n,customParameters:r};return i.bandIds=e.bandIds,i.compressionQuality=e.compressionQuality,i.format=e.format,i.interpolation=e.interpolation,(e.mosaicRule||e.definitionExpression)&&(i.mosaicRule=e.exportImageServiceParameters.mosaicRule.toJSON()),e.rasterFunction&&(i.renderingRule=e.rasterFunction.toJSON()),e.renderer&&(i.layerDefinition??={},i.layerDefinition.drawingInfo??={},i.layerDefinition.drawingInfo.renderer=e.renderer.toJSON()),K(i,e),i}async function ue(e,t,n){if(e.renderer?.type===`flow`||!e.supportsWrite())return G(e,t,n);e.legendEnabled&&n.legendLayers.push({id:e.id});let{bandIds:r,customParameters:i,interpolation:a,layerDefinition:o}=Q(e),s={bandIds:r,customParameters:i,interpolation:a,layerDefinition:o};return s.layerType=`ArcGISImageServiceLayer`,K(s,e),s}async function de(e,t,n){let r=t.printTemplate;if(!e.portalItem||e.portalItem.access===`public`){let t=Q(e,`web-map`);return t.type=`kml`,delete t.layerType,t.url=s(e.url),t}let i=[],a=t.layerView;a.allVisibleMapImages.forEach((t,n)=>{let r={id:`${e.id}_image${n}`,type:`image`,title:e.id,minScale:e.minScale||0,maxScale:e.maxScale||0,opacity:a.fullOpacity,extent:t.extent};t.href.startsWith(`data:image/png;base64,`)?r.imageData=t.href.slice(22):r.url=t.href,i.push(r)});let o=[...a.allVisiblePoints.items,...a.allVisiblePolylines.items,...a.allVisiblePolygons.items],c={id:e.id,...await B(null,o,r,n)};return i.push(c),i}function fe(e,{outScale:t,printTemplate:n,view:r},i){let a={id:e.id,subLayerIds:[]},o=[],s=t||r.scale,c=e=>{let t=s===0,n=e.minScale===0||s<=e.minScale,r=e.maxScale===0||s>=e.maxScale;if(e.visible&&(t||n&&r)){if(e.sublayers)e.sublayers.forEach(c);else{let t=e.toExportImageJSON(),n={id:e.id,name:e.title,layerDefinition:{definitionExpression:t.definitionExpression,drawingInfo:t.drawingInfo,orderBy:t.orderBy,source:t.source}};o.unshift(n),a.subLayerIds.push(e.id)}}};if(e.sublayers?.forEach(c),o.length){o=o.map(({id:e,name:t,layerDefinition:n})=>({id:e,name:t,layerDefinition:n}));let{layerType:t,customParameters:r}=Q(e),s={layerType:t,customParameters:r};return s.layers=o,s.visibleLayers=e.capabilities?.exportMap?.supportsDynamicLayers?void 0:a.subLayerIds,n.attributionVisible&&(s.credits=v(e)),e.gdbVersion&&(s.gdbVersion=e.gdbVersion),K(s,e),e.legendEnabled&&i.legendLayers.push(a),s}}async function pe({layerView:e,printTemplate:t},n){let r=[],i=e.layer;if(i.featureCollections!=null)for(let e of i.featureCollections){let i=await B(e,e.source?.type===`memory`?e.source.items:[],t,n);i&&r.push(...i.featureCollection.layers)}else if(i.sublayers!=null)for(let e of i.sublayers){let i=await B(null,e.graphics,t,n);i&&r.push(...i.featureCollection.layers)}return{featureCollection:{layers:r}}}function me(){return{type:`OpenStreetMap`}}async function he(e,{printTemplate:t},n){let r=[];if(e.featureCollections!=null)for(let i of e.featureCollections){let e=await B(i,i.source?.type===`memory`?i.source.items:[],t,n);e&&r.push(...e.featureCollection.layers)}else{let i=await B(null,e.graphics,t,n);i&&r.push(...i.featureCollection.layers)}return{featureCollection:{layers:r}}}async function G(e,{printTemplate:t,view:n},i){i.screenshotLayers.push(e.id);let a={format:`png`,ignoreBackground:!0,ignorePadding:!0,layers:[e]};n.rotation!==0&&(a.rotation=0);let s=i.ssExtent||n.state.extent.clone(),c=96,l=!0,u=!0;if(t.exportOptions){let e=t.exportOptions;e.dpi!=null&&e.dpi>0&&(c=e.dpi),e.width!=null&&e.width>0&&(l=e.width%2==n.width%2),e.height!=null&&e.height>0&&(u=e.height%2==n.height%2)}if(t.layout===`map-only`&&t.scalePreserved&&(!t.outScale||t.outScale===n.scale)&&c===96&&(!l||!u)&&n.state.extent.equals(n.extent)&&(a.area={x:0,y:0,width:n.width,height:n.height},l||--a.area.width,u||--a.area.height,!i.ssExtent)){let e=n.toMap(r(a.area.width,a.area.height));s.ymin=e.y,s.xmax=e.x,i.ssExtent=s}let d=s.clone().shiftCentralMeridian().toJSON(),f=await n.takeScreenshot(a);return{type:`image`,extent:d,imageData:o(f.dataUrl)?.data}}async function ge(e,{layerView:t,printTemplate:n},r){return e.legendEnabled&&r.legendLayers.push({id:e.id}),B(e,await Z(t),n,r)}async function _e(e,t){if(e.legendEnabled)for(let n of e.sublayers)n.legendEnabled&&t.legendLayers.push({id:n.id});let{customParameters:n,effect:r,layerDefinition:i,layerType:a,layers:o,url:s}=Q(e),c={customParameters:n,effect:r,layerDefinition:i,layerType:a,layers:o,url:s};if(K(c,e),Array.isArray(c.layers)){for(let e of c.layers)delete e.popupInfo;c.token&&c.layers.length>0&&(c.layers[c.layers.length-1].token=c.token,delete c.token)}return c}async function ve(e){let t=[],n=[];for(let t of e.map.allTables)t.type===`feature`&&!t.loaded&&n.push(t.load());n.length&&await Promise.allSettled(n);for(let n of e.map.allTables)if(n.type===`feature`&&n.loaded&&n.isTable&&n.source?.type===`feature-layer`){let{id:e,title:r,customParameters:i,layerDefinition:a,url:o}=Q(n),s={id:e,title:r,customParameters:i,layerDefinition:{definitionExpression:a?.definitionExpression},url:o};K(s,n),t.push(s)}return t.length?t:void 0}function ye(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});let{layerType:n,customParameters:r}=Q(e),i={layerType:n,customParameters:r};return K(i,e),i}async function be(e,t,n){let r=t.layerView;if(e.serviceUrl&&e.styleUrl&&!r.spriteSourceChanged&&!r.styleChanged){let t=p(e.styleUrl,e.apiKey),r=p(e.serviceUrl,e.apiKey);if(!t&&!r||n.cimVersion!==`2.1.0`){let n={type:`VectorTileLayer`};return n.styleUrl=s(e.styleUrl),n.token=t,r!==t&&(n.additionalTokens=[{url:e.serviceUrl,token:r}]),n}}return G(e,t,n)}function xe(e){let t={type:`WebTiledLayer`,urlTemplate:e.urlTemplate?.replaceAll("${",`{`),credits:e.copyright};return e.subDomains&&e.subDomains.length>0&&(t.subDomains=e.subDomains),t}async function Se(e,t,n){if(parseFloat(n.cimVersion)<3.5)return G(e,t,n);e.legendEnabled&&n.legendLayers.push({id:e.id});let{layerType:r,layerDefinition:i,url:a,wfsInfo:o}=Q(e,`web-map`);return{layerType:r,layerDefinition:i,url:a,wfsInfo:o}}function Ce(e,t){let n=[],r=e=>{e.visible&&(e.sublayers?e.sublayers.forEach(r):e.name&&n.unshift(e.name))};if(e.sublayers?.forEach(r),n.length)return e.legendEnabled&&t.legendLayers.push({id:e.id,subLayerIds:n}),{type:`wms`,customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,transparentBackground:e.imageTransparency,visibleLayers:n,url:s(e.url),version:e.version}}function we(e){let t=e.activeLayer;return{type:`wmts`,customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,format:t.imageFormat,layer:t.id,style:t.styleId,tileMatrixSet:t.tileMatrixSetId,url:s(e.url)}}function K(e,t){if(!t.url)return;let n=typeof e.url==`string`&&e.url?e.url:t.url,r=s(n);e.url=r,e.token=p(r,t.apiKey)}async function q(e,n){let r=n.canvas??=document.createElement(`canvas`),o=1024;r.width=o,r.height=o;let s=r.getContext(`2d`),c,l;if(e.type===`esriSMS`){if(!e.path)return null;let t=new Path2D(e.path);t.closePath(),s.fillStyle=Array.isArray(e.color)?`rgba(${e.color[0]},${e.color[1]},${e.color[2]},${e.color[3]/255})`:`rgb(0,0,0)`,s.fill(t);let n=ie(s);if(!n)return null;s.clearRect(0,0,o,o);let r=i(e.size)/Math.max(n.width,n.height);s.scale(r,r);let a=o/r,u=a/2-n.width/2-n.x,d=a/2-n.height/2-n.y;if(s.translate(u,d),Array.isArray(e.color)&&s.fill(t),e.outline?.width&&Array.isArray(e.outline.color)){let a=e.outline;s.lineWidth=i(a.width)/r,s.lineJoin=`round`,s.strokeStyle=`rgba(${a.color[0]},${a.color[1]},${a.color[2]},${a.color[3]/255})`,s.stroke(t),n.width+=s.lineWidth,n.height+=s.lineWidth}n.width*=r,n.height*=r;let f=s.getImageData(o/2-n.width/2,o/2-n.height/2,Math.ceil(n.width),Math.ceil(n.height));c=f.width,l=f.height,s.canvas.width=c,s.canvas.height=l,s.putImageData(f,0,0)}else{let n=e.contentType===`image/svg+xml`?`data:image/svg+xml;base64,`+e.imageData:e.url,r=(await t(n,{responseType:`image`})).data;c=i(e.width),l=i(e.height),s.canvas.width=c,s.canvas.height=l,s.drawImage(r,0,0,s.canvas.width,s.canvas.height)}return{type:`esriPMS`,imageData:s.canvas.toDataURL(`image/png`).slice(22),angle:e.angle,contentType:`image/png`,height:a(l),width:a(c),xoffset:e.xoffset,yoffset:e.yoffset}}async function J(e,t){let n=e.type;if(n===`simple`&&$(e.symbol))e.symbol=await q(e.symbol,t)??{type:`esriSMS`,color:[0,0,0,0],size:0,style:`esriSMSSquare`};else if(n===`uniqueValue`){if($(e.defaultSymbol)&&(e.defaultSymbol=await q(e.defaultSymbol,t)),`uniqueValueInfos`in e&&e.uniqueValueInfos)for(let n of e.uniqueValueInfos)$(n.symbol)&&(n.symbol=await q(n.symbol,t));if(`uniqueValueGroups`in e&&e.uniqueValueGroups)for(let n of e.uniqueValueGroups)for(let e of n.classes)$(e.symbol)&&(e.symbol=await q(e.symbol,t))}else if(n===`classBreaks`){$(e.defaultSymbol)&&(e.defaultSymbol=await q(e.defaultSymbol,t));for(let n of e.classBreakInfos)$(n.symbol)&&(n.symbol=await q(n.symbol,t))}}async function Y(e){if(e?.type!==`styleSymbolReference`)return e;try{return(await ce.fromJSON(e).fetchSymbol())?.toJSON()??e}catch{return e}}async function X(e){if(e.type===`simple`&&e.symbol)e.symbol=await Y(e.symbol);else if(e.type===`uniqueValue`){if(e.defaultSymbol=await Y(e.defaultSymbol),`uniqueValueInfos`in e&&e.uniqueValueInfos)for(let t of e.uniqueValueInfos)t.symbol=await Y(t.symbol);if(`uniqueValueGroups`in e&&e.uniqueValueGroups)for(let t of e.uniqueValueGroups)for(let e of t.classes)e.symbol=await Y(e.symbol)}else if(e.type===`classBreaks`){e.defaultSymbol=await Y(e.defaultSymbol);for(let t of e.classBreakInfos)t.symbol=await Y(t.symbol)}}async function Z(e){return e.queryFeatures(e.createQuery()).then(e=>e.features)}function Q(e,t){return e.write({},{ignorePersistenceEnabled:!0,origin:t})??{}}function Te(e){return e.gpMetadata?.executionType?T.fromJSON(e.gpMetadata.executionType):`sync`}function $(e){return e?.type===`esriSMS`&&`path`in e&&!!e.path||(e?.type===`esriPMS`||e?.type===`esriPFS`)&&(`contentType`in e&&e.contentType===`image/svg+xml`||`url`in e&&!!e.url?.endsWith(`.svg`))}export{D as execute,N as getGpPrintParams,F as getGpServerUrl,k as getMode,O as getPrintCache,M as getTaskExecutionMode,j as getTaskInfo,A as getTaskInfos,E as printCacheMap};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import has from"../../../../../core/has.js";import{destroyMaybe as e}from"../../../../../core/maybe.js";import{notDeepEqual as t}from"../../../../../core/object.js";import{ignoreAbortErrors as n,throwIfNotAbortError as r}from"../../../../../core/promiseUtils.js";import{OptimizedFeature as i}from"../../../../../layers/graphics/OptimizedFeature.js";import{QueryEngine as a}from"../../../../../layers/graphics/data/QueryEngine.js";import{FeatureStoreStatistics as o}from"../FeatureStoreStatistics.js";import{StreamMessenger as s}from"./StreamMessenger.js";import{UpdateStatus as c}from"./strategies/ALoadStrategy.js";import{FeatureDrillDownTileLoadStrategy as l}from"./strategies/FeatureDrillDownTileLoadStrategy.js";import{FeatureHybridTileLoadStrategy as u}from"./strategies/FeatureHybridTileLoadStrategy.js";import{FeaturePagedTileLoadStrategy as d}from"./strategies/FeaturePagedTileLoadStrategy.js";import{FeatureSnapshotLoadStrategy as f}from"./strategies/FeatureSnapshotLoadStrategy.js";import{ParquetSnapshotLoadStrategy as p}from"./strategies/ParquetSnapshotLoadStrategy.js";import{ParquetTileLoadStrategy as m}from"./strategies/ParquetTileLoadStrategy.js";import{StreamLoadStrategy as h}from"./strategies/StreamLoadStrategy.js";import{FeatureSourceChunkStore as g}from"./strategies/chunks/SourceChunkStore.js";import _ from"../support/FeatureFilterEvaluator.js";import{UpdateTracking2D as v}from"../../support/UpdateTracking2D.js";class y{constructor(e,t,n){this._aggregateAdapter=e,this._subscriptions=t,this._connection=n,this._updateTracking=new v({debugName:`FeatureSource`}),this._filters=[],this.store=new g}destroy(){this._strategy?.destroy(),this._streamMessenger?.destroy(),this._updateTracking?.destroy(),this.store.destroy()}get metadata(){return this._strategy.metadata}get streamMessenger(){return this._streamMessenger??this._initStreamMessenger(),this._streamMessenger}get statistics(){return o.from(this.store)}get updateTracking(){return this._updateTracking}get usedMemory(){return this.store.usedMemory}get queryEngine(){if(!this._queryEngine){if(!this.store||!this._strategy)return null;this._queryEngine=new a({featureStore:this.store,fieldsIndex:this.metadata.fieldsIndex,geometryType:this.metadata.geometryType,featureIdInfo:this.metadata.featureIdInfo,hasZ:this.metadata.hasZ,hasM:this.metadata.hasM,spatialReference:this.metadata.outSpatialReference,aggregateAdapter:this._aggregateAdapter,timeInfo:this.metadata.timeInfo,definitionExpression:this._strategy?.definitionExpression,availableFields:this._strategy?.availableFields})}return this._queryEngine}get isStream(){return this._schema.type===`stream`}get hasQueryDisplayFilter(){if(!this._schema)return!1;switch(this._schema.type){case`feature`:return this._schema.strategy.full.displayFilterInfo!=null;case`parquet`:return this._schema.strategy.type===`xz`&&this._schema.strategy.full.displayFilterInfo!=null;case`stream`:return!1}}chunks(){return Array.from(this.store.chunks())}async applyCacheUpdate(){this.hasQueryDisplayFilter&&await this._updateTracking.addPromise(this._strategy.applyCacheUpdate())}cleanup(){return this.store.cleanup()}onSubscribe(e){if(this._connection.onEvent({type:`subscribe`,tile:e.tile.id}),!this._strategy)return;let t=this._strategy.load(e);t.then(()=>this._connection.onEvent({type:`loaded`,tile:e.tile.id})).catch(t=>this._connection.onEvent({type:`error`,tile:e.tile.id,error:t})),this._updateTracking.consumePromise(t)}onResume(e){this._updateTracking.consumePromise(n(this._strategy?.load(e)))}onUnsubscribe(e){this._connection.onEvent({type:`unsubscribe`,tile:e.tile.id}),this._strategy?.unload(e)}async applyOverride(e){await this._strategy?.applyOverride(e)}takeOverrideUpdate(){return this._strategy?.takeOverrideUpdate()}async update(n,r,i){let a=this._schema,o=this._getCachedObjectIds(this._filters),s=this._getCachedObjectIds(r);if(this._schema=n,this._filters=r,this._queryEngine=e(this._queryEngine),a&&a.type!==n.type)throw Error(`InternalError: Reconfiguring source types is not supported.`);let l=new c;if(!a||t(a.service,n.service)||a.strategy.type!==n.strategy.type||t(n.strategy.full,a.strategy.full)||!await this._strategy.tryUpdate(l,n.strategy.partial)){await this._updateStrategyType(this._schema.service,n,i);let e=null;return`postQueryFilter`in this._schema.strategy.full&&this._schema.strategy.full.postQueryFilter&&(e=await _.create({geometryType:this.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:this.metadata.timeInfo,fieldsIndex:this.metadata.fieldsIndex,spatialReference:this.metadata.outSpatialReference,filterJSON:this._schema.strategy.full.postQueryFilter})),await this.store.update({metadata:this.metadata,definitionExpression:this._schema.strategy.full.definitionExpression,postQueryFilter:e}),!0}return this._updateFilterCache(o,s),l.requiresInvalidation}unsafeSetQueryHistoricMoment(e){this._schema.type===`feature`&&(this._schema.strategy.full.historicMoment=e,this._strategy.unsafeSetQueryHistoricMoment(new Date(e)))}_initStreamMessenger(){this._streamMessenger??=new s(this._connection)}async normalizeOverrides(e){let t={historicMoment:e.historicMoment,commands:{updateWeak:e.commands.updateWeak.map(i.fromJSON),removeWeak:e.commands.removeWeak,update:e.commands.update.map(i.fromJSON),remove:e.commands.remove,release:e.commands.release}},n=e.commands.updateByIdWeak,r=await this._queryOptimizedFeatures(n);if(r.length!==n.length){let e=new Set(r.map(e=>e.objectId));for(let r of n)e.has(r)||t.commands.removeWeak.push(r)}return t.commands.updateWeak.push(...r),t}async _queryOptimizedFeatures(e){if(e.length===0)return[];let t=[],n=(await this._strategy.queryByObjectId(e,[`*`])).getCursor();for(;n.next();)t.push(n.readOptimizedFeatureWorldSpace());return t}getObjectIdsFromGlobalIds(e){let t=this.metadata.globalIdField;if(t==null)throw Error(`InternalError: Recieved an edit with globalIds, but not supported by the service`);let n=this.store.mapObjectIdsFromGlobalIds(e,t).values();return Array.from(n)}_getCachedObjectIds(e){let t=new Set;for(let{ensureCached:n,filters:r}of e)if(n)for(let e of r)for(let n of e.objectIds??[])t.add(n);return t}_updateFilterCache(e,t){if(!this.hasQueryDisplayFilter)return;let n=new Set,r=new Set;for(let r of t)e.has(r)||n.add(r);for(let n of e)t.has(n)||r.add(n);this._strategy.prepareCacheUpdate(n,r)}async _updateStrategyType(e,t,n){let i=this._createStrategy(e,t);this._connection.onEvent({type:`updateStrategyStart`,about:i.about});let a=!!this._strategy;this.store.clear(),this._strategy?.destroy(),this._strategy=i,has(`esri-2d-update-debug`)&&console.debug(`Version[${n}] FeatureSource.updateStrategy`,{strategy:i});let o=Array.from(this._subscriptions.values());if(!o.length){this._connection.onEvent({type:`updateStrategyEnd`});return}let s=Promise.all(o.map(e=>this._strategy.load(e).then(()=>this._connection.onEvent({type:`loaded`,tile:e.tile.id})).catch(t=>this._connection.onEvent({type:`error`,tile:e.tile.id,error:t}))));this._updateTracking.consumePromise(s),this._strategy.prepareCacheUpdate(this._getCachedObjectIds(this._filters));try{a&&await s}catch(e){r(e)}this._connection.onEvent({type:`updateStrategyEnd`}),has(`esri-2d-update-debug`)&&console.debug(`Version[${n}] FeatureSource.updateStrategyEnd`,{strategy:i})}_createStrategy(e,t){let n={connection:this._connection,store:this.store};switch(t.type){case`feature`:return this._createFeatureLoadStrategy(e,t.strategy,n);case`parquet`:return this._createParquetLoadStrategy(e,t.strategy,n);case`stream`:return this._createStreamLoadStrategy(e,t.strategy,n)}}_createFeatureLoadStrategy(e,t,n){switch(t.type){case`drill-down`:return new l(e,t,n);case`hybrid-tile`:return new u(e,t,n);case`paged-tile`:return new d(e,t,n);case`snapshot`:return new f(e,t,n)}}_createParquetLoadStrategy(e,t,n){switch(t.type){case`xz`:return new m(e,t,n,this._connection);case`snapshot`:return new p(e,t,n,this._connection)}}_createStreamLoadStrategy(e,t,n){let r=new h(e,t,n);return this.streamMessenger.strategy=r,r}}export{y as FeatureSource};
2
+ import has from"../../../../../core/has.js";import{destroyMaybe as e}from"../../../../../core/maybe.js";import{notDeepEqual as t}from"../../../../../core/object.js";import{ignoreAbortErrors as n,throwIfNotAbortError as r}from"../../../../../core/promiseUtils.js";import{OptimizedFeature as i}from"../../../../../layers/graphics/OptimizedFeature.js";import{QueryEngine as a}from"../../../../../layers/graphics/data/QueryEngine.js";import{FeatureStoreStatistics as o}from"../FeatureStoreStatistics.js";import{StreamMessenger as s}from"./StreamMessenger.js";import{UpdateStatus as c}from"./strategies/ALoadStrategy.js";import{FeatureDrillDownTileLoadStrategy as l}from"./strategies/FeatureDrillDownTileLoadStrategy.js";import{FeatureHybridTileLoadStrategy as u}from"./strategies/FeatureHybridTileLoadStrategy.js";import{FeaturePagedTileLoadStrategy as d}from"./strategies/FeaturePagedTileLoadStrategy.js";import{FeatureSnapshotLoadStrategy as f}from"./strategies/FeatureSnapshotLoadStrategy.js";import{ParquetSnapshotLoadStrategy as p}from"./strategies/ParquetSnapshotLoadStrategy.js";import{ParquetTileLoadStrategy as m}from"./strategies/ParquetTileLoadStrategy.js";import{StreamLoadStrategy as h}from"./strategies/StreamLoadStrategy.js";import{FeatureSourceChunkStore as g}from"./strategies/chunks/SourceChunkStore.js";import _ from"../support/FeatureFilterEvaluator.js";import{UpdateTracking2D as v}from"../../support/UpdateTracking2D.js";class y{constructor(e,t,n){this._aggregateAdapter=e,this._subscriptions=t,this._connection=n,this._updateTracking=new v({debugName:`FeatureSource`}),this._filters=[],this.store=new g}destroy(){this._strategy?.destroy(),this._streamMessenger?.destroy(),this._updateTracking?.destroy(),this.store.destroy()}get metadata(){return this._strategy.metadata}get streamMessenger(){return this._streamMessenger??this._initStreamMessenger(),this._streamMessenger}get statistics(){return o.from(this.store)}get updateTracking(){return this._updateTracking}get usedMemory(){return this.store.usedMemory}get queryEngine(){if(!this._queryEngine){if(!this.store||!this._strategy)return null;this._queryEngine=new a({featureStore:this.store,fieldsIndex:this.metadata.fieldsIndex,geometryType:this.metadata.geometryType,featureIdInfo:this.metadata.featureIdInfo,hasZ:this.metadata.hasZ,hasM:this.metadata.hasM,spatialReference:this.metadata.outSpatialReference,aggregateAdapter:this._aggregateAdapter,timeInfo:this.metadata.timeInfo,definitionExpression:this._strategy?.definitionExpression,availableFields:this._strategy?.availableFields})}return this._queryEngine}get isStream(){return this._schema.type===`stream`}get hasQueryDisplayFilter(){if(!this._schema)return!1;switch(this._schema.type){case`feature`:return this._schema.strategy.full.displayFilterInfo!=null;case`parquet`:return this._schema.strategy.type===`xz`&&this._schema.strategy.full.displayFilterInfo!=null;case`stream`:return!1}}chunks(){return Array.from(this.store.chunks())}async applyCacheUpdate(){this.hasQueryDisplayFilter&&await this._updateTracking.addPromise(this._strategy.applyCacheUpdate())}cleanup(){return this.store.cleanup()}onSubscribe(e){if(this._connection.onEvent({type:`subscribe`,tile:e.tile.id}),!this._strategy)return;let t=this._strategy.load(e);t.then(()=>this._connection.onEvent({type:`loaded`,tile:e.tile.id})).catch(t=>this._connection.onEvent({type:`error`,tile:e.tile.id,error:t})),this._updateTracking.consumePromise(t)}onResume(e){this._updateTracking.consumePromise(n(this._strategy?.load(e)))}onUnsubscribe(e){this._connection.onEvent({type:`unsubscribe`,tile:e.tile.id}),this._strategy?.unload(e)}async applyOverride(e){await this._strategy?.applyOverride(e)}takeOverrideUpdate(){return this._strategy?.takeOverrideUpdate()}async update(n,r,i){let a=this._schema,o=this._getCachedObjectIds(this._filters),s=this._getCachedObjectIds(r);if(this._schema=n,this._filters=r,a&&a.type!==n.type)throw Error(`InternalError: Reconfiguring source types is not supported.`);let l=new c;if(!a||t(a.service,n.service)||a.strategy.type!==n.strategy.type||t(n.strategy.full,a.strategy.full)||!await this._strategy.tryUpdate(l,n.strategy.partial)){await this._updateStrategyType(this._schema.service,n,i);let t=null;return`postQueryFilter`in this._schema.strategy.full&&this._schema.strategy.full.postQueryFilter&&(t=await _.create({geometryType:this.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:this.metadata.timeInfo,fieldsIndex:this.metadata.fieldsIndex,spatialReference:this.metadata.outSpatialReference,filterJSON:this._schema.strategy.full.postQueryFilter})),await this.store.update({metadata:this.metadata,definitionExpression:this._schema.strategy.full.definitionExpression,postQueryFilter:t}),this._queryEngine=e(this._queryEngine),!0}return this._updateFilterCache(o,s),this._queryEngine=e(this._queryEngine),l.requiresInvalidation}unsafeSetQueryHistoricMoment(e){this._schema.type===`feature`&&(this._schema.strategy.full.historicMoment=e,this._strategy.unsafeSetQueryHistoricMoment(new Date(e)))}_initStreamMessenger(){this._streamMessenger??=new s(this._connection)}async normalizeOverrides(e){let t={historicMoment:e.historicMoment,commands:{updateWeak:e.commands.updateWeak.map(i.fromJSON),removeWeak:e.commands.removeWeak,update:e.commands.update.map(i.fromJSON),remove:e.commands.remove,release:e.commands.release}},n=e.commands.updateByIdWeak,r=await this._queryOptimizedFeatures(n);if(r.length!==n.length){let e=new Set(r.map(e=>e.objectId));for(let r of n)e.has(r)||t.commands.removeWeak.push(r)}return t.commands.updateWeak.push(...r),t}async _queryOptimizedFeatures(e){if(e.length===0)return[];let t=[],n=(await this._strategy.queryByObjectId(e,[`*`])).getCursor();for(;n.next();)t.push(n.readOptimizedFeatureWorldSpace());return t}getObjectIdsFromGlobalIds(e){let t=this.metadata.globalIdField;if(t==null)throw Error(`InternalError: Recieved an edit with globalIds, but not supported by the service`);let n=this.store.mapObjectIdsFromGlobalIds(e,t).values();return Array.from(n)}_getCachedObjectIds(e){let t=new Set;for(let{ensureCached:n,filters:r}of e)if(n)for(let e of r)for(let n of e.objectIds??[])t.add(n);return t}_updateFilterCache(e,t){if(!this.hasQueryDisplayFilter)return;let n=new Set,r=new Set;for(let r of t)e.has(r)||n.add(r);for(let n of e)t.has(n)||r.add(n);this._strategy.prepareCacheUpdate(n,r)}async _updateStrategyType(e,t,n){let i=this._createStrategy(e,t);this._connection.onEvent({type:`updateStrategyStart`,about:i.about});let a=!!this._strategy;this.store.clear(),this._strategy?.destroy(),this._strategy=i,has(`esri-2d-update-debug`)&&console.debug(`Version[${n}] FeatureSource.updateStrategy`,{strategy:i});let o=Array.from(this._subscriptions.values());if(!o.length){this._connection.onEvent({type:`updateStrategyEnd`});return}let s=Promise.all(o.map(e=>this._strategy.load(e).then(()=>this._connection.onEvent({type:`loaded`,tile:e.tile.id})).catch(t=>this._connection.onEvent({type:`error`,tile:e.tile.id,error:t}))));this._updateTracking.consumePromise(s),this._strategy.prepareCacheUpdate(this._getCachedObjectIds(this._filters));try{a&&await s}catch(e){r(e)}this._connection.onEvent({type:`updateStrategyEnd`}),has(`esri-2d-update-debug`)&&console.debug(`Version[${n}] FeatureSource.updateStrategyEnd`,{strategy:i})}_createStrategy(e,t){let n={connection:this._connection,store:this.store};switch(t.type){case`feature`:return this._createFeatureLoadStrategy(e,t.strategy,n);case`parquet`:return this._createParquetLoadStrategy(e,t.strategy,n);case`stream`:return this._createStreamLoadStrategy(e,t.strategy,n)}}_createFeatureLoadStrategy(e,t,n){switch(t.type){case`drill-down`:return new l(e,t,n);case`hybrid-tile`:return new u(e,t,n);case`paged-tile`:return new d(e,t,n);case`snapshot`:return new f(e,t,n)}}_createParquetLoadStrategy(e,t,n){switch(t.type){case`xz`:return new m(e,t,n,this._connection);case`snapshot`:return new p(e,t,n,this._connection)}}_createStreamLoadStrategy(e,t,n){let r=new h(e,t,n);return this.streamMessenger.strategy=r,r}}export{y as FeatureSource};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{createTask as n}from"../../../../core/asyncUtils.js";import{makeHandle as r}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{clamp as i,roundToNearest as a,roundUpToNearest as o}from"../../../../core/mathUtils.js";import{removeMaybe as s,abortMaybe as c}from"../../../../core/maybe.js";import{throwIfAborted as l}from"../../../../core/promiseUtils.js";import{initial as u}from"../../../../core/reactiveUtils.js";import{createScreenPoint as d}from"../../../../core/screenUtils.js";import{throttle as f}from"../../../../core/throttle.js";import{convertTime as p}from"../../../../core/timeUtils.js";import{property as m,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as g}from"../../../../core/support/UpdatingHandles.js";import{formatDuration as _}from"../../../../intl/duration.js";import{onLocaleChange as v,prefersRTL as y}from"../../../../intl/locale.js";import{fetchMessageBundle as b}from"../../../../intl/messages.js";import{substitute as x}from"../../../../intl/substitute.js";let S=class extends t{constructor(e){super(e),this.throttleDelay=N,this._tooltipElement=C(),this._tooltipContentElement=w(),this._updatingHandles=new g,this._messagesTask=null,this._screenPoint=null,this._shadowDurationTask=null,this.shadowDuration=null,this._throttledUpdateShadowDuration=null,this._onPointerMove=({x:e,y:t})=>{let n=d(e,t);this._screenPoint=n,this._throttledUpdateShadowDuration?.(this.view,n)},this._updateShadowDuration=(e,t)=>{this._abortShadowDurationTask(),this._shadowDurationTask=n(async n=>{let{results:r,ground:i}=await e.hitTest(t);if(l(n),r.length===0&&!i.mapPoint){this.shadowDuration=null;return}let a=await this.getDuration(t,n);l(n),this.shadowDuration=a<0?null:a})}}initialize(){this._tooltipElement.appendChild(this._tooltipContentElement);let e=()=>{this._messagesTask?.abort(),this._messagesTask=n(()=>b(`esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis`))};e(),this.addHandles([v(e),this._updatingHandles.add(()=>({enabled:this.isVisible(),surface:this.view.surface}),({enabled:e,surface:t})=>{e&&t?(t.appendChild(this._tooltipElement),this._startTracking(this.view)):(this.removeHandles(j),this._tooltipElement.remove())},u),this._updatingHandles.add(()=>this._styles,e=>{Object.assign(this._tooltipElement.style,e)},u),this._updatingHandles.add(()=>this._formattedText,e=>{this._tooltipContentElement.innerText=e},u),this._updatingHandles.add(()=>this.throttleDelay,e=>{this._throttledUpdateShadowDuration=f(this._updateShadowDuration,e)},u),r(()=>{this._throttledUpdateShadowDuration=s(this._throttledUpdateShadowDuration)})])}destroy(){this._updatingHandles.destroy(),this._tooltipElement.remove()}get updating(){return this._updatingHandles.updating||this._shadowDurationTask!=null&&!this._shadowDurationTask?.finished||this._messagesTask!=null&&!this._messagesTask?.finished||this._throttledUpdateShadowDuration?.hasPendingUpdates()===!0}get _formattedText(){let e=this._messagesTask?.value,t=this.shadowDuration;return e==null||t==null?``:this.getMode()===`total-duration`&&this.getTotalDurationMode()===`hourly`?this._formatHourlyText(e,t):this._formatExactText(e,t)}_formatExactText(e,t){return x(this.getVisualizeSunlight()?e.sunlightDuration:e.shadowDuration,{duration:D(A(t))})}_formatHourlyText(e,t){let n=this.getTotalDuration();if(n<=0)return this._formatExactText(e,0);let r=this.getVisualizeSunlight(),a=i(t,0,n);if(a===0&&this.getShowsSeparateZeroBucketInHourlyMode())return x(r?e.sunlightDuration:e.shadowDuration,{duration:D(0)});let o=k(a,n),s=O(o,Math.min(n,o+I));if(o===0){let t=r?e.sunlightDurationLessThan:e.shadowDurationLessThan;return x(t,{duration:s})}let c=r?e.sunlightDurationRange:e.shadowDurationRange;return x(c,{minDuration:D(o),maxDuration:s})}get _styles(){let e=this._screenPoint;return e&&this._formattedText?{display:`block`,transform:`translate(${e.x}px, ${e.y}px)`}:{display:`none`}}get testData(){}_startTracking(e){if(this.hasHandles(j))return;let t=t=>{this.hasHandles(M)||(t&&this._onPointerMove(t),this.addHandles(e.on(`pointer-move`,this._onPointerMove),M))},n=()=>{this.removeHandles(M),this._abortShadowDurationTask(),this._screenPoint=null,this.shadowDuration=null};this.addHandles([e.on(`pointer-enter`,t),e.on(`pointer-leave`,n),e.on(`pointer-down`,n),e.on(`pointer-up`,t),e.on(`pointer-drag`,e=>{e.action===`end`?t(e):n()}),e.on(`click`,t=>{let n=d(t.x,t.y);this._screenPoint=n,this._updateShadowDuration(e,n)}),r(()=>this._abortShadowDurationTask())],j),t()}_abortShadowDurationTask(){this._shadowDurationTask=c(this._shadowDurationTask)}};e([m()],S.prototype,`view`,void 0),e([m()],S.prototype,`isVisible`,void 0),e([m()],S.prototype,`getDuration`,void 0),e([m()],S.prototype,`getMode`,void 0),e([m()],S.prototype,`getShowsSeparateZeroBucketInHourlyMode`,void 0),e([m()],S.prototype,`getTotalDurationMode`,void 0),e([m()],S.prototype,`getTotalDuration`,void 0),e([m()],S.prototype,`throttleDelay`,void 0),e([m()],S.prototype,`updating`,null),e([m()],S.prototype,`getVisualizeSunlight`,void 0),e([m()],S.prototype,`_messagesTask`,void 0),e([m()],S.prototype,`_screenPoint`,void 0),e([m()],S.prototype,`_shadowDurationTask`,void 0),e([m()],S.prototype,`shadowDuration`,void 0),e([m()],S.prototype,`_throttledUpdateShadowDuration`,void 0),e([m()],S.prototype,`_formattedText`,null),e([m()],S.prototype,`_styles`,null),S=e([h(`esri.views.3d.analysis.ShadowCast.ShadowCastTooltip`)],S);function C(){let e=E(document.createElement(`div`),{position:`absolute`,top:`0`,left:`0`,pointerEvents:`none`});return e.style.setProperty(`--tooltip-arrow-size`,`6px`),e.style.setProperty(`--tooltip-background`,`var(--calcite-color-foreground-1)`),e.appendChild(T()),e}function w(){return E(document.createElement(`div`),{color:`var(--calcite-color-text-1)`,fontSize:`var(--calcite-font-size-sm)`,position:`absolute`,width:`max-content`,transform:`translate(0, -100%)`,insetInlineStart:`calc(var(--calcite-spacing-lg) * -1)`,marginTop:`calc((var(--tooltip-arrow-size) * -1) - var(--calcite-spacing-xxs))`,background:`var(--tooltip-background)`,paddingInline:`var(--calcite-spacing-md)`,paddingBlock:`var(--calcite-spacing-xs)`,pointerEvents:`none`,borderRadius:`var(--calcite-corner-radius-sm)`})}function T(){return E(document.createElement(`div`),{display:`block`,position:`absolute`,width:`0`,height:`0`,bottom:`-1px`,left:`50%`,transform:`translate(-50%, 0)`,borderTop:`var(--tooltip-arrow-size) solid var(--tooltip-background)`,borderRight:`var(--tooltip-arrow-size) solid transparent`,borderBottom:`var(--tooltip-arrow-size) solid transparent`,borderLeft:`var(--tooltip-arrow-size) solid transparent`,pointerEvents:`none`})}function E(e,t){return Object.assign(e.style,t),e}function D(e){let t=_(e,void 0,{unitDisplay:`narrow`});return y()?`${L}${t}${R}`:t}function O(e,t){return D(e+A(Math.max(0,t-e)))}function k(e,t){if(e<=0)return 0;let n=o(e,I);return i(n-I,0,t)}function A(e){let t=e<F?a(e,P):a(e,F);return e>0&&t===0?P:t}const j=Symbol(`tracking`),M=Symbol(`pointer`),N=300,P=p(1,`minutes`,`milliseconds`),F=p(15,`minutes`,`milliseconds`),I=p(1,`hours`,`milliseconds`),L=`⁨`,R=`⁩`;export{S as ShadowCastTooltip};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{createTask as n}from"../../../../core/asyncUtils.js";import{makeHandle as r}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{clamp as i,roundToNearest as a,roundUpToNearest as o}from"../../../../core/mathUtils.js";import{removeMaybe as s,abortMaybe as c}from"../../../../core/maybe.js";import{throwIfAborted as l}from"../../../../core/promiseUtils.js";import{initial as u}from"../../../../core/reactiveUtils.js";import{createScreenPoint as d}from"../../../../core/screenUtils.js";import{throttle as f}from"../../../../core/throttle.js";import{convertTime as p}from"../../../../core/timeUtils.js";import{property as m,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as g}from"../../../../core/support/UpdatingHandles.js";import{formatDuration as _}from"../../../../intl/duration.js";import{onLocaleChange as v,prefersRTL as y}from"../../../../intl/locale.js";import{fetchMessageBundle as b}from"../../../../intl/messages.js";import{substitute as x}from"../../../../intl/substitute.js";let S=class extends t{constructor(e){super(e),this.throttleDelay=N,this._tooltipElement=C(),this._tooltipContentElement=w(),this._updatingHandles=new g,this._messagesTask=null,this._screenPoint=null,this._shadowDurationTask=null,this.shadowDuration=null,this._throttledUpdateShadowDuration=null,this._onPointerMove=({x:e,y:t})=>{let n=d(e,t);this._screenPoint=n,this._throttledUpdateShadowDuration?.(this.view,n)},this._updateShadowDuration=(e,t)=>{this._abortShadowDurationTask(),this._shadowDurationTask=n(async n=>{let{results:r,ground:i}=await e.hitTest(t);if(l(n),r.length===0&&!i.mapPoint){this.shadowDuration=null;return}let a=await this.getDuration(t,n);l(n),this.shadowDuration=a<0?null:a})}}initialize(){this._tooltipElement.appendChild(this._tooltipContentElement);let e=()=>{this._messagesTask?.abort(),this._messagesTask=n(()=>b(`esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis`))};e(),this.addHandles([v(e),this._updatingHandles.add(()=>({enabled:this.isVisible(),surface:this.view.surface}),({enabled:e,surface:t})=>{e&&t?(t.appendChild(this._tooltipElement),this._startTracking(this.view)):(this.removeHandles(j),this._tooltipElement.remove())},u),this._updatingHandles.add(()=>this._styles,e=>{Object.assign(this._tooltipElement.style,e)},u),this._updatingHandles.add(()=>this._formattedText,e=>{this._tooltipContentElement.innerText=e},u),this._updatingHandles.add(()=>this.throttleDelay,e=>{this._throttledUpdateShadowDuration=f(this._updateShadowDuration,e)},u),r(()=>{this._throttledUpdateShadowDuration=s(this._throttledUpdateShadowDuration)})])}destroy(){this._updatingHandles.destroy(),this._tooltipElement.remove()}get updating(){return this._updatingHandles.updating||this._shadowDurationTask!=null&&!this._shadowDurationTask?.finished||this._messagesTask!=null&&!this._messagesTask?.finished||this._throttledUpdateShadowDuration?.hasPendingUpdates()===!0}get _formattedText(){let e=this._messagesTask?.value,t=this.shadowDuration;return e==null||t==null?``:this.getMode()===`total-duration`&&this.getTotalDurationMode()===`hourly`?this._formatHourlyText(e,t):this._formatExactText(e,t)}_formatExactText(e,t){return x(this.getVisualizeSunlight()?e.sunlightDuration:e.shadowDuration,{duration:D(A(t))})}_formatHourlyText(e,t){let n=this.getTotalDuration();if(n<=0)return this._formatExactText(e,0);let r=this.getVisualizeSunlight(),a=i(t,0,n);if(a===0&&this.getShowsSeparateZeroBucketInHourlyMode())return x(r?e.sunlightDuration:e.shadowDuration,{duration:D(0)});let o=k(a,n),s=O(o,Math.min(n,o+I));if(o===0){let t=r?e.sunlightDurationLessThan:e.shadowDurationLessThan;return x(t,{duration:s})}let c=r?e.sunlightDurationRange:e.shadowDurationRange;return x(c,{minDuration:D(o),maxDuration:s})}get _styles(){let e=this._screenPoint;return e&&this._formattedText?{display:`block`,transform:`translate(${e.x}px, ${e.y}px)`}:{display:`none`}}get testData(){}_startTracking(e){if(this.hasHandles(j))return;let t=t=>{this.hasHandles(M)||(t&&this._onPointerMove(t),this.addHandles(e.on(`pointer-move`,this._onPointerMove),M))},n=()=>{this.removeHandles(M),this._abortShadowDurationTask(),this._screenPoint=null,this.shadowDuration=null};this.addHandles([e.on(`pointer-enter`,t),e.on(`pointer-leave`,n),e.on(`pointer-down`,n),e.on(`pointer-up`,t),e.on(`pointer-drag`,e=>{e.action===`end`?t(e):n()}),e.on(`click`,t=>{let n=d(t.x,t.y);this._screenPoint=n,this._updateShadowDuration(e,n)}),r(()=>this._abortShadowDurationTask())],j),t()}_abortShadowDurationTask(){this._shadowDurationTask=c(this._shadowDurationTask)}};e([m()],S.prototype,`view`,void 0),e([m()],S.prototype,`isVisible`,void 0),e([m()],S.prototype,`getDuration`,void 0),e([m()],S.prototype,`getMode`,void 0),e([m()],S.prototype,`getShowsSeparateZeroBucketInHourlyMode`,void 0),e([m()],S.prototype,`getTotalDurationMode`,void 0),e([m()],S.prototype,`getTotalDuration`,void 0),e([m()],S.prototype,`throttleDelay`,void 0),e([m()],S.prototype,`updating`,null),e([m()],S.prototype,`getVisualizeSunlight`,void 0),e([m()],S.prototype,`_messagesTask`,void 0),e([m()],S.prototype,`_screenPoint`,void 0),e([m()],S.prototype,`_shadowDurationTask`,void 0),e([m()],S.prototype,`shadowDuration`,void 0),e([m()],S.prototype,`_throttledUpdateShadowDuration`,void 0),e([m()],S.prototype,`_formattedText`,null),e([m()],S.prototype,`_styles`,null),S=e([h(`esri.views.3d.analysis.ShadowCast.ShadowCastTooltip`)],S);function C(){let e=E(document.createElement(`div`),{position:`absolute`,top:`0`,left:`0`,pointerEvents:`none`});return e.style.setProperty(`--tooltip-arrow-size`,`6px`),e.style.setProperty(`--tooltip-background`,`var(--calcite-color-surface-2)`),e.appendChild(T()),e}function w(){return E(document.createElement(`div`),{color:`var(--calcite-color-text-1)`,fontSize:`var(--calcite-font-size-sm)`,position:`absolute`,width:`max-content`,transform:`translate(0, -100%)`,insetInlineStart:`calc(var(--calcite-space-lg) * -1)`,marginTop:`calc((var(--tooltip-arrow-size) * -1) - var(--calcite-space-2xs))`,background:`var(--tooltip-background)`,paddingInline:`var(--calcite-space-md)`,paddingBlock:`var(--calcite-space-xs)`,pointerEvents:`none`,borderRadius:`var(--calcite-corner-radius-sm)`})}function T(){return E(document.createElement(`div`),{display:`block`,position:`absolute`,width:`0`,height:`0`,bottom:`-1px`,left:`50%`,transform:`translate(-50%, 0)`,borderTop:`var(--tooltip-arrow-size) solid var(--tooltip-background)`,borderRight:`var(--tooltip-arrow-size) solid transparent`,borderBottom:`var(--tooltip-arrow-size) solid transparent`,borderLeft:`var(--tooltip-arrow-size) solid transparent`,pointerEvents:`none`})}function E(e,t){return Object.assign(e.style,t),e}function D(e){let t=_(e,void 0,{unitDisplay:`narrow`});return y()?`${L}${t}${R}`:t}function O(e,t){return D(e+A(Math.max(0,t-e)))}function k(e,t){if(e<=0)return 0;let n=o(e,I);return i(n-I,0,t)}function A(e){let t=e<F?a(e,P):a(e,F);return e>0&&t===0?P:t}const j=Symbol(`tracking`),M=Symbol(`pointer`),N=300,P=p(1,`minutes`,`milliseconds`),F=p(15,`minutes`,`milliseconds`),I=p(1,`hours`,`milliseconds`),L=`⁨`,R=`⁩`;export{S as ShadowCastTooltip};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{removeHandles as e,destroyHandle as t,refHandle as n}from"../../../../core/handleUtils.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{watch as i,initial as a}from"../../../../core/reactiveUtils.js";import{signal as o}from"../../../../core/signal.js";import{set as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectPointToVector as l}from"../../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as u}from"../../../../geometry/projection/projectVectorToVector.js";import{empty as d,getMin as f,create as p}from"../../../../geometry/support/aaBoundingBox.js";import{containsXY as m}from"../../../../geometry/support/aaBoundingRect.js";import{featureExpressionInfoIsZero as h}from"../../../../support/elevationInfoUtils.js";import{manipulatedObjectGeometry as g}from"./manipulatedObjectUtils.js";import{ManipulatorState as _}from"./ManipulatorState.js";import{Settings as v}from"./settings.js";import{ExtendedLineVisualElement as y}from"../visualElements/ExtendedLineVisualElement.js";import{LaserlineVisualElement as b}from"../visualElements/LaserlineVisualElement.js";import{PointVisualElement as x}from"../visualElements/PointVisualElement.js";import{evaluateElevationAlignmentAtPoint as S}from"../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as C}from"../../layers/graphics/ElevationContext.js";function w(t){let n=[],r=E(t,n);return T(t,n,r),{visualElement:r,remove:()=>e(n)}}function T(e,n,c){let{view:l,object:p}=e,m=new v({getTheme:()=>l.effectiveTheme}),x=new y({view:l,extensionType:m.visualElements.zVerticalLine.extensionType,innerWidth:1,attached:!1,writeDepthEnabled:!1,renderOccluded:4,isDecoration:!0});n.push(i(()=>m.visualElements.zVerticalLine,e=>e.apply(x),a));let w=new b({view:l,intersectsLineInfinite:!0,attached:!1,isDecoration:!0}),T=r(m.visualElements.heightPlaneAngleCutoff),E=new b({view:l,attached:!1,angleCutoff:T,isDecoration:!0}),O=p.elevationInfo,k=C.fromElevationInfo(O),A=O.mode===`on-the-ground`||!O.offset&&O.mode!==`absolute-height`,N=new _,P=o(1);n.push(i(()=>({heightPlane:m.visualElements.heightPlane,alpha:P.value}),({heightPlane:e,alpha:t})=>e.apply(E,t),a));let F=o(1);n.push(i(()=>({shadowStyle:m.visualElements.pointObjects.shadowStyle,alpha:F.value}),({shadowStyle:e,alpha:t})=>e.apply(w,t),a));let I=()=>{N.update(e);let t=D(g(p)),n=A&&(p.isDraped||t==null||!t.hasZ),r=!0;if(!n&&t!=null){h(p.elevationInfo)&&(t=t.clone(),t.z=0);let e=S(t,l.elevationProvider,k,l.renderCoordsHelper);s(j,t.x,t.y,e),u(j,t.spatialReference,j,l.renderCoordsHelper.spatialReference),x.setStartEndFromWorldDownAtLocation(j),w.intersectsWorldUpAtLocation=j}else r=!1;let i=N.grabbingState&2?m.visualElements.laserlineAlphaMultiplier:1;P.value=i;let a=d(M);!n&&p.visible&&c.calculateMapBounds(a)&&u(f(a,j),l.spatialReference,j,l.renderCoordsHelper.spatialReference)?(E.heightManifoldTarget=j,E.attached=!0):E.attached=!1;let o=N.grabbingState&4?m.visualElements.laserlineAlphaMultiplier:1;F.value=o;let _=r&&p.visible&&!n;w.attached=_,x.attached=_};n.push(i(()=>[p.visible,p.isDraped],I),p.on(`committed`,I)),e.forEachManipulator(e=>{n.push(e.events.on(`grab-changed`,I))}),n.push(t(w)),n.push(t(x)),n.push(t(E)),I()}function E(e,n){let{view:r,object:i}=e,a=new x({view:r,geometry:D(g(i)),elevationInfo:i.elevationInfo,isDecoration:!0});return O(e,a,n),n.push(t(a)),a}function D(e){return e==null?null:e.type===`point`?e:e.type===`mesh`?e.origin.clone():null}function O(e,t,n){let{view:r,object:o}=e,s=()=>{t.attached=o.visible},c=new v({getTheme:()=>r.effectiveTheme});k(e,t,n),c.visualElements.pointObjects.outline.apply(t),n.push(i(()=>o.visible,s,a))}function k(e,t,r){let{view:i,object:a}=e,o=null,s=e=>{o!=null&&(o.remove(),o=null),a.isDraped&&e!=null&&(o=A(i,e,()=>{t.geometry=e}))},c=()=>{let e=D(g(a));e!=null&&h(a.elevationInfo)&&(e.z=0),s(e),t.geometry=e};r.push(a.on(`committed`,c),n(()=>o)),c()}function A(e,t,n){let r=e.elevationProvider.spatialReference;l(t,j,r);let i=j[0],a=j[1];return e.elevationProvider.on(`elevation-change`,e=>{m(e.extent,i,a)&&n()})}const j=c(),M=p();export{w as createVisualElements};
2
+ import{removeHandles as e,destroyHandle as t,refHandle as n}from"../../../../core/handleUtils.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{watch as i,initial as a}from"../../../../core/reactiveUtils.js";import{signal as o}from"../../../../core/signal.js";import{set as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectPointToVector as l}from"../../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as u}from"../../../../geometry/projection/projectVectorToVector.js";import{empty as d,getMin as f,create as p}from"../../../../geometry/support/aaBoundingBox.js";import{containsXY as m}from"../../../../geometry/support/aaBoundingRect.js";import{featureExpressionInfoIsZero as h}from"../../../../support/elevationInfoUtils.js";import{manipulatedObjectGeometry as g}from"./manipulatedObjectUtils.js";import{ManipulatorState as _}from"./ManipulatorState.js";import{Settings as v}from"./settings.js";import{ExtendedLineVisualElement as y}from"../visualElements/ExtendedLineVisualElement.js";import{LaserlineVisualElement as b}from"../visualElements/LaserlineVisualElement.js";import{PointVisualElement as x}from"../visualElements/PointVisualElement.js";import{evaluateElevationAlignmentAtPoint as S}from"../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as C}from"../../layers/graphics/ElevationContext.js";function w(t){let n=[],r=E(t,n);return T(t,n,r),{visualElement:r,remove:()=>e(n)}}function T(e,n,c){let{view:l,object:p}=e,m=new v({getTheme:()=>l.effectiveTheme}),x=new y({view:l,extensionType:m.visualElements.zVerticalLine.extensionType,innerWidth:1,attached:!1,writeDepthEnabled:!1,renderOccluded:4,isDecoration:!0});n.push(i(()=>m.visualElements.zVerticalLine,e=>e.apply(x),a));let w=new b({view:l,intersectsLineInfinite:!0,attached:!1,isDecoration:!0}),T=r(m.visualElements.heightPlaneAngleCutoff),E=new b({view:l,attached:!1,angleCutoff:T,isDecoration:!0}),O=p.elevationInfo,k=C.fromElevationInfo(O),A=O.mode===`on-the-ground`||!O.offset&&O.mode!==`absolute-height`,N=new _,P=o(1);n.push(i(()=>({heightPlane:m.visualElements.heightPlane,alpha:P.value}),({heightPlane:e,alpha:t})=>e.apply(E,t),a));let F=o(1);n.push(i(()=>({shadowStyle:m.visualElements.pointObjects.shadowStyle,alpha:F.value}),({shadowStyle:e,alpha:t})=>e.apply(w,t),a));let I=()=>{N.update(e);let t=D(g(p)),n=A&&(p.isDraped||t==null||!t.hasZ),r=!0;if(!n&&t!=null){h(p.elevationInfo)&&(t=t.clone(),t.z=0);let e=S(t,l.elevationProvider,k,l.renderCoordsHelper);s(j,t.x,t.y,e),u(j,t.spatialReference,j,l.renderCoordsHelper.spatialReference),x.setStartEndFromWorldDownAtLocation(j),w.intersectsWorldUpAtLocation=j}else r=!1;let i=N.grabbingState&2?m.visualElements.laserlineAlphaMultiplier:1;P.value=i;let a=d(M);!n&&p.visible&&c.calculateMapBounds(a)&&u(f(a,j),l.spatialReference,j,l.renderCoordsHelper.spatialReference)?(E.heightManifoldTarget=j,E.attached=!0):E.attached=!1;let o=N.grabbingState&4?m.visualElements.laserlineAlphaMultiplier:1;F.value=o;let _=r&&p.visible&&!n;w.attached=_,x.attached=_};n.push(i(()=>[p.visible,p.isDraped],I),p.on(`committed`,I),l.elevationProvider.on(`elevation-change`,I)),e.forEachManipulator(e=>{n.push(e.events.on(`grab-changed`,I))}),n.push(t(w)),n.push(t(x)),n.push(t(E)),I()}function E(e,n){let{view:r,object:i}=e,a=new x({view:r,geometry:D(g(i)),elevationInfo:i.elevationInfo,isDecoration:!0});return O(e,a,n),n.push(t(a)),a}function D(e){return e==null?null:e.type===`point`?e:e.type===`mesh`?e.origin.clone():null}function O(e,t,n){let{view:r,object:o}=e,s=()=>{t.attached=o.visible},c=new v({getTheme:()=>r.effectiveTheme});k(e,t,n),c.visualElements.pointObjects.outline.apply(t),n.push(i(()=>o.visible,s,a))}function k(e,t,r){let{view:i,object:a}=e,o=null,s=e=>{o!=null&&(o.remove(),o=null),a.isDraped&&e!=null&&(o=A(i,e,()=>{t.geometry=e}))},c=()=>{let e=D(g(a));e!=null&&h(a.elevationInfo)&&(e.z=0),s(e),t.geometry=e};r.push(a.on(`committed`,c),n(()=>o)),c()}function A(e,t,n){let r=e.elevationProvider.spatialReference;l(t,j,r);let i=j[0],a=j[1];return e.elevationProvider.on(`elevation-change`,e=>{m(e.extent,i,a)&&n()})}const j=c(),M=p();export{w as createVisualElements};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{lerp as n}from"../../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{property as i,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{transpose as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{transformMat4 as l,scale as u,round as d,copy as f,set as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as m,create as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as g,transformMat4 as _,scale as ee}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as y}from"../../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as b}from"../../../../geometry/ellipsoidUtils.js";import{create as x,empty as S,copy as C,offset as w,width as T,height as te,expand as ne}from"../../../../geometry/support/aaBoundingRect.js";import{h as re,c as E,a as D}from"../../../../chunks/boundedPlane.js";import{create as O}from"../../../../geometry/support/ray.js";import{Sphere as k,sphereCSO as A}from"../../../../geometry/support/sphere.js";import{InternalRenderCategory as j}from"../../webgl.js";import{DeconflictAABR as M}from"./DeconflictAABR.js";import{prepare as N,drawPoly as P}from"./deconflictorDebug.js";import{isSymbolLayerWithTransparencyMode as F}from"./transparencyUtils.js";import I from"../../webgl/RenderCamera.js";import{GPUPointOcclusionQuery as L}from"../../webgl-engine/lib/GPUPointOcclusionQuery.js";import{SeparateScreenSizePerspectiveEvaluators as R}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{HUDMaterial as z}from"../../webgl-engine/materials/HUDMaterial.js";import{Yield as B}from"../../../support/Yield.js";const V=h(),H=h(),U=v(),W=v(),G=h(),K=s(),q=new k,J=O(),Y=h(),X=x();class ie{constructor(e){this.id=e,this.aabr=x(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.culled=!1,this.visible=!1,this.priority=0}}function ae(e,t){let n=e.distanceToOccluder!==0&&e.distance>e.distanceToOccluder,r=t.distanceToOccluder!==0&&t.distance>t.distanceToOccluder;return n===r?e.priority===t.priority?e.distance===t.distance?e.visible===t.visible?e.id-t.id:+t.visible-e.visible:e.distance-t.distance:t.priority-e.priority:+n-r}class oe{constructor(e,t){this.graphics3DGraphic=e,this.slicePlaneEnabled=t,this._info=null,this._labelInfo=null}ensureInfo(e){let t=this.getInfo(e);return t||(t=new ie(this.graphics3DGraphic.graphic.uid),this._setInfo(e,t)),t}getInfo(e){return e===16?this._labelInfo:this._info}removeInfo(e){this._setInfo(e,null)}_setInfo(e,t){e===16?this._labelInfo=t:this._info=t}}class Z{constructor(){this.camera=new I,this.slicePlane=E(),this.slicePlaneEnabled=!1}copyFrom(e){this.camera.equals(e.camera)||this.camera.copyFrom(e.camera),D(e.slicePlane,this.slicePlane),this.slicePlaneEnabled=e.slicePlaneEnabled}}let Q=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(e){super(e),this._dirty=!1,this._viewState=new Z,this._state=0,this._checkOcclusion=new Map,this._active=new Map,this._checkOcclusionIterator=null,this._activeIterator=null,this._occlusionQueryUids=[],this._updatingHandles=new y,this._deconflictor=new M((e,t)=>{e.visible=t,this._setGraphicVisibility(this._active.get(e.id),t)},(e,t)=>e.id!==t.id,ae),this._baseOccludedVisibility=10,this._altitudeFactor=2,this._minAltitudeDifference=100}initialize(){this._updatingHandles.add(()=>(this.view?.map?.ground?.opacity??0)>0,()=>this.setDirty()),this._updatingHandles.add(()=>this.view.ready,()=>{this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this.setDirty()})}destroy(){this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this._updatingHandles.destroy(),this._deconflictor.destroy(),this._checkOcclusion.clear(),this._active.clear()}setDirty(){!this._dirty&&(this._active.size>0||this._checkOcclusion.size>0)&&(this._dirty=!0,this.notifyChange(`_readyToRun`))}setPriority(e,t){let n=this._active.get(e.graphic.uid)?.getInfo(this.visibilityGroup);n&&(n.priority=t)}get _readyToRun(){return this._state!==0||this._dirty}get updating(){return this._readyToRun||this._updatingHandles.updating}get updatingProgress(){if(!this.updating)return 1;let e=this._state/5;return this._dirty?e*.5:e}get readyToRun(){return this.view.ready&&this.view.state!=null&&this._readyToRun}get usedMemory(){return this._occlusionQuery?.usedMemory??0+(this._occlusionQueryUids?.length??0)*4}runTask(e){switch(this._state){case 0:this._startUpdate(),e.madeProgress();case 1:if(this._state=1,!this._processCheckOcclusion(e))return;case 2:if(this._state=2,!(this._occlusionQuery?.done??!0)||!(this._opaqueOcclusionQuery?.done??!0))return B;this._readOcclusionQueryResult(),e.madeProgress();case 3:if(this._state=3,!this._collectActiveGraphics(e))return;case 4:if(this._state=4,this._deconflictor.run(e),!this._deconflictor.done)return;default:this._state=0,this.notifyChange(`_readyToRun`)}}setGraphicsActive(e,t){t?e.forEach(e=>this.addToActiveGraphics(e)):e.forEach(e=>this.removeFromActiveGraphics(e))}isSupportedLayer(e){if(e==null||!(`hiddenIfDeconflicted`in e)||!e.hiddenIfDeconflicted)return!1;let t=e.stageObject;return(t?.geometries.length??0)===1&&t?.geometries[0]?.material instanceof z}_startUpdate(){N(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);let{fullWidth:e,fullHeight:t}=this._viewState.camera;this._deconflictor.reset(e,t),this._resetIterators(),this._occlusionQueryUids.length=0,!this._checkOcclusion.size&&(this._occlusionQuery=r(this._occlusionQuery),this._opaqueOcclusionQuery=r(this._opaqueOcclusionQuery))}addToActiveGraphics(e){e.ensureInfo(this.visibilityGroup),this._active.set(e.graphics3DGraphic.graphic.uid,e),this.setDirty()}removeFromActiveGraphics(e){this._active.get(e.graphics3DGraphic.graphic.uid)===e&&($(e,this.visibilityGroup),e.removeInfo(this.visibilityGroup),this._active.delete(e.graphics3DGraphic.graphic.uid),this.setDirty())}addToCheckOcclusion(e){this._checkOcclusion.set(e.graphics3DGraphic.graphic.uid,e),this.setDirty()}removeFromCheckOcclusion(e){this._checkOcclusion.get(e.graphics3DGraphic.graphic.uid)===e&&this._checkOcclusion.delete(e.graphics3DGraphic.graphic.uid)}_processCheckOcclusion(e){if(this._checkOcclusion.size===0)return!0;let t=this._ensureCheckOcclusionIterator(),n=this._viewState.camera,i=o(K,n.viewInverseTransposeMatrix),a=this.view.map.ground.opacity>0,s=this.view.viewingMode===`global`&&a&&n.relativeElevation>0?q:null,c=0;s!=null&&(l(s.center,m,n.viewMatrix),s.radius=b(this.view.spatialReference).radius,c=A.distanceToSilhouette(s,m));let u=x();for(;;){if(e.done)return!1;e.madeProgress();let r=t.next();if(r.done===!0)break;let a=r.value,o=a.graphics3DGraphic;if(o.destroyed||!o.isVisible(1,8))continue;let d=ue(o,this.visibilityGroup),f=null,p=!0,m=!1;for(let e of d){if(!this.isSupportedLayer(e))continue;f=de,this._projectHudLayer(e,n,f),S(u);let t=e.stageObject.geometries[0].material;if(this._expandBoundingRect(u,n,e,t,f),f.isOutsideScreen||this._isCulledBySlice(a,f.positionWorld)||s!=null&&le(f,s,c)){p=!1;break}f.altitude=this.view.renderCoordsHelper.getAltitude(f.positionWorld);let r=a.ensureInfo(this.visibilityGroup);if(r.altitude=f.altitude,r.distance=f.distance,r.distanceToOccluder=f.distanceToOccluder,r.culled=!1,C(r.aabr,u),!e.occlusionCheck)break;l(H,f.positionView,i);let d=this._ensureOcclusionQuery(),h=this._ensureOpaqueOcclusionQuery();this._occlusionQueryUids.length===0&&(this._initOcclusionQuery(d),this._initOcclusionQuery(h));let g=d.addPosition(H),_=h.addPosition(H);if(g===this._occlusionQueryUids.length&&_===g){let t=e.adaptiveOcclusion;this._occlusionQueryUids.push(t?-o.graphic.uid:o.graphic.uid),m=!0}break}let h=this._active.has(o.graphic.uid);if(!h&&!m)this._setGraphicVisibility(a,p);else if(h&&(!p||!f)){let e=a.ensureInfo(this.visibilityGroup);e.visible=!f,e.culled=!0}}return this._checkOcclusionIterator=null,this._occlusionQueryUids.length||(this._occlusionQuery=r(this._occlusionQuery),this._opaqueOcclusionQuery=r(this._opaqueOcclusionQuery)),this._occlusionQuery?.start(),this._opaqueOcclusionQuery?.start(),!0}_readOcclusionQueryResult(){if(!this._occlusionQuery||!this._occlusionQueryUids.length)return;let e=this._viewState.camera,t=this.view.renderCoordsHelper.getAltitude(e.eye);for(let e=0;e<this._occlusionQueryUids.length;e++){let n=this._occlusionQueryUids[e],r=Math.abs(n),i=n<0,a=this._checkOcclusion.get(r);if(!a)continue;let o=this._occlusionQuery.getOcclusion(e)??-1,s=this._opaqueOcclusionQuery?.getOcclusion(e)??-1,c=a.getInfo(this.visibilityGroup);c&&(c.distanceToOccluder=o>0?c.distance-o:0);let l=s===0||s>0&&this._occludedVisibility(c?c.distance-s:0,c?.distance??s,c?.altitude??0,t,i),u=o===0||o>0&&this._occludedVisibility(c?.distanceToOccluder??0,c?.distance??o,c?.altitude??0,t,i),d=l||u;d&&this._setTransparentMode(a,l&&!u),this._active.has(r)?c&&(c.culled=!d,c.visible=d):this._setGraphicVisibility(a,d)}this._occlusionQueryUids.length=0}_collectActiveGraphics(e){let t=this._ensureActiveGraphicsIterator(),n=this.visibilityGroup===16;for(;!e.done;){e.madeProgress();let r=t.next();if(r.done===!0)return this._activeIterator=null,!0;let i=r.value,a=i.getInfo(this.visibilityGroup);if(!a)continue;let o=!n||i.graphics3DGraphic.isVisible();!o||a.culled?(P(a.aabr,!1,!0),this._setGraphicVisibility(i,o&&a.visible)):this._deconflictor.add(a)}return!1}_occludedVisibility(e,t,n,r,i=!0){let a=Math.max(this._minAltitudeDifference,Math.abs(n-r))-this._minAltitudeDifference,o=i?this._baseOccludedVisibility+this._altitudeFactor*a:0;return e===0||t-e<=o}_resetIterators(){this._checkOcclusionIterator=null,this._activeIterator=null}_ensureCheckOcclusionIterator(){return this._checkOcclusionIterator??=this._checkOcclusion.values(),this._checkOcclusionIterator}_ensureActiveGraphicsIterator(){return this._activeIterator??=this._active.values(),this._activeIterator}_initOcclusionQuery(e){if(!e)return;let{camera:t}=this._viewState,n=Math.max(2,2+Math.round(Math.log2(Math.abs(t.relativeElevation))));u(V,this._viewState.camera.eye,2**-n),u(V,d(V,V),2**n),e.init(this._checkOcclusion.size,V)}_ensureOcclusionQuery(){return this._occlusionQuery??=new L({view:this.view}),this._occlusionQuery}_ensureOpaqueOcclusionQuery(){return this._opaqueOcclusionQuery??=new L({view:this.view,category:j.OPAQUE_OCCLUSION_QUERY}),this._opaqueOcclusionQuery}_getNumVisible(e){return this._checkOcclusion.values().reduce((t,n)=>t+ +!!n.getInfo(e)?.visible,0)}_projectHudLayer(e,t,n){let r=e.stageObject,i=r.geometries[0],a=i.material;f(H,r.boundingVolumeWorldSpace.sphere.center),l(V,H,t.viewMatrix);let o=i.attributes,s=o.get(`normal`).data,c=o.get(`centerOffset`)?.data??m,[d]=o.get(`groundDistance`).data;a.applyShaderOffsets(H,V,s,r.transformation,c,d,t,n.screenSizePerspectiveEvaluators),g(U,V[0],V[1],V[2],1),_(W,U,t.projectionMatrix),u(n.positionNDC,W,1/W[3]),a.applyShaderOffsetsNDC(n.positionNDC,c,d,t,n.positionNDC,G),n.distanceWithoutPolygonOffset=t.depthNDCToWorld(G[2]),n.distance=G[2]===n.positionNDC[2]?n.distanceWithoutPolygonOffset:t.depthNDCToWorld(n.positionNDC[2]),g(W,n.positionNDC[0],n.positionNDC[1],n.positionNDC[2],1),_(U,W,t.inverseProjectionMatrix),ee(U,U,1/U[3]),p(n.positionView,U[0],U[1],U[2]),f(n.positionWorld,H)}_isCulledBySlice(e,t){return e.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&re(this._viewState.slicePlane,t)}_expandBoundingRect(e,t,r,i,{positionNDC:a,screenSizePerspectiveEvaluators:o}){let s=r.getScreenSize(se);o.evaluator.applyVec2(s,s),s[0]*=t.pixelRatio,s[1]*=t.pixelRatio;let c=w(i.calculateRelativeScreenBounds(s,o.alignmentEvaluator.apply(t.pixelRatio),X),n(0,t.fullWidth,.5+.5*a[0]),n(0,t.fullHeight,.5+.5*a[1])),l=this.marginFactor;if(l!==0){let e=l*Math.min(T(c),te(c));c[0]-=e,c[1]-=e,c[2]+=e,c[3]+=e}ne(e,c,e)}_setGraphicVisibility(e,t){let n=e?.graphics3DGraphic;n&&!n.destroyed&&(n.setVisibilityFlag(this.visibilityGroup,8,t),this.visibilityGroup===16&&this.view.labeler.setLabelGraphicVisibility(n,t))}_setTransparentMode(e,t){let n=e?.graphics3DGraphic;if(n&&!n.destroyed)for(let e of n.layers){if(e?.type!==`object3d`)continue;let{graphics3DSymbolLayer:n}=e;F(n)&&n.updateTransparentMode(e,t)}}};e([i({constructOnly:!0})],Q.prototype,`view`,void 0),e([i({type:Boolean,readOnly:!0})],Q.prototype,`_readyToRun`,null),e([i({type:Boolean,readOnly:!0})],Q.prototype,`updating`,null),e([i({readOnly:!0})],Q.prototype,`_updatingHandles`,void 0),Q=e([a(`esri.views.3d.layers.graphics.Deconflictor`)],Q);function $(e,t){let n=e.graphics3DGraphic;n.destroyed||n.setVisibilityFlag(t,8,!0)}const se=c();class ce{constructor(){this.positionWorld=h(),this.positionView=h(),this.positionNDC=h(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.distanceWithoutPolygonOffset=0,this.screenSizePerspectiveEvaluators=new R}get isOutsideScreen(){let e=this.positionNDC;return e[0]<-1||e[1]<-1||e[2]<-1||e[0]>=1||e[1]>=1||e[2]>=1}}function le(e,t,n){return f(J.direction,e.positionView),p(J.origin,0,0,0),t.intersectRay(J,Y)?e.distanceWithoutPolygonOffset>n:!1}function ue(e,t){return t===16?e.labelLayers:e.layers}const de=new ce;export{Q as Deconflictor,oe as DeconflictorGraphic,Z as DeconflictorViewState};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{lerp as n}from"../../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{property as i,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{transpose as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{transformMat4 as l,scale as u,round as d,copy as f,set as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as m,create as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as g,transformMat4 as _,scale as v}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as y}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as b}from"../../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as ee}from"../../../../geometry/ellipsoidUtils.js";import{create as x,empty as te,copy as S,offset as C,width as w,height as ne,expand as T}from"../../../../geometry/support/aaBoundingRect.js";import{h as E,c as re,a as ie}from"../../../../chunks/boundedPlane.js";import{create as D}from"../../../../geometry/support/ray.js";import{Sphere as O,sphereCSO as k}from"../../../../geometry/support/sphere.js";import{InternalRenderCategory as A}from"../../webgl.js";import{DeconflictAABR as j}from"./DeconflictAABR.js";import{prepare as M,drawPoly as N}from"./deconflictorDebug.js";import{isSymbolLayerWithTransparencyMode as P}from"./transparencyUtils.js";import F from"../../webgl/RenderCamera.js";import{getVec3AttributeView as I,getScalarAttributeView as L}from"../../webgl-engine/lib/attributeViewUtils.js";import{GPUPointOcclusionQuery as R}from"../../webgl-engine/lib/GPUPointOcclusionQuery.js";import{SeparateScreenSizePerspectiveEvaluators as z}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{HUDMaterial as B}from"../../webgl-engine/materials/HUDMaterial.js";import{Yield as V}from"../../../support/Yield.js";const H=h(),U=h(),W=h(),G=h(),K=y(),q=y(),J=h(),Y=s(),ae=new O,X=D(),oe=h(),Z=x();class se{constructor(e){this.id=e,this.aabr=x(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.culled=!1,this.visible=!1,this.priority=0}}function ce(e,t){let n=e.distanceToOccluder!==0&&e.distance>e.distanceToOccluder,r=t.distanceToOccluder!==0&&t.distance>t.distanceToOccluder;return n===r?e.priority===t.priority?e.distance===t.distance?e.visible===t.visible?e.id-t.id:+t.visible-e.visible:e.distance-t.distance:t.priority-e.priority:+n-r}class le{constructor(e,t){this.graphics3DGraphic=e,this.slicePlaneEnabled=t,this._info=null,this._labelInfo=null}ensureInfo(e){let t=this.getInfo(e);return t||(t=new se(this.graphics3DGraphic.graphic.uid),this._setInfo(e,t)),t}getInfo(e){return e===16?this._labelInfo:this._info}removeInfo(e){this._setInfo(e,null)}_setInfo(e,t){e===16?this._labelInfo=t:this._info=t}}class Q{constructor(){this.camera=new F,this.slicePlane=re(),this.slicePlaneEnabled=!1}copyFrom(e){this.camera.equals(e.camera)||this.camera.copyFrom(e.camera),ie(e.slicePlane,this.slicePlane),this.slicePlaneEnabled=e.slicePlaneEnabled}}let $=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(e){super(e),this._dirty=!1,this._viewState=new Q,this._state=0,this._checkOcclusion=new Map,this._active=new Map,this._checkOcclusionIterator=null,this._activeIterator=null,this._occlusionQueryUids=[],this._updatingHandles=new b,this._deconflictor=new j((e,t)=>{e.visible=t,this._setGraphicVisibility(this._active.get(e.id),t)},(e,t)=>e.id!==t.id,ce),this._baseOccludedVisibility=10,this._altitudeFactor=2,this._minAltitudeDifference=100}initialize(){this._updatingHandles.add(()=>(this.view?.map?.ground?.opacity??0)>0,()=>this.setDirty()),this._updatingHandles.add(()=>this.view.ready,()=>{this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this.setDirty()})}destroy(){this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this._updatingHandles.destroy(),this._deconflictor.destroy(),this._checkOcclusion.clear(),this._active.clear()}setDirty(){!this._dirty&&(this._active.size>0||this._checkOcclusion.size>0)&&(this._dirty=!0,this.notifyChange(`_readyToRun`))}setPriority(e,t){let n=this._active.get(e.graphic.uid)?.getInfo(this.visibilityGroup);n&&(n.priority=t)}get _readyToRun(){return this._state!==0||this._dirty}get updating(){return this._readyToRun||this._updatingHandles.updating}get updatingProgress(){if(!this.updating)return 1;let e=this._state/5;return this._dirty?e*.5:e}get readyToRun(){return this.view.ready&&this.view.state!=null&&this._readyToRun}get usedMemory(){return this._occlusionQuery?.usedMemory??0+(this._occlusionQueryUids?.length??0)*4}runTask(e){switch(this._state){case 0:this._startUpdate(),e.madeProgress();case 1:if(this._state=1,!this._processCheckOcclusion(e))return;case 2:if(this._state=2,!(this._occlusionQuery?.done??!0)||!(this._opaqueOcclusionQuery?.done??!0))return V;this._readOcclusionQueryResult(),e.madeProgress();case 3:if(this._state=3,!this._collectActiveGraphics(e))return;case 4:if(this._state=4,this._deconflictor.run(e),!this._deconflictor.done)return;default:this._state=0,this.notifyChange(`_readyToRun`)}}setGraphicsActive(e,t){t?e.forEach(e=>this.addToActiveGraphics(e)):e.forEach(e=>this.removeFromActiveGraphics(e))}isSupportedLayer(e){if(e==null||!(`hiddenIfDeconflicted`in e)||!e.hiddenIfDeconflicted)return!1;let t=e.stageObject;return(t?.geometries.length??0)===1&&t?.geometries[0]?.material instanceof B}_startUpdate(){M(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);let{fullWidth:e,fullHeight:t}=this._viewState.camera;this._deconflictor.reset(e,t),this._resetIterators(),this._occlusionQueryUids.length=0,!this._checkOcclusion.size&&(this._occlusionQuery=r(this._occlusionQuery),this._opaqueOcclusionQuery=r(this._opaqueOcclusionQuery))}addToActiveGraphics(e){e.ensureInfo(this.visibilityGroup),this._active.set(e.graphics3DGraphic.graphic.uid,e),this.setDirty()}removeFromActiveGraphics(e){this._active.get(e.graphics3DGraphic.graphic.uid)===e&&(ue(e,this.visibilityGroup),e.removeInfo(this.visibilityGroup),this._active.delete(e.graphics3DGraphic.graphic.uid),this.setDirty())}addToCheckOcclusion(e){this._checkOcclusion.set(e.graphics3DGraphic.graphic.uid,e),this.setDirty()}removeFromCheckOcclusion(e){this._checkOcclusion.get(e.graphics3DGraphic.graphic.uid)===e&&this._checkOcclusion.delete(e.graphics3DGraphic.graphic.uid)}_processCheckOcclusion(e){if(this._checkOcclusion.size===0)return!0;let t=this._ensureCheckOcclusionIterator(),n=this._viewState.camera,i=o(Y,n.viewInverseTransposeMatrix),a=this.view.map.ground.opacity>0,s=this.view.viewingMode===`global`&&a&&n.relativeElevation>0?ae:null,c=0;s!=null&&(l(s.center,m,n.viewMatrix),s.radius=ee(this.view.spatialReference).radius,c=k.distanceToSilhouette(s,m));let u=x();for(;;){if(e.done)return!1;e.madeProgress();let r=t.next();if(r.done===!0)break;let a=r.value,o=a.graphics3DGraphic;if(o.destroyed||!o.isVisible(1,8))continue;let d=me(o,this.visibilityGroup),f=null,p=!0,m=!1;for(let e of d){if(!this.isSupportedLayer(e))continue;f=he,this._projectHudLayer(e,n,f),te(u);let t=e.stageObject.geometries[0].material;if(this._expandBoundingRect(u,n,e,t,f),f.isOutsideScreen||this._isCulledBySlice(a,f.positionWorld)||s!=null&&pe(f,s,c)){p=!1;break}f.altitude=this.view.renderCoordsHelper.getAltitude(f.positionWorld);let r=a.ensureInfo(this.visibilityGroup);if(r.altitude=f.altitude,r.distance=f.distance,r.distanceToOccluder=f.distanceToOccluder,r.culled=!1,S(r.aabr,u),!e.occlusionCheck)break;l(U,f.positionView,i);let d=this._ensureOcclusionQuery(),h=this._ensureOpaqueOcclusionQuery();this._occlusionQueryUids.length===0&&(this._initOcclusionQuery(d),this._initOcclusionQuery(h));let g=d.addPosition(U),_=h.addPosition(U);if(g===this._occlusionQueryUids.length&&_===g){let t=e.adaptiveOcclusion;this._occlusionQueryUids.push(t?-o.graphic.uid:o.graphic.uid),m=!0}break}let h=this._active.has(o.graphic.uid);if(!h&&!m)this._setGraphicVisibility(a,p);else if(h&&(!p||!f)){let e=a.ensureInfo(this.visibilityGroup);e.visible=!f,e.culled=!0}}return this._checkOcclusionIterator=null,this._occlusionQueryUids.length||(this._occlusionQuery=r(this._occlusionQuery),this._opaqueOcclusionQuery=r(this._opaqueOcclusionQuery)),this._occlusionQuery?.start(),this._opaqueOcclusionQuery?.start(),!0}_readOcclusionQueryResult(){if(!this._occlusionQuery||!this._occlusionQueryUids.length)return;let e=this._viewState.camera,t=this.view.renderCoordsHelper.getAltitude(e.eye);for(let e=0;e<this._occlusionQueryUids.length;e++){let n=this._occlusionQueryUids[e],r=Math.abs(n),i=n<0,a=this._checkOcclusion.get(r);if(!a)continue;let o=this._occlusionQuery.getOcclusion(e)??-1,s=this._opaqueOcclusionQuery?.getOcclusion(e)??-1,c=a.getInfo(this.visibilityGroup);c&&(c.distanceToOccluder=o>0?c.distance-o:0);let l=s===0||s>0&&this._occludedVisibility(c?c.distance-s:0,c?.distance??s,c?.altitude??0,t,i),u=o===0||o>0&&this._occludedVisibility(c?.distanceToOccluder??0,c?.distance??o,c?.altitude??0,t,i),d=l||u;d&&this._setTransparentMode(a,l&&!u),this._active.has(r)?c&&(c.culled=!d,c.visible=d):this._setGraphicVisibility(a,d)}this._occlusionQueryUids.length=0}_collectActiveGraphics(e){let t=this._ensureActiveGraphicsIterator(),n=this.visibilityGroup===16;for(;!e.done;){e.madeProgress();let r=t.next();if(r.done===!0)return this._activeIterator=null,!0;let i=r.value,a=i.getInfo(this.visibilityGroup);if(!a)continue;let o=!n||i.graphics3DGraphic.isVisible();!o||a.culled?(N(a.aabr,!1,!0),this._setGraphicVisibility(i,o&&a.visible)):this._deconflictor.add(a)}return!1}_occludedVisibility(e,t,n,r,i=!0){let a=Math.max(this._minAltitudeDifference,Math.abs(n-r))-this._minAltitudeDifference,o=i?this._baseOccludedVisibility+this._altitudeFactor*a:0;return e===0||t-e<=o}_resetIterators(){this._checkOcclusionIterator=null,this._activeIterator=null}_ensureCheckOcclusionIterator(){return this._checkOcclusionIterator??=this._checkOcclusion.values(),this._checkOcclusionIterator}_ensureActiveGraphicsIterator(){return this._activeIterator??=this._active.values(),this._activeIterator}_initOcclusionQuery(e){if(!e)return;let{camera:t}=this._viewState,n=Math.max(2,2+Math.round(Math.log2(Math.abs(t.relativeElevation))));u(H,this._viewState.camera.eye,2**-n),u(H,d(H,H),2**n),e.init(this._checkOcclusion.size,H)}_ensureOcclusionQuery(){return this._occlusionQuery??=new R({view:this.view}),this._occlusionQuery}_ensureOpaqueOcclusionQuery(){return this._opaqueOcclusionQuery??=new R({view:this.view,category:A.OPAQUE_OCCLUSION_QUERY}),this._opaqueOcclusionQuery}_getNumVisible(e){return this._checkOcclusion.values().reduce((t,n)=>t+ +!!n.getInfo(e)?.visible,0)}_projectHudLayer(e,t,n){let r=e.stageObject,i=r.geometries[0],a=i.material;f(U,r.boundingVolumeWorldSpace.sphere.center),l(H,U,t.viewMatrix);let o=I(i,`normal`).getVec(0,W),s=I(i,`centerOffset`)?.getVec(0,G)??m,c=L(i,`groundDistance`).get(0);a.applyShaderOffsets(U,H,o,r.transformation,s,c,t,n.screenSizePerspectiveEvaluators),g(K,H[0],H[1],H[2],1),_(q,K,t.projectionMatrix),u(n.positionNDC,q,1/q[3]),a.applyShaderOffsetsNDC(n.positionNDC,s,c,t,n.positionNDC,J),n.distanceWithoutPolygonOffset=t.depthNDCToWorld(J[2]),n.distance=J[2]===n.positionNDC[2]?n.distanceWithoutPolygonOffset:t.depthNDCToWorld(n.positionNDC[2]),g(q,n.positionNDC[0],n.positionNDC[1],n.positionNDC[2],1),_(K,q,t.inverseProjectionMatrix),v(K,K,1/K[3]),p(n.positionView,K[0],K[1],K[2]),f(n.positionWorld,U)}_isCulledBySlice(e,t){return e.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&E(this._viewState.slicePlane,t)}_expandBoundingRect(e,t,r,i,{positionNDC:a,screenSizePerspectiveEvaluators:o}){let s=r.getScreenSize(de);o.evaluator.applyVec2(s,s),s[0]*=t.pixelRatio,s[1]*=t.pixelRatio;let c=C(i.calculateRelativeScreenBounds(s,o.alignmentEvaluator.apply(t.pixelRatio),Z),n(0,t.fullWidth,.5+.5*a[0]),n(0,t.fullHeight,.5+.5*a[1])),l=this.marginFactor;if(l!==0){let e=l*Math.min(w(c),ne(c));c[0]-=e,c[1]-=e,c[2]+=e,c[3]+=e}T(e,c,e)}_setGraphicVisibility(e,t){let n=e?.graphics3DGraphic;n&&!n.destroyed&&(n.setVisibilityFlag(this.visibilityGroup,8,t),this.visibilityGroup===16&&this.view.labeler.setLabelGraphicVisibility(n,t))}_setTransparentMode(e,t){let n=e?.graphics3DGraphic;if(n&&!n.destroyed)for(let e of n.layers){if(e?.type!==`object3d`&&e?.type!==`buffer`)continue;let{graphics3DSymbolLayer:n}=e;P(n)&&n.updateTransparentMode(e,t)}}};e([i({constructOnly:!0})],$.prototype,`view`,void 0),e([i({type:Boolean,readOnly:!0})],$.prototype,`_readyToRun`,null),e([i({type:Boolean,readOnly:!0})],$.prototype,`updating`,null),e([i({readOnly:!0})],$.prototype,`_updatingHandles`,void 0),$=e([a(`esri.views.3d.layers.graphics.Deconflictor`)],$);function ue(e,t){let n=e.graphics3DGraphic;n.destroyed||n.setVisibilityFlag(t,8,!0)}const de=c();class fe{constructor(){this.positionWorld=h(),this.positionView=h(),this.positionNDC=h(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.distanceWithoutPolygonOffset=0,this.screenSizePerspectiveEvaluators=new z}get isOutsideScreen(){let e=this.positionNDC;return e[0]<-1||e[1]<-1||e[2]<-1||e[0]>=1||e[1]>=1||e[2]>=1}}function pe(e,t,n){return f(X.direction,e.positionView),p(X.origin,0,0,0),t.intersectRay(X,oe)?e.distanceWithoutPolygonOffset>n:!1}function me(e,t){return t===16?e.labelLayers:e.layers}const he=new fe;export{$ as Deconflictor,le as DeconflictorGraphic,Q as DeconflictorViewState};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{copy as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as i}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as a}from"../../../../geometry/projection/projectBuffer.js";import{SampleElevationInfo as o,updateVertexPointGroundDistance as s}from"./elevationAlignmentUtils.js";import{debugFlags as c}from"../../support/debugFlags.js";import{SamplePosition as l}from"../../support/ElevationProvider.js";import{isGeometryWithMapPositions as u}from"../../webgl-engine/lib/GeometryWithMapPositions.js";function d(e,t,n,r,i){let a=e.stageObject,o=a.geometries,s=0;for(let e of o){if(!u(e))continue;let{update:o,averageGeometrySampledElevation:c}=C(e,t,n,r,i);s+=c,o&&a.geometryVertexAttributeUpdated(e,`position`)}return s/o.length}function f(t,r,a,o,l,u){let d=t.stageObject,f=r.centerInElevationSR,m=0;o(f,S),d.usesVerticalDistanceToGround?(s(d,S.verticalDistanceToGround),m=S.sampledElevation):r.mode!==`absolute-height`&&(m=S.sampledElevation);let h=e(p,u??d.transformation),v=n(x,h[12],h[13],h[14]);c.ENABLE_OPTIMIZATIONS?l.setAltitudeOfTransformation(S.z,h):(_[0]=f[0],_[1]=f[1],_[2]=S.z,i(a,_,h,l.spatialReference)&&(u?e(u,h):d.transformation=h));let y=g/l.unitInMeters;return(Math.abs(h[12]-v[0])>=y||Math.abs(h[13]-v[1])>=y||Math.abs(h[14]-v[2])>=y)&&(u?e(u,h):d.transformation=h),m}const p=t();function m(e,t,r,a,o){let s=e.graphics3DSymbolLayer.lodRenderer;if(s==null)return 0;let l=t.centerInElevationSR;a(l,S);let u=t.mode===`absolute-height`?0:S.sampledElevation,d=s.instanceData,f=e.instanceIndex,p=b;d.getGlobalTransform(f,p);let m=n(x,p[12],p[13],p[14]);c.ENABLE_OPTIMIZATIONS?o.setAltitudeOfTransformation(S.z,p):(_[0]=l[0],_[1]=l[1],_[2]=S.z,i(r,_,p,o.spatialReference)&&d.setGlobalTransform(f,p));let h=g/o.unitInMeters;return(!c.ENABLE_OPTIMIZATIONS||Math.abs(p[12]-m[0])>=h||Math.abs(p[13]-m[1])>=h||Math.abs(p[14]-m[2])>=h)&&d.setGlobalTransform(f,p),u}function h(e,t,n,r,i){let a=e.stageObject,o=a.geometries;if(o.length===0)return 0;let s=0,c=null,l=0,d=!1;for(let e of o){if(!u(e))continue;let o=e.attributes.get(`position`);if(o!==c){let{update:a,averageGeometrySampledElevation:s}=C(e,t,n,r,i);l=s,c=o,d=a}d&&a.geometryVertexAttributeUpdated(e,`position`),s+=l}return s/o.length}const g=.01,_=r(),v=r(),y=r(),b=t(),x=r(),S=new o;function C(e,t,n,r,i){let o=!1,s=e.transformation,u=t.requiresSampledElevationInfo;v[0]=s[12],v[1]=s[13],v[2]=s[14],e.invalidateBoundingInfo();let d=e.getMutableAttribute(`position`),f=d.data,p=d.size,m=f.length/p,h=new l(e.mapPositions,n),b=0,x=0;for(let e=0;e<m;e++){if(y[0]=f[b],y[1]=f[b+1],y[2]=f[b+2],r(h,S),u&&(x+=S.sampledElevation),c.ENABLE_OPTIMIZATIONS){_[0]=f[b]+v[0],_[1]=f[b+1]+v[1],_[2]=f[b+2]+v[2],i.setAltitude(_,S.z),f[b]=_[0]-v[0],f[b+1]=_[1]-v[1],f[b+2]=_[2]-v[2];let e=g/i.unitInMeters;(Math.abs(y[0]-f[b])>=e||Math.abs(y[1]-f[b+1])>=e||Math.abs(y[2]-f[b+2])>=e)&&(o=!0)}else f[b]=h.array[h.offset],f[b+1]=h.array[h.offset+1],f[b+2]=S.z,a(f,n,b,f,i.spatialReference,b,1),f[b]-=v[0],f[b+1]-=v[1],f[b+2]-=v[2],o=!0;b+=p,h.offset+=3}return x/=m,{update:o,averageGeometrySampledElevation:x}}export{m as perLodInstanceElevationAligner,f as perObjectElevationAligner,d as perVertexElevationAligner,h as sharedGeometryElevationAligner};
2
+ import{copy as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n,add as r,subtract as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as o}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as s}from"../../../../geometry/projection/projectBuffer.js";import{BufferViewVec3f as c}from"../../../../geometry/support/buffer/BufferView.js";import{SampleElevationInfo as l,updateVertexPointGroundDistance as u,updateBufferPointGroundDistance as d,applyBufferPointPlacement as f}from"./elevationAlignmentUtils.js";import{debugFlags as p}from"../../support/debugFlags.js";import{SamplePosition as m}from"../../support/ElevationProvider.js";import{updateObjectVertexField as h,updateVertexFieldVec3f as g}from"../../webgl-engine/lib/bufferGeometryUtils.js";import{isGeometryWithMapPositions as _}from"../../webgl-engine/lib/GeometryWithMapPositions.js";function v(e,t,n,r,i){let a=e.stageObject,o=a.geometries,s=0;for(let e of o){if(!_(e))continue;let{update:o,averageGeometrySampledElevation:c}=j(e,t,n,r,i);s+=c,o&&a.geometryVertexAttributeUpdated(e,`position`)}return s/o.length}function y(t,r,i,a,s,c){let l=t.stageObject,d=r.centerInElevationSR,f=0;a(d,A),l.usesVerticalDistanceToGround?(u(l,A.verticalDistanceToGround),f=A.sampledElevation):r.mode!==`absolute-height`&&(f=A.sampledElevation);let m=e(x,c??l.transformation),h=n(k,m[12],m[13],m[14]);p.ENABLE_OPTIMIZATIONS?s.setAltitudeOfTransformation(A.z,m):(T[0]=d[0],T[1]=d[1],T[2]=A.z,o(i,T,m,s.spatialReference)&&(c?e(c,m):l.transformation=m));let g=w/s.unitInMeters;return(Math.abs(m[12]-h[0])>=g||Math.abs(m[13]-h[1])>=g||Math.abs(m[14]-h[2])>=g)&&(c?e(c,m):l.transformation=m),f}function b(e,t,a,o,s){let l=t.centerInElevationSR;if(o(l,A),d(e,A.verticalDistanceToGround),p.ENABLE_OPTIMIZATIONS){let t=w/s.unitInMeters;for(let a of e.geometries){let o=a.buffers.vertex.getField(`position`,c),l=a.localOrigin.vec3;n(D,o.get(0,0),o.get(0,1),o.get(0,2)),r(T,D,l),s.setAltitude(T,A.z),i(T,T,l),(Math.abs(T[0]-D[0])>=t||Math.abs(T[1]-D[1])>=t||Math.abs(T[2]-D[2])>=t)&&h(e,g,a,`position`,0,T)}}else n(T,l[0],l[1],A.z),f(e,T,a,s);return A.sampledElevation}const x=t();function S(e,t,r,i,a){let s=e.graphics3DSymbolLayer.lodRenderer;if(s==null)return 0;let c=t.centerInElevationSR;i(c,A);let l=t.mode===`absolute-height`?0:A.sampledElevation,u=s.instanceData,d=e.instanceIndex,f=O;u.getGlobalTransform(d,f);let m=n(k,f[12],f[13],f[14]);p.ENABLE_OPTIMIZATIONS?a.setAltitudeOfTransformation(A.z,f):(T[0]=c[0],T[1]=c[1],T[2]=A.z,o(r,T,f,a.spatialReference)&&u.setGlobalTransform(d,f));let h=w/a.unitInMeters;return(!p.ENABLE_OPTIMIZATIONS||Math.abs(f[12]-m[0])>=h||Math.abs(f[13]-m[1])>=h||Math.abs(f[14]-m[2])>=h)&&u.setGlobalTransform(d,f),l}function C(e,t,n,r,i){let a=e.stageObject,o=a.geometries;if(o.length===0)return 0;let s=0,c=null,l=0,u=!1;for(let e of o){if(!_(e))continue;let o=e.attributes.get(`position`);if(o!==c){let{update:a,averageGeometrySampledElevation:s}=j(e,t,n,r,i);l=s,c=o,u=a}u&&a.geometryVertexAttributeUpdated(e,`position`),s+=l}return s/o.length}const w=.01,T=a(),E=a(),D=a(),O=t(),k=a(),A=new l;function j(e,t,n,r,i){let a=!1,o=e.transformation,c=t.requiresSampledElevationInfo;E[0]=o[12],E[1]=o[13],E[2]=o[14],e.invalidateBoundingInfo();let l=e.getMutableAttribute(`position`),u=l.data,d=l.size,f=u.length/d,h=new m(e.mapPositions,n),g=0,_=0;for(let e=0;e<f;e++){if(D[0]=u[g],D[1]=u[g+1],D[2]=u[g+2],r(h,A),c&&(_+=A.sampledElevation),p.ENABLE_OPTIMIZATIONS){T[0]=u[g]+E[0],T[1]=u[g+1]+E[1],T[2]=u[g+2]+E[2],i.setAltitude(T,A.z),u[g]=T[0]-E[0],u[g+1]=T[1]-E[1],u[g+2]=T[2]-E[2];let e=w/i.unitInMeters;(Math.abs(D[0]-u[g])>=e||Math.abs(D[1]-u[g+1])>=e||Math.abs(D[2]-u[g+2])>=e)&&(a=!0)}else u[g]=h.array[h.offset],u[g+1]=h.array[h.offset+1],u[g+2]=A.z,s(u,n,g,u,i.spatialReference,g,1),u[g]-=E[0],u[g+1]-=E[1],u[g+2]-=E[2],a=!0;g+=d,h.offset+=3}return _/=f,{update:a,averageGeometrySampledElevation:_}}export{b as perBufferPointElevationAligner,S as perLodInstanceElevationAligner,y as perObjectElevationAligner,v as perVertexElevationAligner,C as sharedGeometryElevationAligner};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
+ import{Graphics3DStageObjectGraphicLayer as e}from"./Graphics3DStageObjectGraphicLayer.js";class t extends e{constructor(e,t,n,r,i){super(e,t,n,i),this.elevationAligner=r,this.type=`buffer`}updateMaterial(e){let{stageObject:t}=this,n=t.geometries.map(t=>t.instantiate(e));for(let e of n)t.removeGeometry(0),t.addGeometry(e)}_alignWithElevation(e,t,n,r){this.elevationAligner!=null&&(this.alignedSampledElevation=this.elevationAligner(this.stageObject,this.elevationContext,e,t,n))}}export{t as Graphics3DBufferGraphicLayer};