@arcgis/core 4.32.0-next.20250107 → 4.32.0-next.20250109

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 (313) hide show
  1. package/WebLinkChart.js +1 -1
  2. package/arcade/Dictionary.js +1 -1
  3. package/arcade/Feature.js +1 -1
  4. package/arcade/Voxel.js +5 -0
  5. package/arcade/arcadeAsyncRuntime.js +1 -1
  6. package/arcade/arcadeCompiler.js +1 -1
  7. package/arcade/arcadeRuntime.js +1 -1
  8. package/arcade/containerUtils.js +1 -1
  9. package/arcade/deepClone.js +1 -1
  10. package/arcade/featureSetUtils.js +1 -1
  11. package/arcade/featureset/actions/GroupBy.js +1 -1
  12. package/arcade/featureset/actions/OrderBy.js +1 -1
  13. package/arcade/functions/convertdirection.js +1 -1
  14. package/arcade/functions/date.js +1 -1
  15. package/arcade/functions/featuresetbase.js +1 -1
  16. package/arcade/functions/featuresetgeom.js +1 -1
  17. package/arcade/functions/featuresetstats.js +1 -1
  18. package/arcade/functions/featuresetstring.js +1 -1
  19. package/arcade/functions/fieldStats.js +1 -1
  20. package/arcade/functions/geomasync.js +1 -1
  21. package/arcade/functions/geometry.js +1 -1
  22. package/arcade/functions/geomsync.js +1 -1
  23. package/arcade/functions/knowledgegraph.js +1 -1
  24. package/arcade/functions/maths.js +1 -1
  25. package/arcade/functions/stats.js +1 -1
  26. package/arcade/functions/string.js +1 -1
  27. package/arcade/geometry/functions.js +1 -1
  28. package/arcade/languageUtils.js +1 -1
  29. package/arcade/treeAnalysis.js +1 -1
  30. package/arcade.js +1 -1
  31. package/assets/esri/core/workers/RemoteClient.js +1 -1
  32. package/assets/esri/core/workers/chunks/06680341bbc33c28fb95.js +1 -0
  33. package/assets/esri/core/workers/chunks/0899a96007c24ee72968.js +1 -0
  34. package/assets/esri/core/workers/chunks/0d32434841779581991f.js +1 -0
  35. package/assets/esri/core/workers/chunks/{07304287ed5244fa4e12.js → 12b2c8251ec2d0e2ca46.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{4423aac6e44c3dbf184e.js → 19a3a03153309ab81100.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{b0f4254d8a32dd713009.js → 1a8fcf820ca637e98eb7.js} +1 -1
  38. package/assets/esri/core/workers/chunks/1abeba63bf623a746d5c.js.LICENSE.txt +1 -1
  39. package/assets/esri/core/workers/chunks/{932375de79e3d33bc4d7.js → 1c3dbf5941d5a8515f4e.js} +1 -1
  40. package/assets/esri/core/workers/chunks/1e71c962e370de2f0039.js +1 -0
  41. package/assets/esri/core/workers/chunks/24a597ae32a2083a50a5.js +1 -0
  42. package/assets/esri/core/workers/chunks/{a7a39a826ce944c15b77.js → 31c0c5b9dcf0a962a3c3.js} +1 -1
  43. package/assets/esri/core/workers/chunks/3ad4953674d35041ca23.js +1 -0
  44. package/assets/esri/core/workers/chunks/{ca4a37bdc0f7fb705146.js → 3d3ba09a4057a00f369b.js} +1 -1
  45. package/assets/esri/core/workers/chunks/426611d7544db1151dff.js +1 -0
  46. package/assets/esri/core/workers/chunks/{c5a928dcff7dc8a8cc9f.js → 4c096f829f3804804cad.js} +2 -2
  47. package/assets/esri/core/workers/chunks/{c5a928dcff7dc8a8cc9f.js.LICENSE.txt → 4c096f829f3804804cad.js.LICENSE.txt} +1 -1
  48. package/assets/esri/core/workers/chunks/4ff41eebb7d5b70e1e93.js +1 -0
  49. package/assets/esri/core/workers/chunks/510cb8647841fec436c8.js +1 -0
  50. package/assets/esri/core/workers/chunks/{dd34df14eb4940e2497b.js → 5a904647767bbb665ed6.js} +1 -1
  51. package/assets/esri/core/workers/chunks/5dfc88ac446b836a652a.js +1 -0
  52. package/assets/esri/core/workers/chunks/62f8949a2d9076f3c1ea.js.LICENSE.txt +1 -1
  53. package/assets/esri/core/workers/chunks/{66d40a486aa3caa76106.js → 6869ac20afbaa5e5a2c2.js} +1 -1
  54. package/assets/esri/core/workers/chunks/6efb36bc2205203ff44d.js.LICENSE.txt +1 -1
  55. package/assets/esri/core/workers/chunks/{0ee669947c23f469e357.js → 7388b57de8926acd1fc2.js} +1 -1
  56. package/assets/esri/core/workers/chunks/73bf65507e9b748c8762.js +1 -0
  57. package/assets/esri/core/workers/chunks/76a7114a69264f5c07b0.js +2 -0
  58. package/assets/esri/core/workers/chunks/{c05e0bd145a1c27d6857.js.LICENSE.txt → 76a7114a69264f5c07b0.js.LICENSE.txt} +1 -1
  59. package/assets/esri/core/workers/chunks/{dca0eb66116e4b5403fc.js → 76c7984cd48cb81bfd41.js} +1 -1
  60. package/assets/esri/core/workers/chunks/7a10b6907f432f3b8f4f.js +1 -0
  61. package/assets/esri/core/workers/chunks/{ca1e186f136abb23ae4b.js → 7d0fc25ce1f74adcfeb6.js} +1 -1
  62. package/assets/esri/core/workers/chunks/{955421ee2247965244f0.js → 7fe92f072d3641ec4662.js} +1 -1
  63. package/assets/esri/core/workers/chunks/80bbdcddeebf4e7175f4.js +1 -0
  64. package/assets/esri/core/workers/chunks/{31d9f0a37a5d0a1c450b.js → 8329c85037e8786f46b1.js} +1 -1
  65. package/assets/esri/core/workers/chunks/9a501194edef2fe00913.js +1 -0
  66. package/assets/esri/core/workers/chunks/9f067dc75c04beaca9ad.js +313 -0
  67. package/assets/esri/core/workers/chunks/{b8ea84adff5619040494.js → 9f348706b14d5748f4ba.js} +1 -1
  68. package/assets/esri/core/workers/chunks/{6b3ee691646fbc39445c.js → a07dde7747f04aee97c2.js} +1 -1
  69. package/assets/esri/core/workers/chunks/a4a8247dc0cbfe027a95.js +1 -0
  70. package/assets/esri/core/workers/chunks/a5b8c85e08ebfd67ff36.js +1 -0
  71. package/assets/esri/core/workers/chunks/a8ec4189ec3b37d5ff74.js +1 -0
  72. package/assets/esri/core/workers/chunks/{8249351daa45ca82ca0c.js → ad8748f7b6cd3ff954f6.js} +1 -1
  73. package/assets/esri/core/workers/chunks/b1e3448ba51557ff6c13.js +1 -0
  74. package/assets/esri/core/workers/chunks/b3995025ae143f4d46b8.js +1 -0
  75. package/assets/esri/core/workers/chunks/{2427a01678f3d9fbf30b.js → bdf95bf0c29ef182000d.js} +1 -1
  76. package/assets/esri/core/workers/chunks/bf773c0bbbb504c063e2.js +1 -0
  77. package/assets/esri/core/workers/chunks/c7faa48b222ddd7d8513.js +1 -0
  78. package/assets/esri/core/workers/chunks/cac79b64a7dade8bf486.js.LICENSE.txt +1 -1
  79. package/assets/esri/core/workers/chunks/{d1dbbab4a4c6072c182f.js → cc7c7c0865013f7fbcfb.js} +1 -1
  80. package/assets/esri/core/workers/chunks/cdfc73029154a729959e.js +1 -0
  81. package/assets/esri/core/workers/chunks/{f6d6bc43ac1c13892d44.js → d7a467ccb2bed1ee21f6.js} +1 -1
  82. package/assets/esri/core/workers/chunks/{75e8ba7e02647b7216ae.js → d7eb0f2e3bd559e0f400.js} +1 -1
  83. package/assets/esri/core/workers/chunks/e2d987c39a6ef318511c.js.LICENSE.txt +1 -1
  84. package/assets/esri/core/workers/chunks/ed8aecf2a06368042b63.js +1 -0
  85. package/assets/esri/core/workers/chunks/f1b63f092e239f84b849.js +1 -0
  86. package/assets/esri/core/workers/chunks/f27390777e971abd61f5.js +1 -0
  87. package/assets/esri/themes/base/_Ui.scss +1 -0
  88. package/assets/esri/themes/base/widgets/_Feature.scss +12 -0
  89. package/assets/esri/themes/base/widgets/_FeatureForm.scss +27 -0
  90. package/assets/esri/themes/base/widgets/_Features.scss +4 -0
  91. package/assets/esri/themes/base/widgets/_Slider.scss +2 -31
  92. package/assets/esri/themes/dark/main.css +1 -1
  93. package/assets/esri/themes/light/main.css +1 -1
  94. package/assets/esri/themes/light/view.css +1 -1
  95. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm.json +1 -1
  96. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ar.json +1 -1
  97. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_bg.json +1 -1
  98. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_bs.json +1 -1
  99. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ca.json +1 -1
  100. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_cs.json +1 -1
  101. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_da.json +1 -1
  102. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_de.json +1 -1
  103. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_el.json +1 -1
  104. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_es.json +1 -1
  105. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_et.json +1 -1
  106. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_fi.json +1 -1
  107. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_fr.json +1 -1
  108. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_he.json +1 -1
  109. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_hr.json +1 -1
  110. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_hu.json +1 -1
  111. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_id.json +1 -1
  112. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_it.json +1 -1
  113. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ja.json +1 -1
  114. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ko.json +1 -1
  115. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_lt.json +1 -1
  116. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_lv.json +1 -1
  117. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_nl.json +1 -1
  118. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_no.json +1 -1
  119. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_pl.json +1 -1
  120. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_pt-BR.json +1 -1
  121. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_pt-PT.json +1 -1
  122. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ro.json +1 -1
  123. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ru.json +1 -1
  124. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sk.json +1 -1
  125. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sl.json +1 -1
  126. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sr.json +1 -1
  127. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sv.json +1 -1
  128. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_th.json +1 -1
  129. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_tr.json +1 -1
  130. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_uk.json +1 -1
  131. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_vi.json +1 -1
  132. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_zh-CN.json +1 -1
  133. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_zh-HK.json +1 -1
  134. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_zh-TW.json +1 -1
  135. package/chunks/CrackAndCluster-CfzXpEle.js +1 -1
  136. package/chunks/LineSeries.js +1 -1
  137. package/chunks/OperatorProject.js +1 -1
  138. package/chunks/Pattern.glsl.js +1 -1
  139. package/chunks/QuadraticBezier.js +1 -1
  140. package/chunks/Transformation2D.js +1 -1
  141. package/chunks/array.js +1 -1
  142. package/chunks/chartUtilsAm5.js +1 -1
  143. package/chunks/languageUtils.js +1 -1
  144. package/chunks/lyr3DWorker.js +1 -1
  145. package/chunks/vxlLayer.js +1 -1
  146. package/core/sql.js +1 -1
  147. package/geometry/support/meshUtils/primitives.js +1 -1
  148. package/geometry/support/triangle.js +1 -1
  149. package/interfaces.d.ts +242 -154
  150. package/layers/FeatureLayer.js +1 -1
  151. package/layers/LinkChartLayer.js +1 -1
  152. package/layers/MapNotesLayer.js +1 -1
  153. package/layers/MediaLayer.js +1 -1
  154. package/layers/mixins/DisplayFilteredLayer.js +5 -0
  155. package/layers/support/DisplayFilter.js +5 -0
  156. package/layers/support/DisplayFilterFilter.js +5 -0
  157. package/layers/support/ImageElement.js +1 -1
  158. package/layers/support/VideoElement.js +1 -1
  159. package/layers/support/displayFilterUtils.js +5 -0
  160. package/layers/support/fieldUtils.js +1 -1
  161. package/layers/support/rasterFunctionUtils.js +1 -1
  162. package/layers/support/rasterFunctions/creators/createConversionFunctions.js +1 -1
  163. package/layers/support/rasterFunctions/creators/createLocalFunctions.js +1 -1
  164. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  165. package/layers/video/VideoController.js +1 -1
  166. package/linkChart/OrganicLayoutSettings.js +1 -1
  167. package/package.json +4 -4
  168. package/smartMapping/renderers/color.js +1 -1
  169. package/smartMapping/renderers/size.js +1 -1
  170. package/smartMapping/renderers/univariateColorSize.js +1 -1
  171. package/support/arcadeOnDemand.js +1 -1
  172. package/support/arcadeUtils.js +1 -1
  173. package/support/mediaLayerUtils.js +5 -0
  174. package/support/revision.js +1 -1
  175. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  176. package/symbols/cim/placements/PlacementInsidePolygon.js +1 -1
  177. package/views/2d/AnimationManager.js +1 -1
  178. package/views/2d/engine/vectorTiles/buckets/FillBucket.js +1 -1
  179. package/views/2d/engine/webgl/Overlay.js +1 -1
  180. package/views/2d/engine/webgl/SDFConverter.js +1 -1
  181. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  182. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/hittestUtils.js +1 -1
  183. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  184. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  185. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  186. package/views/2d/layers/features/schema/SourceSchema.js +1 -1
  187. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  188. package/views/2d/layers/features/support/GraphicsReader.js +1 -1
  189. package/views/2d/navigation/MapViewNavigation.js +1 -1
  190. package/views/2d/support/HighlightGroup.js +1 -1
  191. package/views/3d/analysis/Slice/ShiftManipulator.js +1 -1
  192. package/views/3d/analysis/Viewshed/FieldOfViewManipulation.js +1 -1
  193. package/views/3d/analysis/support/measurementUtils.js +1 -1
  194. package/views/3d/environment/CloudsParameters.js +1 -1
  195. package/views/3d/environment/MarsAtmosphere.js +1 -1
  196. package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
  197. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  198. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  199. package/views/3d/layers/MediaLayerView3D.js +1 -1
  200. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
  201. package/views/3d/layers/graphics/pipeline/PipelineCommand.js +5 -0
  202. package/views/3d/layers/graphics/pipeline/featureData/FeatureDataStore.js +5 -0
  203. package/views/3d/layers/graphics/pipeline/featureData/processingUtils.js +1 -1
  204. package/views/3d/layers/graphics/pipeline/featureSet/PBFPointFeatureSetView.js +1 -1
  205. package/views/3d/layers/graphics/pipeline/rendering/RenderCommandEncoder.js +1 -1
  206. package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
  207. package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
  208. package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
  209. package/views/3d/layers/graphics/placementUtils.js +1 -1
  210. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  211. package/views/3d/layers/support/FeatureTileDescriptor.js +1 -1
  212. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  213. package/views/3d/layers/support/FeatureTileTree3D.js +1 -1
  214. package/views/3d/layers/support/FeatureTileTree3DDebugger.js +1 -1
  215. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  216. package/views/3d/layers/support/I3STreeDebugger.js +1 -1
  217. package/views/3d/layers/support/TerrainTileTree3DDebugger.js +1 -1
  218. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  219. package/views/3d/support/HighlightGroup.js +1 -1
  220. package/views/3d/terrain/OverlayManager.js +1 -1
  221. package/views/3d/terrain/OverlayRenderer.js +1 -1
  222. package/views/3d/terrain/SphericalPatch.js +1 -1
  223. package/views/3d/terrain/TerrainSurface.js +1 -1
  224. package/views/3d/terrain/TilePerLayerInfo.js +1 -1
  225. package/views/3d/terrain/TileRenderer.js +1 -1
  226. package/views/3d/terrain/TileTexture.js +1 -1
  227. package/views/3d/webgl-engine/collections/Component/ComponentIntersectionData.js +1 -1
  228. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  229. package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
  230. package/views/3d/webgl-engine/lib/PathProfile.js +1 -1
  231. package/views/3d/webgl-engine/lib/RenderSlot.js +1 -1
  232. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  233. package/views/3d/webgl-engine/lib/TextureCompressionWorkerHandle.js +1 -1
  234. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  235. package/views/SceneView.js +1 -1
  236. package/views/View.js +1 -1
  237. package/views/input/BrowserEventSource.js +1 -1
  238. package/views/interactive/snapping/featureSources/WorkerTileTreeDebugger.js +1 -1
  239. package/views/layers/FeatureLayerView.js +1 -1
  240. package/views/layers/MediaLayerView.js +1 -1
  241. package/views/support/HighlightGroup.d.ts +4 -0
  242. package/views/support/HighlightGroup.js +5 -0
  243. package/views/support/TileTreeDebugger.js +1 -1
  244. package/views/webgl/Texture.js +1 -1
  245. package/views/webgl/UniformBufferLayout.js +1 -1
  246. package/views/webgl/capabilities.js +1 -1
  247. package/views/webgl/textureUtils.js +1 -1
  248. package/webscene/Slide.js +1 -1
  249. package/widgets/BasemapLayerList.js +1 -1
  250. package/widgets/BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker.js +1 -1
  251. package/widgets/CatalogLayerList.js +1 -1
  252. package/widgets/Daylight/support/SliderWithDropdown.js +1 -1
  253. package/widgets/Editor/EditorViewModel.js +1 -1
  254. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  255. package/widgets/Editor/UpdateWorkflow.js +1 -1
  256. package/widgets/Editor.js +1 -1
  257. package/widgets/Feature/FeatureUtilityNetworkAssociationList.js +5 -0
  258. package/widgets/Feature/FeatureUtilityNetworkAssociations.js +1 -1
  259. package/widgets/Feature/FeatureViewModel.js +1 -1
  260. package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
  261. package/widgets/Feature.js +1 -1
  262. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +5 -0
  263. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  264. package/widgets/FeatureForm/UtilityNetworkAssociationInput.js +1 -1
  265. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  266. package/widgets/FeatureForm.js +1 -1
  267. package/widgets/FeatureTable/FieldColumn.js +1 -1
  268. package/widgets/FeatureTable/support/exportUtils.js +1 -1
  269. package/widgets/LayerList/support/layerListUtils.js +1 -1
  270. package/widgets/LayerList.js +1 -1
  271. package/widgets/Legend/styles/support/relationshipUtils.js +1 -1
  272. package/widgets/PanoramicViewer/utils.js +1 -1
  273. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
  274. package/widgets/ShadowCast.js +1 -1
  275. package/widgets/Sketch/SketchViewModel.js +1 -1
  276. package/widgets/TableList.js +1 -1
  277. package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.d.ts +2 -2
  278. package/widgets/support/TimezonePicker.js +1 -1
  279. package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js +5 -0
  280. package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.d.ts +4 -0
  281. package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +5 -0
  282. package/assets/esri/core/workers/chunks/000771f8eefcd6af0fda.js +0 -1
  283. package/assets/esri/core/workers/chunks/05943caacfd28c383810.js +0 -1
  284. package/assets/esri/core/workers/chunks/095aeb19e2207c8361ca.js +0 -1
  285. package/assets/esri/core/workers/chunks/0bff1b0b11fa2727a11c.js +0 -1
  286. package/assets/esri/core/workers/chunks/127c82cdb229434883b6.js +0 -1
  287. package/assets/esri/core/workers/chunks/304b88ade7551130ad3a.js +0 -1
  288. package/assets/esri/core/workers/chunks/30a84ddf0384bb52fdbe.js +0 -1
  289. package/assets/esri/core/workers/chunks/35d9457109d0631a1ca8.js +0 -1
  290. package/assets/esri/core/workers/chunks/368a36be515e60e35154.js +0 -313
  291. package/assets/esri/core/workers/chunks/4387c47ae1b36d770f1d.js +0 -1
  292. package/assets/esri/core/workers/chunks/4746b7afa90ea3641e60.js +0 -1
  293. package/assets/esri/core/workers/chunks/66b411119b8ffb99b9dc.js +0 -1
  294. package/assets/esri/core/workers/chunks/6c58f792e2ae3736f662.js +0 -1
  295. package/assets/esri/core/workers/chunks/7a43fda8984549a084b8.js +0 -1
  296. package/assets/esri/core/workers/chunks/7b753da3b8a6d75abf20.js +0 -1
  297. package/assets/esri/core/workers/chunks/7db356976198c4df76c1.js +0 -1
  298. package/assets/esri/core/workers/chunks/81816410cb1453938593.js +0 -1
  299. package/assets/esri/core/workers/chunks/8be0151a24c9af76a976.js +0 -1
  300. package/assets/esri/core/workers/chunks/8cd2c9ec1e541836b81c.js +0 -1
  301. package/assets/esri/core/workers/chunks/b07710e01494a6cda097.js +0 -1
  302. package/assets/esri/core/workers/chunks/b48bc5a86164ef4c2dae.js +0 -1
  303. package/assets/esri/core/workers/chunks/b7db64b07edb0b37ece1.js +0 -1
  304. package/assets/esri/core/workers/chunks/c05e0bd145a1c27d6857.js +0 -2
  305. package/assets/esri/core/workers/chunks/c49707b577f3805f0142.js +0 -1
  306. package/assets/esri/core/workers/chunks/d0876eed5249b029f9f0.js +0 -1
  307. package/assets/esri/core/workers/chunks/e27b8674a3492db51f2e.js +0 -1
  308. package/assets/esri/core/workers/chunks/e80b0646a7e0e466ea65.js +0 -1
  309. package/views/2d/support/HighlightGroup.d.ts +0 -4
  310. package/views/3d/layers/graphics/pipeline/symbolization/Symbolizer.js +0 -5
  311. package/widgets/Feature/FeatureUtilityNetworkAssociationType.js +0 -5
  312. package/widgets/Feature/FeatureUtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.d.ts +0 -4
  313. package/widgets/Feature/FeatureUtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +0 -5
package/WebLinkChart.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"./chunks/tslib.es6.js";import e from"./WebDocument2D.js";import r from"./core/Error.js";import{property as a}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import"./core/Logger.js";import"./core/RandomLCG.js";import{subclass as i}from"./core/accessorSupport/decorators/subclass.js";import n from"./linkChart/LayoutSettings.js";import o from"./linkChart/LinkChartProperties.js";import s from"./linkChart/NonspatialDataDisplay.js";import h from"./webmap/InitialViewProperties.js";import{currentVersion as c}from"./webmap/utils.js";import{Version as l}from"./webmap/Version.js";var p;const y={currentVersion:c,createInitialViewProperties:()=>new h,parseVersion:l.parse,itemType:"Web Link Chart",name:"linkchart",origin:"link-chart"};let u=p=class extends e{constructor(t){super(t),this.mapType="webLinkChart",this.linkChartProperties=new o}get activeLinkChartLayer(){return this.layers.find((({type:t})=>"link-chart"===t))}get context(){return y}async applyLayout(t="radial-root-centric",e){return this.linkChartProperties.layoutType=t,e?.layoutSettings?.chronologicalLayoutSettings&&e.layoutSettings.organicLayoutSettings||!this.linkChartProperties.layoutSettings?this.linkChartProperties.layoutSettings=e?.layoutSettings:this.linkChartProperties.layoutSettings=new n({organicLayoutSettings:e?.layoutSettings?.organicLayoutSettings??this.linkChartProperties.layoutSettings?.organicLayoutSettings,chronologicalLayoutSettings:e?.layoutSettings?.chronologicalLayoutSettings??this.linkChartProperties.layoutSettings?.chronologicalLayoutSettings}),this.activeLinkChartLayer?.applyNewLinkChartLayout(t,e)}changeNonspatialDataDisplay(t){this.activeLinkChartLayer&&(this.linkChartProperties.nonspatialDataDisplay||(this.linkChartProperties.nonspatialDataDisplay=new s),this.linkChartProperties.nonspatialDataDisplay.mode=t)}async addRecords(t,e){return this.activeLinkChartLayer?.addRecords(t,e)}async removeRecords(t){return this.activeLinkChartLayer?.removeRecords(t)??[]}async expand(t,e){const r=await(this.activeLinkChartLayer?.expand(t,e));return r?.records??[]}async refreshLinkChartData(t){return this.activeLinkChartLayer?.refreshLinkChartCache(t)}async connectBetweenEntities(t,e){const r=await(this.activeLinkChartLayer?.connectBetweenEntities(t,e));return r?.records??[]}async connectFromEntities(t,e){const r=await(this.activeLinkChartLayer?.connectFromEntities(t,e));return r?.records??[]}getMemberIdsByType(t){return this.activeLinkChartLayer?Array.from(this.activeLinkChartLayer.dataManager.sublayerCaches.get(t)?.keys()??[]):[]}get diagramNodesExtent(){return this.activeLinkChartLayer?.linkChartExtent}get entityCount(){return this.activeLinkChartLayer?.entityLinkChartDiagramLookup.size??0}get relationshipCount(){return this.activeLinkChartLayer?.relationshipLinkChartDiagramLookup.size??0}get knowledgeGraph(){return this.activeLinkChartLayer?.knowledgeGraph}add(t){if(this.activeLinkChartLayer&&"type"in t&&"link-chart"===t.type)throw new r("linkchart:one-link-chart-layer","Web Link Charts can only have one Link Chart Layer, another cannot be added");if(super.add(t),"type"in t&&"link-chart"===t.type){const e=t.defaultLinkChartConfig?.layoutMode;e&&(this.linkChartProperties.layoutType=e);const r=t.defaultLinkChartConfig?.layoutSettings;r&&(this.linkChartProperties.layoutSettings=r)}}static fromJSON(t){if(t)return new p({resourceInfo:t});throw new r("linkchart:empty-resource","Expected a JSON resource but got nothing")}};t([a({readOnly:!0})],u.prototype,"activeLinkChartLayer",null),t([a({json:{write:!0}})],u.prototype,"mapType",void 0),t([a({type:o,nonNullable:!0,json:{write:!0}})],u.prototype,"linkChartProperties",void 0),t([a({readOnly:!0})],u.prototype,"diagramNodesExtent",null),t([a({readOnly:!0})],u.prototype,"entityCount",null),t([a({readOnly:!0})],u.prototype,"relationshipCount",null),t([a({readOnly:!0})],u.prototype,"knowledgeGraph",null),u=p=t([i("esri.WebLinkChart")],u);const L=u;export{L as default};
5
+ import{_ as t}from"./chunks/tslib.es6.js";import e from"./WebDocument2D.js";import r from"./core/Error.js";import{property as a}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import"./core/Logger.js";import"./core/RandomLCG.js";import{subclass as i}from"./core/accessorSupport/decorators/subclass.js";import n from"./linkChart/LayoutSettings.js";import o from"./linkChart/LinkChartProperties.js";import s from"./linkChart/NonspatialDataDisplay.js";import h from"./webmap/InitialViewProperties.js";import{currentVersion as c}from"./webmap/utils.js";import{Version as l}from"./webmap/Version.js";var p;const y={currentVersion:c,createInitialViewProperties:()=>new h,parseVersion:l.parse,itemType:"Web Link Chart",name:"linkchart",origin:"link-chart"};let u=p=class extends e{constructor(t){super(t),this.mapType="webLinkChart",this.linkChartProperties=new o}get activeLinkChartLayer(){return this.layers.find((({type:t})=>"link-chart"===t))}get context(){return y}async applyLayout(t="radial-root-centric",e){return this.linkChartProperties.layoutType=t,e?.layoutSettings?.chronologicalLayoutSettings&&e.layoutSettings.organicLayoutSettings||!this.linkChartProperties.layoutSettings?this.linkChartProperties.layoutSettings=e?.layoutSettings:this.linkChartProperties.layoutSettings=new n({organicLayoutSettings:e?.layoutSettings?.organicLayoutSettings??this.linkChartProperties.layoutSettings?.organicLayoutSettings,chronologicalLayoutSettings:e?.layoutSettings?.chronologicalLayoutSettings??this.linkChartProperties.layoutSettings?.chronologicalLayoutSettings}),this.activeLinkChartLayer?.applyNewLinkChartLayout(t,e)}changeNonspatialDataDisplay(t){this.activeLinkChartLayer&&(this.linkChartProperties.nonspatialDataDisplay||(this.linkChartProperties.nonspatialDataDisplay=new s),this.linkChartProperties.nonspatialDataDisplay.mode=t)}async addRecords(t,e){return this.activeLinkChartLayer?.addRecords(t,e)}async removeRecords(t){return this.activeLinkChartLayer?.removeRecords(t)??[]}async expand(t,e){const r=await(this.activeLinkChartLayer?.expand(t,e));return r?.records??[]}async refreshLinkChartData(t){return this.activeLinkChartLayer?.refreshLinkChartCache(t)}async connectBetweenEntities(t,e){const r=await(this.activeLinkChartLayer?.connectBetweenEntities(t,e));return r?.records??[]}async connectFromEntities(t,e){const r=await(this.activeLinkChartLayer?.connectFromEntities(t,e));return r?.records??[]}getMemberIdsByType(t){return this.activeLinkChartLayer?Array.from(this.activeLinkChartLayer.dataManager.sublayerCaches.get(t)?.keys()??[]):[]}get diagramNodesExtent(){return this.activeLinkChartLayer?.linkChartExtent}get entityCount(){return this.activeLinkChartLayer?.entityLinkChartDiagramLookup.size??0}get relationshipCount(){return this.activeLinkChartLayer?.relationshipLinkChartDiagramLookup.size??0}get knowledgeGraph(){return this.activeLinkChartLayer?.knowledgeGraph}add(t){if(this.activeLinkChartLayer&&"type"in t&&"link-chart"===t.type)throw new r("linkchart:one-link-chart-layer","Web Link Charts can only have one Link Chart Layer, another cannot be added");if(super.add(t),"type"in t&&"link-chart"===t.type){const e=t.initializationLinkChartConfig?.layoutMode;e&&(this.linkChartProperties.layoutType=e);const r=t.initializationLinkChartConfig?.layoutSettings;r&&(this.linkChartProperties.layoutSettings=r)}}static fromJSON(t){if(t)return new p({resourceInfo:t});throw new r("linkchart:empty-resource","Expected a JSON resource but got nothing")}};t([a({readOnly:!0})],u.prototype,"activeLinkChartLayer",null),t([a({json:{write:!0}})],u.prototype,"mapType",void 0),t([a({type:o,nonNullable:!0,json:{write:!0}})],u.prototype,"linkChartProperties",void 0),t([a({readOnly:!0})],u.prototype,"diagramNodesExtent",null),t([a({readOnly:!0})],u.prototype,"entityCount",null),t([a({readOnly:!0})],u.prototype,"relationshipCount",null),t([a({readOnly:!0})],u.prototype,"knowledgeGraph",null),u=p=t([i("esri.WebLinkChart")],u);const L=u;export{L as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as t}from"./ArcadeDate.js";import{deepClone as s}from"./deepClone.js";import{ArcadeExecutionError as i,ExecutionErrorCodes as e}from"./executionError.js";import r from"./ImmutableArray.js";import{i as n,t as o,c as a,a as u,b as l,d as c,e as f,f as h,g as m,h as y,j as b,k as d,l as g}from"../chunks/languageUtils.js";import p from"../geometry/Geometry.js";import{isBoolean as w,isNumber as J,isString as A,isArray as T}from"../support/guards.js";function j(t,s,i=!1,e=!1){if(null==t)return null;if(J(t))return c(t);if(w(t))return f(t);if(A(t))return h(t);if(m(t))return y(t,s);if(b(t))return t;if(d(t))return t;if(T(t)){const r=[];for(const n of t)r.push(j(n,s,i,e));return r}if(e&&g(t))return t;const r=new v;r.immutable=!1;for(const n of Object.keys(t)){const o=t[n];void 0!==o&&r.setField(n,j(o,s,i,e))}return r.immutable=i,r}class v{constructor(t){this.declaredClass="esri.arcade.Dictionary",this.attributes=null,this.plain=!1,this.immutable=!0,this.attributes=t instanceof v?t.attributes:t??{}}field(t){const s=t.toLowerCase(),r=this.attributes[t];if(void 0!==r)return r;for(const i in this.attributes)if(i.toLowerCase()===s)return this.attributes[i];throw new i(null,e.FieldNotFound,null,{key:t})}setField(s,r){if(this.immutable)throw new i(null,e.Immutable,null);if(n(r))throw new i(null,e.NoFunctionInDictionary,null);const o=s.toLowerCase();r instanceof Date&&(r=t.dateJSToArcadeDate(r));if(void 0===this.attributes[s]){for(const t in this.attributes)if(t.toLowerCase()===o)return void(this.attributes[t]=r);this.attributes[s]=r}else this.attributes[s]=r}hasField(t){const s=t.toLowerCase();if(void 0!==this.attributes[t])return!0;for(const i in this.attributes)if(i.toLowerCase()===s)return!0;return!1}keys(){let t=[];for(const s in this.attributes)t.push(s);return t=t.sort(),t}castToText(s=!1){let i="";for(const e in this.attributes){""!==i&&(i+=",");const n=this.attributes[e];null==n?i+=JSON.stringify(e)+":null":w(n)||J(n)||A(n)?i+=JSON.stringify(e)+":"+JSON.stringify(n):n instanceof p?i+=JSON.stringify(e)+":"+o(n):n instanceof r||Array.isArray(n)?i+=JSON.stringify(e)+":"+o(n,null,s):n instanceof t?i+=s?JSON.stringify(e)+":"+JSON.stringify(n.getTime()):JSON.stringify(e)+":"+n.stringify():null!==n&&"object"==typeof n&&void 0!==n.castToText&&(i+=JSON.stringify(e)+":"+n.castToText(s))}return"{"+i+"}"}static convertObjectToArcadeDictionary(t,s,i=!0,e=!1){const r=new v;r.immutable=!1;for(const n in t){const o=t[n];void 0!==o&&r.setField(n.toString(),j(o,s,i,e))}return r.immutable=i,r}static convertJsonToArcade(t,s,i=!1,e=!1){return j(t,s,i,e)}castAsJson(t=null){const s={};for(let i in this.attributes){const e=this.attributes[i];void 0!==e&&(t?.keyTranslate&&(i=t.keyTranslate(i)),s[i]=a(e,t))}return s}async castDictionaryValueAsJsonAsync(t,s,i,e=null,r){const n=await u(i,e,r);return t[s]=n,n}async castAsJsonAsync(s=null,i=null){const e={},r=[];for(let n in this.attributes){const o=this.attributes[n];i?.keyTranslate&&(n=i.keyTranslate(n)),void 0!==o&&(l(o)||o instanceof p||o instanceof t?e[n]=a(o,i):r.push(this.castDictionaryValueAsJsonAsync(e,n,o,s,i)))}return r.length>0&&await Promise.all(r),e}deepClone(){const t=new v;t.immutable=!1;for(const i of this.keys())t.setField(i,s(this.field(i)));return t}}export{v as default};
5
+ import{ArcadeDate as t}from"./ArcadeDate.js";import{deepClone as s}from"./deepClone.js";import{ArcadeExecutionError as e,ExecutionErrorCodes as r}from"./executionError.js";import{i,c as n,a as o,b as a,d as u,t as l,e as c,f,g as h,h as m,j as b,k as d,l as y}from"../chunks/languageUtils.js";import w from"../geometry/Geometry.js";import{isNumber as p,isBoolean as A,isString as k,isArray as v}from"../support/guards.js";function j(t,s,e=!1,r=!1){if(null==t)return null;if(p(t))return l(t);if(A(t))return c(t);if(k(t))return f(t);if(h(t))return m(t,s);if(b(t))return t;if(d(t))return t;if(v(t)){const i=[];for(const n of t)i.push(j(n,s,e,r));return i}if(r&&y(t))return t;const i=new C;i.immutable=!1;for(const n of Object.keys(t)){const o=t[n];void 0!==o&&i.setField(n,j(o,s,e,r))}return i.immutable=e,i}class C{constructor(t){this.declaredClass="esri.arcade.Dictionary",this.plain=!1,this.immutable=!0,this.attributes=t instanceof C?t.attributes:t??{}}field(t){const s=t.toLowerCase(),i=this.attributes[t];if(void 0!==i)return i;for(const e in this.attributes)if(e.toLowerCase()===s)return this.attributes[e];throw new e(null,r.FieldNotFound,null,{key:t})}setField(s,n){if(this.immutable)throw new e(null,r.Immutable,null);if(i(n))throw new e(null,r.NoFunctionInDictionary,null);const o=s.toLowerCase();n instanceof Date&&(n=t.dateJSToArcadeDate(n));if(void 0===this.attributes[s]){for(const t in this.attributes)if(t.toLowerCase()===o)return void(this.attributes[t]=n);this.attributes[s]=n}else this.attributes[s]=n}hasField(t){const s=t.toLowerCase();if(void 0!==this.attributes[t])return!0;for(const e in this.attributes)if(e.toLowerCase()===s)return!0;return!1}keys(){let t=[];for(const s in this.attributes)t.push(s);return t=t.sort(),t}castToText(t=!1){return n(this.attributes,{useNumbersForDates:t})}static convertObjectToArcadeDictionary(t,s,e=!0,r=!1){const i=new C;i.immutable=!1;for(const n in t){const o=t[n];void 0!==o&&i.setField(n.toString(),j(o,s,e,r))}return i.immutable=e,i}static convertJsonToArcade(t,s,e=!1,r=!1){return j(t,s,e,r)}castAsJson(t=null){const s={};for(let e in this.attributes){const r=this.attributes[e];void 0!==r&&(t?.keyTranslate&&(e=t.keyTranslate(e)),s[e]=o(r,t))}return s}async castDictionaryValueAsJsonAsync(t,s,e,r=null,i){const n=await a(e,r,i);return t[s]=n,n}async castAsJsonAsync(s=null,e=null){const r={},i=[];for(let n in this.attributes){const a=this.attributes[n];e?.keyTranslate&&(n=e.keyTranslate(n)),void 0!==a&&(u(a)||a instanceof w||a instanceof t?r[n]=o(a,e):i.push(this.castDictionaryValueAsJsonAsync(r,n,a,s,e)))}return i.length>0&&await Promise.all(i),r}deepClone(){const t=new C;t.immutable=!1;for(const e of this.keys())t.setField(e,s(this.field(e)));return t}}export{C as default};
package/arcade/Feature.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as e}from"./ArcadeDate.js";import{configureDeepClone as t}from"./deepClone.js";import i from"./Dictionary.js";import{ArcadeExecutionError as s,ExecutionErrorCodes as r}from"./executionError.js";import n from"./ImmutableArray.js";import{p as o,t as a,k as l,j as u,g as f,b as d,c as y}from"../chunks/languageUtils.js";import{DateOnly as h}from"../core/sql/DateOnly.js";import{TimeOnly as m}from"../core/sql/TimeOnly.js";import c from"../geometry/Geometry.js";import p from"../geometry/Point.js";import{fromJSON as _}from"../geometry/support/jsonUtils.js";import{convertToGeometry as b}from"../layers/graphics/featureConversionUtils.js";import g from"../layers/support/FieldsIndex.js";import{isBoolean as T,isNumber as x,isString as F}from"../support/guards.js";class D{constructor(){this.arcadeDeclaredClass="esri.arcade.Feature",this._optimizedGeomDefinition=null,this._geometry=null,this.attributes=null,this._layer=null,this._fieldTypesFixed=!0,this.fieldsIndex=null,this.contextTimeZone=null,this.immutable=!0,this._fieldsToFixDataTypes=null,this.immutable=!0}static createFromGraphic(e,t){const i=new D;return i.contextTimeZone=t??null,i._geometry=null!=e.geometry?e.geometry:null,void 0===e.attributes||null===e.attributes?i.attributes={}:i.attributes=e.attributes,e._sourceLayer?(i._layer=e._sourceLayer,i._fieldTypesFixed=!1):e._layer?(i._layer=e._layer,i._fieldTypesFixed=!1):e.layer&&"fields"in e.layer?(i._layer=e.layer,i._fieldTypesFixed=!1):e.sourceLayer&&"fields"in e.sourceLayer&&(i._layer=e.sourceLayer,i._fieldTypesFixed=!1),i._layer&&!i._fieldTypesFixed&&(i.fieldsIndex=this.hydrateFieldsIndex(i._layer)),i}static createFromArcadeFeature(e){if(e instanceof D){const t=new D;return t._fieldTypesFixed=e._fieldTypesFixed,t.attributes=e.attributes,t._geometry=e._geometry,t._optimizedGeomDefinition=e._optimizedGeomDefinition,e._layer&&(t._layer=e._layer),t.fieldsIndex=e.fieldsIndex,t.contextTimeZone=e.contextTimeZone,t}const t={};for(const i of e.keys())t[i]=e.field(i);return D.createFromGraphicLikeObject(e.geometry(),t,e.fullSchema(),e.contextTimeZone)}static createFromOptimisedFeature(e,t,i){const s=new D;return s._geometry=e.geometry?{geometry:e.geometry}:null,s._optimizedGeomDefinition=i,s.attributes=e.attributes||{},s._layer=t,s._fieldTypesFixed=!1,s}static createFromArcadeDictionary(e,t){const s=new D;return s.attributes=e.field("attributes"),null!==s.attributes&&s.attributes instanceof i?(s.attributes=s.attributes.attributes,null===s.attributes&&(s.attributes={})):s.attributes={},s._geometry=e.field("geometry"),null!==s._geometry&&(s._geometry instanceof i?s._geometry=D.parseGeometryFromDictionary(s._geometry,t):s._geometry instanceof c||(s._geometry=null)),s}static createFromGraphicLikeObject(e,t,i=null,s){const r=new D;return r.contextTimeZone=s??null,null===t&&(t={}),r.attributes=t,r._geometry=null!=e?e:null,r._layer=i,r._layer&&(r._fieldTypesFixed=!1,r.fieldsIndex=this.hydrateFieldsIndex(r._layer)),r}static hydrateFieldsIndex(e){return null===e?null:o(e)?e.getFieldsIndex():e.fieldsIndex?e.fieldsIndex:g.fromLayerJSON({datesInUnknownTimezone:e.datesInUnknownTimezone,fields:e.fields,timeInfo:e.timeInfo,editFieldsInfo:e.editFieldsInfo,dateFieldsTimeReference:e.dateFieldsTimeReference??{timeZone:"UTC",respectsDaylightSaving:!1}})}repurposeFromGraphicLikeObject(e,t,i=null){null===t&&(t={}),this.attributes=t,this._geometry=e??null,this._layer=i,this._layer?this._fieldTypesFixed=!1:this._fieldTypesFixed=!0}castToText(t=!1){let i="";!1===this._fieldTypesFixed&&this._fixFieldTypes();for(const s in this.attributes){""!==i&&(i+=",");const r=this.attributes[s];null==r?i+=JSON.stringify(s)+":null":T(r)||x(r)||F(r)?i+=JSON.stringify(s)+":"+JSON.stringify(r):r instanceof c?i+=JSON.stringify(s)+":"+a(r):r instanceof m||r instanceof h?i+=`${JSON.stringify(s)}:${JSON.stringify(r.toString())}`:r instanceof n||Array.isArray(r)?i+=JSON.stringify(s)+":"+a(r,null,t):r instanceof e?i+=t?JSON.stringify(s)+":"+JSON.stringify(r.getTime()):JSON.stringify(s)+":"+r.stringify():null!==r&&"object"==typeof r&&void 0!==r.castToText&&(i+=JSON.stringify(s)+":"+r.castToText(t))}return'{"geometry":'+(null===this.geometry()?"null":a(this.geometry()))+',"attributes":{'+i+"}}"}_fixFieldTypes(){if(this._fieldsToFixDataTypes&&this._fieldsToFixDataTypes?.length>0)return this._fixAllFields(this._fieldsToFixDataTypes),void(this._fieldTypesFixed=!0);const e=[],t=this._layer.fields;for(let i=0;i<t.length;i++){const s=t[i],{name:r,type:n}=s;switch(n){case"date":case"esriFieldTypeDate":e.push({field:r,dataType:"date"});break;case"date-only":case"esriFieldTypeDateOnly":e.push({field:r,dataType:"date-only"});break;case"time-only":case"esriFieldTypeTimeOnly":e.push({field:r,dataType:"time-only"});break;case"timestamp-offset":case"esriFieldTypeTimestampOffset":e.push({field:r,dataType:"timestamp-offset"})}}this._fieldsToFixDataTypes=e,e.length>0&&this._fixAllFields(e),this._fieldTypesFixed=!0}isUnknownDateTimeField(e){return"unknown"===this.fieldsIndex?.getTimeZone(e)}_fixAllFields(t){this.attributes={...this.attributes};const i=this.contextTimeZone??"system";for(let s=0;s<t.length;s++){const r=t[s].field,n=t[s].dataType;let o=this.attributes[r];if(void 0===o){for(const t in this.attributes)if(t.toLowerCase()===r.toLowerCase()){if(o=this.attributes[t],null!==o){if("time-only"===n){l(o)||(this.attributes[t]=m.fromReader(o.toString()));break}if("date-only"===n){u(o)||(this.attributes[t]=h.fromReader(o.toString()));break}if("timestamp-offset"===n){f(o)||(this.attributes[t]=e.fromReaderAsTimeStampOffset(o.toString()));break}const s=this.isUnknownDateTimeField(t);o instanceof Date?this.attributes[t]=s?e.unknownDateJSToArcadeDate(o):e.dateJSAndZoneToArcadeDate(o,i):f(o)||(this.attributes[t]=s?e.unknownEpochToArcadeDate(o):e.epochToArcadeDate(o,i))}break}}else if(null!==o){if("time-only"===n){l(o)?this.attributes[r]=o:this.attributes[r]=m.fromReader(o.toString());continue}if("date-only"===n){u(o)?this.attributes[r]=o:this.attributes[r]=h.fromReader(o.toString());continue}if("timestamp-offset"===n){f(o)?this.attributes[r]=o:this.attributes[r]=e.fromReaderAsTimeStampOffset(o.toString());continue}const t=this.isUnknownDateTimeField(r);f(o)?this.attributes[r]=o:o instanceof Date?this.attributes[r]=t?e.unknownDateJSToArcadeDate(o):e.dateJSAndZoneToArcadeDate(o,i):this.attributes[r]=t?e.unknownEpochToArcadeDate(o):e.epochToArcadeDate(o,i)}}}geometry(){return null===this._geometry||this._geometry instanceof c||(this._optimizedGeomDefinition?(this._geometry=_(b(this._geometry,this._optimizedGeomDefinition.geometryType,this._optimizedGeomDefinition.hasZ,this._optimizedGeomDefinition.hasM)),this._geometry.spatialReference=this._optimizedGeomDefinition.spatialReference):this._geometry=_(this._geometry)),this._geometry}field(e){this._fieldTypesFixed||this._fixFieldTypes();const t=this.attributes[e];if(void 0!==t)return t;const i=e.toLowerCase();for(const s in this.attributes)if(s.toLowerCase()===i)return this.attributes[s];if(this._hasFieldDefinition(i))return null;throw new s(null,r.FieldNotFound,null,{key:e})}_hasFieldDefinition(e){if(null===this._layer)return!1;for(let t=0;t<this._layer.fields.length;t++){if(this._layer.fields[t].name.toLowerCase()===e)return!0}return!1}setField(t,i){if(this.immutable)throw new s(null,r.Immutable,null);if(i instanceof Date&&(i=this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(i):e.dateJSToArcadeDate(i)),!1===d(i))throw new s(null,r.TypeNotAllowedInFeature,null);const n=t.toLowerCase();if(void 0===this.attributes[t]){for(const e in this.attributes)if(e.toLowerCase()===n)return void(this.attributes[e]=i);this.attributes[t]=i}else this.attributes[t]=i}hasField(e){const t=e.toLowerCase();if(void 0!==this.attributes[e])return!0;for(const i in this.attributes)if(i.toLowerCase()===t)return!0;return!!this._hasFieldDefinition(t)}keys(){let e=[];const t={};for(const i in this.attributes)e.push(i),t[i.toLowerCase()]=1;if(null!==this._layer)for(let i=0;i<this._layer.fields.length;i++){const s=this._layer.fields[i];1!==t[s.name.toLowerCase()]&&e.push(s.name)}return e=e.sort(),e}static parseGeometryFromDictionary(e,t){const i=D._convertDictionaryToJson(e,!0);return void 0!==i.hasm&&(i.hasM=i.hasm,delete i.hasm),void 0!==i.hasz&&(i.hasZ=i.hasz,delete i.hasz),void 0!==i.spatialreference&&(i.spatialReference=i.spatialreference,delete i.spatialreference),i.spatialReference||(i.spatialReference=t),void 0!==i.rings&&(i.rings=this._fixPathArrays(i.rings,!0===i.hasZ,!0===i.hasZ)),void 0!==i.paths&&(i.paths=this._fixPathArrays(i.paths,!0===i.hasZ,!0===i.hasM)),void 0!==i.points&&(i.points=this._fixPointArrays(i.points,!0===i.hasZ,!0===i.hasM)),_(i)}static _fixPathArrays(e,t,i){const s=[];if(Array.isArray(e))for(let r=0;r<e.length;r++)s.push(this._fixPointArrays(e[r],t,i));else if(e instanceof n)for(let r=0;r<e.length();r++)s.push(this._fixPointArrays(e.get(r),t,i));return s}static _fixPointArrays(e,t,i){const s=[];if(Array.isArray(e))for(let r=0;r<e.length;r++){const o=e[r];o instanceof p?t&&i?s.push([o.x,o.y,o.z,o.m]):t?s.push([o.x,o.y,o.z]):i?s.push([o.x,o.y,o.m]):s.push([o.x,o.y]):o instanceof n?s.push(o.toArray()):s.push(o)}else if(e instanceof n)for(let r=0;r<e.length();r++){const o=e.get(r);o instanceof p?t&&i?s.push([o.x,o.y,o.z,o.m]):t?s.push([o.x,o.y,o.z]):i?s.push([o.x,o.y,o.m]):s.push([o.x,o.y]):o instanceof n?s.push(o.toArray()):s.push(o)}return s}static _convertDictionaryToJson(e,t=!1){const s={};for(const r in e.attributes){let n=e.attributes[r];n instanceof i&&(n=D._convertDictionaryToJson(n)),t?s[r.toLowerCase()]=n:s[r]=n}return s}static parseAttributesFromDictionary(e){const t={};for(const i in e.attributes){const n=e.attributes[i];if(!d(n))throw new s(null,r.InvalidParameter,null);t[i]=n}return t}static fromJson(e,t){let i=null;null!==e.geometry&&void 0!==e.geometry&&(i=_(e.geometry));const n={};if(null!==e.attributes&&void 0!==e.attributes)for(const o in e.attributes){const t=e.attributes[o];if(null===t)n[o]=t;else{if(!(F(t)||x(t)||T(t)||f(t)||l(t)||u(t)))throw new s(null,r.InvalidParameter,null);n[o]=t}}return D.createFromGraphicLikeObject(i,n,null,t??null)}fullSchema(){return this._layer}gdbVersion(){if(null===this._layer)return"";const e=this._layer.gdbVersion;return void 0===e?"":""===e&&this._layer.capabilities?.isVersioned?"SDE.DEFAULT":e}castAsJson(e){const t={attributes:{},geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null};for(const i in this.attributes){const s=this.attributes[i];void 0!==s&&(t.attributes[i]=y(s,e))}return t}async castAsJsonAsync(e=null,t){return this.castAsJson(t)}}t(D);export{D as default};
5
+ import{ArcadeDate as e}from"./ArcadeDate.js";import{configureDeepClone as t}from"./deepClone.js";import i from"./Dictionary.js";import{ArcadeExecutionError as s,ExecutionErrorCodes as r}from"./executionError.js";import o from"./ImmutableArray.js";import{p as a,c as n,s as l,k as u,j as d,g as f,d as h,a as m}from"../chunks/languageUtils.js";import{DateOnly as y}from"../core/sql/DateOnly.js";import{TimeOnly as c}from"../core/sql/TimeOnly.js";import p from"../geometry/Geometry.js";import _ from"../geometry/Point.js";import{fromJSON as b}from"../geometry/support/jsonUtils.js";import{convertToGeometry as T}from"../layers/graphics/featureConversionUtils.js";import g from"../layers/support/FieldsIndex.js";import{isString as F,isNumber as x,isBoolean as D}from"../support/guards.js";class w{constructor(){this.arcadeDeclaredClass="esri.arcade.Feature",this._optimizedGeomDefinition=null,this._geometry=null,this.attributes=null,this._layer=null,this._fieldTypesFixed=!0,this.fieldsIndex=null,this.contextTimeZone=null,this.immutable=!0,this._fieldsToFixDataTypes=null,this.immutable=!0}static createFromGraphic(e,t){const i=new w;return i.contextTimeZone=t??null,i._geometry=null!=e.geometry?e.geometry:null,void 0===e.attributes||null===e.attributes?i.attributes={}:i.attributes=e.attributes,e._sourceLayer?(i._layer=e._sourceLayer,i._fieldTypesFixed=!1):e._layer?(i._layer=e._layer,i._fieldTypesFixed=!1):e.layer&&"fields"in e.layer?(i._layer=e.layer,i._fieldTypesFixed=!1):e.sourceLayer&&"fields"in e.sourceLayer&&(i._layer=e.sourceLayer,i._fieldTypesFixed=!1),i._layer&&!i._fieldTypesFixed&&(i.fieldsIndex=this.hydrateFieldsIndex(i._layer)),i}static createFromArcadeFeature(e){if(e instanceof w){const t=new w;return t._fieldTypesFixed=e._fieldTypesFixed,t.attributes=e.attributes,t._geometry=e._geometry,t._optimizedGeomDefinition=e._optimizedGeomDefinition,e._layer&&(t._layer=e._layer),t.fieldsIndex=e.fieldsIndex,t.contextTimeZone=e.contextTimeZone,t}const t={};for(const i of e.keys())t[i]=e.field(i);return w.createFromGraphicLikeObject(e.geometry(),t,e.fullSchema(),e.contextTimeZone)}static createFromOptimisedFeature(e,t,i){const s=new w;return s._geometry=e.geometry?{geometry:e.geometry}:null,s._optimizedGeomDefinition=i,s.attributes=e.attributes||{},s._layer=t,s._fieldTypesFixed=!1,s}static createFromArcadeDictionary(e,t){const s=new w;return s.attributes=e.field("attributes"),null!==s.attributes&&s.attributes instanceof i?(s.attributes=s.attributes.attributes,null===s.attributes&&(s.attributes={})):s.attributes={},s._geometry=e.field("geometry"),null!==s._geometry&&(s._geometry instanceof i?s._geometry=w.parseGeometryFromDictionary(s._geometry,t):s._geometry instanceof p||(s._geometry=null)),s}static createFromGraphicLikeObject(e,t,i=null,s){const r=new w;return r.contextTimeZone=s??null,null===t&&(t={}),r.attributes=t,r._geometry=null!=e?e:null,r._layer=i,r._layer&&(r._fieldTypesFixed=!1,r.fieldsIndex=this.hydrateFieldsIndex(r._layer)),r}static hydrateFieldsIndex(e){return null===e?null:a(e)?e.getFieldsIndex():e.fieldsIndex?e.fieldsIndex:g.fromLayerJSON({datesInUnknownTimezone:e.datesInUnknownTimezone,fields:e.fields,timeInfo:e.timeInfo,editFieldsInfo:e.editFieldsInfo,dateFieldsTimeReference:e.dateFieldsTimeReference??{timeZone:"UTC",respectsDaylightSaving:!1}})}repurposeFromGraphicLikeObject(e,t,i=null){null===t&&(t={}),this.attributes=t,this._geometry=e??null,this._layer=i,this._layer?this._fieldTypesFixed=!1:this._fieldTypesFixed=!0}castToText(e=!1){!1===this._fieldTypesFixed&&this._fixFieldTypes();const t=n(this.attributes,{useNumbersForDates:e});return'{"geometry":'+(null===this.geometry()?"null":l(this.geometry()))+',"attributes":'+t+"}"}_fixFieldTypes(){if(this._fieldsToFixDataTypes&&this._fieldsToFixDataTypes?.length>0)return this._fixAllFields(this._fieldsToFixDataTypes),void(this._fieldTypesFixed=!0);const e=[],t=this._layer.fields;for(let i=0;i<t.length;i++){const s=t[i],{name:r,type:o}=s;switch(o){case"date":case"esriFieldTypeDate":e.push({field:r,dataType:"date"});break;case"date-only":case"esriFieldTypeDateOnly":e.push({field:r,dataType:"date-only"});break;case"time-only":case"esriFieldTypeTimeOnly":e.push({field:r,dataType:"time-only"});break;case"timestamp-offset":case"esriFieldTypeTimestampOffset":e.push({field:r,dataType:"timestamp-offset"})}}this._fieldsToFixDataTypes=e,e.length>0&&this._fixAllFields(e),this._fieldTypesFixed=!0}isUnknownDateTimeField(e){return"unknown"===this.fieldsIndex?.getTimeZone(e)}_fixAllFields(t){this.attributes={...this.attributes};const i=this.contextTimeZone??"system";for(let s=0;s<t.length;s++){const r=t[s].field,o=t[s].dataType;let a=this.attributes[r];if(void 0===a){for(const t in this.attributes)if(t.toLowerCase()===r.toLowerCase()){if(a=this.attributes[t],null!==a){if("time-only"===o){u(a)||(this.attributes[t]=c.fromReader(a.toString()));break}if("date-only"===o){d(a)||(this.attributes[t]=y.fromReader(a.toString()));break}if("timestamp-offset"===o){f(a)||(this.attributes[t]=e.fromReaderAsTimeStampOffset(a.toString()));break}const s=this.isUnknownDateTimeField(t);a instanceof Date?this.attributes[t]=s?e.unknownDateJSToArcadeDate(a):e.dateJSAndZoneToArcadeDate(a,i):f(a)||(this.attributes[t]=s?e.unknownEpochToArcadeDate(a):e.epochToArcadeDate(a,i))}break}}else if(null!==a){if("time-only"===o){u(a)?this.attributes[r]=a:this.attributes[r]=c.fromReader(a.toString());continue}if("date-only"===o){d(a)?this.attributes[r]=a:this.attributes[r]=y.fromReader(a.toString());continue}if("timestamp-offset"===o){f(a)?this.attributes[r]=a:this.attributes[r]=e.fromReaderAsTimeStampOffset(a.toString());continue}const t=this.isUnknownDateTimeField(r);f(a)?this.attributes[r]=a:a instanceof Date?this.attributes[r]=t?e.unknownDateJSToArcadeDate(a):e.dateJSAndZoneToArcadeDate(a,i):this.attributes[r]=t?e.unknownEpochToArcadeDate(a):e.epochToArcadeDate(a,i)}}}geometry(){return null===this._geometry||this._geometry instanceof p||(this._optimizedGeomDefinition?(this._geometry=b(T(this._geometry,this._optimizedGeomDefinition.geometryType,this._optimizedGeomDefinition.hasZ,this._optimizedGeomDefinition.hasM)),this._geometry.spatialReference=this._optimizedGeomDefinition.spatialReference):this._geometry=b(this._geometry)),this._geometry}field(e){this._fieldTypesFixed||this._fixFieldTypes();const t=this.attributes[e];if(void 0!==t)return t;const i=e.toLowerCase();for(const s in this.attributes)if(s.toLowerCase()===i)return this.attributes[s];if(this._hasFieldDefinition(i))return null;throw new s(null,r.FieldNotFound,null,{key:e})}_hasFieldDefinition(e){if(null===this._layer)return!1;for(let t=0;t<this._layer.fields.length;t++){if(this._layer.fields[t].name.toLowerCase()===e)return!0}return!1}setField(t,i){if(this.immutable)throw new s(null,r.Immutable,null);if(i instanceof Date&&(i=this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(i):e.dateJSToArcadeDate(i)),!1===h(i))throw new s(null,r.TypeNotAllowedInFeature,null);const o=t.toLowerCase();if(void 0===this.attributes[t]){for(const e in this.attributes)if(e.toLowerCase()===o)return void(this.attributes[e]=i);this.attributes[t]=i}else this.attributes[t]=i}hasField(e){const t=e.toLowerCase();if(void 0!==this.attributes[e])return!0;for(const i in this.attributes)if(i.toLowerCase()===t)return!0;return!!this._hasFieldDefinition(t)}keys(){let e=[];const t={};for(const i in this.attributes)e.push(i),t[i.toLowerCase()]=1;if(null!==this._layer)for(let i=0;i<this._layer.fields.length;i++){const s=this._layer.fields[i];1!==t[s.name.toLowerCase()]&&e.push(s.name)}return e=e.sort(),e}static parseGeometryFromDictionary(e,t){const i=w._convertDictionaryToJson(e,!0);return void 0!==i.hasm&&(i.hasM=i.hasm,delete i.hasm),void 0!==i.hasz&&(i.hasZ=i.hasz,delete i.hasz),void 0!==i.spatialreference&&(i.spatialReference=i.spatialreference,delete i.spatialreference),i.spatialReference||(i.spatialReference=t),void 0!==i.rings&&(i.rings=this._fixPathArrays(i.rings,!0===i.hasZ,!0===i.hasZ)),void 0!==i.paths&&(i.paths=this._fixPathArrays(i.paths,!0===i.hasZ,!0===i.hasM)),void 0!==i.points&&(i.points=this._fixPointArrays(i.points,!0===i.hasZ,!0===i.hasM)),b(i)}static _fixPathArrays(e,t,i){const s=[];if(Array.isArray(e))for(let r=0;r<e.length;r++)s.push(this._fixPointArrays(e[r],t,i));else if(e instanceof o)for(let r=0;r<e.length();r++)s.push(this._fixPointArrays(e.get(r),t,i));return s}static _fixPointArrays(e,t,i){const s=[];if(Array.isArray(e))for(let r=0;r<e.length;r++){const a=e[r];a instanceof _?t&&i?s.push([a.x,a.y,a.z,a.m]):t?s.push([a.x,a.y,a.z]):i?s.push([a.x,a.y,a.m]):s.push([a.x,a.y]):a instanceof o?s.push(a.toArray()):s.push(a)}else if(e instanceof o)for(let r=0;r<e.length();r++){const a=e.get(r);a instanceof _?t&&i?s.push([a.x,a.y,a.z,a.m]):t?s.push([a.x,a.y,a.z]):i?s.push([a.x,a.y,a.m]):s.push([a.x,a.y]):a instanceof o?s.push(a.toArray()):s.push(a)}return s}static _convertDictionaryToJson(e,t=!1){const s={};for(const r in e.attributes){let o=e.attributes[r];o instanceof i&&(o=w._convertDictionaryToJson(o)),t?s[r.toLowerCase()]=o:s[r]=o}return s}static parseAttributesFromDictionary(e){const t={};for(const i in e.attributes){const o=e.attributes[i];if(!h(o))throw new s(null,r.InvalidParameter,null);t[i]=o}return t}static fromJson(e,t){let i=null;null!==e.geometry&&void 0!==e.geometry&&(i=b(e.geometry));const o={};if(null!==e.attributes&&void 0!==e.attributes)for(const a in e.attributes){const t=e.attributes[a];if(null===t)o[a]=t;else{if(!(F(t)||x(t)||D(t)||f(t)||u(t)||d(t)))throw new s(null,r.InvalidParameter,null);o[a]=t}}return w.createFromGraphicLikeObject(i,o,null,t??null)}fullSchema(){return this._layer}gdbVersion(){if(null===this._layer)return"";const e=this._layer.gdbVersion;return void 0===e?"":""===e&&this._layer.capabilities?.isVersioned?"SDE.DEFAULT":e}castAsJson(e){const t={attributes:{},geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null};for(const i in this.attributes){const s=this.attributes[i];void 0!==s&&(t.attributes[i]=m(s,e))}return t}async castAsJsonAsync(e=null,t){return this.castAsJson(t)}}t(w);export{w as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
+ */
5
+ import{ArcadeDate as t}from"./ArcadeDate.js";import{ArcadeExecutionError as e,ExecutionErrorCodes as i}from"./executionError.js";import r from"./ImmutableArray.js";import{c as s}from"../chunks/languageUtils.js";import{isDate as o}from"../support/guards.js";const n="Voxel.Position",a="Voxel.LocalTime";function l(t){const s=t.getAttribute(n);if("string"!=typeof s)throw new e(null,i.InvalidParameter,null);const o=JSON.parse(s);if(!Array.isArray(o)||"number"!=typeof o[0]||"number"!=typeof o[1]||"number"!=typeof o[2])throw new e(null,i.InvalidParameter,null);return new r(o)}function u(r,s){const n=r.getAttribute(a);if(null==n)return null;if(!o(n))throw new e(null,i.InvalidParameter,null);return t.dateJSAndZoneToArcadeDate(n,s)}class c{constructor(t,e){this._graphic=t,this._timeZone=e,this.arcadeDeclaredClass="esri.arcade.Voxel",this._layer=t.layer}getPosition(){return void 0!==this._position?this._position:this._position=l(this._graphic)}getLocalTime(){return void 0!==this._localTime?this._localTime:this._localTime=u(this._graphic,this._timeZone??"system")}keys(){return this._layer.fields.map((t=>t.name)).sort()}hasField(t){return this._layer.fieldsIndex.has(t)}field(t){const r=this._layer.fieldsIndex?.get(t)?.name;if(null==r)throw new e(null,i.FieldNotFound,null,{key:t});switch(r){case n:return this.getPosition();case a:return this.getLocalTime()}return this._graphic.attributes[r]??null}castToText(t=!1){const e={...this._graphic.attributes};e[n]=this.getPosition(),a in e&&(e[a]=this.getLocalTime());for(const i of Object.keys(e))this._layer.fieldsIndex?.has(i)||delete e[i];return s(e,{useNumbersForDates:t})}}export{c as Voxel};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{toSymbolId as e}from"./arcadeEnvironment.js";import{ArcadeModule as t}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import{getNestedOptionalValue as r,geometryMember as o,getGeometryKeys as a}from"./containerUtils.js";import i from"./Dictionary.js";import{ArcadeExecutionError as l,ExecutionErrorCodes as s,ensureArcadeExecutionError as c}from"./executionError.js";import u from"./Feature.js";import{NativeFunction as f,ScopeMarshalledFunction as p,ArcadeFunction as w,wrapModuleScopedResponse as d}from"./FunctionWrapper.js";import{B as h,z as g,i as m,v as y,d as b,n as v,m as S,f as x,y as F,A as I,R as k,I as M,w as R,x as A,s as C,p as O,l as N}from"../chunks/languageUtils.js";import{addFunctionDeclaration as B}from"./treeAnalysis.js";import{A as E}from"../chunks/array.js";import{registerFunctions as j}from"./functions/date.js";import{registerFunctions as D}from"./functions/geomasync.js";import{registerFunctions as K}from"./functions/geometry.js";import{registerFunctions as U}from"./functions/maths.js";import{registerFunctions as Z}from"./functions/stats.js";import{registerFunctions as G}from"./functions/string.js";import L from"../geometry/Geometry.js";import q from"../geometry/SpatialReference.js";import{isBoolean as P,isString as V,isArray as W,isNumber as T,isGraphic as _}from"../support/guards.js";async function z(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(await X(e,t.arguments[r]));return n}async function Y(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await z(e,t))}class H extends w{constructor(e,t){super(),this.definition=null,this.context=null,this.definition=e,this.context=t}createFunction(e){return(...t)=>{const n={spatialReference:this.context.spatialReference,console:this.context.console,lrucache:this.context.lrucache,timeZone:this.context.timeZone??null,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,localScope:{},depthCounter:{depth:e.depthCounter+1},globalScope:this.context.globalScope};if(n.depthCounter.depth>64)throw new l(e,s.MaximumCallDepth,null);return je(this.definition,n,t,null)}}call(e,t){return Q(e,t,((n,r,o)=>{const a={spatialReference:e.spatialReference,services:e.services,console:e.console,libraryResolver:e.libraryResolver,exports:e.exports,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:{},abortSignal:e.abortSignal,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1}};if(a.depthCounter.depth>64)throw new l(e,s.MaximumCallDepth,t);return je(this.definition,a,o,t)}))}marshalledCall(e,t,n,r){return r(e,t,(async(o,a,i)=>{const l={spatialReference:e.spatialReference,globalScope:n.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,abortSignal:e.abortSignal,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:{}};return i=i.map((t=>!m(t)||t instanceof p?t:d(t,e,r))),d(await je(this.definition,l,i,t),n,r)}))}}class J extends t{constructor(e){super(),this.source=e}global(t){const n=this.executingContext.globalScope[e(t)];if(m(n.value)&&!(n.value instanceof p)){const e=new p;e.fn=n.value,e.parameterEvaluator=Q,e.context=this.executingContext,n.value=e}return n.value}setGlobal(t,n){if(m(n))throw new l(null,s.AssignModuleFunction,null);this.executingContext.globalScope[e(t)]={value:n}}hasGlobal(t){return void 0===this.executingContext.exports[t]&&(t=e(t)),void 0!==this.executingContext.exports[t]}async loadModule(e){let t=e.spatialReference;null==t&&(t=new q({wkid:102100})),this.moduleScope=Ue({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:t,services:e.services,libraryResolver:new n(e.libraryResolver._moduleSingletons,this.source.syntax.loadedModules),exports:{},abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,globalScope:this.moduleScope,console:e.console??Ze,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:null,depthCounter:{depth:1}},await he(this.executingContext,this.source.syntax)}}async function Q(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await z(e,t))}async function X(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"UpdateExpression":return await ue(e,t);case"AssignmentExpression":return await pe(e,t);case"TemplateLiteral":return await Oe(e,t);case"Identifier":return Ae(e,t);case"MemberExpression":return await Fe(e,t);case"Literal":return t.value;case"CallExpression":return await Ce(e,t);case"UnaryExpression":return await Ie(e,t);case"BinaryExpression":return await Me(e,t);case"LogicalExpression":return await Re(e,t);case"ArrayExpression":return await ke(e,t);case"ObjectExpression":return await ee(e,t);default:throw new l(e,s.Unrecognized,t)}}catch(n){throw c(e,t,n)}}async function $(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"ImportDeclaration":return await be(e,t);case"ExportNamedDeclaration":return await ve(e,t);case"VariableDeclaration":return await Se(e,t,0);case"BlockStatement":return await he(e,t);case"FunctionDeclaration":return await ye(e,t);case"ReturnStatement":return await me(e,t);case"IfStatement":return await de(e,t);case"ExpressionStatement":return await we(e,t);case"ForStatement":return await ne(e,t);case"WhileStatement":return await te(e,t);case"ForInStatement":return await se(e,t);case"ForOfStatement":return await ce(e,t);case"BreakStatement":return R;case"EmptyStatement":return y;case"ContinueStatement":return A;default:throw new l(e,s.Unrecognized,t)}}catch(n){throw c(e,t,n)}}async function ee(e,t){const n=[];for(let i=0;i<t.properties.length;i++){const r=t.properties[i],o=await X(e,r.value),a="Identifier"===r.key.type?r.key.name:await X(e,r.key);n[i]={key:a,value:o}}const r={},o=new Map;for(let i=0;i<n.length;i++){const a=n[i];if(m(a.value))throw new l(e,s.NoFunctionInDictionary,t);if(!1===V(a.key))throw new l(e,s.KeyMustBeString,t);let c=a.key.toString();const u=c.toLowerCase();o.has(u)?c=o.get(u):o.set(u,c),a.value===y?r[c]=null:r[c]=a.value}const a=new i(r);return a.immutable=!1,a}async function te(e,t){let n=await X(e,t.test);if(!1===n)return y;if(!0!==n)throw new l(e,s.BooleanConditionRequired,t);for(;!0===n;){const r=await $(e,t.body);if(r===R)break;if(r instanceof k)return r;if(n=await X(e,t.test),!0!==n&&!1!==n)throw new l(e,s.BooleanConditionRequired,t)}return y}async function ne(e,t){try{for(null!==t.init&&("VariableDeclaration"===t.init.type?await $(e,t.init):await X(e,t.init));;){if(null!==t.test){const n=await X(e,t.test);if(!0===e.abortSignal?.aborted)throw new l(e,s.Cancelled,t);if(!1===n)break;if(!0!==n)throw new l(e,s.BooleanConditionRequired,t)}const n=await $(e,t.body);if(n===R)break;if(n instanceof k)return n;null!==t.update&&await X(e,t.update)}return y}catch(n){throw n}}async function re(e,t,n,r,o="i"){const a=n.length;for(let i=0;i<a;i++){if("k"===o){if(i>=n.length)throw new l(e,s.OutOfBounds,t);r.value=n[i]}else r.value=i;const a=await $(e,t.body);if(a===R)break;if(a instanceof k)return a}return y}async function oe(e,t,n,r,o="i"){const a=n.length();for(let i=0;i<a;i++){r.value="k"===o?n.get(i):i;const a=await $(e,t.body);if(a===R)break;if(a instanceof k)return a}return y}async function ae(e,t,n,r){const o=n.iterator(e.abortSignal);let a;for(;null!=(a=await o.next());){const o=u.createFromGraphicLikeObject(a.geometry,a.attributes,n,e.timeZone);o._underlyingGraphic=a,r.value=o;const i=await $(e,t.body);if(i===R)break;if(i instanceof k)return i}return y}async function ie(e,t,n,r){for(const o of n.keys()){const a=n.field(o);r.value=new i({key:o,value:a});const l=await $(e,t.body);if(l===R)break;if(l instanceof k)return l}return y}async function le(e,t,n,r){for(const l of a(n)){const a=o(n,l,e,t,1);r.value=new i({key:l,value:a});const s=await $(e,t.body);if(s===R)break;if(s instanceof k)return s}return y}async function se(t,n){const r=await X(t,n.right);"VariableDeclaration"===n.left.type&&await $(t,n.left);const o=e("VariableDeclaration"===n.left.type?n.left.declarations[0].id:n.left);let c=null;if(null!=t.localScope&&void 0!==t.localScope[o]&&(c=t.localScope[o]),null===c&&void 0!==t.globalScope[o]&&(c=t.globalScope[o]),null===c)throw new l(t,s.InvalidIdentifier,n);return W(r)||V(r)?await re(t,n,r,c):S(r)?await oe(t,n,r,c):r instanceof i||v(r)?await re(t,n,r.keys(),c,"k"):O(r)?await ae(t,n,r,c):N(r)?await re(t,n,a(r),c,"k"):y}async function ce(t,n){const r=await X(t,n.right);"VariableDeclaration"===n.left.type&&await $(t,n.left);const o=e("VariableDeclaration"===n.left.type?n.left.declarations[0].id:n.left);let a=null;if(null!=t.localScope&&void 0!==t.localScope[o]&&(a=t.localScope[o]),null===a&&void 0!==t.globalScope[o]&&(a=t.globalScope[o]),null===a)throw new l(t,s.InvalidIdentifier,n);return W(r)||V(r)?await re(t,n,r,a,"k"):S(r)?await oe(t,n,r,a,"k"):r instanceof i||v(r)?await ie(t,n,r,a):O(r)?await ae(t,n,r,a):N(r)?await le(t,n,r,a):y}async function ue(t,n){const r=n.argument;if("CallExpression"===r.type)throw new l(t,s.NeverReach,n);if("MemberExpression"===r.type){const e=await X(t,r.object);let o,a;if(!0===r.computed)o=await X(t,r.property);else{if("Identifier"!==r.property.type)throw new l(t,s.Unrecognized,n);o=r.property.name}if(W(e)){if(!T(o))throw new l(t,s.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>=e.length)throw new l(t,s.OutOfBounds,n);a=b(e[o]),e[o]="++"===n.operator?a+1:a-1}else if(e instanceof i){if(!1===V(o))throw new l(t,s.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new l(t,s.FieldNotFound,n,{key:o});a=b(e.field(o)),e.setField(o,"++"===n.operator?a+1:a-1)}else if(e instanceof J){if(!1===V(o))throw new l(t,s.ModuleAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new l(t,s.ModuleExportNotFound,n);a=b(e.global(o)),e.setGlobal(o,"++"===n.operator?a+1:a-1)}else{if(!v(e))throw S(e)?new l(t,s.Immutable,n):new l(t,s.InvalidParameter,n);if(!1===V(o))throw new l(t,s.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new l(t,s.FieldNotFound,n,{key:o});a=b(e.field(o)),e.setField(o,"++"===n.operator?a+1:a-1)}return!1===n.prefix?a:"++"===n.operator?a+1:a-1}const o=e(r);let a;if(null!=t.localScope&&void 0!==t.localScope[o])return a=b(t.localScope[o].value),t.localScope[o]={value:"++"===n.operator?a+1:a-1},!1===n.prefix?a:"++"===n.operator?a+1:a-1;if(void 0!==t.globalScope[o])return a=b(t.globalScope[o].value),t.globalScope[o]={value:"++"===n.operator?a+1:a-1},!1===n.prefix?a:"++"===n.operator?a+1:a-1;throw new l(t,s.InvalidIdentifier,n)}function fe(e,t,n,r,o){switch(t){case"=":return e===y?null:e;case"/=":return b(n)/b(e);case"*=":return b(n)*b(e);case"-=":return b(n)-b(e);case"+=":return V(n)||V(e)?x(n)+x(e):b(n)+b(e);case"%=":return b(n)%b(e);default:throw new l(o,s.UnsupportedOperator,r)}}async function pe(t,n){const r=n.left;if("MemberExpression"===r.type){const e=await X(t,r.object);let o;if(!0===r.computed)o=await X(t,r.property);else{if("Identifier"!==r.property.type)throw new l(t,s.InvalidIdentifier,n);o=r.property.name}const a=await X(t,n.right);if(W(e)){if(!T(o))throw new l(t,s.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>e.length)throw new l(t,s.OutOfBounds,n);if(o===e.length){if("="!==n.operator)throw new l(t,s.OutOfBounds,n);e[o]=fe(a,n.operator,e[o],n,t)}else e[o]=fe(a,n.operator,e[o],n,t)}else if(e instanceof i){if(!1===V(o))throw new l(t,s.KeyAccessorMustBeString,n);if(!0===e.hasField(o))e.setField(o,fe(a,n.operator,e.field(o),n,t));else{if("="!==n.operator)throw new l(t,s.FieldNotFound,n,{key:o});e.setField(o,fe(a,n.operator,null,n,t))}}else if(e instanceof J){if(!1===V(o))throw new l(t,s.KeyAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new l(t,s.ModuleExportNotFound,n);e.setGlobal(o,fe(a,n.operator,e.global(o),n,t))}else{if(!v(e))throw S(e)?new l(t,s.Immutable,n):new l(t,s.InvalidParameter,n);if(!1===V(o))throw new l(t,s.KeyAccessorMustBeString,n);if(!0===e.hasField(o))e.setField(o,fe(a,n.operator,e.field(o),n,t));else{if("="!==n.operator)throw new l(t,s.FieldNotFound,n,{key:o});e.setField(o,fe(a,n.operator,null,n,t))}}return y}const o=e(r);if(null!=t.localScope&&void 0!==t.localScope[o]){const e=await X(t,n.right);return t.localScope[o]={value:fe(e,n.operator,t.localScope[o].value,n,t)},y}if(void 0!==t.globalScope[o]){const e=await X(t,n.right);return t.globalScope[o]={value:fe(e,n.operator,t.globalScope[o].value,n,t)},y}throw new l(t,s.InvalidIdentifier,n)}async function we(e,t){const n=await X(e,t.expression);return n===y?y:new M(n)}async function de(e,t){const n=await X(e,t.test);if(!0===n)return $(e,t.consequent);if(!1===n)return null!==t.alternate?$(e,t.alternate):y;throw new l(e,s.BooleanConditionRequired,t)}async function he(e,t){return ge(e,t,0)}async function ge(e,t,n){if(n>=t.body.length)return y;const r=await $(e,t.body[n]);return r instanceof k||r===R||r===A||n===t.body.length-1?r:ge(e,t,n+1)}async function me(e,t){if(null===t.argument)return new k(y);const n=await X(e,t.argument);return new k(n)}async function ye(t,n){const r=e(n.id);return t.globalScope[r]={value:new H(n,t)},y}async function be(t,n){const r=e(n.specifiers[0].local),o=t.libraryResolver.loadLibrary(r);let a;return t.libraryResolver._moduleSingletons?.has(o.uri)?a=t.libraryResolver._moduleSingletons.get(o.uri):(a=new J(o),await a.loadModule(t),t.libraryResolver._moduleSingletons?.set(o.uri,a)),t.globalScope[r]={value:a},y}async function ve(t,n){if(await $(t,n.declaration),"FunctionDeclaration"===n.declaration.type)t.exports[e(n.declaration.id)]="function";else if("VariableDeclaration"===n.declaration.type)for(const r of n.declaration.declarations)t.exports[e(r.id)]="variable";return y}async function Se(e,t,n){return n>=t.declarations.length?y:(await xe(e,t.declarations[n]),n===t.declarations.length-1||await Se(e,t,n+1),y)}async function xe(t,n){let r=null;if(r=null===n.init?null:await X(t,n.init),null!==t.localScope){if(r===y&&(r=null),"Identifier"!==n.id.type)throw new l(t,s.InvalidIdentifier,n);const o=e(n.id);return void(null!=t.localScope&&(t.localScope[o]={value:r}))}if("Identifier"!==n.id.type)throw new l(t,s.InvalidIdentifier,n);const o=e(n.id);r===y&&(r=null),t.globalScope[o]={value:r}}async function Fe(e,t){const n=await X(e,t.object);if(null===n)throw new l(e,s.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(n instanceof i||v(n))return n.field(t.property.name);if(n instanceof L)return o(n,t.property.name,e,t);if(n instanceof J){if(!n.hasGlobal(t.property.name))throw new l(e,s.InvalidIdentifier,t);return n.global(t.property.name)}throw new l(e,s.InvalidMemberAccessKey,t)}throw new l(e,s.InvalidMemberAccessKey,t)}let r=await X(e,t.property);if(n instanceof i||v(n)){if(V(r))return n.field(r);throw new l(e,s.InvalidMemberAccessKey,t)}if(n instanceof J){if(V(r))return n.global(r);throw new l(e,s.InvalidMemberAccessKey,t)}if(n instanceof L){if(V(r))return o(n,r,e,t);throw new l(e,s.InvalidMemberAccessKey,t)}if(W(n)){if(T(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new l(e,s.OutOfBounds,t);return n[r]}throw new l(e,s.InvalidMemberAccessKey,t)}if(S(n)){if(T(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length()+r),r>=n.length()||r<0)throw new l(e,s.OutOfBounds,t);return n.get(r)}throw new l(e,s.InvalidMemberAccessKey,t)}if(V(n)){if(T(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new l(e,s.OutOfBounds,t);return n[r]}throw new l(e,s.InvalidMemberAccessKey,t)}throw new l(e,s.InvalidMemberAccessKey,t)}async function Ie(e,t){const n=await X(e,t.argument);if(P(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*b(n);if("+"===t.operator)return 1*b(n);if("~"===t.operator)return~b(n);throw new l(e,s.UnsupportedUnaryOperator,t)}if("-"===t.operator)return-1*b(n);if("+"===t.operator)return 1*b(n);if("~"===t.operator)return~b(n);throw new l(e,s.UnsupportedUnaryOperator,t)}async function ke(e,t){const n=[];for(let r=0;r<t.elements.length;r++)n.push(await X(e,t.elements[r]));for(let r=0;r<n.length;r++){if(m(n[r]))throw new l(e,s.NoFunctionInArray,t);n[r]===y&&(n[r]=null)}return n}async function Me(e,t){const n=await X(e,t.left),r=await X(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return I(b(n),b(r),t.operator);case"==":return g(n,r);case"!=":return!g(n,r);case"<":case">":case"<=":case">=":return F(n,r,t.operator);case"+":return V(n)||V(r)?x(n)+x(r):b(n)+b(r);case"-":return b(n)-b(r);case"*":return b(n)*b(r);case"/":return b(n)/b(r);case"%":return b(n)%b(r);default:throw new l(e,s.UnsupportedOperator,t)}}async function Re(e,t){const n=await X(e,t.left);if(!P(n))throw new l(e,s.LogicalExpressionOnlyBoolean,t);switch(t.operator){case"||":{if(!0===n)return n;const r=await X(e,t.right);if(P(r))return r;throw new l(e,s.LogicExpressionOrAnd,t)}case"&&":{if(!1===n)return n;const r=await X(e,t.right);if(P(r))return r;throw new l(e,s.LogicExpressionOrAnd,t)}default:throw new l(e,s.LogicExpressionOrAnd,t)}}function Ae(t,n){const r=e(n);if(null!=t.localScope&&void 0!==t.localScope[r])return t.localScope[r].value;if(void 0!==t.globalScope[r])return t.globalScope[r].value;throw new l(t,s.InvalidIdentifier,n)}async function Ce(t,n){if("MemberExpression"===n.callee.type){const e=await X(t,n.callee.object);if(!(e instanceof J))throw new l(t,s.FunctionNotFound,n);const r=!1===n.callee.computed?n.callee.property.name:await X(t,n.callee.property);if(!e.hasGlobal(r))throw new l(t,s.FunctionNotFound,n);const o=e.global(r);if(!m(o))throw new l(t,s.CallNonFunction,n);return o.call(t,n)}if("Identifier"!==n.callee.type)throw new l(t,s.FunctionNotFound,n);const r=e(n.callee);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];if(m(e.value))return e.value.call(t,n);throw new l(t,s.CallNonFunction,n)}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];if(m(e.value))return e.value.call(t,n);throw new l(t,s.CallNonFunction,n)}throw new l(t,s.FunctionNotFound,n)}async function Oe(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){if(t.expressions[r]){const o=await X(e,t.expressions[r]);if(m(o))throw new l(e,s.NoFunctionInTemplateLiteral,t);n+=x(o)}r++}return n}const Ne={};async function Be(e,t,n,r){const o=await X(e,t.arguments[n]);if(g(o,r))return X(e,t.arguments[n+1]);const a=t.arguments.length-n;return 1===a?X(e,t.arguments[n]):2===a?null:3===a?X(e,t.arguments[n+2]):Be(e,t,n+2,r)}async function Ee(e,t,n,r){if(!0===r)return X(e,t.arguments[n+1]);if(3===t.arguments.length-n)return X(e,t.arguments[n+2]);const o=await X(e,t.arguments[n+2]);if(!1===P(o))throw new l(e,s.ModuleExportNotFound,t.arguments[n+2]);return Ee(e,t,n+2,o)}async function je(t,n,r,o){const a=t.body;if(r.length!==t.params.length)throw new l(n,s.WrongNumberOfParameters,null);for(let l=0;l<r.length;l++){const o=t.params[l];"Identifier"===o.type&&null!=n.localScope&&(n.localScope[e(o)]={value:r[l]})}const i=await $(n,a);if(i instanceof k)return i.value;if(i===R)throw new l(n,s.UnexpectedToken,o);if(i===A)throw new l(n,s.UnexpectedToken,o);return i instanceof M?i.value:i}j(Ne,Y),G(Ne,Y),U(Ne,Y),K(Ne,Y),Z(Ne,Y),D({functions:Ne,compiled:!1,signatures:null,evaluateIdentifier:null,mode:"async",standardFunction:Y,standardFunctionAsync:Q}),Ne.iif=async function(e,t){h(null===t.arguments?[]:t.arguments,3,3,e,t);const n=await X(e,t.arguments[0]);if(!1===P(n))throw new l(e,s.BooleanConditionRequired,t);return X(e,n?t.arguments[1]:t.arguments[2])},Ne.defaultvalue=async function(e,t){h(null===t.arguments?[]:t.arguments,2,3,e,t);const n=await X(e,t.arguments[0]);if(3===t.arguments.length){const o=await X(e,t.arguments[1]),a=r(n,o);return null!=a&&""!==a?a:X(e,t.arguments[2])}return null==n||""===n?X(e,t.arguments[1]):n},Ne.decode=async function(e,t){if(t.arguments.length<2)throw new l(e,s.WrongNumberOfParameters,t);if(2===t.arguments.length)return X(e,t.arguments[1]);if((t.arguments.length-1)%2==0)throw new l(e,s.WrongNumberOfParameters,t);return Be(e,t,1,await X(e,t.arguments[0]))},Ne.when=async function(e,t){if(t.arguments.length<3)throw new l(e,s.WrongNumberOfParameters,t);if(t.arguments.length%2==0)throw new l(e,s.WrongNumberOfParameters,t);const n=await X(e,t.arguments[0]);if(!1===P(n))throw new l(e,s.BooleanConditionRequired,t.arguments[0]);return Ee(e,t,0,n)};const De={fixSpatialReference:C,parseArguments:z,standardFunction:Y,standardFunctionAsync:Q,evaluateIdentifier:Ae};for(const Pe in Ne)Ne[Pe]={value:new f(Ne[Pe])};const Ke=function(){};function Ue(e,t,n){const r=new Ke;null==e&&(e={}),null==t&&(t={});const o=new i({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});o.immutable=!1,r.textformatting={value:o};for(const a in t)r[a]={value:new f(t[a])};for(const a in e)r[a]={value:_(e[a])?u.createFromGraphic(e[a],n):e[a]};return r}function Ze(e){console.log(e)}Ke.prototype=Ne,Ke.prototype.infinity={value:Number.POSITIVE_INFINITY},Ke.prototype.pi={value:Math.PI};const Ge=De;function Le(e){const t={mode:"async",compiled:!1,functions:{},signatures:[],standardFunction:Y,standardFunctionAsync:Q,evaluateIdentifier:Ae};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)Ne[n]={value:new f(t.functions[n])},Ke.prototype[n]=Ne[n];for(let n=0;n<t.signatures.length;n++)B(t.signatures[n],"async")}async function qe(e,t){let r=t.spatialReference;null==r&&(r=new q({wkid:102100}));let o=null;e.usesModules&&(o=new n(new Map,e.loadedModules));const a=Ue(t.vars,t.customfunctions,t.timeZone),i={spatialReference:r,services:t.services,exports:{},libraryResolver:o,abortSignal:void 0===t.abortSignal||null===t.abortSignal?{aborted:!1}:t.abortSignal,globalScope:a,console:t.console??Ze,timeZone:t.timeZone??null,lrucache:t.lrucache,interceptor:t.interceptor,localScope:null,depthCounter:{depth:1}},c=await he(i,e);if(c instanceof k||c instanceof M){const e=c.value;if(e===y)return null;if(m(e))throw new l(i,s.IllegalResult,null);return e}if(c===y)return null;if(c===R)throw new l(i,s.IllegalResult,null);if(c===A)throw new l(i,s.IllegalResult,null);throw new l(i,s.NeverReach,null)}Le([E]);export{qe as executeScript,Le as extend,Ge as functionHelper};
5
+ import{toSymbolId as e}from"./arcadeEnvironment.js";import{ArcadeModule as t}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import{getNestedOptionalValue as r,geometryMember as o,getGeometryKeys as a}from"./containerUtils.js";import i from"./Dictionary.js";import{ArcadeExecutionError as l,ExecutionErrorCodes as s,ensureArcadeExecutionError as c}from"./executionError.js";import u from"./Feature.js";import{NativeFunction as f,ScopeMarshalledFunction as p,ArcadeFunction as w,wrapModuleScopedResponse as d}from"./FunctionWrapper.js";import{D as h,B as g,i as m,w as y,t as b,n as v,m as S,z as x,f as F,A as I,C as k,R as M,I as R,x as A,y as C,u as O,p as N,l as B}from"../chunks/languageUtils.js";import{addFunctionDeclaration as E}from"./treeAnalysis.js";import{A as j}from"../chunks/array.js";import{registerFunctions as D}from"./functions/date.js";import{registerFunctions as K}from"./functions/geomasync.js";import{registerFunctions as U}from"./functions/geometry.js";import{registerFunctions as Z}from"./functions/maths.js";import{registerFunctions as G}from"./functions/stats.js";import{registerFunctions as L}from"./functions/string.js";import q from"../geometry/Geometry.js";import P from"../geometry/SpatialReference.js";import{isBoolean as V,isString as W,isArray as T,isNumber as _,isGraphic as z}from"../support/guards.js";async function Y(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(await $(e,t.arguments[r]));return n}async function H(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await Y(e,t))}class J extends w{constructor(e,t){super(),this.definition=null,this.context=null,this.definition=e,this.context=t}createFunction(e){return(...t)=>{const n={spatialReference:this.context.spatialReference,console:this.context.console,lrucache:this.context.lrucache,timeZone:this.context.timeZone??null,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,localScope:{},depthCounter:{depth:e.depthCounter+1},globalScope:this.context.globalScope};if(n.depthCounter.depth>64)throw new l(e,s.MaximumCallDepth,null);return De(this.definition,n,t,null)}}call(e,t){return X(e,t,((n,r,o)=>{const a={spatialReference:e.spatialReference,services:e.services,console:e.console,libraryResolver:e.libraryResolver,exports:e.exports,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:{},abortSignal:e.abortSignal,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1}};if(a.depthCounter.depth>64)throw new l(e,s.MaximumCallDepth,t);return De(this.definition,a,o,t)}))}marshalledCall(e,t,n,r){return r(e,t,(async(o,a,i)=>{const l={spatialReference:e.spatialReference,globalScope:n.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,abortSignal:e.abortSignal,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:{}};return i=i.map((t=>!m(t)||t instanceof p?t:d(t,e,r))),d(await De(this.definition,l,i,t),n,r)}))}}class Q extends t{constructor(e){super(),this.source=e}global(t){const n=this.executingContext.globalScope[e(t)];if(m(n.value)&&!(n.value instanceof p)){const e=new p;e.fn=n.value,e.parameterEvaluator=X,e.context=this.executingContext,n.value=e}return n.value}setGlobal(t,n){if(m(n))throw new l(null,s.AssignModuleFunction,null);this.executingContext.globalScope[e(t)]={value:n}}hasGlobal(t){return void 0===this.executingContext.exports[t]&&(t=e(t)),void 0!==this.executingContext.exports[t]}async loadModule(e){let t=e.spatialReference;null==t&&(t=new P({wkid:102100})),this.moduleScope=Ze({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:t,services:e.services,libraryResolver:new n(e.libraryResolver._moduleSingletons,this.source.syntax.loadedModules),exports:{},abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,globalScope:this.moduleScope,console:e.console??Ge,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:null,depthCounter:{depth:1}},await ge(this.executingContext,this.source.syntax)}}async function X(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await Y(e,t))}async function $(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"UpdateExpression":return await fe(e,t);case"AssignmentExpression":return await we(e,t);case"TemplateLiteral":return await Ne(e,t);case"Identifier":return Ce(e,t);case"MemberExpression":return await Ie(e,t);case"Literal":return t.value;case"CallExpression":return await Oe(e,t);case"UnaryExpression":return await ke(e,t);case"BinaryExpression":return await Re(e,t);case"LogicalExpression":return await Ae(e,t);case"ArrayExpression":return await Me(e,t);case"ObjectExpression":return await te(e,t);default:throw new l(e,s.Unrecognized,t)}}catch(n){throw c(e,t,n)}}async function ee(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"ImportDeclaration":return await ve(e,t);case"ExportNamedDeclaration":return await Se(e,t);case"VariableDeclaration":return await xe(e,t,0);case"BlockStatement":return await ge(e,t);case"FunctionDeclaration":return await be(e,t);case"ReturnStatement":return await ye(e,t);case"IfStatement":return await he(e,t);case"ExpressionStatement":return await de(e,t);case"ForStatement":return await re(e,t);case"WhileStatement":return await ne(e,t);case"ForInStatement":return await ce(e,t);case"ForOfStatement":return await ue(e,t);case"BreakStatement":return A;case"EmptyStatement":return y;case"ContinueStatement":return C;default:throw new l(e,s.Unrecognized,t)}}catch(n){throw c(e,t,n)}}async function te(e,t){const n=[];for(let i=0;i<t.properties.length;i++){const r=t.properties[i],o=await $(e,r.value),a="Identifier"===r.key.type?r.key.name:await $(e,r.key);n[i]={key:a,value:o}}const r={},o=new Map;for(let i=0;i<n.length;i++){const a=n[i];if(m(a.value))throw new l(e,s.NoFunctionInDictionary,t);if(!1===W(a.key))throw new l(e,s.KeyMustBeString,t);let c=a.key.toString();const u=c.toLowerCase();o.has(u)?c=o.get(u):o.set(u,c),a.value===y?r[c]=null:r[c]=a.value}const a=new i(r);return a.immutable=!1,a}async function ne(e,t){let n=await $(e,t.test);if(!1===n)return y;if(!0!==n)throw new l(e,s.BooleanConditionRequired,t);for(;!0===n;){const r=await ee(e,t.body);if(r===A)break;if(r instanceof M)return r;if(n=await $(e,t.test),!0!==n&&!1!==n)throw new l(e,s.BooleanConditionRequired,t)}return y}async function re(e,t){try{for(null!==t.init&&("VariableDeclaration"===t.init.type?await ee(e,t.init):await $(e,t.init));;){if(null!==t.test){const n=await $(e,t.test);if(!0===e.abortSignal?.aborted)throw new l(e,s.Cancelled,t);if(!1===n)break;if(!0!==n)throw new l(e,s.BooleanConditionRequired,t)}const n=await ee(e,t.body);if(n===A)break;if(n instanceof M)return n;null!==t.update&&await $(e,t.update)}return y}catch(n){throw n}}async function oe(e,t,n,r,o="i"){const a=n.length;for(let i=0;i<a;i++){if("k"===o){if(i>=n.length)throw new l(e,s.OutOfBounds,t);r.value=n[i]}else r.value=i;const a=await ee(e,t.body);if(a===A)break;if(a instanceof M)return a}return y}async function ae(e,t,n,r,o="i"){const a=n.length();for(let i=0;i<a;i++){r.value="k"===o?n.get(i):i;const a=await ee(e,t.body);if(a===A)break;if(a instanceof M)return a}return y}async function ie(e,t,n,r){const o=n.iterator(e.abortSignal);let a;for(;null!=(a=await o.next());){const o=u.createFromGraphicLikeObject(a.geometry,a.attributes,n,e.timeZone);o._underlyingGraphic=a,r.value=o;const i=await ee(e,t.body);if(i===A)break;if(i instanceof M)return i}return y}async function le(e,t,n,r){for(const o of n.keys()){const a=n.field(o);r.value=new i({key:o,value:a});const l=await ee(e,t.body);if(l===A)break;if(l instanceof M)return l}return y}async function se(e,t,n,r){for(const l of a(n)){const a=o(n,l,e,t,1);r.value=new i({key:l,value:a});const s=await ee(e,t.body);if(s===A)break;if(s instanceof M)return s}return y}async function ce(t,n){const r=await $(t,n.right);"VariableDeclaration"===n.left.type&&await ee(t,n.left);const o=e("VariableDeclaration"===n.left.type?n.left.declarations[0].id:n.left);let c=null;if(null!=t.localScope&&void 0!==t.localScope[o]&&(c=t.localScope[o]),null===c&&void 0!==t.globalScope[o]&&(c=t.globalScope[o]),null===c)throw new l(t,s.InvalidIdentifier,n);return T(r)||W(r)?await oe(t,n,r,c):S(r)?await ae(t,n,r,c):r instanceof i||x(r)?await oe(t,n,r.keys(),c,"k"):N(r)?await ie(t,n,r,c):B(r)?await oe(t,n,a(r),c,"k"):y}async function ue(t,n){const r=await $(t,n.right);"VariableDeclaration"===n.left.type&&await ee(t,n.left);const o=e("VariableDeclaration"===n.left.type?n.left.declarations[0].id:n.left);let a=null;if(null!=t.localScope&&void 0!==t.localScope[o]&&(a=t.localScope[o]),null===a&&void 0!==t.globalScope[o]&&(a=t.globalScope[o]),null===a)throw new l(t,s.InvalidIdentifier,n);return T(r)||W(r)?await oe(t,n,r,a,"k"):S(r)?await ae(t,n,r,a,"k"):r instanceof i||x(r)?await le(t,n,r,a):N(r)?await ie(t,n,r,a):B(r)?await se(t,n,r,a):y}async function fe(t,n){const r=n.argument;if("CallExpression"===r.type)throw new l(t,s.NeverReach,n);if("MemberExpression"===r.type){const e=await $(t,r.object);let o,a;if(!0===r.computed)o=await $(t,r.property);else{if("Identifier"!==r.property.type)throw new l(t,s.Unrecognized,n);o=r.property.name}if(T(e)){if(!_(o))throw new l(t,s.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>=e.length)throw new l(t,s.OutOfBounds,n);a=b(e[o]),e[o]="++"===n.operator?a+1:a-1}else if(e instanceof i){if(!1===W(o))throw new l(t,s.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new l(t,s.FieldNotFound,n,{key:o});a=b(e.field(o)),e.setField(o,"++"===n.operator?a+1:a-1)}else if(e instanceof Q){if(!1===W(o))throw new l(t,s.ModuleAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new l(t,s.ModuleExportNotFound,n);a=b(e.global(o)),e.setGlobal(o,"++"===n.operator?a+1:a-1)}else{if(!v(e))throw S(e)?new l(t,s.Immutable,n):new l(t,s.InvalidParameter,n);if(!1===W(o))throw new l(t,s.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new l(t,s.FieldNotFound,n,{key:o});a=b(e.field(o)),e.setField(o,"++"===n.operator?a+1:a-1)}return!1===n.prefix?a:"++"===n.operator?a+1:a-1}const o=e(r);let a;if(null!=t.localScope&&void 0!==t.localScope[o])return a=b(t.localScope[o].value),t.localScope[o]={value:"++"===n.operator?a+1:a-1},!1===n.prefix?a:"++"===n.operator?a+1:a-1;if(void 0!==t.globalScope[o])return a=b(t.globalScope[o].value),t.globalScope[o]={value:"++"===n.operator?a+1:a-1},!1===n.prefix?a:"++"===n.operator?a+1:a-1;throw new l(t,s.InvalidIdentifier,n)}function pe(e,t,n,r,o){switch(t){case"=":return e===y?null:e;case"/=":return b(n)/b(e);case"*=":return b(n)*b(e);case"-=":return b(n)-b(e);case"+=":return W(n)||W(e)?F(n)+F(e):b(n)+b(e);case"%=":return b(n)%b(e);default:throw new l(o,s.UnsupportedOperator,r)}}async function we(t,n){const r=n.left;if("MemberExpression"===r.type){const e=await $(t,r.object);let o;if(!0===r.computed)o=await $(t,r.property);else{if("Identifier"!==r.property.type)throw new l(t,s.InvalidIdentifier,n);o=r.property.name}const a=await $(t,n.right);if(T(e)){if(!_(o))throw new l(t,s.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>e.length)throw new l(t,s.OutOfBounds,n);if(o===e.length){if("="!==n.operator)throw new l(t,s.OutOfBounds,n);e[o]=pe(a,n.operator,e[o],n,t)}else e[o]=pe(a,n.operator,e[o],n,t)}else if(e instanceof i){if(!1===W(o))throw new l(t,s.KeyAccessorMustBeString,n);if(!0===e.hasField(o))e.setField(o,pe(a,n.operator,e.field(o),n,t));else{if("="!==n.operator)throw new l(t,s.FieldNotFound,n,{key:o});e.setField(o,pe(a,n.operator,null,n,t))}}else if(e instanceof Q){if(!1===W(o))throw new l(t,s.KeyAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new l(t,s.ModuleExportNotFound,n);e.setGlobal(o,pe(a,n.operator,e.global(o),n,t))}else{if(!v(e))throw S(e)?new l(t,s.Immutable,n):new l(t,s.InvalidParameter,n);if(!1===W(o))throw new l(t,s.KeyAccessorMustBeString,n);if(!0===e.hasField(o))e.setField(o,pe(a,n.operator,e.field(o),n,t));else{if("="!==n.operator)throw new l(t,s.FieldNotFound,n,{key:o});e.setField(o,pe(a,n.operator,null,n,t))}}return y}const o=e(r);if(null!=t.localScope&&void 0!==t.localScope[o]){const e=await $(t,n.right);return t.localScope[o]={value:pe(e,n.operator,t.localScope[o].value,n,t)},y}if(void 0!==t.globalScope[o]){const e=await $(t,n.right);return t.globalScope[o]={value:pe(e,n.operator,t.globalScope[o].value,n,t)},y}throw new l(t,s.InvalidIdentifier,n)}async function de(e,t){const n=await $(e,t.expression);return n===y?y:new R(n)}async function he(e,t){const n=await $(e,t.test);if(!0===n)return ee(e,t.consequent);if(!1===n)return null!==t.alternate?ee(e,t.alternate):y;throw new l(e,s.BooleanConditionRequired,t)}async function ge(e,t){return me(e,t,0)}async function me(e,t,n){if(n>=t.body.length)return y;const r=await ee(e,t.body[n]);return r instanceof M||r===A||r===C||n===t.body.length-1?r:me(e,t,n+1)}async function ye(e,t){if(null===t.argument)return new M(y);const n=await $(e,t.argument);return new M(n)}async function be(t,n){const r=e(n.id);return t.globalScope[r]={value:new J(n,t)},y}async function ve(t,n){const r=e(n.specifiers[0].local),o=t.libraryResolver.loadLibrary(r);let a;return t.libraryResolver._moduleSingletons?.has(o.uri)?a=t.libraryResolver._moduleSingletons.get(o.uri):(a=new Q(o),await a.loadModule(t),t.libraryResolver._moduleSingletons?.set(o.uri,a)),t.globalScope[r]={value:a},y}async function Se(t,n){if(await ee(t,n.declaration),"FunctionDeclaration"===n.declaration.type)t.exports[e(n.declaration.id)]="function";else if("VariableDeclaration"===n.declaration.type)for(const r of n.declaration.declarations)t.exports[e(r.id)]="variable";return y}async function xe(e,t,n){return n>=t.declarations.length?y:(await Fe(e,t.declarations[n]),n===t.declarations.length-1||await xe(e,t,n+1),y)}async function Fe(t,n){let r=null;if(r=null===n.init?null:await $(t,n.init),null!==t.localScope){if(r===y&&(r=null),"Identifier"!==n.id.type)throw new l(t,s.InvalidIdentifier,n);const o=e(n.id);return void(null!=t.localScope&&(t.localScope[o]={value:r}))}if("Identifier"!==n.id.type)throw new l(t,s.InvalidIdentifier,n);const o=e(n.id);r===y&&(r=null),t.globalScope[o]={value:r}}async function Ie(e,t){const n=await $(e,t.object);if(null===n)throw new l(e,s.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(n instanceof i||x(n))return n.field(t.property.name);if(n instanceof q)return o(n,t.property.name,e,t);if(n instanceof Q){if(!n.hasGlobal(t.property.name))throw new l(e,s.InvalidIdentifier,t);return n.global(t.property.name)}throw new l(e,s.InvalidMemberAccessKey,t)}throw new l(e,s.InvalidMemberAccessKey,t)}let r=await $(e,t.property);if(n instanceof i||x(n)){if(W(r))return n.field(r);throw new l(e,s.InvalidMemberAccessKey,t)}if(n instanceof Q){if(W(r))return n.global(r);throw new l(e,s.InvalidMemberAccessKey,t)}if(n instanceof q){if(W(r))return o(n,r,e,t);throw new l(e,s.InvalidMemberAccessKey,t)}if(T(n)){if(_(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new l(e,s.OutOfBounds,t);return n[r]}throw new l(e,s.InvalidMemberAccessKey,t)}if(S(n)){if(_(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length()+r),r>=n.length()||r<0)throw new l(e,s.OutOfBounds,t);return n.get(r)}throw new l(e,s.InvalidMemberAccessKey,t)}if(W(n)){if(_(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new l(e,s.OutOfBounds,t);return n[r]}throw new l(e,s.InvalidMemberAccessKey,t)}throw new l(e,s.InvalidMemberAccessKey,t)}async function ke(e,t){const n=await $(e,t.argument);if(V(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*b(n);if("+"===t.operator)return 1*b(n);if("~"===t.operator)return~b(n);throw new l(e,s.UnsupportedUnaryOperator,t)}if("-"===t.operator)return-1*b(n);if("+"===t.operator)return 1*b(n);if("~"===t.operator)return~b(n);throw new l(e,s.UnsupportedUnaryOperator,t)}async function Me(e,t){const n=[];for(let r=0;r<t.elements.length;r++)n.push(await $(e,t.elements[r]));for(let r=0;r<n.length;r++){if(m(n[r]))throw new l(e,s.NoFunctionInArray,t);n[r]===y&&(n[r]=null)}return n}async function Re(e,t){const n=await $(e,t.left),r=await $(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return k(b(n),b(r),t.operator);case"==":return g(n,r);case"!=":return!g(n,r);case"<":case">":case"<=":case">=":return I(n,r,t.operator);case"+":return W(n)||W(r)?F(n)+F(r):b(n)+b(r);case"-":return b(n)-b(r);case"*":return b(n)*b(r);case"/":return b(n)/b(r);case"%":return b(n)%b(r);default:throw new l(e,s.UnsupportedOperator,t)}}async function Ae(e,t){const n=await $(e,t.left);if(!V(n))throw new l(e,s.LogicalExpressionOnlyBoolean,t);switch(t.operator){case"||":{if(!0===n)return n;const r=await $(e,t.right);if(V(r))return r;throw new l(e,s.LogicExpressionOrAnd,t)}case"&&":{if(!1===n)return n;const r=await $(e,t.right);if(V(r))return r;throw new l(e,s.LogicExpressionOrAnd,t)}default:throw new l(e,s.LogicExpressionOrAnd,t)}}function Ce(t,n){const r=e(n);if(null!=t.localScope&&void 0!==t.localScope[r])return t.localScope[r].value;if(void 0!==t.globalScope[r])return t.globalScope[r].value;throw new l(t,s.InvalidIdentifier,n)}async function Oe(t,n){if("MemberExpression"===n.callee.type){const e=await $(t,n.callee.object);if(!(e instanceof Q))throw new l(t,s.FunctionNotFound,n);const r=!1===n.callee.computed?n.callee.property.name:await $(t,n.callee.property);if(!e.hasGlobal(r))throw new l(t,s.FunctionNotFound,n);const o=e.global(r);if(!m(o))throw new l(t,s.CallNonFunction,n);return o.call(t,n)}if("Identifier"!==n.callee.type)throw new l(t,s.FunctionNotFound,n);const r=e(n.callee);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];if(m(e.value))return e.value.call(t,n);throw new l(t,s.CallNonFunction,n)}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];if(m(e.value))return e.value.call(t,n);throw new l(t,s.CallNonFunction,n)}throw new l(t,s.FunctionNotFound,n)}async function Ne(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){if(t.expressions[r]){const o=await $(e,t.expressions[r]);if(m(o))throw new l(e,s.NoFunctionInTemplateLiteral,t);n+=F(o)}r++}return n}const Be={};async function Ee(e,t,n,r){const o=await $(e,t.arguments[n]);if(g(o,r))return $(e,t.arguments[n+1]);const a=t.arguments.length-n;return 1===a?$(e,t.arguments[n]):2===a?null:3===a?$(e,t.arguments[n+2]):Ee(e,t,n+2,r)}async function je(e,t,n,r){if(!0===r)return $(e,t.arguments[n+1]);if(3===t.arguments.length-n)return $(e,t.arguments[n+2]);const o=await $(e,t.arguments[n+2]);if(!1===V(o))throw new l(e,s.ModuleExportNotFound,t.arguments[n+2]);return je(e,t,n+2,o)}async function De(t,n,r,o){const a=t.body;if(r.length!==t.params.length)throw new l(n,s.WrongNumberOfParameters,null);for(let l=0;l<r.length;l++){const o=t.params[l];"Identifier"===o.type&&null!=n.localScope&&(n.localScope[e(o)]={value:r[l]})}const i=await ee(n,a);if(i instanceof M)return i.value;if(i===A)throw new l(n,s.UnexpectedToken,o);if(i===C)throw new l(n,s.UnexpectedToken,o);return i instanceof R?i.value:i}D(Be,H),L(Be,H),Z(Be,H),U(Be,H),G(Be,H),K({functions:Be,compiled:!1,signatures:null,evaluateIdentifier:null,mode:"async",standardFunction:H,standardFunctionAsync:X}),Be.iif=async function(e,t){h(null===t.arguments?[]:t.arguments,3,3,e,t);const n=await $(e,t.arguments[0]);if(!1===V(n))throw new l(e,s.BooleanConditionRequired,t);return $(e,n?t.arguments[1]:t.arguments[2])},Be.defaultvalue=async function(e,t){h(null===t.arguments?[]:t.arguments,2,3,e,t);const n=await $(e,t.arguments[0]);if(3===t.arguments.length){const o=await $(e,t.arguments[1]),a=r(n,o);return null!=a&&""!==a?a:$(e,t.arguments[2])}return null==n||""===n?$(e,t.arguments[1]):n},Be.decode=async function(e,t){if(t.arguments.length<2)throw new l(e,s.WrongNumberOfParameters,t);if(2===t.arguments.length)return $(e,t.arguments[1]);if((t.arguments.length-1)%2==0)throw new l(e,s.WrongNumberOfParameters,t);return Ee(e,t,1,await $(e,t.arguments[0]))},Be.when=async function(e,t){if(t.arguments.length<3)throw new l(e,s.WrongNumberOfParameters,t);if(t.arguments.length%2==0)throw new l(e,s.WrongNumberOfParameters,t);const n=await $(e,t.arguments[0]);if(!1===V(n))throw new l(e,s.BooleanConditionRequired,t.arguments[0]);return je(e,t,0,n)};const Ke={fixSpatialReference:O,parseArguments:Y,standardFunction:H,standardFunctionAsync:X,evaluateIdentifier:Ce};for(const Ve in Be)Be[Ve]={value:new f(Be[Ve])};const Ue=function(){};function Ze(e,t,n){const r=new Ue;null==e&&(e={}),null==t&&(t={});const o=new i({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});o.immutable=!1,r.textformatting={value:o};for(const a in t)r[a]={value:new f(t[a])};for(const a in e)r[a]={value:z(e[a])?u.createFromGraphic(e[a],n):e[a]};return r}function Ge(e){console.log(e)}Ue.prototype=Be,Ue.prototype.infinity={value:Number.POSITIVE_INFINITY},Ue.prototype.pi={value:Math.PI};const Le=Ke;function qe(e){const t={mode:"async",compiled:!1,functions:{},signatures:[],standardFunction:H,standardFunctionAsync:X,evaluateIdentifier:Ce};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)Be[n]={value:new f(t.functions[n])},Ue.prototype[n]=Be[n];for(let n=0;n<t.signatures.length;n++)E(t.signatures[n],"async")}async function Pe(e,t){let r=t.spatialReference;null==r&&(r=new P({wkid:102100}));let o=null;e.usesModules&&(o=new n(new Map,e.loadedModules));const a=Ze(t.vars,t.customfunctions,t.timeZone),i={spatialReference:r,services:t.services,exports:{},libraryResolver:o,abortSignal:void 0===t.abortSignal||null===t.abortSignal?{aborted:!1}:t.abortSignal,globalScope:a,console:t.console??Ge,timeZone:t.timeZone??null,lrucache:t.lrucache,interceptor:t.interceptor,localScope:null,depthCounter:{depth:1}},c=await ge(i,e);if(c instanceof M||c instanceof R){const e=c.value;if(e===y)return null;if(m(e))throw new l(i,s.IllegalResult,null);return e}if(c===y)return null;if(c===A)throw new l(i,s.IllegalResult,null);if(c===C)throw new l(i,s.IllegalResult,null);throw new l(i,s.NeverReach,null)}qe([j]);export{Pe as executeScript,qe as extend,Le as functionHelper};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{toSymbolId as e}from"./arcadeEnvironment.js";import{ArcadeModule as n}from"./ArcadeModule.js";import{ArcadeModuleLoader as t}from"./ArcadeModuleLoader.js";import{getGeometryKeys as o,geometryMember as l,getNestedOptionalValue as r}from"./containerUtils.js";import a from"./Dictionary.js";import{ArcadeExecutionError as s,ExecutionErrorCodes as i,ArcadeCompilationError as c,ArcadeUncompilableError as u}from"./executionError.js";import p from"./Feature.js";import{NativeFunction as m,ArcadeFunction as g,ScopeMarshalledFunction as d,wrapModuleScopedResponse as f}from"./FunctionWrapper.js";import{i as h,s as y,u as b,R as S,I as w,v,w as x,x as F,m as M,n as $,q as C,l as I,f as A,d as _,y as O,z as k,A as G}from"../chunks/languageUtils.js";import{addFunctionDeclaration as E}from"./treeAnalysis.js";import{A as j}from"../chunks/array.js";import{registerFunctions as B}from"./functions/date.js";import{registerFunctions as N}from"./functions/geometry.js";import{registerFunctions as R}from"./functions/geomsync.js";import{registerFunctions as D}from"./functions/maths.js";import{registerFunctions as L}from"./functions/stats.js";import{registerFunctions as U}from"./functions/string.js";import{isPromiseLike as K}from"../core/promiseUtils.js";import Z from"../geometry/Geometry.js";import P from"../geometry/SpatialReference.js";import{isGraphic as W,isNumber as T,isArray as V,isString as q,isBoolean as z}from"../support/guards.js";class J extends g{constructor(e,n){super(),this.paramCount=n,this.fn=e}createFunction(e){return(...n)=>{if(n.length!==this.paramCount)throw new s(e,i.WrongNumberOfParameters,null);return this.fn(...n)}}call(e,n){return this.fn(...n.arguments)}marshalledCall(e,n,t,o){return o(e,n,((n,l,r)=>{r=r.map((n=>!h(n)||n instanceof d?n:f(n,e,o)));const a=this.call(t,{arguments:r});return K(a)?a.then((e=>f(e,t,o))):a}))}}function Y(e,n){const t=[];for(let o=0;o<n.arguments.length;o++)t.push(Q(e,n.arguments[o]));return t}function H(e,n,t){try{return t(e,null,n.arguments)}catch(o){throw o}}function Q(e,n){switch(n.type){case"AssignmentExpression":return ce(e,n);case"UpdateExpression":return se(e,n);case"TemplateLiteral":return Me(e,n);case"Identifier":return Ie(e,n);case"MemberExpression":return ve(e,n);case"Literal":return null===n.value||void 0===n.value?"null":JSON.stringify(n.value);case"CallExpression":return Ae(e,n);case"UnaryExpression":return xe(e,n);case"BinaryExpression":return $e(e,n);case"LogicalExpression":return Ce(e,n);case"ArrayExpression":return Fe(e,n);case"ObjectExpression":return ee(e,n);default:throw new c(e,i.Unrecognized,n)}}function X(e,n){switch(n.type){case"EmptyStatement":return"lc.voidOperation";case"VariableDeclaration":return Se(e,n);case"BlockStatement":return ge(e,n);case"FunctionDeclaration":return be(e,n);case"ImportDeclaration":return fe(e,n);case"ExportNamedDeclaration":return he(e,n);case"ReturnStatement":return de(e,n);case"IfStatement":return me(e,n);case"ExpressionStatement":return ue(e,n);case"BreakStatement":return"break";case"ContinueStatement":return"continue";case"ForStatement":return ae(e,n);case"ForInStatement":return le(e,n);case"ForOfStatement":return re(e,n);case"WhileStatement":return ie(e,n);default:throw new c(e,i.Unrecognized,n)}}function ee(e,n){let t="lang.dictionary([";for(let o=0;o<n.properties.length;o++){const l=n.properties[o];let r;"Identifier"===l.key.type?(ye(l.key.name),r="'"+l.key.name+"'"):r=Q(e,l.key);o>0&&(t+=","),t+="lang.strCheck("+r+",'ObjectExpression'),lang.aCheck("+Q(e,l.value)+", 'ObjectExpression')"}return t+="])",t}function ne(e,n,t,o,l=(e,n)=>`${e} = ${n}`){const r=Be(e),a=Be(e);return[`var ${r} = ${t};`,`for (var ${a} = 0; ${a} < ${r}; ${a}++) {`,` ${l(n,a)}`,` ${X(e,o)}`,"}","lastStatement = lc.voidOperation;"].join("\n")}function te(e,n,t,o,l=e=>e){const r=Be(e),a=Be(e);return[`var ${r} = ${t};`,`for (var ${a} of ${r}) {`,` ${n} = ${l(a)};`,` ${X(e,o)}`,"}","lastStatement = lc.voidOperation;"].join("\n")}function oe(e,n,t,o){const l=Be(e);return[`var ${l} = ${t}.iterator(runtimeCtx.abortSignal);`,`while ((${n} = lang.graphicToFeature(yield ${l}.next(), ${t}, runtimeCtx)) != null) {`,` ${X(e,o)}`,"}","lastStatement = lc.voidOperation;"].join("\n")}function le(n,t){const o=Be(n);let l="var "+o+" = "+Q(n,t.right)+";\n";"VariableDeclaration"===t.left.type&&(l+=X(n,t.left));const r=e("VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);ye(r);let a="";null!==n.localScope&&(void 0!==n.localScope[r]?a="lscope['"+r+"']":void 0!==n.localScope._SymbolsMap[r]&&(a="lscope['"+n.localScope._SymbolsMap[r]+"']"));let s="";if(""===a)if(void 0!==n.globalScope[r])a="gscope['"+r+"']";else if(void 0!==n.globalScope._SymbolsMap[r])a="gscope['"+n.globalScope._SymbolsMap[r]+"']";else if(null!==n.localScope)if(n.undeclaredGlobalsInFunctions.has(r))a="gscope['"+n.undeclaredGlobalsInFunctions.get(r).manglename+"']",s=n.undeclaredGlobalsInFunctions.get(r).manglename;else{const e={manglename:je(n),node:t.left};n.undeclaredGlobalsInFunctions.set(r,e),a="gscope['"+e.manglename+"']",s=e.manglename}return s&&(l+="lang.chkAssig('"+s+"',runtimeCtx); \n"),l+="if ("+o+"===null) { lastStatement = lc.voidOperation; }\n ",l+="else if (lc.isArray("+o+") || lc.isString("+o+")) {\n",l+=ne(n,a,`${o}.length`,t.body),l+="}\n",l+="else if (lc.isImmutableArray("+o+")) {\n",l+=ne(n,a,`${o}.length()`,t.body),l+="}\n",l+="else if (( "+o+" instanceof lang.Dictionary) || lc.isFeature("+o+")) {\n",l+=te(n,a,`${o}.keys()`,t.body),l+="}\n",n.isAsync&&(l+="else if (lc.isFeatureSet("+o+")) {\n",l+=oe(n,a,o,t.body),l+="}\n"),l+=`else if (lc.isGeometry(${o})) {\n`,l+=te(n,a,`lang.getGeometryKeys(${o})`,t.body),l+="}\n",l+="else { lastStatement = lc.voidOperation; } \n",l}function re(n,t){const o=Be(n);let l="var "+o+" = "+Q(n,t.right)+";\n";"VariableDeclaration"===t.left.type&&(l+=X(n,t.left));const r=e("VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);ye(r);let a="";null!==n.localScope&&(void 0!==n.localScope[r]?a="lscope['"+r+"']":void 0!==n.localScope._SymbolsMap[r]&&(a="lscope['"+n.localScope._SymbolsMap[r]+"']"));let s="";if(""===a)if(void 0!==n.globalScope[r])a="gscope['"+r+"']";else if(void 0!==n.globalScope._SymbolsMap[r])a="gscope['"+n.globalScope._SymbolsMap[r]+"']";else if(null!==n.localScope)if(n.undeclaredGlobalsInFunctions.has(r))a="gscope['"+n.undeclaredGlobalsInFunctions.get(r).manglename+"']",s=n.undeclaredGlobalsInFunctions.get(r).manglename;else{const e={manglename:je(n),node:t.left};n.undeclaredGlobalsInFunctions.set(r,e),a="gscope['"+e.manglename+"']",s=e.manglename}return s&&(l+="lang.chkAssig('"+s+"',runtimeCtx); \n"),l+="if ("+o+"===null) { lastStatement = lc.voidOperation; }\n ",l+="else if (lc.isArray("+o+") || lc.isString("+o+")) {\n",l+=ne(n,a,`${o}.length`,t.body,((e,n)=>[`if (${n} >= ${o}.length) {`,` lang.error('${i.OutOfBounds}');`,"}",`${e} = ${o}[${n}];`].join("\n"))),l+="}\n",l+="else if (lc.isImmutableArray("+o+")) {\n",l+=ne(n,a,`${o}.length()`,t.body,((e,n)=>`${e} = ${o}.get(${n});`)),l+="}\n",l+="else if (( "+o+" instanceof lang.Dictionary) || lc.isFeature("+o+")) {\n",l+=te(n,a,`${o}.keys()`,t.body,(e=>`lang.entry(${e}, ${o}.field(${e}))`)),l+="}\n",n.isAsync&&(l+="else if (lc.isFeatureSet("+o+")) {\n",l+=oe(n,a,o,t.body),l+="}\n"),l+=`else if (lc.isGeometry(${o})) {\n`,l+=te(n,a,`lang.getGeometryKeys(${o})`,t.body,(e=>`lang.entry(${e}, lang.geometryMember(${o}, ${e}, runtimeCtx, null, 1))`)),l+="}\n",l+="else { lastStatement = lc.voidOperation; } \n",l}function ae(e,n){let t="lastStatement = lc.voidOperation; \n";null!==n.init&&("VariableDeclaration"===n.init.type?t+=X(e,n.init):t+=Q(e,n.init)+"; ");const o=Be(e),l=Be(e);return t+="var "+o+" = true; ",t+="\n do { ",null!==n.update&&(t+=" if ("+o+"===false) {\n "+Q(e,n.update)+" \n}\n "+o+"=false; \n"),null!==n.test&&(t+="var "+l+" = "+Q(e,n.test)+"; ",t+="if ("+l+"===false) { break; } else if ("+l+"!==true) { lang.error('"+i.BooleanConditionRequired+"'); }\n"),t+=X(e,n.body),null!==n.update&&(t+="\n "+Q(e,n.update)),t+="\n"+o+" = true; \n} while(true); lastStatement = lc.voidOperation; ",t}function se(n,t){if("CallExpression"===t.argument.type)throw new c(n,i.NeverReach,t);let o;if("MemberExpression"===t.argument.type){const e=Q(n,t.argument.object);return!0===t.argument.computed?o=Q(n,t.argument.property):(ye(t.argument.property.name),o="'"+t.argument.property.name+"'"),"lang.memberupdate("+e+","+o+",'"+t.operator+"',"+t.prefix+")"}const l=e(t.argument);if(ye(l),null!==n.localScope){if(void 0!==n.localScope[l])return"lang.update(lscope, '"+l+"','"+t.operator+"',"+t.prefix+")";if(void 0!==n.localScope._SymbolsMap[l])return"lang.update(lscope, '"+n.localScope._SymbolsMap[l]+"','"+t.operator+"',"+t.prefix+")"}if(void 0!==n.globalScope[l])return"lang.update(gscope, '"+l+"','"+t.operator+"',"+t.prefix+")";if(void 0!==n.globalScope._SymbolsMap[l])return"lang.update(gscope, '"+n.globalScope._SymbolsMap[l]+"','"+t.operator+"',"+t.prefix+")";if(null!==n.localScope){if(n.undeclaredGlobalsInFunctions.has(l))return"lang.update(gscope,lang.chkAssig( '"+n.undeclaredGlobalsInFunctions.get(l).manglename+"',runtimeCtx),'"+t.operator+"',"+t.prefix+")";const e={manglename:je(n),node:t.argument};return n.undeclaredGlobalsInFunctions.set(l,e),"lang.update(gscope, lang.chkAssig('"+e.manglename+"',runtimeCtx),'"+t.operator+"',"+t.prefix+")"}throw new s(n,i.InvalidIdentifier,t)}function ie(e,n){let t="lastStatement = lc.voidOperation; \n";const o=Be(e);return t+=`\n var ${o} = true;\n do {\n ${o} = ${Q(e,n.test)};\n if (${o}==false) {\n break;\n }\n if (${o}!==true) {\n lang.error('${i.BooleanConditionRequired}');\n }\n ${X(e,n.body)}\n }\n while (${o} !== false);\n lastStatement = lc.voidOperation;\n `,t}function ce(n,t){const o=Q(n,t.right);if("MemberExpression"===t.left.type){let e;const l=Q(n,t.left.object);return!0===t.left.computed?e=Q(n,t.left.property):(e="'"+t.left.property.name+"'",ye(t.left.property.name)),"lang.assignmember("+l+","+e+",'"+t.operator+"',"+o+")"}const l=e(t.left);if(ye(l),null!==n.localScope){if(void 0!==n.localScope[l])return"lscope['"+l+"']=lang.assign("+o+",'"+t.operator+"', lscope['"+l+"'])";if(void 0!==n.localScope._SymbolsMap[l])return"lscope['"+n.localScope._SymbolsMap[l]+"']=lang.assign("+o+",'"+t.operator+"', lscope['"+n.localScope._SymbolsMap[l]+"'])"}if(void 0!==n.globalScope[l])return"gscope['"+l+"']=lang.assign("+o+",'"+t.operator+"', gscope['"+l+"'])";if(void 0!==n.globalScope._SymbolsMap[l])return"gscope['"+n.globalScope._SymbolsMap[l]+"']=lang.assign("+o+",'"+t.operator+"', gscope['"+n.globalScope._SymbolsMap[l]+"'])";if(null!==n.localScope){if(n.undeclaredGlobalsInFunctions.has(l))return"gscope[lang.chkAssig('"+n.undeclaredGlobalsInFunctions.get(l).manglename+"',runtimeCtx)]=lang.assign("+o+",'"+t.operator+"', gscope['"+n.undeclaredGlobalsInFunctions.get(l).manglename+"'])";const e={manglename:je(n),node:t.left};return n.undeclaredGlobalsInFunctions.set(l,e),"gscope[lang.chkAssig('"+e.manglename+"',runtimeCtx)]=lang.assign("+o+",'"+t.operator+"', gscope['"+e.manglename+"'])"}throw new s(n,i.InvalidIdentifier,t)}function ue(e,n){return"AssignmentExpression"===n.expression.type?"lastStatement = lc.voidOperation; "+Q(e,n.expression)+"; \n ":"lastStatement = "+Q(e,n.expression)+"; "}function pe(e,n){return"BlockStatement"===n.type?X(e,n):"ReturnStatement"===n.type||"BreakStatement"===n.type||"ContinueStatement"===n.type?X(e,n)+"; ":"ExpressionStatement"===n.type?X(e,n):X(e,n)+"; "}function me(e,n){return`if (lang.mustBoolean(${Q(e,n.test)}, runtimeCtx) === true) {\n ${pe(e,n.consequent)}\n } `+(null!==n.alternate?"IfStatement"===n.alternate.type?" else "+me(e,n.alternate):` else {\n ${pe(e,n.alternate)}\n }\n`:" else {\n lastStatement = lc.voidOperation;\n }\n")}function ge(e,n){let t="";for(let o=0;o<n.body.length;o++)"EmptyStatement"!==n.body[o].type&&("ReturnStatement"===n.body[o].type||"BreakStatement"===n.body[o].type||"ContinueStatement"===n.body[o].type?t+=X(e,n.body[o])+"; \n":t+=X(e,n.body[o])+" \n");return t}function de(e,n){if(null===n.argument)return"return lc.voidOperation";return"return "+Q(e,n.argument)}function fe(n,t){const o=e(t.specifiers[0].local);ye(o);const l=n.libraryResolver?.loadLibrary(o),r=je(n);void 0===n.moduleFactory[l.uri]&&(n.moduleFactory[l.uri]=He(l.syntax,{interceptor:n.interceptor,services:n.services,moduleFactory:n.moduleFactory,lrucache:n.lrucache,timeZone:n.timeZone??null,libraryResolver:n.libraryResolver,customfunctions:n.customfunctions,vars:{}},n.isAsync)),n.moduleFactoryMap[r]=l.uri;let a,s="";return s=n.isAsync?"(yield lang.loadModule('"+r+"', runtimeCtx) ); ":"lang.loadModule('"+r+"', runtimeCtx); ",void 0!==n.globalScope[o]?"gscope['"+o+"']="+s:void 0!==n.globalScope._SymbolsMap[o]?"gscope['"+n.globalScope._SymbolsMap[o]+"']="+s:(n.undeclaredGlobalsInFunctions.has(o)?(a=n.undeclaredGlobalsInFunctions.get(o).manglename,n.undeclaredGlobalsInFunctions.delete(o)):a=je(n),n.globalScope._SymbolsMap[o]=a,n.mangleMap[o]=a,"gscope[lang.setAssig('"+a+"', runtimeCtx)]="+s)}function he(n,t){const o=X(n,t.declaration);if("FunctionDeclaration"===t.declaration.type)n.exports[e(t.declaration.id)]="function";else if("VariableDeclaration"===t.declaration.type)for(const l of t.declaration.declarations)n.exports[e(l.id)]="variable";return o}function ye(e){if("iif"===e)throw new u;if("decode"===e)throw new u;if("when"===e)throw new u;if("defaultvalue"===e)throw new u}function be(n,t){const o=e(t.id);let l;ye(o);let r=!1;void 0!==n.globalScope[o]?l=o:void 0!==n.globalScope._SymbolsMap[o]?l=n.globalScope._SymbolsMap[o]:n.undeclaredGlobalsInFunctions.has(o)?(l=n.undeclaredGlobalsInFunctions.get(o).manglename,n.globalScope._SymbolsMap[o]=l,n.mangleMap[o]=l,n.undeclaredGlobalsInFunctions.delete(o),r=!0):(l=je(n),n.globalScope._SymbolsMap[o]=l,n.mangleMap[o]=l);const a={isAsync:n.isAsync,console:n.console,exports:n.exports,undeclaredGlobalsInFunctions:n.undeclaredGlobalsInFunctions,customfunctions:n.customfunctions,moduleFactory:n.moduleFactory,moduleFactoryMap:n.moduleFactoryMap,libraryResolver:n.libraryResolver,lrucache:n.lrucache,interceptor:n.interceptor,services:n.services,symbols:n.symbols,mangleMap:n.mangleMap,localScope:{_SymbolsMap:{}},depthCounter:n.depthCounter,globalScope:n.globalScope};let s="new lang.UserDefinedCompiledFunction( lang.functionDepthchecker(function() { var lastStatement = lc.voidOperation; \n var lscope = runtimeCtx.localStack[runtimeCtx.localStack.length-1];\n";for(let i=0;i<t.params.length;i++){const o=e(t.params[i]);ye(o);const l=je(n);a.localScope._SymbolsMap[o]=l,a.mangleMap[o]=l,s+="lscope['"+l+"']=arguments["+i.toString()+"];\n"}return!0===n.isAsync?(s+="return lang.__awaiter(this, void 0, void 0, function* () {\n",s+=ge(a,t.body)+"\n return lastStatement; ",s+="}); }",s+=", runtimeCtx),"+t.params.length+")",s+="\n lastStatement = lc.voidOperation; \n"):(s+=ge(a,t.body)+"\n return lastStatement; }, runtimeCtx),"+t.params.length+")",s+="\n lastStatement = lc.voidOperation; \n"),r?"gscope[lang.setAssig('"+l+"', runtimeCtx)]="+s:"gscope['"+l+"']="+s}function Se(e,n){const t=[];for(let o=0;o<n.declarations.length;o++)t.push(we(e,n.declarations[o]));return t.join("\n")+" \n lastStatement= lc.voidOperation; \n"}function we(n,t){const o=null===t.init?null:Q(n,t.init),l=e(t.id);if(ye(l),null!==n.localScope){if(void 0!==n.localScope[l])return"lscope['"+l+"']="+o+"; ";if(void 0!==n.localScope._SymbolsMap[l])return"lscope['"+n.localScope._SymbolsMap[l]+"']="+o+"; ";const e=je(n);return n.localScope._SymbolsMap[l]=e,n.mangleMap[l]=e,"lscope['"+e+"']="+o+"; "}if(void 0!==n.globalScope[l])return"gscope['"+l+"']="+o+"; ";if(void 0!==n.globalScope._SymbolsMap[l])return"gscope['"+n.globalScope._SymbolsMap[l]+"']="+o+"; ";if(n.undeclaredGlobalsInFunctions.has(l)){const e=n.undeclaredGlobalsInFunctions.get(l).manglename;return n.globalScope._SymbolsMap[l]=e,n.mangleMap[l]=e,n.undeclaredGlobalsInFunctions.delete(l),"gscope[lang.setAssig('"+e+"', runtimeCtx)]="+o+"; "}const r=je(n);return n.globalScope._SymbolsMap[l]=r,n.mangleMap[l]=r,"gscope['"+r+"']="+o+"; "}function ve(e,n){try{let t;return!0===n.computed?t=Q(e,n.property):(ye(n.property.name),t="'"+n.property.name+"'"),"lang.member("+Q(e,n.object)+","+t+")"}catch(t){throw t}}function xe(e,n){try{return"lang.unary("+Q(e,n.argument)+",'"+n.operator+"')"}catch(t){throw t}}function Fe(e,n){try{const t=[];for(let o=0;o<n.elements.length;o++)"Literal"===n.elements[o].type?t.push(Q(e,n.elements[o])):t.push("lang.aCheck("+Q(e,n.elements[o])+",'ArrayExpression')");return"["+t.join(",")+"]"}catch(t){throw t}}function Me(e,n){try{const t=[];let o=0;for(const l of n.quasis)t.push(l.value?JSON.stringify(l.value.cooked):JSON.stringify("")),!1===l.tail&&(t.push(n.expressions[o]?"lang.castString(lang.aCheck("+Q(e,n.expressions[o])+", 'TemplateLiteral'))":""),o++);return"(["+t.join(",")+"]).join('')"}catch(t){throw t}}function $e(e,n){try{return"lang.binary("+Q(e,n.left)+","+Q(e,n.right)+",'"+n.operator+"')"}catch(t){throw t}}function Ce(e,n){try{if("AssignmentExpression"===n.left.type||"UpdateExpression"===n.left.type)throw new c(e,i.LogicalExpressionOnlyBoolean,n);if("AssignmentExpression"===n.right.type||"UpdateExpression"===n.right.type)throw new c(e,i.LogicalExpressionOnlyBoolean,n);if("&&"===n.operator||"||"===n.operator)return"(lang.logicalCheck("+Q(e,n.left)+") "+n.operator+" lang.logicalCheck("+Q(e,n.right)+"))";throw new c(null,i.LogicExpressionOrAnd,null)}catch(t){throw t}}function Ie(n,t){try{const o=e(t);if(ye(o),null!==n.localScope){if(void 0!==n.localScope[o])return"lscope['"+o+"']";if(void 0!==n.localScope._SymbolsMap[o])return"lscope['"+n.localScope._SymbolsMap[o]+"']"}if(void 0!==n.globalScope[o])return"gscope['"+o+"']";if(void 0!==n.globalScope._SymbolsMap[o])return"gscope['"+n.globalScope._SymbolsMap[o]+"']";if(null!==n.localScope){if(n.undeclaredGlobalsInFunctions.has(o))return"gscope[lang.chkAssig('"+n.undeclaredGlobalsInFunctions.get(o).manglename+"',runtimeCtx)]";const e={manglename:je(n),node:t};return n.undeclaredGlobalsInFunctions.set(o,e),"gscope[lang.chkAssig('"+e.manglename+"',runtimeCtx)]"}throw new c(n,i.InvalidIdentifier,t)}catch(o){throw o}}function Ae(n,t){try{if("MemberExpression"===t.callee.type){let e;!0===t.callee.computed?e=Q(n,t.callee.property):(ye(t.callee.property.name),e="'"+t.callee.property.name+"'");let o="[";for(let l=0;l<t.arguments.length;l++)l>0&&(o+=", "),o+=Q(n,t.arguments[l]);return o+="]",n.isAsync?"(yield lang.callModuleFunction("+Q(n,t.callee.object)+","+o+","+e+",runtimeCtx))":"lang.callModuleFunction("+Q(n,t.callee.object)+","+o+","+e+",runtimeCtx)"}if("Identifier"!==t.callee.type)throw new c(n,i.FunctionNotFound,t);const o=e(t.callee);if("iif"===o)return _e(n,t);if("when"===o)return ke(n,t);if("defaultvalue"===o)return Oe(n,t);if("decode"===o)return Ge(n,t);let l="";if(null!==n.localScope&&(void 0!==n.localScope[o]?l="lscope['"+o+"']":void 0!==n.localScope._SymbolsMap[o]&&(l="lscope['"+n.localScope._SymbolsMap[o]+"']")),""===l)if(void 0!==n.globalScope[o])l="gscope['"+o+"']";else if(void 0!==n.globalScope._SymbolsMap[o])l="gscope['"+n.globalScope._SymbolsMap[o]+"']";else if(null!==n.localScope)if(n.undeclaredGlobalsInFunctions.has(o))l="gscope[lang.chkAssig('"+n.undeclaredGlobalsInFunctions.get(o).manglename+"',runtimeCtx)]";else{const e={manglename:je(n),node:t.callee};n.undeclaredGlobalsInFunctions.set(o,e),l="gscope[lang.chkAssig('"+e.manglename+"',runtimeCtx)]"}if(""!==l){let e="[";for(let o=0;o<t.arguments.length;o++)o>0&&(e+=", "),e+=Q(n,t.arguments[o]);return e+="]",n.isAsync?"(yield lang.callfunc("+l+","+e+",runtimeCtx) )":"lang.callfunc("+l+","+e+",runtimeCtx)"}throw new c(n,i.FunctionNotFound,t)}catch(o){throw o}}function _e(e,n){try{if(3!==n.arguments.length)throw new c(e,i.WrongNumberOfParameters,n);const t=Be(e);return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${Q(e,n.arguments[0])};\n\n if (${t} === true) {\n return ${Q(e,n.arguments[1])};\n }\n else if (${t} === false) {\n return ${Q(e,n.arguments[2])};\n }\n else {\n lang.error('ExecutionErrorCodes.BooleanConditionRequired');\n }\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Oe(e,n){try{if(n.arguments.length<2||n.arguments.length>3)throw new c(e,i.WrongNumberOfParameters,n);const t=Be(e),o=Be(e);return 3===n.arguments.length?`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${Q(e,n.arguments[0])};\n var ${o} = ${Q(e,n.arguments[1])};\n ${t} = lang.getNestedOptionalValue(${t}, ${o});\n return ${t} != null && ${t} !== "" ? ${t} : ${Q(e,n.arguments[2])};\n ${e.isAsync?"})}()))":"}()"}`:`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${Q(e,n.arguments[0])};\n if (${t} === null) {\n return ${Q(e,n.arguments[1])};\n }\n if (${t} === "") {\n return ${Q(e,n.arguments[1])};\n }\n if (${t} === undefined) {\n return ${Q(e,n.arguments[1])};\n }\n return ${t};\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function ke(e,n){try{if(n.arguments.length<3)throw new c(e,i.WrongNumberOfParameters,n);if(n.arguments.length%2==0)throw new c(e,i.WrongNumberOfParameters,n);const t=Be(e);let o="var ";for(let l=0;l<n.arguments.length-1;l+=2)o+=`${t} = lang.mustBoolean(${Q(e,n.arguments[l])}, runtimeCtx);\n if (${t} === true ) {\n return ${Q(e,n.arguments[l+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n ${o}\n return ${Q(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Ge(e,n){try{if(n.arguments.length<2)throw new c(e,i.WrongNumberOfParameters,n);if(2===n.arguments.length)return`(${Q(e,n.arguments[1])})`;if((n.arguments.length-1)%2==0)throw new c(e,i.WrongNumberOfParameters,n);const t=Be(e),o=Be(e);let l="var ";for(let r=1;r<n.arguments.length-1;r+=2)l+=`${o} = ${Q(e,n.arguments[r])};\n if (lang.binary(${o}, ${t}, "==") === true ) {\n return ${Q(e,n.arguments[r+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${Q(e,n.arguments[0])};\n ${l}\n return ${Q(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}const Ee={};function je(e){return e.symbols.symbolCounter++,`_T${e.symbols.symbolCounter}`}function Be(e){return e.symbols.symbolCounter++,`_Tvar${e.symbols.symbolCounter}`}B(Ee,H),U(Ee,H),D(Ee,H),N(Ee,H),L(Ee,H),Ee.iif=function(e,n){try{return H(e,n,((t,o,l)=>{throw new s(e,i.Unrecognized,n)}))}catch(t){throw t}},Ee.decode=function(e,n){try{return H(e,n,((t,o,l)=>{throw new s(e,i.Unrecognized,n)}))}catch(t){throw t}},Ee.when=function(e,n){try{return H(e,n,((t,o,l)=>{throw new s(e,i.Unrecognized,n)}))}catch(t){throw t}},Ee.defaultvalue=function(e,n){try{return H(e,n,((t,o,l)=>{throw new s(e,i.Unrecognized,n)}))}catch(t){throw t}};const Ne={};for(const Qe in Ee)Ne[Qe]=new m(Ee[Qe]);R(Ee,H);for(const Qe in Ee)Ee[Qe]=new m(Ee[Qe]);const Re=function(){};Re.prototype=Ee;const De=function(){};function Le(e,n,t){const o={_SymbolsMap:{}};e||(e={}),t||(t={}),o.textformatting=1,o.infinity=1,o.pi=1;for(const l in n)o[l]=1;for(const l in t)o[l]=1;for(const l in e)o[l]=1;return o}function Ue(e,n,t,o){const l=t?new De:new Re;e||(e={}),n||(n={});const r=new a({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});r.immutable=!1,l._SymbolsMap={textformatting:1,infinity:1,pi:1},l.textformatting=r,l.infinity=Number.POSITIVE_INFINITY,l.pi=Math.PI;for(const a in n)l[a]=n[a],l._SymbolsMap[a]=1;for(const a in e){const n=e[a];l._SymbolsMap[a]=1,W(n)?l[a]=p.createFromGraphic(n,o??null):l[a]=n}return l}De.prototype=Ne;const Ke={fixSpatialReference:y,parseArguments:Y,standardFunction:H};function Ze(e,n){const t={mode:n,compiled:!0,functions:{},signatures:[],standardFunction:H,standardFunctionAsync:H,evaluateIdentifier:We};for(let o=0;o<e.length;o++)e[o].registerFunctions(t);if("sync"===n){for(const e in t.functions)Ee[e]=new m(t.functions[e]),Re.prototype[e]=Ee[e];for(let e=0;e<t.signatures.length;e++)E(t.signatures[e],"sync")}else{for(const e in t.functions)Ne[e]=new m(t.functions[e]),De.prototype[e]=Ne[e];for(let e=0;e<t.signatures.length;e++)E(t.signatures[e],"async")}}function Pe(e,n){return e(n)}function We(e,n){const t=n.name;if("_SymbolsMap"===t)throw new s(e,i.InvalidIdentifier,null);if(e.localStack.length>0){const n=e.localStack[e.localStack.length-1];if(!t.toLowerCase().startsWith("_t")&&void 0!==n[t])return n[t];const o=e.mangleMap[t];if(void 0!==o&&void 0!==n[o])return n[o]}if(!t.toLowerCase().startsWith("_t")&&void 0!==e.globalScope[t])return e.globalScope[t];if(1===e.globalScope._SymbolsMap[t])return e.globalScope[t];const o=e.mangleMap[t];return void 0!==o?e.globalScope[o]:void 0}Ze([j],"sync"),Ze([j],"async");let Te=0;const Ve={isNumber:e=>T(e),isArray:e=>V(e),isImmutableArray:e=>M(e),isFeature:e=>$(e),isString:e=>q(e),isDictionary:e=>C(e),isGeometry:e=>I(e),getGeometryKeys:e=>o(e),geometryMember:(e,n,t,o,r=1)=>l(e,n,t,o,r),error(e){throw new s(null,e,null)},__awaiter:(e,n,t,o)=>new Promise(((t,l)=>{function r(e){try{s(o.next(e))}catch(n){l(n)}}function a(e){try{s(o.throw(e))}catch(n){l(n)}}function s(e){e.done?t(e.value):e.value?.then?e.value.then(r,a):(Te++,Te%100==0?setTimeout((()=>{Te=0,r(e.value)}),0):r(e.value))}s((o=o.apply(e,n||[])).next())})),functionDepthchecker:(e,n)=>function(){if(n.depthCounter.depth++,n.localStack.push({}),n.depthCounter.depth>64)throw new s(null,i.MaximumCallDepth,null);const t=e.apply(this,arguments);return K(t)?t.then((e=>(n.depthCounter.depth--,n.localStack.length=n.localStack.length-1,e))):(n.depthCounter.depth--,n.localStack.length=n.localStack.length-1,t)},chkAssig(e,n){if(void 0===n.gdefs[e])throw new s(n,i.InvalidIdentifier,null);return e},mustBoolean(e,n){if(!0===e||!1===e)return e;throw new s(n,i.BooleanConditionRequired,null)},setAssig:(e,n)=>(n.gdefs[e]=1,e),castString:e=>A(e),aCheck(e,n){if(h(e)){if("ArrayExpression"===n)throw new s(null,i.NoFunctionInArray,null);if("ObjectExpression"===n)throw new s(null,i.NoFunctionInDictionary,null);throw new s(null,i.NoFunctionInTemplateLiteral,null)}return e===v?null:e},Dictionary:a,Feature:p,UserDefinedCompiledFunction:J,dictionary(e){const n={},t=new Map;for(let l=0;l<e.length;l+=2){if(h(e[l+1]))throw new s(null,i.NoFunctionInDictionary,null);if(!1===q(e[l]))throw new s(null,i.KeyMustBeString,null);let o=e[l].toString();const r=o.toLowerCase();t.has(r)?o=t.get(r):t.set(r,o),e[l+1]===v?n[o]=null:n[o]=e[l+1]}const o=new a(n);return o.immutable=!1,o},entry:(e,n)=>new a({key:e,value:n}),strCheck(e){if(!1===q(e))throw new s(null,i.KeyMustBeString,null);return e},unary(e,n){if(z(e)){if("!"===n)return!e;if("-"===n)return-1*_(e);if("+"===n)return 1*_(e);if("~"===n)return~_(e);throw new s(null,i.UnsupportedUnaryOperator,null)}if("-"===n)return-1*_(e);if("+"===n)return 1*_(e);if("~"===n)return~_(e);throw new s(null,i.UnsupportedUnaryOperator,null)},logicalCheck(e){if(!1===z(e))throw new s(null,i.LogicExpressionOrAnd,null);return e},logical(e,n,t){if(z(e)&&z(n))switch(t){case"||":return e||n;case"&&":return e&&n;default:throw new s(null,i.LogicExpressionOrAnd,null)}throw new s(null,i.LogicExpressionOrAnd,null)},binary(e,n,t){switch(t){case"|":case"<<":case">>":case">>>":case"^":case"&":return G(_(e),_(n),t);case"==":case"=":return k(e,n);case"!=":return!k(e,n);case"<":case">":case"<=":case">=":return O(e,n,t);case"+":return q(e)||q(n)?A(e)+A(n):_(e)+_(n);case"-":return _(e)-_(n);case"*":return _(e)*_(n);case"/":return _(e)/_(n);case"%":return _(e)%_(n);default:throw new s(null,i.UnsupportedOperator,null)}},assign(e,n,t){switch(n){case"=":return e===v?null:e;case"/=":return _(t)/_(e);case"*=":return _(t)*_(e);case"-=":return _(t)-_(e);case"+=":return q(t)||q(e)?A(t)+A(e):_(t)+_(e);case"%=":return _(t)%_(e);default:throw new s(null,i.UnsupportedOperator,null)}},update(e,n,t,o){const l=_(e[n]);return e[n]="++"===t?l+1:l-1,!1===o?l:"++"===t?l+1:l-1},graphicToFeature:(e,n,t)=>null===e?null:p.createFromGraphicLikeObject(e.geometry,e.attributes,n,t.timeZone),memberupdate(e,n,t,o){let l;if(V(e)){if(!T(n))throw new s(null,i.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>=e.length)throw new s(null,i.OutOfBounds,null);l=_(e[n]),e[n]="++"===t?l+1:l-1}else if(e instanceof a){if(!1===q(n))throw new s(null,i.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new s(null,i.FieldNotFound,null,{key:n});l=_(e.field(n)),e.setField(n,"++"===t?l+1:l-1)}else if($(e)){if(!1===q(n))throw new s(null,i.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new s(null,i.FieldNotFound,null);l=_(e.field(n)),e.setField(n,"++"===t?l+1:l-1)}else{if(M(e))throw new s(null,i.Immutable,null);if(!(e instanceof Ye))throw new s(null,i.InvalidIdentifier,null);if(!1===q(n))throw new s(null,i.ModuleAccessorMustBeString,null);if(!0!==e.hasGlobal(n))throw new s(null,i.ModuleExportNotFound,null);l=_(e.global(n)),e.setGlobal(n,"++"===t?l+1:l-1)}return!1===o?l:"++"===t?l+1:l-1},assignmember(e,n,t,o){if(V(e)){if(!T(n))throw new s(null,i.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>e.length)throw new s(null,i.OutOfBounds,null);if(n===e.length){if("="!==t)throw new s(null,i.OutOfBounds,null);e[n]=this.assign(o,t,e[n])}else e[n]=this.assign(o,t,e[n])}else if(e instanceof a){if(!1===q(n))throw new s(null,i.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(o,t,e.field(n)));else{if("="!==t)throw new s(null,i.FieldNotFound,null);e.setField(n,this.assign(o,t,null))}}else if($(e)){if(!1===q(n))throw new s(null,i.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(o,t,e.field(n)));else{if("="!==t)throw new s(null,i.FieldNotFound,null);e.setField(n,this.assign(o,t,null))}}else{if(M(e))throw new s(null,i.Immutable,null);if(!(e instanceof Ye))throw new s(null,i.InvalidIdentifier,null);if(!1===q(n))throw new s(null,i.ModuleAccessorMustBeString,null);if(!e.hasGlobal(n))throw new s(null,i.ModuleExportNotFound,null);e.setGlobal(n,this.assign(o,t,e.global(n)))}},member(e,n){if(null===e)throw new s(null,i.MemberOfNull,null);if(e instanceof a||$(e)){if(q(n))return e.field(n);throw new s(null,i.InvalidMemberAccessKey,null)}if(e instanceof Z){if(q(n))return l(e,n,null,null);throw new s(null,i.InvalidMemberAccessKey,null)}if(V(e)){if(T(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new s(null,i.OutOfBounds,null);return e[n]}throw new s(null,i.InvalidMemberAccessKey,null)}if(q(e)){if(T(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new s(null,i.OutOfBounds,null);return e[n]}throw new s(null,i.InvalidMemberAccessKey,null)}if(M(e)){if(T(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length()+n),n>=e.length()||n<0)throw new s(null,i.OutOfBounds,null);return e.get(n)}throw new s(null,i.InvalidMemberAccessKey,null)}if(e instanceof Ye){if(q(n))return e.global(n);throw new s(null,i.InvalidMemberAccessKey,null)}throw new s(null,i.InvalidMemberAccessKey,null)},callfunc:(e,n,t)=>e.call(t,{arguments:n,preparsed:!0}),loadModule(e,n){const t=n.moduleFactoryMap[e];if(n.moduleSingletons[t])return n.moduleSingletons[t];const o=n.moduleFactory[t]({vars:{},moduleSingletons:n.moduleSingletons,depthCounter:n.depthCounter,console:n.console,abortSignal:n.abortSignal,isAsync:n.isAsync,services:n.services,lrucache:n.lrucache,timeZone:n.timeZone??null,interceptor:n.interceptor},n.spatialReference);return n.moduleSingletons[t]=o,o},callModuleFunction(e,n,t,o){if(!(e instanceof Ye))throw new s(null,i.FunctionNotFound,null);const l=e.global(t);if(!1===h(l))throw new s(null,i.CallNonFunction,null);return l.call(o,{preparsed:!0,arguments:n})},getNestedOptionalValue:(e,n)=>r(e,n)};function qe(e){console.log(e)}function ze(e,n,o=!1){null===n&&(n={vars:{},customfunctions:{}});let l=null;e.usesModules&&(l=new t(null,e.loadedModules));const r={isAsync:o,globalScope:Le(n.vars,o?Ne:Ee,n.customfunctions),moduleFactory:{},moduleFactoryMap:{},undeclaredGlobalsInFunctions:new Map,customfunctions:n.customfunctions,libraryResolver:l,localScope:null,mangleMap:{},depthCounter:{depth:1},exports:{},console:qe,lrucache:n.lrucache,timeZone:n.timeZone??null,interceptor:n.interceptor,services:n.services,symbols:{symbolCounter:0}};let a=ge(r,e);""===a&&(a="lc.voidOperation; "),r.undeclaredGlobalsInFunctions.size>0&&r.undeclaredGlobalsInFunctions.forEach((e=>{throw new c(n,i.InvalidIdentifier,e.node)}));let u="";u=o?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+a+"\n return lastStatement; }); } \n return this.postProcess(yield mainBody()); }); ":"var runtimeCtx=this.prepare(context, false);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \n function mainBody() {\n var lastStatement=lc.voidOperation;\n "+a+"\n return lastStatement; } \n return this.postProcess(mainBody()); ";const p=r.moduleFactory,m=r.moduleFactoryMap,g=r.exports,d={};let f;for(f in g)d[f]=r.mangleMap[f]??f;const y={lc:b,lang:Ve,mangles:r.mangleMap,postProcess(e){if(e instanceof S&&(e=e.value),e instanceof w&&(e=e.value),e===v&&(e=null),e===x)throw new s(null,i.IllegalResult,null);if(e===F)throw new s(null,i.IllegalResult,null);if(h(e))throw new s(null,i.IllegalResult,null);return e},prepare(e,n){let t=e.spatialReference;null==t&&(t=P.WebMercator);const o=Ue(e.vars,e.customfunctions,n,e.timeZone);return{localStack:[],isAsync:n,moduleFactory:p,moduleFactoryMap:m,mangleMap:this.mangles,moduleSingletons:{},exports:g,gdefs:{},exportmangle:d,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??qe,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:{depth:1}}}};return new Function("context","spatialReference",u).bind(y)}async function Je(){return Ze([await import("./functions/geomasync.js")],"async"),!0}class Ye extends n{constructor(e){super(),this.moduleContext=e}hasGlobal(e){return void 0===this.moduleContext.exports[e]&&(e=e.toLowerCase()),void 0!==this.moduleContext.exports[e]}setGlobal(e,n){const t=this.moduleContext.globalScope,o=e.toLowerCase();if(h(n))throw new s(null,i.AssignModuleFunction,null);t[this.moduleContext.exportmangle[o]]=n}global(e){const n=this.moduleContext.globalScope,t=e.toLowerCase(),o=n[this.moduleContext.exportmangle[t]];if(void 0===o)throw new s(null,i.InvalidIdentifier,null);if(h(o)&&!(o instanceof d)){const e=new d;return e.fn=o,e.parameterEvaluator=H,e.context=this.moduleContext,n[this.moduleContext.exportmangle[t]]=e,e}return o}}function He(e,n,o=!1){const l={isAsync:o,moduleFactory:n.moduleFactory,moduleFactoryMap:{},libraryResolver:new t(null,e.loadedModules),globalScope:Le(n.vars,o?Ne:Ee,n.customfunctions),customfunctions:n.customfunctions,localScope:null,mangleMap:{},undeclaredGlobalsInFunctions:new Map,depthCounter:{depth:1},exports:{},console:qe,lrucache:n.lrucache,timeZone:n.timeZone??null,interceptor:n.interceptor,services:n.services,symbols:{symbolCounter:0}};let r=ge(l,e);""===r&&(r="lc.voidOperation; ");let a="";a=o?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+r+"\n return lastStatement; }); } \n yield mainBody(); \n return this.prepareModule(runtimeCtx); }); ":"var runtimeCtx=this.prepare(context, false);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \n function mainBody() {\n var lastStatement=lc.voidOperation;\n "+r+"\n return lastStatement; } \n mainBody(); \n return this.prepareModule(runtimeCtx); ";const s=l.moduleFactory,i=l.moduleFactoryMap,c=l.exports,u={};let p;for(p in c)u[p]=l.mangleMap[p]??p;const m={lc:b,lang:Ve,mangles:l.mangleMap,prepareModule:e=>new Ye(e),prepare(e,n){let t=e.spatialReference;null==t&&(t=new P({wkid:102100}));const o=Ue(e.vars,e.customfunctions,n,e.timeZone);return{localStack:[],isAsync:n,exports:c,exportmangle:u,gdefs:{},moduleFactory:s,moduleFactoryMap:i,moduleSingletons:e.moduleSingletons,mangleMap:this.mangles,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??qe,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:e.depthCounter}}};return new Function("context","spatialReference",a).bind(m)}export{J as UserDefinedCompiledFunction,ze as compileScript,Je as enableAsyncSupport,Pe as executeScript,Ze as extend,Ke as functionHelper};
5
+ import{toSymbolId as e}from"./arcadeEnvironment.js";import{ArcadeModule as n}from"./ArcadeModule.js";import{ArcadeModuleLoader as t}from"./ArcadeModuleLoader.js";import{getGeometryKeys as o,geometryMember as l,getNestedOptionalValue as r}from"./containerUtils.js";import a from"./Dictionary.js";import{ArcadeExecutionError as s,ExecutionErrorCodes as i,ArcadeCompilationError as c,ArcadeUncompilableError as u}from"./executionError.js";import p from"./Feature.js";import{NativeFunction as m,ArcadeFunction as g,ScopeMarshalledFunction as d,wrapModuleScopedResponse as f}from"./FunctionWrapper.js";import{i as h,u as y,v as b,R as S,I as w,w as v,x,y as M,m as F,z as $,q as C,l as I,f as A,t as _,A as O,B as k,C as G,n as E}from"../chunks/languageUtils.js";import{addFunctionDeclaration as B}from"./treeAnalysis.js";import{A as j}from"../chunks/array.js";import{registerFunctions as N}from"./functions/date.js";import{registerFunctions as R}from"./functions/geometry.js";import{registerFunctions as D}from"./functions/geomsync.js";import{registerFunctions as L}from"./functions/maths.js";import{registerFunctions as U}from"./functions/stats.js";import{registerFunctions as K}from"./functions/string.js";import{isPromiseLike as Z}from"../core/promiseUtils.js";import P from"../geometry/Geometry.js";import W from"../geometry/SpatialReference.js";import{isGraphic as T,isNumber as V,isArray as q,isString as z,isBoolean as J}from"../support/guards.js";class Y extends g{constructor(e,n){super(),this.paramCount=n,this.fn=e}createFunction(e){return(...n)=>{if(n.length!==this.paramCount)throw new s(e,i.WrongNumberOfParameters,null);return this.fn(...n)}}call(e,n){return this.fn(...n.arguments)}marshalledCall(e,n,t,o){return o(e,n,((n,l,r)=>{r=r.map((n=>!h(n)||n instanceof d?n:f(n,e,o)));const a=this.call(t,{arguments:r});return Z(a)?a.then((e=>f(e,t,o))):a}))}}function H(e,n){const t=[];for(let o=0;o<n.arguments.length;o++)t.push(X(e,n.arguments[o]));return t}function Q(e,n,t){try{return t(e,null,n.arguments)}catch(o){throw o}}function X(e,n){switch(n.type){case"AssignmentExpression":return ue(e,n);case"UpdateExpression":return ie(e,n);case"TemplateLiteral":return $e(e,n);case"Identifier":return Ae(e,n);case"MemberExpression":return xe(e,n);case"Literal":return null===n.value||void 0===n.value?"null":JSON.stringify(n.value);case"CallExpression":return _e(e,n);case"UnaryExpression":return Me(e,n);case"BinaryExpression":return Ce(e,n);case"LogicalExpression":return Ie(e,n);case"ArrayExpression":return Fe(e,n);case"ObjectExpression":return ne(e,n);default:throw new c(e,i.Unrecognized,n)}}function ee(e,n){switch(n.type){case"EmptyStatement":return"lc.voidOperation";case"VariableDeclaration":return we(e,n);case"BlockStatement":return de(e,n);case"FunctionDeclaration":return Se(e,n);case"ImportDeclaration":return he(e,n);case"ExportNamedDeclaration":return ye(e,n);case"ReturnStatement":return fe(e,n);case"IfStatement":return ge(e,n);case"ExpressionStatement":return pe(e,n);case"BreakStatement":return"break";case"ContinueStatement":return"continue";case"ForStatement":return se(e,n);case"ForInStatement":return re(e,n);case"ForOfStatement":return ae(e,n);case"WhileStatement":return ce(e,n);default:throw new c(e,i.Unrecognized,n)}}function ne(e,n){let t="lang.dictionary([";for(let o=0;o<n.properties.length;o++){const l=n.properties[o];let r;"Identifier"===l.key.type?(be(l.key.name),r="'"+l.key.name+"'"):r=X(e,l.key);o>0&&(t+=","),t+="lang.strCheck("+r+",'ObjectExpression'),lang.aCheck("+X(e,l.value)+", 'ObjectExpression')"}return t+="])",t}function te(e,n,t,o,l=(e,n)=>`${e} = ${n}`){const r=Ne(e),a=Ne(e);return[`var ${r} = ${t};`,`for (var ${a} = 0; ${a} < ${r}; ${a}++) {`,` ${l(n,a)}`,` ${ee(e,o)}`,"}","lastStatement = lc.voidOperation;"].join("\n")}function oe(e,n,t,o,l=e=>e){const r=Ne(e),a=Ne(e);return[`var ${r} = ${t};`,`for (var ${a} of ${r}) {`,` ${n} = ${l(a)};`,` ${ee(e,o)}`,"}","lastStatement = lc.voidOperation;"].join("\n")}function le(e,n,t,o){const l=Ne(e);return[`var ${l} = ${t}.iterator(runtimeCtx.abortSignal);`,`while ((${n} = lang.graphicToFeature(yield ${l}.next(), ${t}, runtimeCtx)) != null) {`,` ${ee(e,o)}`,"}","lastStatement = lc.voidOperation;"].join("\n")}function re(n,t){const o=Ne(n);let l="var "+o+" = "+X(n,t.right)+";\n";"VariableDeclaration"===t.left.type&&(l+=ee(n,t.left));const r=e("VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);be(r);let a="";null!==n.localScope&&(void 0!==n.localScope[r]?a="lscope['"+r+"']":void 0!==n.localScope._SymbolsMap[r]&&(a="lscope['"+n.localScope._SymbolsMap[r]+"']"));let s="";if(""===a)if(void 0!==n.globalScope[r])a="gscope['"+r+"']";else if(void 0!==n.globalScope._SymbolsMap[r])a="gscope['"+n.globalScope._SymbolsMap[r]+"']";else if(null!==n.localScope)if(n.undeclaredGlobalsInFunctions.has(r))a="gscope['"+n.undeclaredGlobalsInFunctions.get(r).manglename+"']",s=n.undeclaredGlobalsInFunctions.get(r).manglename;else{const e={manglename:je(n),node:t.left};n.undeclaredGlobalsInFunctions.set(r,e),a="gscope['"+e.manglename+"']",s=e.manglename}return s&&(l+="lang.chkAssig('"+s+"',runtimeCtx); \n"),l+="if ("+o+"===null) { lastStatement = lc.voidOperation; }\n ",l+="else if (lc.isArray("+o+") || lc.isString("+o+")) {\n",l+=te(n,a,`${o}.length`,t.body),l+="}\n",l+="else if (lc.isImmutableArray("+o+")) {\n",l+=te(n,a,`${o}.length()`,t.body),l+="}\n",l+="else if (( "+o+" instanceof lang.Dictionary) || lc.isDictionaryLike("+o+")) {\n",l+=oe(n,a,`${o}.keys()`,t.body),l+="}\n",n.isAsync&&(l+="else if (lc.isFeatureSet("+o+")) {\n",l+=le(n,a,o,t.body),l+="}\n"),l+=`else if (lc.isGeometry(${o})) {\n`,l+=oe(n,a,`lang.getGeometryKeys(${o})`,t.body),l+="}\n",l+="else { lastStatement = lc.voidOperation; } \n",l}function ae(n,t){const o=Ne(n);let l="var "+o+" = "+X(n,t.right)+";\n";"VariableDeclaration"===t.left.type&&(l+=ee(n,t.left));const r=e("VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);be(r);let a="";null!==n.localScope&&(void 0!==n.localScope[r]?a="lscope['"+r+"']":void 0!==n.localScope._SymbolsMap[r]&&(a="lscope['"+n.localScope._SymbolsMap[r]+"']"));let s="";if(""===a)if(void 0!==n.globalScope[r])a="gscope['"+r+"']";else if(void 0!==n.globalScope._SymbolsMap[r])a="gscope['"+n.globalScope._SymbolsMap[r]+"']";else if(null!==n.localScope)if(n.undeclaredGlobalsInFunctions.has(r))a="gscope['"+n.undeclaredGlobalsInFunctions.get(r).manglename+"']",s=n.undeclaredGlobalsInFunctions.get(r).manglename;else{const e={manglename:je(n),node:t.left};n.undeclaredGlobalsInFunctions.set(r,e),a="gscope['"+e.manglename+"']",s=e.manglename}return s&&(l+="lang.chkAssig('"+s+"',runtimeCtx); \n"),l+="if ("+o+"===null) { lastStatement = lc.voidOperation; }\n ",l+="else if (lc.isArray("+o+") || lc.isString("+o+")) {\n",l+=te(n,a,`${o}.length`,t.body,((e,n)=>[`if (${n} >= ${o}.length) {`,` lang.error('${i.OutOfBounds}');`,"}",`${e} = ${o}[${n}];`].join("\n"))),l+="}\n",l+="else if (lc.isImmutableArray("+o+")) {\n",l+=te(n,a,`${o}.length()`,t.body,((e,n)=>`${e} = ${o}.get(${n});`)),l+="}\n",l+="else if (( "+o+" instanceof lang.Dictionary) || lc.isDictionaryLike("+o+")) {\n",l+=oe(n,a,`${o}.keys()`,t.body,(e=>`lang.entry(${e}, ${o}.field(${e}))`)),l+="}\n",n.isAsync&&(l+="else if (lc.isFeatureSet("+o+")) {\n",l+=le(n,a,o,t.body),l+="}\n"),l+=`else if (lc.isGeometry(${o})) {\n`,l+=oe(n,a,`lang.getGeometryKeys(${o})`,t.body,(e=>`lang.entry(${e}, lang.geometryMember(${o}, ${e}, runtimeCtx, null, 1))`)),l+="}\n",l+="else { lastStatement = lc.voidOperation; } \n",l}function se(e,n){let t="lastStatement = lc.voidOperation; \n";null!==n.init&&("VariableDeclaration"===n.init.type?t+=ee(e,n.init):t+=X(e,n.init)+"; ");const o=Ne(e),l=Ne(e);return t+="var "+o+" = true; ",t+="\n do { ",null!==n.update&&(t+=" if ("+o+"===false) {\n "+X(e,n.update)+" \n}\n "+o+"=false; \n"),null!==n.test&&(t+="var "+l+" = "+X(e,n.test)+"; ",t+="if ("+l+"===false) { break; } else if ("+l+"!==true) { lang.error('"+i.BooleanConditionRequired+"'); }\n"),t+=ee(e,n.body),null!==n.update&&(t+="\n "+X(e,n.update)),t+="\n"+o+" = true; \n} while(true); lastStatement = lc.voidOperation; ",t}function ie(n,t){if("CallExpression"===t.argument.type)throw new c(n,i.NeverReach,t);let o;if("MemberExpression"===t.argument.type){const e=X(n,t.argument.object);return!0===t.argument.computed?o=X(n,t.argument.property):(be(t.argument.property.name),o="'"+t.argument.property.name+"'"),"lang.memberupdate("+e+","+o+",'"+t.operator+"',"+t.prefix+")"}const l=e(t.argument);if(be(l),null!==n.localScope){if(void 0!==n.localScope[l])return"lang.update(lscope, '"+l+"','"+t.operator+"',"+t.prefix+")";if(void 0!==n.localScope._SymbolsMap[l])return"lang.update(lscope, '"+n.localScope._SymbolsMap[l]+"','"+t.operator+"',"+t.prefix+")"}if(void 0!==n.globalScope[l])return"lang.update(gscope, '"+l+"','"+t.operator+"',"+t.prefix+")";if(void 0!==n.globalScope._SymbolsMap[l])return"lang.update(gscope, '"+n.globalScope._SymbolsMap[l]+"','"+t.operator+"',"+t.prefix+")";if(null!==n.localScope){if(n.undeclaredGlobalsInFunctions.has(l))return"lang.update(gscope,lang.chkAssig( '"+n.undeclaredGlobalsInFunctions.get(l).manglename+"',runtimeCtx),'"+t.operator+"',"+t.prefix+")";const e={manglename:je(n),node:t.argument};return n.undeclaredGlobalsInFunctions.set(l,e),"lang.update(gscope, lang.chkAssig('"+e.manglename+"',runtimeCtx),'"+t.operator+"',"+t.prefix+")"}throw new s(n,i.InvalidIdentifier,t)}function ce(e,n){let t="lastStatement = lc.voidOperation; \n";const o=Ne(e);return t+=`\n var ${o} = true;\n do {\n ${o} = ${X(e,n.test)};\n if (${o}==false) {\n break;\n }\n if (${o}!==true) {\n lang.error('${i.BooleanConditionRequired}');\n }\n ${ee(e,n.body)}\n }\n while (${o} !== false);\n lastStatement = lc.voidOperation;\n `,t}function ue(n,t){const o=X(n,t.right);if("MemberExpression"===t.left.type){let e;const l=X(n,t.left.object);return!0===t.left.computed?e=X(n,t.left.property):(e="'"+t.left.property.name+"'",be(t.left.property.name)),"lang.assignmember("+l+","+e+",'"+t.operator+"',"+o+")"}const l=e(t.left);if(be(l),null!==n.localScope){if(void 0!==n.localScope[l])return"lscope['"+l+"']=lang.assign("+o+",'"+t.operator+"', lscope['"+l+"'])";if(void 0!==n.localScope._SymbolsMap[l])return"lscope['"+n.localScope._SymbolsMap[l]+"']=lang.assign("+o+",'"+t.operator+"', lscope['"+n.localScope._SymbolsMap[l]+"'])"}if(void 0!==n.globalScope[l])return"gscope['"+l+"']=lang.assign("+o+",'"+t.operator+"', gscope['"+l+"'])";if(void 0!==n.globalScope._SymbolsMap[l])return"gscope['"+n.globalScope._SymbolsMap[l]+"']=lang.assign("+o+",'"+t.operator+"', gscope['"+n.globalScope._SymbolsMap[l]+"'])";if(null!==n.localScope){if(n.undeclaredGlobalsInFunctions.has(l))return"gscope[lang.chkAssig('"+n.undeclaredGlobalsInFunctions.get(l).manglename+"',runtimeCtx)]=lang.assign("+o+",'"+t.operator+"', gscope['"+n.undeclaredGlobalsInFunctions.get(l).manglename+"'])";const e={manglename:je(n),node:t.left};return n.undeclaredGlobalsInFunctions.set(l,e),"gscope[lang.chkAssig('"+e.manglename+"',runtimeCtx)]=lang.assign("+o+",'"+t.operator+"', gscope['"+e.manglename+"'])"}throw new s(n,i.InvalidIdentifier,t)}function pe(e,n){return"AssignmentExpression"===n.expression.type?"lastStatement = lc.voidOperation; "+X(e,n.expression)+"; \n ":"lastStatement = "+X(e,n.expression)+"; "}function me(e,n){return"BlockStatement"===n.type?ee(e,n):"ReturnStatement"===n.type||"BreakStatement"===n.type||"ContinueStatement"===n.type?ee(e,n)+"; ":"ExpressionStatement"===n.type?ee(e,n):ee(e,n)+"; "}function ge(e,n){return`if (lang.mustBoolean(${X(e,n.test)}, runtimeCtx) === true) {\n ${me(e,n.consequent)}\n } `+(null!==n.alternate?"IfStatement"===n.alternate.type?" else "+ge(e,n.alternate):` else {\n ${me(e,n.alternate)}\n }\n`:" else {\n lastStatement = lc.voidOperation;\n }\n")}function de(e,n){let t="";for(let o=0;o<n.body.length;o++)"EmptyStatement"!==n.body[o].type&&("ReturnStatement"===n.body[o].type||"BreakStatement"===n.body[o].type||"ContinueStatement"===n.body[o].type?t+=ee(e,n.body[o])+"; \n":t+=ee(e,n.body[o])+" \n");return t}function fe(e,n){if(null===n.argument)return"return lc.voidOperation";return"return "+X(e,n.argument)}function he(n,t){const o=e(t.specifiers[0].local);be(o);const l=n.libraryResolver?.loadLibrary(o),r=je(n);void 0===n.moduleFactory[l.uri]&&(n.moduleFactory[l.uri]=Qe(l.syntax,{interceptor:n.interceptor,services:n.services,moduleFactory:n.moduleFactory,lrucache:n.lrucache,timeZone:n.timeZone??null,libraryResolver:n.libraryResolver,customfunctions:n.customfunctions,vars:{}},n.isAsync)),n.moduleFactoryMap[r]=l.uri;let a,s="";return s=n.isAsync?"(yield lang.loadModule('"+r+"', runtimeCtx) ); ":"lang.loadModule('"+r+"', runtimeCtx); ",void 0!==n.globalScope[o]?"gscope['"+o+"']="+s:void 0!==n.globalScope._SymbolsMap[o]?"gscope['"+n.globalScope._SymbolsMap[o]+"']="+s:(n.undeclaredGlobalsInFunctions.has(o)?(a=n.undeclaredGlobalsInFunctions.get(o).manglename,n.undeclaredGlobalsInFunctions.delete(o)):a=je(n),n.globalScope._SymbolsMap[o]=a,n.mangleMap[o]=a,"gscope[lang.setAssig('"+a+"', runtimeCtx)]="+s)}function ye(n,t){const o=ee(n,t.declaration);if("FunctionDeclaration"===t.declaration.type)n.exports[e(t.declaration.id)]="function";else if("VariableDeclaration"===t.declaration.type)for(const l of t.declaration.declarations)n.exports[e(l.id)]="variable";return o}function be(e){if("iif"===e)throw new u;if("decode"===e)throw new u;if("when"===e)throw new u;if("defaultvalue"===e)throw new u}function Se(n,t){const o=e(t.id);let l;be(o);let r=!1;void 0!==n.globalScope[o]?l=o:void 0!==n.globalScope._SymbolsMap[o]?l=n.globalScope._SymbolsMap[o]:n.undeclaredGlobalsInFunctions.has(o)?(l=n.undeclaredGlobalsInFunctions.get(o).manglename,n.globalScope._SymbolsMap[o]=l,n.mangleMap[o]=l,n.undeclaredGlobalsInFunctions.delete(o),r=!0):(l=je(n),n.globalScope._SymbolsMap[o]=l,n.mangleMap[o]=l);const a={isAsync:n.isAsync,console:n.console,exports:n.exports,undeclaredGlobalsInFunctions:n.undeclaredGlobalsInFunctions,customfunctions:n.customfunctions,moduleFactory:n.moduleFactory,moduleFactoryMap:n.moduleFactoryMap,libraryResolver:n.libraryResolver,lrucache:n.lrucache,interceptor:n.interceptor,services:n.services,symbols:n.symbols,mangleMap:n.mangleMap,localScope:{_SymbolsMap:{}},depthCounter:n.depthCounter,globalScope:n.globalScope};let s="new lang.UserDefinedCompiledFunction( lang.functionDepthchecker(function() { var lastStatement = lc.voidOperation; \n var lscope = runtimeCtx.localStack[runtimeCtx.localStack.length-1];\n";for(let i=0;i<t.params.length;i++){const o=e(t.params[i]);be(o);const l=je(n);a.localScope._SymbolsMap[o]=l,a.mangleMap[o]=l,s+="lscope['"+l+"']=arguments["+i.toString()+"];\n"}return!0===n.isAsync?(s+="return lang.__awaiter(this, void 0, void 0, function* () {\n",s+=de(a,t.body)+"\n return lastStatement; ",s+="}); }",s+=", runtimeCtx),"+t.params.length+")",s+="\n lastStatement = lc.voidOperation; \n"):(s+=de(a,t.body)+"\n return lastStatement; }, runtimeCtx),"+t.params.length+")",s+="\n lastStatement = lc.voidOperation; \n"),r?"gscope[lang.setAssig('"+l+"', runtimeCtx)]="+s:"gscope['"+l+"']="+s}function we(e,n){const t=[];for(let o=0;o<n.declarations.length;o++)t.push(ve(e,n.declarations[o]));return t.join("\n")+" \n lastStatement= lc.voidOperation; \n"}function ve(n,t){const o=null===t.init?null:X(n,t.init),l=e(t.id);if(be(l),null!==n.localScope){if(void 0!==n.localScope[l])return"lscope['"+l+"']="+o+"; ";if(void 0!==n.localScope._SymbolsMap[l])return"lscope['"+n.localScope._SymbolsMap[l]+"']="+o+"; ";const e=je(n);return n.localScope._SymbolsMap[l]=e,n.mangleMap[l]=e,"lscope['"+e+"']="+o+"; "}if(void 0!==n.globalScope[l])return"gscope['"+l+"']="+o+"; ";if(void 0!==n.globalScope._SymbolsMap[l])return"gscope['"+n.globalScope._SymbolsMap[l]+"']="+o+"; ";if(n.undeclaredGlobalsInFunctions.has(l)){const e=n.undeclaredGlobalsInFunctions.get(l).manglename;return n.globalScope._SymbolsMap[l]=e,n.mangleMap[l]=e,n.undeclaredGlobalsInFunctions.delete(l),"gscope[lang.setAssig('"+e+"', runtimeCtx)]="+o+"; "}const r=je(n);return n.globalScope._SymbolsMap[l]=r,n.mangleMap[l]=r,"gscope['"+r+"']="+o+"; "}function xe(e,n){try{let t;return!0===n.computed?t=X(e,n.property):(be(n.property.name),t="'"+n.property.name+"'"),"lang.member("+X(e,n.object)+","+t+")"}catch(t){throw t}}function Me(e,n){try{return"lang.unary("+X(e,n.argument)+",'"+n.operator+"')"}catch(t){throw t}}function Fe(e,n){try{const t=[];for(let o=0;o<n.elements.length;o++)"Literal"===n.elements[o].type?t.push(X(e,n.elements[o])):t.push("lang.aCheck("+X(e,n.elements[o])+",'ArrayExpression')");return"["+t.join(",")+"]"}catch(t){throw t}}function $e(e,n){try{const t=[];let o=0;for(const l of n.quasis)t.push(l.value?JSON.stringify(l.value.cooked):JSON.stringify("")),!1===l.tail&&(t.push(n.expressions[o]?"lang.castString(lang.aCheck("+X(e,n.expressions[o])+", 'TemplateLiteral'))":""),o++);return"(["+t.join(",")+"]).join('')"}catch(t){throw t}}function Ce(e,n){try{return"lang.binary("+X(e,n.left)+","+X(e,n.right)+",'"+n.operator+"')"}catch(t){throw t}}function Ie(e,n){try{if("AssignmentExpression"===n.left.type||"UpdateExpression"===n.left.type)throw new c(e,i.LogicalExpressionOnlyBoolean,n);if("AssignmentExpression"===n.right.type||"UpdateExpression"===n.right.type)throw new c(e,i.LogicalExpressionOnlyBoolean,n);if("&&"===n.operator||"||"===n.operator)return"(lang.logicalCheck("+X(e,n.left)+") "+n.operator+" lang.logicalCheck("+X(e,n.right)+"))";throw new c(null,i.LogicExpressionOrAnd,null)}catch(t){throw t}}function Ae(n,t){try{const o=e(t);if(be(o),null!==n.localScope){if(void 0!==n.localScope[o])return"lscope['"+o+"']";if(void 0!==n.localScope._SymbolsMap[o])return"lscope['"+n.localScope._SymbolsMap[o]+"']"}if(void 0!==n.globalScope[o])return"gscope['"+o+"']";if(void 0!==n.globalScope._SymbolsMap[o])return"gscope['"+n.globalScope._SymbolsMap[o]+"']";if(null!==n.localScope){if(n.undeclaredGlobalsInFunctions.has(o))return"gscope[lang.chkAssig('"+n.undeclaredGlobalsInFunctions.get(o).manglename+"',runtimeCtx)]";const e={manglename:je(n),node:t};return n.undeclaredGlobalsInFunctions.set(o,e),"gscope[lang.chkAssig('"+e.manglename+"',runtimeCtx)]"}throw new c(n,i.InvalidIdentifier,t)}catch(o){throw o}}function _e(n,t){try{if("MemberExpression"===t.callee.type){let e;!0===t.callee.computed?e=X(n,t.callee.property):(be(t.callee.property.name),e="'"+t.callee.property.name+"'");let o="[";for(let l=0;l<t.arguments.length;l++)l>0&&(o+=", "),o+=X(n,t.arguments[l]);return o+="]",n.isAsync?"(yield lang.callModuleFunction("+X(n,t.callee.object)+","+o+","+e+",runtimeCtx))":"lang.callModuleFunction("+X(n,t.callee.object)+","+o+","+e+",runtimeCtx)"}if("Identifier"!==t.callee.type)throw new c(n,i.FunctionNotFound,t);const o=e(t.callee);if("iif"===o)return Oe(n,t);if("when"===o)return Ge(n,t);if("defaultvalue"===o)return ke(n,t);if("decode"===o)return Ee(n,t);let l="";if(null!==n.localScope&&(void 0!==n.localScope[o]?l="lscope['"+o+"']":void 0!==n.localScope._SymbolsMap[o]&&(l="lscope['"+n.localScope._SymbolsMap[o]+"']")),""===l)if(void 0!==n.globalScope[o])l="gscope['"+o+"']";else if(void 0!==n.globalScope._SymbolsMap[o])l="gscope['"+n.globalScope._SymbolsMap[o]+"']";else if(null!==n.localScope)if(n.undeclaredGlobalsInFunctions.has(o))l="gscope[lang.chkAssig('"+n.undeclaredGlobalsInFunctions.get(o).manglename+"',runtimeCtx)]";else{const e={manglename:je(n),node:t.callee};n.undeclaredGlobalsInFunctions.set(o,e),l="gscope[lang.chkAssig('"+e.manglename+"',runtimeCtx)]"}if(""!==l){let e="[";for(let o=0;o<t.arguments.length;o++)o>0&&(e+=", "),e+=X(n,t.arguments[o]);return e+="]",n.isAsync?"(yield lang.callfunc("+l+","+e+",runtimeCtx) )":"lang.callfunc("+l+","+e+",runtimeCtx)"}throw new c(n,i.FunctionNotFound,t)}catch(o){throw o}}function Oe(e,n){try{if(3!==n.arguments.length)throw new c(e,i.WrongNumberOfParameters,n);const t=Ne(e);return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${X(e,n.arguments[0])};\n\n if (${t} === true) {\n return ${X(e,n.arguments[1])};\n }\n else if (${t} === false) {\n return ${X(e,n.arguments[2])};\n }\n else {\n lang.error('ExecutionErrorCodes.BooleanConditionRequired');\n }\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function ke(e,n){try{if(n.arguments.length<2||n.arguments.length>3)throw new c(e,i.WrongNumberOfParameters,n);const t=Ne(e),o=Ne(e);return 3===n.arguments.length?`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${X(e,n.arguments[0])};\n var ${o} = ${X(e,n.arguments[1])};\n ${t} = lang.getNestedOptionalValue(${t}, ${o});\n return ${t} != null && ${t} !== "" ? ${t} : ${X(e,n.arguments[2])};\n ${e.isAsync?"})}()))":"}()"}`:`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${X(e,n.arguments[0])};\n if (${t} === null) {\n return ${X(e,n.arguments[1])};\n }\n if (${t} === "") {\n return ${X(e,n.arguments[1])};\n }\n if (${t} === undefined) {\n return ${X(e,n.arguments[1])};\n }\n return ${t};\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Ge(e,n){try{if(n.arguments.length<3)throw new c(e,i.WrongNumberOfParameters,n);if(n.arguments.length%2==0)throw new c(e,i.WrongNumberOfParameters,n);const t=Ne(e);let o="var ";for(let l=0;l<n.arguments.length-1;l+=2)o+=`${t} = lang.mustBoolean(${X(e,n.arguments[l])}, runtimeCtx);\n if (${t} === true ) {\n return ${X(e,n.arguments[l+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n ${o}\n return ${X(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Ee(e,n){try{if(n.arguments.length<2)throw new c(e,i.WrongNumberOfParameters,n);if(2===n.arguments.length)return`(${X(e,n.arguments[1])})`;if((n.arguments.length-1)%2==0)throw new c(e,i.WrongNumberOfParameters,n);const t=Ne(e),o=Ne(e);let l="var ";for(let r=1;r<n.arguments.length-1;r+=2)l+=`${o} = ${X(e,n.arguments[r])};\n if (lang.binary(${o}, ${t}, "==") === true ) {\n return ${X(e,n.arguments[r+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${X(e,n.arguments[0])};\n ${l}\n return ${X(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}const Be={};function je(e){return e.symbols.symbolCounter++,`_T${e.symbols.symbolCounter}`}function Ne(e){return e.symbols.symbolCounter++,`_Tvar${e.symbols.symbolCounter}`}N(Be,Q),K(Be,Q),L(Be,Q),R(Be,Q),U(Be,Q),Be.iif=function(e,n){try{return Q(e,n,((t,o,l)=>{throw new s(e,i.Unrecognized,n)}))}catch(t){throw t}},Be.decode=function(e,n){try{return Q(e,n,((t,o,l)=>{throw new s(e,i.Unrecognized,n)}))}catch(t){throw t}},Be.when=function(e,n){try{return Q(e,n,((t,o,l)=>{throw new s(e,i.Unrecognized,n)}))}catch(t){throw t}},Be.defaultvalue=function(e,n){try{return Q(e,n,((t,o,l)=>{throw new s(e,i.Unrecognized,n)}))}catch(t){throw t}};const Re={};for(const Xe in Be)Re[Xe]=new m(Be[Xe]);D(Be,Q);for(const Xe in Be)Be[Xe]=new m(Be[Xe]);const De=function(){};De.prototype=Be;const Le=function(){};function Ue(e,n,t){const o={_SymbolsMap:{}};e||(e={}),t||(t={}),o.textformatting=1,o.infinity=1,o.pi=1;for(const l in n)o[l]=1;for(const l in t)o[l]=1;for(const l in e)o[l]=1;return o}function Ke(e,n,t,o){const l=t?new Le:new De;e||(e={}),n||(n={});const r=new a({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});r.immutable=!1,l._SymbolsMap={textformatting:1,infinity:1,pi:1},l.textformatting=r,l.infinity=Number.POSITIVE_INFINITY,l.pi=Math.PI;for(const a in n)l[a]=n[a],l._SymbolsMap[a]=1;for(const a in e){const n=e[a];l._SymbolsMap[a]=1,T(n)?l[a]=p.createFromGraphic(n,o??null):l[a]=n}return l}Le.prototype=Re;const Ze={fixSpatialReference:y,parseArguments:H,standardFunction:Q};function Pe(e,n){const t={mode:n,compiled:!0,functions:{},signatures:[],standardFunction:Q,standardFunctionAsync:Q,evaluateIdentifier:Te};for(let o=0;o<e.length;o++)e[o].registerFunctions(t);if("sync"===n){for(const e in t.functions)Be[e]=new m(t.functions[e]),De.prototype[e]=Be[e];for(let e=0;e<t.signatures.length;e++)B(t.signatures[e],"sync")}else{for(const e in t.functions)Re[e]=new m(t.functions[e]),Le.prototype[e]=Re[e];for(let e=0;e<t.signatures.length;e++)B(t.signatures[e],"async")}}function We(e,n){return e(n)}function Te(e,n){const t=n.name;if("_SymbolsMap"===t)throw new s(e,i.InvalidIdentifier,null);if(e.localStack.length>0){const n=e.localStack[e.localStack.length-1];if(!t.toLowerCase().startsWith("_t")&&void 0!==n[t])return n[t];const o=e.mangleMap[t];if(void 0!==o&&void 0!==n[o])return n[o]}if(!t.toLowerCase().startsWith("_t")&&void 0!==e.globalScope[t])return e.globalScope[t];if(1===e.globalScope._SymbolsMap[t])return e.globalScope[t];const o=e.mangleMap[t];return void 0!==o?e.globalScope[o]:void 0}Pe([j],"sync"),Pe([j],"async");let Ve=0;const qe={isNumber:e=>V(e),isArray:e=>q(e),isImmutableArray:e=>F(e),isDictionaryLike:e=>$(e),isString:e=>z(e),isDictionary:e=>C(e),isGeometry:e=>I(e),getGeometryKeys:e=>o(e),geometryMember:(e,n,t,o,r=1)=>l(e,n,t,o,r),error(e){throw new s(null,e,null)},__awaiter:(e,n,t,o)=>new Promise(((t,l)=>{function r(e){try{s(o.next(e))}catch(n){l(n)}}function a(e){try{s(o.throw(e))}catch(n){l(n)}}function s(e){e.done?t(e.value):e.value?.then?e.value.then(r,a):(Ve++,Ve%100==0?setTimeout((()=>{Ve=0,r(e.value)}),0):r(e.value))}s((o=o.apply(e,n||[])).next())})),functionDepthchecker:(e,n)=>function(){if(n.depthCounter.depth++,n.localStack.push({}),n.depthCounter.depth>64)throw new s(null,i.MaximumCallDepth,null);const t=e.apply(this,arguments);return Z(t)?t.then((e=>(n.depthCounter.depth--,n.localStack.length=n.localStack.length-1,e))):(n.depthCounter.depth--,n.localStack.length=n.localStack.length-1,t)},chkAssig(e,n){if(void 0===n.gdefs[e])throw new s(n,i.InvalidIdentifier,null);return e},mustBoolean(e,n){if(!0===e||!1===e)return e;throw new s(n,i.BooleanConditionRequired,null)},setAssig:(e,n)=>(n.gdefs[e]=1,e),castString:e=>A(e),aCheck(e,n){if(h(e)){if("ArrayExpression"===n)throw new s(null,i.NoFunctionInArray,null);if("ObjectExpression"===n)throw new s(null,i.NoFunctionInDictionary,null);throw new s(null,i.NoFunctionInTemplateLiteral,null)}return e===v?null:e},Dictionary:a,Feature:p,UserDefinedCompiledFunction:Y,dictionary(e){const n={},t=new Map;for(let l=0;l<e.length;l+=2){if(h(e[l+1]))throw new s(null,i.NoFunctionInDictionary,null);if(!1===z(e[l]))throw new s(null,i.KeyMustBeString,null);let o=e[l].toString();const r=o.toLowerCase();t.has(r)?o=t.get(r):t.set(r,o),e[l+1]===v?n[o]=null:n[o]=e[l+1]}const o=new a(n);return o.immutable=!1,o},entry:(e,n)=>new a({key:e,value:n}),strCheck(e){if(!1===z(e))throw new s(null,i.KeyMustBeString,null);return e},unary(e,n){if(J(e)){if("!"===n)return!e;if("-"===n)return-1*_(e);if("+"===n)return 1*_(e);if("~"===n)return~_(e);throw new s(null,i.UnsupportedUnaryOperator,null)}if("-"===n)return-1*_(e);if("+"===n)return 1*_(e);if("~"===n)return~_(e);throw new s(null,i.UnsupportedUnaryOperator,null)},logicalCheck(e){if(!1===J(e))throw new s(null,i.LogicExpressionOrAnd,null);return e},logical(e,n,t){if(J(e)&&J(n))switch(t){case"||":return e||n;case"&&":return e&&n;default:throw new s(null,i.LogicExpressionOrAnd,null)}throw new s(null,i.LogicExpressionOrAnd,null)},binary(e,n,t){switch(t){case"|":case"<<":case">>":case">>>":case"^":case"&":return G(_(e),_(n),t);case"==":case"=":return k(e,n);case"!=":return!k(e,n);case"<":case">":case"<=":case">=":return O(e,n,t);case"+":return z(e)||z(n)?A(e)+A(n):_(e)+_(n);case"-":return _(e)-_(n);case"*":return _(e)*_(n);case"/":return _(e)/_(n);case"%":return _(e)%_(n);default:throw new s(null,i.UnsupportedOperator,null)}},assign(e,n,t){switch(n){case"=":return e===v?null:e;case"/=":return _(t)/_(e);case"*=":return _(t)*_(e);case"-=":return _(t)-_(e);case"+=":return z(t)||z(e)?A(t)+A(e):_(t)+_(e);case"%=":return _(t)%_(e);default:throw new s(null,i.UnsupportedOperator,null)}},update(e,n,t,o){const l=_(e[n]);return e[n]="++"===t?l+1:l-1,!1===o?l:"++"===t?l+1:l-1},graphicToFeature:(e,n,t)=>null===e?null:p.createFromGraphicLikeObject(e.geometry,e.attributes,n,t.timeZone),memberupdate(e,n,t,o){let l;if(q(e)){if(!V(n))throw new s(null,i.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>=e.length)throw new s(null,i.OutOfBounds,null);l=_(e[n]),e[n]="++"===t?l+1:l-1}else if(e instanceof a){if(!1===z(n))throw new s(null,i.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new s(null,i.FieldNotFound,null,{key:n});l=_(e.field(n)),e.setField(n,"++"===t?l+1:l-1)}else if(E(e)){if(!1===z(n))throw new s(null,i.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new s(null,i.FieldNotFound,null);l=_(e.field(n)),e.setField(n,"++"===t?l+1:l-1)}else{if(F(e))throw new s(null,i.Immutable,null);if(!(e instanceof He))throw new s(null,i.InvalidIdentifier,null);if(!1===z(n))throw new s(null,i.ModuleAccessorMustBeString,null);if(!0!==e.hasGlobal(n))throw new s(null,i.ModuleExportNotFound,null);l=_(e.global(n)),e.setGlobal(n,"++"===t?l+1:l-1)}return!1===o?l:"++"===t?l+1:l-1},assignmember(e,n,t,o){if(q(e)){if(!V(n))throw new s(null,i.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>e.length)throw new s(null,i.OutOfBounds,null);if(n===e.length){if("="!==t)throw new s(null,i.OutOfBounds,null);e[n]=this.assign(o,t,e[n])}else e[n]=this.assign(o,t,e[n])}else if(e instanceof a){if(!1===z(n))throw new s(null,i.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(o,t,e.field(n)));else{if("="!==t)throw new s(null,i.FieldNotFound,null);e.setField(n,this.assign(o,t,null))}}else if(E(e)){if(!1===z(n))throw new s(null,i.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(o,t,e.field(n)));else{if("="!==t)throw new s(null,i.FieldNotFound,null);e.setField(n,this.assign(o,t,null))}}else{if(F(e))throw new s(null,i.Immutable,null);if(!(e instanceof He))throw new s(null,i.InvalidIdentifier,null);if(!1===z(n))throw new s(null,i.ModuleAccessorMustBeString,null);if(!e.hasGlobal(n))throw new s(null,i.ModuleExportNotFound,null);e.setGlobal(n,this.assign(o,t,e.global(n)))}},member(e,n){if(null===e)throw new s(null,i.MemberOfNull,null);if(e instanceof a||$(e)){if(z(n))return e.field(n);throw new s(null,i.InvalidMemberAccessKey,null)}if(e instanceof P){if(z(n))return l(e,n,null,null);throw new s(null,i.InvalidMemberAccessKey,null)}if(q(e)){if(V(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new s(null,i.OutOfBounds,null);return e[n]}throw new s(null,i.InvalidMemberAccessKey,null)}if(z(e)){if(V(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new s(null,i.OutOfBounds,null);return e[n]}throw new s(null,i.InvalidMemberAccessKey,null)}if(F(e)){if(V(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length()+n),n>=e.length()||n<0)throw new s(null,i.OutOfBounds,null);return e.get(n)}throw new s(null,i.InvalidMemberAccessKey,null)}if(e instanceof He){if(z(n))return e.global(n);throw new s(null,i.InvalidMemberAccessKey,null)}throw new s(null,i.InvalidMemberAccessKey,null)},callfunc:(e,n,t)=>e.call(t,{arguments:n,preparsed:!0}),loadModule(e,n){const t=n.moduleFactoryMap[e];if(n.moduleSingletons[t])return n.moduleSingletons[t];const o=n.moduleFactory[t]({vars:{},moduleSingletons:n.moduleSingletons,depthCounter:n.depthCounter,console:n.console,abortSignal:n.abortSignal,isAsync:n.isAsync,services:n.services,lrucache:n.lrucache,timeZone:n.timeZone??null,interceptor:n.interceptor},n.spatialReference);return n.moduleSingletons[t]=o,o},callModuleFunction(e,n,t,o){if(!(e instanceof He))throw new s(null,i.FunctionNotFound,null);const l=e.global(t);if(!1===h(l))throw new s(null,i.CallNonFunction,null);return l.call(o,{preparsed:!0,arguments:n})},getNestedOptionalValue:(e,n)=>r(e,n)};function ze(e){console.log(e)}function Je(e,n,o=!1){null===n&&(n={vars:{},customfunctions:{}});let l=null;e.usesModules&&(l=new t(null,e.loadedModules));const r={isAsync:o,globalScope:Ue(n.vars,o?Re:Be,n.customfunctions),moduleFactory:{},moduleFactoryMap:{},undeclaredGlobalsInFunctions:new Map,customfunctions:n.customfunctions,libraryResolver:l,localScope:null,mangleMap:{},depthCounter:{depth:1},exports:{},console:ze,lrucache:n.lrucache,timeZone:n.timeZone??null,interceptor:n.interceptor,services:n.services,symbols:{symbolCounter:0}};let a=de(r,e);""===a&&(a="lc.voidOperation; "),r.undeclaredGlobalsInFunctions.size>0&&r.undeclaredGlobalsInFunctions.forEach((e=>{throw new c(n,i.InvalidIdentifier,e.node)}));let u="";u=o?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+a+"\n return lastStatement; }); } \n return this.postProcess(yield mainBody()); }); ":"var runtimeCtx=this.prepare(context, false);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \n function mainBody() {\n var lastStatement=lc.voidOperation;\n "+a+"\n return lastStatement; } \n return this.postProcess(mainBody()); ";const p=r.moduleFactory,m=r.moduleFactoryMap,g=r.exports,d={};let f;for(f in g)d[f]=r.mangleMap[f]??f;const y={lc:b,lang:qe,mangles:r.mangleMap,postProcess(e){if(e instanceof S&&(e=e.value),e instanceof w&&(e=e.value),e===v&&(e=null),e===x)throw new s(null,i.IllegalResult,null);if(e===M)throw new s(null,i.IllegalResult,null);if(h(e))throw new s(null,i.IllegalResult,null);return e},prepare(e,n){let t=e.spatialReference;null==t&&(t=W.WebMercator);const o=Ke(e.vars,e.customfunctions,n,e.timeZone);return{localStack:[],isAsync:n,moduleFactory:p,moduleFactoryMap:m,mangleMap:this.mangles,moduleSingletons:{},exports:g,gdefs:{},exportmangle:d,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??ze,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:{depth:1}}}};return new Function("context","spatialReference",u).bind(y)}async function Ye(){return Pe([await import("./functions/geomasync.js")],"async"),!0}class He extends n{constructor(e){super(),this.moduleContext=e}hasGlobal(e){return void 0===this.moduleContext.exports[e]&&(e=e.toLowerCase()),void 0!==this.moduleContext.exports[e]}setGlobal(e,n){const t=this.moduleContext.globalScope,o=e.toLowerCase();if(h(n))throw new s(null,i.AssignModuleFunction,null);t[this.moduleContext.exportmangle[o]]=n}global(e){const n=this.moduleContext.globalScope,t=e.toLowerCase(),o=n[this.moduleContext.exportmangle[t]];if(void 0===o)throw new s(null,i.InvalidIdentifier,null);if(h(o)&&!(o instanceof d)){const e=new d;return e.fn=o,e.parameterEvaluator=Q,e.context=this.moduleContext,n[this.moduleContext.exportmangle[t]]=e,e}return o}}function Qe(e,n,o=!1){const l={isAsync:o,moduleFactory:n.moduleFactory,moduleFactoryMap:{},libraryResolver:new t(null,e.loadedModules),globalScope:Ue(n.vars,o?Re:Be,n.customfunctions),customfunctions:n.customfunctions,localScope:null,mangleMap:{},undeclaredGlobalsInFunctions:new Map,depthCounter:{depth:1},exports:{},console:ze,lrucache:n.lrucache,timeZone:n.timeZone??null,interceptor:n.interceptor,services:n.services,symbols:{symbolCounter:0}};let r=de(l,e);""===r&&(r="lc.voidOperation; ");let a="";a=o?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+r+"\n return lastStatement; }); } \n yield mainBody(); \n return this.prepareModule(runtimeCtx); }); ":"var runtimeCtx=this.prepare(context, false);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \n function mainBody() {\n var lastStatement=lc.voidOperation;\n "+r+"\n return lastStatement; } \n mainBody(); \n return this.prepareModule(runtimeCtx); ";const s=l.moduleFactory,i=l.moduleFactoryMap,c=l.exports,u={};let p;for(p in c)u[p]=l.mangleMap[p]??p;const m={lc:b,lang:qe,mangles:l.mangleMap,prepareModule:e=>new He(e),prepare(e,n){let t=e.spatialReference;null==t&&(t=new W({wkid:102100}));const o=Ke(e.vars,e.customfunctions,n,e.timeZone);return{localStack:[],isAsync:n,exports:c,exportmangle:u,gdefs:{},moduleFactory:s,moduleFactoryMap:i,moduleSingletons:e.moduleSingletons,mangleMap:this.mangles,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??ze,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:e.depthCounter}}};return new Function("context","spatialReference",a).bind(m)}export{Y as UserDefinedCompiledFunction,Je as compileScript,Ye as enableAsyncSupport,We as executeScript,Pe as extend,Ze as functionHelper};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{toSymbolId as e}from"./arcadeEnvironment.js";import{ArcadeModule as t}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import{getNestedOptionalValue as r,geometryMember as o,getGeometryKeys as i}from"./containerUtils.js";import l from"./Dictionary.js";import{ArcadeExecutionError as a,ExecutionErrorCodes as s,ensureArcadeExecutionError as c}from"./executionError.js";import u from"./Feature.js";import{NativeFunction as f,ScopeMarshalledFunction as p,ArcadeFunction as h,wrapModuleScopedResponse as d}from"./FunctionWrapper.js";import{B as w,z as m,i as g,d as y,n as v,m as b,v as S,f as x,y as R,A as F,R as I,I as A,w as M,x as C,s as N,l as O}from"../chunks/languageUtils.js";import{addFunctionDeclaration as B}from"./treeAnalysis.js";import{A as k}from"../chunks/array.js";import{registerFunctions as E}from"./functions/date.js";import{registerFunctions as j}from"./functions/geometry.js";import{registerFunctions as D}from"./functions/geomsync.js";import{registerFunctions as U}from"./functions/maths.js";import{registerFunctions as K}from"./functions/stats.js";import{registerFunctions as Z}from"./functions/string.js";import q from"../geometry/Geometry.js";import L from"../geometry/SpatialReference.js";import{isBoolean as G,isString as P,isArray as V,isNumber as W,isGraphic as T}from"../support/guards.js";class _ extends h{constructor(e,t){super(),this.definition=e,this.context=t}createFunction(e){return(...t)=>{const n={spatialReference:this.context.spatialReference,console:this.context.console,services:this.context.services,timeZone:this.context.timeZone??null,lrucache:this.context.lrucache,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,localScope:{},depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope};if(n.depthCounter.depth>64)throw new a(e,s.MaximumCallDepth,null);return Ce(this.definition,n,t,null)}}call(e,t){return H(e,t,((n,r,o)=>{const i={spatialReference:e.spatialReference,services:e.services,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,timeZone:e.timeZone??null,console:e.console,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};if(i.depthCounter.depth>64)throw new a(e,s.MaximumCallDepth,t);return Ce(this.definition,i,o,t)}))}marshalledCall(e,t,n,r){return r(e,t,((o,i,l)=>{const a={spatialReference:e.spatialReference,globalScope:n.globalScope,services:e.services,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};return l=l.map((t=>!g(t)||t instanceof p?t:d(t,e,r))),d(Ce(this.definition,a,l,t),n,r)}))}}class z extends t{constructor(e){super(),this.source=e}global(t){const n=this.executingContext.globalScope[e(t)];if(g(n.value)&&!(n.value instanceof p)){const e=new p;e.fn=n.value,e.parameterEvaluator=H,e.context=this.executingContext,n.value=e}return n.value}setGlobal(t,n){if(g(n))throw new a(null,s.AssignModuleFunction,null);this.executingContext.globalScope[e(t)]={value:n}}hasGlobal(t){return void 0===this.executingContext.exports[t]&&(t=e(t)),void 0!==this.executingContext.exports[t]}loadModule(e){let t=e.spatialReference;null==t&&(t=new L({wkid:102100})),this.moduleScope=Oe({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:t,globalScope:this.moduleScope,localScope:null,libraryResolver:new n(e.libraryResolver._moduleSingletons,this.source.syntax.loadedModules),exports:{},services:e.services,console:e.console??ke,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,depthCounter:{depth:1}},ce(this.executingContext,this.source.syntax)}}function Y(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(J(e,t.arguments[r]));return n}function H(e,t,n){try{return!0===t.preparsed?n(e,null,t.arguments):n(e,t,Y(e,t))}catch(r){throw r}}function J(e,t){try{switch(t.type){case"AssignmentExpression":return le(e,t);case"UpdateExpression":return oe(e,t);case"TemplateLiteral":return xe(e,t);case"Identifier":return Re(e,t);case"MemberExpression":return me(e,t);case"Literal":return t.value;case"CallExpression":return Fe(e,t);case"UnaryExpression":return ge(e,t);case"BinaryExpression":return ve(e,t);case"LogicalExpression":return be(e,t);case"ArrayExpression":return ye(e,t);case"ObjectExpression":return X(e,t);default:throw new a(e,s.Unrecognized,t)}}catch(n){throw c(e,t,n)}}function Q(e,t){switch(t.type){case"EmptyStatement":return S;case"VariableDeclaration":return de(e,t);case"ImportDeclaration":return pe(e,t);case"ExportNamedDeclaration":return he(e,t);case"BlockStatement":return ce(e,t);case"FunctionDeclaration":return fe(e,t);case"ReturnStatement":return ue(e,t);case"IfStatement":return se(e,t);case"ExpressionStatement":return ae(e,t);case"BreakStatement":return M;case"ContinueStatement":return C;case"ForStatement":return te(e,t);case"ForInStatement":return $(e,t);case"ForOfStatement":return ee(e,t);case"WhileStatement":return ne(e,t);default:throw new a(e,s.Unrecognized,t)}}function X(e,t){const n={},r=new Map;for(let i=0;i<t.properties.length;i++){const o=t.properties[i],l="Identifier"===o.key.type?o.key.name:J(e,o.key),c=J(e,o.value);if(g(c))throw new a(e,s.NoFunctionInDictionary,t);if(!1===P(l))throw new a(e,s.KeyMustBeString,t);let u=l.toString();const f=u.toLowerCase();r.has(f)?u=r.get(f):r.set(f,u),n[u]=c===S?null:c}const o=new l(n);return o.immutable=!1,o}function $(t,n){const r=J(t,n.right);"VariableDeclaration"===n.left.type&&de(t,n.left);const o=e("VariableDeclaration"===n.left.type?n.left.declarations[0].id:n.left);let c=null;if(null!=t.localScope&&void 0!==t.localScope[o]&&(c=t.localScope[o]),null===c&&void 0!==t.globalScope[o]&&(c=t.globalScope[o]),null===c)throw new a(t,s.InvalidIdentifier,n);if(V(r)||P(r)){const e=r.length;for(let r=0;r<e;r++){c.value=r;const e=Q(t,n.body);if(e===M)break;if(e instanceof I)return e}return S}if(b(r)){for(let e=0;e<r.length();e++){c.value=e;const r=Q(t,n.body);if(r===M)break;if(r instanceof I)return r}return S}if(r instanceof l||v(r)){const e=r.keys();for(let r=0;r<e.length;r++){c.value=e[r];const o=Q(t,n.body);if(o===M)break;if(o instanceof I)return o}return S}if(O(r)){for(const e of i(r)){c.value=e;const r=Q(t,n.body);if(r===M)break;if(r instanceof I)return r}return S}return S}function ee(t,n){const r=J(t,n.right);"VariableDeclaration"===n.left.type&&Q(t,n.left);const c=e("VariableDeclaration"===n.left.type?n.left.declarations[0].id:n.left);let u=null;if(null!=t.localScope&&void 0!==t.localScope[c]&&(u=t.localScope[c]),null===u&&void 0!==t.globalScope[c]&&(u=t.globalScope[c]),null===u)throw new a(t,s.InvalidIdentifier,n);if(V(r)||P(r)){const e=r.length;for(let o=0;o<e;o++){if(o>=r.length)throw new a(t,s.OutOfBounds,n);u.value=r[o];const e=Q(t,n.body);if(e===M)break;if(e instanceof I)return e}return S}if(b(r)){for(let e=0;e<r.length();e++){u.value=r.get(e);const o=Q(t,n.body);if(o===M)break;if(o instanceof I)return o}return S}if(r instanceof l||v(r)){for(const e of r.keys()){const o=r.field(e);u.value=new l({key:e,value:o});const i=Q(t,n.body);if(i===M)break;if(i instanceof I)return i}return S}if(O(r)){for(const e of i(r)){const i=o(r,e,t,n,1);u.value=new l({key:e,value:i});const a=Q(t,n.body);if(a===M)break;if(a instanceof I)return a}return S}return S}function te(e,t){null!==t.init&&("VariableDeclaration"===t.init.type?Q(e,t.init):J(e,t.init));const n={testResult:!0,lastAction:S};do{re(e,t,n)}while(!0===n.testResult);return n.lastAction instanceof I?n.lastAction:S}function ne(e,t){const n={testResult:!0,lastAction:S};if(n.testResult=J(e,t.test),!1===n.testResult)return S;if(!0!==n.testResult)throw new a(e,s.BooleanConditionRequired,t);for(;!0===n.testResult&&(n.lastAction=Q(e,t.body),n.lastAction!==M)&&!(n.lastAction instanceof I);)if(n.testResult=J(e,t.test),!0!==n.testResult&&!1!==n.testResult)throw new a(e,s.BooleanConditionRequired,t);return n.lastAction instanceof I?n.lastAction:S}function re(e,t,n){if(null!==t.test){if(n.testResult=J(e,t.test),!1===n.testResult)return;if(!0!==n.testResult)throw new a(e,s.BooleanConditionRequired,t)}n.lastAction=Q(e,t.body),n.lastAction!==M?n.lastAction instanceof I?n.testResult=!1:null!==t.update&&J(e,t.update):n.testResult=!1}function oe(t,n){if("CallExpression"===n.argument.type)throw new a(t,s.NeverReach,n);let r;if("MemberExpression"===n.argument.type){const e=J(t,n.argument.object);let o;if(!0===n.argument.computed)o=J(t,n.argument.property);else{if("Identifier"!==n.argument.property.type)throw new a(t,s.Unrecognized,n);o=n.argument.property.name}if(V(e)){if(!W(o))throw new a(t,s.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>=e.length)throw new a(t,s.OutOfBounds,n);r=y(e[o]),e[o]="++"===n.operator?r+1:r-1}else if(e instanceof l){if(!1===P(o))throw new a(t,s.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new a(t,s.FieldNotFound,n);r=y(e.field(o)),e.setField(o,"++"===n.operator?r+1:r-1)}else if(v(e)){if(!1===P(o))throw new a(t,s.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new a(t,s.FieldNotFound,n);r=y(e.field(o)),e.setField(o,"++"===n.operator?r+1:r-1)}else{if(b(e))throw new a(t,s.Immutable,n);if(!(e instanceof z))throw new a(t,s.InvalidParameter,n);if(!1===P(o))throw new a(t,s.ModuleAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new a(t,s.ModuleExportNotFound,n);r=y(e.global(o)),e.setGlobal(o,"++"===n.operator?r+1:r-1)}return!1===n.prefix?r:"++"===n.operator?r+1:r-1}const o=e(n.argument);if(null!=t.localScope&&void 0!==t.localScope[o])return r=y(t.localScope[o].value),t.localScope[o]={value:"++"===n.operator?r+1:r-1},!1===n.prefix?r:"++"===n.operator?r+1:r-1;if(void 0!==t.globalScope[o])return r=y(t.globalScope[o].value),t.globalScope[o]={value:"++"===n.operator?r+1:r-1},!1===n.prefix?r:"++"===n.operator?r+1:r-1;throw new a(t,s.InvalidIdentifier,n)}function ie(e,t,n,r,o){switch(t){case"=":return e===S?null:e;case"/=":return y(n)/y(e);case"*=":return y(n)*y(e);case"-=":return y(n)-y(e);case"+=":return P(n)||P(e)?x(n)+x(e):y(n)+y(e);case"%=":return y(n)%y(e);default:throw new a(o,s.UnsupportedOperator,r)}}function le(t,n){if("MemberExpression"===n.left.type){const e=J(t,n.left.object);let r;if(!0===n.left.computed)r=J(t,n.left.property);else{if("Identifier"!==n.left.property.type)throw new a(t,s.InvalidIdentifier,n);r=n.left.property.name}const o=J(t,n.right);if(V(e)){if(!W(r))throw new a(t,s.ArrayAccessorMustBeNumber,n);if(r<0&&(r=e.length+r),r<0||r>e.length)throw new a(t,s.OutOfBounds,n);if(r===e.length){if("="!==n.operator)throw new a(t,s.OutOfBounds,n);e[r]=ie(o,n.operator,e[r],n,t)}else e[r]=ie(o,n.operator,e[r],n,t)}else if(e instanceof l){if(!1===P(r))throw new a(t,s.KeyAccessorMustBeString,n);if(!0===e.hasField(r))e.setField(r,ie(o,n.operator,e.field(r),n,t));else{if("="!==n.operator)throw new a(t,s.FieldNotFound,n,{key:r});e.setField(r,ie(o,n.operator,null,n,t))}}else if(v(e)){if(!1===P(r))throw new a(t,s.KeyAccessorMustBeString,n);if(!0===e.hasField(r))e.setField(r,ie(o,n.operator,e.field(r),n,t));else{if("="!==n.operator)throw new a(t,s.FieldNotFound,n,{key:r});e.setField(r,ie(o,n.operator,null,n,t))}}else{if(b(e))throw new a(t,s.Immutable,n);if(!(e instanceof z))throw new a(t,s.InvalidIdentifier,n);if(!1===P(r))throw new a(t,s.ModuleAccessorMustBeString,n);if(!0!==e.hasGlobal(r))throw new a(t,s.ModuleExportNotFound,n);e.setGlobal(r,ie(o,n.operator,e.global(r),n,t))}return S}const r=e(n.left),o=J(t,n.right);if(null!=t.localScope&&void 0!==t.localScope[r])return t.localScope[r]={value:ie(o,n.operator,t.localScope[r].value,n,t)},S;if(void 0!==t.globalScope[r])return t.globalScope[r]={value:ie(o,n.operator,t.globalScope[r].value,n,t)},S;throw new a(t,s.InvalidIdentifier,n)}function ae(e,t){const n=J(e,t.expression);return n===S?S:new A(n)}function se(e,t){const n=J(e,t.test);if(!0===n)return Q(e,t.consequent);if(!1===n)return null!==t.alternate?Q(e,t.alternate):S;throw new a(e,s.BooleanConditionRequired,t)}function ce(e,t){let n=S;for(let r=0;r<t.body.length;r++)if(n=Q(e,t.body[r]),n instanceof I||n===M||n===C)return n;return n}function ue(e,t){if(null===t.argument)return new I(S);const n=J(e,t.argument);return new I(n)}function fe(t,n){const r=e(n.id);return t.globalScope[r]={value:new _(n,t)},S}function pe(t,n){const r=e(n.specifiers[0].local),o=t.libraryResolver.loadLibrary(r);let i;return t.libraryResolver._moduleSingletons?.has(o.uri)?i=t.libraryResolver._moduleSingletons.get(o.uri):(i=new z(o),i.loadModule(t),t.libraryResolver._moduleSingletons?.set(o.uri,i)),t.globalScope[r]={value:i},S}function he(t,n){if(Q(t,n.declaration),"FunctionDeclaration"===n.declaration.type)t.exports[e(n.declaration.id)]="function";else if("VariableDeclaration"===n.declaration.type)for(const r of n.declaration.declarations)t.exports[e(r.id)]="variable";return S}function de(e,t){for(let n=0;n<t.declarations.length;n++)we(e,t.declarations[n]);return S}function we(t,n){let r=null===n.init?null:J(t,n.init);if(r===S&&(r=null),"Identifier"!==n.id.type)throw new a(t,s.InvalidIdentifier,n);const o=e(n.id);null!=t.localScope?t.localScope[o]={value:r}:t.globalScope[o]={value:r}}function me(e,t){try{const n=J(e,t.object);if(null===n)throw new a(e,s.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(n instanceof l||v(n))return n.field(t.property.name);if(n instanceof q)return o(n,t.property.name,e,t);if(n instanceof z){if(!n.hasGlobal(t.property.name))throw new a(e,s.InvalidIdentifier,t);return n.global(t.property.name)}}throw new a(e,s.InvalidMemberAccessKey,t)}let r=J(e,t.property);if(n instanceof l||v(n)){if(P(r))return n.field(r);throw new a(e,s.InvalidMemberAccessKey,t)}if(n instanceof z){if(P(r))return n.global(r);throw new a(e,s.InvalidMemberAccessKey,t)}if(n instanceof q){if(P(r))return o(n,r,e,t);throw new a(e,s.InvalidMemberAccessKey,t)}if(V(n)){if(W(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new a(e,s.OutOfBounds,t);return n[r]}throw new a(e,s.InvalidMemberAccessKey,t)}if(P(n)){if(W(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new a(e,s.OutOfBounds,t);return n[r]}throw new a(e,s.InvalidMemberAccessKey,t)}if(b(n)){if(W(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length()+r),r>=n.length()||r<0)throw new a(e,s.OutOfBounds,t);return n.get(r)}throw new a(e,s.InvalidMemberAccessKey,t)}throw new a(e,s.InvalidMemberAccessKey,t)}catch(n){throw n}}function ge(e,t){try{const n=J(e,t.argument);if(G(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*y(n);if("+"===t.operator)return 1*y(n);if("~"===t.operator)return~y(n);throw new a(e,s.UnsupportedUnaryOperator,t)}if("~"===t.operator)return~y(n);if("-"===t.operator)return-1*y(n);if("+"===t.operator)return 1*y(n);throw new a(e,s.UnsupportedUnaryOperator,t)}catch(n){throw n}}function ye(e,t){try{const n=[];for(let r=0;r<t.elements.length;r++){const o=J(e,t.elements[r]);if(g(o))throw new a(e,s.NoFunctionInArray,t);o===S?n.push(null):n.push(o)}return n}catch(n){throw n}}function ve(e,t){try{const n=J(e,t.left),r=J(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return F(y(n),y(r),t.operator);case"==":return m(n,r);case"!=":return!m(n,r);case"<":case">":case"<=":case">=":return R(n,r,t.operator);case"+":return P(n)||P(r)?x(n)+x(r):y(n)+y(r);case"-":return y(n)-y(r);case"*":return y(n)*y(r);case"/":return y(n)/y(r);case"%":return y(n)%y(r);default:throw new a(e,s.UnsupportedOperator,t)}}catch(n){throw n}}function be(e,t){try{const n=J(e,t.left);if(G(n))switch(t.operator){case"||":{if(!0===n)return n;const r=J(e,t.right);if(G(r))return r;throw new a(e,s.LogicExpressionOrAnd,t)}case"&&":{if(!1===n)return n;const r=J(e,t.right);if(G(r))return r;throw new a(e,s.LogicExpressionOrAnd,t)}default:throw new a(e,s.LogicExpressionOrAnd,t)}throw new a(e,s.LogicalExpressionOnlyBoolean,t)}catch(n){throw n}}function Se(e,t,n){if(g(e))throw new a(t,s.NoFunctionInTemplateLiteral,n);return e}function xe(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){n+=t.expressions[r]?x(Se(J(e,t.expressions[r]),e,t)):"",r++}return n}function Re(t,n){try{const r=e(n);if(null!=t.localScope&&void 0!==t.localScope[r])return t.localScope[r].value;if(void 0!==t.globalScope[r])return t.globalScope[r].value;throw new a(t,s.InvalidIdentifier,n)}catch(r){throw r}}function Fe(t,n){try{if("MemberExpression"===n.callee.type){const e=J(t,n.callee.object);if(!(e instanceof z))throw new a(t,s.FunctionNotFound,n);const r=!1===n.callee.computed?n.callee.property.name:J(t,n.callee.property);if(!e.hasGlobal(r))throw new a(t,s.FunctionNotFound,n);const o=e.global(r);if(!g(o))throw new a(t,s.CallNonFunction,n);return o.call(t,n)}if("Identifier"!==n.callee.type)throw new a(t,s.FunctionNotFound,n);const r=e(n.callee);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];if(g(e.value))return e.value.call(t,n);throw new a(t,s.CallNonFunction,n)}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];if(g(e.value))return e.value.call(t,n);throw new a(t,s.CallNonFunction,n)}throw new a(t,s.FunctionNotFound,n)}catch(r){throw r}}const Ie={};function Ae(e,t,n,r){try{const o=t.arguments,i=J(e,o[n]);if(m(i,r))return J(e,o[n+1]);{const i=o.length-n;return 1===i?J(e,o[n]):2===i?null:3===i?J(e,o[n+2]):Ae(e,t,n+2,r)}}catch(o){throw o}}function Me(e,t,n,r){try{const o=t.arguments;if(!0===r)return J(e,o[n+1]);if(3===o.length-n)return J(e,o[n+2]);{const r=J(e,o[n+2]);if(!1===G(r))throw new a(e,s.BooleanConditionRequired,o[n+2]);return Me(e,t,n+2,r)}}catch(o){throw o}}function Ce(t,n,r,o){try{const i=t.body;if(r.length!==t.params.length)throw new a(n,s.WrongNumberOfParameters,o);if(null!=n.localScope)for(let o=0;o<r.length;o++)n.localScope[e(t.params[o])]={value:r[o]};const l=Q(n,i);if(l instanceof I)return l.value;if(l===M)throw new a(n,s.UnexpectedToken,o);if(l===C)throw new a(n,s.UnexpectedToken,o);return l instanceof A?l.value:l}catch(i){throw i}}E(Ie,H),Z(Ie,H),U(Ie,H),j(Ie,H),K(Ie,H),D(Ie,H),Ie.iif=function(e,t){try{if(!0===t.preparsed)throw new a(e,s.NeverReach,t);const n=t.arguments;w(null===n?[]:n,3,3,e,t);const r=J(e,n[0]);if(!1===G(r))throw new a(e,s.BooleanConditionRequired,t);return J(e,!0===r?n[1]:n[2])}catch(n){throw n}},Ie.defaultvalue=function(e,t){try{if(!0===t.preparsed)throw new a(e,s.NeverReach,t);const n=t.arguments;w(null===n?[]:n,2,3,e,t);const o=J(e,n[0]);if(3===n.length){const t=J(e,n[1]),i=r(o,t);return null!=i&&""!==i?i:J(e,n[2])}return null===o||""===o||void 0===o?J(e,n[1]):o}catch(n){throw n}},Ie.decode=function(e,t){try{if(!0===t.preparsed)throw new a(e,s.NeverReach,t);const n=t.arguments;if(n.length<2)throw new a(e,s.WrongNumberOfParameters,t);if(2===n.length)return J(e,n[1]);{if((n.length-1)%2==0)throw new a(e,s.WrongNumberOfParameters,t);const r=J(e,n[0]);return Ae(e,t,1,r)}}catch(n){throw n}},Ie.when=function(e,t){try{if(!0===t.preparsed)throw new a(e,s.NeverReach,t);const n=t.arguments;if(n.length<3)throw new a(e,s.WrongNumberOfParameters,t);if(n.length%2==0)throw new a(e,s.WrongNumberOfParameters,t);const r=J(e,n[0]);if(!1===G(r))throw new a(e,s.BooleanConditionRequired,n[0]);return Me(e,t,0,r)}catch(n){throw n}};for(const De in Ie)Ie[De]={value:new f(Ie[De])};const Ne=function(){};function Oe(e,t,n){const r=new Ne;e||(e={}),t||(t={});const o=new l({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});o.immutable=!1,r.textformatting={value:o};for(const i in t)r[i]={value:new f(t[i])};for(const i in e)r[i]={value:T(e[i])?u.createFromGraphic(e[i],n):e[i]};return r}Ne.prototype=Ie,Ne.prototype.infinity={value:Number.POSITIVE_INFINITY},Ne.prototype.pi={value:Math.PI};const Be={fixSpatialReference:N,parseArguments:Y,standardFunction:H};function ke(e){console.log(e)}function Ee(e){const t={mode:"sync",compiled:!1,functions:{},signatures:[],standardFunction:H,evaluateIdentifier:Re};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)Ie[n]={value:new f(t.functions[n])},Ne.prototype[n]=Ie[n];for(let n=0;n<t.signatures.length;n++)B(t.signatures[n],"sync")}function je(e,t){let r=t.spatialReference;null==r&&(r=new L({wkid:102100}));let o=null;e.usesModules&&(o=new n(new Map,e.loadedModules));const i={spatialReference:r,globalScope:Oe(t.vars,t.customfunctions,t.timeZone),localScope:null,services:t.services,exports:{},libraryResolver:o,console:t.console??ke,timeZone:t.timeZone??null,lrucache:t.lrucache,interceptor:t.interceptor,depthCounter:{depth:1}},l=ce(i,e);if(l instanceof I||l instanceof A){const e=l.value;if(e===S)return null;if(g(e))throw new a(i,s.IllegalResult,null);return e}if(l===S)return null;if(l===M)throw new a(i,s.IllegalResult,null);if(l===C)throw new a(i,s.IllegalResult,null);throw new a(i,s.NeverReach,null)}Ee([k]);export{je as executeScript,Ee as extend,Be as functionHelper};
5
+ import{toSymbolId as e}from"./arcadeEnvironment.js";import{ArcadeModule as t}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import{getNestedOptionalValue as r,geometryMember as o,getGeometryKeys as i}from"./containerUtils.js";import l from"./Dictionary.js";import{ArcadeExecutionError as a,ExecutionErrorCodes as s,ensureArcadeExecutionError as c}from"./executionError.js";import u from"./Feature.js";import{NativeFunction as f,ScopeMarshalledFunction as p,ArcadeFunction as h,wrapModuleScopedResponse as d}from"./FunctionWrapper.js";import{D as w,B as m,i as g,t as y,n as b,m as v,w as S,z as x,f as R,A as F,C as I,R as A,I as M,x as C,y as N,u as O,l as B}from"../chunks/languageUtils.js";import{addFunctionDeclaration as k}from"./treeAnalysis.js";import{A as E}from"../chunks/array.js";import{registerFunctions as j}from"./functions/date.js";import{registerFunctions as D}from"./functions/geometry.js";import{registerFunctions as U}from"./functions/geomsync.js";import{registerFunctions as K}from"./functions/maths.js";import{registerFunctions as Z}from"./functions/stats.js";import{registerFunctions as q}from"./functions/string.js";import L from"../geometry/Geometry.js";import G from"../geometry/SpatialReference.js";import{isBoolean as P,isString as V,isArray as W,isNumber as T,isGraphic as _}from"../support/guards.js";class z extends h{constructor(e,t){super(),this.definition=e,this.context=t}createFunction(e){return(...t)=>{const n={spatialReference:this.context.spatialReference,console:this.context.console,services:this.context.services,timeZone:this.context.timeZone??null,lrucache:this.context.lrucache,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,localScope:{},depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope};if(n.depthCounter.depth>64)throw new a(e,s.MaximumCallDepth,null);return Ne(this.definition,n,t,null)}}call(e,t){return J(e,t,((n,r,o)=>{const i={spatialReference:e.spatialReference,services:e.services,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,timeZone:e.timeZone??null,console:e.console,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};if(i.depthCounter.depth>64)throw new a(e,s.MaximumCallDepth,t);return Ne(this.definition,i,o,t)}))}marshalledCall(e,t,n,r){return r(e,t,((o,i,l)=>{const a={spatialReference:e.spatialReference,globalScope:n.globalScope,services:e.services,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};return l=l.map((t=>!g(t)||t instanceof p?t:d(t,e,r))),d(Ne(this.definition,a,l,t),n,r)}))}}class Y extends t{constructor(e){super(),this.source=e}global(t){const n=this.executingContext.globalScope[e(t)];if(g(n.value)&&!(n.value instanceof p)){const e=new p;e.fn=n.value,e.parameterEvaluator=J,e.context=this.executingContext,n.value=e}return n.value}setGlobal(t,n){if(g(n))throw new a(null,s.AssignModuleFunction,null);this.executingContext.globalScope[e(t)]={value:n}}hasGlobal(t){return void 0===this.executingContext.exports[t]&&(t=e(t)),void 0!==this.executingContext.exports[t]}loadModule(e){let t=e.spatialReference;null==t&&(t=new G({wkid:102100})),this.moduleScope=Be({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:t,globalScope:this.moduleScope,localScope:null,libraryResolver:new n(e.libraryResolver._moduleSingletons,this.source.syntax.loadedModules),exports:{},services:e.services,console:e.console??Ee,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,depthCounter:{depth:1}},ue(this.executingContext,this.source.syntax)}}function H(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(Q(e,t.arguments[r]));return n}function J(e,t,n){try{return!0===t.preparsed?n(e,null,t.arguments):n(e,t,H(e,t))}catch(r){throw r}}function Q(e,t){try{switch(t.type){case"AssignmentExpression":return ae(e,t);case"UpdateExpression":return ie(e,t);case"TemplateLiteral":return Re(e,t);case"Identifier":return Fe(e,t);case"MemberExpression":return ge(e,t);case"Literal":return t.value;case"CallExpression":return Ie(e,t);case"UnaryExpression":return ye(e,t);case"BinaryExpression":return ve(e,t);case"LogicalExpression":return Se(e,t);case"ArrayExpression":return be(e,t);case"ObjectExpression":return $(e,t);default:throw new a(e,s.Unrecognized,t)}}catch(n){throw c(e,t,n)}}function X(e,t){switch(t.type){case"EmptyStatement":return S;case"VariableDeclaration":return we(e,t);case"ImportDeclaration":return he(e,t);case"ExportNamedDeclaration":return de(e,t);case"BlockStatement":return ue(e,t);case"FunctionDeclaration":return pe(e,t);case"ReturnStatement":return fe(e,t);case"IfStatement":return ce(e,t);case"ExpressionStatement":return se(e,t);case"BreakStatement":return C;case"ContinueStatement":return N;case"ForStatement":return ne(e,t);case"ForInStatement":return ee(e,t);case"ForOfStatement":return te(e,t);case"WhileStatement":return re(e,t);default:throw new a(e,s.Unrecognized,t)}}function $(e,t){const n={},r=new Map;for(let i=0;i<t.properties.length;i++){const o=t.properties[i],l="Identifier"===o.key.type?o.key.name:Q(e,o.key),c=Q(e,o.value);if(g(c))throw new a(e,s.NoFunctionInDictionary,t);if(!1===V(l))throw new a(e,s.KeyMustBeString,t);let u=l.toString();const f=u.toLowerCase();r.has(f)?u=r.get(f):r.set(f,u),n[u]=c===S?null:c}const o=new l(n);return o.immutable=!1,o}function ee(t,n){const r=Q(t,n.right);"VariableDeclaration"===n.left.type&&we(t,n.left);const o=e("VariableDeclaration"===n.left.type?n.left.declarations[0].id:n.left);let c=null;if(null!=t.localScope&&void 0!==t.localScope[o]&&(c=t.localScope[o]),null===c&&void 0!==t.globalScope[o]&&(c=t.globalScope[o]),null===c)throw new a(t,s.InvalidIdentifier,n);if(W(r)||V(r)){const e=r.length;for(let r=0;r<e;r++){c.value=r;const e=X(t,n.body);if(e===C)break;if(e instanceof A)return e}return S}if(v(r)){for(let e=0;e<r.length();e++){c.value=e;const r=X(t,n.body);if(r===C)break;if(r instanceof A)return r}return S}if(r instanceof l||x(r)){const e=r.keys();for(let r=0;r<e.length;r++){c.value=e[r];const o=X(t,n.body);if(o===C)break;if(o instanceof A)return o}return S}if(B(r)){for(const e of i(r)){c.value=e;const r=X(t,n.body);if(r===C)break;if(r instanceof A)return r}return S}return S}function te(t,n){const r=Q(t,n.right);"VariableDeclaration"===n.left.type&&X(t,n.left);const c=e("VariableDeclaration"===n.left.type?n.left.declarations[0].id:n.left);let u=null;if(null!=t.localScope&&void 0!==t.localScope[c]&&(u=t.localScope[c]),null===u&&void 0!==t.globalScope[c]&&(u=t.globalScope[c]),null===u)throw new a(t,s.InvalidIdentifier,n);if(W(r)||V(r)){const e=r.length;for(let o=0;o<e;o++){if(o>=r.length)throw new a(t,s.OutOfBounds,n);u.value=r[o];const e=X(t,n.body);if(e===C)break;if(e instanceof A)return e}return S}if(v(r)){for(let e=0;e<r.length();e++){u.value=r.get(e);const o=X(t,n.body);if(o===C)break;if(o instanceof A)return o}return S}if(r instanceof l||x(r)){for(const e of r.keys()){const o=r.field(e);u.value=new l({key:e,value:o});const i=X(t,n.body);if(i===C)break;if(i instanceof A)return i}return S}if(B(r)){for(const e of i(r)){const i=o(r,e,t,n,1);u.value=new l({key:e,value:i});const a=X(t,n.body);if(a===C)break;if(a instanceof A)return a}return S}return S}function ne(e,t){null!==t.init&&("VariableDeclaration"===t.init.type?X(e,t.init):Q(e,t.init));const n={testResult:!0,lastAction:S};do{oe(e,t,n)}while(!0===n.testResult);return n.lastAction instanceof A?n.lastAction:S}function re(e,t){const n={testResult:!0,lastAction:S};if(n.testResult=Q(e,t.test),!1===n.testResult)return S;if(!0!==n.testResult)throw new a(e,s.BooleanConditionRequired,t);for(;!0===n.testResult&&(n.lastAction=X(e,t.body),n.lastAction!==C)&&!(n.lastAction instanceof A);)if(n.testResult=Q(e,t.test),!0!==n.testResult&&!1!==n.testResult)throw new a(e,s.BooleanConditionRequired,t);return n.lastAction instanceof A?n.lastAction:S}function oe(e,t,n){if(null!==t.test){if(n.testResult=Q(e,t.test),!1===n.testResult)return;if(!0!==n.testResult)throw new a(e,s.BooleanConditionRequired,t)}n.lastAction=X(e,t.body),n.lastAction!==C?n.lastAction instanceof A?n.testResult=!1:null!==t.update&&Q(e,t.update):n.testResult=!1}function ie(t,n){if("CallExpression"===n.argument.type)throw new a(t,s.NeverReach,n);let r;if("MemberExpression"===n.argument.type){const e=Q(t,n.argument.object);let o;if(!0===n.argument.computed)o=Q(t,n.argument.property);else{if("Identifier"!==n.argument.property.type)throw new a(t,s.Unrecognized,n);o=n.argument.property.name}if(W(e)){if(!T(o))throw new a(t,s.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>=e.length)throw new a(t,s.OutOfBounds,n);r=y(e[o]),e[o]="++"===n.operator?r+1:r-1}else if(e instanceof l){if(!1===V(o))throw new a(t,s.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new a(t,s.FieldNotFound,n);r=y(e.field(o)),e.setField(o,"++"===n.operator?r+1:r-1)}else if(b(e)){if(!1===V(o))throw new a(t,s.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new a(t,s.FieldNotFound,n);r=y(e.field(o)),e.setField(o,"++"===n.operator?r+1:r-1)}else{if(v(e))throw new a(t,s.Immutable,n);if(!(e instanceof Y))throw new a(t,s.InvalidParameter,n);if(!1===V(o))throw new a(t,s.ModuleAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new a(t,s.ModuleExportNotFound,n);r=y(e.global(o)),e.setGlobal(o,"++"===n.operator?r+1:r-1)}return!1===n.prefix?r:"++"===n.operator?r+1:r-1}const o=e(n.argument);if(null!=t.localScope&&void 0!==t.localScope[o])return r=y(t.localScope[o].value),t.localScope[o]={value:"++"===n.operator?r+1:r-1},!1===n.prefix?r:"++"===n.operator?r+1:r-1;if(void 0!==t.globalScope[o])return r=y(t.globalScope[o].value),t.globalScope[o]={value:"++"===n.operator?r+1:r-1},!1===n.prefix?r:"++"===n.operator?r+1:r-1;throw new a(t,s.InvalidIdentifier,n)}function le(e,t,n,r,o){switch(t){case"=":return e===S?null:e;case"/=":return y(n)/y(e);case"*=":return y(n)*y(e);case"-=":return y(n)-y(e);case"+=":return V(n)||V(e)?R(n)+R(e):y(n)+y(e);case"%=":return y(n)%y(e);default:throw new a(o,s.UnsupportedOperator,r)}}function ae(t,n){if("MemberExpression"===n.left.type){const e=Q(t,n.left.object);let r;if(!0===n.left.computed)r=Q(t,n.left.property);else{if("Identifier"!==n.left.property.type)throw new a(t,s.InvalidIdentifier,n);r=n.left.property.name}const o=Q(t,n.right);if(W(e)){if(!T(r))throw new a(t,s.ArrayAccessorMustBeNumber,n);if(r<0&&(r=e.length+r),r<0||r>e.length)throw new a(t,s.OutOfBounds,n);if(r===e.length){if("="!==n.operator)throw new a(t,s.OutOfBounds,n);e[r]=le(o,n.operator,e[r],n,t)}else e[r]=le(o,n.operator,e[r],n,t)}else if(e instanceof l){if(!1===V(r))throw new a(t,s.KeyAccessorMustBeString,n);if(!0===e.hasField(r))e.setField(r,le(o,n.operator,e.field(r),n,t));else{if("="!==n.operator)throw new a(t,s.FieldNotFound,n,{key:r});e.setField(r,le(o,n.operator,null,n,t))}}else if(b(e)){if(!1===V(r))throw new a(t,s.KeyAccessorMustBeString,n);if(!0===e.hasField(r))e.setField(r,le(o,n.operator,e.field(r),n,t));else{if("="!==n.operator)throw new a(t,s.FieldNotFound,n,{key:r});e.setField(r,le(o,n.operator,null,n,t))}}else{if(v(e))throw new a(t,s.Immutable,n);if(!(e instanceof Y))throw new a(t,s.InvalidIdentifier,n);if(!1===V(r))throw new a(t,s.ModuleAccessorMustBeString,n);if(!0!==e.hasGlobal(r))throw new a(t,s.ModuleExportNotFound,n);e.setGlobal(r,le(o,n.operator,e.global(r),n,t))}return S}const r=e(n.left),o=Q(t,n.right);if(null!=t.localScope&&void 0!==t.localScope[r])return t.localScope[r]={value:le(o,n.operator,t.localScope[r].value,n,t)},S;if(void 0!==t.globalScope[r])return t.globalScope[r]={value:le(o,n.operator,t.globalScope[r].value,n,t)},S;throw new a(t,s.InvalidIdentifier,n)}function se(e,t){const n=Q(e,t.expression);return n===S?S:new M(n)}function ce(e,t){const n=Q(e,t.test);if(!0===n)return X(e,t.consequent);if(!1===n)return null!==t.alternate?X(e,t.alternate):S;throw new a(e,s.BooleanConditionRequired,t)}function ue(e,t){let n=S;for(let r=0;r<t.body.length;r++)if(n=X(e,t.body[r]),n instanceof A||n===C||n===N)return n;return n}function fe(e,t){if(null===t.argument)return new A(S);const n=Q(e,t.argument);return new A(n)}function pe(t,n){const r=e(n.id);return t.globalScope[r]={value:new z(n,t)},S}function he(t,n){const r=e(n.specifiers[0].local),o=t.libraryResolver.loadLibrary(r);let i;return t.libraryResolver._moduleSingletons?.has(o.uri)?i=t.libraryResolver._moduleSingletons.get(o.uri):(i=new Y(o),i.loadModule(t),t.libraryResolver._moduleSingletons?.set(o.uri,i)),t.globalScope[r]={value:i},S}function de(t,n){if(X(t,n.declaration),"FunctionDeclaration"===n.declaration.type)t.exports[e(n.declaration.id)]="function";else if("VariableDeclaration"===n.declaration.type)for(const r of n.declaration.declarations)t.exports[e(r.id)]="variable";return S}function we(e,t){for(let n=0;n<t.declarations.length;n++)me(e,t.declarations[n]);return S}function me(t,n){let r=null===n.init?null:Q(t,n.init);if(r===S&&(r=null),"Identifier"!==n.id.type)throw new a(t,s.InvalidIdentifier,n);const o=e(n.id);null!=t.localScope?t.localScope[o]={value:r}:t.globalScope[o]={value:r}}function ge(e,t){try{const n=Q(e,t.object);if(null===n)throw new a(e,s.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(n instanceof l||x(n))return n.field(t.property.name);if(n instanceof L)return o(n,t.property.name,e,t);if(n instanceof Y){if(!n.hasGlobal(t.property.name))throw new a(e,s.InvalidIdentifier,t);return n.global(t.property.name)}}throw new a(e,s.InvalidMemberAccessKey,t)}let r=Q(e,t.property);if(n instanceof l||x(n)){if(V(r))return n.field(r);throw new a(e,s.InvalidMemberAccessKey,t)}if(n instanceof Y){if(V(r))return n.global(r);throw new a(e,s.InvalidMemberAccessKey,t)}if(n instanceof L){if(V(r))return o(n,r,e,t);throw new a(e,s.InvalidMemberAccessKey,t)}if(W(n)){if(T(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new a(e,s.OutOfBounds,t);return n[r]}throw new a(e,s.InvalidMemberAccessKey,t)}if(V(n)){if(T(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new a(e,s.OutOfBounds,t);return n[r]}throw new a(e,s.InvalidMemberAccessKey,t)}if(v(n)){if(T(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length()+r),r>=n.length()||r<0)throw new a(e,s.OutOfBounds,t);return n.get(r)}throw new a(e,s.InvalidMemberAccessKey,t)}throw new a(e,s.InvalidMemberAccessKey,t)}catch(n){throw n}}function ye(e,t){try{const n=Q(e,t.argument);if(P(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*y(n);if("+"===t.operator)return 1*y(n);if("~"===t.operator)return~y(n);throw new a(e,s.UnsupportedUnaryOperator,t)}if("~"===t.operator)return~y(n);if("-"===t.operator)return-1*y(n);if("+"===t.operator)return 1*y(n);throw new a(e,s.UnsupportedUnaryOperator,t)}catch(n){throw n}}function be(e,t){try{const n=[];for(let r=0;r<t.elements.length;r++){const o=Q(e,t.elements[r]);if(g(o))throw new a(e,s.NoFunctionInArray,t);o===S?n.push(null):n.push(o)}return n}catch(n){throw n}}function ve(e,t){try{const n=Q(e,t.left),r=Q(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return I(y(n),y(r),t.operator);case"==":return m(n,r);case"!=":return!m(n,r);case"<":case">":case"<=":case">=":return F(n,r,t.operator);case"+":return V(n)||V(r)?R(n)+R(r):y(n)+y(r);case"-":return y(n)-y(r);case"*":return y(n)*y(r);case"/":return y(n)/y(r);case"%":return y(n)%y(r);default:throw new a(e,s.UnsupportedOperator,t)}}catch(n){throw n}}function Se(e,t){try{const n=Q(e,t.left);if(P(n))switch(t.operator){case"||":{if(!0===n)return n;const r=Q(e,t.right);if(P(r))return r;throw new a(e,s.LogicExpressionOrAnd,t)}case"&&":{if(!1===n)return n;const r=Q(e,t.right);if(P(r))return r;throw new a(e,s.LogicExpressionOrAnd,t)}default:throw new a(e,s.LogicExpressionOrAnd,t)}throw new a(e,s.LogicalExpressionOnlyBoolean,t)}catch(n){throw n}}function xe(e,t,n){if(g(e))throw new a(t,s.NoFunctionInTemplateLiteral,n);return e}function Re(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){n+=t.expressions[r]?R(xe(Q(e,t.expressions[r]),e,t)):"",r++}return n}function Fe(t,n){try{const r=e(n);if(null!=t.localScope&&void 0!==t.localScope[r])return t.localScope[r].value;if(void 0!==t.globalScope[r])return t.globalScope[r].value;throw new a(t,s.InvalidIdentifier,n)}catch(r){throw r}}function Ie(t,n){try{if("MemberExpression"===n.callee.type){const e=Q(t,n.callee.object);if(!(e instanceof Y))throw new a(t,s.FunctionNotFound,n);const r=!1===n.callee.computed?n.callee.property.name:Q(t,n.callee.property);if(!e.hasGlobal(r))throw new a(t,s.FunctionNotFound,n);const o=e.global(r);if(!g(o))throw new a(t,s.CallNonFunction,n);return o.call(t,n)}if("Identifier"!==n.callee.type)throw new a(t,s.FunctionNotFound,n);const r=e(n.callee);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];if(g(e.value))return e.value.call(t,n);throw new a(t,s.CallNonFunction,n)}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];if(g(e.value))return e.value.call(t,n);throw new a(t,s.CallNonFunction,n)}throw new a(t,s.FunctionNotFound,n)}catch(r){throw r}}const Ae={};function Me(e,t,n,r){try{const o=t.arguments,i=Q(e,o[n]);if(m(i,r))return Q(e,o[n+1]);{const i=o.length-n;return 1===i?Q(e,o[n]):2===i?null:3===i?Q(e,o[n+2]):Me(e,t,n+2,r)}}catch(o){throw o}}function Ce(e,t,n,r){try{const o=t.arguments;if(!0===r)return Q(e,o[n+1]);if(3===o.length-n)return Q(e,o[n+2]);{const r=Q(e,o[n+2]);if(!1===P(r))throw new a(e,s.BooleanConditionRequired,o[n+2]);return Ce(e,t,n+2,r)}}catch(o){throw o}}function Ne(t,n,r,o){try{const i=t.body;if(r.length!==t.params.length)throw new a(n,s.WrongNumberOfParameters,o);if(null!=n.localScope)for(let o=0;o<r.length;o++)n.localScope[e(t.params[o])]={value:r[o]};const l=X(n,i);if(l instanceof A)return l.value;if(l===C)throw new a(n,s.UnexpectedToken,o);if(l===N)throw new a(n,s.UnexpectedToken,o);return l instanceof M?l.value:l}catch(i){throw i}}j(Ae,J),q(Ae,J),K(Ae,J),D(Ae,J),Z(Ae,J),U(Ae,J),Ae.iif=function(e,t){try{if(!0===t.preparsed)throw new a(e,s.NeverReach,t);const n=t.arguments;w(null===n?[]:n,3,3,e,t);const r=Q(e,n[0]);if(!1===P(r))throw new a(e,s.BooleanConditionRequired,t);return Q(e,!0===r?n[1]:n[2])}catch(n){throw n}},Ae.defaultvalue=function(e,t){try{if(!0===t.preparsed)throw new a(e,s.NeverReach,t);const n=t.arguments;w(null===n?[]:n,2,3,e,t);const o=Q(e,n[0]);if(3===n.length){const t=Q(e,n[1]),i=r(o,t);return null!=i&&""!==i?i:Q(e,n[2])}return null===o||""===o||void 0===o?Q(e,n[1]):o}catch(n){throw n}},Ae.decode=function(e,t){try{if(!0===t.preparsed)throw new a(e,s.NeverReach,t);const n=t.arguments;if(n.length<2)throw new a(e,s.WrongNumberOfParameters,t);if(2===n.length)return Q(e,n[1]);{if((n.length-1)%2==0)throw new a(e,s.WrongNumberOfParameters,t);const r=Q(e,n[0]);return Me(e,t,1,r)}}catch(n){throw n}},Ae.when=function(e,t){try{if(!0===t.preparsed)throw new a(e,s.NeverReach,t);const n=t.arguments;if(n.length<3)throw new a(e,s.WrongNumberOfParameters,t);if(n.length%2==0)throw new a(e,s.WrongNumberOfParameters,t);const r=Q(e,n[0]);if(!1===P(r))throw new a(e,s.BooleanConditionRequired,n[0]);return Ce(e,t,0,r)}catch(n){throw n}};for(const Ue in Ae)Ae[Ue]={value:new f(Ae[Ue])};const Oe=function(){};function Be(e,t,n){const r=new Oe;e||(e={}),t||(t={});const o=new l({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});o.immutable=!1,r.textformatting={value:o};for(const i in t)r[i]={value:new f(t[i])};for(const i in e)r[i]={value:_(e[i])?u.createFromGraphic(e[i],n):e[i]};return r}Oe.prototype=Ae,Oe.prototype.infinity={value:Number.POSITIVE_INFINITY},Oe.prototype.pi={value:Math.PI};const ke={fixSpatialReference:O,parseArguments:H,standardFunction:J};function Ee(e){console.log(e)}function je(e){const t={mode:"sync",compiled:!1,functions:{},signatures:[],standardFunction:J,evaluateIdentifier:Fe};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)Ae[n]={value:new f(t.functions[n])},Oe.prototype[n]=Ae[n];for(let n=0;n<t.signatures.length;n++)k(t.signatures[n],"sync")}function De(e,t){let r=t.spatialReference;null==r&&(r=new G({wkid:102100}));let o=null;e.usesModules&&(o=new n(new Map,e.loadedModules));const i={spatialReference:r,globalScope:Be(t.vars,t.customfunctions,t.timeZone),localScope:null,services:t.services,exports:{},libraryResolver:o,console:t.console??Ee,timeZone:t.timeZone??null,lrucache:t.lrucache,interceptor:t.interceptor,depthCounter:{depth:1}},l=ue(i,e);if(l instanceof A||l instanceof M){const e=l.value;if(e===S)return null;if(g(e))throw new a(i,s.IllegalResult,null);return e}if(l===S)return null;if(l===C)throw new a(i,s.IllegalResult,null);if(l===N)throw new a(i,s.IllegalResult,null);throw new a(i,s.NeverReach,null)}je([E]);export{De as executeScript,je as extend,ke as functionHelper};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import e from"./Dictionary.js";import{ArcadeExecutionError as a,ExecutionErrorCodes as t}from"./executionError.js";import n from"./ImmutablePathArray.js";import r from"./ImmutablePointArray.js";import{m as s,n as i,q as c,l}from"../chunks/languageUtils.js";import o from"../core/Accessor.js";import{isArray as u,isString as h,isNumber as p}from"../support/guards.js";const f={point:["hasZ","hasM","spatialReference","type","x","y","z","m"],multipoint:["hasZ","hasM","spatialReference","type","points"],polyline:["hasZ","hasM","spatialReference","type","paths"],polygon:["hasZ","hasM","spatialReference","type","rings"],extent:["hasZ","hasM","spatialReference","type","xmin","xmax","ymin","ymax","zmin","zmax","mmin","mmax"]};function m(e){return f[e.type]}let d=0;function y(s,i,c,l,u=1){let h;switch(i=i.toLowerCase()){case"hasz":{const e=s.hasZ;return void 0!==e&&e}case"hasm":{const e=s.hasM;return void 0!==e&&e}case"spatialreference":{let a=s.spatialReference._arcadeCacheId;if(void 0===a){let e=!0;o.isFrozen(s.spatialReference)&&(e=!1),e&&(d++,s.spatialReference._arcadeCacheId=d,a=d)}const t=new e({wkt:s.spatialReference.wkt,wkid:s.spatialReference.wkid});return void 0!==a&&(t._arcadeCacheId="SPREF"+a.toString()),t}}switch(s.type){case"extent":switch(i){case"xmin":case"xmax":case"ymin":case"ymax":case"zmin":case"zmax":case"mmin":case"mmax":{const e=s[i];return void 0!==e?e:null}case"type":return"Extent"}break;case"polygon":switch(i){case"rings":h=s.cache._arcadeCacheId,void 0===h&&(d++,h=d,s.cache._arcadeCacheId=h);return new n(s.rings,s.spatialReference,!0===s.hasZ,!0===s.hasM,h);case"type":return"Polygon"}break;case"point":switch(i){case"x":case"y":case"z":case"m":return s[i]??null;case"type":return"Point"}break;case"polyline":switch(i){case"paths":h=s.cache._arcadeCacheId,void 0===h&&(d++,h=d,s.cache._arcadeCacheId=h);return new n(s.paths,s.spatialReference,!0===s.hasZ,!0===s.hasM,h);case"type":return"Polyline"}break;case"multipoint":switch(i){case"points":h=s.cache._arcadeCacheId,void 0===h&&(d++,h=d,s.cache._arcadeCacheId=h);return new r(s.points,s.spatialReference,!0===s.hasZ,!0===s.hasM,h,1);case"type":return"Multipoint"}}if(1===u)throw new a(c,t.InvalidIdentifier,l);return 2===u?{keystate:"notfound"}:null}function x(e,a){let t,n=e;if(null==n)return null;if(u(a))t=a;else if(s(a))t=a.toArray();else{if(null==a)return null;t=[a]}for(const r of t){if(i(n)){if(!1===h(r))return null;if(!n.hasField(r))return null;n=n.field(r)}else if(c(n)){if(!1===h(r))return null;if(!n.hasField(r))return null;n=n.field(r)}else if(l(n)){if(!1===h(r))return null;n=y(n,r,null,null,0)}else if(u(n)){if(!1===p(r))return null;n=r>=0?n[r]:n[n.length+r]}else{if(!s(n))return null;if(!1===p(r))return null;n=r>=0?n.get(r):n.get(n.length()+r)}if(null==n)return null}return n}export{y as geometryMember,m as getGeometryKeys,x as getNestedOptionalValue};
5
+ import e from"./Dictionary.js";import{ArcadeExecutionError as a,ExecutionErrorCodes as t}from"./executionError.js";import r from"./ImmutablePathArray.js";import n from"./ImmutablePointArray.js";import{m as s,z as i,l as c}from"../chunks/languageUtils.js";import l from"../core/Accessor.js";import{isArray as o,isString as u,isNumber as h}from"../support/guards.js";const p={point:["hasZ","hasM","spatialReference","type","x","y","z","m"],multipoint:["hasZ","hasM","spatialReference","type","points"],polyline:["hasZ","hasM","spatialReference","type","paths"],polygon:["hasZ","hasM","spatialReference","type","rings"],extent:["hasZ","hasM","spatialReference","type","xmin","xmax","ymin","ymax","zmin","zmax","mmin","mmax"]};function f(e){return p[e.type]}let m=0;function d(s,i,c,o,u=1){let h;switch(i=i.toLowerCase()){case"hasz":{const e=s.hasZ;return void 0!==e&&e}case"hasm":{const e=s.hasM;return void 0!==e&&e}case"spatialreference":{let a=s.spatialReference._arcadeCacheId;if(void 0===a){let e=!0;l.isFrozen(s.spatialReference)&&(e=!1),e&&(m++,s.spatialReference._arcadeCacheId=m,a=m)}const t=new e({wkt:s.spatialReference.wkt,wkid:s.spatialReference.wkid});return void 0!==a&&(t._arcadeCacheId="SPREF"+a.toString()),t}}switch(s.type){case"extent":switch(i){case"xmin":case"xmax":case"ymin":case"ymax":case"zmin":case"zmax":case"mmin":case"mmax":{const e=s[i];return void 0!==e?e:null}case"type":return"Extent"}break;case"polygon":switch(i){case"rings":h=s.cache._arcadeCacheId,void 0===h&&(m++,h=m,s.cache._arcadeCacheId=h);return new r(s.rings,s.spatialReference,!0===s.hasZ,!0===s.hasM,h);case"type":return"Polygon"}break;case"point":switch(i){case"x":case"y":case"z":case"m":return s[i]??null;case"type":return"Point"}break;case"polyline":switch(i){case"paths":h=s.cache._arcadeCacheId,void 0===h&&(m++,h=m,s.cache._arcadeCacheId=h);return new r(s.paths,s.spatialReference,!0===s.hasZ,!0===s.hasM,h);case"type":return"Polyline"}break;case"multipoint":switch(i){case"points":h=s.cache._arcadeCacheId,void 0===h&&(m++,h=m,s.cache._arcadeCacheId=h);return new n(s.points,s.spatialReference,!0===s.hasZ,!0===s.hasM,h,1);case"type":return"Multipoint"}}if(1===u)throw new a(c,t.InvalidIdentifier,o);return 2===u?{keystate:"notfound"}:null}function y(e,a){let t,r=e;if(null==r)return null;if(o(a))t=a;else if(s(a))t=a.toArray();else{if(null==a)return null;t=[a]}for(const n of t){if(i(r)){if(!1===u(n))return null;if(!r.hasField(n))return null;r=r.field(n)}else if(c(r)){if(!1===u(n))return null;r=d(r,n,null,null,0)}else if(o(r)){if(!1===h(n))return null;r=n>=0?r[n]:r[r.length+n]}else{if(!s(r))return null;if(!1===h(n))return null;r=n>=0?r.get(n):r.get(r.length()+n)}if(null==r)return null}return r}export{d as geometryMember,f as getGeometryKeys,y as getNestedOptionalValue};