@arcgis/core 4.24.0-next.20220329 → 4.24.0-next.20220401

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 (456) hide show
  1. package/PopupTemplate.js +1 -1
  2. package/WebMap.js +1 -1
  3. package/WebScene.js +1 -1
  4. package/analysis/LineOfSightAnalysisObserver.js +1 -1
  5. package/analysis/LineOfSightAnalysisTarget.js +1 -1
  6. package/arcade/featureset/actions/Adapted.js +1 -1
  7. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  8. package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
  9. package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
  10. package/arcade/featureset/support/FeatureSet.js +1 -1
  11. package/arcade/featureset/support/RecentlyUsedCache.js +1 -1
  12. package/arcade/featureset/support/shared.js +1 -1
  13. package/arcade/functions/convertdirection.js +1 -1
  14. package/arcade/lib/character.js +1 -1
  15. package/arcade/lib/scanner.js +1 -1
  16. package/arcade/lib/tokenizer.js +1 -1
  17. package/arcade/request.js +1 -1
  18. package/arcade/treeAnalysis.js +1 -1
  19. package/assets/esri/core/workers/RemoteClient.js +1 -1
  20. package/assets/esri/core/workers/chunks/0bfedb1dbdff8205e468.js +1 -0
  21. package/assets/esri/core/workers/chunks/{5e472c89a38d6a42b84d.js → 0e29250c24a3a7b1ce13.js} +1 -1
  22. package/assets/esri/core/workers/chunks/0eb9c9477d36cd212f8b.js +1 -0
  23. package/assets/esri/core/workers/chunks/10779a256841c37f2429.js +1 -0
  24. package/assets/esri/core/workers/chunks/10a119889d1ab13402a3.js +1 -0
  25. package/assets/esri/core/workers/chunks/125b14c2ccd96d7c20c2.js +1 -0
  26. package/assets/esri/core/workers/chunks/23ec33a30db201e8b2c3.js +1 -0
  27. package/assets/esri/core/workers/chunks/2530e8ccf6e12787ce76.js +1 -0
  28. package/assets/esri/core/workers/chunks/2d9e97ba5b50aec4dd01.js +1 -0
  29. package/assets/esri/core/workers/chunks/365dc146398420f13f82.js +1 -0
  30. package/assets/esri/core/workers/chunks/3ae2827e8d55d6713d20.js +1 -0
  31. package/assets/esri/core/workers/chunks/3e3eebaa0844742db2f2.js +1 -0
  32. package/assets/esri/core/workers/chunks/3fd5b2d6eccd9098d492.js +1 -0
  33. package/assets/esri/core/workers/chunks/404f1d7bce014c7e6965.js +1 -0
  34. package/assets/esri/core/workers/chunks/411b7777bb5e943c156f.js +1 -0
  35. package/assets/esri/core/workers/chunks/{12ca192a5233bb2875d0.js → 4312902ab6e42fbe119b.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{4ef07f50da39f8607c1c.js → 44e95e87bd9e820aeb53.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{4d4c5e535d8b9ceb865a.js → 4810edf605838d07e5c5.js} +1 -1
  38. package/assets/esri/core/workers/chunks/4bce446391176a9d4588.js +1 -0
  39. package/assets/esri/core/workers/chunks/52a0e387073ea264e194.js +1 -0
  40. package/assets/esri/core/workers/chunks/560234694f3e53802aff.js +1 -0
  41. package/assets/esri/core/workers/chunks/5633710daeb3bbb79bcf.js +1 -0
  42. package/assets/esri/core/workers/chunks/5682039666f874836451.js +1 -0
  43. package/assets/esri/core/workers/chunks/6f01905936396fe87865.js +1 -0
  44. package/assets/esri/core/workers/chunks/6f7917da7166e8c6854b.js +1 -0
  45. package/assets/esri/core/workers/chunks/7388824eac8da01ea03d.js +1 -0
  46. package/assets/esri/core/workers/chunks/7745efef7d5119d0b087.js +1 -0
  47. package/assets/esri/core/workers/chunks/794b47764ebb0257ed41.js +1 -0
  48. package/assets/esri/core/workers/chunks/{da64dedf9270b64f42b2.js → 79bdb26244ec7b4472fe.js} +1 -1
  49. package/assets/esri/core/workers/chunks/79ec28b3e3c57fe026aa.js +1 -0
  50. package/assets/esri/core/workers/chunks/81e9d860a044acec74ce.js +1 -0
  51. package/assets/esri/core/workers/chunks/831dc0187f71e658550c.js +1 -0
  52. package/assets/esri/core/workers/chunks/86ad6b020c01850d9095.js +1 -0
  53. package/assets/esri/core/workers/chunks/{fb7397da8d4ec2ae4587.js → 87458fbf395338511662.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{1a859be598ad96bb4719.js → 8771296b537f366596c4.js} +18 -18
  55. package/assets/esri/core/workers/chunks/8958cd555f4887526e8b.js +1 -0
  56. package/assets/esri/core/workers/chunks/{e57b71ba70f088a3a052.js → 90dcd86cdef90099abfa.js} +1 -1
  57. package/assets/esri/core/workers/chunks/93067e27eea5844edc6c.js +1 -0
  58. package/assets/esri/core/workers/chunks/{9fbee2d9bf50c4c148c6.js → 9a146c9e9b4bf7fba88f.js} +1 -1
  59. package/assets/esri/core/workers/chunks/9b9821772b6cbe189fe0.js +1 -0
  60. package/assets/esri/core/workers/chunks/{6c4ce530b493c6f7c430.js → 9df2f9f7c28b31866be8.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{d0620ce99b620621d8bc.js → a0552044e123a3c51ddf.js} +1 -1
  62. package/assets/esri/core/workers/chunks/acc1a4acd57f5657e782.js +1 -0
  63. package/assets/esri/core/workers/chunks/b055ae7c54796751b64c.js +1 -0
  64. package/assets/esri/core/workers/chunks/{acc2cfb116fee7f82ae9.js → b26bd8fde2fc65bb67fb.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{9b45b94c4dbdc8d2c5fd.js → b34ba22c7a5adce8a7a2.js} +1 -1
  66. package/assets/esri/core/workers/chunks/b75665d0bf417c6ef24a.js +1 -0
  67. package/assets/esri/core/workers/chunks/bd50ec30688463b821d1.js +1 -0
  68. package/assets/esri/core/workers/chunks/c28f7ae4756ad1ba94bd.js +1 -0
  69. package/assets/esri/core/workers/chunks/c4f713959d4115b87c6c.js +1 -0
  70. package/assets/esri/core/workers/chunks/c58aa209492bd94b7aad.js +1 -0
  71. package/assets/esri/core/workers/chunks/{9b117097b7be0efd21d4.js → c59b0b58e24e6a60cf3e.js} +1 -1
  72. package/assets/esri/core/workers/chunks/c7bd5a4d318299388645.js +1 -0
  73. package/assets/esri/core/workers/chunks/c7cee13a962396b23a5e.js +1 -0
  74. package/assets/esri/core/workers/chunks/{3bbff5ea1ea0e955c592.js → cd3679fa86129ebabfdf.js} +1 -1
  75. package/assets/esri/core/workers/chunks/{1a36dc0daffd536ea44d.js → cee7ce362860717713bf.js} +1 -1
  76. package/assets/esri/core/workers/chunks/cf463d6309f14df2f2fa.js +1 -0
  77. package/assets/esri/core/workers/chunks/{224c0e64160bdc170051.js → d076627bb7dadea89e89.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{fff4200bc61b82dd6193.js → d1d1c45243af614f2e74.js} +1 -1
  79. package/assets/esri/core/workers/chunks/{1e0498dc9836658d9aba.js → d5fd12ea541c1a6b7fce.js} +1 -1
  80. package/assets/esri/core/workers/chunks/{10322d990cda5aedf2f0.js → d6e32ca237ad9309c76a.js} +1 -1
  81. package/assets/esri/core/workers/chunks/e06ad3a3d71154fed654.js +1 -0
  82. package/assets/esri/core/workers/chunks/{7a77d4cd27c30f1a5cae.js → ee3387a43dfbb3df23e1.js} +1 -1
  83. package/assets/esri/core/workers/chunks/{5d5fa2b1fc48a17eb9ab.js → f4fc165420d449e442b8.js} +1 -1
  84. package/assets/esri/core/workers/chunks/{3d6d9906a534ddd8fa37.js → f5ee03f3fca7a75192de.js} +1 -1
  85. package/assets/esri/themes/base/widgets/_Daylight.scss +1 -1
  86. package/assets/esri/themes/base/widgets/_ElevationProfile.scss +1 -1
  87. package/assets/esri/themes/base/widgets/_Weather.scss +1 -1
  88. package/assets/esri/themes/base/widgets/_Widget.scss +12 -0
  89. package/assets/esri/themes/dark/main.css +1 -1
  90. package/assets/esri/themes/dark-blue/main.css +1 -1
  91. package/assets/esri/themes/dark-green/main.css +1 -1
  92. package/assets/esri/themes/dark-purple/main.css +1 -1
  93. package/assets/esri/themes/dark-red/main.css +1 -1
  94. package/assets/esri/themes/light/main.css +1 -1
  95. package/assets/esri/themes/light/view.css +1 -1
  96. package/assets/esri/themes/light-blue/main.css +1 -1
  97. package/assets/esri/themes/light-green/main.css +1 -1
  98. package/assets/esri/themes/light-purple/main.css +1 -1
  99. package/assets/esri/themes/light-red/main.css +1 -1
  100. package/chunks/ComponentShader.glsl.js +25 -25
  101. package/chunks/HighlightApply.glsl.js +36 -0
  102. package/chunks/HighlightBlur.glsl.js +26 -0
  103. package/chunks/HighlightDownsample.glsl.js +12 -0
  104. package/chunks/ImageMaterial.glsl.js +8 -8
  105. package/chunks/LineCallout.glsl.js +1 -1
  106. package/chunks/Pattern.glsl.js +2 -2
  107. package/chunks/SimpleAtmosphere.glsl.js +7 -7
  108. package/chunks/Stars.glsl.js +1 -1
  109. package/chunks/arcade.js +1 -1
  110. package/chunks/color.js +1 -1
  111. package/chunks/languageUtils.js +1 -1
  112. package/chunks/mat3.js +1 -1
  113. package/copyright.txt +2 -2
  114. package/core/AsyncUpdate.js +1 -1
  115. package/core/Evented.js +1 -1
  116. package/core/PooledArray.js +1 -1
  117. package/core/accessorSupport/diffUtils.js +1 -1
  118. package/core/accessorSupport/get.js +1 -1
  119. package/core/accessorSupport/read.js +1 -1
  120. package/core/accessorSupport/set.js +1 -1
  121. package/core/accessorSupport/tracking.js +1 -1
  122. package/core/accessorSupport/utils.js +1 -1
  123. package/core/arrayUtils.js +1 -1
  124. package/core/libs/gl-matrix-2/mat3.js +1 -1
  125. package/core/libs/gl-matrix-2/math/mat3.js +1 -1
  126. package/core/number.js +1 -1
  127. package/core/object.js +1 -1
  128. package/core/string.js +1 -1
  129. package/core/unitUtils.js +1 -1
  130. package/core/watchUtils.js +1 -1
  131. package/core/workers/RemoteClient.js +1 -1
  132. package/exports/csv.js +1 -1
  133. package/geometry/support/heightModelInfoUtils.js +1 -1
  134. package/geometry/support/meshUtils/exporters/gltf/geometry.js +1 -1
  135. package/geometry/support/normalizeUtils.js +1 -1
  136. package/identity/IdentityManagerBase.js +1 -1
  137. package/interfaces.d.ts +155 -20
  138. package/layers/ImageryLayer.js +1 -1
  139. package/layers/MapImageLayer.js +1 -1
  140. package/layers/RouteLayer.js +1 -1
  141. package/layers/SceneLayer.js +1 -1
  142. package/layers/SubtypeGroupLayer.js +1 -1
  143. package/layers/TileLayer.js +1 -1
  144. package/layers/VectorTileLayer.js +1 -1
  145. package/layers/WMSLayer.js +1 -1
  146. package/layers/WMTSLayer.js +1 -1
  147. package/layers/WebTileLayer.js +1 -1
  148. package/layers/graphics/data/AttributesBuilder.js +1 -1
  149. package/layers/graphics/data/QueryEngine.js +1 -1
  150. package/layers/graphics/editingSupport.js +1 -1
  151. package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
  152. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  153. package/layers/graphics/sources/support/inferenceUtils.js +1 -1
  154. package/layers/mixins/ArcGISCachedService.js +1 -1
  155. package/layers/mixins/ArcGISImageService.js +1 -1
  156. package/layers/ogc/ogcFeatureUtils.js +1 -1
  157. package/layers/support/ExportImageServiceParameters.js +1 -1
  158. package/layers/support/PixelBlock.js +1 -1
  159. package/layers/support/RasterJobHandler.js +1 -1
  160. package/layers/support/SpriteSource.js +1 -1
  161. package/layers/support/Sublayer.js +1 -1
  162. package/layers/support/TilemapCache.js +1 -1
  163. package/layers/support/WMTSSublayer.js +1 -1
  164. package/layers/support/arcgisLayerUrl.js +1 -1
  165. package/layers/support/fieldUtils.js +1 -1
  166. package/layers/support/kmlUtils.js +1 -1
  167. package/layers/support/layerUtils.js +1 -1
  168. package/layers/support/rasterDatasets/ImageAuxRaster.js +1 -1
  169. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  170. package/layers/support/rasterDatasets/RasterFactory.js +1 -1
  171. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  172. package/layers/support/rasterDatasets/multipartParser.js +1 -1
  173. package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
  174. package/layers/support/rasterDatasets/xmlUtilities.js +1 -1
  175. package/layers/support/rasterFormats/RasterCodec.js +1 -1
  176. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  177. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  178. package/layers/support/vectorTileLayerLoader.js +1 -1
  179. package/layers/support/wmsUtils.js +1 -1
  180. package/layers/support/wmtsUtils.js +1 -1
  181. package/libs/i3s/I3SModule.js +1 -1
  182. package/libs/vxl/VxlModule.js +1 -1
  183. package/package.json +1 -1
  184. package/portal/Portal.js +1 -1
  185. package/portal/PortalItem.js +1 -1
  186. package/portal/schemas/definitions.js +1 -1
  187. package/portal/support/layersLoader.js +1 -1
  188. package/portal/support/portalItemUtils.js +1 -1
  189. package/portal/support/portalLayers.js +1 -1
  190. package/renderers/support/AuthoringInfoVisualVariable.js +1 -1
  191. package/renderers/support/DictionaryLoader.js +1 -1
  192. package/renderers/support/RasterSymbolizer.js +1 -1
  193. package/renderers/support/numberUtils.js +1 -1
  194. package/renderers/support/rasterRendererHelper.js +1 -1
  195. package/renderers/support/utils.js +1 -1
  196. package/request.js +1 -1
  197. package/rest/imageService.js +1 -1
  198. package/rest/operations/find.js +1 -1
  199. package/rest/query/operations/query.js +1 -1
  200. package/rest/query/operations/queryRelatedRecords.js +1 -1
  201. package/rest/query/operations/queryTopFeatures.js +1 -1
  202. package/rest/support/DirectionLine.js +1 -1
  203. package/rest/support/DirectionPoint.js +1 -1
  204. package/rest/support/PointBarrier.js +1 -1
  205. package/rest/support/PolygonBarrier.js +1 -1
  206. package/rest/support/PolylineBarrier.js +1 -1
  207. package/rest/support/RouteInfo.js +1 -1
  208. package/rest/support/Stop.js +1 -1
  209. package/smartMapping/labels/clusters.js +1 -1
  210. package/smartMapping/popup/dotDensity.js +1 -1
  211. package/smartMapping/popup/support/clusterUtils.js +1 -1
  212. package/smartMapping/popup/support/utils.js +1 -1
  213. package/smartMapping/raster/support/utils.js +1 -1
  214. package/smartMapping/renderers/color.js +1 -1
  215. package/smartMapping/renderers/location.js +1 -1
  216. package/smartMapping/renderers/predominance.js +1 -1
  217. package/smartMapping/renderers/relationship.js +1 -1
  218. package/smartMapping/renderers/size.js +1 -1
  219. package/smartMapping/renderers/support/utils.js +1 -1
  220. package/smartMapping/renderers/type.js +1 -1
  221. package/smartMapping/renderers/univariateColorSize.js +1 -1
  222. package/smartMapping/statistics/summaryStatisticsForAge.js +1 -1
  223. package/smartMapping/statistics/support/ageUtils.js +1 -1
  224. package/smartMapping/statistics/support/utils.js +1 -1
  225. package/smartMapping/support/adapters/SceneLayerAdapter.js +1 -1
  226. package/smartMapping/support/adapters/support/utils.js +1 -1
  227. package/smartMapping/support/utils.js +1 -1
  228. package/smartMapping/symbology/support/Theme.js +1 -1
  229. package/smartMapping/symbology/support/colorRamps.js +1 -1
  230. package/smartMapping/symbology/support/symbologyUtils.js +1 -1
  231. package/smartMapping/symbology/support/utils.js +1 -1
  232. package/statistics/utils.js +1 -1
  233. package/support/basemapDefinitions.js +1 -1
  234. package/support/basemapUtils.js +1 -1
  235. package/support/elevationInfoUtils.js +1 -1
  236. package/support/popupUtils.js +1 -1
  237. package/support/revision.js +1 -1
  238. package/symbols/cim/CIMSymbolRasterizer.js +1 -1
  239. package/symbols/cim/cimAnalyzer.js +1 -1
  240. package/symbols/cim/utils.js +1 -1
  241. package/symbols/support/previewSymbol3D.js +1 -1
  242. package/symbols/support/renderUtils.js +1 -1
  243. package/symbols/support/symbolLayerUtils.js +1 -1
  244. package/views/2d/engine/Bitmap.js +1 -1
  245. package/views/2d/engine/flow/FlowDisplayObject.js +1 -1
  246. package/views/2d/engine/imagery/RasterBitmap.js +1 -1
  247. package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
  248. package/views/2d/engine/vectorTiles/TextShaping.js +1 -1
  249. package/views/2d/engine/vectorTiles/TileParser.js +1 -1
  250. package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +1 -1
  251. package/views/2d/engine/vectorTiles/expression/expression.js +1 -1
  252. package/views/2d/engine/vectorTiles/shaders/VTLMaterial.js +1 -1
  253. package/views/2d/engine/webgl/Profiler.js +1 -1
  254. package/views/2d/engine/webgl/Utils.js +1 -1
  255. package/views/2d/engine/webgl/brushes/WGLGeometryBrush.js +1 -1
  256. package/views/2d/engine/webgl/definitions.js +1 -1
  257. package/views/2d/engine/webgl/effects/HittestEffect.js +1 -1
  258. package/views/2d/engine/webgl/effects/HittestEffectVTL.js +1 -1
  259. package/views/2d/engine/webgl/mesh/templates/WGLTemplateStore.js +1 -1
  260. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  261. package/views/2d/engine/webgl/util/Lock.js +1 -1
  262. package/views/2d/layers/RouteLayerView2D.js +1 -1
  263. package/views/2d/layers/features/schemaUtils.js +1 -1
  264. package/views/2d/layers/features/sources/SnapshotFeatureSource.js +1 -1
  265. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  266. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  267. package/views/2d/layers/features/tileRenderers/SymbolTileRenderer.js +1 -1
  268. package/views/2d/layers/support/webStyleUtils.js +1 -1
  269. package/views/2d/support/Timeline.js +1 -1
  270. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  271. package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
  272. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  273. package/views/3d/analysis/Slice/SliceController.js +1 -1
  274. package/views/3d/environment/PanoramicAtmosphere.js +1 -1
  275. package/views/3d/environment/SceneViewAtmosphere.js +1 -1
  276. package/views/3d/environment/StarsTechnique.js +1 -1
  277. package/views/3d/externalRenderers/ExternalRendererStore.js +1 -1
  278. package/views/3d/glTF/loader.js +1 -1
  279. package/views/3d/interactive/analysisTools/lineOfSight/LineOfSightTool.js +1 -1
  280. package/views/3d/interactive/analysisTools/slice/SliceTool.js +1 -1
  281. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  282. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  283. package/views/3d/layers/I3SMeshView3D.js +1 -1
  284. package/views/3d/layers/ImageryLayerView3D.js +1 -1
  285. package/views/3d/layers/LayerView3D.js +1 -1
  286. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  287. package/views/3d/layers/RouteLayerView3D.js +1 -1
  288. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  289. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  290. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  291. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  292. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  293. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  294. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  295. package/views/3d/layers/i3s/IDBMockCache.js +5 -0
  296. package/views/3d/layers/i3s/PointCloudWorkerUtil.js +1 -1
  297. package/views/3d/layers/support/PopupSceneLayerView.js +1 -1
  298. package/views/3d/state/ViewStateManager.js +1 -1
  299. package/views/3d/state/controllers/RotateController.js +1 -1
  300. package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
  301. package/views/3d/state/controllers/global/ZoomController.js +1 -1
  302. package/views/3d/state/controllers/global/ZoomStepController.js +1 -1
  303. package/views/3d/state/controllers/local/PinchAndPanController.js +1 -1
  304. package/views/3d/state/controllers/local/ZoomController.js +1 -1
  305. package/views/3d/support/HighlightOptions.js +1 -1
  306. package/views/3d/support/buffer/InterleavedLayout.js +1 -1
  307. package/views/3d/support/debugFlags.js +1 -1
  308. package/views/3d/support/orientedBoundingBox.js +1 -1
  309. package/views/3d/terrain/TerrainSurface.js +1 -1
  310. package/views/3d/webgl-engine/Stage.js +1 -1
  311. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  312. package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
  313. package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js +3 -3
  314. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js +5 -5
  315. package/views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js +1 -1
  316. package/views/3d/webgl-engine/lib/HighlightHelper.js +1 -1
  317. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  318. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  319. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  320. package/views/3d/webgl-engine/lib/edgeRendering/EdgeShaderParameters.js +1 -1
  321. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  322. package/views/3d/webgl-engine/lib/lodRendering/InstanceData.js +1 -1
  323. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  324. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  325. package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
  326. package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
  327. package/views/3d/webgl-engine/shaders/HighlightApply.glsl.js +5 -0
  328. package/views/3d/webgl-engine/shaders/HighlightApplyTechnique.js +5 -0
  329. package/views/3d/webgl-engine/shaders/HighlightBlur.glsl.js +5 -0
  330. package/views/3d/webgl-engine/shaders/HighlightBlurTechnique.js +5 -0
  331. package/views/3d/webgl-engine/shaders/HighlightDownsample.glsl.js +5 -0
  332. package/views/3d/webgl-engine/shaders/HighlightDownsampleTechnique.js +5 -0
  333. package/views/3d/webgl-engine/shaders/HighlightOptions.js +4 -0
  334. package/views/3d/webgl-engine/shaders/HighlightPassParameters.js +5 -0
  335. package/views/3d/webgl-engine/shaders/ImageMaterial.glsl.js +1 -1
  336. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  337. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
  338. package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
  339. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/AdjustProjectedPosition.glsl.js +5 -7
  340. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +14 -14
  341. package/views/SceneView.js +1 -1
  342. package/views/draw/support/GraphicMover.js +1 -1
  343. package/views/input/InputHandler.js +1 -1
  344. package/views/input/InputManager.js +1 -1
  345. package/views/layers/ImageryTileLayerView.js +1 -1
  346. package/views/layers/MapImageLayerView.js +1 -1
  347. package/views/layers/TileLayerView.js +1 -1
  348. package/views/layers/support/popupUtils.js +1 -1
  349. package/views/support/DefaultsFromMap.js +1 -1
  350. package/views/support/Scheduler.js +1 -1
  351. package/views/support/screenshotUtils.js +1 -1
  352. package/views/ui/DefaultUI.js +1 -1
  353. package/views/webgl/ShaderTranspiler.js +1 -1
  354. package/webscene/Slide.js +1 -1
  355. package/webscene/spec-certification/spec.js +1 -1
  356. package/widgets/AreaMeasurement3D/AreaMeasurement3DViewModel.js +1 -1
  357. package/widgets/Attachments/support/attachmentUtils.js +1 -1
  358. package/widgets/Attachments.js +1 -1
  359. package/widgets/Attribution.js +1 -1
  360. package/widgets/BasemapLayerList.js +1 -1
  361. package/widgets/Bookmarks/BookmarksViewModel.js +1 -1
  362. package/widgets/Bookmarks.js +1 -1
  363. package/widgets/BuildingExplorer/support/filterUtils.js +1 -1
  364. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  365. package/widgets/CoordinateConversion/support/coordinateConversionUtils.js +1 -1
  366. package/widgets/CoordinateConversion/support/formatUtils.js +1 -1
  367. package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
  368. package/widgets/Directions/DirectionsViewModel.js +1 -1
  369. package/widgets/Directions.js +1 -1
  370. package/widgets/Editor/EditorViewModel.js +1 -1
  371. package/widgets/Editor/workflowUtils.js +1 -1
  372. package/widgets/Editor.js +1 -1
  373. package/widgets/ElevationProfile/ElevationProfileViewModel.js +1 -1
  374. package/widgets/Feature/FeatureMedia.js +1 -1
  375. package/widgets/Feature/support/featureUtils.js +1 -1
  376. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  377. package/widgets/FeatureForm/InputField.js +1 -1
  378. package/widgets/FeatureForm.js +1 -1
  379. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  380. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  381. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  382. package/widgets/FeatureTemplates.js +1 -1
  383. package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
  384. package/widgets/LayerList/ListItemPanel.js +1 -1
  385. package/widgets/LayerList.js +1 -1
  386. package/widgets/Legend/LegendViewModel.js +1 -1
  387. package/widgets/Legend/styles/Card.js +1 -1
  388. package/widgets/Legend/styles/Classic.js +1 -1
  389. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  390. package/widgets/Legend/support/colorRampUtils.js +1 -1
  391. package/widgets/Legend/support/relationshipRampUtils.js +1 -1
  392. package/widgets/Legend/support/sizeRampUtils.js +1 -1
  393. package/widgets/Popup/PopupViewModel.js +1 -1
  394. package/widgets/Popup/actionUtils.js +1 -1
  395. package/widgets/Print/PrintViewModel.js +1 -1
  396. package/widgets/Print.js +1 -1
  397. package/widgets/ScaleBar/ScaleBarViewModel.js +1 -1
  398. package/widgets/Search/SearchViewModel.js +1 -1
  399. package/widgets/Search/support/layerSearchUtils.js +1 -1
  400. package/widgets/Slider.js +1 -1
  401. package/widgets/Swipe.js +1 -1
  402. package/widgets/TableList.js +1 -1
  403. package/widgets/TimeSlider/TimeSliderViewModel.js +1 -1
  404. package/widgets/TimeSlider.js +1 -1
  405. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  406. package/widgets/support/DatePicker.js +1 -1
  407. package/widgets/support/Popover.js +1 -1
  408. package/widgets/support/SnappingControls.js +1 -1
  409. package/widgets/support/TimePicker.js +1 -1
  410. package/widgets/support/timeWidgetUtils.js +1 -1
  411. package/assets/esri/core/workers/chunks/083a5d10f8e243641cb9.js +0 -1
  412. package/assets/esri/core/workers/chunks/0872812ce4d0ec8faf8f.js +0 -1
  413. package/assets/esri/core/workers/chunks/0bc26899780c33637746.js +0 -1
  414. package/assets/esri/core/workers/chunks/113362697da1b69deaed.js +0 -1
  415. package/assets/esri/core/workers/chunks/11a2f9708938eac98815.js +0 -1
  416. package/assets/esri/core/workers/chunks/11a45709b703be84caaf.js +0 -1
  417. package/assets/esri/core/workers/chunks/1c1294ff1ebbd8f774f7.js +0 -1
  418. package/assets/esri/core/workers/chunks/1c915cc9a9d5729b6f17.js +0 -1
  419. package/assets/esri/core/workers/chunks/31786756b3d44540f8c0.js +0 -1
  420. package/assets/esri/core/workers/chunks/36a6f34fe40785beff5d.js +0 -1
  421. package/assets/esri/core/workers/chunks/373c16f8b8093d001064.js +0 -1
  422. package/assets/esri/core/workers/chunks/382a331a592abb61267f.js +0 -1
  423. package/assets/esri/core/workers/chunks/3bf106fe34e3992032c4.js +0 -1
  424. package/assets/esri/core/workers/chunks/3dcec610f1c1497d87bc.js +0 -1
  425. package/assets/esri/core/workers/chunks/46495e726d8739260d44.js +0 -1
  426. package/assets/esri/core/workers/chunks/4a82a6a473b3d540d0be.js +0 -1
  427. package/assets/esri/core/workers/chunks/4b6719377a95ac10fa43.js +0 -1
  428. package/assets/esri/core/workers/chunks/4d2ef57ff3a5cfc1313f.js +0 -1
  429. package/assets/esri/core/workers/chunks/4fd2b8153d62592210a2.js +0 -1
  430. package/assets/esri/core/workers/chunks/56e6a1079269e2964b02.js +0 -1
  431. package/assets/esri/core/workers/chunks/5b4d9786c010d265346c.js +0 -1
  432. package/assets/esri/core/workers/chunks/604637e1c3937b376a0d.js +0 -1
  433. package/assets/esri/core/workers/chunks/60f83257e361f87fa6fd.js +0 -1
  434. package/assets/esri/core/workers/chunks/6d3f80be6fceb2c18b5d.js +0 -1
  435. package/assets/esri/core/workers/chunks/6f827a32646bab0a8777.js +0 -1
  436. package/assets/esri/core/workers/chunks/70bd2ab42e3801ef5974.js +0 -1
  437. package/assets/esri/core/workers/chunks/746222184b361b50d6ba.js +0 -1
  438. package/assets/esri/core/workers/chunks/7fb72b2d11e8d840f982.js +0 -1
  439. package/assets/esri/core/workers/chunks/85bb6a1a7704fcdcbec2.js +0 -1
  440. package/assets/esri/core/workers/chunks/8b4c76cebb100e6c06f8.js +0 -1
  441. package/assets/esri/core/workers/chunks/9586a6b320edb1922926.js +0 -1
  442. package/assets/esri/core/workers/chunks/99638697ffda9022ce92.js +0 -1
  443. package/assets/esri/core/workers/chunks/a9da1cb118ca62a9581d.js +0 -1
  444. package/assets/esri/core/workers/chunks/aaa41a5013eef713c032.js +0 -1
  445. package/assets/esri/core/workers/chunks/ac321f939dd488ff6ce4.js +0 -1
  446. package/assets/esri/core/workers/chunks/add6027a96398ecf69de.js +0 -1
  447. package/assets/esri/core/workers/chunks/b75206b46ba81606087c.js +0 -1
  448. package/assets/esri/core/workers/chunks/bf8456828e38a768eba3.js +0 -1
  449. package/assets/esri/core/workers/chunks/c0720d0d8adcba6738d4.js +0 -1
  450. package/assets/esri/core/workers/chunks/c5bb712d5cf8c05a4e13.js +0 -1
  451. package/assets/esri/core/workers/chunks/d343f05a3366f95e0494.js +0 -1
  452. package/assets/esri/core/workers/chunks/d8b1f00075983d769985.js +0 -1
  453. package/chunks/Highlight.glsl.js +0 -88
  454. package/views/3d/webgl-engine/shaders/Highlight.glsl.js +0 -5
  455. package/views/3d/webgl-engine/shaders/HighlightTechnique.js +0 -5
  456. package/views/3d/webgl-engine/shaders/HighlightTechniqueConfiguration.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as t}from"../../../core/maybe.js";import{getExpressionFromFieldName as e,getWhereClause as s,getAliasFromFieldName as i}from"./attributeSupport.js";import{getNormalizedValue as a}from"../../../statistics/utils.js";class r{constructor(t,a,r){this._fieldDataCache=new Map,this._returnDistinctMap=new Map,this.returnDistinctValues=t.returnDistinctValues,this.fieldsIndex=r,this.featureAdapter=a;const l=t.outFields;if(l&&-1===l.indexOf("*")){this.outFields=l;let t=0;for(const a of l){const l=e(a),u=this.fieldsIndex.get(l),n=u?null:s(l,r),c=u?u.name:i(a)||"FIELD_EXP_"+t++;this._fieldDataCache.set(a,{alias:c,clause:n})}}}countDistinctValues(t){return this.returnDistinctValues?(t.forEach((t=>this.getAttributes(t))),this._returnDistinctMap.size):t.length}getAttributes(t){const e=this._processAttributesForOutFields(t);return this._processAttributesForDistinctValues(e)}getFieldValue(t,e,i){const a=i?i.name:e;let r=null;return this._fieldDataCache.has(a)?r=this._fieldDataCache.get(a).clause:i||(r=s(e,this.fieldsIndex),this._fieldDataCache.set(a,{alias:a,clause:r})),i?this.featureAdapter.getAttribute(t,a):r.calculateValue(t,this.featureAdapter)}getNormalizedValue(t,e){const s=e.normalizationType,i=e.normalizationTotal;let r=this.getFieldValue(t,e.field,e.fieldInfo);if(s&&Number.isFinite(r)){const l=this.getFieldValue(t,e.normalizationField,e.normalizationFieldInfo);r=a(r,s,l,i)}return r}getExpressionValue(t,e,s){const i={attributes:this.featureAdapter.getAttributes(t)},a=s.createExecContext(i,e.viewInfo);return s.executeFunction(e.compiledFunc,a)}validateItem(t,e){return this._fieldDataCache.has(e)||this._fieldDataCache.set(e,{alias:e,clause:s(e,this.fieldsIndex)}),this._fieldDataCache.get(e).clause.testFeature(t,this.featureAdapter)}validateItems(t,e){return this._fieldDataCache.has(e)||this._fieldDataCache.set(e,{alias:e,clause:s(e,this.fieldsIndex)}),this._fieldDataCache.get(e).clause.testSet(t,this.featureAdapter)}_processAttributesForOutFields(t){const e=this.outFields;if(!e||!e.length)return this.featureAdapter.getAttributes(t);const s={};for(const i of e){const{alias:e,clause:a}=this._fieldDataCache.get(i);s[e]=a?a.calculateValue(t,this.featureAdapter):this.featureAdapter.getAttribute(t,e)}return s}_processAttributesForDistinctValues(e){if(t(e)||!this.returnDistinctValues)return e;const s=this.outFields,i=[];if(s)for(const t of s){const{alias:s}=this._fieldDataCache.get(t);i.push(e[s])}else for(const t in e)i.push(e[t]);const a=`${(s||["*"]).join(",")}=${i.join(",")}`;let r=this._returnDistinctMap.get(a)||0;return this._returnDistinctMap.set(a,++r),r>1?null:e}}export{r as default};
5
+ import{isNone as t}from"../../../core/maybe.js";import{getExpressionFromFieldName as e,getWhereClause as s,getAliasFromFieldName as i}from"./attributeSupport.js";import{getNormalizedValue as a}from"../../../statistics/utils.js";class r{constructor(t,a,r){this._fieldDataCache=new Map,this._returnDistinctMap=new Map,this.returnDistinctValues=t.returnDistinctValues,this.fieldsIndex=r,this.featureAdapter=a;const l=t.outFields;if(l&&!l.includes("*")){this.outFields=l;let t=0;for(const a of l){const l=e(a),u=this.fieldsIndex.get(l),n=u?null:s(l,r),c=u?u.name:i(a)||"FIELD_EXP_"+t++;this._fieldDataCache.set(a,{alias:c,clause:n})}}}countDistinctValues(t){return this.returnDistinctValues?(t.forEach((t=>this.getAttributes(t))),this._returnDistinctMap.size):t.length}getAttributes(t){const e=this._processAttributesForOutFields(t);return this._processAttributesForDistinctValues(e)}getFieldValue(t,e,i){const a=i?i.name:e;let r=null;return this._fieldDataCache.has(a)?r=this._fieldDataCache.get(a).clause:i||(r=s(e,this.fieldsIndex),this._fieldDataCache.set(a,{alias:a,clause:r})),i?this.featureAdapter.getAttribute(t,a):r.calculateValue(t,this.featureAdapter)}getNormalizedValue(t,e){const s=e.normalizationType,i=e.normalizationTotal;let r=this.getFieldValue(t,e.field,e.fieldInfo);if(s&&Number.isFinite(r)){const l=this.getFieldValue(t,e.normalizationField,e.normalizationFieldInfo);r=a(r,s,l,i)}return r}getExpressionValue(t,e,s){const i={attributes:this.featureAdapter.getAttributes(t)},a=s.createExecContext(i,e.viewInfo);return s.executeFunction(e.compiledFunc,a)}validateItem(t,e){return this._fieldDataCache.has(e)||this._fieldDataCache.set(e,{alias:e,clause:s(e,this.fieldsIndex)}),this._fieldDataCache.get(e).clause.testFeature(t,this.featureAdapter)}validateItems(t,e){return this._fieldDataCache.has(e)||this._fieldDataCache.set(e,{alias:e,clause:s(e,this.fieldsIndex)}),this._fieldDataCache.get(e).clause.testSet(t,this.featureAdapter)}_processAttributesForOutFields(t){const e=this.outFields;if(!e||!e.length)return this.featureAdapter.getAttributes(t);const s={};for(const i of e){const{alias:e,clause:a}=this._fieldDataCache.get(i);s[e]=a?a.calculateValue(t,this.featureAdapter):this.featureAdapter.getAttribute(t,e)}return s}_processAttributesForDistinctValues(e){if(t(e)||!this.returnDistinctValues)return e;const s=this.outFields,i=[];if(s)for(const t of s){const{alias:s}=this._fieldDataCache.get(t);i.push(e[s])}else for(const t in e)i.push(e[t]);const a=`${(s||["*"]).join(",")}=${i.join(",")}`;let r=this._returnDistinctMap.get(a)||0;return this._returnDistinctMap.set(a,++r),r>1?null:e}}export{r as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Error.js";import{clone as t}from"../../../core/lang.js";import{removeMaybe as i,destroyMaybe as s,isNone as r,isSome as a,isUndefined as n}from"../../../core/maybe.js";import{MemCacheStorage as u,MemCache as o}from"../../../core/MemCache.js";import{getMetersPerUnitForSR as c}from"../../../core/unitUtils.js";import{create as h,set as l,NEGATIVE_INFINITY as p,expandWithAABB as d}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as y,create as m}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as f}from"../../../geometry/support/boundsUtils.js";import{fromJSON as x,isExtent as _,isPolygon as g}from"../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridian as w}from"../../../geometry/support/normalizeUtils.js";import{equals as S,isValid as Q}from"../../../geometry/support/spatialReferenceUtils.js";import{validateFields as R,validateWhere as F,validateHaving as I,hasInvalidFieldType as E}from"./attributeSupport.js";import{project as j,checkProjectionSupport as b}from"./projectionSupport.js";import{queryCapabilities as k}from"./QueryEngineCapabilities.js";import{QueryEngineResult as A,SnappingTypes as z}from"./QueryEngineResult.js";import{getSpatialQueryOperator as B,canQueryWithRBush as C,checkSpatialQuerySupport as T}from"./spatialQuerySupport.js";import{getTimeExtent as O}from"./timeSupport.js";import{cleanFromGeometryEngine as v,normalizeQuery as G,QUERY_ENGINE_EMPTY_RESULT as P}from"./utils.js";import q from"../../support/FieldsIndex.js";import{loadArcade as M}from"../../../support/arcadeOnDemand.js";import{noBudget as U}from"../../../views/support/Scheduler.js";function N(e){return e.every((e=>"exceedslimit"!==e.statisticType))}const Z="feature-store:unsupported-query";class H{constructor(e,t=null,i,s,r){this.attributes=e,this.geometry=i,this.centroid=s,this.filterFlags=r,this.groupId=-1,this.displayId=t}}const D=new Set,J=new u(2e6);let L=0;class V{constructor(e){this.capabilities={query:k},this.geometryType=e.geometryType,this.hasM=e.hasM,this.hasZ=e.hasZ,this.objectIdField=e.objectIdField,this.spatialReference=e.spatialReference,this.definitionExpression=e.definitionExpression,this.featureStore=e.featureStore,this.aggregateAdapter=e.aggregateAdapter,this._changeHandle=this.featureStore.events.on("changed",(()=>this.clearCache())),this.timeInfo=e.timeInfo,e.cacheSpatialQueries&&(this._geometryQueryCache=new o(L+++"$$",J)),this.fieldsIndex=new q(e.fields),e.scheduler&&e.priority&&(this._frameTask=e.scheduler.registerTask(e.priority))}destroy(){this._frameTask=i(this._frameTask),this.clearCache(),s(this._geometryQueryCache),this._changeHandle=i(this._changeHandle),s(this.fieldsIndex)}get featureAdapter(){return this.featureStore.featureAdapter}get fullExtent(){const e=this.featureStore.fullBounds;return e?{xmin:e[0],ymin:e[1],xmax:e[2],ymax:e[3],spatialReference:v(this.spatialReference)}:null}get timeExtent(){return this.timeInfo?(this._timeExtent||(this._timeExtent=O(this.timeInfo,this.featureStore)),this._timeExtent):null}clearCache(){this._geometryQueryCache&&this._geometryQueryCache.clear(),this._allItems=null,this._timeExtent=null}async executeQuery(e={},i){let s,r=t(e);try{r=await this._schedule((()=>G(r,this.definitionExpression,this.spatialReference)),i),r=await this._reschedule((()=>this._checkQuerySupport(r)),i),s=await this._reschedule((()=>this._executeGeometryQuery(r,i)),i),s=await this._reschedule((()=>s.executeAggregateIdsQuery(r)),i),s=await this._reschedule((()=>s.executeObjectIdsQuery(r)),i),s=await this._reschedule((()=>s.executeTimeQuery(r)),i),s=await this._reschedule((()=>s.executeAttributesQuery(r)),i)}catch(a){if(a!==P)throw a;s=new A([],null,this)}return s.createQueryResponse(r)}async executeQueryForCount(e={},i){let s=t(e);s.returnGeometry=!1,s.returnCentroid=!1,s.outSR=null;try{s=await this._schedule((()=>G(s,this.definitionExpression,this.spatialReference)),i),s=await this._reschedule((()=>this._checkQuerySupport(s)),i);let e=await this._reschedule((()=>this._executeGeometryQuery(s,i)),i);return e=await this._reschedule((()=>e.executeAggregateIdsQuery(s)),i),e=await this._reschedule((()=>e.executeObjectIdsQuery(s)),i),e=await this._reschedule((()=>e.executeTimeQuery(s)),i),e=await this._reschedule((()=>e.executeAttributesQuery(s)),i),e.createQueryResponseForCount(s)}catch(r){if(r!==P)throw r;return 0}}async executeQueryForExtent(e={},i){let s,r=t(e);const a=r.outSR;try{r=await this._schedule((()=>G(r,this.definitionExpression,this.spatialReference)),i),r=await this._reschedule((()=>this._checkQuerySupport(r)),i),r.returnGeometry=!0,r.returnCentroid=!1,r.outSR=null,s=await this._reschedule((()=>this._executeGeometryQuery(r,i)),i),s=await this._reschedule((()=>s.executeAggregateIdsQuery(r)),i),s=await this._reschedule((()=>s.executeObjectIdsQuery(r)),i),s=await this._reschedule((()=>s.executeTimeQuery(r)),i),s=await this._reschedule((()=>s.executeAttributesQuery(r)),i);const e=s.size;if(!e)return{count:e,extent:null};l(W,p),this.featureStore.forEachBounds(s.items,(e=>d(W,e)),$);const t={xmin:W[0],ymin:W[1],xmax:W[3],ymax:W[4],spatialReference:v(this.spatialReference)};this.hasZ&&isFinite(W[2])&&isFinite(W[5])&&(t.zmin=W[2],t.zmax=W[5]);const n=j(t,s.spatialReference,a);if(n.spatialReference=v(a||this.spatialReference),n.xmax-n.xmin==0){const e=c(n.spatialReference);n.xmin-=e,n.xmax+=e}if(n.ymax-n.ymin==0){const e=c(n.spatialReference);n.ymin-=e,n.ymax+=e}if(this.hasZ&&null!=n.zmin&&null!=n.zmax&&n.zmax-n.zmin==0){const e=c(n.spatialReference);n.zmin-=e,n.zmax+=e}return{count:e,extent:n}}catch(n){if(n===P)return{count:0,extent:null};throw n}}async executeQueryForIds(e={},t){return this.executeQueryForIdSet(e,t).then((e=>Array.from(e)))}async executeQueryForIdSet(e={},i){let s,r=t(e);r.returnGeometry=!1,r.returnCentroid=!1,r.outSR=null;try{r=await this._schedule((()=>G(r,this.definitionExpression,this.spatialReference)),i),r=await this._reschedule((()=>this._checkQuerySupport(r)),i),s=await this._reschedule((()=>this._executeGeometryQuery(r,i)),i),s=await this._reschedule((()=>s.executeAggregateIdsQuery(r)),i),s=await this._reschedule((()=>s.executeObjectIdsQuery(r)),i),s=await this._reschedule((()=>s.executeTimeQuery(r)),i),s=await this._reschedule((()=>s.executeAttributesQuery(r)),i);const e=s.items,t=new Set;return await this._reschedule((()=>{for(const i of e)t.add(s.featureAdapter.getObjectId(i))}),i),t}catch(a){if(a===P)return new Set;throw a}}async executeQueryForSnapping(e,t){const{point:i,distance:s,types:a}=e;if(a===z.NONE)return{candidates:[]};const n=await this._reschedule((()=>this._checkQuerySupport(e.query)),t),u=!S(i.spatialReference,this.spatialReference);u&&await b(i.spatialReference,this.spatialReference);const o="number"==typeof s?s:s.x,c="number"==typeof s?s:s.y,h={xmin:i.x-o,xmax:i.x+o,ymin:i.y-c,ymax:i.y+c,spatialReference:i.spatialReference},l=u?j(h,this.spatialReference):h;if(!l)return{candidates:[]};const p=(await w(x(i),null,{signal:t}))[0],d=(await w(x(l),null,{signal:t}))[0];if(r(p)||r(d))return{candidates:[]};let y=new A(this._searchFeatures(this._getQueryBBoxes(d.toJSON())),null,this);y=await this._reschedule((()=>y.executeObjectIdsQuery(n)),t),y=await this._reschedule((()=>y.executeTimeQuery(n)),t),y=await this._reschedule((()=>y.executeAttributesQuery(n)),t);const m=p.toJSON(),f=u?j(m,this.spatialReference):m,_=u?Math.max(l.xmax-l.xmin,l.ymax-l.ymin)/2:s;return y.createSnappingResponse({...e,point:f,distance:_},i.spatialReference)}async executeQueryForLatestObservations(i={},s){if(!this.timeInfo||!this.timeInfo.trackIdField)throw new e(Z,"Missing timeInfo or timeInfo.trackIdField",{query:i,timeInfo:this.timeInfo});let r,a=t(i);try{a=await this._schedule((()=>G(a,this.definitionExpression,this.spatialReference)),s),a=await this._reschedule((()=>this._checkQuerySupport(a)),s),r=await this._reschedule((()=>this._executeGeometryQuery(a,s)),s),r=await this._reschedule((()=>r.executeAggregateIdsQuery(a)),s),r=await this._reschedule((()=>r.executeObjectIdsQuery(a)),s),r=await this._reschedule((()=>r.executeTimeQuery(a)),s),r=await this._reschedule((()=>r.executeAttributesQuery(a)),s),r=await this._reschedule((()=>r.filterLatest()),s)}catch(n){if(n!==P)throw n;r=new A([],null,this)}return r.createQueryResponse(a)}async executeQueryForSummaryStatistics(e={},t,i){const{field:s,normalizationField:r,valueExpression:a}=t;return(await this._getQueryEngineResultForStats(e,{field:s,normalizationField:r,valueExpression:a},i)).createSummaryStatisticsResponse(e,t)}async executeQueryForUniqueValues(e={},t,i){const{field:s,valueExpression:r}=t;return(await this._getQueryEngineResultForStats(e,{field:s,valueExpression:r},i)).createUniqueValuesResponse(e,t)}async executeQueryForClassBreaks(e={},t,i){const{field:s,normalizationField:r,valueExpression:a}=t;return(await this._getQueryEngineResultForStats(e,{field:s,normalizationField:r,valueExpression:a},i)).createClassBreaksResponse(e,t)}async executeQueryForHistogram(e={},t,i){const{field:s,normalizationField:r,valueExpression:a}=t;return(await this._getQueryEngineResultForStats(e,{field:s,normalizationField:r,valueExpression:a},i)).createHistogramResponse(e,t)}async _schedule(e,t){return a(this._frameTask)?this._frameTask.schedule(e,t):e(U)}async _reschedule(e,t){return a(this._frameTask)?this._frameTask.reschedule(e,t):e(U)}_getAll(){if(!this._allItems){const e=[];this.featureStore.forEach((t=>e.push(t))),this._allItems=new A(e,null,this)}return this._allItems}async _executeGeometryQuery(e,t){const{geometry:i,outSR:s,spatialRel:r,returnGeometry:a,returnCentroid:u}=e,o=this.featureStore.featureSpatialReference,c=i&&o&&o!==i.spatialReference?j(i,o):i,h=a||u,l=Q(s)&&!S(this.spatialReference,s),p=this._geometryQueryCache?l&&h?JSON.stringify({originalFilterGeometry:i,spatialRelationship:r,outSpatialReference:s}):JSON.stringify({originalFilterGeometry:i,spatialRelationship:r}):null;if(p){const e=this._geometryQueryCache.get(p);if(!n(e))return e}const d=async e=>{if(l&&h){const t=await e.project(s);return p&&this._geometryQueryCache.put(p,t,t.size||1),t}return p&&this._geometryQueryCache.put(p,e,e.size||1),e};if(!c)return d(this._getAll());const y=this.featureAdapter;if("esriSpatialRelDisjoint"===r){const e=this._searchFeatures(this._getQueryBBoxes(i));if(!e.length)return d(this._getAll());let s,a;const n=new Set;for(const t of e)n.add(y.getObjectId(t));await this._reschedule((()=>{let e=0;s=new Array(n.size),this.featureStore.forEach((t=>s[e++]=t)),a=n}),t);const u=await this._reschedule((async()=>{const e=await B(r,c,this.geometryType,this.hasZ,this.hasM),n=t=>!a.has(y.getObjectId(t))||e(y.getGeometry(t));return new A(await this._runSpatialFilter(s,n,t),i,this)}),t);return d(u)}const m=this._searchFeatures(this._getQueryBBoxes(i));if(!m.length){const e=new A([],i,this);return p&&this._geometryQueryCache.put(p,e,e.size||1),e}if(this._canExecuteSoloPass(c,e))return d(new A(m,i,this));const f=await B(r,c,this.geometryType,this.hasZ,this.hasM),x=await this._runSpatialFilter(m,(e=>f(y.getGeometry(e))),t);return d(new A(x,i,this))}async _runSpatialFilter(e,t,i){if(!t)return e;if(r(this._frameTask))return e.filter((e=>t(e)));let s=0;const a=new Array,n=async r=>{for(;s<e.length;){const u=e[s++];t(u)&&(a.push(u),r.madeProgress()),r.done&&await this._reschedule((e=>n(e)),i)}};return this._reschedule((e=>n(e)),i).then((()=>a))}_canExecuteSoloPass(e,t){const{geometryType:i}=this,{spatialRel:s}=t;return C(e)&&("esriSpatialRelEnvelopeIntersects"===s||"esriGeometryPoint"===i&&("esriSpatialRelIntersects"===s||"esriSpatialRelContains"===s||"esriSpatialRelWithin"===s))}_getQueryBBoxes(e){if(C(e)){if(_(e))return[y(e.xmin,e.ymin,e.xmax,e.ymax)];if(g(e))return e.rings.map((e=>y(Math.min(e[0][0],e[2][0]),Math.min(e[0][1],e[2][1]),Math.max(e[0][0],e[2][0]),Math.max(e[0][1],e[2][1]))))}return[f(m(),e)]}_searchFeatures(e){for(const s of e)this.featureStore.forEachInBounds(s,(e=>{D.add(e)}));const t=new Array(D.size);let i=0;return D.forEach((e=>t[i++]=e)),D.clear(),t}async _checkStatisticsSupport(t,i){if(t.distance<0||null!=t.geometryPrecision||t.multipatchOption||t.pixelSize||t.relationParam||t.text||t.outStatistics||t.groupByFieldsForStatistics||t.having||t.orderByFields)throw new e(Z,"Unsupported query options",{query:t});return Promise.all([this._checkAttributesQuerySupport(t),this._checkStatisticsParamsSupport(i),T(t,this.geometryType,this.spatialReference),b(this.spatialReference,t.outSR)]).then((()=>t))}async _checkStatisticsParamsSupport(t){let i=[];if(t.valueExpression){const{arcadeUtils:e}=await M();i=e.extractFieldNames(t.valueExpression)}if(t.field&&i.push(t.field),t.normalizationField&&i.push(t.normalizationField),!i.length)throw new e(Z,"params should have at least a field or valueExpression",{params:t});R(this.fieldsIndex,i,"params contains missing fields")}async _checkQuerySupport(t){if(t.distance<0||null!=t.geometryPrecision||t.multipatchOption||t.pixelSize||t.relationParam||t.text)throw new e(Z,"Unsupported query options",{query:t});return Promise.all([this._checkAttributesQuerySupport(t),this._checkStatisticsQuerySupport(t),T(t,this.geometryType,this.spatialReference),b(this.spatialReference,t.outSR)]).then((()=>t))}_checkAttributesQuerySupport(t){const{outFields:i,orderByFields:s,returnDistinctValues:r,outStatistics:a}=t,n=a?a.map((e=>e.outStatisticFieldName&&e.outStatisticFieldName.toLowerCase())).filter(Boolean):[];if(s&&s.length>0){const e=" asc",t=" desc",i=s.map((i=>{const s=i.toLowerCase();return s.indexOf(e)>-1?s.split(e)[0]:s.indexOf(t)>-1?s.split(t)[0]:i})).filter((e=>-1===n.indexOf(e)));R(this.fieldsIndex,i,"orderByFields contains missing fields")}if(i&&i.length>0)R(this.fieldsIndex,i,"outFields contains missing fields");else if(r)throw new e(Z,"outFields should be specified for returnDistinctValues",{query:t});F(this.fieldsIndex,t.where)}async _checkStatisticsQuerySupport(t){const{outStatistics:i,groupByFieldsForStatistics:s,having:r}=t,a=s&&s.length,n=i&&i.length;if(r){if(!a||!n)throw new e(Z,"outStatistics and groupByFieldsForStatistics should be specified with having",{query:t});I(this.fieldsIndex,r,i)}if(n){if(!N(i))return;const r=i.map((e=>e.onStatisticField)).filter(Boolean);R(this.fieldsIndex,r,"onStatisticFields contains missing fields"),a&&R(this.fieldsIndex,s,"groupByFieldsForStatistics contains missing fields");for(const s of i){const{onStatisticField:i,statisticType:r}=s;if(("percentile_disc"===r||"percentile_cont"===r)&&"statisticParameters"in s){const{statisticParameters:i}=s;if(!i)throw new e(Z,"statisticParamters should be set for percentile type",{definition:s,query:t})}else if("count"!==r&&i&&E(i,this.fieldsIndex))throw new e(Z,"outStatistics contains non-numeric fields",{definition:s,query:t})}}}async _getQueryEngineResultForStats(e={},i,s){let r;e=t(e);try{e=await this._schedule((()=>G(e,this.definitionExpression,this.spatialReference)),s),e=await this._reschedule((()=>this._checkStatisticsSupport(e,i)),s),r=await this._reschedule((()=>this._executeGeometryQuery(e,s)),s),r=await this._reschedule((()=>r.executeAggregateIdsQuery(e)),s),r=await this._reschedule((()=>r.executeObjectIdsQuery(e)),s),r=await this._reschedule((()=>r.executeTimeQuery(e)),s),r=await this._reschedule((()=>r.executeAttributesQuery(e)),s)}catch(a){if(a!==P)throw a;r=new A([],null,this)}return r}}const $=h(),W=h();export{H as Feature,V as QueryEngine};
5
+ import e from"../../../core/Error.js";import{clone as t}from"../../../core/lang.js";import{removeMaybe as i,destroyMaybe as s,isNone as r,isSome as a,isUndefined as n}from"../../../core/maybe.js";import{MemCacheStorage as u,MemCache as o}from"../../../core/MemCache.js";import{getMetersPerUnitForSR as c}from"../../../core/unitUtils.js";import{create as h,set as l,NEGATIVE_INFINITY as p,expandWithAABB as d}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as y,create as m}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as f}from"../../../geometry/support/boundsUtils.js";import{fromJSON as x,isExtent as _,isPolygon as g}from"../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridian as w}from"../../../geometry/support/normalizeUtils.js";import{equals as S,isValid as Q}from"../../../geometry/support/spatialReferenceUtils.js";import{validateFields as R,validateWhere as F,validateHaving as I,hasInvalidFieldType as E}from"./attributeSupport.js";import{project as j,checkProjectionSupport as b}from"./projectionSupport.js";import{queryCapabilities as k}from"./QueryEngineCapabilities.js";import{QueryEngineResult as A,SnappingTypes as z}from"./QueryEngineResult.js";import{getSpatialQueryOperator as B,canQueryWithRBush as C,checkSpatialQuerySupport as T}from"./spatialQuerySupport.js";import{getTimeExtent as v}from"./timeSupport.js";import{cleanFromGeometryEngine as O,normalizeQuery as G,QUERY_ENGINE_EMPTY_RESULT as P}from"./utils.js";import q from"../../support/FieldsIndex.js";import{loadArcade as M}from"../../../support/arcadeOnDemand.js";import{noBudget as U}from"../../../views/support/Scheduler.js";function N(e){return e.every((e=>"exceedslimit"!==e.statisticType))}const Z="feature-store:unsupported-query";class H{constructor(e,t=null,i,s,r){this.attributes=e,this.geometry=i,this.centroid=s,this.filterFlags=r,this.groupId=-1,this.displayId=t}}const D=new Set,J=new u(2e6);let L=0;class V{constructor(e){this.capabilities={query:k},this.geometryType=e.geometryType,this.hasM=e.hasM,this.hasZ=e.hasZ,this.objectIdField=e.objectIdField,this.spatialReference=e.spatialReference,this.definitionExpression=e.definitionExpression,this.featureStore=e.featureStore,this.aggregateAdapter=e.aggregateAdapter,this._changeHandle=this.featureStore.events.on("changed",(()=>this.clearCache())),this.timeInfo=e.timeInfo,e.cacheSpatialQueries&&(this._geometryQueryCache=new o(L+++"$$",J)),this.fieldsIndex=new q(e.fields),e.scheduler&&e.priority&&(this._frameTask=e.scheduler.registerTask(e.priority))}destroy(){this._frameTask=i(this._frameTask),this.clearCache(),s(this._geometryQueryCache),this._changeHandle=i(this._changeHandle),s(this.fieldsIndex)}get featureAdapter(){return this.featureStore.featureAdapter}get fullExtent(){const e=this.featureStore.fullBounds;return e?{xmin:e[0],ymin:e[1],xmax:e[2],ymax:e[3],spatialReference:O(this.spatialReference)}:null}get timeExtent(){return this.timeInfo?(this._timeExtent||(this._timeExtent=v(this.timeInfo,this.featureStore)),this._timeExtent):null}clearCache(){this._geometryQueryCache&&this._geometryQueryCache.clear(),this._allItems=null,this._timeExtent=null}async executeQuery(e={},i){let s,r=t(e);try{r=await this._schedule((()=>G(r,this.definitionExpression,this.spatialReference)),i),r=await this._reschedule((()=>this._checkQuerySupport(r)),i),s=await this._reschedule((()=>this._executeGeometryQuery(r,i)),i),s=await this._reschedule((()=>s.executeAggregateIdsQuery(r)),i),s=await this._reschedule((()=>s.executeObjectIdsQuery(r)),i),s=await this._reschedule((()=>s.executeTimeQuery(r)),i),s=await this._reschedule((()=>s.executeAttributesQuery(r)),i)}catch(a){if(a!==P)throw a;s=new A([],null,this)}return s.createQueryResponse(r)}async executeQueryForCount(e={},i){let s=t(e);s.returnGeometry=!1,s.returnCentroid=!1,s.outSR=null;try{s=await this._schedule((()=>G(s,this.definitionExpression,this.spatialReference)),i),s=await this._reschedule((()=>this._checkQuerySupport(s)),i);let e=await this._reschedule((()=>this._executeGeometryQuery(s,i)),i);return e=await this._reschedule((()=>e.executeAggregateIdsQuery(s)),i),e=await this._reschedule((()=>e.executeObjectIdsQuery(s)),i),e=await this._reschedule((()=>e.executeTimeQuery(s)),i),e=await this._reschedule((()=>e.executeAttributesQuery(s)),i),e.createQueryResponseForCount(s)}catch(r){if(r!==P)throw r;return 0}}async executeQueryForExtent(e={},i){let s,r=t(e);const a=r.outSR;try{r=await this._schedule((()=>G(r,this.definitionExpression,this.spatialReference)),i),r=await this._reschedule((()=>this._checkQuerySupport(r)),i),r.returnGeometry=!0,r.returnCentroid=!1,r.outSR=null,s=await this._reschedule((()=>this._executeGeometryQuery(r,i)),i),s=await this._reschedule((()=>s.executeAggregateIdsQuery(r)),i),s=await this._reschedule((()=>s.executeObjectIdsQuery(r)),i),s=await this._reschedule((()=>s.executeTimeQuery(r)),i),s=await this._reschedule((()=>s.executeAttributesQuery(r)),i);const e=s.size;if(!e)return{count:e,extent:null};l(W,p),this.featureStore.forEachBounds(s.items,(e=>d(W,e)),$);const t={xmin:W[0],ymin:W[1],xmax:W[3],ymax:W[4],spatialReference:O(this.spatialReference)};this.hasZ&&isFinite(W[2])&&isFinite(W[5])&&(t.zmin=W[2],t.zmax=W[5]);const n=j(t,s.spatialReference,a);if(n.spatialReference=O(a||this.spatialReference),n.xmax-n.xmin==0){const e=c(n.spatialReference);n.xmin-=e,n.xmax+=e}if(n.ymax-n.ymin==0){const e=c(n.spatialReference);n.ymin-=e,n.ymax+=e}if(this.hasZ&&null!=n.zmin&&null!=n.zmax&&n.zmax-n.zmin==0){const e=c(n.spatialReference);n.zmin-=e,n.zmax+=e}return{count:e,extent:n}}catch(n){if(n===P)return{count:0,extent:null};throw n}}async executeQueryForIds(e={},t){return this.executeQueryForIdSet(e,t).then((e=>Array.from(e)))}async executeQueryForIdSet(e={},i){let s,r=t(e);r.returnGeometry=!1,r.returnCentroid=!1,r.outSR=null;try{r=await this._schedule((()=>G(r,this.definitionExpression,this.spatialReference)),i),r=await this._reschedule((()=>this._checkQuerySupport(r)),i),s=await this._reschedule((()=>this._executeGeometryQuery(r,i)),i),s=await this._reschedule((()=>s.executeAggregateIdsQuery(r)),i),s=await this._reschedule((()=>s.executeObjectIdsQuery(r)),i),s=await this._reschedule((()=>s.executeTimeQuery(r)),i),s=await this._reschedule((()=>s.executeAttributesQuery(r)),i);const e=s.items,t=new Set;return await this._reschedule((()=>{for(const i of e)t.add(s.featureAdapter.getObjectId(i))}),i),t}catch(a){if(a===P)return new Set;throw a}}async executeQueryForSnapping(e,t){const{point:i,distance:s,types:a}=e;if(a===z.NONE)return{candidates:[]};const n=await this._reschedule((()=>this._checkQuerySupport(e.query)),t),u=!S(i.spatialReference,this.spatialReference);u&&await b(i.spatialReference,this.spatialReference);const o="number"==typeof s?s:s.x,c="number"==typeof s?s:s.y,h={xmin:i.x-o,xmax:i.x+o,ymin:i.y-c,ymax:i.y+c,spatialReference:i.spatialReference},l=u?j(h,this.spatialReference):h;if(!l)return{candidates:[]};const p=(await w(x(i),null,{signal:t}))[0],d=(await w(x(l),null,{signal:t}))[0];if(r(p)||r(d))return{candidates:[]};let y=new A(this._searchFeatures(this._getQueryBBoxes(d.toJSON())),null,this);y=await this._reschedule((()=>y.executeObjectIdsQuery(n)),t),y=await this._reschedule((()=>y.executeTimeQuery(n)),t),y=await this._reschedule((()=>y.executeAttributesQuery(n)),t);const m=p.toJSON(),f=u?j(m,this.spatialReference):m,_=u?Math.max(l.xmax-l.xmin,l.ymax-l.ymin)/2:s;return y.createSnappingResponse({...e,point:f,distance:_},i.spatialReference)}async executeQueryForLatestObservations(i={},s){if(!this.timeInfo||!this.timeInfo.trackIdField)throw new e(Z,"Missing timeInfo or timeInfo.trackIdField",{query:i,timeInfo:this.timeInfo});let r,a=t(i);try{a=await this._schedule((()=>G(a,this.definitionExpression,this.spatialReference)),s),a=await this._reschedule((()=>this._checkQuerySupport(a)),s),r=await this._reschedule((()=>this._executeGeometryQuery(a,s)),s),r=await this._reschedule((()=>r.executeAggregateIdsQuery(a)),s),r=await this._reschedule((()=>r.executeObjectIdsQuery(a)),s),r=await this._reschedule((()=>r.executeTimeQuery(a)),s),r=await this._reschedule((()=>r.executeAttributesQuery(a)),s),r=await this._reschedule((()=>r.filterLatest()),s)}catch(n){if(n!==P)throw n;r=new A([],null,this)}return r.createQueryResponse(a)}async executeQueryForSummaryStatistics(e={},t,i){const{field:s,normalizationField:r,valueExpression:a}=t;return(await this._getQueryEngineResultForStats(e,{field:s,normalizationField:r,valueExpression:a},i)).createSummaryStatisticsResponse(e,t)}async executeQueryForUniqueValues(e={},t,i){const{field:s,valueExpression:r}=t;return(await this._getQueryEngineResultForStats(e,{field:s,valueExpression:r},i)).createUniqueValuesResponse(e,t)}async executeQueryForClassBreaks(e={},t,i){const{field:s,normalizationField:r,valueExpression:a}=t;return(await this._getQueryEngineResultForStats(e,{field:s,normalizationField:r,valueExpression:a},i)).createClassBreaksResponse(e,t)}async executeQueryForHistogram(e={},t,i){const{field:s,normalizationField:r,valueExpression:a}=t;return(await this._getQueryEngineResultForStats(e,{field:s,normalizationField:r,valueExpression:a},i)).createHistogramResponse(e,t)}async _schedule(e,t){return a(this._frameTask)?this._frameTask.schedule(e,t):e(U)}async _reschedule(e,t){return a(this._frameTask)?this._frameTask.reschedule(e,t):e(U)}_getAll(){if(!this._allItems){const e=[];this.featureStore.forEach((t=>e.push(t))),this._allItems=new A(e,null,this)}return this._allItems}async _executeGeometryQuery(e,t){const{geometry:i,outSR:s,spatialRel:r,returnGeometry:a,returnCentroid:u}=e,o=this.featureStore.featureSpatialReference,c=i&&o&&o!==i.spatialReference?j(i,o):i,h=a||u,l=Q(s)&&!S(this.spatialReference,s),p=this._geometryQueryCache?l&&h?JSON.stringify({originalFilterGeometry:i,spatialRelationship:r,outSpatialReference:s}):JSON.stringify({originalFilterGeometry:i,spatialRelationship:r}):null;if(p){const e=this._geometryQueryCache.get(p);if(!n(e))return e}const d=async e=>{if(l&&h){const t=await e.project(s);return p&&this._geometryQueryCache.put(p,t,t.size||1),t}return p&&this._geometryQueryCache.put(p,e,e.size||1),e};if(!c)return d(this._getAll());const y=this.featureAdapter;if("esriSpatialRelDisjoint"===r){const e=this._searchFeatures(this._getQueryBBoxes(i));if(!e.length)return d(this._getAll());let s,a;const n=new Set;for(const t of e)n.add(y.getObjectId(t));await this._reschedule((()=>{let e=0;s=new Array(n.size),this.featureStore.forEach((t=>s[e++]=t)),a=n}),t);const u=await this._reschedule((async()=>{const e=await B(r,c,this.geometryType,this.hasZ,this.hasM),n=t=>!a.has(y.getObjectId(t))||e(y.getGeometry(t));return new A(await this._runSpatialFilter(s,n,t),i,this)}),t);return d(u)}const m=this._searchFeatures(this._getQueryBBoxes(i));if(!m.length){const e=new A([],i,this);return p&&this._geometryQueryCache.put(p,e,e.size||1),e}if(this._canExecuteSoloPass(c,e))return d(new A(m,i,this));const f=await B(r,c,this.geometryType,this.hasZ,this.hasM),x=await this._runSpatialFilter(m,(e=>f(y.getGeometry(e))),t);return d(new A(x,i,this))}async _runSpatialFilter(e,t,i){if(!t)return e;if(r(this._frameTask))return e.filter((e=>t(e)));let s=0;const a=new Array,n=async r=>{for(;s<e.length;){const u=e[s++];t(u)&&(a.push(u),r.madeProgress()),r.done&&await this._reschedule((e=>n(e)),i)}};return this._reschedule((e=>n(e)),i).then((()=>a))}_canExecuteSoloPass(e,t){const{geometryType:i}=this,{spatialRel:s}=t;return C(e)&&("esriSpatialRelEnvelopeIntersects"===s||"esriGeometryPoint"===i&&("esriSpatialRelIntersects"===s||"esriSpatialRelContains"===s||"esriSpatialRelWithin"===s))}_getQueryBBoxes(e){if(C(e)){if(_(e))return[y(e.xmin,e.ymin,e.xmax,e.ymax)];if(g(e))return e.rings.map((e=>y(Math.min(e[0][0],e[2][0]),Math.min(e[0][1],e[2][1]),Math.max(e[0][0],e[2][0]),Math.max(e[0][1],e[2][1]))))}return[f(m(),e)]}_searchFeatures(e){for(const s of e)this.featureStore.forEachInBounds(s,(e=>{D.add(e)}));const t=new Array(D.size);let i=0;return D.forEach((e=>t[i++]=e)),D.clear(),t}async _checkStatisticsSupport(t,i){if(t.distance<0||null!=t.geometryPrecision||t.multipatchOption||t.pixelSize||t.relationParam||t.text||t.outStatistics||t.groupByFieldsForStatistics||t.having||t.orderByFields)throw new e(Z,"Unsupported query options",{query:t});return Promise.all([this._checkAttributesQuerySupport(t),this._checkStatisticsParamsSupport(i),T(t,this.geometryType,this.spatialReference),b(this.spatialReference,t.outSR)]).then((()=>t))}async _checkStatisticsParamsSupport(t){let i=[];if(t.valueExpression){const{arcadeUtils:e}=await M();i=e.extractFieldNames(t.valueExpression)}if(t.field&&i.push(t.field),t.normalizationField&&i.push(t.normalizationField),!i.length)throw new e(Z,"params should have at least a field or valueExpression",{params:t});R(this.fieldsIndex,i,"params contains missing fields")}async _checkQuerySupport(t){if(t.distance<0||null!=t.geometryPrecision||t.multipatchOption||t.pixelSize||t.relationParam||t.text)throw new e(Z,"Unsupported query options",{query:t});return Promise.all([this._checkAttributesQuerySupport(t),this._checkStatisticsQuerySupport(t),T(t,this.geometryType,this.spatialReference),b(this.spatialReference,t.outSR)]).then((()=>t))}_checkAttributesQuerySupport(t){const{outFields:i,orderByFields:s,returnDistinctValues:r,outStatistics:a}=t,n=a?a.map((e=>e.outStatisticFieldName&&e.outStatisticFieldName.toLowerCase())).filter(Boolean):[];if(s&&s.length>0){const e=" asc",t=" desc",i=s.map((i=>{const s=i.toLowerCase();return s.includes(e)?s.split(e)[0]:s.includes(t)?s.split(t)[0]:i})).filter((e=>!n.includes(e)));R(this.fieldsIndex,i,"orderByFields contains missing fields")}if(i&&i.length>0)R(this.fieldsIndex,i,"outFields contains missing fields");else if(r)throw new e(Z,"outFields should be specified for returnDistinctValues",{query:t});F(this.fieldsIndex,t.where)}async _checkStatisticsQuerySupport(t){const{outStatistics:i,groupByFieldsForStatistics:s,having:r}=t,a=s&&s.length,n=i&&i.length;if(r){if(!a||!n)throw new e(Z,"outStatistics and groupByFieldsForStatistics should be specified with having",{query:t});I(this.fieldsIndex,r,i)}if(n){if(!N(i))return;const r=i.map((e=>e.onStatisticField)).filter(Boolean);R(this.fieldsIndex,r,"onStatisticFields contains missing fields"),a&&R(this.fieldsIndex,s,"groupByFieldsForStatistics contains missing fields");for(const s of i){const{onStatisticField:i,statisticType:r}=s;if(("percentile_disc"===r||"percentile_cont"===r)&&"statisticParameters"in s){const{statisticParameters:i}=s;if(!i)throw new e(Z,"statisticParamters should be set for percentile type",{definition:s,query:t})}else if("count"!==r&&i&&E(i,this.fieldsIndex))throw new e(Z,"outStatistics contains non-numeric fields",{definition:s,query:t})}}}async _getQueryEngineResultForStats(e={},i,s){let r;e=t(e);try{e=await this._schedule((()=>G(e,this.definitionExpression,this.spatialReference)),s),e=await this._reschedule((()=>this._checkStatisticsSupport(e,i)),s),r=await this._reschedule((()=>this._executeGeometryQuery(e,s)),s),r=await this._reschedule((()=>r.executeAggregateIdsQuery(e)),s),r=await this._reschedule((()=>r.executeObjectIdsQuery(e)),s),r=await this._reschedule((()=>r.executeTimeQuery(e)),s),r=await this._reschedule((()=>r.executeAttributesQuery(e)),s)}catch(a){if(a!==P)throw a;r=new A([],null,this)}return r}}const $=h(),W=h();export{H as Feature,V as QueryEngine};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Graphic.js";import t from"../../core/Collection.js";import a from"../../core/Error.js";import{clone as r}from"../../core/lang.js";import{isSome as i}from"../../core/maybe.js";import{dataComponents as s}from"../../core/urlUtils.js";import{normalizeCentralMeridian as d}from"../../geometry/support/normalizeUtils.js";function n(e){return e&&null!=e.applyEdits}async function l(e,t,a,i={}){let s,d;const n={edits:a,result:new Promise(((e,t)=>{s=e,d=t}))};e.emit("apply-edits",n);try{var l;const{results:d,edits:n}=await o(e,t,a,i),u=e=>e.filter((e=>!e.error)).map(r),p={edits:n,addedFeatures:u(d.addFeatureResults),updatedFeatures:u(d.updateFeatureResults),deletedFeatures:u(d.deleteFeatureResults),addedAttachments:u(d.addAttachmentResults),updatedAttachments:u(d.updateAttachmentResults),deletedAttachments:u(d.deleteAttachmentResults)};return null!=(l=d.editedFeatureResults)&&l.length&&(p.editedFeatures=d.editedFeatureResults),(p.addedFeatures.length||p.updatedFeatures.length||p.deletedFeatures.length||p.addedAttachments.length||p.updatedAttachments.length||p.deletedAttachments.length)&&e.emit("edits",p),s(p),d}catch(u){throw d(u),u}}async function o(e,t,r,i){if(await e.load(),!n(t))return Promise.reject(new a(`${e.type}-layer:no-editing-support`,"Layer source does not support applyEdits capability",{layer:e}));if(!e.editingEnabled)throw new a(`${e.type}-layer:editing-disabled`,"Editing is disabled for layer",{layer:e});const{edits:s,options:d}=await u(e,r,i);return s.addFeatures.length||s.updateFeatures.length||s.deleteFeatures.length||s.addAttachments.length||s.updateAttachments.length||s.deleteAttachments.length?{edits:s,results:await t.applyEdits(s,d)}:{edits:s,results:{addFeatureResults:[],updateFeatureResults:[],deleteFeatureResults:[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}}async function u(e,r,i){const s=r&&(r.addFeatures||r.updateFeatures||r.deleteFeatures),d=r&&(r.addAttachments||r.updateAttachments||r.deleteAttachments);if(!r||!s&&!d)throw new a(`${e.type}-layer:missing-parameters`,"'addFeatures', 'updateFeatures', 'deleteFeatures', 'addAttachments', 'updateAttachments' or 'deleteAttachments' parameter is required");if(!e.capabilities.data.isVersioned&&i&&i.gdbVersion)throw new a(`${e.type}-layer:invalid-parameter`,"'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isVersioned'");if(!e.capabilities.editing.supportsRollbackOnFailure&&i&&i.rollbackOnFailureEnabled)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'rollbackOnFailureEnabled' parameter. See: 'capabilities.editing.supportsRollbackOnFailure'");if(!e.capabilities.editing.supportsGlobalId&&i&&i.globalIdUsed)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'globalIdUsed' parameter. See: 'capabilities.editing.supportsGlobalId'");if(!e.capabilities.editing.supportsGlobalId&&d)throw new a(`${e.type}-layer:invalid-parameter`,"'addAttachments', 'updateAttachments' and 'deleteAttachments' are applicable only if the layer supports global ids. See: 'capabilities.editing.supportsGlobalId'");if((!i||!i.globalIdUsed)&&d)throw new a(`${e.type}-layer:invalid-parameter`,"When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true");const n={...i};if(null!=n.rollbackOnFailureEnabled||e.capabilities.editing.supportsRollbackOnFailure||(n.rollbackOnFailureEnabled=!0),!1===n.rollbackOnFailureEnabled&&"original-and-current-features"===n.returnServiceEditsOption)throw new a(`${e.type}-layer:invalid-parameter`,"'original-and-current-features' is valid for 'returnServiceEditsOption' only when 'rollBackOnFailure' is true.");if(!e.capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference&&n.returnServiceEditsInSourceSR)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'returnServiceEditsInSourceSR' parameter. See: 'capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference'");if(n.returnServiceEditsInSourceSR&&"original-and-current-features"!==n.returnServiceEditsOption)throw new a(`${e.type}-layer:invalid-parameter`,"'returnServiceEditsOption' is valid only when 'returnServiceEditsOption' is set to 'original-and-current-features'");const l={...r};if(l.addFeatures=r&&t.isCollection(r.addFeatures)?r.addFeatures.toArray():l.addFeatures||[],l.updateFeatures=r&&t.isCollection(r.updateFeatures)?r.updateFeatures.toArray():l.updateFeatures||[],l.deleteFeatures=r&&t.isCollection(r.deleteFeatures)?r.deleteFeatures.toArray():l.deleteFeatures||[],l.addFeatures.length&&!e.capabilities.operations.supportsAdd)throw new a(`${e.type}-layer:unsupported-operation`,"Layer does not support adding features.");if(l.updateFeatures.length&&!e.capabilities.operations.supportsUpdate)throw new a(`${e.type}-layer:unsupported-operation`,"Layer does not support updating features.");if(l.deleteFeatures.length&&!e.capabilities.operations.supportsDelete)throw new a(`${e.type}-layer:unsupported-operation`,"Layer does not support deleting features.");l.addAttachments=l.addAttachments||[],l.updateAttachments=l.updateAttachments||[],l.deleteAttachments=l.deleteAttachments||[],l.addFeatures=l.addFeatures.map(g),l.updateFeatures=l.updateFeatures.map(g);const o=i&&i.globalIdUsed;l.addFeatures.forEach((t=>c(t,e,o))),l.updateFeatures.forEach((t=>m(t,e,o))),l.deleteFeatures.forEach((t=>h(t,e,o))),l.addAttachments.forEach((t=>y(t,e))),l.updateAttachments.forEach((t=>y(t,e)));return{edits:await f(l),options:n}}function p(e,t,r){if(r){if("attributes"in e&&!e.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,"Feature should have 'globalId' when 'globalIdUsed' is true");if(!("attributes"in e)&&!e.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"'globalId' of the feature should be passed when 'globalIdUsed' is true")}if("geometry"in e&&i(e.geometry)){if(e.geometry.hasZ&&!1===t.capabilities.data.supportsZ)throw new a(`${t.type}-layer:z-unsupported`,"Layer does not support z values while feature has z values.");if(e.geometry.hasM&&!1===t.capabilities.data.supportsM)throw new a(`${t.type}-layer:m-unsupported`,"Layer does not support m values while feature has m values.")}}function c(e,t,a){p(e,t,a)}function h(e,t,a){p(e,t,a)}function m(e,t,r){if(p(e,t,r),"geometry"in e&&i(e.geometry)&&!t.capabilities.editing.supportsGeometryUpdate)throw new a(`${t.type}-layer:unsupported-operation`,"Layer does not support geometry updates.")}function y(e,t){const{feature:r,attachment:i}=e;if(!r||"attributes"in r&&!r.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have reference to a feature with 'globalId'");if(!("attributes"in r)&&!r.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have reference to 'globalId' of the parent feature");if(!i.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have 'globalId'");if(!i.data&&!i.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have 'data' or 'uploadId'");if(!(i.data instanceof File&&!!i.data.name)&&!i.name)throw new a(`${t.type}-layer:invalid-parameter`,"'name' is required when attachment is specified as Base64 encoded string using 'data'");if(!t.capabilities.editing.supportsUploadWithItemId&&i.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,"This layer does not support 'uploadId' parameter. See: 'capabilities.editing.supportsUploadWithItemId'");if("string"==typeof i.data){const e=s(i.data);if(e&&!e.isBase64)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment 'data' should be a Blob, File or Base64 encoded string")}}async function f(e){const t=e.addFeatures,a=e.updateFeatures,r=t.concat(a).map((e=>e.geometry)),i=await d(r),s=t.length,n=a.length;return i.slice(0,s).forEach(((t,a)=>e.addFeatures[a].geometry=t)),i.slice(s,s+n).forEach(((t,a)=>e.updateFeatures[a].geometry=t)),e}function g(t){const a=new e;return t.attributes||(t.attributes={}),a.geometry=t.geometry,a.attributes=t.attributes,a}export{l as applyEdits};
5
+ import e from"../../Graphic.js";import t from"../../core/Collection.js";import a from"../../core/Error.js";import{clone as r}from"../../core/lang.js";import{isSome as i}from"../../core/maybe.js";import{dataComponents as s}from"../../core/urlUtils.js";import{normalizeCentralMeridian as d}from"../../geometry/support/normalizeUtils.js";function n(e){return e&&null!=e.applyEdits}async function l(e,t,a,i={}){let s,d;const n={edits:a,result:new Promise(((e,t)=>{s=e,d=t}))};e.emit("apply-edits",n);try{var l;const{results:d,edits:n}=await o(e,t,a,i),u=e=>e.filter((e=>!e.error)).map(r),p={edits:n,addedFeatures:u(d.addFeatureResults),updatedFeatures:u(d.updateFeatureResults),deletedFeatures:u(d.deleteFeatureResults),addedAttachments:u(d.addAttachmentResults),updatedAttachments:u(d.updateAttachmentResults),deletedAttachments:u(d.deleteAttachmentResults)};return null!=(l=d.editedFeatureResults)&&l.length&&(p.editedFeatures=d.editedFeatureResults),(p.addedFeatures.length||p.updatedFeatures.length||p.deletedFeatures.length||p.addedAttachments.length||p.updatedAttachments.length||p.deletedAttachments.length)&&e.emit("edits",p),s(p),d}catch(u){throw d(u),u}}async function o(e,t,r,i){if(await e.load(),!n(t))throw new a(`${e.type}-layer:no-editing-support`,"Layer source does not support applyEdits capability",{layer:e});if(!e.editingEnabled)throw new a(`${e.type}-layer:editing-disabled`,"Editing is disabled for layer",{layer:e});const{edits:s,options:d}=await u(e,r,i);return s.addFeatures.length||s.updateFeatures.length||s.deleteFeatures.length||s.addAttachments.length||s.updateAttachments.length||s.deleteAttachments.length?{edits:s,results:await t.applyEdits(s,d)}:{edits:s,results:{addFeatureResults:[],updateFeatureResults:[],deleteFeatureResults:[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}}async function u(e,r,i){const s=r&&(r.addFeatures||r.updateFeatures||r.deleteFeatures),d=r&&(r.addAttachments||r.updateAttachments||r.deleteAttachments);if(!r||!s&&!d)throw new a(`${e.type}-layer:missing-parameters`,"'addFeatures', 'updateFeatures', 'deleteFeatures', 'addAttachments', 'updateAttachments' or 'deleteAttachments' parameter is required");if(!e.capabilities.data.isVersioned&&i&&i.gdbVersion)throw new a(`${e.type}-layer:invalid-parameter`,"'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isVersioned'");if(!e.capabilities.editing.supportsRollbackOnFailure&&i&&i.rollbackOnFailureEnabled)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'rollbackOnFailureEnabled' parameter. See: 'capabilities.editing.supportsRollbackOnFailure'");if(!e.capabilities.editing.supportsGlobalId&&i&&i.globalIdUsed)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'globalIdUsed' parameter. See: 'capabilities.editing.supportsGlobalId'");if(!e.capabilities.editing.supportsGlobalId&&d)throw new a(`${e.type}-layer:invalid-parameter`,"'addAttachments', 'updateAttachments' and 'deleteAttachments' are applicable only if the layer supports global ids. See: 'capabilities.editing.supportsGlobalId'");if((!i||!i.globalIdUsed)&&d)throw new a(`${e.type}-layer:invalid-parameter`,"When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true");const n={...i};if(null!=n.rollbackOnFailureEnabled||e.capabilities.editing.supportsRollbackOnFailure||(n.rollbackOnFailureEnabled=!0),!1===n.rollbackOnFailureEnabled&&"original-and-current-features"===n.returnServiceEditsOption)throw new a(`${e.type}-layer:invalid-parameter`,"'original-and-current-features' is valid for 'returnServiceEditsOption' only when 'rollBackOnFailure' is true.");if(!e.capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference&&n.returnServiceEditsInSourceSR)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'returnServiceEditsInSourceSR' parameter. See: 'capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference'");if(n.returnServiceEditsInSourceSR&&"original-and-current-features"!==n.returnServiceEditsOption)throw new a(`${e.type}-layer:invalid-parameter`,"'returnServiceEditsOption' is valid only when 'returnServiceEditsOption' is set to 'original-and-current-features'");const l={...r};if(l.addFeatures=r&&t.isCollection(r.addFeatures)?r.addFeatures.toArray():l.addFeatures||[],l.updateFeatures=r&&t.isCollection(r.updateFeatures)?r.updateFeatures.toArray():l.updateFeatures||[],l.deleteFeatures=r&&t.isCollection(r.deleteFeatures)?r.deleteFeatures.toArray():l.deleteFeatures||[],l.addFeatures.length&&!e.capabilities.operations.supportsAdd)throw new a(`${e.type}-layer:unsupported-operation`,"Layer does not support adding features.");if(l.updateFeatures.length&&!e.capabilities.operations.supportsUpdate)throw new a(`${e.type}-layer:unsupported-operation`,"Layer does not support updating features.");if(l.deleteFeatures.length&&!e.capabilities.operations.supportsDelete)throw new a(`${e.type}-layer:unsupported-operation`,"Layer does not support deleting features.");l.addAttachments=l.addAttachments||[],l.updateAttachments=l.updateAttachments||[],l.deleteAttachments=l.deleteAttachments||[],l.addFeatures=l.addFeatures.map(g),l.updateFeatures=l.updateFeatures.map(g);const o=i&&i.globalIdUsed;l.addFeatures.forEach((t=>c(t,e,o))),l.updateFeatures.forEach((t=>m(t,e,o))),l.deleteFeatures.forEach((t=>h(t,e,o))),l.addAttachments.forEach((t=>y(t,e))),l.updateAttachments.forEach((t=>y(t,e)));return{edits:await f(l),options:n}}function p(e,t,r){if(r){if("attributes"in e&&!e.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,"Feature should have 'globalId' when 'globalIdUsed' is true");if(!("attributes"in e)&&!e.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"'globalId' of the feature should be passed when 'globalIdUsed' is true")}if("geometry"in e&&i(e.geometry)){if(e.geometry.hasZ&&!1===t.capabilities.data.supportsZ)throw new a(`${t.type}-layer:z-unsupported`,"Layer does not support z values while feature has z values.");if(e.geometry.hasM&&!1===t.capabilities.data.supportsM)throw new a(`${t.type}-layer:m-unsupported`,"Layer does not support m values while feature has m values.")}}function c(e,t,a){p(e,t,a)}function h(e,t,a){p(e,t,a)}function m(e,t,r){if(p(e,t,r),"geometry"in e&&i(e.geometry)&&!t.capabilities.editing.supportsGeometryUpdate)throw new a(`${t.type}-layer:unsupported-operation`,"Layer does not support geometry updates.")}function y(e,t){const{feature:r,attachment:i}=e;if(!r||"attributes"in r&&!r.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have reference to a feature with 'globalId'");if(!("attributes"in r)&&!r.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have reference to 'globalId' of the parent feature");if(!i.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have 'globalId'");if(!i.data&&!i.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have 'data' or 'uploadId'");if(!(i.data instanceof File&&!!i.data.name)&&!i.name)throw new a(`${t.type}-layer:invalid-parameter`,"'name' is required when attachment is specified as Base64 encoded string using 'data'");if(!t.capabilities.editing.supportsUploadWithItemId&&i.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,"This layer does not support 'uploadId' parameter. See: 'capabilities.editing.supportsUploadWithItemId'");if("string"==typeof i.data){const e=s(i.data);if(e&&!e.isBase64)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment 'data' should be a Blob, File or Base64 encoded string")}}async function f(e){const t=e.addFeatures,a=e.updateFeatures,r=t.concat(a).map((e=>e.geometry)),i=await d(r),s=t.length,n=a.length;return i.slice(0,s).forEach(((t,a)=>e.addFeatures[a].geometry=t)),i.slice(s,s+n).forEach(((t,a)=>e.updateFeatures[a].geometry=t)),e}function g(t){const a=new e;return t.attributes||(t.attributes={}),a.geometry=t.geometry,a.attributes=t.attributes,a}export{l as applyEdits};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import t from"../../../../request.js";import r from"../../../../core/Error.js";import o from"../../../../core/Logger.js";import{isSome as s,isNone as i,unwrapOr as n,get as a}from"../../../../core/maybe.js";import{createResolver as c}from"../../../../core/promiseUtils.js";import{addQueryParameters as u}from"../../../../core/urlUtils.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/set.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{WebSocketConnection as d}from"./WebSocketConnection.js";import{executeQuery as h}from"../../../../rest/query/operations/query.js";import l from"../../../../rest/support/Query.js";import{fromJSON as y}from"../../../../geometry/support/jsonUtils.js";import m from"../../../../geometry/SpatialReference.js";const p=o.getLogger("esri.layers.graphics.sources.connections.GeoEventConnection"),g=1e4,_={maxQueryDepth:5,maxRecordCountFactor:3};let w=class extends d{constructor(e){super({..._,...e})}async _open(){const e=await this._fetchServiceDefinition(this._config.source);e.timeInfo.trackIdField||p.warn("GeoEvent service was configured without a TrackIdField. This may result in certain functionality being disabled. The purgeOptions.maxObservations property will have no effect.");const t=this._fetchWebSocketUrl(e.streamUrls,this._config.spatialReference);this._buddyServicesQuery||(this._buddyServicesQuery=this._queryBuddyServices()),await this._buddyServicesQuery,await this._tryCreateWebSocket(t);const{filter:r,outFields:o}=this._config;this.destroyed||this._setFilter(r,o)}_onMessage(e){let t;try{t=this._enrich(JSON.parse(e.data)),s(this._featureZScaler)&&this._featureZScaler(t.geometry)}catch(o){return void p.error(new r("geoevent-connection","Failed to parse message",o))}this.onFeature(t)}async _fetchServiceDefinition(e){const r={f:"json",...this._config.customParameters},o=t(e.path,{query:r,responseType:"json"}),s=(await o).data;return this._serviceDefinition=s,s}_fetchWebSocketUrl(e,t){const r=e[0],{urls:o,token:s}=r,i=this._inferWebSocketBaseUrl(o);return u(`${i}/subscribe`,{outSR:""+t.wkid,token:s})}_inferWebSocketBaseUrl(e){if(1===e.length)return e[0];for(const t of e)if(-1!==t.indexOf("wss"))return t;return p.error(new r("geoevent-connection","Unable to infer WebSocket url",e)),null}async _setFilter(e,t){const o=this._websocket;if(i(o)||i(e)&&i(t))return;const s=JSON.stringify({filter:this._serializeFilter(e,t)});let n=!1;const a=c(),u=()=>{n||(this.destroyed||this._websocket!==o||p.error(new r("geoevent-connection","Server timed out when setting filter")),a.reject())},f=e=>{const t=JSON.parse(e.data);t.filter&&(t.error&&(p.error(new r("geoevent-connection","Failed to set service filter",t.error)),this._set("errorString",`Could not set service filter - ${t.error}`),a.reject(t.error)),o.onmessage=this._onMessage.bind(this),n=!0,a.resolve())};return o.onmessage=f,o.send(s),setTimeout(u,g),a.promise}_serializeFilter(e,t){const o={};if(i(e)&&i(t))return o;if(s(e)&&e.geometry)try{const t=y(e.geometry);if("extent"!==t.type)throw new r(`Expected extent but found type ${t.type}`);o.geometry=JSON.stringify(t.shiftCentralMeridian())}catch(n){p.error(new r("geoevent-connection","Encountered an error when setting connection geometryDefinition",n))}return s(e)&&e.where&&"1 = 1"!==e.where&&(o.where=e.where),s(t)&&(o.outFields=t.join(",")),o}_enrich(e){if(!this._relatedFeatures)return e;const t=this._serviceDefinition.relatedFeatures.joinField,o=e.attributes[t];if(!this._relatedFeatures.has(o))return p.warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",e),e;const{attributes:s,geometry:i}=this._relatedFeatures.get(o);for(const r in s)e.attributes[r]=s[r];return i&&(e.geometry=i),e.geometry||e.centroid||p.error(new r("geoevent-connection","Found malformed feature - no geometry found",e)),e}async _queryBuddyServices(){try{const{relatedFeatures:e,keepLatestArchive:t}=this._serviceDefinition,r=this._queryRelatedFeatures(e),o=this._queryArchive(t);await r;const s=await o;if(!s)return;for(const i of s.features)this.onFeature(this._enrich(i))}catch(e){p.error(new r("geoevent-connection","Encountered an error when querying buddy services",{error:e}))}}async _queryRelatedFeatures(e){if(!e)return;const t=await this._queryBuddy(e.featuresUrl);this._addRelatedFeatures(t)}async _queryArchive(e){if(e)return this._queryBuddy(e.featuresUrl)}async _queryBuddy(e){const t=new((await import("../../../FeatureLayer.js")).default)({url:e}),{capabilities:r}=await t.load(),o=r.query.supportsMaxRecordCountFactor,s=r.query.supportsPagination,i=r.query.supportsCentroid,c=this._config.maxRecordCountFactor,u=t.capabilities.query.maxRecordCount,f=o?u*c:u,d=new l;if(d.outFields=n(this._config.outFields,["*"]),d.where=n(a(this._config.filter,"where"),"1=1"),d.returnGeometry=!0,d.returnExceededLimitFeatures=!0,d.outSpatialReference=m.fromJSON(this._config.spatialReference),i&&(d.returnCentroid=!0),o&&(d.maxRecordCountFactor=c),s)return d.num=f,t.destroy(),this._queryPages(e,d);const y=await h(e,d,this._config.sourceSpatialReference);return t.destroy(),y.data}async _queryPages(e,t,r=[],o=0){t.start=s(t.num)?o*t.num:null;const{data:i}=await h(e,t,this._config.sourceSpatialReference);return i.exceededTransferLimit&&o<this._config.maxQueryDepth?(i.features.forEach((e=>r.push(e))),this._queryPages(e,t,r,o+1)):(r.forEach((e=>i.features.push(e))),i)}_addRelatedFeatures(e){const t=new Map,r=e.features,o=this._serviceDefinition.relatedFeatures.joinField;for(const s of r){const e=s.attributes[o];t.set(e,s)}this._relatedFeatures=t}};w=e([f("esri.layers.graphics.sources.connections.GeoEventConnection")],w);const F=w;export{F as default};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import t from"../../../../request.js";import r from"../../../../core/Error.js";import o from"../../../../core/Logger.js";import{isSome as s,isNone as i,unwrapOr as n,get as a}from"../../../../core/maybe.js";import{createResolver as c}from"../../../../core/promiseUtils.js";import{addQueryParameters as u}from"../../../../core/urlUtils.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/set.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{WebSocketConnection as d}from"./WebSocketConnection.js";import{executeQuery as h}from"../../../../rest/query/operations/query.js";import l from"../../../../rest/support/Query.js";import{fromJSON as y}from"../../../../geometry/support/jsonUtils.js";import m from"../../../../geometry/SpatialReference.js";const p=o.getLogger("esri.layers.graphics.sources.connections.GeoEventConnection"),g=1e4,_={maxQueryDepth:5,maxRecordCountFactor:3};let w=class extends d{constructor(e){super({..._,...e})}async _open(){const e=await this._fetchServiceDefinition(this._config.source);e.timeInfo.trackIdField||p.warn("GeoEvent service was configured without a TrackIdField. This may result in certain functionality being disabled. The purgeOptions.maxObservations property will have no effect.");const t=this._fetchWebSocketUrl(e.streamUrls,this._config.spatialReference);this._buddyServicesQuery||(this._buddyServicesQuery=this._queryBuddyServices()),await this._buddyServicesQuery,await this._tryCreateWebSocket(t);const{filter:r,outFields:o}=this._config;this.destroyed||this._setFilter(r,o)}_onMessage(e){let t;try{t=this._enrich(JSON.parse(e.data)),s(this._featureZScaler)&&this._featureZScaler(t.geometry)}catch(o){return void p.error(new r("geoevent-connection","Failed to parse message",o))}this.onFeature(t)}async _fetchServiceDefinition(e){const r={f:"json",...this._config.customParameters},o=t(e.path,{query:r,responseType:"json"}),s=(await o).data;return this._serviceDefinition=s,s}_fetchWebSocketUrl(e,t){const r=e[0],{urls:o,token:s}=r,i=this._inferWebSocketBaseUrl(o);return u(`${i}/subscribe`,{outSR:""+t.wkid,token:s})}_inferWebSocketBaseUrl(e){if(1===e.length)return e[0];for(const t of e)if(t.includes("wss"))return t;return p.error(new r("geoevent-connection","Unable to infer WebSocket url",e)),null}async _setFilter(e,t){const o=this._websocket;if(i(o)||i(e)&&i(t))return;const s=JSON.stringify({filter:this._serializeFilter(e,t)});let n=!1;const a=c(),u=()=>{n||(this.destroyed||this._websocket!==o||p.error(new r("geoevent-connection","Server timed out when setting filter")),a.reject())},f=e=>{const t=JSON.parse(e.data);t.filter&&(t.error&&(p.error(new r("geoevent-connection","Failed to set service filter",t.error)),this._set("errorString",`Could not set service filter - ${t.error}`),a.reject(t.error)),o.onmessage=this._onMessage.bind(this),n=!0,a.resolve())};return o.onmessage=f,o.send(s),setTimeout(u,g),a.promise}_serializeFilter(e,t){const o={};if(i(e)&&i(t))return o;if(s(e)&&e.geometry)try{const t=y(e.geometry);if("extent"!==t.type)throw new r(`Expected extent but found type ${t.type}`);o.geometry=JSON.stringify(t.shiftCentralMeridian())}catch(n){p.error(new r("geoevent-connection","Encountered an error when setting connection geometryDefinition",n))}return s(e)&&e.where&&"1 = 1"!==e.where&&(o.where=e.where),s(t)&&(o.outFields=t.join(",")),o}_enrich(e){if(!this._relatedFeatures)return e;const t=this._serviceDefinition.relatedFeatures.joinField,o=e.attributes[t];if(!this._relatedFeatures.has(o))return p.warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",e),e;const{attributes:s,geometry:i}=this._relatedFeatures.get(o);for(const r in s)e.attributes[r]=s[r];return i&&(e.geometry=i),e.geometry||e.centroid||p.error(new r("geoevent-connection","Found malformed feature - no geometry found",e)),e}async _queryBuddyServices(){try{const{relatedFeatures:e,keepLatestArchive:t}=this._serviceDefinition,r=this._queryRelatedFeatures(e),o=this._queryArchive(t);await r;const s=await o;if(!s)return;for(const i of s.features)this.onFeature(this._enrich(i))}catch(e){p.error(new r("geoevent-connection","Encountered an error when querying buddy services",{error:e}))}}async _queryRelatedFeatures(e){if(!e)return;const t=await this._queryBuddy(e.featuresUrl);this._addRelatedFeatures(t)}async _queryArchive(e){if(e)return this._queryBuddy(e.featuresUrl)}async _queryBuddy(e){const t=new((await import("../../../FeatureLayer.js")).default)({url:e}),{capabilities:r}=await t.load(),o=r.query.supportsMaxRecordCountFactor,s=r.query.supportsPagination,i=r.query.supportsCentroid,c=this._config.maxRecordCountFactor,u=t.capabilities.query.maxRecordCount,f=o?u*c:u,d=new l;if(d.outFields=n(this._config.outFields,["*"]),d.where=n(a(this._config.filter,"where"),"1=1"),d.returnGeometry=!0,d.returnExceededLimitFeatures=!0,d.outSpatialReference=m.fromJSON(this._config.spatialReference),i&&(d.returnCentroid=!0),o&&(d.maxRecordCountFactor=c),s)return d.num=f,t.destroy(),this._queryPages(e,d);const y=await h(e,d,this._config.sourceSpatialReference);return t.destroy(),y.data}async _queryPages(e,t,r=[],o=0){t.start=s(t.num)?o*t.num:null;const{data:i}=await h(e,t,this._config.sourceSpatialReference);return i.exceededTransferLimit&&o<this._config.maxQueryDepth?(i.features.forEach((e=>r.push(e))),this._queryPages(e,t,r,o+1)):(r.forEach((e=>i.features.push(e))),i)}_addRelatedFeatures(e){const t=new Map,r=e.features,o=this._serviceDefinition.relatedFeatures.joinField;for(const s of r){const e=s.attributes[o];t.set(e,s)}this._relatedFeatures=t}};w=e([f("esri.layers.graphics.sources.connections.GeoEventConnection")],w);const F=w;export{F as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import{isNone as t,isSome as i}from"../../../../core/maybe.js";import{getJsonType as s,isPoint as r}from"../../../../geometry/support/jsonUtils.js";import{WGS84 as n}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertFromFeatures as a,convertToFeature as o,convertFromFeature as l}from"../../featureConversionUtils.js";import{initialObjectId as d,findLastObjectIdFromFeatures as u}from"../../objectIdUtils.js";import p from"../../data/FeatureStore.js";import{checkProjectionSupport as f,project as y}from"../../data/projectionSupport.js";import{QueryEngine as c}from"../../data/QueryEngine.js";import{createDefaultAttributesFunction as m,createDrawingInfo as h,createDefaultTemplate as g}from"./clientSideDefaults.js";import{loadGeometryEngineForSimplify as I,createFeatureEditErrorResult as b,mixAttributes as F,createFeatureEditSuccessResult as j,simplify as _}from"./sourceUtils.js";import E from"../../../support/FieldsIndex.js";import{kebabDict as x}from"../../../support/fieldType.js";import{getFieldDefaultValue as T}from"../../../support/fieldUtils.js";const R=n,q={xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:n},D={hasAttachments:!1,capabilities:"query, editing, create, delete, update",useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsStatistics:!0,supportsPercentileStatistics:!0,supportsReturningGeometryCentroid:!0,supportsQueryWithDistance:!0,supportsDistinct:!0,supportsReturningQueryExtent:!0,supportsReturningGeometryProperties:!1,supportsHavingClause:!0,supportsOrderBy:!0,supportsPagination:!0,supportsQueryWithResultType:!1,supportsSqlExpression:!0,supportsDisjointSpatialRel:!0}};function O(e){return r(e)?null!=e.z:!!e.hasZ}function w(e){return r(e)?null!=e.m:!!e.hasM}class S{constructor(){this._queryEngine=null,this._nextObjectId=null}destroy(){this._queryEngine&&this._queryEngine&&this._queryEngine.destroy(),this._queryEngine=this._fieldsIndex=this._createDefaultAttributes=null}async load(t){const i=[],{features:s}=t,r=this._inferLayerProperties(s,t.fields),n=t.fields||[],a=null!=t.hasM?t.hasM:r.hasM,o=null!=t.hasZ?t.hasZ:r.hasZ,l=!t.spatialReference&&!r.spatialReference,y=l?R:t.spatialReference||r.spatialReference,I=l?q:null,b=t.geometryType||r.geometryType,F=!b;let j=t.objectIdField||r.objectIdField,_=t.timeInfo;if(!F&&(l&&i.push({name:"feature-layer:spatial-reference-not-found",message:"Spatial reference not provided or found in features. Defaults to WGS84"}),!b))throw new e("feature-layer:missing-property","geometryType not set and couldn't be inferred from the provided features");if(!j)throw new e("feature-layer:missing-property","objectIdField not set and couldn't be found in the provided fields");if(r.objectIdField&&j!==r.objectIdField&&(i.push({name:"feature-layer:duplicated-oid-field",message:`Provided objectIdField "${j}" doesn't match the field name "${r.objectIdField}", found in the provided fields`}),j=r.objectIdField),j&&!r.objectIdField){let e=null;n.some((t=>t.name===j&&(e=t,!0)))?(e.type="esriFieldTypeOID",e.editable=!1,e.nullable=!1):n.unshift({alias:j,name:j,type:"esriFieldTypeOID",editable:!1,nullable:!1})}for(const d of n){if(null==d.name&&(d.name=d.alias),null==d.alias&&(d.alias=d.name),!d.name)throw new e("feature-layer:invalid-field-name","field name is missing",{field:d});if(d.name===j&&(d.type="esriFieldTypeOID"),-1===x.jsonValues.indexOf(d.type))throw new e("feature-layer:invalid-field-type",`invalid type for field "${d.name}"`,{field:d})}const O={};for(const e of n)if("esriFieldTypeOID"!==e.type&&"esriFieldTypeGlobalID"!==e.type){const t=T(e);void 0!==t&&(O[e.name]=t)}if(this._fieldsIndex=new E(n),this._createDefaultAttributes=m(O,j),_){if(_.startTimeField){const e=this._fieldsIndex.get(_.startTimeField);e?(_.startTimeField=e.name,e.type="esriFieldTypeDate"):_.startTimeField=null}if(_.endTimeField){const e=this._fieldsIndex.get(_.endTimeField);e?(_.endTimeField=e.name,e.type="esriFieldTypeDate"):_.endTimeField=null}if(_.trackIdField){const e=this._fieldsIndex.get(_.trackIdField);e?_.trackIdField=e.name:(_.trackIdField=null,i.push({name:"feature-layer:invalid-timeInfo-trackIdField",message:"trackIdField is missing",details:{timeInfo:_}}))}_.startTimeField||_.endTimeField||(i.push({name:"feature-layer:invalid-timeInfo",message:"startTimeField and endTimeField are missing or invalid",details:{timeInfo:_}}),_=null)}const w={warnings:i,featureErrors:[],layerDefinition:{...D,drawingInfo:h(b),templates:g(O),extent:I,geometryType:b,objectIdField:j,fields:n,hasZ:!!o,hasM:!!a,timeInfo:_},assignedObjectIds:{}};if(this._queryEngine=new c({fields:n,geometryType:b,hasM:a,hasZ:o,objectIdField:j,spatialReference:y,featureStore:new p({geometryType:b,hasM:a,hasZ:o}),timeInfo:_,cacheSpatialQueries:!0}),!s||!s.length)return this._nextObjectId=d,w;const S=u(j,s);return this._nextObjectId=S+1,await f(s,y),this._loadInitialFeatures(w,s)}async applyEdits(e){const{spatialReference:t,geometryType:i}=this._queryEngine;return await Promise.all([I(t,i),f(e.adds,t),f(e.updates,t)]),this._applyEdits(e)}queryFeatures(e,t={}){return this._queryEngine.executeQuery(e,t.signal)}queryFeatureCount(e,t={}){return this._queryEngine.executeQueryForCount(e,t.signal)}queryObjectIds(e,t={}){return this._queryEngine.executeQueryForIds(e,t.signal)}queryExtent(e,t={}){return this._queryEngine.executeQueryForExtent(e,t.signal)}querySnapping(e,t={}){return this._queryEngine.executeQueryForSnapping(e,t.signal)}_inferLayerProperties(e,i){let r,n,a=null,o=null,l=null;for(const d of e){const e=d.geometry;if(!t(e)&&(a||(a=s(e)),o||(o=e.spatialReference),null==r&&(r=O(e)),null==n&&(n=w(e)),a&&o&&null!=r&&null!=n))break}if(i&&i.length){let e=null;i.some((t=>{const i="esriFieldTypeOID"===t.type,s=!t.type&&t.name&&"objectid"===t.name.toLowerCase();return e=t,i||s}))&&(l=e.name)}return{geometryType:a,spatialReference:o,objectIdField:l,hasM:n,hasZ:r}}_loadInitialFeatures(e,t){const{geometryType:r,hasM:n,hasZ:o,objectIdField:l,spatialReference:d,featureStore:u}=this._queryEngine,p=[];for(const a of t){if(null!=a.uid&&(e.assignedObjectIds[a.uid]=-1),a.geometry&&r!==s(a.geometry)){e.featureErrors.push(b("Incorrect geometry type."));continue}const t=this._createDefaultAttributes(),n=F(this._fieldsIndex,t,a.attributes,!0,e.warnings);n?e.featureErrors.push(n):(this._assignObjectId(t,a.attributes,!0),a.attributes=t,null!=a.uid&&(e.assignedObjectIds[a.uid]=a.attributes[l]),i(a.geometry)&&(a.geometry=y(a.geometry,a.geometry.spatialReference,d)),p.push(a))}if(u.addMany(a([],p,r,o,n,l)),e.layerDefinition.extent=this._queryEngine.fullExtent,e.layerDefinition.timeInfo){const{start:t,end:i}=this._queryEngine.timeExtent;e.layerDefinition.timeInfo.timeExtent=[t,i]}return e}_applyEdits(e){const{adds:t,updates:i,deletes:s}=e,r={addResults:[],deleteResults:[],updateResults:[],uidToObjectId:{}};if(t&&t.length&&this._applyAddEdits(r,t),i&&i.length&&this._applyUpdateEdits(r,i),s&&s.length){for(const e of s)r.deleteResults.push(j(e));this._queryEngine.featureStore.removeManyById(s)}return{fullExtent:this._queryEngine.fullExtent,featureEditResults:r}}_applyAddEdits(e,t){const{addResults:r}=e,{geometryType:n,hasM:o,hasZ:l,objectIdField:d,spatialReference:u,featureStore:p}=this._queryEngine,f=[];for(const a of t){if(a.geometry&&n!==s(a.geometry)){r.push(b("Incorrect geometry type."));continue}const t=this._createDefaultAttributes(),o=F(this._fieldsIndex,t,a.attributes);if(o)r.push(o);else{if(this._assignObjectId(t,a.attributes),a.attributes=t,null!=a.uid){const t=a.attributes[d];e.uidToObjectId[a.uid]=t}i(a.geometry)&&(a.geometry=y(_(a.geometry,u),a.geometry.spatialReference,u)),f.push(a),r.push(j(a.attributes[d]))}}p.addMany(a([],f,n,l,o,d))}_applyUpdateEdits({updateResults:e},t){const{geometryType:r,hasM:n,hasZ:a,objectIdField:d,spatialReference:u,featureStore:p}=this._queryEngine;for(const f of t){const{attributes:t,geometry:c}=f,m=t&&t[d];if(null==m){e.push(b(`Identifier field ${d} missing`));continue}if(!p.has(m)){e.push(b(`Feature with object id ${m} missing`));continue}const h=o(p.getFeature(m),r,a,n);if(i(c)){if(r!==s(c)){e.push(b("Incorrect geometry type."));continue}h.geometry=y(_(c,u),c.spatialReference,u)}if(t){const i=F(this._fieldsIndex,h.attributes,t);if(i){e.push(i);continue}}p.add(l(h,r,a,n,d)),e.push(j(m))}}_assignObjectId(e,t,i=!1){const s=this._queryEngine.objectIdField;i&&t&&isFinite(t[s])?e[s]=t[s]:e[s]=this._nextObjectId++}}export{S as default};
5
+ import e from"../../../../core/Error.js";import{isNone as t,isSome as i}from"../../../../core/maybe.js";import{getJsonType as s,isPoint as r}from"../../../../geometry/support/jsonUtils.js";import{WGS84 as n}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertFromFeatures as a,convertToFeature as o,convertFromFeature as l}from"../../featureConversionUtils.js";import{initialObjectId as u,findLastObjectIdFromFeatures as d}from"../../objectIdUtils.js";import p from"../../data/FeatureStore.js";import{checkProjectionSupport as f,project as y}from"../../data/projectionSupport.js";import{QueryEngine as c}from"../../data/QueryEngine.js";import{createDefaultAttributesFunction as m,createDrawingInfo as h,createDefaultTemplate as g}from"./clientSideDefaults.js";import{loadGeometryEngineForSimplify as I,createFeatureEditErrorResult as b,mixAttributes as F,createFeatureEditSuccessResult as j,simplify as _}from"./sourceUtils.js";import E from"../../../support/FieldsIndex.js";import{kebabDict as T}from"../../../support/fieldType.js";import{getFieldDefaultValue as x}from"../../../support/fieldUtils.js";const R=n,q={xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:n},D={hasAttachments:!1,capabilities:"query, editing, create, delete, update",useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsStatistics:!0,supportsPercentileStatistics:!0,supportsReturningGeometryCentroid:!0,supportsQueryWithDistance:!0,supportsDistinct:!0,supportsReturningQueryExtent:!0,supportsReturningGeometryProperties:!1,supportsHavingClause:!0,supportsOrderBy:!0,supportsPagination:!0,supportsQueryWithResultType:!1,supportsSqlExpression:!0,supportsDisjointSpatialRel:!0}};function O(e){return r(e)?null!=e.z:!!e.hasZ}function w(e){return r(e)?null!=e.m:!!e.hasM}class S{constructor(){this._queryEngine=null,this._nextObjectId=null}destroy(){this._queryEngine&&this._queryEngine&&this._queryEngine.destroy(),this._queryEngine=this._fieldsIndex=this._createDefaultAttributes=null}async load(t){const i=[],{features:s}=t,r=this._inferLayerProperties(s,t.fields),n=t.fields||[],a=null!=t.hasM?t.hasM:r.hasM,o=null!=t.hasZ?t.hasZ:r.hasZ,l=!t.spatialReference&&!r.spatialReference,y=l?R:t.spatialReference||r.spatialReference,I=l?q:null,b=t.geometryType||r.geometryType,F=!b;let j=t.objectIdField||r.objectIdField,_=t.timeInfo;if(!F&&(l&&i.push({name:"feature-layer:spatial-reference-not-found",message:"Spatial reference not provided or found in features. Defaults to WGS84"}),!b))throw new e("feature-layer:missing-property","geometryType not set and couldn't be inferred from the provided features");if(!j)throw new e("feature-layer:missing-property","objectIdField not set and couldn't be found in the provided fields");if(r.objectIdField&&j!==r.objectIdField&&(i.push({name:"feature-layer:duplicated-oid-field",message:`Provided objectIdField "${j}" doesn't match the field name "${r.objectIdField}", found in the provided fields`}),j=r.objectIdField),j&&!r.objectIdField){let e=null;n.some((t=>t.name===j&&(e=t,!0)))?(e.type="esriFieldTypeOID",e.editable=!1,e.nullable=!1):n.unshift({alias:j,name:j,type:"esriFieldTypeOID",editable:!1,nullable:!1})}for(const u of n){if(null==u.name&&(u.name=u.alias),null==u.alias&&(u.alias=u.name),!u.name)throw new e("feature-layer:invalid-field-name","field name is missing",{field:u});if(u.name===j&&(u.type="esriFieldTypeOID"),!T.jsonValues.includes(u.type))throw new e("feature-layer:invalid-field-type",`invalid type for field "${u.name}"`,{field:u})}const O={};for(const e of n)if("esriFieldTypeOID"!==e.type&&"esriFieldTypeGlobalID"!==e.type){const t=x(e);void 0!==t&&(O[e.name]=t)}if(this._fieldsIndex=new E(n),this._createDefaultAttributes=m(O,j),_){if(_.startTimeField){const e=this._fieldsIndex.get(_.startTimeField);e?(_.startTimeField=e.name,e.type="esriFieldTypeDate"):_.startTimeField=null}if(_.endTimeField){const e=this._fieldsIndex.get(_.endTimeField);e?(_.endTimeField=e.name,e.type="esriFieldTypeDate"):_.endTimeField=null}if(_.trackIdField){const e=this._fieldsIndex.get(_.trackIdField);e?_.trackIdField=e.name:(_.trackIdField=null,i.push({name:"feature-layer:invalid-timeInfo-trackIdField",message:"trackIdField is missing",details:{timeInfo:_}}))}_.startTimeField||_.endTimeField||(i.push({name:"feature-layer:invalid-timeInfo",message:"startTimeField and endTimeField are missing or invalid",details:{timeInfo:_}}),_=null)}const w={warnings:i,featureErrors:[],layerDefinition:{...D,drawingInfo:h(b),templates:g(O),extent:I,geometryType:b,objectIdField:j,fields:n,hasZ:!!o,hasM:!!a,timeInfo:_},assignedObjectIds:{}};if(this._queryEngine=new c({fields:n,geometryType:b,hasM:a,hasZ:o,objectIdField:j,spatialReference:y,featureStore:new p({geometryType:b,hasM:a,hasZ:o}),timeInfo:_,cacheSpatialQueries:!0}),!s||!s.length)return this._nextObjectId=u,w;const S=d(j,s);return this._nextObjectId=S+1,await f(s,y),this._loadInitialFeatures(w,s)}async applyEdits(e){const{spatialReference:t,geometryType:i}=this._queryEngine;return await Promise.all([I(t,i),f(e.adds,t),f(e.updates,t)]),this._applyEdits(e)}queryFeatures(e,t={}){return this._queryEngine.executeQuery(e,t.signal)}queryFeatureCount(e,t={}){return this._queryEngine.executeQueryForCount(e,t.signal)}queryObjectIds(e,t={}){return this._queryEngine.executeQueryForIds(e,t.signal)}queryExtent(e,t={}){return this._queryEngine.executeQueryForExtent(e,t.signal)}querySnapping(e,t={}){return this._queryEngine.executeQueryForSnapping(e,t.signal)}_inferLayerProperties(e,i){let r,n,a=null,o=null,l=null;for(const u of e){const e=u.geometry;if(!t(e)&&(a||(a=s(e)),o||(o=e.spatialReference),null==r&&(r=O(e)),null==n&&(n=w(e)),a&&o&&null!=r&&null!=n))break}if(i&&i.length){let e=null;i.some((t=>{const i="esriFieldTypeOID"===t.type,s=!t.type&&t.name&&"objectid"===t.name.toLowerCase();return e=t,i||s}))&&(l=e.name)}return{geometryType:a,spatialReference:o,objectIdField:l,hasM:n,hasZ:r}}_loadInitialFeatures(e,t){const{geometryType:r,hasM:n,hasZ:o,objectIdField:l,spatialReference:u,featureStore:d}=this._queryEngine,p=[];for(const a of t){if(null!=a.uid&&(e.assignedObjectIds[a.uid]=-1),a.geometry&&r!==s(a.geometry)){e.featureErrors.push(b("Incorrect geometry type."));continue}const t=this._createDefaultAttributes(),n=F(this._fieldsIndex,t,a.attributes,!0,e.warnings);n?e.featureErrors.push(n):(this._assignObjectId(t,a.attributes,!0),a.attributes=t,null!=a.uid&&(e.assignedObjectIds[a.uid]=a.attributes[l]),i(a.geometry)&&(a.geometry=y(a.geometry,a.geometry.spatialReference,u)),p.push(a))}if(d.addMany(a([],p,r,o,n,l)),e.layerDefinition.extent=this._queryEngine.fullExtent,e.layerDefinition.timeInfo){const{start:t,end:i}=this._queryEngine.timeExtent;e.layerDefinition.timeInfo.timeExtent=[t,i]}return e}_applyEdits(e){const{adds:t,updates:i,deletes:s}=e,r={addResults:[],deleteResults:[],updateResults:[],uidToObjectId:{}};if(t&&t.length&&this._applyAddEdits(r,t),i&&i.length&&this._applyUpdateEdits(r,i),s&&s.length){for(const e of s)r.deleteResults.push(j(e));this._queryEngine.featureStore.removeManyById(s)}return{fullExtent:this._queryEngine.fullExtent,featureEditResults:r}}_applyAddEdits(e,t){const{addResults:r}=e,{geometryType:n,hasM:o,hasZ:l,objectIdField:u,spatialReference:d,featureStore:p}=this._queryEngine,f=[];for(const a of t){if(a.geometry&&n!==s(a.geometry)){r.push(b("Incorrect geometry type."));continue}const t=this._createDefaultAttributes(),o=F(this._fieldsIndex,t,a.attributes);if(o)r.push(o);else{if(this._assignObjectId(t,a.attributes),a.attributes=t,null!=a.uid){const t=a.attributes[u];e.uidToObjectId[a.uid]=t}i(a.geometry)&&(a.geometry=y(_(a.geometry,d),a.geometry.spatialReference,d)),f.push(a),r.push(j(a.attributes[u]))}}p.addMany(a([],f,n,l,o,u))}_applyUpdateEdits({updateResults:e},t){const{geometryType:r,hasM:n,hasZ:a,objectIdField:u,spatialReference:d,featureStore:p}=this._queryEngine;for(const f of t){const{attributes:t,geometry:c}=f,m=t&&t[u];if(null==m){e.push(b(`Identifier field ${u} missing`));continue}if(!p.has(m)){e.push(b(`Feature with object id ${m} missing`));continue}const h=o(p.getFeature(m),r,a,n);if(i(c)){if(r!==s(c)){e.push(b("Incorrect geometry type."));continue}h.geometry=y(_(c,d),c.spatialReference,d)}if(t){const i=F(this._fieldsIndex,h.attributes,t);if(i){e.push(i);continue}}p.add(l(h,r,a,n,u)),e.push(j(m))}}_assignObjectId(e,t,i=!1){const s=this._queryEngine.objectIdField;i&&t&&isFinite(t[s])?e[s]=t[s]:e[s]=this._nextObjectId++}}export{S as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_parseInfo as e}from"../../../../core/number.js";import{parseRows as t}from"../csv/csv.js";function r(e){const t=e.map((e=>e.toLowerCase()));return{longitudeFieldName:e[t.indexOf(d.find((e=>t.includes(e))))],latitudeFieldName:e[t.indexOf(s.find((e=>t.includes(e))))]}}function n(e,r,n,l){const o=[],a=t(e,n,r),u=[];for(const t of a){if(10===u.length)break;u.push(t)}for(const t of n)if(t===l.longitudeFieldName||t===l.latitudeFieldName)o.push({name:t,type:"esriFieldTypeDouble",alias:t});else{const e=i(u.map((e=>e[t]))),r={name:t,type:null,alias:t};switch(e){case"integer":r.type="esriFieldTypeInteger";break;case"double":r.type="esriFieldTypeDouble";break;case"date":r.type="esriFieldTypeDate",r.length=36;break;default:r.type="esriFieldTypeString",r.length=255}o.push(r)}return o}function i(e){if(!e.length)return"string";const t=/[^+-.,0-9]/;return e.map((e=>{let r=!1;if(""!==e){if(t.test(e))r=!0;else{let t=o(e);if(!isNaN(t))return/[.,]/.test(e)||!Number.isInteger(t)||t>214783647||t<-214783648?"double":"integer";if(-1===e.indexOf("E"))r=!0;else{if(t=Number(e),!isNaN(t))return"double";if(-1===e.indexOf(","))r=!0;else{if(e=e.replace(",","."),t=Number(e),!isNaN(t))return"double";r=!0}}}if(r){if(!/^[-]?\d*[.,]?\d*$/.test(e)){return l(new Date(e),e)?"date":"string"}return"string"}return"string"}})).reduce(((e,t)=>void 0===e||e===t?t:"string"===e||"string"===t?"string":"double"===e||"double"===t?"double":void 0))}function l(e,t){if(!e||"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))return!1;let r=!0;if(!u&&/\d+\W*$/.test(t)){const e=t.match(/[a-zA-Z]{2,}/);if(e){let t=!1,n=0;for(;!t&&n<=e.length;)t=!a.test(e[n]),n++;r=!t}}return r}const o=function(){const t=e(),r=new RegExp("^"+t.regexp+"$"),n=new RegExp("["+t.group+"\\s\\xa0]","g"),i=t.factor;return function(e){const l=r.exec(e);if(t.factor=i,!l)return NaN;let o=l[1];if(!l[1]){if(!l[2])return NaN;o=l[2],t.factor*=-1}return o=o.replace(n,"").replace(t.decimal,"."),+o*t.factor}}(),a=/^((jan(uary)?)|(feb(ruary)?)|(mar(ch)?)|(apr(il)?)|(may)|(jun(e)?)|(jul(y)?)|(aug(ust)?)|(sep(tember)?)|(oct(ober)?)|(nov(ember)?)|(dec(ember)?)|(am)|(pm)|(gmt)|(utc))$/i,u=Number.isNaN(new Date("technology 10").getTime()),s=["lat","latitude","latitude83","latdecdeg","lat_dd","y","ycenter","point-y"],d=["lon","lng","long","longitude","longitude83","longdecdeg","long_dd","x","xcenter","point-x"];export{i as inferFieldType,n as inferFields,r as inferLocationInfo,l as isValidDate,o as parseNumber};
5
+ import{_parseInfo as e}from"../../../../core/number.js";import{parseRows as t}from"../csv/csv.js";function r(e){const t=e.map((e=>e.toLowerCase()));return{longitudeFieldName:e[t.indexOf(d.find((e=>t.includes(e))))],latitudeFieldName:e[t.indexOf(s.find((e=>t.includes(e))))]}}function n(e,r,n,l){const o=[],a=t(e,n,r),u=[];for(const t of a){if(10===u.length)break;u.push(t)}for(const t of n)if(t===l.longitudeFieldName||t===l.latitudeFieldName)o.push({name:t,type:"esriFieldTypeDouble",alias:t});else{const e=i(u.map((e=>e[t]))),r={name:t,type:null,alias:t};switch(e){case"integer":r.type="esriFieldTypeInteger";break;case"double":r.type="esriFieldTypeDouble";break;case"date":r.type="esriFieldTypeDate",r.length=36;break;default:r.type="esriFieldTypeString",r.length=255}o.push(r)}return o}function i(e){if(!e.length)return"string";const t=/[^+-.,0-9]/;return e.map((e=>{let r=!1;if(""!==e){if(t.test(e))r=!0;else{let t=o(e);if(!isNaN(t))return/[.,]/.test(e)||!Number.isInteger(t)||t>214783647||t<-214783648?"double":"integer";if(e.includes("E")){if(t=Number(e),!isNaN(t))return"double";if(e.includes(",")){if(e=e.replace(",","."),t=Number(e),!isNaN(t))return"double";r=!0}else r=!0}else r=!0}if(r){if(!/^[-]?\d*[.,]?\d*$/.test(e)){return l(new Date(e),e)?"date":"string"}return"string"}return"string"}})).reduce(((e,t)=>void 0===e||e===t?t:"string"===e||"string"===t?"string":"double"===e||"double"===t?"double":void 0))}function l(e,t){if(!e||"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))return!1;let r=!0;if(!u&&/\d+\W*$/.test(t)){const e=t.match(/[a-zA-Z]{2,}/);if(e){let t=!1,n=0;for(;!t&&n<=e.length;)t=!a.test(e[n]),n++;r=!t}}return r}const o=function(){const t=e(),r=new RegExp("^"+t.regexp+"$"),n=new RegExp("["+t.group+"\\s\\xa0]","g"),i=t.factor;return function(e){const l=r.exec(e);if(t.factor=i,!l)return NaN;let o=l[1];if(!l[1]){if(!l[2])return NaN;o=l[2],t.factor*=-1}return o=o.replace(n,"").replace(t.decimal,"."),+o*t.factor}}(),a=/^((jan(uary)?)|(feb(ruary)?)|(mar(ch)?)|(apr(il)?)|(may)|(jun(e)?)|(jul(y)?)|(aug(ust)?)|(sep(tember)?)|(oct(ober)?)|(nov(ember)?)|(dec(ember)?)|(am)|(pm)|(gmt)|(utc))$/i,u=Number.isNaN(new Date("technology 10").getTime()),s=["lat","latitude","latitude83","latdecdeg","lat_dd","y","ycenter","point-y"],d=["lon","lng","long","longitude","longitude83","longdecdeg","long_dd","x","xcenter","point-x"];export{i as inferFieldType,n as inferFields,r as inferLocationInfo,l as isValidDate,o as parseNumber};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{reader as o}from"../../core/accessorSupport/decorators/reader.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";import{serviceTileInfoProperty as i}from"../support/serviceTileInfoProperty.js";import{TilemapCache as p}from"../support/TilemapCache.js";import a from"../../geometry/SpatialReference.js";const s=s=>{let l=class extends s{constructor(){super(...arguments),this.copyright=null,this.minScale=0,this.maxScale=0,this.spatialReference=null,this.tileInfo=null,this.tilemapCache=null}readMinScale(e,r){return null!=r.minLOD&&null!=r.maxLOD?e:0}readMaxScale(e,r){return null!=r.minLOD&&null!=r.maxLOD?e:0}get supportsBlankTile(){return this.version>=10.2}readTilemapCache(e,r){return r.capabilities&&r.capabilities.indexOf("Tilemap")>-1?new p({layer:this}):null}};return e([r({json:{read:{source:"copyrightText"}}})],l.prototype,"copyright",void 0),e([r()],l.prototype,"minScale",void 0),e([o("service","minScale")],l.prototype,"readMinScale",null),e([r()],l.prototype,"maxScale",void 0),e([o("service","maxScale")],l.prototype,"readMaxScale",null),e([r({type:a})],l.prototype,"spatialReference",void 0),e([r({readOnly:!0})],l.prototype,"supportsBlankTile",null),e([r(i)],l.prototype,"tileInfo",void 0),e([r()],l.prototype,"tilemapCache",void 0),e([o("service","tilemapCache",["capabilities"])],l.prototype,"readTilemapCache",null),e([r()],l.prototype,"version",void 0),l=e([t("esri.layers.mixins.ArcGISCachedService")],l),l};export{s as ArcGISCachedService};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{reader as o}from"../../core/accessorSupport/decorators/reader.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";import{serviceTileInfoProperty as i}from"../support/serviceTileInfoProperty.js";import{TilemapCache as p}from"../support/TilemapCache.js";import a from"../../geometry/SpatialReference.js";const s=s=>{let l=class extends s{constructor(){super(...arguments),this.copyright=null,this.minScale=0,this.maxScale=0,this.spatialReference=null,this.tileInfo=null,this.tilemapCache=null}readMinScale(e,r){return null!=r.minLOD&&null!=r.maxLOD?e:0}readMaxScale(e,r){return null!=r.minLOD&&null!=r.maxLOD?e:0}get supportsBlankTile(){return this.version>=10.2}readTilemapCache(e,r){return r.capabilities&&r.capabilities.includes("Tilemap")?new p({layer:this}):null}};return e([r({json:{read:{source:"copyrightText"}}})],l.prototype,"copyright",void 0),e([r()],l.prototype,"minScale",void 0),e([o("service","minScale")],l.prototype,"readMinScale",null),e([r()],l.prototype,"maxScale",void 0),e([o("service","maxScale")],l.prototype,"readMaxScale",null),e([r({type:a})],l.prototype,"spatialReference",void 0),e([r({readOnly:!0})],l.prototype,"supportsBlankTile",null),e([r(i)],l.prototype,"tileInfo",void 0),e([r()],l.prototype,"tilemapCache",void 0),e([o("service","tilemapCache",["capabilities"])],l.prototype,"readTilemapCache",null),e([r()],l.prototype,"version",void 0),l=e([t("esri.layers.mixins.ArcGISCachedService")],l),l};export{s as ArcGISCachedService};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{read as r,rasterRendererTypes as i,websceneRasterRendererTypes as s}from"../../rasterRenderers.js";import n from"../../request.js";import a from"../../core/Error.js";import{strict as o}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import u from"../../core/Logger.js";import{isSome as p,isNone as c,unwrap as m}from"../../core/maybe.js";import{when as d}from"../../core/promiseUtils.js";import{urlToObject as h}from"../../core/urlUtils.js";import{aliasOf as f}from"../../core/accessorSupport/decorators/aliasOf.js";import{ensureClass as y,Integer as g,ensureNumber as R}from"../../core/accessorSupport/ensureType.js";import{property as v,ensureRange as x}from"../../core/accessorSupport/decorators/property.js";import{reader as b}from"../../core/accessorSupport/decorators/reader.js";import{subclass as S}from"../../core/accessorSupport/decorators/subclass.js";import{writer as I}from"../../core/accessorSupport/decorators/writer.js";import{opacity as _,url as w}from"../support/commonProperties.js";import F from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as O}from"../support/ExportImageServiceParameters.js";import D from"../support/Field.js";import P from"../support/FieldsIndex.js";import{isSupportedRendererType as T}from"../support/imageryRendererUtils.js";import j from"../support/MosaicRule.js";import N from"../support/PixelBlock.js";import{interpolationKebab as C,noDataInterpretationKebab as M}from"../support/rasterEnums.js";import J from"../support/RasterFunction.js";import q from"../support/RasterInfo.js";import V from"../support/RasterJobHandler.js";import{decode as A,getFormat as z}from"../support/rasterFormats/RasterCodec.js";import{uvComponentToVector as E}from"../support/rasterFunctions/vectorFieldUtils.js";import{getSupportedRendererTypes as Q,getDefaultBandCombination as U,createDefaultRenderer as H,normalizeRendererJSON as L}from"../../renderers/support/rasterRendererHelper.js";import k from"../../renderers/support/RasterSymbolizer.js";import{computeAngles as B,computePixelSpaceLocations as G,computeHistograms as W,computeStatisticsHistograms as X,getImageSpatialReferenceQueryParameter as Y,getSamples as K,identify as $}from"../../rest/imageService.js";import"../../core/unitUtils.js";import"../../kernel.js";import"../../rest/query/support/AttachmentInfo.js";import"../../rest/support/AttachmentQuery.js";import{executeForCount as Z}from"../../rest/query/executeForCount.js";import ee from"../../geometry/Extent.js";import"../../geometry/Geometry.js";import"../../geometry/Multipoint.js";import te from"../../geometry/Point.js";import re from"../../geometry/Polygon.js";import"../../geometry/Polyline.js";import"../../geometry/support/normalizeUtils.js";import"../../core/pbf.js";import"../../geometry/support/spatialReferenceUtils.js";import ie from"../../rest/support/Query.js";import{executeForIds as se}from"../../rest/query/executeForIds.js";import{executeQueryJSON as ne}from"../../rest/query/executeQueryJSON.js";import"../../core/has.js";import"../graphics/featureConversionUtils.js";import ae from"../../rest/support/FeatureSet.js";import"../../rest/support/RelationshipQuery.js";import"../../rest/support/TopFeaturesQuery.js";import oe from"../../rest/support/ImageAngleParameters.js";import le from"../../rest/support/ImageHistogramParameters.js";import ue from"../../rest/support/ImageIdentifyParameters.js";import pe from"../../rest/support/ImagePixelLocationParameters.js";import ce from"../../rest/support/ImageSampleParameters.js";import{createStreamlinesMesh as me}from"../../views/2d/engine/flow/dataUtils.js";import de from"../../geometry/SpatialReference.js";const he=u.getLogger("esri.layers.mixins.ArcGISImageService"),fe=o()({U1:"u1",U2:"u2",U4:"u4",U8:"u8",S8:"s8",U16:"u16",S16:"s16",U32:"u32",S32:"s32",F32:"f32",F64:"f64",C64:"c64",C128:"c128",UNKNOWN:"unknown"}),ye=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),ge=x(R,{min:0,max:255});function Re(e){if(!e)return null;const t=JSON.stringify(e).match(/"rasterFunction":"(.*?")/gi),r=null==t?void 0:t.map((e=>e.replace('"rasterFunction":"',"").replace('"',"")));return r?r.join("/"):null}const ve=o=>{let u=class extends o{constructor(){super(...arguments),this._functionRasterInfos={},this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this._defaultServiceMosaicRule=null,this._serviceSourceType=null,this._serviceSupportsMosaicRule=null,this.rasterAttributeTableFieldPrefix="Raster.",this.adjustAspectRatio=null,this.bandCount=null,this.bandIds=void 0,this.capabilities=null,this.compressionQuality=void 0,this.compressionTolerance=.01,this.copyright=null,this.definitionExpression=null,this.exportImageServiceParameters=null,this.rasterInfo=null,this.fields=null,this.fullExtent=null,this.hasMultidimensions=!1,this.imageMaxHeight=4100,this.imageMaxWidth=4100,this.interpolation=void 0,this.minScale=0,this.maxScale=0,this.multidimensionalInfo=null,this.noData=null,this.noDataInterpretation=void 0,this.objectIdField=null,this.geometryType="polygon",this.typeIdField=null,this.types=[],this.pixelSizeX=null,this.pixelSizeY=null,this.pixelFilter=null,this.raster=void 0,this.viewId=void 0,this.symbolizer=null,this.rasterAttributeTable=null,this.rasterFunctionInfos=null,this.serviceDataType=null,this.spatialReference=null,this.pixelType=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.url=null,this.version=void 0}initialize(){this._set("exportImageServiceParameters",new O({layer:this}))}readDefaultServiceMosaicRule(e,t){return this._serviceSupportsMosaicRule?j.fromJSON(t):null}readServiceSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}readServiceSupportsMosaicRule(e,t){return this._isMosaicRuleSupported(t)}get rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.length<1||p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.forEach((t=>{e.set(t.name.toLowerCase().replace(/ /gi,"_"),t.name)})),e}readBandIds(e,t){if(Array.isArray(e)&&e.length>0&&e.every((e=>"number"==typeof e)))return e}readCapabilities(e,t){return this._readCapabilities(t)}writeCompressionQuality(e,t,r){null!=e&&"lerc"!==this.format&&(t[r]=e)}writeCompressionTolerance(e,t,r){"lerc"===this.format&&null!=e&&(t[r]=e)}get fieldsIndex(){return this.fields?new P(this.fields):null}set format(e){e&&ye.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t&&t.mosaicMethod&&(t=j.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const r=e||t.mosaicRule;return r?j.fromJSON(r):this._isMosaicRuleSupported(t)?j.fromJSON(t):null}writeMosaicRule(e,t,r){let i=this.mosaicRule;const s=this.definitionExpression;i?s&&s!==i.where&&(i=i.clone(),i.where=s):s&&(i=new j({where:s})),this._isValidCustomizedMosaicRule(i)&&(t[r]=i.toJSON())}writeNoData(e,t,r){null!=e&&"number"==typeof e&&(t[r]=ge(e))}readObjectIdField(e,t){if(!e){const r=t.fields.filter((e=>"esriFieldTypeOID"===e.type||"oid"===e.type));e=r&&r[0]&&r[0].name}return e}get parsedUrl(){return this.url?h(this.url):null}set renderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("renderer",e)}readRenderer(e,t,i){var s,n;const a=null==t||null==(s=t.layerDefinition)||null==(n=s.drawingInfo)?void 0:n.renderer,o=r(a,i);return null==o?null:("vector-field"===o.type&&t.symbolTileSize&&!a.symbolTileSize&&(o.symbolTileSize=t.symbolTileSize),T(o)||he.warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),o)}writeRenderer(e,t,r){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this.rasterAttributeTableFieldPrefix||"Raster.",t=new D({name:"Raster.ItemPixelValue",alias:"Item Pixel Value",domain:null,editable:!1,length:50,type:"string"}),r=new D({name:"Raster.ServicePixelValue",alias:"Service Pixel Value",domain:null,editable:!1,length:50,type:"string"}),i=new D({name:"Raster.ServicePixelValue.Raw",alias:"Raw Service Pixel Value",domain:null,editable:!1,length:50,type:"string"});let s=this.fields?l(this.fields):[];s.push(r),this.capabilities.operations.supportsQuery&&this.fields&&this.fields.length>0&&s.push(t),this.version>=10.4&&p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.some((e=>"none"===e.name.toLowerCase()))&&s.push(i),p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.filter((e=>"none"!==e.name.toLowerCase())).forEach((e=>{s.push(new D({name:"Raster.ServicePixelValue."+e.name,alias:e.name,domain:null,editable:!1,length:50,type:"string"}))})),null==this.pixelFilter||"esriImageServiceDataTypeVector-UV"!==this.serviceDataType&&"esriImageServiceDataTypeVector-MagDir"!==this.serviceDataType||(s.push(new D({name:"Raster.Magnitude",alias:"Magnitude",domain:null,editable:!1,type:"double"})),s.push(new D({name:"Raster.Direction",alias:"Direction",domain:null,editable:!1,type:"double"})));const n=this.rasterInfo.attributeTable&&this.rasterInfo.attributeTable.fields||null;if(n&&n.length>0){const t=n.filter((e=>"esriFieldTypeOID"!==e.type&&"value"!==e.name.toLowerCase())).map((t=>{const r=l(t);return r.name=e+t.name,r}));s=s.concat(t)}return s}set renderingRule(e){let t=e;t&&t.rasterFunction&&(t=J.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("renderingRule",t)}readRenderingRule(e,t){const r=t.rasterFunctionInfos;return t.renderingRule||r&&r.length&&"None"!==r[0].name?this._isRFTJson(t.renderingRule)?J.fromJSON({rasterFunctionDefinition:t.renderingRule}):J.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}writeRenderingRule(e,t,r){const i=e.toJSON();i.rasterFunctionDefinition?t[r]=i.rasterFunctionDefinition:t[r]=i}readSpatialReference(e,t){const r=e||t.extent.spatialReference;return r?de.fromJSON(r):null}readPixelType(e){return fe.fromJSON(e)||e}writePixelType(e,t,r){(c(this.serviceRasterInfo)||this.pixelType!==this.serviceRasterInfo.pixelType)&&(t[r]=fe.toJSON(e))}readVersion(e,t){let r=t.currentVersion;return r||(r=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),r}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let r=e;if(!this._isPicture()&&this.renderer&&this.symbolizer&&!this.pixelFilter){const i=JSON.stringify(this._cachedRendererJson)!==JSON.stringify(this.renderer.toJSON()),s=this._rasterJobHandler.instance,{bandIds:n}=this;if(s){i&&(this.symbolizer.bind(),await s.updateSymbolizer(this.symbolizer,t),this._cachedRendererJson=this.renderer.toJSON());const a=await s.symbolize({bandIds:n,...e},t);r={extent:e.extent,pixelBlock:a}}else r={extent:e.extent,pixelBlock:this.symbolizer.symbolize({bandIds:n,...e})}}return r}destroy(){this._shutdownJobHandler()}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}async computeAngles(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsComputeAngles)throw new a("imagery-layer:compute-angles","this operation is not supported on the input image service");return e=y(oe,e).clone(),B(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsComputePixelLocation)throw new a("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=y(pe,e).clone(),G(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsComputeHistograms)throw new a("imagery-layer:compute-histograms","this operation is not supported on the input image service");e=y(le,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;return s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule&&(e.mosaicRule=i),r&&null==e.raster&&(e.raster=r),W(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsComputeStatisticsHistograms)throw new a("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");e=y(le,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;return s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule&&(e.mosaicRule=i),r&&null==e.raster&&(e.raster=r),X(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return p(t)?t.get(e):void 0}getFieldDomain(e,t){const r=this.getField(e);return r?r.domain:null}fetchImage(e,t,r,i={}){if(null==e||null==t||null==r)return Promise.reject(new a("imagery-layer:fetch-image","Insufficient parameters for requesting an image. A valid extent, width and height values are required."));const s=this.renderer||this.symbolizer?this.generateRasterInfo(this.renderingRule,{signal:i.signal}):null;return d(s).then((s=>{s&&(this.rasterInfo=s);const n={imageServiceParameters:this.getExportImageServiceParameters(e,t,r,i.timeExtent),imageProps:{extent:e,width:t,height:r,format:this.format},requestAsImageElement:i.requestAsImageElement&&!this.pixelFilter||!1,signal:i.signal};return this._requestArrayBuffer(n)}))}fetchKeyProperties(e){return n(this.parsedUrl.path+"/keyProperties",{query:this._getQueryParams({renderingRule:this.version>=10.3?null==e?void 0:e.renderingRule:null})}).then((e=>e.data))}fetchRasterAttributeTable(e){return this.version<10.1?Promise.reject(new a("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):n(this.parsedUrl.path+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?null==e?void 0:e.renderingRule:null})}).then((e=>ae.fromJSON(e.data)))}async getCatalogItemRasterInfo(e,t){const r=n(this.parsedUrl.path+"/"+e+"/info",{query:this._getQueryParams(),...t}).then((e=>e.data)),i=n(this.parsedUrl.path+"/"+e+"/info/keyProperties",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>{})),s=await Promise.all([r,i]);if(!s[0])return;const a=ee.fromJSON(s[0].extent),o=s[0].statistics?s[0].statistics.map((e=>({min:e[0],max:e[1],avg:e[2],stddev:e[3]}))):null;return new q({bandCount:s[0].bandCount,extent:a,spatialReference:a.sr,pixelSize:new te({x:s[0].pixelSizeX,y:s[0].pixelSizeY,spatialReference:a.sr}),pixelType:s[0].pixelType.toLowerCase(),statistics:o,histograms:s[0].histograms,keyProperties:s[1]||{}})}async getCatalogItemICSInfo(e,t){const{data:r}=await n(this.parsedUrl.path+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),i=r&&r.ics;if(!i)return;let s=null;try{s=(await n(this.parsedUrl.path+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!s||!s.spatialReference)return{ics:i,icsToPixelTransform:null,icsExtent:null,northDirection:null};const a=this.version>=10.7?n(this.parsedUrl.path+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>({}))):{},o=s.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[s]}),inSR:o.wkid||JSON.stringify(o),outSR:"0:"+e},u=n(this.parsedUrl.path+"/project",{query:this._getQueryParams(l),...t}).then((e=>e.data)).catch((()=>({}))),p=5,c=(s.xmin+s.xmax)/2,m=(s.ymax-s.ymin)/(p+1),d=s.ymin+m,h=[];for(let n=0;n<p;n++)h.push({x:c,y:d+m*n});const f={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:h}),inSR:o.wkid||JSON.stringify(o),outSR:"0:"+e},y=n(this.parsedUrl.path+"/project",{query:this._getQueryParams(f),...t}).then((e=>e.data)).catch((()=>({}))),g=await Promise.all([a,u,y]);let R=g[0].ipxf;if(null==R){var v,x,b;const e=null==(v=i.geodataXform)?void 0:v.xf_0;"topup"===(null==e||null==(x=e.name)?void 0:x.toLowerCase())&&6===(null==e||null==(b=e.coefficients)?void 0:b.length)&&(R={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const S=ee.fromJSON(g[1]&&g[1].geometries&&g[1].geometries[0]);S&&(S.spatialReference=new de({wkid:0,imageCoordinateSystem:i}));const I=g[2].geometries?g[2].geometries.filter((e=>null!=e&&null!=e.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y)):[],_=I.length;if(_<3)return{ics:i,icsToPixelTransform:R,icsExtent:S,northDirection:null};let w=0,F=0,O=0,D=0;for(let n=0;n<_;n++)w+=I[n].x,F+=I[n].y,O+=I[n].x*I[n].x,D+=I[n].x*I[n].y;const P=(_*D-w*F)/(_*O-w*w);let T=0;const j=I[p-1].x>I[0].x,N=I[p-1].y>I[0].y;return P===1/0?T=N?90:270:0===P?T=j?0:180:P>0?T=j?180*Math.atan(P)/Math.PI:180*Math.atan(P)/Math.PI+180:P<0&&(T=N?180+180*Math.atan(P)/Math.PI:360+180*Math.atan(P)/Math.PI),{ics:i,icsToPixelTransform:R,icsExtent:S,northDirection:T}}async generateRasterInfo(e,t){var r;if((!e||"none"===(null==e||null==(r=e.functionName)?void 0:r.toLowerCase())||this._isVectorFieldResampleFunction(e))&&p(this.serviceRasterInfo))return this.serviceRasterInfo;const i=Re(e);if(this._functionRasterInfos[i])return this._functionRasterInfos[i];const s=this._generateRasterInfo(e,t);this._functionRasterInfos[i]=s;try{return await s}catch{return this._functionRasterInfos[i]=null,null}}getExportImageServiceParameters(e,t,r,i){var s;e=e.clone().shiftCentralMeridian();const n=Y(e.spatialReference,this.parsedUrl.path);p(this.serviceRasterInfo)&&this.pixelType!==this.serviceRasterInfo.pixelType&&(this.exportImageServiceParameters.pixelType=this.pixelType);const a=this.exportImageServiceParameters.toJSON(),{bandIds:o,noData:l}=a;let{renderingRule:u}=a;const c=null==(s=this.renderingRule)?void 0:s.rasterFunctionDefinition,m=!this.renderer||"raster-stretch"===this.renderer.type;if(null!=o&&o.length&&this._hasRenderingRule(this.renderingRule)&&!c&&m){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:o}};if("Stretch"===u.rasterFunction)e.rasterFunctionArguments.Raster=u.rasterFunctionArguments.Raster,u.rasterFunctionArguments.Raster=e;else if("Colormap"===u.rasterFunction){const t=u.rasterFunctionArguments.Raster;"Stretch"===(null==t?void 0:t.rasterFunction)?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,u.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=u,u=e;a.bandIds=void 0}else a.bandIds=null==o?void 0:o.join(",");l instanceof Array&&l.length>0&&(a.noData=l.join(","));const d=this._serviceSupportsMosaicRule?this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,i):null;a.mosaicRule=d&&JSON.stringify(d),a.renderingRule=this._getRenderingRuleString(J.fromJSON(u));const h={};if(i){const{start:e,end:t}=i.toJSON();e&&t&&e===t?h.time=""+e:null==e&&null==t||(h.time=`${null==e?"null":e},${null==t?"null":t}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:n,imageSR:n,size:t+","+r,...a,...h}}async getSamples(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsGetSamples)throw new a("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=y(ce,e).clone();const{raster:r}=this;return r&&null==e.raster&&(e.raster=r),K(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsIdentify)throw new a("imagery-layer:query-rasters","query operation is not supported on the input image service");e=y(ue,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;if(s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule){const t=this._combineMosaicRuleWithTimeExtent(i,e.timeExtent);e.mosaicRule=m(t)}return r&&null==e.raster&&(e.raster=r),$(this.url,e,this._getRequestOptions(t))}createQuery(){const e=new ie;return e.outFields=["*"],e.returnGeometry=!0,e.where=this.definitionExpression||"1=1",e}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ne(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),se(this.url,e,t)}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Z(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new a("imagery-layer: query-visible-rasters","missing query parameter");const{pixelSize:r,returnDomainValues:i,returnTopmostRaster:s,showNoDataRecords:n}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let o=!1,l=null,u=null;const m="raster.servicepixelvalue",d=this.rasterFunctionNamesIndex;if(p(e.outFields)&&(o=e.outFields.some((e=>-1===e.toLowerCase().indexOf(m))),this.version>=10.4)){const t=e.outFields.filter((e=>e.toLowerCase().indexOf(m)>-1&&e.length>m.length)).map((e=>{const t=e.slice(m.length+1);return[this._updateRenderingRulesFunctionName(t,d),t]}));l=t.map((e=>new J({functionName:e[0]}))),u=t.map((e=>e[1])),0===l.length?this.renderingRule?(l.push(this.renderingRule),u.push(this.renderingRule.functionName)):l=null:this.renderingRule&&!l.some((e=>e.functionName===this.renderingRule.functionName))&&(l.push(this.renderingRule),u.push(this.renderingRule.functionName))}const h=c(e.outSpatialReference)||e.outSpatialReference.equals(this.spatialReference),f=e.timeExtent||this.timeExtent,y=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,f),g=this._getQueryParams({geometry:e.geometry,timeExtent:f,mosaicRule:y,renderingRule:this.version<10.4?this.renderingRule:null,renderingRules:l,pixelSize:r,returnCatalogItems:o,returnGeometry:h,raster:this.raster,maxItemCount:s?1:null});delete g.f;const R=new ue(g);try{var v,x;await this.generateRasterInfo(this.renderingRule);const r=await $(this.url,R,{signal:null==t?void 0:t.signal,query:{...this.customParameters}}),s=e.outFields,a=r.value.toLowerCase().indexOf("nodata")>-1;if(!(o&&!h&&(null==r||null==(v=r.catalogItems)?void 0:v.features.length)&&(n||!a)))return this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s});const l=this.objectIdField||"ObjectId",c=r.catalogItems.features,m=c.map((e=>{var t;return null==(t=e.attributes)?void 0:t[l]})),d=new ie({objectIds:m,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[l]}),f=await this.queryRasters(d);return null!=f&&null!=(x=f.features)&&x.length&&f.features.forEach((t=>{c.forEach((r=>{r.attributes[l]===t.attributes[l]&&(r.geometry=new re(t.geometry),p(e.outSpatialReference)&&(r.geometry.spatialReference=e.outSpatialReference))}))})),this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s})}catch{throw new a("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const r=n(this.parsedUrl.path+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>{var t;return null==(t=e.data)?void 0:t.statistics})),i=n(this.parsedUrl.path+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>{var t;return null==(t=e.data)?void 0:t.histograms})),s=await Promise.all([r,i]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[1]||null}}async createStreamlinesMesh(e,t){const r=this._rasterJobHandler.instance;return r?r.createStreamlinesMesh(e,t):me(e.rendererSettings,e.flowData,p(t.signal)?t.signal:(new AbortController).signal)}async _fetchService(e){await this._fetchServiceInfo(e),p(this.serviceRasterInfo)&&!this.rasterInfo&&(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,r=p(this.serviceRasterInfo)?Promise.resolve(this.serviceRasterInfo):this._fetchAuxiliaryRasterInfo({serviceInfo:t,signal:e}).then((e=>(this._set("serviceRasterInfo",e),e))),i=this._hasRenderingRule(this.renderingRule)?this.generateRasterInfo(this.renderingRule,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([r,i,s]).then((e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.renderer&&!this._isSupportedRenderer(this.renderer)&&(this._set("renderer",null),he.warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("renderer",this._configRenderer(this.renderer)),this.watch("renderingRule",(e=>{(this.renderer||this.symbolizer||this.popupEnabled&&this.popupTemplate)&&this.generateRasterInfo(e).then((e=>{e&&(this.rasterInfo=e)}))}));const t=p(this.serviceRasterInfo)&&this.serviceRasterInfo.multidimensionalInfo;t&&this._updateMultidimensionalDefinition(t)}))}_combineMosaicRuleWithTimeExtent(e,t){const r=this.timeInfo;if(c(e)||c(this.multidimensionalInfo)||c(t)||c(null==r?void 0:r.startField))return e;const{startField:i}=r;var s;if(e=e.clone(),"mosaic-dataset"===this._serviceSourceType)return e.multidimensionalDefinition=null==(s=e.multidimensionalDefinition)?void 0:s.filter((e=>e.dimensionName!==i)),this._cleanupMultidimensionalDefinition(e);e.multidimensionalDefinition=e.multidimensionalDefinition||[];const n=e.multidimensionalDefinition.filter((e=>e.dimensionName===i)),a=p(t.start)?t.start.getTime():null,o=p(t.end)?t.end.getTime():null,l=null==a||null==o||a===o,u=l?[a||o]:[[a,o]],m=this.version>=10.8;if(n.length)n.forEach((e=>{e.dimensionName===i&&(m?(e.dimensionName=null,e.isSlice=null,e.values=null):(e.isSlice=l,e.values=u))}));else if(!m){const t=e.multidimensionalDefinition.filter((e=>null!=e.variableName&&null==e.dimensionName));t.length?t.forEach((e=>{e.dimensionName=i,e.isSlice=l,e.values=u})):e.multidimensionalDefinition.push(new F({variableName:"",dimensionName:i,isSlice:l,values:u}))}return this._cleanupMultidimensionalDefinition(e)}_cleanupMultidimensionalDefinition(e){return c(e)?null:(e.multidimensionalDefinition&&(e.multidimensionalDefinition=e.multidimensionalDefinition.filter((e=>!(!e.variableName&&!e.dimensionName))),0===e.multidimensionalDefinition.length&&(e.multidimensionalDefinition=null)),"mosaic-dataset"!==this._serviceSourceType&&null==e.multidimensionalDefinition?null:e)}async _prepareForQuery(e,t){var r;if(await this._fetchCapabilities(null==(r=t)?void 0:r.signal),!this.capabilities.operations.supportsQuery)throw new a("imagery-layer:query-rasters","query operation is not supported on the input image service");return e=p(e)?y(ie,e):this.createQuery(),t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:e,requestOptions:t}}async _initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new V;this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{this._rasterJobHandler.instance=e}),(()=>null)),await this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0}_isSupportedRenderer(e){const{rasterInfo:t,renderingRule:r}=this;return"unique-value"===e.type&&this._hasRenderingRule(r)&&1===t.bandCount&&["u8","s8"].includes(t.pixelType)||Q(this.rasterInfo).includes(this.renderer.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){var t;let r=this.sourceJSON;if(!r){const{data:t,ssl:i}=await n(this.parsedUrl.path,{query:this._getQueryParams(),signal:e});r=t,this.sourceJSON=r,i&&(this.url=this.url.replace(/^http:/i,"https:"))}if((null==(t=r.capabilities)?void 0:t.toLowerCase().split(",").map((e=>e.trim())).indexOf("tilesonly"))>-1)throw new a("imagery-layer:fetch-service-info","use ImageryTileLayer to open tiles-only image services");this.read(r,{origin:"service",url:this.parsedUrl})}_isMosaicDataset(e){var t;return e.serviceSourceType?"esriImageServiceSourceTypeMosaicDataset"===e.serviceSourceType:(null==(t=e.fields)?void 0:t.length)>0}_isMosaicRuleSupported(e){var t;if(!e)return!1;const r=this._isMosaicDataset(e),i=e.currentVersion>=10.71&&e.hasMultidimensions&&e.timeInfo&&!(e.objectIdField&&(null==(t=e.fields)?void 0:t.length)>1);return r||i}_isVectorFieldResampleFunction(e){if(c(e))return!1;const{functionName:t,functionArguments:r}=e,i="resample"===(null==t?void 0:t.toLowerCase()),s=(null==r?void 0:r.ResampleType)||(null==r?void 0:r.resampleType);return i&&(7===s||10===s)}_isPicture(){return!this.format||this.format.indexOf("jpg")>-1||this.format.indexOf("png")>-1}_configRenderer(e){if(!this._isPicture()&&!this.pixelFilter){if(!this.bandIds&&this.rasterInfo.bandCount>=3){const e=U(this.rasterInfo);!e||3===this.rasterInfo.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}var t,r;if(!e)e=H(this.rasterInfo,{bandIds:this.bandIds,variableName:this.renderingRule?null:null==(t=this.mosaicRule)||null==(r=t.multidimensionalDefinition)?void 0:r[0].variableName});const i=L(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=i,this.symbolizer.rasterInfo=this.rasterInfo):this.symbolizer=new k({rendererJSON:i,rasterInfo:this.rasterInfo}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:p(e.pixelBlock)&&e.pixelBlock.clone()}}_getQueryParams(e){p(null==e?void 0:e.renderingRule)&&"string"!=typeof e.renderingRule&&(e.renderingRule=this._getRenderingRuleString(e.renderingRule));const{raster:t,viewId:r}=this;return{raster:t,viewId:r,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...null==e?void 0:e.query,...this.customParameters}}}_decodePixelBlock(e,t,r){return this._rasterJobHandler.instance?this._rasterJobHandler.instance.decode({data:e,options:t}):A(e,t,r)}async _fetchMultidimensionalInfo(e){var t;const r=await n(this.parsedUrl.path+"/multidimensionalInfo",{query:this._getQueryParams(),signal:e}).then((e=>{var t;return null==(t=e.data)?void 0:t.multidimensionalInfo}));return null!=(t=r.variables)&&t.length&&r.variables.forEach((e=>{var t;null!=(t=e.statistics)&&t.length&&e.statistics.forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation}))})),r}async _getRasterFunctionInfos(e){const t=this.sourceJSON.rasterFunctionInfos;if(this.serviceRasterInfo)return t;if(t&&this.version>=10.3){var r;if(1===t.length&&"none"===t[0].name.toLowerCase())return t;return null==(r=(await n(this.parsedUrl.path+"/rasterFunctionInfos",{query:this._getQueryParams(),signal:e})).data)?void 0:r.rasterFunctionInfos}return null}async _fetchAuxiliaryRasterInfo(e){const t=e&&e.serviceInfo;if(!t)return Promise.reject(new a("imagery-layer:fetch-metadata","valid serviceInfo is required"));const r=e.signal,i=!!(t.hasRasterAttributeTable&&this.version>=10.1)&&n(this.parsedUrl.path+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.1?null==e?void 0:e.renderingRule:null}),signal:r}).then((e=>ae.fromJSON(e.data))).catch((()=>null)),s=!!(t.hasColormap&&this.version>=10.1)&&n(this.parsedUrl.path+"/colormap",{query:this._getQueryParams({renderingRule:this.version>=10.6?null==e?void 0:e.renderingRule:null}),signal:r}).then((e=>{var t;return null==(t=e.data)?void 0:t.colormap})),o=!!(t.hasHistograms&&this.version>=10.1)&&n(this.parsedUrl.path+"/histograms",{query:this._getQueryParams({renderingRule:this.version>=10.1?null==e?void 0:e.renderingRule:null}),signal:r}).then((e=>{var t;return null==(t=e.data)?void 0:t.histograms})),l=this.version>=10.3&&n(this.parsedUrl.path+"/keyProperties",{query:this._getQueryParams({renderingRule:null==e?void 0:e.renderingRule}),signal:r}).then((e=>e.data)).catch((()=>{})),u=!!(t.hasMultidimensions&&this.version>=10.3)&&this._fetchMultidimensionalInfo(),p=await Promise.all([i,s,o,l,u]);let c=null;if(t.minValues&&t.minValues.length===t.bandCount){c=[];for(let e=0;e<t.minValues.length;e++)c.push({min:t.minValues[e],max:t.maxValues[e],avg:t.meanValues[e],stddev:t.stdvValues[e]})}const m=Math.ceil((t.extent.xmax-t.extent.xmin)/t.pixelSizeX-.1),d=Math.ceil((t.extent.ymax-t.extent.ymin)/t.pixelSizeY-.1),h=de.fromJSON(t.spatialReference||t.extent.spatialReference);return new q({width:m,height:d,bandCount:t.bandCount,extent:ee.fromJSON(t.extent),spatialReference:h,pixelSize:new te({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:h}),pixelType:t.pixelType.toLowerCase(),statistics:c,attributeTable:p[0]||null,colormap:p[1]||null,histograms:p[2]||null,keyProperties:p[3]||{},multidimensionalInfo:p[4]||null})}async _requestArrayBuffer(e){var t;const{imageProps:r,requestAsImageElement:i,signal:s}=e;if(i&&!this.pixelFilter&&(null==(t=r.format)?void 0:t.indexOf("png"))>-1){return{imageElement:(await n(this.parsedUrl.path+"/exportImage",{responseType:"image",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:s})).data,params:r}}const o=this._initJobHandler(),l=n(this.parsedUrl.path+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:s}),u=(await Promise.all([l,o]))[0].data,p=r.format||"jpgpng";let c=p;if("bsq"!==c&&"bip"!==c&&(c=z(u)),!c)throw new a("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(u)));const m={signal:s},d="gif"===p||"bmp"===p||p.indexOf("png")>-1&&("png"===c||"jpg"===c)?A(u,{useCanvas:!0,...r},m):this._decodePixelBlock(u,{width:r.width,height:r.height,planes:null,pixelType:null,noDataValue:null,format:p},m);return{pixelData:{pixelBlock:await d,extent:r.extent},params:r}}async _generateRasterInfo(e,t){const{data:r}=await n(this.parsedUrl.path,{query:this._getQueryParams({renderingRule:e}),...t});return await this._fetchAuxiliaryRasterInfo({serviceInfo:r,renderingRule:e,...t})}_isValidCustomizedMosaicRule(e){var t;return e&&JSON.stringify(e.toJSON())!==JSON.stringify(null==(t=this._defaultServiceMosaicRule)?void 0:t.toJSON())}_updateMultidimensionalDefinition(e){if(this._isValidCustomizedMosaicRule(this.mosaicRule))return;const t=e.variables[0].dimensions,r="",i=[];for(const s in t)if(t.hasOwnProperty(s)){const e=t[s],n=e.extent;let a=!0,o=[n[0]];e.hasRanges&&!0===e.hasRanges?(a=!1,o=[e.values[0]]):"stdz"===e.name.toLowerCase()&&Math.abs(n[1])<=Math.abs(n[0])&&(o=[n[1]]),i.push(new F({variableName:r,dimensionName:t[s].name,isSlice:a,values:o}))}if(i.length>0){this.mosaicRule=this.mosaicRule||new j;const e=this.mosaicRule.multidimensionalDefinition;(!e||e&&e.length<=0)&&(this.mosaicRule.multidimensionalDefinition=i)}}_formatAttributeValue(e,t){if("string"==typeof e){const r=this.popupTemplate&&this.popupTemplate.fieldInfos,i=this._getFieldInfo(r,t),s=i&&i.format;if(s){let t,r;return e.trim().indexOf(",")>-1?(t=",",r=t+" ",this._formatDelimitedString(e,t,r,s)):e.trim().indexOf(";")>-1?(t=";",r=t+" ",this._formatDelimitedString(e,t,r,s)):e.trim().indexOf(" ")>-1?(t=r=" ",this._formatDelimitedString(e,t,r,s)):this._formatNumberFromString(e,s)}}return e}_getFieldInfo(e,t){if(!e||!e.length||!t)return;const r=t.toLowerCase();let i;return e.some((e=>!(!e.fieldName||e.fieldName.toLowerCase()!==r&&e.fieldName.toLowerCase()!==r.replace(/ /g,"_"))&&(i=e,!0))),i}_formatDelimitedString(e,t,r,i){return e&&t&&r&&i?e.trim().split(t).map((e=>this._formatNumberFromString(e,i))).join(r):e}_formatNumberFromString(e,t){if(!e||!t)return e;const r=Number(e);return isNaN(r)?e:t.format(r)}_processVisibleRastersResponse(e,r){r=r||{};const i=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:a,templateFields:o}=r,l=e.processedValues;let u=e.catalogItems&&e.catalogItems.features,c=e.properties&&e.properties.Values&&e.properties.Values.map((e=>e.replace(/ /gi,", ")))||[];const m=this.objectIdField||"ObjectId",d="string"==typeof i&&i.toLowerCase().indexOf("nodata")>-1,h=[];if(i&&!u&&!d){const e={};e[m]=0;c=[i],u=[new t(this.fullExtent,null,e)]}if(!u)return[];let f,y,g;this._updateResponseFieldNames(u,o),d&&!n&&(u=[]);for(let t=0;t<u.length;t++){if(f=u[t],null!=i){if(y=c[t],g=this.renderingRule&&l&&l.length>0&&s&&s.length>0&&s.indexOf(this.renderingRule.functionName)>-1?l[s.indexOf(this.renderingRule.functionName)]:i,"nodata"===y.toLowerCase()&&!n)continue;const e="Raster.ItemPixelValue",r="Raster.ServicePixelValue";f.attributes[e]=this._formatAttributeValue(y,e),f.attributes[r]=this._formatAttributeValue(g,r),this._updateFeatureWithMagDirValues(f,y);const a=this.fields&&this.fields.length>0;let o=this.renderingRule&&p(this.serviceRasterInfo)&&this.serviceRasterInfo.attributeTable?a?y:i:g;this.renderingRule||(o=a?y:i),this._updateFeatureWithRasterAttributeTableValues(f,o)}if(f.sourceLayer=f.layer=this,a&&this._updateFeatureWithDomainValues(f),s&&l&&s.length===l.length)for(let e=0;e<s.length;e++){const t="Raster.ServicePixelValue."+s[e];f.attributes[t]=this._formatAttributeValue(l[e],t)}h.push(u[t])}return h}_updateFeatureWithRasterAttributeTableValues(e,t){const r=this.rasterInfo&&this.rasterInfo.attributeTable||p(this.serviceRasterInfo)&&this.serviceRasterInfo.attributeTable,i=r&&r.features;if(!i)return;const s=r.fields,n=s.map((e=>e.name)).filter((e=>"value"===e.toLowerCase())),a=n&&n[0];if(!a)return;const o=i.filter((e=>e.attributes[a]===(null!=t?parseInt(t,10):null)));o&&o[0]&&s.forEach((t=>{const r=this.rasterAttributeTableFieldPrefix+t.name;e.attributes[r]=this._formatAttributeValue(o[0].attributes[t.name],r)}))}_updateFeatureWithMagDirValues(e,t){if("esriImageServiceDataTypeVector-UV"!==this.serviceDataType&&"esriImageServiceDataTypeVector-MagDir"!==this.serviceDataType)return;const r=t.split(/,\s*/).map((e=>parseFloat(e))),i=r.map((e=>[e])),s=r.map((e=>({minValue:e,maxValue:e,noDataValue:null}))),n=new N({height:1,width:1,pixelType:"f32",pixels:i,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new ee(0,0,0,0,this.spatialReference)});const a="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:E([n.pixels[0][0],n.pixels[1][0]]);e.attributes["Raster.Magnitude"]=a[0],e.attributes["Raster.Direction"]=a[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter((e=>e.domain&&"coded-value"===e.domain.type));null!=t&&t.forEach((t=>{const r=e.attributes[t.name];if(null!=r){const i=t.domain.codedValues.find((e=>e.code===r));i&&(e.attributes[t.name]=i.name)}}))}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const r=this.fieldsIndex;c(r)||e.forEach((e=>{if(e&&e.attributes)for(const i of t)if(r.has(i)){const t=r.get(i).name;t!==i&&(e.attributes[i]=e.attributes[t],delete e.attributes[t])}}))}_getRenderingRuleString(e){if(this._hasRenderingRule(e)){var t;let r=e.toJSON();return r=null!=(t=r.rasterFunctionDefinition)?t:r,(r.thumbnail||r.thumbnailEx)&&(r.thumbnail=r.thumbnailEx=null),JSON.stringify(r)}return null}_hasRenderingRule(e){return e&&e.functionName&&"none"!==e.functionName.toLowerCase()}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const r=e.toLowerCase().replace(/ /gi,"_");return t.has(r)?t.get(r):e}_isRFTJson(e){return e&&e.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map((e=>e.trim())):["image","catalog"],{currentVersion:r,advancedQueryCapabilities:i,maxRecordCount:s}=e,n=t.indexOf("image")>-1,a="esriImageServiceDataTypeElevation"===e.serviceDataType,o=!!(e.spatialReference||e.extent&&e.extent.spatialReference),l=t.includes("edit");return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:n,supportsExportImage:n,supportsIdentify:n,supportsMeasure:t.indexOf("mensuration")>-1&&o,supportsDownload:t.indexOf("download")>-1,supportsQuery:t.indexOf("catalog")>-1&&e.fields&&e.fields.length>0,supportsGetSamples:r>=10.2&&n,supportsProject:r>=10.3&&n,supportsComputeStatisticsHistograms:r>=10.4&&n,supportsQueryBoundary:r>=10.6&&n,supportsCalculateVolume:r>=10.7&&a,supportsComputePixelLocation:r>=10.7&&t.indexOf("catalog")>-1,supportsComputeAngles:r>=10.91,supportsAdd:l,supportsDelete:l,supportsEditing:l,supportsUpdate:l,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1},query:{maxRecordCount:s,maxRecordCountFactor:void 0,supportsStatistics:!(null==i||!i.supportsStatistics),supportsOrderBy:!(null==i||!i.supportsOrderBy),supportsDistinct:!(null==i||!i.supportsDistinct),supportsPagination:!(null==i||!i.supportsPagination),supportsStandardizedQueriesOnly:!(null==i||!i.useStandardizedQueries),supportsPercentileStatistics:!(null==i||!i.supportsPercentileStatistics),supportsCentroid:!(null==i||!i.supportsReturningGeometryCentroid),supportsDistance:!(null==i||!i.supportsQueryWithDistance),supportsExtent:!(null==i||!i.supportsReturningQueryExtent),supportsGeometryProperties:!(null==i||!i.supportsReturningGeometryProperties),supportsHavingClause:!(null==i||!i.supportsHavingClause),supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:!1,supportsTopFeaturesQuery:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!(null==i||!i.supportsDefaultSR),supportsCompactGeometry:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0}}}};return e([v()],u.prototype,"_functionRasterInfos",void 0),e([v()],u.prototype,"_rasterJobHandler",void 0),e([v({dependsOn:["_serviceSupportsMosaicRule"]})],u.prototype,"_defaultServiceMosaicRule",void 0),e([b("_defaultServiceMosaicRule",["defaultMosaicMethod"])],u.prototype,"readDefaultServiceMosaicRule",null),e([v()],u.prototype,"_cachedRendererJson",void 0),e([v({readOnly:!0})],u.prototype,"_serviceSourceType",void 0),e([b("_serviceSourceType",["serviceSourceType","fields"])],u.prototype,"readServiceSourceType",null),e([v({readOnly:!0})],u.prototype,"_serviceSupportsMosaicRule",void 0),e([b("_serviceSupportsMosaicRule",["currentVersion","fields"])],u.prototype,"readServiceSupportsMosaicRule",null),e([v()],u.prototype,"rasterAttributeTableFieldPrefix",void 0),e([v({readOnly:!0})],u.prototype,"rasterFunctionNamesIndex",null),e([v()],u.prototype,"adjustAspectRatio",void 0),e([v({readOnly:!0}),f("serviceRasterInfo.bandCount")],u.prototype,"bandCount",void 0),e([v({type:[g],json:{write:!0}})],u.prototype,"bandIds",void 0),e([b("bandIds")],u.prototype,"readBandIds",null),e([v({readOnly:!0,json:{read:!1}})],u.prototype,"capabilities",void 0),e([b("service","capabilities",["capabilities","currentVersion","serviceDataType"])],u.prototype,"readCapabilities",null),e([v({type:Number})],u.prototype,"compressionQuality",void 0),e([I("compressionQuality")],u.prototype,"writeCompressionQuality",null),e([v({type:Number})],u.prototype,"compressionTolerance",void 0),e([I("compressionTolerance")],u.prototype,"writeCompressionTolerance",null),e([v({json:{read:{source:"copyrightText"}}})],u.prototype,"copyright",void 0),e([v({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],u.prototype,"definitionExpression",void 0),e([v({readOnly:!0,constructOnly:!0})],u.prototype,"exportImageServiceParameters",void 0),e([v()],u.prototype,"rasterInfo",void 0),e([v({readOnly:!0,type:[D]})],u.prototype,"fields",void 0),e([v({readOnly:!0})],u.prototype,"fieldsIndex",null),e([v({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"],json:{write:!0}})],u.prototype,"format",null),e([b("service","format",["serviceDataType"])],u.prototype,"readFormat",null),e([v({type:ee})],u.prototype,"fullExtent",void 0),e([v({readOnly:!0})],u.prototype,"hasMultidimensions",void 0),e([v({json:{read:{source:"maxImageHeight"}}})],u.prototype,"imageMaxHeight",void 0),e([v({json:{read:{source:"maxImageWidth"}}})],u.prototype,"imageMaxWidth",void 0),e([v({type:String,json:{type:C.jsonValues,read:C.read,write:C.write}})],u.prototype,"interpolation",void 0),e([v()],u.prototype,"minScale",void 0),e([b("service","minScale")],u.prototype,"readMinScale",null),e([v()],u.prototype,"maxScale",void 0),e([b("service","maxScale")],u.prototype,"readMaxScale",null),e([v({type:j})],u.prototype,"mosaicRule",null),e([b("mosaicRule",["mosaicRule","defaultMosaicMethod"])],u.prototype,"readMosaicRule",null),e([I("mosaicRule")],u.prototype,"writeMosaicRule",null),e([v({readOnly:!0}),f("serviceRasterInfo.multidimensionalInfo")],u.prototype,"multidimensionalInfo",void 0),e([v({json:{type:g}})],u.prototype,"noData",void 0),e([I("noData")],u.prototype,"writeNoData",null),e([v({type:String,json:{type:M.jsonValues,read:M.read,write:M.write}})],u.prototype,"noDataInterpretation",void 0),e([v({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],u.prototype,"objectIdField",void 0),e([b("objectIdField")],u.prototype,"readObjectIdField",null),e([v({})],u.prototype,"geometryType",void 0),e([v({})],u.prototype,"typeIdField",void 0),e([v({})],u.prototype,"types",void 0),e([v({readOnly:!0})],u.prototype,"parsedUrl",null),e([v({readOnly:!0}),f("serviceRasterInfo.pixelSize.x")],u.prototype,"pixelSizeX",void 0),e([v({readOnly:!0}),f("serviceRasterInfo.pixelSize.y")],u.prototype,"pixelSizeY",void 0),e([v({type:Function})],u.prototype,"pixelFilter",void 0),e([v()],u.prototype,"raster",void 0),e([v()],u.prototype,"viewId",void 0),e([v({types:i,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:s,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],u.prototype,"renderer",null),e([b("renderer")],u.prototype,"readRenderer",null),e([I("renderer")],u.prototype,"writeRenderer",null),e([v()],u.prototype,"symbolizer",void 0),e([v(_)],u.prototype,"opacity",void 0),e([v({readOnly:!0}),f("serviceRasterInfo.attributeTable")],u.prototype,"rasterAttributeTable",void 0),e([v({readOnly:!0})],u.prototype,"rasterFields",null),e([v({constructOnly:!0})],u.prototype,"rasterFunctionInfos",void 0),e([v({type:J})],u.prototype,"renderingRule",null),e([b("renderingRule",["renderingRule","rasterFunctionInfos"])],u.prototype,"readRenderingRule",null),e([I("renderingRule")],u.prototype,"writeRenderingRule",null),e([v()],u.prototype,"serviceDataType",void 0),e([v({readOnly:!0,type:de})],u.prototype,"spatialReference",void 0),e([b("spatialReference",["spatialReference","extent"])],u.prototype,"readSpatialReference",null),e([v({json:{type:fe.jsonValues}})],u.prototype,"pixelType",void 0),e([b("pixelType")],u.prototype,"readPixelType",null),e([I("pixelType")],u.prototype,"writePixelType",null),e([v({constructOnly:!0,type:q})],u.prototype,"serviceRasterInfo",void 0),e([v()],u.prototype,"sourceJSON",void 0),e([v(w)],u.prototype,"url",void 0),e([v({readOnly:!0})],u.prototype,"version",void 0),e([b("version",["currentVersion","fields","timeInfo"])],u.prototype,"readVersion",null),u=e([S("esri.layers.mixins.ArcGISImageService")],u),u};export{ve as ArcGISImageService};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{read as r,rasterRendererTypes as i,websceneRasterRendererTypes as s}from"../../rasterRenderers.js";import n from"../../request.js";import a from"../../core/Error.js";import{strict as o}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import u from"../../core/Logger.js";import{isSome as p,isNone as c,unwrap as m}from"../../core/maybe.js";import{when as d}from"../../core/promiseUtils.js";import{urlToObject as h}from"../../core/urlUtils.js";import{aliasOf as f}from"../../core/accessorSupport/decorators/aliasOf.js";import{ensureClass as y,Integer as g,ensureNumber as R}from"../../core/accessorSupport/ensureType.js";import{property as v,ensureRange as b}from"../../core/accessorSupport/decorators/property.js";import{reader as S}from"../../core/accessorSupport/decorators/reader.js";import{subclass as x}from"../../core/accessorSupport/decorators/subclass.js";import{writer as I}from"../../core/accessorSupport/decorators/writer.js";import{opacity as w,url as _}from"../support/commonProperties.js";import F from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as D}from"../support/ExportImageServiceParameters.js";import P from"../support/Field.js";import T from"../support/FieldsIndex.js";import{isSupportedRendererType as j}from"../support/imageryRendererUtils.js";import N from"../support/MosaicRule.js";import O from"../support/PixelBlock.js";import{interpolationKebab as C,noDataInterpretationKebab as M}from"../support/rasterEnums.js";import J from"../support/RasterFunction.js";import q from"../support/RasterInfo.js";import V from"../support/RasterJobHandler.js";import{decode as A,getFormat as z}from"../support/rasterFormats/RasterCodec.js";import{uvComponentToVector as E}from"../support/rasterFunctions/vectorFieldUtils.js";import{getSupportedRendererTypes as Q,getDefaultBandCombination as U,createDefaultRenderer as H,normalizeRendererJSON as L}from"../../renderers/support/rasterRendererHelper.js";import k from"../../renderers/support/RasterSymbolizer.js";import{computeAngles as B,computePixelSpaceLocations as G,computeHistograms as W,computeStatisticsHistograms as X,getImageSpatialReferenceQueryParameter as Y,getSamples as K,identify as $}from"../../rest/imageService.js";import"../../core/unitUtils.js";import"../../kernel.js";import"../../rest/query/support/AttachmentInfo.js";import"../../rest/support/AttachmentQuery.js";import{executeForCount as Z}from"../../rest/query/executeForCount.js";import ee from"../../geometry/Extent.js";import"../../geometry/Geometry.js";import"../../geometry/Multipoint.js";import te from"../../geometry/Point.js";import re from"../../geometry/Polygon.js";import"../../geometry/Polyline.js";import"../../geometry/support/normalizeUtils.js";import"../../core/pbf.js";import"../../geometry/support/spatialReferenceUtils.js";import ie from"../../rest/support/Query.js";import{executeForIds as se}from"../../rest/query/executeForIds.js";import{executeQueryJSON as ne}from"../../rest/query/executeQueryJSON.js";import"../../core/has.js";import"../graphics/featureConversionUtils.js";import ae from"../../rest/support/FeatureSet.js";import"../../rest/support/RelationshipQuery.js";import"../../rest/support/TopFeaturesQuery.js";import oe from"../../rest/support/ImageAngleParameters.js";import le from"../../rest/support/ImageHistogramParameters.js";import ue from"../../rest/support/ImageIdentifyParameters.js";import pe from"../../rest/support/ImagePixelLocationParameters.js";import ce from"../../rest/support/ImageSampleParameters.js";import{createStreamlinesMesh as me}from"../../views/2d/engine/flow/dataUtils.js";import de from"../../geometry/SpatialReference.js";const he=u.getLogger("esri.layers.mixins.ArcGISImageService"),fe=o()({U1:"u1",U2:"u2",U4:"u4",U8:"u8",S8:"s8",U16:"u16",S16:"s16",U32:"u32",S32:"s32",F32:"f32",F64:"f64",C64:"c64",C128:"c128",UNKNOWN:"unknown"}),ye=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),ge=b(R,{min:0,max:255});function Re(e){if(!e)return null;const t=JSON.stringify(e).match(/"rasterFunction":"(.*?")/gi),r=null==t?void 0:t.map((e=>e.replace('"rasterFunction":"',"").replace('"',"")));return r?r.join("/"):null}const ve=o=>{let u=class extends o{constructor(){super(...arguments),this._functionRasterInfos={},this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this._defaultServiceMosaicRule=null,this._serviceSourceType=null,this._serviceSupportsMosaicRule=null,this.rasterAttributeTableFieldPrefix="Raster.",this.adjustAspectRatio=null,this.bandCount=null,this.bandIds=void 0,this.capabilities=null,this.compressionQuality=void 0,this.compressionTolerance=.01,this.copyright=null,this.definitionExpression=null,this.exportImageServiceParameters=null,this.rasterInfo=null,this.fields=null,this.fullExtent=null,this.hasMultidimensions=!1,this.imageMaxHeight=4100,this.imageMaxWidth=4100,this.interpolation=void 0,this.minScale=0,this.maxScale=0,this.multidimensionalInfo=null,this.noData=null,this.noDataInterpretation=void 0,this.objectIdField=null,this.geometryType="polygon",this.typeIdField=null,this.types=[],this.pixelSizeX=null,this.pixelSizeY=null,this.pixelFilter=null,this.raster=void 0,this.viewId=void 0,this.symbolizer=null,this.rasterAttributeTable=null,this.rasterFunctionInfos=null,this.serviceDataType=null,this.spatialReference=null,this.pixelType=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.url=null,this.version=void 0}initialize(){this._set("exportImageServiceParameters",new D({layer:this}))}readDefaultServiceMosaicRule(e,t){return this._serviceSupportsMosaicRule?N.fromJSON(t):null}readServiceSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}readServiceSupportsMosaicRule(e,t){return this._isMosaicRuleSupported(t)}get rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.length<1||p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.forEach((t=>{e.set(t.name.toLowerCase().replace(/ /gi,"_"),t.name)})),e}readBandIds(e,t){if(Array.isArray(e)&&e.length>0&&e.every((e=>"number"==typeof e)))return e}readCapabilities(e,t){return this._readCapabilities(t)}writeCompressionQuality(e,t,r){null!=e&&"lerc"!==this.format&&(t[r]=e)}writeCompressionTolerance(e,t,r){"lerc"===this.format&&null!=e&&(t[r]=e)}get fieldsIndex(){return this.fields?new T(this.fields):null}set format(e){e&&ye.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t&&t.mosaicMethod&&(t=N.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const r=e||t.mosaicRule;return r?N.fromJSON(r):this._isMosaicRuleSupported(t)?N.fromJSON(t):null}writeMosaicRule(e,t,r){let i=this.mosaicRule;const s=this.definitionExpression;i?s&&s!==i.where&&(i=i.clone(),i.where=s):s&&(i=new N({where:s})),this._isValidCustomizedMosaicRule(i)&&(t[r]=i.toJSON())}writeNoData(e,t,r){null!=e&&"number"==typeof e&&(t[r]=ge(e))}readObjectIdField(e,t){if(!e){const r=t.fields.filter((e=>"esriFieldTypeOID"===e.type||"oid"===e.type));e=r&&r[0]&&r[0].name}return e}get parsedUrl(){return this.url?h(this.url):null}set renderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("renderer",e)}readRenderer(e,t,i){var s,n;const a=null==t||null==(s=t.layerDefinition)||null==(n=s.drawingInfo)?void 0:n.renderer,o=r(a,i);return null==o?null:("vector-field"===o.type&&t.symbolTileSize&&!a.symbolTileSize&&(o.symbolTileSize=t.symbolTileSize),j(o)||he.warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),o)}writeRenderer(e,t,r){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this.rasterAttributeTableFieldPrefix||"Raster.",t=new P({name:"Raster.ItemPixelValue",alias:"Item Pixel Value",domain:null,editable:!1,length:50,type:"string"}),r=new P({name:"Raster.ServicePixelValue",alias:"Service Pixel Value",domain:null,editable:!1,length:50,type:"string"}),i=new P({name:"Raster.ServicePixelValue.Raw",alias:"Raw Service Pixel Value",domain:null,editable:!1,length:50,type:"string"});let s=this.fields?l(this.fields):[];s.push(r),this.capabilities.operations.supportsQuery&&this.fields&&this.fields.length>0&&s.push(t),this.version>=10.4&&p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.some((e=>"none"===e.name.toLowerCase()))&&s.push(i),p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.filter((e=>"none"!==e.name.toLowerCase())).forEach((e=>{s.push(new P({name:"Raster.ServicePixelValue."+e.name,alias:e.name,domain:null,editable:!1,length:50,type:"string"}))})),null==this.pixelFilter||"esriImageServiceDataTypeVector-UV"!==this.serviceDataType&&"esriImageServiceDataTypeVector-MagDir"!==this.serviceDataType||(s.push(new P({name:"Raster.Magnitude",alias:"Magnitude",domain:null,editable:!1,type:"double"})),s.push(new P({name:"Raster.Direction",alias:"Direction",domain:null,editable:!1,type:"double"})));const n=this.rasterInfo.attributeTable&&this.rasterInfo.attributeTable.fields||null;if(n&&n.length>0){const t=n.filter((e=>"esriFieldTypeOID"!==e.type&&"value"!==e.name.toLowerCase())).map((t=>{const r=l(t);return r.name=e+t.name,r}));s=s.concat(t)}return s}set renderingRule(e){let t=e;t&&t.rasterFunction&&(t=J.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("renderingRule",t)}readRenderingRule(e,t){const r=t.rasterFunctionInfos;return t.renderingRule||r&&r.length&&"None"!==r[0].name?this._isRFTJson(t.renderingRule)?J.fromJSON({rasterFunctionDefinition:t.renderingRule}):J.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}writeRenderingRule(e,t,r){const i=e.toJSON();i.rasterFunctionDefinition?t[r]=i.rasterFunctionDefinition:t[r]=i}readSpatialReference(e,t){const r=e||t.extent.spatialReference;return r?de.fromJSON(r):null}readPixelType(e){return fe.fromJSON(e)||e}writePixelType(e,t,r){(c(this.serviceRasterInfo)||this.pixelType!==this.serviceRasterInfo.pixelType)&&(t[r]=fe.toJSON(e))}readVersion(e,t){let r=t.currentVersion;return r||(r=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),r}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let r=e;if(!this._isPicture()&&this.renderer&&this.symbolizer&&!this.pixelFilter){const i=JSON.stringify(this._cachedRendererJson)!==JSON.stringify(this.renderer.toJSON()),s=this._rasterJobHandler.instance,{bandIds:n}=this;if(s){i&&(this.symbolizer.bind(),await s.updateSymbolizer(this.symbolizer,t),this._cachedRendererJson=this.renderer.toJSON());const a=await s.symbolize({bandIds:n,...e},t);r={extent:e.extent,pixelBlock:a}}else r={extent:e.extent,pixelBlock:this.symbolizer.symbolize({bandIds:n,...e})}}return r}destroy(){this._shutdownJobHandler()}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}async computeAngles(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsComputeAngles)throw new a("imagery-layer:compute-angles","this operation is not supported on the input image service");return e=y(oe,e).clone(),B(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsComputePixelLocation)throw new a("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=y(pe,e).clone(),G(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsComputeHistograms)throw new a("imagery-layer:compute-histograms","this operation is not supported on the input image service");e=y(le,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;return s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule&&(e.mosaicRule=i),r&&null==e.raster&&(e.raster=r),W(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsComputeStatisticsHistograms)throw new a("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");e=y(le,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;return s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule&&(e.mosaicRule=i),r&&null==e.raster&&(e.raster=r),X(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return p(t)?t.get(e):void 0}getFieldDomain(e,t){const r=this.getField(e);return r?r.domain:null}fetchImage(e,t,r,i={}){if(null==e||null==t||null==r)return Promise.reject(new a("imagery-layer:fetch-image","Insufficient parameters for requesting an image. A valid extent, width and height values are required."));const s=this.renderer||this.symbolizer?this.generateRasterInfo(this.renderingRule,{signal:i.signal}):null;return d(s).then((s=>{s&&(this.rasterInfo=s);const n={imageServiceParameters:this.getExportImageServiceParameters(e,t,r,i.timeExtent),imageProps:{extent:e,width:t,height:r,format:this.format},requestAsImageElement:i.requestAsImageElement&&!this.pixelFilter||!1,signal:i.signal};return this._requestArrayBuffer(n)}))}fetchKeyProperties(e){return n(this.parsedUrl.path+"/keyProperties",{query:this._getQueryParams({renderingRule:this.version>=10.3?null==e?void 0:e.renderingRule:null})}).then((e=>e.data))}fetchRasterAttributeTable(e){return this.version<10.1?Promise.reject(new a("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):n(this.parsedUrl.path+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?null==e?void 0:e.renderingRule:null})}).then((e=>ae.fromJSON(e.data)))}async getCatalogItemRasterInfo(e,t){const r=n(this.parsedUrl.path+"/"+e+"/info",{query:this._getQueryParams(),...t}).then((e=>e.data)),i=n(this.parsedUrl.path+"/"+e+"/info/keyProperties",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>{})),s=await Promise.all([r,i]);if(!s[0])return;const a=ee.fromJSON(s[0].extent),o=s[0].statistics?s[0].statistics.map((e=>({min:e[0],max:e[1],avg:e[2],stddev:e[3]}))):null;return new q({bandCount:s[0].bandCount,extent:a,spatialReference:a.sr,pixelSize:new te({x:s[0].pixelSizeX,y:s[0].pixelSizeY,spatialReference:a.sr}),pixelType:s[0].pixelType.toLowerCase(),statistics:o,histograms:s[0].histograms,keyProperties:s[1]||{}})}async getCatalogItemICSInfo(e,t){const{data:r}=await n(this.parsedUrl.path+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),i=r&&r.ics;if(!i)return;let s=null;try{s=(await n(this.parsedUrl.path+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!s||!s.spatialReference)return{ics:i,icsToPixelTransform:null,icsExtent:null,northDirection:null};const a=this.version>=10.7?n(this.parsedUrl.path+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>({}))):{},o=s.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[s]}),inSR:o.wkid||JSON.stringify(o),outSR:"0:"+e},u=n(this.parsedUrl.path+"/project",{query:this._getQueryParams(l),...t}).then((e=>e.data)).catch((()=>({}))),p=5,c=(s.xmin+s.xmax)/2,m=(s.ymax-s.ymin)/(p+1),d=s.ymin+m,h=[];for(let n=0;n<p;n++)h.push({x:c,y:d+m*n});const f={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:h}),inSR:o.wkid||JSON.stringify(o),outSR:"0:"+e},y=n(this.parsedUrl.path+"/project",{query:this._getQueryParams(f),...t}).then((e=>e.data)).catch((()=>({}))),g=await Promise.all([a,u,y]);let R=g[0].ipxf;if(null==R){var v,b,S;const e=null==(v=i.geodataXform)?void 0:v.xf_0;"topup"===(null==e||null==(b=e.name)?void 0:b.toLowerCase())&&6===(null==e||null==(S=e.coefficients)?void 0:S.length)&&(R={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const x=ee.fromJSON(g[1]&&g[1].geometries&&g[1].geometries[0]);x&&(x.spatialReference=new de({wkid:0,imageCoordinateSystem:i}));const I=g[2].geometries?g[2].geometries.filter((e=>null!=e&&null!=e.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y)):[],w=I.length;if(w<3)return{ics:i,icsToPixelTransform:R,icsExtent:x,northDirection:null};let _=0,F=0,D=0,P=0;for(let n=0;n<w;n++)_+=I[n].x,F+=I[n].y,D+=I[n].x*I[n].x,P+=I[n].x*I[n].y;const T=(w*P-_*F)/(w*D-_*_);let j=0;const N=I[p-1].x>I[0].x,O=I[p-1].y>I[0].y;return T===1/0?j=O?90:270:0===T?j=N?0:180:T>0?j=N?180*Math.atan(T)/Math.PI:180*Math.atan(T)/Math.PI+180:T<0&&(j=O?180+180*Math.atan(T)/Math.PI:360+180*Math.atan(T)/Math.PI),{ics:i,icsToPixelTransform:R,icsExtent:x,northDirection:j}}async generateRasterInfo(e,t){var r;if((!e||"none"===(null==e||null==(r=e.functionName)?void 0:r.toLowerCase())||this._isVectorFieldResampleFunction(e))&&p(this.serviceRasterInfo))return this.serviceRasterInfo;const i=Re(e);if(this._functionRasterInfos[i])return this._functionRasterInfos[i];const s=this._generateRasterInfo(e,t);this._functionRasterInfos[i]=s;try{return await s}catch{return this._functionRasterInfos[i]=null,null}}getExportImageServiceParameters(e,t,r,i){var s;e=e.clone().shiftCentralMeridian();const n=Y(e.spatialReference,this.parsedUrl.path);p(this.serviceRasterInfo)&&this.pixelType!==this.serviceRasterInfo.pixelType&&(this.exportImageServiceParameters.pixelType=this.pixelType);const a=this.exportImageServiceParameters.toJSON(),{bandIds:o,noData:l}=a;let{renderingRule:u}=a;const c=null==(s=this.renderingRule)?void 0:s.rasterFunctionDefinition,m=!this.renderer||"raster-stretch"===this.renderer.type;if(null!=o&&o.length&&this._hasRenderingRule(this.renderingRule)&&!c&&m){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:o}};if("Stretch"===u.rasterFunction)e.rasterFunctionArguments.Raster=u.rasterFunctionArguments.Raster,u.rasterFunctionArguments.Raster=e;else if("Colormap"===u.rasterFunction){const t=u.rasterFunctionArguments.Raster;"Stretch"===(null==t?void 0:t.rasterFunction)?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,u.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=u,u=e;a.bandIds=void 0}else a.bandIds=null==o?void 0:o.join(",");l instanceof Array&&l.length>0&&(a.noData=l.join(","));const d=this._serviceSupportsMosaicRule?this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,i):null;a.mosaicRule=d&&JSON.stringify(d),a.renderingRule=this._getRenderingRuleString(J.fromJSON(u));const h={};if(i){const{start:e,end:t}=i.toJSON();e&&t&&e===t?h.time=""+e:null==e&&null==t||(h.time=`${null==e?"null":e},${null==t?"null":t}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:n,imageSR:n,size:t+","+r,...a,...h}}async getSamples(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsGetSamples)throw new a("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=y(ce,e).clone();const{raster:r}=this;return r&&null==e.raster&&(e.raster=r),K(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(await this._fetchCapabilities(null==t?void 0:t.signal),!this.capabilities.operations.supportsIdentify)throw new a("imagery-layer:query-rasters","query operation is not supported on the input image service");e=y(ue,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;if(s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule){const t=this._combineMosaicRuleWithTimeExtent(i,e.timeExtent);e.mosaicRule=m(t)}return r&&null==e.raster&&(e.raster=r),$(this.url,e,this._getRequestOptions(t))}createQuery(){const e=new ie;return e.outFields=["*"],e.returnGeometry=!0,e.where=this.definitionExpression||"1=1",e}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ne(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),se(this.url,e,t)}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Z(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new a("imagery-layer: query-visible-rasters","missing query parameter");const{pixelSize:r,returnDomainValues:i,returnTopmostRaster:s,showNoDataRecords:n}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let o=!1,l=null,u=null;const m="raster.servicepixelvalue",d=this.rasterFunctionNamesIndex;if(p(e.outFields)&&(o=e.outFields.some((e=>!e.toLowerCase().includes(m))),this.version>=10.4)){const t=e.outFields.filter((e=>e.toLowerCase().includes(m)&&e.length>m.length)).map((e=>{const t=e.slice(m.length+1);return[this._updateRenderingRulesFunctionName(t,d),t]}));l=t.map((e=>new J({functionName:e[0]}))),u=t.map((e=>e[1])),0===l.length?this.renderingRule?(l.push(this.renderingRule),u.push(this.renderingRule.functionName)):l=null:this.renderingRule&&!l.some((e=>e.functionName===this.renderingRule.functionName))&&(l.push(this.renderingRule),u.push(this.renderingRule.functionName))}const h=c(e.outSpatialReference)||e.outSpatialReference.equals(this.spatialReference),f=e.timeExtent||this.timeExtent,y=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,f),g=this._getQueryParams({geometry:e.geometry,timeExtent:f,mosaicRule:y,renderingRule:this.version<10.4?this.renderingRule:null,renderingRules:l,pixelSize:r,returnCatalogItems:o,returnGeometry:h,raster:this.raster,maxItemCount:s?1:null});delete g.f;const R=new ue(g);try{var v,b;await this.generateRasterInfo(this.renderingRule);const r=await $(this.url,R,{signal:null==t?void 0:t.signal,query:{...this.customParameters}}),s=e.outFields,a=r.value.toLowerCase().includes("nodata");if(!(o&&!h&&(null==r||null==(v=r.catalogItems)?void 0:v.features.length)&&(n||!a)))return this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s});const l=this.objectIdField||"ObjectId",c=r.catalogItems.features,m=c.map((e=>{var t;return null==(t=e.attributes)?void 0:t[l]})),d=new ie({objectIds:m,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[l]}),f=await this.queryRasters(d);return null!=f&&null!=(b=f.features)&&b.length&&f.features.forEach((t=>{c.forEach((r=>{r.attributes[l]===t.attributes[l]&&(r.geometry=new re(t.geometry),p(e.outSpatialReference)&&(r.geometry.spatialReference=e.outSpatialReference))}))})),this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s})}catch{throw new a("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const r=n(this.parsedUrl.path+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>{var t;return null==(t=e.data)?void 0:t.statistics})),i=n(this.parsedUrl.path+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>{var t;return null==(t=e.data)?void 0:t.histograms})),s=await Promise.all([r,i]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[1]||null}}async createStreamlinesMesh(e,t){const r=this._rasterJobHandler.instance;return r?r.createStreamlinesMesh(e,t):me(e.rendererSettings,e.flowData,p(t.signal)?t.signal:(new AbortController).signal)}async _fetchService(e){await this._fetchServiceInfo(e),p(this.serviceRasterInfo)&&!this.rasterInfo&&(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,r=p(this.serviceRasterInfo)?Promise.resolve(this.serviceRasterInfo):this._fetchAuxiliaryRasterInfo({serviceInfo:t,signal:e}).then((e=>(this._set("serviceRasterInfo",e),e))),i=this._hasRenderingRule(this.renderingRule)?this.generateRasterInfo(this.renderingRule,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([r,i,s]).then((e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.renderer&&!this._isSupportedRenderer(this.renderer)&&(this._set("renderer",null),he.warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("renderer",this._configRenderer(this.renderer)),this.watch("renderingRule",(e=>{(this.renderer||this.symbolizer||this.popupEnabled&&this.popupTemplate)&&this.generateRasterInfo(e).then((e=>{e&&(this.rasterInfo=e)}))}));const t=p(this.serviceRasterInfo)&&this.serviceRasterInfo.multidimensionalInfo;t&&this._updateMultidimensionalDefinition(t)}))}_combineMosaicRuleWithTimeExtent(e,t){const r=this.timeInfo;if(c(e)||c(this.multidimensionalInfo)||c(t)||c(null==r?void 0:r.startField))return e;const{startField:i}=r;var s;if(e=e.clone(),"mosaic-dataset"===this._serviceSourceType)return e.multidimensionalDefinition=null==(s=e.multidimensionalDefinition)?void 0:s.filter((e=>e.dimensionName!==i)),this._cleanupMultidimensionalDefinition(e);e.multidimensionalDefinition=e.multidimensionalDefinition||[];const n=e.multidimensionalDefinition.filter((e=>e.dimensionName===i)),a=p(t.start)?t.start.getTime():null,o=p(t.end)?t.end.getTime():null,l=null==a||null==o||a===o,u=l?[a||o]:[[a,o]],m=this.version>=10.8;if(n.length)n.forEach((e=>{e.dimensionName===i&&(m?(e.dimensionName=null,e.isSlice=null,e.values=null):(e.isSlice=l,e.values=u))}));else if(!m){const t=e.multidimensionalDefinition.filter((e=>null!=e.variableName&&null==e.dimensionName));t.length?t.forEach((e=>{e.dimensionName=i,e.isSlice=l,e.values=u})):e.multidimensionalDefinition.push(new F({variableName:"",dimensionName:i,isSlice:l,values:u}))}return this._cleanupMultidimensionalDefinition(e)}_cleanupMultidimensionalDefinition(e){return c(e)?null:(e.multidimensionalDefinition&&(e.multidimensionalDefinition=e.multidimensionalDefinition.filter((e=>!(!e.variableName&&!e.dimensionName))),0===e.multidimensionalDefinition.length&&(e.multidimensionalDefinition=null)),"mosaic-dataset"!==this._serviceSourceType&&null==e.multidimensionalDefinition?null:e)}async _prepareForQuery(e,t){var r;if(await this._fetchCapabilities(null==(r=t)?void 0:r.signal),!this.capabilities.operations.supportsQuery)throw new a("imagery-layer:query-rasters","query operation is not supported on the input image service");return e=p(e)?y(ie,e):this.createQuery(),t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:e,requestOptions:t}}async _initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new V;this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{this._rasterJobHandler.instance=e}),(()=>null)),await this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0}_isSupportedRenderer(e){const{rasterInfo:t,renderingRule:r}=this;return"unique-value"===e.type&&this._hasRenderingRule(r)&&1===t.bandCount&&["u8","s8"].includes(t.pixelType)||Q(this.rasterInfo).includes(this.renderer.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){var t;let r=this.sourceJSON;if(!r){const{data:t,ssl:i}=await n(this.parsedUrl.path,{query:this._getQueryParams(),signal:e});r=t,this.sourceJSON=r,i&&(this.url=this.url.replace(/^http:/i,"https:"))}if((null==(t=r.capabilities)?void 0:t.toLowerCase().split(",").map((e=>e.trim())).indexOf("tilesonly"))>-1)throw new a("imagery-layer:fetch-service-info","use ImageryTileLayer to open tiles-only image services");this.read(r,{origin:"service",url:this.parsedUrl})}_isMosaicDataset(e){var t;return e.serviceSourceType?"esriImageServiceSourceTypeMosaicDataset"===e.serviceSourceType:(null==(t=e.fields)?void 0:t.length)>0}_isMosaicRuleSupported(e){var t;if(!e)return!1;const r=this._isMosaicDataset(e),i=e.currentVersion>=10.71&&e.hasMultidimensions&&e.timeInfo&&!(e.objectIdField&&(null==(t=e.fields)?void 0:t.length)>1);return r||i}_isVectorFieldResampleFunction(e){if(c(e))return!1;const{functionName:t,functionArguments:r}=e,i="resample"===(null==t?void 0:t.toLowerCase()),s=(null==r?void 0:r.ResampleType)||(null==r?void 0:r.resampleType);return i&&(7===s||10===s)}_isPicture(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}_configRenderer(e){if(!this._isPicture()&&!this.pixelFilter){if(!this.bandIds&&this.rasterInfo.bandCount>=3){const e=U(this.rasterInfo);!e||3===this.rasterInfo.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}var t,r;if(!e)e=H(this.rasterInfo,{bandIds:this.bandIds,variableName:this.renderingRule?null:null==(t=this.mosaicRule)||null==(r=t.multidimensionalDefinition)?void 0:r[0].variableName});const i=L(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=i,this.symbolizer.rasterInfo=this.rasterInfo):this.symbolizer=new k({rendererJSON:i,rasterInfo:this.rasterInfo}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:p(e.pixelBlock)&&e.pixelBlock.clone()}}_getQueryParams(e){p(null==e?void 0:e.renderingRule)&&"string"!=typeof e.renderingRule&&(e.renderingRule=this._getRenderingRuleString(e.renderingRule));const{raster:t,viewId:r}=this;return{raster:t,viewId:r,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...null==e?void 0:e.query,...this.customParameters}}}_decodePixelBlock(e,t,r){return this._rasterJobHandler.instance?this._rasterJobHandler.instance.decode({data:e,options:t}):A(e,t,r)}async _fetchMultidimensionalInfo(e){var t;const r=await n(this.parsedUrl.path+"/multidimensionalInfo",{query:this._getQueryParams(),signal:e}).then((e=>{var t;return null==(t=e.data)?void 0:t.multidimensionalInfo}));return null!=(t=r.variables)&&t.length&&r.variables.forEach((e=>{var t;null!=(t=e.statistics)&&t.length&&e.statistics.forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation}))})),r}async _getRasterFunctionInfos(e){const t=this.sourceJSON.rasterFunctionInfos;if(this.serviceRasterInfo)return t;if(t&&this.version>=10.3){var r;if(1===t.length&&"none"===t[0].name.toLowerCase())return t;return null==(r=(await n(this.parsedUrl.path+"/rasterFunctionInfos",{query:this._getQueryParams(),signal:e})).data)?void 0:r.rasterFunctionInfos}return null}async _fetchAuxiliaryRasterInfo(e){const t=e&&e.serviceInfo;if(!t)throw new a("imagery-layer:fetch-metadata","valid serviceInfo is required");const r=e.signal,i=!!(t.hasRasterAttributeTable&&this.version>=10.1)&&n(this.parsedUrl.path+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.1?null==e?void 0:e.renderingRule:null}),signal:r}).then((e=>ae.fromJSON(e.data))).catch((()=>null)),s=!!(t.hasColormap&&this.version>=10.1)&&n(this.parsedUrl.path+"/colormap",{query:this._getQueryParams({renderingRule:this.version>=10.6?null==e?void 0:e.renderingRule:null}),signal:r}).then((e=>{var t;return null==(t=e.data)?void 0:t.colormap})),o=!!(t.hasHistograms&&this.version>=10.1)&&n(this.parsedUrl.path+"/histograms",{query:this._getQueryParams({renderingRule:this.version>=10.1?null==e?void 0:e.renderingRule:null}),signal:r}).then((e=>{var t;return null==(t=e.data)?void 0:t.histograms})),l=this.version>=10.3&&n(this.parsedUrl.path+"/keyProperties",{query:this._getQueryParams({renderingRule:null==e?void 0:e.renderingRule}),signal:r}).then((e=>e.data)).catch((()=>{})),u=!!(t.hasMultidimensions&&this.version>=10.3)&&this._fetchMultidimensionalInfo(),p=await Promise.all([i,s,o,l,u]);let c=null;if(t.minValues&&t.minValues.length===t.bandCount){c=[];for(let e=0;e<t.minValues.length;e++)c.push({min:t.minValues[e],max:t.maxValues[e],avg:t.meanValues[e],stddev:t.stdvValues[e]})}const m=Math.ceil((t.extent.xmax-t.extent.xmin)/t.pixelSizeX-.1),d=Math.ceil((t.extent.ymax-t.extent.ymin)/t.pixelSizeY-.1),h=de.fromJSON(t.spatialReference||t.extent.spatialReference);return new q({width:m,height:d,bandCount:t.bandCount,extent:ee.fromJSON(t.extent),spatialReference:h,pixelSize:new te({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:h}),pixelType:t.pixelType.toLowerCase(),statistics:c,attributeTable:p[0]||null,colormap:p[1]||null,histograms:p[2]||null,keyProperties:p[3]||{},multidimensionalInfo:p[4]||null})}async _requestArrayBuffer(e){var t;const{imageProps:r,requestAsImageElement:i,signal:s}=e;if(i&&!this.pixelFilter&&(null==(t=r.format)?void 0:t.indexOf("png"))>-1){return{imageElement:(await n(this.parsedUrl.path+"/exportImage",{responseType:"image",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:s})).data,params:r}}const o=this._initJobHandler(),l=n(this.parsedUrl.path+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:s}),u=(await Promise.all([l,o]))[0].data,p=r.format||"jpgpng";let c=p;if("bsq"!==c&&"bip"!==c&&(c=z(u)),!c)throw new a("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(u)));const m={signal:s},d="gif"===p||"bmp"===p||p.includes("png")&&("png"===c||"jpg"===c)?A(u,{useCanvas:!0,...r},m):this._decodePixelBlock(u,{width:r.width,height:r.height,planes:null,pixelType:null,noDataValue:null,format:p},m);return{pixelData:{pixelBlock:await d,extent:r.extent},params:r}}async _generateRasterInfo(e,t){const{data:r}=await n(this.parsedUrl.path,{query:this._getQueryParams({renderingRule:e}),...t});return await this._fetchAuxiliaryRasterInfo({serviceInfo:r,renderingRule:e,...t})}_isValidCustomizedMosaicRule(e){var t;return e&&JSON.stringify(e.toJSON())!==JSON.stringify(null==(t=this._defaultServiceMosaicRule)?void 0:t.toJSON())}_updateMultidimensionalDefinition(e){if(this._isValidCustomizedMosaicRule(this.mosaicRule))return;const t=e.variables[0].dimensions,r="",i=[];for(const s in t)if(t.hasOwnProperty(s)){const e=t[s],n=e.extent;let a=!0,o=[n[0]];e.hasRanges&&!0===e.hasRanges?(a=!1,o=[e.values[0]]):"stdz"===e.name.toLowerCase()&&Math.abs(n[1])<=Math.abs(n[0])&&(o=[n[1]]),i.push(new F({variableName:r,dimensionName:t[s].name,isSlice:a,values:o}))}if(i.length>0){this.mosaicRule=this.mosaicRule||new N;const e=this.mosaicRule.multidimensionalDefinition;(!e||e&&e.length<=0)&&(this.mosaicRule.multidimensionalDefinition=i)}}_formatAttributeValue(e,t){if("string"==typeof e){const r=this.popupTemplate&&this.popupTemplate.fieldInfos,i=this._getFieldInfo(r,t),s=i&&i.format;if(s){let t,r;return e.trim().includes(",")?(t=",",r=t+" ",this._formatDelimitedString(e,t,r,s)):e.trim().includes(";")?(t=";",r=t+" ",this._formatDelimitedString(e,t,r,s)):e.trim().includes(" ")?(t=r=" ",this._formatDelimitedString(e,t,r,s)):this._formatNumberFromString(e,s)}}return e}_getFieldInfo(e,t){if(!e||!e.length||!t)return;const r=t.toLowerCase();let i;return e.some((e=>!(!e.fieldName||e.fieldName.toLowerCase()!==r&&e.fieldName.toLowerCase()!==r.replace(/ /g,"_"))&&(i=e,!0))),i}_formatDelimitedString(e,t,r,i){return e&&t&&r&&i?e.trim().split(t).map((e=>this._formatNumberFromString(e,i))).join(r):e}_formatNumberFromString(e,t){if(!e||!t)return e;const r=Number(e);return isNaN(r)?e:t.format(r)}_processVisibleRastersResponse(e,r){r=r||{};const i=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:a,templateFields:o}=r,l=e.processedValues;let u=e.catalogItems&&e.catalogItems.features,c=e.properties&&e.properties.Values&&e.properties.Values.map((e=>e.replace(/ /gi,", ")))||[];const m=this.objectIdField||"ObjectId",d="string"==typeof i&&i.toLowerCase().includes("nodata"),h=[];if(i&&!u&&!d){const e={};e[m]=0;c=[i],u=[new t(this.fullExtent,null,e)]}if(!u)return[];let f,y,g;this._updateResponseFieldNames(u,o),d&&!n&&(u=[]);for(let t=0;t<u.length;t++){if(f=u[t],null!=i){if(y=c[t],g=this.renderingRule&&l&&l.length>0&&s&&s.length>0&&s.includes(this.renderingRule.functionName)?l[s.indexOf(this.renderingRule.functionName)]:i,"nodata"===y.toLowerCase()&&!n)continue;const e="Raster.ItemPixelValue",r="Raster.ServicePixelValue";f.attributes[e]=this._formatAttributeValue(y,e),f.attributes[r]=this._formatAttributeValue(g,r),this._updateFeatureWithMagDirValues(f,y);const a=this.fields&&this.fields.length>0;let o=this.renderingRule&&p(this.serviceRasterInfo)&&this.serviceRasterInfo.attributeTable?a?y:i:g;this.renderingRule||(o=a?y:i),this._updateFeatureWithRasterAttributeTableValues(f,o)}if(f.sourceLayer=f.layer=this,a&&this._updateFeatureWithDomainValues(f),s&&l&&s.length===l.length)for(let e=0;e<s.length;e++){const t="Raster.ServicePixelValue."+s[e];f.attributes[t]=this._formatAttributeValue(l[e],t)}h.push(u[t])}return h}_updateFeatureWithRasterAttributeTableValues(e,t){const r=this.rasterInfo&&this.rasterInfo.attributeTable||p(this.serviceRasterInfo)&&this.serviceRasterInfo.attributeTable,i=r&&r.features;if(!i)return;const s=r.fields,n=s.map((e=>e.name)).filter((e=>"value"===e.toLowerCase())),a=n&&n[0];if(!a)return;const o=i.filter((e=>e.attributes[a]===(null!=t?parseInt(t,10):null)));o&&o[0]&&s.forEach((t=>{const r=this.rasterAttributeTableFieldPrefix+t.name;e.attributes[r]=this._formatAttributeValue(o[0].attributes[t.name],r)}))}_updateFeatureWithMagDirValues(e,t){if("esriImageServiceDataTypeVector-UV"!==this.serviceDataType&&"esriImageServiceDataTypeVector-MagDir"!==this.serviceDataType)return;const r=t.split(/,\s*/).map((e=>parseFloat(e))),i=r.map((e=>[e])),s=r.map((e=>({minValue:e,maxValue:e,noDataValue:null}))),n=new O({height:1,width:1,pixelType:"f32",pixels:i,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new ee(0,0,0,0,this.spatialReference)});const a="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:E([n.pixels[0][0],n.pixels[1][0]]);e.attributes["Raster.Magnitude"]=a[0],e.attributes["Raster.Direction"]=a[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter((e=>e.domain&&"coded-value"===e.domain.type));null!=t&&t.forEach((t=>{const r=e.attributes[t.name];if(null!=r){const i=t.domain.codedValues.find((e=>e.code===r));i&&(e.attributes[t.name]=i.name)}}))}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const r=this.fieldsIndex;c(r)||e.forEach((e=>{if(e&&e.attributes)for(const i of t)if(r.has(i)){const t=r.get(i).name;t!==i&&(e.attributes[i]=e.attributes[t],delete e.attributes[t])}}))}_getRenderingRuleString(e){if(this._hasRenderingRule(e)){var t;let r=e.toJSON();return r=null!=(t=r.rasterFunctionDefinition)?t:r,(r.thumbnail||r.thumbnailEx)&&(r.thumbnail=r.thumbnailEx=null),JSON.stringify(r)}return null}_hasRenderingRule(e){return e&&e.functionName&&"none"!==e.functionName.toLowerCase()}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const r=e.toLowerCase().replace(/ /gi,"_");return t.has(r)?t.get(r):e}_isRFTJson(e){return e&&e.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map((e=>e.trim())):["image","catalog"],{currentVersion:r,advancedQueryCapabilities:i,maxRecordCount:s}=e,n=t.includes("image"),a="esriImageServiceDataTypeElevation"===e.serviceDataType,o=!!(e.spatialReference||e.extent&&e.extent.spatialReference),l=t.includes("edit");return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:n,supportsExportImage:n,supportsIdentify:n,supportsMeasure:t.includes("mensuration")&&o,supportsDownload:t.includes("download"),supportsQuery:t.includes("catalog")&&e.fields&&e.fields.length>0,supportsGetSamples:r>=10.2&&n,supportsProject:r>=10.3&&n,supportsComputeStatisticsHistograms:r>=10.4&&n,supportsQueryBoundary:r>=10.6&&n,supportsCalculateVolume:r>=10.7&&a,supportsComputePixelLocation:r>=10.7&&t.includes("catalog"),supportsComputeAngles:r>=10.91,supportsAdd:l,supportsDelete:l,supportsEditing:l,supportsUpdate:l,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1},query:{maxRecordCount:s,maxRecordCountFactor:void 0,supportsStatistics:!(null==i||!i.supportsStatistics),supportsOrderBy:!(null==i||!i.supportsOrderBy),supportsDistinct:!(null==i||!i.supportsDistinct),supportsPagination:!(null==i||!i.supportsPagination),supportsStandardizedQueriesOnly:!(null==i||!i.useStandardizedQueries),supportsPercentileStatistics:!(null==i||!i.supportsPercentileStatistics),supportsCentroid:!(null==i||!i.supportsReturningGeometryCentroid),supportsDistance:!(null==i||!i.supportsQueryWithDistance),supportsExtent:!(null==i||!i.supportsReturningQueryExtent),supportsGeometryProperties:!(null==i||!i.supportsReturningGeometryProperties),supportsHavingClause:!(null==i||!i.supportsHavingClause),supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:!1,supportsTopFeaturesQuery:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!(null==i||!i.supportsDefaultSR),supportsCompactGeometry:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0}}}};return e([v()],u.prototype,"_functionRasterInfos",void 0),e([v()],u.prototype,"_rasterJobHandler",void 0),e([v({dependsOn:["_serviceSupportsMosaicRule"]})],u.prototype,"_defaultServiceMosaicRule",void 0),e([S("_defaultServiceMosaicRule",["defaultMosaicMethod"])],u.prototype,"readDefaultServiceMosaicRule",null),e([v()],u.prototype,"_cachedRendererJson",void 0),e([v({readOnly:!0})],u.prototype,"_serviceSourceType",void 0),e([S("_serviceSourceType",["serviceSourceType","fields"])],u.prototype,"readServiceSourceType",null),e([v({readOnly:!0})],u.prototype,"_serviceSupportsMosaicRule",void 0),e([S("_serviceSupportsMosaicRule",["currentVersion","fields"])],u.prototype,"readServiceSupportsMosaicRule",null),e([v()],u.prototype,"rasterAttributeTableFieldPrefix",void 0),e([v({readOnly:!0})],u.prototype,"rasterFunctionNamesIndex",null),e([v()],u.prototype,"adjustAspectRatio",void 0),e([v({readOnly:!0}),f("serviceRasterInfo.bandCount")],u.prototype,"bandCount",void 0),e([v({type:[g],json:{write:!0}})],u.prototype,"bandIds",void 0),e([S("bandIds")],u.prototype,"readBandIds",null),e([v({readOnly:!0,json:{read:!1}})],u.prototype,"capabilities",void 0),e([S("service","capabilities",["capabilities","currentVersion","serviceDataType"])],u.prototype,"readCapabilities",null),e([v({type:Number})],u.prototype,"compressionQuality",void 0),e([I("compressionQuality")],u.prototype,"writeCompressionQuality",null),e([v({type:Number})],u.prototype,"compressionTolerance",void 0),e([I("compressionTolerance")],u.prototype,"writeCompressionTolerance",null),e([v({json:{read:{source:"copyrightText"}}})],u.prototype,"copyright",void 0),e([v({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],u.prototype,"definitionExpression",void 0),e([v({readOnly:!0,constructOnly:!0})],u.prototype,"exportImageServiceParameters",void 0),e([v()],u.prototype,"rasterInfo",void 0),e([v({readOnly:!0,type:[P]})],u.prototype,"fields",void 0),e([v({readOnly:!0})],u.prototype,"fieldsIndex",null),e([v({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"],json:{write:!0}})],u.prototype,"format",null),e([S("service","format",["serviceDataType"])],u.prototype,"readFormat",null),e([v({type:ee})],u.prototype,"fullExtent",void 0),e([v({readOnly:!0})],u.prototype,"hasMultidimensions",void 0),e([v({json:{read:{source:"maxImageHeight"}}})],u.prototype,"imageMaxHeight",void 0),e([v({json:{read:{source:"maxImageWidth"}}})],u.prototype,"imageMaxWidth",void 0),e([v({type:String,json:{type:C.jsonValues,read:C.read,write:C.write}})],u.prototype,"interpolation",void 0),e([v()],u.prototype,"minScale",void 0),e([S("service","minScale")],u.prototype,"readMinScale",null),e([v()],u.prototype,"maxScale",void 0),e([S("service","maxScale")],u.prototype,"readMaxScale",null),e([v({type:N})],u.prototype,"mosaicRule",null),e([S("mosaicRule",["mosaicRule","defaultMosaicMethod"])],u.prototype,"readMosaicRule",null),e([I("mosaicRule")],u.prototype,"writeMosaicRule",null),e([v({readOnly:!0}),f("serviceRasterInfo.multidimensionalInfo")],u.prototype,"multidimensionalInfo",void 0),e([v({json:{type:g}})],u.prototype,"noData",void 0),e([I("noData")],u.prototype,"writeNoData",null),e([v({type:String,json:{type:M.jsonValues,read:M.read,write:M.write}})],u.prototype,"noDataInterpretation",void 0),e([v({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],u.prototype,"objectIdField",void 0),e([S("objectIdField")],u.prototype,"readObjectIdField",null),e([v({})],u.prototype,"geometryType",void 0),e([v({})],u.prototype,"typeIdField",void 0),e([v({})],u.prototype,"types",void 0),e([v({readOnly:!0})],u.prototype,"parsedUrl",null),e([v({readOnly:!0}),f("serviceRasterInfo.pixelSize.x")],u.prototype,"pixelSizeX",void 0),e([v({readOnly:!0}),f("serviceRasterInfo.pixelSize.y")],u.prototype,"pixelSizeY",void 0),e([v({type:Function})],u.prototype,"pixelFilter",void 0),e([v()],u.prototype,"raster",void 0),e([v()],u.prototype,"viewId",void 0),e([v({types:i,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:s,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],u.prototype,"renderer",null),e([S("renderer")],u.prototype,"readRenderer",null),e([I("renderer")],u.prototype,"writeRenderer",null),e([v()],u.prototype,"symbolizer",void 0),e([v(w)],u.prototype,"opacity",void 0),e([v({readOnly:!0}),f("serviceRasterInfo.attributeTable")],u.prototype,"rasterAttributeTable",void 0),e([v({readOnly:!0})],u.prototype,"rasterFields",null),e([v({constructOnly:!0})],u.prototype,"rasterFunctionInfos",void 0),e([v({type:J})],u.prototype,"renderingRule",null),e([S("renderingRule",["renderingRule","rasterFunctionInfos"])],u.prototype,"readRenderingRule",null),e([I("renderingRule")],u.prototype,"writeRenderingRule",null),e([v()],u.prototype,"serviceDataType",void 0),e([v({readOnly:!0,type:de})],u.prototype,"spatialReference",void 0),e([S("spatialReference",["spatialReference","extent"])],u.prototype,"readSpatialReference",null),e([v({json:{type:fe.jsonValues}})],u.prototype,"pixelType",void 0),e([S("pixelType")],u.prototype,"readPixelType",null),e([I("pixelType")],u.prototype,"writePixelType",null),e([v({constructOnly:!0,type:q})],u.prototype,"serviceRasterInfo",void 0),e([v()],u.prototype,"sourceJSON",void 0),e([v(_)],u.prototype,"url",void 0),e([v({readOnly:!0})],u.prototype,"version",void 0),e([S("version",["currentVersion","fields","timeInfo"])],u.prototype,"readVersion",null),u=e([x("esri.layers.mixins.ArcGISImageService")],u),u};export{ve as ArcGISImageService};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import"../../geometry.js";import e from"../../request.js";import t from"../../core/Error.js";import i from"../../core/Logger.js";import{isNone as n,unwrapOr as r,isSome as a}from"../../core/maybe.js";import{WGS84 as s}from"../../geometry/support/spatialReferenceUtils.js";import{project as o}from"../../geometry/support/webMercatorUtils.js";import{convertToFeatureSet as l,convertToGeometry as c,convertFromGeometry as d}from"../graphics/featureConversionUtils.js";import u from"../graphics/OptimizedFeatureSet.js";import{validateGeoJSON as p,inferLayerProperties as m,createOptimizedFeatures as f}from"../graphics/sources/geojson/geojson.js";import{createDrawingInfo as g}from"../graphics/sources/support/clientSideDefaults.js";import y from"../support/FieldsIndex.js";import{kebabDict as w}from"../support/fieldType.js";import h from"../../geometry/SpatialReference.js";const b=i.getLogger("esri.layers.graphics.sources.ogcfeature"),j="http://www.opengis.net/def/crs/",F=`${j}OGC/1.3/CRS84`;async function I(i,r,a={},s=5){const{links:o}=i,l=G(o,"items","application/geo+json")||G(o,"http://www.opengis.net/def/rel/ogc/1.0/items","application/geo+json");if(n(l))throw new t("ogc-feature-layer:missing-items-page","Missing items url");const{data:c}=await e(l.href,{signal:a.signal,query:{limit:s,...a.customParameters,token:a.apiKey},headers:{accept:"application/geo+json"}});await p(c);const d=m(c,{geometryType:r.geometryType}),u=r.fields||d.fields||[],f=null!=r.hasZ?r.hasZ:d.hasZ,h=d.geometryType,j=r.objectIdField||d.objectIdFieldName||"OBJECTID";let F=r.timeInfo;const I=u.find((e=>e.name===j));if(!I){if(!d.objectIdFieldType)throw new t("ogc-feature-layer:missing-feature-id","Collection geojson require a feature id as a unique identifier");u.unshift({name:j,alias:j,type:"esriFieldTypeOID",editable:!1,nullable:!1})}else I.type="esriFieldTypeOID",I.editable=!1,I.nullable=!1;if(j!==d.objectIdFieldName){const e=u.find((e=>e.name===d.objectIdFieldName));e&&(e.type="esriFieldTypeInteger")}u===d.fields&&d.unknownFields.length>0&&b.warn({name:"ogc-feature-layer:unknown-field-types",message:"Some fields types couldn't be inferred from the features and were dropped",details:{unknownFields:d.unknownFields}});for(const e of u){if(null==e.name&&(e.name=e.alias),null==e.alias&&(e.alias=e.name),"esriFieldTypeOID"!==e.type&&"esriFieldTypeGlobalID"!==e.type&&(e.editable=null==e.editable||!!e.editable,e.nullable=null==e.nullable||!!e.nullable),!e.name)throw new t("ogc-feature-layer:invalid-field-name","field name is missing",{field:e});if(-1===w.jsonValues.indexOf(e.type))throw new t("ogc-feature-layer:invalid-field-type",`invalid type for field "${e.name}"`,{field:e})}if(F){const e=new y(u);if(F.startTimeField){const t=e.get(F.startTimeField);t?(F.startTimeField=t.name,t.type="esriFieldTypeDate"):F.startTimeField=null}if(F.endTimeField){const t=e.get(F.endTimeField);t?(F.endTimeField=t.name,t.type="esriFieldTypeDate"):F.endTimeField=null}if(F.trackIdField){const t=e.get(F.trackIdField);t?F.trackIdField=t.name:(F.trackIdField=null,b.warn({name:"ogc-feature-layer:invalid-timeInfo-trackIdField",message:"trackIdField is missing",details:{timeInfo:F}}))}F.startTimeField||F.endTimeField||(b.warn({name:"ogc-feature-layer:invalid-timeInfo",message:"startTimeField and endTimeField are missing",details:{timeInfo:F}}),F=null)}return{drawingInfo:h?g(h):null,geometryType:h,fields:u,hasZ:!!f,objectIdField:j,timeInfo:F}}async function T(i,r={}){const{links:a}=i,s=G(a,"data","application/json")||G(a,"http://www.opengis.net/def/rel/ogc/1.0/data","application/json");if(n(s))throw new t("ogc-feature-layer:missing-collections-page","Missing collections url");const{apiKey:o,customParameters:l,signal:c}=r,{data:d}=await e(s.href,{signal:c,headers:{accept:"application/json"},query:{...l,token:o}});return d}async function k(i,r={}){const{links:a}=i,s=G(a,"conformance","application/json")||G(a,"http://www.opengis.net/def/rel/ogc/1.0/conformance","application/json");if(n(s))throw new t("ogc-feature-layer:missing-conformance-page","Missing conformance url");const{apiKey:o,customParameters:l,signal:c}=r,{data:d}=await e(s.href,{signal:c,headers:{accept:"application/json"},query:{...l,token:o}});return d}async function x(t,i={}){const{apiKey:n,customParameters:r,signal:a}=i,{data:s}=await e(t,{signal:a,headers:{accept:"application/json"},query:{...r,token:n}});return s}async function S(t,i={}){const r="application/vnd.oai.openapi+json;version=3.0",a=G(t.links,"service-desc",r);if(n(a))return b.warn("ogc-feature-layer:missing-openapi-page","The OGC API-Features server does not have an OpenAPI page."),null;const{apiKey:s,customParameters:o,signal:l}=i,{data:c}=await e(a.href,{signal:l,headers:{accept:r},query:{...o,token:s}});return c}function v(e){const t=/^http:\/\/www\.opengis.net\/def\/crs\/(?<authority>.*)\/(?<version>.*)\/(?<code>.*)$/i.exec(e),i=null==t?void 0:t.groups;if(!i)return null;const{authority:n,code:r}=i;switch(n.toLowerCase()){case"ogc":switch(r.toLowerCase()){case"crs27":return h.GCS_NAD_1927.wkid;case"crs83":return 4269;case"crs84":case"crs84h":return h.WGS84.wkid;default:return null}case"esri":case"epsg":{const e=Number.parseInt(r,10);return Number.isNaN(e)?null:e}default:return null}}async function N(e,t,i){const n=await q(e,t,i);return l(n)}async function q(i,l,p){const{capabilities:{query:{maxRecordCount:m}},collection:g,layerDefinition:y,queryParameters:{apiKey:w,customParameters:b},spatialReference:j,supportedCrs:F}=i,{links:I}=g,T=G(I,"items","application/geo+json")||G(I,"http://www.opengis.net/def/rel/ogc/1.0/items","application/geo+json");if(n(T))throw new t("ogc-feature-layer:missing-items-page","Missing items url");const{geometry:k,num:x,start:S,timeExtent:v,where:N}=l;if(l.objectIds)throw new t("ogc-feature-layer:query-by-objectids-not-supported","Queries with objectids are not supported");const q=h.fromJSON(j),M=r(l.outSpatialReference,q),C=M.isWGS84?null:O(M,F),P=D(k,F),W=R(v),Z=$(N),K=null!=x?x:null!=S&&void 0!==S?10:m,{data:L}=await e(T.href,{...p,query:{...b,...P,crs:C,datetime:W,query:Z,limit:K,startindex:S,token:w},headers:{accept:"application/geo+json"}});let A=!1;if(L.links){const e=L.links.find((e=>"next"===e.rel));A=!!e}!A&&Number.isInteger(L.numberMatched)&&Number.isInteger(L.numberReturned)&&(A=L.numberReturned<L.numberMatched);const{fields:E,globalIdField:J,hasM:U,hasZ:_,objectIdField:z}=y,B=y.geometryType,Q=f(L,{geometryType:B,hasZ:_,objectIdField:z});if(!C&&M.isWebMercator)for(const e of Q)if(a(e.geometry)){const t=c(e.geometry,B,_,!1);t.spatialReference=h.WGS84,e.geometry=d(o(t,M))}for(const e of Q)e.objectId=e.attributes[z];const V=C||!C&&M.isWebMercator?M.toJSON():s,H=new u;return H.exceededTransferLimit=A,H.features=Q,H.fields=E,H.geometryType=B,H.globalIdFieldName=J,H.hasM=U,H.hasZ=_,H.objectIdFieldName=z,H.spatialReference=V,H}function M(e){return a(e)&&"extent"===e.type}function O(e,t){var i,n,r;const{isWebMercator:a,wkid:s}=e;if(!s)return null;const o=a?null!=(i=null!=(n=null!=(r=t[3857])?r:t[102100])?n:t[102113])?i:t[900913]:t[e.wkid];return o?`${j}${o}`:null}function C(e){if(n(e))return"";const{xmin:t,ymin:i,xmax:r,ymax:a}=e;return`${t},${i},${r},${a}`}function R(e){if(n(e))return null;const{start:t,end:i}=e;return`${a(t)?t.toISOString():".."}/${a(i)?i.toISOString():".."}`}function $(e){return n(e)||!e||"1=1"===e?null:e}function D(e,t){if(!M(e))return null;const{spatialReference:i}=e;if(!i||i.isWGS84)return{bbox:C(e)};const n=O(i,t);return a(n)?{bbox:C(e),"bbox-crs":n}:i.isWebMercator?{bbox:C(o(e,h.WGS84))}:null}function G(e,t,i){return e.find((e=>e.rel===t&&e.type===i))||e.find((e=>e.rel===t&&!e.type))}export{F as crsDefault,j as crsPrefix,I as getCollectionDefinition,T as getServerCollections,k as getServerConformance,x as getServerLandingPage,S as getServerOpenApi,v as getSpatialReferenceWkid,N as queryFeatureSetJSON,q as queryOptimizedFeatureSet};
5
+ import"../../geometry.js";import e from"../../request.js";import t from"../../core/Error.js";import i from"../../core/Logger.js";import{isNone as n,unwrapOr as r,isSome as a}from"../../core/maybe.js";import{WGS84 as s}from"../../geometry/support/spatialReferenceUtils.js";import{project as o}from"../../geometry/support/webMercatorUtils.js";import{convertToFeatureSet as l,convertToGeometry as c,convertFromGeometry as d}from"../graphics/featureConversionUtils.js";import u from"../graphics/OptimizedFeatureSet.js";import{validateGeoJSON as p,inferLayerProperties as m,createOptimizedFeatures as f}from"../graphics/sources/geojson/geojson.js";import{createDrawingInfo as g}from"../graphics/sources/support/clientSideDefaults.js";import y from"../support/FieldsIndex.js";import{kebabDict as w}from"../support/fieldType.js";import h from"../../geometry/SpatialReference.js";const b=i.getLogger("esri.layers.graphics.sources.ogcfeature"),j="http://www.opengis.net/def/crs/",F=`${j}OGC/1.3/CRS84`;async function I(i,r,a={},s=5){const{links:o}=i,l=G(o,"items","application/geo+json")||G(o,"http://www.opengis.net/def/rel/ogc/1.0/items","application/geo+json");if(n(l))throw new t("ogc-feature-layer:missing-items-page","Missing items url");const{data:c}=await e(l.href,{signal:a.signal,query:{limit:s,...a.customParameters,token:a.apiKey},headers:{accept:"application/geo+json"}});await p(c);const d=m(c,{geometryType:r.geometryType}),u=r.fields||d.fields||[],f=null!=r.hasZ?r.hasZ:d.hasZ,h=d.geometryType,j=r.objectIdField||d.objectIdFieldName||"OBJECTID";let F=r.timeInfo;const I=u.find((e=>e.name===j));if(!I){if(!d.objectIdFieldType)throw new t("ogc-feature-layer:missing-feature-id","Collection geojson require a feature id as a unique identifier");u.unshift({name:j,alias:j,type:"esriFieldTypeOID",editable:!1,nullable:!1})}else I.type="esriFieldTypeOID",I.editable=!1,I.nullable=!1;if(j!==d.objectIdFieldName){const e=u.find((e=>e.name===d.objectIdFieldName));e&&(e.type="esriFieldTypeInteger")}u===d.fields&&d.unknownFields.length>0&&b.warn({name:"ogc-feature-layer:unknown-field-types",message:"Some fields types couldn't be inferred from the features and were dropped",details:{unknownFields:d.unknownFields}});for(const e of u){if(null==e.name&&(e.name=e.alias),null==e.alias&&(e.alias=e.name),"esriFieldTypeOID"!==e.type&&"esriFieldTypeGlobalID"!==e.type&&(e.editable=null==e.editable||!!e.editable,e.nullable=null==e.nullable||!!e.nullable),!e.name)throw new t("ogc-feature-layer:invalid-field-name","field name is missing",{field:e});if(!w.jsonValues.includes(e.type))throw new t("ogc-feature-layer:invalid-field-type",`invalid type for field "${e.name}"`,{field:e})}if(F){const e=new y(u);if(F.startTimeField){const t=e.get(F.startTimeField);t?(F.startTimeField=t.name,t.type="esriFieldTypeDate"):F.startTimeField=null}if(F.endTimeField){const t=e.get(F.endTimeField);t?(F.endTimeField=t.name,t.type="esriFieldTypeDate"):F.endTimeField=null}if(F.trackIdField){const t=e.get(F.trackIdField);t?F.trackIdField=t.name:(F.trackIdField=null,b.warn({name:"ogc-feature-layer:invalid-timeInfo-trackIdField",message:"trackIdField is missing",details:{timeInfo:F}}))}F.startTimeField||F.endTimeField||(b.warn({name:"ogc-feature-layer:invalid-timeInfo",message:"startTimeField and endTimeField are missing",details:{timeInfo:F}}),F=null)}return{drawingInfo:h?g(h):null,geometryType:h,fields:u,hasZ:!!f,objectIdField:j,timeInfo:F}}async function T(i,r={}){const{links:a}=i,s=G(a,"data","application/json")||G(a,"http://www.opengis.net/def/rel/ogc/1.0/data","application/json");if(n(s))throw new t("ogc-feature-layer:missing-collections-page","Missing collections url");const{apiKey:o,customParameters:l,signal:c}=r,{data:d}=await e(s.href,{signal:c,headers:{accept:"application/json"},query:{...l,token:o}});return d}async function k(i,r={}){const{links:a}=i,s=G(a,"conformance","application/json")||G(a,"http://www.opengis.net/def/rel/ogc/1.0/conformance","application/json");if(n(s))throw new t("ogc-feature-layer:missing-conformance-page","Missing conformance url");const{apiKey:o,customParameters:l,signal:c}=r,{data:d}=await e(s.href,{signal:c,headers:{accept:"application/json"},query:{...l,token:o}});return d}async function S(t,i={}){const{apiKey:n,customParameters:r,signal:a}=i,{data:s}=await e(t,{signal:a,headers:{accept:"application/json"},query:{...r,token:n}});return s}async function x(t,i={}){const r="application/vnd.oai.openapi+json;version=3.0",a=G(t.links,"service-desc",r);if(n(a))return b.warn("ogc-feature-layer:missing-openapi-page","The OGC API-Features server does not have an OpenAPI page."),null;const{apiKey:s,customParameters:o,signal:l}=i,{data:c}=await e(a.href,{signal:l,headers:{accept:r},query:{...o,token:s}});return c}function v(e){const t=/^http:\/\/www\.opengis.net\/def\/crs\/(?<authority>.*)\/(?<version>.*)\/(?<code>.*)$/i.exec(e),i=null==t?void 0:t.groups;if(!i)return null;const{authority:n,code:r}=i;switch(n.toLowerCase()){case"ogc":switch(r.toLowerCase()){case"crs27":return h.GCS_NAD_1927.wkid;case"crs83":return 4269;case"crs84":case"crs84h":return h.WGS84.wkid;default:return null}case"esri":case"epsg":{const e=Number.parseInt(r,10);return Number.isNaN(e)?null:e}default:return null}}async function N(e,t,i){const n=await q(e,t,i);return l(n)}async function q(i,l,p){const{capabilities:{query:{maxRecordCount:m}},collection:g,layerDefinition:y,queryParameters:{apiKey:w,customParameters:b},spatialReference:j,supportedCrs:F}=i,{links:I}=g,T=G(I,"items","application/geo+json")||G(I,"http://www.opengis.net/def/rel/ogc/1.0/items","application/geo+json");if(n(T))throw new t("ogc-feature-layer:missing-items-page","Missing items url");const{geometry:k,num:S,start:x,timeExtent:v,where:N}=l;if(l.objectIds)throw new t("ogc-feature-layer:query-by-objectids-not-supported","Queries with objectids are not supported");const q=h.fromJSON(j),M=r(l.outSpatialReference,q),C=M.isWGS84?null:O(M,F),P=D(k,F),W=R(v),Z=$(N),K=null!=S?S:null!=x&&void 0!==x?10:m,{data:L}=await e(T.href,{...p,query:{...b,...P,crs:C,datetime:W,query:Z,limit:K,startindex:x,token:w},headers:{accept:"application/geo+json"}});let A=!1;if(L.links){const e=L.links.find((e=>"next"===e.rel));A=!!e}!A&&Number.isInteger(L.numberMatched)&&Number.isInteger(L.numberReturned)&&(A=L.numberReturned<L.numberMatched);const{fields:E,globalIdField:J,hasM:U,hasZ:_,objectIdField:z}=y,B=y.geometryType,Q=f(L,{geometryType:B,hasZ:_,objectIdField:z});if(!C&&M.isWebMercator)for(const e of Q)if(a(e.geometry)){const t=c(e.geometry,B,_,!1);t.spatialReference=h.WGS84,e.geometry=d(o(t,M))}for(const e of Q)e.objectId=e.attributes[z];const V=C||!C&&M.isWebMercator?M.toJSON():s,H=new u;return H.exceededTransferLimit=A,H.features=Q,H.fields=E,H.geometryType=B,H.globalIdFieldName=J,H.hasM=U,H.hasZ=_,H.objectIdFieldName=z,H.spatialReference=V,H}function M(e){return a(e)&&"extent"===e.type}function O(e,t){var i,n,r;const{isWebMercator:a,wkid:s}=e;if(!s)return null;const o=a?null!=(i=null!=(n=null!=(r=t[3857])?r:t[102100])?n:t[102113])?i:t[900913]:t[e.wkid];return o?`${j}${o}`:null}function C(e){if(n(e))return"";const{xmin:t,ymin:i,xmax:r,ymax:a}=e;return`${t},${i},${r},${a}`}function R(e){if(n(e))return null;const{start:t,end:i}=e;return`${a(t)?t.toISOString():".."}/${a(i)?i.toISOString():".."}`}function $(e){return n(e)||!e||"1=1"===e?null:e}function D(e,t){if(!M(e))return null;const{spatialReference:i}=e;if(!i||i.isWGS84)return{bbox:C(e)};const n=O(i,t);return a(n)?{bbox:C(e),"bbox-crs":n}:i.isWebMercator?{bbox:C(o(e,h.WGS84))}:null}function G(e,t,i){return e.find((e=>e.rel===t&&e.type===i))||e.find((e=>e.rel===t&&!e.type))}export{F as crsDefault,j as crsPrefix,I as getCollectionDefinition,T as getServerCollections,k as getServerConformance,S as getServerLandingPage,x as getServerOpenApi,v as getSpatialReferenceWkid,N as queryFeatureSetJSON,q as queryOptimizedFeatureSet};