@arcgis/core 4.29.0-next.20231219 → 4.29.0-next.20231221

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 (242) hide show
  1. package/analysis/Analysis.js +1 -1
  2. package/applications/WebEditor/sketchUtils.js +1 -1
  3. package/assets/components/assets/icon/hexagon16.json +1 -0
  4. package/assets/components/assets/icon/hexagon24.json +1 -0
  5. package/assets/components/assets/icon/hexagon32.json +1 -0
  6. package/assets/components/assets/icon/octagon16.json +1 -0
  7. package/assets/components/assets/icon/octagon24.json +1 -0
  8. package/assets/components/assets/icon/octagon32.json +1 -0
  9. package/assets/esri/core/libs/libtess/libtess.wasm +0 -0
  10. package/assets/esri/core/workers/RemoteClient.js +1 -1
  11. package/assets/esri/core/workers/chunks/00b340b4495bfabd4ca2.js +1 -0
  12. package/assets/esri/core/workers/chunks/{4301736368af52b94ee2.js → 02d6e2f0b1003534a077.js} +1 -1
  13. package/assets/esri/core/workers/chunks/050132142f4887c62724.js.LICENSE.txt +1 -1
  14. package/assets/esri/core/workers/chunks/0e315452f11b112523f0.js +1 -0
  15. package/assets/esri/core/workers/chunks/0f5a197f0a4b3a354bcd.js +1 -0
  16. package/assets/esri/core/workers/chunks/1187ba315883ff27e2d9.js +1 -0
  17. package/assets/esri/core/workers/chunks/1254a544d369d99ccf59.js +1 -0
  18. package/assets/esri/core/workers/chunks/138d138a5d33b2f5d8a4.js +1 -0
  19. package/assets/esri/core/workers/chunks/1a73dcbb49d17f16ed5a.js +1 -0
  20. package/assets/esri/core/workers/chunks/1c2b17d22f97d56f6212.js +1 -0
  21. package/assets/esri/core/workers/chunks/{0be38fd63e870341c660.js → 220fcc25578b2ef316da.js} +1 -1
  22. package/assets/esri/core/workers/chunks/251ceefdea4b345698a4.js +1 -0
  23. package/assets/esri/core/workers/chunks/28aafc7ea522663909b8.js +1 -0
  24. package/assets/esri/core/workers/chunks/30749bcd1a7b98a38386.js +1 -0
  25. package/assets/esri/core/workers/chunks/320a75ff760295d9af91.js +1 -0
  26. package/assets/esri/core/workers/chunks/{c9f8354d51f701cd69e5.js → 321dcff84c31c739ed93.js} +1 -1
  27. package/assets/esri/core/workers/chunks/36eb1e0471eb61a6bc38.js +1 -0
  28. package/assets/esri/core/workers/chunks/{57176c0968e07357126d.js → 3a429bb09b89e84021ab.js} +1 -1
  29. package/assets/esri/core/workers/chunks/444adb8a310024ec969c.js +1 -0
  30. package/assets/esri/core/workers/chunks/48aebd650b6eccde01f8.js.LICENSE.txt +1 -1
  31. package/assets/esri/core/workers/chunks/4f7459402b5910288ab1.js +1 -0
  32. package/assets/esri/core/workers/chunks/4fcd94fbf7c68996ad31.js +1 -0
  33. package/assets/esri/core/workers/chunks/573ad8aa1c2cfad61eb8.js +1 -0
  34. package/assets/esri/core/workers/chunks/5e12871a267742de6d22.js +1 -0
  35. package/assets/esri/core/workers/chunks/5f3104051f5267c58dda.js +2 -0
  36. package/assets/esri/core/workers/chunks/{76d0c4d6192449f22e51.js.LICENSE.txt → 5f3104051f5267c58dda.js.LICENSE.txt} +1 -1
  37. package/assets/esri/core/workers/chunks/{f350378a0d93dda39425.js → 7205c1680afee0cc0aac.js} +1 -1
  38. package/assets/esri/core/workers/chunks/77b3dff9fdcfe1222749.js +1 -0
  39. package/assets/esri/core/workers/chunks/77c29cfa3d245ff0afa0.js +1 -0
  40. package/assets/esri/core/workers/chunks/82dac92c1c611dea077f.js +1 -0
  41. package/assets/esri/core/workers/chunks/831283ac6653d7af90b6.js +1 -0
  42. package/assets/esri/core/workers/chunks/8485562b452686c6c3f2.js +1 -0
  43. package/assets/esri/core/workers/chunks/85a39b0f928f817a4b1b.js +1 -0
  44. package/assets/esri/core/workers/chunks/882fec2317740f6c118f.js +1 -0
  45. package/assets/esri/core/workers/chunks/8e1ac19a6188da157c0b.js +1 -0
  46. package/assets/esri/core/workers/chunks/8e2723dbc09400202aea.js +1 -0
  47. package/assets/esri/core/workers/chunks/{d3860693a40394723c99.js → 9249371cb2437e68a304.js} +1 -1
  48. package/assets/esri/core/workers/chunks/9528dfed701ad37ea551.js.LICENSE.txt +1 -1
  49. package/assets/esri/core/workers/chunks/{419f4aaecc4231fdd171.js → 9dc0331885cb8150d9ca.js} +1 -1
  50. package/assets/esri/core/workers/chunks/9ebf8288046aa0fa51f1.js.LICENSE.txt +1 -1
  51. package/assets/esri/core/workers/chunks/a0b8164928a331ffc1b4.js +2 -0
  52. package/assets/esri/core/workers/chunks/{5c71a14417cdd11a1e8d.js.LICENSE.txt → a0b8164928a331ffc1b4.js.LICENSE.txt} +1 -1
  53. package/assets/esri/core/workers/chunks/a6e3783cc10fb505473e.js +1 -0
  54. package/assets/esri/core/workers/chunks/a6fec91863abaa670301.js +2 -0
  55. package/assets/esri/core/workers/chunks/{359297c87764ae8db386.js.LICENSE.txt → a6fec91863abaa670301.js.LICENSE.txt} +1 -1
  56. package/assets/esri/core/workers/chunks/a98cdf10ff7b2923abd5.js +1 -0
  57. package/assets/esri/core/workers/chunks/aa43b12a71957da2e678.js +1 -0
  58. package/assets/esri/core/workers/chunks/ac85f9d88f5583407d66.js +1 -0
  59. package/assets/esri/core/workers/chunks/{418988591e8068adefe2.js → b7c2244c27790ccaca92.js} +1 -1
  60. package/assets/esri/core/workers/chunks/da70e2c191e7d1d2df64.js +1 -0
  61. package/assets/esri/core/workers/chunks/dbded06d7a944dd97b01.js +1 -0
  62. package/assets/esri/core/workers/chunks/dcf857dc23b152fe74ff.js +1 -0
  63. package/assets/esri/core/workers/chunks/dcfc48bf5c27774fa05c.js +1 -0
  64. package/assets/esri/core/workers/chunks/dd368833c042127360ad.js +1 -0
  65. package/assets/esri/core/workers/chunks/e4049e498b3eaa9c8596.js +1 -0
  66. package/assets/esri/core/workers/chunks/e730a930d8a551552db5.js +1 -0
  67. package/assets/esri/core/workers/chunks/eb55835b8d3829f75e1e.js +1 -0
  68. package/assets/esri/core/workers/chunks/ef6fc6c92eae4f51e689.js +2 -0
  69. package/assets/esri/core/workers/chunks/{931063b2654ff763d15e.js.LICENSE.txt → ef6fc6c92eae4f51e689.js.LICENSE.txt} +1 -1
  70. package/assets/esri/core/workers/chunks/f4124bf5b674811332bd.js.LICENSE.txt +1 -1
  71. package/assets/esri/core/workers/chunks/fd03cd19d0d4db699dca.js +1 -0
  72. package/assets/esri/libs/vxl/vxlLayer.wasm +0 -0
  73. package/assets/esri/themes/base/widgets/_Directions.scss +4 -0
  74. package/assets/esri/themes/base/widgets/_Grid.scss +8 -2
  75. package/assets/esri/themes/dark/main.css +1 -1
  76. package/assets/esri/themes/light/main.css +1 -1
  77. package/assets/esri/themes/light/view.css +1 -1
  78. package/chunks/libtess-asm.js +1 -1
  79. package/chunks/libtess.js +1 -1
  80. package/chunks/vec32.js +1 -1
  81. package/chunks/vxlLayer.js +1 -1
  82. package/core/PooledArray.js +1 -1
  83. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  84. package/core/scheduling.js +1 -1
  85. package/core/sql.js +1 -1
  86. package/geometry/ellipsoidUtils.js +1 -1
  87. package/geometry/libtess.js +1 -1
  88. package/geometry/support/meshUtils/loadExternal.js +1 -1
  89. package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
  90. package/interfaces.d.ts +391 -49
  91. package/layers/BuildingSceneLayer.js +1 -1
  92. package/layers/GeoJSONLayer.js +1 -1
  93. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  94. package/layers/IntegratedMeshLayer.js +1 -1
  95. package/layers/MapImageLayer.js +1 -1
  96. package/layers/OGCFeatureLayer.js +1 -1
  97. package/layers/PointCloudLayer.js +1 -1
  98. package/layers/SceneLayer.js +1 -1
  99. package/layers/VoxelLayer.js +1 -1
  100. package/layers/VoxelWasmPerSceneView.js +1 -1
  101. package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
  102. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  103. package/layers/graphics/sources/WFSSource.js +1 -1
  104. package/layers/graphics/sources/support/uploads.js +1 -1
  105. package/layers/mixins/SceneService.js +1 -1
  106. package/layers/ogc/wfsUtils.js +1 -1
  107. package/layers/support/I3SIndexInfo.js +1 -1
  108. package/layers/support/Sublayer.js +1 -1
  109. package/layers/support/associatedFeatureServiceUtils.js +1 -1
  110. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  111. package/layers/support/rasterFunctions/BandArithmeticFunction.js +1 -1
  112. package/layers/support/rasterFunctions/bandIndexUtils.js +1 -1
  113. package/package.json +2 -2
  114. package/portal/schemas/buildingSceneLayerItem.js +1 -1
  115. package/portal/schemas/definitions.js +1 -1
  116. package/portal/schemas/integratedMeshLayerItem.js +1 -1
  117. package/portal/schemas/pointCloudLayerItem.js +1 -1
  118. package/portal/schemas/sceneLayerItem.js +1 -1
  119. package/support/revision.js +1 -1
  120. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerShader.js +1 -1
  121. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  122. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  123. package/views/2d/layers/SubtypeGroupLayerView2D.js +1 -1
  124. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +5 -0
  125. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +5 -0
  126. package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +5 -0
  127. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +5 -0
  128. package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +5 -0
  129. package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +5 -0
  130. package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +5 -0
  131. package/views/2d/layers/features/layerAdapters/featureReductionUtils.js +5 -0
  132. package/views/2d/layers/features/layerAdapters/floorFilterUtils.js +5 -0
  133. package/views/2d/layers/features/support/NormalizedField.js +1 -1
  134. package/views/2d/layers/support/DebugOverlay.js +1 -1
  135. package/views/3d/analysis/AnalysisView3D.js +1 -1
  136. package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
  137. package/views/3d/layers/I3SMeshView3D.js +1 -1
  138. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  139. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  140. package/views/3d/layers/IntegratedMesh3DTilesViewPerformanceInfo.js +5 -0
  141. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  142. package/views/3d/layers/TiledLayerView3D.js +1 -1
  143. package/views/3d/layers/VoxelLayerView3D.js +1 -1
  144. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  145. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  146. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  147. package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
  148. package/views/3d/layers/i3s/PagedNodeIndex.js +1 -1
  149. package/views/3d/layers/support/DefinitionExpressionSceneLayerView.js +1 -1
  150. package/views/3d/layers/support/TemporalSceneLayerView.js +1 -1
  151. package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
  152. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  153. package/views/3d/support/RenderCoordsHelper.js +1 -1
  154. package/views/3d/support/orientedBoundingBox.js +1 -1
  155. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  156. package/views/3d/terrain/OverlayManager.js +1 -1
  157. package/views/3d/terrain/OverlayRenderer.js +1 -1
  158. package/views/3d/terrain/PatchRenderData.js +1 -1
  159. package/views/3d/terrain/SphericalPatch.js +1 -1
  160. package/views/3d/terrain/TerrainSurface.js +1 -1
  161. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  162. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  163. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  164. package/views/3d/webgl-engine/effects/RenderNodeCollection.js +1 -1
  165. package/views/3d/webgl-engine/effects/ScreenSpaceGeometry.js +1 -1
  166. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  167. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  168. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  169. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  170. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  171. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  172. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  173. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  174. package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
  175. package/views/3d/webgl-engine/lib/rendererUtils.js +1 -1
  176. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  177. package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
  178. package/views/draw/DrawGraphicTool.js +1 -1
  179. package/views/interactive/AnalysisToolBase.js +1 -1
  180. package/views/interactive/tooltip/Tooltip.js +1 -1
  181. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  182. package/views/layers/DimensionLayerView.js +1 -1
  183. package/views/webgl/Program.js +1 -1
  184. package/widgets/BasemapLayerList/BasemapLayerListVisibleElements.js +1 -1
  185. package/widgets/BasemapLayerList.js +1 -1
  186. package/widgets/DirectionalPad/DirectionalPadViewModel.d.ts +4 -0
  187. package/widgets/DirectionalPad.d.ts +4 -0
  188. package/widgets/Directions/css.js +1 -1
  189. package/widgets/Directions.js +1 -1
  190. package/widgets/ElevationProfile/ElevationProfileLineView.js +1 -1
  191. package/widgets/FeatureTable/FieldColumn.js +1 -1
  192. package/widgets/FeatureTable/Grid/Column.js +1 -1
  193. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  194. package/widgets/Features/FeaturesViewModel.js +1 -1
  195. package/widgets/LayerList/support/layerListUtils.js +1 -1
  196. package/widgets/LayerList.js +1 -1
  197. package/widgets/TableList.js +1 -1
  198. package/widgets/support/AnchorElementViewModel.js +1 -1
  199. package/assets/esri/core/workers/chunks/040e0122efe1cb716431.js +0 -1
  200. package/assets/esri/core/workers/chunks/04c89069761f7d6bf69d.js +0 -1
  201. package/assets/esri/core/workers/chunks/0c05900239e372f49f7e.js +0 -1
  202. package/assets/esri/core/workers/chunks/104e943cfffd093572a8.js +0 -1
  203. package/assets/esri/core/workers/chunks/1f5a4da5773ba48addfa.js +0 -1
  204. package/assets/esri/core/workers/chunks/24087961564e5b8cc20c.js +0 -1
  205. package/assets/esri/core/workers/chunks/26d8f6e0b9d67c75a781.js +0 -1
  206. package/assets/esri/core/workers/chunks/3441ae1ee2b11cf2c3f6.js +0 -1
  207. package/assets/esri/core/workers/chunks/359297c87764ae8db386.js +0 -2
  208. package/assets/esri/core/workers/chunks/37f71dac3208e74a76fc.js +0 -1
  209. package/assets/esri/core/workers/chunks/3913cf13681761afa596.js +0 -1
  210. package/assets/esri/core/workers/chunks/4a4dfe393c4c5e9435f9.js +0 -1
  211. package/assets/esri/core/workers/chunks/530306592924eb06d30c.js +0 -1
  212. package/assets/esri/core/workers/chunks/5558e8acc1bee29a0e9b.js +0 -1
  213. package/assets/esri/core/workers/chunks/587c81abcbe118ea89ae.js +0 -1
  214. package/assets/esri/core/workers/chunks/5c71a14417cdd11a1e8d.js +0 -2
  215. package/assets/esri/core/workers/chunks/5db76bdc4916d11cbcfe.js +0 -1
  216. package/assets/esri/core/workers/chunks/642e652bf21a7fa463c9.js +0 -1
  217. package/assets/esri/core/workers/chunks/649c3cbf6b3ec94cbdf1.js +0 -1
  218. package/assets/esri/core/workers/chunks/67e4bec7950f09ffe4a7.js +0 -1
  219. package/assets/esri/core/workers/chunks/68b2743411ef5e09862b.js +0 -1
  220. package/assets/esri/core/workers/chunks/76d0c4d6192449f22e51.js +0 -2
  221. package/assets/esri/core/workers/chunks/78123fa25903d376bd49.js +0 -1
  222. package/assets/esri/core/workers/chunks/7918a1c53ce9e7c95030.js +0 -1
  223. package/assets/esri/core/workers/chunks/80498a2a85e1aeadd569.js +0 -1
  224. package/assets/esri/core/workers/chunks/8407cf549c0c59a206f1.js +0 -1
  225. package/assets/esri/core/workers/chunks/89299923c92540455513.js +0 -1
  226. package/assets/esri/core/workers/chunks/8932cdbb7cfab9258d5a.js +0 -1
  227. package/assets/esri/core/workers/chunks/931063b2654ff763d15e.js +0 -2
  228. package/assets/esri/core/workers/chunks/969a22814dc765ac1061.js +0 -1
  229. package/assets/esri/core/workers/chunks/aa4d3276917421abaa12.js +0 -1
  230. package/assets/esri/core/workers/chunks/be924cb8ab2d40abea6c.js +0 -1
  231. package/assets/esri/core/workers/chunks/c6d1a6db8cfa0a7e3bd2.js +0 -1
  232. package/assets/esri/core/workers/chunks/c87e3d55ecdbbb584dfc.js +0 -1
  233. package/assets/esri/core/workers/chunks/cf9bf7d57341d00a92a6.js +0 -1
  234. package/assets/esri/core/workers/chunks/d72121b17640e302d6a9.js +0 -1
  235. package/assets/esri/core/workers/chunks/de01e106ca3daf6c2f49.js +0 -1
  236. package/assets/esri/core/workers/chunks/e3154ef5dbd851224452.js +0 -1
  237. package/assets/esri/core/workers/chunks/f0c62bb406bb93b1408a.js +0 -1
  238. package/assets/esri/core/workers/chunks/f4c4e0fe6be09fa49784.js +0 -1
  239. package/assets/esri/core/workers/chunks/f64a4349f895f92b6338.js +0 -1
  240. package/assets/esri/core/workers/chunks/f7a31ac1251c9c0ba713.js +0 -1
  241. package/assets/esri/core/workers/chunks/f842b3b50059aa70f1af.js +0 -1
  242. package/assets/esri/core/workers/chunks/fab270f3a45914f8df9e.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{on as t,pausable as s}from"../core/events.js";import{makeHandle as o}from"../core/handleUtils.js";import{assertIsSome as i}from"../core/maybe.js";import{watch as n,initial as r,when as a,on as l}from"../core/reactiveUtils.js";import{escapeRegExpString as c}from"../core/string.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import{cast as u}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import"../core/has.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import{defaultUnitPropertyMetadata as p}from"../properties/defaultUnit.js";import v from"../rest/support/Stop.js";import m from"../symbols/SimpleMarkerSymbol.js";import _ from"./Search.js";import g from"./Widget.js";import{css as S}from"./Directions/css.js";import y from"./Directions/DirectionsViewModel.js";import{SaveLayer as w}from"./Directions/components/SaveLayer.js";import{DepartureTimeOption as f,formatDistance as M,formatDuration as b,getIconName as C}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as T,meteredArcGISLocatorUrl as k}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as I}from"./support/componentsUtils.js";import{globalCss as D}from"./support/globalCss.js";import{Heading as R,incrementHeadingLevel as P}from"./support/Heading.js";import{legacyIcon as B}from"./support/legacyIcon.js";import{accessibleHandler as L}from"./support/decorators/accessibleHandler.js";import{messageBundle as j}from"./support/decorators/messageBundle.js";import{tsx as A}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import E from"sortablejs";import{formatNumber as H}from"../intl/number.js";const x={departureTime:!0,layerDetails:!0,printButton:!1,saveAsButton:!0,saveButton:!0,stops:!0,traveMode:!0};function U(e){const{branchName:t,displayText:s,exitName:o,intersectingName:i,name:n,objectId:r,towardName:a}=e;if(null==s)return null;const l=[t,o,i,n,a].filter(Boolean).sort(((e,t)=>t.length-e.length)).map((e=>c(e)));if(!l.length)return s;const d=new RegExp(l.join("|"),"g"),u=s.matchAll(d);let h=0;const p=[];for(const{0:c,index:v}of u)p.push(s.slice(h,v),A("span",{class:S.maneuverPlaceName},c)),h=v+c.length;return p.push(s.slice(h)),A("span",{id:`${S.maneuver}-${r}`},p)}function z(e){return!!e.composedPath?.().find((e=>e.classList?.contains("esri-search__suggestions-list")))}function $(e){const t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}const O="search-term",F=100,N=500;let V=class extends g{constructor(e,t){super(e,t),this._activeStop=null,this._activeManeuver=null,this._autoStopRemovalDelay=F,this._autoStopRemovalTimeoutId=void 0,this._focusedManeuver=null,this._newPlaceholderStop=null,this._pointerDownUpHandle=null,this._pointerPressedSearchSuggestionStop=null,this._renderSavePopoverFunction=null,this._saveAsButtonNode=null,this._saveLayer=new w,this._sections=null,this._sortable=null,this._stopsToSearches=new Map,this._viewClickHandle=null,this.headingLevel=2,this.iconClass=S.widgetIcon,this.icon=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.searchProperties=null,this.viewModel=new y,this.visibleElements={...x},this._setUpDragAndDropStops=e=>{this._sortable=E.create(e,{draggable:`.${S.validStopRow}`,ghostClass:S.stopRowGhost,handle:`.${S.stopHandle}`,onEnd:this._handleStopInputDragEnd})},this._handleDragHandlePointerDown=()=>this.viewModel.layer?.stops.forEach((e=>this.acquireSearch(e).activeMenu="none")),this._handleStopInputDragEnd=({oldIndex:e,newIndex:t,target:s})=>{if(e===t||null==t||null==e)return;const{children:o}=s,i=o[t],n=o[e],r=t-e<0;s.insertBefore(i,r?n.nextElementSibling:n);const{stops:a}=this.viewModel.layer;a.reorder(a.at(e),t);for(const l of a)l.sequence=null;this._solveRoute()}}initialize(){this.addHandles([n((()=>this.viewModel.layer?.routeInfo),(()=>{this._activeManeuver=null,this._focusedManeuver=null,this._sections=this._getSections(),this.scheduleRender()}),r),a((()=>this.view),((e,s)=>{if(s&&(this._viewClickHandle=null,null!=s&&this.removeHandles(s)),e){const s=this._prepPointerDownUpClick(),o=this._prepViewClick();s.pause(),o.pause();const i=e.surface;this.addHandles([t(i,"mousedown",(()=>this._autoStopRemovalDelay=N)),t(i,"mouseup",(()=>this._autoStopRemovalDelay=F)),s,o],e),this._pointerDownUpHandle=s,this._viewClickHandle=o}}),r),a((()=>null==this.viewModel.serviceDescription),(()=>{try{this.viewModel.load()}catch{}}),r),n((()=>this._saveLayer.state),(()=>{this.scheduleRender()}))]),this.when((()=>{this.destroyed||this.visibleElements.saveAsButton&&(this._renderSavePopoverFunction=this._renderSavePopover.bind(this),this._projector.append(document.body,this._renderSavePopoverFunction))}))}loadDependencies(){return I({button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),link:()=>import("@esri/calcite-components/dist/components/calcite-link.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js")})}destroy(){for(const e of this._stopsToSearches.values())e.destroy();this._sortable?.destroy(),null!=this._renderSavePopoverFunction&&this._projector.detach(this._renderSavePopoverFunction)}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...x,...e}}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e);return s.view=t,this._overrideDefaultSources(s),s}const s=new _({view:t,resultGraphicEnabled:!1,popupEnabled:!1,...this.searchProperties});return this._normalizeSearchSources(s),this.addHandles([l((()=>s.allSources),"change",(()=>this._normalizeSearchSources(s))),s.on("select-result",(()=>{e.geometry=s.selectedResult?.feature.geometry,e.name=s.selectedResult?.name,this._solveRoute()})),s.on("search-focus",(()=>this._handleStopInputFocus(s,e))),s.on("search-blur",(()=>this._handleStopInputBlur(s,e))),s.on("search-clear",(()=>{e.geometry=null,e.name=null,this._activeStop=e,this.viewModel.layer?.removeResult()})),n((()=>s.searchTerm),(t=>{e.name=t}))],s),this._stopsToSearches.set(e,s),s}getDirections(){return this.viewModel.getDirections()}render(){return A("div",{class:this.classes(S.base,D.widget,D.panel,S.scroller)},this._renderPanelContent())}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_renderPanelContent(){const{layer:e,serviceDescription:t,state:s}=this.viewModel,o="initializing"===s,i="error"===s&&!t,n="unauthenticated"===s,r={[S.panelContentLoading]:o,[S.panelContentError]:i||!e,[S.panelContentSignIn]:n},a=o?"presentation":"group",l=e?n?this._renderSignIn():i?this._renderMessage(this._getErrorMessage()):o?this._renderLoader():this._renderReadyContent():this._renderMessage(this.messages.missingLayer);return A("div",{class:this.classes(S.panelContent,r),role:a},l)}_renderReadyContent(){return[this._renderStopsContainer(),this._renderTravelModeOptions(),this._renderDepartureTimeControls(),this._renderSaveContainer(),this._renderSectionSplitter(),this._renderDirectionsContainer()]}_renderSignIn(){return A("div",{class:S.signInContent,key:"sign-in"},A(R,{class:S.contentTitle,level:this.headingLevel},this.messages.widgetLabel),this._renderPlaceholder(),A(R,{level:P(this.headingLevel)},this.messages.signInRequired),A("button",{bind:this,class:this.classes(D.button,D.buttonSecondary,S.signInButton),onclick:this._handleSignInClick,tabIndex:0,type:"button"},this.messagesCommon.auth.signIn))}_handleSignInClick(){this.viewModel.load().catch((()=>{}))}_renderTravelModeOptions(){if(!this.visibleElements.traveMode)return null;const{selectedTravelMode:e,travelModes:t}=this.viewModel;if(0===t.length)return null;const s=null!=e?e.name:this.messages.travelMode;return A("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(S.travelMode,this._saveLayer.opened&&D.buttonDisabled),key:"esri-directions__travel-mode-controls",role:"group"},A("select",{"aria-label":s,bind:this,class:this.classes(S.travelModeSelect,D.select),key:"esri-directions__travel-mode-options",onchange:this._handleTravelModeChange,title:s},t.map(((t,s)=>A("option",{"data-mode":t,key:`esri-directions__travel-mode-${s}`,selected:e===t,value:`${s}`},t.name)))))}_handleTravelModeChange(e){const t=e.currentTarget;this.viewModel.selectedTravelMode=q(t.item(t.selectedIndex)),this._solveRoute()}_renderStopsContainer(){return this.visibleElements.stops?A("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(S.section,this._saveLayer.opened&&D.buttonDisabled),key:"esri-directions__stops-container",role:"group"},this._renderStops()):null}_renderDepartureTimeControls(){if(!this.visibleElements.departureTime)return null;const{messages:{departAt:e,departureTime:t,leaveNow:s,timeUnspecified:o},viewModel:{departureOption:i}}=this;return A("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(S.departureTime,this._saveLayer.opened&&D.buttonDisabled),key:"esri-directions__departure-time-controls",role:"group"},A("select",{"aria-label":t,bind:this,class:this.classes(S.departureTimeSelect,D.select),onchange:this._handleDepartureOptionChange,title:t},A("option",{selected:i===f.NOW,value:f.NOW},s),A("option",{selected:i===f.DEPART_AT,value:f.DEPART_AT},e),A("option",{selected:i===f.UNSPECIFIED,value:f.UNSPECIFIED},o)),i===f.DEPART_AT?this._renderTimeControls():null)}_renderStops(){const{stops:e}=this.viewModel.layer;let t=0;for(const i of this._stopsToSearches.keys())e.includes(i)||this._disposeSearch(i);for(const i of e){const e=this.acquireSearch(i);"none"!==e.activeMenu&&(t+=1),null!=i.name&&(e.searchTerm=i.name)}const s=e.toArray().map(((s,o)=>{const i=e.length,n=o>1&&null==s.geometry,r={[B.radioUnchecked]:o>=0&&o<i-1,[B.radioChecked]:o===i-1},a={[S.lastStopIconContainer]:o===i-1},l={[S.validStopRow]:!n},c=e.at(o+1),d=o===i-1,u=o===i-2,h=2===i&&0===o||i>2&&!d&&!u||i>2&&u&&null!=c?.geometry||i>2&&d&&null==s.geometry,p=i<3,v=this.acquireSearch(s),{messages:m}=this,{removeStop:_,reverseStops:g,unlocated:y}=m,w=null!=s.geometry&&null!=s.name?s.name:y,f=H(o+1),M=`${m.stopLabel} ${f} (${w})`,b=`${this.id}__stop--${o}`,C=!!v.searchTerm&&!!v.selectedResult&&null!=s.geometry&&v.selectedResult.name===s.name,T={zIndex:"none"!==v.activeMenu?""+t--:""};return A("li",{afterCreate:this._handleStopFieldCreation,"aria-label":M,bind:this,class:this.classes(S.stopRow,l),"data-stop-index":o,id:b,key:o,styles:T},A("div",{class:S.stopHandle},A("span",{"aria-hidden":"true",class:this.classes(S.stopIcon,B.handleVertical,S.stopHandleIcon,S.interactiveStopIcon),onpointerdown:this._handleDragHandlePointerDown}),A("div",{"aria-labelledby":b,bind:this,class:this.classes(S.stopIconContainer,a),"data-stop-index":o,onclick:this._handleStopIconClick,onkeydown:this._handleStopIconClick,role:"button"},A("span",{class:this.classes(S.stopIcon,r),tabIndex:C?0:void 0}))),A("div",{class:S.stopInput},v.render()),A("div",{class:S.stopOptions,role:"group"},A("div",{"aria-label":_,bind:this,class:S.removeStopButton,"data-stop-index":o,hidden:p,onclick:this._handleRemoveStop,onkeydown:this._handleRemoveStop,role:"button",tabIndex:0,title:_},A("span",{"aria-hidden":"true",class:this.classes(S.stopIcon,S.removeStop,B.trash,S.interactiveStopIcon)}),A("span",{class:B.fontFallbackText},"removeStopTitle")),A("div",{"aria-label":g,bind:this,class:S.reverseStops,hidden:h,onclick:this._handleReverseStops,onkeydown:this._handleReverseStops,role:"button",tabIndex:0,title:g},A("span",{"aria-hidden":"true",class:this.classes(S.stopIcon,B.upDownArrows,S.interactiveStopIcon)}),A("span",{class:B.fontFallbackText},"removeStopTitle"))))})),o=this._renderAddStop();return A("div",null,A("ol",{afterCreate:this._setUpDragAndDropStops,class:S.stops,role:"group"},s),o)}_renderAddStop(){const e=this.viewModel.layer?.stops;if(!e)return null;const t=e.filter((({geometry:e})=>null!=e)),s=e.at(-1);return t.length>1&&t.length<this.maxStops&&null!=s?.geometry?A("div",{class:S.toolbarSection},A("div",{class:S.toolbarButtons},A("calcite-button",{appearance:"outline",class:S.addStopButton,iconStart:"plus",key:S.addStopButton,kind:"neutral",label:this.messages.addStop,onclick:()=>{this._addNewPlaceholder()},round:!0,scale:"s",width:"full"},this.messages.addStop))):null}_handleStopIconClick(e){const t=W(e.currentTarget),s=null!=t?this.viewModel.layer?.stops.at(t):void 0;s?.geometry&&this._centerAtStop(s)}_handleClearRouteClick(){this.viewModel.reset()}_centerAtStop(e){this.viewModel.centerAt(e)}_handleStopFieldCreation(e){const t=this._newPlaceholderStop;if(!t)return;const s=W(e),o=null!=s?this.viewModel.layer?.stops.at(s):void 0;if(t===o){const e=this.acquireSearch(o);e.when((()=>{this.renderNow(),e.focus()}))}this._newPlaceholderStop=null}_handleStopInputBlur(e,t){if(this._saveLayer.opened)return;this.removeHandles(O);if(!!e.selectedResult&&null!=t.geometry&&null!=e.selectedResult?.feature.geometry&&t.geometry===e.selectedResult?.feature.geometry)return void this._pointerDownUpHandle?.pause();const s=null==t.geometry&&null==e.selectedResult?.feature.geometry,o=null!=t.geometry&&null!=e.selectedResult?.feature.geometry&&t.geometry!==e.selectedResult?.feature.geometry;if((s||o)&&"none"===e.activeMenu&&e.searchTerm)return e.search(),void this._pointerDownUpHandle?.pause();e.searchTerm||(this._viewClickHandle?.resume(),clearTimeout(this._autoStopRemovalTimeoutId),this._autoStopRemovalTimeoutId=setTimeout((()=>{this.destroyed||(this._viewClickHandle?.pause(),"searching"!==e.viewModel.state?this._pointerPressedSearchSuggestionStop||(null!=t.geometry&&(t.geometry=null,this._solveRoute()),this.scheduleRender()):this._pointerDownUpHandle?.pause())}),this._autoStopRemovalDelay))}_handleStopInputFocus(e,t){this._pointerDownUpHandle?.resume();const{view:s}=this;if(this.hasHandles(O)||!s)return;const i=s.cursor;this.addHandles([o((()=>{s.cursor=i})),n((()=>e.searchTerm),(t=>{e.destroyed||(s.cursor=t.length?i:"copy")}),r)],O),this._activeStop=t}_prepViewClick(){const{view:e}=this.viewModel;i(e),i(e.surface);const t=s(e,"click",this._handleViewClick.bind(this)),o=s(e.surface,"click",(()=>{clearTimeout(this._autoStopRemovalTimeoutId),o.pause()}));return{remove(){o.remove(),t.remove()},pause(){o.pause(),t.pause()},resume(){o.resume(),t.resume()}}}_prepPointerDownUpClick(){const e=s(document,"pointerdown",(e=>{this._pointerPressedSearchSuggestionStop=z(e)?this._activeStop:null})),t=s(document,"pointerup",(e=>{this._pointerDownUpHandle?.pause();const t=z(e),s=this._activeStop;t||s!==this._pointerPressedSearchSuggestionStop||this._removeStop(s),this.scheduleRender(),this._pointerPressedSearchSuggestionStop=t?s:null}));return{remove(){t.remove(),e.remove()},pause(){t.pause(),e.pause()},resume(){e.resume()}}}_handleViewClick(e){e.stopPropagation();const t=this._activeStop,s=t?this._stopsToSearches.get(t):null;t&&s&&!s.searchTerm&&(s.search(e.mapPoint).then((e=>{const o=e?.results[0].results;if(!o)return;const{feature:i,name:n}=o[0];t.geometry=i.geometry,t.name=n,s.searchTerm=n})),this.scheduleRender()),this._viewClickHandle?.pause(),clearTimeout(this._autoStopRemovalTimeoutId)}_addNewPlaceholder(){if(this._pointerDownUpHandle?.pause(),this._newPlaceholderStop)return;const e=new v({symbol:new m});this.viewModel.layer?.stops.add(e),this._newPlaceholderStop=e}_handleReverseStops(){this._reverseStops()}_reverseStops(){const e=this.viewModel.layer?.stops??[];e.reverse();for(const t of e)t.sequence=null;this._solveRoute()}_handleRemoveStop(e){const{layer:t}=this.viewModel;if(!t)return;const s=W(e.currentTarget);if(null==s)return;const{stops:o,routeInfo:i}=t,n=o.at(s);this._removeStop(n),null==n.geometry&&null!=i||this._solveRoute()}_removeStop(e){const{stops:t}=this.viewModel.layer;!e||t.length<=2||(this._disposeSearch(e),t.remove(e))}_handleDepartureOptionChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);this.viewModel.departureOption=s.value,this._solveRoute()}_renderTimeControls(){return this.viewModel.departureIsoDate&&this.viewModel.departureIsoTime?A("div",{class:S.departureTimeControls,key:S.departureTimeControls,role:"group"},A("div",{class:S.departureDateTimePickers},A("calcite-input-date-picker",{valueAsDate:$(this.viewModel.departureIsoDate),onCalciteInputDatePickerChange:({target:e})=>{this.viewModel.departureIsoDate=e.value,this._solveRoute()}}),A("calcite-input-time-picker",{value:this.viewModel.departureIsoTime,onCalciteInputTimePickerChange:({target:e})=>{this.viewModel.departureIsoTime=e.value,this._solveRoute()}}))):null}_renderSectionSplitter(){return A("div",{class:S.sectionSplitter})}_renderSaveContainer(){const{saveButton:e,saveAsButton:t,printButton:s,layerDetails:o}=this.visibleElements;return e||t||s||o?A("div",{class:S.saveSection,key:S.saveSection},this._renderSaveButtons(),this._renderRouteLayerDetailsLink()):null}_renderSaveButtons(){const{saveButton:e,saveAsButton:t,printButton:s}=this.visibleElements;return e||t||s?A("div",{class:S.saveButtons,key:S.saveButtons},this._renderSaveButton(),this._renderSaveAsButton(),this._renderPrintButton()):null}_renderSaveButton(){if(!this.visibleElements.saveButton)return null;const{portalItem:e,routeInfo:t}=this.viewModel.layer,s=e?.itemControl,o=null!=t&&("admin"===s||"update"===s);return A("calcite-button",{appearance:"outline",class:S.saveButton,disabled:!o,iconStart:"save",key:S.saveButton,label:this.messagesCommon.save,onclick:()=>{this._handleSaveButtonClick()},width:"full"},this.messagesCommon.save)}_renderSaveAsButton(){if(!this.visibleElements.saveAsButton)return null;const e=null==this.viewModel.layer.routeInfo;return A("div",{class:S.saveAsButtonPopover,key:S.saveAsButtonPopover},A("calcite-button",{afterCreate:e=>{this._saveAsButtonNode=e},appearance:"outline",class:S.saveAsButton,disabled:e,iconStart:"duplicate",key:S.saveAsButton,label:this.messagesCommon.saveAs,onclick:()=>this._handleSaveAsButtonClick(),width:"full"},this.messagesCommon.saveAs))}_renderSavePopover(){return A("calcite-popover",{label:this._saveLayer.label,open:this._saveLayer.opened,overlayPositioning:"fixed",referenceElement:this._saveAsButtonNode,triggerDisabled:!0},this._saveLayer.render())}_handleSaveAsButtonClick(){this._saveLayer.opened?this._saveLayer.close():this._saveLayer.open(this.viewModel.layer)}_renderPrintButton(){return this.visibleElements.printButton?A("calcite-button",{appearance:"outline",class:S.printButton,iconStart:"print",key:S.printButton,label:this.messagesCommon.print}):null}_renderRouteLayerDetailsLink(){if(!this.visibleElements.layerDetails)return null;const{portalItem:e}=this.viewModel.layer;if(!e)return null;const{id:t,portal:{url:s}}=e,o=`${s}/home/item.html?id=${t}`;return A("calcite-link",{class:S.layerDetailsLink,href:o,key:S.layerDetailsLink,target:"_blank"},this.messages.viewLayerDetails)}_handleSaveButtonClick(){this.viewModel.layer.save()}_renderDirectionsContainer(){return A("div",{class:this.classes(S.directionsSection,S.section),key:"esri-directions__container"},this._renderDirectionsContainerContent())}_renderLoader(){return A("div",{class:S.loader,key:"loader"})}_renderWarningCard(){return A("div",{class:S.warningCard,role:"alert"},A("div",{class:S.warningHeader},A("span",{"aria-hidden":"true",class:B.noticeTriangle}),A(R,{class:S.warningHeading,level:this.headingLevel},this.messagesCommon.warning)),A("div",{class:S.warningMessage},this._getErrorMessage()))}_renderDirectionsContainerContent(){const{layer:e,state:t}=this.viewModel,s="routing"===t;return"error"===t?this._renderWarningCard():s?this._renderLoader():null!=e.directionLines?A("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(S.summary,this._saveLayer.opened&&D.buttonDisabled),key:S.summary,role:"group"},this._renderCosts(),this._renderRouteActions(),this._renderManeuverSections()):A("div",{class:D.empty,key:"esri-directions__placeholder"},this._renderPlaceholder(),A(R,{class:S.message,level:this.headingLevel},this.messages.directionsPlaceholder))}_renderPlaceholder(){return A("svg",{class:D.emptyIllustration,viewBox:"0 0 256 256",xmlns:"http://www.w3.org/2000/svg"},A("path",{d:"M192 36c-15.477 0-24 6.034-24 16.99v45.822l24 24 24-24v-45.82C216 42.033 207.477 36 192 36zm20 61.155l-20 20-20-20V52.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM192 52a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zM92 140.99C92 130.035 83.477 124 68 124s-24 6.034-24 16.99v45.822l24 24 24-24zm-4 44.165l-20 20-20-20V140.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM68 140a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zm84-44h16v4h-16zm-24 80h4v12h-12v-4h8zm0-28h4v16h-4zm0-52h12v4h-8v8h-4zm0 24h4v16h-4zm-36 64h16v4H92z",fill:"currentcolor"}))}_renderMessage(e){return A(R,{class:S.messageHeading,level:this.headingLevel},e)}_renderRouteActions(){return A("div",{class:S.routeActions},A("button",{"aria-label":this.messages.clearRoute,bind:this,class:this.classes(S.clearRouteButton,D.button,D.buttonTertiary),onclick:this._handleClearRouteClick,tabIndex:0,type:"button"},this.messages.clearRoute))}_getSections(){const{layer:e}=this.viewModel;if(!e)return null;const{directionPoints:t,directionLines:s,stops:o}=e;if(null==t||null==s)return null;const i=[];let n=null;for(const r of t){const{objectId:e,stopId:t}=r;if(null!=t){const e=o.find((({objectId:e})=>e===t)),s=0===i.length;null!=n&&n.stop===e||(n={stop:e,directions:[],open:s},i.push(n));continue}if(null==n)continue;const a=s.find((({directionPointId:t})=>t===e));null!=a&&n.directions.push({directionPoint:r,directionLine:a})}return i}_renderManeuverSections(){return null==this._sections?null:A("div",{class:S.maneuvers,role:"group"},this._sections.map(((e,t)=>{const{open:s}=e;let o;e.directions.length>0&&s&&(o=A("ol",{class:S.maneuverList},e.directions.map((e=>this._renderManeuver(e)))));const i=this._sections.length>2,n=t===this._sections.length-1,r={[S.collapsibleSection]:i},a={[B.down]:!s,[B.up]:s};let l;if(i&&!n){const t=s?this.messagesCommon.close:this.messagesCommon.open;l=A("header",{class:this.classes(S.maneuverSectionHeader,S.maneuverSectionToggle),key:S.maneuverSectionHeader},A("div",{"aria-expanded":s.toString(),"aria-label":t,bind:this,class:S.maneuverSectionHeaderButton,"data-maneuver-section":e,onclick:this._handleSectionToggle,onkeydown:this._handleSectionToggle,role:"button",tabIndex:0,title:t},A(R,{class:S.maneuverSectionTitle,level:this.headingLevel},e.stop.name),A("span",{"aria-hidden":"true",class:this.classes(a)})))}else l=A("header",{class:S.maneuverSectionHeader,key:S.maneuverSectionHeader},A(R,{class:S.maneuverSectionTitle,level:this.headingLevel},e.stop.name));return A("section",{class:this.classes(S.maneuverSection,r),key:t},l,o)})))}_handleSectionToggle(e){const t=G(e.currentTarget);t&&(t.open=!t.open)}_renderCosts(){const e=this._getCostSummary(),{directionPoints:t}=this.viewModel.layer;if(null==t||null==e)return null;const{distance:s,duration:o}=e,{primaryCosts:i,secondaryCosts:n,zoomToRoute:r}=this.messages,a=this._renderEta();return A("div",{"aria-label":r,bind:this,class:S.directionCosts,onclick:this._handleSummaryInteraction,onkeydown:this._handleSummaryInteraction,role:"button",tabIndex:0,title:r},A("div",{class:S.costsDetails,role:"group"},A("div",{class:S.primaryCosts,title:i},o),A("div",{class:S.verticalSplitter}),A("div",{class:S.secondaryCosts,title:n},s)),a)}_renderEta(){return this.viewModel.departureOption===f.UNSPECIFIED?null:A("div",{class:S.arrivalTimeContainer,title:this.messages.eta},A("span",{class:S.arrivalTime},this.viewModel.formattedEta))}_handleSummaryInteraction(){this._activeManeuver=null,this._focusedManeuver=null,this.viewModel.clearHighlights(),this.zoomToRoute()}_getErrorMessage(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){e.viewModel.defaultSources.forEach((e=>{e.autoNavigate=!1}))}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.locationType??="street",T(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=k))}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_renderManeuver(e){const{directionPoint:t,directionLine:s}=e,{distance:o,duration:i}=s,{messages:n,messagesUnits:r,unit:a}=this,l=M(r,o??0,a),c=b(i??0),d=l&&c?`${l}&nbsp;&middot;&nbsp;${c}`:`${l}${c}`,u=U(t),{objectId:h,directionPointType:p}=t,v=C(p),m=`${S.maneuver}-${h}`,_=`${S.intermediateCost}-${h}`,g={[S.maneuverActive]:this._activeManeuver===s};return A("li",{"aria-labelledby":`${m} ${_}`,bind:this,class:this.classes(S.maneuver,g),"data-maneuver":s,key:s,onblur:this._handleManeuverBlur,onclick:this._handleManeuverClick,onfocus:this._handleManeuverFocus,onkeydown:this._handleManeuverClick,onmouseout:this._handleManeuverMouseOut,onmouseover:this._handleManeuverMouseOver,tabIndex:0},A("calcite-icon",{alt:"",class:S.maneuverIcon,icon:v}),A("div",{class:S.maneuverCostsContainer},u,A("div",{class:S.maneuverCosts},A("div",{class:S.horizontalSplitter}),A("div",{"aria-hidden":"true",class:S.intermediateCost,id:_,innerHTML:d,title:n.intermediateCosts}))))}_handleManeuverClick(e){const t=Y(e.currentTarget);if(!t)return;if(this._activeManeuver===t)return this._activeManeuver=null,void this.zoomToRoute();this._activeManeuver=t;const{geometry:s}=t;this.viewModel.centerAt(s),this.viewModel.highlight(t)}_handleManeuverMouseOver(e){if(this._activeManeuver||this._focusedManeuver)return;const t=Y(e.currentTarget);t&&this.viewModel.highlight(t)}_handleManeuverMouseOut(){this._activeManeuver||this._focusedManeuver||this.viewModel.clearHighlights()}_handleManeuverBlur(){this._activeManeuver||(this._focusedManeuver=null,this.viewModel.clearHighlights())}_handleManeuverFocus(e){if(this._activeManeuver)return;const t=Y(e.currentTarget);t&&(this._focusedManeuver=t,this.viewModel.highlight(t))}_getCostSummary(){const{messagesUnits:e,unit:t,viewModel:s}=this,{routeInfo:o}=s.layer;if(null==o)return null;const i=o.totalDistance??0,n=o.totalDuration??0;return{distance:M(e,i,t),duration:b(n)}}async _solveRoute(){this.viewModel.updateDepartureTime();const e=this.viewModel.layer?.stops.filter((({geometry:e})=>null!=e));if(e&&!(e.length<2))try{await this.viewModel.getDirections()}catch{}}};e([d()],V.prototype,"apiKey",null),e([d(p)],V.prototype,"defaultUnit",void 0),e([d()],V.prototype,"goToOverride",null),e([d()],V.prototype,"headingLevel",void 0),e([d()],V.prototype,"iconClass",void 0),e([d()],V.prototype,"icon",void 0),e([d()],V.prototype,"label",null),e([d({readOnly:!0})],V.prototype,"lastRoute",null),e([d()],V.prototype,"layer",null),e([d()],V.prototype,"maxStops",null),e([d(),j("esri/widgets/Directions/t9n/Directions")],V.prototype,"messages",void 0),e([d(),j("esri/t9n/common")],V.prototype,"messagesCommon",void 0),e([d(),j("esri/core/t9n/Units")],V.prototype,"messagesUnits",void 0),e([d()],V.prototype,"searchProperties",void 0),e([d()],V.prototype,"unit",null),e([d()],V.prototype,"view",null),e([d({type:y})],V.prototype,"viewModel",void 0),e([d()],V.prototype,"visibleElements",void 0),e([u("visibleElements")],V.prototype,"castVisibleElements",null),e([L()],V.prototype,"_handleStopIconClick",null),e([L()],V.prototype,"_handleClearRouteClick",null),e([L()],V.prototype,"_handleReverseStops",null),e([L()],V.prototype,"_handleRemoveStop",null),e([L()],V.prototype,"_handleSectionToggle",null),e([L()],V.prototype,"_handleSummaryInteraction",null),e([L()],V.prototype,"_handleManeuverClick",null),V=e([h("esri.widgets.Directions")],V);const K=V;function q(e){return e?.["data-mode"]}function W(e){return e?.["data-stop-index"]}function G(e){return e?.["data-maneuver-section"]}function Y(e){return e?.["data-maneuver"]}export{K as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{on as t,pausable as s}from"../core/events.js";import{makeHandle as o}from"../core/handleUtils.js";import{assertIsSome as i}from"../core/maybe.js";import{watch as r,initial as n,when as a,on as l}from"../core/reactiveUtils.js";import{escapeRegExpString as c}from"../core/string.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import{cast as u}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import"../core/has.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import{defaultUnitPropertyMetadata as p}from"../properties/defaultUnit.js";import v from"../rest/support/Stop.js";import m from"../symbols/SimpleMarkerSymbol.js";import _ from"./Search.js";import g from"./Widget.js";import{css as S}from"./Directions/css.js";import y from"./Directions/DirectionsViewModel.js";import{SaveLayer as w}from"./Directions/components/SaveLayer.js";import{DepartureTimeOption as f,formatDistance as M,formatDuration as b,getIconName as C}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as T,meteredArcGISLocatorUrl as k}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as I}from"./support/componentsUtils.js";import{globalCss as D}from"./support/globalCss.js";import{Heading as R,incrementHeadingLevel as P}from"./support/Heading.js";import{legacyIcon as B}from"./support/legacyIcon.js";import{accessibleHandler as L}from"./support/decorators/accessibleHandler.js";import{messageBundle as j}from"./support/decorators/messageBundle.js";import{tsx as A}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import E from"sortablejs";import{formatNumber as H}from"../intl/number.js";const x={departureTime:!0,layerDetails:!0,printButton:!1,saveAsButton:!0,saveButton:!0,stops:!0,traveMode:!0};function U(e){const{branchName:t,displayText:s,exitName:o,intersectingName:i,name:r,objectId:n,towardName:a}=e;if(null==s)return null;const l=[t,o,i,r,a].filter(Boolean).sort(((e,t)=>t.length-e.length)).map((e=>c(e)));if(!l.length)return s;const d=new RegExp(l.join("|"),"g"),u=s.matchAll(d);let h=0;const p=[];for(const{0:c,index:v}of u)p.push(s.slice(h,v),A("span",{class:S.maneuverPlaceName},c)),h=v+c.length;return p.push(s.slice(h)),A("span",{id:`${S.maneuver}-${n}`},p)}function z(e){return!!e.composedPath?.().find((e=>e.classList?.contains("esri-search__suggestions-list")))}function $(e){const t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}const O="search-term",F=100,N=500;let V=class extends g{constructor(e,t){super(e,t),this._activeStop=null,this._activeManeuver=null,this._autoStopRemovalDelay=F,this._autoStopRemovalTimeoutId=void 0,this._focusedManeuver=null,this._newPlaceholderStop=null,this._pointerDownUpHandle=null,this._pointerPressedSearchSuggestionStop=null,this._renderSavePopoverFunction=null,this._saveAsButtonNode=null,this._saveLayer=new w,this._sections=null,this._sortable=null,this._stopsToSearches=new Map,this._viewClickHandle=null,this.headingLevel=2,this.iconClass=S.widgetIcon,this.icon=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.searchProperties=null,this.viewModel=new y,this.visibleElements={...x},this._setUpDragAndDropStops=e=>{this._sortable=E.create(e,{draggable:`.${S.validStopRow}`,ghostClass:S.stopRowGhost,handle:`.${S.stopHandle}`,onEnd:this._handleStopInputDragEnd})},this._handleDragHandlePointerDown=()=>this.viewModel.layer?.stops.forEach((e=>this.acquireSearch(e).activeMenu="none")),this._handleStopInputDragEnd=({oldIndex:e,newIndex:t,target:s})=>{if(e===t||null==t||null==e)return;const{children:o}=s,i=o[t],r=o[e],n=t-e<0;s.insertBefore(i,n?r.nextElementSibling:r);const{stops:a}=this.viewModel.layer;a.reorder(a.at(e),t);for(const l of a)l.sequence=null;this._solveRoute()}}initialize(){this.addHandles([r((()=>this.viewModel.layer?.routeInfo),(()=>{this._activeManeuver=null,this._focusedManeuver=null,this._sections=this._getSections(),this.scheduleRender()}),n),a((()=>this.view),((e,s)=>{if(s&&(this._viewClickHandle=null,null!=s&&this.removeHandles(s)),e){const s=this._prepPointerDownUpClick(),o=this._prepViewClick();s.pause(),o.pause();const i=e.surface;this.addHandles([t(i,"mousedown",(()=>this._autoStopRemovalDelay=N)),t(i,"mouseup",(()=>this._autoStopRemovalDelay=F)),s,o],e),this._pointerDownUpHandle=s,this._viewClickHandle=o}}),n),a((()=>null==this.viewModel.serviceDescription),(()=>{try{this.viewModel.load()}catch{}}),n),r((()=>this._saveLayer.state),(()=>{this.scheduleRender()}))]),this.when((()=>{this.destroyed||this.visibleElements.saveAsButton&&(this._renderSavePopoverFunction=this._renderSavePopover.bind(this),this._projector.append(document.body,this._renderSavePopoverFunction))}))}loadDependencies(){return I({button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),link:()=>import("@esri/calcite-components/dist/components/calcite-link.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js")})}destroy(){for(const e of this._stopsToSearches.values())e.destroy();this._sortable?.destroy(),null!=this._renderSavePopoverFunction&&this._projector.detach(this._renderSavePopoverFunction)}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...x,...e}}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e);return s.view=t,this._overrideDefaultSources(s),s}const s=new _({view:t,resultGraphicEnabled:!1,popupEnabled:!1,...this.searchProperties});return this._normalizeSearchSources(s),this.addHandles([l((()=>s.allSources),"change",(()=>this._normalizeSearchSources(s))),s.on("select-result",(()=>{e.geometry=s.selectedResult?.feature.geometry,e.name=s.selectedResult?.name,this._solveRoute()})),s.on("search-focus",(()=>this._handleStopInputFocus(s,e))),s.on("search-blur",(()=>this._handleStopInputBlur(s,e))),s.on("search-clear",(()=>{e.geometry=null,e.name=null,this._activeStop=e,this.viewModel.layer?.removeResult()})),r((()=>s.searchTerm),(t=>{e.name=t}))],s),this._stopsToSearches.set(e,s),s}getDirections(){return this.viewModel.getDirections()}render(){return A("div",{class:this.classes(S.base,D.widget,D.panel,S.scroller)},this._renderPanelContent())}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_renderPanelContent(){const{layer:e,serviceDescription:t,state:s}=this.viewModel,o="initializing"===s,i="error"===s&&!t,r="unauthenticated"===s,n={[S.panelContentLoading]:o,[S.panelContentError]:i||!e,[S.panelContentSignIn]:r},a=o?"presentation":"group",l=e?r?this._renderSignIn():i?this._renderMessage(this._getErrorMessage()):o?this._renderLoader():this._renderReadyContent():this._renderMessage(this.messages.missingLayer);return A("div",{class:this.classes(S.panelContent,n),role:a},l)}_renderReadyContent(){return[this._renderStopsContainer(),this._renderTravelModeOptions(),this._renderDepartureTimeControls(),this._renderSaveContainer(),this._renderSectionSplitter(),this._renderDirectionsContainer()]}_renderSignIn(){return A("div",{class:S.signInContent,key:"sign-in"},A(R,{class:S.contentTitle,level:this.headingLevel},this.messages.widgetLabel),this._renderPlaceholder(),A(R,{level:P(this.headingLevel)},this.messages.signInRequired),A("button",{bind:this,class:this.classes(D.button,D.buttonSecondary,S.signInButton),onclick:this._handleSignInClick,tabIndex:0,type:"button"},this.messagesCommon.auth.signIn))}_handleSignInClick(){this.viewModel.load().catch((()=>{}))}_renderTravelModeOptions(){if(!this.visibleElements.traveMode)return null;const{selectedTravelMode:e,travelModes:t}=this.viewModel;if(0===t.length)return null;const s=null!=e?e.name:this.messages.travelMode;return A("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(S.travelMode,this._saveLayer.opened&&D.buttonDisabled),key:"esri-directions__travel-mode-controls",role:"group"},A("select",{"aria-label":s,bind:this,class:this.classes(S.travelModeSelect,D.select),key:"esri-directions__travel-mode-options",onchange:this._handleTravelModeChange,title:s},t.map(((t,s)=>A("option",{"data-mode":t,key:`esri-directions__travel-mode-${s}`,selected:e===t,value:`${s}`},t.name)))))}_handleTravelModeChange(e){const t=e.currentTarget;this.viewModel.selectedTravelMode=q(t.item(t.selectedIndex)),this._solveRoute()}_renderStopsContainer(){return this.visibleElements.stops?A("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(S.section,this._saveLayer.opened&&D.buttonDisabled),key:"esri-directions__stops-container",role:"group"},this._renderStops()):null}_renderDepartureTimeControls(){if(!this.visibleElements.departureTime)return null;const{messages:{departAt:e,departureTime:t,leaveNow:s,timeUnspecified:o},viewModel:{departureOption:i}}=this;return A("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(S.departureTime,this._saveLayer.opened&&D.buttonDisabled),key:"esri-directions__departure-time-controls",role:"group"},A("select",{"aria-label":t,bind:this,class:this.classes(S.departureTimeSelect,D.select),onchange:this._handleDepartureOptionChange,title:t},A("option",{selected:i===f.NOW,value:f.NOW},s),A("option",{selected:i===f.DEPART_AT,value:f.DEPART_AT},e),A("option",{selected:i===f.UNSPECIFIED,value:f.UNSPECIFIED},o)),i===f.DEPART_AT?this._renderTimeControls():null)}_renderStops(){const{stops:e}=this.viewModel.layer;let t=0;for(const i of this._stopsToSearches.keys())e.includes(i)||this._disposeSearch(i);for(const i of e){const e=this.acquireSearch(i);"none"!==e.activeMenu&&(t+=1),null!=i.name&&(e.searchTerm=i.name)}const s=e.toArray().map(((s,o)=>{const i=e.length,r=o>1&&null==s.geometry,n={[B.radioUnchecked]:o>=0&&o<i-1,[B.radioChecked]:o===i-1},a={[S.lastStopIconContainer]:o===i-1},l={[S.validStopRow]:!r},c=e.at(o+1),d=o===i-1,u=o===i-2,h=2===i&&0===o||i>2&&!d&&!u||i>2&&u&&null!=c?.geometry||i>2&&d&&null==s.geometry,p=i<3,v=this.acquireSearch(s),{messages:m}=this,{removeStop:_,reverseStops:g,unlocated:y}=m,w=null!=s.geometry&&null!=s.name?s.name:y,f=H(o+1),M=`${m.stopLabel} ${f} (${w})`,b=`${this.id}__stop--${o}`,C=!!v.searchTerm&&!!v.selectedResult&&null!=s.geometry&&v.selectedResult.name===s.name,T={zIndex:"none"!==v.activeMenu?""+t--:""};return A("li",{afterCreate:this._handleStopFieldCreation,"aria-label":M,bind:this,class:this.classes(S.stopRow,l),"data-stop-index":o,id:b,key:o,styles:T},A("div",{class:S.stopHandle},A("span",{"aria-hidden":"true",class:this.classes(S.stopIcon,B.handleVertical,S.stopHandleIcon,S.interactiveStopIcon),onpointerdown:this._handleDragHandlePointerDown}),A("div",{"aria-labelledby":b,bind:this,class:this.classes(S.stopIconContainer,a),"data-stop-index":o,onclick:this._handleStopIconClick,onkeydown:this._handleStopIconClick,role:"button"},A("span",{class:this.classes(S.stopIcon,n),tabIndex:C?0:void 0}))),A("div",{class:S.stopInput},v.render()),A("div",{class:S.stopOptions,role:"group"},A("div",{"aria-label":_,bind:this,class:S.removeStopButton,"data-stop-index":o,hidden:p,onclick:this._handleRemoveStop,onkeydown:this._handleRemoveStop,role:"button",tabIndex:0,title:_},A("span",{"aria-hidden":"true",class:this.classes(S.stopIcon,S.removeStop,B.trash,S.interactiveStopIcon)}),A("span",{class:B.fontFallbackText},"removeStopTitle")),A("div",{"aria-label":g,bind:this,class:S.reverseStops,hidden:h,onclick:this._handleReverseStops,onkeydown:this._handleReverseStops,role:"button",tabIndex:0,title:g},A("span",{"aria-hidden":"true",class:this.classes(S.stopIcon,B.upDownArrows,S.interactiveStopIcon)}),A("span",{class:B.fontFallbackText},"removeStopTitle"))))})),o=this._renderAddStop();return A("div",null,A("ol",{afterCreate:this._setUpDragAndDropStops,class:S.stops,role:"group"},s),o)}_renderAddStop(){const e=this.viewModel.layer?.stops;if(!e)return null;const t=e.filter((({geometry:e})=>null!=e)),s=e.at(-1);return t.length>1&&t.length<this.maxStops&&null!=s?.geometry?A("div",{class:S.toolbarSection},A("div",{class:S.toolbarButtons},A("calcite-button",{appearance:"outline",class:S.addStopButton,iconStart:"plus",key:S.addStopButton,kind:"neutral",label:this.messages.addStop,onclick:()=>{this._addNewPlaceholder()},round:!0,scale:"s",width:"full"},this.messages.addStop))):null}_handleStopIconClick(e){const t=W(e.currentTarget),s=null!=t?this.viewModel.layer?.stops.at(t):void 0;s?.geometry&&this._centerAtStop(s)}_handleClearRouteClick(){this.viewModel.reset()}_centerAtStop(e){this.viewModel.centerAt(e)}_handleStopFieldCreation(e){const t=this._newPlaceholderStop;if(!t)return;const s=W(e),o=null!=s?this.viewModel.layer?.stops.at(s):void 0;if(t===o){const e=this.acquireSearch(o);e.when((()=>{this.renderNow(),e.focus()}))}this._newPlaceholderStop=null}_handleStopInputBlur(e,t){if(this._saveLayer.opened)return;this.removeHandles(O);if(!!e.selectedResult&&null!=t.geometry&&null!=e.selectedResult?.feature.geometry&&t.geometry===e.selectedResult?.feature.geometry)return void this._pointerDownUpHandle?.pause();const s=null==t.geometry&&null==e.selectedResult?.feature.geometry,o=null!=t.geometry&&null!=e.selectedResult?.feature.geometry&&t.geometry!==e.selectedResult?.feature.geometry;if((s||o)&&"none"===e.activeMenu&&e.searchTerm)return e.search(),void this._pointerDownUpHandle?.pause();e.searchTerm||(this._viewClickHandle?.resume(),clearTimeout(this._autoStopRemovalTimeoutId),this._autoStopRemovalTimeoutId=setTimeout((()=>{this.destroyed||(this._viewClickHandle?.pause(),"searching"!==e.viewModel.state?this._pointerPressedSearchSuggestionStop||(null!=t.geometry&&(t.geometry=null,this._solveRoute()),this.scheduleRender()):this._pointerDownUpHandle?.pause())}),this._autoStopRemovalDelay))}_handleStopInputFocus(e,t){this._pointerDownUpHandle?.resume();const{view:s}=this;if(this.hasHandles(O)||!s)return;const i=s.cursor;this.addHandles([o((()=>{s.cursor=i})),r((()=>e.searchTerm),(t=>{e.destroyed||(s.cursor=t.length?i:"copy")}),n)],O),this._activeStop=t}_prepViewClick(){const{view:e}=this.viewModel;i(e),i(e.surface);const t=s(e,"click",this._handleViewClick.bind(this)),o=s(e.surface,"click",(()=>{clearTimeout(this._autoStopRemovalTimeoutId),o.pause()}));return{remove(){o.remove(),t.remove()},pause(){o.pause(),t.pause()},resume(){o.resume(),t.resume()}}}_prepPointerDownUpClick(){const e=s(document,"pointerdown",(e=>{this._pointerPressedSearchSuggestionStop=z(e)?this._activeStop:null})),t=s(document,"pointerup",(e=>{this._pointerDownUpHandle?.pause();const t=z(e),s=this._activeStop;t||s!==this._pointerPressedSearchSuggestionStop||this._removeStop(s),this.scheduleRender(),this._pointerPressedSearchSuggestionStop=t?s:null}));return{remove(){t.remove(),e.remove()},pause(){t.pause(),e.pause()},resume(){e.resume()}}}_handleViewClick(e){e.stopPropagation();const t=this._activeStop,s=t?this._stopsToSearches.get(t):null;t&&s&&!s.searchTerm&&(s.search(e.mapPoint).then((e=>{const o=e?.results[0].results;if(!o)return;const{feature:i,name:r}=o[0];t.geometry=i.geometry,t.name=r,s.searchTerm=r})),this.scheduleRender()),this._viewClickHandle?.pause(),clearTimeout(this._autoStopRemovalTimeoutId)}_addNewPlaceholder(){if(this._pointerDownUpHandle?.pause(),this._newPlaceholderStop)return;const e=new v({symbol:new m});this.viewModel.layer?.stops.add(e),this._newPlaceholderStop=e}_handleReverseStops(){this._reverseStops()}_reverseStops(){const e=this.viewModel.layer?.stops??[];e.reverse();for(const t of e)t.sequence=null;this._solveRoute()}_handleRemoveStop(e){const{layer:t}=this.viewModel;if(!t)return;const s=W(e.currentTarget);if(null==s)return;const{stops:o,routeInfo:i}=t,r=o.at(s);this._removeStop(r),null==r.geometry&&null!=i||this._solveRoute()}_removeStop(e){const{stops:t}=this.viewModel.layer;!e||t.length<=2||(this._disposeSearch(e),t.remove(e))}_handleDepartureOptionChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);this.viewModel.departureOption=s.value,this._solveRoute()}_renderTimeControls(){return this.viewModel.departureIsoDate&&this.viewModel.departureIsoTime?A("div",{class:S.departureTimeControls,key:S.departureTimeControls,role:"group"},A("div",{class:S.departureDateTimePickers},A("calcite-input-date-picker",{valueAsDate:$(this.viewModel.departureIsoDate),onCalciteInputDatePickerChange:({target:e})=>{this.viewModel.departureIsoDate=e.value,this._solveRoute()}}),A("calcite-input-time-picker",{value:this.viewModel.departureIsoTime,onCalciteInputTimePickerChange:({target:e})=>{this.viewModel.departureIsoTime=e.value,this._solveRoute()}}))):null}_renderSectionSplitter(){return A("div",{class:S.sectionSplitter})}_renderSaveContainer(){const{saveButton:e,saveAsButton:t,printButton:s,layerDetails:o}=this.visibleElements;return e||t||s||o?A("div",{class:S.saveSection,key:S.saveSection},this._renderSaveButtons(),this._renderRouteLayerDetailsLink()):null}_renderSaveButtons(){const{saveButton:e,saveAsButton:t,printButton:s}=this.visibleElements;return e||t||s?A("div",{class:S.saveButtons,key:S.saveButtons},this._renderSaveButton(),this._renderSaveAsButton(),this._renderPrintButton()):null}_renderSaveButton(){if(!this.visibleElements.saveButton)return null;const{portalItem:e,routeInfo:t}=this.viewModel.layer,s=e?.itemControl,o=null!=t&&("admin"===s||"update"===s);return A("calcite-button",{appearance:"outline",class:S.saveButton,disabled:!o,iconStart:"save",key:S.saveButton,label:this.messagesCommon.save,onclick:()=>{this._handleSaveButtonClick()},width:"full"},this.messagesCommon.save)}_renderSaveAsButton(){if(!this.visibleElements.saveAsButton)return null;const e=null==this.viewModel.layer.routeInfo;return A("div",{class:S.saveAsButtonPopover,key:S.saveAsButtonPopover},A("calcite-button",{afterCreate:e=>{this._saveAsButtonNode=e},appearance:"outline",class:S.saveAsButton,disabled:e,iconStart:"duplicate",key:S.saveAsButton,label:this.messagesCommon.saveAs,onclick:()=>this._handleSaveAsButtonClick(),width:"full"},this.messagesCommon.saveAs))}_renderSavePopover(){return A("calcite-popover",{class:S.savePopover,label:this._saveLayer.label,open:this._saveLayer.opened,overlayPositioning:"fixed",referenceElement:this._saveAsButtonNode,triggerDisabled:!0},this._saveLayer.render())}_handleSaveAsButtonClick(){this._saveLayer.opened?this._saveLayer.close():this._saveLayer.open(this.viewModel.layer)}_renderPrintButton(){return this.visibleElements.printButton?A("calcite-button",{appearance:"outline",class:S.printButton,iconStart:"print",key:S.printButton,label:this.messagesCommon.print}):null}_renderRouteLayerDetailsLink(){if(!this.visibleElements.layerDetails)return null;const{portalItem:e}=this.viewModel.layer;if(!e)return null;const{id:t,portal:{url:s}}=e,o=`${s}/home/item.html?id=${t}`;return A("calcite-link",{class:S.layerDetailsLink,href:o,key:S.layerDetailsLink,target:"_blank"},this.messages.viewLayerDetails)}_handleSaveButtonClick(){this.viewModel.layer.save()}_renderDirectionsContainer(){return A("div",{class:this.classes(S.directionsSection,S.section),key:"esri-directions__container"},this._renderDirectionsContainerContent())}_renderLoader(){return A("div",{class:S.loader,key:"loader"})}_renderWarningCard(){return A("div",{class:S.warningCard,role:"alert"},A("div",{class:S.warningHeader},A("span",{"aria-hidden":"true",class:B.noticeTriangle}),A(R,{class:S.warningHeading,level:this.headingLevel},this.messagesCommon.warning)),A("div",{class:S.warningMessage},this._getErrorMessage()))}_renderDirectionsContainerContent(){const{layer:e,state:t}=this.viewModel,s="routing"===t;return"error"===t?this._renderWarningCard():s?this._renderLoader():null!=e.directionLines?A("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(S.summary,this._saveLayer.opened&&D.buttonDisabled),key:S.summary,role:"group"},this._renderCosts(),this._renderRouteActions(),this._renderManeuverSections()):A("div",{class:D.empty,key:"esri-directions__placeholder"},this._renderPlaceholder(),A(R,{class:S.message,level:this.headingLevel},this.messages.directionsPlaceholder))}_renderPlaceholder(){return A("svg",{class:D.emptyIllustration,viewBox:"0 0 256 256",xmlns:"http://www.w3.org/2000/svg"},A("path",{d:"M192 36c-15.477 0-24 6.034-24 16.99v45.822l24 24 24-24v-45.82C216 42.033 207.477 36 192 36zm20 61.155l-20 20-20-20V52.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM192 52a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zM92 140.99C92 130.035 83.477 124 68 124s-24 6.034-24 16.99v45.822l24 24 24-24zm-4 44.165l-20 20-20-20V140.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM68 140a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zm84-44h16v4h-16zm-24 80h4v12h-12v-4h8zm0-28h4v16h-4zm0-52h12v4h-8v8h-4zm0 24h4v16h-4zm-36 64h16v4H92z",fill:"currentcolor"}))}_renderMessage(e){return A(R,{class:S.messageHeading,level:this.headingLevel},e)}_renderRouteActions(){return A("div",{class:S.routeActions},A("button",{"aria-label":this.messages.clearRoute,bind:this,class:this.classes(S.clearRouteButton,D.button,D.buttonTertiary),onclick:this._handleClearRouteClick,tabIndex:0,type:"button"},this.messages.clearRoute))}_getSections(){const{layer:e}=this.viewModel;if(!e)return null;const{directionPoints:t,directionLines:s,stops:o}=e;if(null==t||null==s)return null;const i=[];let r=null;for(const n of t){const{objectId:e,stopId:t}=n;if(null!=t){const e=o.find((({objectId:e})=>e===t)),s=0===i.length;null!=r&&r.stop===e||(r={stop:e,directions:[],open:s},i.push(r));continue}if(null==r)continue;const a=s.find((({directionPointId:t})=>t===e));null!=a&&r.directions.push({directionPoint:n,directionLine:a})}return i}_renderManeuverSections(){return null==this._sections?null:A("div",{class:S.maneuvers,role:"group"},this._sections.map(((e,t)=>{const{open:s}=e;let o;e.directions.length>0&&s&&(o=A("ol",{class:S.maneuverList},e.directions.map((e=>this._renderManeuver(e)))));const i=this._sections.length>2,r=t===this._sections.length-1,n={[S.collapsibleSection]:i},a={[B.down]:!s,[B.up]:s};let l;if(i&&!r){const t=s?this.messagesCommon.close:this.messagesCommon.open;l=A("header",{class:this.classes(S.maneuverSectionHeader,S.maneuverSectionToggle),key:S.maneuverSectionHeader},A("div",{"aria-expanded":s.toString(),"aria-label":t,bind:this,class:S.maneuverSectionHeaderButton,"data-maneuver-section":e,onclick:this._handleSectionToggle,onkeydown:this._handleSectionToggle,role:"button",tabIndex:0,title:t},A(R,{class:S.maneuverSectionTitle,level:this.headingLevel},e.stop.name),A("span",{"aria-hidden":"true",class:this.classes(a)})))}else l=A("header",{class:S.maneuverSectionHeader,key:S.maneuverSectionHeader},A(R,{class:S.maneuverSectionTitle,level:this.headingLevel},e.stop.name));return A("section",{class:this.classes(S.maneuverSection,n),key:t},l,o)})))}_handleSectionToggle(e){const t=G(e.currentTarget);t&&(t.open=!t.open)}_renderCosts(){const e=this._getCostSummary(),{directionPoints:t}=this.viewModel.layer;if(null==t||null==e)return null;const{distance:s,duration:o}=e,{primaryCosts:i,secondaryCosts:r,zoomToRoute:n}=this.messages,a=this._renderEta();return A("div",{"aria-label":n,bind:this,class:S.directionCosts,onclick:this._handleSummaryInteraction,onkeydown:this._handleSummaryInteraction,role:"button",tabIndex:0,title:n},A("div",{class:S.costsDetails,role:"group"},A("div",{class:S.primaryCosts,title:i},o),A("div",{class:S.verticalSplitter}),A("div",{class:S.secondaryCosts,title:r},s)),a)}_renderEta(){return this.viewModel.departureOption===f.UNSPECIFIED?null:A("div",{class:S.arrivalTimeContainer,title:this.messages.eta},A("span",{class:S.arrivalTime},this.viewModel.formattedEta))}_handleSummaryInteraction(){this._activeManeuver=null,this._focusedManeuver=null,this.viewModel.clearHighlights(),this.zoomToRoute()}_getErrorMessage(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){e.viewModel.defaultSources.forEach((e=>{e.autoNavigate=!1}))}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.locationType??="street",T(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=k))}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_renderManeuver(e){const{directionPoint:t,directionLine:s}=e,{distance:o,duration:i}=s,{messages:r,messagesUnits:n,unit:a}=this,l=M(n,o??0,a),c=b(i??0),d=l&&c?`${l}&nbsp;&middot;&nbsp;${c}`:`${l}${c}`,u=U(t),{objectId:h,directionPointType:p}=t,v=C(p),m=`${S.maneuver}-${h}`,_=`${S.intermediateCost}-${h}`,g={[S.maneuverActive]:this._activeManeuver===s};return A("li",{"aria-labelledby":`${m} ${_}`,bind:this,class:this.classes(S.maneuver,g),"data-maneuver":s,key:s,onblur:this._handleManeuverBlur,onclick:this._handleManeuverClick,onfocus:this._handleManeuverFocus,onkeydown:this._handleManeuverClick,onmouseout:this._handleManeuverMouseOut,onmouseover:this._handleManeuverMouseOver,tabIndex:0},A("calcite-icon",{alt:"",class:S.maneuverIcon,icon:v}),A("div",{class:S.maneuverCostsContainer},u,A("div",{class:S.maneuverCosts},A("div",{class:S.horizontalSplitter}),A("div",{"aria-hidden":"true",class:S.intermediateCost,id:_,innerHTML:d,title:r.intermediateCosts}))))}_handleManeuverClick(e){const t=Y(e.currentTarget);if(!t)return;if(this._activeManeuver===t)return this._activeManeuver=null,void this.zoomToRoute();this._activeManeuver=t;const{geometry:s}=t;this.viewModel.centerAt(s),this.viewModel.highlight(t)}_handleManeuverMouseOver(e){if(this._activeManeuver||this._focusedManeuver)return;const t=Y(e.currentTarget);t&&this.viewModel.highlight(t)}_handleManeuverMouseOut(){this._activeManeuver||this._focusedManeuver||this.viewModel.clearHighlights()}_handleManeuverBlur(){this._activeManeuver||(this._focusedManeuver=null,this.viewModel.clearHighlights())}_handleManeuverFocus(e){if(this._activeManeuver)return;const t=Y(e.currentTarget);t&&(this._focusedManeuver=t,this.viewModel.highlight(t))}_getCostSummary(){const{messagesUnits:e,unit:t,viewModel:s}=this,{routeInfo:o}=s.layer;if(null==o)return null;const i=o.totalDistance??0,r=o.totalDuration??0;return{distance:M(e,i,t),duration:b(r)}}async _solveRoute(){this.viewModel.updateDepartureTime();const e=this.viewModel.layer?.stops.filter((({geometry:e})=>null!=e));if(e&&!(e.length<2))try{await this.viewModel.getDirections()}catch{}}};e([d()],V.prototype,"apiKey",null),e([d(p)],V.prototype,"defaultUnit",void 0),e([d()],V.prototype,"goToOverride",null),e([d()],V.prototype,"headingLevel",void 0),e([d()],V.prototype,"iconClass",void 0),e([d()],V.prototype,"icon",void 0),e([d()],V.prototype,"label",null),e([d({readOnly:!0})],V.prototype,"lastRoute",null),e([d()],V.prototype,"layer",null),e([d()],V.prototype,"maxStops",null),e([d(),j("esri/widgets/Directions/t9n/Directions")],V.prototype,"messages",void 0),e([d(),j("esri/t9n/common")],V.prototype,"messagesCommon",void 0),e([d(),j("esri/core/t9n/Units")],V.prototype,"messagesUnits",void 0),e([d()],V.prototype,"searchProperties",void 0),e([d()],V.prototype,"unit",null),e([d()],V.prototype,"view",null),e([d({type:y})],V.prototype,"viewModel",void 0),e([d()],V.prototype,"visibleElements",void 0),e([u("visibleElements")],V.prototype,"castVisibleElements",null),e([L()],V.prototype,"_handleStopIconClick",null),e([L()],V.prototype,"_handleClearRouteClick",null),e([L()],V.prototype,"_handleReverseStops",null),e([L()],V.prototype,"_handleRemoveStop",null),e([L()],V.prototype,"_handleSectionToggle",null),e([L()],V.prototype,"_handleSummaryInteraction",null),e([L()],V.prototype,"_handleManeuverClick",null),V=e([h("esri.widgets.Directions")],V);const K=V;function q(e){return e?.["data-mode"]}function W(e){return e?.["data-stop-index"]}function G(e){return e?.["data-maneuver-section"]}function Y(e){return e?.["data-maneuver"]}export{K as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import{handlesGroup as r}from"../../core/handleUtils.js";import{memoize as i}from"../../core/memoize.js";import{watch as o,on as n}from"../../core/reactiveUtils.js";import{union as s}from"../../core/SetUtils.js";import{getMetersPerVerticalUnitForSR as l}from"../../core/unitUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{s as u}from"../../chunks/vec32.js";import{create as p}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as d}from"../../geometry/ellipsoidUtils.js";import{create as m,fromPoints as v}from"../../geometry/support/ray.js";import{GeometryDescriptor as f}from"../../layers/support/ElevationQuery.js";import{externalToInternalIntersectOptions as y}from"../../views/3d/support/hitTest.js";import{newIntersector as h}from"../../views/3d/webgl-engine/lib/Intersector.js";import{StoreResults as w}from"../../views/3d/webgl-engine/lib/IntersectorInterfaces.js";import{toGraphic as _}from"../../views/3d/webgl-engine/lib/intersectorUtilsConversions.js";import g from"./ElevationProfileLine.js";const j=2e5;let I=class extends g{constructor(e){super(e),this.type="view",this.color=new t("#cf4ccf"),this.viewVisualizationEnabled=!0,this.include=null,this.exclude=null,this.numSamplesForPreview=50,this.numSamplesPerChunk=25,this._getQueryElevationDependencies=i(((e,t,r,i,o,n,s)=>({inputGraphicUid:null!=e?L(e):null,visibleLayers:t,maxIntersectionDistance:r,intersectOptions:i,view:o,stationary:n,spatialReference:s}))),this._vecA=p(),this._vecB=p(),this._ray=m()}get minDemResolution(){const e=this._viewModel?.view;if(null==e||"3d"!==e.type)return null;const t=e.pointsOfInterest?.focus?.renderLocation;if(!t)return null;return e.state.camera.computeRenderPixelSizeAt(t)*l(e.spatialReference)}get queryElevationDependencies(){const e=this._view;return e?this._getQueryElevationDependencies(this._viewModel?.input,this._visibleLayers,this._maxIntersectionDistance,this._intersectOptions,e,e.stationary,e.spatialReference):null}get _visibleLayers(){return this._view?.map?.allLayers?.filter((e=>e.visible)).toArray()??[]}get _intersectOptions(){const e=this._view;if(null==e||e.destroyed)return{};const t=y(e,{include:this.include,exclude:this.exclude}),r=y(e,{exclude:this._pointCloudLayers});return t.exclude=s(t.exclude,r.exclude),t}get _pointCloudLayers(){const e=this._view;return null==e?[]:e.allLayerViews.toArray().filter((e=>"point-cloud"===e.layer?.type)).map((e=>e.layer))}get _view(){const e=this._viewModel?.view;return null!=e&&"3d"===e.type?e:null}get _maxIntersectionDistance(){const e=this._view;return e?.renderCoordsHelper?d(e.spatialReference).radius/e.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY}get _intersector(){const e=this._view;if(null==e)return null;const t=h(e.state.viewingMode),r=t.options;return r.hud=!1,r.invisibleTerrain=!1,r.backfacesTerrain=!1,r.selectionMode=!1,r.store=w.ALL,t}async queryElevation(e,{noDataValue:t,signal:r}){const i=this.queryElevationDependencies;if(null==i)throw new Error("ElevationProfileLineInput: no dependencies");const o=this._intersector;if(null==o)throw new Error("ElevationProfileLineInput: no view");const{intersectOptions:n,view:s,spatialReference:l}=i,c=s.renderCoordsHelper,a=s.sceneIntersectionHelper,p=this._vecA,d=this._vecA,m=this._vecB,y=this._ray;if(!l)return{geometry:e,noDataValue:t};const h=await f.fromGeometry(e).project(l,r);if(!h)return{geometry:e,noDataValue:t};const w=h.coordinates,_=w.length;for(let f=0;f<_;++f){const e=w[f];u(m,e.x,e.y,e.z??0),c.toRenderCoords(m,l,m),c.setAltitude(p,j,m);const r=v(p,m,y);a.computeIntersection(r,o,n);const s=b(i,o.results.all);s?(s.getIntersectionPoint(d),c.fromRenderCoords(d,d,l),e.z=d[2]):e.z=t}return{geometry:h.export(),noDataValue:t}}attach(e){const t=()=>this._onChange();return r([super.attach(e),o((()=>this.queryElevationDependencies),t),n((()=>e.elevationProvider),"elevation-change",t,{onListenerAdd:t,onListenerRemove:t})])}};function b({view:e,inputGraphicUid:t,maxIntersectionDistance:r},i){for(const o of i){if(null!=o.distanceInRenderSpace&&o.distanceInRenderSpace>r)continue;const i=_(o,e);if(null==i||L(i)!==t)return o}return null}function L(e){if(e.layer&&"objectIdField"in e.layer){const t=e.attributes[e.layer.objectIdField];if(t)return`o-${e.layer.id}-${t}`}return`u-${e.uid}`}e([c({type:t,nonNullable:!0})],I.prototype,"color",void 0),e([c()],I.prototype,"viewVisualizationEnabled",void 0),e([c()],I.prototype,"include",void 0),e([c()],I.prototype,"exclude",void 0),e([c({readOnly:!0})],I.prototype,"minDemResolution",null),e([c()],I.prototype,"queryElevationDependencies",null),e([c()],I.prototype,"_visibleLayers",null),e([c()],I.prototype,"_intersectOptions",null),e([c()],I.prototype,"_pointCloudLayers",null),e([c()],I.prototype,"_view",null),e([c()],I.prototype,"_maxIntersectionDistance",null),e([c()],I.prototype,"_intersector",null),I=e([a("esri.widgets.ElevationProfile.ElevationProfileLineView")],I);const x=I;export{x as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import{handlesGroup as r}from"../../core/handleUtils.js";import{memoize as i}from"../../core/memoize.js";import{watch as o,on as n}from"../../core/reactiveUtils.js";import{union as s}from"../../core/SetUtils.js";import{getMetersPerVerticalUnitForSR as l}from"../../core/unitUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{s as u}from"../../chunks/vec32.js";import{create as p}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as d}from"../../geometry/ellipsoidUtils.js";import{create as m,fromPoints as v}from"../../geometry/support/ray.js";import{GeometryDescriptor as f}from"../../layers/support/ElevationQuery.js";import{externalToInternalIntersectOptions as y}from"../../views/3d/support/hitTest.js";import{newIntersector as h}from"../../views/3d/webgl-engine/lib/Intersector.js";import{StoreResults as w}from"../../views/3d/webgl-engine/lib/IntersectorInterfaces.js";import{toGraphic as _}from"../../views/3d/webgl-engine/lib/intersectorUtilsConversions.js";import g from"./ElevationProfileLine.js";const j=2e5;let I=class extends g{constructor(e){super(e),this.type="view",this.color=new t("#cf4ccf"),this.viewVisualizationEnabled=!0,this.include=null,this.exclude=null,this.numSamplesForPreview=50,this.numSamplesPerChunk=25,this._getQueryElevationDependencies=i(((e,t,r,i,o,n,s)=>({inputGraphicUid:null!=e?L(e):null,visibleLayers:t,maxIntersectionDistance:r,intersectOptions:i,view:o,stationary:n,spatialReference:s}))),this._vecA=p(),this._vecB=p(),this._ray=m()}get minDemResolution(){const e=this._viewModel?.view;if(null==e||"3d"!==e.type)return null;const t=e.pointsOfInterest?.focus?.renderLocation;if(!t)return null;return e.state.camera.computeRenderPixelSizeAt(t)*l(e.spatialReference)}get queryElevationDependencies(){const e=this._view;return e?this._getQueryElevationDependencies(this._viewModel?.input,this._visibleLayers,this._maxIntersectionDistance,this._intersectOptions,e,e.stationary,e.spatialReference):null}get _visibleLayers(){return this._view?.map?.allLayers?.filter((e=>e.visible)).toArray()??[]}get _intersectOptions(){const e=this._view;if(null==e||e.destroyed)return{};const t=y(e,{include:this.include,exclude:this.exclude}),r=y(e,{exclude:this._pointCloudLayers});return t.exclude=s(t.exclude,r.exclude),t}get _pointCloudLayers(){const e=this._view;return null==e?[]:e.allLayerViews.toArray().filter((e=>"point-cloud"===e.layer?.type)).map((e=>e.layer))}get _view(){const e=this._viewModel?.view;return null!=e&&"3d"===e.type?e:null}get _maxIntersectionDistance(){const e=this._view;return e?.renderCoordsHelper?d(e.spatialReference).radius/e.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY}get _intersector(){const e=this._view;if(null==e)return null;const t=h(e.state.viewingMode),r=t.options;return r.hud=!1,r.invisibleTerrain=!1,r.backfacesTerrain=!1,r.selectionMode=!1,r.store=w.ALL,t}async queryElevation(e,{noDataValue:t,signal:r}){const i=this.queryElevationDependencies;if(null==i)throw new Error("ElevationProfileLineInput: no dependencies");const o=this._intersector;if(null==o)throw new Error("ElevationProfileLineInput: no view");const{intersectOptions:n,view:s,spatialReference:l}=i,c=s.renderCoordsHelper,a=s.sceneIntersectionHelper,p=this._vecA,d=this._vecA,m=this._vecB,y=this._ray;if(!l)return{geometry:e,noDataValue:t};const h=await f.fromGeometry(e).project(l,r);if(!h)return{geometry:e,noDataValue:t};const w=h.coordinates,_=w.length;for(let f=0;f<_;++f){const e=w[f];u(m,e.x,e.y,e.z??0),c.toRenderCoords(m,l,m),c.setAltitude(p,j,m);const r=v(p,m,y);a.computeIntersection(r,o,n,!0);const s=b(i,o.results.all);s?(s.getIntersectionPoint(d),c.fromRenderCoords(d,d,l),e.z=d[2]):e.z=t}return{geometry:h.export(),noDataValue:t}}attach(e){const t=()=>this._onChange();return r([super.attach(e),o((()=>this.queryElevationDependencies),t),n((()=>e.elevationProvider),"elevation-change",t,{onListenerAdd:t,onListenerRemove:t})])}};function b({view:e,inputGraphicUid:t,maxIntersectionDistance:r},i){for(const o of i){if(null!=o.distanceInRenderSpace&&o.distanceInRenderSpace>r)continue;const i=_(o,e);if(null==i||L(i)!==t)return o}return null}function L(e){if(e.layer&&"objectIdField"in e.layer){const t=e.attributes[e.layer.objectIdField];if(t)return`o-${e.layer.id}-${t}`}return`u-${e.uid}`}e([c({type:t,nonNullable:!0})],I.prototype,"color",void 0),e([c()],I.prototype,"viewVisualizationEnabled",void 0),e([c()],I.prototype,"include",void 0),e([c()],I.prototype,"exclude",void 0),e([c({readOnly:!0})],I.prototype,"minDemResolution",null),e([c()],I.prototype,"queryElevationDependencies",null),e([c()],I.prototype,"_visibleLayers",null),e([c()],I.prototype,"_intersectOptions",null),e([c()],I.prototype,"_pointCloudLayers",null),e([c()],I.prototype,"_view",null),e([c()],I.prototype,"_maxIntersectionDistance",null),e([c()],I.prototype,"_intersector",null),I=e([a("esri.widgets.ElevationProfile.ElevationProfileLineView")],I);const x=I;export{x as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Logger.js";import{watch as n}from"../../core/reactiveUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{convertDateFormatToIntlOptions as o}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as r,formatNumber as l}from"../../intl/number.js";import{CodedValue as s}from"../../layers/support/CodedValue.js";import u from"../../layers/support/CodedValueDomain.js";import{isEditableLayer as d}from"../../layers/support/editableLayers.js";import{isNumericField as p,validateFieldValue as c,isStringField as m}from"../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as h}from"../../layers/support/layerUtils.js";import f from"../FeatureForm/FieldInput.js";import g from"./Grid/EditorColumn.js";import y from"../support/DatePicker.js";import{dateFieldsWithStringFieldValue as v,getLabelForDateFieldValue as b}from"../support/dateUtils.js";import{legacyIcon as _}from"../support/legacyIcon.js";import F from"../support/TimePicker.js";import{renderingSanitizer as E}from"../support/widgetUtils.js";const C={cancelEdit:"Escape"},I="esri-field-column",L={headerRoot:`${I}__header-root`,headerRootEditable:`${I}__header-root--editable`,headerRootMenuEnabled:`${I}__header-root--menu-enabled`,headerContent:`${I}__header-content`,headerLabel:`${I}__header-label`,input:`${I}__cell-input`,inputContainer:`${I}__cell__input-container`,dateInputContainer:`${I}__cell__date-input-container`,dateInputWrapper:`${I}__cell__date-input-wrapper`,button:`${I}__button`},D=o("short-date-short-time"),w=o("short-date"),j={useGrouping:!0,maximumFractionDigits:20};let V=class extends g{constructor(e){super(e),this._fieldInput=null,this.cellValueFormatFunction=({rowData:e,value:t})=>{if(this.formatFunction){const{template:e,field:n}=this;return this.formatFunction({template:e,field:n,value:E.sanitize(t)})}if(null===t)return"&nbsp;";const{field:n}=this,i=e?.item?.feature,a=this._getDomainForFeature(i);if(a){const e=this._getComputedDomain(t,a);if("date"===n.type&&"range"===a.type)return this._formatDateValueForDisplay(n,e);if(p(n)&&"range"===a.type){const e=this.template?.format,n=e?r(e):j;return l(parseFloat(t),n)}return v.has(n.type)?"range"===a.type?E.sanitize(b(n,e)):E.sanitize(e):e}if("date"===n.type||v.has(n.type))return this._formatDateValueForDisplay(n,t);if(p(n)){const e=this.template?.format,n=e?r(e):j;return l(parseFloat(t),n)}return E.sanitize(t)},this.cellValueValidatorFunction=({oldValue:e,value:n})=>{const{_fieldInput:i,field:a}=this;return!(i&&!i.valid)&&((!this.required||null!=n&&""!==n)&&(p(a)&&c(a,n)?(t.getLogger(this).warn("value-exceeds-valid-range","Field value exceeds valid range. Attempted edit was rejected."),!1):e!==n))},this.editingEnabled=!1,this.expressionInfos=null,this.field=null,this.formatFunction=null,this.headerRenderFunction=e=>{const{root:t}=e,{editable:n,editingEnabled:i,headerMenuEnabled:a,sortable:o}=this;if(!t.childElementCount){t.classList.add(L.headerRoot);const e=document.createElement("div");e.classList.add(L.headerContent),t.appendChild(e);const n=document.createElement("div");if(n.classList.add(_.locked),e.appendChild(n),o&&this.sortElement)e.appendChild(this.sortElement);else{const t=document.createElement("span");t.classList.add(L.headerLabel),t.textContent=this.label,e.appendChild(t)}this.menu?.container&&e.appendChild(this.menu.container)}i&&!n?t.classList.add(L.headerRootEditable):t.classList.remove(L.headerRootEditable),a?t.classList.add(L.headerRootMenuEnabled):t.classList.remove(L.headerRootMenuEnabled)},this.inputRenderFunction=({root:e,column:n,rowData:i})=>{if(this.activeEditInfo?.updating||!this.editable)return;const a=this.getCellValue(n,i),{field:o}=this;if(p(o)&&c(o,a))return void t.getLogger(this).warn("value-exceeds-valid-range","Field value is beyond supported limit. Editing is disabled for this field value.");const r=this.createInputElement({root:e,column:n,rowData:i,value:a});if(this._set("activeEditInfo",{column:n,input:r,root:e,rowData:i,updating:!0,oldValue:a}),"date"===this.field.type)return void this._renderDateEditors(a,e,r);const l=this.createInputContainer();l.appendChild(r),this.removeCellContent(e),e.appendChild(l),r.focus(),r instanceof HTMLInputElement&&r.select()},this.layer=null,this.parseInputValueFunction=({input:e})=>{const t=this._fieldInput;if(!t)return null;const n=e.value,{dataType:i,required:a}=t;return a||""!==n?"number"===i||"date"===i?parseFloat(n):"text"===i?n.trim():n:null},this.store=null,this.template=null,this.updateRowItemFunction=({rowData:e,column:t,value:n})=>{e&&t.path&&(e.item.feature.attributes[t.path]=n)},this.updateStoreItemFunction=async({rowData:e,column:t,value:n})=>{if(!e||!this.store||!t.path)return;const i=e.item.objectId,a=this.store.getObjectIdIndex(i)??e.index;await this.store.updateItem({index:a,name:t.path,value:n})}}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get description(){return this.template?.description??this.field?.description??null}get editable(){const{editingEnabled:e,field:t,layer:n,template:i}=this;if(null==t||null==n)return!1;const a=d(n),o=h(n),r=o?.operations.supportsUpdate;return!!(t.editable&&a&&r&&"oid"!==t.type)&&(!v.has(t.type)&&(e?!(!1===i?.editable):!!i?.editable))}get header(){return this.template?.label||this.alias||this.path||null}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,template:t}=this,n=e?.length??-1,i=t?.input&&"maxLength"in t.input?t.input.maxLength:null;return null!=i&&!isNaN(i)&&i>=-1&&(-1===n||i<=n)?i:n}get minLength(){const{template:e,maxLength:t}=this,n=e?.input&&"minLength"in e.input?e.input.minLength:null;return t&&n<=t?n:null}get name(){return this.field?.name}get nullable(){return this.field?.nullable??!1}get path(){return this.field?.name}get required(){const{field:e,template:t}=this,n=e?.nullable,i=t?.required;return this.editable&&(!n||!0===i)}createInputElement({rowData:e,value:t}){const n=e?.item;if(!n?.feature)return null;this._fieldInput=this._setUpFieldInput(n.feature,t);const{field:i,maxLength:a,minLength:o,required:r}=this,{domain:l}=this._fieldInput;let s;"coded-value"===l?.type?(s=this._createSelectElement(t,l.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),this._fieldInput),s.onchange=()=>{s.onblur=null,d()}):(s=document.createElement("input"),s.type=p(i)?"number":"text",a>-1&&(s.maxLength=a),o>0&&(s.minLength=o)),s.classList.add(L.input),s.value=t,s.required=r;let u=!1;s.onkeydown=e=>{u=e.key===C.cancelEdit},s.onblur=()=>{s.onblur=null,d()};const d=()=>{u?this.cancel():this.submit(),this._fieldInput=null};return s}createInputContainer(){const e=document.createElement("div");return e.classList.add(L.inputContainer),e}getCellValue({path:e},t){return e&&t?.item?.feature?.attributes?t.item.feature.attributes?.[e]:null}_formatDateValueForDisplay(e,t){const{timeZone:n,timeZoneName:i}=this;return null!=t?b(e,t,{...this._getDateFormatOptions(),timeZone:n??void 0,timeZoneName:i??void 0}):null}_renderDateEditors(e,t,i){const{messagesCommon:a,template:o,timeZone:r}=this,l=e?new Date(e):new Date(Date.now()),s=new y({dateInputEnabled:!0,timeZone:r,value:l}),u=new F({timeZone:r,value:l});i.value=l.getTime().toString();let d=!e;const p=()=>{d=!0;const e=this._getCombinedDateTime(s.value,u.value);i.value=e.getTime().toString()},c=()=>{d?this.submit():this.cancel()},m=()=>{i.value=null,this.submit()};n((()=>[s.value,u.value]),(()=>p()));const h=document.createElement("div"),f=document.createElement("div");s.container=h,u.container=f;const g=document.createElement("button");g.classList.add(L.button,_.save),g.onclick=()=>c(),g.title=a?.save;const v=document.createElement("button");v.classList.add(L.button,_.trash),v.onclick=()=>m(),v.title=a?.clear;const b=document.createElement("div");b.classList.add(L.dateInputWrapper),b.appendChild(h),(!o?.input||"includeTime"in o.input&&!1!==o.input.includeTime)&&b.appendChild(f);const E=document.createElement("div");E.classList.add(L.dateInputContainer),E.appendChild(b),E.appendChild(g),E.appendChild(v),s.when((()=>{const e=s._inputOrButtonNode;e&&(e.onblur=e=>{const t=e.relatedTarget;t&&t.className.includes("esri-date-picker")||s.close(!1)})})),this.removeCellContent(t),t.appendChild(E)}_createSelectElement(e,t,n){let i=!1;const a=t.map((t=>{t.value===e&&(i=!0);const n=document.createElement("option");return n.text=t.name,n.value=t.value,n}));if(null!=e&&""!==e&&!i){const t=document.createElement("option");t.text=e,t.value=e,a.unshift(t)}if(!n.required&&null==n.value){const e=document.createElement("option");e.value="",a.unshift(e)}const o=document.createElement("select");return a.forEach((e=>o.add(e))),o.value=e,o}_setUpFieldInput(e,t){const{field:n,layer:i}=this,a=new f({feature:e,initialFeature:e.clone(),field:n,layer:i});return a.set("value",t),a}_isDomainCompatible(e){const{field:t}=this;if(e&&"coded-value"===e.type){const n=typeof e.codedValues[0].code;if("string"===n&&m(t)||"number"===n&&p(t))return!0}return!(!e||"range"!==e.type||!p(t))}_getDomainForFeature(e){const{layer:t,name:n,template:i}=this;if(!t)return null;if("wfs"===t.type||"geojson"===t.type||"csv"===t.type)return null;if(i?.domain&&this._isDomainCompatible(i.domain))return i.domain;const{typeIdField:a}=t,o=a===n,r=this.field.domain;if(o&&!r)return new u({name:"__internal-type-based-coded-value-domain__",codedValues:t.types?.map((({id:e,name:t})=>new s({code:e,name:t})))});return a&&null!=n&&t.getFieldDomain(n,{feature:e})||r}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const n=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return n&&n.length?n[0].name:e}return null}_getCombinedDateTime(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}_getDateFormatOptions(){const{template:e}=this,t=e?.format?.dateFormat;return t?o(t):e?.input&&"includeTime"in e.input&&!1===e.input.includeTime?w:D}};e([i({readOnly:!0})],V.prototype,"alias",null),e([i()],V.prototype,"cellValueFormatFunction",void 0),e([i()],V.prototype,"cellValueValidatorFunction",void 0),e([i({readOnly:!0})],V.prototype,"defaultValue",null),e([i({readOnly:!0})],V.prototype,"description",null),e([i({readOnly:!0})],V.prototype,"editable",null),e([i()],V.prototype,"editingEnabled",void 0),e([i()],V.prototype,"expressionInfos",void 0),e([i()],V.prototype,"field",void 0),e([i()],V.prototype,"formatFunction",void 0),e([i({readOnly:!0})],V.prototype,"header",null),e([i()],V.prototype,"headerRenderFunction",void 0),e([i()],V.prototype,"inputRenderFunction",void 0),e([i()],V.prototype,"layer",void 0),e([i({readOnly:!0})],V.prototype,"loadingMessage",null),e([i()],V.prototype,"maxLength",null),e([i()],V.prototype,"minLength",null),e([i({readOnly:!0})],V.prototype,"name",null),e([i({readOnly:!0})],V.prototype,"nullable",null),e([i()],V.prototype,"parseInputValueFunction",void 0),e([i({readOnly:!0})],V.prototype,"path",null),e([i({readOnly:!0})],V.prototype,"required",null),e([i()],V.prototype,"store",void 0),e([i()],V.prototype,"template",void 0),e([i()],V.prototype,"updateRowItemFunction",void 0),e([i()],V.prototype,"updateStoreItemFunction",void 0),V=e([a("esri.widgets.FeatureTable.FieldColumn")],V);const x=V;export{x as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Logger.js";import{watch as n}from"../../core/reactiveUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{convertDateFormatToIntlOptions as o}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as r,formatNumber as l}from"../../intl/number.js";import{CodedValue as s}from"../../layers/support/CodedValue.js";import u from"../../layers/support/CodedValueDomain.js";import{isEditableLayer as d}from"../../layers/support/editableLayers.js";import{isNumericField as p,validateFieldValue as c,isStringField as m}from"../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as h}from"../../layers/support/layerUtils.js";import f from"../FeatureForm/FieldInput.js";import g from"./Grid/EditorColumn.js";import y from"../support/DatePicker.js";import{dateFieldsWithStringFieldValue as v,getLabelForDateFieldValue as b}from"../support/dateUtils.js";import{legacyIcon as _}from"../support/legacyIcon.js";import F from"../support/TimePicker.js";import{renderingSanitizer as E}from"../support/widgetUtils.js";const C={cancelEdit:"Escape"},I="esri-field-column",L={headerRoot:`${I}__header-root`,headerRootEditable:`${I}__header-root--editable`,headerRootMenuEnabled:`${I}__header-root--menu-enabled`,headerContent:`${I}__header-content`,headerLabel:`${I}__header-label`,input:`${I}__cell-input`,inputContainer:`${I}__cell__input-container`,dateInputContainer:`${I}__cell__date-input-container`,dateInputWrapper:`${I}__cell__date-input-wrapper`,button:`${I}__button`},D=o("short-date-short-time"),w=o("short-date"),j={useGrouping:!0,maximumFractionDigits:20};let V=class extends g{constructor(e){super(e),this._fieldInput=null,this.cellValueFormatFunction=({rowData:e,value:t})=>{if(this.formatFunction){const{template:e,field:n}=this;return this.formatFunction({template:e,field:n,value:E.sanitize(t)})}if(null===t)return"&nbsp;";const{field:n}=this,i=e?.item?.feature,a=this._getDomainForFeature(i);if(a){const e=this._getComputedDomain(t,a);if("date"===n.type&&"range"===a.type)return this._formatDateValueForDisplay(n,e);if(p(n)&&"range"===a.type){const e=this.template?.format,n=e?r(e):j;return l(parseFloat(t),n)}return v.has(n.type)?"range"===a.type?E.sanitize(b(n,e)):E.sanitize(e):e}if("date"===n.type||v.has(n.type))return this._formatDateValueForDisplay(n,t);if(p(n)){const e=this.template?.format,n=e?r(e):j;return l(parseFloat(t),n)}return E.sanitize(t)},this.cellValueValidatorFunction=({oldValue:e,value:n})=>{const{_fieldInput:i,field:a}=this;return!(i&&!i.valid)&&((!this.required||null!=n&&""!==n)&&(p(a)&&c(a,n)?(t.getLogger(this).warn("value-exceeds-valid-range","Field value exceeds valid range. Attempted edit was rejected."),!1):e!==n))},this.editingEnabled=!1,this.expressionInfos=null,this.field=null,this.formatFunction=null,this.headerRenderFunction=e=>{const{root:t}=e,{editable:n,editingEnabled:i,headerMenuEnabled:a,sortable:o}=this;if(!t.childElementCount){t.classList.add(L.headerRoot);const e=document.createElement("div");e.classList.add(L.headerContent),t.appendChild(e);const n=document.createElement("div");if(n.classList.add(_.locked),e.appendChild(n),o&&this.sortElement)e.appendChild(this.sortElement);else{const t=document.createElement("span");t.classList.add(L.headerLabel),t.textContent=this.label,e.appendChild(t)}this.menu?.container&&e.appendChild(this.menu.container)}i&&!n?t.classList.add(L.headerRootEditable):t.classList.remove(L.headerRootEditable),a?t.classList.add(L.headerRootMenuEnabled):t.classList.remove(L.headerRootMenuEnabled)},this.inputRenderFunction=({root:e,column:n,rowData:i})=>{if(this.activeEditInfo?.updating||!this.editable)return;const a=this.getCellValue(n,i),{field:o}=this;if(p(o)&&c(o,a))return void t.getLogger(this).warn("value-exceeds-valid-range","Field value is beyond supported limit. Editing is disabled for this field value.");const r=this.createInputElement({root:e,column:n,rowData:i,value:a});if(this._set("activeEditInfo",{column:n,input:r,root:e,rowData:i,updating:!0,oldValue:a}),"date"===this.field.type)return void this._renderDateEditors(a,e,r);const l=this.createInputContainer();l.appendChild(r),this.removeCellContent(e),e.appendChild(l),r.focus(),r instanceof HTMLInputElement&&r.select()},this.layer=null,this.parseInputValueFunction=({input:e})=>{const t=this._fieldInput;if(!t)return null;const n=e.value,{dataType:i,required:a}=t;return a||""!==n?"number"===i||"date"===i?parseFloat(n):"text"===i?n.trim():n:null},this.sortable=!0,this.store=null,this.template=null,this.updateRowItemFunction=({rowData:e,column:t,value:n})=>{e&&t.path&&(e.item.feature.attributes[t.path]=n)},this.updateStoreItemFunction=async({rowData:e,column:t,value:n})=>{if(!e||!this.store||!t.path)return;const i=e.item.objectId,a=this.store.getObjectIdIndex(i)??e.index;await this.store.updateItem({index:a,name:t.path,value:n})}}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get description(){return this.template?.description??this.field?.description??null}get editable(){const{editingEnabled:e,field:t,layer:n,template:i}=this;if(null==t||null==n)return!1;const a=d(n),o=h(n),r=o?.operations.supportsUpdate;return!!(t.editable&&a&&r&&"oid"!==t.type)&&(!v.has(t.type)&&(e?!(!1===i?.editable):!!i?.editable))}get header(){return this.template?.label||this.alias||this.path||null}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,template:t}=this,n=e?.length??-1,i=t?.input&&"maxLength"in t.input?t.input.maxLength:null;return null!=i&&!isNaN(i)&&i>=-1&&(-1===n||i<=n)?i:n}get minLength(){const{template:e,maxLength:t}=this,n=e?.input&&"minLength"in e.input?e.input.minLength:null;return t&&n<=t?n:null}get name(){return this.field?.name}get nullable(){return this.field?.nullable??!1}get path(){return this.field?.name}get required(){const{field:e,template:t}=this,n=e?.nullable,i=t?.required;return this.editable&&(!n||!0===i)}createInputElement({rowData:e,value:t}){const n=e?.item;if(!n?.feature)return null;this._fieldInput=this._setUpFieldInput(n.feature,t);const{field:i,maxLength:a,minLength:o,required:r}=this,{domain:l}=this._fieldInput;let s;"coded-value"===l?.type?(s=this._createSelectElement(t,l.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),this._fieldInput),s.onchange=()=>{s.onblur=null,d()}):(s=document.createElement("input"),s.type=p(i)?"number":"text",a>-1&&(s.maxLength=a),o>0&&(s.minLength=o)),s.classList.add(L.input),s.value=t,s.required=r;let u=!1;s.onkeydown=e=>{u=e.key===C.cancelEdit},s.onblur=()=>{s.onblur=null,d()};const d=()=>{u?this.cancel():this.submit(),this._fieldInput=null};return s}createInputContainer(){const e=document.createElement("div");return e.classList.add(L.inputContainer),e}getCellValue({path:e},t){return e&&t?.item?.feature?.attributes?t.item.feature.attributes?.[e]:null}_formatDateValueForDisplay(e,t){const{timeZone:n,timeZoneName:i}=this;return null!=t?b(e,t,{...this._getDateFormatOptions(),timeZone:n??void 0,timeZoneName:i??void 0}):null}_renderDateEditors(e,t,i){const{messagesCommon:a,template:o,timeZone:r}=this,l=e?new Date(e):new Date(Date.now()),s=new y({dateInputEnabled:!0,timeZone:r,value:l}),u=new F({timeZone:r,value:l});i.value=l.getTime().toString();let d=!e;const p=()=>{d=!0;const e=this._getCombinedDateTime(s.value,u.value);i.value=e.getTime().toString()},c=()=>{d?this.submit():this.cancel()},m=()=>{i.value=null,this.submit()};n((()=>[s.value,u.value]),(()=>p()));const h=document.createElement("div"),f=document.createElement("div");s.container=h,u.container=f;const g=document.createElement("button");g.classList.add(L.button,_.save),g.onclick=()=>c(),g.title=a?.save;const v=document.createElement("button");v.classList.add(L.button,_.trash),v.onclick=()=>m(),v.title=a?.clear;const b=document.createElement("div");b.classList.add(L.dateInputWrapper),b.appendChild(h),(!o?.input||"includeTime"in o.input&&!1!==o.input.includeTime)&&b.appendChild(f);const E=document.createElement("div");E.classList.add(L.dateInputContainer),E.appendChild(b),E.appendChild(g),E.appendChild(v),s.when((()=>{const e=s._inputOrButtonNode;e&&(e.onblur=e=>{const t=e.relatedTarget;t&&t.className.includes("esri-date-picker")||s.close(!1)})})),this.removeCellContent(t),t.appendChild(E)}_createSelectElement(e,t,n){let i=!1;const a=t.map((t=>{t.value===e&&(i=!0);const n=document.createElement("option");return n.text=t.name,n.value=t.value,n}));if(null!=e&&""!==e&&!i){const t=document.createElement("option");t.text=e,t.value=e,a.unshift(t)}if(!n.required&&null==n.value){const e=document.createElement("option");e.value="",a.unshift(e)}const o=document.createElement("select");return a.forEach((e=>o.add(e))),o.value=e,o}_setUpFieldInput(e,t){const{field:n,layer:i}=this,a=new f({feature:e,initialFeature:e.clone(),field:n,layer:i});return a.set("value",t),a}_isDomainCompatible(e){const{field:t}=this;if(e&&"coded-value"===e.type){const n=typeof e.codedValues[0].code;if("string"===n&&m(t)||"number"===n&&p(t))return!0}return!(!e||"range"!==e.type||!p(t))}_getDomainForFeature(e){const{layer:t,name:n,template:i}=this;if(!t)return null;if("wfs"===t.type||"geojson"===t.type||"csv"===t.type)return null;if(i?.domain&&this._isDomainCompatible(i.domain))return i.domain;const{typeIdField:a}=t,o=a===n,r=this.field.domain;if(o&&!r)return new u({name:"__internal-type-based-coded-value-domain__",codedValues:t.types?.map((({id:e,name:t})=>new s({code:e,name:t})))});return a&&null!=n&&t.getFieldDomain(n,{feature:e})||r}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const n=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return n&&n.length?n[0].name:e}return null}_getCombinedDateTime(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}_getDateFormatOptions(){const{template:e}=this,t=e?.format?.dateFormat;return t?o(t):e?.input&&"includeTime"in e.input&&!1===e.input.includeTime?w:D}};e([i({readOnly:!0})],V.prototype,"alias",null),e([i()],V.prototype,"cellValueFormatFunction",void 0),e([i()],V.prototype,"cellValueValidatorFunction",void 0),e([i({readOnly:!0})],V.prototype,"defaultValue",null),e([i({readOnly:!0})],V.prototype,"description",null),e([i({readOnly:!0})],V.prototype,"editable",null),e([i()],V.prototype,"editingEnabled",void 0),e([i()],V.prototype,"expressionInfos",void 0),e([i()],V.prototype,"field",void 0),e([i()],V.prototype,"formatFunction",void 0),e([i({readOnly:!0})],V.prototype,"header",null),e([i()],V.prototype,"headerRenderFunction",void 0),e([i()],V.prototype,"inputRenderFunction",void 0),e([i()],V.prototype,"layer",void 0),e([i({readOnly:!0})],V.prototype,"loadingMessage",null),e([i()],V.prototype,"maxLength",null),e([i()],V.prototype,"minLength",null),e([i({readOnly:!0})],V.prototype,"name",null),e([i({readOnly:!0})],V.prototype,"nullable",null),e([i()],V.prototype,"parseInputValueFunction",void 0),e([i({readOnly:!0})],V.prototype,"path",null),e([i({readOnly:!0})],V.prototype,"required",null),e([i()],V.prototype,"sortable",void 0),e([i()],V.prototype,"store",void 0),e([i()],V.prototype,"template",void 0),e([i()],V.prototype,"updateRowItemFunction",void 0),e([i()],V.prototype,"updateStoreItemFunction",void 0),V=e([a("esri.widgets.FeatureTable.FieldColumn")],V);const x=V;export{x as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Evented.js";import{watch as o}from"../../../core/reactiveUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import n from"./support/ButtonMenu.js";import{legacyIcon as s}from"../../support/legacyIcon.js";import{renderingSanitizer as l}from"../../support/widgetUtils.js";const a="esri-column",d={menuContainer:`${a}__menu-container`,sorter:`${a}__sorter`,headerContent:`${a}__header-content`,headerLabel:`${a}__header-label`},h={keyboardSort1:"Enter",keyboardSort2:"Spacebar"};let c=class extends e.EventedAccessor{constructor(t){super(t),this._menuContainer=document.createElement("div"),this.activeRowIndex=null,this.autoWidth=!1,this.cellValueFormatFunction=({value:t})=>l.sanitize(t),this.direction=null,this.flexGrow=1,this.footerRenderFunction=null,this.frozen=!1,this.grid=null,this.header=null,this.headerRenderFunction=t=>{const{root:e}=t;if(this.removeCellContent(e),e.classList.add(d.headerContent),this.sortable)this.headerSorterRenderFunction(t);else{const t=document.createElement("div");t.classList.add(d.headerLabel),t.textContent=this.label,e.appendChild(t)}this.headerMenuEnabled&&this.headerMenuRenderFunction(t)},this.headerMenuRenderFunction=({root:t})=>{this.menu?.items?.length&&t.appendChild(this._menuContainer)},this.headerSorterRenderFunction=({root:t})=>{const{label:e,sortElement:o}=this;if(!o)return void(t.textContent=e);o.textContent!==e&&o.setAttribute("textContent",e),t.appendChild(o);const i=this.grid?.getSlotElementByName(t.slot),r=i?.parentElement;r&&!r.onkeydown&&(r.onkeydown=({key:t})=>{t!==h.keyboardSort1&&t!==h.keyboardSort2||o.click()})},this.hidden=!1,this.headerMenuEnabled=!0,this.initialSortPriority=null,this.menu=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.path=null,this.renderFunction=({root:t,column:e,rowData:o})=>{const i=this.getCellValue(e,o),r=this.cellValueFormatFunction({column:e,rowData:o,value:i});t.innerHTML!==r&&(t.innerHTML=r)},this.resizable=!0,this.sortable=!0,this.textAlign="start",this.timeZone=null,this.timeZoneName=null,this.width=200}initialize(){const{messages:t,path:e}=this;this._set("sortElement",this.createSortElement()),this.sortElement.setAttribute("path",e??""),this._menuContainer.classList.add(d.menuContainer),this.menu=new n({container:this._menuContainer,label:t?.options,iconClass:s.handleHorizontal,...this.menuConfig}),this.menu.set("items",this.getMenuItems()),this.addHandles([o((()=>this.direction),(t=>{const{sortElement:e}=this;this.sortable&&e&&(t?this.sortElement.direction!==t&&e.setAttribute("direction",t):e.removeAttribute("direction"))})),o((()=>this.hidden),(()=>this.menu?.set("open",!1))),o((()=>this.path),(t=>{const{sortElement:e}=this,o=t??"";e&&e.path!==o&&e.setAttribute("path",o)}))])}destroy(){this.menu?.destroy()}get label(){return l.sanitize(this.header??this.path??"")}getMenuItems(){const{menuConfig:t,sortable:e}=this,o=t?.items,i=this.getSortMenuItems(),r=[];return e&&r.push(...i),o?.length&&r.push(...o),r.length?r:null}getSortMenuItems(){const{messages:t}=this;return[{selected:"asc"===this.direction,iconClass:s.arrowUp,label:t?.sortAsc,autoCloseMenu:!0,clickFunction:()=>this.set("direction","asc"!==this.direction?"asc":null)},{selected:"desc"===this.direction,iconClass:s.arrowDown,label:t?.sortDesc,autoCloseMenu:!0,clickFunction:()=>this.set("direction","desc"!==this.direction?"desc":null)}]}getCellValue(t,e){return t.path&&e?.item?e.item[t.path]:""}createSortElement(){const{direction:t,label:e,path:o,initialSortPriority:i}=this,r=document.createElement("vaadin-grid-sorter");return r.classList.add(d.sorter),r.setAttribute("path",o??""),r.setAttribute("title",e),r.textContent=e,t&&r.setAttribute("direction",t),null!=i&&(r._initialOrder=i),r.addEventListener("direction-changed",(()=>{this.direction!==r.direction&&this._set("direction",r.direction)})),r}removeCellContent(t){if(t&&t.firstChild)try{for(;t?.firstChild;)t?.removeChild(t.firstChild)}catch(e){}}};t([i()],c.prototype,"activeRowIndex",void 0),t([i()],c.prototype,"autoWidth",void 0),t([i()],c.prototype,"cellValueFormatFunction",void 0),t([i()],c.prototype,"direction",void 0),t([i()],c.prototype,"flexGrow",void 0),t([i()],c.prototype,"footerRenderFunction",void 0),t([i()],c.prototype,"frozen",void 0),t([i()],c.prototype,"grid",void 0),t([i()],c.prototype,"header",void 0),t([i()],c.prototype,"headerRenderFunction",void 0),t([i()],c.prototype,"headerMenuRenderFunction",void 0),t([i()],c.prototype,"headerSorterRenderFunction",void 0),t([i()],c.prototype,"hidden",void 0),t([i()],c.prototype,"headerMenuEnabled",void 0),t([i({constructOnly:!0})],c.prototype,"initialSortPriority",void 0),t([i({readOnly:!0})],c.prototype,"label",null),t([i()],c.prototype,"menu",void 0),t([i()],c.prototype,"menuConfig",void 0),t([i()],c.prototype,"messages",void 0),t([i()],c.prototype,"messagesCommon",void 0),t([i()],c.prototype,"messagesURIUtils",void 0),t([i()],c.prototype,"path",void 0),t([i()],c.prototype,"renderFunction",void 0),t([i()],c.prototype,"resizable",void 0),t([i()],c.prototype,"sortable",void 0),t([i({readOnly:!0})],c.prototype,"sortElement",void 0),t([i()],c.prototype,"textAlign",void 0),t([i()],c.prototype,"timeZone",void 0),t([i()],c.prototype,"timeZoneName",void 0),t([i()],c.prototype,"width",void 0),c=t([r("esri.widgets.FeatureTable.Grid.Column")],c);const u=c;export{u as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Evented.js";import{watch as o}from"../../../core/reactiveUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import r from"./support/ButtonMenu.js";import{legacyIcon as s}from"../../support/legacyIcon.js";import{renderingSanitizer as l}from"../../support/widgetUtils.js";const d="esri-column",a={menuContainer:`${d}__menu-container`,sorter:`${d}__sorter`,headerContent:`${d}__header-content`,headerLabel:`${d}__header-label`},h={keyboardSort1:"Enter",keyboardSort2:"Spacebar"};let c=class extends e.EventedAccessor{constructor(t){super(t),this._menuContainer=document.createElement("div"),this.activeRowIndex=null,this.autoWidth=!1,this.cellValueFormatFunction=({value:t})=>l.sanitize(t),this.direction=null,this.flexGrow=1,this.footerRenderFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.grid=null,this.header=null,this.headerRenderFunction=t=>{const{root:e}=t;if(this.removeCellContent(e),e.classList.add(a.headerContent),this.sortable)this.headerSorterRenderFunction(t);else{const t=document.createElement("div");t.classList.add(a.headerLabel);const o=document.createElement("span");o.textContent=this.label,o.setAttribute("title",this.label),t.appendChild(o),e.appendChild(t)}this.headerMenuEnabled&&this.headerMenuRenderFunction(t)},this.headerMenuRenderFunction=({root:t})=>{this.menu?.items?.length&&t.appendChild(this._menuContainer)},this.headerSorterRenderFunction=({root:t})=>{const{label:e,sortElement:o}=this;if(!o)return void(t.textContent=e);o.textContent!==e&&o.setAttribute("textContent",e),t.appendChild(o);const i=this.grid?.getSlotElementByName(t.slot),n=i?.parentElement;n&&!n.onkeydown&&(n.onkeydown=({key:t})=>{t!==h.keyboardSort1&&t!==h.keyboardSort2||o.click()})},this.hidden=!1,this.headerMenuEnabled=!0,this.initialSortPriority=null,this.menu=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.path=null,this.renderFunction=({root:t,column:e,rowData:o})=>{const i=this.getCellValue(e,o),n=this.cellValueFormatFunction({column:e,rowData:o,value:i});t.innerHTML!==n&&(t.innerHTML=n)},this.resizable=!0,this.sortable=!1,this.textAlign="start",this.timeZone=null,this.timeZoneName=null,this.width=200}initialize(){const{messages:t,path:e}=this;this._set("sortElement",this.createSortElement()),this.sortElement.setAttribute("path",e??""),this._menuContainer.classList.add(a.menuContainer),this.menu=new r({container:this._menuContainer,label:t?.options,iconClass:s.handleHorizontal,...this.menuConfig}),this.menu.set("items",this.getMenuItems()),this.addHandles([o((()=>this.direction),(t=>{const{sortElement:e}=this;this.sortable&&e&&(t?this.sortElement.direction!==t&&e.setAttribute("direction",t):e.removeAttribute("direction"))})),o((()=>this.hidden),(()=>this.menu?.set("open",!1))),o((()=>this.path),(t=>{const{sortElement:e}=this,o=t??"";e&&e.path!==o&&e.setAttribute("path",o)}))])}destroy(){this.menu?.destroy()}get label(){return l.sanitize(this.header??this.path??"")}getMenuItems(){const{menuConfig:t,sortable:e}=this,o=t?.items,i=this.getSortMenuItems(),n=[];return e&&n.push(...i),o?.length&&n.push(...o),n.length?n:null}getSortMenuItems(){const{messages:t}=this;return[{selected:"asc"===this.direction,iconClass:s.arrowUp,label:t?.sortAsc,autoCloseMenu:!0,clickFunction:()=>this.set("direction","asc"!==this.direction?"asc":null)},{selected:"desc"===this.direction,iconClass:s.arrowDown,label:t?.sortDesc,autoCloseMenu:!0,clickFunction:()=>this.set("direction","desc"!==this.direction?"desc":null)}]}getCellValue(t,e){return t.path&&e?.item?e.item[t.path]:""}createSortElement(){const{direction:t,label:e,path:o,initialSortPriority:i}=this,n=document.createElement("vaadin-grid-sorter");return n.classList.add(a.sorter),n.setAttribute("path",o??""),n.setAttribute("title",e),n.textContent=e,t&&n.setAttribute("direction",t),null!=i&&(n._initialOrder=i),n.addEventListener("direction-changed",(()=>{this.direction!==n.direction&&this._set("direction",n.direction)})),n}removeCellContent(t){if(t&&t.firstChild)try{for(;t?.firstChild;)t?.removeChild(t.firstChild)}catch(e){}}};t([i()],c.prototype,"activeRowIndex",void 0),t([i()],c.prototype,"autoWidth",void 0),t([i()],c.prototype,"cellValueFormatFunction",void 0),t([i()],c.prototype,"direction",void 0),t([i()],c.prototype,"flexGrow",void 0),t([i()],c.prototype,"footerRenderFunction",void 0),t([i()],c.prototype,"frozen",void 0),t([i()],c.prototype,"frozenToEnd",void 0),t([i()],c.prototype,"grid",void 0),t([i()],c.prototype,"header",void 0),t([i()],c.prototype,"headerRenderFunction",void 0),t([i()],c.prototype,"headerMenuRenderFunction",void 0),t([i()],c.prototype,"headerSorterRenderFunction",void 0),t([i()],c.prototype,"hidden",void 0),t([i()],c.prototype,"headerMenuEnabled",void 0),t([i({constructOnly:!0})],c.prototype,"initialSortPriority",void 0),t([i({readOnly:!0})],c.prototype,"label",null),t([i()],c.prototype,"menu",void 0),t([i()],c.prototype,"menuConfig",void 0),t([i()],c.prototype,"messages",void 0),t([i()],c.prototype,"messagesCommon",void 0),t([i()],c.prototype,"messagesURIUtils",void 0),t([i()],c.prototype,"path",void 0),t([i()],c.prototype,"renderFunction",void 0),t([i()],c.prototype,"resizable",void 0),t([i()],c.prototype,"sortable",void 0),t([i({readOnly:!0})],c.prototype,"sortElement",void 0),t([i()],c.prototype,"textAlign",void 0),t([i()],c.prototype,"timeZone",void 0),t([i()],c.prototype,"timeZoneName",void 0),t([i()],c.prototype,"width",void 0),c=t([n("esri.widgets.FeatureTable.Grid.Column")],c);const u=c;export{u as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"@vaadin/grid/vaadin-grid.js";import"@vaadin/grid/vaadin-grid-column-group.js";import"@vaadin/grid/vaadin-grid-selection-column.js";import"@vaadin/grid/vaadin-grid-sorter.js";import{isSome as t}from"../../../core/arrayUtils.js";import{on as r}from"../../../core/events.js";import{assertIsSome as i}from"../../../core/maybe.js";import{watch as o,on as s}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../../core/accessorSupport/decorators/cast.js";import"../../../core/has.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../Widget.js";import h from"./GridViewModel.js";import{globalCss as c}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{messageBundle as u}from"../../support/decorators/messageBundle.js";import{tsx as m}from"../../support/jsxFactory.js";const g={selectionColumn:!0,columnMenus:!0},p="esri-grid",_="compact column-borders",v={base:p,content:`${p}__content`,grid:`${p}__grid`,noColumnMenu:`${p}--no-column-menu`};let f=class extends a{constructor(e,t){super(e,t),this._grid=null,this._columnElements=[],this.itemIdPath=null,this.messages=null,this.viewModel=new h,this.visibleElements={...g}}initialize(){this.addHandles([this.columns.on("change",(()=>this.onColumnChange())),o((()=>this.viewModel?.size),(()=>this._updateGridSize())),o((()=>this.store?.state),((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshPageCache()})),s((()=>this._grid?.$?.table),"scroll",(()=>this.viewModel?.closeColumnMenus()))])}destroy(){this.resetColumns(),this.columns?.destroy()}resetColumns(){this.columns.items.forEach((e=>e.destroy())),this.columns.removeAll()}get cellClassNameGenerator(){return this.viewModel.cellClassNameGenerator}set cellClassNameGenerator(e){this.viewModel.cellClassNameGenerator=e}get columns(){return this.viewModel.columns}set columns(e){this.viewModel.columns=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get dataProvider(){return this.viewModel.dataProvider}set dataProvider(e){this.viewModel.dataProvider=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get rowDetailsRenderer(){return this.viewModel.rowDetailsRenderer}set rowDetailsRenderer(e){this.viewModel.rowDetailsRenderer=e}get size(){return this.viewModel.size}get sortOrders(){return this._grid?._sorters?this._grid._sorters.filter((e=>!!e&&e.path)).map((({direction:e,path:t})=>({direction:e,path:t}))):[]}get store(){return this.viewModel.store}set store(e){this.viewModel.store=e}castVisibleElements(e){return{...g,...e}}getColumnProps(e,t){const{id:r}=this,{autoWidth:i,direction:o,flexGrow:s,frozen:n,header:l,hidden:d,path:a,resizable:h,textAlign:c,width:u}=e,m=`${r}_${l}_${t??a}`,{renderFunction:g,footerRenderFunction:p,headerRenderFunction:_}=e,v=p?(e,t)=>p({root:e,column:t}):void 0,f=_?(e,t)=>_({root:e,column:t}):void 0,C=g?(e,t,r)=>g({root:e,column:t,rowData:r}):void 0;return{footerRenderer:v,headerRenderer:f,renderer:C,autoWidth:i,direction:o,flexGrow:s,frozen:n,header:l,hidden:d,key:m,path:a,resizable:h,bind:this,"text-align":c,width:"number"==typeof u?`${u}px`:u,afterCreate:this._afterColumnCreate,afterRemoved:this._afterColumnRemoved}}clearSelection(){this._clearSelection(),this.scheduleRender()}clearSort(){let e=!1;if(this._grid){if(this._grid._sorters?.length&&(this._grid._sorters.forEach((e=>{e._order=null,e.direction=null})),e=!0),this.columns?.length){this.columns.some((e=>!!e.direction))&&(this.columns.forEach((e=>e.direction=null)),e=!0)}e&&(this.notifyChange("sortOrders"),this.scheduleRender())}}findColumn(e){this.viewModel.findColumn(e)}generateCellClassNames(){this._grid?.generateCellClassNames()}getSlotElementByName(e){return this._grid?.shadowRoot?.querySelector(`slot[name='${e}']`)??null}hideColumn(e){this.viewModel?.hideColumn(e)}recalculateColumnWidths(){this._grid?.recalculateColumnWidths()}async reset(){this._clearSelection(),await(this.store?.reset()),this.scrollToTop()}refreshPageCache(){this._grid?.clearCache()}selectRows(e){const t=e?.filter((e=>!this.highlightIds.includes(e.objectId))),r=t.map((e=>e.objectId));r.length&&this.highlightIds.addMany(r)}deselectRows(e){const t=e?.map((e=>e.objectId))||[];t.length&&this.highlightIds.removeMany(t)}showColumn(e){this.viewModel?.showColumn(e)}sort({path:e,direction:t}){this.viewModel?.sortColumn(e,t),this.notifyChange("sortOrders")}scrollToIndex(e){this._grid?.scrollToIndex(e)}scrollToTop(){this._grid?.scrollToIndex(0)}isEditingActive(){return!!this._getActiveEditInfo().length}onColumnChange(){this._columnElements.forEach((e=>{this._applyRenderersToColumnElement(e)})),this._grid?.requestContentUpdate()}render(){const{columnMenus:e}=this.visibleElements;return m("div",{bind:this,class:this.classes(v.base,c.widget,{[v.noColumnMenu]:!e})},m("div",{bind:this,class:v.content},this._renderGrid()))}_renderGrid(){const e=this.highlightIds.map((e=>this.store?.getLocalItemByKey(e)||{objectId:e})).toArray();return m("vaadin-grid",{afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellClassNameGenerator:this.cellClassNameGenerator,class:v.grid,columnReorderingAllowed:this.columnReorderingEnabled,dataProvider:this.dataProvider,id:`${this.id}_grid`,itemIdPath:this.itemIdPath,multiSort:this.multiSortEnabled,pageSize:this.pageSize,ref:"grid",rowDetailsRenderer:this.rowDetailsRenderer,selectedItems:e,size:this.size},this._renderAllColumns())}_renderAllColumns(){return"disabled"!==this.viewModel.state&&this.columns?.length?[this._renderSelectionColumn(),this._renderColumns()]:null}_renderSelectionColumn(){return m("vaadin-grid-selection-column",{_selectAllHidden:!0,bind:this,dragSelect:!0,frozen:!0,hidden:!this.visibleElements.selectionColumn,selectAll:!1,sortable:!1,textAlign:"center"})}_renderColumns(){return this.columns.items.map(((e,t)=>"columns"in e?this._renderGroupColumn(e,t):m("vaadin-grid-column",{...this.getColumnProps(e,t)}))).filter(t)}_renderGroupColumn(e,t){const r=this.getColumnProps(e,t);if(r.hidden||!e.columns)return null;const i=e.columns.filter((({hidden:e})=>!e));return i.length?m("vaadin-grid-column-group",{...r},i.map((e=>m("vaadin-grid-column",{...this.getColumnProps(e,t)})))):null}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",_),customElements.whenDefined("vaadin-grid").then((()=>this._addGridEventListeners())),t.__updateSorter=e=>{const r=t._sorters,i=!r.includes(e);if(e.direction||!i)if(e._order=null,t.multiSort)t._removeArrayItem(r,e),e.direction&&(null!=e._initialOrder?(i?r[e._initialOrder]=e:r.splice(e._initialOrder,0,e),e._initialOrder=null):r.unshift(e)),t.__updateSortOrders();else if(e.direction){const i=r.filter((t=>t!==e));t._sorters=[e],i.forEach((e=>{e._order=null,e.direction=null}))}}}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_updateGridSize(){this._grid&&(this._grid.size=this.size||0,this.scheduleRender())}_getActiveEditInfo(){if(!this.columns||this.columns.length)return[];return this.columns.filter((e=>"activeEditInfo"in e)).map((e=>e.activeEditInfo)).items}_addGridEventListeners(){const e=this._grid;i(e),this.addHandles([r(e,"click",(e=>this._onRowClick(e))),r(e,"selected-items-changed",(e=>this._onSelectedItemsChange(e))),r(e,"sorter-changed",(()=>this.notifyChange("sortOrders")))])}_onRowClick(e){const t=this._grid;i(t);const r=t.getEventContext(e),{item:o,section:s}=r;o&&s&&"details"!==s&&"header"!==s&&this.emit("row-click",{context:r,native:e})}_clearSelection(){this.highlightIds.removeAll()}_onSelectedItemsChange(e){const{highlightIds:t}=this,r=e.detail.value.map((e=>e.objectId)),i=r.filter((e=>!t.includes(e))),o=t.filter((e=>!r.includes(e)));t.removeMany(o),t.addMany(i)}_applyRenderersToColumnElement(e){const t=e?.path,r=null!=t?this.viewModel.findColumn(t):void 0;if(r)try{const{renderFunction:t,footerRenderFunction:i,headerRenderFunction:o}=r;t&&"renderer"in e&&(e.renderer=(e,r,i)=>t({root:e,column:r,rowData:i})),i&&(e.footerRenderer=(e,t)=>i({root:e,column:t})),o&&(e.headerRenderer=(e,t)=>o({root:e,column:t}))}catch(i){}}};e([n()],f.prototype,"_grid",void 0),e([n()],f.prototype,"cellClassNameGenerator",null),e([n()],f.prototype,"columns",null),e([n()],f.prototype,"columnReorderingEnabled",null),e([n()],f.prototype,"dataProvider",null),e([n()],f.prototype,"highlightIds",null),e([n()],f.prototype,"itemIdPath",void 0),e([n()],f.prototype,"label",null),e([n(),u("esri/widgets/FeatureTable/t9n/FeatureTable")],f.prototype,"messages",void 0),e([n()],f.prototype,"multiSortEnabled",null),e([n()],f.prototype,"pageSize",null),e([n()],f.prototype,"rowDetailsRenderer",null),e([n()],f.prototype,"size",null),e([n({readOnly:!0})],f.prototype,"sortOrders",null),e([n()],f.prototype,"store",null),e([n()],f.prototype,"viewModel",void 0),e([n()],f.prototype,"visibleElements",void 0),e([l("visibleElements")],f.prototype,"castVisibleElements",null),f=e([d("esri.widgets.FeatureTable.Grid.Grid")],f);const C=f;export{C as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"@vaadin/grid/vaadin-grid.js";import"@vaadin/grid/vaadin-grid-column-group.js";import"@vaadin/grid/vaadin-grid-selection-column.js";import"@vaadin/grid/vaadin-grid-sorter.js";import{isSome as t}from"../../../core/arrayUtils.js";import{on as r}from"../../../core/events.js";import{assertIsSome as i}from"../../../core/maybe.js";import{watch as o,on as s}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../../core/accessorSupport/decorators/cast.js";import"../../../core/has.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../Widget.js";import h from"./GridViewModel.js";import{globalCss as c}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{messageBundle as u}from"../../support/decorators/messageBundle.js";import{tsx as m}from"../../support/jsxFactory.js";const g={selectionColumn:!0,columnMenus:!0},p="esri-grid",_="compact column-borders",v={base:p,content:`${p}__content`,grid:`${p}__grid`,noColumnMenu:`${p}--no-column-menu`};let f=class extends a{constructor(e,t){super(e,t),this._grid=null,this._columnElements=[],this.itemIdPath=null,this.messages=null,this.viewModel=new h,this.visibleElements={...g}}initialize(){this.addHandles([this.columns.on("change",(()=>this.onColumnChange())),o((()=>this.viewModel?.size),(()=>this._updateGridSize())),o((()=>this.store?.state),((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshPageCache()})),s((()=>this._grid?.$?.table),"scroll",(()=>this.viewModel?.closeColumnMenus()))])}destroy(){this.resetColumns(),this.columns?.destroy()}resetColumns(){this.columns.items.forEach((e=>e.destroy())),this.columns.removeAll()}get cellClassNameGenerator(){return this.viewModel.cellClassNameGenerator}set cellClassNameGenerator(e){this.viewModel.cellClassNameGenerator=e}get columns(){return this.viewModel.columns}set columns(e){this.viewModel.columns=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get dataProvider(){return this.viewModel.dataProvider}set dataProvider(e){this.viewModel.dataProvider=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get rowDetailsRenderer(){return this.viewModel.rowDetailsRenderer}set rowDetailsRenderer(e){this.viewModel.rowDetailsRenderer=e}get size(){return this.viewModel.size}get sortOrders(){return this._grid?._sorters?this._grid._sorters.filter((e=>!!e&&e.path)).map((({direction:e,path:t})=>({direction:e,path:t}))):[]}get store(){return this.viewModel.store}set store(e){this.viewModel.store=e}castVisibleElements(e){return{...g,...e}}getColumnProps(e,t){const{id:r}=this,{autoWidth:i,direction:o,flexGrow:s,frozen:n,frozenToEnd:l,header:d,hidden:a,path:h,resizable:c,textAlign:u,width:m}=e,g=`${r}_${d}_${t??h}`,{renderFunction:p,footerRenderFunction:_,headerRenderFunction:v}=e,f=_?(e,t)=>_({root:e,column:t}):void 0,C=v?(e,t)=>v({root:e,column:t}):void 0,w=p?(e,t,r)=>p({root:e,column:t,rowData:r}):void 0;return{footerRenderer:f,headerRenderer:C,renderer:w,autoWidth:i,direction:o,flexGrow:s,frozen:n,frozenToEnd:l,header:d,hidden:a,key:g,path:h,resizable:c,bind:this,"text-align":u,width:"number"==typeof m?`${m}px`:m,afterCreate:this._afterColumnCreate,afterRemoved:this._afterColumnRemoved}}clearSelection(){this._clearSelection(),this.scheduleRender()}clearSort(){let e=!1;if(this._grid){if(this._grid._sorters?.length&&(this._grid._sorters.forEach((e=>{e._order=null,e.direction=null})),e=!0),this.columns?.length){this.columns.some((e=>!!e.direction))&&(this.columns.forEach((e=>e.direction=null)),e=!0)}e&&(this.notifyChange("sortOrders"),this.scheduleRender())}}findColumn(e){this.viewModel.findColumn(e)}generateCellClassNames(){this._grid?.generateCellClassNames()}getSlotElementByName(e){return this._grid?.shadowRoot?.querySelector(`slot[name='${e}']`)??null}hideColumn(e){this.viewModel?.hideColumn(e)}recalculateColumnWidths(){this._grid?.recalculateColumnWidths()}async reset(){this._clearSelection(),await(this.store?.reset()),this.scrollToTop()}refreshPageCache(){this._grid?.clearCache()}selectRows(e){const t=e?.filter((e=>!this.highlightIds.includes(e.objectId))),r=t.map((e=>e.objectId));r.length&&this.highlightIds.addMany(r)}deselectRows(e){const t=e?.map((e=>e.objectId))||[];t.length&&this.highlightIds.removeMany(t)}showColumn(e){this.viewModel?.showColumn(e)}sort({path:e,direction:t}){this.viewModel?.sortColumn(e,t),this.notifyChange("sortOrders")}scrollToIndex(e){this._grid?.scrollToIndex(e)}scrollToTop(){this._grid?.scrollToIndex(0)}isEditingActive(){return!!this._getActiveEditInfo().length}onColumnChange(){this._columnElements.forEach((e=>{this._applyRenderersToColumnElement(e)})),this._grid?.requestContentUpdate()}render(){const{columnMenus:e}=this.visibleElements;return m("div",{bind:this,class:this.classes(v.base,c.widget,{[v.noColumnMenu]:!e})},m("div",{bind:this,class:v.content},this._renderGrid()))}_renderGrid(){const e=this.highlightIds.map((e=>this.store?.getLocalItemByKey(e)||{objectId:e})).toArray();return m("vaadin-grid",{afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellClassNameGenerator:this.cellClassNameGenerator,class:v.grid,columnReorderingAllowed:this.columnReorderingEnabled,dataProvider:this.dataProvider,id:`${this.id}_grid`,itemIdPath:this.itemIdPath,multiSort:this.multiSortEnabled,pageSize:this.pageSize,ref:"grid",rowDetailsRenderer:this.rowDetailsRenderer,selectedItems:e,size:this.size},this._renderAllColumns())}_renderAllColumns(){return"disabled"!==this.viewModel.state&&this.columns?.length?[this._renderSelectionColumn(),this._renderColumns()]:null}_renderSelectionColumn(){return m("vaadin-grid-selection-column",{_selectAllHidden:!0,bind:this,dragSelect:!0,frozen:!0,hidden:!this.visibleElements.selectionColumn,selectAll:!1,sortable:!1,textAlign:"center"})}_renderColumns(){return this.columns.items.map(((e,t)=>"columns"in e?this._renderGroupColumn(e,t):m("vaadin-grid-column",{...this.getColumnProps(e,t)}))).filter(t)}_renderGroupColumn(e,t){const r=this.getColumnProps(e,t);if(r.hidden||!e.columns)return null;const i=e.columns.filter((({hidden:e})=>!e));return i.length?m("vaadin-grid-column-group",{...r},i.map((e=>m("vaadin-grid-column",{...this.getColumnProps(e,t)})))):null}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",_),customElements.whenDefined("vaadin-grid").then((()=>this._addGridEventListeners())),t.__updateSorter=e=>{const r=t._sorters,i=!r.includes(e);if(e.direction||!i)if(e._order=null,t.multiSort)t._removeArrayItem(r,e),e.direction&&(null!=e._initialOrder?(i?r[e._initialOrder]=e:r.splice(e._initialOrder,0,e),e._initialOrder=null):r.unshift(e)),t.__updateSortOrders();else if(e.direction){const i=r.filter((t=>t!==e));t._sorters=[e],i.forEach((e=>{e._order=null,e.direction=null}))}}}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_updateGridSize(){this._grid&&(this._grid.size=this.size||0,this.scheduleRender())}_getActiveEditInfo(){if(!this.columns||this.columns.length)return[];return this.columns.filter((e=>"activeEditInfo"in e)).map((e=>e.activeEditInfo)).items}_addGridEventListeners(){const e=this._grid;i(e),this.addHandles([r(e,"click",(e=>this._onRowClick(e))),r(e,"selected-items-changed",(e=>this._onSelectedItemsChange(e))),r(e,"sorter-changed",(()=>this.notifyChange("sortOrders")))])}_onRowClick(e){const t=this._grid;i(t);const r=t.getEventContext(e),{item:o,section:s}=r;o&&s&&"details"!==s&&"header"!==s&&this.emit("row-click",{context:r,native:e})}_clearSelection(){this.highlightIds.removeAll()}_onSelectedItemsChange(e){const{highlightIds:t}=this,r=e.detail.value.map((e=>e.objectId)),i=r.filter((e=>!t.includes(e))),o=t.filter((e=>!r.includes(e)));t.removeMany(o),t.addMany(i)}_applyRenderersToColumnElement(e){const t=e?.path,r=null!=t?this.viewModel.findColumn(t):void 0;if(r)try{const{renderFunction:t,footerRenderFunction:i,headerRenderFunction:o}=r;t&&"renderer"in e&&(e.renderer=(e,r,i)=>t({root:e,column:r,rowData:i})),i&&(e.footerRenderer=(e,t)=>i({root:e,column:t})),o&&(e.headerRenderer=(e,t)=>o({root:e,column:t}))}catch(i){}}};e([n()],f.prototype,"_grid",void 0),e([n()],f.prototype,"cellClassNameGenerator",null),e([n()],f.prototype,"columns",null),e([n()],f.prototype,"columnReorderingEnabled",null),e([n()],f.prototype,"dataProvider",null),e([n()],f.prototype,"highlightIds",null),e([n()],f.prototype,"itemIdPath",void 0),e([n()],f.prototype,"label",null),e([n(),u("esri/widgets/FeatureTable/t9n/FeatureTable")],f.prototype,"messages",void 0),e([n()],f.prototype,"multiSortEnabled",null),e([n()],f.prototype,"pageSize",null),e([n()],f.prototype,"rowDetailsRenderer",null),e([n()],f.prototype,"size",null),e([n({readOnly:!0})],f.prototype,"sortOrders",null),e([n()],f.prototype,"store",null),e([n()],f.prototype,"viewModel",void 0),e([n()],f.prototype,"visibleElements",void 0),e([l("visibleElements")],f.prototype,"castVisibleElements",null),f=e([d("esri.widgets.FeatureTable.Grid.Grid")],f);const C=f;export{C as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import r from"../../core/Logger.js";import o from"../../core/ReactiveSet.js";import{watch as a,when as n,sync as l}from"../../core/reactiveUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{getPointFromGeometry as c}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as d}from"../../geometry/support/webMercatorUtils.js";import p from"../../layers/Layer.js";import{fallbackObjectIDAttribute as g}from"../../layers/LayerConstants.js";import{getDisplayedSymbol as f}from"../../symbols/support/symbolUtils.js";import{highlightsSupported as m}from"../../views/support/layerViewUtils.js";import y from"../Feature/FeatureViewModel.js";import{ActionsCollection as w,zoomToFeature as F,zoomToClusteredFeatures as v,browseClusteredFeatures as _}from"../Popup/actions.js";import{triggerAction as b,isClusterFeature as C,removeClusteredFeaturesForBrowsing as P,displayClusterExtent as E,browseAggregateFeatures as M,getSelectedTarget as V}from"../Popup/actionUtils.js";import A from"../support/AnchorElementViewModel.js";import{GoToMixin as L}from"../support/GoTo.js";import j from"../../symbols/SimpleFillSymbol.js";import O from"../../geometry/Point.js";const I=()=>[F.clone()],T=()=>[v.clone(),_.clone()];let x=class extends(L(A)){constructor(e){super(e),this._pendingPromises=new o,this._fetchFeaturesController=null,this._highlightSelectedFeaturePromise=null,this._highlightActiveFeaturePromise=null,this._selectedClusterFeature=null,this.actions=new w,this.activeFeature=null,this.autoCloseEnabled=!1,this.autoOpenEnabled=!0,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.selectedClusterBoundaryFeature=new t({symbol:new j({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null}initialize(){this.addHandles([this.on("view-change",(()=>this._autoClose())),a((()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view]),(()=>this._highlightSelectedFeature())),a((()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view]),(()=>this._highlightActiveFeature())),a((()=>this.view?.animation?.state),(e=>this._animationStateChange(e))),a((()=>this.location),(e=>this._locationChange(e))),a((()=>this.selectedFeature),(e=>this._selectedFeatureChange(e))),a((()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage]),(()=>this._selectedFeatureIndexChange())),a((()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels]),(()=>this._setGraphicOnFeatureViewModels())),a((()=>this.featureViewModels),(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>b({event:e,viewModel:this,view:this.view}))),n((()=>!this.waitingForResult),(()=>this._waitingForResultChange()),l),a((()=>[this.features,this.view?.map,this.view?.spatialReference,this.view?.timeZone]),(()=>this._updateFeatureVMs())),a((()=>this.view?.scale),(()=>this._viewScaleChange())),n((()=>!this.visible),(()=>this.browseClusterEnabled=!1)),a((()=>this.browseClusterEnabled),(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new w;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(a)??a;return u?.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){const e=this._get("defaultActions")||new w;return e.removeAll(),e.addMany(C(this.selectedFeature)?T():I()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1)}set location(e){let t=e;const i=this.view?.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=d(e)),this._set("location",t)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice(0)).forEach((e=>this._pendingPromises.add(e))),e.reduce(((e,t)=>e.finally((()=>t.then((e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)})).finally((()=>this._pendingPromises.delete(t))).catch((()=>{}))))),Promise.resolve())):this._set("promises",[])}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;e=isNaN(e)||e<-1||!t?-1:(e+t)%t,this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get state(){return this.view?.ready?"ready":"disabled"}get waitingForContents(){return this.featureViewModels.some((e=>e.waitingForContent))}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=V(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex++,this}previous(){return this.selectedFeatureIndex--,this}disableClusterBrowsing(){P(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?C(t)?(await E(this),await M(this)):r.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):r.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}handleViewClick(e){this.autoOpenEnabled&&this._fetchFeaturesAndOpen(e)}_animationStateChange(e){this.zoomToLocation||(F.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(C(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i}=this;i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>1?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>1?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null===i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach(((t,i)=>{t&&(t.graphic??=e[o+i])}))}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(e&&s){if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),C(e))return;return e.symbol=await f(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}if(!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=c(e.geometry)}}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController(this._getScreenPoint(e??this.location));this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s}=this;if(C(e)||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const r=i.slice(0),o=[];t.forEach(((t,i)=>{if(!t)return;let a=null;if(r.some(((e,i)=>(e&&e.graphic===t&&(a=e,r.splice(i,1)),!!a))),a)o[i]=a;else{const r=new y({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:s?.spatialReference,graphic:t===e?t:null,map:s?.map,view:s});o[i]=r}})),r.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",o)}_getScreenPoint(e){const{view:t}=this;return t&&e&&"function"==typeof t.toScreen?t.toScreen(e):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}_fetchFeaturesWithController(e,t){this._cancelFetchingFeatures();const i=new AbortController,{signal:s}=i;this._fetchFeaturesController=i;const r=this.fetchFeatures(e,{signal:s,event:t});return r.catch((()=>{})).then((()=>{this._fetchFeaturesController=null})),r}async _fetchFeaturesAndOpen(e){const{screenPoint:t,mapPoint:i}=e,{view:s}=this,{pendingFeatures:r}=await this._fetchFeaturesWithController(t,e);s?.popup&&"open"in s.popup&&s.popup.open({location:i??void 0,promises:r})}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t}_getHighlightTarget(e,t){const i="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||g:null,s=e.attributes;return s&&i&&s[i]||e}_mapIncludesLayer(e){return!!this.view?.map?.allLayers?.includes(e)}async _highlightActiveFeature(){const e="highlight-active-feature";this.removeHandles(e);const{highlightEnabled:t,view:i,activeFeature:s,visible:r}=this;if(!(s&&i&&t&&r))return;const o=this._getHighlightLayer(s);if(!(o&&o instanceof p&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(i,o);this._highlightActiveFeaturePromise=a;const n=await a;if(!(n&&m(n)&&this._highlightActiveFeaturePromise===a&&this.activeFeature&&this.highlightEnabled))return;const l=n.highlight(this._getHighlightTarget(s,o));this.addHandles(l,e)}async _highlightSelectedFeature(){const e="highlight-selected-feature";this.removeHandles(e);const{selectedFeature:t,highlightEnabled:i,view:s,visible:r}=this;if(!(t&&s&&i&&r))return;const o=this._getHighlightLayer(t);if(!(o&&o instanceof p&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(s,o);this._highlightSelectedFeaturePromise=a;const n=await a;if(!(n&&m(n)&&this._highlightSelectedFeaturePromise===a&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const l=n.highlight(this._getHighlightTarget(t,o));this.addHandles(l,e)}_updateFeatures(e){const{features:t}=this,i=e.filter((e=>!t.includes(e)));i?.length&&(this.features=t.concat(i))}};e([u()],x.prototype,"_fetchFeaturesController",void 0),e([u({type:w})],x.prototype,"actions",void 0),e([u({readOnly:!0})],x.prototype,"active",null),e([u()],x.prototype,"activeFeature",void 0),e([u({readOnly:!0})],x.prototype,"allActions",null),e([u()],x.prototype,"autoCloseEnabled",void 0),e([u()],x.prototype,"autoOpenEnabled",void 0),e([u()],x.prototype,"browseClusterEnabled",void 0),e([u()],x.prototype,"content",void 0),e([u({type:w,readOnly:!0})],x.prototype,"defaultActions",null),e([u({type:Boolean})],x.prototype,"defaultPopupTemplateEnabled",void 0),e([u({readOnly:!0})],x.prototype,"featureCount",null),e([u()],x.prototype,"featurePage",void 0),e([u({value:[]})],x.prototype,"features",null),e([u()],x.prototype,"featuresPerPage",void 0),e([u()],x.prototype,"featureMenuOpen",void 0),e([u()],x.prototype,"featureViewModelAbilities",void 0),e([u({readOnly:!0})],x.prototype,"featureViewModels",void 0),e([u()],x.prototype,"highlightEnabled",void 0),e([u()],x.prototype,"includeDefaultActions",void 0),e([u({type:O})],x.prototype,"location",null),e([u({readOnly:!0})],x.prototype,"pendingPromisesCount",null),e([u({readOnly:!0})],x.prototype,"promiseCount",null),e([u()],x.prototype,"promises",null),e([u({readOnly:!0})],x.prototype,"selectedClusterBoundaryFeature",void 0),e([u({value:null,readOnly:!0})],x.prototype,"selectedFeature",null),e([u({value:-1})],x.prototype,"selectedFeatureIndex",null),e([u({readOnly:!0})],x.prototype,"selectedFeatureViewModel",null),e([u({readOnly:!0})],x.prototype,"state",null),e([u()],x.prototype,"title",void 0),e([u()],x.prototype,"updateLocationEnabled",void 0),e([u()],x.prototype,"view",void 0),e([u()],x.prototype,"visible",void 0),e([u({readOnly:!0})],x.prototype,"waitingForContents",null),e([u({readOnly:!0})],x.prototype,"waitingForResult",null),e([u()],x.prototype,"zoomFactor",void 0),e([u()],x.prototype,"zoomToLocation",void 0),e([u()],x.prototype,"centerAtLocation",null),x=e([h("esri.widgets.Features.FeaturesViewModel")],x);const S=x;export{S as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import r from"../../core/Logger.js";import o from"../../core/ReactiveSet.js";import{watch as a,when as n,sync as l}from"../../core/reactiveUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{initializeProjection as c}from"../../geometry/projection.js";import{getPointFromGeometry as d}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as p}from"../../geometry/support/webMercatorUtils.js";import g from"../../layers/Layer.js";import{fallbackObjectIDAttribute as f}from"../../layers/LayerConstants.js";import{getDisplayedSymbol as m}from"../../symbols/support/symbolUtils.js";import{highlightsSupported as y}from"../../views/support/layerViewUtils.js";import w from"../Feature/FeatureViewModel.js";import{ActionsCollection as F,zoomToFeature as v,zoomToClusteredFeatures as _,browseClusteredFeatures as b}from"../Popup/actions.js";import{triggerAction as C,isClusterFeature as P,removeClusteredFeaturesForBrowsing as E,displayClusterExtent as M,browseAggregateFeatures as A,getSelectedTarget as V}from"../Popup/actionUtils.js";import j from"../support/AnchorElementViewModel.js";import{GoToMixin as L}from"../support/GoTo.js";import O from"../../symbols/SimpleFillSymbol.js";import I from"../../geometry/Point.js";const T=()=>[v.clone()],S=()=>[_.clone(),b.clone()];let x=class extends(L(j)){constructor(e){super(e),this._pendingPromises=new o,this._fetchFeaturesController=null,this._highlightSelectedFeaturePromise=null,this._highlightActiveFeaturePromise=null,this._selectedClusterFeature=null,this.actions=new F,this.activeFeature=null,this.autoCloseEnabled=!1,this.autoOpenEnabled=!0,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.selectedClusterBoundaryFeature=new t({symbol:new O({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null}initialize(){this.addHandles([this.on("view-change",(()=>this._autoClose())),a((()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view]),(()=>this._highlightSelectedFeature())),a((()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view]),(()=>this._highlightActiveFeature())),a((()=>this.view?.animation?.state),(e=>this._animationStateChange(e))),a((()=>this.location),(e=>this._locationChange(e))),a((()=>this.selectedFeature),(e=>this._selectedFeatureChange(e))),a((()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage]),(()=>this._selectedFeatureIndexChange())),a((()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels]),(()=>this._setGraphicOnFeatureViewModels())),a((()=>this.featureViewModels),(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>C({event:e,viewModel:this,view:this.view}))),n((()=>!this.waitingForResult),(()=>this._waitingForResultChange()),l),a((()=>[this.features,this.view?.map,this.view?.spatialReference,this.view?.timeZone]),(()=>this._updateFeatureVMs())),a((()=>this.view?.scale),(()=>this._viewScaleChange())),n((()=>!this.visible),(()=>this.browseClusterEnabled=!1)),a((()=>this.browseClusterEnabled),(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new F;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(a)??a;return u?.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){const e=this._get("defaultActions")||new F;return e.removeAll(),e.addMany(P(this.selectedFeature)?S():T()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1)}set location(e){let t=e;const i=this.view?.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=p(e)),this._set("location",t)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice(0)).forEach((e=>this._pendingPromises.add(e))),e.reduce(((e,t)=>e.finally((()=>t.then((e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)})).finally((()=>this._pendingPromises.delete(t))).catch((()=>{}))))),Promise.resolve())):this._set("promises",[])}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;e=isNaN(e)||e<-1||!t?-1:(e+t)%t,this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get state(){return this.view?.ready?"ready":"disabled"}get waitingForContents(){return this.featureViewModels.some((e=>e.waitingForContent))}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=V(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex++,this}previous(){return this.selectedFeatureIndex--,this}disableClusterBrowsing(){E(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?P(t)?(await M(this),await A(this)):r.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):r.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}handleViewClick(e){this.autoOpenEnabled&&this._fetchFeaturesAndOpen(e)}_animationStateChange(e){this.zoomToLocation||(v.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(P(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i}=this;i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>1?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>1?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null===i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach(((t,i)=>{t&&(t.graphic??=e[o+i])}))}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(e&&s){if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),P(e))return;return e.symbol=await m(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}if(!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=d(e.geometry)}}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s}=this;if(P(e)||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const r=i.slice(0),o=[];t.forEach(((t,i)=>{if(!t)return;let a=null;if(r.some(((e,i)=>(e&&e.graphic===t&&(a=e,r.splice(i,1)),!!a))),a)o[i]=a;else{const r=new w({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:s?.spatialReference,graphic:t===e?t:null,map:s?.map,view:s});o[i]=r}})),r.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("featureViewModels",o)}async _getScreenPoint(e,t){const{view:i}=this;await(i?.when());const s=e?.spatialReference,r=i?.spatialReference;return s&&r?(await c(s,r,null,t),i.toScreen(e)):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch((()=>{})).then((()=>{this._fetchFeaturesController=null})),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e,{view:s}=this,{pendingFeatures:r}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});s?.popup&&"open"in s.popup&&s.popup.open({location:t??void 0,promises:r})}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t}_getHighlightTarget(e,t){const i="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||f:null,s=e.attributes;return s&&i&&s[i]||e}_mapIncludesLayer(e){return!!this.view?.map?.allLayers?.includes(e)}async _highlightActiveFeature(){const e="highlight-active-feature";this.removeHandles(e);const{highlightEnabled:t,view:i,activeFeature:s,visible:r}=this;if(!(s&&i&&t&&r))return;const o=this._getHighlightLayer(s);if(!(o&&o instanceof g&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(i,o);this._highlightActiveFeaturePromise=a;const n=await a;if(!(n&&y(n)&&this._highlightActiveFeaturePromise===a&&this.activeFeature&&this.highlightEnabled))return;const l=n.highlight(this._getHighlightTarget(s,o));this.addHandles(l,e)}async _highlightSelectedFeature(){const e="highlight-selected-feature";this.removeHandles(e);const{selectedFeature:t,highlightEnabled:i,view:s,visible:r}=this;if(!(t&&s&&i&&r))return;const o=this._getHighlightLayer(t);if(!(o&&o instanceof g&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(s,o);this._highlightSelectedFeaturePromise=a;const n=await a;if(!(n&&y(n)&&this._highlightSelectedFeaturePromise===a&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const l=n.highlight(this._getHighlightTarget(t,o));this.addHandles(l,e)}_updateFeatures(e){const{features:t}=this,i=e.filter((e=>!t.includes(e)));i?.length&&(this.features=t.concat(i))}};e([u()],x.prototype,"_fetchFeaturesController",void 0),e([u({type:F})],x.prototype,"actions",void 0),e([u({readOnly:!0})],x.prototype,"active",null),e([u()],x.prototype,"activeFeature",void 0),e([u({readOnly:!0})],x.prototype,"allActions",null),e([u()],x.prototype,"autoCloseEnabled",void 0),e([u()],x.prototype,"autoOpenEnabled",void 0),e([u()],x.prototype,"browseClusterEnabled",void 0),e([u()],x.prototype,"content",void 0),e([u({type:F,readOnly:!0})],x.prototype,"defaultActions",null),e([u({type:Boolean})],x.prototype,"defaultPopupTemplateEnabled",void 0),e([u({readOnly:!0})],x.prototype,"featureCount",null),e([u()],x.prototype,"featurePage",void 0),e([u({value:[]})],x.prototype,"features",null),e([u()],x.prototype,"featuresPerPage",void 0),e([u()],x.prototype,"featureMenuOpen",void 0),e([u()],x.prototype,"featureViewModelAbilities",void 0),e([u({readOnly:!0})],x.prototype,"featureViewModels",void 0),e([u()],x.prototype,"highlightEnabled",void 0),e([u()],x.prototype,"includeDefaultActions",void 0),e([u({type:I})],x.prototype,"location",null),e([u({readOnly:!0})],x.prototype,"pendingPromisesCount",null),e([u({readOnly:!0})],x.prototype,"promiseCount",null),e([u()],x.prototype,"promises",null),e([u({readOnly:!0})],x.prototype,"selectedClusterBoundaryFeature",void 0),e([u({value:null,readOnly:!0})],x.prototype,"selectedFeature",null),e([u({value:-1})],x.prototype,"selectedFeatureIndex",null),e([u({readOnly:!0})],x.prototype,"selectedFeatureViewModel",null),e([u({readOnly:!0})],x.prototype,"state",null),e([u()],x.prototype,"title",void 0),e([u()],x.prototype,"updateLocationEnabled",void 0),e([u()],x.prototype,"view",void 0),e([u()],x.prototype,"visible",void 0),e([u({readOnly:!0})],x.prototype,"waitingForContents",null),e([u({readOnly:!0})],x.prototype,"waitingForResult",null),e([u()],x.prototype,"zoomFactor",void 0),e([u()],x.prototype,"zoomToLocation",void 0),e([u()],x.prototype,"centerAtLocation",null),x=e([h("esri.widgets.Features.FeaturesViewModel")],x);const B=x;export{B as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- const n={hide:"hide",hideChildren:"hide-children"},i="root";function e({exclusive:n,visible:i,visibilityAppearance:e}){const t="checkbox"===e;return i?n?"circle-f":t?"check-square-f":"view-visible":n?"circle":t?"square":"view-hide"}function t({connectionStatus:n,isUpdating:i,publishing:e}){const t=!!n;return t||e||i?t?"connected"===n?"beacon":"offline":e?"stop-square":"bullet-point":"blank"}function l(n){if(n)return null!=n.listMode?n.listMode:void 0}function r(n){return null!=n&&"minScale"in n&&null!=n.minScale?n.minScale:void 0}function u(n){return null!=n&&"maxScale"in n&&null!=n.maxScale?n.maxScale:void 0}function s(n){if(!n)return"inherited";const i=v(h(n)?n.layer:n);return null!=i?i?"independent":"inherited":"visibilityMode"in n&&null!=n.visibilityMode?n.visibilityMode:"independent"}function a(i){if(i&&(!("type"in i)||"wmts"!==i.type)&&i.listMode!==n.hideChildren)return"sublayers"in i?"sublayers":"layers"in i?"layers":void 0}function o(n){const i=(n?.layer&&h(n.layer)?n.layer.layer:void 0)??n?.layer;return!!i&&(m(i)??!0)}function c(i){return l(i)!==n.hide}function d(n,i){if(!n||null==i||isNaN(i))return!1;const e=r(n),t=u(n),l=null!=e&&!isNaN(e)&&e>0&&i>e,s=null!=t&&!isNaN(t)&&t>0&&i<t;return l||s}function y(n,i){n?.sort(((n,e)=>{const t="uid"in n?i.indexOf(n.uid):-1,l="uid"in e?i.indexOf(e.uid):-1;return t>l?-1:t<l?1:0}))}function f(n,i){const e=n?.layer;if(!e)return;const t=a(e);if(!t)return;let l;"layers"===t&&"layers"in e?l=e.layers:"sublayers"===t&&"sublayers"in e&&(l=e.sublayers),y(l,i)}function p(n){const i=n?.layer;return i&&"layers"in i?i.layers:null}function b(n){const i=h(n)?n:null,e=n?.parent,t=null!=e&&"type"in e&&"map-image"===e.type?i?.source:null,l="";return t&&e?{layer:e,title:l,sublayerIds:[t.mapLayerId]}:{layer:n,title:l}}function h(n){return null!=n&&"layer"in n&&null!=n.layer}function v(n){const i=x(n);return null!=i&&"supportsSublayerVisibility"in i?i.supportsSublayerVisibility:void 0}function m(n){const i=x(n);return null!=i&&"supportsDynamicLayers"in i?i.supportsDynamicLayers:void 0}function x(n){return n&&"capabilities"in n&&null!=n.capabilities&&"exportMap"in n.capabilities?n.capabilities.exportMap:void 0}function S(n){return n?.["data-item"]}function M({children:n,error:i,incompatible:e}){return!!n?.filter((n=>!n.hidden)).length&&!i&&!e}export{c as canDisplayLayer,o as canSortSublayers,l as findLayerListMode,u as findLayerMaxScale,r as findLayerMinScale,s as findLayerVisibilityMode,S as getItem,p as getItemLayers,b as getLegendLayerInfo,a as getNormalizedChildLayerProperty,t as getStatusIcon,e as getVisibilityIcon,d as isLayerOutsideScaleRange,h as isSublayer,M as listItemHasChildren,f as sortChildLayersToIds,y as sortLayersToIds,i as sortableRoot};
5
+ const n={hide:"hide",hideChildren:"hide-children"},i="root";function e({exclusive:n,visible:i,visibilityAppearance:e}){const t="checkbox"===e;return i?n?"circle-f":t?"check-square-f":"view-visible":n?"circle":t?"square":"view-hide"}function t({connectionStatus:n,isUpdating:i,publishing:e}){const t=!!n;return t||e||i?t?"connected"===n?"beacon":"offline":e?"stop-square":"bullet-point":"blank"}function r(n){if(n)return null!=n.listMode?n.listMode:void 0}function l(n){return null!=n&&"minScale"in n&&null!=n.minScale?n.minScale:void 0}function u(n){return null!=n&&"maxScale"in n&&null!=n.maxScale?n.maxScale:void 0}function a(n){if(!n)return"inherited";const i=v(h(n)?n.layer:n);return null!=i?i?"independent":"inherited":"visibilityMode"in n&&null!=n.visibilityMode?n.visibilityMode:"independent"}function s(i){if(i&&(!("type"in i)||"wmts"!==i.type)&&i.listMode!==n.hideChildren)return"sublayers"in i?"sublayers":"layers"in i?"layers":void 0}function o(n){const i=(n?.layer&&h(n.layer)?n.layer.layer:void 0)??n?.layer;return!!i&&(m(i)??!0)}function c(i){return r(i)!==n.hide}function d(n,i){if(!n||null==i||isNaN(i))return!1;const e=l(n),t=u(n),r=null!=e&&!isNaN(e)&&e>0&&i>e,a=null!=t&&!isNaN(t)&&t>0&&i<t;return r||a}function y(n,i){n?.sort(((n,e)=>{const t="uid"in n?i.indexOf(n.uid):-1,r="uid"in e?i.indexOf(e.uid):-1;return t>r?-1:t<r?1:0}))}function f(n,i){const e=n?.layer;if(!e)return;const t=s(e);if(!t)return;let r;"layers"===t&&"layers"in e?r=e.layers:"sublayers"===t&&"sublayers"in e&&(r=e.sublayers),y(r,i)}function p(n){const i=n?.layer;return i&&"layers"in i?i.layers:null}function b(n){const i=h(n)?n:null,e=n?.parent,t=null!=e&&"type"in e&&"map-image"===e.type?i?.source:null,r="";return t&&e?{layer:e,title:r,sublayerIds:[t.mapLayerId]}:{layer:n,title:r}}function h(n){return null!=n&&"layer"in n&&null!=n.layer}function v(n){const i=x(n);return null!=i&&"supportsSublayerVisibility"in i?i.supportsSublayerVisibility:void 0}function m(n){const i=x(n);return null!=i&&"supportsDynamicLayers"in i?i.supportsDynamicLayers:void 0}function x(n){return n&&"capabilities"in n&&null!=n.capabilities&&"exportMap"in n.capabilities?n.capabilities.exportMap:void 0}function S(n){return n?.["data-item"]}function M(n){return n?.getAttribute("data-layer-type")}function N({children:n,error:i,incompatible:e}){return!!n?.filter((n=>!n.hidden)).length&&!i&&!e}export{c as canDisplayLayer,o as canSortSublayers,r as findLayerListMode,u as findLayerMaxScale,l as findLayerMinScale,a as findLayerVisibilityMode,S as getItem,p as getItemLayers,M as getLayerType,b as getLegendLayerInfo,s as getNormalizedChildLayerProperty,t as getStatusIcon,e as getVisibilityIcon,d as isLayerOutsideScaleRange,h as isSublayer,N as listItemHasChildren,f as sortChildLayersToIds,y as sortLayersToIds,i as sortableRoot};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import i from"../core/ReactiveMap.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as n,getActionStyles as l}from"../support/actions/actionUtils.js";import r from"./Widget.js";import{css as a}from"./LayerList/css.js";import c from"./LayerList/LayerListViewModel.js";import d from"./LayerList/LayerListVisibleElements.js";import m from"./LayerList/ListItem.js";import{getItem as p,sortableRoot as u,listItemHasChildren as h,canSortSublayers as v,getStatusIcon as g,getVisibilityIcon as f,sortLayersToIds as _,sortChildLayersToIds as y}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as b}from"./support/componentsUtils.js";import{globalCss as I}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as w}from"./support/decorators/messageBundle.js";import{vmEvent as L}from"./support/decorators/vmEvent.js";import{tsx as A}from"./support/jsxFactory.js";const C=t.ofType(m);let E=class extends r{constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new i,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._lastDragDetail=null,this.collapsed=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.icon=null,this.iconClass=a.widgetIcon,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.messages=null,this.messagesCommon=null,this.multipleSelectionEnabled=!1,this.selectionEnabled=!1,this.selectedItems=new C,this.viewModel=new c,this.visibilityAppearance="default",this.visibleElements=new d,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const s="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,n=p(e);if(!n?.sortable)return!1;const l={selected:n,from:p(t),to:p(i)};return!t.group||!i.group||"function"!=typeof s||s.call(null,l)},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(a.item)));this._activeItem=p(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:o,dragEl:s,newIndex:n,oldIndex:l}=e,r=Array.from(o.children).map((e=>e.id));o.insertBefore(s,o.children[l]);o&&i&&!(t?.newIndex===n&&t?.dragEl===s&&t?.toEl===i&&t?.fromEl===o)&&(this._lastDragDetail=e,o!==i?this._moveLayerFromChildList({toEl:i,fromEl:o,dragEl:s,newIndex:n}):this._sortLayers(o,r))}}loadDependencies(){return b({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._tooltipReferenceMap.clear()}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get operationalItems(){return this.viewModel.operationalItems}set operationalItems(e){this.viewModel.operationalItems=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,t={[I.hidden]:"loading"===e,[I.disabled]:"disabled"===e},i=this.operationalItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)));return A("div",{class:this.classes(a.base,I.widget,I.panel,t)},i?.length?[this._renderItemTooltips(i),this._renderItems(i)]:this._renderNoItems())}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?A("calcite-tooltip",{key:`tooltip-${e.uid}`,referenceElement:t.get(e.uid)},i.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderNoItems(){return A("div",{class:a.itemMessage,key:"esri-layer-list__no-items"},A("calcite-notice",{icon:"information",kind:"info",open:!0,scale:"s",width:"full"},A("div",{slot:"message"},this.messages.noItemsToDisplay)))}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((e=>!e.hidden)).toArray().filter((({panel:e})=>e?.open&&!e.disabled&&e.flowEnabled)).map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return A("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),A("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItems(e){const{visible:t,collapsed:i,visibleElements:{closeButton:o,collapseButton:s,filter:n,heading:l,flow:r},selectionEnabled:a,filterText:c,filterPlaceholder:d,messages:m,multipleSelectionEnabled:p}=this,h=[A("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:o,closed:!t,collapsed:i,collapsible:s,heading:l?m.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},A("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),dragEnabled:a,filterEnabled:n,filterPlaceholder:d,filterText:c,group:u,key:"root-list",label:m.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:a?p?"multiple":"single":"none",onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListFilter:e=>this.filterText=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e))))),this._renderPanelFlowItems(e)];return t?r?A("calcite-flow",{key:"root-flow"},h):h:null}_renderChildList(e){const{selectionEnabled:t}=this,{children:i}=e,o=h(e),s=!o&&t&&"group"===e.layer?.type;return o||s?A("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-item":e,dragEnabled:!!t&&(e.childrenSortable&&v(e)),group:e.uid,key:`child-list-${e.uid}`},i?.filter((e=>!e.hidden)).toArray().map((t=>this._renderItem(t,e)))):null}_renderItemMessage(e){return e.error?A("div",{class:a.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},A("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},A("div",{slot:"message"},this.messages.layerError))):e.incompatible?A("div",{class:a.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},A("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),bind:this,icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},A("div",{slot:"message"},this.messages.layerIncompatible))):null}_renderItem(e,t){const{_activeItem:i,selectionEnabled:o,selectedItems:s,messages:n}=this,l=e.title||n.untitledLayer,r=e.visibleAtCurrentScale?l:`${l} (${n.layerInvisibleAtScale})`,c=this._filterActions(e.actionsSections),d=this._countActions(c);return A("calcite-list-item",{class:this.classes(a.item,{[a.itemActive]:i===e}),"data-item":e,dragDisabled:!e.sortable,id:e.layer.uid,key:`list-item-${e.uid}`,open:e.open,selected:!!o&&s.includes(e),title:r,value:l,onCalciteListItemSelect:i=>this._handleCalciteListItemSelect(i,e,t)},A("div",{class:a.itemContent,slot:"content"},A("div",{class:this.classes({[a.itemInvisibleAtScale]:!e.visibleAtCurrentScale}),key:"item-label"},l)),this._renderItemStatus(e,t),this._renderItemToggle(e,t),this._renderChildList(e),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),d>1?this._renderActionsSections(e,c):1===d?this._renderAction({item:e,action:this._getSingleActionButton(c),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:o,publishing:s,updating:n}=e,l=n&&!t,r=!!o;return A("calcite-icon",{class:this.classes({[a.statusIndicator]:!0,[a.publishing]:s,[a.updating]:l,[a.connectionStatus]:r,[a.connectionStatusConnected]:r&&"connected"===o}),icon:g({connectionStatus:o,publishing:s,isUpdating:l}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemToggle(e,t){const{messages:i,visibilityAppearance:o}=this,{visible:s}=e,n=t?.visibilityMode;if("inherited"===n)return null;const l=f({visible:s,exclusive:"exclusive"===n,visibilityAppearance:o}),r="checkbox"===o;return A("calcite-action",{appearance:"transparent",class:a.visibleToggle,icon:r?l:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:r?"actions-start":"actions-end",text:i.layerVisibility,title:i.layerVisibility},r?null:A("calcite-icon",{class:this.classes({[a.visibleIcon]:"exclusive"!==n&&s}),icon:l,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:A("div",{class:a.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:o}=e;return A("calcite-action",{active:t,appearance:"transparent",disabled:o,icon:n(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){return A("calcite-action-menu",{appearance:"transparent",key:`item-action-menu-${e.uid}`,label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return A("calcite-action-group",{key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o="image"in e?e.image:void 0,s={[a.itemActionIcon]:!!t,[a.itemActionImage]:!!o};return t&&(s[t]=!0),o||t?A("span",{"aria-hidden":"true",class:this.classes(a.itemActionIcon,s),key:"icon",styles:l(o)}):null}_renderAction(e){const{item:t,action:i,textEnabled:o}=e,{active:s,disabled:l,title:r,type:a,indicator:c}=i;return A("calcite-action",{active:"toggle"===a&&i.value,appearance:"transparent",disabled:l,icon:n(i),indicator:c,key:`action-${i.uid}`,loading:s,onclick:()=>this._triggerAction(t,i),scale:"s",slot:o?void 0:"actions-end",text:r??"",textEnabled:o,title:r??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.uid)}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:o}){const s=p(i),n=p(e),l=p(t);this.viewModel.moveListItem(s,l,n,o)}_sortLayers(e,t){if(e)if(e.group===u)_(this.view?.map?.layers,t);else{const i=p(e);if(!i)return;y(i,t)}}_getSingleActionButton(e){return e.reduce((e=>e)).filter((e=>e&&"button"===e.type)).at(0)}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionEnabled:t,selectedItems:i}=this;if(!t)return;const o=e.target.selectedItems.map((e=>p(e))).filter(Boolean);i.removeAll(),i.addMany(o)}_handleCalciteListItemSelect(e,t,i){t&&!this.selectionEnabled&&(e.stopPropagation(),this._toggleVisibility(t,i))}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}};e([o()],E.prototype,"_activeItem",void 0),e([o()],E.prototype,"_tooltipReferenceMap",void 0),e([o()],E.prototype,"_focusRootFlowItem",void 0),e([o()],E.prototype,"_focusPanelFlowItem",void 0),e([o()],E.prototype,"collapsed",void 0),e([o()],E.prototype,"filterPlaceholder",void 0),e([o()],E.prototype,"filterText",void 0),e([o()],E.prototype,"headingLevel",void 0),e([o()],E.prototype,"icon",void 0),e([o()],E.prototype,"iconClass",void 0),e([o()],E.prototype,"label",null),e([o()],E.prototype,"listItemCanGiveFunction",void 0),e([o()],E.prototype,"listItemCanReceiveFunction",void 0),e([o()],E.prototype,"listItemCreatedFunction",null),e([o(),w("esri/widgets/LayerList/t9n/LayerList")],E.prototype,"messages",void 0),e([o(),w("esri/t9n/common")],E.prototype,"messagesCommon",void 0),e([o()],E.prototype,"multipleSelectionEnabled",void 0),e([o()],E.prototype,"operationalItems",null),e([o()],E.prototype,"selectionEnabled",void 0),e([o()],E.prototype,"selectedItems",void 0),e([o()],E.prototype,"view",null),e([L("trigger-action"),o({type:c})],E.prototype,"viewModel",void 0),e([o()],E.prototype,"visibilityAppearance",void 0),e([o({type:d,nonNullable:!0})],E.prototype,"visibleElements",void 0),E=e([s("esri.widgets.LayerList")],E);const F=E;export{F as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import s from"../core/ReactiveMap.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as r,getActionStyles as a}from"../support/actions/actionUtils.js";import c from"./Widget.js";import{css as d}from"./LayerList/css.js";import m from"./LayerList/LayerListViewModel.js";import p from"./LayerList/LayerListVisibleElements.js";import u from"./LayerList/ListItem.js";import{getItem as h,getLayerType as g,sortableRoot as v,listItemHasChildren as f,canSortSublayers as _,getStatusIcon as y,getVisibilityIcon as b,sortLayersToIds as I,sortChildLayersToIds as w}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as L}from"./support/componentsUtils.js";import{globalCss as E}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as C}from"./support/decorators/messageBundle.js";import{vmEvent as A}from"./support/decorators/vmEvent.js";import{tsx as M}from"./support/jsxFactory.js";const F=t.ofType(u),k="operational";let j=class extends c{constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new s,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._lastDragDetail=null,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.icon=null,this.iconClass=d.widgetIcon,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.messages=null,this.messagesCommon=null,this.selectedItems=new F,this.selectionMode="none",this.viewModel=new m,this.visibilityAppearance="default",this.visibleElements=new p,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const s="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,n=h(e);if(!n?.sortable)return!1;const l=h(t),r=g(t),a=h(i),c=g(i),d=!!r&&!!c&&r===c,m={selected:n,from:l,to:a};return t.group&&i.group&&"function"==typeof s?s.call(null,m):d},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(d.item)));this._activeItem=h(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:o,dragEl:s,newIndex:n}=e;if(o&&i&&!(t?.newIndex===n&&t?.dragEl===s&&t?.toEl===i&&t?.fromEl===o))if(this._lastDragDetail=e,o!==i)this._moveLayerFromChildList({toEl:i,fromEl:o,dragEl:s,newIndex:n});else{const e=Array.from(o.children).map((e=>e.id));this._sortLayers(o,e)}}}loadDependencies(){return L({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._tooltipReferenceMap.clear()}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get multipleSelectionEnabled(){return i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),this.selectionMode=this.selectionEnabled?e?"multiple":"single":"none"}get operationalItems(){return this.viewModel.operationalItems}set operationalItems(e){this.viewModel.operationalItems=e}get selectionEnabled(){return i(o.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),"none"!==this.selectionMode&&this.dragEnabled}set selectionEnabled(e){i(o.getLogger(this),"selectionEnabled",{replacement:"selectionMode, dragEnabled",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.selectionMode=e?this.multipleSelectionEnabled?"multiple":"single":"none"}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,t={[E.hidden]:"loading"===e,[E.disabled]:"disabled"===e},i=this.operationalItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)));return M("div",{class:this.classes(d.base,E.widget,E.panel,t)},i?.length?[this._renderItemTooltips(i),this._renderItems(i)]:this._renderNoItems())}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?M("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,referenceElement:t.get(e.layer.uid)},i.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderNoItems(){return M("div",{class:d.itemMessage,key:"esri-layer-list__no-items"},M("calcite-notice",{icon:"information",kind:"info",open:!0,scale:"s",width:"full"},M("div",{slot:"message"},this.messages.noItemsToDisplay)))}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((e=>!e.hidden)).toArray().filter((({panel:e})=>e?.open&&!e.disabled&&e.flowEnabled)).map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return M("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),M("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItems(e){const{visible:t,collapsed:i,visibleElements:{closeButton:o,collapseButton:s,filter:n,heading:l,flow:r},dragEnabled:a,selectionMode:c,filterText:d,filterPlaceholder:m,messages:p}=this,u=[M("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:o,closed:!t,collapsed:i,collapsible:s,heading:l?p.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},M("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-layer-type":k,dragEnabled:a,filterEnabled:n,filterPlaceholder:m,filterText:d,group:v,key:"root-list",label:p.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:c,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e))))),this._renderPanelFlowItems(e)];return t?r?M("calcite-flow",{key:"root-flow"},u):u:null}_renderChildList(e){const{dragEnabled:t}=this,{children:i}=e,o=f(e),s=!o&&t&&"group"===e.layer?.type;return o||s?M("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-item":e,"data-layer-type":k,dragEnabled:!!t&&(e.childrenSortable&&_(e)),group:e.layer.uid},i?.filter((e=>!e.hidden)).toArray().map((t=>this._renderItem(t,e)))):null}_renderItemMessage(e){return e.error?M("div",{class:d.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},M("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},M("div",{slot:"message"},this.messages.layerError))):e.incompatible?M("div",{class:d.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},M("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),bind:this,icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},M("div",{slot:"message"},this.messages.layerIncompatible))):null}_renderItem(e,t){const{_activeItem:i,selectionMode:o,selectedItems:s,messages:n}=this,l=e.title||n.untitledLayer,r=e.visibleAtCurrentScale?l:`${l} (${n.layerInvisibleAtScale})`,a=this._filterActions(e.actionsSections),c=this._countActions(a);return M("calcite-list-item",{class:this.classes(d.item,{[d.itemActive]:i===e}),"data-item":e,dragDisabled:!e.sortable,id:e.layer.uid,key:`list-item-${e.layer.uid}`,open:e.open,selected:"none"!==o&&s.includes(e),title:r,value:l,onCalciteListItemSelect:i=>this._handleCalciteListItemSelect(i,e,t),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},M("div",{class:d.itemContent,slot:"content"},M("div",{class:this.classes({[d.itemInvisibleAtScale]:!e.visibleAtCurrentScale})},l)),this._renderItemStatus(e,t),this._renderItemToggle(e,t),this._renderChildList(e),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),c>1?this._renderActionsSections(e,a):1===c?this._renderAction({item:e,action:this._getSingleActionButton(a),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:o,publishing:s,updating:n}=e,l=n&&!t,r=!!o;return M("calcite-icon",{class:this.classes({[d.statusIndicator]:!0,[d.publishing]:s,[d.updating]:l,[d.connectionStatus]:r,[d.connectionStatusConnected]:r&&"connected"===o}),icon:y({connectionStatus:o,publishing:s,isUpdating:l}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemToggle(e,t){const{messages:i,visibilityAppearance:o}=this,{visible:s}=e,n=t?.visibilityMode;if("inherited"===n)return null;const l=b({visible:s,exclusive:"exclusive"===n,visibilityAppearance:o}),r="checkbox"===o;return M("calcite-action",{appearance:"transparent",class:d.visibleToggle,icon:r?l:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:r?"actions-start":"actions-end",text:i.layerVisibility,title:i.layerVisibility},r?null:M("calcite-icon",{class:this.classes({[d.visibleIcon]:"exclusive"!==n&&s}),icon:l,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:M("div",{class:d.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:o}=e;return M("calcite-action",{active:t,appearance:"transparent",disabled:o,icon:r(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){return M("calcite-action-menu",{appearance:"transparent",key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return M("calcite-action-group",{key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o="image"in e?e.image:void 0,s={[d.itemActionIcon]:!!t,[d.itemActionImage]:!!o};return t&&(s[t]=!0),o||t?M("span",{"aria-hidden":"true",class:this.classes(d.itemActionIcon,s),key:"icon",styles:a(o)}):null}_renderAction(e){const{item:t,action:i,textEnabled:o}=e,{active:s,disabled:n,title:l,type:a,indicator:c}=i;return M("calcite-action",{active:"toggle"===a&&i.value,appearance:"transparent",disabled:n,icon:r(i),indicator:c,key:`action-${i.uid}`,loading:s,onclick:()=>this._triggerAction(t,i),scale:"s",slot:o?void 0:"actions-end",text:l??"",textEnabled:o,title:l??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.layer.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.layer.uid)}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:o}){const s=h(i),n=h(e),l=h(t);this.viewModel.moveListItem(s,l,n,o)}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:o}=e;t.insertBefore(i,t.children[o])}_sortLayers(e,t){if(e)if(e.group===v)I(this.view?.map?.layers,t);else{const i=h(e);if(!i)return;w(i,t)}}_getSingleActionButton(e){return e.reduce((e=>e)).filter((e=>e&&"button"===e.type)).at(0)}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>h(e))).filter(Boolean);i.removeAll(),i.addMany(o)}_handleCalciteListItemToggle(e,t){e.stopPropagation(),t.open=e.target.open}_handleCalciteListItemSelect(e,t,i){h(e.target)===t&&"none"===this.selectionMode&&"inherited"!==i?.visibilityMode&&this._toggleVisibility(t,i)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}};e([n()],j.prototype,"_activeItem",void 0),e([n()],j.prototype,"_tooltipReferenceMap",void 0),e([n()],j.prototype,"_focusRootFlowItem",void 0),e([n()],j.prototype,"_focusPanelFlowItem",void 0),e([n()],j.prototype,"collapsed",void 0),e([n()],j.prototype,"dragEnabled",void 0),e([n()],j.prototype,"filterPlaceholder",void 0),e([n()],j.prototype,"filterText",void 0),e([n()],j.prototype,"headingLevel",void 0),e([n()],j.prototype,"icon",void 0),e([n()],j.prototype,"iconClass",void 0),e([n()],j.prototype,"label",null),e([n()],j.prototype,"listItemCanGiveFunction",void 0),e([n()],j.prototype,"listItemCanReceiveFunction",void 0),e([n()],j.prototype,"listItemCreatedFunction",null),e([n(),C("esri/widgets/LayerList/t9n/LayerList")],j.prototype,"messages",void 0),e([n(),C("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([n()],j.prototype,"multipleSelectionEnabled",null),e([n()],j.prototype,"operationalItems",null),e([n()],j.prototype,"selectionEnabled",null),e([n()],j.prototype,"selectedItems",void 0),e([n()],j.prototype,"selectionMode",void 0),e([n()],j.prototype,"view",null),e([A("trigger-action"),n({type:m})],j.prototype,"viewModel",void 0),e([n()],j.prototype,"visibilityAppearance",void 0),e([n({type:p,nonNullable:!0})],j.prototype,"visibleElements",void 0),j=e([l("esri.widgets.LayerList")],j);const x=j;export{x as default};