@arcgis/core 4.29.0-next.20240103 → 4.29.0-next.20240104

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 (183) hide show
  1. package/WebMap.js +1 -1
  2. package/WebScene.js +1 -1
  3. package/arcade/ArcadeDate.js +1 -1
  4. package/arcade/arcadeAsyncRuntime.js +1 -1
  5. package/arcade/arcadeCompiler.js +1 -1
  6. package/arcade/arcadeRuntime.js +1 -1
  7. package/arcade/executionError.js +1 -1
  8. package/arcade/featureset/support/errorsupport.js +1 -1
  9. package/arcade/functions/date.js +1 -1
  10. package/arcade/functions/featuresetbase.js +1 -1
  11. package/arcade/functions/featuresetgeom.js +1 -1
  12. package/arcade/functions/featuresetstats.js +1 -1
  13. package/arcade/functions/featuresetstring.js +1 -1
  14. package/arcade/functions/fieldStats.js +1 -1
  15. package/arcade/functions/geomasync.js +1 -1
  16. package/arcade/functions/geometry.js +1 -1
  17. package/arcade/functions/geomsync.js +1 -1
  18. package/arcade/functions/maths.js +1 -1
  19. package/arcade/functions/stats.js +1 -1
  20. package/arcade/functions/string.js +1 -1
  21. package/arcade/languageUtils.js +1 -1
  22. package/arcade/lib/arcade-parser.js +1 -1
  23. package/arcade/lib/error-handler.js +1 -1
  24. package/arcade/lib/parser.js +1 -1
  25. package/arcade/lib/scanner.js +1 -1
  26. package/arcade/lib/tokenizer.js +1 -1
  27. package/arcade/lib/types.js +1 -1
  28. package/arcade/validation/arcadeValidator.js +1 -1
  29. package/arcade/validation/diagnosticMessages.js +1 -1
  30. package/arcade/validation/languageKeywords.js +1 -1
  31. package/assets/esri/core/workers/RemoteClient.js +1 -1
  32. package/assets/esri/core/workers/chunks/{0b963b68ba07a5266c79.js → 15f223196b721dfc3655.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{8e1c96f6c518d95a39db.js → 16067b5aa3bc0f36d5b5.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{5c997181e2403dae77aa.js → 1b36d178d1888f329096.js} +8 -7
  35. package/assets/esri/core/workers/chunks/{0a9529efd96b90519f8e.js → 1f321ad53029e7c10247.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{ffad926201d92c4d6b4e.js → 2051a6315c2a0be825ca.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{d4cf3af5f5c30925539c.js → 25ddff03a200d0d2a7cf.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{45d7174973db1524d1b7.js → 343e64ad80e7e71fc09f.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{cd634692fe51124abaa7.js → 393c6db66be6bc773446.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{fbfdb4779198f4c35c65.js → 41c5766b0c3ff7ccf857.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{2220c9739154a9e56efe.js → 43b43a353c7e8d1c2eb4.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{6a354014099c1fd11cdc.js → 4cbbeeaed958eb3362e0.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{3a4598c384c4c31ab35b.js → 5459deb77c515bbbb2e8.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{5695dba9b29e1c2ebb88.js → 6a9ef9ff4bfdef271108.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{cbbbe62be2add1296d6f.js → 7639f0681191c96b4340.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{01dbff2fdff9d5c95892.js → 791800b89a210e07bfd2.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{67d3e73241d0a3cf7641.js → 7ea24ec83e9692ae3397.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{2588c2e9d3c4a94e9b31.js → 911a29d2b66ba7a810d4.js} +1 -1
  49. package/assets/esri/core/workers/chunks/{27bf780e2cd53e6740f0.js → 913f3b757c060bb7c7ac.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{a6e3783cc10fb505473e.js → 9c7dfd305773c3665575.js} +1 -1
  51. package/assets/esri/core/workers/chunks/a4d87d0663b74e31200c.js +1 -0
  52. package/assets/esri/core/workers/chunks/{4f7459402b5910288ab1.js → a9481e5592cf45ed3748.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{73950dfd2355733e2fc4.js → a9670a489f35970b8153.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{d3d075b4d18296fb08ad.js → aea75dc19a58cb68af45.js} +1 -1
  55. package/assets/esri/core/workers/chunks/{4f7c2c9e5100421b0bc2.js → af1e542bd42611c17cdb.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{fd03cd19d0d4db699dca.js → b230eec768232acfd2ab.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{389223ee653c1d67a8ad.js → b36790f0d9d737c4c253.js} +1 -1
  58. package/assets/esri/core/workers/chunks/{6a28f6c6581b67856edd.js → bdd9d065b958a8034975.js} +1 -1
  59. package/assets/esri/core/workers/chunks/{73f161a199d19396d504.js → cd71e052b9e6a91879e7.js} +1 -1
  60. package/assets/esri/core/workers/chunks/{995d0403b17c4d9df91b.js → d8329023d9d6630b06f7.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{5b7b357cb5fd26a7a2a7.js → df3518e4e881b1cf1063.js} +1 -1
  62. package/assets/esri/core/workers/chunks/{d03420f2d10b267ff026.js → e4fa004d44cd7c7e6b04.js} +1 -1
  63. package/assets/esri/core/workers/chunks/{793890ebbe4501f48a55.js → f82dfc9f7df5f67be82f.js} +1 -1
  64. package/assets/esri/core/workers/chunks/{01ec6da0c371bf43f48c.js → fa694273108cebebbc95.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{a379c80a223323df52f4.js → fdb4f2292f44ed7008fb.js} +1 -1
  66. package/assets/esri/themes/base/widgets/_FeatureTable.scss +40 -8
  67. package/assets/esri/themes/base/widgets/_NavigationToggle.scss +4 -92
  68. package/assets/esri/themes/dark/main.css +1 -1
  69. package/assets/esri/themes/light/main.css +1 -1
  70. package/assets/esri/themes/light/view.css +1 -1
  71. package/assets/esri/views/interactive/tooltip/t9n/Tooltip_zh-CN.json +1 -1
  72. package/assets/esri/widgets/ElevationProfile/t9n/ElevationProfile_cs.json +1 -1
  73. package/chunks/LineSeries.js +1 -1
  74. package/chunks/SSAO.glsl.js +3 -2
  75. package/chunks/Theme.js +1 -1
  76. package/chunks/Tick.js +1 -1
  77. package/chunks/array.js +1 -1
  78. package/chunks/chartUtilsAm5.js +1 -1
  79. package/chunks/languageUtils.js +1 -1
  80. package/core/MultiOriginJSONSupport.js +1 -1
  81. package/core/accessorSupport/MultiOriginStore.js +1 -1
  82. package/core/accessorSupport/PropertyOrigin.js +1 -1
  83. package/core/arrayUtils.js +1 -1
  84. package/core/uid.js +1 -1
  85. package/geometry/SpatialReference.js +1 -1
  86. package/geometry/support/frustum.js +1 -1
  87. package/geometry/support/spatialReferenceUtils.js +1 -1
  88. package/interfaces.d.ts +60 -7
  89. package/layers/RouteLayer.js +1 -1
  90. package/layers/graphics/data/queryUtils.js +1 -1
  91. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  92. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  93. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  94. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  95. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  96. package/layers/ogc/ogcFeatureUtils.js +1 -1
  97. package/layers/ogc/wfsUtils.js +1 -1
  98. package/layers/save/featureLayerUtils.js +1 -1
  99. package/layers/save/groupLayerUtils.js +1 -1
  100. package/layers/save/imageryUtils.js +1 -1
  101. package/layers/save/streamLayerUtils.js +1 -1
  102. package/layers/save/utils.js +1 -1
  103. package/layers/support/vectorTileLayerLoader.js +1 -1
  104. package/layers/video/VideoCameraSensorModel.js +1 -1
  105. package/layers/video/VideoController.js +1 -1
  106. package/layers/video/videoUtils.js +1 -1
  107. package/package.json +2 -2
  108. package/portal/support/portalItemUtils.js +1 -1
  109. package/portal/support/portalLayers.js +1 -1
  110. package/support/revision.js +1 -1
  111. package/views/2d/engine/vectorTiles/expression/expression.js +1 -1
  112. package/views/2d/engine/vectorTiles/expression/types.js +1 -1
  113. package/views/2d/engine/vectorTiles/style/Filter.js +1 -1
  114. package/views/2d/engine/vectorTiles/style/StyleProperty.js +1 -1
  115. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityMeshWriter.js +1 -1
  116. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityTechnique.js +1 -1
  117. package/views/2d/engine/webgl/shaderGraph/techniques/fill/ComplexFillMeshWriter.js +1 -1
  118. package/views/2d/engine/webgl/shaderGraph/techniques/fill/ComplexFillTechnique.js +1 -1
  119. package/views/2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js +1 -1
  120. package/views/2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillTechnique.js +1 -1
  121. package/views/2d/engine/webgl/shaderGraph/techniques/fill/FillMeshWriter.js +1 -1
  122. package/views/2d/engine/webgl/shaderGraph/techniques/fill/FillTechnique.js +1 -1
  123. package/views/2d/engine/webgl/shaderGraph/techniques/fill/OutlineFillMeshWriter.js +1 -1
  124. package/views/2d/engine/webgl/shaderGraph/techniques/fill/OutlineFillTechnique.js +1 -1
  125. package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternFillMeshWriter.js +1 -1
  126. package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternFillTechnique.js +1 -1
  127. package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillMeshWriter.js +1 -1
  128. package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillTechnique.js +1 -1
  129. package/views/2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapMeshWriter.js +1 -1
  130. package/views/2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapTechnique.js +1 -1
  131. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelTechnique.js +1 -1
  132. package/views/2d/engine/webgl/shaderGraph/techniques/line/LineTechnique.js +1 -1
  133. package/views/2d/engine/webgl/shaderGraph/techniques/line/TexturedLineMeshWriter.js +1 -1
  134. package/views/2d/engine/webgl/shaderGraph/techniques/line/TexturedLineTechnique.js +1 -1
  135. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  136. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerShader.js +1 -1
  137. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerTechnique.js +1 -1
  138. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriterRegistry.js +1 -1
  139. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/createMeshWriter.js +1 -1
  140. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartTechnique.js +1 -1
  141. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/ComplexFillShader.js +1 -1
  142. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/ComplexOutlineFillShader.js +1 -1
  143. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
  144. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LocalTileOffset.js +1 -1
  145. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/OutlineFillShader.js +1 -1
  146. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/TexturedLineShader.js +1 -1
  147. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/VisualVariableRotation.js +1 -1
  148. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/constants.js +1 -1
  149. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/hittestUtils.js +1 -1
  150. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/utils.js +1 -1
  151. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  152. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  153. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextTechnique.js +1 -1
  154. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  155. package/views/2d/layers/SubtypeGroupLayerView2D.js +1 -1
  156. package/views/2d/layers/features/FeatureContainer.js +1 -1
  157. package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
  158. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  159. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  160. package/views/3d/analysis/images/tilt-rotate-svg.js +1 -1
  161. package/views/3d/effects/ManagedFBO.js +5 -0
  162. package/views/3d/effects/RenderNode.js +1 -1
  163. package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
  164. package/views/3d/terrain/SphericalPatch.js +1 -1
  165. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  166. package/views/3d/webgl-engine/lib/ComponentUtils.js +1 -1
  167. package/views/3d/webgl-engine/lib/ModelDirtySet.js +1 -1
  168. package/views/3d/webgl-engine/lib/lodRendering/InstanceData.js +1 -1
  169. package/views/3d/webgl-engine/lib/lodRendering/RenderInstanceData.js +1 -1
  170. package/views/draw/DrawOperation.js +1 -1
  171. package/views/magnifier/overlay-svg.js +1 -1
  172. package/webdoc/support/webdocSaveUtils.js +1 -1
  173. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  174. package/widgets/FeatureTable/Grid/Column.js +1 -1
  175. package/widgets/FeatureTable/Grid/EditorColumn.js +1 -1
  176. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  177. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  178. package/widgets/FeatureTable/support/ColumnTemplateBase.js +1 -1
  179. package/widgets/NavigationToggle/css.js +1 -1
  180. package/widgets/NavigationToggle.js +1 -1
  181. package/widgets/Sketch/SketchViewModel.js +1 -1
  182. package/widgets/VideoPlayer/VideoPlayerViewModel.js +1 -1
  183. package/assets/esri/core/workers/chunks/693173874498ac59a8b1.js +0 -1
package/WebMap.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import{isSome as o}from"./core/arrayUtils.js";import s from"./core/Collection.js";import n from"./core/Error.js";import a from"./core/Loadable.js";import{loadAll as p}from"./core/loadAll.js";import l from"./core/Logger.js";import{destroyMaybe as u}from"./core/maybe.js";import{MultiOriginJSONMixin as m}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as h}from"./core/Promise.js";import{debounce as c}from"./core/promiseUtils.js";import{whenOnce as d}from"./core/reactiveUtils.js";import{addQueryParameter as g,isDataProtocol as f,dataComponents as w}from"./core/urlUtils.js";import{property as y}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import{reader as b}from"./core/accessorSupport/decorators/reader.js";import{subclass as A}from"./core/accessorSupport/decorators/subclass.js";import{writer as S}from"./core/accessorSupport/decorators/writer.js";import{readLoadable as v}from"./core/accessorSupport/read.js";import _ from"./geometry/SpatialReference.js";import j from"./networks/UtilityNetwork.js";import V from"./portal/PortalItem.js";import{TypeKeyword as I}from"./portal/support/portalItemUtils.js";import U from"./support/MapFloorInfo.js";import P from"./webdoc/GeotriggersInfo.js";import{SaveOperationType as O}from"./webdoc/interfaces.js";import k from"./webdoc/RangeInfo.js";import L from"./webdoc/Widgets.js";import{getOptimalThumbnailSize as F}from"./webdoc/support/thumbnailUtils.js";import{loadFromSource as N}from"./webdoc/support/webdocLoadUtils.js";import{getLayerJSON as R}from"./webdoc/support/writeUtils.js";import T from"./webmap/ApplicationProperties.js";import E from"./webmap/Bookmark.js";import B from"./webmap/InitialViewProperties.js";import{Version as J}from"./webmap/Version.js";import x from"./webmap/background/ColorBackground.js";const M=new J(2,29),Z="Web Map",W="webmap",$="web-map",C=s.ofType(E),G=s.ofType(j),z=new Map([["image/jpeg","jpeg"],["image/jpg","jpg"],["image/png","png"],["image/gif","gif"]]),D="ArcGIS Pro",q=I.JSAPI,H={currentVersion:M,createInitialViewProperties:()=>new B,parseVersion:J.parse,itemType:Z,name:W,origin:$};let K=class extends(m(a.LoadableMixin(h(r)))){constructor(e){super(e),this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1,this._thumbnailFilename=null,this._updateFromPromise=null,this.resourceReferences={portalItem:null,paths:[]},this.applicationProperties=null,this.bookmarks=new C,this.floorInfo=null,this.geotriggersInfo=null,this.initialViewProperties=new B,this.portalItem=null,this.presentation=null,this.sourceVersion=null,this.widgets=null,this.utilityNetworks=null,this._debouncedSaveOperations=c((async(e,t,r)=>{const{save:i,saveAs:o}=await import("./webdoc/support/webdocSaveUtils.js");switch(e){case O.SAVE:return i(H,this,t);case O.SAVE_AS:return o(H,this,r,t)}})),this.authoringApp=this.authoringAppVersion=null,this._isAuthoringAppSetByUser=this._isAuthoringAppVersionSetByUser=!1}destroy(){if(this.portalItem=u(this.portalItem),this.utilityNetworks){const e=this.utilityNetworks.removeAll();for(const t of e)t.destroy();this.utilityNetworks.destroy()}}initialize(){if(this.when().catch((e=>{l.getLogger(this).error("#load()","Failed to load web map",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t)}}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp=q}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}readInitialViewProperties(e,t){const r=new B;t.background&&(r.background=x.fromJSON(t.background));const o=t.initialState?.viewpoint;if(o){if(o.rotation){J.parse(t.version||"","webmap").lessThan(2,20)&&t.authoringApp===D&&(o.rotation*=-1)}r.viewpoint=i.fromJSON(o)}return t.mapRangeInfo&&(r.rangeInfo=k.fromJSON(t.mapRangeInfo)),t.spatialReference&&(r.spatialReference=_.fromJSON(t.spatialReference)),t.timeZone&&(r.timeZone=t.timeZone),r}writeInitialViewProperties(e,t,r,i){e&&(e.background?.color&&(t.background=e.background.write({},i)),e.viewpoint&&(t.initialState={viewpoint:e.viewpoint.write({},i)}),e.rangeInfo&&(t.mapRangeInfo=e.rangeInfo.toJSON(i)),e.spatialReference&&(t.spatialReference=e.spatialReference.write({},i)),t.timeZone=e.timeZone)}writeLayers(e,t,r,i){t[r]=this._writeLayers(e,i,"operational-layers")}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new J(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${M.major}.${M.minor}`}writeTables(e,t,r,i){const o=this._writeLayers(e,i,"tables");o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl||null}set thumbnailUrl(e){e?(this._override("thumbnailUrl",e),this._thumbnailFilename=this._generateCustomThumbnailFilename(e)):this._clearThumbnailOverride()}get updatingFromView(){return!!this._updateFromPromise}load(e){return this.addResolvingPromise(N(H,this)),Promise.resolve(this)}loadAll(){return p(this,(e=>{e(this.ground,this.basemap,this.layers,this.tables)}))}read(e,t){t={...t,origin:$};const r=this._getAuthoringPropsState();v(this,e,(t=>super.read(e,t)),t),this._restoreAuthoringPropsFromState(r)}write(e,t){if("loaded"!==this.loadStatus){const e=new n("webmap:not-loaded","Web map must be loaded before it can be serialized");throw l.getLogger(this).error("#toJSON()","Web map must be loaded before it can be serialized",this.loadError||this.loadStatus),e}return this._removeDanglingLayerRefs(),t={...t,origin:$,restrictedWebMapWriting:!0,webmap:this},super.write(e,t)}async save(e){return this._debouncedSaveOperations(O.SAVE,e)}async saveAs(e,t){return this._debouncedSaveOperations(O.SAVE_AS,t,e)}async updateFrom(e,t){const r=this._updateFromInternal(e,t);this._updateFromPromise=r,await r;r===this._updateFromPromise&&(this._updateFromPromise=null)}getLayerJSONFromResourceInfo(e){const t=this.resourceInfo;return this._collectAllLayersJSON([...t?.baseMap?.baseMapLayers||[],...t?.operationalLayers||[],...this.basemap?.resourceInfo?.data?.baseMapLayers||[]]).find((t=>t.id===e.id))}async updateItemThumbnail(){this.thumbnailUrl&&this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl,filename:this._thumbnailFilename})),this._clearThumbnailOverride())}getThumbnailState(){let e=this.thumbnailUrl;return e&&(e=this._isOverridden("thumbnailUrl")?e:g(e,"w","8192")),{thumbnailUrl:e,filename:this._thumbnailFilename}}restoreThumbnailFromState(e){this.thumbnailUrl=e.thumbnailUrl,this._thumbnailFilename=e.filename}_collectAllLayersJSON(e){return e.reduce(((e,t)=>(e.push(t),"GroupLayer"===t.layerType&&(e=e.concat(this._collectAllLayersJSON(t.layers||[]))),e)),[])}_writeLayers(e,t,r){t={...t,layerContainerType:r};return e.map((e=>R(e,"tables"===r?null:this.getLayerJSONFromResourceInfo(e),t))).filter(o).toArray()}_validateJSON(e){const t=J.parse(e.version||"","webmap");return M.validate(t),e.version=`${t.major}.${t.minor}`,e}_removeDanglingLayerRefs(){const e=this.applicationProperties,t=e?.viewing?.search,r=e=>this.allLayers.some((t=>t.id===e));if(t&&t.layers&&(t.layers=t.layers.filter((e=>r(e.id)))),t&&t.tables&&(t.tables=t.tables.filter((e=>this.tables.some((t=>t.id===e.id))))),e){const t=e.editing?.locationTracking;t?.info&&!r(t.info.layerId)&&(e.editing=null)}const i=this.presentation?.slides;i&&i.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>r(e.id))))}))}async _updateFromInternal(e,t){if(t??={},await d((()=>e.ready)),this._updateInitialViewProperties(e,t),e.map===this)for(const r of e.allLayerViews)"visible"in r&&"visible"in r.layer&&r._isOverridden("visible")&&(r.layer.visible=r.visible),"featureEffect"in r&&"featureEffect"in r.layer&&r._isOverridden("featureEffect")&&(r.layer.featureEffect=r.featureEffect);await this._updateThumbnailUrl(e,t)}_updateInitialViewProperties(e,t){if(t.backgroundExcluded||(this.initialViewProperties.background=e.background?.clone()),this.initialViewProperties.spatialReference=e.spatialReference?.clone(),this.initialViewProperties.timeZone=e.timeZone,t.viewpointExcluded||(this.initialViewProperties.viewpoint=new i({rotation:e.rotation,scale:t.scalePreserved?e.scale:null,targetGeometry:this._getViewExtent(e)})),!t.widgetsExcluded)for(const r of e.persistableViewModels)r.updateWebDocument(this)}_getViewExtent(e){const t=e.center.clone().normalize(),r=e.extent.clone(),i=r.width/2;return r.xmin=t.x-i,r.xmax=t.x+i,r}async _updateThumbnailUrl(e,t){if(t.thumbnailExcluded)return;const r=F(e,t.thumbnailSize),i=await e.takeScreenshot({format:"png",width:r.width,height:r.height});this._setAutoGeneratedThumbnail(i.dataUrl)}_setAutoGeneratedThumbnail(e){this.thumbnailUrl=e,this._thumbnailFilename=null}_clearThumbnailOverride(){this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"),this._thumbnailFilename=null}_generateCustomThumbnailFilename(e){if(f(e)){const t=w(e),r=t?.mediaType,i=r&&z.get(r.toLowerCase())||null,o=`thumbnail${Date.now()}`;return i?`${o}.${i}`:o}return null}_getAuthoringPropsState(){return{authoringApp:this.authoringApp,authoringAppVersion:this.authoringAppVersion,isAuthoringAppSetByUser:this._isAuthoringAppSetByUser,isAuthoringAppVersionSetByUser:this._isAuthoringAppVersionSetByUser}}_restoreAuthoringPropsFromState(e){e.isAuthoringAppSetByUser?this.authoringApp=e.authoringApp:this._isAuthoringAppSetByUser=!1,e.isAuthoringAppVersionSetByUser?this.authoringAppVersion=e.authoringAppVersion:this._isAuthoringAppVersionSetByUser=!1}static fromJSON(e){const t=e;if(!t)throw new n("webmap:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:t})}};K.VERSION=M,e([y()],K.prototype,"_updateFromPromise",void 0),e([y({type:T,json:{write:!0}})],K.prototype,"applicationProperties",void 0),e([y({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],K.prototype,"authoringApp",null),e([S("authoringApp")],K.prototype,"writeAuthoringApp",null),e([y({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],K.prototype,"authoringAppVersion",null),e([S("authoringAppVersion")],K.prototype,"writeAuthoringAppVersion",null),e([y({type:C,json:{write:{overridePolicy:e=>({enabled:!!(e&&e.length>0),ignoreOrigin:!0})}}})],K.prototype,"bookmarks",void 0),e([y({type:U,json:{name:"mapFloorInfo",write:!0}})],K.prototype,"floorInfo",void 0),e([y({type:P,json:{write:!0}})],K.prototype,"geotriggersInfo",void 0),e([y({type:B,nonNullable:!0,json:{read:{source:["background","initialState.viewpoint","mapRangeInfo","spatialReference","timeZone"]},write:{ignoreOrigin:!0,target:{background:{type:x},"initialState.viewpoint":{type:i},mapRangeInfo:{type:k},spatialReference:{type:_},"timeZone:":{type:String}}}}})],K.prototype,"initialViewProperties",void 0),e([b("initialViewProperties")],K.prototype,"readInitialViewProperties",null),e([S("initialViewProperties")],K.prototype,"writeInitialViewProperties",null),e([y({json:{read:!1,write:{target:"operationalLayers",ignoreOrigin:!0}}})],K.prototype,"layers",void 0),e([S("layers")],K.prototype,"writeLayers",null),e([y({type:V})],K.prototype,"portalItem",void 0),e([y({json:{write:!0}})],K.prototype,"presentation",void 0),e([y()],K.prototype,"resourceInfo",void 0),e([y({readOnly:!0,type:J,json:{read:{source:"version"},write:{allowNull:!0,ignoreOrigin:!0,target:"version",isRequired:!0}}})],K.prototype,"sourceVersion",void 0),e([b("sourceVersion")],K.prototype,"readSourceVersion",null),e([S("sourceVersion")],K.prototype,"writeSourceVersion",null),e([y({json:{read:!1,write:{ignoreOrigin:!0}}})],K.prototype,"tables",void 0),e([S("tables")],K.prototype,"writeTables",null),e([y()],K.prototype,"thumbnailUrl",null),e([y()],K.prototype,"updatingFromView",null),e([y({type:L,json:{write:!0}})],K.prototype,"widgets",void 0),e([y({type:G,json:{read:!0,write:!0}})],K.prototype,"utilityNetworks",void 0),K=e([A("esri.WebMap")],K);const Q=K;export{Q as default};
5
+ import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import{isSome as o}from"./core/arrayUtils.js";import s from"./core/Collection.js";import n from"./core/Error.js";import a from"./core/Loadable.js";import{loadAll as p}from"./core/loadAll.js";import l from"./core/Logger.js";import{destroyMaybe as u}from"./core/maybe.js";import{MultiOriginJSONMixin as m}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as h}from"./core/Promise.js";import{debounce as c}from"./core/promiseUtils.js";import{whenOnce as d}from"./core/reactiveUtils.js";import{addQueryParameter as g,isDataProtocol as f,dataComponents as w}from"./core/urlUtils.js";import{property as y}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import{reader as b}from"./core/accessorSupport/decorators/reader.js";import{subclass as A}from"./core/accessorSupport/decorators/subclass.js";import{writer as S}from"./core/accessorSupport/decorators/writer.js";import{readLoadable as v}from"./core/accessorSupport/read.js";import _ from"./geometry/SpatialReference.js";import j from"./networks/UtilityNetwork.js";import V from"./portal/PortalItem.js";import{typeKeyword as I}from"./portal/support/portalItemUtils.js";import U from"./support/MapFloorInfo.js";import P from"./webdoc/GeotriggersInfo.js";import{SaveOperationType as O}from"./webdoc/interfaces.js";import k from"./webdoc/RangeInfo.js";import L from"./webdoc/Widgets.js";import{getOptimalThumbnailSize as F}from"./webdoc/support/thumbnailUtils.js";import{loadFromSource as N}from"./webdoc/support/webdocLoadUtils.js";import{getLayerJSON as R}from"./webdoc/support/writeUtils.js";import T from"./webmap/ApplicationProperties.js";import E from"./webmap/Bookmark.js";import B from"./webmap/InitialViewProperties.js";import{Version as J}from"./webmap/Version.js";import x from"./webmap/background/ColorBackground.js";const M=new J(2,29),Z="Web Map",W="webmap",$="web-map",C=s.ofType(E),G=s.ofType(j),z=new Map([["image/jpeg","jpeg"],["image/jpg","jpg"],["image/png","png"],["image/gif","gif"]]),D="ArcGIS Pro",q=I.JSAPI,H={currentVersion:M,createInitialViewProperties:()=>new B,parseVersion:J.parse,itemType:Z,name:W,origin:$};let K=class extends(m(a.LoadableMixin(h(r)))){constructor(e){super(e),this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1,this._thumbnailFilename=null,this._updateFromPromise=null,this.resourceReferences={portalItem:null,paths:[]},this.applicationProperties=null,this.bookmarks=new C,this.floorInfo=null,this.geotriggersInfo=null,this.initialViewProperties=new B,this.portalItem=null,this.presentation=null,this.sourceVersion=null,this.widgets=null,this.utilityNetworks=null,this._debouncedSaveOperations=c((async(e,t,r)=>{const{save:i,saveAs:o}=await import("./webdoc/support/webdocSaveUtils.js");switch(e){case O.SAVE:return i(H,this,t);case O.SAVE_AS:return o(H,this,r,t)}})),this.authoringApp=this.authoringAppVersion=null,this._isAuthoringAppSetByUser=this._isAuthoringAppVersionSetByUser=!1}destroy(){if(this.portalItem=u(this.portalItem),this.utilityNetworks){const e=this.utilityNetworks.removeAll();for(const t of e)t.destroy();this.utilityNetworks.destroy()}}initialize(){if(this.when().catch((e=>{l.getLogger(this).error("#load()","Failed to load web map",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t)}}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp=q}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}readInitialViewProperties(e,t){const r=new B;t.background&&(r.background=x.fromJSON(t.background));const o=t.initialState?.viewpoint;if(o){if(o.rotation){J.parse(t.version||"","webmap").lessThan(2,20)&&t.authoringApp===D&&(o.rotation*=-1)}r.viewpoint=i.fromJSON(o)}return t.mapRangeInfo&&(r.rangeInfo=k.fromJSON(t.mapRangeInfo)),t.spatialReference&&(r.spatialReference=_.fromJSON(t.spatialReference)),t.timeZone&&(r.timeZone=t.timeZone),r}writeInitialViewProperties(e,t,r,i){e&&(e.background?.color&&(t.background=e.background.write({},i)),e.viewpoint&&(t.initialState={viewpoint:e.viewpoint.write({},i)}),e.rangeInfo&&(t.mapRangeInfo=e.rangeInfo.toJSON(i)),e.spatialReference&&(t.spatialReference=e.spatialReference.write({},i)),t.timeZone=e.timeZone)}writeLayers(e,t,r,i){t[r]=this._writeLayers(e,i,"operational-layers")}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new J(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${M.major}.${M.minor}`}writeTables(e,t,r,i){const o=this._writeLayers(e,i,"tables");o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl||null}set thumbnailUrl(e){e?(this._override("thumbnailUrl",e),this._thumbnailFilename=this._generateCustomThumbnailFilename(e)):this._clearThumbnailOverride()}get updatingFromView(){return!!this._updateFromPromise}load(e){return this.addResolvingPromise(N(H,this)),Promise.resolve(this)}loadAll(){return p(this,(e=>{e(this.ground,this.basemap,this.layers,this.tables)}))}read(e,t){t={...t,origin:$};const r=this._getAuthoringPropsState();v(this,e,(t=>super.read(e,t)),t),this._restoreAuthoringPropsFromState(r)}write(e,t){if("loaded"!==this.loadStatus){const e=new n("webmap:not-loaded","Web map must be loaded before it can be serialized");throw l.getLogger(this).error("#toJSON()","Web map must be loaded before it can be serialized",this.loadError||this.loadStatus),e}return this._removeDanglingLayerRefs(),t={...t,origin:$,restrictedWebMapWriting:!0,webmap:this},super.write(e,t)}async save(e){return this._debouncedSaveOperations(O.SAVE,e)}async saveAs(e,t){return this._debouncedSaveOperations(O.SAVE_AS,t,e)}async updateFrom(e,t){const r=this._updateFromInternal(e,t);this._updateFromPromise=r,await r;r===this._updateFromPromise&&(this._updateFromPromise=null)}getLayerJSONFromResourceInfo(e){const t=this.resourceInfo;return this._collectAllLayersJSON([...t?.baseMap?.baseMapLayers||[],...t?.operationalLayers||[],...this.basemap?.resourceInfo?.data?.baseMapLayers||[]]).find((t=>t.id===e.id))}async updateItemThumbnail(){this.thumbnailUrl&&this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl,filename:this._thumbnailFilename})),this._clearThumbnailOverride())}getThumbnailState(){let e=this.thumbnailUrl;return e&&(e=this._isOverridden("thumbnailUrl")?e:g(e,"w","8192")),{thumbnailUrl:e,filename:this._thumbnailFilename}}restoreThumbnailFromState(e){this.thumbnailUrl=e.thumbnailUrl,this._thumbnailFilename=e.filename}_collectAllLayersJSON(e){return e.reduce(((e,t)=>(e.push(t),"GroupLayer"===t.layerType&&(e=e.concat(this._collectAllLayersJSON(t.layers||[]))),e)),[])}_writeLayers(e,t,r){t={...t,layerContainerType:r};return e.map((e=>R(e,"tables"===r?null:this.getLayerJSONFromResourceInfo(e),t))).filter(o).toArray()}_validateJSON(e){const t=J.parse(e.version||"","webmap");return M.validate(t),e.version=`${t.major}.${t.minor}`,e}_removeDanglingLayerRefs(){const e=this.applicationProperties,t=e?.viewing?.search,r=e=>this.allLayers.some((t=>t.id===e));if(t&&t.layers&&(t.layers=t.layers.filter((e=>r(e.id)))),t&&t.tables&&(t.tables=t.tables.filter((e=>this.tables.some((t=>t.id===e.id))))),e){const t=e.editing?.locationTracking;t?.info&&!r(t.info.layerId)&&(e.editing=null)}const i=this.presentation?.slides;i&&i.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>r(e.id))))}))}async _updateFromInternal(e,t){if(t??={},await d((()=>e.ready)),this._updateInitialViewProperties(e,t),e.map===this)for(const r of e.allLayerViews)"visible"in r&&"visible"in r.layer&&r._isOverridden("visible")&&(r.layer.visible=r.visible),"featureEffect"in r&&"featureEffect"in r.layer&&r._isOverridden("featureEffect")&&(r.layer.featureEffect=r.featureEffect);await this._updateThumbnailUrl(e,t)}_updateInitialViewProperties(e,t){if(t.backgroundExcluded||(this.initialViewProperties.background=e.background?.clone()),this.initialViewProperties.spatialReference=e.spatialReference?.clone(),this.initialViewProperties.timeZone=e.timeZone,t.viewpointExcluded||(this.initialViewProperties.viewpoint=new i({rotation:e.rotation,scale:t.scalePreserved?e.scale:null,targetGeometry:this._getViewExtent(e)})),!t.widgetsExcluded)for(const r of e.persistableViewModels)r.updateWebDocument(this)}_getViewExtent(e){const t=e.center.clone().normalize(),r=e.extent.clone(),i=r.width/2;return r.xmin=t.x-i,r.xmax=t.x+i,r}async _updateThumbnailUrl(e,t){if(t.thumbnailExcluded)return;const r=F(e,t.thumbnailSize),i=await e.takeScreenshot({format:"png",width:r.width,height:r.height});this._setAutoGeneratedThumbnail(i.dataUrl)}_setAutoGeneratedThumbnail(e){this.thumbnailUrl=e,this._thumbnailFilename=null}_clearThumbnailOverride(){this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"),this._thumbnailFilename=null}_generateCustomThumbnailFilename(e){if(f(e)){const t=w(e),r=t?.mediaType,i=r&&z.get(r.toLowerCase())||null,o=`thumbnail${Date.now()}`;return i?`${o}.${i}`:o}return null}_getAuthoringPropsState(){return{authoringApp:this.authoringApp,authoringAppVersion:this.authoringAppVersion,isAuthoringAppSetByUser:this._isAuthoringAppSetByUser,isAuthoringAppVersionSetByUser:this._isAuthoringAppVersionSetByUser}}_restoreAuthoringPropsFromState(e){e.isAuthoringAppSetByUser?this.authoringApp=e.authoringApp:this._isAuthoringAppSetByUser=!1,e.isAuthoringAppVersionSetByUser?this.authoringAppVersion=e.authoringAppVersion:this._isAuthoringAppVersionSetByUser=!1}static fromJSON(e){const t=e;if(!t)throw new n("webmap:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:t})}};K.VERSION=M,e([y()],K.prototype,"_updateFromPromise",void 0),e([y({type:T,json:{write:!0}})],K.prototype,"applicationProperties",void 0),e([y({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],K.prototype,"authoringApp",null),e([S("authoringApp")],K.prototype,"writeAuthoringApp",null),e([y({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],K.prototype,"authoringAppVersion",null),e([S("authoringAppVersion")],K.prototype,"writeAuthoringAppVersion",null),e([y({type:C,json:{write:{overridePolicy:e=>({enabled:!!(e&&e.length>0),ignoreOrigin:!0})}}})],K.prototype,"bookmarks",void 0),e([y({type:U,json:{name:"mapFloorInfo",write:!0}})],K.prototype,"floorInfo",void 0),e([y({type:P,json:{write:!0}})],K.prototype,"geotriggersInfo",void 0),e([y({type:B,nonNullable:!0,json:{read:{source:["background","initialState.viewpoint","mapRangeInfo","spatialReference","timeZone"]},write:{ignoreOrigin:!0,target:{background:{type:x},"initialState.viewpoint":{type:i},mapRangeInfo:{type:k},spatialReference:{type:_},"timeZone:":{type:String}}}}})],K.prototype,"initialViewProperties",void 0),e([b("initialViewProperties")],K.prototype,"readInitialViewProperties",null),e([S("initialViewProperties")],K.prototype,"writeInitialViewProperties",null),e([y({json:{read:!1,write:{target:"operationalLayers",ignoreOrigin:!0}}})],K.prototype,"layers",void 0),e([S("layers")],K.prototype,"writeLayers",null),e([y({type:V})],K.prototype,"portalItem",void 0),e([y({json:{write:!0}})],K.prototype,"presentation",void 0),e([y()],K.prototype,"resourceInfo",void 0),e([y({readOnly:!0,type:J,json:{read:{source:"version"},write:{allowNull:!0,ignoreOrigin:!0,target:"version",isRequired:!0}}})],K.prototype,"sourceVersion",void 0),e([b("sourceVersion")],K.prototype,"readSourceVersion",null),e([S("sourceVersion")],K.prototype,"writeSourceVersion",null),e([y({json:{read:!1,write:{ignoreOrigin:!0}}})],K.prototype,"tables",void 0),e([S("tables")],K.prototype,"writeTables",null),e([y()],K.prototype,"thumbnailUrl",null),e([y()],K.prototype,"updatingFromView",null),e([y({type:L,json:{write:!0}})],K.prototype,"widgets",void 0),e([y({type:G,json:{read:!0,write:!0}})],K.prototype,"utilityNetworks",void 0),K=e([A("esri.WebMap")],K);const Q=K;export{Q as default};
package/WebScene.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.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import o from"./core/Collection.js";import s from"./core/Error.js";import{clone as a}from"./core/lang.js";import n from"./core/Loadable.js";import{loadAll as l}from"./core/loadAll.js";import p from"./core/Logger.js";import{destroyMaybe as c}from"./core/maybe.js";import{MultiOriginJSONMixin as d,MultiOriginJSONSupport as h}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as m}from"./core/Promise.js";import{debounce as u}from"./core/promiseUtils.js";import{on as y}from"./core/reactiveUtils.js";import{urlToObject as w,addQueryParameter as f}from"./core/urlUtils.js";import{property as g}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import{reader as b}from"./core/accessorSupport/decorators/reader.js";import{subclass as v}from"./core/accessorSupport/decorators/subclass.js";import{writer as S}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as _}from"./core/accessorSupport/originUtils.js";import{readLoadable as A}from"./core/accessorSupport/read.js";import I from"./geometry/Extent.js";import j from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as L}from"./geometry/projection.js";import R from"./geometry/SpatialReference.js";import{validateWebSceneError as P}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as U}from"./geometry/support/jsonUtils.js";import{isEarth as V}from"./geometry/support/spatialReferenceUtils.js";import O from"./portal/Portal.js";import M from"./portal/PortalItem.js";import{createForItemWrite as E}from"./portal/support/jsonContext.js";import{toggleTypeKeword as C,TypeKeyword as N}from"./portal/support/portalItemUtils.js";import{hasDeveloperBasemapLayer as T}from"./support/basemapUtils.js";import G from"./support/MapFloorInfo.js";import{WebSceneTag as F}from"./support/tagSymbols.js";import{createSchemaValidationError as J,createCopyError as x}from"./support/webSceneUtils.js";import{ViewingMode as $}from"./views/ViewingMode.js";import{isSpatialReferenceSupported as W}from"./views/support/spatialReferenceSupport.js";import{SaveOperationType as B}from"./webdoc/interfaces.js";import{updateItemWithResources as q,saveResources as k}from"./webdoc/support/resourceUtils.js";import{validateSaveAPIKey as D}from"./webdoc/support/saveAPIKeyUtils.js";import{evaluateWriteErrors as K}from"./webdoc/support/saveUtils.js";import{getOptimalThumbnailSize as H}from"./webdoc/support/thumbnailUtils.js";import z from"./webscene/ApplicationProperties.js";import Q from"./webscene/Environment.js";import X from"./webscene/InitialViewProperties.js";import Y from"./webscene/Presentation.js";import Z from"./webscene/TransportationNetwork.js";import{Version as ee}from"./webscene/Version.js";import{getLoader as te}from"./webscene/support/schemaValidatorLoader.js";var re;const ie=new ee(1,33),oe=()=>{const e=8,t=[],r=ie.major;for(let i=e;i<=ie.minor;i++)t.push(`${r}.${i}`);return t},se="Web Scene";let ae=class extends(n.LoadableMixin(m(d(r)))){constructor(e){super(e),this[re]=!0,this._layersIdGCTimeoutId=void 0,this._updateFromPromise=null,this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=void 0,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new Y,this.initialViewProperties=new X,this.portalItem=null,this.resourceInfo=null,this._debouncedSaveOperations=u((async(e,t,r)=>{switch(e){case B.SAVE:return this._saveImpl(t);case B.SAVE_AS:return this._saveAsImpl(r,t)}})),this._resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch((e=>{p.getLogger(this).error("#load()","Failed to load web scene",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this.addHandles(y((()=>this.allLayers),"change",(()=>this._scheduleLayersIdGC())))}destroy(){this._unscheduleLayersIdGC(),this.presentation&&this.presentation.destroy(),this.portalItem=c(this.portalItem)}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){t[r]=this._layersToJSON(e,"operational-layers",i)}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new ee(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${ie.major}.${ie.minor}`}writeTables(e,t,r,i){const o=this._layersToJSON(e,"tables",i);o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl??null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t){const r={};return t.initialState?.environment&&(r.environment=Q.fromJSON(t.initialState.environment)),r.spatialReference=t.spatialReference?R.fromJSON(t.spatialReference):R.WebMercator,r.viewingMode=t.viewingMode??"global",t.initialState?.viewpoint&&(r.viewpoint=i.fromJSON(t.initialState.viewpoint)),new X(r)}get spatialReference(){return this.initialViewProperties?.spatialReference??R.WebMercator}get viewingMode(){return this.initialViewProperties?.viewingMode??"global"}load(e){const t=this.ground;return this.addResolvingPromise(this._loadFromSource().then((()=>{t&&t!==this.ground&&t.destroy()}))),Promise.resolve(this)}loadAll(){return l(this,(e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map((e=>e.basemap)),this.tables)}))}read(e,t){t={...t,origin:"web-scene"};const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(A(this,e,(t=>super.read(e,t)),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&this.sourceVersion?.supportsVisibleElevationLayersInSlides){const t=e.baseMap.elevationLayers.map((e=>({id:e.id}))),r=this.presentation.slides,i=(e,t)=>e.visibleLayers.some((e=>e.id===t)),o=t.filter((e=>!r.some((t=>i(t,e.id)))));r.forEach((e=>{e.visibleLayers.addMany(o)}))}}_writeBasemapElevationLayers(e){const t=e.ground?.layers;!e.baseMap&&t?.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=a(t))}_layersToJSON(e,t,r){const i={...r,layerContainerType:t};return e.map((e=>this._verifyWritableLayer(e,r)?e.write({},i):null)).filter((e=>!!e)).toArray()}_verifyWritableLayer(e,t){return!!e.persistenceEnabled&&("write"in e||(t?.messages&&t.messages.push(new s("layer:unsupported",`Layers (${e.title}, ${e.id}) of type '${e.declaredClass}' cannot be persisted in web scenes`,{layer:e})),!1))}write(e,t){if("loaded"!==this.loadStatus){const e=new s("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw p.getLogger(this).error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const r=!t?.messages;t={messages:[],...t,origin:"web-scene"};const i=super.write(e,t);if(r){const e=t.messages?.filter((e=>"web-document-write:property-required"===e.name))??[];if(e.length){const t=new s("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw p.getLogger(this).error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(i),i}async save(e){return this._debouncedSaveOperations(B.SAVE,e)}async _saveImpl(e){if(!this.portalItem)throw new s("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene");if(D(this.portalItem),this.portalItem?.type!==se)throw new s("webscene:portal-item-wrong-type",`Portal item needs to have type "${se}"`);const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls(E(this.portalItem,"web-scene",!0)),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,e),this._updateTypeKeywords(this.portalItem),await q(this.portalItem,i,this._resourceReferences,r,null),_(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(B.SAVE_AS,t,e)}async _saveAsImpl(e,t){let r=M.from(e);if(!r)throw new s("webscene:portal-item-required","saveAs requires a portal item to save to");D(r),r.id&&(r=r.clone(),r.id=null);const i=r.portal||O.getDefault();await this._ensureLoadBeforeSave(),r.type=se,r.portal=i;const o=this._enableVerifyItemRelativeUrls(E(r,"web-scene",!0)),a=this.write({},o);await Promise.all(o.resources.pendingOperations),await this._verifySaveAs(a,o,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");if(this._updateTypeKeywords(r),await i.signIn(),!i.user)throw new s("webscene:user-not-signed-in","saveAs requires a user to be signed in to the portal");return await i.user.addItem({item:r,folder:t?.folder,data:a}),await k(this._resourceReferences,o,null),this.portalItem=r,h.prototype.read.call(this,{version:a.version,authoringApp:a.authoringApp,authoringAppVersion:a.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl?w(r.itemUrl):void 0}),_(o),n&&(this.thumbnailUrl=l?f(n,"w","8192"):n),o.portalItem=r,await this._saveThumbnail(),r}async _saveThumbnail(){this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl})),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}async _verifySave(e,t,r,i=!1){if(!V(this.spatialReference))throw new s("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently.");const{ignoreUnsupported:o,requiredPropertyChecksDisabled:a,strictSchemaValidationEnabled:n}=r||{};K(t,{errorName:"webscene:save"},{ignoreUnsupported:o,supplementalUnsupportedErrors:["scenemodification:unsupported"],requiredPropertyChecksDisabled:a});const l=te();if(n&&l){const t=(await l()).validate(e);if(!t.length)return;const r=`webscene did not validate:\n${t.join("\n")}`;p.getLogger(this).error(`${i?"saveAs":"save"}(): ${r}`);const o=t.map((e=>new s("webscene:schema-validation",e)));throw J(o)}}_verifySaveAs(e,t,r){return this.canNotSaveAs(t)?Promise.reject(x()):this._verifySave(e,t,r,!0)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(e){return e||(e=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),this.write({},e)),(e.verifyItemRelativeUrls?.writtenUrls?.length??0)>0}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment&&(this.initialViewProperties.environment=Q.prototype.clone.apply(e.environment)),!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,null!=e.clippingArea?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this._updateFromThumbnail(e,t.thumbnailSize??void 0)}async _updateFromThumbnail(e,t){const r=H(e,t),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-scene"}):this.portalItem?.id?this._loadFromItem(this.portalItem):this._loadObjectsWithLayers()}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_extractOperationalLayers(e){const t=[];if(!this.sourceVersion?.supportsGround&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(this.sourceVersion?.supportsGround||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}async _loadFromJSON(e,t){const r=new o;await this._validateSpatialReference(),await this._validateHeightModelInfo();const{populateOperationalLayers:i}=await import("./layers/support/layersCreator.js"),{operationalLayers:s,operationalElevationLayers:a,basemapElevationLayers:n}=this._extractOperationalLayers(e),l=[],p={context:{...t,layerContainerType:"operational-layers"}};if(this.portalItem&&(p.context.portal=this.portalItem.portal||O.getDefault()),n.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(this.ground.layers,n,e))}if(a.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(r,a,e))}s&&s.length>0&&l.push(i(this.layers,s,p)),e.tables?.length&&l.push(i(this.tables,e.tables,{...p,context:{...p.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"})),await Promise.allSettled(l),await this._loadObjectsWithLayers(),this.ground.layers.addMany(r)}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[],t=[...this.allLayers.items];for(const{basemap:r}of this.presentation.slides.items)r&&(t.push(...r.baseLayers.items),t.push(...r.referenceLayers.items));for(const r of t)if("beforeSave"in r&&"function"==typeof r.beforeSave){const t=r.beforeSave();t&&e.push(t)}await Promise.allSettled(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach((t=>{t.basemap&&e.push(t.basemap.load())})),await Promise.allSettled(e)}async _loadFromItem(e){if(await e.load().catch((e=>{throw new s("webscene:load-portal-item","Failed to load portal item",{error:e})})),"Web Scene"!==e.type)throw new s("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r={origin:"web-scene",url:w(e.itemUrl),portal:e.portal||O.getDefault(),portalItem:e,readResourcePaths:[]};await this._readAndLoadFromJSON(t,r),this._resourceReferences={portalItem:e,paths:r.readResourcePaths??[]}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!W(t,$.Global))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||L(e,t)}else{if(!W(t,$.Local))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e?.camera?.position.spatialReference??e?.targetGeometry?.spatialReference,o=e.viewpoint,a=i(o);if(a&&!r(a))return Promise.reject(new s("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:a,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find((e=>!r(i(e.viewpoint))));if(n){const r=i(n.viewpoint);return Promise.reject(new s("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=P(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateJSON(e){const t=ee.parse(e.version||"","webscene");return ie.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=R.WebMercator.toJSON()),e}_updateTypeKeywords(e){C(e,N.LOCAL_SCENE,"local"===this.initialViewProperties.viewingMode),C(e,N.DEVELOPER_BASEMAP,T(this.basemap)||this.presentation.slides.some((({basemap:e})=>!!e&&T(e)))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||R.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem?.itemUrl?w(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout((()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()}),3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties?.viewing?.search,t=e=>this.allLayers.some((t=>t.id===e&&t.persistenceEnabled));e&&e.layers&&(e.layers=e.layers.filter((e=>t(e.id))));const r=this.presentation&&this.presentation.slides;r&&r.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>t(e.id))))}))}static fromJSON(e){if(!e)throw new s("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}};re=F,ae.version=`${ie.major}.${ie.minor}`,e([g({type:z,json:{write:!0}})],ae.prototype,"applicationProperties",void 0),e([g({type:I,json:{read:{source:"clippingArea.geometry",reader:U},write:{target:"clippingArea.geometry"}}})],ae.prototype,"clippingArea",void 0),e([S("clippingArea")],ae.prototype,"writeClippingArea",null),e([g({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],ae.prototype,"clippingEnabled",void 0),e([b("clippingEnabled",["clippingArea"])],ae.prototype,"readClippingEnabled",null),e([S("clippingEnabled")],ae.prototype,"writeClippingEnabled",null),e([g({type:G,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],ae.prototype,"floorInfo",void 0),e([g({type:j,json:{write:!0}})],ae.prototype,"heightModelInfo",void 0),e([g({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],ae.prototype,"layers",void 0),e([S("layers")],ae.prototype,"writeLayers",null),e([g({readOnly:!0,type:ee,json:{type:oe(),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],ae.prototype,"sourceVersion",void 0),e([b("sourceVersion",["version"])],ae.prototype,"readSourceVersion",null),e([S("sourceVersion")],ae.prototype,"writeSourceVersion",null),e([g({json:{read:!1,write:{enabled:!0,ignoreOrigin:!0}}})],ae.prototype,"tables",void 0),e([S("tables")],ae.prototype,"writeTables",null),e([g()],ae.prototype,"thumbnailUrl",null),e([g({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],ae.prototype,"authoringApp",null),e([S("authoringApp")],ae.prototype,"writeAuthoringApp",null),e([g({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],ae.prototype,"authoringAppVersion",null),e([S("authoringAppVersion")],ae.prototype,"writeAuthoringAppVersion",null),e([g({json:{write:{isRequired:!0,allowNull:!0,ignoreOrigin:!0,enabled:!0}}})],ae.prototype,"ground",void 0),e([S("ground")],ae.prototype,"writeGround",null),e([g({type:o.ofType(Z),json:{write:!0}})],ae.prototype,"transportationNetworks",void 0),e([g({type:Y,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],ae.prototype,"presentation",void 0),e([g({type:X,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new X({viewingMode:"global",spatialReference:R.WebMercator})}})],ae.prototype,"initialViewProperties",void 0),e([b("initialViewProperties",["initialState.environment","initialState.viewpoint","spatialReference","viewingMode"])],ae.prototype,"readInitialViewProperties",null),e([g({type:R,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],ae.prototype,"spatialReference",null),e([g({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],ae.prototype,"viewingMode",null),e([g({type:M})],ae.prototype,"portalItem",void 0),e([g()],ae.prototype,"resourceInfo",void 0),ae=e([v("esri.WebScene")],ae);const ne=ae;export{ne as default};
5
+ import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import o from"./core/Collection.js";import s from"./core/Error.js";import{clone as a}from"./core/lang.js";import n from"./core/Loadable.js";import{loadAll as l}from"./core/loadAll.js";import p from"./core/Logger.js";import{destroyMaybe as c}from"./core/maybe.js";import{MultiOriginJSONMixin as d,MultiOriginJSONSupport as h}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as m}from"./core/Promise.js";import{debounce as u}from"./core/promiseUtils.js";import{on as y}from"./core/reactiveUtils.js";import{urlToObject as w,addQueryParameter as f}from"./core/urlUtils.js";import{property as g}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import{reader as b}from"./core/accessorSupport/decorators/reader.js";import{subclass as v}from"./core/accessorSupport/decorators/subclass.js";import{writer as S}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as _}from"./core/accessorSupport/originUtils.js";import{readLoadable as A}from"./core/accessorSupport/read.js";import I from"./geometry/Extent.js";import j from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as L}from"./geometry/projection.js";import R from"./geometry/SpatialReference.js";import{validateWebSceneError as P}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as U}from"./geometry/support/jsonUtils.js";import{isEarth as V}from"./geometry/support/spatialReferenceUtils.js";import O from"./portal/Portal.js";import M from"./portal/PortalItem.js";import{createForItemWrite as E}from"./portal/support/jsonContext.js";import{toggleTypeKeword as C,typeKeyword as N}from"./portal/support/portalItemUtils.js";import{hasDeveloperBasemapLayer as T}from"./support/basemapUtils.js";import G from"./support/MapFloorInfo.js";import{WebSceneTag as F}from"./support/tagSymbols.js";import{createSchemaValidationError as J,createCopyError as x}from"./support/webSceneUtils.js";import{ViewingMode as $}from"./views/ViewingMode.js";import{isSpatialReferenceSupported as W}from"./views/support/spatialReferenceSupport.js";import{SaveOperationType as B}from"./webdoc/interfaces.js";import{updateItemWithResources as q,saveResources as k}from"./webdoc/support/resourceUtils.js";import{validateSaveAPIKey as D}from"./webdoc/support/saveAPIKeyUtils.js";import{evaluateWriteErrors as K}from"./webdoc/support/saveUtils.js";import{getOptimalThumbnailSize as H}from"./webdoc/support/thumbnailUtils.js";import z from"./webscene/ApplicationProperties.js";import Q from"./webscene/Environment.js";import X from"./webscene/InitialViewProperties.js";import Y from"./webscene/Presentation.js";import Z from"./webscene/TransportationNetwork.js";import{Version as ee}from"./webscene/Version.js";import{getLoader as te}from"./webscene/support/schemaValidatorLoader.js";var re;const ie=new ee(1,33),oe=()=>{const e=8,t=[],r=ie.major;for(let i=e;i<=ie.minor;i++)t.push(`${r}.${i}`);return t},se="Web Scene";let ae=class extends(n.LoadableMixin(m(d(r)))){constructor(e){super(e),this[re]=!0,this._layersIdGCTimeoutId=void 0,this._updateFromPromise=null,this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=void 0,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new Y,this.initialViewProperties=new X,this.portalItem=null,this.resourceInfo=null,this._debouncedSaveOperations=u((async(e,t,r)=>{switch(e){case B.SAVE:return this._saveImpl(t);case B.SAVE_AS:return this._saveAsImpl(r,t)}})),this._resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch((e=>{p.getLogger(this).error("#load()","Failed to load web scene",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this.addHandles(y((()=>this.allLayers),"change",(()=>this._scheduleLayersIdGC())))}destroy(){this._unscheduleLayersIdGC(),this.presentation&&this.presentation.destroy(),this.portalItem=c(this.portalItem)}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){t[r]=this._layersToJSON(e,"operational-layers",i)}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new ee(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${ie.major}.${ie.minor}`}writeTables(e,t,r,i){const o=this._layersToJSON(e,"tables",i);o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl??null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t){const r={};return t.initialState?.environment&&(r.environment=Q.fromJSON(t.initialState.environment)),r.spatialReference=t.spatialReference?R.fromJSON(t.spatialReference):R.WebMercator,r.viewingMode=t.viewingMode??"global",t.initialState?.viewpoint&&(r.viewpoint=i.fromJSON(t.initialState.viewpoint)),new X(r)}get spatialReference(){return this.initialViewProperties?.spatialReference??R.WebMercator}get viewingMode(){return this.initialViewProperties?.viewingMode??"global"}load(e){const t=this.ground;return this.addResolvingPromise(this._loadFromSource().then((()=>{t&&t!==this.ground&&t.destroy()}))),Promise.resolve(this)}loadAll(){return l(this,(e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map((e=>e.basemap)),this.tables)}))}read(e,t){t={...t,origin:"web-scene"};const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(A(this,e,(t=>super.read(e,t)),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&this.sourceVersion?.supportsVisibleElevationLayersInSlides){const t=e.baseMap.elevationLayers.map((e=>({id:e.id}))),r=this.presentation.slides,i=(e,t)=>e.visibleLayers.some((e=>e.id===t)),o=t.filter((e=>!r.some((t=>i(t,e.id)))));r.forEach((e=>{e.visibleLayers.addMany(o)}))}}_writeBasemapElevationLayers(e){const t=e.ground?.layers;!e.baseMap&&t?.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=a(t))}_layersToJSON(e,t,r){const i={...r,layerContainerType:t};return e.map((e=>this._verifyWritableLayer(e,r)?e.write({},i):null)).filter((e=>!!e)).toArray()}_verifyWritableLayer(e,t){return!!e.persistenceEnabled&&("write"in e||(t?.messages&&t.messages.push(new s("layer:unsupported",`Layers (${e.title}, ${e.id}) of type '${e.declaredClass}' cannot be persisted in web scenes`,{layer:e})),!1))}write(e,t){if("loaded"!==this.loadStatus){const e=new s("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw p.getLogger(this).error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const r=!t?.messages;t={messages:[],...t,origin:"web-scene"};const i=super.write(e,t);if(r){const e=t.messages?.filter((e=>"web-document-write:property-required"===e.name))??[];if(e.length){const t=new s("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw p.getLogger(this).error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(i),i}async save(e){return this._debouncedSaveOperations(B.SAVE,e)}async _saveImpl(e){if(!this.portalItem)throw new s("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene");if(D(this.portalItem),this.portalItem?.type!==se)throw new s("webscene:portal-item-wrong-type",`Portal item needs to have type "${se}"`);const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls(E(this.portalItem,"web-scene",!0)),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,e),this._updateTypeKeywords(this.portalItem),await q(this.portalItem,i,this._resourceReferences,r,null),_(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(B.SAVE_AS,t,e)}async _saveAsImpl(e,t){let r=M.from(e);if(!r)throw new s("webscene:portal-item-required","saveAs requires a portal item to save to");D(r),r.id&&(r=r.clone(),r.id=null);const i=r.portal||O.getDefault();await this._ensureLoadBeforeSave(),r.type=se,r.portal=i;const o=this._enableVerifyItemRelativeUrls(E(r,"web-scene",!0)),a=this.write({},o);await Promise.all(o.resources.pendingOperations),await this._verifySaveAs(a,o,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");if(this._updateTypeKeywords(r),await i.signIn(),!i.user)throw new s("webscene:user-not-signed-in","saveAs requires a user to be signed in to the portal");return await i.user.addItem({item:r,folder:t?.folder,data:a}),await k(this._resourceReferences,o,null),this.portalItem=r,h.prototype.read.call(this,{version:a.version,authoringApp:a.authoringApp,authoringAppVersion:a.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl?w(r.itemUrl):void 0}),_(o),n&&(this.thumbnailUrl=l?f(n,"w","8192"):n),o.portalItem=r,await this._saveThumbnail(),r}async _saveThumbnail(){this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl})),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}async _verifySave(e,t,r,i=!1){if(!V(this.spatialReference))throw new s("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently.");const{ignoreUnsupported:o,requiredPropertyChecksDisabled:a,strictSchemaValidationEnabled:n}=r||{};K(t,{errorName:"webscene:save"},{ignoreUnsupported:o,supplementalUnsupportedErrors:["scenemodification:unsupported"],requiredPropertyChecksDisabled:a});const l=te();if(n&&l){const t=(await l()).validate(e);if(!t.length)return;const r=`webscene did not validate:\n${t.join("\n")}`;p.getLogger(this).error(`${i?"saveAs":"save"}(): ${r}`);const o=t.map((e=>new s("webscene:schema-validation",e)));throw J(o)}}_verifySaveAs(e,t,r){return this.canNotSaveAs(t)?Promise.reject(x()):this._verifySave(e,t,r,!0)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(e){return e||(e=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),this.write({},e)),(e.verifyItemRelativeUrls?.writtenUrls?.length??0)>0}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment&&(this.initialViewProperties.environment=Q.prototype.clone.apply(e.environment)),!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,null!=e.clippingArea?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this._updateFromThumbnail(e,t.thumbnailSize??void 0)}async _updateFromThumbnail(e,t){const r=H(e,t),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-scene"}):this.portalItem?.id?this._loadFromItem(this.portalItem):this._loadObjectsWithLayers()}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_extractOperationalLayers(e){const t=[];if(!this.sourceVersion?.supportsGround&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(this.sourceVersion?.supportsGround||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}async _loadFromJSON(e,t){const r=new o;await this._validateSpatialReference(),await this._validateHeightModelInfo();const{populateOperationalLayers:i}=await import("./layers/support/layersCreator.js"),{operationalLayers:s,operationalElevationLayers:a,basemapElevationLayers:n}=this._extractOperationalLayers(e),l=[],p={context:{...t,layerContainerType:"operational-layers"}};if(this.portalItem&&(p.context.portal=this.portalItem.portal||O.getDefault()),n.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(this.ground.layers,n,e))}if(a.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(r,a,e))}s&&s.length>0&&l.push(i(this.layers,s,p)),e.tables?.length&&l.push(i(this.tables,e.tables,{...p,context:{...p.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"})),await Promise.allSettled(l),await this._loadObjectsWithLayers(),this.ground.layers.addMany(r)}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[],t=[...this.allLayers.items];for(const{basemap:r}of this.presentation.slides.items)r&&(t.push(...r.baseLayers.items),t.push(...r.referenceLayers.items));for(const r of t)if("beforeSave"in r&&"function"==typeof r.beforeSave){const t=r.beforeSave();t&&e.push(t)}await Promise.allSettled(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach((t=>{t.basemap&&e.push(t.basemap.load())})),await Promise.allSettled(e)}async _loadFromItem(e){if(await e.load().catch((e=>{throw new s("webscene:load-portal-item","Failed to load portal item",{error:e})})),"Web Scene"!==e.type)throw new s("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r={origin:"web-scene",url:w(e.itemUrl),portal:e.portal||O.getDefault(),portalItem:e,readResourcePaths:[]};await this._readAndLoadFromJSON(t,r),this._resourceReferences={portalItem:e,paths:r.readResourcePaths??[]}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!W(t,$.Global))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||L(e,t)}else{if(!W(t,$.Local))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e?.camera?.position.spatialReference??e?.targetGeometry?.spatialReference,o=e.viewpoint,a=i(o);if(a&&!r(a))return Promise.reject(new s("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:a,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find((e=>!r(i(e.viewpoint))));if(n){const r=i(n.viewpoint);return Promise.reject(new s("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=P(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateJSON(e){const t=ee.parse(e.version||"","webscene");return ie.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=R.WebMercator.toJSON()),e}_updateTypeKeywords(e){C(e,N.LOCAL_SCENE,"local"===this.initialViewProperties.viewingMode),C(e,N.DEVELOPER_BASEMAP,T(this.basemap)||this.presentation.slides.some((({basemap:e})=>!!e&&T(e)))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||R.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem?.itemUrl?w(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout((()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()}),3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties?.viewing?.search,t=e=>this.allLayers.some((t=>t.id===e&&t.persistenceEnabled));e&&e.layers&&(e.layers=e.layers.filter((e=>t(e.id))));const r=this.presentation&&this.presentation.slides;r&&r.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>t(e.id))))}))}static fromJSON(e){if(!e)throw new s("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}};re=F,ae.version=`${ie.major}.${ie.minor}`,e([g({type:z,json:{write:!0}})],ae.prototype,"applicationProperties",void 0),e([g({type:I,json:{read:{source:"clippingArea.geometry",reader:U},write:{target:"clippingArea.geometry"}}})],ae.prototype,"clippingArea",void 0),e([S("clippingArea")],ae.prototype,"writeClippingArea",null),e([g({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],ae.prototype,"clippingEnabled",void 0),e([b("clippingEnabled",["clippingArea"])],ae.prototype,"readClippingEnabled",null),e([S("clippingEnabled")],ae.prototype,"writeClippingEnabled",null),e([g({type:G,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],ae.prototype,"floorInfo",void 0),e([g({type:j,json:{write:!0}})],ae.prototype,"heightModelInfo",void 0),e([g({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],ae.prototype,"layers",void 0),e([S("layers")],ae.prototype,"writeLayers",null),e([g({readOnly:!0,type:ee,json:{type:oe(),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],ae.prototype,"sourceVersion",void 0),e([b("sourceVersion",["version"])],ae.prototype,"readSourceVersion",null),e([S("sourceVersion")],ae.prototype,"writeSourceVersion",null),e([g({json:{read:!1,write:{enabled:!0,ignoreOrigin:!0}}})],ae.prototype,"tables",void 0),e([S("tables")],ae.prototype,"writeTables",null),e([g()],ae.prototype,"thumbnailUrl",null),e([g({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],ae.prototype,"authoringApp",null),e([S("authoringApp")],ae.prototype,"writeAuthoringApp",null),e([g({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],ae.prototype,"authoringAppVersion",null),e([S("authoringAppVersion")],ae.prototype,"writeAuthoringAppVersion",null),e([g({json:{write:{isRequired:!0,allowNull:!0,ignoreOrigin:!0,enabled:!0}}})],ae.prototype,"ground",void 0),e([S("ground")],ae.prototype,"writeGround",null),e([g({type:o.ofType(Z),json:{write:!0}})],ae.prototype,"transportationNetworks",void 0),e([g({type:Y,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],ae.prototype,"presentation",void 0),e([g({type:X,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new X({viewingMode:"global",spatialReference:R.WebMercator})}})],ae.prototype,"initialViewProperties",void 0),e([b("initialViewProperties",["initialState.environment","initialState.viewpoint","spatialReference","viewingMode"])],ae.prototype,"readInitialViewProperties",null),e([g({type:R,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],ae.prototype,"spatialReference",null),e([g({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],ae.prototype,"viewingMode",null),e([g({type:M})],ae.prototype,"portalItem",void 0),e([g()],ae.prototype,"resourceInfo",void 0),ae=e([v("esri.WebScene")],ae);const ne=ae;export{ne 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.29/esri/copyright.txt for details.
4
4
  */
5
- import{replace as e}from"../core/string.js";import{UnknownTimeZone as t}from"../core/sql/UnknownTimeZone.js";import{DateTime as n,Zone as r,FixedOffsetZone as s,IANAZone as i}from"luxon";var o;!function(e){e.TimeZoneNotRecognized="TimeZoneNotRecognized"}(o||(o={}));const a={[o.TimeZoneNotRecognized]:"Timezone identifier has not been recognized."};class d extends Error{constructor(t,n){super(e(a[t],n)),this.declaredRootClass="esri.arcade.arcadedate.dateerror",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}function u(e,t,n){return e<t?e-t:e>n?e-n:0}function c(e,t,n){return e<t?t:e>n?n:e}class m{constructor(e){this._date=e,this.declaredRootClass="esri.arcade.arcadedate"}static fromParts(e=0,t=1,r=1,s=0,i=0,o=0,a=0,d){if(isNaN(e)||isNaN(t)||isNaN(r)||isNaN(s)||isNaN(i)||isNaN(o)||isNaN(a))return null;const l=n.local(e,t).daysInMonth;let f=n.fromObject({day:c(r,1,l),year:e,month:c(t,1,12),hour:c(s,0,23),minute:c(i,0,59),second:c(o,0,59),millisecond:c(a,0,999)},{zone:h(d)});return f=f.plus({months:u(t,1,12),days:u(r,1,l),hours:u(s,0,23),minutes:u(i,0,59),seconds:u(o,0,59),milliseconds:u(a,0,999)}),new m(f)}static get systemTimeZoneCanonicalName(){return Intl.DateTimeFormat().resolvedOptions().timeZone??"system"}static arcadeDateAndZoneToArcadeDate(e,n){const r=h(n);return e.isUnknownTimeZone||r===t.instance?m.fromParts(e.year,e.monthJS+1,e.day,e.hour,e.minute,e.second,e.millisecond,r):new m(e._date.setZone(r))}static dateJSToArcadeDate(e){return new m(n.fromJSDate(e,{zone:"system"}))}static dateJSAndZoneToArcadeDate(e,t="system"){const r=h(t);return new m(n.fromJSDate(e,{zone:r}))}static unknownEpochToArcadeDate(e){return new m(n.fromMillis(e,{zone:t.instance}))}static unknownDateJSToArcadeDate(e){return new m(n.fromMillis(e.getTime(),{zone:t.instance}))}static epochToArcadeDate(e,t="system"){const r=h(t);return new m(n.fromMillis(e,{zone:r}))}static dateTimeToArcadeDate(e){return new m(e)}clone(){return new m(this._date)}changeTimeZone(e){const t=h(e);return m.dateTimeToArcadeDate(this._date.setZone(t))}static dateTimeAndZoneToArcadeDate(e,n){const r=h(n);return e.zone===t.instance||r===t.instance?m.fromParts(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond,r):new m(e.setZone(r))}static nowToArcadeDate(e){const t=h(e);return new m(n.fromJSDate(new Date,{zone:t}))}static nowUTCToArcadeDate(){return new m(n.utc())}get isSystem(){return"system"===this.timeZone||this.timeZone===m.systemTimeZoneCanonicalName}equals(e){return this.isSystem&&e.isSystem?this.toNumber()===e.toNumber():this.isUnknownTimeZone===e.isUnknownTimeZone&&this._date.equals(e._date)}get isUnknownTimeZone(){return this._date.zone===t.instance}get isValid(){return this._date.isValid}get hour(){return this._date.hour}get second(){return this._date.second}get day(){return this._date.day}get dayOfWeekISO(){return this._date.weekday}get dayOfWeekJS(){let e=this._date.weekday;return e>6&&(e=0),e}get millisecond(){return this._date.millisecond}get monthISO(){return this._date.month}get weekISO(){return this._date.weekNumber}get yearISO(){return this._date.weekYear}get monthJS(){return this._date.month-1}get year(){return this._date.year}get minute(){return this._date.minute}get zone(){return this._date.zone}get timeZoneOffset(){return this.isUnknownTimeZone?0:this._date.offset}get timeZone(){if(this.isUnknownTimeZone)return"unknown";if("system"===this._date.zone.type)return"system";const e=this.zone;return"fixed"===e.type?0===e.fixed?"UTC":e.formatOffset(0,"short"):e.name}stringify(){return JSON.stringify(this.toJSDate())}plus(e){return new m(this._date.plus(e))}diff(e,t="milliseconds"){return this._date.diff(e._date,t)[t]}toISODate(){return this._date.toISODate()}toISOString(e){return e?this._date.toISO({suppressMilliseconds:!0,includeOffset:!this.isUnknownTimeZone}):this._date.toISO({includeOffset:!this.isUnknownTimeZone})}toISOTime(e,t){return this._date.toISOTime({suppressMilliseconds:e,includeOffset:t&&!this.isUnknownTimeZone})}toFormat(e,t){return this.isUnknownTimeZone&&(e=e.replaceAll("Z","")),this._date.toFormat(e,t)}toJSDate(){return this._date.toJSDate()}toSQLValue(){return this._date.toFormat("yyyy-LL-dd HH:mm:ss")}toSQLWithKeyword(){return`timestamp '${this.toSQLValue()}'`}toDateTime(){return this._date}toNumber(){return this._date.toMillis()}getTime(){return this._date.toMillis()}toUTC(){return new m(this._date.toUTC())}toLocal(){return new m(this._date.toLocal())}toString(){return this.toISOString(!0)}static fromReaderAsTimeStampOffset(e){if(!e)return null;const t=n.fromISO(e,{setZone:!0});return new m(t)}}function h(e,n=!0){if(e instanceof r)return e;if("system"===e.toLowerCase())return"system";if("utc"===e.toLowerCase())return"UTC";if("unknown"===e.toLowerCase())return t.instance;if(/^[\+\-]?[0-9]{1,2}([:][0-9]{2})?$/.test(e)){const t=s.parseSpecifier("UTC"+(e.startsWith("+")||e.startsWith("-")?"":"+")+e);if(t)return t}const a=i.create(e);if(!a.isValid){if(n)throw new d(o.TimeZoneNotRecognized);return null}return a}export{m as ArcadeDate,d as ArcadeDateError,o as ArcadeDateErrorCodes,a as ArcadeDateErrorMessages,h as createDateTimeZone};
5
+ import{replace as e}from"../core/string.js";import{UnknownTimeZone as t}from"../core/sql/UnknownTimeZone.js";import{DateTime as n,Zone as r,FixedOffsetZone as s,IANAZone as i}from"luxon";var o;!function(e){e.TimeZoneNotRecognized="TimeZoneNotRecognized"}(o||(o={}));const a={[o.TimeZoneNotRecognized]:"Timezone identifier has not been recognized."};class d extends Error{constructor(t,n){super(e(a[t],n)),this.declaredRootClass="esri.arcade.arcadedate.dateerror",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}function u(e,t,n){return e<t?e-t:e>n?e-n:0}function c(e,t,n){return e<t?t:e>n?n:e}class m{constructor(e){this._date=e,this.declaredRootClass="esri.arcade.arcadedate"}static fromParts(e=0,t=1,r=1,s=0,i=0,o=0,a=0,d){if(isNaN(e)||isNaN(t)||isNaN(r)||isNaN(s)||isNaN(i)||isNaN(o)||isNaN(a))return null;const l=n.local(e,t).daysInMonth;let f=n.fromObject({day:c(r,1,l),year:e,month:c(t,1,12),hour:c(s,0,23),minute:c(i,0,59),second:c(o,0,59),millisecond:c(a,0,999)},{zone:h(d)});return f=f.plus({months:u(t,1,12),days:u(r,1,l),hours:u(s,0,23),minutes:u(i,0,59),seconds:u(o,0,59),milliseconds:u(a,0,999)}),new m(f)}static get systemTimeZoneCanonicalName(){return Intl.DateTimeFormat().resolvedOptions().timeZone??"system"}static arcadeDateAndZoneToArcadeDate(e,n){const r=h(n);return e.isUnknownTimeZone||r===t.instance?m.fromParts(e.year,e.monthJS+1,e.day,e.hour,e.minute,e.second,e.millisecond,r):new m(e._date.setZone(r))}static dateJSToArcadeDate(e){return new m(n.fromJSDate(e,{zone:"system"}))}static dateJSAndZoneToArcadeDate(e,t="system"){const r=h(t);return new m(n.fromJSDate(e,{zone:r}))}static unknownEpochToArcadeDate(e){return new m(n.fromMillis(e,{zone:t.instance}))}static unknownDateJSToArcadeDate(e){return new m(n.fromMillis(e.getTime(),{zone:t.instance}))}static epochToArcadeDate(e,t="system"){const r=h(t);return new m(n.fromMillis(e,{zone:r}))}static dateTimeToArcadeDate(e){return new m(e)}clone(){return new m(this._date)}changeTimeZone(e){const t=h(e);return m.dateTimeToArcadeDate(this._date.setZone(t))}static dateTimeAndZoneToArcadeDate(e,n){const r=h(n);return e.zone===t.instance||r===t.instance?m.fromParts(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond,r):new m(e.setZone(r))}static nowToArcadeDate(e){const t=h(e);return new m(n.fromJSDate(new Date,{zone:t}))}static nowUTCToArcadeDate(){return new m(n.utc())}get isSystem(){return"system"===this.timeZone||this.timeZone===m.systemTimeZoneCanonicalName}equals(e){return this.isSystem&&e.isSystem?this.toNumber()===e.toNumber():this.isUnknownTimeZone===e.isUnknownTimeZone&&this._date.equals(e._date)}get isUnknownTimeZone(){return this._date.zone===t.instance}get isValid(){return this._date.isValid}get hour(){return this._date.hour}get second(){return this._date.second}get day(){return this._date.day}get dayOfWeekISO(){return this._date.weekday}get dayOfWeekJS(){let e=this._date.weekday;return e>6&&(e=0),e}get millisecond(){return this._date.millisecond}get monthISO(){return this._date.month}get weekISO(){return this._date.weekNumber}get yearISO(){return this._date.weekYear}get monthJS(){return this._date.month-1}get year(){return this._date.year}get minute(){return this._date.minute}get zone(){return this._date.zone}get timeZoneOffset(){return this.isUnknownTimeZone?0:this._date.offset}get timeZone(){if(this.isUnknownTimeZone)return"unknown";if("system"===this._date.zone.type)return"system";const e=this.zone;return"fixed"===e.type?0===e.fixed?"UTC":e.formatOffset(0,"short"):e.name}stringify(){return JSON.stringify(this.toJSDate())}plus(e){return new m(this._date.plus(e))}diff(e,t="milliseconds"){return this._date.diff(e._date,t)[t]}toISODate(){return this._date.toISODate()}toISOString(e){return e?this._date.toISO({suppressMilliseconds:!0,includeOffset:!this.isUnknownTimeZone}):this._date.toISO({includeOffset:!this.isUnknownTimeZone})}toISOTime(e,t){return this._date.toISOTime({suppressMilliseconds:e,includeOffset:t&&!this.isUnknownTimeZone})}toFormat(e,t){return this.isUnknownTimeZone&&(e=e.replaceAll("Z","")),this._date.toFormat(e,t)}toJSDate(){return this._date.toJSDate()}toSQLValue(){return this._date.toFormat("yyyy-LL-dd HH:mm:ss")}toSQLWithKeyword(){return`timestamp '${this.toSQLValue()}'`}toDateTime(){return this._date}toNumber(){return this._date.toMillis()}getTime(){return this._date.toMillis()}toUTC(){return new m(this._date.toUTC())}toLocal(){return new m(this._date.toLocal())}toString(){return this.toISOString(!0)}static fromReaderAsTimeStampOffset(e){if(!e)return null;const t=n.fromISO(e,{setZone:!0});return new m(t)}}function h(e,n=!0){if(e instanceof r)return e;if("system"===e.toLowerCase())return"system";if("utc"===e.toLowerCase())return"UTC";if("unknown"===e.toLowerCase())return t.instance;if(/^[\+\-]?[0-9]{1,2}([:][0-9]{2})?$/.test(e)){const t=s.parseSpecifier("UTC"+(e.startsWith("+")||e.startsWith("-")?"":"+")+e);if(t)return t}const a=i.create(e);if(!a.isValid){if(n)throw new d(o.TimeZoneNotRecognized);return null}return a}export{m as ArcadeDate,d as ArcadeDateError,o as ArcadeDateErrorCodes,a as arcadeDateErrorMessages,h as createDateTimeZone};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeModule as e}from"./ArcadeModule.js";import{ArcadeModuleLoader as t}from"./ArcadeModuleLoader.js";import n from"./Dictionary.js";import{ArcadeExecutionError as r,ExecutionErrorCodes as o,ensureArcadeExecutionError as a}from"./executionError.js";import i from"./Feature.js";import{NativeFunction as l,ArcadeFunction as s,ScopeMarshalledFunction as c,wrapModuleScopedResponse as u}from"./FunctionWrapper.js";import{E as f,a as p,q as w,o as d,r as h,c as m,b as g,C as y,A as v,y as b,z as S,i as x,R as I,u as F,g as C,I as R,j as A,B as M,D as j,w as k}from"../chunks/languageUtils.js";import{addFunctionDeclaration as L}from"./treeAnalysis.js";import{A as E}from"../chunks/array.js";import{registerFunctions as N}from"./functions/date.js";import{registerFunctions as O}from"./functions/geomasync.js";import{registerFunctions as B,geometryMember as P}from"./functions/geometry.js";import{registerFunctions as K}from"./functions/maths.js";import{registerFunctions as D}from"./functions/stats.js";import{registerFunctions as G}from"./functions/string.js";import Z from"../geometry/Geometry.js";import U from"../geometry/SpatialReference.js";function q(e){return e&&"function"==typeof e.then}const T=100;async function W(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(await H(e,t.arguments[r]));return n}async function V(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await W(e,t))}class _ extends s{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 r(e,o.MaximumCallDepth,null);return Pe(this.definition,n,t,null)}}call(e,t){return Y(e,t,((n,a,i)=>{const l={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(l.depthCounter.depth>64)throw new r(e,o.MaximumCallDepth,t);return Pe(this.definition,l,i,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=>!x(t)||t instanceof c?t:u(t,e,r))),u(await Pe(this.definition,l,i,t),n,r)}))}}class z extends e{constructor(e){super(e)}async global(e){const t=this.executingContext.globalScope[e.toLowerCase()];if(t.valueset||(t.value=await H(this.executingContext,t.node),t.valueset=!0),x(t.value)&&!(t.value instanceof c)){const e=new c;e.fn=t.value,e.parameterEvaluator=Y,e.context=this.executingContext,t.value=e}return t.value}setGlobal(e,t){if(x(t))throw new r(null,o.AssignModuleFunction,null);this.executingContext.globalScope[e.toLowerCase()]={value:t,valueset:!0,node:null}}hasGlobal(e){return void 0===this.executingContext.exports[e]&&(e=e.toLowerCase()),void 0!==this.executingContext.exports[e]}async loadModule(e){let n=e.spatialReference;null==n&&(n=new U({wkid:102100})),this.moduleScope=Ge({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:n,services:e.services,libraryResolver:new t(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 H(this.executingContext,this.source.syntax)}}async function Y(e,t,n){if(!0===t.preparsed){const r=n(e,null,t.arguments);return q(r),r}const r=n(e,t,await W(e,t));return q(r),r}async function H(e,t,n){if(t.breakpoint&&!0!==n){const n=t.breakpoint();return await n,H(e,t,!0)}try{switch(t?.type){case"VariableDeclarator":return await xe(e,t);case"ImportDeclaration":return await ve(e,t);case"ExportNamedDeclaration":return await be(e,t);case"VariableDeclaration":return await Se(e,t,0);case"BlockStatement":case"Program":return await he(e,t);case"FunctionDeclaration":return await ye(e,t);case"ReturnStatement":return await ge(e,t);case"IfStatement":return await de(e,t);case"ExpressionStatement":return await we(e,t);case"UpdateExpression":return await ue(e,t);case"AssignmentExpression":return await pe(e,t);case"ForStatement":return await ne(e,t);case"WhileStatement":return await X(e,t);case"ForInStatement":return await ce(e,t);case"BreakStatement":return S;case"EmptyStatement":return b;case"ContinueStatement":return v;case"TemplateElement":return await ke(e,t);case"TemplateLiteral":return await Ee(e,t);case"Identifier":return await Me(e,t);case"MemberExpression":return await Ie(e,t);case"Literal":return t.value;case"CallExpression":return await je(e,t);case"UnaryExpression":return await Fe(e,t);case"BinaryExpression":return await Re(e,t);case"LogicalExpression":return await Ae(e,t);case"ArrayExpression":return await Ce(e,t);case"ObjectExpression":return await J(e,t);case"Property":return await Q(e,t);default:throw new r(e,o.Unrecognized,t)}}catch(i){throw a(e,t,i)}}async function J(e,t){const a=[];for(let n=0;n<t.properties.length;n++)a[n]=await H(e,t.properties[n]);const i={},l=new Map;for(let n=0;n<a.length;n++){const s=a[n];if(x(s.value))throw new r(e,o.NoFunctionInDictionary,t);if(!1===m(s.key))throw new r(e,o.KeyMustBeString,t);let c=s.key.toString();const u=c.toLowerCase();l.has(u)?c=l.get(u):l.set(u,c),s.value===b?i[c]=null:i[c]=s.value}const s=new n(i);return s.immutable=!1,s}async function Q(e,t){const n=await H(e,t.value);if("Identifier"===t.key.type)return{key:t.key.name,value:n};return{key:await H(e,t.key),value:n}}async function X(e,t){const n={testResult:!0,lastAction:b};if(n.testResult=await H(e,t.test),!1===n.testResult)return b;if(!0!==n.testResult)throw new r(e,o.BooleanConditionRequired,t);for(;!0===n.testResult&&(n.lastAction=await H(e,t.body),n.lastAction!==S)&&!(n.lastAction instanceof I);)if(n.testResult=await H(e,t.test),!0!==n.testResult&&!1!==n.testResult)throw new r(e,o.BooleanConditionRequired,t);return n.lastAction instanceof I?n.lastAction:b}async function $(e,t,n){const r=await H(e,t.body);return n.lastAction=r,n.lastAction===S||n.lastAction instanceof I?(n.testResult=!1,n):null!==t.update?(await H(e,t.update),n):n}async function ee(e,t,n){if(null!==t.test){const a=await H(e,t.test);if(!0===e.abortSignal?.aborted)throw new r(e,o.Cancelled,t);if(n.testResult=a,!1===n.testResult)return n;if(!0!==n.testResult)throw new r(e,o.BooleanConditionRequired,t);return $(e,t,n)}return $(e,t,n)}function te(e,t,n,r,o,a){try{ee(e,t,n).then((()=>{try{!0===n.testResult?++a>T?(a=0,setTimeout((()=>{te(e,t,n,r,o,a)}),0)):te(e,t,n,r,o,a):n.lastAction instanceof I?r(n.lastAction):r(b)}catch(i){o(i)}}),(e=>{o(e)}))}catch(i){o(i)}}function ne(e,t){try{return null!==t.init?H(e,t.init).then((()=>new Promise(((n,r)=>{te(e,t,{testResult:!0,lastAction:b},(e=>{n(e)}),(e=>{r(e)}),0)})))):new Promise(((n,r)=>{te(e,t,{testResult:!0,lastAction:b},(e=>{n(e)}),(e=>{r(e)}),0)}))}catch(n){return Promise.reject(n)}}function re(e,t,n,r,o,a,i,l,s,c){try{if(r<=a)return void l(b);o.value="k"===i?n[a]:a,H(e,t.body).then((u=>{try{u instanceof I?l(u):u===S?l(b):++c>T?(c=0,setTimeout((()=>{re(e,t,n,r,o,a+1,i,l,s,c)}),0)):re(e,t,n,r,o,a+1,i,l,s,c)}catch(f){s(f)}}),(e=>{s(e)}))}catch(u){s(u)}}function oe(e,t,n,r,o,a,i,l,s){try{if(n.length()<=o)return void i(b);r.value="k"===a?n.get(o):o,H(e,t.body).then((c=>{c instanceof I?i(c):c===S?i(b):++s>T?(s=0,setTimeout((()=>{oe(e,t,n,r,o+1,a,i,l,s)}),0)):oe(e,t,n,r,o+1,a,i,l,s)}),(e=>{l(e)}))}catch(c){l(c)}}function ae(e,t,n,r,o,a){try{if(void 0===a&&(a="i"),0===n.length)return void r.resolve(b);re(e,t,n,n.length,o,0,a,(e=>{r.resolve(e)}),(e=>{r.reject(e)}),0)}catch(i){r.reject(i)}}function ie(e,t,n,r,o,a){try{if(void 0===a&&(a="i"),0===n.length)return void r.resolve(b);oe(e,t,n,o,0,a,(e=>{r.resolve(e)}),(e=>{r.reject(e)}),0)}catch(i){r.reject(i)}}function le(e,t,n,r,o){try{ae(e,t,n.keys(),r,o,"k")}catch(a){r.reject(a)}}function se(e,t,n,r,o,a,l,s){try{e.next().then((c=>{try{if(null===c)a(b);else{const u=i.createFromGraphicLikeObject(c.geometry,c.attributes,r,t.timeZone);u._underlyingGraphic=c,o.value=u;H(t,n.body).then((i=>{try{i===S?a(b):i instanceof I?a(i):++s>T?(s=0,setTimeout((()=>{se(e,t,n,r,o,a,l,s)}),0)):se(e,t,n,r,o,a,l,s)}catch(c){l(c)}}),(e=>{l(e)}))}}catch(u){l(u)}}),(e=>{l(e)}))}catch(c){l(c)}}async function ce(e,t){return new Promise(((a,i)=>{H(e,t.right).then((l=>{try{let s=null;s="VariableDeclaration"===t.left.type?H(e,t.left):Promise.resolve(),s.then((()=>{try{let s="";if("VariableDeclaration"===t.left.type){const e=t.left.declarations[0].id;"Identifier"===e.type&&(s=e.name)}else"Identifier"===t.left.type&&(s=t.left.name);if(!s)throw new r(e,o.InvalidIdentifier,t);s=s.toLowerCase();let c=null;if(null!=e.localScope&&void 0!==e.localScope[s]&&(c=e.localScope[s]),null===c&&void 0!==e.globalScope[s]&&(c=e.globalScope[s]),null===c)return void i(new r(e,o.InvalidIdentifier,t));d(l)||m(l)?ae(e,t,l,{reject:i,resolve:a},c):w(l)?ie(e,t,l,{reject:i,resolve:a},c):l instanceof n||h(l)?le(e,t,l,{reject:i,resolve:a},c):F(l)?se(l.iterator(e.abortSignal),e,t,l,c,(e=>{a(e)}),(e=>{i(e)}),0):ae(e,t,[],{reject:i,resolve:a},c)}catch(s){i(s)}}),i)}catch(s){i(s)}}),i)}))}async function ue(e,t){const a=t.argument;if("MemberExpression"===a.type){const i={t:null},l=await H(e,a.object);let s=null;i.t=l,!0===a.computed?s=await H(e,a.property):"Identifier"===a.property.type&&(s=a.property.name);const c=i.t;let u;if(d(c)){if(!g(s))throw new r(e,o.ArrayAccessorMustBeNumber,t);if(s<0&&(s=c.length+s),s<0||s>=c.length)throw new r(e,o.OutOfBounds,t);u=C(c[s]),c[s]="++"===t.operator?u+1:u-1}else if(c instanceof n){if(!1===m(s))throw new r(e,o.KeyAccessorMustBeString,t);if(!0!==c.hasField(s))throw new r(e,o.FieldNotFound,t,{key:s});u=C(c.field(s)),c.setField(s,"++"===t.operator?u+1:u-1)}else if(c instanceof z){if(!1===m(s))throw new r(e,o.ModuleAccessorMustBeString,t);if(!0!==c.hasGlobal(s))throw new r(e,o.ModuleExportNotFound,t);u=C(await c.global(s)),c.setGlobal(s,"++"===t.operator?u+1:u-1)}else{if(!h(c))throw w(c)?new r(e,o.Immutable,t):new r(e,o.InvalidParameter,t);if(!1===m(s))throw new r(e,o.KeyAccessorMustBeString,t);if(!0!==c.hasField(s))throw new r(e,o.FieldNotFound,t,{key:s});u=C(c.field(s)),c.setField(s,"++"===t.operator?u+1:u-1)}return!1===t.prefix?u:"++"===t.operator?u+1:u-1}const i="Identifier"===t.argument.type?t.argument.name.toLowerCase():"";if(!i)throw new r(e,o.InvalidIdentifier,t);let l;if(null!=e.localScope&&void 0!==e.localScope[i])return l=C(e.localScope[i].value),e.localScope[i]={value:"++"===t.operator?l+1:l-1,valueset:!0,node:t},!1===t.prefix?l:"++"===t.operator?l+1:l-1;if(void 0!==e.globalScope[i])return l=C(e.globalScope[i].value),e.globalScope[i]={value:"++"===t.operator?l+1:l-1,valueset:!0,node:t},!1===t.prefix?l:"++"===t.operator?l+1:l-1;throw new r(e,o.InvalidIdentifier,t)}function fe(e,t,n,a,i){switch(t){case"=":return e===b?null:e;case"/=":return C(n)/C(e);case"*=":return C(n)*C(e);case"-=":return C(n)-C(e);case"+=":return m(n)||m(e)?A(n)+A(e):C(n)+C(e);case"%=":return C(n)%C(e);default:throw new r(i,o.UnsupportedOperator,a)}}async function pe(e,t){const a=t.left;if("MemberExpression"===a.type){const i=await H(e,a.object);let l=null;if(!0===a.computed)l=await H(e,a.property);else{if("Identifier"!==a.property.type)throw new r(e,o.InvalidIdentifier,t);l=a.property.name}const s=await H(e,t.right);if(d(i)){if(!g(l))throw new r(e,o.ArrayAccessorMustBeNumber,t);if(l<0&&(l=i.length+l),l<0||l>i.length)throw new r(e,o.OutOfBounds,t);if(l===i.length){if("="!==t.operator)throw new r(e,o.OutOfBounds,t);i[l]=fe(s,t.operator,i[l],t,e)}else i[l]=fe(s,t.operator,i[l],t,e)}else if(i instanceof n){if(!1===m(l))throw new r(e,o.KeyAccessorMustBeString,t);if(!0===i.hasField(l))i.setField(l,fe(s,t.operator,i.field(l),t,e));else{if("="!==t.operator)throw new r(e,o.FieldNotFound,t,{key:l});i.setField(l,fe(s,t.operator,null,t,e))}}else if(i instanceof z){if(!1===m(l))throw new r(e,o.KeyAccessorMustBeString,t);if(!0!==i.hasGlobal(l))throw new r(e,o.ModuleExportNotFound,t);i.setGlobal(l,fe(s,t.operator,await i.global(l),t,e))}else{if(!h(i))throw w(i)?new r(e,o.Immutable,t):new r(e,o.InvalidParameter,t);if(!1===m(l))throw new r(e,o.KeyAccessorMustBeString,t);if(!0===i.hasField(l))i.setField(l,fe(s,t.operator,i.field(l),t,e));else{if("="!==t.operator)throw new r(e,o.FieldNotFound,t,{key:l});i.setField(l,fe(s,t.operator,null,t,e))}}return b}const i=a.name.toLowerCase();if(null!=e.localScope&&void 0!==e.localScope[i]){const n=await H(e,t.right);return e.localScope[i]={value:fe(n,t.operator,e.localScope[i].value,t,e),valueset:!0,node:t.right},b}if(void 0!==e.globalScope[i]){const n=await H(e,t.right);return e.globalScope[i]={value:fe(n,t.operator,e.globalScope[i].value,t,e),valueset:!0,node:t.right},b}throw new r(e,o.InvalidIdentifier,t)}async function we(e,t){if("AssignmentExpression"===t.expression.type)return H(e,t.expression);if("CallExpression"===t.expression.type){const n=await H(e,t.expression);return n===b?b:new R(n)}const n=await H(e,t.expression);return n===b?b:new R(n)}async function de(e,t){const n=await H(e,t.test);if(!0===n)return H(e,t.consequent);if(!1===n)return null!==t.alternate?H(e,t.alternate):b;throw new r(e,o.BooleanConditionRequired,t)}async function he(e,t){return me(e,t,0)}async function me(e,t,n){if(n>=t.body.length)return b;const r=await H(e,t.body[n]);return r instanceof I||r===S||r===v||n===t.body.length-1?r:me(e,t,n+1)}async function ge(e,t){if(null===t.argument)return new I(b);const n=await H(e,t.argument);return new I(n)}async function ye(e,t){const n=t.id.name.toLowerCase();return e.globalScope[n]={valueset:!0,node:null,value:new _(t,e)},b}async function ve(e,t){const n=t.specifiers[0].local.name.toLowerCase(),r=e.libraryResolver.loadLibrary(n);let o=null;return e.libraryResolver._moduleSingletons?.has(r.uri)?o=e.libraryResolver._moduleSingletons.get(r.uri):(o=new z(r),await o.loadModule(e),e.libraryResolver._moduleSingletons?.set(r.uri,o)),e.globalScope[n]={value:o,valueset:!0,node:t},b}async function be(e,t){if(await H(e,t.declaration),"FunctionDeclaration"===t.declaration.type)e.exports[t.declaration.id.name.toLowerCase()]="function";else if("VariableDeclaration"===t.declaration.type)for(const n of t.declaration.declarations)e.exports[n.id.name.toLowerCase()]="variable";return b}async function Se(e,t,n){return n>=t.declarations.length?b:(await H(e,t.declarations[n]),n===t.declarations.length-1||await Se(e,t,n+1),b)}async function xe(e,t){let n=null;if(n=null===t.init?null:await H(e,t.init),null!==e.localScope){if(n===b&&(n=null),"Identifier"!==t.id.type)throw new r(e,o.InvalidIdentifier,t);const a=t.id.name.toLowerCase();return null!=e.localScope&&(e.localScope[a]={value:n,valueset:!0,node:t.init}),b}if("Identifier"!==t.id.type)throw new r(e,o.InvalidIdentifier,t);const a=t.id.name.toLowerCase();return n===b&&(n=null),e.globalScope[a]={value:n,valueset:!0,node:t.init},b}async function Ie(e,t){const a=await H(e,t.object);if(null===a)throw new r(e,o.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(a instanceof n||h(a))return a.field(t.property.name);if(a instanceof Z)return P(a,t.property.name,e,t);if(a instanceof z){if(!a.hasGlobal(t.property.name))throw new r(e,o.InvalidIdentifier,t);return a.global(t.property.name)}throw new r(e,o.InvalidMemberAccessKey,t)}throw new r(e,o.InvalidMemberAccessKey,t)}let i=await H(e,t.property);if(a instanceof n||h(a)){if(m(i))return a.field(i);throw new r(e,o.InvalidMemberAccessKey,t)}if(a instanceof z){if(m(i))return a.global(i);throw new r(e,o.InvalidMemberAccessKey,t)}if(a instanceof Z){if(m(i))return P(a,i,e,t);throw new r(e,o.InvalidMemberAccessKey,t)}if(d(a)){if(g(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=a.length+i),i>=a.length||i<0)throw new r(e,o.OutOfBounds,t);return a[i]}throw new r(e,o.InvalidMemberAccessKey,t)}if(w(a)){if(g(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=a.length()+i),i>=a.length()||i<0)throw new r(e,o.OutOfBounds,t);return a.get(i)}throw new r(e,o.InvalidMemberAccessKey,t)}if(m(a)){if(g(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=a.length+i),i>=a.length||i<0)throw new r(e,o.OutOfBounds,t);return a[i]}throw new r(e,o.InvalidMemberAccessKey,t)}throw new r(e,o.InvalidMemberAccessKey,t)}async function Fe(e,t){const n=await H(e,t.argument);if(p(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*C(n);if("+"===t.operator)return 1*C(n);if("~"===t.operator)return~C(n);throw new r(e,o.UnsupportedUnaryOperator,t)}if("-"===t.operator)return-1*C(n);if("+"===t.operator)return 1*C(n);if("~"===t.operator)return~C(n);throw new r(e,o.UnsupportedUnaryOperator,t)}async function Ce(e,t){const n=[];for(let r=0;r<t.elements.length;r++)n.push(await H(e,t.elements[r]));for(let a=0;a<n.length;a++){if(x(n[a]))throw new r(e,o.NoFunctionInArray,t);n[a]===b&&(n[a]=null)}return n}async function Re(e,t){const n=[];n[0]=await H(e,t.left),n[1]=await H(e,t.right);const a=n[0],i=n[1];switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return j(C(a),C(i),t.operator);case"==":return y(a,i);case"!=":return!y(a,i);case"<":case">":case"<=":case">=":return M(a,i,t.operator);case"+":return m(a)||m(i)?A(a)+A(i):C(a)+C(i);case"-":return C(a)-C(i);case"*":return C(a)*C(i);case"/":return C(a)/C(i);case"%":return C(a)%C(i);default:throw new r(e,o.UnsupportedOperator,t)}}async function Ae(e,t){const n=await H(e,t.left);let a=null;if(!p(n))throw new r(e,o.LogicalExpressionOnlyBoolean,t);switch(t.operator){case"||":if(!0===n)return n;if(a=await H(e,t.right),p(a))return a;throw new r(e,o.LogicExpressionOrAnd,t);case"&&":if(!1===n)return n;if(a=await H(e,t.right),p(a))return a;throw new r(e,o.LogicExpressionOrAnd,t);default:throw new r(e,o.LogicExpressionOrAnd,t)}}async function Me(e,t){const n=t.name.toLowerCase();if(null!=e.localScope&&void 0!==e.localScope[n]){const t=e.localScope[n];if(!0===t.valueset)return t.value;if(null!==t.d)return t.d;t.d=H(e,t.node);const r=await t.d;return t.value=r,t.valueset=!0,r}if(void 0!==e.globalScope[n]){const t=e.globalScope[n];if(!0===t.valueset)return t.value;if(null!==t.d)return t.d;t.d=H(e,t.node);const r=await t.d;return t.value=r,t.valueset=!0,r}throw new r(e,o.InvalidIdentifier,t)}async function je(e,t){if("MemberExpression"===t.callee.type){const n=await H(e,t.callee.object);if(!(n instanceof z))throw new r(e,o.FunctionNotFound,t);const a=!1===t.callee.computed?t.callee.property.name:await H(e,t.callee.property);if(!n.hasGlobal(a))throw new r(e,o.FunctionNotFound,t);const i=await n.global(a);if(!x(i))throw new r(e,o.CallNonFunction,t);return i.call(e,t)}if("Identifier"!==t.callee.type)throw new r(e,o.FunctionNotFound,t);if(null!=e.localScope&&void 0!==e.localScope[t.callee.name.toLowerCase()]){const n=e.localScope[t.callee.name.toLowerCase()];if(x(n.value))return n.value.call(e,t);throw new r(e,o.CallNonFunction,t)}if(void 0!==e.globalScope[t.callee.name.toLowerCase()]){const n=e.globalScope[t.callee.name.toLowerCase()];if(x(n.value))return n.value.call(e,t);throw new r(e,o.CallNonFunction,t)}throw new r(e,o.FunctionNotFound,t)}async function ke(e,t){return t.value?t.value.cooked:""}function Le(e,t,n){if(x(e))throw new r(t,o.NoFunctionInTemplateLiteral,n);return e}async function Ee(e,t){const n=[];for(let a=0;a<t.expressions.length;a++){const r=await H(e,t.expressions[a]);n[a]=A(r)}let r="",o=0;for(const a of t.quasis)if(r+=a.value?a.value.cooked:"",!1===a.tail){r+=n[o]?Le(n[o],e,t):"",o++}return r}const Ne={};async function Oe(e,t,n,r){const o=await H(e,t.arguments[n]);if(y(o,r))return H(e,t.arguments[n+1]);const a=t.arguments.length-n;return 1===a?H(e,t.arguments[n]):2===a?null:3===a?H(e,t.arguments[n+2]):Oe(e,t,n+2,r)}async function Be(e,t,n,a){if(!0===a)return H(e,t.arguments[n+1]);if(3===t.arguments.length-n)return H(e,t.arguments[n+2]);const i=await H(e,t.arguments[n+2]);if(!1===p(i))throw new r(e,o.ModuleExportNotFound,t.arguments[n+2]);return Be(e,t,n+2,i)}async function Pe(e,t,n,a){const i=e.body;if(n.length!==e.params.length)throw new r(t,o.WrongNumberOfParameters,null);for(let r=0;r<n.length;r++){const o=e.params[r];"Identifier"===o.type&&null!=t.localScope&&(t.localScope[o.name.toLowerCase()]={d:null,value:n[r],valueset:!0,node:null})}const l=await H(t,i);if(l instanceof I)return l.value;if(l===S)throw new r(t,o.UnexpectedToken,a);if(l===v)throw new r(t,o.UnexpectedToken,a);return l instanceof R?l.value:l}N(Ne,V),G(Ne,V),K(Ne,V),B(Ne,V),D(Ne,V),O({functions:Ne,compiled:!1,signatures:null,evaluateIdentifier:null,mode:"async",standardFunction:V,standardFunctionAsync:Y}),Ne.iif=async function(e,t){f(null===t.arguments?[]:t.arguments,3,3,e,t);const n=await H(e,t.arguments[0]);if(!1===p(n))throw new r(e,o.BooleanConditionRequired,t);return H(e,n?t.arguments[1]:t.arguments[2])},Ne.defaultvalue=async function(e,t){f(null===t.arguments?[]:t.arguments,2,3,e,t);const a=await H(e,t.arguments[0]);if(3===t.arguments.length){const i=await H(e,t.arguments[1]);let l=[];if(w(i))l=i.toArray();else{if(!d(i))throw new r(e,o.InvalidParameter,t);l=i}let s=a;if(null===s)return H(e,t.arguments[2]);for(const r of l)if(h(s)){if(!1===m(r))return H(e,t.arguments[2]);if(!s.hasField(r))return H(e,t.arguments[2]);s=s.field(r)}else if(s instanceof n){if(!1===m(r))return H(e,t.arguments[2]);if(!s.hasField(r))return H(e,t.arguments[2]);s=s.field(r)}else if(s instanceof Z){if(!1===m(r))return H(e,t.arguments[2]);if(s=P(s,r,null,null,2),null===s)return H(e,t.arguments[2]);if("notfound"===s?.keystate)return H(e,t.arguments[2])}else if(d(s)){if(!1===g(r))return H(e,t.arguments[2]);if(s=s[r],null==s)return H(e,t.arguments[2])}else{if(!w(s))return H(e,t.arguments[2]);if(!1===g(r))return H(e,t.arguments[2]);if(s=s.get(r),null==s)return H(e,t.arguments[2])}return s}return null==a||""===a?H(e,t.arguments[1]):a},Ne.decode=async function(e,t){if(t.arguments.length<2)throw new r(e,o.WrongNumberOfParameters,t);if(2===t.arguments.length)return H(e,t.arguments[1]);if((t.arguments.length-1)%2==0)throw new r(e,o.WrongNumberOfParameters,t);return Oe(e,t,1,await H(e,t.arguments[0]))},Ne.when=async function(e,t){if(t.arguments.length<3)throw new r(e,o.WrongNumberOfParameters,t);if(t.arguments.length%2==0)throw new r(e,o.WrongNumberOfParameters,t);const n=await H(e,t.arguments[0]);if(!1===p(n))throw new r(e,o.BooleanConditionRequired,t.arguments[0]);return Be(e,t,0,n)};const Ke={fixSpatialReference:k,parseArguments:W,standardFunction:V,standardFunctionAsync:Y,evaluateIdentifier:Me};for(const We in Ne)Ne[We]={value:new l(Ne[We]),valueset:!0,node:null};const De=function(){};function Ge(e,t,r){const o=new De;null==e&&(e={}),null==t&&(t={});const a=new n({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});a.immutable=!1,o.textformatting={value:a,valueset:!0,node:null};for(const n in t)o[n]={value:new l(t[n]),native:!0,valueset:!0,node:null};for(const n in e)e[n]&&"esri.Graphic"===e[n].declaredClass?o[n]={value:i.createFromGraphic(e[n],r),valueset:!0,node:null}:o[n]={value:e[n],valueset:!0,node:null};return o}function Ze(e){console.log(e)}De.prototype=Ne,De.prototype.infinity={value:Number.POSITIVE_INFINITY,valueset:!0,node:null},De.prototype.pi={value:Math.PI,valueset:!0,node:null};const Ue=Ke;function qe(e){const t={mode:"async",compiled:!1,functions:{},signatures:[],standardFunction:V,standardFunctionAsync:Y,evaluateIdentifier:Me};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)Ne[n]={value:new l(t.functions[n]),valueset:!0,node:null},De.prototype[n]=Ne[n];for(let n=0;n<t.signatures.length;n++)L(t.signatures[n],"async")}async function Te(e,n){let a=n.spatialReference;null==a&&(a=new U({wkid:102100}));let i=null;e.usesModules&&(i=new t(new Map,e.loadedModules));const l=Ge(n.vars,n.customfunctions,n.timeZone),s={spatialReference:a,services:n.services,exports:{},libraryResolver:i,abortSignal:void 0===n.abortSignal||null===n.abortSignal?{aborted:!1}:n.abortSignal,globalScope:l,console:n.console??Ze,timeZone:n.timeZone??null,lrucache:n.lrucache,interceptor:n.interceptor,localScope:null,depthCounter:{depth:1}};let c=await H(s,e);if(c instanceof I&&(c=c.value),c instanceof R&&(c=c.value),c===b&&(c=null),c===S)throw new r(s,o.IllegalResult,null);if(c===v)throw new r(s,o.IllegalResult,null);if(x(c))throw new r(s,o.IllegalResult,null);return c}qe([E]);export{Te as executeScript,qe as extend,Ue as functionHelper};
5
+ import{ArcadeModule as e}from"./ArcadeModule.js";import{ArcadeModuleLoader as t}from"./ArcadeModuleLoader.js";import n from"./Dictionary.js";import{ArcadeExecutionError as r,ExecutionErrorCodes as o,ensureArcadeExecutionError as a}from"./executionError.js";import i from"./Feature.js";import{NativeFunction as l,ArcadeFunction as s,ScopeMarshalledFunction as c,wrapModuleScopedResponse as u}from"./FunctionWrapper.js";import{G as f,a as p,q as w,o as d,r as h,c as m,b as g,E as y,C as v,A as b,B as S,i as x,y as F,u as I,g as C,z as A,j as R,D as M,F as j,w as k}from"../chunks/languageUtils.js";import{addFunctionDeclaration as L}from"./treeAnalysis.js";import{A as E}from"../chunks/array.js";import{registerFunctions as N}from"./functions/date.js";import{registerFunctions as O}from"./functions/geomasync.js";import{registerFunctions as B,geometryMember as P}from"./functions/geometry.js";import{registerFunctions as K}from"./functions/maths.js";import{registerFunctions as D}from"./functions/stats.js";import{registerFunctions as G}from"./functions/string.js";import Z from"../geometry/Geometry.js";import U from"../geometry/SpatialReference.js";function q(e){return e&&"function"==typeof e.then}const T=100;async function W(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(await H(e,t.arguments[r]));return n}async function V(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await W(e,t))}class _ extends s{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 r(e,o.MaximumCallDepth,null);return Pe(this.definition,n,t,null)}}call(e,t){return Y(e,t,((n,a,i)=>{const l={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(l.depthCounter.depth>64)throw new r(e,o.MaximumCallDepth,t);return Pe(this.definition,l,i,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=>!x(t)||t instanceof c?t:u(t,e,r))),u(await Pe(this.definition,l,i,t),n,r)}))}}class z extends e{constructor(e){super(e)}async global(e){const t=this.executingContext.globalScope[e.toLowerCase()];if(t.valueset||(t.value=await H(this.executingContext,t.node),t.valueset=!0),x(t.value)&&!(t.value instanceof c)){const e=new c;e.fn=t.value,e.parameterEvaluator=Y,e.context=this.executingContext,t.value=e}return t.value}setGlobal(e,t){if(x(t))throw new r(null,o.AssignModuleFunction,null);this.executingContext.globalScope[e.toLowerCase()]={value:t,valueset:!0,node:null}}hasGlobal(e){return void 0===this.executingContext.exports[e]&&(e=e.toLowerCase()),void 0!==this.executingContext.exports[e]}async loadModule(e){let n=e.spatialReference;null==n&&(n=new U({wkid:102100})),this.moduleScope=Ge({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:n,services:e.services,libraryResolver:new t(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 H(this.executingContext,this.source.syntax)}}async function Y(e,t,n){if(!0===t.preparsed){const r=n(e,null,t.arguments);return q(r),r}const r=n(e,t,await W(e,t));return q(r),r}async function H(e,t,n){if(t.breakpoint&&!0!==n){const n=t.breakpoint();return await n,H(e,t,!0)}try{switch(t?.type){case"VariableDeclarator":return await xe(e,t);case"ImportDeclaration":return await ve(e,t);case"ExportNamedDeclaration":return await be(e,t);case"VariableDeclaration":return await Se(e,t,0);case"BlockStatement":case"Program":return await he(e,t);case"FunctionDeclaration":return await ye(e,t);case"ReturnStatement":return await ge(e,t);case"IfStatement":return await de(e,t);case"ExpressionStatement":return await we(e,t);case"UpdateExpression":return await ue(e,t);case"AssignmentExpression":return await pe(e,t);case"ForStatement":return await ne(e,t);case"WhileStatement":return await X(e,t);case"ForInStatement":return await ce(e,t);case"BreakStatement":return S;case"EmptyStatement":return b;case"ContinueStatement":return v;case"TemplateElement":return await ke(e,t);case"TemplateLiteral":return await Ee(e,t);case"Identifier":return await Me(e,t);case"MemberExpression":return await Fe(e,t);case"Literal":return t.value;case"CallExpression":return await je(e,t);case"UnaryExpression":return await Ie(e,t);case"BinaryExpression":return await Ae(e,t);case"LogicalExpression":return await Re(e,t);case"ArrayExpression":return await Ce(e,t);case"ObjectExpression":return await J(e,t);case"Property":return await Q(e,t);default:throw new r(e,o.Unrecognized,t)}}catch(i){throw a(e,t,i)}}async function J(e,t){const a=[];for(let n=0;n<t.properties.length;n++)a[n]=await H(e,t.properties[n]);const i={},l=new Map;for(let n=0;n<a.length;n++){const s=a[n];if(x(s.value))throw new r(e,o.NoFunctionInDictionary,t);if(!1===m(s.key))throw new r(e,o.KeyMustBeString,t);let c=s.key.toString();const u=c.toLowerCase();l.has(u)?c=l.get(u):l.set(u,c),s.value===b?i[c]=null:i[c]=s.value}const s=new n(i);return s.immutable=!1,s}async function Q(e,t){const n=await H(e,t.value);if("Identifier"===t.key.type)return{key:t.key.name,value:n};return{key:await H(e,t.key),value:n}}async function X(e,t){const n={testResult:!0,lastAction:b};if(n.testResult=await H(e,t.test),!1===n.testResult)return b;if(!0!==n.testResult)throw new r(e,o.BooleanConditionRequired,t);for(;!0===n.testResult&&(n.lastAction=await H(e,t.body),n.lastAction!==S)&&!(n.lastAction instanceof F);)if(n.testResult=await H(e,t.test),!0!==n.testResult&&!1!==n.testResult)throw new r(e,o.BooleanConditionRequired,t);return n.lastAction instanceof F?n.lastAction:b}async function $(e,t,n){const r=await H(e,t.body);return n.lastAction=r,n.lastAction===S||n.lastAction instanceof F?(n.testResult=!1,n):null!==t.update?(await H(e,t.update),n):n}async function ee(e,t,n){if(null!==t.test){const a=await H(e,t.test);if(!0===e.abortSignal?.aborted)throw new r(e,o.Cancelled,t);if(n.testResult=a,!1===n.testResult)return n;if(!0!==n.testResult)throw new r(e,o.BooleanConditionRequired,t);return $(e,t,n)}return $(e,t,n)}function te(e,t,n,r,o,a){try{ee(e,t,n).then((()=>{try{!0===n.testResult?++a>T?(a=0,setTimeout((()=>{te(e,t,n,r,o,a)}),0)):te(e,t,n,r,o,a):n.lastAction instanceof F?r(n.lastAction):r(b)}catch(i){o(i)}}),(e=>{o(e)}))}catch(i){o(i)}}function ne(e,t){try{return null!==t.init?H(e,t.init).then((()=>new Promise(((n,r)=>{te(e,t,{testResult:!0,lastAction:b},(e=>{n(e)}),(e=>{r(e)}),0)})))):new Promise(((n,r)=>{te(e,t,{testResult:!0,lastAction:b},(e=>{n(e)}),(e=>{r(e)}),0)}))}catch(n){return Promise.reject(n)}}function re(e,t,n,r,o,a,i,l,s,c){try{if(r<=a)return void l(b);o.value="k"===i?n[a]:a,H(e,t.body).then((u=>{try{u instanceof F?l(u):u===S?l(b):++c>T?(c=0,setTimeout((()=>{re(e,t,n,r,o,a+1,i,l,s,c)}),0)):re(e,t,n,r,o,a+1,i,l,s,c)}catch(f){s(f)}}),(e=>{s(e)}))}catch(u){s(u)}}function oe(e,t,n,r,o,a,i,l,s){try{if(n.length()<=o)return void i(b);r.value="k"===a?n.get(o):o,H(e,t.body).then((c=>{c instanceof F?i(c):c===S?i(b):++s>T?(s=0,setTimeout((()=>{oe(e,t,n,r,o+1,a,i,l,s)}),0)):oe(e,t,n,r,o+1,a,i,l,s)}),(e=>{l(e)}))}catch(c){l(c)}}function ae(e,t,n,r,o,a){try{if(void 0===a&&(a="i"),0===n.length)return void r.resolve(b);re(e,t,n,n.length,o,0,a,(e=>{r.resolve(e)}),(e=>{r.reject(e)}),0)}catch(i){r.reject(i)}}function ie(e,t,n,r,o,a){try{if(void 0===a&&(a="i"),0===n.length)return void r.resolve(b);oe(e,t,n,o,0,a,(e=>{r.resolve(e)}),(e=>{r.reject(e)}),0)}catch(i){r.reject(i)}}function le(e,t,n,r,o){try{ae(e,t,n.keys(),r,o,"k")}catch(a){r.reject(a)}}function se(e,t,n,r,o,a,l,s){try{e.next().then((c=>{try{if(null===c)a(b);else{const u=i.createFromGraphicLikeObject(c.geometry,c.attributes,r,t.timeZone);u._underlyingGraphic=c,o.value=u;H(t,n.body).then((i=>{try{i===S?a(b):i instanceof F?a(i):++s>T?(s=0,setTimeout((()=>{se(e,t,n,r,o,a,l,s)}),0)):se(e,t,n,r,o,a,l,s)}catch(c){l(c)}}),(e=>{l(e)}))}}catch(u){l(u)}}),(e=>{l(e)}))}catch(c){l(c)}}async function ce(e,t){return new Promise(((a,i)=>{H(e,t.right).then((l=>{try{let s=null;s="VariableDeclaration"===t.left.type?H(e,t.left):Promise.resolve(),s.then((()=>{try{let s="";if("VariableDeclaration"===t.left.type){const e=t.left.declarations[0].id;"Identifier"===e.type&&(s=e.name)}else"Identifier"===t.left.type&&(s=t.left.name);if(!s)throw new r(e,o.InvalidIdentifier,t);s=s.toLowerCase();let c=null;if(null!=e.localScope&&void 0!==e.localScope[s]&&(c=e.localScope[s]),null===c&&void 0!==e.globalScope[s]&&(c=e.globalScope[s]),null===c)return void i(new r(e,o.InvalidIdentifier,t));d(l)||m(l)?ae(e,t,l,{reject:i,resolve:a},c):w(l)?ie(e,t,l,{reject:i,resolve:a},c):l instanceof n||h(l)?le(e,t,l,{reject:i,resolve:a},c):I(l)?se(l.iterator(e.abortSignal),e,t,l,c,(e=>{a(e)}),(e=>{i(e)}),0):ae(e,t,[],{reject:i,resolve:a},c)}catch(s){i(s)}}),i)}catch(s){i(s)}}),i)}))}async function ue(e,t){const a=t.argument;if("MemberExpression"===a.type){const i={t:null},l=await H(e,a.object);let s=null;i.t=l,!0===a.computed?s=await H(e,a.property):"Identifier"===a.property.type&&(s=a.property.name);const c=i.t;let u;if(d(c)){if(!g(s))throw new r(e,o.ArrayAccessorMustBeNumber,t);if(s<0&&(s=c.length+s),s<0||s>=c.length)throw new r(e,o.OutOfBounds,t);u=C(c[s]),c[s]="++"===t.operator?u+1:u-1}else if(c instanceof n){if(!1===m(s))throw new r(e,o.KeyAccessorMustBeString,t);if(!0!==c.hasField(s))throw new r(e,o.FieldNotFound,t,{key:s});u=C(c.field(s)),c.setField(s,"++"===t.operator?u+1:u-1)}else if(c instanceof z){if(!1===m(s))throw new r(e,o.ModuleAccessorMustBeString,t);if(!0!==c.hasGlobal(s))throw new r(e,o.ModuleExportNotFound,t);u=C(await c.global(s)),c.setGlobal(s,"++"===t.operator?u+1:u-1)}else{if(!h(c))throw w(c)?new r(e,o.Immutable,t):new r(e,o.InvalidParameter,t);if(!1===m(s))throw new r(e,o.KeyAccessorMustBeString,t);if(!0!==c.hasField(s))throw new r(e,o.FieldNotFound,t,{key:s});u=C(c.field(s)),c.setField(s,"++"===t.operator?u+1:u-1)}return!1===t.prefix?u:"++"===t.operator?u+1:u-1}const i="Identifier"===t.argument.type?t.argument.name.toLowerCase():"";if(!i)throw new r(e,o.InvalidIdentifier,t);let l;if(null!=e.localScope&&void 0!==e.localScope[i])return l=C(e.localScope[i].value),e.localScope[i]={value:"++"===t.operator?l+1:l-1,valueset:!0,node:t},!1===t.prefix?l:"++"===t.operator?l+1:l-1;if(void 0!==e.globalScope[i])return l=C(e.globalScope[i].value),e.globalScope[i]={value:"++"===t.operator?l+1:l-1,valueset:!0,node:t},!1===t.prefix?l:"++"===t.operator?l+1:l-1;throw new r(e,o.InvalidIdentifier,t)}function fe(e,t,n,a,i){switch(t){case"=":return e===b?null:e;case"/=":return C(n)/C(e);case"*=":return C(n)*C(e);case"-=":return C(n)-C(e);case"+=":return m(n)||m(e)?R(n)+R(e):C(n)+C(e);case"%=":return C(n)%C(e);default:throw new r(i,o.UnsupportedOperator,a)}}async function pe(e,t){const a=t.left;if("MemberExpression"===a.type){const i=await H(e,a.object);let l=null;if(!0===a.computed)l=await H(e,a.property);else{if("Identifier"!==a.property.type)throw new r(e,o.InvalidIdentifier,t);l=a.property.name}const s=await H(e,t.right);if(d(i)){if(!g(l))throw new r(e,o.ArrayAccessorMustBeNumber,t);if(l<0&&(l=i.length+l),l<0||l>i.length)throw new r(e,o.OutOfBounds,t);if(l===i.length){if("="!==t.operator)throw new r(e,o.OutOfBounds,t);i[l]=fe(s,t.operator,i[l],t,e)}else i[l]=fe(s,t.operator,i[l],t,e)}else if(i instanceof n){if(!1===m(l))throw new r(e,o.KeyAccessorMustBeString,t);if(!0===i.hasField(l))i.setField(l,fe(s,t.operator,i.field(l),t,e));else{if("="!==t.operator)throw new r(e,o.FieldNotFound,t,{key:l});i.setField(l,fe(s,t.operator,null,t,e))}}else if(i instanceof z){if(!1===m(l))throw new r(e,o.KeyAccessorMustBeString,t);if(!0!==i.hasGlobal(l))throw new r(e,o.ModuleExportNotFound,t);i.setGlobal(l,fe(s,t.operator,await i.global(l),t,e))}else{if(!h(i))throw w(i)?new r(e,o.Immutable,t):new r(e,o.InvalidParameter,t);if(!1===m(l))throw new r(e,o.KeyAccessorMustBeString,t);if(!0===i.hasField(l))i.setField(l,fe(s,t.operator,i.field(l),t,e));else{if("="!==t.operator)throw new r(e,o.FieldNotFound,t,{key:l});i.setField(l,fe(s,t.operator,null,t,e))}}return b}const i=a.name.toLowerCase();if(null!=e.localScope&&void 0!==e.localScope[i]){const n=await H(e,t.right);return e.localScope[i]={value:fe(n,t.operator,e.localScope[i].value,t,e),valueset:!0,node:t.right},b}if(void 0!==e.globalScope[i]){const n=await H(e,t.right);return e.globalScope[i]={value:fe(n,t.operator,e.globalScope[i].value,t,e),valueset:!0,node:t.right},b}throw new r(e,o.InvalidIdentifier,t)}async function we(e,t){if("AssignmentExpression"===t.expression.type)return H(e,t.expression);if("CallExpression"===t.expression.type){const n=await H(e,t.expression);return n===b?b:new A(n)}const n=await H(e,t.expression);return n===b?b:new A(n)}async function de(e,t){const n=await H(e,t.test);if(!0===n)return H(e,t.consequent);if(!1===n)return null!==t.alternate?H(e,t.alternate):b;throw new r(e,o.BooleanConditionRequired,t)}async function he(e,t){return me(e,t,0)}async function me(e,t,n){if(n>=t.body.length)return b;const r=await H(e,t.body[n]);return r instanceof F||r===S||r===v||n===t.body.length-1?r:me(e,t,n+1)}async function ge(e,t){if(null===t.argument)return new F(b);const n=await H(e,t.argument);return new F(n)}async function ye(e,t){const n=t.id.name.toLowerCase();return e.globalScope[n]={valueset:!0,node:null,value:new _(t,e)},b}async function ve(e,t){const n=t.specifiers[0].local.name.toLowerCase(),r=e.libraryResolver.loadLibrary(n);let o=null;return e.libraryResolver._moduleSingletons?.has(r.uri)?o=e.libraryResolver._moduleSingletons.get(r.uri):(o=new z(r),await o.loadModule(e),e.libraryResolver._moduleSingletons?.set(r.uri,o)),e.globalScope[n]={value:o,valueset:!0,node:t},b}async function be(e,t){if(await H(e,t.declaration),"FunctionDeclaration"===t.declaration.type)e.exports[t.declaration.id.name.toLowerCase()]="function";else if("VariableDeclaration"===t.declaration.type)for(const n of t.declaration.declarations)e.exports[n.id.name.toLowerCase()]="variable";return b}async function Se(e,t,n){return n>=t.declarations.length?b:(await H(e,t.declarations[n]),n===t.declarations.length-1||await Se(e,t,n+1),b)}async function xe(e,t){let n=null;if(n=null===t.init?null:await H(e,t.init),null!==e.localScope){if(n===b&&(n=null),"Identifier"!==t.id.type)throw new r(e,o.InvalidIdentifier,t);const a=t.id.name.toLowerCase();return null!=e.localScope&&(e.localScope[a]={value:n,valueset:!0,node:t.init}),b}if("Identifier"!==t.id.type)throw new r(e,o.InvalidIdentifier,t);const a=t.id.name.toLowerCase();return n===b&&(n=null),e.globalScope[a]={value:n,valueset:!0,node:t.init},b}async function Fe(e,t){const a=await H(e,t.object);if(null===a)throw new r(e,o.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(a instanceof n||h(a))return a.field(t.property.name);if(a instanceof Z)return P(a,t.property.name,e,t);if(a instanceof z){if(!a.hasGlobal(t.property.name))throw new r(e,o.InvalidIdentifier,t);return a.global(t.property.name)}throw new r(e,o.InvalidMemberAccessKey,t)}throw new r(e,o.InvalidMemberAccessKey,t)}let i=await H(e,t.property);if(a instanceof n||h(a)){if(m(i))return a.field(i);throw new r(e,o.InvalidMemberAccessKey,t)}if(a instanceof z){if(m(i))return a.global(i);throw new r(e,o.InvalidMemberAccessKey,t)}if(a instanceof Z){if(m(i))return P(a,i,e,t);throw new r(e,o.InvalidMemberAccessKey,t)}if(d(a)){if(g(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=a.length+i),i>=a.length||i<0)throw new r(e,o.OutOfBounds,t);return a[i]}throw new r(e,o.InvalidMemberAccessKey,t)}if(w(a)){if(g(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=a.length()+i),i>=a.length()||i<0)throw new r(e,o.OutOfBounds,t);return a.get(i)}throw new r(e,o.InvalidMemberAccessKey,t)}if(m(a)){if(g(i)&&isFinite(i)&&Math.floor(i)===i){if(i<0&&(i=a.length+i),i>=a.length||i<0)throw new r(e,o.OutOfBounds,t);return a[i]}throw new r(e,o.InvalidMemberAccessKey,t)}throw new r(e,o.InvalidMemberAccessKey,t)}async function Ie(e,t){const n=await H(e,t.argument);if(p(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*C(n);if("+"===t.operator)return 1*C(n);if("~"===t.operator)return~C(n);throw new r(e,o.UnsupportedUnaryOperator,t)}if("-"===t.operator)return-1*C(n);if("+"===t.operator)return 1*C(n);if("~"===t.operator)return~C(n);throw new r(e,o.UnsupportedUnaryOperator,t)}async function Ce(e,t){const n=[];for(let r=0;r<t.elements.length;r++)n.push(await H(e,t.elements[r]));for(let a=0;a<n.length;a++){if(x(n[a]))throw new r(e,o.NoFunctionInArray,t);n[a]===b&&(n[a]=null)}return n}async function Ae(e,t){const n=[];n[0]=await H(e,t.left),n[1]=await H(e,t.right);const a=n[0],i=n[1];switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return j(C(a),C(i),t.operator);case"==":return y(a,i);case"!=":return!y(a,i);case"<":case">":case"<=":case">=":return M(a,i,t.operator);case"+":return m(a)||m(i)?R(a)+R(i):C(a)+C(i);case"-":return C(a)-C(i);case"*":return C(a)*C(i);case"/":return C(a)/C(i);case"%":return C(a)%C(i);default:throw new r(e,o.UnsupportedOperator,t)}}async function Re(e,t){const n=await H(e,t.left);let a=null;if(!p(n))throw new r(e,o.LogicalExpressionOnlyBoolean,t);switch(t.operator){case"||":if(!0===n)return n;if(a=await H(e,t.right),p(a))return a;throw new r(e,o.LogicExpressionOrAnd,t);case"&&":if(!1===n)return n;if(a=await H(e,t.right),p(a))return a;throw new r(e,o.LogicExpressionOrAnd,t);default:throw new r(e,o.LogicExpressionOrAnd,t)}}async function Me(e,t){const n=t.name.toLowerCase();if(null!=e.localScope&&void 0!==e.localScope[n]){const t=e.localScope[n];if(!0===t.valueset)return t.value;if(null!==t.d)return t.d;t.d=H(e,t.node);const r=await t.d;return t.value=r,t.valueset=!0,r}if(void 0!==e.globalScope[n]){const t=e.globalScope[n];if(!0===t.valueset)return t.value;if(null!==t.d)return t.d;t.d=H(e,t.node);const r=await t.d;return t.value=r,t.valueset=!0,r}throw new r(e,o.InvalidIdentifier,t)}async function je(e,t){if("MemberExpression"===t.callee.type){const n=await H(e,t.callee.object);if(!(n instanceof z))throw new r(e,o.FunctionNotFound,t);const a=!1===t.callee.computed?t.callee.property.name:await H(e,t.callee.property);if(!n.hasGlobal(a))throw new r(e,o.FunctionNotFound,t);const i=await n.global(a);if(!x(i))throw new r(e,o.CallNonFunction,t);return i.call(e,t)}if("Identifier"!==t.callee.type)throw new r(e,o.FunctionNotFound,t);if(null!=e.localScope&&void 0!==e.localScope[t.callee.name.toLowerCase()]){const n=e.localScope[t.callee.name.toLowerCase()];if(x(n.value))return n.value.call(e,t);throw new r(e,o.CallNonFunction,t)}if(void 0!==e.globalScope[t.callee.name.toLowerCase()]){const n=e.globalScope[t.callee.name.toLowerCase()];if(x(n.value))return n.value.call(e,t);throw new r(e,o.CallNonFunction,t)}throw new r(e,o.FunctionNotFound,t)}async function ke(e,t){return t.value?t.value.cooked:""}function Le(e,t,n){if(x(e))throw new r(t,o.NoFunctionInTemplateLiteral,n);return e}async function Ee(e,t){const n=[];for(let a=0;a<t.expressions.length;a++){const r=await H(e,t.expressions[a]);n[a]=R(r)}let r="",o=0;for(const a of t.quasis)if(r+=a.value?a.value.cooked:"",!1===a.tail){r+=n[o]?Le(n[o],e,t):"",o++}return r}const Ne={};async function Oe(e,t,n,r){const o=await H(e,t.arguments[n]);if(y(o,r))return H(e,t.arguments[n+1]);const a=t.arguments.length-n;return 1===a?H(e,t.arguments[n]):2===a?null:3===a?H(e,t.arguments[n+2]):Oe(e,t,n+2,r)}async function Be(e,t,n,a){if(!0===a)return H(e,t.arguments[n+1]);if(3===t.arguments.length-n)return H(e,t.arguments[n+2]);const i=await H(e,t.arguments[n+2]);if(!1===p(i))throw new r(e,o.ModuleExportNotFound,t.arguments[n+2]);return Be(e,t,n+2,i)}async function Pe(e,t,n,a){const i=e.body;if(n.length!==e.params.length)throw new r(t,o.WrongNumberOfParameters,null);for(let r=0;r<n.length;r++){const o=e.params[r];"Identifier"===o.type&&null!=t.localScope&&(t.localScope[o.name.toLowerCase()]={d:null,value:n[r],valueset:!0,node:null})}const l=await H(t,i);if(l instanceof F)return l.value;if(l===S)throw new r(t,o.UnexpectedToken,a);if(l===v)throw new r(t,o.UnexpectedToken,a);return l instanceof A?l.value:l}N(Ne,V),G(Ne,V),K(Ne,V),B(Ne,V),D(Ne,V),O({functions:Ne,compiled:!1,signatures:null,evaluateIdentifier:null,mode:"async",standardFunction:V,standardFunctionAsync:Y}),Ne.iif=async function(e,t){f(null===t.arguments?[]:t.arguments,3,3,e,t);const n=await H(e,t.arguments[0]);if(!1===p(n))throw new r(e,o.BooleanConditionRequired,t);return H(e,n?t.arguments[1]:t.arguments[2])},Ne.defaultvalue=async function(e,t){f(null===t.arguments?[]:t.arguments,2,3,e,t);const a=await H(e,t.arguments[0]);if(3===t.arguments.length){const i=await H(e,t.arguments[1]);let l=[];if(w(i))l=i.toArray();else{if(!d(i))throw new r(e,o.InvalidParameter,t);l=i}let s=a;if(null===s)return H(e,t.arguments[2]);for(const r of l)if(h(s)){if(!1===m(r))return H(e,t.arguments[2]);if(!s.hasField(r))return H(e,t.arguments[2]);s=s.field(r)}else if(s instanceof n){if(!1===m(r))return H(e,t.arguments[2]);if(!s.hasField(r))return H(e,t.arguments[2]);s=s.field(r)}else if(s instanceof Z){if(!1===m(r))return H(e,t.arguments[2]);if(s=P(s,r,null,null,2),null===s)return H(e,t.arguments[2]);if("notfound"===s?.keystate)return H(e,t.arguments[2])}else if(d(s)){if(!1===g(r))return H(e,t.arguments[2]);if(s=s[r],null==s)return H(e,t.arguments[2])}else{if(!w(s))return H(e,t.arguments[2]);if(!1===g(r))return H(e,t.arguments[2]);if(s=s.get(r),null==s)return H(e,t.arguments[2])}return s}return null==a||""===a?H(e,t.arguments[1]):a},Ne.decode=async function(e,t){if(t.arguments.length<2)throw new r(e,o.WrongNumberOfParameters,t);if(2===t.arguments.length)return H(e,t.arguments[1]);if((t.arguments.length-1)%2==0)throw new r(e,o.WrongNumberOfParameters,t);return Oe(e,t,1,await H(e,t.arguments[0]))},Ne.when=async function(e,t){if(t.arguments.length<3)throw new r(e,o.WrongNumberOfParameters,t);if(t.arguments.length%2==0)throw new r(e,o.WrongNumberOfParameters,t);const n=await H(e,t.arguments[0]);if(!1===p(n))throw new r(e,o.BooleanConditionRequired,t.arguments[0]);return Be(e,t,0,n)};const Ke={fixSpatialReference:k,parseArguments:W,standardFunction:V,standardFunctionAsync:Y,evaluateIdentifier:Me};for(const We in Ne)Ne[We]={value:new l(Ne[We]),valueset:!0,node:null};const De=function(){};function Ge(e,t,r){const o=new De;null==e&&(e={}),null==t&&(t={});const a=new n({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});a.immutable=!1,o.textformatting={value:a,valueset:!0,node:null};for(const n in t)o[n]={value:new l(t[n]),native:!0,valueset:!0,node:null};for(const n in e)e[n]&&"esri.Graphic"===e[n].declaredClass?o[n]={value:i.createFromGraphic(e[n],r),valueset:!0,node:null}:o[n]={value:e[n],valueset:!0,node:null};return o}function Ze(e){console.log(e)}De.prototype=Ne,De.prototype.infinity={value:Number.POSITIVE_INFINITY,valueset:!0,node:null},De.prototype.pi={value:Math.PI,valueset:!0,node:null};const Ue=Ke;function qe(e){const t={mode:"async",compiled:!1,functions:{},signatures:[],standardFunction:V,standardFunctionAsync:Y,evaluateIdentifier:Me};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)Ne[n]={value:new l(t.functions[n]),valueset:!0,node:null},De.prototype[n]=Ne[n];for(let n=0;n<t.signatures.length;n++)L(t.signatures[n],"async")}async function Te(e,n){let a=n.spatialReference;null==a&&(a=new U({wkid:102100}));let i=null;e.usesModules&&(i=new t(new Map,e.loadedModules));const l=Ge(n.vars,n.customfunctions,n.timeZone),s={spatialReference:a,services:n.services,exports:{},libraryResolver:i,abortSignal:void 0===n.abortSignal||null===n.abortSignal?{aborted:!1}:n.abortSignal,globalScope:l,console:n.console??Ze,timeZone:n.timeZone??null,lrucache:n.lrucache,interceptor:n.interceptor,localScope:null,depthCounter:{depth:1}};let c=await H(s,e);if(c instanceof F&&(c=c.value),c instanceof A&&(c=c.value),c===b&&(c=null),c===S)throw new r(s,o.IllegalResult,null);if(c===v)throw new r(s,o.IllegalResult,null);if(x(c))throw new r(s,o.IllegalResult,null);return c}qe([E]);export{Te as executeScript,qe as extend,Ue 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.29/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeModule as e}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import t from"./Dictionary.js";import{ArcadeExecutionError as o,ExecutionErrorCodes as r,ArcadeCompilationError as l,ArcadeUncompilableError as a}from"./executionError.js";import s from"./Feature.js";import{NativeFunction as i,ArcadeFunction as u,ScopeMarshalledFunction as c,wrapModuleScopedResponse as p}from"./FunctionWrapper.js";import{i as m,w as g,x as f,R as d,I as h,y,z as b,A as w,b as S,o as v,q as x,r as F,c as M,v as $,p as C,j as A,a as I,g as _,B as O,C as k,D as E}from"../chunks/languageUtils.js";import{addFunctionDeclaration as G}from"./treeAnalysis.js";import{A as B}from"../chunks/array.js";import{registerFunctions as N}from"./functions/date.js";import{registerFunctions as j,geometryMember as L}from"./functions/geometry.js";import{registerFunctions as R}from"./functions/geomsync.js";import{registerFunctions as D}from"./functions/maths.js";import{registerFunctions as U}from"./functions/stats.js";import{registerFunctions as P}from"./functions/string.js";import{isPromiseLike as Z}from"../core/promiseUtils.js";import K from"../geometry/Geometry.js";import T from"../geometry/SpatialReference.js";class q extends u{constructor(e,n){super(),this.paramCount=n,this.fn=e}createFunction(e){return(...n)=>{if(n.length!==this.paramCount)throw new o(e,r.WrongNumberOfParameters,null);return this.fn(...n)}}call(e,n){return this.fn(...n.arguments)}marshalledCall(e,n,t,o){return o(e,n,((n,r,l)=>{l=l.map((n=>!m(n)||n instanceof c?n:p(n,e,o)));const a=this.call(t,{arguments:l});return Z(a)?a.then((e=>p(e,t,o))):a}))}}function W(e,n){const t=[];for(let o=0;o<n.arguments.length;o++)t.push(V(e,n.arguments[o]));return t}function z(e,n,t){try{return t(e,null,n.arguments)}catch(o){throw o}}function V(e,n){try{switch(n.type){case"EmptyStatement":return"lc.voidOperation";case"VariableDeclarator":return me(e,n);case"VariableDeclaration":return pe(e,n);case"BlockStatement":case"Program":return le(e,n);case"FunctionDeclaration":return ce(e,n);case"ImportDeclaration":return se(e,n);case"ExportNamedDeclaration":return ie(e,n);case"ReturnStatement":return ae(e,n);case"IfStatement":return re(e,n);case"ExpressionStatement":return te(e,n);case"AssignmentExpression":return ne(e,n);case"UpdateExpression":return X(e,n);case"BreakStatement":return"break";case"ContinueStatement":return"continue";case"TemplateLiteral":return he(e,n);case"TemplateElement":return JSON.stringify(n.value?n.value.cooked:"");case"ForStatement":return Q(e,n);case"ForInStatement":return H(e,n);case"WhileStatement":return ee(e,n);case"Identifier":return we(e,n);case"MemberExpression":return ge(e,n);case"Literal":return null===n.value||void 0===n.value?"null":JSON.stringify(n.value);case"CallExpression":return Se(e,n);case"UnaryExpression":return fe(e,n);case"BinaryExpression":return ye(e,n);case"LogicalExpression":return be(e,n);case"ArrayExpression":return de(e,n);case"ObjectExpression":return J(e,n);case"Property":return Y(e,n);case"Array":throw new l(e,r.NeverReach,n);default:throw new l(e,r.Unrecognized,n)}}catch(t){throw t}}function J(e,n){let t="lang.dictionary([";for(let o=0;o<n.properties.length;o++){const r=n.properties[o];ue(r.key.name);o>0&&(t+=","),t+="lang.strCheck("+("Identifier"===r.key.type?"'"+r.key.name+"'":V(e,r.key))+",'ObjectExpression'),lang.aCheck("+V(e,r.value)+", 'ObjectExpression')"}return t+="])",t}function Y(e,n){throw new l(e,r.NeverReach,n)}function H(e,n){const t=Ae(e),o=Ae(e),r=Ae(e);let l="var "+t+" = "+V(e,n.right)+";\n";"VariableDeclaration"===n.left.type&&(l+=V(e,n.left));let a="VariableDeclaration"===n.left.type?n.left.declarations[0].id.name:n.left.name;a=a.toLowerCase(),ue(a);let s="";null!==e.localScope&&(void 0!==e.localScope[a]?s="lscope['"+a+"']":void 0!==e.localScope._SymbolsMap[a]&&(s="lscope['"+e.localScope._SymbolsMap[a]+"']"));let i="";if(""===s)if(void 0!==e.globalScope[a])s="gscope['"+a+"']";else if(void 0!==e.globalScope._SymbolsMap[a])s="gscope['"+e.globalScope._SymbolsMap[a]+"']";else if(null!==e.localScope)if(e.undeclaredGlobalsInFunctions.has(a))s="gscope['"+e.undeclaredGlobalsInFunctions.get(a).manglename+"']",i=e.undeclaredGlobalsInFunctions.get(a).manglename;else{const t={manglename:Ce(e),node:n.left};e.undeclaredGlobalsInFunctions.set(a,t),s="gscope['"+t.manglename+"']",i=t.manglename}return i&&(l+="lang.chkAssig('"+i+"',runtimeCtx); \n"),l+="if ("+t+"===null) { lastStatement = lc.voidOperation; }\n ",l+="else if (lc.isArray("+t+") || lc.isString("+t+")) {",l+="var "+o+"="+t+".length; \n",l+="for(var "+r+"=0; "+r+"<"+o+"; "+r+"++) {\n",l+=s+"="+r+";\n",l+=V(e,n.body),l+="\n}\n",l+=" lastStatement = lc.voidOperation; \n",l+=" \n}\n",l+="else if (lc.isImmutableArray("+t+")) {",l+="var "+o+"="+t+".length(); \n",l+="for(var "+r+"=0; "+r+"<"+o+"; "+r+"++) {\n",l+=s+"="+r+";\n",l+=V(e,n.body),l+="\n}\n",l+=" lastStatement = lc.voidOperation; \n",l+=" \n}\n",l+="else if (( "+t+" instanceof lang.Dictionary) || ( "+t+" instanceof lang.Feature)) {",l+="var "+o+"="+t+".keys(); \n",l+="for(var "+r+"=0; "+r+"<"+o+".length; "+r+"++) {\n",l+=s+"="+o+"["+r+"];\n",l+=V(e,n.body),l+="\n}\n",l+=" lastStatement = lc.voidOperation; \n",l+=" \n}\n",e.isAsync&&(l+="else if (lc.isFeatureSet("+t+")) {",l+="var "+o+"="+t+".iterator(runtimeCtx.abortSignal); \n",l+="for(var "+r+"=lang. graphicToFeature( yield "+o+".next(),"+t+", runtimeCtx); "+r+"!=null; "+r+"=lang. graphicToFeature( yield "+o+".next(),"+t+", runtimeCtx)) {\n",l+=s+"="+r+";\n",l+=V(e,n.body),l+="\n}\n",l+=" lastStatement = lc.voidOperation; \n",l+=" \n}\n"),l+="else { lastStatement = lc.voidOperation; } \n",l}function Q(e,n){let t="lastStatement = lc.voidOperation; \n";null!==n.init&&(t+=V(e,n.init)+"; ");const o=Ae(e),l=Ae(e);return t+="var "+o+" = true; ",t+="\n do { ",null!==n.update&&(t+=" if ("+o+"===false) {\n "+V(e,n.update)+" \n}\n "+o+"=false; \n"),null!==n.test&&(t+="var "+l+" = "+V(e,n.test)+"; ",t+="if ("+l+"===false) { break; } else if ("+l+"!==true) { lang.error('"+r.BooleanConditionRequired+"'); }\n"),t+=V(e,n.body),null!==n.update&&(t+="\n "+V(e,n.update)),t+="\n"+o+" = true; \n} while(true); lastStatement = lc.voidOperation; ",t}function X(e,n){let t=null,l="";if("MemberExpression"===n.argument.type)return t=V(e,n.argument.object),!0===n.argument.computed?l=V(e,n.argument.property):(l="'"+n.argument.property.name+"'",ue(n.argument.property.name)),"lang.memberupdate("+t+","+l+",'"+n.operator+"',"+n.prefix+")";if(t=n.argument.name.toLowerCase(),ue(t),null!==e.localScope){if(void 0!==e.localScope[t])return"lang.update(lscope, '"+t+"','"+n.operator+"',"+n.prefix+")";if(void 0!==e.localScope._SymbolsMap[t])return"lang.update(lscope, '"+e.localScope._SymbolsMap[t]+"','"+n.operator+"',"+n.prefix+")"}if(void 0!==e.globalScope[t])return"lang.update(gscope, '"+t+"','"+n.operator+"',"+n.prefix+")";if(void 0!==e.globalScope._SymbolsMap[t])return"lang.update(gscope, '"+e.globalScope._SymbolsMap[t]+"','"+n.operator+"',"+n.prefix+")";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(t))return"lang.update(gscope,lang.chkAssig( '"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx),'"+n.operator+"',"+n.prefix+")";const o={manglename:Ce(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(t,o),"lang.update(gscope, lang.chkAssig('"+o.manglename+"',runtimeCtx),'"+n.operator+"',"+n.prefix+")"}throw new o(e,r.InvalidIdentifier,n)}function ee(e,n){let t="lastStatement = lc.voidOperation; \n";const o=Ae(e);return t+=`\n var ${o} = true;\n do {\n ${o} = ${V(e,n.test)};\n if (${o}==false) {\n break;\n }\n if (${o}!==true) {\n lang.error('${r.BooleanConditionRequired}');\n }\n ${V(e,n.body)}\n }\n while (${o} !== false);\n lastStatement = lc.voidOperation;\n `,t}function ne(e,n){const t=V(e,n.right);let l=null,a="";if("MemberExpression"===n.left.type)return l=V(e,n.left.object),!0===n.left.computed?a=V(e,n.left.property):(a="'"+n.left.property.name+"'",ue(n.left.property.name)),"lang.assignmember("+l+","+a+",'"+n.operator+"',"+t+")";if(l=n.left.name.toLowerCase(),ue(l),null!==e.localScope){if(void 0!==e.localScope[l])return"lscope['"+l+"']=lang.assign("+t+",'"+n.operator+"', lscope['"+l+"'])";if(void 0!==e.localScope._SymbolsMap[l])return"lscope['"+e.localScope._SymbolsMap[l]+"']=lang.assign("+t+",'"+n.operator+"', lscope['"+e.localScope._SymbolsMap[l]+"'])"}if(void 0!==e.globalScope[l])return"gscope['"+l+"']=lang.assign("+t+",'"+n.operator+"', gscope['"+l+"'])";if(void 0!==e.globalScope._SymbolsMap[l])return"gscope['"+e.globalScope._SymbolsMap[l]+"']=lang.assign("+t+",'"+n.operator+"', gscope['"+e.globalScope._SymbolsMap[l]+"'])";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(l))return"gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(l).manglename+"',runtimeCtx)]=lang.assign("+t+",'"+n.operator+"', gscope['"+e.undeclaredGlobalsInFunctions.get(l).manglename+"'])";const o={manglename:Ce(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(l,o),"gscope[lang.chkAssig('"+o.manglename+"',runtimeCtx)]=lang.assign("+t+",'"+n.operator+"', gscope['"+o.manglename+"'])"}throw new o(e,r.InvalidIdentifier,n)}function te(e,n){return"AssignmentExpression"===n.expression.type?"lastStatement = lc.voidOperation; "+V(e,n.expression)+"; \n ":(n.expression.type,"lastStatement = "+V(e,n.expression)+"; ")}function oe(e,n){return"BlockStatement"===n.type?V(e,n):"ReturnStatement"===n.type||"BreakStatement"===n.type||"ContinueStatement"===n.type?V(e,n)+"; ":"UpdateExpression"===n.type?"lastStatement = "+V(e,n)+"; ":"ExpressionStatement"===n.type?V(e,n):"ObjectExpression"===n.type?"lastStatement = "+V(e,n)+"; ":V(e,n)+"; "}function re(e,n){if("AssignmentExpression"===n.test.type||"UpdateExpression"===n.test.type)throw new l(e,r.BooleanConditionRequired,n);return`if (lang.mustBoolean(${V(e,n.test)}, runtimeCtx) === true) {\n ${oe(e,n.consequent)}\n } `+(null!==n.alternate?"IfStatement"===n.alternate.type?" else "+re(e,n.alternate):` else {\n ${oe(e,n.alternate)}\n }\n`:" else {\n lastStatement = lc.voidOperation;\n }\n")}function le(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+=V(e,n.body[o])+"; \n":"UpdateExpression"===n.body[o].type||"ObjectExpression"===n.body[o].type?t+="lastStatement = "+V(e,n.body[o])+"; \n":t+=V(e,n.body[o])+" \n");return t}function ae(e,n){if(null===n.argument)return"return lc.voidOperation";return"return "+V(e,n.argument)}function se(e,n){const t=n.specifiers[0].local.name.toLowerCase();ue(t);const o=e.libraryResolver?.loadLibrary(t),r=Ce(e);void 0===e.moduleFactory[o.uri]&&(e.moduleFactory[o.uri]=Ke(o.syntax,{interceptor:e.interceptor,services:e.services,moduleFactory:e.moduleFactory,lrucache:e.lrucache,timeZone:e.timeZone??null,libraryResolver:e.libraryResolver,customfunctions:e.customfunctions,vars:{}},e.isAsync)),e.moduleFactoryMap[r]=o.uri;let l="";if(l=e.isAsync?"(yield lang.loadModule('"+r+"', runtimeCtx) ); ":"lang.loadModule('"+r+"', runtimeCtx); ",void 0!==e.globalScope[t])return"gscope['"+t+"']="+l;if(void 0!==e.globalScope._SymbolsMap[t])return"gscope['"+e.globalScope._SymbolsMap[t]+"']="+l;let a="";return e.undeclaredGlobalsInFunctions.has(t)?(a=e.undeclaredGlobalsInFunctions.get(t).manglename,e.undeclaredGlobalsInFunctions.delete(t)):a=Ce(e),e.globalScope._SymbolsMap[t]=a,e.mangleMap[t]=a,"gscope[lang.setAssig('"+a+"', runtimeCtx)]="+l}function ie(e,n){const t=V(e,n.declaration);if("FunctionDeclaration"===n.declaration.type)e.exports[n.declaration.id.name.toLowerCase()]="function";else if("VariableDeclaration"===n.declaration.type)for(const o of n.declaration.declarations)e.exports[o.id.name.toLowerCase()]="variable";return t}function ue(e){if("iif"===e)throw new a;if("decode"===e)throw new a;if("when"===e)throw new a;if("defaultvalue"===e)throw new a}function ce(e,n){const t=n.id.name.toLowerCase();ue(t);let o="",r=!1;void 0!==e.globalScope[t]?o=t:void 0!==e.globalScope._SymbolsMap[t]?o=e.globalScope._SymbolsMap[t]:e.undeclaredGlobalsInFunctions.has(t)?(o=e.undeclaredGlobalsInFunctions.get(t).manglename,e.globalScope._SymbolsMap[t]=o,e.mangleMap[t]=o,e.undeclaredGlobalsInFunctions.delete(t),r=!0):(o=Ce(e),e.globalScope._SymbolsMap[t]=o,e.mangleMap[t]=o);const l={isAsync:e.isAsync,console:e.console,exports:e.exports,undeclaredGlobalsInFunctions:e.undeclaredGlobalsInFunctions,customfunctions:e.customfunctions,moduleFactory:e.moduleFactory,moduleFactoryMap:e.moduleFactoryMap,libraryResolver:e.libraryResolver,lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,symbols:e.symbols,mangleMap:e.mangleMap,localScope:{_SymbolsMap:{}},depthCounter:e.depthCounter,globalScope:e.globalScope};let a="new lang.UserDefinedCompiledFunction( lang.functionDepthchecker(function() { var lastStatement = lc.voidOperation; \n var lscope = runtimeCtx.localStack[runtimeCtx.localStack.length-1];\n";for(let s=0;s<n.params.length;s++){const t=n.params[s].name.toLowerCase();ue(t);const o=Ce(e);l.localScope._SymbolsMap[t]=o,l.mangleMap[t]=o,a+="lscope['"+o+"']=arguments["+s.toString()+"];\n"}return!0===e.isAsync?(a+="return lang.__awaiter(this, void 0, void 0, function* () {\n",a+=le(l,n.body)+"\n return lastStatement; ",a+="}); }",a+=", runtimeCtx),"+n.params.length+")",a+="\n lastStatement = lc.voidOperation; \n"):(a+=le(l,n.body)+"\n return lastStatement; }, runtimeCtx),"+n.params.length+")",a+="\n lastStatement = lc.voidOperation; \n"),r?"gscope[lang.setAssig('"+o+"', runtimeCtx)]="+a:"gscope['"+o+"']="+a}function pe(e,n){const t=[];for(let o=0;o<n.declarations.length;o++)t.push(V(e,n.declarations[o]));return t.join("\n")+" \n lastStatement= lc.voidOperation; \n"}function me(e,n){let t=null===n.init?null:V(e,n.init);t===y&&(t=null);const o=n.id.name.toLowerCase();if(ue(o),null!==e.localScope){if(void 0!==e.localScope[o])return"lscope['"+o+"']="+t+"; ";if(void 0!==e.localScope._SymbolsMap[o])return"lscope['"+e.localScope._SymbolsMap[o]+"']="+t+"; ";{const n=Ce(e);return e.localScope._SymbolsMap[o]=n,e.mangleMap[o]=n,"lscope['"+n+"']="+t+"; "}}if(void 0!==e.globalScope[o])return"gscope['"+o+"']="+t+"; ";if(void 0!==e.globalScope._SymbolsMap[o])return"gscope['"+e.globalScope._SymbolsMap[o]+"']="+t+"; ";if(e.undeclaredGlobalsInFunctions.has(o)){const n=e.undeclaredGlobalsInFunctions.get(o).manglename;return e.globalScope._SymbolsMap[o]=n,e.mangleMap[o]=n,e.undeclaredGlobalsInFunctions.delete(o),"gscope[lang.setAssig('"+n+"', runtimeCtx)]="+t+"; "}const r=Ce(e);return e.globalScope._SymbolsMap[o]=r,e.mangleMap[o]=r,"gscope['"+r+"']="+t+"; "}function ge(e,n){try{let t;return!0===n.computed?t=V(e,n.property):(t="'"+n.property.name+"'",ue(n.property.name)),"lang.member("+V(e,n.object)+","+t+")"}catch(t){throw t}}function fe(e,n){try{return"lang.unary("+V(e,n.argument)+",'"+n.operator+"')"}catch(t){throw t}}function de(e,n){try{const t=[];for(let o=0;o<n.elements.length;o++)"Literal"===n.elements[o].type?t.push(V(e,n.elements[o])):t.push("lang.aCheck("+V(e,n.elements[o])+",'ArrayExpression')");return"["+t.join(",")+"]"}catch(t){throw t}}function he(e,n){try{const t=[];let o=0;for(const r of n.quasis)t.push(r.value?JSON.stringify(r.value.cooked):JSON.stringify("")),!1===r.tail&&(t.push(n.expressions[o]?"lang.castString(lang.aCheck("+V(e,n.expressions[o])+", 'TemplateLiteral'))":""),o++);return"(["+t.join(",")+"]).join('')"}catch(t){throw t}}function ye(e,n){try{return"lang.binary("+V(e,n.left)+","+V(e,n.right)+",'"+n.operator+"')"}catch(t){throw t}}function be(e,n){try{if("AssignmentExpression"===n.left.type||"UpdateExpression"===n.left.type)throw new l(e,r.LogicalExpressionOnlyBoolean,n);if("AssignmentExpression"===n.right.type||"UpdateExpression"===n.right.type)throw new l(e,r.LogicalExpressionOnlyBoolean,n);if("&&"===n.operator||"||"===n.operator)return"(lang.logicalCheck("+V(e,n.left)+") "+n.operator+" lang.logicalCheck("+V(e,n.right)+"))";throw new l(null,r.LogicExpressionOrAnd,null)}catch(t){throw t}}function we(e,n){try{const t=n.name.toLowerCase();if(ue(t),null!==e.localScope){if(void 0!==e.localScope[t])return"lscope['"+t+"']";if(void 0!==e.localScope._SymbolsMap[t])return"lscope['"+e.localScope._SymbolsMap[t]+"']"}if(void 0!==e.globalScope[t])return"gscope['"+t+"']";if(void 0!==e.globalScope._SymbolsMap[t])return"gscope['"+e.globalScope._SymbolsMap[t]+"']";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(t))return"gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx)]";const o={manglename:Ce(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(t,o),"gscope[lang.chkAssig('"+o.manglename+"',runtimeCtx)]"}throw new l(e,r.InvalidIdentifier,n)}catch(t){throw t}}function Se(e,n){try{if("MemberExpression"===n.callee.type){let t;!0===n.callee.computed?t=V(e,n.callee.property):(t="'"+n.callee.property.name+"'",ue(n.callee.property.name));let o="[";for(let r=0;r<n.arguments.length;r++)r>0&&(o+=", "),o+=V(e,n.arguments[r]);return o+="]",e.isAsync?"(yield lang.callModuleFunction("+V(e,n.callee.object)+","+o+","+t+",runtimeCtx))":"lang.callModuleFunction("+V(e,n.callee.object)+","+o+","+t+",runtimeCtx)"}if("Identifier"!==n.callee.type)throw new l(e,r.FunctionNotFound,n);const t=n.callee.name.toLowerCase();if("iif"===t)return ve(e,n);if("when"===t)return Fe(e,n);if("defaultvalue"===t)return xe(e,n);if("decode"===t)return Me(e,n);let o="";if(null!==e.localScope&&(void 0!==e.localScope[t]?o="lscope['"+t+"']":void 0!==e.localScope._SymbolsMap[t]&&(o="lscope['"+e.localScope._SymbolsMap[t]+"']")),""===o)if(void 0!==e.globalScope[t])o="gscope['"+t+"']";else if(void 0!==e.globalScope._SymbolsMap[t])o="gscope['"+e.globalScope._SymbolsMap[t]+"']";else if(null!==e.localScope)if(e.undeclaredGlobalsInFunctions.has(t))o="gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx)]";else{const r={manglename:Ce(e),node:n.argument};e.undeclaredGlobalsInFunctions.set(t,r),o="gscope[lang.chkAssig('"+r.manglename+"',runtimeCtx)]"}if(""!==o){let t="[";for(let o=0;o<n.arguments.length;o++)o>0&&(t+=", "),t+=V(e,n.arguments[o]);return t+="]",e.isAsync?"(yield lang.callfunc("+o+","+t+",runtimeCtx) )":"lang.callfunc("+o+","+t+",runtimeCtx)"}throw new l(e,r.FunctionNotFound,n)}catch(t){throw t}}function ve(e,n){try{if(3!==n.arguments.length)throw new l(e,r.WrongNumberOfParameters,n);const t=Ae(e);return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${V(e,n.arguments[0])};\n\n if (${t} === true) {\n return ${V(e,n.arguments[1])};\n }\n else if (${t} === false) {\n return ${V(e,n.arguments[2])};\n }\n else {\n lang.error('ExecutionErrorCodes.BooleanConditionRequired');\n }\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function xe(e,n){try{if(n.arguments.length<2||n.arguments.length>3)throw new l(e,r.WrongNumberOfParameters,n);const t=Ae(e),o=Ae(e),a=Ae(e),s=Ae(e);return 3===n.arguments.length?`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${V(e,n.arguments[0])};\n var ${o} = ${V(e,n.arguments[1])};\n var ${a} = [];\n if (lang.isImmutableArray(${o})) {\n ${a} = ${o}.toArray();\n } else if (lang.isArray(${o})) {\n ${a} = ${o};\n } else {\n lang.error('${r.InvalidParameter}');\n }\n if (${t} === null) {\n return ${V(e,n.arguments[2])};\n }\n for (var ${s} of ${a}) {\n if (lang.isFeature(${t})) {\n if (lang.isString(${s}) === false) {\n return ${V(e,n.arguments[2])};\n }\n if (!${t}.hasField(${s})) {\n return ${V(e,n.arguments[2])};\n }\n ${t} = ${t}.field(${s});\n } else if (lang.isDictionary(${t})) {\n if (lang.isString(${s}) === false) {\n return ${V(e,n.arguments[2])};\n }\n if (!${t}.hasField(${s})) {\n return ${V(e,n.arguments[2])};\n }\n ${t} = ${t}.field(${s});\n } else if (lang.isGeometry(${t})) {\n if (lang.isString(${s}) === false) {\n return ${V(e,n.arguments[2])};\n }\n ${t} = lang.geometryMember(${t}, ${s}, null, null, 2);\n if (${t} === null) {\n return ${V(e,n.arguments[2])};\n }\n if (${t} && ${t}.keystate === "notfound") {\n return ${V(e,n.arguments[2])};\n }\n } else if (lang.isArray(${t})) {\n if (lang.isNumber(${s}) === false) {\n return ${V(e,n.arguments[2])};\n }\n ${t} = ${t}[${s}];\n if (${t} === null || ${t} === undefined) {\n return ${V(e,n.arguments[2])};\n }\n } else if (lang.isImmutableArray(${t})) {\n if (lang.isNumber(${s}) === false) {\n return ${V(e,n.arguments[2])};\n }\n ${t} = ${t}.get(${s});\n if (${t} === null || ${t} === undefined) {\n return ${V(e,n.arguments[2])};\n }\n } else {\n return ${V(e,n.arguments[2])};\n }\n }\n return ${t};\n ${e.isAsync?"})}()))":"}()"}`:`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${V(e,n.arguments[0])};\n if (${t} === null) {\n return ${V(e,n.arguments[1])};\n }\n if (${t} === "") {\n return ${V(e,n.arguments[1])};\n }\n if (${t} === undefined) {\n return ${V(e,n.arguments[1])};\n }\n return ${t};\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Fe(e,n){try{if(n.arguments.length<3)throw new l(e,r.WrongNumberOfParameters,n);if(n.arguments.length%2==0)throw new l(e,r.WrongNumberOfParameters,n);const t=Ae(e);let o="var ";for(let r=0;r<n.arguments.length-1;r+=2)o+=`${t} = lang.mustBoolean(${V(e,n.arguments[r])}, runtimeCtx);\n if (${t} === true ) {\n return ${V(e,n.arguments[r+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n ${o}\n return ${V(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Me(e,n){try{if(n.arguments.length<2)throw new l(e,r.WrongNumberOfParameters,n);if(2===n.arguments.length)return`(${V(e,n.arguments[1])})`;if((n.arguments.length-1)%2==0)throw new l(e,r.WrongNumberOfParameters,n);const t=Ae(e),o=Ae(e);let a="var ";for(let r=1;r<n.arguments.length-1;r+=2)a+=`${o} = ${V(e,n.arguments[r])};\n if (lang.binary(${o}, ${t}, "==") === true ) {\n return ${V(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} = ${V(e,n.arguments[0])};\n ${a}\n return ${V(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}const $e={};function Ce(e){return e.symbols.symbolCounter++,"_T"+e.symbols.symbolCounter.toString()}function Ae(e){return e.symbols.symbolCounter++,"_Tvar"+e.symbols.symbolCounter.toString()}N($e,z),P($e,z),D($e,z),j($e,z),U($e,z),$e.iif=function(e,n){try{return z(e,n,((t,l,a)=>{throw new o(e,r.Unrecognized,n)}))}catch(t){throw t}},$e.decode=function(e,n){try{return z(e,n,((t,l,a)=>{throw new o(e,r.Unrecognized,n)}))}catch(t){throw t}},$e.when=function(e,n){try{return z(e,n,((t,l,a)=>{throw new o(e,r.Unrecognized,n)}))}catch(t){throw t}},$e.defaultvalue=function(e,n){try{return z(e,n,((t,l,a)=>{throw new o(e,r.Unrecognized,n)}))}catch(t){throw t}};const Ie={};for(const Te in $e)Ie[Te]=new i($e[Te]);R($e,z);for(const Te in $e)$e[Te]=new i($e[Te]);const _e=function(){};_e.prototype=$e;const Oe=function(){};function ke(e,n,t){const o={};e||(e={}),t||(t={}),o._SymbolsMap={},o.textformatting=1,o.infinity=1,o.pi=1;for(const r in n)o[r]=1;for(const r in t)o[r]=1;for(const r in e)o[r]=1;return o}function Ee(e,n,o,r){const l=o?new Oe:new _e;e||(e={}),n||(n={});const a=new t({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});a.immutable=!1,l._SymbolsMap={textformatting:1,infinity:1,pi:1},l.textformatting=a,l.infinity=Number.POSITIVE_INFINITY,l.pi=Math.PI;for(const t in n)l[t]=n[t],l._SymbolsMap[t]=1;for(const t in e)l._SymbolsMap[t]=1,e[t]&&"esri.Graphic"===e[t].declaredClass?l[t]=s.createFromGraphic(e[t],r??null):l[t]=e[t];return l}Oe.prototype=Ie;const Ge={fixSpatialReference:g,parseArguments:W,standardFunction:z};function Be(e,n){const t={mode:n,compiled:!0,functions:{},signatures:[],standardFunction:z,standardFunctionAsync:z,evaluateIdentifier:je};for(let o=0;o<e.length;o++)e[o].registerFunctions(t);if("sync"===n){for(const e in t.functions)$e[e]=new i(t.functions[e]),_e.prototype[e]=$e[e];for(let e=0;e<t.signatures.length;e++)G(t.signatures[e],"sync")}else{for(const e in t.functions)Ie[e]=new i(t.functions[e]),Oe.prototype[e]=Ie[e];for(let e=0;e<t.signatures.length;e++)G(t.signatures[e],"async")}}function Ne(e,n){return e(n)}function je(e,n){const t=n.name;if("_SymbolsMap"===t)throw new o(e,r.InvalidIdentifier,null);if(e.localStack.length>0){if("_t"!==t.substr(0,2).toLowerCase()&&void 0!==e.localStack[e.localStack.length-1][t])return e.localStack[e.localStack.length-1][t];const n=e.mangleMap[t];if(void 0!==n&&void 0!==e.localStack[e.localStack.length-1][n])return e.localStack[e.localStack.length-1][n]}if("_t"!==t.substr(0,2).toLowerCase()&&void 0!==e.globalScope[t])return e.globalScope[t];if(1===e.globalScope._SymbolsMap[t])return e.globalScope[t];const l=e.mangleMap[t];return void 0!==l?e.globalScope[l]:void 0}Be([B],"sync"),Be([B],"async");let Le=0;const Re={isNumber:e=>S(e),isArray:e=>v(e),isImmutableArray:e=>x(e),isFeature:e=>F(e),isString:e=>M(e),isDictionary:e=>$(e),isGeometry:e=>C(e),geometryMember:(e,n,t,o,r=1)=>L(e,n,t,o,r),error(e){throw new o(null,e,null)},__awaiter:(e,n,t,o)=>new Promise(((t,r)=>{function l(e){try{s(o.next(e))}catch(n){r(n)}}function a(e){try{s(o.throw(e))}catch(n){r(n)}}function s(e){e.done?t(e.value):e.value?.then?e.value.then(l,a):(Le++,Le%100==0?setTimeout((()=>{Le=0,l(e.value)}),0):l(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 o(null,r.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 o(n,r.InvalidIdentifier,null);return e},mustBoolean(e,n){if(!0===e||!1===e)return e;throw new o(n,r.BooleanConditionRequired,null)},setAssig:(e,n)=>(n.gdefs[e]=1,e),castString:e=>A(e),aCheck(e,n){if(m(e)){if("ArrayExpression"===n)throw new o(null,r.NoFunctionInArray,null);if("ObjectExpression"===n)throw new o(null,r.NoFunctionInDictionary,null);throw new o(null,r.NoFunctionInTemplateLiteral,null)}return e===y?null:e},Dictionary:t,Feature:s,UserDefinedCompiledFunction:q,dictionary(e){const n={},l=new Map;for(let t=0;t<e.length;t+=2){if(m(e[t+1]))throw new o(null,r.NoFunctionInDictionary,null);if(!1===M(e[t]))throw new o(null,r.KeyMustBeString,null);let a=e[t].toString();const s=a.toLowerCase();l.has(s)?a=l.get(s):l.set(s,a),e[t+1]===y?n[a]=null:n[a]=e[t+1]}const a=new t(n);return a.immutable=!1,a},strCheck(e){if(!1===M(e))throw new o(null,r.KeyMustBeString,null);return e},unary(e,n){if(I(e)){if("!"===n)return!e;if("-"===n)return-1*_(e);if("+"===n)return 1*_(e);if("~"===n)return~_(e);throw new o(null,r.UnsupportedUnaryOperator,null)}if("-"===n)return-1*_(e);if("+"===n)return 1*_(e);if("~"===n)return~_(e);throw new o(null,r.UnsupportedUnaryOperator,null)},logicalCheck(e){if(!1===I(e))throw new o(null,r.LogicExpressionOrAnd,null);return e},logical(e,n,t){if(I(e)&&I(n))switch(t){case"||":return e||n;case"&&":return e&&n;default:throw new o(null,r.LogicExpressionOrAnd,null)}throw new o(null,r.LogicExpressionOrAnd,null)},binary(e,n,t){switch(t){case"|":case"<<":case">>":case">>>":case"^":case"&":return E(_(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 M(e)||M(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 o(null,r.UnsupportedOperator,null)}},assign(e,n,t){switch(n){case"=":return e===y?null:e;case"/=":return _(t)/_(e);case"*=":return _(t)*_(e);case"-=":return _(t)-_(e);case"+=":return M(t)||M(e)?A(t)+A(e):_(t)+_(e);case"%=":return _(t)%_(e);default:throw new o(null,r.UnsupportedOperator,null)}},update(e,n,t,o){const r=_(e[n]);return e[n]="++"===t?r+1:r-1,!1===o?r:"++"===t?r+1:r-1},graphicToFeature:(e,n,t)=>null===e?null:s.createFromGraphicLikeObject(e.geometry,e.attributes,n,t.timeZone),memberupdate(e,n,l,a){let s;if(v(e)){if(!S(n))throw new o(null,r.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>=e.length)throw new o(null,r.OutOfBounds,null);s=_(e[n]),e[n]="++"===l?s+1:s-1}else if(e instanceof t){if(!1===M(n))throw new o(null,r.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new o(null,r.FieldNotFound,null,{key:n});s=_(e.field(n)),e.setField(n,"++"===l?s+1:s-1)}else if(F(e)){if(!1===M(n))throw new o(null,r.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new o(null,r.FieldNotFound,null);s=_(e.field(n)),e.setField(n,"++"===l?s+1:s-1)}else{if(x(e))throw new o(null,r.Immutable,null);if(!(e instanceof Ze))throw new o(null,r.InvalidIdentifier,null);if(!1===M(n))throw new o(null,r.ModuleAccessorMustBeString,null);if(!0!==e.hasGlobal(n))throw new o(null,r.ModuleExportNotFound,null);s=_(e.global(n)),e.setGlobal(n,"++"===l?s+1:s-1)}return!1===a?s:"++"===l?s+1:s-1},assignmember(e,n,l,a){if(v(e)){if(!S(n))throw new o(null,r.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>e.length)throw new o(null,r.OutOfBounds,null);if(n===e.length){if("="!==l)throw new o(null,r.OutOfBounds,null);e[n]=this.assign(a,l,e[n])}else e[n]=this.assign(a,l,e[n])}else if(e instanceof t){if(!1===M(n))throw new o(null,r.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(a,l,e.field(n)));else{if("="!==l)throw new o(null,r.FieldNotFound,null);e.setField(n,this.assign(a,l,null))}}else if(F(e)){if(!1===M(n))throw new o(null,r.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(a,l,e.field(n)));else{if("="!==l)throw new o(null,r.FieldNotFound,null);e.setField(n,this.assign(a,l,null))}}else{if(x(e))throw new o(null,r.Immutable,null);if(!(e instanceof Ze))throw new o(null,r.InvalidIdentifier,null);if(!1===M(n))throw new o(null,r.ModuleAccessorMustBeString,null);if(!e.hasGlobal(n))throw new o(null,r.ModuleExportNotFound,null);e.setGlobal(n,this.assign(a,l,e.global(n)))}},member(e,n){if(null===e)throw new o(null,r.MemberOfNull,null);if(e instanceof t||F(e)){if(M(n))return e.field(n);throw new o(null,r.InvalidMemberAccessKey,null)}if(e instanceof K){if(M(n))return L(e,n,null,null);throw new o(null,r.InvalidMemberAccessKey,null)}if(v(e)){if(S(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new o(null,r.OutOfBounds,null);return e[n]}throw new o(null,r.InvalidMemberAccessKey,null)}if(M(e)){if(S(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new o(null,r.OutOfBounds,null);return e[n]}throw new o(null,r.InvalidMemberAccessKey,null)}if(x(e)){if(S(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length()+n),n>=e.length()||n<0)throw new o(null,r.OutOfBounds,null);return e.get(n)}throw new o(null,r.InvalidMemberAccessKey,null)}if(e instanceof Ze){if(M(n))return e.global(n);throw new o(null,r.InvalidMemberAccessKey,null)}throw new o(null,r.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,l){if(!(e instanceof Ze))throw new o(null,r.FunctionNotFound,null);const a=e.global(t);if(!1===m(a))throw new o(null,r.CallNonFunction,null);return a.call(l,{preparsed:!0,arguments:n})}};function De(e){console.log(e)}function Ue(e,t,a=!1){null===t&&(t={vars:{},customfunctions:{}});let s=null;e.usesModules&&(s=new n(null,e.loadedModules));const i={isAsync:a,globalScope:ke(t.vars,a?Ie:$e,t.customfunctions),moduleFactory:{},moduleFactoryMap:{},undeclaredGlobalsInFunctions:new Map,customfunctions:t.customfunctions,libraryResolver:s,localScope:null,mangleMap:{},depthCounter:{depth:1},exports:{},console:De,lrucache:t.lrucache,timeZone:t.timeZone??null,interceptor:t.interceptor,services:t.services,symbols:{symbolCounter:0}};let u=V(i,e);""===u&&(u="lc.voidOperation; "),i.undeclaredGlobalsInFunctions.size>0&&i.undeclaredGlobalsInFunctions.forEach((e=>{throw new l(t,r.InvalidIdentifier,e.node)}));let c="";c=a?"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"+u+"\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 "+u+"\n return lastStatement; } \n return this.postProcess(mainBody()); ";const p=i.moduleFactory,g=i.moduleFactoryMap,S=i.exports,v={};for(const n in S)v[n]=void 0!==i.mangleMap[n]?i.mangleMap[n]:n;const x={lc:f,lang:Re,mangles:i.mangleMap,postProcess(e){if(e instanceof d&&(e=e.value),e instanceof h&&(e=e.value),e===y&&(e=null),e===b)throw new o(null,r.IllegalResult,null);if(e===w)throw new o(null,r.IllegalResult,null);if(m(e))throw new o(null,r.IllegalResult,null);return e},prepare(e,n){let t=e.spatialReference;null==t&&(t=T.WebMercator);const o=Ee(e.vars,e.customfunctions,n,e.timeZone);return{localStack:[],isAsync:n,moduleFactory:p,moduleFactoryMap:g,mangleMap:this.mangles,moduleSingletons:{},exports:S,gdefs:{},exportmangle:v,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??De,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:{depth:1}}}};return new Function("context","spatialReference",c).bind(x)}async function Pe(){return Be([await import("./functions/geomasync.js")],"async"),!0}class Ze extends e{constructor(e){super(null),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,l=e.toLowerCase();if(m(n))throw new o(null,r.AssignModuleFunction,null);t[this.moduleContext.exportmangle[l]]=n}global(e){const n=this.moduleContext.globalScope;e=e.toLowerCase();const t=n[this.moduleContext.exportmangle[e]];if(void 0===t)throw new o(null,r.InvalidIdentifier,null);if(m(t)&&!(t instanceof c)){const o=new c;return o.fn=t,o.parameterEvaluator=z,o.context=this.moduleContext,n[this.moduleContext.exportmangle[e]]=o,o}return t}}function Ke(e,t,o=!1){const r={isAsync:o,moduleFactory:t.moduleFactory,moduleFactoryMap:{},libraryResolver:new n(null,e.loadedModules),globalScope:ke(t.vars,o?Ie:$e,t.customfunctions),customfunctions:t.customfunctions,localScope:null,mangleMap:{},undeclaredGlobalsInFunctions:new Map,depthCounter:{depth:1},exports:{},console:De,lrucache:t.lrucache,timeZone:t.timeZone??null,interceptor:t.interceptor,services:t.services,symbols:{symbolCounter:0}};let l=V(r,e);""===l&&(l="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"+l+"\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 "+l+"\n return lastStatement; } \n mainBody(); \n return this.prepareModule(runtimeCtx); ";const s=r.moduleFactory,i=r.moduleFactoryMap,u=r.exports,c={};for(const n in u)c[n]=void 0!==r.mangleMap[n]?r.mangleMap[n]:n;const p={lc:f,lang:Re,mangles:r.mangleMap,prepareModule:e=>new Ze(e),prepare(e,n){let t=e.spatialReference;null==t&&(t=new T({wkid:102100}));const o=Ee(e.vars,e.customfunctions,n,e.timeZone);return{localStack:[],isAsync:n,exports:u,exportmangle:c,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??De,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:e.depthCounter}}};return new Function("context","spatialReference",a).bind(p)}export{q as UserDefinedCompiledFunction,Ue as compileScript,Pe as enableAsyncSupport,Ne as executeScript,Be as extend,Ge as functionHelper};
5
+ import{ArcadeModule as e}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import t from"./Dictionary.js";import{ArcadeExecutionError as o,ExecutionErrorCodes as r,ArcadeCompilationError as l,ArcadeUncompilableError as a}from"./executionError.js";import s from"./Feature.js";import{NativeFunction as i,ArcadeFunction as u,ScopeMarshalledFunction as c,wrapModuleScopedResponse as p}from"./FunctionWrapper.js";import{i as m,w as g,x as f,y as d,z as h,A as y,B as b,C as w,b as S,o as v,q as x,r as F,c as M,v as $,p as C,j as A,a as I,g as _,D as O,E as k,F as E}from"../chunks/languageUtils.js";import{addFunctionDeclaration as G}from"./treeAnalysis.js";import{A as B}from"../chunks/array.js";import{registerFunctions as N}from"./functions/date.js";import{registerFunctions as j,geometryMember as L}from"./functions/geometry.js";import{registerFunctions as R}from"./functions/geomsync.js";import{registerFunctions as D}from"./functions/maths.js";import{registerFunctions as U}from"./functions/stats.js";import{registerFunctions as P}from"./functions/string.js";import{isPromiseLike as Z}from"../core/promiseUtils.js";import K from"../geometry/Geometry.js";import T from"../geometry/SpatialReference.js";class q extends u{constructor(e,n){super(),this.paramCount=n,this.fn=e}createFunction(e){return(...n)=>{if(n.length!==this.paramCount)throw new o(e,r.WrongNumberOfParameters,null);return this.fn(...n)}}call(e,n){return this.fn(...n.arguments)}marshalledCall(e,n,t,o){return o(e,n,((n,r,l)=>{l=l.map((n=>!m(n)||n instanceof c?n:p(n,e,o)));const a=this.call(t,{arguments:l});return Z(a)?a.then((e=>p(e,t,o))):a}))}}function W(e,n){const t=[];for(let o=0;o<n.arguments.length;o++)t.push(V(e,n.arguments[o]));return t}function z(e,n,t){try{return t(e,null,n.arguments)}catch(o){throw o}}function V(e,n){try{switch(n.type){case"EmptyStatement":return"lc.voidOperation";case"VariableDeclarator":return me(e,n);case"VariableDeclaration":return pe(e,n);case"BlockStatement":case"Program":return le(e,n);case"FunctionDeclaration":return ce(e,n);case"ImportDeclaration":return se(e,n);case"ExportNamedDeclaration":return ie(e,n);case"ReturnStatement":return ae(e,n);case"IfStatement":return re(e,n);case"ExpressionStatement":return te(e,n);case"AssignmentExpression":return ne(e,n);case"UpdateExpression":return X(e,n);case"BreakStatement":return"break";case"ContinueStatement":return"continue";case"TemplateLiteral":return he(e,n);case"TemplateElement":return JSON.stringify(n.value?n.value.cooked:"");case"ForStatement":return Q(e,n);case"ForInStatement":return H(e,n);case"WhileStatement":return ee(e,n);case"Identifier":return we(e,n);case"MemberExpression":return ge(e,n);case"Literal":return null===n.value||void 0===n.value?"null":JSON.stringify(n.value);case"CallExpression":return Se(e,n);case"UnaryExpression":return fe(e,n);case"BinaryExpression":return ye(e,n);case"LogicalExpression":return be(e,n);case"ArrayExpression":return de(e,n);case"ObjectExpression":return J(e,n);case"Property":return Y(e,n);case"Array":throw new l(e,r.NeverReach,n);default:throw new l(e,r.Unrecognized,n)}}catch(t){throw t}}function J(e,n){let t="lang.dictionary([";for(let o=0;o<n.properties.length;o++){const r=n.properties[o];ue(r.key.name);o>0&&(t+=","),t+="lang.strCheck("+("Identifier"===r.key.type?"'"+r.key.name+"'":V(e,r.key))+",'ObjectExpression'),lang.aCheck("+V(e,r.value)+", 'ObjectExpression')"}return t+="])",t}function Y(e,n){throw new l(e,r.NeverReach,n)}function H(e,n){const t=Ae(e),o=Ae(e),r=Ae(e);let l="var "+t+" = "+V(e,n.right)+";\n";"VariableDeclaration"===n.left.type&&(l+=V(e,n.left));let a="VariableDeclaration"===n.left.type?n.left.declarations[0].id.name:n.left.name;a=a.toLowerCase(),ue(a);let s="";null!==e.localScope&&(void 0!==e.localScope[a]?s="lscope['"+a+"']":void 0!==e.localScope._SymbolsMap[a]&&(s="lscope['"+e.localScope._SymbolsMap[a]+"']"));let i="";if(""===s)if(void 0!==e.globalScope[a])s="gscope['"+a+"']";else if(void 0!==e.globalScope._SymbolsMap[a])s="gscope['"+e.globalScope._SymbolsMap[a]+"']";else if(null!==e.localScope)if(e.undeclaredGlobalsInFunctions.has(a))s="gscope['"+e.undeclaredGlobalsInFunctions.get(a).manglename+"']",i=e.undeclaredGlobalsInFunctions.get(a).manglename;else{const t={manglename:Ce(e),node:n.left};e.undeclaredGlobalsInFunctions.set(a,t),s="gscope['"+t.manglename+"']",i=t.manglename}return i&&(l+="lang.chkAssig('"+i+"',runtimeCtx); \n"),l+="if ("+t+"===null) { lastStatement = lc.voidOperation; }\n ",l+="else if (lc.isArray("+t+") || lc.isString("+t+")) {",l+="var "+o+"="+t+".length; \n",l+="for(var "+r+"=0; "+r+"<"+o+"; "+r+"++) {\n",l+=s+"="+r+";\n",l+=V(e,n.body),l+="\n}\n",l+=" lastStatement = lc.voidOperation; \n",l+=" \n}\n",l+="else if (lc.isImmutableArray("+t+")) {",l+="var "+o+"="+t+".length(); \n",l+="for(var "+r+"=0; "+r+"<"+o+"; "+r+"++) {\n",l+=s+"="+r+";\n",l+=V(e,n.body),l+="\n}\n",l+=" lastStatement = lc.voidOperation; \n",l+=" \n}\n",l+="else if (( "+t+" instanceof lang.Dictionary) || ( "+t+" instanceof lang.Feature)) {",l+="var "+o+"="+t+".keys(); \n",l+="for(var "+r+"=0; "+r+"<"+o+".length; "+r+"++) {\n",l+=s+"="+o+"["+r+"];\n",l+=V(e,n.body),l+="\n}\n",l+=" lastStatement = lc.voidOperation; \n",l+=" \n}\n",e.isAsync&&(l+="else if (lc.isFeatureSet("+t+")) {",l+="var "+o+"="+t+".iterator(runtimeCtx.abortSignal); \n",l+="for(var "+r+"=lang. graphicToFeature( yield "+o+".next(),"+t+", runtimeCtx); "+r+"!=null; "+r+"=lang. graphicToFeature( yield "+o+".next(),"+t+", runtimeCtx)) {\n",l+=s+"="+r+";\n",l+=V(e,n.body),l+="\n}\n",l+=" lastStatement = lc.voidOperation; \n",l+=" \n}\n"),l+="else { lastStatement = lc.voidOperation; } \n",l}function Q(e,n){let t="lastStatement = lc.voidOperation; \n";null!==n.init&&(t+=V(e,n.init)+"; ");const o=Ae(e),l=Ae(e);return t+="var "+o+" = true; ",t+="\n do { ",null!==n.update&&(t+=" if ("+o+"===false) {\n "+V(e,n.update)+" \n}\n "+o+"=false; \n"),null!==n.test&&(t+="var "+l+" = "+V(e,n.test)+"; ",t+="if ("+l+"===false) { break; } else if ("+l+"!==true) { lang.error('"+r.BooleanConditionRequired+"'); }\n"),t+=V(e,n.body),null!==n.update&&(t+="\n "+V(e,n.update)),t+="\n"+o+" = true; \n} while(true); lastStatement = lc.voidOperation; ",t}function X(e,n){let t=null,l="";if("MemberExpression"===n.argument.type)return t=V(e,n.argument.object),!0===n.argument.computed?l=V(e,n.argument.property):(l="'"+n.argument.property.name+"'",ue(n.argument.property.name)),"lang.memberupdate("+t+","+l+",'"+n.operator+"',"+n.prefix+")";if(t=n.argument.name.toLowerCase(),ue(t),null!==e.localScope){if(void 0!==e.localScope[t])return"lang.update(lscope, '"+t+"','"+n.operator+"',"+n.prefix+")";if(void 0!==e.localScope._SymbolsMap[t])return"lang.update(lscope, '"+e.localScope._SymbolsMap[t]+"','"+n.operator+"',"+n.prefix+")"}if(void 0!==e.globalScope[t])return"lang.update(gscope, '"+t+"','"+n.operator+"',"+n.prefix+")";if(void 0!==e.globalScope._SymbolsMap[t])return"lang.update(gscope, '"+e.globalScope._SymbolsMap[t]+"','"+n.operator+"',"+n.prefix+")";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(t))return"lang.update(gscope,lang.chkAssig( '"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx),'"+n.operator+"',"+n.prefix+")";const o={manglename:Ce(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(t,o),"lang.update(gscope, lang.chkAssig('"+o.manglename+"',runtimeCtx),'"+n.operator+"',"+n.prefix+")"}throw new o(e,r.InvalidIdentifier,n)}function ee(e,n){let t="lastStatement = lc.voidOperation; \n";const o=Ae(e);return t+=`\n var ${o} = true;\n do {\n ${o} = ${V(e,n.test)};\n if (${o}==false) {\n break;\n }\n if (${o}!==true) {\n lang.error('${r.BooleanConditionRequired}');\n }\n ${V(e,n.body)}\n }\n while (${o} !== false);\n lastStatement = lc.voidOperation;\n `,t}function ne(e,n){const t=V(e,n.right);let l=null,a="";if("MemberExpression"===n.left.type)return l=V(e,n.left.object),!0===n.left.computed?a=V(e,n.left.property):(a="'"+n.left.property.name+"'",ue(n.left.property.name)),"lang.assignmember("+l+","+a+",'"+n.operator+"',"+t+")";if(l=n.left.name.toLowerCase(),ue(l),null!==e.localScope){if(void 0!==e.localScope[l])return"lscope['"+l+"']=lang.assign("+t+",'"+n.operator+"', lscope['"+l+"'])";if(void 0!==e.localScope._SymbolsMap[l])return"lscope['"+e.localScope._SymbolsMap[l]+"']=lang.assign("+t+",'"+n.operator+"', lscope['"+e.localScope._SymbolsMap[l]+"'])"}if(void 0!==e.globalScope[l])return"gscope['"+l+"']=lang.assign("+t+",'"+n.operator+"', gscope['"+l+"'])";if(void 0!==e.globalScope._SymbolsMap[l])return"gscope['"+e.globalScope._SymbolsMap[l]+"']=lang.assign("+t+",'"+n.operator+"', gscope['"+e.globalScope._SymbolsMap[l]+"'])";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(l))return"gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(l).manglename+"',runtimeCtx)]=lang.assign("+t+",'"+n.operator+"', gscope['"+e.undeclaredGlobalsInFunctions.get(l).manglename+"'])";const o={manglename:Ce(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(l,o),"gscope[lang.chkAssig('"+o.manglename+"',runtimeCtx)]=lang.assign("+t+",'"+n.operator+"', gscope['"+o.manglename+"'])"}throw new o(e,r.InvalidIdentifier,n)}function te(e,n){return"AssignmentExpression"===n.expression.type?"lastStatement = lc.voidOperation; "+V(e,n.expression)+"; \n ":(n.expression.type,"lastStatement = "+V(e,n.expression)+"; ")}function oe(e,n){return"BlockStatement"===n.type?V(e,n):"ReturnStatement"===n.type||"BreakStatement"===n.type||"ContinueStatement"===n.type?V(e,n)+"; ":"UpdateExpression"===n.type?"lastStatement = "+V(e,n)+"; ":"ExpressionStatement"===n.type?V(e,n):"ObjectExpression"===n.type?"lastStatement = "+V(e,n)+"; ":V(e,n)+"; "}function re(e,n){if("AssignmentExpression"===n.test.type||"UpdateExpression"===n.test.type)throw new l(e,r.BooleanConditionRequired,n);return`if (lang.mustBoolean(${V(e,n.test)}, runtimeCtx) === true) {\n ${oe(e,n.consequent)}\n } `+(null!==n.alternate?"IfStatement"===n.alternate.type?" else "+re(e,n.alternate):` else {\n ${oe(e,n.alternate)}\n }\n`:" else {\n lastStatement = lc.voidOperation;\n }\n")}function le(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+=V(e,n.body[o])+"; \n":"UpdateExpression"===n.body[o].type||"ObjectExpression"===n.body[o].type?t+="lastStatement = "+V(e,n.body[o])+"; \n":t+=V(e,n.body[o])+" \n");return t}function ae(e,n){if(null===n.argument)return"return lc.voidOperation";return"return "+V(e,n.argument)}function se(e,n){const t=n.specifiers[0].local.name.toLowerCase();ue(t);const o=e.libraryResolver?.loadLibrary(t),r=Ce(e);void 0===e.moduleFactory[o.uri]&&(e.moduleFactory[o.uri]=Ke(o.syntax,{interceptor:e.interceptor,services:e.services,moduleFactory:e.moduleFactory,lrucache:e.lrucache,timeZone:e.timeZone??null,libraryResolver:e.libraryResolver,customfunctions:e.customfunctions,vars:{}},e.isAsync)),e.moduleFactoryMap[r]=o.uri;let l="";if(l=e.isAsync?"(yield lang.loadModule('"+r+"', runtimeCtx) ); ":"lang.loadModule('"+r+"', runtimeCtx); ",void 0!==e.globalScope[t])return"gscope['"+t+"']="+l;if(void 0!==e.globalScope._SymbolsMap[t])return"gscope['"+e.globalScope._SymbolsMap[t]+"']="+l;let a="";return e.undeclaredGlobalsInFunctions.has(t)?(a=e.undeclaredGlobalsInFunctions.get(t).manglename,e.undeclaredGlobalsInFunctions.delete(t)):a=Ce(e),e.globalScope._SymbolsMap[t]=a,e.mangleMap[t]=a,"gscope[lang.setAssig('"+a+"', runtimeCtx)]="+l}function ie(e,n){const t=V(e,n.declaration);if("FunctionDeclaration"===n.declaration.type)e.exports[n.declaration.id.name.toLowerCase()]="function";else if("VariableDeclaration"===n.declaration.type)for(const o of n.declaration.declarations)e.exports[o.id.name.toLowerCase()]="variable";return t}function ue(e){if("iif"===e)throw new a;if("decode"===e)throw new a;if("when"===e)throw new a;if("defaultvalue"===e)throw new a}function ce(e,n){const t=n.id.name.toLowerCase();ue(t);let o="",r=!1;void 0!==e.globalScope[t]?o=t:void 0!==e.globalScope._SymbolsMap[t]?o=e.globalScope._SymbolsMap[t]:e.undeclaredGlobalsInFunctions.has(t)?(o=e.undeclaredGlobalsInFunctions.get(t).manglename,e.globalScope._SymbolsMap[t]=o,e.mangleMap[t]=o,e.undeclaredGlobalsInFunctions.delete(t),r=!0):(o=Ce(e),e.globalScope._SymbolsMap[t]=o,e.mangleMap[t]=o);const l={isAsync:e.isAsync,console:e.console,exports:e.exports,undeclaredGlobalsInFunctions:e.undeclaredGlobalsInFunctions,customfunctions:e.customfunctions,moduleFactory:e.moduleFactory,moduleFactoryMap:e.moduleFactoryMap,libraryResolver:e.libraryResolver,lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,symbols:e.symbols,mangleMap:e.mangleMap,localScope:{_SymbolsMap:{}},depthCounter:e.depthCounter,globalScope:e.globalScope};let a="new lang.UserDefinedCompiledFunction( lang.functionDepthchecker(function() { var lastStatement = lc.voidOperation; \n var lscope = runtimeCtx.localStack[runtimeCtx.localStack.length-1];\n";for(let s=0;s<n.params.length;s++){const t=n.params[s].name.toLowerCase();ue(t);const o=Ce(e);l.localScope._SymbolsMap[t]=o,l.mangleMap[t]=o,a+="lscope['"+o+"']=arguments["+s.toString()+"];\n"}return!0===e.isAsync?(a+="return lang.__awaiter(this, void 0, void 0, function* () {\n",a+=le(l,n.body)+"\n return lastStatement; ",a+="}); }",a+=", runtimeCtx),"+n.params.length+")",a+="\n lastStatement = lc.voidOperation; \n"):(a+=le(l,n.body)+"\n return lastStatement; }, runtimeCtx),"+n.params.length+")",a+="\n lastStatement = lc.voidOperation; \n"),r?"gscope[lang.setAssig('"+o+"', runtimeCtx)]="+a:"gscope['"+o+"']="+a}function pe(e,n){const t=[];for(let o=0;o<n.declarations.length;o++)t.push(V(e,n.declarations[o]));return t.join("\n")+" \n lastStatement= lc.voidOperation; \n"}function me(e,n){let t=null===n.init?null:V(e,n.init);t===y&&(t=null);const o=n.id.name.toLowerCase();if(ue(o),null!==e.localScope){if(void 0!==e.localScope[o])return"lscope['"+o+"']="+t+"; ";if(void 0!==e.localScope._SymbolsMap[o])return"lscope['"+e.localScope._SymbolsMap[o]+"']="+t+"; ";{const n=Ce(e);return e.localScope._SymbolsMap[o]=n,e.mangleMap[o]=n,"lscope['"+n+"']="+t+"; "}}if(void 0!==e.globalScope[o])return"gscope['"+o+"']="+t+"; ";if(void 0!==e.globalScope._SymbolsMap[o])return"gscope['"+e.globalScope._SymbolsMap[o]+"']="+t+"; ";if(e.undeclaredGlobalsInFunctions.has(o)){const n=e.undeclaredGlobalsInFunctions.get(o).manglename;return e.globalScope._SymbolsMap[o]=n,e.mangleMap[o]=n,e.undeclaredGlobalsInFunctions.delete(o),"gscope[lang.setAssig('"+n+"', runtimeCtx)]="+t+"; "}const r=Ce(e);return e.globalScope._SymbolsMap[o]=r,e.mangleMap[o]=r,"gscope['"+r+"']="+t+"; "}function ge(e,n){try{let t;return!0===n.computed?t=V(e,n.property):(t="'"+n.property.name+"'",ue(n.property.name)),"lang.member("+V(e,n.object)+","+t+")"}catch(t){throw t}}function fe(e,n){try{return"lang.unary("+V(e,n.argument)+",'"+n.operator+"')"}catch(t){throw t}}function de(e,n){try{const t=[];for(let o=0;o<n.elements.length;o++)"Literal"===n.elements[o].type?t.push(V(e,n.elements[o])):t.push("lang.aCheck("+V(e,n.elements[o])+",'ArrayExpression')");return"["+t.join(",")+"]"}catch(t){throw t}}function he(e,n){try{const t=[];let o=0;for(const r of n.quasis)t.push(r.value?JSON.stringify(r.value.cooked):JSON.stringify("")),!1===r.tail&&(t.push(n.expressions[o]?"lang.castString(lang.aCheck("+V(e,n.expressions[o])+", 'TemplateLiteral'))":""),o++);return"(["+t.join(",")+"]).join('')"}catch(t){throw t}}function ye(e,n){try{return"lang.binary("+V(e,n.left)+","+V(e,n.right)+",'"+n.operator+"')"}catch(t){throw t}}function be(e,n){try{if("AssignmentExpression"===n.left.type||"UpdateExpression"===n.left.type)throw new l(e,r.LogicalExpressionOnlyBoolean,n);if("AssignmentExpression"===n.right.type||"UpdateExpression"===n.right.type)throw new l(e,r.LogicalExpressionOnlyBoolean,n);if("&&"===n.operator||"||"===n.operator)return"(lang.logicalCheck("+V(e,n.left)+") "+n.operator+" lang.logicalCheck("+V(e,n.right)+"))";throw new l(null,r.LogicExpressionOrAnd,null)}catch(t){throw t}}function we(e,n){try{const t=n.name.toLowerCase();if(ue(t),null!==e.localScope){if(void 0!==e.localScope[t])return"lscope['"+t+"']";if(void 0!==e.localScope._SymbolsMap[t])return"lscope['"+e.localScope._SymbolsMap[t]+"']"}if(void 0!==e.globalScope[t])return"gscope['"+t+"']";if(void 0!==e.globalScope._SymbolsMap[t])return"gscope['"+e.globalScope._SymbolsMap[t]+"']";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(t))return"gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx)]";const o={manglename:Ce(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(t,o),"gscope[lang.chkAssig('"+o.manglename+"',runtimeCtx)]"}throw new l(e,r.InvalidIdentifier,n)}catch(t){throw t}}function Se(e,n){try{if("MemberExpression"===n.callee.type){let t;!0===n.callee.computed?t=V(e,n.callee.property):(t="'"+n.callee.property.name+"'",ue(n.callee.property.name));let o="[";for(let r=0;r<n.arguments.length;r++)r>0&&(o+=", "),o+=V(e,n.arguments[r]);return o+="]",e.isAsync?"(yield lang.callModuleFunction("+V(e,n.callee.object)+","+o+","+t+",runtimeCtx))":"lang.callModuleFunction("+V(e,n.callee.object)+","+o+","+t+",runtimeCtx)"}if("Identifier"!==n.callee.type)throw new l(e,r.FunctionNotFound,n);const t=n.callee.name.toLowerCase();if("iif"===t)return ve(e,n);if("when"===t)return Fe(e,n);if("defaultvalue"===t)return xe(e,n);if("decode"===t)return Me(e,n);let o="";if(null!==e.localScope&&(void 0!==e.localScope[t]?o="lscope['"+t+"']":void 0!==e.localScope._SymbolsMap[t]&&(o="lscope['"+e.localScope._SymbolsMap[t]+"']")),""===o)if(void 0!==e.globalScope[t])o="gscope['"+t+"']";else if(void 0!==e.globalScope._SymbolsMap[t])o="gscope['"+e.globalScope._SymbolsMap[t]+"']";else if(null!==e.localScope)if(e.undeclaredGlobalsInFunctions.has(t))o="gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx)]";else{const r={manglename:Ce(e),node:n.argument};e.undeclaredGlobalsInFunctions.set(t,r),o="gscope[lang.chkAssig('"+r.manglename+"',runtimeCtx)]"}if(""!==o){let t="[";for(let o=0;o<n.arguments.length;o++)o>0&&(t+=", "),t+=V(e,n.arguments[o]);return t+="]",e.isAsync?"(yield lang.callfunc("+o+","+t+",runtimeCtx) )":"lang.callfunc("+o+","+t+",runtimeCtx)"}throw new l(e,r.FunctionNotFound,n)}catch(t){throw t}}function ve(e,n){try{if(3!==n.arguments.length)throw new l(e,r.WrongNumberOfParameters,n);const t=Ae(e);return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${V(e,n.arguments[0])};\n\n if (${t} === true) {\n return ${V(e,n.arguments[1])};\n }\n else if (${t} === false) {\n return ${V(e,n.arguments[2])};\n }\n else {\n lang.error('ExecutionErrorCodes.BooleanConditionRequired');\n }\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function xe(e,n){try{if(n.arguments.length<2||n.arguments.length>3)throw new l(e,r.WrongNumberOfParameters,n);const t=Ae(e),o=Ae(e),a=Ae(e),s=Ae(e);return 3===n.arguments.length?`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${V(e,n.arguments[0])};\n var ${o} = ${V(e,n.arguments[1])};\n var ${a} = [];\n if (lang.isImmutableArray(${o})) {\n ${a} = ${o}.toArray();\n } else if (lang.isArray(${o})) {\n ${a} = ${o};\n } else {\n lang.error('${r.InvalidParameter}');\n }\n if (${t} === null) {\n return ${V(e,n.arguments[2])};\n }\n for (var ${s} of ${a}) {\n if (lang.isFeature(${t})) {\n if (lang.isString(${s}) === false) {\n return ${V(e,n.arguments[2])};\n }\n if (!${t}.hasField(${s})) {\n return ${V(e,n.arguments[2])};\n }\n ${t} = ${t}.field(${s});\n } else if (lang.isDictionary(${t})) {\n if (lang.isString(${s}) === false) {\n return ${V(e,n.arguments[2])};\n }\n if (!${t}.hasField(${s})) {\n return ${V(e,n.arguments[2])};\n }\n ${t} = ${t}.field(${s});\n } else if (lang.isGeometry(${t})) {\n if (lang.isString(${s}) === false) {\n return ${V(e,n.arguments[2])};\n }\n ${t} = lang.geometryMember(${t}, ${s}, null, null, 2);\n if (${t} === null) {\n return ${V(e,n.arguments[2])};\n }\n if (${t} && ${t}.keystate === "notfound") {\n return ${V(e,n.arguments[2])};\n }\n } else if (lang.isArray(${t})) {\n if (lang.isNumber(${s}) === false) {\n return ${V(e,n.arguments[2])};\n }\n ${t} = ${t}[${s}];\n if (${t} === null || ${t} === undefined) {\n return ${V(e,n.arguments[2])};\n }\n } else if (lang.isImmutableArray(${t})) {\n if (lang.isNumber(${s}) === false) {\n return ${V(e,n.arguments[2])};\n }\n ${t} = ${t}.get(${s});\n if (${t} === null || ${t} === undefined) {\n return ${V(e,n.arguments[2])};\n }\n } else {\n return ${V(e,n.arguments[2])};\n }\n }\n return ${t};\n ${e.isAsync?"})}()))":"}()"}`:`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${V(e,n.arguments[0])};\n if (${t} === null) {\n return ${V(e,n.arguments[1])};\n }\n if (${t} === "") {\n return ${V(e,n.arguments[1])};\n }\n if (${t} === undefined) {\n return ${V(e,n.arguments[1])};\n }\n return ${t};\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Fe(e,n){try{if(n.arguments.length<3)throw new l(e,r.WrongNumberOfParameters,n);if(n.arguments.length%2==0)throw new l(e,r.WrongNumberOfParameters,n);const t=Ae(e);let o="var ";for(let r=0;r<n.arguments.length-1;r+=2)o+=`${t} = lang.mustBoolean(${V(e,n.arguments[r])}, runtimeCtx);\n if (${t} === true ) {\n return ${V(e,n.arguments[r+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n ${o}\n return ${V(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Me(e,n){try{if(n.arguments.length<2)throw new l(e,r.WrongNumberOfParameters,n);if(2===n.arguments.length)return`(${V(e,n.arguments[1])})`;if((n.arguments.length-1)%2==0)throw new l(e,r.WrongNumberOfParameters,n);const t=Ae(e),o=Ae(e);let a="var ";for(let r=1;r<n.arguments.length-1;r+=2)a+=`${o} = ${V(e,n.arguments[r])};\n if (lang.binary(${o}, ${t}, "==") === true ) {\n return ${V(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} = ${V(e,n.arguments[0])};\n ${a}\n return ${V(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}const $e={};function Ce(e){return e.symbols.symbolCounter++,"_T"+e.symbols.symbolCounter.toString()}function Ae(e){return e.symbols.symbolCounter++,"_Tvar"+e.symbols.symbolCounter.toString()}N($e,z),P($e,z),D($e,z),j($e,z),U($e,z),$e.iif=function(e,n){try{return z(e,n,((t,l,a)=>{throw new o(e,r.Unrecognized,n)}))}catch(t){throw t}},$e.decode=function(e,n){try{return z(e,n,((t,l,a)=>{throw new o(e,r.Unrecognized,n)}))}catch(t){throw t}},$e.when=function(e,n){try{return z(e,n,((t,l,a)=>{throw new o(e,r.Unrecognized,n)}))}catch(t){throw t}},$e.defaultvalue=function(e,n){try{return z(e,n,((t,l,a)=>{throw new o(e,r.Unrecognized,n)}))}catch(t){throw t}};const Ie={};for(const Te in $e)Ie[Te]=new i($e[Te]);R($e,z);for(const Te in $e)$e[Te]=new i($e[Te]);const _e=function(){};_e.prototype=$e;const Oe=function(){};function ke(e,n,t){const o={};e||(e={}),t||(t={}),o._SymbolsMap={},o.textformatting=1,o.infinity=1,o.pi=1;for(const r in n)o[r]=1;for(const r in t)o[r]=1;for(const r in e)o[r]=1;return o}function Ee(e,n,o,r){const l=o?new Oe:new _e;e||(e={}),n||(n={});const a=new t({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});a.immutable=!1,l._SymbolsMap={textformatting:1,infinity:1,pi:1},l.textformatting=a,l.infinity=Number.POSITIVE_INFINITY,l.pi=Math.PI;for(const t in n)l[t]=n[t],l._SymbolsMap[t]=1;for(const t in e)l._SymbolsMap[t]=1,e[t]&&"esri.Graphic"===e[t].declaredClass?l[t]=s.createFromGraphic(e[t],r??null):l[t]=e[t];return l}Oe.prototype=Ie;const Ge={fixSpatialReference:g,parseArguments:W,standardFunction:z};function Be(e,n){const t={mode:n,compiled:!0,functions:{},signatures:[],standardFunction:z,standardFunctionAsync:z,evaluateIdentifier:je};for(let o=0;o<e.length;o++)e[o].registerFunctions(t);if("sync"===n){for(const e in t.functions)$e[e]=new i(t.functions[e]),_e.prototype[e]=$e[e];for(let e=0;e<t.signatures.length;e++)G(t.signatures[e],"sync")}else{for(const e in t.functions)Ie[e]=new i(t.functions[e]),Oe.prototype[e]=Ie[e];for(let e=0;e<t.signatures.length;e++)G(t.signatures[e],"async")}}function Ne(e,n){return e(n)}function je(e,n){const t=n.name;if("_SymbolsMap"===t)throw new o(e,r.InvalidIdentifier,null);if(e.localStack.length>0){if("_t"!==t.substr(0,2).toLowerCase()&&void 0!==e.localStack[e.localStack.length-1][t])return e.localStack[e.localStack.length-1][t];const n=e.mangleMap[t];if(void 0!==n&&void 0!==e.localStack[e.localStack.length-1][n])return e.localStack[e.localStack.length-1][n]}if("_t"!==t.substr(0,2).toLowerCase()&&void 0!==e.globalScope[t])return e.globalScope[t];if(1===e.globalScope._SymbolsMap[t])return e.globalScope[t];const l=e.mangleMap[t];return void 0!==l?e.globalScope[l]:void 0}Be([B],"sync"),Be([B],"async");let Le=0;const Re={isNumber:e=>S(e),isArray:e=>v(e),isImmutableArray:e=>x(e),isFeature:e=>F(e),isString:e=>M(e),isDictionary:e=>$(e),isGeometry:e=>C(e),geometryMember:(e,n,t,o,r=1)=>L(e,n,t,o,r),error(e){throw new o(null,e,null)},__awaiter:(e,n,t,o)=>new Promise(((t,r)=>{function l(e){try{s(o.next(e))}catch(n){r(n)}}function a(e){try{s(o.throw(e))}catch(n){r(n)}}function s(e){e.done?t(e.value):e.value?.then?e.value.then(l,a):(Le++,Le%100==0?setTimeout((()=>{Le=0,l(e.value)}),0):l(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 o(null,r.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 o(n,r.InvalidIdentifier,null);return e},mustBoolean(e,n){if(!0===e||!1===e)return e;throw new o(n,r.BooleanConditionRequired,null)},setAssig:(e,n)=>(n.gdefs[e]=1,e),castString:e=>A(e),aCheck(e,n){if(m(e)){if("ArrayExpression"===n)throw new o(null,r.NoFunctionInArray,null);if("ObjectExpression"===n)throw new o(null,r.NoFunctionInDictionary,null);throw new o(null,r.NoFunctionInTemplateLiteral,null)}return e===y?null:e},Dictionary:t,Feature:s,UserDefinedCompiledFunction:q,dictionary(e){const n={},l=new Map;for(let t=0;t<e.length;t+=2){if(m(e[t+1]))throw new o(null,r.NoFunctionInDictionary,null);if(!1===M(e[t]))throw new o(null,r.KeyMustBeString,null);let a=e[t].toString();const s=a.toLowerCase();l.has(s)?a=l.get(s):l.set(s,a),e[t+1]===y?n[a]=null:n[a]=e[t+1]}const a=new t(n);return a.immutable=!1,a},strCheck(e){if(!1===M(e))throw new o(null,r.KeyMustBeString,null);return e},unary(e,n){if(I(e)){if("!"===n)return!e;if("-"===n)return-1*_(e);if("+"===n)return 1*_(e);if("~"===n)return~_(e);throw new o(null,r.UnsupportedUnaryOperator,null)}if("-"===n)return-1*_(e);if("+"===n)return 1*_(e);if("~"===n)return~_(e);throw new o(null,r.UnsupportedUnaryOperator,null)},logicalCheck(e){if(!1===I(e))throw new o(null,r.LogicExpressionOrAnd,null);return e},logical(e,n,t){if(I(e)&&I(n))switch(t){case"||":return e||n;case"&&":return e&&n;default:throw new o(null,r.LogicExpressionOrAnd,null)}throw new o(null,r.LogicExpressionOrAnd,null)},binary(e,n,t){switch(t){case"|":case"<<":case">>":case">>>":case"^":case"&":return E(_(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 M(e)||M(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 o(null,r.UnsupportedOperator,null)}},assign(e,n,t){switch(n){case"=":return e===y?null:e;case"/=":return _(t)/_(e);case"*=":return _(t)*_(e);case"-=":return _(t)-_(e);case"+=":return M(t)||M(e)?A(t)+A(e):_(t)+_(e);case"%=":return _(t)%_(e);default:throw new o(null,r.UnsupportedOperator,null)}},update(e,n,t,o){const r=_(e[n]);return e[n]="++"===t?r+1:r-1,!1===o?r:"++"===t?r+1:r-1},graphicToFeature:(e,n,t)=>null===e?null:s.createFromGraphicLikeObject(e.geometry,e.attributes,n,t.timeZone),memberupdate(e,n,l,a){let s;if(v(e)){if(!S(n))throw new o(null,r.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>=e.length)throw new o(null,r.OutOfBounds,null);s=_(e[n]),e[n]="++"===l?s+1:s-1}else if(e instanceof t){if(!1===M(n))throw new o(null,r.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new o(null,r.FieldNotFound,null,{key:n});s=_(e.field(n)),e.setField(n,"++"===l?s+1:s-1)}else if(F(e)){if(!1===M(n))throw new o(null,r.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new o(null,r.FieldNotFound,null);s=_(e.field(n)),e.setField(n,"++"===l?s+1:s-1)}else{if(x(e))throw new o(null,r.Immutable,null);if(!(e instanceof Ze))throw new o(null,r.InvalidIdentifier,null);if(!1===M(n))throw new o(null,r.ModuleAccessorMustBeString,null);if(!0!==e.hasGlobal(n))throw new o(null,r.ModuleExportNotFound,null);s=_(e.global(n)),e.setGlobal(n,"++"===l?s+1:s-1)}return!1===a?s:"++"===l?s+1:s-1},assignmember(e,n,l,a){if(v(e)){if(!S(n))throw new o(null,r.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>e.length)throw new o(null,r.OutOfBounds,null);if(n===e.length){if("="!==l)throw new o(null,r.OutOfBounds,null);e[n]=this.assign(a,l,e[n])}else e[n]=this.assign(a,l,e[n])}else if(e instanceof t){if(!1===M(n))throw new o(null,r.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(a,l,e.field(n)));else{if("="!==l)throw new o(null,r.FieldNotFound,null);e.setField(n,this.assign(a,l,null))}}else if(F(e)){if(!1===M(n))throw new o(null,r.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(a,l,e.field(n)));else{if("="!==l)throw new o(null,r.FieldNotFound,null);e.setField(n,this.assign(a,l,null))}}else{if(x(e))throw new o(null,r.Immutable,null);if(!(e instanceof Ze))throw new o(null,r.InvalidIdentifier,null);if(!1===M(n))throw new o(null,r.ModuleAccessorMustBeString,null);if(!e.hasGlobal(n))throw new o(null,r.ModuleExportNotFound,null);e.setGlobal(n,this.assign(a,l,e.global(n)))}},member(e,n){if(null===e)throw new o(null,r.MemberOfNull,null);if(e instanceof t||F(e)){if(M(n))return e.field(n);throw new o(null,r.InvalidMemberAccessKey,null)}if(e instanceof K){if(M(n))return L(e,n,null,null);throw new o(null,r.InvalidMemberAccessKey,null)}if(v(e)){if(S(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new o(null,r.OutOfBounds,null);return e[n]}throw new o(null,r.InvalidMemberAccessKey,null)}if(M(e)){if(S(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new o(null,r.OutOfBounds,null);return e[n]}throw new o(null,r.InvalidMemberAccessKey,null)}if(x(e)){if(S(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length()+n),n>=e.length()||n<0)throw new o(null,r.OutOfBounds,null);return e.get(n)}throw new o(null,r.InvalidMemberAccessKey,null)}if(e instanceof Ze){if(M(n))return e.global(n);throw new o(null,r.InvalidMemberAccessKey,null)}throw new o(null,r.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,l){if(!(e instanceof Ze))throw new o(null,r.FunctionNotFound,null);const a=e.global(t);if(!1===m(a))throw new o(null,r.CallNonFunction,null);return a.call(l,{preparsed:!0,arguments:n})}};function De(e){console.log(e)}function Ue(e,t,a=!1){null===t&&(t={vars:{},customfunctions:{}});let s=null;e.usesModules&&(s=new n(null,e.loadedModules));const i={isAsync:a,globalScope:ke(t.vars,a?Ie:$e,t.customfunctions),moduleFactory:{},moduleFactoryMap:{},undeclaredGlobalsInFunctions:new Map,customfunctions:t.customfunctions,libraryResolver:s,localScope:null,mangleMap:{},depthCounter:{depth:1},exports:{},console:De,lrucache:t.lrucache,timeZone:t.timeZone??null,interceptor:t.interceptor,services:t.services,symbols:{symbolCounter:0}};let u=V(i,e);""===u&&(u="lc.voidOperation; "),i.undeclaredGlobalsInFunctions.size>0&&i.undeclaredGlobalsInFunctions.forEach((e=>{throw new l(t,r.InvalidIdentifier,e.node)}));let c="";c=a?"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"+u+"\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 "+u+"\n return lastStatement; } \n return this.postProcess(mainBody()); ";const p=i.moduleFactory,g=i.moduleFactoryMap,S=i.exports,v={};for(const n in S)v[n]=void 0!==i.mangleMap[n]?i.mangleMap[n]:n;const x={lc:f,lang:Re,mangles:i.mangleMap,postProcess(e){if(e instanceof d&&(e=e.value),e instanceof h&&(e=e.value),e===y&&(e=null),e===b)throw new o(null,r.IllegalResult,null);if(e===w)throw new o(null,r.IllegalResult,null);if(m(e))throw new o(null,r.IllegalResult,null);return e},prepare(e,n){let t=e.spatialReference;null==t&&(t=T.WebMercator);const o=Ee(e.vars,e.customfunctions,n,e.timeZone);return{localStack:[],isAsync:n,moduleFactory:p,moduleFactoryMap:g,mangleMap:this.mangles,moduleSingletons:{},exports:S,gdefs:{},exportmangle:v,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??De,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:{depth:1}}}};return new Function("context","spatialReference",c).bind(x)}async function Pe(){return Be([await import("./functions/geomasync.js")],"async"),!0}class Ze extends e{constructor(e){super(null),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,l=e.toLowerCase();if(m(n))throw new o(null,r.AssignModuleFunction,null);t[this.moduleContext.exportmangle[l]]=n}global(e){const n=this.moduleContext.globalScope;e=e.toLowerCase();const t=n[this.moduleContext.exportmangle[e]];if(void 0===t)throw new o(null,r.InvalidIdentifier,null);if(m(t)&&!(t instanceof c)){const o=new c;return o.fn=t,o.parameterEvaluator=z,o.context=this.moduleContext,n[this.moduleContext.exportmangle[e]]=o,o}return t}}function Ke(e,t,o=!1){const r={isAsync:o,moduleFactory:t.moduleFactory,moduleFactoryMap:{},libraryResolver:new n(null,e.loadedModules),globalScope:ke(t.vars,o?Ie:$e,t.customfunctions),customfunctions:t.customfunctions,localScope:null,mangleMap:{},undeclaredGlobalsInFunctions:new Map,depthCounter:{depth:1},exports:{},console:De,lrucache:t.lrucache,timeZone:t.timeZone??null,interceptor:t.interceptor,services:t.services,symbols:{symbolCounter:0}};let l=V(r,e);""===l&&(l="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"+l+"\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 "+l+"\n return lastStatement; } \n mainBody(); \n return this.prepareModule(runtimeCtx); ";const s=r.moduleFactory,i=r.moduleFactoryMap,u=r.exports,c={};for(const n in u)c[n]=void 0!==r.mangleMap[n]?r.mangleMap[n]:n;const p={lc:f,lang:Re,mangles:r.mangleMap,prepareModule:e=>new Ze(e),prepare(e,n){let t=e.spatialReference;null==t&&(t=new T({wkid:102100}));const o=Ee(e.vars,e.customfunctions,n,e.timeZone);return{localStack:[],isAsync:n,exports:u,exportmangle:c,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??De,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:e.depthCounter}}};return new Function("context","spatialReference",a).bind(p)}export{q as UserDefinedCompiledFunction,Ue as compileScript,Pe as enableAsyncSupport,Ne as executeScript,Be as extend,Ge as functionHelper};