@arcgis/core 4.29.0-next.20240222 → 4.29.1

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 (279) hide show
  1. package/arcade/treeAnalysis.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{b43fde3e25d0c3b020b5.js → 039a872509872ce67ba4.js} +1 -1
  4. package/assets/esri/core/workers/chunks/0bc21d2a0b65bd4e9d76.js +1 -0
  5. package/assets/esri/core/workers/chunks/{5243f9ff21e768c620c2.js → 23a5d750d93a7829174f.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{47e6119be4a4a5ed640d.js → 2447a4d5886aeb0ff72a.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{7f45a9e9bdbcffc2d6e0.js → 348bcc57b99a975902a8.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{8c9fb2601488998013ba.js → 3523789a2948a4ab8cc8.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{24649b410b757599a549.js → 48db6e0bbb1a9c043193.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{752082be991f1cc8558f.js → 4984e2b79d862114d6a6.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{8d9736fd15cdb54d9855.js → 5227f9eea6988aadad7f.js} +1 -1
  12. package/assets/esri/core/workers/chunks/58723274ef657fe212eb.js +1 -0
  13. package/assets/esri/core/workers/chunks/60ab18c6a04d4b2f1d4c.js +1 -0
  14. package/assets/esri/core/workers/chunks/647515801d94180b8402.js +1 -0
  15. package/assets/esri/core/workers/chunks/6c3ae96ec90e9ed7dd50.js +1 -0
  16. package/assets/esri/core/workers/chunks/7a8bba91769ee18cc39f.js +1 -0
  17. package/assets/esri/core/workers/chunks/7a98d2e026f63a581b1e.js +1 -0
  18. package/assets/esri/core/workers/chunks/8c360923cd1850767d3e.js +1 -0
  19. package/assets/esri/core/workers/chunks/{1a25ba411b89e050fbb7.js → a61f337802ae963d7f65.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{d0c5318d7ef2e923aad0.js → a8ac511280f873960d46.js} +1 -1
  21. package/assets/esri/core/workers/chunks/b125ab84b7761e761734.js +1 -0
  22. package/assets/esri/core/workers/chunks/{b34d6e58b125fe111f91.js → b42a83db83851cb57d44.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{1497dd943df7eede0704.js → b9c55ff1f21db198ce03.js} +1 -1
  24. package/assets/esri/core/workers/chunks/bb3322ddb89c0bd444f0.js +1 -0
  25. package/assets/esri/core/workers/chunks/becfdaeeb07f089d8be7.js +1 -0
  26. package/assets/esri/core/workers/chunks/{b26e39a399963c176d33.js → c527692694688a5b3b07.js} +2 -2
  27. package/assets/esri/core/workers/chunks/{210a93e0b96c5bff44a3.js → c556644bb0cf88770939.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{e7b26c7e9e24dc6255be.js → cacf97b0a7a1057b9f79.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{a5e7b4acae17f88e2208.js → ce93027b6b81428ce9b0.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{b8ece275abac93f3dccf.js → d14f16bfa6c12909929c.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{1594f06a2d7d9439c62e.js → e2147c99cc5839654be1.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{d33ed3a2a0d4b640bd4a.js → e4c7d8c69e4957c9d27c.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{7709248f59520aee6f51.js → eceaa46f622f6fa31128.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{2286db4c83ff1b6fb088.js → ef3e6209e6ac6a56960b.js} +1 -1
  35. package/assets/esri/core/workers/chunks/f59b5ea05caca8a1a398.js +1 -0
  36. package/chunks/Laserlines.glsl.js +3 -3
  37. package/chunks/Precipitation.glsl.js +1 -1
  38. package/chunks/SSAOBlur.glsl.js +2 -2
  39. package/chunks/boundedPlane.js +1 -1
  40. package/chunks/cameraUtilsSpherical.js +1 -1
  41. package/chunks/sphere.js +1 -1
  42. package/chunks/terrainUtilsPlanar.js +1 -1
  43. package/chunks/vec32.js +1 -1
  44. package/config.js +1 -1
  45. package/copyright.txt +56 -28
  46. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  47. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  48. package/core/libs/gl-matrix-2/vec3.js +1 -1
  49. package/geometry/support/axisAngleDegrees.js +1 -1
  50. package/geometry/support/coordinateSystem.js +1 -1
  51. package/geometry/support/lineSegment.js +1 -1
  52. package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
  53. package/geometry/support/meshUtils/georeference.js +1 -1
  54. package/geometry/support/meshUtils/merge.js +1 -1
  55. package/geometry/support/meshUtils/rotate.js +1 -1
  56. package/geometry/support/meshUtils/scale.js +1 -1
  57. package/geometry/support/meshUtils/vertexSpaceConversion.js +5 -0
  58. package/geometry/support/meshVertexSpaceUtils.js +1 -1
  59. package/geometry/support/plane.js +1 -1
  60. package/geometry/support/ray.js +1 -1
  61. package/geometry/support/triangle.js +1 -1
  62. package/geometry/support/vector.js +1 -1
  63. package/interfaces.d.ts +12 -12
  64. package/kernel.js +1 -1
  65. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  66. package/layers/LinkChartLayer.js +1 -1
  67. package/layers/VoxelWasmPerSceneView.js +1 -1
  68. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  69. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  70. package/layers/mixins/FeatureReductionLayer.js +1 -1
  71. package/layers/orientedImagery/core/CameraOrientation.js +1 -1
  72. package/layers/orientedImagery/core/ElevationSourceDefinitions.js +1 -1
  73. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  74. package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
  75. package/layers/orientedImagery/transformations/imageToWorld.js +5 -0
  76. package/layers/orientedImagery/transformations/updateElevation.js +5 -0
  77. package/layers/orientedImagery/transformations/updateElevationUtils.js +5 -0
  78. package/layers/orientedImagery/transformations/utils.js +1 -1
  79. package/layers/orientedImagery/transformations/worldToImage.js +5 -0
  80. package/layers/support/EditingCapabilities.js +1 -1
  81. package/layers/support/editableLayers.js +1 -1
  82. package/layers/support/layerUtils.js +1 -1
  83. package/layers/video/VideoCameraSensorModel.js +1 -1
  84. package/layers/voxel/VoxelVolume.js +1 -1
  85. package/layers/voxel/voxelPlaneUtils.js +1 -1
  86. package/libs/linkchartlayout/LinkChartLayout.js +1 -1
  87. package/package.json +1 -1
  88. package/smartMapping/renderers/pieChart.js +1 -1
  89. package/support/revision.js +1 -1
  90. package/symbols/cim/cimAnalyzer.js +1 -1
  91. package/views/2d/arcade/callExpressionWithCursor.js +1 -1
  92. package/views/2d/engine/webgl/shaderGraph/techniques/createTestMeshData.js +1 -1
  93. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriterInputEvaluator.js +1 -1
  94. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  95. package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
  96. package/views/2d/layers/features/Processor.js +1 -1
  97. package/views/2d/layers/features/aggregation/GeohashSpatialIndex.js +1 -1
  98. package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
  99. package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
  100. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  101. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
  102. package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
  103. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
  104. package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
  105. package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
  106. package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
  107. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  108. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  109. package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
  110. package/views/2d/layers/features/sources/strategies/chunks/DrillDownTileSourceChunk.js +1 -1
  111. package/views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js +1 -1
  112. package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +1 -1
  113. package/views/2d/layers/features/sources/strategies/chunks/PagedTileSourceChunk.js +1 -1
  114. package/views/2d/layers/features/sources/strategies/chunks/StreamSourceChunk.js +1 -1
  115. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  116. package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
  117. package/views/2d/layers/features/support/GraphicsReader.js +1 -1
  118. package/views/2d/layers/features/support/Tile.js +1 -1
  119. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  120. package/views/2d/tiling/TileKey.js +1 -1
  121. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  122. package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
  123. package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
  124. package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
  125. package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementController.js +1 -1
  126. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  127. package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
  128. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  129. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  130. package/views/3d/analysis/support/measurementUtils.js +1 -1
  131. package/views/3d/animation/pointToPoint/Camera.js +1 -1
  132. package/views/3d/camera/constraintUtils/common.js +1 -1
  133. package/views/3d/camera/constraintUtils/distance.js +1 -1
  134. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  135. package/views/3d/camera/intersectionUtils.js +1 -1
  136. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  137. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  138. package/views/3d/environment/Fog.js +1 -1
  139. package/views/3d/environment/MarsAtmosphere.js +1 -1
  140. package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
  141. package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
  142. package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
  143. package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
  144. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  145. package/views/3d/interactive/editingTools/reshapeGraphic/edgeOffsetUtils.js +1 -1
  146. package/views/3d/interactive/editingTools/transformGraphic/ExtentScale.js +1 -1
  147. package/views/3d/interactive/editingTools/transformGraphic/extentUtils.js +1 -1
  148. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  149. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  150. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  151. package/views/3d/interactive/visualElements/support/Segment.js +1 -1
  152. package/views/3d/layers/I3SMeshView3D.js +1 -1
  153. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  154. package/views/3d/layers/PointCloudWorker.js +1 -1
  155. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  156. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  157. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  158. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  159. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  160. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  161. package/views/3d/layers/i3s/LoDUtil.js +1 -1
  162. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  163. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  164. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  165. package/views/3d/layers/support/uvUtils.js +1 -1
  166. package/views/3d/state/Frustum.js +1 -1
  167. package/views/3d/state/NearFarHeuristic.js +1 -1
  168. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  169. package/views/3d/state/controllers/RotateController.js +1 -1
  170. package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
  171. package/views/3d/state/controllers/global/ZoomController.js +1 -1
  172. package/views/3d/state/controllers/global/ZoomStepController.js +1 -1
  173. package/views/3d/state/controllers/local/PinchAndPanController.js +1 -1
  174. package/views/3d/state/controllers/local/ZoomController.js +1 -1
  175. package/views/3d/state/controllers/local/ZoomStepController.js +1 -1
  176. package/views/3d/state/controllers/momentum/ZoomPlanarMomentumController.js +1 -1
  177. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  178. package/views/3d/state/utils/navigationUtils.js +1 -1
  179. package/views/3d/state/utils/viewUtils.js +1 -1
  180. package/views/3d/support/FrustumExtentIntersection.js +1 -1
  181. package/views/3d/support/cameraUtils.js +1 -1
  182. package/views/3d/support/cameraUtilsInternal.js +1 -1
  183. package/views/3d/support/intersectionUtils.js +1 -1
  184. package/views/3d/support/mathUtils.js +1 -1
  185. package/views/3d/support/orientedBoundingBox.js +1 -1
  186. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  187. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  188. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  189. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  190. package/views/3d/support/sunUtils.js +1 -1
  191. package/views/3d/support/viewpointUtils.js +1 -1
  192. package/views/3d/terrain/OverlayManager.js +1 -1
  193. package/views/3d/terrain/PatchRenderData.js +1 -1
  194. package/views/3d/terrain/SphericalPatch.js +1 -1
  195. package/views/3d/terrain/TerrainRenderer.js +1 -1
  196. package/views/3d/terrain/Tile.js +1 -1
  197. package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
  198. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  199. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  200. package/views/3d/webgl-engine/core/util/TwoVectorPosition.js +1 -1
  201. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  202. package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
  203. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  204. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  205. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  206. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  207. package/views/3d/webgl-engine/lib/PathVertex.js +1 -1
  208. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  209. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  210. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  211. package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
  212. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  213. package/views/3d/webgl-engine/lib/intersectorUtils.js +1 -1
  214. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  215. package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
  216. package/views/3d/webgl-engine/lighting/SceneLighting.js +1 -1
  217. package/views/3d/webgl-engine/lighting/SphericalHarmonics.js +1 -1
  218. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  219. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  220. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  221. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  222. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  223. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  224. package/views/3d/webgl-engine/materials/pbrUtils.js +1 -1
  225. package/views/SelectionManager.js +1 -1
  226. package/views/draw/support/createUtils.js +1 -1
  227. package/views/draw/support/surfaceCoordinateSystems.js +1 -1
  228. package/views/interactive/GraphicManipulator.js +1 -1
  229. package/views/interactive/SegmentLabels.js +1 -1
  230. package/views/interactive/coordinateHelper.js +1 -1
  231. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  232. package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
  233. package/views/interactive/sketch/constraints.js +1 -1
  234. package/views/interactive/snapping/RightAngleSnapper.js +1 -1
  235. package/views/interactive/snapping/candidates/ParallelLineSnappingCandidate.js +1 -1
  236. package/views/interactive/snapping/candidates/RightAngleTriangleSnappingCandidate.js +1 -1
  237. package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
  238. package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
  239. package/views/interactive/snapping/hints/IntersectionSnappingHint.js +1 -1
  240. package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
  241. package/views/interactive/snapping/hints/ParallelSnappingHint.js +1 -1
  242. package/views/interactive/snapping/hints/PointSnappingHint.js +1 -1
  243. package/views/interactive/snapping/hints/RightAngleSnappingHint.js +1 -1
  244. package/views/layers/FeatureLayerView.js +1 -1
  245. package/views/layers/support/editableLayerViews.js +5 -0
  246. package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
  247. package/views/support/angularMeasurementUtils.js +1 -1
  248. package/views/support/euclideanAreaMeasurementUtils.js +1 -1
  249. package/views/support/euclideanLengthMeasurementUtils.js +1 -1
  250. package/views/support/geometry3dUtils.js +1 -1
  251. package/widgets/Editor/EditorViewModel.js +1 -1
  252. package/widgets/Editor/support/EditorEditingCapabilities.js +1 -1
  253. package/widgets/Editor/support/EditorItem.js +1 -1
  254. package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
  255. package/widgets/FeatureForm.js +1 -1
  256. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  257. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  258. package/widgets/FeatureTable/support/ColumnTemplateBase.js +1 -1
  259. package/widgets/Features/FeaturesViewModel.js +1 -1
  260. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  261. package/widgets/OrientedImageryViewer.js +1 -1
  262. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  263. package/widgets/PanoramicViewer/utils.js +1 -1
  264. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  265. package/widgets/UtilityNetworkTrace.js +1 -1
  266. package/widgets/support/Selector2D/SelectionOperation.js +1 -1
  267. package/widgets/support/Selector2D/selectorUtils.js +1 -1
  268. package/assets/esri/core/workers/chunks/0e83f3718a0b45652b5e.js +0 -1
  269. package/assets/esri/core/workers/chunks/1fa5c8af69a09a3730b3.js +0 -1
  270. package/assets/esri/core/workers/chunks/25f73748df0ee82d06cb.js +0 -1
  271. package/assets/esri/core/workers/chunks/2d7a18f8c540269ecee9.js +0 -1
  272. package/assets/esri/core/workers/chunks/4736f79b5c94ce103d43.js +0 -1
  273. package/assets/esri/core/workers/chunks/65f7adaaf1f535310c11.js +0 -1
  274. package/assets/esri/core/workers/chunks/79c041b292648c5eaecc.js +0 -1
  275. package/assets/esri/core/workers/chunks/7c4c2c0beddabac672b6.js +0 -1
  276. package/assets/esri/core/workers/chunks/9a758de08dfa57735879.js +0 -1
  277. package/assets/esri/core/workers/chunks/a4c3da057ec2a07bbbe8.js +0 -1
  278. package/assets/esri/core/workers/chunks/b252270b100351779f1f.js +0 -1
  279. package/assets/esri/core/workers/chunks/dc57aa9f2fc69e654559.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 t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecatedProperty as r,deprecated as i}from"../../core/deprecate.js";import s from"../../core/Error.js";import o from"../../core/Evented.js";import{makeHandle as n}from"../../core/handleUtils.js";import l from"../../core/Logger.js";import{abortMaybe as p,removeMaybe as d,destroyMaybe as c}from"../../core/maybe.js";import{throwIfAborted as u,createResolver as h}from"../../core/promiseUtils.js";import{watch as w,on as f,when as m,whenOnce as y,syncAndInitial as k,initial as g,sync as v}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as W}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as b}from"../../core/support/UpdatingHandles.js";import I from"../../layers/GraphicsLayer.js";import{isEditableLayer as F}from"../../layers/support/editableLayers.js";import{isFeatureLayer as E,getOwningPortalUrl as M}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as C}from"../../portal/support/urlUtils.js";import V from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as O}from"../../views/interactive/snapping/SnappingManager.js";import U from"../../views/interactive/snapping/SnappingOptions.js";import T from"../Attachments/AttachmentsViewModel.js";import L from"./CreateFeaturesWorkflow.js";import A from"./UpdateWorkflow.js";import{whenEditorLayerView as j}from"./workflowUtils.js";import S from"./support/EditorItem.js";import P from"../FeatureTemplates/FeatureTemplatesViewModel.js";import R from"../Sketch/SketchViewModel.js";import H from"../Spinner/SpinnerViewModel.js";const x="esri.widgets.Editor.EditorViewModel",G=()=>l.getLogger(x),D=["create-features","update"];function q(t,e,a){G().error(new s(t,e,a))}function B(t,e){return t?.find((t=>t.layer===e))}let Q=class extends o.EventedAccessor{constructor(t){super(t),this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new I({listMode:"hide",internal:!0}),this._snappingManager=null,this._updateItemsTask=null,this._updatingHandles=new b,this._featureTemplatesViewModelLocked=!1,this.activeWorkflow=null,this._activityQueue=new a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new T({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new P({disabledItemFunction:({layer:t})=>this._itemIsSuspended(t)}),this.ownSketchViewModel=new R({layer:this._sketchGraphicsLayer}),this.sketchOptions=new V,this.snappingOptions=new U,this.spinnerViewModel=new H,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t){if(t.submit(),!t.submittable)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return}await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([w((()=>{const t=this.view,e=t?.map?.editableLayers,a=t?.allLayerViews,r=a?.filter((t=>!!e?.includes(t.layer)));return[e,r,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditorItems()),k),w((()=>this.hideTemplatesForInactiveLayers),(()=>this.syncFeatureTemplates())),f((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),f((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),f((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),m((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),g),f((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),w((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),w((()=>this.page),((t,e)=>{const a=[...this.pageStack];if(-1===a.indexOf(t))a.push(t);else for(;a.length&&a.at(-1)!==t;)a.pop();this.pageStack=a}),k),m((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),f((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this;if(a){if("update"===a.type&&"awaiting-feature-creation-info"===a.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(e,{emit:!1})}}if(!t)return;const r={layer:t.layer,template:t.template};if(t.supportsUpload)return this.featureTemplatesViewModel.select(e,{emit:!1}),this.startCreateFeaturesWorkflow(r);this.startCreateFeaturesWorkflowAtFeatureCreation(r)})),f((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(t.stopPropagation(),this.back())})),f((()=>this.sketchViewModel),["create","delete","update"],(t=>{const{activeWorkflow:e}=this,a="update"===e?.type,r=a?e.activeWorkflow?.layer:e?.layer,i=a?e?.activeWorkflow?.parentLayer:void 0,s=`sketch-${t.type}`;this.emit(s,{type:s,detail:t,layer:r,parentLayer:i})}),v),w((()=>this.view),(t=>{if(this._snappingManager=c(this._snappingManager),!t)return;const e=this.snappingOptions;this._snappingManager=new O({view:t,options:e})}),k),w((()=>this.snappingOptions),(t=>{this._snappingManager&&(this._snappingManager.options=t)}),k)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=d(this._sketchEventListenerHandle)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){r(l.getLogger(this),"allowedWorkflows",{replacement:"Editor.visibleElements",version:"4.29",warnOnce:!0}),t&&0!==t.length||(t=[...D]),this._set("allowedWorkflows",t)}get canCreate(){return this.editorItems.some((t=>t.supportsCreateFeaturesWorkflow))}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some((t=>t.supportsUpdateWorkflow))}get canUpdateVisible(){return this.editorItems.some((t=>t.supportsUpdateWorkflow&&t.visible))}get featureTemplatesLayers(){const t=new a;for(const e of this.editorItems){const a=e.supportsCreateFeaturesWorkflow&&!e.isTable,r=this.hideTemplatesForInactiveLayers&&!e.visible;a&&!r&&t.push(e.layer)}return t}get editableItems(){return r(l.getLogger(this),"editableItems",{replacement:"editorItems",version:"4.29",warnOnce:!0}),this.editorItems.map((t=>{const{capabilities:e,disabled:a,hasInvalidFormTemplate:r,layer:i}=t,s=[],o=e.create,n=e.update,l=e.delete;return o.enabled&&s.push("create"),n.enabled&&s.push("update"),l.enabled&&s.push("delete"),{layer:i,supports:s,suspended:a,attributeUpdatesEnabled:n.attributes,geometryUpdatesEnabled:n.geometry,attachmentsOnCreateEnabled:o.attachments.enabled,attachmentsOnUpdateEnabled:n.attachments.enabled,hasInvalidFormTemplate:r,hasAttachments:e.attachments.enabled}}))}get featureFormViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeFeatureFormViewModel:"create-features"===t?.type?t.featureFormViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(t){this.sketchOptions.labels=t}set layerInfos(t){const e=t?.some((t=>"allowAttachments"in t));e&&i(G(),"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),this._set("layerInfos",t)}get sketchViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeSketchViewModel:"create-features"===t?.type?t.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?.stepId?"update"===e.type&&e.activeWorkflow?.stepId?e.activeWorkflow.stepId:e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(t){this.sketchOptions.tooltips=t}get valueOptions(){return this.sketchOptions.values}set valueOptions(t){this.sketchOptions.values=t}set view(t){this.ownSketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;if("update"===t?.type&&"awaiting-feature-to-update"===t.stepId)return"ready";if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.upload;if(e)return"default"===e.state?"ready":"creating-features-upload-details"}return e??"disabled"}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t.activeEditorItem?.capabilities.update.attributes}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditorItem?.capabilities.delete.enabled}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await y((()=>!this.updating)),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const a=this._createUpdatingResolver();await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow(t,e);this._set("activeWorkflow",r),await r.start(),a.resolve()}async startCreateFeaturesWorkflowAtFeatureEdit(t){await y((()=>!this.updating));const e=this._createUpdatingResolver(),{initialFeature:a}=t,r=a.sourceLayer,i=r?this.findEditorItemForLayer(r):void 0;if(!i?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const o=this._createCreateFeaturesWorkflow({initialFeature:a,layer:i.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",o),await o.start(),e.resolve()}async startUpdateWorkflowAtFeatureSelection(){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start(),t.resolve()}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("awaiting-update-feature-candidate");a.data.candidates=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async startUpdateWorkflowAtFeatureEdit(t){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("editing-existing-feature");a.data.rootFeature=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():q("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warnIfNoWorkflow:!0,...t})}findEditorItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this.editorItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return null!=t&&!0===this.findEditorItemForLayer(t.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelLocked||(this.featureTemplatesViewModel.layers=this.featureTemplatesLayers.toArray())}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}lockFeatureTemplatesViewModel(){return this._featureTemplatesViewModelLocked=!0,n((()=>{this._featureTemplatesViewModelLocked=!1,this.syncFeatureTemplates()}))}async _getEditorItemCandidates(t){const{view:e}=this;if(!e?.map)return[];const{map:a}=e,r=a.editableLayers.toArray()??[],i=a.allTables.toArray().filter(E)??[];return await Promise.allSettled([...r.map((t=>"subtype-group"===t.type?t.loadAll():Promise.resolve())),...i.map((t=>t.load()))]),u(t),[...r.reverse(),...i.reverse()].filter((t=>{if(!F(t))return!1;const{geometryType:a,spatialReference:r}=t;if("mesh"===a){if("3d"!==e.type)return!1;const{isGeographic:t}=r;switch(e.viewingMode){case"global":return t;case"local":return!t}}return!0})).flatMap((t=>"subtype-group"===t.type?t.sublayers.toArray():t))}_drainEditorItems(){this.editorItems.drain((t=>t.destroy()))}async _updateEditorItems(){p(this._updateItemsTask);const{view:t}=this,a=e((async e=>{if(!t?.map||!t?.allLayerViews)return;const a=await this._getEditorItemCandidates(e);if(!a.length)return void this._drainEditorItems();const r=[],i=[],s=[],{layerInfos:o}=this;for(const l of a){const e=B(o,l),a=await j(t,l).catch((()=>null));(e?r:a?i:s).push(new S({layer:l,layerInfo:e,layerView:a}))}o?.length&&r.sort(((t,e)=>o.findIndex((({layer:e})=>e===t.layer))-o.findIndex((({layer:t})=>t===e.layer))));const n=[...r,...i,...s];e.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))}));this._updatingHandles.addPromise(a.promise),this._updateItemsTask=a}_afterEditorItemsChange(){const{activeWorkflow:t}=this;if(this.syncFeatureTemplates(),!t)return;const{stepId:e}=t;"create-features"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===e&&!t.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t?.warnIfNoWorkflow&&q("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return L.create({viewModel:this,creationInfo:t,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createUpdateWorkflow(t){return A.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if(!("addAttachment"in t)||null==t.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await M(t.url):null,s={returnServiceEditsOption:(!i||!C(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const{view:a}=this;if(!a)return null;const i=await j(a,t).catch((()=>null));return r=await t.applyEdits(e,s),i&&await y((()=>!i.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t);const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if(null!=t&&"error"in t&&null!=t.error)throw t.error;if(null!=t&&"addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{q("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue)}))}_createUpdatingResolver(){const t=h();return this._updatingHandles.addPromise(t.promise),t}_itemIsSuspended(t){const e=this.findEditorItemForLayer(t);return null!=e&&(!e.visible||e.disabled)}};t([_({readOnly:!0})],Q.prototype,"activeWorkflow",void 0),t([_({readOnly:!0})],Q.prototype,"_activityQueue",void 0),t([_({value:[...D]})],Q.prototype,"allowedWorkflows",null),t([_({readOnly:!0})],Q.prototype,"canCreate",null),t([_()],Q.prototype,"canCreateVisible",null),t([_({readOnly:!0})],Q.prototype,"canUpdate",null),t([_()],Q.prototype,"canUpdateVisible",null),t([_()],Q.prototype,"featureTemplatesLayers",null),t([_()],Q.prototype,"editableItems",null),t([_()],Q.prototype,"editorItems",void 0),t([_({readOnly:!0})],Q.prototype,"failures",void 0),t([_()],Q.prototype,"hideTemplatesForInactiveLayers",void 0),t([_()],Q.prototype,"attachmentsViewModel",void 0),t([_()],Q.prototype,"featureFormViewModel",null),t([_()],Q.prototype,"featureTemplatesViewModel",void 0),t([_()],Q.prototype,"labelOptions",null),t([_()],Q.prototype,"layerInfos",null),t([_()],Q.prototype,"ownSketchViewModel",void 0),t([_()],Q.prototype,"sketchOptions",void 0),t([_()],Q.prototype,"sketchViewModel",null),t([_({type:U,nonNullable:!0})],Q.prototype,"snappingOptions",void 0),t([_()],Q.prototype,"spinnerViewModel",void 0),t([_()],Q.prototype,"state",null),t([_({readOnly:!0})],Q.prototype,"syncing",null),t([_()],Q.prototype,"updating",null),t([_()],Q.prototype,"tooltipOptions",null),t([_()],Q.prototype,"valueOptions",null),t([_()],Q.prototype,"view",null),t([_()],Q.prototype,"pageStack",void 0),t([_()],Q.prototype,"showDiscardEditsPrompt",void 0),t([_()],Q.prototype,"_candidateCommitted",void 0),t([_()],Q.prototype,"page",null),t([_()],Q.prototype,"featureFormDisabled",null),t([_()],Q.prototype,"canGoBack",null),t([_()],Q.prototype,"shouldShowDeleteButton",null),t([_()],Q.prototype,"hasPendingEdits",null),Q=t([W(x)],Q);const N=Q;export{N as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecatedProperty as r,deprecated as i}from"../../core/deprecate.js";import s from"../../core/Error.js";import o from"../../core/Evented.js";import{makeHandle as n}from"../../core/handleUtils.js";import l from"../../core/Logger.js";import{abortMaybe as p,removeMaybe as d,destroyMaybe as c}from"../../core/maybe.js";import{throwIfAborted as u,createResolver as h}from"../../core/promiseUtils.js";import{watch as w,on as f,when as m,whenOnce as y,syncAndInitial as k,initial as g,sync as v}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as W}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as b}from"../../core/support/UpdatingHandles.js";import I from"../../layers/GraphicsLayer.js";import{isEditableLayer as F}from"../../layers/support/editableLayers.js";import{isFeatureLayer as E,getOwningPortalUrl as M}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as C}from"../../portal/support/urlUtils.js";import V from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as O}from"../../views/interactive/snapping/SnappingManager.js";import U from"../../views/interactive/snapping/SnappingOptions.js";import T from"../Attachments/AttachmentsViewModel.js";import L from"./CreateFeaturesWorkflow.js";import A from"./UpdateWorkflow.js";import{whenEditorLayerView as j}from"./workflowUtils.js";import S from"./support/EditorItem.js";import P from"../FeatureTemplates/FeatureTemplatesViewModel.js";import R from"../Sketch/SketchViewModel.js";import H from"../Spinner/SpinnerViewModel.js";const x="esri.widgets.Editor.EditorViewModel",D=()=>l.getLogger(x),G=["create-features","update"];function q(t,e,a){D().error(new s(t,e,a))}function B(t,e){return t?.find((t=>t.layer===e))}let Q=class extends o.EventedAccessor{constructor(t){super(t),this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new I({listMode:"hide",internal:!0}),this._snappingManager=null,this._updateItemsTask=null,this._updatingHandles=new b,this._featureTemplatesViewModelLocked=!1,this.activeWorkflow=null,this._activityQueue=new a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new T({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new P({disabledItemFunction:({layer:t})=>this._itemIsSuspended(t)}),this.ownSketchViewModel=new R({layer:this._sketchGraphicsLayer}),this.sketchOptions=new V,this.snappingOptions=new U,this.spinnerViewModel=new H,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t){if(t.submit(),!t.submittable)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return}await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([w((()=>{const t=this.view,e=t?.map?.editableLayers,a=t?.allLayerViews,r=a?.filter((t=>!!e?.includes(t.layer)));return[e,r,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditorItems()),k),w((()=>this.hideTemplatesForInactiveLayers),(()=>this.syncFeatureTemplates())),f((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),f((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),f((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),m((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),g),f((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),w((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),w((()=>this.page),((t,e)=>{const a=[...this.pageStack];if(-1===a.indexOf(t))a.push(t);else for(;a.length&&a.at(-1)!==t;)a.pop();this.pageStack=a}),k),m((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),f((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this;if(a){if("update"===a.type&&"awaiting-feature-creation-info"===a.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(e,{emit:!1})}}if(!t)return;const r={layer:t.layer,template:t.template};if(t.supportsUpload)return this.featureTemplatesViewModel.select(e,{emit:!1}),this.startCreateFeaturesWorkflow(r);this.startCreateFeaturesWorkflowAtFeatureCreation(r)})),f((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(t.stopPropagation(),this.back())})),f((()=>this.sketchViewModel),["create","delete","update"],(t=>{const{activeWorkflow:e}=this,a="update"===e?.type,r=a?e.activeWorkflow?.layer:e?.layer,i=a?e?.activeWorkflow?.parentLayer:void 0,s=`sketch-${t.type}`;this.emit(s,{type:s,detail:t,layer:r,parentLayer:i})}),v),w((()=>this.view),(t=>{if(this._snappingManager=c(this._snappingManager),!t)return;const e=this.snappingOptions;this._snappingManager=new O({view:t,options:e})}),k),w((()=>this.snappingOptions),(t=>{this._snappingManager&&(this._snappingManager.options=t)}),k)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=d(this._sketchEventListenerHandle)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){r(l.getLogger(this),"allowedWorkflows",{replacement:"Editor.visibleElements",version:"4.29",warnOnce:!0}),t&&0!==t.length||(t=[...G]),this._set("allowedWorkflows",t)}get canCreate(){return this.editorItems.some((t=>t.supportsCreateFeaturesWorkflow))}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some((t=>t.supportsUpdateWorkflow))}get canUpdateVisible(){return this.editorItems.some((t=>t.supportsUpdateWorkflow&&t.visible))}get featureTemplatesLayers(){const t=new a;for(const e of this.editorItems){const a=e.supportsCreateFeaturesWorkflow&&!e.isTable,r=this.hideTemplatesForInactiveLayers&&!e.visible;a&&!r&&t.push(e.layer)}return t}get editableItems(){return r(l.getLogger(this),"editableItems",{replacement:"editorItems",version:"4.29",warnOnce:!0}),this.editorItems.map((t=>{const{capabilities:e,disabled:a,hasInvalidFormTemplate:r,layer:i}=t,s=[],o=e.create,n=e.update,l=e.delete;return o.enabled&&s.push("create"),n.enabled&&s.push("update"),l.enabled&&s.push("delete"),{layer:i,supports:s,suspended:a,attributeUpdatesEnabled:n.attributes,geometryUpdatesEnabled:n.geometry,attachmentsOnCreateEnabled:o.attachments.enabled,attachmentsOnUpdateEnabled:n.attachments.enabled,hasInvalidFormTemplate:r,hasAttachments:e.attachments.enabled}}))}get featureFormViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeFeatureFormViewModel:"create-features"===t?.type?t.featureFormViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(t){this.sketchOptions.labels=t}set layerInfos(t){const e=t?.some((t=>"allowAttachments"in t));e&&i(D(),"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),this._set("layerInfos",t)}get sketchViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeSketchViewModel:"create-features"===t?.type?t.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?.stepId?"update"===e.type&&e.activeWorkflow?.stepId?e.activeWorkflow.stepId:e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(t){this.sketchOptions.tooltips=t}get valueOptions(){return this.sketchOptions.values}set valueOptions(t){this.sketchOptions.values=t}set view(t){this.ownSketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;if("update"===t?.type&&"awaiting-feature-to-update"===t.stepId)return"ready";if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.upload;if(e)return"default"===e.state?"ready":"creating-features-upload-details"}return e??"disabled"}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t.activeEditorItem?.capabilities.update.attributes}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditorItem?.capabilities.delete.enabled}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await y((()=>!this.updating)),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const a=this._createUpdatingResolver();await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow(t,e);this._set("activeWorkflow",r),await r.start(),a.resolve()}async startCreateFeaturesWorkflowAtFeatureEdit(t){await y((()=>!this.updating));const e=this._createUpdatingResolver(),{initialFeature:a}=t,r=a.sourceLayer,i=r?this.findEditorItemForLayer(r):void 0;if(!i?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const o=this._createCreateFeaturesWorkflow({initialFeature:a,layer:i.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",o),await o.start(),e.resolve()}async startUpdateWorkflowAtFeatureSelection(){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start(),t.resolve()}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("awaiting-update-feature-candidate");a.data.candidates=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async startUpdateWorkflowAtFeatureEdit(t){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("editing-existing-feature");a.data.rootFeature=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():q("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warnIfNoWorkflow:!0,...t})}findEditorItemForLayer(t){return this.editorItems.find((e=>e.layer===t))}itemHasInvalidFormTemplate(t){return null!=t&&!0===this.findEditorItemForLayer(t.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelLocked||(this.featureTemplatesViewModel.layers=this.featureTemplatesLayers.toArray())}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}lockFeatureTemplatesViewModel(){return this._featureTemplatesViewModelLocked=!0,n((()=>{this._featureTemplatesViewModelLocked=!1,this.syncFeatureTemplates()}))}async _getEditorItemCandidates(t){const{view:e}=this;if(!e?.map)return[];const{map:a}=e,r=a.editableLayers.toArray()??[],i=a.allTables.toArray().filter(E)??[];return await Promise.allSettled([...r.map((t=>"subtype-group"===t.type?t.loadAll():Promise.resolve())),...i.map((t=>t.load()))]),u(t),[...r.reverse(),...i.reverse()].filter((t=>F(t)&&("mesh"!==t.geometryType||"3d"===e.type))).flatMap((t=>"subtype-group"===t.type?t.sublayers.toArray():t))}_drainEditorItems(){this.editorItems.drain((t=>t.destroy()))}async _updateEditorItems(){p(this._updateItemsTask);const{view:t}=this,a=e((async e=>{if(!t?.map||!t?.allLayerViews)return;const a=await this._getEditorItemCandidates(e);if(!a.length)return void this._drainEditorItems();const r=[],i=[],s=[],{layerInfos:o}=this;for(const l of a){const e=B(o,l),a=await j(t,l).catch((()=>null));(e?r:a?i:s).push(new S({layer:l,layerInfo:e,layerView:a}))}o?.length&&r.sort(((t,e)=>o.findIndex((({layer:e})=>e===t.layer))-o.findIndex((({layer:t})=>t===e.layer))));const n=[...r,...i,...s];e.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))}));this._updatingHandles.addPromise(a.promise),this._updateItemsTask=a}_afterEditorItemsChange(){const{activeWorkflow:t}=this;if(this.syncFeatureTemplates(),!t)return;const{stepId:e}=t;"create-features"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===e&&!t.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t?.warnIfNoWorkflow&&q("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return L.create({viewModel:this,creationInfo:t,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createUpdateWorkflow(t){return A.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if(!("addAttachment"in t)||null==t.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await M(t.url):null,s={returnServiceEditsOption:(!i||!C(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const{view:a}=this;if(!a)return null;const i=await j(a,t).catch((()=>null));return r=await t.applyEdits(e,s),i&&await y((()=>!i.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t);const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if(null!=t&&"error"in t&&null!=t.error)throw t.error;if(null!=t&&"addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{q("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue)}))}_createUpdatingResolver(){const t=h();return this._updatingHandles.addPromise(t.promise),t}_itemIsSuspended(t){const e=this.findEditorItemForLayer(t);return null!=e&&(!e.visible||e.disabled)}};t([_({readOnly:!0})],Q.prototype,"activeWorkflow",void 0),t([_({readOnly:!0})],Q.prototype,"_activityQueue",void 0),t([_({value:[...G]})],Q.prototype,"allowedWorkflows",null),t([_({readOnly:!0})],Q.prototype,"canCreate",null),t([_()],Q.prototype,"canCreateVisible",null),t([_({readOnly:!0})],Q.prototype,"canUpdate",null),t([_()],Q.prototype,"canUpdateVisible",null),t([_()],Q.prototype,"featureTemplatesLayers",null),t([_()],Q.prototype,"editableItems",null),t([_()],Q.prototype,"editorItems",void 0),t([_({readOnly:!0})],Q.prototype,"failures",void 0),t([_()],Q.prototype,"hideTemplatesForInactiveLayers",void 0),t([_()],Q.prototype,"attachmentsViewModel",void 0),t([_()],Q.prototype,"featureFormViewModel",null),t([_()],Q.prototype,"featureTemplatesViewModel",void 0),t([_()],Q.prototype,"labelOptions",null),t([_()],Q.prototype,"layerInfos",null),t([_()],Q.prototype,"ownSketchViewModel",void 0),t([_()],Q.prototype,"sketchOptions",void 0),t([_()],Q.prototype,"sketchViewModel",null),t([_({type:U,nonNullable:!0})],Q.prototype,"snappingOptions",void 0),t([_()],Q.prototype,"spinnerViewModel",void 0),t([_()],Q.prototype,"state",null),t([_({readOnly:!0})],Q.prototype,"syncing",null),t([_()],Q.prototype,"updating",null),t([_()],Q.prototype,"tooltipOptions",null),t([_()],Q.prototype,"valueOptions",null),t([_()],Q.prototype,"view",null),t([_()],Q.prototype,"pageStack",void 0),t([_()],Q.prototype,"showDiscardEditsPrompt",void 0),t([_()],Q.prototype,"_candidateCommitted",void 0),t([_()],Q.prototype,"page",null),t([_()],Q.prototype,"featureFormDisabled",null),t([_()],Q.prototype,"canGoBack",null),t([_()],Q.prototype,"shouldShowDeleteButton",null),t([_()],Q.prototype,"hasPendingEdits",null),Q=t([W(x)],Q);const N=Q;export{N 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{property as t}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 a from"../../../layers/support/EditingCapabilities.js";import{isRelatableFeatureSupportedLayer as n}from"../../Feature/support/featureUtils.js";let l=class extends a{constructor(e){super(e),this.layerInfo=null}get attachments(){const e=this.defaults.attachments.enabled,t=this.layerInfo;return{enabled:e&&!1!==t?.allowAttachments&&!1!==t?.enabled}}get create(){const{attachments:e,defaults:t,layerInfo:r}=this,a=t.create,n=!1!==r?.enabled&&!1!==r?.addEnabled,l=a.enabled&&n;return{attributes:l&&a.attributes,enabled:l,geometry:l&&a.geometry,attachments:{enabled:e.enabled&&l&&!1!==r?.attachmentsOnCreateEnabled},reliesOnOwnerAdminPrivileges:a.reliesOnOwnerAdminPrivileges}}get defaults(){return new a({layer:this.layer})}get delete(){const{defaults:e,layerInfo:t}=this,r=e.delete,a=!1!==t?.enabled&&!1!==t?.deleteEnabled;return{enabled:r.enabled&&a,reliesOnOwnerAdminPrivileges:r.reliesOnOwnerAdminPrivileges}}get formTemplate(){const{layer:e,layerInfo:t}=this;return t?.formTemplate?t.formTemplate:e&&"formTemplate"in e?e.formTemplate:null}get relationship(){const{layer:e}=this,t=!(!n(e)||!e.relationships?.length),r=!!this.formTemplate?.elements?.some((e=>"relationship"===e.type));return{enabled:t&&r}}get update(){const{attachments:e,defaults:t,layerInfo:r}=this,a=t.update,n=!1!==r?.enabled&&!1!==r?.updateEnabled,l=a.enabled&&n,s=l&&a.attributes&&!1!==r?.attributeUpdatesEnabled,o=l&&a.geometry&&!1!==r?.geometryUpdatesEnabled,i=e.enabled&&!1!==r?.attachmentsOnUpdateEnabled;return{attributes:s,enabled:l,geometry:o,attachments:{enabled:i,create:i&&a.attachments.create,update:i&&a.attachments.update},reliesOnOwnerAdminPrivileges:a.reliesOnOwnerAdminPrivileges}}};e([t()],l.prototype,"attachments",null),e([t()],l.prototype,"create",null),e([t()],l.prototype,"defaults",null),e([t()],l.prototype,"delete",null),e([t()],l.prototype,"formTemplate",null),e([t()],l.prototype,"layerInfo",void 0),e([t()],l.prototype,"relationship",null),e([t()],l.prototype,"update",null),l=e([r("esri.widgets.Editor.support.EditorEditingCapabilities")],l);const s=l;export{s as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}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 a from"../../../layers/support/EditingCapabilities.js";import{isGeometryEditableSceneLayer as l}from"../../../views/layers/support/editableLayerViews.js";import{isRelatableFeatureSupportedLayer as n}from"../../Feature/support/featureUtils.js";let s=class extends a{constructor(e){super(e),this.layerInfo=null,this.layerView=null}get attachments(){const e=this.defaults.attachments.enabled,t=this.layerInfo;return{enabled:e&&!1!==t?.allowAttachments&&!1!==t?.enabled}}get create(){const{attachments:e,defaults:t,layerInfo:r,layer:a,layerView:l}=this,n=t.create,s=!1!==r?.enabled&&!1!==r?.addEnabled,i=n.enabled&&s;return{attributes:i&&n.attributes,enabled:i,geometry:i&&n.geometry&&o(a,l),attachments:{enabled:e.enabled&&i&&!1!==r?.attachmentsOnCreateEnabled},reliesOnOwnerAdminPrivileges:n.reliesOnOwnerAdminPrivileges}}get defaults(){return new a({layer:this.layer})}get delete(){const{defaults:e,layerInfo:t}=this,r=e.delete,a=!1!==t?.enabled&&!1!==t?.deleteEnabled;return{enabled:r.enabled&&a,reliesOnOwnerAdminPrivileges:r.reliesOnOwnerAdminPrivileges}}get formTemplate(){const{layer:e,layerInfo:t}=this;return t?.formTemplate?t.formTemplate:e&&"formTemplate"in e?e.formTemplate:null}get relationship(){const{layer:e}=this,t=!(!n(e)||!e.relationships?.length),r=!!this.formTemplate?.elements?.some((e=>"relationship"===e.type));return{enabled:t&&r}}get update(){const{attachments:e,defaults:t,layerInfo:r,layer:a,layerView:l}=this,n=t.update,s=!1!==r?.enabled&&!1!==r?.updateEnabled,i=n.enabled&&s,p=i&&n.attributes&&!1!==r?.attributeUpdatesEnabled,d=i&&n.geometry&&!1!==r?.geometryUpdatesEnabled&&o(a,l),m=e.enabled&&!1!==r?.attachmentsOnUpdateEnabled;return{attributes:p,enabled:i,geometry:d,attachments:{enabled:m,create:m&&n.attachments.create,update:m&&n.attachments.update},reliesOnOwnerAdminPrivileges:n.reliesOnOwnerAdminPrivileges}}};function o(e,t){return"scene"!==e.type||null!=t&&"type"in t&&"scene-layer-3d"===t.type&&l(e,t)}e([t()],s.prototype,"attachments",null),e([t()],s.prototype,"create",null),e([t()],s.prototype,"defaults",null),e([t()],s.prototype,"delete",null),e([t()],s.prototype,"formTemplate",null),e([t()],s.prototype,"layerInfo",void 0),e([t()],s.prototype,"layerView",void 0),e([t()],s.prototype,"relationship",null),e([t()],s.prototype,"update",null),s=e([r("esri.widgets.Editor.support.EditorEditingCapabilities")],s);const i=s;export{i as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as r}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{isTable as o}from"../../../layers/support/layerUtils.js";import l from"./EditorEditingCapabilities.js";import{formTemplateHasInvalidFields as a}from"../../FeatureForm/featureFormUtils.js";let i=class extends t{constructor(e){super(e),this.disabled=!1,this.layer=null,this.layerInfo=null,this.layerView=null}get _suspended(){return!!this.layerView?.suspended}get capabilities(){return new l({layer:this.layer,layerInfo:this.layerInfo})}get editable(){const{create:e,relationship:t,update:r,delete:{enabled:s}}=this.capabilities,o=e.attachments.enabled||r.attachments.enabled;return!this.disabled&&(e.enabled||r.enabled||o||s||t.enabled)}get formTemplate(){return this.capabilities.formTemplate}get hasInvalidFormTemplate(){return a(this.layer,this.formTemplate)}get isTable(){return o(this.layer)}get supportsCreateFeaturesWorkflow(){return!this.disabled&&this.capabilities.create.enabled}get supportsUpdateWorkflow(){const{capabilities:e}=this;return!this.disabled&&(e.update.enabled||e.update.attachments.enabled||e.delete.enabled)}get visible(){const{layer:e}=this,t=e.parent;return!this._suspended&&e.visible&&(!t||!("visible"in t)||t.visible)}};e([r()],i.prototype,"_suspended",null),e([r()],i.prototype,"capabilities",null),e([r()],i.prototype,"disabled",void 0),e([r()],i.prototype,"editable",null),e([r()],i.prototype,"formTemplate",null),e([r()],i.prototype,"hasInvalidFormTemplate",null),e([r()],i.prototype,"isTable",null),e([r()],i.prototype,"layer",void 0),e([r()],i.prototype,"layerInfo",void 0),e([r()],i.prototype,"layerView",void 0),e([r()],i.prototype,"supportsCreateFeaturesWorkflow",null),e([r()],i.prototype,"supportsUpdateWorkflow",null),e([r()],i.prototype,"visible",null),i=e([s("esri.widgets.editor.support.EditorItem")],i);const p=i;export{p as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as r}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{isTable as o}from"../../../layers/support/layerUtils.js";import i from"./EditorEditingCapabilities.js";import{formTemplateHasInvalidFields as l}from"../../FeatureForm/featureFormUtils.js";let a=class extends t{constructor(e){super(e),this.disabled=!1,this.layer=null,this.layerInfo=null,this.layerView=null}get _suspended(){return!!this.layerView?.suspended}get capabilities(){return new i({layer:this.layer,layerInfo:this.layerInfo,layerView:this.layerView})}get editable(){const{create:e,relationship:t,update:r,delete:{enabled:s}}=this.capabilities,o=e.attachments.enabled||r.attachments.enabled;return!this.disabled&&(e.enabled||r.enabled||o||s||t.enabled)}get formTemplate(){return this.capabilities.formTemplate}get hasInvalidFormTemplate(){return l(this.layer,this.formTemplate)}get isTable(){return o(this.layer)}get supportsCreateFeaturesWorkflow(){if(this.disabled)return!1;const{enabled:e,geometry:t}=this.capabilities.create;return this.isTable?e:e&&t}get supportsUpdateWorkflow(){const{capabilities:e}=this;return!this.disabled&&(e.update.enabled||e.update.attachments.enabled||e.delete.enabled)}get visible(){const{layer:e}=this,t=e.parent;return!this._suspended&&e.visible&&(!t||!("visible"in t)||t.visible)}};e([r()],a.prototype,"_suspended",null),e([r()],a.prototype,"capabilities",null),e([r()],a.prototype,"disabled",void 0),e([r()],a.prototype,"editable",null),e([r()],a.prototype,"formTemplate",null),e([r()],a.prototype,"hasInvalidFormTemplate",null),e([r()],a.prototype,"isTable",null),e([r()],a.prototype,"layer",void 0),e([r()],a.prototype,"layerInfo",void 0),e([r()],a.prototype,"layerView",void 0),e([r()],a.prototype,"supportsCreateFeaturesWorkflow",null),e([r()],a.prototype,"supportsUpdateWorkflow",null),e([r()],a.prototype,"visible",null),a=e([s("esri.widgets.editor.support.EditorItem")],a);const p=a;export{p 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{lerp as e}from"../../../core/mathUtils.js";import{throwIfAborted as t}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as n}from"../../../core/unitUtils.js";import{distance as r,lerp as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{k as o}from"../../../chunks/vec32.js";import a from"../../../geometry/Polyline.js";import{initializeProjection as i,project as c}from"../../../geometry/projection.js";import u from"../../../geometry/SpatialReference.js";import{geodesicLengths as l,isSupported as f,inverseGeodeticSolver as h,directGeodeticSolver as p}from"../../../geometry/support/geodesicUtils.js";import{getElevationOffset as m}from"../../../support/elevationInfoUtils.js";import{ProfileGenerationError as d,ProfileGenerationErrorCause as g}from"./ProfileGenerationError.js";async function w(e,r,s,o,a,f,h){let p,m,w;const j=e.spatialReference,v=j.isGeographic||j.isWebMercator;let P=0;if(!v){const{planarLength:n}=await import("../../../geometry/geometryEngineAsync.js");t(h),P=await n(e,"meters"),t(h)}const Z=1/n(o),x=a.geodesicDistanceThreshold??1/0;if(v||P>=x){await i([{source:j,dest:o},{source:j,dest:u.WGS84}],h);const t=W(e);p=l([t],"meters")[0];const n=y(p,a);if(D(e,p,n)>f)throw new d(g.TooComplex);const v=R(t,r,s);({densifiedPath:m,distances:w}=b(v,n,Z)),m=c(m,o)}else{await i([{source:j,dest:o}],h),p=P;const n=y(p,a);if(D(e,p,n)>f)throw new d(g.TooComplex);const u=R(e,r,s);({densifiedPath:m,distances:w}=S(u,n,Z)),t(h),m=c(m,o)}return{densifiedPath:m,pathLength:p*Z,distances:w}}function y(e,t){const n=e/t.densificationMaxSamples;return Math.max(t.samplingDistance,n)}function R(e,t,n){if(null==t)return P(e);const r=e.spatialReference,s=t.mode,o=m(t,r);let i=null;switch(n.type){case"2d":i=j(e,s,o);break;case"3d":i=v(e,s,o,n)}return null==i?P(e):new a({hasZ:!0,hasM:!1,spatialReference:r,paths:Z(e.paths,i)})}function j({hasZ:e},t,n){return"absolute-height"===t?e?([e,t,r])=>[e,t,r+n]:([e,t])=>[e,t,n]:null}function v({spatialReference:e,hasZ:t},n,r,{elevationProvider:s}){const o=(t,n,r,o)=>s?.getElevation(t,n,r,e,o)??0;switch(n){case"on-the-ground":return([e,t])=>[e,t,o(e,t,0,"ground")];case"absolute-height":return t?([e,t,n])=>[e,t,n+r]:([e,t])=>[e,t,r];case"relative-to-ground":return t?([e,t,n])=>[e,t,n+o(e,t,n,"ground")+r]:([e,t])=>[e,t,o(e,t,0,"ground")+r];case"relative-to-scene":return t?([e,t,n])=>[e,t,n+o(e,t,n,"scene")+r]:([e,t])=>[e,t,o(e,t,0,"scene")+r];default:return null}}function P(e){return e.hasZ?new a({hasZ:!1,hasM:!1,spatialReference:e.spatialReference,paths:Z(e.paths,(([e,t])=>[e,t]))}):e}function Z(e,t){const n=e.length,r=new Array(n);for(let s=0;s<n;++s){const n=e[s],o=n.length,a=new Array(n.length);r[s]=a;for(let e=0;e<o;++e)a[e]=t(n[e])}return r}function x(e){return M(e)&&e.paths.length>0&&e.paths.every((e=>e.length>=2))}function M(e){return null!=e&&"polyline"===e.type}function A(e,t,r,s,o){const{spatialReference:i,hasZ:c}=e,u={from:null,to:null,distance:0,azimuth:0,reverseAzimuth:0,spatialReference:i,metersPerSR:n(i)},l=[],f=[];let h=0;for(let n=0;n<e.paths.length;++n){const a=e.paths[n],i=new Array,c=new Array;let p=0;for(let e=1;e<a.length;++e){const n=a[e-1],l=a[e],f=s(u,n,l);let m;for(m=p;m<f.distance;m+=t)i.push(o(f,m)),c.push((h+m)*r);p=m-f.distance,h+=f.distance,i.push(l),c.push(h*r)}l[n]=i,f[n]=c}return{densifiedPath:new a({spatialReference:i,hasZ:c,paths:l}),distances:f}}function S(e,t,n){const{hasZ:r}=e;return A(e,t,n,z,r?T:E)}function b(e,t,n){const{hasZ:r}=e;return A(e,t,n,U,r?k:G)}function U(e,t,n){return e.distance=0,h(e,t,n,e.spatialReference),e.from=t,e.to=n,e}function z(e,t,n){return e.from=t,e.to=n,e.distance=r(n,t)*e.metersPerSR,e}function G({from:e,azimuth:t,spatialReference:n},r){return p([0,0],e,t,r,n)}function k({from:t,to:n,azimuth:r,distance:s,spatialReference:o},a){const i=a/s,c=[0,0,e(t[2],n[2],i)];return p(c,t,r,a,o),c}function E({from:e,to:t,distance:n},r){return s([0,0],e,t,r/n)}function T({from:e,to:t,distance:n},r){return o([0,0,0],e,t,r/n)}function W(e){return f(e.spatialReference)?e:c(e,u.WGS84)}function C(e){return e.paths.reduce(((e,t)=>e+t.length),0)}function D(e,t,n){return C(e)+Math.floor(t/n)+Math.max(0,e.paths.reduce((e=>1+e),0)-1)}export{C as countPoints,w as densifyPath,M as isPolyline,x as isValidInputPath,R as toAbsoluteHeightElevation};
5
+ import{lerp as e}from"../../../core/mathUtils.js";import{throwIfAborted as t}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as n}from"../../../core/unitUtils.js";import{distance as r,lerp as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{m as o}from"../../../chunks/vec32.js";import a from"../../../geometry/Polyline.js";import{initializeProjection as i,project as c}from"../../../geometry/projection.js";import u from"../../../geometry/SpatialReference.js";import{geodesicLengths as l,isSupported as f,inverseGeodeticSolver as h,directGeodeticSolver as p}from"../../../geometry/support/geodesicUtils.js";import{getElevationOffset as m}from"../../../support/elevationInfoUtils.js";import{ProfileGenerationError as d,ProfileGenerationErrorCause as g}from"./ProfileGenerationError.js";async function w(e,r,s,o,a,f,h){let p,m,w;const j=e.spatialReference,v=j.isGeographic||j.isWebMercator;let P=0;if(!v){const{planarLength:n}=await import("../../../geometry/geometryEngineAsync.js");t(h),P=await n(e,"meters"),t(h)}const Z=1/n(o),x=a.geodesicDistanceThreshold??1/0;if(v||P>=x){await i([{source:j,dest:o},{source:j,dest:u.WGS84}],h);const t=k(e);p=l([t],"meters")[0];const n=y(p,a);if(D(e,p,n)>f)throw new d(g.TooComplex);const v=R(t,r,s);({densifiedPath:m,distances:w}=b(v,n,Z)),m=c(m,o)}else{await i([{source:j,dest:o}],h),p=P;const n=y(p,a);if(D(e,p,n)>f)throw new d(g.TooComplex);const u=R(e,r,s);({densifiedPath:m,distances:w}=S(u,n,Z)),t(h),m=c(m,o)}return{densifiedPath:m,pathLength:p*Z,distances:w}}function y(e,t){const n=e/t.densificationMaxSamples;return Math.max(t.samplingDistance,n)}function R(e,t,n){if(null==t)return P(e);const r=e.spatialReference,s=t.mode,o=m(t,r);let i=null;switch(n.type){case"2d":i=j(e,s,o);break;case"3d":i=v(e,s,o,n)}return null==i?P(e):new a({hasZ:!0,hasM:!1,spatialReference:r,paths:Z(e.paths,i)})}function j({hasZ:e},t,n){return"absolute-height"===t?e?([e,t,r])=>[e,t,r+n]:([e,t])=>[e,t,n]:null}function v({spatialReference:e,hasZ:t},n,r,{elevationProvider:s}){const o=(t,n,r,o)=>s?.getElevation(t,n,r,e,o)??0;switch(n){case"on-the-ground":return([e,t])=>[e,t,o(e,t,0,"ground")];case"absolute-height":return t?([e,t,n])=>[e,t,n+r]:([e,t])=>[e,t,r];case"relative-to-ground":return t?([e,t,n])=>[e,t,n+o(e,t,n,"ground")+r]:([e,t])=>[e,t,o(e,t,0,"ground")+r];case"relative-to-scene":return t?([e,t,n])=>[e,t,n+o(e,t,n,"scene")+r]:([e,t])=>[e,t,o(e,t,0,"scene")+r];default:return null}}function P(e){return e.hasZ?new a({hasZ:!1,hasM:!1,spatialReference:e.spatialReference,paths:Z(e.paths,(([e,t])=>[e,t]))}):e}function Z(e,t){const n=e.length,r=new Array(n);for(let s=0;s<n;++s){const n=e[s],o=n.length,a=new Array(n.length);r[s]=a;for(let e=0;e<o;++e)a[e]=t(n[e])}return r}function x(e){return M(e)&&e.paths.length>0&&e.paths.every((e=>e.length>=2))}function M(e){return null!=e&&"polyline"===e.type}function A(e,t,r,s,o){const{spatialReference:i,hasZ:c}=e,u={from:null,to:null,distance:0,azimuth:0,reverseAzimuth:0,spatialReference:i,metersPerSR:n(i)},l=[],f=[];let h=0;for(let n=0;n<e.paths.length;++n){const a=e.paths[n],i=new Array,c=new Array;let p=0;for(let e=1;e<a.length;++e){const n=a[e-1],l=a[e],f=s(u,n,l);let m;for(m=p;m<f.distance;m+=t)i.push(o(f,m)),c.push((h+m)*r);p=m-f.distance,h+=f.distance,i.push(l),c.push(h*r)}l[n]=i,f[n]=c}return{densifiedPath:new a({spatialReference:i,hasZ:c,paths:l}),distances:f}}function S(e,t,n){const{hasZ:r}=e;return A(e,t,n,z,r?W:T)}function b(e,t,n){const{hasZ:r}=e;return A(e,t,n,U,r?E:G)}function U(e,t,n){return e.distance=0,h(e,t,n,e.spatialReference),e.from=t,e.to=n,e}function z(e,t,n){return e.from=t,e.to=n,e.distance=r(n,t)*e.metersPerSR,e}function G({from:e,azimuth:t,spatialReference:n},r){return p([0,0],e,t,r,n)}function E({from:t,to:n,azimuth:r,distance:s,spatialReference:o},a){const i=a/s,c=[0,0,e(t[2],n[2],i)];return p(c,t,r,a,o),c}function T({from:e,to:t,distance:n},r){return s([0,0],e,t,r/n)}function W({from:e,to:t,distance:n},r){return o([0,0,0],e,t,r/n)}function k(e){return f(e.spatialReference)?e:c(e,u.WGS84)}function C(e){return e.paths.reduce(((e,t)=>e+t.length),0)}function D(e,t,n){return C(e)+Math.floor(t/n)+Math.max(0,e.paths.reduce((e=>1+e),0)-1)}export{C as countPoints,w as densifyPath,M as isPolyline,x as isValidInputPath,R as toAbsoluteHeightElevation};
@@ -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{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as c}from"./FeatureForm/css.js";import{isGroupInput as p,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as b,getIconForFeature as _,isNumberFieldInput as C}from"./FeatureForm/featureFormUtils.js";import g from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as f}from"./support/componentsUtils.js";import{isString as y}from"./support/dataUtils.js";import{getLabelForDateFieldValue as F,getIntlOptionsForField as R,numberingSystem as w,prepareISOFieldValueForDateComponents as O,prepareUnixFieldValueForDateComponents as k,normalizeTimeOnlyString as x,getISOFieldValueFromDateComponents as I,getUnixFieldValueFromDateComponents as M}from"./support/dateUtils.js";import{globalCss as D}from"./support/globalCss.js";import{Heading as V,incrementHeadingLevel as N}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as L}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as j}from"./support/jsxFactory.js";import{substitute as E}from"../intl/substitute.js";const S="data-field-name";let U=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new g,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._activeCombobox=null,this._activeComboboxClosedByWorkaround=!1,this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this),this._onComboboxOpen=this._onComboboxOpen.bind(this),this._onComboboxClose=this._onComboboxClose.bind(this),this.onScroll=this.onScroll.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return f({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i(o.getLogger(this),"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(o.getLogger(this),"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return j("div",{class:this.classes(c.base,D.widget,D.panel),onscroll:this.onScroll},"ready"===e?this._renderForm():null)}_renderForm(){return j("form",{class:c.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&j(V,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&j("p",{class:c.description,key:"description"},e.formDescription);return j("div",{class:c.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>p(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:j("div",{class:this.classes(c.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),p=this.viewModel.findField(this._focusedFieldName),h=p?.group===e,v=`${this.id}_group_${t}`,b="sequential"===this.groupDisplay;return j("calcite-block",{class:this.classes(c.group,b?c.groupSequential:null,h?c.groupActive:null,i?c.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?N(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(p(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?E(this.messages.requiredFieldLabel,{name:o}):o,class:c.label,key:`${n.id}-${i.uid}-${e.name}`},r=[j("div",{class:c.labelTextContent,key:"labelTextContainer"},o,a?j("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?j("label",{...s},r):j("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n}=e,a=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),a):this._renderComboBoxComponent(e,t,a):this._renderSwitchComponent(e,a)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,a):"number"===t?this._renderNumberComponent(e,a):this._renderStringComponent(e,a)}_renderStringComponent(e,t){return"text-area"===e.inputType?t.readOnly?j("calcite-input",{...t,loading:e.updating,type:"textarea",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)}):j("calcite-text-area",{...t,resize:"vertical",onCalciteTextAreaInput:e=>this._saveValueFromComponent(e.target)}):j("calcite-input",{...t,loading:e.updating,type:"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return j("calcite-input-number",{...t,integer:l(e.field),loading:e.updating,type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,F(i,t.value,{timeZone:this.timeZone,...R(i)}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return j("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:a,"data-date-part":"date","data-field-name":t[S],key:`${s}-date-input`,max:y(l)?l:void 0,min:y(d)?d:void 0,numberingSystem:w,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=n?`${n}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:a,readOnly:s}=t;return j("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[S],key:`${a}-time-input`,numberingSystem:w,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:s,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,timeZone:n,valid:a,value:s}=e,{class:r,key:l,readOnly:d}=t,{rawMax:p,rawMin:u}=o,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!a,numberingSystem:w,overlayPositioning:"fixed",readOnly:d,[S]:i,onfocus:this._onComponentFocus},h=O(p,n),v=O(u,n),b=O(s,n);return j("div",{class:c.dateInputContainer,key:`${l}-date-time-container`},j("calcite-input-date-picker",{...m,class:r,"data-date-part":"date",key:`${l}-date-input`,max:h?.date??void 0,min:v?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:b.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),j("calcite-input-time-picker",{...m,class:r,"data-date-part":"time",key:`${l}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:b.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?j("calcite-input-time-zone",{...m,class:r,"data-date-part":"timeZone",disabled:d,key:`${l}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:b.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,key:r,max:l,min:d,readOnly:p}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:w,overlayPositioning:"fixed",readOnly:p,[S]:o,onfocus:this._onComponentFocus},h=k(a,u),v=k(l,u),b=k(d,u);return j("div",{class:c.dateInputContainer,key:`${r}-date-time-container`},j("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${r}-date-input`,max:v?.date??void 0,min:b?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?j("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:h.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return j("calcite-input",{...i,class:this.classes(c.fieldInput,c.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>j("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[c,p]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&p.unshift(j("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=p.length>0?[j("calcite-combobox-item-group",{key:"recommended",label:a.recommended},c),j("calcite-combobox-item-group",{key:"other",label:s.other},p)]:c,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);e.showNoValueOptionEnabled&&u.unshift(j("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:e.showNoValueLabel||a.empty,value:""}));const b=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return j("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:b,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxBeforeOpen:this._onComboboxOpen,onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)},onCalciteComboboxClose:this._onComboboxClose},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return j("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:c.inputRadioGroup,"data-field-name":i[S],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return j("calcite-switch",{...t,checked:o,class:c.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return j("calcite-label",{class:c.inputRadioLabel,key:e,layout:"inline"},j("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:c.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?b(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?j("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return j("calcite-list-item",{description:E(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},j("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return j("calcite-button",{alignment:"center",appearance:"outline-fill",class:c.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>{!e.updating&&e.originHasValidKey&&this._onAddRelatedRecordsClick(i,o)},round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,c=r?()=>r.remove(i):void 0;return j("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:c,value:n},j("calcite-icon",{icon:_(i),scale:"m",slot:"content-start"}),j("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return j("calcite-label",{class:this.classes(c.label,c.relatedRecordsLabel),key:`relationship-${i}-container`},j("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return j("div",{class:c.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},j("span",null,e.label),t?j("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return j("calcite-list",{class:c.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=E(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return j("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},j("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return j("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},j("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return j("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:c.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:p,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(c.fieldInput,v?c.inputDisabled:null,h&&!u?c.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:p,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[S]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(S))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);C(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const{timeZone:t}=this,i=this._getFieldInputFromHTMLElement(e),o=i.field.type,{name:n,range:a}=i,s=this._dateComponentMap.get(n);if(!s)return;let r=this.viewModel.getValue(n),l=null;"date-only"===o?l=e.value:"time-only"===o?(r=x(r),l=x(e.value)):l="timestamp-offset"===o?null!=e.value?I({dateComponent:s.date,timeComponent:s.time,timeZoneComponent:s.timeZone,oldValue:r,defaultTimeZone:t}):null:null!=e.value?M({oldValue:r,dateComponent:s.date,timeComponent:s.time,timeZone:t,max:a.max,min:a.min}):null,null!==l&&e.value?r!==l&&this._updateFieldValue(n,l):this._updateFieldValue(n,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:o.getLogger(this).warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}_onComboboxClose(e){this._activeComboboxClosedByWorkaround||this._activeCombobox!==e.target||(this._activeCombobox=null)}_onComboboxOpen(e){this._activeComboboxClosedByWorkaround=!1,this._activeCombobox=e.target}onScroll(e){if(this._activeCombobox){const t=this._activeCombobox.getBoundingClientRect(),i=e.target.getBoundingClientRect();t.bottom>i.bottom?(this._activeComboboxClosedByWorkaround=!0,this._activeCombobox.open=!1):(this._activeComboboxClosedByWorkaround&&(this._activeCombobox.open=!0,this._activeComboboxClosedByWorkaround=!1),this._activeCombobox.reposition())}}};e([s()],U.prototype,"_listObserverNode",void 0),e([s()],U.prototype,"_relatedRecordsEnabled",null),e([s()],U.prototype,"disabled",null),e([s()],U.prototype,"feature",null),e([s()],U.prototype,"formTemplate",null),e([s()],U.prototype,"groupDisplay",void 0),e([s()],U.prototype,"headingLevel",void 0),e([s()],U.prototype,"label",null),e([s()],U.prototype,"layer",null),e([s()],U.prototype,"map",null),e([s(),L("esri/widgets/FeatureForm/t9n/FeatureForm")],U.prototype,"messages",void 0),e([s(),L("esri/t9n/common")],U.prototype,"messagesCommon",void 0),e([s(),L("esri/widgets/Feature/t9n/Feature")],U.prototype,"messagesFeature",void 0),e([s(),L("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],U.prototype,"messagesTemplates",void 0),e([s()],U.prototype,"relatedRecordCallbacks",null),e([s()],U.prototype,"relationshipId",null),e([s()],U.prototype,"spatialReference",null),e([s()],U.prototype,"strict",null),e([s()],U.prototype,"timeZone",null),e([s()],U.prototype,"view",null),e([s(),T(["value-change","submit"])],U.prototype,"viewModel",void 0),U=e([r("esri.widgets.FeatureForm")],U);const $=U;export{$ as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as c}from"./FeatureForm/css.js";import{isGroupInput as p,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as b,getIconForFeature as _,isNumberFieldInput as C}from"./FeatureForm/featureFormUtils.js";import g from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as f}from"./support/componentsUtils.js";import{isString as y}from"./support/dataUtils.js";import{getLabelForDateFieldValue as F,getIntlOptionsForField as R,numberingSystem as w,prepareISOFieldValueForDateComponents as O,prepareUnixFieldValueForDateComponents as k,normalizeTimeOnlyString as x,getISOFieldValueFromDateComponents as I,getUnixFieldValueFromDateComponents as M}from"./support/dateUtils.js";import{globalCss as D}from"./support/globalCss.js";import{Heading as V,incrementHeadingLevel as N}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as L}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as j}from"./support/jsxFactory.js";import{substitute as E}from"../intl/substitute.js";const S="data-field-name";let U=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new g,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._activeCombobox=null,this._activeComboboxClosedByWorkaround=!1,this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this),this._onComboboxOpen=this._onComboboxOpen.bind(this),this._onComboboxClose=this._onComboboxClose.bind(this),this.onScroll=this.onScroll.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{this._inputsWithChanges.clear(),this._dateComponentMap.clear(),a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return f({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i(o.getLogger(this),"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(o.getLogger(this),"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return j("div",{class:this.classes(c.base,D.widget,D.panel),onscroll:this.onScroll},"ready"===e?this._renderForm():null)}_renderForm(){return j("form",{class:c.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&j(V,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&j("p",{class:c.description,key:"description"},e.formDescription);return j("div",{class:c.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>p(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:j("div",{class:this.classes(c.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),p=this.viewModel.findField(this._focusedFieldName),h=p?.group===e,v=`${this.id}_group_${t}`,b="sequential"===this.groupDisplay;return j("calcite-block",{class:this.classes(c.group,b?c.groupSequential:null,h?c.groupActive:null,i?c.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?N(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(p(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?E(this.messages.requiredFieldLabel,{name:o}):o,class:c.label,key:`${n.id}-${i.uid}-${e.name}`},r=[j("div",{class:c.labelTextContent,key:"labelTextContainer"},o,a?j("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?j("label",{...s},r):j("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n}=e,a=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),a):this._renderComboBoxComponent(e,t,a):this._renderSwitchComponent(e,a)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,a):"number"===t?this._renderNumberComponent(e,a):this._renderStringComponent(e,a)}_renderStringComponent(e,t){return"text-area"===e.inputType?t.readOnly?j("calcite-input",{...t,loading:e.updating,type:"textarea",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)}):j("calcite-text-area",{...t,resize:"vertical",onCalciteTextAreaInput:e=>this._saveValueFromComponent(e.target)}):j("calcite-input",{...t,loading:e.updating,type:"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return j("calcite-input-number",{...t,integer:l(e.field),loading:e.updating,type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,F(i,t.value,{timeZone:this.timeZone,...R(i)}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return j("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:a,"data-date-part":"date","data-field-name":t[S],key:`${s}-date-input`,max:y(l)?l:void 0,min:y(d)?d:void 0,numberingSystem:w,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=n?`${n}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:a,readOnly:s}=t;return j("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[S],key:`${a}-time-input`,numberingSystem:w,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:s,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,timeZone:n,valid:a,value:s}=e,{class:r,key:l,readOnly:d}=t,{rawMax:p,rawMin:u}=o,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!a,numberingSystem:w,overlayPositioning:"fixed",readOnly:d,[S]:i,onfocus:this._onComponentFocus},h=O(p,n),v=O(u,n),b=O(s,n);return j("div",{class:c.dateInputContainer,key:`${l}-date-time-container`},j("calcite-input-date-picker",{...m,class:r,"data-date-part":"date",key:`${l}-date-input`,max:h?.date??void 0,min:v?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:b.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),j("calcite-input-time-picker",{...m,class:r,"data-date-part":"time",key:`${l}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:b.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?j("calcite-input-time-zone",{...m,class:r,"data-date-part":"timeZone",disabled:d,key:`${l}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:b.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,key:r,max:l,min:d,readOnly:p}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:w,overlayPositioning:"fixed",readOnly:p,[S]:o,onfocus:this._onComponentFocus},h=k(a,u),v=k(l,u),b=k(d,u);return j("div",{class:c.dateInputContainer,key:`${r}-date-time-container`},j("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${r}-date-input`,max:v?.date??void 0,min:b?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?j("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:h.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return j("calcite-input",{...i,class:this.classes(c.fieldInput,c.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>j("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[c,p]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&p.unshift(j("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=p.length>0?[j("calcite-combobox-item-group",{key:"recommended",label:a.recommended},c),j("calcite-combobox-item-group",{key:"other",label:s.other},p)]:c,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);e.showNoValueOptionEnabled&&u.unshift(j("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:e.showNoValueLabel||a.empty,value:""}));const b=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return j("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:b,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxBeforeOpen:this._onComboboxOpen,onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)},onCalciteComboboxClose:this._onComboboxClose},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return j("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:c.inputRadioGroup,"data-field-name":i[S],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return j("calcite-switch",{...t,checked:o,class:c.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return j("calcite-label",{class:c.inputRadioLabel,key:e,layout:"inline"},j("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:c.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?b(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?j("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return j("calcite-list-item",{description:E(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},j("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return j("calcite-button",{alignment:"center",appearance:"outline-fill",class:c.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>{!e.updating&&e.originHasValidKey&&this._onAddRelatedRecordsClick(i,o)},round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,c=r?()=>r.remove(i):void 0;return j("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:c,value:n},j("calcite-icon",{icon:_(i),scale:"m",slot:"content-start"}),j("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return j("calcite-label",{class:this.classes(c.label,c.relatedRecordsLabel),key:`relationship-${i}-container`},j("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return j("div",{class:c.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},j("span",null,e.label),t?j("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return j("calcite-list",{class:c.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=E(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return j("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},j("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return j("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},j("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return j("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:c.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:p,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(c.fieldInput,v?c.inputDisabled:null,h&&!u?c.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:p,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[S]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(S))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);C(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const{timeZone:t}=this,i=this._getFieldInputFromHTMLElement(e),o=i.field.type,{name:n,range:a}=i,s=this._dateComponentMap.get(n);if(!s)return;let r=this.viewModel.getValue(n),l=null;"date-only"===o?l=e.value:"time-only"===o?(r=x(r),l=x(e.value)):l="timestamp-offset"===o?null!=e.value?I({dateComponent:s.date,timeComponent:s.time,timeZoneComponent:s.timeZone,oldValue:r,defaultTimeZone:t}):null:null!=e.value?M({oldValue:r,dateComponent:s.date,timeComponent:s.time,timeZone:t,max:a.max,min:a.min}):null,null!==l&&e.value?r!==l&&this._updateFieldValue(n,l):this._updateFieldValue(n,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:o.getLogger(this).warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}_onComboboxClose(e){this._activeComboboxClosedByWorkaround||this._activeCombobox!==e.target||(this._activeCombobox=null)}_onComboboxOpen(e){this._activeComboboxClosedByWorkaround=!1,this._activeCombobox=e.target}onScroll(e){if(this._activeCombobox){const t=this._activeCombobox.getBoundingClientRect(),i=e.target.getBoundingClientRect();t.bottom>i.bottom?(this._activeComboboxClosedByWorkaround=!0,this._activeCombobox.open=!1):(this._activeComboboxClosedByWorkaround&&(this._activeCombobox.open=!0,this._activeComboboxClosedByWorkaround=!1),this._activeCombobox.reposition())}}};e([s()],U.prototype,"_listObserverNode",void 0),e([s()],U.prototype,"_relatedRecordsEnabled",null),e([s()],U.prototype,"disabled",null),e([s()],U.prototype,"feature",null),e([s()],U.prototype,"formTemplate",null),e([s()],U.prototype,"groupDisplay",void 0),e([s()],U.prototype,"headingLevel",void 0),e([s()],U.prototype,"label",null),e([s()],U.prototype,"layer",null),e([s()],U.prototype,"map",null),e([s(),L("esri/widgets/FeatureForm/t9n/FeatureForm")],U.prototype,"messages",void 0),e([s(),L("esri/t9n/common")],U.prototype,"messagesCommon",void 0),e([s(),L("esri/widgets/Feature/t9n/Feature")],U.prototype,"messagesFeature",void 0),e([s(),L("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],U.prototype,"messagesTemplates",void 0),e([s()],U.prototype,"relatedRecordCallbacks",null),e([s()],U.prototype,"relationshipId",null),e([s()],U.prototype,"spatialReference",null),e([s()],U.prototype,"strict",null),e([s()],U.prototype,"timeZone",null),e([s()],U.prototype,"view",null),e([s(),T(["value-change","submit"])],U.prototype,"viewModel",void 0),U=e([r("esri.widgets.FeatureForm")],U);const $=U;export{$ 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"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Handles.js";import{debounce as r,ignoreAbortErrors as o}from"../../core/promiseUtils.js";import{on as l,watch as n}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as d}from"../../layers/support/fieldUtils.js";import{getTimeZoneFormattingOptions as m,system as g}from"../../time/timeZoneUtils.js";import{highlightsSupported as c}from"../../views/support/layerViewUtils.js";import p from"./AttachmentsColumn.js";import u from"./FieldColumn.js";import y from"./Grid/Column.js";import f from"./Grid/Grid.js";import b from"./Grid/GridViewModel.js";import _ from"./Grid/GroupColumn.js";import w from"./support/FeatureStore.js";import"../support/widgetUtils.js";import{messageBundle as v}from"../support/decorators/messageBundle.js";import{onLocaleChange as I}from"../../intl/locale.js";import{convertDateFormatToIntlOptions as F}from"../../intl/date.js";import{fetchMessageBundle as E}from"../../intl/messages.js";let C=class extends b{constructor(e){super(e),this._debounceRefresh=r((()=>this._refresh())),this._highlights=new s,this.activeFilters=new i,this.attachmentsEnabled=!1,this.autoRefreshEnabled=!0,this.cellClassNameGenerator=(e,t)=>e.path||"",this.columns=new i,this.dataProvider=async(e,t)=>{const{store:i}=this,s=this._sortOrdersToLayerOrderByFields(e.sortOrders);t&&(i?(i.set({orderByFields:s}),"loaded"!==i.state&&"loading"!==i.state&&await i.load(),t&&t(await i.fetchItems(e))):t&&t([]))},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.layer=null,this.messagesCommon=null,this.messagesURIUtils=null,this.relatedRecordsEnabled=!1,this.returnGeometryEnabled=!1,this.store=null,this.tableTemplate=null,this.timeZone=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new w),this._set("grid",new f({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await E("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await E("esri/t9n/common"),this.messagesURIUtils=await E("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([I((()=>{e(),this._generateColumns()})),l((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>{this.highlightIds.forEach((e=>this._highlight(e)))},onListenerRemove:()=>{this.highlightIds.forEach((e=>this._removeHighlight(e)))}}),n((()=>this.attachmentsEnabled),(e=>{this.store.attachmentsEnabled=e,this.layer?.loaded&&this._generateColumns()})),n((()=>this.layerView),(e=>{this._highlights.removeAll(),e&&this.highlightEnabled&&this.highlightIds?.forEach((e=>this._highlight(e)))})),n((()=>this.highlightEnabled),(e=>{this._highlights.removeAll(),e&&this.highlightIds?.forEach((e=>this._highlight(e)))})),n((()=>this.relatedRecordsEnabled),(e=>this.store.relatedRecordsEnabled=e)),n((()=>this.returnGeometryEnabled),(e=>this.store.returnGeometry=e)),n((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await i.reset()),this._drainColumns(),e&&(this.store.layer=e,e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),n((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),n((()=>this.store.state),(e=>{"loaded"===e&&this.grid?.scrollToTop()})),n((()=>[this.messages,this.tableTemplate]),(()=>this.layer?.loaded&&this._generateColumns())),n((()=>[this.timeZone,this.view?.timeZone]),(()=>{this.columns.forEach((e=>{if("field"in e&&e.field){const{timeZone:t,timeZoneName:i}=this._getTimeZoneInfoForFieldColumn(e.field);e.set({timeZone:t,timeZoneName:i})}})),this.grid?.onColumnChange()})),n((()=>this.editingEnabled),(e=>{this.columns.forEach((t=>{"editingEnabled"in t&&(t.editingEnabled=e)})),this.grid?.onColumnChange()})),n((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),n((()=>this.layer&&"timeExtent"in this.layer&&this.layer.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),l((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e)))])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return d(this.layer)}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}set filterGeometry(e){if(!this.filterGeometry&&!e)return;const t=this.activeFilters.find((e=>"geometry"===e.type));t&&this.activeFilters.remove(t),this._set("filterGeometry",e),this.store.filterGeometry=e,e&&this.activeFilters.add({type:"geometry",geometry:e})}get hiddenFields(){return this._get("hiddenFields")??new i}set hiddenFields(e){Array.isArray(e)?this._set("hiddenFields",new i(e)):this._set("hiddenFields",e)}get highlightOnRowSelectEnabled(){return this.highlightEnabled}set highlightOnRowSelectEnabled(e){this.highlightEnabled=e}get layerView(){return this.view?.allLayerViews.find((e=>e.layer===this.layer))||null}set messages(e){this.grid?.set("messages",e),this._set("messages",e)}get state(){const{store:e}=this;return e&&"disabled"!==e.state?"loading"===e.state?"loading":"loaded"===e.state?"loaded":"ready":"disabled"}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}clearSelection(){this.grid?.clearSelection()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.deselectRows(i),await this.refresh())}deselectRows(e){const t=this._getStoreItemsFromSelectionParams(e);this.grid?.deselectRows(t)}filterBySelection(){const e=this.highlightIds.toArray();e.length&&(this.clearSelectionFilter(),this.store.objectIds=e,this.activeFilters.add({type:"selection",objectIds:e}))}getObjectIdIndex(e){return this.store?.getObjectIdIndex(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}get highlightIds(){return this._get("highlightIds")||new i}set highlightIds(e){Array.isArray(e)?this._set("highlightIds",new i(e)):this._set("highlightIds",e)}async refresh(){return o(this._debounceRefresh())}reset(){this.grid?.reset()}selectRows(e){const t=this._getStoreItemsFromSelectionParams(e);return this.grid?.selectRows(t)}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){this.store.objectIds=null;const e=this.activeFilters.find((e=>"selection"===e.type));e&&this.activeFilters.remove(e)}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const r=await e.queryFeatures(s);try{await t.goTo(r.features)}catch(o){"AbortError"!==o.name&&console.error(o)}}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.deselectRows(e[i])}))}this.grid?.refreshPageCache()}_onLayerLoad(){const e=this.layer.capabilities?.query.maxRecordCount;e&&e<this.pageSize&&this.grid&&(this.grid.pageSize=e),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const e=[],t=this.tableTemplate?.columnTemplates?this._generateColumnsFromTemplates(this.tableTemplate.columnTemplates):this._generateDefaultFieldColumns();e.push(...t),e.length&&this.attachmentsEnabled&&e.push(this._generateAttachmentsColumn()),this.columns.addMany([...e])}_generateColumnsFromTemplates(e){const{editingEnabled:t,grid:i,layer:s,messages:r,messagesCommon:o,messagesURIUtils:l,store:n,tableTemplate:a}=this,h=s?.fields??[],d=e=>{const t="fieldName"in e&&e.fieldName?.toLowerCase();return h.find((e=>t===e.name?.toLowerCase()))};return e.map((e=>({template:e,field:d(e)}))).filter((({template:e,field:t})=>null!=t||"group"===e.type&&"columnTemplates"in e||"column"===e.type)).map((({template:e,field:h})=>{if("fieldName"in e){const d=!1===e.visible||!0!==e.visible&&this._isFieldHidden(h?.name),{direction:m,formatFunction:g,initialSortPriority:c,invalid:p,menuConfig:y,sortable:f,textAlign:b}=e,_=a?.expressionInfos||null,{timeZone:w,timeZoneName:v}=this._getTimeZoneInfoForFieldColumn(h);return new u({sortable:!1!==f,direction:m,editingEnabled:t,expressionInfos:_,field:h,formatFunction:g,grid:i,hidden:d,initialSortPriority:c,invalid:p,layer:s,messages:r,messagesCommon:o,messagesURIUtils:l,menuConfig:y,store:n,template:e,textAlign:b,timeZone:w,timeZoneName:v})}if("group"===e.type&&"columnTemplates"in e){const t=this._generateColumnsFromTemplates(e.columnTemplates),i=!1===e.visible||!0!==e.visible&&this._isFieldHidden(e.label),{label:s}=e;return new _({header:s,columns:t,hidden:i})}return new y({...e,timeZone:this.timeZone})}))}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:r,messagesURIUtils:o,store:l}=this;return(this.layer?.fields??[]).map((n=>{const{timeZone:a,timeZoneName:h}=this._getTimeZoneInfoForFieldColumn(n);return new u({editingEnabled:e,field:n,grid:t,hidden:this._isFieldHidden(n.name),layer:i,store:l,messages:s,messagesCommon:r,messagesURIUtils:o,timeZone:a,timeZoneName:h})}))}_getTimeZoneInfoForFieldColumn(e){const{timeZone:t,view:i}=this;return!e||"date"!==e?.type&&"timestamp-offset"!==e?.type?{timeZone:void 0,timeZoneName:void 0}:m("preferredTimeZone"in this.layer?this.layer.preferredTimeZone:null,"datesInUnknownTimezone"in this.layer&&this.layer.datesInUnknownTimezone,t??i?.timeZone??g,F("short-time"),e.type)}_generateAttachmentsColumn(){return new p({header:this.messages?.attachments??"Attachments"})}_sortOrdersToLayerOrderByFields(e){return e?.length?e.filter(((e,t,i)=>i.map((e=>e.path)).indexOf(e.path)===t)).filter((({direction:e})=>!!e)).map((({direction:e,path:t})=>t+" "+e?.toUpperCase())):[]}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_highlight(e){this.layerView&&c(this.layerView)&&this._highlights.add(this.layerView.highlight(e),e)}_removeHighlight(e){this._highlights.remove(e)}_getStoreItemsFromSelectionParams(e){const i=[];return this.layer?((e=e instanceof Array?e:[e]).forEach((e=>{let s=e instanceof t?e:null;const r=s?s.getObjectId():e;if("number"==typeof r||"string"==typeof r){if(!s){const e=this.store.getItemByObjectId(r);e&&(s=e.feature)}i.push({objectId:r,feature:s})}})),i):[]}_onHighlightIdsChange(e){const{highlightEnabled:t}=this,{added:i,removed:s}=e;t&&(i.forEach((e=>this._highlight(e))),s.forEach((e=>this._removeHighlight(e)))),this.emit("selection-change",{added:i,removed:s})}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}};e([a()],C.prototype,"_defaultHiddenFields",null),e([a({readOnly:!0})],C.prototype,"activeFilters",void 0),e([a({readOnly:!0})],C.prototype,"activeSortOrders",null),e([a()],C.prototype,"attachmentsEnabled",void 0),e([a()],C.prototype,"autoRefreshEnabled",void 0),e([a()],C.prototype,"cellClassNameGenerator",void 0),e([a({readOnly:!0})],C.prototype,"columns",void 0),e([a()],C.prototype,"dataProvider",void 0),e([a()],C.prototype,"editingEnabled",void 0),e([a()],C.prototype,"filterGeometry",null),e([a({readOnly:!0})],C.prototype,"grid",void 0),e([a()],C.prototype,"hiddenFields",null),e([a()],C.prototype,"highlightEnabled",void 0),e([a()],C.prototype,"highlightOnRowSelectEnabled",null),e([a({readOnly:!0})],C.prototype,"itemIdPath",void 0),e([a()],C.prototype,"layer",void 0),e([a()],C.prototype,"layerView",null),e([a()],C.prototype,"messages",null),e([a(),v("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([a(),v("esri/widgets/support/t9n/uriUtils")],C.prototype,"messagesURIUtils",void 0),e([a()],C.prototype,"relatedRecordsEnabled",void 0),e([a()],C.prototype,"returnGeometryEnabled",void 0),e([a({readOnly:!0})],C.prototype,"state",null),e([a({readOnly:!0,type:w})],C.prototype,"store",void 0),e([a()],C.prototype,"tableTemplate",void 0),e([a()],C.prototype,"timeExtent",null),e([a()],C.prototype,"timeZone",void 0),e([a()],C.prototype,"view",void 0),e([a()],C.prototype,"highlightIds",null),C=e([h("esri.widgets.FeatureTable.FeatureTableViewModel")],C);const j=C;export{j as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Handles.js";import{debounce as r,ignoreAbortErrors as o}from"../../core/promiseUtils.js";import{on as l,watch as n}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as d}from"../../layers/support/fieldUtils.js";import{getTimeZoneFormattingOptions as m,system as g}from"../../time/timeZoneUtils.js";import{highlightsSupported as c}from"../../views/support/layerViewUtils.js";import p from"./AttachmentsColumn.js";import u from"./FieldColumn.js";import y from"./Grid/Column.js";import f from"./Grid/Grid.js";import b from"./Grid/GridViewModel.js";import _ from"./Grid/GroupColumn.js";import w from"./support/FeatureStore.js";import"../support/widgetUtils.js";import{messageBundle as v}from"../support/decorators/messageBundle.js";import{onLocaleChange as I}from"../../intl/locale.js";import{convertDateFormatToIntlOptions as E}from"../../intl/date.js";import{fetchMessageBundle as F}from"../../intl/messages.js";let C=class extends b{constructor(e){super(e),this._debounceRefresh=r((()=>this._refresh())),this._highlights=new s,this.activeFilters=new i,this.attachmentsEnabled=!1,this.autoRefreshEnabled=!0,this.cellClassNameGenerator=(e,t)=>e.path||"",this.columns=new i,this.dataProvider=async(e,t)=>{const{store:i}=this,s=this._sortOrdersToLayerOrderByFields(e.sortOrders);t&&(i?(i.set({orderByFields:s}),"loaded"!==i.state&&"loading"!==i.state&&await i.load(),t&&t(await i.fetchItems(e))):t&&t([]))},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.layer=null,this.messagesCommon=null,this.messagesURIUtils=null,this.relatedRecordsEnabled=!1,this.returnGeometryEnabled=!1,this.store=null,this.tableTemplate=null,this.timeZone=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new w),this._set("grid",new f({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await F("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await F("esri/t9n/common"),this.messagesURIUtils=await F("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([I((()=>{e(),this._generateColumns()})),l((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>{this.highlightIds.forEach((e=>this._highlight(e)))},onListenerRemove:()=>{this.highlightIds.forEach((e=>this._removeHighlight(e)))}}),n((()=>this.attachmentsEnabled),(e=>{this.store.attachmentsEnabled=e,this.layer?.loaded&&this._generateColumns()})),n((()=>this.layerView),(e=>{this._highlights.removeAll(),e&&this.highlightEnabled&&this.highlightIds?.forEach((e=>this._highlight(e)))})),n((()=>this.highlightEnabled),(e=>{this._highlights.removeAll(),e&&this.highlightIds?.forEach((e=>this._highlight(e)))})),n((()=>this.relatedRecordsEnabled),(e=>this.store.relatedRecordsEnabled=e)),n((()=>this.returnGeometryEnabled),(e=>this.store.returnGeometry=e)),n((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await i.reset()),this._drainColumns(),e&&(this.store.layer=e,e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),n((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),n((()=>this.store.state),(e=>{"loaded"===e&&this.grid?.scrollToTop()})),n((()=>[this.messages,this.tableTemplate]),(()=>this.layer?.loaded&&this._generateColumns())),n((()=>[this.timeZone,this.view?.timeZone]),(()=>{this.columns.forEach((e=>{if("field"in e&&e.field){const{timeZone:t,timeZoneName:i}=this._getTimeZoneInfoForFieldColumn(e.field);e.set({timeZone:t,timeZoneName:i})}})),this.grid?.onColumnChange()})),n((()=>this.editingEnabled),(e=>{this.columns.forEach((t=>{"editingEnabled"in t&&(t.editingEnabled=e)})),this.grid?.onColumnChange()})),n((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),n((()=>this.layer&&"timeExtent"in this.layer&&this.layer.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),l((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e)))])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return d(this.layer)}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}set filterGeometry(e){if(!this.filterGeometry&&!e)return;const t=this.activeFilters.find((e=>"geometry"===e.type));t&&this.activeFilters.remove(t),this._set("filterGeometry",e),this.store.filterGeometry=e,e&&this.activeFilters.add({type:"geometry",geometry:e})}get hiddenFields(){return this._get("hiddenFields")??new i}set hiddenFields(e){Array.isArray(e)?this._set("hiddenFields",new i(e)):this._set("hiddenFields",e)}get highlightOnRowSelectEnabled(){return this.highlightEnabled}set highlightOnRowSelectEnabled(e){this.highlightEnabled=e}get layerView(){return this.view?.allLayerViews.find((e=>e.layer===this.layer))||null}set messages(e){this.grid?.set("messages",e),this._set("messages",e)}get state(){const{store:e}=this;return e&&"disabled"!==e.state?"loading"===e.state?"loading":"loaded"===e.state?"loaded":"ready":"disabled"}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}clearSelection(){this.grid?.clearSelection()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.deselectRows(i),await this.refresh())}deselectRows(e){const t=this._getStoreItemsFromSelectionParams(e);this.grid?.deselectRows(t)}filterBySelection(){const e=this.highlightIds.toArray();e.length&&(this.clearSelectionFilter(),this.store.objectIds=e,this.activeFilters.add({type:"selection",objectIds:e}))}getObjectIdIndex(e){return this.store?.getObjectIdIndex(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}get highlightIds(){return this._get("highlightIds")||new i}set highlightIds(e){Array.isArray(e)?this._set("highlightIds",new i(e)):this._set("highlightIds",e)}async refresh(){return o(this._debounceRefresh())}reset(){this.grid?.reset()}selectRows(e){const t=this._getStoreItemsFromSelectionParams(e);return this.grid?.selectRows(t)}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){this.store.objectIds=null;const e=this.activeFilters.find((e=>"selection"===e.type));e&&this.activeFilters.remove(e)}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const r=await e.queryFeatures(s);try{await t.goTo(r.features)}catch(o){"AbortError"!==o.name&&console.error(o)}}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.deselectRows(e[i])}))}this.grid?.refreshPageCache()}_onLayerLoad(){const e=this.layer.capabilities?.query.maxRecordCount;e&&e<this.pageSize&&this.grid&&(this.grid.pageSize=e),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const e=[],t=this.tableTemplate?.columnTemplates?this._generateColumnsFromTemplates(this.tableTemplate.columnTemplates):this._generateDefaultFieldColumns();e.push(...t),e.length&&this.attachmentsEnabled&&e.push(this._generateAttachmentsColumn()),this.columns.addMany([...e])}_generateColumnsFromTemplates(e){const{editingEnabled:t,grid:i,layer:s,messages:r,messagesCommon:o,messagesURIUtils:l,store:n,tableTemplate:a}=this,h=s?.fields??[],d=e=>{const t="fieldName"in e&&e.fieldName?.toLowerCase();return h.find((e=>t===e.name?.toLowerCase()))};return e.map((e=>({template:e,field:d(e)}))).filter((({template:e,field:t})=>null!=t||"group"===e.type&&"columnTemplates"in e||"column"===e.type)).map((({template:e,field:h})=>{if("fieldName"in e){const d=!1===e.visible||!0!==e.visible&&this._isFieldHidden(h?.name),{direction:m,formatFunction:g,frozen:c,frozenToEnd:p,initialSortPriority:y,invalid:f,menuConfig:b,sortable:_,textAlign:w}=e,v=a?.expressionInfos||null,{timeZone:I,timeZoneName:E}=this._getTimeZoneInfoForFieldColumn(h);return new u({sortable:!1!==_,direction:m,editingEnabled:t,expressionInfos:v,field:h,formatFunction:g,frozen:c,frozenToEnd:p,grid:i,hidden:d,initialSortPriority:y,invalid:f,layer:s,messages:r,messagesCommon:o,messagesURIUtils:l,menuConfig:b,store:n,template:e,textAlign:w,timeZone:I,timeZoneName:E})}if("group"===e.type&&"columnTemplates"in e){const t=this._generateColumnsFromTemplates(e.columnTemplates),i=!1===e.visible||!0!==e.visible&&this._isFieldHidden(e.label),{label:s}=e;return new _({header:s,columns:t,hidden:i})}return new y({...e,timeZone:this.timeZone})}))}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:r,messagesURIUtils:o,store:l}=this;return(this.layer?.fields??[]).map((n=>{const{timeZone:a,timeZoneName:h}=this._getTimeZoneInfoForFieldColumn(n);return new u({editingEnabled:e,field:n,grid:t,hidden:this._isFieldHidden(n.name),layer:i,store:l,messages:s,messagesCommon:r,messagesURIUtils:o,timeZone:a,timeZoneName:h})}))}_getTimeZoneInfoForFieldColumn(e){const{timeZone:t,view:i}=this;return!e||"date"!==e?.type&&"timestamp-offset"!==e?.type?{timeZone:void 0,timeZoneName:void 0}:m("preferredTimeZone"in this.layer?this.layer.preferredTimeZone:null,"datesInUnknownTimezone"in this.layer&&this.layer.datesInUnknownTimezone,t??i?.timeZone??g,E("short-time"),e.type)}_generateAttachmentsColumn(){return new p({header:this.messages?.attachments??"Attachments"})}_sortOrdersToLayerOrderByFields(e){return e?.length?e.filter(((e,t,i)=>i.map((e=>e.path)).indexOf(e.path)===t)).filter((({direction:e})=>!!e)).map((({direction:e,path:t})=>t+" "+e?.toUpperCase())):[]}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_highlight(e){this.layerView&&c(this.layerView)&&this._highlights.add(this.layerView.highlight(e),e)}_removeHighlight(e){this._highlights.remove(e)}_getStoreItemsFromSelectionParams(e){const i=[];return this.layer?((e=e instanceof Array?e:[e]).forEach((e=>{let s=e instanceof t?e:null;const r=s?s.getObjectId():e;if("number"==typeof r||"string"==typeof r){if(!s){const e=this.store.getItemByObjectId(r);e&&(s=e.feature)}i.push({objectId:r,feature:s})}})),i):[]}_onHighlightIdsChange(e){const{highlightEnabled:t}=this,{added:i,removed:s}=e;t&&(i.forEach((e=>this._highlight(e))),s.forEach((e=>this._removeHighlight(e)))),this.emit("selection-change",{added:i,removed:s})}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}};e([a()],C.prototype,"_defaultHiddenFields",null),e([a({readOnly:!0})],C.prototype,"activeFilters",void 0),e([a({readOnly:!0})],C.prototype,"activeSortOrders",null),e([a()],C.prototype,"attachmentsEnabled",void 0),e([a()],C.prototype,"autoRefreshEnabled",void 0),e([a()],C.prototype,"cellClassNameGenerator",void 0),e([a({readOnly:!0})],C.prototype,"columns",void 0),e([a()],C.prototype,"dataProvider",void 0),e([a()],C.prototype,"editingEnabled",void 0),e([a()],C.prototype,"filterGeometry",null),e([a({readOnly:!0})],C.prototype,"grid",void 0),e([a()],C.prototype,"hiddenFields",null),e([a()],C.prototype,"highlightEnabled",void 0),e([a()],C.prototype,"highlightOnRowSelectEnabled",null),e([a({readOnly:!0})],C.prototype,"itemIdPath",void 0),e([a()],C.prototype,"layer",void 0),e([a()],C.prototype,"layerView",null),e([a()],C.prototype,"messages",null),e([a(),v("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([a(),v("esri/widgets/support/t9n/uriUtils")],C.prototype,"messagesURIUtils",void 0),e([a()],C.prototype,"relatedRecordsEnabled",void 0),e([a()],C.prototype,"returnGeometryEnabled",void 0),e([a({readOnly:!0})],C.prototype,"state",null),e([a({readOnly:!0,type:w})],C.prototype,"store",void 0),e([a()],C.prototype,"tableTemplate",void 0),e([a()],C.prototype,"timeExtent",null),e([a()],C.prototype,"timeZone",void 0),e([a()],C.prototype,"view",void 0),e([a()],C.prototype,"highlightIds",null),C=e([h("esri.widgets.FeatureTable.FeatureTableViewModel")],C);const j=C;export{j as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.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 m}from"../../support/decorators/messageBundle.js";import{tsx as u}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._columnElements=[],this._grid=null,this.itemIdPath=null,this.messages=null,this.viewModel=new h,this.visibleElements={...g}}initialize(){this.addHandles([this.columns.on("before-changes",(()=>this.renderNow())),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.destroyed||this.columns.destroy()}resetColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}get _activeEditInfos(){return this._editorColumns.map((e=>e.activeEditInfo)).filter(t)}get _editorColumns(){return this.columns.filter((e=>"activeEditInfo"in e)).toArray()}get cellClassNameGenerator(){return this.viewModel.cellClassNameGenerator}set cellClassNameGenerator(e){this.viewModel.cellClassNameGenerator=e}get cellPartNameGenerator(){return this.viewModel.cellPartNameGenerator}set cellPartNameGenerator(e){this.viewModel.cellPartNameGenerator=e}get columns(){return this.viewModel.columns}set columns(e){this.viewModel.columns=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=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 isEditingActive(){return!!this._activeEditInfos.length}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,invalid:h,path:c,resizable:m,textAlign:u,width:g}=e,p=`${r}_${d}_${t??c}`,{renderFunction:_,footerRenderFunction:v,headerRenderFunction:f}=e,C=v?(e,t)=>v({root:e,column:t}):void 0,w=f?(e,t)=>f({root:e,column:t}):void 0,y=_?(e,t,r)=>_({root:e,column:t,rowData:r}):void 0;return{footerRenderer:C,headerRenderer:w,renderer:y,autoWidth:i,direction:o,flexGrow:s,frozen:n,frozenToEnd:l,header:d,hidden:a,key:p,path:c,resizable:m,bind:this,headerPartName:h?"invalid":void 0,"text-align":u,width:"number"==typeof g?`${g}px`:g,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()}generateCellPartNames(){this._grid?.generateCellPartNames()}getRowContainingNode(e){return this._grid?._getRowContainingNode(e)}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)}onColumnChange(){this._columnElements.forEach((e=>{this._applyRenderersToColumnElement(e)})),this._grid?.requestContentUpdate()}render(){const{columnMenus:e}=this.visibleElements;return u("div",{bind:this,class:this.classes(v.base,c.widget,{[v.noColumnMenu]:!e})},u("div",{bind:this,class:v.content},this._renderGrid()))}_renderGrid(){const e=this.highlightIds.map((e=>this.store?.getLocalItemByKey(e)||{objectId:e})).toArray(),t=this.columnPerformanceModeEnabled?"lazy":"eager";return u("vaadin-grid",{afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellClassNameGenerator:this.cellClassNameGenerator,cellPartNameGenerator:this.cellPartNameGenerator,class:v.grid,columnRendering:t,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 u("vaadin-grid-selection-column",{_selectAllHidden:!0,bind:this,dragSelect:!0,frozen:!0,hidden:!this.visibleElements.selectionColumn,selectAll:!1,sortable:!1,textAlign:"center"})}_renderColumns(){return Array.from(this.columns,((e,t)=>"columns"in e?this._renderGroupColumn(e,t):u("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?u("vaadin-grid-column-group",{...r},i.map((e=>u("vaadin-grid-column",{...this.getColumnProps(e,t)})))):null}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",_),customElements.whenDefined("vaadin-grid").then((()=>{this._appendStyles(),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}))}}}_appendStyles(){const e=this._grid?.shadowRoot,t=document.createElement("style");e&&(t.textContent='\n #items [part~="row"][editing], \n #items [part~="row"][editing][selected] { \n z-index: 2; \n }\n\n #items [part~="editing"],\n #items [part~="editing"][selected] {\n z-index: 3;\n }\n ',e.appendChild(t))}_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())}_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,"_activeEditInfos",null),e([n()],f.prototype,"_columnElements",void 0),e([n()],f.prototype,"_editorColumns",null),e([n()],f.prototype,"_grid",void 0),e([n()],f.prototype,"cellClassNameGenerator",null),e([n()],f.prototype,"cellPartNameGenerator",null),e([n()],f.prototype,"columns",null),e([n()],f.prototype,"columnPerformanceModeEnabled",null),e([n()],f.prototype,"columnReorderingEnabled",null),e([n()],f.prototype,"dataProvider",null),e([n()],f.prototype,"highlightIds",null),e([n()],f.prototype,"isEditingActive",null),e([n()],f.prototype,"itemIdPath",void 0),e([n()],f.prototype,"label",null),e([n(),m("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 n}from"../../../core/reactiveUtils.js";import{property as s}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 m}from"../../support/decorators/messageBundle.js";import{tsx as u}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._columnElements=[],this._grid=null,this.itemIdPath=null,this.messages=null,this.viewModel=new h,this.visibleElements={...g}}initialize(){this.addHandles([this.columns.on("before-changes",(()=>this.renderNow())),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()})),n((()=>this._grid?.$?.table),"scroll",(()=>this.viewModel?.closeColumnMenus()))])}destroy(){this.resetColumns(),this.columns.destroyed||this.columns.destroy()}resetColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}get _activeEditInfos(){return this._editorColumns.map((e=>e.activeEditInfo)).filter(t)}get _editorColumns(){return this.columns.filter((e=>"activeEditInfo"in e)).toArray()}get cellClassNameGenerator(){return this.viewModel.cellClassNameGenerator}set cellClassNameGenerator(e){this.viewModel.cellClassNameGenerator=e}get cellPartNameGenerator(){return this.viewModel.cellPartNameGenerator}set cellPartNameGenerator(e){this.viewModel.cellPartNameGenerator=e}get columns(){return this.viewModel.columns}set columns(e){this.viewModel.columns=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=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 isEditingActive(){return!!this._activeEditInfos.length}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:n,frozen:s,frozenToEnd:l,header:d,hidden:a,invalid:h,path:c,resizable:m,textAlign:u,width:g}=e,p=`${r}_${d}_${t??c}`,{renderFunction:_,footerRenderFunction:v,headerRenderFunction:f}=e,C=v?(e,t)=>v({root:e,column:t}):void 0,w=f?(e,t)=>f({root:e,column:t}):void 0,y=_?(e,t,r)=>_({root:e,column:t,rowData:r}):void 0;return{footerRenderer:C,headerRenderer:w,renderer:y,autoWidth:i,direction:o,flexGrow:n,frozen:s,frozenToEnd:l,header:d,hidden:a,key:p,path:c,resizable:m,bind:this,headerPartName:h?"invalid":void 0,"text-align":u,width:"number"==typeof g?`${g}px`:g,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()}generateCellPartNames(){this._grid?.generateCellPartNames()}getRowContainingNode(e){return this._grid?._getRowContainingNode(e)}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)}onColumnChange(){this._columnElements.forEach((e=>{this._applyRenderersToColumnElement(e)})),this._grid?.requestContentUpdate()}render(){const{columnMenus:e}=this.visibleElements;return u("div",{bind:this,class:this.classes(v.base,c.widget,{[v.noColumnMenu]:!e})},u("div",{bind:this,class:v.content},this._renderGrid()))}_renderGrid(){const e=this.highlightIds.map((e=>this.store?.getLocalItemByKey(e)||{objectId:e})).toArray(),t=this.columnPerformanceModeEnabled?"lazy":"eager";return u("vaadin-grid",{afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellClassNameGenerator:this.cellClassNameGenerator,cellPartNameGenerator:this.cellPartNameGenerator,class:v.grid,columnRendering:t,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 u("vaadin-grid-selection-column",{_selectAllHidden:!0,bind:this,dragSelect:!0,frozen:!0,hidden:!this.visibleElements.selectionColumn,selectAll:!1,sortable:!1,textAlign:"center"})}_renderColumns(){return Array.from(this.columns,((e,t)=>"columns"in e?this._renderGroupColumn(e,t):u("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?u("vaadin-grid-column-group",{...r},i.map((e=>u("vaadin-grid-column",{...this.getColumnProps(e,t)})))):null}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",_),customElements.whenDefined("vaadin-grid").then((()=>{this._appendStyles(),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}))}}}_appendStyles(){const e=this._grid?.shadowRoot,t=document.createElement("style");e&&(t.textContent='\n #items [part~="row"][editing], \n #items [part~="row"][editing][selected] { \n z-index: 2; \n }\n\n #items [part~="editing"],\n #items [part~="editing"][selected] {\n z-index: 3;\n }\n\n [frozen], [frozen-to-end] {\n z-index: 4;\n }\n ',e.appendChild(t))}_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())}_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:n}=r;o&&n&&"details"!==n&&"header"!==n&&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([s()],f.prototype,"_activeEditInfos",null),e([s()],f.prototype,"_columnElements",void 0),e([s()],f.prototype,"_editorColumns",null),e([s()],f.prototype,"_grid",void 0),e([s()],f.prototype,"cellClassNameGenerator",null),e([s()],f.prototype,"cellPartNameGenerator",null),e([s()],f.prototype,"columns",null),e([s()],f.prototype,"columnPerformanceModeEnabled",null),e([s()],f.prototype,"columnReorderingEnabled",null),e([s()],f.prototype,"dataProvider",null),e([s()],f.prototype,"highlightIds",null),e([s()],f.prototype,"isEditingActive",null),e([s()],f.prototype,"itemIdPath",void 0),e([s()],f.prototype,"label",null),e([s(),m("esri/widgets/FeatureTable/t9n/FeatureTable")],f.prototype,"messages",void 0),e([s()],f.prototype,"multiSortEnabled",null),e([s()],f.prototype,"pageSize",null),e([s()],f.prototype,"rowDetailsRenderer",null),e([s()],f.prototype,"size",null),e([s({readOnly:!0})],f.prototype,"sortOrders",null),e([s()],f.prototype,"store",null),e([s()],f.prototype,"viewModel",void 0),e([s()],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 o}from"../../../chunks/tslib.es6.js";import{JSONSupport as t}from"../../../core/JSONSupport.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";let e=class extends t{constructor(o){super(o),this.description=null,this.direction=null,this.formatFunction=null,this.initialSortPriority=null,this.invalid=!1,this.label=null,this.menuConfig=null,this.sortable=!0,this.textAlign="start",this.type=null,this.visible=!0}};o([i()],e.prototype,"description",void 0),o([i()],e.prototype,"direction",void 0),o([i()],e.prototype,"formatFunction",void 0),o([i()],e.prototype,"initialSortPriority",void 0),o([i()],e.prototype,"invalid",void 0),o([i()],e.prototype,"label",void 0),o([i()],e.prototype,"menuConfig",void 0),o([i()],e.prototype,"sortable",void 0),o([i()],e.prototype,"textAlign",void 0),o([i({type:String,json:{read:!1,write:!0}})],e.prototype,"type",void 0),o([i()],e.prototype,"visible",void 0),e=o([r("esri.widgets.FeatureTable.support.ColumnTemplateBase")],e);const s=e;export{s as default};
5
+ import{_ as o}from"../../../chunks/tslib.es6.js";import{JSONSupport as t}from"../../../core/JSONSupport.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";let e=class extends t{constructor(o){super(o),this.description=null,this.direction=null,this.formatFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.initialSortPriority=null,this.invalid=!1,this.label=null,this.menuConfig=null,this.sortable=!0,this.textAlign="start",this.type=null,this.visible=!0}};o([r()],e.prototype,"description",void 0),o([r()],e.prototype,"direction",void 0),o([r()],e.prototype,"formatFunction",void 0),o([r()],e.prototype,"frozen",void 0),o([r()],e.prototype,"frozenToEnd",void 0),o([r()],e.prototype,"initialSortPriority",void 0),o([r()],e.prototype,"invalid",void 0),o([r()],e.prototype,"label",void 0),o([r()],e.prototype,"menuConfig",void 0),o([r()],e.prototype,"sortable",void 0),o([r()],e.prototype,"textAlign",void 0),o([r({type:String,json:{read:!1,write:!0}})],e.prototype,"type",void 0),o([r()],e.prototype,"visible",void 0),e=o([i("esri.widgets.FeatureTable.support.ColumnTemplateBase")],e);const s=e;export{s 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{debounce as o,isAbortError as a}from"../../core/promiseUtils.js";import n from"../../core/ReactiveSet.js";import{watch as l,when as h,sync as u}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{initializeProjection as p,project as g}from"../../geometry/projection.js";import{getPointFromGeometry as f}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as m}from"../../geometry/support/webMercatorUtils.js";import y from"../../layers/Layer.js";import{fallbackObjectIDAttribute as w}from"../../layers/LayerConstants.js";import{getDisplayedSymbol as F}from"../../symbols/support/symbolUtils.js";import{highlightsSupported as v}from"../../views/support/layerViewUtils.js";import _ from"../Feature/FeatureViewModel.js";import{ActionsCollection as b,zoomToFeature as C,zoomToClusteredFeatures as P,browseClusteredFeatures as E}from"../Popup/actions.js";import{triggerAction as j,isClusterFeature as M,removeClusteredFeaturesForBrowsing as A,displayClusterExtent as L,browseAggregateFeatures as V,getSelectedTarget as I}from"../Popup/actionUtils.js";import S from"../support/AnchorElementViewModel.js";import{GoToMixin as O}from"../support/GoTo.js";import x from"../../symbols/SimpleFillSymbol.js";import T from"../../geometry/Point.js";const H=()=>[C.clone()],B=()=>[P.clone(),E.clone()];let R=null;function U(e,t){return"building-scene"===e||"2d"===t&&("map-image"===e||"tile"===e||"imagery"===e||"imagery-tile"===e)}let G=class extends(O(S)){constructor(e){super(e),this._pendingPromises=new n,this._fetchFeaturesController=null,this._highlightSelectedFeaturePromise=null,this._highlightActiveFeaturePromise=null,this._selectedClusterFeature=null,this._locationScaleHandle=null,this.actions=new b,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 x({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,this._debouncedLocationUpdate=o((async e=>{const{view:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if("mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const{pendingFeatures:e}=await this._fetchFeaturesWithController({mapPoint:s}),i=(await Promise.all(e)).flat().filter(Boolean);if(!i.length)return;if(i.length!==this.features.length){const e=this._getHighlightLayer(this.selectedFeature),t="imagery"===e?.type?void 0:e&&"objectIdField"in e?e.objectIdField||w:null;if(t){const s=this.selectedFeature.getObjectId(),r=i.findIndex((i=>{const r=this._getHighlightLayer(i);return r?.uid===e?.uid&&i.attributes[t]===s}));this.features=i,this.selectedFeatureIndex=r}}const r=i[this.selectedFeatureIndex]?.geometry,o=("mesh"!==r?.type?r:null)??this.selectedFeature.geometry,a=g(o,t.spatialReference);R||(R=await import("../../geometry/geometryEngineAsync.js")),a&&!await R.intersects(a,s)&&(this.location=(await R.nearestCoordinate(a,s)).coordinate??s)}catch(o){a(o)||r.getLogger(this).error(o)}else this.location=f(this.selectedFeature.geometry)??s}))}initialize(){this.addHandles([this.on("view-change",(()=>this._autoClose())),l((()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view]),(()=>this._highlightSelectedFeature())),l((()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view]),(()=>this._highlightActiveFeature())),l((()=>this.view?.animation?.state),(e=>this._animationStateChange(e))),l((()=>this.location),(e=>this._locationChange(e))),l((()=>this.selectedFeature),(e=>this._selectedFeatureChange(e))),l((()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage]),(()=>this._selectedFeatureIndexChange())),l((()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels]),(()=>this._setGraphicOnFeatureViewModels())),l((()=>this.featureViewModels),(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>j({event:e,viewModel:this,view:this.view}))),h((()=>!this.waitingForResult),(()=>this._waitingForResultChange()),u),l((()=>[this.features,this.view?.map,this.view?.spatialReference,this.view?.timeZone]),(()=>this._updateFeatureVMs())),l((()=>this.view?.scale),(()=>this._viewScaleChange())),h((()=>!this.visible),(()=>this.browseClusterEnabled=!1)),l((()=>this.browseClusterEnabled),(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this._locationScaleHandle?.remove(),this._locationScaleHandle=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new b;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,h=n?.overwriteActions?l:l?.concat(a)??a;return h?.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){const e=this._get("defaultActions")||new b;return e.removeAll(),e.addMany(M(this.selectedFeature)?B():H()),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=m(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=I(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(){A(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?M(t)?(await L(this),await V(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||(C.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(M(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),M(e))return;return e.symbol=await F(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}if(e.symbol=await F(e),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=f(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(M(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 _({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:s?.spatialReference,graphic:t===e?t:null,location:this.location,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 p(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;this._locationScaleHandle?.remove(),this._locationScaleHandle=l((()=>this.view?.scale),(()=>this._debouncedLocationUpdate(t).catch((e=>{a(e)||r.getLogger(this).error(e)}))));const{pendingFeatures:o}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});s?.popup&&"open"in s.popup&&s.popup.open({location:t??void 0,promises:o})}_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,i){if(U(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||w:null,o=e.attributes;return o&&r&&o[r]||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 y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(i,o);this._highlightActiveFeaturePromise=a;const n=await a;if(!(n&&v(n)&&this._highlightActiveFeaturePromise===a&&this.activeFeature&&this.highlightEnabled))return;const l=n.highlight(this._getHighlightTarget(s,o,i.type));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 y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(s,o);this._highlightSelectedFeaturePromise=a;const n=await a;if(!(n&&v(n)&&this._highlightSelectedFeaturePromise===a&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const l=n.highlight(this._getHighlightTarget(t,o,s.type));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([c()],G.prototype,"_fetchFeaturesController",void 0),e([c({type:b})],G.prototype,"actions",void 0),e([c({readOnly:!0})],G.prototype,"active",null),e([c()],G.prototype,"activeFeature",void 0),e([c({readOnly:!0})],G.prototype,"allActions",null),e([c()],G.prototype,"autoCloseEnabled",void 0),e([c()],G.prototype,"autoOpenEnabled",void 0),e([c()],G.prototype,"browseClusterEnabled",void 0),e([c()],G.prototype,"content",void 0),e([c({type:b,readOnly:!0})],G.prototype,"defaultActions",null),e([c({type:Boolean})],G.prototype,"defaultPopupTemplateEnabled",void 0),e([c({readOnly:!0})],G.prototype,"featureCount",null),e([c()],G.prototype,"featurePage",void 0),e([c({value:[]})],G.prototype,"features",null),e([c()],G.prototype,"featuresPerPage",void 0),e([c()],G.prototype,"featureMenuOpen",void 0),e([c()],G.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],G.prototype,"featureViewModels",void 0),e([c()],G.prototype,"highlightEnabled",void 0),e([c()],G.prototype,"includeDefaultActions",void 0),e([c({type:T})],G.prototype,"location",null),e([c({readOnly:!0})],G.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],G.prototype,"promiseCount",null),e([c()],G.prototype,"promises",null),e([c({readOnly:!0})],G.prototype,"selectedClusterBoundaryFeature",void 0),e([c({value:null,readOnly:!0})],G.prototype,"selectedFeature",null),e([c({value:-1})],G.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],G.prototype,"selectedFeatureViewModel",null),e([c({readOnly:!0})],G.prototype,"state",null),e([c()],G.prototype,"title",void 0),e([c()],G.prototype,"updateLocationEnabled",void 0),e([c()],G.prototype,"view",void 0),e([c()],G.prototype,"visible",void 0),e([c({readOnly:!0})],G.prototype,"waitingForContents",null),e([c({readOnly:!0})],G.prototype,"waitingForResult",null),e([c()],G.prototype,"zoomFactor",void 0),e([c()],G.prototype,"zoomToLocation",void 0),e([c()],G.prototype,"centerAtLocation",null),G=e([d("esri.widgets.Features.FeaturesViewModel")],G);const z=G;export{z 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{debounce as o,isAbortError as a}from"../../core/promiseUtils.js";import n from"../../core/ReactiveSet.js";import{watch as l,when as h,sync as u}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{initializeProjection as p,project as g}from"../../geometry/projection.js";import{getPointFromGeometry as f}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as m}from"../../geometry/support/webMercatorUtils.js";import y from"../../layers/Layer.js";import{fallbackObjectIDAttribute as w}from"../../layers/LayerConstants.js";import{getDisplayedSymbol as F}from"../../symbols/support/symbolUtils.js";import{highlightsSupported as v}from"../../views/support/layerViewUtils.js";import _ from"../Feature/FeatureViewModel.js";import{ActionsCollection as b,zoomToFeature as C,zoomToClusteredFeatures as P,browseClusteredFeatures as E}from"../Popup/actions.js";import{triggerAction as j,isClusterFeature as M,removeClusteredFeaturesForBrowsing as A,displayClusterExtent as L,browseAggregateFeatures as V,getSelectedTarget as I}from"../Popup/actionUtils.js";import S from"../support/AnchorElementViewModel.js";import{GoToMixin as O}from"../support/GoTo.js";import x from"../../symbols/SimpleFillSymbol.js";import T from"../../geometry/Point.js";const H=()=>[C.clone()],B=()=>[P.clone(),E.clone()];let R=null;function U(e,t){return"building-scene"===e||"2d"===t&&("map-image"===e||"tile"===e||"imagery"===e||"imagery-tile"===e)}let G=class extends(O(S)){constructor(e){super(e),this._pendingPromises=new n,this._fetchFeaturesController=null,this._highlightSelectedFeaturePromise=null,this._highlightActiveFeaturePromise=null,this._selectedClusterFeature=null,this._locationScaleHandle=null,this.actions=new b,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 x({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,this._debouncedLocationUpdate=o((async e=>{const{view:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if("mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const{pendingFeatures:e}=await this._fetchFeaturesWithController({mapPoint:s}),i=(await Promise.all(e)).flat().filter(Boolean);if(!i.length)return;if(i.length!==this.features.length){const e=this._getHighlightLayer(this.selectedFeature),t="imagery"===e?.type?void 0:e&&"objectIdField"in e?e.objectIdField||w:null;if(t){const s=this.selectedFeature.getObjectId(),r=i.findIndex((i=>{const r=this._getHighlightLayer(i);return r?.uid===e?.uid&&i.attributes[t]===s}));this.features=i,this.selectedFeatureIndex=r}}const r=i[this.selectedFeatureIndex]?.geometry,o=("mesh"!==r?.type?r:null)??this.selectedFeature.geometry,a=o?g(o,t.spatialReference):null;if(!a)return;R||(R=await import("../../geometry/geometryEngineAsync.js")),await R.intersects(a,s)||(this.location=(await R.nearestCoordinate(a,s)).coordinate??s)}catch(o){a(o)||r.getLogger(this).error(o)}else this.location=f(this.selectedFeature.geometry)??s}))}initialize(){this.addHandles([this.on("view-change",(()=>this._autoClose())),l((()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view]),(()=>this._highlightSelectedFeature())),l((()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view]),(()=>this._highlightActiveFeature())),l((()=>this.view?.animation?.state),(e=>this._animationStateChange(e))),l((()=>this.location),(e=>this._locationChange(e))),l((()=>this.selectedFeature),(e=>this._selectedFeatureChange(e))),l((()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage]),(()=>this._selectedFeatureIndexChange())),l((()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels]),(()=>this._setGraphicOnFeatureViewModels())),l((()=>this.featureViewModels),(()=>this._featureViewModelsChange())),this.on("trigger-action",(e=>j({event:e,viewModel:this,view:this.view}))),h((()=>!this.waitingForResult),(()=>this._waitingForResultChange()),u),l((()=>[this.features,this.view?.map,this.view?.spatialReference,this.view?.timeZone]),(()=>this._updateFeatureVMs())),l((()=>this.view?.scale),(()=>this._viewScaleChange())),h((()=>!this.visible),(()=>this.browseClusterEnabled=!1)),l((()=>this.browseClusterEnabled),(e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing()))])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this._locationScaleHandle?.remove(),this._locationScaleHandle=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new b;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,h=n?.overwriteActions?l:l?.concat(a)??a;return h?.filter(Boolean).forEach((t=>e.add(t))),e}get defaultActions(){const e=this._get("defaultActions")||new b;return e.removeAll(),e.addMany(M(this.selectedFeature)?B():H()),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=m(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=I(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(){A(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?M(t)?(await L(this),await V(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||(C.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(M(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),M(e))return;return e.symbol=await F(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}if(e.symbol=await F(e),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=f(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(M(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 _({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:s?.spatialReference,graphic:t===e?t:null,location:this.location,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 p(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;this._locationScaleHandle?.remove(),this._locationScaleHandle=l((()=>this.view?.scale),(()=>this._debouncedLocationUpdate(t).catch((e=>{a(e)||r.getLogger(this).error(e)}))));const{pendingFeatures:o}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});s?.popup&&"open"in s.popup&&s.popup.open({location:t??void 0,promises:o})}_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,i){if(U(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||w:null,o=e.attributes;return o&&r&&o[r]||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 y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(i,o);this._highlightActiveFeaturePromise=a;const n=await a;if(!(n&&v(n)&&this._highlightActiveFeaturePromise===a&&this.activeFeature&&this.highlightEnabled))return;const l=n.highlight(this._getHighlightTarget(s,o,i.type));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 y&&this._mapIncludesLayer(o)))return;const a=this._getLayerView(s,o);this._highlightSelectedFeaturePromise=a;const n=await a;if(!(n&&v(n)&&this._highlightSelectedFeaturePromise===a&&this.selectedFeature&&this.highlightEnabled&&this.visible))return;const l=n.highlight(this._getHighlightTarget(t,o,s.type));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([c()],G.prototype,"_fetchFeaturesController",void 0),e([c({type:b})],G.prototype,"actions",void 0),e([c({readOnly:!0})],G.prototype,"active",null),e([c()],G.prototype,"activeFeature",void 0),e([c({readOnly:!0})],G.prototype,"allActions",null),e([c()],G.prototype,"autoCloseEnabled",void 0),e([c()],G.prototype,"autoOpenEnabled",void 0),e([c()],G.prototype,"browseClusterEnabled",void 0),e([c()],G.prototype,"content",void 0),e([c({type:b,readOnly:!0})],G.prototype,"defaultActions",null),e([c({type:Boolean})],G.prototype,"defaultPopupTemplateEnabled",void 0),e([c({readOnly:!0})],G.prototype,"featureCount",null),e([c()],G.prototype,"featurePage",void 0),e([c({value:[]})],G.prototype,"features",null),e([c()],G.prototype,"featuresPerPage",void 0),e([c()],G.prototype,"featureMenuOpen",void 0),e([c()],G.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],G.prototype,"featureViewModels",void 0),e([c()],G.prototype,"highlightEnabled",void 0),e([c()],G.prototype,"includeDefaultActions",void 0),e([c({type:T})],G.prototype,"location",null),e([c({readOnly:!0})],G.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],G.prototype,"promiseCount",null),e([c()],G.prototype,"promises",null),e([c({readOnly:!0})],G.prototype,"selectedClusterBoundaryFeature",void 0),e([c({value:null,readOnly:!0})],G.prototype,"selectedFeature",null),e([c({value:-1})],G.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],G.prototype,"selectedFeatureViewModel",null),e([c({readOnly:!0})],G.prototype,"state",null),e([c()],G.prototype,"title",void 0),e([c()],G.prototype,"updateLocationEnabled",void 0),e([c()],G.prototype,"view",void 0),e([c()],G.prototype,"visible",void 0),e([c({readOnly:!0})],G.prototype,"waitingForContents",null),e([c({readOnly:!0})],G.prototype,"waitingForResult",null),e([c()],G.prototype,"zoomFactor",void 0),e([c()],G.prototype,"zoomToLocation",void 0),e([c()],G.prototype,"centerAtLocation",null),G=e([d("esri.widgets.Features.FeaturesViewModel")],G);const z=G;export{z as default};