@arcgis/core 4.32.0-next.20241029 → 4.32.0-next.20241031
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.
- package/arcade/Dictionary.js +1 -1
- package/arcade/Feature.js +1 -1
- package/arcade/arcadeAsyncRuntime.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade/arcadeRuntime.js +1 -1
- package/arcade/containerUtils.js +1 -1
- package/arcade/deepClone.js +1 -1
- package/arcade/featureSetUtils.js +1 -1
- package/arcade/featureset/actions/GroupBy.js +1 -1
- package/arcade/featureset/actions/OrderBy.js +1 -1
- package/arcade/functions/convertdirection.js +1 -1
- package/arcade/functions/date.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/arcade/functions/featuresetgeom.js +1 -1
- package/arcade/functions/featuresetstats.js +1 -1
- package/arcade/functions/featuresetstring.js +1 -1
- package/arcade/functions/fieldStats.js +1 -1
- package/arcade/functions/geomasync.js +1 -1
- package/arcade/functions/geometry.js +1 -1
- package/arcade/functions/geomsync.js +1 -1
- package/arcade/functions/knowledgegraph.js +1 -1
- package/arcade/functions/maths.js +1 -1
- package/arcade/functions/stats.js +1 -1
- package/arcade/functions/string.js +1 -1
- package/arcade/languageUtils.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{802c8305b5dcfcb186f3.js → 0562ef2ca940c540f0ef.js} +1 -1
- package/assets/esri/core/workers/chunks/0da3cf883a2c00800f30.js +1 -0
- package/assets/esri/core/workers/chunks/0db39a3960d240a09457.js +1 -0
- package/assets/esri/core/workers/chunks/0dddfb446047abdf4f15.js +1 -0
- package/assets/esri/core/workers/chunks/0ff8e3f6a2b14c31f07a.js +1 -0
- package/assets/esri/core/workers/chunks/10a2b0c798d75adf098f.js +1 -0
- package/assets/esri/core/workers/chunks/{6ff1419676e95fa990f8.js → 2005ae9b44a8559fa6fb.js} +1 -1
- package/assets/esri/core/workers/chunks/27acb760854ac45d5dc0.js +1 -0
- package/assets/esri/core/workers/chunks/2946ac049400958d5f9b.js +1 -0
- package/assets/esri/core/workers/chunks/297df85b47f80c4659b1.js +1 -0
- package/assets/esri/core/workers/chunks/309edbd31e334ac78685.js +1 -0
- package/assets/esri/core/workers/chunks/328f748131d8a9e8b2cf.js +1 -0
- package/assets/esri/core/workers/chunks/373808292fdb65200531.js +1 -0
- package/assets/esri/core/workers/chunks/3830b54e5b2a4089a540.js +1 -0
- package/assets/esri/core/workers/chunks/3c3ad0928b25d076a3d5.js +1 -0
- package/assets/esri/core/workers/chunks/3c71029ca385ef9ae8e0.js +1 -0
- package/assets/esri/core/workers/chunks/3e0d9d5fe820b5a10f28.js +1 -0
- package/assets/esri/core/workers/chunks/40d98cab2a88dcdeb783.js +1 -0
- package/assets/esri/core/workers/chunks/465d0912d6e3bb0b2fd3.js +1 -0
- package/assets/esri/core/workers/chunks/4b96c2f0b19843ab07b2.js +1 -0
- package/assets/esri/core/workers/chunks/4ce8918a7703d8c1db97.js +1 -0
- package/assets/esri/core/workers/chunks/4ecf7adfdd4133f36c1a.js +1 -0
- package/assets/esri/core/workers/chunks/53d6545601fce0995c12.js +1 -0
- package/assets/esri/core/workers/chunks/578e2761c32b9f61d7d1.js +1 -0
- package/assets/esri/core/workers/chunks/5b235dc38da77b9b7833.js +1 -0
- package/assets/esri/core/workers/chunks/5cdc601c5e1769741105.js +1 -0
- package/assets/esri/core/workers/chunks/{ca9a0b86a293112368f4.js → 5d952a6edce641661348.js} +1 -1
- package/assets/esri/core/workers/chunks/5db96e96dbe17e1ca40e.js +1 -0
- package/assets/esri/core/workers/chunks/62442e449a568d304bd6.js +1 -0
- package/assets/esri/core/workers/chunks/6460d653677f44b87e22.js +1 -0
- package/assets/esri/core/workers/chunks/{e1148291e19a0eaef5a4.js → 65197ad6558511ca4d94.js} +1 -1
- package/assets/esri/core/workers/chunks/{857166490684430878d9.js → 65c367437b9183ebf209.js} +1 -1
- package/assets/esri/core/workers/chunks/674222e21b5aec2faaa8.js +1 -0
- package/assets/esri/core/workers/chunks/{634a2c2d65998a699900.js → 67d031ef350036613ada.js} +1 -1
- package/assets/esri/core/workers/chunks/6c2f066619103fdf1e35.js +1 -0
- package/assets/esri/core/workers/chunks/72c59be13d334e11bd14.js +1 -0
- package/assets/esri/core/workers/chunks/{17a77972b2fbd8e9e905.js → 72f6574e56be59a5ea81.js} +1 -1
- package/assets/esri/core/workers/chunks/{031a1f81c1afbdcd8a9c.js → 767e4b2b2af7310ac980.js} +1 -1
- package/assets/esri/core/workers/chunks/{58986cfd3ba0192cc1a4.js → 7d6c59f5eda43bd760ec.js} +1 -1
- package/assets/esri/core/workers/chunks/8887d3d34bac3a67cc11.js +1 -0
- package/assets/esri/core/workers/chunks/{04fbb60b1b42ad861703.js → 88f5699125a6aa75cf52.js} +1 -1
- package/assets/esri/core/workers/chunks/8b514fce9a7634766682.js +1 -0
- package/assets/esri/core/workers/chunks/{75f017bc3bde698288ca.js → 8d1ac530025271fc9c36.js} +1 -1
- package/assets/esri/core/workers/chunks/945c6eb04c839bde39a4.js +1 -0
- package/assets/esri/core/workers/chunks/{6dd21790b94856ad9ba1.js → 96c222c7a741c48a1050.js} +1 -1
- package/assets/esri/core/workers/chunks/9c1bb8d0149d4c0872c4.js +1 -0
- package/assets/esri/core/workers/chunks/{aeade1daa879cfd7511a.js → aa650776a576dd1c6814.js} +1 -1
- package/assets/esri/core/workers/chunks/acfe00227009fdaa26dc.js +1 -0
- package/assets/esri/core/workers/chunks/af1c1334240e613ab340.js +1 -0
- package/assets/esri/core/workers/chunks/b9f85e88ac53a954473c.js +1 -0
- package/assets/esri/core/workers/chunks/be65578a2fe0462429a8.js +1 -0
- package/assets/esri/core/workers/chunks/bf83852bd12b6d157b15.js +1 -0
- package/assets/esri/core/workers/chunks/bfc0c262e5a1e81a7717.js +1 -0
- package/assets/esri/core/workers/chunks/c2c244e4e76380d245cc.js +320 -0
- package/assets/esri/core/workers/chunks/{6fa13a7f0ac42b56319f.js → c549db4dc5d8eafdcfd1.js} +1 -1
- package/assets/esri/core/workers/chunks/{646589be704473787fc2.js → c562adfb817228dcd31d.js} +1 -1
- package/assets/esri/core/workers/chunks/{06c7b609d8f905aecd11.js → c740049be97682d5c8d0.js} +1 -1
- package/assets/esri/core/workers/chunks/c837c8f03320b988db5a.js +1 -0
- package/assets/esri/core/workers/chunks/c8eeb734e6cb3d9a8ca6.js +1 -0
- package/assets/esri/core/workers/chunks/c9007de7dcb2606c0d05.js +1 -0
- package/assets/esri/core/workers/chunks/{24429a8abe0efc93786d.js → d1f2c83e962b83c63a7a.js} +1 -1
- package/assets/esri/core/workers/chunks/d2bc295edbc8fcec7ae3.js +1 -0
- package/assets/esri/core/workers/chunks/d451448ef06e5dc80cd8.js +1 -0
- package/assets/esri/core/workers/chunks/d484560fd3393ca94193.js +1 -0
- package/assets/esri/core/workers/chunks/d978afe19c22ef917298.js +1 -0
- package/assets/esri/core/workers/chunks/dced64a8fbfc141780c8.js +1 -0
- package/assets/esri/core/workers/chunks/{624382c5785e92ba5ef1.js → de1fcf2a928e8ccb270d.js} +1 -1
- package/assets/esri/core/workers/chunks/e3d65aa9307c244be02f.js +1 -0
- package/assets/esri/core/workers/chunks/ef6afba80fa2086ec104.js +1 -0
- package/assets/esri/core/workers/chunks/f35cf692d8961a0ca7d9.js +1 -0
- package/assets/esri/core/workers/chunks/f429d95eb986f3d215f3.js +1 -0
- package/assets/esri/core/workers/chunks/f5b57274c3f49ccbcf2e.js +1 -0
- package/assets/esri/core/workers/chunks/{ac7f3df658b7f7596c4b.js → fa07dbc92a93a1cf0e3b.js} +1 -1
- package/assets/esri/core/workers/chunks/fe817283bbcbca8fb296.js +1 -0
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- package/assets/esri/themes/base/widgets/_Feature.scss +4 -0
- package/assets/esri/themes/base/widgets/_Histogram.scss +4 -0
- package/assets/esri/themes/base/widgets/_TimeZoneLabel.scss +17 -5
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/Feature/t9n/Feature.json +1 -1
- package/assets/esri/widgets/Feature/t9n/Feature_en.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_ar.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_bg.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_bs.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_ca.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_cs.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_da.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_de.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_el.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_en.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_es.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_et.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_fi.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_fr.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_he.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_hr.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_hu.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_id.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_it.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_ja.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_ko.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_lt.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_lv.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_nb.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_nl.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_pl.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_pt-BR.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_pt-PT.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_ro.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_ru.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_sk.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_sl.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_sr.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_sv.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_th.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_tr.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_uk.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_vi.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_zh-CN.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_zh-HK.json +1 -1
- package/assets/esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel_zh-TW.json +1 -1
- package/chunks/array.js +1 -1
- package/chunks/boundedPlane.js +1 -1
- package/chunks/languageUtils.js +1 -1
- package/chunks/lyr3DWorker.js +1 -1
- package/core/unitUtils.js +1 -1
- package/geometry/operators/minimumBoundingCircleOperator.d.ts +2 -2
- package/geometry/operators/multiPartToSinglePartOperator.d.ts +4 -0
- package/geometry/operators/polygonSlicerOperator.js +1 -1
- package/geometry/operators/reshapeOperator.d.ts +4 -0
- package/geometry/projection/computeTranslationToOriginAndRotation.js +1 -1
- package/geometry/projection/localLinearScaleFactors.js +1 -1
- package/geometry/projection/projectBoundingSphere.js +1 -1
- package/geometry/projection/projectBuffer.js +1 -1
- package/geometry/projection/projectVec3Array.js +1 -1
- package/geometry/projection/projectors.js +1 -1
- package/geometry/projection.js +1 -1
- package/geometry/support/Indices.js +1 -1
- package/interfaces.d.ts +431 -227
- package/layers/FeatureLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/SubtypeGroupLayer.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/support/domainUtils.js +1 -1
- package/layers/support/featureLayerUtils.js +1 -1
- package/package.json +1 -1
- package/renderers/visualVariables/RotationVariable.js +1 -1
- package/smartMapping/renderers/heatmap.js +1 -1
- package/smartMapping/renderers/support/regenerateUtils.js +1 -1
- package/smartMapping/renderers/support/rendererUtils.js +1 -1
- package/smartMapping/renderers/type.js +1 -1
- package/support/arcadeUtils.js +1 -1
- package/support/dateUtils.js +5 -0
- package/support/guards.js +5 -0
- package/support/revision.js +1 -1
- package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
- package/time/timeZoneUtils.js +1 -1
- package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
- package/views/2d/layers/graphics/GraphicStoreItem.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/utils.js +5 -0
- package/views/3d/analysis/AreaMeasurementAnalysisView3D.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementController.js +1 -1
- package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementVisualization.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedConfiguration.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/layers/support/highlightUtils.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/UnpackAttributes.glsl.js +20 -35
- package/views/layers/support/MapServiceLayerViewHelper.js +1 -1
- package/widgets/Directions/DirectionsViewModel.js +1 -1
- package/widgets/Expand.js +1 -1
- package/widgets/Feature/FeatureUtilityNetworkAssociationType.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/Features/FeaturesDrillIn.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/TimeZoneLabel/TimeZoneLabelViewModel.js +1 -1
- package/widgets/TimeZoneLabel/css.js +1 -1
- package/widgets/TimeZoneLabel.js +1 -1
- package/widgets/UtilityNetworkTraceAnalysis/UtilityNetworkTraceAnalysisViewModel.d.ts +4 -0
- package/widgets/support/GridControls/GridControlsViewModel.d.ts +1 -1
- package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
- package/widgets/support/GridControls.js +1 -1
- package/widgets/support/dateUtils.js +1 -1
- package/assets/esri/core/workers/chunks/002f544609275b74912f.js +0 -1
- package/assets/esri/core/workers/chunks/06fa2a58cb7c02fc1ecb.js +0 -1
- package/assets/esri/core/workers/chunks/0f6e3f614a12a56e5246.js +0 -1
- package/assets/esri/core/workers/chunks/1201e22dbadb87cd420c.js +0 -1
- package/assets/esri/core/workers/chunks/123a34146d26075aa409.js +0 -1
- package/assets/esri/core/workers/chunks/12b725c403f8244174d9.js +0 -1
- package/assets/esri/core/workers/chunks/164fbbf29d062d470e36.js +0 -1
- package/assets/esri/core/workers/chunks/165911e07a48542534de.js +0 -1
- package/assets/esri/core/workers/chunks/196ff12122673fffd161.js +0 -1
- package/assets/esri/core/workers/chunks/1cefd1d7845f5e4b9c0f.js +0 -1
- package/assets/esri/core/workers/chunks/2a685bf938956b52b6c6.js +0 -1
- package/assets/esri/core/workers/chunks/2d83aae61e986b97ac62.js +0 -1
- package/assets/esri/core/workers/chunks/2d8aa31dc96bbd014036.js +0 -1
- package/assets/esri/core/workers/chunks/30c064cfff7e45462504.js +0 -1
- package/assets/esri/core/workers/chunks/318dc9461246e9593bb2.js +0 -1
- package/assets/esri/core/workers/chunks/3883e9b815d48496efc5.js +0 -1
- package/assets/esri/core/workers/chunks/3ca5550642b1387c1340.js +0 -1
- package/assets/esri/core/workers/chunks/3d15d8621abed8de1b85.js +0 -1
- package/assets/esri/core/workers/chunks/3fdb8a5b3b3f24737ef4.js +0 -1
- package/assets/esri/core/workers/chunks/4603225bee1768f88821.js +0 -1
- package/assets/esri/core/workers/chunks/463d9a05f40e2c73f644.js +0 -1
- package/assets/esri/core/workers/chunks/47af510d0bd89b108729.js +0 -1
- package/assets/esri/core/workers/chunks/4e3099b06ea3ad933fa5.js +0 -1
- package/assets/esri/core/workers/chunks/52255276b1d53ac75bef.js +0 -1
- package/assets/esri/core/workers/chunks/533aec3418eb419a8cce.js +0 -1
- package/assets/esri/core/workers/chunks/56326fd42c3aecb323d1.js +0 -1
- package/assets/esri/core/workers/chunks/6517f695e8ee3d82b596.js +0 -1
- package/assets/esri/core/workers/chunks/70685c23aad41b0f03ba.js +0 -1
- package/assets/esri/core/workers/chunks/760130e1940b299c1ff7.js +0 -1
- package/assets/esri/core/workers/chunks/7a340d87526e179fd871.js +0 -1
- package/assets/esri/core/workers/chunks/812573c222af4fee8ff0.js +0 -320
- package/assets/esri/core/workers/chunks/82346b518b7625c4e184.js +0 -1
- package/assets/esri/core/workers/chunks/862177e13be636dfa578.js +0 -1
- package/assets/esri/core/workers/chunks/90e758afa0bc8f5a5001.js +0 -1
- package/assets/esri/core/workers/chunks/999a12ab248a3a205f58.js +0 -1
- package/assets/esri/core/workers/chunks/9ca3d958cdec3db99591.js +0 -1
- package/assets/esri/core/workers/chunks/a1752adee1f58ee21581.js +0 -1
- package/assets/esri/core/workers/chunks/a8c536027b6d40e3b4e7.js +0 -1
- package/assets/esri/core/workers/chunks/aa597918f8d480deb8d4.js +0 -1
- package/assets/esri/core/workers/chunks/ad97f3a86de697c18f7b.js +0 -1
- package/assets/esri/core/workers/chunks/b0db3106f38fcc2f0b5c.js +0 -1
- package/assets/esri/core/workers/chunks/b4748c8e9cce4392e185.js +0 -1
- package/assets/esri/core/workers/chunks/b58a48daff2914f8fa81.js +0 -1
- package/assets/esri/core/workers/chunks/b59fc770f6a8f0d913f7.js +0 -1
- package/assets/esri/core/workers/chunks/c90be1540463bf613dc8.js +0 -1
- package/assets/esri/core/workers/chunks/db8d2762ce23c1a9a2e2.js +0 -1
- package/assets/esri/core/workers/chunks/e2d5bae9f982c65301ce.js +0 -1
- package/assets/esri/core/workers/chunks/e71ab113f15d2165feb1.js +0 -1
- package/assets/esri/core/workers/chunks/eb28eab7539898ce75a7.js +0 -1
- package/assets/esri/core/workers/chunks/ee794e3c916da2fb9275.js +0 -1
- package/assets/esri/core/workers/chunks/f409c5fcef0ee9d84ed7.js +0 -1
- package/assets/esri/core/workers/chunks/fc1d1e0b7ce9c0d929a6.js +0 -1
- package/assets/esri/core/workers/chunks/fd2f3b344ae822e9d001.js +0 -1
- package/assets/esri/core/workers/chunks/ffbf38a565cbe8f44ff4.js +0 -1
- package/widgets/support/dataUtils.js +0 -5
package/arcade/Dictionary.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ArcadeDate as t}from"./ArcadeDate.js";import{deepClone as s}from"./deepClone.js";import{ArcadeExecutionError as i,ExecutionErrorCodes as e}from"./executionError.js";import r from"./ImmutableArray.js";import{i as n,a as o,
|
|
5
|
+
import{ArcadeDate as t}from"./ArcadeDate.js";import{deepClone as s}from"./deepClone.js";import{ArcadeExecutionError as i,ExecutionErrorCodes as e}from"./executionError.js";import r from"./ImmutableArray.js";import{i as n,a as o,t as a,c as u,b as l,d as c,e as f,f as m,g as h,h as y,j as b,k as d,l as g,m as p,n as w}from"../chunks/languageUtils.js";import J from"../geometry/Geometry.js";import{isNumber as A,isString as T}from"../support/guards.js";function j(t,s,i=!1,e=!1){if(null==t)return null;if(A(t))return f(t);if(o(t))return m(t);if(T(t))return h(t);if(y(t))return b(t,s);if(d(t))return t;if(g(t))return t;if(p(t)){const r=[];for(const n of t)r.push(j(n,s,i,e));return r}if(e&&w(t))return t;const r=new v;r.immutable=!1;for(const n of Object.keys(t)){const o=t[n];void 0!==o&&r.setField(n,j(o,s,i,e))}return r.immutable=i,r}class v{constructor(t){this.declaredClass="esri.arcade.Dictionary",this.attributes=null,this.plain=!1,this.immutable=!0,this.attributes=t instanceof v?t.attributes:t??{}}field(t){const s=t.toLowerCase(),r=this.attributes[t];if(void 0!==r)return r;for(const i in this.attributes)if(i.toLowerCase()===s)return this.attributes[i];throw new i(null,e.FieldNotFound,null,{key:t})}setField(s,r){if(this.immutable)throw new i(null,e.Immutable,null);if(n(r))throw new i(null,e.NoFunctionInDictionary,null);const o=s.toLowerCase();r instanceof Date&&(r=t.dateJSToArcadeDate(r));if(void 0===this.attributes[s]){for(const t in this.attributes)if(t.toLowerCase()===o)return void(this.attributes[t]=r);this.attributes[s]=r}else this.attributes[s]=r}hasField(t){const s=t.toLowerCase();if(void 0!==this.attributes[t])return!0;for(const i in this.attributes)if(i.toLowerCase()===s)return!0;return!1}keys(){let t=[];for(const s in this.attributes)t.push(s);return t=t.sort(),t}castToText(s=!1){let i="";for(const e in this.attributes){""!==i&&(i+=",");const n=this.attributes[e];null==n?i+=JSON.stringify(e)+":null":o(n)||A(n)||T(n)?i+=JSON.stringify(e)+":"+JSON.stringify(n):n instanceof J?i+=JSON.stringify(e)+":"+a(n):n instanceof r||Array.isArray(n)?i+=JSON.stringify(e)+":"+a(n,null,s):n instanceof t?i+=s?JSON.stringify(e)+":"+JSON.stringify(n.getTime()):JSON.stringify(e)+":"+n.stringify():null!==n&&"object"==typeof n&&void 0!==n.castToText&&(i+=JSON.stringify(e)+":"+n.castToText(s))}return"{"+i+"}"}static convertObjectToArcadeDictionary(t,s,i=!0,e=!1){const r=new v;r.immutable=!1;for(const n in t){const o=t[n];void 0!==o&&r.setField(n.toString(),j(o,s,i,e))}return r.immutable=i,r}static convertJsonToArcade(t,s,i=!1,e=!1){return j(t,s,i,e)}castAsJson(t=null){const s={};for(let i in this.attributes){const e=this.attributes[i];void 0!==e&&(t?.keyTranslate&&(i=t.keyTranslate(i)),s[i]=u(e,t))}return s}async castDictionaryValueAsJsonAsync(t,s,i,e=null,r){const n=await l(i,e,r);return t[s]=n,n}async castAsJsonAsync(s=null,i=null){const e={},r=[];for(let n in this.attributes){const o=this.attributes[n];i?.keyTranslate&&(n=i.keyTranslate(n)),void 0!==o&&(c(o)||o instanceof J||o instanceof t?e[n]=u(o,i):r.push(this.castDictionaryValueAsJsonAsync(e,n,o,s,i)))}return r.length>0&&await Promise.all(r),e}deepClone(){const t=new v;t.immutable=!1;for(const i of this.keys())t.setField(i,s(this.field(i)));return t}}export{v as default};
|
package/arcade/Feature.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ArcadeDate as e}from"./ArcadeDate.js";import{configureDeepClone as t}from"./deepClone.js";import i from"./Dictionary.js";import{ArcadeExecutionError as s,ExecutionErrorCodes as r}from"./executionError.js";import n from"./ImmutableArray.js";import{u as o,a,b as l,c as u,t as f,n as d,m as y,k as h,f as c,d as m}from"../chunks/languageUtils.js";import{DateOnly as p}from"../core/sql/DateOnly.js";import{TimeOnly as _}from"../core/sql/TimeOnly.js";import b from"../geometry/Geometry.js";import g from"../geometry/Point.js";import{fromJSON as T}from"../geometry/support/jsonUtils.js";import{convertToGeometry as x}from"../layers/graphics/featureConversionUtils.js";import F from"../layers/support/FieldsIndex.js";class D{constructor(){this.arcadeDeclaredClass="esri.arcade.Feature",this._optimizedGeomDefinition=null,this._geometry=null,this.attributes=null,this._layer=null,this._fieldTypesFixed=!0,this.fieldsIndex=null,this.contextTimeZone=null,this.immutable=!0,this._fieldsToFixDataTypes=null,this.immutable=!0}static createFromGraphic(e,t){const i=new D;return i.contextTimeZone=t??null,i._geometry=null!=e.geometry?e.geometry:null,void 0===e.attributes||null===e.attributes?i.attributes={}:i.attributes=e.attributes,e._sourceLayer?(i._layer=e._sourceLayer,i._fieldTypesFixed=!1):e._layer?(i._layer=e._layer,i._fieldTypesFixed=!1):e.layer&&"fields"in e.layer?(i._layer=e.layer,i._fieldTypesFixed=!1):e.sourceLayer&&"fields"in e.sourceLayer&&(i._layer=e.sourceLayer,i._fieldTypesFixed=!1),i._layer&&!i._fieldTypesFixed&&(i.fieldsIndex=this.hydrateFieldsIndex(i._layer)),i}static createFromArcadeFeature(e){if(e instanceof D){const t=new D;return t._fieldTypesFixed=e._fieldTypesFixed,t.attributes=e.attributes,t._geometry=e._geometry,t._optimizedGeomDefinition=e._optimizedGeomDefinition,e._layer&&(t._layer=e._layer),t.fieldsIndex=e.fieldsIndex,t.contextTimeZone=e.contextTimeZone,t}const t={};for(const i of e.keys())t[i]=e.field(i);return D.createFromGraphicLikeObject(e.geometry(),t,e.fullSchema(),e.contextTimeZone)}static createFromOptimisedFeature(e,t,i){const s=new D;return s._geometry=e.geometry?{geometry:e.geometry}:null,s._optimizedGeomDefinition=i,s.attributes=e.attributes||{},s._layer=t,s._fieldTypesFixed=!1,s}static createFromArcadeDictionary(e,t){const s=new D;return s.attributes=e.field("attributes"),null!==s.attributes&&s.attributes instanceof i?(s.attributes=s.attributes.attributes,null===s.attributes&&(s.attributes={})):s.attributes={},s._geometry=e.field("geometry"),null!==s._geometry&&(s._geometry instanceof i?s._geometry=D.parseGeometryFromDictionary(s._geometry,t):s._geometry instanceof b||(s._geometry=null)),s}static createFromGraphicLikeObject(e,t,i=null,s){const r=new D;return r.contextTimeZone=s??null,null===t&&(t={}),r.attributes=t,r._geometry=null!=e?e:null,r._layer=i,r._layer&&(r._fieldTypesFixed=!1,r.fieldsIndex=this.hydrateFieldsIndex(r._layer)),r}static hydrateFieldsIndex(e){return null===e?null:o(e)?e.getFieldsIndex():e.fieldsIndex?e.fieldsIndex:F.fromLayerJSON({datesInUnknownTimezone:e.datesInUnknownTimezone,fields:e.fields,timeInfo:e.timeInfo,editFieldsInfo:e.editFieldsInfo,dateFieldsTimeReference:e.dateFieldsTimeReference??{timeZone:"UTC",respectsDaylightSaving:!1}})}repurposeFromGraphicLikeObject(e,t,i=null){null===t&&(t={}),this.attributes=t,this._geometry=e??null,this._layer=i,this._layer?this._fieldTypesFixed=!1:this._fieldTypesFixed=!0}castToText(t=!1){let i="";!1===this._fieldTypesFixed&&this._fixFieldTypes();for(const s in this.attributes){""!==i&&(i+=",");const r=this.attributes[s];null==r?i+=JSON.stringify(s)+":null":a(r)||l(r)||u(r)?i+=JSON.stringify(s)+":"+JSON.stringify(r):r instanceof b?i+=JSON.stringify(s)+":"+f(r):r instanceof _||r instanceof p?i+=`${JSON.stringify(s)}:${JSON.stringify(r.toString())}`:r instanceof n||Array.isArray(r)?i+=JSON.stringify(s)+":"+f(r,null,t):r instanceof e?i+=t?JSON.stringify(s)+":"+JSON.stringify(r.getTime()):JSON.stringify(s)+":"+r.stringify():null!==r&&"object"==typeof r&&void 0!==r.castToText&&(i+=JSON.stringify(s)+":"+r.castToText(t))}return'{"geometry":'+(null===this.geometry()?"null":f(this.geometry()))+',"attributes":{'+i+"}}"}_fixFieldTypes(){if(this._fieldsToFixDataTypes&&this._fieldsToFixDataTypes?.length>0)return this._fixAllFields(this._fieldsToFixDataTypes),void(this._fieldTypesFixed=!0);const e=[],t=this._layer.fields;for(let i=0;i<t.length;i++){const s=t[i],{name:r,type:n}=s;switch(n){case"date":case"esriFieldTypeDate":e.push({field:r,dataType:"date"});break;case"date-only":case"esriFieldTypeDateOnly":e.push({field:r,dataType:"date-only"});break;case"time-only":case"esriFieldTypeTimeOnly":e.push({field:r,dataType:"time-only"});break;case"timestamp-offset":case"esriFieldTypeTimestampOffset":e.push({field:r,dataType:"timestamp-offset"})}}this._fieldsToFixDataTypes=e,e.length>0&&this._fixAllFields(e),this._fieldTypesFixed=!0}isUnknownDateTimeField(e){return"unknown"===this.fieldsIndex?.getTimeZone(e)}_fixAllFields(t){this.attributes={...this.attributes};const i=this.contextTimeZone??"system";for(let s=0;s<t.length;s++){const r=t[s].field,n=t[s].dataType;let o=this.attributes[r];if(void 0===o){for(const t in this.attributes)if(t.toLowerCase()===r.toLowerCase()){if(o=this.attributes[t],null!==o){if("time-only"===n){d(o)||(this.attributes[t]=_.fromReader(o.toString()));break}if("date-only"===n){y(o)||(this.attributes[t]=p.fromReader(o.toString()));break}if("timestamp-offset"===n){h(o)||(this.attributes[t]=e.fromReaderAsTimeStampOffset(o.toString()));break}const s=this.isUnknownDateTimeField(t);o instanceof Date?this.attributes[t]=s?e.unknownDateJSToArcadeDate(o):e.dateJSAndZoneToArcadeDate(o,i):h(o)||(this.attributes[t]=s?e.unknownEpochToArcadeDate(o):e.epochToArcadeDate(o,i))}break}}else if(null!==o){if("time-only"===n){d(o)?this.attributes[r]=o:this.attributes[r]=_.fromReader(o.toString());continue}if("date-only"===n){y(o)?this.attributes[r]=o:this.attributes[r]=p.fromReader(o.toString());continue}if("timestamp-offset"===n){h(o)?this.attributes[r]=o:this.attributes[r]=e.fromReaderAsTimeStampOffset(o.toString());continue}const t=this.isUnknownDateTimeField(r);h(o)?this.attributes[r]=o:o instanceof Date?this.attributes[r]=t?e.unknownDateJSToArcadeDate(o):e.dateJSAndZoneToArcadeDate(o,i):this.attributes[r]=t?e.unknownEpochToArcadeDate(o):e.epochToArcadeDate(o,i)}}}geometry(){return null===this._geometry||this._geometry instanceof b||(this._optimizedGeomDefinition?(this._geometry=T(x(this._geometry,this._optimizedGeomDefinition.geometryType,this._optimizedGeomDefinition.hasZ,this._optimizedGeomDefinition.hasM)),this._geometry.spatialReference=this._optimizedGeomDefinition.spatialReference):this._geometry=T(this._geometry)),this._geometry}field(e){this._fieldTypesFixed||this._fixFieldTypes();const t=this.attributes[e];if(void 0!==t)return t;const i=e.toLowerCase();for(const s in this.attributes)if(s.toLowerCase()===i)return this.attributes[s];if(this._hasFieldDefinition(i))return null;throw new s(null,r.FieldNotFound,null,{key:e})}_hasFieldDefinition(e){if(null===this._layer)return!1;for(let t=0;t<this._layer.fields.length;t++){if(this._layer.fields[t].name.toLowerCase()===e)return!0}return!1}setField(t,i){if(this.immutable)throw new s(null,r.Immutable,null);if(i instanceof Date&&(i=this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(i):e.dateJSToArcadeDate(i)),!1===c(i))throw new s(null,r.TypeNotAllowedInFeature,null);const n=t.toLowerCase();if(void 0===this.attributes[t]){for(const e in this.attributes)if(e.toLowerCase()===n)return void(this.attributes[e]=i);this.attributes[t]=i}else this.attributes[t]=i}hasField(e){const t=e.toLowerCase();if(void 0!==this.attributes[e])return!0;for(const i in this.attributes)if(i.toLowerCase()===t)return!0;return!!this._hasFieldDefinition(t)}keys(){let e=[];const t={};for(const i in this.attributes)e.push(i),t[i.toLowerCase()]=1;if(null!==this._layer)for(let i=0;i<this._layer.fields.length;i++){const s=this._layer.fields[i];1!==t[s.name.toLowerCase()]&&e.push(s.name)}return e=e.sort(),e}static parseGeometryFromDictionary(e,t){const i=D._convertDictionaryToJson(e,!0);return void 0!==i.hasm&&(i.hasM=i.hasm,delete i.hasm),void 0!==i.hasz&&(i.hasZ=i.hasz,delete i.hasz),void 0!==i.spatialreference&&(i.spatialReference=i.spatialreference,delete i.spatialreference),i.spatialReference||(i.spatialReference=t),void 0!==i.rings&&(i.rings=this._fixPathArrays(i.rings,!0===i.hasZ,!0===i.hasZ)),void 0!==i.paths&&(i.paths=this._fixPathArrays(i.paths,!0===i.hasZ,!0===i.hasM)),void 0!==i.points&&(i.points=this._fixPointArrays(i.points,!0===i.hasZ,!0===i.hasM)),T(i)}static _fixPathArrays(e,t,i){const s=[];if(Array.isArray(e))for(let r=0;r<e.length;r++)s.push(this._fixPointArrays(e[r],t,i));else if(e instanceof n)for(let r=0;r<e.length();r++)s.push(this._fixPointArrays(e.get(r),t,i));return s}static _fixPointArrays(e,t,i){const s=[];if(Array.isArray(e))for(let r=0;r<e.length;r++){const o=e[r];o instanceof g?t&&i?s.push([o.x,o.y,o.z,o.m]):t?s.push([o.x,o.y,o.z]):i?s.push([o.x,o.y,o.m]):s.push([o.x,o.y]):o instanceof n?s.push(o.toArray()):s.push(o)}else if(e instanceof n)for(let r=0;r<e.length();r++){const o=e.get(r);o instanceof g?t&&i?s.push([o.x,o.y,o.z,o.m]):t?s.push([o.x,o.y,o.z]):i?s.push([o.x,o.y,o.m]):s.push([o.x,o.y]):o instanceof n?s.push(o.toArray()):s.push(o)}return s}static _convertDictionaryToJson(e,t=!1){const s={};for(const r in e.attributes){let n=e.attributes[r];n instanceof i&&(n=D._convertDictionaryToJson(n)),t?s[r.toLowerCase()]=n:s[r]=n}return s}static parseAttributesFromDictionary(e){const t={};for(const i in e.attributes){const n=e.attributes[i];if(!c(n))throw new s(null,r.InvalidParameter,null);t[i]=n}return t}static fromJson(e,t){let i=null;null!==e.geometry&&void 0!==e.geometry&&(i=T(e.geometry));const n={};if(null!==e.attributes&&void 0!==e.attributes)for(const o in e.attributes){const t=e.attributes[o];if(null===t)n[o]=t;else{if(!(u(t)||l(t)||a(t)||h(t)||d(t)||y(t)))throw new s(null,r.InvalidParameter,null);n[o]=t}}return D.createFromGraphicLikeObject(i,n,null,t??null)}fullSchema(){return this._layer}gdbVersion(){if(null===this._layer)return"";const e=this._layer.gdbVersion;return void 0===e?"":""===e&&this._layer.capabilities?.isVersioned?"SDE.DEFAULT":e}castAsJson(e){const t={attributes:{},geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null};for(const i in this.attributes){const s=this.attributes[i];void 0!==s&&(t.attributes[i]=m(s,e))}return t}async castAsJsonAsync(e=null,t){return this.castAsJson(t)}}t(D);export{D as default};
|
|
5
|
+
import{ArcadeDate as e}from"./ArcadeDate.js";import{configureDeepClone as t}from"./deepClone.js";import i from"./Dictionary.js";import{ArcadeExecutionError as s,ExecutionErrorCodes as r}from"./executionError.js";import n from"./ImmutableArray.js";import{r as o,a,t as l,l as u,k as f,h as d,d as y,c as h}from"../chunks/languageUtils.js";import{DateOnly as m}from"../core/sql/DateOnly.js";import{TimeOnly as c}from"../core/sql/TimeOnly.js";import p from"../geometry/Geometry.js";import _ from"../geometry/Point.js";import{fromJSON as b}from"../geometry/support/jsonUtils.js";import{convertToGeometry as g}from"../layers/graphics/featureConversionUtils.js";import T from"../layers/support/FieldsIndex.js";import{isNumber as x,isString as F}from"../support/guards.js";class D{constructor(){this.arcadeDeclaredClass="esri.arcade.Feature",this._optimizedGeomDefinition=null,this._geometry=null,this.attributes=null,this._layer=null,this._fieldTypesFixed=!0,this.fieldsIndex=null,this.contextTimeZone=null,this.immutable=!0,this._fieldsToFixDataTypes=null,this.immutable=!0}static createFromGraphic(e,t){const i=new D;return i.contextTimeZone=t??null,i._geometry=null!=e.geometry?e.geometry:null,void 0===e.attributes||null===e.attributes?i.attributes={}:i.attributes=e.attributes,e._sourceLayer?(i._layer=e._sourceLayer,i._fieldTypesFixed=!1):e._layer?(i._layer=e._layer,i._fieldTypesFixed=!1):e.layer&&"fields"in e.layer?(i._layer=e.layer,i._fieldTypesFixed=!1):e.sourceLayer&&"fields"in e.sourceLayer&&(i._layer=e.sourceLayer,i._fieldTypesFixed=!1),i._layer&&!i._fieldTypesFixed&&(i.fieldsIndex=this.hydrateFieldsIndex(i._layer)),i}static createFromArcadeFeature(e){if(e instanceof D){const t=new D;return t._fieldTypesFixed=e._fieldTypesFixed,t.attributes=e.attributes,t._geometry=e._geometry,t._optimizedGeomDefinition=e._optimizedGeomDefinition,e._layer&&(t._layer=e._layer),t.fieldsIndex=e.fieldsIndex,t.contextTimeZone=e.contextTimeZone,t}const t={};for(const i of e.keys())t[i]=e.field(i);return D.createFromGraphicLikeObject(e.geometry(),t,e.fullSchema(),e.contextTimeZone)}static createFromOptimisedFeature(e,t,i){const s=new D;return s._geometry=e.geometry?{geometry:e.geometry}:null,s._optimizedGeomDefinition=i,s.attributes=e.attributes||{},s._layer=t,s._fieldTypesFixed=!1,s}static createFromArcadeDictionary(e,t){const s=new D;return s.attributes=e.field("attributes"),null!==s.attributes&&s.attributes instanceof i?(s.attributes=s.attributes.attributes,null===s.attributes&&(s.attributes={})):s.attributes={},s._geometry=e.field("geometry"),null!==s._geometry&&(s._geometry instanceof i?s._geometry=D.parseGeometryFromDictionary(s._geometry,t):s._geometry instanceof p||(s._geometry=null)),s}static createFromGraphicLikeObject(e,t,i=null,s){const r=new D;return r.contextTimeZone=s??null,null===t&&(t={}),r.attributes=t,r._geometry=null!=e?e:null,r._layer=i,r._layer&&(r._fieldTypesFixed=!1,r.fieldsIndex=this.hydrateFieldsIndex(r._layer)),r}static hydrateFieldsIndex(e){return null===e?null:o(e)?e.getFieldsIndex():e.fieldsIndex?e.fieldsIndex:T.fromLayerJSON({datesInUnknownTimezone:e.datesInUnknownTimezone,fields:e.fields,timeInfo:e.timeInfo,editFieldsInfo:e.editFieldsInfo,dateFieldsTimeReference:e.dateFieldsTimeReference??{timeZone:"UTC",respectsDaylightSaving:!1}})}repurposeFromGraphicLikeObject(e,t,i=null){null===t&&(t={}),this.attributes=t,this._geometry=e??null,this._layer=i,this._layer?this._fieldTypesFixed=!1:this._fieldTypesFixed=!0}castToText(t=!1){let i="";!1===this._fieldTypesFixed&&this._fixFieldTypes();for(const s in this.attributes){""!==i&&(i+=",");const r=this.attributes[s];null==r?i+=JSON.stringify(s)+":null":a(r)||x(r)||F(r)?i+=JSON.stringify(s)+":"+JSON.stringify(r):r instanceof p?i+=JSON.stringify(s)+":"+l(r):r instanceof c||r instanceof m?i+=`${JSON.stringify(s)}:${JSON.stringify(r.toString())}`:r instanceof n||Array.isArray(r)?i+=JSON.stringify(s)+":"+l(r,null,t):r instanceof e?i+=t?JSON.stringify(s)+":"+JSON.stringify(r.getTime()):JSON.stringify(s)+":"+r.stringify():null!==r&&"object"==typeof r&&void 0!==r.castToText&&(i+=JSON.stringify(s)+":"+r.castToText(t))}return'{"geometry":'+(null===this.geometry()?"null":l(this.geometry()))+',"attributes":{'+i+"}}"}_fixFieldTypes(){if(this._fieldsToFixDataTypes&&this._fieldsToFixDataTypes?.length>0)return this._fixAllFields(this._fieldsToFixDataTypes),void(this._fieldTypesFixed=!0);const e=[],t=this._layer.fields;for(let i=0;i<t.length;i++){const s=t[i],{name:r,type:n}=s;switch(n){case"date":case"esriFieldTypeDate":e.push({field:r,dataType:"date"});break;case"date-only":case"esriFieldTypeDateOnly":e.push({field:r,dataType:"date-only"});break;case"time-only":case"esriFieldTypeTimeOnly":e.push({field:r,dataType:"time-only"});break;case"timestamp-offset":case"esriFieldTypeTimestampOffset":e.push({field:r,dataType:"timestamp-offset"})}}this._fieldsToFixDataTypes=e,e.length>0&&this._fixAllFields(e),this._fieldTypesFixed=!0}isUnknownDateTimeField(e){return"unknown"===this.fieldsIndex?.getTimeZone(e)}_fixAllFields(t){this.attributes={...this.attributes};const i=this.contextTimeZone??"system";for(let s=0;s<t.length;s++){const r=t[s].field,n=t[s].dataType;let o=this.attributes[r];if(void 0===o){for(const t in this.attributes)if(t.toLowerCase()===r.toLowerCase()){if(o=this.attributes[t],null!==o){if("time-only"===n){u(o)||(this.attributes[t]=c.fromReader(o.toString()));break}if("date-only"===n){f(o)||(this.attributes[t]=m.fromReader(o.toString()));break}if("timestamp-offset"===n){d(o)||(this.attributes[t]=e.fromReaderAsTimeStampOffset(o.toString()));break}const s=this.isUnknownDateTimeField(t);o instanceof Date?this.attributes[t]=s?e.unknownDateJSToArcadeDate(o):e.dateJSAndZoneToArcadeDate(o,i):d(o)||(this.attributes[t]=s?e.unknownEpochToArcadeDate(o):e.epochToArcadeDate(o,i))}break}}else if(null!==o){if("time-only"===n){u(o)?this.attributes[r]=o:this.attributes[r]=c.fromReader(o.toString());continue}if("date-only"===n){f(o)?this.attributes[r]=o:this.attributes[r]=m.fromReader(o.toString());continue}if("timestamp-offset"===n){d(o)?this.attributes[r]=o:this.attributes[r]=e.fromReaderAsTimeStampOffset(o.toString());continue}const t=this.isUnknownDateTimeField(r);d(o)?this.attributes[r]=o:o instanceof Date?this.attributes[r]=t?e.unknownDateJSToArcadeDate(o):e.dateJSAndZoneToArcadeDate(o,i):this.attributes[r]=t?e.unknownEpochToArcadeDate(o):e.epochToArcadeDate(o,i)}}}geometry(){return null===this._geometry||this._geometry instanceof p||(this._optimizedGeomDefinition?(this._geometry=b(g(this._geometry,this._optimizedGeomDefinition.geometryType,this._optimizedGeomDefinition.hasZ,this._optimizedGeomDefinition.hasM)),this._geometry.spatialReference=this._optimizedGeomDefinition.spatialReference):this._geometry=b(this._geometry)),this._geometry}field(e){this._fieldTypesFixed||this._fixFieldTypes();const t=this.attributes[e];if(void 0!==t)return t;const i=e.toLowerCase();for(const s in this.attributes)if(s.toLowerCase()===i)return this.attributes[s];if(this._hasFieldDefinition(i))return null;throw new s(null,r.FieldNotFound,null,{key:e})}_hasFieldDefinition(e){if(null===this._layer)return!1;for(let t=0;t<this._layer.fields.length;t++){if(this._layer.fields[t].name.toLowerCase()===e)return!0}return!1}setField(t,i){if(this.immutable)throw new s(null,r.Immutable,null);if(i instanceof Date&&(i=this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(i):e.dateJSToArcadeDate(i)),!1===y(i))throw new s(null,r.TypeNotAllowedInFeature,null);const n=t.toLowerCase();if(void 0===this.attributes[t]){for(const e in this.attributes)if(e.toLowerCase()===n)return void(this.attributes[e]=i);this.attributes[t]=i}else this.attributes[t]=i}hasField(e){const t=e.toLowerCase();if(void 0!==this.attributes[e])return!0;for(const i in this.attributes)if(i.toLowerCase()===t)return!0;return!!this._hasFieldDefinition(t)}keys(){let e=[];const t={};for(const i in this.attributes)e.push(i),t[i.toLowerCase()]=1;if(null!==this._layer)for(let i=0;i<this._layer.fields.length;i++){const s=this._layer.fields[i];1!==t[s.name.toLowerCase()]&&e.push(s.name)}return e=e.sort(),e}static parseGeometryFromDictionary(e,t){const i=D._convertDictionaryToJson(e,!0);return void 0!==i.hasm&&(i.hasM=i.hasm,delete i.hasm),void 0!==i.hasz&&(i.hasZ=i.hasz,delete i.hasz),void 0!==i.spatialreference&&(i.spatialReference=i.spatialreference,delete i.spatialreference),i.spatialReference||(i.spatialReference=t),void 0!==i.rings&&(i.rings=this._fixPathArrays(i.rings,!0===i.hasZ,!0===i.hasZ)),void 0!==i.paths&&(i.paths=this._fixPathArrays(i.paths,!0===i.hasZ,!0===i.hasM)),void 0!==i.points&&(i.points=this._fixPointArrays(i.points,!0===i.hasZ,!0===i.hasM)),b(i)}static _fixPathArrays(e,t,i){const s=[];if(Array.isArray(e))for(let r=0;r<e.length;r++)s.push(this._fixPointArrays(e[r],t,i));else if(e instanceof n)for(let r=0;r<e.length();r++)s.push(this._fixPointArrays(e.get(r),t,i));return s}static _fixPointArrays(e,t,i){const s=[];if(Array.isArray(e))for(let r=0;r<e.length;r++){const o=e[r];o instanceof _?t&&i?s.push([o.x,o.y,o.z,o.m]):t?s.push([o.x,o.y,o.z]):i?s.push([o.x,o.y,o.m]):s.push([o.x,o.y]):o instanceof n?s.push(o.toArray()):s.push(o)}else if(e instanceof n)for(let r=0;r<e.length();r++){const o=e.get(r);o instanceof _?t&&i?s.push([o.x,o.y,o.z,o.m]):t?s.push([o.x,o.y,o.z]):i?s.push([o.x,o.y,o.m]):s.push([o.x,o.y]):o instanceof n?s.push(o.toArray()):s.push(o)}return s}static _convertDictionaryToJson(e,t=!1){const s={};for(const r in e.attributes){let n=e.attributes[r];n instanceof i&&(n=D._convertDictionaryToJson(n)),t?s[r.toLowerCase()]=n:s[r]=n}return s}static parseAttributesFromDictionary(e){const t={};for(const i in e.attributes){const n=e.attributes[i];if(!y(n))throw new s(null,r.InvalidParameter,null);t[i]=n}return t}static fromJson(e,t){let i=null;null!==e.geometry&&void 0!==e.geometry&&(i=b(e.geometry));const n={};if(null!==e.attributes&&void 0!==e.attributes)for(const o in e.attributes){const t=e.attributes[o];if(null===t)n[o]=t;else{if(!(F(t)||x(t)||a(t)||d(t)||u(t)||f(t)))throw new s(null,r.InvalidParameter,null);n[o]=t}}return D.createFromGraphicLikeObject(i,n,null,t??null)}fullSchema(){return this._layer}gdbVersion(){if(null===this._layer)return"";const e=this._layer.gdbVersion;return void 0===e?"":""===e&&this._layer.capabilities?.isVersioned?"SDE.DEFAULT":e}castAsJson(e){const t={attributes:{},geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null};for(const i in this.attributes){const s=this.attributes[i];void 0!==s&&(t.attributes[i]=h(s,e))}return t}async castAsJsonAsync(e=null,t){return this.castAsJson(t)}}t(D);export{D as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{toSymbolId as e}from"./arcadeEnvironment.js";import{ArcadeModule as t}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import{getNestedOptionalValue as r,geometryMember as o}from"./containerUtils.js";import a from"./Dictionary.js";import{ArcadeExecutionError as i,ExecutionErrorCodes as l,ensureArcadeExecutionError as s}from"./executionError.js";import c from"./Feature.js";import{NativeFunction as u,ScopeMarshalledFunction as f,ArcadeFunction as p,wrapModuleScopedResponse as w}from"./FunctionWrapper.js";import{G as d,a as h,E as g,i as m,c as y,z as v,o as b,b as S,g as x,r as F,q as I,j as M,D as C,F as R,R as k,I as A,A as N,B as O,x as E,C as j,u as B}from"../chunks/languageUtils.js";import{addFunctionDeclaration as K}from"./treeAnalysis.js";import{A as L}from"../chunks/array.js";import{registerFunctions as U}from"./functions/date.js";import{registerFunctions as D}from"./functions/geomasync.js";import{registerFunctions as G}from"./functions/geometry.js";import{registerFunctions as Z}from"./functions/maths.js";import{registerFunctions as q}from"./functions/stats.js";import{registerFunctions as P}from"./functions/string.js";import W from"../geometry/Geometry.js";import T from"../geometry/SpatialReference.js";async function V(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(await J(e,t.arguments[r]));return n}async function _(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await V(e,t))}class z extends p{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 i(e,l.MaximumCallDepth,null);return Ae(this.definition,n,t,null)}}call(e,t){return H(e,t,((n,r,o)=>{const a={spatialReference:e.spatialReference,services:e.services,console:e.console,libraryResolver:e.libraryResolver,exports:e.exports,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:{},abortSignal:e.abortSignal,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1}};if(a.depthCounter.depth>64)throw new i(e,l.MaximumCallDepth,t);return Ae(this.definition,a,o,t)}))}marshalledCall(e,t,n,r){return r(e,t,(async(o,a,i)=>{const l={spatialReference:e.spatialReference,globalScope:n.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,abortSignal:e.abortSignal,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:{}};return i=i.map((t=>!m(t)||t instanceof f?t:w(t,e,r))),w(await Ae(this.definition,l,i,t),n,r)}))}}class Y extends t{constructor(e){super(),this.source=e}async global(e){const t=this.executingContext.globalScope[e.toLowerCase()];if(t.valueset||(t.value=await J(this.executingContext,t.node),t.valueset=!0),m(t.value)&&!(t.value instanceof f)){const e=new f;e.fn=t.value,e.parameterEvaluator=H,e.context=this.executingContext,t.value=e}return t.value}setGlobal(e,t){if(m(t))throw new i(null,l.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 t=e.spatialReference;null==t&&(t=new T({wkid:102100})),this.moduleScope=Ee({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:t,services:e.services,libraryResolver:new n(e.libraryResolver._moduleSingletons,this.source.syntax.loadedModules),exports:{},abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,globalScope:this.moduleScope,console:e.console??je,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:null,depthCounter:{depth:1}},await ue(this.executingContext,this.source.syntax)}}async function H(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await V(e,t))}async function J(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"UpdateExpression":return await ae(e,t);case"AssignmentExpression":return await le(e,t);case"TemplateLiteral":return await Me(e,t);case"Identifier":return await Fe(e,t);case"MemberExpression":return await ye(e,t);case"Literal":return t.value;case"CallExpression":return await Ie(e,t);case"UnaryExpression":return await ve(e,t);case"BinaryExpression":return await Se(e,t);case"LogicalExpression":return await xe(e,t);case"ArrayExpression":return await be(e,t);case"ObjectExpression":return await X(e,t);default:throw new i(e,l.Unrecognized,t)}}catch(n){throw s(e,t,n)}}async function Q(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"ImportDeclaration":return await de(e,t);case"ExportNamedDeclaration":return await he(e,t);case"VariableDeclaration":return await ge(e,t,0);case"BlockStatement":return await ue(e,t);case"FunctionDeclaration":return await we(e,t);case"ReturnStatement":return await pe(e,t);case"IfStatement":return await ce(e,t);case"ExpressionStatement":return await se(e,t);case"ForStatement":return await ee(e,t);case"WhileStatement":return await $(e,t);case"ForInStatement":return await oe(e,t);case"BreakStatement":return N;case"EmptyStatement":return v;case"ContinueStatement":return O;default:throw new i(e,l.Unrecognized,t)}}catch(n){throw s(e,t,n)}}async function X(e,t){const n=[];for(let a=0;a<t.properties.length;a++){const r=t.properties[a],o=await J(e,r.value),i="Identifier"===r.key.type?r.key.name:await J(e,r.key);n[a]={key:i,value:o}}const r={},o=new Map;for(let a=0;a<n.length;a++){const s=n[a];if(m(s.value))throw new i(e,l.NoFunctionInDictionary,t);if(!1===y(s.key))throw new i(e,l.KeyMustBeString,t);let c=s.key.toString();const u=c.toLowerCase();o.has(u)?c=o.get(u):o.set(u,c),s.value===v?r[c]=null:r[c]=s.value}const s=new a(r);return s.immutable=!1,s}async function $(e,t){let n=await J(e,t.test);if(!1===n)return v;if(!0!==n)throw new i(e,l.BooleanConditionRequired,t);for(;!0===n;){const r=await Q(e,t.body);if(r===N)break;if(r instanceof k)return r;if(n=await J(e,t.test),!0!==n&&!1!==n)throw new i(e,l.BooleanConditionRequired,t)}return v}async function ee(e,t){try{for(null!==t.init&&("VariableDeclaration"===t.init.type?await Q(e,t.init):await J(e,t.init));;){if(null!==t.test){const n=await J(e,t.test);if(!0===e.abortSignal?.aborted)throw new i(e,l.Cancelled,t);if(!1===n)break;if(!0!==n)throw new i(e,l.BooleanConditionRequired,t)}const n=await Q(e,t.body);if(n===N)break;if(n instanceof k)return n;null!==t.update&&await J(e,t.update)}return v}catch(n){throw n}}async function te(e,t,n,r,o="i"){const a=n.length;for(let i=0;i<a;i++){r.value="k"===o?n[i]:i;const a=await Q(e,t.body);if(a===N)break;if(a instanceof k)return a}return v}async function ne(e,t,n,r,o="i"){const a=n.length();for(let i=0;i<a;i++){r.value="k"===o?n.get(i):i;const a=await Q(e,t.body);if(a===N)break;if(a instanceof k)return a}return v}async function re(e,t,n,r){const o=n.iterator(e.abortSignal);let a;for(;null!=(a=await o.next());){const o=c.createFromGraphicLikeObject(a.geometry,a.attributes,n,e.timeZone);o._underlyingGraphic=a,r.value=o;const i=await Q(e,t.body);if(i===N)break;if(i instanceof k)return i}return v}async function oe(t,n){const r=await J(t,n.right);"VariableDeclaration"===n.left.type&&await Q(t,n.left);const o=e("VariableDeclaration"===n.left.type?n.left.declarations[0].id:n.left);let s=null;if(null!=t.localScope&&void 0!==t.localScope[o]&&(s=t.localScope[o]),null===s&&void 0!==t.globalScope[o]&&(s=t.globalScope[o]),null===s)throw new i(t,l.InvalidIdentifier,n);return b(r)||y(r)?await te(t,n,r,s):I(r)?await ne(t,n,r,s):r instanceof a||F(r)?await te(t,n,r.keys(),s,"k"):B(r)?await re(t,n,r,s):v}async function ae(t,n){const r=n.argument;if("CallExpression"===r.type)throw new i(t,l.NeverReach,n);if("MemberExpression"===r.type){const e=await J(t,r.object);let o,s;if(!0===r.computed)o=await J(t,r.property);else{if("Identifier"!==r.property.type)throw new i(t,l.Unrecognized,n);o=r.property.name}if(b(e)){if(!S(o))throw new i(t,l.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>=e.length)throw new i(t,l.OutOfBounds,n);s=x(e[o]),e[o]="++"===n.operator?s+1:s-1}else if(e instanceof a){if(!1===y(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new i(t,l.FieldNotFound,n,{key:o});s=x(e.field(o)),e.setField(o,"++"===n.operator?s+1:s-1)}else if(e instanceof Y){if(!1===y(o))throw new i(t,l.ModuleAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new i(t,l.ModuleExportNotFound,n);s=x(await e.global(o)),e.setGlobal(o,"++"===n.operator?s+1:s-1)}else{if(!F(e))throw I(e)?new i(t,l.Immutable,n):new i(t,l.InvalidParameter,n);if(!1===y(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new i(t,l.FieldNotFound,n,{key:o});s=x(e.field(o)),e.setField(o,"++"===n.operator?s+1:s-1)}return!1===n.prefix?s:"++"===n.operator?s+1:s-1}const o=e(r);let s;if(null!=t.localScope&&void 0!==t.localScope[o])return s=x(t.localScope[o].value),t.localScope[o]={value:"++"===n.operator?s+1:s-1,valueset:!0,node:n},!1===n.prefix?s:"++"===n.operator?s+1:s-1;if(void 0!==t.globalScope[o])return s=x(t.globalScope[o].value),t.globalScope[o]={value:"++"===n.operator?s+1:s-1,valueset:!0,node:n},!1===n.prefix?s:"++"===n.operator?s+1:s-1;throw new i(t,l.InvalidIdentifier,n)}function ie(e,t,n,r,o){switch(t){case"=":return e===v?null:e;case"/=":return x(n)/x(e);case"*=":return x(n)*x(e);case"-=":return x(n)-x(e);case"+=":return y(n)||y(e)?M(n)+M(e):x(n)+x(e);case"%=":return x(n)%x(e);default:throw new i(o,l.UnsupportedOperator,r)}}async function le(t,n){const r=n.left;if("MemberExpression"===r.type){const e=await J(t,r.object);let o;if(!0===r.computed)o=await J(t,r.property);else{if("Identifier"!==r.property.type)throw new i(t,l.InvalidIdentifier,n);o=r.property.name}const s=await J(t,n.right);if(b(e)){if(!S(o))throw new i(t,l.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>e.length)throw new i(t,l.OutOfBounds,n);if(o===e.length){if("="!==n.operator)throw new i(t,l.OutOfBounds,n);e[o]=ie(s,n.operator,e[o],n,t)}else e[o]=ie(s,n.operator,e[o],n,t)}else if(e instanceof a){if(!1===y(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0===e.hasField(o))e.setField(o,ie(s,n.operator,e.field(o),n,t));else{if("="!==n.operator)throw new i(t,l.FieldNotFound,n,{key:o});e.setField(o,ie(s,n.operator,null,n,t))}}else if(e instanceof Y){if(!1===y(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new i(t,l.ModuleExportNotFound,n);e.setGlobal(o,ie(s,n.operator,await e.global(o),n,t))}else{if(!F(e))throw I(e)?new i(t,l.Immutable,n):new i(t,l.InvalidParameter,n);if(!1===y(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0===e.hasField(o))e.setField(o,ie(s,n.operator,e.field(o),n,t));else{if("="!==n.operator)throw new i(t,l.FieldNotFound,n,{key:o});e.setField(o,ie(s,n.operator,null,n,t))}}return v}const o=e(r);if(null!=t.localScope&&void 0!==t.localScope[o]){const e=await J(t,n.right);return t.localScope[o]={value:ie(e,n.operator,t.localScope[o].value,n,t),valueset:!0,node:n.right},v}if(void 0!==t.globalScope[o]){const e=await J(t,n.right);return t.globalScope[o]={value:ie(e,n.operator,t.globalScope[o].value,n,t),valueset:!0,node:n.right},v}throw new i(t,l.InvalidIdentifier,n)}async function se(e,t){const n=await J(e,t.expression);return n===v?v:new A(n)}async function ce(e,t){const n=await J(e,t.test);if(!0===n)return Q(e,t.consequent);if(!1===n)return null!==t.alternate?Q(e,t.alternate):v;throw new i(e,l.BooleanConditionRequired,t)}async function ue(e,t){return fe(e,t,0)}async function fe(e,t,n){if(n>=t.body.length)return v;const r=await Q(e,t.body[n]);return r instanceof k||r===N||r===O||n===t.body.length-1?r:fe(e,t,n+1)}async function pe(e,t){if(null===t.argument)return new k(v);const n=await J(e,t.argument);return new k(n)}async function we(t,n){const r=e(n.id);return t.globalScope[r]={valueset:!0,node:null,value:new z(n,t)},v}async function de(t,n){const r=e(n.specifiers[0].local),o=t.libraryResolver.loadLibrary(r);let a;return t.libraryResolver._moduleSingletons?.has(o.uri)?a=t.libraryResolver._moduleSingletons.get(o.uri):(a=new Y(o),await a.loadModule(t),t.libraryResolver._moduleSingletons?.set(o.uri,a)),t.globalScope[r]={value:a,valueset:!0,node:n},v}async function he(t,n){if(await Q(t,n.declaration),"FunctionDeclaration"===n.declaration.type)t.exports[e(n.declaration.id)]="function";else if("VariableDeclaration"===n.declaration.type)for(const r of n.declaration.declarations)t.exports[e(r.id)]="variable";return v}async function ge(e,t,n){return n>=t.declarations.length?v:(await me(e,t.declarations[n]),n===t.declarations.length-1||await ge(e,t,n+1),v)}async function me(t,n){let r=null;if(r=null===n.init?null:await J(t,n.init),null!==t.localScope){if(r===v&&(r=null),"Identifier"!==n.id.type)throw new i(t,l.InvalidIdentifier,n);const o=e(n.id);return void(null!=t.localScope&&(t.localScope[o]={value:r,valueset:!0,node:n.init}))}if("Identifier"!==n.id.type)throw new i(t,l.InvalidIdentifier,n);const o=e(n.id);r===v&&(r=null),t.globalScope[o]={value:r,valueset:!0,node:n.init}}async function ye(e,t){const n=await J(e,t.object);if(null===n)throw new i(e,l.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(n instanceof a||F(n))return n.field(t.property.name);if(n instanceof W)return o(n,t.property.name,e,t);if(n instanceof Y){if(!n.hasGlobal(t.property.name))throw new i(e,l.InvalidIdentifier,t);return n.global(t.property.name)}throw new i(e,l.InvalidMemberAccessKey,t)}throw new i(e,l.InvalidMemberAccessKey,t)}let r=await J(e,t.property);if(n instanceof a||F(n)){if(y(r))return n.field(r);throw new i(e,l.InvalidMemberAccessKey,t)}if(n instanceof Y){if(y(r))return n.global(r);throw new i(e,l.InvalidMemberAccessKey,t)}if(n instanceof W){if(y(r))return o(n,r,e,t);throw new i(e,l.InvalidMemberAccessKey,t)}if(b(n)){if(S(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new i(e,l.OutOfBounds,t);return n[r]}throw new i(e,l.InvalidMemberAccessKey,t)}if(I(n)){if(S(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length()+r),r>=n.length()||r<0)throw new i(e,l.OutOfBounds,t);return n.get(r)}throw new i(e,l.InvalidMemberAccessKey,t)}if(y(n)){if(S(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new i(e,l.OutOfBounds,t);return n[r]}throw new i(e,l.InvalidMemberAccessKey,t)}throw new i(e,l.InvalidMemberAccessKey,t)}async function ve(e,t){const n=await J(e,t.argument);if(h(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*x(n);if("+"===t.operator)return 1*x(n);if("~"===t.operator)return~x(n);throw new i(e,l.UnsupportedUnaryOperator,t)}if("-"===t.operator)return-1*x(n);if("+"===t.operator)return 1*x(n);if("~"===t.operator)return~x(n);throw new i(e,l.UnsupportedUnaryOperator,t)}async function be(e,t){const n=[];for(let r=0;r<t.elements.length;r++)n.push(await J(e,t.elements[r]));for(let r=0;r<n.length;r++){if(m(n[r]))throw new i(e,l.NoFunctionInArray,t);n[r]===v&&(n[r]=null)}return n}async function Se(e,t){const n=await J(e,t.left),r=await J(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return R(x(n),x(r),t.operator);case"==":return g(n,r);case"!=":return!g(n,r);case"<":case">":case"<=":case">=":return C(n,r,t.operator);case"+":return y(n)||y(r)?M(n)+M(r):x(n)+x(r);case"-":return x(n)-x(r);case"*":return x(n)*x(r);case"/":return x(n)/x(r);case"%":return x(n)%x(r);default:throw new i(e,l.UnsupportedOperator,t)}}async function xe(e,t){const n=await J(e,t.left);if(!h(n))throw new i(e,l.LogicalExpressionOnlyBoolean,t);switch(t.operator){case"||":{if(!0===n)return n;const r=await J(e,t.right);if(h(r))return r;throw new i(e,l.LogicExpressionOrAnd,t)}case"&&":{if(!1===n)return n;const r=await J(e,t.right);if(h(r))return r;throw new i(e,l.LogicExpressionOrAnd,t)}default:throw new i(e,l.LogicExpressionOrAnd,t)}}async function Fe(t,n){const r=e(n);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];if(!0===e.valueset)return e.value;if(null!==e.d)return e.d;e.d=J(t,e.node);const n=await e.d;return e.value=n,e.valueset=!0,n}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];if(!0===e.valueset)return e.value;if(null!==e.d)return e.d;e.d=J(t,e.node);const n=await e.d;return e.value=n,e.valueset=!0,n}throw new i(t,l.InvalidIdentifier,n)}async function Ie(t,n){if("MemberExpression"===n.callee.type){const e=await J(t,n.callee.object);if(!(e instanceof Y))throw new i(t,l.FunctionNotFound,n);const r=!1===n.callee.computed?n.callee.property.name:await J(t,n.callee.property);if(!e.hasGlobal(r))throw new i(t,l.FunctionNotFound,n);const o=await e.global(r);if(!m(o))throw new i(t,l.CallNonFunction,n);return o.call(t,n)}if("Identifier"!==n.callee.type)throw new i(t,l.FunctionNotFound,n);const r=e(n.callee);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];if(m(e.value))return e.value.call(t,n);throw new i(t,l.CallNonFunction,n)}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];if(m(e.value))return e.value.call(t,n);throw new i(t,l.CallNonFunction,n)}throw new i(t,l.FunctionNotFound,n)}async function Me(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){if(t.expressions[r]){const o=await J(e,t.expressions[r]);if(m(o))throw new i(e,l.NoFunctionInTemplateLiteral,t);n+=M(o)}r++}return n}const Ce={};async function Re(e,t,n,r){const o=await J(e,t.arguments[n]);if(g(o,r))return J(e,t.arguments[n+1]);const a=t.arguments.length-n;return 1===a?J(e,t.arguments[n]):2===a?null:3===a?J(e,t.arguments[n+2]):Re(e,t,n+2,r)}async function ke(e,t,n,r){if(!0===r)return J(e,t.arguments[n+1]);if(3===t.arguments.length-n)return J(e,t.arguments[n+2]);const o=await J(e,t.arguments[n+2]);if(!1===h(o))throw new i(e,l.ModuleExportNotFound,t.arguments[n+2]);return ke(e,t,n+2,o)}async function Ae(t,n,r,o){const a=t.body;if(r.length!==t.params.length)throw new i(n,l.WrongNumberOfParameters,null);for(let i=0;i<r.length;i++){const o=t.params[i];"Identifier"===o.type&&null!=n.localScope&&(n.localScope[e(o)]={d:null,value:r[i],valueset:!0,node:null})}const s=await Q(n,a);if(s instanceof k)return s.value;if(s===N)throw new i(n,l.UnexpectedToken,o);if(s===O)throw new i(n,l.UnexpectedToken,o);return s instanceof A?s.value:s}U(Ce,_),P(Ce,_),Z(Ce,_),G(Ce,_),q(Ce,_),D({functions:Ce,compiled:!1,signatures:null,evaluateIdentifier:null,mode:"async",standardFunction:_,standardFunctionAsync:H}),Ce.iif=async function(e,t){d(null===t.arguments?[]:t.arguments,3,3,e,t);const n=await J(e,t.arguments[0]);if(!1===h(n))throw new i(e,l.BooleanConditionRequired,t);return J(e,n?t.arguments[1]:t.arguments[2])},Ce.defaultvalue=async function(e,t){d(null===t.arguments?[]:t.arguments,2,3,e,t);const n=await J(e,t.arguments[0]);if(3===t.arguments.length){const o=await J(e,t.arguments[1]),a=r(n,o);return null!=a&&""!==a?a:J(e,t.arguments[2])}return null==n||""===n?J(e,t.arguments[1]):n},Ce.decode=async function(e,t){if(t.arguments.length<2)throw new i(e,l.WrongNumberOfParameters,t);if(2===t.arguments.length)return J(e,t.arguments[1]);if((t.arguments.length-1)%2==0)throw new i(e,l.WrongNumberOfParameters,t);return Re(e,t,1,await J(e,t.arguments[0]))},Ce.when=async function(e,t){if(t.arguments.length<3)throw new i(e,l.WrongNumberOfParameters,t);if(t.arguments.length%2==0)throw new i(e,l.WrongNumberOfParameters,t);const n=await J(e,t.arguments[0]);if(!1===h(n))throw new i(e,l.BooleanConditionRequired,t.arguments[0]);return ke(e,t,0,n)};const Ne={fixSpatialReference:E,parseArguments:V,standardFunction:_,standardFunctionAsync:H,evaluateIdentifier:Fe};for(const Ue in Ce)Ce[Ue]={value:new u(Ce[Ue]),valueset:!0,node:null};const Oe=function(){};function Ee(e,t,n){const r=new Oe;null==e&&(e={}),null==t&&(t={});const o=new a({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});o.immutable=!1,r.textformatting={value:o,valueset:!0,node:null};for(const a in t)r[a]={value:new u(t[a]),native:!0,valueset:!0,node:null};for(const a in e)r[a]={value:j(e[a])?c.createFromGraphic(e[a],n):e[a],valueset:!0,node:null};return r}function je(e){console.log(e)}Oe.prototype=Ce,Oe.prototype.infinity={value:Number.POSITIVE_INFINITY,valueset:!0,node:null},Oe.prototype.pi={value:Math.PI,valueset:!0,node:null};const Be=Ne;function Ke(e){const t={mode:"async",compiled:!1,functions:{},signatures:[],standardFunction:_,standardFunctionAsync:H,evaluateIdentifier:Fe};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)Ce[n]={value:new u(t.functions[n]),valueset:!0,node:null},Oe.prototype[n]=Ce[n];for(let n=0;n<t.signatures.length;n++)K(t.signatures[n],"async")}async function Le(e,t){let r=t.spatialReference;null==r&&(r=new T({wkid:102100}));let o=null;e.usesModules&&(o=new n(new Map,e.loadedModules));const a=Ee(t.vars,t.customfunctions,t.timeZone),s={spatialReference:r,services:t.services,exports:{},libraryResolver:o,abortSignal:void 0===t.abortSignal||null===t.abortSignal?{aborted:!1}:t.abortSignal,globalScope:a,console:t.console??je,timeZone:t.timeZone??null,lrucache:t.lrucache,interceptor:t.interceptor,localScope:null,depthCounter:{depth:1}},c=await ue(s,e);if(c instanceof k||c instanceof A){const e=c.value;if(e===v)return null;if(m(e))throw new i(s,l.IllegalResult,null);return e}if(c===v)return null;if(c===N)throw new i(s,l.IllegalResult,null);if(c===O)throw new i(s,l.IllegalResult,null);throw new i(s,l.NeverReach,null)}Ke([L]);export{Le as executeScript,Ke as extend,Be as functionHelper};
|
|
5
|
+
import{toSymbolId as e}from"./arcadeEnvironment.js";import{ArcadeModule as t}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import{getNestedOptionalValue as r,geometryMember as o}from"./containerUtils.js";import a from"./Dictionary.js";import{ArcadeExecutionError as i,ExecutionErrorCodes as l,ensureArcadeExecutionError as s}from"./executionError.js";import c from"./Feature.js";import{NativeFunction as u,ScopeMarshalledFunction as f,ArcadeFunction as p,wrapModuleScopedResponse as w}from"./FunctionWrapper.js";import{D as d,a as h,B as g,i as m,x as y,m as v,e as b,p as S,o as x,g as F,A as I,C as M,R as C,I as R,y as k,z as A,v as N,r as O}from"../chunks/languageUtils.js";import{addFunctionDeclaration as E}from"./treeAnalysis.js";import{A as j}from"../chunks/array.js";import{registerFunctions as B}from"./functions/date.js";import{registerFunctions as K}from"./functions/geomasync.js";import{registerFunctions as L}from"./functions/geometry.js";import{registerFunctions as U}from"./functions/maths.js";import{registerFunctions as D}from"./functions/stats.js";import{registerFunctions as Z}from"./functions/string.js";import G from"../geometry/Geometry.js";import q from"../geometry/SpatialReference.js";import{isString as P,isNumber as W,isGraphic as T}from"../support/guards.js";async function V(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(await J(e,t.arguments[r]));return n}async function _(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await V(e,t))}class z extends p{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 i(e,l.MaximumCallDepth,null);return Ae(this.definition,n,t,null)}}call(e,t){return H(e,t,((n,r,o)=>{const a={spatialReference:e.spatialReference,services:e.services,console:e.console,libraryResolver:e.libraryResolver,exports:e.exports,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:{},abortSignal:e.abortSignal,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1}};if(a.depthCounter.depth>64)throw new i(e,l.MaximumCallDepth,t);return Ae(this.definition,a,o,t)}))}marshalledCall(e,t,n,r){return r(e,t,(async(o,a,i)=>{const l={spatialReference:e.spatialReference,globalScope:n.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,abortSignal:e.abortSignal,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:{}};return i=i.map((t=>!m(t)||t instanceof f?t:w(t,e,r))),w(await Ae(this.definition,l,i,t),n,r)}))}}class Y extends t{constructor(e){super(),this.source=e}async global(e){const t=this.executingContext.globalScope[e.toLowerCase()];if(t.valueset||(t.value=await J(this.executingContext,t.node),t.valueset=!0),m(t.value)&&!(t.value instanceof f)){const e=new f;e.fn=t.value,e.parameterEvaluator=H,e.context=this.executingContext,t.value=e}return t.value}setGlobal(e,t){if(m(t))throw new i(null,l.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 t=e.spatialReference;null==t&&(t=new q({wkid:102100})),this.moduleScope=Ee({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:t,services:e.services,libraryResolver:new n(e.libraryResolver._moduleSingletons,this.source.syntax.loadedModules),exports:{},abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,globalScope:this.moduleScope,console:e.console??je,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:null,depthCounter:{depth:1}},await ue(this.executingContext,this.source.syntax)}}async function H(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await V(e,t))}async function J(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"UpdateExpression":return await ae(e,t);case"AssignmentExpression":return await le(e,t);case"TemplateLiteral":return await Me(e,t);case"Identifier":return await Fe(e,t);case"MemberExpression":return await ye(e,t);case"Literal":return t.value;case"CallExpression":return await Ie(e,t);case"UnaryExpression":return await ve(e,t);case"BinaryExpression":return await Se(e,t);case"LogicalExpression":return await xe(e,t);case"ArrayExpression":return await be(e,t);case"ObjectExpression":return await X(e,t);default:throw new i(e,l.Unrecognized,t)}}catch(n){throw s(e,t,n)}}async function Q(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"ImportDeclaration":return await de(e,t);case"ExportNamedDeclaration":return await he(e,t);case"VariableDeclaration":return await ge(e,t,0);case"BlockStatement":return await ue(e,t);case"FunctionDeclaration":return await we(e,t);case"ReturnStatement":return await pe(e,t);case"IfStatement":return await ce(e,t);case"ExpressionStatement":return await se(e,t);case"ForStatement":return await ee(e,t);case"WhileStatement":return await $(e,t);case"ForInStatement":return await oe(e,t);case"BreakStatement":return k;case"EmptyStatement":return y;case"ContinueStatement":return A;default:throw new i(e,l.Unrecognized,t)}}catch(n){throw s(e,t,n)}}async function X(e,t){const n=[];for(let a=0;a<t.properties.length;a++){const r=t.properties[a],o=await J(e,r.value),i="Identifier"===r.key.type?r.key.name:await J(e,r.key);n[a]={key:i,value:o}}const r={},o=new Map;for(let a=0;a<n.length;a++){const s=n[a];if(m(s.value))throw new i(e,l.NoFunctionInDictionary,t);if(!1===P(s.key))throw new i(e,l.KeyMustBeString,t);let c=s.key.toString();const u=c.toLowerCase();o.has(u)?c=o.get(u):o.set(u,c),s.value===y?r[c]=null:r[c]=s.value}const s=new a(r);return s.immutable=!1,s}async function $(e,t){let n=await J(e,t.test);if(!1===n)return y;if(!0!==n)throw new i(e,l.BooleanConditionRequired,t);for(;!0===n;){const r=await Q(e,t.body);if(r===k)break;if(r instanceof C)return r;if(n=await J(e,t.test),!0!==n&&!1!==n)throw new i(e,l.BooleanConditionRequired,t)}return y}async function ee(e,t){try{for(null!==t.init&&("VariableDeclaration"===t.init.type?await Q(e,t.init):await J(e,t.init));;){if(null!==t.test){const n=await J(e,t.test);if(!0===e.abortSignal?.aborted)throw new i(e,l.Cancelled,t);if(!1===n)break;if(!0!==n)throw new i(e,l.BooleanConditionRequired,t)}const n=await Q(e,t.body);if(n===k)break;if(n instanceof C)return n;null!==t.update&&await J(e,t.update)}return y}catch(n){throw n}}async function te(e,t,n,r,o="i"){const a=n.length;for(let i=0;i<a;i++){r.value="k"===o?n[i]:i;const a=await Q(e,t.body);if(a===k)break;if(a instanceof C)return a}return y}async function ne(e,t,n,r,o="i"){const a=n.length();for(let i=0;i<a;i++){r.value="k"===o?n.get(i):i;const a=await Q(e,t.body);if(a===k)break;if(a instanceof C)return a}return y}async function re(e,t,n,r){const o=n.iterator(e.abortSignal);let a;for(;null!=(a=await o.next());){const o=c.createFromGraphicLikeObject(a.geometry,a.attributes,n,e.timeZone);o._underlyingGraphic=a,r.value=o;const i=await Q(e,t.body);if(i===k)break;if(i instanceof C)return i}return y}async function oe(t,n){const r=await J(t,n.right);"VariableDeclaration"===n.left.type&&await Q(t,n.left);const o=e("VariableDeclaration"===n.left.type?n.left.declarations[0].id:n.left);let s=null;if(null!=t.localScope&&void 0!==t.localScope[o]&&(s=t.localScope[o]),null===s&&void 0!==t.globalScope[o]&&(s=t.globalScope[o]),null===s)throw new i(t,l.InvalidIdentifier,n);return v(r)||P(r)?await te(t,n,r,s):x(r)?await ne(t,n,r,s):r instanceof a||S(r)?await te(t,n,r.keys(),s,"k"):O(r)?await re(t,n,r,s):y}async function ae(t,n){const r=n.argument;if("CallExpression"===r.type)throw new i(t,l.NeverReach,n);if("MemberExpression"===r.type){const e=await J(t,r.object);let o,s;if(!0===r.computed)o=await J(t,r.property);else{if("Identifier"!==r.property.type)throw new i(t,l.Unrecognized,n);o=r.property.name}if(v(e)){if(!W(o))throw new i(t,l.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>=e.length)throw new i(t,l.OutOfBounds,n);s=b(e[o]),e[o]="++"===n.operator?s+1:s-1}else if(e instanceof a){if(!1===P(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new i(t,l.FieldNotFound,n,{key:o});s=b(e.field(o)),e.setField(o,"++"===n.operator?s+1:s-1)}else if(e instanceof Y){if(!1===P(o))throw new i(t,l.ModuleAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new i(t,l.ModuleExportNotFound,n);s=b(await e.global(o)),e.setGlobal(o,"++"===n.operator?s+1:s-1)}else{if(!S(e))throw x(e)?new i(t,l.Immutable,n):new i(t,l.InvalidParameter,n);if(!1===P(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new i(t,l.FieldNotFound,n,{key:o});s=b(e.field(o)),e.setField(o,"++"===n.operator?s+1:s-1)}return!1===n.prefix?s:"++"===n.operator?s+1:s-1}const o=e(r);let s;if(null!=t.localScope&&void 0!==t.localScope[o])return s=b(t.localScope[o].value),t.localScope[o]={value:"++"===n.operator?s+1:s-1,valueset:!0,node:n},!1===n.prefix?s:"++"===n.operator?s+1:s-1;if(void 0!==t.globalScope[o])return s=b(t.globalScope[o].value),t.globalScope[o]={value:"++"===n.operator?s+1:s-1,valueset:!0,node:n},!1===n.prefix?s:"++"===n.operator?s+1:s-1;throw new i(t,l.InvalidIdentifier,n)}function ie(e,t,n,r,o){switch(t){case"=":return e===y?null:e;case"/=":return b(n)/b(e);case"*=":return b(n)*b(e);case"-=":return b(n)-b(e);case"+=":return P(n)||P(e)?F(n)+F(e):b(n)+b(e);case"%=":return b(n)%b(e);default:throw new i(o,l.UnsupportedOperator,r)}}async function le(t,n){const r=n.left;if("MemberExpression"===r.type){const e=await J(t,r.object);let o;if(!0===r.computed)o=await J(t,r.property);else{if("Identifier"!==r.property.type)throw new i(t,l.InvalidIdentifier,n);o=r.property.name}const s=await J(t,n.right);if(v(e)){if(!W(o))throw new i(t,l.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>e.length)throw new i(t,l.OutOfBounds,n);if(o===e.length){if("="!==n.operator)throw new i(t,l.OutOfBounds,n);e[o]=ie(s,n.operator,e[o],n,t)}else e[o]=ie(s,n.operator,e[o],n,t)}else if(e instanceof a){if(!1===P(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0===e.hasField(o))e.setField(o,ie(s,n.operator,e.field(o),n,t));else{if("="!==n.operator)throw new i(t,l.FieldNotFound,n,{key:o});e.setField(o,ie(s,n.operator,null,n,t))}}else if(e instanceof Y){if(!1===P(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new i(t,l.ModuleExportNotFound,n);e.setGlobal(o,ie(s,n.operator,await e.global(o),n,t))}else{if(!S(e))throw x(e)?new i(t,l.Immutable,n):new i(t,l.InvalidParameter,n);if(!1===P(o))throw new i(t,l.KeyAccessorMustBeString,n);if(!0===e.hasField(o))e.setField(o,ie(s,n.operator,e.field(o),n,t));else{if("="!==n.operator)throw new i(t,l.FieldNotFound,n,{key:o});e.setField(o,ie(s,n.operator,null,n,t))}}return y}const o=e(r);if(null!=t.localScope&&void 0!==t.localScope[o]){const e=await J(t,n.right);return t.localScope[o]={value:ie(e,n.operator,t.localScope[o].value,n,t),valueset:!0,node:n.right},y}if(void 0!==t.globalScope[o]){const e=await J(t,n.right);return t.globalScope[o]={value:ie(e,n.operator,t.globalScope[o].value,n,t),valueset:!0,node:n.right},y}throw new i(t,l.InvalidIdentifier,n)}async function se(e,t){const n=await J(e,t.expression);return n===y?y:new R(n)}async function ce(e,t){const n=await J(e,t.test);if(!0===n)return Q(e,t.consequent);if(!1===n)return null!==t.alternate?Q(e,t.alternate):y;throw new i(e,l.BooleanConditionRequired,t)}async function ue(e,t){return fe(e,t,0)}async function fe(e,t,n){if(n>=t.body.length)return y;const r=await Q(e,t.body[n]);return r instanceof C||r===k||r===A||n===t.body.length-1?r:fe(e,t,n+1)}async function pe(e,t){if(null===t.argument)return new C(y);const n=await J(e,t.argument);return new C(n)}async function we(t,n){const r=e(n.id);return t.globalScope[r]={valueset:!0,node:null,value:new z(n,t)},y}async function de(t,n){const r=e(n.specifiers[0].local),o=t.libraryResolver.loadLibrary(r);let a;return t.libraryResolver._moduleSingletons?.has(o.uri)?a=t.libraryResolver._moduleSingletons.get(o.uri):(a=new Y(o),await a.loadModule(t),t.libraryResolver._moduleSingletons?.set(o.uri,a)),t.globalScope[r]={value:a,valueset:!0,node:n},y}async function he(t,n){if(await Q(t,n.declaration),"FunctionDeclaration"===n.declaration.type)t.exports[e(n.declaration.id)]="function";else if("VariableDeclaration"===n.declaration.type)for(const r of n.declaration.declarations)t.exports[e(r.id)]="variable";return y}async function ge(e,t,n){return n>=t.declarations.length?y:(await me(e,t.declarations[n]),n===t.declarations.length-1||await ge(e,t,n+1),y)}async function me(t,n){let r=null;if(r=null===n.init?null:await J(t,n.init),null!==t.localScope){if(r===y&&(r=null),"Identifier"!==n.id.type)throw new i(t,l.InvalidIdentifier,n);const o=e(n.id);return void(null!=t.localScope&&(t.localScope[o]={value:r,valueset:!0,node:n.init}))}if("Identifier"!==n.id.type)throw new i(t,l.InvalidIdentifier,n);const o=e(n.id);r===y&&(r=null),t.globalScope[o]={value:r,valueset:!0,node:n.init}}async function ye(e,t){const n=await J(e,t.object);if(null===n)throw new i(e,l.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(n instanceof a||S(n))return n.field(t.property.name);if(n instanceof G)return o(n,t.property.name,e,t);if(n instanceof Y){if(!n.hasGlobal(t.property.name))throw new i(e,l.InvalidIdentifier,t);return n.global(t.property.name)}throw new i(e,l.InvalidMemberAccessKey,t)}throw new i(e,l.InvalidMemberAccessKey,t)}let r=await J(e,t.property);if(n instanceof a||S(n)){if(P(r))return n.field(r);throw new i(e,l.InvalidMemberAccessKey,t)}if(n instanceof Y){if(P(r))return n.global(r);throw new i(e,l.InvalidMemberAccessKey,t)}if(n instanceof G){if(P(r))return o(n,r,e,t);throw new i(e,l.InvalidMemberAccessKey,t)}if(v(n)){if(W(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new i(e,l.OutOfBounds,t);return n[r]}throw new i(e,l.InvalidMemberAccessKey,t)}if(x(n)){if(W(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length()+r),r>=n.length()||r<0)throw new i(e,l.OutOfBounds,t);return n.get(r)}throw new i(e,l.InvalidMemberAccessKey,t)}if(P(n)){if(W(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new i(e,l.OutOfBounds,t);return n[r]}throw new i(e,l.InvalidMemberAccessKey,t)}throw new i(e,l.InvalidMemberAccessKey,t)}async function ve(e,t){const n=await J(e,t.argument);if(h(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*b(n);if("+"===t.operator)return 1*b(n);if("~"===t.operator)return~b(n);throw new i(e,l.UnsupportedUnaryOperator,t)}if("-"===t.operator)return-1*b(n);if("+"===t.operator)return 1*b(n);if("~"===t.operator)return~b(n);throw new i(e,l.UnsupportedUnaryOperator,t)}async function be(e,t){const n=[];for(let r=0;r<t.elements.length;r++)n.push(await J(e,t.elements[r]));for(let r=0;r<n.length;r++){if(m(n[r]))throw new i(e,l.NoFunctionInArray,t);n[r]===y&&(n[r]=null)}return n}async function Se(e,t){const n=await J(e,t.left),r=await J(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return M(b(n),b(r),t.operator);case"==":return g(n,r);case"!=":return!g(n,r);case"<":case">":case"<=":case">=":return I(n,r,t.operator);case"+":return P(n)||P(r)?F(n)+F(r):b(n)+b(r);case"-":return b(n)-b(r);case"*":return b(n)*b(r);case"/":return b(n)/b(r);case"%":return b(n)%b(r);default:throw new i(e,l.UnsupportedOperator,t)}}async function xe(e,t){const n=await J(e,t.left);if(!h(n))throw new i(e,l.LogicalExpressionOnlyBoolean,t);switch(t.operator){case"||":{if(!0===n)return n;const r=await J(e,t.right);if(h(r))return r;throw new i(e,l.LogicExpressionOrAnd,t)}case"&&":{if(!1===n)return n;const r=await J(e,t.right);if(h(r))return r;throw new i(e,l.LogicExpressionOrAnd,t)}default:throw new i(e,l.LogicExpressionOrAnd,t)}}async function Fe(t,n){const r=e(n);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];if(!0===e.valueset)return e.value;if(null!==e.d)return e.d;e.d=J(t,e.node);const n=await e.d;return e.value=n,e.valueset=!0,n}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];if(!0===e.valueset)return e.value;if(null!==e.d)return e.d;e.d=J(t,e.node);const n=await e.d;return e.value=n,e.valueset=!0,n}throw new i(t,l.InvalidIdentifier,n)}async function Ie(t,n){if("MemberExpression"===n.callee.type){const e=await J(t,n.callee.object);if(!(e instanceof Y))throw new i(t,l.FunctionNotFound,n);const r=!1===n.callee.computed?n.callee.property.name:await J(t,n.callee.property);if(!e.hasGlobal(r))throw new i(t,l.FunctionNotFound,n);const o=await e.global(r);if(!m(o))throw new i(t,l.CallNonFunction,n);return o.call(t,n)}if("Identifier"!==n.callee.type)throw new i(t,l.FunctionNotFound,n);const r=e(n.callee);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];if(m(e.value))return e.value.call(t,n);throw new i(t,l.CallNonFunction,n)}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];if(m(e.value))return e.value.call(t,n);throw new i(t,l.CallNonFunction,n)}throw new i(t,l.FunctionNotFound,n)}async function Me(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){if(t.expressions[r]){const o=await J(e,t.expressions[r]);if(m(o))throw new i(e,l.NoFunctionInTemplateLiteral,t);n+=F(o)}r++}return n}const Ce={};async function Re(e,t,n,r){const o=await J(e,t.arguments[n]);if(g(o,r))return J(e,t.arguments[n+1]);const a=t.arguments.length-n;return 1===a?J(e,t.arguments[n]):2===a?null:3===a?J(e,t.arguments[n+2]):Re(e,t,n+2,r)}async function ke(e,t,n,r){if(!0===r)return J(e,t.arguments[n+1]);if(3===t.arguments.length-n)return J(e,t.arguments[n+2]);const o=await J(e,t.arguments[n+2]);if(!1===h(o))throw new i(e,l.ModuleExportNotFound,t.arguments[n+2]);return ke(e,t,n+2,o)}async function Ae(t,n,r,o){const a=t.body;if(r.length!==t.params.length)throw new i(n,l.WrongNumberOfParameters,null);for(let i=0;i<r.length;i++){const o=t.params[i];"Identifier"===o.type&&null!=n.localScope&&(n.localScope[e(o)]={d:null,value:r[i],valueset:!0,node:null})}const s=await Q(n,a);if(s instanceof C)return s.value;if(s===k)throw new i(n,l.UnexpectedToken,o);if(s===A)throw new i(n,l.UnexpectedToken,o);return s instanceof R?s.value:s}B(Ce,_),Z(Ce,_),U(Ce,_),L(Ce,_),D(Ce,_),K({functions:Ce,compiled:!1,signatures:null,evaluateIdentifier:null,mode:"async",standardFunction:_,standardFunctionAsync:H}),Ce.iif=async function(e,t){d(null===t.arguments?[]:t.arguments,3,3,e,t);const n=await J(e,t.arguments[0]);if(!1===h(n))throw new i(e,l.BooleanConditionRequired,t);return J(e,n?t.arguments[1]:t.arguments[2])},Ce.defaultvalue=async function(e,t){d(null===t.arguments?[]:t.arguments,2,3,e,t);const n=await J(e,t.arguments[0]);if(3===t.arguments.length){const o=await J(e,t.arguments[1]),a=r(n,o);return null!=a&&""!==a?a:J(e,t.arguments[2])}return null==n||""===n?J(e,t.arguments[1]):n},Ce.decode=async function(e,t){if(t.arguments.length<2)throw new i(e,l.WrongNumberOfParameters,t);if(2===t.arguments.length)return J(e,t.arguments[1]);if((t.arguments.length-1)%2==0)throw new i(e,l.WrongNumberOfParameters,t);return Re(e,t,1,await J(e,t.arguments[0]))},Ce.when=async function(e,t){if(t.arguments.length<3)throw new i(e,l.WrongNumberOfParameters,t);if(t.arguments.length%2==0)throw new i(e,l.WrongNumberOfParameters,t);const n=await J(e,t.arguments[0]);if(!1===h(n))throw new i(e,l.BooleanConditionRequired,t.arguments[0]);return ke(e,t,0,n)};const Ne={fixSpatialReference:N,parseArguments:V,standardFunction:_,standardFunctionAsync:H,evaluateIdentifier:Fe};for(const Ue in Ce)Ce[Ue]={value:new u(Ce[Ue]),valueset:!0,node:null};const Oe=function(){};function Ee(e,t,n){const r=new Oe;null==e&&(e={}),null==t&&(t={});const o=new a({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});o.immutable=!1,r.textformatting={value:o,valueset:!0,node:null};for(const a in t)r[a]={value:new u(t[a]),native:!0,valueset:!0,node:null};for(const a in e)r[a]={value:T(e[a])?c.createFromGraphic(e[a],n):e[a],valueset:!0,node:null};return r}function je(e){console.log(e)}Oe.prototype=Ce,Oe.prototype.infinity={value:Number.POSITIVE_INFINITY,valueset:!0,node:null},Oe.prototype.pi={value:Math.PI,valueset:!0,node:null};const Be=Ne;function Ke(e){const t={mode:"async",compiled:!1,functions:{},signatures:[],standardFunction:_,standardFunctionAsync:H,evaluateIdentifier:Fe};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)Ce[n]={value:new u(t.functions[n]),valueset:!0,node:null},Oe.prototype[n]=Ce[n];for(let n=0;n<t.signatures.length;n++)E(t.signatures[n],"async")}async function Le(e,t){let r=t.spatialReference;null==r&&(r=new q({wkid:102100}));let o=null;e.usesModules&&(o=new n(new Map,e.loadedModules));const a=Ee(t.vars,t.customfunctions,t.timeZone),s={spatialReference:r,services:t.services,exports:{},libraryResolver:o,abortSignal:void 0===t.abortSignal||null===t.abortSignal?{aborted:!1}:t.abortSignal,globalScope:a,console:t.console??je,timeZone:t.timeZone??null,lrucache:t.lrucache,interceptor:t.interceptor,localScope:null,depthCounter:{depth:1}},c=await ue(s,e);if(c instanceof C||c instanceof R){const e=c.value;if(e===y)return null;if(m(e))throw new i(s,l.IllegalResult,null);return e}if(c===y)return null;if(c===k)throw new i(s,l.IllegalResult,null);if(c===A)throw new i(s,l.IllegalResult,null);throw new i(s,l.NeverReach,null)}Ke([j]);export{Le as executeScript,Ke as extend,Be as functionHelper};
|
package/arcade/arcadeCompiler.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{toSymbolId as e}from"./arcadeEnvironment.js";import{ArcadeModule as n}from"./ArcadeModule.js";import{ArcadeModuleLoader as t}from"./ArcadeModuleLoader.js";import{geometryMember as o,getNestedOptionalValue as l}from"./containerUtils.js";import r from"./Dictionary.js";import{ArcadeExecutionError as a,ExecutionErrorCodes as s,ArcadeCompilationError as i,ArcadeUncompilableError as c}from"./executionError.js";import u from"./Feature.js";import{NativeFunction as p,ArcadeFunction as m,ScopeMarshalledFunction as g,wrapModuleScopedResponse as d}from"./FunctionWrapper.js";import{i as f,x as h,y,R as b,I as w,z as S,A as v,B as x,C as F,b as M,o as C,q as I,r as A,c as _,v as O,p as $,j as k,a as E,g as G,D as B,E as j,F as N}from"../chunks/languageUtils.js";import{addFunctionDeclaration as R}from"./treeAnalysis.js";import{A as D}from"../chunks/array.js";import{registerFunctions as L}from"./functions/date.js";import{registerFunctions as U}from"./functions/geometry.js";import{registerFunctions as Z}from"./functions/geomsync.js";import{registerFunctions as K}from"./functions/maths.js";import{registerFunctions as P}from"./functions/stats.js";import{registerFunctions as W}from"./functions/string.js";import{isPromiseLike as T}from"../core/promiseUtils.js";import q from"../geometry/Geometry.js";import z from"../geometry/SpatialReference.js";class V extends m{constructor(e,n){super(),this.paramCount=n,this.fn=e}createFunction(e){return(...n)=>{if(n.length!==this.paramCount)throw new a(e,s.WrongNumberOfParameters,null);return this.fn(...n)}}call(e,n){return this.fn(...n.arguments)}marshalledCall(e,n,t,o){return o(e,n,((n,l,r)=>{r=r.map((n=>!f(n)||n instanceof g?n:d(n,e,o)));const a=this.call(t,{arguments:r});return T(a)?a.then((e=>d(e,t,o))):a}))}}function J(e,n){const t=[];for(let o=0;o<n.arguments.length;o++)t.push(H(e,n.arguments[o]));return t}function Y(e,n,t){try{return t(e,null,n.arguments)}catch(o){throw o}}function H(e,n){switch(n.type){case"AssignmentExpression":return le(e,n);case"UpdateExpression":return te(e,n);case"TemplateLiteral":return we(e,n);case"Identifier":return xe(e,n);case"MemberExpression":return he(e,n);case"Literal":return null===n.value||void 0===n.value?"null":JSON.stringify(n.value);case"CallExpression":return Fe(e,n);case"UnaryExpression":return ye(e,n);case"BinaryExpression":return Se(e,n);case"LogicalExpression":return ve(e,n);case"ArrayExpression":return be(e,n);case"ObjectExpression":return X(e,n);default:throw new i(e,s.Unrecognized,n)}}function Q(e,n){switch(n.type){case"EmptyStatement":return"lc.voidOperation";case"VariableDeclaration":return de(e,n);case"BlockStatement":return ie(e,n);case"FunctionDeclaration":return ge(e,n);case"ImportDeclaration":return ue(e,n);case"ExportNamedDeclaration":return pe(e,n);case"ReturnStatement":return ce(e,n);case"IfStatement":return se(e,n);case"ExpressionStatement":return re(e,n);case"BreakStatement":return"break";case"ContinueStatement":return"continue";case"ForStatement":return ne(e,n);case"ForInStatement":return ee(e,n);case"WhileStatement":return oe(e,n);default:throw new i(e,s.Unrecognized,n)}}function X(e,n){let t="lang.dictionary([";for(let o=0;o<n.properties.length;o++){const l=n.properties[o];let r;"Identifier"===l.key.type?(me(l.key.name),r="'"+l.key.name+"'"):r=H(e,l.key);o>0&&(t+=","),t+="lang.strCheck("+r+",'ObjectExpression'),lang.aCheck("+H(e,l.value)+", 'ObjectExpression')"}return t+="])",t}function ee(n,t){const o=$e(n),l=$e(n),r=$e(n);let a="var "+o+" = "+H(n,t.right)+";\n";"VariableDeclaration"===t.left.type&&(a+=Q(n,t.left));const s=e("VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);me(s);let i="";null!==n.localScope&&(void 0!==n.localScope[s]?i="lscope['"+s+"']":void 0!==n.localScope._SymbolsMap[s]&&(i="lscope['"+n.localScope._SymbolsMap[s]+"']"));let c="";if(""===i)if(void 0!==n.globalScope[s])i="gscope['"+s+"']";else if(void 0!==n.globalScope._SymbolsMap[s])i="gscope['"+n.globalScope._SymbolsMap[s]+"']";else if(null!==n.localScope)if(n.undeclaredGlobalsInFunctions.has(s))i="gscope['"+n.undeclaredGlobalsInFunctions.get(s).manglename+"']",c=n.undeclaredGlobalsInFunctions.get(s).manglename;else{const e={manglename:Oe(n),node:t.left};n.undeclaredGlobalsInFunctions.set(s,e),i="gscope['"+e.manglename+"']",c=e.manglename}return c&&(a+="lang.chkAssig('"+c+"',runtimeCtx); \n"),a+="if ("+o+"===null) { lastStatement = lc.voidOperation; }\n ",a+="else if (lc.isArray("+o+") || lc.isString("+o+")) {",a+="var "+l+"="+o+".length; \n",a+="for(var "+r+"=0; "+r+"<"+l+"; "+r+"++) {\n",a+=i+"="+r+";\n",a+=Q(n,t.body),a+="\n}\n",a+=" lastStatement = lc.voidOperation; \n",a+=" \n}\n",a+="else if (lc.isImmutableArray("+o+")) {",a+="var "+l+"="+o+".length(); \n",a+="for(var "+r+"=0; "+r+"<"+l+"; "+r+"++) {\n",a+=i+"="+r+";\n",a+=Q(n,t.body),a+="\n}\n",a+=" lastStatement = lc.voidOperation; \n",a+=" \n}\n",a+="else if (( "+o+" instanceof lang.Dictionary) || ( "+o+" instanceof lang.Feature)) {",a+="var "+l+"="+o+".keys(); \n",a+="for(var "+r+"=0; "+r+"<"+l+".length; "+r+"++) {\n",a+=i+"="+l+"["+r+"];\n",a+=Q(n,t.body),a+="\n}\n",a+=" lastStatement = lc.voidOperation; \n",a+=" \n}\n",n.isAsync&&(a+="else if (lc.isFeatureSet("+o+")) {",a+="var "+l+"="+o+".iterator(runtimeCtx.abortSignal); \n",a+="for(var "+r+"=lang. graphicToFeature( yield "+l+".next(),"+o+", runtimeCtx); "+r+"!=null; "+r+"=lang. graphicToFeature( yield "+l+".next(),"+o+", runtimeCtx)) {\n",a+=i+"="+r+";\n",a+=Q(n,t.body),a+="\n}\n",a+=" lastStatement = lc.voidOperation; \n",a+=" \n}\n"),a+="else { lastStatement = lc.voidOperation; } \n",a}function ne(e,n){let t="lastStatement = lc.voidOperation; \n";null!==n.init&&("VariableDeclaration"===n.init.type?t+=Q(e,n.init):t+=H(e,n.init)+"; ");const o=$e(e),l=$e(e);return t+="var "+o+" = true; ",t+="\n do { ",null!==n.update&&(t+=" if ("+o+"===false) {\n "+H(e,n.update)+" \n}\n "+o+"=false; \n"),null!==n.test&&(t+="var "+l+" = "+H(e,n.test)+"; ",t+="if ("+l+"===false) { break; } else if ("+l+"!==true) { lang.error('"+s.BooleanConditionRequired+"'); }\n"),t+=Q(e,n.body),null!==n.update&&(t+="\n "+H(e,n.update)),t+="\n"+o+" = true; \n} while(true); lastStatement = lc.voidOperation; ",t}function te(n,t){if("CallExpression"===t.argument.type)throw new i(n,s.NeverReach,t);let o;if("MemberExpression"===t.argument.type){const e=H(n,t.argument.object);return!0===t.argument.computed?o=H(n,t.argument.property):(me(t.argument.property.name),o="'"+t.argument.property.name+"'"),"lang.memberupdate("+e+","+o+",'"+t.operator+"',"+t.prefix+")"}const l=e(t.argument);if(me(l),null!==n.localScope){if(void 0!==n.localScope[l])return"lang.update(lscope, '"+l+"','"+t.operator+"',"+t.prefix+")";if(void 0!==n.localScope._SymbolsMap[l])return"lang.update(lscope, '"+n.localScope._SymbolsMap[l]+"','"+t.operator+"',"+t.prefix+")"}if(void 0!==n.globalScope[l])return"lang.update(gscope, '"+l+"','"+t.operator+"',"+t.prefix+")";if(void 0!==n.globalScope._SymbolsMap[l])return"lang.update(gscope, '"+n.globalScope._SymbolsMap[l]+"','"+t.operator+"',"+t.prefix+")";if(null!==n.localScope){if(n.undeclaredGlobalsInFunctions.has(l))return"lang.update(gscope,lang.chkAssig( '"+n.undeclaredGlobalsInFunctions.get(l).manglename+"',runtimeCtx),'"+t.operator+"',"+t.prefix+")";const e={manglename:Oe(n),node:t.argument};return n.undeclaredGlobalsInFunctions.set(l,e),"lang.update(gscope, lang.chkAssig('"+e.manglename+"',runtimeCtx),'"+t.operator+"',"+t.prefix+")"}throw new a(n,s.InvalidIdentifier,t)}function oe(e,n){let t="lastStatement = lc.voidOperation; \n";const o=$e(e);return t+=`\n var ${o} = true;\n do {\n ${o} = ${H(e,n.test)};\n if (${o}==false) {\n break;\n }\n if (${o}!==true) {\n lang.error('${s.BooleanConditionRequired}');\n }\n ${Q(e,n.body)}\n }\n while (${o} !== false);\n lastStatement = lc.voidOperation;\n `,t}function le(n,t){const o=H(n,t.right);if("MemberExpression"===t.left.type){let e;const l=H(n,t.left.object);return!0===t.left.computed?e=H(n,t.left.property):(e="'"+t.left.property.name+"'",me(t.left.property.name)),"lang.assignmember("+l+","+e+",'"+t.operator+"',"+o+")"}const l=e(t.left);if(me(l),null!==n.localScope){if(void 0!==n.localScope[l])return"lscope['"+l+"']=lang.assign("+o+",'"+t.operator+"', lscope['"+l+"'])";if(void 0!==n.localScope._SymbolsMap[l])return"lscope['"+n.localScope._SymbolsMap[l]+"']=lang.assign("+o+",'"+t.operator+"', lscope['"+n.localScope._SymbolsMap[l]+"'])"}if(void 0!==n.globalScope[l])return"gscope['"+l+"']=lang.assign("+o+",'"+t.operator+"', gscope['"+l+"'])";if(void 0!==n.globalScope._SymbolsMap[l])return"gscope['"+n.globalScope._SymbolsMap[l]+"']=lang.assign("+o+",'"+t.operator+"', gscope['"+n.globalScope._SymbolsMap[l]+"'])";if(null!==n.localScope){if(n.undeclaredGlobalsInFunctions.has(l))return"gscope[lang.chkAssig('"+n.undeclaredGlobalsInFunctions.get(l).manglename+"',runtimeCtx)]=lang.assign("+o+",'"+t.operator+"', gscope['"+n.undeclaredGlobalsInFunctions.get(l).manglename+"'])";const e={manglename:Oe(n),node:t.left};return n.undeclaredGlobalsInFunctions.set(l,e),"gscope[lang.chkAssig('"+e.manglename+"',runtimeCtx)]=lang.assign("+o+",'"+t.operator+"', gscope['"+e.manglename+"'])"}throw new a(n,s.InvalidIdentifier,t)}function re(e,n){return"AssignmentExpression"===n.expression.type?"lastStatement = lc.voidOperation; "+H(e,n.expression)+"; \n ":"lastStatement = "+H(e,n.expression)+"; "}function ae(e,n){return"BlockStatement"===n.type?Q(e,n):"ReturnStatement"===n.type||"BreakStatement"===n.type||"ContinueStatement"===n.type?Q(e,n)+"; ":"ExpressionStatement"===n.type?Q(e,n):Q(e,n)+"; "}function se(e,n){return`if (lang.mustBoolean(${H(e,n.test)}, runtimeCtx) === true) {\n ${ae(e,n.consequent)}\n } `+(null!==n.alternate?"IfStatement"===n.alternate.type?" else "+se(e,n.alternate):` else {\n ${ae(e,n.alternate)}\n }\n`:" else {\n lastStatement = lc.voidOperation;\n }\n")}function ie(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+=Q(e,n.body[o])+"; \n":t+=Q(e,n.body[o])+" \n");return t}function ce(e,n){if(null===n.argument)return"return lc.voidOperation";return"return "+H(e,n.argument)}function ue(n,t){const o=e(t.specifiers[0].local);me(o);const l=n.libraryResolver?.loadLibrary(o),r=Oe(n);void 0===n.moduleFactory[l.uri]&&(n.moduleFactory[l.uri]=qe(l.syntax,{interceptor:n.interceptor,services:n.services,moduleFactory:n.moduleFactory,lrucache:n.lrucache,timeZone:n.timeZone??null,libraryResolver:n.libraryResolver,customfunctions:n.customfunctions,vars:{}},n.isAsync)),n.moduleFactoryMap[r]=l.uri;let a,s="";return s=n.isAsync?"(yield lang.loadModule('"+r+"', runtimeCtx) ); ":"lang.loadModule('"+r+"', runtimeCtx); ",void 0!==n.globalScope[o]?"gscope['"+o+"']="+s:void 0!==n.globalScope._SymbolsMap[o]?"gscope['"+n.globalScope._SymbolsMap[o]+"']="+s:(n.undeclaredGlobalsInFunctions.has(o)?(a=n.undeclaredGlobalsInFunctions.get(o).manglename,n.undeclaredGlobalsInFunctions.delete(o)):a=Oe(n),n.globalScope._SymbolsMap[o]=a,n.mangleMap[o]=a,"gscope[lang.setAssig('"+a+"', runtimeCtx)]="+s)}function pe(n,t){const o=Q(n,t.declaration);if("FunctionDeclaration"===t.declaration.type)n.exports[e(t.declaration.id)]="function";else if("VariableDeclaration"===t.declaration.type)for(const l of t.declaration.declarations)n.exports[e(l.id)]="variable";return o}function me(e){if("iif"===e)throw new c;if("decode"===e)throw new c;if("when"===e)throw new c;if("defaultvalue"===e)throw new c}function ge(n,t){const o=e(t.id);let l;me(o);let r=!1;void 0!==n.globalScope[o]?l=o:void 0!==n.globalScope._SymbolsMap[o]?l=n.globalScope._SymbolsMap[o]:n.undeclaredGlobalsInFunctions.has(o)?(l=n.undeclaredGlobalsInFunctions.get(o).manglename,n.globalScope._SymbolsMap[o]=l,n.mangleMap[o]=l,n.undeclaredGlobalsInFunctions.delete(o),r=!0):(l=Oe(n),n.globalScope._SymbolsMap[o]=l,n.mangleMap[o]=l);const a={isAsync:n.isAsync,console:n.console,exports:n.exports,undeclaredGlobalsInFunctions:n.undeclaredGlobalsInFunctions,customfunctions:n.customfunctions,moduleFactory:n.moduleFactory,moduleFactoryMap:n.moduleFactoryMap,libraryResolver:n.libraryResolver,lrucache:n.lrucache,interceptor:n.interceptor,services:n.services,symbols:n.symbols,mangleMap:n.mangleMap,localScope:{_SymbolsMap:{}},depthCounter:n.depthCounter,globalScope:n.globalScope};let s="new lang.UserDefinedCompiledFunction( lang.functionDepthchecker(function() { var lastStatement = lc.voidOperation; \n var lscope = runtimeCtx.localStack[runtimeCtx.localStack.length-1];\n";for(let i=0;i<t.params.length;i++){const o=e(t.params[i]);me(o);const l=Oe(n);a.localScope._SymbolsMap[o]=l,a.mangleMap[o]=l,s+="lscope['"+l+"']=arguments["+i.toString()+"];\n"}return!0===n.isAsync?(s+="return lang.__awaiter(this, void 0, void 0, function* () {\n",s+=ie(a,t.body)+"\n return lastStatement; ",s+="}); }",s+=", runtimeCtx),"+t.params.length+")",s+="\n lastStatement = lc.voidOperation; \n"):(s+=ie(a,t.body)+"\n return lastStatement; }, runtimeCtx),"+t.params.length+")",s+="\n lastStatement = lc.voidOperation; \n"),r?"gscope[lang.setAssig('"+l+"', runtimeCtx)]="+s:"gscope['"+l+"']="+s}function de(e,n){const t=[];for(let o=0;o<n.declarations.length;o++)t.push(fe(e,n.declarations[o]));return t.join("\n")+" \n lastStatement= lc.voidOperation; \n"}function fe(n,t){const o=null===t.init?null:H(n,t.init),l=e(t.id);if(me(l),null!==n.localScope){if(void 0!==n.localScope[l])return"lscope['"+l+"']="+o+"; ";if(void 0!==n.localScope._SymbolsMap[l])return"lscope['"+n.localScope._SymbolsMap[l]+"']="+o+"; ";const e=Oe(n);return n.localScope._SymbolsMap[l]=e,n.mangleMap[l]=e,"lscope['"+e+"']="+o+"; "}if(void 0!==n.globalScope[l])return"gscope['"+l+"']="+o+"; ";if(void 0!==n.globalScope._SymbolsMap[l])return"gscope['"+n.globalScope._SymbolsMap[l]+"']="+o+"; ";if(n.undeclaredGlobalsInFunctions.has(l)){const e=n.undeclaredGlobalsInFunctions.get(l).manglename;return n.globalScope._SymbolsMap[l]=e,n.mangleMap[l]=e,n.undeclaredGlobalsInFunctions.delete(l),"gscope[lang.setAssig('"+e+"', runtimeCtx)]="+o+"; "}const r=Oe(n);return n.globalScope._SymbolsMap[l]=r,n.mangleMap[l]=r,"gscope['"+r+"']="+o+"; "}function he(e,n){try{let t;return!0===n.computed?t=H(e,n.property):(me(n.property.name),t="'"+n.property.name+"'"),"lang.member("+H(e,n.object)+","+t+")"}catch(t){throw t}}function ye(e,n){try{return"lang.unary("+H(e,n.argument)+",'"+n.operator+"')"}catch(t){throw t}}function be(e,n){try{const t=[];for(let o=0;o<n.elements.length;o++)"Literal"===n.elements[o].type?t.push(H(e,n.elements[o])):t.push("lang.aCheck("+H(e,n.elements[o])+",'ArrayExpression')");return"["+t.join(",")+"]"}catch(t){throw t}}function we(e,n){try{const t=[];let o=0;for(const l of n.quasis)t.push(l.value?JSON.stringify(l.value.cooked):JSON.stringify("")),!1===l.tail&&(t.push(n.expressions[o]?"lang.castString(lang.aCheck("+H(e,n.expressions[o])+", 'TemplateLiteral'))":""),o++);return"(["+t.join(",")+"]).join('')"}catch(t){throw t}}function Se(e,n){try{return"lang.binary("+H(e,n.left)+","+H(e,n.right)+",'"+n.operator+"')"}catch(t){throw t}}function ve(e,n){try{if("AssignmentExpression"===n.left.type||"UpdateExpression"===n.left.type)throw new i(e,s.LogicalExpressionOnlyBoolean,n);if("AssignmentExpression"===n.right.type||"UpdateExpression"===n.right.type)throw new i(e,s.LogicalExpressionOnlyBoolean,n);if("&&"===n.operator||"||"===n.operator)return"(lang.logicalCheck("+H(e,n.left)+") "+n.operator+" lang.logicalCheck("+H(e,n.right)+"))";throw new i(null,s.LogicExpressionOrAnd,null)}catch(t){throw t}}function xe(n,t){try{const o=e(t);if(me(o),null!==n.localScope){if(void 0!==n.localScope[o])return"lscope['"+o+"']";if(void 0!==n.localScope._SymbolsMap[o])return"lscope['"+n.localScope._SymbolsMap[o]+"']"}if(void 0!==n.globalScope[o])return"gscope['"+o+"']";if(void 0!==n.globalScope._SymbolsMap[o])return"gscope['"+n.globalScope._SymbolsMap[o]+"']";if(null!==n.localScope){if(n.undeclaredGlobalsInFunctions.has(o))return"gscope[lang.chkAssig('"+n.undeclaredGlobalsInFunctions.get(o).manglename+"',runtimeCtx)]";const e={manglename:Oe(n),node:t};return n.undeclaredGlobalsInFunctions.set(o,e),"gscope[lang.chkAssig('"+e.manglename+"',runtimeCtx)]"}throw new i(n,s.InvalidIdentifier,t)}catch(o){throw o}}function Fe(n,t){try{if("MemberExpression"===t.callee.type){let e;!0===t.callee.computed?e=H(n,t.callee.property):(me(t.callee.property.name),e="'"+t.callee.property.name+"'");let o="[";for(let l=0;l<t.arguments.length;l++)l>0&&(o+=", "),o+=H(n,t.arguments[l]);return o+="]",n.isAsync?"(yield lang.callModuleFunction("+H(n,t.callee.object)+","+o+","+e+",runtimeCtx))":"lang.callModuleFunction("+H(n,t.callee.object)+","+o+","+e+",runtimeCtx)"}if("Identifier"!==t.callee.type)throw new i(n,s.FunctionNotFound,t);const o=e(t.callee);if("iif"===o)return Me(n,t);if("when"===o)return Ie(n,t);if("defaultvalue"===o)return Ce(n,t);if("decode"===o)return Ae(n,t);let l="";if(null!==n.localScope&&(void 0!==n.localScope[o]?l="lscope['"+o+"']":void 0!==n.localScope._SymbolsMap[o]&&(l="lscope['"+n.localScope._SymbolsMap[o]+"']")),""===l)if(void 0!==n.globalScope[o])l="gscope['"+o+"']";else if(void 0!==n.globalScope._SymbolsMap[o])l="gscope['"+n.globalScope._SymbolsMap[o]+"']";else if(null!==n.localScope)if(n.undeclaredGlobalsInFunctions.has(o))l="gscope[lang.chkAssig('"+n.undeclaredGlobalsInFunctions.get(o).manglename+"',runtimeCtx)]";else{const e={manglename:Oe(n),node:t.callee};n.undeclaredGlobalsInFunctions.set(o,e),l="gscope[lang.chkAssig('"+e.manglename+"',runtimeCtx)]"}if(""!==l){let e="[";for(let o=0;o<t.arguments.length;o++)o>0&&(e+=", "),e+=H(n,t.arguments[o]);return e+="]",n.isAsync?"(yield lang.callfunc("+l+","+e+",runtimeCtx) )":"lang.callfunc("+l+","+e+",runtimeCtx)"}throw new i(n,s.FunctionNotFound,t)}catch(o){throw o}}function Me(e,n){try{if(3!==n.arguments.length)throw new i(e,s.WrongNumberOfParameters,n);const t=$e(e);return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${H(e,n.arguments[0])};\n\n if (${t} === true) {\n return ${H(e,n.arguments[1])};\n }\n else if (${t} === false) {\n return ${H(e,n.arguments[2])};\n }\n else {\n lang.error('ExecutionErrorCodes.BooleanConditionRequired');\n }\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Ce(e,n){try{if(n.arguments.length<2||n.arguments.length>3)throw new i(e,s.WrongNumberOfParameters,n);const t=$e(e),o=$e(e);return 3===n.arguments.length?`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${H(e,n.arguments[0])};\n var ${o} = ${H(e,n.arguments[1])};\n ${t} = lang.getNestedOptionalValue(${t}, ${o});\n return ${t} != null && ${t} !== "" ? ${t} : ${H(e,n.arguments[2])};\n ${e.isAsync?"})}()))":"}()"}`:`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${H(e,n.arguments[0])};\n if (${t} === null) {\n return ${H(e,n.arguments[1])};\n }\n if (${t} === "") {\n return ${H(e,n.arguments[1])};\n }\n if (${t} === undefined) {\n return ${H(e,n.arguments[1])};\n }\n return ${t};\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Ie(e,n){try{if(n.arguments.length<3)throw new i(e,s.WrongNumberOfParameters,n);if(n.arguments.length%2==0)throw new i(e,s.WrongNumberOfParameters,n);const t=$e(e);let o="var ";for(let l=0;l<n.arguments.length-1;l+=2)o+=`${t} = lang.mustBoolean(${H(e,n.arguments[l])}, runtimeCtx);\n if (${t} === true ) {\n return ${H(e,n.arguments[l+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n ${o}\n return ${H(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Ae(e,n){try{if(n.arguments.length<2)throw new i(e,s.WrongNumberOfParameters,n);if(2===n.arguments.length)return`(${H(e,n.arguments[1])})`;if((n.arguments.length-1)%2==0)throw new i(e,s.WrongNumberOfParameters,n);const t=$e(e),o=$e(e);let l="var ";for(let r=1;r<n.arguments.length-1;r+=2)l+=`${o} = ${H(e,n.arguments[r])};\n if (lang.binary(${o}, ${t}, "==") === true ) {\n return ${H(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} = ${H(e,n.arguments[0])};\n ${l}\n return ${H(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}const _e={};function Oe(e){return e.symbols.symbolCounter++,`_T${e.symbols.symbolCounter}`}function $e(e){return e.symbols.symbolCounter++,`_Tvar${e.symbols.symbolCounter}`}L(_e,Y),W(_e,Y),K(_e,Y),U(_e,Y),P(_e,Y),_e.iif=function(e,n){try{return Y(e,n,((t,o,l)=>{throw new a(e,s.Unrecognized,n)}))}catch(t){throw t}},_e.decode=function(e,n){try{return Y(e,n,((t,o,l)=>{throw new a(e,s.Unrecognized,n)}))}catch(t){throw t}},_e.when=function(e,n){try{return Y(e,n,((t,o,l)=>{throw new a(e,s.Unrecognized,n)}))}catch(t){throw t}},_e.defaultvalue=function(e,n){try{return Y(e,n,((t,o,l)=>{throw new a(e,s.Unrecognized,n)}))}catch(t){throw t}};const ke={};for(const ze in _e)ke[ze]=new p(_e[ze]);Z(_e,Y);for(const ze in _e)_e[ze]=new p(_e[ze]);const Ee=function(){};Ee.prototype=_e;const Ge=function(){};function Be(e,n,t){const o={_SymbolsMap:{}};e||(e={}),t||(t={}),o.textformatting=1,o.infinity=1,o.pi=1;for(const l in n)o[l]=1;for(const l in t)o[l]=1;for(const l in e)o[l]=1;return o}function je(e,n,t,o){const l=t?new Ge:new Ee;e||(e={}),n||(n={});const a=new r({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 r in n)l[r]=n[r],l._SymbolsMap[r]=1;for(const r in e){const n=e[r];l._SymbolsMap[r]=1,F(n)?l[r]=u.createFromGraphic(n,o??null):l[r]=n}return l}Ge.prototype=ke;const Ne={fixSpatialReference:h,parseArguments:J,standardFunction:Y};function Re(e,n){const t={mode:n,compiled:!0,functions:{},signatures:[],standardFunction:Y,standardFunctionAsync:Y,evaluateIdentifier:Le};for(let o=0;o<e.length;o++)e[o].registerFunctions(t);if("sync"===n){for(const e in t.functions)_e[e]=new p(t.functions[e]),Ee.prototype[e]=_e[e];for(let e=0;e<t.signatures.length;e++)R(t.signatures[e],"sync")}else{for(const e in t.functions)ke[e]=new p(t.functions[e]),Ge.prototype[e]=ke[e];for(let e=0;e<t.signatures.length;e++)R(t.signatures[e],"async")}}function De(e,n){return e(n)}function Le(e,n){const t=n.name;if("_SymbolsMap"===t)throw new a(e,s.InvalidIdentifier,null);if(e.localStack.length>0){if(!t.toLowerCase().startsWith("_t")&&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.toLowerCase().startsWith("_t")&&void 0!==e.globalScope[t])return e.globalScope[t];if(1===e.globalScope._SymbolsMap[t])return e.globalScope[t];const o=e.mangleMap[t];return void 0!==o?e.globalScope[o]:void 0}Re([D],"sync"),Re([D],"async");let Ue=0;const Ze={isNumber:e=>M(e),isArray:e=>C(e),isImmutableArray:e=>I(e),isFeature:e=>A(e),isString:e=>_(e),isDictionary:e=>O(e),isGeometry:e=>$(e),geometryMember:(e,n,t,l,r=1)=>o(e,n,t,l,r),error(e){throw new a(null,e,null)},__awaiter:(e,n,t,o)=>new Promise(((t,l)=>{function r(e){try{s(o.next(e))}catch(n){l(n)}}function a(e){try{s(o.throw(e))}catch(n){l(n)}}function s(e){e.done?t(e.value):e.value?.then?e.value.then(r,a):(Ue++,Ue%100==0?setTimeout((()=>{Ue=0,r(e.value)}),0):r(e.value))}s((o=o.apply(e,n||[])).next())})),functionDepthchecker:(e,n)=>function(){if(n.depthCounter.depth++,n.localStack.push({}),n.depthCounter.depth>64)throw new a(null,s.MaximumCallDepth,null);const t=e.apply(this,arguments);return T(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 a(n,s.InvalidIdentifier,null);return e},mustBoolean(e,n){if(!0===e||!1===e)return e;throw new a(n,s.BooleanConditionRequired,null)},setAssig:(e,n)=>(n.gdefs[e]=1,e),castString:e=>k(e),aCheck(e,n){if(f(e)){if("ArrayExpression"===n)throw new a(null,s.NoFunctionInArray,null);if("ObjectExpression"===n)throw new a(null,s.NoFunctionInDictionary,null);throw new a(null,s.NoFunctionInTemplateLiteral,null)}return e===S?null:e},Dictionary:r,Feature:u,UserDefinedCompiledFunction:V,dictionary(e){const n={},t=new Map;for(let l=0;l<e.length;l+=2){if(f(e[l+1]))throw new a(null,s.NoFunctionInDictionary,null);if(!1===_(e[l]))throw new a(null,s.KeyMustBeString,null);let o=e[l].toString();const r=o.toLowerCase();t.has(r)?o=t.get(r):t.set(r,o),e[l+1]===S?n[o]=null:n[o]=e[l+1]}const o=new r(n);return o.immutable=!1,o},strCheck(e){if(!1===_(e))throw new a(null,s.KeyMustBeString,null);return e},unary(e,n){if(E(e)){if("!"===n)return!e;if("-"===n)return-1*G(e);if("+"===n)return 1*G(e);if("~"===n)return~G(e);throw new a(null,s.UnsupportedUnaryOperator,null)}if("-"===n)return-1*G(e);if("+"===n)return 1*G(e);if("~"===n)return~G(e);throw new a(null,s.UnsupportedUnaryOperator,null)},logicalCheck(e){if(!1===E(e))throw new a(null,s.LogicExpressionOrAnd,null);return e},logical(e,n,t){if(E(e)&&E(n))switch(t){case"||":return e||n;case"&&":return e&&n;default:throw new a(null,s.LogicExpressionOrAnd,null)}throw new a(null,s.LogicExpressionOrAnd,null)},binary(e,n,t){switch(t){case"|":case"<<":case">>":case">>>":case"^":case"&":return N(G(e),G(n),t);case"==":case"=":return j(e,n);case"!=":return!j(e,n);case"<":case">":case"<=":case">=":return B(e,n,t);case"+":return _(e)||_(n)?k(e)+k(n):G(e)+G(n);case"-":return G(e)-G(n);case"*":return G(e)*G(n);case"/":return G(e)/G(n);case"%":return G(e)%G(n);default:throw new a(null,s.UnsupportedOperator,null)}},assign(e,n,t){switch(n){case"=":return e===S?null:e;case"/=":return G(t)/G(e);case"*=":return G(t)*G(e);case"-=":return G(t)-G(e);case"+=":return _(t)||_(e)?k(t)+k(e):G(t)+G(e);case"%=":return G(t)%G(e);default:throw new a(null,s.UnsupportedOperator,null)}},update(e,n,t,o){const l=G(e[n]);return e[n]="++"===t?l+1:l-1,!1===o?l:"++"===t?l+1:l-1},graphicToFeature:(e,n,t)=>null===e?null:u.createFromGraphicLikeObject(e.geometry,e.attributes,n,t.timeZone),memberupdate(e,n,t,o){let l;if(C(e)){if(!M(n))throw new a(null,s.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>=e.length)throw new a(null,s.OutOfBounds,null);l=G(e[n]),e[n]="++"===t?l+1:l-1}else if(e instanceof r){if(!1===_(n))throw new a(null,s.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new a(null,s.FieldNotFound,null,{key:n});l=G(e.field(n)),e.setField(n,"++"===t?l+1:l-1)}else if(A(e)){if(!1===_(n))throw new a(null,s.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new a(null,s.FieldNotFound,null);l=G(e.field(n)),e.setField(n,"++"===t?l+1:l-1)}else{if(I(e))throw new a(null,s.Immutable,null);if(!(e instanceof Te))throw new a(null,s.InvalidIdentifier,null);if(!1===_(n))throw new a(null,s.ModuleAccessorMustBeString,null);if(!0!==e.hasGlobal(n))throw new a(null,s.ModuleExportNotFound,null);l=G(e.global(n)),e.setGlobal(n,"++"===t?l+1:l-1)}return!1===o?l:"++"===t?l+1:l-1},assignmember(e,n,t,o){if(C(e)){if(!M(n))throw new a(null,s.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>e.length)throw new a(null,s.OutOfBounds,null);if(n===e.length){if("="!==t)throw new a(null,s.OutOfBounds,null);e[n]=this.assign(o,t,e[n])}else e[n]=this.assign(o,t,e[n])}else if(e instanceof r){if(!1===_(n))throw new a(null,s.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(o,t,e.field(n)));else{if("="!==t)throw new a(null,s.FieldNotFound,null);e.setField(n,this.assign(o,t,null))}}else if(A(e)){if(!1===_(n))throw new a(null,s.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(o,t,e.field(n)));else{if("="!==t)throw new a(null,s.FieldNotFound,null);e.setField(n,this.assign(o,t,null))}}else{if(I(e))throw new a(null,s.Immutable,null);if(!(e instanceof Te))throw new a(null,s.InvalidIdentifier,null);if(!1===_(n))throw new a(null,s.ModuleAccessorMustBeString,null);if(!e.hasGlobal(n))throw new a(null,s.ModuleExportNotFound,null);e.setGlobal(n,this.assign(o,t,e.global(n)))}},member(e,n){if(null===e)throw new a(null,s.MemberOfNull,null);if(e instanceof r||A(e)){if(_(n))return e.field(n);throw new a(null,s.InvalidMemberAccessKey,null)}if(e instanceof q){if(_(n))return o(e,n,null,null);throw new a(null,s.InvalidMemberAccessKey,null)}if(C(e)){if(M(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new a(null,s.OutOfBounds,null);return e[n]}throw new a(null,s.InvalidMemberAccessKey,null)}if(_(e)){if(M(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new a(null,s.OutOfBounds,null);return e[n]}throw new a(null,s.InvalidMemberAccessKey,null)}if(I(e)){if(M(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length()+n),n>=e.length()||n<0)throw new a(null,s.OutOfBounds,null);return e.get(n)}throw new a(null,s.InvalidMemberAccessKey,null)}if(e instanceof Te){if(_(n))return e.global(n);throw new a(null,s.InvalidMemberAccessKey,null)}throw new a(null,s.InvalidMemberAccessKey,null)},callfunc:(e,n,t)=>e.call(t,{arguments:n,preparsed:!0}),loadModule(e,n){const t=n.moduleFactoryMap[e];if(n.moduleSingletons[t])return n.moduleSingletons[t];const o=n.moduleFactory[t]({vars:{},moduleSingletons:n.moduleSingletons,depthCounter:n.depthCounter,console:n.console,abortSignal:n.abortSignal,isAsync:n.isAsync,services:n.services,lrucache:n.lrucache,timeZone:n.timeZone??null,interceptor:n.interceptor},n.spatialReference);return n.moduleSingletons[t]=o,o},callModuleFunction(e,n,t,o){if(!(e instanceof Te))throw new a(null,s.FunctionNotFound,null);const l=e.global(t);if(!1===f(l))throw new a(null,s.CallNonFunction,null);return l.call(o,{preparsed:!0,arguments:n})},getNestedOptionalValue:(e,n)=>l(e,n)};function Ke(e){console.log(e)}function Pe(e,n,o=!1){null===n&&(n={vars:{},customfunctions:{}});let l=null;e.usesModules&&(l=new t(null,e.loadedModules));const r={isAsync:o,globalScope:Be(n.vars,o?ke:_e,n.customfunctions),moduleFactory:{},moduleFactoryMap:{},undeclaredGlobalsInFunctions:new Map,customfunctions:n.customfunctions,libraryResolver:l,localScope:null,mangleMap:{},depthCounter:{depth:1},exports:{},console:Ke,lrucache:n.lrucache,timeZone:n.timeZone??null,interceptor:n.interceptor,services:n.services,symbols:{symbolCounter:0}};let c=ie(r,e);""===c&&(c="lc.voidOperation; "),r.undeclaredGlobalsInFunctions.size>0&&r.undeclaredGlobalsInFunctions.forEach((e=>{throw new i(n,s.InvalidIdentifier,e.node)}));let u="";u=o?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+c+"\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 "+c+"\n return lastStatement; } \n return this.postProcess(mainBody()); ";const p=r.moduleFactory,m=r.moduleFactoryMap,g=r.exports,d={};let h;for(h in g)d[h]=r.mangleMap[h]??h;const F={lc:y,lang:Ze,mangles:r.mangleMap,postProcess(e){if(e instanceof b&&(e=e.value),e instanceof w&&(e=e.value),e===S&&(e=null),e===v)throw new a(null,s.IllegalResult,null);if(e===x)throw new a(null,s.IllegalResult,null);if(f(e))throw new a(null,s.IllegalResult,null);return e},prepare(e,n){let t=e.spatialReference;null==t&&(t=z.WebMercator);const o=je(e.vars,e.customfunctions,n,e.timeZone);return{localStack:[],isAsync:n,moduleFactory:p,moduleFactoryMap:m,mangleMap:this.mangles,moduleSingletons:{},exports:g,gdefs:{},exportmangle:d,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??Ke,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:{depth:1}}}};return new Function("context","spatialReference",u).bind(F)}async function We(){return Re([await import("./functions/geomasync.js")],"async"),!0}class Te extends n{constructor(e){super(),this.moduleContext=e}hasGlobal(e){return void 0===this.moduleContext.exports[e]&&(e=e.toLowerCase()),void 0!==this.moduleContext.exports[e]}setGlobal(e,n){const t=this.moduleContext.globalScope,o=e.toLowerCase();if(f(n))throw new a(null,s.AssignModuleFunction,null);t[this.moduleContext.exportmangle[o]]=n}global(e){const n=this.moduleContext.globalScope,t=e.toLowerCase(),o=n[this.moduleContext.exportmangle[t]];if(void 0===o)throw new a(null,s.InvalidIdentifier,null);if(f(o)&&!(o instanceof g)){const e=new g;return e.fn=o,e.parameterEvaluator=Y,e.context=this.moduleContext,n[this.moduleContext.exportmangle[t]]=e,e}return o}}function qe(e,n,o=!1){const l={isAsync:o,moduleFactory:n.moduleFactory,moduleFactoryMap:{},libraryResolver:new t(null,e.loadedModules),globalScope:Be(n.vars,o?ke:_e,n.customfunctions),customfunctions:n.customfunctions,localScope:null,mangleMap:{},undeclaredGlobalsInFunctions:new Map,depthCounter:{depth:1},exports:{},console:Ke,lrucache:n.lrucache,timeZone:n.timeZone??null,interceptor:n.interceptor,services:n.services,symbols:{symbolCounter:0}};let r=ie(l,e);""===r&&(r="lc.voidOperation; ");let a="";a=o?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+r+"\n return lastStatement; }); } \n yield mainBody(); \n return this.prepareModule(runtimeCtx); }); ":"var runtimeCtx=this.prepare(context, false);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \n function mainBody() {\n var lastStatement=lc.voidOperation;\n "+r+"\n return lastStatement; } \n mainBody(); \n return this.prepareModule(runtimeCtx); ";const s=l.moduleFactory,i=l.moduleFactoryMap,c=l.exports,u={};let p;for(p in c)u[p]=l.mangleMap[p]??p;const m={lc:y,lang:Ze,mangles:l.mangleMap,prepareModule:e=>new Te(e),prepare(e,n){let t=e.spatialReference;null==t&&(t=new z({wkid:102100}));const o=je(e.vars,e.customfunctions,n,e.timeZone);return{localStack:[],isAsync:n,exports:c,exportmangle:u,gdefs:{},moduleFactory:s,moduleFactoryMap:i,moduleSingletons:e.moduleSingletons,mangleMap:this.mangles,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??Ke,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:e.depthCounter}}};return new Function("context","spatialReference",a).bind(m)}export{V as UserDefinedCompiledFunction,Pe as compileScript,We as enableAsyncSupport,De as executeScript,Re as extend,Ne as functionHelper};
|
|
5
|
+
import{toSymbolId as e}from"./arcadeEnvironment.js";import{ArcadeModule as n}from"./ArcadeModule.js";import{ArcadeModuleLoader as t}from"./ArcadeModuleLoader.js";import{geometryMember as o,getNestedOptionalValue as l}from"./containerUtils.js";import r from"./Dictionary.js";import{ArcadeExecutionError as a,ExecutionErrorCodes as s,ArcadeCompilationError as i,ArcadeUncompilableError as c}from"./executionError.js";import u from"./Feature.js";import{NativeFunction as p,ArcadeFunction as m,ScopeMarshalledFunction as g,wrapModuleScopedResponse as d}from"./FunctionWrapper.js";import{i as f,v as h,w as y,R as b,I as w,x as S,y as v,z as x,m as F,o as M,p as C,s as I,n as A,g as _,a as O,e as $,A as k,B as E,C as G}from"../chunks/languageUtils.js";import{addFunctionDeclaration as B}from"./treeAnalysis.js";import{A as j}from"../chunks/array.js";import{registerFunctions as N}from"./functions/date.js";import{registerFunctions as R}from"./functions/geometry.js";import{registerFunctions as L}from"./functions/geomsync.js";import{registerFunctions as U}from"./functions/maths.js";import{registerFunctions as D}from"./functions/stats.js";import{registerFunctions as Z}from"./functions/string.js";import{isPromiseLike as K}from"../core/promiseUtils.js";import P from"../geometry/Geometry.js";import W from"../geometry/SpatialReference.js";import{isGraphic as T,isNumber as q,isString as z}from"../support/guards.js";class V extends m{constructor(e,n){super(),this.paramCount=n,this.fn=e}createFunction(e){return(...n)=>{if(n.length!==this.paramCount)throw new a(e,s.WrongNumberOfParameters,null);return this.fn(...n)}}call(e,n){return this.fn(...n.arguments)}marshalledCall(e,n,t,o){return o(e,n,((n,l,r)=>{r=r.map((n=>!f(n)||n instanceof g?n:d(n,e,o)));const a=this.call(t,{arguments:r});return K(a)?a.then((e=>d(e,t,o))):a}))}}function J(e,n){const t=[];for(let o=0;o<n.arguments.length;o++)t.push(H(e,n.arguments[o]));return t}function Y(e,n,t){try{return t(e,null,n.arguments)}catch(o){throw o}}function H(e,n){switch(n.type){case"AssignmentExpression":return le(e,n);case"UpdateExpression":return te(e,n);case"TemplateLiteral":return we(e,n);case"Identifier":return xe(e,n);case"MemberExpression":return he(e,n);case"Literal":return null===n.value||void 0===n.value?"null":JSON.stringify(n.value);case"CallExpression":return Fe(e,n);case"UnaryExpression":return ye(e,n);case"BinaryExpression":return Se(e,n);case"LogicalExpression":return ve(e,n);case"ArrayExpression":return be(e,n);case"ObjectExpression":return X(e,n);default:throw new i(e,s.Unrecognized,n)}}function Q(e,n){switch(n.type){case"EmptyStatement":return"lc.voidOperation";case"VariableDeclaration":return de(e,n);case"BlockStatement":return ie(e,n);case"FunctionDeclaration":return ge(e,n);case"ImportDeclaration":return ue(e,n);case"ExportNamedDeclaration":return pe(e,n);case"ReturnStatement":return ce(e,n);case"IfStatement":return se(e,n);case"ExpressionStatement":return re(e,n);case"BreakStatement":return"break";case"ContinueStatement":return"continue";case"ForStatement":return ne(e,n);case"ForInStatement":return ee(e,n);case"WhileStatement":return oe(e,n);default:throw new i(e,s.Unrecognized,n)}}function X(e,n){let t="lang.dictionary([";for(let o=0;o<n.properties.length;o++){const l=n.properties[o];let r;"Identifier"===l.key.type?(me(l.key.name),r="'"+l.key.name+"'"):r=H(e,l.key);o>0&&(t+=","),t+="lang.strCheck("+r+",'ObjectExpression'),lang.aCheck("+H(e,l.value)+", 'ObjectExpression')"}return t+="])",t}function ee(n,t){const o=$e(n),l=$e(n),r=$e(n);let a="var "+o+" = "+H(n,t.right)+";\n";"VariableDeclaration"===t.left.type&&(a+=Q(n,t.left));const s=e("VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);me(s);let i="";null!==n.localScope&&(void 0!==n.localScope[s]?i="lscope['"+s+"']":void 0!==n.localScope._SymbolsMap[s]&&(i="lscope['"+n.localScope._SymbolsMap[s]+"']"));let c="";if(""===i)if(void 0!==n.globalScope[s])i="gscope['"+s+"']";else if(void 0!==n.globalScope._SymbolsMap[s])i="gscope['"+n.globalScope._SymbolsMap[s]+"']";else if(null!==n.localScope)if(n.undeclaredGlobalsInFunctions.has(s))i="gscope['"+n.undeclaredGlobalsInFunctions.get(s).manglename+"']",c=n.undeclaredGlobalsInFunctions.get(s).manglename;else{const e={manglename:Oe(n),node:t.left};n.undeclaredGlobalsInFunctions.set(s,e),i="gscope['"+e.manglename+"']",c=e.manglename}return c&&(a+="lang.chkAssig('"+c+"',runtimeCtx); \n"),a+="if ("+o+"===null) { lastStatement = lc.voidOperation; }\n ",a+="else if (lc.isArray("+o+") || lc.isString("+o+")) {",a+="var "+l+"="+o+".length; \n",a+="for(var "+r+"=0; "+r+"<"+l+"; "+r+"++) {\n",a+=i+"="+r+";\n",a+=Q(n,t.body),a+="\n}\n",a+=" lastStatement = lc.voidOperation; \n",a+=" \n}\n",a+="else if (lc.isImmutableArray("+o+")) {",a+="var "+l+"="+o+".length(); \n",a+="for(var "+r+"=0; "+r+"<"+l+"; "+r+"++) {\n",a+=i+"="+r+";\n",a+=Q(n,t.body),a+="\n}\n",a+=" lastStatement = lc.voidOperation; \n",a+=" \n}\n",a+="else if (( "+o+" instanceof lang.Dictionary) || ( "+o+" instanceof lang.Feature)) {",a+="var "+l+"="+o+".keys(); \n",a+="for(var "+r+"=0; "+r+"<"+l+".length; "+r+"++) {\n",a+=i+"="+l+"["+r+"];\n",a+=Q(n,t.body),a+="\n}\n",a+=" lastStatement = lc.voidOperation; \n",a+=" \n}\n",n.isAsync&&(a+="else if (lc.isFeatureSet("+o+")) {",a+="var "+l+"="+o+".iterator(runtimeCtx.abortSignal); \n",a+="for(var "+r+"=lang. graphicToFeature( yield "+l+".next(),"+o+", runtimeCtx); "+r+"!=null; "+r+"=lang. graphicToFeature( yield "+l+".next(),"+o+", runtimeCtx)) {\n",a+=i+"="+r+";\n",a+=Q(n,t.body),a+="\n}\n",a+=" lastStatement = lc.voidOperation; \n",a+=" \n}\n"),a+="else { lastStatement = lc.voidOperation; } \n",a}function ne(e,n){let t="lastStatement = lc.voidOperation; \n";null!==n.init&&("VariableDeclaration"===n.init.type?t+=Q(e,n.init):t+=H(e,n.init)+"; ");const o=$e(e),l=$e(e);return t+="var "+o+" = true; ",t+="\n do { ",null!==n.update&&(t+=" if ("+o+"===false) {\n "+H(e,n.update)+" \n}\n "+o+"=false; \n"),null!==n.test&&(t+="var "+l+" = "+H(e,n.test)+"; ",t+="if ("+l+"===false) { break; } else if ("+l+"!==true) { lang.error('"+s.BooleanConditionRequired+"'); }\n"),t+=Q(e,n.body),null!==n.update&&(t+="\n "+H(e,n.update)),t+="\n"+o+" = true; \n} while(true); lastStatement = lc.voidOperation; ",t}function te(n,t){if("CallExpression"===t.argument.type)throw new i(n,s.NeverReach,t);let o;if("MemberExpression"===t.argument.type){const e=H(n,t.argument.object);return!0===t.argument.computed?o=H(n,t.argument.property):(me(t.argument.property.name),o="'"+t.argument.property.name+"'"),"lang.memberupdate("+e+","+o+",'"+t.operator+"',"+t.prefix+")"}const l=e(t.argument);if(me(l),null!==n.localScope){if(void 0!==n.localScope[l])return"lang.update(lscope, '"+l+"','"+t.operator+"',"+t.prefix+")";if(void 0!==n.localScope._SymbolsMap[l])return"lang.update(lscope, '"+n.localScope._SymbolsMap[l]+"','"+t.operator+"',"+t.prefix+")"}if(void 0!==n.globalScope[l])return"lang.update(gscope, '"+l+"','"+t.operator+"',"+t.prefix+")";if(void 0!==n.globalScope._SymbolsMap[l])return"lang.update(gscope, '"+n.globalScope._SymbolsMap[l]+"','"+t.operator+"',"+t.prefix+")";if(null!==n.localScope){if(n.undeclaredGlobalsInFunctions.has(l))return"lang.update(gscope,lang.chkAssig( '"+n.undeclaredGlobalsInFunctions.get(l).manglename+"',runtimeCtx),'"+t.operator+"',"+t.prefix+")";const e={manglename:Oe(n),node:t.argument};return n.undeclaredGlobalsInFunctions.set(l,e),"lang.update(gscope, lang.chkAssig('"+e.manglename+"',runtimeCtx),'"+t.operator+"',"+t.prefix+")"}throw new a(n,s.InvalidIdentifier,t)}function oe(e,n){let t="lastStatement = lc.voidOperation; \n";const o=$e(e);return t+=`\n var ${o} = true;\n do {\n ${o} = ${H(e,n.test)};\n if (${o}==false) {\n break;\n }\n if (${o}!==true) {\n lang.error('${s.BooleanConditionRequired}');\n }\n ${Q(e,n.body)}\n }\n while (${o} !== false);\n lastStatement = lc.voidOperation;\n `,t}function le(n,t){const o=H(n,t.right);if("MemberExpression"===t.left.type){let e;const l=H(n,t.left.object);return!0===t.left.computed?e=H(n,t.left.property):(e="'"+t.left.property.name+"'",me(t.left.property.name)),"lang.assignmember("+l+","+e+",'"+t.operator+"',"+o+")"}const l=e(t.left);if(me(l),null!==n.localScope){if(void 0!==n.localScope[l])return"lscope['"+l+"']=lang.assign("+o+",'"+t.operator+"', lscope['"+l+"'])";if(void 0!==n.localScope._SymbolsMap[l])return"lscope['"+n.localScope._SymbolsMap[l]+"']=lang.assign("+o+",'"+t.operator+"', lscope['"+n.localScope._SymbolsMap[l]+"'])"}if(void 0!==n.globalScope[l])return"gscope['"+l+"']=lang.assign("+o+",'"+t.operator+"', gscope['"+l+"'])";if(void 0!==n.globalScope._SymbolsMap[l])return"gscope['"+n.globalScope._SymbolsMap[l]+"']=lang.assign("+o+",'"+t.operator+"', gscope['"+n.globalScope._SymbolsMap[l]+"'])";if(null!==n.localScope){if(n.undeclaredGlobalsInFunctions.has(l))return"gscope[lang.chkAssig('"+n.undeclaredGlobalsInFunctions.get(l).manglename+"',runtimeCtx)]=lang.assign("+o+",'"+t.operator+"', gscope['"+n.undeclaredGlobalsInFunctions.get(l).manglename+"'])";const e={manglename:Oe(n),node:t.left};return n.undeclaredGlobalsInFunctions.set(l,e),"gscope[lang.chkAssig('"+e.manglename+"',runtimeCtx)]=lang.assign("+o+",'"+t.operator+"', gscope['"+e.manglename+"'])"}throw new a(n,s.InvalidIdentifier,t)}function re(e,n){return"AssignmentExpression"===n.expression.type?"lastStatement = lc.voidOperation; "+H(e,n.expression)+"; \n ":"lastStatement = "+H(e,n.expression)+"; "}function ae(e,n){return"BlockStatement"===n.type?Q(e,n):"ReturnStatement"===n.type||"BreakStatement"===n.type||"ContinueStatement"===n.type?Q(e,n)+"; ":"ExpressionStatement"===n.type?Q(e,n):Q(e,n)+"; "}function se(e,n){return`if (lang.mustBoolean(${H(e,n.test)}, runtimeCtx) === true) {\n ${ae(e,n.consequent)}\n } `+(null!==n.alternate?"IfStatement"===n.alternate.type?" else "+se(e,n.alternate):` else {\n ${ae(e,n.alternate)}\n }\n`:" else {\n lastStatement = lc.voidOperation;\n }\n")}function ie(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+=Q(e,n.body[o])+"; \n":t+=Q(e,n.body[o])+" \n");return t}function ce(e,n){if(null===n.argument)return"return lc.voidOperation";return"return "+H(e,n.argument)}function ue(n,t){const o=e(t.specifiers[0].local);me(o);const l=n.libraryResolver?.loadLibrary(o),r=Oe(n);void 0===n.moduleFactory[l.uri]&&(n.moduleFactory[l.uri]=qe(l.syntax,{interceptor:n.interceptor,services:n.services,moduleFactory:n.moduleFactory,lrucache:n.lrucache,timeZone:n.timeZone??null,libraryResolver:n.libraryResolver,customfunctions:n.customfunctions,vars:{}},n.isAsync)),n.moduleFactoryMap[r]=l.uri;let a,s="";return s=n.isAsync?"(yield lang.loadModule('"+r+"', runtimeCtx) ); ":"lang.loadModule('"+r+"', runtimeCtx); ",void 0!==n.globalScope[o]?"gscope['"+o+"']="+s:void 0!==n.globalScope._SymbolsMap[o]?"gscope['"+n.globalScope._SymbolsMap[o]+"']="+s:(n.undeclaredGlobalsInFunctions.has(o)?(a=n.undeclaredGlobalsInFunctions.get(o).manglename,n.undeclaredGlobalsInFunctions.delete(o)):a=Oe(n),n.globalScope._SymbolsMap[o]=a,n.mangleMap[o]=a,"gscope[lang.setAssig('"+a+"', runtimeCtx)]="+s)}function pe(n,t){const o=Q(n,t.declaration);if("FunctionDeclaration"===t.declaration.type)n.exports[e(t.declaration.id)]="function";else if("VariableDeclaration"===t.declaration.type)for(const l of t.declaration.declarations)n.exports[e(l.id)]="variable";return o}function me(e){if("iif"===e)throw new c;if("decode"===e)throw new c;if("when"===e)throw new c;if("defaultvalue"===e)throw new c}function ge(n,t){const o=e(t.id);let l;me(o);let r=!1;void 0!==n.globalScope[o]?l=o:void 0!==n.globalScope._SymbolsMap[o]?l=n.globalScope._SymbolsMap[o]:n.undeclaredGlobalsInFunctions.has(o)?(l=n.undeclaredGlobalsInFunctions.get(o).manglename,n.globalScope._SymbolsMap[o]=l,n.mangleMap[o]=l,n.undeclaredGlobalsInFunctions.delete(o),r=!0):(l=Oe(n),n.globalScope._SymbolsMap[o]=l,n.mangleMap[o]=l);const a={isAsync:n.isAsync,console:n.console,exports:n.exports,undeclaredGlobalsInFunctions:n.undeclaredGlobalsInFunctions,customfunctions:n.customfunctions,moduleFactory:n.moduleFactory,moduleFactoryMap:n.moduleFactoryMap,libraryResolver:n.libraryResolver,lrucache:n.lrucache,interceptor:n.interceptor,services:n.services,symbols:n.symbols,mangleMap:n.mangleMap,localScope:{_SymbolsMap:{}},depthCounter:n.depthCounter,globalScope:n.globalScope};let s="new lang.UserDefinedCompiledFunction( lang.functionDepthchecker(function() { var lastStatement = lc.voidOperation; \n var lscope = runtimeCtx.localStack[runtimeCtx.localStack.length-1];\n";for(let i=0;i<t.params.length;i++){const o=e(t.params[i]);me(o);const l=Oe(n);a.localScope._SymbolsMap[o]=l,a.mangleMap[o]=l,s+="lscope['"+l+"']=arguments["+i.toString()+"];\n"}return!0===n.isAsync?(s+="return lang.__awaiter(this, void 0, void 0, function* () {\n",s+=ie(a,t.body)+"\n return lastStatement; ",s+="}); }",s+=", runtimeCtx),"+t.params.length+")",s+="\n lastStatement = lc.voidOperation; \n"):(s+=ie(a,t.body)+"\n return lastStatement; }, runtimeCtx),"+t.params.length+")",s+="\n lastStatement = lc.voidOperation; \n"),r?"gscope[lang.setAssig('"+l+"', runtimeCtx)]="+s:"gscope['"+l+"']="+s}function de(e,n){const t=[];for(let o=0;o<n.declarations.length;o++)t.push(fe(e,n.declarations[o]));return t.join("\n")+" \n lastStatement= lc.voidOperation; \n"}function fe(n,t){const o=null===t.init?null:H(n,t.init),l=e(t.id);if(me(l),null!==n.localScope){if(void 0!==n.localScope[l])return"lscope['"+l+"']="+o+"; ";if(void 0!==n.localScope._SymbolsMap[l])return"lscope['"+n.localScope._SymbolsMap[l]+"']="+o+"; ";const e=Oe(n);return n.localScope._SymbolsMap[l]=e,n.mangleMap[l]=e,"lscope['"+e+"']="+o+"; "}if(void 0!==n.globalScope[l])return"gscope['"+l+"']="+o+"; ";if(void 0!==n.globalScope._SymbolsMap[l])return"gscope['"+n.globalScope._SymbolsMap[l]+"']="+o+"; ";if(n.undeclaredGlobalsInFunctions.has(l)){const e=n.undeclaredGlobalsInFunctions.get(l).manglename;return n.globalScope._SymbolsMap[l]=e,n.mangleMap[l]=e,n.undeclaredGlobalsInFunctions.delete(l),"gscope[lang.setAssig('"+e+"', runtimeCtx)]="+o+"; "}const r=Oe(n);return n.globalScope._SymbolsMap[l]=r,n.mangleMap[l]=r,"gscope['"+r+"']="+o+"; "}function he(e,n){try{let t;return!0===n.computed?t=H(e,n.property):(me(n.property.name),t="'"+n.property.name+"'"),"lang.member("+H(e,n.object)+","+t+")"}catch(t){throw t}}function ye(e,n){try{return"lang.unary("+H(e,n.argument)+",'"+n.operator+"')"}catch(t){throw t}}function be(e,n){try{const t=[];for(let o=0;o<n.elements.length;o++)"Literal"===n.elements[o].type?t.push(H(e,n.elements[o])):t.push("lang.aCheck("+H(e,n.elements[o])+",'ArrayExpression')");return"["+t.join(",")+"]"}catch(t){throw t}}function we(e,n){try{const t=[];let o=0;for(const l of n.quasis)t.push(l.value?JSON.stringify(l.value.cooked):JSON.stringify("")),!1===l.tail&&(t.push(n.expressions[o]?"lang.castString(lang.aCheck("+H(e,n.expressions[o])+", 'TemplateLiteral'))":""),o++);return"(["+t.join(",")+"]).join('')"}catch(t){throw t}}function Se(e,n){try{return"lang.binary("+H(e,n.left)+","+H(e,n.right)+",'"+n.operator+"')"}catch(t){throw t}}function ve(e,n){try{if("AssignmentExpression"===n.left.type||"UpdateExpression"===n.left.type)throw new i(e,s.LogicalExpressionOnlyBoolean,n);if("AssignmentExpression"===n.right.type||"UpdateExpression"===n.right.type)throw new i(e,s.LogicalExpressionOnlyBoolean,n);if("&&"===n.operator||"||"===n.operator)return"(lang.logicalCheck("+H(e,n.left)+") "+n.operator+" lang.logicalCheck("+H(e,n.right)+"))";throw new i(null,s.LogicExpressionOrAnd,null)}catch(t){throw t}}function xe(n,t){try{const o=e(t);if(me(o),null!==n.localScope){if(void 0!==n.localScope[o])return"lscope['"+o+"']";if(void 0!==n.localScope._SymbolsMap[o])return"lscope['"+n.localScope._SymbolsMap[o]+"']"}if(void 0!==n.globalScope[o])return"gscope['"+o+"']";if(void 0!==n.globalScope._SymbolsMap[o])return"gscope['"+n.globalScope._SymbolsMap[o]+"']";if(null!==n.localScope){if(n.undeclaredGlobalsInFunctions.has(o))return"gscope[lang.chkAssig('"+n.undeclaredGlobalsInFunctions.get(o).manglename+"',runtimeCtx)]";const e={manglename:Oe(n),node:t};return n.undeclaredGlobalsInFunctions.set(o,e),"gscope[lang.chkAssig('"+e.manglename+"',runtimeCtx)]"}throw new i(n,s.InvalidIdentifier,t)}catch(o){throw o}}function Fe(n,t){try{if("MemberExpression"===t.callee.type){let e;!0===t.callee.computed?e=H(n,t.callee.property):(me(t.callee.property.name),e="'"+t.callee.property.name+"'");let o="[";for(let l=0;l<t.arguments.length;l++)l>0&&(o+=", "),o+=H(n,t.arguments[l]);return o+="]",n.isAsync?"(yield lang.callModuleFunction("+H(n,t.callee.object)+","+o+","+e+",runtimeCtx))":"lang.callModuleFunction("+H(n,t.callee.object)+","+o+","+e+",runtimeCtx)"}if("Identifier"!==t.callee.type)throw new i(n,s.FunctionNotFound,t);const o=e(t.callee);if("iif"===o)return Me(n,t);if("when"===o)return Ie(n,t);if("defaultvalue"===o)return Ce(n,t);if("decode"===o)return Ae(n,t);let l="";if(null!==n.localScope&&(void 0!==n.localScope[o]?l="lscope['"+o+"']":void 0!==n.localScope._SymbolsMap[o]&&(l="lscope['"+n.localScope._SymbolsMap[o]+"']")),""===l)if(void 0!==n.globalScope[o])l="gscope['"+o+"']";else if(void 0!==n.globalScope._SymbolsMap[o])l="gscope['"+n.globalScope._SymbolsMap[o]+"']";else if(null!==n.localScope)if(n.undeclaredGlobalsInFunctions.has(o))l="gscope[lang.chkAssig('"+n.undeclaredGlobalsInFunctions.get(o).manglename+"',runtimeCtx)]";else{const e={manglename:Oe(n),node:t.callee};n.undeclaredGlobalsInFunctions.set(o,e),l="gscope[lang.chkAssig('"+e.manglename+"',runtimeCtx)]"}if(""!==l){let e="[";for(let o=0;o<t.arguments.length;o++)o>0&&(e+=", "),e+=H(n,t.arguments[o]);return e+="]",n.isAsync?"(yield lang.callfunc("+l+","+e+",runtimeCtx) )":"lang.callfunc("+l+","+e+",runtimeCtx)"}throw new i(n,s.FunctionNotFound,t)}catch(o){throw o}}function Me(e,n){try{if(3!==n.arguments.length)throw new i(e,s.WrongNumberOfParameters,n);const t=$e(e);return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${H(e,n.arguments[0])};\n\n if (${t} === true) {\n return ${H(e,n.arguments[1])};\n }\n else if (${t} === false) {\n return ${H(e,n.arguments[2])};\n }\n else {\n lang.error('ExecutionErrorCodes.BooleanConditionRequired');\n }\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Ce(e,n){try{if(n.arguments.length<2||n.arguments.length>3)throw new i(e,s.WrongNumberOfParameters,n);const t=$e(e),o=$e(e);return 3===n.arguments.length?`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${H(e,n.arguments[0])};\n var ${o} = ${H(e,n.arguments[1])};\n ${t} = lang.getNestedOptionalValue(${t}, ${o});\n return ${t} != null && ${t} !== "" ? ${t} : ${H(e,n.arguments[2])};\n ${e.isAsync?"})}()))":"}()"}`:`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${H(e,n.arguments[0])};\n if (${t} === null) {\n return ${H(e,n.arguments[1])};\n }\n if (${t} === "") {\n return ${H(e,n.arguments[1])};\n }\n if (${t} === undefined) {\n return ${H(e,n.arguments[1])};\n }\n return ${t};\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Ie(e,n){try{if(n.arguments.length<3)throw new i(e,s.WrongNumberOfParameters,n);if(n.arguments.length%2==0)throw new i(e,s.WrongNumberOfParameters,n);const t=$e(e);let o="var ";for(let l=0;l<n.arguments.length-1;l+=2)o+=`${t} = lang.mustBoolean(${H(e,n.arguments[l])}, runtimeCtx);\n if (${t} === true ) {\n return ${H(e,n.arguments[l+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n ${o}\n return ${H(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Ae(e,n){try{if(n.arguments.length<2)throw new i(e,s.WrongNumberOfParameters,n);if(2===n.arguments.length)return`(${H(e,n.arguments[1])})`;if((n.arguments.length-1)%2==0)throw new i(e,s.WrongNumberOfParameters,n);const t=$e(e),o=$e(e);let l="var ";for(let r=1;r<n.arguments.length-1;r+=2)l+=`${o} = ${H(e,n.arguments[r])};\n if (lang.binary(${o}, ${t}, "==") === true ) {\n return ${H(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} = ${H(e,n.arguments[0])};\n ${l}\n return ${H(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}const _e={};function Oe(e){return e.symbols.symbolCounter++,`_T${e.symbols.symbolCounter}`}function $e(e){return e.symbols.symbolCounter++,`_Tvar${e.symbols.symbolCounter}`}N(_e,Y),Z(_e,Y),U(_e,Y),R(_e,Y),D(_e,Y),_e.iif=function(e,n){try{return Y(e,n,((t,o,l)=>{throw new a(e,s.Unrecognized,n)}))}catch(t){throw t}},_e.decode=function(e,n){try{return Y(e,n,((t,o,l)=>{throw new a(e,s.Unrecognized,n)}))}catch(t){throw t}},_e.when=function(e,n){try{return Y(e,n,((t,o,l)=>{throw new a(e,s.Unrecognized,n)}))}catch(t){throw t}},_e.defaultvalue=function(e,n){try{return Y(e,n,((t,o,l)=>{throw new a(e,s.Unrecognized,n)}))}catch(t){throw t}};const ke={};for(const ze in _e)ke[ze]=new p(_e[ze]);L(_e,Y);for(const ze in _e)_e[ze]=new p(_e[ze]);const Ee=function(){};Ee.prototype=_e;const Ge=function(){};function Be(e,n,t){const o={_SymbolsMap:{}};e||(e={}),t||(t={}),o.textformatting=1,o.infinity=1,o.pi=1;for(const l in n)o[l]=1;for(const l in t)o[l]=1;for(const l in e)o[l]=1;return o}function je(e,n,t,o){const l=t?new Ge:new Ee;e||(e={}),n||(n={});const a=new r({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 r in n)l[r]=n[r],l._SymbolsMap[r]=1;for(const r in e){const n=e[r];l._SymbolsMap[r]=1,T(n)?l[r]=u.createFromGraphic(n,o??null):l[r]=n}return l}Ge.prototype=ke;const Ne={fixSpatialReference:h,parseArguments:J,standardFunction:Y};function Re(e,n){const t={mode:n,compiled:!0,functions:{},signatures:[],standardFunction:Y,standardFunctionAsync:Y,evaluateIdentifier:Ue};for(let o=0;o<e.length;o++)e[o].registerFunctions(t);if("sync"===n){for(const e in t.functions)_e[e]=new p(t.functions[e]),Ee.prototype[e]=_e[e];for(let e=0;e<t.signatures.length;e++)B(t.signatures[e],"sync")}else{for(const e in t.functions)ke[e]=new p(t.functions[e]),Ge.prototype[e]=ke[e];for(let e=0;e<t.signatures.length;e++)B(t.signatures[e],"async")}}function Le(e,n){return e(n)}function Ue(e,n){const t=n.name;if("_SymbolsMap"===t)throw new a(e,s.InvalidIdentifier,null);if(e.localStack.length>0){if(!t.toLowerCase().startsWith("_t")&&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.toLowerCase().startsWith("_t")&&void 0!==e.globalScope[t])return e.globalScope[t];if(1===e.globalScope._SymbolsMap[t])return e.globalScope[t];const o=e.mangleMap[t];return void 0!==o?e.globalScope[o]:void 0}Re([j],"sync"),Re([j],"async");let De=0;const Ze={isNumber:e=>q(e),isArray:e=>F(e),isImmutableArray:e=>M(e),isFeature:e=>C(e),isString:e=>z(e),isDictionary:e=>I(e),isGeometry:e=>A(e),geometryMember:(e,n,t,l,r=1)=>o(e,n,t,l,r),error(e){throw new a(null,e,null)},__awaiter:(e,n,t,o)=>new Promise(((t,l)=>{function r(e){try{s(o.next(e))}catch(n){l(n)}}function a(e){try{s(o.throw(e))}catch(n){l(n)}}function s(e){e.done?t(e.value):e.value?.then?e.value.then(r,a):(De++,De%100==0?setTimeout((()=>{De=0,r(e.value)}),0):r(e.value))}s((o=o.apply(e,n||[])).next())})),functionDepthchecker:(e,n)=>function(){if(n.depthCounter.depth++,n.localStack.push({}),n.depthCounter.depth>64)throw new a(null,s.MaximumCallDepth,null);const t=e.apply(this,arguments);return K(t)?t.then((e=>(n.depthCounter.depth--,n.localStack.length=n.localStack.length-1,e))):(n.depthCounter.depth--,n.localStack.length=n.localStack.length-1,t)},chkAssig(e,n){if(void 0===n.gdefs[e])throw new a(n,s.InvalidIdentifier,null);return e},mustBoolean(e,n){if(!0===e||!1===e)return e;throw new a(n,s.BooleanConditionRequired,null)},setAssig:(e,n)=>(n.gdefs[e]=1,e),castString:e=>_(e),aCheck(e,n){if(f(e)){if("ArrayExpression"===n)throw new a(null,s.NoFunctionInArray,null);if("ObjectExpression"===n)throw new a(null,s.NoFunctionInDictionary,null);throw new a(null,s.NoFunctionInTemplateLiteral,null)}return e===S?null:e},Dictionary:r,Feature:u,UserDefinedCompiledFunction:V,dictionary(e){const n={},t=new Map;for(let l=0;l<e.length;l+=2){if(f(e[l+1]))throw new a(null,s.NoFunctionInDictionary,null);if(!1===z(e[l]))throw new a(null,s.KeyMustBeString,null);let o=e[l].toString();const r=o.toLowerCase();t.has(r)?o=t.get(r):t.set(r,o),e[l+1]===S?n[o]=null:n[o]=e[l+1]}const o=new r(n);return o.immutable=!1,o},strCheck(e){if(!1===z(e))throw new a(null,s.KeyMustBeString,null);return e},unary(e,n){if(O(e)){if("!"===n)return!e;if("-"===n)return-1*$(e);if("+"===n)return 1*$(e);if("~"===n)return~$(e);throw new a(null,s.UnsupportedUnaryOperator,null)}if("-"===n)return-1*$(e);if("+"===n)return 1*$(e);if("~"===n)return~$(e);throw new a(null,s.UnsupportedUnaryOperator,null)},logicalCheck(e){if(!1===O(e))throw new a(null,s.LogicExpressionOrAnd,null);return e},logical(e,n,t){if(O(e)&&O(n))switch(t){case"||":return e||n;case"&&":return e&&n;default:throw new a(null,s.LogicExpressionOrAnd,null)}throw new a(null,s.LogicExpressionOrAnd,null)},binary(e,n,t){switch(t){case"|":case"<<":case">>":case">>>":case"^":case"&":return G($(e),$(n),t);case"==":case"=":return E(e,n);case"!=":return!E(e,n);case"<":case">":case"<=":case">=":return k(e,n,t);case"+":return z(e)||z(n)?_(e)+_(n):$(e)+$(n);case"-":return $(e)-$(n);case"*":return $(e)*$(n);case"/":return $(e)/$(n);case"%":return $(e)%$(n);default:throw new a(null,s.UnsupportedOperator,null)}},assign(e,n,t){switch(n){case"=":return e===S?null:e;case"/=":return $(t)/$(e);case"*=":return $(t)*$(e);case"-=":return $(t)-$(e);case"+=":return z(t)||z(e)?_(t)+_(e):$(t)+$(e);case"%=":return $(t)%$(e);default:throw new a(null,s.UnsupportedOperator,null)}},update(e,n,t,o){const l=$(e[n]);return e[n]="++"===t?l+1:l-1,!1===o?l:"++"===t?l+1:l-1},graphicToFeature:(e,n,t)=>null===e?null:u.createFromGraphicLikeObject(e.geometry,e.attributes,n,t.timeZone),memberupdate(e,n,t,o){let l;if(F(e)){if(!q(n))throw new a(null,s.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>=e.length)throw new a(null,s.OutOfBounds,null);l=$(e[n]),e[n]="++"===t?l+1:l-1}else if(e instanceof r){if(!1===z(n))throw new a(null,s.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new a(null,s.FieldNotFound,null,{key:n});l=$(e.field(n)),e.setField(n,"++"===t?l+1:l-1)}else if(C(e)){if(!1===z(n))throw new a(null,s.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new a(null,s.FieldNotFound,null);l=$(e.field(n)),e.setField(n,"++"===t?l+1:l-1)}else{if(M(e))throw new a(null,s.Immutable,null);if(!(e instanceof Te))throw new a(null,s.InvalidIdentifier,null);if(!1===z(n))throw new a(null,s.ModuleAccessorMustBeString,null);if(!0!==e.hasGlobal(n))throw new a(null,s.ModuleExportNotFound,null);l=$(e.global(n)),e.setGlobal(n,"++"===t?l+1:l-1)}return!1===o?l:"++"===t?l+1:l-1},assignmember(e,n,t,o){if(F(e)){if(!q(n))throw new a(null,s.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>e.length)throw new a(null,s.OutOfBounds,null);if(n===e.length){if("="!==t)throw new a(null,s.OutOfBounds,null);e[n]=this.assign(o,t,e[n])}else e[n]=this.assign(o,t,e[n])}else if(e instanceof r){if(!1===z(n))throw new a(null,s.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(o,t,e.field(n)));else{if("="!==t)throw new a(null,s.FieldNotFound,null);e.setField(n,this.assign(o,t,null))}}else if(C(e)){if(!1===z(n))throw new a(null,s.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(o,t,e.field(n)));else{if("="!==t)throw new a(null,s.FieldNotFound,null);e.setField(n,this.assign(o,t,null))}}else{if(M(e))throw new a(null,s.Immutable,null);if(!(e instanceof Te))throw new a(null,s.InvalidIdentifier,null);if(!1===z(n))throw new a(null,s.ModuleAccessorMustBeString,null);if(!e.hasGlobal(n))throw new a(null,s.ModuleExportNotFound,null);e.setGlobal(n,this.assign(o,t,e.global(n)))}},member(e,n){if(null===e)throw new a(null,s.MemberOfNull,null);if(e instanceof r||C(e)){if(z(n))return e.field(n);throw new a(null,s.InvalidMemberAccessKey,null)}if(e instanceof P){if(z(n))return o(e,n,null,null);throw new a(null,s.InvalidMemberAccessKey,null)}if(F(e)){if(q(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new a(null,s.OutOfBounds,null);return e[n]}throw new a(null,s.InvalidMemberAccessKey,null)}if(z(e)){if(q(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new a(null,s.OutOfBounds,null);return e[n]}throw new a(null,s.InvalidMemberAccessKey,null)}if(M(e)){if(q(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length()+n),n>=e.length()||n<0)throw new a(null,s.OutOfBounds,null);return e.get(n)}throw new a(null,s.InvalidMemberAccessKey,null)}if(e instanceof Te){if(z(n))return e.global(n);throw new a(null,s.InvalidMemberAccessKey,null)}throw new a(null,s.InvalidMemberAccessKey,null)},callfunc:(e,n,t)=>e.call(t,{arguments:n,preparsed:!0}),loadModule(e,n){const t=n.moduleFactoryMap[e];if(n.moduleSingletons[t])return n.moduleSingletons[t];const o=n.moduleFactory[t]({vars:{},moduleSingletons:n.moduleSingletons,depthCounter:n.depthCounter,console:n.console,abortSignal:n.abortSignal,isAsync:n.isAsync,services:n.services,lrucache:n.lrucache,timeZone:n.timeZone??null,interceptor:n.interceptor},n.spatialReference);return n.moduleSingletons[t]=o,o},callModuleFunction(e,n,t,o){if(!(e instanceof Te))throw new a(null,s.FunctionNotFound,null);const l=e.global(t);if(!1===f(l))throw new a(null,s.CallNonFunction,null);return l.call(o,{preparsed:!0,arguments:n})},getNestedOptionalValue:(e,n)=>l(e,n)};function Ke(e){console.log(e)}function Pe(e,n,o=!1){null===n&&(n={vars:{},customfunctions:{}});let l=null;e.usesModules&&(l=new t(null,e.loadedModules));const r={isAsync:o,globalScope:Be(n.vars,o?ke:_e,n.customfunctions),moduleFactory:{},moduleFactoryMap:{},undeclaredGlobalsInFunctions:new Map,customfunctions:n.customfunctions,libraryResolver:l,localScope:null,mangleMap:{},depthCounter:{depth:1},exports:{},console:Ke,lrucache:n.lrucache,timeZone:n.timeZone??null,interceptor:n.interceptor,services:n.services,symbols:{symbolCounter:0}};let c=ie(r,e);""===c&&(c="lc.voidOperation; "),r.undeclaredGlobalsInFunctions.size>0&&r.undeclaredGlobalsInFunctions.forEach((e=>{throw new i(n,s.InvalidIdentifier,e.node)}));let u="";u=o?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+c+"\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 "+c+"\n return lastStatement; } \n return this.postProcess(mainBody()); ";const p=r.moduleFactory,m=r.moduleFactoryMap,g=r.exports,d={};let h;for(h in g)d[h]=r.mangleMap[h]??h;const F={lc:y,lang:Ze,mangles:r.mangleMap,postProcess(e){if(e instanceof b&&(e=e.value),e instanceof w&&(e=e.value),e===S&&(e=null),e===v)throw new a(null,s.IllegalResult,null);if(e===x)throw new a(null,s.IllegalResult,null);if(f(e))throw new a(null,s.IllegalResult,null);return e},prepare(e,n){let t=e.spatialReference;null==t&&(t=W.WebMercator);const o=je(e.vars,e.customfunctions,n,e.timeZone);return{localStack:[],isAsync:n,moduleFactory:p,moduleFactoryMap:m,mangleMap:this.mangles,moduleSingletons:{},exports:g,gdefs:{},exportmangle:d,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??Ke,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:{depth:1}}}};return new Function("context","spatialReference",u).bind(F)}async function We(){return Re([await import("./functions/geomasync.js")],"async"),!0}class Te extends n{constructor(e){super(),this.moduleContext=e}hasGlobal(e){return void 0===this.moduleContext.exports[e]&&(e=e.toLowerCase()),void 0!==this.moduleContext.exports[e]}setGlobal(e,n){const t=this.moduleContext.globalScope,o=e.toLowerCase();if(f(n))throw new a(null,s.AssignModuleFunction,null);t[this.moduleContext.exportmangle[o]]=n}global(e){const n=this.moduleContext.globalScope,t=e.toLowerCase(),o=n[this.moduleContext.exportmangle[t]];if(void 0===o)throw new a(null,s.InvalidIdentifier,null);if(f(o)&&!(o instanceof g)){const e=new g;return e.fn=o,e.parameterEvaluator=Y,e.context=this.moduleContext,n[this.moduleContext.exportmangle[t]]=e,e}return o}}function qe(e,n,o=!1){const l={isAsync:o,moduleFactory:n.moduleFactory,moduleFactoryMap:{},libraryResolver:new t(null,e.loadedModules),globalScope:Be(n.vars,o?ke:_e,n.customfunctions),customfunctions:n.customfunctions,localScope:null,mangleMap:{},undeclaredGlobalsInFunctions:new Map,depthCounter:{depth:1},exports:{},console:Ke,lrucache:n.lrucache,timeZone:n.timeZone??null,interceptor:n.interceptor,services:n.services,symbols:{symbolCounter:0}};let r=ie(l,e);""===r&&(r="lc.voidOperation; ");let a="";a=o?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+r+"\n return lastStatement; }); } \n yield mainBody(); \n return this.prepareModule(runtimeCtx); }); ":"var runtimeCtx=this.prepare(context, false);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \n function mainBody() {\n var lastStatement=lc.voidOperation;\n "+r+"\n return lastStatement; } \n mainBody(); \n return this.prepareModule(runtimeCtx); ";const s=l.moduleFactory,i=l.moduleFactoryMap,c=l.exports,u={};let p;for(p in c)u[p]=l.mangleMap[p]??p;const m={lc:y,lang:Ze,mangles:l.mangleMap,prepareModule:e=>new Te(e),prepare(e,n){let t=e.spatialReference;null==t&&(t=new W({wkid:102100}));const o=je(e.vars,e.customfunctions,n,e.timeZone);return{localStack:[],isAsync:n,exports:c,exportmangle:u,gdefs:{},moduleFactory:s,moduleFactoryMap:i,moduleSingletons:e.moduleSingletons,mangleMap:this.mangles,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??Ke,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:e.depthCounter}}};return new Function("context","spatialReference",a).bind(m)}export{V as UserDefinedCompiledFunction,Pe as compileScript,We as enableAsyncSupport,Le as executeScript,Re as extend,Ne as functionHelper};
|
package/arcade/arcadeRuntime.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{toSymbolId as e}from"./arcadeEnvironment.js";import{ArcadeModule as t}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import{getNestedOptionalValue as r,geometryMember as o}from"./containerUtils.js";import l from"./Dictionary.js";import{ArcadeExecutionError as i,ExecutionErrorCodes as a,ensureArcadeExecutionError as s}from"./executionError.js";import c from"./Feature.js";import{NativeFunction as u,ScopeMarshalledFunction as f,ArcadeFunction as p,wrapModuleScopedResponse as h}from"./FunctionWrapper.js";import{G as d,a as w,E as m,i as g,c as v,o as y,b,g as x,r as S,q as R,z as F,j as I,D as A,F as M,R as C,I as N,A as O,B,C as E,x as j}from"../chunks/languageUtils.js";import{addFunctionDeclaration as k}from"./treeAnalysis.js";import{A as U}from"../chunks/array.js";import{registerFunctions as D}from"./functions/date.js";import{registerFunctions as L}from"./functions/geometry.js";import{registerFunctions as K}from"./functions/geomsync.js";import{registerFunctions as q}from"./functions/maths.js";import{registerFunctions as Z}from"./functions/stats.js";import{registerFunctions as G}from"./functions/string.js";import P from"../geometry/Geometry.js";import W from"../geometry/SpatialReference.js";class T extends p{constructor(e,t){super(),this.definition=e,this.context=t}createFunction(e){return(...t)=>{const n={spatialReference:this.context.spatialReference,console:this.context.console,services:this.context.services,timeZone:this.context.timeZone??null,lrucache:this.context.lrucache,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,localScope:{},depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope};if(n.depthCounter.depth>64)throw new i(e,a.MaximumCallDepth,null);return Ie(this.definition,n,t,null)}}call(e,t){return z(e,t,((n,r,o)=>{const l={spatialReference:e.spatialReference,services:e.services,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,timeZone:e.timeZone??null,console:e.console,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};if(l.depthCounter.depth>64)throw new i(e,a.MaximumCallDepth,t);return Ie(this.definition,l,o,t)}))}marshalledCall(e,t,n,r){return r(e,t,((o,l,i)=>{const a={spatialReference:e.spatialReference,globalScope:n.globalScope,services:e.services,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};return i=i.map((t=>!g(t)||t instanceof f?t:h(t,e,r))),h(Ie(this.definition,a,i,t),n,r)}))}}class V extends t{constructor(e){super(),this.source=e}global(e){const t=this.executingContext.globalScope[e.toLowerCase()];if(t.valueset||(t.value=Y(this.executingContext,t.node),t.valueset=!0),g(t.value)&&!(t.value instanceof f)){const e=new f;e.fn=t.value,e.parameterEvaluator=z,e.context=this.executingContext,t.value=e}return t.value}setGlobal(e,t){if(g(t))throw new i(null,a.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]}loadModule(e){let t=e.spatialReference;null==t&&(t=new W({wkid:102100})),this.moduleScope=Me({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:t,globalScope:this.moduleScope,localScope:null,libraryResolver:new n(e.libraryResolver._moduleSingletons,this.source.syntax.loadedModules),exports:{},services:e.services,console:e.console??Ne,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,depthCounter:{depth:1}},ie(this.executingContext,this.source.syntax)}}function _(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(Y(e,t.arguments[r]));return n}function z(e,t,n){try{return!0===t.preparsed?n(e,null,t.arguments):n(e,t,_(e,t))}catch(r){throw r}}function Y(e,t){try{switch(t.type){case"AssignmentExpression":return re(e,t);case"UpdateExpression":return te(e,t);case"TemplateLiteral":return ye(e,t);case"Identifier":return be(e,t);case"MemberExpression":return he(e,t);case"Literal":return t.value;case"CallExpression":return xe(e,t);case"UnaryExpression":return de(e,t);case"BinaryExpression":return me(e,t);case"LogicalExpression":return ge(e,t);case"ArrayExpression":return we(e,t);case"ObjectExpression":return J(e,t);default:throw new i(e,a.Unrecognized,t)}}catch(n){throw s(e,t,n)}}function H(e,t){switch(t.type){case"EmptyStatement":return F;case"VariableDeclaration":return fe(e,t);case"ImportDeclaration":return ce(e,t);case"ExportNamedDeclaration":return ue(e,t);case"BlockStatement":return ie(e,t);case"FunctionDeclaration":return se(e,t);case"ReturnStatement":return ae(e,t);case"IfStatement":return le(e,t);case"ExpressionStatement":return oe(e,t);case"BreakStatement":return O;case"ContinueStatement":return B;case"ForStatement":return X(e,t);case"ForInStatement":return Q(e,t);case"WhileStatement":return $(e,t);default:throw new i(e,a.Unrecognized,t)}}function J(e,t){const n={},r=new Map;for(let l=0;l<t.properties.length;l++){const o=t.properties[l],s="Identifier"===o.key.type?o.key.name:Y(e,o.key),c=Y(e,o.value);if(g(c))throw new i(e,a.NoFunctionInDictionary,t);if(!1===v(s))throw new i(e,a.KeyMustBeString,t);let u=s.toString();const f=u.toLowerCase();r.has(f)?u=r.get(f):r.set(f,u),n[u]=c===F?null:c}const o=new l(n);return o.immutable=!1,o}function Q(t,n){const r=Y(t,n.right);"VariableDeclaration"===n.left.type&&fe(t,n.left);const o=e("VariableDeclaration"===n.left.type?n.left.declarations[0].id:n.left);let s=null;if(null!=t.localScope&&void 0!==t.localScope[o]&&(s=t.localScope[o]),null===s&&void 0!==t.globalScope[o]&&(s=t.globalScope[o]),null===s)throw new i(t,a.InvalidIdentifier,n);if(y(r)||v(r)){const e=r.length;for(let r=0;r<e;r++){s.value=r;const e=H(t,n.body);if(e===O)break;if(e instanceof C)return e}return F}if(R(r)){for(let e=0;e<r.length();e++){s.value=e;const r=H(t,n.body);if(r===O)break;if(r instanceof C)return r}return F}if(r instanceof l||S(r)){const e=r.keys();for(let r=0;r<e.length;r++){s.value=e[r];const o=H(t,n.body);if(o===O)break;if(o instanceof C)return o}}return F}function X(e,t){null!==t.init&&("VariableDeclaration"===t.init.type?H(e,t.init):Y(e,t.init));const n={testResult:!0,lastAction:F};do{ee(e,t,n)}while(!0===n.testResult);return n.lastAction instanceof C?n.lastAction:F}function $(e,t){const n={testResult:!0,lastAction:F};if(n.testResult=Y(e,t.test),!1===n.testResult)return F;if(!0!==n.testResult)throw new i(e,a.BooleanConditionRequired,t);for(;!0===n.testResult&&(n.lastAction=H(e,t.body),n.lastAction!==O)&&!(n.lastAction instanceof C);)if(n.testResult=Y(e,t.test),!0!==n.testResult&&!1!==n.testResult)throw new i(e,a.BooleanConditionRequired,t);return n.lastAction instanceof C?n.lastAction:F}function ee(e,t,n){if(null!==t.test){if(n.testResult=Y(e,t.test),!1===n.testResult)return;if(!0!==n.testResult)throw new i(e,a.BooleanConditionRequired,t)}n.lastAction=H(e,t.body),n.lastAction!==O?n.lastAction instanceof C?n.testResult=!1:null!==t.update&&Y(e,t.update):n.testResult=!1}function te(t,n){if("CallExpression"===n.argument.type)throw new i(t,a.NeverReach,n);let r;if("MemberExpression"===n.argument.type){const e=Y(t,n.argument.object);let o;if(!0===n.argument.computed)o=Y(t,n.argument.property);else{if("Identifier"!==n.argument.property.type)throw new i(t,a.Unrecognized,n);o=n.argument.property.name}if(y(e)){if(!b(o))throw new i(t,a.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>=e.length)throw new i(t,a.OutOfBounds,n);r=x(e[o]),e[o]="++"===n.operator?r+1:r-1}else if(e instanceof l){if(!1===v(o))throw new i(t,a.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new i(t,a.FieldNotFound,n);r=x(e.field(o)),e.setField(o,"++"===n.operator?r+1:r-1)}else if(S(e)){if(!1===v(o))throw new i(t,a.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new i(t,a.FieldNotFound,n);r=x(e.field(o)),e.setField(o,"++"===n.operator?r+1:r-1)}else{if(R(e))throw new i(t,a.Immutable,n);if(!(e instanceof V))throw new i(t,a.InvalidParameter,n);if(!1===v(o))throw new i(t,a.ModuleAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new i(t,a.ModuleExportNotFound,n);r=x(e.global(o)),e.setGlobal(o,"++"===n.operator?r+1:r-1)}return!1===n.prefix?r:"++"===n.operator?r+1:r-1}const o=e(n.argument);if(null!=t.localScope&&void 0!==t.localScope[o])return r=x(t.localScope[o].value),t.localScope[o]={value:"++"===n.operator?r+1:r-1,valueset:!0,node:n},!1===n.prefix?r:"++"===n.operator?r+1:r-1;if(void 0!==t.globalScope[o])return r=x(t.globalScope[o].value),t.globalScope[o]={value:"++"===n.operator?r+1:r-1,valueset:!0,node:n},!1===n.prefix?r:"++"===n.operator?r+1:r-1;throw new i(t,a.InvalidIdentifier,n)}function ne(e,t,n,r,o){switch(t){case"=":return e===F?null:e;case"/=":return x(n)/x(e);case"*=":return x(n)*x(e);case"-=":return x(n)-x(e);case"+=":return v(n)||v(e)?I(n)+I(e):x(n)+x(e);case"%=":return x(n)%x(e);default:throw new i(o,a.UnsupportedOperator,r)}}function re(t,n){if("MemberExpression"===n.left.type){const e=Y(t,n.left.object);let r;if(!0===n.left.computed)r=Y(t,n.left.property);else{if("Identifier"!==n.left.property.type)throw new i(t,a.InvalidIdentifier,n);r=n.left.property.name}const o=Y(t,n.right);if(y(e)){if(!b(r))throw new i(t,a.ArrayAccessorMustBeNumber,n);if(r<0&&(r=e.length+r),r<0||r>e.length)throw new i(t,a.OutOfBounds,n);if(r===e.length){if("="!==n.operator)throw new i(t,a.OutOfBounds,n);e[r]=ne(o,n.operator,e[r],n,t)}else e[r]=ne(o,n.operator,e[r],n,t)}else if(e instanceof l){if(!1===v(r))throw new i(t,a.KeyAccessorMustBeString,n);if(!0===e.hasField(r))e.setField(r,ne(o,n.operator,e.field(r),n,t));else{if("="!==n.operator)throw new i(t,a.FieldNotFound,n,{key:r});e.setField(r,ne(o,n.operator,null,n,t))}}else if(S(e)){if(!1===v(r))throw new i(t,a.KeyAccessorMustBeString,n);if(!0===e.hasField(r))e.setField(r,ne(o,n.operator,e.field(r),n,t));else{if("="!==n.operator)throw new i(t,a.FieldNotFound,n,{key:r});e.setField(r,ne(o,n.operator,null,n,t))}}else{if(R(e))throw new i(t,a.Immutable,n);if(!(e instanceof V))throw new i(t,a.InvalidIdentifier,n);if(!1===v(r))throw new i(t,a.ModuleAccessorMustBeString,n);if(!0!==e.hasGlobal(r))throw new i(t,a.ModuleExportNotFound,n);e.setGlobal(r,ne(o,n.operator,e.global(r),n,t))}return F}const r=e(n.left),o=Y(t,n.right);if(null!=t.localScope&&void 0!==t.localScope[r])return t.localScope[r]={value:ne(o,n.operator,t.localScope[r].value,n,t),valueset:!0,node:n.right},F;if(void 0!==t.globalScope[r])return t.globalScope[r]={value:ne(o,n.operator,t.globalScope[r].value,n,t),valueset:!0,node:n.right},F;throw new i(t,a.InvalidIdentifier,n)}function oe(e,t){const n=Y(e,t.expression);return n===F?F:new N(n)}function le(e,t){const n=Y(e,t.test);if(!0===n)return H(e,t.consequent);if(!1===n)return null!==t.alternate?H(e,t.alternate):F;throw new i(e,a.BooleanConditionRequired,t)}function ie(e,t){let n=F;for(let r=0;r<t.body.length;r++)if(n=H(e,t.body[r]),n instanceof C||n===O||n===B)return n;return n}function ae(e,t){if(null===t.argument)return new C(F);const n=Y(e,t.argument);return new C(n)}function se(t,n){const r=e(n.id);return t.globalScope[r]={valueset:!0,node:null,value:new T(n,t)},F}function ce(t,n){const r=e(n.specifiers[0].local),o=t.libraryResolver.loadLibrary(r);let l;return t.libraryResolver._moduleSingletons?.has(o.uri)?l=t.libraryResolver._moduleSingletons.get(o.uri):(l=new V(o),l.loadModule(t),t.libraryResolver._moduleSingletons?.set(o.uri,l)),t.globalScope[r]={value:l,valueset:!0,node:n},F}function ue(t,n){if(H(t,n.declaration),"FunctionDeclaration"===n.declaration.type)t.exports[e(n.declaration.id)]="function";else if("VariableDeclaration"===n.declaration.type)for(const r of n.declaration.declarations)t.exports[e(r.id)]="variable";return F}function fe(e,t){for(let n=0;n<t.declarations.length;n++)pe(e,t.declarations[n]);return F}function pe(t,n){let r=null===n.init?null:Y(t,n.init);if(r===F&&(r=null),"Identifier"!==n.id.type)throw new i(t,a.InvalidIdentifier,n);const o=e(n.id);null!=t.localScope?t.localScope[o]={value:r,valueset:!0,node:n.init}:t.globalScope[o]={value:r,valueset:!0,node:n.init}}function he(e,t){try{const n=Y(e,t.object);if(null===n)throw new i(e,a.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(n instanceof l||S(n))return n.field(t.property.name);if(n instanceof P)return o(n,t.property.name,e,t);if(n instanceof V){if(!n.hasGlobal(t.property.name))throw new i(e,a.InvalidIdentifier,t);return n.global(t.property.name)}}throw new i(e,a.InvalidMemberAccessKey,t)}let r=Y(e,t.property);if(n instanceof l||S(n)){if(v(r))return n.field(r);throw new i(e,a.InvalidMemberAccessKey,t)}if(n instanceof V){if(v(r))return n.global(r);throw new i(e,a.InvalidMemberAccessKey,t)}if(n instanceof P){if(v(r))return o(n,r,e,t);throw new i(e,a.InvalidMemberAccessKey,t)}if(y(n)){if(b(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new i(e,a.OutOfBounds,t);return n[r]}throw new i(e,a.InvalidMemberAccessKey,t)}if(v(n)){if(b(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new i(e,a.OutOfBounds,t);return n[r]}throw new i(e,a.InvalidMemberAccessKey,t)}if(R(n)){if(b(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length()+r),r>=n.length()||r<0)throw new i(e,a.OutOfBounds,t);return n.get(r)}throw new i(e,a.InvalidMemberAccessKey,t)}throw new i(e,a.InvalidMemberAccessKey,t)}catch(n){throw n}}function de(e,t){try{const n=Y(e,t.argument);if(w(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*x(n);if("+"===t.operator)return 1*x(n);if("~"===t.operator)return~x(n);throw new i(e,a.UnsupportedUnaryOperator,t)}if("~"===t.operator)return~x(n);if("-"===t.operator)return-1*x(n);if("+"===t.operator)return 1*x(n);throw new i(e,a.UnsupportedUnaryOperator,t)}catch(n){throw n}}function we(e,t){try{const n=[];for(let r=0;r<t.elements.length;r++){const o=Y(e,t.elements[r]);if(g(o))throw new i(e,a.NoFunctionInArray,t);o===F?n.push(null):n.push(o)}return n}catch(n){throw n}}function me(e,t){try{const n=Y(e,t.left),r=Y(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return M(x(n),x(r),t.operator);case"==":return m(n,r);case"!=":return!m(n,r);case"<":case">":case"<=":case">=":return A(n,r,t.operator);case"+":return v(n)||v(r)?I(n)+I(r):x(n)+x(r);case"-":return x(n)-x(r);case"*":return x(n)*x(r);case"/":return x(n)/x(r);case"%":return x(n)%x(r);default:throw new i(e,a.UnsupportedOperator,t)}}catch(n){throw n}}function ge(e,t){try{const n=Y(e,t.left);if(w(n))switch(t.operator){case"||":{if(!0===n)return n;const r=Y(e,t.right);if(w(r))return r;throw new i(e,a.LogicExpressionOrAnd,t)}case"&&":{if(!1===n)return n;const r=Y(e,t.right);if(w(r))return r;throw new i(e,a.LogicExpressionOrAnd,t)}default:throw new i(e,a.LogicExpressionOrAnd,t)}throw new i(e,a.LogicalExpressionOnlyBoolean,t)}catch(n){throw n}}function ve(e,t,n){if(g(e))throw new i(t,a.NoFunctionInTemplateLiteral,n);return e}function ye(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){n+=t.expressions[r]?I(ve(Y(e,t.expressions[r]),e,t)):"",r++}return n}function be(t,n){try{const r=e(n);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];return!0===e.valueset||(e.value=Y(t,e.node),e.valueset=!0),e.value}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];return!0===e.valueset||(e.value=Y(t,e.node),e.valueset=!0),e.value}throw new i(t,a.InvalidIdentifier,n)}catch(r){throw r}}function xe(t,n){try{if("MemberExpression"===n.callee.type){const e=Y(t,n.callee.object);if(!(e instanceof V))throw new i(t,a.FunctionNotFound,n);const r=!1===n.callee.computed?n.callee.property.name:Y(t,n.callee.property);if(!e.hasGlobal(r))throw new i(t,a.FunctionNotFound,n);const o=e.global(r);if(!g(o))throw new i(t,a.CallNonFunction,n);return o.call(t,n)}if("Identifier"!==n.callee.type)throw new i(t,a.FunctionNotFound,n);const r=e(n.callee);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];if(g(e.value))return e.value.call(t,n);throw new i(t,a.CallNonFunction,n)}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];if(g(e.value))return e.value.call(t,n);throw new i(t,a.CallNonFunction,n)}throw new i(t,a.FunctionNotFound,n)}catch(r){throw r}}const Se={};function Re(e,t,n,r){try{const o=t.arguments,l=Y(e,o[n]);if(m(l,r))return Y(e,o[n+1]);{const l=o.length-n;return 1===l?Y(e,o[n]):2===l?null:3===l?Y(e,o[n+2]):Re(e,t,n+2,r)}}catch(o){throw o}}function Fe(e,t,n,r){try{const o=t.arguments;if(!0===r)return Y(e,o[n+1]);if(3===o.length-n)return Y(e,o[n+2]);{const r=Y(e,o[n+2]);if(!1===w(r))throw new i(e,a.BooleanConditionRequired,o[n+2]);return Fe(e,t,n+2,r)}}catch(o){throw o}}function Ie(t,n,r,o){try{const l=t.body;if(r.length!==t.params.length)throw new i(n,a.WrongNumberOfParameters,o);if(null!=n.localScope)for(let o=0;o<r.length;o++)n.localScope[e(t.params[o])]={value:r[o],valueset:!0,node:null};const s=H(n,l);if(s instanceof C)return s.value;if(s===O)throw new i(n,a.UnexpectedToken,o);if(s===B)throw new i(n,a.UnexpectedToken,o);return s instanceof N?s.value:s}catch(l){throw l}}D(Se,z),G(Se,z),q(Se,z),L(Se,z),Z(Se,z),K(Se,z),Se.iif=function(e,t){try{if(!0===t.preparsed)throw new i(e,a.NeverReach,t);const n=t.arguments;d(null===n?[]:n,3,3,e,t);const r=Y(e,n[0]);if(!1===w(r))throw new i(e,a.BooleanConditionRequired,t);return Y(e,!0===r?n[1]:n[2])}catch(n){throw n}},Se.defaultvalue=function(e,t){try{if(!0===t.preparsed)throw new i(e,a.NeverReach,t);const n=t.arguments;d(null===n?[]:n,2,3,e,t);const o=Y(e,n[0]);if(3===n.length){const t=Y(e,n[1]),l=r(o,t);return null!=l&&""!==l?l:Y(e,n[2])}return null===o||""===o||void 0===o?Y(e,n[1]):o}catch(n){throw n}},Se.decode=function(e,t){try{if(!0===t.preparsed)throw new i(e,a.NeverReach,t);const n=t.arguments;if(n.length<2)throw new i(e,a.WrongNumberOfParameters,t);if(2===n.length)return Y(e,n[1]);{if((n.length-1)%2==0)throw new i(e,a.WrongNumberOfParameters,t);const r=Y(e,n[0]);return Re(e,t,1,r)}}catch(n){throw n}},Se.when=function(e,t){try{if(!0===t.preparsed)throw new i(e,a.NeverReach,t);const n=t.arguments;if(n.length<3)throw new i(e,a.WrongNumberOfParameters,t);if(n.length%2==0)throw new i(e,a.WrongNumberOfParameters,t);const r=Y(e,n[0]);if(!1===w(r))throw new i(e,a.BooleanConditionRequired,n[0]);return Fe(e,t,0,r)}catch(n){throw n}};for(const Ee in Se)Se[Ee]={value:new u(Se[Ee]),valueset:!0,node:null};const Ae=function(){};function Me(e,t,n){const r=new Ae;e||(e={}),t||(t={});const o=new l({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});o.immutable=!1,r.textformatting={value:o,valueset:!0,node:null};for(const l in t)r[l]={value:new u(t[l]),native:!0,valueset:!0,node:null};for(const l in e)r[l]={value:E(e[l])?c.createFromGraphic(e[l],n):e[l],valueset:!0,node:null};return r}Ae.prototype=Se,Ae.prototype.infinity={value:Number.POSITIVE_INFINITY,valueset:!0,node:null},Ae.prototype.pi={value:Math.PI,valueset:!0,node:null};const Ce={fixSpatialReference:j,parseArguments:_,standardFunction:z};function Ne(e){console.log(e)}function Oe(e){const t={mode:"sync",compiled:!1,functions:{},signatures:[],standardFunction:z,evaluateIdentifier:be};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)Se[n]={value:new u(t.functions[n]),valueset:!0,node:null},Ae.prototype[n]=Se[n];for(let n=0;n<t.signatures.length;n++)k(t.signatures[n],"sync")}function Be(e,t){let r=t.spatialReference;null==r&&(r=new W({wkid:102100}));let o=null;e.usesModules&&(o=new n(new Map,e.loadedModules));const l={spatialReference:r,globalScope:Me(t.vars,t.customfunctions,t.timeZone),localScope:null,services:t.services,exports:{},libraryResolver:o,console:t.console??Ne,timeZone:t.timeZone??null,lrucache:t.lrucache,interceptor:t.interceptor,depthCounter:{depth:1}},s=ie(l,e);if(s instanceof C||s instanceof N){const e=s.value;if(e===F)return null;if(g(e))throw new i(l,a.IllegalResult,null);return e}if(s===F)return null;if(s===O)throw new i(l,a.IllegalResult,null);if(s===B)throw new i(l,a.IllegalResult,null);throw new i(l,a.NeverReach,null)}Oe([U]);export{Be as executeScript,Oe as extend,Ce as functionHelper};
|
|
5
|
+
import{toSymbolId as e}from"./arcadeEnvironment.js";import{ArcadeModule as t}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import{getNestedOptionalValue as r,geometryMember as o}from"./containerUtils.js";import l from"./Dictionary.js";import{ArcadeExecutionError as i,ExecutionErrorCodes as a,ensureArcadeExecutionError as s}from"./executionError.js";import c from"./Feature.js";import{NativeFunction as u,ScopeMarshalledFunction as f,ArcadeFunction as p,wrapModuleScopedResponse as h}from"./FunctionWrapper.js";import{D as d,a as w,B as m,i as g,m as v,e as y,p as b,o as x,x as S,g as R,A as F,C as I,R as A,I as M,y as C,z as N,v as O}from"../chunks/languageUtils.js";import{addFunctionDeclaration as B}from"./treeAnalysis.js";import{A as E}from"../chunks/array.js";import{registerFunctions as j}from"./functions/date.js";import{registerFunctions as k}from"./functions/geometry.js";import{registerFunctions as U}from"./functions/geomsync.js";import{registerFunctions as D}from"./functions/maths.js";import{registerFunctions as L}from"./functions/stats.js";import{registerFunctions as K}from"./functions/string.js";import Z from"../geometry/Geometry.js";import q from"../geometry/SpatialReference.js";import{isString as G,isNumber as P,isGraphic as W}from"../support/guards.js";class T extends p{constructor(e,t){super(),this.definition=e,this.context=t}createFunction(e){return(...t)=>{const n={spatialReference:this.context.spatialReference,console:this.context.console,services:this.context.services,timeZone:this.context.timeZone??null,lrucache:this.context.lrucache,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,localScope:{},depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope};if(n.depthCounter.depth>64)throw new i(e,a.MaximumCallDepth,null);return Ie(this.definition,n,t,null)}}call(e,t){return z(e,t,((n,r,o)=>{const l={spatialReference:e.spatialReference,services:e.services,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,timeZone:e.timeZone??null,console:e.console,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};if(l.depthCounter.depth>64)throw new i(e,a.MaximumCallDepth,t);return Ie(this.definition,l,o,t)}))}marshalledCall(e,t,n,r){return r(e,t,((o,l,i)=>{const a={spatialReference:e.spatialReference,globalScope:n.globalScope,services:e.services,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,localScope:{}};return i=i.map((t=>!g(t)||t instanceof f?t:h(t,e,r))),h(Ie(this.definition,a,i,t),n,r)}))}}class V extends t{constructor(e){super(),this.source=e}global(e){const t=this.executingContext.globalScope[e.toLowerCase()];if(t.valueset||(t.value=Y(this.executingContext,t.node),t.valueset=!0),g(t.value)&&!(t.value instanceof f)){const e=new f;e.fn=t.value,e.parameterEvaluator=z,e.context=this.executingContext,t.value=e}return t.value}setGlobal(e,t){if(g(t))throw new i(null,a.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]}loadModule(e){let t=e.spatialReference;null==t&&(t=new q({wkid:102100})),this.moduleScope=Me({},e.customfunctions,e.timeZone),this.executingContext={spatialReference:t,globalScope:this.moduleScope,localScope:null,libraryResolver:new n(e.libraryResolver._moduleSingletons,this.source.syntax.loadedModules),exports:{},services:e.services,console:e.console??Ne,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,depthCounter:{depth:1}},ie(this.executingContext,this.source.syntax)}}function _(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(Y(e,t.arguments[r]));return n}function z(e,t,n){try{return!0===t.preparsed?n(e,null,t.arguments):n(e,t,_(e,t))}catch(r){throw r}}function Y(e,t){try{switch(t.type){case"AssignmentExpression":return re(e,t);case"UpdateExpression":return te(e,t);case"TemplateLiteral":return ye(e,t);case"Identifier":return be(e,t);case"MemberExpression":return he(e,t);case"Literal":return t.value;case"CallExpression":return xe(e,t);case"UnaryExpression":return de(e,t);case"BinaryExpression":return me(e,t);case"LogicalExpression":return ge(e,t);case"ArrayExpression":return we(e,t);case"ObjectExpression":return J(e,t);default:throw new i(e,a.Unrecognized,t)}}catch(n){throw s(e,t,n)}}function H(e,t){switch(t.type){case"EmptyStatement":return S;case"VariableDeclaration":return fe(e,t);case"ImportDeclaration":return ce(e,t);case"ExportNamedDeclaration":return ue(e,t);case"BlockStatement":return ie(e,t);case"FunctionDeclaration":return se(e,t);case"ReturnStatement":return ae(e,t);case"IfStatement":return le(e,t);case"ExpressionStatement":return oe(e,t);case"BreakStatement":return C;case"ContinueStatement":return N;case"ForStatement":return X(e,t);case"ForInStatement":return Q(e,t);case"WhileStatement":return $(e,t);default:throw new i(e,a.Unrecognized,t)}}function J(e,t){const n={},r=new Map;for(let l=0;l<t.properties.length;l++){const o=t.properties[l],s="Identifier"===o.key.type?o.key.name:Y(e,o.key),c=Y(e,o.value);if(g(c))throw new i(e,a.NoFunctionInDictionary,t);if(!1===G(s))throw new i(e,a.KeyMustBeString,t);let u=s.toString();const f=u.toLowerCase();r.has(f)?u=r.get(f):r.set(f,u),n[u]=c===S?null:c}const o=new l(n);return o.immutable=!1,o}function Q(t,n){const r=Y(t,n.right);"VariableDeclaration"===n.left.type&&fe(t,n.left);const o=e("VariableDeclaration"===n.left.type?n.left.declarations[0].id:n.left);let s=null;if(null!=t.localScope&&void 0!==t.localScope[o]&&(s=t.localScope[o]),null===s&&void 0!==t.globalScope[o]&&(s=t.globalScope[o]),null===s)throw new i(t,a.InvalidIdentifier,n);if(v(r)||G(r)){const e=r.length;for(let r=0;r<e;r++){s.value=r;const e=H(t,n.body);if(e===C)break;if(e instanceof A)return e}return S}if(x(r)){for(let e=0;e<r.length();e++){s.value=e;const r=H(t,n.body);if(r===C)break;if(r instanceof A)return r}return S}if(r instanceof l||b(r)){const e=r.keys();for(let r=0;r<e.length;r++){s.value=e[r];const o=H(t,n.body);if(o===C)break;if(o instanceof A)return o}}return S}function X(e,t){null!==t.init&&("VariableDeclaration"===t.init.type?H(e,t.init):Y(e,t.init));const n={testResult:!0,lastAction:S};do{ee(e,t,n)}while(!0===n.testResult);return n.lastAction instanceof A?n.lastAction:S}function $(e,t){const n={testResult:!0,lastAction:S};if(n.testResult=Y(e,t.test),!1===n.testResult)return S;if(!0!==n.testResult)throw new i(e,a.BooleanConditionRequired,t);for(;!0===n.testResult&&(n.lastAction=H(e,t.body),n.lastAction!==C)&&!(n.lastAction instanceof A);)if(n.testResult=Y(e,t.test),!0!==n.testResult&&!1!==n.testResult)throw new i(e,a.BooleanConditionRequired,t);return n.lastAction instanceof A?n.lastAction:S}function ee(e,t,n){if(null!==t.test){if(n.testResult=Y(e,t.test),!1===n.testResult)return;if(!0!==n.testResult)throw new i(e,a.BooleanConditionRequired,t)}n.lastAction=H(e,t.body),n.lastAction!==C?n.lastAction instanceof A?n.testResult=!1:null!==t.update&&Y(e,t.update):n.testResult=!1}function te(t,n){if("CallExpression"===n.argument.type)throw new i(t,a.NeverReach,n);let r;if("MemberExpression"===n.argument.type){const e=Y(t,n.argument.object);let o;if(!0===n.argument.computed)o=Y(t,n.argument.property);else{if("Identifier"!==n.argument.property.type)throw new i(t,a.Unrecognized,n);o=n.argument.property.name}if(v(e)){if(!P(o))throw new i(t,a.ArrayAccessorMustBeNumber,n);if(o<0&&(o=e.length+o),o<0||o>=e.length)throw new i(t,a.OutOfBounds,n);r=y(e[o]),e[o]="++"===n.operator?r+1:r-1}else if(e instanceof l){if(!1===G(o))throw new i(t,a.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new i(t,a.FieldNotFound,n);r=y(e.field(o)),e.setField(o,"++"===n.operator?r+1:r-1)}else if(b(e)){if(!1===G(o))throw new i(t,a.KeyAccessorMustBeString,n);if(!0!==e.hasField(o))throw new i(t,a.FieldNotFound,n);r=y(e.field(o)),e.setField(o,"++"===n.operator?r+1:r-1)}else{if(x(e))throw new i(t,a.Immutable,n);if(!(e instanceof V))throw new i(t,a.InvalidParameter,n);if(!1===G(o))throw new i(t,a.ModuleAccessorMustBeString,n);if(!0!==e.hasGlobal(o))throw new i(t,a.ModuleExportNotFound,n);r=y(e.global(o)),e.setGlobal(o,"++"===n.operator?r+1:r-1)}return!1===n.prefix?r:"++"===n.operator?r+1:r-1}const o=e(n.argument);if(null!=t.localScope&&void 0!==t.localScope[o])return r=y(t.localScope[o].value),t.localScope[o]={value:"++"===n.operator?r+1:r-1,valueset:!0,node:n},!1===n.prefix?r:"++"===n.operator?r+1:r-1;if(void 0!==t.globalScope[o])return r=y(t.globalScope[o].value),t.globalScope[o]={value:"++"===n.operator?r+1:r-1,valueset:!0,node:n},!1===n.prefix?r:"++"===n.operator?r+1:r-1;throw new i(t,a.InvalidIdentifier,n)}function ne(e,t,n,r,o){switch(t){case"=":return e===S?null:e;case"/=":return y(n)/y(e);case"*=":return y(n)*y(e);case"-=":return y(n)-y(e);case"+=":return G(n)||G(e)?R(n)+R(e):y(n)+y(e);case"%=":return y(n)%y(e);default:throw new i(o,a.UnsupportedOperator,r)}}function re(t,n){if("MemberExpression"===n.left.type){const e=Y(t,n.left.object);let r;if(!0===n.left.computed)r=Y(t,n.left.property);else{if("Identifier"!==n.left.property.type)throw new i(t,a.InvalidIdentifier,n);r=n.left.property.name}const o=Y(t,n.right);if(v(e)){if(!P(r))throw new i(t,a.ArrayAccessorMustBeNumber,n);if(r<0&&(r=e.length+r),r<0||r>e.length)throw new i(t,a.OutOfBounds,n);if(r===e.length){if("="!==n.operator)throw new i(t,a.OutOfBounds,n);e[r]=ne(o,n.operator,e[r],n,t)}else e[r]=ne(o,n.operator,e[r],n,t)}else if(e instanceof l){if(!1===G(r))throw new i(t,a.KeyAccessorMustBeString,n);if(!0===e.hasField(r))e.setField(r,ne(o,n.operator,e.field(r),n,t));else{if("="!==n.operator)throw new i(t,a.FieldNotFound,n,{key:r});e.setField(r,ne(o,n.operator,null,n,t))}}else if(b(e)){if(!1===G(r))throw new i(t,a.KeyAccessorMustBeString,n);if(!0===e.hasField(r))e.setField(r,ne(o,n.operator,e.field(r),n,t));else{if("="!==n.operator)throw new i(t,a.FieldNotFound,n,{key:r});e.setField(r,ne(o,n.operator,null,n,t))}}else{if(x(e))throw new i(t,a.Immutable,n);if(!(e instanceof V))throw new i(t,a.InvalidIdentifier,n);if(!1===G(r))throw new i(t,a.ModuleAccessorMustBeString,n);if(!0!==e.hasGlobal(r))throw new i(t,a.ModuleExportNotFound,n);e.setGlobal(r,ne(o,n.operator,e.global(r),n,t))}return S}const r=e(n.left),o=Y(t,n.right);if(null!=t.localScope&&void 0!==t.localScope[r])return t.localScope[r]={value:ne(o,n.operator,t.localScope[r].value,n,t),valueset:!0,node:n.right},S;if(void 0!==t.globalScope[r])return t.globalScope[r]={value:ne(o,n.operator,t.globalScope[r].value,n,t),valueset:!0,node:n.right},S;throw new i(t,a.InvalidIdentifier,n)}function oe(e,t){const n=Y(e,t.expression);return n===S?S:new M(n)}function le(e,t){const n=Y(e,t.test);if(!0===n)return H(e,t.consequent);if(!1===n)return null!==t.alternate?H(e,t.alternate):S;throw new i(e,a.BooleanConditionRequired,t)}function ie(e,t){let n=S;for(let r=0;r<t.body.length;r++)if(n=H(e,t.body[r]),n instanceof A||n===C||n===N)return n;return n}function ae(e,t){if(null===t.argument)return new A(S);const n=Y(e,t.argument);return new A(n)}function se(t,n){const r=e(n.id);return t.globalScope[r]={valueset:!0,node:null,value:new T(n,t)},S}function ce(t,n){const r=e(n.specifiers[0].local),o=t.libraryResolver.loadLibrary(r);let l;return t.libraryResolver._moduleSingletons?.has(o.uri)?l=t.libraryResolver._moduleSingletons.get(o.uri):(l=new V(o),l.loadModule(t),t.libraryResolver._moduleSingletons?.set(o.uri,l)),t.globalScope[r]={value:l,valueset:!0,node:n},S}function ue(t,n){if(H(t,n.declaration),"FunctionDeclaration"===n.declaration.type)t.exports[e(n.declaration.id)]="function";else if("VariableDeclaration"===n.declaration.type)for(const r of n.declaration.declarations)t.exports[e(r.id)]="variable";return S}function fe(e,t){for(let n=0;n<t.declarations.length;n++)pe(e,t.declarations[n]);return S}function pe(t,n){let r=null===n.init?null:Y(t,n.init);if(r===S&&(r=null),"Identifier"!==n.id.type)throw new i(t,a.InvalidIdentifier,n);const o=e(n.id);null!=t.localScope?t.localScope[o]={value:r,valueset:!0,node:n.init}:t.globalScope[o]={value:r,valueset:!0,node:n.init}}function he(e,t){try{const n=Y(e,t.object);if(null===n)throw new i(e,a.MemberOfNull,t);if(!1===t.computed){if("Identifier"===t.property.type){if(n instanceof l||b(n))return n.field(t.property.name);if(n instanceof Z)return o(n,t.property.name,e,t);if(n instanceof V){if(!n.hasGlobal(t.property.name))throw new i(e,a.InvalidIdentifier,t);return n.global(t.property.name)}}throw new i(e,a.InvalidMemberAccessKey,t)}let r=Y(e,t.property);if(n instanceof l||b(n)){if(G(r))return n.field(r);throw new i(e,a.InvalidMemberAccessKey,t)}if(n instanceof V){if(G(r))return n.global(r);throw new i(e,a.InvalidMemberAccessKey,t)}if(n instanceof Z){if(G(r))return o(n,r,e,t);throw new i(e,a.InvalidMemberAccessKey,t)}if(v(n)){if(P(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new i(e,a.OutOfBounds,t);return n[r]}throw new i(e,a.InvalidMemberAccessKey,t)}if(G(n)){if(P(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new i(e,a.OutOfBounds,t);return n[r]}throw new i(e,a.InvalidMemberAccessKey,t)}if(x(n)){if(P(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length()+r),r>=n.length()||r<0)throw new i(e,a.OutOfBounds,t);return n.get(r)}throw new i(e,a.InvalidMemberAccessKey,t)}throw new i(e,a.InvalidMemberAccessKey,t)}catch(n){throw n}}function de(e,t){try{const n=Y(e,t.argument);if(w(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*y(n);if("+"===t.operator)return 1*y(n);if("~"===t.operator)return~y(n);throw new i(e,a.UnsupportedUnaryOperator,t)}if("~"===t.operator)return~y(n);if("-"===t.operator)return-1*y(n);if("+"===t.operator)return 1*y(n);throw new i(e,a.UnsupportedUnaryOperator,t)}catch(n){throw n}}function we(e,t){try{const n=[];for(let r=0;r<t.elements.length;r++){const o=Y(e,t.elements[r]);if(g(o))throw new i(e,a.NoFunctionInArray,t);o===S?n.push(null):n.push(o)}return n}catch(n){throw n}}function me(e,t){try{const n=Y(e,t.left),r=Y(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return I(y(n),y(r),t.operator);case"==":return m(n,r);case"!=":return!m(n,r);case"<":case">":case"<=":case">=":return F(n,r,t.operator);case"+":return G(n)||G(r)?R(n)+R(r):y(n)+y(r);case"-":return y(n)-y(r);case"*":return y(n)*y(r);case"/":return y(n)/y(r);case"%":return y(n)%y(r);default:throw new i(e,a.UnsupportedOperator,t)}}catch(n){throw n}}function ge(e,t){try{const n=Y(e,t.left);if(w(n))switch(t.operator){case"||":{if(!0===n)return n;const r=Y(e,t.right);if(w(r))return r;throw new i(e,a.LogicExpressionOrAnd,t)}case"&&":{if(!1===n)return n;const r=Y(e,t.right);if(w(r))return r;throw new i(e,a.LogicExpressionOrAnd,t)}default:throw new i(e,a.LogicExpressionOrAnd,t)}throw new i(e,a.LogicalExpressionOnlyBoolean,t)}catch(n){throw n}}function ve(e,t,n){if(g(e))throw new i(t,a.NoFunctionInTemplateLiteral,n);return e}function ye(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){n+=t.expressions[r]?R(ve(Y(e,t.expressions[r]),e,t)):"",r++}return n}function be(t,n){try{const r=e(n);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];return!0===e.valueset||(e.value=Y(t,e.node),e.valueset=!0),e.value}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];return!0===e.valueset||(e.value=Y(t,e.node),e.valueset=!0),e.value}throw new i(t,a.InvalidIdentifier,n)}catch(r){throw r}}function xe(t,n){try{if("MemberExpression"===n.callee.type){const e=Y(t,n.callee.object);if(!(e instanceof V))throw new i(t,a.FunctionNotFound,n);const r=!1===n.callee.computed?n.callee.property.name:Y(t,n.callee.property);if(!e.hasGlobal(r))throw new i(t,a.FunctionNotFound,n);const o=e.global(r);if(!g(o))throw new i(t,a.CallNonFunction,n);return o.call(t,n)}if("Identifier"!==n.callee.type)throw new i(t,a.FunctionNotFound,n);const r=e(n.callee);if(null!=t.localScope&&void 0!==t.localScope[r]){const e=t.localScope[r];if(g(e.value))return e.value.call(t,n);throw new i(t,a.CallNonFunction,n)}if(void 0!==t.globalScope[r]){const e=t.globalScope[r];if(g(e.value))return e.value.call(t,n);throw new i(t,a.CallNonFunction,n)}throw new i(t,a.FunctionNotFound,n)}catch(r){throw r}}const Se={};function Re(e,t,n,r){try{const o=t.arguments,l=Y(e,o[n]);if(m(l,r))return Y(e,o[n+1]);{const l=o.length-n;return 1===l?Y(e,o[n]):2===l?null:3===l?Y(e,o[n+2]):Re(e,t,n+2,r)}}catch(o){throw o}}function Fe(e,t,n,r){try{const o=t.arguments;if(!0===r)return Y(e,o[n+1]);if(3===o.length-n)return Y(e,o[n+2]);{const r=Y(e,o[n+2]);if(!1===w(r))throw new i(e,a.BooleanConditionRequired,o[n+2]);return Fe(e,t,n+2,r)}}catch(o){throw o}}function Ie(t,n,r,o){try{const l=t.body;if(r.length!==t.params.length)throw new i(n,a.WrongNumberOfParameters,o);if(null!=n.localScope)for(let o=0;o<r.length;o++)n.localScope[e(t.params[o])]={value:r[o],valueset:!0,node:null};const s=H(n,l);if(s instanceof A)return s.value;if(s===C)throw new i(n,a.UnexpectedToken,o);if(s===N)throw new i(n,a.UnexpectedToken,o);return s instanceof M?s.value:s}catch(l){throw l}}j(Se,z),K(Se,z),D(Se,z),k(Se,z),L(Se,z),U(Se,z),Se.iif=function(e,t){try{if(!0===t.preparsed)throw new i(e,a.NeverReach,t);const n=t.arguments;d(null===n?[]:n,3,3,e,t);const r=Y(e,n[0]);if(!1===w(r))throw new i(e,a.BooleanConditionRequired,t);return Y(e,!0===r?n[1]:n[2])}catch(n){throw n}},Se.defaultvalue=function(e,t){try{if(!0===t.preparsed)throw new i(e,a.NeverReach,t);const n=t.arguments;d(null===n?[]:n,2,3,e,t);const o=Y(e,n[0]);if(3===n.length){const t=Y(e,n[1]),l=r(o,t);return null!=l&&""!==l?l:Y(e,n[2])}return null===o||""===o||void 0===o?Y(e,n[1]):o}catch(n){throw n}},Se.decode=function(e,t){try{if(!0===t.preparsed)throw new i(e,a.NeverReach,t);const n=t.arguments;if(n.length<2)throw new i(e,a.WrongNumberOfParameters,t);if(2===n.length)return Y(e,n[1]);{if((n.length-1)%2==0)throw new i(e,a.WrongNumberOfParameters,t);const r=Y(e,n[0]);return Re(e,t,1,r)}}catch(n){throw n}},Se.when=function(e,t){try{if(!0===t.preparsed)throw new i(e,a.NeverReach,t);const n=t.arguments;if(n.length<3)throw new i(e,a.WrongNumberOfParameters,t);if(n.length%2==0)throw new i(e,a.WrongNumberOfParameters,t);const r=Y(e,n[0]);if(!1===w(r))throw new i(e,a.BooleanConditionRequired,n[0]);return Fe(e,t,0,r)}catch(n){throw n}};for(const Ee in Se)Se[Ee]={value:new u(Se[Ee]),valueset:!0,node:null};const Ae=function(){};function Me(e,t,n){const r=new Ae;e||(e={}),t||(t={});const o=new l({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});o.immutable=!1,r.textformatting={value:o,valueset:!0,node:null};for(const l in t)r[l]={value:new u(t[l]),native:!0,valueset:!0,node:null};for(const l in e)r[l]={value:W(e[l])?c.createFromGraphic(e[l],n):e[l],valueset:!0,node:null};return r}Ae.prototype=Se,Ae.prototype.infinity={value:Number.POSITIVE_INFINITY,valueset:!0,node:null},Ae.prototype.pi={value:Math.PI,valueset:!0,node:null};const Ce={fixSpatialReference:O,parseArguments:_,standardFunction:z};function Ne(e){console.log(e)}function Oe(e){const t={mode:"sync",compiled:!1,functions:{},signatures:[],standardFunction:z,evaluateIdentifier:be};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const n in t.functions)Se[n]={value:new u(t.functions[n]),valueset:!0,node:null},Ae.prototype[n]=Se[n];for(let n=0;n<t.signatures.length;n++)B(t.signatures[n],"sync")}function Be(e,t){let r=t.spatialReference;null==r&&(r=new q({wkid:102100}));let o=null;e.usesModules&&(o=new n(new Map,e.loadedModules));const l={spatialReference:r,globalScope:Me(t.vars,t.customfunctions,t.timeZone),localScope:null,services:t.services,exports:{},libraryResolver:o,console:t.console??Ne,timeZone:t.timeZone??null,lrucache:t.lrucache,interceptor:t.interceptor,depthCounter:{depth:1}},s=ie(l,e);if(s instanceof A||s instanceof M){const e=s.value;if(e===S)return null;if(g(e))throw new i(l,a.IllegalResult,null);return e}if(s===S)return null;if(s===C)throw new i(l,a.IllegalResult,null);if(s===N)throw new i(l,a.IllegalResult,null);throw new i(l,a.NeverReach,null)}Oe([E]);export{Be as executeScript,Oe as extend,Ce as functionHelper};
|
package/arcade/containerUtils.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"./Dictionary.js";import{ArcadeExecutionError as a,ExecutionErrorCodes as r}from"./executionError.js";import t from"./ImmutablePathArray.js";import n from"./ImmutablePointArray.js";import{
|
|
5
|
+
import e from"./Dictionary.js";import{ArcadeExecutionError as a,ExecutionErrorCodes as r}from"./executionError.js";import t from"./ImmutablePathArray.js";import n from"./ImmutablePointArray.js";import{m as s,o as c,p as i,s as l,n as o}from"../chunks/languageUtils.js";import u from"../core/Accessor.js";import{isString as f,isNumber as h}from"../support/guards.js";let d=0;function p(s,c,i,l,o=1){let f;switch(c=c.toLowerCase()){case"hasz":{const e=s.hasZ;return void 0!==e&&e}case"hasm":{const e=s.hasM;return void 0!==e&&e}case"spatialreference":{let a=s.spatialReference._arcadeCacheId;if(void 0===a){let e=!0;u.isFrozen(s.spatialReference)&&(e=!1),e&&(d++,s.spatialReference._arcadeCacheId=d,a=d)}const r=new e({wkt:s.spatialReference.wkt,wkid:s.spatialReference.wkid});return void 0!==a&&(r._arcadeCacheId="SPREF"+a.toString()),r}}switch(s.type){case"extent":switch(c){case"xmin":case"xmax":case"ymin":case"ymax":case"zmin":case"zmax":case"mmin":case"mmax":{const e=s[c];return void 0!==e?e:null}case"type":return"Extent"}break;case"polygon":switch(c){case"rings":f=s.cache._arcadeCacheId,void 0===f&&(d++,f=d,s.cache._arcadeCacheId=f);return new t(s.rings,s.spatialReference,!0===s.hasZ,!0===s.hasM,f);case"type":return"Polygon"}break;case"point":switch(c){case"x":case"y":case"z":case"m":return s[c]??null;case"type":return"Point"}break;case"polyline":switch(c){case"paths":f=s.cache._arcadeCacheId,void 0===f&&(d++,f=d,s.cache._arcadeCacheId=f);return new t(s.paths,s.spatialReference,!0===s.hasZ,!0===s.hasM,f);case"type":return"Polyline"}break;case"multipoint":switch(c){case"points":f=s.cache._arcadeCacheId,void 0===f&&(d++,f=d,s.cache._arcadeCacheId=f);return new n(s.points,s.spatialReference,!0===s.hasZ,!0===s.hasM,f,1);case"type":return"Multipoint"}}if(1===o)throw new a(i,r.InvalidIdentifier,l);return 2===o?{keystate:"notfound"}:null}function m(e,a){let r,t=e;if(null==t)return null;if(s(a))r=a;else if(c(a))r=a.toArray();else{if(null==a)return null;r=[a]}for(const n of r){if(i(t)){if(!1===f(n))return null;if(!t.hasField(n))return null;t=t.field(n)}else if(l(t)){if(!1===f(n))return null;if(!t.hasField(n))return null;t=t.field(n)}else if(o(t)){if(!1===f(n))return null;t=p(t,n,null,null,0)}else if(s(t)){if(!1===h(n))return null;t=n>=0?t[n]:t[t.length+n]}else{if(!c(t))return null;if(!1===h(n))return null;t=n>=0?t.get(n):t.get(t.length()+n)}if(null==t)return null}return t}export{p as geometryMember,m as getNestedOptionalValue};
|
package/arcade/deepClone.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ArcadeModule as a}from"./ArcadeModule.js";import{
|
|
5
|
+
import{ArcadeModule as a}from"./ArcadeModule.js";import{h as e,d as s,n as r,o as l,m as n,p as o,q as t,r as c,s as d,u,i}from"../chunks/languageUtils.js";function m(a){p=a}let p;function f(m){return null===m?null:e(m)?m.clone():s(m)?m:r(m)?m.clone():l(m)?m.toArray().map((a=>f(a))):n(m)?m.map((a=>f(a))):o(m)?p.createFromArcadeFeature(m):t(m)||c(m)?m:d(m)||"esri.arcade.Attachment"===m?.declaredClass?m.deepClone():("esri.arcade.Portal"===m?.declaredClass||u(m)||m instanceof a||i(m),m)}export{m as configureDeepClone,f as deepClone};
|