@arcgis/core 5.0.0-next.3 → 5.0.0-next.5

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 (363) hide show
  1. package/Map.js +1 -1
  2. package/analysis/ElevationProfileAnalysis.js +1 -1
  3. package/analysis/VolumeMeasurement/volumeMeasurementConfiguration.js +1 -1
  4. package/applications/KnowledgeStudio/generalSdkInternalAccess.d.ts +4 -0
  5. package/applications/KnowledgeStudio/generalSdkInternalAccess.js +5 -0
  6. package/applications/KnowledgeStudio/generalSharedKgUtils.d.ts +1 -0
  7. package/applications/KnowledgeStudio/generalSharedKgUtils.js +1 -1
  8. package/applications/KnowledgeStudio/layerInternalAccessUtils.d.ts +2 -0
  9. package/applications/KnowledgeStudio/layerInternalAccessUtils.js +1 -1
  10. package/applications/KnowledgeStudio/resourceSerializationUtils.js +1 -1
  11. package/assets/components/assets/sort-handle/t9n/messages.uk.json +1 -1
  12. package/assets/esri/core/workers/RemoteClient.js +1 -1
  13. package/assets/esri/core/workers/chunks/0366b78b0ccf4ed5f6ac.js +1 -0
  14. package/assets/esri/core/workers/chunks/037b2548bf85e2d7c6ac.js +1 -0
  15. package/assets/esri/core/workers/chunks/{c0feec6e2f0e45900ae0.js → 0686243904381ef863dc.js} +1 -1
  16. package/assets/esri/core/workers/chunks/06ba43843e9c4988049b.js +1 -0
  17. package/assets/esri/core/workers/chunks/0f100e163e1847e04155.js +1 -0
  18. package/assets/esri/core/workers/chunks/{388482cea4b9fdeaf06e.js → 0f30a9514571c7be9978.js} +1 -1
  19. package/assets/esri/core/workers/chunks/0f8847f9ae3068833fa4.js +1 -0
  20. package/assets/esri/core/workers/chunks/{14ace5dc4b8984212a57.js → 17d5f8dba6ebb1184506.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{b2add7338258ca7c24dd.js → 1da74aa308ded5748ef5.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{651b9144abb1895cc510.js → 1e848d9da1c61a27cf18.js} +1 -1
  23. package/assets/esri/core/workers/chunks/1eedac33c9fcd7681427.js +1 -0
  24. package/assets/esri/core/workers/chunks/239377336a2009caea01.js +1 -0
  25. package/assets/esri/core/workers/chunks/285762ff92d5388b6024.js +1 -0
  26. package/assets/esri/core/workers/chunks/{40b81d1c2d53cf598b8e.js → 2f03d33f4ca8a48461fc.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{4f01be74dd26e639330f.js → 2f24017e72d41c259faa.js} +1 -1
  28. package/assets/esri/core/workers/chunks/3271614322ba4b44fb5a.js +1 -0
  29. package/assets/esri/core/workers/chunks/36b1f47d70b57d79df7b.js +1 -0
  30. package/assets/esri/core/workers/chunks/{3d65b8a2fbe1df050a25.js → 377a66034e7c1bad5599.js} +1 -1
  31. package/assets/esri/core/workers/chunks/37f2ef14399546e697e6.js +1 -0
  32. package/assets/esri/core/workers/chunks/{0f9bb3187306f89e3d63.js → 398f356b11fd33bd3831.js} +1 -1
  33. package/assets/esri/core/workers/chunks/3a457e718a901a45902e.js.LICENSE.txt +1 -1
  34. package/assets/esri/core/workers/chunks/4442817beb7a76c95770.js +1 -0
  35. package/assets/esri/core/workers/chunks/4c5a7249a311070d8f43.js +1 -0
  36. package/assets/esri/core/workers/chunks/551c6c89b51b99f4864b.js +1 -0
  37. package/assets/esri/core/workers/chunks/{9a723d739ac44b45432c.js → 557960763695abee4a83.js} +1 -1
  38. package/assets/esri/core/workers/chunks/655360995c1cbc78a5a3.js +1 -0
  39. package/assets/esri/core/workers/chunks/67d9cfe02613cb73ee37.js.LICENSE.txt +1 -1
  40. package/assets/esri/core/workers/chunks/6a69dafeb7c9ca8a3d84.js +1 -0
  41. package/assets/esri/core/workers/chunks/6c3b99209d542efa64d4.js +1 -0
  42. package/assets/esri/core/workers/chunks/{8215015f11221a354273.js → 6d049182bec34a22abcd.js} +1 -1
  43. package/assets/esri/core/workers/chunks/71762199aef5d3107da2.js +1 -0
  44. package/assets/esri/core/workers/chunks/72c851c400752094b162.js +1 -0
  45. package/assets/esri/core/workers/chunks/7558919912f7fdc4837b.js +1 -0
  46. package/assets/esri/core/workers/chunks/7596d005a4dc3964b140.js +1 -0
  47. package/assets/esri/core/workers/chunks/762fe93015b705546188.js +1 -0
  48. package/assets/esri/core/workers/chunks/79dbfa2b9b332ca0002f.js +1 -0
  49. package/assets/esri/core/workers/chunks/7a23ab84e1144f081c92.js +1 -0
  50. package/assets/esri/core/workers/chunks/{2a5f331c0f18d8574b4e.js → 811d4c46c75cf6a63e78.js} +1 -1
  51. package/assets/esri/core/workers/chunks/829bc5dbda2f51561446.js +1 -0
  52. package/assets/esri/core/workers/chunks/8372f142c4d7a65c7954.js +1 -0
  53. package/assets/esri/core/workers/chunks/8605ec4678eb4511c715.js +1 -0
  54. package/assets/esri/core/workers/chunks/883ffaa69b3e6eb158bf.js +1 -0
  55. package/assets/esri/core/workers/chunks/{3d22fe2f2c40abbc246e.js → 88d942cd25bef74fd50a.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{0086a09441627842d34a.js → 8f3503b2fb6cd38757b9.js} +1 -1
  57. package/assets/esri/core/workers/chunks/9786f91455350eaae493.js +1 -0
  58. package/assets/esri/core/workers/chunks/98311fec6c16a1b23586.js +1 -0
  59. package/assets/esri/core/workers/chunks/9c5cbf8810f37b1a4718.js +1 -0
  60. package/assets/esri/core/workers/chunks/a091623bbfb3d771c8d8.js +1 -0
  61. package/assets/esri/core/workers/chunks/a137c27ce078bea44f89.js +1 -0
  62. package/assets/esri/core/workers/chunks/a29d7205394cb8b2a847.js +1 -0
  63. package/assets/esri/core/workers/chunks/a2a284d4dd5caaecbc2e.js +1 -0
  64. package/assets/esri/core/workers/chunks/{135e270b4f03c4270870.js → a4db5c9a90107e097df8.js} +1 -1
  65. package/assets/esri/core/workers/chunks/a61cb4f1ca282bf8b75d.js +1 -0
  66. package/assets/esri/core/workers/chunks/a6ac1ff89c40f3a4797a.js +1 -0
  67. package/assets/esri/core/workers/chunks/{dc31865edea480f0ebba.js → a8c4fd779e454e4075c4.js} +1 -1
  68. package/assets/esri/core/workers/chunks/a8f998b8ec8c56150479.js.LICENSE.txt +1 -1
  69. package/assets/esri/core/workers/chunks/aa6eb55e4fb57c4e8eeb.js +1 -0
  70. package/assets/esri/core/workers/chunks/aa78b69219d9a0ef1c54.js.LICENSE.txt +1 -1
  71. package/assets/esri/core/workers/chunks/af3fc2562bb6d217adf6.js +1 -0
  72. package/assets/esri/core/workers/chunks/{46ef545d2b3b3f4e6d32.js → b017bac40dc8328013e3.js} +2 -2
  73. package/assets/esri/core/workers/chunks/{46ef545d2b3b3f4e6d32.js.LICENSE.txt → b017bac40dc8328013e3.js.LICENSE.txt} +1 -1
  74. package/assets/esri/core/workers/chunks/b59f9c3f7a149214256f.js +1 -0
  75. package/assets/esri/core/workers/chunks/b96eb0ea506379182d62.js +2 -0
  76. package/assets/esri/core/workers/chunks/{24921d31efa8d222ad2d.js.LICENSE.txt → b96eb0ea506379182d62.js.LICENSE.txt} +1 -1
  77. package/assets/esri/core/workers/chunks/{b5863afafd3a7d2d5c05.js → bb5484b5eeacc9ad2ceb.js} +3 -3
  78. package/assets/esri/core/workers/chunks/bb56717c4e36f28d4c08.js +1 -0
  79. package/assets/esri/core/workers/chunks/bb7976e2f883b544add6.js +1 -0
  80. package/assets/esri/core/workers/chunks/c0b7e86860838638537f.js +1 -0
  81. package/assets/esri/core/workers/chunks/c134ebbaeac514cbd657.js +1 -0
  82. package/assets/esri/core/workers/chunks/c2b47a7dc961863d283f.js +1 -0
  83. package/assets/esri/core/workers/chunks/{0eaa4dccba0d844b9da3.js → c3ddcf9148dd2640c402.js} +1 -1
  84. package/assets/esri/core/workers/chunks/c476643002387f60ea42.js +1 -0
  85. package/assets/esri/core/workers/chunks/ce16489cf7eb0d78c741.js.LICENSE.txt +1 -1
  86. package/assets/esri/core/workers/chunks/d048e4926e78458afa3e.js +1 -0
  87. package/assets/esri/core/workers/chunks/d39a10155317e6f7a21c.js +1 -0
  88. package/assets/esri/core/workers/chunks/d6e0528eacee7ea4c1ce.js.LICENSE.txt +1 -1
  89. package/assets/esri/core/workers/chunks/d886fb97bdb348a16f25.js +1 -0
  90. package/assets/esri/core/workers/chunks/{00aa85ae6419aad183ea.js → dc4982b0ac007bd70213.js} +1 -1
  91. package/assets/esri/core/workers/chunks/e1258b6a404e58878c7a.js +1 -0
  92. package/assets/esri/core/workers/chunks/e31192ae920e3e19b6aa.js +1 -0
  93. package/assets/esri/core/workers/chunks/e6a86cad44056735ed26.js +1 -0
  94. package/assets/esri/core/workers/chunks/e82f5437bd66779c6740.js +1 -0
  95. package/assets/esri/core/workers/chunks/{039ec0fbe3b4b398b8c6.js → f26dc1d83beed63b6045.js} +1 -1
  96. package/assets/esri/core/workers/chunks/{fa5c87889c2f0bef896b.js → f35aaa04cca676c2d3f8.js} +1 -1
  97. package/assets/esri/core/workers/chunks/f5b7e7f2860a825ed373.js +1 -0
  98. package/assets/esri/core/workers/chunks/f651c05604eab83aef5f.js.LICENSE.txt +1 -1
  99. package/assets/esri/core/workers/chunks/{18da83afbc324fef9fd8.js → f779034623980bf9a37c.js} +2 -2
  100. package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
  101. package/assets/esri/themes/base/widgets/_Directions.scss +17 -18
  102. package/assets/esri/themes/dark/main.css +1 -1
  103. package/assets/esri/themes/light/main.css +1 -1
  104. package/assets/esri/themes/light/view.css +1 -1
  105. package/chunks/ComponentShader.glsl.js +72 -39
  106. package/chunks/OITBlend.glsl.js +3 -3
  107. package/chunks/bundle.js +1 -1
  108. package/config.js +1 -1
  109. package/core/QueueProcessor.js +1 -1
  110. package/core/has.js +1 -1
  111. package/core/sanitizerUtils.js +1 -1
  112. package/core/workers/Connection.js +1 -1
  113. package/core/workers/WorkerHandle.js +1 -1
  114. package/core/workers/utils.js +1 -1
  115. package/geohash/GeohashCell.js +1 -1
  116. package/geohash/geohashUtils.js +1 -1
  117. package/geometry/GeometryCursor.js +1 -1
  118. package/geometry/geometryCursorCollectUtils.js +1 -1
  119. package/geometry/libtess.js +1 -1
  120. package/geometry/support/jsonUtils.js +1 -1
  121. package/geometry/support/normalizeUtilsSync.js +1 -1
  122. package/geometry/support/triangulationUtils.js +1 -1
  123. package/interfaces.d.ts +426 -347
  124. package/intl/date.js +1 -1
  125. package/intl.d.ts +2 -0
  126. package/intl.js +1 -1
  127. package/kernel.js +1 -1
  128. package/layers/FeatureLayer.js +1 -1
  129. package/layers/graphics/OptimizedFeature.js +1 -1
  130. package/layers/graphics/OptimizedGeometry.js +1 -1
  131. package/layers/graphics/centroid.js +1 -1
  132. package/layers/graphics/contains.js +1 -1
  133. package/layers/graphics/data/AttributesBuilder.js +1 -1
  134. package/layers/graphics/data/FeatureStore.js +1 -1
  135. package/layers/graphics/data/QueryEngine.js +1 -1
  136. package/layers/graphics/data/QueryEngineResult.js +1 -1
  137. package/layers/graphics/data/geometryUtils.js +1 -1
  138. package/layers/graphics/data/spatialQuerySupport.js +1 -1
  139. package/layers/graphics/featureConversionUtils.js +1 -1
  140. package/layers/graphics/sources/OGCFeatureSource.js +1 -1
  141. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  142. package/layers/graphics/sources/geojson/geojson.js +1 -1
  143. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  144. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  145. package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
  146. package/layers/knowledgeGraph/layerUtils.js +1 -1
  147. package/layers/mixins/ArcGISImageService.js +1 -1
  148. package/layers/mixins/ImageryTileMixin.js +1 -1
  149. package/layers/support/PixelBlock.js +1 -1
  150. package/layers/support/RasterInfo.js +1 -1
  151. package/layers/support/RasterJobHandler.js +1 -1
  152. package/layers/support/RasterSensorInfo.js +1 -1
  153. package/layers/support/RasterStorageInfo.js +1 -1
  154. package/layers/support/RasterWorker.js +1 -1
  155. package/layers/support/TitleCreator.js +1 -1
  156. package/layers/support/arcgisLayerUrl.js +1 -1
  157. package/layers/support/capabilities.js +1 -1
  158. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  159. package/layers/support/rasterDatasets/pixelReader.js +1 -1
  160. package/layers/support/rasterFieldUtils.js +1 -1
  161. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  162. package/layers/support/serviceCapabilitiesUtils.js +1 -1
  163. package/package.json +5 -5
  164. package/request.js +1 -1
  165. package/rest/print.js +1 -1
  166. package/rest/query/operations/pbfDehydratedFeatureSet.js +1 -1
  167. package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
  168. package/rest/query/operations/query.js +1 -1
  169. package/rest/query/operations/queryZScale.js +1 -1
  170. package/rest/versionManagement/getVersionInfos.js +1 -1
  171. package/smartMapping/statistics/histogram.js +1 -1
  172. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  173. package/smartMapping/support/utils.js +1 -1
  174. package/support/elevationInfoUtils.js +1 -1
  175. package/support/requestImageUtils.js +1 -1
  176. package/support/revision.js +1 -1
  177. package/views/2d/GoToManager.js +1 -1
  178. package/views/2d/analysis/ElevationProfile/ElevationProfileLineVisualization2D.js +1 -1
  179. package/views/2d/engine/vectorTiles/shaders/sources/shaderRepository.js +1 -1
  180. package/views/2d/engine/webgl/Mesh2D.js +1 -1
  181. package/views/2d/engine/webgl/brushes/WGLBrushVTLSymbol.js +1 -1
  182. package/views/2d/engine/webgl/mesh/templates/templateUtils.js +1 -1
  183. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
  184. package/views/2d/engine/webgl/shaderGraph/techniques/fill/AFillMeshWriter.js +1 -1
  185. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  186. package/views/2d/layers/features/aggregation/GridCell.js +1 -1
  187. package/views/2d/layers/features/processor/AAggregateStrategy.js +1 -1
  188. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  189. package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
  190. package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
  191. package/views/2d/layers/features/schema/SourceSchema.js +1 -1
  192. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  193. package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
  194. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
  195. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  196. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  197. package/views/2d/layers/features/support/FeatureFilterEvaluator.js +1 -1
  198. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  199. package/views/2d/layers/features/support/FeatureSetReaderIndirect.js +1 -1
  200. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  201. package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
  202. package/views/2d/layers/features/support/GraphicsReader.js +1 -1
  203. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  204. package/views/3d/FocusAreasView.js +1 -1
  205. package/views/3d/GroundView3D.js +1 -1
  206. package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +1 -1
  207. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  208. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  209. package/views/3d/glTF/DefaultLoadingContext.js +1 -1
  210. package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
  211. package/views/3d/layers/FlowSubView3D.js +1 -1
  212. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  213. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  214. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  215. package/views/3d/layers/graphics/Graphics3DFeatureStore.js +1 -1
  216. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  217. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  218. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  219. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  220. package/views/3d/layers/graphics/pipeline/featureSet/PBFPointFeatureSetView.js +1 -1
  221. package/views/3d/layers/graphics/pipeline/featureSet/TiledFeatureStore.js +1 -1
  222. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  223. package/views/3d/layers/i3s/I3SQueryFeatureAdapter.js +1 -1
  224. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  225. package/views/3d/layers/support/FeatureTileFetcher3DContext.js +1 -1
  226. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  227. package/views/3d/layers/support/featureTileQuery3D.js +1 -1
  228. package/views/3d/state/ViewStateManager.js +1 -1
  229. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  230. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  231. package/views/3d/state/controllers/RotateController.js +1 -1
  232. package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
  233. package/views/3d/state/controllers/ZoomControllerLocal.js +1 -1
  234. package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
  235. package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
  236. package/views/3d/state/utils/navigationUtils.js +1 -1
  237. package/views/3d/support/DisplayQualityProfile.js +1 -1
  238. package/views/3d/support/QualitySettings.js +1 -1
  239. package/views/3d/support/StreamDataLoader.js +1 -1
  240. package/views/3d/support/engineContent/line.js +1 -1
  241. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  242. package/views/3d/support/flow/FlowWorker.js +1 -1
  243. package/views/3d/support/flow/StreamlineResources3D.js +1 -1
  244. package/views/3d/support/flow/constants.js +1 -1
  245. package/views/3d/support/hitTest.js +1 -1
  246. package/views/3d/support/renderInfoUtils/polygon.js +1 -1
  247. package/views/3d/terrain/Tile.js +1 -1
  248. package/views/3d/terrain/TileOverlayData.js +1 -1
  249. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  250. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  251. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  252. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  253. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
  254. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +7 -7
  255. package/views/3d/webgl-engine/core/shaderModules/BooleanDrawUniform.js +5 -0
  256. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechniqueConstructionContext.js +1 -1
  257. package/views/3d/webgl-engine/lib/CutFillDepth.js +1 -1
  258. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  259. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  260. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  261. package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +4 -4
  262. package/views/analysis/ElevationProfile/ElevationProfileController.js +1 -1
  263. package/views/analysis/ElevationProfile/ElevationProfileLineInputComputation.js +1 -1
  264. package/views/analysis/ElevationProfile/ElevationProfileResult.js +1 -1
  265. package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
  266. package/views/analysis/ElevationProfile/elevationProfileGenerationUtils.js +1 -1
  267. package/views/draw/support/Reshape.js +1 -1
  268. package/views/draw/support/reshapeUtils.js +1 -1
  269. package/views/interactive/dragEventPipeline.js +1 -1
  270. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js +1 -1
  271. package/views/webgl/ShaderBuilder.js +1 -1
  272. package/views/webgl/Texture.js +1 -1
  273. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  274. package/widgets/BatchAttributeForm.js +1 -1
  275. package/widgets/Directions/css.js +1 -1
  276. package/widgets/Directions.js +1 -1
  277. package/widgets/Editor/AddAssociationWorkflow.js +1 -1
  278. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  279. package/widgets/Editor/EditorViewModel.js +1 -1
  280. package/widgets/Editor/Edits.js +1 -1
  281. package/widgets/Editor/MergeFeaturesWorkflow.d.ts +4 -0
  282. package/widgets/Editor/MergeFeaturesWorkflow.js +5 -0
  283. package/widgets/Editor/MergeFeaturesWorkflowData.d.ts +4 -0
  284. package/widgets/Editor/MergeFeaturesWorkflowData.js +5 -0
  285. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  286. package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
  287. package/widgets/Editor/UpdateFeaturesWorkflowData.js +1 -1
  288. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  289. package/widgets/Editor/components/UploadDetails.js +1 -1
  290. package/widgets/Editor/support/EditorItem.js +1 -1
  291. package/widgets/Editor/support/mergeFeaturesUtils.js +5 -0
  292. package/widgets/Editor/workflowUtils.js +1 -1
  293. package/widgets/Editor.js +1 -1
  294. package/widgets/Feature/FeatureExpression.js +1 -1
  295. package/widgets/Feature/FeatureFields/FeatureFieldsViewModel.js +1 -1
  296. package/widgets/Feature/FeatureFields.js +1 -1
  297. package/widgets/Feature/FeatureMedia/FeatureMediaViewModel.js +1 -1
  298. package/widgets/Feature/FeatureMedia.js +1 -1
  299. package/widgets/Feature/FeatureViewModel.js +1 -1
  300. package/widgets/Feature/support/featureUtils.js +1 -1
  301. package/widgets/Feature.js +1 -1
  302. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  303. package/widgets/OrientedImageryViewer/components/SequentialNavigationUI.js +1 -1
  304. package/widgets/OrientedImageryViewer/components/SketchTools.js +1 -1
  305. package/widgets/Print.js +1 -1
  306. package/widgets/support/ColorPicker.js +1 -1
  307. package/widgets/support/SelectionList/LayerItem.js +1 -1
  308. package/widgets/support/jsxWidgetSupport.js +1 -1
  309. package/assets/esri/core/workers/chunks/065f2bbcaeef1f13fd48.js +0 -1
  310. package/assets/esri/core/workers/chunks/0731e588afd1f561ec3b.js +0 -1
  311. package/assets/esri/core/workers/chunks/188272af9a6470ccfe31.js +0 -1
  312. package/assets/esri/core/workers/chunks/1a9f544f20f643161a36.js +0 -1
  313. package/assets/esri/core/workers/chunks/1cfcadaa98ac528fea37.js +0 -1
  314. package/assets/esri/core/workers/chunks/1db0bf570a04687b3130.js +0 -1
  315. package/assets/esri/core/workers/chunks/24921d31efa8d222ad2d.js +0 -2
  316. package/assets/esri/core/workers/chunks/2a900a632a1231deb713.js +0 -1
  317. package/assets/esri/core/workers/chunks/31c6e951b99315e8e68a.js +0 -1
  318. package/assets/esri/core/workers/chunks/35491fbdd287470d40a4.js +0 -1
  319. package/assets/esri/core/workers/chunks/36247c6f6fc2891df2cf.js +0 -1
  320. package/assets/esri/core/workers/chunks/3d53307efbc3f07d7bf2.js +0 -1
  321. package/assets/esri/core/workers/chunks/42a72e1d963e4636323b.js +0 -1
  322. package/assets/esri/core/workers/chunks/456161a323be7d640c61.js +0 -1
  323. package/assets/esri/core/workers/chunks/500d09d2191127371081.js +0 -1
  324. package/assets/esri/core/workers/chunks/5707713c2f27588b9194.js +0 -1
  325. package/assets/esri/core/workers/chunks/5713f96bade5ebb54c81.js +0 -1
  326. package/assets/esri/core/workers/chunks/5718cf135e105e1e026b.js +0 -1
  327. package/assets/esri/core/workers/chunks/5c585b338a9e9aa0e205.js +0 -1
  328. package/assets/esri/core/workers/chunks/5d1d909354c90cb8eb60.js +0 -1
  329. package/assets/esri/core/workers/chunks/5ea03f53d4d64d9e7cae.js +0 -1
  330. package/assets/esri/core/workers/chunks/63019a7eb5222dc5e420.js +0 -1
  331. package/assets/esri/core/workers/chunks/64629ddcf008349eaf41.js +0 -1
  332. package/assets/esri/core/workers/chunks/64ee8d2acae2d6fce608.js +0 -1
  333. package/assets/esri/core/workers/chunks/6fcacfcb3d83515c37c9.js +0 -1
  334. package/assets/esri/core/workers/chunks/72ecf49d03bb24bf0998.js +0 -1
  335. package/assets/esri/core/workers/chunks/7421f9575487cdc9e28e.js +0 -1
  336. package/assets/esri/core/workers/chunks/77a11d7d53325d108ed8.js +0 -1
  337. package/assets/esri/core/workers/chunks/7a05b1f6163112bc9db2.js +0 -1
  338. package/assets/esri/core/workers/chunks/7d9882ddfa6495f72baa.js +0 -1
  339. package/assets/esri/core/workers/chunks/7fffad8ff6878fa1fd56.js +0 -1
  340. package/assets/esri/core/workers/chunks/81bbe5251ed13c0d91cc.js +0 -1
  341. package/assets/esri/core/workers/chunks/8b16aa50d879b92a5375.js +0 -1
  342. package/assets/esri/core/workers/chunks/8bc64fc7c4b9eb8fca4d.js +0 -1
  343. package/assets/esri/core/workers/chunks/8bfa19c24be0e3f3fd74.js +0 -1
  344. package/assets/esri/core/workers/chunks/8eefa133c36a004c054c.js +0 -1
  345. package/assets/esri/core/workers/chunks/9834bc11586a2d8d6f35.js +0 -1
  346. package/assets/esri/core/workers/chunks/9c6fc4fe2c46f40d63d9.js +0 -1
  347. package/assets/esri/core/workers/chunks/a5f25104938ab33e7a85.js +0 -1
  348. package/assets/esri/core/workers/chunks/a7bd294996e6c8b8354a.js +0 -1
  349. package/assets/esri/core/workers/chunks/abf4f018c692c18c3320.js +0 -1
  350. package/assets/esri/core/workers/chunks/b1f667006cba60ef4aa7.js +0 -1
  351. package/assets/esri/core/workers/chunks/b2d9f4e057af26a538fb.js +0 -1
  352. package/assets/esri/core/workers/chunks/b62807c6fcfb70a87cd4.js +0 -1
  353. package/assets/esri/core/workers/chunks/b8339c1d60847a9eed3e.js +0 -1
  354. package/assets/esri/core/workers/chunks/c362fbbafec91c44eeb2.js +0 -1
  355. package/assets/esri/core/workers/chunks/c941d15190fc08523d0d.js +0 -1
  356. package/assets/esri/core/workers/chunks/cc70a4a915b0b2ccb2a0.js +0 -1
  357. package/assets/esri/core/workers/chunks/d121045cddbe55c2ecb2.js +0 -1
  358. package/assets/esri/core/workers/chunks/d2120a623b1bd91b9ed9.js +0 -1
  359. package/assets/esri/core/workers/chunks/d78c2833cdc4730a88a3.js +0 -1
  360. package/assets/esri/core/workers/chunks/df438b62702007267798.js +0 -1
  361. package/assets/esri/core/workers/chunks/f4eb090bcc3eca64306a.js +0 -1
  362. package/assets/esri/core/workers/chunks/f7846523adacbfe5047e.js +0 -1
  363. package/assets/esri/core/workers/chunks/f839b86bee15deaf84e4.js +0 -1
package/intl/date.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{strict as t}from"../core/jsonMap.js";import{beforeLocaleChange as e,getLocaleLanguage as o,normalizeLocale as n}from"./locale.js";import{unknown as r,utc as a,system as m,systemTimeZone as h}from"../time/constants.js";import{shortTimeZoneName as i}from"../time/timeZoneUtils.js";import{DateTime as s}from"luxon";const l={year:void 0,month:void 0,day:void 0,weekday:void 0},y={hour:void 0,minute:void 0,second:void 0},d={timeZone:a},g={year:"numeric",month:"numeric",day:"numeric"},u={year:"numeric",month:"long",day:"numeric"},c={year:"numeric",month:"short",day:"numeric"},D={year:"numeric",month:"long",weekday:"long",day:"numeric"},f={hour:"numeric",minute:"numeric"},T={...f,second:"numeric"},S={hourCycle:"h23"},L={...f,...S},w={...T,...S},M={"short-date":g,"short-date-short-time":{...g,...f},"short-date-short-time-24":{...g,...L},"short-date-long-time":{...g,...T},"short-date-long-time-24":{...g,...w},"short-date-le":g,"short-date-le-short-time":{...g,...f},"short-date-le-short-time-24":{...g,...L},"short-date-le-long-time":{...g,...T},"short-date-le-long-time-24":{...g,...w},"long-month-day-year":u,"long-month-day-year-short-time":{...u,...f},"long-month-day-year-short-time-24":{...u,...L},"long-month-day-year-long-time":{...u,...T},"long-month-day-year-long-time-24":{...u,...w},"day-short-month-year":c,"day-short-month-year-short-time":{...c,...f},"day-short-month-year-short-time-24":{...c,...L},"day-short-month-year-long-time":{...c,...T},"day-short-month-year-long-time-24":{...c,...w},"long-date":D,"long-date-short-time":{...D,...f},"long-date-short-time-24":{...D,...L},"long-date-long-time":{...D,...T},"long-date-long-time-24":{...D,...w},"long-month-year":{month:"long",year:"numeric"},"short-month-year":{month:"short",year:"numeric"},year:{year:"numeric"},"short-time":f,"long-time":T},Y=t()({shortDate:"short-date",shortDateShortTime:"short-date-short-time",shortDateShortTime24:"short-date-short-time-24",shortDateLongTime:"short-date-long-time",shortDateLongTime24:"short-date-long-time-24",shortDateLE:"short-date-le",shortDateLEShortTime:"short-date-le-short-time",shortDateLEShortTime24:"short-date-le-short-time-24",shortDateLELongTime:"short-date-le-long-time",shortDateLELongTime24:"short-date-le-long-time-24",longMonthDayYear:"long-month-day-year",longMonthDayYearShortTime:"long-month-day-year-short-time",longMonthDayYearShortTime24:"long-month-day-year-short-time-24",longMonthDayYearLongTime:"long-month-day-year-long-time",longMonthDayYearLongTime24:"long-month-day-year-long-time-24",dayShortMonthYear:"day-short-month-year",dayShortMonthYearShortTime:"day-short-month-year-short-time",dayShortMonthYearShortTime24:"day-short-month-year-short-time-24",dayShortMonthYearLongTime:"day-short-month-year-long-time",dayShortMonthYearLongTime24:"day-short-month-year-long-time-24",longDate:"long-date",longDateShortTime:"long-date-short-time",longDateShortTime24:"long-date-short-time-24",longDateLongTime:"long-date-long-time",longDateLongTime24:"long-date-long-time-24",longMonthYear:"long-month-year",shortMonthYear:"short-month-year",year:"year"}),Z={ar:"ar-u-nu-latn-ca-gregory",nn:"no-NN"},p=new Intl.DateTimeFormat("bs",{month:"long"}).formatToParts(new Date(2025,2)),v=p.find(({type:t})=>"month"===t)?.value.toLowerCase();function j(){const t=o();return(t&&Z[t])??n()}"mart"!==v&&(Z.bs="sr-Latn-CS");let E=new WeakMap;const k=M["short-date-short-time"],I=M["short-date"];function N(t){let e=E.get(t);if(!e){const o=j(),n=O(t.timeZone??m),r={...t,timeZone:n};e=new Intl.DateTimeFormat(o,r),E.set(t,e)}return e}function C(t){return M[t]}function F(t){const{dateStyle:e,timeStyle:o,hour12:n,year:r,month:a}=t,m={};return e?m.dateStyle=e:r&&(m.year=r,m.month=a||void 0),o&&!m.year&&(m.timeStyle=o,m.hour12="auto"===n?void 0:"always"===n),m}function b(t,e=k){return N(e).format(t)}function x(t,e=k){return b(new Date(t),{...e,...d,...y})}function P(t,e=k){return b(new Date(`1970-01-01T${t}Z`),{...e,...d,...l})}function W(t,e=k){if(e.timeZone)return b(new Date(t),e);const o=s.fromISO(t,{setZone:!0}),n=0===o.offset?a:e.timeZone,r={...e,timeZone:n};return o.toLocaleString(r,{locale:j()})}function O(t){switch(t){case m:return h;case r:return a;default:return t}}function U(t,e){return new Intl.DateTimeFormat(j(),e).formatToParts(t)}function $(t,e=new Date){return U(e,{timeZone:t,timeZoneName:i}).find(({type:t})=>"timeZoneName"===t)?.value}e(()=>{E=new WeakMap});export{C as convertDateFormatToIntlOptions,F as convertDateTimeFieldFormatToIntlOptions,Y as dateFormatJSONMap,k as defaultFormatterOptions,I as defaultFormatterOptionsNoTime,b as formatDate,x as formatDateOnly,P as formatTimeOnly,W as formatTimestamp,N as getDateTimeFormatter,$ as getShortOffsetTimeZoneSuffix,O as resolveTimeZone};
5
+ import{strict as t}from"../core/jsonMap.js";import{beforeLocaleChange as e,getLocaleLanguage as o,normalizeLocale as n}from"./locale.js";import{unknown as r,utc as a,system as m,systemTimeZone as h}from"../time/constants.js";import{shortTimeZoneName as i}from"../time/timeZoneUtils.js";import{DateTime as s}from"luxon";const l={dateStyle:void 0,year:void 0,month:void 0,day:void 0,weekday:void 0},y={timeStyle:void 0,hour12:void 0,hourCycle:void 0,hour:void 0,minute:void 0,second:void 0},d={timeZone:a},g={year:"numeric",month:"numeric",day:"numeric"},u={year:"numeric",month:"long",day:"numeric"},c={year:"numeric",month:"short",day:"numeric"},D={year:"numeric",month:"long",weekday:"long",day:"numeric"},f={hour:"numeric",minute:"numeric"},T={...f,second:"numeric"},S={hourCycle:"h23"},L={...f,...S},v={...T,...S},w={"short-date":g,"short-date-short-time":{...g,...f},"short-date-short-time-24":{...g,...L},"short-date-long-time":{...g,...T},"short-date-long-time-24":{...g,...v},"short-date-le":g,"short-date-le-short-time":{...g,...f},"short-date-le-short-time-24":{...g,...L},"short-date-le-long-time":{...g,...T},"short-date-le-long-time-24":{...g,...v},"long-month-day-year":u,"long-month-day-year-short-time":{...u,...f},"long-month-day-year-short-time-24":{...u,...L},"long-month-day-year-long-time":{...u,...T},"long-month-day-year-long-time-24":{...u,...v},"day-short-month-year":c,"day-short-month-year-short-time":{...c,...f},"day-short-month-year-short-time-24":{...c,...L},"day-short-month-year-long-time":{...c,...T},"day-short-month-year-long-time-24":{...c,...v},"long-date":D,"long-date-short-time":{...D,...f},"long-date-short-time-24":{...D,...L},"long-date-long-time":{...D,...T},"long-date-long-time-24":{...D,...v},"long-month-year":{month:"long",year:"numeric"},"short-month-year":{month:"short",year:"numeric"},year:{year:"numeric"},"short-time":f,"long-time":T},M=t()({shortDate:"short-date",shortDateShortTime:"short-date-short-time",shortDateShortTime24:"short-date-short-time-24",shortDateLongTime:"short-date-long-time",shortDateLongTime24:"short-date-long-time-24",shortDateLE:"short-date-le",shortDateLEShortTime:"short-date-le-short-time",shortDateLEShortTime24:"short-date-le-short-time-24",shortDateLELongTime:"short-date-le-long-time",shortDateLELongTime24:"short-date-le-long-time-24",longMonthDayYear:"long-month-day-year",longMonthDayYearShortTime:"long-month-day-year-short-time",longMonthDayYearShortTime24:"long-month-day-year-short-time-24",longMonthDayYearLongTime:"long-month-day-year-long-time",longMonthDayYearLongTime24:"long-month-day-year-long-time-24",dayShortMonthYear:"day-short-month-year",dayShortMonthYearShortTime:"day-short-month-year-short-time",dayShortMonthYearShortTime24:"day-short-month-year-short-time-24",dayShortMonthYearLongTime:"day-short-month-year-long-time",dayShortMonthYearLongTime24:"day-short-month-year-long-time-24",longDate:"long-date",longDateShortTime:"long-date-short-time",longDateShortTime24:"long-date-short-time-24",longDateLongTime:"long-date-long-time",longDateLongTime24:"long-date-long-time-24",longMonthYear:"long-month-year",shortMonthYear:"short-month-year",year:"year"}),Y={ar:"ar-u-nu-latn-ca-gregory",nn:"no-NN"},Z=new Intl.DateTimeFormat("bs",{month:"long"}).formatToParts(new Date(2025,2)),p=Z.find(({type:t})=>"month"===t)?.value.toLowerCase();function j(){const t=o();return(t&&Y[t])??n()}"mart"!==p&&(Y.bs="sr-Latn-CS");let E=new WeakMap;const k=w["short-date-short-time"],C=w["short-date"];function I(t){let e=E.get(t);if(!e){const o=j(),n=O(t.timeZone??m),r={...t,timeZone:n};e=new Intl.DateTimeFormat(o,r),E.set(t,e)}return e}function N(t){return w[t]}function F(t){const{dateStyle:e,timeStyle:o,hour12:n,year:r,month:a}=t,m={};return e?m.dateStyle=e:r&&(m.year=r,m.month=a||void 0),o&&!m.year&&(m.timeStyle=o,m.hour12="auto"===n?void 0:"always"===n),m}function b(t,e=k){return I(e).format(t)}function x(t,e=k){return b(new Date(t),{...e,...d,...y})}function P(t,e=k){return b(new Date(`1970-01-01T${t}Z`),{...e,...d,...l})}function W(t,e=k){if(e.timeZone)return b(new Date(t),e);const o=s.fromISO(t,{setZone:!0}),n=0===o.offset?a:e.timeZone,r={...e,timeZone:n};return o.toLocaleString(r,{locale:j()})}function O(t){switch(t){case m:return h;case r:return a;default:return t}}function U(t,e){return new Intl.DateTimeFormat(j(),e).formatToParts(t)}function $(t,e=new Date){return U(e,{timeZone:t,timeZoneName:i}).find(({type:t})=>"timeZoneName"===t)?.value}e(()=>{E=new WeakMap});export{N as convertDateFormatToIntlOptions,F as convertDateTimeFieldFormatToIntlOptions,M as dateFormatJSONMap,k as defaultFormatterOptions,C as defaultFormatterOptionsNoTime,b as formatDate,x as formatDateOnly,P as formatTimeOnly,W as formatTimestamp,I as getDateTimeFormatter,$ as getShortOffsetTimeZoneSuffix,O as resolveTimeZone};
package/intl.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import "./interfaces";
2
2
 
3
3
  export const convertDateFormatToIntlOptions: __esri.intl["convertDateFormatToIntlOptions"];
4
+ export const convertDateTimeFieldFormatToIntlOptions: __esri.intl["convertDateTimeFieldFormatToIntlOptions"];
5
+ export const convertNumberFieldFormatToIntlOptions: __esri.intl["convertNumberFieldFormatToIntlOptions"];
4
6
  export const convertNumberFormatToIntlOptions: __esri.intl["convertNumberFormatToIntlOptions"];
5
7
  export const createJSONLoader: __esri.intl["createJSONLoader"];
6
8
  export const fetchMessageBundle: __esri.intl["fetchMessageBundle"];
package/intl.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- export{convertDateFormatToIntlOptions,formatDate,formatDateOnly,formatTimeOnly,formatTimestamp}from"./intl/date.js";export{convertNumberFormatToIntlOptions,formatNumber}from"./intl/number.js";export{substitute}from"./intl/substitute.js";export{getLocale,getLocaleLanguage,onLocaleChange,prefersRTL,setLocale}from"./intl/locale.js";import{registerMessageBundleLoader as t}from"./intl/messages.js";export{fetchMessageBundle,normalizeMessageBundleLocale}from"./intl/messages.js";import{createJSONLoader as e}from"./intl/t9n.js";import{getAssetUrl as o}from"./assets.js";t(e({pattern:"esri/",location:o}));export{e as createJSONLoader,t as registerMessageBundleLoader};
5
+ export{convertDateFormatToIntlOptions,convertDateTimeFieldFormatToIntlOptions,formatDate,formatDateOnly,formatTimeOnly,formatTimestamp}from"./intl/date.js";export{convertNumberFieldFormatToIntlOptions,convertNumberFormatToIntlOptions,formatNumber}from"./intl/number.js";export{substitute}from"./intl/substitute.js";export{getLocale,getLocaleLanguage,onLocaleChange,prefersRTL,setLocale}from"./intl/locale.js";import{registerMessageBundleLoader as t}from"./intl/messages.js";export{fetchMessageBundle,normalizeMessageBundleLocale}from"./intl/messages.js";import{createJSONLoader as e}from"./intl/t9n.js";import{getAssetUrl as o}from"./assets.js";t(e({pattern:"esri/",location:o}));export{e as createJSONLoader,t as registerMessageBundleLoader};
package/kernel.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="5.0";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="5.0.0-next.3",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,r as fullVersion,s as id,i as setId,e as version};
5
+ import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="5.0";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="5.0.0-next.5",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,r as fullVersion,s as id,i as setId,e as version};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../PopupTemplate.js";import r from"../request.js";import{ClonableMixin as i}from"../core/Clonable.js";import o from"../core/Collection.js";import s from"../core/Error.js";import{clone as a}from"../core/lang.js";import n from"../core/Logger.js";import{destroyMaybe as l}from"../core/maybe.js";import{MultiOriginJSONMixin as p}from"../core/MultiOriginJSONSupport.js";import{setDeepValue as u}from"../core/object.js";import{debounce as d,throwIfAbortError as y,whenOrAbort as c}from"../core/promiseUtils.js";import{sqlAnd as m}from"../core/sql.js";import{property as f}from"../core/accessorSupport/decorators/property.js";import{cast as h}from"../core/accessorSupport/decorators/cast.js";import{reader as b}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import{writer as w}from"../core/accessorSupport/decorators/writer.js";import{excludeTables as v}from"../core/accessorSupport/layerContainerType.js";import F from"../form/FormTemplate.js";import T from"../geometry/SpatialReference.js";import j from"../graphic/FeatureGraphicOrigin.js";import S from"./Layer.js";import{MemorySource as I}from"./graphics/sources/MemorySource.js";import{APIKeyMixin as E}from"./mixins/APIKeyMixin.js";import{ArcGISService as L}from"./mixins/ArcGISService.js";import{BlendLayer as D}from"./mixins/BlendLayer.js";import{CustomParametersMixin as C}from"./mixins/CustomParametersMixin.js";import{DisplayFilteredLayer as _}from"./mixins/DisplayFilteredLayer.js";import{EditBusLayer as P}from"./mixins/EditBusLayer.js";import{FeatureEffectLayer as x}from"./mixins/FeatureEffectLayer.js";import{FeatureLayerBase as O}from"./mixins/FeatureLayerBase.js";import{FeatureReductionLayer as q}from"./mixins/FeatureReductionLayer.js";import{OperationalLayer as M}from"./mixins/OperationalLayer.js";import{OrderedLayer as A}from"./mixins/OrderedLayer.js";import{PortalLayer as Q}from"./mixins/PortalLayer.js";import{PublishableLayer as R}from"./mixins/PublishableLayer.js";import{RefreshableLayer as U}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as V}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as N}from"./mixins/TemporalLayer.js";import{TrackableLayer as B}from"./mixins/TrackableLayer.js";import{titleFromUrlAndName as G,parse as J,cleanTitle as $}from"./support/arcgisLayerUrl.js";import{attributeTableTemplate as W,id as Z,labelsVisible as H,opacityDrawingInfo as z,legendEnabled as k,listMode as K,popupEnabled as X,screenSizePerspectiveEnabled as Y}from"./support/commonProperties.js";import{ensureLayerCredential as ee,computeEffectiveEditingEnabled as te,readGlobalIdField as re,readObjectIdField as ie,createDefaultRenderer as oe,addAttachment as se,updateAttachment as ae,applyEdits as ne,uploadAssets as le,createQuery as pe,deleteAttachments as ue,fetchRecomputedExtents as de,getFeatureType as ye,getFieldDomain as ce,queryAttachments as me,queryObjectIds as fe,queryFeatureCount as he,queryExtent as be,queryRelatedFeatures as ge,queryRelatedFeaturesCount as we,validateBinsQuery as ve,hasDataChanged as Fe,geometryTypeKebabDict as Te}from"./support/featureLayerUtils.js";import je from"./support/FeatureTemplate.js";import Se from"./support/FeatureType.js";import Ie from"./support/FieldConfiguration.js";import{popupTemplateWithFieldConfigurations as Ee,fieldConfigurationsFromPopupTemplate as Le,fieldConfigurationsFromFields as De}from"./support/fieldConfigUtils.js";import{defineFieldProperties as Ce}from"./support/fieldProperties.js";import{fixRendererFields as _e,fixTimeInfoFields as Pe}from"./support/fieldUtils.js";import xe from"./support/LabelClass.js";import{reader as Oe}from"./support/labelingInfo.js";import{getFeatureLayerCapabilities as qe}from"./support/serviceCapabilitiesUtils.js";import Me from"./support/TimeInfo.js";import Ae from"./support/TitleCreator.js";import{serviceSupportsSpatialReference as Qe}from"./support/versionUtils.js";import{DataLayerSource as Re}from"./support/source/DataLayerSource.js";import{read as Ue}from"../renderers/support/jsonUtils.js";import{loadStyleRenderer as Ve}from"../renderers/support/styleUtils.js";import{webSceneRendererTypes as Ne,rendererTypes as Be}from"../renderers/support/typeUtils.js";import Ge from"../rest/support/FeatureSet.js";import Je from"../rest/support/Query.js";import{isNumber as $e}from"../support/guards.js";import{createPopupTemplate as We}from"../support/popupUtils.js";import{symbolTypes as Ze}from"../symbols/support/typeUtils.js";import{opacityToTransparency as He}from"../webdoc/support/opacityUtils.js";const ze="FeatureLayer";function ke(e,t){return new s("layer:unsupported",`Layer (${e.title}, ${e.id}) of type '${e.declaredClass}' ${t}`,{layer:e})}function Ke(e){return e&&e instanceof o}const Xe=Ce();function Ye(e,t,r){const i=!!r?.writeLayerSchema;return{enabled:i,ignoreOrigin:i}}let et=class extends(O(q(x(R(P(_(D(A(N(B(V(U(L(M(Q(p(C(E(i(S)))))))))))))))))))){constructor(...e){super(...e),this.attributeTableTemplate=null,this.charts=null,this.copyright=null,this.displayField=null,this.dynamicDataSource=null,this.fields=null,this.fieldsIndex=null,this.formTemplate=null,this.fullExtent=null,this.geometryType=null,this.graphicOrigin=new j(this),this.hasM=void 0,this.hasZ=void 0,this.infoFor3D=null,this.isTable=!1,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.objectIdField=null,this.operationalLayerType="ArcGISFeatureLayer",this.outFields=null,this.path=null,this.popupEnabled=!0,this.popupTemplate=null,this.resourceInfo=null,this.screenSizePerspectiveEnabled=!0,this.spatialReference=T.WGS84,this.subtypeCode=null,this.supportedSourceTypes=new Set(["Feature Layer","Oriented Imagery Layer","Table","Catalog Layer"]),this.templates=null,this.timeInfo=null,this.title=null,this.sublayerTitleMode="item-title",this.type="feature",this.typeIdField=null,this.types=null,this.visible=!0,this._debouncedSaveOperations=d(async(e,t,r)=>{const{save:i,saveAs:o}=await import("./save/featureLayerUtils.js");switch(e){case 0:return i(this,t);case 1:return o(this,r,t)}})}destroy(){this.source?.destroy()}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){const t=null!=e?e.signal:null;if(this.portalItem?.loaded&&this.source)return this.addResolvingPromise(this.createGraphicsSource(t).then(e=>this.initLayerProperties(e))),Promise.resolve(this);const r=this.loadFromPortal({supportedTypes:["Feature Service","Feature Collection","Scene Service"]},e).catch(y).then(async()=>{if(this.url&&null==this.layerId&&/FeatureServer|MapServer\/*$/i.test(this.url)){const e=await this._fetchFirstValidLayerId(t);null!=e&&(this.layerId=e)}if(!this.url&&!this._hasMemorySource())throw new s("feature-layer:missing-url-or-source","Feature layer must be created with either a url or a source");return this.initLayerProperties(await this.createGraphicsSource(t))}).then(()=>ee(this,"load",e));return this.addResolvingPromise(r),Promise.resolve(this)}get _titleCreator(){const e=this._get("_titleCreator");return l(e),new Ae({fieldsIndex:this.fieldsIndex,objectIdField:this.objectIdField,fields:this.fields,displayField:this.displayField,effectivePopupTemplate:this.popupTemplate??this.defaultPopupTemplate})}readCapabilities(e,t){return t=t.layerDefinition||t,qe(t,this.url)}get createQueryVersion(){return this.commitProperty("definitionExpression"),this.commitProperty("dynamicDataSource"),this.commitProperty("timeExtent"),this.commitProperty("timeOffset"),this.commitProperty("geometryType"),this.commitProperty("gdbVersion"),this.commitProperty("historicMoment"),this.commitProperty("returnZ"),this.commitProperty("capabilities"),this.commitProperty("returnM"),(this._get("createQueryVersion")??0)+1}get editingEnabled(){return!(this.loaded&&!this.capabilities?.operations.supportsEditing)&&(this._isOverridden("editingEnabled")?this._get("editingEnabled"):this._hasMemorySource()||this.userHasEditingPrivileges)}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}readEditingEnabled(e,t){return this._readEditingEnabled(t,!1)}readEditingEnabledFromWebMap(e,t,r){return this._readEditingEnabled(t,!0,r)}writeEditingEnabled(e,t){this._writeEditingEnabled(e,t,!1)}writeEditingEnabledToWebMap(e,t,r,i){this._writeEditingEnabled(e,t,!0,i)}get effectiveEditingEnabled(){return te(this)}get featureTitleFields(){return[...this._titleCreator.requiredFields]}set fieldConfigurations(e){if(this._hasMemorySource())return;if(this._override("fieldConfigurations",e),!this.loaded)return;const t=Ee(this,e);t&&this._set("popupTemplate",t)}get fieldConfigurations(){if(!this._hasMemorySource())return this._isOverridden("fieldConfigurations")?this._get("fieldConfigurations"):Le(this)||null}get defaultFieldConfigurations(){return De(this)}readIsTable(e,t){return"Table"===(t=t?.layerDefinition??t).type||!t.geometryType}writeIsTable(e,t,r,i){i?.writeLayerSchema&&u(r,e?"Table":"Feature Layer",t)}readGlobalIdField(e,t){return re(t.layerDefinition||t)}readObjectIdField(e,t){return ie(t.layerDefinition||t)}writePopupTemplate(e,t,r,i){e&&(t[r]=e.toJSON({...i,writeFieldFormat:!i?.writeLayerSchema}))}get defaultPopupTemplate(){return this.createPopupTemplate()}set renderer(e){_e(e,this.fieldsIndex),this._set("renderer",e)}readRenderer(e,t,r){t=t.layerDefinition||t;const i=t.drawingInfo?.renderer;if(i){const e=Ue(i,t,r)??void 0;return e||n.getLogger(this).error("Failed to create renderer",{rendererDefinition:t.drawingInfo.renderer,layer:this,context:r}),e}return oe(t,r)}set source(e){const t=this._get("source");t!==e&&(Ke(t)&&this._resetMemorySource(t),Ke(e)&&this._initMemorySource(e),this._set("source",e))}castSource(e){return e?Array.isArray(e)||e instanceof o?new I({layer:this,items:e}):e:null}readSource(e,t){const r=Ge.fromJSON(t.featureSet);return new I({layer:this,items:r?.features??[]})}readTemplates(e,t){const r=t.editFieldsInfo,i=r?.creatorField,o=r?.editorField;return e=e?.map(e=>je.fromJSON(e)),this._fixTemplates(e,i),this._fixTemplates(e,o),e}readTitle(e,t){const r=t.layerDefinition?.name??t.name,i=t.title||t.layerDefinition?.title;if(r){const e=this.portalItem?.title;if("item-title"===this.sublayerTitleMode)return this.url?G(this.url,r):r;let t=r;if(!t&&this.url){const e=J(this.url);null!=e&&(t=e.title)}if(!t)return;return"item-title-and-service-name"===this.sublayerTitleMode&&e&&e!==t&&(t=e+" - "+t),$(t)}if("item-title"===this.sublayerTitleMode&&i)return i}readTitleFromWebMap(e,t){return t.title||t.layerDefinition?.name}readTypeIdField(e,t){let r=(t=t.layerDefinition||t).typeIdField;if(r&&t.fields){r=r.toLowerCase();const e=t.fields.find(e=>e.name.toLowerCase()===r);e&&(r=e.name)}return r}readTypes(e,t){e=(t=t.layerDefinition||t).types;const r=t.editFieldsInfo,i=r?.creatorField,o=r?.editorField;return e?.map(e=>(e=Se.fromJSON(e),this._fixTemplates(e.templates,i),this._fixTemplates(e.templates,o),e))}readVisible(e,t){return null!=t.layerDefinition?.defaultVisibility?!!t.layerDefinition.defaultVisibility:null!=t.visibility?!!t.visibility:void 0}async addAttachment(e,t){const r=await se(this,e,t,ze);return this.lastEditsEventDate=new Date,r}async updateAttachment(e,t,r){const i=await ae(this,e,t,r,ze);return this.lastEditsEventDate=new Date,i}async applyEdits(e,t){return ne(this,e,t)}async uploadAssets(e,t){return le(this,e,t)}createPopupTemplate(e){return We(this,e)}async createGraphicsSource(e){if(this._hasMemorySource()&&this.source)return this.source.load({signal:e});const{default:t}=await c(import("./graphics/sources/FeatureLayerSource.js"),e);return new t({layer:this,supportedSourceTypes:this.supportedSourceTypes}).load({signal:e})}createQuery(){const e=pe(this);e.dynamicDataSource=this.dynamicDataSource;const t=null!=this.subtypeCode?`${this.subtypeField} = ${this.subtypeCode}`:null,r=m(this.definitionExpression,t);return e.where=r||"1=1",e}async deleteAttachments(e,t){const r=await ue(this,e,t,ze);return this.lastEditsEventDate=new Date,r}async fetchRecomputedExtents(e){return de(this,e,ze)}async getFeatureTitle(e,t){return this._titleCreator.getTitle(this,e,t)}async getFeatureTitles(e,t){return this._titleCreator.getTitles(this,e,t)}getFeatureType(e){return ye(this.types,this.typeIdField,e)}getFieldAlias(e){const t=this.getField(e);if(t)return this.getFieldConfiguration(t.name)?.alias||t.alias}getFieldConfiguration(e){return e=e.toLowerCase(),this.fieldConfigurations?.find(t=>t.name.toLowerCase()===e)}getFieldDomain(e,t){return ce(this,e,t,this.getField(e)?.domain??null)}async queryAttachments(e,t){return me(this,e,t,ze)}async queryFeatures(e,t){const r=await this.load(),i=await r.source.queryFeatures(Je.from(e)??r.createQuery(),t),o=this.graphicOrigin;if(i?.features)for(const s of i.features)s.layer=s.sourceLayer=r,s.origin=o;return i}async queryObjectIds(e,t){return await fe(this,e,t,ze)}async queryFeatureCount(e,t){return he(this,e,t,ze)}async queryExtent(e,t){return be(this,e,t,ze)}async queryRelatedFeatures(e,t){return ge(this,e,t,ze)}async queryRelatedFeaturesCount(e,t){return we(this,e,t,ze)}async queryPivot(e,t){const{source:r}=await this.load();if(!r.queryPivot)throw new s(ze,"Layer source does not support queryPivot capability");const i=await import("../rest/support/PivotQuery.js"),o=await r.queryPivot(i.default.from(e),t);if(o?.features)for(const s of o.features)s.layer=s.sourceLayer=this;return o}async queryTopFeatures(e,t){const{source:r,capabilities:i}=await this.load();if(!r.queryTopFeatures||!i?.query?.supportsTopFeaturesQuery)throw new s(ze,"Layer source does not support queryTopFeatures capability");const o=await import("../rest/support/TopFeaturesQuery.js"),a=await r.queryTopFeatures(o.default.from(e),t);if(a?.features)for(const s of a.features)s.layer=s.sourceLayer=this;return a}async queryAttributeBins(e,t){const{source:r,capabilities:i}=await this.load();if(!r.queryAttributeBins)throw new s(ze,"Layer source does not support queryAttributeBins capability");ve(e,i,ze);const o=await import("../rest/support/AttributeBinsQuery.js"),a=await r.queryAttributeBins(o.default.from(e),t);if(a.features)for(const s of a.features)s.layer=s.sourceLayer=this;return a}async queryTopObjectIds(e,t){const{source:r,capabilities:i}=await this.load();if(!r.queryTopObjectIds||!i?.query.supportsTopFeaturesQuery)throw new s(ze,"Layer source does not support queryTopObjectIds capability");const o=await import("../rest/support/TopFeaturesQuery.js");return(await r.queryTopObjectIds(o.default.from(e),t)).filter($e)}async queryTopFeaturesExtent(e,t){const{source:r,capabilities:i}=await this.load();if(!r.queryTopExtents||!i?.query?.supportsTopFeaturesQuery)throw new s(ze,"Layer source does not support queryTopExtents capability");const o=await import("../rest/support/TopFeaturesQuery.js");return r.queryTopExtents(o.default.from(e),t)}async queryTopFeatureCount(e,t){const{source:r,capabilities:i}=await this.load();if(!r.queryTopCount||!i?.query?.supportsTopFeaturesQuery)throw new s(ze,"Layer source does not support queryFeatureCount capability");const o=await import("../rest/support/TopFeaturesQuery.js");return r.queryTopCount(o.default.from(e),t)}read(e,t){const r=e.featureCollection;if((r||"Feature Collection"===e.type)&&(this.resourceInfo=e),r){const{layers:e,showLegend:i}=r;1===e?.length&&(super.read(e[0],t),null!=i&&super.read({showLegend:i},t))}super.read(e,t),t&&"service"===t.origin&&(this.revert(["objectIdField","fields","timeInfo","dateFieldsTimeZone"],"service"),this.spatialReference||this.revert(["spatialReference"],"service"))}write(e,t){t={...t,origin:t?.origin??void 0,writeLayerSchema:t?.writeLayerSchema??this._hasMemorySource()};const{origin:r,layerContainerType:i,messages:o}=t;if(this.dynamicDataSource)return o?.push(ke(this,"using a dynamic data source cannot be written to web scenes, web maps and feature service items")),null;if(this.isTable){if(("web-map"===r||"web-scene"===r)&&"tables"!==i)return o?.push(ke(this,`a table source can only be written to tables, not ${i}`)),null;if(this._hasMemorySource())return o?.push(ke(this,"using an in-memory table source cannot be written to web scenes and web maps")),null}else if(this.loaded&&("web-map"===r||"web-scene"===r)&&"tables"===i)return o?.push(ke(this,"using a non-table source cannot be written to tables in web maps or web scenes")),null;return super.write(e,t)}clone(){if(this._hasMemorySource())throw new s(ze,`FeatureLayer (title: ${this.title}, id: ${this.id}) created using in-memory source cannot be cloned`);return super.clone()}serviceSupportsSpatialReference(e){return!!this.loaded&&("memory"===this.source?.type||Qe(this,e))}async save(e){return this._debouncedSaveOperations(0,e)}async saveAs(e,t){return this._debouncedSaveOperations(1,t,e)}_readEditingEnabled(e,t,r){let i=e.layerDefinition?.capabilities;return i?this._hasEditingCapability(i):(i=e.capabilities,t&&"web-map"===r?.origin&&!this._hasMemorySource()&&i?this._hasEditingCapability(i):void 0)}_hasEditingCapability(e){return e.toLowerCase().split(",").map(e=>e.trim()).includes("editing")}_writeEditingEnabled(e,t,r,i){if(!e){const e=this.capabilities?.operations?.supportsSync?"Query,Sync":"Query";u("layerDefinition.capabilities",e,t),r&&!i?.writeLayerSchema&&(t.capabilities=e)}}_fetchFirstValidLayerId(e){return r(this.url??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e}).then(e=>{const t=e.data;if(t)return this.applyPreferredHost(t),this.findFirstValidLayerId(t)})}async initLayerProperties(e){return this._set("source",e),e.sourceJSON&&(this.sourceJSON=e.sourceJSON,this.read(e.sourceJSON,{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl})),this._verifySource(),this._verifyFields(),_e(this.renderer,this.fieldsIndex),Pe(this.timeInfo,this.fieldsIndex),this._hasMemorySource()&&"mesh"===this.geometryType&&(this.capabilities.query.supportsReturnMesh=!0),Ve(this,{origin:"service"})}async hasDataChanged(){return Fe(this)}async fetchPublishingStatus(){const e=this.source;return e?.fetchPublishingStatus?e.fetchPublishingStatus():"unavailable"}_verifyFields(){const e=this.parsedUrl?.path??"undefined";this.objectIdField||console.log("FeatureLayer: 'objectIdField' property is not defined (url: "+e+")"),this.isTable||this._hasMemorySource()||-1!==e.search(/\/FeatureServer\//i)||this.fields?.some(e=>"geometry"===e.type)||console.log("FeatureLayer: unable to find field of type 'geometry' in the layer 'fields' list. If you are using a map service layer, features will not have geometry (url: "+e+")")}_fixTemplates(e,t){e&&e.forEach(e=>{const r=e.prototype?.attributes;r&&t&&delete r[t]})}_verifySource(){if(this._hasMemorySource()){if(this.url)throw new s("feature-layer:mixed-source-and-url","FeatureLayer cannot be created with both an in-memory source and a url")}else if(!this.url)throw new s("feature-layer:source-or-url-required","FeatureLayer requires either a url, a valid portal item or a source")}_initMemorySource(e){e.forEach(e=>{e.layer=this,e.sourceLayer=this}),this.addHandles([e.on("after-add",e=>{e.item.layer=this,e.item.sourceLayer=this}),e.on("after-remove",e=>{e.item.layer=null,e.item.sourceLayer=null})],"fl-source")}_resetMemorySource(e){e.forEach(e=>{e.layer=null,e.sourceLayer=null}),this.removeHandles("fl-source")}_hasMemorySource(){return!(this.url||!this.source)}findFirstValidLayerId(e){return Array.isArray(e.layers)&&e.layers.length>0?e.layers[0].id:Array.isArray(e.tables)&&e.tables.length>0?e.tables[0].id:void 0}};e([f({clonable:!1,readOnly:!0})],et.prototype,"_titleCreator",null),e([f(W)],et.prototype,"attributeTableTemplate",void 0),e([b("service","capabilities")],et.prototype,"readCapabilities",null),e([f({json:{origins:{"web-scene":{write:!1}},write:!0}})],et.prototype,"charts",void 0),e([f({readOnly:!0})],et.prototype,"createQueryVersion",null),e([f({json:{read:{source:"layerDefinition.copyrightText"}}})],et.prototype,"copyright",void 0),e([f({json:{read:{source:"layerDefinition.displayField"}}})],et.prototype,"displayField",void 0),e([f({types:Ze,readOnly:!0})],et.prototype,"defaultSymbol",void 0),e([f({type:Re})],et.prototype,"dynamicDataSource",void 0),e([f({type:Boolean})],et.prototype,"editingEnabled",null),e([b(["portal-item","web-scene"],"editingEnabled",["layerDefinition.capabilities"])],et.prototype,"readEditingEnabled",null),e([b("web-map","editingEnabled",["capabilities","layerDefinition.capabilities"])],et.prototype,"readEditingEnabledFromWebMap",null),e([w(["portal-item","web-scene"],"editingEnabled",{"layerDefinition.capabilities":{type:String}})],et.prototype,"writeEditingEnabled",null),e([w("web-map","editingEnabled",{capabilities:{type:String},"layerDefinition.capabilities":{type:String}})],et.prototype,"writeEditingEnabledToWebMap",null),e([f({readOnly:!0})],et.prototype,"effectiveEditingEnabled",null),e([f({clonable:!1,readOnly:!0})],et.prototype,"featureTitleFields",null),e([f({type:[Ie],json:{name:"layerDefinition.fieldConfigurations",write:{overridePolicy:(e,t,r)=>({enabled:!r?.writeLayerSchema})}}})],et.prototype,"fieldConfigurations",null),e([f({readOnly:!0})],et.prototype,"defaultFieldConfigurations",null),e([f({...Xe.fields,json:{read:{source:"layerDefinition.fields"},origins:{service:{name:"fields"},"web-map":{write:{target:"layerDefinition.fields",overridePolicy:Ye}}}}})],et.prototype,"fields",void 0),e([f(Xe.fieldsIndex)],et.prototype,"fieldsIndex",void 0),e([f({type:F,json:{name:"formInfo",write:!0,origins:{"web-scene":{read:!1,write:!1}}}})],et.prototype,"formTemplate",void 0),e([f({json:{read:{source:"layerDefinition.extent"}}})],et.prototype,"fullExtent",void 0),e([f({json:{origins:{"web-map":{write:{target:"layerDefinition.geometryType",overridePolicy:Ye,writer(e,t,r){const i=e?Te.toJSON(e):null;i&&u(r,i,t)}}}},read:{source:"layerDefinition.geometryType",reader:Te.read}}})],et.prototype,"geometryType",void 0),e([f({readOnly:!0,clonable:!1})],et.prototype,"graphicOrigin",void 0),e([f({json:{read:{source:"layerDefinition.hasM"}}})],et.prototype,"hasM",void 0),e([f({json:{read:{source:"layerDefinition.hasZ"}}})],et.prototype,"hasZ",void 0),e([f(Z)],et.prototype,"id",void 0),e([f({readOnly:!0,json:{origins:{service:{read:!0}},read:!1}})],et.prototype,"infoFor3D",void 0),e([f({json:{origins:{"web-map":{write:{target:"layerDefinition.type"}}}}})],et.prototype,"isTable",void 0),e([b("service","isTable",["type","geometryType"]),b("isTable",["layerDefinition.type","layerDefinition.geometryType"])],et.prototype,"readIsTable",null),e([w("web-map","isTable")],et.prototype,"writeIsTable",null),e([f(H)],et.prototype,"labelsVisible",void 0),e([f({type:[xe],json:{origins:{service:{name:"drawingInfo.labelingInfo",read:Oe,write:!1}},name:"layerDefinition.drawingInfo.labelingInfo",read:Oe,write:{layerContainerTypes:v}}})],et.prototype,"labelingInfo",void 0),e([f((()=>{const e=a(z);return e.json.origins["portal-item"]={write:{target:"layerDefinition.drawingInfo.transparency",writer(e,t,r){u(r,He(e),t)}}},e})())],et.prototype,"opacity",void 0),e([f(k)],et.prototype,"legendEnabled",void 0),e([f({type:["show","hide"],json:(()=>{const e=a(K.json);return e.origins["portal-item"]={read:!1,write:!1},e})()})],et.prototype,"listMode",void 0),e([b("globalIdField",["layerDefinition.globalIdField","layerDefinition.fields"])],et.prototype,"readGlobalIdField",null),e([f({json:{origins:{"web-map":{write:{target:"layerDefinition.objectIdField",overridePolicy:Ye}}}}})],et.prototype,"objectIdField",void 0),e([b("objectIdField",["layerDefinition.objectIdField","layerDefinition.fields"])],et.prototype,"readObjectIdField",null),e([f({type:["ArcGISFeatureLayer"],json:{write:{target:"layerType",ignoreOrigin:!0,layerContainerTypes:v}}})],et.prototype,"operationalLayerType",void 0),e([f(Xe.outFields)],et.prototype,"outFields",void 0),e([f({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],et.prototype,"path",void 0),e([f(X)],et.prototype,"popupEnabled",void 0),e([f({type:t,json:{name:"popupInfo",write:!0}})],et.prototype,"popupTemplate",void 0),e([w("popupTemplate")],et.prototype,"writePopupTemplate",null),e([f({readOnly:!0})],et.prototype,"defaultPopupTemplate",null),e([f({types:Be,json:{origins:{service:{write:{target:"drawingInfo.renderer",enabled:!1}},"web-scene":{types:Ne,name:"layerDefinition.drawingInfo.renderer",write:{layerContainerTypes:v,overridePolicy:(e,t,r)=>({ignoreOrigin:r?.writeLayerSchema,layerContainerTypes:v})}}},write:{target:"layerDefinition.drawingInfo.renderer",overridePolicy:(e,t,r)=>({ignoreOrigin:r?.writeLayerSchema,layerContainerTypes:v})}}})],et.prototype,"renderer",null),e([b("service","renderer",["drawingInfo.renderer","defaultSymbol"]),b("renderer",["layerDefinition.drawingInfo.renderer","layerDefinition.defaultSymbol"])],et.prototype,"readRenderer",null),e([f()],et.prototype,"resourceInfo",void 0),e([f((()=>{const e=a(Y);return e.json.origins["portal-item"]={read:!1,write:!1},e})())],et.prototype,"screenSizePerspectiveEnabled",void 0),e([f({clonable:!1})],et.prototype,"source",null),e([h("source")],et.prototype,"castSource",null),e([b("portal-item","source",["featureSet"]),b("web-map","source",["featureSet"])],et.prototype,"readSource",null),e([f({json:{read:{source:"layerDefinition.extent.spatialReference"}}})],et.prototype,"spatialReference",void 0),e([f({type:Number})],et.prototype,"subtypeCode",void 0),e([f({type:[je]})],et.prototype,"templates",void 0),e([b("templates",["editFieldsInfo","creatorField","editorField","templates"])],et.prototype,"readTemplates",null),e([f({type:Me})],et.prototype,"timeInfo",void 0),e([f()],et.prototype,"title",void 0),e([b("service","title",["name"]),b("portal-item","title",["layerDefinition.title","layerDefinition.name","title"])],et.prototype,"readTitle",null),e([b("web-map","title",["layerDefinition.name","title"])],et.prototype,"readTitleFromWebMap",null),e([f({type:String})],et.prototype,"sublayerTitleMode",void 0),e([f({json:{read:!1}})],et.prototype,"type",void 0),e([f({type:String})],et.prototype,"typeIdField",void 0),e([b("service","typeIdField"),b("typeIdField",["layerDefinition.typeIdField"])],et.prototype,"readTypeIdField",null),e([f({type:[Se]})],et.prototype,"types",void 0),e([b("service","types",["types"]),b("types",["layerDefinition.types"])],et.prototype,"readTypes",null),e([f({type:Boolean,json:{origins:{"portal-item":{write:{target:"layerDefinition.defaultVisibility",layerContainerTypes:v}}}}})],et.prototype,"visible",void 0),e([b("portal-item","visible",["visibility","layerDefinition.defaultVisibility"])],et.prototype,"readVisible",null),et=e([g("esri.layers.FeatureLayer")],et);export{et as default};
5
+ import{__decorate as e}from"tslib";import t from"../PopupTemplate.js";import r from"../request.js";import{ClonableMixin as i}from"../core/Clonable.js";import o from"../core/Collection.js";import s from"../core/Error.js";import{clone as a}from"../core/lang.js";import n from"../core/Logger.js";import{destroyMaybe as l}from"../core/maybe.js";import{MultiOriginJSONMixin as p}from"../core/MultiOriginJSONSupport.js";import{setDeepValue as u}from"../core/object.js";import{debounce as d,throwIfAbortError as y,whenOrAbort as c}from"../core/promiseUtils.js";import{sqlAnd as m}from"../core/sql.js";import{property as f}from"../core/accessorSupport/decorators/property.js";import{cast as h}from"../core/accessorSupport/decorators/cast.js";import{reader as b}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import{writer as w}from"../core/accessorSupport/decorators/writer.js";import{excludeTables as v}from"../core/accessorSupport/layerContainerType.js";import F from"../form/FormTemplate.js";import T from"../geometry/SpatialReference.js";import j from"../graphic/FeatureGraphicOrigin.js";import S from"./Layer.js";import{MemorySource as I}from"./graphics/sources/MemorySource.js";import{APIKeyMixin as E}from"./mixins/APIKeyMixin.js";import{ArcGISService as L}from"./mixins/ArcGISService.js";import{BlendLayer as D}from"./mixins/BlendLayer.js";import{CustomParametersMixin as C}from"./mixins/CustomParametersMixin.js";import{DisplayFilteredLayer as _}from"./mixins/DisplayFilteredLayer.js";import{EditBusLayer as P}from"./mixins/EditBusLayer.js";import{FeatureEffectLayer as x}from"./mixins/FeatureEffectLayer.js";import{FeatureLayerBase as O}from"./mixins/FeatureLayerBase.js";import{FeatureReductionLayer as q}from"./mixins/FeatureReductionLayer.js";import{OperationalLayer as M}from"./mixins/OperationalLayer.js";import{OrderedLayer as A}from"./mixins/OrderedLayer.js";import{PortalLayer as Q}from"./mixins/PortalLayer.js";import{PublishableLayer as R}from"./mixins/PublishableLayer.js";import{RefreshableLayer as U}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as V}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as N}from"./mixins/TemporalLayer.js";import{TrackableLayer as B}from"./mixins/TrackableLayer.js";import{titleFromUrlAndName as G,parse as J,cleanTitle as $}from"./support/arcgisLayerUrl.js";import{attributeTableTemplate as W,id as Z,labelsVisible as H,opacityDrawingInfo as z,legendEnabled as k,listMode as K,popupEnabled as X,screenSizePerspectiveEnabled as Y}from"./support/commonProperties.js";import{ensureLayerCredential as ee,computeEffectiveEditingEnabled as te,readGlobalIdField as re,readObjectIdField as ie,createDefaultRenderer as oe,addAttachment as se,updateAttachment as ae,applyEdits as ne,uploadAssets as le,createQuery as pe,deleteAttachments as ue,fetchRecomputedExtents as de,getFeatureType as ye,getFieldDomain as ce,queryAttachments as me,queryObjectIds as fe,queryFeatureCount as he,queryExtent as be,queryRelatedFeatures as ge,queryRelatedFeaturesCount as we,validateBinsQuery as ve,hasDataChanged as Fe,geometryTypeKebabDict as Te}from"./support/featureLayerUtils.js";import je from"./support/FeatureTemplate.js";import Se from"./support/FeatureType.js";import Ie from"./support/FieldConfiguration.js";import{popupTemplateWithFieldConfigurations as Ee,fieldConfigurationsFromPopupTemplate as Le,fieldConfigurationsFromFields as De}from"./support/fieldConfigUtils.js";import{defineFieldProperties as Ce}from"./support/fieldProperties.js";import{fixRendererFields as _e,fixTimeInfoFields as Pe}from"./support/fieldUtils.js";import xe from"./support/LabelClass.js";import{reader as Oe}from"./support/labelingInfo.js";import{getFeatureLayerCapabilities as qe}from"./support/serviceCapabilitiesUtils.js";import Me from"./support/TimeInfo.js";import Ae from"./support/TitleCreator.js";import{serviceSupportsSpatialReference as Qe}from"./support/versionUtils.js";import{DataLayerSource as Re}from"./support/source/DataLayerSource.js";import{read as Ue}from"../renderers/support/jsonUtils.js";import{loadStyleRenderer as Ve}from"../renderers/support/styleUtils.js";import{webSceneRendererTypes as Ne,rendererTypes as Be}from"../renderers/support/typeUtils.js";import Ge from"../rest/support/FeatureSet.js";import Je from"../rest/support/Query.js";import{isNumber as $e}from"../support/guards.js";import{createPopupTemplate as We}from"../support/popupUtils.js";import{symbolTypes as Ze}from"../symbols/support/typeUtils.js";import{opacityToTransparency as He}from"../webdoc/support/opacityUtils.js";const ze="FeatureLayer";function ke(e,t){return new s("layer:unsupported",`Layer (${e.title}, ${e.id}) of type '${e.declaredClass}' ${t}`,{layer:e})}function Ke(e){return e&&e instanceof o}const Xe=Ce();function Ye(e,t,r){const i=!!r?.writeLayerSchema;return{enabled:i,ignoreOrigin:i}}let et=class extends(O(q(x(R(P(_(D(A(N(B(V(U(L(M(Q(p(C(E(i(S)))))))))))))))))))){constructor(...e){super(...e),this.attributeTableTemplate=null,this.charts=null,this.copyright=null,this.displayField=null,this.dynamicDataSource=null,this.fields=null,this.fieldsIndex=null,this.formTemplate=null,this.fullExtent=null,this.geometryType=null,this.graphicOrigin=new j(this),this.hasM=void 0,this.hasZ=void 0,this.infoFor3D=null,this.isTable=!1,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.objectIdField=null,this.operationalLayerType="ArcGISFeatureLayer",this.outFields=null,this.path=null,this.popupEnabled=!0,this.popupTemplate=null,this.resourceInfo=null,this.screenSizePerspectiveEnabled=!0,this.spatialReference=T.WGS84,this.subtypeCode=null,this.supportedSourceTypes=new Set(["Feature Layer","Oriented Imagery Layer","Table","Catalog Layer"]),this.templates=null,this.timeInfo=null,this.title=null,this.sublayerTitleMode="item-title",this.type="feature",this.typeIdField=null,this.types=null,this.visible=!0,this._debouncedSaveOperations=d(async(e,t,r)=>{const{save:i,saveAs:o}=await import("./save/featureLayerUtils.js");switch(e){case 0:return i(this,t);case 1:return o(this,r,t)}})}destroy(){this.source?.destroy()}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){const t=null!=e?e.signal:null;if(this.portalItem?.loaded&&this.source)return this.addResolvingPromise(this.createGraphicsSource(t).then(e=>this.initLayerProperties(e))),Promise.resolve(this);const r=this.loadFromPortal({supportedTypes:["Feature Service","Feature Collection","Scene Service"]},e).catch(y).then(async()=>{if(this.url&&null==this.layerId&&/FeatureServer|MapServer\/*$/i.test(this.url)){const e=await this._fetchFirstValidLayerId(t);null!=e&&(this.layerId=e)}if(!this.url&&!this._hasMemorySource())throw new s("feature-layer:missing-url-or-source","Feature layer must be created with either a url or a source");return this.initLayerProperties(await this.createGraphicsSource(t))}).then(()=>ee(this,"load",e));return this.addResolvingPromise(r),Promise.resolve(this)}get _titleCreator(){const e=this._get("_titleCreator");return l(e),new Ae({fieldsIndex:this.fieldsIndex,objectIdField:this.objectIdField,fields:this.fields,displayField:this.displayField,effectivePopupTemplate:this.popupTemplate??this.defaultPopupTemplate})}readCapabilities(e,t){return t=t.layerDefinition||t,qe(t,this.url)}get createQueryVersion(){return this.commitProperty("definitionExpression"),this.commitProperty("dynamicDataSource"),this.commitProperty("timeExtent"),this.commitProperty("timeOffset"),this.commitProperty("geometryType"),this.commitProperty("gdbVersion"),this.commitProperty("historicMoment"),this.commitProperty("returnZ"),this.commitProperty("capabilities"),this.commitProperty("returnM"),(this._get("createQueryVersion")??0)+1}get editingEnabled(){return!(this.loaded&&!this.capabilities?.operations.supportsEditing)&&(this._isOverridden("editingEnabled")?this._get("editingEnabled"):this._hasMemorySource()||this.userHasEditingPrivileges)}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}readEditingEnabled(e,t){return this._readEditingEnabled(t,!1)}readEditingEnabledFromWebMap(e,t,r){return this._readEditingEnabled(t,!0,r)}writeEditingEnabled(e,t){this._writeEditingEnabled(e,t,!1)}writeEditingEnabledToWebMap(e,t,r,i){this._writeEditingEnabled(e,t,!0,i)}get effectiveEditingEnabled(){return te(this)}get featureTitleFields(){return[...this._titleCreator.requiredFields]}set fieldConfigurations(e){if(this._hasMemorySource())return;if(this._override("fieldConfigurations",e),!this.loaded)return;const t=Ee(this,e);t&&this._set("popupTemplate",t)}get fieldConfigurations(){if(!this._hasMemorySource())return this._isOverridden("fieldConfigurations")?this._get("fieldConfigurations"):Le(this)||null}get defaultFieldConfigurations(){return De(this)}readIsTable(e,t){return"Table"===(t=t?.layerDefinition??t).type||!t.geometryType}writeIsTable(e,t,r,i){i?.writeLayerSchema&&u(r,e?"Table":"Feature Layer",t)}readGlobalIdField(e,t){return re(t.layerDefinition||t)}readObjectIdField(e,t){return ie(t.layerDefinition||t)}writePopupTemplate(e,t,r,i){e&&(t[r]=e.toJSON({...i,writeFieldFormat:!i?.writeLayerSchema}))}get defaultPopupTemplate(){return this.createPopupTemplate()}set renderer(e){_e(e,this.fieldsIndex),this._set("renderer",e)}readRenderer(e,t,r){t=t.layerDefinition||t;const i=t.drawingInfo?.renderer;if(i){const e=Ue(i,t,r)??void 0;return e||n.getLogger(this).error("Failed to create renderer",{rendererDefinition:t.drawingInfo.renderer,layer:this,context:r}),e}return oe(t,r)}set source(e){const t=this._get("source");t!==e&&(Ke(t)&&this._resetMemorySource(t),Ke(e)&&this._initMemorySource(e),this._set("source",e))}castSource(e){return e?Array.isArray(e)||e instanceof o?new I({layer:this,items:e}):e:null}readSource(e,t){const r=Ge.fromJSON(t.featureSet);return new I({layer:this,items:r?.features??[]})}readTemplates(e,t){const r=t.editFieldsInfo,i=r?.creatorField,o=r?.editorField;return e=e?.map(e=>je.fromJSON(e)),this._fixTemplates(e,i),this._fixTemplates(e,o),e}readTitle(e,t){const r=t.layerDefinition?.name??t.name,i=t.title||t.layerDefinition?.title;if(r){const e=this.portalItem?.title;if("item-title"===this.sublayerTitleMode)return this.url?G(this.url,r):r;let t=r;if(!t&&this.url){const e=J(this.url);null!=e&&(t=e.title)}if(!t)return;return"item-title-and-service-name"===this.sublayerTitleMode&&e&&e!==t&&(t=e+" - "+t),$(t)}if("item-title"===this.sublayerTitleMode&&i)return i}readTitleFromWebMap(e,t){return t.title||t.layerDefinition?.name}readTypeIdField(e,t){let r=(t=t.layerDefinition||t).typeIdField;if(r&&t.fields){r=r.toLowerCase();const e=t.fields.find(e=>e.name.toLowerCase()===r);e&&(r=e.name)}return r}readTypes(e,t){e=(t=t.layerDefinition||t).types;const r=t.editFieldsInfo,i=r?.creatorField,o=r?.editorField;return e?.map(e=>(e=Se.fromJSON(e),this._fixTemplates(e.templates,i),this._fixTemplates(e.templates,o),e))}readVisible(e,t){return null!=t.layerDefinition?.defaultVisibility?!!t.layerDefinition.defaultVisibility:null!=t.visibility?!!t.visibility:void 0}async addAttachment(e,t){const r=await se(this,e,t,ze);return this.lastEditsEventDate=new Date,r}async updateAttachment(e,t,r){const i=await ae(this,e,t,r,ze);return this.lastEditsEventDate=new Date,i}async applyEdits(e,t){return ne(this,e,t)}async uploadAssets(e,t){return le(this,e,t)}createPopupTemplate(e){return We(this,e)}async createGraphicsSource(e){if(this._hasMemorySource()&&this.source)return this.source.load({signal:e});const{default:t}=await c(import("./graphics/sources/FeatureLayerSource.js"),e);return new t({layer:this,supportedSourceTypes:this.supportedSourceTypes}).load({signal:e})}createQuery(){const e=pe(this);e.dynamicDataSource=this.dynamicDataSource;const t=null!=this.subtypeCode?`${this.subtypeField} = ${this.subtypeCode}`:null,r=m(this.definitionExpression,t);return e.where=r||"1=1",e}async deleteAttachments(e,t){const r=await ue(this,e,t,ze);return this.lastEditsEventDate=new Date,r}async fetchRecomputedExtents(e){return de(this,e,ze)}async getFeatureTitle(e,t){return this._titleCreator.getTitle(this,e,t)}async getFeatureTitles(e,t){return this._titleCreator.getTitles(this,e,t)}getFeatureType(e){return ye(this.types,this.typeIdField,e)}getFieldAlias(e){const t=this.getField(e);if(t)return this.getFieldConfiguration(t.name)?.alias||t.alias}getFieldConfiguration(e){return e=e.toLowerCase(),this.fieldConfigurations?.find(t=>t.name.toLowerCase()===e)}getFieldDomain(e,t){return ce(this,e,t,this.getField(e)?.domain??null)}async queryAttachments(e,t){return me(this,e,t,ze)}async queryFeatures(e,t){const r=await this.load(),i=await r.source.queryFeatures(Je.from(e)??r.createQuery(),t),o=this.graphicOrigin;if(i?.features)for(const s of i.features)s.layer=s.sourceLayer=r,s.origin=o;return i}async queryObjectIds(e,t){return await fe(this,e,t,ze)}async queryFeatureCount(e,t){return he(this,e,t,ze)}async queryExtent(e,t){return be(this,e,t,ze)}async queryRelatedFeatures(e,t){return ge(this,e,t,ze)}async queryRelatedFeaturesCount(e,t){return we(this,e,t,ze)}async queryPivot(e,t){const{source:r,capabilities:i}=await this.load();if(!r.queryPivot||!i?.operations?.supportsQueryPivot)throw new s(ze,"Layer source does not support queryPivot capability");const o=await import("../rest/support/PivotQuery.js"),a=await r.queryPivot(o.default.from(e),t);if(a?.features)for(const s of a.features)s.layer=s.sourceLayer=this;return a}async queryTopFeatures(e,t){const{source:r,capabilities:i}=await this.load();if(!r.queryTopFeatures||!i?.query?.supportsTopFeaturesQuery)throw new s(ze,"Layer source does not support queryTopFeatures capability");const o=await import("../rest/support/TopFeaturesQuery.js"),a=await r.queryTopFeatures(o.default.from(e),t);if(a?.features)for(const s of a.features)s.layer=s.sourceLayer=this;return a}async queryAttributeBins(e,t){const{source:r,capabilities:i}=await this.load();if(!r.queryAttributeBins)throw new s(ze,"Layer source does not support queryAttributeBins capability");ve(e,i,ze);const o=await import("../rest/support/AttributeBinsQuery.js"),a=await r.queryAttributeBins(o.default.from(e),t);if(a.features)for(const s of a.features)s.layer=s.sourceLayer=this;return a}async queryTopObjectIds(e,t){const{source:r,capabilities:i}=await this.load();if(!r.queryTopObjectIds||!i?.query.supportsTopFeaturesQuery)throw new s(ze,"Layer source does not support queryTopObjectIds capability");const o=await import("../rest/support/TopFeaturesQuery.js");return(await r.queryTopObjectIds(o.default.from(e),t)).filter($e)}async queryTopFeaturesExtent(e,t){const{source:r,capabilities:i}=await this.load();if(!r.queryTopExtents||!i?.query?.supportsTopFeaturesQuery)throw new s(ze,"Layer source does not support queryTopExtents capability");const o=await import("../rest/support/TopFeaturesQuery.js");return r.queryTopExtents(o.default.from(e),t)}async queryTopFeatureCount(e,t){const{source:r,capabilities:i}=await this.load();if(!r.queryTopCount||!i?.query?.supportsTopFeaturesQuery)throw new s(ze,"Layer source does not support queryFeatureCount capability");const o=await import("../rest/support/TopFeaturesQuery.js");return r.queryTopCount(o.default.from(e),t)}read(e,t){const r=e.featureCollection;if((r||"Feature Collection"===e.type)&&(this.resourceInfo=e),r){const{layers:e,showLegend:i}=r;1===e?.length&&(super.read(e[0],t),null!=i&&super.read({showLegend:i},t))}super.read(e,t),t&&"service"===t.origin&&(this.revert(["objectIdField","fields","timeInfo","dateFieldsTimeZone"],"service"),this.spatialReference||this.revert(["spatialReference"],"service"))}write(e,t){t={...t,origin:t?.origin??void 0,writeLayerSchema:t?.writeLayerSchema??this._hasMemorySource()};const{origin:r,layerContainerType:i,messages:o}=t;if(this.dynamicDataSource)return o?.push(ke(this,"using a dynamic data source cannot be written to web scenes, web maps and feature service items")),null;if(this.isTable){if(("web-map"===r||"web-scene"===r)&&"tables"!==i)return o?.push(ke(this,`a table source can only be written to tables, not ${i}`)),null;if(this._hasMemorySource())return o?.push(ke(this,"using an in-memory table source cannot be written to web scenes and web maps")),null}else if(this.loaded&&("web-map"===r||"web-scene"===r)&&"tables"===i)return o?.push(ke(this,"using a non-table source cannot be written to tables in web maps or web scenes")),null;return super.write(e,t)}clone(){if(this._hasMemorySource())throw new s(ze,`FeatureLayer (title: ${this.title}, id: ${this.id}) created using in-memory source cannot be cloned`);return super.clone()}serviceSupportsSpatialReference(e){return!!this.loaded&&("memory"===this.source?.type||Qe(this,e))}async save(e){return this._debouncedSaveOperations(0,e)}async saveAs(e,t){return this._debouncedSaveOperations(1,t,e)}_readEditingEnabled(e,t,r){let i=e.layerDefinition?.capabilities;return i?this._hasEditingCapability(i):(i=e.capabilities,t&&"web-map"===r?.origin&&!this._hasMemorySource()&&i?this._hasEditingCapability(i):void 0)}_hasEditingCapability(e){return e.toLowerCase().split(",").map(e=>e.trim()).includes("editing")}_writeEditingEnabled(e,t,r,i){if(!e){const e=this.capabilities?.operations?.supportsSync?"Query,Sync":"Query";u("layerDefinition.capabilities",e,t),r&&!i?.writeLayerSchema&&(t.capabilities=e)}}_fetchFirstValidLayerId(e){return r(this.url??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e}).then(e=>{const t=e.data;if(t)return this.applyPreferredHost(t),this.findFirstValidLayerId(t)})}async initLayerProperties(e){return this._set("source",e),e.sourceJSON&&(this.sourceJSON=e.sourceJSON,this.read(e.sourceJSON,{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl})),this._verifySource(),this._verifyFields(),_e(this.renderer,this.fieldsIndex),Pe(this.timeInfo,this.fieldsIndex),this._hasMemorySource()&&"mesh"===this.geometryType&&(this.capabilities.query.supportsReturnMesh=!0),Ve(this,{origin:"service"})}async hasDataChanged(){return Fe(this)}async fetchPublishingStatus(){const e=this.source;return e?.fetchPublishingStatus?e.fetchPublishingStatus():"unavailable"}_verifyFields(){const e=this.parsedUrl?.path??"undefined";this.objectIdField||console.log("FeatureLayer: 'objectIdField' property is not defined (url: "+e+")"),this.isTable||this._hasMemorySource()||-1!==e.search(/\/FeatureServer\//i)||this.fields?.some(e=>"geometry"===e.type)||console.log("FeatureLayer: unable to find field of type 'geometry' in the layer 'fields' list. If you are using a map service layer, features will not have geometry (url: "+e+")")}_fixTemplates(e,t){e&&e.forEach(e=>{const r=e.prototype?.attributes;r&&t&&delete r[t]})}_verifySource(){if(this._hasMemorySource()){if(this.url)throw new s("feature-layer:mixed-source-and-url","FeatureLayer cannot be created with both an in-memory source and a url")}else if(!this.url)throw new s("feature-layer:source-or-url-required","FeatureLayer requires either a url, a valid portal item or a source")}_initMemorySource(e){e.forEach(e=>{e.layer=this,e.sourceLayer=this}),this.addHandles([e.on("after-add",e=>{e.item.layer=this,e.item.sourceLayer=this}),e.on("after-remove",e=>{e.item.layer=null,e.item.sourceLayer=null})],"fl-source")}_resetMemorySource(e){e.forEach(e=>{e.layer=null,e.sourceLayer=null}),this.removeHandles("fl-source")}_hasMemorySource(){return!(this.url||!this.source)}findFirstValidLayerId(e){return Array.isArray(e.layers)&&e.layers.length>0?e.layers[0].id:Array.isArray(e.tables)&&e.tables.length>0?e.tables[0].id:void 0}};e([f({clonable:!1,readOnly:!0})],et.prototype,"_titleCreator",null),e([f(W)],et.prototype,"attributeTableTemplate",void 0),e([b("service","capabilities")],et.prototype,"readCapabilities",null),e([f({json:{origins:{"web-scene":{write:!1}},write:!0}})],et.prototype,"charts",void 0),e([f({readOnly:!0})],et.prototype,"createQueryVersion",null),e([f({json:{read:{source:"layerDefinition.copyrightText"}}})],et.prototype,"copyright",void 0),e([f({json:{read:{source:"layerDefinition.displayField"}}})],et.prototype,"displayField",void 0),e([f({types:Ze,readOnly:!0})],et.prototype,"defaultSymbol",void 0),e([f({type:Re})],et.prototype,"dynamicDataSource",void 0),e([f({type:Boolean})],et.prototype,"editingEnabled",null),e([b(["portal-item","web-scene"],"editingEnabled",["layerDefinition.capabilities"])],et.prototype,"readEditingEnabled",null),e([b("web-map","editingEnabled",["capabilities","layerDefinition.capabilities"])],et.prototype,"readEditingEnabledFromWebMap",null),e([w(["portal-item","web-scene"],"editingEnabled",{"layerDefinition.capabilities":{type:String}})],et.prototype,"writeEditingEnabled",null),e([w("web-map","editingEnabled",{capabilities:{type:String},"layerDefinition.capabilities":{type:String}})],et.prototype,"writeEditingEnabledToWebMap",null),e([f({readOnly:!0})],et.prototype,"effectiveEditingEnabled",null),e([f({clonable:!1,readOnly:!0})],et.prototype,"featureTitleFields",null),e([f({type:[Ie],json:{name:"layerDefinition.fieldConfigurations",write:{overridePolicy:(e,t,r)=>({enabled:!r?.writeLayerSchema})}}})],et.prototype,"fieldConfigurations",null),e([f({readOnly:!0})],et.prototype,"defaultFieldConfigurations",null),e([f({...Xe.fields,json:{read:{source:"layerDefinition.fields"},origins:{service:{name:"fields"},"web-map":{write:{target:"layerDefinition.fields",overridePolicy:Ye}}}}})],et.prototype,"fields",void 0),e([f(Xe.fieldsIndex)],et.prototype,"fieldsIndex",void 0),e([f({type:F,json:{name:"formInfo",write:!0,origins:{"web-scene":{read:!1,write:!1}}}})],et.prototype,"formTemplate",void 0),e([f({json:{read:{source:"layerDefinition.extent"}}})],et.prototype,"fullExtent",void 0),e([f({json:{origins:{"web-map":{write:{target:"layerDefinition.geometryType",overridePolicy:Ye,writer(e,t,r){const i=e?Te.toJSON(e):null;i&&u(r,i,t)}}}},read:{source:"layerDefinition.geometryType",reader:Te.read}}})],et.prototype,"geometryType",void 0),e([f({readOnly:!0,clonable:!1})],et.prototype,"graphicOrigin",void 0),e([f({json:{read:{source:"layerDefinition.hasM"}}})],et.prototype,"hasM",void 0),e([f({json:{read:{source:"layerDefinition.hasZ"}}})],et.prototype,"hasZ",void 0),e([f(Z)],et.prototype,"id",void 0),e([f({readOnly:!0,json:{origins:{service:{read:!0}},read:!1}})],et.prototype,"infoFor3D",void 0),e([f({json:{origins:{"web-map":{write:{target:"layerDefinition.type"}}}}})],et.prototype,"isTable",void 0),e([b("service","isTable",["type","geometryType"]),b("isTable",["layerDefinition.type","layerDefinition.geometryType"])],et.prototype,"readIsTable",null),e([w("web-map","isTable")],et.prototype,"writeIsTable",null),e([f(H)],et.prototype,"labelsVisible",void 0),e([f({type:[xe],json:{origins:{service:{name:"drawingInfo.labelingInfo",read:Oe,write:!1}},name:"layerDefinition.drawingInfo.labelingInfo",read:Oe,write:{layerContainerTypes:v}}})],et.prototype,"labelingInfo",void 0),e([f((()=>{const e=a(z);return e.json.origins["portal-item"]={write:{target:"layerDefinition.drawingInfo.transparency",writer(e,t,r){u(r,He(e),t)}}},e})())],et.prototype,"opacity",void 0),e([f(k)],et.prototype,"legendEnabled",void 0),e([f({type:["show","hide"],json:(()=>{const e=a(K.json);return e.origins["portal-item"]={read:!1,write:!1},e})()})],et.prototype,"listMode",void 0),e([b("globalIdField",["layerDefinition.globalIdField","layerDefinition.fields"])],et.prototype,"readGlobalIdField",null),e([f({json:{origins:{"web-map":{write:{target:"layerDefinition.objectIdField",overridePolicy:Ye}}}}})],et.prototype,"objectIdField",void 0),e([b("objectIdField",["layerDefinition.objectIdField","layerDefinition.fields"])],et.prototype,"readObjectIdField",null),e([f({type:["ArcGISFeatureLayer"],json:{write:{target:"layerType",ignoreOrigin:!0,layerContainerTypes:v}}})],et.prototype,"operationalLayerType",void 0),e([f(Xe.outFields)],et.prototype,"outFields",void 0),e([f({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],et.prototype,"path",void 0),e([f(X)],et.prototype,"popupEnabled",void 0),e([f({type:t,json:{name:"popupInfo",write:!0}})],et.prototype,"popupTemplate",void 0),e([w("popupTemplate")],et.prototype,"writePopupTemplate",null),e([f({readOnly:!0})],et.prototype,"defaultPopupTemplate",null),e([f({types:Be,json:{origins:{service:{write:{target:"drawingInfo.renderer",enabled:!1}},"web-scene":{types:Ne,name:"layerDefinition.drawingInfo.renderer",write:{layerContainerTypes:v,overridePolicy:(e,t,r)=>({ignoreOrigin:r?.writeLayerSchema,layerContainerTypes:v})}}},write:{target:"layerDefinition.drawingInfo.renderer",overridePolicy:(e,t,r)=>({ignoreOrigin:r?.writeLayerSchema,layerContainerTypes:v})}}})],et.prototype,"renderer",null),e([b("service","renderer",["drawingInfo.renderer","defaultSymbol"]),b("renderer",["layerDefinition.drawingInfo.renderer","layerDefinition.defaultSymbol"])],et.prototype,"readRenderer",null),e([f()],et.prototype,"resourceInfo",void 0),e([f((()=>{const e=a(Y);return e.json.origins["portal-item"]={read:!1,write:!1},e})())],et.prototype,"screenSizePerspectiveEnabled",void 0),e([f({clonable:!1})],et.prototype,"source",null),e([h("source")],et.prototype,"castSource",null),e([b("portal-item","source",["featureSet"]),b("web-map","source",["featureSet"])],et.prototype,"readSource",null),e([f({json:{read:{source:"layerDefinition.extent.spatialReference"}}})],et.prototype,"spatialReference",void 0),e([f({type:Number})],et.prototype,"subtypeCode",void 0),e([f({type:[je]})],et.prototype,"templates",void 0),e([b("templates",["editFieldsInfo","creatorField","editorField","templates"])],et.prototype,"readTemplates",null),e([f({type:Me})],et.prototype,"timeInfo",void 0),e([f()],et.prototype,"title",void 0),e([b("service","title",["name"]),b("portal-item","title",["layerDefinition.title","layerDefinition.name","title"])],et.prototype,"readTitle",null),e([b("web-map","title",["layerDefinition.name","title"])],et.prototype,"readTitleFromWebMap",null),e([f({type:String})],et.prototype,"sublayerTitleMode",void 0),e([f({json:{read:!1}})],et.prototype,"type",void 0),e([f({type:String})],et.prototype,"typeIdField",void 0),e([b("service","typeIdField"),b("typeIdField",["layerDefinition.typeIdField"])],et.prototype,"readTypeIdField",null),e([f({type:[Se]})],et.prototype,"types",void 0),e([b("service","types",["types"]),b("types",["layerDefinition.types"])],et.prototype,"readTypes",null),e([f({type:Boolean,json:{origins:{"portal-item":{write:{target:"layerDefinition.defaultVisibility",layerContainerTypes:v}}}}})],et.prototype,"visible",void 0),e([b("portal-item","visible",["visibility","layerDefinition.defaultVisibility"])],et.prototype,"readVisible",null),et=e([g("esri.layers.FeatureLayer")],et);export{et 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{estimateAttributesMemory as t}from"../../core/memoryEstimations.js";import{getCentroidOptimizedGeometry as e}from"./centroid.js";import r from"./OptimizedGeometry.js";class s{constructor(t=null,e={},r,s,o=0){this.geometry=t,this.attributes=e,this.centroid=r,this.objectId=s,this.displayId=o}static fromJSON(t){const e=t.geometry?r.fromJSON(t.geometry):null,o=t.centroid?r.fromJSON(t.centroid):null,i=t.objectId;return new s(e,t.attributes,o,i)}weakClone(){const t=new s(this.geometry,this.attributes,this.centroid,this.objectId);return t.displayId=this.displayId,t}clone(){const t=this.geometry?.clone(),e=new s(t,{...this.attributes},this.centroid?.clone(),this.objectId);return e.displayId=this.displayId,e}ensureCentroid(t){return this.centroid??=e(new r,this.geometry,t.hasZ,t.hasM),this.centroid}get usedMemory(){return 128+t(this.attributes)+(this.geometry?.usedMemory??0)}}function o(t){return!!t.geometry?.coords?.length}class i extends s{}export{s as OptimizedFeature,i as OptimizedFeatureWithGeometry,o as hasGeometry};
5
+ import{estimateAttributesMemory as t}from"../../core/memoryEstimations.js";import{getCentroidOptimizedGeometry as e}from"./centroid.js";import r from"./OptimizedGeometry.js";class o{constructor(t=null,e={},r,o,s=0){this.geometry=t,this.attributes=e,this.centroid=r,this.objectId=o,this.displayId=s}static fromJSON(t){const e=t.geometry?r.fromJSON(t.geometry):null,s=t.centroid?r.fromJSON(t.centroid):null,i=t.objectId;return new o(e,t.attributes,s,i)}weakClone(){const t=new o(this.geometry,this.attributes,this.centroid,this.objectId);return t.displayId=this.displayId,t}clone(){const t=this.geometry?.clone(),e=new o(t,{...this.attributes},this.centroid?.clone(),this.objectId);return e.displayId=this.displayId,e}ensureCentroid(t){return this.centroid??=e(this.geometry),this.centroid}get usedMemory(){return 128+t(this.attributes)+(this.geometry?.usedMemory??0)}}function s(t){return!!t.geometry?.coords?.length}class i extends o{}export{o as OptimizedFeature,i as OptimizedFeatureWithGeometry,s as hasGeometry};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{estimateNumberArrayMemory as t}from"../../core/memoryEstimations.js";const s=2;class e{constructor(t=[],s=[]){this.lengths=t??[],this.coords=s??[]}static fromJSON(t){return new e(t.lengths,t.coords)}static fromRect(t){const[s,o,r,h]=t,n=r-s,i=h-o;return new e([5],[s,o,n,0,0,i,-n,0,0,-i])}get isPoint(){return 0===this.lengths.length&&this.coords.length>=2}get maxLength(){return Math.max(...this.lengths)}get size(){return this.lengths.reduce((t,s)=>t+s)}get usedMemory(){return 64+t(this.lengths,this.coords)}area(){let t=0,e=0;if(!this.lengths.length)return 0;for(let o=0;o<this.lengths.length;o++){const r=this.lengths[o];if(r<3)continue;let h=this.coords[s*e],n=this.coords[s*e+1];for(let o=1;o<r;o+=1){const r=this.coords[s*(o+e)],i=this.coords[s*(o+e)+1];t+=-.5*(r-h)*(i+n),h=r,n=i}e+=r}return t}forEachVertex(t){let e=0;this.lengths.length||t(this.coords[0],this.coords[1]);for(let o=0;o<this.lengths.length;o++){const r=this.lengths[o];for(let o=0;o<r;o++){t(this.coords[s*(o+e)],this.coords[s*(o+e)+1])}e+=r}}deltaDecode(){const t=this.clone(),{coords:s,lengths:e}=t;let o=0;for(const r of e){for(let t=1;t<r;t++)s[2*(o+t)]+=s[2*(o+t)-2],s[2*(o+t)+1]+=s[2*(o+t)-1];o+=r}return t}clone(t){if(0===this.lengths.length)return new e([],[this.coords[0],this.coords[1]]);const o=(0===this.lengths.length?1:this.lengths.reduce((t,s)=>t+s))*s,r=this.coords.slice(0,o);return t?(t.set(r),new e(this.lengths,t)):new e(Array.from(this.lengths),Array.from(r))}}export{e as default};
5
+ import{estimateNumberArrayMemory as t}from"../../core/memoryEstimations.js";class s{constructor(t=[],s=[],r=!1,e=!1){this.lengths=t??[],this.coords=s??[],this.hasZ=r,this.hasM=e}static fromJSON({lengths:t,coords:r,hasZ:e,hasM:o}){return new s(t,r,e||!1,o||!1)}static fromRect([t,r,e,o]){const i=e-t,h=o-r;return new s([5],[t,r,i,0,0,h,-i,0,0,-h])}get isPoint(){return 0===this.lengths.length&&this.coords.length>=2}get maxLength(){return Math.max(...this.lengths)}get size(){return this.isPoint?1:this.lengths.reduce((t,s)=>t+s,0)}get usedMemory(){return 64+t(this.lengths,this.coords)}get stride(){return 2+(this.hasZ?1:0)+(this.hasM?1:0)}area(){if(this.isPoint)return 0;let t=0,s=0;for(const r of this.lengths){if(r<3)continue;const{stride:e}=this;let o=this.coords[e*s],i=this.coords[e*s+1];for(let h=1;h<r;h+=1){const r=e*(s+h),n=this.coords[r],c=this.coords[r+1];t+=-.5*(n-o)*(c+i),o=n,i=c}s+=r}return t}forEachVertex(t){let s=0;if(this.isPoint)return t(this.coords[0],this.coords[1]);const{stride:r}=this;for(const e of this.lengths){for(let o=0;o<e;o++){const e=r*(s+o);t(this.coords[e],this.coords[e+1])}s+=e}}deltaDecode(){const t=this.clone(),{coords:s,lengths:r}=t;let e=0;const{stride:o}=this;for(const i of r){for(let t=1;t<i;t++){const r=o*(e+t);s[r]+=s[r-o],s[r+1]+=s[r+1-o]}e+=i}return t}clone(t){if(this.isPoint)return new s([],Array.from(this.coords.slice(0,this.stride)),this.hasZ,this.hasM);const{stride:r,size:e}=this,o=e*r,i=this.coords.slice(0,o);return t?(t.set(i),new s(this.lengths,t)):new s(Array.from(this.lengths),Array.from(i),this.hasZ,this.hasM)}justXY(){const{stride:t,size:r}=this;if(2===t)return this;const e=new Array(r*t);for(let s=0,o=0;s<e.length;s+=t)e[o++]=this.coords[s],e[o++]=this.coords[s+1];return new s(this.lengths,e,!1,!1)}}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/5.0/esri/copyright.txt for details.
4
4
  */
5
- function t(t,n){return t?n?4:3:n?3:2}function n(n,I,u,o){if(!I?.lengths.length)return null;n.lengths.length&&(n.lengths.length=0),n.coords.length&&(n.coords.length=0);const N=n.coords,l=[],s=u?[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY]:[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY],{lengths:c,coords:T}=I,f=t(u,o);let h=0;for(const t of c){const n=e(s,T,h,t,u,o);n&&l.push(n),h+=t*f}if(l.sort((t,n)=>{let e=t[2]-n[2];return 0===e&&u&&(e=t[4]-n[4]),e}),l.length){let t=6*l[0][2];N[0]=l[0][0]/t,N[1]=l[0][1]/t,u&&(t=6*l[0][4],N[2]=0!==t?l[0][3]/t:0),(N[0]<s[0]||N[0]>s[1]||N[1]<s[2]||N[1]>s[3]||u&&(N[2]<s[4]||N[2]>s[5]))&&(N.length=0)}if(!N.length){const t=I.lengths[0]?r(T,0,c[0],u,o):null;if(!t)return null;N[0]=t[0],N[1]=t[1],u&&t.length>2&&(N[2]=t[2])}return n}function e(n,e,r,I,u,o){const N=t(u,o);let l=r,s=r+N,c=0,T=0,f=0,h=0,i=0;for(let t=0,g=I-1;t<g;t++,l+=N,s+=N){const t=e[l],r=e[l+1],I=e[l+2],o=e[s],N=e[s+1],E=e[s+2];let g=t*N-o*r;h+=g,c+=(t+o)*g,T+=(r+N)*g,u&&(g=t*E-o*I,f+=(I+E)*g,i+=g),t<n[0]&&(n[0]=t),t>n[1]&&(n[1]=t),r<n[2]&&(n[2]=r),r>n[3]&&(n[3]=r),u&&(I<n[4]&&(n[4]=I),I>n[5]&&(n[5]=I))}if(h>0&&(h*=-1),i>0&&(i*=-1),!h)return null;const E=[c,T,.5*h];return u&&(E[3]=f,E[4]=.5*i),E}function r(n,e,r,l,s){const c=t(l,s);let T=e,f=e+c,h=0,i=0,E=0,g=0;for(let t=0,b=r-1;t<b;t++,T+=c,f+=c){const t=n[T],e=n[T+1],r=n[T+2],s=n[f],c=n[f+1],b=n[f+2],m=l?u(t,e,r,s,c,b):I(t,e,s,c);if(m)if(h+=m,l){const n=N(t,e,r,s,c,b);i+=m*n[0],E+=m*n[1],g+=m*n[2]}else{const n=o(t,e,s,c);i+=m*n[0],E+=m*n[1]}}return h>0?l?[i/h,E/h,g/h]:[i/h,E/h]:r>0?l?[n[e],n[e+1],n[e+2]]:[n[e],n[e+1]]:null}function I(t,n,e,r){const I=e-t,u=r-n;return Math.sqrt(I*I+u*u)}function u(t,n,e,r,I,u){const o=r-t,N=I-n,l=u-e;return Math.sqrt(o*o+N*N+l*l)}function o(t,n,e,r){return[t+.5*(e-t),n+.5*(r-n)]}function N(t,n,e,r,I,u){return[t+.5*(r-t),n+.5*(I-n),e+.5*(u-e)]}export{n as getCentroidOptimizedGeometry,r as lineCentroid};
5
+ import t from"./OptimizedGeometry.js";function n(t,n){return t?n?4:3:n?3:2}function r(n){if(null==n)return null;if(!n?.lengths.length)return null;const{lengths:r,coords:u,stride:N,hasZ:o,hasM:l}=n,s=new t([],[],o,!1),c=s.coords,f=[],i=o?[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY]:[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY];let T=0;for(const t of r){const n=e(i,u,T,t,o,l);n&&f.push(n),T+=t*N}if(f.sort((t,n)=>{let r=t[2]-n[2];return 0===r&&o&&(r=t[4]-n[4]),r}),f.length){let t=6*f[0][2];c[0]=f[0][0]/t,c[1]=f[0][1]/t,o&&(t=6*f[0][4],c[2]=0!==t?f[0][3]/t:0),(c[0]<i[0]||c[0]>i[1]||c[1]<i[2]||c[1]>i[3]||o&&(c[2]<i[4]||c[2]>i[5]))&&(c.length=0)}if(!c.length){const t=n.lengths[0]?I(u,0,r[0],o,l):null;if(!t)return null;c[0]=t[0],c[1]=t[1],o&&(c[2]=t[2]??0)}return s}function e(t,r,e,I,u,N){const o=n(u,N);let l=e,s=e+o,c=0,f=0,i=0,T=0,E=0;for(let n=0,h=I-1;n<h;n++,l+=o,s+=o){const n=r[l],e=r[l+1],I=r[l+2],N=r[s],o=r[s+1],m=r[s+2];let h=n*o-N*e;T+=h,c+=(n+N)*h,f+=(e+o)*h,u&&(h=n*m-N*I,i+=(I+m)*h,E+=h),n<t[0]&&(t[0]=n),n>t[1]&&(t[1]=n),e<t[2]&&(t[2]=e),e>t[3]&&(t[3]=e),u&&(I<t[4]&&(t[4]=I),I>t[5]&&(t[5]=I))}if(T>0&&(T*=-1),E>0&&(E*=-1),!T)return null;const m=[c,f,.5*T];return u&&(m[3]=i,m[4]=.5*E),m}function I(t,r,e,I,s){const c=n(I,s);let f=r,i=r+c,T=0,E=0,m=0,h=0;for(let n=0,b=e-1;n<b;n++,f+=c,i+=c){const n=t[f],r=t[f+1],e=t[f+2],s=t[i],c=t[i+1],b=t[i+2],F=I?N(n,r,e,s,c,b):u(n,r,s,c);if(F)if(T+=F,I){const t=l(n,r,e,s,c,b);E+=F*t[0],m+=F*t[1],h+=F*t[2]}else{const t=o(n,r,s,c);E+=F*t[0],m+=F*t[1]}}return T>0?I?[E/T,m/T,h/T]:[E/T,m/T]:e>0?I?[t[r],t[r+1],t[r+2]]:[t[r],t[r+1]]:null}function u(t,n,r,e){const I=r-t,u=e-n;return Math.sqrt(I*I+u*u)}function N(t,n,r,e,I,u){const N=e-t,o=I-n,l=u-r;return Math.sqrt(N*N+o*o+l*l)}function o(t,n,r,e){return[t+.5*(r-t),n+.5*(e-n)]}function l(t,n,r,e,I,u){return[t+.5*(e-t),n+.5*(I-n),r+.5*(u-r)]}export{r as getCentroidOptimizedGeometry,I as lineCentroid};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- function n(n,t){return n?t?4:3:t?3:2}function t(n,t,r,e){return o(n,t,r,e.coords[0],e.coords[1])}function r(t,r,e,c,u,f){const s=n(u,f),{coords:i,lengths:l}=c;if(!l)return!1;for(let n=0,d=0;n<l.length;n++,d+=s)if(!o(t,r,e,i[d],i[d+1]))return!1;return!0}function o(t,r,o,c,u){if(!t)return!1;const f=n(r,o),{coords:s,lengths:i}=t;let l=!1,d=0;for(const n of i)l=e(l,s,f,d,n,c,u),d+=n*f;return l}function e(n,t,r,o,e,c,u){let f=n,s=o;for(let i=o,l=o+e*r;i<l;i+=r){s=i+r,s===l&&(s=o);const n=t[i],e=t[i+1],d=t[s],g=t[s+1];(e<u&&g>=u||g<u&&e>=u)&&n+(u-e)/(g-e)*(d-n)<c&&(f=!f)}return f}export{o as polygonContainsCoords,r as polygonContainsMultipoint,t as polygonContainsPoint};
5
+ function t(t,r){return n(t,r.coords[0],r.coords[1])}function r(t,r){const{coords:o,lengths:e,stride:c}=r;if(!e)return!1;for(let s=0,f=0;s<e.length;s++,f+=c)if(!n(t,o[f],o[f+1]))return!1;return!0}function n(t,r,n){if(!t)return!1;const{coords:e,lengths:c,stride:s}=t;let f=!1,u=0;for(const i of c)f=o(f,e,s,u,i,r,n),u+=i*s;return f}function o(t,r,n,o,e,c,s){let f=t,u=o;for(let i=o,l=o+e*n;i<l;i+=n){u=i+n,u===l&&(u=o);const t=r[i],e=r[i+1],d=r[u],g=r[u+1];(e<s&&g>=s||g<s&&e>=s)&&t+(s-e)/(g-e)*(d-t)<c&&(f=!f)}return f}export{n as polygonContainsCoords,r as polygonContainsMultipoint,t as polygonContainsPoint};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{getExpressionFromFieldName as t,getWhereClause as e,getAliasFromFieldName as i}from"./attributeSupport.js";import{getGeometry as s}from"./geometryUtils.js";import{isDateOnlyField as a,isTimestampOffsetField as l,isTimeOnlyField as r}from"../../support/fieldUtils.js";import{timeOnlyToMilliseconds as n}from"../../../smartMapping/statistics/support/utils.js";import{processNullValue as u,getNormalizedValue as o}from"../../../statistics/utils.js";import{loadArcade as d}from"../../../support/loadArcade.js";class c{constructor(s,a,l){this._fieldDataCache=new Map,this._returnDistinctMap=new Map,this.returnDistinctValues=s.returnDistinctValues??!1,this.fieldsIndex=l,this.featureAdapter=a;const r=s.outFields;if(r&&!r.includes("*")){this.outFields=r;let s=0;for(const a of r){const r=t(a),n=this.fieldsIndex.get(r),u=n?null:e(r,l),o=n?n.name:i(a)||"FIELD_EXP_"+s++;this._fieldDataCache.set(a,{alias:o,clause:u})}}}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,i,s){const a=s?s.name:i;let l=null;return this._fieldDataCache.has(a)?l=this._fieldDataCache.get(a)?.clause:s||(l=e(i,this.fieldsIndex),this._fieldDataCache.set(a,{alias:a,clause:l})),s?this.featureAdapter.getAttribute(t,a):l?.calculateValue(t,this.featureAdapter)}getDataValues(t,e,i=!0){const s=e.normalizationType,d=e.normalizationTotal,c=this.fieldsIndex.get(e.field),h=a(c)||l(c),f=r(c);return t.map(t=>{let a=e.field&&this.getFieldValue(t,e.field,this.fieldsIndex.get(e.field));if(e.field2?(a=`${u(a)}${e.fieldDelimiter}${u(this.getFieldValue(t,e.field2,this.fieldsIndex.get(e.field2)))}`,e.field3&&(a=`${a}${e.fieldDelimiter}${u(this.getFieldValue(t,e.field3,this.fieldsIndex.get(e.field3)))}`)):"string"==typeof a&&i&&(h?a=a?new Date(a).getTime():null:f&&(a=a?n(a):null)),s&&Number.isFinite(a)){const i="field"===s&&e.normalizationField?this.getFieldValue(t,e.normalizationField,this.fieldsIndex.get(e.normalizationField)):null;a=o(a,s,i,d)}return a})}async getExpressionValues(t,e,i,a,l){const{arcadeUtils:r}=await d(),n=r.hasGeometryOperations(e);n&&await r.enableGeometryOperations();const u=r.createFunction(e),o=r.getViewInfo(i),c={fields:this.fieldsIndex.fields};return t.map(t=>{const e={attributes:this.featureAdapter.getAttributes(t),layer:c,geometry:n?{...s(a.geometryType,a.hasZ,a.hasM,this.featureAdapter.getGeometry(t)),spatialReference:i?.spatialReference}:null},d=r.createExecContext(e,o,l);return r.executeFunction(u,d)})}validateItem(t,i){return this._fieldDataCache.has(i)||this._fieldDataCache.set(i,{alias:i,clause:e(i,this.fieldsIndex)}),this._fieldDataCache.get(i)?.clause?.testFeature(t,this.featureAdapter)??!1}validateItems(t,i){return this._fieldDataCache.has(i)||this._fieldDataCache.set(i,{alias:i,clause:e(i,this.fieldsIndex)}),this._fieldDataCache.get(i)?.clause?.testSet(t,this.featureAdapter)??!1}_processAttributesForOutFields(t){const e=this.outFields;if(!e?.length)return this.featureAdapter.getAttributes(t);const i={};for(const s of e){const{alias:e,clause:a}=this._fieldDataCache.get(s);i[e]=a?a.calculateValue(t,this.featureAdapter):this.featureAdapter.getAttribute(t,e)}return i}_processAttributesForDistinctValues(t){if(null==t||!this.returnDistinctValues)return t;const e=this.outFields,i=[];if(e)for(const l of e){const{alias:e}=this._fieldDataCache.get(l);i.push(t[e])}else for(const l in t)i.push(t[l]);const s=`${(e||["*"]).join(",")}=${i.join(",")}`;let a=this._returnDistinctMap.get(s)||0;return this._returnDistinctMap.set(s,++a),a>1?null:t}}export{c as default};
5
+ import{getExpressionFromFieldName as t,getWhereClause as e,getAliasFromFieldName as i}from"./attributeSupport.js";import{getGeometry as s}from"./geometryUtils.js";import{isDateOnlyField as a,isTimestampOffsetField as l,isTimeOnlyField as r}from"../../support/fieldUtils.js";import{timeOnlyToMilliseconds as n}from"../../../smartMapping/statistics/support/utils.js";import{processNullValue as u,getNormalizedValue as o}from"../../../statistics/utils.js";import{loadArcade as d}from"../../../support/loadArcade.js";class c{constructor(s,a,l){this._fieldDataCache=new Map,this._returnDistinctMap=new Map,this.returnDistinctValues=s.returnDistinctValues??!1,this.fieldsIndex=l,this.featureAdapter=a;const r=s.outFields;if(r&&!r.includes("*")){this.outFields=r;let s=0;for(const a of r){const r=t(a),n=this.fieldsIndex.get(r),u=n?null:e(r,l),o=n?n.name:i(a)||"FIELD_EXP_"+s++;this._fieldDataCache.set(a,{alias:o,clause:u})}}}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,i,s){const a=s?s.name:i;let l=null;return this._fieldDataCache.has(a)?l=this._fieldDataCache.get(a)?.clause:s||(l=e(i,this.fieldsIndex),this._fieldDataCache.set(a,{alias:a,clause:l})),s?this.featureAdapter.getAttribute(t,a):l?.calculateValue(t,this.featureAdapter)}getDataValues(t,e,i=!0){const s=e.normalizationType,d=e.normalizationTotal,c=this.fieldsIndex.get(e.field),f=a(c)||l(c),h=r(c);return t.map(t=>{let a=e.field&&this.getFieldValue(t,e.field,this.fieldsIndex.get(e.field));if(e.field2?(a=`${u(a)}${e.fieldDelimiter}${u(this.getFieldValue(t,e.field2,this.fieldsIndex.get(e.field2)))}`,e.field3&&(a=`${a}${e.fieldDelimiter}${u(this.getFieldValue(t,e.field3,this.fieldsIndex.get(e.field3)))}`)):"string"==typeof a&&i&&(f?a=a?new Date(a).getTime():null:h&&(a=a?n(a):null)),s&&Number.isFinite(a)){const i="field"===s&&e.normalizationField?this.getFieldValue(t,e.normalizationField,this.fieldsIndex.get(e.normalizationField)):null;a=o(a,s,i,d)}return a})}async getExpressionValues(t,e,i,a,l){const{arcadeUtils:r}=await d(),n=r.hasGeometryOperations(e);n&&await r.enableGeometryOperations();const u=r.createFunction(e),o=r.getViewInfo(i),c={fields:this.fieldsIndex.fields};return t.map(t=>{const e={attributes:this.featureAdapter.getAttributes(t),layer:c,geometry:n?{...s(a.geometryType,this.featureAdapter.getGeometry(t)),spatialReference:i?.spatialReference}:null},d=r.createExecContext(e,o,l);return r.executeFunction(u,d)})}validateItem(t,i){return this._fieldDataCache.has(i)||this._fieldDataCache.set(i,{alias:i,clause:e(i,this.fieldsIndex)}),this._fieldDataCache.get(i)?.clause?.testFeature(t,this.featureAdapter)??!1}validateItems(t,i){return this._fieldDataCache.has(i)||this._fieldDataCache.set(i,{alias:i,clause:e(i,this.fieldsIndex)}),this._fieldDataCache.get(i)?.clause?.testSet(t,this.featureAdapter)??!1}_processAttributesForOutFields(t){const e=this.outFields;if(!e?.length)return this.featureAdapter.getAttributes(t);const i={};for(const s of e){const{alias:e,clause:a}=this._fieldDataCache.get(s);i[e]=a?a.calculateValue(t,this.featureAdapter):this.featureAdapter.getAttribute(t,e)}return i}_processAttributesForDistinctValues(t){if(null==t||!this.returnDistinctValues)return t;const e=this.outFields,i=[];if(e)for(const l of e){const{alias:e}=this._fieldDataCache.get(l);i.push(t[e])}else for(const l in t)i.push(t[l]);const s=`${(e||["*"]).join(",")}=${i.join(",")}`;let a=this._returnDistinctMap.get(s)||0;return this._returnDistinctMap.set(s,++a),a>1?null:t}}export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as e}from"../../../core/arrayUtils.js";import t from"../../../core/Error.js";import{EventEmitter as r}from"../../../core/Evented.js";import s from"../../../core/Logger.js";import{fromRect as o,create as i}from"../../../geometry/support/aaBoundingBox.js";import{create as n}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsOptimizedGeometry as u}from"../featureConversionUtils.js";import{BoundsStore as a}from"./BoundsStore.js";import{cleanFromGeometryEngine as d}from"./geometryUtils.js";import{optimizedFeatureQueryEngineAdapter as h}from"./optimizedFeatureQueryEngineAdapter.js";const m=i();class f{constructor(e){this.geometryInfo=e,this._boundsStore=new a,this._featuresById=new Map,this._usedMemory=0,this.events=new r,this.featureAdapter=h}get usedMemory(){return this._usedMemory}get geometryType(){return this.geometryInfo.geometryType}get hasM(){return this.geometryInfo.hasM}get hasZ(){return this.geometryInfo.hasZ}get numFeatures(){return this._featuresById.size}get fullBounds(){return this._boundsStore.fullBounds}get storeStatistics(){let e=0;return this._featuresById.forEach(t=>{null!=t.geometry&&t.geometry.coords&&(e+=t.geometry.coords.length)}),{featureCount:this._featuresById.size,vertexCount:e/(this.hasZ?this.hasM?4:3:this.hasM?3:2)}}getFullExtent(e){if(null==this.fullBounds)return null;const[t,r,s,o]=this.fullBounds;return{xmin:t,ymin:r,xmax:s,ymax:o,spatialReference:d(e)}}add(e){this._add(e),this._emitChanged()}addMany(e){for(const t of e)this._add(t);this._emitChanged()}upsertMany(t){const r=t.map(e=>this._upsert(e));return this._emitChanged(),r.filter(e)}clear(){this._featuresById.clear(),this._boundsStore.clear(),this._emitChanged(),this._usedMemory=0}removeById(e){const t=this._featuresById.get(e);return t?(this._remove(t),this._emitChanged(),t):null}removeManyById(e){this._boundsStore.invalidateIndex();for(const t of e){const e=this._featuresById.get(t);e&&this._remove(e)}this._emitChanged()}forEachBounds(e,t){for(const r of e){const e=this._boundsStore.get(r.objectId);e&&t(o(m,e))}}getFeature(e){return this._featuresById.get(e)}has(e){return this._featuresById.has(e)}forEach(e){this._featuresById.forEach(t=>e(t))}forEachInBounds(e,t){this._boundsStore.forEachInBounds(e,e=>{t(this._featuresById.get(e))})}_emitChanged(){this.events.emit("changed",void 0)}_add(e){if(!e)return;const r=e.objectId;if(null==r)return void s.getLogger("esri.layers.graphics.data.FeatureStore").error(new t("featurestore:invalid-feature","feature id is missing",{feature:e}));const o=this._featuresById.get(r);let i;if(o?(e.displayId=o.displayId,i=this._boundsStore.get(r),this._boundsStore.delete(r),this._usedMemory-=this.estimateFeatureUsedMemory?.(o)??0):null!=this.onFeatureAdd&&this.onFeatureAdd(e),!e.geometry?.coords?.length)return this._boundsStore.set(r,null),void this._featuresById.set(r,e);i=u(null!=i?i:n(),e.geometry,this.geometryInfo.hasZ,this.geometryInfo.hasM),null!=i&&this._boundsStore.set(r,i),this._featuresById.set(r,e),this._usedMemory+=this.estimateFeatureUsedMemory?.(e)??0}_upsert(e){const r=e?.objectId;if(null==r)return s.getLogger("esri.layers.graphics.data.FeatureStore").error(new t("featurestore:invalid-feature","feature id is missing",{feature:e})),null;const o=this._featuresById.get(r);if(!o)return this._add(e),e;this._usedMemory-=this.estimateFeatureUsedMemory?.(o)??0;const{geometry:i,attributes:a}=e;for(const t in a)o.attributes[t]=a[t];return i&&(o.geometry=i,this._boundsStore.set(r,u(n(),i,this.geometryInfo.hasZ,this.geometryInfo.hasM)??null)),this._usedMemory+=this.estimateFeatureUsedMemory?.(o)??0,o}_remove(e){null!=this.onFeatureRemove&&this.onFeatureRemove(e);const t=e.objectId;return this._boundsStore.delete(t),this._featuresById.delete(t),this._usedMemory-=this.estimateFeatureUsedMemory?.(e)??0,e}}export{f as default};
5
+ import{isSome as e}from"../../../core/arrayUtils.js";import t from"../../../core/Error.js";import{EventEmitter as r}from"../../../core/Evented.js";import s from"../../../core/Logger.js";import{fromRect as o,create as i}from"../../../geometry/support/aaBoundingBox.js";import{create as n}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsOptimizedGeometry as u}from"../featureConversionUtils.js";import{BoundsStore as a}from"./BoundsStore.js";import{cleanFromGeometryEngine as d}from"./geometryUtils.js";import{optimizedFeatureQueryEngineAdapter as h}from"./optimizedFeatureQueryEngineAdapter.js";const m=i();class f{constructor(e){this.geometryInfo=e,this._boundsStore=new a,this._featuresById=new Map,this._usedMemory=0,this.events=new r,this.featureAdapter=h}get usedMemory(){return this._usedMemory}get geometryType(){return this.geometryInfo.geometryType}get hasM(){return this.geometryInfo.hasM}get hasZ(){return this.geometryInfo.hasZ}get numFeatures(){return this._featuresById.size}get fullBounds(){return this._boundsStore.fullBounds}get storeStatistics(){let e=0;return this._featuresById.forEach(t=>{null!=t.geometry&&t.geometry.coords&&(e+=t.geometry.coords.length)}),{featureCount:this._featuresById.size,vertexCount:e/(this.hasZ?this.hasM?4:3:this.hasM?3:2)}}getFullExtent(e){if(null==this.fullBounds)return null;const[t,r,s,o]=this.fullBounds;return{xmin:t,ymin:r,xmax:s,ymax:o,spatialReference:d(e)}}add(e){this._add(e),this._emitChanged()}addMany(e){for(const t of e)this._add(t);this._emitChanged()}upsertMany(t){const r=t.map(e=>this._upsert(e));return this._emitChanged(),r.filter(e)}clear(){this._featuresById.clear(),this._boundsStore.clear(),this._emitChanged(),this._usedMemory=0}removeById(e){const t=this._featuresById.get(e);return t?(this._remove(t),this._emitChanged(),t):null}removeManyById(e){this._boundsStore.invalidateIndex();for(const t of e){const e=this._featuresById.get(t);e&&this._remove(e)}this._emitChanged()}forEachBounds(e,t){for(const r of e){const e=this._boundsStore.get(r.objectId);e&&t(o(m,e))}}getFeature(e){return this._featuresById.get(e)}has(e){return this._featuresById.has(e)}forEach(e){this._featuresById.forEach(t=>e(t))}forEachInBounds(e,t){this._boundsStore.forEachInBounds(e,e=>{t(this._featuresById.get(e))})}_emitChanged(){this.events.emit("changed",void 0)}_add(e){if(!e)return;const r=e.objectId;if(null==r)return void s.getLogger("esri.layers.graphics.data.FeatureStore").error(new t("featurestore:invalid-feature","feature id is missing",{feature:e}));const o=this._featuresById.get(r);let i;if(o?(e.displayId=o.displayId,i=this._boundsStore.get(r),this._boundsStore.delete(r),this._usedMemory-=this.estimateFeatureUsedMemory?.(o)??0):null!=this.onFeatureAdd&&this.onFeatureAdd(e),!e.geometry?.coords?.length)return this._boundsStore.set(r,null),void this._featuresById.set(r,e);i=u(null!=i?i:n(),e.geometry),null!=i&&this._boundsStore.set(r,i),this._featuresById.set(r,e),this._usedMemory+=this.estimateFeatureUsedMemory?.(e)??0}_upsert(e){const r=e?.objectId;if(null==r)return s.getLogger("esri.layers.graphics.data.FeatureStore").error(new t("featurestore:invalid-feature","feature id is missing",{feature:e})),null;const o=this._featuresById.get(r);if(!o)return this._add(e),e;this._usedMemory-=this.estimateFeatureUsedMemory?.(o)??0;const{geometry:i,attributes:a}=e;for(const t in a)o.attributes[t]=a[t];return i&&(o.geometry=i,this._boundsStore.set(r,u(n(),i)??null)),this._usedMemory+=this.estimateFeatureUsedMemory?.(o)??0,o}_remove(e){null!=this.onFeatureRemove&&this.onFeatureRemove(e);const t=e.objectId;return this._boundsStore.delete(t),this._featuresById.delete(t),this._usedMemory-=this.estimateFeatureUsedMemory?.(e)??0,e}}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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{indexOf as e,PositionHint as t}from"../../../core/arrayUtils.js";import{toConst as i}from"../../../core/compilerUtils.js";import r from"../../../core/Error.js";import"../../../core/has.js";import{clone as s}from"../../../core/lang.js";import{removeMaybe as a,destroyMaybe as n}from"../../../core/maybe.js";import{signalFromSignalOrOptions as l,throwIfAborted as u}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as o}from"../../../core/unitUtils.js";import{isSerializable as c}from"../../../core/support/jsonUtils.js";import{isLoaded as h}from"../../../geometry/projectionUtils.js";import{set as y,negativeInfinity as d,create as m,expandWithAABB as f}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as p,create as x}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as g}from"../../../geometry/support/boundsUtils.js";import{fromJSON as _,isExtent as F,isPolygon as w}from"../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridian as Q}from"../../../geometry/support/normalizeUtils.js";import{equals as S,isValid as R}from"../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as I}from"../featureConversionUtils.js";import{getWhereClause as j}from"./attributeSupport.js";import{cleanFromGeometryEngine as b,getGeometry as E}from"./geometryUtils.js";import{project as T,checkProjectionSupport as A,projectMany as v}from"./projectionSupport.js";import{QueryEngineCache as G}from"./QueryEngineCache.js";import{queryCapabilities as k}from"./QueryEngineCapabilities.js";import{QueryEngineResult as C}from"./QueryEngineResult.js";import{queryEngineEmptyResult as O,normalizeAttributeBinsQuery as M,normalizeQueryLike as P,normalizeQuery as q}from"./queryUtils.js";import{validateAttributeBinsQuery as z,validateQuery as U,validateStatisticsQuery as B}from"./queryValidationUtils.js";import{getSpatialQueryOperator as Z,canQueryWithRBush as H}from"./spatialQuerySupport.js";import{getTimeExtent as N,getTimeOperator as J}from"./timeSupport.js";import L from"../../support/FieldsIndex.js";import{ImmediateTask as V}from"../../../views/support/Scheduler.js";const D="unsupported-query";class K{constructor(e,t=null,i,r,s){this.attributes=e,this.geometry=i,this.centroid=r,this.filterFlags=s,this.groupId=-1,this.displayId=t}}class W{constructor(e){this._changeHandle=null,this.capabilities={query:k},this.geometryType=e.geometryType,this.hasM=!!e.hasM,this.hasZ=!!e.hasZ,this.spatialReference=e.spatialReference,this.definitionExpression=e.definitionExpression,this.featureStore=e.featureStore,this.aggregateAdapter=e.aggregateAdapter,this._cache=e.cache??new G,this.timeInfo=e.timeInfo,this.featureIdInfo=e.featureIdInfo,"object-id"===e.featureIdInfo.type&&(this.objectIdField=e.featureIdInfo.fieldName),this._changeHandle=this.featureStore.events.on("changed",()=>this._clearCache()),this.fieldsIndex=c(e.fieldsIndex)?e.fieldsIndex:L.fromJSON(e.fieldsIndex),!e.availableFields||1===e.availableFields.length&&"*"===e.availableFields[0]?this.availableFields=new Set(this.fieldsIndex.fields.map(e=>e.name)):this.availableFields=new Set(e.availableFields.map(e=>this.fieldsIndex.get(e)?.name).filter(e=>null!=e)),e.scheduler&&e.priority?this._frameTask=e.scheduler.registerTask(e.priority):this._frameTask=V}destroy(){this._changeHandle=a(this._changeHandle),this._frameTask=a(this._frameTask),this._clearCache(),n(this._cache)}get featureAdapter(){return this.featureStore.featureAdapter}async executeQuery(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryFeatureSet(e),i)}async executeQueryForCount(e={},t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForCount(e),i)}async executeQueryForExtent(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForExtent(e),i)}async executeQueryForIds(e,t){return Array.from(await this.executeQueryForIdSet(e,t))}async executeQueryForIdSet(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForIdSet(e),i)}async executeQueryForLatestObservations(e,t){const i=l(t);if(!this.timeInfo?.trackIdField)throw new r(D,"Missing timeInfo or timeInfo.trackIdField",{query:e,timeInfo:this.timeInfo});return await this._frameTask.scheduleGenerator(()=>this._executeQueryForLatestObservations(e),i)}async executeQueryForOpaqueFeatures(e,t){const i=l(t);return(await this._frameTask.scheduleGenerator(()=>this._executeQuery(e,{}),i)).items}async executeAttributeBinsQuery(e,t){const i=l(t);return e=s(e),await this._frameTask.scheduleGenerator(()=>this._executeAttributeBinsQuery(e),i)}async executeQueryForSummaryStatistics(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForSummaryStatistics(e,t),r)}async executeQueryForUniqueValues(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForUniqueValues(e,t),r)}async executeQueryForClassBreaks(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForClassBreaks(e,t),r)}async executeQueryForHistogram(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForHistogram(e,t),r)}async executeQueryForSnapping(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForSnapping(e,i),i)}async fetchRecomputedExtents(e){const t=l(e);this._timeExtentPromise||=N(this.timeInfo,this.featureStore);const[i,r]=await Promise.all([this._getFullExtent(),this._timeExtentPromise]);return u(t),{fullExtent:i,timeExtent:r}}_clearCache(){this._cache.clear(),this._allFeaturesPromise=null,this._timeExtentPromise=null,this._fullExtentPromise=null}async*_executeQueryFeatureSet(e){try{const t=yield*this._executeQuery(e,{});return yield,await t.createQueryResponse()}catch(t){if(t!==O)throw t;return await new C([],e,this).createQueryResponse()}}async*_executeQueryForCount(e){try{const t=yield*this._executeQuery(e,{returnGeometry:!1,returnCentroid:!1,outSR:null});return yield,t.createQueryResponseForCount()}catch(t){if(t!==O)throw t;return 0}}async*_executeQueryForExtent(e){const t=e.outSR;try{const i=yield*this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null});yield;const r=i.size;if(!r)return{count:0,extent:null};const s=await this._getBounds(i.items,i.spatialReference,t??this.spatialReference);return yield,{count:r,extent:s}}catch(i){if(i===O)return{count:0,extent:null};throw i}}async*_executeQueryForIdSet(e){try{const t=yield*this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null});yield;const i=t.items,r=new Set;for(const e of i)r.add(t.featureAdapter.getObjectId(e));return r}catch(t){if(t===O)return new Set;throw t}}async*_executeQueryForLatestObservations(e){try{const t=yield*this._executeQuery(e,{});return yield,this._filterLatest(t),yield,await t.createQueryResponse()}catch(t){if(t!==O)throw t;return await new C([],e,this).createQueryResponse()}}async*_executeAttributeBinsQuery(e){let t;try{e=await M(e,this.definitionExpression,this.spatialReference),yield,e=await z(e,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield;const i=yield*this._executeSceneFilterQuery(e);yield,t=yield*this._executeGeometryQuery(e,i),yield,this._executeAggregateIdsQuery(t),yield,this._executeObjectIdsQuery(t),yield,this._executeTimeQuery(t),yield,this._executeAttributesQuery(t),yield}catch(i){if(i!==O)throw i;t=new C([],e,this)}return await t.createQueryBinsResponse(e)}async*_executeQueryForSummaryStatistics(e={},t){const{field:i,normalizationField:r,valueExpression:s}=t,a=yield*this._executeQueryForStatistics(e,{field:i,normalizationField:r,valueExpression:s});return yield,await a.createSummaryStatisticsResponse(t)}async*_executeQueryForUniqueValues(e={},t){const{field:i,field2:r,field3:s,valueExpression:a}=t,n=yield*this._executeQueryForStatistics(e,{field:i,field2:r,field3:s,valueExpression:a});return yield,await n.createUniqueValuesResponse(t)}async*_executeQueryForClassBreaks(e,t){const{field:i,normalizationField:r,valueExpression:s}=t,a=yield*this._executeQueryForStatistics(e,{field:i,normalizationField:r,valueExpression:s});return yield,await a.createClassBreaksResponse(t)}async*_executeQueryForHistogram(e,t){const{field:i,normalizationField:r,valueExpression:s}=t,a=yield*this._executeQueryForStatistics(e,{field:i,normalizationField:r,valueExpression:s});return yield,await a.createHistogramResponse(t)}async*_executeQueryForSnapping(e,t){const{point:i,distance:r,returnEdge:a,vertexMode:n}=e;if(!a&&"none"===n)return{candidates:[]};let l=s(e.query);l=await P(l,this.definitionExpression,this.spatialReference),yield,l=await U(l,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield;const u=!S(i.spatialReference,this.spatialReference);u&&(await A(i.spatialReference,this.spatialReference),yield);const o="number"==typeof r?r:r.x,c="number"==typeof r?r:r.y,h={xmin:i.x-o,xmax:i.x+o,ymin:i.y-c,ymax:i.y+c,spatialReference:i.spatialReference},y=u?T(h,this.spatialReference):h;if(!y)return{candidates:[]};const d=(await Q(_(i),null,{signal:t}))[0];yield;const m=(await Q(_(y),null,{signal:t}))[0];if(yield,null==d||null==m)return{candidates:[]};const f=await this._searchFeatures(X(m.toJSON()));yield;const p=new C(f,l,this);this._executeObjectIdsQuery(p),yield,this._executeTimeQuery(p),yield,this._executeAttributesQuery(p),yield,yield*this._executeGeometryQueryForSnapping(p),yield;const x=d.toJSON(),g=u?T(x,this.spatialReference):x,F=u?Math.max(y.xmax-y.xmin,y.ymax-y.ymin)/2:r;return p.createSnappingResponse({...e,point:g,distance:F},l.returnZ,i.spatialReference)}async _getBounds(e,t,i){const r=y(m(),d);return await this.featureStore.forEachBounds(e,e=>f(r,e)),Y(r,t,i,this.spatialReference,this.hasZ)}_getFullExtent(){return this._fullExtentPromise||="getFullExtent"in this.featureStore&&this.featureStore.getFullExtent?Promise.resolve(this.featureStore.getFullExtent(this.spatialReference)):this._getAllFeatures().then(e=>this._getBounds(e,this.spatialReference,this.spatialReference)),this._fullExtentPromise}async _getAllFeaturesQueryEngineResult(e){return new C(await this._getAllFeatures(),e,this)}async _getAllFeatures(){if(null==this._allFeaturesPromise){const e=[];this._allFeaturesPromise=(async()=>await this.featureStore.forEach(t=>e.push(t)))().then(()=>i(e))}const e=this._allFeaturesPromise,t=await e;return e===this._allFeaturesPromise?t.slice():this._getAllFeatures()}async*_executeQuery(e,t){e=s(e),e=await q(e,this.definitionExpression,this.spatialReference),yield,e=await U(e,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield,e={...e,...t};const i=yield*this._executeSceneFilterQuery(e);yield;const r=yield*this._executeGeometryQuery(e,i);return yield,this._executeAggregateIdsQuery(r),yield,this._executeObjectIdsQuery(r),yield,this._executeTimeQuery(r),yield,this._executeAttributesQuery(r),r}async*_executeSceneFilterQuery(e){if(null==e.sceneFilter)return null;const{outSR:t,returnGeometry:i,returnCentroid:r}=e,s=this.featureStore.featureSpatialReference,a=e.sceneFilter.geometry,n=null==s||S(s,a.spatialReference)?a:T(a,s);if(!n)return null;const l=i||r,u=R(t)&&!S(this.spatialReference,t)&&l?async e=>this._project(e,t):e=>e;yield;const o=this.featureAdapter,c=await this._searchFeatures(X(n));yield;if("disjoint"===e.sceneFilter.spatialRelationship){if(!c.length)return null;const t=new Set;for(const e of c)t.add(o.getObjectId(e));const i=await this._getAllFeatures();yield;const r=await Z("esriSpatialRelDisjoint",n,this.geometryType,this.hasZ,this.hasM);yield;const s=e=>!t.has(o.getObjectId(e))||r(o.getGeometry(e)),a=yield*this._runSpatialFilter(i,s);yield;const l=new C(a,e,this);return await u(l)}if(!c.length)return new C([],e,this);if(this._canExecuteSinglePass(n,e))return await u(new C(c,e,this));const h=await Z("esriSpatialRelContains",n,this.geometryType,this.hasZ,this.hasM);yield;const y=yield*this._runSpatialFilter(c,e=>h(o.getGeometry(e)));return yield,await u(new C(y,e,this))}async*_executeGeometryQuery(i,r){if(null!=r&&0===r.items.length)return r;const{geometry:s,outSR:a,returnGeometry:n,returnCentroid:l}=i,u=r?null:this._getCacheKey(i),o=u?this._cache.get(u):null;if(o)return new C(o,i,this);const c=R(a)&&!S(this.spatialReference,a),h=n||l,y=async e=>(c&&h&&await this._project(e,a),u&&this._cache.put(u,e.items),e),d=this.featureStore.featureSpatialReference,m=!s||null==d||S(d,s.spatialReference)?s:T(s,d);if(!m)return await y(null!=r?r:await this._getAllFeaturesQueryEngineResult(i));yield;const f=this.featureAdapter;let p=await this._searchFeatures(X(s));yield;const x=i.spatialRel??"esriSpatialRelIntersects";if("esriSpatialRelDisjoint"===x){if(!p.length)return await y(null!=r?r:await this._getAllFeaturesQueryEngineResult(i));const e=new Set;for(const i of p)e.add(f.getObjectId(i));let t;null!=r?t=r.items:(yield,t=await this._getAllFeatures(),yield);const s=await Z(x,m,this.geometryType,this.hasZ,this.hasM);yield;const a=t=>!e.has(f.getObjectId(t))||s(f.getGeometry(t)),n=yield*this._runSpatialFilter(t,a);yield;const l=new C(n,i,this);return await y(l)}if(null!=r){const i=new t;p=p.filter(t=>e(r.items,t,r.items.length,i)>=0)}if(!p.length){const e=new C([],i,this);return u&&this._cache.put(u,e.items),e}if(this._canExecuteSinglePass(m,i))return await y(new C(p,i,this));const g=await Z(x,m,this.geometryType,this.hasZ,this.hasM);yield;const _=yield*this._runSpatialFilter(p,e=>g(f.getGeometry(e)));return yield,await y(new C(_,i,this))}_executeAggregateIdsQuery(e){if(0===e.items.length||!e.query.aggregateIds?.length||null==this.aggregateAdapter)return;const t=new Set;for(const r of e.query.aggregateIds){this.aggregateAdapter.getFeatureObjectIds(r).forEach(e=>t.add(e))}const i=this.featureAdapter.getObjectId;e.items=e.items.filter(e=>t.has(i(e)))}_executeObjectIdsQuery(e){if(0===e.items.length||!e.query.objectIds?.length)return;const t=new Set(e.query.objectIds),i=this.featureAdapter.getObjectId;e.items=e.items.filter(e=>t.has(i(e)))}_executeTimeQuery(e){if(0===e.items.length)return;const t=J(this.timeInfo,e.query.timeExtent,this.featureAdapter);null!=t&&(e.items=e.items.filter(t))}_executeAttributesQuery(e){if(0===e.items.length)return;const t=j(e.query.where,this.fieldsIndex);if(t){if(!t.isStandardized)throw new TypeError("Where clause is not standardized");e.items=e.items.filter(e=>t.testFeature(e,this.featureAdapter))}}async*_executeGeometryQueryForSnapping(e){const{query:t}=e,{spatialRel:i}=t;if(!e?.items?.length||!t.geometry||!i)return;const r=await Z(i,t.geometry,this.geometryType,this.hasZ,this.hasM);yield;const s=this.featureAdapter,a=e=>r(s.getGeometry(e)),n=yield*this._runSpatialFilter(e.items,a);e.items=n}*_runSpatialFilter(e,t){if(!t)return e;if(null==this._frameTask)return e.filter(e=>t(e));let i=yield;const r=new Array;for(const s of e)t(s)&&r.push(s),i.madeProgress(),i.done&&(i=yield);return r}_filterLatest(e){const{trackIdField:t,startTimeField:i,endTimeField:r}=this.timeInfo,s=r||i,a=new Map,n=this.featureAdapter.getAttribute;for(const l of e.items){const e=n(l,t),i=n(l,s),r=a.get(e);(!r||i>n(r,s))&&a.set(e,l)}e.items=Array.from(a.values())}_getCacheKey(e){const{geometry:t,spatialRel:i,returnGeometry:r,returnCentroid:s,outSR:a,resultType:n,cacheHint:l}=e;if("tile"!==n&&!l)return null;const u=r||s;return R(a)&&!S(this.spatialReference,a)&&u?JSON.stringify([t,i,a]):JSON.stringify([t,i])}_canExecuteSinglePass(e,t){const{spatialRel:i}=t;return H(e)&&("esriSpatialRelEnvelopeIntersects"===i||"esriGeometryPoint"===this.geometryType&&("esriSpatialRelIntersects"===i||"esriSpatialRelContains"===i))}async _project(e,t){if(!t||S(this.spatialReference,t))return e;const r=this.featureAdapter,s=h()?await this._getFullExtent():void 0,a=await v(e.items.map(e=>E(this.geometryType,this.hasZ,this.hasM,r.getGeometry(e))),this.spatialReference,t,{areaOfInterestExtent:s});return e.items=i(a.map((t,i)=>r.cloneWithGeometry(e.items[i],I(t,this.hasZ,this.hasM)))),e}async _searchFeatures(e){const t=new Set;await Promise.all(e.map(e=>this.featureStore.forEachInBounds(e,e=>t.add(e))));const i=Array.from(t.values());return t.clear(),i}async*_executeQueryForStatistics(e,t){e=s(e);try{e=await q(e,this.definitionExpression,this.spatialReference),yield,e=await B(e,t,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield;const i=yield*this._executeSceneFilterQuery(e);yield;const r=yield*this._executeGeometryQuery(e,i);return yield,this._executeAggregateIdsQuery(r),yield,this._executeObjectIdsQuery(r),yield,this._executeTimeQuery(r),yield,this._executeAttributesQuery(r),yield,r}catch(i){if(i!==O)throw i;return new C([],e,this)}}get test(){}}function X(e){if(H(e)){if(F(e))return[p(Math.min(e.xmin,e.xmax),Math.min(e.ymin,e.ymax),Math.max(e.xmin,e.xmax),Math.max(e.ymin,e.ymax))];if(w(e))return e.rings.map(e=>p(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[g(x(),e)]}function Y(e,t,i,r,s){const a={xmin:e[0],ymin:e[1],xmax:e[3],ymax:e[4],spatialReference:b(r)};s&&isFinite(e[2])&&isFinite(e[5])&&(a.zmin=e[2],a.zmax=e[5],a.hasZ=!0);const n=T(a,t,i);if(n.spatialReference=b(i),n.xmax-n.xmin===0){const e=o(n.spatialReference);n.xmin-=e,n.xmax+=e}if(n.ymax-n.ymin===0){const e=o(n.spatialReference);n.ymin-=e,n.ymax+=e}if(s&&null!=n.zmin&&null!=n.zmax&&n.zmax-n.zmin===0){const e=o(n.spatialReference);n.zmin-=e,n.zmax+=e}return n}export{K as Feature,W as QueryEngine,Y as getQueryResultExtent};
5
+ import{indexOf as e,PositionHint as t}from"../../../core/arrayUtils.js";import{toConst as i}from"../../../core/compilerUtils.js";import r from"../../../core/Error.js";import"../../../core/has.js";import{clone as s}from"../../../core/lang.js";import{removeMaybe as a,destroyMaybe as n}from"../../../core/maybe.js";import{signalFromSignalOrOptions as l,throwIfAborted as u}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as o}from"../../../core/unitUtils.js";import{isSerializable as c}from"../../../core/support/jsonUtils.js";import{isLoaded as y}from"../../../geometry/projectionUtils.js";import{set as h,negativeInfinity as d,create as m,expandWithAABB as f}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as p,create as x}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as g}from"../../../geometry/support/boundsUtils.js";import{fromJSON as _,isExtent as F,isPolygon as w}from"../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridian as Q}from"../../../geometry/support/normalizeUtils.js";import{equals as S,isValid as R}from"../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as I}from"../featureConversionUtils.js";import{getWhereClause as j}from"./attributeSupport.js";import{cleanFromGeometryEngine as b,getGeometry as E}from"./geometryUtils.js";import{project as T,checkProjectionSupport as A,projectMany as v}from"./projectionSupport.js";import{QueryEngineCache as G}from"./QueryEngineCache.js";import{queryCapabilities as k}from"./QueryEngineCapabilities.js";import{QueryEngineResult as C}from"./QueryEngineResult.js";import{queryEngineEmptyResult as O,normalizeAttributeBinsQuery as P,normalizeQueryLike as q,normalizeQuery as z}from"./queryUtils.js";import{validateAttributeBinsQuery as U,validateQuery as B,validateStatisticsQuery as M}from"./queryValidationUtils.js";import{getSpatialQueryOperator as H,canQueryWithRBush as N}from"./spatialQuerySupport.js";import{getTimeExtent as Z,getTimeOperator as J}from"./timeSupport.js";import L from"../../support/FieldsIndex.js";import{ImmediateTask as V}from"../../../views/support/Scheduler.js";const D="unsupported-query";class K{constructor(e,t=null,i,r,s){this.attributes=e,this.geometry=i,this.centroid=r,this.filterFlags=s,this.groupId=-1,this.displayId=t}}class W{constructor(e){this._changeHandle=null,this.capabilities={query:k},this.geometryType=e.geometryType,this.hasM=!!e.hasM,this.hasZ=!!e.hasZ,this.spatialReference=e.spatialReference,this.definitionExpression=e.definitionExpression,this.featureStore=e.featureStore,this.aggregateAdapter=e.aggregateAdapter,this._cache=e.cache??new G,this.timeInfo=e.timeInfo,this.featureIdInfo=e.featureIdInfo,"object-id"===e.featureIdInfo.type&&(this.objectIdField=e.featureIdInfo.fieldName),this._changeHandle=this.featureStore.events.on("changed",()=>this._clearCache()),this.fieldsIndex=c(e.fieldsIndex)?e.fieldsIndex:L.fromJSON(e.fieldsIndex),!e.availableFields||1===e.availableFields.length&&"*"===e.availableFields[0]?this.availableFields=new Set(this.fieldsIndex.fields.map(e=>e.name)):this.availableFields=new Set(e.availableFields.map(e=>this.fieldsIndex.get(e)?.name).filter(e=>null!=e)),e.scheduler&&e.priority?this._frameTask=e.scheduler.registerTask(e.priority):this._frameTask=V}destroy(){this._changeHandle=a(this._changeHandle),this._frameTask=a(this._frameTask),this._clearCache(),n(this._cache)}get featureAdapter(){return this.featureStore.featureAdapter}async executeQuery(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryFeatureSet(e),i)}async executeQueryForCount(e={},t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForCount(e),i)}async executeQueryForExtent(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForExtent(e),i)}async executeQueryForIds(e,t){return Array.from(await this.executeQueryForIdSet(e,t))}async executeQueryForIdSet(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForIdSet(e),i)}async executeQueryForLatestObservations(e,t){const i=l(t);if(!this.timeInfo?.trackIdField)throw new r(D,"Missing timeInfo or timeInfo.trackIdField",{query:e,timeInfo:this.timeInfo});return await this._frameTask.scheduleGenerator(()=>this._executeQueryForLatestObservations(e),i)}async executeQueryForOpaqueFeatures(e,t){const i=l(t);return(await this._frameTask.scheduleGenerator(()=>this._executeQuery(e,{}),i)).items}async executeAttributeBinsQuery(e,t){const i=l(t);return e=s(e),await this._frameTask.scheduleGenerator(()=>this._executeAttributeBinsQuery(e),i)}async executeQueryForSummaryStatistics(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForSummaryStatistics(e,t),r)}async executeQueryForUniqueValues(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForUniqueValues(e,t),r)}async executeQueryForClassBreaks(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForClassBreaks(e,t),r)}async executeQueryForHistogram(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForHistogram(e,t),r)}async executeQueryForSnapping(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForSnapping(e,i),i)}async fetchRecomputedExtents(e){const t=l(e);this._timeExtentPromise||=Z(this.timeInfo,this.featureStore);const[i,r]=await Promise.all([this._getFullExtent(),this._timeExtentPromise]);return u(t),{fullExtent:i,timeExtent:r}}_clearCache(){this._cache.clear(),this._allFeaturesPromise=null,this._timeExtentPromise=null,this._fullExtentPromise=null}async*_executeQueryFeatureSet(e){try{const t=yield*this._executeQuery(e,{});return yield,await t.createQueryResponse()}catch(t){if(t!==O)throw t;return await new C([],e,this).createQueryResponse()}}async*_executeQueryForCount(e){try{const t=yield*this._executeQuery(e,{returnGeometry:!1,returnCentroid:!1,outSR:null});return yield,t.createQueryResponseForCount()}catch(t){if(t!==O)throw t;return 0}}async*_executeQueryForExtent(e){const t=e.outSR;try{const i=yield*this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null});yield;const r=i.size;if(!r)return{count:0,extent:null};const s=await this._getBounds(i.items,i.spatialReference,t??this.spatialReference);return yield,{count:r,extent:s}}catch(i){if(i===O)return{count:0,extent:null};throw i}}async*_executeQueryForIdSet(e){try{const t=yield*this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null});yield;const i=t.items,r=new Set;for(const e of i)r.add(t.featureAdapter.getObjectId(e));return r}catch(t){if(t===O)return new Set;throw t}}async*_executeQueryForLatestObservations(e){try{const t=yield*this._executeQuery(e,{});return yield,this._filterLatest(t),yield,await t.createQueryResponse()}catch(t){if(t!==O)throw t;return await new C([],e,this).createQueryResponse()}}async*_executeAttributeBinsQuery(e){let t;try{e=await P(e,this.definitionExpression,this.spatialReference),yield,e=await U(e,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield;const i=yield*this._executeSceneFilterQuery(e);yield,t=yield*this._executeGeometryQuery(e,i),yield,this._executeAggregateIdsQuery(t),yield,this._executeObjectIdsQuery(t),yield,this._executeTimeQuery(t),yield,this._executeAttributesQuery(t),yield}catch(i){if(i!==O)throw i;t=new C([],e,this)}return await t.createQueryBinsResponse(e)}async*_executeQueryForSummaryStatistics(e={},t){const{field:i,normalizationField:r,valueExpression:s}=t,a=yield*this._executeQueryForStatistics(e,{field:i,normalizationField:r,valueExpression:s});return yield,await a.createSummaryStatisticsResponse(t)}async*_executeQueryForUniqueValues(e={},t){const{field:i,field2:r,field3:s,valueExpression:a}=t,n=yield*this._executeQueryForStatistics(e,{field:i,field2:r,field3:s,valueExpression:a});return yield,await n.createUniqueValuesResponse(t)}async*_executeQueryForClassBreaks(e,t){const{field:i,normalizationField:r,valueExpression:s}=t,a=yield*this._executeQueryForStatistics(e,{field:i,normalizationField:r,valueExpression:s});return yield,await a.createClassBreaksResponse(t)}async*_executeQueryForHistogram(e,t){const{field:i,normalizationField:r,valueExpression:s}=t,a=yield*this._executeQueryForStatistics(e,{field:i,normalizationField:r,valueExpression:s});return yield,await a.createHistogramResponse(t)}async*_executeQueryForSnapping(e,t){const{point:i,distance:r,returnEdge:a,vertexMode:n}=e;if(!a&&"none"===n)return{candidates:[]};let l=s(e.query);l=await q(l,this.definitionExpression,this.spatialReference),yield,l=await B(l,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield;const u=!S(i.spatialReference,this.spatialReference);u&&(await A(i.spatialReference,this.spatialReference),yield);const o="number"==typeof r?r:r.x,c="number"==typeof r?r:r.y,y={xmin:i.x-o,xmax:i.x+o,ymin:i.y-c,ymax:i.y+c,spatialReference:i.spatialReference},h=u?T(y,this.spatialReference):y;if(!h)return{candidates:[]};const d=(await Q(_(i),null,{signal:t}))[0];yield;const m=(await Q(_(h),null,{signal:t}))[0];if(yield,null==d||null==m)return{candidates:[]};const f=await this._searchFeatures(X(m.toJSON()));yield;const p=new C(f,l,this);this._executeObjectIdsQuery(p),yield,this._executeTimeQuery(p),yield,this._executeAttributesQuery(p),yield,yield*this._executeGeometryQueryForSnapping(p),yield;const x=d.toJSON(),g=u?T(x,this.spatialReference):x,F=u?Math.max(h.xmax-h.xmin,h.ymax-h.ymin)/2:r;return p.createSnappingResponse({...e,point:g,distance:F},l.returnZ,i.spatialReference)}async _getBounds(e,t,i){const r=h(m(),d);return await this.featureStore.forEachBounds(e,e=>f(r,e)),Y(r,t,i,this.spatialReference,this.hasZ)}_getFullExtent(){return this._fullExtentPromise||="getFullExtent"in this.featureStore&&this.featureStore.getFullExtent?Promise.resolve(this.featureStore.getFullExtent(this.spatialReference)):this._getAllFeatures().then(e=>this._getBounds(e,this.spatialReference,this.spatialReference)),this._fullExtentPromise}async _getAllFeaturesQueryEngineResult(e){return new C(await this._getAllFeatures(),e,this)}async _getAllFeatures(){if(null==this._allFeaturesPromise){const e=[];this._allFeaturesPromise=(async()=>await this.featureStore.forEach(t=>e.push(t)))().then(()=>i(e))}const e=this._allFeaturesPromise,t=await e;return e===this._allFeaturesPromise?t.slice():this._getAllFeatures()}async*_executeQuery(e,t){e=s(e),e=await z(e,this.definitionExpression,this.spatialReference),yield,e=await B(e,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield,e={...e,...t};const i=yield*this._executeSceneFilterQuery(e);yield;const r=yield*this._executeGeometryQuery(e,i);return yield,this._executeAggregateIdsQuery(r),yield,this._executeObjectIdsQuery(r),yield,this._executeTimeQuery(r),yield,this._executeAttributesQuery(r),r}async*_executeSceneFilterQuery(e){if(null==e.sceneFilter)return null;const{outSR:t,returnGeometry:i,returnCentroid:r}=e,s=this.featureStore.featureSpatialReference,a=e.sceneFilter.geometry,n=null==s||S(s,a.spatialReference)?a:T(a,s);if(!n)return null;const l=i||r,u=R(t)&&!S(this.spatialReference,t)&&l?async e=>this._project(e,t):e=>e;yield;const o=this.featureAdapter,c=await this._searchFeatures(X(n));yield;if("disjoint"===e.sceneFilter.spatialRelationship){if(!c.length)return null;const t=new Set;for(const e of c)t.add(o.getObjectId(e));const i=await this._getAllFeatures();yield;const r=await H("esriSpatialRelDisjoint",n,this.geometryType);yield;const s=e=>!t.has(o.getObjectId(e))||r(o.getGeometry(e)),a=yield*this._runSpatialFilter(i,s);yield;const l=new C(a,e,this);return await u(l)}if(!c.length)return new C([],e,this);if(this._canExecuteSinglePass(n,e))return await u(new C(c,e,this));const y=await H("esriSpatialRelContains",n,this.geometryType);yield;const h=yield*this._runSpatialFilter(c,e=>y(o.getGeometry(e)));return yield,await u(new C(h,e,this))}async*_executeGeometryQuery(i,r){if(null!=r&&0===r.items.length)return r;const{geometry:s,outSR:a,returnGeometry:n,returnCentroid:l}=i,u=r?null:this._getCacheKey(i),o=u?this._cache.get(u):null;if(o)return new C(o,i,this);const c=R(a)&&!S(this.spatialReference,a),y=n||l,h=async e=>(c&&y&&await this._project(e,a),u&&this._cache.put(u,e.items),e),d=this.featureStore.featureSpatialReference,m=!s||null==d||S(d,s.spatialReference)?s:T(s,d);if(!m)return await h(null!=r?r:await this._getAllFeaturesQueryEngineResult(i));yield;const f=this.featureAdapter;let p=await this._searchFeatures(X(s));yield;const x=i.spatialRel??"esriSpatialRelIntersects";if("esriSpatialRelDisjoint"===x){if(!p.length)return await h(null!=r?r:await this._getAllFeaturesQueryEngineResult(i));const e=new Set;for(const i of p)e.add(f.getObjectId(i));let t;null!=r?t=r.items:(yield,t=await this._getAllFeatures(),yield);const s=await H(x,m,this.geometryType);yield;const a=t=>!e.has(f.getObjectId(t))||s(f.getGeometry(t)),n=yield*this._runSpatialFilter(t,a);yield;const l=new C(n,i,this);return await h(l)}if(null!=r){const i=new t;p=p.filter(t=>e(r.items,t,r.items.length,i)>=0)}if(!p.length){const e=new C([],i,this);return u&&this._cache.put(u,e.items),e}if(this._canExecuteSinglePass(m,i))return await h(new C(p,i,this));const g=await H(x,m,this.geometryType);yield;const _=yield*this._runSpatialFilter(p,e=>g(f.getGeometry(e)));return yield,await h(new C(_,i,this))}_executeAggregateIdsQuery(e){if(0===e.items.length||!e.query.aggregateIds?.length||null==this.aggregateAdapter)return;const t=new Set;for(const r of e.query.aggregateIds){this.aggregateAdapter.getFeatureObjectIds(r).forEach(e=>t.add(e))}const i=this.featureAdapter.getObjectId;e.items=e.items.filter(e=>t.has(i(e)))}_executeObjectIdsQuery(e){if(0===e.items.length||!e.query.objectIds?.length)return;const t=new Set(e.query.objectIds),i=this.featureAdapter.getObjectId;e.items=e.items.filter(e=>t.has(i(e)))}_executeTimeQuery(e){if(0===e.items.length)return;const t=J(this.timeInfo,e.query.timeExtent,this.featureAdapter);null!=t&&(e.items=e.items.filter(t))}_executeAttributesQuery(e){if(0===e.items.length)return;const t=j(e.query.where,this.fieldsIndex);if(t){if(!t.isStandardized)throw new TypeError("Where clause is not standardized");e.items=e.items.filter(e=>t.testFeature(e,this.featureAdapter))}}async*_executeGeometryQueryForSnapping(e){const{query:t}=e,{spatialRel:i}=t;if(!e?.items?.length||!t.geometry||!i)return;const r=await H(i,t.geometry,this.geometryType);yield;const s=this.featureAdapter,a=e=>r(s.getGeometry(e)),n=yield*this._runSpatialFilter(e.items,a);e.items=n}*_runSpatialFilter(e,t){if(!t)return e;if(null==this._frameTask)return e.filter(e=>t(e));let i=yield;const r=new Array;for(const s of e)t(s)&&r.push(s),i.madeProgress(),i.done&&(i=yield);return r}_filterLatest(e){const{trackIdField:t,startTimeField:i,endTimeField:r}=this.timeInfo,s=r||i,a=new Map,n=this.featureAdapter.getAttribute;for(const l of e.items){const e=n(l,t),i=n(l,s),r=a.get(e);(!r||i>n(r,s))&&a.set(e,l)}e.items=Array.from(a.values())}_getCacheKey(e){const{geometry:t,spatialRel:i,returnGeometry:r,returnCentroid:s,outSR:a,resultType:n,cacheHint:l}=e;if("tile"!==n&&!l)return null;const u=r||s;return R(a)&&!S(this.spatialReference,a)&&u?JSON.stringify([t,i,a]):JSON.stringify([t,i])}_canExecuteSinglePass(e,t){const{spatialRel:i}=t;return N(e)&&("esriSpatialRelEnvelopeIntersects"===i||"esriGeometryPoint"===this.geometryType&&("esriSpatialRelIntersects"===i||"esriSpatialRelContains"===i))}async _project(e,t){if(!t||S(this.spatialReference,t))return e;const r=this.featureAdapter,s=y()?await this._getFullExtent():void 0,a=await v(e.items.map(e=>E(this.geometryType,r.getGeometry(e))),this.spatialReference,t,{areaOfInterestExtent:s});return e.items=i(a.map((t,i)=>r.cloneWithGeometry(e.items[i],I(t,this.hasZ,this.hasM)))),e}async _searchFeatures(e){const t=new Set;await Promise.all(e.map(e=>this.featureStore.forEachInBounds(e,e=>t.add(e))));const i=Array.from(t.values());return t.clear(),i}async*_executeQueryForStatistics(e,t){e=s(e);try{e=await z(e,this.definitionExpression,this.spatialReference),yield,e=await M(e,t,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield;const i=yield*this._executeSceneFilterQuery(e);yield;const r=yield*this._executeGeometryQuery(e,i);return yield,this._executeAggregateIdsQuery(r),yield,this._executeObjectIdsQuery(r),yield,this._executeTimeQuery(r),yield,this._executeAttributesQuery(r),yield,r}catch(i){if(i!==O)throw i;return new C([],e,this)}}get test(){}}function X(e){if(N(e)){if(F(e))return[p(Math.min(e.xmin,e.xmax),Math.min(e.ymin,e.ymax),Math.max(e.xmin,e.xmax),Math.max(e.ymin,e.ymax))];if(w(e))return e.rings.map(e=>p(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[g(x(),e)]}function Y(e,t,i,r,s){const a={xmin:e[0],ymin:e[1],xmax:e[3],ymax:e[4],spatialReference:b(r)};s&&isFinite(e[2])&&isFinite(e[5])&&(a.zmin=e[2],a.zmax=e[5],a.hasZ=!0);const n=T(a,t,i);if(n.spatialReference=b(i),n.xmax-n.xmin===0){const e=o(n.spatialReference);n.xmin-=e,n.xmax+=e}if(n.ymax-n.ymin===0){const e=o(n.spatialReference);n.ymin-=e,n.ymax+=e}if(s&&null!=n.zmin&&null!=n.zmax&&n.zmax-n.zmin===0){const e=o(n.spatialReference);n.zmin-=e,n.zmax+=e}return n}export{K as Feature,W as QueryEngine,Y as getQueryResultExtent};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{clone as e}from"../../../core/lang.js";import{polygonCentroid as t,extentCentroid as i}from"../../../geometry/support/centroid.js";import{getPolygonExtent as s,getGeometryExtent as a}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as r}from"../../../geometry/support/quantizationUtils.js";import{isValid as n,equals as o}from"../../../geometry/support/spatialReferenceUtils.js";import l from"./AttributesBuilder.js";import{cleanFromGeometryEngine as u,getGeometry as c,transformCentroid as m}from"./geometryUtils.js";import{project as d}from"./projectionSupport.js";import{getDateInNumber as h}from"./queryUtils.js";import{makeEdgeCandidate as f,makeVertexCandidate as p}from"./SnappingCandidate.js";import{isDateField as y,isDateOnlyField as g,isTimestampOffsetField as x,isStringField as T,isTimeOnlyField as F}from"../../support/fieldUtils.js";import I from"../../../rest/support/AutoIntervalBinParameters.js";import _ from"../../../rest/support/DateBinParameters.js";import{unitsDict as S}from"../../../rest/support/DateBinUtils.js";import V from"../../../rest/support/FixedBoundariesBinParameters.js";import b from"../../../rest/support/FixedIntervalBinParameters.js";import{calculateStringStatistics as v,calculateStatistics as R,processSummaryStatisticsResult as B,calculateUniqueValuesCount as z,createUVResult as M,calculateClassBreaks as A,resolveCBResult as N,calculateHistogram as D,getAttributeComparator as w,calculatePercentile as P,binIndex as q,getBinParams as Z,isNullCountSupported as j}from"../../../statistics/utils.js";import{utc as G}from"../../../time/constants.js";import{DateTime as C}from"luxon";const O="bin";class E{constructor(e,t,i){this.items=e,this.query=t,this.geometryType=i.geometryType,this.hasM=i.hasM,this.hasZ=i.hasZ,this.fieldsIndex=i.fieldsIndex,this.objectIdField=i.objectIdField,this.spatialReference=i.spatialReference,this.featureAdapter=i.featureAdapter}get size(){return this.items.length}createQueryResponseForCount(){const e=new l(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:i,outStatistics:s}=this.query,a=t?.length;if(!!!a)return 1;const r=new Map,n=new Map,o=new Set;for(const l of s){const{statisticType:s}=l,a="exceedslimit"!==s?l.onStatisticField:void 0;if(!n.has(a)){const i=[];for(const s of t){const t=this._getAttributeValues(e,s,this.items,r);i.push(t)}n.set(a,this._calculateUniqueValues(i,this.items,e.returnDistinctValues))}const u=n.get(a);for(const t in u){const{data:s,items:a}=u[t],r=s.join(",");i&&!e.validateItems(a,i)||o.add(r)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some(e=>"exceedslimit"===e.statisticType)?this._createExceedsLimitQueryResponse():await this._createStatisticsQueryResponse(this.query,this.items)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;n(this.query.outSR)&&!o(t.spatialReference,this.query.outSR)?e.queryGeometry=u({spatialReference:this.query.outSR,...d(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=u({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t,i){const s=this.featureAdapter,a=Q(this.hasZ,this.hasM),{point:r,mode:n}=e,o="number"==typeof e.distance?e.distance:e.distance.x,l="number"==typeof e.distance?e.distance:e.distance.y,u={candidates:[]},c="esriGeometryPolygon"===this.geometryType,m="esriGeometryPolyline"===this.geometryType||"esriGeometryPoint"===this.geometryType,d=this._getPointCreator(n,t,this.spatialReference,i),h=new U(null,0),y=new U(null,0),g={x:0,y:0,z:0};for(const x of this.items){const t=s.getGeometry(x);if(null==t)continue;const{coords:i}=t,n=t.isPoint?J:t.lengths;if(h.coords=i,y.coords=i,e.returnEdge){let e=0;for(let t=0;t<n.length;t++){const i=n[t],m=e;for(let t=0;t<i;t++,e+=a){if(!c&&t===i-1)continue;const n=h;n.coordsIndex=e;const p=y;p.coordsIndex=t===i-1?m:e+a;const T=g;if(!H(g,r,n,p))continue;const F=(r.x-T.x)/o,I=(r.y-T.y)/l,_=F*F+I*I;_<=1&&u.candidates.push(f(s.getObjectId(x),d(T),Math.sqrt(_),d(n),d(p)))}}}if("all"===e.vertexMode){let e=0;for(let t=0;t<n.length;t++){const i=n[t],m=e,f=y;f.coordsIndex=m;for(let t=0;t<i;t++,e+=a){const a=h;if(a.coordsIndex=e,c&&t===i-1&&a.x===f.x&&a.y===f.y)continue;const n=(r.x-a.x)/o,m=(r.y-a.y)/l,y=n*n+m*m;y<=1&&u.candidates.push(p(s.getObjectId(x),d(a),Math.sqrt(y)))}}}else if(m&&"ends"===e.vertexMode){let e=0;const t=[];for(let i=0;i<n.length;i++){t.push(e);const s=n[i];e+=s*a,!c&&s>1&&t.push(e-a)}for(const i of t){const e=h;e.coordsIndex=i;const t=(r.x-e.x)/o,a=(r.y-e.y)/l,n=t*t+a*a;n<=1&&u.candidates.push(p(s.getObjectId(x),d(e),Math.sqrt(n)))}}}return u.candidates.sort((e,t)=>e.distance-t.distance),u}_getPointCreator(e,t,i,s){const a=null==s||o(i,s)?e=>e:e=>d(e,i,s),{hasZ:r}=this,n=0;return"3d"===e?r&&t?({x:e,y:t,z:i})=>a({x:e,y:t,z:i}):({x:e,y:t})=>a({x:e,y:t,z:n}):({x:e,y:t})=>a({x:e,y:t})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,minValue:n,maxValue:o,scale:l,timeZone:u,outStatisticTypes:c}=e,m=this.fieldsIndex.get(t),d=y(m)||g(m)||x(m),h=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:l,timeZone:u},this.items),f=j({normalizationType:a,normalizationField:s,minValue:n,maxValue:o}),p={value:.5,fieldType:m?.type},F=T(m)?v({values:h,supportsNullCount:f,percentileParams:p,outStatisticTypes:c}):R({values:h,minValue:n,maxValue:o,useSampleStdDev:!a,supportsNullCount:f,percentileParams:p,outStatisticTypes:c});return B(F,c,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:i,domains:s,returnAllCodedValues:a,scale:r,timeZone:n}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:i,scale:r,timeZone:n},this.items,!1),l=z(o);return M(l,s,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:m,timeZone:d}=e,h=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:m,timeZone:d},this.items),f=A(h,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return N(f,n)}async createHistogramResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:m,timeZone:d}=e,h=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:m,timeZone:d},this.items);return D(h,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,i){if(e.length>1&&t?.length)for(const s of t.slice().reverse()){const t=s.split(" "),a=t[0],r=this.fieldsIndex.get(a),n=!!t[1]&&"desc"===t[1].toLowerCase(),o=w(r?.type,n);e.sort((e,t)=>{const s=i(e,a,r),n=i(t,a,r);return o(s,n)})}}_createFeatureQueryResponse(e){const{items:t,geometryType:i,hasM:s,hasZ:a,objectIdField:n,spatialReference:o}=this,{outFields:l,outSR:c,quantizationParameters:m,resultRecordCount:d,resultOffset:h,returnZ:f,returnM:p}=e,y=null!=d&&t.length>(h||0)+d,g=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map(e=>this.fieldsIndex.get(e)));return{exceededTransferLimit:y,features:this._createFeatures(e,t),fields:g,geometryType:i,hasM:s&&p,hasZ:a&&f,objectIdFieldName:n,spatialReference:u(c||o),transform:m&&r(m)||null}}_createFeatures(e,t){const i=new l(e,this.featureAdapter,this.fieldsIndex),{hasM:s,hasZ:a}=this,{orderByFields:n,quantizationParameters:o,returnGeometry:u,returnCentroid:d,maxAllowableOffset:h,resultOffset:f,resultRecordCount:p,returnZ:y=!1,returnM:g=!1}=e,x=a&&y,T=s&&g;let F=[],I=0;const _=[...t];if(this._sortFeatures(_,n,(e,t,s)=>i.getFieldValue(e,t,s)),this.geometryType&&(u||d)){const e=r(o)??void 0,t="esriGeometryPolygon"===this.geometryType||"esriGeometryPolyline"===this.geometryType;if(u&&!d)for(const s of _){const a=this.featureAdapter.getGeometry(s),r=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),geometry:c(this.geometryType,this.hasZ,this.hasM,a,h,e,x,T)});t&&a&&!r.geometry&&(r.centroid=m(this,this.featureAdapter.getCentroid(s,this),e)),F[I++]=r}else if(!u&&d)for(const s of _)F[I++]=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),centroid:m(this,this.featureAdapter.getCentroid(s,this),e)});else for(const s of _)F[I++]=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),centroid:m(this,this.featureAdapter.getCentroid(s,this),e),geometry:c(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(s),h,e,x,T)})}else for(const r of _){const e=i.getAttributes(r);e&&(F[I++]=this._addFeatureJSONMetadata(r,{attributes:e}))}const S=f||0;if(null!=p){const e=S+p;F=F.slice(S,Math.min(F.length,e))}return F}_addFeatureJSONMetadata(e,t){const i=this.featureAdapter.getMetadata?.(e);return void 0!==i&&(t.metadata=i),t}_createExceedsLimitQueryResponse(){let e=!1,t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY;for(const a of this.query.outStatistics??[])if("exceedslimit"===a.statisticType){t=null!=a.maxPointCount?a.maxPointCount:Number.POSITIVE_INFINITY,i=null!=a.maxRecordCount?a.maxRecordCount:Number.POSITIVE_INFINITY,s=null!=a.maxVertexCount?a.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)e=this.items.length>t;else if(this.items.length>i)e=!0;else{const t=Q(this.hasZ,this.hasM),i=this.featureAdapter;e=this.items.reduce((e,t)=>{const s=i.getGeometry(t);return e+(null!=s&&s.coords.length||0)},0)/t>s}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(e)}}]}}async _createStatisticsQueryResponse(e,t,i={attributes:{}}){const s=[],a=new Map,r=new Map,n=new Map,o=new Map,u=new l(e,this.featureAdapter,this.fieldsIndex),c=e.outStatistics,{groupByFieldsForStatistics:m,having:d,orderByFields:h,resultRecordCount:f}=e,p=m?.length,y=!!p,g=y?m[0]:null,x=y&&!this.fieldsIndex.get(g);for(const l of c??[]){const{outStatisticFieldName:e,statisticType:c}=l,h=l,f="exceedslimit"!==c?l.onStatisticField:void 0,F="percentile_disc"===c||"percentile_cont"===c,I="EnvelopeAggregate"===c||"CentroidAggregate"===c||"ConvexHullAggregate"===c,_=y&&1===p&&(f===g||x)&&"count"===c;if(y){if(!n.has(f)){const e=[];for(const i of m){const s=this._getAttributeValues(u,i,t,a);e.push(s)}n.set(f,this._calculateUniqueValues(e,t,!I&&u.returnDistinctValues))}const i=n.get(f);if(!i)continue;const s=Object.keys(i);for(const r of s){const{count:s,data:n,items:l,itemPositions:c}=i[r],p=n.join(",");if(!d||u.validateItems(l,d)){const i=o.get(p)||{attributes:{}};if(I){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(h,l);i.aggregateGeometries[t]=e}else{let r=null;if(_)r=s;else{const e=this._getAttributeValues(u,f,t,a),i=c.map(t=>e[t]);r=F&&"statisticParameters"in h?this._getPercentileValue(h,i):this._getStatisticValue(h,i,null,u.returnDistinctValues)}i.attributes[e]=r}let r=0;m.forEach((e,t)=>i.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++r]=n[t]),o.set(p,i)}}}else if(I){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(h,t);i.aggregateGeometries[s]=e}else{const s=this._getAttributeValues(u,f,t,a);i.attributes[e]=F&&"statisticParameters"in h?this._getPercentileValue(h,s):this._getStatisticValue(h,s,r,u.returnDistinctValues)}const S="min"!==c&&"max"!==c||!T(this.fieldsIndex.get(f))&&!this._isAnyDateField(f)?null:this.fieldsIndex.get(f)?.type;s.push({name:e,alias:e,type:S||"esriFieldTypeDouble"})}const F=y?Array.from(o.values()):[i];return this._sortFeatures(F,h,(e,t)=>e.attributes[t]),f&&(F.length=Math.min(f,F.length)),{fields:s,features:F}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return y(t)||g(t)||x(t)||F(t)}async _getAggregateGeometry(e,r){const{convexHull:n,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:m,spatialReference:d,geometryType:h,hasZ:f,hasM:p}=this,y=r.map(e=>c(h,f,p,m.getGeometry(e))),g=n(d,y,!0)[0],x={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=g?s(g):a(o(d,y));x.aggregateGeometries={...e,spatialReference:d},x.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=g?t(g):i(a(o(d,y)));x.aggregateGeometries={x:e[0],y:e[1],spatialReference:d},x.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(x.aggregateGeometries=g,x.outStatisticFieldName=u||"convexHull");return x}_getStatisticValue(e,t,i,s){const{onStatisticField:a,statisticType:r}=e;let n=null;n=i?.has(a)?i.get(a):T(this.fieldsIndex.get(a))||this._isAnyDateField(a)?v({values:t,returnDistinct:s}):R({values:s?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),i&&i.set(a,n);return n["var"===r?"variance":r]}_getPercentileValue(e,t){const{onStatisticField:i,statisticParameters:s,statisticType:a}=e,{value:r,orderBy:n}=s,o=this.fieldsIndex.get(i);return P(t,{value:r,orderBy:n,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,i,s){if(s.has(t))return s.get(t);const a=this.fieldsIndex.get(t),r=i.map(i=>e.getFieldValue(i,t,a));return s.set(t,r),r}_calculateUniqueValues(e,t,i){const s={},a=t.length;for(let r=0;r<a;r++){const a=t[r],n=[];for(const t of e)n.push(t[r]);const o=n.join(",");null==s[o]?s[o]={count:1,data:n,items:[a],itemPositions:[r]}:(i||s[o].count++,s[o].items.push(a),s[o].itemPositions.push(r))}return s}async _getDataValues(t,i,s=!0){const a=new l(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:r,scale:n,timeZone:o}=t;return r?a.getExpressionValues(i,r,{viewingMode:"map",scale:n,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},o):a.getDataValues(i,e(t),s)}_calculateHistogramBins(e,t,i){if(null==t.min&&null==t.max)return[];const s=t.intervals,a=t.min??0,r=t.max??0,n=s.map(([e,t])=>({minValue:e,maxValue:t,count:0,items:[]}));for(let o=0;o<e.length;o++){const t=e[o],l=i[o];if(null!=t&&t>=a&&t<=r){const e=q(s,t);e>-1&&(n[e].count++,n[e].items.push(l))}}return n}async createQueryBinsResponse(e){const t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);const{value:i,outAlias:s,valueType:a}=t,r=[],n=[{name:s??i,alias:s??i,type:a??"esriFieldTypeString"},{name:O,alias:O,type:"esriFieldTypeInteger"}],o=new l(e,this.featureAdapter,this.fieldsIndex),u=new Map,c=[...this.items];this._sortFeatures(c,[i],(e,t,i)=>o.getFieldValue(e,t,i));const m=this._getAttributeValues(o,i,c,u),d=this._calculateUniqueValues([m],c,o.returnDistinctValues);for(const l in d){const{items:t}=d[l],a=await this._createBinsResponse(e,t);if(r.push(...a.features.map(e=>({...e,attributes:{...e.attributes,[s??i]:l}}))),a.fields)for(const e of a.fields)n.some(t=>t.name===e.name)||n.push(e)}return{fields:n,features:r}}async _createBinsResponse(e,t){const i=e.bin;switch(t=t??this.items,i.type){case"autoIntervalBin":return this._createAutoIntervalBinsResponse(I.fromJSON(i),e,t);case"dateBin":return this._createDateBinsResponse(_.fromJSON(i),e,t);case"fixedBoundariesBin":return this._createFixedBoundariesBinsResponse(V.fromJSON(i),e,t);case"fixedIntervalBin":return this._createFixedIntervalBinsResponse(b.fromJSON(i),e,t)}}async _createAutoIntervalBinsResponse(e,t,i){const{field:s,normalizationField:a,numBins:r,normalizationType:n,normalizationTotal:o,start:l,end:u}=e,c=await this._getDataValues({field:e.field,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},i),m=Z(c,{field:s,normalizationField:a,normalizationType:n,normalizationTotal:o,numBins:r,minValue:h(l,!1),maxValue:h(u,!1)}),d=this._calculateHistogramBins(c,m,i);return this._createFeaturesFromHistogramBins(d,t)}async _createDateBinsResponse(e,t,i){const{field:s,interval:a,start:r,end:n,snapToData:o,returnFullIntervalBin:l}=e,u=a.unit,c=await this._getDataValues({field:e.field,timeZone:t.outTimeReference?.ianaTimeZone},i),m=F(this.fieldsIndex.get(s)),d=S.toJSON(u),f=c.filter(Boolean).sort((e,t)=>e-t),p=null!=r?h(r,m):f[0],y=null!=n?h(n,m):f[f.length-1],g={zone:t.outTimeReference?.ianaTimeZone??G},x=C.fromMillis(p,g),T=C.fromMillis(y,g),I=[];if("last"===o){let e=T;for(;e>x;){const t=e.minus({[d]:a.value});if(t<x){I.unshift([l?t.toMillis():x.toMillis(),e.toMillis()]);break}I.unshift([t.toMillis(),e.toMillis()]),e=t}}else{let e="first"===o?x:x.startOf(d);for(;e<=T;){const t=e.plus({[d]:a.value});if(t>T){I.push([e.toMillis(),l?t.toMillis():T.toMillis()]);break}I.push([e.toMillis(),t.toMillis()]),e=t}}const _=this._calculateHistogramBins(c,{intervals:I,min:p,max:y},i);return this._createFeaturesFromHistogramBins(_,t)}async _createFixedBoundariesBinsResponse(e,t,i){const{field:s}=e,a=await this._getDataValues({field:s,timeZone:t.outTimeReference?.ianaTimeZone},i),r=F(this.fieldsIndex.get(s)),n=e.boundaries.map(e=>h(e,r)).sort((e,t)=>e-t),o=[];for(let c=0;c<n.length-1;c++)o.push([n[c],n[c+1]]);const l={intervals:o,min:n.at(0),max:n.at(-1)},u=this._calculateHistogramBins(a,l,i);return this._createFeaturesFromHistogramBins(u,t)}async _createFixedIntervalBinsResponse(e,t,i){const{field:s,interval:a,start:r,end:n}=e,o=await this._getDataValues({field:e.field,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},i),l=F(this.fieldsIndex.get(s)),u=Z(o,{field:s,classificationMethod:"defined-interval",definedInterval:a,minValue:h(r,l),maxValue:h(n,l)},!0),c=this._calculateHistogramBins(o,u,i);return this._createFeaturesFromHistogramBins(c,t)}async _createFeaturesFromHistogramBins(e,t){const{upperBoundaryAlias:i,lowerBoundaryAlias:s}=t,a=s||"lowerBoundary",r=i||"upperBoundary",n=[],o=[{name:a,alias:a,type:"esriFieldTypeDouble"},{name:r,alias:r,type:"esriFieldTypeDouble"}],l=t.bin?.stackBy?.value,u=t.bin?.stackBy?.outAlias;l&&o.push({name:O,alias:O,type:"esriFieldTypeInteger"},{name:u??l,alias:u??l,type:"esriFieldTypeString"});let c=0;const m="dateBin"===t.bin.type,d=t.outTimeReference?.ianaTimeZone;for(const h of e){const{minValue:e,maxValue:i,items:s}=h,f={attributes:{}};let p;if(f.attributes[a]=m&&d&&null!=e?C.fromMillis(e,{zone:d}).toISO():e,f.attributes[r]=m&&d&&null!=i?C.fromMillis(i,{zone:d}).toISO():i,l?(p=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[l],orderByFields:[l]},s),f.attributes[O]=++c,"flat"===t.bin.jsonStyle?n.push(...p.features.map(({attributes:{EXPR_1:e,...t},...i})=>({...i,attributes:u??e?{...t,[u??e]:e,...f.attributes}:{...t,...f.attributes}}))):(f.stackedAttributes=p.features.map(({attributes:{EXPR_1:e,...t}})=>u??e?{...t,[u??e]:e}:t),n.push(f))):(t.bin?.splitBy&&(f.attributes[O]=++c),p=await this._createStatisticsQueryResponse(t,s,f),n.push(f)),p.fields)for(const t of p.fields)o.some(e=>e.name===t.name)||o.push(t)}return"desc"===t.binOrder&&n.reverse(),{fields:o,features:n}}}function H(e,t,i,s){const a=s.x-i.x,r=s.y-i.y,n=t.x-i.x,o=t.y-i.y,l=a*a+r*r;if(0===l)return!1;const u=n*a+o*r,c=Math.min(1,Math.max(0,u/l));return e.x=i.x+a*c,e.y=i.y+r*c,!0}function Q(e,t){return e?t?4:3:t?3:2}class U{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}const J=[1];export{E as QueryEngineResult};
5
+ import{clone as e}from"../../../core/lang.js";import{polygonCentroid as t,extentCentroid as i}from"../../../geometry/support/centroid.js";import{getPolygonExtent as s,getGeometryExtent as a}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as r}from"../../../geometry/support/quantizationUtils.js";import{isValid as n,equals as o}from"../../../geometry/support/spatialReferenceUtils.js";import l from"./AttributesBuilder.js";import{cleanFromGeometryEngine as u,getGeometry as c,transformCentroid as m}from"./geometryUtils.js";import{project as d}from"./projectionSupport.js";import{getDateInNumber as f}from"./queryUtils.js";import{makeEdgeCandidate as p,makeVertexCandidate as h}from"./SnappingCandidate.js";import{isDateField as y,isDateOnlyField as g,isTimestampOffsetField as x,isStringField as T,isTimeOnlyField as F}from"../../support/fieldUtils.js";import I from"../../../rest/support/AutoIntervalBinParameters.js";import _ from"../../../rest/support/DateBinParameters.js";import{unitsDict as S}from"../../../rest/support/DateBinUtils.js";import V from"../../../rest/support/FixedBoundariesBinParameters.js";import b from"../../../rest/support/FixedIntervalBinParameters.js";import{calculateStringStatistics as v,calculateStatistics as R,processSummaryStatisticsResult as B,calculateUniqueValuesCount as z,createUVResult as M,calculateClassBreaks as A,resolveCBResult as N,calculateHistogram as D,getAttributeComparator as w,calculatePercentile as P,binIndex as q,getBinParams as j,isNullCountSupported as Z}from"../../../statistics/utils.js";import{utc as G}from"../../../time/constants.js";import{DateTime as C}from"luxon";const O="bin";class E{constructor(e,t,i){this.items=e,this.query=t,this.geometryType=i.geometryType,this.hasM=i.hasM,this.hasZ=i.hasZ,this.fieldsIndex=i.fieldsIndex,this.objectIdField=i.objectIdField,this.spatialReference=i.spatialReference,this.featureAdapter=i.featureAdapter}get size(){return this.items.length}createQueryResponseForCount(){const e=new l(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:i,outStatistics:s}=this.query,a=t?.length;if(!!!a)return 1;const r=new Map,n=new Map,o=new Set;for(const l of s){const{statisticType:s}=l,a="exceedslimit"!==s?l.onStatisticField:void 0;if(!n.has(a)){const i=[];for(const s of t){const t=this._getAttributeValues(e,s,this.items,r);i.push(t)}n.set(a,this._calculateUniqueValues(i,this.items,e.returnDistinctValues))}const u=n.get(a);for(const t in u){const{data:s,items:a}=u[t],r=s.join(",");i&&!e.validateItems(a,i)||o.add(r)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some(e=>"exceedslimit"===e.statisticType)?this._createExceedsLimitQueryResponse():await this._createStatisticsQueryResponse(this.query,this.items)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;n(this.query.outSR)&&!o(t.spatialReference,this.query.outSR)?e.queryGeometry=u({spatialReference:this.query.outSR,...d(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=u({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t,i){const s=this.featureAdapter,a=Q(this.hasZ,this.hasM),{point:r,mode:n}=e,o="number"==typeof e.distance?e.distance:e.distance.x,l="number"==typeof e.distance?e.distance:e.distance.y,u={candidates:[]},c="esriGeometryPolygon"===this.geometryType,m="esriGeometryPolyline"===this.geometryType||"esriGeometryPoint"===this.geometryType,d=this._getPointCreator(n,t,this.spatialReference,i),f=new U(null,0),y=new U(null,0),g={x:0,y:0,z:0};for(const x of this.items){const t=s.getGeometry(x);if(null==t)continue;const{coords:i}=t,n=t.isPoint?J:t.lengths;if(f.coords=i,y.coords=i,e.returnEdge){let e=0;for(let t=0;t<n.length;t++){const i=n[t],m=e;for(let t=0;t<i;t++,e+=a){if(!c&&t===i-1)continue;const n=f;n.coordsIndex=e;const h=y;h.coordsIndex=t===i-1?m:e+a;const T=g;if(!H(g,r,n,h))continue;const F=(r.x-T.x)/o,I=(r.y-T.y)/l,_=F*F+I*I;_<=1&&u.candidates.push(p(s.getObjectId(x),d(T),Math.sqrt(_),d(n),d(h)))}}}if("all"===e.vertexMode){let e=0;for(let t=0;t<n.length;t++){const i=n[t],m=e,p=y;p.coordsIndex=m;for(let t=0;t<i;t++,e+=a){const a=f;if(a.coordsIndex=e,c&&t===i-1&&a.x===p.x&&a.y===p.y)continue;const n=(r.x-a.x)/o,m=(r.y-a.y)/l,y=n*n+m*m;y<=1&&u.candidates.push(h(s.getObjectId(x),d(a),Math.sqrt(y)))}}}else if(m&&"ends"===e.vertexMode){let e=0;const t=[];for(let i=0;i<n.length;i++){t.push(e);const s=n[i];e+=s*a,!c&&s>1&&t.push(e-a)}for(const i of t){const e=f;e.coordsIndex=i;const t=(r.x-e.x)/o,a=(r.y-e.y)/l,n=t*t+a*a;n<=1&&u.candidates.push(h(s.getObjectId(x),d(e),Math.sqrt(n)))}}}return u.candidates.sort((e,t)=>e.distance-t.distance),u}_getPointCreator(e,t,i,s){const a=null==s||o(i,s)?e=>e:e=>d(e,i,s),{hasZ:r}=this,n=0;return"3d"===e?r&&t?({x:e,y:t,z:i})=>a({x:e,y:t,z:i}):({x:e,y:t})=>a({x:e,y:t,z:n}):({x:e,y:t})=>a({x:e,y:t})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,minValue:n,maxValue:o,scale:l,timeZone:u,outStatisticTypes:c}=e,m=this.fieldsIndex.get(t),d=y(m)||g(m)||x(m),f=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:l,timeZone:u},this.items),p=Z({normalizationType:a,normalizationField:s,minValue:n,maxValue:o}),h={value:.5,fieldType:m?.type},F=T(m)?v({values:f,supportsNullCount:p,percentileParams:h,outStatisticTypes:c}):R({values:f,minValue:n,maxValue:o,useSampleStdDev:!a,supportsNullCount:p,percentileParams:h,outStatisticTypes:c});return B(F,c,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:i,domains:s,returnAllCodedValues:a,scale:r,timeZone:n}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:i,scale:r,timeZone:n},this.items,!1),l=z(o);return M(l,s,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:m,timeZone:d}=e,f=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:m,timeZone:d},this.items),p=A(f,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return N(p,n)}async createHistogramResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:m,timeZone:d}=e,f=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:m,timeZone:d},this.items);return D(f,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,i){if(e.length>1&&t?.length)for(const s of t.slice().reverse()){const t=s.split(" "),a=t[0],r=this.fieldsIndex.get(a),n=!!t[1]&&"desc"===t[1].toLowerCase(),o=w(r?.type,n);e.sort((e,t)=>{const s=i(e,a,r),n=i(t,a,r);return o(s,n)})}}_createFeatureQueryResponse(e){const{items:t,geometryType:i,hasM:s,hasZ:a,objectIdField:n,spatialReference:o}=this,{outFields:l,outSR:c,quantizationParameters:m,resultRecordCount:d,resultOffset:f,returnZ:p,returnM:h}=e,y=null!=d&&t.length>(f||0)+d,g=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map(e=>this.fieldsIndex.get(e)));return{exceededTransferLimit:y,features:this._createFeatures(e,t),fields:g,geometryType:i,hasM:s&&h,hasZ:a&&p,objectIdFieldName:n,spatialReference:u(c||o),transform:m&&r(m)||null}}_createFeatures(e,t){const i=new l(e,this.featureAdapter,this.fieldsIndex),{hasM:s,hasZ:a}=this,{orderByFields:n,quantizationParameters:o,returnGeometry:u,returnCentroid:d,maxAllowableOffset:f,resultOffset:p,resultRecordCount:h,returnZ:y=!1,returnM:g=!1}=e,x=a&&y,T=s&&g;let F=[],I=0;const _=[...t];if(this._sortFeatures(_,n,(e,t,s)=>i.getFieldValue(e,t,s)),this.geometryType&&(u||d)){const e=r(o)??void 0,t="esriGeometryPolygon"===this.geometryType||"esriGeometryPolyline"===this.geometryType;if(u&&!d)for(const s of _){const a=this.featureAdapter.getGeometry(s),r=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),geometry:c(this.geometryType,a,f,e,x,T)});t&&a&&!r.geometry&&(r.centroid=m(this,this.featureAdapter.getCentroid(s,this),e)),F[I++]=r}else if(!u&&d)for(const s of _)F[I++]=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),centroid:m(this,this.featureAdapter.getCentroid(s,this),e)});else for(const s of _)F[I++]=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),centroid:m(this,this.featureAdapter.getCentroid(s,this),e),geometry:c(this.geometryType,this.featureAdapter.getGeometry(s),f,e,x,T)})}else for(const r of _){const e=i.getAttributes(r);e&&(F[I++]=this._addFeatureJSONMetadata(r,{attributes:e}))}const S=p||0;if(null!=h){const e=S+h;F=F.slice(S,Math.min(F.length,e))}return F}_addFeatureJSONMetadata(e,t){const i=this.featureAdapter.getMetadata?.(e);return void 0!==i&&(t.metadata=i),t}_createExceedsLimitQueryResponse(){let e=!1,t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY;for(const a of this.query.outStatistics??[])if("exceedslimit"===a.statisticType){t=null!=a.maxPointCount?a.maxPointCount:Number.POSITIVE_INFINITY,i=null!=a.maxRecordCount?a.maxRecordCount:Number.POSITIVE_INFINITY,s=null!=a.maxVertexCount?a.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)e=this.items.length>t;else if(this.items.length>i)e=!0;else{const t=Q(this.hasZ,this.hasM),i=this.featureAdapter;e=this.items.reduce((e,t)=>{const s=i.getGeometry(t);return e+(null!=s&&s.coords.length||0)},0)/t>s}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(e)}}]}}async _createStatisticsQueryResponse(e,t,i={attributes:{}}){const s=[],a=new Map,r=new Map,n=new Map,o=new Map,u=new l(e,this.featureAdapter,this.fieldsIndex),c=e.outStatistics,{groupByFieldsForStatistics:m,having:d,orderByFields:f,resultRecordCount:p}=e,h=m?.length,y=!!h,g=y?m[0]:null,x=y&&!this.fieldsIndex.get(g);for(const l of c??[]){const{outStatisticFieldName:e,statisticType:c}=l,f=l,p="exceedslimit"!==c?l.onStatisticField:void 0,F="percentile_disc"===c||"percentile_cont"===c,I="EnvelopeAggregate"===c||"CentroidAggregate"===c||"ConvexHullAggregate"===c,_=y&&1===h&&(p===g||x)&&"count"===c;if(y){if(!n.has(p)){const e=[];for(const i of m){const s=this._getAttributeValues(u,i,t,a);e.push(s)}n.set(p,this._calculateUniqueValues(e,t,!I&&u.returnDistinctValues))}const i=n.get(p);if(!i)continue;const s=Object.keys(i);for(const r of s){const{count:s,data:n,items:l,itemPositions:c}=i[r],h=n.join(",");if(!d||u.validateItems(l,d)){const i=o.get(h)||{attributes:{}};if(I){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(f,l);i.aggregateGeometries[t]=e}else{let r=null;if(_)r=s;else{const e=this._getAttributeValues(u,p,t,a),i=c.map(t=>e[t]);r=F&&"statisticParameters"in f?this._getPercentileValue(f,i):this._getStatisticValue(f,i,null,u.returnDistinctValues)}i.attributes[e]=r}let r=0;m.forEach((e,t)=>i.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++r]=n[t]),o.set(h,i)}}}else if(I){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(f,t);i.aggregateGeometries[s]=e}else{const s=this._getAttributeValues(u,p,t,a);i.attributes[e]=F&&"statisticParameters"in f?this._getPercentileValue(f,s):this._getStatisticValue(f,s,r,u.returnDistinctValues)}const S="min"!==c&&"max"!==c||!T(this.fieldsIndex.get(p))&&!this._isAnyDateField(p)?null:this.fieldsIndex.get(p)?.type;s.push({name:e,alias:e,type:S||"esriFieldTypeDouble"})}const F=y?Array.from(o.values()):[i];return this._sortFeatures(F,f,(e,t)=>e.attributes[t]),p&&(F.length=Math.min(p,F.length)),{fields:s,features:F}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return y(t)||g(t)||x(t)||F(t)}async _getAggregateGeometry(e,r){const{convexHull:n,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:m,spatialReference:d,geometryType:f}=this,p=r.map(e=>c(f,m.getGeometry(e))),h=n(d,p,!0)[0],y={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=h?s(h):a(o(d,p));y.aggregateGeometries={...e,spatialReference:d},y.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=h?t(h):i(a(o(d,p)));y.aggregateGeometries={x:e[0],y:e[1],spatialReference:d},y.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(y.aggregateGeometries=h,y.outStatisticFieldName=u||"convexHull");return y}_getStatisticValue(e,t,i,s){const{onStatisticField:a,statisticType:r}=e;let n=null;n=i?.has(a)?i.get(a):T(this.fieldsIndex.get(a))||this._isAnyDateField(a)?v({values:t,returnDistinct:s}):R({values:s?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),i&&i.set(a,n);return n["var"===r?"variance":r]}_getPercentileValue(e,t){const{onStatisticField:i,statisticParameters:s,statisticType:a}=e,{value:r,orderBy:n}=s,o=this.fieldsIndex.get(i);return P(t,{value:r,orderBy:n,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,i,s){if(s.has(t))return s.get(t);const a=this.fieldsIndex.get(t),r=i.map(i=>e.getFieldValue(i,t,a));return s.set(t,r),r}_calculateUniqueValues(e,t,i){const s={},a=t.length;for(let r=0;r<a;r++){const a=t[r],n=[];for(const t of e)n.push(t[r]);const o=n.join(",");null==s[o]?s[o]={count:1,data:n,items:[a],itemPositions:[r]}:(i||s[o].count++,s[o].items.push(a),s[o].itemPositions.push(r))}return s}async _getDataValues(t,i,s=!0){const a=new l(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:r,scale:n,timeZone:o}=t;return r?a.getExpressionValues(i,r,{viewingMode:"map",scale:n,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},o):a.getDataValues(i,e(t),s)}_calculateHistogramBins(e,t,i){if(null==t.min&&null==t.max)return[];const s=t.intervals,a=t.min??0,r=t.max??0,n=s.map(([e,t])=>({minValue:e,maxValue:t,count:0,items:[]}));for(let o=0;o<e.length;o++){const t=e[o],l=i[o];if(null!=t&&t>=a&&t<=r){const e=q(s,t);e>-1&&(n[e].count++,n[e].items.push(l))}}return n}async createQueryBinsResponse(e){const t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);const{value:i,outAlias:s,valueType:a}=t,r=[],n=[{name:s??i,alias:s??i,type:a??"esriFieldTypeString"},{name:O,alias:O,type:"esriFieldTypeInteger"}],o=new l(e,this.featureAdapter,this.fieldsIndex),u=new Map,c=[...this.items];this._sortFeatures(c,[i],(e,t,i)=>o.getFieldValue(e,t,i));const m=this._getAttributeValues(o,i,c,u),d=this._calculateUniqueValues([m],c,o.returnDistinctValues);for(const l in d){const{items:t}=d[l],a=await this._createBinsResponse(e,t);if(r.push(...a.features.map(e=>({...e,attributes:{...e.attributes,[s??i]:l}}))),a.fields)for(const e of a.fields)n.some(t=>t.name===e.name)||n.push(e)}return{fields:n,features:r}}async _createBinsResponse(e,t){const i=e.bin;switch(t=t??this.items,i.type){case"autoIntervalBin":return this._createAutoIntervalBinsResponse(I.fromJSON(i),e,t);case"dateBin":return this._createDateBinsResponse(_.fromJSON(i),e,t);case"fixedBoundariesBin":return this._createFixedBoundariesBinsResponse(V.fromJSON(i),e,t);case"fixedIntervalBin":return this._createFixedIntervalBinsResponse(b.fromJSON(i),e,t)}}async _createAutoIntervalBinsResponse(e,t,i){const{field:s,normalizationField:a,numBins:r,normalizationType:n,normalizationTotal:o,start:l,end:u}=e,c=await this._getDataValues({field:e.field,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},i),m=j(c,{field:s,normalizationField:a,normalizationType:n,normalizationTotal:o,numBins:r,minValue:f(l,!1),maxValue:f(u,!1)}),d=this._calculateHistogramBins(c,m,i);return this._createFeaturesFromHistogramBins(d,t)}async _createDateBinsResponse(e,t,i){const{field:s,interval:a,start:r,end:n,snapToData:o,returnFullIntervalBin:l}=e,u=a.unit,c=await this._getDataValues({field:e.field,timeZone:t.outTimeReference?.ianaTimeZone},i),m=F(this.fieldsIndex.get(s)),d=S.toJSON(u),p=c.filter(Boolean).sort((e,t)=>e-t),h=null!=r?f(r,m):p[0],y=null!=n?f(n,m):p[p.length-1],g=[];if(null!=h&&null!=y){const e={zone:t.outTimeReference?.ianaTimeZone??G},i=C.fromMillis(h,e),s=C.fromMillis(y,e);if("last"===o){let e=s;for(;e>i;){const t=e.minus({[d]:a.value});if(t<i){g.unshift([l?t.toMillis():i.toMillis(),e.toMillis()]);break}g.unshift([t.toMillis(),e.toMillis()]),e=t}}else{let e="first"===o?i:i.startOf(d);for(;e<=s;){const t=e.plus({[d]:a.value});if(t>s){g.push([e.toMillis(),l?t.toMillis():s.toMillis()]);break}g.push([e.toMillis(),t.toMillis()]),e=t}}}const x=this._calculateHistogramBins(c,{intervals:g,min:h,max:y},i);return this._createFeaturesFromHistogramBins(x,t)}async _createFixedBoundariesBinsResponse(e,t,i){const{field:s}=e,a=await this._getDataValues({field:s,timeZone:t.outTimeReference?.ianaTimeZone},i),r=F(this.fieldsIndex.get(s)),n=e.boundaries.map(e=>f(e,r)).sort((e,t)=>e-t),o=[];for(let c=0;c<n.length-1;c++)o.push([n[c],n[c+1]]);const l={intervals:o,min:n.at(0),max:n.at(-1)},u=this._calculateHistogramBins(a,l,i);return this._createFeaturesFromHistogramBins(u,t)}async _createFixedIntervalBinsResponse(e,t,i){const{field:s,interval:a,start:r,end:n}=e,o=await this._getDataValues({field:e.field,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},i),l=F(this.fieldsIndex.get(s)),u=j(o,{field:s,classificationMethod:"defined-interval",definedInterval:a,minValue:f(r,l),maxValue:f(n,l)},!0),c=this._calculateHistogramBins(o,u,i);return this._createFeaturesFromHistogramBins(c,t)}async _createFeaturesFromHistogramBins(e,t){const{upperBoundaryAlias:i,lowerBoundaryAlias:s}=t,a=s||"lowerBoundary",r=i||"upperBoundary",n=[],o=[{name:a,alias:a,type:"esriFieldTypeDouble"},{name:r,alias:r,type:"esriFieldTypeDouble"}],l=t.bin?.stackBy?.value,u=t.bin?.stackBy?.outAlias;l&&o.push({name:O,alias:O,type:"esriFieldTypeInteger"},{name:u??l,alias:u??l,type:"esriFieldTypeString"});let c=0;const m="dateBin"===t.bin.type,d=t.outTimeReference?.ianaTimeZone;for(const f of e){const{minValue:e,maxValue:i,items:s}=f,p={attributes:{}};let h;if(p.attributes[a]=m&&d&&null!=e?C.fromMillis(e,{zone:d}).toISO():e,p.attributes[r]=m&&d&&null!=i?C.fromMillis(i,{zone:d}).toISO():i,l?(h=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[l],orderByFields:[l]},s),p.attributes[O]=++c,"flat"===t.bin.jsonStyle?n.push(...h.features.map(({attributes:{EXPR_1:e,...t},...i})=>({...i,attributes:u??e?{...t,[u??e]:e,...p.attributes}:{...t,...p.attributes}}))):(p.stackedAttributes=h.features.map(({attributes:{EXPR_1:e,...t}})=>u??e?{...t,[u??e]:e}:t),n.push(p))):(t.bin?.splitBy&&(p.attributes[O]=++c),h=await this._createStatisticsQueryResponse(t,s,p),n.push(p)),h.fields)for(const t of h.fields)o.some(e=>e.name===t.name)||o.push(t)}return"desc"===t.binOrder&&n.reverse(),{fields:o,features:n}}}function H(e,t,i,s){const a=s.x-i.x,r=s.y-i.y,n=t.x-i.x,o=t.y-i.y,l=a*a+r*r;if(0===l)return!1;const u=n*a+o*r,c=Math.min(1,Math.max(0,u/l));return e.x=i.x+a*c,e.y=i.y+r*c,!0}function Q(e,t){return e?t?4:3:t?3:2}class U{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}const J=[1];export{E as QueryEngineResult};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{generalizeOptimizedGeometry as n,quantizeOptimizedGeometry as e,convertToMultipoint as r,convertToPolygon as t,convertToPolyline as o,convertToPoint as i,removeZMValues as s}from"../featureConversionUtils.js";import l from"../OptimizedGeometry.js";const u=new l,f=new l,m=new l,c={esriGeometryPoint:i,esriGeometryPolyline:o,esriGeometryPolygon:t,esriGeometryMultipoint:r};function y(n,r,t,o=n.hasZ,s=n.hasM){if(null==r)return null;const l=n.hasZ&&o,u=n.hasM&&s;if(t){const f=e(m,r,n.hasZ,n.hasM,"esriGeometryPoint",t,o,s);return i(f,l,u)}return i(r,l,u)}function a(r,t,o,i,l,y,a=t,h=o){const p=t&&a,G=o&&h,g=null!=i?"coords"in i?i:i.geometry:null;if(null==g)return null;if(l){let i=n(f,g,t,o,r,l,a,h);return y&&(i=e(m,i,p,G,r,y)),c[r]?.(i,p,G)??null}if(y){const n=e(m,g,t,o,r,y,a,h);return c[r]?.(n,p,G)??null}return s(u,g,t,o,a,h),c[r]?.(u,p,G)??null}function h(n){return n&&p in n?JSON.parse(JSON.stringify(n,G)):n}const p="_geVersion",G=(n,e)=>n===p?void 0:e;export{h as cleanFromGeometryEngine,a as getGeometry,y as transformCentroid};
5
+ import{generalizeOptimizedGeometry as n,quantizeOptimizedGeometry as r,convertToGeometry as t,convertToPoint as e}from"../featureConversionUtils.js";function o(n,t,o,i=n.hasZ,s=n.hasM){if(null==t)return null;const u=n.hasZ&&i,l=n.hasM&&s;if(o){const n=r(t,"esriGeometryPoint",o,i,s);return e(n,u,l)}return e(t,u,l)}function i(e,o,i,s,u,l){if(null==o)return null;const f="coords"in o?o:o.geometry;if(null==f)return null;const{hasZ:c,hasM:a}=f,h=c&&(u??=c),m=a&&(l??=a);if(i){let o=n(f,e,i,u,l);return s&&(o=r(o,e,s)),t(o,e,h,m)}if(s){const n=r(f,e,s,u,l);return t(n,e,h,m)}return t(f,e,h,m)}function s(n){return n&&u in n?JSON.parse(JSON.stringify(n,l)):n}const u="_geVersion",l=(n,r)=>n===u?void 0:r;export{s as cleanFromGeometryEngine,i as getGeometry,o as transformCentroid};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Error.js";import{extentContainsPoint as r,extentContainsMultipoint as t}from"../../../geometry/support/contains.js";import{getExtentIntersector as i}from"../../../geometry/support/intersects.js";import{isPolygon as o,isExtent as s,getJsonType as n}from"../../../geometry/support/jsonUtils.js";import{isValid as a}from"../../../geometry/support/spatialReferenceUtils.js";import{polygonContainsPoint as l,polygonContainsMultipoint as p}from"../contains.js";import{convertFromPolygon as m}from"../featureConversionUtils.js";import u from"../OptimizedGeometry.js";import{getGeometry as y}from"./geometryUtils.js";import{checkProjectionSupport as c}from"./projectionSupport.js";const f="unsupported-query",R={spatialRelationship:{esriSpatialRelIntersects:!0,esriSpatialRelContains:!0,esriSpatialRelWithin:!0,esriSpatialRelCrosses:!0,esriSpatialRelDisjoint:!0,esriSpatialRelTouches:!0,esriSpatialRelOverlaps:!0,esriSpatialRelEnvelopeIntersects:!0,esriSpatialRelIndexIntersects:!1,esriSpatialRelRelation:!1},queryGeometry:{esriGeometryPoint:!0,esriGeometryMultiPatch:!1,esriGeometryMultipoint:!0,esriGeometryPolyline:!0,esriGeometryPolygon:!0,esriGeometryEnvelope:!0},layerGeometry:{esriGeometryPoint:!0,esriGeometryMultiPatch:!0,esriGeometryMultipoint:!0,esriGeometryPolyline:!0,esriGeometryPolygon:!0,esriGeometryEnvelope:!1}};function S(e){return null!=e&&!0===R.spatialRelationship[e]}function j(e){return null!=e&&!0===R.queryGeometry[n(e)]}function G(e){return null!=e&&!0===R.layerGeometry[e]}const g={esriSpatialRelIntersects:()=>import("../../../geometry/operators/json/intersectsOperator.js"),esriSpatialRelContains:()=>import("../../../geometry/operators/json/containsOperator.js"),esriSpatialRelCrosses:()=>import("../../../geometry/operators/json/crossesOperator.js"),esriSpatialRelDisjoint:()=>import("../../../geometry/operators/json/disjointOperator.js"),esriSpatialRelEnvelopeIntersects:null,esriSpatialRelIndexIntersects:null,esriSpatialRelOverlaps:()=>import("../../../geometry/operators/json/overlapsOperator.js"),esriSpatialRelTouches:()=>import("../../../geometry/operators/json/touchesOperator.js"),esriSpatialRelWithin:()=>import("../../../geometry/operators/json/withinOperator.js"),esriSpatialRelRelation:null};function h(e){const r=g[e];if(null==r)throw new Error(`Cannot load unsupported spatial operator: ${e}`);return r()}async function I(e,n,a,c,f){if(o(n)){if("esriGeometryPoint"===a&&("esriSpatialRelIntersects"===e||"esriSpatialRelContains"===e)){const e=m(new u,n,!1,!1);return r=>l(e,!1,!1,r)}if("esriGeometryMultipoint"===a){const r=m(new u,n,!1,!1);if("esriSpatialRelContains"===e)return e=>p(r,!1,!1,e,c,f)}}if(s(n)){if("esriGeometryPoint"===a&&("esriSpatialRelIntersects"===e||"esriSpatialRelContains"===e))return e=>r(n,y(a,c,f,e));if("esriGeometryMultipoint"===a&&"esriSpatialRelContains"===e)return e=>t(n,y(a,c,f,e));if("esriSpatialRelIntersects"===e){const e=i(a);return r=>e(n,y(a,c,f,r))}}"esriSpatialRelEnvelopeIntersects"===e&&(e="esriSpatialRelIntersects");const R=await h(e);return e=>R.execute(n,y(a,c,f,e))}async function w(r,t,i){const{spatialRel:o,geometry:s}=r;if(s){if(!S(o))throw new e(f,"Unsupported query spatial relationship",{query:r});if(a(s.spatialReference)&&a(i)){if(!j(s))throw new e(f,"Unsupported query geometry type",{query:r});if(!G(t))throw new e(f,"Unsupported layer geometry type",{query:r});if(r.outSR)return c(r.geometry?.spatialReference,r.outSR)}}}function d(e){if(s(e))return!0;if(o(e)){for(const r of e.rings){if(5!==r.length)return!1;if(r[0][0]!==r[1][0]||r[0][0]!==r[4][0]||r[2][0]!==r[3][0]||r[0][1]!==r[3][1]||r[0][1]!==r[4][1]||r[1][1]!==r[2][1])return!1}return!0}return!1}export{d as canQueryWithRBush,w as checkSpatialQuerySupport,I as getSpatialQueryOperator};
5
+ import e from"../../../core/Error.js";import{extentContainsPoint as r,extentContainsMultipoint as t}from"../../../geometry/support/contains.js";import{getExtentIntersector as i}from"../../../geometry/support/intersects.js";import{isPolygon as o,isExtent as s,getJsonType as n}from"../../../geometry/support/jsonUtils.js";import{isValid as a}from"../../../geometry/support/spatialReferenceUtils.js";import{polygonContainsPoint as l,polygonContainsMultipoint as p}from"../contains.js";import{convertFromPolygon as u}from"../featureConversionUtils.js";import{getGeometry as m}from"./geometryUtils.js";import{checkProjectionSupport as y}from"./projectionSupport.js";const c="unsupported-query",f={spatialRelationship:{esriSpatialRelIntersects:!0,esriSpatialRelContains:!0,esriSpatialRelWithin:!0,esriSpatialRelCrosses:!0,esriSpatialRelDisjoint:!0,esriSpatialRelTouches:!0,esriSpatialRelOverlaps:!0,esriSpatialRelEnvelopeIntersects:!0,esriSpatialRelIndexIntersects:!1,esriSpatialRelRelation:!1},queryGeometry:{esriGeometryPoint:!0,esriGeometryMultiPatch:!1,esriGeometryMultipoint:!0,esriGeometryPolyline:!0,esriGeometryPolygon:!0,esriGeometryEnvelope:!0},layerGeometry:{esriGeometryPoint:!0,esriGeometryMultiPatch:!0,esriGeometryMultipoint:!0,esriGeometryPolyline:!0,esriGeometryPolygon:!0,esriGeometryEnvelope:!1}};function R(e){return null!=e&&!0===f.spatialRelationship[e]}function S(e){return null!=e&&!0===f.queryGeometry[n(e)]}function j(e){return null!=e&&!0===f.layerGeometry[e]}const g={esriSpatialRelIntersects:()=>import("../../../geometry/operators/json/intersectsOperator.js"),esriSpatialRelContains:()=>import("../../../geometry/operators/json/containsOperator.js"),esriSpatialRelCrosses:()=>import("../../../geometry/operators/json/crossesOperator.js"),esriSpatialRelDisjoint:()=>import("../../../geometry/operators/json/disjointOperator.js"),esriSpatialRelEnvelopeIntersects:null,esriSpatialRelIndexIntersects:null,esriSpatialRelOverlaps:()=>import("../../../geometry/operators/json/overlapsOperator.js"),esriSpatialRelTouches:()=>import("../../../geometry/operators/json/touchesOperator.js"),esriSpatialRelWithin:()=>import("../../../geometry/operators/json/withinOperator.js"),esriSpatialRelRelation:null};function G(e){const r=g[e];if(null==r)throw new Error(`Cannot load unsupported spatial operator: ${e}`);return r()}async function h(e,n,a){if(o(n)){if("esriGeometryPoint"===a&&("esriSpatialRelIntersects"===e||"esriSpatialRelContains"===e)){const e=u(n,!1,!1);return r=>l(e,r)}if("esriGeometryMultipoint"===a){const r=u(n,!1,!1);if("esriSpatialRelContains"===e)return e=>p(r,e)}}if(s(n)){if("esriGeometryPoint"===a&&("esriSpatialRelIntersects"===e||"esriSpatialRelContains"===e))return e=>r(n,m(a,e));if("esriGeometryMultipoint"===a&&"esriSpatialRelContains"===e)return e=>t(n,m(a,e));if("esriSpatialRelIntersects"===e){const e=i(a);return r=>e(n,m(a,r))}}"esriSpatialRelEnvelopeIntersects"===e&&(e="esriSpatialRelIntersects");const y=await G(e);return e=>y.execute(n,m(a,e))}async function I(r,t,i){const{spatialRel:o,geometry:s}=r;if(s){if(!R(o))throw new e(c,"Unsupported query spatial relationship",{query:r});if(a(s.spatialReference)&&a(i)){if(!S(s))throw new e(c,"Unsupported query geometry type",{query:r});if(!j(t))throw new e(c,"Unsupported layer geometry type",{query:r});if(r.outSR)return y(r.geometry?.spatialReference,r.outSR)}}}function w(e){if(s(e))return!0;if(o(e)){for(const r of e.rings){if(5!==r.length)return!1;if(r[0][0]!==r[1][0]||r[0][0]!==r[4][0]||r[2][0]!==r[3][0]||r[0][1]!==r[3][1]||r[0][1]!==r[4][1]||r[1][1]!==r[2][1])return!1}return!0}return!1}export{w as canQueryWithRBush,I as checkSpatialQuerySupport,h as getSpatialQueryOperator};