@arcgis/core 5.2.0-next.129 → 5.2.0-next.130
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/Feature.js +1 -1
- package/arcade/Voxel.js +1 -1
- package/arcade/functions/feature.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/arcade.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/051ccfea4268b357c44a.js +1 -0
- package/assets/esri/core/workers/chunks/1012cd1dff551025e605.js +1 -0
- package/assets/esri/core/workers/chunks/1538cfa272658871a3ad.js +1 -0
- package/assets/esri/core/workers/chunks/15f0cb6af89bafea61dc.js +1 -0
- package/assets/esri/core/workers/chunks/{8cb216404a6254bc695c.js → 18d5bad86ea3ef3ec747.js} +47 -47
- package/assets/esri/core/workers/chunks/{f652d1db26fbdea1a79b.js → 19fd46743daecd1f2dcb.js} +1 -1
- package/assets/esri/core/workers/chunks/{81327e10200065a0ccef.js → 1b5e0ab7e4f64a3aae09.js} +1 -1
- package/assets/esri/core/workers/chunks/1e66240ef0ae351d3275.js +1 -0
- package/assets/esri/core/workers/chunks/260fb3e021fe1a8e7ef1.js +1 -0
- package/assets/esri/core/workers/chunks/276cc95ae152ecf3048e.js +1 -0
- package/assets/esri/core/workers/chunks/34b6307fdd0226914dc4.js +1 -0
- package/assets/esri/core/workers/chunks/353acc00762b5ca450ef.js +1 -0
- package/assets/esri/core/workers/chunks/3df58dc89f2160893c66.js +1 -0
- package/assets/esri/core/workers/chunks/{1a02c68de65a67ab6a67.js → 550d8631450bb5eb7a6f.js} +1 -1
- package/assets/esri/core/workers/chunks/{f92178ac6dc9abff304f.js → 5f610ccf07bc73942b28.js} +1 -1
- package/assets/esri/core/workers/chunks/650618e7bfd932b9c5ff.js +1 -0
- package/assets/esri/core/workers/chunks/{cd1821bf601949674e02.js → 6ca2898aa500c81c7a8e.js} +1 -1
- package/assets/esri/core/workers/chunks/6fbc76b6e3494a09814e.js +1 -0
- package/assets/esri/core/workers/chunks/7185de70abe4face6f6e.js +1 -0
- package/assets/esri/core/workers/chunks/8048ce97ce22b32c454d.js +1 -0
- package/assets/esri/core/workers/chunks/9238409c942c24e26a0f.js +1 -0
- package/assets/esri/core/workers/chunks/{540acf6abdee9dbd453e.js → 92ec93287d4598377def.js} +1 -1
- package/assets/esri/core/workers/chunks/{88610ebfdf9c93ada781.js → 9c87a7f14298fd5e6c1d.js} +1 -1
- package/assets/esri/core/workers/chunks/a12773419465999fafe7.js +1 -0
- package/assets/esri/core/workers/chunks/{a3a5cb664bdb1db190dd.js → a61395db617fd26f048f.js} +1 -1
- package/assets/esri/core/workers/chunks/a826b7d9e6c59e951cb2.js +1 -0
- package/assets/esri/core/workers/chunks/a84cac7963ca3258bd75.js +1 -0
- package/assets/esri/core/workers/chunks/{c94bdfed831c775e04c0.js → abdb34cfaff49472223c.js} +1 -1
- package/assets/esri/core/workers/chunks/ba1d9d3cb90636dc9814.js +1 -0
- package/assets/esri/core/workers/chunks/bcab8bcb1fb1fd2aa65a.js +1 -0
- package/assets/esri/core/workers/chunks/d713c8d36cb7ed943003.js +1 -0
- package/assets/esri/core/workers/chunks/da8c881ea2dfcad8bbba.js +1 -0
- package/assets/esri/core/workers/chunks/ddafe5dfe178288ed721.js +1 -0
- package/assets/esri/core/workers/chunks/e5d2247187764c149854.js +1 -0
- package/assets/esri/core/workers/chunks/e706296a91780c665ab7.js +1 -0
- package/assets/esri/core/workers/chunks/e8a1abc881decf66e260.js +1 -0
- package/assets/esri/core/workers/chunks/ef527a7ea65fe6530a3e.js +1 -0
- package/assets/esri/core/workers/chunks/f5e24f1c38fe494585a8.js +1 -0
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.ar.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.bg.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.bs.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.ca.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.cs.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.da.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.de.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.el.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.es.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.et.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.fi.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.fr.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.he.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.hr.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.hu.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.id.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.it.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.ja.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.ko.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.lt.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.lv.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.nl.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.no.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.pl.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.pt-BR.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.pt-PT.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.ro.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.ru.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.sk.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.sl.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.sr.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.sv.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.th.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.tr.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.uk.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.vi.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.zh-CN.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.zh-HK.json +1 -1
- package/assets/esri/views/3d/analysis/ShadowCast/t9n/messages.zh-TW.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ar.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.bg.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.bs.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ca.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.cs.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.da.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.de.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.el.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.es.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.et.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.fi.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.fr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.he.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.hr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.hu.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.id.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.it.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ja.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ko.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.lt.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.lv.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.nl.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.no.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.pl.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.pt-BR.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.pt-PT.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ro.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ru.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sk.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sl.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sv.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.th.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.tr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.uk.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.vi.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.zh-CN.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.zh-HK.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.zh-TW.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/messages.en.json +1 -1
- package/chunks/GlobalIllumination.glsl.js +1 -1
- package/config.js +1 -1
- package/geometry/support/heightModelInfoUtils.js +1 -1
- package/graphic/AggregateGraphicOrigin.js +1 -1
- package/graphic/AnnotationFeatureGraphicOrigin.js +1 -1
- package/graphic/BuildingGraphicOrigin.js +1 -1
- package/graphic/CSVGraphicOrigin.js +1 -1
- package/graphic/CatalogGraphicOrigin.js +1 -1
- package/graphic/DimensionFeatureGraphicOrigin.js +1 -1
- package/graphic/FeatureGraphicOrigin.js +1 -1
- package/graphic/GeoJSONGraphicOrigin.js +1 -1
- package/graphic/ImageryGraphicOrigin.js +1 -1
- package/graphic/ImageryTileGraphicOrigin.js +1 -1
- package/graphic/KnowledgeGraphGraphicOrigin.js +1 -1
- package/graphic/LinkChartGraphicOrigin.js +1 -1
- package/graphic/MapImageGraphicOrigin.js +1 -1
- package/graphic/OGCFeatureGraphicOrigin.js +1 -1
- package/graphic/OrientedImageryGraphicOrigin.js +1 -1
- package/graphic/ParquetGraphicOrigin.js +1 -1
- package/graphic/PointCloudGraphicOrigin.js +1 -1
- package/graphic/SceneGraphicOrigin.js +1 -1
- package/graphic/StreamGraphicOrigin.js +1 -1
- package/graphic/SubtypeGroupGraphicOrigin.js +1 -1
- package/graphic/TileGraphicOrigin.js +1 -1
- package/graphic/TrackGraphicOrigin.js +1 -1
- package/graphic/WCSGraphicOrigin.js +1 -1
- package/graphic/WFSGraphicOrigin.js +1 -1
- package/graphic/getArcadeFeatureSource.js +2 -0
- package/kernel.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/package.json +3 -3
- package/support/arcadeUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/selection/types.d.ts +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/videoViewerUtils.js +1 -1
- package/widgets/PanoramicViewer/PanoramicVideoViewerViewModel.js +1 -1
- package/widgets/Sketch/support/PluginManager.js +1 -1
- package/widgets/support/SelectionList/FeatureItem.d.ts +14 -0
- package/widgets/support/SelectionList/FeatureItem.js +1 -1
- package/widgets/support/SelectionList.js +1 -1
- package/assets/esri/core/workers/chunks/06da350b4ea25732f52b.js +0 -1
- package/assets/esri/core/workers/chunks/0de140199161fcd15a0c.js +0 -1
- package/assets/esri/core/workers/chunks/0deceece4b465f653f58.js +0 -1
- package/assets/esri/core/workers/chunks/15dc28b4fa5b5110472b.js +0 -1
- package/assets/esri/core/workers/chunks/1beb32170d659bc43977.js +0 -1
- package/assets/esri/core/workers/chunks/237795866c075880531b.js +0 -1
- package/assets/esri/core/workers/chunks/25e4da9c6837ab0fa585.js +0 -1
- package/assets/esri/core/workers/chunks/28a04887ecaee5445d14.js +0 -1
- package/assets/esri/core/workers/chunks/2a5fde737dc99627142e.js +0 -1
- package/assets/esri/core/workers/chunks/323451ef52d0c2805f1d.js +0 -1
- package/assets/esri/core/workers/chunks/397ddcf0b8e858a17b70.js +0 -1
- package/assets/esri/core/workers/chunks/3d174a84b785fc633a5a.js +0 -1
- package/assets/esri/core/workers/chunks/5f794f4e0113d5dd50ba.js +0 -1
- package/assets/esri/core/workers/chunks/6994ba168465b77a36af.js +0 -1
- package/assets/esri/core/workers/chunks/7fccf53aa751cd9dae57.js +0 -1
- package/assets/esri/core/workers/chunks/88e11b645a1361f1bdbe.js +0 -1
- package/assets/esri/core/workers/chunks/8b0d6205ceeec1ab446f.js +0 -1
- package/assets/esri/core/workers/chunks/8dfea65341991e13ab71.js +0 -1
- package/assets/esri/core/workers/chunks/ab0b2a76247dfd56b92d.js +0 -1
- package/assets/esri/core/workers/chunks/ad372e399e20d5a3262d.js +0 -1
- package/assets/esri/core/workers/chunks/bb831d23422acfb00ae2.js +0 -1
- package/assets/esri/core/workers/chunks/bd231bc0624eb889ac14.js +0 -1
- package/assets/esri/core/workers/chunks/cf7b7e54cd87422ca62a.js +0 -1
- package/assets/esri/core/workers/chunks/df6992416cba9539f1ed.js +0 -1
- package/assets/esri/core/workers/chunks/e4005d95a396e1af9ac2.js +0 -1
- package/assets/esri/core/workers/chunks/ec187933b42fe65594b7.js +0 -1
- package/assets/esri/core/workers/chunks/f7ab606be37373312ebe.js +0 -1
- package/assets/esri/core/workers/chunks/fe1787a8d499832996b3.js +0 -1
package/arcade/Feature.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{ArcadeDate as e}from"./ArcadeDate.js";import{configureDeepClone as t}from"./deepClone.js";import{ArcadeExecutionError as s}from"./executionError.js";import{k as i,c as r,t as
|
|
2
|
+
import{ArcadeDate as e}from"./ArcadeDate.js";import{configureDeepClone as t}from"./deepClone.js";import{ArcadeExecutionError as s}from"./executionError.js";import{k as i,c as r,t as n,b as a,a as l,f as o,q as u,r as d,d as c}from"../chunks/languageUtils.js";import{createArcadeGeometryFromAccessorGeometry as f}from"./geometry/adapters/accessor.js";import{createArcadeGeometryFromUnknownJsonGeometry as m}from"./geometry/adapters/json.js";import{DateOnly as y}from"../core/sql/DateOnly.js";import{TimeOnly as h}from"../core/sql/TimeOnly.js";import p from"../geometry/Geometry.js";import{getArcadeFeatureSource as T}from"../graphic/getArcadeFeatureSource.js";import b from"../layers/support/FieldsIndex.js";import{isString as F,isNumber as g,isBoolean as _,isDate as w}from"../support/guards.js";function x(e){switch(e.type){case"small-integer":case"esriFieldTypeSmallInteger":case"integer":case"esriFieldTypeInteger":case"single":case"esriFieldTypeSingle":case"double":case"esriFieldTypeDouble":case"big-integer":case"esriFieldTypeBigInteger":case"long":case"esriFieldTypeLong":case"oid":case"esriFieldTypeOID":return{name:e.name,type:"number"};case"global-id":case"esriFieldTypeGlobalID":case"guid":case"esriFieldTypeGUID":case"string":case"esriFieldTypeString":return{name:e.name,type:"text"};case"date":case"esriFieldTypeDate":case"timestamp-offset":case"esriFieldTypeTimestampOffset":return{name:e.name,type:"date"};case"date-only":case"esriFieldTypeDateOnly":return{name:e.name,type:"dateOnly"};case"time-only":case"esriFieldTypeTimeOnly":return{name:e.name,type:"time"};default:return null}}function D(t,s,i){if(null==t)return null;switch(s){case"time-only":return d(t)?t:h.fromReader(t.toString());case"date-only":return u(t)?t:y.fromReader(t.toString());case"timestamp-offset":return o(t)?t:e.fromReaderAsTimeStampOffset(t.toString());case"date":return o(t)?t:w(t)?e.dateJSAndZoneToArcadeDate(t,i):e.epochToArcadeDate(t,i);case"geometry":return null;default:return t}}function I(e){if(null==e)return null;if(c(e))return e;if(null==e.spatialReference)throw new Error("spatialReference required");return e instanceof p?f(e):m(e,null)}class j{constructor(){this.arcadeDeclaredClass="esri.arcade.Feature",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 s=new j;s.contextTimeZone=t??null,s._geometry=I(e.geometry),s.attributes=e.attributes??Object.create(null);const i=null!=e.layer&&"fields"in e.layer?e.layer:T(e.origin)??e.sourceLayer;return null!=i&&(s._layer=i,s._fieldTypesFixed=!1,s.fieldsIndex=this.hydrateFieldsIndex(i)),s}static createFromArcadeFeature(e){if(e instanceof j){const t=new j;return t._fieldTypesFixed=e._fieldTypesFixed,t.attributes=e.attributes,t._geometry=e._geometry,e._layer&&(t._layer=e._layer),t.fieldsIndex=e.fieldsIndex,t.contextTimeZone=e.contextTimeZone,t}const t={};for(const s of e.keys())t[s]=e.field(s);return j.createFromGraphicLikeObject(e.geometry(),t,e.fullSchema(),e.contextTimeZone)}static fromArcadeParts(e,t){const s=new j;return null==t?s.attributes=Object.create(null):null!=Object.getPrototypeOf(t)?s.attributes={__proto__:null,...t}:s.attributes=t,s._geometry=e??null,s.immutable=!1,s}static createFromGraphicLikeObject(e,t,s=null,i){const r=new j;return r.contextTimeZone=i??null,r.attributes=t??Object.create(null),r._geometry=I(e),r._layer=s,r._layer&&(r._fieldTypesFixed=!1,r.fieldsIndex=this.hydrateFieldsIndex(r._layer)),r}static hydrateFieldsIndex(e){return null==e?null:i(e)?e.getFieldsIndex():e.fieldsIndex?e.fieldsIndex:b.fromLayerJSON({datesInUnknownTimezone:e.datesInUnknownTimezone,fields:e.fields,timeInfo:e.timeInfo,editFieldsInfo:e.editFieldsInfo,dateFieldsTimeReference:e.dateFieldsTimeReference??{timeZone:"UTC",respectsDaylightSaving:!1}})}castToText(e=!1){!1===this._fieldTypesFixed&&this._fixFieldTypes();const t=r(this.attributes,{useNumbersForDates:e});return'{"geometry":'+(null===this.geometry()?"null":n(this.geometry()))+',"attributes":'+t+"}"}_fixFieldTypes(){if(this._fieldsToFixDataTypes&&this._fieldsToFixDataTypes?.length>0)return this._fixAllFields(this._fieldsToFixDataTypes),void(this._fieldTypesFixed=!0);const e=[],t=this._layer.fields;for(let s=0;s<(t?.length??0);s++){const i=t[s],{name:r,type:n}=i;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"});break;case"geometry":case"esriFieldTypeGeometry":e.push({field:r,dataType:"geometry"})}}this._fieldsToFixDataTypes=e,e.length>0&&this._fixAllFields(e),this._fieldTypesFixed=!0}isUnknownDateTimeField(e){return"unknown"===this.fieldsIndex?.getTimeZone(e)}_fixAllFields(e){this.attributes={...this.attributes};const t=this.contextTimeZone??"system";for(let s=0;s<e.length;s++){const i=e[s].field,r=e[s].dataType;let n=this.attributes[i];if(void 0===n){for(const e in this.attributes)if(e.toLowerCase()===i.toLowerCase()){n=this.attributes[e],this.attributes[e]=D(n,r,this.isUnknownDateTimeField(e)?"unknown":t);break}}else null!==n&&(this.attributes[i]=D(n,r,this.isUnknownDateTimeField(i)?"unknown":t))}}geometry(){return 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("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("Immutable",null);if(i instanceof Date&&(i=this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(i):e.dateJSToArcadeDate(i)),!1===a(i))throw new s("TypeNotAllowedInFeature",null);const r=t.toLowerCase();if(void 0===this.attributes[t]){for(const e in this.attributes)if(e.toLowerCase()===r)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 s in this.attributes)if(s.toLowerCase()===t)return!0;return!!this._hasFieldDefinition(t)}keys(){const e=[],t=new Set;for(const s in this.attributes)e.push(s),t.add(s.toLowerCase());if(null!==this._layer)for(let s=0;s<this._layer.fields.length;s++){const i=this._layer.fields[s];t.has(i.name.toLowerCase())||e.push(i.name)}return e.sort((e,t)=>e.toLowerCase()<t.toLowerCase()?-1:1)}isEmpty(){for(const e in this.attributes)return!1;return!(null!=this._layer&&this._layer.fields.length>0)&&null==this.geometry()}static parseAttributesFromDictionary(e){const t=Object.create(null);for(const i in e.attributes){const r=e.attributes[i];if(!a(r))throw new s("InvalidParameter",null);t[i]=r}return t}static parseFromJson(e,t){const i=JSON.parse(e);if(null==i||"object"!=typeof i)throw new s("InvalidParameter",null);let r=null;"geometry"in i&&null!=i.geometry&&(r=m(i.geometry,t));const n=Object.create(null);if("attributes"in i&&null!=i.attributes)for(const[a,l]of Object.entries(i.attributes)){if(!(null==l||F(l)||g(l)||_(l)))throw new s("InvalidParameter",null);n[a]=l}return j.fromArcadeParts(r,n)}fullSchema(){return this._layer}gdbVersion(){return this._layer?.gdbVersion??""}castAsJson(){const e={attributes:{},geometry:this.geometry()?.castAsJson()??null};for(const t in this.attributes){const s=this.attributes[t];void 0!==s&&(e.attributes[t]=l(s))}return e}async castAsJsonAsync(){return this.castAsJson()}}t(j);export{j as Feature,D as convertAttributeToArcadeValue,x as getArcadeVariableForField};
|
package/arcade/Voxel.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{ArcadeDate as e}from"./ArcadeDate.js";import{ArcadeExecutionError as t}from"./executionError.js";import r from"./ImmutableArray.js";import{c as i}from"../chunks/languageUtils.js";import{isDate as s}from"../support/guards.js";const
|
|
2
|
+
import{ArcadeDate as e}from"./ArcadeDate.js";import{ArcadeExecutionError as t}from"./executionError.js";import r from"./ImmutableArray.js";import{c as i}from"../chunks/languageUtils.js";import{isVoxelGraphicOrigin as n}from"../graphic/isVoxelGraphicOrigin.js";import{isDate as s}from"../support/guards.js";const a="Voxel.Position",o="Voxel.LocalTime";function l(e){const i=e.getAttribute(a);if("string"!=typeof i)throw new t("InvalidParameter",null);const n=JSON.parse(i);if(!Array.isArray(n)||"number"!=typeof n[0]||"number"!=typeof n[1]||"number"!=typeof n[2])throw new t("InvalidParameter",null);return r.from(n.slice(0,3))}function u(r,i){const n=r.getAttribute(o);if(null==n)return null;if(!s(n))throw new t("InvalidParameter",null);return e.dateJSAndZoneToArcadeDate(n,i)}class m{constructor(e,t,r){this._graphic=e,this._layer=t,this._timeZone=r,this.arcadeDeclaredClass="esri.arcade.Voxel"}static fromVoxelGraphic(e,r){if(!n(e.origin))throw new t("InvalidParameter",null);return new m(e,e.origin.layer,r)}static getDeclaredMembers(e){return e.fields.map(e=>{switch(e.name){case a:return{name:e.name,type:"array",elementType:{type:"number"}};case o:return{name:e.name,type:"date"};default:switch(e.type){case"string":return{name:e.name,type:"text"};case"double":return{name:e.name,type:"number"}}return null}}).filter(e=>null!=e)}getPosition(){return void 0!==this._position?this._position:this._position=l(this._graphic)}getLocalTime(){return void 0!==this._localTime?this._localTime:this._localTime=u(this._graphic,this._timeZone??"system")}keys(){return this._layer.fields.map(e=>e.name).sort((e,t)=>e.toLowerCase()<t.toLowerCase()?-1:1)}hasField(e){return this._layer.fieldsIndex.has(e)}field(e){const r=this._layer.fieldsIndex?.get(e)?.name;if(null==r)throw new t("FieldNotFound",null,{key:e});switch(r){case a:return this.getPosition();case o:return this.getLocalTime()}return this._graphic.attributes[r]??null}entryCount(){return this._layer.fields.length}isEmpty(){return this.entryCount()<=0}castToText(e=!1){const t={...this._graphic.attributes};t[a]=this.getPosition(),o in t&&(t[o]=this.getLocalTime());for(const r of Object.keys(t))this._layer.fieldsIndex?.has(r)||delete t[r];return i(t,{useNumbersForDates:e})}}export{m as Voxel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{ArcadeDate as e}from"../ArcadeDate.js";import{toSymbolId as r}from"../arcadeEnvironment.js";import{convertDomainInfoToArcadeValue as t,convertJsonValueToImmutableArcadeValue as n}from"../containerUtils.js";import{ArcadeExecutionError as i}from"../executionError.js";import{Feature as o}from"../Feature.js";import{E as s,h as a,W as u,w as f,X as l,Y as m,x as d,Z as c,_ as p,f as w}from"../../chunks/languageUtils.js";import{SqlTimeStampOffset as
|
|
2
|
+
import{ArcadeDate as e}from"../ArcadeDate.js";import{toSymbolId as r}from"../arcadeEnvironment.js";import{convertDomainInfoToArcadeValue as t,convertJsonValueToImmutableArcadeValue as n}from"../containerUtils.js";import{ArcadeExecutionError as i}from"../executionError.js";import{Feature as o}from"../Feature.js";import{E as s,h as a,W as u,w as f,X as l,Y as m,x as d,Z as c,_ as p,f as w,k as h}from"../../chunks/languageUtils.js";import{SqlTimeStampOffset as v}from"../../core/sql/SqlTimestampOffset.js";import b from"../../core/sql/WhereClause.js";import{internalTimeReceivedField as y}from"../../layers/support/streamLayerUtils.js";import{isString as I,isNumber as F}from"../../support/guards.js";function g(e){const r=e?.fullSchema();return r?.datesInUnknownTimezone?"unknown":r?.dateFieldsTimeZone||"UTC"}function P(e){const r=e.fullSchema(),t=h(r)?r.getFieldsIndex():r?.fieldsIndex;return null==t&&e instanceof o?e.fieldsIndex:t}const j={getAttributeSQL(e,r){const t=e.field(r);if(null==t)return t;if(w(t)){const n=t.toDateTime(),i=P(e)?.get(r)?.type;return"esriFieldTypeTimestampOffset"===i||"timestamp-offset"===i?v.fromDateTime(n):n}return t}};function T(o,h,v){o.domain=function(e,r){return h(e,r,(e,n,o)=>{if(s(o,2,3,r),a(o[0])){const e=u(o[0],f(o[1]),void 0===o[2]?void 0:o[2]);return t(e)}throw new i("InvalidParameter",r)})},o.domaincode=function(e,r){return h(e,r,(e,t,n)=>{if(s(n,2,4,r),a(n[0]))return l(n[0],f(n[1]),n[2],void 0===n[3]?void 0:n[3]);throw new i("InvalidParameter",r)})},o.domainname=function(e,r){return h(e,r,(e,t,n)=>{if(s(n,2,4,r),a(n[0]))return m(n[0],f(n[1]),n[2],void 0===n[3]?void 0:n[3]);throw new i("InvalidParameter",r)})},o.expects=function(e,r){return h(e,r,(e,t,n)=>{if(n.length<1)throw new i("WrongNumberOfParameters",r);return d})},o.featureinfilter=function(e,r){return h(e,r,(e,r,t)=>{s(t,2,2,r);const[n,o]=t;if(null==n)return!1;if(""===o||null==o)return!0;if(!a(n)||!I(o))throw new i("InvalidParameter",r);const u=b.create(o,{fieldsIndex:P(n),timeZone:g(n)}),f=u.getVariables();for(const i of f)u.parameters[i]=v(e,{name:i});return u.testFeature(n,j)})},o.gdbversion=function(e,r){return h(e,r,(e,t,n)=>{if(s(n,1,1,r),a(n[0]))return n[0].gdbVersion();throw new i("InvalidParameter",r)})},o.schema=function(e,r){return h(e,r,(e,t,o)=>{if(a(o[0]))return n(c(o[0]));throw new i("InvalidParameter",r)})},o.subtypecode=function(e,r){return h(e,r,(e,t,n)=>{if(s(n,1,1,r),a(n[0])){const e=p(n[0]);if(!e)return null;if(e.subtypeField&&n[0].hasField(e.subtypeField)){const r=n[0].field(e.subtypeField);for(const t of e.subtypes)if(t.code===r)return t.code;return null}return null}throw new i("InvalidParameter",r)})},o.subtypename=function(e,r){return h(e,r,(e,t,n)=>{if(s(n,1,1,r),a(n[0])){const e=p(n[0]);if(!e)return"";if(e.subtypeField&&n[0].hasField(e.subtypeField)){const r=n[0].field(e.subtypeField);for(const t of e.subtypes)if(t.code===r)return t.name;return""}return""}throw new i("InvalidParameter",r)})},o.subtypes=function(e,r){return h(e,r,(e,t,o)=>{if(s(o,1,1,r),a(o[0]))return n(p(o[0]));throw new i("InvalidParameter",r)})},o[r("TimeReceived")]=function(r,t){return h(r,t,(r,t,n)=>{if(s(n,1,1,t),a(n[0])){if(n[0].hasField(y)){const t=n[0].field(y);return F(t)?e.epochToArcadeDate(t,r.timeZone??"system"):w(t)?t:null}return null}throw new i("InvalidParameter",t)})}}export{T as registerFunctions};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"../../Graphic.js";import{ArcadeDate as t}from"../ArcadeDate.js";import n from"../ArcadePortal.js";import i from"../Dictionary.js";import{StringEnum as a,toStringEnumKey as r}from"../enum.js";import{ArcadeExecutionError as o}from"../executionError.js";import{Feature as s}from"../Feature.js";import{convertToFeatureSet as l,constructFeatureSetFromPortalItem as f,constructFeatureSet as d,constructFeatureSetFromRelationship as u,constructFeatureSetFromUrl as c,constructAssociationMetaDataFeatureSetFromUrl as m}from"../featureSetUtils.js";import p from"../ImmutableArray.js";import{E as y,r as w,q as h,k as I,w as g,T as F,S as b,f as T,j as D,M as E,N as x,h as N,g as A,i as S,v,P as L,a1 as j}from"../../chunks/languageUtils.js";import{getPortal as C,getDefaultPortal as k}from"../portalUtils.js";import{SqlExpressionAdapted as Z,StringToCodeAdapted as $,FieldRename as P,AdaptedFeatureSet as U,OriginalField as M}from"../featureset/actions/Adapted.js";import R from"../featureset/actions/AttributeFilter.js";import O from"../featureset/actions/GroupBy.js";import z from"../featureset/actions/OrderBy.js";import W from"../featureset/actions/Top.js";import H from"../featureset/sources/Empty.js";import G from"../featureset/sources/FeatureLayerMemory.js";import _ from"../featureset/support/OrderbyClause.js";import{isSupportedLayer as V,cloneField as q}from"../featureset/support/shared.js";import{isSingleField as B}from"../featureset/support/sqlUtils.js";import{distinct as K}from"./fieldStats.js";import{isPromiseLike as Q}from"../../core/promiseUtils.js";import J from"../../core/sql/WhereClause.js";import Y from"../../layers/FeatureLayer.js";import X from"../../layers/support/Field.js";import{queryAssociations as ee}from"../../rest/networks/queryAssociations.js";import te from"../../rest/networks/support/NetworkElement.js";import ne from"../../rest/networks/support/QueryAssociationsParameters.js";import{isString as ie,isArray as ae,isInteger as re}from"../../support/guards.js";function oe(e){if(1===e.length){if(ae(e[0]))return K(e[0],-1);if(A(e[0]))return K(e[0].toArray(),-1)}return K(e,-1)}function se(e,t,n){const i=e.getVariables();if(i.length>0){const a={};for(const e of i)a[e]=t.evaluateIdentifier(n,{name:e});e.parameters=a}return e}function le(e,t,n=null){for(const i in e)if(i.toLowerCase()===t.toLowerCase())return e[i];return n}function fe(e){if(null===e)return null;const t={type:le(e,"type",""),name:le(e,"name","")};if("range"===t.type)t.range=le(e,"range",[]);else{t.codedValues=[];for(const n of le(e,"codedValues",[]))t.codedValues.push({name:le(n,"name",""),code:le(n,"code",null)})}return t}function de(e){if(null===e)return null;const t={},n=le(e,"wkt");null!==n&&(t.wkt=n);const i=le(e,"wkid");return null!==i&&(t.wkid=i),t}function ue(e){if(null===e)return null;const t={hasZ:le(e,"hasz",!1),hasM:le(e,"hasm",!1)},n=le(e,"spatialreference");null!=n&&(t.spatialReference=de(n));const i=le(e,"x",null);if(null!==i)return t.x=i,t.y=le(e,"y",null),t.hasZ&&(t.z=le(e,"z",null)),t.hasM&&(t.m=le(e,"m",null)),t;const a=le(e,"rings",null);if(null!==a)return t.rings=a,t;const r=le(e,"paths",null);if(null!==r)return t.paths=r,t;const o=le(e,"points",null);if(null!==o)return t.points=o,t;for(const s of["xmin","xmax","ymin","ymax","zmin","zmax","mmin","mmax"]){const n=le(e,s,null);null!==n&&(t[s]=n)}return t}function ce(e,t){for(const n of t)if(n===e)return!0;return!1}function me(e){return!!e.layerDefinition&&(!!e.featureSet&&(!1!==ce(e.layerDefinition.geometryType,["",null,"esriGeometryNull","esriGeometryPoint","esriGeometryPolyline","esriGeometryPolygon","esriGeometryMultipoint","esriGeometryEnvelope"])&&(!1!==ae(e.layerDefinition.fields)&&!1!==ae(e.featureSet.features))))}function pe(e){return"utc"===e?.toLowerCase()?"UTC":"unknown"===e?.toLowerCase()?"Unknown":e}async function ye(t,n,i,a,r,s){const l=await t.getFeatureSetInfo();if(null===(l?.layerId??null))return null;if(!r.layerIdLookup.get(l.layerId))return null;const f=t.serviceUrl().replace(/\/FeatureServer/i,"/UtilityNetworkServer"),u=[];switch(i){case"connected":u.push("connectivity"),u.push("junction-edge-from-connectivity"),u.push("junction-edge-to-connectivity"),u.push("junction-edge-midspan-connectivity"),u.push("junction-junction-connectivity");break;case"container":case"content":u.push("containment");break;case"structure":case"attached":u.push("attachment");break;case"junctionedge":u.push("junction-edge-from-connectivity"),u.push("junction-edge-to-connectivity");break;case"midspan":u.push("junction-edge-midspan-connectivity");break;default:throw new o("InvalidParameter",s)}let c=null,m=!1;if(null!==a&&""!==a&&void 0!==a){for(const e of r.terminals)e.terminalName===a&&(c=e.terminalId);null===c&&(m=!0)}const p=[];if(!m){const a=new te({globalId:n.field(t.globalIdField),networkSourceId:r.layerIdLookup.get(l.layerId).sourceId,...c?{terminalId:c}:""}),o=await ee(f,new ne({types:u,elements:[a]}));let s=0;for(const t of o.associations){let n=null,o="",l="";if(t.fromNetworkElement?.globalId===a.globalId?(n=t.toNetworkElement,l="to"):t.toNetworkElement?.globalId===a.globalId&&(n=t.fromNetworkElement,l="from"),!n)continue;switch(i){case"attached":if("attachment"!==t.associationType)continue;if("to"!==l)continue;break;case"structure":if("attachment"!==t.associationType)continue;if("from"!==l)continue;break;case"container":if("containment"!==t.associationType)continue;if("from"!==l)continue;break;case"content":if("containment"!==t.associationType)continue;if("to"!==l)continue;break;case"connected":break;case"junctionedge":"junction-edge-to-connectivity"===t.associationType?o="to":"junction-edge-from-connectivity"===t.associationType&&(o="from");break;case"midspan":if("junction-edge-midspan-connectivity"!==t.associationType)continue}const f=r.sourceIdLookup.get(n.networkSourceId)?.className??"";p.push(new e({geometry:null,attributes:{objectId:s++,globalId:n.globalId,percentAlong:t.percentAlong??0,isContentVisible:t.isContentVisible?0:1,className:f,side:o}}))}}const y=new Y({source:p,geometryType:null,objectIdField:"objectId",globalIdField:"globalId",fields:[new X({name:"objectId",alias:"objectId",type:"oid"}),new X({name:"globalId",alias:"globalId",type:"global-id"}),new X({name:"percentAlong",alias:"percentAlong",type:"double"}),new X({name:"side",alias:"side",type:"string"}),new X({name:"isContentVisible",alias:"isContentVisible",type:"integer"}),new X({name:"className",alias:"className",type:"string"})]});return d(y)}function we(e){if(null==e)return["*"];if(A(e)&&(e=e.toArray()),!ae(e))throw new o("InvalidParameter",null);for(const t of e)if(!ie(t))throw new o("InvalidParameter",null);return e}function he(e){if("async"===e.mode){e.functions.timezone=function(n,a){return e.standardFunctionAsync(n,a,async(e,r,s)=>{if(y(s,1,2,a),w(s[0]))return"Unknown";if(h(s[0]))return"Unknown";if(I(s[0])){if(await s[0].load(),1===s.length||null===s[1])return s[0].datesInUnknownTimezone?pe("unknown"):pe(s[0].dateFieldsTimeZone);if(!(s[1]instanceof i)||!1===s[1].hasField("type"))throw new o("InvalidParameter",a);const e=s[1].field("type");if(!1===ie(e))throw new o("InvalidParameter",a);switch(g(e).toLowerCase()){case"preferredtimezone":return pe(s[0].preferredTimeZone);case"editfieldsinfo":return pe(s[0].editFieldsInfo?.timeZone??null);case"timeinfo":return pe(s[0].timeInfo?.timeZone??null);case"field":if(s[1].hasField("fieldname")&&ie(s[1].field("fieldname")))return pe(s[0].fieldTimeZone(g(s[1].field("fieldname"))))}throw new o("InvalidParameter",a)}const l=F(s[0],b(n));if(null===l)return null;const f=l.timeZone;return"system"===f?t.systemTimeZoneCanonicalName:"utc"===f.toLowerCase()?"UTC":"unknown"===f.toLowerCase()?"Unknown":f})},e.functions.sqltimestamp=function(t,n){return e.standardFunctionAsync(t,n,async(e,t,i)=>{y(i,1,3,n);const a=i[0];if(T(a)){if(1===i.length)return a.toSQLWithKeyword();if(2===i.length)return a.changeTimeZone(g(i[1])).toSQLWithKeyword();throw new o("InvalidParameter",n)}if(h(a))return a.toSQLWithKeyword();if(I(a)){if(3!==i.length)throw new o("InvalidParameter",n);await a.load();const e=g(i[1]);if(h(i[2]))return i[2].toSQLWithKeyword();if(!1===T(i[2]))throw new o("InvalidParameter",n);const t=a.fieldTimeZone(e);return null==t?i[2].toSQLWithKeyword():i[2].changeTimeZone(t).toSQLWithKeyword()}throw new o("InvalidParameter",n)})},e.signatures.push({name:"sqltimestamp",min:2,max:4}),e.functions.featuresetbyid=function(t,n){return e.standardFunctionAsync(t,n,(e,t,i)=>{if(y(i,2,4,n),D(i[0])){const e=g(i[1]),t=we(i[2]),n=E(x(i[3],!0));return i[0].featureSetById(e,n,t)}throw new o("InvalidParameter",n)})},e.signatures.push({name:"featuresetbyid",min:2,max:4});const K=new a(["datasource","parent","root"]);e.functions.getfeatureset=function(t,n){return e.standardFunctionAsync(t,n,async(e,i,a)=>{if(y(a,1,2,n),N(a[0])){const e=null==a[1]?"datasource":K.lookup(g(a[1]));return l(a[0].fullSchema(),e,t.lrucache,t.interceptor,t.spatialReference)}throw new o("InvalidParameter",n)})},e.signatures.push({name:"getfeatureset",min:1,max:2}),e.functions.featuresetbyportalitem=function(t,i){return e.standardFunctionAsync(t,i,(e,a,r)=>{if(y(r,2,5,i),null===r[0])throw new o("PortalRequired",i);if(r[0]instanceof n){const e=g(r[1]),n=g(r[2]),i=we(r[3]),a=E(x(r[4],!0)),o=C(t,r[0]);return f(e,n,t.spatialReference,i,a,o,t.lrucache,t.interceptor)}if(!1===ie(r[0]))throw new o("PortalRequired",i);const s=g(r[0]),l=g(r[1]),d=we(r[2]),u=E(x(r[3],!0));return f(s,l,t.spatialReference,d,u,k(t),t.lrucache,t.interceptor)})},e.signatures.push({name:"featuresetbyportalitem",min:2,max:5}),e.functions.featuresetbyname=function(t,n){return e.standardFunctionAsync(t,n,(e,t,i)=>{if(y(i,2,4,n),D(i[0])){const e=g(i[1]),t=we(i[2]),n=E(x(i[3],!0));return i[0].featureSetByName(e,n,t)}throw new o("InvalidParameter",n)})},e.signatures.push({name:"featuresetbyname",min:2,max:4}),e.functions.featureset=function(t,n){return e.standardFunction(t,n,(e,a,r)=>{y(r,1,1,n);const s={layerDefinition:{geometryType:"",objectIdField:"",globalIdField:"",typeIdField:"",hasM:!1,hasZ:!1,fields:[]},featureSet:{geometryType:"",features:[]}};if(ie(r[0])){const e=JSON.parse(r[0]);void 0!==e.layerDefinition?(s.layerDefinition=e.layerDefinition,s.featureSet=e.featureSet,e.layerDefinition.spatialReference&&(s.layerDefinition.spatialReference=e.layerDefinition.spatialReference)):(s.featureSet.features=e.features,s.featureSet.geometryType=e.geometryType,s.layerDefinition.geometryType=s.featureSet.geometryType,s.layerDefinition.objectIdField=e.objectIdFieldName??"",s.layerDefinition.typeIdField=e.typeIdFieldName,s.layerDefinition.globalIdField=e.globalIdFieldName,s.layerDefinition.fields=e.fields,e.spatialReference&&(s.layerDefinition.spatialReference=e.spatialReference))}else{if(!(r[0]instanceof i))throw new o("InvalidParameter",n);{const e=JSON.parse(r[0].castToText(!0)),t=le(e,"layerdefinition");if(null!==t){s.layerDefinition.geometryType=le(t,"geometrytype",""),s.featureSet.geometryType=s.layerDefinition.geometryType,s.layerDefinition.globalIdField=le(t,"globalidfield",""),s.layerDefinition.objectIdField=le(t,"objectidfield",""),s.layerDefinition.typeIdField=le(t,"typeidfield",""),s.layerDefinition.hasZ=!0===le(t,"hasz",!1),s.layerDefinition.hasM=!0===le(t,"hasm",!1);const n=le(t,"spatialreference");n&&(s.layerDefinition.spatialReference=de(n));const i=[];for(const e of le(t,"fields",[])){const t={name:le(e,"name",""),alias:le(e,"alias",""),type:le(e,"type",""),nullable:le(e,"nullable",!0),editable:le(e,"editable",!0),length:le(e,"length",null),domain:fe(le(e,"domain"))};i.push(t)}s.layerDefinition.fields=i;const a=le(e,"featureset");if(a){const e={};for(const t of i)e[t.name.toLowerCase()]=t.name;for(const t of le(a,"features",[])){const n={},i=le(t,"attributes",{});for(const t in i)n[e[t.toLowerCase()]]=i[t];s.featureSet.features.push({attributes:n,geometry:ue(le(t,"geometry"))})}}}else{s.layerDefinition.hasZ=!0===le(e,"hasz",!1),s.layerDefinition.hasM=!0===le(e,"hasm",!1),s.layerDefinition.geometryType=le(e,"geometrytype",""),s.featureSet.geometryType=s.layerDefinition.geometryType,s.layerDefinition.objectIdField=le(e,"objectidfieldname",""),s.layerDefinition.typeIdField=le(e,"typeidfieldname","");const t=le(e,"spatialreference");t&&(s.layerDefinition.spatialReference=de(t));const i=[],a=le(e,"fields",null);if(!ae(a))throw new o("InvalidParameter",n);for(const e of a){const t={name:le(e,"name",""),alias:le(e,"alias",""),type:le(e,"type",""),nullable:le(e,"nullable",!0),editable:le(e,"editable",!0),length:le(e,"length",null),domain:fe(le(e,"domain"))};i.push(t)}s.layerDefinition.fields=i;const r={};for(const e of i)r[e.name.toLowerCase()]=e.name;let l=le(e,"features",null);if(ae(l))for(const e of l){const t={},n=le(e,"attributes",{});for(const e in n)t[r[e.toLowerCase()]]=n[e];s.featureSet.features.push({attributes:t,geometry:ue(le(e,"geometry",null))})}else l=null,s.featureSet.features=l}}}if(!1===me(s))throw new o("InvalidParameter",n);return s.layerDefinition.geometryType||(s.layerDefinition.geometryType="esriGeometryNull"),G.create(s,t.spatialReference)})},e.signatures.push({name:"featureset",min:1,max:1}),e.functions.filter=function(t,n){return e.standardFunctionAsync(t,n,async(i,a,r)=>{if(y(r,2,2,n),ae(r[0])||A(r[0])){const e=[];let i,a=r[0];if(a instanceof p&&(a=a.toArray()),!S(r[1]))throw new o("InvalidParameter",n);i=r[1].createFunction(t);for(const t of a){const n=i(t);Q(n)?!0===await n&&e.push(t):!0===n&&e.push(t)}return e}if(I(r[0])){const n=await r[0].load(),i=J.create(r[1],{fieldsIndex:n.getFieldsIndex(),timeZone:n.dateFieldsTimeZoneDefaultUTC}),a=i.getVariables();if(a.length>0){const n={};for(const i of a)n[i]=e.evaluateIdentifier(t,{name:i});i.parameters=n}return new R({parentfeatureset:r[0],whereclause:i})}throw new o("InvalidParameter",n)})},e.signatures.push({name:"filter",min:2,max:2}),e.functions.orderby=function(t,n){return e.standardFunctionAsync(t,n,async(e,t,i)=>{if(y(i,2,2,n),I(i[0])){const e=new _(i[1]);return new z({parentfeatureset:i[0],orderbyclause:e})}throw new o("InvalidParameter",n)})},e.signatures.push({name:"orderby",min:2,max:2}),e.functions.top=function(t,n){return e.standardFunctionAsync(t,n,async(e,t,i)=>{if(y(i,2,2,n),I(i[0]))return new W({parentfeatureset:i[0],topnum:i[1]});if(ae(i[0]))return v(i[1])>=i[0].length?i[0].slice():i[0].slice(0,v(i[1]));if(A(i[0]))return v(i[1])>=i[0].length()?i[0].slice():i[0].slice(0,v(i[1]));throw new o("InvalidParameter",n)})},e.signatures.push({name:"top",min:2,max:2}),e.functions.first=function(t,n){return e.standardFunctionAsync(t,n,async(e,i,a)=>{if(y(a,1,1,n),I(a[0])){const n=await a[0].first(e.abortSignal);if(null!==n){const e=s.createFromGraphicLikeObject(n.geometry,n.attributes,a[0],t.timeZone);return e._underlyingGraphic=n,e}return n}return ae(a[0])?0===a[0].length?null:a[0][0]:A(a[0])?0===a[0].length()?null:a[0].get(0):null})},e.signatures.push({name:"first",min:1,max:1}),e.functions.attachments=function(t,n){return e.standardFunctionAsync(t,n,async(e,a,r)=>{y(r,1,2,n);const s={minsize:-1,maxsize:-1,types:null,returnMetadata:!1};if(r.length>1)if(r[1]instanceof i){if(r[1].hasField("minsize")&&(s.minsize=v(r[1].field("minsize"))),r[1].hasField("metadata")&&(s.returnMetadata=E(r[1].field("metadata"))),r[1].hasField("maxsize")&&(s.maxsize=v(r[1].field("maxsize"))),r[1].hasField("types")){const e=L(r[1].field("types"),!1);e.length>0&&(s.types=e)}}else if(null!==r[1])throw new o("InvalidParameter",n);if(N(r[0])){const e=r[0]._layer;let n;if(I(e))n=e;else{if(null==e||!V(e))return[];n=d(e,t.spatialReference,["*"],!0,t.lrucache,t.interceptor)}return await n.load(),n.queryAttachments(r[0].field(n.objectIdField),s.minsize,s.maxsize,s.types,s.returnMetadata)}if(null===r[0])return[];throw new o("InvalidParameter",n)})},e.signatures.push({name:"attachments",min:1,max:2}),e.functions.featuresetbyrelationshipname=function(t,n){return e.standardFunctionAsync(t,n,async(e,i,a)=>{y(a,2,4,n);const r=a[0],s=g(a[1]),l=we(a[2]),f=E(x(a[3],!0));if(null===a[0])return null;if(!N(a[0]))throw new o("InvalidParameter",n);const m=r._layer;let p;if(I(m))p=m;else{if(null==m||!V(m))return null;p=d(m,t.spatialReference,["*"],!0,t.lrucache,t.interceptor)}p=await p.load();const w=p.relationshipMetadata().filter(e=>e.name===s);if(0===w.length)return null;if(void 0!==w[0].relationshipTableId&&null!==w[0].relationshipTableId&&w[0].relationshipTableId>-1)return u(p,w[0],r.field(p.objectIdField),p.spatialReference,l,f,t.lrucache,t.interceptor);let h=p.serviceUrl();if(!h)return null;h=h.endsWith("/")?h+w[0].relatedTableId.toString():h+"/"+w[0].relatedTableId.toString();const F=await c(h,p.spatialReference,l,f,t.lrucache,t.interceptor);await F.load();let b=F.relationshipMetadata();if(b=b.filter(e=>e.id===w[0].id),!1===r.hasField(w[0].keyField)||null===r.field(w[0].keyField)){const e=await p.getFeatureByObjectId(r.field(p.objectIdField),[w[0].keyField]);if(e){const t=J.create(b[0].keyField+"= @id",{fieldsIndex:F.getFieldsIndex(),timeZone:F.dateFieldsTimeZoneDefaultUTC});return t.parameters={id:e.attributes[w[0].keyField]},new R({parentfeatureset:F,whereclause:t})}return new H({parentfeatureset:F})}const T=J.create(b[0].keyField+"= @id",{fieldsIndex:F.getFieldsIndex(),timeZone:F.dateFieldsTimeZoneDefaultUTC});return T.parameters={id:r.field(w[0].keyField)},new R({parentfeatureset:F,whereclause:T})})},e.signatures.push({name:"featuresetbyrelationshipname",min:2,max:4}),e.functions.featuresetbyassociation=function(t,n){return e.standardFunctionAsync(t,n,async(e,i,a)=>{y(a,2,3,n);const s=a[0],l=r(g(x(a[1],""))),f=ie(a[2])?g(a[2]):null;if(null===a[0])return null;if(!N(a[0]))throw new o("InvalidParameter",n);const u=s._layer;let c;if(I(u))c=u;else{if(null==u||!V(u))return null;c=d(u,t.spatialReference,["*"],!0,t.lrucache,t.interceptor)}await c.load();const p=c.serviceUrl(),w=await m(p,t.spatialReference,!0);if(w.unVersion>=8)return await ye(c,s,l,f,w,n);const h=w.associations;if(null==h)return null;let F=null,b=null,T=!1;if(null!==f&&""!==f&&void 0!==f){for(const e of w.terminals)e.terminalName===f&&(b=e.terminalId);null===b&&(T=!0)}const D=h.getFieldsIndex(),E=D.get("TOGLOBALID").name,A=D.get("FROMGLOBALID").name,S=D.get("TOTERMINALID").name,v=D.get("FROMTERMINALID").name,L=D.get("FROMNETWORKSOURCEID").name,C=D.get("TONETWORKSOURCEID").name,k=D.get("ASSOCIATIONTYPE").name,R=D.get("ISCONTENTVISIBLE").name,O=D.get("OBJECTID").name;for(const t of c.fields)if("global-id"===t.type){F=s.field(t.name);break}let z=null,W=new Z(new X({name:"percentalong",alias:"percentalong",type:"double"}),J.create("0",{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC})),H=new Z(new X({name:"side",alias:"side",type:"string"}),J.create("''",{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC}));const G="globalid",_="globalId",B={};for(const t in w.lkp)B[t]=w.lkp[t].sourceId;const K=new $(new X({name:"classname",alias:"classname",type:"string"}),null,B);let Q="";switch(l){case"midspan":{Q=`((${E}='${F}') OR ( ${A}='${F}')) AND (${k} IN (5))`,K.codefield=J.create(`CASE WHEN (${E}='${F}') THEN ${L} ELSE ${C} END`,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC});const e=q(U.findField(h.fields,A));e.name=G,e.alias=G,z=new Z(e,J.create(`CASE WHEN (${A}='${F}') THEN ${E} ELSE ${A} END`,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC})),W=w.unVersion>=4?new M(U.findField(h.fields,D.get("PERCENTALONG").name)):new Z(new X({name:"percentalong",alias:"percentalong",type:"double"}),J.create("0",{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC}));break}case"junctionedge":{Q=`((${E}='${F}') OR ( ${A}='${F}')) AND (${k} IN (4,6))`,K.codefield=J.create(`CASE WHEN (${E}='${F}') THEN ${L} ELSE ${C} END`,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC});const e=q(U.findField(h.fields,A));e.name=G,e.alias=G,z=new Z(e,J.create(`CASE WHEN (${A}='${F}') THEN ${E} ELSE ${A} END`,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC})),H=new Z(new X({name:"side",alias:"side",type:"string"}),J.create(`CASE WHEN (${k}=4) THEN 'from' ELSE 'to' END`,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC}));break}case"connected":{let e=`${E}='@T'`,t=`${A}='@T'`;null!==b&&(e+=` AND ${S}=@A`,t+=` AND ${v}=@A`),Q="(("+e+") OR ("+t+"))",Q=j(Q,"@T",F??""),e=j(e,"@T",F??""),null!==b&&(e=j(e,"@A",b.toString()),Q=j(Q,"@A",b.toString())),K.codefield=J.create("CASE WHEN "+e+` THEN ${L} ELSE ${C} END`,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC});const n=q(U.findField(h.fields,A));n.name=G,n.alias=G,z=new Z(n,J.create("CASE WHEN "+e+` THEN ${A} ELSE ${E} END`,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC}));break}case"container":Q=`${E}='${F}' AND ${k} = 2`,null!==b&&(Q+=` AND ${S} = `+b.toString()),K.codefield=L,Q="( "+Q+" )",z=new P(U.findField(h.fields,A),G,G);break;case"content":Q=`(${A}='${F}' AND ${k} = 2)`,null!==b&&(Q+=` AND ${v} = `+b.toString()),K.codefield=C,Q="( "+Q+" )",z=new P(U.findField(h.fields,E),G,G);break;case"structure":Q=`(${E}='${F}' AND ${k} = 3)`,null!==b&&(Q+=` AND ${S} = `+b.toString()),K.codefield=L,Q="( "+Q+" )",z=new P(U.findField(h.fields,A),G,_);break;case"attached":Q=`(${A}='${F}' AND ${k} = 3)`,null!==b&&(Q+=` AND ${v} = `+b.toString()),K.codefield=C,Q="( "+Q+" )",z=new P(U.findField(h.fields,E),G,_);break;default:throw new o("InvalidParameter",n)}T&&(Q="1 <> 1");return new U({parentfeatureset:h,adaptedFields:[new M(U.findField(h.fields,O)),new M(U.findField(h.fields,R)),z,H,K,W],extraFilter:Q?J.create(Q,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC}):null})})},e.signatures.push({name:"featuresetbyassociation",min:2,max:6}),e.functions.groupby=function(t,n){return e.standardFunctionAsync(t,n,async(a,r,s)=>{if(y(s,3,3,n),!I(s[0]))throw new o("InvalidParameter",n);const l=await s[0].load(),f=[],d=[];let u=!1,c=[];if(ie(s[1]))c.push(s[1]);else if(s[1]instanceof i)c.push(s[1]);else if(ae(s[1]))c=s[1];else{if(!A(s[1]))throw new o("InvalidParameter",n);c=s[1].toArray()}for(const e of c)if(ie(e)){const t=J.create(g(e),{fieldsIndex:l.getFieldsIndex(),timeZone:l.dateFieldsTimeZoneDefaultUTC}),n=!0===B(t)?g(e):"%%%%FIELDNAME";f.push({name:n,expression:t}),"%%%%FIELDNAME"===n&&(u=!0)}else{if(!(e instanceof i))throw new o("InvalidParameter",n);{const t=e.hasField("name")?e.field("name"):"%%%%FIELDNAME",i=e.hasField("expression")?e.field("expression"):"";if("%%%%FIELDNAME"===t&&(u=!0),!t||!ie(t)||!ie(i))throw new o("InvalidParameter",n);f.push({name:t,expression:J.create(i||t,{fieldsIndex:l.getFieldsIndex(),timeZone:l.dateFieldsTimeZoneDefaultUTC})})}}if(c=[],ie(s[2]))c.push(s[2]);else if(ae(s[2]))c=s[2];else if(A(s[2]))c=s[2].toArray();else{if(!(s[2]instanceof i))throw new o("InvalidParameter",n);c.push(s[2])}for(const e of c){if(!(e instanceof i))throw new o("InvalidParameter",n);{const t=e.hasField("name")?e.field("name"):"",i=e.hasField("statistic")?e.field("statistic"):"",a=e.hasField("expression")?e.field("expression"):"";if(!(t&&ie(t)&&i&&ie(i)&&a&&ie(a)))throw new o("InvalidParameter",n);d.push({name:t,statistic:i,expression:J.create(a,{fieldsIndex:l.getFieldsIndex(),timeZone:l.dateFieldsTimeZoneDefaultUTC})})}}if(u){const e={};for(const n of l.fields)e[n.name.toLowerCase()]=1;for(const n of f)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);for(const n of d)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);let t=0;for(const n of f)if("%%%%FIELDNAME"===n.name){for(;1===e["field_"+t.toString()];)t++;e["field_"+t.toString()]=1,n.name="FIELD_"+t.toString()}}for(const n of f)se(n.expression,e,t);for(const n of d)se(n.expression,e,t);return new O({parentfeatureset:s[0],groupbyfields:f,statsfields:d})})},e.signatures.push({name:"groupby",min:3,max:3}),e.functions.distinct=function(t,n){return e.standardFunctionAsync(t,n,async(a,r,s)=>{if(I(s[0])){y(s,2,2,n);const a=await s[0].load(),r=[];let l=[];if(ie(s[1]))l.push(s[1]);else if(s[1]instanceof i)l.push(s[1]);else if(ae(s[1]))l=s[1];else{if(!A(s[1]))throw new o("InvalidParameter",n);l=s[1].toArray()}let f=!1;for(const e of l)if(ie(e)){const t=J.create(g(e),{fieldsIndex:a.getFieldsIndex(),timeZone:a.dateFieldsTimeZoneDefaultUTC}),n=!0===B(t)?g(e):"%%%%FIELDNAME";r.push({name:n,expression:t}),"%%%%FIELDNAME"===n&&(f=!0)}else{if(!(e instanceof i))throw new o("InvalidParameter",n);{const t=e.hasField("name")?e.field("name"):"%%%%FIELDNAME",i=e.hasField("expression")?e.field("expression"):"";if("%%%%FIELDNAME"===t&&(f=!0),!t||!ie(t)||!ie(i))throw new o("InvalidParameter",n);r.push({name:t,expression:J.create(i||t,{fieldsIndex:a.getFieldsIndex(),timeZone:a.dateFieldsTimeZoneDefaultUTC})})}}if(f){const e={};for(const n of a.fields)e[n.name.toLowerCase()]=1;for(const n of r)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);let t=0;for(const n of r)if("%%%%FIELDNAME"===n.name){for(;1===e["field_"+t.toString()];)t++;e["field_"+t.toString()]=1,n.name="FIELD_"+t.toString()}}for(const n of r)se(n.expression,e,t);return new O({parentfeatureset:s[0],groupbyfields:r,statsfields:[]})}return oe(s)})},e.functions.getfeaturesetinfo=function(t,n){return e.standardFunctionAsync(t,n,async(e,t,a)=>{if(y(a,1,1,n),!I(a[0]))return null;const r=await a[0].getFeatureSetInfo();return r?i.createMutable({__proto__:null,layerId:r.layerId,layerName:r.layerName,itemId:r.itemId,serviceLayerUrl:r.serviceLayerUrl,webMapLayerId:r.webMapLayerId??null,webMapLayerTitle:r.webMapLayerTitle??null,className:null,objectClassId:null}):null})},e.signatures.push({name:"getfeaturesetinfo",min:1,max:1}),e.functions.filterbysubtypecode=function(t,n){return e.standardFunctionAsync(t,n,async(e,t,i)=>{if(y(i,2,2,n),I(i[0])){const e=await i[0].load(),t=i[1];if(!re(t))throw new o("InvalidParameter",n);if(e.subtypeField){const t=J.create(`${e.subtypeField}= ${i[1]}`,{fieldsIndex:e.getFieldsIndex(),timeZone:e.dateFieldsTimeZoneDefaultUTC});return new R({parentfeatureset:i[0],whereclause:t})}if(null===e.typeIdField||""===e.typeIdField)throw new o("FeatureSetDoesNotHaveSubtypes",n);const a=J.create(`${e.typeIdField}= ${i[1]}`,{fieldsIndex:e.getFieldsIndex(),timeZone:e.dateFieldsTimeZoneDefaultUTC});return new R({parentfeatureset:i[0],whereclause:a})}throw new o("InvalidParameter",n)})},e.signatures.push({name:"filterbysubtypecode",min:2,max:2})}}export{he as registerFunctions};
|
|
2
|
+
import e from"../../Graphic.js";import{ArcadeDate as t}from"../ArcadeDate.js";import n from"../ArcadePortal.js";import i from"../Dictionary.js";import{StringEnum as a,toStringEnumKey as r}from"../enum.js";import{ArcadeExecutionError as o}from"../executionError.js";import{Feature as s}from"../Feature.js";import{convertToFeatureSet as l,constructFeatureSetFromPortalItem as f,constructFeatureSet as d,constructFeatureSetFromRelationship as u,constructFeatureSetFromUrl as c,constructAssociationMetaDataFeatureSetFromUrl as m}from"../featureSetUtils.js";import p from"../ImmutableArray.js";import{E as y,r as w,q as h,k as I,w as g,T as F,S as b,f as T,j as D,M as E,N as x,h as N,g as A,i as S,v,P as L,a1 as j}from"../../chunks/languageUtils.js";import{getPortal as C,getDefaultPortal as k}from"../portalUtils.js";import{SqlExpressionAdapted as Z,StringToCodeAdapted as $,FieldRename as P,AdaptedFeatureSet as U,OriginalField as M}from"../featureset/actions/Adapted.js";import R from"../featureset/actions/AttributeFilter.js";import O from"../featureset/actions/GroupBy.js";import z from"../featureset/actions/OrderBy.js";import W from"../featureset/actions/Top.js";import H from"../featureset/sources/Empty.js";import G from"../featureset/sources/FeatureLayerMemory.js";import V from"../featureset/support/OrderbyClause.js";import{isSupportedLayer as _,cloneField as q}from"../featureset/support/shared.js";import{isSingleField as B}from"../featureset/support/sqlUtils.js";import{distinct as K}from"./fieldStats.js";import{isPromiseLike as Q}from"../../core/promiseUtils.js";import J from"../../core/sql/WhereClause.js";import Y from"../../layers/FeatureLayer.js";import X from"../../layers/support/Field.js";import{queryAssociations as ee}from"../../rest/networks/queryAssociations.js";import te from"../../rest/networks/support/NetworkElement.js";import ne from"../../rest/networks/support/QueryAssociationsParameters.js";import{isString as ie,isArray as ae,isInteger as re}from"../../support/guards.js";function oe(e){if(1===e.length){if(ae(e[0]))return K(e[0],-1);if(A(e[0]))return K(e[0].toArray(),-1)}return K(e,-1)}function se(e,t,n){const i=e.getVariables();if(i.length>0){const a={};for(const e of i)a[e]=t.evaluateIdentifier(n,{name:e});e.parameters=a}return e}function le(e,t,n=null){for(const i in e)if(i.toLowerCase()===t.toLowerCase())return e[i];return n}function fe(e){if(null===e)return null;const t={type:le(e,"type",""),name:le(e,"name","")};if("range"===t.type)t.range=le(e,"range",[]);else{t.codedValues=[];for(const n of le(e,"codedValues",[]))t.codedValues.push({name:le(n,"name",""),code:le(n,"code",null)})}return t}function de(e){if(null===e)return null;const t={},n=le(e,"wkt");null!==n&&(t.wkt=n);const i=le(e,"wkid");return null!==i&&(t.wkid=i),t}function ue(e){if(null===e)return null;const t={hasZ:le(e,"hasz",!1),hasM:le(e,"hasm",!1)},n=le(e,"spatialreference");null!=n&&(t.spatialReference=de(n));const i=le(e,"x",null);if(null!==i)return t.x=i,t.y=le(e,"y",null),t.hasZ&&(t.z=le(e,"z",null)),t.hasM&&(t.m=le(e,"m",null)),t;const a=le(e,"rings",null);if(null!==a)return t.rings=a,t;const r=le(e,"paths",null);if(null!==r)return t.paths=r,t;const o=le(e,"points",null);if(null!==o)return t.points=o,t;for(const s of["xmin","xmax","ymin","ymax","zmin","zmax","mmin","mmax"]){const n=le(e,s,null);null!==n&&(t[s]=n)}return t}function ce(e,t){for(const n of t)if(n===e)return!0;return!1}function me(e){return!!e.layerDefinition&&(!!e.featureSet&&(!1!==ce(e.layerDefinition.geometryType,["",null,"esriGeometryNull","esriGeometryPoint","esriGeometryPolyline","esriGeometryPolygon","esriGeometryMultipoint","esriGeometryEnvelope"])&&(!1!==ae(e.layerDefinition.fields)&&!1!==ae(e.featureSet.features))))}function pe(e){return"utc"===e?.toLowerCase()?"UTC":"unknown"===e?.toLowerCase()?"Unknown":e}async function ye(t,n,i,a,r,s){const l=await t.getFeatureSetInfo();if(null===(l?.layerId??null))return null;if(!r.layerIdLookup.get(l.layerId))return null;const f=t.serviceUrl().replace(/\/FeatureServer/i,"/UtilityNetworkServer"),u=[];switch(i){case"connected":u.push("connectivity"),u.push("junction-edge-from-connectivity"),u.push("junction-edge-to-connectivity"),u.push("junction-edge-midspan-connectivity"),u.push("junction-junction-connectivity");break;case"container":case"content":u.push("containment");break;case"structure":case"attached":u.push("attachment");break;case"junctionedge":u.push("junction-edge-from-connectivity"),u.push("junction-edge-to-connectivity");break;case"midspan":u.push("junction-edge-midspan-connectivity");break;default:throw new o("InvalidParameter",s)}let c=null,m=!1;if(null!==a&&""!==a&&void 0!==a){for(const e of r.terminals)e.terminalName===a&&(c=e.terminalId);null===c&&(m=!0)}const p=[];if(!m){const a=new te({globalId:n.field(t.globalIdField),networkSourceId:r.layerIdLookup.get(l.layerId).sourceId,...c?{terminalId:c}:""}),o=await ee(f,new ne({types:u,elements:[a]}));let s=0;for(const t of o.associations){let n=null,o="",l="";if(t.fromNetworkElement?.globalId===a.globalId?(n=t.toNetworkElement,l="to"):t.toNetworkElement?.globalId===a.globalId&&(n=t.fromNetworkElement,l="from"),!n)continue;switch(i){case"attached":if("attachment"!==t.associationType)continue;if("to"!==l)continue;break;case"structure":if("attachment"!==t.associationType)continue;if("from"!==l)continue;break;case"container":if("containment"!==t.associationType)continue;if("from"!==l)continue;break;case"content":if("containment"!==t.associationType)continue;if("to"!==l)continue;break;case"connected":break;case"junctionedge":"junction-edge-to-connectivity"===t.associationType?o="to":"junction-edge-from-connectivity"===t.associationType&&(o="from");break;case"midspan":if("junction-edge-midspan-connectivity"!==t.associationType)continue}const f=r.sourceIdLookup.get(n.networkSourceId)?.className??"";p.push(new e({geometry:null,attributes:{objectId:s++,globalId:n.globalId,percentAlong:t.percentAlong??0,isContentVisible:t.isContentVisible?0:1,className:f,side:o}}))}}const y=new Y({source:p,geometryType:null,objectIdField:"objectId",globalIdField:"globalId",fields:[new X({name:"objectId",alias:"objectId",type:"oid"}),new X({name:"globalId",alias:"globalId",type:"global-id"}),new X({name:"percentAlong",alias:"percentAlong",type:"double"}),new X({name:"side",alias:"side",type:"string"}),new X({name:"isContentVisible",alias:"isContentVisible",type:"integer"}),new X({name:"className",alias:"className",type:"string"})]});return d(y)}function we(e){if(null==e)return["*"];if(A(e)&&(e=e.toArray()),!ae(e))throw new o("InvalidParameter",null);for(const t of e)if(!ie(t))throw new o("InvalidParameter",null);return e}function he(e){if("async"===e.mode){e.functions.timezone=function(n,a){return e.standardFunctionAsync(n,a,async(e,r,s)=>{if(y(s,1,2,a),w(s[0]))return"Unknown";if(h(s[0]))return"Unknown";if(I(s[0])){if(await s[0].load(),1===s.length||null===s[1])return s[0].datesInUnknownTimezone?pe("unknown"):pe(s[0].dateFieldsTimeZone);if(!(s[1]instanceof i)||!1===s[1].hasField("type"))throw new o("InvalidParameter",a);const e=s[1].field("type");if(!1===ie(e))throw new o("InvalidParameter",a);switch(g(e).toLowerCase()){case"preferredtimezone":return pe(s[0].preferredTimeZone);case"editfieldsinfo":return pe(s[0].editFieldsInfo?.timeZone??null);case"timeinfo":return pe(s[0].timeInfo?.timeZone??null);case"field":if(s[1].hasField("fieldname")&&ie(s[1].field("fieldname")))return pe(s[0].fieldTimeZone(g(s[1].field("fieldname"))))}throw new o("InvalidParameter",a)}const l=F(s[0],b(n));if(null===l)return null;const f=l.timeZone;return"system"===f?t.systemTimeZoneCanonicalName:"utc"===f.toLowerCase()?"UTC":"unknown"===f.toLowerCase()?"Unknown":f})},e.functions.sqltimestamp=function(t,n){return e.standardFunctionAsync(t,n,async(e,t,i)=>{y(i,1,3,n);const a=i[0];if(T(a)){if(1===i.length)return a.toSQLWithKeyword();if(2===i.length)return a.changeTimeZone(g(i[1])).toSQLWithKeyword();throw new o("InvalidParameter",n)}if(h(a))return a.toSQLWithKeyword();if(I(a)){if(3!==i.length)throw new o("InvalidParameter",n);await a.load();const e=g(i[1]);if(h(i[2]))return i[2].toSQLWithKeyword();if(!1===T(i[2]))throw new o("InvalidParameter",n);const t=a.fieldTimeZone(e);return null==t?i[2].toSQLWithKeyword():i[2].changeTimeZone(t).toSQLWithKeyword()}throw new o("InvalidParameter",n)})},e.signatures.push({name:"sqltimestamp",min:2,max:4}),e.functions.featuresetbyid=function(t,n){return e.standardFunctionAsync(t,n,(e,t,i)=>{if(y(i,2,4,n),D(i[0])){const e=g(i[1]),t=we(i[2]),n=E(x(i[3],!0));return i[0].featureSetById(e,n,t)}throw new o("InvalidParameter",n)})},e.signatures.push({name:"featuresetbyid",min:2,max:4});const K=new a(["datasource","parent","root"]);e.functions.getfeatureset=function(t,n){return e.standardFunctionAsync(t,n,async(e,i,a)=>{if(y(a,1,2,n),N(a[0])){const e=null==a[1]?"datasource":K.lookup(g(a[1]));return l(a[0].fullSchema(),e,t.lrucache,t.interceptor,t.spatialReference)}throw new o("InvalidParameter",n)})},e.signatures.push({name:"getfeatureset",min:1,max:2}),e.functions.featuresetbyportalitem=function(t,i){return e.standardFunctionAsync(t,i,(e,a,r)=>{if(y(r,2,5,i),null===r[0])throw new o("PortalRequired",i);if(r[0]instanceof n){const e=g(r[1]),n=g(r[2]),i=we(r[3]),a=E(x(r[4],!0)),o=C(t,r[0]);return f(e,n,t.spatialReference,i,a,o,t.lrucache,t.interceptor)}if(!1===ie(r[0]))throw new o("PortalRequired",i);const s=g(r[0]),l=g(r[1]),d=we(r[2]),u=E(x(r[3],!0));return f(s,l,t.spatialReference,d,u,k(t),t.lrucache,t.interceptor)})},e.signatures.push({name:"featuresetbyportalitem",min:2,max:5}),e.functions.featuresetbyname=function(t,n){return e.standardFunctionAsync(t,n,(e,t,i)=>{if(y(i,2,4,n),D(i[0])){const e=g(i[1]),t=we(i[2]),n=E(x(i[3],!0));return i[0].featureSetByName(e,n,t)}throw new o("InvalidParameter",n)})},e.signatures.push({name:"featuresetbyname",min:2,max:4}),e.functions.featureset=function(t,n){return e.standardFunction(t,n,(e,a,r)=>{y(r,1,1,n);const s={layerDefinition:{geometryType:"",objectIdField:"",globalIdField:"",typeIdField:"",hasM:!1,hasZ:!1,fields:[]},featureSet:{geometryType:"",features:[]}};if(ie(r[0])){const e=JSON.parse(r[0]);void 0!==e.layerDefinition?(s.layerDefinition=e.layerDefinition,s.featureSet=e.featureSet,e.layerDefinition.spatialReference&&(s.layerDefinition.spatialReference=e.layerDefinition.spatialReference)):(s.featureSet.features=e.features,s.featureSet.geometryType=e.geometryType,s.layerDefinition.geometryType=s.featureSet.geometryType,s.layerDefinition.objectIdField=e.objectIdFieldName??"",s.layerDefinition.typeIdField=e.typeIdFieldName,s.layerDefinition.globalIdField=e.globalIdFieldName,s.layerDefinition.fields=e.fields,e.spatialReference&&(s.layerDefinition.spatialReference=e.spatialReference))}else{if(!(r[0]instanceof i))throw new o("InvalidParameter",n);{const e=JSON.parse(r[0].castToText(!0)),t=le(e,"layerdefinition");if(null!==t){s.layerDefinition.geometryType=le(t,"geometrytype",""),s.featureSet.geometryType=s.layerDefinition.geometryType,s.layerDefinition.globalIdField=le(t,"globalidfield",""),s.layerDefinition.objectIdField=le(t,"objectidfield",""),s.layerDefinition.typeIdField=le(t,"typeidfield",""),s.layerDefinition.hasZ=!0===le(t,"hasz",!1),s.layerDefinition.hasM=!0===le(t,"hasm",!1);const n=le(t,"spatialreference");n&&(s.layerDefinition.spatialReference=de(n));const i=[];for(const e of le(t,"fields",[])){const t={name:le(e,"name",""),alias:le(e,"alias",""),type:le(e,"type",""),nullable:le(e,"nullable",!0),editable:le(e,"editable",!0),length:le(e,"length",null),domain:fe(le(e,"domain"))};i.push(t)}s.layerDefinition.fields=i;const a=le(e,"featureset");if(a){const e={};for(const t of i)e[t.name.toLowerCase()]=t.name;for(const t of le(a,"features",[])){const n={},i=le(t,"attributes",{});for(const t in i)n[e[t.toLowerCase()]]=i[t];s.featureSet.features.push({attributes:n,geometry:ue(le(t,"geometry"))})}}}else{s.layerDefinition.hasZ=!0===le(e,"hasz",!1),s.layerDefinition.hasM=!0===le(e,"hasm",!1),s.layerDefinition.geometryType=le(e,"geometrytype",""),s.featureSet.geometryType=s.layerDefinition.geometryType,s.layerDefinition.objectIdField=le(e,"objectidfieldname",""),s.layerDefinition.typeIdField=le(e,"typeidfieldname","");const t=le(e,"spatialreference");t&&(s.layerDefinition.spatialReference=de(t));const i=[],a=le(e,"fields",null);if(!ae(a))throw new o("InvalidParameter",n);for(const e of a){const t={name:le(e,"name",""),alias:le(e,"alias",""),type:le(e,"type",""),nullable:le(e,"nullable",!0),editable:le(e,"editable",!0),length:le(e,"length",null),domain:fe(le(e,"domain"))};i.push(t)}s.layerDefinition.fields=i;const r={};for(const e of i)r[e.name.toLowerCase()]=e.name;let l=le(e,"features",null);if(ae(l))for(const e of l){const t={},n=le(e,"attributes",{});for(const e in n)t[r[e.toLowerCase()]]=n[e];s.featureSet.features.push({attributes:t,geometry:ue(le(e,"geometry",null))})}else l=null,s.featureSet.features=l}}}if(!1===me(s))throw new o("InvalidParameter",n);return s.layerDefinition.geometryType||(s.layerDefinition.geometryType="esriGeometryNull"),G.create(s,t.spatialReference)})},e.signatures.push({name:"featureset",min:1,max:1}),e.functions.filter=function(t,n){return e.standardFunctionAsync(t,n,async(i,a,r)=>{if(y(r,2,2,n),ae(r[0])||A(r[0])){const e=[];let i,a=r[0];if(a instanceof p&&(a=a.toArray()),!S(r[1]))throw new o("InvalidParameter",n);i=r[1].createFunction(t);for(const t of a){const n=i(t);Q(n)?!0===await n&&e.push(t):!0===n&&e.push(t)}return e}if(I(r[0])){const n=await r[0].load(),i=J.create(r[1],{fieldsIndex:n.getFieldsIndex(),timeZone:n.dateFieldsTimeZoneDefaultUTC}),a=i.getVariables();if(a.length>0){const n={};for(const i of a)n[i]=e.evaluateIdentifier(t,{name:i});i.parameters=n}return new R({parentfeatureset:r[0],whereclause:i})}throw new o("InvalidParameter",n)})},e.signatures.push({name:"filter",min:2,max:2}),e.functions.orderby=function(t,n){return e.standardFunctionAsync(t,n,async(e,t,i)=>{if(y(i,2,2,n),I(i[0])){const e=new V(i[1]);return new z({parentfeatureset:i[0],orderbyclause:e})}throw new o("InvalidParameter",n)})},e.signatures.push({name:"orderby",min:2,max:2}),e.functions.top=function(t,n){return e.standardFunctionAsync(t,n,async(e,t,i)=>{if(y(i,2,2,n),I(i[0]))return new W({parentfeatureset:i[0],topnum:i[1]});if(ae(i[0]))return v(i[1])>=i[0].length?i[0].slice():i[0].slice(0,v(i[1]));if(A(i[0]))return v(i[1])>=i[0].length()?i[0].slice():i[0].slice(0,v(i[1]));throw new o("InvalidParameter",n)})},e.signatures.push({name:"top",min:2,max:2}),e.functions.first=function(t,n){return e.standardFunctionAsync(t,n,async(e,i,a)=>{if(y(a,1,1,n),I(a[0])){const n=await a[0].first(e.abortSignal);if(null!==n){const e=s.createFromGraphicLikeObject(n.geometry,n.attributes,a[0],t.timeZone);return e._underlyingGraphic=n,e}return n}return ae(a[0])?0===a[0].length?null:a[0][0]:A(a[0])?0===a[0].length()?null:a[0].get(0):null})},e.signatures.push({name:"first",min:1,max:1}),e.functions.attachments=function(t,n){return e.standardFunctionAsync(t,n,async(e,a,r)=>{y(r,1,2,n);const s={minsize:-1,maxsize:-1,types:null,returnMetadata:!1};if(r.length>1)if(r[1]instanceof i){if(r[1].hasField("minsize")&&(s.minsize=v(r[1].field("minsize"))),r[1].hasField("metadata")&&(s.returnMetadata=E(r[1].field("metadata"))),r[1].hasField("maxsize")&&(s.maxsize=v(r[1].field("maxsize"))),r[1].hasField("types")){const e=L(r[1].field("types"),!1);e.length>0&&(s.types=e)}}else if(null!==r[1])throw new o("InvalidParameter",n);if(N(r[0])){const e=r[0].fullSchema();let n;if(I(e))n=e;else{if(null==e||!_(e))return[];n=d(e,t.spatialReference,["*"],!0,t.lrucache,t.interceptor)}return await n.load(),n.queryAttachments(r[0].field(n.objectIdField),s.minsize,s.maxsize,s.types,s.returnMetadata)}if(null===r[0])return[];throw new o("InvalidParameter",n)})},e.signatures.push({name:"attachments",min:1,max:2}),e.functions.featuresetbyrelationshipname=function(t,n){return e.standardFunctionAsync(t,n,async(e,i,a)=>{y(a,2,4,n);const r=a[0],s=g(a[1]),l=we(a[2]),f=E(x(a[3],!0));if(null===a[0])return null;if(!N(a[0]))throw new o("InvalidParameter",n);const m=r.fullSchema();let p;if(I(m))p=m;else{if(null==m||!_(m))return null;p=d(m,t.spatialReference,["*"],!0,t.lrucache,t.interceptor)}p=await p.load();const w=p.relationshipMetadata().filter(e=>e.name===s);if(0===w.length)return null;if(void 0!==w[0].relationshipTableId&&null!==w[0].relationshipTableId&&w[0].relationshipTableId>-1)return u(p,w[0],r.field(p.objectIdField),p.spatialReference,l,f,t.lrucache,t.interceptor);let h=p.serviceUrl();if(!h)return null;h=h.endsWith("/")?h+w[0].relatedTableId.toString():h+"/"+w[0].relatedTableId.toString();const F=await c(h,p.spatialReference,l,f,t.lrucache,t.interceptor);await F.load();let b=F.relationshipMetadata();if(b=b.filter(e=>e.id===w[0].id),!1===r.hasField(w[0].keyField)||null===r.field(w[0].keyField)){const e=await p.getFeatureByObjectId(r.field(p.objectIdField),[w[0].keyField]);if(e){const t=J.create(b[0].keyField+"= @id",{fieldsIndex:F.getFieldsIndex(),timeZone:F.dateFieldsTimeZoneDefaultUTC});return t.parameters={id:e.attributes[w[0].keyField]},new R({parentfeatureset:F,whereclause:t})}return new H({parentfeatureset:F})}const T=J.create(b[0].keyField+"= @id",{fieldsIndex:F.getFieldsIndex(),timeZone:F.dateFieldsTimeZoneDefaultUTC});return T.parameters={id:r.field(w[0].keyField)},new R({parentfeatureset:F,whereclause:T})})},e.signatures.push({name:"featuresetbyrelationshipname",min:2,max:4}),e.functions.featuresetbyassociation=function(t,n){return e.standardFunctionAsync(t,n,async(e,i,a)=>{y(a,2,3,n);const s=a[0],l=r(g(x(a[1],""))),f=ie(a[2])?g(a[2]):null;if(null===a[0])return null;if(!N(a[0]))throw new o("InvalidParameter",n);const u=s.fullSchema();let c;if(I(u))c=u;else{if(null==u||!_(u))return null;c=d(u,t.spatialReference,["*"],!0,t.lrucache,t.interceptor)}await c.load();const p=c.serviceUrl(),w=await m(p,t.spatialReference,!0);if(w.unVersion>=8)return await ye(c,s,l,f,w,n);const h=w.associations;if(null==h)return null;let F=null,b=null,T=!1;if(null!==f&&""!==f&&void 0!==f){for(const e of w.terminals)e.terminalName===f&&(b=e.terminalId);null===b&&(T=!0)}const D=h.getFieldsIndex(),E=D.get("TOGLOBALID").name,A=D.get("FROMGLOBALID").name,S=D.get("TOTERMINALID").name,v=D.get("FROMTERMINALID").name,L=D.get("FROMNETWORKSOURCEID").name,C=D.get("TONETWORKSOURCEID").name,k=D.get("ASSOCIATIONTYPE").name,R=D.get("ISCONTENTVISIBLE").name,O=D.get("OBJECTID").name;for(const t of c.fields)if("global-id"===t.type){F=s.field(t.name);break}let z=null,W=new Z(new X({name:"percentalong",alias:"percentalong",type:"double"}),J.create("0",{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC})),H=new Z(new X({name:"side",alias:"side",type:"string"}),J.create("''",{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC}));const G="globalid",V="globalId",B={};for(const t in w.lkp)B[t]=w.lkp[t].sourceId;const K=new $(new X({name:"classname",alias:"classname",type:"string"}),null,B);let Q="";switch(l){case"midspan":{Q=`((${E}='${F}') OR ( ${A}='${F}')) AND (${k} IN (5))`,K.codefield=J.create(`CASE WHEN (${E}='${F}') THEN ${L} ELSE ${C} END`,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC});const e=q(U.findField(h.fields,A));e.name=G,e.alias=G,z=new Z(e,J.create(`CASE WHEN (${A}='${F}') THEN ${E} ELSE ${A} END`,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC})),W=w.unVersion>=4?new M(U.findField(h.fields,D.get("PERCENTALONG").name)):new Z(new X({name:"percentalong",alias:"percentalong",type:"double"}),J.create("0",{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC}));break}case"junctionedge":{Q=`((${E}='${F}') OR ( ${A}='${F}')) AND (${k} IN (4,6))`,K.codefield=J.create(`CASE WHEN (${E}='${F}') THEN ${L} ELSE ${C} END`,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC});const e=q(U.findField(h.fields,A));e.name=G,e.alias=G,z=new Z(e,J.create(`CASE WHEN (${A}='${F}') THEN ${E} ELSE ${A} END`,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC})),H=new Z(new X({name:"side",alias:"side",type:"string"}),J.create(`CASE WHEN (${k}=4) THEN 'from' ELSE 'to' END`,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC}));break}case"connected":{let e=`${E}='@T'`,t=`${A}='@T'`;null!==b&&(e+=` AND ${S}=@A`,t+=` AND ${v}=@A`),Q="(("+e+") OR ("+t+"))",Q=j(Q,"@T",F??""),e=j(e,"@T",F??""),null!==b&&(e=j(e,"@A",b.toString()),Q=j(Q,"@A",b.toString())),K.codefield=J.create("CASE WHEN "+e+` THEN ${L} ELSE ${C} END`,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC});const n=q(U.findField(h.fields,A));n.name=G,n.alias=G,z=new Z(n,J.create("CASE WHEN "+e+` THEN ${A} ELSE ${E} END`,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC}));break}case"container":Q=`${E}='${F}' AND ${k} = 2`,null!==b&&(Q+=` AND ${S} = `+b.toString()),K.codefield=L,Q="( "+Q+" )",z=new P(U.findField(h.fields,A),G,G);break;case"content":Q=`(${A}='${F}' AND ${k} = 2)`,null!==b&&(Q+=` AND ${v} = `+b.toString()),K.codefield=C,Q="( "+Q+" )",z=new P(U.findField(h.fields,E),G,G);break;case"structure":Q=`(${E}='${F}' AND ${k} = 3)`,null!==b&&(Q+=` AND ${S} = `+b.toString()),K.codefield=L,Q="( "+Q+" )",z=new P(U.findField(h.fields,A),G,V);break;case"attached":Q=`(${A}='${F}' AND ${k} = 3)`,null!==b&&(Q+=` AND ${v} = `+b.toString()),K.codefield=C,Q="( "+Q+" )",z=new P(U.findField(h.fields,E),G,V);break;default:throw new o("InvalidParameter",n)}T&&(Q="1 <> 1");return new U({parentfeatureset:h,adaptedFields:[new M(U.findField(h.fields,O)),new M(U.findField(h.fields,R)),z,H,K,W],extraFilter:Q?J.create(Q,{fieldsIndex:h.getFieldsIndex(),timeZone:h.dateFieldsTimeZoneDefaultUTC}):null})})},e.signatures.push({name:"featuresetbyassociation",min:2,max:6}),e.functions.groupby=function(t,n){return e.standardFunctionAsync(t,n,async(a,r,s)=>{if(y(s,3,3,n),!I(s[0]))throw new o("InvalidParameter",n);const l=await s[0].load(),f=[],d=[];let u=!1,c=[];if(ie(s[1]))c.push(s[1]);else if(s[1]instanceof i)c.push(s[1]);else if(ae(s[1]))c=s[1];else{if(!A(s[1]))throw new o("InvalidParameter",n);c=s[1].toArray()}for(const e of c)if(ie(e)){const t=J.create(g(e),{fieldsIndex:l.getFieldsIndex(),timeZone:l.dateFieldsTimeZoneDefaultUTC}),n=!0===B(t)?g(e):"%%%%FIELDNAME";f.push({name:n,expression:t}),"%%%%FIELDNAME"===n&&(u=!0)}else{if(!(e instanceof i))throw new o("InvalidParameter",n);{const t=e.hasField("name")?e.field("name"):"%%%%FIELDNAME",i=e.hasField("expression")?e.field("expression"):"";if("%%%%FIELDNAME"===t&&(u=!0),!t||!ie(t)||!ie(i))throw new o("InvalidParameter",n);f.push({name:t,expression:J.create(i||t,{fieldsIndex:l.getFieldsIndex(),timeZone:l.dateFieldsTimeZoneDefaultUTC})})}}if(c=[],ie(s[2]))c.push(s[2]);else if(ae(s[2]))c=s[2];else if(A(s[2]))c=s[2].toArray();else{if(!(s[2]instanceof i))throw new o("InvalidParameter",n);c.push(s[2])}for(const e of c){if(!(e instanceof i))throw new o("InvalidParameter",n);{const t=e.hasField("name")?e.field("name"):"",i=e.hasField("statistic")?e.field("statistic"):"",a=e.hasField("expression")?e.field("expression"):"";if(!(t&&ie(t)&&i&&ie(i)&&a&&ie(a)))throw new o("InvalidParameter",n);d.push({name:t,statistic:i,expression:J.create(a,{fieldsIndex:l.getFieldsIndex(),timeZone:l.dateFieldsTimeZoneDefaultUTC})})}}if(u){const e={};for(const n of l.fields)e[n.name.toLowerCase()]=1;for(const n of f)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);for(const n of d)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);let t=0;for(const n of f)if("%%%%FIELDNAME"===n.name){for(;1===e["field_"+t.toString()];)t++;e["field_"+t.toString()]=1,n.name="FIELD_"+t.toString()}}for(const n of f)se(n.expression,e,t);for(const n of d)se(n.expression,e,t);return new O({parentfeatureset:s[0],groupbyfields:f,statsfields:d})})},e.signatures.push({name:"groupby",min:3,max:3}),e.functions.distinct=function(t,n){return e.standardFunctionAsync(t,n,async(a,r,s)=>{if(I(s[0])){y(s,2,2,n);const a=await s[0].load(),r=[];let l=[];if(ie(s[1]))l.push(s[1]);else if(s[1]instanceof i)l.push(s[1]);else if(ae(s[1]))l=s[1];else{if(!A(s[1]))throw new o("InvalidParameter",n);l=s[1].toArray()}let f=!1;for(const e of l)if(ie(e)){const t=J.create(g(e),{fieldsIndex:a.getFieldsIndex(),timeZone:a.dateFieldsTimeZoneDefaultUTC}),n=!0===B(t)?g(e):"%%%%FIELDNAME";r.push({name:n,expression:t}),"%%%%FIELDNAME"===n&&(f=!0)}else{if(!(e instanceof i))throw new o("InvalidParameter",n);{const t=e.hasField("name")?e.field("name"):"%%%%FIELDNAME",i=e.hasField("expression")?e.field("expression"):"";if("%%%%FIELDNAME"===t&&(f=!0),!t||!ie(t)||!ie(i))throw new o("InvalidParameter",n);r.push({name:t,expression:J.create(i||t,{fieldsIndex:a.getFieldsIndex(),timeZone:a.dateFieldsTimeZoneDefaultUTC})})}}if(f){const e={};for(const n of a.fields)e[n.name.toLowerCase()]=1;for(const n of r)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);let t=0;for(const n of r)if("%%%%FIELDNAME"===n.name){for(;1===e["field_"+t.toString()];)t++;e["field_"+t.toString()]=1,n.name="FIELD_"+t.toString()}}for(const n of r)se(n.expression,e,t);return new O({parentfeatureset:s[0],groupbyfields:r,statsfields:[]})}return oe(s)})},e.functions.getfeaturesetinfo=function(t,n){return e.standardFunctionAsync(t,n,async(e,t,a)=>{if(y(a,1,1,n),!I(a[0]))return null;const r=await a[0].getFeatureSetInfo();return r?i.createMutable({__proto__:null,layerId:r.layerId,layerName:r.layerName,itemId:r.itemId,serviceLayerUrl:r.serviceLayerUrl,webMapLayerId:r.webMapLayerId??null,webMapLayerTitle:r.webMapLayerTitle??null,className:null,objectClassId:null}):null})},e.signatures.push({name:"getfeaturesetinfo",min:1,max:1}),e.functions.filterbysubtypecode=function(t,n){return e.standardFunctionAsync(t,n,async(e,t,i)=>{if(y(i,2,2,n),I(i[0])){const e=await i[0].load(),t=i[1];if(!re(t))throw new o("InvalidParameter",n);if(e.subtypeField){const t=J.create(`${e.subtypeField}= ${i[1]}`,{fieldsIndex:e.getFieldsIndex(),timeZone:e.dateFieldsTimeZoneDefaultUTC});return new R({parentfeatureset:i[0],whereclause:t})}if(null===e.typeIdField||""===e.typeIdField)throw new o("FeatureSetDoesNotHaveSubtypes",n);const a=J.create(`${e.typeIdField}= ${i[1]}`,{fieldsIndex:e.getFieldsIndex(),timeZone:e.dateFieldsTimeZoneDefaultUTC});return new R({parentfeatureset:i[0],whereclause:a})}throw new o("InvalidParameter",n)})},e.signatures.push({name:"filterbysubtypecode",min:2,max:2})}}export{he as registerFunctions};
|
package/arcade.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"./Graphic.js";import{ArcadeDate as t}from"./arcade/ArcadeDate.js";import{toSymbolId as r}from"./arcade/arcadeEnvironment.js";import a from"./arcade/ImmutableArray.js";import n from"./arcade/featureset/support/RecentlyUsedCache.js";import{deprecatedProperty as o,deprecated as c}from"./core/deprecate.js";import i from"./core/Error.js";import{clone as s}from"./core/lang.js";import l from"./core/Logger.js";import{DateOnly as u}from"./core/sql/DateOnly.js";import{TimeOnly as p}from"./core/sql/TimeOnly.js";import m from"./layers/FeatureLayer.js";import y from"./portal/Portal.js";import f from"./rest/support/FeatureSet.js";import{loadArcade as d}from"./support/loadArcade.js";let b=null;function h(e,t,r,n={}){const o=t.elementType,c="value",i="array"===o.type?[{name:c,type:o.type,elementType:o.elementType}]:"dictionary"===o.type?[{name:c,type:o.type,properties:o.properties}]:[{name:c,type:o.type}];return a.from(e.map(e=>{const t={};return A(t,i,{[c]:e},r,n),t[c]}))}function v(e,t,r={}){const a=e instanceof f?new m({source:e.features,geometryType:e.geometryType,fields:e.fields,spatialReference:e.spatialReference}):e;return t.constructFeatureSet(a,r.spatialReference,null,!0,L(r.cache),r.interceptor)}function g(e,t,r={}){const{spatialReference:a,interceptor:n,cache:o}=r;return"string"==typeof e?t.createFeatureSetCollectionFromService(e,a,L(o),n):t.createFeatureSetCollectionFromMap(e,a,L(o),n)}function w(e,t,r,a={}){const n=Object.create(null);return A(n,t.properties,e,r,a),new b.Dictionary(n)}function S(e){if(null==e)return null;if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e;if(Array.isArray(e))return a.from(e.map(e=>S(e)));if("object"==typeof e){const t=Object.create(null);for(const r of Object.entries(e))t[r[0]]=S(r[1]);return new b.Dictionary(t)}throw new Error(`Unsupported json value: ${e}`)}function A(e,r,a,n,o={}){const c={};for(const t of Object.keys(a))c[t.toLowerCase()]=a[t];for(const i of r){const r=i.name.toLowerCase();if(o.variablesPreProcessed)e[r]=c[r];else switch(i.type){case"array":{const t=c[r];e[r]=null==t?null:h(t,i,n,o);break}case"feature":{const t=c[r];e[r]=null==t?null:b.Feature.createFromGraphic(t,o?.timeZone);break}case"featureSet":{const t=c[r];e[r]=null==t?null:n?v(t,n,o):null;break}case"featureSetCollection":{const t=c[r];e[r]=null==t?null:n?g(t,n,o):null;break}case"dictionary":{const t=c[r];e[r]=null==t?null:w(t,i,n,o);break}case"date":{const a=c[r];e[r]=a?a instanceof t?a:o?.timeZone?t.dateJSAndZoneToArcadeDate(a,o?.timeZone):t.dateJSToArcadeDate(a):null;break}case"dateOnly":{const t=c[r];e[r]=t?t instanceof u?t:u.fromReader(t):null;break}case"time":{const t=c[r];e[r]=t?t instanceof p?t:p.fromReader(t):null;break}case"knowledgeGraph":case"boolean":case"text":case"number":e[r]=c[r];break;case"geometry":e[r]=b.arcadeUtils.createArcadeGeometryFromAccessorGeometry(c[r]);break;case"voxel":{const t=c[r];e[r]=null==t?null:new b.Voxel(t,o?.timeZone);break}case"pixel":{const t=c[r];e[r]=null==t?null:b.Pixel.fromImageryGraphic(t,o?.timeZone);break}case"json":e[r]=S(c[r])}}}function $(e,t){for(const r of e)t.push(r),"dictionary"===r.type&&$(r.properties,t);return t}function x(e,t,r,a,n){null!=r.lruCache&&o(l.getLogger("esri.arcade"),"ExecuteContext#lruCache",{replacement:"ExecuteContext#cache",warnOnce:!0,version:"5.0"});const c={vars:{},spatialReference:r.spatialReference,interceptor:r.interceptor,timeZone:r.timeZone,lrucache:L(r.cache),useAsync:n,services:r.services,console:r.console,abortSignal:r.abortSignal,track:r.track};return t?(A(c.vars,e.variables,t,a,r),c):c}function C(t,r){if(null==t||r.isVoid(t))return null;if(r.isArray(t))return t.map(e=>C(e,r));if(r.isImmutableArray(t))return t.toArray().map(e=>C(e,r));if(r.isDate(t))return t.toJSDate();if(r.isString(t))return t;if(r.isBoolean(t))return t;if(r.isNumber(t))return t;if(r.isDictionary(t)||r.isAttachment(t)||r.isPortal(t)){const e=Object.create(null);for(const a of t.keys())e[a]=C(t.field(a),r);return e}if(r.isFeature(t)){const r=t,a="geometry"in r?r.geometry()?.asAccessorGeometry():null,n="readAttributes"in r?r.readAttributes():r.attributes;return new e({geometry:a,attributes:n})}return r.isGeometry(t)?t.asAccessorGeometry():r.isDateOnly(t)||r.isTime(t)?t.toString():t}class j{constructor(e,t){this._actual=e,this._lc=t,this.declaredClass="esri.arcade.Dictionary"}keys(){return this._actual.keys()}field(e){return O(this._actual.field(e),this._lc)}castAsJson(){return this._actual.castAsJson()}castAsJsonAsync(e){return this._actual.castAsJsonAsync(e)}}class k{constructor(e,t){this._actual=e,this._lc=t,this.arcadeDeclaredClass="esri.arcade.Feature"}keys(){return this._actual.keys()}field(e){return O(this._actual.field(e),this._lc)}geometry(){return this._actual.geometry()?.asAccessorGeometry()??null}castAsJson(){return this._actual.castAsJson()}}function O(e,t){return t.isGeometry(e)?e.asAccessorGeometry():t.isArray(e)?e.map(e=>O(e,t)):t.isImmutableArray(e)?a.from(e.toArray().map(e=>O(e,t))):t.isDictionary(e)?new j(e,t):t.isFeature(e)?new k(e,t):e}const E={variables:[{name:"$feature",type:"feature"},{name:"$originalFeature",type:"feature"},{name:"$layer",type:"featureSet"},{name:"$featureSet",type:"featureSet"},{name:"$datastore",type:"featureSetCollection"},{name:"$map",type:"featureSetCollection"},{name:"$editContext",type:"dictionary",properties:[{name:"editType",type:"text"}]}]},I={variables:[{name:"$feature",type:"feature"},{name:"$layer",type:"featureSet"},{name:"$datastore",type:"featureSetCollection"},{name:"$map",type:"featureSetCollection"},{name:"$userInput",type:"geometry"},{name:"$graph",type:"knowledgeGraph"},{name:"$view",type:"dictionary",properties:[{name:"scale",type:"number"},{name:"timeProperties",type:"dictionary",properties:[{name:"currentStart",type:"date"},{name:"currentEnd",type:"date"},{name:"startIncluded",type:"boolean"},{name:"endIncluded",type:"boolean"}]}]}]},F={variables:[{name:"$feature",type:"feature"},{name:"$aggregatedFeatures",type:"featureSet"},{name:"$view",type:"dictionary",properties:[{name:"scale",type:"number"},{name:"timeProperties",type:"dictionary",properties:[{name:"currentStart",type:"date"},{name:"currentEnd",type:"date"},{name:"startIncluded",type:"boolean"},{name:"endIncluded",type:"boolean"}]}]}]},D={variables:[{name:"$voxel",type:"voxel"}]},T={variables:[{name:"$pixel",type:"pixel"},{name:"$imageCollectionItem",type:"feature"},{name:"$userInput",type:"geometry"},{name:"$view",type:"dictionary",properties:[{name:"scale",type:"number"},{name:"timeProperties",type:"dictionary",properties:[{name:"currentStart",type:"date"},{name:"currentEnd",type:"date"},{name:"startIncluded",type:"boolean"},{name:"endIncluded",type:"boolean"}]}]}]},G=new Map([["aggregate-field",{variables:[{name:"$feature",type:"feature"}]}],["form-constraint",E],["feature-z",{variables:[{name:"$feature",type:"feature"}]}],["field-calculation",{variables:[{name:"$feature",type:"feature"},{name:"$datastore",type:"featureSetCollection"}]}],["form-calculation",E],["form-dynamic-choice",E],["form-attachment-filename-calculation",{variables:[{name:"$feature",type:"feature"},{name:"$originalFeature",type:"feature"},{name:"$layer",type:"featureSet"},{name:"$datastore",type:"featureSetCollection"},{name:"$featureset",type:"featureSet"},{name:"$map",type:"featureSetCollection"},{name:"$formElement",type:"dictionary",properties:[{name:"attachmentKeyword",type:"text"},{name:"label",type:"text"},{name:"description",type:"text"}]}]}],["labeling",{variables:[{name:"$feature",type:"feature"},{name:"$view",type:"dictionary",properties:[{name:"scale",type:"number"},{name:"timeProperties",type:"dictionary",properties:[{name:"currentStart",type:"date"},{name:"currentEnd",type:"date"},{name:"startIncluded",type:"boolean"},{name:"endIncluded",type:"boolean"}]}]}]}],["popup",I],["popup-element",I],["popup-feature-reduction",F],["popup-element-feature-reduction",F],["visualization",{variables:[{name:"$feature",type:"feature"},{name:"$view",type:"dictionary",properties:[{name:"scale",type:"number"},{name:"timeProperties",type:"dictionary",properties:[{name:"currentStart",type:"date"},{name:"currentEnd",type:"date"},{name:"startIncluded",type:"boolean"},{name:"endIncluded",type:"boolean"}]}]}]}],["popup-voxel",D],["popup-element-voxel",D],["popup-imagery",T],["popup-element-imagery",T]]);function _(e){"feature-reduction-popup"===e?(c(l.getLogger("esri.arcade"),'profile name: "feature-reduction-popup"',{replacement:'"popup-feature-reduction"',version:"4.32",warnOnce:!0}),e="popup-feature-reduction"):"feature-reduction-popup-element"===e&&(c(l.getLogger("esri.arcade"),'profile name: "feature-reduction-popup-element"',{replacement:'"popup-element-feature-reduction"',version:"4.32",warnOnce:!0}),e="popup-element-feature-reduction");const t=G.get(e);if(!t){const t=Array.from(G.keys()).map(e=>`'${e}'`).join(", ");throw new i("createArcadeProfile:invalid-profile-name",`Invalid profile name '${e}'. You must specify one of the following values: ${t}`)}return s(t)}async function U(e,t,a={}){b||(b=await d());const{arcade:n,arcadeUtils:c,batchExec:{createBatchExecutor:s},aiServices:{BatchTranslationServiceFactory:u,PortalTranslationService:p},languageUtils:m}=b,{loadScriptDependencies:f,referencesMember:h,scriptIsAsync:v}=n,g=$(t.variables,[]).filter(e=>"featureSet"===e.type||"featureSetCollection"===e.type).map(e=>r(e.name)),w=n.parseScript(e,g);if(!w)throw new i("arcade:invalid-script","Unable to create SyntaxTree");const S=c.extractFieldNames(w),A=n.scriptTouchesGeometry(w),j=t.variables.map(e=>r(e.name)).filter(e=>h(w,e)),k=v(w,g);await f(w,k,g);const E=n.compileScript(w,{vars:Object.fromEntries(j.map(e=>[e,!0])),useAsync:k}),I=a.services,F=a.cache??a.lruCache;null!=a.lruCache&&o(l.getLogger("esri.arcade"),"ExecutorOptions#lruCache",{replacement:"ExecutorOptions#cache",warnOnce:!0,version:"5.0"});const D=n.featureSetUtils(),T=(e,r={})=>{if(k)throw new i("arcade:invalid-execution-mode","Cannot execute the script in synchronous mode");const a={...I,...r.services},n=r.cache??r.lruCache??F,o={...r,cache:n,services:a},c=E(x(t,e,o,D,k));return r.rawOutput?O(c,m):C(c,m)},G=async(e,r={})=>{const a={...I,...r.services},n=r.cache??r.lruCache??F,o={...r,cache:n,services:a},c=await E(x(t,e,o,D,k));return r.rawOutput?O(c,m):C(c,m)},_=async(e,r,a={})=>{const n=[],o=a.cache??a.lruCache??F,c=s(e,async(e,c)=>{const s=r(e);try{const e={...i,translation:l.create(c)},r={...a,cache:o,services:e},u=await E(x(t,s,r,D,k)),p=a.rawOutput?O(u,m):C(u,m);n.push({id:c.id,result:{status:"fulfilled",value:p}})}catch(u){throw n.push({id:c.id,result:{status:"rejected",reason:u}}),u}},a.maxConcurrency??64,a.abortSignal),i={...I,...a.services},l=new u(c,i.translation??new p(i.portal??y.getDefault(),a.console));return await c.run(),n.sort(({id:e},{id:t})=>e-t).map(({result:e})=>e)};return{execute:T,executeAsync:G,executeAsyncBatch:_,isAsync:k,variablesUsed:j,fieldsUsed:S,geometryUsed:A,syntaxTree:w}}async function P(e,t,a={}){b||(b=await d());const{arcade:n}=b,{loadScriptDependencies:c,scriptIsAsync:s}=n,u=$(t.variables,[]).filter(e=>"featureSet"===e.type||"featureSetCollection"===e.type).map(e=>r(e.name)),p=n.parseScript(e,u);if(!p)throw new i("arcade:invalid-script","Unable to create SyntaxTree");const m=s(p,u)||null!=a.breakpoints;await c(p,m,u),await n.enableFeatureSetSupport();const y=n.compileDebugScript(p,{vars:Object.fromEntries(t.variables.map(e=>e.name).map(e=>[e,!0])),useAsync:m,breakpoints:a.breakpoints}),f=a.services,h=a.cache??a.lruCache;null!=a.lruCache&&o(l.getLogger("esri.arcade"),"ExecutorOptions#lruCache",{replacement:"ExecutorOptions#cache",warnOnce:!0,version:"5.0"});const v=n.featureSetUtils();return{async executeAsync(e,r={}){const a={...f,...r.services},n=r.cache??r.lruCache??h,o={...r,cache:n,services:a};return await y(x(t,e,o,v,m))}}}function J(){return new n}function L(e){if(null!=e&&!(e instanceof n))throw new Error("Use createArcadeCache() to construct a cache instance or provide null/undefined.");return e}export{J as createArcadeCache,P as createArcadeDebugExecutor,U as createArcadeExecutor,_ as createArcadeProfile};
|
|
2
|
+
import e from"./Graphic.js";import{ArcadeDate as t}from"./arcade/ArcadeDate.js";import{toSymbolId as r}from"./arcade/arcadeEnvironment.js";import a from"./arcade/ImmutableArray.js";import n from"./arcade/featureset/support/RecentlyUsedCache.js";import{deprecatedProperty as o,deprecated as c}from"./core/deprecate.js";import i from"./core/Error.js";import{clone as s}from"./core/lang.js";import l from"./core/Logger.js";import{DateOnly as u}from"./core/sql/DateOnly.js";import{TimeOnly as p}from"./core/sql/TimeOnly.js";import m from"./layers/FeatureLayer.js";import y from"./portal/Portal.js";import f from"./rest/support/FeatureSet.js";import{loadArcade as d}from"./support/loadArcade.js";let b=null;function h(e,t,r,n={}){const o=t.elementType,c="value",i="array"===o.type?[{name:c,type:o.type,elementType:o.elementType}]:"dictionary"===o.type?[{name:c,type:o.type,properties:o.properties}]:[{name:c,type:o.type}];return a.from(e.map(e=>{const t={};return A(t,i,{[c]:e},r,n),t[c]}))}function v(e,t,r={}){const a=e instanceof f?new m({source:e.features,geometryType:e.geometryType,fields:e.fields,spatialReference:e.spatialReference}):e;return t.constructFeatureSet(a,r.spatialReference,null,!0,L(r.cache),r.interceptor)}function g(e,t,r={}){const{spatialReference:a,interceptor:n,cache:o}=r;return"string"==typeof e?t.createFeatureSetCollectionFromService(e,a,L(o),n):t.createFeatureSetCollectionFromMap(e,a,L(o),n)}function S(e,t,r,a={}){const n=Object.create(null);return A(n,t.properties,e,r,a),new b.Dictionary(n)}function w(e){if(null==e)return null;if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e;if(Array.isArray(e))return a.from(e.map(e=>w(e)));if("object"==typeof e){const t=Object.create(null);for(const r of Object.entries(e))t[r[0]]=w(r[1]);return new b.Dictionary(t)}throw new Error(`Unsupported json value: ${e}`)}function A(e,r,a,n,o={}){const c={};for(const t of Object.keys(a))c[t.toLowerCase()]=a[t];for(const i of r){const r=i.name.toLowerCase();if(o.variablesPreProcessed)e[r]=c[r];else switch(i.type){case"array":{const t=c[r];e[r]=null==t?null:h(t,i,n,o);break}case"feature":{const t=c[r];e[r]=null==t?null:b.Feature.createFromGraphic(t,o?.timeZone);break}case"featureSet":{const t=c[r];e[r]=null==t?null:n?v(t,n,o):null;break}case"featureSetCollection":{const t=c[r];e[r]=null==t?null:n?g(t,n,o):null;break}case"dictionary":{const t=c[r];e[r]=null==t?null:S(t,i,n,o);break}case"date":{const a=c[r];e[r]=a?a instanceof t?a:o?.timeZone?t.dateJSAndZoneToArcadeDate(a,o?.timeZone):t.dateJSToArcadeDate(a):null;break}case"dateOnly":{const t=c[r];e[r]=t?t instanceof u?t:u.fromReader(t):null;break}case"time":{const t=c[r];e[r]=t?t instanceof p?t:p.fromReader(t):null;break}case"knowledgeGraph":case"boolean":case"text":case"number":e[r]=c[r];break;case"geometry":e[r]=b.arcadeUtils.createArcadeGeometryFromAccessorGeometry(c[r]);break;case"voxel":{const t=c[r];e[r]=null==t?null:b.Voxel.fromVoxelGraphic(t,o?.timeZone);break}case"pixel":{const t=c[r];e[r]=null==t?null:b.Pixel.fromImageryGraphic(t,o?.timeZone);break}case"json":e[r]=w(c[r])}}}function $(e,t){for(const r of e)t.push(r),"dictionary"===r.type&&$(r.properties,t);return t}function x(e,t,r,a,n){null!=r.lruCache&&o(l.getLogger("esri.arcade"),"ExecuteContext#lruCache",{replacement:"ExecuteContext#cache",warnOnce:!0,version:"5.0"});const c={vars:{},spatialReference:r.spatialReference,interceptor:r.interceptor,timeZone:r.timeZone,lrucache:L(r.cache),useAsync:n,services:r.services,console:r.console,abortSignal:r.abortSignal,track:r.track};return t?(A(c.vars,e.variables,t,a,r),c):c}function C(t,r){if(null==t||r.isVoid(t))return null;if(r.isArray(t))return t.map(e=>C(e,r));if(r.isImmutableArray(t))return t.toArray().map(e=>C(e,r));if(r.isDate(t))return t.toJSDate();if(r.isString(t))return t;if(r.isBoolean(t))return t;if(r.isNumber(t))return t;if(r.isDictionary(t)||r.isAttachment(t)||r.isPortal(t)){const e=Object.create(null);for(const a of t.keys())e[a]=C(t.field(a),r);return e}if(r.isFeature(t)){const r=t,a="geometry"in r?r.geometry()?.asAccessorGeometry():null,n="readAttributes"in r?r.readAttributes():r.attributes;return new e({geometry:a,attributes:n})}return r.isGeometry(t)?t.asAccessorGeometry():r.isDateOnly(t)||r.isTime(t)?t.toString():t}class j{constructor(e,t){this._actual=e,this._lc=t,this.declaredClass="esri.arcade.Dictionary"}keys(){return this._actual.keys()}field(e){return O(this._actual.field(e),this._lc)}castAsJson(){return this._actual.castAsJson()}castAsJsonAsync(e){return this._actual.castAsJsonAsync(e)}}class k{constructor(e,t){this._actual=e,this._lc=t,this.arcadeDeclaredClass="esri.arcade.Feature"}keys(){return this._actual.keys()}field(e){return O(this._actual.field(e),this._lc)}geometry(){return this._actual.geometry()?.asAccessorGeometry()??null}castAsJson(){return this._actual.castAsJson()}}function O(e,t){return t.isGeometry(e)?e.asAccessorGeometry():t.isArray(e)?e.map(e=>O(e,t)):t.isImmutableArray(e)?a.from(e.toArray().map(e=>O(e,t))):t.isDictionary(e)?new j(e,t):t.isFeature(e)?new k(e,t):e}const E={variables:[{name:"$feature",type:"feature"},{name:"$originalFeature",type:"feature"},{name:"$layer",type:"featureSet"},{name:"$featureSet",type:"featureSet"},{name:"$datastore",type:"featureSetCollection"},{name:"$map",type:"featureSetCollection"},{name:"$editContext",type:"dictionary",properties:[{name:"editType",type:"text"}]}]},I={variables:[{name:"$feature",type:"feature"},{name:"$layer",type:"featureSet"},{name:"$datastore",type:"featureSetCollection"},{name:"$map",type:"featureSetCollection"},{name:"$userInput",type:"geometry"},{name:"$graph",type:"knowledgeGraph"},{name:"$view",type:"dictionary",properties:[{name:"scale",type:"number"},{name:"timeProperties",type:"dictionary",properties:[{name:"currentStart",type:"date"},{name:"currentEnd",type:"date"},{name:"startIncluded",type:"boolean"},{name:"endIncluded",type:"boolean"}]}]}]},F={variables:[{name:"$feature",type:"feature"},{name:"$aggregatedFeatures",type:"featureSet"},{name:"$view",type:"dictionary",properties:[{name:"scale",type:"number"},{name:"timeProperties",type:"dictionary",properties:[{name:"currentStart",type:"date"},{name:"currentEnd",type:"date"},{name:"startIncluded",type:"boolean"},{name:"endIncluded",type:"boolean"}]}]}]},D={variables:[{name:"$voxel",type:"voxel"}]},T={variables:[{name:"$pixel",type:"pixel"},{name:"$imageCollectionItem",type:"feature"},{name:"$userInput",type:"geometry"},{name:"$view",type:"dictionary",properties:[{name:"scale",type:"number"},{name:"timeProperties",type:"dictionary",properties:[{name:"currentStart",type:"date"},{name:"currentEnd",type:"date"},{name:"startIncluded",type:"boolean"},{name:"endIncluded",type:"boolean"}]}]}]},G=new Map([["aggregate-field",{variables:[{name:"$feature",type:"feature"}]}],["form-constraint",E],["feature-z",{variables:[{name:"$feature",type:"feature"}]}],["field-calculation",{variables:[{name:"$feature",type:"feature"},{name:"$datastore",type:"featureSetCollection"}]}],["form-calculation",E],["form-dynamic-choice",E],["form-attachment-filename-calculation",{variables:[{name:"$feature",type:"feature"},{name:"$originalFeature",type:"feature"},{name:"$layer",type:"featureSet"},{name:"$datastore",type:"featureSetCollection"},{name:"$featureset",type:"featureSet"},{name:"$map",type:"featureSetCollection"},{name:"$formElement",type:"dictionary",properties:[{name:"attachmentKeyword",type:"text"},{name:"label",type:"text"},{name:"description",type:"text"}]}]}],["labeling",{variables:[{name:"$feature",type:"feature"},{name:"$view",type:"dictionary",properties:[{name:"scale",type:"number"},{name:"timeProperties",type:"dictionary",properties:[{name:"currentStart",type:"date"},{name:"currentEnd",type:"date"},{name:"startIncluded",type:"boolean"},{name:"endIncluded",type:"boolean"}]}]}]}],["popup",I],["popup-element",I],["popup-feature-reduction",F],["popup-element-feature-reduction",F],["visualization",{variables:[{name:"$feature",type:"feature"},{name:"$view",type:"dictionary",properties:[{name:"scale",type:"number"},{name:"timeProperties",type:"dictionary",properties:[{name:"currentStart",type:"date"},{name:"currentEnd",type:"date"},{name:"startIncluded",type:"boolean"},{name:"endIncluded",type:"boolean"}]}]}]}],["popup-voxel",D],["popup-element-voxel",D],["popup-imagery",T],["popup-element-imagery",T]]);function _(e){"feature-reduction-popup"===e?(c(l.getLogger("esri.arcade"),'profile name: "feature-reduction-popup"',{replacement:'"popup-feature-reduction"',version:"4.32",warnOnce:!0}),e="popup-feature-reduction"):"feature-reduction-popup-element"===e&&(c(l.getLogger("esri.arcade"),'profile name: "feature-reduction-popup-element"',{replacement:'"popup-element-feature-reduction"',version:"4.32",warnOnce:!0}),e="popup-element-feature-reduction");const t=G.get(e);if(!t){const t=Array.from(G.keys()).map(e=>`'${e}'`).join(", ");throw new i("createArcadeProfile:invalid-profile-name",`Invalid profile name '${e}'. You must specify one of the following values: ${t}`)}return s(t)}async function U(e,t,a={}){b||(b=await d());const{arcade:n,arcadeUtils:c,batchExec:{createBatchExecutor:s},aiServices:{BatchTranslationServiceFactory:u,PortalTranslationService:p},languageUtils:m}=b,{loadScriptDependencies:f,referencesMember:h,scriptIsAsync:v}=n,g=$(t.variables,[]).filter(e=>"featureSet"===e.type||"featureSetCollection"===e.type).map(e=>r(e.name)),S=n.parseScript(e,g);if(!S)throw new i("arcade:invalid-script","Unable to create SyntaxTree");const w=c.extractFieldNames(S),A=n.scriptTouchesGeometry(S),j=t.variables.map(e=>r(e.name)).filter(e=>h(S,e)),k=v(S,g);await f(S,k,g);const E=n.compileScript(S,{vars:Object.fromEntries(j.map(e=>[e,!0])),useAsync:k}),I=a.services,F=a.cache??a.lruCache;null!=a.lruCache&&o(l.getLogger("esri.arcade"),"ExecutorOptions#lruCache",{replacement:"ExecutorOptions#cache",warnOnce:!0,version:"5.0"});const D=n.featureSetUtils(),T=(e,r={})=>{if(k)throw new i("arcade:invalid-execution-mode","Cannot execute the script in synchronous mode");const a={...I,...r.services},n=r.cache??r.lruCache??F,o={...r,cache:n,services:a},c=E(x(t,e,o,D,k));return r.rawOutput?O(c,m):C(c,m)},G=async(e,r={})=>{const a={...I,...r.services},n=r.cache??r.lruCache??F,o={...r,cache:n,services:a},c=await E(x(t,e,o,D,k));return r.rawOutput?O(c,m):C(c,m)},_=async(e,r,a={})=>{const n=[],o=a.cache??a.lruCache??F,c=s(e,async(e,c)=>{const s=r(e);try{const e={...i,translation:l.create(c)},r={...a,cache:o,services:e},u=await E(x(t,s,r,D,k)),p=a.rawOutput?O(u,m):C(u,m);n.push({id:c.id,result:{status:"fulfilled",value:p}})}catch(u){throw n.push({id:c.id,result:{status:"rejected",reason:u}}),u}},a.maxConcurrency??64,a.abortSignal),i={...I,...a.services},l=new u(c,i.translation??new p(i.portal??y.getDefault(),a.console));return await c.run(),n.sort(({id:e},{id:t})=>e-t).map(({result:e})=>e)};return{execute:T,executeAsync:G,executeAsyncBatch:_,isAsync:k,variablesUsed:j,fieldsUsed:w,geometryUsed:A,syntaxTree:S}}async function P(e,t,a={}){b||(b=await d());const{arcade:n}=b,{loadScriptDependencies:c,scriptIsAsync:s}=n,u=$(t.variables,[]).filter(e=>"featureSet"===e.type||"featureSetCollection"===e.type).map(e=>r(e.name)),p=n.parseScript(e,u);if(!p)throw new i("arcade:invalid-script","Unable to create SyntaxTree");const m=s(p,u)||null!=a.breakpoints;await c(p,m,u),await n.enableFeatureSetSupport();const y=n.compileDebugScript(p,{vars:Object.fromEntries(t.variables.map(e=>e.name).map(e=>[e,!0])),useAsync:m,breakpoints:a.breakpoints}),f=a.services,h=a.cache??a.lruCache;null!=a.lruCache&&o(l.getLogger("esri.arcade"),"ExecutorOptions#lruCache",{replacement:"ExecutorOptions#cache",warnOnce:!0,version:"5.0"});const v=n.featureSetUtils();return{async executeAsync(e,r={}){const a={...f,...r.services},n=r.cache??r.lruCache??h,o={...r,cache:n,services:a};return await y(x(t,e,o,v,m))}}}function J(){return new n}function L(e){if(null!=e&&!(e instanceof n))throw new Error("Use createArcadeCache() to construct a cache instance or provide null/undefined.");return e}export{J as createArcadeCache,P as createArcadeDebugExecutor,U as createArcadeExecutor,_ as createArcadeProfile};
|