@arcgis/ai-components 5.2.0-next.10 → 5.2.0-next.100

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 (300) hide show
  1. package/LICENSE.md +4 -2
  2. package/README.md +2 -2
  3. package/dist/agent-utils/FunctionAgent.d.ts +2 -2
  4. package/dist/agent-utils/LLMAgent.d.ts +7 -4
  5. package/dist/agent-utils/LLMAgent.js +4 -2
  6. package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
  7. package/dist/agent-utils/WorkflowAgent.js +14 -15
  8. package/dist/agent-utils/index.d.ts +177 -0
  9. package/dist/agent-utils/index.js +167 -0
  10. package/dist/agent-utils/middlewares/trace.d.ts +2 -0
  11. package/dist/agent-utils/middlewares/trace.js +25 -33
  12. package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
  13. package/dist/agent-utils/types.d.ts +37 -8
  14. package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
  15. package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
  16. package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
  17. package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
  18. package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
  19. package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
  20. package/dist/agentic-workflow/AgenticWorkflowRuntime.d.ts +24 -0
  21. package/dist/agentic-workflow/Edge.d.ts +16 -0
  22. package/dist/agentic-workflow/WebAgent.d.ts +39 -0
  23. package/dist/agentic-workflow/jsonTypes.d.ts +189 -0
  24. package/dist/agentic-workflow/nodes/AgentNode.d.ts +28 -0
  25. package/dist/agentic-workflow/nodes/BaseNode.d.ts +35 -0
  26. package/dist/agentic-workflow/nodes/EndMessageNode.d.ts +25 -0
  27. package/dist/agentic-workflow/nodes/StartNode.d.ts +21 -0
  28. package/dist/agentic-workflow/nodes/tools/ArcgisTool.d.ts +21 -0
  29. package/dist/agentic-workflow/types.d.ts +29 -0
  30. package/dist/agents/tools/filter/clearFilters/adapter.d.ts +8 -0
  31. package/dist/agents/tools/filter/clearFilters/adapter.js +22 -0
  32. package/dist/agents/tools/filter/resetMap/adapter.d.ts +8 -0
  33. package/dist/agents/tools/filter/resetMap/adapter.js +22 -0
  34. package/dist/agents/tools/filter/setFeatureEffect/adapter.d.ts +8 -0
  35. package/dist/agents/tools/filter/setFeatureEffect/adapter.js +121 -0
  36. package/dist/agents/tools/help/listFields/adapter.d.ts +11 -0
  37. package/dist/agents/tools/help/listFields/adapter.js +30 -0
  38. package/dist/agents/tools/navigation/goToAddress/adapter.d.ts +10 -0
  39. package/dist/agents/tools/navigation/goToAddress/adapter.js +60 -0
  40. package/dist/agents/tools/navigation/goToBookmark/adapter.d.ts +8 -0
  41. package/dist/agents/tools/navigation/goToBookmark/adapter.js +30 -0
  42. package/dist/agents/tools/navigation/goToFeatures/adapter.d.ts +8 -0
  43. package/dist/agents/tools/navigation/goToFeatures/adapter.js +50 -0
  44. package/dist/agents/tools/navigation/goToFullExtent/adapter.d.ts +8 -0
  45. package/dist/agents/tools/navigation/goToFullExtent/adapter.js +27 -0
  46. package/dist/agents/tools/navigation/goToHomeExtent/adapter.d.ts +8 -0
  47. package/dist/agents/tools/navigation/goToHomeExtent/adapter.js +24 -0
  48. package/dist/agents/tools/navigation/goToLayer/adapter.d.ts +8 -0
  49. package/dist/agents/tools/navigation/goToLayer/adapter.js +26 -0
  50. package/dist/agents/tools/navigation/goToScale/adapter.d.ts +8 -0
  51. package/dist/agents/tools/navigation/goToScale/adapter.js +21 -0
  52. package/dist/agents/tools/navigation/goToViewpoint/adapter.d.ts +8 -0
  53. package/dist/agents/tools/navigation/goToViewpoint/adapter.js +42 -0
  54. package/dist/agents/tools/navigation/goToZoom/adapter.d.ts +8 -0
  55. package/dist/agents/tools/navigation/goToZoom/adapter.js +21 -0
  56. package/dist/agents/tools/query/getAttribute/adapter.d.ts +8 -0
  57. package/dist/agents/tools/query/getAttribute/adapter.js +40 -0
  58. package/dist/agents/tools/query/getStatistics/adapter.d.ts +8 -0
  59. package/dist/agents/tools/query/getStatistics/adapter.js +157 -0
  60. package/dist/agents/tools/query/getTopFeatures/adapter.d.ts +8 -0
  61. package/dist/agents/tools/query/getTopFeatures/adapter.js +144 -0
  62. package/dist/agents/tools/query/queryFeatures/adapter.d.ts +8 -0
  63. package/dist/agents/tools/query/queryFeatures/adapter.js +130 -0
  64. package/dist/agents/tools/search/findRelevantFields/adapter.d.ts +8 -0
  65. package/dist/agents/tools/search/findRelevantFields/adapter.js +57 -0
  66. package/dist/agents/tools/search/findRelevantLayers/adapter.d.ts +8 -0
  67. package/dist/agents/tools/search/findRelevantLayers/adapter.js +38 -0
  68. package/dist/cdn/22KHSDJI.js +2 -0
  69. package/dist/cdn/2EY3BQQX.js +2 -0
  70. package/dist/cdn/{SWOXSJ62.js → 2O4DON37.js} +1 -1
  71. package/dist/cdn/34O57OGV.js +2 -0
  72. package/dist/cdn/{5W7S2RS4.js → 3UEKINYC.js} +1 -1
  73. package/dist/cdn/4OGR5QKS.js +2 -0
  74. package/dist/cdn/5FL5BTTX.js +66 -0
  75. package/dist/cdn/5HBAJ57P.js +2 -0
  76. package/dist/cdn/5K5ZY267.js +2 -0
  77. package/dist/cdn/5MK44FNO.js +2 -0
  78. package/dist/cdn/5WYRJMBW.js +2 -0
  79. package/dist/cdn/5X7EG7D2.js +2 -0
  80. package/dist/cdn/5XZLS7UO.js +2 -0
  81. package/dist/cdn/5ZFUGNRN.js +2 -0
  82. package/dist/cdn/655YIKL3.js +11 -0
  83. package/dist/cdn/6ECRQVHY.js +2 -0
  84. package/dist/cdn/6OOZSZRJ.js +2 -0
  85. package/dist/cdn/{D3TNNRP4.js → 6P44KOKX.js} +1 -1
  86. package/dist/cdn/6YYPVU7H.js +3 -0
  87. package/dist/cdn/7BCQMK6D.js +2 -0
  88. package/dist/cdn/7SRLZQVC.js +5 -0
  89. package/dist/cdn/7V6OSTFC.js +2 -0
  90. package/dist/cdn/7VAQUCBU.js +9 -0
  91. package/dist/cdn/7VUSIGEM.js +2 -0
  92. package/dist/cdn/ACJTJLZN.js +2 -0
  93. package/dist/cdn/AI6DYOKR.js +181 -0
  94. package/dist/cdn/AKD5UOVX.js +2 -0
  95. package/dist/cdn/ANRQWYU2.js +2 -0
  96. package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
  97. package/dist/cdn/APFZY4PI.js +2 -0
  98. package/dist/cdn/B2JDVLA6.js +2 -0
  99. package/dist/cdn/BE7BRJZD.js +2 -0
  100. package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
  101. package/dist/cdn/C4FEETBZ.js +2 -0
  102. package/dist/cdn/C4JT4S5E.js +2 -0
  103. package/dist/cdn/CCC6LBMY.js +2 -0
  104. package/dist/cdn/{5ZZGKP7N.js → CEKOEHB3.js} +1 -1
  105. package/dist/cdn/CJMUJXPL.js +2 -0
  106. package/dist/cdn/COH3QXWG.js +4 -0
  107. package/dist/cdn/CP5BVGJU.js +2 -0
  108. package/dist/cdn/D5UFYQHN.js +44 -0
  109. package/dist/cdn/EWLXNGKH.js +208 -0
  110. package/dist/cdn/EYOWRGDP.js +2 -0
  111. package/dist/cdn/F5NIRETW.js +2 -0
  112. package/dist/cdn/FDOMMK2M.js +2 -0
  113. package/dist/cdn/FG647IP6.js +2 -0
  114. package/dist/cdn/FJO4KNOZ.js +2 -0
  115. package/dist/cdn/FUF3NAU7.js +2 -0
  116. package/dist/cdn/FXP5UIQU.js +156 -0
  117. package/dist/cdn/{T537PKP4.js → FYZATVB3.js} +1 -1
  118. package/dist/cdn/G2EGT3CF.js +6 -0
  119. package/dist/cdn/G3SF6U2U.js +2 -0
  120. package/dist/cdn/G7OMHU2B.js +2 -0
  121. package/dist/cdn/HAEFC2SJ.js +2 -0
  122. package/dist/cdn/HDACNIZF.js +2 -0
  123. package/dist/cdn/HHFNQR6Z.js +2 -0
  124. package/dist/cdn/HHUQXL3R.js +2 -0
  125. package/dist/cdn/IBZ2NEAO.js +2 -0
  126. package/dist/cdn/{FX7UOGHP.js → ICBIUFK7.js} +1 -1
  127. package/dist/cdn/ICQCK5D3.js +2 -0
  128. package/dist/cdn/IHP25JWI.js +99 -0
  129. package/dist/cdn/IJVMUS2L.js +14 -0
  130. package/dist/cdn/J6A4AS7E.js +22 -0
  131. package/dist/cdn/J6SZIQJA.js +2 -0
  132. package/dist/cdn/JCOA24UH.js +3 -0
  133. package/dist/cdn/{NE7E52YR.js → JEBRN3EU.js} +9 -3
  134. package/dist/cdn/JO5ETMPS.js +2 -0
  135. package/dist/cdn/K2R6XVK3.js +2 -0
  136. package/dist/cdn/KITIP6J2.js +2 -0
  137. package/dist/cdn/KWD2ECTM.js +2 -0
  138. package/dist/cdn/{MODWHY3R.js → LAYVGCPL.js} +6 -4
  139. package/dist/cdn/{7RCQFLPP.js → LK7ZIQW6.js} +1 -1
  140. package/dist/cdn/LLUGJKAQ.js +2 -0
  141. package/dist/cdn/MWYBF3F3.js +66 -0
  142. package/dist/cdn/{VMXLYWUK.js → MXTXJKFE.js} +1 -1
  143. package/dist/cdn/MY47B3CE.js +3 -0
  144. package/dist/cdn/NEV6OZN3.js +71 -0
  145. package/dist/cdn/NNXISHCA.js +14 -0
  146. package/dist/cdn/NZSOJ726.js +2 -0
  147. package/dist/cdn/O4NVW75A.js +2 -0
  148. package/dist/cdn/OE3GW5LE.js +2 -0
  149. package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
  150. package/dist/cdn/ONQ6JSBJ.js +2 -0
  151. package/dist/cdn/OX64WOEL.js +22 -0
  152. package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
  153. package/dist/cdn/PUHRBGKB.js +2 -0
  154. package/dist/cdn/Q57QWN5W.js +2 -0
  155. package/dist/cdn/QUKNPVAF.js +2 -0
  156. package/dist/cdn/R2PQVY4O.js +2 -0
  157. package/dist/cdn/R74ZHFA6.js +2 -0
  158. package/dist/cdn/RBE55SWR.js +2 -0
  159. package/dist/cdn/RHYNE5OE.js +2 -0
  160. package/dist/cdn/RLEHNAIA.js +2 -0
  161. package/dist/cdn/RVSTAUQS.js +2 -0
  162. package/dist/cdn/{X2ZDYHCG.js → SDWWUWAF.js} +10 -5
  163. package/dist/cdn/{GTLS44GI.js → SXM4NUT5.js} +1 -1
  164. package/dist/cdn/SZ2QSSB3.js +2 -0
  165. package/dist/cdn/T4RIGOXB.js +2 -0
  166. package/dist/cdn/TCH5I5LS.js +2 -0
  167. package/dist/cdn/TEPP7YPR.js +2 -0
  168. package/dist/cdn/TMVF2W5N.js +36 -0
  169. package/dist/cdn/TPULIO6I.js +34 -0
  170. package/dist/cdn/UDRKUVZP.js +2 -0
  171. package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
  172. package/dist/cdn/UHNVDALX.js +18 -0
  173. package/dist/cdn/UZLQALHY.js +2 -0
  174. package/dist/cdn/V6HOUZPZ.js +2 -0
  175. package/dist/cdn/VAXH6RUQ.js +134 -0
  176. package/dist/cdn/VLLZ2FFU.js +2 -0
  177. package/dist/cdn/VOKXKU7M.js +56 -0
  178. package/dist/cdn/VXFQANGJ.js +2 -0
  179. package/dist/cdn/WGO5SER7.js +6 -0
  180. package/dist/cdn/WJXXOKGA.js +9 -0
  181. package/dist/cdn/WKTQVBFJ.js +2 -0
  182. package/dist/cdn/{2SJAOYZT.js → WSWB3B7B.js} +1 -1
  183. package/dist/cdn/XX6GHMNR.js +2 -0
  184. package/dist/cdn/Y7XD7ZRD.js +2 -0
  185. package/dist/cdn/YEZ3AMNX.js +2 -0
  186. package/dist/cdn/YLVJA4ZE.js +2 -0
  187. package/dist/cdn/Z5HWPSZN.js +2 -0
  188. package/dist/cdn/Z5W4V7RC.js +2 -0
  189. package/dist/cdn/ZDV4K4WG.js +2 -0
  190. package/dist/cdn/ZOEMBHRF.js +2 -0
  191. package/dist/cdn/ZRVZMPFN.js +2 -0
  192. package/dist/cdn/{ZTBA5PM7.js → ZU2FHVNK.js} +1 -1
  193. package/dist/cdn/agent-utils/index.js +2 -0
  194. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
  195. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
  196. package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
  197. package/dist/cdn/assets/assistant/t9n/messages.en.json +1 -1
  198. package/dist/cdn/assets/assistant-interrupt/t9n/messages.en.json +1 -1
  199. package/dist/cdn/assets/assistant-interrupt-preview/t9n/messages.en.json +1 -0
  200. package/dist/cdn/assets/assistant-message/t9n/messages.en.json +1 -0
  201. package/dist/cdn/assets/assistant-message-loading/t9n/messages.en.json +1 -0
  202. package/dist/cdn/index.js +1 -1
  203. package/dist/chunks/adapter.js +1295 -2104
  204. package/dist/chunks/arcgisKnowledgeGraph.js +128 -72
  205. package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
  206. package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
  207. package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
  208. package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
  209. package/dist/chunks/baseAgentState.js +58 -0
  210. package/dist/chunks/converterUtils.js +66 -41
  211. package/dist/chunks/dataExplorationGraph.js +131 -182
  212. package/dist/chunks/data_explore_query_prompt.js +9 -4
  213. package/dist/chunks/fetchAgentContext.js +13 -0
  214. package/dist/chunks/fetchService.js +10 -0
  215. package/dist/chunks/fieldStatistics.js +79 -0
  216. package/dist/chunks/formatFeatureAttributes.js +132 -0
  217. package/dist/chunks/generateLayerDescriptions.js +259 -282
  218. package/dist/chunks/helpGraph.js +35 -25
  219. package/dist/chunks/help_prompt.js +34 -17
  220. package/dist/chunks/index.js +11 -0
  221. package/dist/chunks/intent_prompt.js +16 -0
  222. package/dist/chunks/layerStylingGraph.js +39 -33
  223. package/dist/chunks/mergeWhereClauses.js +15 -0
  224. package/dist/chunks/navigationGraph.js +140 -116
  225. package/dist/chunks/navigation_intent_prompt.js +8 -2
  226. package/dist/chunks/orchestrator.js +444 -233
  227. package/dist/chunks/resolvePointGeometryFilter.js +92 -0
  228. package/dist/chunks/state.js +21 -27
  229. package/dist/chunks/toolCallResponse.js +14 -10
  230. package/dist/chunks/utils2.js +11 -11
  231. package/dist/components/arcgis-assistant/customElement.d.ts +82 -1
  232. package/dist/components/arcgis-assistant/customElement.js +332 -183
  233. package/dist/components/arcgis-assistant-agent/customElement.d.ts +13 -1
  234. package/dist/components/arcgis-assistant-agent/customElement.js +614 -10
  235. package/dist/components/arcgis-assistant-chat/customElement.js +22 -17
  236. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +20 -4
  237. package/dist/components/arcgis-assistant-help-agent/customElement.js +29 -7
  238. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -0
  239. package/dist/components/arcgis-assistant-interrupt/customElement.js +11 -12
  240. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +12 -8
  241. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
  242. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +40 -16
  243. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +30 -7
  244. package/dist/components/arcgis-assistant-message/customElement.d.ts +3 -0
  245. package/dist/components/arcgis-assistant-message/customElement.js +9 -8
  246. package/dist/components/arcgis-assistant-message-block/customElement.js +1 -1
  247. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +3 -0
  248. package/dist/components/arcgis-assistant-message-loading/customElement.js +11 -10
  249. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +1 -0
  250. package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
  251. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +18 -4
  252. package/dist/components/arcgis-assistant-speech-input/customElement.js +34 -52
  253. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +2 -0
  254. package/dist/components/arcgis-assistant-user-message/customElement.js +15 -10
  255. package/dist/docs/api.json +1 -1
  256. package/dist/docs/docs.json +1 -1
  257. package/dist/docs/vscode.html-custom-data.json +1 -1
  258. package/dist/docs/web-types.json +1 -1
  259. package/dist/loader.js +6 -6
  260. package/dist/oauth-callback.html +1 -1
  261. package/dist/orchestrator/orchestrator/orchestratorEvents.d.ts +78 -0
  262. package/dist/types/lumina.d.ts +5 -4
  263. package/dist/types/preact.d.ts +5 -4
  264. package/dist/types/react.d.ts +5 -4
  265. package/dist/types/stencil.d.ts +7 -6
  266. package/dist/utils/index.d.ts +65 -38
  267. package/dist/utils/index.js +56 -55
  268. package/package.json +32 -12
  269. package/dist/cdn/462JBSEV.js +0 -422
  270. package/dist/cdn/5QAHYX7Y.js +0 -5
  271. package/dist/cdn/64PJB5NU.js +0 -2
  272. package/dist/cdn/6AWNQHCO.js +0 -4
  273. package/dist/cdn/AXDZBBNL.js +0 -45
  274. package/dist/cdn/BIV2IPHH.js +0 -2
  275. package/dist/cdn/CCY4TSBO.js +0 -2
  276. package/dist/cdn/CTSALWEP.js +0 -2
  277. package/dist/cdn/D2N2NSRQ.js +0 -72
  278. package/dist/cdn/DOV5ZJ7M.js +0 -2
  279. package/dist/cdn/EEUCKMU7.js +0 -2
  280. package/dist/cdn/EGHBXLNG.js +0 -2
  281. package/dist/cdn/ETRWZ3MS.js +0 -108
  282. package/dist/cdn/EWI4V3GQ.js +0 -36
  283. package/dist/cdn/F2AHA4GB.js +0 -54
  284. package/dist/cdn/I6HNBTWY.js +0 -2
  285. package/dist/cdn/JBHNHHWO.js +0 -3
  286. package/dist/cdn/JOFUPKIB.js +0 -2
  287. package/dist/cdn/KMQ3SP4I.js +0 -5
  288. package/dist/cdn/KUEOKIQR.js +0 -2
  289. package/dist/cdn/LKRAPK4A.js +0 -165
  290. package/dist/cdn/NXKKG5TK.js +0 -2
  291. package/dist/cdn/OBUZ7HBN.js +0 -2
  292. package/dist/cdn/OIVRK7HT.js +0 -2
  293. package/dist/cdn/RUURNLTP.js +0 -2
  294. package/dist/cdn/RVOAPUBN.js +0 -2
  295. package/dist/cdn/TSZPHE7L.js +0 -22
  296. package/dist/cdn/VAZNJSKA.js +0 -16
  297. package/dist/cdn/VNQN5ZQO.js +0 -14
  298. package/dist/cdn/WIDTPVSU.js +0 -2
  299. package/dist/cdn/XER22VYQ.js +0 -3
  300. package/dist/cdn/YIMNOUTF.js +0 -2
@@ -1,307 +1,75 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import ce from "@arcgis/core/identity/IdentityManager.js";
3
- import k from "@arcgis/core/portal/Portal.js";
4
- import { Annotation as b, messagesStateReducer as ye } from "@langchain/langgraph/web";
5
- import { n as ze, o as x, k as U, s as S, i as qe } from "./generateLayerDescriptions.js";
2
+ import H from "@arcgis/core/identity/IdentityManager.js";
3
+ import P from "@arcgis/core/portal/Portal.js";
4
+ import J from "@arcgis/core/request.js";
5
+ import { Annotation as m, messagesStateReducer as ee } from "@langchain/langgraph/web";
6
+ import "@arcgis/toolkit/string";
7
+ import { i as le } from "./generateLayerDescriptions.js";
6
8
  import "@langchain/core/messages";
7
9
  import "@langchain/core/callbacks/dispatch/web";
10
+ import "@langchain/core/callbacks/base";
8
11
  import "@langchain/openai";
9
- import * as De from "@arcgis/core/core/reactiveUtils.js";
12
+ import "@arcgis/core/config.js";
13
+ import * as ce from "@arcgis/core/core/reactiveUtils.js";
10
14
  import "@arcgis/core/layers/FeatureLayer.js";
11
- import le from "@arcgis/core/request.js";
12
15
  import "@langchain/core/prompts";
13
- import { tool as f } from "@langchain/core/tools";
14
- import J from "@arcgis/core/config.js";
15
- import Ae from "@arcgis/core/Graphic.js";
16
- import { addressToLocations as Le } from "@arcgis/core/rest/locator.js";
17
- import Pe from "@arcgis/core/symbols/PictureMarkerSymbol.js";
18
- import i, { z as C } from "zod";
19
- import je from "@arcgis/core/geometry/Extent.js";
20
- import fe from "@arcgis/core/geometry/Point.js";
21
- import { createRenderer as Ge } from "@arcgis/core/smartMapping/renderers/pieChart.js";
22
- import { getSchemesByTag as Oe, getSchemes as Me } from "@arcgis/core/smartMapping/symbology/pieChart.js";
23
- import { getBackgroundColorTheme as ue } from "@arcgis/core/views/support/colorUtils.js";
24
- import { createAgeRenderer as Qe, createContinuousRenderer as _e } from "@arcgis/core/smartMapping/renderers/color.js";
25
- import { getSchemesByTag as re } from "@arcgis/core/smartMapping/symbology/color.js";
26
- import { createContinuousRenderer as We } from "@arcgis/core/smartMapping/renderers/univariateColorSize.js";
27
- import { createRenderer as Ve } from "@arcgis/core/smartMapping/renderers/dotDensity.js";
28
- import { getSchemesByTag as Ue } from "@arcgis/core/smartMapping/symbology/dotDensity.js";
29
- import { createRenderer as Ke } from "@arcgis/core/smartMapping/renderers/heatmap.js";
30
- import { getSchemesByTag as Be } from "@arcgis/core/smartMapping/symbology/heatmap.js";
31
- import { createRenderer as He } from "@arcgis/core/smartMapping/renderers/predominance.js";
32
- import { getSchemesByTag as Je } from "@arcgis/core/smartMapping/symbology/predominance.js";
33
- import { createRenderer as Ze } from "@arcgis/core/smartMapping/renderers/relationship.js";
34
- import { getSchemesByTag as Ye } from "@arcgis/core/smartMapping/symbology/relationship.js";
35
- import { createAgeRenderer as Xe, createContinuousRenderer as et } from "@arcgis/core/smartMapping/renderers/size.js";
36
- import { createRenderer as tt } from "@arcgis/core/smartMapping/renderers/type.js";
37
- import { getSchemesByTag as rt } from "@arcgis/core/smartMapping/symbology/type.js";
38
- import { ToolNode as ot } from "@langchain/langgraph/prebuilt";
39
- import at from "@arcgis/core/layers/support/FeatureEffect.js";
40
- import ge from "@arcgis/core/layers/support/FeatureFilter.js";
41
- import * as nt from "@arcgis/core/geometry/operators/unionOperator.js";
42
- import { formatDateOnly as it, convertDateFormatToIntlOptions as M, formatTimeOnly as st, formatDate as de } from "@arcgis/core/intl.js";
43
- import ct from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
44
- import lt from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
45
- import ut from "@arcgis/core/rest/support/TopFeaturesQuery.js";
46
- import dt from "@arcgis/core/rest/support/TopFilter.js";
47
- import pt from "@arcgis/core/WebLinkChart.js";
48
- import we from "@arcgis/core/rest/knowledgeGraph/GraphQueryStreaming.js";
49
- import "@arcgis/core/views/LinkChartView.js";
50
- import { fetchKnowledgeGraph as pe, executeQueryStreaming as ht, executeSearchStreaming as mt } from "@arcgis/core/rest/knowledgeGraphService.js";
51
- import yt from "@arcgis/core/rest/knowledgeGraph/GraphSearchStreaming.js";
52
- const L = (e, t) => t ?? e, vn = b.Root({
53
- ...ze(),
16
+ import { b as pe, a as G } from "./baseAgentState.js";
17
+ import { ToolNode as de } from "@langchain/langgraph/prebuilt";
18
+ import { s as T, a as S } from "./index.js";
19
+ import { clearFiltersTool as ue } from "../agents/tools/filter/clearFilters/adapter.js";
20
+ import { resetMapTool as he } from "../agents/tools/filter/resetMap/adapter.js";
21
+ import { setFeatureEffectTool as ye } from "../agents/tools/filter/setFeatureEffect/adapter.js";
22
+ import { getAttributeTool as me } from "../agents/tools/query/getAttribute/adapter.js";
23
+ import { getStatisticsTool as ge } from "../agents/tools/query/getStatistics/adapter.js";
24
+ import { getTopFeaturesTool as fe } from "../agents/tools/query/getTopFeatures/adapter.js";
25
+ import { queryFeaturesTool as we } from "../agents/tools/query/queryFeatures/adapter.js";
26
+ import c from "zod";
27
+ import { tool as g } from "@langchain/core/tools";
28
+ import { createRenderer as be } from "@arcgis/core/smartMapping/renderers/pieChart.js";
29
+ import { getSchemesByTag as Te, getSchemes as Se } from "@arcgis/core/smartMapping/symbology/pieChart.js";
30
+ import { getBackgroundColorTheme as X } from "@arcgis/core/views/support/colorUtils.js";
31
+ import { createAgeRenderer as ve, createContinuousRenderer as Re } from "@arcgis/core/smartMapping/renderers/color.js";
32
+ import { getSchemesByTag as V } from "@arcgis/core/smartMapping/symbology/color.js";
33
+ import { createContinuousRenderer as xe } from "@arcgis/core/smartMapping/renderers/univariateColorSize.js";
34
+ import { createRenderer as Ce } from "@arcgis/core/smartMapping/renderers/dotDensity.js";
35
+ import { getSchemesByTag as $e } from "@arcgis/core/smartMapping/symbology/dotDensity.js";
36
+ import { createRenderer as Pe } from "@arcgis/core/smartMapping/renderers/heatmap.js";
37
+ import { getSchemesByTag as Ee } from "@arcgis/core/smartMapping/symbology/heatmap.js";
38
+ import { createRenderer as ze } from "@arcgis/core/smartMapping/renderers/predominance.js";
39
+ import { getSchemesByTag as ke } from "@arcgis/core/smartMapping/symbology/predominance.js";
40
+ import { createRenderer as Ae } from "@arcgis/core/smartMapping/renderers/relationship.js";
41
+ import { getSchemesByTag as qe } from "@arcgis/core/smartMapping/symbology/relationship.js";
42
+ import { createAgeRenderer as Ne, createContinuousRenderer as Me } from "@arcgis/core/smartMapping/renderers/size.js";
43
+ import { createRenderer as De } from "@arcgis/core/smartMapping/renderers/type.js";
44
+ import { getSchemesByTag as Le } from "@arcgis/core/smartMapping/symbology/type.js";
45
+ import Ge from "@arcgis/core/WebLinkChart.js";
46
+ import re from "@arcgis/core/rest/knowledgeGraph/GraphQueryStreaming.js";
47
+ import { fetchKnowledgeGraph as Y, executeQueryStreaming as je, executeSearchStreaming as Fe } from "@arcgis/core/rest/knowledgeGraphService.js";
48
+ import _e from "@arcgis/core/rest/knowledgeGraph/GraphSearchStreaming.js";
49
+ import { getBindParametersFromCypherQuery as Qe } from "@arcgis/core/applications/KnowledgeStudio/generalSharedKgUtils.js";
50
+ const k = (e, t) => t ?? e, va = m.Root({
51
+ ...pe(),
54
52
  // internal to the navigation agent
55
- intent: b({
56
- reducer: L
53
+ intent: m({
54
+ reducer: k
57
55
  }),
58
- vectorSearchLayerResults: b({
59
- reducer: L,
56
+ vectorSearchLayerResults: m({
57
+ reducer: k,
60
58
  default: () => []
61
59
  }),
62
- vectorSearchFieldResults: b({
63
- reducer: L
60
+ vectorSearchFieldResults: m({
61
+ reducer: k
64
62
  }),
65
- navigationInternalState: b({
66
- reducer: L,
63
+ navigationInternalState: m({
64
+ reducer: k,
67
65
  default: () => ({
68
66
  toolCallMessage: void 0
69
67
  })
70
68
  })
71
- });
72
- async function ft(e, t) {
73
- const o = k.getDefault().helperServices, a = o.geocode.find((h) => h.name === "ArcGIS World Geocoding Service") ?? o.geocode[0];
74
- if (!a)
75
- throw new Error("No geocoding service found in helperServices.");
76
- const n = a.url, s = `${J.assetsPath?.endsWith("/") ? J.assetsPath : `${J.assetsPath}/`}esri/images/search/search-symbol-32.png`, u = (await Le(n, {
77
- address: { SingleLine: e },
78
- outFields: ["Match_addr"]
79
- }))?.[0];
80
- if (!u?.extent || !u.location)
81
- throw new Error(`Could not find location for: ${e}`);
82
- const l = new Pe({
83
- url: s,
84
- width: 24,
85
- height: 24
86
- }), d = new Ae({
87
- geometry: u.location,
88
- symbol: l
89
- });
90
- t.graphics.removeAll(), t.graphics.add(d), await t.goTo(u.extent);
91
- const p = {
92
- address: u.address ?? "",
93
- location: u.location ? u.location.toJSON() : null,
94
- extent: u.extent ? u.extent.toJSON() : null
95
- };
96
- return {
97
- text: `Successfully zoomed to ${e}.`,
98
- sharedStatePatch: { lastResolvedLocation: { value: p } }
99
- };
100
- }
101
- const gt = ["mapView"];
102
- function $(e) {
103
- const r = e?.configurable?.context;
104
- if (!r || typeof r != "object")
105
- throw new Error("NavigationAgent context missing");
106
- const o = gt.filter((a) => !(a in r));
107
- if (o.length)
108
- throw new Error(`NavigationAgent context missing: ${o.join(", ")}`);
109
- return r;
110
- }
111
- async function wt({ address: e }, t) {
112
- const { mapView: r } = $(t);
113
- return await ft(e, r);
114
- }
115
- const bt = i.object({
116
- address: i.string().describe("The full address or place name to locate.")
117
- }), Sn = f(wt, {
118
- name: "goToAddress",
119
- description: "Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",
120
- schema: bt
121
- });
122
- async function Tt(e, t) {
123
- const o = t.map.bookmarks;
124
- if (!o || o.length === 0)
125
- throw new Error("No bookmarks found in the map.");
126
- const a = o.find((s) => s.name === e);
127
- if (!a)
128
- throw new Error(`Bookmark with name "${e}" not found.`);
129
- const n = a.viewpoint;
130
- if (!n)
131
- throw new Error(`Bookmark with name "${e}" does not have a valid viewpoint.`);
132
- return await t.goTo(n), { text: `Navigated to bookmark: ${e}` };
133
- }
134
- async function vt({ bookmarkName: e }, t) {
135
- const { mapView: r } = $(t);
136
- return await Promise.resolve(Tt(e, r));
137
- }
138
- const St = C.object({
139
- bookmarkName: C.string().describe("The name of the bookmark to navigate to.")
140
- }), xn = f(vt, {
141
- name: "goToBookmark",
142
- description: "Go to the extent of the bookmark with the given name.",
143
- schema: St
144
- });
145
- async function xt(e, t, r) {
146
- const o = r.map?.allLayers.find((s) => s.id === e);
147
- if (!o)
148
- return { text: `Error: Layer with id ${e} not found` };
149
- const a = t?.trim() ? t : "1=1", n = o.createQuery();
150
- n.where = a;
151
- try {
152
- const { extent: s, count: c } = await o.queryExtent(n);
153
- if (c === 0)
154
- return { text: `No features found in ${o.title} matching: ${a}`, where: a };
155
- if (s)
156
- await r.goTo(s);
157
- else
158
- return { text: `Error: Unable to determine extent for ${o.title}`, where: a };
159
- const u = {
160
- layerId: e,
161
- layerTitle: o.title ?? e,
162
- where: a,
163
- count: c
164
- };
165
- return {
166
- text: `Successfully zoomed to ${c} feature(s) in ${o.title} matching: ${a}`,
167
- where: a,
168
- sharedStatePatch: { lastNavigatedFeatures: { value: u } }
169
- };
170
- } catch (s) {
171
- return console.error("Error in goToFeatures:", s), { text: `Error: ${s instanceof Error ? s.message : "Unknown error"}`, where: a };
172
- }
173
- }
174
- async function Rt({ layerId: e, where: t }, r) {
175
- const { mapView: o } = $(r);
176
- return await xt(e, t, o);
177
- }
178
- const $t = C.object({
179
- layerId: C.string().describe("The layerId of the layer to zoom to."),
180
- where: C.string().describe("The sql-92 where clause used to query features to zoom to")
181
- }), Rn = f(Rt, {
182
- name: "goToFeatures",
183
- description: "Go to the features that match the given filter related to the given layerId.",
184
- schema: $t
185
- });
186
- async function Et(e) {
187
- const r = new je({
188
- xmin: -180,
189
- ymin: -90,
190
- xmax: 180,
191
- ymax: 90,
192
- spatialReference: { wkid: 4326 }
193
- }).expand(0.7);
194
- return await e.goTo(r), { text: "Successfully zoomed to world extent" };
195
- }
196
- async function Ct(e, t) {
197
- const { mapView: r } = $(t);
198
- return await Et(r);
199
- }
200
- const Ft = C.object({}), $n = f(Ct, {
201
- name: "goToFullExtent",
202
- description: "Zooms the map to the full world extent using Esri's Geocoding Service.",
203
- schema: Ft
204
- });
205
- async function It(e) {
206
- const r = e.map.initialViewProperties?.viewpoint?.targetGeometry;
207
- if (r)
208
- await e.goTo(r);
209
- else
210
- throw new Error("Initial extent is undefined");
211
- return { text: "Successfully zoomed to home extent" };
212
- }
213
- async function kt(e, t) {
214
- const { mapView: r } = $(t);
215
- return await It(r);
216
- }
217
- const Nt = i.object({}), En = f(kt, {
218
- name: "goToHomeExtent",
219
- description: "Go to the initial web map view extent",
220
- schema: Nt
221
- });
222
- async function zt(e, t) {
223
- await t.when();
224
- const r = t.map?.allLayers.find((a) => a.id === e);
225
- if (!r)
226
- return console.warn(`[goToLayer] No matching FeatureLayer found for: ${e}`), { text: `Could not find layer for: ${e}` };
227
- let o;
228
- return (r.type === "link-chart" || r.type === "knowledge-graph-sublayer") && t.map?.activeLinkChartLayer ? o = t.map.diagramNodesExtent : o = r.fullExtent, o ? (await t.goTo(o), r.visible = !0, { text: `Successfully zoomed to: ${r.title ?? ""}` }) : { text: "Layer has no defined extent. Cannot zoom to layer." };
229
- }
230
- async function qt({ layerId: e }, t) {
231
- const { mapView: r } = $(t);
232
- return await zt(e, r);
233
- }
234
- const Dt = C.object({
235
- layerId: C.string().describe("The id of the layer to navigate to")
236
- }), Cn = f(qt, {
237
- name: "goToLayer",
238
- description: "Zooms the map view to the full extent of the top matching layer.",
239
- schema: Dt
240
- });
241
- async function At(e, t) {
242
- return await t.goTo({ scale: e }), { text: `Successfully zoomed to: ${e}` };
243
- }
244
- async function Lt({ scale: e }, t) {
245
- const { mapView: r } = $(t);
246
- return await At(e, r);
247
- }
248
- const Pt = i.object({
249
- scale: i.number().describe("The map scale of the view to go to.")
250
- }), Fn = f(Lt, {
251
- name: "goToScale",
252
- description: "Go to the specified view scale.",
253
- schema: Pt
254
- });
255
- async function jt(e, t, r) {
256
- const a = {
257
- target: new fe({
258
- longitude: e.longitude,
259
- latitude: e.latitude,
260
- spatialReference: { wkid: 4326 }
261
- })
262
- };
263
- return r?.zoom !== void 0 && (a.zoom = r.zoom), r?.scale !== void 0 && (a.scale = r.scale), await t.goTo(a), { text: `Successfully navigated to: ${[
264
- `(${e.latitude}°, ${e.longitude}°)`,
265
- r?.zoom !== void 0 ? `zoom ${r.zoom}` : "",
266
- r?.scale !== void 0 ? `scale 1:${r.scale}` : ""
267
- ].filter(Boolean).join(", ")}` };
268
- }
269
- async function Gt({
270
- center: e,
271
- zoom: t,
272
- scale: r
273
- }, o) {
274
- const { mapView: a } = $(o);
275
- return await jt(e, a, { zoom: t, scale: r });
276
- }
277
- const Ot = i.object({
278
- center: i.object({
279
- longitude: i.number().describe("The longitude (x-coordinate) of the point to navigate to."),
280
- latitude: i.number().describe("The latitude (y-coordinate) of the point to navigate to.")
281
- }),
282
- zoom: i.number().optional().describe("The zoom level. Higher values = more zoomed in."),
283
- scale: i.number().optional().describe("The map scale. Alternative to zoom. Smaller numbers = more zoomed in.")
284
- }), In = f(Gt, {
285
- name: "goToViewpoint",
286
- description: "Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",
287
- schema: Ot
288
- });
289
- async function Mt(e, t) {
290
- return await t.goTo({ zoom: e }), { text: `Successfully zoomed to: ${e}` };
291
- }
292
- async function Qt({ zoom: e }, t) {
293
- const { mapView: r } = $(t);
294
- return await Mt(e, r);
295
- }
296
- const _t = i.object({
297
- zoom: i.number().min(1).max(20).describe("The zoom level of the view to go to.")
298
- }), kn = f(Qt, {
299
- name: "goToZoom",
300
- description: 'Go to the specified zoom level. If input is generic (e.g. "zoom in", then only zoom to the next appropriate level - increase level for zooming in and decrease for zooming out.).',
301
- schema: _t
302
- }), he = /* @__PURE__ */ Object.assign({
69
+ }), Z = /* @__PURE__ */ Object.assign({
303
70
  "../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_lc_context.md": () => import("./arcgis_knowledge_current_lc_context.js").then((e) => e.default),
304
71
  "../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_map_context.md": () => import("./arcgis_knowledge_current_map_context.js").then((e) => e.default),
72
+ "../agents/arcgisKnowledge/prompts/arcgis_knowledge_cypher_query_prompt.md": () => import("./arcgis_knowledge_cypher_query_prompt.js").then((e) => e.default),
305
73
  "../agents/arcgisKnowledge/prompts/arcgis_knowledge_lucene_generation_prompt.md": () => import("./arcgis_knowledge_lucene_generation_prompt.js").then((e) => e.default),
306
74
  "../agents/arcgisKnowledge/prompts/arcgis_knowledge_summarize_result_prompt.md": () => import("./arcgis_knowledge_summarize_result_prompt.js").then((e) => e.default),
307
75
  "../agents/arcgisKnowledge/prompts/arcgis_knowledge_tool_prompt.md": () => import("./arcgis_knowledge_tool_prompt.js").then((e) => e.default),
@@ -313,115 +81,157 @@ const _t = i.object({
313
81
  "../agents/navigation/prompts/navigation_intent_prompt.md": () => import("./navigation_intent_prompt.js").then((e) => e.default),
314
82
  "../agents/navigation/prompts/navigation_tool_prompt.md": () => import("./navigation_tool_prompt.js").then((e) => e.default)
315
83
  });
316
- async function Y(e) {
317
- const t = Object.entries(he).find(([r]) => r.endsWith(`/${e}.md`));
84
+ async function L(e) {
85
+ const t = Object.entries(Z).find(([r]) => r.endsWith(`/${e}.md`));
318
86
  if (!t)
319
87
  throw new Error(`Prompt not found: ${e}
320
88
  Available prompts:
321
- ${Object.keys(he).join(`
89
+ ${Object.keys(Z).join(`
322
90
  `)}`);
323
91
  return await t[1]();
324
92
  }
325
- const Wt = (e, t = 300) => {
93
+ const Ie = (e, t = 300) => {
326
94
  const r = e.replace(/\s+/gu, " ").replace(/[*_`#>\-]/gu, "").trim();
327
95
  return r.length > t ? `${r.slice(0, t)}...` : r;
328
- }, be = (e, t) => {
329
- const o = e?.configurable?.services?.[t];
330
- if (o == null)
331
- throw new Error(`${t} missing in config.configurable.services`);
332
- return o;
333
- }, Nn = (e, t) => (r, o) => {
334
- const a = o?.configurable?.services;
335
- for (const n of e)
336
- if (!a?.[n])
337
- throw new Error(`${t} requires services.${n} to be available.`);
96
+ }, Ra = (e, t) => (r, a) => {
97
+ const o = a?.configurable?.services;
98
+ for (const i of e)
99
+ if (!o?.[i])
100
+ throw new Error(`${t} requires services.${i} to be available.`);
338
101
  return r;
339
- };
340
- async function Vt(e) {
341
- const { fields: t, layer: r, view: o, styleName: a, colorSchemeTags: n } = e;
102
+ }, xa = m.Root({
103
+ ...G(),
104
+ vectorSearchLayerIds: m(),
105
+ vectorSearchFieldResults: m(),
106
+ layerFieldInfo: m(),
107
+ queryResponse: m(),
108
+ dataExplorationMessages: m({
109
+ reducer: ee,
110
+ default: () => []
111
+ })
112
+ }), Oe = [me, ge, fe, we], Ca = [ye, he, ue], Ke = new de(Oe, { handleToolErrors: !1 });
113
+ async function $a(e, t) {
114
+ const { messages: r } = await Ke.invoke({ messages: e.dataExplorationMessages }, t), a = [], o = [];
115
+ for (const i of r) {
116
+ const s = i.content;
117
+ let n;
118
+ typeof s != "string" && (n = {
119
+ tool: i.name ?? "unknown",
120
+ layerName: "unknown",
121
+ summary: "Query failed",
122
+ details: { error: "Skipping non-string tool output:", raw: s }
123
+ });
124
+ try {
125
+ typeof s == "string" ? n = JSON.parse(s) : n = {
126
+ tool: i.name ?? "unknown",
127
+ layerName: "unknown",
128
+ summary: "Query failed",
129
+ details: { error: "Invalid tool output type", raw: s }
130
+ };
131
+ } catch {
132
+ n = {
133
+ tool: i.name ?? "unknown",
134
+ layerName: "unknown",
135
+ summary: "Query failed",
136
+ details: { error: s }
137
+ };
138
+ }
139
+ a.push(n), n.details && typeof n.details == "object" && "error" in n.details ? o.push(`- ${n.tool}: Error - ${String(n.details.error)}`) : o.push(`- ${n.layerName}: ${n.summary}`);
140
+ }
141
+ return await T({ text: `Finished executing layer query tool: ${o.join(", ")}` }, t), {
142
+ ...e,
143
+ dataExplorationMessages: [...e.dataExplorationMessages, ...r],
144
+ queryResponse: a,
145
+ status: "success",
146
+ summary: o.length > 0 ? Ie(o.join(`
147
+ `)) : "Query executed."
148
+ };
149
+ }
150
+ async function Ve(e) {
151
+ const { fields: t, layer: r, view: a, styleName: o, colorSchemeTags: i } = e;
342
152
  let s;
343
- return n ? s = Oe({
344
- basemapTheme: await ue(o),
153
+ return i ? s = Te({
154
+ basemapTheme: await X(a),
345
155
  geometryType: r.geometryType,
346
- includedTags: n,
156
+ includedTags: i,
347
157
  numColors: Math.min(t.length, 8)
348
- })[0] : s = Me({
349
- basemapTheme: await ue(o),
158
+ })[0] : s = Se({
159
+ basemapTheme: await X(a),
350
160
  geometryType: r.geometryType,
351
161
  numColors: Math.min(t.length, 8)
352
162
  }).primaryScheme, {
353
163
  layer: r,
354
- view: o,
355
- attributes: t.map((c) => ({
356
- field: c,
357
- label: r.fields.find((u) => u.name === c)?.alias ?? ""
164
+ view: a,
165
+ attributes: t.map((n) => ({
166
+ field: n,
167
+ label: r.fields.find((l) => l.name === n)?.alias ?? ""
358
168
  })).slice(0, 8),
359
169
  outlineOptimizationEnabled: !0,
360
170
  sizeOptimizationEnabled: !0,
361
- includeSizeVariable: a.includes("Size"),
171
+ includeSizeVariable: o.includes("Size"),
362
172
  pieChartScheme: s
363
173
  };
364
174
  }
365
- async function Ut(e) {
366
- return await Ge(e);
175
+ async function Be(e) {
176
+ return await be(e);
367
177
  }
368
- async function Kt({
178
+ async function We({
369
179
  arcgisMap: e,
370
180
  arcgisMapView: t,
371
181
  layerId: r,
372
- fields: o,
373
- colorSchemes: a,
374
- includeSize: n
182
+ fields: a,
183
+ colorSchemes: o,
184
+ includeSize: i
375
185
  }) {
376
- const s = t, c = e?.allLayers.find((d) => d.id === r);
377
- if (!c)
186
+ const s = t, n = e?.allLayers.find((d) => d.id === r);
187
+ if (!n)
378
188
  return `Could not find layer for id: ${r}`;
379
- const l = {
380
- styleName: n ? "chart-size" : "chart",
381
- fields: o,
382
- layer: c,
189
+ const p = {
190
+ styleName: i ? "chart-size" : "chart",
191
+ fields: a,
192
+ layer: n,
383
193
  view: s,
384
- colorSchemeTags: a
194
+ colorSchemeTags: o
385
195
  };
386
196
  try {
387
- const d = await Vt(l), p = await Ut(d);
388
- return c.renderer = p.renderer, c.visible = !0, `Chart renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
197
+ const d = await Ve(p), u = await Be(d);
198
+ return n.renderer = u.renderer, n.visible = !0, `Chart renderer applied to layer: ${n.title ?? n.id} using fields ${a.join(", ")}`;
389
199
  } catch (d) {
390
200
  return `Error applying chart renderer: ${d instanceof Error ? d.message : String(d)}`;
391
201
  }
392
202
  }
393
- const Bt = ["mapView"];
394
- function R(e) {
203
+ const Ue = ["mapView"];
204
+ function v(e) {
395
205
  const r = e?.configurable?.context;
396
206
  if (!r || typeof r != "object")
397
207
  throw new Error("LayerStylingAgent context missing");
398
- const o = Bt.filter((a) => !(a in r));
399
- if (o.length)
400
- throw new Error(`LayerStylingAgent context missing: ${o.join(", ")}`);
208
+ const a = Ue.filter((o) => !(o in r));
209
+ if (a.length)
210
+ throw new Error(`LayerStylingAgent context missing: ${a.join(", ")}`);
401
211
  return r;
402
212
  }
403
- async function Ht({
213
+ async function He({
404
214
  layerId: e,
405
215
  fields: t,
406
216
  colorSchemes: r,
407
- includeSize: o
408
- }, a) {
409
- const { mapView: n } = R(a);
410
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await Kt({
411
- arcgisMap: n.map,
412
- arcgisMapView: n,
217
+ includeSize: a
218
+ }, o) {
219
+ const { mapView: i } = v(o);
220
+ return await S({ type: "show-legend", data: { layerIds: [e] } }, o), await We({
221
+ arcgisMap: i.map,
222
+ arcgisMapView: i,
413
223
  layerId: e,
414
224
  fields: t,
415
225
  colorSchemes: r,
416
- includeSize: o
226
+ includeSize: a
417
227
  });
418
228
  }
419
- const Jt = i.object({
420
- layerId: i.string().describe("The id of the layer to apply the chart renderer to"),
421
- fields: i.array(i.string()).describe("The fields to use for the chart renderer (multiple numeric fields)"),
422
- colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
423
- includeSize: i.boolean().optional().describe("Whether to vary the chart size (chart-size)")
424
- }), zn = f(Ht, {
229
+ const Je = c.object({
230
+ layerId: c.string().describe("The id of the layer to apply the chart renderer to"),
231
+ fields: c.array(c.string()).describe("The fields to use for the chart renderer (multiple numeric fields)"),
232
+ colorSchemes: c.array(c.string()).optional().describe("Optional color scheme tags to use"),
233
+ includeSize: c.boolean().optional().describe("Whether to vary the chart size (chart-size)")
234
+ }), Pa = g(He, {
425
235
  name: "chart",
426
236
  description: `Label: Charts
427
237
  Description: Show the values of two or more categories as a proportion of the total using a pie chart.
@@ -434,156 +244,156 @@ const Jt = i.object({
434
244
  Keywords: pie, chart, all categories, breakdown, proportion, total, amount, how much, sum, graduated size, proportional size
435
245
  Example: Show the total number of homes built in each decade using a pie chart for each feature and vary the size of each chart based on the total of all categories.
436
246
  Fields: This style requires 2-8 number fields.`,
437
- schema: Jt
247
+ schema: Je
438
248
  });
439
- function Zt(e) {
440
- const { fields: t, layer: r, view: o, theme: a, colorSchemeTags: n } = e, s = t[0];
441
- let c;
442
- return n && (c = re({
249
+ function Xe(e) {
250
+ const { fields: t, layer: r, view: a, theme: o, colorSchemeTags: i } = e, s = t[0];
251
+ let n;
252
+ return i && (n = V({
443
253
  geometryType: r.geometryType,
444
- includedTags: n,
445
- theme: a || "high-to-low"
254
+ includedTags: i,
255
+ theme: o || "high-to-low"
446
256
  })[0]), {
447
257
  layer: r,
448
- view: o,
258
+ view: a,
449
259
  startTime: s,
450
260
  endTime: /* @__PURE__ */ new Date(),
451
- theme: a,
261
+ theme: o,
452
262
  sizeOptimizationEnabled: !0,
453
263
  outlineOptimizationEnabled: !0,
454
- colorScheme: c
264
+ colorScheme: n
455
265
  };
456
266
  }
457
- async function Yt(e) {
458
- return await Qe(e);
267
+ async function Ye(e) {
268
+ return await ve(e);
459
269
  }
460
- async function Xt({
270
+ async function Ze({
461
271
  arcgisMap: e,
462
272
  arcgisMapView: t,
463
273
  layerId: r,
464
- fields: o,
465
- colorSchemes: a,
466
- theme: n
274
+ fields: a,
275
+ colorSchemes: o,
276
+ theme: i
467
277
  }) {
468
- const s = t, c = e?.allLayers.find((l) => l.id === r);
469
- if (!c)
278
+ const s = t, n = e?.allLayers.find((p) => p.id === r);
279
+ if (!n)
470
280
  return `Could not find layer for id: ${r}`;
471
- const u = {
281
+ const l = {
472
282
  styleName: "color-age",
473
- fields: o,
474
- layer: c,
283
+ fields: a,
284
+ layer: n,
475
285
  view: s,
476
- colorSchemeTags: a,
477
- theme: n
286
+ colorSchemeTags: o,
287
+ theme: i
478
288
  };
479
289
  try {
480
- const l = Zt(u), d = await Yt(l);
481
- return c.renderer = d.renderer, c.visible = !0, `Color-age renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
482
- } catch (l) {
483
- return `Error applying color-age renderer: ${l instanceof Error ? l.message : String(l)}`;
290
+ const p = Xe(l), d = await Ye(p);
291
+ return n.renderer = d.renderer, n.visible = !0, `Color-age renderer applied to layer: ${n.title ?? n.id} using fields ${a.join(", ")}`;
292
+ } catch (p) {
293
+ return `Error applying color-age renderer: ${p instanceof Error ? p.message : String(p)}`;
484
294
  }
485
295
  }
486
296
  async function er({
487
297
  layerId: e,
488
298
  fields: t,
489
299
  colorSchemes: r,
490
- theme: o
491
- }, a) {
492
- const { mapView: n } = R(a);
493
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await Xt({
494
- arcgisMap: n.map,
495
- arcgisMapView: n,
300
+ theme: a
301
+ }, o) {
302
+ const { mapView: i } = v(o);
303
+ return await S({ type: "show-legend", data: { layerIds: [e] } }, o), await Ze({
304
+ arcgisMap: i.map,
305
+ arcgisMapView: i,
496
306
  layerId: e,
497
307
  fields: t,
498
308
  colorSchemes: r,
499
- theme: o
309
+ theme: a
500
310
  });
501
311
  }
502
- const tr = i.object({
503
- layerId: i.string().describe("The id of the layer to apply the color-age renderer to"),
504
- fields: i.array(i.string()).describe("The field(s) to use for the color-age renderer (temporal/date data)"),
505
- colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
506
- theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
507
- }), qn = f(er, {
312
+ const rr = c.object({
313
+ layerId: c.string().describe("The id of the layer to apply the color-age renderer to"),
314
+ fields: c.array(c.string()).describe("The field(s) to use for the color-age renderer (temporal/date data)"),
315
+ colorSchemes: c.array(c.string()).optional().describe("Optional color scheme tags to use"),
316
+ theme: c.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
317
+ }), Ea = g(er, {
508
318
  name: "color-age",
509
319
  description: `Label: Age (color)
510
320
  Description: Use colors along a continuous color ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
511
321
  Keywords: since, age, how old, how long
512
322
  Example: Show the age of each feature based on its reported date.
513
323
  Fields: This style requires at least one field with a date type.`,
514
- schema: tr
324
+ schema: rr
515
325
  });
516
- function rr(e) {
517
- const { fields: t, layer: r, view: o, colorSchemeTags: a } = e;
518
- let { theme: n } = e, s = t[1];
519
- const c = t[0];
520
- let u;
521
- return a && (u = re({
326
+ function tr(e) {
327
+ const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
328
+ let { theme: i } = e, s = t[1];
329
+ const n = t[0];
330
+ let l;
331
+ return o && (l = V({
522
332
  geometryType: r.geometryType,
523
- includedTags: a,
524
- theme: n || "high-to-low"
333
+ includedTags: o,
334
+ theme: i || "high-to-low"
525
335
  })[0]), {
526
336
  layer: r,
527
- view: o,
528
- field: c,
337
+ view: a,
338
+ field: n,
529
339
  normalizationField: s,
530
- theme: n,
340
+ theme: i,
531
341
  sizeOptimizationEnabled: !0,
532
342
  outlineOptimizationEnabled: !0,
533
- colorScheme: u
343
+ colorScheme: l
534
344
  };
535
345
  }
536
- async function or(e) {
537
- return await _e(e);
346
+ async function ar(e) {
347
+ return await Re(e);
538
348
  }
539
- async function ar({
349
+ async function or({
540
350
  arcgisMap: e,
541
351
  arcgisMapView: t,
542
352
  layerId: r,
543
- fields: o,
544
- colorSchemes: a,
545
- theme: n
353
+ fields: a,
354
+ colorSchemes: o,
355
+ theme: i
546
356
  }) {
547
- const s = t, c = e?.allLayers.find((l) => l.id === r);
548
- if (!c)
357
+ const s = t, n = e?.allLayers.find((p) => p.id === r);
358
+ if (!n)
549
359
  return `Could not find layer for id: ${r}`;
550
- const u = {
360
+ const l = {
551
361
  styleName: "color",
552
- fields: o,
553
- layer: c,
362
+ fields: a,
363
+ layer: n,
554
364
  view: s,
555
- colorSchemeTags: a,
556
- theme: n
365
+ colorSchemeTags: o,
366
+ theme: i
557
367
  };
558
368
  try {
559
- const l = rr(u), d = await or(l);
560
- return c.renderer = d.renderer, c.visible = !0, `Color renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
561
- } catch (l) {
562
- return `Error applying color renderer: ${l instanceof Error ? l.message : String(l)}`;
369
+ const p = tr(l), d = await ar(p);
370
+ return n.renderer = d.renderer, n.visible = !0, `Color renderer applied to layer: ${n.title ?? n.id} using fields ${a.join(", ")}`;
371
+ } catch (p) {
372
+ return `Error applying color renderer: ${p instanceof Error ? p.message : String(p)}`;
563
373
  }
564
374
  }
565
375
  async function nr({
566
376
  layerId: e,
567
377
  fields: t,
568
378
  colorSchemes: r,
569
- theme: o
570
- }, a) {
571
- const { mapView: n } = R(a);
572
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await ar({
573
- arcgisMap: n.map,
574
- arcgisMapView: n,
379
+ theme: a
380
+ }, o) {
381
+ const { mapView: i } = v(o);
382
+ return await S({ type: "show-legend", data: { layerIds: [e] } }, o), await or({
383
+ arcgisMap: i.map,
384
+ arcgisMapView: i,
575
385
  layerId: e,
576
386
  fields: t,
577
387
  colorSchemes: r,
578
- theme: o
388
+ theme: a
579
389
  });
580
390
  }
581
- const ir = i.object({
582
- layerId: i.string().describe("The id of the layer to apply the color renderer to"),
583
- fields: i.array(i.string()).describe("The field(s) to use for the color renderer"),
584
- colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
585
- theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
586
- }), Dn = f(nr, {
391
+ const ir = c.object({
392
+ layerId: c.string().describe("The id of the layer to apply the color renderer to"),
393
+ fields: c.array(c.string()).describe("The field(s) to use for the color renderer"),
394
+ colorSchemes: c.array(c.string()).optional().describe("Optional color scheme tags to use"),
395
+ theme: c.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color ramp")
396
+ }), za = g(nr, {
587
397
  name: "color",
588
398
  description: `Label: Counts and Amounts (color)
589
399
  Description: Vary color along a continuous color ramp to represent numeric or ranked data.
@@ -593,75 +403,75 @@ const ir = i.object({
593
403
  schema: ir
594
404
  });
595
405
  function sr(e) {
596
- const { fields: t, layer: r, view: o, colorSchemeTags: a, theme: n } = e;
597
- let s, c;
598
- const u = t[0];
599
- return a && (c = re({
406
+ const { fields: t, layer: r, view: a, colorSchemeTags: o, theme: i } = e;
407
+ let s, n;
408
+ const l = t[0];
409
+ return o && (n = V({
600
410
  geometryType: r.geometryType,
601
- includedTags: a,
602
- theme: n || "high-to-low"
411
+ includedTags: o,
412
+ theme: i || "high-to-low"
603
413
  })[0]), {
604
414
  layer: r,
605
- view: o,
606
- field: u,
415
+ view: a,
416
+ field: l,
607
417
  normalizationField: s,
608
- theme: n,
418
+ theme: i,
609
419
  colorOptions: {
610
- colorScheme: c
420
+ colorScheme: n
611
421
  }
612
422
  };
613
423
  }
614
- async function cr(e) {
615
- return await We(e);
424
+ async function lr(e) {
425
+ return await xe(e);
616
426
  }
617
- async function lr({
427
+ async function cr({
618
428
  arcgisMap: e,
619
429
  arcgisMapView: t,
620
430
  layerId: r,
621
- fields: o,
622
- colorSchemes: a,
623
- theme: n
431
+ fields: a,
432
+ colorSchemes: o,
433
+ theme: i
624
434
  }) {
625
- const s = t, c = e?.allLayers.find((l) => l.id === r);
626
- if (!c)
435
+ const s = t, n = e?.allLayers.find((p) => p.id === r);
436
+ if (!n)
627
437
  return `Could not find layer for id: ${r}`;
628
- const u = {
438
+ const l = {
629
439
  styleName: "color-size-univariate",
630
- fields: o,
631
- layer: c,
440
+ fields: a,
441
+ layer: n,
632
442
  view: s,
633
- colorSchemeTags: a,
634
- theme: n
443
+ colorSchemeTags: o,
444
+ theme: i
635
445
  };
636
446
  try {
637
- const l = sr(u), d = await cr(l);
638
- return c.renderer = d.renderer, c.visible = !0, `Color-size-univariate renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
639
- } catch (l) {
640
- return `Error applying color-size-univariate renderer: ${l instanceof Error ? l.message : String(l)}`;
447
+ const p = sr(l), d = await lr(p);
448
+ return n.renderer = d.renderer, n.visible = !0, `Color-size-univariate renderer applied to layer: ${n.title ?? n.id} using fields ${a.join(", ")}`;
449
+ } catch (p) {
450
+ return `Error applying color-size-univariate renderer: ${p instanceof Error ? p.message : String(p)}`;
641
451
  }
642
452
  }
643
- async function ur({
453
+ async function pr({
644
454
  layerId: e,
645
455
  fields: t,
646
456
  colorSchemes: r,
647
- theme: o
648
- }, a) {
649
- const { mapView: n } = R(a);
650
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await lr({
651
- arcgisMap: n.map,
652
- arcgisMapView: n,
457
+ theme: a
458
+ }, o) {
459
+ const { mapView: i } = v(o);
460
+ return await S({ type: "show-legend", data: { layerIds: [e] } }, o), await cr({
461
+ arcgisMap: i.map,
462
+ arcgisMapView: i,
653
463
  layerId: e,
654
464
  fields: t,
655
465
  colorSchemes: r,
656
- theme: o
466
+ theme: a
657
467
  });
658
468
  }
659
- const dr = i.object({
660
- layerId: i.string().describe("The id of the layer to apply the color-size univariate renderer to"),
661
- fields: i.array(i.string()).describe("The fields to use for the color-size univariate renderer"),
662
- colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
663
- theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color and size ramps")
664
- }), An = f(ur, {
469
+ const dr = c.object({
470
+ layerId: c.string().describe("The id of the layer to apply the color-size univariate renderer to"),
471
+ fields: c.array(c.string()).describe("The fields to use for the color-size univariate renderer"),
472
+ colorSchemes: c.array(c.string()).optional().describe("Optional color scheme tags to use"),
473
+ theme: c.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color and size ramps")
474
+ }), ka = g(pr, {
665
475
  name: "color-size-univariate",
666
476
  description: `Label: Color and Size (univariate)
667
477
  Description: Vary symbol size and color based on the values of two numeric attributes.
@@ -670,72 +480,72 @@ const dr = i.object({
670
480
  Fields: This style requires at least two fields: one determining the color of each feature, the other determining the size of each feature. Each field may be normalized by an additional normalization field.`,
671
481
  schema: dr
672
482
  });
673
- function pr(e) {
674
- const { fields: t, layer: r, view: o, colorSchemeTags: a } = e;
675
- let n;
676
- return a && (n = Ue({
677
- includedTags: a,
483
+ function ur(e) {
484
+ const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
485
+ let i;
486
+ return o && (i = $e({
487
+ includedTags: o,
678
488
  numColors: Math.min(t.length, 8)
679
489
  })[0]), {
680
490
  layer: r,
681
- view: o,
491
+ view: a,
682
492
  legendOptions: {
683
493
  unit: "units"
684
494
  },
685
495
  attributes: t.map((s) => ({
686
496
  field: s,
687
- label: r.fields.find((c) => c.name === s)?.alias ?? ""
497
+ label: r.fields.find((n) => n.name === s)?.alias ?? ""
688
498
  })).slice(0, 8),
689
499
  outlineOptimizationEnabled: !0,
690
- dotDensityScheme: n
500
+ dotDensityScheme: i
691
501
  };
692
502
  }
693
503
  async function hr(e) {
694
- return await Ve(e);
504
+ return await Ce(e);
695
505
  }
696
- async function mr({
506
+ async function yr({
697
507
  arcgisMap: e,
698
508
  arcgisMapView: t,
699
509
  layerId: r,
700
- fields: o,
701
- colorSchemes: a
510
+ fields: a,
511
+ colorSchemes: o
702
512
  }) {
703
- const n = t, s = e?.allLayers.find((u) => u.id === r);
513
+ const i = t, s = e?.allLayers.find((l) => l.id === r);
704
514
  if (!s)
705
515
  return `Could not find layer for id: ${r}`;
706
- const c = {
516
+ const n = {
707
517
  styleName: "dot-density",
708
- fields: o,
518
+ fields: a,
709
519
  layer: s,
710
- view: n,
711
- colorSchemeTags: a
520
+ view: i,
521
+ colorSchemeTags: o
712
522
  };
713
523
  try {
714
- const u = pr(c), l = await hr(u);
715
- return s.renderer = l.renderer, s.visible = !0, `Dot Density renderer applied to layer: ${s.title ?? s.id} using fields ${o.join(", ")}`;
716
- } catch (u) {
717
- return `Error applying dot density renderer: ${u instanceof Error ? u.message : String(u)}`;
524
+ const l = ur(n), p = await hr(l);
525
+ return s.renderer = p.renderer, s.visible = !0, `Dot Density renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
526
+ } catch (l) {
527
+ return `Error applying dot density renderer: ${l instanceof Error ? l.message : String(l)}`;
718
528
  }
719
529
  }
720
- async function yr({
530
+ async function mr({
721
531
  layerId: e,
722
532
  fields: t,
723
533
  colorSchemes: r
724
- }, o) {
725
- const { mapView: a } = R(o);
726
- return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await mr({
727
- arcgisMap: a.map,
728
- arcgisMapView: a,
534
+ }, a) {
535
+ const { mapView: o } = v(a);
536
+ return await S({ type: "show-legend", data: { layerIds: [e] } }, a), await yr({
537
+ arcgisMap: o.map,
538
+ arcgisMapView: o,
729
539
  layerId: e,
730
540
  fields: t,
731
541
  colorSchemes: r
732
542
  });
733
543
  }
734
- const fr = i.object({
735
- layerId: i.string().describe("The id of the layer to apply the dot density renderer to"),
736
- fields: i.array(i.string()).describe("The field(s) to use for the dot density renderer (population or count data)"),
737
- colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
738
- }), Ln = f(yr, {
544
+ const gr = c.object({
545
+ layerId: c.string().describe("The id of the layer to apply the dot density renderer to"),
546
+ fields: c.array(c.string()).describe("The field(s) to use for the dot density renderer (population or count data)"),
547
+ colorSchemes: c.array(c.string()).optional().describe("Optional color scheme tags to use")
548
+ }), Aa = g(mr, {
739
549
  name: "dot-density",
740
550
  description: `Dot Density
741
551
  Use dot density to visualize the distribution of one attribute or compare the density of multiple attributes. This is only valid for polygon layers.
@@ -749,143 +559,143 @@ const fr = i.object({
749
559
  - Display demographic patterns within census tracts
750
560
  **Fields:** Requires 2-8 number fields.
751
561
  **Keywords:** density, how much, how many, total, number, amount`,
752
- schema: fr
562
+ schema: gr
753
563
  });
754
- function gr(e) {
755
- const { fields: t, layer: r, view: o, colorSchemeTags: a } = e;
756
- let n;
564
+ function fr(e) {
565
+ const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
566
+ let i;
757
567
  const s = t[0];
758
- return a && (n = Be({
759
- includedTags: a,
760
- basemap: o.map?.basemap || "topo"
568
+ return o && (i = Ee({
569
+ includedTags: o,
570
+ basemap: a.map?.basemap || "topo"
761
571
  })[0]), {
762
572
  layer: r,
763
- view: o,
573
+ view: a,
764
574
  field: s,
765
- heatmapScheme: n
575
+ heatmapScheme: i
766
576
  };
767
577
  }
768
578
  async function wr(e) {
769
- return await Ke(e);
579
+ return await Pe(e);
770
580
  }
771
581
  async function br({
772
582
  arcgisMap: e,
773
583
  arcgisMapView: t,
774
584
  layerId: r,
775
- fields: o,
776
- colorSchemes: a
585
+ fields: a,
586
+ colorSchemes: o
777
587
  }) {
778
- const n = t, s = e?.allLayers.find((u) => u.id === r);
588
+ const i = t, s = e?.allLayers.find((l) => l.id === r);
779
589
  if (!s)
780
590
  return `Could not find layer for id: ${r}`;
781
- const c = {
591
+ const n = {
782
592
  styleName: "heatmap",
783
- fields: o,
593
+ fields: a,
784
594
  layer: s,
785
- view: n,
786
- colorSchemeTags: a
595
+ view: i,
596
+ colorSchemeTags: o
787
597
  };
788
598
  try {
789
- const u = gr(c), l = await wr(u);
790
- return s.renderer = l.renderer, s.visible = !0, `Heatmap renderer applied to layer: ${s.title ?? s.id} using fields ${o.join(", ")}`;
791
- } catch (u) {
792
- return `Error applying heatmap renderer: ${u instanceof Error ? u.message : String(u)}`;
599
+ const l = fr(n), p = await wr(l);
600
+ return s.renderer = p.renderer, s.visible = !0, `Heatmap renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
601
+ } catch (l) {
602
+ return `Error applying heatmap renderer: ${l instanceof Error ? l.message : String(l)}`;
793
603
  }
794
604
  }
795
605
  async function Tr({
796
606
  layerId: e,
797
607
  fields: t,
798
608
  colorSchemes: r
799
- }, o) {
800
- const { mapView: a } = R(o);
801
- return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await br({
802
- arcgisMap: a.map,
803
- arcgisMapView: a,
609
+ }, a) {
610
+ const { mapView: o } = v(a);
611
+ return await S({ type: "show-legend", data: { layerIds: [e] } }, a), await br({
612
+ arcgisMap: o.map,
613
+ arcgisMapView: o,
804
614
  layerId: e,
805
615
  fields: t,
806
616
  colorSchemes: r
807
617
  });
808
618
  }
809
- const vr = i.object({
810
- layerId: i.string().describe("The id of the layer to apply the heatmap renderer to"),
811
- fields: i.array(i.string()).describe("The field(s) to use for the heatmap renderer (typically point density)"),
812
- colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
813
- }), Pn = f(Tr, {
619
+ const Sr = c.object({
620
+ layerId: c.string().describe("The id of the layer to apply the heatmap renderer to"),
621
+ fields: c.array(c.string()).describe("The field(s) to use for the heatmap renderer (typically point density)"),
622
+ colorSchemes: c.array(c.string()).optional().describe("Optional color scheme tags to use")
623
+ }), qa = g(Tr, {
814
624
  name: "heatmap",
815
625
  description: `Label: Heat Map
816
626
  Description: Show areas of high density with colors that appear to glow hotter. This is only valid for point layers.
817
627
  Keywords: density, heatmap, hot spots, pattern, cluster
818
628
  Example: Create a heatmap
819
629
  Fields: This typically requires zero or one field of type number.`,
820
- schema: vr
630
+ schema: Sr
821
631
  });
822
- function Sr(e) {
823
- const { fields: t, layer: r, view: o, styleName: a, colorSchemeTags: n } = e;
632
+ function vr(e) {
633
+ const { fields: t, layer: r, view: a, styleName: o, colorSchemeTags: i } = e;
824
634
  let s;
825
- return n && (s = Je({
635
+ return i && (s = ke({
826
636
  geometryType: r.geometryType,
827
- includedTags: n,
637
+ includedTags: i,
828
638
  numColors: Math.min(t.length, 10)
829
639
  })[0]), {
830
640
  layer: r,
831
- view: o,
832
- fields: t.map((c) => ({ name: c })).slice(0, 9),
641
+ view: a,
642
+ fields: t.map((n) => ({ name: n })).slice(0, 9),
833
643
  outlineOptimizationEnabled: !0,
834
644
  sizeOptimizationEnabled: !0,
835
- includeSizeVariable: a.includes("Size"),
645
+ includeSizeVariable: o.includes("Size"),
836
646
  predominanceScheme: s
837
647
  };
838
648
  }
839
- async function xr(e) {
840
- return await He(e);
649
+ async function Rr(e) {
650
+ return await ze(e);
841
651
  }
842
- async function Rr({
652
+ async function xr({
843
653
  arcgisMap: e,
844
654
  arcgisMapView: t,
845
655
  layerId: r,
846
- fields: o,
847
- colorSchemes: a,
848
- includeSize: n
656
+ fields: a,
657
+ colorSchemes: o,
658
+ includeSize: i
849
659
  }) {
850
- const s = t, c = e?.allLayers.find((d) => d.id === r);
851
- if (!c)
660
+ const s = t, n = e?.allLayers.find((d) => d.id === r);
661
+ if (!n)
852
662
  return `Could not find layer for id: ${r}`;
853
- const l = {
854
- styleName: n ? "predominance-size" : "predominance",
855
- fields: o,
856
- layer: c,
663
+ const p = {
664
+ styleName: i ? "predominance-size" : "predominance",
665
+ fields: a,
666
+ layer: n,
857
667
  view: s,
858
- colorSchemeTags: a
668
+ colorSchemeTags: o
859
669
  };
860
670
  try {
861
- const d = Sr(l), p = await xr(d);
862
- return c.renderer = p.renderer, c.visible = !0, `Predominance renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
671
+ const d = vr(p), u = await Rr(d);
672
+ return n.renderer = u.renderer, n.visible = !0, `Predominance renderer applied to layer: ${n.title ?? n.id} using fields ${a.join(", ")}`;
863
673
  } catch (d) {
864
674
  return `Error applying predominance renderer: ${d instanceof Error ? d.message : String(d)}`;
865
675
  }
866
676
  }
867
- async function $r({
677
+ async function Cr({
868
678
  layerId: e,
869
679
  fields: t,
870
680
  colorSchemes: r,
871
- includeSize: o
872
- }, a) {
873
- const { mapView: n } = R(a);
874
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await Rr({
875
- arcgisMap: n.map,
876
- arcgisMapView: n,
681
+ includeSize: a
682
+ }, o) {
683
+ const { mapView: i } = v(o);
684
+ return await S({ type: "show-legend", data: { layerIds: [e] } }, o), await xr({
685
+ arcgisMap: i.map,
686
+ arcgisMapView: i,
877
687
  layerId: e,
878
688
  fields: t,
879
689
  colorSchemes: r,
880
- includeSize: o
690
+ includeSize: a
881
691
  });
882
692
  }
883
- const Er = i.object({
884
- layerId: i.string().describe("The id of the layer to apply the predominance renderer to"),
885
- fields: i.array(i.string()).describe("The fields to use for the predominance renderer (competing categories)"),
886
- colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
887
- includeSize: i.boolean().optional().describe("Whether to include size visualization (predominance-size)")
888
- }), jn = f($r, {
693
+ const $r = c.object({
694
+ layerId: c.string().describe("The id of the layer to apply the predominance renderer to"),
695
+ fields: c.array(c.string()).describe("The fields to use for the predominance renderer (competing categories)"),
696
+ colorSchemes: c.array(c.string()).optional().describe("Optional color scheme tags to use"),
697
+ includeSize: c.boolean().optional().describe("Whether to include size visualization (predominance-size)")
698
+ }), Na = g(Cr, {
889
699
  name: "predominance",
890
700
  description: `Label: Predominant category
891
701
  Description: Compare attributes that share a common subject and unit of measurement to see which has the highest value.
@@ -898,146 +708,146 @@ const Er = i.object({
898
708
  Keywords: predominant, winner, won, competing, most, most common, most frequent, dominant, prevalent, top, amount, total, how much, proportional size, graduated size, sum
899
709
  Example: Show the predominant crop in each area and vary the size of each symbol based on the total of all categories.
900
710
  Fields: This style relies on 2-10 number fields.`,
901
- schema: Er
711
+ schema: $r
902
712
  });
903
- function Cr(e) {
904
- const { fields: t, layer: r, view: o, colorSchemeTags: a } = e;
905
- let n;
713
+ function Pr(e) {
714
+ const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
715
+ let i;
906
716
  const s = {
907
717
  field: t[0]
908
- }, c = {
718
+ }, n = {
909
719
  field: t[1]
910
720
  };
911
- return a && (n = Ye({
721
+ return o && (i = qe({
912
722
  geometryType: r.geometryType,
913
- includedTags: a
723
+ includedTags: o
914
724
  })[0]), {
915
725
  layer: r,
916
- view: o,
726
+ view: a,
917
727
  field1: s,
918
- field2: c,
728
+ field2: n,
919
729
  outlineOptimizationEnabled: !0,
920
730
  sizeOptimizationEnabled: !0,
921
- relationshipScheme: n
731
+ relationshipScheme: i
922
732
  };
923
733
  }
924
- async function Fr(e) {
925
- return await Ze(e);
734
+ async function Er(e) {
735
+ return await Ae(e);
926
736
  }
927
- async function Ir({
737
+ async function zr({
928
738
  arcgisMap: e,
929
739
  arcgisMapView: t,
930
740
  layerId: r,
931
- fields: o,
932
- colorSchemes: a
741
+ fields: a,
742
+ colorSchemes: o
933
743
  }) {
934
- const n = t, s = e?.allLayers.find((u) => u.id === r);
744
+ const i = t, s = e?.allLayers.find((l) => l.id === r);
935
745
  if (!s)
936
746
  return `Could not find layer for id: ${r}`;
937
- const c = {
747
+ const n = {
938
748
  styleName: "relationship",
939
- fields: o,
749
+ fields: a,
940
750
  layer: s,
941
- view: n,
942
- colorSchemeTags: a
751
+ view: i,
752
+ colorSchemeTags: o
943
753
  };
944
754
  try {
945
- const u = Cr(c), l = await Fr(u);
946
- return s.renderer = l.renderer, s.visible = !0, `Relationship renderer applied to layer: ${s.title ?? s.id} using fields ${o.join(", ")}`;
947
- } catch (u) {
948
- return `Error applying relationship renderer: ${u instanceof Error ? u.message : String(u)}`;
755
+ const l = Pr(n), p = await Er(l);
756
+ return s.renderer = p.renderer, s.visible = !0, `Relationship renderer applied to layer: ${s.title ?? s.id} using fields ${a.join(", ")}`;
757
+ } catch (l) {
758
+ return `Error applying relationship renderer: ${l instanceof Error ? l.message : String(l)}`;
949
759
  }
950
760
  }
951
761
  async function kr({
952
762
  layerId: e,
953
763
  fields: t,
954
764
  colorSchemes: r
955
- }, o) {
956
- const { mapView: a } = R(o);
957
- return await x({ type: "show-legend", data: { layerIds: [e] } }, o), await Ir({
958
- arcgisMap: a.map,
959
- arcgisMapView: a,
765
+ }, a) {
766
+ const { mapView: o } = v(a);
767
+ return await S({ type: "show-legend", data: { layerIds: [e] } }, a), await zr({
768
+ arcgisMap: o.map,
769
+ arcgisMapView: o,
960
770
  layerId: e,
961
771
  fields: t,
962
772
  colorSchemes: r
963
773
  });
964
774
  }
965
- const Nr = i.object({
966
- layerId: i.string().describe("The id of the layer to apply the relationship renderer to"),
967
- fields: i.array(i.string()).describe("The two fields to use for the relationship renderer (bivariate visualization)"),
968
- colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
969
- }), Gn = f(kr, {
775
+ const Ar = c.object({
776
+ layerId: c.string().describe("The id of the layer to apply the relationship renderer to"),
777
+ fields: c.array(c.string()).describe("The two fields to use for the relationship renderer (bivariate visualization)"),
778
+ colorSchemes: c.array(c.string()).optional().describe("Optional color scheme tags to use")
779
+ }), Ma = g(kr, {
970
780
  name: "relationship",
971
781
  description: `Label: Relationship
972
782
  Description: Overlays two color ramps to represent the relationship between two numeric attributes.
973
783
  Keywords: relationship, correlation, compare, related, bivariate choropleth, bivariate color
974
784
  Example: Show the relationship between tree height and carbon storage
975
785
  Fields: This style requires two number fields.`,
976
- schema: Nr
786
+ schema: Ar
977
787
  });
978
- function zr(e) {
979
- const { fields: t, layer: r, view: o, theme: a } = e, n = t[0];
788
+ function qr(e) {
789
+ const { fields: t, layer: r, view: a, theme: o } = e, i = t[0];
980
790
  return {
981
791
  layer: r,
982
- view: o,
983
- startTime: n,
792
+ view: a,
793
+ startTime: i,
984
794
  endTime: /* @__PURE__ */ new Date(),
985
- theme: a,
795
+ theme: o,
986
796
  sizeOptimizationEnabled: !0,
987
797
  outlineOptimizationEnabled: !0
988
798
  };
989
799
  }
990
- async function qr(e) {
991
- return await Xe(e);
800
+ async function Nr(e) {
801
+ return await Ne(e);
992
802
  }
993
- async function Dr({
803
+ async function Mr({
994
804
  arcgisMap: e,
995
805
  arcgisMapView: t,
996
806
  layerId: r,
997
- fields: o,
998
- colorSchemes: a,
999
- theme: n
807
+ fields: a,
808
+ colorSchemes: o,
809
+ theme: i
1000
810
  }) {
1001
- const s = t, c = e?.allLayers.find((l) => l.id === r);
1002
- if (!c)
811
+ const s = t, n = e?.allLayers.find((p) => p.id === r);
812
+ if (!n)
1003
813
  return `Could not find layer for id: ${r}`;
1004
- const u = {
814
+ const l = {
1005
815
  styleName: "size-age",
1006
- fields: o,
1007
- layer: c,
816
+ fields: a,
817
+ layer: n,
1008
818
  view: s,
1009
- colorSchemeTags: a,
1010
- theme: n
819
+ colorSchemeTags: o,
820
+ theme: i
1011
821
  };
1012
822
  try {
1013
- const l = zr(u), d = await qr(l);
1014
- return c.renderer = d.renderer, c.visible = !0, `Size-age renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
1015
- } catch (l) {
1016
- return `Error applying size-age renderer: ${l instanceof Error ? l.message : String(l)}`;
823
+ const p = qr(l), d = await Nr(p);
824
+ return n.renderer = d.renderer, n.visible = !0, `Size-age renderer applied to layer: ${n.title ?? n.id} using fields ${a.join(", ")}`;
825
+ } catch (p) {
826
+ return `Error applying size-age renderer: ${p instanceof Error ? p.message : String(p)}`;
1017
827
  }
1018
828
  }
1019
- async function Ar({
829
+ async function Dr({
1020
830
  layerId: e,
1021
831
  fields: t,
1022
832
  colorSchemes: r,
1023
- theme: o
1024
- }, a) {
1025
- const { mapView: n } = R(a);
1026
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await Dr({
1027
- arcgisMap: n.map,
1028
- arcgisMapView: n,
833
+ theme: a
834
+ }, o) {
835
+ const { mapView: i } = v(o);
836
+ return await S({ type: "show-legend", data: { layerIds: [e] } }, o), await Mr({
837
+ arcgisMap: i.map,
838
+ arcgisMapView: i,
1029
839
  layerId: e,
1030
840
  fields: t,
1031
841
  colorSchemes: r,
1032
- theme: o
842
+ theme: a
1033
843
  });
1034
844
  }
1035
- const Lr = i.object({
1036
- layerId: i.string().describe("The id of the layer to apply the size-age renderer to"),
1037
- fields: i.array(i.string()).describe("The field(s) to use for the size-age renderer (temporal data with size)"),
1038
- colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
1039
- theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
1040
- }), On = f(Ar, {
845
+ const Lr = c.object({
846
+ layerId: c.string().describe("The id of the layer to apply the size-age renderer to"),
847
+ fields: c.array(c.string()).describe("The field(s) to use for the size-age renderer (temporal data with size)"),
848
+ colorSchemes: c.array(c.string()).optional().describe("Optional color scheme tags to use"),
849
+ theme: c.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
850
+ }), Da = g(Dr, {
1041
851
  name: "size-age",
1042
852
  description: `Label: Age (size)
1043
853
  Description: Vary symbol sizes along a continuous ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
@@ -1046,71 +856,71 @@ const Lr = i.object({
1046
856
  Fields: This style requires at least one field with a date type.`,
1047
857
  schema: Lr
1048
858
  });
1049
- function Pr(e) {
1050
- const { fields: t, layer: r, view: o } = e;
1051
- let { theme: a } = e, n = t[1];
859
+ function Gr(e) {
860
+ const { fields: t, layer: r, view: a } = e;
861
+ let { theme: o } = e, i = t[1];
1052
862
  const s = t[0];
1053
863
  return {
1054
864
  layer: r,
1055
- view: o,
865
+ view: a,
1056
866
  field: s,
1057
- normalizationField: n,
1058
- theme: a,
867
+ normalizationField: i,
868
+ theme: o,
1059
869
  sizeOptimizationEnabled: !0,
1060
870
  outlineOptimizationEnabled: !0
1061
871
  };
1062
872
  }
1063
873
  async function jr(e) {
1064
- return await et(e);
874
+ return await Me(e);
1065
875
  }
1066
- async function Gr({
876
+ async function Fr({
1067
877
  arcgisMap: e,
1068
878
  arcgisMapView: t,
1069
879
  layerId: r,
1070
- fields: o,
1071
- colorSchemes: a,
1072
- theme: n
880
+ fields: a,
881
+ colorSchemes: o,
882
+ theme: i
1073
883
  }) {
1074
- const s = t, c = e?.allLayers.find((l) => l.id === r);
1075
- if (!c)
884
+ const s = t, n = e?.allLayers.find((p) => p.id === r);
885
+ if (!n)
1076
886
  return `Could not find layer for id: ${r}`;
1077
- const u = {
887
+ const l = {
1078
888
  styleName: "size",
1079
- fields: o,
1080
- layer: c,
889
+ fields: a,
890
+ layer: n,
1081
891
  view: s,
1082
- colorSchemeTags: a,
1083
- theme: n
892
+ colorSchemeTags: o,
893
+ theme: i
1084
894
  };
1085
895
  try {
1086
- const l = Pr(u), d = await jr(l);
1087
- return c.renderer = d.renderer, c.visible = !0, `Size renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
1088
- } catch (l) {
1089
- return `Error applying size renderer: ${l instanceof Error ? l.message : String(l)}`;
896
+ const p = Gr(l), d = await jr(p);
897
+ return n.renderer = d.renderer, n.visible = !0, `Size renderer applied to layer: ${n.title ?? n.id} using fields ${a.join(", ")}`;
898
+ } catch (p) {
899
+ return `Error applying size renderer: ${p instanceof Error ? p.message : String(p)}`;
1090
900
  }
1091
901
  }
1092
- async function Or({
902
+ async function _r({
1093
903
  layerId: e,
1094
904
  fields: t,
1095
905
  colorSchemes: r,
1096
- theme: o
1097
- }, a) {
1098
- const { mapView: n } = R(a);
1099
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await Gr({
1100
- arcgisMap: n.map,
1101
- arcgisMapView: n,
906
+ theme: a
907
+ }, o) {
908
+ const { mapView: i } = v(o);
909
+ return await S({ type: "show-legend", data: { layerIds: [e] } }, o), await Fr({
910
+ arcgisMap: i.map,
911
+ arcgisMapView: i,
1102
912
  layerId: e,
1103
913
  fields: t,
1104
914
  colorSchemes: r,
1105
- theme: o
915
+ theme: a
1106
916
  });
1107
917
  }
1108
- const Mr = i.object({
1109
- layerId: i.string().describe("The id of the layer to apply the size renderer to"),
1110
- fields: i.array(i.string()).describe("The field(s) to use for the size renderer (numeric data)"),
1111
- colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
1112
- theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
1113
- }), Mn = f(Or, {
918
+ const Qr = c.object({
919
+ layerId: c.string().describe("The id of the layer to apply the size renderer to"),
920
+ fields: c.array(c.string()).describe("The field(s) to use for the size renderer (numeric data)"),
921
+ colorSchemes: c.array(c.string()).optional().describe("Optional color scheme tags to use"),
922
+ theme: c.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the size ramp")
923
+ }), La = g(_r, {
1114
924
  name: "size",
1115
925
  description: `Label: Counts and Amounts (size)
1116
926
  Description: Vary symbol sizes along a continuous ramp to represent numeric or ranked data.
@@ -1123,944 +933,168 @@ const Mr = i.object({
1123
933
  Keywords: graduated size, proportional size, classed size, how much, total, number, when
1124
934
  Example: Vary the size of each feature based on the date a ticket was completed.
1125
935
  Fields: This style requires a single field with a date type.`,
1126
- schema: Mr
936
+ schema: Qr
1127
937
  });
1128
- function Qr(e) {
1129
- const { fields: t, layer: r, view: o, colorSchemeTags: a } = e, n = t[0], s = t[1], c = t[2];
1130
- let u;
1131
- return a && (u = rt({
938
+ function Ir(e) {
939
+ const { fields: t, layer: r, view: a, colorSchemeTags: o } = e, i = t[0], s = t[1], n = t[2];
940
+ let l;
941
+ return o && (l = Le({
1132
942
  geometryType: r.geometryType,
1133
- includedTags: a
943
+ includedTags: o
1134
944
  })[0]), {
1135
945
  layer: r,
1136
- view: o,
1137
- field: n,
946
+ view: a,
947
+ field: i,
1138
948
  field2: s,
1139
- field3: c,
949
+ field3: n,
1140
950
  outlineOptimizationEnabled: !0,
1141
951
  sizeOptimizationEnabled: !0,
1142
- typeScheme: u
952
+ typeScheme: l
1143
953
  };
1144
954
  }
1145
- async function _r(e) {
1146
- return await tt(e);
955
+ async function Or(e) {
956
+ return await De(e);
1147
957
  }
1148
- async function Wr({
958
+ async function Kr({
1149
959
  arcgisMap: e,
1150
960
  arcgisMapView: t,
1151
961
  layerId: r,
1152
- fields: o,
1153
- colorSchemes: a,
1154
- theme: n
962
+ fields: a,
963
+ colorSchemes: o,
964
+ theme: i
1155
965
  }) {
1156
- const s = t, c = e?.allLayers.find((l) => l.id === r);
1157
- if (!c)
966
+ const s = t, n = e?.allLayers.find((p) => p.id === r);
967
+ if (!n)
1158
968
  return `Could not find layer for id: ${r}`;
1159
- const u = {
969
+ const l = {
1160
970
  styleName: "type",
1161
- fields: o,
1162
- layer: c,
971
+ fields: a,
972
+ layer: n,
1163
973
  view: s,
1164
- colorSchemeTags: a,
1165
- theme: n
974
+ colorSchemeTags: o,
975
+ theme: i
1166
976
  };
1167
977
  try {
1168
- const l = Qr(u), d = await _r(l);
1169
- return c.renderer = d.renderer, c.visible = !0, `Type renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
1170
- } catch (l) {
1171
- return `Error applying type renderer: ${l instanceof Error ? l.message : String(l)}`;
978
+ const p = Ir(l), d = await Or(p);
979
+ return n.renderer = d.renderer, n.visible = !0, `Type renderer applied to layer: ${n.title ?? n.id} using fields ${a.join(", ")}`;
980
+ } catch (p) {
981
+ return `Error applying type renderer: ${p instanceof Error ? p.message : String(p)}`;
1172
982
  }
1173
983
  }
1174
984
  async function Vr({
1175
985
  layerId: e,
1176
986
  fields: t,
1177
987
  colorSchemes: r,
1178
- theme: o
1179
- }, a) {
1180
- const { mapView: n } = R(a);
1181
- return await x({ type: "show-legend", data: { layerIds: [e] } }, a), await Wr({
1182
- arcgisMap: n.map,
1183
- arcgisMapView: n,
988
+ theme: a
989
+ }, o) {
990
+ const { mapView: i } = v(o);
991
+ return await S({ type: "show-legend", data: { layerIds: [e] } }, o), await Kr({
992
+ arcgisMap: i.map,
993
+ arcgisMapView: i,
1184
994
  layerId: e,
1185
995
  fields: t,
1186
996
  colorSchemes: r,
1187
- theme: o
997
+ theme: a
1188
998
  });
1189
999
  }
1190
- const Ur = i.object({
1191
- layerId: i.string().describe("The id of the layer to apply the type renderer to"),
1192
- fields: i.array(i.string()).describe("The field(s) to use for the type renderer (categorical data)"),
1193
- colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use"),
1194
- theme: i.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color scheme")
1195
- }), Qn = f(Vr, {
1000
+ const Br = c.object({
1001
+ layerId: c.string().describe("The id of the layer to apply the type renderer to"),
1002
+ fields: c.array(c.string()).describe("The field(s) to use for the type renderer (categorical data)"),
1003
+ colorSchemes: c.array(c.string()).optional().describe("Optional color scheme tags to use"),
1004
+ theme: c.enum(["above-and-below", "above", "below", "centered-on", "extremes", "high-to-low"]).optional().describe("Optional theme for the color scheme")
1005
+ }), Ga = g(Vr, {
1196
1006
  name: "type",
1197
1007
  description: `Label: Types (unique symbols)
1198
1008
  Description: Represent features as categories with different symbol colors or shapes. Examples include type of tree, road class, or province name.
1199
1009
  Keywords: categorical, category, type, unique, discrete, point of interest, region, group
1200
1010
  Example: Color each feature based on the region it belongs to
1201
1011
  Fields: This style requires a single field which may be a string, number, or date type. It is usually a string.`,
1202
- schema: Ur
1203
- }), _n = b.Root({
1204
- ...U(),
1205
- vectorSearchLayerIds: b(),
1206
- vectorSearchFieldResults: b(),
1207
- layerFieldInfo: b(),
1208
- selectedLayerId: b()
1209
- }), Wn = b.Root({
1210
- ...U(),
1211
- vectorSearchLayerIds: b(),
1212
- vectorSearchFieldResults: b(),
1213
- layerFieldInfo: b(),
1214
- queryResponse: b(),
1215
- dataExplorationMessages: b({
1216
- reducer: ye,
1217
- default: () => []
1218
- })
1219
- }), Kr = ["mapView"];
1220
- function N(e) {
1221
- const r = e?.configurable?.context;
1222
- if (!r || typeof r != "object")
1223
- throw new Error("DataExplorationAgent context missing");
1224
- const o = Kr.filter((a) => !(a in r));
1225
- if (o.length)
1226
- throw new Error(`DataExplorationAgent context missing: ${o.join(", ")}`);
1227
- return r;
1228
- }
1229
- const Br = (e) => {
1230
- const t = e.map?.allLayers.filter((o) => o.type === "feature");
1231
- let r = 0;
1232
- return t?.forEach((o) => {
1233
- const a = o;
1234
- a.featureEffect && (a.featureEffect = null, r++);
1235
- }), r > 0 ? `Cleared filters from ${r} layer(s). View unchanged.` : "No active filters to clear. View unchanged.";
1236
- }, Hr = async (e, t) => {
1237
- const { mapView: r } = N(t);
1238
- return Br(r);
1239
- }, Jr = f(Hr, {
1240
- name: "clearFilters",
1241
- description: "Clears all feature effects/filters from the map but does NOT change the current view. Use when user says 'clear filters', 'reset filters', 'remove filters', 'show all features', or wants to remove emphasis without navigating anywhere.",
1242
- schema: i.object({})
1243
- }), Zr = async (e) => {
1244
- e.map?.allLayers.filter((a) => a.type === "feature")?.forEach((a) => {
1245
- const n = a;
1246
- n.featureEffect && (n.featureEffect = null);
1247
- });
1248
- const o = e.map.initialViewProperties?.viewpoint?.targetGeometry;
1249
- return o ? (await e.goTo(o), "Cleared all filters and returned to home extent.") : "Cleared all filters. Could not determine home extent.";
1250
- }, Yr = async (e, t) => {
1251
- const { mapView: r } = N(t);
1252
- return await Zr(r);
1253
- }, Xr = f(Yr, {
1254
- name: "resetMap",
1255
- description: "Clears all feature effects/filters from the map AND zooms to the home extent (initial map view). Use when user says 'reset map', 'reset the map', 'start over', or wants to both clear filters and return to the initial view.",
1256
- schema: i.object({})
1257
- }), me = 5;
1258
- function W(e) {
1259
- return "point" in e && e.point !== void 0;
1260
- }
1261
- function P(e) {
1262
- return "layerId" in e && e.layerId !== void 0;
1263
- }
1264
- const K = async (e, t) => {
1265
- if (W(e)) {
1266
- const { point: r } = e;
1267
- return { geometry: new fe({
1268
- x: r.x,
1269
- y: r.y,
1270
- spatialReference: r.spatialReference ? { wkid: r.spatialReference.wkid } : t.spatialReference
1271
- }) };
1272
- }
1273
- if (P(e)) {
1274
- const r = t.map?.allLayers.find(
1275
- (n) => n.id === e.layerId
1276
- );
1277
- if (!r)
1278
- return { error: `Could not find geometry layer with ID: ${e.layerId}` };
1279
- const o = r.title ?? r.id, a = e.where?.trim() || "1=1";
1280
- try {
1281
- const n = await r.queryFeatures({
1282
- where: a,
1283
- returnGeometry: !0,
1284
- outSpatialReference: t.spatialReference,
1285
- num: me + 1
1286
- });
1287
- if (!n.features.length)
1288
- return {
1289
- error: `No features found in geometry layer "${o}" with the specified where clause: ${a}`
1290
- };
1291
- if (n.features.length > me)
1292
- return {
1293
- error: `Geometry filter for layer "${o}" matched too many features (${n.features.length}+). Please narrow the geometry layer filter.`
1294
- };
1295
- const s = n.features.map((u) => u.geometry).filter((u) => !!u);
1296
- if (!s.length)
1297
- return { error: "No valid geometries found for the matched geometry layer features." };
1298
- const c = s.length === 1 ? s[0] : nt.executeMany(s);
1299
- return c ? (c.spatialReference || (c.spatialReference = t.spatialReference), { geometry: c }) : { error: "Failed to combine geometries from geometry layer." };
1300
- } catch (n) {
1301
- return { error: `Failed to query geometry: ${String(n)}` };
1302
- }
1303
- }
1304
- return { error: "Invalid geometry configuration provided" };
1305
- }, eo = async (e, t, r, o, a, n) => {
1306
- const s = e.map?.allLayers.find((u) => u.id === t);
1307
- if (!s)
1308
- return { success: !1, error: `Layer '${t}' not found.` };
1309
- const c = s.createQuery();
1310
- c.where = r ?? "1=1", o && (c.geometry = o, c.spatialRelationship = "intersects", a && (c.distance = a), n && (c.units = n));
1311
- try {
1312
- const { extent: u, count: l } = await s.queryExtent(c);
1313
- return !u || l === 0 ? {
1314
- success: !1,
1315
- error: `No features found for filter (where: ${c.where}${o ? ", spatial filter used" : ""})`
1316
- } : (await e.goTo(u), { success: !0 });
1317
- } catch (u) {
1318
- return {
1319
- success: !1,
1320
- error: u instanceof Error ? u.message : String(u)
1321
- };
1322
- }
1323
- }, to = async (e, t, r, o, a, n) => {
1324
- const s = t.map?.allLayers.find(
1325
- (p) => p.id === e.layerId
1326
- );
1327
- if (!s)
1328
- return `Could not find target layer with ID: ${e.layerId}`;
1329
- let c;
1330
- if (a) {
1331
- const p = await K(a, t);
1332
- if ("error" in p)
1333
- return p.error;
1334
- c = p.geometry;
1335
- }
1336
- if (s.featureEffect = null, s.featureEffect = new at({
1337
- filter: new ge({
1338
- ...e.objectIds?.length ? { objectIds: e.objectIds } : { where: e.where },
1339
- geometry: c,
1340
- spatialRelationship: "intersects",
1341
- distance: a?.distance,
1342
- units: a?.units
1343
- }),
1344
- includedEffect: r,
1345
- excludedEffect: o
1346
- }), s.visible = !0, n)
1347
- return `Applied feature effects to "${s.title ?? e.layerId}" within current map extent.`;
1348
- const u = e.objectIds?.length ? `${s.objectIdField} IN (${e.objectIds.join(",")})` : e.where, l = await eo(
1349
- t,
1350
- e.layerId,
1351
- u,
1352
- c,
1353
- a?.distance,
1354
- a?.units
1355
- ), d = s.title ?? e.layerId;
1356
- return l.success ? `Applied feature effects to target layer "${s.title ?? e.layerId}"${a && "layerId" in a ? ` using geometry from layer "${a.layerId}"` : ""}.` : `Applied filter to "${d}" but no features matched. ${l.error}`;
1357
- }, ro = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], F = i.enum(ro), oo = async ({
1358
- targetLayer: e,
1359
- geometryFilter: t,
1360
- useCurrentExtent: r,
1361
- includedEffect: o = "drop-shadow(2px, 2px, 2px, gray)",
1362
- excludedEffect: a = "grayscale(100%) opacity(60%) blur(2px)"
1363
- }, n) => {
1364
- const { mapView: s } = N(n);
1365
- return await to(e, s, o, a, t, r);
1366
- }, ao = i.object({
1367
- layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1368
- where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1369
- distance: i.number().optional().describe("The buffer distance around the geometry."),
1370
- units: F.optional().describe("The units for the distance buffer.")
1371
- }), no = i.object({
1372
- point: i.object({
1373
- x: i.number().describe("X coordinate (longitude) from navigation result"),
1374
- y: i.number().describe("Y coordinate (latitude) from navigation result"),
1375
- spatialReference: i.object({
1376
- wkid: i.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
1377
- }).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
1378
- }).describe("Point coordinates from a previous navigation/geocoding result"),
1379
- distance: i.number().optional().describe("Optional buffer distance around the point."),
1380
- units: F.optional().describe("The units for the distance buffer.")
1381
- }), io = i.object({
1382
- targetLayer: i.object({
1383
- layerId: i.string().describe("The layerId of the layer on which to set a feature effect."),
1384
- where: i.string().describe("The SQL-92 where clause representing the features to emphasize."),
1385
- objectIds: i.array(i.number()).optional().describe(
1386
- "Array of objectIds from a previous query result. Use this instead of a where clause when the query returned objectIds (e.g. top N results). If provided, takes precedence over where clause."
1387
- )
1388
- }),
1389
- geometryFilter: i.union([ao, no]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),
1390
- useCurrentExtent: i.boolean().optional().describe(
1391
- "Set to true when the previous query used the current map extent as a spatial filter. This ensures the feature effect applies only to features visible in the current view. Default is false."
1392
- ),
1393
- includedEffect: i.string().default("drop-shadow(2px, 2px, 2px, gray)").describe(
1394
- "The effect applied to features that meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified."
1395
- ),
1396
- excludedEffect: i.string().default("grayscale(100%) opacity(60%) blur(2px)").describe(
1397
- "The effect applied to features that do not meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified."
1398
- )
1399
- }), so = f(oo, {
1400
- name: "setFeatureEffect",
1401
- description: "Sets a feature effect on a given layer with given filter parameters and feature effects to emphasize certain features that meet a filter requirement. If no feature effect information is provided, then use the default effect provided.",
1402
- schema: io
1403
- }), X = (e) => {
1404
- if (e instanceof Date)
1405
- return Number.isNaN(e.getTime()) ? null : e;
1406
- if (typeof e == "number" && Number.isFinite(e)) {
1407
- const t = new Date(e);
1408
- return Number.isNaN(t.getTime()) ? null : t;
1409
- }
1410
- return null;
1411
- }, co = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, lo = (e) => {
1412
- if (typeof e == "string" && e)
1413
- return e;
1414
- const t = X(e);
1415
- return t ? t.toISOString().slice(0, 10) : null;
1416
- }, Vn = () => {
1417
- const e = (/* @__PURE__ */ new Date()).getTimezoneOffset(), t = e <= 0 ? "+" : "-", r = Math.floor(Math.abs(e) / 60).toString().padStart(2, "0"), o = (Math.abs(e) % 60).toString().padStart(2, "0"), a = `${t}${r}:${o}`;
1418
- return { userTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone, userTimezoneOffset: a };
1419
- }, uo = (e, t, r) => {
1420
- const o = t?.toLowerCase();
1421
- if (o === "date-only") {
1422
- const n = lo(e);
1423
- return n ? it(n, M("short-date")) : e;
1424
- }
1425
- if (o === "time-only") {
1426
- if (typeof e == "string" && e)
1427
- return st(e, M("long-time"));
1428
- const n = X(e);
1429
- return n ? de(n, {
1430
- ...M("long-time"),
1431
- timeZone: "UTC"
1432
- }) : e;
1433
- }
1434
- const a = X(e);
1435
- return a ? de(a, {
1436
- ...M("short-date-short-time"),
1437
- timeZone: co(r)
1438
- }) : e;
1439
- }, Te = (e, t, r) => {
1440
- if (e && typeof e != "function") {
1441
- const o = "getField" in r && r.getField?.(e), a = o && "getFieldDomain" in r && r.getFieldDomain ? r.getFieldDomain(o.name) : null;
1442
- if (a?.type === "coded-value") {
1443
- const s = a.codedValues.find((c) => c.code === t);
1444
- return s ? s.name : null;
1445
- }
1446
- }
1447
- return null;
1448
- }, po = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, ho = (e) => {
1449
- if (e instanceof Date)
1450
- return Number.isNaN(e.getTime()) ? null : e;
1451
- if (typeof e == "number" && Number.isFinite(e)) {
1452
- const t = new Date(e);
1453
- return Number.isNaN(t.getTime()) ? null : t;
1454
- }
1455
- if (typeof e == "string" && e) {
1456
- const t = new Date(e);
1457
- return Number.isNaN(t.getTime()) ? null : t;
1458
- }
1459
- return null;
1460
- }, mo = (e, t) => {
1461
- if (typeof e != "number")
1462
- return e;
1463
- const r = {};
1464
- t.minimumFractionDigits !== void 0 && (r.minimumFractionDigits = t.minimumFractionDigits), t.maximumFractionDigits !== void 0 && (r.maximumFractionDigits = t.maximumFractionDigits), t.useGrouping === "always" ? r.useGrouping = !0 : t.useGrouping === "never" && (r.useGrouping = !1);
1465
- try {
1466
- return new Intl.NumberFormat(void 0, r).format(e);
1467
- } catch {
1468
- return e;
1469
- }
1470
- }, yo = (e, t, r) => {
1471
- const o = ho(e);
1472
- if (!o)
1473
- return e;
1474
- const a = {};
1475
- t.dateStyle ? a.dateStyle = t.dateStyle : (t.year && (a.year = t.year), t.month && (a.month = t.month)), t.timeStyle && (a.timeStyle = t.timeStyle), t.timeStyle && t.hour12 === "always" ? a.hour12 = !0 : t.timeStyle && t.hour12 === "never" && (a.hour12 = !1), a.timeZone = po(r);
1476
- try {
1477
- return new Intl.DateTimeFormat(void 0, a).format(o);
1478
- } catch {
1479
- return e;
1480
- }
1481
- }, ve = (e, t) => e.getFieldAlias?.(t) ?? e.fieldsIndex?.get(t)?.alias ?? e.fieldsIndex?.get(t)?.name ?? t, Se = (e, t, r, o, a) => {
1482
- if (r == null)
1483
- return r;
1484
- const s = e.getFieldConfiguration?.(t)?.fieldFormat;
1485
- return s?.type === "number" ? mo(r, s) : s?.type === "date-time" ? yo(r, s, a) : uo(r, o, a);
1486
- }, fo = (e, t, r, o) => {
1487
- const a = e.fieldsIndex?.get(t), n = Te(t, r, e) ?? r;
1488
- return Se(e, t, n, a?.type, o);
1489
- }, go = (e, t) => ve(e, t), xe = (e, t, r) => {
1490
- const o = e.objectIdField, a = t.features.map(
1491
- (s) => s.attributes[o]
1492
- ), n = t.features.map((s) => {
1493
- const c = s.attributes, u = {};
1494
- return e.fields.forEach((l) => {
1495
- if (!Object.hasOwn(c, l.name))
1496
- return;
1497
- const d = c[l.name];
1498
- if (l.name === o) {
1499
- u[l.name] = d;
1500
- return;
1501
- }
1502
- const p = Te(l.name, d, e) ?? d, h = ve(e, l.name);
1503
- u[h] = Se(e, l.name, p, l.type, r);
1504
- }), u;
1505
- });
1506
- return { objectIds: a, attributes: n };
1507
- }, wo = (e, t, r) => {
1508
- const o = e.createQuery();
1509
- return o.outFields = [t], o.where = r || "1=1", o.num = 1, o;
1510
- }, bo = async (e, t, r, o) => {
1511
- const a = o.map?.allLayers.find((h) => h.id === e), n = wo(a, t, r.where), c = (await a.queryFeatures(n)).features[0], u = c ? c.attributes[t] : null, l = fo(a, t, u, o.timeZone), d = go(a, t);
1512
- return {
1513
- tool: "getAttribute",
1514
- layerName: a.title ?? e,
1515
- summary: `${d} = ${l}`,
1516
- details: {
1517
- fieldName: t,
1518
- fieldAlias: d !== t ? d : void 0,
1519
- value: l,
1520
- where: r.where
1521
- }
1522
- };
1523
- };
1524
- async function To({ layerId: e, fieldName: t, query: r }, o) {
1525
- const { mapView: a } = N(o), n = await bo(e, t, r, a);
1526
- return JSON.stringify(n, null, 2);
1527
- }
1528
- const vo = i.object({
1529
- layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
1530
- fieldName: i.string().describe("The name of the field/attribute from which to get a field value."),
1531
- query: i.object({
1532
- where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
1533
- })
1534
- }), So = f(To, {
1535
- name: "getAttribute",
1536
- description: "Returns an attribute value for a given feature.",
1537
- schema: vo
1538
- }), oe = (e, t, r) => r ? e.hasAllFeaturesInView && e.availableFields === t : e.hasAllFeatures && e.availableFields === t;
1539
- function V(e, t) {
1540
- let r = e ?? "";
1541
- return t != null && t && (r = r ? `(${r}) AND (${t})` : t), r || null;
1542
- }
1543
- const xo = async (e) => {
1544
- const { targetLayer: t, fieldName: r, statisticType: o, mapView: a, layersAndFieldsRegistry: n, geometryFilter: s } = e, c = a.map?.allLayers.find((v) => v.id === t.layerId);
1545
- if (!c)
1546
- throw new Error(`Layer '${t.layerId}' not found.`);
1547
- const u = await a.whenLayerView(c), d = n.get(t.layerId)?.fieldRegistry.get(r), p = d?.alias;
1548
- if (!d)
1549
- throw new Error(`Field '${r}' not found.`);
1550
- let h, m;
1551
- if (s) {
1552
- const v = await K(s, a);
1553
- if ("error" in v)
1554
- throw new Error(v.error);
1555
- if (!v.geometry)
1556
- throw P(s) ? new Error(`No features found matching: ${s.where}`) : new Error("Failed to create geometry");
1557
- if (P(s)) {
1558
- const O = a.map?.allLayers.find((A) => A.id === s.layerId);
1559
- h = {
1560
- geometryLayerName: O?.title ?? O?.id,
1561
- geometryLayerId: s.layerId,
1562
- geometryWhere: s.where,
1563
- distance: s.distance,
1564
- units: s.units,
1565
- applied: !0
1566
- };
1567
- } else W(s) && (h = {
1568
- point: s.point,
1569
- distance: s.distance,
1570
- units: s.units,
1571
- applied: !0
1572
- });
1573
- m = new ge({
1574
- geometry: v.geometry,
1575
- distance: s.distance,
1576
- units: s.units,
1577
- spatialRelationship: "intersects"
1578
- });
1579
- }
1580
- const w = oe(u, [r], !1);
1581
- let y = null, g = null;
1582
- const T = 10;
1583
- if (d.type !== "geometry" && d.type !== "oid" && d.type !== "global-id")
1584
- try {
1585
- const v = {
1586
- layer: c,
1587
- useFeaturesInView: w,
1588
- view: w ? a : void 0,
1589
- field: r,
1590
- sqlWhere: V(c.definitionExpression, t.where),
1591
- ...m && { filter: m },
1592
- outStatisticTypes: { include: [o] }
1593
- };
1594
- y = await ct(v);
1595
- const O = ["string", "small-integer", "integer"], A = d.domain?.type === "coded-value" ? d.domain : null;
1596
- (O.includes(d.type) || A) && (g = (await lt({
1597
- layer: c,
1598
- useFeaturesInView: w,
1599
- view: w ? a : void 0,
1600
- field: r,
1601
- sqlWhere: V(c.definitionExpression, t.where),
1602
- ...m && { filter: m }
1603
- })).uniqueValueInfos.sort((q, Ne) => Ne.count - q.count).slice(0, T)), g && d.domain?.type === "coded-value" && (g = g.map((q) => ({
1604
- ...q,
1605
- value: A ? A.getName(q.value) ?? q.value : q.value
1606
- })));
1607
- } catch (v) {
1608
- console.error("Statistics error:", v);
1609
- }
1610
- return {
1611
- tool: "getStatistics",
1612
- layerName: c.title ?? t.layerId,
1613
- summary: `${o} = ${typeof y?.[o] == "number" ? y[o] : "N/A"}`,
1614
- details: {
1615
- fieldName: r,
1616
- fieldAlias: p,
1617
- statisticType: o,
1618
- statistic: y?.[o] ?? null,
1619
- summaryStatistics: y,
1620
- uniqueValues: g,
1621
- where: t.where,
1622
- spatialFilterInfo: h
1623
- }
1624
- };
1625
- };
1626
- async function Ro({
1627
- targetLayer: e,
1628
- fieldName: t,
1629
- statisticType: r,
1630
- geometryFilter: o
1631
- }, a) {
1632
- const n = be(a, "layersAndFieldsRegistry"), { mapView: s } = N(a), c = await xo({
1633
- targetLayer: e,
1634
- fieldName: t,
1635
- statisticType: r,
1636
- mapView: s,
1637
- layersAndFieldsRegistry: n,
1638
- geometryFilter: o
1639
- });
1640
- return JSON.stringify(c, null, 2);
1641
- }
1642
- const $o = i.object({
1643
- layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1644
- where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1645
- distance: i.number().optional().describe("The buffer distance around the geometry."),
1646
- units: F.optional().describe("The units for the distance buffer.")
1647
- }), Eo = i.object({
1648
- point: i.object({
1649
- x: i.number().describe("X coordinate (longitude) from navigation result"),
1650
- y: i.number().describe("Y coordinate (latitude) from navigation result"),
1651
- spatialReference: i.object({
1652
- wkid: i.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
1653
- }).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
1654
- }).describe("Point coordinates from a previous navigation/geocoding result"),
1655
- distance: i.number().optional().describe("Optional buffer distance around the point."),
1656
- units: F.optional().describe("The units for the distance buffer.")
1657
- }), Co = i.object({
1658
- targetLayer: i.object({
1659
- layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
1660
- where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
1661
- }),
1662
- geometryFilter: i.union([$o, Eo]).optional().describe(
1663
- "Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."
1664
- ),
1665
- fieldName: i.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),
1666
- statisticType: i.enum(["avg", "max", "median", "min", "stddev", "sum", "variance", "nullcount", "count"]).describe("The statistic type to calculate.")
1667
- }), Fo = f(Ro, {
1668
- name: "getStatistics",
1669
- description: `Computes a single aggregate statistic (max, min, avg, sum, median, stddev, variance) for a numeric field across matching features. Also returns frequency analysis for categorical fields.
1670
-
1671
- USE THIS TOOL FOR:
1672
- - "What is the average/maximum/minimum/total [field]?" — aggregate computations
1673
- - "Most common/frequent value of [field]?" — frequency analysis
1674
- - Questions requiring a mathematical aggregation across many features
1675
-
1676
- DO NOT USE FOR:
1677
- - "How many features match X?" — use queryFeatures instead (it returns totalCount)
1678
- - "Show / list / find features" — use queryFeatures instead
1679
- - Simple counts of features matching a condition — use queryFeatures instead
1680
-
1681
- Only call this tool when the answer requires computing an aggregate (avg, max, min, sum, median, stddev) over a field's values, not just counting or listing features.`,
1682
- schema: Co
1683
- }), Io = async (e, t, r, o, a) => {
1684
- const n = r.map?.allLayers.find((h) => h.id === e.layerId), s = await r.whenLayerView(n), c = n.title ?? e.layerId;
1685
- let u;
1686
- if (o) {
1687
- const h = await K(o, r);
1688
- if ("error" in h)
1689
- return {
1690
- tool: "getTopFeatures",
1691
- layerName: c,
1692
- summary: "Geometry lookup failed",
1693
- details: { error: h.error }
1694
- };
1695
- if (!h.geometry)
1696
- return {
1697
- tool: "getTopFeatures",
1698
- layerName: c,
1699
- summary: "No features found for geometry filter",
1700
- details: {
1701
- error: `No features found matching: ${"where" in o ? o.where : "unknown criteria"}`
1702
- }
1703
- };
1704
- u = h.geometry;
1705
- } else a && (u = r.extent.clone());
1706
- const l = t.groupByFields && t.groupByFields.length > 0, d = n.objectIdField, p = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, d])];
1707
- try {
1708
- let h;
1709
- if (l) {
1710
- const y = new ut({
1711
- where: e.where || "1=1",
1712
- outFields: p,
1713
- orderByFields: e.orderByFields,
1714
- geometry: u,
1715
- spatialRelationship: u ? "intersects" : void 0,
1716
- distance: o?.distance,
1717
- units: o?.units,
1718
- topFilter: new dt({
1719
- topCount: t.topCount,
1720
- groupByFields: t.groupByFields,
1721
- orderByFields: t.orderByFields
1722
- })
1723
- });
1724
- h = await n.queryTopFeatures(y);
1725
- } else {
1726
- const y = n.createQuery();
1727
- y.where = V(n.definitionExpression, e.where || "1=1"), y.outFields = p.length ? p : ["*"], y.orderByFields = t.orderByFields, y.num = t.topCount, u && (y.geometry = u, y.spatialRelationship = "intersects"), o?.distance && (y.distance = o.distance), o?.units && (y.units = o.units), y.outSpatialReference = r.spatialReference;
1728
- const g = oe(s, e.outFields, a ?? !1);
1729
- try {
1730
- h = g ? await s.queryFeatures(y) : await n.queryFeatures(y);
1731
- } catch (T) {
1732
- console.warn("Client-side query failed, falling back to server:", T), h = await n.queryFeatures(y);
1733
- }
1734
- }
1735
- const m = h.features.map((y) => y.attributes[d]), { attributes: w } = xe(n, h, r.timeZone);
1736
- return {
1737
- tool: "getTopFeatures",
1738
- layerName: c,
1739
- summary: `Top ${t.topCount} features extracted`,
1740
- details: {
1741
- topCount: t.topCount,
1742
- attributes: w,
1743
- objectIds: m,
1744
- objectIdField: d,
1745
- where: e.where,
1746
- orderByFields: t.orderByFields,
1747
- ...l && { groupByFields: t.groupByFields }
1748
- }
1749
- };
1750
- } catch (h) {
1751
- return {
1752
- tool: "getTopFeatures",
1753
- layerName: c,
1754
- summary: "Query failed",
1755
- details: { error: h instanceof Error ? h.message : String(h) }
1756
- };
1757
- }
1758
- }, ko = async ({
1759
- targetLayer: e,
1760
- topFilter: t,
1761
- geometryFilter: r,
1762
- useCurrentExtent: o
1763
- }, a) => {
1764
- const { mapView: n } = N(a), s = await Io(e, t, n, r, o);
1765
- return JSON.stringify(s, null, 2);
1766
- }, No = i.object({
1767
- layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1768
- where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1769
- distance: i.number().optional().describe("The buffer distance around the geometry."),
1770
- units: F.optional().describe("The units for the distance buffer.")
1771
- }), zo = i.object({
1772
- point: i.object({
1773
- x: i.number().describe("X coordinate (longitude) from navigation result"),
1774
- y: i.number().describe("Y coordinate (latitude) from navigation result"),
1775
- spatialReference: i.object({
1776
- wkid: i.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
1777
- }).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
1778
- }).describe("Point coordinates from a previous navigation/geocoding result"),
1779
- distance: i.number().optional().describe("Optional buffer distance around the point."),
1780
- units: F.optional().describe("The units for the distance buffer.")
1781
- }), qo = i.object({
1782
- targetLayer: i.object({
1783
- layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
1784
- where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),
1785
- orderByFields: i.array(i.string().describe("The field(s) and order for which to sort the resulting features.")),
1786
- outFields: i.array(
1787
- i.string().describe(
1788
- 'The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").'
1789
- ).default("*")
1790
- )
1791
- }),
1792
- geometryFilter: i.union([No, zo]).optional().describe(
1793
- "Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."
1794
- ),
1795
- topFilter: i.object({
1796
- topCount: i.number().describe("Number of top features to return per group."),
1797
- orderByFields: i.array(
1798
- i.string().describe("Field(s) to rank by with ASC/DESC. Must be existing field names, not aggregate functions.")
1799
- ),
1800
- groupByFields: i.array(i.string().describe("Field(s) to group results by. Returns top N per group."))
1801
- }).required(),
1802
- useCurrentExtent: i.boolean().optional().describe(
1803
- "Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at'. Default is false (queries entire layer)."
1804
- )
1805
- }), Do = f(ko, {
1806
- name: "getTopFeatures",
1807
- description: 'Returns top N features ranked by an existing field value. Use for "highest", "lowest", "top N" questions where ranking is based on a field that already exists in the data (e.g., population, value, date, depth). orderByFields must be actual field names with ASC/DESC. Do NOT use aggregate functions like COUNT(), SUM(), AVG() - those require getStatistics.',
1808
- schema: qo
1809
- }), Z = 25, Ao = async (e, t, r, o) => {
1810
- const a = t.map?.allLayers.find((y) => y.id === e.layerId), n = await t.whenLayerView(a), s = a.title ?? e.layerId;
1811
- let c;
1812
- if (r) {
1813
- const y = await K(r, t);
1814
- if ("error" in y) {
1815
- const g = { error: y.error };
1816
- if (P(r)) {
1817
- const T = t.map?.allLayers.find((E) => E.id === r.layerId);
1818
- g.geometryLayerName = T?.title ?? T?.id, g.geometryLayerId = r.layerId, g.geometryWhere = r.where;
1819
- } else W(r) && (g.point = r.point);
1820
- return {
1821
- tool: "queryFeatures",
1822
- layerName: s,
1823
- summary: "Geometry lookup failed",
1824
- details: g
1825
- };
1826
- }
1827
- if (!y.geometry) {
1828
- const g = {};
1829
- if (P(r)) {
1830
- const T = t.map?.allLayers.find((E) => E.id === r.layerId);
1831
- g.error = `No features found matching: ${r.where}`, g.geometryLayerName = T?.title ?? T?.id, g.geometryLayerId = r.layerId, g.geometryWhere = r.where;
1832
- } else W(r) && (g.error = "Failed to create point geometry", g.point = r.point);
1833
- return {
1834
- tool: "queryFeatures",
1835
- layerName: s,
1836
- summary: "No features found for geometry filter",
1837
- details: g
1838
- };
1839
- }
1840
- c = y.geometry;
1841
- } else o && (c = t.extent.clone());
1842
- const u = oe(n, e.outFields, o ?? !1), l = a.objectIdField, d = a.createQuery();
1843
- d.where = V(a.definitionExpression, e.where || "1=1"), d.outFields = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, l])], d.orderByFields = e.orderByFields, c && (d.geometry = c, d.spatialRelationship = "intersects"), r?.distance && (d.distance = r.distance), r?.units && (d.units = r.units), d.outSpatialReference = t.spatialReference;
1844
- let p, h;
1845
- try {
1846
- p = u ? await n.queryFeatureCount(d) : await a.queryFeatureCount(d), p > 0 && p <= Z && (h = u ? await n.queryFeatures(d) : await a.queryFeatures(d));
1847
- } catch (y) {
1848
- console.warn("Client-side query failed, falling back to server:", y), p = await a.queryFeatureCount(d), p > 0 && p <= Z && (h = await a.queryFeatures(d));
1849
- }
1850
- const { objectIds: m, attributes: w } = h ? xe(a, h, t.timeZone) : { objectIds: void 0, attributes: void 0 };
1851
- return {
1852
- tool: "queryFeatures",
1853
- layerName: s,
1854
- summary: `${p} features found`,
1855
- details: {
1856
- totalCount: p,
1857
- where: e.where,
1858
- orderByFields: e.orderByFields,
1859
- outFields: e.outFields,
1860
- ...m && { objectIds: m, objectIdField: l },
1861
- ...w && { attributes: w },
1862
- ...p > Z && {
1863
- note: `${p} features found.`
1864
- }
1865
- }
1866
- };
1867
- };
1868
- async function Lo({
1869
- targetLayer: e,
1870
- geometryFilter: t,
1871
- useCurrentExtent: r
1872
- }, o) {
1873
- const { mapView: a } = N(o), n = await Ao(e, a, t, r);
1874
- return JSON.stringify(n, null, 2);
1875
- }
1876
- const Po = i.object({
1877
- layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1878
- where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1879
- distance: i.number().optional().describe("The buffer distance around the geometry."),
1880
- units: F.optional().describe("The units for the distance buffer.")
1881
- }), jo = i.object({
1882
- point: i.object({
1883
- x: i.number().describe("X coordinate (longitude) from navigation result"),
1884
- y: i.number().describe("Y coordinate (latitude) from navigation result"),
1885
- spatialReference: i.object({
1886
- wkid: i.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
1887
- }).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
1888
- }).describe("Point coordinates from a previous navigation/geocoding result"),
1889
- distance: i.number().optional().describe("Optional buffer distance around the point."),
1890
- units: F.optional().describe("The units for the distance buffer.")
1891
- }), Go = i.object({
1892
- targetLayer: i.object({
1893
- layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
1894
- where: i.string().describe(
1895
- "SQL-92 where clause. IMPORTANT: When using geometryFilter.point for point-in-polygon queries, set this to '1=1' to return all features that intersect the point. Only add attribute filters if the user specifically requests them in addition to the spatial query."
1896
- ),
1897
- orderByFields: i.array(i.string().describe("The field(s) and order for which to sort the resulting features.")),
1898
- outFields: i.array(
1899
- i.string().describe(
1900
- 'The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").'
1901
- ).default("*")
1902
- )
1903
- }),
1904
- geometryFilter: i.union([Po, jo]).optional().describe(
1905
- "Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."
1906
- ),
1907
- useCurrentExtent: i.boolean().optional().describe(
1908
- "Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at', OR when the user refers back to features previously identified using the current extent (e.g. 'these', 'those', 'them', 'the same ones'). Default is false (queries entire layer)."
1909
- )
1910
- }), Oo = f(Lo, {
1911
- name: "queryFeatures",
1912
- description: `Queries features from a layer. Returns the total count of matching features, plus individual feature attributes if ≤25 features match.
1913
-
1914
- USE THIS TOOL FOR:
1915
- - "Show / display / list features where..." — finding and listing features
1916
- - "How many X are Y?" — counting features that match a condition
1917
- - "Which features..." / "Find features..." — identifying specific features
1918
- - Spatial queries — finding features near/within/intersecting other features
1919
- - Any question where the user wants to SEE or COUNT matching features
1920
-
1921
- This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
1922
- schema: Go
1923
- }), Mo = [So, Fo, Do, Oo], Un = [so, Xr, Jr], Qo = new ot(Mo, { handleToolErrors: !1 });
1924
- async function Kn(e, t) {
1925
- const { messages: r } = await Qo.invoke({ messages: e.dataExplorationMessages }, t), o = [], a = [];
1926
- for (const n of r) {
1927
- const s = n.content;
1928
- let c;
1929
- typeof s != "string" && (c = {
1930
- tool: n.name ?? "unknown",
1931
- layerName: "unknown",
1932
- summary: "Query failed",
1933
- details: { error: "Skipping non-string tool output:", raw: s }
1934
- });
1935
- try {
1936
- typeof s == "string" ? c = JSON.parse(s) : c = {
1937
- tool: n.name ?? "unknown",
1938
- layerName: "unknown",
1939
- summary: "Query failed",
1940
- details: { error: "Invalid tool output type", raw: s }
1941
- };
1942
- } catch {
1943
- c = {
1944
- tool: n.name ?? "unknown",
1945
- layerName: "unknown",
1946
- summary: "Query failed",
1947
- details: { error: s }
1948
- };
1949
- }
1950
- o.push(c), c.details && typeof c.details == "object" && "error" in c.details ? a.push(`- ${c.tool}: Error - ${String(c.details.error)}`) : a.push(`- ${c.layerName}: ${c.summary}`);
1951
- }
1952
- return await S({ text: `Finished executing layer query tool: ${a.join(", ")}` }, t), {
1953
- ...e,
1954
- dataExplorationMessages: [...e.dataExplorationMessages, ...r],
1955
- queryResponse: o,
1956
- status: "success",
1957
- summary: a.length > 0 ? Wt(a.join(`
1958
- `)) : "Query executed."
1959
- };
1960
- }
1961
- const Bn = b.Root({
1962
- ...U(),
1012
+ schema: Br
1013
+ }), ja = m.Root({
1014
+ ...G(),
1015
+ vectorSearchLayerIds: m(),
1016
+ vectorSearchFieldResults: m(),
1017
+ layerFieldInfo: m(),
1018
+ selectedLayerId: m()
1019
+ }), Fa = m.Root({
1020
+ ...G(),
1963
1021
  // internal to the help agent
1964
- helpInternalState: b({
1965
- reducer: L,
1022
+ helpInternalState: m({
1023
+ reducer: k,
1966
1024
  default: () => ({
1967
1025
  toolCallMessage: void 0
1968
1026
  })
1969
1027
  })
1970
- }), _o = (e, t) => {
1971
- const r = Array.from(e.values()).find(
1972
- ({ layerItem: n }) => n.title?.toLowerCase().includes(t.toLowerCase())
1973
- );
1974
- if (!r) {
1975
- const n = Array.from(e.values()).map((s) => s.layerItem.title).join(", ");
1976
- return `Could not find a layer matching "${t}". Available layers: ${n}`;
1977
- }
1978
- const o = Array.from(r.fieldRegistry.values()), a = o.map((n) => `- **${n.alias || n.name}** (\`${n.name}\`, ${n.type})${n.description ? `: ${n.description}` : ""}`).join(`
1979
- `);
1980
- return `**${r.layerItem.title}** has ${o.length} field(s):
1981
-
1982
- ${a}`;
1983
- }, Wo = async ({ layerTitle: e }, t) => {
1984
- const r = be(t, "layersAndFieldsRegistry");
1985
- return _o(r, e);
1986
- }, Hn = f(Wo, {
1987
- name: "listLayerFields",
1988
- description: "Lists all fields for a given layer by title. Use ONLY when the user explicitly asks to see fields, columns, or attributes of a specific named layer. Do NOT call this tool for general help questions, capability overviews, or layer listing.",
1989
- schema: i.object({
1990
- layerTitle: i.string().describe("The title or partial title of the layer to list fields for.")
1991
- })
1992
- }), Jn = b.Root({
1993
- ...U(),
1994
- intent: b({
1028
+ }), _a = m.Root({
1029
+ ...G(),
1030
+ intent: m({
1995
1031
  reducer: (e, t) => t
1996
1032
  }),
1997
- arcgisKnowledgeMessages: b({
1998
- reducer: ye,
1033
+ arcgisKnowledgeMessages: m({
1034
+ reducer: ee,
1999
1035
  default: () => []
2000
1036
  }),
2001
- arcgisKnowledgeToolResult: b({
1037
+ arcgisKnowledgeToolResult: m({
2002
1038
  reducer: (e, t) => t,
2003
1039
  default: () => null
2004
1040
  })
2005
- }), Q = {
2006
- conversationId: ""
2007
- };
2008
- function ae(e) {
1041
+ });
1042
+ function B(e) {
2009
1043
  const t = e.map?.allLayers.filter((r) => r.type === "knowledge-graph");
2010
1044
  if (!t || t?.length !== 1)
2011
1045
  throw new Error("The Knowledge Agent currently only supports maps with exactly one Knowledge Graph Layer.");
2012
1046
  }
2013
- function z(e) {
2014
- return !!e?.map && !("activeLinkChartLayer" in e.map);
1047
+ function x(e) {
1048
+ return !!e?.map && "activeLinkChartLayer" in e.map;
2015
1049
  }
2016
- async function B(e) {
2017
- !e || z(e) || !e.map?.diagramNodesExtent || await e.goTo(e.map.diagramNodesExtent);
1050
+ async function j(e) {
1051
+ !x(e) || !e.map.diagramNodesExtent || await e.goTo(e.map.diagramNodesExtent);
2018
1052
  }
2019
- function H(e) {
1053
+ function q(e) {
2020
1054
  const r = e?.configurable?.context;
2021
1055
  if (!r || typeof r != "object")
2022
1056
  throw new Error("ArcgisKnowledgeAgent context missing");
2023
1057
  if (!("view" in r))
2024
1058
  throw new Error("View context missing");
2025
- const o = r.view;
2026
- return o.map && !("activeLinkChartLayer" in o.map) && ae(o), {
2027
- view: o
1059
+ const a = r.view;
1060
+ return a.map && !("activeLinkChartLayer" in a.map) && B(a), {
1061
+ view: a
2028
1062
  };
2029
1063
  }
2030
- function Zn(e) {
1064
+ function Qa(e) {
2031
1065
  const r = e?.configurable?.context;
2032
- if (Re(e) === "knowledgeGraph")
1066
+ if (te(e) === "knowledgeGraph")
2033
1067
  return "knowledgeGraph";
2034
- const a = r.view;
2035
- return z(a) ? (ae(a), "map") : "linkChart";
1068
+ const o = r.view;
1069
+ return x(o) ? "linkChart" : (B(o), "map");
2036
1070
  }
2037
- async function G(e) {
1071
+ async function N(e) {
2038
1072
  const r = e?.configurable?.context;
2039
- if (Re(e) === "knowledgeGraph")
1073
+ if (te(e) === "knowledgeGraph")
2040
1074
  return r;
2041
1075
  {
2042
- const a = r.view.map;
2043
- if (a && "activeLinkChartLayer" in a) {
2044
- const n = a.knowledgeGraph?.url;
2045
- if (!n)
1076
+ const o = r.view.map;
1077
+ if (o && "activeLinkChartLayer" in o) {
1078
+ const i = o.knowledgeGraph?.url;
1079
+ if (!i)
2046
1080
  throw new Error("Knowledge graph url missing from link chart.");
2047
1081
  return {
2048
- knowledgeGraph: await pe(n)
1082
+ knowledgeGraph: await Y(i)
2049
1083
  };
2050
1084
  } else {
2051
- ae(r.view);
1085
+ B(r.view);
2052
1086
  const s = (r.view.map?.allLayers.find(
2053
- (u) => u.type === "knowledge-graph"
1087
+ (l) => l.type === "knowledge-graph"
2054
1088
  )).url;
2055
1089
  if (!s)
2056
1090
  throw new Error("Knowledge graph url missing from map.");
2057
1091
  return {
2058
- knowledgeGraph: await pe(s)
1092
+ knowledgeGraph: await Y(s)
2059
1093
  };
2060
1094
  }
2061
1095
  }
2062
1096
  }
2063
- function Re(e) {
1097
+ function te(e) {
2064
1098
  const r = e?.configurable?.context;
2065
1099
  if (!r || typeof r != "object")
2066
1100
  throw new Error("ArcgisKnowledgeAgent context missing");
@@ -2072,12 +1106,12 @@ function Re(e) {
2072
1106
  return "view";
2073
1107
  throw new Error("ArcgisKnowledgeAgent context must have either a view or knowledgeGraph property.");
2074
1108
  }
2075
- class Vo {
1109
+ class Wr {
2076
1110
  constructor(t) {
2077
- this.dataModel = t, this.kind = "GraphQueryGenerationRequest", this.explainQuery = !0, this.schemaInformation = ne.fromDataModel(t);
1111
+ this.dataModel = t, this.kind = "GraphQueryGenerationRequest", this.explainQuery = !0, this.schemaInformation = W.fromDataModel(t);
2078
1112
  }
2079
1113
  }
2080
- class ne {
1114
+ class W {
2081
1115
  constructor() {
2082
1116
  this.schemaType = "ArcgisGraphSchema", this.entityTypes = [], this.relationshipTypes = [], this.identifierInfo = {
2083
1117
  mappingInfo: {
@@ -2087,14 +1121,14 @@ class ne {
2087
1121
  };
2088
1122
  }
2089
1123
  static fromDataModel(t) {
2090
- const r = new ne();
2091
- for (const o of t.entityTypes)
2092
- r.entityTypes.push(j.fromEntityType(o));
2093
- for (const o of t.relationshipTypes)
2094
- r.relationshipTypes.push(Uo.fromRelationshipType(o));
1124
+ const r = new W();
1125
+ for (const a of t.entityTypes)
1126
+ r.entityTypes.push(A.fromEntityType(a));
1127
+ for (const a of t.relationshipTypes)
1128
+ r.relationshipTypes.push(Ur.fromRelationshipType(a));
2095
1129
  return r.identifierInfo = {
2096
1130
  mappingInfo: {
2097
- identifierMapsTo: Ko(
1131
+ identifierMapsTo: Hr(
2098
1132
  t.identifierInfo.identifierMappingInfo.identifierInfoType
2099
1133
  ),
2100
1134
  identifierPropertyName: t.identifierInfo.identifierMappingInfo.uniformPropertyIdentifier.identifierPropertyName
@@ -2103,51 +1137,51 @@ class ne {
2103
1137
  }
2104
1138
  // Generates a short summary of the types in the data model for LLM consumption.
2105
1139
  static getDataModelTypesSummary(t) {
2106
- const r = t.entityTypes.map((a) => a.name).join(", "), o = t.relationshipTypes.map((a) => a.name).join(", ");
1140
+ const r = t.entityTypes.map((o) => o.name).join(", "), a = t.relationshipTypes.map((o) => o.name).join(", ");
2107
1141
  return `Entity Types: ${r}.
2108
- Relationship Types: ${o}.`;
1142
+ Relationship Types: ${a}.`;
2109
1143
  }
2110
1144
  }
2111
- class j {
1145
+ class A {
2112
1146
  constructor() {
2113
1147
  this.name = "", this.properties = [];
2114
1148
  }
2115
1149
  static fromEntityType(t) {
2116
- const r = new j();
2117
- r.name = t.name, r.alias = t.alias ? t.alias : void 0, r.role = Bo(t.role);
2118
- for (const o of t.properties) {
2119
- const a = {
2120
- name: o.name,
2121
- alias: o.alias ? o.alias : void 0,
2122
- fieldType: o.fieldType,
2123
- role: Ho(o.role),
2124
- geometryDef: o.fieldType === "esriFieldTypeGeometry" ? {
2125
- geometryType: o.geometryType ?? "esriGeometryAny",
2126
- hasM: o.hasM ? o.hasM : void 0,
2127
- hasZ: o.hasZ ? o.hasZ : void 0
1150
+ const r = new A();
1151
+ r.name = t.name, r.alias = t.alias ? t.alias : void 0, r.role = Jr(t.role);
1152
+ for (const a of t.properties) {
1153
+ const o = {
1154
+ name: a.name,
1155
+ alias: a.alias ? a.alias : void 0,
1156
+ fieldType: a.fieldType,
1157
+ role: Xr(a.role),
1158
+ geometryDef: a.fieldType === "esriFieldTypeGeometry" ? {
1159
+ geometryType: a.geometryType ?? "esriGeometryAny",
1160
+ hasM: a.hasM ? a.hasM : void 0,
1161
+ hasZ: a.hasZ ? a.hasZ : void 0
2128
1162
  } : void 0
2129
1163
  };
2130
- r.properties.push(a);
1164
+ r.properties.push(o);
2131
1165
  }
2132
1166
  return r;
2133
1167
  }
2134
1168
  }
2135
- class Uo extends j {
1169
+ class Ur extends A {
2136
1170
  constructor() {
2137
1171
  super(...arguments), this.observedEndPoints = [];
2138
1172
  }
2139
1173
  static fromRelationshipType(t) {
2140
- const r = j.fromEntityType(t);
1174
+ const r = A.fromEntityType(t);
2141
1175
  r.observedEndPoints = [];
2142
- for (const o of t.endPoints)
1176
+ for (const a of t.endPoints)
2143
1177
  r.observedEndPoints.push({
2144
- originEntityType: o.originEntityType,
2145
- destinationEntityType: o.destinationEntityType
1178
+ originEntityType: a.originEntityType,
1179
+ destinationEntityType: a.destinationEntityType
2146
1180
  });
2147
1181
  return r;
2148
1182
  }
2149
1183
  }
2150
- const Ko = (e) => {
1184
+ const Hr = (e) => {
2151
1185
  switch (e) {
2152
1186
  case "esriIdentifierInfoTypeUNSPECIFIED":
2153
1187
  return "UNSPECIFIED";
@@ -2158,7 +1192,7 @@ const Ko = (e) => {
2158
1192
  default:
2159
1193
  return e;
2160
1194
  }
2161
- }, Bo = (e) => {
1195
+ }, Jr = (e) => {
2162
1196
  switch (e) {
2163
1197
  case "Regular":
2164
1198
  return "esriGraphNamedObjectRegular";
@@ -2170,7 +1204,7 @@ const Ko = (e) => {
2170
1204
  return e;
2171
1205
  }
2172
1206
  };
2173
- function Ho(e) {
1207
+ function Xr(e) {
2174
1208
  switch (e) {
2175
1209
  case "esriGraphPropertyRegular":
2176
1210
  return "Regular";
@@ -2208,389 +1242,496 @@ function Ho(e) {
2208
1242
  return "Regular";
2209
1243
  }
2210
1244
  }
2211
- function Jo(e, t) {
2212
- return t ? `${e}
1245
+ function F(e) {
1246
+ return e?.signal;
1247
+ }
1248
+ async function Yr(e, t) {
1249
+ const r = await L("arcgis_knowledge_cypher_query_prompt");
1250
+ return t ? `${e} ${r}
2213
1251
 
2214
1252
  Your previous attempt to generate a cypher query failed. See the details below and generate a new cypher query that avoids this error.
2215
1253
 
2216
1254
  Attempt Number: ${t.attemptCount}
2217
1255
  Execution Error: ${t.executionError}
2218
1256
  Failed Query:
2219
- ${t.failedGraphQuery}` : e;
2220
- }
2221
- async function Zo(e, t, r, o) {
2222
- const { graphQuery: a, explanation: n } = await ie(e, t, r, o);
2223
- return `Generated Graph Query:
2224
- ${a}
2225
-
2226
- Explanation: ${n}`;
2227
- }
2228
- async function ie(e, t, r, o, a) {
2229
- const n = {
2230
- message: Jo(e, a),
2231
- context: new Vo(t)
2232
- };
2233
- Q.conversationId && (n.conversationId = Q.conversationId), await S({ text: "Attempting to generate a cypher query from your prompt..." }, o);
2234
- const s = await le(`${r}/chat`, {
1257
+ ${t.failedGraphQuery}` : `${e} ${r}`;
1258
+ }
1259
+ async function Zr(e, t, r, a) {
1260
+ const { graphQuery: o, explanation: i } = await U(e, t, r, a);
1261
+ return { graphQuery: o, explanation: i };
1262
+ }
1263
+ async function U(e, t, r, a, o) {
1264
+ const i = {
1265
+ message: await Yr(e, o),
1266
+ context: new Wr(t)
1267
+ }, s = F(a);
1268
+ await T({ text: "Attempting to generate a cypher query from your prompt..." }, a);
1269
+ const n = await J(`${r}/chat`, {
2235
1270
  method: "post",
2236
- body: JSON.stringify(n),
1271
+ body: JSON.stringify(i),
2237
1272
  headers: {
2238
1273
  "Content-Type": "application/json",
2239
- token: ce.findCredential(k.getDefault().url)?.token ?? ""
2240
- }
1274
+ "X-Esri-Authorization": `Bearer ${H.findCredential(P.getDefault().url)?.token ?? ""}`
1275
+ },
1276
+ signal: s
2241
1277
  });
2242
- if (s.httpStatus !== 200)
2243
- throw new Error(`Graph query service returned an error: ${s.httpStatus}`, {
2244
- cause: s.data
1278
+ if (n.httpStatus !== 200)
1279
+ throw new Error(`Graph query service returned an error: ${n.httpStatus}`, {
1280
+ cause: n.data
2245
1281
  });
2246
- Q.conversationId || (Q.conversationId = s.data.conversationId);
2247
- let c = !1;
2248
- const u = Date.now();
2249
- let l = s.data.sequenceNumber, d = "", p = "", h = 1;
2250
- for (; !c; ) {
2251
- await new Promise((w) => setTimeout(w, 1e3)), await S(
2252
- { text: `Periodically requesting status of job from ArcGIS AI Services${"...".substring(0, h)}` },
2253
- o
2254
- ), h = h % 3 + 1;
2255
- const m = await le(`${r}/chat`, {
1282
+ let l = !1;
1283
+ const p = Date.now();
1284
+ let d = n.data.sequenceNumber, u = "", h = "", f = 1;
1285
+ for (; !l; ) {
1286
+ await new Promise((w) => setTimeout(w, 1e3)), await T(
1287
+ { text: `Periodically requesting status of job from ArcGIS AI Services${"...".substring(0, f)}` },
1288
+ a
1289
+ ), f = f % 3 + 1;
1290
+ const y = await J(`${r}/chat`, {
2256
1291
  method: "post",
2257
1292
  body: JSON.stringify({
2258
- conversationId: s.data.conversationId,
2259
- inquiryId: s.data.inquiryId,
2260
- ackSequenceNumber: l
1293
+ conversationId: n.data.conversationId,
1294
+ inquiryId: n.data.inquiryId,
1295
+ ackSequenceNumber: d
2261
1296
  }),
2262
1297
  headers: {
2263
1298
  "Content-Type": "application/json",
2264
- token: ce.findCredential(k.getDefault().url)?.token ?? ""
2265
- }
1299
+ "X-Esri-Authorization": `Bearer ${H.findCredential(P.getDefault().url)?.token ?? ""}`
1300
+ },
1301
+ signal: s
2266
1302
  });
2267
- if (m.httpStatus !== 200)
2268
- throw new Error(`Graph query service polling returned an error: ${m.httpStatus}`, {
2269
- cause: m.data
1303
+ if (y.httpStatus !== 200)
1304
+ throw new Error(`Graph query service polling returned an error: ${y.httpStatus}`, {
1305
+ cause: y.data
2270
1306
  });
2271
- if (m.data.context)
2272
- d = m.data.context.graphQuery, p = m.data.message || "";
2273
- else if (!m.data.hasMore)
2274
- c = !0;
2275
- else if (Date.now() - u > 6e4)
1307
+ if (y.data.context?.kind) {
1308
+ if (y.data.context.kind !== "GraphQueryGenerationResponse")
1309
+ throw new Error(`Unexpected response from graph query service polling. Message: ${y.data.message}`, {
1310
+ cause: y.data
1311
+ });
1312
+ u = y.data.context.graphQuery, h = y.data.message || "", l = !0;
1313
+ } else if (!y.data.hasMore)
1314
+ l = !0;
1315
+ else if (Date.now() - p > 6e4)
2276
1316
  throw new Error("Graph query service polling timed out after 1 minute.");
2277
- l = m.data.sequenceNumber;
1317
+ d = y.data.sequenceNumber;
2278
1318
  }
2279
- return { graphQuery: d, explanation: p };
1319
+ return { graphQuery: u, explanation: h };
2280
1320
  }
2281
- const I = 3;
2282
- function $e(e, t = 100) {
1321
+ function et(e, t) {
1322
+ C(e, (r) => {
1323
+ t.set(`${r.typeName}__${r.id}`, {
1324
+ id: r.id,
1325
+ typeName: r.typeName
1326
+ });
1327
+ });
1328
+ }
1329
+ function C(e, t) {
1330
+ if (!(!e || typeof e != "object")) {
1331
+ if (tt(e))
1332
+ for (const r of e.path)
1333
+ C(r, t);
1334
+ else if (rt(e))
1335
+ t(e);
1336
+ else if (Array.isArray(e))
1337
+ for (const r of e)
1338
+ C(r, t);
1339
+ else if (at(e))
1340
+ for (const r of Object.values(e.properties ?? {}))
1341
+ C(r, t);
1342
+ }
1343
+ }
1344
+ function rt(e) {
1345
+ return !e || typeof e != "object" || Array.isArray(e) ? !1 : "id" in e && "typeName" in e;
1346
+ }
1347
+ function tt(e) {
1348
+ return !e || typeof e != "object" || Array.isArray(e) ? !1 : e && "path" in e && Array.isArray(e.path);
1349
+ }
1350
+ function at(e) {
1351
+ return !e || typeof e != "object" || Array.isArray(e) || "id" in e ? !1 : "properties" in e && typeof e.properties == "object";
1352
+ }
1353
+ function ot(e, t) {
1354
+ const r = [], a = [], o = [
1355
+ [t.dataModel.entityTypes, r],
1356
+ [t.dataModel.relationshipTypes, a]
1357
+ ];
1358
+ for (const [i, s] of o)
1359
+ for (const n of i) {
1360
+ const l = e.getMemberIdsByType(n.name);
1361
+ s.push(...l);
1362
+ }
1363
+ return { entityIds: r, relationshipIds: a };
1364
+ }
1365
+ function nt(e, t) {
1366
+ const r = { entityIds: new Array(), relationshipIds: new Array() }, a = [], i = e?.allLayers.find((l) => l.type === "knowledge-graph")?.inclusionModeDefinition;
1367
+ if (!i)
1368
+ return { allNamedTypesFullyDynamic: !0, bindParameters: r, nonDynamicTypes: a };
1369
+ const s = [
1370
+ [t.dataModel.entityTypes, r.entityIds],
1371
+ [t.dataModel.relationshipTypes, r.relationshipIds]
1372
+ ];
1373
+ let n = !0;
1374
+ for (const [l, p] of s)
1375
+ for (const d of l) {
1376
+ const u = i.namedTypeDefinitions.get(d.name);
1377
+ if (!u) {
1378
+ n = !1, a.push(d.name);
1379
+ continue;
1380
+ }
1381
+ if (!u.useAllData) {
1382
+ n = !1, a.push(d.name);
1383
+ for (const [h] of u.members || [])
1384
+ p.push(h);
1385
+ }
1386
+ }
1387
+ return { allNamedTypesFullyDynamic: n, bindParameters: r, nonDynamicTypes: a };
1388
+ }
1389
+ const $ = 3;
1390
+ function ae(e, t = 100) {
2283
1391
  const r = {};
2284
- for (const o of Object.entries(e.properties ?? {})) {
2285
- const [a, n] = o;
2286
- typeof n == "string" && n.length > t ? r[a] = `${n.slice(0, t)}... (truncated, original length: ${n.length})` : r[a] = n;
1392
+ for (const a of Object.entries(e.properties ?? {})) {
1393
+ const [o, i] = a;
1394
+ typeof i == "string" && i.length > t ? r[o] = `${i.slice(0, t)}... (truncated, original length: ${i.length})` : r[o] = i;
2287
1395
  }
2288
1396
  return e.properties = r, e;
2289
1397
  }
2290
- function se(e) {
1398
+ function E(e) {
2291
1399
  return typeof e != "object" || e === null ? String(e) : "details" in e && typeof e.details == "object" && e.details !== null && "errorMessage" in e.details && typeof e.details.errorMessage == "string" ? e.details.errorMessage : "message" in e && typeof e.message == "string" ? e.message : String(e);
2292
1400
  }
2293
- const Yo = async ({
1401
+ const it = async ({
2294
1402
  kg: e,
2295
1403
  queryParams: t,
2296
1404
  targetStructure: r,
2297
- targetStructureReducer: o,
2298
- requestOptions: a,
2299
- queryRowLimit: n,
1405
+ targetStructureReducer: a,
1406
+ requestOptions: o,
1407
+ queryRowLimit: i,
2300
1408
  queryTimeoutMs: s
2301
1409
  }) => {
2302
- let c = null, u = r;
2303
- const l = new AbortController(), d = a?.signal, p = () => {
2304
- l.abort(d?.reason);
1410
+ let n = null, l = r;
1411
+ const p = new AbortController(), d = o?.signal, u = () => {
1412
+ p.abort(d?.reason);
2305
1413
  };
2306
- d && (d.aborted ? l.abort(d.reason) : d.addEventListener("abort", p, { once: !0 }));
1414
+ d && (d.aborted ? p.abort(d.reason) : d.addEventListener("abort", u, { once: !0 }));
2307
1415
  try {
2308
- const h = await ht(e, t, a);
2309
- c = h.resultHeader;
2310
- const m = h.resultRowsStream.getReader();
2311
- let w = 0;
2312
- const y = Date.now(), g = !1;
1416
+ const h = await je(e, t, o);
1417
+ n = h.resultHeader;
1418
+ const f = h.resultRowsStream.getReader();
1419
+ let y = 0;
1420
+ const w = Date.now(), b = !1;
2313
1421
  for (; ; ) {
2314
- const { done: T, value: E } = await m.read();
2315
- if (T)
1422
+ const { done: R, value: z } = await f.read();
1423
+ if (R)
2316
1424
  break;
2317
- if (!g && s && Date.now() - y > s)
2318
- return l.abort(), { type: "timeout" };
2319
- for (const v of E) {
2320
- if (w++, n && w > n)
2321
- return l.abort(), { type: "success", rowLimitReached: !0, resultHeader: c, processedResult: u };
2322
- u = o(u, v);
1425
+ if (!b && s && Date.now() - w > s)
1426
+ return p.abort(), { type: "timeout" };
1427
+ for (const se of z) {
1428
+ if (y++, i && y > i)
1429
+ return p.abort(), { type: "success", rowLimitReached: !0, resultHeader: n, processedResult: l };
1430
+ l = a(l, se);
2323
1431
  }
2324
1432
  }
2325
1433
  } catch (h) {
2326
- return l.signal.aborted ? { type: "aborted" } : { type: "error", errorMessage: se(h), error: h };
1434
+ return p.signal.aborted ? { type: "aborted" } : { type: "error", errorMessage: E(h), error: h };
2327
1435
  } finally {
2328
- d?.removeEventListener("abort", p);
1436
+ d?.removeEventListener("abort", u);
2329
1437
  }
2330
- return { type: "success", rowLimitReached: !1, resultHeader: c, processedResult: u };
1438
+ return { type: "success", rowLimitReached: !1, resultHeader: n, processedResult: l };
2331
1439
  };
2332
- async function Ee({
1440
+ async function oe({
2333
1441
  prompt: e,
2334
- kg: t,
2335
- graphQueryServiceUrl: r,
1442
+ bindParameters: t,
1443
+ kg: r,
1444
+ graphQueryServiceUrl: a,
2336
1445
  targetStructure: o,
2337
- targetStructureReducer: a,
2338
- requestOptions: n,
2339
- queryRowLimit: s,
2340
- queryTimeoutMs: c,
2341
- config: u
1446
+ targetStructureReducer: i,
1447
+ requestOptions: s,
1448
+ queryRowLimit: n,
1449
+ queryTimeoutMs: l,
1450
+ config: p
2342
1451
  }) {
2343
- let l;
2344
- for (let d = 1; d <= I; d++) {
2345
- let p;
1452
+ let d;
1453
+ for (let u = 1; u <= $; u++) {
1454
+ let h;
2346
1455
  try {
2347
- p = await ie(e, t.dataModel, r, u, l);
2348
- } catch (w) {
1456
+ h = await U(e, r.dataModel, a, p, d);
1457
+ } catch (b) {
2349
1458
  return {
2350
1459
  type: "generation-error",
2351
- errorMessage: se(w),
2352
- error: w
1460
+ errorMessage: E(b),
1461
+ error: b
2353
1462
  };
2354
1463
  }
2355
- await S(
1464
+ await T(
2356
1465
  {
2357
- text: `Attempting to execute query: ${p.graphQuery.substring(0, 500)}${p.graphQuery.length > 500 ? "..." : ""}`
1466
+ text: `Attempting to execute query: ${h.graphQuery.substring(0, 500)}${h.graphQuery.length > 500 ? "..." : ""}`
2358
1467
  },
2359
- u
1468
+ p
2360
1469
  );
2361
- const h = await Yo({
2362
- kg: t,
2363
- queryParams: new we({
2364
- openCypherQuery: p.graphQuery
1470
+ const f = await st(h.graphQuery, t), y = await it({
1471
+ kg: r,
1472
+ queryParams: new re({
1473
+ openCypherQuery: h.graphQuery,
1474
+ bindParameters: f
2365
1475
  }),
2366
1476
  targetStructure: o,
2367
- targetStructureReducer: a,
2368
- requestOptions: n,
2369
- queryRowLimit: s,
2370
- queryTimeoutMs: c
2371
- }), m = h.type === "aborted" ? "Query execution was aborted." : h.type === "timeout" ? "Query execution timed out." : h.type === "error" ? `Query failed with error: ${h.errorMessage}` : "";
2372
- if (h.type === "success")
1477
+ targetStructureReducer: i,
1478
+ requestOptions: s,
1479
+ queryRowLimit: n,
1480
+ queryTimeoutMs: l
1481
+ }), w = y.type === "aborted" ? "Query execution was aborted." : y.type === "timeout" ? "Query execution timed out." : y.type === "error" ? `Query failed with error: ${y.errorMessage}` : "";
1482
+ if (y.type === "success")
2373
1483
  return {
2374
1484
  type: "success",
2375
- graphQuery: p.graphQuery,
2376
- explanation: p.explanation,
2377
- rowLimitReached: h.rowLimitReached,
2378
- resultHeader: h.resultHeader,
2379
- processedResult: h.processedResult
1485
+ graphQuery: h.graphQuery,
1486
+ explanation: h.explanation,
1487
+ rowLimitReached: y.rowLimitReached,
1488
+ resultHeader: y.resultHeader,
1489
+ processedResult: y.processedResult
2380
1490
  };
2381
- if (h.type === "aborted")
1491
+ if (y.type === "aborted")
2382
1492
  return {
2383
1493
  type: "aborted",
2384
- errorMessage: m,
2385
- graphQuery: p.graphQuery,
2386
- explanation: p.explanation
1494
+ errorMessage: w,
1495
+ graphQuery: h.graphQuery,
1496
+ explanation: h.explanation
2387
1497
  };
2388
- if (d >= I)
2389
- return h.type === "timeout" ? {
1498
+ if (u >= $)
1499
+ return y.type === "timeout" ? {
2390
1500
  type: "timeout",
2391
- errorMessage: m,
2392
- graphQuery: p.graphQuery,
2393
- explanation: p.explanation
1501
+ errorMessage: w,
1502
+ graphQuery: h.graphQuery,
1503
+ explanation: h.explanation
2394
1504
  } : {
2395
1505
  type: "execution-error",
2396
- errorMessage: m,
2397
- error: h.error,
2398
- graphQuery: p.graphQuery,
2399
- explanation: p.explanation
1506
+ errorMessage: w,
1507
+ error: y.error,
1508
+ graphQuery: h.graphQuery,
1509
+ explanation: h.explanation
2400
1510
  };
2401
- l = {
2402
- failedGraphQuery: p.graphQuery,
2403
- executionError: m,
2404
- attemptCount: d
2405
- }, await S(
2406
- { text: `Attempt ${d} failed with error: ${m}. Retrying...` },
2407
- u
1511
+ d = {
1512
+ failedGraphQuery: h.graphQuery,
1513
+ executionError: w,
1514
+ attemptCount: u
1515
+ }, await T(
1516
+ { text: `Attempt ${u} failed with error: ${w}. Retrying...` },
1517
+ p
2408
1518
  );
2409
1519
  }
2410
1520
  throw new Error(
2411
- `Failed to execute generated cypher due to an unexpected error after ${I} attempts.`
1521
+ `Failed to execute generated cypher due to an unexpected error after ${$} attempts.`
2412
1522
  );
2413
1523
  }
2414
- const Xo = async ({
1524
+ const st = async (e, t) => {
1525
+ if (!t)
1526
+ return {};
1527
+ const { bindParameters: r, parseErrors: a } = await Qe(e);
1528
+ if (a)
1529
+ return t;
1530
+ const o = {};
1531
+ for (const i of r)
1532
+ i in t && (o[i] = t[i]);
1533
+ return o;
1534
+ }, lt = async ({
2415
1535
  kg: e,
2416
1536
  searchQuery: t,
2417
1537
  typeCategoryFilter: r,
2418
- namedTypesFilter: o,
2419
- searchResultLimit: a,
2420
- requestOptions: n
1538
+ namedTypesFilter: a,
1539
+ searchResultLimit: o,
1540
+ requestOptions: i
2421
1541
  }) => {
2422
1542
  const s = [];
2423
- let c = [r];
2424
- r === "both" && !e.serviceDefinition.serviceCapabilities.searchCapabilities.searchTypeFilterCapabilities.includes("esriTypeBoth") && (c = ["entity", "relationship"]);
2425
- const u = a ?? 1 / 0;
1543
+ let n = [r];
1544
+ r === "both" && !e.serviceDefinition.serviceCapabilities.searchCapabilities.searchTypeFilterCapabilities.includes("esriTypeBoth") && (n = ["entity", "relationship"]);
1545
+ const l = o ?? 1 / 0;
2426
1546
  try {
2427
- for (const l of c) {
2428
- const d = u - s.length;
1547
+ for (const p of n) {
1548
+ const d = l - s.length;
2429
1549
  if (d <= 0)
2430
1550
  break;
2431
- const m = (await mt(
1551
+ const f = (await Fe(
2432
1552
  e,
2433
- new yt({
1553
+ new _e({
2434
1554
  searchQuery: t,
2435
- typeCategoryFilter: l,
2436
- namedTypesFilter: o ?? void 0,
1555
+ typeCategoryFilter: p,
1556
+ namedTypesFilter: a ?? void 0,
2437
1557
  num: d
2438
1558
  }),
2439
- n
1559
+ i
2440
1560
  )).resultRowsStream.getReader();
2441
- let w = !1;
2442
- for (; !w; ) {
2443
- const { done: y, value: g } = await m.read();
2444
- if (y) {
2445
- w = !0;
1561
+ let y = !1;
1562
+ for (; !y; ) {
1563
+ const { done: w, value: b } = await f.read();
1564
+ if (w) {
1565
+ y = !0;
2446
1566
  break;
2447
1567
  }
2448
- for (const T of g)
2449
- for (const E of T)
2450
- s.push(E);
1568
+ for (const R of b)
1569
+ for (const z of R)
1570
+ s.push(z);
2451
1571
  }
2452
1572
  }
2453
- } catch (l) {
2454
- return console.log('Error when running graph search with query: "', t, '" - error: ', l), n?.signal?.aborted ? {
2455
- type: "aborted"
2456
- } : { type: "error", errorMessage: se(l), error: l };
1573
+ } catch (p) {
1574
+ const d = E(p);
1575
+ return i?.signal?.aborted ? {
1576
+ type: "aborted",
1577
+ errorMessage: d,
1578
+ error: p
1579
+ } : { type: "error", errorMessage: d, error: p };
2457
1580
  }
2458
1581
  return {
2459
1582
  type: "success",
2460
1583
  results: s
2461
1584
  };
2462
- };
2463
- function ea(e, t) {
2464
- D(e, (r) => {
2465
- t.set(`${r.typeName}__${r.id}`, {
2466
- id: r.id,
2467
- typeName: r.typeName
2468
- });
2469
- });
2470
- }
2471
- function D(e, t) {
2472
- if (!(!e || typeof e != "object")) {
2473
- if (ra(e))
2474
- for (const r of e.path)
2475
- D(r, t);
2476
- else if (ta(e))
2477
- t(e);
2478
- else if (Array.isArray(e))
2479
- for (const r of e)
2480
- D(r, t);
2481
- else if (oa(e))
2482
- for (const r of Object.values(e.properties ?? {}))
2483
- D(r, t);
2484
- }
2485
- }
2486
- function ta(e) {
2487
- return !e || typeof e != "object" || Array.isArray(e) ? !1 : "id" in e && "typeName" in e;
2488
- }
2489
- function ra(e) {
2490
- return !e || typeof e != "object" || Array.isArray(e) ? !1 : e && "path" in e && Array.isArray(e.path);
2491
- }
2492
- function oa(e) {
2493
- return !e || typeof e != "object" || Array.isArray(e) || "id" in e ? !1 : "properties" in e && typeof e.properties == "object";
2494
- }
2495
- function aa(e, t) {
2496
- const r = [];
2497
- for (const o of [...t.dataModel.entityTypes, ...t.dataModel.relationshipTypes]) {
2498
- const a = e.getMemberIdsByType(o.name);
2499
- for (const n of a)
2500
- r.push({ id: n, typeName: o.name });
1585
+ }, ne = "IMPORTANT: The generated cypher query must return entire entities and relationships ONLY.";
1586
+ async function ie({
1587
+ prompt: e,
1588
+ view: t,
1589
+ knowledgeGraph: r,
1590
+ includeReturnEntityAndRelationshipContext: a = !1
1591
+ }) {
1592
+ const o = [e];
1593
+ if (a && o.push(ne), x(t)) {
1594
+ const d = await L("arcgis_knowledge_current_lc_context"), u = ot(t.map, r);
1595
+ return o.push(d), {
1596
+ enhancedPrompt: o.join(`
1597
+
1598
+ `),
1599
+ bindParameters: u,
1600
+ allNamedTypesFullyDynamic: !1
1601
+ };
2501
1602
  }
2502
- return r;
1603
+ const i = t.map, { allNamedTypesFullyDynamic: s, bindParameters: n, nonDynamicTypes: l } = nt(
1604
+ i,
1605
+ r
1606
+ );
1607
+ if (s)
1608
+ return {
1609
+ enhancedPrompt: o.join(`
1610
+
1611
+ `),
1612
+ bindParameters: n,
1613
+ allNamedTypesFullyDynamic: !0
1614
+ };
1615
+ const p = (await L("arcgis_knowledge_current_map_context")).replaceAll(
1616
+ "{nonDynamicTypes}",
1617
+ JSON.stringify(l)
1618
+ );
1619
+ return o.push(p), {
1620
+ enhancedPrompt: o.join(`
1621
+
1622
+ `),
1623
+ bindParameters: n,
1624
+ allNamedTypesFullyDynamic: s
1625
+ };
2503
1626
  }
2504
- function na(e) {
2505
- const t = [], r = [], a = e?.allLayers.find((n) => n.type === "knowledge-graph")?.inclusionModeDefinition;
2506
- if (a?.generateAllSublayers)
2507
- return { allNamedTypesFullyDynamic: !0, idTypePairs: t, dynamicTypes: r };
2508
- for (const [n, s] of a?.namedTypeDefinitions ?? [])
2509
- if (s.useAllData)
2510
- r.push(n);
2511
- else
2512
- for (const [c] of s.members)
2513
- t.push({ id: c, typeName: n });
2514
- return { allNamedTypesFullyDynamic: !1, idTypePairs: t, dynamicTypes: r };
2515
- }
2516
- async function ia(e, t, r, o, a) {
2517
- const { view: n } = o, s = await Ee({
1627
+ async function ct(e, t, r, a, o, i) {
1628
+ const { view: s } = o, n = await oe({
2518
1629
  prompt: e,
2519
- kg: t,
2520
- graphQueryServiceUrl: r,
1630
+ bindParameters: t,
1631
+ kg: r,
1632
+ graphQueryServiceUrl: a,
2521
1633
  targetStructure: /* @__PURE__ */ new Map(),
2522
- targetStructureReducer: (p, h) => {
2523
- for (const m of h)
2524
- ea(m, p);
2525
- return p;
1634
+ targetStructureReducer: (h, f) => {
1635
+ for (const y of f)
1636
+ et(y, h);
1637
+ return h;
2526
1638
  },
2527
1639
  requestOptions: {
2528
- signal: a?.signal,
2529
- timeout: a?.timeout
1640
+ signal: F(i),
1641
+ timeout: i?.timeout
2530
1642
  },
2531
- config: a
1643
+ config: i
2532
1644
  });
2533
- if (s.type !== "success") {
2534
- const p = s.type === "generation-error" ? s.errorMessage : `${s.errorMessage} Cypher query: ${s.graphQuery}`;
2535
- throw new Error(`Failed to add records to the link chart. ${p}`);
1645
+ if (n.type !== "success") {
1646
+ const h = n.type === "generation-error" ? n.errorMessage : `${n.errorMessage} Cypher query: ${n.graphQuery}`;
1647
+ throw new Error(`Failed to add records to the link chart. ${h}`);
2536
1648
  }
2537
- const { graphQuery: c, explanation: u, processedResult: l } = s, d = Array.from(l.values());
2538
- return await S(
1649
+ const { graphQuery: l, explanation: p, processedResult: d } = n, u = Array.from(d.values());
1650
+ return await T(
2539
1651
  {
2540
- text: `Query Results parsed into ${d.length} unique relationships and entities. Atempting to add to link chart...`
1652
+ text: `Query Results parsed into ${u.length} unique relationships and entities. Atempting to add to link chart...`
2541
1653
  },
2542
- a
2543
- ), !z(n) && n?.map ? (await n.map.addRecords(d), await B(n), `Link Chart updated successfully. Cypher Query used:
2544
- ${c}
2545
-
2546
- Explanation: ${u}`) : (await n?.map?.allLayers.find(
2547
- (h) => h.type === "knowledge-graph"
2548
- )?.addRecords(d), `Map updated successfully. Cypher Query used:
2549
- ${c}
2550
-
2551
- Explanation: ${u}`);
2552
- }
2553
- const Ce = "addRecords", sa = i.object({
2554
- prompt: i.string().describe("The user's inquiry into the knowledge graph that needs to be run.")
2555
- }), ca = async ({ prompt: e }, t) => {
2556
- const { knowledgeGraph: r } = await G(t), o = H(t), { view: a } = o, s = k.getDefault().helperServices;
2557
- let c = e;
2558
- if (!z(a) && a.map) {
2559
- const l = a.map, d = await Y("arcgis_knowledge_current_lc_context"), p = aa(l, r);
2560
- c = `${e}
2561
-
2562
- ${d}${JSON.stringify(p)}`;
2563
- } else {
2564
- const l = a.map, { allNamedTypesFullyDynamic: d, idTypePairs: p, dynamicTypes: h } = na(l), m = await Y("arcgis_knowledge_current_map_context");
2565
- if (c = `${e}
1654
+ i
1655
+ ), x(s) ? (await s.map.addRecords(u), await j(s), { generatedQuery: l, explanation: p, addedIdTypePairs: u }) : (await s?.map?.allLayers.find(
1656
+ (f) => f.type === "knowledge-graph"
1657
+ )?.addRecords(u), { generatedQuery: l, explanation: p, addedIdTypePairs: u });
1658
+ }
1659
+ const M = "addRecords", pt = c.object({
1660
+ prompt: c.string().describe(
1661
+ "The user's inquiry and context required in order to generate a cypher query that will be used to add records to the link chart."
1662
+ )
1663
+ }), dt = async ({ prompt: e }, t) => {
1664
+ const { knowledgeGraph: r } = await N(t), a = q(t), { view: o } = a, s = P.getDefault().helperServices, {
1665
+ enhancedPrompt: n,
1666
+ bindParameters: l,
1667
+ allNamedTypesFullyDynamic: p
1668
+ } = await ie({
1669
+ prompt: e,
1670
+ view: o,
1671
+ knowledgeGraph: r,
1672
+ includeReturnEntityAndRelationshipContext: !0
1673
+ });
1674
+ if (p)
1675
+ return {
1676
+ toolName: M,
1677
+ status: "success",
1678
+ summary: "No records have been added to the map because all data in the knowledge graph is contained in the map.",
1679
+ details: {
1680
+ generatedQuery: "N/A",
1681
+ explanation: "All named types in the knowledge graph are fully dynamic and therefore all data is already contained in the map. No records have been added.",
1682
+ addedIdTypePairs: []
1683
+ }
1684
+ };
1685
+ try {
1686
+ const { generatedQuery: d, explanation: u, addedIdTypePairs: h } = await ct(
1687
+ n,
1688
+ l,
1689
+ r,
1690
+ `${s.aiAssistantServices.url}${s.aiAssistantServices.graphQueryAssistant}`,
1691
+ a,
1692
+ t
1693
+ );
1694
+ return {
1695
+ toolName: M,
1696
+ status: "success",
1697
+ summary: `Records added successfully. Cypher Query used: ${d}
2566
1698
 
2567
- ${m}${JSON.stringify(p)} and all entities or relationships with the the following typeNames in the array: ${JSON.stringify(h)}`, d)
2568
- throw new Error(
2569
- "No records have been added to the map because all data in the knowledge graph is contained in the map."
2570
- );
1699
+ Number of records added: ${h.length}`,
1700
+ details: {
1701
+ generatedQuery: d,
1702
+ explanation: u,
1703
+ addedIdTypePairs: h
1704
+ }
1705
+ };
1706
+ } catch (d) {
1707
+ const u = E(d);
1708
+ return {
1709
+ toolName: M,
1710
+ status: "error",
1711
+ errorMessage: `Failed to add records to the link chart. ${u}`,
1712
+ error: d
1713
+ };
2571
1714
  }
2572
- const u = await ia(
2573
- c,
2574
- r,
2575
- `${s.aiAssistantServices.url}${s.aiAssistantServices.graphQueryAssistant}`,
2576
- o,
2577
- t
2578
- );
2579
- return {
2580
- toolName: Ce,
2581
- status: "success",
2582
- summary: u
2583
- };
2584
- }, Yn = f(ca, {
2585
- name: Ce,
2586
- description: "Adds records (entities or relationships) to the current link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the records to be added to the link chart. The user should have explicitly requested to add records to the current link chart from their prompt.",
2587
- schema: sa
1715
+ }, Ia = g(dt, {
1716
+ name: M,
1717
+ description: `Adds records (entities or relationships) to the current link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the records to be added to the link chart. The user should have explicitly requested to add records to the current link chart from their prompt. "add to new link chart" is not a valid prompt for this tool.
1718
+
1719
+ example prompts:
1720
+ - "add all suppliers and the parts they produce to the link chart"
1721
+ - "show me the competitors of company x and add them to the link chart"
1722
+ - "add the relationships between company x and company y to the link chart"
1723
+ - "expand all the companies"
1724
+ - "expand company x through all the buildings it owns"
1725
+ - "connect company x and company y"
1726
+ - "connect all buildings on the link chart"
1727
+ `,
1728
+ schema: pt
2588
1729
  });
2589
- async function la(e, t) {
2590
- return await t.map?.applyLayout(e), await B(t), `Successfully applied layout: ${e}.`;
1730
+ async function ut(e, t) {
1731
+ return await t.map?.applyLayout(e), await j(t), { appliedLayout: e };
2591
1732
  }
2592
- const ee = "applyLayout", ua = i.object({
2593
- layout: i.enum([
1733
+ const _ = "applyLayout", ht = c.object({
1734
+ layout: c.enum([
2594
1735
  "organic-standard",
2595
1736
  "organic-community",
2596
1737
  "basic-grid",
@@ -2603,367 +1744,417 @@ const ee = "applyLayout", ua = i.object({
2603
1744
  ]).describe(
2604
1745
  "The layout mode to apply to the link chart. The value must be one of the following: organic-standard, organic-community, basic-grid, hierarchical-bottom-to-top, radial-root-centric, tree-left-to-right, geographic-organic-standard, chronological-mono-timeline, chronological-multi-timeline"
2605
1746
  )
2606
- }), da = async ({ layout: e }, t) => {
2607
- const { view: r } = H(t);
2608
- if (z(r))
1747
+ }), yt = async ({ layout: e }, t) => {
1748
+ const { view: r } = q(t);
1749
+ if (x(r)) {
1750
+ const { appliedLayout: a } = await ut(e, r);
1751
+ return {
1752
+ toolName: _,
1753
+ status: "success",
1754
+ summary: `Successfully applied layout: ${a}.`,
1755
+ details: {
1756
+ appliedLayout: a
1757
+ }
1758
+ };
1759
+ } else
2609
1760
  return {
2610
- toolName: ee,
1761
+ toolName: _,
2611
1762
  status: "error",
2612
1763
  errorMessage: "The applyLayout tool can only be used with a LinkChartView.",
2613
1764
  error: new Error()
2614
1765
  };
2615
- {
2616
- const o = await la(e, r);
1766
+ }, Oa = g(yt, {
1767
+ name: _,
1768
+ description: "Apply a diagram layout to the link chart",
1769
+ schema: ht
1770
+ });
1771
+ async function mt(e, t) {
1772
+ return t.map?.changeNonspatialDataDisplay(e), await j(t), { appliedNonspatialDataDisplayMode: e };
1773
+ }
1774
+ const Q = "changeNonspatialVisibility", gt = c.object({
1775
+ setting: c.enum(["hidden", "visible"]).describe("The setting of nonspatial visibility")
1776
+ }), ft = async ({ setting: e }, t) => {
1777
+ const { view: r } = q(t);
1778
+ if (x(r)) {
1779
+ const { appliedNonspatialDataDisplayMode: a } = await mt(e, r);
2617
1780
  return {
2618
- toolName: ee,
1781
+ toolName: Q,
2619
1782
  status: "success",
2620
- summary: o
1783
+ summary: `Successfully applied nonspatial visibility setting: ${a}.`,
1784
+ details: {
1785
+ appliedNonspatialDataDisplayMode: a
1786
+ }
2621
1787
  };
2622
- }
2623
- }, Xn = f(da, {
2624
- name: ee,
2625
- description: "Apply a diagram layout to the link chart",
2626
- schema: ua
2627
- });
2628
- async function pa(e, t) {
2629
- return t.map?.changeNonspatialDataDisplay(e), await B(t), `Successfully applied nonspatial visibility setting: ${e}.`;
2630
- }
2631
- const te = "changeNonspatialVisibility", ha = i.object({
2632
- setting: i.enum(["hidden", "visible"]).describe("The setting of nonspatial visibility")
2633
- }), ma = async ({ setting: e }, t) => {
2634
- const { view: r } = H(t);
2635
- if (z(r))
1788
+ } else
2636
1789
  return {
2637
- toolName: te,
1790
+ toolName: Q,
2638
1791
  status: "error",
2639
1792
  errorMessage: "The changeNonspatialVisibility tool can only be used with a LinkChartView.",
2640
1793
  error: new Error()
2641
1794
  };
2642
- {
2643
- const o = await pa(e, r);
2644
- return {
2645
- toolName: te,
2646
- status: "success",
2647
- summary: o
2648
- };
2649
- }
2650
- }, ei = f(ma, {
2651
- name: te,
1795
+ }, Ka = g(ft, {
1796
+ name: Q,
2652
1797
  description: "Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",
2653
- schema: ha
1798
+ schema: gt
2654
1799
  });
2655
- async function ya(e, t, r, o, a) {
2656
- let n;
2657
- for (let s = 1; s <= I; s++) {
2658
- const { graphQuery: c, explanation: u } = await ie(
1800
+ async function wt(e, t, r, a, o) {
1801
+ let i, s = "";
1802
+ for (let n = 1; n <= $; n++) {
1803
+ const { graphQuery: l, explanation: p } = await U(
2659
1804
  e,
2660
1805
  t.dataModel,
2661
1806
  r,
2662
- a,
2663
- n
1807
+ o,
1808
+ i
2664
1809
  );
2665
1810
  try {
2666
- await S({ text: `Attempting to create link chart from derived query: ${c}` }, a);
2667
- const l = await pt.fromCypherQuery(
1811
+ await T({ text: `Attempting to create link chart from derived query: ${l}` }, o);
1812
+ const d = await Ge.fromCypherQuery(
2668
1813
  t,
2669
- new we({
2670
- openCypherQuery: c
1814
+ new re({
1815
+ openCypherQuery: l
2671
1816
  })
2672
1817
  );
2673
- await S({ text: "Link chart created successfully, loading..." }, a), await l.load();
2674
- const d = o.map;
2675
- return o.map = l, await o.when(), await De.whenOnce(() => !o.updating), l.entityCount === 0 && l.relationshipCount === 0 ? (o.map === l && (o.map = d), l.destroy(), {
1818
+ await T({ text: "Link chart created successfully, loading..." }, o), await d.load();
1819
+ const u = a.map;
1820
+ return a.map = d, await a.when(), await ce.whenOnce(() => !a.updating), d.entityCount === 0 && d.relationshipCount === 0 ? (a.map === d && (a.map = u), d.destroy(), {
2676
1821
  type: "error",
2677
- message: `Query returned no results. Cypher Query used to create the link chart:
2678
- ${c}
1822
+ errorMessage: `Query returned no results. Cypher Query used to create the link chart:
1823
+ ${l}
2679
1824
 
2680
- Explanation: ${u}`
2681
- }) : (await B(o), {
1825
+ Explanation: ${p}`
1826
+ }) : (await j(a), {
2682
1827
  type: "success",
2683
- message: `Link chart created successfully. Cypher Query used to create the link chart:
2684
- ${c}
2685
-
2686
- Explanation: ${u}`
1828
+ graphQuery: l,
1829
+ explanation: p
2687
1830
  });
2688
- } catch (l) {
2689
- const d = l instanceof Error ? l.message : String(l);
2690
- if (s >= I)
2691
- throw new Error(
2692
- `Failed to create link chart after ${I} attempts. Last error: ${d}`
2693
- );
2694
- n = {
2695
- failedGraphQuery: c,
2696
- executionError: d,
2697
- attemptCount: s
2698
- }, await S(
2699
- { text: `Attempt ${s} to create link chart failed with error: ${d}. Retrying ...` },
2700
- a
1831
+ } catch (d) {
1832
+ const u = E(d);
1833
+ if (n >= $) {
1834
+ s = u;
1835
+ break;
1836
+ }
1837
+ i = {
1838
+ failedGraphQuery: l,
1839
+ executionError: u,
1840
+ attemptCount: n
1841
+ }, await T(
1842
+ { text: `Attempt ${n} to create link chart failed with error: ${u}. Retrying ...` },
1843
+ o
2701
1844
  );
2702
1845
  }
2703
1846
  }
2704
- throw new Error(`Failed to create link chart after ${I} attempts.`);
1847
+ return {
1848
+ type: "error",
1849
+ errorMessage: `Failed to create link chart after ${$} attempts. Last error: ${s}`
1850
+ };
2705
1851
  }
2706
- const _ = "createLinkChart", fa = i.object({
2707
- prompt: i.string().describe(
2708
- "The user's inquiry into the knowledge graph that needs to be transformed into a link chart visualization."
1852
+ const D = "createLinkChart", bt = c.object({
1853
+ prompt: c.string().describe(
1854
+ "The user's inquiry and context required in order to generate a cypher query that will be used to create a link chart visualization. Only include information relevant to generating a cypher query. Do not suggest entity types, relationship types or properties. Do not include limits or formatting instructions for the query results unless specifically requested by the user. The prompt should be focused on the data the user wants to see in the link chart, not how to generate it."
2709
1855
  )
2710
- }), ga = async ({ prompt: e }, t) => {
2711
- const { knowledgeGraph: r } = await G(t), { view: o } = H(t);
2712
- if (z(o))
2713
- return {
2714
- toolName: _,
2715
- status: "error",
2716
- errorMessage: "The createLinkChart tool can only be used with a LinkChartView.",
2717
- error: new Error()
2718
- };
2719
- {
2720
- const n = k.getDefault().helperServices, s = await ya(
2721
- e,
1856
+ }), Tt = async ({ prompt: e }, t) => {
1857
+ const { knowledgeGraph: r } = await N(t), { view: a } = q(t);
1858
+ if (x(a)) {
1859
+ const i = P.getDefault().helperServices, s = await wt(
1860
+ `${e}
1861
+
1862
+ ${ne}`,
2722
1863
  r,
2723
- `${n.aiAssistantServices.url}${n.aiAssistantServices.graphQueryAssistant}`,
2724
- o,
1864
+ `${i.aiAssistantServices.url}${i.aiAssistantServices.graphQueryAssistant}`,
1865
+ a,
2725
1866
  t
2726
1867
  );
2727
- return s.type === "error" ? {
2728
- toolName: _,
1868
+ if (s.type === "error")
1869
+ return {
1870
+ toolName: D,
1871
+ status: "error",
1872
+ errorMessage: s.errorMessage,
1873
+ error: new Error()
1874
+ };
1875
+ const { graphQuery: n, explanation: l } = s;
1876
+ return {
1877
+ toolName: D,
1878
+ status: "success",
1879
+ summary: `Link chart created successfully. Cypher Query used to create the link chart:
1880
+ ${n}
1881
+
1882
+ Explanation: ${l}`,
1883
+ details: {
1884
+ generatedQuery: n,
1885
+ explanation: l
1886
+ }
1887
+ };
1888
+ } else
1889
+ return {
1890
+ toolName: D,
2729
1891
  status: "error",
2730
- errorMessage: s.message,
1892
+ errorMessage: "The createLinkChart tool can only be used with a LinkChartView.",
2731
1893
  error: new Error()
2732
- } : {
2733
- toolName: _,
2734
- status: "success",
2735
- summary: s.message
2736
1894
  };
2737
- }
2738
- }, ti = f(ga, {
2739
- name: _,
2740
- description: "Creates a new link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the new link chart. The user should have explicitly requested the creation of a new link chart from their prompt.",
2741
- schema: fa
2742
- }), Fe = "queryGraphData", wa = i.object({
2743
- prompt: i.string().describe(
2744
- `The user's inquiry into the knowledge graph, from which a cypher query will be generated and executed to answer the inquiry. IMPORTANT:
2745
-
2746
- REQUEST LIMIT: If the user does not specifically request for no limits or an explicit limit to be placed on the query, or the number of rows will not be limited by e.g. the number of entity or relationship types in the graph, ensure that the generated query has a reasonable row limit (e.g. 10 rows).
2747
-
2748
- DESCRIPTIVE COLUMN NAMES: If the user's prompt does not explicitly request for specific column names in the result, ensure that the generated query has descriptive column names (using AS statements) to make the results easier to understand when displayed in a table format.`
1895
+ }, Va = g(Tt, {
1896
+ name: D,
1897
+ description: "Creates a new link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the new link chart. The user should have explicitly requested the creation of a new link chart from their prompt using language like 'create new link chart' or 'add to new link chart'.",
1898
+ schema: bt
1899
+ }), I = "queryGraphData", St = c.object({
1900
+ prompt: c.string().describe(
1901
+ "The user's inquiry into the knowledge graph, from which a cypher query will be generated and executed to answer the inquiry. Only include entity types, relationship types or properties if they are provided in the user prompt or prior steps. Do not suggest entity types, relationship types or properties. Do not include limits, information on what to return, instructions on how to write the query, or formatting instructions for the query results unless specifically requested by the user."
2749
1902
  )
2750
- }), ba = async ({ prompt: e }, t) => {
2751
- const { knowledgeGraph: r } = await G(t), a = k.getDefault().helperServices, n = await Ee({
1903
+ }), vt = async ({ prompt: e }, t) => {
1904
+ const { knowledgeGraph: r } = await N(t), o = P.getDefault().helperServices;
1905
+ let i = e, s = null, n = null;
1906
+ try {
1907
+ ({ view: n } = q(t));
1908
+ } catch {
1909
+ }
1910
+ n && ({ enhancedPrompt: i, bindParameters: s } = await ie({
2752
1911
  prompt: e,
1912
+ view: n,
1913
+ knowledgeGraph: r,
1914
+ includeReturnEntityAndRelationshipContext: !1
1915
+ }));
1916
+ const l = await oe({
1917
+ prompt: i,
1918
+ bindParameters: s,
2753
1919
  kg: r,
2754
- graphQueryServiceUrl: `${a.aiAssistantServices.url}${a.aiAssistantServices.graphQueryAssistant}`,
1920
+ graphQueryServiceUrl: `${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
2755
1921
  targetStructure: new Array(),
2756
- targetStructureReducer: (h, m) => (h.push(m), h),
1922
+ targetStructureReducer: (b, R) => (b.push(R), b),
2757
1923
  requestOptions: {
2758
- signal: t?.signal,
1924
+ signal: F(t),
2759
1925
  timeout: t?.timeout
2760
1926
  },
2761
1927
  config: t
2762
1928
  });
2763
- if (n.type !== "success") {
2764
- const h = n.type === "generation-error" ? n.errorMessage : `${n.errorMessage} Cypher query: ${n.graphQuery}`;
2765
- throw new Error(`Failed to query the knowledge graph. ${h}`);
1929
+ if (l.type !== "success") {
1930
+ const b = l.type === "generation-error" ? l.errorMessage : `${l.errorMessage} Cypher query: ${l.graphQuery}`;
1931
+ return {
1932
+ toolName: I,
1933
+ status: "error",
1934
+ errorMessage: `Failed to query the knowledge graph. ${b}`,
1935
+ error: "error" in l ? l.error : null
1936
+ };
2766
1937
  }
2767
- const { graphQuery: s, processedResult: c, resultHeader: u } = n, l = u.headerKeys;
2768
- for (const h of c)
2769
- for (const m of h)
2770
- D(
2771
- m,
2772
- (w) => $e(w)
1938
+ const { graphQuery: p, explanation: d, processedResult: u, resultHeader: h } = l, f = h.headerKeys;
1939
+ for (const b of u)
1940
+ for (const R of b)
1941
+ C(
1942
+ R,
1943
+ (z) => ae(z)
2773
1944
  );
2774
- const d = 50, p = c.slice(0, d).map((h) => JSON.stringify(h));
1945
+ const y = 50, w = u.slice(0, y).map((b) => JSON.stringify(b));
2775
1946
  return {
2776
- toolName: Fe,
1947
+ toolName: I,
2777
1948
  status: "success",
2778
1949
  summary: `To answer the inquiry, the following cypher query was executed against the knowledge graph:
2779
1950
 
2780
1951
  \`\`\`cypher
2781
- ${s}
1952
+ ${p}
2782
1953
  \`\`\`
2783
1954
 
2784
1955
  Query Results:
2785
- ${p.length} result(s) found.
1956
+ ${w.length} result(s) found.
2786
1957
 
2787
- Column Headers: ${l.join(", ")}
1958
+ Column Headers: ${f.join(", ")}
2788
1959
 
2789
- ${p.length > d ? `Showing top ${d} results:
1960
+ ${w.length > y ? `Showing top ${y} results:
2790
1961
 
2791
1962
  ` : `Results:
2792
1963
 
2793
- `}${p.join(`
1964
+ `}${w.join(`
2794
1965
  `)}
2795
1966
  `,
2796
1967
  details: {
2797
- generatedQuery: s,
2798
- resultHeader: u,
2799
- queryResults: c
1968
+ generatedQuery: p,
1969
+ explanation: d,
1970
+ resultHeader: {
1971
+ headerKeys: f,
1972
+ exceededTransferLimit: h.exceededTransferLimit,
1973
+ outSpatialReference: h.outSpatialReference
1974
+ },
1975
+ queryResults: u
2800
1976
  }
2801
1977
  };
2802
- }, ri = f(ba, {
2803
- name: Fe,
1978
+ }, Ba = g(vt, {
1979
+ name: I,
2804
1980
  description: "Allows users to explore the data in their knowledge graph via cypher query. Generates and executes a cypher query based on the user's inquiry into the knowledge graph, and displays the results in the chat pane without modifying the user's link chart if any. Use this tool when the user is asking an exploratory question about their data as a whole that can be answered via cypher query, for example 'What are the top 5 suppliers by total parts cost?' or 'How many employees do we have in each department?'.",
2805
- schema: wa
2806
- }), Ie = "generateCypher", Ta = i.object({
2807
- prompt: i.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")
2808
- }), va = async ({ prompt: e }, t) => {
2809
- const { knowledgeGraph: r } = await G(t), a = k.getDefault().helperServices, n = await Zo(
2810
- e,
2811
- r.dataModel,
2812
- `${a.aiAssistantServices.url}${a.aiAssistantServices.graphQueryAssistant}`,
2813
- t
2814
- );
2815
- return {
2816
- toolName: Ie,
2817
- status: "success",
2818
- summary: n
2819
- };
2820
- }, oi = f(va, {
2821
- name: Ie,
1981
+ schema: St
1982
+ }), O = "generateCypher", Rt = c.object({
1983
+ prompt: c.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")
1984
+ }), xt = async ({ prompt: e }, t) => {
1985
+ const { knowledgeGraph: r } = await N(t), o = P.getDefault().helperServices;
1986
+ try {
1987
+ const { graphQuery: i, explanation: s } = await Zr(
1988
+ e,
1989
+ r.dataModel,
1990
+ `${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
1991
+ t
1992
+ );
1993
+ return {
1994
+ toolName: O,
1995
+ status: "success",
1996
+ summary: `Generated Graph Query:
1997
+ ${i}
1998
+
1999
+ Explanation: ${s}`,
2000
+ details: {
2001
+ generatedQuery: i,
2002
+ explanation: s
2003
+ }
2004
+ };
2005
+ } catch (i) {
2006
+ const s = E(i);
2007
+ return {
2008
+ toolName: O,
2009
+ status: "error",
2010
+ errorMessage: `Failed to generate Cypher query. ${s}`,
2011
+ error: i
2012
+ };
2013
+ }
2014
+ }, Wa = g(xt, {
2015
+ name: O,
2822
2016
  description: "Generates an Open Cypher query based on the user's prompt which represents an inquiry into the data of the knowledge service and its graph database, attempting to filter based on certain conditions and traverse specified relationships. The generated query should be syntactically correct and optimized for performance.",
2823
- schema: Ta
2824
- }), Sa = (e) => {
2017
+ schema: Rt
2018
+ }), Ct = (e) => {
2825
2019
  const t = e.dataModel, r = /* @__PURE__ */ new Map();
2826
- for (const c of t.searchIndexes)
2827
- if (c.supportedCategory !== "esriTypeMetaEntityProvenance")
2828
- for (const [u, l] of c.searchProperties.entries()) {
2829
- const d = r.get(u) ?? /* @__PURE__ */ new Set();
2830
- l.propertyNames.forEach((p) => d.add(p)), r.set(u, d);
2020
+ for (const n of t.searchIndexes)
2021
+ if (n.supportedCategory !== "esriTypeMetaEntityProvenance")
2022
+ for (const [l, p] of n.searchProperties.entries()) {
2023
+ const d = r.get(l) ?? /* @__PURE__ */ new Set();
2024
+ p.propertyNames.forEach((u) => d.add(u)), r.set(l, d);
2831
2025
  }
2832
- const o = t.entityTypes.filter((c) => r.has(c.name)), a = t.relationshipTypes.filter((c) => r.has(c.name)), n = `Entity Types:
2833
- ${o.map(({ name: c }) => `${c}: [${Array.from(r.get(c) ?? []).join(", ")}]`).join(`
2026
+ const a = t.entityTypes.filter((n) => r.has(n.name)), o = t.relationshipTypes.filter((n) => r.has(n.name)), i = `Entity Types:
2027
+ ${a.map(({ name: n }) => `${n}: [${Array.from(r.get(n) ?? []).join(", ")}]`).join(`
2834
2028
  `)}`, s = `Relationship Types:
2835
- ${a.map(({ name: c }) => `${c}: [${Array.from(r.get(c) ?? []).join(", ")}]`).join(`
2029
+ ${o.map(({ name: n }) => `${n}: [${Array.from(r.get(n) ?? []).join(", ")}]`).join(`
2836
2030
  `)}`;
2837
- return `${n}
2031
+ return `${i}
2838
2032
 
2839
2033
  ${s}`;
2840
2034
  };
2841
- async function xa(e, t) {
2842
- const r = await Y("arcgis_knowledge_lucene_generation_prompt"), o = {
2035
+ async function $t(e, t, r) {
2036
+ const a = await L("arcgis_knowledge_lucene_generation_prompt"), o = {
2843
2037
  inquiry: e,
2844
- dataModelForSearch: Sa(t)
2845
- }, a = i.enum(["entity", "relationship", "both"]).describe("The graph element category to search against - entity, relationship, or both"), n = i.number().int().positive().nullable().describe(
2038
+ dataModelForSearch: Ct(t)
2039
+ }, i = c.enum(["entity", "relationship", "both"]).describe("The graph element category to search against - entity, relationship, or both"), s = c.number().int().positive().nullable().describe(
2846
2040
  "The maximum number of search results to return. Default to 10 if not specified by the user, or set to null if the user specifically requests no limits or all results."
2847
- ), s = i.array(
2848
- i.enum(
2849
- t.dataModel.entityTypes.map((l) => l.name).concat(t.dataModel.relationshipTypes.map((l) => l.name))
2041
+ ), n = c.array(
2042
+ c.enum(
2043
+ t.dataModel.entityTypes.map((d) => d.name).concat(t.dataModel.relationshipTypes.map((d) => d.name))
2850
2044
  )
2851
- ).min(1), c = i.object({
2852
- query: i.string().describe("A lucene syntax query string to be executed against the knowledge graph search API"),
2853
- typeFilters: s.nullable().describe(
2045
+ ).min(1), l = c.object({
2046
+ query: c.string().describe("A lucene syntax query string to be executed against the knowledge graph search API"),
2047
+ typeFilters: n.nullable().describe(
2854
2048
  "Nullable list of entity or relationship types from the graph to limit the search to. If set to null, search will execute against all named types with indexed properties in the graph"
2855
2049
  ),
2856
- typeCategoryFilter: a,
2857
- resultLimit: n
2050
+ typeCategoryFilter: i,
2051
+ resultLimit: s
2858
2052
  });
2859
- return await qe({
2860
- promptText: r,
2053
+ return await le({
2054
+ promptText: a,
2861
2055
  inputVariables: o,
2862
- schema: c
2056
+ schema: l,
2057
+ config: r
2863
2058
  });
2864
2059
  }
2865
- const ke = "searchGraphData", Ra = i.object({
2866
- prompt: i.string().describe(
2060
+ const K = "searchGraphData", Pt = c.object({
2061
+ prompt: c.string().describe(
2867
2062
  "The user's inquiry into the knowledge graph, from which a lucene search query will be generated and executed against the graph to return relevant results."
2868
2063
  )
2869
- }), $a = async ({ prompt: e }, t) => {
2870
- const { knowledgeGraph: r } = await G(t);
2871
- await S({ text: "Generating search query for the user inquiry" }, t);
2872
- const o = await xa(e, r);
2873
- await S({ text: "Executing graph search with generated search query" }, t);
2874
- const a = await Xo({
2064
+ }), Et = async ({ prompt: e }, t) => {
2065
+ const { knowledgeGraph: r } = await N(t);
2066
+ await T({ text: "Generating search query for the user inquiry" }, t);
2067
+ const a = await $t(e, r, t);
2068
+ await T({ text: "Executing graph search with generated search query" }, t);
2069
+ const o = await lt({
2875
2070
  kg: r,
2876
- searchQuery: o.query,
2877
- typeCategoryFilter: o.typeCategoryFilter,
2878
- namedTypesFilter: o.typeFilters,
2879
- searchResultLimit: o.resultLimit,
2071
+ searchQuery: a.query,
2072
+ typeCategoryFilter: a.typeCategoryFilter,
2073
+ namedTypesFilter: a.typeFilters,
2074
+ searchResultLimit: a.resultLimit,
2880
2075
  requestOptions: {
2881
- signal: t?.signal,
2076
+ signal: F(t),
2882
2077
  timeout: t?.timeout
2883
2078
  }
2884
2079
  });
2885
- if (a.type !== "success")
2886
- throw new Error(
2887
- `Graph search failed with error: ${a.type === "error" ? a.errorMessage : "aborted"}`
2888
- );
2889
- for (const c of a.results)
2890
- D(
2891
- c,
2892
- (u) => $e(u)
2080
+ if (o.type !== "success")
2081
+ return {
2082
+ toolName: K,
2083
+ status: "error",
2084
+ errorMessage: o.errorMessage,
2085
+ error: "error" in o ? o.error : null
2086
+ };
2087
+ for (const n of o.results)
2088
+ C(
2089
+ n,
2090
+ (l) => ae(l)
2893
2091
  );
2894
- const n = 10, s = a.results.slice(0, n);
2092
+ const i = 10, s = o.results.slice(0, i);
2895
2093
  return {
2896
- toolName: ke,
2094
+ toolName: K,
2897
2095
  status: "success",
2898
2096
  summary: `To answer the query, the following lucene query was generated and executed:
2899
- Query: ${o.query}
2900
- Type Category Filter: ${o.typeCategoryFilter}
2901
- Named Type Filters: ${o.typeFilters ? o.typeFilters.join(", ") : "None"}
2902
- Result Limit: ${o.resultLimit ?? "No limit"}
2097
+ Query: ${a.query}
2098
+ Type Category Filter: ${a.typeCategoryFilter}
2099
+ Named Type Filters: ${a.typeFilters ? a.typeFilters.join(", ") : "None"}
2100
+ Result Limit: ${a.resultLimit ?? "No limit"}
2903
2101
 
2904
- Search Results: ${a.results.length} result(s) found.
2102
+ Search Results: ${o.results.length} result(s) found.
2905
2103
 
2906
- ${a.results.length > n ? `Showing top ${n} results:
2104
+ ${o.results.length > i ? `Showing top ${i} results:
2907
2105
 
2908
- ` : ""}${s.map((c) => JSON.stringify(c)).join(`
2106
+ ` : ""}${s.map((n) => JSON.stringify(n)).join(`
2909
2107
  `)}`,
2910
2108
  details: {
2911
- generatedQuery: o,
2912
- searchResults: {
2913
- ...a
2914
- }
2109
+ generatedSearchQuery: a,
2110
+ searchResults: o.results
2915
2111
  }
2916
2112
  };
2917
- }, ai = f($a, {
2918
- name: ke,
2919
- description: "Allows users to search the knowledge graph for text matching their inquiry, using lucene search syntax, against indexed string properties defined on their entities and relationships. Use this tool when the user asks a question about their knowledge graph data as a whole, that could be answered via lucene text search of properties stored on graph elements, e.g requiring fuzzy matching. Otherwise if the inquiry is looking for connected records (e.g. paths), data aggregations, etc explore the data via the queryGraphData tool.",
2920
- schema: Ra
2113
+ }, Ua = g(Et, {
2114
+ name: K,
2115
+ description: `
2116
+ Search the knowledge graph using one or more search texts, using lucene search syntax, against indexed string properties defined on their entities and relationships. Use this tool when the user asks a question about their knowledge graph data as a whole, that could be answered via lucene text search of properties stored on graph elements, e.g requiring fuzzy matching. Otherwise if the inquiry is looking for connected records (e.g. paths), data aggregations, etc explore the data via the queryGraphData tool.
2117
+ Example prompts:
2118
+ - "Find 'Bradley'"
2119
+ - "find the person john smith"
2120
+ - "find all people named smith"
2121
+ - "Find all references to 'delayed parts shipment'"
2122
+ - "Find all reports authored by someone with the title of 'Researcher'"
2123
+ - "Find the first 5 reports where summary mentions flood zoning near Sacramento, and the organization name is the City of Sacramento Utilities, and tags containing stormwater".
2124
+ - "Search for all john smiths and show their global ids`,
2125
+ schema: Pt
2921
2126
  });
2922
2127
  export {
2923
- qn as A,
2924
- Dn as B,
2925
- An as C,
2926
- Ln as D,
2927
- Pn as E,
2928
- jn as F,
2929
- ne as G,
2930
- Bn as H,
2931
- Gn as I,
2932
- On as J,
2933
- Mn as K,
2934
- Qn as L,
2935
- _n as M,
2936
- vn as N,
2937
- Vn as O,
2938
- Un as P,
2939
- Mo as Q,
2940
- N as R,
2941
- Wn as S,
2942
- Kn as T,
2943
- Xn as a,
2944
- oi as b,
2945
- ei as c,
2946
- ti as d,
2947
- Yn as e,
2948
- be as f,
2949
- Y as g,
2950
- Zn as h,
2951
- G as i,
2952
- Jn as j,
2953
- Sn as k,
2954
- Hn as l,
2955
- xn as m,
2956
- Rn as n,
2957
- $n as o,
2958
- En as p,
2959
- ri as q,
2960
- Nn as r,
2961
- ai as s,
2962
- Wt as t,
2963
- Cn as u,
2964
- Fn as v,
2965
- In as w,
2966
- kn as x,
2967
- $ as y,
2968
- zn as z
2128
+ Ga as A,
2129
+ xa as D,
2130
+ W as G,
2131
+ Fa as H,
2132
+ ja as L,
2133
+ va as N,
2134
+ Oa as a,
2135
+ Wa as b,
2136
+ Ka as c,
2137
+ Va as d,
2138
+ Ia as e,
2139
+ Qa as f,
2140
+ L as g,
2141
+ N as h,
2142
+ _a as i,
2143
+ Ca as j,
2144
+ Oe as k,
2145
+ $a as l,
2146
+ Pa as m,
2147
+ Ea as n,
2148
+ za as o,
2149
+ ka as p,
2150
+ Ba as q,
2151
+ Ra as r,
2152
+ Ua as s,
2153
+ Ie as t,
2154
+ Aa as u,
2155
+ qa as v,
2156
+ Na as w,
2157
+ Ma as x,
2158
+ Da as y,
2159
+ La as z
2969
2160
  };