@arcgis/core 4.27.0-rc.0 → 4.27.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/arcade/featureSetUtils.js +1 -1
  2. package/arcade/featureset/actions/GroupBy.js +1 -1
  3. package/arcade/featureset/actions/OrderBy.js +1 -1
  4. package/arcade/functions/featuresetbase.js +1 -1
  5. package/arcade/functions/featuresetstring.js +1 -1
  6. package/arcade/languageUtils.js +1 -1
  7. package/arcade/treeAnalysis.js +1 -1
  8. package/assets/esri/core/workers/RemoteClient.js +1 -1
  9. package/assets/esri/core/workers/chunks/0407bf97ad621c89a734.js +1 -0
  10. package/assets/esri/core/workers/chunks/0610691a0c0d9fbbd6d2.js +1 -0
  11. package/assets/esri/core/workers/chunks/{7ec6be2bc0f354011e46.js → 07651ef8348f702d59ac.js} +1 -1
  12. package/assets/esri/core/workers/chunks/0a02ac5628d1739372c6.js +1 -0
  13. package/assets/esri/core/workers/chunks/0a86c458916e83d6c523.js +1 -0
  14. package/assets/esri/core/workers/chunks/14145959a3dab1437818.js +1 -0
  15. package/assets/esri/core/workers/chunks/16db0bc87d87a7313dc4.js +1 -0
  16. package/assets/esri/core/workers/chunks/183e2e0cb86c1c640d94.js +1 -0
  17. package/assets/esri/core/workers/chunks/19d329b9d4ec2eff1d13.js +1 -0
  18. package/assets/esri/core/workers/chunks/1b8074269800b384ecf6.js +1 -0
  19. package/assets/esri/core/workers/chunks/2154d395f405be3cd3ba.js +1 -0
  20. package/assets/esri/core/workers/chunks/{33dbba3b7fc648437e50.js → 21e1f3b11e7d363b727a.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{31a158c73994603c169d.js → 2446e336b1f7256d4fde.js} +1 -1
  22. package/assets/esri/core/workers/chunks/29290a44fd3b183c24e3.js +1 -0
  23. package/assets/esri/core/workers/chunks/{f498c4d4831141125781.js → 2f5639886f577baedbca.js} +1 -1
  24. package/assets/esri/core/workers/chunks/33901eb1574e46abd9af.js +1 -0
  25. package/assets/esri/core/workers/chunks/{9c78ad5ab57e0d47ac43.js → 3ba2fcb9110230f8790c.js} +1 -1
  26. package/assets/esri/core/workers/chunks/3e239bfad611985e50fb.js +1 -0
  27. package/assets/esri/core/workers/chunks/42f3421740a5479559dc.js +1 -0
  28. package/assets/esri/core/workers/chunks/474d9b334812533bab36.js +1 -0
  29. package/assets/esri/core/workers/chunks/53ad34bf32f5f3d4fe18.js +1 -0
  30. package/assets/esri/core/workers/chunks/{97cdbec7532cfcdf9ad2.js → 595a2baa04d92de59558.js} +1 -1
  31. package/assets/esri/core/workers/chunks/624521961fe1f2c4f2c5.js +1 -0
  32. package/assets/esri/core/workers/chunks/{212d59764c275c763941.js → 659b7bad7281c0e2aed3.js} +1 -1
  33. package/assets/esri/core/workers/chunks/6a3d611e8842afbb50ab.js.LICENSE.txt +1 -1
  34. package/assets/esri/core/workers/chunks/6e562fa57c0347091154.js +1 -0
  35. package/assets/esri/core/workers/chunks/7479dc0c790337af7597.js +1 -0
  36. package/assets/esri/core/workers/chunks/{e88cff2537be52da6531.js → 74fd2059ddda9083cbcc.js} +1 -1
  37. package/assets/esri/core/workers/chunks/7dc6774c77c822b68c99.js +1 -0
  38. package/assets/esri/core/workers/chunks/82a103a8b5382300889d.js +1 -0
  39. package/assets/esri/core/workers/chunks/{3fe357df92afa1bee70a.js → 90da1ed112b82712d0ef.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{9849f64793f2ad39366b.js → 9290b0d330f02233d803.js} +1 -1
  41. package/assets/esri/core/workers/chunks/92e7f224a80195e606d6.js +1 -0
  42. package/assets/esri/core/workers/chunks/{36df72362b38759b895b.js → 9648a8f2b24f1ca3d637.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{ad18fb7bb54a0c4bdb38.js → a20361b4d3bdd7d196ca.js} +1 -1
  44. package/assets/esri/core/workers/chunks/a7fd2a95fde197c06828.js +1 -0
  45. package/assets/esri/core/workers/chunks/b0cda39b53ecd6c44cd0.js +1 -0
  46. package/assets/esri/core/workers/chunks/b2a423d9ce8bb784267c.js +1 -0
  47. package/assets/esri/core/workers/chunks/b5fc6f2044ed047c5afd.js +1 -0
  48. package/assets/esri/core/workers/chunks/{df0453cdfe685d6436cc.js → b6dc41fce601b9d3480e.js} +1 -1
  49. package/assets/esri/core/workers/chunks/b8e6c64792a512df4c4d.js +1 -0
  50. package/assets/esri/core/workers/chunks/c6617a937440701c0180.js +1 -0
  51. package/assets/esri/core/workers/chunks/c6efe2e04ea6a55bb6e3.js +1 -0
  52. package/assets/esri/core/workers/chunks/d8607326a199dd994844.js +1 -0
  53. package/assets/esri/core/workers/chunks/d8bd3f498b3fa8153404.js +1 -0
  54. package/assets/esri/core/workers/chunks/{39e473586579d11d6732.js → e2432871f1329f47465d.js} +1 -1
  55. package/assets/esri/core/workers/chunks/ee5ee03dd2c7dc940272.js +1 -0
  56. package/assets/esri/core/workers/chunks/{c83669cf08391a62fb72.js → f1da7b29eecad0e9efae.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{2e627c94e57c924e5917.js → f339db2b599fa9585283.js} +1 -1
  58. package/assets/esri/core/workers/chunks/f505ebd4bd3bfb6c790d.js +1 -0
  59. package/assets/esri/core/workers/chunks/{3c6c082157c916f8ddba.js → ffe61d5a6a9b34bee9d4.js} +1 -1
  60. package/assets/esri/themes/base/widgets/_Bookmarks.scss +5 -0
  61. package/assets/esri/themes/base/widgets/_Features.scss +5 -7
  62. package/assets/esri/themes/base/widgets/_Popup.scss +3 -3
  63. package/assets/esri/themes/base/widgets/_Swipe.scss +11 -0
  64. package/assets/esri/themes/dark/main.css +1 -1
  65. package/assets/esri/themes/light/main.css +1 -1
  66. package/assets/esri/themes/light/view.css +1 -1
  67. package/chunks/SSAO.glsl.js +1 -1
  68. package/chunks/languageUtils.js +1 -1
  69. package/geometry/Mesh.js +1 -1
  70. package/geometry/support/DoubleArray.js +1 -1
  71. package/geometry/support/meshUtils/bounds.js +5 -0
  72. package/geometry/support/meshUtils/georeference.js +1 -1
  73. package/interfaces.d.ts +2 -2
  74. package/kernel.js +1 -1
  75. package/layers/FeatureLayer.js +1 -1
  76. package/layers/StreamLayer.js +1 -1
  77. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  78. package/layers/graphics/data/QueryEngine.js +1 -1
  79. package/layers/graphics/data/attributeSupport.js +1 -1
  80. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  81. package/layers/support/FeatureReductionBinning.js +1 -1
  82. package/layers/support/FeatureReductionCluster.js +1 -1
  83. package/layers/support/featureLayerUtils.js +1 -1
  84. package/layers/support/rasterFunctions/colormaps.js +1 -1
  85. package/package.json +2 -2
  86. package/renderers/support/utils.js +1 -1
  87. package/support/arcadeUtils.js +1 -1
  88. package/support/revision.js +1 -1
  89. package/symbols/cim/CIMSymbolHelper.js +1 -1
  90. package/symbols/cim/effects/EffectBuffer.js +1 -1
  91. package/symbols/cim/effects/EffectDonut.js +1 -1
  92. package/symbols/cim/effects/EffectOffset.js +1 -1
  93. package/views/2d/layers/features/Store2D.js +1 -1
  94. package/views/2d/layers/features/sources/StreamSource.js +1 -1
  95. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  96. package/views/3d/layers/graphics/webStyleUtils.js +1 -1
  97. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  98. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  99. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  100. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  101. package/views/3d/webgl-engine/materials/pbrUtils.js +5 -0
  102. package/webdoc/support/writeUtils.js +1 -1
  103. package/widgets/Bookmarks/css.js +1 -1
  104. package/widgets/Bookmarks.js +1 -1
  105. package/widgets/Features.js +1 -1
  106. package/assets/esri/core/workers/chunks/0b03165dbf289797cefa.js +0 -1
  107. package/assets/esri/core/workers/chunks/0c1c0024879f944f44c4.js +0 -1
  108. package/assets/esri/core/workers/chunks/13a48796905613bc1679.js +0 -1
  109. package/assets/esri/core/workers/chunks/1ea1104651ab15f9a13c.js +0 -1
  110. package/assets/esri/core/workers/chunks/2108cfc7921430f0b805.js +0 -1
  111. package/assets/esri/core/workers/chunks/2eacca322737aafd8f0c.js +0 -1
  112. package/assets/esri/core/workers/chunks/39577683e334eb4d904c.js +0 -1
  113. package/assets/esri/core/workers/chunks/4d3deeb0ebd0ce8c1215.js +0 -1
  114. package/assets/esri/core/workers/chunks/576bddc3fa7d91a7e5bd.js +0 -1
  115. package/assets/esri/core/workers/chunks/623d6710a4f800c622ce.js +0 -1
  116. package/assets/esri/core/workers/chunks/6782cc3feb713676d544.js +0 -1
  117. package/assets/esri/core/workers/chunks/6e7178de0b2c3d2f7e6b.js +0 -1
  118. package/assets/esri/core/workers/chunks/78ce0b1af62435d8ebf4.js +0 -1
  119. package/assets/esri/core/workers/chunks/79d2baf392589588ef9b.js +0 -1
  120. package/assets/esri/core/workers/chunks/7bbdba52157da13a01fc.js +0 -1
  121. package/assets/esri/core/workers/chunks/84860b535a70ec448cfe.js +0 -1
  122. package/assets/esri/core/workers/chunks/9035d9e09a4e7cb94d37.js +0 -1
  123. package/assets/esri/core/workers/chunks/956b0fef7bc849415354.js +0 -1
  124. package/assets/esri/core/workers/chunks/9ab98321a4a7eaeeb018.js +0 -1
  125. package/assets/esri/core/workers/chunks/9cb7a68ff46e5c43e1d2.js +0 -1
  126. package/assets/esri/core/workers/chunks/a0f7f7f578521970c714.js +0 -1
  127. package/assets/esri/core/workers/chunks/a60eac45d3c65bd0216f.js +0 -1
  128. package/assets/esri/core/workers/chunks/aca5260f6984952a6e3d.js +0 -1
  129. package/assets/esri/core/workers/chunks/b05be356743fa5d24573.js +0 -1
  130. package/assets/esri/core/workers/chunks/ba6024465308c248170b.js +0 -1
  131. package/assets/esri/core/workers/chunks/d0983f808008920514f2.js +0 -1
  132. package/assets/esri/core/workers/chunks/dab832799bc06b0fec34.js +0 -1
  133. package/assets/esri/core/workers/chunks/e45d36aef2bc69ee9132.js +0 -1
  134. package/assets/esri/core/workers/chunks/e5bbd4cc5edbf7ab3624.js +0 -1
  135. package/assets/esri/core/workers/chunks/e700cf4d1f99291a4396.js +0 -1
  136. package/assets/esri/core/workers/chunks/f398a5cf33c3fd2522a5.js +0 -1
  137. package/assets/esri/core/workers/chunks/f4ee94a6cde4ea8837f1.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../request.js";import t from"./featureSetCollection.js";import a from"./featureset/actions/AttributeFilter.js";import r from"./featureset/actions/GroupBy.js";import n from"./featureset/actions/OrderBy.js";import i from"./featureset/actions/SpatialFilter.js";import s from"./featureset/actions/Top.js";import l from"./featureset/sources/FeatureLayerDynamic.js";import o from"./featureset/sources/FeatureLayerMemory.js";import u from"./featureset/sources/FeatureLayerRelated.js";import c from"./featureset/support/cache.js";import{FeatureSetError as d,FeatureSetErrorCodes as f}from"./featureset/support/errorsupport.js";import p from"./featureset/support/FeatureSet.js";import{extractServiceUrl as m}from"./featureset/support/shared.js";import{WhereClause as y}from"../core/sql/WhereClause.js";import h from"../layers/FeatureLayer.js";import _ from"../layers/SubtypeGroupLayer.js";import S from"../layers/support/SubtypeSublayer.js";import L from"../portal/PortalItem.js";function w(){null===c.applicationCache&&(c.applicationCache=new c)}async function I(e,t){if(c.applicationCache){const r=c.applicationCache.getLayerInfo(e);if(r){const a=await r;return new h({url:e,outFields:t,sourceJSON:a})}const n=new h({url:e,outFields:t}),i=(async()=>(await n.load(),n.sourceJSON))();if(c.applicationCache){c.applicationCache.setLayerInfo(e,i);try{return await i,n}catch(a){throw c.applicationCache.clearLayerInfo(e),a}}return await i,n}return new h({url:e,outFields:t})}async function F(e,t,a,r,n,i=null){return g(await I(e,["*"]),t,a,r,n,i)}function g(e,t=null,a=null,r=!0,n=null,i=null){if(e instanceof h||e instanceof _){const s={layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:n,interceptor:i};return!0==!(e.url||!e.source)?new o(s):new l(s)}return g(e.parent,t,a,r,n,i).filter(y.create(e.parent.subtypeField+"="+e.subtypeCode.toString(),e.parent?.fieldsIndex))}async function A(t){if(null!==c.applicationCache){const e=c.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});return a.data?a.data:null})();if(null!==c.applicationCache){c.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw c.applicationCache.clearLayerInfo(t),r}}return a}async function N(t,a){const r="QUERYDATAELEMTS:"+a.toString()+":"+t;if(null!==c.applicationCache){const e=c.applicationCache.getLayerInfo(r);if(null!==e)return e}const n=(async()=>{const r=await e(t+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([a.toString()]),f:"json"}});if(r.data){const e=r.data;if(e.layerDataElements&&e.layerDataElements[0])return e.layerDataElements[0]}throw new d(f.DataElementsNotFound)})();if(null!==c.applicationCache){c.applicationCache.setLayerInfo(r,n);try{return await n}catch(i){throw c.applicationCache.clearLayerInfo(r),i}}return n}async function C(t){if(null!==c.applicationCache){const e=c.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});if(a.data){const e=a.data;return e.layers||(e.layers=[]),e.tables||(e.tables=[]),e}return{layers:[],tables:[]}})();if(null!==c.applicationCache){c.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw c.applicationCache.clearLayerInfo(t),r}}return a}async function T(e,t){const a={metadata:null,networkId:-1,unVersion:3,terminals:[],queryelem:null,layerNameLkp:{},lkp:null},r=await C(e);if(a.metadata=r,r.controllerDatasetLayers&&void 0!==r.controllerDatasetLayers.utilityNetworkLayerId&&null!==r.controllerDatasetLayers.utilityNetworkLayerId){if(r.layers)for(const e of r.layers)a.layerNameLkp[e.id]=e.name;if(r.tables)for(const e of r.tables)a.layerNameLkp[e.id]=e.name;const n=r.controllerDatasetLayers.utilityNetworkLayerId;a.networkId=n;const i=await N(e,n);if(i){a.queryelem=i,a.queryelem&&a.queryelem.dataElement&&void 0!==a.queryelem.dataElement.schemaGeneration&&(a.unVersion=a.queryelem.dataElement.schemaGeneration),a.lkp={},a.queryelem.dataElement.domainNetworks||(a.queryelem.dataElement.domainNetworks=[]);for(const e of a.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:a.layerNameLkp[t.layerId]??null};e.className&&(a.lkp[e.className]=e)}for(const t of e.junctionSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:a.layerNameLkp[t.layerId]??null};e.className&&(a.lkp[e.className]=e)}}if(a.queryelem.dataElement.terminalConfigurations)for(const e of a.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)a.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});const r=await A(e+"/"+n);if(r.systemLayers&&void 0!==r.systemLayers.associationsTableId&&null!==r.systemLayers.associationsTableId){const n=[];a.unVersion>=4&&(n.push("STATUS"),n.push("PERCENTALONG"));let i=await F(e+"/"+r.systemLayers.associationsTableId.toString(),t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...n],!1,null,null);return await i.load(),a.unVersion>=4&&(i=i.filter(y.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62,63)",i.getFieldsIndex())),await i.load()),{lkp:a.lkp,associations:i,unVersion:a.unVersion,terminals:a.terminals}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}async function k(e,t,a,r=null,n=null,i=!0,s=null,l=null){let o=e.serviceUrl();if(!o)return null;o="/"===o.charAt(o.length-1)?o+t.relatedTableId.toString():o+"/"+t.relatedTableId.toString();const c=await F(o,r,n,i,s,l);return new u({layer:e,relatedLayer:c,relationship:t,objectId:a,spatialReference:r,outFields:n,includeGeometry:i,lrucache:s,interceptor:l})}a.registerAction(),r.registerAction(),n.registerAction(),i.registerAction(),s.registerAction();class b extends t{constructor(e,t=null,a=null,r=null){super(),this._map=e,this._overridespref=t,this._lrucache=a,this._interceptor=r,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,a=null){const r=g(e,this._overridespref,null===a?["*"]:a,t,this._lrucache,this._interceptor);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async featureSetByName(e,t=!0,a=null){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return await this._map.load(),this.featureSetByName(e,t,a);null===a&&(a=["*"]),a=(a=a.slice(0)).sort();const r=JSON.stringify(a);for(let l=0;l<this._instantLayers.length;l++){const a=this._instantLayers[l];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[l].featureset}const n=[],i=this._map.allLayers.find((t=>{if(t instanceof h){if(t.title===e)return!0}else if(t instanceof _){if(t.title===e)return!0;n.push(t)}return!1}));if(i)return this._makeAndAddFeatureSet(i,t,a);if(this._map.tables){const r=this._map.tables.find((t=>!!(t.title&&t.title===e||t.title&&t.title===e)));if(r){if(r instanceof h)return this._makeAndAddFeatureSet(r,t,a);if(r._materializedTable);else{const e=r.outFields?r:{...r,outFields:["*"]};r._materializedTable=new h(e)}return await r._materializedTable.load(),this._makeAndAddFeatureSet(r._materializedTable,t,a)}}for(const l of n){if("not-loaded"===l.loadStatus||"loading"===l.loadStatus)try{await l.load()}catch(s){}const r=l.sublayers.find((t=>t.title===e));if(r)return this._makeAndAddFeatureSet(r,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return await this._map.load(),this.featureSetById(e,t,a);null===a&&(a=["*"]),a=(a=a.slice(0)).sort();const r=JSON.stringify(a);for(let l=0;l<this._instantLayers.length;l++){const a=this._instantLayers[l];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[l].featureset}const n=[],i=this._map.allLayers.find((t=>{if(t instanceof h){if(t.id===e)return!0}else if(t instanceof _){if(t.id===e)return!0;n.push(t)}return!1}));if(i)return this._makeAndAddFeatureSet(i,t,a);if(this._map.tables){const r=this._map.tables.find((t=>t.id===e));if(r){if(r instanceof h)return this._makeAndAddFeatureSet(r,t,a);if(r._materializedTable);else{const e={...r,outFields:["*"]};r._materializedTable=new h(e)}return await r._materializedTable.load(),this._makeAndAddFeatureSet(r._materializedTable,t,a)}}for(const l of n){if("not-loaded"===l.loadStatus||"loading"===l.loadStatus)try{await l.load()}catch(s){}const r=l.sublayers.find((t=>t.id===e));if(r)return this._makeAndAddFeatureSet(r,t,a)}return null}}class O extends t{constructor(e,t=null,a=null,r=null){super(),this._url=e,this._overridespref=t,this._lrucache=a,this._interceptor=r,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,a=null){const r=g(e,this._overridespref,null===a?["*"]:a,t,this._lrucache);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async _loadMetaData(){const e=await C(this._url);return this.metadata=e,e}load(){return this._loadMetaData()}clone(){return new O(this._url,this._overridespref,this._lrucache,this._interceptor)}async featureSetByName(e,t=!0,a=null){null===a&&(a=["*"]),a=(a=a.slice(0)).sort();const r=JSON.stringify(a);for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let i=null;for(const s of n.layers??[])s.name===e&&(i=s);if(!i)for(const s of n.tables??[])s.name===e&&(i=s);if(i){const e=await I(this._url+"/"+i.id,["*"]);return this._makeAndAddFeatureSet(e,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){null===a&&(a=["*"]),a=(a=a.slice(0)).sort();const r=JSON.stringify(a);e=null!=e?e.toString():"";for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let i=null;for(const s of n.layers??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(i=s);if(!i)for(const s of n.tables??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(i=s);if(i){const e=await I(this._url+"/"+i.id,["*"]);return this._makeAndAddFeatureSet(e,t,a)}return null}}function E(e,t,a=null,r=null){return new b(e,t,a,r)}function j(e,t,a=null,r=null){return new O(e,t,a,r)}function D(e,t,a,r,n){if(null===e)return null;if(e instanceof h){switch(t){case"datasource":return g(e,n,e.outFields,!0,a,r).getDataSourceFeatureSet();case"parent":case"root":return g(e,n,e.outFields,!0,a,r)}return null}if(e instanceof _){switch(t){case"datasource":return g(e,n,e.outFields,!0,a,r).getDataSourceFeatureSet();case"parent":case"root":return g(e,n,e.outFields,!0,a,r)}return null}if(e instanceof S){switch(t){case"datasource":return g(e.parent,n,e.parent.outFields,!0,a,r).getDataSourceFeatureSet();case"parent":case"root":return g(e,n,e.parent.outFields,!0,a,r)}return null}if(e instanceof p)switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}async function q(e,t,a,r,n,i,s,l=null){if(c.applicationCache){const o=c.applicationCache.getLayerInfo(e+":"+i.url);if(o){const e=await o;return g(new h({url:m(e.url)+"/"+t,outFields:["*"]}),a,r,n,s,l)}}const o=new L({id:e,portal:i}).load();c.applicationCache&&c.applicationCache.setLayerInfo(e+":"+i.url,o);try{const e=await o;return g(new h({url:m(e.url??"")+"/"+t,outFields:["*"]}),a,r,n,s,l)}catch(u){throw c.applicationCache&&c.applicationCache.clearLayerInfo(e+":"+i.url),u}}export{T as constructAssociationMetaDataFeatureSetFromUrl,g as constructFeatureSet,q as constructFeatureSetFromPortalItem,k as constructFeatureSetFromRelationship,F as constructFeatureSetFromUrl,D as convertToFeatureSet,E as createFeatureSetCollectionFromMap,j as createFeatureSetCollectionFromService,w as initialiseMetaDataCache};
5
+ import e from"../request.js";import t from"./featureSetCollection.js";import{Z as a,_ as r}from"../chunks/languageUtils.js";import n from"./featureset/actions/AttributeFilter.js";import i from"./featureset/actions/GroupBy.js";import s from"./featureset/actions/OrderBy.js";import l from"./featureset/actions/SpatialFilter.js";import o from"./featureset/actions/Top.js";import u from"./featureset/sources/FeatureLayerDynamic.js";import c from"./featureset/sources/FeatureLayerMemory.js";import d from"./featureset/sources/FeatureLayerRelated.js";import f from"./featureset/support/cache.js";import{FeatureSetError as p,FeatureSetErrorCodes as m}from"./featureset/support/errorsupport.js";import y from"./featureset/support/FeatureSet.js";import{extractServiceUrl as h}from"./featureset/support/shared.js";import{WhereClause as _}from"../core/sql/WhereClause.js";import w from"../layers/FeatureLayer.js";import L from"../portal/PortalItem.js";function S(){null===f.applicationCache&&(f.applicationCache=new f)}async function I(e,t){if(f.applicationCache){const r=f.applicationCache.getLayerInfo(e);if(r){const a=await r;return new w({url:e,outFields:t,sourceJSON:a})}const n=new w({url:e,outFields:t}),i=(async()=>(await n.load(),n.sourceJSON))();if(f.applicationCache){f.applicationCache.setLayerInfo(e,i);try{return await i,n}catch(a){throw f.applicationCache.clearLayerInfo(e),a}}return await i,n}return new w({url:e,outFields:t})}async function F(e,t,a,r,n,i=null){return g(await I(e,["*"]),t,a,r,n,i)}function g(e,t=null,r=null,n=!0,i=null,s=null){if(e instanceof w||a(e)){const a={layer:e,spatialReference:t,outFields:r,includeGeometry:n,lrucache:i,interceptor:s};return!0==!(e.url||!e.source)?new c(a):new u(a)}return g(e.parent,t,r,n,i,s).filter(_.create(e.parent.subtypeField+"="+e.subtypeCode.toString(),e.parent?.fieldsIndex))}async function A(t){if(null!==f.applicationCache){const e=f.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});return a.data?a.data:null})();if(null!==f.applicationCache){f.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw f.applicationCache.clearLayerInfo(t),r}}return a}async function N(t,a){const r="QUERYDATAELEMTS:"+a.toString()+":"+t;if(null!==f.applicationCache){const e=f.applicationCache.getLayerInfo(r);if(null!==e)return e}const n=(async()=>{const r=await e(t+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([a.toString()]),f:"json"}});if(r.data){const e=r.data;if(e.layerDataElements&&e.layerDataElements[0])return e.layerDataElements[0]}throw new p(m.DataElementsNotFound)})();if(null!==f.applicationCache){f.applicationCache.setLayerInfo(r,n);try{return await n}catch(i){throw f.applicationCache.clearLayerInfo(r),i}}return n}async function C(t){if(null!==f.applicationCache){const e=f.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});if(a.data){const e=a.data;return e.layers||(e.layers=[]),e.tables||(e.tables=[]),e}return{layers:[],tables:[]}})();if(null!==f.applicationCache){f.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw f.applicationCache.clearLayerInfo(t),r}}return a}async function T(e,t){const a={metadata:null,networkId:-1,unVersion:3,terminals:[],queryelem:null,layerNameLkp:{},lkp:null},r=await C(e);if(a.metadata=r,r.controllerDatasetLayers&&void 0!==r.controllerDatasetLayers.utilityNetworkLayerId&&null!==r.controllerDatasetLayers.utilityNetworkLayerId){if(r.layers)for(const e of r.layers)a.layerNameLkp[e.id]=e.name;if(r.tables)for(const e of r.tables)a.layerNameLkp[e.id]=e.name;const n=r.controllerDatasetLayers.utilityNetworkLayerId;a.networkId=n;const i=await N(e,n);if(i){a.queryelem=i,a.queryelem&&a.queryelem.dataElement&&void 0!==a.queryelem.dataElement.schemaGeneration&&(a.unVersion=a.queryelem.dataElement.schemaGeneration),a.lkp={},a.queryelem.dataElement.domainNetworks||(a.queryelem.dataElement.domainNetworks=[]);for(const e of a.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:a.layerNameLkp[t.layerId]??null};e.className&&(a.lkp[e.className]=e)}for(const t of e.junctionSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:a.layerNameLkp[t.layerId]??null};e.className&&(a.lkp[e.className]=e)}}if(a.queryelem.dataElement.terminalConfigurations)for(const e of a.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)a.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});const r=await A(e+"/"+n);if(r.systemLayers&&void 0!==r.systemLayers.associationsTableId&&null!==r.systemLayers.associationsTableId){const n=[];a.unVersion>=4&&(n.push("STATUS"),n.push("PERCENTALONG"));let i=await F(e+"/"+r.systemLayers.associationsTableId.toString(),t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...n],!1,null,null);return await i.load(),a.unVersion>=4&&(i=i.filter(_.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62,63)",i.getFieldsIndex())),await i.load()),{lkp:a.lkp,associations:i,unVersion:a.unVersion,terminals:a.terminals}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}async function k(e,t,a,r=null,n=null,i=!0,s=null,l=null){let o=e.serviceUrl();if(!o)return null;o="/"===o.charAt(o.length-1)?o+t.relatedTableId.toString():o+"/"+t.relatedTableId.toString();const u=await F(o,r,n,i,s,l);return new d({layer:e,relatedLayer:u,relationship:t,objectId:a,spatialReference:r,outFields:n,includeGeometry:i,lrucache:s,interceptor:l})}n.registerAction(),i.registerAction(),s.registerAction(),l.registerAction(),o.registerAction();class b extends t{constructor(e,t=null,a=null,r=null){super(),this._map=e,this._overridespref=t,this._lrucache=a,this._interceptor=r,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,a=null){const r=g(e,this._overridespref,null===a?["*"]:a,t,this._lrucache,this._interceptor);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async featureSetByName(e,t=!0,r=null){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return await this._map.load(),this.featureSetByName(e,t,r);null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.title===e&&r.includeGeometry===t&&r.outFields===n)return this._instantLayers[a].featureset}const i=[],s=this._map.allLayers.find((t=>{if(t instanceof w){if(t.title===e)return!0}else if(a(t)){if(t.title===e)return!0;i.push(t)}return!1}));if(s)return this._makeAndAddFeatureSet(s,t,r);if(this._map.tables){const a=this._map.tables.find((t=>!!(t.title&&t.title===e||t.title&&t.title===e)));if(a){if(a instanceof w)return this._makeAndAddFeatureSet(a,t,r);if(a._materializedTable);else{const e=a.outFields?a:{...a,outFields:["*"]};a._materializedTable=new w(e)}return await a._materializedTable.load(),this._makeAndAddFeatureSet(a._materializedTable,t,r)}}for(const a of i){if("not-loaded"===a.loadStatus||"loading"===a.loadStatus)try{await a.load()}catch(l){}const n=a.sublayers.find((t=>t.title===e));if(n)return this._makeAndAddFeatureSet(n,t,r)}return null}async featureSetById(e,t=!0,r=["*"]){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return await this._map.load(),this.featureSetById(e,t,r);null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.id===e&&r.includeGeometry===t&&r.outFields===n)return this._instantLayers[a].featureset}const i=[],s=this._map.allLayers.find((t=>{if(t instanceof w){if(t.id===e)return!0}else if(a(t)){if(t.id===e)return!0;i.push(t)}return!1}));if(s)return this._makeAndAddFeatureSet(s,t,r);if(this._map.tables){const a=this._map.tables.find((t=>t.id===e));if(a){if(a instanceof w)return this._makeAndAddFeatureSet(a,t,r);if(a._materializedTable);else{const e={...a,outFields:["*"]};a._materializedTable=new w(e)}return await a._materializedTable.load(),this._makeAndAddFeatureSet(a._materializedTable,t,r)}}for(const a of i){if("not-loaded"===a.loadStatus||"loading"===a.loadStatus)try{await a.load()}catch(l){}const n=a.sublayers.find((t=>t.id===e));if(n)return this._makeAndAddFeatureSet(n,t,r)}return null}}class O extends t{constructor(e,t=null,a=null,r=null){super(),this._url=e,this._overridespref=t,this._lrucache=a,this._interceptor=r,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,a=null){const r=g(e,this._overridespref,null===a?["*"]:a,t,this._lrucache);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async _loadMetaData(){const e=await C(this._url);return this.metadata=e,e}load(){return this._loadMetaData()}clone(){return new O(this._url,this._overridespref,this._lrucache,this._interceptor)}async featureSetByName(e,t=!0,a=null){null===a&&(a=["*"]),a=(a=a.slice(0)).sort();const r=JSON.stringify(a);for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let i=null;for(const s of n.layers??[])s.name===e&&(i=s);if(!i)for(const s of n.tables??[])s.name===e&&(i=s);if(i){const e=await I(this._url+"/"+i.id,["*"]);return this._makeAndAddFeatureSet(e,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){null===a&&(a=["*"]),a=(a=a.slice(0)).sort();const r=JSON.stringify(a);e=null!=e?e.toString():"";for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let i=null;for(const s of n.layers??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(i=s);if(!i)for(const s of n.tables??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(i=s);if(i){const e=await I(this._url+"/"+i.id,["*"]);return this._makeAndAddFeatureSet(e,t,a)}return null}}function E(e,t,a=null,r=null){return new b(e,t,a,r)}function D(e,t,a=null,r=null){return new O(e,t,a,r)}function j(e,t,n,i,s){if(null===e)return null;if(e instanceof w){switch(t){case"datasource":return g(e,s,e.outFields,!0,n,i).getDataSourceFeatureSet();case"parent":case"root":return g(e,s,e.outFields,!0,n,i)}return null}if(a(e)){switch(t){case"datasource":return g(e,s,e.outFields,!0,n,i).getDataSourceFeatureSet();case"parent":case"root":return g(e,s,e.outFields,!0,n,i)}return null}if(r(e)){switch(t){case"datasource":return g(e.parent,s,e.parent.outFields,!0,n,i).getDataSourceFeatureSet();case"parent":case"root":return g(e,s,e.parent.outFields,!0,n,i)}return null}if(e instanceof y)switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}async function q(e,t,a,r,n,i,s,l=null){if(f.applicationCache){const o=f.applicationCache.getLayerInfo(e+":"+i.url);if(o){const e=await o;return g(new w({url:h(e.url)+"/"+t,outFields:["*"]}),a,r,n,s,l)}}const o=new L({id:e,portal:i}).load();f.applicationCache&&f.applicationCache.setLayerInfo(e+":"+i.url,o);try{const e=await o;return g(new w({url:h(e.url??"")+"/"+t,outFields:["*"]}),a,r,n,s,l)}catch(u){throw f.applicationCache&&f.applicationCache.clearLayerInfo(e+":"+i.url),u}}export{T as constructAssociationMetaDataFeatureSetFromUrl,g as constructFeatureSet,q as constructFeatureSetFromPortalItem,k as constructFeatureSetFromRelationship,F as constructFeatureSetFromUrl,j as convertToFeatureSet,E as createFeatureSetCollectionFromMap,D as createFeatureSetCollectionFromService,S as initialiseMetaDataCache};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Graphic.js";import{Z as t}from"../../../chunks/languageUtils.js";import{SqlExpressionAdapted as i,OriginalField as s,AdaptedFeatureSet as n}from"./Adapted.js";import r from"./AttributeFilter.js";import a from"./OrderBy.js";import o from"../support/FeatureSet.js";import l from"../support/IdSet.js";import d from"../support/OrderbyClause.js";import{IdState as u,layerGeometryEsriConstants as f,FeatureServiceDatabaseType as c}from"../support/shared.js";import{isSingleField as h,toWhereClause as p,predictType as g,scanForField as _,reformulateWithoutField as m}from"../support/sqlUtils.js";import{calculateStat as y}from"../support/stats.js";import b from"../support/StatsField.js";import{createMD5Hash as w,outputTypes as F}from"../../../core/MD5.js";import{WhereClause as I}from"../../../core/sql/WhereClause.js";import S from"../../../geometry/SpatialReference.js";import x from"../../../layers/support/Field.js";import k from"../../../layers/support/FieldsIndex.js";import{FeatureSetError as D,FeatureSetErrorCodes as A}from"../support/errorsupport.js";function j(e){if(!e)return"COUNT";switch(e.toLowerCase()){case"max":return"MAX";case"var":case"variance":return"VAR";case"avg":case"average":case"mean":return"AVG";case"min":return"MIN";case"sum":return"SUM";case"stdev":case"stddev":return"STDDEV";case"count":return"COUNT"}return"COUNT"}class C extends o{constructor(e){super(e),this._decodedStatsfield=[],this._decodedGroupbyfield=[],this._candosimplegroupby=!0,this.phsyicalgroupbyfields=[],this.objectIdField="ROW__ID",this._internalObjectIdField="ROW__ID",this._adaptedFields=[],this.declaredClass="esri.arcade.featureset.actions.Aggregate",this._uniqueIds=1,this._maxQuery=10,this._maxProcessing=10,this._parent=e.parentfeatureset,this._config=e}isTable(){return!0}async _getSet(e){if(null===this._wset){const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,this._wset}return this._wset}_isInFeatureSet(){return u.InFeatureSet}_nextUniqueName(e){for(;1===e["T"+this._uniqueIds.toString()];)this._uniqueIds++;const t="T"+this._uniqueIds.toString();return e[t]=1,t}_convertToEsriFieldType(e){return e}_initialiseFeatureSet(){const e={};let t=!1,n=1;const r=this._parent?this._parent.getFieldsIndex():new k([]);for(this.objectIdField="ROW__ID",this.globalIdField="";!1===t;){let e=!1;for(let t=0;t<this._config.groupbyfields.length;t++)if(this._config.groupbyfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}if(!1===e)for(let t=0;t<this._config.statsfields.length;t++)if(this._config.statsfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}!1===e?t=!0:(this.objectIdField="ROW__ID"+n.toString(),n++)}for(const i of this._config.statsfields){const e=new b;e.field=i.name,e.tofieldname=i.name,e.workingexpr=i.expression instanceof I?i.expression:I.create(i.expression,r),e.typeofstat=j(i.statistic),this._decodedStatsfield.push(e)}this._decodedGroupbyfield=[];for(const i of this._config.groupbyfields){const e={name:i.name,singlefield:null,tofieldname:i.name,expression:i.expression instanceof I?i.expression:I.create(i.expression,r)};this._decodedGroupbyfield.push(e)}if(null!==this._parent){this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField="";for(const t of this._parent.fields)e[t.name.toUpperCase()]=1;this.types=null}else this.geometryType=f.point,this.typeIdField="",this.types=null,this.spatialReference=new S({wkid:4326});this.fields=[];const a=new b;a.field=this._nextUniqueName(e),a.tofieldname=this.objectIdField,a.workingexpr=I.create(this._parent.objectIdField,this._parent.getFieldsIndex()),a.typeofstat="MIN",this._decodedStatsfield.push(a);for(const s of this._decodedGroupbyfield){const t=new x;if(s.name=this._nextUniqueName(e),t.name=s.tofieldname,t.alias=t.name,h(s.expression)){const e=this._parent.getField(p(s.expression,c.Standardised));if(!e)throw new D(A.AggregationFieldNotFound);s.name=e.name,s.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),t.type=e.type}else{t.type=this._convertToEsriFieldType(g(s.expression,this._parent.fields));const e=new x;e.name=s.name,e.alias=e.name,this.phsyicalgroupbyfields.push(s.name),this._adaptedFields.push(new i(e,s.expression)),this._candosimplegroupby=!1}this.fields.push(t)}if(this._adaptedFields.length>0)for(const i of this._parent.fields)this._adaptedFields.push(new s(i));for(let i=0;i<this._decodedStatsfield.length;i++){const t=new x;let s=null;const n=this._decodedStatsfield[i];n.field=this._nextUniqueName(e),n.tofieldname===this.objectIdField&&(this._internalObjectIdField=n.field),t.name=n.tofieldname,t.alias=t.name;const r=null!==n.workingexpr&&h(n.workingexpr)?p(n.workingexpr,c.Standardised):"";switch(this._decodedStatsfield[i].typeofstat){case"SUM":if(""!==r){if(s=this._parent.getField(r),!s)throw new D(A.AggregationFieldNotFound);t.type=s.type}else t.type="double";break;case"MIN":case"MAX":if(""!==r){if(s=this._parent.getField(r),!s)throw new D(A.AggregationFieldNotFound);t.type=s.type}else t.type="double";break;case"COUNT":t.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==r&&(s=this._parent.getField(r),!s))throw new D(A.AggregationFieldNotFound);t.type="double"}this.fields.push(t)}}async _canDoAggregates(){return!1}async _getFeatures(e,t,i,s){-1!==t&&this._featureCache[t];const n=this._maxQuery;return!0===this._checkIfNeedToExpandKnownPage(e,n)?(await this._expandPagedSet(e,n,0,0,s),this._getFeatures(e,t,i,s)):"success"}async _getFilteredSet(e,t,i,s,o){if(""!==e)return new l([],[],!0,null);let u=null;const f={ordered:!1,nowhereclause:!1};if(await this._ensureLoaded(),null!==i)for(let n=0;n<this._decodedStatsfield.length;n++)if(!0===_(i,this._decodedStatsfield[n].tofieldname)){f.nowhereclause=!0,i=null;break}if(null!==s){f.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===s.scanForField(this._decodedStatsfield[e].tofieldname)){s=null,f.ordered=!1;break}if(null!==s)for(const e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===s.scanForField(e.tofieldname)){s=null,f.ordered=!1;break}}if(!1!==this._candosimplegroupby&&await this._parent._canDoAggregates(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,null)){let e=null;i&&(e=this._reformulateWhereClauseWithoutGroupByFields(i));let t=null;s&&(t=this._reformulateOrderClauseWithoutGroupByFields(s));const n=await this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField);return this._checkCancelled(o),u=!0===f.nowhereclause?new l(n._candidates.slice(0).concat(n._known.slice(0)),[],!0===f.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)):new l(n._candidates.slice(0),n._known.slice(0),!0===f.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)),u}let c=this._parent;if(this._adaptedFields.length>0&&(c=new n({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===f.nowhereclause)u=new l(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:c,orderbyclause:new d(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=c;if(null!==i){let t=null;i&&(t=this._reformulateWhereClauseWithoutGroupByFields(i)),e=new r({parentfeatureset:e,whereclause:t})}u=new l(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:e,orderbyclause:new d(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return u}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=m(e,t.tofieldname,p(t.workingexpr,c.Standardised),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=m(e,t.tofieldname,p(t.expression,c.Standardised),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){const t=[];for(const i of this._decodedGroupbyfield)i.tofieldname!==i.name&&t.push({field:i.tofieldname,newfield:i.name});return t.length>0?e.replaceFields(t):e}_clonePageDefinition(e){return null===e?null:!0===e.aggregatefeaturesetpagedefinition?{aggregatefeaturesetpagedefinition:!0,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,internal:e.internal}:this._parent._clonePageDefinition(e)}async _refineSetBlock(e,t,i){if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQuery))return await this._expandPagedSet(e,this._maxQuery,0,0,i),this._refineSetBlock(e,t,i);this._checkCancelled(i);const s=e._candidates.length;this._refineKnowns(e,t);e._candidates.length;return e._candidates.length,e}_expandPagedSet(e,t,i,s,n){return this._expandPagedSetFeatureSet(e,t,i,s,n)}async _getPhysicalPage(t,i,s){if(!0===t.pagesDefinition.aggregatefeaturesetpagedefinition)return this._sequentialGetPhysicalItem(t,t.pagesDefinition.resultRecordCount,s,[]);const n=await this._getAgregagtePhysicalPage(t,i,s);for(const r of n){const t={geometry:r.geometry,attributes:{}},i={};for(const e in r.attributes)i[e.toLowerCase()]=r.attributes[e];for(const e of this._decodedGroupbyfield)t.attributes[e.tofieldname]=i[e.name.toLowerCase()];for(const e of this._decodedStatsfield)t.attributes[e.tofieldname]=i[e.field.toLowerCase()];this._featureCache[t.attributes[this.objectIdField]]=new e(t)}return n.length}_sequentialGetPhysicalItem(e,t,i,s){return new Promise(((n,r)=>{null===e.pagesDefinition.internal.iterator&&(e.pagesDefinition.internal.iterator=e.pagesDefinition.internal.subfeatureset.iterator(i)),!0===e.pagesDefinition.internal.fullyResolved||0===t?n(s.length):this._nextAggregateItem(e,t,i,s,(r=>{null===r?n(s.length):(t-=1,n(this._sequentialGetPhysicalItem(e,t,i,s)))}),r)}))}_nextAggregateItem(e,i,s,n,r,a){try{t(e.pagesDefinition.internal.iterator.next()).then((t=>{if(null===t)if(null!==e.pagesDefinition.internal.workingItem){const t=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);n.push(t),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(t.attributes[this.objectIdField]),e.pagesDefinition.internal.fullyResolved=!0,r(null)}else e.pagesDefinition.internal.fullyResolved=!0,r(null);else{const o=this._generateAggregateHash(t);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[t],id:o};else{if(o!==e.pagesDefinition.internal.workingItem.id){const s=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);return n.push(s),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(s.attributes[this.objectIdField]),i-=1,e.pagesDefinition.internal.workingItem={features:[t],id:o},void r(s)}e.pagesDefinition.internal.workingItem.features.push(t)}this._nextAggregateItem(e,i,s,n,r,a)}}),a)}catch(o){a(o)}}_calculateFieldStat(e,t,i){const s=[];for(let n=0;n<e.features.length;n++)if(null!==t.workingexpr){const i=t.workingexpr.calculateValue(e.features[n]);null!==i&&s.push(i)}else s.push(null);switch(t.typeofstat){case"MIN":i.attributes[t.tofieldname]=y("min",s,-1);break;case"MAX":i.attributes[t.tofieldname]=y("max",s,-1);break;case"SUM":i.attributes[t.tofieldname]=y("sum",s,-1);break;case"COUNT":i.attributes[t.tofieldname]=s.length;break;case"VAR":i.attributes[t.tofieldname]=y("var",s,-1);break;case"STDDEV":i.attributes[t.tofieldname]=y("stddev",s,-1);break;case"AVG":i.attributes[t.tofieldname]=y("avg",s,-1)}return!0}_calculateAndAppendAggregateItem(t){const i={attributes:{},geometry:null};for(const e of this._decodedGroupbyfield){const s=e.singlefield?t.features[0].attributes[e.singlefield]:e.expression.calculateValue(t.features[0]);i.attributes[e.tofieldname]=s}for(const e of this._decodedStatsfield)this._calculateFieldStat(t,e,i);const s=[];for(let e=0;e<this._decodedStatsfield.length;e++)s.push(this._calculateFieldStat(t,this._decodedStatsfield[e],i));return this._featureCache[i.attributes[this.objectIdField]]=new e({attributes:i.attributes,geometry:i.geometry}),i}_generateAggregateHash(e){let t="";for(const i of this._decodedGroupbyfield){const s=i.singlefield?e.attributes[i.singlefield]:i.expression.calculateValue(e);t+=null==s?":":":"+s.toString()}return w(t,F.String)}async _stat(){return{calculated:!1}}async getFeatureByObjectId(){return null}static registerAction(){o._featuresetFunctions.groupby=function(e,t){return new C({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}export{C as default};
5
+ import e from"../../../Graphic.js";import{$ as t}from"../../../chunks/languageUtils.js";import{SqlExpressionAdapted as i,OriginalField as s,AdaptedFeatureSet as n}from"./Adapted.js";import r from"./AttributeFilter.js";import a from"./OrderBy.js";import o from"../support/FeatureSet.js";import l from"../support/IdSet.js";import d from"../support/OrderbyClause.js";import{IdState as u,layerGeometryEsriConstants as f,FeatureServiceDatabaseType as c}from"../support/shared.js";import{isSingleField as h,toWhereClause as p,predictType as g,scanForField as _,reformulateWithoutField as m}from"../support/sqlUtils.js";import{calculateStat as y}from"../support/stats.js";import b from"../support/StatsField.js";import{createMD5Hash as w,outputTypes as F}from"../../../core/MD5.js";import{WhereClause as I}from"../../../core/sql/WhereClause.js";import S from"../../../geometry/SpatialReference.js";import x from"../../../layers/support/Field.js";import k from"../../../layers/support/FieldsIndex.js";import{FeatureSetError as D,FeatureSetErrorCodes as A}from"../support/errorsupport.js";function j(e){if(!e)return"COUNT";switch(e.toLowerCase()){case"max":return"MAX";case"var":case"variance":return"VAR";case"avg":case"average":case"mean":return"AVG";case"min":return"MIN";case"sum":return"SUM";case"stdev":case"stddev":return"STDDEV";case"count":return"COUNT"}return"COUNT"}class C extends o{constructor(e){super(e),this._decodedStatsfield=[],this._decodedGroupbyfield=[],this._candosimplegroupby=!0,this.phsyicalgroupbyfields=[],this.objectIdField="ROW__ID",this._internalObjectIdField="ROW__ID",this._adaptedFields=[],this.declaredClass="esri.arcade.featureset.actions.Aggregate",this._uniqueIds=1,this._maxQuery=10,this._maxProcessing=10,this._parent=e.parentfeatureset,this._config=e}isTable(){return!0}async _getSet(e){if(null===this._wset){const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,this._wset}return this._wset}_isInFeatureSet(){return u.InFeatureSet}_nextUniqueName(e){for(;1===e["T"+this._uniqueIds.toString()];)this._uniqueIds++;const t="T"+this._uniqueIds.toString();return e[t]=1,t}_convertToEsriFieldType(e){return e}_initialiseFeatureSet(){const e={};let t=!1,n=1;const r=this._parent?this._parent.getFieldsIndex():new k([]);for(this.objectIdField="ROW__ID",this.globalIdField="";!1===t;){let e=!1;for(let t=0;t<this._config.groupbyfields.length;t++)if(this._config.groupbyfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}if(!1===e)for(let t=0;t<this._config.statsfields.length;t++)if(this._config.statsfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}!1===e?t=!0:(this.objectIdField="ROW__ID"+n.toString(),n++)}for(const i of this._config.statsfields){const e=new b;e.field=i.name,e.tofieldname=i.name,e.workingexpr=i.expression instanceof I?i.expression:I.create(i.expression,r),e.typeofstat=j(i.statistic),this._decodedStatsfield.push(e)}this._decodedGroupbyfield=[];for(const i of this._config.groupbyfields){const e={name:i.name,singlefield:null,tofieldname:i.name,expression:i.expression instanceof I?i.expression:I.create(i.expression,r)};this._decodedGroupbyfield.push(e)}if(null!==this._parent){this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField="";for(const t of this._parent.fields)e[t.name.toUpperCase()]=1;this.types=null}else this.geometryType=f.point,this.typeIdField="",this.types=null,this.spatialReference=new S({wkid:4326});this.fields=[];const a=new b;a.field=this._nextUniqueName(e),a.tofieldname=this.objectIdField,a.workingexpr=I.create(this._parent.objectIdField,this._parent.getFieldsIndex()),a.typeofstat="MIN",this._decodedStatsfield.push(a);for(const s of this._decodedGroupbyfield){const t=new x;if(s.name=this._nextUniqueName(e),t.name=s.tofieldname,t.alias=t.name,h(s.expression)){const e=this._parent.getField(p(s.expression,c.Standardised));if(!e)throw new D(A.AggregationFieldNotFound);s.name=e.name,s.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),t.type=e.type}else{t.type=this._convertToEsriFieldType(g(s.expression,this._parent.fields));const e=new x;e.name=s.name,e.alias=e.name,this.phsyicalgroupbyfields.push(s.name),this._adaptedFields.push(new i(e,s.expression)),this._candosimplegroupby=!1}this.fields.push(t)}if(this._adaptedFields.length>0)for(const i of this._parent.fields)this._adaptedFields.push(new s(i));for(let i=0;i<this._decodedStatsfield.length;i++){const t=new x;let s=null;const n=this._decodedStatsfield[i];n.field=this._nextUniqueName(e),n.tofieldname===this.objectIdField&&(this._internalObjectIdField=n.field),t.name=n.tofieldname,t.alias=t.name;const r=null!==n.workingexpr&&h(n.workingexpr)?p(n.workingexpr,c.Standardised):"";switch(this._decodedStatsfield[i].typeofstat){case"SUM":if(""!==r){if(s=this._parent.getField(r),!s)throw new D(A.AggregationFieldNotFound);t.type=s.type}else t.type="double";break;case"MIN":case"MAX":if(""!==r){if(s=this._parent.getField(r),!s)throw new D(A.AggregationFieldNotFound);t.type=s.type}else t.type="double";break;case"COUNT":t.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==r&&(s=this._parent.getField(r),!s))throw new D(A.AggregationFieldNotFound);t.type="double"}this.fields.push(t)}}async _canDoAggregates(){return!1}async _getFeatures(e,t,i,s){-1!==t&&this._featureCache[t];const n=this._maxQuery;return!0===this._checkIfNeedToExpandKnownPage(e,n)?(await this._expandPagedSet(e,n,0,0,s),this._getFeatures(e,t,i,s)):"success"}async _getFilteredSet(e,t,i,s,o){if(""!==e)return new l([],[],!0,null);let u=null;const f={ordered:!1,nowhereclause:!1};if(await this._ensureLoaded(),null!==i)for(let n=0;n<this._decodedStatsfield.length;n++)if(!0===_(i,this._decodedStatsfield[n].tofieldname)){f.nowhereclause=!0,i=null;break}if(null!==s){f.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===s.scanForField(this._decodedStatsfield[e].tofieldname)){s=null,f.ordered=!1;break}if(null!==s)for(const e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===s.scanForField(e.tofieldname)){s=null,f.ordered=!1;break}}if(!1!==this._candosimplegroupby&&await this._parent._canDoAggregates(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,null)){let e=null;i&&(e=this._reformulateWhereClauseWithoutGroupByFields(i));let t=null;s&&(t=this._reformulateOrderClauseWithoutGroupByFields(s));const n=await this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField);return this._checkCancelled(o),u=!0===f.nowhereclause?new l(n._candidates.slice(0).concat(n._known.slice(0)),[],!0===f.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)):new l(n._candidates.slice(0),n._known.slice(0),!0===f.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)),u}let c=this._parent;if(this._adaptedFields.length>0&&(c=new n({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===f.nowhereclause)u=new l(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:c,orderbyclause:new d(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=c;if(null!==i){let t=null;i&&(t=this._reformulateWhereClauseWithoutGroupByFields(i)),e=new r({parentfeatureset:e,whereclause:t})}u=new l(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:e,orderbyclause:new d(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return u}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=m(e,t.tofieldname,p(t.workingexpr,c.Standardised),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=m(e,t.tofieldname,p(t.expression,c.Standardised),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){const t=[];for(const i of this._decodedGroupbyfield)i.tofieldname!==i.name&&t.push({field:i.tofieldname,newfield:i.name});return t.length>0?e.replaceFields(t):e}_clonePageDefinition(e){return null===e?null:!0===e.aggregatefeaturesetpagedefinition?{aggregatefeaturesetpagedefinition:!0,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,internal:e.internal}:this._parent._clonePageDefinition(e)}async _refineSetBlock(e,t,i){if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQuery))return await this._expandPagedSet(e,this._maxQuery,0,0,i),this._refineSetBlock(e,t,i);this._checkCancelled(i);const s=e._candidates.length;this._refineKnowns(e,t);e._candidates.length;return e._candidates.length,e}_expandPagedSet(e,t,i,s,n){return this._expandPagedSetFeatureSet(e,t,i,s,n)}async _getPhysicalPage(t,i,s){if(!0===t.pagesDefinition.aggregatefeaturesetpagedefinition)return this._sequentialGetPhysicalItem(t,t.pagesDefinition.resultRecordCount,s,[]);const n=await this._getAgregagtePhysicalPage(t,i,s);for(const r of n){const t={geometry:r.geometry,attributes:{}},i={};for(const e in r.attributes)i[e.toLowerCase()]=r.attributes[e];for(const e of this._decodedGroupbyfield)t.attributes[e.tofieldname]=i[e.name.toLowerCase()];for(const e of this._decodedStatsfield)t.attributes[e.tofieldname]=i[e.field.toLowerCase()];this._featureCache[t.attributes[this.objectIdField]]=new e(t)}return n.length}_sequentialGetPhysicalItem(e,t,i,s){return new Promise(((n,r)=>{null===e.pagesDefinition.internal.iterator&&(e.pagesDefinition.internal.iterator=e.pagesDefinition.internal.subfeatureset.iterator(i)),!0===e.pagesDefinition.internal.fullyResolved||0===t?n(s.length):this._nextAggregateItem(e,t,i,s,(r=>{null===r?n(s.length):(t-=1,n(this._sequentialGetPhysicalItem(e,t,i,s)))}),r)}))}_nextAggregateItem(e,i,s,n,r,a){try{t(e.pagesDefinition.internal.iterator.next()).then((t=>{if(null===t)if(null!==e.pagesDefinition.internal.workingItem){const t=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);n.push(t),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(t.attributes[this.objectIdField]),e.pagesDefinition.internal.fullyResolved=!0,r(null)}else e.pagesDefinition.internal.fullyResolved=!0,r(null);else{const o=this._generateAggregateHash(t);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[t],id:o};else{if(o!==e.pagesDefinition.internal.workingItem.id){const s=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);return n.push(s),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(s.attributes[this.objectIdField]),i-=1,e.pagesDefinition.internal.workingItem={features:[t],id:o},void r(s)}e.pagesDefinition.internal.workingItem.features.push(t)}this._nextAggregateItem(e,i,s,n,r,a)}}),a)}catch(o){a(o)}}_calculateFieldStat(e,t,i){const s=[];for(let n=0;n<e.features.length;n++)if(null!==t.workingexpr){const i=t.workingexpr.calculateValue(e.features[n]);null!==i&&s.push(i)}else s.push(null);switch(t.typeofstat){case"MIN":i.attributes[t.tofieldname]=y("min",s,-1);break;case"MAX":i.attributes[t.tofieldname]=y("max",s,-1);break;case"SUM":i.attributes[t.tofieldname]=y("sum",s,-1);break;case"COUNT":i.attributes[t.tofieldname]=s.length;break;case"VAR":i.attributes[t.tofieldname]=y("var",s,-1);break;case"STDDEV":i.attributes[t.tofieldname]=y("stddev",s,-1);break;case"AVG":i.attributes[t.tofieldname]=y("avg",s,-1)}return!0}_calculateAndAppendAggregateItem(t){const i={attributes:{},geometry:null};for(const e of this._decodedGroupbyfield){const s=e.singlefield?t.features[0].attributes[e.singlefield]:e.expression.calculateValue(t.features[0]);i.attributes[e.tofieldname]=s}for(const e of this._decodedStatsfield)this._calculateFieldStat(t,e,i);const s=[];for(let e=0;e<this._decodedStatsfield.length;e++)s.push(this._calculateFieldStat(t,this._decodedStatsfield[e],i));return this._featureCache[i.attributes[this.objectIdField]]=new e({attributes:i.attributes,geometry:i.geometry}),i}_generateAggregateHash(e){let t="";for(const i of this._decodedGroupbyfield){const s=i.singlefield?e.attributes[i.singlefield]:i.expression.calculateValue(e);t+=null==s?":":":"+s.toString()}return w(t,F.String)}async _stat(){return{calculated:!1}}async getFeatureByObjectId(){return null}static registerAction(){o._featuresetFunctions.groupby=function(e,t){return new C({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}export{C as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{Z as e}from"../../../chunks/languageUtils.js";import{FeatureSetError as t,FeatureSetErrorCodes as r}from"../support/errorsupport.js";import n from"../support/FeatureSet.js";import s from"../support/IdSet.js";import i from"../support/OrderbyClause.js";class a extends n{constructor(e){super(e),this._orderbyclause=null,this.declaredClass="esri.arcade.featureset.actions.OrderBy",this._maxProcessing=100,this._orderbyclause=e.orderbyclause,this._parent=e.parentfeatureset}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,this._orderbyclause,e);return this._checkCancelled(e),this._wset=t,this._wset}return this._wset}async manualOrderSet(e,t){const r=await this.getIdColumnDictionary(e,[],-1,t);this._orderbyclause?.order(r);const n=new s([],[],!0,null);for(let s=0;s<r.length;s++)n._known.push(r[s].id);return n}async getIdColumnDictionary(t,r,n,s){if(n<t._known.length-1){const i=this._maxQueryRate();if("GETPAGES"===t._known[n+1])return await e(this._parent._expandPagedSet(t,i,0,0,s)),this.getIdColumnDictionary(t,r,n,s);let a=n+1;const o=[];for(;a<t._known.length&&"GETPAGES"!==t._known[a];)o.push(t._known[a]),a++;n+=o.length;const u=await e(this._parent._getFeatureBatch(o,s));this._checkCancelled(s);for(const e of u)r.push({id:e.attributes[this.objectIdField],feature:e});return this.getIdColumnDictionary(t,r,n,s)}return t._candidates.length>0?(await e(this._refineSetBlock(t,this._maxProcessingRate(),s)),this._checkCancelled(s),this.getIdColumnDictionary(t,r,n,s)):r}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(e,t,r,n){return this._parent._getFeatures(e,t,r,n)}_featureFromCache(e){if(void 0===this._featureCache[e]){const t=this._parent._featureFromCache(e);if(void 0===t)return;return null===t?null:(this._featureCache[e]=t,t)}return this._featureCache[e]}async _fetchAndRefineFeatures(){throw new t(r.NeverReach)}async _getFilteredSet(e,t,r,n,i){await this._ensureLoaded();const a=await this._parent._getFilteredSet(e,t,r,null===n?this._orderbyclause:n,i);this._checkCancelled(i);const o=new s(a._candidates.slice(0),a._known.slice(0),a._ordered,this._clonePageDefinition(a.pagesDefinition));let u=!0;if(a._candidates.length>0&&(u=!1),!1===o._ordered){let e=await this.manualOrderSet(o,i);return!1===u&&(null===t&&null===r||(e=new s(e._candidates.slice(0).concat(e._known.slice(0)),[],e._ordered,this._clonePageDefinition(e.pagesDefinition)))),e}return o}static registerAction(){n._featuresetFunctions.orderBy=function(e){return""===e?this:new a({parentfeatureset:this,orderbyclause:new i(e)})}}}export{a as default};
5
+ import{$ as e}from"../../../chunks/languageUtils.js";import{FeatureSetError as t,FeatureSetErrorCodes as r}from"../support/errorsupport.js";import n from"../support/FeatureSet.js";import s from"../support/IdSet.js";import i from"../support/OrderbyClause.js";class a extends n{constructor(e){super(e),this._orderbyclause=null,this.declaredClass="esri.arcade.featureset.actions.OrderBy",this._maxProcessing=100,this._orderbyclause=e.orderbyclause,this._parent=e.parentfeatureset}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,this._orderbyclause,e);return this._checkCancelled(e),this._wset=t,this._wset}return this._wset}async manualOrderSet(e,t){const r=await this.getIdColumnDictionary(e,[],-1,t);this._orderbyclause?.order(r);const n=new s([],[],!0,null);for(let s=0;s<r.length;s++)n._known.push(r[s].id);return n}async getIdColumnDictionary(t,r,n,s){if(n<t._known.length-1){const i=this._maxQueryRate();if("GETPAGES"===t._known[n+1])return await e(this._parent._expandPagedSet(t,i,0,0,s)),this.getIdColumnDictionary(t,r,n,s);let a=n+1;const o=[];for(;a<t._known.length&&"GETPAGES"!==t._known[a];)o.push(t._known[a]),a++;n+=o.length;const u=await e(this._parent._getFeatureBatch(o,s));this._checkCancelled(s);for(const e of u)r.push({id:e.attributes[this.objectIdField],feature:e});return this.getIdColumnDictionary(t,r,n,s)}return t._candidates.length>0?(await e(this._refineSetBlock(t,this._maxProcessingRate(),s)),this._checkCancelled(s),this.getIdColumnDictionary(t,r,n,s)):r}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(e,t,r,n){return this._parent._getFeatures(e,t,r,n)}_featureFromCache(e){if(void 0===this._featureCache[e]){const t=this._parent._featureFromCache(e);if(void 0===t)return;return null===t?null:(this._featureCache[e]=t,t)}return this._featureCache[e]}async _fetchAndRefineFeatures(){throw new t(r.NeverReach)}async _getFilteredSet(e,t,r,n,i){await this._ensureLoaded();const a=await this._parent._getFilteredSet(e,t,r,null===n?this._orderbyclause:n,i);this._checkCancelled(i);const o=new s(a._candidates.slice(0),a._known.slice(0),a._ordered,this._clonePageDefinition(a.pagesDefinition));let u=!0;if(a._candidates.length>0&&(u=!1),!1===o._ordered){let e=await this.manualOrderSet(o,i);return!1===u&&(null===t&&null===r||(e=new s(e._candidates.slice(0).concat(e._known.slice(0)),[],e._ordered,this._clonePageDefinition(e.pagesDefinition)))),e}return o}static registerAction(){n._featuresetFunctions.orderBy=function(e){return""===e?this:new a({parentfeatureset:this,orderbyclause:new i(e)})}}}export{a as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as e}from"../ArcadeDate.js";import t from"../ArcadePortal.js";import n from"../Dictionary.js";import{ArcadeExecutionError as i,ExecutionErrorCodes as a}from"../executionError.js";import r from"../Feature.js";import s from"../featureSetCollection.js";import{convertToFeatureSet as l,constructFeatureSetFromPortalItem as o,constructFeatureSet as f,constructFeatureSetFromRelationship as u,constructFeatureSetFromUrl as c,constructAssociationMetaDataFeatureSetFromUrl as d}from"../featureSetUtils.js";import m from"../ImmutableArray.js";import{C as p,r as y,c as h,j as g,l as w,G as I,k as F,D,h as E,m as b,p as x,o as A,i as N,g as S,_ as T,P as L}from"../../chunks/languageUtils.js";import{getPortal as $}from"../portalUtils.js";import{SqlExpressionAdapted as v,StringToCodeAdapted as P,FieldRename as R,AdaptedFeatureSet as j,OriginalField as C}from"../featureset/actions/Adapted.js";import M from"../featureset/actions/AttributeFilter.js";import O from"../featureset/actions/OrderBy.js";import k from"../featureset/actions/Top.js";import z from"../featureset/sources/Empty.js";import H from"../featureset/sources/FeatureLayerMemory.js";import Z from"../featureset/support/OrderbyClause.js";import{cloneField as G}from"../featureset/support/shared.js";import{isSingleField as _}from"../featureset/support/sqlUtils.js";import{calculateStat as W}from"./fieldStats.js";import{isPromiseLike as U}from"../../core/promiseUtils.js";import{WhereClause as B}from"../../core/sql/WhereClause.js";import q from"../../layers/FeatureLayer.js";import V from"../../layers/support/Field.js";import Q from"../../portal/Portal.js";function J(e,t,n,i){if(1===i.length){if(b(i[0]))return W(e,i[0],-1);if(A(i[0]))return W(e,i[0].toArray(),-1)}return W(e,i,-1)}async function K(e,t,n){const i=e.getVariables();if(i.length>0){const a=[];for(let e=0;e<i.length;e++){const r={name:i[e]};a.push(await t.evaluateIdentifier(n,r))}const r={};for(let e=0;e<i.length;e++)r[i[e]]=a[e];return e.parameters=r,e}return e}function Y(e,t,n=null){for(const i in e)if(i.toLowerCase()===t.toLowerCase())return e[i];return n}function X(e){if(null===e)return null;const t={type:Y(e,"type",""),name:Y(e,"name","")};if("range"===t.type)t.range=Y(e,"range",[]);else{t.codedValues=[];for(const n of Y(e,"codedValues",[]))t.codedValues.push({name:Y(n,"name",""),code:Y(n,"code",null)})}return t}function ee(e){if(null===e)return null;const t={},n=Y(e,"wkt",null);null!==n&&(t.wkt=n);const i=Y(e,"wkid",null);return null!==i&&(t.wkid=i),t}function te(e){if(null===e)return null;const t={hasZ:Y(e,"hasz",!1),hasM:Y(e,"hasm",!1)},n=Y(e,"spatialreference",null);n&&(t.spatialReference=ee(n));const i=Y(e,"x",null);if(null!==i)return t.x=i,t.y=Y(e,"y",null),t;const a=Y(e,"rings",null);if(null!==a)return t.rings=a,t;const r=Y(e,"paths",null);if(null!==r)return t.paths=r,t;const s=Y(e,"points",null);if(null!==s)return t.points=s,t;for(const l of["xmin","xmax","ymin","ymax","zmin","zmax","mmin","mmax"]){const n=Y(e,l,null);null!==n&&(t[l]=n)}return t}function ne(e,t){for(const n of t)if(n===e)return!0;return!1}function ie(e){return!!e.layerDefinition&&(!!e.featureSet&&(!1!==ne(e.layerDefinition.geometryType,["",null,"esriGeometryNull","esriGeometryPoint","esriGeometryPolyline","esriGeometryPolygon","esriGeometryMultipoint","esriGeometryEnvelope"])&&(!1!==b(e.layerDefinition.fields)&&!1!==b(e.featureSet.features))))}function ae(W){"async"===W.mode&&(W.functions.timezone=function(t,r){return W.standardFunctionAsync(t,r,(async(s,l,o)=>{if(p(o,1,2,t,r),y(o[0])){if(await o[0].load(),1===o.length||null===o[1])return o[0].dateTimeReferenceFieldIndex.layerDateFieldsTimeZone;if(!(o[1]instanceof n)||!1===o[1].hasField("type"))throw new i(t,a.InvalidParameter,r);const e=o[1].field("type");if(!1===h(e))throw new i(t,a.InvalidParameter,r);switch(g(e).toLowerCase()){case"preferredtimezone":return o[0].dateTimeReferenceFieldIndex.layerPreferredTimeZone;case"editfieldsinfo":return o[0].dateTimeReferenceFieldIndex.layerEditFieldsTimeZone;case"timeinfo":return o[0].dateTimeReferenceFieldIndex.layerTimeInfoTimeZone;case"field":if(o[1].hasField("fieldname")&&h(o[1].field("fieldname")))return o[0].dateTimeReferenceFieldIndex.fieldTimeZone(g(o[1].field("fieldname")))}throw new i(t,a.InvalidParameter,r)}const f=w(o[0],I(t));if(null===f)return null;const u=f.timeZone;return"system"===u?e.systemTimeZoneCanonicalName:u}))},W.functions.sqltimestamp=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{p(s,1,3,e,t);const l=s[0];if(F(l)){if(1===s.length)return l.toSQLString();if(2===s.length)return l.changeTimeZone(g(s[1])).toSQLString();throw new i(e,a.InvalidParameter,t)}if(y(l)){if(3!==s.length)throw new i(e,a.InvalidParameter,t);await l.load();const n=g(s[1]);if(!1===F(s[2]))throw new i(e,a.InvalidParameter,t);const r=l.fieldTimeZone(n);return null===r?s[2].toSQLString():s[2].changeTimeZone(r).toSQLString()}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"sqltimestamp",min:2,max:4}),W.functions.featuresetbyid=function(e,t){return W.standardFunctionAsync(e,t,((n,r,l)=>{if(p(l,2,4,e,t),l[0]instanceof s){const n=g(l[1]);let r=D(l[2],null);const s=E(D(l[3],!0));if(null===r&&(r=["*"]),!1===b(r))throw new i(e,a.InvalidParameter,t);return l[0].featureSetById(n,s,r)}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"featuresetbyid",min:2,max:4}),W.functions.getfeatureset=function(e,t){return W.standardFunctionAsync(e,t,((n,r,s)=>{if(p(s,1,2,e,t),x(s[0])){let t=D(s[1],"datasource");return null===t&&(t="datasource"),t=g(t).toLowerCase(),l(s[0].fullSchema(),t,e.lrucache,e.interceptor,e.spatialReference)}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"getfeatureset",min:1,max:2}),W.functions.featuresetbyportalitem=function(e,n){return W.standardFunctionAsync(e,n,((r,s,l)=>{if(p(l,2,5,e,n),null===l[0])throw new i(e,a.PortalRequired,n);if(l[0]instanceof t){const t=g(l[1]),r=g(l[2]);let s=D(l[3],null);const f=E(D(l[4],!0));if(null===s&&(s=["*"]),!1===b(s))throw new i(e,a.InvalidParameter,n);let u=null;return u=e.services&&e.services.portal?e.services.portal:Q.getDefault(),u=$(l[0],u),o(t,r,e.spatialReference,s,f,u,e.lrucache,e.interceptor)}if(!1===h(l[0]))throw new i(e,a.PortalRequired,n);const f=g(l[0]),u=g(l[1]);let c=D(l[2],null);const d=E(D(l[3],!0));if(null===c&&(c=["*"]),!1===b(c))throw new i(e,a.InvalidParameter,n);return o(f,u,e.spatialReference,c,d,e.services?.portal??Q.getDefault(),e.lrucache,e.interceptor)}))},W.signatures.push({name:"featuresetbyportalitem",min:2,max:5}),W.functions.featuresetbyname=function(e,t){return W.standardFunctionAsync(e,t,((n,r,l)=>{if(p(l,2,4,e,t),l[0]instanceof s){const n=g(l[1]);let r=D(l[2],null);const s=E(D(l[3],!0));if(null===r&&(r=["*"]),!1===b(r))throw new i(e,a.InvalidParameter,t);return l[0].featureSetByName(n,s,r)}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"featuresetbyname",min:2,max:4}),W.functions.featureset=function(e,t){return W.standardFunction(e,t,((r,s,l)=>{p(l,1,1,e,t);let o=l[0];const f={layerDefinition:{geometryType:"",objectIdField:"",hasM:!1,hasZ:!1,globalIdField:"",typeIdField:"",fields:[]},featureSet:{geometryType:"",features:[]}};if(h(o))o=JSON.parse(o),void 0!==o.layerDefinition?(f.layerDefinition=o.layerDefinition,f.featureSet=o.featureSet,o.layerDefinition.spatialReference&&(f.layerDefinition.spatialReference=o.layerDefinition.spatialReference)):(f.featureSet.features=o.features,f.featureSet.geometryType=o.geometryType,f.layerDefinition.geometryType=f.featureSet.geometryType,f.layerDefinition.objectIdField=o.objectIdFieldName??"",f.layerDefinition.typeIdField=o.typeIdFieldName,f.layerDefinition.globalIdField=o.globalIdFieldName,f.layerDefinition.fields=o.fields,o.spatialReference&&(f.layerDefinition.spatialReference=o.spatialReference));else{if(!(l[0]instanceof n))throw new i(e,a.InvalidParameter,t);{o=JSON.parse(l[0].castToText(!0));const e=Y(o,"layerdefinition");if(null!==e){f.layerDefinition.geometryType=Y(e,"geometrytype",""),f.featureSet.geometryType=f.layerDefinition.geometryType,f.layerDefinition.globalIdField=Y(e,"globalidfield",""),f.layerDefinition.objectIdField=Y(e,"objectidfield",""),f.layerDefinition.typeIdField=Y(e,"typeidfield",""),f.layerDefinition.hasZ=!0===Y(e,"hasz",!1),f.layerDefinition.hasM=!0===Y(e,"hasm",!1);const t=Y(e,"spatialreference",null);t&&(f.layerDefinition.spatialReference=ee(t));for(const i of Y(e,"fields",[])){const e={name:Y(i,"name",""),alias:Y(i,"alias",""),type:Y(i,"type",""),nullable:Y(i,"nullable",!0),editable:Y(i,"editable",!0),length:Y(i,"length",null),domain:X(Y(i,"domain"))};f.layerDefinition.fields.push(e)}const n=Y(o,"featureset",null);if(n){const e={};for(const t of f.layerDefinition.fields)e[t.name.toLowerCase()]=t.name;for(const t of Y(n,"features",[])){const n={},i=Y(t,"attributes",{});for(const t in i)n[e[t.toLowerCase()]]=i[t];f.featureSet.features.push({attributes:n,geometry:te(Y(t,"geometry",null))})}}}else{f.layerDefinition.hasZ=!0===Y(o,"hasz",!1),f.layerDefinition.hasM=!0===Y(o,"hasm",!1),f.layerDefinition.geometryType=Y(o,"geometrytype",""),f.featureSet.geometryType=f.layerDefinition.geometryType,f.layerDefinition.objectIdField=Y(o,"objectidfieldname",""),f.layerDefinition.typeIdField=Y(o,"typeidfieldname","");const e=Y(o,"spatialreference",null);e&&(f.layerDefinition.spatialReference=ee(e));let t=Y(o,"fields",null);if(b(t))for(const a of t){const e={name:Y(a,"name",""),alias:Y(a,"alias",""),type:Y(a,"type",""),nullable:Y(a,"nullable",!0),editable:Y(a,"editable",!0),length:Y(a,"length",null),domain:X(Y(a,"domain"))};f.layerDefinition.fields.push(e)}else t=null,f.layerDefinition.fields=t;const n={};for(const a of f.layerDefinition.fields)n[a.name.toLowerCase()]=a.name;let i=Y(o,"features",null);if(b(i))for(const a of i){const e={},t=Y(a,"attributes",{});for(const i in t)e[n[i.toLowerCase()]]=t[i];f.featureSet.features.push({attributes:e,geometry:te(Y(a,"geometry",null))})}else i=null,f.featureSet.features=i}}}if(!1===ie(f))throw new i(e,a.InvalidParameter,t);return""===(f?.layerDefinition?.geometryType||"")&&(f.layerDefinition.geometryType="esriGeometryNull"),H.create(f,e.spatialReference)}))},W.signatures.push({name:"featureset",min:1,max:1}),W.functions.filter=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{if(p(s,2,2,e,t),b(s[0])||A(s[0])){const n=[];let r=s[0];r instanceof m&&(r=r.toArray());let l=null;if(!N(s[1]))throw new i(e,a.InvalidParameter,t);l=s[1].createFunction(e);for(const e of r){const t=l(e);U(t)?!0===await t&&n.push(e):!0===t&&n.push(e)}return n}if(y(s[0])){const t=await s[0].load(),n=B.create(s[1],t.getFieldsIndex()),i=n.getVariables();if(i.length>0){const t=[];for(let n=0;n<i.length;n++){const a={name:i[n]};t.push(await W.evaluateIdentifier(e,a))}const a={};for(let e=0;e<i.length;e++)a[i[e]]=t[e];return n.parameters=a,new M({parentfeatureset:s[0],whereclause:n})}return new M({parentfeatureset:s[0],whereclause:n})}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"filter",min:2,max:2}),W.functions.orderby=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{if(p(s,2,2,e,t),y(s[0])){const e=new Z(s[1]);return new O({parentfeatureset:s[0],orderbyclause:e})}throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"orderby",min:2,max:2}),W.functions.top=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{if(p(s,2,2,e,t),y(s[0]))return new k({parentfeatureset:s[0],topnum:s[1]});if(b(s[0]))return S(s[1])>=s[0].length?s[0].slice(0):s[0].slice(0,S(s[1]));if(A(s[0]))return S(s[1])>=s[0].length()?s[0].slice(0):s[0].slice(0,S(s[1]));throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"top",min:2,max:2}),W.functions.first=function(e,t){return W.standardFunctionAsync(e,t,(async(n,i,a)=>{if(p(a,1,1,e,t),y(a[0])){const t=await a[0].first(n.abortSignal);if(null!==t){const n=r.createFromGraphicLikeObject(t.geometry,t.attributes,a[0],e.timeReference);return n._underlyingGraphic=t,n}return t}return b(a[0])?0===a[0].length?null:a[0][0]:A(a[0])?0===a[0].length()?null:a[0].get(0):null}))},W.signatures.push({name:"first",min:1,max:1}),W.functions.attachments=function(e,t){return W.standardFunctionAsync(e,t,(async(r,s,l)=>{p(l,1,2,e,t);const o={minsize:-1,maxsize:-1,types:null,returnMetadata:!1};if(l.length>1)if(l[1]instanceof n){if(l[1].hasField("minsize")&&(o.minsize=S(l[1].field("minsize"))),l[1].hasField("metadata")&&(o.returnMetadata=E(l[1].field("metadata"))),l[1].hasField("maxsize")&&(o.maxsize=S(l[1].field("maxsize"))),l[1].hasField("types")){const e=T(l[1].field("types"),!1);e.length>0&&(o.types=e)}}else if(null!==l[1])throw new i(e,a.InvalidParameter,t);if(x(l[0])){let t=l[0]._layer;return t instanceof q&&(t=f(t,e.spatialReference,["*"],!0,e.lrucache,e.interceptor)),null===t?[]:!1===y(t)?[]:(await t.load(),t.queryAttachments(l[0].field(t.objectIdField),o.minsize,o.maxsize,o.types,o.returnMetadata))}if(null===l[0])return[];throw new i(e,a.InvalidParameter,t)}))},W.signatures.push({name:"attachments",min:1,max:2}),W.functions.featuresetbyrelationshipname=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{p(s,2,4,e,t);const l=s[0],o=g(s[1]);let d=D(s[2],null);const m=E(D(s[3],!0));if(null===d&&(d=["*"]),!1===b(d))throw new i(e,a.InvalidParameter,t);if(null===s[0])return null;if(!x(s[0]))throw new i(e,a.InvalidParameter,t);let h=l._layer;if(h instanceof q&&(h=f(h,e.spatialReference,["*"],!0,e.lrucache,e.interceptor)),null===h)return null;if(!1===y(h))return null;h=await h.load();const w=h.relationshipMetaData().filter((e=>e.name===o));if(0===w.length)return null;if(void 0!==w[0].relationshipTableId&&null!==w[0].relationshipTableId&&w[0].relationshipTableId>-1)return u(h,w[0],l.field(h.objectIdField),h.spatialReference,d,m,e.lrucache,e.interceptor);let I=h.serviceUrl();if(!I)return null;I="/"===I.charAt(I.length-1)?I+w[0].relatedTableId.toString():I+"/"+w[0].relatedTableId.toString();const F=await c(I,h.spatialReference,d,m,e.lrucache,e.interceptor);await F.load();let A=F.relationshipMetaData();if(A=A.filter((e=>e.id===w[0].id)),!1===l.hasField(w[0].keyField)||null===l.field(w[0].keyField)){const e=await h.getFeatureByObjectId(l.field(h.objectIdField),[w[0].keyField]);if(e){const t=B.create(A[0].keyField+"= @id",F.getFieldsIndex());return t.parameters={id:e.attributes[w[0].keyField]},F.filter(t)}return new z({parentfeatureset:F})}const N=B.create(A[0].keyField+"= @id",F.getFieldsIndex());return N.parameters={id:l.field(w[0].keyField)},F.filter(N)}))},W.signatures.push({name:"featuresetbyrelationshipname",min:2,max:4}),W.functions.featuresetbyassociation=function(e,t){return W.standardFunctionAsync(e,t,(async(n,r,s)=>{p(s,2,3,e,t);const l=s[0],o=g(D(s[1],"")).toLowerCase(),u=h(s[2])?g(s[2]):null;if(null===s[0])return null;if(!x(s[0]))throw new i(e,a.InvalidParameter,t);let c=l._layer;if(c instanceof q&&(c=f(c,e.spatialReference,["*"],!0,e.lrucache,e.interceptor)),null===c)return null;if(!1===y(c))return null;await c.load();const m=c.serviceUrl(),w=await d(m,e.spatialReference);let I=null,F=null,E=!1;if(null!==u&&""!==u&&void 0!==u){for(const e of w.terminals)e.terminalName===u&&(F=e.terminalId);null===F&&(E=!0)}const b=w.associations.getFieldsIndex(),A=b.get("TOGLOBALID").name,N=b.get("FROMGLOBALID").name,S=b.get("TOTERMINALID").name,T=b.get("FROMTERMINALID").name,$=b.get("FROMNETWORKSOURCEID").name,M=b.get("TONETWORKSOURCEID").name,O=b.get("ASSOCIATIONTYPE").name,k=b.get("ISCONTENTVISIBLE").name,z=b.get("OBJECTID").name;for(const e of c.fields)if("global-id"===e.type){I=l.field(e.name);break}let H=null,Z=new v(new V({name:"percentalong",alias:"percentalong",type:"double"}),B.create("0",w.associations.getFieldsIndex())),_=new v(new V({name:"side",alias:"side",type:"string"}),B.create("''",w.associations.getFieldsIndex()));const W="globalid",U="globalId",Q={};for(const e in w.lkp)Q[e]=w.lkp[e].sourceId;const J=new P(new V({name:"classname",alias:"classname",type:"string"}),null,Q);let K="";switch(o){case"midspan":{K=`((${A}='${I}') OR ( ${N}='${I}')) AND (${O} IN (5))`,J.codefield=B.create(`CASE WHEN (${A}='${I}') THEN ${$} ELSE ${M} END`,w.associations.getFieldsIndex());const e=G(j.findField(w.associations.fields,N));e.name=W,e.alias=W,H=new v(e,B.create(`CASE WHEN (${N}='${I}') THEN ${A} ELSE ${N} END`,w.associations.getFieldsIndex())),Z=w.unVersion>=4?new C(j.findField(w.associations.fields,b.get("PERCENTALONG").name)):new v(new V({name:"percentalong",alias:"percentalong",type:"double"}),B.create("0",w.associations.getFieldsIndex()));break}case"junctionedge":{K=`((${A}='${I}') OR ( ${N}='${I}')) AND (${O} IN (4,6))`,J.codefield=B.create(`CASE WHEN (${A}='${I}') THEN ${$} ELSE ${M} END`,w.associations.getFieldsIndex());const e=G(j.findField(w.associations.fields,N));e.name=W,e.alias=W,H=new v(e,B.create(`CASE WHEN (${N}='${I}') THEN ${A} ELSE ${N} END`,w.associations.getFieldsIndex())),_=new v(new V({name:"side",alias:"side",type:"string"}),B.create(`CASE WHEN (${O}=4) THEN 'from' ELSE 'to' END`,w.associations.getFieldsIndex()));break}case"connected":{let e=`${A}='@T'`,t=`${N}='@T'`;null!==F&&(e+=` AND ${S}=@A`,t+=` AND ${T}=@A`),K="(("+e+") OR ("+t+"))",K=L(K,"@T",I??""),e=L(e,"@T",I??""),null!==F&&(e=L(e,"@A",F.toString()),K=L(K,"@A",F.toString())),J.codefield=B.create("CASE WHEN "+e+` THEN ${$} ELSE ${M} END`,w.associations.getFieldsIndex());const n=G(j.findField(w.associations.fields,N));n.name=W,n.alias=W,H=new v(n,B.create("CASE WHEN "+e+` THEN ${N} ELSE ${A} END`,w.associations.getFieldsIndex()));break}case"container":K=`${A}='${I}' AND ${O} = 2`,null!==F&&(K+=` AND ${S} = `+F.toString()),J.codefield=$,K="( "+K+" )",H=new R(j.findField(w.associations.fields,N),W,W);break;case"content":K=`(${N}='${I}' AND ${O} = 2)`,null!==F&&(K+=` AND ${T} = `+F.toString()),J.codefield=M,K="( "+K+" )",H=new R(j.findField(w.associations.fields,A),W,W);break;case"structure":K=`(${A}='${I}' AND ${O} = 3)`,null!==F&&(K+=` AND ${S} = `+F.toString()),J.codefield=$,K="( "+K+" )",H=new R(j.findField(w.associations.fields,N),W,U);break;case"attached":K=`(${N}='${I}' AND ${O} = 3)`,null!==F&&(K+=` AND ${T} = `+F.toString()),J.codefield=M,K="( "+K+" )",H=new R(j.findField(w.associations.fields,A),W,U);break;default:throw new i(e,a.InvalidParameter,t)}E&&(K="1 <> 1");return new j({parentfeatureset:w.associations,adaptedFields:[new C(j.findField(w.associations.fields,z)),new C(j.findField(w.associations.fields,k)),H,_,J,Z],extraFilter:K?B.create(K,w.associations.getFieldsIndex()):null})}))},W.signatures.push({name:"featuresetbyassociation",min:2,max:6}),W.functions.groupby=function(e,t){return W.standardFunctionAsync(e,t,(async(r,s,l)=>{if(p(l,3,3,e,t),!y(l[0]))throw new i(e,a.InvalidParameter,t);const o=await l[0].load(),f=[],u=[];let c=!1,d=[];if(h(l[1]))d.push(l[1]);else if(l[1]instanceof n)d.push(l[1]);else if(b(l[1]))d=l[1];else{if(!A(l[1]))throw new i(e,a.InvalidParameter,t);d=l[1].toArray()}for(const m of d)if(h(m)){const e=B.create(g(m),o.getFieldsIndex()),t=!0===_(e)?g(m):"%%%%FIELDNAME";f.push({name:t,expression:e}),"%%%%FIELDNAME"===t&&(c=!0)}else{if(!(m instanceof n))throw new i(e,a.InvalidParameter,t);{const n=m.hasField("name")?m.field("name"):"%%%%FIELDNAME",r=m.hasField("expression")?m.field("expression"):"";if("%%%%FIELDNAME"===n&&(c=!0),!n)throw new i(e,a.InvalidParameter,t);f.push({name:n,expression:B.create(r||n,o.getFieldsIndex())})}}if(d=[],h(l[2]))d.push(l[2]);else if(b(l[2]))d=l[2];else if(A(l[2]))d=l[2].toArray();else{if(!(l[2]instanceof n))throw new i(e,a.InvalidParameter,t);d.push(l[2])}for(const m of d){if(!(m instanceof n))throw new i(e,a.InvalidParameter,t);{const n=m.hasField("name")?m.field("name"):"",r=m.hasField("statistic")?m.field("statistic"):"",s=m.hasField("expression")?m.field("expression"):"";if(!n||!r||!s)throw new i(e,a.InvalidParameter,t);u.push({name:n,statistic:r.toLowerCase(),expression:B.create(s,o.getFieldsIndex())})}}if(c){const e={};for(const n of o.fields)e[n.name.toLowerCase()]=1;for(const n of f)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);for(const n of u)"%%%%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 t of f)await K(t.expression,W,e);for(const t of u)await K(t.expression,W,e);return l[0].groupby(f,u)}))},W.signatures.push({name:"groupby",min:3,max:3}),W.functions.distinct=function(e,t){return W.standardFunctionAsync(e,t,(async(r,s,l)=>{if(y(l[0])){p(l,2,2,e,t);const r=await l[0].load(),s=[];let o=[];if(h(l[1]))o.push(l[1]);else if(l[1]instanceof n)o.push(l[1]);else if(b(l[1]))o=l[1];else{if(!A(l[1]))throw new i(e,a.InvalidParameter,t);o=l[1].toArray()}let f=!1;for(const l of o)if(h(l)){const e=B.create(g(l),r.getFieldsIndex()),t=!0===_(e)?g(l):"%%%%FIELDNAME";s.push({name:t,expression:e}),"%%%%FIELDNAME"===t&&(f=!0)}else{if(!(l instanceof n))throw new i(e,a.InvalidParameter,t);{const n=l.hasField("name")?l.field("name"):"%%%%FIELDNAME",o=l.hasField("expression")?l.field("expression"):"";if("%%%%FIELDNAME"===n&&(f=!0),!n)throw new i(e,a.InvalidParameter,t);s.push({name:n,expression:B.create(o||n,r.getFieldsIndex())})}}if(f){const e={};for(const n of r.fields)e[n.name.toLowerCase()]=1;for(const n of s)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);let t=0;for(const n of s)if("%%%%FIELDNAME"===n.name){for(;1===e["field_"+t.toString()];)t++;e["field_"+t.toString()]=1,n.name="FIELD_"+t.toString()}}for(const t of s)await K(t.expression,W,e);return l[0].groupby(s,[])}return J("distinct",r,s,l)}))})}export{ae as registerFunctions};
5
+ import{ArcadeDate as e}from"../ArcadeDate.js";import t from"../ArcadePortal.js";import n from"../Dictionary.js";import{ArcadeExecutionError as i,ExecutionErrorCodes as a}from"../executionError.js";import r from"../Feature.js";import s from"../featureSetCollection.js";import{convertToFeatureSet as l,constructFeatureSetFromPortalItem as o,constructFeatureSet as f,constructFeatureSetFromRelationship as u,constructFeatureSetFromUrl as c,constructAssociationMetaDataFeatureSetFromUrl as d}from"../featureSetUtils.js";import m from"../ImmutableArray.js";import{C as p,r as y,c as h,j as g,l as w,G as I,k as F,D,h as E,m as b,p as x,o as A,i as N,g as S,a0 as T,P as L}from"../../chunks/languageUtils.js";import{getPortal as $}from"../portalUtils.js";import{SqlExpressionAdapted as v,StringToCodeAdapted as P,FieldRename as R,AdaptedFeatureSet as j,OriginalField as C}from"../featureset/actions/Adapted.js";import M from"../featureset/actions/AttributeFilter.js";import O from"../featureset/actions/OrderBy.js";import k from"../featureset/actions/Top.js";import z from"../featureset/sources/Empty.js";import H from"../featureset/sources/FeatureLayerMemory.js";import Z from"../featureset/support/OrderbyClause.js";import{cloneField as G}from"../featureset/support/shared.js";import{isSingleField as W}from"../featureset/support/sqlUtils.js";import{calculateStat as _}from"./fieldStats.js";import{isPromiseLike as U}from"../../core/promiseUtils.js";import{WhereClause as B}from"../../core/sql/WhereClause.js";import q from"../../layers/FeatureLayer.js";import V from"../../layers/support/Field.js";import Q from"../../portal/Portal.js";function J(e,t,n,i){if(1===i.length){if(b(i[0]))return _(e,i[0],-1);if(A(i[0]))return _(e,i[0].toArray(),-1)}return _(e,i,-1)}async function K(e,t,n){const i=e.getVariables();if(i.length>0){const a=[];for(let e=0;e<i.length;e++){const r={name:i[e]};a.push(await t.evaluateIdentifier(n,r))}const r={};for(let e=0;e<i.length;e++)r[i[e]]=a[e];return e.parameters=r,e}return e}function Y(e,t,n=null){for(const i in e)if(i.toLowerCase()===t.toLowerCase())return e[i];return n}function X(e){if(null===e)return null;const t={type:Y(e,"type",""),name:Y(e,"name","")};if("range"===t.type)t.range=Y(e,"range",[]);else{t.codedValues=[];for(const n of Y(e,"codedValues",[]))t.codedValues.push({name:Y(n,"name",""),code:Y(n,"code",null)})}return t}function ee(e){if(null===e)return null;const t={},n=Y(e,"wkt",null);null!==n&&(t.wkt=n);const i=Y(e,"wkid",null);return null!==i&&(t.wkid=i),t}function te(e){if(null===e)return null;const t={hasZ:Y(e,"hasz",!1),hasM:Y(e,"hasm",!1)},n=Y(e,"spatialreference",null);n&&(t.spatialReference=ee(n));const i=Y(e,"x",null);if(null!==i)return t.x=i,t.y=Y(e,"y",null),t;const a=Y(e,"rings",null);if(null!==a)return t.rings=a,t;const r=Y(e,"paths",null);if(null!==r)return t.paths=r,t;const s=Y(e,"points",null);if(null!==s)return t.points=s,t;for(const l of["xmin","xmax","ymin","ymax","zmin","zmax","mmin","mmax"]){const n=Y(e,l,null);null!==n&&(t[l]=n)}return t}function ne(e,t){for(const n of t)if(n===e)return!0;return!1}function ie(e){return!!e.layerDefinition&&(!!e.featureSet&&(!1!==ne(e.layerDefinition.geometryType,["",null,"esriGeometryNull","esriGeometryPoint","esriGeometryPolyline","esriGeometryPolygon","esriGeometryMultipoint","esriGeometryEnvelope"])&&(!1!==b(e.layerDefinition.fields)&&!1!==b(e.featureSet.features))))}function ae(_){"async"===_.mode&&(_.functions.timezone=function(t,r){return _.standardFunctionAsync(t,r,(async(s,l,o)=>{if(p(o,1,2,t,r),y(o[0])){if(await o[0].load(),1===o.length||null===o[1])return o[0].dateTimeReferenceFieldIndex.layerDateFieldsTimeZone;if(!(o[1]instanceof n)||!1===o[1].hasField("type"))throw new i(t,a.InvalidParameter,r);const e=o[1].field("type");if(!1===h(e))throw new i(t,a.InvalidParameter,r);switch(g(e).toLowerCase()){case"preferredtimezone":return o[0].dateTimeReferenceFieldIndex.layerPreferredTimeZone;case"editfieldsinfo":return o[0].dateTimeReferenceFieldIndex.layerEditFieldsTimeZone;case"timeinfo":return o[0].dateTimeReferenceFieldIndex.layerTimeInfoTimeZone;case"field":if(o[1].hasField("fieldname")&&h(o[1].field("fieldname")))return o[0].dateTimeReferenceFieldIndex.fieldTimeZone(g(o[1].field("fieldname")))}throw new i(t,a.InvalidParameter,r)}const f=w(o[0],I(t));if(null===f)return null;const u=f.timeZone;return"system"===u?e.systemTimeZoneCanonicalName:u}))},_.functions.sqltimestamp=function(e,t){return _.standardFunctionAsync(e,t,(async(n,r,s)=>{p(s,1,3,e,t);const l=s[0];if(F(l)){if(1===s.length)return l.toSQLString();if(2===s.length)return l.changeTimeZone(g(s[1])).toSQLString();throw new i(e,a.InvalidParameter,t)}if(y(l)){if(3!==s.length)throw new i(e,a.InvalidParameter,t);await l.load();const n=g(s[1]);if(!1===F(s[2]))throw new i(e,a.InvalidParameter,t);const r=l.fieldTimeZone(n);return null===r?s[2].toSQLString():s[2].changeTimeZone(r).toSQLString()}throw new i(e,a.InvalidParameter,t)}))},_.signatures.push({name:"sqltimestamp",min:2,max:4}),_.functions.featuresetbyid=function(e,t){return _.standardFunctionAsync(e,t,((n,r,l)=>{if(p(l,2,4,e,t),l[0]instanceof s){const n=g(l[1]);let r=D(l[2],null);const s=E(D(l[3],!0));if(null===r&&(r=["*"]),!1===b(r))throw new i(e,a.InvalidParameter,t);return l[0].featureSetById(n,s,r)}throw new i(e,a.InvalidParameter,t)}))},_.signatures.push({name:"featuresetbyid",min:2,max:4}),_.functions.getfeatureset=function(e,t){return _.standardFunctionAsync(e,t,((n,r,s)=>{if(p(s,1,2,e,t),x(s[0])){let t=D(s[1],"datasource");return null===t&&(t="datasource"),t=g(t).toLowerCase(),l(s[0].fullSchema(),t,e.lrucache,e.interceptor,e.spatialReference)}throw new i(e,a.InvalidParameter,t)}))},_.signatures.push({name:"getfeatureset",min:1,max:2}),_.functions.featuresetbyportalitem=function(e,n){return _.standardFunctionAsync(e,n,((r,s,l)=>{if(p(l,2,5,e,n),null===l[0])throw new i(e,a.PortalRequired,n);if(l[0]instanceof t){const t=g(l[1]),r=g(l[2]);let s=D(l[3],null);const f=E(D(l[4],!0));if(null===s&&(s=["*"]),!1===b(s))throw new i(e,a.InvalidParameter,n);let u=null;return u=e.services&&e.services.portal?e.services.portal:Q.getDefault(),u=$(l[0],u),o(t,r,e.spatialReference,s,f,u,e.lrucache,e.interceptor)}if(!1===h(l[0]))throw new i(e,a.PortalRequired,n);const f=g(l[0]),u=g(l[1]);let c=D(l[2],null);const d=E(D(l[3],!0));if(null===c&&(c=["*"]),!1===b(c))throw new i(e,a.InvalidParameter,n);return o(f,u,e.spatialReference,c,d,e.services?.portal??Q.getDefault(),e.lrucache,e.interceptor)}))},_.signatures.push({name:"featuresetbyportalitem",min:2,max:5}),_.functions.featuresetbyname=function(e,t){return _.standardFunctionAsync(e,t,((n,r,l)=>{if(p(l,2,4,e,t),l[0]instanceof s){const n=g(l[1]);let r=D(l[2],null);const s=E(D(l[3],!0));if(null===r&&(r=["*"]),!1===b(r))throw new i(e,a.InvalidParameter,t);return l[0].featureSetByName(n,s,r)}throw new i(e,a.InvalidParameter,t)}))},_.signatures.push({name:"featuresetbyname",min:2,max:4}),_.functions.featureset=function(e,t){return _.standardFunction(e,t,((r,s,l)=>{p(l,1,1,e,t);let o=l[0];const f={layerDefinition:{geometryType:"",objectIdField:"",hasM:!1,hasZ:!1,globalIdField:"",typeIdField:"",fields:[]},featureSet:{geometryType:"",features:[]}};if(h(o))o=JSON.parse(o),void 0!==o.layerDefinition?(f.layerDefinition=o.layerDefinition,f.featureSet=o.featureSet,o.layerDefinition.spatialReference&&(f.layerDefinition.spatialReference=o.layerDefinition.spatialReference)):(f.featureSet.features=o.features,f.featureSet.geometryType=o.geometryType,f.layerDefinition.geometryType=f.featureSet.geometryType,f.layerDefinition.objectIdField=o.objectIdFieldName??"",f.layerDefinition.typeIdField=o.typeIdFieldName,f.layerDefinition.globalIdField=o.globalIdFieldName,f.layerDefinition.fields=o.fields,o.spatialReference&&(f.layerDefinition.spatialReference=o.spatialReference));else{if(!(l[0]instanceof n))throw new i(e,a.InvalidParameter,t);{o=JSON.parse(l[0].castToText(!0));const e=Y(o,"layerdefinition");if(null!==e){f.layerDefinition.geometryType=Y(e,"geometrytype",""),f.featureSet.geometryType=f.layerDefinition.geometryType,f.layerDefinition.globalIdField=Y(e,"globalidfield",""),f.layerDefinition.objectIdField=Y(e,"objectidfield",""),f.layerDefinition.typeIdField=Y(e,"typeidfield",""),f.layerDefinition.hasZ=!0===Y(e,"hasz",!1),f.layerDefinition.hasM=!0===Y(e,"hasm",!1);const t=Y(e,"spatialreference",null);t&&(f.layerDefinition.spatialReference=ee(t));for(const i of Y(e,"fields",[])){const e={name:Y(i,"name",""),alias:Y(i,"alias",""),type:Y(i,"type",""),nullable:Y(i,"nullable",!0),editable:Y(i,"editable",!0),length:Y(i,"length",null),domain:X(Y(i,"domain"))};f.layerDefinition.fields.push(e)}const n=Y(o,"featureset",null);if(n){const e={};for(const t of f.layerDefinition.fields)e[t.name.toLowerCase()]=t.name;for(const t of Y(n,"features",[])){const n={},i=Y(t,"attributes",{});for(const t in i)n[e[t.toLowerCase()]]=i[t];f.featureSet.features.push({attributes:n,geometry:te(Y(t,"geometry",null))})}}}else{f.layerDefinition.hasZ=!0===Y(o,"hasz",!1),f.layerDefinition.hasM=!0===Y(o,"hasm",!1),f.layerDefinition.geometryType=Y(o,"geometrytype",""),f.featureSet.geometryType=f.layerDefinition.geometryType,f.layerDefinition.objectIdField=Y(o,"objectidfieldname",""),f.layerDefinition.typeIdField=Y(o,"typeidfieldname","");const e=Y(o,"spatialreference",null);e&&(f.layerDefinition.spatialReference=ee(e));let t=Y(o,"fields",null);if(b(t))for(const a of t){const e={name:Y(a,"name",""),alias:Y(a,"alias",""),type:Y(a,"type",""),nullable:Y(a,"nullable",!0),editable:Y(a,"editable",!0),length:Y(a,"length",null),domain:X(Y(a,"domain"))};f.layerDefinition.fields.push(e)}else t=null,f.layerDefinition.fields=t;const n={};for(const a of f.layerDefinition.fields)n[a.name.toLowerCase()]=a.name;let i=Y(o,"features",null);if(b(i))for(const a of i){const e={},t=Y(a,"attributes",{});for(const i in t)e[n[i.toLowerCase()]]=t[i];f.featureSet.features.push({attributes:e,geometry:te(Y(a,"geometry",null))})}else i=null,f.featureSet.features=i}}}if(!1===ie(f))throw new i(e,a.InvalidParameter,t);return""===(f?.layerDefinition?.geometryType||"")&&(f.layerDefinition.geometryType="esriGeometryNull"),H.create(f,e.spatialReference)}))},_.signatures.push({name:"featureset",min:1,max:1}),_.functions.filter=function(e,t){return _.standardFunctionAsync(e,t,(async(n,r,s)=>{if(p(s,2,2,e,t),b(s[0])||A(s[0])){const n=[];let r=s[0];r instanceof m&&(r=r.toArray());let l=null;if(!N(s[1]))throw new i(e,a.InvalidParameter,t);l=s[1].createFunction(e);for(const e of r){const t=l(e);U(t)?!0===await t&&n.push(e):!0===t&&n.push(e)}return n}if(y(s[0])){const t=await s[0].load(),n=B.create(s[1],t.getFieldsIndex()),i=n.getVariables();if(i.length>0){const t=[];for(let n=0;n<i.length;n++){const a={name:i[n]};t.push(await _.evaluateIdentifier(e,a))}const a={};for(let e=0;e<i.length;e++)a[i[e]]=t[e];return n.parameters=a,new M({parentfeatureset:s[0],whereclause:n})}return new M({parentfeatureset:s[0],whereclause:n})}throw new i(e,a.InvalidParameter,t)}))},_.signatures.push({name:"filter",min:2,max:2}),_.functions.orderby=function(e,t){return _.standardFunctionAsync(e,t,(async(n,r,s)=>{if(p(s,2,2,e,t),y(s[0])){const e=new Z(s[1]);return new O({parentfeatureset:s[0],orderbyclause:e})}throw new i(e,a.InvalidParameter,t)}))},_.signatures.push({name:"orderby",min:2,max:2}),_.functions.top=function(e,t){return _.standardFunctionAsync(e,t,(async(n,r,s)=>{if(p(s,2,2,e,t),y(s[0]))return new k({parentfeatureset:s[0],topnum:s[1]});if(b(s[0]))return S(s[1])>=s[0].length?s[0].slice(0):s[0].slice(0,S(s[1]));if(A(s[0]))return S(s[1])>=s[0].length()?s[0].slice(0):s[0].slice(0,S(s[1]));throw new i(e,a.InvalidParameter,t)}))},_.signatures.push({name:"top",min:2,max:2}),_.functions.first=function(e,t){return _.standardFunctionAsync(e,t,(async(n,i,a)=>{if(p(a,1,1,e,t),y(a[0])){const t=await a[0].first(n.abortSignal);if(null!==t){const n=r.createFromGraphicLikeObject(t.geometry,t.attributes,a[0],e.timeReference);return n._underlyingGraphic=t,n}return t}return b(a[0])?0===a[0].length?null:a[0][0]:A(a[0])?0===a[0].length()?null:a[0].get(0):null}))},_.signatures.push({name:"first",min:1,max:1}),_.functions.attachments=function(e,t){return _.standardFunctionAsync(e,t,(async(r,s,l)=>{p(l,1,2,e,t);const o={minsize:-1,maxsize:-1,types:null,returnMetadata:!1};if(l.length>1)if(l[1]instanceof n){if(l[1].hasField("minsize")&&(o.minsize=S(l[1].field("minsize"))),l[1].hasField("metadata")&&(o.returnMetadata=E(l[1].field("metadata"))),l[1].hasField("maxsize")&&(o.maxsize=S(l[1].field("maxsize"))),l[1].hasField("types")){const e=T(l[1].field("types"),!1);e.length>0&&(o.types=e)}}else if(null!==l[1])throw new i(e,a.InvalidParameter,t);if(x(l[0])){let t=l[0]._layer;return t instanceof q&&(t=f(t,e.spatialReference,["*"],!0,e.lrucache,e.interceptor)),null===t?[]:!1===y(t)?[]:(await t.load(),t.queryAttachments(l[0].field(t.objectIdField),o.minsize,o.maxsize,o.types,o.returnMetadata))}if(null===l[0])return[];throw new i(e,a.InvalidParameter,t)}))},_.signatures.push({name:"attachments",min:1,max:2}),_.functions.featuresetbyrelationshipname=function(e,t){return _.standardFunctionAsync(e,t,(async(n,r,s)=>{p(s,2,4,e,t);const l=s[0],o=g(s[1]);let d=D(s[2],null);const m=E(D(s[3],!0));if(null===d&&(d=["*"]),!1===b(d))throw new i(e,a.InvalidParameter,t);if(null===s[0])return null;if(!x(s[0]))throw new i(e,a.InvalidParameter,t);let h=l._layer;if(h instanceof q&&(h=f(h,e.spatialReference,["*"],!0,e.lrucache,e.interceptor)),null===h)return null;if(!1===y(h))return null;h=await h.load();const w=h.relationshipMetaData().filter((e=>e.name===o));if(0===w.length)return null;if(void 0!==w[0].relationshipTableId&&null!==w[0].relationshipTableId&&w[0].relationshipTableId>-1)return u(h,w[0],l.field(h.objectIdField),h.spatialReference,d,m,e.lrucache,e.interceptor);let I=h.serviceUrl();if(!I)return null;I="/"===I.charAt(I.length-1)?I+w[0].relatedTableId.toString():I+"/"+w[0].relatedTableId.toString();const F=await c(I,h.spatialReference,d,m,e.lrucache,e.interceptor);await F.load();let A=F.relationshipMetaData();if(A=A.filter((e=>e.id===w[0].id)),!1===l.hasField(w[0].keyField)||null===l.field(w[0].keyField)){const e=await h.getFeatureByObjectId(l.field(h.objectIdField),[w[0].keyField]);if(e){const t=B.create(A[0].keyField+"= @id",F.getFieldsIndex());return t.parameters={id:e.attributes[w[0].keyField]},F.filter(t)}return new z({parentfeatureset:F})}const N=B.create(A[0].keyField+"= @id",F.getFieldsIndex());return N.parameters={id:l.field(w[0].keyField)},F.filter(N)}))},_.signatures.push({name:"featuresetbyrelationshipname",min:2,max:4}),_.functions.featuresetbyassociation=function(e,t){return _.standardFunctionAsync(e,t,(async(n,r,s)=>{p(s,2,3,e,t);const l=s[0],o=g(D(s[1],"")).toLowerCase(),u=h(s[2])?g(s[2]):null;if(null===s[0])return null;if(!x(s[0]))throw new i(e,a.InvalidParameter,t);let c=l._layer;if(c instanceof q&&(c=f(c,e.spatialReference,["*"],!0,e.lrucache,e.interceptor)),null===c)return null;if(!1===y(c))return null;await c.load();const m=c.serviceUrl(),w=await d(m,e.spatialReference);let I=null,F=null,E=!1;if(null!==u&&""!==u&&void 0!==u){for(const e of w.terminals)e.terminalName===u&&(F=e.terminalId);null===F&&(E=!0)}const b=w.associations.getFieldsIndex(),A=b.get("TOGLOBALID").name,N=b.get("FROMGLOBALID").name,S=b.get("TOTERMINALID").name,T=b.get("FROMTERMINALID").name,$=b.get("FROMNETWORKSOURCEID").name,M=b.get("TONETWORKSOURCEID").name,O=b.get("ASSOCIATIONTYPE").name,k=b.get("ISCONTENTVISIBLE").name,z=b.get("OBJECTID").name;for(const e of c.fields)if("global-id"===e.type){I=l.field(e.name);break}let H=null,Z=new v(new V({name:"percentalong",alias:"percentalong",type:"double"}),B.create("0",w.associations.getFieldsIndex())),W=new v(new V({name:"side",alias:"side",type:"string"}),B.create("''",w.associations.getFieldsIndex()));const _="globalid",U="globalId",Q={};for(const e in w.lkp)Q[e]=w.lkp[e].sourceId;const J=new P(new V({name:"classname",alias:"classname",type:"string"}),null,Q);let K="";switch(o){case"midspan":{K=`((${A}='${I}') OR ( ${N}='${I}')) AND (${O} IN (5))`,J.codefield=B.create(`CASE WHEN (${A}='${I}') THEN ${$} ELSE ${M} END`,w.associations.getFieldsIndex());const e=G(j.findField(w.associations.fields,N));e.name=_,e.alias=_,H=new v(e,B.create(`CASE WHEN (${N}='${I}') THEN ${A} ELSE ${N} END`,w.associations.getFieldsIndex())),Z=w.unVersion>=4?new C(j.findField(w.associations.fields,b.get("PERCENTALONG").name)):new v(new V({name:"percentalong",alias:"percentalong",type:"double"}),B.create("0",w.associations.getFieldsIndex()));break}case"junctionedge":{K=`((${A}='${I}') OR ( ${N}='${I}')) AND (${O} IN (4,6))`,J.codefield=B.create(`CASE WHEN (${A}='${I}') THEN ${$} ELSE ${M} END`,w.associations.getFieldsIndex());const e=G(j.findField(w.associations.fields,N));e.name=_,e.alias=_,H=new v(e,B.create(`CASE WHEN (${N}='${I}') THEN ${A} ELSE ${N} END`,w.associations.getFieldsIndex())),W=new v(new V({name:"side",alias:"side",type:"string"}),B.create(`CASE WHEN (${O}=4) THEN 'from' ELSE 'to' END`,w.associations.getFieldsIndex()));break}case"connected":{let e=`${A}='@T'`,t=`${N}='@T'`;null!==F&&(e+=` AND ${S}=@A`,t+=` AND ${T}=@A`),K="(("+e+") OR ("+t+"))",K=L(K,"@T",I??""),e=L(e,"@T",I??""),null!==F&&(e=L(e,"@A",F.toString()),K=L(K,"@A",F.toString())),J.codefield=B.create("CASE WHEN "+e+` THEN ${$} ELSE ${M} END`,w.associations.getFieldsIndex());const n=G(j.findField(w.associations.fields,N));n.name=_,n.alias=_,H=new v(n,B.create("CASE WHEN "+e+` THEN ${N} ELSE ${A} END`,w.associations.getFieldsIndex()));break}case"container":K=`${A}='${I}' AND ${O} = 2`,null!==F&&(K+=` AND ${S} = `+F.toString()),J.codefield=$,K="( "+K+" )",H=new R(j.findField(w.associations.fields,N),_,_);break;case"content":K=`(${N}='${I}' AND ${O} = 2)`,null!==F&&(K+=` AND ${T} = `+F.toString()),J.codefield=M,K="( "+K+" )",H=new R(j.findField(w.associations.fields,A),_,_);break;case"structure":K=`(${A}='${I}' AND ${O} = 3)`,null!==F&&(K+=` AND ${S} = `+F.toString()),J.codefield=$,K="( "+K+" )",H=new R(j.findField(w.associations.fields,N),_,U);break;case"attached":K=`(${N}='${I}' AND ${O} = 3)`,null!==F&&(K+=` AND ${T} = `+F.toString()),J.codefield=M,K="( "+K+" )",H=new R(j.findField(w.associations.fields,A),_,U);break;default:throw new i(e,a.InvalidParameter,t)}E&&(K="1 <> 1");return new j({parentfeatureset:w.associations,adaptedFields:[new C(j.findField(w.associations.fields,z)),new C(j.findField(w.associations.fields,k)),H,W,J,Z],extraFilter:K?B.create(K,w.associations.getFieldsIndex()):null})}))},_.signatures.push({name:"featuresetbyassociation",min:2,max:6}),_.functions.groupby=function(e,t){return _.standardFunctionAsync(e,t,(async(r,s,l)=>{if(p(l,3,3,e,t),!y(l[0]))throw new i(e,a.InvalidParameter,t);const o=await l[0].load(),f=[],u=[];let c=!1,d=[];if(h(l[1]))d.push(l[1]);else if(l[1]instanceof n)d.push(l[1]);else if(b(l[1]))d=l[1];else{if(!A(l[1]))throw new i(e,a.InvalidParameter,t);d=l[1].toArray()}for(const m of d)if(h(m)){const e=B.create(g(m),o.getFieldsIndex()),t=!0===W(e)?g(m):"%%%%FIELDNAME";f.push({name:t,expression:e}),"%%%%FIELDNAME"===t&&(c=!0)}else{if(!(m instanceof n))throw new i(e,a.InvalidParameter,t);{const n=m.hasField("name")?m.field("name"):"%%%%FIELDNAME",r=m.hasField("expression")?m.field("expression"):"";if("%%%%FIELDNAME"===n&&(c=!0),!n)throw new i(e,a.InvalidParameter,t);f.push({name:n,expression:B.create(r||n,o.getFieldsIndex())})}}if(d=[],h(l[2]))d.push(l[2]);else if(b(l[2]))d=l[2];else if(A(l[2]))d=l[2].toArray();else{if(!(l[2]instanceof n))throw new i(e,a.InvalidParameter,t);d.push(l[2])}for(const m of d){if(!(m instanceof n))throw new i(e,a.InvalidParameter,t);{const n=m.hasField("name")?m.field("name"):"",r=m.hasField("statistic")?m.field("statistic"):"",s=m.hasField("expression")?m.field("expression"):"";if(!n||!r||!s)throw new i(e,a.InvalidParameter,t);u.push({name:n,statistic:r.toLowerCase(),expression:B.create(s,o.getFieldsIndex())})}}if(c){const e={};for(const n of o.fields)e[n.name.toLowerCase()]=1;for(const n of f)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);for(const n of u)"%%%%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 t of f)await K(t.expression,_,e);for(const t of u)await K(t.expression,_,e);return l[0].groupby(f,u)}))},_.signatures.push({name:"groupby",min:3,max:3}),_.functions.distinct=function(e,t){return _.standardFunctionAsync(e,t,(async(r,s,l)=>{if(y(l[0])){p(l,2,2,e,t);const r=await l[0].load(),s=[];let o=[];if(h(l[1]))o.push(l[1]);else if(l[1]instanceof n)o.push(l[1]);else if(b(l[1]))o=l[1];else{if(!A(l[1]))throw new i(e,a.InvalidParameter,t);o=l[1].toArray()}let f=!1;for(const l of o)if(h(l)){const e=B.create(g(l),r.getFieldsIndex()),t=!0===W(e)?g(l):"%%%%FIELDNAME";s.push({name:t,expression:e}),"%%%%FIELDNAME"===t&&(f=!0)}else{if(!(l instanceof n))throw new i(e,a.InvalidParameter,t);{const n=l.hasField("name")?l.field("name"):"%%%%FIELDNAME",o=l.hasField("expression")?l.field("expression"):"";if("%%%%FIELDNAME"===n&&(f=!0),!n)throw new i(e,a.InvalidParameter,t);s.push({name:n,expression:B.create(o||n,r.getFieldsIndex())})}}if(f){const e={};for(const n of r.fields)e[n.name.toLowerCase()]=1;for(const n of s)"%%%%FIELDNAME"!==n.name&&(e[n.name.toLowerCase()]=1);let t=0;for(const n of s)if("%%%%FIELDNAME"===n.name){for(;1===e["field_"+t.toString()];)t++;e["field_"+t.toString()]=1,n.name="FIELD_"+t.toString()}}for(const t of s)await K(t.expression,_,e);return l[0].groupby(s,[])}return J("distinct",r,s,l)}))})}export{ae as registerFunctions};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import n from"../Dictionary.js";import{ArcadeExecutionError as a,ExecutionErrorCodes as e}from"../executionError.js";import{C as t,p as r,U as o,j as i,r as c,$ as s,T as d,G as u,V as m,a0 as f,W as l,a1 as y,D as v,t as p,S as w}from"../../chunks/languageUtils.js";import{layerFieldEsriConstants as T}from"../featureset/support/shared.js";function h(a,e){return a&&a.domain?"coded-value"===a.domain.type||"codedValue"===a.domain.type?n.convertObjectToArcadeDictionary({type:"codedValue",name:a.domain.name,dataType:T[a.field.type],codedValues:a.domain.codedValues.map((n=>({name:n.name,code:n.code})))},u(e)):n.convertObjectToArcadeDictionary({type:"range",name:a.domain.name,dataType:T[a.field.type],min:a.domain.min,max:a.domain.max},u(e)):null}function b(T){"async"===T.mode&&(T.functions.domain=function(n,d){return T.standardFunctionAsync(n,d,(async(u,m,f)=>{if(t(f,2,3,n,d),r(f[0])){return h(o(f[0],i(f[1]),void 0===f[2]?void 0:f[2]),n)}if(c(f[0])){await f[0]._ensureLoaded();return h(s(i(f[1]),f[0],null,void 0===f[2]?void 0:f[2]),n)}throw new a(n,e.InvalidParameter,d)}))},T.functions.subtypes=function(o,i){return T.standardFunctionAsync(o,i,(async(s,m,f)=>{if(t(f,1,1,o,i),r(f[0])){const a=d(f[0]);return a?n.convertObjectToArcadeDictionary(a,u(o)):null}if(c(f[0])){await f[0]._ensureLoaded();const a=f[0].subtypes();return a?n.convertObjectToArcadeDictionary(a,u(o)):null}throw new a(o,e.InvalidParameter,i)}))},T.functions.domainname=function(n,o){return T.standardFunctionAsync(n,o,(async(d,u,l)=>{if(t(l,2,4,n,o),r(l[0]))return m(l[0],i(l[1]),l[2],void 0===l[3]?void 0:l[3]);if(c(l[0])){await l[0]._ensureLoaded();const n=s(i(l[1]),l[0],null,void 0===l[3]?void 0:l[3]);return f(n,l[2])}throw new a(n,e.InvalidParameter,o)}))},T.signatures.push({name:"domainname",min:2,max:4}),T.functions.domaincode=function(n,o){return T.standardFunctionAsync(n,o,(async(d,u,m)=>{if(t(m,2,4,n,o),r(m[0]))return l(m[0],i(m[1]),m[2],void 0===m[3]?void 0:m[3]);if(c(m[0])){await m[0]._ensureLoaded();const n=s(i(m[1]),m[0],null,void 0===m[3]?void 0:m[3]);return y(n,m[2])}throw new a(n,e.InvalidParameter,o)}))},T.signatures.push({name:"domaincode",min:2,max:4})),T.functions.text=function(n,a){return T.standardFunctionAsync(n,a,((e,r,o)=>{if(t(o,1,2,n,a),!c(o[0]))return p(o[0],o[1]);{const n=v(o[1],"");if(""===n)return o[0].castToText();if("schema"===n.toLowerCase())return o[0].convertToText("schema",e.abortSignal);if("featureset"===n.toLowerCase())return o[0].convertToText("featureset",e.abortSignal)}}))},T.functions.gdbversion=function(n,o){return T.standardFunctionAsync(n,o,(async(i,s,d)=>{if(t(d,1,1,n,o),r(d[0]))return d[0].gdbVersion();if(c(d[0])){return(await d[0].load()).gdbVersion}throw new a(n,e.InvalidParameter,o)}))},T.functions.schema=function(o,i){return T.standardFunctionAsync(o,i,(async(s,d,m)=>{if(t(m,1,1,o,i),c(m[0]))return await m[0].load(),n.convertObjectToArcadeDictionary(m[0].schema(),u(o));if(r(m[0])){const a=w(m[0]);return a?n.convertObjectToArcadeDictionary(a,u(o)):null}throw new a(o,e.InvalidParameter,i)}))}}export{b as registerFunctions};
5
+ import n from"../Dictionary.js";import{ArcadeExecutionError as a,ExecutionErrorCodes as e}from"../executionError.js";import{C as t,p as r,U as o,j as i,r as c,a1 as s,T as d,G as u,V as m,a2 as f,W as l,a3 as y,D as v,t as p,S as w}from"../../chunks/languageUtils.js";import{layerFieldEsriConstants as T}from"../featureset/support/shared.js";function h(a,e){return a&&a.domain?"coded-value"===a.domain.type||"codedValue"===a.domain.type?n.convertObjectToArcadeDictionary({type:"codedValue",name:a.domain.name,dataType:T[a.field.type],codedValues:a.domain.codedValues.map((n=>({name:n.name,code:n.code})))},u(e)):n.convertObjectToArcadeDictionary({type:"range",name:a.domain.name,dataType:T[a.field.type],min:a.domain.min,max:a.domain.max},u(e)):null}function b(T){"async"===T.mode&&(T.functions.domain=function(n,d){return T.standardFunctionAsync(n,d,(async(u,m,f)=>{if(t(f,2,3,n,d),r(f[0])){return h(o(f[0],i(f[1]),void 0===f[2]?void 0:f[2]),n)}if(c(f[0])){await f[0]._ensureLoaded();return h(s(i(f[1]),f[0],null,void 0===f[2]?void 0:f[2]),n)}throw new a(n,e.InvalidParameter,d)}))},T.functions.subtypes=function(o,i){return T.standardFunctionAsync(o,i,(async(s,m,f)=>{if(t(f,1,1,o,i),r(f[0])){const a=d(f[0]);return a?n.convertObjectToArcadeDictionary(a,u(o)):null}if(c(f[0])){await f[0]._ensureLoaded();const a=f[0].subtypes();return a?n.convertObjectToArcadeDictionary(a,u(o)):null}throw new a(o,e.InvalidParameter,i)}))},T.functions.domainname=function(n,o){return T.standardFunctionAsync(n,o,(async(d,u,l)=>{if(t(l,2,4,n,o),r(l[0]))return m(l[0],i(l[1]),l[2],void 0===l[3]?void 0:l[3]);if(c(l[0])){await l[0]._ensureLoaded();const n=s(i(l[1]),l[0],null,void 0===l[3]?void 0:l[3]);return f(n,l[2])}throw new a(n,e.InvalidParameter,o)}))},T.signatures.push({name:"domainname",min:2,max:4}),T.functions.domaincode=function(n,o){return T.standardFunctionAsync(n,o,(async(d,u,m)=>{if(t(m,2,4,n,o),r(m[0]))return l(m[0],i(m[1]),m[2],void 0===m[3]?void 0:m[3]);if(c(m[0])){await m[0]._ensureLoaded();const n=s(i(m[1]),m[0],null,void 0===m[3]?void 0:m[3]);return y(n,m[2])}throw new a(n,e.InvalidParameter,o)}))},T.signatures.push({name:"domaincode",min:2,max:4})),T.functions.text=function(n,a){return T.standardFunctionAsync(n,a,((e,r,o)=>{if(t(o,1,2,n,a),!c(o[0]))return p(o[0],o[1]);{const n=v(o[1],"");if(""===n)return o[0].castToText();if("schema"===n.toLowerCase())return o[0].convertToText("schema",e.abortSignal);if("featureset"===n.toLowerCase())return o[0].convertToText("featureset",e.abortSignal)}}))},T.functions.gdbversion=function(n,o){return T.standardFunctionAsync(n,o,(async(i,s,d)=>{if(t(d,1,1,n,o),r(d[0]))return d[0].gdbVersion();if(c(d[0])){return(await d[0].load()).gdbVersion}throw new a(n,e.InvalidParameter,o)}))},T.functions.schema=function(o,i){return T.standardFunctionAsync(o,i,(async(s,d,m)=>{if(t(m,1,1,o,i),c(m[0]))return await m[0].load(),n.convertObjectToArcadeDictionary(m[0].schema(),u(o));if(r(m[0])){const a=w(m[0]);return a?n.convertObjectToArcadeDictionary(a,u(o)):null}throw new a(o,e.InvalidParameter,i)}))}}export{b as registerFunctions};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import"./FunctionWrapper.js";import"./ImmutableArray.js";import"./ImmutablePathArray.js";import"./ImmutablePointArray.js";import"./ArcadeDate.js";import"../geometry/Extent.js";import"../geometry/Geometry.js";import"../geometry/Multipoint.js";import"../geometry/Point.js";import"../geometry/Polygon.js";import"../geometry/Polyline.js";import"luxon";import"../core/number.js";import"../geometry/support/coordsUtils.js";import"../intl/locale.js";import"../config.js";import"../kernel.js";import"./featureset/support/shared.js";import"./ArcadeModule.js";import"./executionError.js";export{I as ImplicitResult,a3 as ImplicitResultE,R as ReturnResult,a2 as ReturnResultE,J as absRound,aa as arcadeVersion,O as autoCastArrayOfPointsToMultiPoint,N as autoCastArrayOfPointsToPolygon,M as autoCastArrayOfPointsToPolyline,L as autoCastFeatureToGeometry,B as binaryOperator,w as breakResult,d as castAsJson,e as castAsJsonAsync,x as continueResult,X as defaultExecutingContext,G as defaultTimeZone,D as defaultUndefined,A as equalityTest,W as featureDomainCodeLookup,V as featureDomainValueLookup,U as featureFullDomain,S as featureSchema,T as featureSubtypes,K as fixNullGeometry,y as fixSpatialReference,a8 as formatDate,a7 as formatNumber,Q as generateUUID,$ as getDomain,a1 as getDomainCode,a0 as getDomainValue,F as getType,z as greaterThanLessThan,m as isArray,a as isBoolean,k as isDate,s as isDictionary,p as isFeature,r as isFeatureSet,q as isFeatureSetCollection,i as isFunctionParameter,n as isGeometry,o as isImmutableArray,E as isInteger,a6 as isJsDate,a4 as isModule,b as isNumber,a5 as isObject,f as isSimpleType,c as isString,P as multiReplace,C as pcCheck,a9 as stableStringify,H as standardiseDateFormat,Z as tick,h as toBoolean,l as toDate,g as toNumber,Y as toNumberArray,j as toString,_ as toStringArray,t as toStringExplicit,v as voidOperation}from"../chunks/languageUtils.js";
5
+ import"./FunctionWrapper.js";import"./ImmutableArray.js";import"./ImmutablePathArray.js";import"./ImmutablePointArray.js";import"./ArcadeDate.js";import"../geometry/Extent.js";import"../geometry/Geometry.js";import"../geometry/Multipoint.js";import"../geometry/Point.js";import"../geometry/Polygon.js";import"../geometry/Polyline.js";import"luxon";import"../core/number.js";import"../geometry/support/coordsUtils.js";import"../intl/locale.js";import"../config.js";import"../kernel.js";import"./featureset/support/shared.js";import"./ArcadeModule.js";import"./executionError.js";export{I as ImplicitResult,a5 as ImplicitResultE,R as ReturnResult,a4 as ReturnResultE,J as absRound,ac as arcadeVersion,O as autoCastArrayOfPointsToMultiPoint,N as autoCastArrayOfPointsToPolygon,M as autoCastArrayOfPointsToPolyline,L as autoCastFeatureToGeometry,B as binaryOperator,w as breakResult,d as castAsJson,e as castAsJsonAsync,x as continueResult,X as defaultExecutingContext,G as defaultTimeZone,D as defaultUndefined,A as equalityTest,W as featureDomainCodeLookup,V as featureDomainValueLookup,U as featureFullDomain,S as featureSchema,T as featureSubtypes,K as fixNullGeometry,y as fixSpatialReference,aa as formatDate,a9 as formatNumber,Q as generateUUID,a1 as getDomain,a3 as getDomainCode,a2 as getDomainValue,F as getType,z as greaterThanLessThan,m as isArray,a as isBoolean,k as isDate,s as isDictionary,p as isFeature,r as isFeatureSet,q as isFeatureSetCollection,i as isFunctionParameter,n as isGeometry,o as isImmutableArray,E as isInteger,a8 as isJsDate,a6 as isModule,b as isNumber,a7 as isObject,f as isSimpleType,c as isString,Z as isSubtypeGrouplayer,_ as isSubtypeSublayer,P as multiReplace,C as pcCheck,ab as stableStringify,H as standardiseDateFormat,$ as tick,h as toBoolean,l as toDate,g as toNumber,Y as toNumberArray,j as toString,a0 as toStringArray,t as toStringExplicit,v as voidOperation}from"../chunks/languageUtils.js";
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- const e={all:{min:2,max:2},getenvironment:{min:0,max:0},none:{min:2,max:2},any:{min:2,max:2},reduce:{min:2,max:3},map:{min:2,max:2},filter:{min:2,max:2},fromcodepoint:{min:1,max:-1},fromcharcode:{min:1,max:-1},tocodepoint:{min:1,max:2},tocharcode:{min:1,max:2},concatenate:{min:0,max:-1},expects:{min:1,max:-1},getfeatureset:{min:1,max:2},week:{min:1,max:2},fromjson:{min:1,max:1},length3d:{min:1,max:2},tohex:{min:1,max:1},hash:{min:1,max:1},timezone:{min:1,max:1},timezoneoffset:{min:1,max:1},changetimezone:{min:2,max:2},isoweek:{min:1,max:1},isoweekday:{min:1,max:1},hasvalue:{min:2,max:2},isomonth:{min:1,max:1},isoyear:{min:1,max:1},resize:{min:2,max:3},slice:{min:0,max:-1},splice:{min:0,max:-1},push:{min:2,max:2},pop:{min:1,max:1},includes:{min:2,max:2},array:{min:0,max:2},front:{min:1,max:1},back:{min:1,max:1},insert:{min:3,max:3},erase:{min:2,max:2},split:{min:2,max:4},guid:{min:0,max:1},standardizeguid:{min:2,max:2},today:{min:0,max:0},angle:{min:2,max:3},bearing:{min:2,max:3},urlencode:{min:1,max:1},now:{min:0,max:0},timestamp:{min:0,max:0},day:{min:1,max:1},month:{min:1,max:1},year:{min:1,max:1},hour:{min:1,max:1},second:{min:1,max:1},millisecond:{min:1,max:1},minute:{min:1,max:1},weekday:{min:1,max:1},toutc:{min:1,max:1},tolocal:{min:1,max:1},date:{min:0,max:8},datediff:{min:2,max:4},dateadd:{min:2,max:3},trim:{min:1,max:1},text:{min:1,max:2},left:{min:2,max:2},right:{min:2,max:2},mid:{min:2,max:3},upper:{min:1,max:1},proper:{min:1,max:2},lower:{min:1,max:1},find:{min:2,max:3},iif:{min:3,max:3},decode:{min:2,max:-1},when:{min:2,max:-1},defaultvalue:{min:2,max:2},isempty:{min:1,max:1},domaincode:{min:2,max:4},domainname:{min:2,max:4},polygon:{min:1,max:1},point:{min:1,max:1},polyline:{min:1,max:1},extent:{min:1,max:1},multipoint:{min:1,max:1},ringisclockwise:{min:1,max:1},geometry:{min:1,max:1},count:{min:0,max:-1},number:{min:1,max:2},acos:{min:1,max:1},asin:{min:1,max:1},atan:{min:1,max:1},atan2:{min:2,max:2},ceil:{min:1,max:2},floor:{min:1,max:2},round:{min:1,max:2},cos:{min:1,max:1},exp:{min:1,max:1},log:{min:1,max:1},min:{min:0,max:-1},constrain:{min:3,max:3},console:{min:0,max:-1},max:{min:0,max:-1},pow:{min:2,max:2},random:{min:0,max:0},sqrt:{min:1,max:1},sin:{min:1,max:1},tan:{min:1,max:1},abs:{min:1,max:1},isnan:{min:1,max:1},stdev:{min:0,max:-1},average:{min:0,max:-1},mean:{min:0,max:-1},sum:{min:0,max:-1},variance:{min:0,max:-1},distinct:{min:0,max:-1},first:{min:1,max:1},top:{min:2,max:2},boolean:{min:1,max:1},dictionary:{min:0,max:-1},typeof:{min:1,max:1},reverse:{min:1,max:1},replace:{min:3,max:4},sort:{min:1,max:2},feature:{min:1,max:-1},haskey:{min:2,max:2},indexof:{min:2,max:2},disjoint:{min:2,max:2},intersects:{min:2,max:2},touches:{min:2,max:2},crosses:{min:2,max:2},within:{min:2,max:2},contains:{min:2,max:2},overlaps:{min:2,max:2},equals:{min:2,max:2},relate:{min:3,max:3},intersection:{min:2,max:2},union:{min:1,max:2},difference:{min:2,max:2},symmetricdifference:{min:2,max:2},clip:{min:2,max:2},cut:{min:2,max:2},area:{min:1,max:2},areageodetic:{min:1,max:2},length:{min:1,max:2},lengthgeodetic:{min:1,max:2},distancegeodetic:{min:2,max:3},distance:{min:2,max:3},densify:{min:2,max:3},densifygeodetic:{min:2,max:3},generalize:{min:2,max:4},buffer:{min:2,max:3},buffergeodetic:{min:2,max:3},offset:{min:2,max:6},rotate:{min:2,max:3},issimple:{min:1,max:1},simplify:{min:1,max:1},convexhull:{min:1,max:1},centroid:{min:1,max:1},nearestcoordinate:{min:2,max:2},nearestvertex:{min:2,max:2},isselfintersecting:{min:1,max:1},multiparttosinglepart:{min:1,max:1},setgeometry:{min:2,max:2},portal:{min:1,max:1},getuser:{min:0,max:2},subtypes:{min:1,max:1},subtypecode:{min:1,max:1},subtypename:{min:1,max:1},domain:{min:2,max:3},convertdirection:{min:3,max:3},sqltimestamp:{min:1,max:3},schema:{min:1,max:1}},n={functionDefinitions:new Map,constantDefinitions:new Map},a={functionDefinitions:new Map,constantDefinitions:new Map};for(const b of["pi","infinity"])a.constantDefinitions.set(b,{type:"constant"}),n.constantDefinitions.set(b,{type:"constant"});a.constantDefinitions.set("textformatting",{type:"namespace",key:"textformatting",members:[{key:"backwardslash",type:"constant"},{key:"doublequote",type:"constant"},{key:"forwardslash",type:"constant"},{key:"tab",type:"constant"},{key:"singlequote",type:"constant"},{key:"newline",type:"constant"}]}),n.constantDefinitions.set("textformatting",{type:"namespace",key:"textformatting",members:[{key:"backwardslash",type:"constant"},{key:"tab",type:"constant"},{key:"singlequote",type:"constant"},{key:"doublequote",type:"constant"},{key:"forwardslash",type:"constant"},{key:"newline",type:"constant"}]});for(const b in e){const t=e[b];a.functionDefinitions.set(b,{overloads:[{type:"function",parametersInfo:{min:t.min,max:t.max}}]}),n.functionDefinitions.set(b,{overloads:[{type:"function",parametersInfo:{min:t.min,max:t.max}}]})}const t=["featureset","featuresetbyid","featuresetbyname","featuresetbyassociation","featuresetbyrelationshipname","featuresetbyurl","getfeatureset","attachments","featuresetbyportalitem"],i=["disjoint","intersects","touches","crosses","within","contains","overlaps","equals","relate","intersection","nearestvertex","nearestcoordinate","union","difference","symmetricdifference","clip","cut","area","areageodetic","length","length3d","lengthgeodetic","distance","distancegeodetic","densify","densifygeodetic","generalize","buffer","buffergeodetic","offset","rotate","issimple","convexhull","simplify","multiparttosinglepart"];function m(e){return"string"==typeof e||e instanceof String}function o(e,t){const i="sync"===t?n:a;i.functionDefinitions.has(e.name.toLowerCase())?i.functionDefinitions.get(e.name.toLowerCase())?.overloads.push({type:"function",parametersInfo:{min:e.min,max:e.max}}):i.functionDefinitions.set(e.name.toLowerCase(),{overloads:[{type:"function",parametersInfo:{min:e.min,max:e.max}}]})}function s(e,n){if(e)for(const a of e)r(a,n)}function r(e,n){if(e&&!1!==n(e))switch(e.type){case"ImportDeclaration":s(e.specifiers,n),r(e.source,n);break;case"ExportNamedDeclaration":r(e.declaration,n);break;case"ArrayExpression":s(e.elements,n);break;case"AssignmentExpression":case"BinaryExpression":case"LogicalExpression":r(e.left,n),r(e.right,n);break;case"BlockStatement":case"Program":s(e.body,n);break;case"BreakStatement":case"ContinueStatement":case"EmptyStatement":case"Identifier":case"Literal":break;case"CallExpression":r(e.callee,n),s(e.arguments,n);break;case"ExpressionStatement":r(e.expression,n);break;case"ForInStatement":r(e.left,n),r(e.right,n),r(e.body,n);break;case"ForStatement":r(e.init,n),r(e.test,n),r(e.update,n),r(e.body,n);break;case"WhileStatement":r(e.test,n),r(e.body,n);break;case"FunctionDeclaration":r(e.id,n),s(e.params,n),r(e.body,n);break;case"IfStatement":r(e.test,n),r(e.consequent,n),r(e.alternate,n);break;case"MemberExpression":r(e.object,n),r(e.property,n);break;case"ObjectExpression":s(e.properties,n);break;case"Property":r(e.key,n),r(e.value,n);break;case"ReturnStatement":case"UnaryExpression":case"UpdateExpression":r(e.argument,n);break;case"VariableDeclaration":s(e.declarations,n);break;case"VariableDeclarator":r(e.id,n),r(e.init,n);break;case"TemplateLiteral":s(e.expressions,n),s(e.quasis,n)}}function c(e,n){let a=!1;const t=n.toLowerCase();return r(e,(e=>!a&&("Identifier"===e.type&&e.name&&e.name.toLowerCase()===t&&(a=!0),!0))),a}function x(e){const n=[];return r(e,(e=>("ImportDeclaration"===e.type&&e.source&&e.source.value&&n.push({libname:e.specifiers[0].local.name.toLowerCase(),source:e.source.value}),!0))),n}function p(e,n){let a=!1;const t=n.toLowerCase();return r(e,(e=>!a&&("CallExpression"!==e.type||"Identifier"!==e.callee.type||!e.callee.name||e.callee.name.toLowerCase()!==t||(a=!0,!1)))),a}function l(e){const n=[];return r(e,(e=>"MemberExpression"!==e.type||"Identifier"!==e.object.type||(!1===e.computed&&e.object&&e.object.name&&e.property&&"Identifier"===e.property.type&&e.property.name?n.push(e.object.name.toLowerCase()+"."+e.property.name.toLowerCase()):e.object&&e.object.name&&e.property&&"Literal"===e.property.type&&"string"==typeof e.property.value&&n.push(e.object.name.toLowerCase()+"."+e.property.value?.toString().toLowerCase()),!1))),n}function u(e){const n=[];return r(e,(e=>{if("CallExpression"===e.type){if("Identifier"===e.callee.type&&"expects"===e.callee.name.toLowerCase()){let a="";for(let t=0;t<(e.arguments||[]).length;t++)0===t?"Identifier"===e.arguments[t].type&&(a=e.arguments[t].name.toLowerCase()):a&&"Literal"===e.arguments[t].type&&m(e.arguments[t].value)&&n.push(a+"."+e.arguments[t].value.toLowerCase());return!1}if("Identifier"===e.callee.type&&["domainname","domaincode","domain","haskey"].includes(e.callee.name.toLowerCase())&&e.arguments.length>=2){let a="";return"Identifier"===e.arguments[0].type&&(a=e.arguments[0].name.toLowerCase()),a&&"Literal"===e.arguments[1].type&&m(e.arguments[1].value)&&n.push(a+"."+e.arguments[1].value.toLowerCase()),!1}}return"MemberExpression"!==e.type||"Identifier"!==e.object.type||(!1===e.computed&&e.object&&e.object.name&&e.property&&"Identifier"===e.property.type&&e.property.name?n.push(e.object.name.toLowerCase()+"."+e.property.name.toLowerCase()):e.object&&e.object.name&&e.property&&"Literal"===e.property.type&&"string"==typeof e.property.value&&n.push(e.object.name.toLowerCase()+"."+e.property.value?.toString().toLowerCase()),!1)})),n}function f(e,n){const a=[];if(void 0!==n.params&&null!==n.params)for(let t=0;t<n.params.length;t++)a.push("any");return{name:e,return:"any",params:a}}function y(e){const n=[];return r(e,(e=>("CallExpression"===e.type&&"Identifier"===e.callee.type&&n.push(e.callee.name.toLowerCase()),!0))),n}function d(e,n=[]){let a=null;if(void 0===e.usesFeatureSet){null===a&&(a=y(e)),e.usesFeatureSet=!1;for(let n=0;n<a.length;n++)t.includes(a[n])&&(e.usesFeatureSet=!0,e.isAsync=!0);if(!1===e.usesFeatureSet&&n&&n.length>0)for(const a of n)if(c(e,a)){e.usesFeatureSet=!0,e.isAsync=!0;break}}if(void 0===e.usesModules){e.usesModules=!1;x(e).length>0&&(e.usesModules=!0)}if(void 0===e.usesGeometry){e.usesGeometry=!1,null===a&&(a=y(e));for(let n=0;n<a.length;n++)i.includes(a[n])&&(e.usesGeometry=!0)}}function g(e){const n=y(e);for(let a=0;a<n.length;a++)if(t.includes(n[a]))return!0;return!1}export{o as addFunctionDeclaration,f as extractFunctionDeclaration,u as findExpectedFieldLiterals,l as findFieldLiterals,y as findFunctionCalls,x as findModuleImports,d as findScriptDependencies,a as fullArcadeApiAsync,n as fullArcadeApiSync,p as referencesFunction,c as referencesMember,g as scriptUsesFeatureSet,r as walk};
5
+ const e={all:{min:2,max:2},getenvironment:{min:0,max:0},none:{min:2,max:2},any:{min:2,max:2},reduce:{min:2,max:3},map:{min:2,max:2},filter:{min:2,max:2},fromcodepoint:{min:1,max:-1},fromcharcode:{min:1,max:-1},tocodepoint:{min:1,max:2},tocharcode:{min:1,max:2},concatenate:{min:0,max:-1},expects:{min:1,max:-1},getfeatureset:{min:1,max:2},week:{min:1,max:2},fromjson:{min:1,max:1},length3d:{min:1,max:2},tohex:{min:1,max:1},hash:{min:1,max:1},timezone:{min:1,max:1},timezoneoffset:{min:1,max:1},changetimezone:{min:2,max:2},isoweek:{min:1,max:1},isoweekday:{min:1,max:1},hasvalue:{min:2,max:2},isomonth:{min:1,max:1},isoyear:{min:1,max:1},resize:{min:2,max:3},slice:{min:0,max:-1},splice:{min:0,max:-1},push:{min:2,max:2},pop:{min:1,max:1},includes:{min:2,max:2},array:{min:0,max:2},front:{min:1,max:1},back:{min:1,max:1},insert:{min:3,max:3},erase:{min:2,max:2},split:{min:2,max:4},guid:{min:0,max:1},standardizeguid:{min:2,max:2},today:{min:0,max:0},angle:{min:2,max:3},bearing:{min:2,max:3},urlencode:{min:1,max:1},now:{min:0,max:0},timestamp:{min:0,max:0},day:{min:1,max:1},month:{min:1,max:1},year:{min:1,max:1},hour:{min:1,max:1},second:{min:1,max:1},millisecond:{min:1,max:1},minute:{min:1,max:1},weekday:{min:1,max:1},toutc:{min:1,max:1},tolocal:{min:1,max:1},date:{min:0,max:8},datediff:{min:2,max:4},dateadd:{min:2,max:3},trim:{min:1,max:1},text:{min:1,max:2},left:{min:2,max:2},right:{min:2,max:2},mid:{min:2,max:3},upper:{min:1,max:1},proper:{min:1,max:2},lower:{min:1,max:1},find:{min:2,max:3},iif:{min:3,max:3},decode:{min:2,max:-1},when:{min:2,max:-1},defaultvalue:{min:2,max:2},isempty:{min:1,max:1},domaincode:{min:2,max:4},domainname:{min:2,max:4},polygon:{min:1,max:1},point:{min:1,max:1},polyline:{min:1,max:1},extent:{min:1,max:1},multipoint:{min:1,max:1},ringisclockwise:{min:1,max:1},geometry:{min:1,max:1},count:{min:0,max:-1},number:{min:1,max:2},acos:{min:1,max:1},asin:{min:1,max:1},atan:{min:1,max:1},atan2:{min:2,max:2},ceil:{min:1,max:2},floor:{min:1,max:2},round:{min:1,max:2},cos:{min:1,max:1},exp:{min:1,max:1},log:{min:1,max:1},min:{min:0,max:-1},constrain:{min:3,max:3},console:{min:0,max:-1},max:{min:0,max:-1},pow:{min:2,max:2},random:{min:0,max:0},sqrt:{min:1,max:1},sin:{min:1,max:1},tan:{min:1,max:1},abs:{min:1,max:1},isnan:{min:1,max:1},stdev:{min:0,max:-1},average:{min:0,max:-1},mean:{min:0,max:-1},sum:{min:0,max:-1},variance:{min:0,max:-1},distinct:{min:0,max:-1},first:{min:1,max:1},top:{min:2,max:2},boolean:{min:1,max:1},dictionary:{min:0,max:-1},typeof:{min:1,max:1},reverse:{min:1,max:1},replace:{min:3,max:4},sort:{min:1,max:2},feature:{min:1,max:-1},haskey:{min:2,max:2},indexof:{min:2,max:2},disjoint:{min:2,max:2},intersects:{min:2,max:2},touches:{min:2,max:2},crosses:{min:2,max:2},within:{min:2,max:2},contains:{min:2,max:2},overlaps:{min:2,max:2},equals:{min:2,max:2},relate:{min:3,max:3},intersection:{min:2,max:2},union:{min:1,max:2},difference:{min:2,max:2},symmetricdifference:{min:2,max:2},clip:{min:2,max:2},cut:{min:2,max:2},area:{min:1,max:2},areageodetic:{min:1,max:2},length:{min:1,max:2},lengthgeodetic:{min:1,max:2},distancegeodetic:{min:2,max:3},distance:{min:2,max:3},densify:{min:2,max:3},densifygeodetic:{min:2,max:3},generalize:{min:2,max:4},buffer:{min:2,max:3},buffergeodetic:{min:2,max:3},offset:{min:2,max:6},rotate:{min:2,max:3},issimple:{min:1,max:1},simplify:{min:1,max:1},convexhull:{min:1,max:1},centroid:{min:1,max:1},nearestcoordinate:{min:2,max:2},nearestvertex:{min:2,max:2},isselfintersecting:{min:1,max:1},multiparttosinglepart:{min:1,max:1},setgeometry:{min:2,max:2},portal:{min:1,max:1},getuser:{min:0,max:2},subtypes:{min:1,max:1},subtypecode:{min:1,max:1},subtypename:{min:1,max:1},domain:{min:2,max:3},convertdirection:{min:3,max:3},sqltimestamp:{min:1,max:3},schema:{min:1,max:1}},n={functionDefinitions:new Map,constantDefinitions:new Map},a={functionDefinitions:new Map,constantDefinitions:new Map};for(const b of["pi","infinity"])a.constantDefinitions.set(b,{type:"constant"}),n.constantDefinitions.set(b,{type:"constant"});a.constantDefinitions.set("textformatting",{type:"namespace",key:"textformatting",members:[{key:"backwardslash",type:"constant"},{key:"doublequote",type:"constant"},{key:"forwardslash",type:"constant"},{key:"tab",type:"constant"},{key:"singlequote",type:"constant"},{key:"newline",type:"constant"}]}),n.constantDefinitions.set("textformatting",{type:"namespace",key:"textformatting",members:[{key:"backwardslash",type:"constant"},{key:"tab",type:"constant"},{key:"singlequote",type:"constant"},{key:"doublequote",type:"constant"},{key:"forwardslash",type:"constant"},{key:"newline",type:"constant"}]});for(const b in e){const t=e[b];a.functionDefinitions.set(b,{overloads:[{type:"function",parametersInfo:{min:t.min,max:t.max}}]}),n.functionDefinitions.set(b,{overloads:[{type:"function",parametersInfo:{min:t.min,max:t.max}}]})}const t=["featureset","featuresetbyid","featuresetbyname","featuresetbyassociation","featuresetbyrelationshipname","featuresetbyurl","getfeatureset","getuser","attachments","featuresetbyportalitem"],i=["disjoint","intersects","touches","crosses","within","contains","overlaps","equals","relate","intersection","nearestvertex","nearestcoordinate","union","difference","symmetricdifference","clip","cut","area","areageodetic","length","length3d","lengthgeodetic","distance","distancegeodetic","densify","densifygeodetic","generalize","buffer","buffergeodetic","offset","rotate","issimple","convexhull","simplify","multiparttosinglepart"];function m(e){return"string"==typeof e||e instanceof String}function o(e,t){const i="sync"===t?n:a;i.functionDefinitions.has(e.name.toLowerCase())?i.functionDefinitions.get(e.name.toLowerCase())?.overloads.push({type:"function",parametersInfo:{min:e.min,max:e.max}}):i.functionDefinitions.set(e.name.toLowerCase(),{overloads:[{type:"function",parametersInfo:{min:e.min,max:e.max}}]})}function s(e,n){if(e)for(const a of e)r(a,n)}function r(e,n){if(e&&!1!==n(e))switch(e.type){case"ImportDeclaration":s(e.specifiers,n),r(e.source,n);break;case"ExportNamedDeclaration":r(e.declaration,n);break;case"ArrayExpression":s(e.elements,n);break;case"AssignmentExpression":case"BinaryExpression":case"LogicalExpression":r(e.left,n),r(e.right,n);break;case"BlockStatement":case"Program":s(e.body,n);break;case"BreakStatement":case"ContinueStatement":case"EmptyStatement":case"Identifier":case"Literal":break;case"CallExpression":r(e.callee,n),s(e.arguments,n);break;case"ExpressionStatement":r(e.expression,n);break;case"ForInStatement":r(e.left,n),r(e.right,n),r(e.body,n);break;case"ForStatement":r(e.init,n),r(e.test,n),r(e.update,n),r(e.body,n);break;case"WhileStatement":r(e.test,n),r(e.body,n);break;case"FunctionDeclaration":r(e.id,n),s(e.params,n),r(e.body,n);break;case"IfStatement":r(e.test,n),r(e.consequent,n),r(e.alternate,n);break;case"MemberExpression":r(e.object,n),r(e.property,n);break;case"ObjectExpression":s(e.properties,n);break;case"Property":r(e.key,n),r(e.value,n);break;case"ReturnStatement":case"UnaryExpression":case"UpdateExpression":r(e.argument,n);break;case"VariableDeclaration":s(e.declarations,n);break;case"VariableDeclarator":r(e.id,n),r(e.init,n);break;case"TemplateLiteral":s(e.expressions,n),s(e.quasis,n)}}function c(e,n){let a=!1;const t=n.toLowerCase();return r(e,(e=>!a&&("Identifier"===e.type&&e.name&&e.name.toLowerCase()===t&&(a=!0),!0))),a}function x(e){const n=[];return r(e,(e=>("ImportDeclaration"===e.type&&e.source&&e.source.value&&n.push({libname:e.specifiers[0].local.name.toLowerCase(),source:e.source.value}),!0))),n}function p(e,n){let a=!1;const t=n.toLowerCase();return r(e,(e=>!a&&("CallExpression"!==e.type||"Identifier"!==e.callee.type||!e.callee.name||e.callee.name.toLowerCase()!==t||(a=!0,!1)))),a}function l(e){const n=[];return r(e,(e=>"MemberExpression"!==e.type||"Identifier"!==e.object.type||(!1===e.computed&&e.object&&e.object.name&&e.property&&"Identifier"===e.property.type&&e.property.name?n.push(e.object.name.toLowerCase()+"."+e.property.name.toLowerCase()):e.object&&e.object.name&&e.property&&"Literal"===e.property.type&&"string"==typeof e.property.value&&n.push(e.object.name.toLowerCase()+"."+e.property.value?.toString().toLowerCase()),!1))),n}function u(e){const n=[];return r(e,(e=>{if("CallExpression"===e.type){if("Identifier"===e.callee.type&&"expects"===e.callee.name.toLowerCase()){let a="";for(let t=0;t<(e.arguments||[]).length;t++)0===t?"Identifier"===e.arguments[t].type&&(a=e.arguments[t].name.toLowerCase()):a&&"Literal"===e.arguments[t].type&&m(e.arguments[t].value)&&n.push(a+"."+e.arguments[t].value.toLowerCase());return!1}if("Identifier"===e.callee.type&&["domainname","domaincode","domain","haskey"].includes(e.callee.name.toLowerCase())&&e.arguments.length>=2){let a="";return"Identifier"===e.arguments[0].type&&(a=e.arguments[0].name.toLowerCase()),a&&"Literal"===e.arguments[1].type&&m(e.arguments[1].value)&&n.push(a+"."+e.arguments[1].value.toLowerCase()),!1}}return"MemberExpression"!==e.type||"Identifier"!==e.object.type||(!1===e.computed&&e.object&&e.object.name&&e.property&&"Identifier"===e.property.type&&e.property.name?n.push(e.object.name.toLowerCase()+"."+e.property.name.toLowerCase()):e.object&&e.object.name&&e.property&&"Literal"===e.property.type&&"string"==typeof e.property.value&&n.push(e.object.name.toLowerCase()+"."+e.property.value?.toString().toLowerCase()),!1)})),n}function f(e,n){const a=[];if(void 0!==n.params&&null!==n.params)for(let t=0;t<n.params.length;t++)a.push("any");return{name:e,return:"any",params:a}}function y(e){const n=[];return r(e,(e=>("CallExpression"===e.type&&"Identifier"===e.callee.type&&n.push(e.callee.name.toLowerCase()),!0))),n}function d(e,n=[]){let a=null;if(void 0===e.usesFeatureSet){null===a&&(a=y(e)),e.usesFeatureSet=!1;for(let n=0;n<a.length;n++)t.includes(a[n])&&(e.usesFeatureSet=!0,e.isAsync=!0);if(!1===e.usesFeatureSet&&n&&n.length>0)for(const a of n)if(c(e,a)){e.usesFeatureSet=!0,e.isAsync=!0;break}}if(void 0===e.usesModules){e.usesModules=!1;x(e).length>0&&(e.usesModules=!0)}if(void 0===e.usesGeometry){e.usesGeometry=!1,null===a&&(a=y(e));for(let n=0;n<a.length;n++)i.includes(a[n])&&(e.usesGeometry=!0)}}function g(e){const n=y(e);for(let a=0;a<n.length;a++)if(t.includes(n[a]))return!0;return!1}export{o as addFunctionDeclaration,f as extractFunctionDeclaration,u as findExpectedFieldLiterals,l as findFieldLiterals,y as findFunctionCalls,x as findModuleImports,d as findScriptDependencies,a as fullArcadeApiAsync,n as fullArcadeApiSync,p as referencesFunction,c as referencesMember,g as scriptUsesFeatureSet,r as walk};