@arcgis/core 4.28.0-next.20230621 → 4.28.0-next.20230623

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 (249) hide show
  1. package/Basemap.js +1 -1
  2. package/arcade/ArcadeModuleResolver.js +1 -1
  3. package/arcade/Feature.js +1 -1
  4. package/arcade/arcadeCompiler.js +1 -1
  5. package/arcade/arcadeTimeUtils.js +1 -1
  6. package/arcade/featureset/actions/GroupBy.js +1 -1
  7. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  8. package/arcade/featureset/support/sqlUtils.js +1 -1
  9. package/arcade/functions/date.js +1 -1
  10. package/arcade/functions/geomasync.js +1 -1
  11. package/arcade/functions/geometry.js +1 -1
  12. package/arcade/functions/geomsync.js +1 -1
  13. package/arcade/functions/string.js +1 -1
  14. package/arcade/languageUtils.js +1 -1
  15. package/assets/esri/core/workers/RemoteClient.js +1 -1
  16. package/assets/esri/core/workers/chunks/0380e9f61b6f3ca85139.js +1 -0
  17. package/assets/esri/core/workers/chunks/0bd95f46a0a9005a19f9.js +1 -0
  18. package/assets/esri/core/workers/chunks/0c621046b7211cdde980.js +1 -0
  19. package/assets/esri/core/workers/chunks/0e0267739728e5413f1d.js +1 -0
  20. package/assets/esri/core/workers/chunks/{39079bcfd35ed73c4e34.js → 156e801a3262f0ac79c0.js} +1 -1
  21. package/assets/esri/core/workers/chunks/19b4f02fb2392d964582.js +1 -0
  22. package/assets/esri/core/workers/chunks/1ae75f5282e983f6d768.js +1 -0
  23. package/assets/esri/core/workers/chunks/2179b3e9e532ca8ef982.js +1 -0
  24. package/assets/esri/core/workers/chunks/21aaa7fa0e5482670010.js +1 -0
  25. package/assets/esri/core/workers/chunks/26212a08ea383547335b.js +1 -0
  26. package/assets/esri/core/workers/chunks/{2420ec029236ab31d908.js → 2882a55a971af1f7858b.js} +1 -1
  27. package/assets/esri/core/workers/chunks/294285f2822c101326ec.js +1 -0
  28. package/assets/esri/core/workers/chunks/29f9a380610e4fd98a7c.js +1 -0
  29. package/assets/esri/core/workers/chunks/303238fc2fcdbb277981.js +1 -0
  30. package/assets/esri/core/workers/chunks/{3db8ae98799c752afe60.js → 34958516e604d487c625.js} +1 -1
  31. package/assets/esri/core/workers/chunks/3bee743f4c9370045a5d.js +1 -0
  32. package/assets/esri/core/workers/chunks/{8e08968505483dc58e00.js → 40ee4e0a5000a08c3abd.js} +1 -1
  33. package/assets/esri/core/workers/chunks/4128e45e17c9e5280e11.js +1 -0
  34. package/assets/esri/core/workers/chunks/4f88c4d1d2103843aca8.js +1 -0
  35. package/assets/esri/core/workers/chunks/505792ce8cbbddd2e815.js +1 -0
  36. package/assets/esri/core/workers/chunks/{3d42fa4ab5f8632d690a.js → 5237b3938be0d4bc6045.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{57077e608f20d3a931e8.js → 570e94f4fbefc856d303.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{4b235d1b6a72773cd4f4.js → 57bb8516fa998a0fba78.js} +1 -1
  39. package/assets/esri/core/workers/chunks/57bf3ff01d738cedc292.js +1 -0
  40. package/assets/esri/core/workers/chunks/{1e9e68312cd865358260.js → 60486acc5dacf73f851a.js} +1 -1
  41. package/assets/esri/core/workers/chunks/6208f2dfa9dfd3bca000.js +1 -0
  42. package/assets/esri/core/workers/chunks/64008bde5d3ffd9f2499.js +1 -0
  43. package/assets/esri/core/workers/chunks/69f51a7768bf51c9e346.js +1 -0
  44. package/assets/esri/core/workers/chunks/719f741a0e45c3e694ba.js +1 -0
  45. package/assets/esri/core/workers/chunks/{cfe379a78a983373b3ac.js → 7304f45f5622a68253e4.js} +1 -1
  46. package/assets/esri/core/workers/chunks/733b70d6e5c466a67e9c.js +1 -0
  47. package/assets/esri/core/workers/chunks/7694521b44681d52b713.js +1 -0
  48. package/assets/esri/core/workers/chunks/840fd05ceaa038c476d6.js +1 -0
  49. package/assets/esri/core/workers/chunks/89f7fd2ab92aa14fe0c0.js +1 -0
  50. package/assets/esri/core/workers/chunks/8a6f29f2ebd59783bb1b.js +1 -0
  51. package/assets/esri/core/workers/chunks/9d487b7817ccf5bceff6.js +1 -0
  52. package/assets/esri/core/workers/chunks/{42b6315e21c4c1345ba5.js → 9f5337a80963e0b3c009.js} +1 -1
  53. package/assets/esri/core/workers/chunks/a0face18b3ea567999ef.js +1 -0
  54. package/assets/esri/core/workers/chunks/b773c8854e98384ac8ac.js +1 -0
  55. package/assets/esri/core/workers/chunks/{fb44d872b9dbadcf8ccf.js → b9ef05c22bc3e395bcb3.js} +1 -1
  56. package/assets/esri/core/workers/chunks/bc5e34200776cfc83d5b.js +1 -0
  57. package/assets/esri/core/workers/chunks/{cfc3dcca2b69d20d5375.js → c0b9cc091efd5db827de.js} +1 -1
  58. package/assets/esri/core/workers/chunks/c9f5e949830196ad9458.js +1 -0
  59. package/assets/esri/core/workers/chunks/{036301f545aba2b8e485.js → cc15e28a99694120556d.js} +1 -1
  60. package/assets/esri/core/workers/chunks/ce7f575a6c2053c7ca17.js +1 -0
  61. package/assets/esri/core/workers/chunks/ce9c99cee3d1a3963e7c.js +1 -0
  62. package/assets/esri/core/workers/chunks/cf9a87b53ea74bae6a37.js +1 -0
  63. package/assets/esri/core/workers/chunks/d16850b98a53ade0de10.js +1 -0
  64. package/assets/esri/core/workers/chunks/d24f7ef6eca8c91b90b4.js +1 -0
  65. package/assets/esri/core/workers/chunks/dbd86e4b7983873cbe7c.js +1 -0
  66. package/assets/esri/core/workers/chunks/{3c3f65913006b84b2289.js → de20572d334abd4a7d82.js} +1 -1
  67. package/assets/esri/core/workers/chunks/e009e7f074a572894f48.js +1 -0
  68. package/assets/esri/core/workers/chunks/{cb004c492e22c50f9bfa.js → f3eb89cff63e00f036c6.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{b2a423d9ce8bb784267c.js → f53f20c7100092823487.js} +1 -1
  70. package/assets/esri/core/workers/chunks/f6040205c50e2795a1a0.js +1 -0
  71. package/assets/esri/core/workers/chunks/{915734255a79bff3ef0f.js → fcd54e9e64c2864f183c.js} +1 -1
  72. package/assets/esri/t9n/common.json +1 -1
  73. package/assets/esri/t9n/common_en.json +1 -1
  74. package/assets/esri/themes/base/_core.scss +6 -2
  75. package/assets/esri/themes/base/_mixins.scss +0 -147
  76. package/assets/esri/themes/base/widgets/_AreaMeasurement2D.scss +0 -8
  77. package/assets/esri/themes/base/widgets/_AreaMeasurement3D.scss +0 -8
  78. package/assets/esri/themes/base/widgets/_DirectLineMeasurement3D.scss +0 -1
  79. package/assets/esri/themes/base/widgets/_DistanceMeasurement2D.scss +0 -1
  80. package/assets/esri/themes/base/widgets/_MeasurementWidgetContent.scss +67 -0
  81. package/assets/esri/themes/base/widgets/_Slice.scss +17 -54
  82. package/assets/esri/themes/base/widgets/_UnitSelect.scss +14 -0
  83. package/assets/esri/themes/dark/main.css +1 -1
  84. package/assets/esri/themes/light/main.css +1 -1
  85. package/assets/esri/themes/light/view.css +1 -1
  86. package/assets/esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D.json +1 -1
  87. package/assets/esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D_en.json +1 -1
  88. package/assets/esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D.json +1 -1
  89. package/assets/esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D_en.json +1 -1
  90. package/assets/esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D.json +1 -1
  91. package/assets/esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D_en.json +1 -1
  92. package/assets/esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D.json +1 -1
  93. package/assets/esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D_en.json +1 -1
  94. package/chunks/HUDMaterial.glsl.js +39 -39
  95. package/chunks/HighlightBlur.glsl.js +2 -2
  96. package/chunks/ShadowHighlight.glsl.js +1 -1
  97. package/chunks/arcade.js +1 -1
  98. package/chunks/languageUtils.js +1 -1
  99. package/core/HandleOwner.js +1 -1
  100. package/core/promiseUtils.js +1 -1
  101. package/core/support/{WatchUpdatingTracking.js → UpdatingHandles.js} +1 -1
  102. package/core/workers/workerFactory.js +1 -1
  103. package/geometry/projection.js +1 -1
  104. package/interfaces.d.ts +270 -5
  105. package/kernel.js +1 -1
  106. package/layers/Layer.js +1 -1
  107. package/layers/LinkChartLayer.d.ts +4 -0
  108. package/layers/LinkChartLayer.js +1 -1
  109. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  110. package/layers/mixins/PortalLayer.js +1 -1
  111. package/layers/support/TileInfoTilemapCache.js +1 -1
  112. package/package.json +1 -1
  113. package/support/revision.js +1 -1
  114. package/symbols/cim/cimAnalyzer.js +1 -1
  115. package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
  116. package/views/2d/layers/features/sources/DataTileSource.js +1 -1
  117. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  118. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  119. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  120. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  121. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  122. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  123. package/views/3d/analysis/LineOfSight/LineOfSightVisualization.js +1 -1
  124. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  125. package/views/3d/environment/CloudsGenerator.js +1 -1
  126. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  127. package/views/3d/environment/Precipitation.js +1 -1
  128. package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
  129. package/views/3d/environment/Stars.js +1 -1
  130. package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
  131. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  132. package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
  133. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  134. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  135. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  136. package/views/3d/layers/I3SMeshView3D.js +1 -1
  137. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  138. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  139. package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
  140. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  141. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  142. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  143. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  144. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  145. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  146. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  147. package/views/3d/layers/graphics/Graphics3DScaleVisibility.js +1 -1
  148. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  149. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  150. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  151. package/views/3d/layers/graphics/GraphicsProcessor.js +1 -1
  152. package/views/3d/layers/graphics/Labeler.js +1 -1
  153. package/views/3d/layers/graphics/labelPlacement.js +1 -1
  154. package/views/3d/layers/support/FeatureTileTree3DDebugger.js +1 -1
  155. package/views/3d/layers/support/FeatureVisibilityFilter.js +1 -1
  156. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  157. package/views/3d/state/ViewState.js +1 -1
  158. package/views/3d/state/ViewStateManager.js +1 -1
  159. package/views/3d/support/DisplayQualityProfile.js +1 -1
  160. package/views/3d/support/MemoryController.js +1 -1
  161. package/views/3d/support/SceneViewPerformanceInfo.js +1 -1
  162. package/views/3d/support/cameraUtils.js +1 -1
  163. package/views/3d/support/viewpointUtils.js +1 -1
  164. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  165. package/views/3d/terrain/OverlayManager.js +1 -1
  166. package/views/3d/terrain/OverlayRenderer.js +1 -1
  167. package/views/3d/terrain/TerrainSurface.js +1 -1
  168. package/views/3d/webgl-engine/Stage.js +1 -1
  169. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  170. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUDOcclusionPass.glsl.js +6 -7
  171. package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +1 -1
  172. package/views/3d/webgl-engine/lib/Highlight.js +1 -1
  173. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  174. package/views/3d/webgl-engine/lib/RenderPluginManager.js +1 -1
  175. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  176. package/views/3d/webgl-engine/lib/SSAOHelper.js +1 -1
  177. package/views/3d/webgl-engine/lib/SmaaRenderPass.js +1 -1
  178. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  179. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  180. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  181. package/views/LayerViewManager.js +1 -1
  182. package/views/ToolViewManager.js +1 -1
  183. package/views/draw/DrawOperation.js +1 -1
  184. package/views/draw/PointDrawAction.js +1 -1
  185. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  186. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  187. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  188. package/views/interactive/snapping/featureSources/I3SSnappingSource.js +1 -1
  189. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  190. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
  191. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
  192. package/views/layers/LayerView.js +1 -1
  193. package/views/overlay/ViewOverlay.js +1 -1
  194. package/views/webgl/Texture.js +1 -1
  195. package/widgets/AreaMeasurement2D.js +1 -1
  196. package/widgets/AreaMeasurement3D.js +1 -1
  197. package/widgets/DirectLineMeasurement3D.js +1 -1
  198. package/widgets/DistanceMeasurement2D.js +1 -1
  199. package/widgets/Editor/EditorViewModel.js +1 -1
  200. package/widgets/Editor/Workflow.js +1 -1
  201. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  202. package/widgets/FeatureForm/FieldInput.js +1 -1
  203. package/widgets/FeatureForm/FormExpressionArcadeExecutor.js +1 -1
  204. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  205. package/widgets/OrientedImageryViewer.js +1 -1
  206. package/widgets/Slice.js +1 -1
  207. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
  208. package/widgets/support/MeasurementWidgetContent.js +5 -0
  209. package/widgets/support/UnitSelect.js +5 -0
  210. package/assets/esri/core/workers/chunks/0254165377538522c830.js +0 -1
  211. package/assets/esri/core/workers/chunks/07f16ea775b39a1a4a7b.js +0 -1
  212. package/assets/esri/core/workers/chunks/170c72126d10b1fdb2b0.js +0 -1
  213. package/assets/esri/core/workers/chunks/1bbc868d2430103951eb.js +0 -1
  214. package/assets/esri/core/workers/chunks/1d2ef88a8d028adef102.js +0 -1
  215. package/assets/esri/core/workers/chunks/2ef70c9b2484a11b7435.js +0 -1
  216. package/assets/esri/core/workers/chunks/39ae4b9b766f674bc6f2.js +0 -1
  217. package/assets/esri/core/workers/chunks/3b3d676b609c47a77164.js +0 -1
  218. package/assets/esri/core/workers/chunks/3d9a8cb638cf9b8ca4b3.js +0 -1
  219. package/assets/esri/core/workers/chunks/42f3421740a5479559dc.js +0 -1
  220. package/assets/esri/core/workers/chunks/45629ff775e77234b227.js +0 -1
  221. package/assets/esri/core/workers/chunks/52315f93a6f0ad59bd90.js +0 -1
  222. package/assets/esri/core/workers/chunks/5bb96e602d7cecbecf54.js +0 -1
  223. package/assets/esri/core/workers/chunks/63322229183f1d4eaa70.js +0 -1
  224. package/assets/esri/core/workers/chunks/642510b0371311ff8e16.js +0 -1
  225. package/assets/esri/core/workers/chunks/6995ace1d25d67c98d0e.js +0 -1
  226. package/assets/esri/core/workers/chunks/7e4013f8c31c9a9438c6.js +0 -1
  227. package/assets/esri/core/workers/chunks/82939ead43848a13f765.js +0 -1
  228. package/assets/esri/core/workers/chunks/8b6b963230df56850580.js +0 -1
  229. package/assets/esri/core/workers/chunks/95ff92d7caa34664d58f.js +0 -1
  230. package/assets/esri/core/workers/chunks/9e570cd4a48c30c83ae6.js +0 -1
  231. package/assets/esri/core/workers/chunks/a9e9297267614c4c4f3b.js +0 -1
  232. package/assets/esri/core/workers/chunks/b052463ffb7cb32306dc.js +0 -1
  233. package/assets/esri/core/workers/chunks/b31974524932e638df8c.js +0 -1
  234. package/assets/esri/core/workers/chunks/b75b4b132dbd9cb9d372.js +0 -1
  235. package/assets/esri/core/workers/chunks/c1dfbda75abc748a6ca4.js +0 -1
  236. package/assets/esri/core/workers/chunks/c8702e53a8ad6cf6ab85.js +0 -1
  237. package/assets/esri/core/workers/chunks/c90416e7bf29eb1d4536.js +0 -1
  238. package/assets/esri/core/workers/chunks/cad7a2092ea7f51dbd8b.js +0 -1
  239. package/assets/esri/core/workers/chunks/d0e2b42dca51711f2c6f.js +0 -1
  240. package/assets/esri/core/workers/chunks/d2a127f7bb0e2ba14a13.js +0 -1
  241. package/assets/esri/core/workers/chunks/df96824a6f76bad1370c.js +0 -1
  242. package/assets/esri/core/workers/chunks/e097f41bbfac00250477.js +0 -1
  243. package/assets/esri/core/workers/chunks/e3243d120a23a9b48392.js +0 -1
  244. package/assets/esri/core/workers/chunks/e55f80b774e090a0aa04.js +0 -1
  245. package/assets/esri/core/workers/chunks/e668c7e2e61aae6ca6e0.js +0 -1
  246. package/assets/esri/core/workers/chunks/ef900614353505afb210.js +0 -1
  247. package/assets/esri/core/workers/chunks/f0299d93a95f40ea7cf7.js +0 -1
  248. package/assets/esri/core/workers/chunks/f23b95d7e51a144ad065.js +0 -1
  249. package/assets/esri/core/workers/chunks/f263e73a25fae4beffae.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../chunks/tslib.es6.js";import e from"../core/Accessor.js";import{clock as o}from"../core/clock.js";import i from"../core/Collection.js";import{makeHandle as r}from"../core/handleUtils.js";import"../core/has.js";import a from"../core/Logger.js";import{removeMaybe as s,destroyMaybe as n}from"../core/maybe.js";import{watch as l}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as u}from"../core/support/WatchUpdatingTracking.js";import{TextureCollection as p}from"./3d/support/TextureCollection.js";import{ViewEventPriorities as m}from"./input/InputManager.js";import{eventTypes as d}from"./input/ViewEvents.js";import{getToolCollectionHandles as v,areToolManipulatorsEditable as _}from"./interactive/interactiveToolUtils.js";import{EditableFlag as g}from"./interactive/interfaces.js";import{ToolViewManagerManipulatorState as T}from"./interactive/ToolViewManagerManipulatorState.js";const f="attached",E="tools",y=1e3;let w=class extends e{constructor(t){super(t),this._updatingHandles=new u,this._clock=o,this._manipulatorState=new T,this.tools=new i,this.cursor=null,this._interacting=!1,this._interactingTimeout=null,this._forEachTool=t=>{for(const e of this.tools.items)if(t(e))return}}initialize(){this.addHandles([this.view.on(d,(t=>{this._handleInputEvent(t)}),m.TOOL),...v(this.tools),this.tools.on("before-add",(({item:t})=>{this._updateToolEditableFlag(t)})),this.tools.on("before-remove",(({item:t})=>{this._manipulatorState.clearPointers(t,this._manipulatorStateEventArgs),this._updateCursor()})),this.tools.on("change",(()=>{this._refreshToolWatchers()}))])}destroy(){this.detach(),this.removeAllHandles(),this._updatingHandles.destroy()}get _manipulatorStateEventArgs(){return{forEachTool:this._forEachTool,activeTool:this.activeTool,setActiveTool:t=>{this.activeTool=t},view:this.view}}set activeTool(t){if(null!=t&&!this.view.ready)return void a.getLogger(this).error("Cannot set active tool while view is not ready.");if(t===this.activeTool)return;const e=this.activeTool;this._set("activeTool",t),null!=e&&e.deactivate(),null!=t&&t.activate(),this._removeIncompleteTools(t);for(const o of this.tools){this._updateToolEditableFlag(o);const t=_(o);null!=this.activeTool&&t||this._manipulatorState.clearPointers(o,this._manipulatorStateEventArgs,!t)}this._updateCursor()}get updating(){return this._updatingHandles.updating||this.tools.some((t=>t.updating))||(this.textures?.updating??!1)}get interacting(){return this._interacting}_clearInteractingTimeout(){this._interactingTimeout=s(this._interactingTimeout)}_startInteractingTimeout(){this._clearInteractingTimeout(),this._interactingTimeout=this._clock.setTimeout((()=>this._interacting=!1),y)}attach(){"3d"===this.view.type?(this._set("textures",new p(this.view._stage,this.view.resourceController.scheduler)),this.addHandles([l((()=>{const{state:t}=this.view;return"camera"in t&&t.camera}),(()=>this._forEachManipulator((t=>t.onViewChange())))),this.view.elevationProvider?.on("elevation-change",(t=>this._forEachManipulator((e=>e.onElevationChange(t))))),r((()=>this._set("textures",n(this.textures))))],f)):this.addHandles(l((()=>this.view.extent),(()=>this._forEachManipulator((t=>t.onViewChange())))))}detach(){this.activeTool=null,this.tools.removeAll(),this.removeHandles(f),this._clearInteractingTimeout(),this._interacting=!1}_forEachManipulator(t){this._forEachTool((e=>{e.manipulators&&e.manipulators.forEach((({manipulator:o})=>t(o,e)))}))}_handleInputEvent(t){let e=!1;const o={...t,stopPropagation:()=>{e=!0,t.stopPropagation()}};null!=this.activeTool?this.activeTool.handleInputEvent&&this.activeTool.handleInputEvent(o):this._forEachTool((t=>{!e&&t.visible&&t.handleInputEvent(o)})),!e&&"key-down"===t.type&&"Escape"===t.key&&this.activeTool&&(t.stopPropagation(),this.activeTool=null),this._manipulatorState.handleInputEvent(o,this._manipulatorStateEventArgs),e||null==this.activeTool||this.activeTool.handleInputEventAfter(o),this._manipulatorState.handleHoverEvent(o,this._forEachTool),this._updateCursor(),"pointer-move"===t.type&&(this._manipulatorState.hasFocusedManipulators()||this.activeTool)&&(this._interacting=!0,this._startInteractingTimeout())}_refreshToolWatchers(){this.removeHandles(E),this._forEachTool((t=>{if(t instanceof e){const e=l((()=>[t.cursor,t.visible,t.editable]),(()=>{_(t)||this._manipulatorState.clearPointers(t,this._manipulatorStateEventArgs),this._updateCursor()}));this.addHandles(e,E)}t.manipulators&&this.addHandles([t.manipulators.on("after-remove",(e=>{this._manipulatorState.clearPointers(t,this._manipulatorStateEventArgs,!0,e.item.manipulator)})),t.manipulators.on("change",(()=>{this._manipulatorState.updateHoveredStateFromKnownPointers(this._forEachTool),this._updateCursor()}))],E)})),this._manipulatorState.updateHoveredStateFromKnownPointers(this._forEachTool),this._updateCursor()}_updateToolEditableFlag(t){t.setEditableFlag?.(g.MANAGER,null==this.activeTool||t===this.activeTool)}_updateCursor(){let t=this._manipulatorState.cursor;null==t&&this._forEachTool((e=>!(null==e.cursor||!e.visible)&&(t=e.cursor,!0))),this._get("cursor")!==t&&this._set("cursor",t)}_removeIncompleteTools(t){this.tools.filter((e=>(null==t||e!==t)&&!e.created&&e.removeIncompleteOnCancel)).forEach((t=>{this.tools.remove(t)}))}get test(){return{setClock:t=>this._clock=t}}};t([h({constructOnly:!0,nonNullable:!0})],w.prototype,"view",void 0),t([h({readOnly:!0,nonNullable:!0})],w.prototype,"textures",void 0),t([h({value:null})],w.prototype,"activeTool",null),t([h({readOnly:!0,type:i})],w.prototype,"tools",void 0),t([h({readOnly:!0})],w.prototype,"cursor",void 0),t([h({readOnly:!0})],w.prototype,"updating",null),t([h()],w.prototype,"_interacting",void 0),t([h({readOnly:!0})],w.prototype,"interacting",null),w=t([c("esri.views.ToolViewManager")],w);export{y as INTERACTING_TIMEOUT,w as ToolViewManager};
5
+ import{_ as t}from"../chunks/tslib.es6.js";import e from"../core/Accessor.js";import{clock as o}from"../core/clock.js";import i from"../core/Collection.js";import{makeHandle as r}from"../core/handleUtils.js";import"../core/has.js";import a from"../core/Logger.js";import{removeMaybe as s,destroyMaybe as n}from"../core/maybe.js";import{watch as l}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../core/support/UpdatingHandles.js";import{TextureCollection as p}from"./3d/support/TextureCollection.js";import{ViewEventPriorities as m}from"./input/InputManager.js";import{eventTypes as d}from"./input/ViewEvents.js";import{getToolCollectionHandles as v,areToolManipulatorsEditable as _}from"./interactive/interactiveToolUtils.js";import{EditableFlag as g}from"./interactive/interfaces.js";import{ToolViewManagerManipulatorState as T}from"./interactive/ToolViewManagerManipulatorState.js";const f="attached",E="tools",y=1e3;let w=class extends e{constructor(t){super(t),this._updatingHandles=new u,this._clock=o,this._manipulatorState=new T,this.tools=new i,this.cursor=null,this._interacting=!1,this._interactingTimeout=null,this._forEachTool=t=>{for(const e of this.tools.items)if(t(e))return}}initialize(){this.addHandles([this.view.on(d,(t=>{this._handleInputEvent(t)}),m.TOOL),...v(this.tools),this.tools.on("before-add",(({item:t})=>{this._updateToolEditableFlag(t)})),this.tools.on("before-remove",(({item:t})=>{this._manipulatorState.clearPointers(t,this._manipulatorStateEventArgs),this._updateCursor()})),this.tools.on("change",(()=>{this._refreshToolWatchers()}))])}destroy(){this.detach(),this.removeAllHandles(),this._updatingHandles.destroy()}get _manipulatorStateEventArgs(){return{forEachTool:this._forEachTool,activeTool:this.activeTool,setActiveTool:t=>{this.activeTool=t},view:this.view}}set activeTool(t){if(null!=t&&!this.view.ready)return void a.getLogger(this).error("Cannot set active tool while view is not ready.");if(t===this.activeTool)return;const e=this.activeTool;this._set("activeTool",t),null!=e&&e.deactivate(),null!=t&&t.activate(),this._removeIncompleteTools(t);for(const o of this.tools){this._updateToolEditableFlag(o);const t=_(o);null!=this.activeTool&&t||this._manipulatorState.clearPointers(o,this._manipulatorStateEventArgs,!t)}this._updateCursor()}get updating(){return this._updatingHandles.updating||this.tools.some((t=>t.updating))||(this.textures?.updating??!1)}get interacting(){return this._interacting}_clearInteractingTimeout(){this._interactingTimeout=s(this._interactingTimeout)}_startInteractingTimeout(){this._clearInteractingTimeout(),this._interactingTimeout=this._clock.setTimeout((()=>this._interacting=!1),y)}attach(){"3d"===this.view.type?(this._set("textures",new p(this.view._stage,this.view.resourceController.scheduler)),this.addHandles([l((()=>{const{state:t}=this.view;return"camera"in t&&t.camera}),(()=>this._forEachManipulator((t=>t.onViewChange())))),this.view.elevationProvider?.on("elevation-change",(t=>this._forEachManipulator((e=>e.onElevationChange(t))))),r((()=>this._set("textures",n(this.textures))))],f)):this.addHandles(l((()=>this.view.extent),(()=>this._forEachManipulator((t=>t.onViewChange())))))}detach(){this.activeTool=null,this.tools.removeAll(),this.removeHandles(f),this._clearInteractingTimeout(),this._interacting=!1}_forEachManipulator(t){this._forEachTool((e=>{e.manipulators&&e.manipulators.forEach((({manipulator:o})=>t(o,e)))}))}_handleInputEvent(t){let e=!1;const o={...t,stopPropagation:()=>{e=!0,t.stopPropagation()}};null!=this.activeTool?this.activeTool.handleInputEvent&&this.activeTool.handleInputEvent(o):this._forEachTool((t=>{!e&&t.visible&&t.handleInputEvent(o)})),!e&&"key-down"===t.type&&"Escape"===t.key&&this.activeTool&&(t.stopPropagation(),this.activeTool=null),this._manipulatorState.handleInputEvent(o,this._manipulatorStateEventArgs),e||null==this.activeTool||this.activeTool.handleInputEventAfter(o),this._manipulatorState.handleHoverEvent(o,this._forEachTool),this._updateCursor(),"pointer-move"===t.type&&(this._manipulatorState.hasFocusedManipulators()||this.activeTool)&&(this._interacting=!0,this._startInteractingTimeout())}_refreshToolWatchers(){this.removeHandles(E),this._forEachTool((t=>{if(t instanceof e){const e=l((()=>[t.cursor,t.visible,t.editable]),(()=>{_(t)||this._manipulatorState.clearPointers(t,this._manipulatorStateEventArgs),this._updateCursor()}));this.addHandles(e,E)}t.manipulators&&this.addHandles([t.manipulators.on("after-remove",(e=>{this._manipulatorState.clearPointers(t,this._manipulatorStateEventArgs,!0,e.item.manipulator)})),t.manipulators.on("change",(()=>{this._manipulatorState.updateHoveredStateFromKnownPointers(this._forEachTool),this._updateCursor()}))],E)})),this._manipulatorState.updateHoveredStateFromKnownPointers(this._forEachTool),this._updateCursor()}_updateToolEditableFlag(t){t.setEditableFlag?.(g.MANAGER,null==this.activeTool||t===this.activeTool)}_updateCursor(){let t=this._manipulatorState.cursor;null==t&&this._forEachTool((e=>!(null==e.cursor||!e.visible)&&(t=e.cursor,!0))),this._get("cursor")!==t&&this._set("cursor",t)}_removeIncompleteTools(t){this.tools.filter((e=>(null==t||e!==t)&&!e.created&&e.removeIncompleteOnCancel)).forEach((t=>{this.tools.remove(t)}))}get test(){return{setClock:t=>this._clock=t}}};t([h({constructOnly:!0,nonNullable:!0})],w.prototype,"view",void 0),t([h({readOnly:!0,nonNullable:!0})],w.prototype,"textures",void 0),t([h({value:null})],w.prototype,"activeTool",null),t([h({readOnly:!0,type:i})],w.prototype,"tools",void 0),t([h({readOnly:!0})],w.prototype,"cursor",void 0),t([h({readOnly:!0})],w.prototype,"updating",null),t([h()],w.prototype,"_interacting",void 0),t([h({readOnly:!0})],w.prototype,"interacting",null),w=t([c("esri.views.ToolViewManager")],w);export{y as INTERACTING_TIMEOUT,w as ToolViewManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as r,equalsMaybe as o}from"../../core/maybe.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as a,syncAndInitial as p}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{WatchUpdatingTracking as g}from"../../core/support/WatchUpdatingTracking.js";import{pointEquals as u}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as m}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as y}from"./DrawingMode.js";import{DrawManipulator as _}from"./DrawManipulator.js";import{createCoordinateHelper as x}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as f,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as V,Component as w}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as O}from"../interactive/editGeometry/EditGeometryOperations.js";import T from"../interactive/sketch/SketchLabelOptions.js";import b from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as M}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as P}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as D}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as C}from"../interactive/snapping/snappingUtils.js";let I=class extends(i.EventedMixin(t)){constructor(e){super(e),this._createOperationCompleted=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this.isDraped=!0,this.labelOptions=new T,this.tooltipOptions=new b,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.lastVertex=null,null==e.elevationInfo&&(this.elevationInfo=m(!!e.hasZ))}initialize(){const{geometryType:e,view:t}=this,i=t.spatialReference,n="viewingMode"in t.state?t.state.viewingMode:v.Local,r="segment"===e||"multipoint"===e?"polyline":e;this.coordinateHelper=x(this.hasZ,this.hasM,i),this._editGeometryOperations=new O(new V(r,this.coordinateHelper)),this._snappingOperation=new D({view:t,constrainResult:e=>null==e?e:this._getEffectiveDrawSurface()?.constrainZ(e)}),this.addHandles([a((()=>this.stagedVertex),(e=>{null!=e&&this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(e)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(e,t)=>o(e,t,u)}),a((()=>this.view.viewpoint),((e,t)=>{e&&t&&h(e,t)&&this._onViewpointChange()}))]),this._activeComponent=new w(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const c=this.segmentLabels;null!=c&&(c.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles([a((()=>this.labelOptions.enabled),(e=>{c.visible=e}),p),this.on("cursor-update",(()=>{const e=this.stagedVertex;c.stagedVertex=null!=e?this.coordinateHelper.pointToVector(e):null}))])),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(e=>{const t=e.vertices.map((e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)}))),i=t.map((e=>e.coordinates));switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:i,vertices:t})}const n=this._activeComponent.getLastVertex(),r=null!=n?this.coordinateHelper.vectorToDehydratedPoint(n.pos):null;null!=r&&null!=this.lastVertex&&u(this.lastVertex,r)||(this.lastVertex=r)})));const l=this._manipulator=new _({grabbableForEvent:e=>"click"!==this.drawingMode||"touch"===e.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==e,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(e=>this._onImmediateClick(e))),l.events.on("immediate-double-click",(e=>this._onImmediateDoubleClick(e))),a((()=>({cursor:this.cursor,loading:this.loading})),(({cursor:e,loading:t})=>{l.cursor=t?"progress":e}),p)]),C(this,(()=>{const e=this.view.inputManager.latestPointerType??"mouse",t=this._getSnappingContext(e);null!=this.snappingManager&&this._updatingHandles.addPromise(s(this._snappingOperation.resnap(this.snappingManager,t)))}))}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const e=this._getEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((e=>this.coordinateHelper.vectorToArray(e.pos)))}set drawingMode(e){this._set("drawingMode",e??y)}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return null!=this.stagedVertex?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get stagedVertex(){return this._snappingOperation.stagedPoint}set stagedVertex(e){this._snappingOperation.stagedPoint=n(e)}get updating(){return this._updatingHandles.updating}get vertices(){const e=this.committedVertices;return null!=this.stagedVertex&&e.push(this.coordinateHelper.pointToArray(this.stagedVertex)),e}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),null!=this.stagedVertex){const{stagedVertex:e}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e))}}complete(e){const t=e&&e.aborted||!1;this._snappingOperation.abort(),null!=this.snappingManager&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||t)&&this.emit("complete",{vertices:this.vertices.map(((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e}))),aborted:t,type:"complete"})}onInputEvent(e){switch(e.type){case"pointer-down":this._pointerDownStates.add(e.pointerId);break;case"pointer-up":this._pointerDownStates.delete(e.pointerId)}switch(e.type){case"pointer-move":return this._onPointerMove(e);case"hold":return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(e){const t=this._activeComponent;if("polygon"===this.geometryType&&t.vertices.length>2){if(this._vertexWithinPointerDistance(t.vertices[0].pos,e))return 0;if(this._vertexWithinPointerDistance(t.vertices[t.vertices.length-1].pos,e))return t.vertices.length-1}return null}_createManipulatorDragPipeline(e){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(e);case"freehand":return this._createManipulatorDragPipelineFreehand(e);case"hybrid":return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return f(e,((e,t,i,n)=>{const r="touch"===n&&this._snappingEnabled;if(this.isCompleted||!r)return;const{snappingStep:o,cancelSnapping:s}=P({predicate:()=>r,snappingManager:this.snappingManager,snappingContext:new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((e=>(r&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),e))).next(s),t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(this.stagedVertex=e.mapStart,("segment"===this.geometryType||r&&0===this.numVertices)&&this.commitStagedVertex()),e))).next(S(this.view,this.elevationInfo)).next(...o).next((e=>(r&&(this.stagedVertex=e.mapEnd,"end"===e.action&&this.commitStagedVertex()),e))).next((e=>("end"===e.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),e)))}))}_createManipulatorDragPipelineFreehand(e){return f(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return e}))}))}_createManipulatorDragPipelineHybrid(e){return f(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return e}))}))}get _drawAtFixedElevation(){return("segment"===this.geometryType||"polygon"===this.geometryType)&&this.numCommittedVertices>0}_getEffectiveDrawSurface(){if(null==this.elevationDrawSurface)return this.drawSurface;if(!this.coordinateHelper.hasZ())return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let e=this.defaultZ,t=!1;return null!=this.elevationInfo&&"absolute-height"===this.elevationInfo.mode&&(t=!0),null!=this.snapToSceneEnabled&&(t=this.snapToSceneEnabled),null!=this.elevationInfo&&"on-the-ground"===this.elevationInfo.mode&&(t=!1),this._drawAtFixedElevation&&(e=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),t=!1),t?this.drawSurface:(this.elevationDrawSurface.defaultZ=e,this.elevationDrawSurface)}_mapToScreen(e){return this._getEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===e.pointerType&&this._snappingEnabled&&(this.stagedVertex=e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if("mouse"===e.pointerType&&2===e.button||this._manipulator.dragging)return;const t=this._activeComponent;if(null!=this._closeOnClickVertexIndex(e.screenPoint))return e.stopPropagation(),void this.complete();const i=this._screenToMap(e.screenPoint);if(null!=i)switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),("point"===this.geometryType||"segment"===this.geometryType&&2===t.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===t.vertices.length)&&this.complete()}e.stopPropagation()}_onImmediateDoubleClick(e){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),e.stopPropagation())}_onPointerMove(e){const t=c(e.x,e.y);this._stagedScreenPoint=t,this._stagedPointerType=e.pointerType;const i=this._snappingOperation,n=this._manipulator;n.dragging||this._pointerDownStates.has(e.pointerId)||n.grabbing||!n.interactive?i.abort():(e.stopPropagation(),this._updateStagedVertexOnPointerMove(t,e.pointerType))}_onViewpointChange(){const e=this._manipulator;this._stagedScreenPoint&&!e.dragging&&!e.grabbing&&e.interactive?this._updateStagedVertexOnPointerMove(this._stagedScreenPoint,this._stagedPointerType??"mouse"):this._snappingOperation.abort()}_updateStagedVertexOnPointerMove(e,t){const i=this._snappingOperation,n=this._closeOnClickVertexIndex(e);if(null!=n)return this._closeOnVertex(n),void i.abort();const r=this._screenToMap(e),o=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(null==r)return this.cursor=null,void i.abort();this.cursor="crosshair";const a=this.snappingManager;if(null==a)return this.stagedVertex=r,void i.abort();const p=this._getSnappingContext(t);this._updatingHandles.addPromise(s(i.snap({point:r,scenePoint:o},a,p)))}_closeOnVertex(e){this.stagedVertex=null;const t={componentIndex:0,vertexIndex:e,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[e].pos)};this.emit("cursor-update",{updated:null,vertices:[t],operation:"apply",type:"vertex-update"})}_screenToMap(e){return this._getEffectiveDrawSurface()?.screenToMap(e)}_screenToMapDragEventStep(){let e=null;return t=>{if("start"===t.action&&(e=this._screenToMap(t.screenStart)),null==e)return null;const i=this._screenToMap(t.screenEnd);return null!=i?{...t,mapStart:e,mapEnd:i}:null}}_vertexWithinPointerDistance(e,t){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return null!=n&&E(n,t,i)}_getSnappingContext(e){const t=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,visualizer:this.snappingVisualizer,selfSnappingZ:null!=t?{value:t,elevationInfo:this.elevationInfo}:null})}};function E(e,t,i){const n=e.x-t.x,r=e.y-t.y;return n*n+r*r<=i}e([l()],I.prototype,"_snappingEnabled",null),e([l()],I.prototype,"defaultZ",void 0),e([l()],I.prototype,"isDraped",void 0),e([l({value:y})],I.prototype,"drawingMode",null),e([l({constructOnly:!0})],I.prototype,"elevationDrawSurface",void 0),e([l({constructOnly:!0})],I.prototype,"elevationInfo",void 0),e([l({constructOnly:!0,type:T})],I.prototype,"labelOptions",void 0),e([l({constructOnly:!0,type:b})],I.prototype,"tooltipOptions",void 0),e([l({constructOnly:!0})],I.prototype,"geometryType",void 0),e([l({constructOnly:!0})],I.prototype,"hasM",void 0),e([l({constructOnly:!0})],I.prototype,"hasZ",void 0),e([l()],I.prototype,"cursor",void 0),e([l()],I.prototype,"loading",void 0),e([l({constructOnly:!0})],I.prototype,"manipulators",void 0),e([l({constructOnly:!0})],I.prototype,"drawSurface",void 0),e([l({constructOnly:!0})],I.prototype,"segmentLabels",void 0),e([l({constructOnly:!0})],I.prototype,"snappingManager",void 0),e([l({constructOnly:!0})],I.prototype,"snappingVisualizer",void 0),e([l()],I.prototype,"snapToSceneEnabled",void 0),e([l()],I.prototype,"_snappingOperation",void 0),e([l()],I.prototype,"stagedVertex",null),e([l()],I.prototype,"lastVertex",void 0),e([l()],I.prototype,"updating",null),e([l({constructOnly:!0})],I.prototype,"view",void 0),I=e([d("esri.views.draw.DrawOperation")],I);export{I as DrawOperation};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as r,equalsMaybe as o}from"../../core/maybe.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as a,syncAndInitial as p}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as u}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as m}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as y}from"./DrawingMode.js";import{DrawManipulator as _}from"./DrawManipulator.js";import{createCoordinateHelper as x}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as f,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as V,Component as w}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as O}from"../interactive/editGeometry/EditGeometryOperations.js";import T from"../interactive/sketch/SketchLabelOptions.js";import b from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as M}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as P}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as D}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as C}from"../interactive/snapping/snappingUtils.js";let I=class extends(i.EventedMixin(t)){constructor(e){super(e),this._createOperationCompleted=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this.isDraped=!0,this.labelOptions=new T,this.tooltipOptions=new b,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.lastVertex=null,null==e.elevationInfo&&(this.elevationInfo=m(!!e.hasZ))}initialize(){const{geometryType:e,view:t}=this,i=t.spatialReference,n="viewingMode"in t.state?t.state.viewingMode:v.Local,r="segment"===e||"multipoint"===e?"polyline":e;this.coordinateHelper=x(this.hasZ,this.hasM,i),this._editGeometryOperations=new O(new V(r,this.coordinateHelper)),this._snappingOperation=new D({view:t,constrainResult:e=>null==e?e:this._getEffectiveDrawSurface()?.constrainZ(e)}),this.addHandles([a((()=>this.stagedVertex),(e=>{null!=e&&this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(e)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(e,t)=>o(e,t,u)}),a((()=>this.view.viewpoint),((e,t)=>{e&&t&&h(e,t)&&this._onViewpointChange()}))]),this._activeComponent=new w(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const c=this.segmentLabels;null!=c&&(c.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles([a((()=>this.labelOptions.enabled),(e=>{c.visible=e}),p),this.on("cursor-update",(()=>{const e=this.stagedVertex;c.stagedVertex=null!=e?this.coordinateHelper.pointToVector(e):null}))])),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(e=>{const t=e.vertices.map((e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)}))),i=t.map((e=>e.coordinates));switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:i,vertices:t})}const n=this._activeComponent.getLastVertex(),r=null!=n?this.coordinateHelper.vectorToDehydratedPoint(n.pos):null;null!=r&&null!=this.lastVertex&&u(this.lastVertex,r)||(this.lastVertex=r)})));const l=this._manipulator=new _({grabbableForEvent:e=>"click"!==this.drawingMode||"touch"===e.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==e,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(e=>this._onImmediateClick(e))),l.events.on("immediate-double-click",(e=>this._onImmediateDoubleClick(e))),a((()=>({cursor:this.cursor,loading:this.loading})),(({cursor:e,loading:t})=>{l.cursor=t?"progress":e}),p)]),C(this,(()=>{const e=this.view.inputManager.latestPointerType??"mouse",t=this._getSnappingContext(e);null!=this.snappingManager&&this._updatingHandles.addPromise(s(this._snappingOperation.resnap(this.snappingManager,t)))}))}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const e=this._getEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((e=>this.coordinateHelper.vectorToArray(e.pos)))}set drawingMode(e){this._set("drawingMode",e??y)}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return null!=this.stagedVertex?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get stagedVertex(){return this._snappingOperation.stagedPoint}set stagedVertex(e){this._snappingOperation.stagedPoint=n(e)}get updating(){return this._updatingHandles.updating}get vertices(){const e=this.committedVertices;return null!=this.stagedVertex&&e.push(this.coordinateHelper.pointToArray(this.stagedVertex)),e}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),null!=this.stagedVertex){const{stagedVertex:e}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e))}}complete(e){const t=e&&e.aborted||!1;this._snappingOperation.abort(),null!=this.snappingManager&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||t)&&this.emit("complete",{vertices:this.vertices.map(((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e}))),aborted:t,type:"complete"})}onInputEvent(e){switch(e.type){case"pointer-down":this._pointerDownStates.add(e.pointerId);break;case"pointer-up":this._pointerDownStates.delete(e.pointerId)}switch(e.type){case"pointer-move":return this._onPointerMove(e);case"hold":return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(e){const t=this._activeComponent;if("polygon"===this.geometryType&&t.vertices.length>2){if(this._vertexWithinPointerDistance(t.vertices[0].pos,e))return 0;if(this._vertexWithinPointerDistance(t.vertices[t.vertices.length-1].pos,e))return t.vertices.length-1}return null}_createManipulatorDragPipeline(e){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(e);case"freehand":return this._createManipulatorDragPipelineFreehand(e);case"hybrid":return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return f(e,((e,t,i,n)=>{const r="touch"===n&&this._snappingEnabled;if(this.isCompleted||!r)return;const{snappingStep:o,cancelSnapping:s}=P({predicate:()=>r,snappingManager:this.snappingManager,snappingContext:new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((e=>(r&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),e))).next(s),t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(this.stagedVertex=e.mapStart,("segment"===this.geometryType||r&&0===this.numVertices)&&this.commitStagedVertex()),e))).next(S(this.view,this.elevationInfo)).next(...o).next((e=>(r&&(this.stagedVertex=e.mapEnd,"end"===e.action&&this.commitStagedVertex()),e))).next((e=>("end"===e.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),e)))}))}_createManipulatorDragPipelineFreehand(e){return f(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return e}))}))}_createManipulatorDragPipelineHybrid(e){return f(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return e}))}))}get _drawAtFixedElevation(){return("segment"===this.geometryType||"polygon"===this.geometryType)&&this.numCommittedVertices>0}_getEffectiveDrawSurface(){if(null==this.elevationDrawSurface)return this.drawSurface;if(!this.coordinateHelper.hasZ())return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let e=this.defaultZ,t=!1;return null!=this.elevationInfo&&"absolute-height"===this.elevationInfo.mode&&(t=!0),null!=this.snapToSceneEnabled&&(t=this.snapToSceneEnabled),null!=this.elevationInfo&&"on-the-ground"===this.elevationInfo.mode&&(t=!1),this._drawAtFixedElevation&&(e=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),t=!1),t?this.drawSurface:(this.elevationDrawSurface.defaultZ=e,this.elevationDrawSurface)}_mapToScreen(e){return this._getEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===e.pointerType&&this._snappingEnabled&&(this.stagedVertex=e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if("mouse"===e.pointerType&&2===e.button||this._manipulator.dragging)return;const t=this._activeComponent;if(null!=this._closeOnClickVertexIndex(e.screenPoint))return e.stopPropagation(),void this.complete();const i=this._screenToMap(e.screenPoint);if(null!=i)switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),("point"===this.geometryType||"segment"===this.geometryType&&2===t.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===t.vertices.length)&&this.complete()}e.stopPropagation()}_onImmediateDoubleClick(e){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),e.stopPropagation())}_onPointerMove(e){const t=c(e.x,e.y);this._stagedScreenPoint=t,this._stagedPointerType=e.pointerType;const i=this._snappingOperation,n=this._manipulator;n.dragging||this._pointerDownStates.has(e.pointerId)||n.grabbing||!n.interactive?i.abort():(e.stopPropagation(),this._updateStagedVertexOnPointerMove(t,e.pointerType))}_onViewpointChange(){const e=this._manipulator;this._stagedScreenPoint&&!e.dragging&&!e.grabbing&&e.interactive?this._updateStagedVertexOnPointerMove(this._stagedScreenPoint,this._stagedPointerType??"mouse"):this._snappingOperation.abort()}_updateStagedVertexOnPointerMove(e,t){const i=this._snappingOperation,n=this._closeOnClickVertexIndex(e);if(null!=n)return this._closeOnVertex(n),void i.abort();const r=this._screenToMap(e),o=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(null==r)return this.cursor=null,void i.abort();this.cursor="crosshair";const a=this.snappingManager;if(null==a)return this.stagedVertex=r,void i.abort();const p=this._getSnappingContext(t);this._updatingHandles.addPromise(s(i.snap({point:r,scenePoint:o},a,p)))}_closeOnVertex(e){this.stagedVertex=null;const t={componentIndex:0,vertexIndex:e,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[e].pos)};this.emit("cursor-update",{updated:null,vertices:[t],operation:"apply",type:"vertex-update"})}_screenToMap(e){return this._getEffectiveDrawSurface()?.screenToMap(e)}_screenToMapDragEventStep(){let e=null;return t=>{if("start"===t.action&&(e=this._screenToMap(t.screenStart)),null==e)return null;const i=this._screenToMap(t.screenEnd);return null!=i?{...t,mapStart:e,mapEnd:i}:null}}_vertexWithinPointerDistance(e,t){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return null!=n&&E(n,t,i)}_getSnappingContext(e){const t=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,visualizer:this.snappingVisualizer,selfSnappingZ:null!=t?{value:t,elevationInfo:this.elevationInfo}:null})}};function E(e,t,i){const n=e.x-t.x,r=e.y-t.y;return n*n+r*r<=i}e([l()],I.prototype,"_snappingEnabled",null),e([l()],I.prototype,"defaultZ",void 0),e([l()],I.prototype,"isDraped",void 0),e([l({value:y})],I.prototype,"drawingMode",null),e([l({constructOnly:!0})],I.prototype,"elevationDrawSurface",void 0),e([l({constructOnly:!0})],I.prototype,"elevationInfo",void 0),e([l({constructOnly:!0,type:T})],I.prototype,"labelOptions",void 0),e([l({constructOnly:!0,type:b})],I.prototype,"tooltipOptions",void 0),e([l({constructOnly:!0})],I.prototype,"geometryType",void 0),e([l({constructOnly:!0})],I.prototype,"hasM",void 0),e([l({constructOnly:!0})],I.prototype,"hasZ",void 0),e([l()],I.prototype,"cursor",void 0),e([l()],I.prototype,"loading",void 0),e([l({constructOnly:!0})],I.prototype,"manipulators",void 0),e([l({constructOnly:!0})],I.prototype,"drawSurface",void 0),e([l({constructOnly:!0})],I.prototype,"segmentLabels",void 0),e([l({constructOnly:!0})],I.prototype,"snappingManager",void 0),e([l({constructOnly:!0})],I.prototype,"snappingVisualizer",void 0),e([l()],I.prototype,"snapToSceneEnabled",void 0),e([l()],I.prototype,"_snappingOperation",void 0),e([l()],I.prototype,"stagedVertex",null),e([l()],I.prototype,"lastVertex",void 0),e([l()],I.prototype,"updating",null),e([l({constructOnly:!0})],I.prototype,"view",void 0),I=e([d("esri.views.draw.DrawOperation")],I);export{I as DrawOperation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{destroyMaybe as t}from"../../core/maybe.js";import"../../core/Logger.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/Error.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import o from"./DrawAction.js";import{DrawTool as r}from"./DrawTool.js";import{CursorUpdateEvent as s,DrawCompleteEvent as n}from"./input/DrawEvents.js";import{ViewEventPriorities as a}from"../input/InputManager.js";import{SKETCH_KEYS as h}from"../interactive/keybindings.js";import{createScreenPointFromEvent as d}from"../support/screenUtils.js";import p from"../../geometry/Point.js";let l=class extends o{constructor(e){super(e),this._addVertexOnPointerUp=!1}initialize(){"2d"===this.view.type?this._addViewHandles():this._addDrawTool()}destroy(){"2d"===this.view.type?this._removeViewHandles():this._removeDrawTool(),this.emit("destroy")}complete(){"2d"===this.view.type?this._cursorScreenPoint&&this._completeDrawing():this._drawTool.completeCreateOperation()}_addViewHandles(){this._removeViewHandles(),this._handles.add([this.view.on("pointer-down",(e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._activePointerId=e.pointerId,this._addVertexOnPointerUp=!0,this._cursorScreenPoint=d(e),"touch"===e.pointerType&&this._updateCursor(e.native))}),a.TOOL),this.view.on("pointer-move",(e=>{this._abortSnapping(),this._cursorScreenPoint=d(e),"touch"!==e.pointerType&&this._updateCursor(e.native)}),a.TOOL),this.view.on("pointer-drag",(e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._addVertexOnPointerUp=!1)}),a.TOOL),this.view.on("pointer-up",(e=>{if(this._shouldHandlePointerEvent(e))if(this._abortSnapping(),this._activePointerId=null,this._addVertexOnPointerUp)e.stopPropagation(),this._vertexAddHandler(e);else{const t="touch"===e.pointerType;this._updateCursor(e.native,t)}}),a.TOOL),this.view.on("drag",["Shift"],(e=>{e.stopPropagation()}),a.TOOL),this.view.on("key-down",(e=>{e.key===h.complete&&this._cursorScreenPoint&&(this._abortSnapping(),this._vertexAddHandler(e))}),a.TOOL)],this._viewHandlesKey)}_removeViewHandles(){this._handles.remove(this._viewHandlesKey)}_addDrawTool(){this._drawTool=new r({view:this.view,elevationInfo:this.elevationInfo,hasZ:this.hasZ,geometryType:"point",mode:"click"}),this.view.addAndActivateTool(this._drawTool),this._handles.add([this._drawTool.on("cursor-update",(e=>{1===e.vertices.length&&this.emit("cursor-update",new s(this.view,null,e.vertices[0].vertexIndex,this._drawTool.getVertexCoords()))})),this._drawTool.on("complete",(e=>{this.emit("draw-complete",new n(null,this._drawTool.getVertexCoords())),this._removeDrawTool()}))],this._drawToolHandlesKey)}_removeDrawTool(){this._handles.remove(this._drawToolHandlesKey),this.view.tools.remove(this._drawTool),this._drawTool=t(this._drawTool)}_addVertex(e){const t=this._coordinateHelper.arrayToVector(e);this._isDuplicateOfLastVertex(t)||(this._lastVertexUnsnapped=this._stagedVertexUnsnapped,this._popCursorVertex(),this._editGeometryOperations.appendVertex(t),this.notifyChange("vertices"),this._completeDrawing())}_updateCursor(e,t=!1){if(this._popCursorVertex(),!this._cursorScreenPoint)return;const i=this.getCoordsAndPointFromScreenPoint(this._cursorScreenPoint);null==i||t||this._pushCursorVertex(i.vertex,(()=>this.emit("cursor-update",new s(this.view,e,this._activeComponent.vertices.length,this.vertices,null!=this._stagedVertex?new p(this._stagedVertex):null))))}_completeDrawing(e){this._activePointerId=null,this._popCursorVertex(),this._abortSnapping(),null!=this._snappingManager&&this._snappingManager.doneSnapping();const t=new n(e,this.vertices);this.emit("draw-complete",t),t.defaultPrevented||this._removeViewHandles()}};l=e([i("esri.views.draw.PointDrawAction")],l);export{l as PointDrawAction};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import"../../core/Logger.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/Error.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";import i from"./DrawAction.js";import{DrawTool as o}from"./DrawTool.js";import{CursorUpdateEvent as r,DrawCompleteEvent as s}from"./input/DrawEvents.js";import{ViewEventPriorities as n}from"../input/InputManager.js";import{SKETCH_KEYS as a}from"../interactive/keybindings.js";import{createScreenPointFromEvent as h}from"../support/screenUtils.js";import d from"../../geometry/Point.js";let p=class extends i{constructor(e){super(e),this._addVertexOnPointerUp=!1}initialize(){"2d"===this.view.type?this._addViewHandles():this._addDrawTool()}destroy(){"2d"===this.view.type?this._removeViewHandles():this._removeDrawTool(),this.emit("destroy")}complete(){"2d"===this.view.type?this._cursorScreenPoint&&this._completeDrawing():this._drawTool.completeCreateOperation()}_addViewHandles(){this._removeViewHandles(),this._handles.add([this.view.on("pointer-down",(e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._activePointerId=e.pointerId,this._addVertexOnPointerUp=!0,this._cursorScreenPoint=h(e),"touch"===e.pointerType&&this._updateCursor(e.native))}),n.TOOL),this.view.on("pointer-move",(e=>{this._abortSnapping(),this._cursorScreenPoint=h(e),"touch"!==e.pointerType&&this._updateCursor(e.native)}),n.TOOL),this.view.on("pointer-drag",(e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._addVertexOnPointerUp=!1)}),n.TOOL),this.view.on("pointer-up",(e=>{if(this._shouldHandlePointerEvent(e))if(this._abortSnapping(),this._activePointerId=null,this._addVertexOnPointerUp)e.stopPropagation(),this._vertexAddHandler(e);else{const t="touch"===e.pointerType;this._updateCursor(e.native,t)}}),n.TOOL),this.view.on("drag",["Shift"],(e=>{e.stopPropagation()}),n.TOOL),this.view.on("key-down",(e=>{e.key===a.complete&&this._cursorScreenPoint&&(this._abortSnapping(),this._vertexAddHandler(e))}),n.TOOL)],this._viewHandlesKey)}_removeViewHandles(){this._handles.remove(this._viewHandlesKey)}_addDrawTool(){this._drawTool=new o({view:this.view,elevationInfo:this.elevationInfo,hasZ:this.hasZ,geometryType:"point",mode:"click"}),this.view.addAndActivateTool(this._drawTool),this._handles.add([this._drawTool.on("cursor-update",(e=>{1===e.vertices.length&&this.emit("cursor-update",new r(this.view,null,e.vertices[0].vertexIndex,this._drawTool.getVertexCoords()))})),this._drawTool.on("complete",(e=>{this.emit("draw-complete",new s(null,this._drawTool.getVertexCoords())),this._removeDrawTool()}))],this._drawToolHandlesKey)}_removeDrawTool(){this._handles.remove(this._drawToolHandlesKey),this.view.tools.remove(this._drawTool),this._drawTool=null}_addVertex(e){const t=this._coordinateHelper.arrayToVector(e);this._isDuplicateOfLastVertex(t)||(this._lastVertexUnsnapped=this._stagedVertexUnsnapped,this._popCursorVertex(),this._editGeometryOperations.appendVertex(t),this.notifyChange("vertices"),this._completeDrawing())}_updateCursor(e,t=!1){if(this._popCursorVertex(),!this._cursorScreenPoint)return;const i=this.getCoordsAndPointFromScreenPoint(this._cursorScreenPoint);null==i||t||this._pushCursorVertex(i.vertex,(()=>this.emit("cursor-update",new r(this.view,e,this._activeComponent.vertices.length,this.vertices,null!=this._stagedVertex?new d(this._stagedVertex):null))))}_completeDrawing(e){this._activePointerId=null,this._popCursorVertex(),this._abortSnapping(),null!=this._snappingManager&&this._snappingManager.doneSnapping();const t=new s(e,this.vertices);this.emit("draw-complete",t),t.defaultPrevented||this._removeViewHandles()}};p=e([t("esri.views.draw.PointDrawAction")],p);export{p as PointDrawAction};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Handles.js";import{someMap as n}from"../../../core/MapUtils.js";import{eachAlwaysValues as s,throwIfAborted as o}from"../../../core/promiseUtils.js";import{sync as a,watch as i,syncAndInitial as u}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{k as p}from"../../../chunks/vec2.js";import{d,c as h}from"../../../chunks/vec3.js";import{c as g}from"../../../chunks/vec3f64.js";import{g as m}from"../../../chunks/common.js";import{WatchUpdatingTracking as S}from"../../../core/support/WatchUpdatingTracking.js";import{absoluteHeightElevationInfo as y}from"../../../support/elevationInfoUtils.js";import{VerticalHalfPlaneConstraint as f}from"./SnappingConstraint.js";import{SnappingDomain as w}from"./SnappingDomain.js";import{anyMapPointToSnappingPoint as _}from"./SnappingPoint.js";import{sortCandidatesInPlace as v,screenDistance as j}from"./snappingUtils.js";import{DrapedEdgeSnappingCandidate as C}from"./candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as F}from"./candidates/EdgeSnappingCandidate.js";import{FeatureSnappingCandidate as x}from"./candidates/FeatureSnappingCandidate.js";import{RightAngleSnappingCandidate as b,OtherVertexType as H}from"./candidates/RightAngleSnappingCandidate.js";import{vectorToScreenPoint as L}from"../support/viewUtils.js";let M=class extends t{get updating(){return n(this.snappingSources,(({snappingSource:e})=>e.updating))||this._updatingHandles.updating}get snappingSources(){const e=this._get("snappingSources")||new Map,t=new Map;if(null!=this.options&&null!=this.options.featureSources)for(const r of this.options.featureSources.items){const n=r.layer.uid,s=e.get(n);if(s){e.delete(n),t.set(n,s);continue}if(!r.layer.loaded){this._updatingHandles.addPromise(r.layer.load());continue}const o=this._createSourceInfo(r);null!=o&&t.set(n,o)}for(const[,r]of e)r.destroy();return t}constructor(e){super(e),this.options=null,this._domain=w.FEATURE,this._updatingHandles=new S,this._sourceModules={featureService:{module:null,loader:null},featureCollection:{module:null,loader:null},graphics:{module:null,loader:null},notes:{module:null,loader:null},scene:{module:null,loader:null}}}initialize(){this._updatingHandles.add((()=>this.snappingSources),(()=>this.notifyChange("updating")),a),null!=this.view&&this.addHandles([this.view.on("layerview-create",(e=>this._updateLayerView(e.layer,e.layerView))),this.view.on("layerview-destroy",(e=>this._updateLayerView(e.layer,null)))])}_updateLayerView(e,t){for(const[,r]of this.snappingSources)r.snappingSource.layerSource.layer===e&&(r.layerView=t)}destroy(){this._set("options",null);for(const[,e]of this.snappingSources)e.destroy();this._updatingHandles.destroy()}async fetchCandidates(e,t,r,n){if(!(t&this._domain&&null!=this.options&&this.options.effectiveFeatureEnabled))return[];const a=[],i=this._computeScreenSizeDistanceParameters(e,r),u={distance:i,mode:this.view?.type??"2d",point:e,coordinateHelper:r.coordinateHelper,...this._types};for(const[,{snappingSource:s,layerView:o}]of this.snappingSources)!s.layerSource.enabled||null!=o&&o.suspended||a.push(s.fetchCandidates(u,n).then((e=>e.filter((e=>!this._candidateIsExcluded(s,e,r.excludeFeature))))));const c=(await s(a)).flat();return this._addRightAngleCandidates(c,e,i,r),o(n),v(e,c),c}_addRightAngleCandidates(e,t,r,n){const s=null!=n.vertexHandle?n.vertexHandle.rightEdge?.rightVertex?.pos:null!=n.editGeometryOperations&&"polygon"===n.editGeometryOperations.data.type?n.editGeometryOperations.data.components[0]?.getFirstVertex()?.pos:null,o=null!=n.vertexHandle?n.vertexHandle.leftEdge?.leftVertex?.pos:null!=n.editGeometryOperations?n.editGeometryOperations.data.components[0]?.getLastVertex()?.pos:null,{view:a}=this,i=_(s,a,n),u=_(o,a,n),c=e.length;for(let l=0;l<c;l++)this._addRightAngleCandidate(e[l],u,t,r,e),this._addRightAngleCandidate(e[l],i,t,r,e)}_addRightAngleCandidate(e,t,r,n,s){if(null==t||!V(e))return;const o=e.constraint.closestTo(t),a=(o[0]-r[0])/n.x,i=(o[1]-r[1])/n.y,{start:u,end:c}=e.constraint;if(a*a+i*i<=1){const r=new b({targetPoint:o,otherVertex:t,otherVertexType:H.NEXT,previousVertex:p(o,u)>p(o,c)?u:c,constraint:new f(t,o),objectId:e.objectId,isDraped:e.isDraped});s.push(r)}}_computeScreenSizeDistanceParameters(e,t){let r=null!=this.options?this.options.distance*("touch"===t.pointer?this.options.touchSensitivityMultiplier:1):0;return null==this.view?{x:r,y:r,z:r,distance:r}:"2d"===this.view.type?(r*=this.view.resolution,{x:r,y:r,z:r,distance:r}):this._computeScreenSizeDistanceParameters3D(e,r,this.view,t)}_computeScreenSizeDistanceParameters3D(e,t,r,n){const{spatialReference:s}=n;r.renderCoordsHelper.toRenderCoords(e,s,E);const o=r.state.camera.computeScreenPixelSizeAt(E),a=o*r.renderCoordsHelper.unitInMeters/r.mapCoordsHelper.unitInMeters,i=t*a,u=L(e,s,y,r),c=u?P(u,e,a,0,0,r,n):0,l=u?P(u,e,0,a,0,r,n):0,p=u?P(u,e,0,0,a,r,n):0;return{x:0===c?0:i/c,y:0===l?0:i/l,z:0===p?0:i/p,distance:o*t}}get _types(){return{returnEdge:!0,returnVertex:!0}}_candidateIsExcluded(e,t,r){if(null==r)return!1;const n=this._getCandidateObjectId(t);if(null==n)return!1;const s=e.layerSource.layer;return"graphics"===s.type?r.uid===n:r.sourceLayer===s&&(!(!r.attributes||!("objectIdField"in s))&&r.attributes[s.objectIdField]===n)}_getCandidateObjectId(e){return e instanceof x?e.objectId:null}_createSourceInfo(e){const t=this._createFeatureSnappingSourceType(e);if(null==t)return null;if("loading"in t)return this._updatingHandles.addPromise(t.loading.then((()=>{this.destroyed||this.notifyChange("snappingSources")}))),null;const r=null!=this.view?this.view.allLayerViews.find((t=>t.layer===e.layer)):null;return new R(t.source,r)}_createFeatureSnappingSourceType(e){switch(e.layer.type){case"feature":case"geojson":case"csv":case"oriented-imagery":case"subtype-group":case"wfs":return this._createFeatureSnappingSourceFeatureLayer(e);case"graphics":return this._createFeatureSnappingSourceGraphicsLayer(e);case"map-notes":return this._createFeatureSnappingSourceMapNotesLayer(e);case"scene":case"building-scene":return this._createFeatureSnappingSourceSceneLayer(e)}return null}_createFeatureSnappingSourceSceneLayer(e){const{view:t}=this;if(null==t||"3d"!==t.type)return null;const r=this._getSourceModule("scene");return null!=r.module?{source:new r.module.SceneLayerSnappingSource({layerSource:e,view:t})}:{loading:r.loader}}_createFeatureSnappingSourceFeatureLayer(e){switch(e.layer.source?.type){case"feature-layer":case"oriented-imagery":{const t=this._getSourceModule("featureService");return null!=t.module?{source:new t.module.FeatureServiceSnappingSource({spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}case"memory":case"csv":case"geojson":case"wfs":{if("mesh"===e.layer.geometryType)return null;const t=this._getSourceModule("featureCollection");return null!=t.module?{source:new t.module.FeatureCollectionSnappingSource({layerSource:e,view:this.view})}:{loading:t.loader}}}return null}_createFeatureSnappingSourceGraphicsLayer(e){const t=this._getSourceModule("graphics");return null!=t.module?{source:new t.module.GraphicsSnappingSource({getGraphicsLayers:()=>[e.layer],spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}_createFeatureSnappingSourceMapNotesLayer(e){const t=this._getSourceModule("notes");return null!=t.module?{source:new t.module.GraphicsSnappingSource({getGraphicsLayers:()=>null!=e.layer.sublayers?e.layer.sublayers.toArray():[],spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}_getSourceModule(e){const t=this._sourceModules[e];if(null==t.loader){const r=this._loadSourceModule(e).then((e=>{t.module=e}));return t.loader=r,{module:t.module,loader:r}}return{module:t.module,loader:t.loader}}_loadSourceModule(e){const t=this._updatingHandles;switch(e){case"featureService":return t.addPromise(import("./featureSources/FeatureServiceSnappingSource.js"));case"featureCollection":return t.addPromise(import("./featureSources/FeatureCollectionSnappingSource.js"));case"graphics":case"notes":return t.addPromise(import("./featureSources/GraphicsSnappingSource.js"));case"scene":return t.addPromise(import("./featureSources/SceneLayerSnappingSource.js"))}}};e([c({constructOnly:!0})],M.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],M.prototype,"view",void 0),e([c()],M.prototype,"options",void 0),e([c({readOnly:!0})],M.prototype,"updating",null),e([c({readOnly:!0})],M.prototype,"snappingSources",null),M=e([l("esri.views.interactive.snapping.FeatureSnappingEngine")],M);class R{constructor(e,t){this.snappingSource=e,this.layerView=t,this.handles=new r;const n=this.snappingSource.layerSource.layer;if("refresh"in n){const t=n;this.handles.add(t.on("refresh",(()=>e.refresh())))}this.handles.add([i((()=>e.updating),(t=>e.layerSource.updating=t),u),i((()=>e.availability),(t=>e.layerSource.availability=t),u)])}destroy(){this.snappingSource.destroy(),this.handles.destroy()}}function V(e){return(e instanceof F||e instanceof C)&&!I(e)}function I({constraint:{start:e,end:t}}){const r=d(e,t),n=p(e,t);return r<m()||n/r<O}function P(e,t,r,n,s,o,{spatialReference:a}){const i=h(G,t);i[0]+=r,i[1]+=n,i[2]+=s;const u=L(i,a,y,o);return u?j(u,e):1/0}const E=g(),G=g(),O=1e-4;export{M as FeatureSnappingEngine};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Handles.js";import{someMap as n}from"../../../core/MapUtils.js";import{eachAlwaysValues as s,throwIfAborted as o}from"../../../core/promiseUtils.js";import{sync as a,watch as i,syncAndInitial as u}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{k as p}from"../../../chunks/vec2.js";import{d,c as h}from"../../../chunks/vec3.js";import{c as g}from"../../../chunks/vec3f64.js";import{g as m}from"../../../chunks/common.js";import{UpdatingHandles as S}from"../../../core/support/UpdatingHandles.js";import{absoluteHeightElevationInfo as y}from"../../../support/elevationInfoUtils.js";import{VerticalHalfPlaneConstraint as f}from"./SnappingConstraint.js";import{SnappingDomain as w}from"./SnappingDomain.js";import{anyMapPointToSnappingPoint as _}from"./SnappingPoint.js";import{sortCandidatesInPlace as v,screenDistance as j}from"./snappingUtils.js";import{DrapedEdgeSnappingCandidate as C}from"./candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as F}from"./candidates/EdgeSnappingCandidate.js";import{FeatureSnappingCandidate as x}from"./candidates/FeatureSnappingCandidate.js";import{RightAngleSnappingCandidate as b,OtherVertexType as H}from"./candidates/RightAngleSnappingCandidate.js";import{vectorToScreenPoint as L}from"../support/viewUtils.js";let M=class extends t{get updating(){return n(this.snappingSources,(({snappingSource:e})=>e.updating))||this._updatingHandles.updating}get snappingSources(){const e=this._get("snappingSources")||new Map,t=new Map;if(null!=this.options&&null!=this.options.featureSources)for(const r of this.options.featureSources.items){const n=r.layer.uid,s=e.get(n);if(s){e.delete(n),t.set(n,s);continue}if(!r.layer.loaded){this._updatingHandles.addPromise(r.layer.load());continue}const o=this._createSourceInfo(r);null!=o&&t.set(n,o)}for(const[,r]of e)r.destroy();return t}constructor(e){super(e),this.options=null,this._domain=w.FEATURE,this._updatingHandles=new S,this._sourceModules={featureService:{module:null,loader:null},featureCollection:{module:null,loader:null},graphics:{module:null,loader:null},notes:{module:null,loader:null},scene:{module:null,loader:null}}}initialize(){this._updatingHandles.add((()=>this.snappingSources),(()=>this.notifyChange("updating")),a),null!=this.view&&this.addHandles([this.view.on("layerview-create",(e=>this._updateLayerView(e.layer,e.layerView))),this.view.on("layerview-destroy",(e=>this._updateLayerView(e.layer,null)))])}_updateLayerView(e,t){for(const[,r]of this.snappingSources)r.snappingSource.layerSource.layer===e&&(r.layerView=t)}destroy(){this._set("options",null);for(const[,e]of this.snappingSources)e.destroy();this._updatingHandles.destroy()}async fetchCandidates(e,t,r,n){if(!(t&this._domain&&null!=this.options&&this.options.effectiveFeatureEnabled))return[];const a=[],i=this._computeScreenSizeDistanceParameters(e,r),u={distance:i,mode:this.view?.type??"2d",point:e,coordinateHelper:r.coordinateHelper,...this._types};for(const[,{snappingSource:s,layerView:o}]of this.snappingSources)!s.layerSource.enabled||null!=o&&o.suspended||a.push(s.fetchCandidates(u,n).then((e=>e.filter((e=>!this._candidateIsExcluded(s,e,r.excludeFeature))))));const c=(await s(a)).flat();return this._addRightAngleCandidates(c,e,i,r),o(n),v(e,c),c}_addRightAngleCandidates(e,t,r,n){const s=null!=n.vertexHandle?n.vertexHandle.rightEdge?.rightVertex?.pos:null!=n.editGeometryOperations&&"polygon"===n.editGeometryOperations.data.type?n.editGeometryOperations.data.components[0]?.getFirstVertex()?.pos:null,o=null!=n.vertexHandle?n.vertexHandle.leftEdge?.leftVertex?.pos:null!=n.editGeometryOperations?n.editGeometryOperations.data.components[0]?.getLastVertex()?.pos:null,{view:a}=this,i=_(s,a,n),u=_(o,a,n),c=e.length;for(let l=0;l<c;l++)this._addRightAngleCandidate(e[l],u,t,r,e),this._addRightAngleCandidate(e[l],i,t,r,e)}_addRightAngleCandidate(e,t,r,n,s){if(null==t||!V(e))return;const o=e.constraint.closestTo(t),a=(o[0]-r[0])/n.x,i=(o[1]-r[1])/n.y,{start:u,end:c}=e.constraint;if(a*a+i*i<=1){const r=new b({targetPoint:o,otherVertex:t,otherVertexType:H.NEXT,previousVertex:p(o,u)>p(o,c)?u:c,constraint:new f(t,o),objectId:e.objectId,isDraped:e.isDraped});s.push(r)}}_computeScreenSizeDistanceParameters(e,t){let r=null!=this.options?this.options.distance*("touch"===t.pointer?this.options.touchSensitivityMultiplier:1):0;return null==this.view?{x:r,y:r,z:r,distance:r}:"2d"===this.view.type?(r*=this.view.resolution,{x:r,y:r,z:r,distance:r}):this._computeScreenSizeDistanceParameters3D(e,r,this.view,t)}_computeScreenSizeDistanceParameters3D(e,t,r,n){const{spatialReference:s}=n;r.renderCoordsHelper.toRenderCoords(e,s,E);const o=r.state.camera.computeScreenPixelSizeAt(E),a=o*r.renderCoordsHelper.unitInMeters/r.mapCoordsHelper.unitInMeters,i=t*a,u=L(e,s,y,r),c=u?P(u,e,a,0,0,r,n):0,l=u?P(u,e,0,a,0,r,n):0,p=u?P(u,e,0,0,a,r,n):0;return{x:0===c?0:i/c,y:0===l?0:i/l,z:0===p?0:i/p,distance:o*t}}get _types(){return{returnEdge:!0,returnVertex:!0}}_candidateIsExcluded(e,t,r){if(null==r)return!1;const n=this._getCandidateObjectId(t);if(null==n)return!1;const s=e.layerSource.layer;return"graphics"===s.type?r.uid===n:r.sourceLayer===s&&(!(!r.attributes||!("objectIdField"in s))&&r.attributes[s.objectIdField]===n)}_getCandidateObjectId(e){return e instanceof x?e.objectId:null}_createSourceInfo(e){const t=this._createFeatureSnappingSourceType(e);if(null==t)return null;if("loading"in t)return this._updatingHandles.addPromise(t.loading.then((()=>{this.destroyed||this.notifyChange("snappingSources")}))),null;const r=null!=this.view?this.view.allLayerViews.find((t=>t.layer===e.layer)):null;return new R(t.source,r)}_createFeatureSnappingSourceType(e){switch(e.layer.type){case"feature":case"geojson":case"csv":case"oriented-imagery":case"subtype-group":case"wfs":return this._createFeatureSnappingSourceFeatureLayer(e);case"graphics":return this._createFeatureSnappingSourceGraphicsLayer(e);case"map-notes":return this._createFeatureSnappingSourceMapNotesLayer(e);case"scene":case"building-scene":return this._createFeatureSnappingSourceSceneLayer(e)}return null}_createFeatureSnappingSourceSceneLayer(e){const{view:t}=this;if(null==t||"3d"!==t.type)return null;const r=this._getSourceModule("scene");return null!=r.module?{source:new r.module.SceneLayerSnappingSource({layerSource:e,view:t})}:{loading:r.loader}}_createFeatureSnappingSourceFeatureLayer(e){switch(e.layer.source?.type){case"feature-layer":case"oriented-imagery":{const t=this._getSourceModule("featureService");return null!=t.module?{source:new t.module.FeatureServiceSnappingSource({spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}case"memory":case"csv":case"geojson":case"wfs":{if("mesh"===e.layer.geometryType)return null;const t=this._getSourceModule("featureCollection");return null!=t.module?{source:new t.module.FeatureCollectionSnappingSource({layerSource:e,view:this.view})}:{loading:t.loader}}}return null}_createFeatureSnappingSourceGraphicsLayer(e){const t=this._getSourceModule("graphics");return null!=t.module?{source:new t.module.GraphicsSnappingSource({getGraphicsLayers:()=>[e.layer],spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}_createFeatureSnappingSourceMapNotesLayer(e){const t=this._getSourceModule("notes");return null!=t.module?{source:new t.module.GraphicsSnappingSource({getGraphicsLayers:()=>null!=e.layer.sublayers?e.layer.sublayers.toArray():[],spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}_getSourceModule(e){const t=this._sourceModules[e];if(null==t.loader){const r=this._loadSourceModule(e).then((e=>{t.module=e}));return t.loader=r,{module:t.module,loader:r}}return{module:t.module,loader:t.loader}}_loadSourceModule(e){const t=this._updatingHandles;switch(e){case"featureService":return t.addPromise(import("./featureSources/FeatureServiceSnappingSource.js"));case"featureCollection":return t.addPromise(import("./featureSources/FeatureCollectionSnappingSource.js"));case"graphics":case"notes":return t.addPromise(import("./featureSources/GraphicsSnappingSource.js"));case"scene":return t.addPromise(import("./featureSources/SceneLayerSnappingSource.js"))}}};e([c({constructOnly:!0})],M.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],M.prototype,"view",void 0),e([c()],M.prototype,"options",void 0),e([c({readOnly:!0})],M.prototype,"updating",null),e([c({readOnly:!0})],M.prototype,"snappingSources",null),M=e([l("esri.views.interactive.snapping.FeatureSnappingEngine")],M);class R{constructor(e,t){this.snappingSource=e,this.layerView=t,this.handles=new r;const n=this.snappingSource.layerSource.layer;if("refresh"in n){const t=n;this.handles.add(t.on("refresh",(()=>e.refresh())))}this.handles.add([i((()=>e.updating),(t=>e.layerSource.updating=t),u),i((()=>e.availability),(t=>e.layerSource.availability=t),u)])}destroy(){this.snappingSource.destroy(),this.handles.destroy()}}function V(e){return(e instanceof F||e instanceof C)&&!I(e)}function I({constraint:{start:e,end:t}}){const r=d(e,t),n=p(e,t);return r<m()||n/r<O}function P(e,t,r,n,s,o,{spatialReference:a}){const i=h(G,t);i[0]+=r,i[1]+=n,i[2]+=s;const u=L(i,a,y,o);return u?j(u,e):1/0}const E=g(),G=g(),O=1e-4;export{M as FeatureSnappingEngine};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{destroyHandle as r}from"../../../../core/handleUtils.js";import{throwIfAborted as i,ignoreAbortErrors as s}from"../../../../core/promiseUtils.js";import{watch as o,initial as a,on as n,sync as l}from"../../../../core/reactiveUtils.js";import{signal as u}from"../../../../core/signal.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{WatchUpdatingTracking as d}from"../../../../core/support/WatchUpdatingTracking.js";import{elevationContextAffectsAlignment as h}from"../../../../support/elevationInfoUtils.js";import{FeatureServiceTiles2D as y}from"../../../2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js";import{FeatureServiceTiles3D as g}from"../../../3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js";import{convertSnappingCandidate as f,makeGetGroundElevation as m}from"./queryEngineUtils.js";import{WorkerTileTreeDebugger as _}from"./WorkerTileTreeDebugger.js";import{FeatureServiceSnappingSourceWorkerHandle as v}from"./featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js";import{FeatureServiceTilesSimple as S}from"./featureServiceSource/FeatureServiceTilesSimple.js";import w from"../../../support/debugFlags.js";let b=class extends t{get _updateTilesParameters(){return{tiles:this._tilesOfInterest.tiles,tileInfo:this._tilesOfInterest.tileInfo,tileSize:this._tilesOfInterest.tileSize}}get updating(){return this._workerHandle?.updating||this._updatingHandles.updating}get configuration(){const{view:e}=this,t=null!=e?e.type:"2d";return{filter:this._layer.createQuery(),customParameters:this._layer.customParameters,viewType:t}}get availability(){return this._workerHandle?.availability??0}get _layer(){return this.layerSource.layer}constructor(e){super(e),this._updatingHandles=new d,this._workerHandle=null,this._debug=null}initialize(){let e;const t=this.view;if(null!=t)switch(t.type){case"2d":this._tilesOfInterest=new y({view:t,layer:this._layer}),e=this._workerHandle=new v;break;case"3d":{const{resourceController:r}=t,l=this._layer,p=t.whenLayerView(l);this._tilesOfInterest=new g({view:t}),e=this._workerHandle=new v({schedule:e=>r.immediate.schedule(e),hasZ:this._layer.hasZ&&(this._layer.returnZ??!0),elevationAlignPointsInFeatures:async(e,t)=>{const r=await p;return i(t),r.elevationAlignPointsInFeatures(e,t)},queryForSymbologySnapping:async(e,t)=>{const r=await p;return i(t),r.queryForSymbologySnapping(e,t)}});const c=u(null);p.then((e=>c.value=e)),this.addHandles([t.elevationProvider.on("elevation-change",(({context:t})=>{const{elevationInfo:r}=l;h(t,r)&&s(e.notifyElevationSourceChange())})),o((()=>l.elevationInfo),(()=>s(e.notifyElevationSourceChange())),a),o((()=>c.value?.processor?.renderer),(()=>s(e.notifySymbologyChange())),a),o((()=>c.value?.symbologySnappingSupported??!1),(t=>s(e.setSymbologySnappingSupported(t))),a),n((()=>c.value?.layer),["edits","apply-edits","graphic-update"],(()=>e.notifySymbologyChange()))]);break}}else this._tilesOfInterest=new S({layer:this._layer}),e=this._workerHandle=new v;this.addHandles([r(e)]),s(e.setup({layer:this._layer,spatialReference:this.spatialReference,configuration:this.configuration},null)),this._updatingHandles.add((()=>this._updateTilesParameters),(()=>s(e.updateTiles(this._updateTilesParameters,null))),a),this.addHandles([o((()=>this.configuration),(t=>s(e.configure(t,null))),l)]),null!=t&&this.addHandles(o((()=>w.FEATURE_SERVICE_SNAPPING_SOURCE_TILE_TREE_SHOW_TILES),(i=>{i&&!this._debug?(this._debug=new _({view:t,handle:e}),this.addHandles(r(this._debug),"debug")):!i&&this._debug&&this.removeHandles("debug")}),a)),this.addHandles(this.layerSource.layer.on("apply-edits",(t=>{s(e.applyEdits(t,null))})))}destroy(){this._updatingHandles.destroy()}refresh(){this._workerHandle?.refresh(null)}async fetchCandidates(e,t){const{coordinateHelper:r,point:i}=e;this._tilesOfInterest.pointOfInterest=r.arrayToPoint(i);const s=this._getGroundElevation;return(await this._workerHandle.fetchCandidates({...e},t)).candidates.map((e=>f(e,s)))}getDebugInfo(e){return this._workerHandle.getDebugInfo(e)}get _getGroundElevation(){return m(this.view)}};e([p({constructOnly:!0})],b.prototype,"spatialReference",void 0),e([p({constructOnly:!0})],b.prototype,"layerSource",void 0),e([p({constructOnly:!0})],b.prototype,"view",void 0),e([p()],b.prototype,"_tilesOfInterest",void 0),e([p({readOnly:!0})],b.prototype,"_updateTilesParameters",null),e([p({readOnly:!0})],b.prototype,"updating",null),e([p({readOnly:!0})],b.prototype,"configuration",null),e([p({readOnly:!0})],b.prototype,"availability",null),e([p()],b.prototype,"_getGroundElevation",null),b=e([c("esri.views.interactive.snapping.featureSources.FeatureServiceSnappingSource")],b);export{b as FeatureServiceSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{destroyHandle as r}from"../../../../core/handleUtils.js";import{throwIfAborted as i,ignoreAbortErrors as s}from"../../../../core/promiseUtils.js";import{watch as o,initial as a,on as n,sync as l}from"../../../../core/reactiveUtils.js";import{signal as u}from"../../../../core/signal.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 d}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as c}from"../../../../core/support/UpdatingHandles.js";import{elevationContextAffectsAlignment as y}from"../../../../support/elevationInfoUtils.js";import{FeatureServiceTiles2D as h}from"../../../2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js";import{FeatureServiceTiles3D as g}from"../../../3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js";import{convertSnappingCandidate as f,makeGetGroundElevation as m}from"./queryEngineUtils.js";import{WorkerTileTreeDebugger as _}from"./WorkerTileTreeDebugger.js";import{FeatureServiceSnappingSourceWorkerHandle as v}from"./featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js";import{FeatureServiceTilesSimple as S}from"./featureServiceSource/FeatureServiceTilesSimple.js";import w from"../../../support/debugFlags.js";let b=class extends t{get _updateTilesParameters(){return{tiles:this._tilesOfInterest.tiles,tileInfo:this._tilesOfInterest.tileInfo,tileSize:this._tilesOfInterest.tileSize}}get updating(){return this._workerHandle?.updating||this._updatingHandles.updating}get configuration(){const{view:e}=this,t=null!=e?e.type:"2d";return{filter:this._layer.createQuery(),customParameters:this._layer.customParameters,viewType:t}}get availability(){return this._workerHandle?.availability??0}get _layer(){return this.layerSource.layer}constructor(e){super(e),this._updatingHandles=new c,this._workerHandle=null,this._debug=null}initialize(){let e;const t=this.view;if(null!=t)switch(t.type){case"2d":this._tilesOfInterest=new h({view:t,layer:this._layer}),e=this._workerHandle=new v;break;case"3d":{const{resourceController:r}=t,l=this._layer,p=t.whenLayerView(l);this._tilesOfInterest=new g({view:t}),e=this._workerHandle=new v({schedule:e=>r.immediate.schedule(e),hasZ:this._layer.hasZ&&(this._layer.returnZ??!0),elevationAlignPointsInFeatures:async(e,t)=>{const r=await p;return i(t),r.elevationAlignPointsInFeatures(e,t)},queryForSymbologySnapping:async(e,t)=>{const r=await p;return i(t),r.queryForSymbologySnapping(e,t)}});const d=u(null);p.then((e=>d.value=e)),this.addHandles([t.elevationProvider.on("elevation-change",(({context:t})=>{const{elevationInfo:r}=l;y(t,r)&&s(e.notifyElevationSourceChange())})),o((()=>l.elevationInfo),(()=>s(e.notifyElevationSourceChange())),a),o((()=>d.value?.processor?.renderer),(()=>s(e.notifySymbologyChange())),a),o((()=>d.value?.symbologySnappingSupported??!1),(t=>s(e.setSymbologySnappingSupported(t))),a),n((()=>d.value?.layer),["edits","apply-edits","graphic-update"],(()=>e.notifySymbologyChange()))]);break}}else this._tilesOfInterest=new S({layer:this._layer}),e=this._workerHandle=new v;this.addHandles([r(e)]),s(e.setup({layer:this._layer,spatialReference:this.spatialReference,configuration:this.configuration},null)),this._updatingHandles.add((()=>this._updateTilesParameters),(()=>s(e.updateTiles(this._updateTilesParameters,null))),a),this.addHandles([o((()=>this.configuration),(t=>s(e.configure(t,null))),l)]),null!=t&&this.addHandles(o((()=>w.FEATURE_SERVICE_SNAPPING_SOURCE_TILE_TREE_SHOW_TILES),(i=>{i&&!this._debug?(this._debug=new _({view:t,handle:e}),this.addHandles(r(this._debug),"debug")):!i&&this._debug&&this.removeHandles("debug")}),a)),this.addHandles(this.layerSource.layer.on("apply-edits",(t=>{s(e.applyEdits(t,null))})))}destroy(){this._updatingHandles.destroy()}refresh(){this._workerHandle?.refresh(null)}async fetchCandidates(e,t){const{coordinateHelper:r,point:i}=e;this._tilesOfInterest.pointOfInterest=r.arrayToPoint(i);const s=this._getGroundElevation;return(await this._workerHandle.fetchCandidates({...e},t)).candidates.map((e=>f(e,s)))}getDebugInfo(e){return this._workerHandle.getDebugInfo(e)}get _getGroundElevation(){return m(this.view)}};e([p({constructOnly:!0})],b.prototype,"spatialReference",void 0),e([p({constructOnly:!0})],b.prototype,"layerSource",void 0),e([p({constructOnly:!0})],b.prototype,"view",void 0),e([p()],b.prototype,"_tilesOfInterest",void 0),e([p({readOnly:!0})],b.prototype,"_updateTilesParameters",null),e([p({readOnly:!0})],b.prototype,"updating",null),e([p({readOnly:!0})],b.prototype,"configuration",null),e([p({readOnly:!0})],b.prototype,"availability",null),e([p()],b.prototype,"_getGroundElevation",null),b=e([d("esri.views.interactive.snapping.featureSources.FeatureServiceSnappingSource")],b);export{b as FeatureServiceSnappingSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as s}from"../../../../core/arrayUtils.js";import{createTask as o}from"../../../../core/asyncUtils.js";import{throwIfAborted as r,eachAlwaysValues as i,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{initial as a,watch as p,on as l}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as u}from"../../../../core/support/WatchUpdatingTracking.js";import h from"../../../../geometry/Polygon.js";import{initializeProjection as y,canProjectWithoutEngine as g,project as m}from"../../../../geometry/projection.js";import{normalizeCentralMeridianForDisplay as f}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as _}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as v}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as S}from"../../../../layers/graphics/OptimizedFeature.js";import w from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as j}from"../../../../layers/graphics/data/QueryEngine.js";import{elevationContextAffectsAlignment as b}from"../../../../support/elevationInfoUtils.js";import{symbolHasExtrudeSymbolLayer as E}from"../../../../symbols/support/utils.js";import{sortCandidatesInPlace as k,makeSnappingQuery as C}from"../snappingUtils.js";import{convertSnappingCandidate as F,makeGetGroundElevation as A}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as P}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as R}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as G}from"./symbologySnappingCandidates.js";const I="graphics-collections";let U=class extends t{get updating(){return this._updatingHandles.updating}get _hasZ(){const e=this.view;return null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type;if(!s||"map-notes"===t.type)return P();const o=async(s,o)=>(await n(e.whenLayerView(t),o)).elevationAlignPointsInFeatures(s,o);return P(s,{elevationInfo:t.elevationInfo,alignPointsInFeatures:o,spatialReference:e.spatialReference})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type;return R(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type,o=this._extrudedPolygonSymbolsCount>0;return s&&"map-notes"!==t.type&&o?G(o,(async(s,o)=>{const i=await e.whenLayerView(t);return r(o),i.queryForSymbologySnapping({candidates:s,spatialReference:e.spatialReference},o)})):G()}constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[],this._extrudedPolygonSymbolsCount=0,this._updatingHandles=new u}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources((e=>this._destroySource(e))),this._updatingHandles.destroy()}initialize(){this._updatingHandles.add((()=>this.getGraphicsLayers()),(e=>{this._updatingHandles.removeHandles(I);for(const t of e)this._addMany(t.graphics.toArray()),this.addHandles([t.on("graphic-update",(e=>this._onGraphicUpdate(e))),this._updatingHandles.addOnCollectionChange((()=>t.graphics),(e=>this._onGraphicsChanged(e)))],I)}),a);const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"map-notes"!==t.type&&this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{b(e,t.elevationInfo)&&this._snappingElevationAligner.notifyElevationSourceChange()})),p((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),a),l((()=>t),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))])}async fetchCandidates(e,t){const{point:s}=e,o=await i(this._mapSources((s=>this._fetchCandidatesForSource(s,e,t))));r(t);const n=this._getGroundElevation,a=o.flat().map((e=>F(e,n)));return k(s,a),a}get _getGroundElevation(){return A(this.view)}async _fetchCandidatesForSource(e,t,s){const o=C(t,this.view?.type??"2d"),i=await e.queryEngine.executeQueryForSnapping(o,s);r(s);const n=await this._snappingElevationAligner.alignCandidates(i.candidates,s);r(s);const a=await this._symbologySnappingFetcher.fetch(n,s);r(s);const p=0===a.length?n:[...n,...a];return this._snappingElevationFilter.filter(o,p)}refresh(){}_onGraphicUpdate(e){if(this.getGraphicsLayers().some((t=>t.graphics.includes(e.graphic))))switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],s=new Map;for(const o of e)null!=o.geometry&&(this._needsInitializeProjection(o.geometry.spatialReference)?(t.push(o.geometry.spatialReference),s.set(o.uid,o)):this._add(o));this._createPendingAdd(t,s)}_createPendingAdd(e,t){if(!e.length)return;const r=o((async s=>{await y(e.map((e=>({source:e,dest:this.spatialReference}))),{signal:s}),this._markLoadedSpatialReferences(e);for(const[,e]of t)this._add(e)}));this._updatingHandles.addPromise(r.promise);const i={task:r,graphics:t},n=()=>s(this._pendingAdds,i);r.promise.then(n,n),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e)null!=t.wkid&&this._loadedWkids.add(t.wkid),null!=t.wkt&&this._loadedWkts.add(t.wkt)}_add(e){if(null==e.geometry||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=h.fromExtent(t));const s=this._ensureSource(t.type);if(null==s)return;const o=this._createOptimizedFeature(e.uid,t);null!=o&&(s.featureStore.add(o),E(e.symbol)&&this._extrudedPolygonSymbolsCount++)}_needsInitializeProjection(e){return(null==e.wkid||!this._loadedWkids.has(e.wkid))&&((null==e.wkt||!this._loadedWkts.has(e.wkt))&&!g(e,this.spatialReference))}_createOptimizedFeature(e,t){const s=m(f(t),this.spatialReference);if(!s)return null;const o=this._ensureGeometryHasZ(s),r=v(o,this._hasZ,!1);return new S(r,{[H]:e},null,e)}_ensureGeometryHasZ(e){if(!this._hasZ)return e;const t=e=>{for(;e.length<3;)e.push(0)},s=e.clone();switch(s.hasZ=!0,s.type){case"point":s.z=s.z??0;break;case"multipoint":s.points.forEach(t);break;case"polyline":s.paths.forEach((e=>e.forEach(t)));break;case"polygon":s.rings.forEach((e=>e.forEach(t)))}return s}_ensureSource(e){const t=this._sources[e];if(null!=t)return t;const s=this._createSource(e);return this._sources[e]=s,s}_createSource(e){const t=_.toJSON(e),s=this._hasZ,o=new w({geometryType:t,hasZ:s,hasM:!1});return{featureStore:o,queryEngine:new j({featureStore:o,fields:[{name:H,type:"esriFieldTypeOID",alias:H}],geometryType:t,hasM:!1,hasZ:s,objectIdField:H,spatialReference:this.spatialReference,scheduler:null!=this.view&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources((t=>this._removeFromSource(t,e)));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const s=t.uid;e.featureStore.has(s)&&(e.featureStore.removeById(t.uid),E(t.symbol)&&this._extrudedPolygonSymbolsCount--)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:s,polyline:o,multipoint:r}=this._sources,i=[];return null!=t&&i.push(e(t)),null!=s&&i.push(e(s)),null!=o&&i.push(e(o)),null!=r&&i.push(e(r)),i}};e([c()],U.prototype,"getGraphicsLayers",void 0),e([c({constructOnly:!0})],U.prototype,"layerSource",void 0),e([c({constructOnly:!0})],U.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],U.prototype,"view",void 0),e([c({readOnly:!0})],U.prototype,"updating",null),e([c({readOnly:!0})],U.prototype,"availability",void 0),e([c()],U.prototype,"_hasZ",null),e([c()],U.prototype,"_snappingElevationAligner",null),e([c()],U.prototype,"_snappingElevationFilter",null),e([c()],U.prototype,"_symbologySnappingFetcher",null),e([c()],U.prototype,"_extrudedPolygonSymbolsCount",void 0),e([c()],U.prototype,"_getGroundElevation",null),U=e([d("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],U);const H="OBJECTID";export{U as GraphicsSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as s}from"../../../../core/arrayUtils.js";import{createTask as o}from"../../../../core/asyncUtils.js";import{throwIfAborted as r,eachAlwaysValues as i,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{initial as a,watch as p,on as l}from"../../../../core/reactiveUtils.js";import{property as d}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../../../../core/support/UpdatingHandles.js";import h from"../../../../geometry/Polygon.js";import{initializeProjection as y,canProjectWithoutEngine as g,project as m}from"../../../../geometry/projection.js";import{normalizeCentralMeridianForDisplay as f}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as _}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as v}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as S}from"../../../../layers/graphics/OptimizedFeature.js";import w from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as j}from"../../../../layers/graphics/data/QueryEngine.js";import{elevationContextAffectsAlignment as b}from"../../../../support/elevationInfoUtils.js";import{symbolHasExtrudeSymbolLayer as E}from"../../../../symbols/support/utils.js";import{sortCandidatesInPlace as k,makeSnappingQuery as C}from"../snappingUtils.js";import{convertSnappingCandidate as F,makeGetGroundElevation as A}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as P}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as R}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as G}from"./symbologySnappingCandidates.js";const H="graphics-collections";let I=class extends t{get updating(){return this._updatingHandles.updating}get _hasZ(){const e=this.view;return null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type;if(!s||"map-notes"===t.type)return P();const o=async(s,o)=>(await n(e.whenLayerView(t),o)).elevationAlignPointsInFeatures(s,o);return P(s,{elevationInfo:t.elevationInfo,alignPointsInFeatures:o,spatialReference:e.spatialReference})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type;return R(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type,o=this._extrudedPolygonSymbolsCount>0;return s&&"map-notes"!==t.type&&o?G(o,(async(s,o)=>{const i=await e.whenLayerView(t);return r(o),i.queryForSymbologySnapping({candidates:s,spatialReference:e.spatialReference},o)})):G()}constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[],this._extrudedPolygonSymbolsCount=0,this._updatingHandles=new u}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources((e=>this._destroySource(e))),this._updatingHandles.destroy()}initialize(){this._updatingHandles.add((()=>this.getGraphicsLayers()),(e=>{this._updatingHandles.removeHandles(H);for(const t of e)this._addMany(t.graphics.toArray()),this.addHandles([t.on("graphic-update",(e=>this._onGraphicUpdate(e))),this._updatingHandles.addOnCollectionChange((()=>t.graphics),(e=>this._onGraphicsChanged(e)))],H)}),a);const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"map-notes"!==t.type&&this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{b(e,t.elevationInfo)&&this._snappingElevationAligner.notifyElevationSourceChange()})),p((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),a),l((()=>t),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))])}async fetchCandidates(e,t){const{point:s}=e,o=await i(this._mapSources((s=>this._fetchCandidatesForSource(s,e,t))));r(t);const n=this._getGroundElevation,a=o.flat().map((e=>F(e,n)));return k(s,a),a}get _getGroundElevation(){return A(this.view)}async _fetchCandidatesForSource(e,t,s){const o=C(t,this.view?.type??"2d"),i=await e.queryEngine.executeQueryForSnapping(o,s);r(s);const n=await this._snappingElevationAligner.alignCandidates(i.candidates,s);r(s);const a=await this._symbologySnappingFetcher.fetch(n,s);r(s);const p=0===a.length?n:[...n,...a];return this._snappingElevationFilter.filter(o,p)}refresh(){}_onGraphicUpdate(e){if(this.getGraphicsLayers().some((t=>t.graphics.includes(e.graphic))))switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],s=new Map;for(const o of e)null!=o.geometry&&(this._needsInitializeProjection(o.geometry.spatialReference)?(t.push(o.geometry.spatialReference),s.set(o.uid,o)):this._add(o));this._createPendingAdd(t,s)}_createPendingAdd(e,t){if(!e.length)return;const r=o((async s=>{await y(e.map((e=>({source:e,dest:this.spatialReference}))),{signal:s}),this._markLoadedSpatialReferences(e);for(const[,e]of t)this._add(e)}));this._updatingHandles.addPromise(r.promise);const i={task:r,graphics:t},n=()=>s(this._pendingAdds,i);r.promise.then(n,n),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e)null!=t.wkid&&this._loadedWkids.add(t.wkid),null!=t.wkt&&this._loadedWkts.add(t.wkt)}_add(e){if(null==e.geometry||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=h.fromExtent(t));const s=this._ensureSource(t.type);if(null==s)return;const o=this._createOptimizedFeature(e.uid,t);null!=o&&(s.featureStore.add(o),E(e.symbol)&&this._extrudedPolygonSymbolsCount++)}_needsInitializeProjection(e){return(null==e.wkid||!this._loadedWkids.has(e.wkid))&&((null==e.wkt||!this._loadedWkts.has(e.wkt))&&!g(e,this.spatialReference))}_createOptimizedFeature(e,t){const s=m(f(t),this.spatialReference);if(!s)return null;const o=this._ensureGeometryHasZ(s),r=v(o,this._hasZ,!1);return new S(r,{[U]:e},null,e)}_ensureGeometryHasZ(e){if(!this._hasZ)return e;const t=e=>{for(;e.length<3;)e.push(0)},s=e.clone();switch(s.hasZ=!0,s.type){case"point":s.z=s.z??0;break;case"multipoint":s.points.forEach(t);break;case"polyline":s.paths.forEach((e=>e.forEach(t)));break;case"polygon":s.rings.forEach((e=>e.forEach(t)))}return s}_ensureSource(e){const t=this._sources[e];if(null!=t)return t;const s=this._createSource(e);return this._sources[e]=s,s}_createSource(e){const t=_.toJSON(e),s=this._hasZ,o=new w({geometryType:t,hasZ:s,hasM:!1});return{featureStore:o,queryEngine:new j({featureStore:o,fields:[{name:U,type:"esriFieldTypeOID",alias:U}],geometryType:t,hasM:!1,hasZ:s,objectIdField:U,spatialReference:this.spatialReference,scheduler:null!=this.view&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources((t=>this._removeFromSource(t,e)));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const s=t.uid;e.featureStore.has(s)&&(e.featureStore.removeById(t.uid),E(t.symbol)&&this._extrudedPolygonSymbolsCount--)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:s,polyline:o,multipoint:r}=this._sources,i=[];return null!=t&&i.push(e(t)),null!=s&&i.push(e(s)),null!=o&&i.push(e(o)),null!=r&&i.push(e(r)),i}};e([d()],I.prototype,"getGraphicsLayers",void 0),e([d({constructOnly:!0})],I.prototype,"layerSource",void 0),e([d({constructOnly:!0})],I.prototype,"spatialReference",void 0),e([d({constructOnly:!0})],I.prototype,"view",void 0),e([d({readOnly:!0})],I.prototype,"updating",null),e([d({readOnly:!0})],I.prototype,"availability",void 0),e([d()],I.prototype,"_hasZ",null),e([d()],I.prototype,"_snappingElevationAligner",null),e([d()],I.prototype,"_snappingElevationFilter",null),e([d()],I.prototype,"_symbologySnappingFetcher",null),e([d()],I.prototype,"_extrudedPolygonSymbolsCount",void 0),e([d()],I.prototype,"_getGroundElevation",null),I=e([c("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],I);const U="OBJECTID";export{I as GraphicsSnappingSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{destroyHandle as t}from"../../../../core/handleUtils.js";import{removeMaybe as o,abortMaybe as s}from"../../../../core/maybe.js";import{isAborted as i}from"../../../../core/promiseUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as d}from"../../../../core/support/WatchUpdatingTracking.js";import{EdgeWorkerHandle as c}from"../../../3d/webgl-engine/lib/edgeRendering/EdgeWorkerHandle.js";import{SceneLayerSnappingSourceWorkerHandle as l}from"./sceneLayerSource/SceneLayerSnappingSourceWorkerHandle.js";let p=class extends r{get updating(){return this._updatingHandles.updating}constructor(e){super(e),this.availability=1,this._updatingHandles=new d,this._abortController=new AbortController}destroy(){this._tracker=o(this._tracker),this._abortController=s(this._abortController),this._updatingHandles.destroy()}initialize(){const{view:e}=this,r=e.resourceController;this._edgeWorker=new c(h(r)),this._workerHandle=new l({renderCoordsHelper:this.view.renderCoordsHelper,schedule:h(r),fetchEdgeLocations:async(e,r)=>{if(null==this._tracker)throw new Error("tracker-not-initialized");return this._tracker.fetchEdgeLocations(e,this._edgeWorker,r)}}),this._updatingHandles.addPromise(this._setupLayerView()),this.addHandles([t(this._workerHandle),t(this._edgeWorker)])}async fetchCandidates(e,r){return this._workerHandle.fetchCandidates(e,r)}refresh(){}async _setupLayerView(){if(this.destroyed)return;const e=this._abortController?.signal,r=await this.getLayerView();null==r||i(e)||(this._tracker=r.trackSnappingSources({add:(r,t)=>{this._updatingHandles.addPromise(this._workerHandle.add({id:r,bounds:t},e))},remove:r=>{this._updatingHandles.addPromise(this._workerHandle.remove({id:r},e))}}))}};function h(e){return r=>e.immediate.schedule(r)}e([a({constructOnly:!0})],p.prototype,"getLayerView",void 0),e([a({constructOnly:!0})],p.prototype,"view",void 0),e([a({readOnly:!0})],p.prototype,"updating",null),e([a({readOnly:!0})],p.prototype,"availability",void 0),p=e([n("esri.views.interactive.snapping.featureSources.I3SSnappingSource")],p);export{p as I3SSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{destroyHandle as t}from"../../../../core/handleUtils.js";import{removeMaybe as o,abortMaybe as s}from"../../../../core/maybe.js";import{isAborted as i}from"../../../../core/promiseUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../core/support/UpdatingHandles.js";import{EdgeWorkerHandle as c}from"../../../3d/webgl-engine/lib/edgeRendering/EdgeWorkerHandle.js";import{SceneLayerSnappingSourceWorkerHandle as l}from"./sceneLayerSource/SceneLayerSnappingSourceWorkerHandle.js";let p=class extends r{get updating(){return this._updatingHandles.updating}constructor(e){super(e),this.availability=1,this._updatingHandles=new d,this._abortController=new AbortController}destroy(){this._tracker=o(this._tracker),this._abortController=s(this._abortController),this._updatingHandles.destroy()}initialize(){const{view:e}=this,r=e.resourceController;this._edgeWorker=new c(h(r)),this._workerHandle=new l({renderCoordsHelper:this.view.renderCoordsHelper,schedule:h(r),fetchEdgeLocations:async(e,r)=>{if(null==this._tracker)throw new Error("tracker-not-initialized");return this._tracker.fetchEdgeLocations(e,this._edgeWorker,r)}}),this._updatingHandles.addPromise(this._setupLayerView()),this.addHandles([t(this._workerHandle),t(this._edgeWorker)])}async fetchCandidates(e,r){return this._workerHandle.fetchCandidates(e,r)}refresh(){}async _setupLayerView(){if(this.destroyed)return;const e=this._abortController?.signal,r=await this.getLayerView();null==r||i(e)||(this._tracker=r.trackSnappingSources({add:(r,t)=>{this._updatingHandles.addPromise(this._workerHandle.add({id:r,bounds:t},e))},remove:r=>{this._updatingHandles.addPromise(this._workerHandle.remove({id:r},e))}}))}};function h(e){return r=>e.immediate.schedule(r)}e([a({constructOnly:!0})],p.prototype,"getLayerView",void 0),e([a({constructOnly:!0})],p.prototype,"view",void 0),e([a({readOnly:!0})],p.prototype,"updating",null),e([a({readOnly:!0})],p.prototype,"availability",void 0),p=e([n("esri.views.interactive.snapping.featureSources.I3SSnappingSource")],p);export{p as I3SSnappingSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as r}from"../../../../../core/promiseUtils.js";import{watch as s,whenOnce as n,sync as a}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as d}from"../../../../../core/support/WatchUpdatingTracking.js";import p from"../../../../../geometry/SpatialReference.js";import u from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as c}from"../../../../../layers/graphics/data/QueryEngine.js";import h from"../../../../../layers/support/TileInfo.js";import g from"../../../../../rest/support/Query.js";import f from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as m}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as y}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as _}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as S}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as v}from"./FeatureServiceTileStore.js";let F=class extends t.EventedAccessor{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=i(),this._elevationAligner=m(),this._elevationFilter=y(),this._symbologyCandidatesFetcher=_(),this._updatingHandles=new d,this._editsUpdatingHandles=new d,this._pendingApplyEdits=new Map,this._alignPointsInFeatures=async(e,t)=>{const i={points:e},s=await this.remoteClient.invoke("alignElevation",i,{signal:t});return r(t),s},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},s=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return r(t),s}}get updating(){return this.updatingExcludingEdits||this._editsUpdatingHandles.updating||this._featureFetcher.updating}get updatingExcludingEdits(){return this._featureFetcher.updatingExcludingEdits||this._isInitializing||this._updatingHandles.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:r,fields:n}=e.serviceInfo,{hasZ:o}=e,l=p.fromJSON(e.spatialReference);this._spatialReference=l,this._featureStore=new u({...e.serviceInfo,hasZ:o,hasM:!1}),this._queryEngine=new c({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fields:n,hasZ:o,hasM:!1,objectIdField:i,timeInfo:r}),this._featureFetcher=new S({store:new v({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:l,sourceSpatialReference:p.fromJSON(e.serviceInfo.spatialReference)});const d="3d"===e.configuration.viewType;return this._elevationAligner=m(d,{elevationInfo:null!=e.elevationInfo?f.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures,spatialReference:l}),this._elevationFilter=y(d),this.addHandles([s((()=>this._featureFetcher.availability),(e=>this.emit("notify-availability",{availability:e})),a),s((()=>this.updating),(()=>this._notifyUpdating()))]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),{result:{}}}async fetchCandidates(e,t){await this._whenSetup.promise,r(t);const i=w(e),s=null!=t?t.signal:null,n=await this._queryEngine.executeQueryForSnapping(i,s);r(s);const a=await this._elevationAligner.alignCandidates(n.candidates,s);r(s);const o=await this._symbologyCandidatesFetcher.fetch(a,s);r(s);const l=0===o.length?a:a.concat(o);return{result:{candidates:this._elevationFilter.filter(i,l)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=null!=e.tileInfo?h.fromJSON(e.tileInfo):null,E}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.refresh(),E}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),await n((()=>!this.updatingExcludingEdits),t),r(t),E}async getDebugInfo(e,t){return r(t),{result:this._featureFetcher.debugInfo}}async beginApplyEdits(e,t){this._updatingHandles.addPromise(this._whenSetup.promise),r(t);const s=i();return this._pendingApplyEdits.set(e.id,s),this._featureFetcher.applyEdits(s.promise),this._editsUpdatingHandles.addPromise(s.promise),E}async endApplyEdits(e,t){const i=this._pendingApplyEdits.get(e.id);return i&&i.resolve(e.edits),r(t),E}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),E}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),E}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=_(e,this._getSymbologyCandidates),E}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=null!=e.filter?g.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([o({readOnly:!0})],F.prototype,"updating",null),e([o({readOnly:!0})],F.prototype,"updatingExcludingEdits",null),e([o()],F.prototype,"_isInitializing",void 0),F=e([l("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],F);const I=F;function w(e){return{point:e.point,mode:e.mode,distance:e.distance,returnEdge:e.returnEdge,returnVertex:e.returnVertex,query:null!=e.filter?e.filter:{where:"1=1"}}}const E={result:{}};export{I as default};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as r}from"../../../../../core/promiseUtils.js";import{watch as s,whenOnce as n,sync as a}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../../core/support/UpdatingHandles.js";import p from"../../../../../geometry/SpatialReference.js";import u from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as c}from"../../../../../layers/graphics/data/QueryEngine.js";import h from"../../../../../layers/support/TileInfo.js";import g from"../../../../../rest/support/Query.js";import f from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as m}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as y}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as _}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as S}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as v}from"./FeatureServiceTileStore.js";let F=class extends t.EventedAccessor{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=i(),this._elevationAligner=m(),this._elevationFilter=y(),this._symbologyCandidatesFetcher=_(),this._updatingHandles=new d,this._editsUpdatingHandles=new d,this._pendingApplyEdits=new Map,this._alignPointsInFeatures=async(e,t)=>{const i={points:e},s=await this.remoteClient.invoke("alignElevation",i,{signal:t});return r(t),s},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},s=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return r(t),s}}get updating(){return this.updatingExcludingEdits||this._editsUpdatingHandles.updating||this._featureFetcher.updating}get updatingExcludingEdits(){return this._featureFetcher.updatingExcludingEdits||this._isInitializing||this._updatingHandles.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:r,fields:n}=e.serviceInfo,{hasZ:o}=e,l=p.fromJSON(e.spatialReference);this._spatialReference=l,this._featureStore=new u({...e.serviceInfo,hasZ:o,hasM:!1}),this._queryEngine=new c({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fields:n,hasZ:o,hasM:!1,objectIdField:i,timeInfo:r}),this._featureFetcher=new S({store:new v({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:l,sourceSpatialReference:p.fromJSON(e.serviceInfo.spatialReference)});const d="3d"===e.configuration.viewType;return this._elevationAligner=m(d,{elevationInfo:null!=e.elevationInfo?f.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures,spatialReference:l}),this._elevationFilter=y(d),this.addHandles([s((()=>this._featureFetcher.availability),(e=>this.emit("notify-availability",{availability:e})),a),s((()=>this.updating),(()=>this._notifyUpdating()))]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),{result:{}}}async fetchCandidates(e,t){await this._whenSetup.promise,r(t);const i=w(e),s=null!=t?t.signal:null,n=await this._queryEngine.executeQueryForSnapping(i,s);r(s);const a=await this._elevationAligner.alignCandidates(n.candidates,s);r(s);const o=await this._symbologyCandidatesFetcher.fetch(a,s);r(s);const l=0===o.length?a:a.concat(o);return{result:{candidates:this._elevationFilter.filter(i,l)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=null!=e.tileInfo?h.fromJSON(e.tileInfo):null,E}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),this._featureFetcher.refresh(),E}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),r(t),await n((()=>!this.updatingExcludingEdits),t),r(t),E}async getDebugInfo(e,t){return r(t),{result:this._featureFetcher.debugInfo}}async beginApplyEdits(e,t){this._updatingHandles.addPromise(this._whenSetup.promise),r(t);const s=i();return this._pendingApplyEdits.set(e.id,s),this._featureFetcher.applyEdits(s.promise),this._editsUpdatingHandles.addPromise(s.promise),E}async endApplyEdits(e,t){const i=this._pendingApplyEdits.get(e.id);return i&&i.resolve(e.edits),r(t),E}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),E}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),E}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=_(e,this._getSymbologyCandidates),E}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=null!=e.filter?g.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([o({readOnly:!0})],F.prototype,"updating",null),e([o({readOnly:!0})],F.prototype,"updatingExcludingEdits",null),e([o()],F.prototype,"_isInitializing",void 0),F=e([l("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],F);const I=F;function w(e){return{point:e.point,mode:e.mode,distance:e.distance,returnEdge:e.returnEdge,returnVertex:e.returnVertex,query:null!=e.filter?e.filter:{where:"1=1"}}}const E={result:{}};export{I 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{isSome as i}from"../../../../../core/arrayUtils.js";import{whenOrAbort as o}from"../../../../../core/promiseUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as n}from"../../../../../core/support/WatchUpdatingTracking.js";import{WorkerHandle as s}from"../../../../../core/workers/WorkerHandle.js";import{featureGeometryTypeKebabDictionary as d}from"../../../../../geometry/support/typeUtils.js";import{makeDehydratedPoint as l}from"../../../../../layers/graphics/dehydratedFeatures.js";let p=class extends t{get updating(){return this._updatingHandles.updating||this._workerHandleUpdating}constructor(e){super(e),this._updatingHandles=new n,this.schedule=null,this.hasZ=!1,this.elevationAlignPointsInFeatures=async e=>{const t=[];for(const{points:i}of e)for(const{z:e}of i)t.push(e);return{elevations:t,drapedObjectIds:new Set,failedObjectIds:new Set}},this.queryForSymbologySnapping=async()=>({candidates:[],sourceCandidateIndices:[]}),this.availability=0,this._workerHandleUpdating=!0,this._editId=0}destroy(){this._workerHandle.destroy(),this._updatingHandles.destroy()}initialize(){this._workerHandle=new c(this.schedule,{alignElevation:async(e,{signal:t})=>({result:await this.elevationAlignPointsInFeatures(e.points,t)}),getSymbologyCandidates:async(e,{signal:t})=>({result:await this.queryForSymbologySnapping(e,t)})}),this.addHandles([this._workerHandle.on("notify-updating",(({updating:e})=>this._workerHandleUpdating=e)),this._workerHandle.on("notify-availability",(({availability:e})=>this._set("availability",e)))])}async setup(e,t){const i=this._serviceInfoFromLayer(e.layer);if(null==i)return;const o={configuration:this._convertConfiguration(e.configuration),serviceInfo:i,spatialReference:e.spatialReference.toJSON(),hasZ:this.hasZ,elevationInfo:e.layer.elevationInfo?.toJSON()};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("setup",o,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}async configure(e,t){const i=this._convertConfiguration(e);await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("configure",i,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}async refresh(e){await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("refresh",{},e)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},e))}async fetchCandidates(e,t){const i=e.point,o={distance:e.distance,mode:e.mode,point:l(i[0],i[1],i[2],e.coordinateHelper.spatialReference.toJSON()),returnEdge:e.returnEdge,returnVertex:e.returnVertex,filter:null!=e.filter?e.filter.toJSON():null};return this._workerHandle.invoke(o,t)}async updateTiles(e,t){const i={tiles:e.tiles,tileInfo:null!=e.tileInfo?e.tileInfo.toJSON():null,tileSize:e.tileSize};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("updateTiles",i,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}async applyEdits(e,t){const a=this._editId++,r={id:a};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("beginApplyEdits",r,t));const n=await this._updatingHandles.addPromise(o(e.result,t)),s={id:a,edits:{addedFeatures:n.addedFeatures?.map((({objectId:e})=>e)).filter(i)??[],deletedFeatures:n.deletedFeatures?.map((({objectId:e,globalId:t})=>({objectId:e,globalId:t})))??[],updatedFeatures:n.updatedFeatures?.map((({objectId:e})=>e)).filter(i)??[]}};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("endApplyEdits",s,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}getDebugInfo(e){return this._workerHandle.invokeMethod("getDebugInfo",{},e)}async notifyElevationSourceChange(){await this._workerHandle.invokeMethod("notifyElevationSourceChange",{})}async notifySymbologyChange(){await this._workerHandle.invokeMethod("notifySymbologyChange",{})}async setSymbologySnappingSupported(e){await this._workerHandle.invokeMethod("setSymbologySnappingSupported",e)}_convertConfiguration(e){return{filter:null!=e.filter?e.filter.toJSON():null,customParameters:e.customParameters,viewType:e.viewType}}_serviceInfoFromLayer(e){return"multipatch"===e.geometryType||"mesh"===e.geometryType?null:{url:e.parsedUrl?.path??"",fields:e.fields.map((e=>e.toJSON())),geometryType:d.toJSON(e.geometryType),capabilities:e.capabilities,objectIdField:e.objectIdField,globalIdField:e.globalIdField,spatialReference:e.spatialReference.toJSON(),timeInfo:e.timeInfo?.toJSON()}}};e([a({constructOnly:!0})],p.prototype,"schedule",void 0),e([a({constructOnly:!0})],p.prototype,"hasZ",void 0),e([a({constructOnly:!0})],p.prototype,"elevationAlignPointsInFeatures",void 0),e([a({constructOnly:!0})],p.prototype,"queryForSymbologySnapping",void 0),e([a({readOnly:!0})],p.prototype,"updating",null),e([a({readOnly:!0})],p.prototype,"availability",void 0),e([a()],p.prototype,"_workerHandleUpdating",void 0),p=e([r("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorkerHandle")],p);class c extends s{constructor(e,t){super("FeatureServiceSnappingSourceWorker","fetchCandidates",{},e,{strategy:"dedicated",client:t})}}export{p as FeatureServiceSnappingSourceWorkerHandle};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{isSome as i}from"../../../../../core/arrayUtils.js";import{whenOrAbort as o}from"../../../../../core/promiseUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as n}from"../../../../../core/support/UpdatingHandles.js";import{WorkerHandle as s}from"../../../../../core/workers/WorkerHandle.js";import{featureGeometryTypeKebabDictionary as d}from"../../../../../geometry/support/typeUtils.js";import{makeDehydratedPoint as l}from"../../../../../layers/graphics/dehydratedFeatures.js";let p=class extends t{get updating(){return this._updatingHandles.updating||this._workerHandleUpdating}constructor(e){super(e),this._updatingHandles=new n,this.schedule=null,this.hasZ=!1,this.elevationAlignPointsInFeatures=async e=>{const t=[];for(const{points:i}of e)for(const{z:e}of i)t.push(e);return{elevations:t,drapedObjectIds:new Set,failedObjectIds:new Set}},this.queryForSymbologySnapping=async()=>({candidates:[],sourceCandidateIndices:[]}),this.availability=0,this._workerHandleUpdating=!0,this._editId=0}destroy(){this._workerHandle.destroy(),this._updatingHandles.destroy()}initialize(){this._workerHandle=new c(this.schedule,{alignElevation:async(e,{signal:t})=>({result:await this.elevationAlignPointsInFeatures(e.points,t)}),getSymbologyCandidates:async(e,{signal:t})=>({result:await this.queryForSymbologySnapping(e,t)})}),this.addHandles([this._workerHandle.on("notify-updating",(({updating:e})=>this._workerHandleUpdating=e)),this._workerHandle.on("notify-availability",(({availability:e})=>this._set("availability",e)))])}async setup(e,t){const i=this._serviceInfoFromLayer(e.layer);if(null==i)return;const o={configuration:this._convertConfiguration(e.configuration),serviceInfo:i,spatialReference:e.spatialReference.toJSON(),hasZ:this.hasZ,elevationInfo:e.layer.elevationInfo?.toJSON()};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("setup",o,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}async configure(e,t){const i=this._convertConfiguration(e);await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("configure",i,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}async refresh(e){await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("refresh",{},e)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},e))}async fetchCandidates(e,t){const i=e.point,o={distance:e.distance,mode:e.mode,point:l(i[0],i[1],i[2],e.coordinateHelper.spatialReference.toJSON()),returnEdge:e.returnEdge,returnVertex:e.returnVertex,filter:null!=e.filter?e.filter.toJSON():null};return this._workerHandle.invoke(o,t)}async updateTiles(e,t){const i={tiles:e.tiles,tileInfo:null!=e.tileInfo?e.tileInfo.toJSON():null,tileSize:e.tileSize};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("updateTiles",i,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}async applyEdits(e,t){const a=this._editId++,r={id:a};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("beginApplyEdits",r,t));const n=await this._updatingHandles.addPromise(o(e.result,t)),s={id:a,edits:{addedFeatures:n.addedFeatures?.map((({objectId:e})=>e)).filter(i)??[],deletedFeatures:n.deletedFeatures?.map((({objectId:e,globalId:t})=>({objectId:e,globalId:t})))??[],updatedFeatures:n.updatedFeatures?.map((({objectId:e})=>e)).filter(i)??[]}};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("endApplyEdits",s,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}getDebugInfo(e){return this._workerHandle.invokeMethod("getDebugInfo",{},e)}async notifyElevationSourceChange(){await this._workerHandle.invokeMethod("notifyElevationSourceChange",{})}async notifySymbologyChange(){await this._workerHandle.invokeMethod("notifySymbologyChange",{})}async setSymbologySnappingSupported(e){await this._workerHandle.invokeMethod("setSymbologySnappingSupported",e)}_convertConfiguration(e){return{filter:null!=e.filter?e.filter.toJSON():null,customParameters:e.customParameters,viewType:e.viewType}}_serviceInfoFromLayer(e){return"multipatch"===e.geometryType||"mesh"===e.geometryType?null:{url:e.parsedUrl?.path??"",fields:e.fields.map((e=>e.toJSON())),geometryType:d.toJSON(e.geometryType),capabilities:e.capabilities,objectIdField:e.objectIdField,globalIdField:e.globalIdField,spatialReference:e.spatialReference.toJSON(),timeInfo:e.timeInfo?.toJSON()}}};e([a({constructOnly:!0})],p.prototype,"schedule",void 0),e([a({constructOnly:!0})],p.prototype,"hasZ",void 0),e([a({constructOnly:!0})],p.prototype,"elevationAlignPointsInFeatures",void 0),e([a({constructOnly:!0})],p.prototype,"queryForSymbologySnapping",void 0),e([a({readOnly:!0})],p.prototype,"updating",null),e([a({readOnly:!0})],p.prototype,"availability",void 0),e([a()],p.prototype,"_workerHandleUpdating",void 0),p=e([r("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorkerHandle")],p);class c extends s{constructor(e,t){super("FeatureServiceSnappingSourceWorker","fetchCandidates",{},e,{strategy:"dedicated",client:t})}}export{p as FeatureServiceSnappingSourceWorkerHandle};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as i}from"../../../../../core/arrayUtils.js";import{AsyncSequence as s}from"../../../../../core/AsyncSequence.js";import{createTask as r}from"../../../../../core/asyncUtils.js";import{makeHandle as n}from"../../../../../core/handleUtils.js";import o from"../../../../../core/Logger.js";import{throwIfAbortError as a}from"../../../../../core/promiseUtils.js";import{sync as l}from"../../../../../core/reactiveUtils.js";import{property as u}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as c}from"../../../../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as d}from"../../../../../core/support/WatchUpdatingTracking.js";import h from"../../../../../geometry/Extent.js";import{toExtent as p}from"../../../../../geometry/support/aaBoundingRect.js";import{unquantizeOptimizedFeatureSet as f,convertFromFeatureSet as g}from"../../../../../layers/graphics/featureConversionUtils.js";import{isHostedAgolService as y}from"../../../../../layers/support/arcgisLayerUrl.js";import{OptimizedFeatureSetParserContext as _}from"../../../../../rest/query/operations/pbfOptimizedFeatureSet.js";import{executeQueryForExtent as m,executeQueryPBF as b,executeQuery as F}from"../../../../../rest/query/operations/query.js";import T from"../../../../../rest/support/Query.js";import{StateType as P,PendingFeatureTile as I}from"./PendingFeatureTile.js";let v=class extends t{get _minimumVerticesPerFeature(){switch(this.store?.featureStore.geometryType){case"esriGeometryPoint":case"esriGeometryMultipoint":return 1;case"esriGeometryPolygon":return 4;case"esriGeometryPolyline":return 2}}set filter(e){const t=this._get("filter"),i=this._filterProperties(e);JSON.stringify(t)!==JSON.stringify(i)&&this._set("filter",i)}set customParameters(e){const t=this._get("customParameters");JSON.stringify(t)!==JSON.stringify(e)&&this._set("customParameters",e)}get _configuration(){return{filter:this.filter,customParameters:this.customParameters,tileInfo:this.tileInfo,tileSize:this.tileSize}}set tileInfo(e){const t=this._get("tileInfo");t!==e&&(null!=e&&null!=t&&JSON.stringify(e)===JSON.stringify(t)||(this._set("tileInfo",e),this.store.tileInfo=e))}set tileSize(e){this._get("tileSize")!==e&&this._set("tileSize",e)}get updating(){return this.updatingExcludingEdits||this._pendingEdits.updating}get updatingExcludingEdits(){return this._updatingHandles.updating}get hasZ(){return this.store.featureStore.hasZ}constructor(e){super(e),this.tilesOfInterest=[],this.availability=0,this._pendingTiles=new Map,this._updatingHandles=new d,this._pendingEdits=new s,this._pendingEditsAbortController=new AbortController}initialize(){this._initializeFetchExtent(),this._updatingHandles.add((()=>this._configuration),(()=>this.refresh())),this._updatingHandles.add((()=>this.tilesOfInterest),((e,t)=>{i(e,t,(({id:e},{id:t})=>e===t))||this._process()}),l)}destroy(){this._pendingTiles.forEach((e=>this._deletePendingTile(e))),this._pendingTiles.clear(),this.store.destroy(),this.tilesOfInterest.length=0,this._pendingEditsAbortController.abort(),this._pendingEditsAbortController=null,this._updatingHandles.destroy()}refresh(){this.store.refresh(),this._pendingTiles.forEach((e=>this._deletePendingTile(e))),this._process()}applyEdits(e){this._pendingEdits.push(e,(async e=>{if(0===e.addedFeatures.length&&0===e.updatedFeatures.length&&0===e.deletedFeatures.length)return;for(const[,i]of this._pendingTiles)i.reset();const t={...e,deletedFeatures:e.deletedFeatures.map((({objectId:e,globalId:t})=>e&&-1!==e?e:this._lookupObjectIdByGlobalId(t)))};await this._updatingHandles.addPromise(this.store.processEdits(t,((e,t)=>this._queryFeaturesById(e,t)),this._pendingEditsAbortController.signal)),this._processPendingTiles()}))}_initializeFetchExtent(){if(!this.capabilities.query.supportsExtent||!y(this.url))return;const e=r((async e=>{try{const t=await m(this.url,new T({where:"1=1",outSpatialReference:this.spatialReference,cacheHint:this.capabilities.query.supportsCacheHint??void 0}),{query:this._configuration.customParameters,signal:e});this.store.extent=h.fromJSON(t.data?.extent)}catch(t){a(t),o.getLogger(this).warn("Failed to fetch data extent",t)}}));this._updatingHandles.addPromise(e.promise.then((()=>this._process()))),this.addHandles(n((()=>e.abort())))}get debugInfo(){return{numberOfFeatures:this.store.featureStore.numFeatures,tilesOfInterest:this.tilesOfInterest,pendingTiles:Array.from(this._pendingTiles.values()).map((e=>e.debugInfo)),storedTiles:this.store.debugInfo}}_process(){this._markTilesNotAlive(),this._createPendingTiles(),this._deletePendingTiles(),this._processPendingTiles()}_markTilesNotAlive(){for(const[,e]of this._pendingTiles)e.alive=!1}_createPendingTiles(){const e=this._collectMissingTilesInfo();if(this._setAvailability(null==e?1:e.coveredArea/e.fullArea),null!=e)for(const{data:t,resolution:i}of e.missingTiles){const e=this._pendingTiles.get(t.id);e?(e.resolution=i,e.alive=!0):this._createPendingTile(t,i)}}_collectMissingTilesInfo(){let e=null;for(let t=this.tilesOfInterest.length-1;t>=0;t--){const i=this.tilesOfInterest[t],s=this.store.process(i,((e,t)=>this._verifyTileComplexity(e,t)));null==e?e=s:e.prepend(s)}return e}_deletePendingTiles(){for(const[,e]of this._pendingTiles)e.alive||this._deletePendingTile(e)}_processPendingTiles(){const e={fetchCount:(e,t)=>this._fetchCount(e,t),fetchFeatures:(e,t,i)=>this._fetchFeatures(e,t,i),finish:(e,t)=>this._finishPendingTile(e,t),resume:()=>this._processPendingTiles()};if(this._ensureFetchAllCounts(e))for(const[,t]of this._pendingTiles)this._verifyTileComplexity(this.store.getFeatureCount(t.data),t.resolution)&&this._updatingHandles.addPromise(t.process(e))}_verifyTileComplexity(e,t){return this._verifyVertexComplexity(e)&&this._verifyFeatureDensity(e,t)}_verifyVertexComplexity(e){return e*this._minimumVerticesPerFeature<E}_verifyFeatureDensity(e,t){if(null==this.tileInfo)return!1;const i=this.tileSize*t;return e*(S/(i*i))<x}_ensureFetchAllCounts(e){let t=!0;for(const[,i]of this._pendingTiles)i.state.type<P.FETCHED_COUNT&&this._updatingHandles.addPromise(i.process(e)),i.state.type<=P.FETCH_COUNT&&(t=!1);return t}_finishPendingTile(e,t){this.store.add(e.data,t),this._deletePendingTile(e),this._updateAvailability()}_updateAvailability(){const e=this._collectMissingTilesInfo();this._setAvailability(null==e?1:e.coveredArea/e.fullArea)}_setAvailability(e){this._set("availability",e)}_createPendingTile(e,t){const i=new I(e,t);return this._pendingTiles.set(e.id,i),i}_deletePendingTile(e){e.reset(),this._pendingTiles.delete(e.data.id)}async _fetchCount(e,t){return this.store.fetchCount(e.data,this.url,this._createCountQuery(e),{query:this.customParameters,timeout:C,signal:t})}async _fetchFeatures(e,t,i){let s=0;const r=[];let n=0,o=t;for(;;){const a=this._createFeaturesQuery(e),l=this._setPagingParameters(a,s,o),{features:u,exceededTransferLimit:c}=await this._queryFeatures(a,i);l&&(s+=a.num),n+=u.length;for(const e of u)r.push(e);if(o=t-n,!l||!c||o<=0)return r}}_filterProperties(e){return null==e?{where:"1=1",gdbVersion:void 0,timeExtent:void 0}:{where:e.where||"1=1",timeExtent:e.timeExtent,gdbVersion:e.gdbVersion}}_lookupObjectIdByGlobalId(e){const t=this.globalIdField,i=this.objectIdField;if(null==t)throw new Error("Expected globalIdField to be defined");let s=null;if(this.store.featureStore.forEach((r=>{e===r.attributes[t]&&(s=r.objectId??r.attributes[i])})),null==s)throw new Error(`Expected to find a feature with globalId ${e}`);return s}_queryFeaturesById(e,t){const i=this._createFeaturesQuery();return i.objectIds=e,this._queryFeatures(i,t)}_queryFeatures(e,t){return this.capabilities.query.supportsFormatPBF?this._queryFeaturesPBF(e,t):this._queryFeaturesJSON(e,t)}async _queryFeaturesPBF(e,t){const{sourceSpatialReference:i}=this,{data:s}=await b(this.url,e,new _({sourceSpatialReference:i}),{query:this._configuration.customParameters,timeout:C,signal:t});return f(s)}async _queryFeaturesJSON(e,t){const{sourceSpatialReference:i}=this,{data:s}=await F(this.url,e,i,{query:this._configuration.customParameters,timeout:C,signal:t});return g(s,this.objectIdField)}_createCountQuery(e){const t=this._createBaseQuery(e);return this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0),t}_createFeaturesQuery(e=null){const t=this._createBaseQuery(e);return t.outFields=this.globalIdField?[this.globalIdField,this.objectIdField]:[this.objectIdField],t.returnGeometry=!0,null!=e&&(this.capabilities.query.supportsResultType?t.resultType="tile":this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0)),t}_createBaseQuery(e){const t=new T({returnZ:this.hasZ,returnM:!1,geometry:null!=this.tileInfo&&null!=e?p(e.data.extent,this.tileInfo.spatialReference):void 0}),i=this._configuration.filter;return null!=i&&(t.where=i.where,t.gdbVersion=i.gdbVersion,t.timeExtent=i.timeExtent),t.outSpatialReference=this.spatialReference,t}_setPagingParameters(e,t,i){if(!this.capabilities.query.supportsPagination)return!1;const{supportsMaxRecordCountFactor:s,supportsCacheHint:r,tileMaxRecordCount:n,maxRecordCount:o,supportsResultType:a}=this.capabilities.query,l=s?T.MAX_MAX_RECORD_COUNT_FACTOR:1,u=l*((a||r)&&n?n:o||O);return e.start=t,s?(e.maxRecordCountFactor=Math.min(l,Math.ceil(i/u)),e.num=Math.min(i,e.maxRecordCountFactor*u)):e.num=Math.min(i,u),!0}};e([u({constructOnly:!0})],v.prototype,"url",void 0),e([u({constructOnly:!0})],v.prototype,"objectIdField",void 0),e([u({constructOnly:!0})],v.prototype,"globalIdField",void 0),e([u({constructOnly:!0})],v.prototype,"capabilities",void 0),e([u({constructOnly:!0})],v.prototype,"sourceSpatialReference",void 0),e([u({constructOnly:!0})],v.prototype,"spatialReference",void 0),e([u({constructOnly:!0})],v.prototype,"store",void 0),e([u({readOnly:!0})],v.prototype,"_minimumVerticesPerFeature",null),e([u()],v.prototype,"filter",null),e([u()],v.prototype,"customParameters",null),e([u({readOnly:!0})],v.prototype,"_configuration",null),e([u()],v.prototype,"tileInfo",null),e([u()],v.prototype,"tileSize",null),e([u()],v.prototype,"tilesOfInterest",void 0),e([u({readOnly:!0})],v.prototype,"updating",null),e([u({readOnly:!0})],v.prototype,"updatingExcludingEdits",null),e([u({readOnly:!0})],v.prototype,"availability",void 0),e([u()],v.prototype,"hasZ",null),v=e([c("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTiledFetcher")],v);const O=2e3,C=6e5,E=1e6,S=25,x=1;export{v as FeatureServiceTiledFetcher};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as i}from"../../../../../core/arrayUtils.js";import{AsyncSequence as s}from"../../../../../core/AsyncSequence.js";import{createTask as r}from"../../../../../core/asyncUtils.js";import{makeHandle as n}from"../../../../../core/handleUtils.js";import o from"../../../../../core/Logger.js";import{throwIfAbortError as a}from"../../../../../core/promiseUtils.js";import{sync as l}from"../../../../../core/reactiveUtils.js";import{property as u}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as c}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../../core/support/UpdatingHandles.js";import h from"../../../../../geometry/Extent.js";import{toExtent as p}from"../../../../../geometry/support/aaBoundingRect.js";import{unquantizeOptimizedFeatureSet as f,convertFromFeatureSet as g}from"../../../../../layers/graphics/featureConversionUtils.js";import{isHostedAgolService as y}from"../../../../../layers/support/arcgisLayerUrl.js";import{OptimizedFeatureSetParserContext as _}from"../../../../../rest/query/operations/pbfOptimizedFeatureSet.js";import{executeQueryForExtent as m,executeQueryPBF as b,executeQuery as F}from"../../../../../rest/query/operations/query.js";import T from"../../../../../rest/support/Query.js";import{StateType as P,PendingFeatureTile as I}from"./PendingFeatureTile.js";let v=class extends t{get _minimumVerticesPerFeature(){switch(this.store?.featureStore.geometryType){case"esriGeometryPoint":case"esriGeometryMultipoint":return 1;case"esriGeometryPolygon":return 4;case"esriGeometryPolyline":return 2}}set filter(e){const t=this._get("filter"),i=this._filterProperties(e);JSON.stringify(t)!==JSON.stringify(i)&&this._set("filter",i)}set customParameters(e){const t=this._get("customParameters");JSON.stringify(t)!==JSON.stringify(e)&&this._set("customParameters",e)}get _configuration(){return{filter:this.filter,customParameters:this.customParameters,tileInfo:this.tileInfo,tileSize:this.tileSize}}set tileInfo(e){const t=this._get("tileInfo");t!==e&&(null!=e&&null!=t&&JSON.stringify(e)===JSON.stringify(t)||(this._set("tileInfo",e),this.store.tileInfo=e))}set tileSize(e){this._get("tileSize")!==e&&this._set("tileSize",e)}get updating(){return this.updatingExcludingEdits||this._pendingEdits.updating}get updatingExcludingEdits(){return this._updatingHandles.updating}get hasZ(){return this.store.featureStore.hasZ}constructor(e){super(e),this.tilesOfInterest=[],this.availability=0,this._pendingTiles=new Map,this._updatingHandles=new d,this._pendingEdits=new s,this._pendingEditsAbortController=new AbortController}initialize(){this._initializeFetchExtent(),this._updatingHandles.add((()=>this._configuration),(()=>this.refresh())),this._updatingHandles.add((()=>this.tilesOfInterest),((e,t)=>{i(e,t,(({id:e},{id:t})=>e===t))||this._process()}),l)}destroy(){this._pendingTiles.forEach((e=>this._deletePendingTile(e))),this._pendingTiles.clear(),this.store.destroy(),this.tilesOfInterest.length=0,this._pendingEditsAbortController.abort(),this._pendingEditsAbortController=null,this._updatingHandles.destroy()}refresh(){this.store.refresh(),this._pendingTiles.forEach((e=>this._deletePendingTile(e))),this._process()}applyEdits(e){this._pendingEdits.push(e,(async e=>{if(0===e.addedFeatures.length&&0===e.updatedFeatures.length&&0===e.deletedFeatures.length)return;for(const[,i]of this._pendingTiles)i.reset();const t={...e,deletedFeatures:e.deletedFeatures.map((({objectId:e,globalId:t})=>e&&-1!==e?e:this._lookupObjectIdByGlobalId(t)))};await this._updatingHandles.addPromise(this.store.processEdits(t,((e,t)=>this._queryFeaturesById(e,t)),this._pendingEditsAbortController.signal)),this._processPendingTiles()}))}_initializeFetchExtent(){if(!this.capabilities.query.supportsExtent||!y(this.url))return;const e=r((async e=>{try{const t=await m(this.url,new T({where:"1=1",outSpatialReference:this.spatialReference,cacheHint:this.capabilities.query.supportsCacheHint??void 0}),{query:this._configuration.customParameters,signal:e});this.store.extent=h.fromJSON(t.data?.extent)}catch(t){a(t),o.getLogger(this).warn("Failed to fetch data extent",t)}}));this._updatingHandles.addPromise(e.promise.then((()=>this._process()))),this.addHandles(n((()=>e.abort())))}get debugInfo(){return{numberOfFeatures:this.store.featureStore.numFeatures,tilesOfInterest:this.tilesOfInterest,pendingTiles:Array.from(this._pendingTiles.values()).map((e=>e.debugInfo)),storedTiles:this.store.debugInfo}}_process(){this._markTilesNotAlive(),this._createPendingTiles(),this._deletePendingTiles(),this._processPendingTiles()}_markTilesNotAlive(){for(const[,e]of this._pendingTiles)e.alive=!1}_createPendingTiles(){const e=this._collectMissingTilesInfo();if(this._setAvailability(null==e?1:e.coveredArea/e.fullArea),null!=e)for(const{data:t,resolution:i}of e.missingTiles){const e=this._pendingTiles.get(t.id);e?(e.resolution=i,e.alive=!0):this._createPendingTile(t,i)}}_collectMissingTilesInfo(){let e=null;for(let t=this.tilesOfInterest.length-1;t>=0;t--){const i=this.tilesOfInterest[t],s=this.store.process(i,((e,t)=>this._verifyTileComplexity(e,t)));null==e?e=s:e.prepend(s)}return e}_deletePendingTiles(){for(const[,e]of this._pendingTiles)e.alive||this._deletePendingTile(e)}_processPendingTiles(){const e={fetchCount:(e,t)=>this._fetchCount(e,t),fetchFeatures:(e,t,i)=>this._fetchFeatures(e,t,i),finish:(e,t)=>this._finishPendingTile(e,t),resume:()=>this._processPendingTiles()};if(this._ensureFetchAllCounts(e))for(const[,t]of this._pendingTiles)this._verifyTileComplexity(this.store.getFeatureCount(t.data),t.resolution)&&this._updatingHandles.addPromise(t.process(e))}_verifyTileComplexity(e,t){return this._verifyVertexComplexity(e)&&this._verifyFeatureDensity(e,t)}_verifyVertexComplexity(e){return e*this._minimumVerticesPerFeature<E}_verifyFeatureDensity(e,t){if(null==this.tileInfo)return!1;const i=this.tileSize*t;return e*(S/(i*i))<x}_ensureFetchAllCounts(e){let t=!0;for(const[,i]of this._pendingTiles)i.state.type<P.FETCHED_COUNT&&this._updatingHandles.addPromise(i.process(e)),i.state.type<=P.FETCH_COUNT&&(t=!1);return t}_finishPendingTile(e,t){this.store.add(e.data,t),this._deletePendingTile(e),this._updateAvailability()}_updateAvailability(){const e=this._collectMissingTilesInfo();this._setAvailability(null==e?1:e.coveredArea/e.fullArea)}_setAvailability(e){this._set("availability",e)}_createPendingTile(e,t){const i=new I(e,t);return this._pendingTiles.set(e.id,i),i}_deletePendingTile(e){e.reset(),this._pendingTiles.delete(e.data.id)}async _fetchCount(e,t){return this.store.fetchCount(e.data,this.url,this._createCountQuery(e),{query:this.customParameters,timeout:C,signal:t})}async _fetchFeatures(e,t,i){let s=0;const r=[];let n=0,o=t;for(;;){const a=this._createFeaturesQuery(e),l=this._setPagingParameters(a,s,o),{features:u,exceededTransferLimit:c}=await this._queryFeatures(a,i);l&&(s+=a.num),n+=u.length;for(const e of u)r.push(e);if(o=t-n,!l||!c||o<=0)return r}}_filterProperties(e){return null==e?{where:"1=1",gdbVersion:void 0,timeExtent:void 0}:{where:e.where||"1=1",timeExtent:e.timeExtent,gdbVersion:e.gdbVersion}}_lookupObjectIdByGlobalId(e){const t=this.globalIdField,i=this.objectIdField;if(null==t)throw new Error("Expected globalIdField to be defined");let s=null;if(this.store.featureStore.forEach((r=>{e===r.attributes[t]&&(s=r.objectId??r.attributes[i])})),null==s)throw new Error(`Expected to find a feature with globalId ${e}`);return s}_queryFeaturesById(e,t){const i=this._createFeaturesQuery();return i.objectIds=e,this._queryFeatures(i,t)}_queryFeatures(e,t){return this.capabilities.query.supportsFormatPBF?this._queryFeaturesPBF(e,t):this._queryFeaturesJSON(e,t)}async _queryFeaturesPBF(e,t){const{sourceSpatialReference:i}=this,{data:s}=await b(this.url,e,new _({sourceSpatialReference:i}),{query:this._configuration.customParameters,timeout:C,signal:t});return f(s)}async _queryFeaturesJSON(e,t){const{sourceSpatialReference:i}=this,{data:s}=await F(this.url,e,i,{query:this._configuration.customParameters,timeout:C,signal:t});return g(s,this.objectIdField)}_createCountQuery(e){const t=this._createBaseQuery(e);return this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0),t}_createFeaturesQuery(e=null){const t=this._createBaseQuery(e);return t.outFields=this.globalIdField?[this.globalIdField,this.objectIdField]:[this.objectIdField],t.returnGeometry=!0,null!=e&&(this.capabilities.query.supportsResultType?t.resultType="tile":this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0)),t}_createBaseQuery(e){const t=new T({returnZ:this.hasZ,returnM:!1,geometry:null!=this.tileInfo&&null!=e?p(e.data.extent,this.tileInfo.spatialReference):void 0}),i=this._configuration.filter;return null!=i&&(t.where=i.where,t.gdbVersion=i.gdbVersion,t.timeExtent=i.timeExtent),t.outSpatialReference=this.spatialReference,t}_setPagingParameters(e,t,i){if(!this.capabilities.query.supportsPagination)return!1;const{supportsMaxRecordCountFactor:s,supportsCacheHint:r,tileMaxRecordCount:n,maxRecordCount:o,supportsResultType:a}=this.capabilities.query,l=s?T.MAX_MAX_RECORD_COUNT_FACTOR:1,u=l*((a||r)&&n?n:o||O);return e.start=t,s?(e.maxRecordCountFactor=Math.min(l,Math.ceil(i/u)),e.num=Math.min(i,e.maxRecordCountFactor*u)):e.num=Math.min(i,u),!0}};e([u({constructOnly:!0})],v.prototype,"url",void 0),e([u({constructOnly:!0})],v.prototype,"objectIdField",void 0),e([u({constructOnly:!0})],v.prototype,"globalIdField",void 0),e([u({constructOnly:!0})],v.prototype,"capabilities",void 0),e([u({constructOnly:!0})],v.prototype,"sourceSpatialReference",void 0),e([u({constructOnly:!0})],v.prototype,"spatialReference",void 0),e([u({constructOnly:!0})],v.prototype,"store",void 0),e([u({readOnly:!0})],v.prototype,"_minimumVerticesPerFeature",null),e([u()],v.prototype,"filter",null),e([u()],v.prototype,"customParameters",null),e([u({readOnly:!0})],v.prototype,"_configuration",null),e([u()],v.prototype,"tileInfo",null),e([u()],v.prototype,"tileSize",null),e([u()],v.prototype,"tilesOfInterest",void 0),e([u({readOnly:!0})],v.prototype,"updating",null),e([u({readOnly:!0})],v.prototype,"updatingExcludingEdits",null),e([u({readOnly:!0})],v.prototype,"availability",void 0),e([u()],v.prototype,"hasZ",null),v=e([c("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTiledFetcher")],v);const O=2e3,C=6e5,E=1e6,S=25,x=1;export{v as FeatureServiceTiledFetcher};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import r from"../../core/Evented.js";import{IdentifiableMixin as s}from"../../core/Identifiable.js";import i from"../../core/Logger.js";import{EsriPromiseMixin as o}from"../../core/Promise.js";import{property as n}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{WatchUpdatingTracking as l}from"../../core/support/WatchUpdatingTracking.js";let p=class extends(s(o(r.EventedMixin(t)))){constructor(e){super(e),this._updatingHandles=new l,this.layer=null,this.parent=null}initialize(){this.when().catch((e=>{if("layerview:create-error"!==e.name){const t=this.layer&&this.layer.id||"no id",r=this.layer&&this.layer.title||"no title";i.getLogger(this).error("#resolve()",`Failed to resolve layer view (layer title: '${r}', id: '${t}')`,e)}}))}destroy(){this._updatingHandles.destroy()}get fullOpacity(){return(this.layer?.opacity??1)*(this.parent?.fullOpacity??1)}get suspended(){return!this.canResume()}get suspendInfo(){return this.getSuspendInfo()}get legendEnabled(){return!this.suspended&&!0===this.layer?.legendEnabled}get updating(){return!(!this._updatingHandles?.updating&&!this.isUpdating())}get updatingProgress(){return this.updating?0:1}get visible(){return!0===this.layer?.visible}set visible(e){this._overrideIfSome("visible",e)}canResume(){return this.visible&&this.layer?.loaded&&!this.parent?.suspended&&this.view?.ready||!1}getSuspendInfo(){const e=this.parent&&this.parent.suspended?this.parent.suspendInfo:{},t=this;return t.view&&t.view.ready||(e.viewNotReady=!0),this.layer&&this.layer.loaded||(e.layerNotLoaded=!0),this.visible||(e.layerInvisible=!0),e}isUpdating(){return!1}};e([n()],p.prototype,"fullOpacity",null),e([n()],p.prototype,"layer",void 0),e([n()],p.prototype,"parent",void 0),e([n({readOnly:!0})],p.prototype,"suspended",null),e([n({readOnly:!0})],p.prototype,"suspendInfo",null),e([n({readOnly:!0})],p.prototype,"legendEnabled",null),e([n({type:Boolean,readOnly:!0})],p.prototype,"updating",null),e([n({readOnly:!0})],p.prototype,"updatingProgress",null),e([n()],p.prototype,"visible",null),e([n()],p.prototype,"view",void 0),p=e([a("esri.views.layers.LayerView")],p);const d=p;export{d as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import r from"../../core/Evented.js";import{IdentifiableMixin as s}from"../../core/Identifiable.js";import i from"../../core/Logger.js";import{EsriPromiseMixin as o}from"../../core/Promise.js";import{property as n}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{UpdatingHandles as l}from"../../core/support/UpdatingHandles.js";let p=class extends(s(o(r.EventedMixin(t)))){constructor(e){super(e),this._updatingHandles=new l,this.layer=null,this.parent=null}initialize(){this.when().catch((e=>{if("layerview:create-error"!==e.name){const t=this.layer&&this.layer.id||"no id",r=this.layer&&this.layer.title||"no title";i.getLogger(this).error("#resolve()",`Failed to resolve layer view (layer title: '${r}', id: '${t}')`,e)}}))}destroy(){this._updatingHandles.destroy()}get fullOpacity(){return(this.layer?.opacity??1)*(this.parent?.fullOpacity??1)}get suspended(){return!this.canResume()}get suspendInfo(){return this.getSuspendInfo()}get legendEnabled(){return!this.suspended&&!0===this.layer?.legendEnabled}get updating(){return!(!this._updatingHandles?.updating&&!this.isUpdating())}get updatingProgress(){return this.updating?0:1}get visible(){return!0===this.layer?.visible}set visible(e){this._overrideIfSome("visible",e)}canResume(){return this.visible&&this.layer?.loaded&&!this.parent?.suspended&&this.view?.ready||!1}getSuspendInfo(){const e=this.parent&&this.parent.suspended?this.parent.suspendInfo:{},t=this;return t.view&&t.view.ready||(e.viewNotReady=!0),this.layer&&this.layer.loaded||(e.layerNotLoaded=!0),this.visible||(e.layerInvisible=!0),e}isUpdating(){return!1}};e([n()],p.prototype,"fullOpacity",null),e([n()],p.prototype,"layer",void 0),e([n()],p.prototype,"parent",void 0),e([n({readOnly:!0})],p.prototype,"suspended",null),e([n({readOnly:!0})],p.prototype,"suspendInfo",null),e([n({readOnly:!0})],p.prototype,"legendEnabled",null),e([n({type:Boolean,readOnly:!0})],p.prototype,"updating",null),e([n({readOnly:!0})],p.prototype,"updatingProgress",null),e([n()],p.prototype,"visible",null),e([n()],p.prototype,"view",void 0),p=e([a("esri.views.layers.LayerView")],p);const d=p;export{d as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import r from"../../core/Collection.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as i}from"../../core/support/WatchUpdatingTracking.js";import"../../libs/maquette/projection.js";import{createProjector as n}from"../../libs/maquette/projector.js";let a=class extends e{constructor(){super(...arguments),this.items=new r,this._watchUpdatingTracking=new i,this._callbacks=new Map,this._projector=n(),this._hiddenProjector=n()}get needsRender(){return this.items.length>0}get updating(){return this._watchUpdatingTracking?.updating??!1}initialize(){const t=document.createElement("div");t.className="esri-overlay-surface",this._set("surface",t),this._hiddenSurface=document.createElement("div"),this._hiddenSurface.setAttribute("style","visibility: hidden;"),t.appendChild(this._hiddenSurface),this._watchUpdatingTracking.addOnCollectionChange((()=>this.items),(t=>{for(const e of t.added){const t=()=>e.render();this._callbacks.set(e,t),this._projector.append(this.surface,t)}for(const e of t.removed){const t=this._projector.detach(this._callbacks.get(e));this.surface.removeChild(t.domNode),this._callbacks.delete(e)}}))}addItem(t){this.items.add(t)}removeItem(t){this.items.remove(t)}destroy(){this.items.removeAll(),this._callbacks.forEach((t=>this._projector.detach(t))),this._callbacks=null,this._projector=null,this._watchUpdatingTracking.destroy()}render(){this._projector.renderNow()}computeBoundingRect(t){const e=this._hiddenSurface,r=this._hiddenProjector;let o;const s=()=>(o=t.render(),o);r.append(e,s),r.renderNow();const i={left:0,top:0,right:0,bottom:0};if(o&&o.domNode){const t=o.domNode.getBoundingClientRect();i.left=t.left,i.top=t.top,i.right=t.right,i.bottom=t.bottom}for(r.detach(s);e.firstChild;)e.removeChild(e.firstChild);return i}overlaps(t,e){const r=this.computeBoundingRect(t),o=this.computeBoundingRect(e);return Math.max(r.left,o.left)<=Math.min(r.right,o.right)&&Math.max(r.top,o.top)<=Math.min(r.bottom,o.bottom)}get hasVisibleItems(){return this.items.some((t=>t.visible))}async prepare(){await document.fonts.load(this._fontString()).catch((()=>{}))}renderCanvas(t,e){const r=!!e?.disableDecorations;if(!this.items.some((t=>t.visible&&!(r&&t.isDecoration))))return;const o=t.getContext("2d");o.save(),o.font=this._fontString(),this.items.forEach((t=>{r&&t.isDecoration||(o.save(),t.renderCanvas(o),o.restore())})),o.restore()}_fontString(){return`10px ${getComputedStyle(this.surface).fontFamily}`}};t([o({readOnly:!0})],a.prototype,"surface",void 0),t([o({readOnly:!0})],a.prototype,"items",void 0),t([o({readOnly:!0})],a.prototype,"needsRender",null),t([o({readOnly:!0})],a.prototype,"_watchUpdatingTracking",void 0),t([o({readOnly:!0})],a.prototype,"updating",null),a=t([s("esri.views.overlay.ViewOverlay")],a);const c=a;export{c as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import o from"../../core/Collection.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as i}from"../../core/support/UpdatingHandles.js";import"../../libs/maquette/projection.js";import{createProjector as n}from"../../libs/maquette/projector.js";let a=class extends e{constructor(){super(...arguments),this.items=new o,this._watchUpdatingTracking=new i,this._callbacks=new Map,this._projector=n(),this._hiddenProjector=n()}get needsRender(){return this.items.length>0}get updating(){return this._watchUpdatingTracking?.updating??!1}initialize(){const t=document.createElement("div");t.className="esri-overlay-surface",this._set("surface",t),this._hiddenSurface=document.createElement("div"),this._hiddenSurface.setAttribute("style","visibility: hidden;"),t.appendChild(this._hiddenSurface),this._watchUpdatingTracking.addOnCollectionChange((()=>this.items),(t=>{for(const e of t.added){const t=()=>e.render();this._callbacks.set(e,t),this._projector.append(this.surface,t)}for(const e of t.removed){const t=this._projector.detach(this._callbacks.get(e));this.surface.removeChild(t.domNode),this._callbacks.delete(e)}}))}addItem(t){this.items.add(t)}removeItem(t){this.items.remove(t)}destroy(){this.items.removeAll(),this._callbacks.forEach((t=>this._projector.detach(t))),this._callbacks=null,this._projector=null,this._watchUpdatingTracking.destroy()}render(){this._projector.renderNow()}computeBoundingRect(t){const e=this._hiddenSurface,o=this._hiddenProjector;let r;const s=()=>(r=t.render(),r);o.append(e,s),o.renderNow();const i={left:0,top:0,right:0,bottom:0};if(r&&r.domNode){const t=r.domNode.getBoundingClientRect();i.left=t.left,i.top=t.top,i.right=t.right,i.bottom=t.bottom}for(o.detach(s);e.firstChild;)e.removeChild(e.firstChild);return i}overlaps(t,e){const o=this.computeBoundingRect(t),r=this.computeBoundingRect(e);return Math.max(o.left,r.left)<=Math.min(o.right,r.right)&&Math.max(o.top,r.top)<=Math.min(o.bottom,r.bottom)}get hasVisibleItems(){return this.items.some((t=>t.visible))}async prepare(){await document.fonts.load(this._fontString()).catch((()=>{}))}renderCanvas(t,e){const o=!!e?.disableDecorations;if(!this.items.some((t=>t.visible&&!(o&&t.isDecoration))))return;const r=t.getContext("2d");r.save(),r.font=this._fontString(),this.items.forEach((t=>{o&&t.isDecoration||(r.save(),t.renderCanvas(r),r.restore())})),r.restore()}_fontString(){return`10px ${getComputedStyle(this.surface).fontFamily}`}};t([r({readOnly:!0})],a.prototype,"surface",void 0),t([r({readOnly:!0})],a.prototype,"items",void 0),t([r({readOnly:!0})],a.prototype,"needsRender",null),t([r({readOnly:!0})],a.prototype,"_watchUpdatingTracking",void 0),t([r({readOnly:!0})],a.prototype,"updating",null),a=t([s("esri.views.overlay.ViewOverlay")],a);const c=a;export{c 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.28/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../core/Error.js";import"../../core/has.js";import{isPowerOfTwo as e}from"../../core/mathUtils.js";import{checkWebGLError as i}from"./checkWebGLError.js";import{ContextType as r}from"./contextUtils.js";import{ResourceType as s,TextureType as o,TextureSamplingMode as a,PixelFormat as n,PixelType as h,SizedPixelFormat as p,TextureWrapMode as l,CompressedTextureFormat as d}from"./enums.js";import{GLObjectType as c}from"./GLObjectType.js";import{estimateMemory as _}from"./TextureDescriptor.js";import{ValidatedTextureDescriptor as m}from"./ValidatedTextureDescriptor.js";const u=4;let T=class{constructor(e,i=null,a=null){if(this.type=c.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,a=i;else{const r=m.validate(e,i);if(!r)throw new t("Texture descriptor invalid");this._descriptor=r}if(this._descriptor.context.instanceCounter.increment(s.Texture,this),this._descriptor.context.type!==r.WEBGL2&&(this._descriptor.isImmutable&&(this._descriptor.isImmutable=!1),R(this._descriptor.target)))throw new t("3D and array textures are not supported in WebGL1");this._descriptor.target===o.TEXTURE_CUBE_MAP?this._setDataCubeMap(a):this.setData(a)}get glName(){return this._glName}get descriptor(){return this._descriptor}get gpuMemoryUsage(){return P.delete(this),_(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}dispose(){this._descriptor.context.gl&&this._glName&&(this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null,this._descriptor.context.instanceCounter.decrement(s.Texture,this))}release(){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===o.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}_setDataCubeMap(t=null){for(let e=o.TEXTURE_CUBE_MAP_POSITIVE_X;e<=o.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}setData(t){this._setData(t)}_setData(e,r){if(!this._descriptor.context||!this._descriptor.context.gl)return;const s=this._descriptor.context.gl;i(s),this._glName||(this._glName=s.createTexture()),void 0===e&&(e=null);const o=this._descriptor,a=r??o.target,n=R(a);null===e&&(o.width=o.width||u,o.height=o.height||u,n&&(o.depth=o.depth??1));const h=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(T.TEXTURE_UNIT_FOR_UPDATES),g(this._descriptor.context,o),this._configurePixelStorage(),i(s);const p=this._deriveInternalFormat();if(D(e)){let t="width"in e?e.width:e.codedWidth,r="height"in e?e.height:e.codedHeight;const h=1;e instanceof HTMLVideoElement&&(t=e.videoWidth,r=e.videoHeight),o.width&&o.height,n&&o.depth,o.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(a,p,o.hasMipmap,t,r,h),this._texImage(a,0,p,t,r,h,e),i(s),o.hasMipmap&&this.generateMipmap(),o.width||(o.width=t),o.height||(o.height=r),n&&!o.depth&&(o.depth=h)}else{const{width:r,height:h,depth:l}=o;if(null==r||null==h)throw new t("Width and height must be specified!");if(n&&null==l)throw new t("Depth must be specified!");if(o.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(a,p,o.hasMipmap,r,h,l),A(e)){const i=e.levels,n=b(a,r,h,l),d=Math.min(n-1,i.length-1);null!=this._descriptor.context.gl2?s.texParameteri(o.target,this._descriptor.context.gl2.TEXTURE_MAX_LEVEL,d):o.hasMipmap=o.hasMipmap&&n===i.length;const c=p;if(!w(c))throw new t("Attempting to use compressed data with an uncompressed format!");this._forEachMipmapLevel(((t,e,r,s)=>{const o=i[Math.min(t,i.length-1)];this._compressedTexImage(a,t,c,e,r,s,o)}),d)}else this._texImage(a,0,p,r,h,l,e),i(s),o.hasMipmap&&this.generateMipmap()}x(s,this._descriptor),E(s,this._descriptor),f(this._descriptor.context,this._descriptor),i(s),this._descriptor.context.bindTexture(h,T.TEXTURE_UNIT_FOR_UPDATES)}updateData(e,i,r,s,o,a,n=0){a||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const h=this._descriptor.context.gl,p=this._descriptor.context.gl2,l=this._descriptor,d=this._deriveInternalFormat(),{pixelFormat:c,dataType:_,target:m,isImmutable:u}=l;if(u&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");const g=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES,!0);if((i<0||r<0||s>l.width||o>l.height||i+s>l.width||r+o>l.height)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage(),n){if(!p)return void console.error("Webgl2 must be enabled to use dataRowOffset!");h.pixelStorei(p.UNPACK_SKIP_ROWS,n)}if(D(a)?p?p.texSubImage2D(m,e,i,r,s,o,c,_,a):h.texSubImage2D(m,e,i,r,c,_,a):A(a)?h.compressedTexSubImage2D(m,e,i,r,s,o,d,a.levels[e]):h.texSubImage2D(m,e,i,r,s,o,c,_,a),n){if(!p)return void console.error("Webgl2 must be enabled to use dataRowOffset!");h.pixelStorei(p.UNPACK_SKIP_ROWS,0)}this._descriptor.context.bindTexture(g,T.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(e,i,r,s,o,a,n,h){h||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const p=this._descriptor.context.gl2;if(null==p)throw new t("3D textures are not supported in WebGL1");const l=this._descriptor,d=this._deriveInternalFormat(),{pixelFormat:c,dataType:_,isImmutable:m,target:u}=l;if(m&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");R(u)||console.warn("Attempting to set 3D texture data on a non-3D texture");const g=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES);if(this._descriptor.context.setActiveTexture(T.TEXTURE_UNIT_FOR_UPDATES),(i<0||r<0||s<0||o>l.width||a>l.height||n>l.depth||i+o>l.width||r+a>l.height||s+n>l.depth)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage(),A(h))h=h.levels[e],p.compressedTexSubImage3D(u,e,i,r,s,o,a,n,d,h);else{const t=h;p.texSubImage3D(u,e,i,r,s,o,a,n,c,_,t)}this._descriptor.context.bindTexture(g,T.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const e=this._descriptor;if(!e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot add mipmaps to immutable texture after allocation");e.hasMipmap=!0,this._samplingModeDirty=!0,g(this._descriptor.context,e)}e.samplingMode===a.LINEAR?(this._samplingModeDirty=!0,e.samplingMode=a.LINEAR_MIPMAP_NEAREST):e.samplingMode===a.NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=a.NEAREST_MIPMAP_NEAREST);const i=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(T.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.gl.generateMipmap(e.target),this._descriptor.context.bindTexture(i,T.TEXTURE_UNIT_FOR_UPDATES)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,g(this._descriptor.context,this._descriptor),this._wrapModeDirty=!0)}applyChanges(){const t=this._descriptor.context.gl,e=this._descriptor;this._samplingModeDirty&&(x(t,e),this._samplingModeDirty=!1),this._wrapModeDirty&&(E(t,e),this._wrapModeDirty=!1)}_deriveInternalFormat(){if(this._descriptor.context.type===r.WEBGL1)return this._descriptor.internalFormat=this._descriptor.pixelFormat;if(null!=this._descriptor.internalFormat)return this._descriptor.internalFormat===n.DEPTH_STENCIL&&(this._descriptor.internalFormat=n.DEPTH24_STENCIL8),this._descriptor.internalFormat;switch(this._descriptor.dataType){case h.FLOAT:switch(this._descriptor.pixelFormat){case n.RGBA:return this._descriptor.internalFormat=p.RGBA32F;case n.RGB:return this._descriptor.internalFormat=p.RGB32F;default:throw new t("Unable to derive format")}case h.UNSIGNED_BYTE:switch(this._descriptor.pixelFormat){case n.RGBA:return this._descriptor.internalFormat=p.RGBA8;case n.RGB:return this._descriptor.internalFormat=p.RGB8}}return this._descriptor.internalFormat=this._descriptor.pixelFormat===n.DEPTH_STENCIL?n.DEPTH24_STENCIL8:this._descriptor.pixelFormat}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_texStorage(e,i,r,s,o,a){const n=this._descriptor.context.gl2;if(null==n)throw new t("Immutable textures are not supported in WebGL1");if(!M(i))throw new t("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const h=r?b(e,s,o,a):1;if(R(e)){if(null==a)throw new t("Missing depth dimension for 3D texture upload");n.texStorage3D(e,h,i,s,o,a)}else n.texStorage2D(e,h,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,s,o,a,n,h){const p=this._descriptor.context.gl,l=R(e),{isImmutable:d,pixelFormat:c,dataType:_}=this._descriptor,m=this._descriptor.context.type===r.WEBGL2,u=m?p:null;if(m||!D(h))if(d){if(null!=h){const r=h;if(l){if(null==n)throw new t("Missing depth dimension for 3D texture upload");u.texSubImage3D(e,i,0,0,0,o,a,n,c,_,r)}else p.texSubImage2D(e,i,0,0,o,a,c,_,r)}}else{const r=h;if(l){if(null==n)throw new t("Missing depth dimension for 3D texture upload");u.texImage3D(e,i,s,o,a,n,0,c,_,r)}else p.texImage2D(e,i,s,o,a,0,c,_,r)}else p.texImage2D(e,0,s,c,_,h)}_compressedTexImage(e,i,s,o,a,n,h){const p=this._descriptor.context.gl;let l=null;const d=R(e),c=this._descriptor.isImmutable;if(d){if(this._descriptor.context.type!==r.WEBGL2)throw new t("3D textures are not supported in WebGL1");l=p}if(c){if(null!=h)if(d){if(null==n)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexSubImage3D(e,i,0,0,0,o,a,n,s,h)}else p.compressedTexSubImage2D(e,i,0,0,o,a,s,h)}else if(d){if(null==n)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexImage3D(e,i,s,o,a,n,0,h)}else p.compressedTexImage2D(e,i,s,o,a,0,h)}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:a,hasMipmap:n,target:h}=this._descriptor;const p=h===o.TEXTURE_3D;if(null==r||null==s||p&&null==a)throw new t("Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,a),n&&(1!==r||1!==s||p&&1!==a)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),p&&(a=Math.max(1,a>>1))}};function g(t,i){(null!=i.width&&i.width<0||null!=i.height&&i.height<0||null!=i.depth&&i.depth<0)&&console.error("Negative dimension parameters are not allowed!");const s=t.type===r.WEBGL2;if(s||!i.isImmutable&&!R(i.target)||console.error("Immutable and 3D-like textures are not supported in WebGL1!"),s)return;null!=i.width&&e(i.width)&&null!=i.height&&e(i.height)||("number"==typeof i.wrapMode?i.wrapMode!==l.CLAMP_TO_EDGE&&console.error("Non-power-of-two textures must have a wrap mode of CLAMP_TO_EDGE!"):i.wrapMode.s===l.CLAMP_TO_EDGE&&i.wrapMode.t===l.CLAMP_TO_EDGE||console.error("Non-power-of-two textures must have a wrap mode of CLAMP_TO_EDGE!"),i.hasMipmap&&console.error("Mipmapping requires power-of-two textures!"))}function x(t,e){let i=e.samplingMode,r=e.samplingMode;i===a.LINEAR_MIPMAP_NEAREST||i===a.LINEAR_MIPMAP_LINEAR?(i=a.LINEAR,e.hasMipmap||(r=a.LINEAR)):i!==a.NEAREST_MIPMAP_NEAREST&&i!==a.NEAREST_MIPMAP_LINEAR||(i=a.NEAREST,e.hasMipmap||(r=a.NEAREST)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,i),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,r)}function E(t,e){"number"==typeof e.wrapMode?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}function f(t,e){const i=t.capabilities.textureFilterAnisotropic;if(!i)return;t.gl.texParameterf(e.target,i.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}function M(t){return t in p}function w(t){return t in d}function A(t){return null!=t&&"type"in t&&"compressed"===t.type}function I(t){return null!=t&&"byteLength"in t}function D(t){return null!=t&&!A(t)&&!I(t)}function R(t){return t===o.TEXTURE_3D||t===o.TEXTURE_2D_ARRAY}function b(t,e,i,r=1){let s=Math.max(e,i);return t===o.TEXTURE_3D&&(s=Math.max(s,r)),Math.round(Math.log(s)/Math.LN2)+1}function U(){const t=new Array;return P.forEach(((e,i)=>t.push([i.gpuMemoryUsage,e]))),P.clear(),t.sort(((t,e)=>e[0]-t[0])),t.reduce(((t,e)=>`${t}\n\n${Math.round(e[0]/1024)}KB: ${e[1]}`),"")}T.TEXTURE_UNIT_FOR_UPDATES=0;const P=new Map;export{T as Texture,U as clearUnestimatedTextures};
5
+ import t from"../../core/Error.js";import"../../core/has.js";import{isPowerOfTwo as e}from"../../core/mathUtils.js";import{checkWebGLError as i}from"./checkWebGLError.js";import{ContextType as r}from"./contextUtils.js";import{ResourceType as s,TextureType as o,TextureSamplingMode as a,PixelFormat as n,PixelType as h,SizedPixelFormat as p,TextureWrapMode as l,CompressedTextureFormat as d}from"./enums.js";import{GLObjectType as c}from"./GLObjectType.js";import{estimateMemory as _}from"./TextureDescriptor.js";import{ValidatedTextureDescriptor as m}from"./ValidatedTextureDescriptor.js";const u=4;let T=class{constructor(e,i=null,a=null){if(this.type=c.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,a=i;else{const r=m.validate(e,i);if(!r)throw new t("Texture descriptor invalid");this._descriptor=r}if(this._descriptor.context.instanceCounter.increment(s.Texture,this),this._descriptor.context.type!==r.WEBGL2&&(this._descriptor.isImmutable&&(this._descriptor.isImmutable=!1),R(this._descriptor.target)))throw new t("3D and array textures are not supported in WebGL1");this._descriptor.target===o.TEXTURE_CUBE_MAP?this._setDataCubeMap(a):this.setData(a)}get glName(){return this._glName}get descriptor(){return this._descriptor}get gpuMemoryUsage(){return P.delete(this),_(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}dispose(){this._descriptor.context.gl&&this._glName&&(this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null,this._descriptor.context.instanceCounter.decrement(s.Texture,this))}release(){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===o.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}_setDataCubeMap(t=null){for(let e=o.TEXTURE_CUBE_MAP_POSITIVE_X;e<=o.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}setData(t){this._setData(t)}_setData(e,r){if(!this._descriptor.context||!this._descriptor.context.gl)return;const s=this._descriptor.context.gl;i(s),this._glName||(this._glName=s.createTexture()),void 0===e&&(e=null);const o=this._descriptor,a=r??o.target,n=R(a);null===e&&(o.width=o.width||u,o.height=o.height||u,n&&(o.depth=o.depth??1));const h=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(T.TEXTURE_UNIT_FOR_UPDATES),g(this._descriptor.context,o),this._configurePixelStorage(),i(s);const p=this._deriveInternalFormat();if(D(e)){let t="width"in e?e.width:e.codedWidth,r="height"in e?e.height:e.codedHeight;const h=1;e instanceof HTMLVideoElement&&(t=e.videoWidth,r=e.videoHeight),o.width&&o.height,n&&o.depth,o.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(a,p,o.hasMipmap,t,r,h),this._texImage(a,0,p,t,r,h,e),i(s),o.hasMipmap&&this.generateMipmap(),o.width||(o.width=t),o.height||(o.height=r),n&&!o.depth&&(o.depth=h)}else{const{width:r,height:h,depth:l}=o;if(null==r||null==h)throw new t("Width and height must be specified!");if(n&&null==l)throw new t("Depth must be specified!");if(o.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(a,p,o.hasMipmap,r,h,l),A(e)){const i=e.levels,n=b(a,r,h,l),d=Math.min(n-1,i.length-1);null!=this._descriptor.context.gl2?s.texParameteri(o.target,this._descriptor.context.gl2.TEXTURE_MAX_LEVEL,d):o.hasMipmap=o.hasMipmap&&n===i.length;const c=p;if(!w(c))throw new t("Attempting to use compressed data with an uncompressed format!");this._forEachMipmapLevel(((t,e,r,s)=>{const o=i[Math.min(t,i.length-1)];this._compressedTexImage(a,t,c,e,r,s,o)}),d)}else this._texImage(a,0,p,r,h,l,e),i(s),o.hasMipmap&&this.generateMipmap()}x(s,this._descriptor),E(s,this._descriptor),f(this._descriptor.context,this._descriptor),i(s),this._descriptor.context.bindTexture(h,T.TEXTURE_UNIT_FOR_UPDATES)}updateData(e,i,r,s,o,a,n=0){a||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const h=this._descriptor.context.gl,p=this._descriptor.context.gl2,l=this._descriptor,d=this._deriveInternalFormat(),{pixelFormat:c,dataType:_,target:m,isImmutable:u}=l;if(u&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");const g=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES,!0);if((i<0||r<0||s>l.width||o>l.height||i+s>l.width||r+o>l.height)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage(),n){if(!p)return void console.error("Webgl2 must be enabled to use dataRowOffset!");h.pixelStorei(p.UNPACK_SKIP_ROWS,n)}if(D(a)?p?p.texSubImage2D(m,e,i,r,s,o,c,_,a):h.texSubImage2D(m,e,i,r,c,_,a):A(a)?h.compressedTexSubImage2D(m,e,i,r,s,o,d,a.levels[e]):h.texSubImage2D(m,e,i,r,s,o,c,_,a),n){if(!p)return void console.error("Webgl2 must be enabled to use dataRowOffset!");h.pixelStorei(p.UNPACK_SKIP_ROWS,0)}this._descriptor.context.bindTexture(g,T.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(e,i,r,s,o,a,n,h){h||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const p=this._descriptor.context.gl2;if(null==p)throw new t("3D textures are not supported in WebGL1");const l=this._descriptor,d=this._deriveInternalFormat(),{pixelFormat:c,dataType:_,isImmutable:m,target:u}=l;if(m&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");R(u)||console.warn("Attempting to set 3D texture data on a non-3D texture");const g=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES);if(this._descriptor.context.setActiveTexture(T.TEXTURE_UNIT_FOR_UPDATES),(i<0||r<0||s<0||o>l.width||a>l.height||n>l.depth||i+o>l.width||r+a>l.height||s+n>l.depth)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage(),A(h))h=h.levels[e],p.compressedTexSubImage3D(u,e,i,r,s,o,a,n,d,h);else{const t=h;p.texSubImage3D(u,e,i,r,s,o,a,n,c,_,t)}this._descriptor.context.bindTexture(g,T.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const e=this._descriptor;if(!e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot add mipmaps to immutable texture after allocation");e.hasMipmap=!0,this._samplingModeDirty=!0,g(this._descriptor.context,e)}e.samplingMode===a.LINEAR?(this._samplingModeDirty=!0,e.samplingMode=a.LINEAR_MIPMAP_NEAREST):e.samplingMode===a.NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=a.NEAREST_MIPMAP_NEAREST);const i=this._descriptor.context.bindTexture(this,T.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(T.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.gl.generateMipmap(e.target),this._descriptor.context.bindTexture(i,T.TEXTURE_UNIT_FOR_UPDATES)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,g(this._descriptor.context,this._descriptor),this._wrapModeDirty=!0)}applyChanges(){const t=this._descriptor.context.gl,e=this._descriptor;this._samplingModeDirty&&(x(t,e),this._samplingModeDirty=!1),this._wrapModeDirty&&(E(t,e),this._wrapModeDirty=!1)}_deriveInternalFormat(){if(this._descriptor.context.type===r.WEBGL1)return this._descriptor.internalFormat=this._descriptor.pixelFormat;if(null!=this._descriptor.internalFormat)return this._descriptor.internalFormat===n.DEPTH_STENCIL&&(this._descriptor.internalFormat=n.DEPTH24_STENCIL8),this._descriptor.internalFormat;switch(this._descriptor.dataType){case h.FLOAT:switch(this._descriptor.pixelFormat){case n.RGBA:return this._descriptor.internalFormat=p.RGBA32F;case n.RGB:return this._descriptor.internalFormat=p.RGB32F;default:throw new t("Unable to derive format")}case h.UNSIGNED_BYTE:switch(this._descriptor.pixelFormat){case n.RGBA:return this._descriptor.internalFormat=p.RGBA8;case n.RGB:return this._descriptor.internalFormat=p.RGB8}}return this._descriptor.internalFormat=this._descriptor.pixelFormat===n.DEPTH_STENCIL?n.DEPTH24_STENCIL8:this._descriptor.pixelFormat}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_texStorage(e,i,r,s,o,a){const n=this._descriptor.context.gl2;if(null==n)throw new t("Immutable textures are not supported in WebGL1");if(!M(i))throw new t("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const h=r?b(e,s,o,a):1;if(R(e)){if(null==a)throw new t("Missing depth dimension for 3D texture upload");n.texStorage3D(e,h,i,s,o,a)}else n.texStorage2D(e,h,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,s,o,a,n,h){const p=this._descriptor.context.gl,l=R(e),{isImmutable:d,pixelFormat:c,dataType:_}=this._descriptor,m=this._descriptor.context.type===r.WEBGL2,u=m?p:null;if(m||!D(h))if(d){if(null!=h){const r=h;if(l){if(null==n)throw new t("Missing depth dimension for 3D texture upload");u.texSubImage3D(e,i,0,0,0,o,a,n,c,_,r)}else p.texSubImage2D(e,i,0,0,o,a,c,_,r)}}else{const r=h;if(l){if(null==n)throw new t("Missing depth dimension for 3D texture upload");u.texImage3D(e,i,s,o,a,n,0,c,_,r)}else p.texImage2D(e,i,s,o,a,0,c,_,r)}else p.texImage2D(e,0,s,c,_,h)}_compressedTexImage(e,i,s,o,a,n,h){const p=this._descriptor.context.gl;let l=null;const d=R(e),c=this._descriptor.isImmutable;if(d){if(this._descriptor.context.type!==r.WEBGL2)throw new t("3D textures are not supported in WebGL1");l=p}if(c){if(null!=h)if(d){if(null==n)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexSubImage3D(e,i,0,0,0,o,a,n,s,h)}else p.compressedTexSubImage2D(e,i,0,0,o,a,s,h)}else if(d){if(null==n)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexImage3D(e,i,s,o,a,n,0,h)}else p.compressedTexImage2D(e,i,s,o,a,0,h)}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:a,hasMipmap:n,target:h}=this._descriptor;const p=h===o.TEXTURE_3D;if(null==r||null==s||p&&null==a)throw new t("Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,a),n&&(1!==r||1!==s||p&&1!==a)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),p&&(a=Math.max(1,a>>1))}};function g(t,i){(null!=i.width&&i.width<0||null!=i.height&&i.height<0||null!=i.depth&&i.depth<0)&&console.error("Negative dimension parameters are not allowed!");const s=t.type===r.WEBGL2;if(s||!i.isImmutable&&!R(i.target)||console.error("Immutable and 3D-like textures are not supported in WebGL1!"),s)return;null!=i.width&&e(i.width)&&null!=i.height&&e(i.height)||("number"==typeof i.wrapMode?i.wrapMode!==l.CLAMP_TO_EDGE&&console.error("Non-power-of-two textures must have a wrap mode of CLAMP_TO_EDGE!"):i.wrapMode.s===l.CLAMP_TO_EDGE&&i.wrapMode.t===l.CLAMP_TO_EDGE||console.error("Non-power-of-two textures must have a wrap mode of CLAMP_TO_EDGE!"),i.hasMipmap&&console.error("Mipmapping requires power-of-two textures!"))}function x(t,e){let i=e.samplingMode,r=e.samplingMode;i===a.LINEAR_MIPMAP_NEAREST||i===a.LINEAR_MIPMAP_LINEAR?(i=a.LINEAR,e.hasMipmap||(r=a.LINEAR)):i!==a.NEAREST_MIPMAP_NEAREST&&i!==a.NEAREST_MIPMAP_LINEAR||(i=a.NEAREST,e.hasMipmap||(r=a.NEAREST)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,i),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,r)}function E(t,e){"number"==typeof e.wrapMode?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}function f(t,e){const i=t.capabilities.textureFilterAnisotropic;if(!i)return;t.gl.texParameterf(e.target,i.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}function M(t){return t in p}function w(t){return t in d}function A(t){return null!=t&&"type"in t&&"compressed"===t.type}function I(t){return null!=t&&"byteLength"in t}function D(t){return null!=t&&!A(t)&&!I(t)}function R(t){return t===o.TEXTURE_3D||t===o.TEXTURE_2D_ARRAY}function b(t,e,i,r=1){let s=Math.max(e,i);return t===o.TEXTURE_3D&&(s=Math.max(s,r)),Math.round(Math.log(s)/Math.LN2)+1}function U(){const t=new Array;return P.forEach(((e,i)=>t.push([i.gpuMemoryUsage,e]))),P.clear(),t.sort(((t,e)=>e[0]-t[0])),t.reduce(((t,e)=>`${t}\n\n${Math.round(e[0]/1024)}KB: ${e[1]}`),`Total: ${Math.round(t.reduce(((t,e)=>t+e[0]),0)/1024)}KB`)}T.TEXTURE_UNIT_FOR_UPDATES=0;const P=new Map;export{T as Texture,U as clearUnestimatedTextures};