@arcgis/core 5.2.0-next.125 → 5.2.0-next.126

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 (283) hide show
  1. package/analysis/ElevationProfile/ElevationProfileDisplayUnits.d.ts +3 -2
  2. package/analysis/VolumeMeasurement/VolumeMeasurementDisplayUnits.d.ts +1 -0
  3. package/arcgisGlobal.d.ts +1 -0
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/{fe9582bc2244667e40ab.js → 05afa8c2b5929ce0545a.js} +1 -1
  6. package/assets/esri/core/workers/chunks/0a20f84b5f004a77a9f9.js +1 -0
  7. package/assets/esri/core/workers/chunks/{cfd56e0a716baf95e17b.js → 0a2b7c691a577cb3d189.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{6cf34cfdd063a1b6fe3e.js → 0ccd4200c5a2a5de6e16.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{bdf012e591a8476db467.js → 1406a884241809b62bff.js} +1 -1
  10. package/assets/esri/core/workers/chunks/17218d714cb07b607c2f.js +1 -0
  11. package/assets/esri/core/workers/chunks/1d040aa8951fff3141d9.js +1 -0
  12. package/assets/esri/core/workers/chunks/30604a29df320d7a4c6b.js +1 -0
  13. package/assets/esri/core/workers/chunks/3ef367c9b7bf1588307d.js +1 -0
  14. package/assets/esri/core/workers/chunks/{5b9b76e180cf206a8a0c.js → 4327d2c39a660bd89da7.js} +1 -1
  15. package/assets/esri/core/workers/chunks/4678a8170d8a3ccd1a7b.js +1 -0
  16. package/assets/esri/core/workers/chunks/474d9541d387b31ad275.js +1 -0
  17. package/assets/esri/core/workers/chunks/{f05becec0952a61bc654.js → 4d18451e0ea6ca54101a.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{26bc509a031788bfa678.js → 4f464047c6f6c9486efd.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{58528ccb7f72ae76d52b.js → 540f60e31b19d85e9371.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{44857a76be2c0ac65bb9.js → 55a560fd872f7463b33d.js} +1 -1
  21. package/assets/esri/core/workers/chunks/56acda1eed3a013430e2.js +1 -0
  22. package/assets/esri/core/workers/chunks/{1f55701d23a5e5a0c70c.js → 57ab87e70ef85b9405f9.js} +122 -122
  23. package/assets/esri/core/workers/chunks/{f0901f9c7135b708434f.js → 5adf2792416b22cd602f.js} +1 -1
  24. package/assets/esri/core/workers/chunks/5fe5ef5ccf480634d159.js +1 -0
  25. package/assets/esri/core/workers/chunks/67678054342178b601cf.js +1 -0
  26. package/assets/esri/core/workers/chunks/67dcf9b873cb037b2647.js +1 -0
  27. package/assets/esri/core/workers/chunks/76548469fe1b9c3b2051.js +1 -0
  28. package/assets/esri/core/workers/chunks/7d6da4e89aa951e6523f.js +1 -0
  29. package/assets/esri/core/workers/chunks/7dd94567833386dc74de.js +1 -0
  30. package/assets/esri/core/workers/chunks/806f96ad09e882be41af.js +1 -0
  31. package/assets/esri/core/workers/chunks/{bbaaebe1774a22dba39b.js → 97602019a1ccad22a03a.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{378bdb4e5cd1ebada1f4.js → 9ca98fffd43e63d5ade3.js} +1 -1
  33. package/assets/esri/core/workers/chunks/9d6a96e4c7ccedcb0c13.js +1 -0
  34. package/assets/esri/core/workers/chunks/9ec04faad97be55309b8.js +1 -0
  35. package/assets/esri/core/workers/chunks/a08385ebf1715414c1a6.js +1 -0
  36. package/assets/esri/core/workers/chunks/{e22a013ec38989caf9de.js → a790fc6b22acf651574b.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{2f52ad525744b8793d49.js → a8258636096416c837a2.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{813dd84933b407c8fe86.js → b34305474a861aaf6ccb.js} +1 -1
  39. package/assets/esri/core/workers/chunks/c5b733c3a5b2680042a2.js +1 -0
  40. package/assets/esri/core/workers/chunks/{f0709c48daca93e759c8.js → c692e583e87af58f6d91.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{4f7e8e4ddf52b5245ea4.js → c77496c350004ee66eb2.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{0fba5c0e89b057da548d.js → cb7cb7d57c4e7f76600f.js} +1 -1
  43. package/assets/esri/core/workers/chunks/d371d9279b30548efa02.js +1 -0
  44. package/assets/esri/core/workers/chunks/d5f0fed415b5b155d57c.js +1 -0
  45. package/assets/esri/core/workers/chunks/{3f082329a544c2c1d62d.js → d5f72670634e73c0b53a.js} +1 -1
  46. package/assets/esri/core/workers/chunks/d6e914f6ed45ea59034e.js +1 -0
  47. package/assets/esri/core/workers/chunks/{5afc12671a9a1bb6c56c.js → dc52e036547612949d32.js} +1 -1
  48. package/assets/esri/core/workers/chunks/e0894a308c84d5c158b0.js +1 -0
  49. package/assets/esri/core/workers/chunks/e1ae83ff3e0225708d4d.js +1 -0
  50. package/assets/esri/core/workers/chunks/{df79c00b5ddbef7148a0.js → eaa7cb3ffa8c11706a09.js} +1 -1
  51. package/assets/esri/core/workers/chunks/eebbc86a15ae3adb5f38.js +1 -0
  52. package/assets/esri/core/workers/chunks/fdbda3d2afea25142b86.js +1 -0
  53. package/assets/esri/libs/pdfjs/pdf.worker.mjs +4 -63051
  54. package/assets/esri/widgets/Editor/t9n/messages.ar.json +1 -1
  55. package/assets/esri/widgets/Editor/t9n/messages.bg.json +1 -1
  56. package/assets/esri/widgets/Editor/t9n/messages.bs.json +1 -1
  57. package/assets/esri/widgets/Editor/t9n/messages.ca.json +1 -1
  58. package/assets/esri/widgets/Editor/t9n/messages.cs.json +1 -1
  59. package/assets/esri/widgets/Editor/t9n/messages.da.json +1 -1
  60. package/assets/esri/widgets/Editor/t9n/messages.de.json +1 -1
  61. package/assets/esri/widgets/Editor/t9n/messages.el.json +1 -1
  62. package/assets/esri/widgets/Editor/t9n/messages.es.json +1 -1
  63. package/assets/esri/widgets/Editor/t9n/messages.et.json +1 -1
  64. package/assets/esri/widgets/Editor/t9n/messages.fi.json +1 -1
  65. package/assets/esri/widgets/Editor/t9n/messages.fr.json +1 -1
  66. package/assets/esri/widgets/Editor/t9n/messages.he.json +1 -1
  67. package/assets/esri/widgets/Editor/t9n/messages.hr.json +1 -1
  68. package/assets/esri/widgets/Editor/t9n/messages.hu.json +1 -1
  69. package/assets/esri/widgets/Editor/t9n/messages.id.json +1 -1
  70. package/assets/esri/widgets/Editor/t9n/messages.it.json +1 -1
  71. package/assets/esri/widgets/Editor/t9n/messages.ja.json +1 -1
  72. package/assets/esri/widgets/Editor/t9n/messages.ko.json +1 -1
  73. package/assets/esri/widgets/Editor/t9n/messages.lt.json +1 -1
  74. package/assets/esri/widgets/Editor/t9n/messages.lv.json +1 -1
  75. package/assets/esri/widgets/Editor/t9n/messages.nl.json +1 -1
  76. package/assets/esri/widgets/Editor/t9n/messages.no.json +1 -1
  77. package/assets/esri/widgets/Editor/t9n/messages.pl.json +1 -1
  78. package/assets/esri/widgets/Editor/t9n/messages.pt-BR.json +1 -1
  79. package/assets/esri/widgets/Editor/t9n/messages.pt-PT.json +1 -1
  80. package/assets/esri/widgets/Editor/t9n/messages.ro.json +1 -1
  81. package/assets/esri/widgets/Editor/t9n/messages.ru.json +1 -1
  82. package/assets/esri/widgets/Editor/t9n/messages.sk.json +1 -1
  83. package/assets/esri/widgets/Editor/t9n/messages.sl.json +1 -1
  84. package/assets/esri/widgets/Editor/t9n/messages.sr.json +1 -1
  85. package/assets/esri/widgets/Editor/t9n/messages.sv.json +1 -1
  86. package/assets/esri/widgets/Editor/t9n/messages.th.json +1 -1
  87. package/assets/esri/widgets/Editor/t9n/messages.tr.json +1 -1
  88. package/assets/esri/widgets/Editor/t9n/messages.uk.json +1 -1
  89. package/assets/esri/widgets/Editor/t9n/messages.vi.json +1 -1
  90. package/assets/esri/widgets/Editor/t9n/messages.zh-CN.json +1 -1
  91. package/assets/esri/widgets/Editor/t9n/messages.zh-HK.json +1 -1
  92. package/assets/esri/widgets/Editor/t9n/messages.zh-TW.json +1 -1
  93. package/chunks/GlobalIllumination.glsl.js +9 -9
  94. package/chunks/GlobalIlluminationBlur.glsl.js +8 -8
  95. package/chunks/HeatmapDensity.glsl.js +5 -5
  96. package/chunks/Pattern.glsl.js +30 -30
  97. package/chunks/RibbonLine.glsl.js +19 -19
  98. package/config.js +1 -1
  99. package/core/accessorSupport/types.d.ts +5 -1
  100. package/interfaces.d.ts +3 -0
  101. package/kernel.js +1 -1
  102. package/layers/ParquetLayer.d.ts +3 -2
  103. package/layers/ParquetLayer.js +1 -1
  104. package/layers/SceneLayer.js +1 -1
  105. package/layers/geospatialPDF/GeospatialPDFFrame.js +1 -1
  106. package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +2 -2
  107. package/layers/geospatialPDF/GeospatialPDFWorkerClient.js +1 -1
  108. package/layers/geospatialPDF/LGIDictMapFrame.js +1 -1
  109. package/layers/geospatialPDF/ViewportMeasureFrame.js +1 -1
  110. package/layers/geospatialPDF/geospatialPDFParserUtils.js +2 -0
  111. package/layers/geospatialPDF/projectionToWKTUtils.js +2 -0
  112. package/layers/geospatialPDF/renderExtentUtils.js +1 -1
  113. package/layers/geospatialPDF/sharedUtils.js +1 -1
  114. package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
  115. package/layers/orientedImagery/transformations/utils.js +1 -1
  116. package/layers/raster/datasets/GeospatialPDFRaster.js +1 -1
  117. package/layers/raster/types.d.ts +6 -0
  118. package/layers/support/TimeSeriesCalculation.d.ts +32 -0
  119. package/layers/support/TimeSeriesCalculation.js +2 -0
  120. package/layers/support/TimeSeriesInfo.d.ts +19 -0
  121. package/layers/support/TimeSeriesInfo.js +1 -1
  122. package/layers/support/commonProperties.js +1 -1
  123. package/layers/support/timeSeriesUtils.d.ts +25 -1
  124. package/layers/support/timeSeriesUtils.js +1 -1
  125. package/layers/types.d.ts +1 -0
  126. package/package.json +2 -2
  127. package/popup/FeatureContentCollection.d.ts +4 -1
  128. package/popup/FeatureContentCollection.js +1 -1
  129. package/popup/types.d.ts +14 -3
  130. package/portal/schemas/definitions.js +1 -1
  131. package/portal/schemas/sceneLayerItem.js +1 -1
  132. package/renderers/support/AuthoringInfo.d.ts +8 -1
  133. package/renderers/support/AuthoringInfo.js +1 -1
  134. package/renderers/support/AuthoringInfoVisualVariable.d.ts +8 -1
  135. package/renderers/support/AuthoringInfoVisualVariable.js +1 -1
  136. package/rest/imageService/fetchRasterInfo.js +1 -1
  137. package/rest/knowledgeGraph/DataModel.js +1 -1
  138. package/smartMapping/renderers/color.d.ts +12 -0
  139. package/smartMapping/renderers/color.js +1 -1
  140. package/smartMapping/renderers/opacity.d.ts +6 -0
  141. package/smartMapping/renderers/opacity.js +1 -1
  142. package/smartMapping/renderers/size.d.ts +12 -0
  143. package/smartMapping/renderers/size.js +1 -1
  144. package/smartMapping/renderers/support/regenerateUtils.js +1 -1
  145. package/smartMapping/renderers/support/rendererUtils.js +1 -1
  146. package/smartMapping/renderers/support/timeSeriesUtils.js +1 -1
  147. package/smartMapping/renderers/type.d.ts +6 -0
  148. package/smartMapping/renderers/type.js +1 -1
  149. package/smartMapping/renderers/univariateColorSize.d.ts +6 -0
  150. package/smartMapping/renderers/univariateColorSize.js +1 -1
  151. package/support/revision.js +1 -1
  152. package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
  153. package/views/2d/analysis/AreaMeasurementAnalysisView2D.d.ts +8 -0
  154. package/views/2d/analysis/AreaMeasurementAnalysisView2D.js +1 -1
  155. package/views/2d/analysis/DistanceMeasurement/DistanceMeasurementTool.js +1 -1
  156. package/views/2d/analysis/DistanceMeasurementAnalysisView2D.d.ts +8 -0
  157. package/views/2d/analysis/DistanceMeasurementAnalysisView2D.js +1 -1
  158. package/views/2d/analysis/ElevationProfileAnalysisView2D.d.ts +3 -2
  159. package/views/3d/analysis/AreaMeasurementAnalysisView3D.js +1 -1
  160. package/views/3d/analysis/Dimension/DimensionController.js +1 -1
  161. package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
  162. package/views/3d/analysis/ElevationProfileAnalysisView3D.d.ts +3 -2
  163. package/views/3d/analysis/LineOfSight/LineOfSightEditTool.js +1 -1
  164. package/views/3d/analysis/LineOfSight/LineOfSightItemTool.js +1 -1
  165. package/views/3d/analysis/LineOfSight/lineOfSightPlacementUtils.js +1 -1
  166. package/views/3d/analysis/Viewshed/ViewshedEditTool.js +1 -1
  167. package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
  168. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementShiftTool.js +1 -1
  169. package/views/3d/analysis/VolumeMeasurementAnalysisView3D.d.ts +1 -0
  170. package/views/3d/analysis/VolumeMeasurementAnalysisView3D.js +1 -1
  171. package/views/3d/input/handlers/DragRotate.js +1 -1
  172. package/views/3d/input/handlers/PinchAndPanNavigation.js +1 -1
  173. package/views/3d/input/handlers/ground/GroundDoubleClickMove.js +1 -1
  174. package/views/3d/input/handlers/ground/GroundNavigation.js +1 -1
  175. package/views/3d/state/Constraints.js +1 -1
  176. package/views/3d/state/controllers/GroundNavigationController.js +1 -1
  177. package/views/3d/state/controllers/RotateController.js +1 -1
  178. package/views/3d/support/engineContent/line.js +1 -1
  179. package/views/3d/support/planarDistanceToGroundRatio.js +2 -0
  180. package/views/3d/terrain/OverlayManager.js +1 -1
  181. package/views/3d/terrain/OverlayRenderer.js +1 -1
  182. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +13 -13
  183. package/views/3d/webgl-engine/core/shaderLibrary/shading/MarkerSizing.glsl.js +2 -2
  184. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.glsl.js +1 -1
  185. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  186. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  187. package/views/3d/webgl-engine/lib/GaussianSplatRenderUtils.js +1 -1
  188. package/views/3d/webgl-engine/lib/GaussianSplatShadows.js +1 -1
  189. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  190. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  191. package/views/DOMContainer.js +1 -1
  192. package/views/analysis/ElevationProfile/ElevationProfileController.js +1 -1
  193. package/views/analysis/LengthDimensionResult.d.ts +4 -1
  194. package/views/draw/support/managers/TooltipManager.js +1 -1
  195. package/views/interactive/options/SnappingOptions.d.ts +4 -2
  196. package/views/interactive/options/SnappingOptions.js +1 -1
  197. package/views/interactive/options/ViewOptions.d.ts +18 -0
  198. package/views/interactive/options/bindViewToolOptions.js +2 -0
  199. package/views/interactive/snapping/SnappingManagerPool.js +1 -1
  200. package/views/interactive/snapping/allLayerSnapping.js +1 -1
  201. package/views/overlay/FocusRegionOverlayItem.js +1 -1
  202. package/views/selection/SelectionOperation.d.ts +27 -1
  203. package/views/selection/types.d.ts +8 -20
  204. package/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel.d.ts +1 -0
  205. package/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel.js +1 -1
  206. package/widgets/AreaMeasurement2D.js +1 -1
  207. package/widgets/BasemapLayerList/BasemapLayerListViewModel.d.ts +1 -0
  208. package/widgets/BasemapLayerList.d.ts +1 -0
  209. package/widgets/BatchAttributeForm/expressions/types.d.ts +1 -0
  210. package/widgets/BatchAttributeForm/types.d.ts +5 -1
  211. package/widgets/BatchAttributeForm.d.ts +1 -0
  212. package/widgets/Bookmarks/BookmarksViewModel.d.ts +1 -0
  213. package/widgets/Bookmarks.d.ts +1 -0
  214. package/widgets/CatalogLayerList/CatalogLayerListViewModel.d.ts +1 -0
  215. package/widgets/CatalogLayerList.d.ts +1 -0
  216. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DViewModel.d.ts +1 -0
  217. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DViewModel.js +1 -1
  218. package/widgets/DistanceMeasurement2D.js +1 -1
  219. package/widgets/Editor.d.ts +1 -0
  220. package/widgets/FeatureForm.d.ts +1 -0
  221. package/widgets/FeatureTable/FeatureTableViewModel.d.ts +14 -0
  222. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  223. package/widgets/FeatureTable/support/FeatureStore.d.ts +14 -0
  224. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  225. package/widgets/FeatureTable.d.ts +1 -0
  226. package/widgets/FeatureTemplates.d.ts +1 -0
  227. package/widgets/Features/FeaturesViewModel.d.ts +1 -0
  228. package/widgets/Features.d.ts +2 -1
  229. package/widgets/HistogramRangeSlider.d.ts +1 -0
  230. package/widgets/Home/HomeViewModel.d.ts +1 -0
  231. package/widgets/Home.d.ts +1 -0
  232. package/widgets/LayerList/LayerListViewModel.d.ts +1 -0
  233. package/widgets/LayerList.d.ts +1 -0
  234. package/widgets/Locate/LocateViewModel.d.ts +1 -0
  235. package/widgets/Locate.d.ts +1 -0
  236. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  237. package/widgets/OrientedImageryViewer/navigation/NavigationManagerPanoramic.js +1 -1
  238. package/widgets/OrientedImageryViewer/types.d.ts +4 -1
  239. package/widgets/OrientedImageryViewer.d.ts +4 -1
  240. package/widgets/Popup.d.ts +1 -0
  241. package/widgets/Print/PrintViewModel.d.ts +1 -0
  242. package/widgets/Print.d.ts +1 -0
  243. package/widgets/Search.d.ts +1 -0
  244. package/widgets/Sketch.d.ts +1 -0
  245. package/widgets/Slider.d.ts +4 -0
  246. package/widgets/TimeSlider.d.ts +1 -0
  247. package/widgets/Track/TrackViewModel.d.ts +1 -0
  248. package/widgets/Track.d.ts +1 -0
  249. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.d.ts +1 -0
  250. package/widgets/UtilityNetworkTrace.d.ts +1 -0
  251. package/widgets/ValuePicker/types.d.ts +1 -0
  252. package/widgets/ValuePicker.d.ts +1 -0
  253. package/widgets/smartMapping/SmartMappingSliderBase.d.ts +1 -0
  254. package/widgets/support/SelectionList/types.d.ts +2 -0
  255. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.d.ts +2 -1
  256. package/assets/esri/core/workers/chunks/0148cb611bf7c8c5fe8a.js +0 -1
  257. package/assets/esri/core/workers/chunks/0a4a5ed831a4e4d8e0fc.js +0 -1
  258. package/assets/esri/core/workers/chunks/0acc754907395e83bbc6.js +0 -1
  259. package/assets/esri/core/workers/chunks/0f8ff964461cf8e0673b.js +0 -1
  260. package/assets/esri/core/workers/chunks/1e46703cb566c25458ad.js +0 -1
  261. package/assets/esri/core/workers/chunks/25c90092def215949db9.js +0 -1
  262. package/assets/esri/core/workers/chunks/2a34760b3f0c134898ec.js +0 -1
  263. package/assets/esri/core/workers/chunks/38890ac5917942374ab8.js +0 -1
  264. package/assets/esri/core/workers/chunks/3b4ceaf21be540cb3499.js +0 -1
  265. package/assets/esri/core/workers/chunks/4c4ba466e23159991322.js +0 -1
  266. package/assets/esri/core/workers/chunks/606ac9358f508bda94f2.js +0 -1
  267. package/assets/esri/core/workers/chunks/6c4def0faaef861a09c9.js +0 -1
  268. package/assets/esri/core/workers/chunks/7285a37cd5359aa4bac5.js +0 -1
  269. package/assets/esri/core/workers/chunks/753d1ff177ecee8e2377.js +0 -1
  270. package/assets/esri/core/workers/chunks/8a8e94b5d7d153361b0b.js +0 -1
  271. package/assets/esri/core/workers/chunks/923c45ebcf45d9ce8ae0.js +0 -1
  272. package/assets/esri/core/workers/chunks/9af36ee6a0df224859bc.js +0 -1
  273. package/assets/esri/core/workers/chunks/a7ce5b958dfeb240c4a5.js +0 -1
  274. package/assets/esri/core/workers/chunks/aed479c14d93955f4798.js +0 -1
  275. package/assets/esri/core/workers/chunks/be52c319a0a81ce1ba36.js +0 -1
  276. package/assets/esri/core/workers/chunks/c0ec87800faf99cbd8bd.js +0 -1
  277. package/assets/esri/core/workers/chunks/ca5a4f62b09cc8579dc0.js +0 -1
  278. package/assets/esri/core/workers/chunks/d090baaa974e1e83fa44.js +0 -1
  279. package/assets/esri/core/workers/chunks/e9f8325a4cf89ae816cc.js +0 -1
  280. package/assets/esri/core/workers/chunks/ed7d4e8725aaa0ca4589.js +0 -1
  281. package/assets/esri/core/workers/chunks/f4572ad25712d204f258.js +0 -1
  282. package/layers/geospatialPDF/GeospatialPDFParserUtils.js +0 -2
  283. package/layers/geospatialPDF/Projection.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{onLocaleChange as t,substitute as i,fetchMessageBundle as s}from"../../intl.js";import{isSome as n}from"../../core/arrayUtils.js";import l from"../../core/Collection.js";import{referenceSetter as r}from"../../core/collectionUtils.js";import o from"../../core/Error.js";import a from"../../core/Logger.js";import{debounce as d,ignoreAbortErrors as h}from"../../core/promiseUtils.js";import{watch as m,initial as c,on as p,syncAndInitial as u}from"../../core/reactiveUtils.js";import{throttle as g}from"../../core/throttle.js";import{property as b,subclass as f}from"../../core/accessorSupport/decorators.js";import{getEffectiveFieldAlias as y}from"../../editing/fieldUtils.js";import{geometryTypes as T}from"../../geometry/support/typeUtils.js";import{getLowerCaseDefaultHiddenFields as w}from"../../layers/support/fieldUtils.js";import{getSubtypesFromLayer as C,isSubtypeGroupLayer as I}from"../../layers/support/layerUtils.js";import{createFieldInfos as v}from"../../support/popupUtils.js";import _ from"../../tables/AttributeTableTemplate.js";import{syncAttributeTableTemplateWithColumns as E}from"../../tables/support/templateUtils.js";import S from"../../time/TimeExtent.js";import{isSelectableLayerWithObjectIds as A}from"../../views/support/selectionUtils.js";import F from"./ActionColumn.js";import x from"./AttachmentsColumn.js";import j from"./FieldColumn.js";import R from"./RelationshipColumn.js";import O from"./Grid/Column.js";import P from"./Grid/Grid.js";import U from"./Grid/GridViewModel.js";import V from"./Grid/GroupColumn.js";import z from"./support/AttachmentsColumnTemplate.js";import W from"./support/AttachmentsViewOptions.js";import{isAttachmentsColumn as B,isFieldColumn as L,isRelationshipColumn as G}from"./support/columnUtils.js";import{downloadAttachmentInfo as M,exportToCSV as N}from"./support/exportUtils.js";import k from"./support/FeatureStore.js";import D from"./support/FieldColumnTemplate.js";import H from"./support/RelationshipColumnTemplate.js";import $ from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as Z,isIFeatureTableSupportedLayerWithRelationships as q,findRelatedLayerInSources as Q,findRelationship as J,uniqueColumnNames as K,hasColumnForField as X,findField as Y,isIFeatureTableSupportedLayerWithAttachments as ee,getRelationshipIdsToShow as te}from"./support/tableUtils.js";import{goTo as ie}from"../support/goToUtils.js";import{messageBundle as se}from"../support/widget.js";const ne="80px";let le=class extends U{constructor(e){super(e),this._refreshDebounced=d(()=>this._refresh()),this._syncTemplateThrottled=g(()=>this._syncAttributeTableTemplate()),this.attachmentsViewOptions=new W,this.attributeTableTemplate=null,this.autoRefreshEnabled=!0,this.columns=new l,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));try{await i.load()}catch{return}const{objectIds:n}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===n.length&&-1===n.items[0])return void t([]);if("loaded"!==s.state&&"loading"!==s.state)try{await s.load()}catch{return}const l=this.paginationEnabled?this.pageIndex:e.page;try{const i=await s.queryPage({...e,pageIndex:l});t?.(i)}catch{return}},this.grid=null,this.layers=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.messagesURIUtils=null,this.prompt=null,this.relatedTables=new l,this.relationshipColumnConfigs=null,this.showRelatedTableCallback=null,this.store=null,this.syncTemplateOnChangesEnabled=!0,this.tableController=null,this.tableParent=null,this.tableTemplate=null,this.tableTemplateOverride=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._onShowPromptCallback=this._onShowPromptCallback.bind(this),this._set("store",new k),this._set("grid",new P({viewModel:this}))}initialize(){const e=async()=>{this.messages=await s("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await s("esri/t9n/common"),this.messagesUnits=await s("esri/core/t9n/Units"),this.messagesURIUtils=await s("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([t(()=>{e(),this._generateColumns()}),m(()=>[this.messages,this.messagesCommon,this.messagesURIUtils],()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.allColumns.forEach(t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils}),this.refreshCellContent()},c),m(()=>this.attachmentsEnabled,()=>this.layer?.loaded&&this._generateColumns()),m(()=>this.layer,async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this.goToPage(0),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad().catch(()=>{}):e.load().catch(()=>{})),this.syncViewSelection&&this._syncSelection(),t&&null!=this.attachmentsViewOptions.objectId&&(this.attachmentsViewOptions.objectId=null)}),m(()=>this.layer?.loaded,e=>{e&&this._onLayerLoad().catch(()=>{})}),m(()=>this.store.state,e=>{"loaded"===e&&(this.scrollToTop(),this.refreshCellContent())}),m(()=>this._effectiveTableTemplate,()=>{this.scrollLeft(),this.layer?.loaded&&this._generateColumns()}),m(()=>this.editingEnabled,()=>this.refreshCellContent()),m(()=>this.timeZone??this.view?.timeZone,()=>this.refreshCellContent()),m(()=>[this.effectiveTimeExtent,this.effectiveWhere],()=>{"loaded"===this.store.state&&this.reset().catch(()=>{})}),p(()=>this.layer,"refresh",e=>this._onLayerRefresh(e)),p(()=>this.grid,["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder"],({index:e,item:t,native:i,path:s,type:n})=>{const l=t?.feature,r=l?.getObjectId(),o="cell-keydown"===n&&i&&i instanceof KeyboardEvent&&"Enter"===i.key;this.emit(n,{feature:l,index:e,native:i,type:n,fieldName:s??void 0,objectId:r}),(o||"cell-click"===n)&&this._onCellInteraction(r)}),m(()=>this.actionColumnConfig,e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())}),m(()=>this.relatedRecordsEnabled,()=>this.layer?.loaded&&this._generateColumns()),p(()=>this.objectIds,"change",()=>this._onObjectIdsChange(),{onListenerAdd:()=>this._onObjectIdsChange()}),m(()=>[this.paginationEnabled,this.pageIndex],()=>this.refreshPageCache()),m(()=>this.activeSortOrders,e=>{this.store.sortOrders=e,this._syncTemplateThrottled()}),m(()=>this.allVisibleColumns,()=>this._syncTemplateThrottled()),m(()=>this.pageCount,()=>{this.pageIndex>=this.pageCount&&this.goToPage(0)}),m(()=>this.state,e=>{"disabled"===e&&this.relatedTables.length&&this.drainRelatedTables()}),p(()=>this.tableParent?.highlightIds,"change",({added:e})=>{const{relationshipConfig:t}=this,i=e[0];if(null==i||!t)return;const{relatedLayer:s,relationshipId:n}=t;this.relationshipConfig={objectId:i,relatedLayer:s,relationshipId:n}}),p(()=>this.tableParent,"cell-click",async e=>{const{objectId:t}=e;this.tableController&&this.hasPendingEdits?await this.tableController.discardPendingEdits(void 0,!0).then(e=>e&&this._syncTableParentSelection(t)):this._syncTableParentSelection(t)}),m(()=>this.attachmentsViewOptions.objectId,(e,t)=>{null!=e?null==t&&this.showAttachmentsView({objectId:e}):this.hideAttachmentsView()}),m(()=>[this.layerFieldConfigurations,this.pendingEditsCount],()=>this.refreshCellContent()),p(()=>this.highlightIds,"change",e=>this._onHighlightIdsChange(e),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this.defaultSelectionManager.clear()}),m(()=>this.effectiveSelectionManager,()=>this._syncSelection(),u),p(()=>this.effectiveSelectionManager,"selection-change",()=>this._syncSelection(),u)])}destroy(){this._drainColumns(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return w(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _effectiveAttributeTableTemplate(){return this.attributeTableTemplate||this.layer?.attributeTableTemplate}get _subtypes(){return C(this.layer)}get actionColumn(){return super.actionColumn}get activeFilters(){const{filterGeometry:e,objectIds:t,filterBySelectionEnabled:i,highlightIds:s}=this,n=new l;return e&&n.push({type:"geometry",geometry:e}),i?n.push({type:"selection",objectIds:s.toArray()}):t.length&&n.push({type:"objectId",objectIds:t.toArray()}),n}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map(({path:e,direction:t})=>({fieldName:e,direction:t})).filter(e=>e.fieldName&&e.direction):[]}get allColumns(){return super.allColumns}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this.showAllRelatedTables)}get allVisibleColumns(){return super.allVisibleColumns}get attachmentsColumns(){return this.allColumns.filter(e=>B(e))}get attachmentsEnabled(){return this.store.attachmentsEnabled}set attachmentsEnabled(e){this.store.attachmentsEnabled=e}get autoSaveEnabled(){return this.store.autoSaveEnabled}set autoSaveEnabled(e){this.store.autoSaveEnabled=e}get canAddRelatedFeature(){return this.store.canAddRelatedFeature}get clearPrompt(){return()=>this.prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}get defaultSelectionManager(){return this.store.defaultSelectionManager}get definitionExpression(){return this.store.where}set definitionExpression(e){this.store.where=e}get editingEnabled(){return super.editingEnabled}set editingEnabled(e){super.editingEnabled=e}get effectiveSelectionManager(){return this.store.effectiveSelectionManager}get effectiveMultipleSelectionEnabled(){return super.effectiveMultipleSelectionEnabled}get effectiveSize(){return super.effectiveSize}get effectiveTimeExtent(){return this.store.effectiveTimeExtent}get effectiveWhere(){return this.store.effectiveWhere}get fieldColumns(){return this.allColumns.filter(e=>L(e))}get filterByViewExtent(){return this.store.filterByViewExtent}set filterByViewExtent(e){this.store.filterByViewExtent=e}get filterByLayerScaleRange(){return this.store.filterByLayerScaleRange}set filterByLayerScaleRange(e){this.store.filterByLayerScaleRange=e}get filterGeometry(){return this.store.filterGeometry}set filterGeometry(e){this.store.filterGeometry=e}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get groupColumns(){return super.groupColumns}get hasContingentValues(){return this.relatedTableHasContingentValues||this.store.hasContingentValues}get hasInvalidPendingEdits(){return this.relatedTableHasInvalidPendingEdits||this.store.hasInvalidPendingEdits}get hasPendingEdits(){return this.relatedTableHasPendingEdits||this.store.hasPendingEdits}get hiddenFields(){return this._get("hiddenFields")??new l}set hiddenFields(e){this._set("hiddenFields",r(e,this._get("hiddenFields"),l))}get highlightEnabled(){return this.store.highlightEnabled}set highlightEnabled(e){this.store.highlightEnabled=e}get highlightIds(){return super.highlightIds}set highlightIds(e){super.highlightIds=e}get initialSize(){return this.store.initialSize}set initialSize(e){this.store.initialSize=e}get isEditing(){return super.isEditing}get isQuerying(){return super.isQuerying}get isSyncing(){return super.isSyncing}get isQueryingOrSyncing(){return this.isQuerying||this.isSyncing||this.relatedTables.some(e=>!!e.isQueryingOrSyncing)}get isSyncingAttachments(){return this.store.isSyncingAttachmentEdits||this.relatedTables.some(e=>!!e.isSyncingAttachments)}get layer(){return this._get("layer")}set layer(e){this.drainRelatedTables(),this._set("layer",e)}get layerFieldConfigurations(){const e=this.layer;return Z(e)?e.fieldConfigurations:void 0}get layerView(){return this.store.layerView}get maxSize(){return super.maxSize}set maxSize(e){super.maxSize=e}get objectIds(){return super.objectIds}set objectIds(e){super.objectIds=e}get outFields(){return this.store.outFields}set outFields(e){this.store.outFields=e}get pageCount(){return super.pageCount}get pageIndex(){return super.pageIndex}set pageIndex(e){super.pageIndex=e}get pageSize(){return super.pageSize}set pageSize(e){super.pageSize=e}get paginationEnabled(){return super.paginationEnabled}set paginationEnabled(e){super.paginationEnabled=e}get pendingEditsCount(){return this.store.pendingEditsCount}get relatedRecordsEnabled(){return this.store.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relatedTableHasContingentValues(){return!!this.relatedTable?.hasContingentValues}get relatedTableHasInvalidPendingEdits(){return!!this.relatedTable?.hasInvalidPendingEdits}get relatedTableHasPendingEdits(){return!!this.relatedTable?.hasPendingEdits}get relationship(){return this.store.relationship}get relationshipColumns(){return this.allColumns.filter(e=>G(e))}get relationshipConfig(){return this.store.relationshipConfig}set relationshipConfig(e){this.highlightIds.removeAll(),this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e}get relationshipInfos(){const{layer:e,layers:t,relationships:i,tableController:s}=this,n=this.store.relationshipInfos;if(n.length||!q(e)||!i?.length)return n;const l=[],r=s?.layers||t||[];return i.forEach(t=>{const i=Q(e,r,t);i&&(i.load().catch(()=>{}),l.push({layer:e,relatedLayer:i,relationshipId:t.id}))}),l}get relationships(){return this.store.relationships}get returnGeometryEnabled(){return this.store.returnGeometry}set returnGeometryEnabled(e){this.store.returnGeometry=e}get returnMEnabled(){return this.store.returnM}set returnMEnabled(e){this.store.returnM=e}get returnZEnabled(){return this.store.returnZ}set returnZEnabled(e){this.store.returnZ=e}get rowHighlightIds(){return super.rowHighlightIds}set rowHighlightIds(e){super.rowHighlightIds=e}get selectionManager(){return this.store.selectionManager}set selectionManager(e){this.store.selectionManager=e}get selectionSource(){return"table"}set selectionSource(e){this.syncViewSelection="view"===e,this._overrideIfSome("selectionSource",e)}get showAllRelatedTables(){return this._get("showAllRelatedTables")}set showAllRelatedTables(e){const{relatedTable:t}=this;this._set("showAllRelatedTables",e),t&&(e?this._showAllRelatedTables(t):this._hideAllRelatedTables(t))}get showPrompt(){return e=>{this.prompt?.cancel?.(),this.prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get size(){return super.size}get state(){return super.state}get supportsAttachments(){return this.store.supportsAttachments}get supportsAddAttachments(){const{store:{supportsAddAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsDeleteAttachments(){return this.supportsUpdateAttachments}get supportsResizeAttachments(){return this.store.supportsResizeAttachments}get supportsUpdateAttachments(){const{store:{supportsUpdateAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get syncViewSelection(){return this.store.syncViewSelection}set syncViewSelection(e){this.store.syncViewSelection=e}get timeExtent(){return this.store.timeExtent}set timeExtent(e){this.store.timeExtent=e}get timeZone(){return this.store.timeZone}set timeZone(e){this.store.timeZone=e}get view(){return this.store.view}set view(e){this.store.view=e,this.fieldColumns.forEach(t=>t.view=e),this.refreshCellContent()}get viewTimeEnabled(){return this.store.viewTimeEnabled}set viewTimeEnabled(e){this.store.viewTimeEnabled=e}get visibleColumns(){return super.visibleColumns}async addAttachment(e,t){const{attachmentsViewOptions:i,store:s}=this,n=i.objectId===e;await s.addAttachment(e,t).catch(e=>{n&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to add attachment. ${e.error.name} ${e.error.message}`),i.error=e.error)}),n&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}addPendingEdits(e){this.store.addPendingEdits(e)}collapseRelatedTable(e,t){const{relatedLayer:i,objectId:s,relationshipId:n}=t,{objectIdField:r}=i,o=J(i,n),a=i.displayField||o?.keyField||r;e.set({highlightIds:new l([s]),multipleSelectionEnabledOverride:!1,tableTemplateOverride:this._getTableTemplateForRelatedTableView(e,a,n)});const d=e.hiddenFields;d.includes(K.action)||d.add(K.action),d.includes(K.attachments)||d.add(K.attachments),e.scrollLeft()}async deleteAttachments(e,t){const{attachmentsViewOptions:i,store:s}=this,n=i.objectId===e;await s.deleteAttachments(e,t).catch(e=>{n&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to delete attachment(s). ${e.error.name} ${e.error.message}`),i.error=e.error)}),n&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}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.highlightIds.removeMany(i),await this.refresh())}async discardPendingEdits(e){return this.relatedTable&&this.relatedTableHasPendingEdits?this.relatedTable.discardPendingEdits(e):(this.store.discardPendingEdits(e),!0)}async downloadAttachmentById(e,t){const i=(await this.store.getAttachmentsByObjectId(e,!0)).find(e=>e.id===t);await M(i)}drainRelatedTables(){this.relatedTables.drain(e=>e.destroy()),this.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:null,showAllRelatedTables:!1,tableTemplateOverride:null}),this.hiddenFields.removeMany([K.action,K.attachments])}drainRelatedTablesAboveIndex(e){const{relatedTables:t}=this,i=t.slice(e+1);t.removeMany(i).forEach(e=>e.destroy());const s=t.at(-1);s&&(s.attachmentsViewOptions.objectId=null,this.allRelatedTablesVisible?this._showAllRelatedTables(s):this._hideAllRelatedTables(s))}async exportSelectionToCSV(e){const{highlightIds:t,layer:i,outFields:s}=this;i&&t.length?await N({layer:i,objectIds:t.toArray(),outFields:s,includeGeometry:e}):this._logWarning("Export failed.")}getFeatureStoreItemByObjectId(e){return this.store.getItemByObjectId(e)}async getFeatureTitle(e,t){return this.store.getFeatureTitle(e,t)}getFeatureTitleSync(e){const t=this.layer;if(!t)return`${e}`;const i=`${t.objectIdField}: ${e}`;return null==e?i:this.store.featureTitleMap.get(e)??i}getObjectIdIndex(e){return this.store.getItemIndexByObjectId(e)}getValue(e,t){const i=this.getFeatureStoreItemByObjectId(e);return i?.feature?.attributes[t]}getVirtualPageIndex(){return this.grid?.getVirtualPageIndex()??0}goToPage(e){if(null==e||!Number.isInteger(e))return void this._logWarning("Invalid 'page' parameter provided to 'goToPage()'. Current page will remain the same.");const{pageCount:t}=this;(e>=t||-1===e)&&(e=t-1),e<-1&&(e=0),e!==this.pageIndex&&(this.pageIndex=e),this.paginationEnabled||this.scrollToIndex(e*this.pageSize)}hideAttachmentsView(){this.attachmentsViewOptions.objectId=null,this.set({relationshipColumnConfigs:null,multipleSelectionEnabledOverride:null,tableTemplateOverride:null}),this.hiddenFields.remove(K.action)}nextPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e+1)}previousPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e-1)}async refresh(){await Promise.all([...this.relatedTables.map(e=>e.refresh()),h(this._refreshDebounced())])}refreshCellContent(){this.grid?.requestContentUpdate()}refreshPageCache(){this.grid?.refreshPageCache()}async reset(){this.goToPage(0),await(this.grid?.reset())}async savePendingEdits(){!this.relatedTableHasPendingEdits||this.relatedTableHasInvalidPendingEdits?this.hasPendingEdits&&!this.relatedTable&&(await this.store.savePendingEdits(),await this.refresh()):await(this.relatedTable?.savePendingEdits())}scrollLeft(){this.grid?.scrollLeft(0)}scrollToBottom(){this.grid?.scrollToBottom()}scrollToIndex(e){this.grid?.scrollToIndex(e)}scrollToRow(e){const t=this.store.getItemIndexByObjectId(e);t>-1?this.grid?.scrollToIndex(t):this._logWarning("Row not found. Associated data may not be loaded yet.")}scrollToTop(){this.grid?.scrollToTop()}async saveAttachmentsViewForm(){const{attachmentId:e,form:t,objectId:i}=this.attachmentsViewOptions;null!=i&&t&&(null!=e?await this.updateAttachment(i,e,t):await this.addAttachment(i,t))}async showAttachmentsView({objectId:e}){const{attachmentsViewOptions:t,hiddenFields:i,layer:s}=this;if(!this.attachmentsEnabled||!s)return void this._logWarning("The 'attachmentsEnabled' property is currently false.");await s.load();const n=this._getDefaultLayerDisplayField(s),r=await this.store.getAttachmentsByObjectId(e,!0),o=this.store.getItemIndexByObjectId(e);t.set({attachmentInfos:r,mode:r.length?"list":"file",objectId:e}),this.set({highlightIds:new l([e]),multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForAttachmentsView(n)}),i.includes(K.action)||i.add(K.action),null!=o&&this.scrollToIndex(o)}syncAttributeTableTemplate(){this._syncAttributeTableTemplate(!0)}syncSelectionSources(){this.store.syncSelectionSources()}async updateAttachment(e,t,i){const{attachmentsViewOptions:s,store:n}=this,l=s.objectId===e;await n.updateAttachment(e,t,i).catch(e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to update attachment. ${e.error.name} ${e.error.message}`),s.error=e.error)}),l&&!s.error&&(s.onEditComplete(),s.attachmentInfos=await n.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}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 n=await e.queryFeatures(s);try{await ie(t,n.features)}catch(l){"AbortError"!==l.name&&console.error(l)}}_syncAttributeTableTemplate(e=!1){const{_effectiveAttributeTableTemplate:t,layer:i,tableTemplateOverride:s,syncTemplateOnChangesEnabled:n}=this;if(!i||!t||!n&&!e||s||this.tableParent||this.relatedTable||null!==this.attachmentsViewOptions.objectId)return;const l=JSON.stringify(t.toJSON());E(t,this.columns.toArray(),this.activeSortOrders),t===i.attributeTableTemplate&&JSON.stringify(t.toJSON())!==l&&(i.attributeTableTemplate=t.clone())}async _refresh(){await super.refresh();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach((t,i)=>{t||this.highlightIds.remove(e[i])})}this.refreshPageCache();const t=this.attachmentsViewOptions;null!=t?.objectId&&(t.attachmentInfos=await this.store.getAttachmentsByObjectId(t.objectId,!0))}async _onLayerLoad(){const{layer:e,pageSize:t}=this;if(!e)return;e.parent&&I(e.parent)&&await e.parent.loadAll();const i=e.capabilities.query?.maxRecordCount,s=i&&i<t,n=s?i:t;s&&(this._logWarning("The value for 'pageSize' has been adjusted due to the provided layer's max record count."),this.pageSize=n),this.grid?.set("pageSize",n),this.store.load().catch(()=>{}),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const{_effectiveTableTemplate:e,_effectiveAttributeTableTemplate:t,layer:i}=this,s=e?.columnTemplates;if(!i)return;const n=this._generateColumnsFromColumnTemplates(i,s)??this._generateColumnsFromAttributeTableTemplate(i,t)??this._generateDefaultFieldColumns(i);n.length&&(this.attachmentsEnabled&&!n.some(e=>B(e))&&n.push(this._generateDefaultAttachmentsColumn(i)),this.relatedRecordsEnabled&&this.relationshipInfos.length&&!n.some(e=>G(e))&&n.push(...this._generateDefaultRelationshipColumns()),this.actionColumnConfig&&n.push(this._generateActionColumn()),n.sort((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0),this.columns.addMany(n))}_generateColumnsFromAttributeTableTemplate(e,t){if(!t)return null;const{elements:i,orderByFields:s}=t,l=v(e),r=[];r.push(...this._generateColumnsFromAttributeTableElements(e,i,s));const o=l.map(t=>{if(!t.fieldName||X(t.fieldName,r))return null;const{fieldName:i}=t,n=Y(e,i);return n?this._generateDefaultFieldColumn(e,n,{hidden:!0,orderByFields:s}):(this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null)}).filter(n);return r.push(...o),this.attachmentsEnabled&&ee(e)&&!r.some(e=>B(e))&&r.push(this._generateDefaultAttachmentsColumn(e,{hidden:!0})),this.relatedRecordsEnabled&&q(e)&&e.relationships?.forEach(({id:e},t)=>{const i=this.relationshipInfos.find(t=>t.relationshipId===e);i&&!r.some(t=>G(t)&&t.relationshipId===e)&&r.push(this._generateDefaultRelationshipColumn({hidden:!0,info:i,index:t}))}),r.length?r:null}_generateColumnsFromAttributeTableElements(e,t,i){return t?.map((t,s)=>{switch(t.type){case"field":return this._createFieldColumnFromElement({layer:e,element:t,orderByFields:i});case"group":return this._createGroupColumnFromElement({layer:e,element:t,orderByFields:i});case"attachment":return this._createAttachmentColumnFromElement({layer:e,element:t,index:s});case"relationship":return this._createRelationshipColumnFromElement({element:t,index:s})}}).filter(e=>!!e)??[]}_createFieldColumnFromElement(e){const{layer:t,element:i,orderByFields:s}=e,{fieldName:n}=i;if(null==n)return this._logTemplateWarning("A valid 'fieldName' must be provided."),null;const l=Y(t,n);if(!l)return this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null;const{description:r,label:o}=i,a=s?.findIndex(({field:e})=>e&&e===n)??-1,d=a>-1?s?.at(a)?.order:void 0,h=a>-1?a:void 0,{grid:m,messages:c,messagesCommon:p,messagesURIUtils:u,store:g,view:b}=this;return new j({description:r,direction:d,field:l,fieldName:n,grid:m,initialSortPriority:h,label:o,layer:t,messages:c,messagesCommon:p,messagesURIUtils:u,store:g,view:b,onShowPromptCallback:this._onShowPromptCallback})}_createGroupColumnFromElement(e){const{layer:t,element:i,orderByFields:s}=e,{description:n,label:l}=i;if(!l)return this._logTemplateWarning("Group columns require a label."),null;if(!i.elements.length)return this._logTemplateWarning("Group columns require child columns."),null;const{grid:r,messages:o,messagesCommon:a,messagesURIUtils:d,store:h}=this;return new V({columns:this._generateColumnsFromAttributeTableElements(t,i.elements,s),description:n,grid:r,label:l,messages:o,messagesCommon:a,messagesURIUtils:d,store:h})}_createAttachmentColumnFromElement(e){if(!this.attachmentsEnabled)return void this._logTemplateWarning("The 'attachmentsEnabled' property is currently false.");const{layer:t,element:i,index:s}=e,{description:n,label:l}=i,{grid:r,messages:o,messagesCommon:a,messagesURIUtils:d,store:h}=this;return new x({description:n,fieldName:`${K.attachments}-${s}`,grid:r,label:l,layer:t,messages:o,messagesCommon:a,messagesURIUtils:d,store:h,onShowAttachments:e=>this._onShowAttachments(e)})}_createRelationshipColumnFromElement(e){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{element:t,index:i}=e,{description:s,label:n,relationshipId:l}=t,r=this.relationshipInfos.find(e=>e.relationshipId===l);if(!r)return this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id."),null;const{grid:o,messages:a,messagesCommon:d,messagesURIUtils:h,store:m}=this;return new R({description:s,fieldName:`${K.relationship}-${l}-${i}`,grid:o,label:n,messages:a,messagesCommon:d,messagesURIUtils:h,relationshipId:l,store:m,layer:r.relatedLayer,relatedLayer:r.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateColumnsFromColumnTemplates(e,t){const{grid:i,messages:s,messagesCommon:n,messagesURIUtils:l,store:r,view:o}=this;if(!t?.length)return null;const a=[];return t.forEach((t,d)=>{const{autoWidth:h,description:m,direction:c,flexGrow:p,fieldName:u,formatFunction:g,frozen:b,frozenToEnd:f,icon:y,iconText:T,initialSortPriority:w,invalid:C,label:I,labelTooltipText:v,menuConfig:_,resizable:E,sortable:S,textAlign:A,textWrap:F,timeZone:x,type:R,width:P}=t;if(!R)return void this._logTemplateWarning("Property 'type' is missing from the provided template.");if(b&&f)return void this._logTemplateWarning("Properties 'frozen' and 'frozenToEnd' cannot both be true for the same column.");const U=!1===t.visible;if("group"===R){if(!t.columnTemplates?.length)return void this._logTemplateWarning("Group columns must contain column templates.");if(!t.label)return void this._logTemplateWarning("Group columns require a label.");const r=this._generateColumnsFromColumnTemplates(e,t.columnTemplates),o=U||this._isFieldHidden(t.label);a.push(new V({autoWidth:h,columns:r,description:m,flexGrow:p,frozen:b,frozenToEnd:f,grid:i,hidden:o,icon:y,iconText:T,invalid:C,label:I,labelTooltipText:v,menuConfig:_,messages:s,messagesCommon:n,messagesURIUtils:l,resizable:E,textAlign:A,textWrap:F,timeZone:x,width:P}))}else if("attachment"===R){if(!this.attachmentsEnabled)return void this._logTemplateWarning("Attachment columns require attachments to be enabled on the table.");a.push(this._generateAttachmentsColumnFromTemplate(e,t,d))}else if("relationship"===R){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{relationshipId:e}=t;if(null==e)return void this._logTemplateWarning("Property 'relationshipId' is missing from the provided template.");const i=this.relationshipInfos.find(t=>t.relationshipId===e);if(!i)return void this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id.");a.push(this._generateRelationshipColumnFromTemplate(i,t,d))}else if(!u)return void this._logTemplateWarning("Value for 'fieldName' property was missing from the provided template.");const z=U||this._isFieldHidden(u);if("column"===R)a.push(new O({autoWidth:h,description:m,direction:c,fieldName:u,flexGrow:p,formatFunction:g,frozen:b,frozenToEnd:f,grid:i,hidden:z,icon:y,iconText:T,initialSortPriority:w,invalid:C,label:I,labelTooltipText:v,menuConfig:_,messages:s,messagesCommon:n,messagesURIUtils:l,resizable:E,sortable:S,store:r,textAlign:A,textWrap:F,timeZone:x,width:P}));else if("field"===R){const d=Y(e,t.fieldName);if(!d)return void this._logTemplateWarning("A valid 'field' could not be found for the provided template.");const{editable:u,required:R}=t;a.push(new j({autoWidth:h,description:m,direction:c,editable:u,field:d,fieldName:d.name,flexGrow:p,formatFunction:g,frozen:b,frozenToEnd:f,grid:i,hidden:z,icon:y,iconText:T,initialSortPriority:w,invalid:C,label:I,labelTooltipText:v,layer:e,messages:s,messagesCommon:n,messagesURIUtils:l,menuConfig:_,required:R,resizable:E,sortable:S,store:r,template:t,textAlign:A,textWrap:F,timeZone:x,width:P,view:o,onShowPromptCallback:this._onShowPromptCallback}))}}),a.length?a:null}_generateDefaultFieldColumns(e){return e.fields?.map(t=>this._generateDefaultFieldColumn(e,t)).filter(n)??[]}_generateDefaultFieldColumn(e,t,i){const{grid:s,messages:n,messagesCommon:l,messagesURIUtils:r,store:o,view:a}=this;if(!t.visible||"geometry"===t.type)return null;const d=i?.orderByFields,h=t.name,m=d?.findIndex(({field:e})=>e&&e===h)??-1,c=m>-1?d?.at(m)?.order:void 0,p=m>-1?m:void 0;return new j({direction:c,field:t,fieldName:h,grid:s,hidden:i?.hidden||this._isFieldHidden(h),initialSortPriority:p,layer:e,messages:n,messagesCommon:l,messagesURIUtils:r,store:o,view:a,onShowPromptCallback:this._onShowPromptCallback})}_generateAttachmentsColumnFromTemplate(e,t,i){const{grid:s,messages:n,messagesCommon:l,messagesURIUtils:r,store:o}=this,{attachmentsViewEnabled:a,autoWidth:d,description:h,flexGrow:m,fieldName:c,formatFunction:p,frozen:u,frozenToEnd:g,icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:C,resizable:I,textAlign:v,textWrap:_,thumbnailAppearance:E,thumbnailCount:S,thumbnailIconScale:A,thumbnailsEnabled:F,timeZone:j,width:R}=t;return new x({attachmentsViewEnabled:a,autoWidth:d,description:h,fieldName:`${K.attachments}-${i}`,flexGrow:m,formatFunction:p,frozen:u,frozenToEnd:g,grid:s,hidden:!1===t.visible||this._isFieldHidden(T)||this._isFieldHidden(c),icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,layer:e,menuConfig:C,messages:n,messagesCommon:l,messagesURIUtils:r,resizable:I,store:o,textAlign:v,textWrap:_,thumbnailAppearance:E,thumbnailCount:S,thumbnailIconScale:A,thumbnailsEnabled:F,timeZone:j,width:R,onShowAttachments:e=>this._onShowAttachments(e)})}_generateDefaultAttachmentsColumn(e,t){const{grid:i,messages:s,messagesCommon:n,messagesURIUtils:l,store:r}=this,o=K.attachments;return new x({fieldName:o,grid:i,hidden:t?.hidden||this._isFieldHidden(o),layer:e,messages:s,messagesCommon:n,messagesURIUtils:l,store:r,onShowAttachments:e=>this._onShowAttachments(e)})}_generateRelationshipColumnFromTemplate(e,t,i){const{grid:s,messages:n,messagesCommon:l,messagesURIUtils:r,store:o}=this,{autoWidth:a,collapsed:d,description:h,flexGrow:m,fieldName:c,formatFunction:p,frozen:u,frozenToEnd:g,icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:C,relationshipId:I,resizable:v,textAlign:_,textWrap:E,timeZone:S,width:A}=t;return new R({autoWidth:a,collapsed:d,description:h,fieldName:`${K.relationship}-${I}-${i}`,flexGrow:m,formatFunction:p,frozen:u,frozenToEnd:g,grid:s,hidden:!1===t.visible||this._isFieldHidden(T)||this._isFieldHidden(c),icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:C,messages:n,messagesCommon:l,messagesURIUtils:r,relationshipId:I,resizable:v,store:o,textAlign:_,textWrap:E,timeZone:S,width:A,layer:e.relatedLayer,relatedLayer:e.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateDefaultRelationshipColumns(){const{relationshipInfos:e,relationshipColumnConfigs:t}=this,i=[];return e?.length?(t?t.forEach((t,s)=>{const{relationshipId:n}=t,l=e.find(e=>e.relationshipId===n);l&&i.push(this._generateDefaultRelationshipColumn({config:t,index:s,info:l}))}):e.forEach((e,t)=>i.push(this._generateDefaultRelationshipColumn({index:t,info:e}))),i):i}_generateDefaultRelationshipColumn(e){const{config:t,hidden:i,index:s,info:n}=e,{grid:l,messages:r,messagesCommon:o,messagesURIUtils:a,store:d}=this,{relationshipId:h}=n;return new R({...t,fieldName:`${K.relationship}-${h}-${s}`,grid:l,hidden:!!i,messages:r,messagesCommon:o,messagesURIUtils:a,layer:n.relatedLayer,relatedLayer:n.layer,relationshipId:h,store:d,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateActionColumn(){const e=this.actionColumnConfig,t=!0!==e?.frozen&&(e?.frozenToEnd??!0);return new F({hidden:this._isFieldHidden(K.action),store:this.store,...e,frozenToEnd:t})}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some(e=>e.toLowerCase()===t)}_syncSelection(){const{layer:e}=this;A(e)?this.highlightIds.items=this.effectiveSelectionManager.getSelection(e)??[]:this.highlightIds.removeAll()}_addToSelection(e){const t=this.layer;A(t)&&this.effectiveSelectionManager.add(t,e)}_removeFromSelection(e){const t=this.layer;A(t)&&this.effectiveSelectionManager.remove(t,e)}async _onHighlightIdsChange(e){const{added:t,removed:i}=e,{attachmentsViewOptions:s}=this;if(this._removeFromSelection(i),this._addToSelection(t),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray()),null!=s.objectId){const e=this.highlightIds.at(0);if(null!=e){const t=await this.store.getAttachmentsByObjectId(e,!0);s.set({attachmentInfos:t,objectId:e,mode:t.length?"list":"file"}),this.getFeatureTitle(e)}}}_syncTableParentSelection(e){const{tableParent:t}=this;t&&null!=e&&t.highlightIds.add(e)}_onShowRelatedTable(e){const{highlightIds:t}=this,{objectId:i}=e;t.removeAll(),t.add(i),this.showRelatedTableCallback?this.showRelatedTableCallback(e):this.emit("show-related-table",e)}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.refreshPageCache()}_drainColumns(){this.columns.drain(e=>!e.destroyed&&e.destroy())}_showAllRelatedTables(e){const t=e.layer;if(!t)return;const i=this._getDefaultLayerDisplayField(t);e.set({relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForShowAllTablesView(e,i)});const s=e.hiddenFields;s.includes(K.action)||s.add(K.action),s.includes(K.attachments)||s.add(K.attachments)}_hideAllRelatedTables(e){const{layer:t,relationship:i}=e;if(t&&null!=i?.id)if(null!=e.attachmentsViewOptions.objectId){const i=this._getDefaultLayerDisplayField(t);e.set({multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],showAllRelatedTables:!1,tableTemplateOverride:this._getTableTemplateForAttachmentsView(i)})}else e.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:te(t,i.id),showAllRelatedTables:!1,tableTemplateOverride:null}),e.hiddenFields.removeMany([K.action,K.attachments])}_getTableTemplateForRelatedTableView(e,t,i){return new $({columnTemplates:[new D({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([s,n])=>({selected:s===t,label:n||s,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForRelatedTableView(e,s,i)}}))},resizable:!1}),new H({autoWidth:!1,collapsed:!0,flexGrow:0,label:"",resizable:!1,relationshipId:i,width:ne})]})}_getTableTemplateForShowAllTablesView(e,t){const i=[new D({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([i,s])=>({selected:i===t,label:s||i,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForShowAllTablesView(e,i)}}))},resizable:!1})];return null!=e.attachmentsViewOptions.objectId&&i.push(new z({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:ne})),new $({columnTemplates:i})}async _onShowPromptCallback(e){const{column:t,objectId:i,oldValue:s,value:n}=e,{_subtypes:l,layer:r}=this;if(!r||!l.length)return void t.cancel();const o=l.find(e=>e.code===n);if(!o)return void t.cancel();const a=Promise.withResolvers(),d=this._createSubtypeEditPrompt(s,o,a),h=!!r.parent&&this.autoSaveEnabled;try{this.showPrompt(d);const e=await a.promise,s=[{fieldName:t.fieldName,value:n}];switch(e){case"update-fields":for(const[e,t]of Object.entries(o.defaultValues))null!=t&&s.push({fieldName:e,value:t});await t.updateItems({objectId:i,updates:s}),h&&this.refresh();break;case"keep-existing":await t.updateItems({objectId:i,updates:s}),h&&this.refresh();break;case"undo":t.cancel()}}finally{this.clearPrompt()}}_createSubtypeEditPrompt(e,t,s){const{_subtypes:n,messages:l,messagesCommon:r}=this,o=n.find(t=>t.code===e)?.name??`${e}`;let a="update-fields";const d=[{label:l.subtypes.useDefaultValuesOption,value:"update-fields"},{label:l.subtypes.keepCurrentValuesOption,value:"keep-existing"}];return{context:"info",title:l.subtypes.changeWarningTitle,message:i(l.subtypes.changeWarning,{originalType:o,newType:t.name}),radios:d,defaultRadioSelection:"update-fields",onRadioSelection:e=>{a=e},actions:{primary:{label:r.apply,action:()=>s.resolve(a),type:"positive"},secondary:{label:r.cancel,type:"neutral",action:()=>s.resolve("undo")}},cancel:()=>s.reject()}}_onShowAttachments({objectId:e}){this.hasPendingEdits||(this.attachmentsViewOptions.objectId=e)}_getTableTemplateForAttachmentsView(e){return new $({columnTemplates:[new D({fieldName:e,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(this).map(([t,i])=>({selected:t===e,label:i||t,clickFunction:()=>{this.tableTemplateOverride=this._getTableTemplateForAttachmentsView(t)}}))},resizable:!1}),new z({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:ne})]})}_extractFieldColumnInfosFromTableTemplate(e){const t=e??this,{layer:i,tableTemplate:s}=t;return s?s.columnTemplates.filter(({type:e})=>"field"===e||"column"===e).map(({fieldName:e,label:t})=>{if(null!=t&&""!==t)return[e,t];const s=i?.fieldsIndex.get(e);return[e,s&&y(s,i)]}):i?.fields.map(e=>[e.name,y(e,i)])??[]}_getDefaultLayerDisplayField(e){const{displayField:t,objectIdField:i}=e;return t&&""!==t.trim()?t:i||(e.fields.length?e.fields[0].name:"")}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex(e=>e.frozenToEnd);return e>-1?e:void 0}_logWarning(e,t){t?a.getLogger(this).warnOnce(e):a.getLogger(this).warn(e)}_logTemplateWarning(e){this._logWarning(`${e} Skipped generating a column using the provided template.`,!0)}_onCellInteraction(e){null!=e&&null!=this.attachmentsViewOptions.objectId&&this.highlightIds.add(e)}};e([b()],le.prototype,"_defaultHiddenFields",null),e([b()],le.prototype,"_effectiveTableTemplate",null),e([b()],le.prototype,"_effectiveAttributeTableTemplate",null),e([b()],le.prototype,"_subtypes",null),e([b()],le.prototype,"activeFilters",null),e([b({readOnly:!0})],le.prototype,"activeSortOrders",null),e([b()],le.prototype,"allRelatedTablesVisible",null),e([b()],le.prototype,"attachmentsColumns",null),e([b()],le.prototype,"attachmentsEnabled",null),e([b()],le.prototype,"attachmentsViewOptions",void 0),e([b({type:_})],le.prototype,"attributeTableTemplate",void 0),e([b()],le.prototype,"autoRefreshEnabled",void 0),e([b()],le.prototype,"autoSaveEnabled",null),e([b()],le.prototype,"canAddRelatedFeature",null),e([b()],le.prototype,"clearPrompt",null),e([b({readOnly:!0})],le.prototype,"columns",void 0),e([b()],le.prototype,"dataProvider",void 0),e([b()],le.prototype,"defaultSelectionManager",null),e([b()],le.prototype,"definitionExpression",null),e([b()],le.prototype,"effectiveSelectionManager",null),e([b()],le.prototype,"effectiveTimeExtent",null),e([b()],le.prototype,"effectiveWhere",null),e([b()],le.prototype,"fieldColumns",null),e([b()],le.prototype,"filterByViewExtent",null),e([b()],le.prototype,"filterByLayerScaleRange",null),e([b({types:T})],le.prototype,"filterGeometry",null),e([b()],le.prototype,"filterBySelectionEnabled",null),e([b({readOnly:!0})],le.prototype,"grid",void 0),e([b()],le.prototype,"hasContingentValues",null),e([b()],le.prototype,"hasInvalidPendingEdits",null),e([b()],le.prototype,"hasPendingEdits",null),e([b()],le.prototype,"hiddenFields",null),e([b()],le.prototype,"highlightEnabled",null),e([b()],le.prototype,"initialSize",null),e([b()],le.prototype,"isQueryingOrSyncing",null),e([b()],le.prototype,"isSyncingAttachments",null),e([b()],le.prototype,"layer",null),e([b()],le.prototype,"layers",void 0),e([b()],le.prototype,"layerFieldConfigurations",null),e([b()],le.prototype,"layerView",null),e([b()],le.prototype,"menuConfig",void 0),e([b()],le.prototype,"messages",void 0),e([b(),se("esri/t9n/common")],le.prototype,"messagesCommon",void 0),e([b(),se("esri/core/t9n/Units")],le.prototype,"messagesUnits",void 0),e([b(),se("esri/widgets/support/t9n/uriUtils")],le.prototype,"messagesURIUtils",void 0),e([b()],le.prototype,"outFields",null),e([b()],le.prototype,"pendingEditsCount",null),e([b()],le.prototype,"prompt",void 0),e([b()],le.prototype,"relatedRecordsEnabled",null),e([b()],le.prototype,"relatedTable",null),e([b()],le.prototype,"relatedTableHasContingentValues",null),e([b()],le.prototype,"relatedTables",void 0),e([b()],le.prototype,"relationship",null),e([b()],le.prototype,"relationshipColumnConfigs",void 0),e([b()],le.prototype,"relationshipColumns",null),e([b()],le.prototype,"relationshipConfig",null),e([b()],le.prototype,"relationshipInfos",null),e([b()],le.prototype,"relationships",null),e([b()],le.prototype,"returnGeometryEnabled",null),e([b()],le.prototype,"returnMEnabled",null),e([b()],le.prototype,"returnZEnabled",null),e([b()],le.prototype,"selectionManager",null),e([b()],le.prototype,"selectionSource",null),e([b()],le.prototype,"showAllRelatedTables",null),e([b()],le.prototype,"showPrompt",null),e([b()],le.prototype,"showRelatedTableCallback",void 0),e([b({readOnly:!0,type:k})],le.prototype,"store",void 0),e([b()],le.prototype,"supportsAttachments",null),e([b()],le.prototype,"supportsAddAttachments",null),e([b()],le.prototype,"supportsDeleteAttachments",null),e([b()],le.prototype,"supportsResizeAttachments",null),e([b()],le.prototype,"supportsUpdateAttachments",null),e([b()],le.prototype,"syncTemplateOnChangesEnabled",void 0),e([b()],le.prototype,"syncViewSelection",null),e([b()],le.prototype,"tableController",void 0),e([b()],le.prototype,"tableParent",void 0),e([b({type:$})],le.prototype,"tableTemplate",void 0),e([b()],le.prototype,"tableTemplateOverride",void 0),e([b({type:S})],le.prototype,"timeExtent",null),e([b()],le.prototype,"timeZone",null),e([b()],le.prototype,"view",null),e([b()],le.prototype,"viewTimeEnabled",null),le=e([f("esri.widgets.FeatureTable.FeatureTableViewModel")],le);const re=le;export{re as default};
2
+ import{__decorate as e}from"tslib";import{onLocaleChange as t,substitute as i,fetchMessageBundle as s}from"../../intl.js";import{isSome as n}from"../../core/arrayUtils.js";import l from"../../core/Collection.js";import{referenceSetter as r}from"../../core/collectionUtils.js";import o from"../../core/Error.js";import a from"../../core/Logger.js";import{debounce as d,ignoreAbortErrors as h}from"../../core/promiseUtils.js";import{watch as m,initial as c,on as u,syncAndInitial as p}from"../../core/reactiveUtils.js";import{throttle as g}from"../../core/throttle.js";import{property as b,subclass as f}from"../../core/accessorSupport/decorators.js";import{getEffectiveFieldAlias as y}from"../../editing/fieldUtils.js";import{geometryTypes as T}from"../../geometry/support/typeUtils.js";import{getLowerCaseDefaultHiddenFields as w}from"../../layers/support/fieldUtils.js";import{getSubtypesFromLayer as C,isSubtypeGroupLayer as I}from"../../layers/support/layerUtils.js";import{createFieldInfos as v}from"../../support/popupUtils.js";import _ from"../../tables/AttributeTableTemplate.js";import{syncAttributeTableTemplateWithColumns as E}from"../../tables/support/templateUtils.js";import S from"../../time/TimeExtent.js";import{isSelectableLayerWithObjectIds as A}from"../../views/support/selectionUtils.js";import F from"./ActionColumn.js";import x from"./AttachmentsColumn.js";import j from"./FieldColumn.js";import R from"./RelationshipColumn.js";import O from"./Grid/Column.js";import P from"./Grid/Grid.js";import U from"./Grid/GridViewModel.js";import V from"./Grid/GroupColumn.js";import z from"./support/AttachmentsColumnTemplate.js";import W from"./support/AttachmentsViewOptions.js";import{isAttachmentsColumn as B,isFieldColumn as L,isRelationshipColumn as G}from"./support/columnUtils.js";import{downloadAttachmentInfo as M,exportToCSV as N}from"./support/exportUtils.js";import k from"./support/FeatureStore.js";import D from"./support/FieldColumnTemplate.js";import H from"./support/RelationshipColumnTemplate.js";import $ from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as Z,isIFeatureTableSupportedLayerWithRelationships as q,findRelatedLayerInSources as Q,findRelationship as J,uniqueColumnNames as K,hasColumnForField as X,findField as Y,isIFeatureTableSupportedLayerWithAttachments as ee,getRelationshipIdsToShow as te}from"./support/tableUtils.js";import{goTo as ie}from"../support/goToUtils.js";import{messageBundle as se}from"../support/widget.js";const ne="80px";let le=class extends U{constructor(e){super(e),this._refreshDebounced=d(()=>this._refresh()),this._syncTemplateThrottled=g(()=>this._syncAttributeTableTemplate()),this.attachmentsViewOptions=new W,this.attributeTableTemplate=null,this.autoRefreshEnabled=!0,this.columns=new l,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));try{await i.load()}catch{return}const{objectIds:n}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===n.length&&-1===n.items[0])return void t([]);if("loaded"!==s.state&&"loading"!==s.state)try{await s.load()}catch{return}const l=this.paginationEnabled?this.pageIndex:e.page;try{const i=await s.queryPage({...e,pageIndex:l});t?.(i)}catch{return}},this.grid=null,this.layers=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.messagesURIUtils=null,this.prompt=null,this.relatedTables=new l,this.relationshipColumnConfigs=null,this.showRelatedTableCallback=null,this.store=null,this.syncTemplateOnChangesEnabled=!0,this.tableController=null,this.tableParent=null,this.tableTemplate=null,this.tableTemplateOverride=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._onShowPromptCallback=this._onShowPromptCallback.bind(this),this._set("store",new k),this._set("grid",new P({viewModel:this}))}initialize(){const e=async()=>{this.messages=await s("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await s("esri/t9n/common"),this.messagesUnits=await s("esri/core/t9n/Units"),this.messagesURIUtils=await s("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([t(()=>{e(),this._generateColumns()}),m(()=>[this.messages,this.messagesCommon,this.messagesURIUtils],()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.allColumns.forEach(t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils}),this.refreshCellContent()},c),m(()=>this.attachmentsEnabled,()=>this.layer?.loaded&&this._generateColumns()),m(()=>this.layer,async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this.goToPage(0),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad().catch(()=>{}):e.load().catch(()=>{})),this.syncViewSelection&&this._syncSelection(),t&&null!=this.attachmentsViewOptions.objectId&&(this.attachmentsViewOptions.objectId=null)}),m(()=>this.layer?.loaded,e=>{e&&this._onLayerLoad().catch(()=>{})}),m(()=>this.store.state,e=>{"loaded"===e&&(this.scrollToTop(),this.refreshCellContent())}),m(()=>this._effectiveTableTemplate,()=>{this.scrollLeft(),this.layer?.loaded&&this._generateColumns()}),m(()=>this.editingEnabled,()=>this.refreshCellContent()),m(()=>this.timeZone??this.view?.timeZone,()=>this.refreshCellContent()),m(()=>[this.effectiveTimeExtent,this.effectiveWhere],()=>{"loaded"===this.store.state&&this.reset().catch(()=>{})}),u(()=>this.layer,"refresh",e=>this._onLayerRefresh(e)),u(()=>this.grid,["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder"],({index:e,item:t,native:i,path:s,type:n})=>{const l=t?.feature,r=l?.getObjectId(),o="cell-keydown"===n&&i&&i instanceof KeyboardEvent&&"Enter"===i.key;this.emit(n,{feature:l,index:e,native:i,type:n,fieldName:s??void 0,objectId:r}),(o||"cell-click"===n)&&this._onCellInteraction(r)}),m(()=>this.actionColumnConfig,e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())}),m(()=>this.relatedRecordsEnabled,()=>this.layer?.loaded&&this._generateColumns()),u(()=>this.objectIds,"change",()=>this._onObjectIdsChange(),{onListenerAdd:()=>this._onObjectIdsChange()}),m(()=>[this.paginationEnabled,this.pageIndex],()=>this.refreshPageCache()),m(()=>this.activeSortOrders,e=>{this.store.sortOrders=e,this._syncTemplateThrottled()}),m(()=>this.allVisibleColumns,()=>this._syncTemplateThrottled()),m(()=>this.pageCount,()=>{this.pageIndex>=this.pageCount&&this.goToPage(0)}),m(()=>this.state,e=>{"disabled"===e&&this.relatedTables.length&&this.drainRelatedTables()}),u(()=>this.tableParent?.highlightIds,"change",({added:e})=>{const{relationshipConfig:t}=this,i=e[0];if(null==i||!t)return;const{relatedLayer:s,relationshipId:n}=t;this.relationshipConfig={objectId:i,relatedLayer:s,relationshipId:n}}),u(()=>this.tableParent,"cell-click",async e=>{const{objectId:t}=e;this.tableController&&this.hasPendingEdits?await this.tableController.discardPendingEdits(void 0,!0).then(e=>e&&this._syncTableParentSelection(t)):this._syncTableParentSelection(t)}),m(()=>this.attachmentsViewOptions.objectId,(e,t)=>{null!=e?null==t&&this.showAttachmentsView({objectId:e}):this.hideAttachmentsView()}),m(()=>[this.layerFieldConfigurations,this.pendingEditsCount],()=>this.refreshCellContent()),u(()=>this.highlightIds,"change",e=>this._onHighlightIdsChange(e),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this.defaultSelectionManager.clear()}),m(()=>this.effectiveSelectionManager,()=>this._syncSelection(),p),u(()=>this.effectiveSelectionManager,"selection-change",()=>this._syncSelection(),p)])}destroy(){this._drainColumns(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return w(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _effectiveAttributeTableTemplate(){return this.attributeTableTemplate||this.layer?.attributeTableTemplate}get _subtypes(){return C(this.layer)}get actionColumn(){return super.actionColumn}get activeFilters(){const{filterGeometry:e,objectIds:t,filterBySelectionEnabled:i,highlightIds:s}=this,n=new l;return e&&n.push({type:"geometry",geometry:e}),i?n.push({type:"selection",objectIds:s.toArray()}):t.length&&n.push({type:"objectId",objectIds:t.toArray()}),n}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map(({path:e,direction:t})=>({fieldName:e,direction:t})).filter(e=>e.fieldName&&e.direction):[]}get allColumns(){return super.allColumns}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this.showAllRelatedTables)}get allVisibleColumns(){return super.allVisibleColumns}get attachmentsColumns(){return this.allColumns.filter(e=>B(e))}get attachmentsEnabled(){return this.store.attachmentsEnabled}set attachmentsEnabled(e){this.store.attachmentsEnabled=e}get autoSaveEnabled(){return this.store.autoSaveEnabled}set autoSaveEnabled(e){this.store.autoSaveEnabled=e}get cachedPageCount(){return this.store.cachedPageCount}get canAddRelatedFeature(){return this.store.canAddRelatedFeature}get clearPrompt(){return()=>this.prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}get defaultSelectionManager(){return this.store.defaultSelectionManager}get definitionExpression(){return this.store.where}set definitionExpression(e){this.store.where=e}get editingEnabled(){return super.editingEnabled}set editingEnabled(e){super.editingEnabled=e}get effectiveSelectionManager(){return this.store.effectiveSelectionManager}get effectiveMultipleSelectionEnabled(){return super.effectiveMultipleSelectionEnabled}get effectiveSize(){return super.effectiveSize}get effectiveTimeExtent(){return this.store.effectiveTimeExtent}get effectiveWhere(){return this.store.effectiveWhere}get fieldColumns(){return this.allColumns.filter(e=>L(e))}get filterByViewExtent(){return this.store.filterByViewExtent}set filterByViewExtent(e){this.store.filterByViewExtent=e}get filterByLayerScaleRange(){return this.store.filterByLayerScaleRange}set filterByLayerScaleRange(e){this.store.filterByLayerScaleRange=e}get filterGeometry(){return this.store.filterGeometry}set filterGeometry(e){this.store.filterGeometry=e}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get groupColumns(){return super.groupColumns}get hasContingentValues(){return this.relatedTableHasContingentValues||this.store.hasContingentValues}get hasInvalidPendingEdits(){return this.relatedTableHasInvalidPendingEdits||this.store.hasInvalidPendingEdits}get hasPendingEdits(){return this.relatedTableHasPendingEdits||this.store.hasPendingEdits}get hiddenFields(){return this._get("hiddenFields")??new l}set hiddenFields(e){this._set("hiddenFields",r(e,this._get("hiddenFields"),l))}get highlightEnabled(){return this.store.highlightEnabled}set highlightEnabled(e){this.store.highlightEnabled=e}get highlightIds(){return super.highlightIds}set highlightIds(e){super.highlightIds=e}get initialSize(){return this.store.initialSize}set initialSize(e){this.store.initialSize=e}get isEditing(){return super.isEditing}get isQuerying(){return super.isQuerying}get isSyncing(){return super.isSyncing}get isQueryingOrSyncing(){return this.isQuerying||this.isSyncing||this.relatedTables.some(e=>!!e.isQueryingOrSyncing)}get isSyncingAttachments(){return this.store.isSyncingAttachmentEdits||this.relatedTables.some(e=>!!e.isSyncingAttachments)}get layer(){return this._get("layer")}set layer(e){this.drainRelatedTables(),this._set("layer",e)}get layerFieldConfigurations(){const e=this.layer;return Z(e)?e.fieldConfigurations:void 0}get layerView(){return this.store.layerView}get maxSize(){return super.maxSize}set maxSize(e){super.maxSize=e}get objectIds(){return super.objectIds}set objectIds(e){super.objectIds=e}get outFields(){return this.store.outFields}set outFields(e){this.store.outFields=e}get pageCount(){return super.pageCount}get pageIndex(){return super.pageIndex}set pageIndex(e){super.pageIndex=e}get pageSize(){return super.pageSize}set pageSize(e){super.pageSize=e}get paginationEnabled(){return super.paginationEnabled}set paginationEnabled(e){super.paginationEnabled=e}get pendingEditsCount(){return this.store.pendingEditsCount}get relatedRecordsEnabled(){return this.store.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relatedTableHasContingentValues(){return!!this.relatedTable?.hasContingentValues}get relatedTableHasInvalidPendingEdits(){return!!this.relatedTable?.hasInvalidPendingEdits}get relatedTableHasPendingEdits(){return!!this.relatedTable?.hasPendingEdits}get relationship(){return this.store.relationship}get relationshipColumns(){return this.allColumns.filter(e=>G(e))}get relationshipConfig(){return this.store.relationshipConfig}set relationshipConfig(e){this.highlightIds.removeAll(),this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e}get relationshipInfos(){const{layer:e,layers:t,relationships:i,tableController:s}=this,n=this.store.relationshipInfos;if(n.length||!q(e)||!i?.length)return n;const l=[],r=s?.layers||t||[];return i.forEach(t=>{const i=Q(e,r,t);i&&(i.load().catch(()=>{}),l.push({layer:e,relatedLayer:i,relationshipId:t.id}))}),l}get relationships(){return this.store.relationships}get returnGeometryEnabled(){return this.store.returnGeometry}set returnGeometryEnabled(e){this.store.returnGeometry=e}get returnMEnabled(){return this.store.returnM}set returnMEnabled(e){this.store.returnM=e}get returnZEnabled(){return this.store.returnZ}set returnZEnabled(e){this.store.returnZ=e}get rowHighlightIds(){return super.rowHighlightIds}set rowHighlightIds(e){super.rowHighlightIds=e}get selectionManager(){return this.store.selectionManager}set selectionManager(e){this.store.selectionManager=e}get selectionSource(){return"table"}set selectionSource(e){this.syncViewSelection="view"===e,this._overrideIfSome("selectionSource",e)}get showAllRelatedTables(){return this._get("showAllRelatedTables")}set showAllRelatedTables(e){const{relatedTable:t}=this;this._set("showAllRelatedTables",e),t&&(e?this._showAllRelatedTables(t):this._hideAllRelatedTables(t))}get showPrompt(){return e=>{this.prompt?.cancel?.(),this.prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get size(){return super.size}get state(){return super.state}get supportsAttachments(){return this.store.supportsAttachments}get supportsAddAttachments(){const{store:{supportsAddAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsDeleteAttachments(){return this.supportsUpdateAttachments}get supportsResizeAttachments(){return this.store.supportsResizeAttachments}get supportsUpdateAttachments(){const{store:{supportsUpdateAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get syncViewSelection(){return this.store.syncViewSelection}set syncViewSelection(e){this.store.syncViewSelection=e}get timeExtent(){return this.store.timeExtent}set timeExtent(e){this.store.timeExtent=e}get timeZone(){return this.store.timeZone}set timeZone(e){this.store.timeZone=e}get view(){return this.store.view}set view(e){this.store.view=e,this.fieldColumns.forEach(t=>t.view=e),this.refreshCellContent()}get viewTimeEnabled(){return this.store.viewTimeEnabled}set viewTimeEnabled(e){this.store.viewTimeEnabled=e}get visibleColumns(){return super.visibleColumns}async addAttachment(e,t){const{attachmentsViewOptions:i,store:s}=this,n=i.objectId===e;await s.addAttachment(e,t).catch(e=>{n&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to add attachment. ${e.error.name} ${e.error.message}`),i.error=e.error)}),n&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}addPendingEdits(e){this.store.addPendingEdits(e)}collapseRelatedTable(e,t){const{relatedLayer:i,objectId:s,relationshipId:n}=t,{objectIdField:r}=i,o=J(i,n),a=i.displayField||o?.keyField||r;e.set({highlightIds:new l([s]),multipleSelectionEnabledOverride:!1,tableTemplateOverride:this._getTableTemplateForRelatedTableView(e,a,n)});const d=e.hiddenFields;d.includes(K.action)||d.add(K.action),d.includes(K.attachments)||d.add(K.attachments),e.scrollLeft()}async deleteAttachments(e,t){const{attachmentsViewOptions:i,store:s}=this,n=i.objectId===e;await s.deleteAttachments(e,t).catch(e=>{n&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to delete attachment(s). ${e.error.name} ${e.error.message}`),i.error=e.error)}),n&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}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.highlightIds.removeMany(i),await this.refresh())}async discardPendingEdits(e){return this.relatedTable&&this.relatedTableHasPendingEdits?this.relatedTable.discardPendingEdits(e):(this.store.discardPendingEdits(e),!0)}async downloadAttachmentById(e,t){const i=(await this.store.getAttachmentsByObjectId(e,!0)).find(e=>e.id===t);await M(i)}drainRelatedTables(){this.relatedTables.drain(e=>e.destroy()),this.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:null,showAllRelatedTables:!1,tableTemplateOverride:null}),this.hiddenFields.removeMany([K.action,K.attachments])}drainRelatedTablesAboveIndex(e){const{relatedTables:t}=this,i=t.slice(e+1);t.removeMany(i).forEach(e=>e.destroy());const s=t.at(-1);s&&(s.attachmentsViewOptions.objectId=null,this.allRelatedTablesVisible?this._showAllRelatedTables(s):this._hideAllRelatedTables(s))}async exportSelectionToCSV(e){const{highlightIds:t,layer:i,outFields:s}=this;i&&t.length?await N({layer:i,objectIds:t.toArray(),outFields:s,includeGeometry:e}):this._logWarning("Export failed.")}getCachedFeaturesByPageIndex(e){return this.store.getCachedFeaturesByPageIndex(e)}getFeatureStoreItemByObjectId(e){return this.store.getItemByObjectId(e)}async getFeatureTitle(e,t){return this.store.getFeatureTitle(e,t)}getFeatureTitleSync(e){const t=this.layer;if(!t)return`${e}`;const i=`${t.objectIdField}: ${e}`;return null==e?i:this.store.featureTitleMap.get(e)??i}getObjectIdIndex(e){return this.store.getItemIndexByObjectId(e)}getValue(e,t){const i=this.getFeatureStoreItemByObjectId(e);return i?.feature?.attributes[t]}getVirtualPageIndex(){return this.grid?.getVirtualPageIndex()??0}goToPage(e){if(null==e||!Number.isInteger(e))return void this._logWarning("Invalid 'page' parameter provided to 'goToPage()'. Current page will remain the same.");const{pageCount:t}=this;(e>=t||-1===e)&&(e=t-1),e<-1&&(e=0),e!==this.pageIndex&&(this.pageIndex=e),this.paginationEnabled||this.scrollToIndex(e*this.pageSize)}hideAttachmentsView(){this.attachmentsViewOptions.objectId=null,this.set({relationshipColumnConfigs:null,multipleSelectionEnabledOverride:null,tableTemplateOverride:null}),this.hiddenFields.remove(K.action)}nextPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e+1)}previousPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e-1)}async refresh(){await Promise.all([...this.relatedTables.map(e=>e.refresh()),h(this._refreshDebounced())])}refreshCellContent(){this.grid?.requestContentUpdate()}refreshPageCache(){this.grid?.refreshPageCache()}async reset(){this.goToPage(0),await(this.grid?.reset())}async savePendingEdits(){!this.relatedTableHasPendingEdits||this.relatedTableHasInvalidPendingEdits?this.hasPendingEdits&&!this.relatedTable&&(await this.store.savePendingEdits(),await this.refresh()):await(this.relatedTable?.savePendingEdits())}scrollLeft(){this.grid?.scrollLeft(0)}scrollToBottom(){this.grid?.scrollToBottom()}scrollToIndex(e){this.grid?.scrollToIndex(e)}scrollToRow(e){const t=this.store.getItemIndexByObjectId(e);t>-1?this.grid?.scrollToIndex(t):this._logWarning("Row not found. Associated data may not be loaded yet.")}scrollToTop(){this.grid?.scrollToTop()}async saveAttachmentsViewForm(){const{attachmentId:e,form:t,objectId:i}=this.attachmentsViewOptions;null!=i&&t&&(null!=e?await this.updateAttachment(i,e,t):await this.addAttachment(i,t))}async showAttachmentsView({objectId:e}){const{attachmentsViewOptions:t,hiddenFields:i,layer:s}=this;if(!this.attachmentsEnabled||!s)return void this._logWarning("The 'attachmentsEnabled' property is currently false.");await s.load();const n=this._getDefaultLayerDisplayField(s),r=await this.store.getAttachmentsByObjectId(e,!0),o=this.store.getItemIndexByObjectId(e);t.set({attachmentInfos:r,mode:r.length?"list":"file",objectId:e}),this.set({highlightIds:new l([e]),multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForAttachmentsView(n)}),i.includes(K.action)||i.add(K.action),null!=o&&this.scrollToIndex(o)}syncAttributeTableTemplate(){this._syncAttributeTableTemplate(!0)}syncSelectionSources(){this.store.syncSelectionSources()}async updateAttachment(e,t,i){const{attachmentsViewOptions:s,store:n}=this,l=s.objectId===e;await n.updateAttachment(e,t,i).catch(e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to update attachment. ${e.error.name} ${e.error.message}`),s.error=e.error)}),l&&!s.error&&(s.onEditComplete(),s.attachmentInfos=await n.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}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 n=await e.queryFeatures(s);try{await ie(t,n.features)}catch(l){"AbortError"!==l.name&&console.error(l)}}_syncAttributeTableTemplate(e=!1){const{_effectiveAttributeTableTemplate:t,layer:i,tableTemplateOverride:s,syncTemplateOnChangesEnabled:n}=this;if(!i||!t||!n&&!e||s||this.tableParent||this.relatedTable||null!==this.attachmentsViewOptions.objectId)return;const l=JSON.stringify(t.toJSON());E(t,this.columns.toArray(),this.activeSortOrders),t===i.attributeTableTemplate&&JSON.stringify(t.toJSON())!==l&&(i.attributeTableTemplate=t.clone())}async _refresh(){await super.refresh();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach((t,i)=>{t||this.highlightIds.remove(e[i])})}this.refreshPageCache();const t=this.attachmentsViewOptions;null!=t?.objectId&&(t.attachmentInfos=await this.store.getAttachmentsByObjectId(t.objectId,!0))}async _onLayerLoad(){const{layer:e,pageSize:t}=this;if(!e)return;e.parent&&I(e.parent)&&await e.parent.loadAll();const i=e.capabilities.query?.maxRecordCount,s=i&&i<t,n=s?i:t;s&&(this._logWarning("The value for 'pageSize' has been adjusted due to the provided layer's max record count."),this.pageSize=n),this.grid?.set("pageSize",n),this.store.load().catch(()=>{}),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const{_effectiveTableTemplate:e,_effectiveAttributeTableTemplate:t,layer:i}=this,s=e?.columnTemplates;if(!i)return;const n=this._generateColumnsFromColumnTemplates(i,s)??this._generateColumnsFromAttributeTableTemplate(i,t)??this._generateDefaultFieldColumns(i);n.length&&(this.attachmentsEnabled&&!n.some(e=>B(e))&&n.push(this._generateDefaultAttachmentsColumn(i)),this.relatedRecordsEnabled&&this.relationshipInfos.length&&!n.some(e=>G(e))&&n.push(...this._generateDefaultRelationshipColumns()),this.actionColumnConfig&&n.push(this._generateActionColumn()),n.sort((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0),this.columns.addMany(n))}_generateColumnsFromAttributeTableTemplate(e,t){if(!t)return null;const{elements:i,orderByFields:s}=t,l=v(e),r=[];r.push(...this._generateColumnsFromAttributeTableElements(e,i,s));const o=l.map(t=>{if(!t.fieldName||X(t.fieldName,r))return null;const{fieldName:i}=t,n=Y(e,i);return n?this._generateDefaultFieldColumn(e,n,{hidden:!0,orderByFields:s}):(this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null)}).filter(n);return r.push(...o),this.attachmentsEnabled&&ee(e)&&!r.some(e=>B(e))&&r.push(this._generateDefaultAttachmentsColumn(e,{hidden:!0})),this.relatedRecordsEnabled&&q(e)&&e.relationships?.forEach(({id:e},t)=>{const i=this.relationshipInfos.find(t=>t.relationshipId===e);i&&!r.some(t=>G(t)&&t.relationshipId===e)&&r.push(this._generateDefaultRelationshipColumn({hidden:!0,info:i,index:t}))}),r.length?r:null}_generateColumnsFromAttributeTableElements(e,t,i){return t?.map((t,s)=>{switch(t.type){case"field":return this._createFieldColumnFromElement({layer:e,element:t,orderByFields:i});case"group":return this._createGroupColumnFromElement({layer:e,element:t,orderByFields:i});case"attachment":return this._createAttachmentColumnFromElement({layer:e,element:t,index:s});case"relationship":return this._createRelationshipColumnFromElement({element:t,index:s})}}).filter(e=>!!e)??[]}_createFieldColumnFromElement(e){const{layer:t,element:i,orderByFields:s}=e,{fieldName:n}=i;if(null==n)return this._logTemplateWarning("A valid 'fieldName' must be provided."),null;const l=Y(t,n);if(!l)return this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null;const{description:r,label:o}=i,a=s?.findIndex(({field:e})=>e&&e===n)??-1,d=a>-1?s?.at(a)?.order:void 0,h=a>-1?a:void 0,{grid:m,messages:c,messagesCommon:u,messagesURIUtils:p,store:g,view:b}=this;return new j({description:r,direction:d,field:l,fieldName:n,grid:m,initialSortPriority:h,label:o,layer:t,messages:c,messagesCommon:u,messagesURIUtils:p,store:g,view:b,onShowPromptCallback:this._onShowPromptCallback})}_createGroupColumnFromElement(e){const{layer:t,element:i,orderByFields:s}=e,{description:n,label:l}=i;if(!l)return this._logTemplateWarning("Group columns require a label."),null;if(!i.elements.length)return this._logTemplateWarning("Group columns require child columns."),null;const{grid:r,messages:o,messagesCommon:a,messagesURIUtils:d,store:h}=this;return new V({columns:this._generateColumnsFromAttributeTableElements(t,i.elements,s),description:n,grid:r,label:l,messages:o,messagesCommon:a,messagesURIUtils:d,store:h})}_createAttachmentColumnFromElement(e){if(!this.attachmentsEnabled)return void this._logTemplateWarning("The 'attachmentsEnabled' property is currently false.");const{layer:t,element:i,index:s}=e,{description:n,label:l}=i,{grid:r,messages:o,messagesCommon:a,messagesURIUtils:d,store:h}=this;return new x({description:n,fieldName:`${K.attachments}-${s}`,grid:r,label:l,layer:t,messages:o,messagesCommon:a,messagesURIUtils:d,store:h,onShowAttachments:e=>this._onShowAttachments(e)})}_createRelationshipColumnFromElement(e){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{element:t,index:i}=e,{description:s,label:n,relationshipId:l}=t,r=this.relationshipInfos.find(e=>e.relationshipId===l);if(!r)return this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id."),null;const{grid:o,messages:a,messagesCommon:d,messagesURIUtils:h,store:m}=this;return new R({description:s,fieldName:`${K.relationship}-${l}-${i}`,grid:o,label:n,messages:a,messagesCommon:d,messagesURIUtils:h,relationshipId:l,store:m,layer:r.relatedLayer,relatedLayer:r.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateColumnsFromColumnTemplates(e,t){const{grid:i,messages:s,messagesCommon:n,messagesURIUtils:l,store:r,view:o}=this;if(!t?.length)return null;const a=[];return t.forEach((t,d)=>{const{autoWidth:h,description:m,direction:c,flexGrow:u,fieldName:p,formatFunction:g,frozen:b,frozenToEnd:f,icon:y,iconText:T,initialSortPriority:w,invalid:C,label:I,labelTooltipText:v,menuConfig:_,resizable:E,sortable:S,textAlign:A,textWrap:F,timeZone:x,type:R,width:P}=t;if(!R)return void this._logTemplateWarning("Property 'type' is missing from the provided template.");if(b&&f)return void this._logTemplateWarning("Properties 'frozen' and 'frozenToEnd' cannot both be true for the same column.");const U=!1===t.visible;if("group"===R){if(!t.columnTemplates?.length)return void this._logTemplateWarning("Group columns must contain column templates.");if(!t.label)return void this._logTemplateWarning("Group columns require a label.");const r=this._generateColumnsFromColumnTemplates(e,t.columnTemplates),o=U||this._isFieldHidden(t.label);a.push(new V({autoWidth:h,columns:r,description:m,flexGrow:u,frozen:b,frozenToEnd:f,grid:i,hidden:o,icon:y,iconText:T,invalid:C,label:I,labelTooltipText:v,menuConfig:_,messages:s,messagesCommon:n,messagesURIUtils:l,resizable:E,textAlign:A,textWrap:F,timeZone:x,width:P}))}else if("attachment"===R){if(!this.attachmentsEnabled)return void this._logTemplateWarning("Attachment columns require attachments to be enabled on the table.");a.push(this._generateAttachmentsColumnFromTemplate(e,t,d))}else if("relationship"===R){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{relationshipId:e}=t;if(null==e)return void this._logTemplateWarning("Property 'relationshipId' is missing from the provided template.");const i=this.relationshipInfos.find(t=>t.relationshipId===e);if(!i)return void this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id.");a.push(this._generateRelationshipColumnFromTemplate(i,t,d))}else if(!p)return void this._logTemplateWarning("Value for 'fieldName' property was missing from the provided template.");const z=U||this._isFieldHidden(p);if("column"===R)a.push(new O({autoWidth:h,description:m,direction:c,fieldName:p,flexGrow:u,formatFunction:g,frozen:b,frozenToEnd:f,grid:i,hidden:z,icon:y,iconText:T,initialSortPriority:w,invalid:C,label:I,labelTooltipText:v,menuConfig:_,messages:s,messagesCommon:n,messagesURIUtils:l,resizable:E,sortable:S,store:r,textAlign:A,textWrap:F,timeZone:x,width:P}));else if("field"===R){const d=Y(e,t.fieldName);if(!d)return void this._logTemplateWarning("A valid 'field' could not be found for the provided template.");const{editable:p,required:R}=t;a.push(new j({autoWidth:h,description:m,direction:c,editable:p,field:d,fieldName:d.name,flexGrow:u,formatFunction:g,frozen:b,frozenToEnd:f,grid:i,hidden:z,icon:y,iconText:T,initialSortPriority:w,invalid:C,label:I,labelTooltipText:v,layer:e,messages:s,messagesCommon:n,messagesURIUtils:l,menuConfig:_,required:R,resizable:E,sortable:S,store:r,template:t,textAlign:A,textWrap:F,timeZone:x,width:P,view:o,onShowPromptCallback:this._onShowPromptCallback}))}}),a.length?a:null}_generateDefaultFieldColumns(e){return e.fields?.map(t=>this._generateDefaultFieldColumn(e,t)).filter(n)??[]}_generateDefaultFieldColumn(e,t,i){const{grid:s,messages:n,messagesCommon:l,messagesURIUtils:r,store:o,view:a}=this;if(!t.visible||"geometry"===t.type)return null;const d=i?.orderByFields,h=t.name,m=d?.findIndex(({field:e})=>e&&e===h)??-1,c=m>-1?d?.at(m)?.order:void 0,u=m>-1?m:void 0;return new j({direction:c,field:t,fieldName:h,grid:s,hidden:i?.hidden||this._isFieldHidden(h),initialSortPriority:u,layer:e,messages:n,messagesCommon:l,messagesURIUtils:r,store:o,view:a,onShowPromptCallback:this._onShowPromptCallback})}_generateAttachmentsColumnFromTemplate(e,t,i){const{grid:s,messages:n,messagesCommon:l,messagesURIUtils:r,store:o}=this,{attachmentsViewEnabled:a,autoWidth:d,description:h,flexGrow:m,fieldName:c,formatFunction:u,frozen:p,frozenToEnd:g,icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:C,resizable:I,textAlign:v,textWrap:_,thumbnailAppearance:E,thumbnailCount:S,thumbnailIconScale:A,thumbnailsEnabled:F,timeZone:j,width:R}=t;return new x({attachmentsViewEnabled:a,autoWidth:d,description:h,fieldName:`${K.attachments}-${i}`,flexGrow:m,formatFunction:u,frozen:p,frozenToEnd:g,grid:s,hidden:!1===t.visible||this._isFieldHidden(T)||this._isFieldHidden(c),icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,layer:e,menuConfig:C,messages:n,messagesCommon:l,messagesURIUtils:r,resizable:I,store:o,textAlign:v,textWrap:_,thumbnailAppearance:E,thumbnailCount:S,thumbnailIconScale:A,thumbnailsEnabled:F,timeZone:j,width:R,onShowAttachments:e=>this._onShowAttachments(e)})}_generateDefaultAttachmentsColumn(e,t){const{grid:i,messages:s,messagesCommon:n,messagesURIUtils:l,store:r}=this,o=K.attachments;return new x({fieldName:o,grid:i,hidden:t?.hidden||this._isFieldHidden(o),layer:e,messages:s,messagesCommon:n,messagesURIUtils:l,store:r,onShowAttachments:e=>this._onShowAttachments(e)})}_generateRelationshipColumnFromTemplate(e,t,i){const{grid:s,messages:n,messagesCommon:l,messagesURIUtils:r,store:o}=this,{autoWidth:a,collapsed:d,description:h,flexGrow:m,fieldName:c,formatFunction:u,frozen:p,frozenToEnd:g,icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:C,relationshipId:I,resizable:v,textAlign:_,textWrap:E,timeZone:S,width:A}=t;return new R({autoWidth:a,collapsed:d,description:h,fieldName:`${K.relationship}-${I}-${i}`,flexGrow:m,formatFunction:u,frozen:p,frozenToEnd:g,grid:s,hidden:!1===t.visible||this._isFieldHidden(T)||this._isFieldHidden(c),icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:C,messages:n,messagesCommon:l,messagesURIUtils:r,relationshipId:I,resizable:v,store:o,textAlign:_,textWrap:E,timeZone:S,width:A,layer:e.relatedLayer,relatedLayer:e.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateDefaultRelationshipColumns(){const{relationshipInfos:e,relationshipColumnConfigs:t}=this,i=[];return e?.length?(t?t.forEach((t,s)=>{const{relationshipId:n}=t,l=e.find(e=>e.relationshipId===n);l&&i.push(this._generateDefaultRelationshipColumn({config:t,index:s,info:l}))}):e.forEach((e,t)=>i.push(this._generateDefaultRelationshipColumn({index:t,info:e}))),i):i}_generateDefaultRelationshipColumn(e){const{config:t,hidden:i,index:s,info:n}=e,{grid:l,messages:r,messagesCommon:o,messagesURIUtils:a,store:d}=this,{relationshipId:h}=n;return new R({...t,fieldName:`${K.relationship}-${h}-${s}`,grid:l,hidden:!!i,messages:r,messagesCommon:o,messagesURIUtils:a,layer:n.relatedLayer,relatedLayer:n.layer,relationshipId:h,store:d,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateActionColumn(){const e=this.actionColumnConfig,t=!0!==e?.frozen&&(e?.frozenToEnd??!0);return new F({hidden:this._isFieldHidden(K.action),store:this.store,...e,frozenToEnd:t})}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some(e=>e.toLowerCase()===t)}_syncSelection(){const{layer:e}=this;A(e)?this.highlightIds.items=this.effectiveSelectionManager.getSelection(e)??[]:this.highlightIds.removeAll()}_addToSelection(e){const t=this.layer;A(t)&&this.effectiveSelectionManager.add(t,e)}_removeFromSelection(e){const t=this.layer;A(t)&&this.effectiveSelectionManager.remove(t,e)}async _onHighlightIdsChange(e){const{added:t,removed:i}=e,{attachmentsViewOptions:s}=this;if(this._removeFromSelection(i),this._addToSelection(t),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray()),null!=s.objectId){const e=this.highlightIds.at(0);if(null!=e){const t=await this.store.getAttachmentsByObjectId(e,!0);s.set({attachmentInfos:t,objectId:e,mode:t.length?"list":"file"}),this.getFeatureTitle(e)}}}_syncTableParentSelection(e){const{tableParent:t}=this;t&&null!=e&&t.highlightIds.add(e)}_onShowRelatedTable(e){const{highlightIds:t}=this,{objectId:i}=e;t.removeAll(),t.add(i),this.showRelatedTableCallback?this.showRelatedTableCallback(e):this.emit("show-related-table",e)}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.refreshPageCache()}_drainColumns(){this.columns.drain(e=>!e.destroyed&&e.destroy())}_showAllRelatedTables(e){const t=e.layer;if(!t)return;const i=this._getDefaultLayerDisplayField(t);e.set({relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForShowAllTablesView(e,i)});const s=e.hiddenFields;s.includes(K.action)||s.add(K.action),s.includes(K.attachments)||s.add(K.attachments)}_hideAllRelatedTables(e){const{layer:t,relationship:i}=e;if(t&&null!=i?.id)if(null!=e.attachmentsViewOptions.objectId){const i=this._getDefaultLayerDisplayField(t);e.set({multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],showAllRelatedTables:!1,tableTemplateOverride:this._getTableTemplateForAttachmentsView(i)})}else e.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:te(t,i.id),showAllRelatedTables:!1,tableTemplateOverride:null}),e.hiddenFields.removeMany([K.action,K.attachments])}_getTableTemplateForRelatedTableView(e,t,i){return new $({columnTemplates:[new D({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([s,n])=>({selected:s===t,label:n||s,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForRelatedTableView(e,s,i)}}))},resizable:!1}),new H({autoWidth:!1,collapsed:!0,flexGrow:0,label:"",resizable:!1,relationshipId:i,width:ne})]})}_getTableTemplateForShowAllTablesView(e,t){const i=[new D({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([i,s])=>({selected:i===t,label:s||i,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForShowAllTablesView(e,i)}}))},resizable:!1})];return null!=e.attachmentsViewOptions.objectId&&i.push(new z({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:ne})),new $({columnTemplates:i})}async _onShowPromptCallback(e){const{column:t,objectId:i,oldValue:s,value:n}=e,{_subtypes:l,layer:r}=this;if(!r||!l.length)return void t.cancel();const o=l.find(e=>e.code===n);if(!o)return void t.cancel();const a=Promise.withResolvers(),d=this._createSubtypeEditPrompt(s,o,a),h=!!r.parent&&this.autoSaveEnabled;try{this.showPrompt(d);const e=await a.promise,s=[{fieldName:t.fieldName,value:n}];switch(e){case"update-fields":for(const[e,t]of Object.entries(o.defaultValues))null!=t&&s.push({fieldName:e,value:t});await t.updateItems({objectId:i,updates:s}),h&&this.refresh();break;case"keep-existing":await t.updateItems({objectId:i,updates:s}),h&&this.refresh();break;case"undo":t.cancel()}}finally{this.clearPrompt()}}_createSubtypeEditPrompt(e,t,s){const{_subtypes:n,messages:l,messagesCommon:r}=this,o=n.find(t=>t.code===e)?.name??`${e}`;let a="update-fields";const d=[{label:l.subtypes.useDefaultValuesOption,value:"update-fields"},{label:l.subtypes.keepCurrentValuesOption,value:"keep-existing"}];return{context:"info",title:l.subtypes.changeWarningTitle,message:i(l.subtypes.changeWarning,{originalType:o,newType:t.name}),radios:d,defaultRadioSelection:"update-fields",onRadioSelection:e=>{a=e},actions:{primary:{label:r.apply,action:()=>s.resolve(a),type:"positive"},secondary:{label:r.cancel,type:"neutral",action:()=>s.resolve("undo")}},cancel:()=>s.reject()}}_onShowAttachments({objectId:e}){this.hasPendingEdits||(this.attachmentsViewOptions.objectId=e)}_getTableTemplateForAttachmentsView(e){return new $({columnTemplates:[new D({fieldName:e,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(this).map(([t,i])=>({selected:t===e,label:i||t,clickFunction:()=>{this.tableTemplateOverride=this._getTableTemplateForAttachmentsView(t)}}))},resizable:!1}),new z({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:ne})]})}_extractFieldColumnInfosFromTableTemplate(e){const t=e??this,{layer:i,tableTemplate:s}=t;return s?s.columnTemplates.filter(({type:e})=>"field"===e||"column"===e).map(({fieldName:e,label:t})=>{if(null!=t&&""!==t)return[e,t];const s=i?.fieldsIndex.get(e);return[e,s&&y(s,i)]}):i?.fields.map(e=>[e.name,y(e,i)])??[]}_getDefaultLayerDisplayField(e){const{displayField:t,objectIdField:i}=e;return t&&""!==t.trim()?t:i||(e.fields.length?e.fields[0].name:"")}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex(e=>e.frozenToEnd);return e>-1?e:void 0}_logWarning(e,t){t?a.getLogger(this).warnOnce(e):a.getLogger(this).warn(e)}_logTemplateWarning(e){this._logWarning(`${e} Skipped generating a column using the provided template.`,!0)}_onCellInteraction(e){null!=e&&null!=this.attachmentsViewOptions.objectId&&this.highlightIds.add(e)}};e([b()],le.prototype,"_defaultHiddenFields",null),e([b()],le.prototype,"_effectiveTableTemplate",null),e([b()],le.prototype,"_effectiveAttributeTableTemplate",null),e([b()],le.prototype,"_subtypes",null),e([b()],le.prototype,"activeFilters",null),e([b({readOnly:!0})],le.prototype,"activeSortOrders",null),e([b()],le.prototype,"allRelatedTablesVisible",null),e([b()],le.prototype,"attachmentsColumns",null),e([b()],le.prototype,"attachmentsEnabled",null),e([b()],le.prototype,"attachmentsViewOptions",void 0),e([b({type:_})],le.prototype,"attributeTableTemplate",void 0),e([b()],le.prototype,"autoRefreshEnabled",void 0),e([b()],le.prototype,"autoSaveEnabled",null),e([b()],le.prototype,"cachedPageCount",null),e([b()],le.prototype,"canAddRelatedFeature",null),e([b()],le.prototype,"clearPrompt",null),e([b({readOnly:!0})],le.prototype,"columns",void 0),e([b()],le.prototype,"dataProvider",void 0),e([b()],le.prototype,"defaultSelectionManager",null),e([b()],le.prototype,"definitionExpression",null),e([b()],le.prototype,"effectiveSelectionManager",null),e([b()],le.prototype,"effectiveTimeExtent",null),e([b()],le.prototype,"effectiveWhere",null),e([b()],le.prototype,"fieldColumns",null),e([b()],le.prototype,"filterByViewExtent",null),e([b()],le.prototype,"filterByLayerScaleRange",null),e([b({types:T})],le.prototype,"filterGeometry",null),e([b()],le.prototype,"filterBySelectionEnabled",null),e([b({readOnly:!0})],le.prototype,"grid",void 0),e([b()],le.prototype,"hasContingentValues",null),e([b()],le.prototype,"hasInvalidPendingEdits",null),e([b()],le.prototype,"hasPendingEdits",null),e([b()],le.prototype,"hiddenFields",null),e([b()],le.prototype,"highlightEnabled",null),e([b()],le.prototype,"initialSize",null),e([b()],le.prototype,"isQueryingOrSyncing",null),e([b()],le.prototype,"isSyncingAttachments",null),e([b()],le.prototype,"layer",null),e([b()],le.prototype,"layers",void 0),e([b()],le.prototype,"layerFieldConfigurations",null),e([b()],le.prototype,"layerView",null),e([b()],le.prototype,"menuConfig",void 0),e([b()],le.prototype,"messages",void 0),e([b(),se("esri/t9n/common")],le.prototype,"messagesCommon",void 0),e([b(),se("esri/core/t9n/Units")],le.prototype,"messagesUnits",void 0),e([b(),se("esri/widgets/support/t9n/uriUtils")],le.prototype,"messagesURIUtils",void 0),e([b()],le.prototype,"outFields",null),e([b()],le.prototype,"pendingEditsCount",null),e([b()],le.prototype,"prompt",void 0),e([b()],le.prototype,"relatedRecordsEnabled",null),e([b()],le.prototype,"relatedTable",null),e([b()],le.prototype,"relatedTableHasContingentValues",null),e([b()],le.prototype,"relatedTables",void 0),e([b()],le.prototype,"relationship",null),e([b()],le.prototype,"relationshipColumnConfigs",void 0),e([b()],le.prototype,"relationshipColumns",null),e([b()],le.prototype,"relationshipConfig",null),e([b()],le.prototype,"relationshipInfos",null),e([b()],le.prototype,"relationships",null),e([b()],le.prototype,"returnGeometryEnabled",null),e([b()],le.prototype,"returnMEnabled",null),e([b()],le.prototype,"returnZEnabled",null),e([b()],le.prototype,"selectionManager",null),e([b()],le.prototype,"selectionSource",null),e([b()],le.prototype,"showAllRelatedTables",null),e([b()],le.prototype,"showPrompt",null),e([b()],le.prototype,"showRelatedTableCallback",void 0),e([b({readOnly:!0,type:k})],le.prototype,"store",void 0),e([b()],le.prototype,"supportsAttachments",null),e([b()],le.prototype,"supportsAddAttachments",null),e([b()],le.prototype,"supportsDeleteAttachments",null),e([b()],le.prototype,"supportsResizeAttachments",null),e([b()],le.prototype,"supportsUpdateAttachments",null),e([b()],le.prototype,"syncTemplateOnChangesEnabled",void 0),e([b()],le.prototype,"syncViewSelection",null),e([b()],le.prototype,"tableController",void 0),e([b()],le.prototype,"tableParent",void 0),e([b({type:$})],le.prototype,"tableTemplate",void 0),e([b()],le.prototype,"tableTemplateOverride",void 0),e([b({type:S})],le.prototype,"timeExtent",null),e([b()],le.prototype,"timeZone",null),e([b()],le.prototype,"view",null),e([b()],le.prototype,"viewTimeEnabled",null),le=e([f("esri.widgets.FeatureTable.FeatureTableViewModel")],le);const re=le;export{re as default};
@@ -60,6 +60,12 @@ export default class FeatureStore extends Accessor {
60
60
  * @internal
61
61
  */
62
62
  accessor autoSaveEnabled: boolean;
63
+ /**
64
+ * Indicates the number of pages currently cached in the store.
65
+ *
66
+ * @internal
67
+ */
68
+ get cachedPageCount(): number;
63
69
  /**
64
70
  * Indicates whether the table supports adding a related record based on the current relationship
65
71
  * configuration. This accounts for whether table is currently configured to show related features.
@@ -563,6 +569,14 @@ export default class FeatureStore extends Accessor {
563
569
  * @internal
564
570
  */
565
571
  getAttachmentsByObjectId(objectId: ObjectId, force?: boolean): Promise<AttachmentInfo[]>;
572
+ /**
573
+ * Returns cached features for a specific page index. If no cached features are found for the specified page, undefined is returned.
574
+ *
575
+ * @param pageIndex - The index of the page for which to retrieve cached features.
576
+ * @returns An array of FeatureStoreItem objects representing the cached features for the specified page, or undefined if no cached features are found for that page.
577
+ * @internal
578
+ */
579
+ getCachedFeaturesByPageIndex(pageIndex: number): FeatureStoreItem[] | undefined;
566
580
  /**
567
581
  * Returns a string representing the provided feature. If the feature does not exist locally an extra query is
568
582
  * made to the server to retrieve the feature information. Additionally, if 'force' is true, the store will query the
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import i from"../../../core/Accessor.js";import{equals as r,isSome as s}from"../../../core/arrayUtils.js";import{createTask as n}from"../../../core/asyncUtils.js";import a from"../../../core/Collection.js";import o from"../../../core/Error.js";import{clone as l}from"../../../core/lang.js";import h from"../../../core/Logger.js";import{getOrCreateMapValue as d}from"../../../core/MapUtils.js";import{removeMaybe as u,abortMaybe as p}from"../../../core/maybe.js";import{debounce as c,ignoreAbortErrors as y,throwIfAborted as g}from"../../../core/promiseUtils.js";import _ from"../../../core/ReactiveMap.js";import{watch as f,when as m,syncAndInitial as b,sync as E}from"../../../core/reactiveUtils.js";import{property as v,subclass as I}from"../../../core/accessorSupport/decorators.js";import{geometryTypes as C}from"../../../geometry/support/typeUtils.js";import{isFeatureLayer as w,isSubtypeGroupLayer as F,isSubtypeSublayer as O}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as A}from"../../../layers/support/timeSupport.js";import j from"../../../rest/support/AttachmentQuery.js";import S from"../../../rest/support/RelationshipQuery.js";import q from"../../../time/TimeExtent.js";import R from"../../../views/SelectionManager.js";import{temporaryHighlightName as M}from"../../../views/support/HighlightDefaults.js";import{highlightsSupported as V}from"../../../views/support/layerViewUtils.js";import{isSelectableLayerWithObjectIds as L,isSelectableLayer as B}from"../../../views/support/selectionUtils.js";import{isIFeatureTableSupportedLayerWithAttachments as W,isIFeatureTableSupportedLayerWithAttachmentsEditing as H,isIFeatureTableSupportedLayerWithEditing as P,isIFeatureTableSupportedLayerWithRelationships as x,isPageIndexValid as z,findRelatedLayer as Q}from"./tableUtils.js";import{ContingentValuesManager as U}from"../../support/ContingentValuesManager.js";let T=class extends i{constructor(e){super(e),this._attachmentsOperationQueue=new a,this._contingentValuesManager=new U,this._defaultOutFields=["*"],this._editOperationQueue=new a,this.featureTitleMap=new _,this._loaded=!1,this._loadController=null,this._loadDebounced=c(()=>this._load()),this._loadError=!1,this._objectIdCache=new a,this._pendingEditsCache=new _,this._queryOperationInfos=new _,this._refreshDebounced=c(()=>this._refresh()),this._size=0,this._temporaryHighlight=null,this._temporaryHighlightAbortController=null,this.attachmentsEnabled=!1,this.autoSaveEnabled=!0,this.defaultSelectionManager=new R,this.editingEnabled=!1,this.failures=new a,this.filterByViewExtent=!1,this.filterByLayerScaleRange=!1,this.filterGeometry=null,this.highlightEnabled=!0,this.initialSize=null,this.layer=null,this.maxSize=null,this.objectIds=null,this.outFields=null,this.pageCache=new _,this.pageSize=50,this.paginationEnabled=!1,this.relationshipConfig=null,this.relatedRecordsEnabled=!1,this.returnGeometry=!1,this.returnZ=!1,this.returnM=!1,this.selectionManager=null,this.sortOrders=[],this.syncViewSelection=!1,this.temporaryHighlightId=void 0,this.timeExtent=null,this.timeZone=null,this.view=null,this.viewTimeEnabled=!1,this.where=null}initialize(){this.addHandles([f(()=>[this._visibleAtCurrentScale,this.effectiveTimeExtent,this.effectiveWhere,this.filterGeometry,this.layer,this.objectIds,this.outFields,this.pageSize,this.relationshipConfig,this.returnGeometry,this.returnM,this.returnZ],()=>this._reset()),f(()=>this.orderByFields,()=>this._clearCaches(),{equals:r}),m(()=>this.attachmentsEnabled,()=>this._reset()),m(()=>this.relatedRecordsEnabled,()=>this._reset()),f(()=>this._layerWithContingentValues,e=>{const t=this._contingentValuesManager;e&&!t.layers.includes(e)&&t.layers.add(e)}),f(()=>[this.view?.extent,this.view?.stationary,this.filterByViewExtent],([e,t,i])=>{i&&(e?t&&(this.filterGeometry=e):this.filterGeometry=null)},b),f(()=>this.maxSize,(e,t)=>{0===t&&this._reset()}),f(()=>[this.layer,this.view],()=>this.syncSelectionSources(),b),f(()=>this.highlightEnabled,e=>this.defaultSelectionManager.highlightEnabled=e,b),f(()=>this.temporaryHighlightId,e=>{this._temporaryHighlight=u(this._temporaryHighlight?.handle),this._temporaryHighlightAbortController?.abort(),this._temporaryHighlightAbortController=new AbortController;const t=this._syncTemporaryHighlight(e,this._temporaryHighlightAbortController.signal);y(this.view?.addUpdatingPromise(t)??t)},E)])}destroy(){this.layer=null,this.itemCache.destroy(),this.failures.destroy(),this.defaultSelectionManager.destroy(),this._temporaryHighlight=u(this._temporaryHighlight?.handle),this._temporaryHighlightAbortController=p(this._temporaryHighlightAbortController)}get _capabilities(){const{layer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _canSavePendingEdits(){return this.supportsEditing&&this.hasPendingEdits&&!this.hasInvalidPendingEdits}get _effectiveReturnZ(){return this.returnZ&&this.supportsZ}get _effectiveReturnM(){return this.returnM&&this.supportsM}get _layerWithAttachments(){const{layer:e}=this;return e&&this._capabilities&&this.attachmentsEnabled&&this.supportsAttachments&&W(e)?e:null}get _layerWithAttachmentsEditing(){const{_layerWithAttachments:e}=this;return e&&H(e)&&this.supportsEditing?e:null}get _layerWithContingentValues(){const{layer:e}=this;return w(e)||F(e)?e:null}get _layerWithEditing(){const e=this.layer;return P(e)&&this.supportsEditing?e:null}get _layerWithRelationships(){const e=this.layer;return x(e)&&this.supportsQueryRelated?e:null}get _pendingEditsAreInvalid(){const e=this._pendingEditsCache,t=this._layerWithContingentValues;if(!t)return!1;for(const i of e.keys()){const r=e.get(i),s=this._getFeatureWithPendingEdits(i,r);for(const e of r.changes.keys()){if(this._contingentValuesManager.getViolationForField(t,s,e))return!0}}return!1}get _relatedLayer(){return this.relationshipConfig?.relatedLayer}get _relatedLayerCapabilities(){const{_relatedLayer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _relatedLayerSupportsCacheHint(){return!!this._relatedLayerCapabilities?.queryRelated?.supportsCacheHint}get _relatedLayerSupportsQuery(){return!!this._relatedLayerCapabilities?.operations.supportsQuery}get _relatedLayerSupportsQueryRelated(){const{_relatedLayerCapabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get _sortedFieldNames(){return this.sortOrders.map(({fieldName:e})=>e)}get _subtypeCode(){return this.layer?.subtypeCode??null}get _subtypeField(){const{layer:e}=this;return F(e?.parent)?e.subtypeField:null}get _canUseRelatedLayer(){return!(!this._relatedLayerSupportsQuery||!this._relatedLayerSupportsQueryRelated)}get _shouldFilterByLayerScaleRange(){return!(!this.view||!this.filterByLayerScaleRange)}get _visibleAtCurrentScale(){return!(!this._shouldFilterByLayerScaleRange||!this.layerView?.visibleAtCurrentScale)}get canAddRelatedFeature(){const{state:e,relationship:t,supportsAdd:i,supportsEditing:r}=this;if("loaded"!==e||!t||!i||!r)return!1;const{cardinality:s,role:n}=t,a=this.size>0;return("one-to-one"!==s||!a)&&("one-to-many"!==s||"origin"!==n||!a)}get effectiveOutFields(){const{layer:e,outFields:t}=this;if(!e||!t?.length)return this._defaultOutFields;const i=[];t.forEach(t=>{const r=e.fieldsIndex.normalizeFieldName(t);r&&i.push(r)});const{objectIdField:r}=e,s=e.fieldsIndex.normalizeFieldName(r)??r;return s&&!i.includes(s)&&i.unshift(s),i}get effectiveSelectionManager(){const{layer:e,view:t}=this;return e&&this.syncViewSelection&&L(e)&&t?.selectionManager?.sources.includes(e)?t.selectionManager:this.selectionManager??this.defaultSelectionManager}get effectiveSize(){const{_size:e,maxSize:t}=this;return null!=t?Math.min(t,e):e}get effectiveTimeExtent(){const{layer:e,timeExtent:t,view:i,viewTimeEnabled:r}=this;if(t||!e)return t;if(!i||!r)return e.timeExtent??void 0;return A({datesInUnknownTimezone:e.datesInUnknownTimezone??void 0,timeExtent:e.timeExtent,timeInfo:e.timeInfo,timeOffset:e.timeOffset,useViewTime:e.useViewTime},i.timeExtent,this._get("effectiveTimeExtent"))??void 0}get effectiveWhere(){const{layer:e,where:t}=this;return null!=t&&""!==t?t:O(e)&&e.parent?.definitionExpression?e.parent.definitionExpression:e?.definitionExpression||"1=1"}get fieldsWithContingentValues(){return this._contingentValuesManager.getFieldsWithContingentValues(this.layer)}get hasContingentValues(){return this.fieldsWithContingentValues.size>0}get hasInvalidPendingEdits(){return this.hasPendingEdits&&this._pendingEditsAreInvalid}get hasPendingEdits(){return this.pendingEditsCount>0}get highlightableLayerView(){const e=this.layerView;return V(e)?e:null}get isQuerying(){return this._queryOperationInfos.size>0}get isSyncing(){return this.isSyncingFeatureEdits||this.isSyncingAttachmentEdits}get isSyncingAttachmentEdits(){return this._attachmentsOperationQueue.length>0}get isSyncingFeatureEdits(){return this._editOperationQueue.length>0}get itemCache(){return new a({items:[...this.pageCache.values()].flat()})}get layerView(){const{layer:e,view:t}=this;if(!e||!t)return null;const i="sublayer"===e.type||O(e)?e.parent:e;return t.allLayerViews.find(e=>e.layer===i)}get orderByFields(){const{_sortedFieldNames:e,layer:t,sortOrders:i}=this,r=i.filter(({fieldName:t,direction:i},r)=>e.indexOf(t)===r&&null!=i).map(({fieldName:e,direction:t})=>`${e} ${t?.toUpperCase()}`);if(t&&!r.length&&!t.objectIdField&&t.fields?.length){const e=t.fields.find(e=>e.name);if(e){const i=t.fieldsIndex.normalizeFieldName(e.name);i&&r.push(`${i} ASC`)}}return r}get pageCount(){const{effectiveSize:e,pageSize:t}=this;return 0===e||0===t?1:Math.ceil(e/t)}get pageIndex(){return this._get("pageIndex")||0}set pageIndex(e){const{pageCount:t}=this;z(e,t)&&this._set("pageIndex",e)}get pendingEditsCount(){let e=0;return this._pendingEditsCache.forEach(t=>e+=t.changes.size),e}get relationship(){const{relationshipConfig:e}=this;return null==e?.relationshipId?null:this.relationships?.find(t=>t.id===e.relationshipId)}get relationshipIds(){return this.relationships?.map(e=>e.id)??[]}get relationshipInfos(){const{_layerWithRelationships:e,relatedRecordsEnabled:t,relationships:i,view:r}=this,s=[];return t&&e?.loaded&&r?.map&&i?.length?(i.forEach(t=>{const i=Q(e,r,t);i&&(i.load().catch(()=>{}),s.push({layer:e,relatedLayer:i,relationshipId:t.id}))}),s):s}get relationships(){return this._layerWithRelationships?.relationships}get size(){return this._size}get state(){const{layer:e,_loaded:t,_loadError:i}=this;return!e||e.destroyed?"disabled":i||e.loadError?"error":this._loadController?"loading":"loaded"===e.loadStatus&&t?"loaded":"ready"}get supportsAdd(){return!!this._capabilities?.operations.supportsAdd}get supportsAddAttachments(){return!(!this._layerWithAttachmentsEditing||!this.supportsAdd&&!this.supportsUpdate)}get supportsAttachments(){const{_capabilities:e}=this;return!(!e?.data?.supportsAttachment||!e?.operations.supportsQueryAttachments)}get supportsCacheHint(){return!!this._capabilities?.query?.supportsCacheHint}get supportsCacheHintQueryRelated(){return!!this._capabilities?.queryRelated?.supportsCacheHint}get supportsDelete(){return!!this._capabilities?.operations.supportsDelete}get supportsEditing(){return!!this._capabilities?.operations.supportsEditing}get supportsM(){return!!this.layer?.hasM&&!!this._capabilities?.data?.supportsM}get supportsOrderBy(){return!!this._capabilities?.query?.supportsOrderBy}get supportsPagination(){return!!this._capabilities?.query?.supportsPagination}get supportsQuery(){return!!this._capabilities?.operations.supportsQuery}get supportsQueryRelated(){const{_capabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get supportsResizeAttachments(){const{_capabilities:e}=this;return!(!this.supportsAttachments||!e?.attachment?.supportsResize)}get supportsUpdate(){return!!this._capabilities?.operations.supportsUpdate}get supportsUpdateAttachments(){return!(!this._layerWithAttachmentsEditing||!this.supportsAdd&&!this.supportsUpdate)}get supportsZ(){return!!this.layer?.hasZ&&!!this._capabilities?.data?.supportsZ}async addAttachment(e,t){const{_layerWithAttachmentsEditing:i}=this;if(!i||!this.supportsAddAttachments)return{};const r=await this._queueAttachmentsOperation(e,()=>i.addAttachment(this._createBaseGraphic(i,e),t));return this._ensureArrayContent(r)}addPendingEdits(e){const t=this._ensureLayerAndUpdateSupport();this.editingEnabled?(this.autoSaveEnabled&&this._logWarning("store:pending-edit","Edit will be cached, but 'autoSaveEnabled' is true.",!0),this._stashPendingEdits(t,e)):this._logWarning("store:editing-disabled","Editing is disabled.")}async deleteAttachments(e,t){const{_layerWithAttachmentsEditing:i}=this;if(!i||!this.supportsUpdateAttachments||!t.length)return[];const r=await this._queueAttachmentsOperation(e,()=>i.deleteAttachments(this._createBaseGraphic(i,e),t));return this._ensureArray(r)}async deleteRowsByObjectId(e){const{_layerWithEditing:t}=this;if(!this.supportsDelete||!t)throw new o("store:delete-error","Delete is not supported.");const i=e.map(e=>this.getItemByObjectId(e)?.feature).filter(s),r=this._queueEditOperation(()=>t.applyEdits({deleteFeatures:i}));return e.forEach(e=>{this.featureTitleMap.delete(e),this._discardPendingEdit({objectId:e})}),r}discardPendingEdits(e){if(e?.length)e.forEach(e=>this._discardPendingEdit(e));else{for(const[e,t]of this._pendingEditsCache){const i=this.getItemByObjectId(e);i&&(i.feature=t.originalFeature)}this._pendingEditsCache.clear(),this._clearOptionsAndViolations()}}itemHasInvalidPendingEdits(e,t){if(!this.hasInvalidPendingEdits)return!1;const i=this._layerWithContingentValues,r=this._pendingEditsCache.get(e);if(!i||!r)return!1;const s=this._getFeatureWithPendingEdits(e,r),n=this._contingentValuesManager;return t?!!n.getViolationForField(i,s,t):!!n.getAllViolations(i,s)}itemHasPendingEdits(e,t){const i=this._pendingEditsCache.get(e);return!!i&&(!t||i.changes.has(t))}async getAttachmentsByObjectId(e,t){const i=this.getItemByObjectId(e)?.attachments??[];if(!i.length&&t){return(await this._queryAttachments([e]))[e]??[]}return i}getFieldValueOptions(e){return this._contingentValuesManager.getFieldValueOptions(e)}async getFeatureTitle(e,i=!1){const{layer:r}=this,s=this.featureTitleMap.get(e),n=`${e}`;if(!r)return s||n;if(s&&!i)return s;if(!("getFeatureTitle"in r)||!r.getFeatureTitle)return n;const a=this.getItemByObjectId(e);let o=a?.feature;o||(o=new t({attributes:{[r.objectIdField]:e},origin:r.graphicOrigin}));const l=await r.getFeatureTitle(o,{fetchMissingFields:!0,removeHTML:!0});return l?(this.featureTitleMap.set(e,l),l):n}getItemByObjectId(e){for(const t of this.pageCache.values())for(const i of t)if(i.objectId===e)return i}getItemIndexByObjectId(e){const{pageCache:t,pageSize:i}=this,r=t.entries();let s=-1;for(const[n,a]of r)if(a.some((t,r)=>{const a=t.objectId===e;return a&&(s=n*i+r),a}),s>-1)break;return s}async load(){await y(this._loadDebounced())}async queryPage(e){const{layer:t,state:i}=this;if(!t||"loaded"!==i||!this.supportsQuery||0===this.size||0===this.maxSize)return[];const{pageIndex:r}=e;if(!z(r,this.pageCount))return[];const s=e.pageSize??this.pageSize,n=r*s,a=n+s;return await y(this._query({layer:t,start:n,num:a,pageIndex:r,pageSize:s}))??[]}async refresh(){await y(this._refreshDebounced())}reset(){this._reset()}async savePendingEdits(){const e=this._ensureLayerAndUpdateSupport();if(!this.editingEnabled)return void this._logWarning("store:editing-disabled","Editing is disabled.");if(this.autoSaveEnabled&&this._logWarning("store:pending-edit","Edit will be cached, but 'autoSaveEnabled' is true.",!0),!this._canSavePendingEdits)return void this._logError("store:update-error","An error occurred. Unable to save pending edits.");const t=[];for(const[i]of this._pendingEditsCache){const e=this.getItemByObjectId(i);e?.feature&&t.push(e.feature)}(await this._update(e,t,!0)).updateFeatureResults.find(e=>e.error)&&this.discardPendingEdits(),this._clearOptionsAndViolations()}syncSelectionSources(){const{defaultSelectionManager:e,layer:t,view:i}=this;e.view=i,e.sources.removeAll(),B(t)&&(e.sources.items=[t])}async updateAttachment(e,t,i){const{_layerWithAttachmentsEditing:r}=this;if(!r||!this.supportsUpdateAttachments)return{};const s=await this._queueAttachmentsOperation(e,()=>r.updateAttachment(this._createBaseGraphic(r,e),t,i));return this._ensureArrayContent(s)}async updateItem(e){const t=this._ensureLayerAndUpdateSupport();if(!this.editingEnabled)return void this._logWarning("store:editing-disabled","Editing is disabled.");if(this.hasContingentValues){const t=e.updates.some(e=>this.fieldsWithContingentValues.has(e.fieldName)),i=this.itemHasPendingEdits(e.objectId);if(i||t){const t=this._layerWithContingentValues,r=this.getItemByObjectId(e.objectId)?.feature?.clone();if(r){const s=this._contingentValuesManager.getAllViolations(t,r);e.updates.forEach(({fieldName:e,value:i})=>{const s=t.getField(e);s&&(r.attributes[s.name]=i)});if(this._contingentValuesManager.validateContingencyConstraints(t,r).length||s.length||i)return this._stashPendingEdits(t,[e]),void this._contingentValuesManager.resetOptionsForLayer(t)}}}if(!this.autoSaveEnabled)return void this._stashPendingEdits(t,[e]);const{_sortedFieldNames:i}=this,r=e.updates.map(({fieldName:e})=>e),s=this._prepareEditsForUpdate([e]);!(await this._update(t,s)).updateFeatureResults.find(e=>e.error)&&r.some(e=>i.includes(e))&&this._clearCaches()}async verifyFeaturesByObjectId(e){const{layer:t,state:i}=this;if(!t||"loaded"!==i)return[];const{objectIdField:r}=t,s=await this._queryFeaturesByObjectId(e);return e.map(e=>s.some(t=>{const i=t.getObjectId()??t.attributes[r];return e===i}))}async _load(){const{layer:e}=this;if(this._reset(),!e)return;const t=new AbortController;this._loadController=t;try{if(await e.load(),e.parent&&F(e.parent)&&await e.parent.loadAll(),await e.when(),t.signal.aborted)return;let i=this.initialSize;if(this.initialSize=null,this._shouldFilterByLayerScaleRange&&(this._visibleAtCurrentScale||(i=0)),await y(this._refresh(t,i)),t.signal.aborted)return void(this._loadController=null);this._loaded=!0,this._loadController=null}catch(i){throw this._reset(),this._loadError=!0,this._logError("store:load-error","An error occurred."),i}}async _refresh(e,t){this._clearCaches();const i=e?.signal,r=await this._getSize(i,t),s=await this._queryAllObjectIds(i);i?.aborted||(this._size=r,this._objectIdCache.removeAll(),s?.length&&this._objectIdCache.addMany(s),this._syncPendingEdits())}async _queryAllObjectIds(e){return this.supportsPagination?void 0:await this._queryObjectIds(e)}_clearCaches(){this.pageCache.clear(),this._objectIdCache.removeAll()}_createBaseGraphic(e,i){const r=new t({attributes:{[e.objectIdField]:i}});return this._subtypeField&&null!=this._subtypeCode&&(r.attributes[this._subtypeField]=this._subtypeCode),r}_ensureArray(e){return Array.isArray(e)?e:[e]}_ensureArrayContent(e){return Array.isArray(e)?e[0]:e}_getObjectIdsForFeatures(e,t){return e.map(e=>e.getObjectId()??e.attributes[t.objectIdField])}_getObjectIdsForPage(e,t){const i=this._objectIdCache.toArray();return i.length>=e+t?i.slice(e,e+t):i.slice(e)}_logError(e,t){h.getLogger(this).error(e,t)}_logWarning(e,t,i=!1){i?h.getLogger(this).warnOnce(e,t):h.getLogger(this).warn(e,t)}_reset(){this._clearCaches(),this._pendingEditsCache.clear(),this.failures.removeAll(),this._attachmentsOperationQueue.removeAll(),this._editOperationQueue.removeAll(),this.featureTitleMap.clear(),this._loadController=p(this._loadController),this._queryOperationInfos.forEach(e=>e.controller.abort()),this._queryOperationInfos.clear(),this._temporaryHighlight=u(this._temporaryHighlight?.handle),this._temporaryHighlightAbortController=p(this._temporaryHighlightAbortController),this._loaded=!1,this._loadError=!1,this._size=0}async _getSize(e,t){return 0===this.maxSize?0:null!=t?t:await this._queryCount(e)}async _queryFeaturesByObjectId(e){const{layer:t}=this;if(!t||!this.supportsQuery)throw new o("store:query-error","Layer does not support query operation.");const{effectiveTimeExtent:i,effectiveWhere:r,orderByFields:s,supportsCacheHint:n,supportsOrderBy:a}=this,l=t.createQuery();l.where=r,l.timeExtent=i,l.returnGeometry=!1,l.objectIds=e.length?e:void 0,l.outFields=[t.objectIdField],a&&(l.orderByFields=s),n&&(l.cacheHint=!0);return(await t.queryFeatures(l)).features}async _syncTemporaryHighlight(e,t){const{highlightEnabled:i,highlightableLayerView:r}=this;r&&i&&null!=e&&(g(t),this._temporaryHighlight={id:e,handle:r.highlight(e,{name:M})})}_ensureLayerAndUpdateSupport(){const e=this._layerWithEditing;if(!e||!this.supportsUpdate)throw new o("store:update-error","Update is not supported.");return e}_stashPendingEdits(e,t){t.forEach(({objectId:t,updates:i})=>{const r=this.getItemByObjectId(t)?.feature;if(!r)throw new o("store:update-error","Feature with provided 'objectId' not found.");const s=r.clone(),n=d(this._pendingEditsCache,t,()=>({originalFeature:s,changes:new _}));i.forEach(({fieldName:t,value:i})=>{const s=e.getField(t);s?(n.changes.set(s.name,i),r.attributes[s.name]=i):this._logWarning("store:pending-edit-unknown-field","The provided field does not belong to this layer.")}),n.changes.size>0&&this._pendingEditsCache.set(t,n)})}_syncPendingEdits(){for(const[e,t]of this._pendingEditsCache){const i=this.getItemByObjectId(e)?.feature;if(i){const e=i.clone();for(const[r,s]of t.changes)i.attributes[r]=s;t.originalFeature=e}}}_getFeatureWithPendingEdits(e,t){let i=this.getItemByObjectId(e)?.feature;if(!i){i=t.originalFeature.clone();for(const[e,r]of t.changes)i.attributes[e]=r}return i}_discardPendingEdit({objectId:e,fieldName:t}){const i=this._pendingEditsCache.get(e);if(!i)return void this._logWarning("store:pending-edit-not-found","Could not find a pending edit with the given information");const r=this.getItemByObjectId(e);t?(r&&(r.feature.attributes[t]=i.originalFeature.attributes[t]),i.changes.delete(t),0===i.changes.size&&this._pendingEditsCache.delete(e)):(r&&(r.feature=i.originalFeature),this._pendingEditsCache.delete(e))}_clearOptionsAndViolations(){const{_layerWithContingentValues:e,_contingentValuesManager:t}=this;e&&(t.resetOptionsForLayer(e),t.resetViolationsForLayer(e))}_prepareEditsForUpdate(e){const i=[];return e.forEach(({objectId:e,updates:r})=>{const s=this.getItemByObjectId(e)?.feature;if(!s)return;const n=l(s.attributes);r.forEach(({fieldName:e,value:t})=>n[e]=t),i.push(new t({attributes:n,sourceLayer:s.sourceLayer}))}),i}_update(e,t,i=!1){const r=e.applyEdits({updateFeatures:t}).then(i=>{const{updateFeatureResults:r}=i,s=r.find(e=>!!e.error);if(s)throw s.error;return t.forEach(t=>{const i=t.getObjectId()??t.attributes[e.objectIdField],r=this.getItemByObjectId(i)?.feature;r&&(r.attributes=t.attributes),this.featureTitleMap.has(i)&&this.getFeatureTitle(i,!0)}),i});return this._queueEditOperation(()=>r,i)}_createFeatureStoreItems(e){const{attachments:t,features:i,layer:r,relatedRecords:s}=e,n=r.objectIdField;return i.map(e=>{const i=e.getObjectId()??e.attributes[n],a=[];e.layer||e.sourceLayer||(e.layer=r,e.sourceLayer=r);const o=this._pendingEditsCache.get(i);if(o){const t=e.clone(),i=o.changes;for(const[r,s]of i)e.attributes[r]=s;o.originalFeature=t}return s.forEach((e,t)=>{a.push({relationshipId:t,count:e[i]??0})}),{objectId:i,feature:e,attachments:t[i]??null,relatedRecords:a}})}async _query(e){const{pageIndex:t,refresh:i}=e;!0===i&&await this._refresh();const r=this.pageCache.get(t);if(r)return r;const s=this._queryOperationInfos.get(t);if(s)return s.task.promise;const n=new AbortController,a=await this._queryPage(e,n);return n.signal.aborted||this.pageCache.set(t,a),a}_queryAttachments(e,t){const{_layerWithAttachments:i,effectiveWhere:r}=this;return i?e.some(e=>"number"!=typeof e)?Promise.reject(new o("invalid-object-id","Only numeric object ids are valid to query attachments")):i.queryAttachments(new j({objectIds:e,where:r,returnMetadata:!0}),{signal:t}):Promise.resolve({})}async _queryCount(e){const{_relatedLayerSupportsCacheHint:t,layer:i,relationshipConfig:r,supportsCacheHint:s}=this;if(!i)return 0;if(r&&this._canUseRelatedLayer){const{objectId:i,relatedLayer:s,relationshipId:n}=r;return(await s.queryRelatedFeaturesCount(new S({cacheHint:t,relationshipId:n,objectIds:[i]}),{signal:e}))[i]??0}const{effectiveTimeExtent:n,effectiveWhere:a,filterGeometry:o,objectIds:l}=this,h=i.createQuery();return h.geometry=o,h.returnGeometry=!1,h.where=a,h.timeExtent=n,h.objectIds=l?.length?l:void 0,s&&(h.cacheHint=!0),i.queryFeatureCount(h,{signal:e})}async _queryFeatures(e,t){const{relationshipConfig:i}=this;if(i&&this._canUseRelatedLayer)return this._queryRelatedFeatures(e,i);const{_effectiveReturnM:r,_effectiveReturnZ:s,effectiveOutFields:n,effectiveTimeExtent:a,effectiveWhere:o,filterGeometry:l,objectIds:h,orderByFields:d,pageSize:u,returnGeometry:p,supportsCacheHint:c,supportsOrderBy:y,supportsPagination:g}=this,{layer:_,start:f}=e,m=h?.length,b=_.createQuery();b.returnGeometry=p,b.outFields=n,b.returnM=r,b.returnZ=s,g?(b.start=f,b.num=u,b.where=o,b.timeExtent=a,b.objectIds=m?h:void 0):b.objectIds=m?h:this._getObjectIdsForPage(f,u??0),y&&(b.orderByFields=d),l&&(b.geometry=l),c&&(b.cacheHint=!0);return(await _.queryFeatures(b,{signal:t})).features}_queryObjectIds(e){const{effectiveTimeExtent:t,effectiveWhere:i,filterGeometry:r,layer:s,objectIds:n,orderByFields:a,supportsCacheHint:o,supportsOrderBy:l}=this;if(!s)return Promise.resolve([]);const h=s.createQuery();return h.geometry=r,h.outFields=[s.objectIdField],h.returnGeometry=!1,h.where=i,h.timeExtent=t,h.objectIds=n?.length?n:void 0,l&&(h.orderByFields=a),o&&(h.cacheHint=!0),s.queryObjectIds(h,{signal:e})}async _queryPage(e,t){return this._queueQueryOperation(e.pageIndex,{controller:t,task:n(async()=>this._queryPageData(e,t))})}async _queryPageData(e,t){const{layer:i}=e,{signal:r}=t,s=await this._queryFeatures(e,r);if(r.aborted)return[];const n=this._getObjectIdsForFeatures(s,i),[a,o]=await Promise.all([this._queryAttachments(n,r),this._queryRelatedCounts(n,r)]);return t.signal.aborted?[]:this._createFeatureStoreItems({layer:i,features:s,attachments:a,relatedRecords:o})||[]}async _queryRelatedCounts(e,t){const{_layerWithRelationships:i,relationshipIds:r,supportsCacheHintQueryRelated:s}=this,n=new Map;return i&&e?.length&&r.length?(await Promise.allSettled(r.map(async r=>{const a=await i.queryRelatedFeaturesCount(new S({cacheHint:s,relationshipId:r,objectIds:e}),{signal:t});n.set(r,a)})),n):n}async _queryRelatedFeatures(e,t){const{_defaultOutFields:i,_effectiveReturnM:r,_effectiveReturnZ:s,orderByFields:n,pageSize:a,returnGeometry:o,supportsCacheHint:l}=this,{layer:h,start:d}=e,{objectId:u,relatedLayer:p,relationshipId:c}=t,y=h.createQuery(),g=new S({cacheHint:l,num:a,objectIds:[u],orderByFields:n,outFields:i,relationshipId:c,returnGeometry:o,returnM:r,returnZ:s,start:d,where:y.where??void 0}),_=await p.queryRelatedFeatures(g);return _[u]?.features||[]}_queueAttachmentsOperation(e,t){return this._attachmentsOperationQueue.push(t),t().then(async i=>{this._attachmentsOperationQueue.remove(t);const r=this._ensureArray(i),s=r.some(e=>e.error),n=this.getItemByObjectId(e);if(n&&(!s||r.length>1)){const t=await this._queryAttachments([e]);n.attachments=t[e]}return i}).catch(async i=>{this._logError("store:attachment-error","An error occurred.");const r={error:i,retry:()=>{this.failures.remove(r),this._queueAttachmentsOperation(e,t)},cancel:()=>this.failures.remove(r)};throw this.failures.add(r),this._attachmentsOperationQueue.remove(t),i})}_queueEditOperation(e,t=!1){return this._editOperationQueue.push(e),e().then(i=>(this._editOperationQueue.remove(e),t&&this._pendingEditsCache.clear(),i)).catch(t=>{this._logError("store:edit-error","An error occurred.");const i={error:t,retry:()=>{this.failures.remove(i),this._queueEditOperation(e)},cancel:()=>this.failures.remove(i)};throw this.failures.add(i),this._editOperationQueue.remove(e),t})}async _queueQueryOperation(e,t){this._queryOperationInfos.set(e,t);const i=await t.task.promise;return this._queryOperationInfos.delete(e),i}};e([v()],T.prototype,"_attachmentsOperationQueue",void 0),e([v({readOnly:!0})],T.prototype,"_capabilities",null),e([v()],T.prototype,"_canSavePendingEdits",null),e([v()],T.prototype,"_contingentValuesManager",void 0),e([v()],T.prototype,"_defaultOutFields",void 0),e([v()],T.prototype,"_editOperationQueue",void 0),e([v()],T.prototype,"_effectiveReturnZ",null),e([v()],T.prototype,"_effectiveReturnM",null),e([v()],T.prototype,"featureTitleMap",void 0),e([v({readOnly:!0})],T.prototype,"_layerWithAttachments",null),e([v({readOnly:!0})],T.prototype,"_layerWithAttachmentsEditing",null),e([v()],T.prototype,"_layerWithContingentValues",null),e([v({readOnly:!0})],T.prototype,"_layerWithEditing",null),e([v({readOnly:!0})],T.prototype,"_layerWithRelationships",null),e([v()],T.prototype,"_loaded",void 0),e([v()],T.prototype,"_loadController",void 0),e([v()],T.prototype,"_loadError",void 0),e([v()],T.prototype,"_objectIdCache",void 0),e([v()],T.prototype,"_pendingEditsCache",void 0),e([v()],T.prototype,"_pendingEditsAreInvalid",null),e([v()],T.prototype,"_queryOperationInfos",void 0),e([v({readOnly:!0})],T.prototype,"_relatedLayer",null),e([v({readOnly:!0})],T.prototype,"_relatedLayerCapabilities",null),e([v({readOnly:!0})],T.prototype,"_relatedLayerSupportsCacheHint",null),e([v()],T.prototype,"_relatedLayerSupportsQuery",null),e([v()],T.prototype,"_relatedLayerSupportsQueryRelated",null),e([v()],T.prototype,"_size",void 0),e([v()],T.prototype,"_sortedFieldNames",null),e([v()],T.prototype,"_subtypeCode",null),e([v()],T.prototype,"_subtypeField",null),e([v()],T.prototype,"_canUseRelatedLayer",null),e([v()],T.prototype,"_shouldFilterByLayerScaleRange",null),e([v()],T.prototype,"_visibleAtCurrentScale",null),e([v()],T.prototype,"attachmentsEnabled",void 0),e([v()],T.prototype,"autoSaveEnabled",void 0),e([v()],T.prototype,"canAddRelatedFeature",null),e([v()],T.prototype,"defaultSelectionManager",void 0),e([v()],T.prototype,"editingEnabled",void 0),e([v()],T.prototype,"effectiveOutFields",null),e([v()],T.prototype,"effectiveSelectionManager",null),e([v()],T.prototype,"effectiveSize",null),e([v()],T.prototype,"effectiveTimeExtent",null),e([v()],T.prototype,"effectiveWhere",null),e([v({readOnly:!0})],T.prototype,"failures",void 0),e([v()],T.prototype,"fieldsWithContingentValues",null),e([v()],T.prototype,"filterByViewExtent",void 0),e([v()],T.prototype,"filterByLayerScaleRange",void 0),e([v({types:C})],T.prototype,"filterGeometry",void 0),e([v()],T.prototype,"hasContingentValues",null),e([v()],T.prototype,"hasInvalidPendingEdits",null),e([v()],T.prototype,"hasPendingEdits",null),e([v()],T.prototype,"highlightEnabled",void 0),e([v()],T.prototype,"highlightableLayerView",null),e([v()],T.prototype,"initialSize",void 0),e([v({readOnly:!0})],T.prototype,"isQuerying",null),e([v({readOnly:!0})],T.prototype,"isSyncing",null),e([v({readOnly:!0})],T.prototype,"isSyncingAttachmentEdits",null),e([v({readOnly:!0})],T.prototype,"isSyncingFeatureEdits",null),e([v({readOnly:!0})],T.prototype,"itemCache",null),e([v()],T.prototype,"layer",void 0),e([v()],T.prototype,"layerView",null),e([v()],T.prototype,"maxSize",void 0),e([v()],T.prototype,"objectIds",void 0),e([v()],T.prototype,"orderByFields",null),e([v()],T.prototype,"outFields",void 0),e([v({readOnly:!0})],T.prototype,"pageCache",void 0),e([v()],T.prototype,"pageCount",null),e([v()],T.prototype,"pageIndex",null),e([v()],T.prototype,"pageSize",void 0),e([v()],T.prototype,"paginationEnabled",void 0),e([v()],T.prototype,"pendingEditsCount",null),e([v()],T.prototype,"relationship",null),e([v()],T.prototype,"relationshipConfig",void 0),e([v()],T.prototype,"relationshipIds",null),e([v()],T.prototype,"relationshipInfos",null),e([v()],T.prototype,"relationships",null),e([v()],T.prototype,"relatedRecordsEnabled",void 0),e([v()],T.prototype,"returnGeometry",void 0),e([v()],T.prototype,"returnZ",void 0),e([v()],T.prototype,"returnM",void 0),e([v()],T.prototype,"selectionManager",void 0),e([v({readOnly:!0})],T.prototype,"size",null),e([v()],T.prototype,"sortOrders",void 0),e([v({readOnly:!0})],T.prototype,"state",null),e([v()],T.prototype,"supportsAdd",null),e([v()],T.prototype,"supportsAddAttachments",null),e([v()],T.prototype,"supportsAttachments",null),e([v()],T.prototype,"supportsCacheHint",null),e([v()],T.prototype,"supportsCacheHintQueryRelated",null),e([v()],T.prototype,"supportsDelete",null),e([v()],T.prototype,"supportsEditing",null),e([v()],T.prototype,"supportsM",null),e([v()],T.prototype,"supportsOrderBy",null),e([v()],T.prototype,"supportsPagination",null),e([v()],T.prototype,"supportsQuery",null),e([v()],T.prototype,"supportsQueryRelated",null),e([v()],T.prototype,"supportsResizeAttachments",null),e([v()],T.prototype,"supportsUpdate",null),e([v()],T.prototype,"supportsUpdateAttachments",null),e([v()],T.prototype,"supportsZ",null),e([v()],T.prototype,"syncViewSelection",void 0),e([v()],T.prototype,"temporaryHighlightId",void 0),e([v({type:q})],T.prototype,"timeExtent",void 0),e([v()],T.prototype,"timeZone",void 0),e([v()],T.prototype,"view",void 0),e([v()],T.prototype,"viewTimeEnabled",void 0),e([v()],T.prototype,"where",void 0),T=e([I("esri.widgets.FeatureTable.support.FeatureStore")],T);const G=T;export{G as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{equals as i,isSome as s}from"../../../core/arrayUtils.js";import{createTask as n}from"../../../core/asyncUtils.js";import a from"../../../core/Collection.js";import o from"../../../core/Error.js";import{clone as l}from"../../../core/lang.js";import h from"../../../core/Logger.js";import{getOrCreateMapValue as d}from"../../../core/MapUtils.js";import{removeMaybe as u,abortMaybe as p}from"../../../core/maybe.js";import{debounce as c,ignoreAbortErrors as y,throwIfAborted as g}from"../../../core/promiseUtils.js";import _ from"../../../core/ReactiveMap.js";import{watch as f,when as m,syncAndInitial as b,sync as E}from"../../../core/reactiveUtils.js";import{property as v,subclass as C}from"../../../core/accessorSupport/decorators.js";import{geometryTypes as I}from"../../../geometry/support/typeUtils.js";import{isFeatureLayer as w,isSubtypeGroupLayer as F,isSubtypeSublayer as O}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as A}from"../../../layers/support/timeSupport.js";import j from"../../../rest/support/AttachmentQuery.js";import S from"../../../rest/support/RelationshipQuery.js";import q from"../../../time/TimeExtent.js";import R from"../../../views/SelectionManager.js";import{temporaryHighlightName as M}from"../../../views/support/HighlightDefaults.js";import{highlightsSupported as V}from"../../../views/support/layerViewUtils.js";import{isSelectableLayerWithObjectIds as L,isSelectableLayer as P}from"../../../views/support/selectionUtils.js";import{isIFeatureTableSupportedLayerWithAttachments as B,isIFeatureTableSupportedLayerWithAttachmentsEditing as W,isIFeatureTableSupportedLayerWithEditing as x,isIFeatureTableSupportedLayerWithRelationships as z,isPageIndexValid as H,findRelatedLayer as Q}from"./tableUtils.js";import{ContingentValuesManager as U}from"../../support/ContingentValuesManager.js";let T=class extends r{constructor(e){super(e),this._attachmentsOperationQueue=new a,this._contingentValuesManager=new U,this._defaultOutFields=["*"],this._editOperationQueue=new a,this.featureTitleMap=new _,this._loaded=!1,this._loadController=null,this._loadDebounced=c(()=>this._load()),this._loadError=!1,this._objectIdCache=new a,this._pendingEditsCache=new _,this._queryOperationInfos=new _,this._refreshDebounced=c(()=>this._refresh()),this._size=0,this._temporaryHighlight=null,this._temporaryHighlightAbortController=null,this.attachmentsEnabled=!1,this.autoSaveEnabled=!0,this.defaultSelectionManager=new R,this.editingEnabled=!1,this.failures=new a,this.filterByViewExtent=!1,this.filterByLayerScaleRange=!1,this.filterGeometry=null,this.highlightEnabled=!0,this.initialSize=null,this.layer=null,this.maxSize=null,this.objectIds=null,this.outFields=null,this.pageCache=new _,this.pageSize=50,this.paginationEnabled=!1,this.relationshipConfig=null,this.relatedRecordsEnabled=!1,this.returnGeometry=!1,this.returnZ=!1,this.returnM=!1,this.selectionManager=null,this.sortOrders=[],this.syncViewSelection=!1,this.temporaryHighlightId=void 0,this.timeExtent=null,this.timeZone=null,this.view=null,this.viewTimeEnabled=!1,this.where=null}initialize(){this.addHandles([f(()=>[this._visibleAtCurrentScale,this.effectiveTimeExtent,this.effectiveWhere,this.filterGeometry,this.layer,this.objectIds,this.outFields,this.pageSize,this.relationshipConfig,this.returnGeometry,this.returnM,this.returnZ],()=>this._reset()),f(()=>this.orderByFields,()=>this._clearCaches(),{equals:i}),m(()=>this.attachmentsEnabled,()=>this._reset()),m(()=>this.relatedRecordsEnabled,()=>this._reset()),f(()=>this._layerWithContingentValues,e=>{const t=this._contingentValuesManager;e&&!t.layers.includes(e)&&t.layers.add(e)}),f(()=>[this.view?.extent,this.view?.stationary,this.filterByViewExtent],([e,t,r])=>{r&&(e?t&&(this.filterGeometry=e):this.filterGeometry=null)},b),f(()=>this.maxSize,(e,t)=>{0===t&&this._reset()}),f(()=>[this.layer,this.view],()=>this.syncSelectionSources(),b),f(()=>this.highlightEnabled,e=>this.defaultSelectionManager.highlightEnabled=e,b),f(()=>this.temporaryHighlightId,e=>{this._temporaryHighlight=u(this._temporaryHighlight?.handle),this._temporaryHighlightAbortController?.abort(),this._temporaryHighlightAbortController=new AbortController;const t=this._syncTemporaryHighlight(e,this._temporaryHighlightAbortController.signal);y(this.view?.addUpdatingPromise(t)??t)},E)])}destroy(){this.layer=null,this.itemCache.destroy(),this.failures.destroy(),this.defaultSelectionManager.destroy(),this._temporaryHighlight=u(this._temporaryHighlight?.handle),this._temporaryHighlightAbortController=p(this._temporaryHighlightAbortController)}get _capabilities(){const{layer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _canSavePendingEdits(){return this.supportsEditing&&this.hasPendingEdits&&!this.hasInvalidPendingEdits}get _effectiveReturnZ(){return this.returnZ&&this.supportsZ}get _effectiveReturnM(){return this.returnM&&this.supportsM}get _layerWithAttachments(){const{layer:e}=this;return e&&this._capabilities&&this.attachmentsEnabled&&this.supportsAttachments&&B(e)?e:null}get _layerWithAttachmentsEditing(){const{_layerWithAttachments:e}=this;return e&&W(e)&&this.supportsEditing?e:null}get _layerWithContingentValues(){const{layer:e}=this;return w(e)||F(e)?e:null}get _layerWithEditing(){const e=this.layer;return x(e)&&this.supportsEditing?e:null}get _layerWithRelationships(){const e=this.layer;return z(e)&&this.supportsQueryRelated?e:null}get _pendingEditsAreInvalid(){const e=this._pendingEditsCache,t=this._layerWithContingentValues;if(!t)return!1;for(const r of e.keys()){const i=e.get(r),s=this._getFeatureWithPendingEdits(r,i);for(const e of i.changes.keys()){if(this._contingentValuesManager.getViolationForField(t,s,e))return!0}}return!1}get _relatedLayer(){return this.relationshipConfig?.relatedLayer}get _relatedLayerCapabilities(){const{_relatedLayer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _relatedLayerSupportsCacheHint(){return!!this._relatedLayerCapabilities?.queryRelated?.supportsCacheHint}get _relatedLayerSupportsQuery(){return!!this._relatedLayerCapabilities?.operations.supportsQuery}get _relatedLayerSupportsQueryRelated(){const{_relatedLayerCapabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get _sortedFieldNames(){return this.sortOrders.map(({fieldName:e})=>e)}get _subtypeCode(){return this.layer?.subtypeCode??null}get _subtypeField(){const{layer:e}=this;return F(e?.parent)?e.subtypeField:null}get _canUseRelatedLayer(){return!(!this._relatedLayerSupportsQuery||!this._relatedLayerSupportsQueryRelated)}get _shouldFilterByLayerScaleRange(){return!(!this.view||!this.filterByLayerScaleRange)}get _visibleAtCurrentScale(){return!(!this._shouldFilterByLayerScaleRange||!this.layerView?.visibleAtCurrentScale)}get cachedPageCount(){return this.pageCache.size}get canAddRelatedFeature(){const{state:e,relationship:t,supportsAdd:r,supportsEditing:i}=this;if("loaded"!==e||!t||!r||!i)return!1;const{cardinality:s,role:n}=t,a=this.size>0;return("one-to-one"!==s||!a)&&("one-to-many"!==s||"origin"!==n||!a)}get effectiveOutFields(){const{layer:e,outFields:t}=this;if(!e||!t?.length)return this._defaultOutFields;const r=[];t.forEach(t=>{const i=e.fieldsIndex.normalizeFieldName(t);i&&r.push(i)});const{objectIdField:i}=e,s=e.fieldsIndex.normalizeFieldName(i)??i;return s&&!r.includes(s)&&r.unshift(s),r}get effectiveSelectionManager(){const{layer:e,view:t}=this;return e&&this.syncViewSelection&&L(e)&&t?.selectionManager?.sources.includes(e)?t.selectionManager:this.selectionManager??this.defaultSelectionManager}get effectiveSize(){const{_size:e,maxSize:t}=this;return null!=t?Math.min(t,e):e}get effectiveTimeExtent(){const{layer:e,timeExtent:t,view:r,viewTimeEnabled:i}=this;if(t||!e)return t;if(!r||!i)return e.timeExtent??void 0;return A({datesInUnknownTimezone:e.datesInUnknownTimezone??void 0,timeExtent:e.timeExtent,timeInfo:e.timeInfo,timeOffset:e.timeOffset,useViewTime:e.useViewTime},r.timeExtent,this._get("effectiveTimeExtent"))??void 0}get effectiveWhere(){const{layer:e,where:t}=this;return null!=t&&""!==t?t:O(e)&&e.parent?.definitionExpression?e.parent.definitionExpression:e?.definitionExpression||"1=1"}get fieldsWithContingentValues(){return this._contingentValuesManager.getFieldsWithContingentValues(this.layer)}get hasContingentValues(){return this.fieldsWithContingentValues.size>0}get hasInvalidPendingEdits(){return this.hasPendingEdits&&this._pendingEditsAreInvalid}get hasPendingEdits(){return this.pendingEditsCount>0}get highlightableLayerView(){const e=this.layerView;return V(e)?e:null}get isQuerying(){return this._queryOperationInfos.size>0}get isSyncing(){return this.isSyncingFeatureEdits||this.isSyncingAttachmentEdits}get isSyncingAttachmentEdits(){return this._attachmentsOperationQueue.length>0}get isSyncingFeatureEdits(){return this._editOperationQueue.length>0}get itemCache(){return new a({items:[...this.pageCache.values()].flat()})}get layerView(){const{layer:e,view:t}=this;if(!e||!t)return null;const r="sublayer"===e.type||O(e)?e.parent:e;return t.allLayerViews.find(e=>e.layer===r)}get orderByFields(){const{_sortedFieldNames:e,layer:t,sortOrders:r}=this,i=r.filter(({fieldName:t,direction:r},i)=>e.indexOf(t)===i&&null!=r).map(({fieldName:e,direction:t})=>`${e} ${t?.toUpperCase()}`);if(t&&!i.length&&!t.objectIdField&&t.fields?.length){const e=t.fields.find(e=>e.name);if(e){const r=t.fieldsIndex.normalizeFieldName(e.name);r&&i.push(`${r} ASC`)}}return i}get pageCount(){const{effectiveSize:e,pageSize:t}=this;return 0===e||0===t?1:Math.ceil(e/t)}get pageIndex(){return this._get("pageIndex")||0}set pageIndex(e){const{pageCount:t}=this;H(e,t)&&this._set("pageIndex",e)}get pendingEditsCount(){let e=0;return this._pendingEditsCache.forEach(t=>e+=t.changes.size),e}get relationship(){const{relationshipConfig:e}=this;return null==e?.relationshipId?null:this.relationships?.find(t=>t.id===e.relationshipId)}get relationshipIds(){return this.relationships?.map(e=>e.id)??[]}get relationshipInfos(){const{_layerWithRelationships:e,relatedRecordsEnabled:t,relationships:r,view:i}=this,s=[];return t&&e?.loaded&&i?.map&&r?.length?(r.forEach(t=>{const r=Q(e,i,t);r&&(r.load().catch(()=>{}),s.push({layer:e,relatedLayer:r,relationshipId:t.id}))}),s):s}get relationships(){return this._layerWithRelationships?.relationships}get size(){return this._size}get state(){const{layer:e,_loaded:t,_loadError:r}=this;return!e||e.destroyed?"disabled":r||e.loadError?"error":this._loadController?"loading":"loaded"===e.loadStatus&&t?"loaded":"ready"}get supportsAdd(){return!!this._capabilities?.operations.supportsAdd}get supportsAddAttachments(){return!(!this._layerWithAttachmentsEditing||!this.supportsAdd&&!this.supportsUpdate)}get supportsAttachments(){const{_capabilities:e}=this;return!(!e?.data?.supportsAttachment||!e?.operations.supportsQueryAttachments)}get supportsCacheHint(){return!!this._capabilities?.query?.supportsCacheHint}get supportsCacheHintQueryRelated(){return!!this._capabilities?.queryRelated?.supportsCacheHint}get supportsDelete(){return!!this._capabilities?.operations.supportsDelete}get supportsEditing(){return!!this._capabilities?.operations.supportsEditing}get supportsM(){return!!this.layer?.hasM&&!!this._capabilities?.data?.supportsM}get supportsOrderBy(){return!!this._capabilities?.query?.supportsOrderBy}get supportsPagination(){return!!this._capabilities?.query?.supportsPagination}get supportsQuery(){return!!this._capabilities?.operations.supportsQuery}get supportsQueryRelated(){const{_capabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get supportsResizeAttachments(){const{_capabilities:e}=this;return!(!this.supportsAttachments||!e?.attachment?.supportsResize)}get supportsUpdate(){return!!this._capabilities?.operations.supportsUpdate}get supportsUpdateAttachments(){return!(!this._layerWithAttachmentsEditing||!this.supportsAdd&&!this.supportsUpdate)}get supportsZ(){return!!this.layer?.hasZ&&!!this._capabilities?.data?.supportsZ}async addAttachment(e,t){const{_layerWithAttachmentsEditing:r}=this;if(!r||!this.supportsAddAttachments)return{};const i=await this._queueAttachmentsOperation(e,()=>r.addAttachment(this._createBaseGraphic(r,e),t));return this._ensureArrayContent(i)}addPendingEdits(e){const t=this._ensureLayerAndUpdateSupport();this.editingEnabled?(this.autoSaveEnabled&&this._logWarning("store:pending-edit","Edit will be cached, but 'autoSaveEnabled' is true.",!0),this._stashPendingEdits(t,e)):this._logWarning("store:editing-disabled","Editing is disabled.")}async deleteAttachments(e,t){const{_layerWithAttachmentsEditing:r}=this;if(!r||!this.supportsUpdateAttachments||!t.length)return[];const i=await this._queueAttachmentsOperation(e,()=>r.deleteAttachments(this._createBaseGraphic(r,e),t));return this._ensureArray(i)}async deleteRowsByObjectId(e){const{_layerWithEditing:t}=this;if(!this.supportsDelete||!t)throw new o("store:delete-error","Delete is not supported.");const r=e.map(e=>this.getItemByObjectId(e)?.feature).filter(s),i=this._queueEditOperation(()=>t.applyEdits({deleteFeatures:r}));return e.forEach(e=>{this.featureTitleMap.delete(e),this._discardPendingEdit({objectId:e})}),i}discardPendingEdits(e){if(e?.length)e.forEach(e=>this._discardPendingEdit(e));else{for(const[e,t]of this._pendingEditsCache){const r=this.getItemByObjectId(e);r&&(r.feature=t.originalFeature)}this._pendingEditsCache.clear(),this._clearOptionsAndViolations()}}itemHasInvalidPendingEdits(e,t){if(!this.hasInvalidPendingEdits)return!1;const r=this._layerWithContingentValues,i=this._pendingEditsCache.get(e);if(!r||!i)return!1;const s=this._getFeatureWithPendingEdits(e,i),n=this._contingentValuesManager;return t?!!n.getViolationForField(r,s,t):!!n.getAllViolations(r,s)}itemHasPendingEdits(e,t){const r=this._pendingEditsCache.get(e);return!!r&&(!t||r.changes.has(t))}async getAttachmentsByObjectId(e,t){const r=this.getItemByObjectId(e)?.attachments??[];if(!r.length&&t){return(await this._queryAttachments([e]))[e]??[]}return r}getCachedFeaturesByPageIndex(e){return this.pageCache.get(e)}getFieldValueOptions(e){return this._contingentValuesManager.getFieldValueOptions(e)}async getFeatureTitle(e,r=!1){const{layer:i}=this,s=this.featureTitleMap.get(e),n=`${e}`;if(!i)return s||n;if(s&&!r)return s;if(!("getFeatureTitle"in i)||!i.getFeatureTitle)return n;const a=this.getItemByObjectId(e);let o=a?.feature;o||(o=new t({attributes:{[i.objectIdField]:e},origin:i.graphicOrigin}));const l=await i.getFeatureTitle(o,{fetchMissingFields:!0,removeHTML:!0});return l?(this.featureTitleMap.set(e,l),l):n}getItemByObjectId(e){for(const t of this.pageCache.values())for(const r of t)if(r.objectId===e)return r}getItemIndexByObjectId(e){const{pageCache:t,pageSize:r}=this,i=t.entries();let s=-1;for(const[n,a]of i)if(a.some((t,i)=>{const a=t.objectId===e;return a&&(s=n*r+i),a}),s>-1)break;return s}async load(){await y(this._loadDebounced())}async queryPage(e){const{layer:t,state:r}=this;if(!t||"loaded"!==r||!this.supportsQuery||0===this.size||0===this.maxSize)return[];const{pageIndex:i}=e;if(!H(i,this.pageCount))return[];const s=e.pageSize??this.pageSize,n=i*s,a=n+s;return await y(this._query({layer:t,start:n,num:a,pageIndex:i,pageSize:s}))??[]}async refresh(){await y(this._refreshDebounced())}reset(){this._reset()}async savePendingEdits(){const e=this._ensureLayerAndUpdateSupport();if(!this.editingEnabled)return void this._logWarning("store:editing-disabled","Editing is disabled.");if(this.autoSaveEnabled&&this._logWarning("store:pending-edit","Edit will be cached, but 'autoSaveEnabled' is true.",!0),!this._canSavePendingEdits)return void this._logError("store:update-error","An error occurred. Unable to save pending edits.");const t=[];for(const[r]of this._pendingEditsCache){const e=this.getItemByObjectId(r);e?.feature&&t.push(e.feature)}(await this._update(e,t,!0)).updateFeatureResults.find(e=>e.error)&&this.discardPendingEdits(),this._clearOptionsAndViolations()}syncSelectionSources(){const{defaultSelectionManager:e,layer:t,view:r}=this;e.view=r,e.sources.removeAll(),P(t)&&(e.sources.items=[t])}async updateAttachment(e,t,r){const{_layerWithAttachmentsEditing:i}=this;if(!i||!this.supportsUpdateAttachments)return{};const s=await this._queueAttachmentsOperation(e,()=>i.updateAttachment(this._createBaseGraphic(i,e),t,r));return this._ensureArrayContent(s)}async updateItem(e){const t=this._ensureLayerAndUpdateSupport();if(!this.editingEnabled)return void this._logWarning("store:editing-disabled","Editing is disabled.");if(this.hasContingentValues){const t=e.updates.some(e=>this.fieldsWithContingentValues.has(e.fieldName)),r=this.itemHasPendingEdits(e.objectId);if(r||t){const t=this._layerWithContingentValues,i=this.getItemByObjectId(e.objectId)?.feature?.clone();if(i){const s=this._contingentValuesManager.getAllViolations(t,i);e.updates.forEach(({fieldName:e,value:r})=>{const s=t.getField(e);s&&(i.attributes[s.name]=r)});if(this._contingentValuesManager.validateContingencyConstraints(t,i).length||s.length||r)return this._stashPendingEdits(t,[e]),void this._contingentValuesManager.resetOptionsForLayer(t)}}}if(!this.autoSaveEnabled)return void this._stashPendingEdits(t,[e]);const{_sortedFieldNames:r}=this,i=e.updates.map(({fieldName:e})=>e),s=this._prepareEditsForUpdate([e]);!(await this._update(t,s)).updateFeatureResults.find(e=>e.error)&&i.some(e=>r.includes(e))&&this._clearCaches()}async verifyFeaturesByObjectId(e){const{layer:t,state:r}=this;if(!t||"loaded"!==r)return[];const{objectIdField:i}=t,s=await this._queryFeaturesByObjectId(e);return e.map(e=>s.some(t=>{const r=t.getObjectId()??t.attributes[i];return e===r}))}async _load(){const{layer:e}=this;if(this._reset(),!e)return;const t=new AbortController;this._loadController=t;try{if(await e.load(),e.parent&&F(e.parent)&&await e.parent.loadAll(),await e.when(),t.signal.aborted)return;let r=this.initialSize;if(this.initialSize=null,this._shouldFilterByLayerScaleRange&&(this._visibleAtCurrentScale||(r=0)),await y(this._refresh(t,r)),t.signal.aborted)return void(this._loadController=null);this._loaded=!0,this._loadController=null}catch(r){throw this._reset(),this._loadError=!0,this._logError("store:load-error","An error occurred."),r}}async _refresh(e,t){this._clearCaches();const r=e?.signal,i=await this._getSize(r,t),s=await this._queryAllObjectIds(r);r?.aborted||(this._size=i,this._objectIdCache.removeAll(),s?.length&&this._objectIdCache.addMany(s),this._syncPendingEdits())}async _queryAllObjectIds(e){return this.supportsPagination?void 0:await this._queryObjectIds(e)}_clearCaches(){this.pageCache.clear(),this._objectIdCache.removeAll()}_createBaseGraphic(e,r){const i=new t({attributes:{[e.objectIdField]:r}});return this._subtypeField&&null!=this._subtypeCode&&(i.attributes[this._subtypeField]=this._subtypeCode),i}_ensureArray(e){return Array.isArray(e)?e:[e]}_ensureArrayContent(e){return Array.isArray(e)?e[0]:e}_getObjectIdsForFeatures(e,t){return e.map(e=>e.getObjectId()??e.attributes[t.objectIdField])}_getObjectIdsForPage(e,t){const r=this._objectIdCache.toArray();return r.length>=e+t?r.slice(e,e+t):r.slice(e)}_logError(e,t){h.getLogger(this).error(e,t)}_logWarning(e,t,r=!1){r?h.getLogger(this).warnOnce(e,t):h.getLogger(this).warn(e,t)}_reset(){this._clearCaches(),this._pendingEditsCache.clear(),this.failures.removeAll(),this._attachmentsOperationQueue.removeAll(),this._editOperationQueue.removeAll(),this.featureTitleMap.clear(),this._loadController=p(this._loadController),this._queryOperationInfos.forEach(e=>e.controller.abort()),this._queryOperationInfos.clear(),this._temporaryHighlight=u(this._temporaryHighlight?.handle),this._temporaryHighlightAbortController=p(this._temporaryHighlightAbortController),this._loaded=!1,this._loadError=!1,this._size=0}async _getSize(e,t){return 0===this.maxSize?0:null!=t?t:await this._queryCount(e)}async _queryFeaturesByObjectId(e){const{layer:t}=this;if(!t||!this.supportsQuery)throw new o("store:query-error","Layer does not support query operation.");const{effectiveTimeExtent:r,effectiveWhere:i,orderByFields:s,supportsCacheHint:n,supportsOrderBy:a}=this,l=t.createQuery();l.where=i,l.timeExtent=r,l.returnGeometry=!1,l.objectIds=e.length?e:void 0,l.outFields=[t.objectIdField],a&&(l.orderByFields=s),n&&(l.cacheHint=!0);return(await t.queryFeatures(l)).features}async _syncTemporaryHighlight(e,t){const{highlightEnabled:r,highlightableLayerView:i}=this;i&&r&&null!=e&&(g(t),this._temporaryHighlight={id:e,handle:i.highlight(e,{name:M})})}_ensureLayerAndUpdateSupport(){const e=this._layerWithEditing;if(!e||!this.supportsUpdate)throw new o("store:update-error","Update is not supported.");return e}_stashPendingEdits(e,t){t.forEach(({objectId:t,updates:r})=>{const i=this.getItemByObjectId(t)?.feature;if(!i)throw new o("store:update-error","Feature with provided 'objectId' not found.");const s=i.clone(),n=d(this._pendingEditsCache,t,()=>({originalFeature:s,changes:new _}));r.forEach(({fieldName:t,value:r})=>{const s=e.getField(t);s?(n.changes.set(s.name,r),i.attributes[s.name]=r):this._logWarning("store:pending-edit-unknown-field","The provided field does not belong to this layer.")}),n.changes.size>0&&this._pendingEditsCache.set(t,n)})}_syncPendingEdits(){for(const[e,t]of this._pendingEditsCache){const r=this.getItemByObjectId(e)?.feature;if(r){const e=r.clone();for(const[i,s]of t.changes)r.attributes[i]=s;t.originalFeature=e}}}_getFeatureWithPendingEdits(e,t){let r=this.getItemByObjectId(e)?.feature;if(!r){r=t.originalFeature.clone();for(const[e,i]of t.changes)r.attributes[e]=i}return r}_discardPendingEdit({objectId:e,fieldName:t}){const r=this._pendingEditsCache.get(e);if(!r)return void this._logWarning("store:pending-edit-not-found","Could not find a pending edit with the given information");const i=this.getItemByObjectId(e);t?(i&&(i.feature.attributes[t]=r.originalFeature.attributes[t]),r.changes.delete(t),0===r.changes.size&&this._pendingEditsCache.delete(e)):(i&&(i.feature=r.originalFeature),this._pendingEditsCache.delete(e))}_clearOptionsAndViolations(){const{_layerWithContingentValues:e,_contingentValuesManager:t}=this;e&&(t.resetOptionsForLayer(e),t.resetViolationsForLayer(e))}_prepareEditsForUpdate(e){const r=[];return e.forEach(({objectId:e,updates:i})=>{const s=this.getItemByObjectId(e)?.feature;if(!s)return;const n=l(s.attributes);i.forEach(({fieldName:e,value:t})=>n[e]=t),r.push(new t({attributes:n,sourceLayer:s.sourceLayer}))}),r}_update(e,t,r=!1){const i=e.applyEdits({updateFeatures:t}).then(r=>{const{updateFeatureResults:i}=r,s=i.find(e=>!!e.error);if(s)throw s.error;return t.forEach(t=>{const r=t.getObjectId()??t.attributes[e.objectIdField],i=this.getItemByObjectId(r)?.feature;i&&(i.attributes=t.attributes),this.featureTitleMap.has(r)&&this.getFeatureTitle(r,!0)}),r});return this._queueEditOperation(()=>i,r)}_createFeatureStoreItems(e){const{attachments:t,features:r,layer:i,relatedRecords:s}=e,n=i.objectIdField;return r.map(e=>{const r=e.getObjectId()??e.attributes[n],a=[];e.layer||e.sourceLayer||(e.layer=i,e.sourceLayer=i);const o=this._pendingEditsCache.get(r);if(o){const t=e.clone(),r=o.changes;for(const[i,s]of r)e.attributes[i]=s;o.originalFeature=t}return s.forEach((e,t)=>{a.push({relationshipId:t,count:e[r]??0})}),{objectId:r,feature:e,attachments:t[r]??null,relatedRecords:a}})}async _query(e){const{pageIndex:t,refresh:r}=e;!0===r&&await this._refresh();const i=this.pageCache.get(t);if(i)return i;const s=this._queryOperationInfos.get(t);if(s)return s.task.promise;const n=new AbortController,a=await this._queryPage(e,n);return n.signal.aborted||this.pageCache.set(t,a),a}_queryAttachments(e,t){const{_layerWithAttachments:r,effectiveWhere:i}=this;return r?e.some(e=>"number"!=typeof e)?Promise.reject(new o("invalid-object-id","Only numeric object ids are valid to query attachments")):r.queryAttachments(new j({objectIds:e,where:i,returnMetadata:!0}),{signal:t}):Promise.resolve({})}async _queryCount(e){const{_relatedLayerSupportsCacheHint:t,layer:r,relationshipConfig:i,supportsCacheHint:s}=this;if(!r)return 0;if(i&&this._canUseRelatedLayer){const{objectId:r,relatedLayer:s,relationshipId:n}=i;return(await s.queryRelatedFeaturesCount(new S({cacheHint:t,relationshipId:n,objectIds:[r]}),{signal:e}))[r]??0}const{effectiveTimeExtent:n,effectiveWhere:a,filterGeometry:o,objectIds:l}=this,h=r.createQuery();return h.geometry=o,h.returnGeometry=!1,h.where=a,h.timeExtent=n,h.objectIds=l?.length?l:void 0,s&&(h.cacheHint=!0),r.queryFeatureCount(h,{signal:e})}async _queryFeatures(e,t){const{relationshipConfig:r}=this;if(r&&this._canUseRelatedLayer)return this._queryRelatedFeatures(e,r);const{_effectiveReturnM:i,_effectiveReturnZ:s,effectiveOutFields:n,effectiveTimeExtent:a,effectiveWhere:o,filterGeometry:l,objectIds:h,orderByFields:d,pageSize:u,returnGeometry:p,supportsCacheHint:c,supportsOrderBy:y,supportsPagination:g}=this,{layer:_,start:f}=e,m=h?.length,b=_.createQuery();b.returnGeometry=p,b.outFields=n,b.returnM=i,b.returnZ=s,g?(b.start=f,b.num=u,b.where=o,b.timeExtent=a,b.objectIds=m?h:void 0):b.objectIds=m?h:this._getObjectIdsForPage(f,u??0),y&&(b.orderByFields=d),l&&(b.geometry=l),c&&(b.cacheHint=!0);return(await _.queryFeatures(b,{signal:t})).features}_queryObjectIds(e){const{effectiveTimeExtent:t,effectiveWhere:r,filterGeometry:i,layer:s,objectIds:n,orderByFields:a,supportsCacheHint:o,supportsOrderBy:l}=this;if(!s)return Promise.resolve([]);const h=s.createQuery();return h.geometry=i,h.outFields=[s.objectIdField],h.returnGeometry=!1,h.where=r,h.timeExtent=t,h.objectIds=n?.length?n:void 0,l&&(h.orderByFields=a),o&&(h.cacheHint=!0),s.queryObjectIds(h,{signal:e})}async _queryPage(e,t){return this._queueQueryOperation(e.pageIndex,{controller:t,task:n(async()=>this._queryPageData(e,t))})}async _queryPageData(e,t){const{layer:r}=e,{signal:i}=t,s=await this._queryFeatures(e,i);if(i.aborted)return[];const n=this._getObjectIdsForFeatures(s,r),[a,o]=await Promise.all([this._queryAttachments(n,i),this._queryRelatedCounts(n,i)]);return t.signal.aborted?[]:this._createFeatureStoreItems({layer:r,features:s,attachments:a,relatedRecords:o})||[]}async _queryRelatedCounts(e,t){const{_layerWithRelationships:r,relationshipIds:i,supportsCacheHintQueryRelated:s}=this,n=new Map;return r&&e?.length&&i.length?(await Promise.allSettled(i.map(async i=>{const a=await r.queryRelatedFeaturesCount(new S({cacheHint:s,relationshipId:i,objectIds:e}),{signal:t});n.set(i,a)})),n):n}async _queryRelatedFeatures(e,t){const{_defaultOutFields:r,_effectiveReturnM:i,_effectiveReturnZ:s,orderByFields:n,pageSize:a,returnGeometry:o,supportsCacheHint:l}=this,{layer:h,start:d}=e,{objectId:u,relatedLayer:p,relationshipId:c}=t,y=h.createQuery(),g=new S({cacheHint:l,num:a,objectIds:[u],orderByFields:n,outFields:r,relationshipId:c,returnGeometry:o,returnM:i,returnZ:s,start:d,where:y.where??void 0}),_=await p.queryRelatedFeatures(g);return _[u]?.features||[]}_queueAttachmentsOperation(e,t){return this._attachmentsOperationQueue.push(t),t().then(async r=>{this._attachmentsOperationQueue.remove(t);const i=this._ensureArray(r),s=i.some(e=>e.error),n=this.getItemByObjectId(e);if(n&&(!s||i.length>1)){const t=await this._queryAttachments([e]);n.attachments=t[e]}return r}).catch(async r=>{this._logError("store:attachment-error","An error occurred.");const i={error:r,retry:()=>{this.failures.remove(i),this._queueAttachmentsOperation(e,t)},cancel:()=>this.failures.remove(i)};throw this.failures.add(i),this._attachmentsOperationQueue.remove(t),r})}_queueEditOperation(e,t=!1){return this._editOperationQueue.push(e),e().then(r=>(this._editOperationQueue.remove(e),t&&this._pendingEditsCache.clear(),r)).catch(t=>{this._logError("store:edit-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueEditOperation(e)},cancel:()=>this.failures.remove(r)};throw this.failures.add(r),this._editOperationQueue.remove(e),t})}async _queueQueryOperation(e,t){this._queryOperationInfos.set(e,t);const r=await t.task.promise;return this._queryOperationInfos.delete(e),r}};e([v()],T.prototype,"_attachmentsOperationQueue",void 0),e([v({readOnly:!0})],T.prototype,"_capabilities",null),e([v()],T.prototype,"_canSavePendingEdits",null),e([v()],T.prototype,"_contingentValuesManager",void 0),e([v()],T.prototype,"_defaultOutFields",void 0),e([v()],T.prototype,"_editOperationQueue",void 0),e([v()],T.prototype,"_effectiveReturnZ",null),e([v()],T.prototype,"_effectiveReturnM",null),e([v()],T.prototype,"featureTitleMap",void 0),e([v({readOnly:!0})],T.prototype,"_layerWithAttachments",null),e([v({readOnly:!0})],T.prototype,"_layerWithAttachmentsEditing",null),e([v()],T.prototype,"_layerWithContingentValues",null),e([v({readOnly:!0})],T.prototype,"_layerWithEditing",null),e([v({readOnly:!0})],T.prototype,"_layerWithRelationships",null),e([v()],T.prototype,"_loaded",void 0),e([v()],T.prototype,"_loadController",void 0),e([v()],T.prototype,"_loadError",void 0),e([v()],T.prototype,"_objectIdCache",void 0),e([v()],T.prototype,"_pendingEditsCache",void 0),e([v()],T.prototype,"_pendingEditsAreInvalid",null),e([v()],T.prototype,"_queryOperationInfos",void 0),e([v({readOnly:!0})],T.prototype,"_relatedLayer",null),e([v({readOnly:!0})],T.prototype,"_relatedLayerCapabilities",null),e([v({readOnly:!0})],T.prototype,"_relatedLayerSupportsCacheHint",null),e([v()],T.prototype,"_relatedLayerSupportsQuery",null),e([v()],T.prototype,"_relatedLayerSupportsQueryRelated",null),e([v()],T.prototype,"_size",void 0),e([v()],T.prototype,"_sortedFieldNames",null),e([v()],T.prototype,"_subtypeCode",null),e([v()],T.prototype,"_subtypeField",null),e([v()],T.prototype,"_canUseRelatedLayer",null),e([v()],T.prototype,"_shouldFilterByLayerScaleRange",null),e([v()],T.prototype,"_visibleAtCurrentScale",null),e([v()],T.prototype,"attachmentsEnabled",void 0),e([v()],T.prototype,"autoSaveEnabled",void 0),e([v()],T.prototype,"cachedPageCount",null),e([v()],T.prototype,"canAddRelatedFeature",null),e([v()],T.prototype,"defaultSelectionManager",void 0),e([v()],T.prototype,"editingEnabled",void 0),e([v()],T.prototype,"effectiveOutFields",null),e([v()],T.prototype,"effectiveSelectionManager",null),e([v()],T.prototype,"effectiveSize",null),e([v()],T.prototype,"effectiveTimeExtent",null),e([v()],T.prototype,"effectiveWhere",null),e([v({readOnly:!0})],T.prototype,"failures",void 0),e([v()],T.prototype,"fieldsWithContingentValues",null),e([v()],T.prototype,"filterByViewExtent",void 0),e([v()],T.prototype,"filterByLayerScaleRange",void 0),e([v({types:I})],T.prototype,"filterGeometry",void 0),e([v()],T.prototype,"hasContingentValues",null),e([v()],T.prototype,"hasInvalidPendingEdits",null),e([v()],T.prototype,"hasPendingEdits",null),e([v()],T.prototype,"highlightEnabled",void 0),e([v()],T.prototype,"highlightableLayerView",null),e([v()],T.prototype,"initialSize",void 0),e([v({readOnly:!0})],T.prototype,"isQuerying",null),e([v({readOnly:!0})],T.prototype,"isSyncing",null),e([v({readOnly:!0})],T.prototype,"isSyncingAttachmentEdits",null),e([v({readOnly:!0})],T.prototype,"isSyncingFeatureEdits",null),e([v({readOnly:!0})],T.prototype,"itemCache",null),e([v()],T.prototype,"layer",void 0),e([v()],T.prototype,"layerView",null),e([v()],T.prototype,"maxSize",void 0),e([v()],T.prototype,"objectIds",void 0),e([v()],T.prototype,"orderByFields",null),e([v()],T.prototype,"outFields",void 0),e([v({readOnly:!0})],T.prototype,"pageCache",void 0),e([v()],T.prototype,"pageCount",null),e([v()],T.prototype,"pageIndex",null),e([v()],T.prototype,"pageSize",void 0),e([v()],T.prototype,"paginationEnabled",void 0),e([v()],T.prototype,"pendingEditsCount",null),e([v()],T.prototype,"relationship",null),e([v()],T.prototype,"relationshipConfig",void 0),e([v()],T.prototype,"relationshipIds",null),e([v()],T.prototype,"relationshipInfos",null),e([v()],T.prototype,"relationships",null),e([v()],T.prototype,"relatedRecordsEnabled",void 0),e([v()],T.prototype,"returnGeometry",void 0),e([v()],T.prototype,"returnZ",void 0),e([v()],T.prototype,"returnM",void 0),e([v()],T.prototype,"selectionManager",void 0),e([v({readOnly:!0})],T.prototype,"size",null),e([v()],T.prototype,"sortOrders",void 0),e([v({readOnly:!0})],T.prototype,"state",null),e([v()],T.prototype,"supportsAdd",null),e([v()],T.prototype,"supportsAddAttachments",null),e([v()],T.prototype,"supportsAttachments",null),e([v()],T.prototype,"supportsCacheHint",null),e([v()],T.prototype,"supportsCacheHintQueryRelated",null),e([v()],T.prototype,"supportsDelete",null),e([v()],T.prototype,"supportsEditing",null),e([v()],T.prototype,"supportsM",null),e([v()],T.prototype,"supportsOrderBy",null),e([v()],T.prototype,"supportsPagination",null),e([v()],T.prototype,"supportsQuery",null),e([v()],T.prototype,"supportsQueryRelated",null),e([v()],T.prototype,"supportsResizeAttachments",null),e([v()],T.prototype,"supportsUpdate",null),e([v()],T.prototype,"supportsUpdateAttachments",null),e([v()],T.prototype,"supportsZ",null),e([v()],T.prototype,"syncViewSelection",void 0),e([v()],T.prototype,"temporaryHighlightId",void 0),e([v({type:q})],T.prototype,"timeExtent",void 0),e([v()],T.prototype,"timeZone",void 0),e([v()],T.prototype,"view",void 0),e([v()],T.prototype,"viewTimeEnabled",void 0),e([v()],T.prototype,"where",void 0),T=e([C("esri.widgets.FeatureTable.support.FeatureStore")],T);const G=T;export{G as default};
@@ -346,6 +346,7 @@ export type FeatureTableTitleFunction = () => string;
346
346
  /** A custom function used to replace the description for the FeatureTable. This is useful in situations where it may be necessary to dynamically update descriptions based on the current state of the table. */
347
347
  export type FeatureTableDescriptionFunction = () => string;
348
348
 
349
+ /** @deprecated since version 5.0. Use the [Feature Table](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-feature-table/) component instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/). */
349
350
  export interface FeatureTableEvents extends FeatureTableViewModelEvents {}
350
351
 
351
352
  /**
@@ -47,6 +47,7 @@ export interface FeatureTemplatesProperties extends WidgetProperties, Partial<Pi
47
47
  visibleElements?: VisibleElementsProperties;
48
48
  }
49
49
 
50
+ /** @deprecated since version 5.0. Use the [Feature Templates (Legacy)](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-feature-templates-legacy/) component instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/). */
50
51
  export interface FeatureTemplatesEvents extends FeatureTemplatesViewModelEvents {}
51
52
 
52
53
  /**
@@ -102,6 +102,7 @@ export interface FeaturesViewModelProperties extends GoToProperties, Partial<Pic
102
102
  timeZone?: TimeZone | null;
103
103
  }
104
104
 
105
+ /** @deprecated since 5.2. Use the [Features (Next) component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-features-next/) or the [FeatureContentCollection](https://developers.arcgis.com/javascript/latest/references/core/popup/FeatureContentCollection/) class instead. */
105
106
  export interface FeaturesViewModelEvents {
106
107
  /**
107
108
  * Fires after the user clicks on an [action](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionButton/) or [action toggle](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionToggle/) in the action bar. This
@@ -68,6 +68,7 @@ export interface FeaturesProperties extends WidgetProperties, Partial<Pick<Featu
68
68
 
69
69
  export type FeaturesOpenOptions = Partial<Pick<PopupOpenOptions, "actions" | "collapsed" | "content" | "featureStream" | "features" | "fetchFeatures" | "featureMenuOpen" | "featureMenuTitle" | "location" | "promises" | "title" | "updateLocationEnabled">>;
70
70
 
71
+ /** @deprecated since version 4.34. Use the [Features (Next) component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-features-next/) instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/). */
71
72
  export interface FeaturesEvents extends FeaturesViewModelEvents {}
72
73
 
73
74
  /**
@@ -97,7 +98,7 @@ export interface FeaturesEvents extends FeaturesViewModelEvents {}
97
98
  * The Features widget should be used if needing to use the Popup functionality outside of the View. If wanting to show a single feature's content without
98
99
  * actions, related records, clustering configuration, etc., then use the [Feature](https://developers.arcgis.com/javascript/latest/references/core/widgets/Feature/) widget.
99
100
  *
100
- * @deprecated since version 4.34. Use the [Features component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-features/) instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/).
101
+ * @deprecated since version 4.34. Use the [Features (Next) component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-features-next/) instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/).
101
102
  * @since 4.27
102
103
  * @see [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/)
103
104
  * @see [Deprecated since 5.1 - Guide - Esri Icon Font](https://developers.arcgis.com/javascript/latest/esri-icon-font/)
@@ -66,6 +66,7 @@ export interface HistogramRangeSliderProperties extends WidgetProperties, Partia
66
66
  viewModel?: HistogramRangeSliderViewModelProperties;
67
67
  }
68
68
 
69
+ /** @deprecated since version 5.0. Use the [Histogram](https://developers.arcgis.com/javascript/latest/references/common-components/components/arcgis-histogram/) and [Slider](https://developers.arcgis.com/javascript/latest/references/common-components/components/arcgis-slider/) components instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/). */
69
70
  export interface HistogramRangeSliderEvents extends CommonSliderEvents {}
70
71
 
71
72
  /**
@@ -28,6 +28,7 @@ export interface HomeViewModelProperties extends GoToProperties, Partial<Pick<Ho
28
28
 
29
29
  export type HomeViewModelState = "disabled" | "going-home" | "ready";
30
30
 
31
+ /** @deprecated since 5.0. Use the [Home component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-home/) directly instead. */
31
32
  export interface HomeViewModelEvents {
32
33
  /**
33
34
  * Fires when the [Home.go()](https://developers.arcgis.com/javascript/latest/references/core/widgets/Home/#go) method is called.
package/widgets/Home.d.ts CHANGED
@@ -52,6 +52,7 @@ export interface HomeProperties extends WidgetProperties, Partial<Pick<Home, "go
52
52
  viewpoint?: ViewpointProperties | null;
53
53
  }
54
54
 
55
+ /** @deprecated since version 4.32. Use the [Home component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-home/) instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/). */
55
56
  export interface HomeEvents extends HomeViewModelEvents {}
56
57
 
57
58
  /**
@@ -7,6 +7,7 @@ import type { Action, ListItemModifier, State } from "./types.js";
7
7
  /** @deprecated since 5.2. Use [LayerItemCollectionProperties](https://developers.arcgis.com/javascript/latest/references/core/layers/list/types/#LayerItemCollectionProperties) instead. */
8
8
  export interface LayerListViewModelProperties extends Partial<Pick<LayerListViewModel, "checkPublishStatusEnabled" | "listItemCreatedFunction" | "listModeDisabled" | "view">> {}
9
9
 
10
+ /** @deprecated since 5.2. Use [LayerItemCollection](https://developers.arcgis.com/javascript/latest/references/core/layers/list/LayerItemCollection/) instead. */
10
11
  export interface LayerListViewModelEvents {
11
12
  /**
12
13
  * Emitted when the user clicks an [action](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionButton/) or
@@ -79,6 +79,7 @@ export type SubtablesLayer = KnowledgeGraphLayer | MapImageLayer | TileLayer;
79
79
  */
80
80
  export type FlowLayer = SubtablesLayer | CatalogLayer;
81
81
 
82
+ /** @deprecated since version 5.0. Use the [Layer List](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-layer-list/) component instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/). */
82
83
  export interface LayerListEvents extends LayerListViewModelEvents {}
83
84
 
84
85
  /**
@@ -5,6 +5,7 @@ export interface LocateViewModelProperties extends GeolocationPositioningPropert
5
5
 
6
6
  export type LocateViewModelState = "disabled" | "ready" | "locating" | "feature-unsupported" | "error";
7
7
 
8
+ /** @deprecated since version 4.34. Use the [Locate component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-locate/) instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/). */
8
9
  export interface LocateViewModelEvents {
9
10
  /**
10
11
  * Fires after the `locate()` method is called and succeeds.
@@ -48,6 +48,7 @@ export interface LocateProperties extends WidgetProperties, Partial<Pick<Locate,
48
48
  viewModel?: LocateViewModelProperties;
49
49
  }
50
50
 
51
+ /** @deprecated since version 4.32. Use the [Locate component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-locate/) instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/). */
51
52
  export interface LocateEvents extends LocateViewModelEvents {}
52
53
 
53
54
  /**