@arcgis/core 4.23.0-next.20220302 → 4.23.0-next.20220311

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 (318) hide show
  1. package/PopupTemplate.js +1 -1
  2. package/WebMap.js +1 -1
  3. package/analysis/analysisUtils.js +5 -0
  4. package/arcade/featureSetUtils.js +1 -1
  5. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  6. package/assets/esri/core/workers/RemoteClient.js +1 -1
  7. package/assets/esri/core/workers/chunks/{6d8c1e4aad360e02282b.js → 013eefcf29d02f955676.js} +1 -1
  8. package/assets/esri/core/workers/chunks/2a1adc5de77f832b31de.js +1 -0
  9. package/assets/esri/core/workers/chunks/36df90c086bdb14d903b.js +1 -0
  10. package/assets/esri/core/workers/chunks/{5de7afa97148e3cf1ead.js → 3894fe150674f64d6f19.js} +1 -1
  11. package/assets/esri/core/workers/chunks/4d2ef57ff3a5cfc1313f.js +1 -0
  12. package/assets/esri/core/workers/chunks/{5c71398ba99a1cc8a28e.js → 4f90019bf2a1fbf3c754.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{2250625e50f3089247e0.js → 68fc1d7c3fd10a7205c4.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{66dbf817c16fd6b02708.js → 6d01a79473d6556b5c90.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{bdcabd171ede948fac96.js → 6f827a32646bab0a8777.js} +1 -1
  16. package/assets/esri/core/workers/chunks/792fc86380a84b6ac98e.js +1 -0
  17. package/assets/esri/core/workers/chunks/{2d16a1193d2c9de1ef94.js → 7adf62addc056a6309a5.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{02c350995d0e1a549242.js → 807ffca9c71313cf2ea8.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{e0540242f0b568360957.js → 85fde4b92b0c212f5ff6.js} +1 -1
  20. package/assets/esri/core/workers/chunks/8b4c76cebb100e6c06f8.js +1 -0
  21. package/assets/esri/core/workers/chunks/8fcabb9332d1d425e64f.js +1 -0
  22. package/assets/esri/core/workers/chunks/93ace2e16c102db1bc29.js +1 -0
  23. package/assets/esri/core/workers/chunks/{a8f2d9a54ca4511616c9.js → b160857d5d25e8b56335.js} +1 -1
  24. package/assets/esri/core/workers/chunks/be169019d465ad017a9e.js +1 -0
  25. package/assets/esri/core/workers/chunks/{1c8da77ca96b5c7953ea.js → da7cce130c459c84a794.js} +1 -1
  26. package/assets/esri/core/workers/chunks/ea56ec1ea31e3e241773.js +1 -0
  27. package/assets/esri/core/workers/chunks/f6e7506ee0a7b132a65f.js +1 -0
  28. package/assets/esri/core/workers/chunks/f720ce44e0af6a68b608.js +1 -0
  29. package/assets/esri/core/workers/chunks/{76c7ae0956e669b5744a.js → fa42e7b062e44940617e.js} +29 -29
  30. package/assets/esri/images/portal/experiencebuilderwidget16.png +0 -0
  31. package/assets/esri/images/portal/experiencebuilderwidgetpackage16.png +0 -0
  32. package/assets/esri/libs/vxl/vxlLayer.wasm +0 -0
  33. package/assets/esri/themes/base/_mixins.scss +17 -2
  34. package/assets/esri/themes/base/widgets/_BasemapGallery.scss +0 -6
  35. package/assets/esri/themes/base/widgets/_ScaleRangeSlider.scss +1 -0
  36. package/assets/esri/themes/base/widgets/_Widget.scss +4 -0
  37. package/assets/esri/themes/dark/main.css +1 -1
  38. package/assets/esri/themes/dark-blue/main.css +1 -1
  39. package/assets/esri/themes/dark-green/main.css +1 -1
  40. package/assets/esri/themes/dark-purple/main.css +1 -1
  41. package/assets/esri/themes/dark-red/main.css +1 -1
  42. package/assets/esri/themes/light/main.css +1 -1
  43. package/assets/esri/themes/light/view.css +1 -1
  44. package/assets/esri/themes/light-blue/main.css +1 -1
  45. package/assets/esri/themes/light-green/main.css +1 -1
  46. package/assets/esri/themes/light-purple/main.css +1 -1
  47. package/assets/esri/themes/light-red/main.css +1 -1
  48. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ar.json +1 -1
  49. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_bg.json +1 -1
  50. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_bs.json +1 -1
  51. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ca.json +1 -1
  52. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_cs.json +1 -1
  53. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_da.json +1 -1
  54. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_de.json +1 -1
  55. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_el.json +1 -1
  56. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_es.json +1 -1
  57. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_et.json +1 -1
  58. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_fi.json +1 -1
  59. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_fr.json +1 -1
  60. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_he.json +1 -1
  61. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_hr.json +1 -1
  62. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_hu.json +1 -1
  63. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_id.json +1 -1
  64. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_it.json +1 -1
  65. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ja.json +1 -1
  66. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ko.json +1 -1
  67. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_lt.json +1 -1
  68. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_lv.json +1 -1
  69. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_nb.json +1 -1
  70. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_nl.json +1 -1
  71. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_pl.json +1 -1
  72. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_pt-BR.json +1 -1
  73. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_pt-PT.json +1 -1
  74. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ro.json +1 -1
  75. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ru.json +1 -1
  76. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sk.json +1 -1
  77. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sl.json +1 -1
  78. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sr.json +1 -1
  79. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sv.json +1 -1
  80. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_th.json +1 -1
  81. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_tr.json +1 -1
  82. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_uk.json +1 -1
  83. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_vi.json +1 -1
  84. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_zh-CN.json +1 -1
  85. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_zh-HK.json +1 -1
  86. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_zh-TW.json +1 -1
  87. package/assets/esri/widgets/LayerList/t9n/LayerList_ar.json +1 -1
  88. package/assets/esri/widgets/LayerList/t9n/LayerList_bg.json +1 -1
  89. package/assets/esri/widgets/LayerList/t9n/LayerList_bs.json +1 -1
  90. package/assets/esri/widgets/LayerList/t9n/LayerList_ca.json +1 -1
  91. package/assets/esri/widgets/LayerList/t9n/LayerList_cs.json +1 -1
  92. package/assets/esri/widgets/LayerList/t9n/LayerList_da.json +1 -1
  93. package/assets/esri/widgets/LayerList/t9n/LayerList_de.json +1 -1
  94. package/assets/esri/widgets/LayerList/t9n/LayerList_el.json +1 -1
  95. package/assets/esri/widgets/LayerList/t9n/LayerList_es.json +1 -1
  96. package/assets/esri/widgets/LayerList/t9n/LayerList_et.json +1 -1
  97. package/assets/esri/widgets/LayerList/t9n/LayerList_fi.json +1 -1
  98. package/assets/esri/widgets/LayerList/t9n/LayerList_fr.json +1 -1
  99. package/assets/esri/widgets/LayerList/t9n/LayerList_he.json +1 -1
  100. package/assets/esri/widgets/LayerList/t9n/LayerList_hr.json +1 -1
  101. package/assets/esri/widgets/LayerList/t9n/LayerList_hu.json +1 -1
  102. package/assets/esri/widgets/LayerList/t9n/LayerList_id.json +1 -1
  103. package/assets/esri/widgets/LayerList/t9n/LayerList_it.json +1 -1
  104. package/assets/esri/widgets/LayerList/t9n/LayerList_ja.json +1 -1
  105. package/assets/esri/widgets/LayerList/t9n/LayerList_ko.json +1 -1
  106. package/assets/esri/widgets/LayerList/t9n/LayerList_lt.json +1 -1
  107. package/assets/esri/widgets/LayerList/t9n/LayerList_lv.json +1 -1
  108. package/assets/esri/widgets/LayerList/t9n/LayerList_nb.json +1 -1
  109. package/assets/esri/widgets/LayerList/t9n/LayerList_nl.json +1 -1
  110. package/assets/esri/widgets/LayerList/t9n/LayerList_pl.json +1 -1
  111. package/assets/esri/widgets/LayerList/t9n/LayerList_pt-BR.json +1 -1
  112. package/assets/esri/widgets/LayerList/t9n/LayerList_pt-PT.json +1 -1
  113. package/assets/esri/widgets/LayerList/t9n/LayerList_ro.json +1 -1
  114. package/assets/esri/widgets/LayerList/t9n/LayerList_ru.json +1 -1
  115. package/assets/esri/widgets/LayerList/t9n/LayerList_sk.json +1 -1
  116. package/assets/esri/widgets/LayerList/t9n/LayerList_sl.json +1 -1
  117. package/assets/esri/widgets/LayerList/t9n/LayerList_sr.json +1 -1
  118. package/assets/esri/widgets/LayerList/t9n/LayerList_sv.json +1 -1
  119. package/assets/esri/widgets/LayerList/t9n/LayerList_th.json +1 -1
  120. package/assets/esri/widgets/LayerList/t9n/LayerList_tr.json +1 -1
  121. package/assets/esri/widgets/LayerList/t9n/LayerList_uk.json +1 -1
  122. package/assets/esri/widgets/LayerList/t9n/LayerList_vi.json +1 -1
  123. package/assets/esri/widgets/LayerList/t9n/LayerList_zh-CN.json +1 -1
  124. package/assets/esri/widgets/LayerList/t9n/LayerList_zh-HK.json +1 -1
  125. package/assets/esri/widgets/LayerList/t9n/LayerList_zh-TW.json +1 -1
  126. package/assets/esri/widgets/Weather/t9n/Weather_ar.json +1 -1
  127. package/assets/esri/widgets/Weather/t9n/Weather_bg.json +1 -1
  128. package/assets/esri/widgets/Weather/t9n/Weather_bs.json +1 -1
  129. package/assets/esri/widgets/Weather/t9n/Weather_ca.json +1 -1
  130. package/assets/esri/widgets/Weather/t9n/Weather_cs.json +1 -1
  131. package/assets/esri/widgets/Weather/t9n/Weather_da.json +1 -1
  132. package/assets/esri/widgets/Weather/t9n/Weather_de.json +1 -1
  133. package/assets/esri/widgets/Weather/t9n/Weather_el.json +1 -1
  134. package/assets/esri/widgets/Weather/t9n/Weather_es.json +1 -1
  135. package/assets/esri/widgets/Weather/t9n/Weather_et.json +1 -1
  136. package/assets/esri/widgets/Weather/t9n/Weather_fi.json +1 -1
  137. package/assets/esri/widgets/Weather/t9n/Weather_fr.json +1 -1
  138. package/assets/esri/widgets/Weather/t9n/Weather_he.json +1 -1
  139. package/assets/esri/widgets/Weather/t9n/Weather_hr.json +1 -1
  140. package/assets/esri/widgets/Weather/t9n/Weather_hu.json +1 -1
  141. package/assets/esri/widgets/Weather/t9n/Weather_id.json +1 -1
  142. package/assets/esri/widgets/Weather/t9n/Weather_it.json +1 -1
  143. package/assets/esri/widgets/Weather/t9n/Weather_ja.json +1 -1
  144. package/assets/esri/widgets/Weather/t9n/Weather_ko.json +1 -1
  145. package/assets/esri/widgets/Weather/t9n/Weather_lt.json +1 -1
  146. package/assets/esri/widgets/Weather/t9n/Weather_lv.json +1 -1
  147. package/assets/esri/widgets/Weather/t9n/Weather_nb.json +1 -1
  148. package/assets/esri/widgets/Weather/t9n/Weather_nl.json +1 -1
  149. package/assets/esri/widgets/Weather/t9n/Weather_pl.json +1 -1
  150. package/assets/esri/widgets/Weather/t9n/Weather_pt-BR.json +1 -1
  151. package/assets/esri/widgets/Weather/t9n/Weather_pt-PT.json +1 -1
  152. package/assets/esri/widgets/Weather/t9n/Weather_ro.json +1 -1
  153. package/assets/esri/widgets/Weather/t9n/Weather_ru.json +1 -1
  154. package/assets/esri/widgets/Weather/t9n/Weather_sk.json +1 -1
  155. package/assets/esri/widgets/Weather/t9n/Weather_sl.json +1 -1
  156. package/assets/esri/widgets/Weather/t9n/Weather_sr.json +1 -1
  157. package/assets/esri/widgets/Weather/t9n/Weather_sv.json +1 -1
  158. package/assets/esri/widgets/Weather/t9n/Weather_th.json +1 -1
  159. package/assets/esri/widgets/Weather/t9n/Weather_tr.json +1 -1
  160. package/assets/esri/widgets/Weather/t9n/Weather_uk.json +1 -1
  161. package/assets/esri/widgets/Weather/t9n/Weather_vi.json +1 -1
  162. package/assets/esri/widgets/Weather/t9n/Weather_zh-CN.json +1 -1
  163. package/assets/esri/widgets/Weather/t9n/Weather_zh-HK.json +1 -1
  164. package/assets/esri/widgets/Weather/t9n/Weather_zh-TW.json +1 -1
  165. package/chunks/LineMarker.glsl.js +19 -23
  166. package/chunks/RibbonLine.glsl.js +5 -4
  167. package/chunks/vxlLayer.js +1 -1
  168. package/core/quantity.js +1 -0
  169. package/core/quantityUtils.js +1 -1
  170. package/interfaces.d.ts +581 -188
  171. package/layers/VoxelWasmPerScene.js +1 -1
  172. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  173. package/layers/graphics/data/QueryEngine.js +1 -1
  174. package/layers/graphics/data/projectionSupport.js +1 -1
  175. package/layers/support/RasterJobHandler.js +1 -1
  176. package/layers/support/RasterWorker.js +1 -1
  177. package/layers/support/layerUtils.js +1 -1
  178. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  179. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  180. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  181. package/layers/support/rasterFunctions/vectorFieldUtils.js +1 -1
  182. package/package.json +2 -3
  183. package/portal/PortalItem.js +1 -1
  184. package/portal/schemas/definitions.js +1 -1
  185. package/renderers/HeatmapRenderer.js +1 -1
  186. package/renderers/support/RasterSymbolizer.js +1 -1
  187. package/renderers/support/UniqueValueInfo.js +1 -1
  188. package/rest/support/DirectionLine.js +1 -1
  189. package/rest/support/DirectionPoint.js +1 -1
  190. package/rest/support/PointBarrier.js +1 -1
  191. package/rest/support/PolygonBarrier.js +1 -1
  192. package/rest/support/PolylineBarrier.js +1 -1
  193. package/rest/support/RouteInfo.js +1 -1
  194. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  195. package/support/AnalysesCollection.js +1 -1
  196. package/support/basemapUtils.js +1 -1
  197. package/support/revision.js +1 -1
  198. package/symbols/LineStyleMarker3D.js +1 -1
  199. package/symbols/LineSymbolMarker.js +1 -1
  200. package/symbols/TextSymbol3DLayer.js +1 -1
  201. package/symbols/support/textUtils.js +1 -1
  202. package/views/2d/engine/flow/dataUtils.js +1 -1
  203. package/views/2d/engine/vectorTiles/shaders/sources/shaderRepository.js +1 -1
  204. package/views/2d/engine/webgl/GroupContainer.js +1 -1
  205. package/views/2d/engine/webgl/Painter.js +1 -1
  206. package/views/2d/engine/webgl/brushes/WGLGeometryBrushFill.js +1 -1
  207. package/views/2d/engine/webgl/effects/post-processing/DropShadow.js +1 -1
  208. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  209. package/views/2d/layers/imagery/VectorFieldTileView2D.js +1 -1
  210. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
  211. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  212. package/views/3d/analysis/AreaMeasurementAnalysisView3D.js +1 -1
  213. package/views/3d/analysis/LineOfSight/LineOfSightComputation.js +1 -1
  214. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  215. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  216. package/views/3d/environment/CloudsComposition.js +1 -1
  217. package/views/3d/environment/CloudsCompositionTechnique.js +1 -1
  218. package/views/3d/environment/CloudsTechnique.js +1 -1
  219. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  220. package/views/3d/environment/Fog.js +1 -1
  221. package/views/3d/environment/NoiseTextureAtlas.js +1 -1
  222. package/views/3d/environment/NoiseTextureAtlasTechnique.js +1 -1
  223. package/views/3d/environment/PanoramicAtmosphere.js +1 -1
  224. package/views/3d/environment/Precipitation.js +1 -1
  225. package/views/3d/environment/SimpleAtmosphere.js +1 -1
  226. package/views/3d/environment/Stars.js +1 -1
  227. package/views/3d/environment/StarsTechnique.js +1 -1
  228. package/views/3d/environment/SunLighting.d.ts +4 -0
  229. package/views/3d/environment/SunLighting.js +1 -1
  230. package/views/3d/environment/VirtualLighting.d.ts +4 -0
  231. package/views/3d/environment/VirtualLighting.js +1 -1
  232. package/views/3d/interactive/Manipulator3D.js +1 -1
  233. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
  234. package/views/3d/layers/FeatureLayerView3D.js +1 -1
  235. package/views/3d/layers/graphics/ElevationAligners.js +1 -1
  236. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  237. package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
  238. package/views/3d/layers/graphics/Graphics3DFeatureStore.js +1 -1
  239. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  240. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  241. package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
  242. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  243. package/views/3d/layers/graphics/sdfPrimitives.js +1 -1
  244. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  245. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  246. package/views/3d/layers/support/markerUtils.js +1 -1
  247. package/views/3d/support/LaserLineRenderer.js +1 -1
  248. package/views/3d/support/TextureCollection.js +1 -1
  249. package/views/3d/terrain/TerrainRenderer.js +1 -1
  250. package/views/3d/terrain/TileRenderer.js +1 -1
  251. package/views/3d/terrain/terrainUtils.js +1 -1
  252. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +5 -5
  253. package/views/3d/webgl-engine/core/shaderLibrary/util/ScreenSizePerspective.glsl.js +1 -1
  254. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechnique.js +1 -1
  255. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js +1 -1
  256. package/views/3d/webgl-engine/lib/DrapedHeatmapRenderer.js +1 -1
  257. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  258. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  259. package/views/3d/webgl-engine/lib/ShadowHighlightHelper.js +1 -1
  260. package/views/3d/webgl-engine/lib/TextRenderer.js +1 -1
  261. package/views/3d/webgl-engine/lib/TextTextureFactory.js +5 -0
  262. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  263. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  264. package/views/3d/webgl-engine/lib/screenSizePerspectiveUtils.js +1 -1
  265. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  266. package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
  267. package/views/3d/webgl-engine/materials/lineStippleUtils.js +1 -1
  268. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  269. package/views/3d/webgl-engine/shaders/HeatmapDensityTechnique.js +1 -1
  270. package/views/3d/webgl-engine/shaders/HeatmapTechnique.js +1 -1
  271. package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
  272. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
  273. package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
  274. package/views/3d/webgl-engine/shaders/ShadowCastTechnique.js +1 -1
  275. package/views/3d/webgl-engine/shaders/ShadowHighlightTechnique.js +1 -1
  276. package/views/SceneView.js +1 -1
  277. package/views/draw/DrawGraphicTool.js +1 -1
  278. package/views/webgl/capabilities/load.js +1 -1
  279. package/widgets/AreaMeasurement3D/AreaMeasurement3DViewModel.js +1 -1
  280. package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
  281. package/widgets/BasemapGallery/support/basemapCompatibilityUtils.js +1 -1
  282. package/widgets/BasemapGallery.js +1 -1
  283. package/widgets/BasemapToggle/BasemapToggleViewModel.js +1 -1
  284. package/widgets/BasemapToggle.js +1 -1
  285. package/widgets/Daylight/DaylightViewModel.js +1 -1
  286. package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
  287. package/widgets/Editor/BatchCreateWorkflow.d.ts +4 -0
  288. package/widgets/Editor/BatchCreateWorkflowData.d.ts +4 -0
  289. package/widgets/Editor.js +1 -1
  290. package/widgets/ElevationProfile/ElevationProfileController.js +1 -1
  291. package/widgets/ElevationProfile.js +1 -1
  292. package/widgets/FeatureForm/InputField.js +1 -1
  293. package/widgets/FeatureForm.js +1 -1
  294. package/widgets/FeatureTemplates.js +1 -1
  295. package/widgets/LineOfSight/LineOfSightViewModel.js +1 -1
  296. package/widgets/Slice/SliceViewModel.js +1 -1
  297. package/widgets/smartMapping/SmartMappingSliderBase.js +1 -1
  298. package/widgets/support/DatePicker.js +1 -1
  299. package/widgets/support/DatePickerViewModel.js +1 -1
  300. package/widgets/support/DateTimeElementViewModel.d.ts +4 -0
  301. package/widgets/support/{MomentElementViewModel.js → DateTimeElementViewModel.js} +1 -1
  302. package/widgets/support/InteractiveAnalysisViewModel.js +1 -1
  303. package/widgets/support/TimePicker.js +1 -1
  304. package/widgets/support/TimePickerViewModel.js +1 -1
  305. package/assets/esri/core/workers/chunks/2c8fe9bc988c3c5760a5.js +0 -1
  306. package/assets/esri/core/workers/chunks/4e6230f0c88f8081bde5.js +0 -1
  307. package/assets/esri/core/workers/chunks/57c67e260267a1dbc5e3.js +0 -1
  308. package/assets/esri/core/workers/chunks/58aa86c448bc3355990c.js +0 -1
  309. package/assets/esri/core/workers/chunks/6049970cb7d137db0d51.js +0 -1
  310. package/assets/esri/core/workers/chunks/73e5ba3b66bef568c2df.js +0 -1
  311. package/assets/esri/core/workers/chunks/a579651e63a0e70dba18.js +0 -1
  312. package/assets/esri/core/workers/chunks/aa04b90b82bf70caaae4.js +0 -1
  313. package/assets/esri/core/workers/chunks/abf8af455ffc7c9fad03.js +0 -1
  314. package/assets/esri/core/workers/chunks/ce34cfa41a16d55be4bb.js +0 -1
  315. package/assets/esri/core/workers/chunks/d4e71c6c024599849ec3.js +0 -1
  316. package/intl/moment.js +0 -5
  317. package/views/3d/webgl-engine/lib/TextTexture.js +0 -5
  318. package/widgets/support/MomentElementViewModel.d.ts +0 -4
package/PopupTemplate.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"./chunks/tslib.es6.js";import e from"./core/Collection.js";import{JSONSupport as o}from"./core/JSONSupport.js";import{clone as s}from"./core/lang.js";import i from"./core/Logger.js";import{isPromiseLike as r}from"./core/promiseUtils.js";import{property as n}from"./core/accessorSupport/decorators/property.js";import{cast as p}from"./core/accessorSupport/decorators/cast.js";import{reader as l}from"./core/accessorSupport/decorators/reader.js";import{subclass as a}from"./core/accessorSupport/decorators/subclass.js";import{writer as d}from"./core/accessorSupport/decorators/writer.js";import{ensureOneOfType as f}from"./core/accessorSupport/ensureType.js";import{collectFields as c,collectArcadeFieldNames as m}from"./layers/support/fieldUtils.js";import{persistableTypes as u}from"./popup/content.js";import y from"./popup/ExpressionInfo.js";import h from"./popup/FieldInfo.js";import I from"./popup/LayerOptions.js";import x from"./popup/RelatedRecordsInfo.js";import{types as F}from"./popup/content/support/mediaInfoTypes.js";import A from"./support/actions/ActionBase.js";import _ from"./support/actions/ActionButton.js";import g from"./support/actions/ActionToggle.js";import w from"./popup/content/MediaContent.js";import j from"./popup/content/TextContent.js";import N from"./popup/content/AttachmentsContent.js";import C from"./popup/content/FieldsContent.js";import v from"./popup/content/ExpressionContent.js";import E from"./popup/content/Content.js";import O from"./popup/content/CustomContent.js";var S;const T=e.ofType({key:"type",defaultKeyValue:"button",base:A,typeMap:{button:_,toggle:g}}),b={base:E,key:"type",typeMap:{media:w,custom:O,text:j,attachments:N,fields:C,expression:v}},R="esri.PopupTemplate",L=i.getLogger(R),J=["attachments","fields","media","text","expression"];let M=S=class extends o{constructor(){super(...arguments),this.actions=null,this.content="",this.expressionInfos=null,this.fieldInfos=null,this.layerOptions=null,this.lastEditInfoEnabled=!0,this.outFields=null,this.overwriteActions=!1,this.returnGeometry=!1,this.title="",this.relatedRecordsInfo=null}castContent(t){return Array.isArray(t)?t.map((t=>f(b,t))):"string"==typeof t||"function"==typeof t||t instanceof HTMLElement||r(t)?t:(L.error("content error","unsupported content value",{value:t}),null)}readContent(t,e){const{popupElements:o}=e;return Array.isArray(o)&&o.length>0?this._readPopupInfoElements(e):this._readPopupInfo(e)}writeContent(t,e,o,s){"string"!=typeof t?Array.isArray(t)&&(e.popupElements=t.filter((t=>-1!==J.indexOf(t.type))).map((t=>t&&t.toJSON(s))),e.popupElements.forEach((t=>{"attachments"===t.type?this._writeAttachmentContent(e):"media"===t.type?this._writeMediaContent(t,e):"text"===t.type&&this._writeTextContent(t,e)}))):e.description=t}writeFieldInfos(t,e,o,s){const{content:i}=this,r=Array.isArray(i)?i:null;if(t){const o=r?r.filter((t=>"fields"===t.type)):[],i=o.length&&o.every((t=>{var e;return null==(e=t.fieldInfos)?void 0:e.length}));e.fieldInfos=t.filter(Boolean).map((t=>{const e=t.toJSON(s);return i&&(e.visible=!1),e}))}if(r)for(const n of r)"fields"===n.type&&this._writeFieldsContent(n,e)}writeLayerOptions(t,e,o,s){e[o]=!t||null===t.showNoDataRecords&&null===t.returnTopmostRaster?null:t.toJSON(s)}writeTitle(t,e){e.title=t||""}clone(){const{actions:t}=this,e=t?s(t.toArray()):[];return new S({actions:e,content:Array.isArray(this.content)?s(this.content):this.content,expressionInfos:Array.isArray(this.expressionInfos)?s(this.expressionInfos):null,fieldInfos:Array.isArray(this.fieldInfos)?s(this.fieldInfos):null,layerOptions:this.layerOptions?s(this.layerOptions):null,lastEditInfoEnabled:this.lastEditInfoEnabled,outFields:Array.isArray(this.outFields)?s(this.outFields):null,overwriteActions:this.overwriteActions,returnGeometry:this.returnGeometry,title:this.title,relatedRecordsInfo:this.relatedRecordsInfo?s(this.relatedRecordsInfo):null})}async collectRequiredFields(t,e){await this._collectExpressionInfoFields(t,e,this._getContentExpressionInfos(this.content,this.expressionInfos)),c(t,e,[...this.outFields||[],...this._getActionsFields(this.actions),...this._getTitleFields(this.title),...this._getContentFields(this.content)])}async getRequiredFields(t){const e=new Set;return await this.collectRequiredFields(e,t),[...e].sort()}_writeFieldsContent(t,e){if(!Array.isArray(t.fieldInfos)||!t.fieldInfos.length)return;const o=s(t.fieldInfos);Array.isArray(e.fieldInfos)?o.forEach((t=>{const o=e.fieldInfos.find((e=>e.fieldName.toLowerCase()===t.fieldName.toLowerCase()));o?o.visible=!0:e.fieldInfos.push(t)})):e.fieldInfos=o}_writeAttachmentContent(t){t.showAttachments||(t.showAttachments=!0)}_writeTextContent(t,e){!e.description&&t.text&&(e.description=t.text)}_writeMediaContent(t,e){if(!Array.isArray(t.mediaInfos)||!t.mediaInfos.length)return;const o=s(t.mediaInfos);Array.isArray(e.mediaInfos)?e.mediaInfos=[...e.mediaInfos,...o]:e.mediaInfos=o}_readPopupInfoElements({description:t,mediaInfos:e,popupElements:o}){const s={description:!1,mediaInfos:!1};return o.map((o=>"media"===o.type?(o.mediaInfos||!e||s.mediaInfos||(o.mediaInfos=e,s.mediaInfos=!0),w.fromJSON(o)):"text"===o.type?(o.text||!t||s.description||(o.text=t,s.description=!0),j.fromJSON(o)):"attachments"===o.type?N.fromJSON(o):"fields"===o.type?C.fromJSON(o):"expression"===o.type?v.fromJSON(o):void 0)).filter(Boolean)}_readPopupInfo({description:t,mediaInfos:e,showAttachments:o}){const s=[];return t?s.push(new j({text:t})):s.push(new C),Array.isArray(e)&&e.length&&s.push(w.fromJSON({mediaInfos:e})),o&&s.push(N.fromJSON({displayType:"auto"})),s.length?s:t}_getContentElementFields(t){const e=null==t?void 0:t.type;if("attachments"===e)return[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description)];if("custom"===e)return t.outFields||[];if("fields"===e)return[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description),...this._getFieldInfoFields(t.fieldInfos||this.fieldInfos)];if("media"===e){const e=t.mediaInfos||[];return[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description),...e.reduce(((t,e)=>[...t,...this._getMediaInfoFields(e)]),[])]}return"text"===e?this._extractFieldNames(t.text):[]}_getMediaInfoFields(t){const{caption:e,title:o,value:s}=t,i=s||{},{fields:r=[],normalizeField:n,tooltipField:p,sourceURL:l,linkURL:a}=i,d=[...this._extractFieldNames(o),...this._extractFieldNames(e),...this._extractFieldNames(l),...this._extractFieldNames(a),...r];return n&&d.push(n),p&&d.push(p),d}_getContentExpressionInfos(t,e){return Array.isArray(t)?t.reduce(((t,e)=>[...t,..."expression"===e.type&&e.expressionInfo?[e.expressionInfo]:[]]),e||[]):[]}_getContentFields(t){return"string"==typeof t?this._extractFieldNames(t):Array.isArray(t)?t.reduce(((t,e)=>[...t,...this._getContentElementFields(e)]),[]):[]}async _collectExpressionInfoFields(t,e,o){o&&await Promise.all(o.map((o=>m(t,e,o.expression))))}_getFieldInfoFields(t){return t?t.filter((t=>void 0===t.visible||!!t.visible)).map((t=>t.fieldName)).filter((t=>-1===t.indexOf("relationships/")&&-1===t.indexOf("expression/"))):[]}_getActionsFields(t){return t?t.toArray().reduce(((t,e)=>[...t,...this._getActionFields(e)]),[]):[]}_getActionFields(t){const{className:e,title:o,type:s}=t,i="button"===s||"toggle"===s?t.image:"";return[...this._extractFieldNames(o),...this._extractFieldNames(e),...this._extractFieldNames(i)]}_getTitleFields(t){return"string"==typeof t?this._extractFieldNames(t):[]}_extractFieldNames(t){if(!t||"string"!=typeof t)return[];const e=/{[^}]*}/g,o=t.match(e);if(!o)return[];const s=/\{(\w+):.+\}/,i=o.filter((t=>!(0===t.indexOf("{relationships/")||0===t.indexOf("{expression/")))).map((t=>t.replace(s,"{$1}")));return i?i.map((t=>t.slice(1,-1))):[]}};t([n({type:T})],M.prototype,"actions",void 0),t([n()],M.prototype,"content",void 0),t([p("content")],M.prototype,"castContent",null),t([l("content",["description","fieldInfos","popupElements","mediaInfos","showAttachments"])],M.prototype,"readContent",null),t([d("content",{popupElements:{type:e.ofType(u)},showAttachments:{type:Boolean},mediaInfos:{type:e.ofType(F)},description:{type:String}})],M.prototype,"writeContent",null),t([n({type:[y],json:{write:!0}})],M.prototype,"expressionInfos",void 0),t([n({type:[h]})],M.prototype,"fieldInfos",void 0),t([d("fieldInfos")],M.prototype,"writeFieldInfos",null),t([n({type:I})],M.prototype,"layerOptions",void 0),t([d("layerOptions")],M.prototype,"writeLayerOptions",null),t([n({type:Boolean,json:{read:{source:"showLastEditInfo"},write:{target:"showLastEditInfo"},default:!0}})],M.prototype,"lastEditInfoEnabled",void 0),t([n()],M.prototype,"outFields",void 0),t([n()],M.prototype,"overwriteActions",void 0),t([n()],M.prototype,"returnGeometry",void 0),t([n({json:{type:String}})],M.prototype,"title",void 0),t([d("title")],M.prototype,"writeTitle",null),t([n({type:x,json:{write:!0}})],M.prototype,"relatedRecordsInfo",void 0),M=S=t([a(R)],M);const B=M;export{B as default};
5
+ import{_ as t}from"./chunks/tslib.es6.js";import e from"./core/Collection.js";import{JSONSupport as o}from"./core/JSONSupport.js";import{clone as s}from"./core/lang.js";import i from"./core/Logger.js";import{isPromiseLike as r}from"./core/promiseUtils.js";import{property as n}from"./core/accessorSupport/decorators/property.js";import{cast as p}from"./core/accessorSupport/decorators/cast.js";import{reader as l}from"./core/accessorSupport/decorators/reader.js";import{subclass as a}from"./core/accessorSupport/decorators/subclass.js";import{writer as d}from"./core/accessorSupport/decorators/writer.js";import{ensureOneOfType as c}from"./core/accessorSupport/ensureType.js";import{collectFields as f,collectArcadeFieldNames as m}from"./layers/support/fieldUtils.js";import{persistableTypes as u}from"./popup/content.js";import y from"./popup/ExpressionInfo.js";import h from"./popup/FieldInfo.js";import I from"./popup/LayerOptions.js";import x from"./popup/RelatedRecordsInfo.js";import{types as F}from"./popup/content/support/mediaInfoTypes.js";import A from"./support/actions/ActionBase.js";import _ from"./support/actions/ActionButton.js";import g from"./support/actions/ActionToggle.js";import w from"./popup/content/MediaContent.js";import j from"./popup/content/TextContent.js";import N from"./popup/content/AttachmentsContent.js";import C from"./popup/content/FieldsContent.js";import v from"./popup/content/ExpressionContent.js";import E from"./popup/content/Content.js";import O from"./popup/content/CustomContent.js";var S;const T=e.ofType({key:"type",defaultKeyValue:"button",base:A,typeMap:{button:_,toggle:g}}),b={base:E,key:"type",typeMap:{media:w,custom:O,text:j,attachments:N,fields:C,expression:v}},R="esri.PopupTemplate",L=i.getLogger(R),J=["attachments","fields","media","text","expression"];let M=S=class extends o{constructor(){super(...arguments),this.actions=null,this.content="",this.expressionInfos=null,this.fieldInfos=null,this.layerOptions=null,this.lastEditInfoEnabled=!0,this.outFields=null,this.overwriteActions=!1,this.returnGeometry=!1,this.title="",this.relatedRecordsInfo=null}castContent(t){return Array.isArray(t)?t.map((t=>c(b,t))):"string"==typeof t||"function"==typeof t||t instanceof HTMLElement||r(t)?t:(L.error("content error","unsupported content value",{value:t}),null)}readContent(t,e){const{popupElements:o}=e;return Array.isArray(o)&&o.length>0?this._readPopupInfoElements(e):this._readPopupInfo(e)}writeContent(t,e,o,s){"string"!=typeof t?Array.isArray(t)&&(e.popupElements=t.filter((t=>-1!==J.indexOf(t.type))).map((t=>t&&t.toJSON(s))),e.popupElements.forEach((t=>{"attachments"===t.type?this._writeAttachmentContent(e):"media"===t.type?this._writeMediaContent(t,e):"text"===t.type&&this._writeTextContent(t,e)}))):e.description=t}writeFieldInfos(t,e,o,s){const{content:i}=this,r=Array.isArray(i)?i:null;if(t){const o=r?r.filter((t=>"fields"===t.type)):[],i=o.length&&o.every((t=>{var e;return null==(e=t.fieldInfos)?void 0:e.length}));e.fieldInfos=t.filter(Boolean).map((t=>{const e=t.toJSON(s);return i&&(e.visible=!1),e}))}if(r)for(const n of r)"fields"===n.type&&this._writeFieldsContent(n,e)}writeLayerOptions(t,e,o,s){e[o]=!t||null===t.showNoDataRecords&&null===t.returnTopmostRaster?null:t.toJSON(s)}writeTitle(t,e){e.title=t||""}clone(){const{actions:t}=this,e=t?s(t.toArray()):[];return new S({actions:e,content:Array.isArray(this.content)?s(this.content):this.content,expressionInfos:Array.isArray(this.expressionInfos)?s(this.expressionInfos):null,fieldInfos:Array.isArray(this.fieldInfos)?s(this.fieldInfos):null,layerOptions:this.layerOptions?s(this.layerOptions):null,lastEditInfoEnabled:this.lastEditInfoEnabled,outFields:Array.isArray(this.outFields)?s(this.outFields):null,overwriteActions:this.overwriteActions,returnGeometry:this.returnGeometry,title:this.title,relatedRecordsInfo:this.relatedRecordsInfo?s(this.relatedRecordsInfo):null})}async collectRequiredFields(t,e){const o=this.expressionInfos||[];await this._collectExpressionInfoFields(t,e,[...o,...this._getContentExpressionInfos(this.content,o)]),f(t,e,[...this.outFields||[],...this._getActionsFields(this.actions),...this._getTitleFields(this.title),...this._getContentFields(this.content)])}async getRequiredFields(t){const e=new Set;return await this.collectRequiredFields(e,t),[...e].sort()}_writeFieldsContent(t,e){if(!Array.isArray(t.fieldInfos)||!t.fieldInfos.length)return;const o=s(t.fieldInfos);Array.isArray(e.fieldInfos)?o.forEach((t=>{const o=e.fieldInfos.find((e=>e.fieldName.toLowerCase()===t.fieldName.toLowerCase()));o?o.visible=!0:e.fieldInfos.push(t)})):e.fieldInfos=o}_writeAttachmentContent(t){t.showAttachments||(t.showAttachments=!0)}_writeTextContent(t,e){!e.description&&t.text&&(e.description=t.text)}_writeMediaContent(t,e){if(!Array.isArray(t.mediaInfos)||!t.mediaInfos.length)return;const o=s(t.mediaInfos);Array.isArray(e.mediaInfos)?e.mediaInfos=[...e.mediaInfos,...o]:e.mediaInfos=o}_readPopupInfoElements({description:t,mediaInfos:e,popupElements:o}){const s={description:!1,mediaInfos:!1};return o.map((o=>"media"===o.type?(o.mediaInfos||!e||s.mediaInfos||(o.mediaInfos=e,s.mediaInfos=!0),w.fromJSON(o)):"text"===o.type?(o.text||!t||s.description||(o.text=t,s.description=!0),j.fromJSON(o)):"attachments"===o.type?N.fromJSON(o):"fields"===o.type?C.fromJSON(o):"expression"===o.type?v.fromJSON(o):void 0)).filter(Boolean)}_readPopupInfo({description:t,mediaInfos:e,showAttachments:o}){const s=[];return t?s.push(new j({text:t})):s.push(new C),Array.isArray(e)&&e.length&&s.push(w.fromJSON({mediaInfos:e})),o&&s.push(N.fromJSON({displayType:"auto"})),s.length?s:t}_getContentElementFields(t){const e=null==t?void 0:t.type;if("attachments"===e)return[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description)];if("custom"===e)return t.outFields||[];if("fields"===e)return[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description),...this._getFieldInfoFields(t.fieldInfos||this.fieldInfos)];if("media"===e){const e=t.mediaInfos||[];return[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description),...e.reduce(((t,e)=>[...t,...this._getMediaInfoFields(e)]),[])]}return"text"===e?this._extractFieldNames(t.text):[]}_getMediaInfoFields(t){const{caption:e,title:o,value:s}=t,i=s||{},{fields:r=[],normalizeField:n,tooltipField:p,sourceURL:l,linkURL:a}=i,d=[...this._extractFieldNames(o),...this._extractFieldNames(e),...this._extractFieldNames(l),...this._extractFieldNames(a),...r];return n&&d.push(n),p&&d.push(p),d}_getContentExpressionInfos(t,e){return Array.isArray(t)?t.reduce(((t,e)=>[...t,..."expression"===e.type&&e.expressionInfo?[e.expressionInfo]:[]]),e):[]}_getContentFields(t){return"string"==typeof t?this._extractFieldNames(t):Array.isArray(t)?t.reduce(((t,e)=>[...t,...this._getContentElementFields(e)]),[]):[]}async _collectExpressionInfoFields(t,e,o){o&&await Promise.all(o.map((o=>m(t,e,o.expression))))}_getFieldInfoFields(t){return t?t.filter((t=>void 0===t.visible||!!t.visible)).map((t=>t.fieldName)).filter((t=>-1===t.indexOf("relationships/")&&-1===t.indexOf("expression/"))):[]}_getActionsFields(t){return t?t.toArray().reduce(((t,e)=>[...t,...this._getActionFields(e)]),[]):[]}_getActionFields(t){const{className:e,title:o,type:s}=t,i="button"===s||"toggle"===s?t.image:"";return[...this._extractFieldNames(o),...this._extractFieldNames(e),...this._extractFieldNames(i)]}_getTitleFields(t){return"string"==typeof t?this._extractFieldNames(t):[]}_extractFieldNames(t){if(!t||"string"!=typeof t)return[];const e=/{[^}]*}/g,o=t.match(e);if(!o)return[];const s=/\{(\w+):.+\}/,i=o.filter((t=>!(0===t.indexOf("{relationships/")||0===t.indexOf("{expression/")))).map((t=>t.replace(s,"{$1}")));return i?i.map((t=>t.slice(1,-1))):[]}};t([n({type:T})],M.prototype,"actions",void 0),t([n()],M.prototype,"content",void 0),t([p("content")],M.prototype,"castContent",null),t([l("content",["description","fieldInfos","popupElements","mediaInfos","showAttachments"])],M.prototype,"readContent",null),t([d("content",{popupElements:{type:e.ofType(u)},showAttachments:{type:Boolean},mediaInfos:{type:e.ofType(F)},description:{type:String}})],M.prototype,"writeContent",null),t([n({type:[y],json:{write:!0}})],M.prototype,"expressionInfos",void 0),t([n({type:[h]})],M.prototype,"fieldInfos",void 0),t([d("fieldInfos")],M.prototype,"writeFieldInfos",null),t([n({type:I})],M.prototype,"layerOptions",void 0),t([d("layerOptions")],M.prototype,"writeLayerOptions",null),t([n({type:Boolean,json:{read:{source:"showLastEditInfo"},write:{target:"showLastEditInfo"},default:!0}})],M.prototype,"lastEditInfoEnabled",void 0),t([n()],M.prototype,"outFields",void 0),t([n()],M.prototype,"overwriteActions",void 0),t([n()],M.prototype,"returnGeometry",void 0),t([n({json:{type:String}})],M.prototype,"title",void 0),t([d("title")],M.prototype,"writeTitle",null),t([n({type:x,json:{write:!0}})],M.prototype,"relatedRecordsInfo",void 0),M=S=t([a(R)],M);const B=M;export{B as default};
package/WebMap.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import{flatten as o}from"./core/arrayUtils.js";import a from"./core/Collection.js";import s from"./core/Error.js";import n from"./core/Loadable.js";import{loadAll as l}from"./core/loadAll.js";import p from"./core/Logger.js";import{unwrap as m,isSome as u}from"./core/maybe.js";import{MultiOriginJSONMixin as h,MultiOriginJSONSupport as d}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as c}from"./core/Promise.js";import{eachAlways as y}from"./core/promiseUtils.js";import{whenOnce as w}from"./core/reactiveUtils.js";import{urlToObject as f,isDataProtocol as g,dataComponents as b,addQueryParameter as _}from"./core/urlUtils.js";import{property as v}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import"./core/accessorSupport/ensureType.js";import{reader as S}from"./core/accessorSupport/decorators/reader.js";import{subclass as I}from"./core/accessorSupport/decorators/subclass.js";import{writer as A}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as j}from"./core/accessorSupport/originUtils.js";import{readLoadable as O}from"./core/accessorSupport/read.js";import L from"./geometry/SpatialReference.js";import{geographicToWebMercator as P,webMercatorToGeographic as U}from"./geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as V}from"./layers/support/arcgisLayerUrl.js";import F from"./networks/UtilityNetwork.js";import T from"./portal/Portal.js";import W from"./portal/PortalItem.js";import{removeTypeKeyword as R,addTypeKeyword as x,hasTypeKeyword as N}from"./portal/support/portalItemUtils.js";import{project as M}from"./rest/geometryService/project.js";import k from"./rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as C,isDeveloperBasemapLayer as E}from"./support/basemapUtils.js";import B from"./support/MapFloorInfo.js";import G from"./webdoc/RangeInfo.js";import J from"./webdoc/Widgets.js";import{getOptimalThumbnailSize as D}from"./webdoc/support/thumbnailUtils.js";import{getLayerJSON as K}from"./webdoc/support/writeUtils.js";import $ from"./webmap/ApplicationProperties.js";import z from"./webmap/Bookmark.js";import q from"./webmap/InitialViewProperties.js";import{Version as H}from"./webmap/Version.js";import Q from"./webmap/background/ColorBackground.js";const X=new H(2,23),Y="Web Map",Z=a.ofType(z),ee=a.ofType(F),te=p.getLogger("esri.WebMap"),re=new Map;re.set("image/jpeg","jpeg"),re.set("image/jpg","jpg"),re.set("image/png","png"),re.set("image/gif","gif");const ie="ArcGIS Pro",oe="ArcGIS API for JavaScript",ae="CollectorDisabled",se="Collector",ne="Data Editing",le="OfflineDisabled",pe="Offline",me="Workforce Project",ue="Workforce Worker",he="Workforce Dispatcher",de="Offline Map Areas",ce="FieldMapsDisabled",ye="DeveloperBasemap",we=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));let fe=class extends(h(n.LoadableMixin(c(r)))){constructor(e){super(e),this.applicationProperties=null,this.bookmarks=new Z,this.floorInfo=null,this.initialViewProperties=new q,this.portalItem=null,this.presentation=null,this.sourceVersion=null,this.widgets=null,this.utilityNetworks=null,this.authoringApp=this.authoringAppVersion=null,this._isAuthoringAppSetByUser=this._isAuthoringAppVersionSetByUser=!1}destroy(){const e=this.portalItem;this.portalItem=null,null==e||e.destroy()}initialize(){if(this.when().catch((e=>{te.error("#load()","Failed to load web map",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t)}}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp=oe}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}readInitialViewProperties(e,t){var r;const o=new q;t.background&&(o.background=Q.fromJSON(t.background));const a=null==(r=t.initialState)?void 0:r.viewpoint;if(a){if(a.rotation){H.parse(t.version||"","webmap").lessThan(2,20)&&t.authoringApp===ie&&(a.rotation*=-1)}o.viewpoint=i.fromJSON(a)}return t.mapRangeInfo&&(o.rangeInfo=G.fromJSON(t.mapRangeInfo)),t.spatialReference&&(o.spatialReference=L.fromJSON(t.spatialReference)),o}writeInitialViewProperties(e,t,r,i){if(!e)return;const o=e.background;o&&o.color&&(t.background=o.write({},i)),e.viewpoint&&(t.initialState={viewpoint:e.viewpoint.write({},i)}),e.rangeInfo&&(t.mapRangeInfo=e.rangeInfo.toJSON(i)),e.spatialReference&&(t.spatialReference=e.spatialReference.write({},i))}writeLayers(e,t,r,i){t[r]=this._writeLayers(e,i,"operational-layers")}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new H(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${X.major}.${X.minor}`}writeTables(e,t,r,i){const o=this._writeLayers(e,i,"tables");o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem&&this.portalItem.thumbnailUrl||null}set thumbnailUrl(e){e?(this._override("thumbnailUrl",e),this._thumbnailFilename=this._generateCustomThumbnailFilename(e)):this._clearThumbnailOverride()}load(e){return this.addResolvingPromise(this._loadFromSource()),Promise.resolve(this)}loadAll(){return l(this,(e=>{e(this.ground,this.basemap,this.layers,this.tables)}))}read(e,t){t={...t,origin:"web-map"};const r=this._getAuthoringPropsState();O(this,e,(t=>super.read(e,t)),t),this._restoreAuthoringPropsFromState(r)}write(e,t){if("loaded"!==this.loadStatus){const e=new s("webmap:not-loaded","Web map must be loaded before it can be serialized");throw te.error("#toJSON()","Web map must be loaded before it can be serialized",this.loadError||this.loadStatus),e}return this._removeDanglingLayerRefs(),t={...t,origin:"web-map",restrictedWebMapWriting:!0,webmap:this},super.write(e,t)}async save(e){e=e||{},this._validateItem(),await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),this._validateMap();const t=this.portalItem,r={origin:"web-map",messages:[],writtenProperties:[],url:t.itemUrl&&f(t.itemUrl),portal:t.portal||T.getDefault()},i=this.write({},r);return this._validateJSONForWriting(r,e),await this._updateItemProperties(t),await this._updateItem(t,i,r),await this._updateItemThumbnail(),t}async saveAs(e,t){t=t||{};const r=this._getPortalItem(e);await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),this._validateMap();const i={origin:"web-map",messages:[],writtenProperties:[],url:null,portal:r.portal},o=this.write({},i);this._validateJSONForWriting(i,t),await this._updateItemPropertiesForSaveAs(r);const a=this._getThumbnailState();return await this._createItem(r,o,i,t),this._restoreThumbnailFromState(a),await this._updateItemThumbnail(),r}async updateFrom(e,t){const r=this._updateFromInternal(e,t);this._updateFromPromise=r,await r;r===this._updateFromPromise&&(this._updateFromPromise=null)}getLayerJSONFromResourceInfo(e){var t,r,i,a;const s=this.resourceInfo;return this._collectAllLayersJSON(o([null==s||null==(t=s.baseMap)?void 0:t.baseMapLayers,null==s?void 0:s.operationalLayers,null==(r=this.basemap)||null==(i=r.resourceInfo)||null==(a=i.data)?void 0:a.baseMapLayers])).find((t=>t.id===e.id))}_collectAllLayersJSON(e){return e.reduce(((e,t)=>(e.push(t),"GroupLayer"===t.layerType&&(e=e.concat(this._collectAllLayersJSON(t.layers||[]))),e)),[])}_writeLayers(e,t,r){t={...t,layerContainerType:r};return e.map((e=>m(K(e,"tables"===r?null:this.getLayerJSONFromResourceInfo(e),t)))).filter(Boolean).toArray()}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-map"}):this.portalItem&&this.portalItem.id?this._loadFromItem(this.portalItem):Promise.resolve(null)}_loadFromItem(e){return e.load().catch((e=>{throw new s("webmap:load-portal-item","Failed to load portal item",{error:e})})).then((()=>{if("Web Map"!==e.type)throw new s("webmap:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Map'",{type:e.type})})).then((()=>e.fetchData())).then((t=>(this.resourceInfo=t,this._readAndLoadFromJSON(t,{origin:"web-map",portal:e.portal||T.getDefault()})))).then((()=>this._computeInitialViewpoint()))}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_validateJSON(e){const t=H.parse(e.version||"","webmap");return X.validate(t),e.version=`${t.major}.${t.minor}`,e}_loadFromJSON(e,t){const r={context:{...t,layerContainerType:"operational-layers"}};return this.portalItem&&(r.context.portal=this.portalItem.portal||T.getDefault()),import("./layers/support/layersCreator.js").then((({populateOperationalLayers:t})=>{const i=[],o=e.operationalLayers;o&&o.length&&i.push(t(this.layers,o,r));const a={...r,context:{...r.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"},s=e.tables;return s&&s.length&&i.push(t(this.tables,s,a)),y(i).then((()=>{}))}))}async _computeInitialViewpoint(){var e,t;let r=this.initialViewProperties;if(null==(e=r)||null==(t=e.viewpoint)?void 0:t.targetGeometry)return;const o=await this._getExtentFromItem();o&&(r=r?r.clone():new q,r.viewpoint=new i,r.viewpoint.targetGeometry=o,this.initialViewProperties=r)}async _getExtentFromItem(){var e,t;const r=null==(e=this.initialViewProperties)?void 0:e.spatialReference,i=null==(t=this.portalItem)?void 0:t.extent;if(r&&i){if(r.isWGS84)return i.clone();if(r.isWebMercator)return P(i);return(await import("./portal/support/geometryServiceUtils.js")).getGeometryServiceURL(this.portalItem).then((e=>{const t=new k;return t.geometries=[i],t.outSpatialReference=r,M(e,t)})).then((e=>e[0])).catch((e=>(te.error("Error projecting item's extent:",e),null)))}return null}_removeDanglingLayerRefs(){const e=this.applicationProperties,t=e&&e.viewing&&e.viewing.search,r=e=>!!this.allLayers.find((t=>t.id===e));t&&t.layers&&(t.layers=t.layers.filter((e=>r(e.id)))),t&&t.tables&&(t.tables=t.tables.filter((e=>!!this.tables.find((t=>t.id===e.id)))));const i=e&&e.editing&&e.editing.locationTracking;i&&i.info&&!r(i.info.layerId)&&(e.editing=null);const o=this.presentation&&this.presentation.slides;o&&o.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>r(e.id))))}))}_validateMap(){if(!this.basemap||!this.basemap.baseLayers.length)throw new s("webmap:save","Map does not have a valid basemap with a base layer.")}_validateItem(){if(!this.portalItem)throw te.error("save: requires the portalItem property to be set"),new s("webmap:portal-item-not-set","Portal item to save to has not been set on the WebMap");this._validateItemType(this.portalItem)}_validateItemType(e){if(e.type!==Y)throw new s("webmap:portal-item-wrong-type",`Portal item needs to have type "${Y}"`)}_loadLayerContainers(){const e=[];return this.basemap&&e.push(this.basemap.load()),this.ground&&e.push(this.ground.load()),y(e).then((()=>{}))}async _beforeSave(){const e=[];for(const t of this.allLayers)if("beforeSave"in t&&"function"==typeof t.beforeSave){const r=t.beforeSave();r&&e.push(r)}await y(e)}_loadAllLayers(){const e=this._getAllLayersAndTables().map((e=>e.load()));return y(e).then((()=>{}))}_getAllLayersAndTables(){return this.allLayers.concat(this.allTables)}_validateJSONForWriting(e,t){let r=e.messages.filter((e=>"error"===e.type)).map((e=>new s(e.name,e.message,e.details)));if(t.ignoreUnsupported&&(r=r.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name))),r.length>0)throw new s("webmap:save","Failed to save webmap due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:r})}async _updateItemProperties(e){e.extent=await this._getWGS84Extent(this.initialViewProperties.viewpoint.targetGeometry),await this._updateTypeKeywords(e)}async _updateItemPropertiesForSaveAs(e){R(e,ae),R(e,le),R(e,me),R(e,ue),R(e,he),R(e,de),R(e,ce),await this._updateItemProperties(e)}async _getWGS84Extent(e){const t=e.clone().normalize();let r;if(t.length>1)for(const i of t)r?i.width>r.width&&(r=i):r=i;else r=t[0];return this._projectToWGS84(r)}async _projectToWGS84(e){const t=e.spatialReference;if(t.isWGS84)return e.clone();if(t.isWebMercator)return U(e);const r=await import("./portal/support/geometryServiceUtils.js"),i=await r.getGeometryServiceURL(this.portalItem),o=new k;o.geometries=[e],o.outSpatialReference=L.WGS84;return(await M(i,o))[0]}async _updateTypeKeywords(e){x(e,oe),await this._loadAllLayers(),this._evalCollectorKeyword(e),this._evalDataEditingKeyword(e),this._evalOfflineKeyword(e),this._evalDeveloperBasemapKeyword(e),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}_evalCollectorKeyword(e){N(e,ae)||N(e,me)||N(e,ue)||N(e,he)||!this._hasEditableFeatureLayer()?R(e,se):x(e,se)}_evalDataEditingKeyword(e){this._hasEditableFeatureLayer()?x(e,ne):R(e,ne)}_evalOfflineKeyword(e){!N(e,le)&&this._isOfflineCapableMap()?x(e,pe):R(e,pe)}_evalDeveloperBasemapKeyword(e){C(this.basemap)?x(e,ye):R(e,ye)}_hasEditableFeatureLayer(){return this._getAllLayersAndTables().some((e=>e.loaded&&this._isFeatureServiceLayer(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled))}_isFeatureServiceLayer(e){return!("feature"!==e.type||!e.source||"feature-layer"!==e.source.type)}_isOfflineCapableMap(){return this._getAllLayersAndTables().filter((e=>"group"!==e.type)).every((e=>e.loaded&&this._isOfflineCapableLayer(e)))}_isOfflineCapableLayer(e){return this._isFeatureServiceLayer(e)&&e.capabilities.operations.supportsSync||("tile"===e.type||"vector-tile"===e.type)&&(e.capabilities.operations.supportsExportTiles||this._isExportableAGOLTileLayer(e)||E(e))&&e.spatialReference.equals(this.initialViewProperties.spatialReference)}_isExportableAGOLTileLayer(e){return"tile"===e.type&&(V(e.url)&&we.some((t=>e.url.toLowerCase().indexOf("/"+t+"/")>-1)))}async _updateItem(e,t,r){await e.update({data:t}),this._syncUpInstanceWithItem(e,t,r)}async _createItem(e,t,r,i){const o=this.portalItem,a=!!(o&&o.id&&o.portal.user),n=e.portal;if(await n._signIn(),!await this._canCopyItem(o,a,n))throw new s("webmap:save-as-copy-not-allowed","Owner of this map does not allow others to save a copy");await n.user.addItem({item:e,folder:i.folder,data:t}),this.portalItem=e,this._syncUpInstanceWithItem(e,t,r)}async _canCopyItem(e,t,r){return!(u(e)&&e.id&&e.typeKeywords&&e.typeKeywords.indexOf("useOnly")>-1)||e.portal.portalHostname===r.portalHostname&&(t||await e.reload(),"admin"===e.itemControl||"update"===e.itemControl)}_syncUpInstanceWithItem(e,t,r){d.prototype.read.call(this,{version:t.version,authoringApp:t.authoringApp,authoringAppVersion:t.authoringAppVersion},{origin:"web-map",ignoreDefaults:!0,url:e.itemUrl&&f(e.itemUrl)}),j(r),this.resourceInfo=t}async _updateItemThumbnail(){this.thumbnailUrl&&this._isOverridden("thumbnailUrl")&&(await this.portalItem.updateThumbnail({thumbnail:this.thumbnailUrl,filename:this._thumbnailFilename}),this._clearThumbnailOverride())}_getPortalItem(e){let t=W.from(e);return t.id&&(t=t.clone(),t.id=null),t.type||(t.type=Y),t.portal||(t.portal=T.getDefault()),this._validateItemType(t),t}async _updateFromInternal(e,t){if(t=t||{},await w((()=>e.ready)),this._updateInitialViewProperties(e,t),e.map===this)for(const r of e.allLayerViews)for(const e of["visible","featureEffect"])e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e]);await this._updateThumbnailUrl(e,t)}_updateInitialViewProperties(e,t){var r;t.backgroundExcluded||(this.initialViewProperties.background=null==(r=e.background)?void 0:r.clone());if(this.initialViewProperties.spatialReference=e.spatialReference.clone(),t.viewpointExcluded||(this.initialViewProperties.viewpoint=new i({rotation:e.rotation,scale:t.scalePreserved?e.scale:null,targetGeometry:this._getViewExtent(e)})),!t.widgetsExcluded)for(const i of e.persistableViewModels)i.updateWebDocument(this)}_getViewExtent(e){const t=e.center.clone().normalize(),r=e.extent.clone(),i=r.width/2;return r.xmin=t.x-i,r.xmax=t.x+i,r}async _updateThumbnailUrl(e,t){if(t.thumbnailExcluded)return;const r=D(e,t.thumbnailSize),i=await e.takeScreenshot({format:"png",width:r.width,height:r.height});this._setAutoGeneratedThumbnail(i.dataUrl)}_setAutoGeneratedThumbnail(e){this.thumbnailUrl=e,this._thumbnailFilename=null}_clearThumbnailOverride(){this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"),this._thumbnailFilename=null}_generateCustomThumbnailFilename(e){if(g(e)){const t=b(e),r=t&&t.mediaType,i=r&&re.get(r.toLowerCase())||null,o=`thumbnail${Date.now()}`;return i?`${o}.${i}`:o}return null}_getThumbnailState(){let e=this.thumbnailUrl;return e&&(e=this._isOverridden("thumbnailUrl")?e:_(e,"w","8192")),{thumbnailUrl:e,filename:this._thumbnailFilename}}_restoreThumbnailFromState(e){this.thumbnailUrl=e.thumbnailUrl,this._thumbnailFilename=e.filename}_getAuthoringPropsState(){return{authoringApp:this.authoringApp,authoringAppVersion:this.authoringAppVersion,isAuthoringAppSetByUser:this._isAuthoringAppSetByUser,isAuthoringAppVersionSetByUser:this._isAuthoringAppVersionSetByUser}}_restoreAuthoringPropsFromState(e){e.isAuthoringAppSetByUser?this.authoringApp=e.authoringApp:this._isAuthoringAppSetByUser=!1,e.isAuthoringAppVersionSetByUser?this.authoringAppVersion=e.authoringAppVersion:this._isAuthoringAppVersionSetByUser=!1}static fromJSON(e){const t=e;if(!t)throw new s("webmap:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:t})}};fe.VERSION=X,e([v({type:$,json:{write:!0}})],fe.prototype,"applicationProperties",void 0),e([v({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],fe.prototype,"authoringApp",null),e([A("authoringApp")],fe.prototype,"writeAuthoringApp",null),e([v({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],fe.prototype,"authoringAppVersion",null),e([A("authoringAppVersion")],fe.prototype,"writeAuthoringAppVersion",null),e([v({json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],fe.prototype,"basemap",void 0),e([v({type:Z,json:{write:{overridePolicy:e=>({enabled:!!(e&&e.length>0),ignoreOrigin:!0})}}})],fe.prototype,"bookmarks",void 0),e([v({type:B,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],fe.prototype,"floorInfo",void 0),e([v({type:q,nonNullable:!0,json:{read:{source:["background","initialState.viewpoint","mapRangeInfo","spatialReference"]},write:{ignoreOrigin:!0,target:{background:{type:Q},"initialState.viewpoint":{type:i},mapRangeInfo:{type:G},spatialReference:{type:L}}}}})],fe.prototype,"initialViewProperties",void 0),e([S("initialViewProperties")],fe.prototype,"readInitialViewProperties",null),e([A("initialViewProperties")],fe.prototype,"writeInitialViewProperties",null),e([v({json:{read:!1,write:{target:"operationalLayers",ignoreOrigin:!0}}})],fe.prototype,"layers",void 0),e([A("layers")],fe.prototype,"writeLayers",null),e([v({type:W})],fe.prototype,"portalItem",void 0),e([v({json:{write:!0}})],fe.prototype,"presentation",void 0),e([v()],fe.prototype,"resourceInfo",void 0),e([v({readOnly:!0,type:H,json:{read:{source:"version"},write:{allowNull:!0,ignoreOrigin:!0,target:"version",isRequired:!0}}})],fe.prototype,"sourceVersion",void 0),e([S("sourceVersion")],fe.prototype,"readSourceVersion",null),e([A("sourceVersion")],fe.prototype,"writeSourceVersion",null),e([v({json:{read:!1,write:{ignoreOrigin:!0}}})],fe.prototype,"tables",void 0),e([A("tables")],fe.prototype,"writeTables",null),e([v()],fe.prototype,"thumbnailUrl",null),e([v({type:J,json:{write:!0}})],fe.prototype,"widgets",void 0),e([v({type:ee,json:{read:!0,write:!0}})],fe.prototype,"utilityNetworks",void 0),fe=e([I("esri.WebMap")],fe);const ge=fe;export{ge as default};
5
+ import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import{flatten as o}from"./core/arrayUtils.js";import a from"./core/Collection.js";import s from"./core/Error.js";import n from"./core/Loadable.js";import{loadAll as l}from"./core/loadAll.js";import p from"./core/Logger.js";import{unwrap as m,isSome as u}from"./core/maybe.js";import{MultiOriginJSONMixin as h,MultiOriginJSONSupport as d}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as c}from"./core/Promise.js";import{eachAlways as y}from"./core/promiseUtils.js";import{whenOnce as w}from"./core/reactiveUtils.js";import{urlToObject as f,isDataProtocol as g,dataComponents as b,addQueryParameter as _}from"./core/urlUtils.js";import{property as v}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import"./core/accessorSupport/ensureType.js";import{reader as S}from"./core/accessorSupport/decorators/reader.js";import{subclass as I}from"./core/accessorSupport/decorators/subclass.js";import{writer as A}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as j}from"./core/accessorSupport/originUtils.js";import{readLoadable as O}from"./core/accessorSupport/read.js";import L from"./geometry/SpatialReference.js";import{equals as P}from"./geometry/support/spatialReferenceUtils.js";import{geographicToWebMercator as V,webMercatorToGeographic as U}from"./geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as F}from"./layers/support/arcgisLayerUrl.js";import T from"./networks/UtilityNetwork.js";import W from"./portal/Portal.js";import R from"./portal/PortalItem.js";import{removeTypeKeyword as x,addTypeKeyword as N,hasTypeKeyword as M}from"./portal/support/portalItemUtils.js";import{project as k}from"./rest/geometryService/project.js";import C from"./rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as E,isDeveloperBasemapLayer as B,findSpatialReference as G}from"./support/basemapUtils.js";import J from"./support/MapFloorInfo.js";import D from"./webdoc/RangeInfo.js";import K from"./webdoc/Widgets.js";import{getOptimalThumbnailSize as $}from"./webdoc/support/thumbnailUtils.js";import{getLayerJSON as z}from"./webdoc/support/writeUtils.js";import q from"./webmap/ApplicationProperties.js";import H from"./webmap/Bookmark.js";import Q from"./webmap/InitialViewProperties.js";import{Version as X}from"./webmap/Version.js";import Y from"./webmap/background/ColorBackground.js";const Z=new X(2,23),ee="Web Map",te=a.ofType(H),re=a.ofType(T),ie=p.getLogger("esri.WebMap"),oe=new Map;oe.set("image/jpeg","jpeg"),oe.set("image/jpg","jpg"),oe.set("image/png","png"),oe.set("image/gif","gif");const ae="ArcGIS Pro",se="ArcGIS API for JavaScript",ne="CollectorDisabled",le="Collector",pe="Data Editing",me="OfflineDisabled",ue="Offline",he="Workforce Project",de="Workforce Worker",ce="Workforce Dispatcher",ye="Offline Map Areas",we="FieldMapsDisabled",fe="DeveloperBasemap",ge=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));let be=class extends(h(n.LoadableMixin(c(r)))){constructor(e){super(e),this.applicationProperties=null,this.bookmarks=new te,this.floorInfo=null,this.initialViewProperties=new Q,this.portalItem=null,this.presentation=null,this.sourceVersion=null,this.widgets=null,this.utilityNetworks=null,this.authoringApp=this.authoringAppVersion=null,this._isAuthoringAppSetByUser=this._isAuthoringAppVersionSetByUser=!1}destroy(){const e=this.portalItem;this.portalItem=null,null==e||e.destroy()}initialize(){if(this.when().catch((e=>{ie.error("#load()","Failed to load web map",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t)}}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp=se}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}readInitialViewProperties(e,t){var r;const o=new Q;t.background&&(o.background=Y.fromJSON(t.background));const a=null==(r=t.initialState)?void 0:r.viewpoint;if(a){if(a.rotation){X.parse(t.version||"","webmap").lessThan(2,20)&&t.authoringApp===ae&&(a.rotation*=-1)}o.viewpoint=i.fromJSON(a)}return t.mapRangeInfo&&(o.rangeInfo=D.fromJSON(t.mapRangeInfo)),t.spatialReference&&(o.spatialReference=L.fromJSON(t.spatialReference)),o}writeInitialViewProperties(e,t,r,i){if(!e)return;const o=e.background;o&&o.color&&(t.background=o.write({},i)),e.viewpoint&&(t.initialState={viewpoint:e.viewpoint.write({},i)}),e.rangeInfo&&(t.mapRangeInfo=e.rangeInfo.toJSON(i)),e.spatialReference&&(t.spatialReference=e.spatialReference.write({},i))}writeLayers(e,t,r,i){t[r]=this._writeLayers(e,i,"operational-layers")}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new X(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${Z.major}.${Z.minor}`}writeTables(e,t,r,i){const o=this._writeLayers(e,i,"tables");o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem&&this.portalItem.thumbnailUrl||null}set thumbnailUrl(e){e?(this._override("thumbnailUrl",e),this._thumbnailFilename=this._generateCustomThumbnailFilename(e)):this._clearThumbnailOverride()}load(e){return this.addResolvingPromise(this._loadFromSource()),Promise.resolve(this)}loadAll(){return l(this,(e=>{e(this.ground,this.basemap,this.layers,this.tables)}))}read(e,t){t={...t,origin:"web-map"};const r=this._getAuthoringPropsState();O(this,e,(t=>super.read(e,t)),t),this._restoreAuthoringPropsFromState(r)}write(e,t){if("loaded"!==this.loadStatus){const e=new s("webmap:not-loaded","Web map must be loaded before it can be serialized");throw ie.error("#toJSON()","Web map must be loaded before it can be serialized",this.loadError||this.loadStatus),e}return this._removeDanglingLayerRefs(),t={...t,origin:"web-map",restrictedWebMapWriting:!0,webmap:this},super.write(e,t)}async save(e){e=e||{},this._validateItem(),await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),await this._validateMap();const t=this.portalItem,r={origin:"web-map",messages:[],writtenProperties:[],url:t.itemUrl&&f(t.itemUrl),portal:t.portal||W.getDefault()},i=this.write({},r);return this._validateJSONForWriting(r,e),await this._updateItemProperties(t),await this._updateItem(t,i,r),await this._updateItemThumbnail(),t}async saveAs(e,t){t=t||{};const r=this._getPortalItem(e);await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),await this._validateMap();const i={origin:"web-map",messages:[],writtenProperties:[],url:null,portal:r.portal},o=this.write({},i);this._validateJSONForWriting(i,t),await this._updateItemPropertiesForSaveAs(r);const a=this._getThumbnailState();return await this._createItem(r,o,i,t),this._restoreThumbnailFromState(a),await this._updateItemThumbnail(),r}async updateFrom(e,t){const r=this._updateFromInternal(e,t);this._updateFromPromise=r,await r;r===this._updateFromPromise&&(this._updateFromPromise=null)}getLayerJSONFromResourceInfo(e){var t,r,i,a;const s=this.resourceInfo;return this._collectAllLayersJSON(o([null==s||null==(t=s.baseMap)?void 0:t.baseMapLayers,null==s?void 0:s.operationalLayers,null==(r=this.basemap)||null==(i=r.resourceInfo)||null==(a=i.data)?void 0:a.baseMapLayers])).find((t=>t.id===e.id))}_collectAllLayersJSON(e){return e.reduce(((e,t)=>(e.push(t),"GroupLayer"===t.layerType&&(e=e.concat(this._collectAllLayersJSON(t.layers||[]))),e)),[])}_writeLayers(e,t,r){t={...t,layerContainerType:r};return e.map((e=>m(z(e,"tables"===r?null:this.getLayerJSONFromResourceInfo(e),t)))).filter(Boolean).toArray()}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-map"}):this.portalItem&&this.portalItem.id?this._loadFromItem(this.portalItem):Promise.resolve(null)}_loadFromItem(e){return e.load().catch((e=>{throw new s("webmap:load-portal-item","Failed to load portal item",{error:e})})).then((()=>{if("Web Map"!==e.type)throw new s("webmap:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Map'",{type:e.type})})).then((()=>e.fetchData())).then((t=>(this.resourceInfo=t,this._readAndLoadFromJSON(t,{origin:"web-map",portal:e.portal||W.getDefault()})))).then((()=>this._computeInitialViewpoint()))}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_validateJSON(e){const t=X.parse(e.version||"","webmap");return Z.validate(t),e.version=`${t.major}.${t.minor}`,e}_loadFromJSON(e,t){const r={context:{...t,layerContainerType:"operational-layers"}};return this.portalItem&&(r.context.portal=this.portalItem.portal||W.getDefault()),import("./layers/support/layersCreator.js").then((({populateOperationalLayers:t})=>{const i=[],o=e.operationalLayers;o&&o.length&&i.push(t(this.layers,o,r));const a={...r,context:{...r.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"},s=e.tables;return s&&s.length&&i.push(t(this.tables,s,a)),y(i).then((()=>{}))}))}async _computeInitialViewpoint(){var e,t;let r=this.initialViewProperties;if(null==(e=r)||null==(t=e.viewpoint)?void 0:t.targetGeometry)return;const o=await this._getExtentFromItem();o&&(r=r?r.clone():new Q,r.viewpoint=new i,r.viewpoint.targetGeometry=o,this.initialViewProperties=r)}async _getExtentFromItem(){var e,t;const r=null==(e=this.initialViewProperties)?void 0:e.spatialReference,i=null==(t=this.portalItem)?void 0:t.extent;if(r&&i){if(r.isWGS84)return i.clone();if(r.isWebMercator)return V(i);return(await import("./portal/support/geometryServiceUtils.js")).getGeometryServiceURL(this.portalItem).then((e=>{const t=new C;return t.geometries=[i],t.outSpatialReference=r,k(e,t)})).then((e=>e[0])).catch((e=>(ie.error("Error projecting item's extent:",e),null)))}return null}_removeDanglingLayerRefs(){const e=this.applicationProperties,t=e&&e.viewing&&e.viewing.search,r=e=>!!this.allLayers.find((t=>t.id===e));t&&t.layers&&(t.layers=t.layers.filter((e=>r(e.id)))),t&&t.tables&&(t.tables=t.tables.filter((e=>!!this.tables.find((t=>t.id===e.id)))));const i=e&&e.editing&&e.editing.locationTracking;i&&i.info&&!r(i.info.layerId)&&(e.editing=null);const o=this.presentation&&this.presentation.slides;o&&o.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>r(e.id))))}))}async _validateMap(){var e;if(null==(e=this.basemap)||!e.baseLayers.length)throw new s("webmap:save","Map does not have a valid basemap with a base layer.");let t=null;if(await w((()=>{const e=G(this.initialViewProperties,this.basemap);return t=e.spatialReference,!e.updating})),!P(t,this.initialViewProperties.spatialReference))throw new s("webmap:save","The spatial reference of the basemap is not compatible with the one from the map.",{expected:this.initialViewProperties.spatialReference,actual:t})}_validateItem(){if(!this.portalItem)throw ie.error("save: requires the portalItem property to be set"),new s("webmap:portal-item-not-set","Portal item to save to has not been set on the WebMap");this._validateItemType(this.portalItem)}_validateItemType(e){if(e.type!==ee)throw new s("webmap:portal-item-wrong-type",`Portal item needs to have type "${ee}"`)}_loadLayerContainers(){const e=[];return this.basemap&&e.push(this.basemap.load()),this.ground&&e.push(this.ground.load()),y(e).then((()=>{}))}async _beforeSave(){const e=[];for(const t of this.allLayers)if("beforeSave"in t&&"function"==typeof t.beforeSave){const r=t.beforeSave();r&&e.push(r)}await y(e)}_loadAllLayers(){const e=this._getAllLayersAndTables().map((e=>e.load()));return y(e).then((()=>{}))}_getAllLayersAndTables(){return this.allLayers.concat(this.allTables)}_validateJSONForWriting(e,t){let r=e.messages.filter((e=>"error"===e.type)).map((e=>new s(e.name,e.message,e.details)));if(t.ignoreUnsupported&&(r=r.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name))),r.length>0)throw new s("webmap:save","Failed to save webmap due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:r})}async _updateItemProperties(e){e.extent=await this._getWGS84Extent(this.initialViewProperties.viewpoint.targetGeometry),await this._updateTypeKeywords(e)}async _updateItemPropertiesForSaveAs(e){x(e,ne),x(e,me),x(e,he),x(e,de),x(e,ce),x(e,ye),x(e,we),await this._updateItemProperties(e)}async _getWGS84Extent(e){const t=e.clone().normalize();let r;if(t.length>1)for(const i of t)r?i.width>r.width&&(r=i):r=i;else r=t[0];return this._projectToWGS84(r)}async _projectToWGS84(e){const t=e.spatialReference;if(t.isWGS84)return e.clone();if(t.isWebMercator)return U(e);const r=await import("./portal/support/geometryServiceUtils.js"),i=await r.getGeometryServiceURL(this.portalItem),o=new C;o.geometries=[e],o.outSpatialReference=L.WGS84;return(await k(i,o))[0]}async _updateTypeKeywords(e){N(e,se),await this._loadAllLayers(),this._evalCollectorKeyword(e),this._evalDataEditingKeyword(e),this._evalOfflineKeyword(e),this._evalDeveloperBasemapKeyword(e),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}_evalCollectorKeyword(e){M(e,ne)||M(e,he)||M(e,de)||M(e,ce)||!this._hasEditableFeatureLayer()?x(e,le):N(e,le)}_evalDataEditingKeyword(e){this._hasEditableFeatureLayer()?N(e,pe):x(e,pe)}_evalOfflineKeyword(e){!M(e,me)&&this._isOfflineCapableMap()?N(e,ue):x(e,ue)}_evalDeveloperBasemapKeyword(e){E(this.basemap)?N(e,fe):x(e,fe)}_hasEditableFeatureLayer(){return this._getAllLayersAndTables().some((e=>e.loaded&&this._isFeatureServiceLayer(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled))}_isFeatureServiceLayer(e){return!("feature"!==e.type||!e.source||"feature-layer"!==e.source.type)}_isOfflineCapableMap(){return this._getAllLayersAndTables().filter((e=>"group"!==e.type)).every((e=>e.loaded&&this._isOfflineCapableLayer(e)))}_isOfflineCapableLayer(e){return this._isFeatureServiceLayer(e)&&e.capabilities.operations.supportsSync||("tile"===e.type||"vector-tile"===e.type)&&(e.capabilities.operations.supportsExportTiles||this._isExportableAGOLTileLayer(e)||B(e))&&e.spatialReference.equals(this.initialViewProperties.spatialReference)}_isExportableAGOLTileLayer(e){return"tile"===e.type&&(F(e.url)&&ge.some((t=>e.url.toLowerCase().indexOf("/"+t+"/")>-1)))}async _updateItem(e,t,r){await e.update({data:t}),this._syncUpInstanceWithItem(e,t,r)}async _createItem(e,t,r,i){const o=this.portalItem,a=!!(o&&o.id&&o.portal.user),n=e.portal;if(await n._signIn(),!await this._canCopyItem(o,a,n))throw new s("webmap:save-as-copy-not-allowed","Owner of this map does not allow others to save a copy");await n.user.addItem({item:e,folder:i.folder,data:t}),this.portalItem=e,this._syncUpInstanceWithItem(e,t,r)}async _canCopyItem(e,t,r){return!(u(e)&&e.id&&e.typeKeywords&&e.typeKeywords.indexOf("useOnly")>-1)||e.portal.portalHostname===r.portalHostname&&(t||await e.reload(),"admin"===e.itemControl||"update"===e.itemControl)}_syncUpInstanceWithItem(e,t,r){d.prototype.read.call(this,{version:t.version,authoringApp:t.authoringApp,authoringAppVersion:t.authoringAppVersion},{origin:"web-map",ignoreDefaults:!0,url:e.itemUrl&&f(e.itemUrl)}),j(r),this.resourceInfo=t}async _updateItemThumbnail(){this.thumbnailUrl&&this._isOverridden("thumbnailUrl")&&(await this.portalItem.updateThumbnail({thumbnail:this.thumbnailUrl,filename:this._thumbnailFilename}),this._clearThumbnailOverride())}_getPortalItem(e){let t=R.from(e);return t.id&&(t=t.clone(),t.id=null),t.type||(t.type=ee),t.portal||(t.portal=W.getDefault()),this._validateItemType(t),t}async _updateFromInternal(e,t){if(t=t||{},await w((()=>e.ready)),this._updateInitialViewProperties(e,t),e.map===this)for(const r of e.allLayerViews)for(const e of["visible","featureEffect"])e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e]);await this._updateThumbnailUrl(e,t)}_updateInitialViewProperties(e,t){var r;t.backgroundExcluded||(this.initialViewProperties.background=null==(r=e.background)?void 0:r.clone());if(this.initialViewProperties.spatialReference=e.spatialReference.clone(),t.viewpointExcluded||(this.initialViewProperties.viewpoint=new i({rotation:e.rotation,scale:t.scalePreserved?e.scale:null,targetGeometry:this._getViewExtent(e)})),!t.widgetsExcluded)for(const i of e.persistableViewModels)i.updateWebDocument(this)}_getViewExtent(e){const t=e.center.clone().normalize(),r=e.extent.clone(),i=r.width/2;return r.xmin=t.x-i,r.xmax=t.x+i,r}async _updateThumbnailUrl(e,t){if(t.thumbnailExcluded)return;const r=$(e,t.thumbnailSize),i=await e.takeScreenshot({format:"png",width:r.width,height:r.height});this._setAutoGeneratedThumbnail(i.dataUrl)}_setAutoGeneratedThumbnail(e){this.thumbnailUrl=e,this._thumbnailFilename=null}_clearThumbnailOverride(){this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"),this._thumbnailFilename=null}_generateCustomThumbnailFilename(e){if(g(e)){const t=b(e),r=t&&t.mediaType,i=r&&oe.get(r.toLowerCase())||null,o=`thumbnail${Date.now()}`;return i?`${o}.${i}`:o}return null}_getThumbnailState(){let e=this.thumbnailUrl;return e&&(e=this._isOverridden("thumbnailUrl")?e:_(e,"w","8192")),{thumbnailUrl:e,filename:this._thumbnailFilename}}_restoreThumbnailFromState(e){this.thumbnailUrl=e.thumbnailUrl,this._thumbnailFilename=e.filename}_getAuthoringPropsState(){return{authoringApp:this.authoringApp,authoringAppVersion:this.authoringAppVersion,isAuthoringAppSetByUser:this._isAuthoringAppSetByUser,isAuthoringAppVersionSetByUser:this._isAuthoringAppVersionSetByUser}}_restoreAuthoringPropsFromState(e){e.isAuthoringAppSetByUser?this.authoringApp=e.authoringApp:this._isAuthoringAppSetByUser=!1,e.isAuthoringAppVersionSetByUser?this.authoringAppVersion=e.authoringAppVersion:this._isAuthoringAppVersionSetByUser=!1}static fromJSON(e){const t=e;if(!t)throw new s("webmap:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:t})}};be.VERSION=Z,e([v({type:q,json:{write:!0}})],be.prototype,"applicationProperties",void 0),e([v({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],be.prototype,"authoringApp",null),e([A("authoringApp")],be.prototype,"writeAuthoringApp",null),e([v({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],be.prototype,"authoringAppVersion",null),e([A("authoringAppVersion")],be.prototype,"writeAuthoringAppVersion",null),e([v({json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],be.prototype,"basemap",void 0),e([v({type:te,json:{write:{overridePolicy:e=>({enabled:!!(e&&e.length>0),ignoreOrigin:!0})}}})],be.prototype,"bookmarks",void 0),e([v({type:J,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],be.prototype,"floorInfo",void 0),e([v({type:Q,nonNullable:!0,json:{read:{source:["background","initialState.viewpoint","mapRangeInfo","spatialReference"]},write:{ignoreOrigin:!0,target:{background:{type:Y},"initialState.viewpoint":{type:i},mapRangeInfo:{type:D},spatialReference:{type:L}}}}})],be.prototype,"initialViewProperties",void 0),e([S("initialViewProperties")],be.prototype,"readInitialViewProperties",null),e([A("initialViewProperties")],be.prototype,"writeInitialViewProperties",null),e([v({json:{read:!1,write:{target:"operationalLayers",ignoreOrigin:!0}}})],be.prototype,"layers",void 0),e([A("layers")],be.prototype,"writeLayers",null),e([v({type:R})],be.prototype,"portalItem",void 0),e([v({json:{write:!0}})],be.prototype,"presentation",void 0),e([v()],be.prototype,"resourceInfo",void 0),e([v({readOnly:!0,type:X,json:{read:{source:"version"},write:{allowNull:!0,ignoreOrigin:!0,target:"version",isRequired:!0}}})],be.prototype,"sourceVersion",void 0),e([S("sourceVersion")],be.prototype,"readSourceVersion",null),e([A("sourceVersion")],be.prototype,"writeSourceVersion",null),e([v({json:{read:!1,write:{ignoreOrigin:!0}}})],be.prototype,"tables",void 0),e([A("tables")],be.prototype,"writeTables",null),e([v()],be.prototype,"thumbnailUrl",null),e([v({type:K,json:{write:!0}})],be.prototype,"widgets",void 0),e([v({type:re,json:{read:!0,write:!0}})],be.prototype,"utilityNetworks",void 0),be=e([I("esri.WebMap")],be);const _e=be;export{_e as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
+ */
5
+ import e from"./AreaMeasurementAnalysis.js";import s from"./DirectLineMeasurementAnalysis.js";import i from"./LineOfSightAnalysis.js";import r from"./SliceAnalysis.js";const t={key:"type",base:null,typeMap:{"area-measurement":e,"direct-line-measurement":s,slice:r,"line-of-sight":i}};export{t as analysisPropertyType};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{id as e}from"../kernel.js";import t from"../request.js";import r from"./featureSetCollection.js";import n from"./featureset/actions/AttributeFilter.js";import a from"./featureset/actions/GroupBy.js";import s from"./featureset/actions/OrderBy.js";import i from"./featureset/actions/SpatialFilter.js";import l from"./featureset/actions/Top.js";import o from"./featureset/sources/FeatureLayerDynamic.js";import u from"./featureset/sources/FeatureLayerMemory.js";import c from"./featureset/sources/FeatureLayerRelated.js";import d from"./featureset/support/cache.js";import m from"./featureset/support/FeatureSet.js";import{extractServiceUrl as f}from"./featureset/support/shared.js";import{resolve as h,reject as p,create as y}from"../core/promiseUtils.js";import{WhereClause as L}from"../core/sql/WhereClause.js";import _ from"../layers/FeatureLayer.js";import I from"../portal/Portal.js";import S from"../portal/PortalItem.js";function N(){null===d.applicationCache&&(d.applicationCache=new d)}function F(e,t){if(d.applicationCache){const r=d.applicationCache.getLayerInfo(e);if(r)return r.then((r=>h(new _({url:e,outFields:t,sourceJSON:r}))));const n=new _({url:e,outFields:t});let a=y(((e,t)=>{n.load().then((()=>{e(n.sourceJSON)}),(e=>{t(e)}))}));return d.applicationCache&&(d.applicationCache.setLayerInfo(e,a),a=a.catch((t=>{throw d.applicationCache.clearLayerInfo(e),t}))),a.then((()=>h(n)))}return h(new _({url:e,outFields:t}))}function T(e,t,r,n,a,s=null){return F(e,["*"]).then((e=>h(g(e,t,r,n,a,s))))}function g(e,t=null,r=null,n=!0,a=null,s=null){return!0===e._hasMemorySource()?new u({layer:e,spatialReference:t,outFields:r,includeGeometry:n,lrucache:a,interceptor:s}):new o({layer:e,spatialReference:t,outFields:r,includeGeometry:n,lrucache:a,interceptor:s})}function A(e){if(null!==d.applicationCache){const t=d.applicationCache.getLayerInfo(e);if(null!==t)return t}let r=t(e,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return h(t)}return h(null)}));return null!==d.applicationCache&&(d.applicationCache.setLayerInfo(e,r),r=r.catch((t=>{throw d.applicationCache.clearLayerInfo(e),t}))),r}function C(e,r){const n="QUERYDATAELEMTS:"+r.toString()+":"+e;if(null!==d.applicationCache){const e=d.applicationCache.getLayerInfo(n);if(null!==e)return e}let a=t(e+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([r.toString()]),f:"json"}}).then((e=>{if(e.data){const t=e.data;if(t.layerDataElements&&t.layerDataElements[0])return t.layerDataElements[0]}throw new Error("Not Found")}));return null!==d.applicationCache&&(d.applicationCache.setLayerInfo(n,a),a=a.catch((e=>{throw d.applicationCache.clearLayerInfo(n),e}))),a}function k(e){if(null!==d.applicationCache){const t=d.applicationCache.getLayerInfo(e);if(null!==t)return t}let r=t(e,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return t.layers||(t.layers=[]),t.tables||(t.tables=[]),h(t)}return h({layers:[],tables:[]})}));return null!==d.applicationCache&&(d.applicationCache.setLayerInfo(e,r),r=r.catch((t=>{throw d.applicationCache.clearLayerInfo(e),t}))),r}function j(e,t){const r={metadata:null,networkId:-1,unVersion:3,terminals:[],queryelem:null,layerNameLkp:{},lkp:null};return k(e).then((n=>{if(r.metadata=n,n.controllerDatasetLayers&&void 0!==n.controllerDatasetLayers.utilityNetworkLayerId&&null!==n.controllerDatasetLayers.utilityNetworkLayerId){if(n.layers)for(const e of n.layers)r.layerNameLkp[e.id]=e.name;if(n.tables)for(const e of n.tables)r.layerNameLkp[e.id]=e.name;const a=n.controllerDatasetLayers.utilityNetworkLayerId;return r.networkId=a,C(e,a).then((n=>{if(n){r.queryelem=n,r.queryelem&&r.queryelem.dataElement&&void 0!==r.queryelem.dataElement.schemaGeneration&&(r.unVersion=r.queryelem.dataElement.schemaGeneration),r.lkp={},r.queryelem.dataElement.domainNetworks||(r.queryelem.dataElement.domainNetworks=[]);for(const e of r.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources?e.edgeSources:[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]?r.layerNameLkp[t.layerId]:null};e.className&&(r.lkp[e.className]=e)}for(const t of e.junctionSources?e.junctionSources:[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]?r.layerNameLkp[t.layerId]:null};e.className&&(r.lkp[e.className]=e)}}if(r.queryelem.dataElement.terminalConfigurations)for(const e of r.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)r.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});return A(e+"/"+a).then((n=>{if(n.systemLayers&&void 0!==n.systemLayers.associationsTableId&&null!==n.systemLayers.associationsTableId){const a=[];return r.unVersion>=4&&(a.push("STATUS"),a.push("PERCENTALONG")),T(e+"/"+n.systemLayers.associationsTableId.toString(),t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...a],!1,null,null).then((e=>e.load())).then((e=>r.unVersion>=4?(e=e.filter(L.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62,63)",e.getFieldsIndex()))).load():e)).then((e=>({lkp:r.lkp,associations:e,unVersion:r.unVersion,terminals:r.terminals})))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}function w(e,t,r,n=null,a=null,s=!0,i=null,l=null){let o=e.serviceUrl();return o?(o="/"===o.charAt(o.length-1)?o+t.relatedTableId.toString():o+"/"+t.relatedTableId.toString(),T(o,n,a,s,i,l).then((o=>new c({layer:e,relatedLayer:o,relationship:t,objectId:r,spatialReference:n,outFields:a,includeGeometry:s,lrucache:i,interceptor:l})))):null}n.registerAction(),a.registerAction(),s.registerAction(),i.registerAction(),l.registerAction();class O extends r{constructor(e,t=null,r=null,n=null){super(),this._map=e,this._overridespref=t,this.lrucache=r,this.interceptor=n,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,r=null){const n=g(e,this._overridespref,null===r?["*"]:r,t,this.lrucache,this.interceptor);return this._instantLayers.push({featureset:n,opitem:e,includeGeometry:t,outFields:JSON.stringify(r)}),n}featureSetByName(e,t=!0,r=null){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return this._map.load().then((()=>{try{return this.featureSetByName(e,t,r)}catch(n){return p(n)}}));null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let s=0;s<this._instantLayers.length;s++){const r=this._instantLayers[s];if(r.opitem.title===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[s].featureset)}const a=this._map.layers.find((t=>t instanceof _&&t.title===e));if(a)return this.resolvePromise(this._makeAndAddFeatureSet(a,t,r));if(this._map.tables){const n=this._map.tables.find((t=>!!(t.title&&t.title===e||t.title&&t.title===e)));if(n){if(n instanceof _)return this.resolvePromise(this._makeAndAddFeatureSet(n,t,r));if(n._materializedTable);else{const e=n.outFields?n:{...n,outFields:["*"]};n._materializedTable=new _(e)}return n._materializedTable.load().then((()=>this.resolvePromise(this._makeAndAddFeatureSet(n._materializedTable,t,r))))}}return this.resolvePromise(null)}featureSetById(e,t=!0,r=["*"]){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return this._map.load().then((()=>{try{return this.featureSetById(e,t,r)}catch(n){return p(n)}}));null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let s=0;s<this._instantLayers.length;s++){const r=this._instantLayers[s];if(r.opitem.id===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[s].featureset)}const a=this._map.layers.find((t=>t instanceof _&&t.id===e));if(a)return this.resolvePromise(this._makeAndAddFeatureSet(a,t,r));if(this._map.tables){const n=this._map.tables.find((t=>t.id===e));if(n){if(n instanceof _)return this.resolvePromise(this._makeAndAddFeatureSet(n,t,r));if(n._materializedTable);else{const e={...n,outFields:["*"]};n._materializedTable=new _(e)}return n._materializedTable.load().then((()=>this.resolvePromise(this._makeAndAddFeatureSet(n._materializedTable,t,r))))}}return this.resolvePromise(null)}}class v extends r{constructor(e,t=null,r=null,n=null){super(),this._url=e,this._overridespref=t,this.lrucache=r,this.interceptor=n,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,r=null){const n=g(e,this._overridespref,null===r?["*"]:r,t,this.lrucache);return this._instantLayers.push({featureset:n,opitem:e,includeGeometry:t,outFields:JSON.stringify(r)}),n}_loadMetaData(){return k(this._url).then((e=>(this.metadata=e,e)))}load(){return this._loadMetaData()}clone(){return new v(this._url,this._overridespref,this.lrucache,this.interceptor)}featureSetByName(e,t=!0,r=null){null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.title===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[a].featureset)}return this._loadMetaData().then((n=>{let a=null;for(const t of n.layers?n.layers:[])t.name===e&&(a=t);if(!a)for(const t of n.tables?n.tables:[])t.name===e&&(a=t);return a?F(this._url+"/"+a.id,["*"]).then((e=>this._makeAndAddFeatureSet(e,t,r))):this.resolvePromise(null)}))}featureSetById(e,t=!0,r=["*"]){null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);e=null!=e?e.toString():"";for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.id===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[a].featureset)}return this._loadMetaData().then((n=>{let a=null;for(const t of n.layers?n.layers:[])null!==t.id&&void 0!==t.id&&t.id.toString()===e&&(a=t);if(!a)for(const t of n.tables?n.tables:[])null!==t.id&&void 0!==t.id&&t.id.toString()===e&&(a=t);return a?F(this._url+"/"+a.id,["*"]).then((e=>this._makeAndAddFeatureSet(e,t,r))):this.resolvePromise(null)}))}}function E(e,t,r=null,n=null){return new O(e,t,r,n)}function b(e,t,r=null,n=null){return new v(e,t,r,n)}function D(e,t){if(null===e)return t;return new I({url:e.field("url")})}function q(r,n,a){return e.findCredential(r.restUrl)?"loaded"===r.loadStatus&&""===n&&r.user&&r.user.sourceJSON&&!1===a?h(r.user.sourceJSON):""===n?t(r.restUrl+"/community/self",{responseType:"json",query:{f:"json",...!1===a?{}:{returnUserLicenseTypeExtensions:!0}}}).then((e=>{if(e.data){const t=e.data;if(t&&t.username)return h(t)}return h(null)})):t(r.restUrl+"/community/users/"+n,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return t.error?null:h(t)}return h(null)})):h(null)}function P(e,t,r,n,a){if(null===e)return null;if(e instanceof _){switch(t){case"datasource":return g(e,a,e.outFields,!0,r,n).getDataSourceFeatureSet();case"parent":case"root":return g(e,a,e.outFields,!0,r,n)}return null}if(e instanceof m)switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}function G(e,t,r,n,a,s,i,l=null){if(d.applicationCache){const o=d.applicationCache.getLayerInfo(e+":"+s.url);if(o)return o.then((e=>{try{const s=new _({url:f(e.url)+"/"+t,outFields:["*"]});return h(g(s,r,n,a,i,l))}catch(s){return p(s)}}),(e=>p(e)))}return y(((o,u)=>{const c=new S({id:e,portal:s}).load();d.applicationCache&&d.applicationCache.setLayerInfo(e+":"+s.url,c),c.then((e=>{try{const s=new _({url:f(e.url)+"/"+t,outFields:["*"]});o(g(s,r,n,a,i,l))}catch(s){u(s)}}),(t=>{d.applicationCache&&d.applicationCache.clearLayerInfo(e+":"+s.url),u(t)}))}))}export{j as constructAssociationMetaDataFeatureSetFromUrl,g as constructFeatureSet,G as constructFeatureSetFromPortalItem,w as constructFeatureSetFromRelationship,T as constructFeatureSetFromUrl,P as convertToFeatureSet,E as createFeatureSetCollectionFromMap,b as createFeatureSetCollectionFromService,D as getPortal,N as initialiseMetaDataCache,q as lookupUser};
5
+ import{id as e}from"../kernel.js";import t from"../request.js";import r from"./featureSetCollection.js";import n from"./featureset/actions/AttributeFilter.js";import a from"./featureset/actions/GroupBy.js";import s from"./featureset/actions/OrderBy.js";import i from"./featureset/actions/SpatialFilter.js";import l from"./featureset/actions/Top.js";import o from"./featureset/sources/FeatureLayerDynamic.js";import u from"./featureset/sources/FeatureLayerMemory.js";import c from"./featureset/sources/FeatureLayerRelated.js";import d from"./featureset/support/cache.js";import m from"./featureset/support/FeatureSet.js";import{extractServiceUrl as f}from"./featureset/support/shared.js";import{resolve as h,reject as p,create as y}from"../core/promiseUtils.js";import{WhereClause as L}from"../core/sql/WhereClause.js";import _ from"../layers/FeatureLayer.js";import I from"../portal/Portal.js";import S from"../portal/PortalItem.js";function N(){null===d.applicationCache&&(d.applicationCache=new d)}function F(e,t){if(d.applicationCache){const r=d.applicationCache.getLayerInfo(e);if(r)return r.then((r=>h(new _({url:e,outFields:t,sourceJSON:r}))));const n=new _({url:e,outFields:t});let a=y(((e,t)=>{n.load().then((()=>{e(n.sourceJSON)}),(e=>{t(e)}))}));return d.applicationCache&&(d.applicationCache.setLayerInfo(e,a),a=a.catch((t=>{throw d.applicationCache.clearLayerInfo(e),t}))),a.then((()=>h(n)))}return h(new _({url:e,outFields:t}))}function T(e,t,r,n,a,s=null){return F(e,["*"]).then((e=>h(g(e,t,r,n,a,s))))}function g(e,t=null,r=null,n=!0,a=null,s=null){return!0===e._hasMemorySource()?new u({layer:e,spatialReference:t,outFields:r,includeGeometry:n,lrucache:a,interceptor:s}):new o({layer:e,spatialReference:t,outFields:r,includeGeometry:n,lrucache:a,interceptor:s})}function A(e){if(null!==d.applicationCache){const t=d.applicationCache.getLayerInfo(e);if(null!==t)return t}let r=t(e,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return h(t)}return h(null)}));return null!==d.applicationCache&&(d.applicationCache.setLayerInfo(e,r),r=r.catch((t=>{throw d.applicationCache.clearLayerInfo(e),t}))),r}function C(e,r){const n="QUERYDATAELEMTS:"+r.toString()+":"+e;if(null!==d.applicationCache){const e=d.applicationCache.getLayerInfo(n);if(null!==e)return e}let a=t(e+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([r.toString()]),f:"json"}}).then((e=>{if(e.data){const t=e.data;if(t.layerDataElements&&t.layerDataElements[0])return t.layerDataElements[0]}throw new Error("Not Found")}));return null!==d.applicationCache&&(d.applicationCache.setLayerInfo(n,a),a=a.catch((e=>{throw d.applicationCache.clearLayerInfo(n),e}))),a}function k(e){if(null!==d.applicationCache){const t=d.applicationCache.getLayerInfo(e);if(null!==t)return t}let r=t(e,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return t.layers||(t.layers=[]),t.tables||(t.tables=[]),h(t)}return h({layers:[],tables:[]})}));return null!==d.applicationCache&&(d.applicationCache.setLayerInfo(e,r),r=r.catch((t=>{throw d.applicationCache.clearLayerInfo(e),t}))),r}function j(e,t){const r={metadata:null,networkId:-1,unVersion:3,terminals:[],queryelem:null,layerNameLkp:{},lkp:null};return k(e).then((n=>{if(r.metadata=n,n.controllerDatasetLayers&&void 0!==n.controllerDatasetLayers.utilityNetworkLayerId&&null!==n.controllerDatasetLayers.utilityNetworkLayerId){if(n.layers)for(const e of n.layers)r.layerNameLkp[e.id]=e.name;if(n.tables)for(const e of n.tables)r.layerNameLkp[e.id]=e.name;const a=n.controllerDatasetLayers.utilityNetworkLayerId;return r.networkId=a,C(e,a).then((n=>{if(n){r.queryelem=n,r.queryelem&&r.queryelem.dataElement&&void 0!==r.queryelem.dataElement.schemaGeneration&&(r.unVersion=r.queryelem.dataElement.schemaGeneration),r.lkp={},r.queryelem.dataElement.domainNetworks||(r.queryelem.dataElement.domainNetworks=[]);for(const e of r.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources?e.edgeSources:[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]?r.layerNameLkp[t.layerId]:null};e.className&&(r.lkp[e.className]=e)}for(const t of e.junctionSources?e.junctionSources:[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]?r.layerNameLkp[t.layerId]:null};e.className&&(r.lkp[e.className]=e)}}if(r.queryelem.dataElement.terminalConfigurations)for(const e of r.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)r.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});return A(e+"/"+a).then((n=>{if(n.systemLayers&&void 0!==n.systemLayers.associationsTableId&&null!==n.systemLayers.associationsTableId){const a=[];return r.unVersion>=4&&(a.push("STATUS"),a.push("PERCENTALONG")),T(e+"/"+n.systemLayers.associationsTableId.toString(),t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...a],!1,null,null).then((e=>e.load())).then((e=>r.unVersion>=4?(e=e.filter(L.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62,63)",e.getFieldsIndex()))).load():e)).then((e=>({lkp:r.lkp,associations:e,unVersion:r.unVersion,terminals:r.terminals})))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}function w(e,t,r,n=null,a=null,s=!0,i=null,l=null){let o=e.serviceUrl();return o?(o="/"===o.charAt(o.length-1)?o+t.relatedTableId.toString():o+"/"+t.relatedTableId.toString(),T(o,n,a,s,i,l).then((o=>new c({layer:e,relatedLayer:o,relationship:t,objectId:r,spatialReference:n,outFields:a,includeGeometry:s,lrucache:i,interceptor:l})))):null}n.registerAction(),a.registerAction(),s.registerAction(),i.registerAction(),l.registerAction();class O extends r{constructor(e,t=null,r=null,n=null){super(),this._map=e,this._overridespref=t,this.lrucache=r,this.interceptor=n,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,r=null){const n=g(e,this._overridespref,null===r?["*"]:r,t,this.lrucache,this.interceptor);return this._instantLayers.push({featureset:n,opitem:e,includeGeometry:t,outFields:JSON.stringify(r)}),n}featureSetByName(e,t=!0,r=null){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return this._map.load().then((()=>{try{return this.featureSetByName(e,t,r)}catch(n){return p(n)}}));null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let s=0;s<this._instantLayers.length;s++){const r=this._instantLayers[s];if(r.opitem.title===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[s].featureset)}const a=this._map.allLayers.find((t=>t instanceof _&&t.title===e));if(a)return this.resolvePromise(this._makeAndAddFeatureSet(a,t,r));if(this._map.tables){const n=this._map.tables.find((t=>!!(t.title&&t.title===e||t.title&&t.title===e)));if(n){if(n instanceof _)return this.resolvePromise(this._makeAndAddFeatureSet(n,t,r));if(n._materializedTable);else{const e=n.outFields?n:{...n,outFields:["*"]};n._materializedTable=new _(e)}return n._materializedTable.load().then((()=>this.resolvePromise(this._makeAndAddFeatureSet(n._materializedTable,t,r))))}}return this.resolvePromise(null)}featureSetById(e,t=!0,r=["*"]){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return this._map.load().then((()=>{try{return this.featureSetById(e,t,r)}catch(n){return p(n)}}));null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let s=0;s<this._instantLayers.length;s++){const r=this._instantLayers[s];if(r.opitem.id===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[s].featureset)}const a=this._map.allLayers.find((t=>t instanceof _&&t.id===e));if(a)return this.resolvePromise(this._makeAndAddFeatureSet(a,t,r));if(this._map.tables){const n=this._map.tables.find((t=>t.id===e));if(n){if(n instanceof _)return this.resolvePromise(this._makeAndAddFeatureSet(n,t,r));if(n._materializedTable);else{const e={...n,outFields:["*"]};n._materializedTable=new _(e)}return n._materializedTable.load().then((()=>this.resolvePromise(this._makeAndAddFeatureSet(n._materializedTable,t,r))))}}return this.resolvePromise(null)}}class v extends r{constructor(e,t=null,r=null,n=null){super(),this._url=e,this._overridespref=t,this.lrucache=r,this.interceptor=n,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,r=null){const n=g(e,this._overridespref,null===r?["*"]:r,t,this.lrucache);return this._instantLayers.push({featureset:n,opitem:e,includeGeometry:t,outFields:JSON.stringify(r)}),n}_loadMetaData(){return k(this._url).then((e=>(this.metadata=e,e)))}load(){return this._loadMetaData()}clone(){return new v(this._url,this._overridespref,this.lrucache,this.interceptor)}featureSetByName(e,t=!0,r=null){null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.title===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[a].featureset)}return this._loadMetaData().then((n=>{let a=null;for(const t of n.layers?n.layers:[])t.name===e&&(a=t);if(!a)for(const t of n.tables?n.tables:[])t.name===e&&(a=t);return a?F(this._url+"/"+a.id,["*"]).then((e=>this._makeAndAddFeatureSet(e,t,r))):this.resolvePromise(null)}))}featureSetById(e,t=!0,r=["*"]){null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);e=null!=e?e.toString():"";for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.id===e&&r.includeGeometry===t&&r.outFields===n)return this.resolvePromise(this._instantLayers[a].featureset)}return this._loadMetaData().then((n=>{let a=null;for(const t of n.layers?n.layers:[])null!==t.id&&void 0!==t.id&&t.id.toString()===e&&(a=t);if(!a)for(const t of n.tables?n.tables:[])null!==t.id&&void 0!==t.id&&t.id.toString()===e&&(a=t);return a?F(this._url+"/"+a.id,["*"]).then((e=>this._makeAndAddFeatureSet(e,t,r))):this.resolvePromise(null)}))}}function E(e,t,r=null,n=null){return new O(e,t,r,n)}function b(e,t,r=null,n=null){return new v(e,t,r,n)}function D(e,t){if(null===e)return t;return new I({url:e.field("url")})}function q(r,n,a){return e.findCredential(r.restUrl)?"loaded"===r.loadStatus&&""===n&&r.user&&r.user.sourceJSON&&!1===a?h(r.user.sourceJSON):""===n?t(r.restUrl+"/community/self",{responseType:"json",query:{f:"json",...!1===a?{}:{returnUserLicenseTypeExtensions:!0}}}).then((e=>{if(e.data){const t=e.data;if(t&&t.username)return h(t)}return h(null)})):t(r.restUrl+"/community/users/"+n,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return t.error?null:h(t)}return h(null)})):h(null)}function P(e,t,r,n,a){if(null===e)return null;if(e instanceof _){switch(t){case"datasource":return g(e,a,e.outFields,!0,r,n).getDataSourceFeatureSet();case"parent":case"root":return g(e,a,e.outFields,!0,r,n)}return null}if(e instanceof m)switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}function G(e,t,r,n,a,s,i,l=null){if(d.applicationCache){const o=d.applicationCache.getLayerInfo(e+":"+s.url);if(o)return o.then((e=>{try{const s=new _({url:f(e.url)+"/"+t,outFields:["*"]});return h(g(s,r,n,a,i,l))}catch(s){return p(s)}}),(e=>p(e)))}return y(((o,u)=>{const c=new S({id:e,portal:s}).load();d.applicationCache&&d.applicationCache.setLayerInfo(e+":"+s.url,c),c.then((e=>{try{const s=new _({url:f(e.url)+"/"+t,outFields:["*"]});o(g(s,r,n,a,i,l))}catch(s){u(s)}}),(t=>{d.applicationCache&&d.applicationCache.clearLayerInfo(e+":"+s.url),u(t)}))}))}export{j as constructAssociationMetaDataFeatureSetFromUrl,g as constructFeatureSet,G as constructFeatureSetFromPortalItem,w as constructFeatureSetFromRelationship,T as constructFeatureSetFromUrl,P as convertToFeatureSet,E as createFeatureSetCollectionFromMap,b as createFeatureSetCollectionFromService,D as getPortal,N as initialiseMetaDataCache,q as lookupUser};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Graphic.js";import t from"../../../request.js";import r from"../../Attachment.js";import i from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{defaultMaxRecords as a,stableStringify as n,FeatureServiceDatabaseType as l,IdState as o,extractServiceUrl as u}from"../support/shared.js";import{toWhereClause as d,isSingleField as h}from"../support/sqlUtils.js";import{decodeStatType as p}from"../support/stats.js";import{createMD5Hash as c,outputTypes as y}from"../../../core/MD5.js";import{id as f}from"../../../kernel.js";import{create as _,resolve as m,reject as g}from"../../../core/promiseUtils.js";import{fromJSON as F}from"../../../geometry/support/jsonUtils.js";import S from"../../../layers/FeatureLayer.js";import{convertToFeatureSet as b}from"../../../layers/graphics/featureConversionUtils.js";import"../../../core/urlUtils.js";import"../../../core/unitUtils.js";import"../../../rest/query/support/AttachmentInfo.js";import"../../../rest/support/AttachmentQuery.js";import{executeForCount as R}from"../../../rest/query/executeForCount.js";import"../../../geometry.js";import{executeQueryPBF as D}from"../../../rest/query/operations/query.js";import x from"../../../rest/support/Query.js";import{executeForIds as w}from"../../../rest/query/executeForIds.js";import{executeQueryJSON as I}from"../../../rest/query/executeQueryJSON.js";import"../../../core/has.js";import"../../../geometry/support/spatialReferenceUtils.js";import q from"../../../rest/support/FeatureSet.js";import"../../../rest/support/RelationshipQuery.js";import"../../../geometry/support/normalizeUtils.js";import"../../../rest/support/TopFeaturesQuery.js";import{OptimizedFeatureSetParserContext as P}from"../../../rest/query/operations/pbfOptimizedFeatureSet.js";import v from"../../../rest/support/StatisticDefinition.js";import C from"../../Dictionary.js";class j extends i{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}convertQueryToLruCacheKey(e){const t=n(e.toJSON());return c(t,y.String)}load(){return null===this._loadPromise&&(this._loadPromise=_(((e,t)=>{try{if(!0===this._layer.loaded)return this._initialiseFeatureSet(),void e(this);this._layer.when().then((()=>{try{this._initialiseFeatureSet(),e(this)}catch(r){t(r)}}),t),this._layer.load()}catch(r){t(r)}}))),this._loadPromise}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const r of this._layer.outFields)if(r.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}else;if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=l.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=l.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=l.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=l.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}_isInFeatureSet(){return o.InFeatureSet}_refineSetBlock(e){return m(e)}_candidateIdTransform(e){return e}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,null,e))).then((e=>(this._wset=e,e))):m(this._wset)}_runDatabaseProbe(e){return _(((t,r)=>{try{this._ensureLoaded().then((()=>{try{const i=new x;i.where=e.replace("OBJECTID",this._layer.objectIdField),this._layer.queryObjectIds(i).then((()=>{t(!0)}),(()=>{try{t(!1)}catch(e){r(e)}}))}catch(i){r(i)}}))}catch(i){r(i)}}))}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){return!e.outStatistics&&this._layer&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsFormatPBF&&!0===this._layer.capabilities.query.supportsQuantizationEditMode}queryPBF(e){return e.quantizationParameters={mode:"edit"},D(this._layer.parsedUrl,e,new P({})).then((e=>q.fromJSON(b(e.data)).unquantize()))}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion?this._layer.gdbVersion:"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title,source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}executeQuery(e,t){const r="execute"===t?I:"executeForCount"===t?R:w,i="execute"===t&&this.pbfSupportedForQuery(e);let s=null;if(this.recentlyUsedQueries){const a=this.convertQueryToLruCacheKey(e);s=this.recentlyUsedQueries.getFromCache(a),null===s&&(s=!0!==i?r[t](e):this.queryPBF(e),this.recentlyUsedQueries.addToCache(a,s),s=s.catch((e=>{throw this.recentlyUsedQueries.removeFromCache(a),e})))}return this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e)),s}_getFilteredSet(e,t,r,i,a){return this.databaseType().then((n=>{if(this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,r,i,a);let l="",o=!1;null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(l=i.constructClause(),o=!0);const u=new x;return u.where=null===r?null===t?"1=1":"":d(r,n),this._requestStandardised&&(u.sqlFormat="standard"),u.spatialRelationship=this._makeRelationshipEnum(e),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==l?l.split(","):null,u.geometry=null===t?null:t,u.relationParameter=this._makeRelationshipParam(e),this.executeQuery(u,"executeForIds").then((e=>{null===e&&(e=[]),this._checkCancelled(a);return new s([],e,o,null)}))}))}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_getFilteredSetUsingPaging(e,t,r,i,a){try{let n="",l=!1;return null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=i.constructClause(),l=!0),this.databaseType().then((i=>{let o=null===r?null===t?"1=1":"":d(r,i);this._layer.definitionExpression&&this._useDefinitionExpression&&(o=""!==o?"(("+this._layer.definitionExpression+") AND ("+o+"))":this._layer.definitionExpression);let u=this._maxQueryRate();const h=this._layer.capabilities.query.maxRecordCount;void 0!==h&&h<u&&(u=h);let p=null;if(!0===this._pageJustIds)p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let r=!0;!0===this._removeGeometry&&(r=!1);const i=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]);p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:i.join(","),resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:r,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return this._expandPagedSet(p,u,0,1,a).then((()=>p))}))}catch(n){return g(n)}}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}_getPhysicalPage(e,t,r){try{const t=e.pagesDefinition.internal.lastRetrieved,i=t,s=e.pagesDefinition.internal.lastPage,a=new x;return this._requestStandardised&&(a.sqlFormat="standard"),a.spatialRelationship=e.pagesDefinition.spatialRel,a.relationParameter=e.pagesDefinition.relationParam,a.outFields=e.pagesDefinition.outFields.split(","),a.num=e.pagesDefinition.resultRecordCount,a.start=e.pagesDefinition.internal.lastPage,a.geometry=e.pagesDefinition.geometry,a.where=e.pagesDefinition.where,a.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,a.returnGeometry=e.pagesDefinition.returnGeometry,a.outSpatialReference=this.spatialReference,this.executeQuery(a,"execute").then((a=>{if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==s)return"done";for(let t=0;t<a.features.length;t++)e.pagesDefinition.internal.set[i+t]=a.features[t].attributes[this._layer.objectIdField];if(!1===this._pageJustIds)for(let e=0;e<a.features.length;e++)this._featureCache[a.features[e].attributes[this._layer.objectIdField]]=a.features[e];return(void 0===a.exceededTransferLimit&&a.features.length!==e.pagesDefinition.resultRecordCount||!1===a.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=t+a.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}))}catch(i){return g(i)}}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.indexOf("*")>-1)return t;let r=!1;for(const i of t)if(i.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return!1===r&&t.push(this.objectIdField),t}_getFeatures(e,t,r,i){const s=[];try{if(-1!==t&&void 0===this._featureCache[t]&&s.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return this._expandPagedSet(e,this._maxProcessingRate(),0,0,i).then((()=>this._getFeatures(e,t,r,i)));let n=0;for(let i=e._lastFetchedIndex;i<e._known.length;i++){if(e._lastFetchedIndex+=1,n++,void 0===this._featureCache[e._known[i]]){let r=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[i]]){const s=t._featureMap[e._known[i]];null!==s&&(r=!0,this._featureCache[e._known[i]]=s)}}if(!1===r&&(e._known[i]!==t&&s.push(e._known[i]),s.length>=this._maxProcessingRate()-1))break}if(n>=r&&0===s.length)break}if(0===s.length)return m("success");try{const e=new x;return this._requestStandardised&&(e.sqlFormat="standard"),e.objectIds=s,e.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]),e.returnGeometry=!0,!0===this._removeGeometry&&(e.returnGeometry=!1),e.outSpatialReference=this.spatialReference,this.executeQuery(e,"execute").then((e=>{if(this._checkCancelled(i),void 0!==e.error)return g(new Error(e.error));for(let t=0;t<e.features.length;t++)this._featureCache[e.features[t].attributes[this._layer.objectIdField]]=e.features[t];return"success"}))}catch(a){return g(a)}}catch(a){return g(a)}}_getDistinctPages(e,t,r,i,s,a,n,l,o){return this._ensureLoaded().then((()=>this.databaseType())).then((u=>{let h=r.parseTree.column;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name.toLowerCase()===h.toLowerCase()){h=this._layer.fields[e].name;break}const p=new x;this._requestStandardised&&(p.sqlFormat="standard");let c=null===a?null===s?"1=1":"":d(a,u);return this._layer.definitionExpression&&this._useDefinitionExpression&&(c=""!==c?"(("+this._layer.definitionExpression+") AND ("+c+"))":this._layer.definitionExpression),p.where=c,p.spatialRelationship=this._makeRelationshipEnum(i),p.relationParameter=this._makeRelationshipParam(i),p.geometry=null===s?null:s,p.returnDistinctValues=!0,p.returnGeometry=!1,p.outFields=[h],this.executeQuery(p,"execute").then((u=>{if(this._checkCancelled(o),!u.hasOwnProperty("features"))return g(new Error("Unnexected Result querying statistics from layer"));let d=!1;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name===h){"date"===this._layer.fields[e].type&&(d=!0);break}for(let e=0;e<u.features.length;e++){if(d){const t=u.features[e].attributes[h];null!==t?l.push(new Date(t)):l.push(t)}else l.push(u.features[e].attributes[h]);if(l.length>=n)break}return 0===u.features.length?l:u.features.length===this._layer.capabilities.query.maxRecordCount&&l.length<n?this._getDistinctPages(e+u.features.length,t,r,i,s,a,n,l,o).then((e=>({calculated:!0,result:e}))):l}))}))}_distinctStat(e,t,r,i,s,a,n){return this._getDistinctPages(0,e,t,r,i,s,a,[],n).then((e=>({calculated:!0,result:e})))}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType}_countstat(e,t,r,i){return this.databaseType().then((e=>{const s=new x;if(this._requestStandardised&&(s.sqlFormat="standard"),this.isTable()&&r&&null!==t&&""!==t)return{calculated:!0,result:0};let a=null===i?null===r?"1=1":"":d(i,e);return this._layer.definitionExpression&&this._useDefinitionExpression&&(a=""!==a?"(("+this._layer.definitionExpression+") AND ("+a+"))":this._layer.definitionExpression),s.where=a,s.where=a,s.spatialRelationship=this._makeRelationshipEnum(t),s.relationParameter=this._makeRelationshipParam(t),s.geometry=null===r?null:r,s.returnGeometry=!1,this.executeQuery(s,"executeForCount").then((e=>({calculated:!0,result:e})))}))}_stats(e,t,r,i,s,a,n){return this._ensureLoaded().then((()=>{const l=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,o=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;return"count"===e?u?this._countstat(e,r,i,s):{calculated:!1}:!1===o||!1===h(t)&&!1===l||!1===t.isStandardized?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):"distinct"===e?!1===u?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):this._distinctStat(e,t,r,i,s,a,n):this.databaseType().then((a=>{if(this.isTable()&&i&&null!==r&&""!==r)return{calculated:!0,result:null};const n=new x;this._requestStandardised&&(n.sqlFormat="standard");let l=null===s?null===i?"1=1":"":d(s,a);this._layer.definitionExpression&&this._useDefinitionExpression&&(l=""!==l?"(("+this._layer.definitionExpression+") AND ("+l+"))":this._layer.definitionExpression),n.where=l,n.spatialRelationship=this._makeRelationshipEnum(r),n.relationParameter=this._makeRelationshipParam(r),n.geometry=null===i?null:i;const o=new v;o.statisticType=p(e),o.onStatisticField=d(t,a),o.outStatisticFieldName="ARCADE_STAT_RESULT",n.returnGeometry=!1;let u="ARCADE_STAT_RESULT";return n.outStatistics=[o],this.executeQuery(n,"execute").then((e=>{if(!e.hasOwnProperty("features")||0===e.features.length)return g(new Error("Unnexected Result querying statistics from layer"));let t=!1;for(let r=0;r<e.fields.length;r++)if("ARCADE_STAT_RESULT"===e.fields[r].name.toUpperCase()){u=e.fields[r].name,"date"===e.fields[r].type&&(t=!0);break}if(t){let t=e.features[0].attributes[u];return null!==t&&(t=new Date(e.features[0].attributes[u])),{calculated:!0,result:t}}return{calculated:!0,result:e.features[0].attributes[u]}}))}))}))}_stat(e,t,r,i,s,a,n){return this._stats(e,t,r,i,s,a,n)}_canDoAggregates(e,t){return this._ensureLoaded().then((()=>{let e=!1;const r=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression;if(void 0!==this._layer.capabilities&&null!==this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics&&!0===this._layer.capabilities.query.supportsOrderBy&&(e=!0),e)for(let i=0;i<t.length-1;i++)null!==t[i].workingexpr&&(!1===t[i].workingexpr.isStandardized||!1===h(t[i].workingexpr)&&!1===r)&&(e=!1);return!1!==e}))}_makeRelationshipEnum(e){if(e.indexOf("esriSpatialRelRelation")>=0)return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.indexOf("esriSpatialRelRelation")>=0?e.split(":")[1]:""}_getAggregatePagesDataSourceDefinition(e,t,r,i,a,n,l){return this._ensureLoaded().then((()=>this.databaseType())).then((o=>{let u="",h=!1,p=!1;null!==n&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=n.constructClause(),p=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(p=!1,h=!0,u=this._layer.objectIdField);const c=[];for(let e=0;e<t.length;e++){const r=new v;r.onStatisticField=null!==t[e].workingexpr?d(t[e].workingexpr,o):"",r.outStatisticFieldName=t[e].field,r.statisticType=t[e].toStatisticsName(),c.push(r)}""===u&&(u=e.join(","));let y=this._maxQueryRate();const f=this._layer.capabilities.query.maxRecordCount;void 0!==f&&f<y&&(y=f);let _=null===a?null===i?"1=1":"":d(a,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression);return new s([],["GETPAGES"],p,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(r),relationParam:this._makeRelationshipParam(r),outFields:["*"],useOIDpagination:h,generatedOid:l,resultRecordCount:y,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:c,geometry:null===i?null:i,where:_,orderByFields:u,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}))}_getAgregagtePhysicalPage(t,r,i){try{let r=t.pagesDefinition.where;!0===t.pagesDefinition.useOIDpagination&&(r=""!==r?"("+r+") AND ("+t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString()+")":t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString());const s=t.pagesDefinition.internal.lastRetrieved,a=s,n=t.pagesDefinition.internal.lastPage,l=new x;return this._requestStandardised&&(l.sqlFormat="standard"),l.where=r,l.spatialRelationship=t.pagesDefinition.spatialRel,l.relationParameter=t.pagesDefinition.relationParam,l.outFields=t.pagesDefinition.outFields,l.outStatistics=t.pagesDefinition.outStatistics,l.geometry=t.pagesDefinition.geometry,l.groupByFieldsForStatistics=t.pagesDefinition.groupByFieldsForStatistics,l.num=t.pagesDefinition.resultRecordCount,l.start=t.pagesDefinition.internal.lastPage,l.returnGeometry=t.pagesDefinition.returnGeometry,l.orderByFields=""!==t.pagesDefinition.orderByFields?t.pagesDefinition.orderByFields.split(","):null,this.isTable()&&l.geometry&&l.spatialRelationship?m([]):this.executeQuery(l,"execute").then((r=>{if(this._checkCancelled(i),!r.hasOwnProperty("features"))return g(new Error("Unnexected Result querying aggregates from layer"));const l=[];if(t.pagesDefinition.internal.lastPage!==n)return[];for(let e=0;e<r.features.length;e++)t.pagesDefinition.internal.set[a+e]=r.features[e].attributes[t.pagesDefinition.generatedOid];for(let t=0;t<r.features.length;t++)l.push(new e({attributes:r.features[t].attributes,geometry:null}));return!0===t.pagesDefinition.useOIDpagination?0===r.features.length?t.pagesDefinition.internal.fullyResolved=!0:t.pagesDefinition.internal.lastMaxId=r.features[r.features.length-1].attributes[t.pagesDefinition.generatedOid]:(void 0===r.exceededTransferLimit&&r.features.length!==t.pagesDefinition.resultRecordCount||!1===r.exceededTransferLimit)&&(t.pagesDefinition.internal.fullyResolved=!0),t.pagesDefinition.internal.lastRetrieved=s+r.features.length,t.pagesDefinition.internal.lastPage+=t.pagesDefinition.resultRecordCount,l}))}catch(s){return g(s)}}static create(e,t,r,i,s){const a=new S({url:e,outFields:null===t?["*"]:t});return new j({layer:a,spatialReference:r,lrucache:i,interceptor:s})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON&&this._layer.source.sourceJSON.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return u(this._layer.parsedUrl.path)}queryAttachments(e,t,i,s,a){if(this._layer.capabilities.data.supportsAttachment&&this._layer.capabilities.operations.supportsQueryAttachments){const n={objectIds:[e],returnMetadata:a};return(t&&t>0||i&&i>0)&&(n.size=[t&&t>0?t:0,i&&i>0?i:t+1]),s&&s.length>0&&(n.attachmentTypes=s),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:n,method:"attachments"}),this._layer.queryAttachments(n).then((t=>{const i=[];return t&&t[e]&&t[e].forEach((t=>{const s=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let n=null;a&&t.exifInfo&&(n=C.convertJsonToArcade(t.exifInfo,!0)),i.push(new r(t.id,t.name,t.contentType,t.size,s,n))})),i}))}return m([])}queryRelatedFeatures(r){const i={f:"json",relationshipId:r.relationshipId.toString(),definitionExpression:r.where,outFields:r.outFields.join(","),returnGeometry:r.returnGeometry.toString()};return void 0!==r.resultOffset&&null!==r.resultOffset&&(i.resultOffset=r.resultOffset.toString()),void 0!==r.resultRecordCount&&null!==r.resultRecordCount&&(i.resultRecordCount=r.resultRecordCount.toString()),r.orderByFields&&(i.orderByFields=r.orderByFields.join(",")),r.objectIds.length>0&&(i.objectIds=r.objectIds.join(",")),r.outSpatialReference&&(i.outSR=JSON.stringify(r.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:i,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"}),t(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:i}).then((t=>{if(t.data){const r={},i=t.data;if(i&&i.relatedRecordGroups){const t=i.spatialReference;for(const s of i.relatedRecordGroups){const a=s.objectId,n=[];for(const r of s.relatedRecords){r.geometry&&(r.geometry.spatialReference=t);const i=new e({geometry:r.geometry?F(r.geometry):null,attributes:r.attributes});n.push(i)}r[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return r}return g("Invalid Request")}))}getFeatureByObjectId(e,t){const r=new x;return r.outFields=t,r.returnGeometry=!1,r.outSpatialReference=this.spatialReference,r.where=this.objectIdField+"="+e.toString(),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:r,method:"execute"}),I(this._layer.parsedUrl.path,r).then((e=>1===e.features.length?e.features[0]:null))}getIdentityUser(){return this.load().then((()=>{var e;const t=null==(e=f)?void 0:e.findCredential(this._layer.url);return t?t.userId:null}))}getOwningSystemUrl(){return this.load().then((()=>{var e;const r=null==(e=f)?void 0:e.findServerInfo(this._layer.url);if(r)return m(r.owningSystemUrl);let i=this._layer.url;const s=i.toLowerCase().indexOf("/rest/services");return i=s>-1?i.substring(0,s):i,i?(i+="/rest/info",_(((e,r)=>{t(i,{query:{f:"json"}}).then((t=>{let r="";t.data&&t.data.owningSystemUrl&&(r=t.data.owningSystemUrl),e(r)}),(t=>{e("")}))}))):m("")}))}getDataSourceFeatureSet(){const e=new j({layer:this._layer,spatialReference:this.spatialReference,outFields:this._overrideFields,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries,interceptor:this.featureSetQueryInterceptor});return e._useDefinitionExpression=!1,e}}export{j as default};
5
+ import e from"../../../Graphic.js";import t from"../../../request.js";import r from"../../Attachment.js";import i from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{defaultMaxRecords as a,stableStringify as n,FeatureServiceDatabaseType as l,IdState as o,extractServiceUrl as u}from"../support/shared.js";import{toWhereClause as d,isSingleField as h}from"../support/sqlUtils.js";import{decodeStatType as p}from"../support/stats.js";import{createMD5Hash as c,outputTypes as y}from"../../../core/MD5.js";import{id as f}from"../../../kernel.js";import{create as _,resolve as m,reject as g}from"../../../core/promiseUtils.js";import{fromJSON as F}from"../../../geometry/support/jsonUtils.js";import S from"../../../layers/FeatureLayer.js";import{convertToFeatureSet as b}from"../../../layers/graphics/featureConversionUtils.js";import"../../../core/urlUtils.js";import"../../../core/unitUtils.js";import"../../../rest/query/support/AttachmentInfo.js";import"../../../rest/support/AttachmentQuery.js";import{executeForCount as R}from"../../../rest/query/executeForCount.js";import"../../../geometry.js";import{executeQueryPBF as D}from"../../../rest/query/operations/query.js";import x from"../../../rest/support/Query.js";import{executeForIds as w}from"../../../rest/query/executeForIds.js";import{executeQueryJSON as I}from"../../../rest/query/executeQueryJSON.js";import"../../../core/has.js";import"../../../geometry/support/spatialReferenceUtils.js";import q from"../../../rest/support/FeatureSet.js";import"../../../rest/support/RelationshipQuery.js";import"../../../geometry/support/normalizeUtils.js";import"../../../rest/support/TopFeaturesQuery.js";import{OptimizedFeatureSetParserContext as P}from"../../../rest/query/operations/pbfOptimizedFeatureSet.js";import v from"../../../rest/support/StatisticDefinition.js";import C from"../../Dictionary.js";class j extends i{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}convertQueryToLruCacheKey(e){const t=n(e.toJSON());return c(t,y.String)}load(){return null===this._loadPromise&&(this._loadPromise=_(((e,t)=>{try{if(!0===this._layer.loaded)return this._initialiseFeatureSet(),void e(this);this._layer.when().then((()=>{try{this._initialiseFeatureSet(),e(this)}catch(r){t(r)}}),t),this._layer.load()}catch(r){t(r)}}))),this._loadPromise}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const r of this._layer.outFields)if(r.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}else;if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=l.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=l.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=l.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=l.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}_isInFeatureSet(){return o.InFeatureSet}_refineSetBlock(e){return m(e)}_candidateIdTransform(e){return e}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,null,e))).then((e=>(this._wset=e,e))):m(this._wset)}_runDatabaseProbe(e){return _(((t,r)=>{try{this._ensureLoaded().then((()=>{try{const i=new x;i.where=e.replace("OBJECTID",this._layer.objectIdField),this._layer.queryObjectIds(i).then((()=>{t(!0)}),(()=>{try{t(!1)}catch(e){r(e)}}))}catch(i){r(i)}}))}catch(i){r(i)}}))}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){return!e.outStatistics&&this._layer&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsFormatPBF&&!0===this._layer.capabilities.query.supportsQuantizationEditMode}queryPBF(e){return e.quantizationParameters={mode:"edit"},D(this._layer.parsedUrl,e,new P({})).then((e=>q.fromJSON(b(e.data)).unquantize()))}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion?this._layer.gdbVersion:"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title,source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}executeQuery(e,t){const r="execute"===t?I:"executeForCount"===t?R:w,i="execute"===t&&this.pbfSupportedForQuery(e);let s=null;if(this.recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);s=this.recentlyUsedQueries.getFromCache(t),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e),this.recentlyUsedQueries.addToCache(t,s),s=s.catch((e=>{throw this.recentlyUsedQueries.removeFromCache(t),e})))}return this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e)),s}_getFilteredSet(e,t,r,i,a){return this.databaseType().then((n=>{if(this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,r,i,a);let l="",o=!1;null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(l=i.constructClause(),o=!0);const u=new x;return u.where=null===r?null===t?"1=1":"":d(r,n),this._requestStandardised&&(u.sqlFormat="standard"),u.spatialRelationship=this._makeRelationshipEnum(e),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==l?l.split(","):null,u.geometry=null===t?null:t,u.relationParameter=this._makeRelationshipParam(e),this.executeQuery(u,"executeForIds").then((e=>{null===e&&(e=[]),this._checkCancelled(a);return new s([],e,o,null)}))}))}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_getFilteredSetUsingPaging(e,t,r,i,a){try{let n="",l=!1;return null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=i.constructClause(),l=!0),this.databaseType().then((i=>{let o=null===r?null===t?"1=1":"":d(r,i);this._layer.definitionExpression&&this._useDefinitionExpression&&(o=""!==o?"(("+this._layer.definitionExpression+") AND ("+o+"))":this._layer.definitionExpression);let u=this._maxQueryRate();const h=this._layer.capabilities.query.maxRecordCount;void 0!==h&&h<u&&(u=h);let p=null;if(!0===this._pageJustIds)p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let r=!0;!0===this._removeGeometry&&(r=!1);const i=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]);p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:i.join(","),resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:r,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return this._expandPagedSet(p,u,0,1,a).then((()=>p))}))}catch(n){return g(n)}}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}_getPhysicalPage(e,t,r){try{const t=e.pagesDefinition.internal.lastRetrieved,i=t,s=e.pagesDefinition.internal.lastPage,a=new x;return this._requestStandardised&&(a.sqlFormat="standard"),a.spatialRelationship=e.pagesDefinition.spatialRel,a.relationParameter=e.pagesDefinition.relationParam,a.outFields=e.pagesDefinition.outFields.split(","),a.num=e.pagesDefinition.resultRecordCount,a.start=e.pagesDefinition.internal.lastPage,a.geometry=e.pagesDefinition.geometry,a.where=e.pagesDefinition.where,a.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,a.returnGeometry=e.pagesDefinition.returnGeometry,a.outSpatialReference=this.spatialReference,this.executeQuery(a,"execute").then((a=>{if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==s)return"done";for(let t=0;t<a.features.length;t++)e.pagesDefinition.internal.set[i+t]=a.features[t].attributes[this._layer.objectIdField];if(!1===this._pageJustIds)for(let e=0;e<a.features.length;e++)this._featureCache[a.features[e].attributes[this._layer.objectIdField]]=a.features[e];return(void 0===a.exceededTransferLimit&&a.features.length!==e.pagesDefinition.resultRecordCount||!1===a.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=t+a.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}))}catch(i){return g(i)}}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.indexOf("*")>-1)return t;let r=!1;for(const i of t)if(i.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return!1===r&&t.push(this.objectIdField),t}_getFeatures(e,t,r,i){const s=[];try{if(-1!==t&&void 0===this._featureCache[t]&&s.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return this._expandPagedSet(e,this._maxProcessingRate(),0,0,i).then((()=>this._getFeatures(e,t,r,i)));let n=0;for(let i=e._lastFetchedIndex;i<e._known.length;i++){if(e._lastFetchedIndex+=1,n++,void 0===this._featureCache[e._known[i]]){let r=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[i]]){const s=t._featureMap[e._known[i]];null!==s&&(r=!0,this._featureCache[e._known[i]]=s)}}if(!1===r&&(e._known[i]!==t&&s.push(e._known[i]),s.length>=this._maxProcessingRate()-1))break}if(n>=r&&0===s.length)break}if(0===s.length)return m("success");try{const e=new x;return this._requestStandardised&&(e.sqlFormat="standard"),e.objectIds=s,e.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]),e.returnGeometry=!0,!0===this._removeGeometry&&(e.returnGeometry=!1),e.outSpatialReference=this.spatialReference,this.executeQuery(e,"execute").then((e=>{if(this._checkCancelled(i),void 0!==e.error)return g(new Error(e.error));for(let t=0;t<e.features.length;t++)this._featureCache[e.features[t].attributes[this._layer.objectIdField]]=e.features[t];return"success"}))}catch(a){return g(a)}}catch(a){return g(a)}}_getDistinctPages(e,t,r,i,s,a,n,l,o){return this._ensureLoaded().then((()=>this.databaseType())).then((u=>{let h=r.parseTree.column;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name.toLowerCase()===h.toLowerCase()){h=this._layer.fields[e].name;break}const p=new x;this._requestStandardised&&(p.sqlFormat="standard");let c=null===a?null===s?"1=1":"":d(a,u);return this._layer.definitionExpression&&this._useDefinitionExpression&&(c=""!==c?"(("+this._layer.definitionExpression+") AND ("+c+"))":this._layer.definitionExpression),p.where=c,p.spatialRelationship=this._makeRelationshipEnum(i),p.relationParameter=this._makeRelationshipParam(i),p.geometry=null===s?null:s,p.returnDistinctValues=!0,p.returnGeometry=!1,p.outFields=[h],this.executeQuery(p,"execute").then((u=>{if(this._checkCancelled(o),!u.hasOwnProperty("features"))return g(new Error("Unnexected Result querying statistics from layer"));let d=!1;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name===h){"date"===this._layer.fields[e].type&&(d=!0);break}for(let e=0;e<u.features.length;e++){if(d){const t=u.features[e].attributes[h];null!==t?l.push(new Date(t)):l.push(t)}else l.push(u.features[e].attributes[h]);if(l.length>=n)break}return 0===u.features.length?l:u.features.length===this._layer.capabilities.query.maxRecordCount&&l.length<n?this._getDistinctPages(e+u.features.length,t,r,i,s,a,n,l,o).then((e=>({calculated:!0,result:e}))):l}))}))}_distinctStat(e,t,r,i,s,a,n){return this._getDistinctPages(0,e,t,r,i,s,a,[],n).then((e=>({calculated:!0,result:e})))}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType}_countstat(e,t,r,i){return this.databaseType().then((e=>{const s=new x;if(this._requestStandardised&&(s.sqlFormat="standard"),this.isTable()&&r&&null!==t&&""!==t)return{calculated:!0,result:0};let a=null===i?null===r?"1=1":"":d(i,e);return this._layer.definitionExpression&&this._useDefinitionExpression&&(a=""!==a?"(("+this._layer.definitionExpression+") AND ("+a+"))":this._layer.definitionExpression),s.where=a,s.where=a,s.spatialRelationship=this._makeRelationshipEnum(t),s.relationParameter=this._makeRelationshipParam(t),s.geometry=null===r?null:r,s.returnGeometry=!1,this.executeQuery(s,"executeForCount").then((e=>({calculated:!0,result:e})))}))}_stats(e,t,r,i,s,a,n){return this._ensureLoaded().then((()=>{const l=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,o=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;return"count"===e?u?this._countstat(e,r,i,s):{calculated:!1}:!1===o||!1===h(t)&&!1===l||!1===t.isStandardized?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):"distinct"===e?!1===u?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):this._distinctStat(e,t,r,i,s,a,n):this.databaseType().then((a=>{if(this.isTable()&&i&&null!==r&&""!==r)return{calculated:!0,result:null};const n=new x;this._requestStandardised&&(n.sqlFormat="standard");let l=null===s?null===i?"1=1":"":d(s,a);this._layer.definitionExpression&&this._useDefinitionExpression&&(l=""!==l?"(("+this._layer.definitionExpression+") AND ("+l+"))":this._layer.definitionExpression),n.where=l,n.spatialRelationship=this._makeRelationshipEnum(r),n.relationParameter=this._makeRelationshipParam(r),n.geometry=null===i?null:i;const o=new v;o.statisticType=p(e),o.onStatisticField=d(t,a),o.outStatisticFieldName="ARCADE_STAT_RESULT",n.returnGeometry=!1;let u="ARCADE_STAT_RESULT";return n.outStatistics=[o],this.executeQuery(n,"execute").then((e=>{if(!e.hasOwnProperty("features")||0===e.features.length)return g(new Error("Unnexected Result querying statistics from layer"));let t=!1;for(let r=0;r<e.fields.length;r++)if("ARCADE_STAT_RESULT"===e.fields[r].name.toUpperCase()){u=e.fields[r].name,"date"===e.fields[r].type&&(t=!0);break}if(t){let t=e.features[0].attributes[u];return null!==t&&(t=new Date(e.features[0].attributes[u])),{calculated:!0,result:t}}return{calculated:!0,result:e.features[0].attributes[u]}}))}))}))}_stat(e,t,r,i,s,a,n){return this._stats(e,t,r,i,s,a,n)}_canDoAggregates(e,t){return this._ensureLoaded().then((()=>{let e=!1;const r=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression;if(void 0!==this._layer.capabilities&&null!==this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics&&!0===this._layer.capabilities.query.supportsOrderBy&&(e=!0),e)for(let i=0;i<t.length-1;i++)null!==t[i].workingexpr&&(!1===t[i].workingexpr.isStandardized||!1===h(t[i].workingexpr)&&!1===r)&&(e=!1);return!1!==e}))}_makeRelationshipEnum(e){if(e.indexOf("esriSpatialRelRelation")>=0)return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.indexOf("esriSpatialRelRelation")>=0?e.split(":")[1]:""}_getAggregatePagesDataSourceDefinition(e,t,r,i,a,n,l){return this._ensureLoaded().then((()=>this.databaseType())).then((o=>{let u="",h=!1,p=!1;null!==n&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=n.constructClause(),p=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(p=!1,h=!0,u=this._layer.objectIdField);const c=[];for(let e=0;e<t.length;e++){const r=new v;r.onStatisticField=null!==t[e].workingexpr?d(t[e].workingexpr,o):"",r.outStatisticFieldName=t[e].field,r.statisticType=t[e].toStatisticsName(),c.push(r)}""===u&&(u=e.join(","));let y=this._maxQueryRate();const f=this._layer.capabilities.query.maxRecordCount;void 0!==f&&f<y&&(y=f);let _=null===a?null===i?"1=1":"":d(a,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression);return new s([],["GETPAGES"],p,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(r),relationParam:this._makeRelationshipParam(r),outFields:["*"],useOIDpagination:h,generatedOid:l,resultRecordCount:y,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:c,geometry:null===i?null:i,where:_,orderByFields:u,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}))}_getAgregagtePhysicalPage(t,r,i){try{let r=t.pagesDefinition.where;!0===t.pagesDefinition.useOIDpagination&&(r=""!==r?"("+r+") AND ("+t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString()+")":t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString());const s=t.pagesDefinition.internal.lastRetrieved,a=s,n=t.pagesDefinition.internal.lastPage,l=new x;return this._requestStandardised&&(l.sqlFormat="standard"),l.where=r,l.spatialRelationship=t.pagesDefinition.spatialRel,l.relationParameter=t.pagesDefinition.relationParam,l.outFields=t.pagesDefinition.outFields,l.outStatistics=t.pagesDefinition.outStatistics,l.geometry=t.pagesDefinition.geometry,l.groupByFieldsForStatistics=t.pagesDefinition.groupByFieldsForStatistics,l.num=t.pagesDefinition.resultRecordCount,l.start=t.pagesDefinition.internal.lastPage,l.returnGeometry=t.pagesDefinition.returnGeometry,l.orderByFields=""!==t.pagesDefinition.orderByFields?t.pagesDefinition.orderByFields.split(","):null,this.isTable()&&l.geometry&&l.spatialRelationship?m([]):this.executeQuery(l,"execute").then((r=>{if(this._checkCancelled(i),!r.hasOwnProperty("features"))return g(new Error("Unnexected Result querying aggregates from layer"));const l=[];if(t.pagesDefinition.internal.lastPage!==n)return[];for(let e=0;e<r.features.length;e++)t.pagesDefinition.internal.set[a+e]=r.features[e].attributes[t.pagesDefinition.generatedOid];for(let t=0;t<r.features.length;t++)l.push(new e({attributes:r.features[t].attributes,geometry:null}));return!0===t.pagesDefinition.useOIDpagination?0===r.features.length?t.pagesDefinition.internal.fullyResolved=!0:t.pagesDefinition.internal.lastMaxId=r.features[r.features.length-1].attributes[t.pagesDefinition.generatedOid]:(void 0===r.exceededTransferLimit&&r.features.length!==t.pagesDefinition.resultRecordCount||!1===r.exceededTransferLimit)&&(t.pagesDefinition.internal.fullyResolved=!0),t.pagesDefinition.internal.lastRetrieved=s+r.features.length,t.pagesDefinition.internal.lastPage+=t.pagesDefinition.resultRecordCount,l}))}catch(s){return g(s)}}static create(e,t,r,i,s){const a=new S({url:e,outFields:null===t?["*"]:t});return new j({layer:a,spatialReference:r,lrucache:i,interceptor:s})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON&&this._layer.source.sourceJSON.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return u(this._layer.parsedUrl.path)}queryAttachments(e,t,i,s,a){if(this._layer.capabilities.data.supportsAttachment&&this._layer.capabilities.operations.supportsQueryAttachments){const n={objectIds:[e],returnMetadata:a};return(t&&t>0||i&&i>0)&&(n.size=[t&&t>0?t:0,i&&i>0?i:t+1]),s&&s.length>0&&(n.attachmentTypes=s),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:n,method:"attachments"}),this._layer.queryAttachments(n).then((t=>{const i=[];return t&&t[e]&&t[e].forEach((t=>{const s=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let n=null;a&&t.exifInfo&&(n=C.convertJsonToArcade(t.exifInfo,!0)),i.push(new r(t.id,t.name,t.contentType,t.size,s,n))})),i}))}return m([])}queryRelatedFeatures(r){const i={f:"json",relationshipId:r.relationshipId.toString(),definitionExpression:r.where,outFields:r.outFields.join(","),returnGeometry:r.returnGeometry.toString()};return void 0!==r.resultOffset&&null!==r.resultOffset&&(i.resultOffset=r.resultOffset.toString()),void 0!==r.resultRecordCount&&null!==r.resultRecordCount&&(i.resultRecordCount=r.resultRecordCount.toString()),r.orderByFields&&(i.orderByFields=r.orderByFields.join(",")),r.objectIds.length>0&&(i.objectIds=r.objectIds.join(",")),r.outSpatialReference&&(i.outSR=JSON.stringify(r.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:i,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"}),t(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:i}).then((t=>{if(t.data){const r={},i=t.data;if(i&&i.relatedRecordGroups){const t=i.spatialReference;for(const s of i.relatedRecordGroups){const a=s.objectId,n=[];for(const r of s.relatedRecords){r.geometry&&(r.geometry.spatialReference=t);const i=new e({geometry:r.geometry?F(r.geometry):null,attributes:r.attributes});n.push(i)}r[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return r}return g("Invalid Request")}))}getFeatureByObjectId(e,t){const r=new x;return r.outFields=t,r.returnGeometry=!1,r.outSpatialReference=this.spatialReference,r.where=this.objectIdField+"="+e.toString(),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:r,method:"execute"}),I(this._layer.parsedUrl.path,r).then((e=>1===e.features.length?e.features[0]:null))}getIdentityUser(){return this.load().then((()=>{var e;const t=null==(e=f)?void 0:e.findCredential(this._layer.url);return t?t.userId:null}))}getOwningSystemUrl(){return this.load().then((()=>{var e;const r=null==(e=f)?void 0:e.findServerInfo(this._layer.url);if(r)return m(r.owningSystemUrl);let i=this._layer.url;const s=i.toLowerCase().indexOf("/rest/services");return i=s>-1?i.substring(0,s):i,i?(i+="/rest/info",_(((e,r)=>{t(i,{query:{f:"json"}}).then((t=>{let r="";t.data&&t.data.owningSystemUrl&&(r=t.data.owningSystemUrl),e(r)}),(t=>{e("")}))}))):m("")}))}getDataSourceFeatureSet(){const e=new j({layer:this._layer,spatialReference:this.spatialReference,outFields:this._overrideFields,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries,interceptor:this.featureSetQueryInterceptor});return e._useDefinitionExpression=!1,e}}export{j as default};