@arcgis/core 4.27.0-next.20230321 → 4.27.0-next.20230323

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 (267) hide show
  1. package/analysis/LineOfSightAnalysisObserver.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/02b6227c156ee0d8eb66.js +1 -0
  4. package/assets/esri/core/workers/chunks/{7e0c65aa61c2ff0c3504.js → 1c98b92933a48cf96c1e.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{a27951dbe83c63f9d01a.js → 26bc91a9d9d7345a3eba.js} +1 -1
  6. package/assets/esri/core/workers/chunks/321f272d4c7ed6b0cb46.js +1 -0
  7. package/assets/esri/core/workers/chunks/{a09cc8e2ff43fe4afa04.js → 375628de4cfc71cb41c1.js} +1 -1
  8. package/assets/esri/core/workers/chunks/47bd558e2ce89f47f908.js +1 -0
  9. package/assets/esri/core/workers/chunks/4cb62855bb1ae608bfde.js +1 -0
  10. package/assets/esri/core/workers/chunks/4f0c2b6b200bf8222fd7.js +1 -0
  11. package/assets/esri/core/workers/chunks/5252f3cc244204edc299.js +1 -0
  12. package/assets/esri/core/workers/chunks/6f952a6464cf9e62dbac.js +1098 -0
  13. package/assets/esri/core/workers/chunks/76d6c1fc25f02bcf258e.js +1 -0
  14. package/assets/esri/core/workers/chunks/{d6ec7682de8fad9718e9.js → 77dccfaf1f9e778973b3.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{c5d872adce711ec61ede.js → 8980c5dc389c27368b73.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{6acaf28cba5d49a98fb6.js → 91b292f310f06a0cbf72.js} +1 -1
  17. package/assets/esri/core/workers/chunks/9bac27976e7a71268b7b.js +1 -0
  18. package/assets/esri/core/workers/chunks/{ff9efa829497557ec26a.js → aa4640a0207e0be224e2.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{81a6f4b43e047c3395c0.js → aebc5091bd4159197ce0.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{c8cd3fde6d8d43ddb954.js → b6cdf4daf07d9e55f61e.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{6b14673a4afd6ef81487.js → c76cabd2d2510a653dff.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{4be7647605300e07e843.js → c90fff7e28ba5b443b11.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{e637e47000f4dc48054d.js → cc7f4fd20443a2acf0f1.js} +1 -1
  24. package/assets/esri/core/workers/chunks/d19e9fab4f4fb765c6a3.js +1 -0
  25. package/assets/esri/core/workers/chunks/d9ef4891c8b0bdd90f5b.js +1 -0
  26. package/assets/esri/core/workers/chunks/{d92d6a43270fb0d366b4.js → de4f5c48efbcee82c3c1.js} +1 -1
  27. package/assets/esri/core/workers/chunks/f6e7948075b3742b4ef9.js +1 -0
  28. package/assets/esri/core/workers/chunks/{32f9b488915a4a8864e5.js → f8b9e0c1671e55b61904.js} +1 -1
  29. package/assets/esri/views/3d/analysis/Slice/images/heading-rotate.ts.svg +7 -28
  30. package/assets/esri/views/3d/analysis/Slice/images/tilt-rotate.ts.svg +11 -0
  31. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList.json +1 -1
  32. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ar.json +1 -1
  33. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_bg.json +1 -1
  34. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_bs.json +1 -1
  35. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ca.json +1 -1
  36. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_cs.json +1 -1
  37. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_da.json +1 -1
  38. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_de.json +1 -1
  39. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_el.json +1 -1
  40. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_en.json +1 -1
  41. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_es.json +1 -1
  42. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_et.json +1 -1
  43. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_fi.json +1 -1
  44. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_fr.json +1 -1
  45. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_he.json +1 -1
  46. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_hr.json +1 -1
  47. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_hu.json +1 -1
  48. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_id.json +1 -1
  49. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_it.json +1 -1
  50. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ja.json +1 -1
  51. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ko.json +1 -1
  52. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_lt.json +1 -1
  53. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_lv.json +1 -1
  54. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_nb.json +1 -1
  55. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_nl.json +1 -1
  56. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_pl.json +1 -1
  57. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_pt-BR.json +1 -1
  58. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_pt-PT.json +1 -1
  59. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ro.json +1 -1
  60. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ru.json +1 -1
  61. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sk.json +1 -1
  62. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sl.json +1 -1
  63. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sr.json +1 -1
  64. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sv.json +1 -1
  65. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_th.json +1 -1
  66. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_tr.json +1 -1
  67. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_uk.json +1 -1
  68. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_vi.json +1 -1
  69. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_zh-CN.json +1 -1
  70. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_zh-HK.json +1 -1
  71. package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_zh-TW.json +1 -1
  72. package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
  73. package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
  74. package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
  75. package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
  76. package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
  77. package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
  78. package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
  79. package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
  80. package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
  81. package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
  82. package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
  83. package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
  84. package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
  85. package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
  86. package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
  87. package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
  88. package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
  89. package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
  90. package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
  91. package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
  92. package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
  93. package/assets/esri/widgets/Editor/t9n/Editor_nb.json +1 -1
  94. package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
  95. package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
  96. package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
  97. package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
  98. package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
  99. package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
  100. package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
  101. package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
  102. package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
  103. package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
  104. package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
  105. package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
  106. package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
  107. package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
  108. package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
  109. package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
  110. package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
  111. package/assets/esri/widgets/LayerList/t9n/LayerList.json +1 -1
  112. package/assets/esri/widgets/LayerList/t9n/LayerList_ar.json +1 -1
  113. package/assets/esri/widgets/LayerList/t9n/LayerList_bg.json +1 -1
  114. package/assets/esri/widgets/LayerList/t9n/LayerList_bs.json +1 -1
  115. package/assets/esri/widgets/LayerList/t9n/LayerList_ca.json +1 -1
  116. package/assets/esri/widgets/LayerList/t9n/LayerList_cs.json +1 -1
  117. package/assets/esri/widgets/LayerList/t9n/LayerList_da.json +1 -1
  118. package/assets/esri/widgets/LayerList/t9n/LayerList_de.json +1 -1
  119. package/assets/esri/widgets/LayerList/t9n/LayerList_el.json +1 -1
  120. package/assets/esri/widgets/LayerList/t9n/LayerList_en.json +1 -1
  121. package/assets/esri/widgets/LayerList/t9n/LayerList_es.json +1 -1
  122. package/assets/esri/widgets/LayerList/t9n/LayerList_et.json +1 -1
  123. package/assets/esri/widgets/LayerList/t9n/LayerList_fi.json +1 -1
  124. package/assets/esri/widgets/LayerList/t9n/LayerList_fr.json +1 -1
  125. package/assets/esri/widgets/LayerList/t9n/LayerList_he.json +1 -1
  126. package/assets/esri/widgets/LayerList/t9n/LayerList_hr.json +1 -1
  127. package/assets/esri/widgets/LayerList/t9n/LayerList_hu.json +1 -1
  128. package/assets/esri/widgets/LayerList/t9n/LayerList_id.json +1 -1
  129. package/assets/esri/widgets/LayerList/t9n/LayerList_it.json +1 -1
  130. package/assets/esri/widgets/LayerList/t9n/LayerList_ja.json +1 -1
  131. package/assets/esri/widgets/LayerList/t9n/LayerList_ko.json +1 -1
  132. package/assets/esri/widgets/LayerList/t9n/LayerList_lt.json +1 -1
  133. package/assets/esri/widgets/LayerList/t9n/LayerList_lv.json +1 -1
  134. package/assets/esri/widgets/LayerList/t9n/LayerList_nb.json +1 -1
  135. package/assets/esri/widgets/LayerList/t9n/LayerList_nl.json +1 -1
  136. package/assets/esri/widgets/LayerList/t9n/LayerList_pl.json +1 -1
  137. package/assets/esri/widgets/LayerList/t9n/LayerList_pt-BR.json +1 -1
  138. package/assets/esri/widgets/LayerList/t9n/LayerList_pt-PT.json +1 -1
  139. package/assets/esri/widgets/LayerList/t9n/LayerList_ro.json +1 -1
  140. package/assets/esri/widgets/LayerList/t9n/LayerList_ru.json +1 -1
  141. package/assets/esri/widgets/LayerList/t9n/LayerList_sk.json +1 -1
  142. package/assets/esri/widgets/LayerList/t9n/LayerList_sl.json +1 -1
  143. package/assets/esri/widgets/LayerList/t9n/LayerList_sr.json +1 -1
  144. package/assets/esri/widgets/LayerList/t9n/LayerList_sv.json +1 -1
  145. package/assets/esri/widgets/LayerList/t9n/LayerList_th.json +1 -1
  146. package/assets/esri/widgets/LayerList/t9n/LayerList_tr.json +1 -1
  147. package/assets/esri/widgets/LayerList/t9n/LayerList_uk.json +1 -1
  148. package/assets/esri/widgets/LayerList/t9n/LayerList_vi.json +1 -1
  149. package/assets/esri/widgets/LayerList/t9n/LayerList_zh-CN.json +1 -1
  150. package/assets/esri/widgets/LayerList/t9n/LayerList_zh-HK.json +1 -1
  151. package/assets/esri/widgets/LayerList/t9n/LayerList_zh-TW.json +1 -1
  152. package/chunks/ComponentShader.glsl.js +1 -1
  153. package/chunks/DefaultMaterial.glsl.js +4 -4
  154. package/chunks/vec42.js +1 -1
  155. package/core/Loadable.js +1 -1
  156. package/core/accessorSupport/Property.js +1 -1
  157. package/core/accessorSupport/tracking/SimpleTrackingTarget.js +1 -1
  158. package/core/analysisThemeUtils.js +1 -1
  159. package/core/maybe.js +1 -1
  160. package/geometry/support/buffer/math/vec4.js +1 -1
  161. package/interfaces.d.ts +1 -1
  162. package/layers/IntegratedMeshLayer.js +1 -1
  163. package/layers/LineOfSightLayer.js +1 -1
  164. package/layers/SceneLayer.js +1 -1
  165. package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
  166. package/layers/mixins/ImageryTileMixin.js +1 -1
  167. package/layers/mixins/RefreshableLayer.js +1 -1
  168. package/layers/support/SceneFilter.js +1 -1
  169. package/layers/support/SceneModifications.js +1 -1
  170. package/layers/support/rasterFunctions/clipUtils.js +1 -1
  171. package/layers/support/rasterFunctions/stretchUtils.js +1 -1
  172. package/package.json +1 -1
  173. package/portal/PortalItemResource.js +1 -1
  174. package/portal/support/resourceUtils.js +1 -1
  175. package/support/revision.js +1 -1
  176. package/symbols/support/utils.js +1 -1
  177. package/views/2d/engine/vectorTiles/TileHandler.js +1 -1
  178. package/views/2d/viewpointUtils.js +1 -1
  179. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  180. package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
  181. package/views/3d/analysis/Dimension/settings.js +1 -1
  182. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  183. package/views/3d/analysis/Slice/SliceVisualization.js +1 -1
  184. package/views/3d/analysis/Slice/images/Factory.js +1 -1
  185. package/views/3d/analysis/Slice/images/generateTextures.js +1 -1
  186. package/views/3d/analysis/Slice/images/heading-rotate-svg.js +1 -1
  187. package/views/3d/analysis/Slice/images/tilt-rotate-svg.js +5 -0
  188. package/views/3d/analysis/Slice/settings.js +5 -0
  189. package/views/3d/analysis/Slice/sliceToolConfig.js +1 -1
  190. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  191. package/views/3d/environment/Stars.js +1 -1
  192. package/views/3d/interactive/Manipulator3D.js +1 -1
  193. package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
  194. package/views/3d/interactive/manipulatorUtils.js +1 -1
  195. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  196. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  197. package/views/3d/layers/PointCloudWorker.js +1 -1
  198. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  199. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  200. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  201. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  202. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  203. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  204. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  205. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  206. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  207. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  208. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  209. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  210. package/views/3d/layers/i3s/PointCloudRendererUtil.js +1 -1
  211. package/views/3d/layers/i3s/PointCloudWorkerUtil.js +1 -1
  212. package/views/3d/layers/i3s/PointGraphic.js +1 -1
  213. package/views/3d/state/ViewState.js +1 -1
  214. package/views/3d/state/controllers/SurfaceCollisionCorrectionController.js +1 -1
  215. package/views/3d/terrain/GeometryState.js +1 -1
  216. package/views/3d/terrain/PatchGeometry.js +1 -1
  217. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  218. package/views/3d/terrain/TileAgent.js +1 -1
  219. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  220. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  221. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  222. package/views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js +6 -5
  223. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js +1 -1
  224. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +11 -11
  225. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeShadingNormal.glsl.js +1 -1
  226. package/views/3d/webgl-engine/lib/AnimationTimeStep.js +1 -1
  227. package/views/3d/webgl-engine/lib/AttributeArray.js +1 -1
  228. package/views/3d/webgl-engine/lib/DefaultVertexAttributeLocations.js +1 -1
  229. package/views/3d/webgl-engine/lib/Normals.js +5 -0
  230. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  231. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  232. package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
  233. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  234. package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
  235. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  236. package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
  237. package/views/3d/webgl-engine/shaders/RealisticTreeTechnique.js +1 -1
  238. package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
  239. package/views/LayerViewManager.js +1 -1
  240. package/views/SceneView.js +1 -1
  241. package/views/draw/support/Reshape.js +1 -1
  242. package/views/layers/SceneLayerView.js +1 -1
  243. package/views/support/colorUtils.js +1 -1
  244. package/views/webgl/ShaderTranspiler.js +1 -1
  245. package/widgets/BasemapLayerList.js +1 -1
  246. package/widgets/Daylight/DaylightViewModel.js +1 -1
  247. package/widgets/Expand.js +1 -1
  248. package/widgets/FeatureForm/FieldInput.js +1 -1
  249. package/widgets/LayerList.js +1 -1
  250. package/widgets/Search.js +1 -1
  251. package/widgets/Sketch/SketchViewModel.js +1 -1
  252. package/assets/esri/core/workers/chunks/0487ab23a20ec356ab4c.js +0 -1
  253. package/assets/esri/core/workers/chunks/29ee4f14602caf6967e4.js +0 -1
  254. package/assets/esri/core/workers/chunks/2c0775541cfec9d43acb.js +0 -1
  255. package/assets/esri/core/workers/chunks/4879164b48da9ad4547a.js +0 -1
  256. package/assets/esri/core/workers/chunks/69060e5cffc19e76062a.js +0 -1
  257. package/assets/esri/core/workers/chunks/87edeb09a948122fa030.js +0 -1
  258. package/assets/esri/core/workers/chunks/92951b85676df776961f.js +0 -1100
  259. package/assets/esri/core/workers/chunks/a71a5c8a9aa302bf6f01.js +0 -1
  260. package/assets/esri/core/workers/chunks/ad5c61daaed286c74982.js +0 -1
  261. package/assets/esri/core/workers/chunks/bc002e4dff8859571a7a.js +0 -1
  262. package/assets/esri/core/workers/chunks/ef2d3e84cd58df5f80af.js +0 -1
  263. package/assets/esri/core/workers/chunks/fec5e55e0fbf1710e22d.js +0 -1
  264. package/assets/esri/views/3d/analysis/Slice/images/tilt-rotate.svg +0 -80
  265. package/assets/esri/views/3d/analysis/Slice/images/tilt-rotate.ts.png +0 -0
  266. package/views/3d/analysis/Slice/images/tilt-rotate-png.js +0 -5
  267. package/views/3d/webgl-engine/core/shaderLibrary/util/DecodeNormal.glsl.js +0 -8
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import r from"../core/Accessor.js";import t from"../core/Error.js";import i from"../core/Logger.js";import{someMap as s}from"../core/MapUtils.js";import{removeMaybe as a}from"../core/maybe.js";import{createDeferred as o,createAbortError as l,isAbortError as n,onAbort as y,throwIfAborted as h}from"../core/promiseUtils.js";import{on as c,watch as w,syncAndInitial as p}from"../core/reactiveUtils.js";import{schedule as d}from"../core/scheduling.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as f}from"../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as u}from"../core/support/WatchUpdatingTracking.js";import{destroyMap as _}from"../support/collectionUtils.js";function g(e){return"tryRecycleWith"in e}class v{constructor(e,r,i){this.layer=e,this.view=r,this.layerViewImporter=i,this._controller=new AbortController,this._deferred=o(),this._started=!1,this.done=!1,this.promise=this._deferred.promise,y(this._controller.signal,(()=>{const r=new t("cancelled:layerview-create","layerview creation cancelled",{layer:e});this._deferred.reject(r)}))}tryRecycle(e){if(!this.done||!this.layerView||!g(this.layerView))return null;const r=this.layer.type,t=this._controller.signal;for(let i=0;i<e.length;i++){const s=e[i];if(s.type!==r)continue;const a=this.layerView.tryRecycleWith(s,{signal:t});if(a){e.splice(i,1),this.layer=s;const r=this.layerView,t=r.view;return this.promise=Promise.race([a.then((()=>(h(this._controller.signal),s.emit("layerview-destroy",{view:t,layerView:r}),t.emit("layerview-destroy",{view:t,layerView:r}),s.emit("layerview-create",{view:t,layerView:r}),t.emit("layerview-create",{view:t,layerView:r}),r))),new Promise(((e,r)=>y(this._controller.signal,(()=>r(l())))))]),this.promise}}return null}destroy(){this._controller.abort();const{layerView:e}=this;if(e){const{layer:r,view:t}=this;r.emit("layerview-destroy",{view:t,layerView:e}),t.emit("layerview-destroy",{layer:r,layerView:e})}this.done=!0,this.layer=null,this.layerView=null,this.view=null,this.layerViewImporter=null}async start(){if(this._started)return;this._started=!0;const{_controller:{signal:e},layer:r,view:i}=this;this._map=i.map;try{let o,l;if(await r.load({signal:e}),"prefetchResources"in r&&await(r.prefetchResources?.({signal:e})),M(r))o=await r.createLayerView(i,{signal:e});else{if(!this.layerViewImporter.hasLayerViewModule(r))throw new t("layer:view-not-supported","No layerview implementation was found");const s=await this.layerViewImporter.importLayerView(r);h(e),o="default"in s?new s.default({layer:r,view:i}):new s({layer:r,view:i})}const n=()=>{l=a(l),o.destroyed||o.destroy(),o.layer=null,o.parent=null,o.view=null,this.done=!0};l=y(e,n),h(e);try{await o.when()}catch(s){throw n(),s}const c=this._map?.allLayers?.includes(r);if(!c)return n(),void this._deferred.reject(new t("view:no-layerview-for-layer","The layer has been removed from the map",{layer:r}));this.layerView=o,r.emit("layerview-create",{view:i,layerView:o}),i.emit("layerview-create",{layer:r,layerView:o}),this.done=!0,this._deferred.resolve(o)}catch(s){r.emit("layerview-create-error",{view:i,error:s}),i.emit("layerview-create-error",{layer:r,error:s}),this.done=!0,this._deferred.reject(new t("layerview:create-error","layerview creation failed",{layer:r,error:s}))}}}let V=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new u,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=o(),this._workPromise.promise.catch((()=>{}))),this.removeHandles("reschedule"),this.addHandles(d(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{if(this.destroyed)return;const e=this.view.map;if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,t=[],i=this.view.ready,s=e=>{if(null!=e)for(const a of e)if(a){r.add(a);const e=this._layerLayerViewInfoMap.get(a);e&&i?e.start():e||this._recyclingInfoMap.has(a)||t.push(a),"layers"in a&&a.layers&&s(a.layers)}};for(const o of this._rootCollectionNames)s(this.get(o));for(const[o,l]of this._layerLayerViewInfoMap)if(!r.has(o)){this._layerLayerViewInfoMap.delete(l.layer);const e=l.tryRecycle(t);e?(this._recyclingInfoMap.set(l.layer,l),e.then((()=>{this._recyclingInfoMap.delete(l.layer),this._layerLayerViewInfoMap.set(l.layer,l),this._reschedule()})).catch((()=>{this._recyclingInfoMap.delete(l.layer),l.destroy(),this._reschedule()}))):l.destroy()}for(const[o,l]of this._recyclingInfoMap)r.has(o)||(this._recyclingInfoMap.delete(l.layer),l.destroy());for(const o of t)this._createLayerView(o);this._refreshCollections();const a=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.referenceLayers,e?.layers].filter((e=>!!e));r.forEach((e=>"layers"in e&&a.push(e.layers))),this.addHandles(a.map((e=>this._watchUpdatingTracking.addOnCollectionChange((()=>e),this._reschedule))),"collection-change"),this._workPromise.resolve(),this._workPromise=null}}initialize(){this.own([c((()=>this.view?.map?.allLayers),"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),w((()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]}),(()=>this._reschedule()),p)]),this._preloadLayerViewModules(),this._reschedule()}destroy(){this.clear(),_(this._recyclingInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(l()),this._workPromise=null)}get _layersToLayerViews(){const e=[["view.map.basemap.baseLayers","view.basemapView.baseLayerViews"],["view.map.layers","view.layerViews"],["view.map.basemap.referenceLayers","view.basemapView.referenceLayerViews"]];return this.supportsGround&&e.push(["view.map.ground.layers","view.groundView.layerViews"]),new Map(e)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||s(this._layerLayerViewInfoMap,(e=>!e.done))}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){if(!this.destroyed){for(const e of this._layerLayerViewInfoMap.values())e.destroy();this._layerLayerViewInfoMap.clear(),this._refreshCollections()}}async whenLayerView(e){if(await this._reschedule(),!this._layerLayerViewInfoMap.has(e)){if(this._recyclingInfoMap.has(e))return this._recyclingInfoMap.get(e).promise;throw new t("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e})}return this._layerLayerViewInfoMap.get(e).promise}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(this.get(e),this.get(r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_populateLayerViewsOwners(e,r,t){if(!e||!r)return void(r&&r.removeAll());let i=0;for(const s of e){const e=this._layerLayerViewInfoMap.get(s);if(!e||!e.layerView)continue;const a=e.layerView;a.layer=s,a.parent=t,r.getItemAt(i)!==a&&r.splice(i,0,a),s.layers&&this._populateLayerViewsOwners(s.layers,a.layerViews,a),i+=1}i<r.length&&r.splice(i,r.length)}_createLayerView(e){e.load().catch((()=>{})),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new v(e,this.view,this.layerViewImporter);r.promise.then((()=>this._refreshCollections()),(r=>{r&&(n(r)||"cancelled:layerview-create"===r.name)||i.getLogger(this.declaredClass).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this._refreshCollections()})),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([m()],V.prototype,"_workPromise",void 0),e([m({readOnly:!0})],V.prototype,"_watchUpdatingTracking",void 0),e([m({readOnly:!0})],V.prototype,"_layersToLayerViews",null),e([m({readOnly:!0})],V.prototype,"_rootCollectionNames",null),e([m()],V.prototype,"layerViewImporter",void 0),e([m()],V.prototype,"supportsGround",void 0),e([m({readOnly:!0})],V.prototype,"updating",null),e([m({readOnly:!0})],V.prototype,"updatingRemaining",null),e([m({constructOnly:!0})],V.prototype,"view",void 0),V=e([f("esri.views.LayerViewManager")],V);const L=V;function M(e){return"createLayerView"in e&&null!=e.createLayerView}export{L as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import r from"../core/Accessor.js";import i from"../core/Error.js";import t from"../core/Logger.js";import{someMap as s}from"../core/MapUtils.js";import{removeMaybe as a}from"../core/maybe.js";import{createDeferred as o,createAbortError as l,isAbortError as n,onAbort as y,throwIfAborted as h}from"../core/promiseUtils.js";import{on as c,watch as w,syncAndInitial as p}from"../core/reactiveUtils.js";import{schedule as d}from"../core/scheduling.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as f}from"../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as u}from"../core/support/WatchUpdatingTracking.js";import{destroyMap as _}from"../support/collectionUtils.js";function g(e){return"tryRecycleWith"in e}class v{constructor(e,r,t){this.layer=e,this.view=r,this.layerViewImporter=t,this._controller=new AbortController,this._deferred=o(),this._started=!1,this.done=!1,this.promise=this._deferred.promise,y(this._controller.signal,(()=>{const r=new i("cancelled:layerview-create","layerview creation cancelled",{layer:e});this._deferred.reject(r)}))}tryRecycle(e){if(!this.done||!this.layerView||!g(this.layerView))return null;const r=this.layer.type,i=this._controller.signal;for(let t=0;t<e.length;t++){const s=e[t];if(s.type!==r)continue;const a=this.layerView.tryRecycleWith(s,{signal:i});if(a){e.splice(t,1),this.layer=s;const r=this.layerView,i=r.view;return this.promise=Promise.race([a.then((()=>(h(this._controller.signal),s.emit("layerview-destroy",{view:i,layerView:r}),i.emit("layerview-destroy",{view:i,layerView:r}),s.emit("layerview-create",{view:i,layerView:r}),i.emit("layerview-create",{view:i,layerView:r}),r))),new Promise(((e,r)=>y(this._controller.signal,(()=>r(l())))))]),this.promise}}return null}destroy(){this._controller.abort();const{layerView:e}=this;if(e){const{layer:r,view:i}=this;r.emit("layerview-destroy",{view:i,layerView:e}),i.emit("layerview-destroy",{layer:r,layerView:e})}this.done=!0,this.layer=null,this.layerView=null,this.view=null,this.layerViewImporter=null,this._map=null}async start(){if(this._started)return;this._started=!0;const{_controller:{signal:e},layer:r,view:t}=this;this._map=t.map;try{let o,l;if(await r.load({signal:e}),"prefetchResources"in r&&await(r.prefetchResources?.({signal:e})),M(r))o=await r.createLayerView(t,{signal:e});else{if(!this.layerViewImporter.hasLayerViewModule(r))throw new i("layer:view-not-supported","No layerview implementation was found");const s=await this.layerViewImporter.importLayerView(r);h(e),o="default"in s?new s.default({layer:r,view:t}):new s({layer:r,view:t})}const n=()=>{l=a(l),o.destroyed||o.destroy(),o.layer=null,o.parent=null,o.view=null,this.done=!0};l=y(e,n),h(e);try{await o.when()}catch(s){throw n(),s}const c=this._map?.allLayers?.includes(r);if(!c)return n(),void this._deferred.reject(new i("view:no-layerview-for-layer","The layer has been removed from the map",{layer:r}));this.layerView=o,r.emit("layerview-create",{view:t,layerView:o}),t.emit("layerview-create",{layer:r,layerView:o}),this.done=!0,this._deferred.resolve(o)}catch(s){r.emit("layerview-create-error",{view:t,error:s}),t.emit("layerview-create-error",{layer:r,error:s}),this.done=!0,this._deferred.reject(new i("layerview:create-error","layerview creation failed",{layer:r,error:s}))}}}let V=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new u,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=o(),this._workPromise.promise.catch((()=>{}))),this.removeHandles("reschedule"),this.addHandles(d(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{if(this.destroyed)return;const e=this.view.map;if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,i=[],t=this.view.ready,s=e=>{if(null!=e)for(const a of e)if(a){r.add(a);const e=this._layerLayerViewInfoMap.get(a);e&&t?e.start():e||this._recyclingInfoMap.has(a)||i.push(a),"layers"in a&&a.layers&&s(a.layers)}};for(const o of this._rootCollectionNames)s(this.get(o));for(const[o,l]of this._layerLayerViewInfoMap)if(!r.has(o)){this._layerLayerViewInfoMap.delete(l.layer);const e=l.tryRecycle(i);e?(this._recyclingInfoMap.set(l.layer,l),e.then((()=>{this._recyclingInfoMap.delete(l.layer),this._layerLayerViewInfoMap.set(l.layer,l),this._reschedule()})).catch((()=>{this._recyclingInfoMap.delete(l.layer),l.destroy(),this._reschedule()}))):l.destroy()}for(const[o,l]of this._recyclingInfoMap)r.has(o)||(this._recyclingInfoMap.delete(l.layer),l.destroy());for(const o of i)this._createLayerView(o);this._refreshCollections();const a=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.referenceLayers,e?.layers].filter((e=>!!e));r.forEach((e=>"layers"in e&&a.push(e.layers))),this.addHandles(a.map((e=>this._watchUpdatingTracking.addOnCollectionChange((()=>e),this._reschedule))),"collection-change"),this._workPromise.resolve(),this._workPromise=null}}initialize(){this.own([c((()=>this.view?.map?.allLayers),"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),w((()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]}),(()=>this._reschedule()),p)]),this._preloadLayerViewModules(),this._reschedule()}destroy(){this.clear(),_(this._recyclingInfoMap),_(this._layerLayerViewInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(l()),this._workPromise=null)}get _layersToLayerViews(){const e=[["view.map.basemap.baseLayers","view.basemapView.baseLayerViews"],["view.map.layers","view.layerViews"],["view.map.basemap.referenceLayers","view.basemapView.referenceLayerViews"]];return this.supportsGround&&e.push(["view.map.ground.layers","view.groundView.layerViews"]),new Map(e)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||s(this._layerLayerViewInfoMap,(e=>!e.done))}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){this.destroyed||(_(this._layerLayerViewInfoMap),this._refreshCollections())}async whenLayerView(e){if(await this._reschedule(),!this._layerLayerViewInfoMap.has(e)){if(this._recyclingInfoMap.has(e))return this._recyclingInfoMap.get(e).promise;throw new i("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e})}return this._layerLayerViewInfoMap.get(e).promise}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(this.get(e),this.get(r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_populateLayerViewsOwners(e,r,i){if(!e||!r)return void(r&&r.removeAll());let t=0;for(const s of e){const e=this._layerLayerViewInfoMap.get(s);if(!e||!e.layerView)continue;const a=e.layerView;a.layer=s,a.parent=i,r.getItemAt(t)!==a&&r.splice(t,0,a),s.layers&&this._populateLayerViewsOwners(s.layers,a.layerViews,a),t+=1}t<r.length&&r.splice(t,r.length)}_createLayerView(e){e.load().catch((()=>{})),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new v(e,this.view,this.layerViewImporter);r.promise.then((()=>this._refreshCollections()),(r=>{r&&(n(r)||"cancelled:layerview-create"===r.name)||t.getLogger(this.declaredClass).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this._refreshCollections()})),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([m()],V.prototype,"_workPromise",void 0),e([m({readOnly:!0})],V.prototype,"_watchUpdatingTracking",void 0),e([m({readOnly:!0})],V.prototype,"_layersToLayerViews",null),e([m({readOnly:!0})],V.prototype,"_rootCollectionNames",null),e([m()],V.prototype,"layerViewImporter",void 0),e([m()],V.prototype,"supportsGround",void 0),e([m({readOnly:!0})],V.prototype,"updating",null),e([m({readOnly:!0})],V.prototype,"updatingRemaining",null),e([m({constructOnly:!0})],V.prototype,"view",void 0),V=e([f("esri.views.LayerViewManager")],V);const L=V;function M(e){return"createLayerView"in e&&null!=e.createLayerView}export{L as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Camera.js";import"../geometry.js";import i from"../Graphic.js";import r from"../Viewpoint.js";import s from"../core/Collection.js";import{byId as n}from"../core/domUtils.js";import a from"../core/Error.js";import{on as o}from"../core/events.js";import{handlesGroup as l,makeHandle as p}from"../core/handleUtils.js";import has from"../core/has.js";import{isIterable as h}from"../core/iteratorUtils.js";import d from"../core/Logger.js";import{destroyMaybe as c}from"../core/maybe.js";import{ObservableChangesType as u}from"../core/ObservableChangesType.js";import{throwIfAborted as g}from"../core/promiseUtils.js";import{on as m,watch as y,initial as f,syncAndInitial as w,whenOnce as v,sync as _}from"../core/reactiveUtils.js";import{setFrameDuration as b}from"../core/scheduling.js";import{screenPointObjectToArray as M,createScreenPoint as S,createScreenPointArray as C}from"../core/screenUtils.js";import{initialize as R}from"../core/workers/workers.js";import{property as V}from"../core/accessorSupport/decorators/property.js";import{cast as x}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import{subclass as T}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as O,ensureClass as j}from"../core/accessorSupport/ensureType.js";import{c as E}from"../chunks/vec3f64.js";import{owningCollectionProperty as I}from"../core/support/OwningCollection.js";import L from"../geometry/HeightModelInfo.js";import{projectPointToVector as P,projectVectorToVector as H,canProjectWithoutEngine as A,project as G,projectBoundingRect as U}from"../geometry/projection.js";import{create as D,toExtent as F}from"../geometry/support/aaBoundingRect.js";import{B as W,c as k}from"../chunks/boundedPlane.js";import{renderSRFromViewSR as q}from"../geometry/support/coordinateSystem.js";import{getResolutionForScale as z}from"../geometry/support/scaleUtils.js";import{fallbackObjectIDAttribute as B}from"../layers/LayerConstants.js";import{isImageryTileLayer as N,isTiledLayer as Q,isVoxelLayer as $}from"../layers/support/layerUtils.js";import{AnalysesCollection as X}from"../support/AnalysesCollection.js";import{BreakpointsOwner as Y}from"./BreakpointsOwner.js";import{DOMContainer as Z}from"./DOMContainer.js";import J from"./GroundView.js";import{PopupView as K}from"./PopupView.js";import ee from"./View.js";import te from"./ViewAnimation.js";import{ViewingMode as ie,stringFromViewingMode as re,viewingModeFromString as se}from"./ViewingMode.js";import{layerView3DImporter as ne}from"./3d/layerViewModuleImportUtils.js";import ae from"./3d/analysis/AnalysisViewManager3D.js";import{Constraints as oe}from"./3d/constraints/Constraints.js";import le from"./3d/environment/SceneViewEnvironment.js";import{SceneViewEnvironmentManager as pe}from"./3d/environment/SceneViewEnvironmentManager.js";import he from"./3d/input/SceneInputManager.js";import{GraphicsDeconflictor as de}from"./3d/layers/graphics/GraphicsDeconflictor.js";import{Labeler as ce}from"./3d/layers/graphics/Labeler.js";import{FeatureTileTree3D as ue}from"./3d/layers/support/FeatureTileTree3D.js";import ge from"./3d/state/ViewState.js";import{ViewStateManager as me}from"./3d/state/ViewStateManager.js";import{SceneIntersectionHelper as ye}from"./3d/state/helpers/SceneIntersectionHelper.js";import{CombinedElevationProvider as fe}from"./3d/support/CombinedElevationProvider.js";import we from"./3d/support/debugFlags.js";import ve from"./3d/support/DisplayQualityProfile.js";import{getElevationAtPoint as _e}from"./3d/support/ElevationProvider.js";import be from"./3d/support/HighlightOptions.js";import{MapCoordsHelper as Me}from"./3d/support/MapCoordsHelper.js";import{PropertiesPool as Se}from"./3d/support/PropertiesPool.js";import Ce from"./3d/support/QualitySettings.js";import{RenderCoordsHelper as Re}from"./3d/support/RenderCoordsHelper.js";import{newResourceController as Ve}from"./3d/support/ResourceController.js";import xe from"./3d/support/SceneViewPerformanceInfo.js";import{SharedSymbolResources as Te}from"./3d/support/SharedSymbolResources.js";import{PointsOfInterest as Oe}from"./3d/support/pointsOfInterest/PointsOfInterest.js";import je from"./3d/terrain/TerrainSurface.js";import{isSurfaceLayerView as Ee,getTiledLayerInfo as Ie,checkIfTileInfoSupportedForView as Le}from"./3d/terrain/terrainUtils.js";import{Stage as Pe}from"./3d/webgl-engine/Stage.js";import{newIntersector as He,DEFAULT_TOLERANCE as Ae}from"./3d/webgl-engine/lib/Intersector.js";import{StoreResults as Ge,IntersectorType as Ue}from"./3d/webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as De}from"./3d/webgl-engine/lib/intersectorUtils.js";import{toHit as Fe,toOwner as We}from"./3d/webgl-engine/lib/intersectorUtilsConversions.js";import{TERRAIN_ID as ke}from"./3d/webgl-engine/lib/verticalOffsetUtils.js";import{hitTestSelectSimilarDistance as qe}from"./support/hitTestSelectUtils.js";import{occludeesSupported as ze}from"./support/layerViewUtils.js";import{RenderState as Be}from"./support/RenderState.js";import{encode as Ne,encodeData as Qe,toRenderSettings as $e,screenshotSuperSampleSettings as Xe}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as Ye,createScreenPointFromSupportedEvent as Ze}from"./support/screenUtils.js";import{isSpatialReferenceSupported as Je}from"./support/spatialReferenceSupport.js";import{check as Ke}from"./support/WebGLRequirements.js";import et from"./ui/DefaultUI.js";import tt from"./ui/3d/DefaultUI3D.js";import it from"../webscene/Environment.js";import rt from"../geometry/Extent.js";import st from"../geometry/SpatialReference.js";import nt from"../geometry/Point.js";let at=class extends(Y(Z(K(ee)))){constructor(e){super(e),this._userClippingArea=null,this._clippingArea=null,this._initialDefaultSpatialReference=null,this._defaults={},this._externallySet={environment:!1},this._createGraphicsViewController=null,this._resolveWhenReady=[],this._propertiesPool=new Se({slicePlane:W},this),this._resourceController=Ve(this),this._defaultToMapOptions={include:new Set},this._defaultHitTestOptions={exclude:new Set},this.deconflictor=new de({view:this}),this.labeler=new ce({view:this,deconflictor:this.deconflictor.labels}),this.sharedSymbolResources=null,this.analyses=new X,this.basemapTerrain=null,this.elevationProvider=null,this.canvas=null,this.constraints=new oe,this.environmentManager=new pe,this.floors=new s,this.fullOpacity=1,this.graphicsView=null,this.analysisViewManager=new ae({view:this}),this.groundView=null,this.map=null,this.screenSizePerspectiveEnabled=!0,this.state=new ge,this.spatialReference=null,this.alphaCompositingEnabled=!1,this.preserveDrawingBufferEnabled=!1,this.supersampleScreenshotsEnabled=!0,this.type="3d",this.ui=new tt,this._numUpdating=0,this._lastUpdateTime=0,this.updatingProgress=.5,this.highlightOptions=new be,this.voxelWasm=null,this.voxelWasmPromise=null,R(),e&&e.environment||(this._defaults.environment=new le,this.environment=this._defaults.environment);const t=(e=null)=>{null!=e&&e.type===u.MOVE||(this._updatingChanged(),this.map&&this.map.allLayers.forEach((async e=>{try{await e.when()}catch{}this._updatingChanged()})))};this.addHandles([m((()=>this.map?.allLayers),"after-changes",(e=>t(e)),{onListenerAdd:()=>t(),onListenerRemove:()=>t(),sync:!0}),this.allLayerViews.on("after-changes",(e=>this._updateUpdatingMonitors(e))),y((()=>this.map),(e=>{e&&"load"in e&&e.load&&e.load().catch((()=>{}))}))]),this.inputManager=new he({view:this}),this.stateManager=new me({view:this})}initialize(){this.groundView=new J({view:this}),this._updateUpdatingMonitors();const e=()=>this._updateDefaultToMapOptions();this.addHandles(m((()=>this.map?.allLayers),"after-changes",e,{onListenerAdd:e,onListenerRemove:e})),this.updatingHandles.add((()=>this.qualitySettings.memoryLimit),(e=>{this.resourceController&&(this.resourceController.memoryController.maxMemory=e)}),f),this.updatingHandles.add((()=>this.qualitySettings.additionalCacheMemory),(e=>{this.resourceController&&(this.resourceController.memoryController.additionalCacheMemory=e)}),f),this.updatingHandles.add((()=>this.qualitySettings.frameRate??0),(e=>b(e>0?1e3/Math.ceil(e):0)),f),this.updatingHandles.add((()=>this.map?.ground),e,w),this.updatingHandles.add((()=>this.map?.ground?.opacity),(()=>this._updateDefaultHitTestOptions()),w),this.addHandles(y((()=>this.spatialReference),(()=>this.notifyChange("clippingArea")),_))}destroy(){this.destroyed||(this.updatingHandles.removeAll(),this.removeAllHandles(),this.invalidate(),this.activeTool=null,this.layerViewManager.clear(),this.environmentManager.destroy(),this._exitSurface(),this._disposeGraphicsView(),this.sharedSymbolResources=c(this.sharedSymbolResources),this._set("labeler",c(this.labeler)),this._set("deconflictor",c(this.deconflictor)),this._resourceController=c(this._resourceController),this._set("stateManager",c(this.stateManager)),this._set("inputManager",c(this.inputManager)),this.state.destroy(),this._propertiesPool.destroy(),this.removeHandles("updatingMonitors"),this._set("environmentManager",c(this.environmentManager)),this.groundView=c(this.groundView),this._exitBasemapTerrain(),this._stage?.destroy(),this.removeAllHandles(),this.updatingHandles.removeAll(),this.handles.removeAll())}get renderSpatialReference(){return this.renderCoordsHelper&&this.renderCoordsHelper.spatialReference}get basemapSpatialReference(){return this.basemapTerrain?.spatialReference}get animation(){return this.state?.animation}get camera(){return this.stateManager?.camera}set camera(e){this.stateManager&&(this.stateManager.camera=e)}get contentCamera(){return this.stateManager?.contentCamera}set contentCamera(e){this.stateManager&&(this.stateManager.contentCamera=e)}installContentCameraReset(e={sticky:!1}){return this.stateManager.installContentCameraReset(e)}get center(){return this.stateManager?.center}set center(e){this.stateManager&&(this.stateManager.center=e)}get clippingArea(){if("global"===this.viewingMode)return null;let e=this._userClippingArea||("clippingArea"in this.map?this.map?.clippingArea:void 0);return!this._userClippingArea&&!this.get("map.clippingEnabled")||null==e?(this._clippingArea=null,null):e instanceof rt?this.spatialReference&&(e=pt(e,this.spatialReference),null==e)?(d.getLogger(this.declaredClass).error("#clippingArea","setting clippingArea with incompatible SpatialReference"),this._clippingArea):(e=e.clone(),null==e.intersection(this._groundAndLayersExtent)&&(e.xmin=e.xmax,e.ymin=e.ymax),e.zmin=void 0,e.zmax=void 0,e.equals(this._clippingArea)||(this._clippingArea=e),this._clippingArea):(d.getLogger(this.declaredClass).error("#clippingArea","only clippingArea geometries of type Extent are supported"),this._clippingArea)}set clippingArea(e){this.ready&&"global"===this.viewingMode&&null!=e?d.getLogger(this.declaredClass).error("#clippingArea=","Clipping area is only supported in local viewingMode"):this._userClippingArea=e}get renderDataExtent(){if(this.state.viewingMode===ie.Global)return null;const e=this.renderSpatialReference,t=this.dataExtent;return null==t||null==e||t.spatialReference.equals(e)?t:pt(t,e)}get dataExtent(){let e=this._groundAndLayersExtent;const t=this.spatialReference||st.WGS84,i=pt(this.clippingArea,t);null!=i&&(e=null!=e?e.intersection(i):i);const r=this._get("dataExtent");return null!=e&&e.equals(r)?r:e}get _groundAndLayersExtent(){const e=this.spatialReference||st.WGS84;let t;const i=i=>{const r=pt(i,e);null!=r&&(null!=t?t.union(r):t=r.clone())},r=this.basemapTerrain;if(r?.spatialReference){const e=r.groundExtent;i(new rt({xmin:e[0],ymin:e[1],zmin:0,xmax:e[2],ymax:e[3],zmax:0,spatialReference:r.spatialReference}))}if(this.map){const e=e=>{null==e.fullExtent||"graphics"===e.type&&e.internal||i(e.fullExtent)};this.map.allLayers.forEach((t=>e(t)))}if(null==t)return null;t.hasZ?(t.zmin=Math.min(0,t.zmin??0),t.zmax=Math.max(0,t.zmax??0)):(t.zmin=0,t.zmax=0);const s=this._get("_groundAndLayersExtent");return t.equals(s)?s:t}set environment(e){e!==this._defaults.environment&&(this._externallySet.environment=!0),this._set("environment",e)}castEnvironment(e){return e?e instanceof le?e:e instanceof it?null!=this.environment?this.environment.cloneWithWebsceneEnvironment(e):le.fromWebsceneEnvironment(e):O(le,e):new le}get extent(){return this.stateManager?.extent}set extent(e){this.stateManager&&(this.stateManager.extent=e)}get screenCenter(){return this.stateManager?.screenCenter}get frustum(){return this.stateManager?.frustum}get initialExtentRequired(){return this.stateManager&&!this.stateManager.hasInitialView}get _defaultsFromMapSettings(){return{required:{tileInfo:!1,heightModelInfo:!0,extent:!1}}}get interacting(){return this.navigating||this.toolViewManager?.interacting}get stationary(){return!this.animation&&!this.resizing&&(null==this.state||this.state.stationary)}get navigating(){return this.state?.navigating??!1}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}set qualityProfile(e){ve.isValidProfile(e)&&(ve.apply(e,this.qualitySettings),this._set("qualityProfile",e))}get qualityProfile(){return this._get("qualityProfile")||ve.getDefaultProfile()}set slicePlane(e){if(null!=this._stage&&this._stage.renderer.setParameters({slicePlane:e}),null==e)return void this._set("slicePlane",null);const t=this._propertiesPool.get("slicePlane");k(e,t),this._set("slicePlane",t)}get typeSpecificPreconditionsReady(){return!!this.viewingMode}get resolution(){return null!=this.spatialReference?z(this.scale,this.spatialReference):0}get scale(){return this.stateManager?.scale}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get heightModelInfo(){const e=this.getDefaultHeightModelInfo();return null!=e?L.deriveUnitFromSR(e,this.spatialReference):null}get updating(){if(this.destroyed)return!1;let e=0,t=this.layerViewManager.updating,i=t?this.layerViewManager.updatingRemaining:0;this.allLayerViews.forEach((r=>{if(r.isFulfilled()){if(r.updating){if(t=!0,r.suspended||Ee(r))return;++i,e+=r.updatingProgress}}else++i}));for(const s of[this.graphicsView,this.basemapView,this._resourceController,this._stage,this.featureTiles,this.pointsOfInterest,this.environmentManager,this.overlay,this._featureTreeDebugger,this.toolViewManager,this.analysisViewManager])if(null!=s&&s.updating){const t=.1;i+=t,e+=.5*t}for(const s of[this.deconflictor,this.labeler,this.basemapTerrain])null!=s&&s.updating&&(++i,e+=s.updatingProgress);const r=this.stateManager.test.updatingIgnoreRenderState?Be.IDLE:this.state.mode;if(t=!!(t||i>0||this.updatingHandles.updating||!this.ready||!this.stationary||r!==Be.IDLE||this._createGraphicsViewController||this.inputManager?.hasPendingInputs||this.map?.allLayers?.some((e=>!e.isFulfilled()))),t?(this._numUpdating=Math.max(i,this._numUpdating),e+=this._numUpdating-i):this._numUpdating=0,this._numUpdating>0?e/=this._numUpdating:e=t?0:1,this._get("updatingProgress")!==e){const i=performance.now();if(e<1){const t=Math.min((i-this._lastUpdateTime)/2e3,1);e=this.updatingProgress*(1-t)+e*t}this._set("updatingProgress",e),this._lastUpdateTime=t&&e<1?i:0}return t}get viewingMode(){const e=this._predeterminedViewingMode;if(null!=e)return re(e);const t=this.spatialReference;return t?null!=this.defaultsFromMap?.viewingMode&&t.equals(this.defaultsFromMap.spatialReference)?re(this.defaultsFromMap.viewingMode):Je(t,ie.Global)?"global":"local":"global"}set viewingMode(e){this.ready?d.getLogger(this.declaredClass).error("#viewingMode","viewingMode cannot be set once view is ready"):this._overrideIfSome("viewingMode",e)}get viewpoint(){return this.stateManager?.viewpoint}set viewpoint(e){this.stateManager&&(this.stateManager.viewpoint=e)}get zoom(){return this.stateManager.zoom}set zoom(e){this.stateManager&&(this.stateManager.zoom=e)}get resourceController(){return this._resourceController}get performanceInfo(){return new xe(this)}on(e,t,i,r){const s=this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}toMap(e,t){if(!this.ready)return d.getLogger(this.declaredClass).error("#toMap()","Scene view cannot be used before it is ready"),null;const i=t?this.externalToInternalIntersectOptions(t):this._defaultToMapOptions,r=null!=i.graphics&&(null!=i.graphics.include||null!=i.graphics.exclude),s=Ye(e)?Ze(this,e):e,n=M(s);i.enableDraped=i.include&&!i.include.has(ke)||i.exclude&&i.exclude.has(ke);const a=this.sceneIntersectionHelper,o=He(this.state.viewingMode);if(o.options.selectionMode=!0,o.options.store=r?Ge.ALL:Ge.MIN,a.intersectIntersectorScreen(n,o,i),r){for(const e of o.results.all){const t=Fe(e,this);if(null==t)return this._intersectResultToMapPoint(e);if("graphic"!==t.type||this._testGraphicUidFilter(i.graphics,t.graphic))return this._intersectResultToMapPoint(e)}return null}return this._intersectResultToMapPoint(o.results.min)}toScreen(e){if(!this.ready)return d.getLogger(this.declaredClass).error("#toScreen()","Scene view cannot be used before it is ready"),null;const t=(null==e.z?_e(this.elevationProvider,e):null)??0;return P(e,dt,this.renderSpatialReference,t),this.state.camera.projectToScreen(dt,ct),S(ct[0],ct[1])}pixelSizeAt(e){return this.ready?e?(P(e,dt,this.renderSpatialReference),this.state.camera.computeScreenPixelSizeAt(dt)):0:(d.getLogger(this.declaredClass).error("#pixelSizeAt()","Scene view cannot be used before it is ready"),null)}overlayPixelSizeInMapUnits(e){const t=this.basemapTerrain.overlayManager;return t?t.overlayPixelSizeInMapUnits(e):1}hitTest(e,t){if(!this.ready)return d.getLogger(this.declaredClass).error("#hitTest()","Scene view cannot be used before it is ready"),null;const i=Ye(e)?Ze(this,e):e,r=C(i.x,i.y),s=t?this.externalToInternalIntersectOptions(t):this._defaultHitTestOptions;s.requiresGroundFeedback=!0,s.enableDraped=!0;const n=He(this.state.viewingMode);n.options.selectionMode=!0,n.options.store=Ge.ALL,this.sceneIntersectionHelper.intersectIntersectorScreen(r,n,s);const a=this._intersectResultsToHits(n.results.all,s.graphics),o=n.results.ground,l=We(o,this),p=null!=l&&"type"in l&&"integrated-mesh"===l.type?l:null,h={screenPoint:i,results:a,ground:{mapPoint:this._intersectResultToMapPoint(o),distance:De(o)?o.distanceInRenderSpace:0,layer:p}};return we.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(h.intersector=n),Promise.resolve(h)}async popupHitTest(e){const{results:t,ground:i}=await qe(this,e);let r=null;return!(0===t.length||Math.abs((t[0].distance??0)-i.distance)<1e-5)||i.layer&&"integrated-mesh"===i.layer.type||(r=i.mapPoint),{results:t,screenPoint:e,mapPoint:r}}goTo(e,t){return this.updatingHandles.addPromise(this.stateManager.goTo(e,t))}async whenAnalysisView(e){if(null==e.parent)throw new a("view:no-analysisview-for-analysis","The analysis has not been added to view.analyses",{analysis:e});switch(e.parent.type){case"line-of-sight":case"dimension":return(await this.whenLayerView(e.parent)).whenAnalysisView();default:return this.analysisViewManager.whenAnalysisView(e)}}whenLayerView(e){return super.whenLayerView(e)}async takeScreenshot(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshot(t);return Ne(i,t,this._pixelFormat())}async _takeScreenshot(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshot(t);return Qe(i,this._pixelFormat())}async _takeScreenshotWithObjectAndLayerId(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshotWithOID(t);return[Qe(i[0],this._pixelFormat()),Qe(i[1],this._pixelFormat())]}_completeSettings(e){const t=$e(e,this);return t.pixelRatio/=this.state.pixelRatio,Xe(t,this.supersampleScreenshotsEnabled,this.padding)}_pixelFormat(){return{flipY:!0,premultipliedAlpha:this._stage.renderView.getAlpha()}}get test(){return{takeScreenshot:e=>this._takeScreenshot(e),takeScreenshotWithObjectAndLayerId:e=>this._takeScreenshotWithObjectAndLayerId(e)}}async takeScreenshotWithObjectAndLayerId(e){if(!has("enable-feature:objectAndLayerId-rendering"))throw new Error("has enable-feature:objectAndLayerId-rendering must be true");const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshotWithOID(t),r=Ne(i[0],t,this._pixelFormat()),s=this._completeSettings(e);s.format="png";return[r,Ne(i[1],s,this._pixelFormat())]}getColorToObjectAndLayerIdMapping(){if(null==this._stage.renderView.objectAndLayerIdRenderHelper)throw new Error("has enable-feature:objectAndLayerId-rendering must be true");return this._stage.renderView.objectAndLayerIdRenderHelper.getColorToObjectAndLayerIdMapping()}addUpdatingPromise(e){return this.updatingHandles.addPromise(e)}importLayerView(e){return ne.importLayerView(e)}hasLayerViewModule(e){return ne.hasLayerViewModule(e)}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map?.initialViewProperties?.spatialReference||this.defaultsFromMap?.spatialReference||this.defaultsFromMap?.ready&&this._initialDefaultSpatialReference||null}async validate(){let e=Ke(this.type);const t=has("safari");if(t&&t<9&&(e=new a("sceneview:browser-not-supported","This browser is not supported by SceneView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:t})),null!=e)throw d.getLogger(this.declaredClass).warn("#validate()",e.message),e}get _predeterminedViewingMode(){const e=this._isOverridden("viewingMode")?this._get("viewingMode"):(this.map&&"initialViewProperties"in this.map?this.map.initialViewProperties?.viewingMode:null)??null;return null!=e?se(e):null}getSpatialReferenceSupport({spatialReference:e,layer:t}){const i=this._predeterminedViewingMode;if(null!=i)return this._validateSpatialReferenceForViewingMode(e,t,i)?{constraints:this._makeSpatialReferenceConstraints(e,t,i)}:null;const r=this._validateSpatialReferenceForViewingMode(e,t,ie.Local),s=this._validateSpatialReferenceForViewingMode(e,t,ie.Global);return r||s?r&&s?{constraints:this._makeSpatialReferenceConstraints(e,t,null)}:r?{constraints:this._makeSpatialReferenceConstraints(e,t,ie.Local)}:{constraints:this._makeSpatialReferenceConstraints(e,t,ie.Global)}:null}_validateSpatialReferenceForViewingMode(e,t,i){return!!Je(e,i)&&(null==t||(!!N(t)||(!Q(t)||null!=Ie(t,e,i))&&(!$(t)||i!==ie.Global)))}_makeSpatialReferenceConstraints(e,t,i){if(null==t)return[{spatialReference:e,viewingMode:i}];const r=e.isWebMercator,s=e.isWGS84;if(N(t)&&(r||s)){return!s||i===ie.Local||null===Le(t.tileInfo,t.fullExtent,e,ie.Global)?[{spatialReference:e,viewingMode:i},{spatialReference:st.WebMercator,viewingMode:i}]:[{spatialReference:r?st.WGS84:st.WebMercator,viewingMode:i}]}return Q(t)||$(t)||!r&&!s?Q(t)&&r&&i!==ie.Global?[{spatialReference:e,viewingMode:i},{spatialReference:st.WGS84,viewingMode:ie.Local}]:[{spatialReference:e,viewingMode:i}]:[{spatialReference:e,viewingMode:i},{spatialReference:r?st.WGS84:st.WebMercator,viewingMode:i}]}_validateSpatialReference(e){const t=null!=this.getSpatialReferenceSupport({spatialReference:e}),i=this._predeterminedViewingMode;return t||(null!=i?d.getLogger(this.declaredClass).warnOnce(`Spatial reference defined on view not supported in ${re(i)} viewing mode.`):e.isGeographic&&d.getLogger(this.declaredClass).warnOnce("Spatial reference is geographic but not supported.")),t}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}computeMapPointFromVec3d(e,t){let i=this.spatialReference||st.WGS84;return H(e,this.renderSpatialReference,e,i)||(i=st.WGS84,H(e,this.renderSpatialReference,e,i)),t?(t.x=e[0],t.y=e[1],t.z=e[2],t.spatialReference=i):t=new nt(e,i),t}trackGraphicState(e){if(!e.graphic)return d.getLogger(this.declaredClass).error("trackGraphicState","GraphicState.graphic must not be null or undefined to start tracking"),null;const t=this.getViewForGraphic(e.graphic);let i=null,r=!1;const s=t=>{!r&&null!=t&&"processor"in t&&"graphics-3d"===t.processor?.type&&t.processor.graphicsCore&&(i=t.processor.graphicsCore.trackGraphicState(e))};return null!=t?s(t):this.whenViewForGraphic(e.graphic,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,null!=i&&(i.remove(),i=null)}}}highlight(e){if(Array.isArray(e))return l(e.map((e=>this.highlight(e))));if(s.isCollection(e))return l(e.toArray().map((e=>this.highlight(e))));const t=this.getViewForGraphic(e);return t&&"highlight"in t?t.highlight(e):p()}maskOccludee(e){if(!e)return d.getLogger(this.declaredClass).error("maskOccludee","GraphicState.graphic must not be null or undefined to mask an occludee"),null;const t=this.getViewForGraphic(e);let i=null,r=!1;const s=t=>{!r&&null!=t&&ze(t)&&(i=t.maskOccludee(e))};return null!=t?s(t):this.whenViewForGraphic(e,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,null!=i&&(i.remove(),i=null)}}}getViewForGraphic(e){return e.layer===this.graphics?this.graphicsView:e.layer?this.allLayerViews.find((t=>t.layer===e.layer)):null}graphicChanged(e){null!=this.graphicsView&&this.graphicsView.graphicChanged(e)}async whenViewForGraphic(e,t){if(e.layer===this)return await v((()=>this.graphicsView)),this.graphicsView;if(!e.layer||!this.map)throw new a("no-view-for-graphic");return t&&t.waitForLayer&&!this.map.allLayers.includes(e.layer)?new Promise(((t,i)=>{const r=this.map.allLayers.on("change",(s=>{s.added.includes(e.layer)&&(r.remove(),this.whenLayerView(e.layer).then(t,i))}))})):this.whenLayerView(e.layer)}externalToInternalIntersectOptions(e){const t=this._externalToInternalRenderItems(e.include,ht.INCLUDE),i=this._externalToInternalRenderItems(e.exclude,ht.EXCLUDE);return{include:t.layerUids,exclude:i.layerUids,graphics:{include:t.graphicUids,exclude:i.graphicUids}}}_intersectResultToMapPoint(e,t){return e.getIntersectionPoint(dt)?(t=this.computeMapPointFromVec3d(dt,t),e.intersector===Ue.TERRAIN&&this.basemapTerrain&&(t.z=_e(this.basemapTerrain,t)??0),t):null}_intersectResultsToHits(e,t){const i=new Array;let r=null;for(let s=0;s<e.length;s++){const n=e[s],a=We(n,this);if(null!=a&&(a===this.map.ground||"type"in a&&"integrated-mesh"===a.type))break;const o=Fe(n,this);if(null==o)continue;if("graphic"===o.type){if(null==r&&s!==e.length-1&&(r=new Set),null!=r){const e=this._getGraphicFilterUid(o.graphic);if(r.has(e))continue;r.add(e)}if(!this._testGraphicUidFilter(t,o.graphic))continue}const l=this._intersectResultToMapPoint(n),p=n.distanceInRenderSpace;i.push({...o,mapPoint:l,distance:p})}return i}_getGraphicFilterUid(e){const t=e.sourceLayer,i=e.layer,r=t&&"objectIdField"in t?t:i&&"objectIdField"in i?i:t;if(r){const t=r.objectIdField??B,i=e.attributes?.[t];if(i)return`o-${r.id}-${i}`}return`u-${e.uid}`}_testGraphicUidFilter(e,t){const i=this._getGraphicFilterUid(t);return null==e||(null==e.include||e.include.has(i))&&(null==e.exclude||!e.exclude.has(i))}_externalToInternalRenderItems(e,t,r={layerUids:void 0,graphicUids:void 0}){if(!e)return r;if(e instanceof i)lt(r,this._getGraphicFilterUid(e)),t===ht.INCLUDE&&(null!=this.graphicsView&&e.layer===this?ot(r,this.graphicsView.processor.layer.id):e.layer&&ot(r,e.layer.uid));else if(h(e))for(const i of e)i===this.graphics&&null!=this.graphicsView?ot(r,this.graphicsView.processor.layer.id):i===this.map.ground?ot(r,ke):this._externalToInternalRenderItems(i,t,r);else"uid"in e&&ot(r,e.uid);return r}_initBasemapTerrain(){this._set("basemapTerrain",new je({view:this})),this._set("elevationProvider",new fe({view:this})),this.elevationProvider.register("ground",this.basemapTerrain)}_exitBasemapTerrain(){this.basemapTerrain&&(this.elevationProvider.unregister(this.basemapTerrain),this.elevationProvider.destroy(),this._set("elevationProvider",null),this.basemapTerrain.destroy(),this._set("basemapTerrain",null))}_initGlobe(){this._initCoordinateSystem(),this.state.createInitialCamera(),this._initBasemapTerrain(),this._set("pointsOfInterest",new Oe({view:this})),this._set("featureTiles",new ue({renderCoordsHelper:this.renderCoordsHelper,cameraOnSurface:this.pointsOfInterest.cameraOnSurface,focus:this.pointsOfInterest.focus,tilingSchemeOwner:this.basemapTerrain,viewState:this.state,scheduler:this._resourceController.scheduler,terrain:this.basemapTerrain}));const e=()=>{const e=this.basemapTerrain?.extent;if(this.clippingArea||e)if(e&&this.basemapTerrain.spatialReference){const e=null!=this.basemapTerrain.extent&&null!=this.basemapTerrain.spatialReference?G(F(this.basemapTerrain.extent,this.basemapTerrain.spatialReference),this.spatialReference):null;null!=this.clippingArea?this.featureTiles.filterExtent=this.clippingArea.intersection(e):this.featureTiles.filterExtent=e}else this.featureTiles.filterExtent=this.clippingArea;else this.featureTiles.filterExtent=null};this.addHandles([this.updatingHandles.add((()=>we.FEATURE_TILE_TREE_SHOW_TILES),(e=>{e&&this.featureTiles&&!this._featureTreeDebugger?this.updatingHandles.addPromise(import("./3d/layers/support/FeatureTileTree3DDebugger.js")).then((({FeatureTileTree3DDebugger:e})=>{!this._featureTreeDebugger&&we.FEATURE_TILE_TREE_SHOW_TILES&&(this._featureTreeDebugger=new e({view:this}))})):e||!this._featureTreeDebugger||we.FEATURE_TILE_TREE_SHOW_TILES||(this._featureTreeDebugger.destroy(),this._featureTreeDebugger=null)}),w),this.updatingHandles.add((()=>this.clippingArea),e,w),this.updatingHandles.add((()=>this.basemapTerrain.extent),e,w)],"feature-tiles"),this.stateManager.init()}_exitGlobe(){this.state&&(this.stateManager.exit(),this.removeHandles("render-coords-helper"),this.removeHandles("feature-tiles"),this.featureTiles.destroy(),this._set("featureTiles",null),this.pointsOfInterest.destroy(),this._set("pointsOfInterest",null),this._exitBasemapTerrain(),this.state.exit(),this._exitCoordinateSystem())}_initCoordinateSystem(){if(this.spatialReference){const e=this.spatialReference;this.mapCoordsHelper&&this.mapCoordsHelper.spatialReference.equals(e)||this._set("mapCoordsHelper",new Me(this.map,e));const t=this.state.isGlobal,i=q(t,e);i!==this.renderSpatialReference&&(this._set("renderCoordsHelper",Re.create(this.state.viewingMode,i)),t||this.addHandles(y((()=>this.basemapTerrain?.extent),(e=>{const t=this.renderCoordsHelper.spatialReference;null==e||0===e[0]&&0===e[1]&&0===e[2]&&0===e[3]||!U(e,this.basemapTerrain.spatialReference,ut,t)||(this.renderCoordsHelper.extent=ut)}),_),"render-coords-helper"),this.sceneIntersectionHelper&&this.sceneIntersectionHelper.setTolerance(Ae/this.renderCoordsHelper.unitInMeters))}else this._set("mapCoordsHelper",null),this._set("renderCoordsHelper",null)}_exitCoordinateSystem(){this.mapCoordsHelper&&(this.removeHandles("render-coords-helper"),this._set("renderCoordsHelper",null),this._set("mapCoordsHelper",null))}_updatingChanged(){this.notifyChange("updating")}_updateUpdatingMonitors(e=null){null!=e&&e.type===u.MOVE||(this.removeHandles("updatingMonitors"),this.allLayerViews.forEach((e=>{e.destroyed||(this.addHandles(y((()=>[e.updating,e.updatingProgress]),(()=>this._updatingChanged()),_),"updatingMonitors"),e.when((()=>this._updatingChanged()),(()=>this._updatingChanged())))})),this._updatingChanged())}async _prepareScreenshotOverlay(){this.overlay&&await this.overlay.prepare()}_renderScreenshotOverlay(e,t){if(!this.overlay||!this.overlay.hasVisibleItems)return t;const i=e.getContext("2d");return i.putImageData(t,0,0),this.overlay.renderCanvas(e),i.getImageData(0,0,t.width,t.height)}_initStage(){const e={deactivatedWebGLExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions,alpha:this.alphaCompositingEnabled,preserveDrawingBuffer:this.preserveDrawingBufferEnabled,canvas:this.renderCanvas,screenshot:{prepareOverlay:()=>this._prepareScreenshotOverlay(),renderOverlay:(e,t)=>this._renderScreenshotOverlay(e,t)}},t=new ye(this.state.viewingMode,(e=>this._stage.layers.forAll(e)),this);this._set("sceneIntersectionHelper",t);const i=n(this.surface);this._stage=new Pe({view:this,options:e,container:i}),this._stage.renderer.setParameters({slicePlane:this.slicePlane}),this.addHandles([this.updatingHandles.add((()=>this.qualitySettings.antialiasingEnabled),(()=>this._stage.renderer.setParameters({antialiasingEnabled:this.qualitySettings.antialiasingEnabled})),f),this.updatingHandles.add((()=>this.qualitySettings.highQualityTransparency),(e=>this._stage.renderer.setParameters({highQualityTransparency:e})),f),y((()=>this.magnifier),(e=>this._stage.renderView.magnifier=e),w),this.on("pointer-move",(()=>this._stage?.renderer.resetAnimation())),o(this._stage.renderView.canvas,"webglcontextlost",(e=>this.fatalError=new a("webgl-context-lost",e.statusMessage)))],"stage");const r=()=>{this._stage.renderer.setParameters({defaultHighlightOptions:be.toEngineOptions(this.highlightOptions)})};this.addHandles(this.updatingHandles.add((()=>[this.highlightOptions.color,this.highlightOptions.haloColor,this.highlightOptions.haloOpacity,this.highlightOptions.fillOpacity,this.highlightOptions.shadowOpacity,this.highlightOptions.shadowColor,this.highlightOptions.shadowDifference]),r),"stage"),r(),this.renderCoordsHelper&&this.sceneIntersectionHelper.setTolerance(Ae/this.renderCoordsHelper.unitInMeters),this._set("canvas",this._stage.renderView.canvas)}_exitStage(){this._set("sceneIntersectionHelper",null),this._stage=c(this._stage),this.removeHandles("stage"),this._set("canvas",null)}_initSurface(e){this._exitSurface(),this.state.init(e,this.spatialReference),this._initStage(),this._initGlobe(),this.sharedSymbolResources=new Te({view:this,viewingMode:e,resourceController:this._resourceController,pointsOfInterest:this.pointsOfInterest,viewState:this.state})}_exitSurface(){this.sharedSymbolResources&&(this.sharedSymbolResources.objectResourceCache.destroy(),this.sharedSymbolResources.destroy(),this.sharedSymbolResources=null,this._exitGlobe(),this._exitStage())}_createGraphicsViewIfNeeded(){if(this.graphicsView||this._createGraphicsViewController)return;if(0===this.graphics.length)return;this.removeHandles("graphics-view"),this._createGraphicsViewController=new AbortController;const e=()=>{this._createGraphicsViewController=null,this._updatingChanged()};this._createGraphicsViewAsync(this._createGraphicsViewController.signal).then(e,e),this._updatingChanged()}async _createGraphicsViewAsync(e){const t=(await import("./3d/layers/GraphicsView3D.js")).default;g(e),await v((()=>this.basemapTerrain?.ready),e),this._set("graphicsView",new t({view:this}))}_disposeGraphicsView(){this._createGraphicsViewController&&(this._createGraphicsViewController.abort(),this._createGraphicsViewController=null),this.removeHandles("graphics-view"),null!=this.graphicsView&&(this.removeHandles(this.graphicsView.processor.layer.id),this.graphicsView.destroy(),this._set("graphicsView",null))}_startup(){const e=se(this.viewingMode);if(e===ie.Global&&(this._clippingArea=null),this._initSurface(e),this._set("ready",!0),this.addHandles(m((()=>this.graphics),"after-changes",(()=>this._createGraphicsViewIfNeeded())),"graphics-view"),this._createGraphicsViewIfNeeded(),!this._externallySet.environment){const e=this.get("map.initialViewProperties.environment");e&&(this.environment=e)}this.labeler.setup(),this.environmentManager.connectView(this),this.inputManager.connect();const t=this._resolveWhenReady;this._resolveWhenReady=[],t.forEach((e=>e(this)))}_teardown(){this._initialDefaultSpatialReference=null,this.inputManager.disconnect(),this.environmentManager.disconnectView(),this.labeler.dispose(),this._disposeGraphicsView(),this.removeHandles("graphics-view"),this._exitSurface(),this._set("ready",!1)}_updateDefaultToMapOptions(){if(this._defaultToMapOptions.include.clear(),this.map){this.map.ground&&this._defaultToMapOptions.include.add(ke);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&this._defaultToMapOptions.include.add(e.uid)}}_updateDefaultHitTestOptions(){if(this._defaultHitTestOptions.exclude.clear(),this.map){this.map.ground&&this.map.ground.opacity<1&&this._defaultHitTestOptions.exclude.add(ke);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&e.opacity<1&&this._defaultHitTestOptions.exclude.add(e.uid)}}addVoxelLayerViewToWasm(e){return null==this.voxelWasm?(null==this.voxelWasmPromise&&(this.voxelWasmPromise=import("../layers/VoxelWasmPerSceneView.js").then((e=>(this.voxelWasm=new e.default(this),this.voxelWasm)))),this.voxelWasmPromise.then((t=>t.addVoxelLayer(e)))):this.voxelWasm.addVoxelLayer(e)}removeVoxelLayerViewFromWasm(e){if(null!=this.voxelWasm){this.voxelWasm.removeVoxelLayer(e)<1&&(this.voxelWasm=null,this.voxelWasmPromise=null)}}};function ot(e,t){e.layerUids||(e.layerUids=new Set),e.layerUids.add(t)}function lt(e,t){e.graphicUids||(e.graphicUids=new Set),e.graphicUids.add(t)}function pt(e,t){return null!=e&&A(e.spatialReference,t)?G(e,t):null}var ht;at.type="3d",e([V()],at.prototype,"_userClippingArea",void 0),e([V()],at.prototype,"_resourceController",void 0),e([V()],at.prototype,"_stage",void 0),e([V({readOnly:!0})],at.prototype,"deconflictor",void 0),e([V({readOnly:!0})],at.prototype,"labeler",void 0),e([V(I(X,"analyses"))],at.prototype,"analyses",void 0),e([V({type:te,readOnly:!0})],at.prototype,"animation",null),e([V({readOnly:!0})],at.prototype,"basemapTerrain",void 0),e([V({readOnly:!0})],at.prototype,"elevationProvider",void 0),e([V()],at.prototype,"camera",null),e([V({type:t})],at.prototype,"contentCamera",null),e([V({readOnly:!0})],at.prototype,"canvas",void 0),e([V({type:nt})],at.prototype,"center",null),e([V({type:rt})],at.prototype,"clippingArea",null),e([V({type:oe})],at.prototype,"constraints",void 0),e([V({type:rt,readOnly:!0})],at.prototype,"renderDataExtent",null),e([V({type:rt,readOnly:!0})],at.prototype,"dataExtent",null),e([V({type:rt,readOnly:!0})],at.prototype,"_groundAndLayersExtent",null),e([V({value:null,type:le})],at.prototype,"environment",null),e([x("environment")],at.prototype,"castEnvironment",null),e([V({readOnly:!0})],at.prototype,"environmentManager",void 0),e([V({type:rt})],at.prototype,"extent",null),e([V()],at.prototype,"floors",void 0),e([V()],at.prototype,"screenCenter",null),e([V()],at.prototype,"frustum",null),e([V({type:Number,readOnly:!0})],at.prototype,"fullOpacity",void 0),e([V({readOnly:!0})],at.prototype,"graphicsView",void 0),e([V({readOnly:!0})],at.prototype,"analysisViewManager",void 0),e([V()],at.prototype,"groundView",void 0),e([V({type:Boolean})],at.prototype,"initialExtentRequired",null),e([V()],at.prototype,"_defaultsFromMapSettings",null),e([V()],at.prototype,"interacting",null),e([V()],at.prototype,"stationary",null),e([V()],at.prototype,"navigating",null),e([V()],at.prototype,"map",void 0),e([V({readOnly:!0})],at.prototype,"mapCoordsHelper",void 0),e([V()],at.prototype,"padding",null),e([V({type:Oe,readOnly:!0})],at.prototype,"pointsOfInterest",void 0),e([V({type:ue,readOnly:!0})],at.prototype,"featureTiles",void 0),e([V()],at.prototype,"_featureTreeDebugger",void 0),e([V({type:Boolean})],at.prototype,"screenSizePerspectiveEnabled",void 0),e([V({constructOnly:!0})],at.prototype,"deactivatedWebGLExtensions",void 0),e([V({constructOnly:!0})],at.prototype,"debugWebGLExtensions",void 0),e([V({constructOnly:!0})],at.prototype,"renderCanvas",void 0),e([V({constructOnly:!0})],at.prototype,"state",void 0),e([V({readOnly:!0})],at.prototype,"inputManager",void 0),e([V({readOnly:!0})],at.prototype,"stateManager",void 0),e([V({type:["low","medium","high"]})],at.prototype,"qualityProfile",null),e([V({type:Ce,get(){let e=this._get("qualitySettings");return e||(e=new Ce,ve.apply(this.qualityProfile,e)),e}})],at.prototype,"qualitySettings",void 0),e([V()],at.prototype,"slicePlane",null),e([V({readOnly:!0})],at.prototype,"typeSpecificPreconditionsReady",null),e([V({readOnly:!0})],at.prototype,"renderCoordsHelper",void 0),e([V({readOnly:!0})],at.prototype,"sceneIntersectionHelper",void 0),e([V({type:Number,dependsOn:["scale","spatialReference"],readOnly:!0})],at.prototype,"resolution",null),e([V({type:Number})],at.prototype,"scale",null),e([V()],at.prototype,"heightModelInfo",null),e([V()],at.prototype,"spatialReference",void 0),e([V({type:Boolean,constructOnly:!0})],at.prototype,"alphaCompositingEnabled",void 0),e([V({constructOnly:!0})],at.prototype,"preserveDrawingBufferEnabled",void 0),e([V({type:Boolean})],at.prototype,"supersampleScreenshotsEnabled",void 0),e([V({readOnly:!0})],at.prototype,"type",void 0),e([V(),x((e=>e instanceof et?e:j(tt,e)))],at.prototype,"ui",void 0),e([V({type:Boolean,readOnly:!0,dependsOn:["graphicsView.updating","basemapView.updating","basemapTerrain.updating","layerViewManager.updating","layerViewManager.updatingRemaining","_resourceController.updating","_stage.updating","featureTiles.updating","pointsOfInterest.updating","environmentManager.updating","overlay.updating","updatingHandles.updating","featureTreeDebugger.updating","labeler.updating","deconflictor.updating","ready","stationary","inputManager.hasPendingInputs","toolViewManager.updating","analysisViewManager.updating","state.mode"]})],at.prototype,"updating",null),e([V({type:Number,readOnly:!0,dependsOn:["updating"]})],at.prototype,"updatingProgress",void 0),e([V({type:["global","local"]})],at.prototype,"viewingMode",null),e([V({type:r})],at.prototype,"viewpoint",null),e([V({type:Number})],at.prototype,"zoom",null),e([V({type:be})],at.prototype,"highlightOptions",void 0),at=e([T("esri.views.SceneView")],at),function(e){e[e.INCLUDE=0]="INCLUDE",e[e.EXCLUDE=1]="EXCLUDE"}(ht||(ht={}));const dt=E(),ct=C(),ut=D(),gt=at;export{gt as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Camera.js";import"../geometry.js";import i from"../Graphic.js";import r from"../Viewpoint.js";import s from"../core/Collection.js";import{byId as n}from"../core/domUtils.js";import a from"../core/Error.js";import{on as o}from"../core/events.js";import{handlesGroup as l,makeHandle as p}from"../core/handleUtils.js";import has from"../core/has.js";import{isIterable as h}from"../core/iteratorUtils.js";import d from"../core/Logger.js";import{destroyMaybe as c}from"../core/maybe.js";import{ObservableChangesType as u}from"../core/ObservableChangesType.js";import{throwIfAborted as g}from"../core/promiseUtils.js";import{on as m,watch as y,initial as f,syncAndInitial as w,whenOnce as v,sync as _}from"../core/reactiveUtils.js";import{setFrameDuration as b}from"../core/scheduling.js";import{screenPointObjectToArray as M,createScreenPoint as S,createScreenPointArray as C}from"../core/screenUtils.js";import{initialize as R}from"../core/workers/workers.js";import{property as V}from"../core/accessorSupport/decorators/property.js";import{cast as x}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import{subclass as T}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as O,ensureClass as j}from"../core/accessorSupport/ensureType.js";import{c as E}from"../chunks/vec3f64.js";import{owningCollectionProperty as I}from"../core/support/OwningCollection.js";import L from"../geometry/HeightModelInfo.js";import{projectPointToVector as P,projectVectorToVector as H,canProjectWithoutEngine as A,project as G,projectBoundingRect as U}from"../geometry/projection.js";import{create as D,toExtent as F}from"../geometry/support/aaBoundingRect.js";import{B as W,c as k}from"../chunks/boundedPlane.js";import{renderSRFromViewSR as q}from"../geometry/support/coordinateSystem.js";import{getResolutionForScale as z}from"../geometry/support/scaleUtils.js";import{fallbackObjectIDAttribute as B}from"../layers/LayerConstants.js";import{isImageryTileLayer as N,isTiledLayer as Q,isVoxelLayer as $}from"../layers/support/layerUtils.js";import{AnalysesCollection as X}from"../support/AnalysesCollection.js";import{BreakpointsOwner as Y}from"./BreakpointsOwner.js";import{DOMContainer as Z}from"./DOMContainer.js";import J from"./GroundView.js";import{PopupView as K}from"./PopupView.js";import ee from"./View.js";import te from"./ViewAnimation.js";import{ViewingMode as ie,stringFromViewingMode as re,viewingModeFromString as se}from"./ViewingMode.js";import{layerView3DImporter as ne}from"./3d/layerViewModuleImportUtils.js";import ae from"./3d/analysis/AnalysisViewManager3D.js";import{Constraints as oe}from"./3d/constraints/Constraints.js";import le from"./3d/environment/SceneViewEnvironment.js";import{SceneViewEnvironmentManager as pe}from"./3d/environment/SceneViewEnvironmentManager.js";import he from"./3d/input/SceneInputManager.js";import{GraphicsDeconflictor as de}from"./3d/layers/graphics/GraphicsDeconflictor.js";import{Labeler as ce}from"./3d/layers/graphics/Labeler.js";import{FeatureTileTree3D as ue}from"./3d/layers/support/FeatureTileTree3D.js";import ge from"./3d/state/ViewState.js";import{ViewStateManager as me}from"./3d/state/ViewStateManager.js";import{SceneIntersectionHelper as ye}from"./3d/state/helpers/SceneIntersectionHelper.js";import{CombinedElevationProvider as fe}from"./3d/support/CombinedElevationProvider.js";import we from"./3d/support/debugFlags.js";import ve from"./3d/support/DisplayQualityProfile.js";import{getElevationAtPoint as _e}from"./3d/support/ElevationProvider.js";import be from"./3d/support/HighlightOptions.js";import{MapCoordsHelper as Me}from"./3d/support/MapCoordsHelper.js";import{PropertiesPool as Se}from"./3d/support/PropertiesPool.js";import Ce from"./3d/support/QualitySettings.js";import{RenderCoordsHelper as Re}from"./3d/support/RenderCoordsHelper.js";import{newResourceController as Ve}from"./3d/support/ResourceController.js";import xe from"./3d/support/SceneViewPerformanceInfo.js";import{SharedSymbolResources as Te}from"./3d/support/SharedSymbolResources.js";import{PointsOfInterest as Oe}from"./3d/support/pointsOfInterest/PointsOfInterest.js";import je from"./3d/terrain/TerrainSurface.js";import{isSurfaceLayerView as Ee,getTiledLayerInfo as Ie,checkIfTileInfoSupportedForView as Le}from"./3d/terrain/terrainUtils.js";import{Stage as Pe}from"./3d/webgl-engine/Stage.js";import{newIntersector as He,DEFAULT_TOLERANCE as Ae}from"./3d/webgl-engine/lib/Intersector.js";import{StoreResults as Ge,IntersectorType as Ue}from"./3d/webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as De}from"./3d/webgl-engine/lib/intersectorUtils.js";import{toHit as Fe,toOwner as We}from"./3d/webgl-engine/lib/intersectorUtilsConversions.js";import{TERRAIN_ID as ke}from"./3d/webgl-engine/lib/verticalOffsetUtils.js";import{hitTestSelectSimilarDistance as qe}from"./support/hitTestSelectUtils.js";import{occludeesSupported as ze}from"./support/layerViewUtils.js";import{RenderState as Be}from"./support/RenderState.js";import{encode as Ne,encodeData as Qe,toRenderSettings as $e,screenshotSuperSampleSettings as Xe}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as Ye,createScreenPointFromSupportedEvent as Ze}from"./support/screenUtils.js";import{isSpatialReferenceSupported as Je}from"./support/spatialReferenceSupport.js";import{check as Ke}from"./support/WebGLRequirements.js";import et from"./ui/DefaultUI.js";import tt from"./ui/3d/DefaultUI3D.js";import it from"../webscene/Environment.js";import rt from"../geometry/Extent.js";import st from"../geometry/SpatialReference.js";import nt from"../geometry/Point.js";let at=class extends(Y(Z(K(ee)))){constructor(e){super(e),this._userClippingArea=null,this._clippingArea=null,this._initialDefaultSpatialReference=null,this._defaults={},this._externallySet={environment:!1},this._createGraphicsViewController=null,this._resolveWhenReady=[],this._propertiesPool=new Se({slicePlane:W},this),this._resourceController=Ve(this),this._defaultToMapOptions={include:new Set},this._defaultHitTestOptions={exclude:new Set},this.deconflictor=new de({view:this}),this.labeler=new ce({view:this,deconflictor:this.deconflictor.labels}),this.sharedSymbolResources=null,this.analyses=new X,this.basemapTerrain=null,this.elevationProvider=null,this.canvas=null,this.constraints=new oe,this.environmentManager=new pe,this.floors=new s,this.fullOpacity=1,this.graphicsView=null,this.analysisViewManager=new ae({view:this}),this.groundView=null,this.map=null,this.screenSizePerspectiveEnabled=!0,this.state=new ge,this.spatialReference=null,this.alphaCompositingEnabled=!1,this.preserveDrawingBufferEnabled=!1,this.supersampleScreenshotsEnabled=!0,this.type="3d",this.ui=new tt,this._numUpdating=0,this._lastUpdateTime=0,this.updatingProgress=.5,this.highlightOptions=new be,this.voxelWasm=null,this.voxelWasmPromise=null,R(),e&&e.environment||(this._defaults.environment=new le,this.environment=this._defaults.environment);const t=(e=null)=>{null!=e&&e.type===u.MOVE||(this._updatingChanged(),this.map&&this.map.allLayers.forEach((async e=>{try{await e.when()}catch{}this._updatingChanged()})))};this.addHandles([m((()=>this.map?.allLayers),"after-changes",(e=>t(e)),{onListenerAdd:()=>t(),onListenerRemove:()=>t(),sync:!0}),this.allLayerViews.on("after-changes",(e=>this._updateUpdatingMonitors(e))),y((()=>this.map),(e=>{e&&"load"in e&&e.load&&e.load().catch((()=>{}))}))]),this.inputManager=new he({view:this}),this.stateManager=new me({view:this})}initialize(){this.groundView=new J({view:this}),this._updateUpdatingMonitors();const e=()=>this._updateDefaultToMapOptions();this.addHandles(m((()=>this.map?.allLayers),"after-changes",e,{onListenerAdd:e,onListenerRemove:e})),this.updatingHandles.add((()=>this.qualitySettings.memoryLimit),(e=>{this.resourceController&&(this.resourceController.memoryController.maxMemory=e)}),f),this.updatingHandles.add((()=>this.qualitySettings.additionalCacheMemory),(e=>{this.resourceController&&(this.resourceController.memoryController.additionalCacheMemory=e)}),f),this.updatingHandles.add((()=>this.qualitySettings.frameRate??0),(e=>b(e>0?1e3/Math.ceil(e):0)),f),this.updatingHandles.add((()=>this.map?.ground),e,w),this.updatingHandles.add((()=>this.map?.ground?.opacity),(()=>this._updateDefaultHitTestOptions()),w),this.addHandles(y((()=>this.spatialReference),(()=>this.notifyChange("clippingArea")),_))}destroy(){this.destroyed||(this.updatingHandles.removeAll(),this.removeAllHandles(),this.invalidate(),this.activeTool=null,this.layerViewManager.clear(),this.environmentManager.destroy(),this._exitSurface(),this._disposeGraphicsView(),this.sharedSymbolResources=c(this.sharedSymbolResources),this._set("labeler",c(this.labeler)),this._set("deconflictor",c(this.deconflictor)),this._resourceController=c(this._resourceController),this._set("stateManager",c(this.stateManager)),this._set("inputManager",c(this.inputManager)),this.state.destroy(),this._propertiesPool.destroy(),this.removeHandles("updatingMonitors"),this._set("environmentManager",c(this.environmentManager)),this.groundView=c(this.groundView),this._exitBasemapTerrain(),this._stage?.destroy(),this.state.destroy(),this.removeAllHandles(),this.updatingHandles.removeAll(),this.handles.removeAll())}get renderSpatialReference(){return this.renderCoordsHelper&&this.renderCoordsHelper.spatialReference}get basemapSpatialReference(){return this.basemapTerrain?.spatialReference}get animation(){return this.state?.animation}get camera(){return this.stateManager?.camera}set camera(e){this.stateManager&&(this.stateManager.camera=e)}get contentCamera(){return this.stateManager?.contentCamera}set contentCamera(e){this.stateManager&&(this.stateManager.contentCamera=e)}installContentCameraReset(e={sticky:!1}){return this.stateManager.installContentCameraReset(e)}get center(){return this.stateManager?.center}set center(e){this.stateManager&&(this.stateManager.center=e)}get clippingArea(){if("global"===this.viewingMode)return null;let e=this._userClippingArea||("clippingArea"in this.map?this.map?.clippingArea:void 0);return!this._userClippingArea&&!this.get("map.clippingEnabled")||null==e?(this._clippingArea=null,null):e instanceof rt?this.spatialReference&&(e=pt(e,this.spatialReference),null==e)?(d.getLogger(this.declaredClass).error("#clippingArea","setting clippingArea with incompatible SpatialReference"),this._clippingArea):(e=e.clone(),null==e.intersection(this._groundAndLayersExtent)&&(e.xmin=e.xmax,e.ymin=e.ymax),e.zmin=void 0,e.zmax=void 0,e.equals(this._clippingArea)||(this._clippingArea=e),this._clippingArea):(d.getLogger(this.declaredClass).error("#clippingArea","only clippingArea geometries of type Extent are supported"),this._clippingArea)}set clippingArea(e){this.ready&&"global"===this.viewingMode&&null!=e?d.getLogger(this.declaredClass).error("#clippingArea=","Clipping area is only supported in local viewingMode"):this._userClippingArea=e}get renderDataExtent(){if(this.state.viewingMode===ie.Global)return null;const e=this.renderSpatialReference,t=this.dataExtent;return null==t||null==e||t.spatialReference.equals(e)?t:pt(t,e)}get dataExtent(){let e=this._groundAndLayersExtent;const t=this.spatialReference||st.WGS84,i=pt(this.clippingArea,t);null!=i&&(e=null!=e?e.intersection(i):i);const r=this._get("dataExtent");return null!=e&&e.equals(r)?r:e}get _groundAndLayersExtent(){const e=this.spatialReference||st.WGS84;let t;const i=i=>{const r=pt(i,e);null!=r&&(null!=t?t.union(r):t=r.clone())},r=this.basemapTerrain;if(r?.spatialReference){const e=r.groundExtent;i(new rt({xmin:e[0],ymin:e[1],zmin:0,xmax:e[2],ymax:e[3],zmax:0,spatialReference:r.spatialReference}))}if(this.map){const e=e=>{null==e.fullExtent||"graphics"===e.type&&e.internal||i(e.fullExtent)};this.map.allLayers.forEach((t=>e(t)))}if(null==t)return null;t.hasZ?(t.zmin=Math.min(0,t.zmin??0),t.zmax=Math.max(0,t.zmax??0)):(t.zmin=0,t.zmax=0);const s=this._get("_groundAndLayersExtent");return t.equals(s)?s:t}set environment(e){e!==this._defaults.environment&&(this._externallySet.environment=!0),this._set("environment",e)}castEnvironment(e){return e?e instanceof le?e:e instanceof it?null!=this.environment?this.environment.cloneWithWebsceneEnvironment(e):le.fromWebsceneEnvironment(e):O(le,e):new le}get extent(){return this.stateManager?.extent}set extent(e){this.stateManager&&(this.stateManager.extent=e)}get screenCenter(){return this.stateManager?.screenCenter}get frustum(){return this.stateManager?.frustum}get initialExtentRequired(){return this.stateManager&&!this.stateManager.hasInitialView}get _defaultsFromMapSettings(){return{required:{tileInfo:!1,heightModelInfo:!0,extent:!1}}}get interacting(){return this.navigating||this.toolViewManager?.interacting}get stationary(){return!this.animation&&!this.resizing&&(null==this.state||this.state.stationary)}get navigating(){return this.state?.navigating??!1}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}set qualityProfile(e){ve.isValidProfile(e)&&(ve.apply(e,this.qualitySettings),this._set("qualityProfile",e))}get qualityProfile(){return this._get("qualityProfile")||ve.getDefaultProfile()}set slicePlane(e){if(null!=this._stage&&this._stage.renderer.setParameters({slicePlane:e}),null==e)return void this._set("slicePlane",null);const t=this._propertiesPool.get("slicePlane");k(e,t),this._set("slicePlane",t)}get typeSpecificPreconditionsReady(){return!!this.viewingMode}get resolution(){return null!=this.spatialReference?z(this.scale,this.spatialReference):0}get scale(){return this.stateManager?.scale}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get heightModelInfo(){const e=this.getDefaultHeightModelInfo();return null!=e?L.deriveUnitFromSR(e,this.spatialReference):null}get updating(){if(this.destroyed)return!1;let e=0,t=this.layerViewManager.updating,i=t?this.layerViewManager.updatingRemaining:0;this.allLayerViews.forEach((r=>{if(r.isFulfilled()){if(r.updating){if(t=!0,r.suspended||Ee(r))return;++i,e+=r.updatingProgress}}else++i}));for(const s of[this.graphicsView,this.basemapView,this._resourceController,this._stage,this.featureTiles,this.pointsOfInterest,this.environmentManager,this.overlay,this._featureTreeDebugger,this.toolViewManager,this.analysisViewManager])if(null!=s&&s.updating){const t=.1;i+=t,e+=.5*t}for(const s of[this.deconflictor,this.labeler,this.basemapTerrain])null!=s&&s.updating&&(++i,e+=s.updatingProgress);const r=this.stateManager.test.updatingIgnoreRenderState?Be.IDLE:this.state.mode;if(t=!!(t||i>0||this.updatingHandles.updating||!this.ready||!this.stationary||r!==Be.IDLE||this._createGraphicsViewController||this.inputManager?.hasPendingInputs||this.map?.allLayers?.some((e=>!e.isFulfilled()))),t?(this._numUpdating=Math.max(i,this._numUpdating),e+=this._numUpdating-i):this._numUpdating=0,this._numUpdating>0?e/=this._numUpdating:e=t?0:1,this._get("updatingProgress")!==e){const i=performance.now();if(e<1){const t=Math.min((i-this._lastUpdateTime)/2e3,1);e=this.updatingProgress*(1-t)+e*t}this._set("updatingProgress",e),this._lastUpdateTime=t&&e<1?i:0}return t}get viewingMode(){const e=this._predeterminedViewingMode;if(null!=e)return re(e);const t=this.spatialReference;return t?null!=this.defaultsFromMap?.viewingMode&&t.equals(this.defaultsFromMap.spatialReference)?re(this.defaultsFromMap.viewingMode):Je(t,ie.Global)?"global":"local":"global"}set viewingMode(e){this.ready?d.getLogger(this.declaredClass).error("#viewingMode","viewingMode cannot be set once view is ready"):this._overrideIfSome("viewingMode",e)}get viewpoint(){return this.stateManager?.viewpoint}set viewpoint(e){this.stateManager&&(this.stateManager.viewpoint=e)}get zoom(){return this.stateManager.zoom}set zoom(e){this.stateManager&&(this.stateManager.zoom=e)}get resourceController(){return this._resourceController}get performanceInfo(){return new xe(this)}on(e,t,i,r){const s=this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}toMap(e,t){if(!this.ready)return d.getLogger(this.declaredClass).error("#toMap()","Scene view cannot be used before it is ready"),null;const i=t?this.externalToInternalIntersectOptions(t):this._defaultToMapOptions,r=null!=i.graphics&&(null!=i.graphics.include||null!=i.graphics.exclude),s=Ye(e)?Ze(this,e):e,n=M(s);i.enableDraped=i.include&&!i.include.has(ke)||i.exclude&&i.exclude.has(ke);const a=this.sceneIntersectionHelper,o=He(this.state.viewingMode);if(o.options.selectionMode=!0,o.options.store=r?Ge.ALL:Ge.MIN,a.intersectIntersectorScreen(n,o,i),r){for(const e of o.results.all){const t=Fe(e,this);if(null==t)return this._intersectResultToMapPoint(e);if("graphic"!==t.type||this._testGraphicUidFilter(i.graphics,t.graphic))return this._intersectResultToMapPoint(e)}return null}return this._intersectResultToMapPoint(o.results.min)}toScreen(e){if(!this.ready)return d.getLogger(this.declaredClass).error("#toScreen()","Scene view cannot be used before it is ready"),null;const t=(null==e.z?_e(this.elevationProvider,e):null)??0;return P(e,dt,this.renderSpatialReference,t),this.state.camera.projectToScreen(dt,ct),S(ct[0],ct[1])}pixelSizeAt(e){return this.ready?e?(P(e,dt,this.renderSpatialReference),this.state.camera.computeScreenPixelSizeAt(dt)):0:(d.getLogger(this.declaredClass).error("#pixelSizeAt()","Scene view cannot be used before it is ready"),null)}overlayPixelSizeInMapUnits(e){const t=this.basemapTerrain.overlayManager;return t?t.overlayPixelSizeInMapUnits(e):1}hitTest(e,t){if(!this.ready)return d.getLogger(this.declaredClass).error("#hitTest()","Scene view cannot be used before it is ready"),null;const i=Ye(e)?Ze(this,e):e,r=C(i.x,i.y),s=t?this.externalToInternalIntersectOptions(t):this._defaultHitTestOptions;s.requiresGroundFeedback=!0,s.enableDraped=!0;const n=He(this.state.viewingMode);n.options.selectionMode=!0,n.options.store=Ge.ALL,this.sceneIntersectionHelper.intersectIntersectorScreen(r,n,s);const a=this._intersectResultsToHits(n.results.all,s.graphics),o=n.results.ground,l=We(o,this),p=null!=l&&"type"in l&&"integrated-mesh"===l.type?l:null,h={screenPoint:i,results:a,ground:{mapPoint:this._intersectResultToMapPoint(o),distance:De(o)?o.distanceInRenderSpace:0,layer:p}};return we.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(h.intersector=n),Promise.resolve(h)}async popupHitTest(e){const{results:t,ground:i}=await qe(this,e);let r=null;return!(0===t.length||Math.abs((t[0].distance??0)-i.distance)<1e-5)||i.layer&&"integrated-mesh"===i.layer.type||(r=i.mapPoint),{results:t,screenPoint:e,mapPoint:r}}goTo(e,t){return this.updatingHandles.addPromise(this.stateManager.goTo(e,t))}async whenAnalysisView(e){if(null==e.parent)throw new a("view:no-analysisview-for-analysis","The analysis has not been added to view.analyses",{analysis:e});switch(e.parent.type){case"line-of-sight":case"dimension":return(await this.whenLayerView(e.parent)).whenAnalysisView();default:return this.analysisViewManager.whenAnalysisView(e)}}whenLayerView(e){return super.whenLayerView(e)}async takeScreenshot(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshot(t);return Ne(i,t,this._pixelFormat())}async _takeScreenshot(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshot(t);return Qe(i,this._pixelFormat())}async _takeScreenshotWithObjectAndLayerId(e){const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshotWithOID(t);return[Qe(i[0],this._pixelFormat()),Qe(i[1],this._pixelFormat())]}_completeSettings(e){const t=$e(e,this);return t.pixelRatio/=this.state.pixelRatio,Xe(t,this.supersampleScreenshotsEnabled,this.padding)}_pixelFormat(){return{flipY:!0,premultipliedAlpha:this._stage.renderView.getAlpha()}}get test(){return{takeScreenshot:e=>this._takeScreenshot(e),takeScreenshotWithObjectAndLayerId:e=>this._takeScreenshotWithObjectAndLayerId(e)}}async takeScreenshotWithObjectAndLayerId(e){if(!has("enable-feature:objectAndLayerId-rendering"))throw new Error("has enable-feature:objectAndLayerId-rendering must be true");const t=this._completeSettings(e);await this.whenReady();const i=await this._stage.renderView.takeScreenshotWithOID(t),r=Ne(i[0],t,this._pixelFormat()),s=this._completeSettings(e);s.format="png";return[r,Ne(i[1],s,this._pixelFormat())]}getColorToObjectAndLayerIdMapping(){if(null==this._stage.renderView.objectAndLayerIdRenderHelper)throw new Error("has enable-feature:objectAndLayerId-rendering must be true");return this._stage.renderView.objectAndLayerIdRenderHelper.getColorToObjectAndLayerIdMapping()}addUpdatingPromise(e){return this.updatingHandles.addPromise(e)}importLayerView(e){return ne.importLayerView(e)}hasLayerViewModule(e){return ne.hasLayerViewModule(e)}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map?.initialViewProperties?.spatialReference||this.defaultsFromMap?.spatialReference||this.defaultsFromMap?.ready&&this._initialDefaultSpatialReference||null}async validate(){let e=Ke(this.type);const t=has("safari");if(t&&t<9&&(e=new a("sceneview:browser-not-supported","This browser is not supported by SceneView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:t})),null!=e)throw d.getLogger(this.declaredClass).warn("#validate()",e.message),e}get _predeterminedViewingMode(){const e=this._isOverridden("viewingMode")?this._get("viewingMode"):(this.map&&"initialViewProperties"in this.map?this.map.initialViewProperties?.viewingMode:null)??null;return null!=e?se(e):null}getSpatialReferenceSupport({spatialReference:e,layer:t}){const i=this._predeterminedViewingMode;if(null!=i)return this._validateSpatialReferenceForViewingMode(e,t,i)?{constraints:this._makeSpatialReferenceConstraints(e,t,i)}:null;const r=this._validateSpatialReferenceForViewingMode(e,t,ie.Local),s=this._validateSpatialReferenceForViewingMode(e,t,ie.Global);return r||s?r&&s?{constraints:this._makeSpatialReferenceConstraints(e,t,null)}:r?{constraints:this._makeSpatialReferenceConstraints(e,t,ie.Local)}:{constraints:this._makeSpatialReferenceConstraints(e,t,ie.Global)}:null}_validateSpatialReferenceForViewingMode(e,t,i){return!!Je(e,i)&&(null==t||(!!N(t)||(!Q(t)||null!=Ie(t,e,i))&&(!$(t)||i!==ie.Global)))}_makeSpatialReferenceConstraints(e,t,i){if(null==t)return[{spatialReference:e,viewingMode:i}];const r=e.isWebMercator,s=e.isWGS84;if(N(t)&&(r||s)){return!s||i===ie.Local||null===Le(t.tileInfo,t.fullExtent,e,ie.Global)?[{spatialReference:e,viewingMode:i},{spatialReference:st.WebMercator,viewingMode:i}]:[{spatialReference:r?st.WGS84:st.WebMercator,viewingMode:i}]}return Q(t)||$(t)||!r&&!s?Q(t)&&r&&i!==ie.Global?[{spatialReference:e,viewingMode:i},{spatialReference:st.WGS84,viewingMode:ie.Local}]:[{spatialReference:e,viewingMode:i}]:[{spatialReference:e,viewingMode:i},{spatialReference:r?st.WGS84:st.WebMercator,viewingMode:i}]}_validateSpatialReference(e){const t=null!=this.getSpatialReferenceSupport({spatialReference:e}),i=this._predeterminedViewingMode;return t||(null!=i?d.getLogger(this.declaredClass).warnOnce(`Spatial reference defined on view not supported in ${re(i)} viewing mode.`):e.isGeographic&&d.getLogger(this.declaredClass).warnOnce("Spatial reference is geographic but not supported.")),t}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}computeMapPointFromVec3d(e,t){let i=this.spatialReference||st.WGS84;return H(e,this.renderSpatialReference,e,i)||(i=st.WGS84,H(e,this.renderSpatialReference,e,i)),t?(t.x=e[0],t.y=e[1],t.z=e[2],t.spatialReference=i):t=new nt(e,i),t}trackGraphicState(e){if(!e.graphic)return d.getLogger(this.declaredClass).error("trackGraphicState","GraphicState.graphic must not be null or undefined to start tracking"),null;const t=this.getViewForGraphic(e.graphic);let i=null,r=!1;const s=t=>{!r&&null!=t&&"processor"in t&&"graphics-3d"===t.processor?.type&&t.processor.graphicsCore&&(i=t.processor.graphicsCore.trackGraphicState(e))};return null!=t?s(t):this.whenViewForGraphic(e.graphic,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,null!=i&&(i.remove(),i=null)}}}highlight(e){if(Array.isArray(e))return l(e.map((e=>this.highlight(e))));if(s.isCollection(e))return l(e.toArray().map((e=>this.highlight(e))));const t=this.getViewForGraphic(e);return t&&"highlight"in t?t.highlight(e):p()}maskOccludee(e){if(!e)return d.getLogger(this.declaredClass).error("maskOccludee","GraphicState.graphic must not be null or undefined to mask an occludee"),null;const t=this.getViewForGraphic(e);let i=null,r=!1;const s=t=>{!r&&null!=t&&ze(t)&&(i=t.maskOccludee(e))};return null!=t?s(t):this.whenViewForGraphic(e,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,null!=i&&(i.remove(),i=null)}}}getViewForGraphic(e){return e.layer===this.graphics?this.graphicsView:e.layer?this.allLayerViews.find((t=>t.layer===e.layer)):null}graphicChanged(e){null!=this.graphicsView&&this.graphicsView.graphicChanged(e)}async whenViewForGraphic(e,t){if(e.layer===this)return await v((()=>this.graphicsView)),this.graphicsView;if(!e.layer||!this.map)throw new a("no-view-for-graphic");return t&&t.waitForLayer&&!this.map.allLayers.includes(e.layer)?new Promise(((t,i)=>{const r=this.map.allLayers.on("change",(s=>{s.added.includes(e.layer)&&(r.remove(),this.whenLayerView(e.layer).then(t,i))}))})):this.whenLayerView(e.layer)}externalToInternalIntersectOptions(e){const t=this._externalToInternalRenderItems(e.include,ht.INCLUDE),i=this._externalToInternalRenderItems(e.exclude,ht.EXCLUDE);return{include:t.layerUids,exclude:i.layerUids,graphics:{include:t.graphicUids,exclude:i.graphicUids}}}_intersectResultToMapPoint(e,t){return e.getIntersectionPoint(dt)?(t=this.computeMapPointFromVec3d(dt,t),e.intersector===Ue.TERRAIN&&this.basemapTerrain&&(t.z=_e(this.basemapTerrain,t)??0),t):null}_intersectResultsToHits(e,t){const i=new Array;let r=null;for(let s=0;s<e.length;s++){const n=e[s],a=We(n,this);if(null!=a&&(a===this.map.ground||"type"in a&&"integrated-mesh"===a.type))break;const o=Fe(n,this);if(null==o)continue;if("graphic"===o.type){if(null==r&&s!==e.length-1&&(r=new Set),null!=r){const e=this._getGraphicFilterUid(o.graphic);if(r.has(e))continue;r.add(e)}if(!this._testGraphicUidFilter(t,o.graphic))continue}const l=this._intersectResultToMapPoint(n),p=n.distanceInRenderSpace;i.push({...o,mapPoint:l,distance:p})}return i}_getGraphicFilterUid(e){const t=e.sourceLayer,i=e.layer,r=t&&"objectIdField"in t?t:i&&"objectIdField"in i?i:t;if(r){const t=r.objectIdField??B,i=e.attributes?.[t];if(i)return`o-${r.id}-${i}`}return`u-${e.uid}`}_testGraphicUidFilter(e,t){const i=this._getGraphicFilterUid(t);return null==e||(null==e.include||e.include.has(i))&&(null==e.exclude||!e.exclude.has(i))}_externalToInternalRenderItems(e,t,r={layerUids:void 0,graphicUids:void 0}){if(!e)return r;if(e instanceof i)lt(r,this._getGraphicFilterUid(e)),t===ht.INCLUDE&&(null!=this.graphicsView&&e.layer===this?ot(r,this.graphicsView.processor.layer.id):e.layer&&ot(r,e.layer.uid));else if(h(e))for(const i of e)i===this.graphics&&null!=this.graphicsView?ot(r,this.graphicsView.processor.layer.id):i===this.map.ground?ot(r,ke):this._externalToInternalRenderItems(i,t,r);else"uid"in e&&ot(r,e.uid);return r}_initBasemapTerrain(){this._set("basemapTerrain",new je({view:this})),this._set("elevationProvider",new fe({view:this})),this.elevationProvider.register("ground",this.basemapTerrain)}_exitBasemapTerrain(){this.basemapTerrain&&(this.elevationProvider.unregister(this.basemapTerrain),this.elevationProvider.destroy(),this._set("elevationProvider",null),this.basemapTerrain.destroy(),this._set("basemapTerrain",null))}_initGlobe(){this._initCoordinateSystem(),this.state.createInitialCamera(),this._initBasemapTerrain(),this._set("pointsOfInterest",new Oe({view:this})),this._set("featureTiles",new ue({renderCoordsHelper:this.renderCoordsHelper,cameraOnSurface:this.pointsOfInterest.cameraOnSurface,focus:this.pointsOfInterest.focus,tilingSchemeOwner:this.basemapTerrain,viewState:this.state,scheduler:this._resourceController.scheduler,terrain:this.basemapTerrain}));const e=()=>{const e=this.basemapTerrain?.extent;if(this.clippingArea||e)if(e&&this.basemapTerrain.spatialReference){const e=null!=this.basemapTerrain.extent&&null!=this.basemapTerrain.spatialReference?G(F(this.basemapTerrain.extent,this.basemapTerrain.spatialReference),this.spatialReference):null;null!=this.clippingArea?this.featureTiles.filterExtent=this.clippingArea.intersection(e):this.featureTiles.filterExtent=e}else this.featureTiles.filterExtent=this.clippingArea;else this.featureTiles.filterExtent=null};this.addHandles([this.updatingHandles.add((()=>we.FEATURE_TILE_TREE_SHOW_TILES),(e=>{e&&this.featureTiles&&!this._featureTreeDebugger?this.updatingHandles.addPromise(import("./3d/layers/support/FeatureTileTree3DDebugger.js")).then((({FeatureTileTree3DDebugger:e})=>{!this._featureTreeDebugger&&we.FEATURE_TILE_TREE_SHOW_TILES&&(this._featureTreeDebugger=new e({view:this}))})):e||!this._featureTreeDebugger||we.FEATURE_TILE_TREE_SHOW_TILES||(this._featureTreeDebugger.destroy(),this._featureTreeDebugger=null)}),w),this.updatingHandles.add((()=>this.clippingArea),e,w),this.updatingHandles.add((()=>this.basemapTerrain.extent),e,w)],"feature-tiles"),this.stateManager.init()}_exitGlobe(){this.state&&(this.stateManager.exit(),this.removeHandles("render-coords-helper"),this.removeHandles("feature-tiles"),this.featureTiles.destroy(),this._set("featureTiles",null),this.pointsOfInterest.destroy(),this._set("pointsOfInterest",null),this._exitBasemapTerrain(),this.state.exit(),this._exitCoordinateSystem())}_initCoordinateSystem(){if(this.spatialReference){const e=this.spatialReference;this.mapCoordsHelper&&this.mapCoordsHelper.spatialReference.equals(e)||this._set("mapCoordsHelper",new Me(this.map,e));const t=this.state.isGlobal,i=q(t,e);i!==this.renderSpatialReference&&(this._set("renderCoordsHelper",Re.create(this.state.viewingMode,i)),t||this.addHandles(y((()=>this.basemapTerrain?.extent),(e=>{const t=this.renderCoordsHelper.spatialReference;null==e||0===e[0]&&0===e[1]&&0===e[2]&&0===e[3]||!U(e,this.basemapTerrain.spatialReference,ut,t)||(this.renderCoordsHelper.extent=ut)}),_),"render-coords-helper"),this.sceneIntersectionHelper&&this.sceneIntersectionHelper.setTolerance(Ae/this.renderCoordsHelper.unitInMeters))}else this._set("mapCoordsHelper",null),this._set("renderCoordsHelper",null)}_exitCoordinateSystem(){this.mapCoordsHelper&&(this.removeHandles("render-coords-helper"),this._set("renderCoordsHelper",null),this._set("mapCoordsHelper",null))}_updatingChanged(){this.notifyChange("updating")}_updateUpdatingMonitors(e=null){null!=e&&e.type===u.MOVE||(this.removeHandles("updatingMonitors"),this.allLayerViews.forEach((e=>{e.destroyed||(this.addHandles(y((()=>[e.updating,e.updatingProgress]),(()=>this._updatingChanged()),_),"updatingMonitors"),e.when((()=>this._updatingChanged()),(()=>this._updatingChanged())))})),this._updatingChanged())}async _prepareScreenshotOverlay(){this.overlay&&await this.overlay.prepare()}_renderScreenshotOverlay(e,t){if(!this.overlay||!this.overlay.hasVisibleItems)return t;const i=e.getContext("2d");return i.putImageData(t,0,0),this.overlay.renderCanvas(e),i.getImageData(0,0,t.width,t.height)}_initStage(){const e={deactivatedWebGLExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions,alpha:this.alphaCompositingEnabled,preserveDrawingBuffer:this.preserveDrawingBufferEnabled,canvas:this.renderCanvas,screenshot:{prepareOverlay:()=>this._prepareScreenshotOverlay(),renderOverlay:(e,t)=>this._renderScreenshotOverlay(e,t)}},t=new ye(this.state.viewingMode,(e=>this._stage.layers.forAll(e)),this);this._set("sceneIntersectionHelper",t);const i=n(this.surface);this._stage=new Pe({view:this,options:e,container:i}),this._stage.renderer.setParameters({slicePlane:this.slicePlane}),this.addHandles([this.updatingHandles.add((()=>this.qualitySettings.antialiasingEnabled),(()=>this._stage.renderer.setParameters({antialiasingEnabled:this.qualitySettings.antialiasingEnabled})),f),this.updatingHandles.add((()=>this.qualitySettings.highQualityTransparency),(e=>this._stage.renderer.setParameters({highQualityTransparency:e})),f),y((()=>this.magnifier),(e=>this._stage.renderView.magnifier=e),w),this.on("pointer-move",(()=>this._stage?.renderer.resetAnimation())),o(this._stage.renderView.canvas,"webglcontextlost",(e=>this.fatalError=new a("webgl-context-lost",e.statusMessage)))],"stage");const r=()=>{this._stage.renderer.setParameters({defaultHighlightOptions:be.toEngineOptions(this.highlightOptions)})};this.addHandles(this.updatingHandles.add((()=>[this.highlightOptions.color,this.highlightOptions.haloColor,this.highlightOptions.haloOpacity,this.highlightOptions.fillOpacity,this.highlightOptions.shadowOpacity,this.highlightOptions.shadowColor,this.highlightOptions.shadowDifference]),r),"stage"),r(),this.renderCoordsHelper&&this.sceneIntersectionHelper.setTolerance(Ae/this.renderCoordsHelper.unitInMeters),this._set("canvas",this._stage.renderView.canvas)}_exitStage(){this._set("sceneIntersectionHelper",null),this._stage=c(this._stage),this.removeHandles("stage"),this._set("canvas",null)}_initSurface(e){this._exitSurface(),this.state.init(e,this.spatialReference),this._initStage(),this._initGlobe(),this.sharedSymbolResources=new Te({view:this,viewingMode:e,resourceController:this._resourceController,pointsOfInterest:this.pointsOfInterest,viewState:this.state})}_exitSurface(){this.sharedSymbolResources&&(this.sharedSymbolResources.objectResourceCache.destroy(),this.sharedSymbolResources.destroy(),this.sharedSymbolResources=null,this._exitGlobe(),this._exitStage())}_createGraphicsViewIfNeeded(){if(this.graphicsView||this._createGraphicsViewController)return;if(0===this.graphics.length)return;this.removeHandles("graphics-view"),this._createGraphicsViewController=new AbortController;const e=()=>{this._createGraphicsViewController=null,this._updatingChanged()};this._createGraphicsViewAsync(this._createGraphicsViewController.signal).then(e,e),this._updatingChanged()}async _createGraphicsViewAsync(e){const t=(await import("./3d/layers/GraphicsView3D.js")).default;g(e),await v((()=>this.basemapTerrain?.ready),e),this._set("graphicsView",new t({view:this}))}_disposeGraphicsView(){this._createGraphicsViewController&&(this._createGraphicsViewController.abort(),this._createGraphicsViewController=null),this.removeHandles("graphics-view"),null!=this.graphicsView&&(this.removeHandles(this.graphicsView.processor.layer.id),this.graphicsView.destroy(),this._set("graphicsView",null))}_startup(){const e=se(this.viewingMode);if(e===ie.Global&&(this._clippingArea=null),this._initSurface(e),this._set("ready",!0),this.addHandles(m((()=>this.graphics),"after-changes",(()=>this._createGraphicsViewIfNeeded())),"graphics-view"),this._createGraphicsViewIfNeeded(),!this._externallySet.environment){const e=this.get("map.initialViewProperties.environment");e&&(this.environment=e)}this.labeler.setup(),this.environmentManager.connectView(this),this.inputManager.connect();const t=this._resolveWhenReady;this._resolveWhenReady=[],t.forEach((e=>e(this)))}_teardown(){this._initialDefaultSpatialReference=null,this.inputManager.disconnect(),this.environmentManager.disconnectView(),this.labeler.dispose(),this._disposeGraphicsView(),this.removeHandles("graphics-view"),this._exitSurface(),this._set("ready",!1)}_updateDefaultToMapOptions(){if(this._defaultToMapOptions.include.clear(),this.map){this.map.ground&&this._defaultToMapOptions.include.add(ke);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&this._defaultToMapOptions.include.add(e.uid)}}_updateDefaultHitTestOptions(){if(this._defaultHitTestOptions.exclude.clear(),this.map){this.map.ground&&this.map.ground.opacity<1&&this._defaultHitTestOptions.exclude.add(ke);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&e.opacity<1&&this._defaultHitTestOptions.exclude.add(e.uid)}}addVoxelLayerViewToWasm(e){return null==this.voxelWasm?(null==this.voxelWasmPromise&&(this.voxelWasmPromise=import("../layers/VoxelWasmPerSceneView.js").then((e=>(this.voxelWasm=new e.default(this),this.voxelWasm)))),this.voxelWasmPromise.then((t=>t.addVoxelLayer(e)))):this.voxelWasm.addVoxelLayer(e)}removeVoxelLayerViewFromWasm(e){if(null!=this.voxelWasm){this.voxelWasm.removeVoxelLayer(e)<1&&(this.voxelWasm=null,this.voxelWasmPromise=null)}}};function ot(e,t){e.layerUids||(e.layerUids=new Set),e.layerUids.add(t)}function lt(e,t){e.graphicUids||(e.graphicUids=new Set),e.graphicUids.add(t)}function pt(e,t){return null!=e&&A(e.spatialReference,t)?G(e,t):null}var ht;at.type="3d",e([V()],at.prototype,"_userClippingArea",void 0),e([V()],at.prototype,"_resourceController",void 0),e([V()],at.prototype,"_stage",void 0),e([V({readOnly:!0})],at.prototype,"deconflictor",void 0),e([V({readOnly:!0})],at.prototype,"labeler",void 0),e([V(I(X,"analyses"))],at.prototype,"analyses",void 0),e([V({type:te,readOnly:!0})],at.prototype,"animation",null),e([V({readOnly:!0})],at.prototype,"basemapTerrain",void 0),e([V({readOnly:!0})],at.prototype,"elevationProvider",void 0),e([V()],at.prototype,"camera",null),e([V({type:t})],at.prototype,"contentCamera",null),e([V({readOnly:!0})],at.prototype,"canvas",void 0),e([V({type:nt})],at.prototype,"center",null),e([V({type:rt})],at.prototype,"clippingArea",null),e([V({type:oe})],at.prototype,"constraints",void 0),e([V({type:rt,readOnly:!0})],at.prototype,"renderDataExtent",null),e([V({type:rt,readOnly:!0})],at.prototype,"dataExtent",null),e([V({type:rt,readOnly:!0})],at.prototype,"_groundAndLayersExtent",null),e([V({value:null,type:le})],at.prototype,"environment",null),e([x("environment")],at.prototype,"castEnvironment",null),e([V({readOnly:!0})],at.prototype,"environmentManager",void 0),e([V({type:rt})],at.prototype,"extent",null),e([V()],at.prototype,"floors",void 0),e([V()],at.prototype,"screenCenter",null),e([V()],at.prototype,"frustum",null),e([V({type:Number,readOnly:!0})],at.prototype,"fullOpacity",void 0),e([V({readOnly:!0})],at.prototype,"graphicsView",void 0),e([V({readOnly:!0})],at.prototype,"analysisViewManager",void 0),e([V()],at.prototype,"groundView",void 0),e([V({type:Boolean})],at.prototype,"initialExtentRequired",null),e([V()],at.prototype,"_defaultsFromMapSettings",null),e([V()],at.prototype,"interacting",null),e([V()],at.prototype,"stationary",null),e([V()],at.prototype,"navigating",null),e([V()],at.prototype,"map",void 0),e([V({readOnly:!0})],at.prototype,"mapCoordsHelper",void 0),e([V()],at.prototype,"padding",null),e([V({type:Oe,readOnly:!0})],at.prototype,"pointsOfInterest",void 0),e([V({type:ue,readOnly:!0})],at.prototype,"featureTiles",void 0),e([V()],at.prototype,"_featureTreeDebugger",void 0),e([V({type:Boolean})],at.prototype,"screenSizePerspectiveEnabled",void 0),e([V({constructOnly:!0})],at.prototype,"deactivatedWebGLExtensions",void 0),e([V({constructOnly:!0})],at.prototype,"debugWebGLExtensions",void 0),e([V({constructOnly:!0})],at.prototype,"renderCanvas",void 0),e([V({constructOnly:!0})],at.prototype,"state",void 0),e([V({readOnly:!0})],at.prototype,"inputManager",void 0),e([V({readOnly:!0})],at.prototype,"stateManager",void 0),e([V({type:["low","medium","high"]})],at.prototype,"qualityProfile",null),e([V({type:Ce,get(){let e=this._get("qualitySettings");return e||(e=new Ce,ve.apply(this.qualityProfile,e)),e}})],at.prototype,"qualitySettings",void 0),e([V()],at.prototype,"slicePlane",null),e([V({readOnly:!0})],at.prototype,"typeSpecificPreconditionsReady",null),e([V({readOnly:!0})],at.prototype,"renderCoordsHelper",void 0),e([V({readOnly:!0})],at.prototype,"sceneIntersectionHelper",void 0),e([V({type:Number,dependsOn:["scale","spatialReference"],readOnly:!0})],at.prototype,"resolution",null),e([V({type:Number})],at.prototype,"scale",null),e([V()],at.prototype,"heightModelInfo",null),e([V()],at.prototype,"spatialReference",void 0),e([V({type:Boolean,constructOnly:!0})],at.prototype,"alphaCompositingEnabled",void 0),e([V({constructOnly:!0})],at.prototype,"preserveDrawingBufferEnabled",void 0),e([V({type:Boolean})],at.prototype,"supersampleScreenshotsEnabled",void 0),e([V({readOnly:!0})],at.prototype,"type",void 0),e([V(),x((e=>e instanceof et?e:j(tt,e)))],at.prototype,"ui",void 0),e([V({type:Boolean,readOnly:!0,dependsOn:["graphicsView.updating","basemapView.updating","basemapTerrain.updating","layerViewManager.updating","layerViewManager.updatingRemaining","_resourceController.updating","_stage.updating","featureTiles.updating","pointsOfInterest.updating","environmentManager.updating","overlay.updating","updatingHandles.updating","featureTreeDebugger.updating","labeler.updating","deconflictor.updating","ready","stationary","inputManager.hasPendingInputs","toolViewManager.updating","analysisViewManager.updating","state.mode"]})],at.prototype,"updating",null),e([V({type:Number,readOnly:!0,dependsOn:["updating"]})],at.prototype,"updatingProgress",void 0),e([V({type:["global","local"]})],at.prototype,"viewingMode",null),e([V({type:r})],at.prototype,"viewpoint",null),e([V({type:Number})],at.prototype,"zoom",null),e([V({type:be})],at.prototype,"highlightOptions",void 0),at=e([T("esri.views.SceneView")],at),function(e){e[e.INCLUDE=0]="INCLUDE",e[e.EXCLUDE=1]="EXCLUDE"}(ht||(ht={}));const dt=E(),ct=C(),ut=D(),gt=at;export{gt as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import r from"../../../core/Evented.js";import n from"../../../core/Handles.js";import a from"../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as p,get as c}from"../../../core/maybe.js";import{zeroMeters as l}from"../../../core/quantityUtils.js";import{when as d,pausable as m,watch as v,syncAndInitial as y}from"../../../core/reactiveUtils.js";import{createScreenPoint as _}from"../../../core/screenUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{closeRingsAndFixWinding as f,geometryToCoordinates as x,getMidpoint as G}from"../../../geometry/support/coordsUtils.js";import b from"../../../layers/GraphicsLayer.js";import V from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as w}from"../../ViewingMode.js";import{SnappingVisualizer2D as M}from"../../2d/interactive/SnappingVisualizer2D.js";import{cloneMove as S}from"./drawUtils.js";import E from"./GraphicMover.js";import k from"./HighlightHelper.js";import{addUniqueLayer as I}from"./layerUtils.js";import{settings as O}from"./settings.js";import{ViewEventPriorities as C}from"../../input/InputManager.js";import{SKETCH_KEYS as j}from"../../interactive/keybindings.js";import{EditGeometryOperations as T}from"../../interactive/editGeometry/EditGeometryOperations.js";import R from"../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as H}from"../../interactive/snapping/SnappingContext.js";import{Tooltip as U}from"../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as A,TranslateVertexTooltipInfo as L}from"../../interactive/tooltip/TranslateTooltipInfos.js";import{autoArea2D as F}from"../../support/automaticAreaMeasurementUtils.js";import{autoDistanceBetweenPoints2D as D,autoLength2D as z}from"../../support/automaticLengthMeasurementUtils.js";import P from"../../../geometry/Polyline.js";import q from"../../../geometry/Point.js";class K{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class N{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class B{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class J{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class Q{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class W{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class X{constructor(e){this.added=e,this.type="vertex-select"}}class Y{constructor(e){this.removed=e,this.type="vertex-deselect"}}class Z{constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class ${constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const ee=O.reshapeGraphics,te={vertices:{default:new V({style:"circle",size:ee.vertex.size,color:ee.vertex.color,outline:{color:ee.vertex.outlineColor,width:1}}),hover:new V({style:"circle",size:ee.vertex.hoverSize,color:ee.vertex.hoverColor,outline:{color:ee.vertex.hoverOutlineColor,width:1}}),selected:new V({style:"circle",size:ee.selected.size,color:ee.selected.color,outline:{color:ee.selected.outlineColor,width:1}})},midpoints:{default:new V({style:"circle",size:ee.midpoint.size,color:ee.midpoint.color,outline:{color:ee.midpoint.outlineColor,width:1}}),hover:new V({style:"circle",size:ee.midpoint.size,color:ee.midpoint.color,outline:{color:ee.midpoint.outlineColor,width:1}})}};let ie=class extends r.EventedAccessor{constructor(e){super(e),this._activeOperationInfo=null,this._editGeometryOperations=null,this._handles=new n,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingTask=null,this._stagedVertex=null,this._tooltip=null,this._viewHandles=new n,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new V({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=[],this.snappingManager=null,this.tooltipOptions=new R,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new k({view:e}),this._setup(),this._handles.add([d((()=>e?.ready),(()=>{const{layer:e,view:t}=this;I(t,e),this._viewHandles.add(t.on("key-down",(e=>this._keyDownHandler(e)),C.TOOL))}),{once:!0,initial:!0}),m((()=>this.graphic),(()=>this.refresh())),m((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),m((()=>this.enableMidpoints),(()=>this.refresh())),v((()=>this.tooltipOptions.enabled),(e=>{this._tooltip=e?new U({view:this.view}):h(this._tooltip)}),y)])}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._tooltip=h(this._tooltip),this._handles=h(this._handles),this._viewHandles=h(this._viewHandles)}set highlightsEnabled(e){this._highlightHelper?.removeAll(),this._set("highlightsEnabled",e),this._setUpHighlights()}get state(){const e=!!this.get("view.ready"),t=!(!this.get("graphic")||!this.get("layer"));return e&&t?"active":e?"ready":"disabled"}set symbols(e){const{midpoints:t=te.midpoints,vertices:i=te.vertices}=e||{};this._set("symbols",{midpoints:t,vertices:i})}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_setup(){const{graphic:e,layer:t}=this;if(!t||!e||null==e.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&f(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper.add(this.graphic)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(null==e||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new P({paths:e.points,spatialReference:e.spatialReference}):e;this._editGeometryOperations=T.fromGeometry(t,w.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new b({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer),this._snappingContext=new H({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,visualizer:new M(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=h(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this._set("selectedVertices",[])}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_getCoordinatesForUI(e){const t=x(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=this._getCoordinatesForUI(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((e,a)=>{const[h,p]=e;r.push(new t({geometry:new q({x:h,y:p,spatialReference:o}),symbol:s?.vertices?.default,attributes:{...i,pathIndex:n,pointIndex:a}}))}))})),r}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((a,h)=>{const[p,l]=a,d=e[h+1]?h+1:0;if("polygon"===c(this.graphic.geometry,"type")||0!==d){const[a,c]=e[d],[m,v]=G([p,l],[a,c]);r.push(new t({geometry:new q({x:m,y:v,spatialReference:o}),symbol:s.midpoints.default,attributes:{...i,pathIndex:n,pointIndexStart:h,pointIndexEnd:d}}))}}))})),r}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&r.push(t),this._mover=new E({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e;if(s===this.graphic){const{geometry:o}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),void(null!=o&&"point"===o.type&&this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)})))}if(!this.selectedVertices.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)}))}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)}));else if("point"===n.type)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}));else if("polyline"===n.type||"polygon"===n.type){const t=this._getCoordinatesForUI(n);this._updateVertexGraphicLocations(t),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,(()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o))),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const t=this.view.spatialReference;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes,[r,n]=e[s][o];i.geometry=new q({x:r,y:n,spatialReference:t})}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,[r,n]=e[i][s],[a,h]=e[i][o],[p,c]=G([r,n],[a,h]);t.geometry=new q({x:p,y:c,spatialReference:this.view.spatialReference})}}_getIndicesForVertexGraphic({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}_getVertexFromEditGeometry(e){const[t,i]=this._getIndicesForVertexGraphic(e);return this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,h="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!h){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new q(this._stagedVertex),t,s,h),r(),this._snappingTask=i((async i=>{const p=await o.snap({point:a,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new q(this._stagedVertex),t,s,h),r())}))}else{const i=null!=this._stagedVertex?new q(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,h),r()}}async _syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations.data.geometry;if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t),e.notifyGeometryChanged();else{const{x:n,y:a}=t,[h,p]=this._getIndicesForVertexGraphic(e);let c=x(r);const l=c[h].length-1;c[h][p]=[n,a],"polygon"===r.type&&(0===p?c[h][l]=[n,a]:p===l&&(c[h][0]=[n,a])),this._isVertex(e)&&(c=this._moveRelatedCoordinates(c,e,n,a),c=this._moveSelectedHandleCoordinates(c,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(c)),this.graphic.geometry=r.clone();const d=this._getVertexFromEditGeometry(e),m=n-d.pos[0],v=a-d.pos[1];this._editGeometryOperations.moveVertices([d],m,v,0),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i,s){const{relatedGraphicIndices:o}=t.attributes;for(const r of o){const o=this.vertexGraphics.getItemAt(r),{pathIndex:n,pointIndex:a}=o.attributes;e[n][a]=[i,s],o.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=r.attributes,h=S(r.geometry,i,s,this.view),p=e[t].length-1;e[t][n]=[h.x,h.y],r.geometry=h,o&&(0===n?e[t][p]=[h.x,h.y]:n===p&&(e[t][0]=[h.x,h.y]));for(const i of a){const t=this.vertexGraphics.getItemAt(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=[h.x,h.y],t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic,i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default",this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:h}=e.attributes,{x:p,y:c}=e.geometry,l=0===h?a+1:h,d=x(o);return d[n].splice(l,0,[p,c]),e.attributes={...t,pathIndex:n,pointIndex:l,relatedGraphicIndices:[]},r.push({coordinates:d[n][l],componentIndex:n,vertexIndex:l}),this.graphic.geometry=o,r}_addToSelection(e){e instanceof t&&(e=[e]);for(const t of e)t.symbol=this.symbols.vertices.selected;this._set("selectedVertices",this.selectedVertices.concat(e)),this._emitSelectEvent(e)}_removeFromSelection(e,i){const{vertices:s}=this.symbols,o=i?s.hover:s.default;e instanceof t&&(e=[e]);for(const t of e)this.selectedVertices.splice(this.selectedVertices.indexOf(t),1),this._set("selectedVertices",this.selectedVertices),t.set("symbol",o);this._emitDeselectEvent(e)}_clearSelection(){if(this.selectedVertices.length){const e=this.selectedVertices;for(const t of this.selectedVertices)t.set("symbol",this.symbols.vertices.default);this._set("selectedVertices",[]),this._emitDeselectEvent(e)}}_keyDownHandler(e){j.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const i=this.graphic.geometry;if(null==i||"polygon"!==i.type&&"polyline"!==i.type)return;if("polygon"===i.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;e instanceof t&&(e=[e]);const s=this.graphic.clone(),o=i.clone();let r=x(o);const n=[];e instanceof t&&(e=[e]);for(const t of e){const{x:e,y:i}=t.geometry;for(let t=0;t<r.length;t++){const s=r[t];for(let o=0;o<s.length;o++){const[a,h]=s[o];e===a&&i===h&&(n.push({coordinates:r[t][o],componentIndex:t,vertexIndex:o}),r[t].splice(Number(o),1))}}}if("polygon"===o.type)r=r.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)})),o.rings=r;else{for(const e of r)1===e.length&&r.splice(r.indexOf(e),1);o.paths=r}this.graphic.geometry=o,this.refresh(),this._emitVertexRemoveEvent(e,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_updateTooltip(e,t){null!=this._tooltip&&(e?e===this.graphic?this._updateMoveGraphicTooltip(t):this._updateMoveVertexTooltip(t):this._tooltip.clear())}_updateMoveGraphicTooltip(e){const{_tooltip:t,tooltipOptions:i,view:s}=this;if(null==t)return;const o=new A({tooltipOptions:i});if(e){const{x:t,y:i}=e.origin,r=s.toMap(e),n=s.toMap(_(t,i)),a=D(n,r);o.distance=null!=a?a:l}t.info=o}_updateMoveVertexTooltip(e){const{_tooltip:t,graphic:{geometry:i},tooltipOptions:s,view:o}=this;if(null==t)return;const r=new L({tooltipOptions:s});if(null!=i&&("polygon"===i.type?r.area=F(i):"polyline"===i.type&&(r.totalLength=z(i))),e){const{x:t,y:i}=e.origin,s=o.toMap(e),n=o.toMap(_(t,i)),a=D(n,s);r.distance=null!=a?a:l}t.info=r}_emitMoveStartEvent(e,t){const i=new J(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart&&this.callbacks.onMoveStart(i)}_emitMoveEvent(e,t){const i=new Q(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove&&this.callbacks.onMove(i)}_emitMoveStopEvent(){const e=this._activeOperationInfo;if(!e)return;const{totalDx:t,totalDy:i}=e,s=new W(this.graphic,t,i);this.emit("move-stop",s),this.callbacks.onMoveStop&&this.callbacks.onMoveStop(s)}_emitReshapeStartEvent(e){const t=new K(this.graphic,e,this.selectedVertices);this.emit("reshape-start",t),this.callbacks.onReshapeStart&&this.callbacks.onReshapeStart(t)}_emitReshapeEvent(e){const t=new N(this.graphic,e,this.selectedVertices);this.emit("reshape",t),this.callbacks.onReshape&&this.callbacks.onReshape(t)}_emitReshapeStopEvent(e){const t=new B(this.graphic,e,this.selectedVertices);this.emit("reshape-stop",t),this.callbacks.onReshapeStop&&this.callbacks.onReshapeStop(t)}_emitSelectEvent(e){const t=new X(e);this.emit("select",t),this.callbacks.onVertexSelect&&this.callbacks.onVertexSelect(t)}_emitDeselectEvent(e){const t=new Y(e);this.emit("deselect",t),this.callbacks.onVertexDeselect&&this.callbacks.onVertexDeselect(t)}_emitVertexAddEvent(e,t,i){const s=new Z(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd&&this.callbacks.onVertexAdd(s)}_emitVertexRemoveEvent(e,t,i){const s=new $(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove&&this.callbacks.onVertexRemove(s)}_logGeometryTypeError(){a.getLogger(this.declaredClass).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};e([g()],ie.prototype,"_tooltip",void 0),e([g()],ie.prototype,"callbacks",void 0),e([g()],ie.prototype,"enableMidpoints",void 0),e([g()],ie.prototype,"enableMovement",void 0),e([g()],ie.prototype,"enableVertices",void 0),e([g()],ie.prototype,"graphic",void 0),e([g({value:!0})],ie.prototype,"highlightsEnabled",null),e([g()],ie.prototype,"layer",void 0),e([g({readOnly:!0})],ie.prototype,"midpointGraphics",void 0),e([g()],ie.prototype,"midpointSymbol",void 0),e([g({readOnly:!0})],ie.prototype,"selectedVertices",void 0),e([g()],ie.prototype,"snappingManager",void 0),e([g({readOnly:!0})],ie.prototype,"state",null),e([g({value:te})],ie.prototype,"symbols",null),e([g({type:R})],ie.prototype,"tooltipOptions",void 0),e([g({readOnly:!0})],ie.prototype,"type",void 0),e([g({readOnly:!0})],ie.prototype,"vertexGraphics",void 0),e([g()],ie.prototype,"view",void 0),ie=e([u("esri.views.draw.support.Reshape")],ie);const se=ie;export{se as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import r from"../../../core/Evented.js";import n from"../../../core/Handles.js";import a from"../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as p}from"../../../core/maybe.js";import{zeroMeters as c}from"../../../core/quantityUtils.js";import{when as l,pausable as d,watch as m,syncAndInitial as v}from"../../../core/reactiveUtils.js";import{createScreenPoint as y}from"../../../core/screenUtils.js";import{property as _}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as g}from"../../../core/accessorSupport/decorators/subclass.js";import{closeRingsAndFixWinding as u,geometryToCoordinates as f,getMidpoint as x}from"../../../geometry/support/coordsUtils.js";import G from"../../../layers/GraphicsLayer.js";import b from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as V}from"../../ViewingMode.js";import{SnappingVisualizer2D as w}from"../../2d/interactive/SnappingVisualizer2D.js";import{cloneMove as M}from"./drawUtils.js";import S from"./GraphicMover.js";import E from"./HighlightHelper.js";import{addUniqueLayer as k}from"./layerUtils.js";import{settings as I}from"./settings.js";import{ViewEventPriorities as O}from"../../input/InputManager.js";import{SKETCH_KEYS as C}from"../../interactive/keybindings.js";import{EditGeometryOperations as j}from"../../interactive/editGeometry/EditGeometryOperations.js";import T from"../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as R}from"../../interactive/snapping/SnappingContext.js";import{Tooltip as H}from"../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as U,TranslateVertexTooltipInfo as A}from"../../interactive/tooltip/TranslateTooltipInfos.js";import{autoArea2D as L}from"../../support/automaticAreaMeasurementUtils.js";import{autoDistanceBetweenPoints2D as F,autoLength2D as D}from"../../support/automaticLengthMeasurementUtils.js";import z from"../../../geometry/Polyline.js";import P from"../../../geometry/Point.js";class q{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class K{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class N{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class B{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class J{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class Q{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class W{constructor(e){this.added=e,this.type="vertex-select"}}class X{constructor(e){this.removed=e,this.type="vertex-deselect"}}class Y{constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class Z{constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const $=I.reshapeGraphics,ee={vertices:{default:new b({style:"circle",size:$.vertex.size,color:$.vertex.color,outline:{color:$.vertex.outlineColor,width:1}}),hover:new b({style:"circle",size:$.vertex.hoverSize,color:$.vertex.hoverColor,outline:{color:$.vertex.hoverOutlineColor,width:1}}),selected:new b({style:"circle",size:$.selected.size,color:$.selected.color,outline:{color:$.selected.outlineColor,width:1}})},midpoints:{default:new b({style:"circle",size:$.midpoint.size,color:$.midpoint.color,outline:{color:$.midpoint.outlineColor,width:1}}),hover:new b({style:"circle",size:$.midpoint.size,color:$.midpoint.color,outline:{color:$.midpoint.outlineColor,width:1}})}};let te=class extends r.EventedAccessor{constructor(e){super(e),this._activeOperationInfo=null,this._editGeometryOperations=null,this._handles=new n,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingTask=null,this._stagedVertex=null,this._tooltip=null,this._viewHandles=new n,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new b({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=[],this.snappingManager=null,this.tooltipOptions=new T,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new E({view:e}),this._setup(),this._handles.add([l((()=>e?.ready),(()=>{const{layer:e,view:t}=this;k(t,e),this._viewHandles.add(t.on("key-down",(e=>this._keyDownHandler(e)),O.TOOL))}),{once:!0,initial:!0}),d((()=>this.graphic),(()=>this.refresh())),d((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),d((()=>this.enableMidpoints),(()=>this.refresh())),m((()=>this.tooltipOptions.enabled),(e=>{this._tooltip=e?new H({view:this.view}):h(this._tooltip)}),v)])}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._tooltip=h(this._tooltip),this._handles=h(this._handles),this._viewHandles=h(this._viewHandles)}set highlightsEnabled(e){this._highlightHelper?.removeAll(),this._set("highlightsEnabled",e),this._setUpHighlights()}get state(){const e=!!this.get("view.ready"),t=!(!this.get("graphic")||!this.get("layer"));return e&&t?"active":e?"ready":"disabled"}set symbols(e){const{midpoints:t=ee.midpoints,vertices:i=ee.vertices}=e||{};this._set("symbols",{midpoints:t,vertices:i})}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_setup(){const{graphic:e,layer:t}=this;if(!t||!e||null==e.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&u(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper.add(this.graphic)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(null==e||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new z({paths:e.points,spatialReference:e.spatialReference}):e;this._editGeometryOperations=j.fromGeometry(t,V.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new G({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer),this._snappingContext=new R({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,visualizer:new w(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=h(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this._set("selectedVertices",[])}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_getCoordinatesForUI(e){const t=f(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=this._getCoordinatesForUI(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((e,a)=>{const[h,p]=e;r.push(new t({geometry:new P({x:h,y:p,spatialReference:o}),symbol:s?.vertices?.default,attributes:{...i,pathIndex:n,pointIndex:a}}))}))})),r}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((a,h)=>{const[p,c]=a,l=e[h+1]?h+1:0;if("polygon"===this.graphic.geometry?.type||0!==l){const[a,d]=e[l],[m,v]=x([p,c],[a,d]);r.push(new t({geometry:new P({x:m,y:v,spatialReference:o}),symbol:s.midpoints.default,attributes:{...i,pathIndex:n,pointIndexStart:h,pointIndexEnd:l}}))}}))})),r}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&r.push(t),this._mover=new S({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e;if(s===this.graphic){const{geometry:o}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),void(null!=o&&"point"===o.type&&this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)})))}if(!this.selectedVertices.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)}))}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)}));else if("point"===n.type)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}));else if("polyline"===n.type||"polygon"===n.type){const t=this._getCoordinatesForUI(n);this._updateVertexGraphicLocations(t),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,(()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o))),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const t=this.view.spatialReference;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes,[r,n]=e[s][o];i.geometry=new P({x:r,y:n,spatialReference:t})}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,[r,n]=e[i][s],[a,h]=e[i][o],[p,c]=x([r,n],[a,h]);t.geometry=new P({x:p,y:c,spatialReference:this.view.spatialReference})}}_getIndicesForVertexGraphic({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}_getVertexFromEditGeometry(e){const[t,i]=this._getIndicesForVertexGraphic(e);return this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,h="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!h){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new P(this._stagedVertex),t,s,h),r(),this._snappingTask=i((async i=>{const p=await o.snap({point:a,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new P(this._stagedVertex),t,s,h),r())}))}else{const i=null!=this._stagedVertex?new P(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,h),r()}}async _syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations.data.geometry;if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t),e.notifyGeometryChanged();else{const{x:n,y:a}=t,[h,p]=this._getIndicesForVertexGraphic(e);let c=f(r);const l=c[h].length-1;c[h][p]=[n,a],"polygon"===r.type&&(0===p?c[h][l]=[n,a]:p===l&&(c[h][0]=[n,a])),this._isVertex(e)&&(c=this._moveRelatedCoordinates(c,e,n,a),c=this._moveSelectedHandleCoordinates(c,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(c)),this.graphic.geometry=r.clone();const d=this._getVertexFromEditGeometry(e),m=n-d.pos[0],v=a-d.pos[1];this._editGeometryOperations.moveVertices([d],m,v,0),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i,s){const{relatedGraphicIndices:o}=t.attributes;for(const r of o){const o=this.vertexGraphics.getItemAt(r),{pathIndex:n,pointIndex:a}=o.attributes;e[n][a]=[i,s],o.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=r.attributes,h=M(r.geometry,i,s,this.view),p=e[t].length-1;e[t][n]=[h.x,h.y],r.geometry=h,o&&(0===n?e[t][p]=[h.x,h.y]:n===p&&(e[t][0]=[h.x,h.y]));for(const i of a){const t=this.vertexGraphics.getItemAt(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=[h.x,h.y],t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic,i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default",this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:h}=e.attributes,{x:p,y:c}=e.geometry,l=0===h?a+1:h,d=f(o);return d[n].splice(l,0,[p,c]),e.attributes={...t,pathIndex:n,pointIndex:l,relatedGraphicIndices:[]},r.push({coordinates:d[n][l],componentIndex:n,vertexIndex:l}),this.graphic.geometry=o,r}_addToSelection(e){e instanceof t&&(e=[e]);for(const t of e)t.symbol=this.symbols.vertices.selected;this._set("selectedVertices",this.selectedVertices.concat(e)),this._emitSelectEvent(e)}_removeFromSelection(e,i){const{vertices:s}=this.symbols,o=i?s.hover:s.default;e instanceof t&&(e=[e]);for(const t of e)this.selectedVertices.splice(this.selectedVertices.indexOf(t),1),this._set("selectedVertices",this.selectedVertices),t.set("symbol",o);this._emitDeselectEvent(e)}_clearSelection(){if(this.selectedVertices.length){const e=this.selectedVertices;for(const t of this.selectedVertices)t.set("symbol",this.symbols.vertices.default);this._set("selectedVertices",[]),this._emitDeselectEvent(e)}}_keyDownHandler(e){C.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const i=this.graphic.geometry;if(null==i||"polygon"!==i.type&&"polyline"!==i.type)return;if("polygon"===i.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;e instanceof t&&(e=[e]);const s=this.graphic.clone(),o=i.clone();let r=f(o);const n=[];e instanceof t&&(e=[e]);for(const t of e){const{x:e,y:i}=t.geometry;for(let t=0;t<r.length;t++){const s=r[t];for(let o=0;o<s.length;o++){const[a,h]=s[o];e===a&&i===h&&(n.push({coordinates:r[t][o],componentIndex:t,vertexIndex:o}),r[t].splice(Number(o),1))}}}if("polygon"===o.type)r=r.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)})),o.rings=r;else{for(const e of r)1===e.length&&r.splice(r.indexOf(e),1);o.paths=r}this.graphic.geometry=o,this.refresh(),this._emitVertexRemoveEvent(e,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_updateTooltip(e,t){null!=this._tooltip&&(e?e===this.graphic?this._updateMoveGraphicTooltip(t):this._updateMoveVertexTooltip(t):this._tooltip.clear())}_updateMoveGraphicTooltip(e){const{_tooltip:t,tooltipOptions:i,view:s}=this;if(null==t)return;const o=new U({tooltipOptions:i});if(e){const{x:t,y:i}=e.origin,r=s.toMap(e),n=s.toMap(y(t,i)),a=F(n,r);o.distance=null!=a?a:c}t.info=o}_updateMoveVertexTooltip(e){const{_tooltip:t,graphic:{geometry:i},tooltipOptions:s,view:o}=this;if(null==t)return;const r=new A({tooltipOptions:s});if(null!=i&&("polygon"===i.type?r.area=L(i):"polyline"===i.type&&(r.totalLength=D(i))),e){const{x:t,y:i}=e.origin,s=o.toMap(e),n=o.toMap(y(t,i)),a=F(n,s);r.distance=null!=a?a:c}t.info=r}_emitMoveStartEvent(e,t){const i=new B(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart&&this.callbacks.onMoveStart(i)}_emitMoveEvent(e,t){const i=new J(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove&&this.callbacks.onMove(i)}_emitMoveStopEvent(){const e=this._activeOperationInfo;if(!e)return;const{totalDx:t,totalDy:i}=e,s=new Q(this.graphic,t,i);this.emit("move-stop",s),this.callbacks.onMoveStop&&this.callbacks.onMoveStop(s)}_emitReshapeStartEvent(e){const t=new q(this.graphic,e,this.selectedVertices);this.emit("reshape-start",t),this.callbacks.onReshapeStart&&this.callbacks.onReshapeStart(t)}_emitReshapeEvent(e){const t=new K(this.graphic,e,this.selectedVertices);this.emit("reshape",t),this.callbacks.onReshape&&this.callbacks.onReshape(t)}_emitReshapeStopEvent(e){const t=new N(this.graphic,e,this.selectedVertices);this.emit("reshape-stop",t),this.callbacks.onReshapeStop&&this.callbacks.onReshapeStop(t)}_emitSelectEvent(e){const t=new W(e);this.emit("select",t),this.callbacks.onVertexSelect&&this.callbacks.onVertexSelect(t)}_emitDeselectEvent(e){const t=new X(e);this.emit("deselect",t),this.callbacks.onVertexDeselect&&this.callbacks.onVertexDeselect(t)}_emitVertexAddEvent(e,t,i){const s=new Y(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd&&this.callbacks.onVertexAdd(s)}_emitVertexRemoveEvent(e,t,i){const s=new Z(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove&&this.callbacks.onVertexRemove(s)}_logGeometryTypeError(){a.getLogger(this.declaredClass).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};e([_()],te.prototype,"_tooltip",void 0),e([_()],te.prototype,"callbacks",void 0),e([_()],te.prototype,"enableMidpoints",void 0),e([_()],te.prototype,"enableMovement",void 0),e([_()],te.prototype,"enableVertices",void 0),e([_()],te.prototype,"graphic",void 0),e([_({value:!0})],te.prototype,"highlightsEnabled",null),e([_()],te.prototype,"layer",void 0),e([_({readOnly:!0})],te.prototype,"midpointGraphics",void 0),e([_()],te.prototype,"midpointSymbol",void 0),e([_({readOnly:!0})],te.prototype,"selectedVertices",void 0),e([_()],te.prototype,"snappingManager",void 0),e([_({readOnly:!0})],te.prototype,"state",null),e([_({value:ee})],te.prototype,"symbols",null),e([_({type:T})],te.prototype,"tooltipOptions",void 0),e([_({readOnly:!0})],te.prototype,"type",void 0),e([_({readOnly:!0})],te.prototype,"vertexGraphics",void 0),e([_()],te.prototype,"view",void 0),te=e([g("esri.views.draw.support.Reshape")],te);const ie=te;export{ie as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Logger.js";import{isSome as r}from"../../core/maybe.js";import{unwrapUpdating as o,updating as i,isUpdating as n}from"../../core/maybeUpdating.js";import{whenOnce as l}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{project as m,canProjectWithoutEngine as p,isLoaded as u,load as y}from"../../geometry/projection.js";import c from"./LayerView.js";const g="esri.views.layers.SceneLayerView",d=t.getLogger(g);let h=class extends c{constructor(){super(...arguments),this.layer=null,this.filter=null,this._geometryEngine=null,this._projectionEngineLoaded=!1}get availableFields(){return[]}get maximumNumberOfFeatures(){return 0}set maximumNumberOfFeatures(e){throw new Error("Not implemented")}get maximumNumberOfFeaturesExceeded(){return!1}get layerFilter(){return o(this._layerFilter)}get _layerFilter(){const e=this.layer.filter;if(null==e||e.geometries.length<1)return null;const t=this._geometryEngine;if(null==t||!this._projectionEngineLoaded&&this._filterNeedsProjectionEngine)return i;const o=e.geometries.getItemAt(0).spatialReference,n=e.geometries.toArray().map((e=>{try{e=t.simplify(e)}catch(r){return d.warnOncePerTick("Failed to simplify scene filter mask polygon. Polygon will be ignored."),null}if(null==e)return null;if(e.spatialReference.equals(o))return e;try{return m(e,o)}catch(r){return d.warnOncePerTick("Failed to project scene filter mask polygon. Polygon will be ignored."),null}})).filter(r).sort(((e,t)=>e.extent.xmin-t.extent.xmin)),l=new Set,s=new Array,a=new Array;for(let r of n){const e=r.extent.xmin;if(s.length=0,l.forEach((o=>{if(e>=o.extent.xmax)return a.push(o),void l.delete(o);r.extent.ymin<=o.extent.ymax&&r.extent.ymax>=o.extent.ymin&&t.intersects(r,o)&&s.push(o)})),s.length>0){s.push(r);try{r=t.union(s)}catch(p){d.warnOncePerTick("Failed to unify filter mask polygons. Polygon will be ignored.");continue}s.pop(),s.forEach((e=>l.delete(e)))}l.add(r)}return l.forEach((e=>a.push(e))),a.length>0?{spatialRelationship:e.spatialRelationship,geometries:a}:null}get _filterNeedsProjectionEngine(){const e=this.layer.filter;if(null==e||e.geometries.length<=1)return!1;const t=e.geometries.getItemAt(0).spatialReference;return e.geometries.some((({spatialReference:e})=>!e.equals(t)&&!p(e,t)))}get layerFilterUpdating(){return n(this._layerFilter)}initialize(){l((()=>this.destroyed||!this._geometryEngine&&this.layer?.filter?.geometries?.length)).then((async()=>{this.destroyed||(this._geometryEngine=await import("../../geometry/geometryEngine.js"))})),this._projectionEngineLoaded=u(),l((()=>this.destroyed||!this._projectionEngineLoaded&&this._filterNeedsProjectionEngine)).then((async()=>{this.destroyed||(await y(),this._projectionEngineLoaded=!0)}))}destroy(){}highlight(e){throw new Error("Not implemented")}queryFeatures(e,t){throw new Error("Not implemented")}queryObjectIds(e,t){throw new Error("Not implemented")}queryFeatureCount(e,t){throw new Error("Not implemented")}createQuery(){throw new Error("Not implemented")}queryExtent(e,t){throw new Error("Not implemented")}};e([s()],h.prototype,"layer",void 0),e([s()],h.prototype,"availableFields",null),e([s()],h.prototype,"maximumNumberOfFeatures",null),e([s({readOnly:!0})],h.prototype,"maximumNumberOfFeaturesExceeded",null),e([s()],h.prototype,"filter",void 0),e([s({readOnly:!0})],h.prototype,"layerFilter",null),e([s({readOnly:!0})],h.prototype,"_layerFilter",null),e([s()],h.prototype,"_geometryEngine",void 0),e([s()],h.prototype,"_projectionEngineLoaded",void 0),e([s()],h.prototype,"_filterNeedsProjectionEngine",null),e([s()],h.prototype,"layerFilterUpdating",null),h=e([a(g)],h);const f=h;export{f as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Logger.js";import{isSome as r,abortMaybe as o}from"../../core/maybe.js";import{unwrapUpdating as i,updating as n,isUpdating as l}from"../../core/maybeUpdating.js";import{throwIfAbortError as s,throwIfNotAbortError as a}from"../../core/promiseUtils.js";import{whenOnce as m}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{project as u,canProjectWithoutEngine as y,isLoaded as g,load as d}from"../../geometry/projection.js";import h from"./LayerView.js";const f="esri.views.layers.SceneLayerView",w=t.getLogger(f);let E=class extends h{constructor(){super(...arguments),this.layer=null,this.filter=null,this._geometryEngine=null,this._projectionEngineLoaded=!1,this._abortController=new AbortController}get availableFields(){return[]}get maximumNumberOfFeatures(){return 0}set maximumNumberOfFeatures(e){throw new Error("Not implemented")}get maximumNumberOfFeaturesExceeded(){return!1}get layerFilter(){return i(this._layerFilter)}get _layerFilter(){const e=this.layer.filter;if(null==e||e.geometries.length<1)return null;const t=this._geometryEngine;if(null==t||!this._projectionEngineLoaded&&this._filterNeedsProjectionEngine)return n;const o=e.geometries.getItemAt(0).spatialReference,i=e.geometries.toArray().map((e=>{try{e=t.simplify(e)}catch(r){return w.warnOncePerTick("Failed to simplify scene filter mask polygon. Polygon will be ignored."),null}if(null==e)return null;if(e.spatialReference.equals(o))return e;try{return u(e,o)}catch(r){return w.warnOncePerTick("Failed to project scene filter mask polygon. Polygon will be ignored."),null}})).filter(r).sort(((e,t)=>e.extent.xmin-t.extent.xmin)),l=new Set,s=new Array,a=new Array;for(let r of i){const e=r.extent.xmin;if(s.length=0,l.forEach((o=>{if(e>=o.extent.xmax)return a.push(o),void l.delete(o);r.extent.ymin<=o.extent.ymax&&r.extent.ymax>=o.extent.ymin&&t.intersects(r,o)&&s.push(o)})),s.length>0){s.push(r);try{r=t.union(s)}catch(m){w.warnOncePerTick("Failed to unify filter mask polygons. Polygon will be ignored.");continue}s.pop(),s.forEach((e=>l.delete(e)))}l.add(r)}return l.forEach((e=>a.push(e))),a.length>0?{spatialRelationship:e.spatialRelationship,geometries:a}:null}get _filterNeedsProjectionEngine(){const e=this.layer.filter;if(null==e||e.geometries.length<=1)return!1;const t=e.geometries.getItemAt(0).spatialReference;return e.geometries.some((({spatialReference:e})=>!e.equals(t)&&!y(e,t)))}get layerFilterUpdating(){return l(this._layerFilter)}initialize(){const{signal:e}=this._abortController;m((()=>this.destroyed||!this._geometryEngine&&this.layer?.filter?.geometries?.length),e).then((async()=>{s(e),this._geometryEngine=await import("../../geometry/geometryEngine.js")})).catch(a),this._projectionEngineLoaded=g(),m((()=>this.destroyed||!this._projectionEngineLoaded&&this._filterNeedsProjectionEngine),e).then((async()=>{s(e),await d(),this._projectionEngineLoaded=!0})).catch(a)}destroy(){this._abortController=o(this._abortController)}highlight(e){throw new Error("Not implemented")}queryFeatures(e,t){throw new Error("Not implemented")}queryObjectIds(e,t){throw new Error("Not implemented")}queryFeatureCount(e,t){throw new Error("Not implemented")}createQuery(){throw new Error("Not implemented")}queryExtent(e,t){throw new Error("Not implemented")}};e([p()],E.prototype,"layer",void 0),e([p()],E.prototype,"availableFields",null),e([p()],E.prototype,"maximumNumberOfFeatures",null),e([p({readOnly:!0})],E.prototype,"maximumNumberOfFeaturesExceeded",null),e([p()],E.prototype,"filter",void 0),e([p({readOnly:!0})],E.prototype,"layerFilter",null),e([p({readOnly:!0})],E.prototype,"_layerFilter",null),e([p()],E.prototype,"_geometryEngine",void 0),e([p()],E.prototype,"_projectionEngineLoaded",void 0),e([p()],E.prototype,"_filterNeedsProjectionEngine",null),e([p()],E.prototype,"layerFilterUpdating",null),E=e([c(f)],E);const j=E;export{j as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../Color.js";async function n(n){await n.whenReady();const r=n.basemapView?.baseLayerViews.map((t=>t.layer)).toArray()??[];if(!r.length){const r=getComputedStyle(n.container).backgroundColor,a=r&&new t(r);return n.get("background.color")||(a&&0!==a.a?a:null)||null}const a=(await n.takeScreenshot({format:"png",layers:r})).data.data,o=a.length;let e=0,u=0,l=0,c=0,s=0,i=0;for(let t=0;t<o;t+=4){const n=a[t],r=a[t+1],o=a[t+2],h=a[t+3],d=h/255;e+=n*n*d,u+=r*r*d,l+=o*o*d,s+=d,h&&(c+=h,i++)}e=Math.round(Math.sqrt(e/s)),u=Math.round(Math.sqrt(u/s)),l=Math.round(Math.sqrt(l/s));return new t([e,u,l,c/i/255])}async function r(t){if(!t)return null;const r=await n(t);return null!=r?a(r):null}function a(t){return o(t).isBright?"light":"dark"}function o(n){let{r,g:a,b:o,a:e}=n;return e<1&&(r=Math.round(e*r+255*(1-e)),a=Math.round(e*a+255*(1-e)),o=Math.round(e*o+255*(1-e))),new t({r,g:a,b:o})}function e(t){const{r:n,g:r,b:a}=o(t);return.2126*n+.7152*r+.0722*a}export{n as getBackgroundColor,r as getBackgroundColorTheme,e as getColorLuminance,a as getColorTheme};
5
+ import t from"../../Color.js";async function n(n){await n.whenReady();const r=n.basemapView?.baseLayerViews.map((t=>t.layer)).toArray()??[];if(!r.length){const r=getComputedStyle(n.container).backgroundColor,a=r&&new t(r);return n.get("background.color")||(a&&0!==a.a?a:null)||null}const a=(await n.takeScreenshot({format:"png",layers:r})).data.data,o=a.length;let e=0,u=0,l=0,c=0,i=0,s=0;for(let t=0;t<o;t+=4){const n=a[t],r=a[t+1],o=a[t+2],h=a[t+3],d=h/255;e+=n*n*d,u+=r*r*d,l+=o*o*d,i+=d,h&&(c+=h,s++)}e=Math.round(Math.sqrt(e/i)),u=Math.round(Math.sqrt(u/i)),l=Math.round(Math.sqrt(l/i));return new t([e,u,l,c/s/255])}async function r(t){if(!t)return null;const r=await n(t);return null!=r?a(r):null}function a(t){return o(t).isBright?"light":"dark"}function o(n){let{r,g:a,b:o,a:e}=n;return e<1&&(r=Math.round(e*r+255*(1-e)),a=Math.round(e*a+255*(1-e)),o=Math.round(e*o+255*(1-e))),new t({r,g:a,b:o})}function e(t,n){const{r,g:a,b:e}=n?.ignoreAlpha?t:o(t);return.2126*r+.7152*a+.0722*e}export{n as getBackgroundColor,r as getBackgroundColorTheme,e as getColorLuminance,a as getColorTheme};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import"../../core/has.js";import{ShaderType as t}from"./enums.js";import e from"./reservedWordsGLSL3.js";import{shaderTranspiler as a}from"./testUtils.js";import{o as r,l as n,b as o}from"../../chunks/builtins.js";var i=999,s=9999,c=0,u=1,p=2,d=3,f=4,l=5,h=6,y=7,w=8,g=9,m=10,k=11,b=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function E(){var t,e,a,E=0,_=0,v=i,j=[],x=[],D=1,R=0,T=0,A=!1,G=!1,S="";return function(t){return x=[],null!==t?F(t.replace?t.replace(/\r\n/g,"\n"):t):L()};function X(t){t.length&&x.push({type:b[v],data:t,position:T,line:D,column:R})}function F(e){var r;for(E=0,a=(S+=e).length;t=S[E],E<a;){switch(r=E,v){case c:E=V();break;case u:E=P();break;case p:E=M();break;case d:E=O();break;case f:E=z();break;case k:E=$();break;case l:E=I();break;case s:E=U();break;case g:E=H();break;case i:E=C()}if(r!==E)if("\n"===S[r])R=0,++D;else++R}return _+=E,S=S.slice(E),x}function L(t){return j.length&&X(j.join("")),v=m,X("(eof)"),x}function C(){return j=j.length?[]:j,"/"===e&&"*"===t?(T=_+E-1,v=c,e=t,E+1):"/"===e&&"/"===t?(T=_+E-1,v=u,e=t,E+1):"#"===t?(v=p,T=_+E,E):/\s/.test(t)?(v=g,T=_+E,E):(A=/\d/.test(t),G=/[^\w_]/.test(t),T=_+E,v=A?f:G?d:s,E)}function H(){return/[^\s]/g.test(t)?(X(j.join("")),v=i,E):(j.push(t),e=t,E+1)}function M(){return"\r"!==t&&"\n"!==t||"\\"===e?(j.push(t),e=t,E+1):(X(j.join("")),v=i,E)}function P(){return M()}function V(){return"/"===t&&"*"===e?(j.push(t),X(j.join("")),v=i,E+1):(j.push(t),e=t,E+1)}function O(){if("."===e&&/\d/.test(t))return v=l,E;if("/"===e&&"*"===t)return v=c,E;if("/"===e&&"/"===t)return v=u,E;if("."===t&&j.length){for(;N(j););return v=l,E}if(";"===t||")"===t||"("===t){if(j.length)for(;N(j););return X(t),v=i,E+1}var a=2===j.length&&"="!==t;if(/[\w_\d\s]/.test(t)||a){for(;N(j););return v=i,E}return j.push(t),e=t,E+1}function N(t){for(var e,a,n=0;;){if(e=r.indexOf(t.slice(0,t.length+n).join("")),a=r[e],-1===e){if(n--+t.length>0)continue;a=t.slice(0,1).join("")}return X(a),T+=a.length,(j=j.slice(a.length)).length}}function $(){return/[^a-fA-F0-9]/.test(t)?(X(j.join("")),v=i,E):(j.push(t),e=t,E+1)}function z(){return"."===t||/[eE]/.test(t)?(j.push(t),v=l,e=t,E+1):"x"===t&&1===j.length&&"0"===j[0]?(v=k,j.push(t),e=t,E+1):/[^\d]/.test(t)?(X(j.join("")),v=i,E):(j.push(t),e=t,E+1)}function I(){return"f"===t&&(j.push(t),e=t,E+=1),/[eE]/.test(t)||"-"===t&&/[eE]/.test(e)?(j.push(t),e=t,E+1):/[^\d]/.test(t)?(X(j.join("")),v=i,E):(j.push(t),e=t,E+1)}function U(){if(/[^\d\w_]/.test(t)){var a=j.join("");return v=n.indexOf(a)>-1?w:o.indexOf(a)>-1?y:h,X(j.join("")),v=i,E}return j.push(t),e=t,E+1}}function _(t){var e=E(),a=[];return a=(a=a.concat(e(t))).concat(e(null))}function v(t){return _(t)}function j(t){return t.map((t=>"eof"!==t.type?t.data:"")).join("")}const x=["GL_OES_standard_derivatives","GL_EXT_frag_depth","GL_EXT_draw_buffers","GL_EXT_shader_texture_lod"];function D(t,e="100",a="300 es"){const r=/^\s*\#version\s+([0-9]+(\s+[a-zA-Z]+)?)\s*/;for(const n of t)if("preprocessor"===n.type){const t=r.exec(n.data);if(t){const r=t[1].replace(/\s\s+/g," ");if(r===a)return r;if(r===e)return n.data="#version "+a,e;throw new Error("unknown glsl version: "+r)}}return t.splice(0,0,{type:"preprocessor",data:"#version "+a},{type:"whitespace",data:"\n"}),null}function R(t,e){for(let a=e-1;a>=0;a--){const e=t[a];if("whitespace"!==e.type&&"block-comment"!==e.type){if("keyword"!==e.type)break;if("attribute"===e.data||"in"===e.data)return!0}}return!1}function T(t,e,a,r){r=r||a;for(const n of t)if("ident"===n.type&&n.data===a){r in e?e[r]++:e[r]=0;return T(t,e,r+"_"+e[r],r)}return a}function A(t,e,a="afterVersion"){function r(t,e){for(let a=e;a<t.length;a++){const e=t[a];if("operator"===e.type&&";"===e.data)return a}return null}function n(t){let e=-1,n=0,o=-1;for(let i=0;i<t.length;i++){const s=t[i];if("preprocessor"===s.type&&(s.data.match(/\#(if|ifdef|ifndef)\s+.+/)?++n:s.data.match(/\#endif\s*.*/)&&--n),"afterVersion"!==a&&"afterPrecision"!==a||"preprocessor"===s.type&&/^#version/.test(s.data)&&(o=Math.max(o,i)),"afterPrecision"===a&&"keyword"===s.type&&"precision"===s.data){const e=r(t,i);if(null===e)throw new Error("precision statement not followed by any semicolons!");o=Math.max(o,e)}e<o&&0===n&&(e=i)}return e+1}const o={data:"\n",type:"whitespace"},i=e=>e<t.length&&/[^\r\n]$/.test(t[e].data);let s=n(t);i(s-1)&&t.splice(s++,0,o);for(const c of e)t.splice(s++,0,c);i(s-1)&&i(s)&&t.splice(s,0,o)}function G(t,e,a,r="lowp"){A(t,[{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:r},{type:"whitespace",data:" "},{type:"keyword",data:a},{type:"whitespace",data:" "},{type:"ident",data:e},{type:"operator",data:";"}],"afterPrecision")}function S(t,e,a,r,n="lowp"){A(t,[{type:"keyword",data:"layout"},{type:"operator",data:"("},{type:"keyword",data:"location"},{type:"whitespace",data:" "},{type:"operator",data:"="},{type:"whitespace",data:" "},{type:"integer",data:r.toString()},{type:"operator",data:")"},{type:"whitespace",data:" "},{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:n},{type:"whitespace",data:" "},{type:"keyword",data:a},{type:"whitespace",data:" "},{type:"ident",data:e},{type:"operator",data:";"}],"afterPrecision")}function X(t,e){let a,r,n=-1;for(let o=e;o<t.length;o++){const e=t[o];if("operator"===e.type&&("["===e.data&&(a=o),"]"===e.data)){r=o;break}"integer"===e.type&&(n=parseInt(e.data,10))}return a&&r&&t.splice(a,r-a+1),n}function F(a,r){const n=C(a);if(null!=n)return n;const o=v(a);if("300 es"===D(o,"100","300 es"))return a;let i=null,s=null;const c={},u={};for(let p=0;p<o.length;++p){const a=o[p];switch(a.type){case"keyword":r===t.VERTEX_SHADER&&"attribute"===a.data?a.data="in":"varying"===a.data&&(a.data=r===t.VERTEX_SHADER?"out":"in");break;case"builtin":if(/^texture(2D|Cube)(Proj)?(Lod|Grad)?(EXT)?$/.test(a.data.trim())&&(a.data=a.data.replace(/(2D|Cube|EXT)/g,"")),r===t.FRAGMENT_SHADER&&"gl_FragColor"===a.data&&(i||(i=T(o,c,"fragColor"),G(o,i,"vec4")),a.data=i),r===t.FRAGMENT_SHADER&&"gl_FragData"===a.data){const t=X(o,p+1),e=T(o,c,"fragData");S(o,e,"vec4",t,"mediump"),a.data=e}else r===t.FRAGMENT_SHADER&&"gl_FragDepthEXT"===a.data&&(s||(s=T(o,c,"gl_FragDepth")),a.data=s);break;case"ident":if(e.includes(a.data)){if(r===t.VERTEX_SHADER&&R(o,p))throw new Error("attribute in vertex shader uses a name that is a reserved word in glsl 300 es");a.data in u||(u[a.data]=T(o,c,a.data)),a.data=u[a.data]}}}for(let t=o.length-1;t>=0;--t){const e=o[t];if("preprocessor"===e.type){const a=e.data.match(/\#extension\s+(.*)\:/);if(a&&a[1]&&x.includes(a[1].trim())){const e=o[t+1];o.splice(t,e&&"whitespace"===e.type?2:1)}const r=e.data.match(/\#ifdef\s+(.*)/);r&&r[1]&&x.includes(r[1].trim())&&(e.data="#if 1");const n=e.data.match(/\#ifndef\s+(.*)/);n&&n[1]&&x.includes(n[1].trim())&&(e.data="#if 0")}}return H(a,j(o))}const L=new Map;function C(t){return a.enableCache?L.get(t):null}function H(t,e){return a.enableCache&&L.set(t,e),e}export{F as transpileShader};
5
+ import"../../core/has.js";import{ShaderType as t}from"./enums.js";import e from"./reservedWordsGLSL3.js";import{shaderTranspiler as a}from"./testUtils.js";import{o as r,l as n,b as o}from"../../chunks/builtins.js";var i=999,s=9999,c=0,u=1,p=2,d=3,f=4,l=5,h=6,y=7,w=8,g=9,m=10,k=11,b=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function E(){var t,e,a,E=0,_=0,v=i,j=[],x=[],D=1,R=0,T=0,A=!1,G=!1,S="";return function(t){return x=[],null!==t?F(t.replace?t.replace(/\r\n/g,"\n"):t):L()};function X(t){t.length&&x.push({type:b[v],data:t,position:T,line:D,column:R})}function F(e){var r;for(E=0,a=(S+=e).length;t=S[E],E<a;){switch(r=E,v){case c:E=V();break;case u:E=P();break;case p:E=M();break;case d:E=O();break;case f:E=$();break;case k:E=W();break;case l:E=z();break;case s:E=I();break;case g:E=H();break;case i:E=C()}if(r!==E)if("\n"===S[r])R=0,++D;else++R}return _+=E,S=S.slice(E),x}function L(t){return j.length&&X(j.join("")),v=m,X("(eof)"),x}function C(){return j=j.length?[]:j,"/"===e&&"*"===t?(T=_+E-1,v=c,e=t,E+1):"/"===e&&"/"===t?(T=_+E-1,v=u,e=t,E+1):"#"===t?(v=p,T=_+E,E):/\s/.test(t)?(v=g,T=_+E,E):(A=/\d/.test(t),G=/[^\w_]/.test(t),T=_+E,v=A?f:G?d:s,E)}function H(){return/[^\s]/g.test(t)?(X(j.join("")),v=i,E):(j.push(t),e=t,E+1)}function M(){return"\r"!==t&&"\n"!==t||"\\"===e?(j.push(t),e=t,E+1):(X(j.join("")),v=i,E)}function P(){return M()}function V(){return"/"===t&&"*"===e?(j.push(t),X(j.join("")),v=i,E+1):(j.push(t),e=t,E+1)}function O(){if("."===e&&/\d/.test(t))return v=l,E;if("/"===e&&"*"===t)return v=c,E;if("/"===e&&"/"===t)return v=u,E;if("."===t&&j.length){for(;N(j););return v=l,E}if(";"===t||")"===t||"("===t){if(j.length)for(;N(j););return X(t),v=i,E+1}var a=2===j.length&&"="!==t;if(/[\w_\d\s]/.test(t)||a){for(;N(j););return v=i,E}return j.push(t),e=t,E+1}function N(t){for(var e,a,n=0;;){if(e=r.indexOf(t.slice(0,t.length+n).join("")),a=r[e],-1===e){if(n--+t.length>0)continue;a=t.slice(0,1).join("")}return X(a),T+=a.length,(j=j.slice(a.length)).length}}function W(){return/[^a-fA-F0-9]/.test(t)?(X(j.join("")),v=i,E):(j.push(t),e=t,E+1)}function $(){return"."===t||/[eE]/.test(t)?(j.push(t),v=l,e=t,E+1):"x"===t&&1===j.length&&"0"===j[0]?(v=k,j.push(t),e=t,E+1):/[^\d]/.test(t)?(X(j.join("")),v=i,E):(j.push(t),e=t,E+1)}function z(){return"f"===t&&(j.push(t),e=t,E+=1),/[eE]/.test(t)||"-"===t&&/[eE]/.test(e)?(j.push(t),e=t,E+1):/[^\d]/.test(t)?(X(j.join("")),v=i,E):(j.push(t),e=t,E+1)}function I(){if(/[^\d\w_]/.test(t)){var a=j.join("");return v=n.indexOf(a)>-1?w:o.indexOf(a)>-1?y:h,X(j.join("")),v=i,E}return j.push(t),e=t,E+1}}function _(t){var e=E(),a=[];return a=(a=a.concat(e(t))).concat(e(null))}function v(t){return _(t)}function j(t){return t.map((t=>"eof"!==t.type?t.data:"")).join("")}const x=["GL_OES_standard_derivatives","GL_EXT_frag_depth","GL_EXT_draw_buffers","GL_EXT_shader_texture_lod"];function D(t,e="100",a="300 es"){const r=/^\s*\#version\s+([0-9]+(\s+[a-zA-Z]+)?)\s*/;for(const n of t)if("preprocessor"===n.type){const t=r.exec(n.data);if(t){const r=t[1].replace(/\s\s+/g," ");if(r===a)return r;if(r===e)return n.data="#version "+a,e;throw new Error("unknown glsl version: "+r)}}return t.splice(0,0,{type:"preprocessor",data:"#version "+a},{type:"whitespace",data:"\n"}),null}function R(t,e){for(let a=e-1;a>=0;a--){const e=t[a];if("whitespace"!==e.type&&"block-comment"!==e.type){if("keyword"!==e.type)break;if("attribute"===e.data||"in"===e.data)return!0}}return!1}function T(t,e,a,r){r=r||a;for(const n of t)if("ident"===n.type&&n.data===a){r in e?e[r]++:e[r]=0;return T(t,e,r+"_"+e[r],r)}return a}function A(t,e,a="afterVersion"){function r(t,e){for(let a=e;a<t.length;a++){const e=t[a];if("operator"===e.type&&";"===e.data)return a}return null}function n(t){let e=-1,n=0,o=-1;for(let i=0;i<t.length;i++){const s=t[i];if("preprocessor"===s.type&&(s.data.match(/\#(if|ifdef|ifndef)\s+.+/)?++n:s.data.match(/\#endif\s*.*/)&&--n),"afterVersion"!==a&&"afterPrecision"!==a||"preprocessor"===s.type&&/^#version/.test(s.data)&&(o=Math.max(o,i)),"afterPrecision"===a&&"keyword"===s.type&&"precision"===s.data){const e=r(t,i);if(null===e)throw new Error("precision statement not followed by any semicolons!");o=Math.max(o,e)}e<o&&0===n&&(e=i)}return e+1}const o={data:"\n",type:"whitespace"},i=e=>e<t.length&&/[^\r\n]$/.test(t[e].data);let s=n(t);i(s-1)&&t.splice(s++,0,o);for(const c of e)t.splice(s++,0,c);i(s-1)&&i(s)&&t.splice(s,0,o)}function G(t,e,a,r="lowp"){A(t,[{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:r},{type:"whitespace",data:" "},{type:"keyword",data:a},{type:"whitespace",data:" "},{type:"ident",data:e},{type:"operator",data:";"}],"afterPrecision")}function S(t,e,a,r,n="lowp"){A(t,[{type:"keyword",data:"layout"},{type:"operator",data:"("},{type:"keyword",data:"location"},{type:"whitespace",data:" "},{type:"operator",data:"="},{type:"whitespace",data:" "},{type:"integer",data:r.toString()},{type:"operator",data:")"},{type:"whitespace",data:" "},{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:n},{type:"whitespace",data:" "},{type:"keyword",data:a},{type:"whitespace",data:" "},{type:"ident",data:e},{type:"operator",data:";"}],"afterPrecision")}function X(t,e){let a,r,n=-1;for(let o=e;o<t.length;o++){const e=t[o];if("operator"===e.type&&("["===e.data&&(a=o),"]"===e.data)){r=o;break}"integer"===e.type&&(n=parseInt(e.data,10))}return a&&r&&t.splice(a,r-a+1),n}function F(a,r){if(a.startsWith("#version 300"))return a;const n=C(a);if(null!=n)return n;const o=v(a);if("300 es"===D(o,"100","300 es"))return a;let i=null,s=null;const c={},u={};for(let p=0;p<o.length;++p){const a=o[p];switch(a.type){case"keyword":r===t.VERTEX_SHADER&&"attribute"===a.data?a.data="in":"varying"===a.data&&(a.data=r===t.VERTEX_SHADER?"out":"in");break;case"builtin":if(/^texture(2D|Cube)(Proj)?(Lod|Grad)?(EXT)?$/.test(a.data.trim())&&(a.data=a.data.replace(/(2D|Cube|EXT)/g,"")),r===t.FRAGMENT_SHADER&&"gl_FragColor"===a.data&&(i||(i=T(o,c,"fragColor"),G(o,i,"vec4")),a.data=i),r===t.FRAGMENT_SHADER&&"gl_FragData"===a.data){const t=X(o,p+1),e=T(o,c,"fragData");S(o,e,"vec4",t,"mediump"),a.data=e}else r===t.FRAGMENT_SHADER&&"gl_FragDepthEXT"===a.data&&(s||(s=T(o,c,"gl_FragDepth")),a.data=s);break;case"ident":if(e.includes(a.data)){if(r===t.VERTEX_SHADER&&R(o,p))throw new Error("attribute in vertex shader uses a name that is a reserved word in glsl 300 es");a.data in u||(u[a.data]=T(o,c,a.data)),a.data=u[a.data]}}}for(let t=o.length-1;t>=0;--t){const e=o[t];if("preprocessor"===e.type){const a=e.data.match(/\#extension\s+(.*)\:/);if(a&&a[1]&&x.includes(a[1].trim())){const e=o[t+1];o.splice(t,e&&"whitespace"===e.type?2:1)}const r=e.data.match(/\#ifdef\s+(.*)/);r&&r[1]&&x.includes(r[1].trim())&&(e.data="#if 1");const n=e.data.match(/\#ifndef\s+(.*)/);n&&n[1]&&x.includes(n[1].trim())&&(e.data="#if 0")}}return H(a,j(o))}const L=new Map;function C(t){return a.enableCache?L.get(t):null}function H(t,e){return a.enableCache&&L.set(t,e),e}export{F as transpileShader};