@arcgis/core 5.2.0-next.95 → 5.2.0-next.97

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 (542) hide show
  1. package/WebScene.d.ts +6 -3
  2. package/WebScene.js +1 -1
  3. package/applications/WebEditor/geometryUtils.d.ts +1 -1
  4. package/arcade/arcadeAsyncRuntime.js +1 -1
  5. package/arcade/arcadeCompiler.js +1 -1
  6. package/arcade/arcadeRuntime.js +1 -1
  7. package/arcade/containerUtils.js +1 -1
  8. package/arcade/functions/track.js +1 -1
  9. package/arcgisGlobal.d.ts +2 -0
  10. package/assets/components/assets/icon/aiAgent16.json +1 -0
  11. package/assets/components/assets/icon/aiAgent24.json +1 -0
  12. package/assets/components/assets/icon/aiAgent32.json +1 -0
  13. package/assets/components/assets/icon/aiAgents16.json +1 -0
  14. package/assets/components/assets/icon/aiAgents24.json +1 -0
  15. package/assets/components/assets/icon/aiAgents32.json +1 -0
  16. package/assets/components/assets/icon/explodeGeometry16.json +1 -0
  17. package/assets/components/assets/icon/explodeGeometry24.json +1 -0
  18. package/assets/components/assets/icon/explodeGeometry32.json +1 -0
  19. package/assets/components/assets/icon/integration16.json +1 -0
  20. package/assets/components/assets/icon/integration24.json +1 -0
  21. package/assets/components/assets/icon/integration32.json +1 -0
  22. package/assets/components/assets/icon/spatiotemporalCatalog16.json +1 -0
  23. package/assets/components/assets/icon/spatiotemporalCatalog24.json +1 -0
  24. package/assets/components/assets/icon/spatiotemporalCatalog32.json +1 -0
  25. package/assets/components/assets/input-time-zone/t9n/messages.de.json +1 -1
  26. package/assets/esri/core/workers/RemoteClient.js +1 -1
  27. package/assets/esri/core/workers/chunks/000f91a18c22377f8525.js +1 -0
  28. package/assets/esri/core/workers/chunks/{05662a663f761dd3dea5.js → 006146ad6d4a5cbf1a1f.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{bd1a7e95a797e1ed4a7b.js → 013c17e07756fa465845.js} +1 -1
  30. package/assets/esri/core/workers/chunks/014eaccf2c2d357981f0.js +1 -0
  31. package/assets/esri/core/workers/chunks/{f253875feb11883deb84.js → 04d4cd66485b622403d0.js} +1 -1
  32. package/assets/esri/core/workers/chunks/05eb064f9b543890ae24.js +1 -0
  33. package/assets/esri/core/workers/chunks/{26737d061c7cfbbab95c.js → 0809a55a2f9be07cc5a9.js} +1 -1
  34. package/assets/esri/core/workers/chunks/0930738f43ce09b2ed2d.js +1 -0
  35. package/assets/esri/core/workers/chunks/{691434d4c6a38e63d819.js → 0a242e76bc293b0ad04b.js} +1 -1
  36. package/assets/esri/core/workers/chunks/0a4092578dc7578bcf76.js +1 -0
  37. package/assets/esri/core/workers/chunks/0e11bee9b56a7f51b012.js +1 -0
  38. package/assets/esri/core/workers/chunks/0e65869a5dd5a3917da7.js +1 -0
  39. package/assets/esri/core/workers/chunks/0ffb5a1275d07dcd9115.js +1 -0
  40. package/assets/esri/core/workers/chunks/{e370a3337b3c90240e73.js → 105da965fc90604eb6bf.js} +1 -1
  41. package/assets/esri/core/workers/chunks/1082bb0858585bd4fa21.js +2 -0
  42. package/assets/esri/core/workers/chunks/{5235b9c21ac4156c2375.js → 10f4c5533f50c3693318.js} +1 -1
  43. package/assets/esri/core/workers/chunks/1201bb22a2bfd7d7ecba.js +1 -0
  44. package/assets/esri/core/workers/chunks/16f55c5d642a23c2547e.js +1 -0
  45. package/assets/esri/core/workers/chunks/{09e01fd1c199be0c8e03.js → 16ffbe484f6cd4736f79.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{1bf967c68d0c795d3fb4.js → 19a4907fc93ae8b817e9.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{f74c7cbe4bd12f73ae90.js → 19d7339f20f3008c4893.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{a8aa8cb60b30f0983e7e.js → 1a9f17781e0a3bc5106f.js} +1 -1
  49. package/assets/esri/core/workers/chunks/{bf7875fda48b15271a10.js → 1bef7097fe5e402539ea.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{fa377112ef3b78f6ed18.js → 1de1cc0ed0f169a58aff.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{0549e2badf511e27aa54.js → 1e3b07cf0e608431a277.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{2e51764c8aa31096cb2a.js → 20feca2fdd304b3e9664.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{4c73c2f4331351e2a50c.js → 22ff018342860249b3eb.js} +1 -1
  54. package/assets/esri/core/workers/chunks/248df6fda489a9de5852.js +1 -0
  55. package/assets/esri/core/workers/chunks/279b16727d4b515eca44.js +1 -0
  56. package/assets/esri/core/workers/chunks/2b10d6597af3eeec5396.js +1 -0
  57. package/assets/esri/core/workers/chunks/2bd4b536e329112591c4.js +1 -0
  58. package/assets/esri/core/workers/chunks/2c01477b69c38f691e19.js +1 -0
  59. package/assets/esri/core/workers/chunks/2e2349387a2b9903f13c.js +2 -0
  60. package/assets/esri/core/workers/chunks/{4d700cb028f6306b163e.js → 32aa1529e84b839d051d.js} +1 -1
  61. package/assets/esri/core/workers/chunks/33041e50ea02d99480b0.js +1 -0
  62. package/assets/esri/core/workers/chunks/{5d7a5aa608ed6192b016.js → 349982635e921e838030.js} +1 -1
  63. package/assets/esri/core/workers/chunks/35d0a7597473d46866de.js +1 -0
  64. package/assets/esri/core/workers/chunks/374d726fdd0a9848cea5.js +1 -0
  65. package/assets/esri/core/workers/chunks/379f5ca5372d834af497.js +1 -0
  66. package/assets/esri/core/workers/chunks/37ae52c71bf9c70fbb92.js +1 -0
  67. package/assets/esri/core/workers/chunks/{05393b23ab24126d4236.js → 38bc5d09ae07f486d457.js} +1 -1
  68. package/assets/esri/core/workers/chunks/3bafa01ca01a67d09432.js +1 -0
  69. package/assets/esri/core/workers/chunks/3c7901ea007c9615ba54.js +1 -0
  70. package/assets/esri/core/workers/chunks/4047208f9559e06d7102.js +1 -0
  71. package/assets/esri/core/workers/chunks/4049e9b86c8e27a7ff12.js +1 -0
  72. package/assets/esri/core/workers/chunks/411bbdecba340df11d95.js +2 -0
  73. package/assets/esri/core/workers/chunks/42b5533f94ebcdc4befe.js +1 -0
  74. package/assets/esri/core/workers/chunks/44ca13c874b5aa0ed5a0.js +1 -0
  75. package/assets/esri/core/workers/chunks/4717831effb1ac6d5f5d.js +1 -0
  76. package/assets/esri/core/workers/chunks/{5edf77618ca51819d7c4.js → 476535cfb06ced74d611.js} +2 -2
  77. package/assets/esri/core/workers/chunks/486f1277fe834c0fc4c1.js +1 -0
  78. package/assets/esri/core/workers/chunks/48ade66f1685a1aaffba.js +1 -0
  79. package/assets/esri/core/workers/chunks/4d13c1a04788e5222678.js +1 -0
  80. package/assets/esri/core/workers/chunks/{cc3186dcbbf5edff8b9e.js → 4d7f6c92041d52cc8732.js} +1 -1
  81. package/assets/esri/core/workers/chunks/{595edbc1e9bba47d5676.js → 4f89da01b67b66a92c01.js} +1 -1
  82. package/assets/esri/core/workers/chunks/507bbcde2b39321b50a4.js +1 -0
  83. package/assets/esri/core/workers/chunks/{9b8e33985310f281f084.js → 56a5b65961e722f5cae9.js} +1 -1
  84. package/assets/esri/core/workers/chunks/5830deda121e4c95d199.js +1 -0
  85. package/assets/esri/core/workers/chunks/{b102ae764c14d8b32ace.js → 58a52adc42fbe5cd12c6.js} +1 -1
  86. package/assets/esri/core/workers/chunks/{b0e25ccb5a1e57a82628.js → 58b93f13316196d2e97d.js} +1 -1
  87. package/assets/esri/core/workers/chunks/58f98bd89b644cfdafae.js +1 -0
  88. package/assets/esri/core/workers/chunks/5a8658e4ef5163e8ab3b.js +1 -0
  89. package/assets/esri/core/workers/chunks/5bb8d9d887dd4211afd2.js +1 -0
  90. package/assets/esri/core/workers/chunks/5d7625eb9997cd0dff09.js +1 -0
  91. package/assets/esri/core/workers/chunks/5e56a004b4407b8066eb.js +1 -0
  92. package/assets/esri/core/workers/chunks/5efc66be4576c6f67064.js +1 -0
  93. package/assets/esri/core/workers/chunks/60b1af54e7fc20fd9588.js +1 -0
  94. package/assets/esri/core/workers/chunks/6134a2c6983792787184.js +1 -0
  95. package/assets/esri/core/workers/chunks/6319413b89e23f671487.js +1 -0
  96. package/assets/esri/core/workers/chunks/{1b311ff39dede07865df.js → 633454b27c34f9ec7940.js} +1 -1
  97. package/assets/esri/core/workers/chunks/63c43ebf46964c283b4d.js +1 -0
  98. package/assets/esri/core/workers/chunks/65d3638ded62c5606ae3.js +1 -0
  99. package/assets/esri/core/workers/chunks/{aa0ef4493a7e9bed159f.js → 662f4b39ec44c68e0733.js} +1 -1
  100. package/assets/esri/core/workers/chunks/680bef5e8237cc3bdd84.js +1 -0
  101. package/assets/esri/core/workers/chunks/6835f959952f70972fce.js +1 -0
  102. package/assets/esri/core/workers/chunks/{ddf284648a73b6993737.js → 68d823697c298122ee08.js} +1 -1
  103. package/assets/esri/core/workers/chunks/6aaefd61505027267c9b.js +1 -0
  104. package/assets/esri/core/workers/chunks/6ceb17eada151230abf7.js +1 -0
  105. package/assets/esri/core/workers/chunks/6df29716f75696434807.js +1 -0
  106. package/assets/esri/core/workers/chunks/6e804bd6bb4b0ee44fa9.js +1 -0
  107. package/assets/esri/core/workers/chunks/{ee77999df3785468b2b6.js → 6f6e8b7e6e2c856e4ed1.js} +1 -1
  108. package/assets/esri/core/workers/chunks/{8ea28a4b1afe8bb2d313.js → 7091bbdc36f1f03f14b3.js} +1 -1
  109. package/assets/esri/core/workers/chunks/7608de0d942b4c16b2f6.js +1 -0
  110. package/assets/esri/core/workers/chunks/{4b6f433022a6822706cb.js → 762817d30474c15142b4.js} +1 -1
  111. package/assets/esri/core/workers/chunks/762e9a15b2638475a2b4.js +1 -0
  112. package/assets/esri/core/workers/chunks/79088d5c9c2e6a780929.js +1 -0
  113. package/assets/esri/core/workers/chunks/{f3d57c5b9dffd12e45b4.js → 7c3a89c12ea32a071ad4.js} +1 -1
  114. package/assets/esri/core/workers/chunks/7c67596c0792282afdfc.js +1 -0
  115. package/assets/esri/core/workers/chunks/7cef6e5f39137e74bbc3.js +1 -0
  116. package/assets/esri/core/workers/chunks/{87e0ceb1a64ab08e679a.js → 7fd54fa2f91cdab44ab3.js} +1 -1
  117. package/assets/esri/core/workers/chunks/822a5020afbca21df7f7.js +1 -0
  118. package/assets/esri/core/workers/chunks/8599d2f2eb0fbb4a8bf5.js +1 -0
  119. package/assets/esri/core/workers/chunks/862f7090ba4a56c07093.js +1 -0
  120. package/assets/esri/core/workers/chunks/{97c7dfd29ad4c2966cb4.js → 88252899a5291ad29710.js} +1 -1
  121. package/assets/esri/core/workers/chunks/8837fbcc0d484659b79c.js +1 -0
  122. package/assets/esri/core/workers/chunks/8dcc7749de3391710864.js +1 -0
  123. package/assets/esri/core/workers/chunks/900dad076347443b3ad9.js +1 -0
  124. package/assets/esri/core/workers/chunks/{f8f7b86bbd62106bc3d4.js → 925f83be3c1eb4b5c6af.js} +1 -1
  125. package/assets/esri/core/workers/chunks/{a4a22149077c7780481c.js → 9378ce457b02717304e6.js} +1 -1
  126. package/assets/esri/core/workers/chunks/93a7cf23f73b23fc7802.js +1 -0
  127. package/assets/esri/core/workers/chunks/93c1d1e7c0935242071e.js +1 -0
  128. package/assets/esri/core/workers/chunks/{fddcb8be714ad18ad0c8.js → 970b33947bf61fccd461.js} +1 -1
  129. package/assets/esri/core/workers/chunks/97aaff86e06380a68df8.js +1 -0
  130. package/assets/esri/core/workers/chunks/9bc7df2b8ae0ed443d13.js +1 -0
  131. package/assets/esri/core/workers/chunks/9cc14a41d4a90f6d626e.js +1 -0
  132. package/assets/esri/core/workers/chunks/9e514a58b1165e273202.js +1 -0
  133. package/assets/esri/core/workers/chunks/9fe1db0762ab3326eab4.js +1 -0
  134. package/assets/esri/core/workers/chunks/{a5bb19d2b7d7db22222b.js → a10188c4d1904965898a.js} +1 -1
  135. package/assets/esri/core/workers/chunks/a2288d44cba34d947613.js +1 -0
  136. package/assets/esri/core/workers/chunks/a26916de4c105859621e.js +1 -0
  137. package/assets/esri/core/workers/chunks/a322afbb48898ce35851.js +1 -0
  138. package/assets/esri/core/workers/chunks/a34cadd486e7fcc79063.js +1 -0
  139. package/assets/esri/core/workers/chunks/{cefb70d633c220cbedf9.js → a4dc1a80ed6604d71722.js} +1 -1
  140. package/assets/esri/core/workers/chunks/{6baae3e856d904fef9b1.js → a8f70cece5ce2b095cdd.js} +1 -1
  141. package/assets/esri/core/workers/chunks/ab332bd411d6c7d4190c.js +1 -0
  142. package/assets/esri/core/workers/chunks/{777f2fdf1f4b9f243893.js → ab3a6ce7bc2a27b92469.js} +1 -1
  143. package/assets/esri/core/workers/chunks/abd2f8fae6b918fbdd6d.js +1 -0
  144. package/assets/esri/core/workers/chunks/ad695de9f73b268af139.js +1 -0
  145. package/assets/esri/core/workers/chunks/{b13d2da33ec07e9d41ff.js → b0da2b089a89d643df1e.js} +1 -1
  146. package/assets/esri/core/workers/chunks/{65f4ca7201e7267bfc81.js → b5fcf4165ac72654742d.js} +1 -1
  147. package/assets/esri/core/workers/chunks/b82b523b6837ed1f28d3.js +2 -0
  148. package/assets/esri/core/workers/chunks/{527b87fddf33bb5d519e.js → ba77a8892cb23c7a297d.js} +1 -1
  149. package/assets/esri/core/workers/chunks/bb8089929ded0613d8e7.js +1 -0
  150. package/assets/esri/core/workers/chunks/bc7ca87d3bfe8a4aec81.js +1 -0
  151. package/assets/esri/core/workers/chunks/bc9b96a539f28afcb8cb.js +1 -0
  152. package/assets/esri/core/workers/chunks/{2d07d5a9ec67c39ef10c.js → bd4f29d2681e5596591a.js} +1 -1
  153. package/assets/esri/core/workers/chunks/bf9eba555aebca2c132b.js +1 -0
  154. package/assets/esri/core/workers/chunks/{903c7bd079888f65fef1.js → c3fbd81bb5820e48038f.js} +1 -1
  155. package/assets/esri/core/workers/chunks/c9df18e9ff7367a004b6.js +1 -0
  156. package/assets/esri/core/workers/chunks/ca8061e0a6d78d646ebf.js +1 -0
  157. package/assets/esri/core/workers/chunks/cc73ac8404615dc392d2.js +1 -0
  158. package/assets/esri/core/workers/chunks/{e823c9ccb7bc348d8824.js → ccb26860518dce6d01c0.js} +1 -1
  159. package/assets/esri/core/workers/chunks/cded34b161fcc790e672.js +1 -0
  160. package/assets/esri/core/workers/chunks/{1bf5c0a4bc5a960a3fa2.js → d1d4979e9dcabe5e4619.js} +1 -1
  161. package/assets/esri/core/workers/chunks/d2865c604849ce79183f.js +1 -0
  162. package/assets/esri/core/workers/chunks/{9b81bd62a2c72f592db1.js → d826f6d32b4c5885276a.js} +1 -1
  163. package/assets/esri/core/workers/chunks/d92540d3ffc4af980dd8.js +1 -0
  164. package/assets/esri/core/workers/chunks/dc7853795439ae77ace9.js +1 -0
  165. package/assets/esri/core/workers/chunks/{1f047dd747e7c1916dc7.js → dd55737fba0a8fe68101.js} +3 -3
  166. package/assets/esri/core/workers/chunks/dd8d19eb6b8e955c8067.js +1 -0
  167. package/assets/esri/core/workers/chunks/dda269a088275c823b40.js +1 -0
  168. package/assets/esri/core/workers/chunks/{7b70d6fdfa7a19ffffb0.js → de95dee8db92cf8f796f.js} +1 -1
  169. package/assets/esri/core/workers/chunks/e1c8767143f9f9d1f049.js +1 -0
  170. package/assets/esri/core/workers/chunks/{2cf2f2842c19be84ab4d.js → e6cb31c727f799c1297c.js} +1 -1
  171. package/assets/esri/core/workers/chunks/e934ef66d130c212c05b.js +1 -0
  172. package/assets/esri/core/workers/chunks/{7c56446184abcd14678b.js → ea77654c8964cc39b9a6.js} +1 -1
  173. package/assets/esri/core/workers/chunks/eb167f9f6132a6348d2e.js +1 -0
  174. package/assets/esri/core/workers/chunks/ed5ac1efd3cba49be756.js +1 -0
  175. package/assets/esri/core/workers/chunks/ef24fd6c0322e5de9fdf.js +2 -0
  176. package/assets/esri/core/workers/chunks/f219ba010c480bb75684.js +1 -0
  177. package/assets/esri/core/workers/chunks/fbf2d90240d36f8b423f.js +1 -0
  178. package/assets/esri/core/workers/chunks/{4ee99e654dad6f09abee.js → fc042b9936686785c39e.js} +1 -1
  179. package/assets/esri/core/workers/chunks/fc1658eae7b312502fab.js +1 -0
  180. package/assets/esri/core/workers/chunks/{af6b9fd77b1792fbb66e.js → fd4d124c5bf810d9e352.js} +1 -1
  181. package/assets/esri/core/workers/chunks/ffa35ecc681ec1c4739a.js +1 -0
  182. package/assets/esri/core/workers/chunks/ffca0b2333e760b66d3a.js +1 -0
  183. package/config.js +1 -1
  184. package/editing/sharedTemplates/executor/builders/bufferLineToPolygon.js +1 -1
  185. package/editing/sharedTemplates/executor/builders/bufferPointToPolygon.js +1 -1
  186. package/editing/sharedTemplates/executor/builders/bufferPolygonToPolygon.js +1 -1
  187. package/editing/sharedTemplates/executor/builders/pointAtIntersectionVerticesOfLine.js +1 -1
  188. package/editing/sharedTemplates/executor/builders/support/offsetUtils.js +1 -1
  189. package/editing/sharedTemplates/executor/support/createPresetServiceEdit.js +1 -1
  190. package/geometry/Polygon.js +1 -1
  191. package/geometry/geometryEngine.d.ts +36 -36
  192. package/geometry/operators/affineTransformOperator.d.ts +30 -1
  193. package/geometry/operators/affineTransformOperator.js +1 -1
  194. package/geometry/operators/alphaShapeOperator.d.ts +49 -5
  195. package/geometry/operators/alphaShapeOperator.js +1 -1
  196. package/geometry/operators/areaOperator.d.ts +28 -4
  197. package/geometry/operators/areaOperator.js +1 -1
  198. package/geometry/operators/autoCompleteOperator.d.ts +25 -2
  199. package/geometry/operators/autoCompleteOperator.js +1 -1
  200. package/geometry/operators/boundaryOperator.d.ts +40 -2
  201. package/geometry/operators/boundaryOperator.js +1 -1
  202. package/geometry/operators/bufferOperator.d.ts +51 -6
  203. package/geometry/operators/bufferOperator.js +1 -1
  204. package/geometry/operators/centroidOperator.d.ts +23 -2
  205. package/geometry/operators/centroidOperator.js +1 -1
  206. package/geometry/operators/clipOperator.d.ts +34 -2
  207. package/geometry/operators/clipOperator.js +1 -1
  208. package/geometry/operators/containsOperator.d.ts +32 -2
  209. package/geometry/operators/containsOperator.js +1 -1
  210. package/geometry/operators/convexHullOperator.d.ts +47 -4
  211. package/geometry/operators/convexHullOperator.js +1 -1
  212. package/geometry/operators/crossesOperator.d.ts +35 -2
  213. package/geometry/operators/crossesOperator.js +1 -1
  214. package/geometry/operators/cutOperator.d.ts +23 -2
  215. package/geometry/operators/cutOperator.js +1 -1
  216. package/geometry/operators/densifyOperator.d.ts +61 -6
  217. package/geometry/operators/densifyOperator.js +1 -1
  218. package/geometry/operators/differenceOperator.d.ts +34 -2
  219. package/geometry/operators/differenceOperator.js +1 -1
  220. package/geometry/operators/disjointOperator.d.ts +33 -2
  221. package/geometry/operators/disjointOperator.js +1 -1
  222. package/geometry/operators/distanceOperator.d.ts +29 -4
  223. package/geometry/operators/distanceOperator.js +1 -1
  224. package/geometry/operators/equalsOperator.d.ts +32 -2
  225. package/geometry/operators/equalsOperator.js +1 -1
  226. package/geometry/operators/extendOperator.d.ts +29 -3
  227. package/geometry/operators/extendOperator.js +1 -1
  228. package/geometry/operators/generalizeOperator.d.ts +46 -5
  229. package/geometry/operators/generalizeOperator.js +1 -1
  230. package/geometry/operators/geodesicBufferOperator.d.ts +71 -7
  231. package/geometry/operators/geodesicBufferOperator.js +1 -1
  232. package/geometry/operators/geodesicProximityOperator.d.ts +106 -14
  233. package/geometry/operators/geodesicProximityOperator.js +1 -1
  234. package/geometry/operators/geodeticAreaOperator.d.ts +51 -5
  235. package/geometry/operators/geodeticAreaOperator.js +1 -1
  236. package/geometry/operators/geodeticDensifyOperator.d.ts +65 -6
  237. package/geometry/operators/geodeticDensifyOperator.js +1 -1
  238. package/geometry/operators/geodeticDistanceOperator.d.ts +52 -5
  239. package/geometry/operators/geodeticDistanceOperator.js +1 -1
  240. package/geometry/operators/geodeticLengthOperator.d.ts +51 -5
  241. package/geometry/operators/geodeticLengthOperator.js +1 -1
  242. package/geometry/operators/geodeticUtilsOperator.d.ts +79 -9
  243. package/geometry/operators/geodeticUtilsOperator.js +1 -1
  244. package/geometry/operators/graphicBufferOperator.d.ts +47 -4
  245. package/geometry/operators/graphicBufferOperator.js +1 -1
  246. package/geometry/operators/integrateOperator.d.ts +24 -2
  247. package/geometry/operators/integrateOperator.js +1 -1
  248. package/geometry/operators/intersectionOperator.d.ts +88 -3
  249. package/geometry/operators/intersectionOperator.js +1 -1
  250. package/geometry/operators/intersectsOperator.d.ts +32 -2
  251. package/geometry/operators/intersectsOperator.js +1 -1
  252. package/geometry/operators/isNearOperator.d.ts +31 -4
  253. package/geometry/operators/isNearOperator.js +1 -1
  254. package/geometry/operators/json/bufferOperator.js +1 -1
  255. package/geometry/operators/json/containsOperator.js +1 -1
  256. package/geometry/operators/json/convexHullOperator.js +1 -1
  257. package/geometry/operators/json/crossesOperator.js +1 -1
  258. package/geometry/operators/json/disjointOperator.js +1 -1
  259. package/geometry/operators/json/generalizeOperator.js +1 -1
  260. package/geometry/operators/json/geodesicBufferOperator.js +1 -1
  261. package/geometry/operators/json/graphicBufferOperator.js +1 -1
  262. package/geometry/operators/json/intersectionOperator.js +1 -1
  263. package/geometry/operators/json/intersectsOperator.js +1 -1
  264. package/geometry/operators/json/lengthOperator.js +1 -1
  265. package/geometry/operators/json/offsetOperator.js +1 -1
  266. package/geometry/operators/json/overlapsOperator.js +1 -1
  267. package/geometry/operators/json/projectOperator.js +1 -1
  268. package/geometry/operators/json/simplifyOperator.js +1 -1
  269. package/geometry/operators/json/simplifyOperatorOGC.js +1 -1
  270. package/geometry/operators/json/touchesOperator.js +1 -1
  271. package/geometry/operators/json/unionOperator.js +1 -1
  272. package/geometry/operators/json/withinOperator.js +1 -1
  273. package/geometry/operators/labelPointOperator.d.ts +32 -2
  274. package/geometry/operators/labelPointOperator.js +1 -1
  275. package/geometry/operators/lengthOperator.d.ts +28 -4
  276. package/geometry/operators/lengthOperator.js +1 -1
  277. package/geometry/operators/linesToPolygonsOperator.d.ts +23 -2
  278. package/geometry/operators/linesToPolygonsOperator.js +1 -1
  279. package/geometry/operators/locateBetweenOperator.d.ts +28 -2
  280. package/geometry/operators/locateBetweenOperator.js +1 -1
  281. package/geometry/operators/minimumBoundingCircleOperator.d.ts +38 -4
  282. package/geometry/operators/minimumBoundingCircleOperator.js +1 -1
  283. package/geometry/operators/multiPartToSinglePartOperator.d.ts +33 -4
  284. package/geometry/operators/multiPartToSinglePartOperator.js +1 -1
  285. package/geometry/operators/offsetOperator.d.ts +50 -5
  286. package/geometry/operators/offsetOperator.js +1 -1
  287. package/geometry/operators/overlapsOperator.d.ts +33 -2
  288. package/geometry/operators/overlapsOperator.js +1 -1
  289. package/geometry/operators/polygonOverlayOperator.d.ts +31 -5
  290. package/geometry/operators/polygonOverlayOperator.js +1 -1
  291. package/geometry/operators/polygonSlicerOperator.d.ts +72 -10
  292. package/geometry/operators/polygonSlicerOperator.js +1 -1
  293. package/geometry/operators/projectOperator.d.ts +63 -3
  294. package/geometry/operators/projectOperator.js +1 -1
  295. package/geometry/operators/proximityOperator.d.ts +71 -9
  296. package/geometry/operators/proximityOperator.js +1 -1
  297. package/geometry/operators/relateOperator.d.ts +41 -2
  298. package/geometry/operators/relateOperator.js +1 -1
  299. package/geometry/operators/reshapeOperator.d.ts +28 -2
  300. package/geometry/operators/reshapeOperator.js +1 -1
  301. package/geometry/operators/shapePreservingProjectOperator.d.ts +64 -6
  302. package/geometry/operators/shapePreservingProjectOperator.js +1 -1
  303. package/geometry/operators/simplifyOGCOperator.d.ts +72 -6
  304. package/geometry/operators/simplifyOGCOperator.js +1 -1
  305. package/geometry/operators/simplifyOperator.d.ts +72 -4
  306. package/geometry/operators/simplifyOperator.js +1 -1
  307. package/geometry/operators/singlePartToMultiPartOperator.js +1 -1
  308. package/geometry/operators/support/Transformation.d.ts +17 -11
  309. package/geometry/operators/support/jsonConverter.js +1 -1
  310. package/geometry/operators/symmetricDifferenceOperator.d.ts +33 -2
  311. package/geometry/operators/symmetricDifferenceOperator.js +1 -1
  312. package/geometry/operators/touchesOperator.d.ts +32 -2
  313. package/geometry/operators/touchesOperator.js +1 -1
  314. package/geometry/operators/types.d.ts +4 -1
  315. package/geometry/operators/unionOperator.d.ts +33 -2
  316. package/geometry/operators/unionOperator.js +1 -1
  317. package/geometry/operators/withinOperator.d.ts +32 -2
  318. package/geometry/operators/withinOperator.js +1 -1
  319. package/geometry/projectionUtils.js +1 -1
  320. package/geometry/support/geometryUtils.js +1 -1
  321. package/geometry/support/normalizeUtils.d.ts +5 -3
  322. package/geometry/support/normalizeUtils.js +1 -1
  323. package/interfaces.d.ts +202 -202
  324. package/kernel.js +1 -1
  325. package/layers/graphics/data/QueryEngineResult.js +1 -1
  326. package/layers/graphics/data/queryUtils.js +1 -1
  327. package/layers/graphics/data/spatialQuerySupport.js +1 -1
  328. package/layers/graphics/sources/support/sourceUtils.js +1 -1
  329. package/layers/list/Item.d.ts +27 -3
  330. package/layers/list/Item.js +1 -1
  331. package/layers/list/ItemPanel.d.ts +1 -1
  332. package/layers/list/LayerItemCollection.js +1 -1
  333. package/layers/mixins/ArcGISImageService.js +1 -1
  334. package/layers/mixins/TiledImagery.js +1 -1
  335. package/layers/orientedImagery/transformations/updateElevationUtils.js +1 -1
  336. package/layers/raster/datasets/FunctionRaster.js +1 -1
  337. package/layers/raster/datasets/pixelReader.js +1 -1
  338. package/layers/raster/functions/clipUtils.js +1 -1
  339. package/layers/raster/functions/rasterProjectionHelper.js +1 -1
  340. package/layers/support/Sublayer.js +1 -1
  341. package/layers/support/trackInfoUtils.js +2 -0
  342. package/layers/video/videoUtils.js +1 -1
  343. package/package.json +5 -5
  344. package/popup/FeatureContentCollection.d.ts +3 -3
  345. package/popup/FeatureContentCollection.js +1 -1
  346. package/portal/schemas/definitions.js +1 -1
  347. package/portal/schemas/webScene.js +1 -1
  348. package/smartMapping/support/adapters/InMemoryLayerAdapter.js +1 -1
  349. package/support/revision.js +1 -1
  350. package/support/tests/serviceMockDependencies.js +1 -1
  351. package/support/tests/setupServiceMocksMesh.js +1 -1
  352. package/symbols/cim/CIMEffects.js +1 -1
  353. package/symbols/cim/effects/EffectBuffer.js +1 -1
  354. package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
  355. package/symbols/cim/effects/EffectDonut.js +1 -1
  356. package/symbols/cim/effects/EffectEnclosingPolygon.js +1 -1
  357. package/symbols/cim/effects/EffectOffset.js +1 -1
  358. package/symbols/cim/effects/EffectTaperedPolygon.js +1 -1
  359. package/views/2d/analysis/AreaMeasurement/AreaMeasurementController.js +1 -1
  360. package/views/2d/analysis/DistanceMeasurement/DistanceMeasurementController.js +1 -1
  361. package/views/2d/engine/webgl/Overlay.js +1 -1
  362. package/views/2d/engine/webgl/VideoScreenRenderer.js +1 -1
  363. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  364. package/views/2d/layers/TileLayerView2D.js +1 -1
  365. package/views/2d/layers/support/RouteLayerWaypointVisualization.js +1 -1
  366. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  367. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementController.js +1 -1
  368. package/views/3d/layers/ElevationLayerView3D.js +1 -1
  369. package/views/3d/layers/ElevationLayerView3DModifications.js +1 -1
  370. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  371. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  372. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  373. package/views/MapView.d.ts +3 -3
  374. package/views/SceneView.js +1 -1
  375. package/views/VideoView.js +1 -1
  376. package/views/View2D.d.ts +22 -22
  377. package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
  378. package/views/draw/DrawTool.js +1 -1
  379. package/views/draw/support/createUtils.js +1 -1
  380. package/views/layers/SceneLayerView.js +1 -1
  381. package/views/support/GeometryWorker.js +1 -1
  382. package/views/support/imageReprojection.js +1 -1
  383. package/views/video/VideoOperationalDataView.js +1 -1
  384. package/webscene/InitialViewProperties.d.ts +9 -1
  385. package/webscene/InitialViewProperties.js +1 -1
  386. package/webscene/Slide.d.ts +10 -1
  387. package/webscene/Slide.js +1 -1
  388. package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
  389. package/widgets/BatchAttributeForm/expressions/ExpressionsModel.js +1 -1
  390. package/widgets/BatchAttributeForm/expressions/expressionUtils.js +1 -1
  391. package/widgets/BatchAttributeForm/inputs/support/DynamicChoiceController.js +1 -1
  392. package/widgets/BatchAttributeForm/templates/FieldElementTemplate.js +1 -1
  393. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  394. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
  395. package/widgets/Editor/support/mergeFeaturesUtils.js +1 -1
  396. package/widgets/Editor/support/splitFeatureUtils.js +1 -1
  397. package/widgets/ElevationProfile/support/ElevationProfileView.js +1 -1
  398. package/widgets/ElevationProfile/support/InputRepresentation2D.js +1 -1
  399. package/widgets/ElevationProfile/support/InputRepresentation3D.js +1 -1
  400. package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
  401. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  402. package/widgets/Features/FeaturesViewModel.js +1 -1
  403. package/widgets/Features.js +1 -1
  404. package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
  405. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  406. package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
  407. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  408. package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
  409. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  410. package/widgets/OrientedImageryViewer/support/panConstraint.js +1 -1
  411. package/widgets/OrientedImageryViewer/support/superimposeUtils.js +1 -1
  412. package/widgets/OrientedImageryViewer/videoViewerUtils.js +1 -1
  413. package/widgets/Print.js +1 -1
  414. package/widgets/Search/SearchViewModel.js +1 -1
  415. package/widgets/Search/support/layerSearchUtils.js +1 -1
  416. package/widgets/Search/support/locatorUtils.js +1 -1
  417. package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
  418. package/widgets/support/FilterBuilder/FilterBuilderViewModel.d.ts +104 -0
  419. package/widgets/support/FilterBuilder/FilterBuilderViewModel.js +1 -1
  420. package/widgets/support/FilterBuilder.js +1 -1
  421. package/widgets/support/FilterCondition/FilterConditionViewModel.d.ts +145 -0
  422. package/widgets/support/FilterCondition/FilterConditionViewModel.js +1 -1
  423. package/widgets/support/FilterCondition/types.d.ts +20 -0
  424. package/widgets/support/ItemList.js +1 -1
  425. package/widgets/support/SelectionList/FeatureItem.d.ts +17 -68
  426. package/widgets/support/SelectionList/FeatureItem.js +1 -1
  427. package/widgets/support/SelectionList/GroupLayerItem.d.ts +12 -50
  428. package/widgets/support/SelectionList/GroupLayerItem.js +1 -1
  429. package/widgets/support/SelectionList/ItemBase.d.ts +14 -44
  430. package/widgets/support/SelectionList/ItemBase.js +1 -1
  431. package/widgets/support/SelectionList/LayerItem.d.ts +10 -56
  432. package/widgets/support/SelectionList/LayerItem.js +1 -1
  433. package/widgets/support/SelectionList/types.d.ts +4 -4
  434. package/widgets/support/Selector2D/selectorUtils.js +1 -1
  435. package/assets/esri/core/workers/chunks/090ea7a131f8f60203ed.js +0 -1
  436. package/assets/esri/core/workers/chunks/0b4a7209b99227a842ad.js +0 -1
  437. package/assets/esri/core/workers/chunks/0be98adfef79fc5036f0.js +0 -1
  438. package/assets/esri/core/workers/chunks/0d2e2d90a4e4a28e2c0c.js +0 -1
  439. package/assets/esri/core/workers/chunks/0d7763d39a5a8586a0ae.js +0 -1
  440. package/assets/esri/core/workers/chunks/0d95f72e1c07ab867d21.js +0 -1
  441. package/assets/esri/core/workers/chunks/0dbbac7a2378728571a7.js +0 -1
  442. package/assets/esri/core/workers/chunks/0df9864ecebe6a2b973f.js +0 -1
  443. package/assets/esri/core/workers/chunks/104d74bc36c28c519396.js +0 -1
  444. package/assets/esri/core/workers/chunks/1670e9867efde4d7a6d6.js +0 -1
  445. package/assets/esri/core/workers/chunks/1c803eef9a8fdabc61e3.js +0 -2
  446. package/assets/esri/core/workers/chunks/1e192ac0533a5c0b5a7a.js +0 -1
  447. package/assets/esri/core/workers/chunks/1fe077f57a087c0e9119.js +0 -1
  448. package/assets/esri/core/workers/chunks/20f7b5fe64a217cb3d3d.js +0 -1
  449. package/assets/esri/core/workers/chunks/212222b64039d436b9a6.js +0 -1
  450. package/assets/esri/core/workers/chunks/24944b625ed8dcd904f0.js +0 -1
  451. package/assets/esri/core/workers/chunks/2b6d261fe79fe186fb22.js +0 -1
  452. package/assets/esri/core/workers/chunks/2bc3e7f394386fa75447.js +0 -1
  453. package/assets/esri/core/workers/chunks/30af0f7c4cfa541c9efd.js +0 -1
  454. package/assets/esri/core/workers/chunks/30d816bdeea00f6fa1ca.js +0 -1
  455. package/assets/esri/core/workers/chunks/35d46c2f658a8e92d913.js +0 -1
  456. package/assets/esri/core/workers/chunks/36e35a8067b18f59cc05.js +0 -1
  457. package/assets/esri/core/workers/chunks/3869dca884d7ca6488f5.js +0 -1
  458. package/assets/esri/core/workers/chunks/3f5234120d3a14186c1c.js +0 -1
  459. package/assets/esri/core/workers/chunks/45c1c90ac6c14657f3ff.js +0 -1
  460. package/assets/esri/core/workers/chunks/4a40b894ec89b0a4f9bf.js +0 -1
  461. package/assets/esri/core/workers/chunks/5165d367328ac7badf47.js +0 -1
  462. package/assets/esri/core/workers/chunks/5168bd8ab6233dc9c32a.js +0 -1
  463. package/assets/esri/core/workers/chunks/545bec045167c433af8f.js +0 -1
  464. package/assets/esri/core/workers/chunks/5782c0362a1799ceef41.js +0 -1
  465. package/assets/esri/core/workers/chunks/59598023c0aea62a6297.js +0 -1
  466. package/assets/esri/core/workers/chunks/59f0a2bd40b033ce77e4.js +0 -1
  467. package/assets/esri/core/workers/chunks/5af16937904c06fb06f6.js +0 -1
  468. package/assets/esri/core/workers/chunks/5b8591486f33627f5389.js +0 -1
  469. package/assets/esri/core/workers/chunks/6057a79c68c33ee4a193.js +0 -1
  470. package/assets/esri/core/workers/chunks/607acd9f615f87e14075.js +0 -1
  471. package/assets/esri/core/workers/chunks/62ee6c247f783acabb74.js +0 -1
  472. package/assets/esri/core/workers/chunks/63127e3b22e7eac6003d.js +0 -2
  473. package/assets/esri/core/workers/chunks/6564f17c4700dc8d9c0e.js +0 -2
  474. package/assets/esri/core/workers/chunks/678585509706755c0434.js +0 -2
  475. package/assets/esri/core/workers/chunks/691e9cc541cfaebe1776.js +0 -1
  476. package/assets/esri/core/workers/chunks/6a2d890640b2cd6c5ccb.js +0 -1
  477. package/assets/esri/core/workers/chunks/6b84982dfaf084a61b93.js +0 -1
  478. package/assets/esri/core/workers/chunks/6cbc30b31f0bb39c73ca.js +0 -1
  479. package/assets/esri/core/workers/chunks/6f01bd01b13662eb3bd7.js +0 -1
  480. package/assets/esri/core/workers/chunks/74cd9df85c4560bb8e52.js +0 -1
  481. package/assets/esri/core/workers/chunks/75bddfe2be64379db8fd.js +0 -1
  482. package/assets/esri/core/workers/chunks/7cf903db44f3647c8fd4.js +0 -1
  483. package/assets/esri/core/workers/chunks/7ddb5800777fbecee3a8.js +0 -1
  484. package/assets/esri/core/workers/chunks/7eae9053065d3d38e54e.js +0 -1
  485. package/assets/esri/core/workers/chunks/80f38ab2b7ae61e6f301.js +0 -1
  486. package/assets/esri/core/workers/chunks/854f42f16fdb40000aae.js +0 -1
  487. package/assets/esri/core/workers/chunks/87094044458b0ea5cb0f.js +0 -2
  488. package/assets/esri/core/workers/chunks/88f03352a4dc6184ea1f.js +0 -1
  489. package/assets/esri/core/workers/chunks/909ee7d2a0eec773037a.js +0 -1
  490. package/assets/esri/core/workers/chunks/91ac9328afff8a51bd96.js +0 -1
  491. package/assets/esri/core/workers/chunks/92a6559a6999b26362d7.js +0 -1
  492. package/assets/esri/core/workers/chunks/94ddfe165ac25aef8229.js +0 -1
  493. package/assets/esri/core/workers/chunks/9509bef285929c52c244.js +0 -1
  494. package/assets/esri/core/workers/chunks/99966339b061eb9945b8.js +0 -1
  495. package/assets/esri/core/workers/chunks/99f627938dbf0152fc02.js +0 -1
  496. package/assets/esri/core/workers/chunks/9df38cadebf8e6fd746c.js +0 -1
  497. package/assets/esri/core/workers/chunks/9e2b3754a76e0dd4a94a.js +0 -1
  498. package/assets/esri/core/workers/chunks/a0565137027c83108953.js +0 -1
  499. package/assets/esri/core/workers/chunks/a0eb882a5a81d25b9153.js +0 -1
  500. package/assets/esri/core/workers/chunks/a785e827f0215a73103d.js +0 -1
  501. package/assets/esri/core/workers/chunks/abe7670db06b27c0c8c8.js +0 -1
  502. package/assets/esri/core/workers/chunks/b19cff0e43fab2632660.js +0 -1
  503. package/assets/esri/core/workers/chunks/b333de4dea14c5db0a4d.js +0 -1
  504. package/assets/esri/core/workers/chunks/b6af90be328ebda26b8d.js +0 -1
  505. package/assets/esri/core/workers/chunks/b7c0da9d255d5e48320d.js +0 -1
  506. package/assets/esri/core/workers/chunks/bd7d87d175ba933ab2ce.js +0 -1
  507. package/assets/esri/core/workers/chunks/be0417df35a7d99af675.js +0 -1
  508. package/assets/esri/core/workers/chunks/c30b6bbabd05e4976fba.js +0 -1
  509. package/assets/esri/core/workers/chunks/c35553d07ad169910742.js +0 -1
  510. package/assets/esri/core/workers/chunks/c5c2fed38e0ccf84f1fa.js +0 -1
  511. package/assets/esri/core/workers/chunks/c88bfa51d2a8a024fc24.js +0 -1
  512. package/assets/esri/core/workers/chunks/ca36d85a47179d95f2fc.js +0 -1
  513. package/assets/esri/core/workers/chunks/d0cf9ff48f051adbd455.js +0 -1
  514. package/assets/esri/core/workers/chunks/d1304d414b1fa725168a.js +0 -1
  515. package/assets/esri/core/workers/chunks/d24125a791247019e2ca.js +0 -1
  516. package/assets/esri/core/workers/chunks/d26be8313526ecea9c68.js +0 -1
  517. package/assets/esri/core/workers/chunks/d2cb3d5ef0a9285afb78.js +0 -1
  518. package/assets/esri/core/workers/chunks/d4b0012ae1d3b8a9ba01.js +0 -1
  519. package/assets/esri/core/workers/chunks/e018cbd97e6e0e4ca5c4.js +0 -1
  520. package/assets/esri/core/workers/chunks/e39bccc000c768120a32.js +0 -1
  521. package/assets/esri/core/workers/chunks/e4380706b629729f2212.js +0 -1
  522. package/assets/esri/core/workers/chunks/ea1877ce00da3b585a30.js +0 -1
  523. package/assets/esri/core/workers/chunks/ea5ee1b12b43594592a0.js +0 -1
  524. package/assets/esri/core/workers/chunks/ea91c57a0b31f3f65ee5.js +0 -1
  525. package/assets/esri/core/workers/chunks/eafc591e1a98000d54ef.js +0 -1
  526. package/assets/esri/core/workers/chunks/ef851a2cff76fd211c07.js +0 -1
  527. package/assets/esri/core/workers/chunks/f3e53be08ab9dbdf17ae.js +0 -1
  528. package/assets/esri/core/workers/chunks/f53010adb70463b75bb9.js +0 -1
  529. package/assets/esri/core/workers/chunks/f5a058a0ce006bce2a2a.js +0 -1
  530. package/assets/esri/core/workers/chunks/f5f5b54cab722abe88e0.js +0 -1
  531. package/assets/esri/core/workers/chunks/f60ed579981913d44675.js +0 -1
  532. package/assets/esri/core/workers/chunks/f6f56f3e011dcef90bbb.js +0 -1
  533. package/assets/esri/core/workers/chunks/f83c3597e9332bd991eb.js +0 -1
  534. package/assets/esri/core/workers/chunks/f9a4387f850d85c44ca5.js +0 -1
  535. package/assets/esri/core/workers/chunks/fdd0e6d9927d3c43b0d3.js +0 -1
  536. package/geometry/operators/importUtils.js +0 -2
  537. /package/assets/esri/core/workers/chunks/{1c803eef9a8fdabc61e3.js.LICENSE.txt → 1082bb0858585bd4fa21.js.LICENSE.txt} +0 -0
  538. /package/assets/esri/core/workers/chunks/{87094044458b0ea5cb0f.js.LICENSE.txt → 2e2349387a2b9903f13c.js.LICENSE.txt} +0 -0
  539. /package/assets/esri/core/workers/chunks/{678585509706755c0434.js.LICENSE.txt → 411bbdecba340df11d95.js.LICENSE.txt} +0 -0
  540. /package/assets/esri/core/workers/chunks/{5edf77618ca51819d7c4.js.LICENSE.txt → 476535cfb06ced74d611.js.LICENSE.txt} +0 -0
  541. /package/assets/esri/core/workers/chunks/{6564f17c4700dc8d9c0e.js.LICENSE.txt → b82b523b6837ed1f28d3.js.LICENSE.txt} +0 -0
  542. /package/assets/esri/core/workers/chunks/{63127e3b22e7eac6003d.js.LICENSE.txt → ef24fd6c0322e5de9fdf.js.LICENSE.txt} +0 -0
package/WebScene.d.ts CHANGED
@@ -66,6 +66,7 @@ export interface WebSceneProperties extends MapProperties, LoadableMixinProperti
66
66
  * The initial view of the WebScene. This object may contain the following properties:
67
67
  * [InitialViewProperties.environment](https://developers.arcgis.com/javascript/latest/references/core/webscene/InitialViewProperties/#environment),
68
68
  * [InitialViewProperties.spatialReference](https://developers.arcgis.com/javascript/latest/references/core/webscene/InitialViewProperties/#spatialReference),
69
+ * [InitialViewProperties.timeZone](https://developers.arcgis.com/javascript/latest/references/core/webscene/InitialViewProperties/#timeZone),
69
70
  * [InitialViewProperties.viewingMode](https://developers.arcgis.com/javascript/latest/references/core/webscene/InitialViewProperties/#viewingMode), and
70
71
  * [InitialViewProperties.viewpoint](https://developers.arcgis.com/javascript/latest/references/core/webscene/InitialViewProperties/#viewpoint).
71
72
  *
@@ -323,6 +324,7 @@ export default class WebScene extends WebSceneSuperclass {
323
324
  * The initial view of the WebScene. This object may contain the following properties:
324
325
  * [InitialViewProperties.environment](https://developers.arcgis.com/javascript/latest/references/core/webscene/InitialViewProperties/#environment),
325
326
  * [InitialViewProperties.spatialReference](https://developers.arcgis.com/javascript/latest/references/core/webscene/InitialViewProperties/#spatialReference),
327
+ * [InitialViewProperties.timeZone](https://developers.arcgis.com/javascript/latest/references/core/webscene/InitialViewProperties/#timeZone),
326
328
  * [InitialViewProperties.viewingMode](https://developers.arcgis.com/javascript/latest/references/core/webscene/InitialViewProperties/#viewingMode), and
327
329
  * [InitialViewProperties.viewpoint](https://developers.arcgis.com/javascript/latest/references/core/webscene/InitialViewProperties/#viewpoint).
328
330
  *
@@ -610,9 +612,10 @@ export default class WebScene extends WebSceneSuperclass {
610
612
  * 1. `initialViewProperties.spatialReference`
611
613
  * 2. `initialViewProperties.viewingMode`
612
614
  * 3. `initialViewProperties.timeExtent`
613
- * 4. `initialViewProperties.analyses`
614
- * 5. `clippingArea`
615
- * 6. `heightModelInfo`
615
+ * 4. `initialViewProperties.timeZone`
616
+ * 5. `initialViewProperties.analyses`
617
+ * 6. `clippingArea`
618
+ * 7. `heightModelInfo`
616
619
  *
617
620
  * Depending on the provided options, the following properties are also updated:
618
621
  *
package/WebScene.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./core/Collection.js";import o from"./core/Error.js";import{clone as s}from"./core/lang.js";import{LoadableMixin as a}from"./core/Loadable.js";import{loadAll as n}from"./core/loadAll.js";import l from"./core/Logger.js";import{destroyMaybe as p}from"./core/maybe.js";import{MultiOriginJSONSupportMixin as c,MultiOriginJSONSupport as d}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as h}from"./core/Promise.js";import{debounce as u}from"./core/promiseUtils.js";import{on as m,watch as y}from"./core/reactiveUtils.js";import{urlToObject as w,addQueryParameter as f}from"./core/urlUtils.js";import g from"./core/Version.js";import b from"./core/Warning.js";import{property as v,subclass as _}from"./core/accessorSupport/decorators.js";import{updateOrigins as S}from"./core/accessorSupport/originUtils.js";import{readLoadable as A}from"./core/accessorSupport/read.js";import{isEarth as I}from"./geometry/ellipsoidUtils.js";import j from"./geometry/Extent.js";import L from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as R}from"./geometry/projectionUtils.js";import P from"./geometry/SpatialReference.js";import{validateWebSceneError as U}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as O}from"./geometry/support/jsonUtils.js";import V from"./portal/Portal.js";import M from"./portal/PortalItem.js";import{createForItemWrite as E}from"./portal/support/jsonContext.js";import{toggleTypeKeyword as C,typeKeyword as T}from"./portal/support/portalItemUtils.js";import{hasDeveloperBasemapLayer as N}from"./support/basemapUtils.js";import{ensureType as x}from"./support/groundUtils.js";import F from"./support/MapFloorInfo.js";import{WebSceneTag as G}from"./support/tagSymbols.js";import{createSchemaValidationError as W}from"./support/webSceneUtils.js";import{isSpatialReferenceSupported as J}from"./views/support/spatialReferenceSupport.js";import k from"./webdoc/Widgets.js";import{updateItemWithResources as B,saveResources as $}from"./webdoc/support/resourceUtils.js";import{evaluateWriteErrors as q}from"./webdoc/support/saveUtils.js";import{getNormalizedThumbnailData as H,getOptimalThumbnailSize as D}from"./webdoc/support/thumbnailUtils.js";import{addLayerUnsupportedError as z}from"./webdoc/support/unsupportedErrors.js";import{isCopyAllowed as K,initializeNewItem as Q}from"./webdoc/support/webdocSaveUtils.js";import X from"./webscene/ApplicationProperties.js";import Y from"./webscene/Environment.js";import Z from"./webscene/InitialViewProperties.js";import ee from"./webscene/Presentation.js";import te from"./webscene/TransportationNetwork.js";import{webSceneVersion as re}from"./webscene/version.js";import{alphaCutoff as ie}from"./webscene/support/AlphaCutoff.js";import{getLoader as oe}from"./webscene/support/schemaValidatorLoader.js";import{supportsVisibleElevationLayersInSlides as se,versionSupportsGround as ae,generateWebSceneVersions as ne}from"./webscene/support/versionUtils.js";import{writer as le}from"./core/accessorSupport/decorators/writer.js";import{reader as pe}from"./core/accessorSupport/decorators/reader.js";var ce;const de="Web Scene";let he=class extends(a(h(c(r)))){static{ce=G}constructor(e){super(e),this[ce]=!0,this._layersIdGCTimeoutId=void 0,this._updateFromPromise=null,this._afterLoadHooks=[],this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=void 0,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new ee,this.initialViewProperties=new Z,this.portalItem=null,this.resourceInfo=null,this.widgets=null,this._debouncedSaveOperations=u(async(e,t,r)=>{switch(e){case 0:return this._saveImpl(t);case 1:return this._saveAsImpl(r,t)}}),this._loadContext={origin:"web-scene",initiator:this,hooks:{onAfterLoad:e=>this._afterLoadHooks.push(e)}},this._resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch(e=>{l.getLogger(this).error("#load()","Failed to load web scene",e)}),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this.addHandles(m(()=>this.allLayers,"change",()=>this._scheduleLayersIdGC()))}destroy(){this._unscheduleLayersIdGC(),this.presentation&&this.presentation.destroy(),this.portalItem=p(this.portalItem)}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){t[r]=this._layersToJSON(e,"operational-layers",i)}get loaded(){return super.loaded}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new g(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${re.major}.${re.minor}`}writeTables(e,t,r,i){const o=this._layersToJSON(e,"tables",i);o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl??null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}get ground(){return this._get("ground")}set ground(e){const t=x(e);null!=t&&this._set("ground",t)}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t,r){const{viewingMode:i,spatialReference:o}=t,s=new Z,a={...t.initialState};return void 0!==o&&(a.spatialReference=o),void 0!==i&&(a.viewingMode=i),s.read(a,r),s}get spatialReference(){return this.initialViewProperties?.spatialReference??P.WebMercator}get viewingMode(){return this.initialViewProperties?.viewingMode??"global"}load(e){const t=this.ground;return this.addResolvingPromise(this._loadFromSource().then(()=>{t&&t!==this.ground&&t.destroy(),this._validateFeatureLayerSymbolVisibility()})),Promise.resolve(this)}loadAll(){return n(this,e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map(e=>e.basemap),this.tables)})}read(e,t){t??=this._loadContext,t.origin="web-scene";const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(A(this,e,t=>super.read(e,t),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&se(this.sourceVersion)){const t=e.baseMap.elevationLayers.map(e=>({id:e.id})),r=this.presentation.slides,i=t.filter(e=>!r.some(t=>t.visibleLayers.some(t=>t.id===e.id)));r.forEach(e=>e.visibleLayers.addMany(i))}}_writeBasemapElevationLayers(e){const t=e.ground?.layers;!e.baseMap&&t?.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=s(t))}_layersToJSON(e,t,r){const i={...r,layerContainerType:t};return e.map(e=>this._verifyWritableLayer(e,r)?e.write({},i):null).filter(e=>!!e).toArray()}_verifyWritableLayer(e,t){return!!e.persistenceEnabled&&("write"in e||(z(t,e),!1))}write(e,t){if("loaded"!==this.loadStatus){const e=new o("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw l.getLogger(this).error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const r=!t?.messages;t={messages:[],...t,origin:"web-scene"};const i=super.write(e,t);if(r){const e=t.messages?.filter(e=>"web-document-write:property-required"===e.name)??[];if(e.length){const t=new o("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw l.getLogger(this).error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(i),i}async save(e){return this._debouncedSaveOperations(0,e)}async _saveImpl(e){if(!this.portalItem)throw new o("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene");if(this.portalItem?.type!==de)throw new o("webscene:portal-item-wrong-type",`Portal item needs to have type "${de}"`);const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls(E(this.portalItem,"web-scene",{withResources:!0})),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,0,e),this._updateTypeKeywords(this.portalItem),await B(this.portalItem,i,this._resourceReferences,r),S(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(1,t,e)}async _saveAsImpl(e,t){let r=M.from(e);if(!r)throw new o("webscene:portal-item-required","saveAs requires a portal item to save to");r.id&&(r=r.clone(),r.id=null);const i=r.portal||V.getDefault();await this._ensureLoadBeforeSave(),r.type=de,r.portal=i;const s=this._enableVerifyItemRelativeUrls(E(r,"web-scene",{withResources:!0})),a=this.write({},s);await Promise.all(s.resources.pendingOperations),await this._verifySaveAs(a,s,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");this._updateTypeKeywords(r),await i.signIn();const p=this.portalItem,c={item:p,authenticated:!(!p?.id||!p.portal.user)},{copyAllowed:h,itemReloaded:u}=await K(c,i);if(c.authenticated||=u,!h)throw new o(`${s.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const m={...t,copyAllResources:!0},y=await Q(r,c,a,m);return y&&(this._resourceReferences.portalItem=r),await $(this._resourceReferences,s,{ignoreResourceCopyErrors:y}),this.portalItem=r,d.prototype.read.call(this,{version:a.version,authoringApp:a.authoringApp,authoringAppVersion:a.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl?w(r.itemUrl):void 0}),S(s),n&&(this.thumbnailUrl=l?f(n,"w","8192"):n),s.portalItem=r,await this._saveThumbnail(p),r}async _saveThumbnail(e){if(this._isOverridden("thumbnailUrl")){const t=await H(this.thumbnailUrl,null,e);await(this.portalItem?.updateThumbnail(t)),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user")}}async _verifySave(e,t,r,i){if(!I(this.spatialReference))throw new o("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently.");const{ignoreUnsupported:s,requiredPropertyChecksDisabled:a,strictSchemaValidationEnabled:n}=i||{};q(t,{errorName:"webscene:save"},{ignoreUnsupported:s,supplementalUnsupportedErrors:["scenemodification:unsupported"],requiredPropertyChecksDisabled:a});const p=oe();if(n&&p){const t=(await p()).validate(e);if(!t.length)return;const i=`webscene did not validate:\n${t.join("\n")}`;l.getLogger(this).error(`${1===r?"saveAs":"save"}(): ${i}`);const s=t.map(e=>new o("webscene:schema-validation",e));throw W(s)}}_verifySaveAs(e,t,r){return this._verifySave(e,t,1,r)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(){return!1}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment&&(this.initialViewProperties.environment=Y.prototype.clone.apply(e.environment)),!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,this.initialViewProperties.timeExtent=e.timeExtent?.clone()??null,this.initialViewProperties.analyses.updateFrom(e),null!=e.clippingArea?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}if(!t.widgetsExcluded)for(const r of e.registeredComponents)r.updateWebDocument(this);(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this.updateThumbnail(e,{size:t.thumbnailSize})}async updateThumbnail(e,t){const r=D(e,t?.size),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}async _loadFromSource(){this.resourceInfo?await this._loadFromJSON(this.resourceInfo):this.portalItem?.id?await this._loadFromItem(this.portalItem):await this._loadObjectsWithLayers(),await this._afterLoad()}async _afterLoad(){for(;this._afterLoadHooks.length;){const e=this._afterLoadHooks.slice();this._afterLoadHooks.length=0,await Promise.allSettled(e.map(e=>e(this._loadContext)))}}_readAndLoadFromJSON(e){const t=this._loadContext,r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r)}_extractOperationalLayers(e){const t=[];if(!ae(this.sourceVersion)&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(ae(this.sourceVersion)||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}async _loadFromJSON(e){const t=new i;await this._validateSpatialReference(),await this._validateHeightModelInfo();const{populateOperationalLayers:r}=await(import("./layers/support/layersCreator.js")),{operationalLayers:o,operationalElevationLayers:s,basemapElevationLayers:a}=this._extractOperationalLayers(e),n=[],l={context:{...this._loadContext,layerContainerType:"operational-layers"}};if(this.portalItem&&(l.context.portal=this.portalItem.portal||V.getDefault()),a.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(r(this.ground.layers,a,e))}if(s.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(r(t,s,e))}o&&o.length>0&&n.push(r(this.layers,o,l)),e.tables?.length&&n.push(r(this.tables,e.tables,{...l,context:{...l.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"})),await Promise.allSettled(n),await this._loadObjectsWithLayers(),this.ground.layers.addMany(t.filter(e=>"base-elevation"===e.type||"elevation"===e.type))}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[],t=[...this.allLayers.items];for(const{basemap:r}of this.presentation.slides.items)r&&(t.push(...r.baseLayers.items),t.push(...r.groundLayers.items),t.push(...r.referenceLayers.items));for(const r of t)if("beforeSave"in r&&"function"==typeof r.beforeSave){const t=r.beforeSave();t&&e.push(t)}await Promise.allSettled(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach(t=>{t.basemap&&e.push(t.basemap.load())}),await Promise.allSettled(e)}async _loadFromItem(e){if(await e.load().catch(e=>{throw new o("webscene:load-portal-item","Failed to load portal item",{error:e})}),"Web Scene"!==e.type)throw new o("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r=this._loadContext;r.url=w(e.itemUrl),r.portal=e.portal||V.getDefault(),r.portalItem=e,r.readResourcePaths=[],await this._readAndLoadFromJSON(t),this._resourceReferences={portalItem:e,paths:r.readResourcePaths??[]}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!J(t,1))return Promise.reject(new o("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||R(e,t)}else{if(!J(t,2))return Promise.reject(new o("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e?.camera?.position.spatialReference??e?.targetGeometry?.spatialReference,s=e.viewpoint,a=i(s);if(a&&!r(a))return Promise.reject(new o("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:a,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find(e=>!r(i(e.viewpoint)));if(n){const r=i(n.viewpoint);return Promise.reject(new o("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=U(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateFeatureLayerSymbolVisibility(){this.sourceVersion?.greaterEqual(1,35)||this.layers.forEach(e=>{"feature"===e.type&&e.addHandles(y(()=>e.loaded,()=>{"on-the-ground"===e.elevationInfo?.mode&&"simple"===e.renderer?.type&&"polygon-3d"===e.renderer.symbol?.type&&e.renderer.symbol.symbolLayers.some(t=>"fill"===t.type&&null!=t.material&&((!t.material.color||t.material.color.a*e.opacity<ie)&&(e.loadWarnings.push(new b("feature-layer:invisible-draped-symbols","FeatureLayer has fully transparent symbols which will no longer render or highlight",{layer:e})),!0)))},{once:!0,sync:!0}))})}_validateJSON(e){const t=g.parse(e.version||"","webscene");return re.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=P.WebMercator.toJSON()),e}_updateTypeKeywords(e){C(e,T.LOCAL_SCENE,"local"===this.initialViewProperties.viewingMode),C(e,T.DEVELOPER_BASEMAP,N(this.basemap)||this.presentation.slides.some(({basemap:e})=>!!e&&N(e))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter((e,t,r)=>r.indexOf(e)===t))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||P.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem?.itemUrl?w(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout(()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()},3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties?.viewing?.search,t=e=>this.allLayers.some(t=>t.id===e&&t.persistenceEnabled);e?.layers&&(e.layers=e.layers.filter(e=>t(e.id)));const r=this.presentation&&this.presentation.slides;r&&r.forEach(e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter(e=>t(e.id)))})}static fromJSON(e){if(!e)throw new o("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}static{this.version=`${re.major}.${re.minor}`}};e([v({type:X,json:{write:!0}})],he.prototype,"applicationProperties",void 0),e([v({type:j,json:{read:{source:"clippingArea.geometry",reader:O},write:{target:"clippingArea.geometry"}}})],he.prototype,"clippingArea",void 0),e([le("clippingArea")],he.prototype,"writeClippingArea",null),e([v({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],he.prototype,"clippingEnabled",void 0),e([pe("clippingEnabled",["clippingArea"])],he.prototype,"readClippingEnabled",null),e([le("clippingEnabled")],he.prototype,"writeClippingEnabled",null),e([v({type:F,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],he.prototype,"floorInfo",void 0),e([v({type:L,json:{write:!0}})],he.prototype,"heightModelInfo",void 0),e([v({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],he.prototype,"layers",void 0),e([le("layers")],he.prototype,"writeLayers",null),e([v({readOnly:!0,type:g,json:{type:ne(re).map(e=>e.toString()),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],he.prototype,"sourceVersion",void 0),e([pe("sourceVersion",["version"])],he.prototype,"readSourceVersion",null),e([le("sourceVersion")],he.prototype,"writeSourceVersion",null),e([v({json:{read:!1,write:{enabled:!0,ignoreOrigin:!0}}})],he.prototype,"tables",void 0),e([le("tables")],he.prototype,"writeTables",null),e([v()],he.prototype,"thumbnailUrl",null),e([v({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],he.prototype,"authoringApp",null),e([le("authoringApp")],he.prototype,"writeAuthoringApp",null),e([v({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],he.prototype,"authoringAppVersion",null),e([le("authoringAppVersion")],he.prototype,"writeAuthoringAppVersion",null),e([v({json:{write:{isRequired:!0,enabled:!0,overridePolicy:()=>({isRequired:!0,enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],he.prototype,"ground",null),e([le("ground")],he.prototype,"writeGround",null),e([v({type:i.ofType(te),json:{write:!0}})],he.prototype,"transportationNetworks",void 0),e([v({type:ee,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],he.prototype,"presentation",void 0),e([v({type:Z,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new Z({viewingMode:"global",spatialReference:P.WebMercator})}})],he.prototype,"initialViewProperties",void 0),e([pe("initialViewProperties",["initialState","spatialReference","viewingMode"])],he.prototype,"readInitialViewProperties",null),e([v({type:P,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],he.prototype,"spatialReference",null),e([v({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],he.prototype,"viewingMode",null),e([v({type:M})],he.prototype,"portalItem",void 0),e([v()],he.prototype,"resourceInfo",void 0),e([v({type:k,json:{write:!0}})],he.prototype,"widgets",void 0),he=e([_("esri.WebScene")],he);const ue=he;export{ue as default};
2
+ import{__decorate as e}from"tslib";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./core/Collection.js";import o from"./core/Error.js";import{clone as s}from"./core/lang.js";import{LoadableMixin as a}from"./core/Loadable.js";import{loadAll as n}from"./core/loadAll.js";import l from"./core/Logger.js";import{destroyMaybe as p}from"./core/maybe.js";import{MultiOriginJSONSupportMixin as c,MultiOriginJSONSupport as d}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as h}from"./core/Promise.js";import{debounce as u}from"./core/promiseUtils.js";import{on as m,watch as y}from"./core/reactiveUtils.js";import{urlToObject as w,addQueryParameter as f}from"./core/urlUtils.js";import g from"./core/Version.js";import b from"./core/Warning.js";import{property as v,subclass as _}from"./core/accessorSupport/decorators.js";import{updateOrigins as S}from"./core/accessorSupport/originUtils.js";import{readLoadable as A}from"./core/accessorSupport/read.js";import{isEarth as I}from"./geometry/ellipsoidUtils.js";import j from"./geometry/Extent.js";import L from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as R}from"./geometry/projectionUtils.js";import P from"./geometry/SpatialReference.js";import{validateWebSceneError as U}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as V}from"./geometry/support/jsonUtils.js";import O from"./portal/Portal.js";import M from"./portal/PortalItem.js";import{createForItemWrite as E}from"./portal/support/jsonContext.js";import{toggleTypeKeyword as C,typeKeyword as T}from"./portal/support/portalItemUtils.js";import{hasDeveloperBasemapLayer as N}from"./support/basemapUtils.js";import{ensureType as x}from"./support/groundUtils.js";import F from"./support/MapFloorInfo.js";import{WebSceneTag as G}from"./support/tagSymbols.js";import{createSchemaValidationError as W}from"./support/webSceneUtils.js";import{isSpatialReferenceSupported as J}from"./views/support/spatialReferenceSupport.js";import k from"./webdoc/Widgets.js";import{updateItemWithResources as B,saveResources as $}from"./webdoc/support/resourceUtils.js";import{evaluateWriteErrors as q}from"./webdoc/support/saveUtils.js";import{getNormalizedThumbnailData as H,getOptimalThumbnailSize as D}from"./webdoc/support/thumbnailUtils.js";import{addLayerUnsupportedError as Z}from"./webdoc/support/unsupportedErrors.js";import{isCopyAllowed as z,initializeNewItem as K}from"./webdoc/support/webdocSaveUtils.js";import Q from"./webscene/ApplicationProperties.js";import X from"./webscene/Environment.js";import Y from"./webscene/InitialViewProperties.js";import ee from"./webscene/Presentation.js";import te from"./webscene/TransportationNetwork.js";import{webSceneVersion as re}from"./webscene/version.js";import{alphaCutoff as ie}from"./webscene/support/AlphaCutoff.js";import{getLoader as oe}from"./webscene/support/schemaValidatorLoader.js";import{supportsVisibleElevationLayersInSlides as se,versionSupportsGround as ae,generateWebSceneVersions as ne}from"./webscene/support/versionUtils.js";import{writer as le}from"./core/accessorSupport/decorators/writer.js";import{reader as pe}from"./core/accessorSupport/decorators/reader.js";var ce;const de="Web Scene";let he=class extends(a(h(c(r)))){static{ce=G}constructor(e){super(e),this[ce]=!0,this._layersIdGCTimeoutId=void 0,this._updateFromPromise=null,this._afterLoadHooks=[],this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=void 0,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new ee,this.initialViewProperties=new Y,this.portalItem=null,this.resourceInfo=null,this.widgets=null,this._debouncedSaveOperations=u(async(e,t,r)=>{switch(e){case 0:return this._saveImpl(t);case 1:return this._saveAsImpl(r,t)}}),this._loadContext={origin:"web-scene",initiator:this,hooks:{onAfterLoad:e=>this._afterLoadHooks.push(e)}},this._resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch(e=>{l.getLogger(this).error("#load()","Failed to load web scene",e)}),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this.addHandles(m(()=>this.allLayers,"change",()=>this._scheduleLayersIdGC()))}destroy(){this._unscheduleLayersIdGC(),this.presentation&&this.presentation.destroy(),this.portalItem=p(this.portalItem)}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){t[r]=this._layersToJSON(e,"operational-layers",i)}get loaded(){return super.loaded}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new g(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${re.major}.${re.minor}`}writeTables(e,t,r,i){const o=this._layersToJSON(e,"tables",i);o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl??null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}get ground(){return this._get("ground")}set ground(e){const t=x(e);null!=t&&this._set("ground",t)}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t,r){const{spatialReference:i,timeZone:o,viewingMode:s}=t,a=new Y,n={...t.initialState};return void 0!==i&&(n.spatialReference=i),void 0!==o&&(n.timeZone=o),void 0!==s&&(n.viewingMode=s),a.read(n,r),a}get spatialReference(){return this.initialViewProperties?.spatialReference??P.WebMercator}get timeZone(){return this.initialViewProperties?.timeZone}get viewingMode(){return this.initialViewProperties?.viewingMode??"global"}load(e){const t=this.ground;return this.addResolvingPromise(this._loadFromSource().then(()=>{t&&t!==this.ground&&t.destroy(),this._validateFeatureLayerSymbolVisibility()})),Promise.resolve(this)}loadAll(){return n(this,e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map(e=>e.basemap),this.tables)})}read(e,t){t??=this._loadContext,t.origin="web-scene";const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(A(this,e,t=>super.read(e,t),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&se(this.sourceVersion)){const t=e.baseMap.elevationLayers.map(e=>({id:e.id})),r=this.presentation.slides,i=t.filter(e=>!r.some(t=>t.visibleLayers.some(t=>t.id===e.id)));r.forEach(e=>e.visibleLayers.addMany(i))}}_writeBasemapElevationLayers(e){const t=e.ground?.layers;!e.baseMap&&t?.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=s(t))}_layersToJSON(e,t,r){const i={...r,layerContainerType:t};return e.map(e=>this._verifyWritableLayer(e,r)?e.write({},i):null).filter(e=>!!e).toArray()}_verifyWritableLayer(e,t){return!!e.persistenceEnabled&&("write"in e||(Z(t,e),!1))}write(e,t){if("loaded"!==this.loadStatus){const e=new o("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw l.getLogger(this).error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const r=!t?.messages;t={messages:[],...t,origin:"web-scene"};const i=super.write(e,t);if(r){const e=t.messages?.filter(e=>"web-document-write:property-required"===e.name)??[];if(e.length){const t=new o("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw l.getLogger(this).error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(i),i}async save(e){return this._debouncedSaveOperations(0,e)}async _saveImpl(e){if(!this.portalItem)throw new o("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene");if(this.portalItem?.type!==de)throw new o("webscene:portal-item-wrong-type",`Portal item needs to have type "${de}"`);const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls(E(this.portalItem,"web-scene",{withResources:!0})),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,0,e),this._updateTypeKeywords(this.portalItem),await B(this.portalItem,i,this._resourceReferences,r),S(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(1,t,e)}async _saveAsImpl(e,t){let r=M.from(e);if(!r)throw new o("webscene:portal-item-required","saveAs requires a portal item to save to");r.id&&(r=r.clone(),r.id=null);const i=r.portal||O.getDefault();await this._ensureLoadBeforeSave(),r.type=de,r.portal=i;const s=this._enableVerifyItemRelativeUrls(E(r,"web-scene",{withResources:!0})),a=this.write({},s);await Promise.all(s.resources.pendingOperations),await this._verifySaveAs(a,s,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");this._updateTypeKeywords(r),await i.signIn();const p=this.portalItem,c={item:p,authenticated:!(!p?.id||!p.portal.user)},{copyAllowed:h,itemReloaded:u}=await z(c,i);if(c.authenticated||=u,!h)throw new o(`${s.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const m={...t,copyAllResources:!0},y=await K(r,c,a,m);return y&&(this._resourceReferences.portalItem=r),await $(this._resourceReferences,s,{ignoreResourceCopyErrors:y}),this.portalItem=r,d.prototype.read.call(this,{version:a.version,authoringApp:a.authoringApp,authoringAppVersion:a.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl?w(r.itemUrl):void 0}),S(s),n&&(this.thumbnailUrl=l?f(n,"w","8192"):n),s.portalItem=r,await this._saveThumbnail(p),r}async _saveThumbnail(e){if(this._isOverridden("thumbnailUrl")){const t=await H(this.thumbnailUrl,null,e);await(this.portalItem?.updateThumbnail(t)),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user")}}async _verifySave(e,t,r,i){if(!I(this.spatialReference))throw new o("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently.");const{ignoreUnsupported:s,requiredPropertyChecksDisabled:a,strictSchemaValidationEnabled:n}=i||{};q(t,{errorName:"webscene:save"},{ignoreUnsupported:s,supplementalUnsupportedErrors:["scenemodification:unsupported"],requiredPropertyChecksDisabled:a});const p=oe();if(n&&p){const t=(await p()).validate(e);if(!t.length)return;const i=`webscene did not validate:\n${t.join("\n")}`;l.getLogger(this).error(`${1===r?"saveAs":"save"}(): ${i}`);const s=t.map(e=>new o("webscene:schema-validation",e));throw W(s)}}_verifySaveAs(e,t,r){return this._verifySave(e,t,1,r)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(){return!1}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment&&(this.initialViewProperties.environment=X.prototype.clone.apply(e.environment)),!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,this.initialViewProperties.timeExtent=e.timeExtent?.clone()??null,this.initialViewProperties.timeZone=e.timeZone,this.initialViewProperties.analyses.updateFrom(e),null!=e.clippingArea?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}if(!t.widgetsExcluded)for(const r of e.registeredComponents)r.updateWebDocument(this);(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this.updateThumbnail(e,{size:t.thumbnailSize})}async updateThumbnail(e,t){const r=D(e,t?.size),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}async _loadFromSource(){this.resourceInfo?await this._loadFromJSON(this.resourceInfo):this.portalItem?.id?await this._loadFromItem(this.portalItem):await this._loadObjectsWithLayers(),await this._afterLoad()}async _afterLoad(){for(;this._afterLoadHooks.length;){const e=this._afterLoadHooks.slice();this._afterLoadHooks.length=0,await Promise.allSettled(e.map(e=>e(this._loadContext)))}}_readAndLoadFromJSON(e){const t=this._loadContext,r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r)}_extractOperationalLayers(e){const t=[];if(!ae(this.sourceVersion)&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(ae(this.sourceVersion)||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}async _loadFromJSON(e){const t=new i;await this._validateSpatialReference(),await this._validateHeightModelInfo();const{populateOperationalLayers:r}=await(import("./layers/support/layersCreator.js")),{operationalLayers:o,operationalElevationLayers:s,basemapElevationLayers:a}=this._extractOperationalLayers(e),n=[],l={context:{...this._loadContext,layerContainerType:"operational-layers"}};if(this.portalItem&&(l.context.portal=this.portalItem.portal||O.getDefault()),a.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(r(this.ground.layers,a,e))}if(s.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(r(t,s,e))}o&&o.length>0&&n.push(r(this.layers,o,l)),e.tables?.length&&n.push(r(this.tables,e.tables,{...l,context:{...l.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"})),await Promise.allSettled(n),await this._loadObjectsWithLayers(),this.ground.layers.addMany(t.filter(e=>"base-elevation"===e.type||"elevation"===e.type))}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[],t=[...this.allLayers.items];for(const{basemap:r}of this.presentation.slides.items)r&&(t.push(...r.baseLayers.items),t.push(...r.groundLayers.items),t.push(...r.referenceLayers.items));for(const r of t)if("beforeSave"in r&&"function"==typeof r.beforeSave){const t=r.beforeSave();t&&e.push(t)}await Promise.allSettled(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach(t=>{t.basemap&&e.push(t.basemap.load())}),await Promise.allSettled(e)}async _loadFromItem(e){if(await e.load().catch(e=>{throw new o("webscene:load-portal-item","Failed to load portal item",{error:e})}),"Web Scene"!==e.type)throw new o("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r=this._loadContext;r.url=w(e.itemUrl),r.portal=e.portal||O.getDefault(),r.portalItem=e,r.readResourcePaths=[],await this._readAndLoadFromJSON(t),this._resourceReferences={portalItem:e,paths:r.readResourcePaths??[]}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!J(t,1))return Promise.reject(new o("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||R(e,t)}else{if(!J(t,2))return Promise.reject(new o("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e?.camera?.position.spatialReference??e?.targetGeometry?.spatialReference,s=e.viewpoint,a=i(s);if(a&&!r(a))return Promise.reject(new o("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:a,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find(e=>!r(i(e.viewpoint)));if(n){const r=i(n.viewpoint);return Promise.reject(new o("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=U(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateFeatureLayerSymbolVisibility(){this.sourceVersion?.greaterEqual(1,35)||this.layers.forEach(e=>{"feature"===e.type&&e.addHandles(y(()=>e.loaded,()=>{"on-the-ground"===e.elevationInfo?.mode&&"simple"===e.renderer?.type&&"polygon-3d"===e.renderer.symbol?.type&&e.renderer.symbol.symbolLayers.some(t=>"fill"===t.type&&null!=t.material&&((!t.material.color||t.material.color.a*e.opacity<ie)&&(e.loadWarnings.push(new b("feature-layer:invisible-draped-symbols","FeatureLayer has fully transparent symbols which will no longer render or highlight",{layer:e})),!0)))},{once:!0,sync:!0}))})}_validateJSON(e){const t=g.parse(e.version||"","webscene");return re.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=P.WebMercator.toJSON()),e}_updateTypeKeywords(e){C(e,T.LOCAL_SCENE,"local"===this.initialViewProperties.viewingMode),C(e,T.DEVELOPER_BASEMAP,N(this.basemap)||this.presentation.slides.some(({basemap:e})=>!!e&&N(e))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter((e,t,r)=>r.indexOf(e)===t))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||P.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem?.itemUrl?w(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout(()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()},3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties?.viewing?.search,t=e=>this.allLayers.some(t=>t.id===e&&t.persistenceEnabled);e?.layers&&(e.layers=e.layers.filter(e=>t(e.id)));const r=this.presentation&&this.presentation.slides;r&&r.forEach(e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter(e=>t(e.id)))})}static fromJSON(e){if(!e)throw new o("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}static{this.version=`${re.major}.${re.minor}`}};e([v({type:Q,json:{write:!0}})],he.prototype,"applicationProperties",void 0),e([v({type:j,json:{read:{source:"clippingArea.geometry",reader:V},write:{target:"clippingArea.geometry"}}})],he.prototype,"clippingArea",void 0),e([le("clippingArea")],he.prototype,"writeClippingArea",null),e([v({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],he.prototype,"clippingEnabled",void 0),e([pe("clippingEnabled",["clippingArea"])],he.prototype,"readClippingEnabled",null),e([le("clippingEnabled")],he.prototype,"writeClippingEnabled",null),e([v({type:F,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],he.prototype,"floorInfo",void 0),e([v({type:L,json:{write:!0}})],he.prototype,"heightModelInfo",void 0),e([v({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],he.prototype,"layers",void 0),e([le("layers")],he.prototype,"writeLayers",null),e([v({readOnly:!0,type:g,json:{type:ne(re).map(e=>e.toString()),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],he.prototype,"sourceVersion",void 0),e([pe("sourceVersion",["version"])],he.prototype,"readSourceVersion",null),e([le("sourceVersion")],he.prototype,"writeSourceVersion",null),e([v({json:{read:!1,write:{enabled:!0,ignoreOrigin:!0}}})],he.prototype,"tables",void 0),e([le("tables")],he.prototype,"writeTables",null),e([v()],he.prototype,"thumbnailUrl",null),e([v({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],he.prototype,"authoringApp",null),e([le("authoringApp")],he.prototype,"writeAuthoringApp",null),e([v({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],he.prototype,"authoringAppVersion",null),e([le("authoringAppVersion")],he.prototype,"writeAuthoringAppVersion",null),e([v({json:{write:{isRequired:!0,enabled:!0,overridePolicy:()=>({isRequired:!0,enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],he.prototype,"ground",null),e([le("ground")],he.prototype,"writeGround",null),e([v({type:i.ofType(te),json:{write:!0}})],he.prototype,"transportationNetworks",void 0),e([v({type:ee,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],he.prototype,"presentation",void 0),e([v({type:Y,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new Y({viewingMode:"global",spatialReference:P.WebMercator})}})],he.prototype,"initialViewProperties",void 0),e([pe("initialViewProperties",["initialState","spatialReference","timeZone","viewingMode"])],he.prototype,"readInitialViewProperties",null),e([v({type:P,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],he.prototype,"spatialReference",null),e([v({type:String,json:{read:!1,write:{ignoreOrigin:!0}}})],he.prototype,"timeZone",null),e([v({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],he.prototype,"viewingMode",null),e([v({type:M})],he.prototype,"portalItem",void 0),e([v()],he.prototype,"resourceInfo",void 0),e([v({type:k,json:{write:!0}})],he.prototype,"widgets",void 0),he=e([_("esri.WebScene")],he);const ue=he;export{ue as default};
@@ -17,7 +17,7 @@ export type IntegrateOptions = "defaultBehavior" | "defaultBehaviorOnlyModified"
17
17
  * @internal
18
18
  * @example
19
19
  * // Integrate a set of geometries
20
- * const result = integrateOperator.executeMany(geometries);
20
+ * const result = integrateExecuteMany(geometries);
21
21
  * @internal
22
22
  */
23
23
  export function extendedIntegrate(geometries: GeometryUnion[], options?: IntegrateOptions): {
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{toSymbolId as e,neverAbortedSignal as t}from"./arcadeEnvironment.js";import{ArcadeModule as n}from"./ArcadeModule.js";import{ArcadeModuleLoader as r}from"./ArcadeModuleLoader.js";import{collectDeclaredGlobalNames as o,resolveBreakpoints as a,flattenAccessChain as i,collectDeclaredLocalNames as s}from"./compilerUtils.js";import{getNestedOptionalValue as c,getGeometryKeys as l,tryGetMember as u,getMember as f,getGeometryMember as p}from"./containerUtils.js";import{wrapDebugValue as w,renderFunctionDebugName as d}from"./debug.js";import m from"./Dictionary.js";import{ArcadeExecutionError as h,ensureLocatableError as g}from"./executionError.js";import{Feature as b}from"./Feature.js";import{NativeFunction as y,ScopeMarshalledFunction as v,ArcadeFunction as x,wrapModuleScopedResponse as S}from"./FunctionWrapper.js";import{R as k,I as F,u as I,i as j,C as O,D as N,x as M,E as R,v as C,w as E,y as A,z as D,A as B,h as U,g as _,B as G,k as z,d as L}from"../chunks/languageUtils.js";import{addFunctionDeclaration as Z}from"./treeAnalysis.js";import{A as P}from"../chunks/aiServices.js";import{A as q}from"../chunks/array.js";import{registerFunctions as W}from"./functions/date.js";import{registerFunctions as T}from"./functions/feature.js";import{registerFunctions as V}from"./functions/geomasync.js";import{registerFunctions as K}from"./functions/geometry.js";import{registerFunctions as $}from"./functions/maths.js";import{P as Y}from"../chunks/portal.js";import{registerFunctions as H}from"./functions/stats.js";import{registerFunctions as J}from"./functions/string.js";import{registerFunctions as Q}from"./functions/track.js";import X from"../core/Logger.js";import ee from"../geometry/SpatialReference.js";import{isGraphic as te}from"../support/graphicInstanceUtils.js";import{isBoolean as ne,isString as re,isArray as oe,isNumber as ae}from"../support/guards.js";const ie=()=>X.getLogger("esri.arcade.arcadeAsyncRuntime"),se=Symbol("debugInfo"),ce=Symbol("uninitialized");function le(e){if(e===ce)throw new h("InvalidIdentifier",null)}function ue(e){return le(e),e}function fe(t,n){const r=e(n);if(null!==t.localScope){const e=t.localScope[r];if(void 0!==e)return{scope:t.localScope,id:r,var:e}}const o=t.globalScope[r];if(void 0!==o)return{scope:t.globalScope,id:r,var:o};throw new h("InvalidIdentifier",n)}function pe(t,n,r="InvalidIdentifier"){const o=e(n);if(null!==t.localScope){const e=t.localScope[o];if(void 0!==e)return le(e),e.value}const a=t.globalScope[o];if(void 0!==a)return le(a),a.value;throw new h(r,n)}const we=function(){};async function de(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(await ke(e,t.arguments[r]));return n}async function me(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await de(e,t))}we.prototype=Object.freeze(Object.create(null));class he extends x{constructor(e,t,n,r,o){super(),this.definition=e,this.context=t,this._params=n,this._locals=r,this._debugInfo=o}get debugName(){return this.definition.id.name}createFunction(e){return(...t)=>{const n=new we;n[se]=this._debugInfo;const r={spatialReference:this.context.spatialReference,console:this.context.console,lrucache:this.context.lrucache,timeZone:this.context.timeZone??null,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,services:this.context.services,abortSignal:this.context.abortSignal,localScope:n,depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope,contextScopeDebugInfo:this.context.contextScopeDebugInfo,track:this.context.track};if(r.depthCounter.depth>64)throw new h("MaximumCallDepth",null);return ge(r,this.definition.body,this._params,this._locals,t,null)}}call(e,t){return ye(e,t,(n,r,o)=>{const a=new we;a[se]=this._debugInfo;const i={spatialReference:e.spatialReference,services:e.services,console:e.console,libraryResolver:e.libraryResolver,exports:e.exports,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:a,abortSignal:e.abortSignal,globalScope:e.globalScope,contextScopeDebugInfo:e.contextScopeDebugInfo,depthCounter:{depth:e.depthCounter.depth+1},track:e.track};if(i.depthCounter.depth>64)throw new h("MaximumCallDepth",t);return ge(i,this.definition.body,this._params,this._locals,o,t)})}marshalledCall(e,t,n,r){return r(e,t,async(o,a,i)=>{const s=new we;s[se]=this._debugInfo;const c={spatialReference:e.spatialReference,services:e.services,globalScope:n.globalScope,contextScopeDebugInfo:n.contextScopeDebugInfo,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,abortSignal:e.abortSignal,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:s,track:e.track};return i=i.map(t=>!j(t)||t instanceof v?t:S(t,e,r)),S(await ge(c,this.definition.body,this._params,this._locals,i,t),n,r)})}}async function ge(e,t,n,r,o,a){if(n.length!==o.length)throw new h("WrongNumberOfParameters",a);if(null!=e.localScope){for(let t=0;t<n.length;t++)e.localScope[n[t]]={value:o[t]};for(const t of r)e.localScope[t]=ce}const i=await Fe(e,t);if(i instanceof k)return i.value;if(i===O)throw new h("UnexpectedToken",a);if(i===N)throw new h("UnexpectedToken",a);return i instanceof F?i.value:i}class be extends n{constructor(e){super(),this.moduleGlobalContext=e}global(t){const n=e(t);if(!this.moduleGlobalContext.exports.has(n))throw new h("ModuleExportNotFound",null);const r=this.moduleGlobalContext.globalScope[n];if(le(r),j(r.value)&&!(r.value instanceof v)){const e=new v;return e.fn=r.value,e.parameterEvaluator=me,e.context=this.moduleGlobalContext,this.moduleGlobalContext.globalScope[n]={value:e},e}return r.value}setGlobal(t,n){if(j(n))throw new h("AssignModuleFunction",null);const r=e(t);if(!this.moduleGlobalContext.exports.has(r))throw new h("ModuleExportNotFound",null);this.moduleGlobalContext.globalScope[r]={value:n}}hasGlobal(t){return this.moduleGlobalContext.exports.has(e(t))}static async load(e,n){const{globals:a,exports:i}=o(n),s=new dt;null!=e.contextScopeDebugInfo&&(s[se]={declaredNames:a});for(const t of a.keys())t in s||(s[t]=ce);const c=e.spatialReference??ee.WebMercator,l={lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??ht,abortSignal:e.abortSignal??t,timeZone:e.timeZone??null,spatialReference:c,track:null,depthCounter:{depth:1},libraryResolver:new r(e.libraryResolver._moduleSingletons,n.loadedModules),exports:i,localScope:null,globalScope:s,contextScopeDebugInfo:null!=e.contextScopeDebugInfo?{declaredNames:new Map}:null};return await Le(l,n),new be(l)}}async function ye(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await de(e,t))}function ve(e,t,n){const r=new Map;if(t)for(const[o,a]of t.declaredNames){const t=e[o];r.set(a,null==t||t===ce?null:w(t.value,n))}else for(const o of Object.getOwnPropertyNames(e)){const t=e[o];r.set(o,t===ce?null:w(t.value,n))}return r}function xe(e){return e instanceof he?`ƒ ${e.debugName}(${e.definition.params.map(e=>e.name).join(", ")})`:d(e)}function Se(e,t){const n=e.services?.debugger;if(null==n)return;const r={renderFunction:xe,defaultTimeZone:e.timeZone??"system"};return n.pause(t,{profile:null!=e.contextScopeDebugInfo?ve(e.globalScope,e.contextScopeDebugInfo,r):new Map,globals:ve(e.globalScope,e.globalScope[se],r),locals:null==e.localScope?null:ve(e.localScope,e.localScope[se],r)})}async function ke(e,t){t.breakpoint&&await Se(e,t.breakpoint);try{switch(t.type){case"UpdateExpression":return await Be(e,t);case"AssignmentExpression":return await _e(e,t);case"TemplateLiteral":return await it(e,t);case"Identifier":return rt(e,t);case"MemberExpression":return await $e(e,t);case"Literal":return t.value;case"CallExpression":return await ot(e,t);case"UnaryExpression":return await Xe(e,t);case"BinaryExpression":return await tt(e,t);case"LogicalExpression":return await nt(e,t);case"ArrayExpression":return await et(e,t);case"ObjectExpression":return await Ie(e,t);case"MemberAccessChainExpression":return await Qe(e,t);case"SafeMemberExpression":throw ie().error("SafeMemberExpression outside of MemberAccessChainExpression"),new h("Unrecognized",t);default:throw new h("Unrecognized",t)}}catch(n){throw g(n,t)}}async function Fe(e,t){t.breakpoint&&await Se(e,t.breakpoint);try{switch(t.type){case"ImportDeclaration":return await We(e,t);case"ExportNamedDeclaration":return await Te(e,t);case"VariableDeclaration":return await Ve(e,t);case"BlockStatement":return await Le(e,t);case"FunctionDeclaration":return await qe(e,t);case"ReturnStatement":return await Pe(e,t);case"IfStatement":return await ze(e,t);case"ExpressionStatement":return await Ge(e,t);case"ForStatement":return await Oe(e,t);case"WhileStatement":return await je(e,t);case"ForInStatement":return await Ae(e,t);case"ForOfStatement":return await De(e,t);case"BreakStatement":return O;case"EmptyStatement":return M;case"ContinueStatement":return N;default:throw new h("Unrecognized",t)}}catch(n){throw g(n,t)}}async function Ie(e,t){const n=[];for(let i=0;i<t.properties.length;i++){const r=t.properties[i],o=await ke(e,r.value),a="Identifier"===r.key.type?r.key.name:await ke(e,r.key);n[i]={key:a,value:o}}const r=Object.create(null),o=new Map;for(let i=0;i<n.length;i++){const e=n[i];if(j(e.value))throw new h("NoFunctionInDictionary",t);if(!1===re(e.key))throw new h("KeyMustBeString",t);let a=e.key.toString();const s=a.toLowerCase();o.has(s)?a=o.get(s):o.set(s,a),e.value===M?r[a]=null:r[a]=e.value}const a=new m(r);return a.immutable=!1,a}async function je(e,t){let n=await ke(e,t.test);if(!1===n)return M;if(!0!==n)throw new h("BooleanConditionRequired",t);for(;!0===n;){const r=await Fe(e,t.body);if(r===O)break;if(r instanceof k)return r;if(n=await ke(e,t.test),!0!==n&&!1!==n)throw new h("BooleanConditionRequired",t)}return M}async function Oe(e,t){try{for(null!==t.init&&("VariableDeclaration"===t.init.type?await Fe(e,t.init):await ke(e,t.init));;){if(null!==t.test){const n=await ke(e,t.test);if(!0===e.abortSignal?.aborted)throw new h("Cancelled",t);if(!1===n)break;if(!0!==n)throw new h("BooleanConditionRequired",t)}const n=await Fe(e,t.body);if(n===O)break;if(n instanceof k)return n;null!==t.update&&await ke(e,t.update)}return M}catch(n){throw n}}async function Ne(e,t,n,r,o="i"){const a=n.length;for(let i=0;i<a;i++){if("k"===o){if(i>=n.length)throw new h("OutOfBounds",t);r.scope[r.id]={value:n[i]}}else r.scope[r.id]={value:i};const a=await Fe(e,t.body);if(a===O)break;if(a instanceof k)return a}return M}async function Me(e,t,n,r,o="i"){const a=n.length();for(let i=0;i<a;i++){r.scope[r.id]="k"===o?{value:n.get(i)}:{value:i};const a=await Fe(e,t.body);if(a===O)break;if(a instanceof k)return a}return M}async function Re(e,t,n,r){e:for await(const o of await n.queryAll(e.abortSignal))for(const a of o){r.scope[r.id]={value:b.createFromGraphicLikeObject(a.geometry,a.attributes,n,e.timeZone)};const o=await Fe(e,t.body);if(o===O)break e;if(o instanceof k)return o}return M}async function Ce(e,t,n,r){for(const o of n.keys()){const a=n.field(o);r.scope[r.id]={value:m.containerEntry(o,a)};const i=await Fe(e,t.body);if(i===O)break;if(i instanceof k)return i}return M}async function Ee(e,t,n,r){for(const o of l(n)){const a=p(n,o);r.scope[r.id]={value:m.containerEntry(o,a)};const i=await Fe(e,t.body);if(i===O)break;if(i instanceof k)return i}return M}async function Ae(e,t){const n=await ke(e,t.right);"VariableDeclaration"===t.left.type&&await Fe(e,t.left);const r=fe(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);return oe(n)||re(n)?await Ne(e,t,n,r):_(n)?await Me(e,t,n,r):n instanceof m||G(n)?await Ne(e,t,n.keys(),r,"k"):z(n)?await Re(e,t,n,r):L(n)?await Ne(e,t,l(n),r,"k"):M}async function De(e,t){const n=await ke(e,t.right);"VariableDeclaration"===t.left.type&&await Fe(e,t.left);const r=fe(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);return oe(n)||re(n)?await Ne(e,t,n,r,"k"):_(n)?await Me(e,t,n,r,"k"):n instanceof m||G(n)?await Ce(e,t,n,r):z(n)?await Re(e,t,n,r):L(n)?await Ee(e,t,n,r):M}async function Be(e,t){const n=t.argument;if("CallExpression"===n.type)throw new h("NeverReach",t);if("MemberExpression"===n.type){const r=await ke(e,n.object);let o,a;if(!0===n.computed)o=await ke(e,n.property);else{if("Identifier"!==n.property.type)throw new h("Unrecognized",t);o=n.property.name}if(oe(r)){if(!ae(o))throw new h("ArrayAccessMustBeNumber",t);if(o<0&&(o=r.length+o),o<0||o>=r.length)throw new h("OutOfBounds",t);a=C(r[o]),r[o]="++"===t.operator?a+1:a-1}else if(r instanceof m){if(!1===re(o))throw new h("KeyAccessorMustBeString",t);if(!0!==r.hasField(o))throw new h("FieldNotFound",t,{key:o});a=C(r.field(o)),r.setField(o,"++"===t.operator?a+1:a-1)}else if(r instanceof be){if(!1===re(o))throw new h("ModuleAccessorMustBeString",t);if(!0!==r.hasGlobal(o))throw new h("ModuleExportNotFound",t);a=C(r.global(o)),r.setGlobal(o,"++"===t.operator?a+1:a-1)}else{if(!U(r))throw _(r)?new h("Immutable",t):new h("InvalidParameter",t);if(!1===re(o))throw new h("KeyAccessorMustBeString",t);if(!0!==r.hasField(o))throw new h("FieldNotFound",t,{key:o});a=C(r.field(o)),r.setField(o,"++"===t.operator?a+1:a-1)}return!1===t.prefix?a:"++"===t.operator?a+1:a-1}const r=fe(e,n),o=C(ue(r.var).value),a="++"===t.operator?o+1:o-1;return r.scope[r.id]={value:a},!1===t.prefix?o:"++"===t.operator?o+1:o-1}function Ue(e,t,n,r){switch(t){case"=":return e===M?null:e;case"/=":return C(n)/C(e);case"*=":return C(n)*C(e);case"-=":return C(n)-C(e);case"+=":return re(n)||re(e)?E(n)+E(e):C(n)+C(e);case"%=":return C(n)%C(e);default:throw new h("UnsupportedOperator",r)}}async function _e(e,t){const n=t.left;if("MemberExpression"===n.type){const r=await ke(e,n.object);let o;if(!0===n.computed)o=await ke(e,n.property);else{if("Identifier"!==n.property.type)throw new h("InvalidIdentifier",t);o=n.property.name}const a=await ke(e,t.right);if(oe(r)){if(!ae(o))throw new h("ArrayAccessMustBeNumber",t);if(o<0&&(o=r.length+o),o<0||o>r.length)throw new h("OutOfBounds",t);if(o===r.length){if("="!==t.operator)throw new h("OutOfBounds",t);r[o]=Ue(a,t.operator,r[o],t)}else r[o]=Ue(a,t.operator,r[o],t)}else if(r instanceof m){if(!1===re(o))throw new h("KeyAccessorMustBeString",t);if(!0===r.hasField(o))r.setField(o,Ue(a,t.operator,r.field(o),t));else{if("="!==t.operator)throw new h("FieldNotFound",t,{key:o});r.setField(o,Ue(a,t.operator,null,t))}}else if(r instanceof be){if(!1===re(o))throw new h("KeyAccessorMustBeString",t);if(!0!==r.hasGlobal(o))throw new h("ModuleExportNotFound",t);r.setGlobal(o,Ue(a,t.operator,r.global(o),t))}else{if(!U(r))throw _(r)?new h("Immutable",t):new h("InvalidParameter",t);if(!1===re(o))throw new h("KeyAccessorMustBeString",t);if(!0===r.hasField(o))r.setField(o,Ue(a,t.operator,r.field(o),t));else{if("="!==t.operator)throw new h("FieldNotFound",t,{key:o});r.setField(o,Ue(a,t.operator,null,t))}}return M}const r=fe(e,n),o=await ke(e,t.right);return r.scope[r.id]={value:Ue(o,t.operator,"="!==t.operator?ue(r.var).value:null,t)},M}async function Ge(e,t){const n=await ke(e,t.expression);return n===M?M:new F(n)}async function ze(e,t){const n=await ke(e,t.test);if(!0===n)return Fe(e,t.consequent);if(!1===n)return null!==t.alternate?Fe(e,t.alternate):M;throw new h("BooleanConditionRequired",t)}async function Le(e,t){return Ze(e,t,0)}async function Ze(e,t,n){if(n>=t.body.length)return M;const r=await Fe(e,t.body[n]);return r instanceof k||r===O||r===N||n===t.body.length-1?r:Ze(e,t,n+1)}async function Pe(e,t){if(null===t.argument)return new k(M);const n=await ke(e,t.argument);return new k(n)}async function qe(t,n){if(null!=t.localScope)throw ie().error("Function declarations are only valid in global scope."),new h("NeverReach",n);const r=e(n.id);if(!(r in t.globalScope))throw ie().error(`Function "${r}" not declared.`),new h("NeverReach",n);const o=s(n),a=n.params.map(t=>e(t)),i=Array.from(o.keys()).filter(e=>!a.includes(e));let c=null;return null!=t.contextScopeDebugInfo&&(c={declaredNames:new Map([...n.params.map(t=>[e(t),t.name]),...o])}),t.globalScope[r]={value:new he(n,t,a,i,c)},M}async function We(e,t){const n=fe(e,t.specifiers[0].local),r=e.libraryResolver;if(null==r)throw ie().error("Internal error: module loader not initialized"),new h("NeverReach",t);const o=r.loadLibrary(n.id);let a;return r._moduleSingletons?.has(o.uri)?a=r._moduleSingletons.get(o.uri):(a=await be.load(e,o.syntax),r._moduleSingletons?.set(o.uri,a)),n.scope[n.id]={value:a},M}async function Te(e,t){return await Fe(e,t.declaration),M}async function Ve(e,t){for(const n of t.declarations)await Ke(e,n);return M}async function Ke(e,t){t.breakpoint&&await Se(e,t.breakpoint);let n=null;n=null===t.init?null:await ke(e,t.init),n===M&&(n=null);const r=fe(e,t.id);r.scope[r.id]={value:n}}async function $e(e,t){return Ye(e,await ke(e,t.object),t)}async function Ye(e,t,n){const r=n.computed?await ke(e,n.property):n.property.name;return f(t,r)}async function He(e,t,n){for(const r of n)switch(r.type){case"MemberExpression":t=await Ye(e,t,r);break;case"CallExpression":t=await at(e,t,r);break;default:throw new h("Unrecognized",r)}return t}async function Je(e,t,n){const r=n.computed?await ke(e,n.property):n.property.name;return u(t,r)}async function Qe(e,t){const n=i(t);let r=await ke(e,n.root);for(const o of n.sections){const t=await Je(e,r,o.checked);if(null==t)return null;r=await He(e,t,o.unchecked)}return r}async function Xe(e,t){const n=await ke(e,t.argument);if(ne(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*C(n);if("+"===t.operator)return 1*C(n);if("~"===t.operator)return~C(n);throw new h("UnsupportUnaryOperator",t)}if("-"===t.operator)return-1*C(n);if("+"===t.operator)return 1*C(n);if("~"===t.operator)return~C(n);throw new h("UnsupportUnaryOperator",t)}async function et(e,t){const n=[];for(let r=0;r<t.elements.length;r++)n.push(await ke(e,t.elements[r]));for(let r=0;r<n.length;r++){if(j(n[r]))throw new h("NoFunctionInArray",t);n[r]===M&&(n[r]=null)}return n}async function tt(e,t){const n=await ke(e,t.left),r=await ke(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return B(C(n),C(r),t.operator);case"==":return D(n,r);case"!=":return!D(n,r);case"<":case">":case"<=":case">=":return A(n,r,t.operator);case"+":return re(n)||re(r)?E(n)+E(r):C(n)+C(r);case"-":return C(n)-C(r);case"*":return C(n)*C(r);case"/":return C(n)/C(r);case"%":return C(n)%C(r);default:throw t.operator,new h("UnsupportedOperator",t)}}async function nt(e,t){const n=await ke(e,t.left);if(!ne(n))throw new h("LogicalExpressionOnlyBoolean",t);switch(t.operator){case"||":{if(!0===n)return n;const r=await ke(e,t.right);if(ne(r))return r;throw new h("LogicExpressionOrAnd",t)}case"&&":{if(!1===n)return n;const r=await ke(e,t.right);if(ne(r))return r;throw new h("LogicExpressionOrAnd",t)}default:throw t.operator,new h("LogicExpressionOrAnd",t)}}function rt(e,t){return pe(e,t)}async function ot(e,t){let n;if("Identifier"===t.callee.type){const r=t.callee;r.breakpoint&&await Se(e,r.breakpoint),n=pe(e,t.callee,"FunctionNotFound")}else n=await ke(e,t.callee);return at(e,n,t)}async function at(e,t,n){if(j(t))return t.call(e,n);throw new h("CallNonFunction",n)}async function it(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){if(t.expressions[r]){const o=await ke(e,t.expressions[r]);if(j(o))throw new h("NoFunctionInTemplateLiteral",t);n+=E(o)}r++}return n}async function st(e,t){R(null===t.arguments?[]:t.arguments,3,3,t);const n=await ke(e,t.arguments[0]);if(!1===ne(n))throw new h("BooleanConditionRequired",t);return ke(e,n?t.arguments[1]:t.arguments[2])}async function ct(e,t){R(null===t.arguments?[]:t.arguments,2,3,t);const n=await ke(e,t.arguments[0]);if(3===t.arguments.length){const r=await ke(e,t.arguments[1]),o=c(n,r);return null!=o&&""!==o?o:ke(e,t.arguments[2])}return null==n||""===n?ke(e,t.arguments[1]):n}async function lt(e,t){if(t.arguments.length<2)throw new h("WrongNumberOfParameters",t);if(2===t.arguments.length)return ke(e,t.arguments[1]);if((t.arguments.length-1)%2==0)throw new h("WrongNumberOfParameters",t);return ut(e,t,1,await ke(e,t.arguments[0]))}async function ut(e,t,n,r){const o=await ke(e,t.arguments[n]);if(D(o,r))return ke(e,t.arguments[n+1]);const a=t.arguments.length-n;return 1===a?ke(e,t.arguments[n]):2===a?null:3===a?ke(e,t.arguments[n+2]):ut(e,t,n+2,r)}async function ft(e,t){if(t.arguments.length<3)throw new h("WrongNumberOfParameters",t);if(t.arguments.length%2==0)throw new h("WrongNumberOfParameters",t);const n=await ke(e,t.arguments[0]);if(!1===ne(n))throw new h("BooleanConditionRequired",t.arguments[0]);return pt(e,t,0,n)}async function pt(e,t,n,r){if(!0===r)return ke(e,t.arguments[n+1]);if(3===t.arguments.length-n)return ke(e,t.arguments[n+2]);const o=await ke(e,t.arguments[n+2]);if(!1===ne(o))throw new h("ModuleExportNotFound",t.arguments[n+2]);return pt(e,t,n+2,o)}function wt(){const e=Object.create(null);W(e,me),J(e,me),T(e,me,rt),$(e,me),K(e,me),H(e,me),Q(e,me),V({functions:e,compiled:!1,signatures:null,evaluateIdentifier:null,mode:"async",standardFunction:me,standardFunctionAsync:ye}),e.iif=st,e.defaultvalue=ct,e.decode=lt,e.when=ft;const t=function(){this.textformatting={value:m.textFormatting()}};t.prototype=Object.create(null),t.prototype.infinity=Object.freeze({value:Number.POSITIVE_INFINITY}),t.prototype.nan=Object.freeze({value:Number.NaN}),t.prototype.pi=Object.freeze({value:Math.PI});for(const[n,r]of Object.entries(e))t.prototype[n]=Object.freeze({value:new y(r,n)});return t}const dt=wt();function mt(e){const t={mode:"async",compiled:!1,functions:Object.create(null),signatures:[],standardFunction:me,standardFunctionAsync:ye,evaluateIdentifier:rt};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const[n,r]of Object.entries(t.functions))dt.prototype[n]=Object.freeze({value:new y(r,n)});for(let n=0;n<t.signatures.length;n++)Z(t.signatures[n],"async")}function ht(e){console.log(e)}function gt(n,i){const s=new Set(Object.keys(i?.vars||{}).map(t=>e(t))),c=new Set(Object.keys(i?.customfunctions||{}).map(t=>e(t))),{globals:l,exports:u}=o(n);let f=null;if(i?.breakpoints){for(const[e,t]of a(i.breakpoints,n))e.breakpoint=t;f={declaredNames:new Map(Object.keys(i?.vars||{}).map(t=>[e(t),t]).filter(([e])=>!l.has(e)))}}return async e=>{const o=e.spatialReference??ee.WebMercator;let a=null;n.usesModules&&(a=new r(new Map,n.loadedModules));const i=new dt;null!=f&&(i[se]={declaredNames:l});for(const t of c)null!=e.customfunctions&&t in e.customfunctions?i[t]={value:new y(e.customfunctions[t],t)}:i[t]=ce;for(const t of s){if(null==e.vars||!(t in e.vars)){t in i||(i[t]=ce);continue}const n=e.vars[t]??null;te(n)?i[t]={value:b.createFromGraphic(n,e.timeZone??null)}:i[t]={value:n}}for(const t of l.keys())t in i||(i[t]=ce);const p={lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??ht,abortSignal:e.abortSignal??t,timeZone:e.timeZone??null,spatialReference:o,track:e.track,depthCounter:{depth:1},libraryResolver:a,exports:u,localScope:null,globalScope:i,contextScopeDebugInfo:f},w=await Le(p,n);if(w instanceof k||w instanceof F){const e=w.value;if(I(e))return null;if(j(e))throw new h("IllegalResult",null);return e}if(I(w))return null;if(w===O)throw new h("IllegalResult",null);if(w===N)throw new h("IllegalResult",null);throw new h("NeverReach",null)}}function bt(e,t){return gt(e,t)(t)}mt([q]),mt([P]),mt([Y]);export{bt as executeScript,mt as extend,gt as prepareScript};
2
+ import{toSymbolId as e,neverAbortedSignal as t}from"./arcadeEnvironment.js";import{ArcadeModule as n}from"./ArcadeModule.js";import{ArcadeModuleLoader as r}from"./ArcadeModuleLoader.js";import{collectDeclaredGlobalNames as o,resolveBreakpoints as a,flattenAccessChain as i,collectDeclaredLocalNames as s}from"./compilerUtils.js";import{getNestedOptionalValue as c,updateMember as l,getGeometryKeys as u,tryGetMember as f,getMember as p,getGeometryMember as w}from"./containerUtils.js";import{wrapDebugValue as d,renderFunctionDebugName as m}from"./debug.js";import h from"./Dictionary.js";import{ArcadeExecutionError as g,ensureLocatableError as b}from"./executionError.js";import{Feature as y}from"./Feature.js";import{NativeFunction as v,ScopeMarshalledFunction as x,ArcadeFunction as S,wrapModuleScopedResponse as k}from"./FunctionWrapper.js";import{R as I,I as j,u as F,i as O,C as N,D as R,x as C,E,v as M,w as D,y as A,z as B,A as U,h as _,g as z,B as G,k as L,d as Z}from"../chunks/languageUtils.js";import{addFunctionDeclaration as P}from"./treeAnalysis.js";import{A as q}from"../chunks/aiServices.js";import{A as W}from"../chunks/array.js";import{registerFunctions as T}from"./functions/date.js";import{registerFunctions as V}from"./functions/feature.js";import{registerFunctions as K}from"./functions/geomasync.js";import{registerFunctions as $}from"./functions/geometry.js";import{registerFunctions as Y}from"./functions/maths.js";import{P as H}from"../chunks/portal.js";import{registerFunctions as J}from"./functions/stats.js";import{registerFunctions as Q}from"./functions/string.js";import{registerFunctions as X}from"./functions/track.js";import ee from"../core/Logger.js";import te from"../geometry/SpatialReference.js";import{isGraphic as ne}from"../support/graphicInstanceUtils.js";import{isBoolean as re,isString as oe,isArray as ae,isNumber as ie}from"../support/guards.js";const se=()=>ee.getLogger("esri.arcade.arcadeAsyncRuntime"),ce=Symbol("debugInfo"),le=Symbol("uninitialized");function ue(e){if(e===le)throw new g("InvalidIdentifier",null)}function fe(e){return ue(e),e}function pe(t,n){const r=e(n);if(null!==t.localScope){const e=t.localScope[r];if(void 0!==e)return{scope:t.localScope,id:r,var:e}}const o=t.globalScope[r];if(void 0!==o)return{scope:t.globalScope,id:r,var:o};throw new g("InvalidIdentifier",n)}function we(t,n,r="InvalidIdentifier"){const o=e(n);if(null!==t.localScope){const e=t.localScope[o];if(void 0!==e)return ue(e),e.value}const a=t.globalScope[o];if(void 0!==a)return ue(a),a.value;throw new g(r,n)}const de=function(){};async function me(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(await Ie(e,t.arguments[r]));return n}async function he(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await me(e,t))}de.prototype=Object.freeze(Object.create(null));class ge extends S{constructor(e,t,n,r,o){super(),this.definition=e,this.context=t,this._params=n,this._locals=r,this._debugInfo=o}get debugName(){return this.definition.id.name}createFunction(e){return(...t)=>{const n=new de;n[ce]=this._debugInfo;const r={spatialReference:this.context.spatialReference,console:this.context.console,lrucache:this.context.lrucache,timeZone:this.context.timeZone??null,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,services:this.context.services,abortSignal:this.context.abortSignal,localScope:n,depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope,contextScopeDebugInfo:this.context.contextScopeDebugInfo,track:this.context.track};if(r.depthCounter.depth>64)throw new g("MaximumCallDepth",null);return be(r,this.definition.body,this._params,this._locals,t,null)}}call(e,t){return ve(e,t,(n,r,o)=>{const a=new de;a[ce]=this._debugInfo;const i={spatialReference:e.spatialReference,services:e.services,console:e.console,libraryResolver:e.libraryResolver,exports:e.exports,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:a,abortSignal:e.abortSignal,globalScope:e.globalScope,contextScopeDebugInfo:e.contextScopeDebugInfo,depthCounter:{depth:e.depthCounter.depth+1},track:e.track};if(i.depthCounter.depth>64)throw new g("MaximumCallDepth",t);return be(i,this.definition.body,this._params,this._locals,o,t)})}marshalledCall(e,t,n,r){return r(e,t,async(o,a,i)=>{const s=new de;s[ce]=this._debugInfo;const c={spatialReference:e.spatialReference,services:e.services,globalScope:n.globalScope,contextScopeDebugInfo:n.contextScopeDebugInfo,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,abortSignal:e.abortSignal,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:s,track:e.track};return i=i.map(t=>!O(t)||t instanceof x?t:k(t,e,r)),k(await be(c,this.definition.body,this._params,this._locals,i,t),n,r)})}}async function be(e,t,n,r,o,a){if(n.length!==o.length)throw new g("WrongNumberOfParameters",a);if(null!=e.localScope){for(let t=0;t<n.length;t++)e.localScope[n[t]]={value:o[t]};for(const t of r)e.localScope[t]=le}const i=await je(e,t);if(i instanceof I)return i.value;if(i===N)throw new g("UnexpectedToken",a);if(i===R)throw new g("UnexpectedToken",a);return i instanceof j?i.value:i}class ye extends n{constructor(e){super(),this.moduleGlobalContext=e}global(t){const n=e(t);if(!this.moduleGlobalContext.exports.has(n))throw new g("ModuleExportNotFound",null);const r=this.moduleGlobalContext.globalScope[n];if(ue(r),O(r.value)&&!(r.value instanceof x)){const e=new x;return e.fn=r.value,e.parameterEvaluator=he,e.context=this.moduleGlobalContext,this.moduleGlobalContext.globalScope[n]={value:e},e}return r.value}setGlobal(t,n){if(O(n))throw new g("AssignModuleFunction",null);const r=e(t);if(!this.moduleGlobalContext.exports.has(r))throw new g("ModuleExportNotFound",null);this.moduleGlobalContext.globalScope[r]={value:n}}hasGlobal(t){return this.moduleGlobalContext.exports.has(e(t))}static async load(e,n){const{globals:a,exports:i}=o(n),s=new mt;null!=e.contextScopeDebugInfo&&(s[ce]={declaredNames:a});for(const t of a.keys())t in s||(s[t]=le);const c=e.spatialReference??te.WebMercator,l={lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??gt,abortSignal:e.abortSignal??t,timeZone:e.timeZone??null,spatialReference:c,track:null,depthCounter:{depth:1},libraryResolver:new r(e.libraryResolver._moduleSingletons,n.loadedModules),exports:i,localScope:null,globalScope:s,contextScopeDebugInfo:null!=e.contextScopeDebugInfo?{declaredNames:new Map}:null};return await Ze(l,n),new ye(l)}}async function ve(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await me(e,t))}function xe(e,t,n){const r=new Map;if(t)for(const[o,a]of t.declaredNames){const t=e[o];r.set(a,null==t||t===le?null:d(t.value,n))}else for(const o of Object.getOwnPropertyNames(e)){const t=e[o];r.set(o,t===le?null:d(t.value,n))}return r}function Se(e){return e instanceof ge?`ƒ ${e.debugName}(${e.definition.params.map(e=>e.name).join(", ")})`:m(e)}function ke(e,t){const n=e.services?.debugger;if(null==n)return;const r={renderFunction:Se,defaultTimeZone:e.timeZone??"system"};return n.pause(t,{profile:null!=e.contextScopeDebugInfo?xe(e.globalScope,e.contextScopeDebugInfo,r):new Map,globals:xe(e.globalScope,e.globalScope[ce],r),locals:null==e.localScope?null:xe(e.localScope,e.localScope[ce],r)})}async function Ie(e,t){t.breakpoint&&await ke(e,t.breakpoint);try{switch(t.type){case"UpdateExpression":return await Ue(e,t);case"AssignmentExpression":return await ze(e,t);case"TemplateLiteral":return await st(e,t);case"Identifier":return ot(e,t);case"MemberExpression":return await Ye(e,t);case"Literal":return t.value;case"CallExpression":return await at(e,t);case"UnaryExpression":return await et(e,t);case"BinaryExpression":return await nt(e,t);case"LogicalExpression":return await rt(e,t);case"ArrayExpression":return await tt(e,t);case"ObjectExpression":return await Fe(e,t);case"MemberAccessChainExpression":return await Xe(e,t);case"SafeMemberExpression":throw se().error("SafeMemberExpression outside of MemberAccessChainExpression"),new g("Unrecognized",t);default:throw new g("Unrecognized",t)}}catch(n){throw b(n,t)}}async function je(e,t){t.breakpoint&&await ke(e,t.breakpoint);try{switch(t.type){case"ImportDeclaration":return await Te(e,t);case"ExportNamedDeclaration":return await Ve(e,t);case"VariableDeclaration":return await Ke(e,t);case"BlockStatement":return await Ze(e,t);case"FunctionDeclaration":return await We(e,t);case"ReturnStatement":return await qe(e,t);case"IfStatement":return await Le(e,t);case"ExpressionStatement":return await Ge(e,t);case"ForStatement":return await Ne(e,t);case"WhileStatement":return await Oe(e,t);case"ForInStatement":return await Ae(e,t);case"ForOfStatement":return await Be(e,t);case"BreakStatement":return N;case"EmptyStatement":return C;case"ContinueStatement":return R;default:throw new g("Unrecognized",t)}}catch(n){throw b(n,t)}}async function Fe(e,t){const n=[];for(let i=0;i<t.properties.length;i++){const r=t.properties[i],o=await Ie(e,r.value),a="Identifier"===r.key.type?r.key.name:await Ie(e,r.key);n[i]={key:a,value:o}}const r=Object.create(null),o=new Map;for(let i=0;i<n.length;i++){const e=n[i];if(O(e.value))throw new g("NoFunctionInDictionary",t);if(!1===oe(e.key))throw new g("KeyMustBeString",t);let a=e.key.toString();const s=a.toLowerCase();o.has(s)?a=o.get(s):o.set(s,a),e.value===C?r[a]=null:r[a]=e.value}const a=new h(r);return a.immutable=!1,a}async function Oe(e,t){let n=await Ie(e,t.test);if(!1===n)return C;if(!0!==n)throw new g("BooleanConditionRequired",t);for(;!0===n;){const r=await je(e,t.body);if(r===N)break;if(r instanceof I)return r;if(n=await Ie(e,t.test),!0!==n&&!1!==n)throw new g("BooleanConditionRequired",t)}return C}async function Ne(e,t){try{for(null!==t.init&&("VariableDeclaration"===t.init.type?await je(e,t.init):await Ie(e,t.init));;){if(null!==t.test){const n=await Ie(e,t.test);if(!0===e.abortSignal?.aborted)throw new g("Cancelled",t);if(!1===n)break;if(!0!==n)throw new g("BooleanConditionRequired",t)}const n=await je(e,t.body);if(n===N)break;if(n instanceof I)return n;null!==t.update&&await Ie(e,t.update)}return C}catch(n){throw n}}async function Re(e,t,n,r,o="i"){const a=n.length;for(let i=0;i<a;i++){if("k"===o){if(i>=n.length)throw new g("OutOfBounds",t);r.scope[r.id]={value:n[i]}}else r.scope[r.id]={value:i};const a=await je(e,t.body);if(a===N)break;if(a instanceof I)return a}return C}async function Ce(e,t,n,r,o="i"){const a=n.length();for(let i=0;i<a;i++){r.scope[r.id]="k"===o?{value:n.get(i)}:{value:i};const a=await je(e,t.body);if(a===N)break;if(a instanceof I)return a}return C}async function Ee(e,t,n,r){e:for await(const o of await n.queryAll(e.abortSignal))for(const a of o){r.scope[r.id]={value:y.createFromGraphicLikeObject(a.geometry,a.attributes,n,e.timeZone)};const o=await je(e,t.body);if(o===N)break e;if(o instanceof I)return o}return C}async function Me(e,t,n,r){for(const o of n.keys()){const a=n.field(o);r.scope[r.id]={value:h.containerEntry(o,a)};const i=await je(e,t.body);if(i===N)break;if(i instanceof I)return i}return C}async function De(e,t,n,r){for(const o of u(n)){const a=w(n,o);r.scope[r.id]={value:h.containerEntry(o,a)};const i=await je(e,t.body);if(i===N)break;if(i instanceof I)return i}return C}async function Ae(e,t){const n=await Ie(e,t.right);"VariableDeclaration"===t.left.type&&await je(e,t.left);const r=pe(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);return ae(n)||oe(n)?await Re(e,t,n,r):z(n)?await Ce(e,t,n,r):n instanceof h||G(n)?await Re(e,t,n.keys(),r,"k"):L(n)?await Ee(e,t,n,r):Z(n)?await Re(e,t,u(n),r,"k"):C}async function Be(e,t){const n=await Ie(e,t.right);"VariableDeclaration"===t.left.type&&await je(e,t.left);const r=pe(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);return ae(n)||oe(n)?await Re(e,t,n,r,"k"):z(n)?await Ce(e,t,n,r,"k"):n instanceof h||G(n)?await Me(e,t,n,r):L(n)?await Ee(e,t,n,r):Z(n)?await De(e,t,n,r):C}async function Ue(e,t){const n=t.argument;if("CallExpression"===n.type)throw new g("NeverReach",t);if("MemberExpression"===n.type){const r=await Ie(e,n.object);let o;if(!0===n.computed)o=await Ie(e,n.property);else{if("Identifier"!==n.property.type)throw new g("Unrecognized",t);o=n.property.name}return l(r,o,"++"===t.operator,t.prefix)}const r=pe(e,n),o=fe(r.var).value,a=M(o)+("++"===t.operator?1:-1);return r.scope[r.id]={value:a},t.prefix?a:o}function _e(e,t,n,r){switch(t){case"=":return e===C?null:e;case"/=":return M(n)/M(e);case"*=":return M(n)*M(e);case"-=":return M(n)-M(e);case"+=":return oe(n)||oe(e)?D(n)+D(e):M(n)+M(e);case"%=":return M(n)%M(e);default:throw new g("UnsupportedOperator",r)}}async function ze(e,t){const n=t.left;if("MemberExpression"===n.type){const r=await Ie(e,n.object);let o;if(!0===n.computed)o=await Ie(e,n.property);else{if("Identifier"!==n.property.type)throw new g("InvalidIdentifier",t);o=n.property.name}const a=await Ie(e,t.right);if(ae(r)){if(!ie(o))throw new g("ArrayAccessMustBeNumber",t);if(o<0&&(o=r.length+o),o<0||o>r.length)throw new g("OutOfBounds",t);if(o===r.length){if("="!==t.operator)throw new g("OutOfBounds",t);r[o]=_e(a,t.operator,r[o],t)}else r[o]=_e(a,t.operator,r[o],t)}else if(r instanceof h){if(!1===oe(o))throw new g("KeyAccessorMustBeString",t);if(!0===r.hasField(o))r.setField(o,_e(a,t.operator,r.field(o),t));else{if("="!==t.operator)throw new g("FieldNotFound",t,{key:o});r.setField(o,_e(a,t.operator,null,t))}}else if(r instanceof ye){if(!1===oe(o))throw new g("KeyAccessorMustBeString",t);if(!0!==r.hasGlobal(o))throw new g("ModuleExportNotFound",t);r.setGlobal(o,_e(a,t.operator,r.global(o),t))}else{if(!_(r))throw z(r)?new g("Immutable",t):new g("InvalidParameter",t);if(!1===oe(o))throw new g("KeyAccessorMustBeString",t);if(!0===r.hasField(o))r.setField(o,_e(a,t.operator,r.field(o),t));else{if("="!==t.operator)throw new g("FieldNotFound",t,{key:o});r.setField(o,_e(a,t.operator,null,t))}}return C}const r=pe(e,n),o=await Ie(e,t.right);return r.scope[r.id]={value:_e(o,t.operator,"="!==t.operator?fe(r.var).value:null,t)},C}async function Ge(e,t){const n=await Ie(e,t.expression);return n===C?C:new j(n)}async function Le(e,t){const n=await Ie(e,t.test);if(!0===n)return je(e,t.consequent);if(!1===n)return null!==t.alternate?je(e,t.alternate):C;throw new g("BooleanConditionRequired",t)}async function Ze(e,t){return Pe(e,t,0)}async function Pe(e,t,n){if(n>=t.body.length)return C;const r=await je(e,t.body[n]);return r instanceof I||r===N||r===R||n===t.body.length-1?r:Pe(e,t,n+1)}async function qe(e,t){if(null===t.argument)return new I(C);const n=await Ie(e,t.argument);return new I(n)}async function We(t,n){if(null!=t.localScope)throw se().error("Function declarations are only valid in global scope."),new g("NeverReach",n);const r=e(n.id);if(!(r in t.globalScope))throw se().error(`Function "${r}" not declared.`),new g("NeverReach",n);const o=s(n),a=n.params.map(t=>e(t)),i=Array.from(o.keys()).filter(e=>!a.includes(e));let c=null;return null!=t.contextScopeDebugInfo&&(c={declaredNames:new Map([...n.params.map(t=>[e(t),t.name]),...o])}),t.globalScope[r]={value:new ge(n,t,a,i,c)},C}async function Te(e,t){const n=pe(e,t.specifiers[0].local),r=e.libraryResolver;if(null==r)throw se().error("Internal error: module loader not initialized"),new g("NeverReach",t);const o=r.loadLibrary(n.id);let a;return r._moduleSingletons?.has(o.uri)?a=r._moduleSingletons.get(o.uri):(a=await ye.load(e,o.syntax),r._moduleSingletons?.set(o.uri,a)),n.scope[n.id]={value:a},C}async function Ve(e,t){return await je(e,t.declaration),C}async function Ke(e,t){for(const n of t.declarations)await $e(e,n);return C}async function $e(e,t){t.breakpoint&&await ke(e,t.breakpoint);let n=null;n=null===t.init?null:await Ie(e,t.init),n===C&&(n=null);const r=pe(e,t.id);r.scope[r.id]={value:n}}async function Ye(e,t){return He(e,await Ie(e,t.object),t)}async function He(e,t,n){const r=n.computed?await Ie(e,n.property):n.property.name;return p(t,r)}async function Je(e,t,n){for(const r of n)switch(r.type){case"MemberExpression":t=await He(e,t,r);break;case"CallExpression":t=await it(e,t,r);break;default:throw new g("Unrecognized",r)}return t}async function Qe(e,t,n){const r=n.computed?await Ie(e,n.property):n.property.name;return f(t,r)}async function Xe(e,t){const n=i(t);let r=await Ie(e,n.root);for(const o of n.sections){const t=await Qe(e,r,o.checked);if(null==t)return null;r=await Je(e,t,o.unchecked)}return r}async function et(e,t){const n=await Ie(e,t.argument);if(re(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*M(n);if("+"===t.operator)return 1*M(n);if("~"===t.operator)return~M(n);throw new g("UnsupportUnaryOperator",t)}if("-"===t.operator)return-1*M(n);if("+"===t.operator)return 1*M(n);if("~"===t.operator)return~M(n);throw new g("UnsupportUnaryOperator",t)}async function tt(e,t){const n=[];for(let r=0;r<t.elements.length;r++)n.push(await Ie(e,t.elements[r]));for(let r=0;r<n.length;r++){if(O(n[r]))throw new g("NoFunctionInArray",t);n[r]===C&&(n[r]=null)}return n}async function nt(e,t){const n=await Ie(e,t.left),r=await Ie(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return U(M(n),M(r),t.operator);case"==":return B(n,r);case"!=":return!B(n,r);case"<":case">":case"<=":case">=":return A(n,r,t.operator);case"+":return oe(n)||oe(r)?D(n)+D(r):M(n)+M(r);case"-":return M(n)-M(r);case"*":return M(n)*M(r);case"/":return M(n)/M(r);case"%":return M(n)%M(r);default:throw t.operator,new g("UnsupportedOperator",t)}}async function rt(e,t){const n=await Ie(e,t.left);if(!re(n))throw new g("LogicalExpressionOnlyBoolean",t);switch(t.operator){case"||":{if(!0===n)return n;const r=await Ie(e,t.right);if(re(r))return r;throw new g("LogicExpressionOrAnd",t)}case"&&":{if(!1===n)return n;const r=await Ie(e,t.right);if(re(r))return r;throw new g("LogicExpressionOrAnd",t)}default:throw t.operator,new g("LogicExpressionOrAnd",t)}}function ot(e,t){return we(e,t)}async function at(e,t){let n;if("Identifier"===t.callee.type){const r=t.callee;r.breakpoint&&await ke(e,r.breakpoint),n=we(e,t.callee,"FunctionNotFound")}else n=await Ie(e,t.callee);return it(e,n,t)}async function it(e,t,n){if(O(t))return t.call(e,n);throw new g("CallNonFunction",n)}async function st(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){if(t.expressions[r]){const o=await Ie(e,t.expressions[r]);if(O(o))throw new g("NoFunctionInTemplateLiteral",t);n+=D(o)}r++}return n}async function ct(e,t){E(null===t.arguments?[]:t.arguments,3,3,t);const n=await Ie(e,t.arguments[0]);if(!1===re(n))throw new g("BooleanConditionRequired",t);return Ie(e,n?t.arguments[1]:t.arguments[2])}async function lt(e,t){E(null===t.arguments?[]:t.arguments,2,3,t);const n=await Ie(e,t.arguments[0]);if(3===t.arguments.length){const r=await Ie(e,t.arguments[1]),o=c(n,r);return null!=o&&""!==o?o:Ie(e,t.arguments[2])}return null==n||""===n?Ie(e,t.arguments[1]):n}async function ut(e,t){if(t.arguments.length<2)throw new g("WrongNumberOfParameters",t);if(2===t.arguments.length)return Ie(e,t.arguments[1]);if((t.arguments.length-1)%2==0)throw new g("WrongNumberOfParameters",t);return ft(e,t,1,await Ie(e,t.arguments[0]))}async function ft(e,t,n,r){const o=await Ie(e,t.arguments[n]);if(B(o,r))return Ie(e,t.arguments[n+1]);const a=t.arguments.length-n;return 1===a?Ie(e,t.arguments[n]):2===a?null:3===a?Ie(e,t.arguments[n+2]):ft(e,t,n+2,r)}async function pt(e,t){if(t.arguments.length<3)throw new g("WrongNumberOfParameters",t);if(t.arguments.length%2==0)throw new g("WrongNumberOfParameters",t);const n=await Ie(e,t.arguments[0]);if(!1===re(n))throw new g("BooleanConditionRequired",t.arguments[0]);return wt(e,t,0,n)}async function wt(e,t,n,r){if(!0===r)return Ie(e,t.arguments[n+1]);if(3===t.arguments.length-n)return Ie(e,t.arguments[n+2]);const o=await Ie(e,t.arguments[n+2]);if(!1===re(o))throw new g("ModuleExportNotFound",t.arguments[n+2]);return wt(e,t,n+2,o)}function dt(){const e=Object.create(null);T(e,he),Q(e,he),V(e,he,ot),Y(e,he),$(e,he),J(e,he),X(e,he),K({functions:e,compiled:!1,signatures:null,evaluateIdentifier:null,mode:"async",standardFunction:he,standardFunctionAsync:ve}),e.iif=ct,e.defaultvalue=lt,e.decode=ut,e.when=pt;const t=function(){this.textformatting={value:h.textFormatting()}};t.prototype=Object.create(null),t.prototype.infinity=Object.freeze({value:Number.POSITIVE_INFINITY}),t.prototype.nan=Object.freeze({value:Number.NaN}),t.prototype.pi=Object.freeze({value:Math.PI});for(const[n,r]of Object.entries(e))t.prototype[n]=Object.freeze({value:new v(r,n)});return t}const mt=dt();function ht(e){const t={mode:"async",compiled:!1,functions:Object.create(null),signatures:[],standardFunction:he,standardFunctionAsync:ve,evaluateIdentifier:ot};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const[n,r]of Object.entries(t.functions))mt.prototype[n]=Object.freeze({value:new v(r,n)});for(let n=0;n<t.signatures.length;n++)P(t.signatures[n],"async")}function gt(e){console.log(e)}function bt(n,i){const s=new Set(Object.keys(i?.vars||{}).map(t=>e(t))),c=new Set(Object.keys(i?.customfunctions||{}).map(t=>e(t))),{globals:l,exports:u}=o(n);let f=null;if(i?.breakpoints){for(const[e,t]of a(i.breakpoints,n))e.breakpoint=t;f={declaredNames:new Map(Object.keys(i?.vars||{}).map(t=>[e(t),t]).filter(([e])=>!l.has(e)))}}return async e=>{const o=e.spatialReference??te.WebMercator;let a=null;n.usesModules&&(a=new r(new Map,n.loadedModules));const i=new mt;null!=f&&(i[ce]={declaredNames:l});for(const t of c)null!=e.customfunctions&&t in e.customfunctions?i[t]={value:new v(e.customfunctions[t],t)}:i[t]=le;for(const t of s){if(null==e.vars||!(t in e.vars)){t in i||(i[t]=le);continue}const n=e.vars[t]??null;ne(n)?i[t]={value:y.createFromGraphic(n,e.timeZone??null)}:i[t]={value:n}}for(const t of l.keys())t in i||(i[t]=le);const p={lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??gt,abortSignal:e.abortSignal??t,timeZone:e.timeZone??null,spatialReference:o,track:e.track,depthCounter:{depth:1},libraryResolver:a,exports:u,localScope:null,globalScope:i,contextScopeDebugInfo:f},w=await Ze(p,n);if(w instanceof I||w instanceof j){const e=w.value;if(F(e))return null;if(O(e))throw new g("IllegalResult",null);return e}if(F(w))return null;if(w===N)throw new g("IllegalResult",null);if(w===R)throw new g("IllegalResult",null);throw new g("NeverReach",null)}}function yt(e,t){return bt(e,t)(t)}ht([W]),ht([q]),ht([H]);export{yt as executeScript,ht as extend,bt as prepareScript};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{toSymbolId as e,neverAbortedSignal as t}from"./arcadeEnvironment.js";import{ArcadeModule as n}from"./ArcadeModule.js";import{ArcadeModuleLoader as r}from"./ArcadeModuleLoader.js";import{collectDeclaredGlobalNames as o,collectDeclaredLocalNames as a,flattenAccessChain as s}from"./compilerUtils.js";import{getNestedOptionalValue as l,tryGetMember as i,getMember as c,getGeometryMember as u,getGeometryKeys as m}from"./containerUtils.js";import p from"./Dictionary.js";import{ArcadeExecutionError as f,ArcadeCompilationError as d,ArcadeUncompilableError as g}from"./executionError.js";import{Feature as h}from"./Feature.js";import{NativeFunction as y,ArcadeFunction as w,ScopeMarshalledFunction as b,wrapModuleScopedResponse as $}from"./FunctionWrapper.js";import{s as v,u as S,i as x,h as I,g as F,v as C,w as M,x as O,y as k,z as j,A,d as E,l as N,B}from"../chunks/languageUtils.js";import{addFunctionDeclaration as _}from"./treeAnalysis.js";import{A as V}from"../chunks/aiServices.js";import{A as T}from"../chunks/array.js";import{registerFunctions as L}from"./functions/date.js";import{registerFunctions as R}from"./functions/feature.js";import{registerFunctions as U}from"./functions/geometry.js";import{registerFunctions as D}from"./functions/geomsync.js";import{registerFunctions as G}from"./functions/maths.js";import{P as z}from"../chunks/portal.js";import{registerFunctions as P}from"./functions/stats.js";import{registerFunctions as q}from"./functions/string.js";import{registerFunctions as W}from"./functions/track.js";import K from"../core/Logger.js";import{isPromiseLike as Z}from"../core/promiseUtils.js";import{addMany as J}from"../core/SetUtils.js";import Y from"../geometry/SpatialReference.js";import{isGraphic as H}from"../support/graphicInstanceUtils.js";import{isArray as Q,isNumber as X,isString as ee,isBoolean as te}from"../support/guards.js";const ne=()=>K.getLogger("esri.arcade.arcadeCompiler");class re{constructor(){this._symbolCounter=0,this.safeAccessTempVarId="_Tsat"}nextVarId(){return this._symbolCounter+=1,`_T${this._symbolCounter}`}nextTempVarId(){return this._symbolCounter+=1,`_Tvar${this._symbolCounter}`}nextLocalsSymbolMapId(){return this._symbolCounter+=1,`_Locals${this._symbolCounter}`}}function oe(e,t){const n=e.localScope?.get(t);if(null!=n)return{scope:"local",name:t,var:n};const r=e.globalScope.get(t);return null!=r?{scope:"global",name:t,var:r}:e.standardGlobals.has(t)?{scope:"global",name:t,var:t}:null}function ae(t,n,r="InvalidIdentifier"){const o=oe(t,e(n));if(null!=o)return o;throw new d(r,n)}function se(t,n,r){const o=oe(t,e(n));if(null==o)throw ne().error(`Internal error: Symbol "${n.name}" not declared.`),new d("NeverReach",n);if(null!=r&&o.scope!==r)throw ne().error(`Internal error: Expected to resolve "${n.name}" in the ${r} scope but is in the ${o.scope} scope.`),new d("NeverReach",n);return o}function le(t,n){const r=e(n),o=t.symbolMetadata;if(t.localStack.length>0){const e=t.localStack[t.localStack.length-1],n=o.locals.get(e._SymbolsMapId);if(null==n)return void ne().error(`Internal error: no reflection metadata for ${e._SymbolsMapId}`);const a=n.get(r);if(null!=a)return at.requireInitialized(e[a])}const a=o.globals.get(r);if(null!=a)return at.requireInitialized(t.globalScope[a]);if(o.standardGlobals.has(r))return at.requireInitialized(t.globalScope[r]);throw new f("InvalidIdentifier",null)}class ie extends w{constructor(e,t){super(),this.paramCount=t,this.fn=e}get debugName(){return null}createFunction(e){return(...e)=>{if(e.length!==this.paramCount)throw new f("WrongNumberOfParameters",null);return this.fn(...e)}}call(e,t){return this.fn(...t.arguments)}marshalledCall(e,t,n,r){return r(e,t,(t,o,a)=>{a=a.map(t=>!x(t)||t instanceof b?t:$(t,e,r));const s=this.call(n,{arguments:a});return Z(s)?s.then(e=>$(e,n,r)):s})}}function ce(e,t,n){try{return n(e,null,t.arguments)}catch(r){throw r}}function ue(e,t,n,r,a,s){const{globals:l,exports:i}=o(e),c=new Set(l.keys());J(c,n);const u=new re,m=[],p=new Map;for(const o of c)if(n.has(o)||t.has(o))p.set(o,o);else{const e=u.nextVarId();p.set(o,e),m.push(`gscope[${JSON.stringify(e)}] = ${rt};`)}const f=new Map,d=Object.create(null),g={isAsync:r,symbols:u,standardGlobals:t,globalScope:p,exports:i,localScope:null,allLocalSymbolMetadata:f,moduleFactory:s,moduleFactoryMap:d,libraryResolver:a};return{body:[...m,`var ${u.safeAccessTempVarId};`,"var lastStatement = lc.voidOperation;",Ce(g,e),"return lastStatement;"].join("\n"),symbolMetadata:{standardGlobals:t,exports:i,globals:p,locals:f},moduleFactoryMap:d}}function me(e,t){switch(t.type){case"AssignmentExpression":return Se(e,t);case"UpdateExpression":return $e(e,t);case"TemplateLiteral":return Ue(e,t);case"Identifier":return ze(e,t);case"MemberExpression":return Ne(e,t);case"Literal":return null===t.value||void 0===t.value?"null":JSON.stringify(t.value);case"CallExpression":return Pe(e,t);case"UnaryExpression":return Le(e,t);case"BinaryExpression":return De(e,t);case"LogicalExpression":return Ge(e,t);case"ArrayExpression":return Re(e,t);case"ObjectExpression":return fe(e,t);case"MemberAccessChainExpression":return Te(e,t);case"SafeMemberExpression":throw ne().error("SafeMemberExpression outside of MemberAccessChainExpression"),new d("Unrecognized",t);default:throw new d("Unrecognized",t)}}function pe(e,t){switch(t.type){case"EmptyStatement":return"lc.voidOperation";case"VariableDeclaration":return Ae(e,t);case"BlockStatement":return Ce(e,t);case"FunctionDeclaration":return je(e,t);case"ImportDeclaration":return Oe(e,t);case"ExportNamedDeclaration":return pe(e,t.declaration);case"ReturnStatement":return Me(e,t);case"IfStatement":return Fe(e,t);case"ExpressionStatement":return xe(e,t);case"BreakStatement":return"break";case"ContinueStatement":return"continue";case"ForStatement":return be(e,t);case"ForInStatement":return ye(e,t);case"ForOfStatement":return we(e,t);case"WhileStatement":return ve(e,t);default:throw new d("Unrecognized",t)}}function fe(e,t){let n="lang.dictionary([";for(let r=0;r<t.properties.length;r++){const o=t.properties[r];let a;a="Identifier"===o.key.type?"'"+o.key.name+"'":me(e,o.key);r>0&&(n+=","),n+="lang.strCheck("+a+",'ObjectExpression'),lang.aCheck("+me(e,o.value)+", 'ObjectExpression')"}return n+="])",n}function de(e,t,n,r,o=(e,t)=>`${e} = ${t}`){const a=e.symbols.nextTempVarId(),s=e.symbols.nextTempVarId();return[`var ${a} = ${n};`,`for (var ${s} = 0; ${s} < ${a}; ${s}++) {`,` ${o(t,s)}`,` ${pe(e,r)}`,"}","lastStatement = lc.voidOperation;"].join("\n")}function ge(e,t,n,r,o=e=>e){const a=e.symbols.nextTempVarId(),s=e.symbols.nextTempVarId();return[`var ${a} = ${n};`,`for (var ${s} of ${a}) {`,` ${t} = ${o(s)};`,` ${pe(e,r)}`,"}","lastStatement = lc.voidOperation;"].join("\n")}function he(e,t,n,r){const o=e.symbols.nextTempVarId(),a=e.symbols.nextTempVarId(),s=e.symbols.nextTempVarId(),l=e.symbols.nextTempVarId();return[`var ${o} = yield ${n}.queryAll(runtimeCtx.abortSignal);`,`var ${a} = { done: false, value: [] };`,`for (var ${s} = 0; ${s} < ${a}.value.length || ((${s} = 0), !(${a} = yield ${o}.next()).done); ${s}++) {`,` if (${a}.value.length === 0) continue;`,` var ${l} = ${a}.value[${s}];`,` ${t} = lang.createFeature(${l}, ${n}, runtimeCtx);`,` ${pe(e,r)}`,"}"].join("\n")}function ye(e,t){const n=e.symbols.nextTempVarId();let r,o,a="var "+n+" = "+me(e,t.right)+";\n";switch("VariableDeclaration"===t.left.type?(r=se(e,t.left.declarations[0].id),a+=pe(e,t.left)):r=ae(e,t.left),r.scope){case"local":o=`lscope['${r.var}']`;break;case"global":o=`gscope['${r.var}']`;break;default:throw r.scope,new d("NeverReach",t.left)}return a+="if ("+n+"===null) { lastStatement = lc.voidOperation; }\n ",a+="else if (lc.isArray("+n+") || lc.isString("+n+")) {\n",a+=de(e,o,`${n}.length`,t.body),a+="}\n",a+="else if (lc.isImmutableArray("+n+")) {\n",a+=de(e,o,`${n}.length()`,t.body),a+="}\n",a+="else if (( "+n+" instanceof lang.Dictionary) || lc.isDictionaryLike("+n+")) {\n",a+=ge(e,o,`${n}.keys()`,t.body),a+="}\n",e.isAsync&&(a+="else if (lc.isFeatureSet("+n+")) {\n",a+=he(e,o,n,t.body),a+="}\n"),a+=`else if (lc.isGeometry(${n})) {\n`,a+=ge(e,o,`lang.getGeometryKeys(${n})`,t.body),a+="}\n",a+="else { lastStatement = lc.voidOperation; } \n",a}function we(e,t){const n=e.symbols.nextTempVarId();let r,o,a="var "+n+" = "+me(e,t.right)+";\n";switch("VariableDeclaration"===t.left.type?(r=se(e,t.left.declarations[0].id),a+=pe(e,t.left)):r=ae(e,t.left),r.scope){case"local":o=`lscope['${r.var}']`;break;case"global":o=`gscope['${r.var}']`;break;default:throw r.scope,new d("NeverReach",t.left)}return a+="if ("+n+"===null) { lastStatement = lc.voidOperation; }\n ",a+="else if (lc.isArray("+n+") || lc.isString("+n+")) {\n",a+=de(e,o,`${n}.length`,t.body,(e,t)=>[`if (${t} >= ${n}.length) {`," lang.error('OutOfBounds');","}",`${e} = ${n}[${t}];`].join("\n")),a+="}\n",a+="else if (lc.isImmutableArray("+n+")) {\n",a+=de(e,o,`${n}.length()`,t.body,(e,t)=>`${e} = ${n}.get(${t});`),a+="}\n",a+="else if (( "+n+" instanceof lang.Dictionary) || lc.isDictionaryLike("+n+")) {\n",a+=ge(e,o,`${n}.keys()`,t.body,e=>`lang.entry(${e}, ${n}.field(${e}))`),a+="}\n",e.isAsync&&(a+="else if (lc.isFeatureSet("+n+")) {\n",a+=he(e,o,n,t.body),a+="}\n"),a+=`else if (lc.isGeometry(${n})) {\n`,a+=ge(e,o,`lang.getGeometryKeys(${n})`,t.body,e=>`lang.entry(${e}, lang.getGeometryMember(${n}, ${e}))`),a+="}\n",a+="else { lastStatement = lc.voidOperation; } \n",a}function be(e,t){let n="lastStatement = lc.voidOperation; \n";null!==t.init&&("VariableDeclaration"===t.init.type?n+=pe(e,t.init):n+=me(e,t.init)+"; ");const r=e.symbols.nextTempVarId(),o=e.symbols.nextTempVarId();return n+="var "+r+" = true; ",n+="\n do { ",null!==t.update&&(n+=" if ("+r+"===false) {\n "+me(e,t.update)+" \n}\n "+r+"=false; \n"),null!==t.test&&(n+="var "+o+" = "+me(e,t.test)+"; ",n+="if ("+o+"===false) { break; } else if ("+o+"!==true) { lang.error('BooleanConditionRequired'); }\n"),n+=pe(e,t.body),null!==t.update&&(n+="\n "+me(e,t.update)),n+="\n"+r+" = true; \n} while(true); lastStatement = lc.voidOperation; ",n}function $e(e,t){if("CallExpression"===t.argument.type)throw new d("NeverReach",t);let n;if("MemberExpression"===t.argument.type){const r=me(e,t.argument.object);return n=!0===t.argument.computed?me(e,t.argument.property):"'"+t.argument.property.name+"'","lang.memberupdate("+r+","+n+",'"+t.operator+"',"+t.prefix+")"}const r=ae(e,t.argument);switch(ke(r),r.scope){case"local":return`lang.update(lscope, '${r.var}', '${t.operator}', ${t.prefix})`;case"global":return`lang.update(gscope, '${r.var}', '${t.operator}', ${t.prefix})`;default:throw r.scope,new d("NeverReach",t.argument)}}function ve(e,t){let n="lastStatement = lc.voidOperation; \n";const r=e.symbols.nextTempVarId();return n+=`\n var ${r} = true;\n do {\n ${r} = ${me(e,t.test)};\n if (${r}==false) {\n break;\n }\n if (${r}!==true) {\n lang.error('BooleanConditionRequired');\n }\n ${pe(e,t.body)}\n }\n while (${r} !== false);\n lastStatement = lc.voidOperation;\n `,n}function Se(e,t){const n=me(e,t.right);if("MemberExpression"===t.left.type){let r;const o=me(e,t.left.object);return r=!0===t.left.computed?me(e,t.left.property):"'"+t.left.property.name+"'","lang.assignmember("+o+","+r+",'"+t.operator+"',"+n+")"}const r=ae(e,t.left);switch(ke(r),r.scope){case"local":return`lscope['${r.var}']=lang.assign(${n},'${t.operator}', ${"="===t.operator?"null":ot(`lscope['${r.var}']`)})`;case"global":return`gscope['${r.var}']=lang.assign(${n},'${t.operator}', ${"="===t.operator?"null":ot(`gscope['${r.var}']`)})`;default:throw r.scope,new d("NeverReach",t.left)}}function xe(e,t){return"AssignmentExpression"===t.expression.type?"lastStatement = lc.voidOperation; "+me(e,t.expression)+"; \n ":"lastStatement = "+me(e,t.expression)+"; "}function Ie(e,t){return"BlockStatement"===t.type?pe(e,t):"ReturnStatement"===t.type||"BreakStatement"===t.type||"ContinueStatement"===t.type?pe(e,t)+"; ":"ExpressionStatement"===t.type?pe(e,t):pe(e,t)+"; "}function Fe(e,t){return`if (lang.mustBoolean(${me(e,t.test)}) === true) {\n ${Ie(e,t.consequent)}\n } `+(null!==t.alternate?"IfStatement"===t.alternate.type?" else "+Fe(e,t.alternate):` else {\n ${Ie(e,t.alternate)}\n }\n`:" else {\n lastStatement = lc.voidOperation;\n }\n")}function Ce(e,t){let n="";for(let r=0;r<t.body.length;r++)"EmptyStatement"!==t.body[r].type&&("ReturnStatement"===t.body[r].type||"BreakStatement"===t.body[r].type||"ContinueStatement"===t.body[r].type?n+=pe(e,t.body[r])+"; \n":n+=pe(e,t.body[r])+" \n");return n}function Me(e,t){if(null===t.argument)return"return lc.voidOperation";return"return "+me(e,t.argument)}function Oe(e,t){const n=se(e,t.specifiers[0].local,"global"),r=e.libraryResolver?.loadLibrary(n.name),o=e.symbols.nextVarId();void 0===e.moduleFactory[r.uri]&&(e.moduleFactory[r.uri]=ut(r.syntax,e.moduleFactory,e.isAsync)),e.moduleFactoryMap[o]=r.uri;let a="";return a=e.isAsync?"(yield lang.loadModule('"+o+"', runtimeCtx) ); ":"lang.loadModule('"+o+"', runtimeCtx); ",ke(n),`gscope['${n.var}']=${a}`}function ke(e){if("global"===e.scope)switch(e.name){case"iif":case"when":case"defaultvalue":case"decode":throw new g}}function je(t,n){const r=new Set(n.params.map(t=>e(t))),o=new Set(a(n).keys());J(o,r);const s=t.symbols,l=new Map;for(const e of o)l.set(e,s.nextVarId());const i=s.nextLocalsSymbolMapId();t.allLocalSymbolMetadata.set(i,l);const c={...t,localScope:l},u=[`lscope._SymbolsMapId = ${JSON.stringify(i)};`];for(let e=0;e<n.params.length;e++){const t=se(c,n.params[e],"local");ke(t),u.push(`lscope['${t.var}'] = arguments[${e}];`)}for(const[e,a]of l)r.has(e)||u.push(`lscope['${a}'] = ${rt};`);const m=Ce(c,n.body),p=!0===t.isAsync?["return lang.__awaiter(this, void 0, void 0, function* () {",` ${m}`," return lastStatement;","});"]:[m,"return lastStatement;"],f=["new lang.UserDefinedCompiledFunction("," lang.functionDepthchecker("," function() {"," var lastStatement = lc.voidOperation;"," var lscope = runtimeCtx.localStack[runtimeCtx.localStack.length-1];",...u,...p," },"," runtimeCtx,"," ),",` ${n.params.length},`,")"].join("\n"),d=se(t,n.id,"global");return ke(d),`gscope['${d.var}']=${f}; lastStatement = lc.voidOperation;`}function Ae(e,t){const n=[];for(let r=0;r<t.declarations.length;r++)n.push(Ee(e,t.declarations[r]));return n.join("\n")+" \n lastStatement= lc.voidOperation; \n"}function Ee(e,t){const n=null===t.init?"null":me(e,t.init),r=se(e,t.id);switch(ke(r),r.scope){case"local":return`lscope['${r.var}']=${n};`;case"global":return`gscope['${r.var}']=${n};`;default:throw r.scope,new d("NeverReach",t.id)}}function Ne(e,t){return Be(e,me(e,t.object),t)}function Be(e,t,n){return`lang.member(${t}, ${n.computed?me(e,n.property):`'${n.property.name}'`})`}function _e(e,t,n){for(const r of n)switch(r.type){case"MemberExpression":t=Be(e,t,r);break;case"CallExpression":t=qe(e,t,r.arguments);break;default:throw new d("Unrecognized",r)}return t}function Ve(e,t,n){return`lang.tryMember(${t}, ${n.computed?me(e,n.property):`'${n.property.name}'`})`}function Te(e,t){const n=s(t);let r="",o=me(e,n.root);for(const a of n.sections)r+=`(${e.symbols.safeAccessTempVarId} = ${Ve(e,o,a.checked)}) == null ? null : `,o=_e(e,e.symbols.safeAccessTempVarId,a.unchecked);return`(${r}${o})`}function Le(e,t){try{return"lang.unary("+me(e,t.argument)+",'"+t.operator+"')"}catch(n){throw n}}function Re(e,t){try{const n=[];for(let r=0;r<t.elements.length;r++)"Literal"===t.elements[r].type?n.push(me(e,t.elements[r])):n.push("lang.aCheck("+me(e,t.elements[r])+",'ArrayExpression')");return"["+n.join(",")+"]"}catch(n){throw n}}function Ue(e,t){try{const n=[];let r=0;for(const o of t.quasis)n.push(o.value?JSON.stringify(o.value.cooked):JSON.stringify("")),!1===o.tail&&(n.push(t.expressions[r]?"lang.castString(lang.aCheck("+me(e,t.expressions[r])+", 'TemplateLiteral'))":""),r++);return"(["+n.join(",")+"]).join('')"}catch(n){throw n}}function De(e,t){try{return"lang.binary("+me(e,t.left)+","+me(e,t.right)+",'"+t.operator+"')"}catch(n){throw n}}function Ge(e,t){try{if("AssignmentExpression"===t.left.type||"UpdateExpression"===t.left.type)throw new d("LogicalExpressionOnlyBoolean",t);if("AssignmentExpression"===t.right.type||"UpdateExpression"===t.right.type)throw new d("LogicalExpressionOnlyBoolean",t);if("&&"===t.operator||"||"===t.operator)return"(lang.logicalCheck("+me(e,t.left)+") "+t.operator+" lang.logicalCheck("+me(e,t.right)+"))";throw new d("LogicExpressionOrAnd",null)}catch(n){throw n}}function ze(e,t){const n=ae(e,t);switch(ke(n),n.scope){case"local":return ot(`lscope['${n.var}']`);case"global":return ot(`gscope['${n.var}']`);default:throw n.scope,new d("NeverReach",t)}}function Pe(e,t){if("Identifier"===t.callee.type){const n=ae(e,t.callee,"FunctionNotFound");if("global"===n.scope)switch(n.name){case"iif":return We(e,t);case"when":return Ze(e,t);case"defaultvalue":return Ke(e,t);case"decode":return Je(e,t)}}return qe(e,me(e,t.callee),t.arguments)}function qe(e,t,n){const r=`lang.callfunc(${t}, [${n.map(t=>me(e,t)).join(", ")}], runtimeCtx)`;return e.isAsync?`(yield ${r})`:r}function We(e,t){try{if(3!==t.arguments.length)throw new d("WrongNumberOfParameters",t);const n=e.symbols.nextTempVarId();return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${n} = ${me(e,t.arguments[0])};\n\n if (${n} === true) {\n return ${me(e,t.arguments[1])};\n }\n else if (${n} === false) {\n return ${me(e,t.arguments[2])};\n }\n else {\n lang.error('ExecutionErrorCodes.BooleanConditionRequired');\n }\n ${e.isAsync?"})}()))":"}()"}`}catch(n){throw n}}function Ke(e,t){try{if(t.arguments.length<2||t.arguments.length>3)throw new d("WrongNumberOfParameters",t);const n=e.symbols.nextTempVarId(),r=e.symbols.nextTempVarId();return 3===t.arguments.length?`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${n} = ${me(e,t.arguments[0])};\n var ${r} = ${me(e,t.arguments[1])};\n ${n} = lang.getNestedOptionalValue(${n}, ${r});\n return ${n} != null && ${n} !== "" ? ${n} : ${me(e,t.arguments[2])};\n ${e.isAsync?"})}()))":"}()"}`:`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${n} = ${me(e,t.arguments[0])};\n if (${n} === null) {\n return ${me(e,t.arguments[1])};\n }\n if (${n} === "") {\n return ${me(e,t.arguments[1])};\n }\n if (${n} === undefined) {\n return ${me(e,t.arguments[1])};\n }\n return ${n};\n ${e.isAsync?"})}()))":"}()"}`}catch(n){throw n}}function Ze(e,t){try{if(t.arguments.length<3)throw new d("WrongNumberOfParameters",t);if(t.arguments.length%2==0)throw new d("WrongNumberOfParameters",t);const n=e.symbols.nextTempVarId();let r="var ";for(let o=0;o<t.arguments.length-1;o+=2)r+=`${n} = lang.mustBoolean(${me(e,t.arguments[o])});\n if (${n} === true ) {\n return ${me(e,t.arguments[o+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n ${r}\n return ${me(e,t.arguments[t.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(n){throw n}}function Je(e,t){try{if(t.arguments.length<2)throw new d("WrongNumberOfParameters",t);if(2===t.arguments.length)return`(${me(e,t.arguments[1])})`;if((t.arguments.length-1)%2==0)throw new d("WrongNumberOfParameters",t);const n=e.symbols.nextTempVarId();let r;if(t.arguments.every((e,t)=>t%2==0||"Literal"===e.type)){r=`switch (${n}) {`;for(let n=1;n<t.arguments.length-1;n+=2){const o=t.arguments[n],a=t.arguments[n+1];null==o.value?r+="\n case null:\n case lc.voidOperation:\n ":r+=`\n case ${JSON.stringify(o.value)}:\n `,r+=`return ${me(e,a)}`}r+="}"}else{const o=e.symbols.nextTempVarId();r="var ";for(let a=1;a<t.arguments.length-1;a+=2){const s=t.arguments[a],l=t.arguments[a+1];r+=`${o} = ${me(e,s)};\n if (lang.binary(${o}, ${n}, "==") === true ) {\n return ${me(e,l)}\n }\n `}}return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${n} = ${me(e,t.arguments[0])};\n ${r}\n return ${me(e,t.arguments[t.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(n){throw n}}function Ye(e,t){try{return ce(e,t,(e,t)=>{throw new f("Unrecognized",t)})}catch(n){throw n}}function He(e){const t=function(){this.textformatting=p.textFormatting()};t.prototype=Object.create(null),t.provided=new Set(["textformatting","infinity","nan","pi"]),t.prototype.infinity=Number.POSITIVE_INFINITY,t.prototype.nan=Number.NaN,t.prototype.pi=Math.PI;for(const[n,r]of Object.entries(e))t.prototype[n]=new y(r),t.provided.add(n);return t}function Qe(){const e=Object.create(null);L(e,ce),q(e,ce),R(e,ce,le),G(e,ce),U(e,ce),P(e,ce),W(e,ce),e.iif=Ye,e.decode=Ye,e.when=Ye,e.defaultvalue=Ye;const t=He(e);D(e,ce);return{ScopeSync:He(e),ScopeAsync:t}}const{ScopeSync:Xe,ScopeAsync:et}=Qe();function tt(e,t){const n={mode:t,compiled:!0,functions:Object.create(null),signatures:[],standardFunction:ce,standardFunctionAsync:ce,evaluateIdentifier:le};for(const r of e)r.registerFunctions(n);if("sync"===t)for(const[r,o]of Object.entries(n.functions))Xe.prototype[r]=new y(o),Xe.provided.add(r);else for(const[r,o]of Object.entries(n.functions))et.prototype[r]=new y(o),et.provided.add(r);for(const r of n.signatures)_(r,t)}tt([T],"sync"),tt([T],"async"),tt([V],"async"),tt([z],"async");const nt=Symbol("uninitialized"),rt="lang.uninitialized";function ot(e){return`lang.requireInitialized(${e})`}const at={uninitialized:nt,requireInitialized(e){if(e===nt)throw new f("InvalidIdentifier",null);return e},isNumber:e=>X(e),isArray:e=>Q(e),isImmutableArray:e=>F(e),isDictionaryLike:e=>B(e),isString:e=>ee(e),isDictionary:e=>N(e),isGeometry:e=>E(e),getGeometryKeys:e=>m(e),getGeometryMember:(e,t)=>u(e,t),error(e){throw new f(e,null)},__awaiter(e,t,n,r){const o=r.apply(e,t||[]);let a=o.next();for(;!a.done&&!Z(a.value);)a=o.next(a.value);return a.done?a.value:new Promise((e,t)=>{function n(r){for(;!r.done;){if(Z(r.value))return void Promise.resolve(r.value).then(e=>{try{n(o.next(e))}catch(r){t(r)}},e=>{try{n(o.throw(e))}catch(r){t(r)}});try{r=o.next(r.value)}catch(a){return void t(a)}}e(r.value)}n(a)})},functionDepthchecker:(e,t)=>function(){if(t.depthCounter.depth++,t.localStack.push({}),t.depthCounter.depth>64)throw new f("MaximumCallDepth",null);const n=e.apply(this,arguments);return Z(n)?n.then(e=>(t.depthCounter.depth--,t.localStack.length=t.localStack.length-1,e)):(t.depthCounter.depth--,t.localStack.length=t.localStack.length-1,n)},mustBoolean(e){if(!0===e||!1===e)return e;throw new f("BooleanConditionRequired",null)},castString:e=>M(e),aCheck(e,t){if(x(e)){if("ArrayExpression"===t)throw new f("NoFunctionInArray",null);if("ObjectExpression"===t)throw new f("NoFunctionInDictionary",null);throw new f("NoFunctionInTemplateLiteral",null)}return e===O?null:e},Dictionary:p,Feature:h,UserDefinedCompiledFunction:ie,dictionary(e){const t=Object.create(null),n=new Map;for(let o=0;o<e.length;o+=2){if(x(e[o+1]))throw new f("NoFunctionInDictionary",null);if(!1===ee(e[o]))throw new f("KeyMustBeString",null);let r=e[o].toString();const a=r.toLowerCase();n.has(a)?r=n.get(a):n.set(a,r),e[o+1]===O?t[r]=null:t[r]=e[o+1]}const r=new p(t);return r.immutable=!1,r},entry:(e,t)=>p.containerEntry(e,t),strCheck(e){if(!1===ee(e))throw new f("KeyMustBeString",null);return e},unary(e,t){if(te(e)){if("!"===t)return!e;if("-"===t)return-1*C(e);if("+"===t)return 1*C(e);if("~"===t)return~C(e);throw new f("UnsupportUnaryOperator",null)}if("-"===t)return-1*C(e);if("+"===t)return 1*C(e);if("~"===t)return~C(e);throw new f("UnsupportUnaryOperator",null)},logicalCheck(e){if(!1===te(e))throw new f("LogicExpressionOrAnd",null);return e},logical(e,t,n){if(te(e)&&te(t))switch(n){case"||":return e||t;case"&&":return e&&t;default:throw new f("LogicExpressionOrAnd",null)}throw new f("LogicExpressionOrAnd",null)},binary(e,t,n){switch(n){case"|":case"<<":case">>":case">>>":case"^":case"&":return A(C(e),C(t),n);case"==":return j(e,t);case"!=":return!j(e,t);case"<":case">":case"<=":case">=":return k(e,t,n);case"+":return ee(e)||ee(t)?M(e)+M(t):C(e)+C(t);case"-":return C(e)-C(t);case"*":return C(e)*C(t);case"/":return C(e)/C(t);case"%":return C(e)%C(t);default:throw new f("UnsupportedOperator",null)}},assign(e,t,n){switch(t){case"=":return e===O?null:e;case"/=":return C(n)/C(e);case"*=":return C(n)*C(e);case"-=":return C(n)-C(e);case"+=":return ee(n)||ee(e)?M(n)+M(e):C(n)+C(e);case"%=":return C(n)%C(e);default:throw new f("UnsupportedOperator",null)}},update(e,t,n,r){const o=C(this.requireInitialized(e[t]));return e[t]="++"===n?o+1:o-1,!1===r?o:"++"===n?o+1:o-1},createFeature:(e,t,n)=>h.createFromGraphicLikeObject(e.geometry,e.attributes,t,n.timeZone),memberupdate(e,t,n,r){let o;if(Q(e)){if(!X(t))throw new f("ArrayAccessMustBeNumber",null);if(t<0&&(t=e.length+t),t<0||t>=e.length)throw new f("OutOfBounds",null);o=C(e[t]),e[t]="++"===n?o+1:o-1}else if(e instanceof p){if(!1===ee(t))throw new f("KeyAccessorMustBeString",null);if(!0!==e.hasField(t))throw new f("FieldNotFound",null,{key:t});o=C(e.field(t)),e.setField(t,"++"===n?o+1:o-1)}else if(I(e)){if(!1===ee(t))throw new f("KeyAccessorMustBeString",null);if(!0!==e.hasField(t))throw new f("FieldNotFound",null,{key:t});o=C(e.field(t)),e.setField(t,"++"===n?o+1:o-1)}else{if(F(e))throw new f("Immutable",null);if(!(e instanceof ct))throw new f("InvalidIdentifier",null);if(!1===ee(t))throw new f("ModuleAccessorMustBeString",null);if(!0!==e.hasGlobal(t))throw new f("ModuleExportNotFound",null);o=C(e.global(t)),e.setGlobal(t,"++"===n?o+1:o-1)}return!1===r?o:"++"===n?o+1:o-1},assignmember(e,t,n,r){if(Q(e)){if(!X(t))throw new f("ArrayAccessMustBeNumber",null);if(t<0&&(t=e.length+t),t<0||t>e.length)throw new f("OutOfBounds",null);if(t===e.length){if("="!==n)throw new f("OutOfBounds",null);e[t]=this.assign(r,n,e[t])}else e[t]=this.assign(r,n,e[t])}else if(e instanceof p){if(!1===ee(t))throw new f("KeyAccessorMustBeString",null);if(!0===e.hasField(t))e.setField(t,this.assign(r,n,e.field(t)));else{if("="!==n)throw new f("FieldNotFound",null,{key:t});e.setField(t,this.assign(r,n,null))}}else if(I(e)){if(!1===ee(t))throw new f("KeyAccessorMustBeString",null);if(!0===e.hasField(t))e.setField(t,this.assign(r,n,e.field(t)));else{if("="!==n)throw new f("FieldNotFound",null,{key:t});e.setField(t,this.assign(r,n,null))}}else{if(F(e))throw new f("Immutable",null);if(!(e instanceof ct))throw new f("InvalidIdentifier",null);if(!1===ee(t))throw new f("ModuleAccessorMustBeString",null);if(!e.hasGlobal(t))throw new f("ModuleExportNotFound",null);e.setGlobal(t,this.assign(r,n,e.global(t)))}},member:(e,t)=>c(e,t),tryMember:(e,t)=>i(e,t),callfunc(e,t,n){if(x(e))return e.call(n,{arguments:t,preparsed:!0});throw new f("CallNonFunction",null)},loadModule(e,t){const n=t.moduleFactoryMap[e];if(t.moduleSingletons[n])return t.moduleSingletons[n];const r=t.moduleFactory[n]({moduleSingletons:t.moduleSingletons,depthCounter:t.depthCounter,lrucache:t.lrucache,interceptor:t.interceptor,services:t.services,console:t.console,abortSignal:t.abortSignal,timeZone:t.timeZone??null,spatialReference:t.spatialReference});return t.moduleSingletons[n]=r,r},getNestedOptionalValue:(e,t)=>l(e,t)};function st(e){console.log(e)}function lt(n,o,a=!1){let s=null;n.usesModules&&(s=new r(null,n.loadedModules));const l=Object.create(null),i=new Set(Object.keys(o?.vars||{}).map(t=>e(t))),c=new Set(Object.keys(o?.customfunctions||{}).map(t=>e(t))),u=ue(n,a?et.provided:Xe.provided,new Set([...i,...c]),a,s,l);let m;m=a?["var runtimeCtx = this.prepare(context, true);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","return lang.__awaiter(this, void 0, void 0, function* () {"," function mainBody() {"," return lang.__awaiter(this, void 0, void 0, function* () {",` ${u.body}`," });"," }"," return this.postProcess(yield mainBody());","});"].join("\n"):["var runtimeCtx = this.prepare(context, false);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","function mainBody() {",` ${u.body}`,"}","return this.postProcess(mainBody());"].join("\n");const{symbolMetadata:p,moduleFactoryMap:d}=u,g={lc:v,lang:at,postProcess(e){if(S(e))return null;if(x(e))throw new f("IllegalResult",null);return e},prepare(e,n){const r=e.spatialReference??Y.WebMercator,o=n?new et:new Xe;for(const t of c)null!=e.customfunctions&&t in e.customfunctions?o[t]=e.customfunctions[t]??null:o[t]=nt;for(const t of i){if(null==e.vars||!(t in e.vars)){t in o||(o[t]=nt);continue}const n=e.vars[t]??null;H(n)?o[t]=h.createFromGraphic(n,e.timeZone??null):o[t]=n}return{lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??st,abortSignal:e.abortSignal??t,timeZone:e.timeZone??null,spatialReference:r,track:e.track,globalScope:o,localStack:[],depthCounter:{depth:1},symbolMetadata:p,moduleFactory:l,moduleFactoryMap:d,moduleSingletons:Object.create(null)}}};return new Function("context",m).bind(g)}async function it(){return tt([await(import("./functions/geomasync.js"))],"async"),!0}class ct extends n{constructor(e){super(),this.moduleContext=e}hasGlobal(t){const n=this.moduleContext.symbolMetadata.exports;return n.has(t)||n.has(e(t))}setGlobal(t,n){if(x(n))throw new f("AssignModuleFunction",null);const r=this.moduleContext.symbolMetadata.globals.get(e(t));if(null==r)throw new f("ModuleExportNotFound",null);this.moduleContext.globalScope[r]=n}global(t){const n=this.moduleContext.symbolMetadata.globals.get(e(t));if(null==n)throw new f("ModuleExportNotFound",null);const r=this.moduleContext.globalScope,o=at.requireInitialized(r[n]);if(x(o)&&!(o instanceof b)){const e=new b;return e.fn=o,e.parameterEvaluator=ce,e.context=this.moduleContext,r[n]=e,e}return o}}function ut(e,n,o){const a=new r(null,e.loadedModules),s=ue(e,o?et.provided:Xe.provided,new Set,o,a,n);let l;l=o?["var runtimeCtx = this.prepare(context, true);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","return lang.__awaiter(this, void 0, void 0, function* () {"," function mainBody() {"," return lang.__awaiter(this, void 0, void 0, function* () {",` ${s.body}`," });"," }"," yield mainBody();"," return this.prepareModule(runtimeCtx);","});"].join("\n"):["var runtimeCtx = this.prepare(context, false);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","function mainBody() {",` ${s.body}`,"}","mainBody();","return this.prepareModule(runtimeCtx);"].join("\n");const{symbolMetadata:i,moduleFactoryMap:c}=s,u={lc:v,lang:at,prepareModule:e=>new ct(e),prepare(e,r){const o=e.spatialReference??Y.WebMercator,a=r?new et:new Xe;return{lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??st,abortSignal:e.abortSignal??t,timeZone:e.timeZone??null,spatialReference:o,track:null,globalScope:a,localStack:[],depthCounter:e.depthCounter,symbolMetadata:i,moduleFactory:n,moduleFactoryMap:c,moduleSingletons:e.moduleSingletons}}};return new Function("context",l).bind(u)}export{ie as UserDefinedCompiledFunction,lt as compileScript,it as enableAsyncSupport,tt as extend};
2
+ import{toSymbolId as e,neverAbortedSignal as t}from"./arcadeEnvironment.js";import{ArcadeModule as n}from"./ArcadeModule.js";import{ArcadeModuleLoader as r}from"./ArcadeModuleLoader.js";import{collectDeclaredGlobalNames as o,collectDeclaredLocalNames as a,flattenAccessChain as s}from"./compilerUtils.js";import{getNestedOptionalValue as l,tryGetMember as i,getMember as c,updateMember as u,getGeometryMember as m,getGeometryKeys as p}from"./containerUtils.js";import f from"./Dictionary.js";import{ArcadeExecutionError as d,ArcadeCompilationError as g,ArcadeUncompilableError as h}from"./executionError.js";import{Feature as y}from"./Feature.js";import{NativeFunction as b,ArcadeFunction as w,ScopeMarshalledFunction as $,wrapModuleScopedResponse as v}from"./FunctionWrapper.js";import{s as S,u as x,i as I,h as C,g as O,v as F,w as M,x as j,y as k,z as A,A as E,d as N,l as _,B as V}from"../chunks/languageUtils.js";import{addFunctionDeclaration as B}from"./treeAnalysis.js";import{A as T}from"../chunks/aiServices.js";import{A as L}from"../chunks/array.js";import{registerFunctions as R}from"./functions/date.js";import{registerFunctions as U}from"./functions/feature.js";import{registerFunctions as D}from"./functions/geometry.js";import{registerFunctions as G}from"./functions/geomsync.js";import{registerFunctions as z}from"./functions/maths.js";import{P}from"../chunks/portal.js";import{registerFunctions as q}from"./functions/stats.js";import{registerFunctions as W}from"./functions/string.js";import{registerFunctions as J}from"./functions/track.js";import Z from"../core/Logger.js";import{isPromiseLike as K}from"../core/promiseUtils.js";import{addMany as Y}from"../core/SetUtils.js";import H from"../geometry/SpatialReference.js";import{isGraphic as Q}from"../support/graphicInstanceUtils.js";import{isArray as X,isNumber as ee,isString as te,isBoolean as ne}from"../support/guards.js";const re=()=>Z.getLogger("esri.arcade.arcadeCompiler");class oe{constructor(){this._symbolCounter=0,this.safeAccessTempVarId="_Tsat"}nextVarId(){return this._symbolCounter+=1,`_T${this._symbolCounter}`}nextTempVarId(){return this._symbolCounter+=1,`_Tvar${this._symbolCounter}`}nextLocalsSymbolMapId(){return this._symbolCounter+=1,`_Locals${this._symbolCounter}`}}function ae(e,t){const n=e.localScope?.get(t);if(null!=n)return{scope:"local",name:t,var:n};const r=e.globalScope.get(t);return null!=r?{scope:"global",name:t,var:r}:e.standardGlobals.has(t)?{scope:"global",name:t,var:t}:null}function se(t,n,r="InvalidIdentifier"){const o=ae(t,e(n));if(null!=o)return o;throw new g(r,n)}function le(t,n,r){const o=ae(t,e(n));if(null==o)throw re().error(`Internal error: Symbol "${n.name}" not declared.`),new g("NeverReach",n);if(null!=r&&o.scope!==r)throw re().error(`Internal error: Expected to resolve "${n.name}" in the ${r} scope but is in the ${o.scope} scope.`),new g("NeverReach",n);return o}function ie(t,n){const r=e(n),o=t.symbolMetadata;if(t.localStack.length>0){const e=t.localStack[t.localStack.length-1],n=o.locals.get(e._SymbolsMapId);if(null==n)return void re().error(`Internal error: no reflection metadata for ${e._SymbolsMapId}`);const a=n.get(r);if(null!=a)return st.requireInitialized(e[a])}const a=o.globals.get(r);if(null!=a)return st.requireInitialized(t.globalScope[a]);if(o.standardGlobals.has(r))return st.requireInitialized(t.globalScope[r]);throw new d("InvalidIdentifier",null)}class ce extends w{constructor(e,t){super(),this.paramCount=t,this.fn=e}get debugName(){return null}createFunction(e){return(...e)=>{if(e.length!==this.paramCount)throw new d("WrongNumberOfParameters",null);return this.fn(...e)}}call(e,t){return this.fn(...t.arguments)}marshalledCall(e,t,n,r){return r(e,t,(t,o,a)=>{a=a.map(t=>!I(t)||t instanceof $?t:v(t,e,r));const s=this.call(n,{arguments:a});return K(s)?s.then(e=>v(e,n,r)):s})}}function ue(e,t,n){try{return n(e,null,t.arguments)}catch(r){throw r}}function me(e,t,n,r,a,s){const{globals:l,exports:i}=o(e),c=new Set(l.keys());Y(c,n);const u=new oe,m=[],p=new Map;for(const o of c)if(n.has(o)||t.has(o))p.set(o,o);else{const e=u.nextVarId();p.set(o,e),m.push(`gscope[${JSON.stringify(e)}] = ${ot};`)}const f=new Map,d=Object.create(null),g={isAsync:r,symbols:u,standardGlobals:t,globalScope:p,exports:i,localScope:null,allLocalSymbolMetadata:f,moduleFactory:s,moduleFactoryMap:d,libraryResolver:a};return{body:[...m,`var ${u.safeAccessTempVarId};`,"var lastStatement = lc.voidOperation;",Fe(g,e),"return lastStatement;"].join("\n"),symbolMetadata:{standardGlobals:t,exports:i,globals:p,locals:f},moduleFactoryMap:d}}function pe(e,t){switch(t.type){case"AssignmentExpression":return xe(e,t);case"UpdateExpression":return ve(e,t);case"TemplateLiteral":return De(e,t);case"Identifier":return Pe(e,t);case"MemberExpression":return _e(e,t);case"Literal":return null===t.value||void 0===t.value?"null":JSON.stringify(t.value);case"CallExpression":return qe(e,t);case"UnaryExpression":return Re(e,t);case"BinaryExpression":return Ge(e,t);case"LogicalExpression":return ze(e,t);case"ArrayExpression":return Ue(e,t);case"ObjectExpression":return de(e,t);case"MemberAccessChainExpression":return Le(e,t);case"SafeMemberExpression":throw re().error("SafeMemberExpression outside of MemberAccessChainExpression"),new g("Unrecognized",t);default:throw new g("Unrecognized",t)}}function fe(e,t){switch(t.type){case"EmptyStatement":return"lc.voidOperation";case"VariableDeclaration":return Ee(e,t);case"BlockStatement":return Fe(e,t);case"FunctionDeclaration":return Ae(e,t);case"ImportDeclaration":return je(e,t);case"ExportNamedDeclaration":return fe(e,t.declaration);case"ReturnStatement":return Me(e,t);case"IfStatement":return Oe(e,t);case"ExpressionStatement":return Ie(e,t);case"BreakStatement":return"break";case"ContinueStatement":return"continue";case"ForStatement":return $e(e,t);case"ForInStatement":return be(e,t);case"ForOfStatement":return we(e,t);case"WhileStatement":return Se(e,t);default:throw new g("Unrecognized",t)}}function de(e,t){let n="lang.dictionary([";for(let r=0;r<t.properties.length;r++){const o=t.properties[r];let a;a="Identifier"===o.key.type?"'"+o.key.name+"'":pe(e,o.key);r>0&&(n+=","),n+="lang.strCheck("+a+",'ObjectExpression'),lang.aCheck("+pe(e,o.value)+", 'ObjectExpression')"}return n+="])",n}function ge(e,t,n,r,o=(e,t)=>`${e} = ${t}`){const a=e.symbols.nextTempVarId(),s=e.symbols.nextTempVarId();return[`var ${a} = ${n};`,`for (var ${s} = 0; ${s} < ${a}; ${s}++) {`,` ${o(t,s)}`,` ${fe(e,r)}`,"}","lastStatement = lc.voidOperation;"].join("\n")}function he(e,t,n,r,o=e=>e){const a=e.symbols.nextTempVarId(),s=e.symbols.nextTempVarId();return[`var ${a} = ${n};`,`for (var ${s} of ${a}) {`,` ${t} = ${o(s)};`,` ${fe(e,r)}`,"}","lastStatement = lc.voidOperation;"].join("\n")}function ye(e,t,n,r){const o=e.symbols.nextTempVarId(),a=e.symbols.nextTempVarId(),s=e.symbols.nextTempVarId(),l=e.symbols.nextTempVarId();return[`var ${o} = yield ${n}.queryAll(runtimeCtx.abortSignal);`,`var ${a} = { done: false, value: [] };`,`for (var ${s} = 0; ${s} < ${a}.value.length || ((${s} = 0), !(${a} = yield ${o}.next()).done); ${s}++) {`,` if (${a}.value.length === 0) continue;`,` var ${l} = ${a}.value[${s}];`,` ${t} = lang.createFeature(${l}, ${n}, runtimeCtx);`,` ${fe(e,r)}`,"}"].join("\n")}function be(e,t){const n=e.symbols.nextTempVarId();let r,o,a="var "+n+" = "+pe(e,t.right)+";\n";switch("VariableDeclaration"===t.left.type?(r=le(e,t.left.declarations[0].id),a+=fe(e,t.left)):r=se(e,t.left),r.scope){case"local":o=`lscope['${r.var}']`;break;case"global":o=`gscope['${r.var}']`;break;default:throw r.scope,new g("NeverReach",t.left)}return a+="if ("+n+"===null) { lastStatement = lc.voidOperation; }\n ",a+="else if (lc.isArray("+n+") || lc.isString("+n+")) {\n",a+=ge(e,o,`${n}.length`,t.body),a+="}\n",a+="else if (lc.isImmutableArray("+n+")) {\n",a+=ge(e,o,`${n}.length()`,t.body),a+="}\n",a+="else if (( "+n+" instanceof lang.Dictionary) || lc.isDictionaryLike("+n+")) {\n",a+=he(e,o,`${n}.keys()`,t.body),a+="}\n",e.isAsync&&(a+="else if (lc.isFeatureSet("+n+")) {\n",a+=ye(e,o,n,t.body),a+="}\n"),a+=`else if (lc.isGeometry(${n})) {\n`,a+=he(e,o,`lang.getGeometryKeys(${n})`,t.body),a+="}\n",a+="else { lastStatement = lc.voidOperation; } \n",a}function we(e,t){const n=e.symbols.nextTempVarId();let r,o,a="var "+n+" = "+pe(e,t.right)+";\n";switch("VariableDeclaration"===t.left.type?(r=le(e,t.left.declarations[0].id),a+=fe(e,t.left)):r=se(e,t.left),r.scope){case"local":o=`lscope['${r.var}']`;break;case"global":o=`gscope['${r.var}']`;break;default:throw r.scope,new g("NeverReach",t.left)}return a+="if ("+n+"===null) { lastStatement = lc.voidOperation; }\n ",a+="else if (lc.isArray("+n+") || lc.isString("+n+")) {\n",a+=ge(e,o,`${n}.length`,t.body,(e,t)=>[`if (${t} >= ${n}.length) {`," lang.error('OutOfBounds');","}",`${e} = ${n}[${t}];`].join("\n")),a+="}\n",a+="else if (lc.isImmutableArray("+n+")) {\n",a+=ge(e,o,`${n}.length()`,t.body,(e,t)=>`${e} = ${n}.get(${t});`),a+="}\n",a+="else if (( "+n+" instanceof lang.Dictionary) || lc.isDictionaryLike("+n+")) {\n",a+=he(e,o,`${n}.keys()`,t.body,e=>`lang.entry(${e}, ${n}.field(${e}))`),a+="}\n",e.isAsync&&(a+="else if (lc.isFeatureSet("+n+")) {\n",a+=ye(e,o,n,t.body),a+="}\n"),a+=`else if (lc.isGeometry(${n})) {\n`,a+=he(e,o,`lang.getGeometryKeys(${n})`,t.body,e=>`lang.entry(${e}, lang.getGeometryMember(${n}, ${e}))`),a+="}\n",a+="else { lastStatement = lc.voidOperation; } \n",a}function $e(e,t){let n="lastStatement = lc.voidOperation; \n";null!==t.init&&("VariableDeclaration"===t.init.type?n+=fe(e,t.init):n+=pe(e,t.init)+"; ");const r=e.symbols.nextTempVarId(),o=e.symbols.nextTempVarId();return n+="var "+r+" = true; ",n+="\n do { ",null!==t.update&&(n+=" if ("+r+"===false) {\n "+pe(e,t.update)+" \n}\n "+r+"=false; \n"),null!==t.test&&(n+="var "+o+" = "+pe(e,t.test)+"; ",n+="if ("+o+"===false) { break; } else if ("+o+"!==true) { lang.error('BooleanConditionRequired'); }\n"),n+=fe(e,t.body),null!==t.update&&(n+="\n "+pe(e,t.update)),n+="\n"+r+" = true; \n} while(true); lastStatement = lc.voidOperation; ",n}function ve(e,t){if("CallExpression"===t.argument.type)throw new g("NeverReach",t);const n=JSON.stringify("++"===t.operator),r=JSON.stringify(!!t.prefix);let o;if("MemberExpression"===t.argument.type){const a=pe(e,t.argument.object);return o=!0===t.argument.computed?pe(e,t.argument.property):"'"+t.argument.property.name+"'",`lang.memberupdate(${a}, ${o}, ${n}, ${r})`}const a=se(e,t.argument);switch(ke(a),a.scope){case"local":return`lang.update(lscope, '${a.var}', ${n}, ${r})`;case"global":return`lang.update(gscope, '${a.var}', ${n}, ${r})`;default:throw a.scope,new g("NeverReach",t.argument)}}function Se(e,t){let n="lastStatement = lc.voidOperation; \n";const r=e.symbols.nextTempVarId();return n+=`\n var ${r} = true;\n do {\n ${r} = ${pe(e,t.test)};\n if (${r}==false) {\n break;\n }\n if (${r}!==true) {\n lang.error('BooleanConditionRequired');\n }\n ${fe(e,t.body)}\n }\n while (${r} !== false);\n lastStatement = lc.voidOperation;\n `,n}function xe(e,t){const n=pe(e,t.right);if("MemberExpression"===t.left.type){let r;const o=pe(e,t.left.object);return r=!0===t.left.computed?pe(e,t.left.property):"'"+t.left.property.name+"'","lang.assignmember("+o+","+r+",'"+t.operator+"',"+n+")"}const r=se(e,t.left);switch(ke(r),r.scope){case"local":return`lscope['${r.var}']=lang.assign(${n},'${t.operator}', ${"="===t.operator?"null":at(`lscope['${r.var}']`)})`;case"global":return`gscope['${r.var}']=lang.assign(${n},'${t.operator}', ${"="===t.operator?"null":at(`gscope['${r.var}']`)})`;default:throw r.scope,new g("NeverReach",t.left)}}function Ie(e,t){return"AssignmentExpression"===t.expression.type?"lastStatement = lc.voidOperation; "+pe(e,t.expression)+"; \n ":"lastStatement = "+pe(e,t.expression)+"; "}function Ce(e,t){return"BlockStatement"===t.type?fe(e,t):"ReturnStatement"===t.type||"BreakStatement"===t.type||"ContinueStatement"===t.type?fe(e,t)+"; ":"ExpressionStatement"===t.type?fe(e,t):fe(e,t)+"; "}function Oe(e,t){return`if (lang.mustBoolean(${pe(e,t.test)}) === true) {\n ${Ce(e,t.consequent)}\n } `+(null!==t.alternate?"IfStatement"===t.alternate.type?" else "+Oe(e,t.alternate):` else {\n ${Ce(e,t.alternate)}\n }\n`:" else {\n lastStatement = lc.voidOperation;\n }\n")}function Fe(e,t){let n="";for(let r=0;r<t.body.length;r++)"EmptyStatement"!==t.body[r].type&&("ReturnStatement"===t.body[r].type||"BreakStatement"===t.body[r].type||"ContinueStatement"===t.body[r].type?n+=fe(e,t.body[r])+"; \n":n+=fe(e,t.body[r])+" \n");return n}function Me(e,t){if(null===t.argument)return"return lc.voidOperation";return"return "+pe(e,t.argument)}function je(e,t){const n=le(e,t.specifiers[0].local,"global"),r=e.libraryResolver?.loadLibrary(n.name),o=e.symbols.nextVarId();void 0===e.moduleFactory[r.uri]&&(e.moduleFactory[r.uri]=mt(r.syntax,e.moduleFactory,e.isAsync)),e.moduleFactoryMap[o]=r.uri;let a="";return a=e.isAsync?"(yield lang.loadModule('"+o+"', runtimeCtx) ); ":"lang.loadModule('"+o+"', runtimeCtx); ",ke(n),`gscope['${n.var}']=${a}`}function ke(e){if("global"===e.scope)switch(e.name){case"iif":case"when":case"defaultvalue":case"decode":throw new h}}function Ae(t,n){const r=new Set(n.params.map(t=>e(t))),o=new Set(a(n).keys());Y(o,r);const s=t.symbols,l=new Map;for(const e of o)l.set(e,s.nextVarId());const i=s.nextLocalsSymbolMapId();t.allLocalSymbolMetadata.set(i,l);const c={...t,localScope:l},u=[`lscope._SymbolsMapId = ${JSON.stringify(i)};`];for(let e=0;e<n.params.length;e++){const t=le(c,n.params[e],"local");ke(t),u.push(`lscope['${t.var}'] = arguments[${e}];`)}for(const[e,a]of l)r.has(e)||u.push(`lscope['${a}'] = ${ot};`);const m=Fe(c,n.body),p=!0===t.isAsync?["return lang.__awaiter(this, void 0, void 0, function* () {",` ${m}`," return lastStatement;","});"]:[m,"return lastStatement;"],f=["new lang.UserDefinedCompiledFunction("," lang.functionDepthchecker("," function() {"," var lastStatement = lc.voidOperation;"," var lscope = runtimeCtx.localStack[runtimeCtx.localStack.length-1];",...u,...p," },"," runtimeCtx,"," ),",` ${n.params.length},`,")"].join("\n"),d=le(t,n.id,"global");return ke(d),`gscope['${d.var}']=${f}; lastStatement = lc.voidOperation;`}function Ee(e,t){const n=[];for(let r=0;r<t.declarations.length;r++)n.push(Ne(e,t.declarations[r]));return n.join("\n")+" \n lastStatement= lc.voidOperation; \n"}function Ne(e,t){const n=null===t.init?"null":pe(e,t.init),r=le(e,t.id);switch(ke(r),r.scope){case"local":return`lscope['${r.var}']=${n};`;case"global":return`gscope['${r.var}']=${n};`;default:throw r.scope,new g("NeverReach",t.id)}}function _e(e,t){return Ve(e,pe(e,t.object),t)}function Ve(e,t,n){return`lang.member(${t}, ${n.computed?pe(e,n.property):`'${n.property.name}'`})`}function Be(e,t,n){for(const r of n)switch(r.type){case"MemberExpression":t=Ve(e,t,r);break;case"CallExpression":t=We(e,t,r.arguments);break;default:throw new g("Unrecognized",r)}return t}function Te(e,t,n){return`lang.tryMember(${t}, ${n.computed?pe(e,n.property):`'${n.property.name}'`})`}function Le(e,t){const n=s(t);let r="",o=pe(e,n.root);for(const a of n.sections)r+=`(${e.symbols.safeAccessTempVarId} = ${Te(e,o,a.checked)}) == null ? null : `,o=Be(e,e.symbols.safeAccessTempVarId,a.unchecked);return`(${r}${o})`}function Re(e,t){try{return"lang.unary("+pe(e,t.argument)+",'"+t.operator+"')"}catch(n){throw n}}function Ue(e,t){try{const n=[];for(let r=0;r<t.elements.length;r++)"Literal"===t.elements[r].type?n.push(pe(e,t.elements[r])):n.push("lang.aCheck("+pe(e,t.elements[r])+",'ArrayExpression')");return"["+n.join(",")+"]"}catch(n){throw n}}function De(e,t){try{const n=[];let r=0;for(const o of t.quasis)n.push(o.value?JSON.stringify(o.value.cooked):JSON.stringify("")),!1===o.tail&&(n.push(t.expressions[r]?"lang.castString(lang.aCheck("+pe(e,t.expressions[r])+", 'TemplateLiteral'))":""),r++);return"(["+n.join(",")+"]).join('')"}catch(n){throw n}}function Ge(e,t){try{return"lang.binary("+pe(e,t.left)+","+pe(e,t.right)+",'"+t.operator+"')"}catch(n){throw n}}function ze(e,t){try{if("AssignmentExpression"===t.left.type||"UpdateExpression"===t.left.type)throw new g("LogicalExpressionOnlyBoolean",t);if("AssignmentExpression"===t.right.type||"UpdateExpression"===t.right.type)throw new g("LogicalExpressionOnlyBoolean",t);if("&&"===t.operator||"||"===t.operator)return"(lang.logicalCheck("+pe(e,t.left)+") "+t.operator+" lang.logicalCheck("+pe(e,t.right)+"))";throw new g("LogicExpressionOrAnd",null)}catch(n){throw n}}function Pe(e,t){const n=se(e,t);switch(ke(n),n.scope){case"local":return at(`lscope['${n.var}']`);case"global":return at(`gscope['${n.var}']`);default:throw n.scope,new g("NeverReach",t)}}function qe(e,t){if("Identifier"===t.callee.type){const n=se(e,t.callee,"FunctionNotFound");if("global"===n.scope)switch(n.name){case"iif":return Je(e,t);case"when":return Ke(e,t);case"defaultvalue":return Ze(e,t);case"decode":return Ye(e,t)}}return We(e,pe(e,t.callee),t.arguments)}function We(e,t,n){const r=`lang.callfunc(${t}, [${n.map(t=>pe(e,t)).join(", ")}], runtimeCtx)`;return e.isAsync?`(yield ${r})`:r}function Je(e,t){try{if(3!==t.arguments.length)throw new g("WrongNumberOfParameters",t);const n=e.symbols.nextTempVarId();return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${n} = ${pe(e,t.arguments[0])};\n\n if (${n} === true) {\n return ${pe(e,t.arguments[1])};\n }\n else if (${n} === false) {\n return ${pe(e,t.arguments[2])};\n }\n else {\n lang.error('ExecutionErrorCodes.BooleanConditionRequired');\n }\n ${e.isAsync?"})}()))":"}()"}`}catch(n){throw n}}function Ze(e,t){try{if(t.arguments.length<2||t.arguments.length>3)throw new g("WrongNumberOfParameters",t);const n=e.symbols.nextTempVarId(),r=e.symbols.nextTempVarId();return 3===t.arguments.length?`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${n} = ${pe(e,t.arguments[0])};\n var ${r} = ${pe(e,t.arguments[1])};\n ${n} = lang.getNestedOptionalValue(${n}, ${r});\n return ${n} != null && ${n} !== "" ? ${n} : ${pe(e,t.arguments[2])};\n ${e.isAsync?"})}()))":"}()"}`:`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${n} = ${pe(e,t.arguments[0])};\n if (${n} === null) {\n return ${pe(e,t.arguments[1])};\n }\n if (${n} === "") {\n return ${pe(e,t.arguments[1])};\n }\n if (${n} === undefined) {\n return ${pe(e,t.arguments[1])};\n }\n return ${n};\n ${e.isAsync?"})}()))":"}()"}`}catch(n){throw n}}function Ke(e,t){try{if(t.arguments.length<3)throw new g("WrongNumberOfParameters",t);if(t.arguments.length%2==0)throw new g("WrongNumberOfParameters",t);const n=e.symbols.nextTempVarId();let r="var ";for(let o=0;o<t.arguments.length-1;o+=2)r+=`${n} = lang.mustBoolean(${pe(e,t.arguments[o])});\n if (${n} === true ) {\n return ${pe(e,t.arguments[o+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n ${r}\n return ${pe(e,t.arguments[t.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(n){throw n}}function Ye(e,t){try{if(t.arguments.length<2)throw new g("WrongNumberOfParameters",t);if(2===t.arguments.length)return`(${pe(e,t.arguments[1])})`;if((t.arguments.length-1)%2==0)throw new g("WrongNumberOfParameters",t);const n=e.symbols.nextTempVarId();let r;if(t.arguments.every((e,t)=>t%2==0||"Literal"===e.type)){r=`switch (${n}) {`;for(let n=1;n<t.arguments.length-1;n+=2){const o=t.arguments[n],a=t.arguments[n+1];null==o.value?r+="\n case null:\n case lc.voidOperation:\n ":r+=`\n case ${JSON.stringify(o.value)}:\n `,r+=`return ${pe(e,a)}`}r+="}"}else{const o=e.symbols.nextTempVarId();r="var ";for(let a=1;a<t.arguments.length-1;a+=2){const s=t.arguments[a],l=t.arguments[a+1];r+=`${o} = ${pe(e,s)};\n if (lang.binary(${o}, ${n}, "==") === true ) {\n return ${pe(e,l)}\n }\n `}}return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${n} = ${pe(e,t.arguments[0])};\n ${r}\n return ${pe(e,t.arguments[t.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(n){throw n}}function He(e,t){try{return ue(e,t,(e,t)=>{throw new d("Unrecognized",t)})}catch(n){throw n}}function Qe(e){const t=function(){this.textformatting=f.textFormatting()};t.prototype=Object.create(null),t.provided=new Set(["textformatting","infinity","nan","pi"]),t.prototype.infinity=Number.POSITIVE_INFINITY,t.prototype.nan=Number.NaN,t.prototype.pi=Math.PI;for(const[n,r]of Object.entries(e))t.prototype[n]=new b(r),t.provided.add(n);return t}function Xe(){const e=Object.create(null);R(e,ue),W(e,ue),U(e,ue,ie),z(e,ue),D(e,ue),q(e,ue),J(e,ue),e.iif=He,e.decode=He,e.when=He,e.defaultvalue=He;const t=Qe(e);G(e,ue);return{ScopeSync:Qe(e),ScopeAsync:t}}const{ScopeSync:et,ScopeAsync:tt}=Xe();function nt(e,t){const n={mode:t,compiled:!0,functions:Object.create(null),signatures:[],standardFunction:ue,standardFunctionAsync:ue,evaluateIdentifier:ie};for(const r of e)r.registerFunctions(n);if("sync"===t)for(const[r,o]of Object.entries(n.functions))et.prototype[r]=new b(o),et.provided.add(r);else for(const[r,o]of Object.entries(n.functions))tt.prototype[r]=new b(o),tt.provided.add(r);for(const r of n.signatures)B(r,t)}nt([L],"sync"),nt([L],"async"),nt([T],"async"),nt([P],"async");const rt=Symbol("uninitialized"),ot="lang.uninitialized";function at(e){return`lang.requireInitialized(${e})`}const st={uninitialized:rt,requireInitialized(e){if(e===rt)throw new d("InvalidIdentifier",null);return e},isNumber:e=>ee(e),isArray:e=>X(e),isImmutableArray:e=>O(e),isDictionaryLike:e=>V(e),isString:e=>te(e),isDictionary:e=>_(e),isGeometry:e=>N(e),getGeometryKeys:e=>p(e),getGeometryMember:(e,t)=>m(e,t),error(e){throw new d(e,null)},__awaiter(e,t,n,r){const o=r.apply(e,t||[]);let a=o.next();for(;!a.done&&!K(a.value);)a=o.next(a.value);return a.done?a.value:new Promise((e,t)=>{function n(r){for(;!r.done;){if(K(r.value))return void Promise.resolve(r.value).then(e=>{try{n(o.next(e))}catch(r){t(r)}},e=>{try{n(o.throw(e))}catch(r){t(r)}});try{r=o.next(r.value)}catch(a){return void t(a)}}e(r.value)}n(a)})},functionDepthchecker:(e,t)=>function(){if(t.depthCounter.depth++,t.localStack.push({}),t.depthCounter.depth>64)throw new d("MaximumCallDepth",null);const n=e.apply(this,arguments);return K(n)?n.then(e=>(t.depthCounter.depth--,t.localStack.length=t.localStack.length-1,e)):(t.depthCounter.depth--,t.localStack.length=t.localStack.length-1,n)},mustBoolean(e){if(!0===e||!1===e)return e;throw new d("BooleanConditionRequired",null)},castString:e=>M(e),aCheck(e,t){if(I(e)){if("ArrayExpression"===t)throw new d("NoFunctionInArray",null);if("ObjectExpression"===t)throw new d("NoFunctionInDictionary",null);throw new d("NoFunctionInTemplateLiteral",null)}return e===j?null:e},Dictionary:f,Feature:y,UserDefinedCompiledFunction:ce,dictionary(e){const t=Object.create(null),n=new Map;for(let o=0;o<e.length;o+=2){if(I(e[o+1]))throw new d("NoFunctionInDictionary",null);if(!1===te(e[o]))throw new d("KeyMustBeString",null);let r=e[o].toString();const a=r.toLowerCase();n.has(a)?r=n.get(a):n.set(a,r),e[o+1]===j?t[r]=null:t[r]=e[o+1]}const r=new f(t);return r.immutable=!1,r},entry:(e,t)=>f.containerEntry(e,t),strCheck(e){if(!1===te(e))throw new d("KeyMustBeString",null);return e},unary(e,t){if(ne(e)){if("!"===t)return!e;if("-"===t)return-1*F(e);if("+"===t)return 1*F(e);if("~"===t)return~F(e);throw new d("UnsupportUnaryOperator",null)}if("-"===t)return-1*F(e);if("+"===t)return 1*F(e);if("~"===t)return~F(e);throw new d("UnsupportUnaryOperator",null)},logicalCheck(e){if(!1===ne(e))throw new d("LogicExpressionOrAnd",null);return e},logical(e,t,n){if(ne(e)&&ne(t))switch(n){case"||":return e||t;case"&&":return e&&t;default:throw new d("LogicExpressionOrAnd",null)}throw new d("LogicExpressionOrAnd",null)},binary(e,t,n){switch(n){case"|":case"<<":case">>":case">>>":case"^":case"&":return E(F(e),F(t),n);case"==":return A(e,t);case"!=":return!A(e,t);case"<":case">":case"<=":case">=":return k(e,t,n);case"+":return te(e)||te(t)?M(e)+M(t):F(e)+F(t);case"-":return F(e)-F(t);case"*":return F(e)*F(t);case"/":return F(e)/F(t);case"%":return F(e)%F(t);default:throw new d("UnsupportedOperator",null)}},assign(e,t,n){switch(t){case"=":return e===j?null:e;case"/=":return F(n)/F(e);case"*=":return F(n)*F(e);case"-=":return F(n)-F(e);case"+=":return te(n)||te(e)?M(n)+M(e):F(n)+F(e);case"%=":return F(n)%F(e);default:throw new d("UnsupportedOperator",null)}},update(e,t,n,r){const o=this.requireInitialized(e[t]),a=F(o)+(n?1:-1);return e[t]=a,r?a:o},createFeature:(e,t,n)=>y.createFromGraphicLikeObject(e.geometry,e.attributes,t,n.timeZone),memberupdate:(e,t,n,r)=>u(e,t,n,r),assignmember(e,t,n,r){if(X(e)){if(!ee(t))throw new d("ArrayAccessMustBeNumber",null);if(t<0&&(t=e.length+t),t<0||t>e.length)throw new d("OutOfBounds",null);if(t===e.length){if("="!==n)throw new d("OutOfBounds",null);e[t]=this.assign(r,n,e[t])}else e[t]=this.assign(r,n,e[t])}else if(e instanceof f){if(!1===te(t))throw new d("KeyAccessorMustBeString",null);if(!0===e.hasField(t))e.setField(t,this.assign(r,n,e.field(t)));else{if("="!==n)throw new d("FieldNotFound",null,{key:t});e.setField(t,this.assign(r,n,null))}}else if(C(e)){if(!1===te(t))throw new d("KeyAccessorMustBeString",null);if(!0===e.hasField(t))e.setField(t,this.assign(r,n,e.field(t)));else{if("="!==n)throw new d("FieldNotFound",null,{key:t});e.setField(t,this.assign(r,n,null))}}else{if(O(e))throw new d("Immutable",null);if(!(e instanceof ut))throw new d("InvalidIdentifier",null);if(!1===te(t))throw new d("ModuleAccessorMustBeString",null);if(!e.hasGlobal(t))throw new d("ModuleExportNotFound",null);e.setGlobal(t,this.assign(r,n,e.global(t)))}},member:(e,t)=>c(e,t),tryMember:(e,t)=>i(e,t),callfunc(e,t,n){if(I(e))return e.call(n,{arguments:t,preparsed:!0});throw new d("CallNonFunction",null)},loadModule(e,t){const n=t.moduleFactoryMap[e];if(t.moduleSingletons[n])return t.moduleSingletons[n];const r=t.moduleFactory[n]({moduleSingletons:t.moduleSingletons,depthCounter:t.depthCounter,lrucache:t.lrucache,interceptor:t.interceptor,services:t.services,console:t.console,abortSignal:t.abortSignal,timeZone:t.timeZone??null,spatialReference:t.spatialReference});return t.moduleSingletons[n]=r,r},getNestedOptionalValue:(e,t)=>l(e,t)};function lt(e){console.log(e)}function it(n,o,a=!1){let s=null;n.usesModules&&(s=new r(null,n.loadedModules));const l=Object.create(null),i=new Set(Object.keys(o?.vars||{}).map(t=>e(t))),c=new Set(Object.keys(o?.customfunctions||{}).map(t=>e(t))),u=me(n,a?tt.provided:et.provided,new Set([...i,...c]),a,s,l);let m;m=a?["var runtimeCtx = this.prepare(context, true);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","return lang.__awaiter(this, void 0, void 0, function* () {"," function mainBody() {"," return lang.__awaiter(this, void 0, void 0, function* () {",` ${u.body}`," });"," }"," return this.postProcess(yield mainBody());","});"].join("\n"):["var runtimeCtx = this.prepare(context, false);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","function mainBody() {",` ${u.body}`,"}","return this.postProcess(mainBody());"].join("\n");const{symbolMetadata:p,moduleFactoryMap:f}=u,g={lc:S,lang:st,postProcess(e){if(x(e))return null;if(I(e))throw new d("IllegalResult",null);return e},prepare(e,n){const r=e.spatialReference??H.WebMercator,o=n?new tt:new et;for(const t of c)null!=e.customfunctions&&t in e.customfunctions?o[t]=e.customfunctions[t]??null:o[t]=rt;for(const t of i){if(null==e.vars||!(t in e.vars)){t in o||(o[t]=rt);continue}const n=e.vars[t]??null;Q(n)?o[t]=y.createFromGraphic(n,e.timeZone??null):o[t]=n}return{lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??lt,abortSignal:e.abortSignal??t,timeZone:e.timeZone??null,spatialReference:r,track:e.track,globalScope:o,localStack:[],depthCounter:{depth:1},symbolMetadata:p,moduleFactory:l,moduleFactoryMap:f,moduleSingletons:Object.create(null)}}};return new Function("context",m).bind(g)}async function ct(){return nt([await(import("./functions/geomasync.js"))],"async"),!0}class ut extends n{constructor(e){super(),this.moduleContext=e}hasGlobal(t){const n=this.moduleContext.symbolMetadata.exports;return n.has(t)||n.has(e(t))}setGlobal(t,n){if(I(n))throw new d("AssignModuleFunction",null);const r=this.moduleContext.symbolMetadata.globals.get(e(t));if(null==r)throw new d("ModuleExportNotFound",null);this.moduleContext.globalScope[r]=n}global(t){const n=this.moduleContext.symbolMetadata.globals.get(e(t));if(null==n)throw new d("ModuleExportNotFound",null);const r=this.moduleContext.globalScope,o=st.requireInitialized(r[n]);if(I(o)&&!(o instanceof $)){const e=new $;return e.fn=o,e.parameterEvaluator=ue,e.context=this.moduleContext,r[n]=e,e}return o}}function mt(e,n,o){const a=new r(null,e.loadedModules),s=me(e,o?tt.provided:et.provided,new Set,o,a,n);let l;l=o?["var runtimeCtx = this.prepare(context, true);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","return lang.__awaiter(this, void 0, void 0, function* () {"," function mainBody() {"," return lang.__awaiter(this, void 0, void 0, function* () {",` ${s.body}`," });"," }"," yield mainBody();"," return this.prepareModule(runtimeCtx);","});"].join("\n"):["var runtimeCtx = this.prepare(context, false);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","function mainBody() {",` ${s.body}`,"}","mainBody();","return this.prepareModule(runtimeCtx);"].join("\n");const{symbolMetadata:i,moduleFactoryMap:c}=s,u={lc:S,lang:st,prepareModule:e=>new ut(e),prepare(e,r){const o=e.spatialReference??H.WebMercator,a=r?new tt:new et;return{lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??lt,abortSignal:e.abortSignal??t,timeZone:e.timeZone??null,spatialReference:o,track:null,globalScope:a,localStack:[],depthCounter:e.depthCounter,symbolMetadata:i,moduleFactory:n,moduleFactoryMap:c,moduleSingletons:e.moduleSingletons}}};return new Function("context",l).bind(u)}export{ce as UserDefinedCompiledFunction,it as compileScript,ct as enableAsyncSupport,nt as extend};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{toSymbolId as e,neverAbortedSignal as t}from"./arcadeEnvironment.js";import{ArcadeModule as r}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import{collectDeclaredGlobalNames as o,collectDeclaredLocalNames as s,flattenAccessChain as i}from"./compilerUtils.js";import{getNestedOptionalValue as a,getGeometryKeys as l,getGeometryMember as c,tryGetMember as u,getMember as f}from"./containerUtils.js";import p from"./Dictionary.js";import{ArcadeExecutionError as h,ensureLocatableError as d}from"./executionError.js";import{Feature as w}from"./Feature.js";import{NativeFunction as m,ArcadeFunction as g,ScopeMarshalledFunction as b,wrapModuleScopedResponse as y}from"./FunctionWrapper.js";import{R as v,I as x,u as S,i as R,C as F,D as k,x as j,E as I,g as O,B as A,d as C,z as N,v as E,w as M,y as B,A as U,h as G}from"../chunks/languageUtils.js";import{addFunctionDeclaration as z}from"./treeAnalysis.js";import{A as D}from"../chunks/array.js";import{registerFunctions as L}from"./functions/date.js";import{registerFunctions as _}from"./functions/feature.js";import{registerFunctions as Z}from"./functions/geometry.js";import{registerFunctions as q}from"./functions/geomsync.js";import{registerFunctions as W}from"./functions/maths.js";import{registerFunctions as P}from"./functions/stats.js";import{registerFunctions as V}from"./functions/string.js";import{registerFunctions as T}from"./functions/track.js";import K from"../core/Logger.js";import Y from"../geometry/SpatialReference.js";import{isGraphic as $}from"../support/graphicInstanceUtils.js";import{isBoolean as H,isArray as J,isString as Q,isNumber as X}from"../support/guards.js";const ee=()=>K.getLogger("esri.arcade.arcadeRuntime"),te=Symbol("uninitialized");function re(e){if(e===te)throw new h("InvalidIdentifier",null)}function ne(e){return re(e),e}function oe(t,r){const n=e(r);if(null!==t.localScope){const e=t.localScope[n];if(void 0!==e)return{scope:t.localScope,id:n,var:e}}const o=t.globalScope[n];if(void 0!==o)return{scope:t.globalScope,id:n,var:o};throw new h("InvalidIdentifier",r)}function se(t,r,n="InvalidIdentifier"){const o=e(r);if(null!==t.localScope){const e=t.localScope[o];if(void 0!==e)return re(e),e.value}const s=t.globalScope[o];if(void 0!==s)return re(s),s.value;throw new h(n,r)}const ie=function(){};ie.prototype=Object.freeze(Object.create(null));class ae extends g{constructor(e,t,r,n){super(),this.definition=e,this.context=t,this._params=r,this._locals=n}get debugName(){return null}createFunction(e){return(...t)=>{const r={spatialReference:this.context.spatialReference,console:this.context.console,services:this.context.services,timeZone:this.context.timeZone??null,lrucache:this.context.lrucache,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,abortSignal:this.context.abortSignal,localScope:new ie,depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope,track:this.context.track};if(r.depthCounter.depth>64)throw new h("MaximumCallDepth",null);return le(r,this.definition.body,this._params,this._locals,t,null)}}call(e,t){return fe(e,t,(r,n,o)=>{const s={spatialReference:e.spatialReference,services:e.services,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,timeZone:e.timeZone??null,console:e.console,lrucache:e.lrucache,interceptor:e.interceptor,abortSignal:e.abortSignal,localScope:new ie,track:e.track};if(s.depthCounter.depth>64)throw new h("MaximumCallDepth",t);return le(s,this.definition.body,this._params,this._locals,o,t)})}marshalledCall(e,t,r,n){return n(e,t,(o,s,i)=>{const a={spatialReference:e.spatialReference,globalScope:r.globalScope,services:e.services,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,abortSignal:e.abortSignal,localScope:new ie,track:e.track};return i=i.map(t=>!R(t)||t instanceof b?t:y(t,e,n)),y(le(a,this.definition.body,this._params,this._locals,i,t),r,n)})}}function le(e,t,r,n,o,s){try{if(r.length!==o.length)throw new h("WrongNumberOfParameters",s);if(null!=e.localScope){for(let t=0;t<r.length;t++)e.localScope[r[t]]={value:o[t]};for(const t of n)e.localScope[t]=te}const i=he(e,t);if(i instanceof v)return i.value;if(i===F)throw new h("UnexpectedToken",s);if(i===k)throw new h("UnexpectedToken",s);return i instanceof x?i.value:i}catch(i){throw i}}class ce extends r{constructor(e){super(),this.moduleGlobalContext=e}global(t){const r=e(t);if(!this.moduleGlobalContext.exports.has(r))throw new h("ModuleExportNotFound",null);const n=this.moduleGlobalContext.globalScope[r];if(re(n),R(n.value)&&!(n.value instanceof b)){const e=new b;return e.fn=n.value,e.parameterEvaluator=fe,e.context=this.moduleGlobalContext,this.moduleGlobalContext.globalScope[r]={value:e},e}return n.value}setGlobal(t,r){if(R(r))throw new h("AssignModuleFunction",null);const n=e(t);if(!this.moduleGlobalContext.exports.has(n))throw new h("ModuleExportNotFound",null);this.moduleGlobalContext.globalScope[n]={value:r}}hasGlobal(t){return this.moduleGlobalContext.exports.has(e(t))}static load(e,r){const{globals:s,exports:i}=o(r),a=new Xe;for(const t of s.keys())t in a||(a[t]=te);const l=e.spatialReference??Y.WebMercator,c={lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??tt,abortSignal:t,timeZone:e.timeZone??null,spatialReference:l,track:e.track,depthCounter:{depth:1},libraryResolver:new n(e.libraryResolver._moduleSingletons,r.loadedModules),exports:i,localScope:null,globalScope:a};return ke(c,r),new ce(c)}}function ue(e,t){const r=[];for(let n=0;n<t.arguments.length;n++)r.push(pe(e,t.arguments[n]));return r}function fe(e,t,r){try{return!0===t.preparsed?r(e,null,t.arguments):r(e,t,ue(e,t))}catch(n){throw n}}function pe(e,t){try{switch(t.type){case"AssignmentExpression":return Se(e,t);case"UpdateExpression":return ve(e,t);case"TemplateLiteral":return qe(e,t);case"Identifier":return We(e,t);case"MemberExpression":return Ee(e,t);case"Literal":return t.value;case"CallExpression":return Pe(e,t);case"UnaryExpression":return ze(e,t);case"BinaryExpression":return Le(e,t);case"LogicalExpression":return _e(e,t);case"ArrayExpression":return De(e,t);case"ObjectExpression":return de(e,t);case"MemberAccessChainExpression":return Ge(e,t);case"SafeMemberExpression":throw ee().error("SafeMemberExpression outside of MemberAccessChainExpression"),new h("Unrecognized",t);default:throw new h("Unrecognized",t)}}catch(r){throw d(r,t)}}function he(e,t){switch(t.type){case"EmptyStatement":return j;case"VariableDeclaration":return Ce(e,t);case"ImportDeclaration":return Oe(e,t);case"ExportNamedDeclaration":return Ae(e,t);case"BlockStatement":return ke(e,t);case"FunctionDeclaration":return Ie(e,t);case"ReturnStatement":return je(e,t);case"IfStatement":return Fe(e,t);case"ExpressionStatement":return Re(e,t);case"BreakStatement":return F;case"ContinueStatement":return k;case"ForStatement":return ge(e,t);case"ForInStatement":return we(e,t);case"ForOfStatement":return me(e,t);case"WhileStatement":return be(e,t);default:throw new h("Unrecognized",t)}}function de(e,t){const r=Object.create(null),n=new Map;for(let s=0;s<t.properties.length;s++){const o=t.properties[s],i="Identifier"===o.key.type?o.key.name:pe(e,o.key),a=pe(e,o.value);if(R(a))throw new h("NoFunctionInDictionary",t);if(!1===Q(i))throw new h("KeyMustBeString",t);let l=i.toString();const c=l.toLowerCase();n.has(c)?l=n.get(c):n.set(c,l),r[l]=a===j?null:a}const o=new p(r);return o.immutable=!1,o}function we(e,t){const r=pe(e,t.right);"VariableDeclaration"===t.left.type&&Ce(e,t.left);const n=oe(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);if(J(r)||Q(r)){const o=r.length;for(let r=0;r<o;r++){n.scope[n.id]={value:r};const o=he(e,t.body);if(o===F)break;if(o instanceof v)return o}return j}if(O(r)){for(let o=0;o<r.length();o++){n.scope[n.id]={value:o};const r=he(e,t.body);if(r===F)break;if(r instanceof v)return r}return j}if(r instanceof p||A(r)){const o=r.keys();for(let r=0;r<o.length;r++){n.scope[n.id]={value:o[r]};const s=he(e,t.body);if(s===F)break;if(s instanceof v)return s}return j}if(C(r)){for(const o of l(r)){n.scope[n.id]={value:o};const r=he(e,t.body);if(r===F)break;if(r instanceof v)return r}return j}return j}function me(e,t){const r=pe(e,t.right);"VariableDeclaration"===t.left.type&&he(e,t.left);const n=oe(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);if(J(r)||Q(r)){const o=r.length;for(let s=0;s<o;s++){if(s>=r.length)throw new h("OutOfBounds",t);n.scope[n.id]={value:r[s]};const o=he(e,t.body);if(o===F)break;if(o instanceof v)return o}return j}if(O(r)){for(let o=0;o<r.length();o++){n.scope[n.id]={value:r.get(o)};const s=he(e,t.body);if(s===F)break;if(s instanceof v)return s}return j}if(r instanceof p||A(r)){for(const o of r.keys()){const s=r.field(o);n.scope[n.id]={value:p.containerEntry(o,s)};const i=he(e,t.body);if(i===F)break;if(i instanceof v)return i}return j}if(C(r)){for(const o of l(r)){const s=c(r,o);n.scope[n.id]={value:p.containerEntry(o,s)};const i=he(e,t.body);if(i===F)break;if(i instanceof v)return i}return j}return j}function ge(e,t){null!==t.init&&("VariableDeclaration"===t.init.type?he(e,t.init):pe(e,t.init));const r={testResult:!0,lastAction:j};do{ye(e,t,r)}while(!0===r.testResult);return r.lastAction instanceof v?r.lastAction:j}function be(e,t){const r={testResult:!0,lastAction:j};if(r.testResult=pe(e,t.test),!1===r.testResult)return j;if(!0!==r.testResult)throw new h("BooleanConditionRequired",t);for(;!0===r.testResult&&(r.lastAction=he(e,t.body),r.lastAction!==F)&&!(r.lastAction instanceof v);)if(r.testResult=pe(e,t.test),!0!==r.testResult&&!1!==r.testResult)throw new h("BooleanConditionRequired",t);return r.lastAction instanceof v?r.lastAction:j}function ye(e,t,r){if(null!==t.test){if(r.testResult=pe(e,t.test),!1===r.testResult)return;if(!0!==r.testResult)throw new h("BooleanConditionRequired",t)}r.lastAction=he(e,t.body),r.lastAction!==F?r.lastAction instanceof v?r.testResult=!1:null!==t.update&&pe(e,t.update):r.testResult=!1}function ve(e,t){if("CallExpression"===t.argument.type)throw new h("NeverReach",t);let r;if("MemberExpression"===t.argument.type){const n=pe(e,t.argument.object);let o;if(!0===t.argument.computed)o=pe(e,t.argument.property);else{if("Identifier"!==t.argument.property.type)throw new h("Unrecognized",t);o=t.argument.property.name}if(J(n)){if(!X(o))throw new h("ArrayAccessMustBeNumber",t);if(o<0&&(o=n.length+o),o<0||o>=n.length)throw new h("OutOfBounds",t);r=E(n[o]),n[o]="++"===t.operator?r+1:r-1}else if(n instanceof p){if(!1===Q(o))throw new h("KeyAccessorMustBeString",t);if(!0!==n.hasField(o))throw new h("FieldNotFound",t,{key:o});r=E(n.field(o)),n.setField(o,"++"===t.operator?r+1:r-1)}else if(G(n)){if(!1===Q(o))throw new h("KeyAccessorMustBeString",t);if(!0!==n.hasField(o))throw new h("FieldNotFound",t,{key:o});r=E(n.field(o)),n.setField(o,"++"===t.operator?r+1:r-1)}else{if(O(n))throw new h("Immutable",t);if(!(n instanceof ce))throw new h("InvalidParameter",t);if(!1===Q(o))throw new h("ModuleAccessorMustBeString",t);if(!0!==n.hasGlobal(o))throw new h("ModuleExportNotFound",t);r=E(n.global(o)),n.setGlobal(o,"++"===t.operator?r+1:r-1)}return!1===t.prefix?r:"++"===t.operator?r+1:r-1}const n=oe(e,t.argument);r=E(ne(n.var).value);const o="++"===t.operator?r+1:r-1;return n.scope[n.id]={value:o},!1===t.prefix?r:"++"===t.operator?r+1:r-1}function xe(e,t,r,n){switch(t){case"=":return e===j?null:e;case"/=":return E(r)/E(e);case"*=":return E(r)*E(e);case"-=":return E(r)-E(e);case"+=":return Q(r)||Q(e)?M(r)+M(e):E(r)+E(e);case"%=":return E(r)%E(e);default:throw new h("UnsupportedOperator",n)}}function Se(e,t){if("MemberExpression"===t.left.type){const r=pe(e,t.left.object);let n;if(!0===t.left.computed)n=pe(e,t.left.property);else{if("Identifier"!==t.left.property.type)throw new h("InvalidIdentifier",t);n=t.left.property.name}const o=pe(e,t.right);if(J(r)){if(!X(n))throw new h("ArrayAccessMustBeNumber",t);if(n<0&&(n=r.length+n),n<0||n>r.length)throw new h("OutOfBounds",t);if(n===r.length){if("="!==t.operator)throw new h("OutOfBounds",t);r[n]=xe(o,t.operator,r[n],t)}else r[n]=xe(o,t.operator,r[n],t)}else if(r instanceof p){if(!1===Q(n))throw new h("KeyAccessorMustBeString",t);if(!0===r.hasField(n))r.setField(n,xe(o,t.operator,r.field(n),t));else{if("="!==t.operator)throw new h("FieldNotFound",t,{key:n});r.setField(n,xe(o,t.operator,null,t))}}else if(G(r)){if(!1===Q(n))throw new h("KeyAccessorMustBeString",t);if(!0===r.hasField(n))r.setField(n,xe(o,t.operator,r.field(n),t));else{if("="!==t.operator)throw new h("FieldNotFound",t,{key:n});r.setField(n,xe(o,t.operator,null,t))}}else{if(O(r))throw new h("Immutable",t);if(!(r instanceof ce))throw new h("InvalidIdentifier",t);if(!1===Q(n))throw new h("ModuleAccessorMustBeString",t);if(!0!==r.hasGlobal(n))throw new h("ModuleExportNotFound",t);r.setGlobal(n,xe(o,t.operator,r.global(n),t))}return j}const r=oe(e,t.left),n=pe(e,t.right);return r.scope[r.id]={value:xe(n,t.operator,"="!==t.operator?ne(r.var).value:null,t)},j}function Re(e,t){const r=pe(e,t.expression);return r===j?j:new x(r)}function Fe(e,t){const r=pe(e,t.test);if(!0===r)return he(e,t.consequent);if(!1===r)return null!==t.alternate?he(e,t.alternate):j;throw new h("BooleanConditionRequired",t)}function ke(e,t){let r=j;for(let n=0;n<t.body.length;n++)if(r=he(e,t.body[n]),r instanceof v||r===F||r===k)return r;return r}function je(e,t){if(null===t.argument)return new v(j);const r=pe(e,t.argument);return new v(r)}function Ie(t,r){if(null!=t.localScope)throw ee().error("Function declarations are only valid in global scope."),new h("NeverReach",r);const n=e(r.id);if(!(n in t.globalScope))throw ee().error(`Function "${n}" not declared.`),new h("NeverReach",r);const o=s(r),i=r.params.map(t=>e(t)),a=Array.from(o.keys()).filter(e=>!i.includes(e));return t.globalScope[n]={value:new ae(r,t,i,a)},j}function Oe(e,t){const r=oe(e,t.specifiers[0].local),n=e.libraryResolver;if(null==n)throw ee().error("Internal error: module loader not initialized"),new h("NeverReach",t);const o=n.loadLibrary(r.id);let s;return n._moduleSingletons?.has(o.uri)?s=n._moduleSingletons.get(o.uri):(s=ce.load(e,o.syntax),n._moduleSingletons?.set(o.uri,s)),r.scope[r.id]={value:s},j}function Ae(e,t){return he(e,t.declaration),j}function Ce(e,t){for(let r=0;r<t.declarations.length;r++)Ne(e,t.declarations[r]);return j}function Ne(e,t){let r=null===t.init?null:pe(e,t.init);if(r===j&&(r=null),"Identifier"!==t.id.type)throw new h("InvalidIdentifier",t);const n=oe(e,t.id);n.scope[n.id]={value:r}}function Ee(e,t){return Me(e,pe(e,t.object),t)}function Me(e,t,r){const n=r.computed?pe(e,r.property):r.property.name;return f(t,n)}function Be(e,t,r){for(const n of r)switch(n.type){case"MemberExpression":t=Me(e,t,n);break;case"CallExpression":t=Ve(e,t,n);break;default:throw new h("Unrecognized",n)}return t}function Ue(e,t,r){const n=r.computed?pe(e,r.property):r.property.name;return u(t,n)}function Ge(e,t){const r=i(t);let n=pe(e,r.root);for(const o of r.sections){const t=Ue(e,n,o.checked);if(null==t)return null;n=Be(e,t,o.unchecked)}return n}function ze(e,t){try{const r=pe(e,t.argument);if(H(r)){if("!"===t.operator)return!r;if("-"===t.operator)return-1*E(r);if("+"===t.operator)return 1*E(r);if("~"===t.operator)return~E(r);throw new h("UnsupportUnaryOperator",t)}if("~"===t.operator)return~E(r);if("-"===t.operator)return-1*E(r);if("+"===t.operator)return 1*E(r);throw new h("UnsupportUnaryOperator",t)}catch(r){throw r}}function De(e,t){try{const r=[];for(let n=0;n<t.elements.length;n++){const o=pe(e,t.elements[n]);if(R(o))throw new h("NoFunctionInArray",t);o===j?r.push(null):r.push(o)}return r}catch(r){throw r}}function Le(e,t){try{const r=pe(e,t.left),n=pe(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return U(E(r),E(n),t.operator);case"==":return N(r,n);case"!=":return!N(r,n);case"<":case">":case"<=":case">=":return B(r,n,t.operator);case"+":return Q(r)||Q(n)?M(r)+M(n):E(r)+E(n);case"-":return E(r)-E(n);case"*":return E(r)*E(n);case"/":return E(r)/E(n);case"%":return E(r)%E(n);default:throw t.operator,new h("UnsupportedOperator",t)}}catch(r){throw r}}function _e(e,t){try{const r=pe(e,t.left);if(H(r))switch(t.operator){case"||":{if(!0===r)return r;const n=pe(e,t.right);if(H(n))return n;throw new h("LogicExpressionOrAnd",t)}case"&&":{if(!1===r)return r;const n=pe(e,t.right);if(H(n))return n;throw new h("LogicExpressionOrAnd",t)}default:throw t.operator,new h("LogicExpressionOrAnd",t)}throw new h("LogicalExpressionOnlyBoolean",t)}catch(r){throw r}}function Ze(e,t){if(R(e))throw new h("NoFunctionInTemplateLiteral",t);return e}function qe(e,t){let r="",n=0;for(const o of t.quasis)if(r+=o.value?o.value.cooked:"",!1===o.tail){r+=t.expressions[n]?M(Ze(pe(e,t.expressions[n]),t)):"",n++}return r}function We(e,t){return se(e,t)}function Pe(e,t){return Ve(e,"Identifier"===t.callee.type?se(e,t.callee,"FunctionNotFound"):pe(e,t.callee),t)}function Ve(e,t,r){if(R(t))return t.call(e,r);throw new h("CallNonFunction",r)}function Te(e,t){try{if(!0===t.preparsed)throw new h("NeverReach",null);const r=t.arguments;I(null===r?[]:r,3,3,t);const n=pe(e,r[0]);if(!1===H(n))throw new h("BooleanConditionRequired",t);return pe(e,!0===n?r[1]:r[2])}catch(r){throw r}}function Ke(e,t){try{if(!0===t.preparsed)throw new h("NeverReach",null);const r=t.arguments;I(null===r?[]:r,2,3,t);const n=pe(e,r[0]);if(3===r.length){const t=pe(e,r[1]),o=a(n,t);return null!=o&&""!==o?o:pe(e,r[2])}return null===n||""===n||void 0===n?pe(e,r[1]):n}catch(r){throw r}}function Ye(e,t){try{if(!0===t.preparsed)throw new h("NeverReach",null);const r=t.arguments;if(r.length<2)throw new h("WrongNumberOfParameters",t);if(2===r.length)return pe(e,r[1]);{if((r.length-1)%2==0)throw new h("WrongNumberOfParameters",t);const n=pe(e,r[0]);return $e(e,t,1,n)}}catch(r){throw r}}function $e(e,t,r,n){try{const o=t.arguments,s=pe(e,o[r]);if(N(s,n))return pe(e,o[r+1]);{const s=o.length-r;return 1===s?pe(e,o[r]):2===s?null:3===s?pe(e,o[r+2]):$e(e,t,r+2,n)}}catch(o){throw o}}function He(e,t){try{if(!0===t.preparsed)throw new h("NeverReach",null);const r=t.arguments;if(r.length<3)throw new h("WrongNumberOfParameters",t);if(r.length%2==0)throw new h("WrongNumberOfParameters",t);const n=pe(e,r[0]);if(!1===H(n))throw new h("BooleanConditionRequired",r[0]);return Je(e,t,0,n)}catch(r){throw r}}function Je(e,t,r,n){try{const o=t.arguments;if(!0===n)return pe(e,o[r+1]);if(3===o.length-r)return pe(e,o[r+2]);{const n=pe(e,o[r+2]);if(!1===H(n))throw new h("BooleanConditionRequired",o[r+2]);return Je(e,t,r+2,n)}}catch(o){throw o}}function Qe(){const e=Object.create(null);L(e,fe),V(e,fe),_(e,fe,We),W(e,fe),Z(e,fe),P(e,fe),q(e,fe),T(e,fe),e.iif=Te,e.defaultvalue=Ke,e.decode=Ye,e.when=He;const t=function(){this.textformatting={value:p.textFormatting()}};t.prototype=Object.create(null),t.prototype.infinity=Object.freeze({value:Number.POSITIVE_INFINITY}),t.prototype.nan=Object.freeze({value:Number.NaN}),t.prototype.pi=Object.freeze({value:Math.PI});for(const[r,n]of Object.entries(e))t.prototype[r]=Object.freeze({value:new m(n)});return t}const Xe=Qe();function et(e){const t={mode:"sync",compiled:!1,functions:Object.create(null),signatures:[],standardFunction:fe,evaluateIdentifier:We};for(let r=0;r<e.length;r++)e[r].registerFunctions(t);for(const[r,n]of Object.entries(t.functions))Xe.prototype[r]=Object.freeze({value:new m(n)});for(let r=0;r<t.signatures.length;r++)z(t.signatures[r],"sync")}function tt(e){console.log(e)}function rt(r,s){const i=new Set(Object.keys(s?.vars||{}).map(t=>e(t))),a=new Set(Object.keys(s?.customfunctions||{}).map(t=>e(t))),{globals:l,exports:c}=o(r),u=new Set(l.keys());return e=>{const o=e.spatialReference??Y.WebMercator;let s=null;r.usesModules&&(s=new n(new Map,r.loadedModules));const l=new Xe;for(const t of a)null!=e.customfunctions&&t in e.customfunctions?l[t]={value:new m(e.customfunctions[t])}:l[t]=te;for(const t of i){if(null==e.vars||!(t in e.vars)){t in l||(l[t]=te);continue}const r=e.vars[t]??null;$(r)?l[t]={value:w.createFromGraphic(r,e.timeZone??null)}:l[t]={value:r}}for(const t of u)t in l||(l[t]=te);const f=ke({lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??tt,abortSignal:t,timeZone:e.timeZone??null,spatialReference:o,track:e.track,depthCounter:{depth:1},libraryResolver:s,exports:c,localScope:null,globalScope:l},r);if(f instanceof v||f instanceof x){const e=f.value;if(S(e))return null;if(R(e))throw new h("IllegalResult",null);return e}if(S(f))return null;if(f===F)throw new h("IllegalResult",null);if(f===k)throw new h("IllegalResult",null);throw new h("NeverReach",null)}}function nt(e,t){return rt(e,t)(t)}et([D]);export{nt as executeScript,et as extend,rt as prepareScript};
2
+ import{toSymbolId as e,neverAbortedSignal as t}from"./arcadeEnvironment.js";import{ArcadeModule as n}from"./ArcadeModule.js";import{ArcadeModuleLoader as r}from"./ArcadeModuleLoader.js";import{collectDeclaredGlobalNames as o,collectDeclaredLocalNames as s,flattenAccessChain as i}from"./compilerUtils.js";import{getNestedOptionalValue as a,getGeometryKeys as c,getGeometryMember as l,updateMember as u,tryGetMember as f,getMember as p}from"./containerUtils.js";import h from"./Dictionary.js";import{ArcadeExecutionError as d,ensureLocatableError as w}from"./executionError.js";import{Feature as m}from"./Feature.js";import{NativeFunction as g,ArcadeFunction as b,ScopeMarshalledFunction as y,wrapModuleScopedResponse as v}from"./FunctionWrapper.js";import{R as x,I as S,u as R,i as j,C as k,D as F,x as I,E as C,g as O,B as E,d as N,z as A,v as M,w as B,y as U,A as z,h as D}from"../chunks/languageUtils.js";import{addFunctionDeclaration as G}from"./treeAnalysis.js";import{A as L}from"../chunks/array.js";import{registerFunctions as _}from"./functions/date.js";import{registerFunctions as Z}from"./functions/feature.js";import{registerFunctions as q}from"./functions/geometry.js";import{registerFunctions as W}from"./functions/geomsync.js";import{registerFunctions as P}from"./functions/maths.js";import{registerFunctions as V}from"./functions/stats.js";import{registerFunctions as T}from"./functions/string.js";import{registerFunctions as K}from"./functions/track.js";import Y from"../core/Logger.js";import $ from"../geometry/SpatialReference.js";import{isGraphic as H}from"../support/graphicInstanceUtils.js";import{isBoolean as J,isArray as Q,isString as X,isNumber as ee}from"../support/guards.js";const te=()=>Y.getLogger("esri.arcade.arcadeRuntime"),ne=Symbol("uninitialized");function re(e){if(e===ne)throw new d("InvalidIdentifier",null)}function oe(e){return re(e),e}function se(t,n){const r=e(n);if(null!==t.localScope){const e=t.localScope[r];if(void 0!==e)return{scope:t.localScope,id:r,var:e}}const o=t.globalScope[r];if(void 0!==o)return{scope:t.globalScope,id:r,var:o};throw new d("InvalidIdentifier",n)}function ie(t,n,r="InvalidIdentifier"){const o=e(n);if(null!==t.localScope){const e=t.localScope[o];if(void 0!==e)return re(e),e.value}const s=t.globalScope[o];if(void 0!==s)return re(s),s.value;throw new d(r,n)}const ae=function(){};ae.prototype=Object.freeze(Object.create(null));class ce extends b{constructor(e,t,n,r){super(),this.definition=e,this.context=t,this._params=n,this._locals=r}get debugName(){return null}createFunction(e){return(...t)=>{const n={spatialReference:this.context.spatialReference,console:this.context.console,services:this.context.services,timeZone:this.context.timeZone??null,lrucache:this.context.lrucache,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,abortSignal:this.context.abortSignal,localScope:new ae,depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope,track:this.context.track};if(n.depthCounter.depth>64)throw new d("MaximumCallDepth",null);return le(n,this.definition.body,this._params,this._locals,t,null)}}call(e,t){return pe(e,t,(n,r,o)=>{const s={spatialReference:e.spatialReference,services:e.services,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,timeZone:e.timeZone??null,console:e.console,lrucache:e.lrucache,interceptor:e.interceptor,abortSignal:e.abortSignal,localScope:new ae,track:e.track};if(s.depthCounter.depth>64)throw new d("MaximumCallDepth",t);return le(s,this.definition.body,this._params,this._locals,o,t)})}marshalledCall(e,t,n,r){return r(e,t,(o,s,i)=>{const a={spatialReference:e.spatialReference,globalScope:n.globalScope,services:e.services,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,timeZone:e.timeZone??null,lrucache:e.lrucache,interceptor:e.interceptor,abortSignal:e.abortSignal,localScope:new ae,track:e.track};return i=i.map(t=>!j(t)||t instanceof y?t:v(t,e,r)),v(le(a,this.definition.body,this._params,this._locals,i,t),n,r)})}}function le(e,t,n,r,o,s){try{if(n.length!==o.length)throw new d("WrongNumberOfParameters",s);if(null!=e.localScope){for(let t=0;t<n.length;t++)e.localScope[n[t]]={value:o[t]};for(const t of r)e.localScope[t]=ne}const i=de(e,t);if(i instanceof x)return i.value;if(i===k)throw new d("UnexpectedToken",s);if(i===F)throw new d("UnexpectedToken",s);return i instanceof S?i.value:i}catch(i){throw i}}class ue extends n{constructor(e){super(),this.moduleGlobalContext=e}global(t){const n=e(t);if(!this.moduleGlobalContext.exports.has(n))throw new d("ModuleExportNotFound",null);const r=this.moduleGlobalContext.globalScope[n];if(re(r),j(r.value)&&!(r.value instanceof y)){const e=new y;return e.fn=r.value,e.parameterEvaluator=pe,e.context=this.moduleGlobalContext,this.moduleGlobalContext.globalScope[n]={value:e},e}return r.value}setGlobal(t,n){if(j(n))throw new d("AssignModuleFunction",null);const r=e(t);if(!this.moduleGlobalContext.exports.has(r))throw new d("ModuleExportNotFound",null);this.moduleGlobalContext.globalScope[r]={value:n}}hasGlobal(t){return this.moduleGlobalContext.exports.has(e(t))}static load(e,n){const{globals:s,exports:i}=o(n),a=new et;for(const t of s.keys())t in a||(a[t]=ne);const c=e.spatialReference??$.WebMercator,l={lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??nt,abortSignal:t,timeZone:e.timeZone??null,spatialReference:c,track:e.track,depthCounter:{depth:1},libraryResolver:new r(e.libraryResolver._moduleSingletons,n.loadedModules),exports:i,localScope:null,globalScope:a};return Fe(l,n),new ue(l)}}function fe(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(he(e,t.arguments[r]));return n}function pe(e,t,n){try{return!0===t.preparsed?n(e,null,t.arguments):n(e,t,fe(e,t))}catch(r){throw r}}function he(e,t){try{switch(t.type){case"AssignmentExpression":return Re(e,t);case"UpdateExpression":return xe(e,t);case"TemplateLiteral":return We(e,t);case"Identifier":return Pe(e,t);case"MemberExpression":return Me(e,t);case"Literal":return t.value;case"CallExpression":return Ve(e,t);case"UnaryExpression":return Ge(e,t);case"BinaryExpression":return _e(e,t);case"LogicalExpression":return Ze(e,t);case"ArrayExpression":return Le(e,t);case"ObjectExpression":return we(e,t);case"MemberAccessChainExpression":return De(e,t);case"SafeMemberExpression":throw te().error("SafeMemberExpression outside of MemberAccessChainExpression"),new d("Unrecognized",t);default:throw new d("Unrecognized",t)}}catch(n){throw w(n,t)}}function de(e,t){switch(t.type){case"EmptyStatement":return I;case"VariableDeclaration":return Ne(e,t);case"ImportDeclaration":return Oe(e,t);case"ExportNamedDeclaration":return Ee(e,t);case"BlockStatement":return Fe(e,t);case"FunctionDeclaration":return Ce(e,t);case"ReturnStatement":return Ie(e,t);case"IfStatement":return ke(e,t);case"ExpressionStatement":return je(e,t);case"BreakStatement":return k;case"ContinueStatement":return F;case"ForStatement":return be(e,t);case"ForInStatement":return me(e,t);case"ForOfStatement":return ge(e,t);case"WhileStatement":return ye(e,t);default:throw new d("Unrecognized",t)}}function we(e,t){const n=Object.create(null),r=new Map;for(let s=0;s<t.properties.length;s++){const o=t.properties[s],i="Identifier"===o.key.type?o.key.name:he(e,o.key),a=he(e,o.value);if(j(a))throw new d("NoFunctionInDictionary",t);if(!1===X(i))throw new d("KeyMustBeString",t);let c=i.toString();const l=c.toLowerCase();r.has(l)?c=r.get(l):r.set(l,c),n[c]=a===I?null:a}const o=new h(n);return o.immutable=!1,o}function me(e,t){const n=he(e,t.right);"VariableDeclaration"===t.left.type&&Ne(e,t.left);const r=se(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);if(Q(n)||X(n)){const o=n.length;for(let n=0;n<o;n++){r.scope[r.id]={value:n};const o=de(e,t.body);if(o===k)break;if(o instanceof x)return o}return I}if(O(n)){for(let o=0;o<n.length();o++){r.scope[r.id]={value:o};const n=de(e,t.body);if(n===k)break;if(n instanceof x)return n}return I}if(n instanceof h||E(n)){const o=n.keys();for(let n=0;n<o.length;n++){r.scope[r.id]={value:o[n]};const s=de(e,t.body);if(s===k)break;if(s instanceof x)return s}return I}if(N(n)){for(const o of c(n)){r.scope[r.id]={value:o};const n=de(e,t.body);if(n===k)break;if(n instanceof x)return n}return I}return I}function ge(e,t){const n=he(e,t.right);"VariableDeclaration"===t.left.type&&de(e,t.left);const r=se(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);if(Q(n)||X(n)){const o=n.length;for(let s=0;s<o;s++){if(s>=n.length)throw new d("OutOfBounds",t);r.scope[r.id]={value:n[s]};const o=de(e,t.body);if(o===k)break;if(o instanceof x)return o}return I}if(O(n)){for(let o=0;o<n.length();o++){r.scope[r.id]={value:n.get(o)};const s=de(e,t.body);if(s===k)break;if(s instanceof x)return s}return I}if(n instanceof h||E(n)){for(const o of n.keys()){const s=n.field(o);r.scope[r.id]={value:h.containerEntry(o,s)};const i=de(e,t.body);if(i===k)break;if(i instanceof x)return i}return I}if(N(n)){for(const o of c(n)){const s=l(n,o);r.scope[r.id]={value:h.containerEntry(o,s)};const i=de(e,t.body);if(i===k)break;if(i instanceof x)return i}return I}return I}function be(e,t){null!==t.init&&("VariableDeclaration"===t.init.type?de(e,t.init):he(e,t.init));const n={testResult:!0,lastAction:I};do{ve(e,t,n)}while(!0===n.testResult);return n.lastAction instanceof x?n.lastAction:I}function ye(e,t){const n={testResult:!0,lastAction:I};if(n.testResult=he(e,t.test),!1===n.testResult)return I;if(!0!==n.testResult)throw new d("BooleanConditionRequired",t);for(;!0===n.testResult&&(n.lastAction=de(e,t.body),n.lastAction!==k)&&!(n.lastAction instanceof x);)if(n.testResult=he(e,t.test),!0!==n.testResult&&!1!==n.testResult)throw new d("BooleanConditionRequired",t);return n.lastAction instanceof x?n.lastAction:I}function ve(e,t,n){if(null!==t.test){if(n.testResult=he(e,t.test),!1===n.testResult)return;if(!0!==n.testResult)throw new d("BooleanConditionRequired",t)}n.lastAction=de(e,t.body),n.lastAction!==k?n.lastAction instanceof x?n.testResult=!1:null!==t.update&&he(e,t.update):n.testResult=!1}function xe(e,t){const n=t.argument;if("CallExpression"===n.type)throw new d("NeverReach",t);if("MemberExpression"===n.type){const r=he(e,n.object);let o;if(!0===n.computed)o=he(e,n.property);else{if("Identifier"!==n.property.type)throw new d("Unrecognized",t);o=n.property.name}return u(r,o,"++"===t.operator,t.prefix)}const r=se(e,n),o=oe(r.var).value,s=M(o)+("++"===t.operator?1:-1);return r.scope[r.id]={value:s},t.prefix?s:o}function Se(e,t,n,r){switch(t){case"=":return e===I?null:e;case"/=":return M(n)/M(e);case"*=":return M(n)*M(e);case"-=":return M(n)-M(e);case"+=":return X(n)||X(e)?B(n)+B(e):M(n)+M(e);case"%=":return M(n)%M(e);default:throw new d("UnsupportedOperator",r)}}function Re(e,t){if("MemberExpression"===t.left.type){const n=he(e,t.left.object);let r;if(!0===t.left.computed)r=he(e,t.left.property);else{if("Identifier"!==t.left.property.type)throw new d("InvalidIdentifier",t);r=t.left.property.name}const o=he(e,t.right);if(Q(n)){if(!ee(r))throw new d("ArrayAccessMustBeNumber",t);if(r<0&&(r=n.length+r),r<0||r>n.length)throw new d("OutOfBounds",t);if(r===n.length){if("="!==t.operator)throw new d("OutOfBounds",t);n[r]=Se(o,t.operator,n[r],t)}else n[r]=Se(o,t.operator,n[r],t)}else if(n instanceof h){if(!1===X(r))throw new d("KeyAccessorMustBeString",t);if(!0===n.hasField(r))n.setField(r,Se(o,t.operator,n.field(r),t));else{if("="!==t.operator)throw new d("FieldNotFound",t,{key:r});n.setField(r,Se(o,t.operator,null,t))}}else if(D(n)){if(!1===X(r))throw new d("KeyAccessorMustBeString",t);if(!0===n.hasField(r))n.setField(r,Se(o,t.operator,n.field(r),t));else{if("="!==t.operator)throw new d("FieldNotFound",t,{key:r});n.setField(r,Se(o,t.operator,null,t))}}else{if(O(n))throw new d("Immutable",t);if(!(n instanceof ue))throw new d("InvalidIdentifier",t);if(!1===X(r))throw new d("ModuleAccessorMustBeString",t);if(!0!==n.hasGlobal(r))throw new d("ModuleExportNotFound",t);n.setGlobal(r,Se(o,t.operator,n.global(r),t))}return I}const n=se(e,t.left),r=he(e,t.right);return n.scope[n.id]={value:Se(r,t.operator,"="!==t.operator?oe(n.var).value:null,t)},I}function je(e,t){const n=he(e,t.expression);return n===I?I:new S(n)}function ke(e,t){const n=he(e,t.test);if(!0===n)return de(e,t.consequent);if(!1===n)return null!==t.alternate?de(e,t.alternate):I;throw new d("BooleanConditionRequired",t)}function Fe(e,t){let n=I;for(let r=0;r<t.body.length;r++)if(n=de(e,t.body[r]),n instanceof x||n===k||n===F)return n;return n}function Ie(e,t){if(null===t.argument)return new x(I);const n=he(e,t.argument);return new x(n)}function Ce(t,n){if(null!=t.localScope)throw te().error("Function declarations are only valid in global scope."),new d("NeverReach",n);const r=e(n.id);if(!(r in t.globalScope))throw te().error(`Function "${r}" not declared.`),new d("NeverReach",n);const o=s(n),i=n.params.map(t=>e(t)),a=Array.from(o.keys()).filter(e=>!i.includes(e));return t.globalScope[r]={value:new ce(n,t,i,a)},I}function Oe(e,t){const n=se(e,t.specifiers[0].local),r=e.libraryResolver;if(null==r)throw te().error("Internal error: module loader not initialized"),new d("NeverReach",t);const o=r.loadLibrary(n.id);let s;return r._moduleSingletons?.has(o.uri)?s=r._moduleSingletons.get(o.uri):(s=ue.load(e,o.syntax),r._moduleSingletons?.set(o.uri,s)),n.scope[n.id]={value:s},I}function Ee(e,t){return de(e,t.declaration),I}function Ne(e,t){for(let n=0;n<t.declarations.length;n++)Ae(e,t.declarations[n]);return I}function Ae(e,t){let n=null===t.init?null:he(e,t.init);if(n===I&&(n=null),"Identifier"!==t.id.type)throw new d("InvalidIdentifier",t);const r=se(e,t.id);r.scope[r.id]={value:n}}function Me(e,t){return Be(e,he(e,t.object),t)}function Be(e,t,n){const r=n.computed?he(e,n.property):n.property.name;return p(t,r)}function Ue(e,t,n){for(const r of n)switch(r.type){case"MemberExpression":t=Be(e,t,r);break;case"CallExpression":t=Te(e,t,r);break;default:throw new d("Unrecognized",r)}return t}function ze(e,t,n){const r=n.computed?he(e,n.property):n.property.name;return f(t,r)}function De(e,t){const n=i(t);let r=he(e,n.root);for(const o of n.sections){const t=ze(e,r,o.checked);if(null==t)return null;r=Ue(e,t,o.unchecked)}return r}function Ge(e,t){try{const n=he(e,t.argument);if(J(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*M(n);if("+"===t.operator)return 1*M(n);if("~"===t.operator)return~M(n);throw new d("UnsupportUnaryOperator",t)}if("~"===t.operator)return~M(n);if("-"===t.operator)return-1*M(n);if("+"===t.operator)return 1*M(n);throw new d("UnsupportUnaryOperator",t)}catch(n){throw n}}function Le(e,t){try{const n=[];for(let r=0;r<t.elements.length;r++){const o=he(e,t.elements[r]);if(j(o))throw new d("NoFunctionInArray",t);o===I?n.push(null):n.push(o)}return n}catch(n){throw n}}function _e(e,t){try{const n=he(e,t.left),r=he(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return z(M(n),M(r),t.operator);case"==":return A(n,r);case"!=":return!A(n,r);case"<":case">":case"<=":case">=":return U(n,r,t.operator);case"+":return X(n)||X(r)?B(n)+B(r):M(n)+M(r);case"-":return M(n)-M(r);case"*":return M(n)*M(r);case"/":return M(n)/M(r);case"%":return M(n)%M(r);default:throw t.operator,new d("UnsupportedOperator",t)}}catch(n){throw n}}function Ze(e,t){try{const n=he(e,t.left);if(J(n))switch(t.operator){case"||":{if(!0===n)return n;const r=he(e,t.right);if(J(r))return r;throw new d("LogicExpressionOrAnd",t)}case"&&":{if(!1===n)return n;const r=he(e,t.right);if(J(r))return r;throw new d("LogicExpressionOrAnd",t)}default:throw t.operator,new d("LogicExpressionOrAnd",t)}throw new d("LogicalExpressionOnlyBoolean",t)}catch(n){throw n}}function qe(e,t){if(j(e))throw new d("NoFunctionInTemplateLiteral",t);return e}function We(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){n+=t.expressions[r]?B(qe(he(e,t.expressions[r]),t)):"",r++}return n}function Pe(e,t){return ie(e,t)}function Ve(e,t){return Te(e,"Identifier"===t.callee.type?ie(e,t.callee,"FunctionNotFound"):he(e,t.callee),t)}function Te(e,t,n){if(j(t))return t.call(e,n);throw new d("CallNonFunction",n)}function Ke(e,t){try{if(!0===t.preparsed)throw new d("NeverReach",null);const n=t.arguments;C(null===n?[]:n,3,3,t);const r=he(e,n[0]);if(!1===J(r))throw new d("BooleanConditionRequired",t);return he(e,!0===r?n[1]:n[2])}catch(n){throw n}}function Ye(e,t){try{if(!0===t.preparsed)throw new d("NeverReach",null);const n=t.arguments;C(null===n?[]:n,2,3,t);const r=he(e,n[0]);if(3===n.length){const t=he(e,n[1]),o=a(r,t);return null!=o&&""!==o?o:he(e,n[2])}return null===r||""===r||void 0===r?he(e,n[1]):r}catch(n){throw n}}function $e(e,t){try{if(!0===t.preparsed)throw new d("NeverReach",null);const n=t.arguments;if(n.length<2)throw new d("WrongNumberOfParameters",t);if(2===n.length)return he(e,n[1]);{if((n.length-1)%2==0)throw new d("WrongNumberOfParameters",t);const r=he(e,n[0]);return He(e,t,1,r)}}catch(n){throw n}}function He(e,t,n,r){try{const o=t.arguments,s=he(e,o[n]);if(A(s,r))return he(e,o[n+1]);{const s=o.length-n;return 1===s?he(e,o[n]):2===s?null:3===s?he(e,o[n+2]):He(e,t,n+2,r)}}catch(o){throw o}}function Je(e,t){try{if(!0===t.preparsed)throw new d("NeverReach",null);const n=t.arguments;if(n.length<3)throw new d("WrongNumberOfParameters",t);if(n.length%2==0)throw new d("WrongNumberOfParameters",t);const r=he(e,n[0]);if(!1===J(r))throw new d("BooleanConditionRequired",n[0]);return Qe(e,t,0,r)}catch(n){throw n}}function Qe(e,t,n,r){try{const o=t.arguments;if(!0===r)return he(e,o[n+1]);if(3===o.length-n)return he(e,o[n+2]);{const r=he(e,o[n+2]);if(!1===J(r))throw new d("BooleanConditionRequired",o[n+2]);return Qe(e,t,n+2,r)}}catch(o){throw o}}function Xe(){const e=Object.create(null);_(e,pe),T(e,pe),Z(e,pe,Pe),P(e,pe),q(e,pe),V(e,pe),W(e,pe),K(e,pe),e.iif=Ke,e.defaultvalue=Ye,e.decode=$e,e.when=Je;const t=function(){this.textformatting={value:h.textFormatting()}};t.prototype=Object.create(null),t.prototype.infinity=Object.freeze({value:Number.POSITIVE_INFINITY}),t.prototype.nan=Object.freeze({value:Number.NaN}),t.prototype.pi=Object.freeze({value:Math.PI});for(const[n,r]of Object.entries(e))t.prototype[n]=Object.freeze({value:new g(r)});return t}const et=Xe();function tt(e){const t={mode:"sync",compiled:!1,functions:Object.create(null),signatures:[],standardFunction:pe,evaluateIdentifier:Pe};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const[n,r]of Object.entries(t.functions))et.prototype[n]=Object.freeze({value:new g(r)});for(let n=0;n<t.signatures.length;n++)G(t.signatures[n],"sync")}function nt(e){console.log(e)}function rt(n,s){const i=new Set(Object.keys(s?.vars||{}).map(t=>e(t))),a=new Set(Object.keys(s?.customfunctions||{}).map(t=>e(t))),{globals:c,exports:l}=o(n),u=new Set(c.keys());return e=>{const o=e.spatialReference??$.WebMercator;let s=null;n.usesModules&&(s=new r(new Map,n.loadedModules));const c=new et;for(const t of a)null!=e.customfunctions&&t in e.customfunctions?c[t]={value:new g(e.customfunctions[t])}:c[t]=ne;for(const t of i){if(null==e.vars||!(t in e.vars)){t in c||(c[t]=ne);continue}const n=e.vars[t]??null;H(n)?c[t]={value:m.createFromGraphic(n,e.timeZone??null)}:c[t]={value:n}}for(const t of u)t in c||(c[t]=ne);const f=Fe({lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??nt,abortSignal:t,timeZone:e.timeZone??null,spatialReference:o,track:e.track,depthCounter:{depth:1},libraryResolver:s,exports:l,localScope:null,globalScope:c},n);if(f instanceof x||f instanceof S){const e=f.value;if(R(e))return null;if(j(e))throw new d("IllegalResult",null);return e}if(R(f))return null;if(f===k)throw new d("IllegalResult",null);if(f===F)throw new d("IllegalResult",null);throw new d("NeverReach",null)}}function ot(e,t){return rt(e,t)(t)}tt([L]);export{ot as executeScript,tt as extend,rt as prepareScript};