@arcgis/core 4.34.0-next.88 → 4.34.0-next.89

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 (227) hide show
  1. package/PopupTemplate.js +1 -1
  2. package/arcade/Dictionary.js +1 -1
  3. package/arcade/Feature.js +1 -1
  4. package/arcade/Pixel.js +1 -1
  5. package/arcade/Voxel.js +1 -1
  6. package/arcade/containerUtils.js +1 -1
  7. package/arcade/featureSetUtils.js +1 -1
  8. package/arcade/featureset/actions/GroupBy.js +1 -1
  9. package/arcade/featureset/actions/OrderBy.js +1 -1
  10. package/arcade/featureset/support/FeatureSet.js +1 -1
  11. package/arcade/functions/date.js +1 -1
  12. package/arcade/functions/feature.js +1 -1
  13. package/arcade/functions/featuresetbase.js +1 -1
  14. package/arcade/functions/featuresetstats.js +1 -1
  15. package/arcade/functions/featuresetstring.js +1 -1
  16. package/arcade/functions/fieldStats.js +1 -1
  17. package/arcade/functions/geometry.js +1 -1
  18. package/arcade/functions/maths.js +1 -1
  19. package/arcade/functions/string.js +1 -1
  20. package/arcade/languageUtils.js +1 -1
  21. package/assets/esri/core/workers/RemoteClient.js +1 -1
  22. package/assets/esri/core/workers/chunks/{ed8863c3d334f438b625.js → 0037abf0a82d1ed32e91.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{d7fc8ea2ff527a09f4b9.js → 0296ebe8e37e30af771c.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{39a1f361bb69073af765.js → 04dbdaa63c950f32b8f0.js} +1 -1
  25. package/assets/esri/core/workers/chunks/05aac984cbbadb5f6aa0.js +1 -0
  26. package/assets/esri/core/workers/chunks/0fadd1defbb6743dacdc.js +1 -0
  27. package/assets/esri/core/workers/chunks/{0f05425954578ac796ec.js → 135142f3cbfaf24949bc.js} +1 -1
  28. package/assets/esri/core/workers/chunks/2b2f1fcd50dea017d891.js +1 -0
  29. package/assets/esri/core/workers/chunks/{9ca55d33ae4bf25e8edd.js → 2e1cc11462846febb3b2.js} +1 -1
  30. package/assets/esri/core/workers/chunks/300b96f0f8e34b4a5d8b.js +1 -0
  31. package/assets/esri/core/workers/chunks/37b5007660535f1c91c6.js +1 -0
  32. package/assets/esri/core/workers/chunks/{2dc88379ee94fabdaf52.js → 39a5863355cccaabd2d6.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{f3ee035fa7bf638c8e60.js → 3d68a650a1f944ec5171.js} +1 -1
  34. package/assets/esri/core/workers/chunks/47c0c16c1e995a441ec2.js +1 -0
  35. package/assets/esri/core/workers/chunks/48913b944c28343816ac.js +1 -0
  36. package/assets/esri/core/workers/chunks/{4d4db6854aff7656f6e1.js → 4dd4b19c410026233999.js} +1 -1
  37. package/assets/esri/core/workers/chunks/52121179d4f9833008ec.js +1 -0
  38. package/assets/esri/core/workers/chunks/58e2652810143f509fe1.js +1 -0
  39. package/assets/esri/core/workers/chunks/{97489bf16a1d327992b2.js → 595593dd03bcfba795c8.js} +11 -16
  40. package/assets/esri/core/workers/chunks/59e27818cb68f0285d54.js +1 -0
  41. package/assets/esri/core/workers/chunks/620a94b54be3ed78350d.js +1 -0
  42. package/assets/esri/core/workers/chunks/6f29951f5a2da068b257.js +1 -0
  43. package/assets/esri/core/workers/chunks/71c6c0b26253c4ca1b68.js +1 -0
  44. package/assets/esri/core/workers/chunks/{1c1b0cc91fe9cb3fec61.js → 71df48968d6cdc736458.js} +1 -1
  45. package/assets/esri/core/workers/chunks/779ee975efebb838b5d6.js +1 -0
  46. package/assets/esri/core/workers/chunks/7a240ab31d9ff2d2c5af.js +1 -0
  47. package/assets/esri/core/workers/chunks/834985ec601623df34a1.js +1 -0
  48. package/assets/esri/core/workers/chunks/{5dee8c0c60ced791e57f.js → 84a556dafd583635ad5e.js} +1 -1
  49. package/assets/esri/core/workers/chunks/8be9fa12e854a83062c3.js +1 -0
  50. package/assets/esri/core/workers/chunks/8f4cfef97716c3502b0f.js +1 -0
  51. package/assets/esri/core/workers/chunks/{65ec21d29e8563fdbc55.js → 94c9d3094c93f7760433.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{177840d5f0076c0de46b.js → 96de78f9994207aa7201.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{366db86914a63e6d0c68.js → 978ffde9ebebf5c83aea.js} +1 -1
  54. package/assets/esri/core/workers/chunks/a1abe9865d66789bd5af.js +1 -0
  55. package/assets/esri/core/workers/chunks/{257fd65786feb5951b90.js → a96e58ed9a4a2329ee53.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{0074f1836d7ff69ff6ec.js → aa778e5d7db40d9b9b4a.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{c78de6dd6c10280cee69.js → baa48614d9567d5f240d.js} +1 -1
  58. package/assets/esri/core/workers/chunks/c3010d783506f8410f99.js +1 -0
  59. package/assets/esri/core/workers/chunks/c55c096669677321a227.js +1 -0
  60. package/assets/esri/core/workers/chunks/c86ca87959f04075e834.js +1 -0
  61. package/assets/esri/core/workers/chunks/c954d281038f6bf80232.js +1 -0
  62. package/assets/esri/core/workers/chunks/{a48f980c1531805db73b.js → d1fc2c6e95fe2572d297.js} +1 -1
  63. package/assets/esri/core/workers/chunks/{fc5ac54aab66562c8463.js → d51aabb9b950f49df183.js} +1 -1
  64. package/assets/esri/core/workers/chunks/{639d856cd217914dfe1f.js → de34c21d3e6913befe5a.js} +1 -1
  65. package/assets/esri/core/workers/chunks/e99fc64b67bb0c71dc34.js +1 -0
  66. package/assets/esri/core/workers/chunks/f6806780ca2aa591475a.js +1 -0
  67. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_ar.json +1 -0
  68. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_bg.json +1 -0
  69. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_bs.json +1 -0
  70. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_ca.json +1 -0
  71. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_cs.json +1 -0
  72. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_da.json +1 -0
  73. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_de.json +1 -0
  74. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_el.json +1 -0
  75. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_es.json +1 -0
  76. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_et.json +1 -0
  77. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_fi.json +1 -0
  78. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_fr.json +1 -0
  79. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_he.json +1 -0
  80. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_hr.json +1 -0
  81. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_hu.json +1 -0
  82. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_id.json +1 -0
  83. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_it.json +1 -0
  84. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_ja.json +1 -0
  85. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_ko.json +1 -0
  86. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_lt.json +1 -0
  87. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_lv.json +1 -0
  88. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_nl.json +1 -0
  89. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_no.json +1 -0
  90. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_pl.json +1 -0
  91. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_pt-BR.json +1 -0
  92. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_pt-PT.json +1 -0
  93. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_ro.json +1 -0
  94. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_ru.json +1 -0
  95. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_sk.json +1 -0
  96. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_sl.json +1 -0
  97. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_sr.json +1 -0
  98. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_sv.json +1 -0
  99. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_th.json +1 -0
  100. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_tr.json +1 -0
  101. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_uk.json +1 -0
  102. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_vi.json +1 -0
  103. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_zh-CN.json +1 -0
  104. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_zh-HK.json +1 -0
  105. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis_zh-TW.json +1 -0
  106. package/chunks/ComponentShader.glsl.js +15 -16
  107. package/chunks/DefaultMaterial.glsl.js +15 -16
  108. package/chunks/Path.glsl.js +12 -12
  109. package/chunks/RealisticTree.glsl.js +5 -6
  110. package/chunks/aiServices.js +1 -1
  111. package/chunks/array.js +1 -1
  112. package/chunks/languageUtils.js +1 -1
  113. package/config.js +1 -1
  114. package/editing/sharedTemplates/SharedTemplate.js +1 -1
  115. package/editing/sharedTemplates/SharedTemplateMetadata.js +1 -1
  116. package/editing/sharedTemplates/SharedTemplateProvider.js +1 -1
  117. package/editing/sharedTemplates/templateDefinitions/FeatureTemplateDefinition.js +1 -1
  118. package/editing/sharedTemplates/templateDefinitions/GroupTemplateDefinition.js +1 -1
  119. package/editing/sharedTemplates/templateDefinitions/PresetTemplateDefinition.js +1 -1
  120. package/editing/sharedTemplates/templateDefinitions/TemplateDefinitionBase.js +1 -1
  121. package/editing/sharedTemplates/templateDefinitions/parts/FeatureTemplateRelationshipPart.js +1 -1
  122. package/editing/sharedTemplates/templateDefinitions/parts/PresetTemplatePart.js +1 -1
  123. package/editing/sharedTemplates/templateDefinitions/parts/TemplatePartBase.js +1 -1
  124. package/interfaces.d.ts +40 -25
  125. package/kernel.js +1 -1
  126. package/layers/CSVLayer.js +1 -1
  127. package/layers/FeatureLayer.js +1 -1
  128. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  129. package/layers/OrientedImageryLayer.js +1 -1
  130. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  131. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  132. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  133. package/layers/support/DateTimeFieldFormat.js +1 -1
  134. package/layers/support/FieldConfiguration.js +1 -1
  135. package/layers/support/FieldFormat.js +1 -1
  136. package/layers/support/NumberFieldFormat.js +1 -1
  137. package/layers/support/Sublayer.js +1 -1
  138. package/layers/support/capabilities.js +1 -1
  139. package/layers/support/fieldConfigUtils.js +1 -1
  140. package/layers/support/fieldFormatUtils.js +5 -0
  141. package/layers/support/serviceCapabilitiesUtils.js +1 -1
  142. package/layers/support/vectorTileLayerLoader.js +1 -1
  143. package/package.json +1 -1
  144. package/popup/FieldInfo.js +1 -1
  145. package/popup/content/FieldsContent.js +1 -1
  146. package/portal/Portal.js +1 -1
  147. package/portal/schemas/definitions.js +1 -1
  148. package/rest/sharedTemplates/addSharedTemplates.js +5 -0
  149. package/rest/sharedTemplates/querySharedTemplates.js +1 -1
  150. package/rest/sharedTemplates/utils.js +5 -0
  151. package/support/ArcadeExpression.js +1 -1
  152. package/support/revision.js +1 -1
  153. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  154. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementConfiguration.js +1 -1
  155. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  156. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementShiftTool.js +1 -1
  157. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementTool.js +1 -1
  158. package/views/3d/environment/CloudsComposition.js +1 -1
  159. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  160. package/views/3d/interactive/editingTools/reshape/ReshapeTool3D.js +1 -1
  161. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  162. package/views/3d/layers/GaussianSplatLayerViewPerformanceInfo.js +5 -0
  163. package/views/3d/layers/I3SMeshView3D.js +1 -1
  164. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  165. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  166. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  167. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  168. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  169. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  170. package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
  171. package/views/3d/state/ViewState.js +1 -1
  172. package/views/3d/state/ViewStateManager.js +1 -1
  173. package/views/3d/support/ResourceController.js +1 -1
  174. package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
  175. package/views/3d/support/orientedBoundingBox.js +1 -1
  176. package/views/3d/terrain/TerrainRenderer.js +1 -1
  177. package/views/3d/webgl/RenderNode.js +1 -1
  178. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  179. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  180. package/views/3d/webgl-engine/collections/Component/{ComponentObjectElevationAgnosticComponentBVH.js → ComponentObjectElevationAgnosticBVH.js} +1 -1
  181. package/views/3d/webgl-engine/collections/Component/ComponentObjectFixedBVH.js +5 -0
  182. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  183. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  184. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  185. package/views/3d/webgl-engine/collections/Component/ObjectParameters.js +1 -1
  186. package/views/3d/webgl-engine/collections/Component/SourceGeometry.js +1 -1
  187. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
  188. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  189. package/views/3d/webgl-engine/effects/weather/SnowCover.glsl.js +0 -3
  190. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  191. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  192. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  193. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  194. package/views/3d/webgl-engine/materials/PathTechniqueConfiguration.js +1 -1
  195. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  196. package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
  197. package/views/GroundView.js +1 -1
  198. package/views/interactive/dragEventPipeline.js +1 -1
  199. package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
  200. package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
  201. package/views/support/Scheduler.js +1 -1
  202. package/widgets/ScaleRangeSlider.js +1 -1
  203. package/assets/esri/core/workers/chunks/09c2004126f4a5242b85.js +0 -1
  204. package/assets/esri/core/workers/chunks/0dfc2ca36014910457ef.js +0 -1
  205. package/assets/esri/core/workers/chunks/1c7fffb496af6f2540dd.js +0 -1
  206. package/assets/esri/core/workers/chunks/1fc6311d4f0d27e88737.js +0 -1
  207. package/assets/esri/core/workers/chunks/2fe96bf7dedef11a3b63.js +0 -1
  208. package/assets/esri/core/workers/chunks/36a006c55766f9540bfc.js +0 -1
  209. package/assets/esri/core/workers/chunks/5f0a50ebd2a08b9b9de2.js +0 -1
  210. package/assets/esri/core/workers/chunks/637a5293e36f4f7f2853.js +0 -1
  211. package/assets/esri/core/workers/chunks/7540b34e743a23e67729.js +0 -1
  212. package/assets/esri/core/workers/chunks/7be11a3ef1f49245089f.js +0 -1
  213. package/assets/esri/core/workers/chunks/819a8bc1f0a694017ee6.js +0 -1
  214. package/assets/esri/core/workers/chunks/88d8ff0140f5ea97c6b7.js +0 -1
  215. package/assets/esri/core/workers/chunks/8de11aab65d91e7f1a4d.js +0 -1
  216. package/assets/esri/core/workers/chunks/96740c75ad65d651cc43.js +0 -1
  217. package/assets/esri/core/workers/chunks/9971de3f38a55735cec9.js +0 -1
  218. package/assets/esri/core/workers/chunks/9e47f680b66320dcfd34.js +0 -1
  219. package/assets/esri/core/workers/chunks/a7fcb60d5a9d2d9560e4.js +0 -1
  220. package/assets/esri/core/workers/chunks/a9e133166e9200fe135e.js +0 -1
  221. package/assets/esri/core/workers/chunks/aa84775399420e35c6a5.js +0 -1
  222. package/assets/esri/core/workers/chunks/acb1c5dd987c801d7b31.js +0 -1
  223. package/assets/esri/core/workers/chunks/b0508c96338d7cf296c1.js +0 -1
  224. package/assets/esri/core/workers/chunks/b09b34f64a6bc2b49e0a.js +0 -1
  225. package/assets/esri/core/workers/chunks/c0ae186620b68d43b338.js +0 -1
  226. package/assets/esri/core/workers/chunks/cc579c94438f48a0dbab.js +0 -1
  227. package/assets/esri/core/workers/chunks/ce0bf0d0cd9e9a90093b.js +0 -1
package/PopupTemplate.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{ClonableMixin as e}from"./core/Clonable.js";import o from"./core/Collection.js";import{JSONSupport as s}from"./core/JSONSupport.js";import{clone as i}from"./core/lang.js";import r from"./core/Logger.js";import{isPromiseLike as n}from"./core/promiseUtils.js";import{property as p}from"./core/accessorSupport/decorators/property.js";import{cast as l}from"./core/accessorSupport/decorators/cast.js";import{reader as a}from"./core/accessorSupport/decorators/reader.js";import{subclass as d}from"./core/accessorSupport/decorators/subclass.js";import{writer as c}from"./core/accessorSupport/decorators/writer.js";import{ensureOneOfType as f}from"./core/accessorSupport/ensureType.js";import{collectFields as m,collectArcadeFieldNames as u,extractSubstitutionTemplatesFromString as h}from"./layers/support/fieldUtils.js";import{persistableWebSceneTypes as y,persistableTypes as I}from"./popup/content.js";import F from"./popup/ExpressionInfo.js";import _ from"./popup/FieldInfo.js";import w from"./popup/LayerOptions.js";import x from"./popup/RelatedRecordsInfo.js";import{types as g}from"./popup/content/support/mediaInfoTypes.js";import N from"./support/actions/ActionBase.js";import A from"./support/actions/ActionButton.js";import C from"./support/actions/ActionToggle.js";import j from"./popup/content/UtilityNetworkAssociationsContent.js";import S from"./popup/content/RelationshipContent.js";import E from"./popup/content/ExpressionContent.js";import R from"./popup/content/FieldsContent.js";import O from"./popup/content/AttachmentsContent.js";import T from"./popup/content/TextContent.js";import v from"./popup/content/CustomContent.js";import b from"./popup/content/MediaContent.js";import J from"./popup/content/Content.js";const B="relationships/",L="expression/",M=o.ofType({key:"type",defaultKeyValue:"button",base:N,typeMap:{button:A,toggle:C}}),P={base:J,key:"type",typeMap:{media:b,custom:v,text:T,attachments:O,fields:R,expression:E,relationship:S,utilityNetworkAssociations:j}},W=new Set(["attachments","fields","media","text","expression","relationship"]),k=new Set([...W,"utility-network-associations"]);let U=class extends(e(s)){constructor(t){super(t),this.actions=null,this.content="",this.expressionInfos=null,this.fieldInfos=null,this.layerOptions=null,this.lastEditInfoEnabled=!0,this.outFields=null,this.overwriteActions=!1,this.returnGeometry=!1,this.title=""}castContent(t){return Array.isArray(t)?t.map(t=>f(P,t)):"string"==typeof t||"function"==typeof t||t instanceof HTMLElement||n(t)?t:(r.getLogger(this).error("content error","unsupported content value",{value:t}),null)}readContent(t,e){const{popupElements:o}=e;return Array.isArray(o)&&o.length>0?this._readPopupInfoElements(e.description,e.mediaInfos,o):this._readPopupInfo(e)}writeWebSceneContent(t,e,o,s){this._writePopupTemplateContent(t,e,s)}writeWebMapContent(t,e,o,s){this._writePopupTemplateContent(t,e,s)}writeFieldInfos(t,e,o,s){const{content:i}=this,r=Array.isArray(i)?i:null;if(t){const o=r?r.filter(t=>"fields"===t.type):[],i=o.length&&o.every(t=>t.fieldInfos?.length);e.fieldInfos=t.filter(Boolean).map(t=>{const e=t.toJSON(s);return i&&(e.visible=!1),e})}if(r)for(const n of r)"fields"===n.type&&this._writeFieldsContent(n,e)}writeLayerOptions(t,e,o,s){e[o]=!t||null===t.showNoDataRecords&&null===t.returnTopmostRaster?null:t.toJSON(s)}writeTitle(t,e){e.title=t||""}async collectRequiredFields(t,e,o){const s=this.expressionInfos||[];await this._collectExpressionInfoFields(t,e,o,[...s,...this._getContentExpressionInfos(this.content,s)]),m(t,e,[...this.outFields||[],...this._getActionsFields(this.actions),...this._getTitleFields(this.title),...this._getContentFields(this.content)])}async getRequiredFields(t,e){const o=new Set;return await this.collectRequiredFields(o,t,e),[...o].sort()}_writePopupTemplateContent(t,e,o){"string"!=typeof t?Array.isArray(t)&&(e.popupElements=t.filter(t=>"web-scene"===o?.origin?W.has(t.type):k.has(t.type)).map(t=>t?.toJSON(o)),e.popupElements.forEach(t=>{"attachments"===t.type?this._writeAttachmentContent(e):"media"===t.type?this._writeMediaContent(t,e):"text"===t.type?this._writeTextContent(t,e):"relationship"===t.type&&this._writeRelationshipContent(t,e)})):e.description=t}_writeFieldsContent(t,e){if(!Array.isArray(t.fieldInfos)||!t.fieldInfos.length)return;const o=i(t.fieldInfos);Array.isArray(e.fieldInfos)?o.forEach(t=>{const o=e.fieldInfos.find(e=>e.fieldName?.toLowerCase()===t.fieldName?.toLowerCase());o?o.visible=!0:e.fieldInfos.push(t)}):e.fieldInfos=o}_writeAttachmentContent(t){t.showAttachments||(t.showAttachments=!0)}_writeRelationshipContent(t,e){const o=t.orderByFields?.map(e=>this._toFieldOrderJSON(e,t.relationshipId))||[],s=[...e.relatedRecordsInfo?.orderByFields||[],...o];e.relatedRecordsInfo={showRelatedRecords:!0,...s?.length&&{orderByFields:s}}}_writeTextContent(t,e){!e.description&&t.text&&(e.description=t.text)}_writeMediaContent(t,e){if(!Array.isArray(t.mediaInfos)||!t.mediaInfos.length)return;const o=i(t.mediaInfos);Array.isArray(e.mediaInfos)?e.mediaInfos=[...e.mediaInfos,...o]:e.mediaInfos=o}_readPopupInfoElements(t,e,o){const s={description:!1,mediaInfos:!1};return o.map(o=>"media"===o.type?(o.mediaInfos||!e||s.mediaInfos||(o.mediaInfos=e,s.mediaInfos=!0),b.fromJSON(o)):"text"===o.type?(o.text||!t||s.description||(o.text=t,s.description=!0),T.fromJSON(o)):"attachments"===o.type?O.fromJSON(o):"fields"===o.type?R.fromJSON(o):"expression"===o.type?E.fromJSON(o):"relationship"===o.type?S.fromJSON(o):"utilityNetworkAssociations"===o.type?j.fromJSON(o):void 0).filter(Boolean)}_toRelationshipContent(t){const{field:e,order:o}=t;if(!e?.startsWith(B))return null;const s=e.replace(B,"").split("/");if(2!==s.length)return null;const i=parseInt(s[0],10),r=s[1];return!Number.isNaN(i)&&r?S.fromJSON({relationshipId:i,orderByFields:[{field:r,order:o}]}):null}_toFieldOrderJSON(t,e){const{order:o,field:s}=t;return{field:`${B}${e}/${s}`,order:o}}_readPopupInfo({description:t,mediaInfos:e,showAttachments:o,relatedRecordsInfo:s={showRelatedRecords:!1}}){const i=[];t?i.push(new T({text:t})):i.push(new R),Array.isArray(e)&&e.length&&i.push(b.fromJSON({mediaInfos:e})),o&&i.push(O.fromJSON({displayType:"auto"}));const{showRelatedRecords:r,orderByFields:n}=s;return r&&n?.length&&n.forEach(t=>{const e=this._toRelationshipContent(t);e&&i.push(e)}),i.length?i:t}_getContentElementFields(t){const e=t?.type;if("attachments"===e)return[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description)];if("custom"===e)return t.outFields||[];if("fields"===e)return[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description),...this._getFieldInfoFields(t.fieldInfos??this.fieldInfos)];if("media"===e){const e=t.mediaInfos||[];return[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description),...e.reduce((t,e)=>[...t,...this._getMediaInfoFields(e)],[])]}return"text"===e?this._extractFieldNames(t.text):"relationship"===e||"utility-network-associations"===e?[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description)]:[]}_getMediaInfoFields(t){const{caption:e,title:o,value:s}=t,i=s||{},{fields:r,normalizeField:n,tooltipField:p,sourceURL:l,linkURL:a}=i,d=[...this._extractFieldNames(o),...this._extractFieldNames(e),...this._extractFieldNames(l),...this._extractFieldNames(a),...r??[]];return n&&d.push(n),p&&d.push(p),d}_getContentExpressionInfos(t,e){return Array.isArray(t)?t.reduce((t,e)=>[...t,..."expression"===e.type&&e.expressionInfo?[e.expressionInfo]:[]],e):[]}_getContentFields(t){return"string"==typeof t?this._extractFieldNames(t):Array.isArray(t)?t.reduce((t,e)=>[...t,...this._getContentElementFields(e)],[]):[]}async _collectExpressionInfoFields(t,e,o,s){s&&await Promise.all(s.map(s=>u(t,e,o,s.expression)))}_getFieldInfoFields(t){return t?t.filter(({fieldName:t,visible:e})=>!(void 0!==e&&!e||!t||t.startsWith(B)||t.startsWith(L))).map(t=>t.fieldName):[]}_getActionsFields(t){return t?t.toArray().reduce((t,e)=>[...t,...this._getActionFields(e)],[]):[]}_getActionFields(t){const{className:e,title:o,type:s}=t,i="button"===s||"toggle"===s?t.image:"";return[...this._extractFieldNames(o),...this._extractFieldNames(e),...this._extractFieldNames(i)]}_getTitleFields(t){return"string"==typeof t?this._extractFieldNames(t):[]}_extractFieldNames(t){return h(t).filter(t=>!(t.startsWith(B)||t.startsWith(L)))}};t([p({type:M})],U.prototype,"actions",void 0),t([p()],U.prototype,"content",void 0),t([l("content")],U.prototype,"castContent",null),t([a("content",["description","fieldInfos","popupElements","mediaInfos","showAttachments","relatedRecordsInfo"])],U.prototype,"readContent",null),t([c("web-scene","content",{popupElements:{type:o.ofType(y)},showAttachments:{type:Boolean},mediaInfos:{type:o.ofType(g)},description:{type:String},relatedRecordsInfo:{type:x}})],U.prototype,"writeWebSceneContent",null),t([c("content",{popupElements:{type:o.ofType(I)},showAttachments:{type:Boolean},mediaInfos:{type:o.ofType(g)},description:{type:String},relatedRecordsInfo:{type:x}})],U.prototype,"writeWebMapContent",null),t([p({type:[F],json:{write:!0}})],U.prototype,"expressionInfos",void 0),t([p({type:[_]})],U.prototype,"fieldInfos",void 0),t([c("fieldInfos")],U.prototype,"writeFieldInfos",null),t([p({type:w})],U.prototype,"layerOptions",void 0),t([c("layerOptions")],U.prototype,"writeLayerOptions",null),t([p({type:Boolean,json:{read:{source:"showLastEditInfo"},write:{target:"showLastEditInfo"},default:!0}})],U.prototype,"lastEditInfoEnabled",void 0),t([p()],U.prototype,"outFields",void 0),t([p()],U.prototype,"overwriteActions",void 0),t([p()],U.prototype,"returnGeometry",void 0),t([p({json:{type:String}})],U.prototype,"title",void 0),t([c("title")],U.prototype,"writeTitle",null),U=t([d("esri.PopupTemplate")],U);const q=U;export{q as default};
5
+ import{__decorate as t}from"tslib";import{ClonableMixin as e}from"./core/Clonable.js";import o from"./core/Collection.js";import{JSONSupport as s}from"./core/JSONSupport.js";import{clone as i}from"./core/lang.js";import r from"./core/Logger.js";import{isPromiseLike as n}from"./core/promiseUtils.js";import{property as p}from"./core/accessorSupport/decorators/property.js";import{cast as a}from"./core/accessorSupport/decorators/cast.js";import{reader as l}from"./core/accessorSupport/decorators/reader.js";import{subclass as d}from"./core/accessorSupport/decorators/subclass.js";import{writer as c}from"./core/accessorSupport/decorators/writer.js";import{ensureOneOfType as m}from"./core/accessorSupport/ensureType.js";import{collectFields as f,collectArcadeFieldNames as u,extractSubstitutionTemplatesFromString as h}from"./layers/support/fieldUtils.js";import{persistableWebSceneTypes as y,persistableTypes as I}from"./popup/content.js";import F from"./popup/ExpressionInfo.js";import w from"./popup/FieldInfo.js";import _ from"./popup/LayerOptions.js";import x from"./popup/RelatedRecordsInfo.js";import{types as g}from"./popup/content/support/mediaInfoTypes.js";import N from"./support/actions/ActionBase.js";import A from"./support/actions/ActionButton.js";import C from"./support/actions/ActionToggle.js";import j from"./popup/content/UtilityNetworkAssociationsContent.js";import S from"./popup/content/RelationshipContent.js";import O from"./popup/content/ExpressionContent.js";import R from"./popup/content/FieldsContent.js";import E from"./popup/content/AttachmentsContent.js";import T from"./popup/content/TextContent.js";import v from"./popup/content/CustomContent.js";import b from"./popup/content/MediaContent.js";import J from"./popup/content/Content.js";const B="relationships/",L="expression/",M=o.ofType({key:"type",defaultKeyValue:"button",base:N,typeMap:{button:A,toggle:C}}),P={base:J,key:"type",typeMap:{media:b,custom:v,text:T,attachments:E,fields:R,expression:O,relationship:S,utilityNetworkAssociations:j}},W=new Set(["attachments","fields","media","text","expression","relationship"]),k=new Set([...W,"utility-network-associations"]);let U=class extends(e(s)){constructor(t){super(t),this.actions=null,this.content="",this.expressionInfos=null,this.fieldInfos=null,this.layerOptions=null,this.lastEditInfoEnabled=!0,this.outFields=null,this.overwriteActions=!1,this.returnGeometry=!1,this.title=""}castContent(t){return Array.isArray(t)?t.map(t=>m(P,t)):"string"==typeof t||"function"==typeof t||t instanceof HTMLElement||n(t)?t:(r.getLogger(this).error("content error","unsupported content value",{value:t}),null)}readContent(t,e){const{popupElements:o}=e;return Array.isArray(o)&&o.length>0?this._readPopupInfoElements(e.description,e.mediaInfos,o):this._readPopupInfo(e)}writeWebSceneContent(t,e,o,s){this._writePopupTemplateContent(t,e,s)}writeWebMapContent(t,e,o,s){this._writePopupTemplateContent(t,e,s)}writeFieldInfos(t,e,o,s){const{content:i}=this,r=Array.isArray(i)?i:null,{writeFieldFormat:n,...p}=s||{};if(t){const o=r?r.filter(t=>"fields"===t.type):[],s=o.length&&o.every(t=>t.fieldInfos?.length);e.fieldInfos=t.filter(Boolean).map(t=>{const e=t.toJSON(p);return s&&(e.visible=!1),e})}if(r)for(const a of r)"fields"===a.type&&this._writeFieldsContent(a,e,p)}writeLayerOptions(t,e,o,s){e[o]=!t||null===t.showNoDataRecords&&null===t.returnTopmostRaster?null:t.toJSON(s)}writeTitle(t,e){e.title=t||""}async collectRequiredFields(t,e,o){const s=this.expressionInfos||[];await this._collectExpressionInfoFields(t,e,o,[...s,...this._getContentExpressionInfos(this.content,s)]),f(t,e,[...this.outFields||[],...this._getActionsFields(this.actions),...this._getTitleFields(this.title),...this._getContentFields(this.content)])}async getRequiredFields(t,e){const o=new Set;return await this.collectRequiredFields(o,t,e),[...o].sort()}_writePopupTemplateContent(t,e,o){"string"!=typeof t?Array.isArray(t)&&(e.popupElements=t.filter(t=>"web-scene"===o?.origin?W.has(t.type):k.has(t.type)).map(t=>t?.toJSON(o)),e.popupElements.forEach(t=>{"attachments"===t.type?this._writeAttachmentContent(e):"media"===t.type?this._writeMediaContent(t,e):"text"===t.type?this._writeTextContent(t,e):"relationship"===t.type&&this._writeRelationshipContent(t,e)})):e.description=t}_writeFieldsContent(t,e,o){const s=t.fieldInfos;if(!Array.isArray(s)||!s.length)return;const i=e.fieldInfos;if(Array.isArray(i))for(const r of s){const t=i.find(t=>t.fieldName?.toLowerCase()===r.fieldName?.toLowerCase());t?t.visible=!0:i.push(r.toJSON(o))}else e.fieldInfos=s.map(t=>t.toJSON(o))}_writeAttachmentContent(t){t.showAttachments||(t.showAttachments=!0)}_writeRelationshipContent(t,e){const o=t.orderByFields?.map(e=>this._toFieldOrderJSON(e,t.relationshipId))||[],s=[...e.relatedRecordsInfo?.orderByFields||[],...o];e.relatedRecordsInfo={showRelatedRecords:!0,...s?.length&&{orderByFields:s}}}_writeTextContent(t,e){!e.description&&t.text&&(e.description=t.text)}_writeMediaContent(t,e){if(!Array.isArray(t.mediaInfos)||!t.mediaInfos.length)return;const o=i(t.mediaInfos);Array.isArray(e.mediaInfos)?e.mediaInfos=[...e.mediaInfos,...o]:e.mediaInfos=o}_readPopupInfoElements(t,e,o){const s={description:!1,mediaInfos:!1};return o.map(o=>"media"===o.type?(o.mediaInfos||!e||s.mediaInfos||(o.mediaInfos=e,s.mediaInfos=!0),b.fromJSON(o)):"text"===o.type?(o.text||!t||s.description||(o.text=t,s.description=!0),T.fromJSON(o)):"attachments"===o.type?E.fromJSON(o):"fields"===o.type?R.fromJSON(o):"expression"===o.type?O.fromJSON(o):"relationship"===o.type?S.fromJSON(o):"utilityNetworkAssociations"===o.type?j.fromJSON(o):void 0).filter(Boolean)}_toRelationshipContent(t){const{field:e,order:o}=t;if(!e?.startsWith(B))return null;const s=e.replace(B,"").split("/");if(2!==s.length)return null;const i=parseInt(s[0],10),r=s[1];return!Number.isNaN(i)&&r?S.fromJSON({relationshipId:i,orderByFields:[{field:r,order:o}]}):null}_toFieldOrderJSON(t,e){const{order:o,field:s}=t;return{field:`${B}${e}/${s}`,order:o}}_readPopupInfo({description:t,mediaInfos:e,showAttachments:o,relatedRecordsInfo:s={showRelatedRecords:!1}}){const i=[];t?i.push(new T({text:t})):i.push(new R),Array.isArray(e)&&e.length&&i.push(b.fromJSON({mediaInfos:e})),o&&i.push(E.fromJSON({displayType:"auto"}));const{showRelatedRecords:r,orderByFields:n}=s;return r&&n?.length&&n.forEach(t=>{const e=this._toRelationshipContent(t);e&&i.push(e)}),i.length?i:t}_getContentElementFields(t){const e=t?.type;if("attachments"===e)return[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description)];if("custom"===e)return t.outFields||[];if("fields"===e)return[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description),...this._getFieldInfoFields(t.fieldInfos??this.fieldInfos)];if("media"===e){const e=t.mediaInfos||[];return[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description),...e.reduce((t,e)=>[...t,...this._getMediaInfoFields(e)],[])]}return"text"===e?this._extractFieldNames(t.text):"relationship"===e||"utility-network-associations"===e?[...this._extractFieldNames(t.title),...this._extractFieldNames(t.description)]:[]}_getMediaInfoFields(t){const{caption:e,title:o,value:s}=t,i=s||{},{fields:r,normalizeField:n,tooltipField:p,sourceURL:a,linkURL:l}=i,d=[...this._extractFieldNames(o),...this._extractFieldNames(e),...this._extractFieldNames(a),...this._extractFieldNames(l),...r??[]];return n&&d.push(n),p&&d.push(p),d}_getContentExpressionInfos(t,e){return Array.isArray(t)?t.reduce((t,e)=>[...t,..."expression"===e.type&&e.expressionInfo?[e.expressionInfo]:[]],e):[]}_getContentFields(t){return"string"==typeof t?this._extractFieldNames(t):Array.isArray(t)?t.reduce((t,e)=>[...t,...this._getContentElementFields(e)],[]):[]}async _collectExpressionInfoFields(t,e,o,s){s&&await Promise.all(s.map(s=>u(t,e,o,s.expression)))}_getFieldInfoFields(t){return t?t.filter(({fieldName:t,visible:e})=>!(void 0!==e&&!e||!t||t.startsWith(B)||t.startsWith(L))).map(t=>t.fieldName):[]}_getActionsFields(t){return t?t.toArray().reduce((t,e)=>[...t,...this._getActionFields(e)],[]):[]}_getActionFields(t){const{className:e,title:o,type:s}=t,i="button"===s||"toggle"===s?t.image:"";return[...this._extractFieldNames(o),...this._extractFieldNames(e),...this._extractFieldNames(i)]}_getTitleFields(t){return"string"==typeof t?this._extractFieldNames(t):[]}_extractFieldNames(t){return h(t).filter(t=>!(t.startsWith(B)||t.startsWith(L)))}};t([p({type:M})],U.prototype,"actions",void 0),t([p()],U.prototype,"content",void 0),t([a("content")],U.prototype,"castContent",null),t([l("content",["description","fieldInfos","popupElements","mediaInfos","showAttachments","relatedRecordsInfo"])],U.prototype,"readContent",null),t([c("web-scene","content",{popupElements:{type:o.ofType(y)},showAttachments:{type:Boolean},mediaInfos:{type:o.ofType(g)},description:{type:String},relatedRecordsInfo:{type:x}})],U.prototype,"writeWebSceneContent",null),t([c("content",{popupElements:{type:o.ofType(I)},showAttachments:{type:Boolean},mediaInfos:{type:o.ofType(g)},description:{type:String},relatedRecordsInfo:{type:x}})],U.prototype,"writeWebMapContent",null),t([p({type:[F],json:{write:!0}})],U.prototype,"expressionInfos",void 0),t([p({type:[w]})],U.prototype,"fieldInfos",void 0),t([c("fieldInfos")],U.prototype,"writeFieldInfos",null),t([p({type:_})],U.prototype,"layerOptions",void 0),t([c("layerOptions")],U.prototype,"writeLayerOptions",null),t([p({type:Boolean,json:{read:{source:"showLastEditInfo"},write:{target:"showLastEditInfo"},default:!0}})],U.prototype,"lastEditInfoEnabled",void 0),t([p()],U.prototype,"outFields",void 0),t([p()],U.prototype,"overwriteActions",void 0),t([p()],U.prototype,"returnGeometry",void 0),t([p({json:{type:String}})],U.prototype,"title",void 0),t([c("title")],U.prototype,"writeTitle",null),U=t([d("esri.PopupTemplate")],U);const q=U;export{q 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as t}from"./ArcadeDate.js";import{deepClone as e}from"./deepClone.js";import{ArcadeExecutionError as s}from"./executionError.js";import{i as r,c as i,a as n,b as o,d as a,e as u,f as l,g as c,h as b}from"../chunks/languageUtils.js";import h from"../geometry/Geometry.js";import{isNumber as f,isBoolean as m,isString as d,isArray as w}from"../support/guards.js";function y(t,e,s=!1,r=!1){if(null==t)return null;if(f(t)||m(t)||d(t)||u(t)||l(t)||c(t))return t;if(w(t)){const i=[];for(const n of t)i.push(y(n,e,s,r));return i}if(r&&b(t))return t;const i=new p;i.immutable=!1;for(const[n,o]of Object.entries(t))void 0!==o&&i.setField(n,y(o,e,s,r));return i.immutable=s,i}class p{constructor(t){this.declaredClass="esri.arcade.Dictionary",this.plain=!1,this.immutable=!0,t instanceof p?this.attributes=t.attributes:null==t?this.attributes=Object.create(null):null!=Object.getPrototypeOf(t)?this.attributes={__proto__:null,...t}:this.attributes=t}static containerEntry(t,e){return new p({__proto__:null,key:t,value:e})}static textFormatting(){const t=new p({__proto__:null,newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});return t.immutable=!1,t}field(t){const e=t.toLowerCase(),r=this.attributes[t];if(void 0!==r)return r;for(const s in this.attributes)if(s.toLowerCase()===e)return this.attributes[s];throw new s(null,"FieldNotFound",null,{key:t})}setField(e,i){if(this.immutable)throw new s(null,"Immutable",null);if(r(i))throw new s(null,"NoFunctionInDictionary",null);const n=e.toLowerCase();i instanceof Date&&(i=t.dateJSToArcadeDate(i));if(void 0===this.attributes[e]){for(const t in this.attributes)if(t.toLowerCase()===n)return void(this.attributes[t]=i);this.attributes[e]=i}else this.attributes[e]=i}eraseField(t){if(this.immutable)throw new s(null,"Immutable",null);if(t in this.attributes)return void delete this.attributes[t];const e=t.toLowerCase();for(const s in this.attributes)if(s.toLowerCase()===e)return void delete this.attributes[s]}hasField(t){const e=t.toLowerCase();if(void 0!==this.attributes[t])return!0;for(const s in this.attributes)if(s.toLowerCase()===e)return!0;return!1}keys(){let t=[];for(const e in this.attributes)t.push(e);return t=t.sort(),t}values(){return this.keys().map(t=>this.attributes[t])}entryCount(){return Object.keys(this.attributes).length}castToText(t=!1){return i(this.attributes,{useNumbersForDates:t})}static convertObjectToArcadeDictionary(t,e,s=!0,r=!1){const i=new p;i.immutable=!1;for(const n in t){const o=t[n];void 0!==o&&i.setField(n.toString(),y(o,e,s,r))}return i.immutable=s,i}static convertJsonToArcade(t,e,s=!1,r=!1){return y(t,e,s,r)}castAsJson(t=null){const e=Object.create(null);for(let s in this.attributes){const r=this.attributes[s];void 0!==r&&(t?.keyTranslate&&(s=t.keyTranslate(s)),e[s]=n(r,t))}return e}async castDictionaryValueAsJsonAsync(t,e,s,r=null,i){const n=await o(s,r,i);return t[e]=n,n}async castAsJsonAsync(e=null,s=null){const r=Object.create(null),i=[];for(let o in this.attributes){const u=this.attributes[o];s?.keyTranslate&&(o=s.keyTranslate(o)),void 0!==u&&(a(u)||u instanceof h||u instanceof t?r[o]=n(u,s):i.push(this.castDictionaryValueAsJsonAsync(r,o,u,e,s)))}return i.length>0&&await Promise.all(i),r}deepClone(){const t=new p;t.immutable=!1;for(const s of this.keys())t.setField(s,e(this.field(s)));return t}}export{p as default};
5
+ import{ArcadeDate as t}from"./ArcadeDate.js";import{deepClone as e}from"./deepClone.js";import{ArcadeExecutionError as s}from"./executionError.js";import{i as r,c as i,a as n,b as o,d as a,e as u,f as l,g as c,h as b}from"../chunks/languageUtils.js";import h from"../geometry/Geometry.js";import{isNumber as f,isBoolean as m,isString as d,isArray as y}from"../support/guards.js";function w(t,e,s=!1,r=!1){if(null==t)return null;if(f(t)||m(t)||d(t)||u(t)||l(t)||c(t))return t;if(y(t)){const i=[];for(const n of t)i.push(w(n,e,s,r));return i}if(r&&b(t))return t;const i=new p;i.immutable=!1;for(const[n,o]of Object.entries(t))void 0!==o&&i.setField(n,w(o,e,s,r));return i.immutable=s,i}class p{constructor(t){this.declaredClass="esri.arcade.Dictionary",this.plain=!1,this.immutable=!0,t instanceof p?this.attributes=t.attributes:null==t?this.attributes=Object.create(null):null!=Object.getPrototypeOf(t)?this.attributes={__proto__:null,...t}:this.attributes=t}static containerEntry(t,e){return new p({__proto__:null,key:t,value:e})}static textFormatting(){const t=new p({__proto__:null,newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});return t.immutable=!1,t}field(t){const e=t.toLowerCase(),r=this.attributes[t];if(void 0!==r)return r;for(const s in this.attributes)if(s.toLowerCase()===e)return this.attributes[s];throw new s(null,"FieldNotFound",null,{key:t})}setField(e,i){if(this.immutable)throw new s(null,"Immutable",null);if(r(i))throw new s(null,"NoFunctionInDictionary",null);const n=e.toLowerCase();i instanceof Date&&(i=t.dateJSToArcadeDate(i));if(void 0===this.attributes[e]){for(const t in this.attributes)if(t.toLowerCase()===n)return void(this.attributes[t]=i);this.attributes[e]=i}else this.attributes[e]=i}eraseField(t){if(this.immutable)throw new s(null,"Immutable",null);if(t in this.attributes)return void delete this.attributes[t];const e=t.toLowerCase();for(const s in this.attributes)if(s.toLowerCase()===e)return void delete this.attributes[s]}hasField(t){const e=t.toLowerCase();if(void 0!==this.attributes[t])return!0;for(const s in this.attributes)if(s.toLowerCase()===e)return!0;return!1}keys(){let t=[];for(const e in this.attributes)t.push(e);return t=t.sort(),t}values(){return this.keys().map(t=>this.attributes[t])}entryCount(){return Object.keys(this.attributes).length}isEmpty(){return this.entryCount()<=0}castToText(t=!1){return i(this.attributes,{useNumbersForDates:t})}static convertObjectToArcadeDictionary(t,e,s=!0,r=!1){const i=new p;i.immutable=!1;for(const n in t){const o=t[n];void 0!==o&&i.setField(n.toString(),w(o,e,s,r))}return i.immutable=s,i}static convertJsonToArcade(t,e,s=!1,r=!1){return w(t,e,s,r)}castAsJson(t=null){const e=Object.create(null);for(let s in this.attributes){const r=this.attributes[s];void 0!==r&&(t?.keyTranslate&&(s=t.keyTranslate(s)),e[s]=n(r,t))}return e}async castDictionaryValueAsJsonAsync(t,e,s,r=null,i){const n=await o(s,r,i);return t[e]=n,n}async castAsJsonAsync(e=null,s=null){const r=Object.create(null),i=[];for(let o in this.attributes){const u=this.attributes[o];s?.keyTranslate&&(o=s.keyTranslate(o)),void 0!==u&&(a(u)||u instanceof h||u instanceof t?r[o]=n(u,s):i.push(this.castDictionaryValueAsJsonAsync(r,o,u,e,s)))}return i.length>0&&await Promise.all(i),r}deepClone(){const t=new p;t.immutable=!1;for(const s of this.keys())t.setField(s,e(this.field(s)));return t}}export{p as default};
package/arcade/Feature.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as e}from"./ArcadeDate.js";import{configureDeepClone as t}from"./deepClone.js";import i from"./Dictionary.js";import{ArcadeExecutionError as s}from"./executionError.js";import{m as r,c as n,t as a,d as o,e as l,g as d,f as u,a as m}from"../chunks/languageUtils.js";import{constructGeometryFromDictionary as y}from"./geometry/constructors.js";import{DateOnly as c}from"../core/sql/DateOnly.js";import{TimeOnly as f}from"../core/sql/TimeOnly.js";import h from"../geometry/Geometry.js";import{fromJSON as p}from"../geometry/support/jsonUtils.js";import{convertToGeometry as _}from"../layers/graphics/featureConversionUtils.js";import T from"../layers/support/FieldsIndex.js";import{isString as g,isNumber as F,isBoolean as b,isDate as x}from"../support/guards.js";function D(e){switch(e.type){case"small-integer":case"esriFieldTypeSmallInteger":case"integer":case"esriFieldTypeInteger":case"single":case"esriFieldTypeSingle":case"double":case"esriFieldTypeDouble":case"big-integer":case"esriFieldTypeBigInteger":case"long":case"esriFieldTypeLong":case"oid":case"esriFieldTypeOID":return{name:e.name,type:"number"};case"global-id":case"esriFieldTypeGlobalID":case"guid":case"esriFieldTypeGUID":case"string":case"esriFieldTypeString":return{name:e.name,type:"text"};case"date":case"esriFieldTypeDate":case"timestamp-offset":case"esriFieldTypeTimestampOffset":return{name:e.name,type:"date"};case"date-only":case"esriFieldTypeDateOnly":return{name:e.name,type:"dateOnly"};case"time-only":case"esriFieldTypeTimeOnly":return{name:e.name,type:"time"};default:return null}}function w(t,i,s){if(null==t)return null;switch(i){case"time-only":return d(t)?t:f.fromReader(t.toString());case"date-only":return u(t)?t:c.fromReader(t.toString());case"timestamp-offset":return l(t)?t:e.fromReaderAsTimeStampOffset(t.toString());case"date":return l(t)?t:x(t)?e.dateJSAndZoneToArcadeDate(t,s):e.epochToArcadeDate(t,s);case"geometry":return null;default:return t}}class I{constructor(){this.arcadeDeclaredClass="esri.arcade.Feature",this._optimizedGeomDefinition=null,this._geometry=null,this.attributes=null,this._layer=null,this._fieldTypesFixed=!0,this.fieldsIndex=null,this.contextTimeZone=null,this.immutable=!0,this._fieldsToFixDataTypes=null,this.immutable=!0}static createFromGraphic(e,t){const i=new I;return i.contextTimeZone=t??null,i._geometry=null!=e.geometry?e.geometry:null,void 0===e.attributes||null===e.attributes?i.attributes={}:i.attributes=e.attributes,e._sourceLayer?(i._layer=e._sourceLayer,i._fieldTypesFixed=!1):e._layer?(i._layer=e._layer,i._fieldTypesFixed=!1):e.layer&&"fields"in e.layer?(i._layer=e.layer,i._fieldTypesFixed=!1):e.sourceLayer&&"fields"in e.sourceLayer&&(i._layer=e.sourceLayer,i._fieldTypesFixed=!1),i._layer&&!i._fieldTypesFixed&&(i.fieldsIndex=this.hydrateFieldsIndex(i._layer)),i}static createFromArcadeFeature(e){if(e instanceof I){const t=new I;return t._fieldTypesFixed=e._fieldTypesFixed,t.attributes=e.attributes,t._geometry=e._geometry,t._optimizedGeomDefinition=e._optimizedGeomDefinition,e._layer&&(t._layer=e._layer),t.fieldsIndex=e.fieldsIndex,t.contextTimeZone=e.contextTimeZone,t}const t={};for(const i of e.keys())t[i]=e.field(i);return I.createFromGraphicLikeObject(e.geometry(),t,e.fullSchema(),e.contextTimeZone)}static createFromOptimisedFeature(e,t,i){const s=new I;return s._geometry=e.geometry?{geometry:e.geometry}:null,s._optimizedGeomDefinition=i,s.attributes=e.attributes||{},s._layer=t,s._fieldTypesFixed=!1,s}static createFromArcadeDictionary(e,t){const s=new I;return s.attributes=e.field("attributes"),null!==s.attributes&&s.attributes instanceof i?(s.attributes=s.attributes.attributes,null===s.attributes&&(s.attributes={})):s.attributes={},s._geometry=e.field("geometry"),null!==s._geometry&&(s._geometry instanceof i?s._geometry=y(s._geometry,t):s._geometry instanceof h||(s._geometry=null)),s}static createFromGraphicLikeObject(e,t,i=null,s){const r=new I;return r.contextTimeZone=s??null,null===t&&(t={}),r.attributes=t,r._geometry=null!=e?e:null,r._layer=i,r._layer&&(r._fieldTypesFixed=!1,r.fieldsIndex=this.hydrateFieldsIndex(r._layer)),r}static hydrateFieldsIndex(e){return null===e?null:r(e)?e.getFieldsIndex():e.fieldsIndex?e.fieldsIndex:T.fromLayerJSON({datesInUnknownTimezone:e.datesInUnknownTimezone,fields:e.fields,timeInfo:e.timeInfo,editFieldsInfo:e.editFieldsInfo,dateFieldsTimeReference:e.dateFieldsTimeReference??{timeZone:"UTC",respectsDaylightSaving:!1}})}repurposeFromGraphicLikeObject(e,t,i=null){null===t&&(t={}),this.attributes=t,this._geometry=e??null,this._layer=i,this._layer?this._fieldTypesFixed=!1:this._fieldTypesFixed=!0}castToText(e=!1){!1===this._fieldTypesFixed&&this._fixFieldTypes();const t=n(this.attributes,{useNumbersForDates:e});return'{"geometry":'+(null===this.geometry()?"null":a(this.geometry()))+',"attributes":'+t+"}"}_fixFieldTypes(){if(this._fieldsToFixDataTypes&&this._fieldsToFixDataTypes?.length>0)return this._fixAllFields(this._fieldsToFixDataTypes),void(this._fieldTypesFixed=!0);const e=[],t=this._layer.fields;for(let i=0;i<(t?.length??0);i++){const s=t[i],{name:r,type:n}=s;switch(n){case"date":case"esriFieldTypeDate":e.push({field:r,dataType:"date"});break;case"date-only":case"esriFieldTypeDateOnly":e.push({field:r,dataType:"date-only"});break;case"time-only":case"esriFieldTypeTimeOnly":e.push({field:r,dataType:"time-only"});break;case"timestamp-offset":case"esriFieldTypeTimestampOffset":e.push({field:r,dataType:"timestamp-offset"});break;case"geometry":case"esriFieldTypeGeometry":e.push({field:r,dataType:"geometry"})}}this._fieldsToFixDataTypes=e,e.length>0&&this._fixAllFields(e),this._fieldTypesFixed=!0}isUnknownDateTimeField(e){return"unknown"===this.fieldsIndex?.getTimeZone(e)}_fixAllFields(e){this.attributes={...this.attributes};const t=this.contextTimeZone??"system";for(let i=0;i<e.length;i++){const s=e[i].field,r=e[i].dataType;let n=this.attributes[s];if(void 0===n){for(const e in this.attributes)if(e.toLowerCase()===s.toLowerCase()){n=this.attributes[e],this.attributes[e]=w(n,r,this.isUnknownDateTimeField(e)?"unknown":t);break}}else null!==n&&(this.attributes[s]=w(n,r,this.isUnknownDateTimeField(s)?"unknown":t))}}geometry(){return null===this._geometry||this._geometry instanceof h||(this._optimizedGeomDefinition?(this._geometry=p(_(this._geometry,this._optimizedGeomDefinition.geometryType,this._optimizedGeomDefinition.hasZ,this._optimizedGeomDefinition.hasM)),this._geometry.spatialReference=this._optimizedGeomDefinition.spatialReference):this._geometry=p(this._geometry)),this._geometry}field(e){this._fieldTypesFixed||this._fixFieldTypes();const t=this.attributes[e];if(void 0!==t)return t;const i=e.toLowerCase();for(const s in this.attributes)if(s.toLowerCase()===i)return this.attributes[s];if(this._hasFieldDefinition(i))return null;throw new s(null,"FieldNotFound",null,{key:e})}_hasFieldDefinition(e){if(null===this._layer)return!1;for(let t=0;t<this._layer.fields.length;t++){if(this._layer.fields[t].name.toLowerCase()===e)return!0}return!1}setField(t,i){if(this.immutable)throw new s(null,"Immutable",null);if(i instanceof Date&&(i=this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(i):e.dateJSToArcadeDate(i)),!1===o(i))throw new s(null,"TypeNotAllowedInFeature",null);const r=t.toLowerCase();if(void 0===this.attributes[t]){for(const e in this.attributes)if(e.toLowerCase()===r)return void(this.attributes[e]=i);this.attributes[t]=i}else this.attributes[t]=i}hasField(e){const t=e.toLowerCase();if(void 0!==this.attributes[e])return!0;for(const i in this.attributes)if(i.toLowerCase()===t)return!0;return!!this._hasFieldDefinition(t)}keys(){let e=[];const t={};for(const i in this.attributes)e.push(i),t[i.toLowerCase()]=1;if(null!==this._layer)for(let i=0;i<this._layer.fields.length;i++){const s=this._layer.fields[i];1!==t[s.name.toLowerCase()]&&e.push(s.name)}return e=e.sort(),e}static parseAttributesFromDictionary(e){const t={};for(const i in e.attributes){const r=e.attributes[i];if(!o(r))throw new s(null,"InvalidParameter",null);t[i]=r}return t}static fromJson(e,t){let i=null;null!==e.geometry&&void 0!==e.geometry&&(i=p(e.geometry));const r={};if(null!==e.attributes&&void 0!==e.attributes)for(const n in e.attributes){const t=e.attributes[n];if(null===t)r[n]=t;else{if(!(g(t)||F(t)||b(t)||l(t)||d(t)||u(t)))throw new s(null,"InvalidParameter",null);r[n]=t}}return I.createFromGraphicLikeObject(i,r,null,t??null)}fullSchema(){return this._layer}gdbVersion(){if(null===this._layer)return"";const e=this._layer.gdbVersion;return void 0===e?"":""===e&&this._layer.capabilities?.isVersioned?"SDE.DEFAULT":e}castAsJson(e){const t={attributes:{},geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null};for(const i in this.attributes){const s=this.attributes[i];void 0!==s&&(t.attributes[i]=m(s,e))}return t}async castAsJsonAsync(e=null,t){return this.castAsJson(t)}}t(I);export{I as Feature,w as convertAttributeToArcadeValue,D as getArcadeVariableForField};
5
+ import{ArcadeDate as e}from"./ArcadeDate.js";import{configureDeepClone as t}from"./deepClone.js";import i from"./Dictionary.js";import{ArcadeExecutionError as s}from"./executionError.js";import{m as r,c as n,t as a,d as l,e as o,g as u,f as d,a as m}from"../chunks/languageUtils.js";import{constructGeometryFromDictionary as y}from"./geometry/constructors.js";import{DateOnly as c}from"../core/sql/DateOnly.js";import{TimeOnly as f}from"../core/sql/TimeOnly.js";import h from"../geometry/Geometry.js";import{fromJSON as p}from"../geometry/support/jsonUtils.js";import{convertToGeometry as _}from"../layers/graphics/featureConversionUtils.js";import T from"../layers/support/FieldsIndex.js";import{isString as g,isNumber as F,isBoolean as b,isDate as x}from"../support/guards.js";function D(e){switch(e.type){case"small-integer":case"esriFieldTypeSmallInteger":case"integer":case"esriFieldTypeInteger":case"single":case"esriFieldTypeSingle":case"double":case"esriFieldTypeDouble":case"big-integer":case"esriFieldTypeBigInteger":case"long":case"esriFieldTypeLong":case"oid":case"esriFieldTypeOID":return{name:e.name,type:"number"};case"global-id":case"esriFieldTypeGlobalID":case"guid":case"esriFieldTypeGUID":case"string":case"esriFieldTypeString":return{name:e.name,type:"text"};case"date":case"esriFieldTypeDate":case"timestamp-offset":case"esriFieldTypeTimestampOffset":return{name:e.name,type:"date"};case"date-only":case"esriFieldTypeDateOnly":return{name:e.name,type:"dateOnly"};case"time-only":case"esriFieldTypeTimeOnly":return{name:e.name,type:"time"};default:return null}}function w(t,i,s){if(null==t)return null;switch(i){case"time-only":return u(t)?t:f.fromReader(t.toString());case"date-only":return d(t)?t:c.fromReader(t.toString());case"timestamp-offset":return o(t)?t:e.fromReaderAsTimeStampOffset(t.toString());case"date":return o(t)?t:x(t)?e.dateJSAndZoneToArcadeDate(t,s):e.epochToArcadeDate(t,s);case"geometry":return null;default:return t}}class I{constructor(){this.arcadeDeclaredClass="esri.arcade.Feature",this._optimizedGeomDefinition=null,this._geometry=null,this.attributes=null,this._layer=null,this._fieldTypesFixed=!0,this.fieldsIndex=null,this.contextTimeZone=null,this.immutable=!0,this._fieldsToFixDataTypes=null,this.immutable=!0}static createFromGraphic(e,t){const i=new I;return i.contextTimeZone=t??null,i._geometry=null!=e.geometry?e.geometry:null,void 0===e.attributes||null===e.attributes?i.attributes={}:i.attributes=e.attributes,e._sourceLayer?(i._layer=e._sourceLayer,i._fieldTypesFixed=!1):e._layer?(i._layer=e._layer,i._fieldTypesFixed=!1):e.layer&&"fields"in e.layer?(i._layer=e.layer,i._fieldTypesFixed=!1):e.sourceLayer&&"fields"in e.sourceLayer&&(i._layer=e.sourceLayer,i._fieldTypesFixed=!1),i._layer&&!i._fieldTypesFixed&&(i.fieldsIndex=this.hydrateFieldsIndex(i._layer)),i}static createFromArcadeFeature(e){if(e instanceof I){const t=new I;return t._fieldTypesFixed=e._fieldTypesFixed,t.attributes=e.attributes,t._geometry=e._geometry,t._optimizedGeomDefinition=e._optimizedGeomDefinition,e._layer&&(t._layer=e._layer),t.fieldsIndex=e.fieldsIndex,t.contextTimeZone=e.contextTimeZone,t}const t={};for(const i of e.keys())t[i]=e.field(i);return I.createFromGraphicLikeObject(e.geometry(),t,e.fullSchema(),e.contextTimeZone)}static createFromOptimisedFeature(e,t,i){const s=new I;return s._geometry=e.geometry?{geometry:e.geometry}:null,s._optimizedGeomDefinition=i,s.attributes=e.attributes||{},s._layer=t,s._fieldTypesFixed=!1,s}static createFromArcadeDictionary(e,t){const s=new I;return s.attributes=e.field("attributes"),null!==s.attributes&&s.attributes instanceof i?(s.attributes=s.attributes.attributes,null===s.attributes&&(s.attributes={})):s.attributes={},s._geometry=e.field("geometry"),null!==s._geometry&&(s._geometry instanceof i?s._geometry=y(s._geometry,t):s._geometry instanceof h||(s._geometry=null)),s}static createFromGraphicLikeObject(e,t,i=null,s){const r=new I;return r.contextTimeZone=s??null,null===t&&(t={}),r.attributes=t,r._geometry=null!=e?e:null,r._layer=i,r._layer&&(r._fieldTypesFixed=!1,r.fieldsIndex=this.hydrateFieldsIndex(r._layer)),r}static hydrateFieldsIndex(e){return null===e?null:r(e)?e.getFieldsIndex():e.fieldsIndex?e.fieldsIndex:T.fromLayerJSON({datesInUnknownTimezone:e.datesInUnknownTimezone,fields:e.fields,timeInfo:e.timeInfo,editFieldsInfo:e.editFieldsInfo,dateFieldsTimeReference:e.dateFieldsTimeReference??{timeZone:"UTC",respectsDaylightSaving:!1}})}repurposeFromGraphicLikeObject(e,t,i=null){null===t&&(t={}),this.attributes=t,this._geometry=e??null,this._layer=i,this._layer?this._fieldTypesFixed=!1:this._fieldTypesFixed=!0}castToText(e=!1){!1===this._fieldTypesFixed&&this._fixFieldTypes();const t=n(this.attributes,{useNumbersForDates:e});return'{"geometry":'+(null===this.geometry()?"null":a(this.geometry()))+',"attributes":'+t+"}"}_fixFieldTypes(){if(this._fieldsToFixDataTypes&&this._fieldsToFixDataTypes?.length>0)return this._fixAllFields(this._fieldsToFixDataTypes),void(this._fieldTypesFixed=!0);const e=[],t=this._layer.fields;for(let i=0;i<(t?.length??0);i++){const s=t[i],{name:r,type:n}=s;switch(n){case"date":case"esriFieldTypeDate":e.push({field:r,dataType:"date"});break;case"date-only":case"esriFieldTypeDateOnly":e.push({field:r,dataType:"date-only"});break;case"time-only":case"esriFieldTypeTimeOnly":e.push({field:r,dataType:"time-only"});break;case"timestamp-offset":case"esriFieldTypeTimestampOffset":e.push({field:r,dataType:"timestamp-offset"});break;case"geometry":case"esriFieldTypeGeometry":e.push({field:r,dataType:"geometry"})}}this._fieldsToFixDataTypes=e,e.length>0&&this._fixAllFields(e),this._fieldTypesFixed=!0}isUnknownDateTimeField(e){return"unknown"===this.fieldsIndex?.getTimeZone(e)}_fixAllFields(e){this.attributes={...this.attributes};const t=this.contextTimeZone??"system";for(let i=0;i<e.length;i++){const s=e[i].field,r=e[i].dataType;let n=this.attributes[s];if(void 0===n){for(const e in this.attributes)if(e.toLowerCase()===s.toLowerCase()){n=this.attributes[e],this.attributes[e]=w(n,r,this.isUnknownDateTimeField(e)?"unknown":t);break}}else null!==n&&(this.attributes[s]=w(n,r,this.isUnknownDateTimeField(s)?"unknown":t))}}geometry(){return null===this._geometry||this._geometry instanceof h||(this._optimizedGeomDefinition?(this._geometry=p(_(this._geometry,this._optimizedGeomDefinition.geometryType,this._optimizedGeomDefinition.hasZ,this._optimizedGeomDefinition.hasM)),this._geometry.spatialReference=this._optimizedGeomDefinition.spatialReference):this._geometry=p(this._geometry)),this._geometry}field(e){this._fieldTypesFixed||this._fixFieldTypes();const t=this.attributes[e];if(void 0!==t)return t;const i=e.toLowerCase();for(const s in this.attributes)if(s.toLowerCase()===i)return this.attributes[s];if(this._hasFieldDefinition(i))return null;throw new s(null,"FieldNotFound",null,{key:e})}_hasFieldDefinition(e){if(null===this._layer)return!1;for(let t=0;t<this._layer.fields.length;t++){if(this._layer.fields[t].name.toLowerCase()===e)return!0}return!1}setField(t,i){if(this.immutable)throw new s(null,"Immutable",null);if(i instanceof Date&&(i=this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(i):e.dateJSToArcadeDate(i)),!1===l(i))throw new s(null,"TypeNotAllowedInFeature",null);const r=t.toLowerCase();if(void 0===this.attributes[t]){for(const e in this.attributes)if(e.toLowerCase()===r)return void(this.attributes[e]=i);this.attributes[t]=i}else this.attributes[t]=i}hasField(e){const t=e.toLowerCase();if(void 0!==this.attributes[e])return!0;for(const i in this.attributes)if(i.toLowerCase()===t)return!0;return!!this._hasFieldDefinition(t)}keys(){let e=[];const t={};for(const i in this.attributes)e.push(i),t[i.toLowerCase()]=1;if(null!==this._layer)for(let i=0;i<this._layer.fields.length;i++){const s=this._layer.fields[i];1!==t[s.name.toLowerCase()]&&e.push(s.name)}return e=e.sort(),e}isEmpty(){for(const e in this.attributes)return!1;return!(null!=this._layer&&this._layer.fields.length>0)&&null==this.geometry()}static parseAttributesFromDictionary(e){const t={};for(const i in e.attributes){const r=e.attributes[i];if(!l(r))throw new s(null,"InvalidParameter",null);t[i]=r}return t}static fromJson(e,t){let i=null;null!==e.geometry&&void 0!==e.geometry&&(i=p(e.geometry));const r={};if(null!==e.attributes&&void 0!==e.attributes)for(const n in e.attributes){const t=e.attributes[n];if(null===t)r[n]=t;else{if(!(g(t)||F(t)||b(t)||o(t)||u(t)||d(t)))throw new s(null,"InvalidParameter",null);r[n]=t}}return I.createFromGraphicLikeObject(i,r,null,t??null)}fullSchema(){return this._layer}gdbVersion(){if(null===this._layer)return"";const e=this._layer.gdbVersion;return void 0===e?"":""===e&&this._layer.capabilities?.isVersioned?"SDE.DEFAULT":e}castAsJson(e){const t={attributes:{},geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null};for(const i in this.attributes){const s=this.attributes[i];void 0!==s&&(t.attributes[i]=m(s,e))}return t}async castAsJsonAsync(e=null,t){return this.castAsJson(t)}}t(I);export{I as Feature,w as convertAttributeToArcadeValue,D as getArcadeVariableForField};
package/arcade/Pixel.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{toSymbolId as r}from"./arcadeEnvironment.js";import{ArcadeExecutionError as e}from"./executionError.js";import{getArcadeVariableForField as t,convertAttributeToArcadeValue as s}from"./Feature.js";import i from"./ImmutableArray.js";import{d as a,c as n}from"../chunks/languageUtils.js";import o from"../core/Logger.js";import{getOrCreateMapValue as l}from"../core/MapUtils.js";import{isImageryGraphicOrigin as m}from"../graphic/isImageryGraphicOrigin.js";import{isImageryTileGraphicOrigin as p}from"../graphic/isImageryTileGraphicOrigin.js";import{isRasterPixelValueField as u}from"../layers/support/fieldUtils.js";import{rasterFieldPrefix as f}from"../layers/support/rasterFieldUtils.js";import{isDate as c}from"../support/guards.js";const g=()=>o.getLogger("esri.arcade.Pixel");function h(r){return r.rasterFields.filter(r=>r.name.startsWith(f))}class d{constructor(e,t,s){this._graphic=t,this._timeZone=s,this.arcadeDeclaredClass="esri.arcade.Pixel",this._values=new Map,this._fields=new Map(e.map(e=>[r(e.name),e]))}static fromImageryGraphic(r,t){if(!m(r.origin)&&!p(r.origin))throw new e(null,"InvalidParameter",null);return new d(h(r.origin.layer),r,t)}static getDeclaredMembers(r){return h(r).map(r=>u(r.name)&&"string"===r.type?{name:r.name,type:"array",elementType:{type:"text"}}:t(r)).filter(r=>null!=r)}keys(){return Array.from(this._fields.values()).map(r=>r.name).sort()}hasField(e){return this._fields.has(r(e))}field(t){const n=this._fields.get(r(t));if(null==n)throw new e(null,"FieldNotFound",null,{key:t});return l(this._values,n.name,()=>{const r=this._graphic.getAttribute(n.name);return null==r?null:u(n.name)&&"string"==typeof r?new i(r.split(/,\s*|\s+/)):c(r)||a(r)?s(r,n.type,this._timeZone??"system"):(g().warn(`Unsupported type for attribute: ${n.name}. Ignoring value.`),null)})}castToText(r=!1){const e={};for(const t of this._fields.values())e[t.name]=this.field(t.name);return n(e,{useNumbersForDates:r})}}export{d as Pixel};
5
+ import{toSymbolId as r}from"./arcadeEnvironment.js";import{ArcadeExecutionError as e}from"./executionError.js";import{getArcadeVariableForField as t,convertAttributeToArcadeValue as s}from"./Feature.js";import i from"./ImmutableArray.js";import{d as a,c as n}from"../chunks/languageUtils.js";import o from"../core/Logger.js";import{getOrCreateMapValue as l}from"../core/MapUtils.js";import{isImageryGraphicOrigin as m}from"../graphic/isImageryGraphicOrigin.js";import{isImageryTileGraphicOrigin as p}from"../graphic/isImageryTileGraphicOrigin.js";import{isRasterPixelValueField as u}from"../layers/support/fieldUtils.js";import{rasterFieldPrefix as f}from"../layers/support/rasterFieldUtils.js";import{isDate as c}from"../support/guards.js";const g=()=>o.getLogger("esri.arcade.Pixel");function h(r){return r.rasterFields.filter(r=>r.name.startsWith(f))}class d{constructor(e,t,s){this._graphic=t,this._timeZone=s,this.arcadeDeclaredClass="esri.arcade.Pixel",this._values=new Map,this._fields=new Map(e.map(e=>[r(e.name),e]))}static fromImageryGraphic(r,t){if(!m(r.origin)&&!p(r.origin))throw new e(null,"InvalidParameter",null);return new d(h(r.origin.layer),r,t)}static getDeclaredMembers(r){return h(r).map(r=>u(r.name)&&"string"===r.type?{name:r.name,type:"array",elementType:{type:"text"}}:t(r)).filter(r=>null!=r)}keys(){return Array.from(this._fields.values()).map(r=>r.name).sort()}hasField(e){return this._fields.has(r(e))}field(t){const n=this._fields.get(r(t));if(null==n)throw new e(null,"FieldNotFound",null,{key:t});return l(this._values,n.name,()=>{const r=this._graphic.getAttribute(n.name);return null==r?null:u(n.name)&&"string"==typeof r?new i(r.split(/,\s*|\s+/)):c(r)||a(r)?s(r,n.type,this._timeZone??"system"):(g().warn(`Unsupported type for attribute: ${n.name}. Ignoring value.`),null)})}isEmpty(){return this._fields.size<=0}castToText(r=!1){const e={};for(const t of this._fields.values())e[t.name]=this.field(t.name);return n(e,{useNumbersForDates:r})}}export{d as Pixel};
package/arcade/Voxel.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as e}from"./ArcadeDate.js";import{ArcadeExecutionError as t}from"./executionError.js";import r from"./ImmutableArray.js";import{c as i}from"../chunks/languageUtils.js";import{isDate as n}from"../support/guards.js";const s="Voxel.Position",a="Voxel.LocalTime";function o(e){const i=e.getAttribute(s);if("string"!=typeof i)throw new t(null,"InvalidParameter",null);const n=JSON.parse(i);if(!Array.isArray(n)||"number"!=typeof n[0]||"number"!=typeof n[1]||"number"!=typeof n[2])throw new t(null,"InvalidParameter",null);return new r(n)}function l(r,i){const s=r.getAttribute(a);if(null==s)return null;if(!n(s))throw new t(null,"InvalidParameter",null);return e.dateJSAndZoneToArcadeDate(s,i)}class u{constructor(e,t){this._graphic=e,this._timeZone=t,this.arcadeDeclaredClass="esri.arcade.Voxel",this._layer=e.sourceLayer}static getDeclaredMembers(e){return e.fields.map(e=>{switch(e.name){case s:return{name:e.name,type:"array",elementType:{type:"number"}};case a:return{name:e.name,type:"date"};default:switch(e.type){case"string":return{name:e.name,type:"text"};case"double":return{name:e.name,type:"number"}}return null}}).filter(e=>null!=e)}getPosition(){return void 0!==this._position?this._position:this._position=o(this._graphic)}getLocalTime(){return void 0!==this._localTime?this._localTime:this._localTime=l(this._graphic,this._timeZone??"system")}keys(){return this._layer.fields.map(e=>e.name).sort()}hasField(e){return this._layer.fieldsIndex.has(e)}field(e){const r=this._layer.fieldsIndex?.get(e)?.name;if(null==r)throw new t(null,"FieldNotFound",null,{key:e});switch(r){case s:return this.getPosition();case a:return this.getLocalTime()}return this._graphic.attributes[r]??null}castToText(e=!1){const t={...this._graphic.attributes};t[s]=this.getPosition(),a in t&&(t[a]=this.getLocalTime());for(const r of Object.keys(t))this._layer.fieldsIndex?.has(r)||delete t[r];return i(t,{useNumbersForDates:e})}}export{u as Voxel};
5
+ import{ArcadeDate as e}from"./ArcadeDate.js";import{ArcadeExecutionError as t}from"./executionError.js";import r from"./ImmutableArray.js";import{c as i}from"../chunks/languageUtils.js";import{isDate as n}from"../support/guards.js";const s="Voxel.Position",a="Voxel.LocalTime";function l(e){const i=e.getAttribute(s);if("string"!=typeof i)throw new t(null,"InvalidParameter",null);const n=JSON.parse(i);if(!Array.isArray(n)||"number"!=typeof n[0]||"number"!=typeof n[1]||"number"!=typeof n[2])throw new t(null,"InvalidParameter",null);return new r(n)}function o(r,i){const s=r.getAttribute(a);if(null==s)return null;if(!n(s))throw new t(null,"InvalidParameter",null);return e.dateJSAndZoneToArcadeDate(s,i)}class u{constructor(e,t){this._graphic=e,this._timeZone=t,this.arcadeDeclaredClass="esri.arcade.Voxel",this._layer=e.sourceLayer}static getDeclaredMembers(e){return e.fields.map(e=>{switch(e.name){case s:return{name:e.name,type:"array",elementType:{type:"number"}};case a:return{name:e.name,type:"date"};default:switch(e.type){case"string":return{name:e.name,type:"text"};case"double":return{name:e.name,type:"number"}}return null}}).filter(e=>null!=e)}getPosition(){return void 0!==this._position?this._position:this._position=l(this._graphic)}getLocalTime(){return void 0!==this._localTime?this._localTime:this._localTime=o(this._graphic,this._timeZone??"system")}keys(){return this._layer.fields.map(e=>e.name).sort()}hasField(e){return this._layer.fieldsIndex.has(e)}field(e){const r=this._layer.fieldsIndex?.get(e)?.name;if(null==r)throw new t(null,"FieldNotFound",null,{key:e});switch(r){case s:return this.getPosition();case a:return this.getLocalTime()}return this._graphic.attributes[r]??null}isEmpty(){return this._layer.fields.length<=0}castToText(e=!1){const t={...this._graphic.attributes};t[s]=this.getPosition(),a in t&&(t[a]=this.getLocalTime());for(const r of Object.keys(t))this._layer.fieldsIndex?.has(r)||delete t[r];return i(t,{useNumbersForDates:e})}}export{u as Voxel};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"./Dictionary.js";import{ArcadeExecutionError as a}from"./executionError.js";import t from"./ImmutablePathArray.js";import r from"./ImmutablePointArray.js";import{j as n,r as s,h as i}from"../chunks/languageUtils.js";import c from"../core/Accessor.js";import{isArray as l,isString as o,isNumber as u}from"../support/guards.js";const h={point:["hasZ","hasM","spatialReference","type","x","y","z","m"],multipoint:["hasZ","hasM","spatialReference","type","points"],polyline:["hasZ","hasM","spatialReference","type","paths"],polygon:["hasZ","hasM","spatialReference","type","rings"],extent:["hasZ","hasM","spatialReference","type","xmin","xmax","ymin","ymax","zmin","zmax","mmin","mmax"]};function p(e){return h[e.type]}let f=0;function m(n,s,i,l,o=1){let u;switch(s=s.toLowerCase()){case"hasz":{const e=n.hasZ;return void 0!==e&&e}case"hasm":{const e=n.hasM;return void 0!==e&&e}case"spatialreference":{let a=n.spatialReference._arcadeCacheId;if(void 0===a){let e=!0;c.isFrozen(n.spatialReference)&&(e=!1),e&&(f++,n.spatialReference._arcadeCacheId=f,a=f)}const t=new e({__proto__:null,wkt:n.spatialReference.wkt,wkid:n.spatialReference.wkid});return void 0!==a&&(t._arcadeCacheId="SPREF"+a.toString()),t}}switch(n.type){case"extent":switch(s){case"xmin":case"xmax":case"ymin":case"ymax":case"zmin":case"zmax":case"mmin":case"mmax":{const e=n[s];return void 0!==e?e:null}case"type":return"Extent"}break;case"polygon":switch(s){case"rings":u=n.cache._arcadeCacheId,void 0===u&&(f++,u=f,n.cache._arcadeCacheId=u);return new t(n.rings,n.spatialReference,!0===n.hasZ,!0===n.hasM,u);case"type":return"Polygon"}break;case"point":switch(s){case"x":case"y":case"z":case"m":return n[s]??null;case"type":return"Point"}break;case"polyline":switch(s){case"paths":u=n.cache._arcadeCacheId,void 0===u&&(f++,u=f,n.cache._arcadeCacheId=u);return new t(n.paths,n.spatialReference,!0===n.hasZ,!0===n.hasM,u);case"type":return"Polyline"}break;case"multipoint":switch(s){case"points":u=n.cache._arcadeCacheId,void 0===u&&(f++,u=f,n.cache._arcadeCacheId=u);return new r(n.points,n.spatialReference,!0===n.hasZ,!0===n.hasM,u,1);case"type":return"Multipoint"}}if(1===o)throw new a(i,"InvalidIdentifier",l);return 2===o?{keystate:"notfound"}:null}function d(e,a){let t,r=e;if(null==r)return null;if(l(a))t=a;else if(n(a))t=a.toArray();else{if(null==a)return null;t=[a]}for(const c of t){if(s(r)){if(!1===o(c))return null;if(!r.hasField(c))return null;r=r.field(c)}else if(i(r)){if(!1===o(c))return null;r=m(r,c,null,null,0)}else if(l(r)){if(!1===u(c))return null;r=c>=0?r[c]:r[r.length+c]}else{if(!n(r))return null;if(!1===u(c))return null;r=c>=0?r.get(c):r.get(r.length()+c)}if(null==r)return null}return r}export{m as geometryMember,p as getGeometryKeys,d as getNestedOptionalValue};
5
+ import e from"./Dictionary.js";import{ArcadeExecutionError as a}from"./executionError.js";import t from"./ImmutablePathArray.js";import n from"./ImmutablePointArray.js";import{L as r,j as s,r as i,h as c}from"../chunks/languageUtils.js";import l from"../core/Accessor.js";import{isArray as o,isString as u,isNumber as h}from"../support/guards.js";const p={point:["hasZ","hasM","spatialReference","type","x","y","z","m"],multipoint:["hasZ","hasM","spatialReference","type","points"],polyline:["hasZ","hasM","spatialReference","type","paths"],polygon:["hasZ","hasM","spatialReference","type","rings"],extent:["hasZ","hasM","spatialReference","type","xmin","xmax","ymin","ymax","zmin","zmax","mmin","mmax"]};function f(e){return p[e.type]}let m=0;function d(r,s,i,c,o=1){let u;switch(s=s.toLowerCase()){case"hasz":{const e=r.hasZ;return void 0!==e&&e}case"hasm":{const e=r.hasM;return void 0!==e&&e}case"spatialreference":{let a=r.spatialReference._arcadeCacheId;if(void 0===a){let e=!0;l.isFrozen(r.spatialReference)&&(e=!1),e&&(m++,r.spatialReference._arcadeCacheId=m,a=m)}const t=new e({__proto__:null,wkt:r.spatialReference.wkt,wkid:r.spatialReference.wkid});return void 0!==a&&(t._arcadeCacheId="SPREF"+a.toString()),t}}switch(r.type){case"extent":switch(s){case"xmin":case"xmax":case"ymin":case"ymax":case"zmin":case"zmax":case"mmin":case"mmax":{const e=r[s];return void 0!==e?e:null}case"type":return"Extent"}break;case"polygon":switch(s){case"rings":u=r.cache._arcadeCacheId,void 0===u&&(m++,u=m,r.cache._arcadeCacheId=u);return new t(r.rings,r.spatialReference,!0===r.hasZ,!0===r.hasM,u);case"type":return"Polygon"}break;case"point":switch(s){case"x":case"y":case"z":case"m":return r[s]??null;case"type":return"Point"}break;case"polyline":switch(s){case"paths":u=r.cache._arcadeCacheId,void 0===u&&(m++,u=m,r.cache._arcadeCacheId=u);return new t(r.paths,r.spatialReference,!0===r.hasZ,!0===r.hasM,u);case"type":return"Polyline"}break;case"multipoint":switch(s){case"points":u=r.cache._arcadeCacheId,void 0===u&&(m++,u=m,r.cache._arcadeCacheId=u);return new n(r.points,r.spatialReference,!0===r.hasZ,!0===r.hasM,u,1);case"type":return"Multipoint"}}if(1===o)throw new a(i,"InvalidIdentifier",c);return 2===o?{keystate:"notfound"}:null}function y(e,a){let t,n=e;if(null==n)return null;if(o(a))t=a;else if(s(a))t=a.toArray();else{if(null==a)return null;t=[a]}for(const r of t){if(i(n)){if(!1===u(r))return null;if(!n.hasField(r))return null;n=n.field(r)}else if(c(n)){if(!1===u(r))return null;n=d(n,r,null,null,0)}else if(o(n)){if(!1===h(r))return null;n=r>=0?n[r]:n[n.length+r]}else{if(!s(n))return null;if(!1===h(r))return null;n=r>=0?n.get(r):n.get(n.length()+r)}if(null==n)return null}return n}function x(e){return!!r(e)||(o(e)?0===e.length:s(e)?0===e.length():!!i(e)&&e.isEmpty())}export{d as geometryMember,f as getGeometryKeys,y as getNestedOptionalValue,x as isEmpty};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../request.js";import t from"./featureSetCollection.js";import{m as a,a0 as r}from"../chunks/languageUtils.js";import n from"./featureset/actions/AttributeFilter.js";import l from"./featureset/actions/GroupBy.js";import s from"./featureset/actions/OrderBy.js";import i 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 p from"./featureset/support/cache.js";import{FeatureSetError as f}from"./featureset/support/errorsupport.js";import{isSupportedSourceLayer as y,isSupportedLayer as m,extractServiceUrl as h}from"./featureset/support/shared.js";import{isLoadable as I}from"../core/Loadable.js";import w from"../core/sql/WhereClause.js";import L from"../layers/FeatureLayer.js";import S from"../layers/Layer.js";import _ from"../portal/PortalItem.js";function C(){null===p.applicationCache&&(p.applicationCache=new p)}async function g(e,t,a){if(p.applicationCache){const a=p.applicationCache.getLayerInfo(e);if(a){const r=await a;return new L({url:e,outFields:t,sourceJSON:r})}const n=new L({url:e,outFields:t}),l=(async()=>(await n.load(),n.sourceJSON))();if(p.applicationCache){p.applicationCache.setLayerInfo(e,l);try{return await l,n}catch(r){throw p.applicationCache.clearLayerInfo(e),r}}return await l,n}if(null!=a){const r=a.getCachedLayerMetadata(e);if(r){const a=await r;return new L({url:e,outFields:t,sourceJSON:a})}const l=new L({url:e,outFields:t}),s=(async()=>(await l.load(),l.sourceJSON))();a.setCachedLayerMetadata(e,s);try{return await s,l}catch(n){throw a.removeCachedLayerMetadata(e,s),n}}return new L({url:e,outFields:t})}async function k(e,t,a,r,n,l=null){return F(await g(e,["*"],n),t,a,r,n,l)}function F(e,t=null,a=null,r=!0,n=null,l=null){switch(e.type){case"catalog-footprint":return F(e.parent,t,a,r,n,l);case"subtype-sublayer":{const s=F(e.parent,t,a,r,n,l);return s.filter(w.create(e.parent.subtypeField+"="+e.subtypeCode.toString(),{fieldsIndex:e.parent.fieldsIndex,timeZone:s.dateFieldsTimeZoneDefaultUTC}))}case"csv":case"geojson":case"knowledge-graph-sublayer":case"wfs":return new c({layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:n,interceptor:l});case"catalog":case"feature":case"oriented-imagery":case"subtype-group":{const s={layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:n,interceptor:l};return!e.url&&e.source?new c(s):new u(s)}default:throw new Error(`Unsupported layer type: ${e.type}`)}}async function N(t){if(null!==p.applicationCache){const e=p.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!==p.applicationCache){p.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw p.applicationCache.clearLayerInfo(t),r}}return a}async function T(t,a){const r="QUERYDATAELEMTS:"+a.toString()+":"+t;if(null!==p.applicationCache){const e=p.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?.[0])return e.layerDataElements[0]}throw new f("DataElementsNotFound")})();if(null!==p.applicationCache){p.applicationCache.setLayerInfo(r,n);try{return await n}catch(l){throw p.applicationCache.clearLayerInfo(r),l}}return n}async function A(t,a){if(null!==p.applicationCache){const e=p.applicationCache.getLayerInfo(t);if(null!==e)return e}if(null!=a){const e=a.getCachedServiceMetadata(t);if(null!=e)return e}const r=(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!==p.applicationCache){p.applicationCache.setLayerInfo(t,r);try{return await r}catch(n){throw p.applicationCache.clearLayerInfo(t),n}}if(null!=a){a.setCachedServiceMetadata(t,r);try{return await r}catch(l){throw a.removeCachedServiceMetadata(t,r),l}}return r}async function O(e,t,a){const r={metadata:null,networkId:-1,unVersion:3,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map,queryelem:null,layerNameLkp:{},lkp:null},n=await A(e,null);if(r.metadata=n,void 0!==n.controllerDatasetLayers?.utilityNetworkLayerId&&null!==n.controllerDatasetLayers.utilityNetworkLayerId){if(n.layers)for(const e of n.layers)r.layerNameLkp[e.id]=e.name;if(n.tables)for(const e of n.tables)r.layerNameLkp[e.id]=e.name;const l=n.controllerDatasetLayers.utilityNetworkLayerId;r.networkId=l;const s=await T(e,l);if(s){r.queryelem=s,r.queryelem?.dataElement&&void 0!==r.queryelem.dataElement.schemaGeneration&&(r.unVersion=r.queryelem.dataElement.schemaGeneration),r.lkp={},r.queryelem.dataElement.domainNetworks||(r.queryelem.dataElement.domainNetworks=[]);for(const e of r.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}for(const t of e.junctionSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}}if(r.queryelem.dataElement.terminalConfigurations)for(const e of r.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)r.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});const n=await N(e+"/"+l);if(void 0!==n.systemLayers?.associationsTableId&&null!==n.systemLayers.associationsTableId){let l=null;if(a&&r.unVersion<8){const a=[];r.unVersion>=4&&(a.push("STATUS"),a.push("PERCENTALONG")),l=await k(e+"/"+n.systemLayers.associationsTableId,t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...a],!1,null,null),await l.load(),r.unVersion>=4&&(l=l.filter(w.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)",{fieldsIndex:l.getFieldsIndex(),timeZone:l.dateFieldsTimeZoneDefaultUTC})),await l.load())}return{lkp:r.lkp,associations:l,unVersion:r.unVersion,terminals:r.terminals,layerIdLookup:r.layerIdLookup,sourceIdLookup:r.sourceIdLookup}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}async function E(e,t,a,r=null,n=null,l=!0,s=null,i=null){let o=e.serviceUrl();if(!o)return null;o=o.endsWith("/")?o+t.relatedTableId.toString():o+"/"+t.relatedTableId.toString();const u=await k(o,r,n,l,s,i);return new d({layer:e,relatedLayer:u,relationship:t,objectId:a,spatialReference:r,outFields:n,includeGeometry:l,lrucache:s,interceptor:i})}n.registerAction(),l.registerAction(),s.registerAction(),i.registerAction(),o.registerAction();class j extends t{constructor(e,t=null,a=null,r=null){super(),this._map=e,this._overrideSpatialReference=t,this._lrucache=a,this._interceptor=r,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,a=null){const r=F(e,this._overrideSpatialReference,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(I(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetByName(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).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=this._map.allLayers.find(t=>m(t)&&t.title===e);if(null!=n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>m(t)&&t.title===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){if(I(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetById(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).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=this._map.allLayers.find(t=>m(t)&&t.id===e);if(n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>m(t)&&t.id===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}}class D extends t{constructor(e,t=null,a=null,r=null){super(),this._url=e,this._overrideSpatialReference=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=F(e,this._overrideSpatialReference,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 A(this._url,this._lrucache);return this.metadata=e,e}load(){return this._loadMetaData()}clone(){return new D(this._url,this._overrideSpatialReference,this._lrucache,this._interceptor)}async featureSetByName(e,t=!0,a=null){null===a&&(a=["*"]),a=(a=a.slice()).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 l=null;for(const s of n.layers??[])s.name===e&&(l=s);if(!l)for(const s of n.tables??[])s.name===e&&(l=s);if(l){const e=await g(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){null===a&&(a=["*"]),a=(a=a.slice()).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 l=null;for(const s of n.layers??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(!l)for(const s of n.tables??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(l){const e=await g(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}}function M(e,t,a=null,r=null){return new j(e,t,a,r)}function b(e,t,a=null,r=null){return new D(e,t,a,r)}function v(e,t,n,l,s){if(null===e)return null;if(a(e)){switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}if(e instanceof S&&y(e)){const a=e;switch(t){case"datasource":return F(a,s,"outFields"in a?a.outFields:null,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return F(a,s,"outFields"in a?a.outFields:null,!0,n,l)}return null}if(r(e)){switch(t){case"datasource":return F(e.parent,s,e.parent.outFields,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return F(e,s,e.parent.outFields,!0,n,l)}return null}return null}async function R(e,t,a,r,n,l,s,i=null){if(p.applicationCache){const o=p.applicationCache.getLayerInfo(e+":"+l.url);if(o)return q(await o,t,a,r,n,s,i)}if(null!=s){const o=s.getCachedPortalItem(l.url,e);if(null!=o)return await q(await o,t,a,r,n,s,i)}const o=new _({id:e,portal:l}).load();p.applicationCache?p.applicationCache.setLayerInfo(e+":"+l.url,o):null!=s&&s.setCachedPortalItem(l.url,e,o);try{return await q(await o,t,a,r,n,s,i)}catch(u){throw p.applicationCache&&p.applicationCache.clearLayerInfo(e+":"+l.url),null!=s&&s.removeCachedPortalItem(l.url,e,o),u}}async function q(e,t,a,r,n,l,s){let i;if("Feature Service"===e.type||"Map Service"===e.type)i=await g(h(e.url??"")+"/"+t,["*"],l);else{if(t)throw new Error(`layerId=${t} provided for ${e.type} item`);if(null!=l){const t=l.getCachedPortalItemLayer(e.portal.url,e.id);if(null!=t)i=await t;else{const t=S.fromPortalItem(e);l.setCachedPortalItemLayer(e.portal.url,e.id,t);try{i=await t}catch(o){throw l.removeCachedPortalItemLayer(e.portal.url,e.id,t),o}}}else i=await S.fromPortalItem(e)}return F(i,a,r,n,l,s)}export{O as constructAssociationMetaDataFeatureSetFromUrl,F as constructFeatureSet,R as constructFeatureSetFromPortalItem,E as constructFeatureSetFromRelationship,k as constructFeatureSetFromUrl,v as convertToFeatureSet,M as createFeatureSetCollectionFromMap,b as createFeatureSetCollectionFromService,C as initialiseMetaDataCache};
5
+ import e from"../request.js";import t from"./featureSetCollection.js";import{m as a,a1 as r}from"../chunks/languageUtils.js";import n from"./featureset/actions/AttributeFilter.js";import l from"./featureset/actions/GroupBy.js";import s from"./featureset/actions/OrderBy.js";import i 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 p from"./featureset/support/cache.js";import{FeatureSetError as f}from"./featureset/support/errorsupport.js";import{isSupportedSourceLayer as y,isSupportedLayer as m,extractServiceUrl as h}from"./featureset/support/shared.js";import{isLoadable as I}from"../core/Loadable.js";import w from"../core/sql/WhereClause.js";import L from"../layers/FeatureLayer.js";import S from"../layers/Layer.js";import _ from"../portal/PortalItem.js";function C(){null===p.applicationCache&&(p.applicationCache=new p)}async function g(e,t,a){if(p.applicationCache){const a=p.applicationCache.getLayerInfo(e);if(a){const r=await a;return new L({url:e,outFields:t,sourceJSON:r})}const n=new L({url:e,outFields:t}),l=(async()=>(await n.load(),n.sourceJSON))();if(p.applicationCache){p.applicationCache.setLayerInfo(e,l);try{return await l,n}catch(r){throw p.applicationCache.clearLayerInfo(e),r}}return await l,n}if(null!=a){const r=a.getCachedLayerMetadata(e);if(r){const a=await r;return new L({url:e,outFields:t,sourceJSON:a})}const l=new L({url:e,outFields:t}),s=(async()=>(await l.load(),l.sourceJSON))();a.setCachedLayerMetadata(e,s);try{return await s,l}catch(n){throw a.removeCachedLayerMetadata(e,s),n}}return new L({url:e,outFields:t})}async function k(e,t,a,r,n,l=null){return F(await g(e,["*"],n),t,a,r,n,l)}function F(e,t=null,a=null,r=!0,n=null,l=null){switch(e.type){case"catalog-footprint":return F(e.parent,t,a,r,n,l);case"subtype-sublayer":{const s=F(e.parent,t,a,r,n,l);return s.filter(w.create(e.parent.subtypeField+"="+e.subtypeCode.toString(),{fieldsIndex:e.parent.fieldsIndex,timeZone:s.dateFieldsTimeZoneDefaultUTC}))}case"csv":case"geojson":case"knowledge-graph-sublayer":case"wfs":return new c({layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:n,interceptor:l});case"catalog":case"feature":case"oriented-imagery":case"subtype-group":{const s={layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:n,interceptor:l};return!e.url&&e.source?new c(s):new u(s)}default:throw new Error(`Unsupported layer type: ${e.type}`)}}async function N(t){if(null!==p.applicationCache){const e=p.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!==p.applicationCache){p.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw p.applicationCache.clearLayerInfo(t),r}}return a}async function T(t,a){const r="QUERYDATAELEMTS:"+a.toString()+":"+t;if(null!==p.applicationCache){const e=p.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?.[0])return e.layerDataElements[0]}throw new f("DataElementsNotFound")})();if(null!==p.applicationCache){p.applicationCache.setLayerInfo(r,n);try{return await n}catch(l){throw p.applicationCache.clearLayerInfo(r),l}}return n}async function A(t,a){if(null!==p.applicationCache){const e=p.applicationCache.getLayerInfo(t);if(null!==e)return e}if(null!=a){const e=a.getCachedServiceMetadata(t);if(null!=e)return e}const r=(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!==p.applicationCache){p.applicationCache.setLayerInfo(t,r);try{return await r}catch(n){throw p.applicationCache.clearLayerInfo(t),n}}if(null!=a){a.setCachedServiceMetadata(t,r);try{return await r}catch(l){throw a.removeCachedServiceMetadata(t,r),l}}return r}async function O(e,t,a){const r={metadata:null,networkId:-1,unVersion:3,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map,queryelem:null,layerNameLkp:{},lkp:null},n=await A(e,null);if(r.metadata=n,void 0!==n.controllerDatasetLayers?.utilityNetworkLayerId&&null!==n.controllerDatasetLayers.utilityNetworkLayerId){if(n.layers)for(const e of n.layers)r.layerNameLkp[e.id]=e.name;if(n.tables)for(const e of n.tables)r.layerNameLkp[e.id]=e.name;const l=n.controllerDatasetLayers.utilityNetworkLayerId;r.networkId=l;const s=await T(e,l);if(s){r.queryelem=s,r.queryelem?.dataElement&&void 0!==r.queryelem.dataElement.schemaGeneration&&(r.unVersion=r.queryelem.dataElement.schemaGeneration),r.lkp={},r.queryelem.dataElement.domainNetworks||(r.queryelem.dataElement.domainNetworks=[]);for(const e of r.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}for(const t of e.junctionSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}}if(r.queryelem.dataElement.terminalConfigurations)for(const e of r.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)r.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});const n=await N(e+"/"+l);if(void 0!==n.systemLayers?.associationsTableId&&null!==n.systemLayers.associationsTableId){let l=null;if(a&&r.unVersion<8){const a=[];r.unVersion>=4&&(a.push("STATUS"),a.push("PERCENTALONG")),l=await k(e+"/"+n.systemLayers.associationsTableId,t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...a],!1,null,null),await l.load(),r.unVersion>=4&&(l=l.filter(w.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)",{fieldsIndex:l.getFieldsIndex(),timeZone:l.dateFieldsTimeZoneDefaultUTC})),await l.load())}return{lkp:r.lkp,associations:l,unVersion:r.unVersion,terminals:r.terminals,layerIdLookup:r.layerIdLookup,sourceIdLookup:r.sourceIdLookup}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}async function E(e,t,a,r=null,n=null,l=!0,s=null,i=null){let o=e.serviceUrl();if(!o)return null;o=o.endsWith("/")?o+t.relatedTableId.toString():o+"/"+t.relatedTableId.toString();const u=await k(o,r,n,l,s,i);return new d({layer:e,relatedLayer:u,relationship:t,objectId:a,spatialReference:r,outFields:n,includeGeometry:l,lrucache:s,interceptor:i})}n.registerAction(),l.registerAction(),s.registerAction(),i.registerAction(),o.registerAction();class j extends t{constructor(e,t=null,a=null,r=null){super(),this._map=e,this._overrideSpatialReference=t,this._lrucache=a,this._interceptor=r,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,a=null){const r=F(e,this._overrideSpatialReference,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(I(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetByName(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).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=this._map.allLayers.find(t=>m(t)&&t.title===e);if(null!=n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>m(t)&&t.title===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){if(I(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetById(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).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=this._map.allLayers.find(t=>m(t)&&t.id===e);if(n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>m(t)&&t.id===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}}class D extends t{constructor(e,t=null,a=null,r=null){super(),this._url=e,this._overrideSpatialReference=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=F(e,this._overrideSpatialReference,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 A(this._url,this._lrucache);return this.metadata=e,e}load(){return this._loadMetaData()}clone(){return new D(this._url,this._overrideSpatialReference,this._lrucache,this._interceptor)}async featureSetByName(e,t=!0,a=null){null===a&&(a=["*"]),a=(a=a.slice()).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 l=null;for(const s of n.layers??[])s.name===e&&(l=s);if(!l)for(const s of n.tables??[])s.name===e&&(l=s);if(l){const e=await g(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){null===a&&(a=["*"]),a=(a=a.slice()).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 l=null;for(const s of n.layers??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(!l)for(const s of n.tables??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(l){const e=await g(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}}function M(e,t,a=null,r=null){return new j(e,t,a,r)}function b(e,t,a=null,r=null){return new D(e,t,a,r)}function v(e,t,n,l,s){if(null===e)return null;if(a(e)){switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}if(e instanceof S&&y(e)){const a=e;switch(t){case"datasource":return F(a,s,"outFields"in a?a.outFields:null,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return F(a,s,"outFields"in a?a.outFields:null,!0,n,l)}return null}if(r(e)){switch(t){case"datasource":return F(e.parent,s,e.parent.outFields,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return F(e,s,e.parent.outFields,!0,n,l)}return null}return null}async function R(e,t,a,r,n,l,s,i=null){if(p.applicationCache){const o=p.applicationCache.getLayerInfo(e+":"+l.url);if(o)return q(await o,t,a,r,n,s,i)}if(null!=s){const o=s.getCachedPortalItem(l.url,e);if(null!=o)return await q(await o,t,a,r,n,s,i)}const o=new _({id:e,portal:l}).load();p.applicationCache?p.applicationCache.setLayerInfo(e+":"+l.url,o):null!=s&&s.setCachedPortalItem(l.url,e,o);try{return await q(await o,t,a,r,n,s,i)}catch(u){throw p.applicationCache&&p.applicationCache.clearLayerInfo(e+":"+l.url),null!=s&&s.removeCachedPortalItem(l.url,e,o),u}}async function q(e,t,a,r,n,l,s){let i;if("Feature Service"===e.type||"Map Service"===e.type)i=await g(h(e.url??"")+"/"+t,["*"],l);else{if(t)throw new Error(`layerId=${t} provided for ${e.type} item`);if(null!=l){const t=l.getCachedPortalItemLayer(e.portal.url,e.id);if(null!=t)i=await t;else{const t=S.fromPortalItem(e);l.setCachedPortalItemLayer(e.portal.url,e.id,t);try{i=await t}catch(o){throw l.removeCachedPortalItemLayer(e.portal.url,e.id,t),o}}}else i=await S.fromPortalItem(e)}return F(i,a,r,n,l,s)}export{O as constructAssociationMetaDataFeatureSetFromUrl,F as constructFeatureSet,R as constructFeatureSetFromPortalItem,E as constructFeatureSetFromRelationship,k as constructFeatureSetFromUrl,v as convertToFeatureSet,M as createFeatureSetCollectionFromMap,b as createFeatureSetCollectionFromService,C 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.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Graphic.js";import{StringEnum as t}from"../../enum.js";import{a1 as i}from"../../../chunks/languageUtils.js";import{SqlExpressionAdapted as s,OriginalField as n,AdaptedFeatureSet as r}from"./Adapted.js";import a from"./AttributeFilter.js";import o from"./OrderBy.js";import{FeatureSetError as l}from"../support/errorsupport.js";import d from"../support/FeatureSet.js";import u from"../support/IdSet.js";import f from"../support/OrderbyClause.js";import{layerGeometryEsriConstants as p}from"../support/shared.js";import{isSingleField as h,toWhereClause as c,predictType as g,scanForField as _,reformulateWithoutField as m}from"../support/sqlUtils.js";import y from"../support/StatsField.js";import{createMD5Hash as b,outputTypes as w}from"../../../core/MD5.js";import{aggregateFunction as F}from"../../../core/sql/AggregateFunctions.js";import{DateOnly as I}from"../../../core/sql/DateOnly.js";import{SqlTimeStampOffset as S}from"../../../core/sql/SqlTimestampOffset.js";import{TimeOnly as x}from"../../../core/sql/TimeOnly.js";import D from"../../../core/sql/WhereClause.js";import A from"../../../geometry/SpatialReference.js";import j from"../../../layers/support/Field.js";import k from"../../../layers/support/FieldsIndex.js";const C=new t(["MIN","MAX","VAR","STDDEV","COUNT","SUM","AVG"],[["VARIANCE","VAR"],["AVERAGE","AVG"],["MEAN","AVG"],["STDEV","STDDEV"]]);class T extends d{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 0}_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,i=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"+i.toString(),i++)}for(const s of this._config.statsfields){const e=new y;e.field=s.name,e.tofieldname=s.name,e.workingexpr=s.expression instanceof D?s.expression:D.create(s.expression,{fieldsIndex:r,timeZone:this.dateFieldsTimeZoneDefaultUTC}),e.typeofstat=C.lookup(s.statistic)??"COUNT",this._decodedStatsfield.push(e)}this._decodedGroupbyfield=[];for(const s of this._config.groupbyfields){const e={name:s.name,singlefield:null,tofieldname:s.name,expression:s.expression instanceof D?s.expression:D.create(s.expression,{fieldsIndex:r,timeZone:this.dateFieldsTimeZoneDefaultUTC}),sqlType:null};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,this.subtypes=null,this.subtypeField=""}else this.geometryType=p.point,this.typeIdField="",this.types=null,this.subtypes=null,this.subtypeField="",this.spatialReference=new A({wkid:4326});this.fields=[];const a=new y;a.field=this._nextUniqueName(e),a.tofieldname=this.objectIdField,a.workingexpr=D.create(this._parent.objectIdField,{fieldsIndex:this._parent.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC}),a.typeofstat="MIN",this._decodedStatsfield.push(a);for(const n of this._decodedGroupbyfield){const t=new j;if(n.name=this._nextUniqueName(e),t.name=n.tofieldname,t.alias=t.name,h(n.expression)){const e=this._parent.getField(c(n.expression,0));if(!e)throw new l("AggregationFieldNotFound");n.name=e.name,n.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),t.type=e.type,n.sqlType=e.type}else{t.type=this._convertToEsriFieldType(g(n.expression,this._parent.fields));const e=new j;e.name=n.name,e.alias=e.name,this.phsyicalgroupbyfields.push(n.name),this._adaptedFields.push(new s(e,n.expression)),this._candosimplegroupby=!1,n.sqlType=t.type}this.fields.push(t)}if(this._adaptedFields.length>0)for(const s of this._parent.fields)this._adaptedFields.push(new n(s));for(let s=0;s<this._decodedStatsfield.length;s++){const t=new j;let i=null;const n=this._decodedStatsfield[s];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)?c(n.workingexpr,0):"";switch(this._decodedStatsfield[s].typeofstat){case"SUM":if(""!==r){if(i=this._parent.getField(r),!i)throw new l("AggregationFieldNotFound");t.type=i.type}else t.type="double";break;case"MIN":case"MAX":if(""!==r){if(i=this._parent.getField(r),!i)throw new l("AggregationFieldNotFound");t.type=i.type}else t.type="double";break;case"COUNT":t.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==r&&(i=this._parent.getField(r),!i))throw new l("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,n){if(""!==e)return new u([],[],!0,null);let l=null;const d={ordered:!1,nowhereclause:!1};if(await this._ensureLoaded(),null!==i)for(let r=0;r<this._decodedStatsfield.length;r++)if(!0===_(i,this._decodedStatsfield[r].tofieldname)){d.nowhereclause=!0,i=null;break}if(null!==s){d.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===s.scanForField(this._decodedStatsfield[e].tofieldname)){s=null,d.ordered=!1;break}if(null!==s)for(const e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===s.scanForField(e.tofieldname)){s=null,d.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 r=await this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField);return this._checkCancelled(n),l=!0===d.nowhereclause?new u(r._candidates.slice().concat(r._known.slice()),[],!0===d.ordered&&r._ordered,this._clonePageDefinition(r.pagesDefinition)):new u(r._candidates.slice(),r._known.slice(),!0===d.ordered&&r._ordered,this._clonePageDefinition(r.pagesDefinition)),l}let p=this._parent;if(this._adaptedFields.length>0&&(p=new r({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===d.nowhereclause)l=new u(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new o({parentfeatureset:p,orderbyclause:new f(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=p;if(null!==i){let t=null;i&&(t=this._reformulateWhereClauseWithoutGroupByFields(i)),e=new a({parentfeatureset:e,whereclause:t})}l=new u(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new o({parentfeatureset:e,orderbyclause:new f(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return l}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=m(e,t.tofieldname,c(t.workingexpr,0),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=m(e,t.tofieldname,c(t.expression,0),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,t,s,n,r,a){try{i(e.pagesDefinition.internal.iterator.next()).then(i=>{if(null===i)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(i);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[i],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]),t-=1,e.pagesDefinition.internal.workingItem={features:[i],id:o},void r(s)}e.pagesDefinition.internal.workingItem.features.push(i)}this._nextAggregateItem(e,t,s,n,r,a)}},a)}catch(o){a(o)}}_calculateFieldStat(e,t,i){const s=[];for(const n of e.features)if(null!==t.workingexpr){const e=t.workingexpr.calculateValue(n);null!==e&&(e instanceof I||e instanceof x?s.push(e.toNumber()):e instanceof S?s.push(e.toMilliseconds()):s.push(e))}else s.push(null);i.attributes[t.tofieldname]=F(t.typeofstat,[s])}_calculateAndAppendAggregateItem(t){const i={attributes:{},geometry:null};for(const e of this._decodedGroupbyfield){const s=e.singlefield?t.features[0].attributes[e.singlefield]:D.convertValueToStorageFormat(e.expression.calculateValue(t.features[0]),e.sqlType);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 b(t,w.String)}async _stat(){return{calculated:!1}}async getFeatureByObjectId(){return null}static registerAction(){d._featuresetFunctions.groupby=function(e,t){return new T({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}export{T as default};
5
+ import e from"../../../Graphic.js";import{StringEnum as t}from"../../enum.js";import{a2 as i}from"../../../chunks/languageUtils.js";import{SqlExpressionAdapted as s,OriginalField as n,AdaptedFeatureSet as r}from"./Adapted.js";import a from"./AttributeFilter.js";import o from"./OrderBy.js";import{FeatureSetError as l}from"../support/errorsupport.js";import d from"../support/FeatureSet.js";import u from"../support/IdSet.js";import f from"../support/OrderbyClause.js";import{layerGeometryEsriConstants as p}from"../support/shared.js";import{isSingleField as h,toWhereClause as c,predictType as g,scanForField as _,reformulateWithoutField as m}from"../support/sqlUtils.js";import y from"../support/StatsField.js";import{createMD5Hash as b,outputTypes as w}from"../../../core/MD5.js";import{aggregateFunction as F}from"../../../core/sql/AggregateFunctions.js";import{DateOnly as I}from"../../../core/sql/DateOnly.js";import{SqlTimeStampOffset as S}from"../../../core/sql/SqlTimestampOffset.js";import{TimeOnly as x}from"../../../core/sql/TimeOnly.js";import D from"../../../core/sql/WhereClause.js";import A from"../../../geometry/SpatialReference.js";import j from"../../../layers/support/Field.js";import k from"../../../layers/support/FieldsIndex.js";const C=new t(["MIN","MAX","VAR","STDDEV","COUNT","SUM","AVG"],[["VARIANCE","VAR"],["AVERAGE","AVG"],["MEAN","AVG"],["STDEV","STDDEV"]]);class T extends d{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 0}_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,i=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"+i.toString(),i++)}for(const s of this._config.statsfields){const e=new y;e.field=s.name,e.tofieldname=s.name,e.workingexpr=s.expression instanceof D?s.expression:D.create(s.expression,{fieldsIndex:r,timeZone:this.dateFieldsTimeZoneDefaultUTC}),e.typeofstat=C.lookup(s.statistic)??"COUNT",this._decodedStatsfield.push(e)}this._decodedGroupbyfield=[];for(const s of this._config.groupbyfields){const e={name:s.name,singlefield:null,tofieldname:s.name,expression:s.expression instanceof D?s.expression:D.create(s.expression,{fieldsIndex:r,timeZone:this.dateFieldsTimeZoneDefaultUTC}),sqlType:null};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,this.subtypes=null,this.subtypeField=""}else this.geometryType=p.point,this.typeIdField="",this.types=null,this.subtypes=null,this.subtypeField="",this.spatialReference=new A({wkid:4326});this.fields=[];const a=new y;a.field=this._nextUniqueName(e),a.tofieldname=this.objectIdField,a.workingexpr=D.create(this._parent.objectIdField,{fieldsIndex:this._parent.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC}),a.typeofstat="MIN",this._decodedStatsfield.push(a);for(const n of this._decodedGroupbyfield){const t=new j;if(n.name=this._nextUniqueName(e),t.name=n.tofieldname,t.alias=t.name,h(n.expression)){const e=this._parent.getField(c(n.expression,0));if(!e)throw new l("AggregationFieldNotFound");n.name=e.name,n.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),t.type=e.type,n.sqlType=e.type}else{t.type=this._convertToEsriFieldType(g(n.expression,this._parent.fields));const e=new j;e.name=n.name,e.alias=e.name,this.phsyicalgroupbyfields.push(n.name),this._adaptedFields.push(new s(e,n.expression)),this._candosimplegroupby=!1,n.sqlType=t.type}this.fields.push(t)}if(this._adaptedFields.length>0)for(const s of this._parent.fields)this._adaptedFields.push(new n(s));for(let s=0;s<this._decodedStatsfield.length;s++){const t=new j;let i=null;const n=this._decodedStatsfield[s];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)?c(n.workingexpr,0):"";switch(this._decodedStatsfield[s].typeofstat){case"SUM":if(""!==r){if(i=this._parent.getField(r),!i)throw new l("AggregationFieldNotFound");t.type=i.type}else t.type="double";break;case"MIN":case"MAX":if(""!==r){if(i=this._parent.getField(r),!i)throw new l("AggregationFieldNotFound");t.type=i.type}else t.type="double";break;case"COUNT":t.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==r&&(i=this._parent.getField(r),!i))throw new l("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,n){if(""!==e)return new u([],[],!0,null);let l=null;const d={ordered:!1,nowhereclause:!1};if(await this._ensureLoaded(),null!==i)for(let r=0;r<this._decodedStatsfield.length;r++)if(!0===_(i,this._decodedStatsfield[r].tofieldname)){d.nowhereclause=!0,i=null;break}if(null!==s){d.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===s.scanForField(this._decodedStatsfield[e].tofieldname)){s=null,d.ordered=!1;break}if(null!==s)for(const e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===s.scanForField(e.tofieldname)){s=null,d.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 r=await this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField);return this._checkCancelled(n),l=!0===d.nowhereclause?new u(r._candidates.slice().concat(r._known.slice()),[],!0===d.ordered&&r._ordered,this._clonePageDefinition(r.pagesDefinition)):new u(r._candidates.slice(),r._known.slice(),!0===d.ordered&&r._ordered,this._clonePageDefinition(r.pagesDefinition)),l}let p=this._parent;if(this._adaptedFields.length>0&&(p=new r({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===d.nowhereclause)l=new u(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new o({parentfeatureset:p,orderbyclause:new f(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=p;if(null!==i){let t=null;i&&(t=this._reformulateWhereClauseWithoutGroupByFields(i)),e=new a({parentfeatureset:e,whereclause:t})}l=new u(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new o({parentfeatureset:e,orderbyclause:new f(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return l}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=m(e,t.tofieldname,c(t.workingexpr,0),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=m(e,t.tofieldname,c(t.expression,0),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,t,s,n,r,a){try{i(e.pagesDefinition.internal.iterator.next()).then(i=>{if(null===i)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(i);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[i],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]),t-=1,e.pagesDefinition.internal.workingItem={features:[i],id:o},void r(s)}e.pagesDefinition.internal.workingItem.features.push(i)}this._nextAggregateItem(e,t,s,n,r,a)}},a)}catch(o){a(o)}}_calculateFieldStat(e,t,i){const s=[];for(const n of e.features)if(null!==t.workingexpr){const e=t.workingexpr.calculateValue(n);null!==e&&(e instanceof I||e instanceof x?s.push(e.toNumber()):e instanceof S?s.push(e.toMilliseconds()):s.push(e))}else s.push(null);i.attributes[t.tofieldname]=F(t.typeofstat,[s])}_calculateAndAppendAggregateItem(t){const i={attributes:{},geometry:null};for(const e of this._decodedGroupbyfield){const s=e.singlefield?t.features[0].attributes[e.singlefield]:D.convertValueToStorageFormat(e.expression.calculateValue(t.features[0]),e.sqlType);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 b(t,w.String)}async _stat(){return{calculated:!1}}async getFeatureByObjectId(){return null}static registerAction(){d._featuresetFunctions.groupby=function(e,t){return new T({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}export{T 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{a1 as e}from"../../../chunks/languageUtils.js";import{FeatureSetError as t}from"../support/errorsupport.js";import r from"../support/FeatureSet.js";import n from"../support/IdSet.js";import s from"../support/OrderbyClause.js";class i extends r{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 s=new n([],[],!0,null);for(let n=0;n<r.length;n++)s._known.push(r[n].id);return s}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("NeverReach")}async _getFilteredSet(e,t,r,s,i){await this._ensureLoaded();const a=await this._parent._getFilteredSet(e,t,r,null===s?this._orderbyclause:s,i);this._checkCancelled(i);const o=new n(a._candidates.slice(),a._known.slice(),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 n(e._candidates.slice().concat(e._known.slice()),[],e._ordered,this._clonePageDefinition(e.pagesDefinition)))),e}return o}static registerAction(){r._featuresetFunctions.orderBy=function(e){return""===e?this:new i({parentfeatureset:this,orderbyclause:new s(e)})}}getFieldsIndex(){return this._parent.getFieldsIndex()}}export{i as default};
5
+ import{a2 as e}from"../../../chunks/languageUtils.js";import{FeatureSetError as t}from"../support/errorsupport.js";import r from"../support/FeatureSet.js";import n from"../support/IdSet.js";import s from"../support/OrderbyClause.js";class i extends r{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 s=new n([],[],!0,null);for(let n=0;n<r.length;n++)s._known.push(r[n].id);return s}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("NeverReach")}async _getFilteredSet(e,t,r,s,i){await this._ensureLoaded();const a=await this._parent._getFilteredSet(e,t,r,null===s?this._orderbyclause:s,i);this._checkCancelled(i);const o=new n(a._candidates.slice(),a._known.slice(),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 n(e._candidates.slice().concat(e._known.slice()),[],e._ordered,this._clonePageDefinition(e.pagesDefinition)))),e}return o}static registerAction(){r._featuresetFunctions.orderBy=function(e){return""===e?this:new i({parentfeatureset:this,orderbyclause:new s(e)})}}getFieldsIndex(){return this._parent.getFieldsIndex()}}export{i 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.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"./cache.js";import{FeatureSetError as t}from"./errorsupport.js";import s from"./FeatureSetIterator.js";import i from"./IdSet.js";import{layerGeometryEsriConstants as n,esriFieldToJson as a,layerGeometryEsriRestConstants as r}from"./shared.js";import{max as l,min as u,sum as h,variance as o,stdev as c,mean as d,distinct as f,count as _}from"./stats.js";import{invokeRemoteGeometryOp as p}from"../../geometry/operatorsWorkerConnection.js";import{isPromiseLike as m}from"../../../core/promiseUtils.js";import g from"../../../core/sql/WhereClause.js";import y from"../../../geometry/SpatialReference.js";import{fromJSON as F}from"../../../geometry/support/jsonUtils.js";import T from"../../../layers/support/FieldsIndex.js";class b{constructor(e){this.recentlyUsedQueries=null,this.featureSetQueryInterceptor=null,this._idstates=[],this._parent=null,this._wset=null,this._mainSetInUse=null,this._maxProcessing=200,this._maxQuery=500,this._totalCount=-1,this._databaseType=7,this._databaseTypeProbed=null,this.declaredRootClass="esri.arcade.featureset.support.FeatureSet",this._featureCache=Object.create(null),this.typeIdField=null,this.types=null,this.subtypeField=null,this.subtypes=null,this.fields=null,this.geometryType="",this.objectIdField="",this.globalIdField="",this.spatialReference=null,this.hasM=!1,this.hasZ=!1,this._transparent=!1,this.loaded=!1,this._loadPromise=null,this._fieldsIndex=null,this.fsetInfo=null,e?.lrucache&&(this.recentlyUsedQueries=e.lrucache),e?.interceptor&&(this.featureSetQueryInterceptor=e.interceptor)}optimisePagingFeatureQueries(e){this._parent&&this._parent.optimisePagingFeatureQueries(e)}_hasMemorySource(){return!0}static{this._featuresetFunctions={}}prop(e,t){return void 0===t?this[e]:(void 0!==this[e]&&(this[e]=t),this)}end(){return null!==this._parent&&!0===this._parent._transparent?this._parent.end():this._parent}_ensureLoaded(){return this.load()}load(){return null===this._loadPromise&&(this._loadPromise=this.loadImpl()),this._loadPromise}async loadImpl(){return!0===this._parent?.loaded?(this._initialiseFeatureSet(),this):(await(this._parent?.load()),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){null!==this._parent?(this.fields=this._parent.fields.slice(),this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types,this.subtypeField=this._parent.subtypeField,this.subtypes=this._parent.subtypes):(this.fields=[],this.typeIdField="",this.subtypeField="",this.objectIdField="",this.globalIdField="",this.spatialReference=new y({wkid:4326}),this.geometryType=n.point)}getField(e,t){let s;return(t=t||this.fields)&&(e=e.toLowerCase(),t.some(t=>(t&&t.name.toLowerCase()===e&&(s=t),!!s))),s}getFieldsIndex(){return null===this._fieldsIndex&&(this._fieldsIndex=T.fromLayer({timeInfo:this.timeInfo,editFieldsInfo:this.editFieldsInfo,dateFieldsTimeZone:this.dateFieldsTimeZone,datesInUnknownTimezone:this.datesInUnknownTimezone,fields:this.fields})),this._fieldsIndex}_maxProcessingRate(){return null!==this._parent?Math.min(this._maxProcessing,this._parent._maxProcessingRate()):Math.min(this._maxProcessing,this._maxQueryRate())}_maxQueryRate(){return null!==this._parent?Math.max(this._maxQuery,this._parent._maxQueryRate()):this._maxQuery}_checkCancelled(e){if(null!=e&&e.aborted)throw new t("Cancelled")}nativeCapabilities(){return this._parent.nativeCapabilities()}async _canDoAggregates(e,t,s,i,n){return null!==this._parent&&this._parent._canDoAggregates(e,t,s,i,n)}async _getAggregatePagesDataSourceDefinition(e,s,i,n,a,r,l){if(null===this._parent)throw new t("NeverReach");return this._parent._getAggregatePagesDataSourceDefinition(e,s,i,n,a,r,l)}async _getAgregagtePhysicalPage(e,s,i){if(null===this._parent)throw new t("NeverReach");return this._parent._getAgregagtePhysicalPage(e,s,i)}async databaseType(){if(7===this._databaseType){if(null!==e.applicationCache){const t=e.applicationCache.getDatabaseType(this._cacheableFeatureSetSourceKey());if(null!==t)return t}if(null!==this._databaseTypeProbed)return this._databaseTypeProbed;try{this._databaseTypeProbed=this._getDatabaseTypeImpl(),null!==e.applicationCache&&e.applicationCache.setDatabaseType(this._cacheableFeatureSetSourceKey(),this._databaseTypeProbed)}catch(t){throw null!==e.applicationCache&&e.applicationCache.clearDatabaseType(this._cacheableFeatureSetSourceKey()),t}return this._databaseTypeProbed}return this._databaseType}async _getDatabaseTypeImpl(){const e=[{thetype:2,testwhere:"(CAST( '2015-01-01' as DATETIME) = CAST( '2015-01-01' as DATETIME)) AND OBJECTID<0"},{thetype:3,testwhere:"(TO_DATE('2003-11-18','YYYY-MM-DD') = TO_DATE('2003-11-18','YYYY-MM-DD')) AND OBJECTID<0"},{thetype:1,testwhere:"(date '2015-01-01 10:10:10' = date '2015-01-01 10:10:10') AND OBJECTID<0"}];for(const t of e){if(!0===await this._runDatabaseProbe(t.testwhere))return t.thetype}return 1}_cacheableFeatureSetSourceKey(){return"MUSTBESET"}async _runDatabaseProbe(e){if(null!==this._parent)return this._parent._runDatabaseProbe(e);throw new t("NotImplemented")}isTable(){return this._parent?.isTable()??!1}_featureFromCache(e){if(void 0!==this._featureCache[e])return this._featureCache[e]}_isInFeatureSet(e){return 2}_getSet(e){throw new t("NotImplemented")}async _getFeature(e,s,i){if(this._checkCancelled(i),void 0!==this._featureFromCache(s))return this._featureFromCache(s);if(await this._getFeatures(e,s,this._maxProcessingRate(),i),this._checkCancelled(i),void 0!==this._featureFromCache(s))return this._featureFromCache(s);throw new t("MissingFeatures")}async _getFeatureBatch(e,t){this._checkCancelled(t);const s=new i([],e,!1,null),n=[];await this._getFeatures(s,-1,e.length,t),this._checkCancelled(t);for(const i of e)void 0!==this._featureFromCache(i)&&n.push(this._featureFromCache(i));return n}async _getFeatures(e,t,s,i){return"success"}_getFilteredSet(e,s,i,n,a){throw new t("NotImplemented")}async _refineSetBlock(e,t,s){if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQueryRate()))return await this._expandPagedSet(e,this._maxQueryRate(),0,0,s),this._refineSetBlock(e,t,s);this._checkCancelled(s);const i=e._candidates.length;this._refineKnowns(e,t);let n=i-e._candidates.length;if(0===e._candidates.length)return e;if(n>=t)return e;if(await this._refineIfParentKnown(e,t-n,s),this._checkCancelled(s),this._refineKnowns(e,t-n),n=i-e._candidates.length,n<t&&e._candidates.length>0){const i=t-n,a=this._prepareFetchAndRefineSet(e._candidates);return await this._fetchAndRefineFeatures(a,a.length>i?i:e._candidates.length,s),this._checkCancelled(s),this._refineKnowns(e,t-n),e}return e}_fetchAndRefineFeatures(e,t,s){return null}_prepareFetchAndRefineSet(e){const t=[];for(let s=0;s<e.length;s++)this._isPhysicalFeature(e[s])&&t.push(e[s]);return t}_isPhysicalFeature(e){return null===this._parent||this._parent._isPhysicalFeature(e)}_refineKnowns(e,t){let s=0,i=null;const n=[];t=this._maxQueryRate();for(let a=0;a<e._candidates.length&&"GETPAGES"!==e._candidates[a];a++){let r=!1;const l=this._candidateIdTransform(e._candidates[a]);l!==e._candidates[a]&&(r=!0);const u=this._isInFeatureSet(l);if(0===u)!0===r?e._known.includes(l)||(e._known.push(l),s+=1):(e._known.push(e._candidates[a]),s+=1),null===i?i={start:a,end:a}:i.end===a-1?i.end=a:(n.push(i),i={start:a,end:a});else if(1===u)null===i?i={start:a,end:a}:i.end===a-1?i.end=a:(n.push(i),i={start:a,end:a}),s+=1;else if(2===u&&(s+=1,!0===e._ordered))break;if(s>=t)break}null!==i&&n.push(i);for(let a=n.length-1;a>=0;a--)e._candidates.splice(n[a].start,n[a].end-n[a].start+1)}_refineIfParentKnown(e,t,s){const n=new i([],[],e._ordered,null);return n._candidates=e._candidates.slice(),this._parent._refineSetBlock(n,t,s)}_candidateIdTransform(e){return this._parent._candidateIdTransform(e)}_checkIfNeedToExpandKnownPage(e,t){if(null===e.pagesDefinition)return!1;let s=0;for(let i=e._lastFetchedIndex;i<e._known.length;i++){if("GETPAGES"===e._known[i])return!0;if(void 0===this._featureCache[e._known[i]]&&(s+=1,s>=t))break}return!1}_checkIfNeedToExpandCandidatePage(e,t){if(null===e.pagesDefinition)return!1;let s=0;for(let i=0;i<e._candidates.length;i++){if("GETPAGES"===e._candidates[i])return!0;if(s+=1,s>=t)break}return!1}async _expandPagedSet(e,s,i,n,a){if(null===this._parent)throw new t("NotImplemented");return this._parent._expandPagedSet(e,s,i,n,a)}async _expandPagedSetFeatureSet(e,t,s,i,n){if(e._known.length>0&&"GETPAGES"===e._known[e._known.length-1]&&(i=1),0===i&&e._candidates.length>0&&"GETPAGES"===e._candidates[e._candidates.length-1]&&(i=2),0===i)return"finished";const a=await this._getPage(e,i,n);return s+a<t?this._expandPagedSet(e,t,s+a,0,n):"success"}async _getPage(e,t,s){const i=1===t?e._known:e._candidates;if(e.pagesDefinition.internal.set.length>e.pagesDefinition.resultOffset||!0===e.pagesDefinition.internal.fullyResolved){i.length=i.length-1;let t=0;for(let n=0;n<e.pagesDefinition.resultRecordCount&&!(e.pagesDefinition.resultOffset+n>=e.pagesDefinition.internal.set.length);n++)i[i.length]=e.pagesDefinition.internal.set[e.pagesDefinition.resultOffset+n],t++;e.pagesDefinition.resultOffset+=t;let s=!1;return!0===e.pagesDefinition.internal.fullyResolved&&e.pagesDefinition.internal.set.length<=e.pagesDefinition.resultOffset&&(s=!0),!1===s&&i.push("GETPAGES"),t}return await this._getPhysicalPage(e,t,s),this._getPage(e,t,s)}_getPhysicalPage(e,t,s){return null}_clonePageDefinition(e){return null===this._parent?null:this._parent._clonePageDefinition(e)}_first(e){return this.iterator(e).next()}first(e){return this._first(e)}async calculateStatistic(e,t,s,i){await this._ensureLoaded();let n=await this._stat(e,t,"",null,null,s,i);return!1===n.calculated&&(n=await this._manualStat(e,t,s,i)),n.result}async _manualStat(e,t,s,i){let n=null;switch(e.toLowerCase()){case"count":return n=await _(this,i),{calculated:!0,result:n};case"distinct":return n=await f(this,t,s,i),{calculated:!0,result:n};case"avg":case"mean":return n=await d(this,t,i),{calculated:!0,result:n};case"stdev":return n=await c(this,t,i),{calculated:!0,result:n};case"variance":return n=await o(this,t,i),{calculated:!0,result:n};case"sum":return n=await h(this,t,i),{calculated:!0,result:n};case"min":return n=await u(this,t,i),{calculated:!0,result:n};case"max":return n=await l(this,t,i),{calculated:!0,result:n};default:return{calculated:!0,result:0}}}async _stat(e,t,s,i,n,a,r){const l=await this._parent._stat(e,t,s,i,n,a,r);return!1===l.calculated?null===n&&""===s&&null===i?this._manualStat(e,t,a,r):{calculated:!1}:l}_unionAllGeomSelf(e){const t=this.iterator(this._defaultTracker(e)),s=[];return new Promise((e,i)=>{this._unionShapeInBatches(s,t,e,i)})}_unionAllGeom(e){return new Promise((t,s)=>{const i=this.iterator(this._defaultTracker(e)),n=[];this._unionShapeInBatches(n,i,t,s)})}_unionShapeInBatches(e,t,s,i){t.next().then(n=>{try{null!==n&&null!==n.geometry&&e.push(n.geometry),e.length>30||null===n&&e.length>1?p("union",[e.map(e=>e.toJSON())]).then(a=>{try{null===n?s(a):(e=[F(a)],this._unionShapeInBatches(e,t,s,i))}catch(r){i(r)}},i):null===n?1===e.length?s(e[0]):s(null):this._unionShapeInBatches(e,t,s,i)}catch(a){i(a)}},i)}iterator(e){return new s(this,e)}intersection(e,t=!1){return b._featuresetFunctions.intersection.bind(this)(e,t)}difference(e,t=!1,s=!0){return b._featuresetFunctions.difference.bind(this)(e,t,s)}symmetricDifference(e,t=!1,s=!0){return b._featuresetFunctions.symmetricDifference.bind(this)(e,t,s)}morphShape(e,t,s="unknown",i=null){return b._featuresetFunctions.morphShape.bind(this)(e,t,s,i)}morphShapeAndAttributes(e,t,s="unknown"){return b._featuresetFunctions.morphShapeAndAttributes.bind(this)(e,t,s)}union(e,t=!1){return b._featuresetFunctions.union.bind(this)(e,t)}intersects(e){return b._featuresetFunctions.intersects.bind(this)(e)}envelopeIntersects(e){return b._featuresetFunctions.envelopeIntersects.bind(this)(e)}contains(e){return b._featuresetFunctions.contains.bind(this)(e)}overlaps(e){return b._featuresetFunctions.overlaps.bind(this)(e)}relate(e,t){return b._featuresetFunctions.relate.bind(this)(e,t)}within(e){return b._featuresetFunctions.within.bind(this)(e)}touches(e){return b._featuresetFunctions.touches.bind(this)(e)}top(e){return b._featuresetFunctions.top.bind(this)(e)}crosses(e){return b._featuresetFunctions.crosses.bind(this)(e)}buffer(e,t,s,i=!0){return b._featuresetFunctions.buffer.bind(this)(e,t,s,i)}filter(e,t=null){return b._featuresetFunctions.filter.bind(this)(e,t)}orderBy(e){return b._featuresetFunctions.orderBy.bind(this)(e)}dissolve(e,t){return b._featuresetFunctions.dissolve.bind(this)(e,t)}groupby(e,t){return b._featuresetFunctions.groupby.bind(this)(e,t)}reduce(e,t=null,s){return new Promise((i,n)=>{this._reduceImpl(this.iterator(this._defaultTracker(s)),e,t,0,i,n,0)})}_reduceImpl(e,t,s,i,n,a,r){try{if(++r>1e3)return void setTimeout(()=>{r=0,this._reduceImpl(e,t,s,i,n,a,r)});e.next().then(l=>{try{if(null===l)n(s);else{const u=t(s,l,i,this);m(u)?u.then(s=>{this._reduceImpl(e,t,s,i+1,n,a,r)},a):this._reduceImpl(e,t,u,i+1,n,a,r)}}catch(u){a(u)}},a)}catch(l){a(l)}}removeField(e){return b._featuresetFunctions.removeField.bind(this)(e)}addField(e,t,s=null){return b._featuresetFunctions.addField.bind(this)(e,t,s)}async sumArea(e,t,s){const i=this.iterator(s);let n,a=0;for(;null!=(n=await i.next());)null!=n.geometry&&(a+=null!=t?await p("geodeticArea",[n.geometry.toJSON(),e,t]):await p("area",[n.geometry.toJSON(),e]));return a}async sumLength(e,t,s){const i=this.iterator(s);let n,a=0;for(;null!=(n=await i.next());)null!=n.geometry&&(a+=null!=t?await p("geodeticLength",[n.geometry.toJSON(),e,t]):await p("length",[n.geometry.toJSON(),e]));return a}async distinct(e,t=1e3,s=null,i){await this.load();const n=g.create(e,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC});return I(n,s),this.calculateStatistic("distinct",n,t,this._defaultTracker(i))}async min(e,t=null,s){await this.load();const i=g.create(e,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC});return I(i,t),this.calculateStatistic("min",i,-1,this._defaultTracker(s))}async max(e,t=null,s){await this.load();const i=g.create(e,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC});return I(i,t),this.calculateStatistic("max",i,-1,this._defaultTracker(s))}async avg(e,t=null,s){await this.load();const i=g.create(e,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC});return I(i,t),this.calculateStatistic("avg",i,-1,this._defaultTracker(s))}async sum(e,t=null,s){await this.load();const i=g.create(e,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC});return I(i,t),this.calculateStatistic("sum",i,-1,this._defaultTracker(s))}async stdev(e,t=null,s){await this.load();const i=g.create(e,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC});return I(i,t),this.calculateStatistic("stdev",i,-1,this._defaultTracker(s))}async variance(e,t=null,s){await this.load();const i=g.create(e,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC});return I(i,t),this.calculateStatistic("variance",i,-1,this._defaultTracker(s))}async count(e){return await this.load(),this.calculateStatistic("count",g.create("1",{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC}),-1,this._defaultTracker(e))}_defaultTracker(e){return e??{aborted:!1}}forEach(e,t){return new Promise((s,i)=>{this._forEachImpl(this.iterator(this._defaultTracker(t)),e,this,s,i,0)})}_forEachImpl(e,t,s,i,n,a){try{if(++a>1e3)return void setTimeout(()=>{a=0,this._forEachImpl(e,t,s,i,n,a)},0);e.next().then(r=>{try{if(null===r)i(s);else{const l=t(r);null==l?this._forEachImpl(e,t,s,i,n,a):m(l)?l.then(()=>{try{this._forEachImpl(e,t,s,i,n,a)}catch(r){n(r)}},n):this._forEachImpl(e,t,s,i,n,a)}}catch(l){n(l)}},n)}catch(r){n(r)}}convertToJSON(e){const t={layerDefinition:{geometryType:this.geometryType,fields:[]},featureSet:{features:[],geometryType:this.geometryType}};for(let s=0;s<this.fields.length;s++)t.layerDefinition.fields.push(a(this.fields[s]));return this.reduce((e,s)=>{const i={geometry:s.geometry?.toJSON(),attributes:{}};for(const t in s.attributes)i.attributes[t]=s.attributes[t];return t.featureSet.features.push(i),1},0,e).then(()=>t)}castToText(e=!1){return"object, FeatureSet"}queryAttachments(e,t,s,i,n){return this._parent.queryAttachments(e,t,s,i,n)}serviceUrl(){return this._parent.serviceUrl()}subtypeMetaData(){return this.subtypeField&&this.subtypes?{subtypeField:this.subtypeField,subtypes:this.subtypes?this.subtypes.map(e=>({name:e.name,code:e.code})):[]}:this.typeIdField?{subtypeField:this.typeIdField,subtypes:this.types?this.types.map(e=>({name:e.name,code:e.id})):[]}:null}relationshipMetaData(){return this._parent.relationshipMetaData()}get gdbVersion(){return this._parent?this._parent.gdbVersion:""}schema(){const e=[];for(const t of this.fields)e.push(a(t));return{objectIdField:this.objectIdField,globalIdField:this.globalIdField,geometryType:void 0===r[this.geometryType]?"esriGeometryNull":r[this.geometryType],fields:e}}async convertToText(e,t){if("schema"===e)return await this._ensureLoaded(),JSON.stringify(this.schema());if("featureset"===e){await this._ensureLoaded();const e=[];await this.reduce((t,s)=>{const i={geometry:s.geometry?s.geometry.toJSON():null,attributes:s.attributes};return null!==i.geometry&&i.geometry.spatialReference&&delete i.geometry.spatialReference,e.push(i),1},0,t);const s=this.schema();return s.features=e,s.spatialReference=this.spatialReference.toJSON(),JSON.stringify(s)}return this.castToText()}getFeatureByObjectId(e,t){return this._parent.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._parent.getOwningSystemUrl()}getIdentityUser(){return this._parent.getIdentityUser()}getRootFeatureSet(){return null!==this._parent?this._parent.getRootFeatureSet():this}getDataSourceFeatureSet(){return null!==this._parent?this._parent.getDataSourceFeatureSet():this}castAsJson(e=null){return"keeptype"===e?.featureset?this:"none"===e?.featureset?null:{type:"FeatureSet"}}async castAsJsonAsync(e=null,t=null){if("keeptype"===t?.featureset)return this;if("schema"===t?.featureset)return await this._ensureLoaded(),JSON.parse(JSON.stringify(this.schema()));if("none"===t?.featureset)return null;await this._ensureLoaded();const s=[];await this.reduce((e,i)=>{const n={geometry:i.geometry?!0===t?.keepGeometryType?i.geometry:i.geometry.toJSON():null,attributes:i.attributes};return null!==n.geometry&&n.geometry.spatialReference&&!0!==t?.keepGeometryType&&delete n.geometry.spatialReference,s.push(n),1},0,e);const i=this.schema();return i.features=s,i.spatialReference=!0===t?.keepGeometryType?this.spatialReference:this.spatialReference?.toJSON(),i}fieldTimeZone(e){return this.getFieldsIndex().getTimeZone(e)}get preferredTimeZone(){return this._parent?.preferredTimeZone??null}get dateFieldsTimeZone(){return this._parent?.dateFieldsTimeZone??null}get dateFieldsTimeZoneDefaultUTC(){if(this.datesInUnknownTimezone)return"unknown";const e=this.dateFieldsTimeZone??"UTC";return""===e?"UTC":e}get datesInUnknownTimezone(){return this._parent.datesInUnknownTimezone}get editFieldsInfo(){return this._parent?.editFieldsInfo??null}get timeInfo(){return this._parent?.timeInfo??null}set featureSetInfo(e){this.fsetInfo=e}async getFeatureSetInfo(){return this.fsetInfo??await(this._parent?.getFeatureSetInfo())??null}}function I(e,t){if(null!==t){const s={};for(const e in t)s[e.toLowerCase()]=t[e];e.parameters=s}}export{b as default};
5
+ import e from"./cache.js";import{FeatureSetError as t}from"./errorsupport.js";import s from"./FeatureSetIterator.js";import i from"./IdSet.js";import{layerGeometryEsriConstants as n,esriFieldToJson as a,layerGeometryEsriRestConstants as r}from"./shared.js";import{max as l,min as u,sum as h,variance as o,stdev as c,mean as d,distinct as f,count as _}from"./stats.js";import{invokeRemoteGeometryOp as p}from"../../geometry/operatorsWorkerConnection.js";import{isPromiseLike as m}from"../../../core/promiseUtils.js";import g from"../../../core/sql/WhereClause.js";import y from"../../../geometry/SpatialReference.js";import{fromJSON as F}from"../../../geometry/support/jsonUtils.js";import T from"../../../layers/support/FieldsIndex.js";class b{constructor(e){this.recentlyUsedQueries=null,this.featureSetQueryInterceptor=null,this._idstates=[],this._parent=null,this._wset=null,this._mainSetInUse=null,this._maxProcessing=200,this._maxQuery=500,this._totalCount=-1,this._databaseType=7,this._databaseTypeProbed=null,this.declaredRootClass="esri.arcade.featureset.support.FeatureSet",this._featureCache=Object.create(null),this.typeIdField=null,this.types=null,this.subtypeField=null,this.subtypes=null,this.fields=null,this.geometryType="",this.objectIdField="",this.globalIdField="",this.spatialReference=null,this.hasM=!1,this.hasZ=!1,this._transparent=!1,this.loaded=!1,this._loadPromise=null,this._fieldsIndex=null,this.fsetInfo=null,e?.lrucache&&(this.recentlyUsedQueries=e.lrucache),e?.interceptor&&(this.featureSetQueryInterceptor=e.interceptor)}optimisePagingFeatureQueries(e){this._parent&&this._parent.optimisePagingFeatureQueries(e)}_hasMemorySource(){return!0}static{this._featuresetFunctions={}}prop(e,t){return void 0===t?this[e]:(void 0!==this[e]&&(this[e]=t),this)}end(){return null!==this._parent&&!0===this._parent._transparent?this._parent.end():this._parent}_ensureLoaded(){return this.load()}load(){return null===this._loadPromise&&(this._loadPromise=this.loadImpl()),this._loadPromise}async loadImpl(){return!0===this._parent?.loaded?(this._initialiseFeatureSet(),this):(await(this._parent?.load()),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){null!==this._parent?(this.fields=this._parent.fields.slice(),this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types,this.subtypeField=this._parent.subtypeField,this.subtypes=this._parent.subtypes):(this.fields=[],this.typeIdField="",this.subtypeField="",this.objectIdField="",this.globalIdField="",this.spatialReference=new y({wkid:4326}),this.geometryType=n.point)}getField(e,t){let s;return(t=t||this.fields)&&(e=e.toLowerCase(),t.some(t=>(t&&t.name.toLowerCase()===e&&(s=t),!!s))),s}getFieldsIndex(){return null===this._fieldsIndex&&(this._fieldsIndex=T.fromLayer({timeInfo:this.timeInfo,editFieldsInfo:this.editFieldsInfo,dateFieldsTimeZone:this.dateFieldsTimeZone,datesInUnknownTimezone:this.datesInUnknownTimezone,fields:this.fields})),this._fieldsIndex}_maxProcessingRate(){return null!==this._parent?Math.min(this._maxProcessing,this._parent._maxProcessingRate()):Math.min(this._maxProcessing,this._maxQueryRate())}_maxQueryRate(){return null!==this._parent?Math.max(this._maxQuery,this._parent._maxQueryRate()):this._maxQuery}_checkCancelled(e){if(null!=e&&e.aborted)throw new t("Cancelled")}nativeCapabilities(){return this._parent.nativeCapabilities()}async _canDoAggregates(e,t,s,i,n){return null!==this._parent&&this._parent._canDoAggregates(e,t,s,i,n)}async _getAggregatePagesDataSourceDefinition(e,s,i,n,a,r,l){if(null===this._parent)throw new t("NeverReach");return this._parent._getAggregatePagesDataSourceDefinition(e,s,i,n,a,r,l)}async _getAgregagtePhysicalPage(e,s,i){if(null===this._parent)throw new t("NeverReach");return this._parent._getAgregagtePhysicalPage(e,s,i)}async databaseType(){if(7===this._databaseType){if(null!==e.applicationCache){const t=e.applicationCache.getDatabaseType(this._cacheableFeatureSetSourceKey());if(null!==t)return t}if(null!==this._databaseTypeProbed)return this._databaseTypeProbed;try{this._databaseTypeProbed=this._getDatabaseTypeImpl(),null!==e.applicationCache&&e.applicationCache.setDatabaseType(this._cacheableFeatureSetSourceKey(),this._databaseTypeProbed)}catch(t){throw null!==e.applicationCache&&e.applicationCache.clearDatabaseType(this._cacheableFeatureSetSourceKey()),t}return this._databaseTypeProbed}return this._databaseType}async _getDatabaseTypeImpl(){const e=[{thetype:2,testwhere:"(CAST( '2015-01-01' as DATETIME) = CAST( '2015-01-01' as DATETIME)) AND OBJECTID<0"},{thetype:3,testwhere:"(TO_DATE('2003-11-18','YYYY-MM-DD') = TO_DATE('2003-11-18','YYYY-MM-DD')) AND OBJECTID<0"},{thetype:1,testwhere:"(date '2015-01-01 10:10:10' = date '2015-01-01 10:10:10') AND OBJECTID<0"}];for(const t of e){if(!0===await this._runDatabaseProbe(t.testwhere))return t.thetype}return 1}_cacheableFeatureSetSourceKey(){return"MUSTBESET"}async _runDatabaseProbe(e){if(null!==this._parent)return this._parent._runDatabaseProbe(e);throw new t("NotImplemented")}isTable(){return this._parent?.isTable()??!1}_featureFromCache(e){if(void 0!==this._featureCache[e])return this._featureCache[e]}_isInFeatureSet(e){return 2}_getSet(e){throw new t("NotImplemented")}async _getFeature(e,s,i){if(this._checkCancelled(i),void 0!==this._featureFromCache(s))return this._featureFromCache(s);if(await this._getFeatures(e,s,this._maxProcessingRate(),i),this._checkCancelled(i),void 0!==this._featureFromCache(s))return this._featureFromCache(s);throw new t("MissingFeatures")}async _getFeatureBatch(e,t){this._checkCancelled(t);const s=new i([],e,!1,null),n=[];await this._getFeatures(s,-1,e.length,t),this._checkCancelled(t);for(const i of e)void 0!==this._featureFromCache(i)&&n.push(this._featureFromCache(i));return n}async _getFeatures(e,t,s,i){return"success"}_getFilteredSet(e,s,i,n,a){throw new t("NotImplemented")}async _refineSetBlock(e,t,s){if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQueryRate()))return await this._expandPagedSet(e,this._maxQueryRate(),0,0,s),this._refineSetBlock(e,t,s);this._checkCancelled(s);const i=e._candidates.length;this._refineKnowns(e,t);let n=i-e._candidates.length;if(0===e._candidates.length)return e;if(n>=t)return e;if(await this._refineIfParentKnown(e,t-n,s),this._checkCancelled(s),this._refineKnowns(e,t-n),n=i-e._candidates.length,n<t&&e._candidates.length>0){const i=t-n,a=this._prepareFetchAndRefineSet(e._candidates);return await this._fetchAndRefineFeatures(a,a.length>i?i:e._candidates.length,s),this._checkCancelled(s),this._refineKnowns(e,t-n),e}return e}_fetchAndRefineFeatures(e,t,s){return null}_prepareFetchAndRefineSet(e){const t=[];for(let s=0;s<e.length;s++)this._isPhysicalFeature(e[s])&&t.push(e[s]);return t}_isPhysicalFeature(e){return null===this._parent||this._parent._isPhysicalFeature(e)}_refineKnowns(e,t){let s=0,i=null;const n=[];t=this._maxQueryRate();for(let a=0;a<e._candidates.length&&"GETPAGES"!==e._candidates[a];a++){let r=!1;const l=this._candidateIdTransform(e._candidates[a]);l!==e._candidates[a]&&(r=!0);const u=this._isInFeatureSet(l);if(0===u)!0===r?e._known.includes(l)||(e._known.push(l),s+=1):(e._known.push(e._candidates[a]),s+=1),null===i?i={start:a,end:a}:i.end===a-1?i.end=a:(n.push(i),i={start:a,end:a});else if(1===u)null===i?i={start:a,end:a}:i.end===a-1?i.end=a:(n.push(i),i={start:a,end:a}),s+=1;else if(2===u&&(s+=1,!0===e._ordered))break;if(s>=t)break}null!==i&&n.push(i);for(let a=n.length-1;a>=0;a--)e._candidates.splice(n[a].start,n[a].end-n[a].start+1)}_refineIfParentKnown(e,t,s){const n=new i([],[],e._ordered,null);return n._candidates=e._candidates.slice(),this._parent._refineSetBlock(n,t,s)}_candidateIdTransform(e){return this._parent._candidateIdTransform(e)}_checkIfNeedToExpandKnownPage(e,t){if(null===e.pagesDefinition)return!1;let s=0;for(let i=e._lastFetchedIndex;i<e._known.length;i++){if("GETPAGES"===e._known[i])return!0;if(void 0===this._featureCache[e._known[i]]&&(s+=1,s>=t))break}return!1}_checkIfNeedToExpandCandidatePage(e,t){if(null===e.pagesDefinition)return!1;let s=0;for(let i=0;i<e._candidates.length;i++){if("GETPAGES"===e._candidates[i])return!0;if(s+=1,s>=t)break}return!1}async _expandPagedSet(e,s,i,n,a){if(null===this._parent)throw new t("NotImplemented");return this._parent._expandPagedSet(e,s,i,n,a)}async _expandPagedSetFeatureSet(e,t,s,i,n){if(e._known.length>0&&"GETPAGES"===e._known[e._known.length-1]&&(i=1),0===i&&e._candidates.length>0&&"GETPAGES"===e._candidates[e._candidates.length-1]&&(i=2),0===i)return"finished";const a=await this._getPage(e,i,n);return s+a<t?this._expandPagedSet(e,t,s+a,0,n):"success"}async _getPage(e,t,s){const i=1===t?e._known:e._candidates;if(e.pagesDefinition.internal.set.length>e.pagesDefinition.resultOffset||!0===e.pagesDefinition.internal.fullyResolved){i.length=i.length-1;let t=0;for(let n=0;n<e.pagesDefinition.resultRecordCount&&!(e.pagesDefinition.resultOffset+n>=e.pagesDefinition.internal.set.length);n++)i[i.length]=e.pagesDefinition.internal.set[e.pagesDefinition.resultOffset+n],t++;e.pagesDefinition.resultOffset+=t;let s=!1;return!0===e.pagesDefinition.internal.fullyResolved&&e.pagesDefinition.internal.set.length<=e.pagesDefinition.resultOffset&&(s=!0),!1===s&&i.push("GETPAGES"),t}return await this._getPhysicalPage(e,t,s),this._getPage(e,t,s)}_getPhysicalPage(e,t,s){return null}_clonePageDefinition(e){return null===this._parent?null:this._parent._clonePageDefinition(e)}_first(e){return this.iterator(e).next()}first(e){return this._first(e)}async isEmpty(e){return this._totalCount>=0?0===this._totalCount:null==await this._first(e)}async calculateStatistic(e,t,s,i){await this._ensureLoaded();let n=await this._stat(e,t,"",null,null,s,i);return!1===n.calculated&&(n=await this._manualStat(e,t,s,i)),n.result}async _manualStat(e,t,s,i){let n=null;switch(e.toLowerCase()){case"count":return n=await _(this,i),{calculated:!0,result:n};case"distinct":return n=await f(this,t,s,i),{calculated:!0,result:n};case"avg":case"mean":return n=await d(this,t,i),{calculated:!0,result:n};case"stdev":return n=await c(this,t,i),{calculated:!0,result:n};case"variance":return n=await o(this,t,i),{calculated:!0,result:n};case"sum":return n=await h(this,t,i),{calculated:!0,result:n};case"min":return n=await u(this,t,i),{calculated:!0,result:n};case"max":return n=await l(this,t,i),{calculated:!0,result:n};default:return{calculated:!0,result:0}}}async _stat(e,t,s,i,n,a,r){const l=await this._parent._stat(e,t,s,i,n,a,r);return!1===l.calculated?null===n&&""===s&&null===i?this._manualStat(e,t,a,r):{calculated:!1}:l}_unionAllGeomSelf(e){const t=this.iterator(this._defaultTracker(e)),s=[];return new Promise((e,i)=>{this._unionShapeInBatches(s,t,e,i)})}_unionAllGeom(e){return new Promise((t,s)=>{const i=this.iterator(this._defaultTracker(e)),n=[];this._unionShapeInBatches(n,i,t,s)})}_unionShapeInBatches(e,t,s,i){t.next().then(n=>{try{null!==n&&null!==n.geometry&&e.push(n.geometry),e.length>30||null===n&&e.length>1?p("union",[e.map(e=>e.toJSON())]).then(a=>{try{null===n?s(a):(e=[F(a)],this._unionShapeInBatches(e,t,s,i))}catch(r){i(r)}},i):null===n?1===e.length?s(e[0]):s(null):this._unionShapeInBatches(e,t,s,i)}catch(a){i(a)}},i)}iterator(e){return new s(this,e)}intersection(e,t=!1){return b._featuresetFunctions.intersection.bind(this)(e,t)}difference(e,t=!1,s=!0){return b._featuresetFunctions.difference.bind(this)(e,t,s)}symmetricDifference(e,t=!1,s=!0){return b._featuresetFunctions.symmetricDifference.bind(this)(e,t,s)}morphShape(e,t,s="unknown",i=null){return b._featuresetFunctions.morphShape.bind(this)(e,t,s,i)}morphShapeAndAttributes(e,t,s="unknown"){return b._featuresetFunctions.morphShapeAndAttributes.bind(this)(e,t,s)}union(e,t=!1){return b._featuresetFunctions.union.bind(this)(e,t)}intersects(e){return b._featuresetFunctions.intersects.bind(this)(e)}envelopeIntersects(e){return b._featuresetFunctions.envelopeIntersects.bind(this)(e)}contains(e){return b._featuresetFunctions.contains.bind(this)(e)}overlaps(e){return b._featuresetFunctions.overlaps.bind(this)(e)}relate(e,t){return b._featuresetFunctions.relate.bind(this)(e,t)}within(e){return b._featuresetFunctions.within.bind(this)(e)}touches(e){return b._featuresetFunctions.touches.bind(this)(e)}top(e){return b._featuresetFunctions.top.bind(this)(e)}crosses(e){return b._featuresetFunctions.crosses.bind(this)(e)}buffer(e,t,s,i=!0){return b._featuresetFunctions.buffer.bind(this)(e,t,s,i)}filter(e,t=null){return b._featuresetFunctions.filter.bind(this)(e,t)}orderBy(e){return b._featuresetFunctions.orderBy.bind(this)(e)}dissolve(e,t){return b._featuresetFunctions.dissolve.bind(this)(e,t)}groupby(e,t){return b._featuresetFunctions.groupby.bind(this)(e,t)}reduce(e,t=null,s){return new Promise((i,n)=>{this._reduceImpl(this.iterator(this._defaultTracker(s)),e,t,0,i,n,0)})}_reduceImpl(e,t,s,i,n,a,r){try{if(++r>1e3)return void setTimeout(()=>{r=0,this._reduceImpl(e,t,s,i,n,a,r)});e.next().then(l=>{try{if(null===l)n(s);else{const u=t(s,l,i,this);m(u)?u.then(s=>{this._reduceImpl(e,t,s,i+1,n,a,r)},a):this._reduceImpl(e,t,u,i+1,n,a,r)}}catch(u){a(u)}},a)}catch(l){a(l)}}removeField(e){return b._featuresetFunctions.removeField.bind(this)(e)}addField(e,t,s=null){return b._featuresetFunctions.addField.bind(this)(e,t,s)}async sumArea(e,t,s){const i=this.iterator(s);let n,a=0;for(;null!=(n=await i.next());)null!=n.geometry&&(a+=null!=t?await p("geodeticArea",[n.geometry.toJSON(),e,t]):await p("area",[n.geometry.toJSON(),e]));return a}async sumLength(e,t,s){const i=this.iterator(s);let n,a=0;for(;null!=(n=await i.next());)null!=n.geometry&&(a+=null!=t?await p("geodeticLength",[n.geometry.toJSON(),e,t]):await p("length",[n.geometry.toJSON(),e]));return a}async distinct(e,t=1e3,s=null,i){await this.load();const n=g.create(e,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC});return I(n,s),this.calculateStatistic("distinct",n,t,this._defaultTracker(i))}async min(e,t=null,s){await this.load();const i=g.create(e,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC});return I(i,t),this.calculateStatistic("min",i,-1,this._defaultTracker(s))}async max(e,t=null,s){await this.load();const i=g.create(e,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC});return I(i,t),this.calculateStatistic("max",i,-1,this._defaultTracker(s))}async avg(e,t=null,s){await this.load();const i=g.create(e,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC});return I(i,t),this.calculateStatistic("avg",i,-1,this._defaultTracker(s))}async sum(e,t=null,s){await this.load();const i=g.create(e,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC});return I(i,t),this.calculateStatistic("sum",i,-1,this._defaultTracker(s))}async stdev(e,t=null,s){await this.load();const i=g.create(e,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC});return I(i,t),this.calculateStatistic("stdev",i,-1,this._defaultTracker(s))}async variance(e,t=null,s){await this.load();const i=g.create(e,{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC});return I(i,t),this.calculateStatistic("variance",i,-1,this._defaultTracker(s))}async count(e){return await this.load(),this.calculateStatistic("count",g.create("1",{fieldsIndex:this.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC}),-1,this._defaultTracker(e))}_defaultTracker(e){return e??{aborted:!1}}forEach(e,t){return new Promise((s,i)=>{this._forEachImpl(this.iterator(this._defaultTracker(t)),e,this,s,i,0)})}_forEachImpl(e,t,s,i,n,a){try{if(++a>1e3)return void setTimeout(()=>{a=0,this._forEachImpl(e,t,s,i,n,a)},0);e.next().then(r=>{try{if(null===r)i(s);else{const l=t(r);null==l?this._forEachImpl(e,t,s,i,n,a):m(l)?l.then(()=>{try{this._forEachImpl(e,t,s,i,n,a)}catch(r){n(r)}},n):this._forEachImpl(e,t,s,i,n,a)}}catch(l){n(l)}},n)}catch(r){n(r)}}convertToJSON(e){const t={layerDefinition:{geometryType:this.geometryType,fields:[]},featureSet:{features:[],geometryType:this.geometryType}};for(let s=0;s<this.fields.length;s++)t.layerDefinition.fields.push(a(this.fields[s]));return this.reduce((e,s)=>{const i={geometry:s.geometry?.toJSON(),attributes:{}};for(const t in s.attributes)i.attributes[t]=s.attributes[t];return t.featureSet.features.push(i),1},0,e).then(()=>t)}castToText(e=!1){return"object, FeatureSet"}queryAttachments(e,t,s,i,n){return this._parent.queryAttachments(e,t,s,i,n)}serviceUrl(){return this._parent.serviceUrl()}subtypeMetaData(){return this.subtypeField&&this.subtypes?{subtypeField:this.subtypeField,subtypes:this.subtypes?this.subtypes.map(e=>({name:e.name,code:e.code})):[]}:this.typeIdField?{subtypeField:this.typeIdField,subtypes:this.types?this.types.map(e=>({name:e.name,code:e.id})):[]}:null}relationshipMetaData(){return this._parent.relationshipMetaData()}get gdbVersion(){return this._parent?this._parent.gdbVersion:""}schema(){const e=[];for(const t of this.fields)e.push(a(t));return{objectIdField:this.objectIdField,globalIdField:this.globalIdField,geometryType:void 0===r[this.geometryType]?"esriGeometryNull":r[this.geometryType],fields:e}}async convertToText(e,t){if("schema"===e)return await this._ensureLoaded(),JSON.stringify(this.schema());if("featureset"===e){await this._ensureLoaded();const e=[];await this.reduce((t,s)=>{const i={geometry:s.geometry?s.geometry.toJSON():null,attributes:s.attributes};return null!==i.geometry&&i.geometry.spatialReference&&delete i.geometry.spatialReference,e.push(i),1},0,t);const s=this.schema();return s.features=e,s.spatialReference=this.spatialReference.toJSON(),JSON.stringify(s)}return this.castToText()}getFeatureByObjectId(e,t){return this._parent.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._parent.getOwningSystemUrl()}getIdentityUser(){return this._parent.getIdentityUser()}getRootFeatureSet(){return null!==this._parent?this._parent.getRootFeatureSet():this}getDataSourceFeatureSet(){return null!==this._parent?this._parent.getDataSourceFeatureSet():this}castAsJson(e=null){return"keeptype"===e?.featureset?this:"none"===e?.featureset?null:{type:"FeatureSet"}}async castAsJsonAsync(e=null,t=null){if("keeptype"===t?.featureset)return this;if("schema"===t?.featureset)return await this._ensureLoaded(),JSON.parse(JSON.stringify(this.schema()));if("none"===t?.featureset)return null;await this._ensureLoaded();const s=[];await this.reduce((e,i)=>{const n={geometry:i.geometry?!0===t?.keepGeometryType?i.geometry:i.geometry.toJSON():null,attributes:i.attributes};return null!==n.geometry&&n.geometry.spatialReference&&!0!==t?.keepGeometryType&&delete n.geometry.spatialReference,s.push(n),1},0,e);const i=this.schema();return i.features=s,i.spatialReference=!0===t?.keepGeometryType?this.spatialReference:this.spatialReference?.toJSON(),i}fieldTimeZone(e){return this.getFieldsIndex().getTimeZone(e)}get preferredTimeZone(){return this._parent?.preferredTimeZone??null}get dateFieldsTimeZone(){return this._parent?.dateFieldsTimeZone??null}get dateFieldsTimeZoneDefaultUTC(){if(this.datesInUnknownTimezone)return"unknown";const e=this.dateFieldsTimeZone??"UTC";return""===e?"UTC":e}get datesInUnknownTimezone(){return this._parent.datesInUnknownTimezone}get editFieldsInfo(){return this._parent?.editFieldsInfo??null}get timeInfo(){return this._parent?.timeInfo??null}set featureSetInfo(e){this.fsetInfo=e}async getFeatureSetInfo(){return this.fsetInfo??await(this._parent?.getFeatureSetInfo())??null}}function I(e,t){if(null!==t){const s={};for(const e in t)s[e.toLowerCase()]=t[e];e.parameters=s}}export{b 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as n,createDateTimeZone as r}from"../ArcadeDate.js";import{toStringEnumKey as e,StringEnum as t}from"../enum.js";import{ArcadeExecutionError as o}from"../executionError.js";import{B as u,K as l,s as i,g as a,e as s,f as c,u as f,N as m,J as d,O as h,P as N}from"../../chunks/languageUtils.js";import{DateOnly as y}from"../../core/sql/DateOnly.js";import{TimeOnly as w}from"../../core/sql/TimeOnly.js";import{getLocale as g}from"../../intl/locale.js";import{DateTime as T}from"luxon";import{isString as A}from"../../support/guards.js";function D(n,r,e){return n+(k(e)?p:P)[r]}function k(n){return n%4==0&&(n%100!=0||n%400==0)}const P=[0,31,59,90,120,151,181,212,243,273,304,334],p=[0,31,60,91,121,152,182,213,244,274,305,335];function S(n){return null===n?n:!1===n.isValid?null:n}function Z(n,r){switch(e(n)){case"":case"default":return l(r);case"z":return"UTC";default:return n}}function O(n,r){return c(n)?n.toArcadeDate():m(n,l(r))}const C=new t(["days","months","minutes","seconds","hours","years","milliseconds"],[["day","days"],["d","days"],["month","months"],["minute","minutes"],["m","minutes"],["second","seconds"],["s","seconds"],["hour","hours"],["h","hours"],["year","years"],["y","years"],["millisecond","milliseconds"],["ms","milliseconds"]]);function U(n){return"M"===n?"months":C.lookup(f(n))??"milliseconds"}function j(e,t){e.today=function(r,e){return t(r,e,(t,o,i)=>{u(i,0,0,r,e);const a=new Date;return a.setHours(0,0,0,0),n.dateJSAndZoneToArcadeDate(a,l(r))})},e.time=function(r,e){return t(r,e,(t,f,m)=>{switch(u(m,0,4,r,e),m.length){case 0:{const e=n.nowToArcadeDate(l(r));return new w(e.hour,e.minute,e.second,e.millisecond)}case 1:{if(a(m[0]))return m[0].clone();if(s(m[0]))return new w(m[0].hour,m[0].minute,m[0].second,m[0].millisecond);if(c(m[0]))return new w(0,0,0,0);if(A(m[0]))return w.fromString(m[0]);const n=i(m[0]);return!1===isNaN(n)?w.fromMilliseconds(n):null}case 2:return A(m[0])&&A(m[1])?w.fromString(m[0],m[1]):w.fromParts(i(m[0]),i(m[1]),0,0);case 3:return w.fromParts(i(m[0]),i(m[1]),i(m[2]),0);case 4:return w.fromParts(i(m[0]),i(m[1]),i(m[2]),i(m[3]))}throw new o(r,"InvalidParameter",e)})},e.dateonly=function(r,e){return t(r,e,(t,o,a)=>{if(u(a,0,3,r,e),3===a.length)return y.fromParts(i(a[0]),i(a[1])+1,i(a[2]));if(2===a.length){const n=f(a[1]);return""===n?null:"X"===n?y.fromSeconds(i(a[0])):"x"===n?y.fromMilliseconds(i(a[0])):y.fromString(f(a[0]),n)}if(1===a.length){if(A(a[0])){if(""===a[0].replaceAll(/^\s+|\s+$/g,""))return null;if(!0===/^[0-9][0-9][0-9][0-9]$/.test(a[0]))return y.fromString(a[0]+"-01-01")}if(c(a[0]))return a[0].clone();if(s(a[0]))return y.fromParts(a[0].year,a[0].monthJS+1,a[0].day);const n=i(a[0]);return!1===isNaN(n)?y.fromMilliseconds(n):A(a[0])?y.fromString(a[0]):null}if(0===a.length){const e=n.nowToArcadeDate(l(r));return!1===e.isValid?null:y.fromParts(e.year,e.monthJS+1,e.day)}return null})},e.changetimezone=function(e,i){return t(e,i,(t,a,s)=>{if(u(s,2,2,e,i),null===s[0])return null;if(c(s[0]))throw new o(e,"CannotChangeTimeZoneDateOnly",i);if(c(s[0]))throw new o(e,"CannotChangeTimeZoneTime",i);const d=m(s[0],l(e));if(null===d)throw new o(e,"InvalidParameter",i);const h=r(Z(f(s[1]),e),!1);if(null===h)return null;const N=n.arcadeDateAndZoneToArcadeDate(d,h);return!1===N.isValid?null:N})},e.timezone=function(r,e){return t(r,e,(t,o,i)=>{if(u(i,1,2,r,e),a(i[0]))return"Unknown";if(c(i[0]))return"Unknown";const s=m(i[0],l(r));if(null===s)return null;const f=s.timeZone;return"system"===f?n.systemTimeZoneCanonicalName:"utc"===f.toLowerCase()?"UTC":"unknown"===f.toLowerCase()?"Unknown":f})},e.timezoneoffset=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=m(o[0],l(n));return null===i?null:60*i.timeZoneOffset*1e3})},e.now=function(r,e){return t(r,e,(t,o,i)=>{u(i,0,0,r,e);const a=n.nowToArcadeDate(l(r));return!1===a.isValid?null:a})},e.timestamp=function(r,e){return t(r,e,(t,o,l)=>{u(l,0,0,r,e);const i=n.nowUTCToArcadeDate();return!1===i.isValid?null:i})},e.toutc=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=m(o[0],l(n));return null===i?null:i.toUTC()})},e.tolocal=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=m(o[0],l(n));return null===i?null:i.toLocal()})},e.day=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.day})},e.month=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.monthJS})},e.year=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.year})},e.hour=function(n,r){return t(n,r,(e,t,o)=>{if(u(o,1,1,n,r),a(o[0]))return o[0].hour;const i=m(o[0],l(n));return null===i?NaN:i.hour})},e.second=function(n,r){return t(n,r,(e,t,o)=>{if(u(o,1,1,n,r),a(o[0]))return o[0].second;const i=m(o[0],l(n));return null===i?NaN:i.second})},e.millisecond=function(n,r){return t(n,r,(e,t,o)=>{if(u(o,1,1,n,r),a(o[0]))return o[0].millisecond;const i=m(o[0],l(n));return null===i?NaN:i.millisecond})},e.minute=function(n,r){return t(n,r,(e,t,o)=>{if(u(o,1,1,n,r),a(o[0]))return o[0].minute;const i=m(o[0],l(n));return null===i?NaN:i.minute})},e.week=function(n,r){return t(n,r,(e,t,a)=>{u(a,1,2,n,r);const s=O(a[0],l(n));if(null===s)return NaN;const c=i(d(a[1],0));if(c<0||c>6)throw new o(n,"InvalidParameter",r);const f=s.day,m=s.monthJS,h=s.year,N=s.dayOfWeekJS,y=D(f,m,h)-1,w=Math.floor(y/7);return N-c+(N-c<0?7:0)<y-7*w?w+1:w})},e.weekday=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.dayOfWeekJS})},e.isoweekday=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.dayOfWeekISO})},e.isomonth=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.monthISO})},e.isoweek=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.weekISO})},e.isoyear=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.yearISO})},e.date=function(e,o){return t(e,o,(t,s,d)=>{if(u(d,0,8,e,o),3===d.length){if(c(d[0])&&a(d[1])&&A(d[2])){const t=r(Z(f(d[2])??"unknown",e),!1);return null===t?null:S(n.fromParts(d[0].year,d[0].month,d[0].day,d[1].hour,d[1].minute,d[1].second,d[1].millisecond,t))}return S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),0,0,0,0,l(e)))}if(4===d.length)return S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),i(d[3]),0,0,0,l(e)));if(5===d.length)return S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),i(d[3]),i(d[4]),0,0,l(e)));if(6===d.length)return S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),i(d[3]),i(d[4]),i(d[5]),0,l(e)));if(7===d.length)return S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),i(d[3]),i(d[4]),i(d[5]),i(d[6]),l(e)));if(8===d.length){const t=r(Z(f(d[7])??"unknown",e),!1);return null===t?null:S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),i(d[3]),i(d[4]),i(d[5]),i(d[6]),t))}if(2===d.length){if(c(d[0])&&A(d[1])){const t=r(Z(f(d[1])??"unknown",e),!1);return null===t?null:S(n.fromParts(d[0].year,d[0].month,d[0].day,0,0,0,0,t))}if(c(d[0])&&a(d[1]))return S(n.fromParts(d[0].year,d[0].month,d[0].day,d[1].hour,d[1].minute,d[1].second,d[1].millisecond,"unknown"));let t,o=f(d[1]);return""===o?null:(o=h(o,!0),t="X"===o?T.fromSeconds(i(d[0])):"x"===o?T.fromMillis(i(d[0])):T.fromFormat(f(d[0]),o,{locale:g(),numberingSystem:"latn"}),t.isValid?n.dateTimeToArcadeDate(t):null)}if(1===d.length){if(c(d[0]))return S(n.fromParts(d[0].year,d[0].month,d[0].day,0,0,0,0,"unknown"));if(A(d[0])){if(""===d[0].replaceAll(/^\s+|\s+$/g,""))return null;if(!0===/^[0-9][0-9][0-9][0-9]$/.test(d[0]))return m(d[0]+"-01-01",l(e))}const r=i(d[0]);if(!1===isNaN(r)){const t=T.fromMillis(r);return t.isValid?n.dateTimeAndZoneToArcadeDate(t,l(e)):null}return m(d[0],l(e))}return 0===d.length?n.nowToArcadeDate(l(e)):null})},e.datediff=function(r,e){return t(r,e,(t,o,i)=>{if(u(i,2,4,r,e),a(i[0]))return a(i[1])?i[0].difference(i[1],f(i[2])):NaN;if(a(i[1]))return NaN;if(c(i[0]))return c(i[1])?i[0].difference(i[1],f(i[2])):NaN;if(c(i[1]))return NaN;let s=m(i[0],l(r)),h=m(i[1],l(r));if(null===s||null===h)return NaN;let N=d(i[3],"");return""!==N&&null!==N?(N=Z(f(N),r),s=n.arcadeDateAndZoneToArcadeDate(s,N),h=n.arcadeDateAndZoneToArcadeDate(h,N)):s.timeZone!==h.timeZone&&(s.isUnknownTimeZone?s=n.arcadeDateAndZoneToArcadeDate(s,h.timeZone):h=(h.isUnknownTimeZone,n.arcadeDateAndZoneToArcadeDate(h,s.timeZone))),s.diff(h,U(i[2]))})},e.dateadd=function(n,r){return t(n,r,(e,t,o)=>{u(o,2,3,n,r);let s=i(o[1]);if(isNaN(s)||s===1/0||s===-1/0)return a(o[0])||c(o[0])?o[0].clone():m(o[0],l(n));const f=U(o[2]);if("days"!==f&&"months"!==f||(s=c(o[0])?s:N(s)),a(o[0]))return o[0].plus(f,s);if(c(o[0]))return o[0].plus(f,s);const d=m(o[0],l(n));return null===d?null:d.plus({[f]:s})})}}export{j as registerFunctions};
5
+ import{ArcadeDate as n,createDateTimeZone as r}from"../ArcadeDate.js";import{toStringEnumKey as e,StringEnum as t}from"../enum.js";import{ArcadeExecutionError as o}from"../executionError.js";import{B as u,K as l,s as i,g as a,e as s,f as c,u as f,O as m,J as d,P as h,Q as N}from"../../chunks/languageUtils.js";import{DateOnly as y}from"../../core/sql/DateOnly.js";import{TimeOnly as w}from"../../core/sql/TimeOnly.js";import{getLocale as g}from"../../intl/locale.js";import{DateTime as T}from"luxon";import{isString as A}from"../../support/guards.js";function D(n,r,e){return n+(k(e)?p:P)[r]}function k(n){return n%4==0&&(n%100!=0||n%400==0)}const P=[0,31,59,90,120,151,181,212,243,273,304,334],p=[0,31,60,91,121,152,182,213,244,274,305,335];function S(n){return null===n?n:!1===n.isValid?null:n}function Z(n,r){switch(e(n)){case"":case"default":return l(r);case"z":return"UTC";default:return n}}function O(n,r){return c(n)?n.toArcadeDate():m(n,l(r))}const C=new t(["days","months","minutes","seconds","hours","years","milliseconds"],[["day","days"],["d","days"],["month","months"],["minute","minutes"],["m","minutes"],["second","seconds"],["s","seconds"],["hour","hours"],["h","hours"],["year","years"],["y","years"],["millisecond","milliseconds"],["ms","milliseconds"]]);function U(n){return"M"===n?"months":C.lookup(f(n))??"milliseconds"}function j(e,t){e.today=function(r,e){return t(r,e,(t,o,i)=>{u(i,0,0,r,e);const a=new Date;return a.setHours(0,0,0,0),n.dateJSAndZoneToArcadeDate(a,l(r))})},e.time=function(r,e){return t(r,e,(t,f,m)=>{switch(u(m,0,4,r,e),m.length){case 0:{const e=n.nowToArcadeDate(l(r));return new w(e.hour,e.minute,e.second,e.millisecond)}case 1:{if(a(m[0]))return m[0].clone();if(s(m[0]))return new w(m[0].hour,m[0].minute,m[0].second,m[0].millisecond);if(c(m[0]))return new w(0,0,0,0);if(A(m[0]))return w.fromString(m[0]);const n=i(m[0]);return!1===isNaN(n)?w.fromMilliseconds(n):null}case 2:return A(m[0])&&A(m[1])?w.fromString(m[0],m[1]):w.fromParts(i(m[0]),i(m[1]),0,0);case 3:return w.fromParts(i(m[0]),i(m[1]),i(m[2]),0);case 4:return w.fromParts(i(m[0]),i(m[1]),i(m[2]),i(m[3]))}throw new o(r,"InvalidParameter",e)})},e.dateonly=function(r,e){return t(r,e,(t,o,a)=>{if(u(a,0,3,r,e),3===a.length)return y.fromParts(i(a[0]),i(a[1])+1,i(a[2]));if(2===a.length){const n=f(a[1]);return""===n?null:"X"===n?y.fromSeconds(i(a[0])):"x"===n?y.fromMilliseconds(i(a[0])):y.fromString(f(a[0]),n)}if(1===a.length){if(A(a[0])){if(""===a[0].replaceAll(/^\s+|\s+$/g,""))return null;if(!0===/^[0-9][0-9][0-9][0-9]$/.test(a[0]))return y.fromString(a[0]+"-01-01")}if(c(a[0]))return a[0].clone();if(s(a[0]))return y.fromParts(a[0].year,a[0].monthJS+1,a[0].day);const n=i(a[0]);return!1===isNaN(n)?y.fromMilliseconds(n):A(a[0])?y.fromString(a[0]):null}if(0===a.length){const e=n.nowToArcadeDate(l(r));return!1===e.isValid?null:y.fromParts(e.year,e.monthJS+1,e.day)}return null})},e.changetimezone=function(e,i){return t(e,i,(t,a,s)=>{if(u(s,2,2,e,i),null===s[0])return null;if(c(s[0]))throw new o(e,"CannotChangeTimeZoneDateOnly",i);if(c(s[0]))throw new o(e,"CannotChangeTimeZoneTime",i);const d=m(s[0],l(e));if(null===d)throw new o(e,"InvalidParameter",i);const h=r(Z(f(s[1]),e),!1);if(null===h)return null;const N=n.arcadeDateAndZoneToArcadeDate(d,h);return!1===N.isValid?null:N})},e.timezone=function(r,e){return t(r,e,(t,o,i)=>{if(u(i,1,2,r,e),a(i[0]))return"Unknown";if(c(i[0]))return"Unknown";const s=m(i[0],l(r));if(null===s)return null;const f=s.timeZone;return"system"===f?n.systemTimeZoneCanonicalName:"utc"===f.toLowerCase()?"UTC":"unknown"===f.toLowerCase()?"Unknown":f})},e.timezoneoffset=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=m(o[0],l(n));return null===i?null:60*i.timeZoneOffset*1e3})},e.now=function(r,e){return t(r,e,(t,o,i)=>{u(i,0,0,r,e);const a=n.nowToArcadeDate(l(r));return!1===a.isValid?null:a})},e.timestamp=function(r,e){return t(r,e,(t,o,l)=>{u(l,0,0,r,e);const i=n.nowUTCToArcadeDate();return!1===i.isValid?null:i})},e.toutc=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=m(o[0],l(n));return null===i?null:i.toUTC()})},e.tolocal=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=m(o[0],l(n));return null===i?null:i.toLocal()})},e.day=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.day})},e.month=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.monthJS})},e.year=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.year})},e.hour=function(n,r){return t(n,r,(e,t,o)=>{if(u(o,1,1,n,r),a(o[0]))return o[0].hour;const i=m(o[0],l(n));return null===i?NaN:i.hour})},e.second=function(n,r){return t(n,r,(e,t,o)=>{if(u(o,1,1,n,r),a(o[0]))return o[0].second;const i=m(o[0],l(n));return null===i?NaN:i.second})},e.millisecond=function(n,r){return t(n,r,(e,t,o)=>{if(u(o,1,1,n,r),a(o[0]))return o[0].millisecond;const i=m(o[0],l(n));return null===i?NaN:i.millisecond})},e.minute=function(n,r){return t(n,r,(e,t,o)=>{if(u(o,1,1,n,r),a(o[0]))return o[0].minute;const i=m(o[0],l(n));return null===i?NaN:i.minute})},e.week=function(n,r){return t(n,r,(e,t,a)=>{u(a,1,2,n,r);const s=O(a[0],l(n));if(null===s)return NaN;const c=i(d(a[1],0));if(c<0||c>6)throw new o(n,"InvalidParameter",r);const f=s.day,m=s.monthJS,h=s.year,N=s.dayOfWeekJS,y=D(f,m,h)-1,w=Math.floor(y/7);return N-c+(N-c<0?7:0)<y-7*w?w+1:w})},e.weekday=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.dayOfWeekJS})},e.isoweekday=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.dayOfWeekISO})},e.isomonth=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.monthISO})},e.isoweek=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.weekISO})},e.isoyear=function(n,r){return t(n,r,(e,t,o)=>{u(o,1,1,n,r);const i=O(o[0],l(n));return null===i?NaN:i.yearISO})},e.date=function(e,o){return t(e,o,(t,s,d)=>{if(u(d,0,8,e,o),3===d.length){if(c(d[0])&&a(d[1])&&A(d[2])){const t=r(Z(f(d[2])??"unknown",e),!1);return null===t?null:S(n.fromParts(d[0].year,d[0].month,d[0].day,d[1].hour,d[1].minute,d[1].second,d[1].millisecond,t))}return S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),0,0,0,0,l(e)))}if(4===d.length)return S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),i(d[3]),0,0,0,l(e)));if(5===d.length)return S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),i(d[3]),i(d[4]),0,0,l(e)));if(6===d.length)return S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),i(d[3]),i(d[4]),i(d[5]),0,l(e)));if(7===d.length)return S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),i(d[3]),i(d[4]),i(d[5]),i(d[6]),l(e)));if(8===d.length){const t=r(Z(f(d[7])??"unknown",e),!1);return null===t?null:S(n.fromParts(i(d[0]),i(d[1])+1,i(d[2]),i(d[3]),i(d[4]),i(d[5]),i(d[6]),t))}if(2===d.length){if(c(d[0])&&A(d[1])){const t=r(Z(f(d[1])??"unknown",e),!1);return null===t?null:S(n.fromParts(d[0].year,d[0].month,d[0].day,0,0,0,0,t))}if(c(d[0])&&a(d[1]))return S(n.fromParts(d[0].year,d[0].month,d[0].day,d[1].hour,d[1].minute,d[1].second,d[1].millisecond,"unknown"));let t,o=f(d[1]);return""===o?null:(o=h(o,!0),t="X"===o?T.fromSeconds(i(d[0])):"x"===o?T.fromMillis(i(d[0])):T.fromFormat(f(d[0]),o,{locale:g(),numberingSystem:"latn"}),t.isValid?n.dateTimeToArcadeDate(t):null)}if(1===d.length){if(c(d[0]))return S(n.fromParts(d[0].year,d[0].month,d[0].day,0,0,0,0,"unknown"));if(A(d[0])){if(""===d[0].replaceAll(/^\s+|\s+$/g,""))return null;if(!0===/^[0-9][0-9][0-9][0-9]$/.test(d[0]))return m(d[0]+"-01-01",l(e))}const r=i(d[0]);if(!1===isNaN(r)){const t=T.fromMillis(r);return t.isValid?n.dateTimeAndZoneToArcadeDate(t,l(e)):null}return m(d[0],l(e))}return 0===d.length?n.nowToArcadeDate(l(e)):null})},e.datediff=function(r,e){return t(r,e,(t,o,i)=>{if(u(i,2,4,r,e),a(i[0]))return a(i[1])?i[0].difference(i[1],f(i[2])):NaN;if(a(i[1]))return NaN;if(c(i[0]))return c(i[1])?i[0].difference(i[1],f(i[2])):NaN;if(c(i[1]))return NaN;let s=m(i[0],l(r)),h=m(i[1],l(r));if(null===s||null===h)return NaN;let N=d(i[3],"");return""!==N&&null!==N?(N=Z(f(N),r),s=n.arcadeDateAndZoneToArcadeDate(s,N),h=n.arcadeDateAndZoneToArcadeDate(h,N)):s.timeZone!==h.timeZone&&(s.isUnknownTimeZone?s=n.arcadeDateAndZoneToArcadeDate(s,h.timeZone):h=(h.isUnknownTimeZone,n.arcadeDateAndZoneToArcadeDate(h,s.timeZone))),s.diff(h,U(i[2]))})},e.dateadd=function(n,r){return t(n,r,(e,t,o)=>{u(o,2,3,n,r);let s=i(o[1]);if(isNaN(s)||s===1/0||s===-1/0)return a(o[0])||c(o[0])?o[0].clone():m(o[0],l(n));const f=U(o[2]);if("days"!==f&&"months"!==f||(s=c(o[0])?s:N(s)),a(o[0]))return o[0].plus(f,s);if(c(o[0]))return o[0].plus(f,s);const d=m(o[0],l(n));return null===d?null:d.plus({[f]:s})})}}export{j 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as e}from"../ArcadeDate.js";import{toSymbolId as r}from"../arcadeEnvironment.js";import t from"../Dictionary.js";import{ArcadeExecutionError as n}from"../executionError.js";import{Feature as o}from"../Feature.js";import{B as i,k as a,Q as u,u as s,K as d,S as m,T as c,v as f,U as l,V as p,e as y}from"../../chunks/languageUtils.js";import{layerFieldEsriConstants as v}from"../featureset/support/shared.js";import{SqlTimeStampOffset as w}from"../../core/sql/SqlTimestampOffset.js";import h from"../../core/sql/WhereClause.js";import{internalTimeReceivedField as b}from"../../layers/support/streamLayerUtils.js";import{isString as T,isNumber as j}from"../../support/guards.js";function I(e){const r=e?.fullSchema();return r?.datesInUnknownTimezone?"unknown":r?.dateFieldsTimeZone||"UTC"}function F(e){const r=e.fullSchema()?.fieldsIndex;return null==r&&e instanceof o?e.fieldsIndex:r}const g={getAttributeSQL(e,r){const t=e.field(r);if(null==t)return t;if(y(t)){const n=t.toDateTime(),o=F(e)?.get(r)?.type;return"esriFieldTypeTimestampOffset"===o||"timestamp-offset"===o?w.fromDateTime(n):n}return t}};function P(o,w,P){o.domain=function(e,r){return w(e,r,(o,m,c)=>{if(i(c,2,3,e,r),a(c[0])){const r=u(c[0],s(c[1]),void 0===c[2]?void 0:c[2]);return r&&r.domain?"coded-value"===r.domain.type||"codedValue"===r.domain.type?t.convertObjectToArcadeDictionary({type:"codedValue",name:r.domain.name,dataType:v[r.field.type],codedValues:r.domain.codedValues.map(e=>({name:e.name,code:e.code}))},d(e)):t.convertObjectToArcadeDictionary({type:"range",name:r.domain.name,dataType:v[r.field.type],min:r.domain.minValue,max:r.domain.maxValue},d(e)):null}throw new n(e,"InvalidParameter",r)})},o.domaincode=function(e,r){return w(e,r,(t,o,u)=>{if(i(u,2,4,e,r),a(u[0]))return m(u[0],s(u[1]),u[2],void 0===u[3]?void 0:u[3]);throw new n(e,"InvalidParameter",r)})},o.domainname=function(e,r){return w(e,r,(t,o,u)=>{if(i(u,2,4,e,r),a(u[0]))return c(u[0],s(u[1]),u[2],void 0===u[3]?void 0:u[3]);throw new n(e,"InvalidParameter",r)})},o.expects=function(e,r){return w(e,r,(t,o,i)=>{if(i.length<1)throw new n(e,"WrongNumberOfParameters",r);return f})},o.featureinfilter=function(e,r){return w(e,r,(e,r,t)=>{i(t,2,2,e,r);const[o,u]=t;if(null==o)return!1;if(""===u||null==u)return!0;if(!a(o)||!T(u))throw new n(e,"InvalidParameter",r);const s=h.create(u,{fieldsIndex:F(o),timeZone:I(o)}),d=s.getVariables();for(const n of d)s.parameters[n]=P(e,{name:n});return s.testFeature(o,g)})},o.gdbversion=function(e,r){return w(e,r,(t,o,u)=>{if(i(u,1,1,e,r),a(u[0]))return u[0].gdbVersion();throw new n(e,"InvalidParameter",r)})},o.schema=function(e,r){return w(e,r,(o,i,u)=>{if(a(u[0])){const r=l(u[0]);return r?t.convertObjectToArcadeDictionary(r,d(e)):null}throw new n(e,"InvalidParameter",r)})},o.subtypecode=function(e,r){return w(e,r,(t,o,u)=>{if(i(u,1,1,e,r),a(u[0])){const e=p(u[0]);if(!e)return null;if(e.subtypeField&&u[0].hasField(e.subtypeField)){const r=u[0].field(e.subtypeField);for(const t of e.subtypes)if(t.code===r)return t.code;return null}return null}throw new n(e,"InvalidParameter",r)})},o.subtypename=function(e,r){return w(e,r,(t,o,u)=>{if(i(u,1,1,e,r),a(u[0])){const e=p(u[0]);if(!e)return"";if(e.subtypeField&&u[0].hasField(e.subtypeField)){const r=u[0].field(e.subtypeField);for(const t of e.subtypes)if(t.code===r)return t.name;return""}return""}throw new n(e,"InvalidParameter",r)})},o.subtypes=function(e,r){return w(e,r,(o,u,s)=>{if(i(s,1,1,e,r),a(s[0])){const r=p(s[0]);return r?t.convertObjectToArcadeDictionary(r,d(e)):null}throw new n(e,"InvalidParameter",r)})},o[r("TimeReceived")]=function(r,t){return w(r,t,(r,t,o)=>{if(i(o,1,1,r,t),a(o[0])){if(o[0].hasField(b)){const t=o[0].field(b);return j(t)?e.epochToArcadeDate(t,r.timeZone??"system"):y(t)?t:null}return null}throw new n(r,"InvalidParameter",t)})}}export{P as registerFunctions};
5
+ import{ArcadeDate as e}from"../ArcadeDate.js";import{toSymbolId as r}from"../arcadeEnvironment.js";import t from"../Dictionary.js";import{ArcadeExecutionError as n}from"../executionError.js";import{Feature as o}from"../Feature.js";import{B as i,k as a,S as u,u as s,K as d,T as m,U as c,v as f,V as l,W as p,e as y}from"../../chunks/languageUtils.js";import{layerFieldEsriConstants as v}from"../featureset/support/shared.js";import{SqlTimeStampOffset as w}from"../../core/sql/SqlTimestampOffset.js";import h from"../../core/sql/WhereClause.js";import{internalTimeReceivedField as b}from"../../layers/support/streamLayerUtils.js";import{isString as T,isNumber as j}from"../../support/guards.js";function I(e){const r=e?.fullSchema();return r?.datesInUnknownTimezone?"unknown":r?.dateFieldsTimeZone||"UTC"}function F(e){const r=e.fullSchema()?.fieldsIndex;return null==r&&e instanceof o?e.fieldsIndex:r}const g={getAttributeSQL(e,r){const t=e.field(r);if(null==t)return t;if(y(t)){const n=t.toDateTime(),o=F(e)?.get(r)?.type;return"esriFieldTypeTimestampOffset"===o||"timestamp-offset"===o?w.fromDateTime(n):n}return t}};function P(o,w,P){o.domain=function(e,r){return w(e,r,(o,m,c)=>{if(i(c,2,3,e,r),a(c[0])){const r=u(c[0],s(c[1]),void 0===c[2]?void 0:c[2]);return r&&r.domain?"coded-value"===r.domain.type||"codedValue"===r.domain.type?t.convertObjectToArcadeDictionary({type:"codedValue",name:r.domain.name,dataType:v[r.field.type],codedValues:r.domain.codedValues.map(e=>({name:e.name,code:e.code}))},d(e)):t.convertObjectToArcadeDictionary({type:"range",name:r.domain.name,dataType:v[r.field.type],min:r.domain.minValue,max:r.domain.maxValue},d(e)):null}throw new n(e,"InvalidParameter",r)})},o.domaincode=function(e,r){return w(e,r,(t,o,u)=>{if(i(u,2,4,e,r),a(u[0]))return m(u[0],s(u[1]),u[2],void 0===u[3]?void 0:u[3]);throw new n(e,"InvalidParameter",r)})},o.domainname=function(e,r){return w(e,r,(t,o,u)=>{if(i(u,2,4,e,r),a(u[0]))return c(u[0],s(u[1]),u[2],void 0===u[3]?void 0:u[3]);throw new n(e,"InvalidParameter",r)})},o.expects=function(e,r){return w(e,r,(t,o,i)=>{if(i.length<1)throw new n(e,"WrongNumberOfParameters",r);return f})},o.featureinfilter=function(e,r){return w(e,r,(e,r,t)=>{i(t,2,2,e,r);const[o,u]=t;if(null==o)return!1;if(""===u||null==u)return!0;if(!a(o)||!T(u))throw new n(e,"InvalidParameter",r);const s=h.create(u,{fieldsIndex:F(o),timeZone:I(o)}),d=s.getVariables();for(const n of d)s.parameters[n]=P(e,{name:n});return s.testFeature(o,g)})},o.gdbversion=function(e,r){return w(e,r,(t,o,u)=>{if(i(u,1,1,e,r),a(u[0]))return u[0].gdbVersion();throw new n(e,"InvalidParameter",r)})},o.schema=function(e,r){return w(e,r,(o,i,u)=>{if(a(u[0])){const r=l(u[0]);return r?t.convertObjectToArcadeDictionary(r,d(e)):null}throw new n(e,"InvalidParameter",r)})},o.subtypecode=function(e,r){return w(e,r,(t,o,u)=>{if(i(u,1,1,e,r),a(u[0])){const e=p(u[0]);if(!e)return null;if(e.subtypeField&&u[0].hasField(e.subtypeField)){const r=u[0].field(e.subtypeField);for(const t of e.subtypes)if(t.code===r)return t.code;return null}return null}throw new n(e,"InvalidParameter",r)})},o.subtypename=function(e,r){return w(e,r,(t,o,u)=>{if(i(u,1,1,e,r),a(u[0])){const e=p(u[0]);if(!e)return"";if(e.subtypeField&&u[0].hasField(e.subtypeField)){const r=u[0].field(e.subtypeField);for(const t of e.subtypes)if(t.code===r)return t.name;return""}return""}throw new n(e,"InvalidParameter",r)})},o.subtypes=function(e,r){return w(e,r,(o,u,s)=>{if(i(s,1,1,e,r),a(s[0])){const r=p(s[0]);return r?t.convertObjectToArcadeDictionary(r,d(e)):null}throw new n(e,"InvalidParameter",r)})},o[r("TimeReceived")]=function(r,t){return w(r,t,(r,t,o)=>{if(i(o,1,1,r,t),a(o[0])){if(o[0].hasField(b)){const t=o[0].field(b);return j(t)?e.epochToArcadeDate(t,r.timeZone??"system"):y(t)?t:null}return null}throw new n(r,"InvalidParameter",t)})}}export{P as registerFunctions};