@arcgis/core 5.2.0-next.72 → 5.2.0-next.74

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 (357) hide show
  1. package/analysis/ViewshedAnalysis.js +1 -1
  2. package/arcgisGlobal.d.ts +1 -0
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/{d3be4d914fc99a1d686c.js → 075e65cc4275ac886f08.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{3b3a8a6167f2e1eeb828.js → 0823961e5d0bdedbf8cf.js} +2 -2
  6. package/assets/esri/core/workers/chunks/087bd698b80ca0cea71e.js +1 -0
  7. package/assets/esri/core/workers/chunks/{b6c7b7b7f87dce5de811.js → 0bf644f93c180a2bc2f8.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{a62f1b8ed065b2a38f1a.js → 0dbf31a663b5220a3136.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{fe10a95ebe1da2322af6.js → 0df660dfd941cff3ea1d.js} +1 -1
  10. package/assets/esri/core/workers/chunks/0e81c6d4f1c81f9b0a1b.js +1 -0
  11. package/assets/esri/core/workers/chunks/{d93d0cb69f3a9a722510.js → 1418c03c4ab87f7ab5f4.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{c03da138651ac53cadcb.js → 186bedc377cc97731ca2.js} +2 -2
  13. package/assets/esri/core/workers/chunks/193aed69de2dec4f36b6.js +1 -0
  14. package/assets/esri/core/workers/chunks/1a3afee3ecd806b4aa81.js +1 -0
  15. package/assets/esri/core/workers/chunks/{359584a8fb5687a7d098.js → 264fd750691d517ab1f3.js} +1 -1
  16. package/assets/esri/core/workers/chunks/28f87daaba1ae3441364.js +1 -0
  17. package/assets/esri/core/workers/chunks/{fff23b2682590c4b21e3.js → 2a2ed7bd44010f24c2dd.js} +1 -1
  18. package/assets/esri/core/workers/chunks/2baa16ec8559e77c226f.js +1 -0
  19. package/assets/esri/core/workers/chunks/2c31648a4b95275516ee.js +1 -0
  20. package/assets/esri/core/workers/chunks/2e44978ee677aa23163d.js +256 -0
  21. package/assets/esri/core/workers/chunks/2f81047790c4890ae625.js +1 -0
  22. package/assets/esri/core/workers/chunks/305eea9c1fc4aee3309e.js +1 -0
  23. package/assets/esri/core/workers/chunks/31d19bb72a9e79b30070.js +1 -0
  24. package/assets/esri/core/workers/chunks/{fc2cae359d571690d754.js → 35fd2f765d2cb3f59a22.js} +4 -4
  25. package/assets/esri/core/workers/chunks/{6b208bac120bcfecd9e4.js → 3e2b4e734aa20a308f3e.js} +1 -1
  26. package/assets/esri/core/workers/chunks/45ccca01db0027b9dc16.js +1 -0
  27. package/assets/esri/core/workers/chunks/495f90fe3d0ad32bb82d.js +1 -0
  28. package/assets/esri/core/workers/chunks/4b5bd0c9a55ea2998601.js +1 -0
  29. package/assets/esri/core/workers/chunks/{50e0dd74795978468625.js → 4cf2b0558a4acc141429.js} +1 -1
  30. package/assets/esri/core/workers/chunks/509aecafbc629bee1c15.js +1 -0
  31. package/assets/esri/core/workers/chunks/{d901f8503a73277cfa58.js → 553be2bd69bd311477ea.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{2d3a18d56e2e5669c562.js → 64176f7ae719289a2f79.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{31669511cfddf116d991.js → 66e60351aacbd162775f.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{9684ab5e8254fdfcb7bb.js → 67f54586156d1ab80257.js} +1 -1
  35. package/assets/esri/core/workers/chunks/762be5d3e6aeaea33f74.js +29 -0
  36. package/assets/esri/core/workers/chunks/76b573143d1a65fdbcb6.js +1 -0
  37. package/assets/esri/core/workers/chunks/7aaa051b51a8e34bbfb0.js +1 -0
  38. package/assets/esri/core/workers/chunks/{fa19d5923276418096da.js → 7b5b66ae79e0287e3ade.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{2cfe6f41865ffb3a4645.js → 7e373d9c98ce910db9d2.js} +1 -1
  40. package/assets/esri/core/workers/chunks/81130dbcb738d40f723b.js +1 -0
  41. package/assets/esri/core/workers/chunks/{4da993c79b373b9d304e.js → 8302bffd28cc6720e0fe.js} +2 -2
  42. package/assets/esri/core/workers/chunks/835af7b4fd92cb4e7af0.js +1 -0
  43. package/assets/esri/core/workers/chunks/859dd86c921053bf03a1.js +1 -0
  44. package/assets/esri/core/workers/chunks/877594b6db08da98acd7.js +1 -0
  45. package/assets/esri/core/workers/chunks/{96d861265566854760cd.js → 88fd698b940dadcc6dc5.js} +1 -1
  46. package/assets/esri/core/workers/chunks/8f0d4aec8bd3cbfefc40.js +1 -0
  47. package/assets/esri/core/workers/chunks/{7f208ef75ef2ce0d7cf9.js → 910c93bbbf8113a4a51f.js} +1 -1
  48. package/assets/esri/core/workers/chunks/92c4464b67fce6cea134.js +1 -0
  49. package/assets/esri/core/workers/chunks/{509cfac9e5d86a8ee449.js → 936d44c7bc3a181e64a3.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{b9953277d0cd4a01bdc6.js → 94368a097e6190ce3c7a.js} +1 -1
  51. package/assets/esri/core/workers/chunks/947f1ea4dbc3e3419ecc.js +1 -0
  52. package/assets/esri/core/workers/chunks/9b76c8974424a1908e86.js +1 -0
  53. package/assets/esri/core/workers/chunks/{c203df41f9d2e4b80889.js → 9ca59077712e45ef4d56.js} +1 -1
  54. package/assets/esri/core/workers/chunks/9e25f715cda59c686a4c.js +1 -0
  55. package/assets/esri/core/workers/chunks/{36171c72a3c04b0d13ef.js → a0a1f0bd3648738354a6.js} +1 -1
  56. package/assets/esri/core/workers/chunks/a101152066dd56259619.js +1 -0
  57. package/assets/esri/core/workers/chunks/a2a2c7e274fb32fecffa.js +1 -0
  58. package/assets/esri/core/workers/chunks/a50421fe79f264ae3619.js +1 -0
  59. package/assets/esri/core/workers/chunks/a9053ad0f4e8c4705665.js +1 -0
  60. package/assets/esri/core/workers/chunks/aca5c524bd3c955e9243.js +1 -0
  61. package/assets/esri/core/workers/chunks/{9dda9414104f585560a4.js → ad1d06a91121ebfe9162.js} +2 -2
  62. package/assets/esri/core/workers/chunks/b1a175b3b2d1a7ddde8e.js +1 -0
  63. package/assets/esri/core/workers/chunks/{065e3353124fc5ac44ce.js → b33d870cbfa238762c5e.js} +1 -1
  64. package/assets/esri/core/workers/chunks/b3b53cf0a3a30164d337.js +1 -0
  65. package/assets/esri/core/workers/chunks/b6d26d9738c0787acc38.js +1 -0
  66. package/assets/esri/core/workers/chunks/b9c61b20bbc91cb63036.js +1 -0
  67. package/assets/esri/core/workers/chunks/bf3dc3ad8df8488da3f0.js +1 -0
  68. package/assets/esri/core/workers/chunks/bff75cc7413bf0d319db.js +1 -0
  69. package/assets/esri/core/workers/chunks/c1568bcd3f04014152e1.js +1 -0
  70. package/assets/esri/core/workers/chunks/c1a4d499a30f3d80567b.js +1 -0
  71. package/assets/esri/core/workers/chunks/c374e5d5980db74c4aca.js +1 -0
  72. package/assets/esri/core/workers/chunks/{8c76f31a363dd0c3354d.js → c46f79d5b7712adbbd1c.js} +1 -1
  73. package/assets/esri/core/workers/chunks/c67e4a848d41038367b8.js +1 -0
  74. package/assets/esri/core/workers/chunks/{684d3cb4fb233180b2d0.js → cd892c9603710d6130a9.js} +1 -1
  75. package/assets/esri/core/workers/chunks/{fa5d27e47d47ff8fcb96.js → d03e7be74c57c3dbf003.js} +2 -2
  76. package/assets/esri/core/workers/chunks/de5013f89f0eae93978f.js +1 -0
  77. package/assets/esri/core/workers/chunks/e557043f90c051e93925.js +1 -0
  78. package/assets/esri/core/workers/chunks/{bee5e738ecf8680909c4.js → eaf26c1cc938789d5336.js} +1 -1
  79. package/assets/esri/core/workers/chunks/ebfb3cdc0df15eb05d75.js +1 -0
  80. package/assets/esri/core/workers/chunks/f1727b4a32cb6f36a5e6.js +1 -0
  81. package/assets/esri/core/workers/chunks/f4bc563c71c478d3912f.js +1 -0
  82. package/assets/esri/core/workers/chunks/fb0b89bbb4f8607d5f20.js +1 -0
  83. package/assets/esri/core/workers/chunks/fdca9873914b9dbd9244.js +1 -0
  84. package/assets/esri/core/workers/chunks/ff890167ff2baabfc4ce.js +1 -0
  85. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  86. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  87. package/chunks/Component.glsl.js +3 -3
  88. package/chunks/HUDMaterial.glsl.js +8 -8
  89. package/chunks/lyr3DMain.js +1 -1
  90. package/config.js +1 -1
  91. package/kernel.js +1 -1
  92. package/layers/DimensionFeatureLayer.d.ts +22 -0
  93. package/layers/DimensionFeatureLayer.js +1 -1
  94. package/layers/ILyr3DWasmPerSceneView.js +1 -1
  95. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  96. package/layers/save/featureLayerUtils.js +1 -1
  97. package/layers/support/layerUtils.js +1 -1
  98. package/layers/support/layersMapping.js +1 -1
  99. package/layers/support/tiles3DUtils.js +1 -1
  100. package/layers/video/VideoController.js +1 -1
  101. package/package.json +3 -3
  102. package/support/revision.js +1 -1
  103. package/views/2d/engine/Bitmap.js +1 -1
  104. package/views/2d/engine/BitmapTile.js +1 -1
  105. package/views/2d/engine/BitmapTileContainer.js +1 -1
  106. package/views/2d/engine/flow/FlowContainer.js +1 -1
  107. package/views/2d/engine/flow/FlowDisplayObject.js +1 -1
  108. package/views/2d/engine/flow/styles/Imagery.js +1 -1
  109. package/views/2d/engine/flow/styles/Particles.js +1 -1
  110. package/views/2d/engine/flow/styles/Streamlines.js +1 -1
  111. package/views/2d/engine/imagery/RasterBitmap.js +1 -1
  112. package/views/2d/engine/imagery/RasterTile.js +1 -1
  113. package/views/2d/engine/imagery/RasterTileContainer.js +1 -1
  114. package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
  115. package/views/2d/engine/imagery/RasterVFTile.js +1 -1
  116. package/views/2d/engine/imagery/RasterVFTileContainer.js +1 -1
  117. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  118. package/views/2d/engine/vectorTiles/VectorTileRendererHelper3D.js +1 -1
  119. package/views/2d/engine/webgl/Overlay.js +1 -1
  120. package/views/2d/engine/webgl/OverlayContainer.js +1 -1
  121. package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
  122. package/views/2d/engine/webgl/TileContainer.js +1 -1
  123. package/views/2d/engine/webgl/normalizedTileUtils.js +2 -0
  124. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AAnimatedShader.js +1 -1
  125. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedFillShader.js +1 -1
  126. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedLineShader.js +1 -1
  127. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerShader.js +1 -1
  128. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedTechnique.js +1 -1
  129. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimationUniformInfo.js +1 -1
  130. package/views/2d/engine/webgl/shaderGraph/techniques/bitmap/BitmapTechnique.js +1 -1
  131. package/views/2d/engine/webgl/shaderGraph/techniques/clip/ClipTechnique.js +1 -1
  132. package/views/2d/engine/webgl/shaderGraph/techniques/createGraphicSymbolMeshSchemas.js +1 -1
  133. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityPointShader.js +1 -1
  134. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityTechnique.js +1 -1
  135. package/views/2d/engine/webgl/shaderGraph/techniques/drop-shadow/DropShadowTechnique.js +1 -1
  136. package/views/2d/engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js +1 -1
  137. package/views/2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillTechnique.js +1 -1
  138. package/views/2d/engine/webgl/shaderGraph/techniques/fill/FillMeshWriter.js +1 -1
  139. package/views/2d/engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js +1 -1
  140. package/views/2d/engine/webgl/shaderGraph/techniques/fill/OutlineFillTechnique.js +1 -1
  141. package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillTechnique.js +1 -1
  142. package/views/2d/engine/webgl/shaderGraph/techniques/flow/FlowTechnique.js +1 -1
  143. package/views/2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeTechnique.js +1 -1
  144. package/views/2d/engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js +1 -1
  145. package/views/2d/engine/webgl/shaderGraph/techniques/line/LineTechnique.js +1 -1
  146. package/views/2d/engine/webgl/shaderGraph/techniques/line/TexturedLineTechnique.js +1 -1
  147. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerShader.js +1 -1
  148. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriter.js +1 -1
  149. package/views/2d/engine/webgl/shaderGraph/techniques/overlay/OverlayTechnique.js +1 -1
  150. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartShader.js +1 -1
  151. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
  152. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterHighlightTechnique.js +1 -1
  153. package/views/2d/engine/webgl/shaderGraph/techniques/raster/VectorFieldTechnique.js +1 -1
  154. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ReprojectTechnique.js +1 -1
  155. package/views/2d/engine/webgl/shaderGraph/techniques/raster/rasterVFUtils.js +2 -0
  156. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/AFeatureShader.js +1 -1
  157. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/BitmapShader.js +1 -1
  158. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/ClipShader.js +1 -1
  159. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/ComplexFillShader.js +1 -1
  160. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/ComplexOutlineFillShader.js +1 -1
  161. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/DebugOverlayShader.js +1 -1
  162. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/DropShadowShader.js +1 -1
  163. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/FillShader.js +1 -1
  164. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/GradientFillShader.js +1 -1
  165. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/GradientStrokeShader.js +1 -1
  166. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/HeatmapAccumulateShader.js +1 -1
  167. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
  168. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/OutlineFillShader.js +1 -1
  169. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/OverlayShader.js +1 -1
  170. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/PatternFillShader.js +1 -1
  171. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/PatternOutlineFillShader.js +1 -1
  172. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/TexturedLineShader.js +1 -1
  173. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/Tile.js +2 -0
  174. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/TileDebugInfoShader.js +1 -1
  175. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/TileInfo.js +2 -0
  176. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/TileStencilShader.js +1 -1
  177. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/ViewInfo.js +1 -1
  178. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/flow/FlowImageryShader.js +1 -1
  179. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/flow/FlowParticlesShader.js +1 -1
  180. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/flow/FlowStreamlinesShader.js +1 -1
  181. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/flow/FlowUtils.js +1 -1
  182. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/hittestUtils.js +1 -1
  183. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/BaseRasterColorizerShader.js +1 -1
  184. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/BaseRasterHighlightShader.js +1 -1
  185. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/MagDirShader.js +1 -1
  186. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterVFTransform.js +2 -0
  187. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/ScalarShader.js +1 -1
  188. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/ReprojectShader.js +1 -1
  189. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderBackground.js +1 -1
  190. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderCircle.js +1 -1
  191. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderFill.js +1 -1
  192. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderIcon.js +1 -1
  193. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderLine.js +1 -1
  194. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderOutline.js +1 -1
  195. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/vector-tiles/VTLShaderText.js +1 -1
  196. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  197. package/views/2d/engine/webgl/shaderGraph/techniques/tile/TileDebugInfoTechnique.js +1 -1
  198. package/views/2d/engine/webgl/shaderGraph/techniques/tile/TileStencilTechnique.js +1 -1
  199. package/views/2d/engine/webgl/shaderGraph/techniques/utility/DebugOverlayTechnique.js +1 -1
  200. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueBackground.js +1 -1
  201. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueCircle.js +1 -1
  202. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueFill.js +1 -1
  203. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueLine.js +1 -1
  204. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueSymbol.js +1 -1
  205. package/views/2d/engine/webgl/shaderGraph/typed/TypedShaderProgram.js +1 -1
  206. package/views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js +1 -1
  207. package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
  208. package/views/2d/layers/MediaLayerView2D.js +1 -1
  209. package/views/2d/layers/TileLayerView2D.js +1 -1
  210. package/views/2d/layers/features/layerAdapters/AnnotationLayerAdapter.js +1 -1
  211. package/views/2d/layers/features/layerAdapters/DimensionLayerAdapter.js +1 -1
  212. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  213. package/views/2d/layers/support/DebugOverlay.js +1 -1
  214. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  215. package/views/3d/analysis/LineOfSight/LineOfSightAggregateManipulatedObject3D.js +1 -1
  216. package/views/3d/analysis/LineOfSight/LineOfSightPlacementController.js +1 -1
  217. package/views/3d/analysis/LineOfSight/LineOfSightReshapeTool3D.js +1 -1
  218. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  219. package/views/3d/analysis/LineOfSight/lineOfSightPlacementUtils.js +1 -1
  220. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  221. package/views/3d/analysis/Viewshed/ViewshedEditTool.js +1 -1
  222. package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
  223. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  224. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  225. package/views/3d/analysis/Viewshed/placementUtils.js +1 -1
  226. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  227. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  228. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  229. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementShiftTool.js +1 -1
  230. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementTool.js +1 -1
  231. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  232. package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
  233. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  234. package/views/3d/interactive/editingTools/reshape/ReshapeTool3D.js +1 -1
  235. package/views/3d/interactive/editingTools/reshape/reshapeTooltipUtils3D.js +1 -1
  236. package/views/3d/interactive/editingTools/settings.js +1 -1
  237. package/views/3d/interactive/editingTools/tooltipUtils3D.js +1 -1
  238. package/views/3d/interactive/editingTools/transform/ExtentTransformTool.js +1 -1
  239. package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
  240. package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
  241. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentMove.js +1 -1
  242. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentRotate.js +1 -1
  243. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
  244. package/views/3d/interactive/manipulatorUtils.js +1 -1
  245. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  246. package/views/3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js +1 -1
  247. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  248. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  249. package/views/3d/layers/graphics/tessellationUtils.js +1 -1
  250. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  251. package/views/3d/layers/support/MediaLayerInteraction.js +1 -1
  252. package/views/3d/layers/support/lyr3dTypeConversions.js +1 -1
  253. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  254. package/views/3d/support/renderInfoUtils/polygon.js +1 -1
  255. package/views/3d/webgl-engine/collections/Component/Material/Component.glsl.js +1 -1
  256. package/views/3d/webgl-engine/core/shaderLibrary/NormalFromDepth.glsl.js +1 -1
  257. package/views/3d/webgl-engine/core/shaderLibrary/output/DepthConversion.glsl.js +14 -0
  258. package/views/3d/webgl-engine/core/shaderLibrary/output/ReadDepth.glsl.js +3 -15
  259. package/views/3d/webgl-engine/core/shaderLibrary/output/ReadDepthLastFrame.glsl.js +1 -1
  260. package/views/3d/webgl-engine/lib/BasisUtil.js +1 -1
  261. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  262. package/views/3d/webgl-engine/lib/ManagedTexture.js +1 -1
  263. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  264. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  265. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  266. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  267. package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
  268. package/views/3d/webgl.js +1 -1
  269. package/views/VideoView.js +1 -1
  270. package/views/View.js +1 -1
  271. package/views/draw/DrawGraphicTool.js +1 -1
  272. package/views/draw/DrawOperation.js +1 -1
  273. package/views/draw/DrawTool.js +1 -1
  274. package/views/draw/plugins/PolylinePlugin.js +1 -1
  275. package/views/draw/support/Box.js +1 -1
  276. package/views/draw/support/InteractiveHandle.js +1 -1
  277. package/views/draw/support/Reshape.js +1 -1
  278. package/views/draw/support/drawToolUtils.js +1 -1
  279. package/views/draw/support/managers/InteractiveHandleManager.js +1 -1
  280. package/views/draw/support/managers/TooltipManager.js +1 -1
  281. package/views/draw/support/reshapeTooltipUtils.js +1 -1
  282. package/views/draw/support/tooltipUtils.js +1 -1
  283. package/views/interactive/options/InteractiveToolOptions.d.ts +36 -0
  284. package/views/interactive/options/InteractiveToolOptions.js +2 -0
  285. package/views/interactive/sketch/SketchOptions.d.ts +4 -3
  286. package/views/interactive/sketch/SketchOptions.js +1 -1
  287. package/views/interactive/tooltip/components/DrawHeaderActions.js +1 -1
  288. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  289. package/views/interactive/tooltip/content/TooltipContentDrawPolygon.js +1 -1
  290. package/views/interactive/tooltip/content/TooltipContentDrawPolyline.js +1 -1
  291. package/views/interactive/tooltip/content/TooltipContentDynamic.js +1 -1
  292. package/views/interactive/tooltip/fields/fields.js +1 -1
  293. package/views/interactive/tooltip/infos/DynamicTooltipInfo.js +1 -1
  294. package/views/interactive/tooltip/infos/SketchTooltipInfo.js +1 -1
  295. package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
  296. package/views/support/imageReprojection.js +1 -1
  297. package/widgets/Sketch/SketchViewModel.js +1 -1
  298. package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
  299. package/assets/esri/core/workers/chunks/0623acb2bd14a61b65c9.js +0 -29
  300. package/assets/esri/core/workers/chunks/06c9aac75a01d3af6d54.js +0 -1
  301. package/assets/esri/core/workers/chunks/089f8c60e96d920a2cb2.js +0 -1
  302. package/assets/esri/core/workers/chunks/0c3c311400ee352187ea.js +0 -1
  303. package/assets/esri/core/workers/chunks/158d2ac0333d53556e33.js +0 -1
  304. package/assets/esri/core/workers/chunks/16cade1c2ddf44e336ee.js +0 -1
  305. package/assets/esri/core/workers/chunks/1b130af7d14eaae69d96.js +0 -1
  306. package/assets/esri/core/workers/chunks/1e0140556c2e3fa72545.js +0 -1
  307. package/assets/esri/core/workers/chunks/1e5cb72830c7f32f2961.js +0 -1
  308. package/assets/esri/core/workers/chunks/259bdacfb7b0f866a8d0.js +0 -1
  309. package/assets/esri/core/workers/chunks/2f58e1f64df2da8259a2.js +0 -1
  310. package/assets/esri/core/workers/chunks/383304d33b496c5d8baa.js +0 -1
  311. package/assets/esri/core/workers/chunks/3aacb935d632834d4154.js +0 -1
  312. package/assets/esri/core/workers/chunks/3c8e98cf23ad8ef12fcb.js +0 -1
  313. package/assets/esri/core/workers/chunks/3dc71e03a630dd50b28e.js +0 -1
  314. package/assets/esri/core/workers/chunks/3fd022df127af32782ce.js +0 -1
  315. package/assets/esri/core/workers/chunks/4344ab1250a1c550bf8b.js +0 -1
  316. package/assets/esri/core/workers/chunks/43de723f765ec8f268ac.js +0 -1
  317. package/assets/esri/core/workers/chunks/4695cd6120f60b234d5c.js +0 -1
  318. package/assets/esri/core/workers/chunks/582a1d468089b9986416.js +0 -1
  319. package/assets/esri/core/workers/chunks/5f201c77a09ae0df29d6.js +0 -1
  320. package/assets/esri/core/workers/chunks/6080e46fc79127500283.js +0 -1
  321. package/assets/esri/core/workers/chunks/6357c7cac401aee9fe77.js +0 -1
  322. package/assets/esri/core/workers/chunks/67d3ff7fcefaa7d5d27f.js +0 -1
  323. package/assets/esri/core/workers/chunks/6a9002fcba11e2cf3f2e.js +0 -1
  324. package/assets/esri/core/workers/chunks/72dcd4bd1a28bf8605c5.js +0 -1
  325. package/assets/esri/core/workers/chunks/73f228d966b89c73c9e9.js +0 -1
  326. package/assets/esri/core/workers/chunks/77df0bb35d2688729479.js +0 -1
  327. package/assets/esri/core/workers/chunks/7a143ca61c0a70306185.js +0 -1
  328. package/assets/esri/core/workers/chunks/869d292a60747c93dc84.js +0 -1
  329. package/assets/esri/core/workers/chunks/9c57161ad48d8d546dc7.js +0 -1
  330. package/assets/esri/core/workers/chunks/a7f42ada0aa69873a938.js +0 -1
  331. package/assets/esri/core/workers/chunks/a988fd54912969b812ce.js +0 -1
  332. package/assets/esri/core/workers/chunks/aff0e7761276036e029d.js +0 -1
  333. package/assets/esri/core/workers/chunks/b7d8817018b3d277c454.js +0 -1
  334. package/assets/esri/core/workers/chunks/bfb6566c27c09deb0929.js +0 -1
  335. package/assets/esri/core/workers/chunks/c715c585c42d8c2b86f5.js +0 -1
  336. package/assets/esri/core/workers/chunks/c7e9513f75b8ec205562.js +0 -1
  337. package/assets/esri/core/workers/chunks/c838cc1c786368b78598.js +0 -1
  338. package/assets/esri/core/workers/chunks/cd4e5c948d1bfa9b9a2d.js +0 -1
  339. package/assets/esri/core/workers/chunks/cfe31b7d1c6c05fbd268.js +0 -1
  340. package/assets/esri/core/workers/chunks/d0c1bc90e474f706211c.js +0 -1
  341. package/assets/esri/core/workers/chunks/d2faac81142586cf7509.js +0 -1
  342. package/assets/esri/core/workers/chunks/da484787bd9fd3b13d15.js +0 -1
  343. package/assets/esri/core/workers/chunks/e21b3490bfce75405e55.js +0 -1
  344. package/assets/esri/core/workers/chunks/e4353f0792f45aa6a62f.js +0 -1
  345. package/assets/esri/core/workers/chunks/e702abaeccef20b64a81.js +0 -1
  346. package/assets/esri/core/workers/chunks/ebd619533be077059494.js +0 -1
  347. package/assets/esri/core/workers/chunks/f475672ff4c2ec9367c2.js +0 -1
  348. package/assets/esri/core/workers/chunks/f69329b85b362b349a8c.js +0 -1
  349. package/assets/esri/core/workers/chunks/fba8065a3a6fbd877e23.js +0 -1
  350. package/assets/esri/core/workers/chunks/fd6107f95082e05f016a.js +0 -256
  351. package/assets/esri/core/workers/chunks/fec07a16b72cdcafc641.js +0 -1
  352. package/views/2d/engine/webgl/shaderGraph/techniques/line/utils.js +0 -2
  353. /package/assets/esri/core/workers/chunks/{3b3a8a6167f2e1eeb828.js.LICENSE.txt → 0823961e5d0bdedbf8cf.js.LICENSE.txt} +0 -0
  354. /package/assets/esri/core/workers/chunks/{c03da138651ac53cadcb.js.LICENSE.txt → 186bedc377cc97731ca2.js.LICENSE.txt} +0 -0
  355. /package/assets/esri/core/workers/chunks/{4da993c79b373b9d304e.js.LICENSE.txt → 8302bffd28cc6720e0fe.js.LICENSE.txt} +0 -0
  356. /package/assets/esri/core/workers/chunks/{9dda9414104f585560a4.js.LICENSE.txt → ad1d06a91121ebfe9162.js.LICENSE.txt} +0 -0
  357. /package/assets/esri/core/workers/chunks/{fa5d27e47d47ff8fcb96.js.LICENSE.txt → d03e7be74c57c3dbf003.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{UndoRedo as o}from"../../UndoRedo.js";import{createTask as r}from"../../core/asyncUtils.js";import{makeHandle as i}from"../../core/handleUtils.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as n,syncAndInitial as a,sync as l}from"../../core/reactiveUtils.js";import{property as p,subclass as c}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as d}from"../../core/support/UpdatingHandles.js";import{load as h}from"../../geometry/coordinateFormatter.js";import u from"../../layers/GraphicsLayer.js";import{pointEquals as m}from"../../layers/graphics/dehydratedFeatureComparison.js";import{CreateOperationGeometry as y}from"./support/CreateOperationGeometry.js";import{createCircle as g,createEllipse as v,createSquare as f,createRectangle as _,createPolygon as O,createPolyline as w,createMultipoint as G}from"./support/createUtils.js";import{createViewAlignedCoordinateSystem as C}from"./support/surfaceCoordinateSystems.js";import{createTooltipInfos as x,initializeConstraints as V,updateTooltipInfo as k,getConstraintZ as b,unlockConstraintsOnVertexAddOrRemove as U,lockElevationOnVertexAdd as H,getActiveTooltipInfo as T}from"./support/tooltipUtils.js";import{InteractiveToolBase as S}from"../interactive/InteractiveToolBase.js";import j from"../interactive/sketch/SketchOptions.js";import{makeTooltip as L,pasteLocation as R,enterInputModeIfAvailable as z}from"../interactive/tooltip/tooltipCommonUtils.js";import{GeometryWorkerHandle as E}from"../support/GeometryWorkerHandle.js";import{autorun as I}from"../../core/accessorSupport/trackingUtils.js";let A=class extends S{constructor(e){super(e),this._graphic=null,this._coordinateFormatterLoadTask=null,this._createOperationGeometry=null,this.defaultZ=0,this.directionOptions=null,this.elevationLockOnVertexAddDisabled=!1,this.geometryType=null,this.hasZ=!0,this.geometryToPlace=null,this.snappingManager=null,this.snapToScene=!1,this.sketchOptions=new j,this._updatingHandles=new d,this._measurementWorker=new E({preloadGeodetic:!0})}initialize(){const{view:e}=this;this.internalGraphicsLayer=new u({listMode:"hide",internal:!0,title:"DrawGraphicTool layer"}),this.view.map.layers.add(this.internalGraphicsLayer);const t=this.drawOperation=this.makeDrawOperation();this.tooltipInfos=x(e.type,this.sketchOptions);const o=L(()=>({view:e,options:this.sketchOptions.tooltips}));this.tooltip=o,V(this._tooltipsContext),this._coordinateFormatterLoadTask=r(()=>h()),this.addHandles([t.on("vertex-add",e=>this.onVertexAdd(e)),t.on("vertex-remove",e=>this.onVertexRemove(e)),t.on("vertex-update",e=>this.onVertexUpdate(e)),t.on("cursor-update",e=>this.onCursorUpdate(e)),t.on("cursor-remove",()=>this._updateGraphic()),t.on("complete",e=>this.onComplete(e)),this._coordinateFormatterLoadTask,o.on("paste",e=>R(e,this.activeTooltipInfo)),n(()=>this.cursor,e=>{t.cursor=e},a),I(()=>{const{activeTooltipInfo:e,sketchOptions:t}=this;k(e,this._tooltipsContext,this._updatingHandles),o.info=t.tooltips.effectiveEnabled?e:null}),I(()=>{t.constraintZ=b(this._tooltipsContext)},l)]),this.finishToolCreation(),t.initializePointer()}destroy(){this.drawOperation=s(this.drawOperation),this.tooltip=s(this.tooltip),this._destroyAllVisualizations(),this.view.map.remove(this.internalGraphicsLayer),this.internalGraphicsLayer=s(this.internalGraphicsLayer),this._updatingHandles.destroy(),this._measurementWorker.destroy(),this._set("view",null)}get _drawSpatialReference(){return this.drawOperation.coordinateHelper.spatialReference}get _tooltipsContext(){const{defaultZ:e,directionOptions:t,drawOperation:o,forceUniformSize:r,geometryType:i,graphic:s,sketchOptions:n,tooltipInfos:a,view:l,_measurementWorker:p}=this;return{createOperationGeometry:this._createOperationGeometry,defaultZ:e,directionOptions:t,drawOperation:o,forceUniformSize:r,geometryType:i,graphic:s,sketchOptions:n,tooltipInfos:a,view:l,measurementWorker:p}}get canRedo(){return this.drawOperation.canRedo}get canUndo(){return this.drawOperation.canUndo}set centered(e){this._set("centered",e),this._updateGraphic()}get cursor(){return this._get("cursor")}set cursor(e){this._set("cursor",e)}set enabled(e){this.drawOperation.interactive=e,this._set("enabled",e)}set forceUniformSize(e){this._set("forceUniformSize",e),this._updateGraphic()}get graphic(){return this._graphic}set graphicSymbol(e){this._set("graphicSymbol",e),null!=this._graphic&&(this._graphic.symbol=e)}set mode(e){const t=this.drawOperation;t&&(t.drawingMode=e),this._set("mode",e)}get updating(){return(this._updatingHandles.updating||this.drawOperation?.updating)??!1}get undoRedo(){const{view:{type:e,map:t}}=this;return"2d"===e&&t&&"undoRedo"in t&&t.undoRedo instanceof o?t.undoRedo:null}set undoRedo(e){this._override("undoRedo",e)}completeCreateOperation(){this.drawOperation.complete()}onInputEvent(e){this.destroyed||z(e,this.tooltip)||this.drawOperation.onInputEvent(e)}redo(){this.drawOperation.redo()}reset(){}undo(){this.drawOperation.undo(),0===this.drawOperation.numCommittedVertices&&V(this._tooltipsContext)}_destroyAllVisualizations(){this.removeHandles(F.outline),this.removeHandles(F.regularVertices),this.removeHandles(F.activeVertex),this.removeHandles(F.activeEdge),this.removeHandles(D)}_createOrUpdateGraphic(e){if(null!=this._graphic)return this.updateGraphicGeometry(e),this._graphic;const o=new t({...this.graphicProperties,symbol:this.graphicSymbol});return this._graphic=o,this.updateGraphicGeometry(e),this.internalGraphicsLayer.add(o),this.addHandles(this.initializeGraphic(o)),this.notifyChange("graphic"),this.addHandles(i(()=>{this.internalGraphicsLayer.remove(o),this._graphic===o&&(this._graphic=null)}),D),o}updateGraphicGeometry(e){this._graphic.geometry=e}_getCreateOperationGeometry(e={operationComplete:!1}){if(null==this.drawOperation)return;const{coordinateHelper:t,view:o,visualizationCursorVertex:r,lastVertex:i,committedVertices:s,geometryIncludingUncommittedVertices:n,numCommittedVertices:a}=this.drawOperation;if(!(a>0||null!=r))return;const l=e.operationComplete?s:n,p=l.length,c=null!=r?t.pointToArray(r):null,d=this._drawSpatialReference,h="3d"===o.type&&"global"===o.viewingMode,u=new y;u.committedVertices=s,u.cursorVertex=c;const{geometryType:x}=this;switch(x){case"point":case"mesh":u.full=t.arrayToPoint(l[0]);break;case"multipoint":u.full=p>0?G(l,d):null;break;case"polyline":case"polygon":p>0&&(u.full="polygon"===x?O([l],d,h,!0):w([l],d,h),u.cursorEdge=null!=c&&i&&!m(r,i)?w([[c,t.pointToArray(i)]],d,h):null,u.outline=p>1?u.full:null);break;case"circle":case"rectangle":{if(u.committedVertices=u.cursorVertex=null,!p)break;const t=C(o,l[0]),r=l[0],i=t.makeMapPoint(r[0]+Z*o.resolution,r[1]);"circle"===x?1===p&&e.operationComplete?u.circle=g([r,i],t,!0):2===p&&(this.forceUniformSize?u.circle=g(l,t,this.centered):u.rectangle=v(l,t,this.centered)):1===p&&e.operationComplete?u.rectangle=f([r,i],t,!0):2===p&&(u.rectangle=this.forceUniformSize?f(l,t,this.centered):_(l,t,this.centered)),u.full=null!=u.circle?u.circle.geometry:u.rectangle?.geometry,u.outline="polygon"===u.full?.type?u.full:null;break}default:return null}return u}initializeGraphic(e){return i()}onComplete(e){if(!this.drawOperation)return;this._updateGraphic();let t=null;if(this.drawOperation.isCompleted){const e=this._getCreateOperationGeometry({operationComplete:!0});null!=e&&(t=this._createOrUpdateGraphic(e.full))}this._createOperationGeometry=null,this.emit("complete",{graphic:t,...e})}onCursorUpdate(e){this._updateGraphic(),this.emit("cursor-update",e)}onDeactivate(){const{drawOperation:e}=this;e&&(e.isCompleted||e.cancel())}onOutlineChanged(e){return i()}onCursorEdgeChanged(e){return i()}onVertexAdd(e){U(this._tooltipsContext),this._updateGraphic(),this.elevationLockOnVertexAddDisabled||H(e.vertices.at(0)?.coordinates,this._tooltipsContext),this.emit("vertex-add",e)}onVertexRemove(e){U(this._tooltipsContext),this._updateGraphic(),this.emit("vertex-remove",e)}onVertexUpdate(e){this._updateGraphic(),this.emit("vertex-update",e)}_updateGraphic(){const e=this._getCreateOperationGeometry();this._createOperationGeometry=e,null!=e?(null!=e.cursorEdge?this.addHandles(this.onCursorEdgeChanged(e.cursorEdge),F.activeEdge):this.removeHandles(F.activeEdge),null!=e.outline?this.addHandles(this.onOutlineChanged(e.outline),F.outline):this.removeHandles(F.outline),null!=e.committedVertices?this.addHandles(this.onRegularVerticesChanged(e.committedVertices),F.regularVertices):this.removeHandles(F.regularVertices),null!=e.cursorVertex?this.addHandles(this.onActiveVertexChanged(e.cursorVertex),F.activeVertex):this.removeHandles(F.activeVertex),null!=e.full?this._createOrUpdateGraphic(e.full):this.removeHandles(D)):this._destroyAllVisualizations()}get activeTooltipInfo(){return this._coordinateFormatterLoadTask?.finished?T(this._tooltipsContext):null}};e([p()],A.prototype,"_coordinateFormatterLoadTask",void 0),e([p()],A.prototype,"_createOperationGeometry",void 0),e([p()],A.prototype,"_tooltipsContext",null),e([p({value:!0})],A.prototype,"centered",null),e([p()],A.prototype,"cursor",null),e([p({nonNullable:!0})],A.prototype,"defaultZ",void 0),e([p({constructOnly:!0})],A.prototype,"directionOptions",void 0),e([p()],A.prototype,"drawOperation",void 0),e([p()],A.prototype,"elevationLockOnVertexAddDisabled",void 0),e([p({value:!0})],A.prototype,"enabled",null),e([p({value:!0})],A.prototype,"forceUniformSize",null),e([p({constructOnly:!0})],A.prototype,"geometryType",void 0),e([p()],A.prototype,"graphic",null),e([p({constructOnly:!0})],A.prototype,"graphicProperties",void 0),e([p()],A.prototype,"graphicSymbol",null),e([p({constructOnly:!0})],A.prototype,"hasZ",void 0),e([p({constructOnly:!0})],A.prototype,"geometryToPlace",void 0),e([p()],A.prototype,"mode",null),e([p()],A.prototype,"snappingManager",void 0),e([p()],A.prototype,"snapToScene",void 0),e([p()],A.prototype,"tooltip",void 0),e([p()],A.prototype,"tooltipInfos",void 0),e([p({constructOnly:!0,type:j})],A.prototype,"sketchOptions",void 0),e([p()],A.prototype,"updating",null),e([p({constructOnly:!0,nonNullable:!0})],A.prototype,"view",void 0),e([p({constructOnly:!0})],A.prototype,"undoRedo",null),e([p()],A.prototype,"activeTooltipInfo",null),A=e([c("esri.views.draw.DrawGraphicTool")],A);const D=Symbol("create-operation-graphic"),F={outline:Symbol("outline-visual"),regularVertices:Symbol("regular-vertices-visual"),activeVertex:Symbol("active-vertex-visual"),activeEdge:Symbol("active-edge-visual")};function P(e){switch(e){case"point":case"polyline":case"polygon":case"multipoint":return e;case"circle":case"rectangle":return"segment";case"mesh":return"point"}}const Z=48;export{A as DrawGraphicTool,P as geometryTypeToDrawOperationGeometryType};
2
+ import{__decorate as t}from"tslib";import e from"../../Graphic.js";import{UndoRedo as o}from"../../UndoRedo.js";import{createTask as r}from"../../core/asyncUtils.js";import{makeHandle as i}from"../../core/handleUtils.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as n,syncAndInitial as a,sync as l}from"../../core/reactiveUtils.js";import{property as p,subclass as c}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as d}from"../../core/support/UpdatingHandles.js";import{load as h}from"../../geometry/coordinateFormatter.js";import u from"../../layers/GraphicsLayer.js";import{pointEquals as m}from"../../layers/graphics/dehydratedFeatureComparison.js";import{CreateOperationGeometry as y}from"./support/CreateOperationGeometry.js";import{createCircle as g,createEllipse as v,createSquare as f,createRectangle as _,createPolygon as O,createPolyline as w,createMultipoint as G}from"./support/createUtils.js";import{createViewAlignedCoordinateSystem as C}from"./support/surfaceCoordinateSystems.js";import{createTooltipInfos as x,initializeConstraints as V,updateTooltipInfo as b,getConstraintZ as T,unlockConstraintsOnVertexAddOrRemove as U,lockElevationOnVertexAdd as H,getActiveTooltipInfo as S}from"./support/tooltipUtils.js";import{InteractiveToolBase as k}from"../interactive/InteractiveToolBase.js";import j from"../interactive/options/InteractiveToolOptions.js";import{makeTooltip as L,pasteLocation as R,enterInputModeIfAvailable as z}from"../interactive/tooltip/tooltipCommonUtils.js";import{GeometryWorkerHandle as I}from"../support/GeometryWorkerHandle.js";import{autorun as E}from"../../core/accessorSupport/trackingUtils.js";let A=class extends k{constructor(t){super(t),this._graphic=null,this._coordinateFormatterLoadTask=null,this._createOperationGeometry=null,this.defaultZ=0,this.directionOptions=null,this.elevationLockOnVertexAddDisabled=!1,this.geometryType=null,this.hasZ=!0,this.geometryToPlace=null,this.snappingManager=null,this.snapToScene=!1,this.toolOptions=new j,this._updatingHandles=new d,this._measurementWorker=new I({preloadGeodetic:!0})}initialize(){const{view:t}=this;this.internalGraphicsLayer=new u({listMode:"hide",internal:!0,title:"DrawGraphicTool layer"}),this.view.map.layers.add(this.internalGraphicsLayer);const e=this.drawOperation=this.makeDrawOperation();this.tooltipInfos=x(t.type,this.toolOptions);const o=L(()=>({view:t,options:this.toolOptions.tooltips}));this.tooltip=o,V(this._tooltipsContext),this._coordinateFormatterLoadTask=r(()=>h()),this.addHandles([e.on("vertex-add",t=>this.onVertexAdd(t)),e.on("vertex-remove",t=>this.onVertexRemove(t)),e.on("vertex-update",t=>this.onVertexUpdate(t)),e.on("cursor-update",t=>this.onCursorUpdate(t)),e.on("cursor-remove",()=>this._updateGraphic()),e.on("complete",t=>this.onComplete(t)),this._coordinateFormatterLoadTask,o.on("paste",t=>R(t,this.activeTooltipInfo)),n(()=>this.cursor,t=>{e.cursor=t},a),E(()=>{const{activeTooltipInfo:t,toolOptions:e}=this;b(t,this._tooltipsContext,this._updatingHandles),o.info=e.tooltips.effectiveEnabled?t:null}),E(()=>{e.constraintZ=T(this._tooltipsContext)},l)]),this.finishToolCreation(),e.initializePointer()}destroy(){this.drawOperation=s(this.drawOperation),this.tooltip=s(this.tooltip),this._destroyAllVisualizations(),this.view.map.remove(this.internalGraphicsLayer),this.internalGraphicsLayer=s(this.internalGraphicsLayer),this._updatingHandles.destroy(),this._measurementWorker.destroy(),this._set("view",null)}get _drawSpatialReference(){return this.drawOperation.coordinateHelper.spatialReference}get _tooltipsContext(){const{defaultZ:t,directionOptions:e,drawOperation:o,forceUniformSize:r,geometryType:i,graphic:s,toolOptions:n,tooltipInfos:a,view:l,_measurementWorker:p}=this;return{createOperationGeometry:this._createOperationGeometry,defaultZ:t,directionOptions:e,drawOperation:o,forceUniformSize:r,geometryType:i,graphic:s,toolOptions:n,tooltipInfos:a,view:l,measurementWorker:p}}get canRedo(){return this.drawOperation.canRedo}get canUndo(){return this.drawOperation.canUndo}set centered(t){this._set("centered",t),this._updateGraphic()}get cursor(){return this._get("cursor")}set cursor(t){this._set("cursor",t)}set enabled(t){this.drawOperation.interactive=t,this._set("enabled",t)}set forceUniformSize(t){this._set("forceUniformSize",t),this._updateGraphic()}get graphic(){return this._graphic}set graphicSymbol(t){this._set("graphicSymbol",t),null!=this._graphic&&(this._graphic.symbol=t)}set mode(t){const e=this.drawOperation;e&&(e.drawingMode=t),this._set("mode",t)}get updating(){return(this._updatingHandles.updating||this.drawOperation?.updating)??!1}get undoRedo(){const{view:{type:t,map:e}}=this;return"2d"===t&&e&&"undoRedo"in e&&e.undoRedo instanceof o?e.undoRedo:null}set undoRedo(t){this._override("undoRedo",t)}completeCreateOperation(){this.drawOperation.complete()}onInputEvent(t){this.destroyed||z(t,this.tooltip)||this.drawOperation.onInputEvent(t)}redo(){this.drawOperation.redo()}reset(){}undo(){this.drawOperation.undo(),0===this.drawOperation.numCommittedVertices&&V(this._tooltipsContext)}_destroyAllVisualizations(){this.removeHandles(F.outline),this.removeHandles(F.regularVertices),this.removeHandles(F.activeVertex),this.removeHandles(F.activeEdge),this.removeHandles(D)}_createOrUpdateGraphic(t){if(null!=this._graphic)return this.updateGraphicGeometry(t),this._graphic;const o=new e({...this.graphicProperties,symbol:this.graphicSymbol});return this._graphic=o,this.updateGraphicGeometry(t),this.internalGraphicsLayer.add(o),this.addHandles(this.initializeGraphic(o)),this.notifyChange("graphic"),this.addHandles(i(()=>{this.internalGraphicsLayer.remove(o),this._graphic===o&&(this._graphic=null)}),D),o}updateGraphicGeometry(t){this._graphic.geometry=t}_getCreateOperationGeometry(t={operationComplete:!1}){if(null==this.drawOperation)return;const{coordinateHelper:e,view:o,visualizationCursorVertex:r,lastVertex:i,committedVertices:s,geometryIncludingUncommittedVertices:n,numCommittedVertices:a}=this.drawOperation;if(!(a>0||null!=r))return;const l=t.operationComplete?s:n,p=l.length,c=null!=r?e.pointToArray(r):null,d=this._drawSpatialReference,h="3d"===o.type&&"global"===o.viewingMode,u=new y;u.committedVertices=s,u.cursorVertex=c;const{geometryType:x}=this;switch(x){case"point":case"mesh":u.full=e.arrayToPoint(l[0]);break;case"multipoint":u.full=p>0?G(l,d):null;break;case"polyline":case"polygon":p>0&&(u.full="polygon"===x?O([l],d,h,!0):w([l],d,h),u.cursorEdge=null!=c&&i&&!m(r,i)?w([[c,e.pointToArray(i)]],d,h):null,u.outline=p>1?u.full:null);break;case"circle":case"rectangle":{if(u.committedVertices=u.cursorVertex=null,!p)break;const e=C(o,l[0]),r=l[0],i=e.makeMapPoint(r[0]+Z*o.resolution,r[1]);"circle"===x?1===p&&t.operationComplete?u.circle=g([r,i],e,!0):2===p&&(this.forceUniformSize?u.circle=g(l,e,this.centered):u.rectangle=v(l,e,this.centered)):1===p&&t.operationComplete?u.rectangle=f([r,i],e,!0):2===p&&(u.rectangle=this.forceUniformSize?f(l,e,this.centered):_(l,e,this.centered)),u.full=null!=u.circle?u.circle.geometry:u.rectangle?.geometry,u.outline="polygon"===u.full?.type?u.full:null;break}default:return null}return u}initializeGraphic(t){return i()}onComplete(t){if(!this.drawOperation)return;this._updateGraphic();let e=null;if(this.drawOperation.isCompleted){const t=this._getCreateOperationGeometry({operationComplete:!0});null!=t&&(e=this._createOrUpdateGraphic(t.full))}this._createOperationGeometry=null,this.emit("complete",{graphic:e,...t})}onCursorUpdate(t){this._updateGraphic(),this.emit("cursor-update",t)}onDeactivate(){const{drawOperation:t}=this;t&&(t.isCompleted||t.cancel())}onOutlineChanged(t){return i()}onCursorEdgeChanged(t){return i()}onVertexAdd(t){U(this._tooltipsContext),this._updateGraphic(),this.elevationLockOnVertexAddDisabled||H(t.vertices.at(0)?.coordinates,this._tooltipsContext),this.emit("vertex-add",t)}onVertexRemove(t){U(this._tooltipsContext),this._updateGraphic(),this.emit("vertex-remove",t)}onVertexUpdate(t){this._updateGraphic(),this.emit("vertex-update",t)}_updateGraphic(){const t=this._getCreateOperationGeometry();this._createOperationGeometry=t,null!=t?(null!=t.cursorEdge?this.addHandles(this.onCursorEdgeChanged(t.cursorEdge),F.activeEdge):this.removeHandles(F.activeEdge),null!=t.outline?this.addHandles(this.onOutlineChanged(t.outline),F.outline):this.removeHandles(F.outline),null!=t.committedVertices?this.addHandles(this.onRegularVerticesChanged(t.committedVertices),F.regularVertices):this.removeHandles(F.regularVertices),null!=t.cursorVertex?this.addHandles(this.onActiveVertexChanged(t.cursorVertex),F.activeVertex):this.removeHandles(F.activeVertex),null!=t.full?this._createOrUpdateGraphic(t.full):this.removeHandles(D)):this._destroyAllVisualizations()}get activeTooltipInfo(){return this._coordinateFormatterLoadTask?.finished?S(this._tooltipsContext):null}};t([p()],A.prototype,"_coordinateFormatterLoadTask",void 0),t([p()],A.prototype,"_createOperationGeometry",void 0),t([p()],A.prototype,"_tooltipsContext",null),t([p({value:!0})],A.prototype,"centered",null),t([p()],A.prototype,"cursor",null),t([p({nonNullable:!0})],A.prototype,"defaultZ",void 0),t([p({constructOnly:!0})],A.prototype,"directionOptions",void 0),t([p()],A.prototype,"drawOperation",void 0),t([p()],A.prototype,"elevationLockOnVertexAddDisabled",void 0),t([p({value:!0})],A.prototype,"enabled",null),t([p({value:!0})],A.prototype,"forceUniformSize",null),t([p({constructOnly:!0})],A.prototype,"geometryType",void 0),t([p()],A.prototype,"graphic",null),t([p({constructOnly:!0})],A.prototype,"graphicProperties",void 0),t([p()],A.prototype,"graphicSymbol",null),t([p({constructOnly:!0})],A.prototype,"hasZ",void 0),t([p({constructOnly:!0})],A.prototype,"geometryToPlace",void 0),t([p()],A.prototype,"mode",null),t([p()],A.prototype,"snappingManager",void 0),t([p()],A.prototype,"snapToScene",void 0),t([p()],A.prototype,"tooltip",void 0),t([p()],A.prototype,"tooltipInfos",void 0),t([p({constructOnly:!0,type:j})],A.prototype,"toolOptions",void 0),t([p()],A.prototype,"updating",null),t([p({constructOnly:!0,nonNullable:!0})],A.prototype,"view",void 0),t([p({constructOnly:!0})],A.prototype,"undoRedo",null),t([p()],A.prototype,"activeTooltipInfo",null),A=t([c("esri.views.draw.DrawGraphicTool")],A);const D=Symbol("create-operation-graphic"),F={outline:Symbol("outline-visual"),regularVertices:Symbol("regular-vertices-visual"),activeVertex:Symbol("active-vertex-visual"),activeEdge:Symbol("active-edge-visual")};function P(t){switch(t){case"point":case"polyline":case"polygon":case"multipoint":return t;case"circle":case"rectangle":return"segment";case"mesh":return"point"}}const Z=48;export{A as DrawGraphicTool,P as geometryTypeToDrawOperationGeometryType};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{clone as i}from"../../core/lang.js";import{equalsMaybe as n,destroyMaybe as r}from"../../core/maybe.js";import{memoize as s}from"../../core/memoize.js";import{ignoreAbortErrors as o}from"../../core/promiseUtils.js";import a from"../../core/ReactiveSet.js";import{watch as p,syncAndInitial as l}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as d,subclass as h}from"../../core/accessorSupport/decorators.js";import{diff as u}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as m,pointNear as y}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as _}from"../../support/elevationInfoUtils.js";import{defaultDrawingMode as v}from"./drawingModes.js";import{LegacyDrawManipulator as f}from"./LegacyDrawManipulator.js";import{createCoordinateHelper as x}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as P,sceneSnappingAtLocation as b}from"../interactive/dragEventPipeline.js";import{EditGeometry as T,Part as S}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as C}from"../interactive/editGeometry/EditGeometryOperations.js";import{isPoint as V}from"../interactive/sketch/constraints.js";import{getPointConstraint as w,getPolylineOrPolygonConstraint as O,pointToConstraintSpace as M,constraintSpaceToPoint as D}from"../interactive/sketch/constraintUtils.js";import E from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as I}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as H}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as G}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as j}from"../interactive/snapping/snappingUtils.js";const k="crosshair",Z="progress",A=Symbol(),L=Symbol();let z=class extends e{constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new a,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this._stagedPointerId=null,this.constraintsEnabled=!1,this.constraints=void 0,this._getPointConstraint=s(w),this._getPolylineOrPolygonConstraint=s(O),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new E,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,null==t.elevationInfo&&(this.elevationInfo=_(!!t.hasZ))}initializePointer(){const t=this.view.inputManager?.latestPointerInfo;null!=t&&"touch"!==t.type&&this._updatePointer(t.location,t.id,t.type)}initialize(){const{geometryType:t,view:e}=this,i=e.spatialReference,r="viewingMode"in e.state?e.state.viewingMode:2,s="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=x(this.hasZ,this.hasM,i),this._editGeometryOperations=new C(new T(s,this.coordinateHelper),r),this._snappingOperation=new G({view:e}),this.addHandles([p(()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this._constraint}),({stagedPoint:t,constraint:e},i)=>{const{snappingOptions:n}=this;n&&(n.forceDisabled=null!=e&&V(e));if(null!=i&&t===i.stagedPoint&&e!==i.constraint)return this._onKeyboardBasedChange();this._processCursor(t??this._screenToMap(this._stagedScreenPoint))},{equals:(t,e)=>t.stagedPoint===e.stagedPoint&&n(t.constraint,e.constraint)}),p(()=>this.view.viewpoint,(t,e)=>{t&&e&&u(t,e)&&this._onKeyboardBasedChange()})]),this._activePart=new S(i,r),this._editGeometryOperations.data.parts.push(this._activePart);const a=this.segmentLabels;null!=a&&(a.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles(p(()=>this.labelOptions.enabled,t=>{a.visible=t},l))),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],t=>{const e=t.vertices.map(t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)})),i=e.map(t=>t.coordinates),n=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getFirstVertex()?.pos)??null;m(n,this.firstVertex)||(this.firstVertex=n);const r=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getLastVertex()?.pos)??null;m(r,this.lastVertex)||(this.lastVertex=r);const s=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.segments.at(-1)?.leftVertex?.pos)??null;switch(m(s,this.secondToLastVertex)||(this.secondToLastVertex=s),this._processCursor(this.cursorVertex),t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}}));const c=this._manipulator=new f({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(c),c.grabbable="point"!==t&&"multipoint"!==t,this.addHandles([c.events.on("immediate-click",t=>this._onImmediateClick(t)),c.events.on("immediate-double-click",t=>this._onImmediateDoubleClick(t)),p(()=>this.drawingMode,()=>{this.removeHandles(A),this.addHandles(this._createManipulatorDragPipeline(c),A)},l),p(()=>({effectiveCursor:this.effectiveCursor}),({effectiveCursor:t})=>{c.cursor=t},l)]),j(this,()=>{const t=this.view.inputManager.latestPointerInfo?.type??"mouse",e=this._getSnappingContext(t);if(null!=this.snappingManager){const t=this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e);this._updatingHandles.consumePromise(o(t))}})}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations),this._updatingHandles.destroy()}get _isDragging(){const{_stagedPointerId:t,_manipulator:e}=this;return null!=t&&this._pointerDownStates.has(t)||e.grabbing||!e.interactive}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const t=this._updateAndGetEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==t}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activePart.vertices.map(t=>this.coordinateHelper.vectorToArray(t.pos))}get _constraint(){const{constraints:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":case"multipoint":return this._getPointConstraint(t);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t)}}set drawingMode(t){this._set("drawingMode",t??v)}get effectiveCursor(){return this.loading?Z:this._hideDefaultCursor?null:this.cursor||k}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activePart.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get cursorVertex(){return this._get("cursorVertex")}get visualizationCursorVertex(){return"mouse"===this._stagedPointerType?this.cursorVertex:null}get committableVertex(){const{cursorVertex:t,lastVertex:e,firstVertex:i,geometryType:n}=this;return"polygon"===n&&y(t,i)||y(t,e)?null:t}get updating(){return this._updatingHandles.updating||!!this.segmentLabels?.updating}get geometryIncludingUncommittedVertices(){const{committedVertices:t,committableVertex:e,coordinateHelper:i}=this,n=t.slice();return null!=e&&n.push(i.pointToArray(e)),n}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();const{committableVertex:t}=this;null!=t&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t),this._activePart)}complete(t){const e=t?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();const{geometryType:i,numCommittedVertices:n}=this,r="multipoint"===i&&0===n||"polyline"===i&&n<2||"polygon"===i&&n<3;"segment"!==i&&"point"!==i||this.commitStagedVertex(),this._createOperationCompleted=!r,(this.isCompleted||e)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit("complete",{vertices:this.committedVertices.map((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t})),aborted:e,type:"complete"}))}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(t){const e=i(this.cursorVertex),n=i(t),r=n&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(n)??n),s=this._snapToClosingVertex(r),o=this._applyConstraints(s);y(e,o)||(this._set("cursorVertex",o),this.segmentLabels?.set("stagedVertex",null!=o?this.coordinateHelper.pointToVector(o):null),null==o||"mouse"!==this._stagedPointerType?this.emit("cursor-remove"):this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activePart.vertices.length,coordinates:this.coordinateHelper.pointToArray(o)}],operation:"apply",type:"vertex-update"}))}_snapToClosingVertex(t){if(null==t||this._isDragging||"polygon"!==this.geometryType||this.numCommittedVertices<=2)return t;const e=this._mapToScreen(t);if(!e)return t;const i=this._activePart;return this._vertexWithinPointerDistance(i.vertices[0].pos,e)?this.firstVertex:this._vertexWithinPointerDistance(i.vertices.at(-1).pos,e)?this.lastVertex:t}_createManipulatorDragPipeline(t){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return P(t,(t,e,i,n)=>{const r="touch"===n&&this._snappingEnabled;if(this.isCompleted||!r)return;const{snappingStep:s,cancelSnapping:o}=H({predicate:()=>r,snappingManager:this.snappingManager,snappingContext:new I({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer,drawConstraints:this.constraints}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i.next(t=>(r&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),t)).next(o),e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._processCursor(t.mapStart),("segment"===this.geometryType||r&&!this.numCommittedVertices)&&this.commitStagedVertex()),t)).next(b(this.view,this.elevationInfo)).next(...s).next(t=>(r&&(this._processCursor(t.mapEnd),"end"===t.action&&this.commitStagedVertex()),t)).next(t=>("end"===t.action&&("mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t))})}_createManipulatorDragPipelineFreehand(t){return P(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),null==this.committableVertex&&this._processCursor(t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t})})}_createManipulatorDragPipelineHybrid(t){return P(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),this.addHandles(this._editGeometryOperations.createUndoGroup(),L),this._processCursor(t.mapStart),this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),this.removeHandles(L),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t})})}get _drawAtFixedElevation(){const{constraintsEnabled:t,constraintZ:e,geometryType:i,numCommittedVertices:n}=this;return t?null!=e||"segment"===i&&n>0:("segment"===i||"polygon"===i)&&n>0}_updateAndGetEffectiveDrawSurface(){const{constraintsEnabled:t,coordinateHelper:e,drawSurface:i,elevationDrawSurface:n,snapToSceneEnabled:r}=this;if(null==n)return i;if(!this.hasZ)return n.defaultZ=null,n;const s=this.elevationInfo?.mode;let o=this.defaultZ,a=t||"absolute-height"===s;if(null!=r&&(a=r),"on-the-ground"===s&&(a=!1),this._drawAtFixedElevation){o=(t?this.constraintZ:null)??e.getZ(this._activePart.vertices[0].pos),a=!1}return a?i:(n.defaultZ=o,n)}_mapToScreen(t){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&this._processCursor(t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if(!("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging))try{const{drawingMode:e,geometryType:i}=this;this._stagedPointerType=t.pointerType,this._stagedScreenPoint=t.screenPoint;const n=this._screenToMap(t.screenPoint);if(null==n)return;if(null==n||"freehand"===e&&"point"!==i&&"multipoint"!==i)return;if(this._snappingEnabled&&null!=this.cursorVertex||this._processCursor(n),null==this.committableVertex)return void this.complete();this.commitStagedVertex(),"mouse"!==t.pointerType&&this._processCursor(null),("freehand"===e&&"multipoint"!==this.geometryType||"point"===i||"segment"===i&&2===this.numCommittedVertices||"segment"===i&&"hybrid"===e&&1===this.numCommittedVertices)&&this.complete()}finally{t.stopPropagation()}}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=c(t.x,t.y);this._updatePointer(e,t.pointerId,t.pointerType)&&t.stopPropagation()}_updatePointer(t,e,i){return this._stagedScreenPoint=t,this._stagedPointerType=i,this._stagedPointerId=e,this._isDragging?(this._snappingOperation.abort(),!1):(this._processCursorMovementRelativeToSurface(t,i),!0)}_onKeyboardBasedChange(){"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._isDragging?this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType):this._snappingOperation.abort()}_processCursorMovementRelativeToSurface(t,e){const i=this._snappingOperation,n=this._screenToMap(t),r=this._requiresScenePoint?this.drawSurface?.screenToMap(t):null;if(null==n)return this._hideDefaultCursor=!0,this._processCursor(null),void i.abort();this._hideDefaultCursor=!1;const s=this.snappingManager;if(null==s)return this._processCursor(n),void i.abort();const a=this._getSnappingContext(e);this._updatingHandles.consumePromise(o(i.snap({point:n,scenePoint:r},s,a)))}_applyConstraints(t){const{_constraint:e,constraints:i}=this;if(!t||!i||!e)return t;const{context:n}=i,r=M(t,n),s=r?e.closestTo(r):void 0;if(!s)return t;const o=D(s,t,n),a="2d"===this.view.type||"absolute-height"!==n.elevationInfo.mode;return null!=o&&a&&null!=this.constraintZ&&this.hasZ&&(o.z=this.constraintZ),o}_screenToMap(t){return t?this._updateAndGetEffectiveDrawSurface()?.screenToMap(t):null}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),null==t)return null;const i=this._screenToMap(e.screenEnd);return null!=i?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return null!=n&&U(n,e,i)}_getSnappingContext(t){const e=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new I({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null,drawConstraints:this.constraints})}};function U(t,e,i){const n=t.x-e.x,r=t.y-e.y;return n*n+r*r<=i}t([d()],z.prototype,"_hideDefaultCursor",void 0),t([d()],z.prototype,"_stagedPointerId",void 0),t([d()],z.prototype,"_isDragging",null),t([d()],z.prototype,"_snappingOperation",void 0),t([d()],z.prototype,"_snappingEnabled",null),t([d({constructOnly:!0})],z.prototype,"graphic",void 0),t([d()],z.prototype,"constraintsEnabled",void 0),t([d()],z.prototype,"constraints",void 0),t([d()],z.prototype,"_constraint",null),t([d()],z.prototype,"constraintZ",void 0),t([d()],z.prototype,"defaultZ",void 0),t([d()],z.prototype,"isDraped",void 0),t([d({value:v})],z.prototype,"drawingMode",null),t([d({constructOnly:!0})],z.prototype,"elevationDrawSurface",void 0),t([d({constructOnly:!0})],z.prototype,"elevationInfo",void 0),t([d({constructOnly:!0,type:E})],z.prototype,"labelOptions",void 0),t([d({constructOnly:!0})],z.prototype,"geometryType",void 0),t([d({constructOnly:!0})],z.prototype,"hasM",void 0),t([d({constructOnly:!0})],z.prototype,"hasZ",void 0),t([d()],z.prototype,"cursor",void 0),t([d()],z.prototype,"effectiveCursor",null),t([d()],z.prototype,"loading",void 0),t([d({constructOnly:!0})],z.prototype,"manipulators",void 0),t([d({constructOnly:!0})],z.prototype,"drawSurface",void 0),t([d({constructOnly:!0})],z.prototype,"segmentLabels",void 0),t([d({constructOnly:!0})],z.prototype,"snappingManager",void 0),t([d({constructOnly:!0})],z.prototype,"snappingVisualizer",void 0),t([d()],z.prototype,"snapToSceneEnabled",void 0),t([d({readOnly:!0})],z.prototype,"cursorVertex",null),t([d({readOnly:!0})],z.prototype,"visualizationCursorVertex",null),t([d()],z.prototype,"committableVertex",null),t([d()],z.prototype,"firstVertex",void 0),t([d()],z.prototype,"lastVertex",void 0),t([d()],z.prototype,"secondToLastVertex",void 0),t([d()],z.prototype,"updating",null),t([d({constructOnly:!0})],z.prototype,"view",void 0),z=t([h("esri.views.draw.DrawOperation")],z);export{z as DrawOperation,k as defaultCursor,Z as defaultLoadingCursor};
2
+ import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{clone as i}from"../../core/lang.js";import{equalsMaybe as n,destroyMaybe as r}from"../../core/maybe.js";import{memoize as s}from"../../core/memoize.js";import{ignoreAbortErrors as o}from"../../core/promiseUtils.js";import a from"../../core/ReactiveSet.js";import{watch as p,syncAndInitial as l}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as d,subclass as h}from"../../core/accessorSupport/decorators.js";import{diff as u}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as m,pointNear as y}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as _}from"../../support/elevationInfoUtils.js";import{defaultDrawingMode as v}from"./drawingModes.js";import{LegacyDrawManipulator as f}from"./LegacyDrawManipulator.js";import{createCoordinateHelper as x}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as P,sceneSnappingAtLocation as b}from"../interactive/dragEventPipeline.js";import{EditGeometry as T,Part as S}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as C}from"../interactive/editGeometry/EditGeometryOperations.js";import{isPoint as V}from"../interactive/sketch/constraints.js";import{getPointConstraint as w,getPolylineOrPolygonConstraint as O,pointToConstraintSpace as M,constraintSpaceToPoint as D}from"../interactive/sketch/constraintUtils.js";import E from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as I}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as H}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as G}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as j}from"../interactive/snapping/snappingUtils.js";const k="crosshair",Z="progress",A=Symbol(),L=Symbol();let z=class extends e{constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new a,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this._stagedPointerId=null,this.constraintsEnabled=!1,this.constraints=void 0,this._getPointConstraint=s(w),this._getPolylineOrPolygonConstraint=s(O),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new E,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,null==t.elevationInfo&&(this.elevationInfo=_(!!t.hasZ))}initializePointer(){const t=this.view.inputManager?.latestPointerInfo;null!=t&&"touch"!==t.type&&this._updatePointer(t.location,t.id,t.type)}initialize(){const{geometryType:t,view:e}=this,i=e.spatialReference,r="viewingMode"in e.state?e.state.viewingMode:2,s="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=x(this.hasZ,this.hasM,i),this._editGeometryOperations=new C(new T(s,this.coordinateHelper),r),this._snappingOperation=new G({view:e}),this.addHandles([p(()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this._constraint}),({stagedPoint:t,constraint:e},i)=>{const{snappingOptions:n}=this;n&&(n.forceDisabled=null!=e&&V(e));if(null!=i&&t===i.stagedPoint&&e!==i.constraint)return this._onKeyboardBasedChange();this._processCursor(t??this._screenToMap(this._stagedScreenPoint))},{equals:(t,e)=>t.stagedPoint===e.stagedPoint&&n(t.constraint,e.constraint)}),p(()=>this.view.viewpoint,(t,e)=>{t&&e&&u(t,e)&&this._onKeyboardBasedChange()})]),this._activePart=new S(i,r),this._editGeometryOperations.data.parts.push(this._activePart);const a=this.segmentLabels;null!=a&&(a.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles(p(()=>this.labelOptions.enabled,t=>{a.visible=t},l))),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],t=>{const e=t.vertices.map(t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)})),i=e.map(t=>t.coordinates),n=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getFirstVertex()?.pos)??null;m(n,this.firstVertex)||(this.firstVertex=n);const r=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getLastVertex()?.pos)??null;m(r,this.lastVertex)||(this.lastVertex=r);const s=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.segments.at(-1)?.leftVertex?.pos)??null;switch(m(s,this.secondToLastVertex)||(this.secondToLastVertex=s),this._processCursor(this.cursorVertex),t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}}));const c=this._manipulator=new f({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(c),c.grabbable="point"!==t&&"multipoint"!==t,this.addHandles([c.events.on("immediate-click",t=>this._onImmediateClick(t)),c.events.on("immediate-double-click",t=>this._onImmediateDoubleClick(t)),p(()=>this.drawingMode,()=>{this.removeHandles(A),this.addHandles(this._createManipulatorDragPipeline(c),A)},l),p(()=>({effectiveCursor:this.effectiveCursor}),({effectiveCursor:t})=>{c.cursor=t},l)]),j(this,()=>{const t=this.view.inputManager.latestPointerInfo?.type??"mouse",e=this._getSnappingContext(t);if(null!=this.snappingManager){const t=this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e);this._updatingHandles.consumePromise(o(t))}})}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations),this._updatingHandles.destroy()}get _isDragging(){const{_stagedPointerId:t,_manipulator:e}=this;return null!=t&&this._pointerDownStates.has(t)||e.grabbing||!e.interactive}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const t=this._updateAndGetEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==t}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activePart.vertices.map(t=>this.coordinateHelper.vectorToArray(t.pos))}get _constraint(){const{constraints:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":case"multipoint":return this._getPointConstraint(t);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t)}}set drawingMode(t){this._set("drawingMode",t??v)}get effectiveCursor(){return this.loading?Z:this._hideDefaultCursor?null:this.cursor||k}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activePart.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get cursorVertex(){return this._get("cursorVertex")}get visualizationCursorVertex(){return"mouse"===this._stagedPointerType?this.cursorVertex:null}get committableVertex(){const{cursorVertex:t,lastVertex:e,firstVertex:i,geometryType:n}=this;return"polygon"===n&&y(t,i)||y(t,e)?null:t}get updating(){return this.loading||this._updatingHandles.updating||!!this.segmentLabels?.updating}get geometryIncludingUncommittedVertices(){const{committedVertices:t,committableVertex:e,coordinateHelper:i}=this,n=t.slice();return null!=e&&n.push(i.pointToArray(e)),n}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();const{committableVertex:t}=this;null!=t&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t),this._activePart)}complete(t){const e=t?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();const{geometryType:i,numCommittedVertices:n}=this,r="multipoint"===i&&0===n||"polyline"===i&&n<2||"polygon"===i&&n<3;"segment"!==i&&"point"!==i||this.commitStagedVertex(),this._createOperationCompleted=!r,(this.isCompleted||e)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit("complete",{vertices:this.committedVertices.map((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t})),aborted:e,type:"complete"}))}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(t){const e=i(this.cursorVertex),n=i(t),r=n&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(n)??n),s=this._snapToClosingVertex(r),o=this._applyConstraints(s);y(e,o)||(this._set("cursorVertex",o),this.segmentLabels?.set("stagedVertex",null!=o?this.coordinateHelper.pointToVector(o):null),null==o||"mouse"!==this._stagedPointerType?this.emit("cursor-remove"):this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activePart.vertices.length,coordinates:this.coordinateHelper.pointToArray(o)}],operation:"apply",type:"vertex-update"}))}_snapToClosingVertex(t){if(null==t||this._isDragging||"polygon"!==this.geometryType||this.numCommittedVertices<=2)return t;const e=this._mapToScreen(t);if(!e)return t;const i=this._activePart;return this._vertexWithinPointerDistance(i.vertices[0].pos,e)?this.firstVertex:this._vertexWithinPointerDistance(i.vertices.at(-1).pos,e)?this.lastVertex:t}_createManipulatorDragPipeline(t){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return P(t,(t,e,i,n)=>{const r="touch"===n&&this._snappingEnabled;if(this.isCompleted||!r)return;const{snappingStep:s,cancelSnapping:o}=H({predicate:()=>r,snappingManager:this.snappingManager,snappingContext:new I({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer,drawConstraints:this.constraints}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i.next(t=>(r&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),t)).next(o),e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._processCursor(t.mapStart),("segment"===this.geometryType||r&&!this.numCommittedVertices)&&this.commitStagedVertex()),t)).next(b(this.view,this.elevationInfo)).next(...s).next(t=>(r&&(this._processCursor(t.mapEnd),"end"===t.action&&this.commitStagedVertex()),t)).next(t=>("end"===t.action&&("mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t))})}_createManipulatorDragPipelineFreehand(t){return P(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),null==this.committableVertex&&this._processCursor(t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t})})}_createManipulatorDragPipelineHybrid(t){return P(t,(t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next(t=>("start"===t.action&&(this._snappingOperation.abort(),this.addHandles(this._editGeometryOperations.createUndoGroup(),L),this._processCursor(t.mapStart),this.commitStagedVertex()),t)).next(t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),this.removeHandles(L),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t})})}get _drawAtFixedElevation(){const{constraintsEnabled:t,constraintZ:e,geometryType:i,numCommittedVertices:n}=this;return t?null!=e||"segment"===i&&n>0:("segment"===i||"polygon"===i)&&n>0}_updateAndGetEffectiveDrawSurface(){const{constraintsEnabled:t,coordinateHelper:e,drawSurface:i,elevationDrawSurface:n,snapToSceneEnabled:r}=this;if(null==n)return i;if(!this.hasZ)return n.defaultZ=null,n;const s=this.elevationInfo?.mode;let o=this.defaultZ,a=t||"absolute-height"===s;if(null!=r&&(a=r),"on-the-ground"===s&&(a=!1),this._drawAtFixedElevation){o=(t?this.constraintZ:null)??e.getZ(this._activePart.vertices[0].pos),a=!1}return a?i:(n.defaultZ=o,n)}_mapToScreen(t){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&this._processCursor(t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if(!("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging))try{const{drawingMode:e,geometryType:i}=this;this._stagedPointerType=t.pointerType,this._stagedScreenPoint=t.screenPoint;const n=this._screenToMap(t.screenPoint);if(null==n)return;if(null==n||"freehand"===e&&"point"!==i&&"multipoint"!==i)return;if(this._snappingEnabled&&null!=this.cursorVertex||this._processCursor(n),null==this.committableVertex)return void this.complete();this.commitStagedVertex(),"mouse"!==t.pointerType&&this._processCursor(null),("freehand"===e&&"multipoint"!==this.geometryType||"point"===i||"segment"===i&&2===this.numCommittedVertices||"segment"===i&&"hybrid"===e&&1===this.numCommittedVertices)&&this.complete()}finally{t.stopPropagation()}}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=c(t.x,t.y);this._updatePointer(e,t.pointerId,t.pointerType)&&t.stopPropagation()}_updatePointer(t,e,i){return this._stagedScreenPoint=t,this._stagedPointerType=i,this._stagedPointerId=e,this._isDragging?(this._snappingOperation.abort(),!1):(this._processCursorMovementRelativeToSurface(t,i),!0)}_onKeyboardBasedChange(){"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._isDragging?this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType):this._snappingOperation.abort()}_processCursorMovementRelativeToSurface(t,e){const i=this._snappingOperation,n=this._screenToMap(t),r=this._requiresScenePoint?this.drawSurface?.screenToMap(t):null;if(null==n)return this._hideDefaultCursor=!0,this._processCursor(null),void i.abort();this._hideDefaultCursor=!1;const s=this.snappingManager;if(null==s)return this._processCursor(n),void i.abort();const a=this._getSnappingContext(e);this._updatingHandles.consumePromise(o(i.snap({point:n,scenePoint:r},s,a)))}_applyConstraints(t){const{_constraint:e,constraints:i}=this;if(!t||!i||!e)return t;const{context:n}=i,r=M(t,n),s=r?e.closestTo(r):void 0;if(!s)return t;const o=D(s,t,n),a="2d"===this.view.type||"absolute-height"!==n.elevationInfo.mode;return null!=o&&a&&null!=this.constraintZ&&this.hasZ&&(o.z=this.constraintZ),o}_screenToMap(t){return t?this._updateAndGetEffectiveDrawSurface()?.screenToMap(t):null}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),null==t)return null;const i=this._screenToMap(e.screenEnd);return null!=i?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return null!=n&&U(n,e,i)}_getSnappingContext(t){const e=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new I({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null,drawConstraints:this.constraints})}};function U(t,e,i){const n=t.x-e.x,r=t.y-e.y;return n*n+r*r<=i}t([d()],z.prototype,"_hideDefaultCursor",void 0),t([d()],z.prototype,"_stagedPointerId",void 0),t([d()],z.prototype,"_isDragging",null),t([d()],z.prototype,"_snappingOperation",void 0),t([d()],z.prototype,"_snappingEnabled",null),t([d({constructOnly:!0})],z.prototype,"graphic",void 0),t([d()],z.prototype,"constraintsEnabled",void 0),t([d()],z.prototype,"constraints",void 0),t([d()],z.prototype,"_constraint",null),t([d()],z.prototype,"constraintZ",void 0),t([d()],z.prototype,"defaultZ",void 0),t([d()],z.prototype,"isDraped",void 0),t([d({value:v})],z.prototype,"drawingMode",null),t([d({constructOnly:!0})],z.prototype,"elevationDrawSurface",void 0),t([d({constructOnly:!0})],z.prototype,"elevationInfo",void 0),t([d({constructOnly:!0,type:E})],z.prototype,"labelOptions",void 0),t([d({constructOnly:!0})],z.prototype,"geometryType",void 0),t([d({constructOnly:!0})],z.prototype,"hasM",void 0),t([d({constructOnly:!0})],z.prototype,"hasZ",void 0),t([d()],z.prototype,"cursor",void 0),t([d()],z.prototype,"effectiveCursor",null),t([d()],z.prototype,"loading",void 0),t([d({constructOnly:!0})],z.prototype,"manipulators",void 0),t([d({constructOnly:!0})],z.prototype,"drawSurface",void 0),t([d({constructOnly:!0})],z.prototype,"segmentLabels",void 0),t([d({constructOnly:!0})],z.prototype,"snappingManager",void 0),t([d({constructOnly:!0})],z.prototype,"snappingVisualizer",void 0),t([d()],z.prototype,"snapToSceneEnabled",void 0),t([d({readOnly:!0})],z.prototype,"cursorVertex",null),t([d({readOnly:!0})],z.prototype,"visualizationCursorVertex",null),t([d()],z.prototype,"committableVertex",null),t([d()],z.prototype,"firstVertex",void 0),t([d()],z.prototype,"lastVertex",void 0),t([d()],z.prototype,"secondToLastVertex",void 0),t([d()],z.prototype,"updating",null),t([d({constructOnly:!0})],z.prototype,"view",void 0),z=t([h("esri.views.draw.DrawOperation")],z);export{z as DrawOperation,k as defaultCursor,Z as defaultLoadingCursor};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__addDisposableResource as e,__disposeResources as t,__decorate as i}from"tslib";import{createTask as n}from"../../core/asyncUtils.js";import{makeHandle as a,disposable as s}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{destroyMaybe as l,abortMaybe as d}from"../../core/maybe.js";import{ignoreAbortErrors as p}from"../../core/promiseUtils.js";import{when as u,initial as c,watch as h,syncAndInitial as g,on as m,sync as v}from"../../core/reactiveUtils.js";import{screenPointEqual as y,createScreenPoint as f}from"../../core/screenUtils.js";import{diff as M}from"../../core/accessorSupport/diffUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as S}from"../../core/support/UpdatingHandles.js";import w from"../../geometry/Polygon.js";import{i as C,e as P}from"../../chunks/simplifyOperator.js";import{isPolygon as x}from"../../geometry/support/typeUtils.js";import{isCurvedGeometry as H}from"../../geometry/support/curves/curveUtils.js";import{densifyCurvedGeometry as L}from"../../geometry/support/curves/densifyCurvedGeometry.js";import{getEffectiveElevationInfo as k}from"../../support/elevationInfoUtils.js";import{getMaxDeviationInPixels as I,getMinSegmentsPerCurve as O}from"../2d/layers/graphics/densificationConstants.js";import{createSnappingVisualizer as V}from"./support/createSnappingVisualizer.js";import{multipointFromGeometry as G,markHandled as T,getPointerType as j}from"./support/drawToolUtils.js";import{PluginContext as E}from"./support/PluginContext.js";import{viewEventToCommand as D}from"./support/input/drawToolInput.js";import{EditSessionManager as U}from"./support/managers/EditSessionManager.js";import{GlobalStateManager as A}from"./support/managers/GlobalStateManager.js";import{InteractiveHandleManager as F}from"./support/managers/InteractiveHandleManager.js";import{MeasurementManager as R}from"./support/managers/MeasurementManager.js";import{PluginLifecycleManager as Z}from"./support/managers/PluginLifecycleManager.js";import{SurfaceManager as B}from"./support/managers/SurfaceManager.js";import{TooltipManager as q}from"./support/managers/TooltipManager.js";import{ViewEventPriorities as z}from"../input/InputManager.js";import{createCoordinateHelper as K}from"../interactive/coordinateHelper.js";import{InteractiveToolBase as N}from"../interactive/InteractiveToolBase.js";import{KeyBindings as Q,mediaKeys as W,sketchKeys as $,advancedSketchKeys as J,tooltipKeys as X}from"../interactive/keybindings.js";import{isInputModeAvailable as Y}from"../interactive/tooltip/tooltipCommonUtils.js";const ee=Symbol();let te=class extends N{constructor(e){super(e),this._shapeVisualId=Symbol(),this._vertexVisualId=Symbol(),this._pluginContexts=new Map,this._queuedFeedbackEvents=[],this._flushingQueuedFeedbackEvents=!1,this._commandsSuspended=!1,this._snappingVisualizer=null,this._segmentLabels=null,this._segmentLabelsImportTask=null,this._updatingHandles=new S,this._keybindings=this._makeKeyBindings(),this._pendingBeginRequest=null,this.type="draw-2.0",this.automaticManipulatorSelection=!0,this.snappingManager=null,this.sketchOptions=null,this.elevationInfo=null,this.hasZ=!1,this.defaultZ=0,this.lastScreenPosition=null,this.measurementManager=new R,this.globalStateManager=new A({getPluginStack:()=>this.pluginStack}),this.editSessionManager=new U({getContext:()=>this._editSessionManagerContext}),this.lifecycleManager=new Z({getContext:this._getContextForPlugin.bind(this),editSessionManager:this.editSessionManager,afterAttach:this._afterAttach.bind(this),afterDetach:this._afterDetach.bind(this),beforeResume:this._beforeResume.bind(this)}),this.surfaceManager=null,this.interactiveHandleManager=null,this.renderer=null,this.readPluginSetting=null,this.enableVertexVisuals=!0}initialize(){const{view:e}=this;this.interactiveHandleManager=new F({view:e,renderer:this.renderer}),this._override("manipulators",this.interactiveHandleManager.manipulators),this.tooltipManager=new q({getDependencies:()=>this._tooltipDependencies,getLastScreenPosition:()=>this.lastScreenPosition}),this.addHandles(u(()=>this.renderer,t=>{t.addOrUpdateVisual(this._shapeVisualId,{role:"outputGeometry"}),t.addOrUpdateVisual(this._vertexVisualId,{role:"vertex"}),this._updatingHandles.addPromise(V(e,t).then(e=>this._snappingVisualizer=e))},c)),this.addHandles([h(()=>[this.view,this.coordinateHelper.spatialReference,this.defaultZ,this.hasZ,this.elevationInfo],([e,t,i,n,a])=>{this.surfaceManager?.destroy(),this.surfaceManager=new B({spatialReference:t,excludedGraphicsLayer:null,defaultZ:i,hasZ:n,view:e,elevationInfo:a,getContext:()=>({drawAtFixedElevation:this.globalStateManager.drawAtFixedElevation,elevationConstraint:this.tooltipManager?.elevationConstraint,constraintsEnabled:this.tooltipManager?.constraintsEnabled??!1})})},g),u(()=>this.sketchOptions?.tooltips.effectiveEnabled,()=>this.measurementManager.preloadMeasurementUtils(),{once:!0,initial:!0}),h(()=>[this.editGeometryOperations,this.sketchOptions?.labels.enabled,this.globalStateManager.segmentLabelsDisabled],()=>{this._updatingHandles.addPromise(this._setupSegmentLabels())},c),m(()=>this.editSessionManager,"cancelPlugin",({plugin:e})=>{this._suspendPlugin(e)},v),m(()=>this.editSessionManager,"restartPlugin",({restartInfo:e})=>{this._resumePlugin(e)},v),h(()=>this.lifecycleManager.updating,e=>{e||this._emitQueuedFeedbackEvents()},v),m(()=>this.editGeometryOperations,["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._emitWhenReady(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this._emitWhenReady(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this._emitWhenReady(e.type,{...e,removed:i,vertices:t})}})])}destroy(){this.active&&this.onDeactivate(),this.editSessionManager.destroy(),this.lifecycleManager.destroy(),this.measurementManager.destroy(),this.globalStateManager.destroy();for(const e of this._pluginContexts.values())e.destroy();this._pluginContexts.clear(),this.surfaceManager=l(this.surfaceManager),this.interactiveHandleManager=l(this.interactiveHandleManager),this._segmentLabelsImportTask=d(this._segmentLabelsImportTask),this._segmentLabels=l(this._segmentLabels),this.tooltipManager=l(this.tooltipManager)}get _zOfLastUserInput(){const e=this.mostDownstreamPlugin&&this.editSessionManager.getSession(this.mostDownstreamPlugin),t=e?.firstPointAddedBySession?.point;return t?.hasZ?t.z:null}get _tooltipDependencies(){const{defaultZ:e,editGeometryOperations:t,sketchOptions:i,directionOptions:n,elevationInfo:a,view:s}=this;return t&&i&&s?{defaultZ:e,directionOptions:n,elevationInfo:a,editGeometryOperations:t,sketchOptions:i,view:s,getActiveHandle:()=>this.interactiveHandleManager?.focusedHandle,getAllHandles:()=>this.interactiveHandleManager?.allhandles,getHelpMessageKey:()=>this.helpMessageKey,notifyTooltipsChanged:()=>{const{interactiveHandleManager:e,movementCommandContext:t}=this;e&&t&&e.reapplyPositions(t)}}:null}get _editSessionManagerContext(){const{coordinateHelper:e,view:t}=this;if(!t)return null;return{coordinateHelper:e,viewingMode:"3d"===t.type&&"global"===t.viewingMode?1:2}}get _densificationParameters(){const{view:e,coordinateHelper:t}=this,i=t.spatialReference,n=e?.spatialReference,a=e.resolution;if(!(i&&n&&a&&Number.isFinite(a)))return null;const s=n.metersPerUnit/i.metersPerUnit;return{maxDeviation:2**Math.round(Math.log2(a))*I()*s,minSegmentsPerCurve:O()}}get test(){return{densificationParameters:this._densificationParameters,segmentLabels:this._segmentLabels}}get updating(){return this._updatingHandles.updating||this.snappingManager?.updating||this.lifecycleManager.updating||!!this._segmentLabels?.updating}get coordinateHelper(){return K(this.hasZ,!1,this.view.spatialReference)}get editGeometry(){return this.editGeometryOperations?.data}get editGeometryOperations(){return this.editSessionManager.editGeometryOperations}get unprocessedGeometry(){return this.editSessionManager.outputGeometry}get simplifiedGeometryPreview(){const e=this.editSessionManager.outputGeometry;if(e&&x(e))try{const t=this._densificationParameters,i=H(e)&&t?new w({...L(e,t)}):e;if(!C(i))return P(i)}catch(t){return e}return e}get _suppressCoincidentPointOverlaysIn3D(){return"3d"===this.view.type&&"point"===this.unprocessedGeometry?.type&&!!this.interactiveHandleManager?.allhandles?.find(e=>"primary"===e.role)?.outputMapPosition}get _shapeVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.simplifiedGeometryPreview}get _vertexVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.unprocessedGeometry}get canUndo(){return this.editSessionManager.canUndo}get canRedo(){return this.editSessionManager.canRedo}get pluginStack(){return this.lifecycleManager.pluginStack}get mostDownstreamPlugin(){return this.pluginStack.at(-1)}get mostUpstreamPlugin(){return this.pluginStack.at(0)}get positionOfLastUserInput(){const e=this.lastScreenPosition;return e?this.surfaceManager?.screenToMap(e,{firstPointZ:this._zOfLastUserInput})??this.view.toMap(e):this.view.center}get movementCommandContext(){const{editGeometryOperations:e,tooltipManager:t,surfaceManager:i,snappingManager:n,interactiveHandleManager:a,_snappingVisualizer:s,defaultZ:r,hasZ:o,globalStateManager:{drawAtFixedElevation:l},view:d}=this;return{tooltipManager:t,editGeometryOperations:e,surfaceManager:i,interactiveHandleManager:a,snappingManager:n,snappingVisualizer:s,pointerType:"mouse",hasZ:o,defaultZ:r,view:d,drawAtFixedElevation:l}}get tooltip(){return this.tooltipManager?.tooltip}get activeTooltipInfo(){return this.tooltipManager?.tooltipInfo}get helpMessageKey(){return this.pluginStack.items.findLast(e=>e.helpMessageKey)?.helpMessageKey??"noTool"}begin(e){this.active?(this.lifecycleManager.begin(e),this._pendingBeginRequest=null):this._pendingBeginRequest=e}complete(e){const t=this.lifecycleManager;if(e&&t.complete(e),0===t.pluginStack.length){const e=this.unprocessedGeometry,t=!e||"mesh"===e.type||C(e);this.emit("complete",{geometry:e,isSimple:t,aborted:!1,type:"complete",vertices:[]}),this.view?.activeTool===this&&(this.view.activeTool=null)}}cancelFirstUserLeafPlugin(){const e=this.pluginStack.toArray().findLast(e=>!0!==e.configuration?.hidden);e&&this.lifecycleManager.cancel(e)}getVertexSnappingCandidates(){return"secondary"===this.interactiveHandleManager?.capturingHandle?.role?[]:this.snappingManager?.getVertexCandidates()??[]}replaceLeaf(e){const t=this.lifecycleManager;t.updating?r.getLogger(this).info("Ignoring command; arrived while updating:","replaceLeaf"):t.replaceLeaf(e)}finishPart(){const e=this.mostUpstreamPlugin,t=e?.configuration;if(this.editGeometryOperations&&t&&t.kind?.includes("multipart")){const e=this.pluginStack.at(1);e&&this.complete(e)}}undo(){this._handleCommand({action:"undo"})}redo(){this._handleCommand({action:"redo"})}executeCommand(e){return this._handleCommand(e)}suspendCommands(){return this._commandsSuspended=!0,a(()=>{this._commandsSuspended=!1;const e=this.view?.inputManager.latestPointerInfo;if(e){const{x:t,y:i}=e.location;this._handleCommand({action:"manipulator-move-to",x:t,y:i})}})}addPromise(e){return this._updatingHandles.addPromise(e)}readPluginSettingValue(e,t){return this.readPluginSetting?.(e,t)}getGeometryIfCompleted(){const e=this.lifecycleManager.gatherCompletablePlugins();return this.editSessionManager?.generatePreviewGeometryForPlugins(e)}onActivate(){super.onActivate();const{view:e}=this;this.lastScreenPosition=e?.inputManager.latestPointerInfo?.location,this.renderer?.activate(),this._pendingBeginRequest&&(this.begin(this._pendingBeginRequest),this._pendingBeginRequest=null),this.enableVertexVisuals&&this.addHandles(h(()=>this._vertexVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._vertexVisualId,{geometry:e?G(e):null})},c)),this.addHandles([h(()=>this._shapeVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._shapeVisualId,{geometry:e})},c),u(()=>this.interactiveHandleManager?.capturingHandle?.screenPosition,e=>this.lastScreenPosition=e,{initial:!0,equals:y}),h(()=>this.interactiveHandleManager?.capturingHandle?.outputMapPosition,(e,t)=>{const i=this.interactiveHandleManager?.capturingHandle?.editSession?.endVertex;e&&t&&i&&this._emitWhenReady("cursor-update",{updated:i.pos,type:"vertex-update",operation:"apply",vertices:[{componentIndex:i.part.index,vertexIndex:i.index,coordinates:i.pos}]})},v),this._keybindings.register(e,z.TOOL),h(()=>e.viewpoint,(e,t)=>{e&&t&&M(e,t)&&this._handleCommand({action:"viewpoint-moved"})})],ee)}onDeactivate(){super.onDeactivate(),this.removeHandles(ee),this.renderer?.deactivate(),this.snappingManager?.doneSnapping(),this.lifecycleManager.cancelAll(),this._pendingBeginRequest=null}onInputEvent(e){const t=D(e);t&&this._handleCommand(t)}forceAddVertex(){this._commitNext()}_emitWhenReady(e,t){if(this.destroyed)return;const i=()=>{this.emit(e,t)};this.lifecycleManager.updating||this._flushingQueuedFeedbackEvents?this._queuedFeedbackEvents.push(i):i()}_emitQueuedFeedbackEvents(){if(!(this.destroyed||this._flushingQueuedFeedbackEvents||this.lifecycleManager.updating||0===this._queuedFeedbackEvents.length)){this._flushingQueuedFeedbackEvents=!0;try{for(;!this.destroyed&&!this.lifecycleManager.updating&&this._queuedFeedbackEvents.length>0;)this._queuedFeedbackEvents.shift()?.()}finally{this._flushingQueuedFeedbackEvents=!1}}}async _handleCommand(e){if(!this._commandsSuspended)if(this.lifecycleManager.updating)r.getLogger(this).info("Ignoring command; arrived while updating:",e.action);else switch(e.action){case"view-drag":return await this._handleViewDragCommand(e);case"vertex-add":return this._guardCommand(e,()=>{T(e),this._commitNext()});case"vertex-add-and-finish-part":return this._handleVertexAddAndFinishPartCommand(e);case"cancel":return this._guardCommand(e,()=>this.cancel());case"complete":return this._guardCommand(e,()=>{this.mostUpstreamPlugin&&(T(e),this.complete(this.mostUpstreamPlugin))});case"finish-part":return this._guardCommand(e,()=>this.finishPart());case"undo":return this._guardCommand(e,()=>this.editSessionManager.undo());case"redo":return this._guardCommand(e,()=>this.editSessionManager.redo());case"next-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("forward"));case"previous-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("backward"));case"toggle-manipulator-follow":this.interactiveHandleManager?.toggleFollow()&&T(e);break;case"viewpoint-moved":return await this._handleViewpointMovedCommand(e);case"manipulator-move-to":return await this._handleManipulatorMoveToCommand(e);case"manipulator-drag-to":return await this._handleManipulatorDragToCommand(e);case"vertex-add-at-point":return await this._handleVertexAddAtPointCommand(e);case"show-tooltip":return this._guardCommand(e,async()=>{const t=this.tooltipManager?.tooltip;t&&Y(t.info)&&(await t.enterInputMode(),T(e))});case"constraint-center":this.globalStateManager.setCentered(e.enabled);break;case"constraint-aspect":this.globalStateManager.setPreserveAspectRatio(e.enabled)}}async _handleViewDragCommand(e){if(!this.editable)return;const t=e.originalEvent,i=this.interactiveHandleManager?.capturingHandle;(!t||!("pointerType"in t)||"touch"!==t.pointerType||"capture-always"!==i?.captureMode&&"capture-when-engaged"!==i?.captureMode)&&"capture-when-engaged"!==this.interactiveHandleManager?.capturingHandle?.captureMode?this._before(e)&&T(e):T(e)}_handleVertexAddAndFinishPartCommand(e){this._before(e)||(T(e),this._commitNext(),this.finishPart())}async _handleViewpointMovedCommand(e){this.editable&&(await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(null,{...this.movementCommandContext,pointerType:j(e.originalEvent)})),this.interactiveHandleManager?.updateAllScreenPositions(this.movementCommandContext.surfaceManager))}async _handleManipulatorMoveToCommand(e){if(!this.editable)return;const t=this._updateLastScreenPosition(e);this.interactiveHandleManager?.capturingHandle&&T(e),await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(t,{...this.movementCommandContext,pointerType:j(e.originalEvent)}))}async _handleManipulatorDragToCommand(e){if(!this.editable)return;const t=j(e.originalEvent),i=this._updateLastScreenPosition(e),n=this.interactiveHandleManager?.findHandleByManipulator(i,t);"touch"===t&&n&&"start"===e.state&&this.interactiveHandleManager?.releaseHandle();const a=this.interactiveHandleManager?.findHandleDragging(),s=this.interactiveHandleManager?.capturingHandle,r=a??s??n;r&&!n&&T(e),"capture-when-engaged"===r?.captureMode||"capture-always"===r?.captureMode&&"touch"===t?"end"===e.state?await this._updatingHandles.addPromise(r.noteDragEnd(i,{...this.movementCommandContext,pointerType:t}).then(()=>{r&&"touch"===j(e.originalEvent)&&"grabbable-object"!==r.captureMode&&"capture-when-engaged"!==r.defaultCaptureMode&&"primary"===r.role&&(1===this.interactiveHandleManager?.handleCount?this._handleCommand({action:"vertex-add"}):this.interactiveHandleManager?.releaseHandle())})):"start"===e.state?await this._updatingHandles.addPromise(r.noteDragStart(i,{...this.movementCommandContext,pointerType:t}).then(()=>{r&&"touch"===j(e.originalEvent)&&"grabbable-object"!==r.captureMode&&"capture-when-engaged"!==r.defaultCaptureMode&&!r.editSession?.lastPointAddedBySession&&this._handleCommand({action:"vertex-add"})})):await this._updatingHandles.addPromise(r?.moveTo(i,{...this.movementCommandContext,pointerType:j(e.originalEvent)})):"grabbable-object"===r?.captureMode&&(this.interactiveHandleManager?.releaseHandle(s),await this._updatingHandles.addPromise(r.moveTo(i,{...this.movementCommandContext,pointerType:t})))}async _handleVertexAddAtPointCommand(e){const t=this._updateLastScreenPosition(e),i=j(e.originalEvent),n=this.interactiveHandleManager?.capturingHandle??this.interactiveHandleManager?.findHandleByManipulator(t,i);this.editable&&n&&(this._before(e)||(T(e),await this._updatingHandles.addPromise(n.moveTo(t,{...this.movementCommandContext,skipSnapping:!0,pointerType:i}).finally(()=>this._commitNext()))))}_makeKeyBindings(){const e=new Q,t=(t,i)=>{e.addToggle(t,e=>this._handleCommand({action:i,originalEvent:e,enabled:"key-down"===e.type}))},i=(t,i)=>{e.add(t,e=>this._handleCommand({action:i,originalEvent:e}))};return t(W.preserveAspectRatio,"constraint-aspect"),t($.center,"constraint-center"),i(J.toggleFollowManipulator,"toggle-manipulator-follow"),i($.undo,"undo"),i($.redo,"redo"),i($.complete,"complete"),i($.vertexAdd,"vertex-add"),i({key:X.enterInputMode,continuePropagation:!0,repeats:!0},"show-tooltip"),e}_afterAttach(){}_afterDetach(e){this.interactiveHandleManager?.unregisterCustomConstraint(e),this.interactiveHandleManager?.unregisterHandle(e),this.tooltipManager?.unregisterPluginFields(e),this.globalStateManager.clearPluginOverrides(e);const t=this._pluginContexts.get(e);t&&(t.destroy(),this._pluginContexts.delete(e))}_beforeResume(e,t){this.interactiveHandleManager?.replaceEditSessions(e,t)}_commitNext(){const i={stack:[],error:void 0,hasError:!1};try{const t=this.mostDownstreamPlugin;if(!t)return;this.tooltipManager?.storeConstraintSnapshot();let n=!1;const a=this.editGeometryOperations;e(i,a?s(a.on("vertex-add",()=>n=!0)):null,!1);t.completeStep?t.completeStep():this.complete(t),n&&this.tooltipManager?.unlockOnVertexPlacement()}catch(n){i.error=n,i.hasError=!0}finally{t(i)}}_suspendPlugin(e){this.lifecycleManager.suspend(e),this.measurementManager.suspendPlugin(e)}_resumePlugin(e){this.lifecycleManager.resume(e)}_updateLastScreenPosition(e){const t=f(e.x,e.y);return this.lastScreenPosition=t,t}_getContextForPlugin(e,t){const i=o(this._pluginContexts,e,()=>new E({drawTool:this,plugin:e,session:t}));return i.session=t,i}_before(e){if(!this.hasEventListener(`before-${e.action}`))return!1;const t=new CustomEvent(`before-${e.action}`,{detail:e,cancelable:!0});return this.emit(`before-${e.action}`,t),t.defaultPrevented}_guardCommand(e,t,i){return this._before(e)?i?.():t()}async _setupSegmentLabels(){const e=this.editGeometryOperations,t=this.sketchOptions?.labels,i=!!t?.enabled,n=this.globalStateManager.segmentLabelsDisabled;if(!e||!t||!i)return void(this._segmentLabels=l(this._segmentLabels));if(n)return void(this._segmentLabels&&(this._segmentLabels.visible=!1));if(this._segmentLabels?.context?.editGeometryOperations===e&&this._segmentLabels.context.labelOptions===t)return void(this._segmentLabels.visible=!0);const a=await this._createSegmentLabels(e,t);a&&(this._segmentLabels=l(this._segmentLabels),this._segmentLabels=a)}async _createSegmentLabels(e,t){this._segmentLabelsImportTask?.abort();const i=this._segmentLabelsImportTask=n(async i=>{if("3d"===this.view.type){const n=import("../3d/interactive/SegmentLabels3D.js"),{SegmentLabels3D:a}=await this._updatingHandles.addPromise(n);return this._isSegmentLabelsSetupStale(i,e,t)?null:new a({context:{view:this.view,editGeometryOperations:e,elevationInfo:k(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})}const n=import("../2d/interactive/SegmentLabels2D.js"),{SegmentLabels2D:a}=await this._updatingHandles.addPromise(n);return this._isSegmentLabelsSetupStale(i,e,t)?null:new a({context:{view:this.view,editGeometryOperations:e,elevationInfo:k(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})});return p(i.promise)}_isSegmentLabelsSetupStale(e,t,i){return e.aborted||this.editGeometryOperations!==t||this.sketchOptions?.labels!==i||!i.enabled||this.globalStateManager.segmentLabelsDisabled}};i([_()],te.prototype,"_commandsSuspended",void 0),i([_()],te.prototype,"_zOfLastUserInput",null),i([_()],te.prototype,"_snappingVisualizer",void 0),i([_()],te.prototype,"_segmentLabels",void 0),i([_()],te.prototype,"_segmentLabelsImportTask",void 0),i([_()],te.prototype,"_tooltipDependencies",null),i([_()],te.prototype,"_editSessionManagerContext",null),i([_()],te.prototype,"_densificationParameters",null),i([_({constructOnly:!0,nonNullable:!0})],te.prototype,"view",void 0),i([_()],te.prototype,"automaticManipulatorSelection",void 0),i([_()],te.prototype,"updating",null),i([_()],te.prototype,"coordinateHelper",null),i([_()],te.prototype,"editGeometry",null),i([_()],te.prototype,"editGeometryOperations",null),i([_()],te.prototype,"unprocessedGeometry",null),i([_()],te.prototype,"simplifiedGeometryPreview",null),i([_()],te.prototype,"_suppressCoincidentPointOverlaysIn3D",null),i([_()],te.prototype,"_shapeVisualGeometry",null),i([_()],te.prototype,"_vertexVisualGeometry",null),i([_()],te.prototype,"snappingManager",void 0),i([_()],te.prototype,"sketchOptions",void 0),i([_()],te.prototype,"elevationInfo",void 0),i([_()],te.prototype,"hasZ",void 0),i([_()],te.prototype,"defaultZ",void 0),i([_()],te.prototype,"directionOptions",void 0),i([_()],te.prototype,"canUndo",null),i([_()],te.prototype,"canRedo",null),i([_()],te.prototype,"pluginStack",null),i([_()],te.prototype,"mostDownstreamPlugin",null),i([_()],te.prototype,"mostUpstreamPlugin",null),i([_()],te.prototype,"lastScreenPosition",void 0),i([_()],te.prototype,"positionOfLastUserInput",null),i([_()],te.prototype,"tooltipManager",void 0),i([_()],te.prototype,"measurementManager",void 0),i([_()],te.prototype,"globalStateManager",void 0),i([_()],te.prototype,"editSessionManager",void 0),i([_()],te.prototype,"lifecycleManager",void 0),i([_()],te.prototype,"surfaceManager",void 0),i([_()],te.prototype,"interactiveHandleManager",void 0),i([_()],te.prototype,"renderer",void 0),i([_()],te.prototype,"readPluginSetting",void 0),i([_()],te.prototype,"movementCommandContext",null),i([_()],te.prototype,"tooltip",null),i([_()],te.prototype,"activeTooltipInfo",null),i([_()],te.prototype,"helpMessageKey",null),i([_({constructOnly:!0})],te.prototype,"enableVertexVisuals",void 0),te=i([b("esri.views.draw.DrawTool")],te);export{te as DrawTool};
2
+ import{__addDisposableResource as e,__disposeResources as t,__decorate as i}from"tslib";import{createTask as n}from"../../core/asyncUtils.js";import{makeHandle as a,disposable as s}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{destroyMaybe as l,abortMaybe as d}from"../../core/maybe.js";import{ignoreAbortErrors as p}from"../../core/promiseUtils.js";import{when as u,initial as c,watch as h,syncAndInitial as g,on as m,sync as v}from"../../core/reactiveUtils.js";import{screenPointEqual as y,createScreenPoint as f}from"../../core/screenUtils.js";import{diff as M}from"../../core/accessorSupport/diffUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as w}from"../../core/support/UpdatingHandles.js";import S from"../../geometry/Polygon.js";import{i as C,e as P}from"../../chunks/simplifyOperator.js";import{isPolygon as H}from"../../geometry/support/typeUtils.js";import{isCurvedGeometry as x}from"../../geometry/support/curves/curveUtils.js";import{densifyCurvedGeometry as I}from"../../geometry/support/curves/densifyCurvedGeometry.js";import{getEffectiveElevationInfo as L}from"../../support/elevationInfoUtils.js";import{getMaxDeviationInPixels as O,getMinSegmentsPerCurve as k}from"../2d/layers/graphics/densificationConstants.js";import{createSnappingVisualizer as T}from"./support/createSnappingVisualizer.js";import{multipointFromGeometry as V,markHandled as G,getPointerType as j,getPointerId as E}from"./support/drawToolUtils.js";import{PluginContext as D}from"./support/PluginContext.js";import{viewEventToCommand as U}from"./support/input/drawToolInput.js";import{EditSessionManager as A}from"./support/managers/EditSessionManager.js";import{GlobalStateManager as F}from"./support/managers/GlobalStateManager.js";import{InteractiveHandleManager as R}from"./support/managers/InteractiveHandleManager.js";import{MeasurementManager as Z}from"./support/managers/MeasurementManager.js";import{PluginLifecycleManager as B}from"./support/managers/PluginLifecycleManager.js";import{SurfaceManager as q}from"./support/managers/SurfaceManager.js";import{TooltipManager as z}from"./support/managers/TooltipManager.js";import{ViewEventPriorities as K}from"../input/InputManager.js";import{createCoordinateHelper as N}from"../interactive/coordinateHelper.js";import{InteractiveToolBase as Q}from"../interactive/InteractiveToolBase.js";import{KeyBindings as W,mediaKeys as $,sketchKeys as J,advancedSketchKeys as X,tooltipKeys as Y}from"../interactive/keybindings.js";import{isInputModeAvailable as ee}from"../interactive/tooltip/tooltipCommonUtils.js";const te=Symbol();let ie=class extends Q{constructor(e){super(e),this._shapeVisualId=Symbol(),this._vertexVisualId=Symbol(),this._pluginContexts=new Map,this._queuedFeedbackEvents=[],this._flushingQueuedFeedbackEvents=!1,this._commandsSuspended=!1,this._snappingVisualizer=null,this._segmentLabels=null,this._segmentLabelsImportTask=null,this._updatingHandles=new w,this._keybindings=this._makeKeyBindings(),this._pendingBeginRequest=null,this.type="draw-2.0",this.automaticManipulatorSelection=!0,this.snappingManager=null,this.toolOptions=null,this.elevationInfo=null,this.hasZ=!1,this.defaultZ=0,this.lastScreenPosition=null,this.measurementManager=new Z,this.globalStateManager=new F({getPluginStack:()=>this.pluginStack}),this.editSessionManager=new A({getContext:()=>this._editSessionManagerContext}),this.lifecycleManager=new B({getContext:this._getContextForPlugin.bind(this),editSessionManager:this.editSessionManager,afterAttach:this._afterAttach.bind(this),afterDetach:this._afterDetach.bind(this),beforeResume:this._beforeResume.bind(this)}),this.surfaceManager=null,this.interactiveHandleManager=null,this.renderer=null,this.readPluginSetting=null,this.enableVertexVisuals=!0}initialize(){const{view:e}=this;this.interactiveHandleManager=new R({view:e,renderer:this.renderer}),this._override("manipulators",this.interactiveHandleManager.manipulators),this.tooltipManager=new z({getDependencies:()=>this._tooltipDependencies,getLastScreenPosition:()=>this.lastScreenPosition}),this.addHandles(u(()=>this.renderer,t=>{t.addOrUpdateVisual(this._shapeVisualId,{role:"outputGeometry"}),t.addOrUpdateVisual(this._vertexVisualId,{role:"vertex"}),this._updatingHandles.addPromise(T(e,t).then(e=>this._snappingVisualizer=e))},c)),this.addHandles([h(()=>[this.view,this.coordinateHelper.spatialReference,this.defaultZ,this.hasZ,this.elevationInfo],([e,t,i,n,a])=>{this.surfaceManager?.destroy(),this.surfaceManager=new q({spatialReference:t,excludedGraphicsLayer:null,defaultZ:i,hasZ:n,view:e,elevationInfo:a,getContext:()=>({drawAtFixedElevation:this.globalStateManager.drawAtFixedElevation,elevationConstraint:this.tooltipManager?.elevationConstraint,constraintsEnabled:this.tooltipManager?.constraintsEnabled??!1})})},g),u(()=>this.toolOptions?.tooltips.effectiveEnabled,()=>this.measurementManager.preloadMeasurementUtils(),{once:!0,initial:!0}),h(()=>[this.editGeometryOperations,this.toolOptions?.labels.enabled,this.globalStateManager.segmentLabelsDisabled],()=>{this._updatingHandles.addPromise(this._setupSegmentLabels())},c),m(()=>this.editSessionManager,"cancelPlugin",({plugin:e})=>{this._suspendPlugin(e)},v),m(()=>this.editSessionManager,"restartPlugin",({restartInfo:e})=>{this._resumePlugin(e)},v),h(()=>this.lifecycleManager.updating,e=>{e||this._emitQueuedFeedbackEvents()},v),m(()=>this.editGeometryOperations,["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._emitWhenReady(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this._emitWhenReady(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this._emitWhenReady(e.type,{...e,removed:i,vertices:t})}})])}destroy(){this.active&&this.onDeactivate(),this.editSessionManager.destroy(),this.lifecycleManager.destroy(),this.measurementManager.destroy(),this.globalStateManager.destroy();for(const e of this._pluginContexts.values())e.destroy();this._pluginContexts.clear(),this.surfaceManager=l(this.surfaceManager),this.interactiveHandleManager=l(this.interactiveHandleManager),this._segmentLabelsImportTask=d(this._segmentLabelsImportTask),this._segmentLabels=l(this._segmentLabels),this.tooltipManager=l(this.tooltipManager)}get _zOfLastUserInput(){const e=this.mostDownstreamPlugin&&this.editSessionManager.getSession(this.mostDownstreamPlugin),t=e?.firstPointAddedBySession?.point;return t?.hasZ?t.z:null}get _tooltipDependencies(){const{defaultZ:e,editGeometryOperations:t,toolOptions:i,directionOptions:n,elevationInfo:a,view:s}=this;return t&&i&&s?{defaultZ:e,directionOptions:n,elevationInfo:a,editGeometryOperations:t,toolOptions:i,view:s,getActiveHandle:()=>this.interactiveHandleManager?.focusedHandle,getAllHandles:()=>this.interactiveHandleManager?.allhandles,getHelpMessageKey:()=>this.helpMessageKey,notifyTooltipsChanged:()=>{const{interactiveHandleManager:e,movementCommandContext:t}=this;e&&t&&e.reapplyPositions(t)}}:null}get _editSessionManagerContext(){const{coordinateHelper:e,view:t}=this;if(!t)return null;return{coordinateHelper:e,viewingMode:"3d"===t.type&&"global"===t.viewingMode?1:2}}get _densificationParameters(){const{view:e,coordinateHelper:t}=this,i=t.spatialReference,n=e?.spatialReference,a=e.resolution;if(!(i&&n&&a&&Number.isFinite(a)))return null;const s=n.metersPerUnit/i.metersPerUnit;return{maxDeviation:2**Math.round(Math.log2(a))*O()*s,minSegmentsPerCurve:k()}}get test(){return{densificationParameters:this._densificationParameters,segmentLabels:this._segmentLabels}}get updating(){return this._updatingHandles.updating||this.snappingManager?.updating||this.lifecycleManager.updating||!!this._segmentLabels?.updating}get coordinateHelper(){return N(this.hasZ,!1,this.view.spatialReference)}get editGeometry(){return this.editGeometryOperations?.data}get editGeometryOperations(){return this.editSessionManager.editGeometryOperations}get unprocessedGeometry(){return this.editSessionManager.outputGeometry}get simplifiedGeometryPreview(){const e=this.editSessionManager.outputGeometry;if(e&&H(e))try{const t=this._densificationParameters,i=x(e)&&t?new S({...I(e,t)}):e;if(!C(i))return P(i)}catch(t){return e}return e}get _suppressCoincidentPointOverlaysIn3D(){return"3d"===this.view.type&&"point"===this.unprocessedGeometry?.type&&!!this.interactiveHandleManager?.allhandles?.find(e=>"primary"===e.role)?.outputMapPosition}get _shapeVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.simplifiedGeometryPreview}get _vertexVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.unprocessedGeometry}get canUndo(){return this.editSessionManager.canUndo}get canRedo(){return this.editSessionManager.canRedo}get pluginStack(){return this.lifecycleManager.pluginStack}get mostDownstreamPlugin(){return this.pluginStack.at(-1)}get mostUpstreamPlugin(){return this.pluginStack.at(0)}get positionOfLastUserInput(){const e=this.lastScreenPosition;return e?this.surfaceManager?.screenToMap(e,{firstPointZ:this._zOfLastUserInput})??this.view.toMap(e):this.view.center}get movementCommandContext(){const{editGeometryOperations:e,tooltipManager:t,surfaceManager:i,snappingManager:n,interactiveHandleManager:a,_snappingVisualizer:s,defaultZ:r,hasZ:o,globalStateManager:{drawAtFixedElevation:l},view:d}=this;return{tooltipManager:t,editGeometryOperations:e,surfaceManager:i,interactiveHandleManager:a,snappingManager:n,snappingVisualizer:s,pointerType:"mouse",hasZ:o,defaultZ:r,view:d,drawAtFixedElevation:l}}get tooltip(){return this.tooltipManager?.tooltip}get activeTooltipInfo(){return this.tooltipManager?.tooltipInfo}get helpMessageKey(){return this.pluginStack.items.findLast(e=>e.helpMessageKey)?.helpMessageKey??"noTool"}begin(e){this.active?(this.lifecycleManager.begin(e),this._pendingBeginRequest=null):this._pendingBeginRequest=e}complete(e){const t=this.lifecycleManager;if(e&&t.complete(e),0===t.pluginStack.length){const e=this.unprocessedGeometry,t=!e||"mesh"===e.type||C(e);this.emit("complete",{geometry:e,isSimple:t,aborted:!1,type:"complete",vertices:[]}),this.view?.activeTool===this&&(this.view.activeTool=null)}}cancelFirstUserLeafPlugin(){const e=this.pluginStack.toArray().findLast(e=>!0!==e.configuration?.hidden);e&&this.lifecycleManager.cancel(e)}getVertexSnappingCandidates(){return"secondary"===this.interactiveHandleManager?.capturingHandle?.role?[]:this.snappingManager?.getVertexCandidates()??[]}replaceLeaf(e){const t=this.lifecycleManager;t.updating?r.getLogger(this).info("Ignoring command; arrived while updating:","replaceLeaf"):t.replaceLeaf(e)}finishPart(){const e=this.mostUpstreamPlugin,t=e?.configuration;if(this.editGeometryOperations&&t&&t.kind?.includes("multipart")){const e=this.pluginStack.at(1);e&&this.complete(e)}}undo(){this._handleCommand({action:"undo"})}redo(){this._handleCommand({action:"redo"})}executeCommand(e){return this._handleCommand(e)}suspendCommands(){return this._commandsSuspended=!0,a(()=>{this._commandsSuspended=!1;const e=this.view?.inputManager.latestPointerInfo;if(e){const{x:t,y:i}=e.location;this._handleCommand({action:"manipulator-move-to",x:t,y:i})}})}addPromise(e){return this._updatingHandles.addPromise(e)}readPluginSettingValue(e,t){return this.readPluginSetting?.(e,t)}getGeometryIfCompleted(){const e=this.lifecycleManager.gatherCompletablePlugins();return this.editSessionManager?.generatePreviewGeometryForPlugins(e)}onActivate(){super.onActivate();const{view:e}=this;this.lastScreenPosition=e?.inputManager.latestPointerInfo?.location,this.renderer?.activate(),this._pendingBeginRequest&&(this.begin(this._pendingBeginRequest),this._pendingBeginRequest=null),this.enableVertexVisuals&&this.addHandles(h(()=>this._vertexVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._vertexVisualId,{geometry:e?V(e):null})},c)),this.addHandles([h(()=>this._shapeVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._shapeVisualId,{geometry:e})},c),u(()=>this.interactiveHandleManager?.capturingHandle?.screenPosition,e=>this.lastScreenPosition=e,{initial:!0,equals:y}),h(()=>this.interactiveHandleManager?.capturingHandle?.outputMapPosition,(e,t)=>{const i=this.interactiveHandleManager?.capturingHandle?.editSession?.endVertex;e&&t&&i&&this._emitWhenReady("cursor-update",{updated:i.pos,type:"vertex-update",operation:"apply",vertices:[{componentIndex:i.part.index,vertexIndex:i.index,coordinates:i.pos}]})},v),this._keybindings.register(e,K.TOOL),h(()=>e.viewpoint,(e,t)=>{e&&t&&M(e,t)&&this._handleCommand({action:"viewpoint-moved"})})],te)}onDeactivate(){super.onDeactivate(),this.removeHandles(te),this.renderer?.deactivate(),this.snappingManager?.doneSnapping(),this.lifecycleManager.cancelAll(),this._pendingBeginRequest=null}onInputEvent(e){"pointer-down"===e.type?this.interactiveHandleManager?.notePointerDown(e.pointerId,e.pointerType):"pointer-up"!==e.type&&"pointer-leave"!==e.type||this.interactiveHandleManager?.notePointerUp(e.pointerId,e.pointerType);const t=U(e);t&&this._handleCommand(t)}forceAddVertex(){this._commitNext()}_emitWhenReady(e,t){if(this.destroyed)return;const i=()=>{this.emit(e,t)};this.lifecycleManager.updating||this._flushingQueuedFeedbackEvents?this._queuedFeedbackEvents.push(i):i()}_emitQueuedFeedbackEvents(){if(!(this.destroyed||this._flushingQueuedFeedbackEvents||this.lifecycleManager.updating||0===this._queuedFeedbackEvents.length)){this._flushingQueuedFeedbackEvents=!0;try{for(;!this.destroyed&&!this.lifecycleManager.updating&&this._queuedFeedbackEvents.length>0;)this._queuedFeedbackEvents.shift()?.()}finally{this._flushingQueuedFeedbackEvents=!1}}}async _handleCommand(e){if(!this._commandsSuspended)if(this.lifecycleManager.updating)r.getLogger(this).info("Ignoring command; arrived while updating:",e.action);else switch(e.action){case"view-drag":return await this._handleViewDragCommand(e);case"vertex-add":return this._guardCommand(e,()=>{G(e),this._commitNext()});case"vertex-add-and-finish-part":return this._handleVertexAddAndFinishPartCommand(e);case"cancel":return this._guardCommand(e,()=>this.cancel());case"complete":return this._guardCommand(e,()=>{this.mostUpstreamPlugin&&(G(e),this.complete(this.mostUpstreamPlugin))});case"finish-part":return this._guardCommand(e,()=>this.finishPart());case"undo":return this._guardCommand(e,()=>this.editSessionManager.undo());case"redo":return this._guardCommand(e,()=>this.editSessionManager.redo());case"next-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("forward"));case"previous-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("backward"));case"toggle-manipulator-follow":this.interactiveHandleManager?.toggleFollow()&&G(e);break;case"viewpoint-moved":return await this._handleViewpointMovedCommand(e);case"manipulator-move-to":return await this._handleManipulatorMoveToCommand(e);case"manipulator-drag-to":return await this._handleManipulatorDragToCommand(e);case"vertex-add-at-point":return await this._handleVertexAddAtPointCommand(e);case"show-tooltip":return this._guardCommand(e,async()=>{const t=this.tooltipManager?.tooltip;t&&ee(t.info)&&(await t.enterInputMode(),G(e))});case"constraint-center":this.globalStateManager.setCentered(e.enabled);break;case"constraint-aspect":this.globalStateManager.setPreserveAspectRatio(e.enabled)}}async _handleViewDragCommand(e){if(!this.editable)return;const t=e.originalEvent,i=this.interactiveHandleManager?.capturingHandle;(!t||!("pointerType"in t)||"touch"!==t.pointerType||"capture-always"!==i?.captureMode&&"capture-when-engaged"!==i?.captureMode)&&"capture-when-engaged"!==this.interactiveHandleManager?.capturingHandle?.captureMode?this._before(e)&&G(e):G(e)}_handleVertexAddAndFinishPartCommand(e){this._before(e)||(G(e),this._commitNext(),this.finishPart())}async _handleViewpointMovedCommand(e){if(!this.editable)return;const t=j(e.originalEvent),i=E(e.originalEvent);await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(null,{...this.movementCommandContext,pointerType:t,pointerId:i})),this.interactiveHandleManager?.updateAllScreenPositions(this.movementCommandContext.surfaceManager)}async _handleManipulatorMoveToCommand(e){if(!this.editable)return;const t=j(e.originalEvent),i=E(e.originalEvent);if(!this.interactiveHandleManager?.shouldCaptureInput(i,t))return;const n=this._updateLastScreenPosition(e);this.interactiveHandleManager?.capturingHandle&&G(e),await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(n,{...this.movementCommandContext,pointerType:t,pointerId:i}))}async _handleManipulatorDragToCommand(e){if(!this.editable)return;const t=j(e.originalEvent),i=E(e.originalEvent);if(!this.interactiveHandleManager?.shouldCaptureInput(i,t))return;const n=this._updateLastScreenPosition(e),a=this.interactiveHandleManager?.findHandleByManipulator(n,t);"touch"===t&&a&&"start"===e.state&&this.interactiveHandleManager?.releaseHandle();const s=this.interactiveHandleManager?.findHandleDragging(),r=this.interactiveHandleManager?.capturingHandle,o=s??r??a;o&&!a&&G(e),"capture-when-engaged"===o?.captureMode||"capture-always"===o?.captureMode&&"touch"===t?"end"===e.state?await this._updatingHandles.addPromise(o.noteDragEnd(n,{...this.movementCommandContext,pointerType:t,pointerId:i}).then(()=>{o&&"touch"===j(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&"primary"===o.role&&(1===this.interactiveHandleManager?.handleCount?this._handleCommand({action:"vertex-add"}):this.interactiveHandleManager?.releaseHandle())})):"start"===e.state?await this._updatingHandles.addPromise(o.noteDragStart(n,{...this.movementCommandContext,pointerType:t,pointerId:i}).then(()=>{o&&"touch"===j(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&!o.editSession?.lastPointAddedBySession&&this._handleCommand({action:"vertex-add"})})):await this._updatingHandles.addPromise(o?.moveTo(n,{...this.movementCommandContext,pointerType:t,pointerId:i})):"grabbable-object"===o?.captureMode&&(this.interactiveHandleManager?.releaseHandle(r),await this._updatingHandles.addPromise(o.moveTo(n,{...this.movementCommandContext,pointerType:t,pointerId:i})))}async _handleVertexAddAtPointCommand(e){const t=this._updateLastScreenPosition(e),i=j(e.originalEvent),n=E(e.originalEvent);if(!this.interactiveHandleManager?.shouldCaptureInput(n,i))return;const a=this.interactiveHandleManager?.capturingHandle??this.interactiveHandleManager?.findHandleByManipulator(t,i);this.editable&&a&&(this._before(e)||(G(e),await this._updatingHandles.addPromise(a.moveTo(t,{...this.movementCommandContext,skipSnapping:!0,pointerType:i,pointerId:n}).finally(()=>this._commitNext()))))}_makeKeyBindings(){const e=new W,t=(t,i)=>{e.addToggle(t,e=>this._handleCommand({action:i,originalEvent:e,enabled:"key-down"===e.type}))},i=(t,i)=>{e.add(t,e=>this._handleCommand({action:i,originalEvent:e}))};return t($.preserveAspectRatio,"constraint-aspect"),t(J.center,"constraint-center"),i(X.toggleFollowManipulator,"toggle-manipulator-follow"),i(J.undo,"undo"),i(J.redo,"redo"),i(J.complete,"complete"),i(J.vertexAdd,"vertex-add"),i({key:Y.enterInputMode,continuePropagation:!0,repeats:!0},"show-tooltip"),e}_afterAttach(){}_afterDetach(e){this.interactiveHandleManager?.unregisterCustomConstraint(e),this.interactiveHandleManager?.unregisterHandle(e),this.tooltipManager?.unregisterPluginFields(e),this.globalStateManager.clearPluginOverrides(e);const t=this._pluginContexts.get(e);t&&(t.destroy(),this._pluginContexts.delete(e))}_beforeResume(e,t){this.interactiveHandleManager?.replaceEditSessions(e,t)}_commitNext(){const i={stack:[],error:void 0,hasError:!1};try{const t=this.mostDownstreamPlugin;if(!t)return;this.tooltipManager?.storeConstraintSnapshot();let n=!1;const a=this.editGeometryOperations;e(i,a?s(a.on("vertex-add",()=>n=!0)):null,!1);t.completeStep?t.completeStep():this.complete(t),n&&this.tooltipManager?.unlockOnVertexPlacement()}catch(n){i.error=n,i.hasError=!0}finally{t(i)}}_suspendPlugin(e){this.lifecycleManager.suspend(e),this.measurementManager.suspendPlugin(e)}_resumePlugin(e){this.lifecycleManager.resume(e)}_updateLastScreenPosition(e){const t=f(e.x,e.y);return this.lastScreenPosition=t,t}_getContextForPlugin(e,t){const i=o(this._pluginContexts,e,()=>new D({drawTool:this,plugin:e,session:t}));return i.session=t,i}_before(e){if(!this.hasEventListener(`before-${e.action}`))return!1;const t=new CustomEvent(`before-${e.action}`,{detail:e,cancelable:!0});return this.emit(`before-${e.action}`,t),t.defaultPrevented}_guardCommand(e,t,i){return this._before(e)?i?.():t()}async _setupSegmentLabels(){const e=this.editGeometryOperations,t=this.toolOptions?.labels,i=!!t?.enabled,n=this.globalStateManager.segmentLabelsDisabled;if(!e||!t||!i)return void(this._segmentLabels=l(this._segmentLabels));if(n)return void(this._segmentLabels&&(this._segmentLabels.visible=!1));if(this._segmentLabels?.context?.editGeometryOperations===e&&this._segmentLabels.context.labelOptions===t)return void(this._segmentLabels.visible=!0);const a=await this._createSegmentLabels(e,t);a&&(this._segmentLabels=l(this._segmentLabels),this._segmentLabels=a)}async _createSegmentLabels(e,t){this._segmentLabelsImportTask?.abort();const i=this._segmentLabelsImportTask=n(async i=>{if("3d"===this.view.type){const n=import("../3d/interactive/SegmentLabels3D.js"),{SegmentLabels3D:a}=await this._updatingHandles.addPromise(n);return this._isSegmentLabelsSetupStale(i,e,t)?null:new a({context:{view:this.view,editGeometryOperations:e,elevationInfo:L(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})}const n=import("../2d/interactive/SegmentLabels2D.js"),{SegmentLabels2D:a}=await this._updatingHandles.addPromise(n);return this._isSegmentLabelsSetupStale(i,e,t)?null:new a({context:{view:this.view,editGeometryOperations:e,elevationInfo:L(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})});return p(i.promise)}_isSegmentLabelsSetupStale(e,t,i){return e.aborted||this.editGeometryOperations!==t||this.toolOptions?.labels!==i||!i.enabled||this.globalStateManager.segmentLabelsDisabled}};i([_()],ie.prototype,"_commandsSuspended",void 0),i([_()],ie.prototype,"_zOfLastUserInput",null),i([_()],ie.prototype,"_snappingVisualizer",void 0),i([_()],ie.prototype,"_segmentLabels",void 0),i([_()],ie.prototype,"_segmentLabelsImportTask",void 0),i([_()],ie.prototype,"_tooltipDependencies",null),i([_()],ie.prototype,"_editSessionManagerContext",null),i([_()],ie.prototype,"_densificationParameters",null),i([_({constructOnly:!0,nonNullable:!0})],ie.prototype,"view",void 0),i([_()],ie.prototype,"automaticManipulatorSelection",void 0),i([_()],ie.prototype,"updating",null),i([_()],ie.prototype,"coordinateHelper",null),i([_()],ie.prototype,"editGeometry",null),i([_()],ie.prototype,"editGeometryOperations",null),i([_()],ie.prototype,"unprocessedGeometry",null),i([_()],ie.prototype,"simplifiedGeometryPreview",null),i([_()],ie.prototype,"_suppressCoincidentPointOverlaysIn3D",null),i([_()],ie.prototype,"_shapeVisualGeometry",null),i([_()],ie.prototype,"_vertexVisualGeometry",null),i([_()],ie.prototype,"snappingManager",void 0),i([_()],ie.prototype,"toolOptions",void 0),i([_()],ie.prototype,"elevationInfo",void 0),i([_()],ie.prototype,"hasZ",void 0),i([_()],ie.prototype,"defaultZ",void 0),i([_()],ie.prototype,"directionOptions",void 0),i([_()],ie.prototype,"canUndo",null),i([_()],ie.prototype,"canRedo",null),i([_()],ie.prototype,"pluginStack",null),i([_()],ie.prototype,"mostDownstreamPlugin",null),i([_()],ie.prototype,"mostUpstreamPlugin",null),i([_()],ie.prototype,"lastScreenPosition",void 0),i([_()],ie.prototype,"positionOfLastUserInput",null),i([_()],ie.prototype,"tooltipManager",void 0),i([_()],ie.prototype,"measurementManager",void 0),i([_()],ie.prototype,"globalStateManager",void 0),i([_()],ie.prototype,"editSessionManager",void 0),i([_()],ie.prototype,"lifecycleManager",void 0),i([_()],ie.prototype,"surfaceManager",void 0),i([_()],ie.prototype,"interactiveHandleManager",void 0),i([_()],ie.prototype,"renderer",void 0),i([_()],ie.prototype,"readPluginSetting",void 0),i([_()],ie.prototype,"movementCommandContext",null),i([_()],ie.prototype,"tooltip",null),i([_()],ie.prototype,"activeTooltipInfo",null),i([_()],ie.prototype,"helpMessageKey",null),i([_({constructOnly:!0})],ie.prototype,"enableVertexVisuals",void 0),ie=i([b("esri.views.draw.DrawTool")],ie);export{ie as DrawTool};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{zeroDegreesGeographic as t,createLength as i}from"../../../core/quantity.js";import{watch as o,initial as s}from"../../../core/reactiveUtils.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{isPolyline as l}from"../../../geometry/support/typeUtils.js";import{PluginBase as a}from"./PluginBase.js";import{knownFieldDisplayOrders as d}from"../support/types.js";import{directionForVertices as p}from"../../support/angularMeasurementUtils.js";const m=Symbol("polyline-committed-length-measurement"),u=Symbol("polyline-staged-measurement"),c=Symbol("polyline-cursor-distance-measurement"),h=Symbol("polyline-distance-field"),_=Symbol("polyline-direction-field"),y=Symbol("polyline-total-length-field");let g=class extends a{constructor(){super(...arguments),this._lineVisualId=Symbol()}get _downstreamGeometry(){return this._downstreamEditSession?.generatePreviewGeometry({includeAutomaticConnection:!0,geometryType:"polyline"})}get _downstreamEditSession(){const{_downstreamPlugin:e,_context:t}=this;return e?t?.getSession(e):null}get _committed(){return this._getCommittedGeometry()}get helpMessageKey(){return this._session?.lastPointAddedBySession?"polylineOneVertex":"polylineZeroVertices"}start(e){super.start(e);const{session:t}=e;t.automaticRestart=!1,e.addOrUpdateVisual(this._lineVisualId,{role:"outline",state:"active"}),this.addHandles([o(()=>this._downstreamEditSession?.lastPointAddedBySession,t=>{this._cursorVertex=t;const i=this._downstreamGeometry,o=this._session;t&&o?(this._lastVertex=null!=t.pointIndex&&t.pointIndex>0?o.getInformationAboutPoint(t.pointIndex-1,t.partIndex):null,this._secondToLastVertex=null!=t.pointIndex&&t.pointIndex>1?o.getInformationAboutPoint(t.pointIndex-2,t.partIndex):null):(this._lastVertex=null,this._secondToLastVertex=null),e.addOrUpdateVisual(this._lineVisualId,{geometry:i})},s)],this._ownHandlesKey),this._setupTooltips()}complete(){this._session?.complete(),this._isComplete=!0,this.removeHandles(this._ownHandlesKey),this.removeHandles(this._downstreamHandlesKey)}attachPlugin(e){this._downstreamPlugin=e,this.notifyChange("_downstreamEditSession")}detachPlugin(e,t){this.notifyChange("_committed"),"complete"===t&&e.configuration&&this._context?.requestBeginDownstreamPlugin(e.configuration)}_getCommittedGeometry(){return this._session?.generatePreviewGeometry({includeAutomaticConnection:!1,geometryType:"polyline"})}_setupTooltips(){this._context&&(this._distanceField??=this._context.createMeasuredField({id:h,preset:"distance",getMeasurementInput:()=>[this._lastVertex?.point,this._cursorVertex?.point],measure:async(e,t)=>{if(!e||!e[0]||!e[1])return null;const i=t.inputUnitInfos.length.unit;return this._context?.measureDistance([e[0],e[1]],c,"tooltip",i)},fieldProperties:{displayOrder:d.Coordinates+11},fieldFilters:{appliesToHandlesWithRole:"primary"}}),this._directionField??=this._context.createMeasuredField({id:_,preset:"direction",getMeasurementInput:()=>[this._lastVertex?.point,this._cursorVertex?.point],measure:async([e,i],o)=>{const s=o.sketchOptions.values.effectiveDirectionMode;if(e&&i){const o=p(this._secondToLastVertex?.point,e,i,s);return this._directionField&&(this._directionField.readOnly="absolute"===s?!e:!this._secondToLastVertex?.point),o??("absolute"===s||this._secondToLastVertex?t:null)}return null},fieldProperties:{displayOrder:d.Coordinates+10},fieldFilters:{appliesToHandlesWithRole:"primary"}}),this._setupGeometrySpecificTooltip())}_setupGeometrySpecificTooltip(){this._context&&(this._lengthField??=this._context.createMeasuredField({id:y,preset:"totalLength",getMeasurementInput:()=>[this._committed,this._downstreamGeometry],measure:async([e,t],o,s)=>{const n=o.inputUnitInfos.length.unit,r=t&&l(t)?await(this._context?.measureLength(t,u,"tooltip",n)):void 0,a=e&&e!==s?.[0]&&l(e)?await(this._context?.measureLength(e,m,"tooltip",n)):e?this._cachedCommittedLength:null;return this._cachedCommittedLength=a,(a||r)&&(e||0!==r?.value)?i((a?.value??0)+(r?.value??0),n):null},fieldProperties:{displayOrder:d.ShapeMeasurements}}))}};e([n()],g.prototype,"_downstreamPlugin",void 0),e([n()],g.prototype,"_lastVertex",void 0),e([n()],g.prototype,"_cursorVertex",void 0),e([n()],g.prototype,"_secondToLastVertex",void 0),e([n()],g.prototype,"_lengthField",void 0),e([n()],g.prototype,"_distanceField",void 0),e([n()],g.prototype,"_directionField",void 0),e([n()],g.prototype,"_downstreamGeometry",null),e([n()],g.prototype,"_downstreamEditSession",null),e([n()],g.prototype,"_committed",null),e([n()],g.prototype,"helpMessageKey",null),g=e([r("esri.views.draw.plugins.PolylinePlugin")],g);export{g as PolylinePlugin};
2
+ import{__decorate as e}from"tslib";import{zeroDegreesGeographic as t,createLength as i}from"../../../core/quantity.js";import{watch as o,initial as s}from"../../../core/reactiveUtils.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{isPolyline as l}from"../../../geometry/support/typeUtils.js";import{PluginBase as a}from"./PluginBase.js";import{knownFieldDisplayOrders as d}from"../support/types.js";import{directionForVertices as p}from"../../support/angularMeasurementUtils.js";const m=Symbol("polyline-committed-length-measurement"),u=Symbol("polyline-staged-measurement"),c=Symbol("polyline-cursor-distance-measurement"),h=Symbol("polyline-distance-field"),_=Symbol("polyline-direction-field"),y=Symbol("polyline-total-length-field");let g=class extends a{constructor(){super(...arguments),this._lineVisualId=Symbol()}get _downstreamGeometry(){return this._downstreamEditSession?.generatePreviewGeometry({includeAutomaticConnection:!0,geometryType:"polyline"})}get _downstreamEditSession(){const{_downstreamPlugin:e,_context:t}=this;return e?t?.getSession(e):null}get _committed(){return this._getCommittedGeometry()}get helpMessageKey(){return this._session?.lastPointAddedBySession?"polylineOneVertex":"polylineZeroVertices"}start(e){super.start(e);const{session:t}=e;t.automaticRestart=!1,e.addOrUpdateVisual(this._lineVisualId,{role:"outline",state:"active"}),this.addHandles([o(()=>this._downstreamEditSession?.lastPointAddedBySession,t=>{this._cursorVertex=t;const i=this._downstreamGeometry,o=this._session;t&&o?(this._lastVertex=null!=t.pointIndex&&t.pointIndex>0?o.getInformationAboutPoint(t.pointIndex-1,t.partIndex):null,this._secondToLastVertex=null!=t.pointIndex&&t.pointIndex>1?o.getInformationAboutPoint(t.pointIndex-2,t.partIndex):null):(this._lastVertex=null,this._secondToLastVertex=null),e.addOrUpdateVisual(this._lineVisualId,{geometry:i})},s)],this._ownHandlesKey),this._setupTooltips()}complete(){this._session?.complete(),this._isComplete=!0,this.removeHandles(this._ownHandlesKey),this.removeHandles(this._downstreamHandlesKey)}attachPlugin(e){this._downstreamPlugin=e,this.notifyChange("_downstreamEditSession")}detachPlugin(e,t){this.notifyChange("_committed"),"complete"===t&&e.configuration&&this._context?.requestBeginDownstreamPlugin(e.configuration)}_getCommittedGeometry(){return this._session?.generatePreviewGeometry({includeAutomaticConnection:!1,geometryType:"polyline"})}_setupTooltips(){this._context&&(this._distanceField??=this._context.createMeasuredField({id:h,preset:"distance",getMeasurementInput:()=>[this._lastVertex?.point,this._cursorVertex?.point],measure:async(e,t)=>{if(!e||!e[0]||!e[1])return null;const i=t.inputUnitInfos.length.unit;return this._context?.measureDistance([e[0],e[1]],c,"tooltip",i)},fieldProperties:{displayOrder:d.Coordinates+11},fieldFilters:{appliesToHandlesWithRole:"primary"}}),this._directionField??=this._context.createMeasuredField({id:_,preset:"direction",getMeasurementInput:()=>[this._lastVertex?.point,this._cursorVertex?.point],measure:async([e,i],o)=>{const s=o.toolOptions.values.effectiveDirectionMode;if(e&&i){const o=p(this._secondToLastVertex?.point,e,i,s);return this._directionField&&(this._directionField.readOnly="absolute"===s?!e:!this._secondToLastVertex?.point),o??("absolute"===s||this._secondToLastVertex?t:null)}return null},fieldProperties:{displayOrder:d.Coordinates+10},fieldFilters:{appliesToHandlesWithRole:"primary"}}),this._setupGeometrySpecificTooltip())}_setupGeometrySpecificTooltip(){this._context&&(this._lengthField??=this._context.createMeasuredField({id:y,preset:"totalLength",getMeasurementInput:()=>[this._committed,this._downstreamGeometry],measure:async([e,t],o,s)=>{const n=o.inputUnitInfos.length.unit,r=t&&l(t)?await(this._context?.measureLength(t,u,"tooltip",n)):void 0,a=e&&e!==s?.[0]&&l(e)?await(this._context?.measureLength(e,m,"tooltip",n)):e?this._cachedCommittedLength:null;return this._cachedCommittedLength=a,(a||r)&&(e||0!==r?.value)?i((a?.value??0)+(r?.value??0),n):null},fieldProperties:{displayOrder:d.ShapeMeasurements}}))}};e([n()],g.prototype,"_downstreamPlugin",void 0),e([n()],g.prototype,"_lastVertex",void 0),e([n()],g.prototype,"_cursorVertex",void 0),e([n()],g.prototype,"_secondToLastVertex",void 0),e([n()],g.prototype,"_lengthField",void 0),e([n()],g.prototype,"_distanceField",void 0),e([n()],g.prototype,"_directionField",void 0),e([n()],g.prototype,"_downstreamGeometry",null),e([n()],g.prototype,"_downstreamEditSession",null),e([n()],g.prototype,"_committed",null),e([n()],g.prototype,"helpMessageKey",null),g=e([r("esri.views.draw.plugins.PolylinePlugin")],g);export{g as PolylinePlugin};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../Graphic.js";import{EventedAccessor as i}from"../../../core/Evented.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{debounce as o}from"../../../core/promiseUtils.js";import{zeroMeters as r}from"../../../core/quantity.js";import{when as a,watch as h,syncAndInitial as c,initial as n}from"../../../core/reactiveUtils.js";import{property as l,subclass as p}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as _}from"../../../core/support/UpdatingHandles.js";import d from"../../../geometry/Point.js";import m from"../../../geometry/Polygon.js";import u from"../../../geometry/Polyline.js";import{create as g,center as y}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as v}from"../../../geometry/support/boundsUtils.js";import f from"../../../geometry/support/rotate.js";import G from"../../../symbols/SimpleFillSymbol.js";import b from"../../../symbols/SimpleLineSymbol.js";import x from"../../../symbols/SimpleMarkerSymbol.js";import{cloneMove as w,scale as S,getRotationAngle as k,getScaleRatio as R}from"./drawUtils.js";import H from"./GraphicMover.js";import I from"./HighlightHelper.js";import{addUniqueLayer as C}from"./layerUtils.js";import{settings as M}from"./settings.js";import T from"../../interactive/sketch/SketchOptions.js";import{makeTooltip as O}from"../../interactive/tooltip/tooltipCommonUtils.js";import{ExtentRotateTooltipInfo as j}from"../../interactive/tooltip/infos/ExtentRotateTooltipInfo.js";import{ExtentScaleTooltipInfo as E}from"../../interactive/tooltip/infos/ExtentScaleTooltipInfo.js";import{TranslateTooltipInfo as B}from"../../interactive/tooltip/infos/TranslateTooltipInfo.js";import{GeometryWorkerHandle as L}from"../../support/GeometryWorkerHandle.js";const N=M.transformGraphics,z={centerIndicator:new x({style:"cross",size:N.center.size,color:N.center.color}),fill:{default:new G({color:N.fill.color,outline:{color:N.fill.outlineColor,join:"round",width:1}}),active:new G({color:N.fill.stagedColor,outline:{color:N.fill.outlineColor,join:"round",style:"dash",width:1}})},handles:{default:new x({style:"square",size:N.vertex.size,color:N.vertex.color,outline:{color:N.vertex.outlineColor,width:1}}),hover:new x({style:"square",size:N.vertex.hoverSize,color:N.vertex.hoverColor,outline:{color:N.vertex.hoverOutlineColor,width:1}})},rotator:{default:new x({style:"circle",size:N.vertex.size,color:N.vertex.color,outline:{color:N.vertex.outlineColor,width:1}}),hover:new x({style:"circle",size:N.vertex.hoverSize,color:N.vertex.hoverColor,outline:{color:N.vertex.hoverOutlineColor,width:1}})},rotatorLine:new b({color:N.line.color,width:1})},Y=Symbol();let A=class extends i{constructor(t){super(t),this._activeHandleGraphic=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._centerGraphic=null,this._backgroundGraphic=null,this._vertexGraphics=[],this._rotateHandleGraphic=null,this._rotateGraphicOffset=20,this._angleOfRotation=0,this._rotateLineGraphic=null,this._startInfo=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this.tooltip=null,this.type="box",this.callbacks={onMoveStart(){},onMove(){},onMoveStop(){},onScaleStart(){},onScale(){},onScaleStop(){},onRotateStart(){},onRotate(){},onRotateStop(){},onGraphicClick(){}},this.enableMovement=!0,this.enableRotation=!0,this.enableScaling=!0,this.graphics=[],this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.preserveAspectRatio=!1,this.showCenterGraphic=!0,this.symbols=z,this.sketchOptions=new T,this.view=null,this._updatingHandles=new _,this._getBounds=(()=>{const t=g();return(e,i)=>{e[0]=Number.POSITIVE_INFINITY,e[1]=Number.POSITIVE_INFINITY,e[2]=Number.NEGATIVE_INFINITY,e[3]=Number.NEGATIVE_INFINITY;for(const s of i){if(!s)continue;let i,o,r,a;if("point"===s.type)i=r=s.x,o=a=s.y;else if("extent"===s.type)[i,o,r,a]=[s.xmin,s.ymin,s.xmax,s.ymax];else{const e=v(t,s);[i,o,r,a]=e}e[0]=Math.min(i,e[0]),e[1]=Math.min(o,e[1]),e[2]=Math.max(r,e[2]),e[3]=Math.max(a,e[3])}return e}})(),this._extentScaleTooltipInfo=new E({sketchOptions:this.sketchOptions}),this._measurementWorker=new L({preloadGeodetic:!0}),this._updateScaleTooltipAsync=o(async()=>{const t=this._getCoordinates(),e=this.view.spatialReference,{width:i,height:s}=await this._measurementWorker.autoSize2D(new d({x:t[0][0],y:t[0][1],spatialReference:e}),new d({x:t[1][0],y:t[1][1],spatialReference:e}),new d({x:t[2][0],y:t[2][1],spatialReference:e}),new d({x:t[3][0],y:t[3][1],spatialReference:e}));this._extentScaleTooltipInfo.xSize=i,this._extentScaleTooltipInfo.ySize=s}),this._translateTooltipInfo=new B({sketchOptions:this.sketchOptions}),this._updateMoveTooltipAsync=o(async t=>{const{view:e}=this,i=this._translateTooltipInfo;if(!t)return void(i.distance=r);const{x:s,y:o}=t.origin,a=e.toMap(t),h=e.toMap({x:s,y:o}),c=await this._measurementWorker.autoDistance2DBetweenPoints(h,a);i.distance=null!=c?c:r})}initialize(){const t=this.view;this._highlightHelper=new I({view:t}),this._setup(),this.addHandles([a(()=>t?.ready,()=>{const{layer:t,view:e}=this;C(e,t)},{once:!0,initial:!0}),h(()=>this.preserveAspectRatio,()=>{this._activeHandleGraphic&&(this._scaleGraphic(this._activeHandleGraphic),this._updateGraphics(),this._updateTooltip(this._activeHandleGraphic))}),h(()=>t?.scale,()=>{this._updateRotateGraphic(),this._updateRotateLineGraphic()}),h(()=>this.graphics,()=>this.refresh()),h(()=>this.layer,(t,e)=>{e&&this._resetGraphics(e),this.refresh()}),h(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),h(()=>this.sketchOptions.tooltips.effectiveEnabled,e=>{this.tooltip=e?O(()=>({view:t,options:this.sketchOptions.tooltips})):s(this.tooltip)},c),h(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),n),this.on("move-start",t=>this.callbacks?.onMoveStart?.(t)),this.on("move",t=>this.callbacks?.onMove?.(t)),this.on("move-stop",t=>this.callbacks?.onMoveStop?.(t)),this.on("rotate-start",t=>this.callbacks?.onRotateStart?.(t)),this.on("rotate",t=>this.callbacks?.onRotate?.(t)),this.on("rotate-stop",t=>this.callbacks?.onRotateStop?.(t)),this.on("scale-start",t=>this.callbacks?.onScaleStart?.(t)),this.on("scale",t=>this.callbacks?.onScale?.(t)),this.on("scale-stop",t=>this.callbacks?.onScaleStop?.(t))])}destroy(){this._reset(),this.tooltip=s(this.tooltip)}get state(){const t=this.view?.ready??!1,e=this.graphics.length&&this.layer;return t&&e?"active":t?"ready":"disabled"}get updating(){return this._updatingHandles.updating}isUIGraphic(t){return this._vertexGraphics.includes(t)||t===this._backgroundGraphic||t===this._centerGraphic||t===this._rotateHandleGraphic||t===this._rotateLineGraphic}move(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=w(s,t,e,this.view);i.geometry=o}this.refresh(),this.emit("move-stop",{graphics:this.graphics,mover:null,dx:t,dy:e,type:"move-stop"})}}scale(t,e){if(!this._mover||!this.graphics.length)return;const i=this._getBoxBounds(g()),s=y(i);for(const o of this.graphics){const i=o.geometry,r=S(i,t,e,s);o.geometry=r}this.refresh(),this.emit("scale-stop",{graphics:this.graphics,mover:null,xScale:t,yScale:e,type:"scale-stop"})}rotate(t,e){if(this._mover&&this.graphics.length){if(!e){const t=this._vertexGraphics[1].geometry.x,i=this._vertexGraphics[3].geometry.y;e=new d(t,i,this.view.spatialReference)}for(const i of this.graphics){const s=i.geometry,o=f(s,t,e);i.geometry=o}this.refresh(),this.emit("rotate-stop",{graphics:this.graphics,mover:null,angle:t,type:"rotate-stop"})}}refresh(){this._reset(),this._setup()}reset(){this.graphics=[]}_setup(){"active"===this.state&&(this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._updateGraphics())}_reset(){this._highlightHelper?.removeAll(),this._resetGraphicStateVars(),this._resetGraphics(),this._updateTooltip(),this._mover?.destroy(),this._mover=null,this.removeHandles(Y)}_resetGraphicStateVars(){this._startInfo=null,this._activeHandleGraphic=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this._angleOfRotation=0}_resetGraphics(t){(t=t||this.layer)&&(t.removeMany(this._vertexGraphics),t.remove(this._backgroundGraphic),t.remove(this._centerGraphic),t.remove(this._rotateHandleGraphic),t.remove(this._rotateLineGraphic)),this._vertexGraphics.forEach(t=>!t.destroyed&&t.destroy()),!this._backgroundGraphic.destroyed&&this._backgroundGraphic.destroy(),!this._centerGraphic.destroyed&&this._centerGraphic.destroy(),!this._rotateHandleGraphic.destroyed&&this._rotateHandleGraphic.destroy(),!this._rotateLineGraphic.destroyed&&this._rotateLineGraphic.destroy(),this._vertexGraphics=[],this._backgroundGraphic=null,this._centerGraphic=null,this._rotateHandleGraphic=null,this._rotateLineGraphic=null}_setupMover(){let t=[];this.enableScaling&&(t=t.concat(this._vertexGraphics)),this.enableRotation&&t.push(this._rotateHandleGraphic),this.enableMovement&&(t=t.concat(this.graphics,this._backgroundGraphic)),this.showCenterGraphic&&t.push(this._centerGraphic),this._mover=new H({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,view:this.view,graphics:t,callbacks:{onGraphicClick:t=>this._onGraphicClickCallback(t),onGraphicMoveStart:t=>this._onGraphicMoveStartCallback(t),onGraphicMove:t=>this._onGraphicMoveCallback(t),onGraphicMoveStop:t=>this._onGraphicMoveStopCallback(t),onGraphicPointerOver:t=>this._onGraphicPointerOverCallback(t),onGraphicPointerOut:t=>this._onGraphicPointerOutCallback(t)}})}_setCursor(t){this.addHandles(this.view.acquireCursor(t,"high"),Y)}_getStartInfo(t){const[e,i,s,o]=this._getBoxBounds(g()),r=Math.abs(s-e),a=Math.abs(o-i),h=(s+e)/2,c=(o+i)/2,{x:n,y:l}=t.geometry;return{width:r,height:a,centerX:h,centerY:c,startX:n,startY:l,graphicInfos:this._getGraphicInfos(),box:this._backgroundGraphic.geometry,rotate:this._rotateHandleGraphic.geometry}}_getGraphicInfos(){return this.graphics.map(t=>this._getGraphicInfo(t))}_getGraphicInfo(t){const e=t.geometry,[i,s,o,r]=this._getBounds(g(),[e]);return{width:Math.abs(o-i),height:Math.abs(r-s),centerX:(o+i)/2,centerY:(r+s)/2,geometry:e}}_onGraphicClickCallback(t){t.viewEvent.stopPropagation(),this.emit("graphic-click",t),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(t)}_onGraphicMoveStartCallback(t){const{_angleOfRotation:e,_xScale:i,_yScale:s,_backgroundGraphic:o,_vertexGraphics:r,_rotateHandleGraphic:a,symbols:h,graphics:c}=this,{graphic:n,dx:l,dy:p,viewEvent:_}=t;this._resetGraphicStateVars(),this._hideGraphicsBeforeUpdate(),o.symbol=h.fill.active,this._startInfo=this._getStartInfo(n),this._updateTooltip(n,_),n===a?(this._setCursor("grabbing"),this.emit("rotate-start",{type:"rotate-start",mover:n,graphics:c,angle:e})):r.includes(n)?(this._activeHandleGraphic=n,this.emit("scale-start",{type:"scale-start",mover:n,graphics:c,xScale:i,yScale:s})):this.emit("move-start",{type:"move-start",graphics:c,mover:n,dx:l,dy:p})}_onGraphicMoveCallback(t){const e=t.graphic;if(!this._startInfo)return;const{_xScale:i,_yScale:s,_angleOfRotation:o,graphics:r}=this;if(this._vertexGraphics.includes(e))this._scaleGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("scale",{type:"scale",graphics:r,mover:e,xScale:i,yScale:s});else if(e===this._rotateHandleGraphic)this._rotateGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("rotate",{type:"rotate",graphics:r,mover:e,angle:o});else{const{dx:i,dy:s}=t;this._totalDx+=i,this._totalDy+=s,this._moveGraphic(e,i,s),this._updateTooltip(e,t.viewEvent),this.emit("move",{type:"move",graphics:r,mover:e,dx:i,dy:s})}}_onGraphicMoveStopCallback(t){const e=t.graphic;if(!this._startInfo)return void this.refresh();const{_angleOfRotation:i,_totalDx:s,_totalDy:o,_xScale:r,_yScale:a,_vertexGraphics:h,_rotateHandleGraphic:c,graphics:n}=this;this.refresh(),e===c?(this._setCursor("pointer"),this.emit("rotate-stop",{type:"rotate-stop",graphics:n,mover:e,angle:i})):h.includes(e)?this.emit("scale-stop",{type:"scale-stop",mover:e,graphics:n,xScale:r,yScale:a}):this.emit("move-stop",{type:"move-stop",graphics:n,mover:e,dx:s,dy:o})}_onGraphicPointerOverCallback(t){const{_backgroundGraphic:e,_vertexGraphics:i,graphics:s,_rotateHandleGraphic:o,symbols:r,view:a}=this,h=t.graphic;if(this._hoveredGraphic=h,h===o)return o.symbol=r.rotator.hover,this._setCursor("pointer"),void this._updateTooltip(h);if(s.includes(h)||h===e)return void this._setCursor("move");if(!i.includes(h))return void this._setCursor("pointer");this._updateTooltip(h),t.graphic.symbol=r.handles.hover;const c=a.rotation;let n,l=t.index;switch(l<8&&(c>=0&&c<45?l%=8:l=c>=45&&c<90?(l+1)%8:c>=90&&c<135?(l+2)%8:c>=135&&c<180?(l+3)%8:c>=180&&c<225?(l+4)%8:c>=225&&c<270?(l+5)%8:c>=270&&c<315?(l+6)%8:(l+7)%8),l){case 0:case 4:n="nwse-resize";break;case 1:case 5:n="ns-resize";break;case 2:case 6:n="nesw-resize";break;case 3:case 7:n="ew-resize";break;default:n="pointer"}this._setCursor(n)}_onGraphicPointerOutCallback(t){const{_vertexGraphics:e,_rotateHandleGraphic:i,symbols:s}=this;this._hoveredGraphic=null,t.graphic===i?i.symbol=s.rotator.default:e.includes(t.graphic)&&(t.graphic.symbol=s.handles.default),this.removeHandles(Y),this._updateTooltip()}_scaleGraphic(t){const{_startInfo:e,_vertexGraphics:i,preserveAspectRatio:s,view:o}=this,{centerX:r,centerY:a,graphicInfos:h,height:c,startX:n,startY:l,width:p}=e,{resolution:_,transform:m}=o.state,u=i.indexOf(t);1!==u&&5!==u||this._updateX(t,r),3!==u&&7!==u||this._updateY(t,a);const{x:g,y}=t.geometry,v=m[0]*g+m[2]*y+m[4],f=m[1]*g+m[3]*y+m[5],G=h?.map(t=>t.geometry)??[],b=G.every(t=>"point"===t.type);if((0===p||0===c)&&b){const t=P((g-n)/_),i=P((l-y)/_);for(let e=0;e<G.length;e++)this.graphics[e].geometry=w(G[e],t,i,o,!0);return this._centerGraphic.geometry=new d(g,y,o.spatialReference),void(this._backgroundGraphic.geometry=w(e.box,t,i,o,!0))}if(s){const t=P(m[0]*r+m[2]*a+m[4],2),e=P(m[1]*r+m[3]*a+m[5],2),i=P(m[0]*n+m[2]*l+m[4],2),s=P(m[1]*n+m[3]*l+m[5],2);let o=R(t,e,i,s,v,f);0!==o&&Math.abs(o)!==1/0||(o=1),this._xScale=this._yScale=o;for(const h of G){const t=G.indexOf(h);this.graphics[t].geometry=S(h,this._xScale,this._yScale,[r,a])}this._updateBackgroundGraphic()}else{let t=g-n,i=l-y;if(1===u||5===u?t=0:3!==u&&7!==u||(i=0),0===t&&0===i)return;const s=r+t/2,h=a+i/2;let m=(p+(n>r?t:-1*t))/p,v=(c+(l<a?i:-1*i))/c;1!==u&&5!==u&&0!==m&&Math.abs(m)!==1/0||(m=1),3!==u&&7!==u&&0!==v&&Math.abs(v)!==1/0||(v=1),this._xScale=m,this._yScale=v;const f=(s-r)/_,b=(h-a)/_,x=S(e.box,this._xScale,this._yScale);this._backgroundGraphic.geometry=w(x,f,b,o,!0);const{centerX:k,centerY:R}=this._getGraphicInfo(this._backgroundGraphic),H=(k-r)/_,I=-1*(R-a)/_;for(const e of G){const t=G.indexOf(e),i=S(e,this._xScale,this._yScale,[r,a]);this.graphics[t].geometry=w(i,H,I,o,!0)}this._centerGraphic.geometry=new d(k,R,o.spatialReference)}}_rotateGraphic(t){const{centerX:e,centerY:i,startX:s,startY:o,box:r,rotate:a}=this._startInfo,h=this.view.spatialReference,c=new d(s,o,h),n=new d(e,i,h),l=t.geometry;this._angleOfRotation=k(c,l,n);const p=this._startInfo.graphicInfos?.map(t=>t.geometry)??[];for(const _ of p){const t=p.indexOf(_),e=f(_,this._angleOfRotation,n);this.graphics[t].geometry=e}this._backgroundGraphic.geometry=f(r,this._angleOfRotation,n),this._rotateHandleGraphic.geometry=f(a,this._angleOfRotation,n)}_moveGraphic(t,e,i){if(this.graphics.includes(t)){const s=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=w(s,e,i,this.view);for(const o of this.graphics)o!==t&&(o.geometry=w(o.geometry,e,i,this.view))}else if(t===this._centerGraphic){const t=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=w(t,e,i,this.view)}if(t===this._backgroundGraphic||t===this._centerGraphic)for(const s of this.graphics)s.geometry=w(s.geometry,e,i,this.view)}_setUpHighlights(){this.highlightsEnabled&&this.graphics.length&&this._highlightHelper?.add(this.graphics,this.highlightName)}_setupGraphics(){const{_graphicAttributes:t,symbols:i}=this;this._centerGraphic=new e({symbol:i.centerIndicator,attributes:t}),this.showCenterGraphic&&this.layer.add(this._centerGraphic),this._backgroundGraphic=new e({symbol:i.fill.default,attributes:t}),this.layer.add(this._backgroundGraphic),this._rotateLineGraphic=new e({symbol:i.rotatorLine,attributes:t}),this._rotateHandleGraphic=new e({symbol:i.rotator.default,attributes:t}),this.enableRotation&&!this._hasExtentGraphic()&&this.layer.addMany([this._rotateLineGraphic,this._rotateHandleGraphic]);for(let s=0;s<8;s++)this._vertexGraphics.push(new e({symbol:i.handles.default,attributes:t}));this.enableScaling&&this.layer.addMany(this._vertexGraphics)}_updateSymbolsForTheme(){const t=this.view.effectiveTheme.accentColor;this.symbols={...this.symbols,fill:{active:this.symbols.fill.active?.clone().set("outline.color",t),default:this.symbols.fill.default?.clone().set("outline.color",t)},handles:{...this.symbols.handles,default:this.symbols.handles.default.clone().set("outline.color",t)},rotator:{...this.symbols.rotator,default:this.symbols.rotator.default.clone().set("outline.color",t)},rotatorLine:this.symbols.rotatorLine.clone().set("color",t)};for(const e of this._vertexGraphics)e.symbol=e===this._hoveredGraphic?this.symbols.handles.hover:this.symbols.handles.default;this._backgroundGraphic.symbol=this.symbols.fill.default,this._rotateHandleGraphic.symbol=this._rotateHandleGraphic===this._hoveredGraphic?this.symbols.rotator.hover:this.symbols.rotator.default,this._rotateLineGraphic.symbol=this.symbols.rotatorLine}_updateGraphics(){this._updateBackgroundGraphic(),this._updateHandleGraphics(),this._updateCenterGraphic(),this._updateRotateGraphic(),this._updateRotateLineGraphic()}_hideGraphicsBeforeUpdate(){this._centerGraphic.visible=!1,this._rotateHandleGraphic.visible=!1,this._rotateLineGraphic.visible=!1,this._vertexGraphics.forEach(t=>t.visible=!1)}_updateHandleGraphics(){const t=this._getCoordinates(!0);this._vertexGraphics.forEach((e,i)=>{const[s,o]=t[i];this._updateXY(e,s,o)})}_updateBackgroundGraphic(){const t=this._getCoordinates().map(([t,e])=>[t,e]);this._backgroundGraphic.geometry=new m({rings:[t],spatialReference:this.view.spatialReference})}_updateCenterGraphic(){const[t,e,i,s]=this._getBoxBounds(g()),o=(i+t)/2,r=(s+e)/2;this._centerGraphic.geometry=new d(o,r,this.view.spatialReference)}_updateRotateGraphic(){if(!this._vertexGraphics.length)return;const{x:t,y:e}=this._vertexGraphics[1].geometry,i=e+this.view.state.resolution*this._rotateGraphicOffset;this._rotateHandleGraphic.geometry=new d(t,i,this.view.spatialReference)}_updateRotateLineGraphic(){if(!this._vertexGraphics.length||!this._rotateHandleGraphic?.geometry)return;const t=this._vertexGraphics[1].geometry,e=this._rotateHandleGraphic.geometry;this._rotateLineGraphic.geometry=new u({paths:[[[t.x,t.y],[e.x,e.y]]],spatialReference:this.view.spatialReference})}_updateXY(t,e,i){t.geometry=new d(e,i,this.view.spatialReference)}_updateX(t,e){const i=t.geometry.y;t.geometry=new d(e,i,this.view.spatialReference)}_updateY(t,e){const i=t.geometry.x;t.geometry=new d(i,e,this.view.spatialReference)}_hasExtentGraphic(){return this.graphics.some(t=>null!=t?.geometry&&"extent"===t.geometry.type)}_getBoxBounds(t){const e=this.graphics.map(t=>t.geometry);return this._getBounds(t,e)}_getCoordinates(t){const[e,i,s,o]=this._getBoxBounds(g());if(t){const t=(e+s)/2,r=(o+i)/2;return[[e,o],[t,o],[s,o],[s,r],[s,i],[t,i],[e,i],[e,r]]}return[[e,o],[s,o],[s,i],[e,i]]}_updateTooltip(t,e){if(null==this.tooltip)return;if(!t)return void this.tooltip.clear();const{_backgroundGraphic:i,graphics:s,_vertexGraphics:o,_rotateHandleGraphic:r}=this;t===r?this._updateRotateTooltip():o.includes(t)?this._updateScaleTooltip():(s.includes(t)||t===i)&&this._updateMoveTooltip(e)}_updateRotateTooltip(){null!=this.tooltip&&(this.tooltip.info=new j({sketchOptions:this.sketchOptions,angle:-this._angleOfRotation}))}_updateScaleTooltip(){const{tooltip:t,_xScale:e,_yScale:i,sketchOptions:s}=this;if(null==t)return;const o=Math.abs(e),r=Math.abs(i),a=this._extentScaleTooltipInfo;a.sketchOptions=s,a.xScale=o,a.yScale=r,this._updatingHandles.consumePromise(this._updateScaleTooltipAsync()),t.info=a}_updateMoveTooltip(t){const{tooltip:e}=this;if(null==e)return;const i=this._translateTooltipInfo;this._updatingHandles.consumePromise(this._updateMoveTooltipAsync(t)),e.info=i}};function P(t,e=2){return Number.parseFloat(t.toFixed(e))}t([l()],A.prototype,"tooltip",void 0),t([l({readOnly:!0})],A.prototype,"type",void 0),t([l()],A.prototype,"callbacks",void 0),t([l()],A.prototype,"enableMovement",void 0),t([l()],A.prototype,"enableRotation",void 0),t([l()],A.prototype,"enableScaling",void 0),t([l()],A.prototype,"graphics",void 0),t([l()],A.prototype,"highlightName",void 0),t([l()],A.prototype,"highlightsEnabled",void 0),t([l()],A.prototype,"layer",void 0),t([l()],A.prototype,"preserveAspectRatio",void 0),t([l()],A.prototype,"showCenterGraphic",void 0),t([l({readOnly:!0})],A.prototype,"state",null),t([l()],A.prototype,"symbols",void 0),t([l({type:T})],A.prototype,"sketchOptions",void 0),t([l({constructOnly:!0})],A.prototype,"view",void 0),A=t([p("esri.views.draw.support.Box")],A);const U=A;export{U as default};
2
+ import{__decorate as t}from"tslib";import e from"../../../Graphic.js";import{EventedAccessor as i}from"../../../core/Evented.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{debounce as s}from"../../../core/promiseUtils.js";import{zeroMeters as r}from"../../../core/quantity.js";import{when as a,watch as h,syncAndInitial as n,initial as c}from"../../../core/reactiveUtils.js";import{property as l,subclass as p}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as _}from"../../../core/support/UpdatingHandles.js";import d from"../../../geometry/Point.js";import m from"../../../geometry/Polygon.js";import u from"../../../geometry/Polyline.js";import{create as g,center as y}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as v}from"../../../geometry/support/boundsUtils.js";import f from"../../../geometry/support/rotate.js";import G from"../../../symbols/SimpleFillSymbol.js";import b from"../../../symbols/SimpleLineSymbol.js";import x from"../../../symbols/SimpleMarkerSymbol.js";import{cloneMove as w,scale as S,getRotationAngle as k,getScaleRatio as R}from"./drawUtils.js";import H from"./GraphicMover.js";import I from"./HighlightHelper.js";import{addUniqueLayer as C}from"./layerUtils.js";import{settings as M}from"./settings.js";import T from"../../interactive/options/InteractiveToolOptions.js";import{makeTooltip as O}from"../../interactive/tooltip/tooltipCommonUtils.js";import{ExtentRotateTooltipInfo as j}from"../../interactive/tooltip/infos/ExtentRotateTooltipInfo.js";import{ExtentScaleTooltipInfo as E}from"../../interactive/tooltip/infos/ExtentScaleTooltipInfo.js";import{TranslateTooltipInfo as B}from"../../interactive/tooltip/infos/TranslateTooltipInfo.js";import{GeometryWorkerHandle as L}from"../../support/GeometryWorkerHandle.js";const N=M.transformGraphics,z={centerIndicator:new x({style:"cross",size:N.center.size,color:N.center.color}),fill:{default:new G({color:N.fill.color,outline:{color:N.fill.outlineColor,join:"round",width:1}}),active:new G({color:N.fill.stagedColor,outline:{color:N.fill.outlineColor,join:"round",style:"dash",width:1}})},handles:{default:new x({style:"square",size:N.vertex.size,color:N.vertex.color,outline:{color:N.vertex.outlineColor,width:1}}),hover:new x({style:"square",size:N.vertex.hoverSize,color:N.vertex.hoverColor,outline:{color:N.vertex.hoverOutlineColor,width:1}})},rotator:{default:new x({style:"circle",size:N.vertex.size,color:N.vertex.color,outline:{color:N.vertex.outlineColor,width:1}}),hover:new x({style:"circle",size:N.vertex.hoverSize,color:N.vertex.hoverColor,outline:{color:N.vertex.hoverOutlineColor,width:1}})},rotatorLine:new b({color:N.line.color,width:1})},Y=Symbol();let A=class extends i{constructor(t){super(t),this._activeHandleGraphic=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._centerGraphic=null,this._backgroundGraphic=null,this._vertexGraphics=[],this._rotateHandleGraphic=null,this._rotateGraphicOffset=20,this._angleOfRotation=0,this._rotateLineGraphic=null,this._startInfo=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this.tooltip=null,this.type="box",this.callbacks={onMoveStart(){},onMove(){},onMoveStop(){},onScaleStart(){},onScale(){},onScaleStop(){},onRotateStart(){},onRotate(){},onRotateStop(){},onGraphicClick(){}},this.enableMovement=!0,this.enableRotation=!0,this.enableScaling=!0,this.graphics=[],this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.preserveAspectRatio=!1,this.showCenterGraphic=!0,this.symbols=z,this.toolOptions=new T,this.view=null,this._updatingHandles=new _,this._getBounds=(()=>{const t=g();return(e,i)=>{e[0]=Number.POSITIVE_INFINITY,e[1]=Number.POSITIVE_INFINITY,e[2]=Number.NEGATIVE_INFINITY,e[3]=Number.NEGATIVE_INFINITY;for(const o of i){if(!o)continue;let i,s,r,a;if("point"===o.type)i=r=o.x,s=a=o.y;else if("extent"===o.type)[i,s,r,a]=[o.xmin,o.ymin,o.xmax,o.ymax];else{const e=v(t,o);[i,s,r,a]=e}e[0]=Math.min(i,e[0]),e[1]=Math.min(s,e[1]),e[2]=Math.max(r,e[2]),e[3]=Math.max(a,e[3])}return e}})(),this._extentScaleTooltipInfo=new E({toolOptions:this.toolOptions}),this._measurementWorker=new L({preloadGeodetic:!0}),this._updateScaleTooltipAsync=s(async()=>{const t=this._getCoordinates(),e=this.view.spatialReference,{width:i,height:o}=await this._measurementWorker.autoSize2D(new d({x:t[0][0],y:t[0][1],spatialReference:e}),new d({x:t[1][0],y:t[1][1],spatialReference:e}),new d({x:t[2][0],y:t[2][1],spatialReference:e}),new d({x:t[3][0],y:t[3][1],spatialReference:e}));this._extentScaleTooltipInfo.xSize=i,this._extentScaleTooltipInfo.ySize=o}),this._translateTooltipInfo=new B({toolOptions:this.toolOptions}),this._updateMoveTooltipAsync=s(async t=>{const{view:e}=this,i=this._translateTooltipInfo;if(!t)return void(i.distance=r);const{x:o,y:s}=t.origin,a=e.toMap(t),h=e.toMap({x:o,y:s}),n=await this._measurementWorker.autoDistance2DBetweenPoints(h,a);i.distance=null!=n?n:r})}initialize(){const t=this.view;this._highlightHelper=new I({view:t}),this._setup(),this.addHandles([a(()=>t?.ready,()=>{const{layer:t,view:e}=this;C(e,t)},{once:!0,initial:!0}),h(()=>this.preserveAspectRatio,()=>{this._activeHandleGraphic&&(this._scaleGraphic(this._activeHandleGraphic),this._updateGraphics(),this._updateTooltip(this._activeHandleGraphic))}),h(()=>t?.scale,()=>{this._updateRotateGraphic(),this._updateRotateLineGraphic()}),h(()=>this.graphics,()=>this.refresh()),h(()=>this.layer,(t,e)=>{e&&this._resetGraphics(e),this.refresh()}),h(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),h(()=>this.toolOptions.tooltips.effectiveEnabled,e=>{this.tooltip=e?O(()=>({view:t,options:this.toolOptions.tooltips})):o(this.tooltip)},n),h(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),c),this.on("move-start",t=>this.callbacks?.onMoveStart?.(t)),this.on("move",t=>this.callbacks?.onMove?.(t)),this.on("move-stop",t=>this.callbacks?.onMoveStop?.(t)),this.on("rotate-start",t=>this.callbacks?.onRotateStart?.(t)),this.on("rotate",t=>this.callbacks?.onRotate?.(t)),this.on("rotate-stop",t=>this.callbacks?.onRotateStop?.(t)),this.on("scale-start",t=>this.callbacks?.onScaleStart?.(t)),this.on("scale",t=>this.callbacks?.onScale?.(t)),this.on("scale-stop",t=>this.callbacks?.onScaleStop?.(t))])}destroy(){this._reset(),this.tooltip=o(this.tooltip)}get state(){const t=this.view?.ready??!1,e=this.graphics.length&&this.layer;return t&&e?"active":t?"ready":"disabled"}get updating(){return this._updatingHandles.updating}isUIGraphic(t){return this._vertexGraphics.includes(t)||t===this._backgroundGraphic||t===this._centerGraphic||t===this._rotateHandleGraphic||t===this._rotateLineGraphic}move(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const o=i.geometry,s=w(o,t,e,this.view);i.geometry=s}this.refresh(),this.emit("move-stop",{graphics:this.graphics,mover:null,dx:t,dy:e,type:"move-stop"})}}scale(t,e){if(!this._mover||!this.graphics.length)return;const i=this._getBoxBounds(g()),o=y(i);for(const s of this.graphics){const i=s.geometry,r=S(i,t,e,o);s.geometry=r}this.refresh(),this.emit("scale-stop",{graphics:this.graphics,mover:null,xScale:t,yScale:e,type:"scale-stop"})}rotate(t,e){if(this._mover&&this.graphics.length){if(!e){const t=this._vertexGraphics[1].geometry.x,i=this._vertexGraphics[3].geometry.y;e=new d(t,i,this.view.spatialReference)}for(const i of this.graphics){const o=i.geometry,s=f(o,t,e);i.geometry=s}this.refresh(),this.emit("rotate-stop",{graphics:this.graphics,mover:null,angle:t,type:"rotate-stop"})}}refresh(){this._reset(),this._setup()}reset(){this.graphics=[]}_setup(){"active"===this.state&&(this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._updateGraphics())}_reset(){this._highlightHelper?.removeAll(),this._resetGraphicStateVars(),this._resetGraphics(),this._updateTooltip(),this._mover?.destroy(),this._mover=null,this.removeHandles(Y)}_resetGraphicStateVars(){this._startInfo=null,this._activeHandleGraphic=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this._angleOfRotation=0}_resetGraphics(t){(t=t||this.layer)&&(t.removeMany(this._vertexGraphics),t.remove(this._backgroundGraphic),t.remove(this._centerGraphic),t.remove(this._rotateHandleGraphic),t.remove(this._rotateLineGraphic)),this._vertexGraphics.forEach(t=>!t.destroyed&&t.destroy()),!this._backgroundGraphic.destroyed&&this._backgroundGraphic.destroy(),!this._centerGraphic.destroyed&&this._centerGraphic.destroy(),!this._rotateHandleGraphic.destroyed&&this._rotateHandleGraphic.destroy(),!this._rotateLineGraphic.destroyed&&this._rotateLineGraphic.destroy(),this._vertexGraphics=[],this._backgroundGraphic=null,this._centerGraphic=null,this._rotateHandleGraphic=null,this._rotateLineGraphic=null}_setupMover(){let t=[];this.enableScaling&&(t=t.concat(this._vertexGraphics)),this.enableRotation&&t.push(this._rotateHandleGraphic),this.enableMovement&&(t=t.concat(this.graphics,this._backgroundGraphic)),this.showCenterGraphic&&t.push(this._centerGraphic),this._mover=new H({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,view:this.view,graphics:t,callbacks:{onGraphicClick:t=>this._onGraphicClickCallback(t),onGraphicMoveStart:t=>this._onGraphicMoveStartCallback(t),onGraphicMove:t=>this._onGraphicMoveCallback(t),onGraphicMoveStop:t=>this._onGraphicMoveStopCallback(t),onGraphicPointerOver:t=>this._onGraphicPointerOverCallback(t),onGraphicPointerOut:t=>this._onGraphicPointerOutCallback(t)}})}_setCursor(t){this.addHandles(this.view.acquireCursor(t,"high"),Y)}_getStartInfo(t){const[e,i,o,s]=this._getBoxBounds(g()),r=Math.abs(o-e),a=Math.abs(s-i),h=(o+e)/2,n=(s+i)/2,{x:c,y:l}=t.geometry;return{width:r,height:a,centerX:h,centerY:n,startX:c,startY:l,graphicInfos:this._getGraphicInfos(),box:this._backgroundGraphic.geometry,rotate:this._rotateHandleGraphic.geometry}}_getGraphicInfos(){return this.graphics.map(t=>this._getGraphicInfo(t))}_getGraphicInfo(t){const e=t.geometry,[i,o,s,r]=this._getBounds(g(),[e]);return{width:Math.abs(s-i),height:Math.abs(r-o),centerX:(s+i)/2,centerY:(r+o)/2,geometry:e}}_onGraphicClickCallback(t){t.viewEvent.stopPropagation(),this.emit("graphic-click",t),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(t)}_onGraphicMoveStartCallback(t){const{_angleOfRotation:e,_xScale:i,_yScale:o,_backgroundGraphic:s,_vertexGraphics:r,_rotateHandleGraphic:a,symbols:h,graphics:n}=this,{graphic:c,dx:l,dy:p,viewEvent:_}=t;this._resetGraphicStateVars(),this._hideGraphicsBeforeUpdate(),s.symbol=h.fill.active,this._startInfo=this._getStartInfo(c),this._updateTooltip(c,_),c===a?(this._setCursor("grabbing"),this.emit("rotate-start",{type:"rotate-start",mover:c,graphics:n,angle:e})):r.includes(c)?(this._activeHandleGraphic=c,this.emit("scale-start",{type:"scale-start",mover:c,graphics:n,xScale:i,yScale:o})):this.emit("move-start",{type:"move-start",graphics:n,mover:c,dx:l,dy:p})}_onGraphicMoveCallback(t){const e=t.graphic;if(!this._startInfo)return;const{_xScale:i,_yScale:o,_angleOfRotation:s,graphics:r}=this;if(this._vertexGraphics.includes(e))this._scaleGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("scale",{type:"scale",graphics:r,mover:e,xScale:i,yScale:o});else if(e===this._rotateHandleGraphic)this._rotateGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("rotate",{type:"rotate",graphics:r,mover:e,angle:s});else{const{dx:i,dy:o}=t;this._totalDx+=i,this._totalDy+=o,this._moveGraphic(e,i,o),this._updateTooltip(e,t.viewEvent),this.emit("move",{type:"move",graphics:r,mover:e,dx:i,dy:o})}}_onGraphicMoveStopCallback(t){const e=t.graphic;if(!this._startInfo)return void this.refresh();const{_angleOfRotation:i,_totalDx:o,_totalDy:s,_xScale:r,_yScale:a,_vertexGraphics:h,_rotateHandleGraphic:n,graphics:c}=this;this.refresh(),e===n?(this._setCursor("pointer"),this.emit("rotate-stop",{type:"rotate-stop",graphics:c,mover:e,angle:i})):h.includes(e)?this.emit("scale-stop",{type:"scale-stop",mover:e,graphics:c,xScale:r,yScale:a}):this.emit("move-stop",{type:"move-stop",graphics:c,mover:e,dx:o,dy:s})}_onGraphicPointerOverCallback(t){const{_backgroundGraphic:e,_vertexGraphics:i,graphics:o,_rotateHandleGraphic:s,symbols:r,view:a}=this,h=t.graphic;if(this._hoveredGraphic=h,h===s)return s.symbol=r.rotator.hover,this._setCursor("pointer"),void this._updateTooltip(h);if(o.includes(h)||h===e)return void this._setCursor("move");if(!i.includes(h))return void this._setCursor("pointer");this._updateTooltip(h),t.graphic.symbol=r.handles.hover;const n=a.rotation;let c,l=t.index;switch(l<8&&(n>=0&&n<45?l%=8:l=n>=45&&n<90?(l+1)%8:n>=90&&n<135?(l+2)%8:n>=135&&n<180?(l+3)%8:n>=180&&n<225?(l+4)%8:n>=225&&n<270?(l+5)%8:n>=270&&n<315?(l+6)%8:(l+7)%8),l){case 0:case 4:c="nwse-resize";break;case 1:case 5:c="ns-resize";break;case 2:case 6:c="nesw-resize";break;case 3:case 7:c="ew-resize";break;default:c="pointer"}this._setCursor(c)}_onGraphicPointerOutCallback(t){const{_vertexGraphics:e,_rotateHandleGraphic:i,symbols:o}=this;this._hoveredGraphic=null,t.graphic===i?i.symbol=o.rotator.default:e.includes(t.graphic)&&(t.graphic.symbol=o.handles.default),this.removeHandles(Y),this._updateTooltip()}_scaleGraphic(t){const{_startInfo:e,_vertexGraphics:i,preserveAspectRatio:o,view:s}=this,{centerX:r,centerY:a,graphicInfos:h,height:n,startX:c,startY:l,width:p}=e,{resolution:_,transform:m}=s.state,u=i.indexOf(t);1!==u&&5!==u||this._updateX(t,r),3!==u&&7!==u||this._updateY(t,a);const{x:g,y}=t.geometry,v=m[0]*g+m[2]*y+m[4],f=m[1]*g+m[3]*y+m[5],G=h?.map(t=>t.geometry)??[],b=G.every(t=>"point"===t.type);if((0===p||0===n)&&b){const t=P((g-c)/_),i=P((l-y)/_);for(let e=0;e<G.length;e++)this.graphics[e].geometry=w(G[e],t,i,s,!0);return this._centerGraphic.geometry=new d(g,y,s.spatialReference),void(this._backgroundGraphic.geometry=w(e.box,t,i,s,!0))}if(o){const t=P(m[0]*r+m[2]*a+m[4],2),e=P(m[1]*r+m[3]*a+m[5],2),i=P(m[0]*c+m[2]*l+m[4],2),o=P(m[1]*c+m[3]*l+m[5],2);let s=R(t,e,i,o,v,f);0!==s&&Math.abs(s)!==1/0||(s=1),this._xScale=this._yScale=s;for(const h of G){const t=G.indexOf(h);this.graphics[t].geometry=S(h,this._xScale,this._yScale,[r,a])}this._updateBackgroundGraphic()}else{let t=g-c,i=l-y;if(1===u||5===u?t=0:3!==u&&7!==u||(i=0),0===t&&0===i)return;const o=r+t/2,h=a+i/2;let m=(p+(c>r?t:-1*t))/p,v=(n+(l<a?i:-1*i))/n;1!==u&&5!==u&&0!==m&&Math.abs(m)!==1/0||(m=1),3!==u&&7!==u&&0!==v&&Math.abs(v)!==1/0||(v=1),this._xScale=m,this._yScale=v;const f=(o-r)/_,b=(h-a)/_,x=S(e.box,this._xScale,this._yScale);this._backgroundGraphic.geometry=w(x,f,b,s,!0);const{centerX:k,centerY:R}=this._getGraphicInfo(this._backgroundGraphic),H=(k-r)/_,I=-1*(R-a)/_;for(const e of G){const t=G.indexOf(e),i=S(e,this._xScale,this._yScale,[r,a]);this.graphics[t].geometry=w(i,H,I,s,!0)}this._centerGraphic.geometry=new d(k,R,s.spatialReference)}}_rotateGraphic(t){const{centerX:e,centerY:i,startX:o,startY:s,box:r,rotate:a}=this._startInfo,h=this.view.spatialReference,n=new d(o,s,h),c=new d(e,i,h),l=t.geometry;this._angleOfRotation=k(n,l,c);const p=this._startInfo.graphicInfos?.map(t=>t.geometry)??[];for(const _ of p){const t=p.indexOf(_),e=f(_,this._angleOfRotation,c);this.graphics[t].geometry=e}this._backgroundGraphic.geometry=f(r,this._angleOfRotation,c),this._rotateHandleGraphic.geometry=f(a,this._angleOfRotation,c)}_moveGraphic(t,e,i){if(this.graphics.includes(t)){const o=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=w(o,e,i,this.view);for(const s of this.graphics)s!==t&&(s.geometry=w(s.geometry,e,i,this.view))}else if(t===this._centerGraphic){const t=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=w(t,e,i,this.view)}if(t===this._backgroundGraphic||t===this._centerGraphic)for(const o of this.graphics)o.geometry=w(o.geometry,e,i,this.view)}_setUpHighlights(){this.highlightsEnabled&&this.graphics.length&&this._highlightHelper?.add(this.graphics,this.highlightName)}_setupGraphics(){const{_graphicAttributes:t,symbols:i}=this;this._centerGraphic=new e({symbol:i.centerIndicator,attributes:t}),this.showCenterGraphic&&this.layer.add(this._centerGraphic),this._backgroundGraphic=new e({symbol:i.fill.default,attributes:t}),this.layer.add(this._backgroundGraphic),this._rotateLineGraphic=new e({symbol:i.rotatorLine,attributes:t}),this._rotateHandleGraphic=new e({symbol:i.rotator.default,attributes:t}),this.enableRotation&&!this._hasExtentGraphic()&&this.layer.addMany([this._rotateLineGraphic,this._rotateHandleGraphic]);for(let o=0;o<8;o++)this._vertexGraphics.push(new e({symbol:i.handles.default,attributes:t}));this.enableScaling&&this.layer.addMany(this._vertexGraphics)}_updateSymbolsForTheme(){const t=this.view.effectiveTheme.accentColor;this.symbols={...this.symbols,fill:{active:this.symbols.fill.active?.clone().set("outline.color",t),default:this.symbols.fill.default?.clone().set("outline.color",t)},handles:{...this.symbols.handles,default:this.symbols.handles.default.clone().set("outline.color",t)},rotator:{...this.symbols.rotator,default:this.symbols.rotator.default.clone().set("outline.color",t)},rotatorLine:this.symbols.rotatorLine.clone().set("color",t)};for(const e of this._vertexGraphics)e.symbol=e===this._hoveredGraphic?this.symbols.handles.hover:this.symbols.handles.default;this._backgroundGraphic.symbol=this.symbols.fill.default,this._rotateHandleGraphic.symbol=this._rotateHandleGraphic===this._hoveredGraphic?this.symbols.rotator.hover:this.symbols.rotator.default,this._rotateLineGraphic.symbol=this.symbols.rotatorLine}_updateGraphics(){this._updateBackgroundGraphic(),this._updateHandleGraphics(),this._updateCenterGraphic(),this._updateRotateGraphic(),this._updateRotateLineGraphic()}_hideGraphicsBeforeUpdate(){this._centerGraphic.visible=!1,this._rotateHandleGraphic.visible=!1,this._rotateLineGraphic.visible=!1,this._vertexGraphics.forEach(t=>t.visible=!1)}_updateHandleGraphics(){const t=this._getCoordinates(!0);this._vertexGraphics.forEach((e,i)=>{const[o,s]=t[i];this._updateXY(e,o,s)})}_updateBackgroundGraphic(){const t=this._getCoordinates().map(([t,e])=>[t,e]);this._backgroundGraphic.geometry=new m({rings:[t],spatialReference:this.view.spatialReference})}_updateCenterGraphic(){const[t,e,i,o]=this._getBoxBounds(g()),s=(i+t)/2,r=(o+e)/2;this._centerGraphic.geometry=new d(s,r,this.view.spatialReference)}_updateRotateGraphic(){if(!this._vertexGraphics.length)return;const{x:t,y:e}=this._vertexGraphics[1].geometry,i=e+this.view.state.resolution*this._rotateGraphicOffset;this._rotateHandleGraphic.geometry=new d(t,i,this.view.spatialReference)}_updateRotateLineGraphic(){if(!this._vertexGraphics.length||!this._rotateHandleGraphic?.geometry)return;const t=this._vertexGraphics[1].geometry,e=this._rotateHandleGraphic.geometry;this._rotateLineGraphic.geometry=new u({paths:[[[t.x,t.y],[e.x,e.y]]],spatialReference:this.view.spatialReference})}_updateXY(t,e,i){t.geometry=new d(e,i,this.view.spatialReference)}_updateX(t,e){const i=t.geometry.y;t.geometry=new d(e,i,this.view.spatialReference)}_updateY(t,e){const i=t.geometry.x;t.geometry=new d(i,e,this.view.spatialReference)}_hasExtentGraphic(){return this.graphics.some(t=>null!=t?.geometry&&"extent"===t.geometry.type)}_getBoxBounds(t){const e=this.graphics.map(t=>t.geometry);return this._getBounds(t,e)}_getCoordinates(t){const[e,i,o,s]=this._getBoxBounds(g());if(t){const t=(e+o)/2,r=(s+i)/2;return[[e,s],[t,s],[o,s],[o,r],[o,i],[t,i],[e,i],[e,r]]}return[[e,s],[o,s],[o,i],[e,i]]}_updateTooltip(t,e){if(null==this.tooltip)return;if(!t)return void this.tooltip.clear();const{_backgroundGraphic:i,graphics:o,_vertexGraphics:s,_rotateHandleGraphic:r}=this;t===r?this._updateRotateTooltip():s.includes(t)?this._updateScaleTooltip():(o.includes(t)||t===i)&&this._updateMoveTooltip(e)}_updateRotateTooltip(){null!=this.tooltip&&(this.tooltip.info=new j({toolOptions:this.toolOptions,angle:-this._angleOfRotation}))}_updateScaleTooltip(){const{tooltip:t,_xScale:e,_yScale:i,toolOptions:o}=this;if(null==t)return;const s=Math.abs(e),r=Math.abs(i),a=this._extentScaleTooltipInfo;a.toolOptions=o,a.xScale=s,a.yScale=r,this._updatingHandles.consumePromise(this._updateScaleTooltipAsync()),t.info=a}_updateMoveTooltip(t){const{tooltip:e}=this;if(null==e)return;const i=this._translateTooltipInfo;this._updatingHandles.consumePromise(this._updateMoveTooltipAsync(t)),e.info=i}};function P(t,e=2){return Number.parseFloat(t.toFixed(e))}t([l()],A.prototype,"tooltip",void 0),t([l({readOnly:!0})],A.prototype,"type",void 0),t([l()],A.prototype,"callbacks",void 0),t([l()],A.prototype,"enableMovement",void 0),t([l()],A.prototype,"enableRotation",void 0),t([l()],A.prototype,"enableScaling",void 0),t([l()],A.prototype,"graphics",void 0),t([l()],A.prototype,"highlightName",void 0),t([l()],A.prototype,"highlightsEnabled",void 0),t([l()],A.prototype,"layer",void 0),t([l()],A.prototype,"preserveAspectRatio",void 0),t([l()],A.prototype,"showCenterGraphic",void 0),t([l({readOnly:!0})],A.prototype,"state",null),t([l()],A.prototype,"symbols",void 0),t([l({type:T})],A.prototype,"toolOptions",void 0),t([l({constructOnly:!0})],A.prototype,"view",void 0),A=t([p("esri.views.draw.support.Box")],A);const U=A;export{U as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import n from"../../../core/Logger.js";import{memoize as i}from"../../../core/memoize.js";import{ignoreAbortErrors as o}from"../../../core/promiseUtils.js";import{valueInUnit as s}from"../../../core/quantity.js";import{createScreenPoint as r}from"../../../core/screenUtils.js";import{property as a,subclass as p}from"../../../core/accessorSupport/decorators.js";import{fromArray as l,create as u}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{normalize as c}from"../../../core/libs/gl-matrix-2/math/vec2.js";import g from"../../../geometry/Point.js";import{pointEquals as d}from"../../../layers/graphics/dehydratedFeatureComparison.js";import{makeDehydratedPoint as f}from"../../../layers/graphics/dehydratedPoint.js";import{getZFromVertexSnappingCandidates as h}from"./drawUtils.js";import{getPolylineOrPolygonConstraint as m,getPointConstraint as S,pointToConstraintSpace as P,constraintSpaceToPoint as y}from"../../interactive/sketch/constraintUtils.js";import{SnappingContext as v}from"../../interactive/snapping/SnappingContext.js";import{SnappingOperation as M}from"../../interactive/snapping/SnappingOperation.js";let T=class extends e{constructor(t){super(t),this._snappingOperation=null,this.role="primary",this.captureMode="capture-always",this.defaultCaptureMode="capture-always",this.snappingEnabled=!0,this.selfSnappingEnabled=!0,this.editSession=null,this.outputMapPositionOfDragStart=null,this.selectedSnappingResult=null,this.screenPosition=null,this.inputMapPosition=null,this.drawToolDragging=!1,this.manipulatorDragging=!1,this._getSnappingContext=i((t,e,n,i,o,s)=>n?new v({elevationInfo:i,pointer:t,vertexHandle:e,editGeometryOperations:n,visualizer:o,suppressSelfSnapping:!s}):null)}get grabbable(){return"grabbable-object"===this.captureMode}get following(){const{captureMode:t}=this;return"capture-always"===t||"capture-when-engaged"===t}get outputMapPosition(){return this._get("outputMapPosition")}set outputMapPosition(t){const e=this._get("outputMapPosition");t&&e&&d(t,e)||this._set("outputMapPosition",t)}get dragging(){return this.drawToolDragging||this.manipulatorDragging}get firstPointZ(){const t=this.editSession?.lastPointAddedBySession;if(!t)return null;const e=this.editSession?.getInformationAboutPoint(0,t.partIndex);return e?.point.hasZ?e.point.z:null}async moveTo(t,e){const{snappingManager:n,skipSnapping:i,surfaceManager:s,pointerType:r,editGeometryOperations:a,snappingVisualizer:p}=e,l=this._getSnappingContext(r??"mouse",this.editSession?.endVertex,a,s?.elevationInfo,p,this.selfSnappingEnabled),u=this._ensureSnappingOperation(e);t&&(this.screenPosition=t);const c=this.screenPosition;if(!c)return null;const h=this.firstPointZ,m=s?.screenToMap(c,{firstPointZ:h});if(this.inputMapPosition=m,this.selectedSnappingResult=null,!n||!m||!l||i||!this.snappingEnabled)return this.selectedSnappingResult=void 0,this.outputMapPosition=this._finalizeSnappingAndConstraintResult(null,m,e);const S=f(m.x,m.y,m.z,m?.spatialReference),P=s?.screenToScene?.(c,{firstPointZ:h}),y=u.snap({point:S,scenePoint:P},n,l);return o(y.then(()=>{const t=u.stagedPoint;return d(this.selectedSnappingResult,t)||(this.selectedSnappingResult=new g({...t})),this.outputMapPosition=this._finalizeSnappingAndConstraintResult(this.selectedSnappingResult,m,e)}))}async moveDeltaRelativeToScreen(t,e,n){const{inputMapPosition:i,screenPosition:o,firstPointZ:s}=this;if(!i)return null;const a=n.surfaceManager?n.surfaceManager.mapToScreen(i,{firstPointZ:s}):o;if(!a)return null;const p=r(a.x+t,a.y+e);return this.moveTo(p,n)}async noteDragStart(t,e){if(this.drawToolDragging=!0,e.skipSnapping||!this.snappingEnabled)return null;const{snappingManager:i,surfaceManager:s,pointerType:r,editGeometryOperations:a,snappingVisualizer:p}=e,l=this._getSnappingContext(r??"mouse",this.editSession?.endVertex,a,s?.elevationInfo,p,this.selfSnappingEnabled),u=this._ensureSnappingOperation(e),c=this.firstPointZ,d=s?.screenToMap(t,{firstPointZ:c});if(this.outputMapPositionOfDragStart=null,i&&l&&d){const r=u.snap({point:f(d.x,d.y,d.z,d?.spatialReference),scenePoint:s?.screenToScene?.(t,{firstPointZ:c})},i,l);return o(r.then(()=>{const t=u.stagedPoint?new g({...u.stagedPoint}):null;return this.outputMapPositionOfDragStart=this._finalizeSnappingAndConstraintResult(t,d,e)})).catch(t=>(n.getLogger(this).error("drawtool:handle:snapping-failed",t),null))}return this.outputMapPositionOfDragStart=d,null}async noteDragEnd(t,e){return this.moveTo(t,e).finally(()=>this.drawToolDragging=!1)}async moveDeltaRelativeToSketchSegment(t,e){const n=this.editSession?.endVertex?.leftSegment?.leftVertex?.pos,{firstPointZ:i}=this,o=this.inputMapPosition?e.surfaceManager?.mapToScreen(this.inputMapPosition,{firstPointZ:i})??this.screenPosition:this.screenPosition;if(!n||!o)return null;const s=e.editGeometryOperations?.data?.coordinateHelper.vectorToPoint(n);if(!s)return null;const r=e.surfaceManager?.mapToScreen(s,{firstPointZ:i});if(!r)return null;const a=[o.x-r.x,o.y-r.y],p=c(u(),l(a)),[g,d]=[p[0]*t,p[1]*t];return this.moveDeltaRelativeToScreen(g,d,e)}refreshConstraint(t){const e=this.outputMapPosition??this.inputMapPosition;return this.outputMapPosition=this._finalizeSnappingAndConstraintResult(null,e,t)}_finalizeSnappingAndConstraintResult(t,e,n){const i=t??e;i&&(i.z=h(n.snappingManager)??i.z);const o=(i?n.surfaceManager?.constrainZToEffectiveSurface?.(i):null)??i;return this._ensureZ(this._applyTooltipConstraints(o,n),n)}_applyTooltipConstraints(t,e){let n=t;const i=e.tooltipManager?.getConstraints(this);if(!i&&!e.interactiveHandleManager?.customConstraints)return n;if(!n)return n;const o=e.interactiveHandleManager?.customConstraints,r=e.editGeometryOperations?.data?.coordinateHelper;if(!r)return n;if(o&&this.editSession&&n){const t={handle:this,editSession:this.editSession,toScreen:t=>e.surfaceManager?.mapToScreen(t,{firstPointZ:this.firstPointZ})??null};for(const e of o)n=e(n,t)||n}const a=this.editSession?.endVertex,p=a?.leftSegment?.leftVertex,l=p?.leftSegment?.leftVertex,u=p&&r.vectorToPoint(p.pos),c=l&&r.vectorToPoint(l.pos);if(!i)return n;const d=(u||c)&&"primary"===this.role?m(u,c,i):S(i);if(!n||!i||!d)return n;const{context:f}=i,h=P(n,f),v=h?d.closestTo(h):void 0;if(!v)return n;const M=y(v,n,f),T="2d"===e.surfaceManager?.view?.type||"absolute-height"!==f.elevationInfo.mode,Z=i.elevation,{hasZ:x,metersPerVerticalUnit:b}=e.surfaceManager??{};if(null!=M&&T&&null!=Z&&x&&b&&(M.z=s(Z,"meters")/b),!M)return null;return new g({x:M.x,y:M.y,z:M.z,hasM:M.hasM,hasZ:M.hasZ,m:M.m,spatialReference:M.spatialReference})}_ensureZ(t,e){return t&&e.hasZ?(null!=t.z&&t.hasZ||(t.z=e.defaultZ??0,t.hasZ=!0),t):t}_ensureSnappingOperation({view:t}){return this._snappingOperation??=new M({view:t})}};t([a()],T.prototype,"_snappingOperation",void 0),t([a()],T.prototype,"role",void 0),t([a()],T.prototype,"name",void 0),t([a()],T.prototype,"captureMode",void 0),t([a()],T.prototype,"defaultCaptureMode",void 0),t([a()],T.prototype,"grabbable",null),t([a()],T.prototype,"following",null),t([a()],T.prototype,"snappingEnabled",void 0),t([a()],T.prototype,"selfSnappingEnabled",void 0),t([a()],T.prototype,"editSession",void 0),t([a()],T.prototype,"outputMapPosition",null),t([a()],T.prototype,"outputMapPositionOfDragStart",void 0),t([a()],T.prototype,"selectedSnappingResult",void 0),t([a()],T.prototype,"screenPosition",void 0),t([a()],T.prototype,"inputMapPosition",void 0),t([a()],T.prototype,"dragging",null),t([a()],T.prototype,"drawToolDragging",void 0),t([a()],T.prototype,"manipulatorDragging",void 0),t([a({readOnly:!0})],T.prototype,"firstPointZ",null),T=t([p("esri.views.draw.support.InteractiveHandle")],T);export{T as InteractiveHandle};
2
+ import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import n from"../../../core/Logger.js";import{memoize as i}from"../../../core/memoize.js";import{ignoreAbortErrors as o}from"../../../core/promiseUtils.js";import{valueInUnit as r}from"../../../core/quantity.js";import{createScreenPoint as s}from"../../../core/screenUtils.js";import{property as a,subclass as p}from"../../../core/accessorSupport/decorators.js";import{fromArray as l,create as u}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{normalize as c}from"../../../core/libs/gl-matrix-2/math/vec2.js";import g from"../../../geometry/Point.js";import{pointEquals as d}from"../../../layers/graphics/dehydratedFeatureComparison.js";import{makeDehydratedPoint as h}from"../../../layers/graphics/dehydratedPoint.js";import{getZFromVertexSnappingCandidates as f}from"./drawUtils.js";import{getPolylineOrPolygonConstraint as m,getPointConstraint as P,pointToConstraintSpace as y,constraintSpaceToPoint as v}from"../../interactive/sketch/constraintUtils.js";import{SnappingContext as S}from"../../interactive/snapping/SnappingContext.js";import{SnappingOperation as M}from"../../interactive/snapping/SnappingOperation.js";let T=class extends e{constructor(t){super(t),this._snappingOperation=null,this.role="primary",this.captureMode="capture-always",this.defaultCaptureMode="capture-always",this.snappingEnabled=!0,this.selfSnappingEnabled=!0,this.editSession=null,this.outputMapPositionOfDragStart=null,this.selectedSnappingResult=null,this.screenPosition=null,this.inputMapPosition=null,this.drawToolDragging=!1,this.manipulatorDragging=!1,this.activePointerId=null,this.activePointerType=null,this._getSnappingContext=i((t,e,n,i,o,r)=>n?new S({elevationInfo:i,pointer:t,vertexHandle:e,editGeometryOperations:n,visualizer:o,suppressSelfSnapping:!r}):null)}get grabbable(){return"grabbable-object"===this.captureMode}get following(){const{captureMode:t}=this;return"capture-always"===t||"capture-when-engaged"===t}get outputMapPosition(){return this._get("outputMapPosition")}set outputMapPosition(t){const e=this._get("outputMapPosition");t&&e&&d(t,e)||this._set("outputMapPosition",t)}get dragging(){return this.drawToolDragging||this.manipulatorDragging}get firstPointZ(){const t=this.editSession?.lastPointAddedBySession;if(!t)return null;const e=this.editSession?.getInformationAboutPoint(0,t.partIndex);return e?.point.hasZ?e.point.z:null}async moveTo(t,e){const{snappingManager:n,skipSnapping:i,surfaceManager:r,pointerType:s,editGeometryOperations:a,snappingVisualizer:p}=e;this.notePointerActivity(e.pointerId,s);const l=this._getSnappingContext(s??"mouse",this.editSession?.endVertex,a,r?.elevationInfo,p,this.selfSnappingEnabled),u=this._ensureSnappingOperation(e);t&&(this.screenPosition=t);const c=this.screenPosition;if(!c)return null;const f=this.firstPointZ,m=r?.screenToMap(c,{firstPointZ:f});if(this.inputMapPosition=m,this.selectedSnappingResult=null,!n||!m||!l||i||!this.snappingEnabled)return this.selectedSnappingResult=void 0,this.outputMapPosition=this._finalizeSnappingAndConstraintResult(null,m,e);const P=h(m.x,m.y,m.z,m?.spatialReference),y=r?.screenToScene?.(c,{firstPointZ:f}),v=u.snap({point:P,scenePoint:y},n,l);return o(v.then(()=>{const t=u.stagedPoint;return d(this.selectedSnappingResult,t)||(this.selectedSnappingResult=new g({...t})),this.outputMapPosition=this._finalizeSnappingAndConstraintResult(this.selectedSnappingResult,m,e)}))}async moveDeltaRelativeToScreen(t,e,n){const{inputMapPosition:i,screenPosition:o,firstPointZ:r}=this;if(!i)return null;const a=n.surfaceManager?n.surfaceManager.mapToScreen(i,{firstPointZ:r}):o;if(!a)return null;const p=s(a.x+t,a.y+e);return this.moveTo(p,n)}async noteDragStart(t,e){if(this.notePointerDown(e.pointerId,e.pointerType),this.drawToolDragging=!0,e.skipSnapping||!this.snappingEnabled)return null;const{snappingManager:i,surfaceManager:r,pointerType:s,editGeometryOperations:a,snappingVisualizer:p}=e,l=this._getSnappingContext(s??"mouse",this.editSession?.endVertex,a,r?.elevationInfo,p,this.selfSnappingEnabled),u=this._ensureSnappingOperation(e),c=this.firstPointZ,d=r?.screenToMap(t,{firstPointZ:c});if(this.outputMapPositionOfDragStart=null,i&&l&&d){const s=u.snap({point:h(d.x,d.y,d.z,d?.spatialReference),scenePoint:r?.screenToScene?.(t,{firstPointZ:c})},i,l);return o(s.then(()=>{const t=u.stagedPoint?new g({...u.stagedPoint}):null;return this.outputMapPositionOfDragStart=this._finalizeSnappingAndConstraintResult(t,d,e)})).catch(t=>(n.getLogger(this).error("drawtool:handle:snapping-failed",t),null))}return this.outputMapPositionOfDragStart=d,null}async noteDragEnd(t,e){return this.moveTo(t,e).finally(()=>{this.drawToolDragging=!1,this.notePointerUp(e.pointerId,e.pointerType)})}notePointerActivity(t=null,e=null){e&&(this.activePointerType=e),null!=t&&this.dragging&&(this.activePointerId=t)}notePointerDown(t=null,e=null){null!=t&&(this.activePointerId=t),e&&(this.activePointerType=e)}notePointerUp(t=null,e=null){null!=t&&null!=this.activePointerId&&this.activePointerId!==t||(this.activePointerId=null),e&&this.activePointerType===e&&(this.activePointerType=null)}async moveDeltaRelativeToSketchSegment(t,e){const n=this.editSession?.endVertex?.leftSegment?.leftVertex?.pos,{firstPointZ:i}=this,o=this.inputMapPosition?e.surfaceManager?.mapToScreen(this.inputMapPosition,{firstPointZ:i})??this.screenPosition:this.screenPosition;if(!n||!o)return null;const r=e.editGeometryOperations?.data?.coordinateHelper.vectorToPoint(n);if(!r)return null;const s=e.surfaceManager?.mapToScreen(r,{firstPointZ:i});if(!s)return null;const a=[o.x-s.x,o.y-s.y],p=c(u(),l(a)),[g,d]=[p[0]*t,p[1]*t];return this.moveDeltaRelativeToScreen(g,d,e)}refreshConstraint(t){const e=this.outputMapPosition??this.inputMapPosition;return this.outputMapPosition=this._finalizeSnappingAndConstraintResult(null,e,t)}_finalizeSnappingAndConstraintResult(t,e,n){const i=t??e;i&&(i.z=f(n.snappingManager)??i.z);const o=(i?n.surfaceManager?.constrainZToEffectiveSurface?.(i):null)??i;return this._ensureZ(this._applyTooltipConstraints(o,n),n)}_applyTooltipConstraints(t,e){let n=t;const i=e.tooltipManager?.getConstraints(this);if(!i&&!e.interactiveHandleManager?.customConstraints)return n;if(!n)return n;const o=e.interactiveHandleManager?.customConstraints,s=e.editGeometryOperations?.data?.coordinateHelper;if(!s)return n;if(o&&this.editSession&&n){const t={handle:this,editSession:this.editSession,toScreen:t=>e.surfaceManager?.mapToScreen(t,{firstPointZ:this.firstPointZ})??null};for(const e of o)n=e(n,t)||n}const a=this.editSession?.endVertex,p=a?.leftSegment?.leftVertex,l=p?.leftSegment?.leftVertex,u=p&&s.vectorToPoint(p.pos),c=l&&s.vectorToPoint(l.pos);if(!i)return n;const d=(u||c)&&"primary"===this.role?m(u,c,i):P(i);if(!n||!i||!d)return n;const{context:h}=i,f=y(n,h),S=f?d.closestTo(f):void 0;if(!S)return n;const M=v(S,n,h),T="2d"===e.surfaceManager?.view?.type||"absolute-height"!==h.elevationInfo.mode,Z=i.elevation,{hasZ:w,metersPerVerticalUnit:x}=e.surfaceManager??{};if(null!=M&&T&&null!=Z&&w&&x&&(M.z=r(Z,"meters")/x),!M)return null;return new g({x:M.x,y:M.y,z:M.z,hasM:M.hasM,hasZ:M.hasZ,m:M.m,spatialReference:M.spatialReference})}_ensureZ(t,e){return t&&e.hasZ?(null!=t.z&&t.hasZ||(t.z=e.defaultZ??0,t.hasZ=!0),t):t}_ensureSnappingOperation({view:t}){return this._snappingOperation??=new M({view:t})}};t([a()],T.prototype,"_snappingOperation",void 0),t([a()],T.prototype,"role",void 0),t([a()],T.prototype,"name",void 0),t([a()],T.prototype,"captureMode",void 0),t([a()],T.prototype,"defaultCaptureMode",void 0),t([a()],T.prototype,"grabbable",null),t([a()],T.prototype,"following",null),t([a()],T.prototype,"snappingEnabled",void 0),t([a()],T.prototype,"selfSnappingEnabled",void 0),t([a()],T.prototype,"editSession",void 0),t([a()],T.prototype,"outputMapPosition",null),t([a()],T.prototype,"outputMapPositionOfDragStart",void 0),t([a()],T.prototype,"selectedSnappingResult",void 0),t([a()],T.prototype,"screenPosition",void 0),t([a()],T.prototype,"inputMapPosition",void 0),t([a()],T.prototype,"dragging",null),t([a()],T.prototype,"drawToolDragging",void 0),t([a()],T.prototype,"manipulatorDragging",void 0),t([a()],T.prototype,"activePointerId",void 0),t([a()],T.prototype,"activePointerType",void 0),t([a({readOnly:!0})],T.prototype,"firstPointZ",null),T=t([p("esri.views.draw.support.InteractiveHandle")],T);export{T as InteractiveHandle};