@arcgis/ai-components 5.2.0-next.8 → 5.2.0-next.85

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 (313) 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 +3 -2
  6. package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
  7. package/dist/agent-utils/index.d.ts +177 -0
  8. package/dist/agent-utils/index.js +167 -0
  9. package/dist/agent-utils/middlewares/trace.d.ts +2 -0
  10. package/dist/agent-utils/middlewares/trace.js +25 -33
  11. package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
  12. package/dist/agent-utils/types.d.ts +37 -8
  13. package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
  14. package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
  15. package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
  16. package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
  17. package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
  18. package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
  19. package/dist/agentic-workflow/AgenticWorkflowRuntime.d.ts +24 -0
  20. package/dist/agentic-workflow/Edge.d.ts +16 -0
  21. package/dist/agentic-workflow/WebAgent.d.ts +39 -0
  22. package/dist/agentic-workflow/jsonTypes.d.ts +183 -0
  23. package/dist/agentic-workflow/nodes/AgentNode.d.ts +27 -0
  24. package/dist/agentic-workflow/nodes/BaseNode.d.ts +35 -0
  25. package/dist/agentic-workflow/nodes/EndMessageNode.d.ts +25 -0
  26. package/dist/agentic-workflow/nodes/StartNode.d.ts +21 -0
  27. package/dist/agentic-workflow/nodes/tools/ArcgisTool.d.ts +21 -0
  28. package/dist/agentic-workflow/types.d.ts +29 -0
  29. package/dist/agents/tools/filter/clearFilters/adapter.d.ts +8 -0
  30. package/dist/agents/tools/filter/clearFilters/adapter.js +22 -0
  31. package/dist/agents/tools/filter/resetMap/adapter.d.ts +8 -0
  32. package/dist/agents/tools/filter/resetMap/adapter.js +22 -0
  33. package/dist/agents/tools/filter/setFeatureEffect/adapter.d.ts +8 -0
  34. package/dist/agents/tools/filter/setFeatureEffect/adapter.js +109 -0
  35. package/dist/agents/tools/help/listFields/adapter.d.ts +11 -0
  36. package/dist/agents/tools/help/listFields/adapter.js +30 -0
  37. package/dist/agents/tools/navigation/goToAddress/adapter.d.ts +10 -0
  38. package/dist/agents/tools/navigation/goToAddress/adapter.js +52 -0
  39. package/dist/agents/tools/navigation/goToBookmark/adapter.d.ts +8 -0
  40. package/dist/agents/tools/navigation/goToBookmark/adapter.js +30 -0
  41. package/dist/agents/tools/navigation/goToFeatures/adapter.d.ts +8 -0
  42. package/dist/agents/tools/navigation/goToFeatures/adapter.js +50 -0
  43. package/dist/agents/tools/navigation/goToFullExtent/adapter.d.ts +8 -0
  44. package/dist/agents/tools/navigation/goToFullExtent/adapter.js +27 -0
  45. package/dist/agents/tools/navigation/goToHomeExtent/adapter.d.ts +8 -0
  46. package/dist/agents/tools/navigation/goToHomeExtent/adapter.js +24 -0
  47. package/dist/agents/tools/navigation/goToLayer/adapter.d.ts +8 -0
  48. package/dist/agents/tools/navigation/goToLayer/adapter.js +26 -0
  49. package/dist/agents/tools/navigation/goToScale/adapter.d.ts +8 -0
  50. package/dist/agents/tools/navigation/goToScale/adapter.js +21 -0
  51. package/dist/agents/tools/navigation/goToViewpoint/adapter.d.ts +8 -0
  52. package/dist/agents/tools/navigation/goToViewpoint/adapter.js +42 -0
  53. package/dist/agents/tools/navigation/goToZoom/adapter.d.ts +8 -0
  54. package/dist/agents/tools/navigation/goToZoom/adapter.js +21 -0
  55. package/dist/agents/tools/query/getAttribute/adapter.d.ts +8 -0
  56. package/dist/agents/tools/query/getAttribute/adapter.js +40 -0
  57. package/dist/agents/tools/query/getStatistics/adapter.d.ts +8 -0
  58. package/dist/agents/tools/query/getStatistics/adapter.js +154 -0
  59. package/dist/agents/tools/query/getTopFeatures/adapter.d.ts +8 -0
  60. package/dist/agents/tools/query/getTopFeatures/adapter.js +141 -0
  61. package/dist/agents/tools/query/queryFeatures/adapter.d.ts +8 -0
  62. package/dist/agents/tools/query/queryFeatures/adapter.js +127 -0
  63. package/dist/agents/tools/search/findRelevantFields/adapter.d.ts +8 -0
  64. package/dist/agents/tools/search/findRelevantFields/adapter.js +57 -0
  65. package/dist/agents/tools/search/findRelevantLayers/adapter.d.ts +8 -0
  66. package/dist/agents/tools/search/findRelevantLayers/adapter.js +38 -0
  67. package/dist/cdn/2EY3BQQX.js +2 -0
  68. package/dist/cdn/34O57OGV.js +2 -0
  69. package/dist/cdn/3POGAH2X.js +2 -0
  70. package/dist/cdn/3SEKXQVK.js +9 -0
  71. package/dist/cdn/{AMP6IALT.js → 3UEKINYC.js} +1 -1
  72. package/dist/cdn/434TAA3J.js +2 -0
  73. package/dist/cdn/4HDDRBIY.js +2 -0
  74. package/dist/cdn/4NJ2FF7H.js +2 -0
  75. package/dist/cdn/4OGR5QKS.js +2 -0
  76. package/dist/cdn/4QGVOLW6.js +22 -0
  77. package/dist/cdn/4WIDLQUH.js +2 -0
  78. package/dist/cdn/5WYRJMBW.js +2 -0
  79. package/dist/cdn/5X7EG7D2.js +2 -0
  80. package/dist/cdn/5ZFUGNRN.js +2 -0
  81. package/dist/cdn/6HF36IKA.js +2 -0
  82. package/dist/cdn/6KFMRBAA.js +2 -0
  83. package/dist/cdn/6NHYXISD.js +2 -0
  84. package/dist/cdn/6U4GTCLJ.js +66 -0
  85. package/dist/cdn/7BCQMK6D.js +2 -0
  86. package/dist/cdn/7GMCLVSZ.js +2 -0
  87. package/dist/cdn/7M6VKBTK.js +6 -0
  88. package/dist/cdn/{GGSZM7KV.js → 7Q5EESAR.js} +6 -4
  89. package/dist/cdn/7SRLZQVC.js +5 -0
  90. package/dist/cdn/7TXR75RG.js +2 -0
  91. package/dist/cdn/7V6OSTFC.js +2 -0
  92. package/dist/cdn/7VAQUCBU.js +9 -0
  93. package/dist/cdn/7ZFAFKJT.js +2 -0
  94. package/dist/cdn/ACJTJLZN.js +2 -0
  95. package/dist/cdn/AI6DYOKR.js +181 -0
  96. package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
  97. package/dist/cdn/APFZY4PI.js +2 -0
  98. package/dist/cdn/AT4XVTJR.js +44 -0
  99. package/dist/cdn/AZ5G7YZH.js +3 -0
  100. package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
  101. package/dist/cdn/BM3WFHJG.js +2 -0
  102. package/dist/cdn/{DHOVCT6R.js → BPCBE7J6.js} +1 -1
  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/CP5BVGJU.js +2 -0
  107. package/dist/cdn/CZM4URK7.js +2 -0
  108. package/dist/cdn/DPALM2OW.js +2 -0
  109. package/dist/cdn/E7JZ7GUW.js +18 -0
  110. package/dist/cdn/EMLOVMD4.js +2 -0
  111. package/dist/cdn/EWLXNGKH.js +208 -0
  112. package/dist/cdn/F2J6BMMX.js +36 -0
  113. package/dist/cdn/FAR3DFFK.js +2 -0
  114. package/dist/cdn/FDOMMK2M.js +2 -0
  115. package/dist/cdn/{ZLXN7NMF.js → FYZATVB3.js} +10 -8
  116. package/dist/cdn/GFEOVHJK.js +2 -0
  117. package/dist/cdn/HDM2D2GD.js +2 -0
  118. package/dist/cdn/HHFNQR6Z.js +2 -0
  119. package/dist/cdn/HMUWQCXU.js +2 -0
  120. package/dist/cdn/I3ONG4AX.js +2 -0
  121. package/dist/cdn/IBZ2NEAO.js +2 -0
  122. package/dist/cdn/{FX7UOGHP.js → ICBIUFK7.js} +1 -1
  123. package/dist/cdn/IFJM5XEQ.js +2 -0
  124. package/dist/cdn/IHP25JWI.js +99 -0
  125. package/dist/cdn/J6A4AS7E.js +22 -0
  126. package/dist/cdn/J6SZIQJA.js +2 -0
  127. package/dist/cdn/{NE7E52YR.js → JEBRN3EU.js} +9 -3
  128. package/dist/cdn/JKIESH74.js +2 -0
  129. package/dist/cdn/JO5ETMPS.js +2 -0
  130. package/dist/cdn/JWIE3YK3.js +2 -0
  131. package/dist/cdn/K2R6XVK3.js +2 -0
  132. package/dist/cdn/KITIP6J2.js +2 -0
  133. package/dist/cdn/KPO4XX6J.js +2 -0
  134. package/dist/cdn/KWD2ECTM.js +2 -0
  135. package/dist/cdn/L7XTRDFM.js +3 -0
  136. package/dist/cdn/{7RCQFLPP.js → LK7ZIQW6.js} +1 -1
  137. package/dist/cdn/LLUGJKAQ.js +2 -0
  138. package/dist/cdn/LMPNXXTQ.js +2 -0
  139. package/dist/cdn/LYKCYBGB.js +2 -0
  140. package/dist/cdn/{3PKJWIC3.js → M2L5R4LA.js} +1 -1
  141. package/dist/cdn/{V2P4AIGG.js → M4URMXDS.js} +1 -1
  142. package/dist/cdn/MDAKBX7N.js +2 -0
  143. package/dist/cdn/MWYBF3F3.js +66 -0
  144. package/dist/cdn/NEV6OZN3.js +71 -0
  145. package/dist/cdn/NQDOAPE3.js +2 -0
  146. package/dist/cdn/OAKRPM7D.js +2 -0
  147. package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
  148. package/dist/cdn/ONMNQBPO.js +2 -0
  149. package/dist/cdn/ONQ6JSBJ.js +2 -0
  150. package/dist/cdn/OWTGH34K.js +2 -0
  151. package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
  152. package/dist/cdn/PSYRZMX2.js +2 -0
  153. package/dist/cdn/PUHRBGKB.js +2 -0
  154. package/dist/cdn/Q57QWN5W.js +2 -0
  155. package/dist/cdn/QNNGPA3Q.js +2 -0
  156. package/dist/cdn/R74ZHFA6.js +2 -0
  157. package/dist/cdn/RBE55SWR.js +2 -0
  158. package/dist/cdn/RHYNE5OE.js +2 -0
  159. package/dist/cdn/RLEHNAIA.js +2 -0
  160. package/dist/cdn/RV55GABG.js +2 -0
  161. package/dist/cdn/RWWOOC7S.js +2 -0
  162. package/dist/cdn/{X2ZDYHCG.js → SDWWUWAF.js} +10 -5
  163. package/dist/cdn/T4RIGOXB.js +2 -0
  164. package/dist/cdn/TACBKKBI.js +2 -0
  165. package/dist/cdn/TMJMDCSA.js +4 -0
  166. package/dist/cdn/TPULIO6I.js +34 -0
  167. package/dist/cdn/U2D53TAX.js +14 -0
  168. package/dist/cdn/UEEH5ZQK.js +156 -0
  169. package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
  170. package/dist/cdn/UHZG7SKO.js +2 -0
  171. package/dist/cdn/UZLQALHY.js +2 -0
  172. package/dist/cdn/V52XWEGV.js +11 -0
  173. package/dist/cdn/V6HOUZPZ.js +2 -0
  174. package/dist/cdn/VAXH6RUQ.js +134 -0
  175. package/dist/cdn/VLLZ2FFU.js +2 -0
  176. package/dist/cdn/VNJMTA6O.js +2 -0
  177. package/dist/cdn/VOKXKU7M.js +56 -0
  178. package/dist/cdn/VXFQANGJ.js +2 -0
  179. package/dist/cdn/W5G35GO4.js +2 -0
  180. package/dist/cdn/WKTQVBFJ.js +2 -0
  181. package/dist/cdn/WLH47YFC.js +14 -0
  182. package/dist/cdn/WP7ORLSB.js +6 -0
  183. package/dist/cdn/Y7XD7ZRD.js +2 -0
  184. package/dist/cdn/YEZ3AMNX.js +2 -0
  185. package/dist/cdn/YLVJA4ZE.js +2 -0
  186. package/dist/cdn/Z5W4V7RC.js +2 -0
  187. package/dist/cdn/ZLWWWTH4.js +2 -0
  188. package/dist/cdn/ZOEMBHRF.js +2 -0
  189. package/dist/cdn/ZQMBJ6MI.js +2 -0
  190. package/dist/cdn/ZRESBCJL.js +2 -0
  191. package/dist/cdn/{ZTBA5PM7.js → ZU2FHVNK.js} +1 -1
  192. package/dist/cdn/ZUNLFO6M.js +3 -0
  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 +1294 -2112
  204. package/dist/chunks/arcgisKnowledgeGraph.js +127 -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 +56 -0
  210. package/dist/chunks/converterUtils.js +66 -41
  211. package/dist/chunks/dataExplorationGraph.js +132 -177
  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 +34 -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 +36 -31
  223. package/dist/chunks/mergeWhereClauses.js +15 -0
  224. package/dist/chunks/navigationGraph.js +123 -103
  225. package/dist/chunks/navigation_intent_prompt.js +8 -2
  226. package/dist/chunks/orchestrator.js +205 -175
  227. package/dist/chunks/slottableRequestUtils.js +3 -7
  228. package/dist/chunks/state.js +21 -27
  229. package/dist/chunks/summarize_query_response_prompt.js +9 -7
  230. package/dist/chunks/toolCallResponse.js +13 -10
  231. package/dist/chunks/types.js +59 -0
  232. package/dist/chunks/utils2.js +11 -11
  233. package/dist/components/arcgis-assistant/customElement.d.ts +56 -0
  234. package/dist/components/arcgis-assistant/customElement.js +387 -155
  235. package/dist/components/arcgis-assistant/index.js +2 -3
  236. package/dist/components/arcgis-assistant/types.d.ts +14 -1
  237. package/dist/components/arcgis-assistant-agent/customElement.d.ts +13 -1
  238. package/dist/components/arcgis-assistant-agent/customElement.js +608 -10
  239. package/dist/components/arcgis-assistant-chat/customElement.d.ts +2 -1
  240. package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
  241. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +2 -0
  242. package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
  243. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +19 -3
  244. package/dist/components/arcgis-assistant-help-agent/customElement.js +28 -6
  245. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -0
  246. package/dist/components/arcgis-assistant-interrupt/customElement.js +17 -14
  247. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +24 -0
  248. package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
  249. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
  250. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +39 -16
  251. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +29 -6
  252. package/dist/components/arcgis-assistant-message/customElement.d.ts +5 -0
  253. package/dist/components/arcgis-assistant-message/customElement.js +29 -26
  254. package/dist/components/arcgis-assistant-message/index.js +2 -0
  255. package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
  256. package/dist/components/arcgis-assistant-message-block/index.js +1 -0
  257. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +7 -0
  258. package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -7
  259. package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
  260. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +1 -0
  261. package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
  262. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +17 -3
  263. package/dist/components/arcgis-assistant-speech-input/customElement.js +29 -46
  264. package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
  265. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +2 -0
  266. package/dist/components/arcgis-assistant-user-message/customElement.js +15 -10
  267. package/dist/docs/api.json +1 -1
  268. package/dist/docs/docs.json +1 -1
  269. package/dist/docs/vscode.html-custom-data.json +1 -1
  270. package/dist/docs/web-types.json +1 -1
  271. package/dist/loader.js +9 -8
  272. package/dist/oauth-callback.html +1 -1
  273. package/dist/types/lumina.d.ts +9 -8
  274. package/dist/types/preact.d.ts +9 -8
  275. package/dist/types/react.d.ts +9 -8
  276. package/dist/types/stencil.d.ts +11 -10
  277. package/dist/utils/index.d.ts +10 -10
  278. package/dist/utils/index.js +56 -55
  279. package/package.json +32 -12
  280. package/dist/cdn/2AXF774U.js +0 -2
  281. package/dist/cdn/462JBSEV.js +0 -422
  282. package/dist/cdn/53ZCUPKK.js +0 -22
  283. package/dist/cdn/5QAHYX7Y.js +0 -5
  284. package/dist/cdn/5XRDJL7R.js +0 -14
  285. package/dist/cdn/7BCR6TUO.js +0 -2
  286. package/dist/cdn/7GH7VSB2.js +0 -2
  287. package/dist/cdn/7PLV4QH6.js +0 -2
  288. package/dist/cdn/AO7BQHKC.js +0 -2
  289. package/dist/cdn/AXDZBBNL.js +0 -45
  290. package/dist/cdn/DDLZOMUY.js +0 -2
  291. package/dist/cdn/EECZLT6C.js +0 -166
  292. package/dist/cdn/ETRWZ3MS.js +0 -108
  293. package/dist/cdn/F2AHA4GB.js +0 -54
  294. package/dist/cdn/FX5JFRDL.js +0 -2
  295. package/dist/cdn/H7422XUG.js +0 -2
  296. package/dist/cdn/HB5A5R2E.js +0 -2
  297. package/dist/cdn/I6HNBTWY.js +0 -2
  298. package/dist/cdn/IG6YKZH3.js +0 -3
  299. package/dist/cdn/KMQ3SP4I.js +0 -5
  300. package/dist/cdn/MH5RPXHM.js +0 -2
  301. package/dist/cdn/NAUXSHIE.js +0 -72
  302. package/dist/cdn/NVI3I46B.js +0 -2
  303. package/dist/cdn/OAVEHGB6.js +0 -2
  304. package/dist/cdn/OH64RMOR.js +0 -4
  305. package/dist/cdn/P26NON3Z.js +0 -16
  306. package/dist/cdn/P6OPJQMC.js +0 -3
  307. package/dist/cdn/QR54T33D.js +0 -2
  308. package/dist/cdn/RVOAPUBN.js +0 -2
  309. package/dist/cdn/S3VPZFWQ.js +0 -36
  310. package/dist/cdn/SXDLXCIM.js +0 -2
  311. package/dist/cdn/USMDJUFS.js +0 -2
  312. package/dist/cdn/Y333DGV6.js +0 -2
  313. 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 me } from "@langchain/langgraph/web";
5
- import { n as Ne, o as x, k as U, s as S, i as ze } 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";
8
10
  import "@langchain/openai";
9
- import * as qe from "@arcgis/core/core/reactiveUtils.js";
11
+ import "@arcgis/core/config.js";
12
+ import * as ce from "@arcgis/core/core/reactiveUtils.js";
10
13
  import "@arcgis/core/layers/FeatureLayer.js";
11
- import le from "@arcgis/core/request.js";
12
14
  import "@langchain/core/prompts";
13
- import { tool as f } from "@langchain/core/tools";
14
- import J from "@arcgis/core/config.js";
15
- import De from "@arcgis/core/Graphic.js";
16
- import { addressToLocations as Ae } from "@arcgis/core/rest/locator.js";
17
- import Le from "@arcgis/core/symbols/PictureMarkerSymbol.js";
18
- import i, { z as C } from "zod";
19
- import Pe from "@arcgis/core/geometry/Extent.js";
20
- import ye from "@arcgis/core/geometry/Point.js";
21
- import { createRenderer as je } from "@arcgis/core/smartMapping/renderers/pieChart.js";
22
- import { getSchemesByTag as Ge, getSchemes as Oe } from "@arcgis/core/smartMapping/symbology/pieChart.js";
23
- import { getBackgroundColorTheme as ue } from "@arcgis/core/views/support/colorUtils.js";
24
- import { createAgeRenderer as Me, createContinuousRenderer as Qe } from "@arcgis/core/smartMapping/renderers/color.js";
25
- import { getSchemesByTag as re } from "@arcgis/core/smartMapping/symbology/color.js";
26
- import { createContinuousRenderer as _e } from "@arcgis/core/smartMapping/renderers/univariateColorSize.js";
27
- import { createRenderer as We } from "@arcgis/core/smartMapping/renderers/dotDensity.js";
28
- import { getSchemesByTag as Ve } from "@arcgis/core/smartMapping/symbology/dotDensity.js";
29
- import { createRenderer as Ue } from "@arcgis/core/smartMapping/renderers/heatmap.js";
30
- import { getSchemesByTag as Ke } from "@arcgis/core/smartMapping/symbology/heatmap.js";
31
- import { createRenderer as Be } from "@arcgis/core/smartMapping/renderers/predominance.js";
32
- import { getSchemesByTag as He } from "@arcgis/core/smartMapping/symbology/predominance.js";
33
- import { createRenderer as Je } from "@arcgis/core/smartMapping/renderers/relationship.js";
34
- import { getSchemesByTag as Ze } from "@arcgis/core/smartMapping/symbology/relationship.js";
35
- import { createAgeRenderer as Ye, createContinuousRenderer as Xe } from "@arcgis/core/smartMapping/renderers/size.js";
36
- import { createRenderer as et } from "@arcgis/core/smartMapping/renderers/type.js";
37
- import { getSchemesByTag as tt } from "@arcgis/core/smartMapping/symbology/type.js";
38
- import { ToolNode as rt } from "@langchain/langgraph/prebuilt";
39
- import ot from "@arcgis/core/layers/support/FeatureEffect.js";
40
- import fe from "@arcgis/core/layers/support/FeatureFilter.js";
41
- import * as at from "@arcgis/core/geometry/operators/unionOperator.js";
42
- import { formatDateOnly as nt, convertDateFormatToIntlOptions as M, formatTimeOnly as it, formatDate as de } from "@arcgis/core/intl.js";
43
- import st from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
44
- import ct from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
45
- import lt from "@arcgis/core/rest/support/TopFeaturesQuery.js";
46
- import ut from "@arcgis/core/rest/support/TopFilter.js";
47
- import dt from "@arcgis/core/WebLinkChart.js";
48
- import ge from "@arcgis/core/rest/knowledgeGraph/GraphQueryStreaming.js";
15
+ import { b as pe, a as G } from "./baseAgentState.js";
16
+ import { ToolNode as de } from "@langchain/langgraph/prebuilt";
17
+ import { s as T, a as S } from "./index.js";
18
+ import { clearFiltersTool as ue } from "../agents/tools/filter/clearFilters/adapter.js";
19
+ import { resetMapTool as he } from "../agents/tools/filter/resetMap/adapter.js";
20
+ import { setFeatureEffectTool as ye } from "../agents/tools/filter/setFeatureEffect/adapter.js";
21
+ import { getAttributeTool as me } from "../agents/tools/query/getAttribute/adapter.js";
22
+ import { getStatisticsTool as ge } from "../agents/tools/query/getStatistics/adapter.js";
23
+ import { getTopFeaturesTool as fe } from "../agents/tools/query/getTopFeatures/adapter.js";
24
+ import { queryFeaturesTool as we } from "../agents/tools/query/queryFeatures/adapter.js";
25
+ import c from "zod";
26
+ import { tool as g } from "@langchain/core/tools";
27
+ import { createRenderer as be } from "@arcgis/core/smartMapping/renderers/pieChart.js";
28
+ import { getSchemesByTag as Te, getSchemes as Se } from "@arcgis/core/smartMapping/symbology/pieChart.js";
29
+ import { getBackgroundColorTheme as Y } from "@arcgis/core/views/support/colorUtils.js";
30
+ import { createAgeRenderer as ve, createContinuousRenderer as Re } from "@arcgis/core/smartMapping/renderers/color.js";
31
+ import { getSchemesByTag as V } from "@arcgis/core/smartMapping/symbology/color.js";
32
+ import { createContinuousRenderer as xe } from "@arcgis/core/smartMapping/renderers/univariateColorSize.js";
33
+ import { createRenderer as Ce } from "@arcgis/core/smartMapping/renderers/dotDensity.js";
34
+ import { getSchemesByTag as $e } from "@arcgis/core/smartMapping/symbology/dotDensity.js";
35
+ import { createRenderer as Pe } from "@arcgis/core/smartMapping/renderers/heatmap.js";
36
+ import { getSchemesByTag as Ee } from "@arcgis/core/smartMapping/symbology/heatmap.js";
37
+ import { createRenderer as ze } from "@arcgis/core/smartMapping/renderers/predominance.js";
38
+ import { getSchemesByTag as ke } from "@arcgis/core/smartMapping/symbology/predominance.js";
39
+ import { createRenderer as Ae } from "@arcgis/core/smartMapping/renderers/relationship.js";
40
+ import { getSchemesByTag as qe } from "@arcgis/core/smartMapping/symbology/relationship.js";
41
+ import { createAgeRenderer as Ne, createContinuousRenderer as Me } from "@arcgis/core/smartMapping/renderers/size.js";
42
+ import { createRenderer as De } from "@arcgis/core/smartMapping/renderers/type.js";
43
+ import { getSchemesByTag as Le } from "@arcgis/core/smartMapping/symbology/type.js";
44
+ import Ge from "@arcgis/core/WebLinkChart.js";
45
+ import re from "@arcgis/core/rest/knowledgeGraph/GraphQueryStreaming.js";
49
46
  import "@arcgis/core/views/LinkChartView.js";
50
- import { fetchKnowledgeGraph as pe, executeQueryStreaming as pt, executeSearchStreaming as ht } from "@arcgis/core/rest/knowledgeGraphService.js";
51
- import mt from "@arcgis/core/rest/knowledgeGraph/GraphSearchStreaming.js";
52
- const L = (e, t) => t ?? e, Tn = b.Root({
53
- ...Ne(),
47
+ import { fetchKnowledgeGraph as Z, 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 yt(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 Ae(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 Le({
83
- url: s,
84
- width: 24,
85
- height: 24
86
- }), d = new De({
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 ft = ["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 = ft.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 gt({ address: e }, t) {
112
- const { mapView: r } = $(t);
113
- return await yt(e, r);
114
- }
115
- const wt = i.object({
116
- address: i.string().describe("The full address or place name to locate.")
117
- }), vn = f(gt, {
118
- name: "goToAddress",
119
- description: "Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",
120
- schema: wt
121
- });
122
- async function bt(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 Tt({ bookmarkName: e }, t) {
135
- const { mapView: r } = $(t);
136
- return await Promise.resolve(bt(e, r));
137
- }
138
- const vt = C.object({
139
- bookmarkName: C.string().describe("The name of the bookmark to navigate to.")
140
- }), Sn = f(Tt, {
141
- name: "goToBookmark",
142
- description: "Go to the extent of the bookmark with the given name.",
143
- schema: vt
144
- });
145
- async function St(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 xt({ layerId: e, where: t }, r) {
175
- const { mapView: o } = $(r);
176
- return await St(e, t, o);
177
- }
178
- const Rt = 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
- }), xn = f(xt, {
182
- name: "goToFeatures",
183
- description: "Go to the features that match the given filter related to the given layerId.",
184
- schema: Rt
185
- });
186
- async function $t(e) {
187
- const r = new Pe({
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 Et(e, t) {
197
- const { mapView: r } = $(t);
198
- return await $t(r);
199
- }
200
- const Ct = C.object({}), Rn = f(Et, {
201
- name: "goToFullExtent",
202
- description: "Zooms the map to the full world extent using Esri's Geocoding Service.",
203
- schema: Ct
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 Ft(e, t) {
214
- const { mapView: r } = $(t);
215
- return await It(r);
216
- }
217
- const kt = i.object({}), $n = f(Ft, {
218
- name: "goToHomeExtent",
219
- description: "Go to the initial web map view extent",
220
- schema: kt
221
- });
222
- async function Nt(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 zt({ layerId: e }, t) {
231
- const { mapView: r } = $(t);
232
- return await Nt(e, r);
233
- }
234
- const qt = C.object({
235
- layerId: C.string().describe("The id of the layer to navigate to")
236
- }), En = f(zt, {
237
- name: "goToLayer",
238
- description: "Zooms the map view to the full extent of the top matching layer.",
239
- schema: qt
240
- });
241
- async function Dt(e, t) {
242
- return await t.goTo({ scale: e }), { text: `Successfully zoomed to: ${e}` };
243
- }
244
- async function At({ scale: e }, t) {
245
- const { mapView: r } = $(t);
246
- return await Dt(e, r);
247
- }
248
- const Lt = i.object({
249
- scale: i.number().describe("The map scale of the view to go to.")
250
- }), Cn = f(At, {
251
- name: "goToScale",
252
- description: "Go to the specified view scale.",
253
- schema: Lt
254
- });
255
- async function Pt(e, t, r) {
256
- const a = {
257
- target: new ye({
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 jt({
270
- center: e,
271
- zoom: t,
272
- scale: r
273
- }, o) {
274
- const { mapView: a } = $(o);
275
- return await Pt(e, a, { zoom: t, scale: r });
276
- }
277
- const Gt = 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(jt, {
285
- name: "goToViewpoint",
286
- description: "Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",
287
- schema: Gt
288
- });
289
- async function Ot(e, t) {
290
- return await t.goTo({ zoom: e }), { text: `Successfully zoomed to: ${e}` };
291
- }
292
- async function Mt({ zoom: e }, t) {
293
- const { mapView: r } = $(t);
294
- return await Ot(e, r);
295
- }
296
- const Qt = i.object({
297
- zoom: i.number().min(1).max(20).describe("The zoom level of the view to go to.")
298
- }), Fn = f(Mt, {
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: Qt
302
- }), he = /* @__PURE__ */ Object.assign({
69
+ }), X = /* @__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 Qt = 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(X).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(X).join(`
322
90
  `)}`);
323
91
  return await t[1]();
324
92
  }
325
- const _t = (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
- }, we = (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
- }, kn = (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 Wt(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 = Ge({
344
- basemapTheme: await ue(o),
153
+ return i ? s = Te({
154
+ basemapTheme: await Y(a),
345
155
  geometryType: r.geometryType,
346
- includedTags: n,
156
+ includedTags: i,
347
157
  numColors: Math.min(t.length, 8)
348
- })[0] : s = Oe({
349
- basemapTheme: await ue(o),
158
+ })[0] : s = Se({
159
+ basemapTheme: await Y(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 Vt(e) {
366
- return await je(e);
175
+ async function We(e) {
176
+ return await be(e);
367
177
  }
368
- async function Ut({
178
+ async function Be({
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 Wt(l), p = await Vt(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 We(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 Kt = ["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 = Kt.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 Bt({
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 Ut({
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 Be({
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 Ht = 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
- }), Nn = f(Bt, {
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,308 +244,308 @@ const Ht = 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: Ht
247
+ schema: Je
438
248
  });
439
- function Jt(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 Ye(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 Zt(e) {
458
- return await Me(e);
267
+ async function Ze(e) {
268
+ return await ve(e);
459
269
  }
460
- async function Yt({
270
+ async function Xe({
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 = Jt(u), d = await Zt(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 = Ye(l), d = await Ze(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
- async function Xt({
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 Yt({
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 Xe({
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 er = 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
- }), zn = f(Xt, {
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: er
324
+ schema: rr
515
325
  });
516
326
  function tr(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({
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 rr(e) {
537
- return await Qe(e);
346
+ async function ar(e) {
347
+ return await Re(e);
538
348
  }
539
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 = tr(u), d = await rr(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
- async function ar({
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 or({
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 nr = 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
- }), qn = f(ar, {
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.
590
400
  Keywords: graduated color, choropleth, continuous color, hue, color, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease
591
401
  Example: Color each feature based on the population density.
592
402
  Fields: This style requires a single field with a number type. A second number field may be specified for normalizing the value of the first field.`,
593
- schema: nr
403
+ schema: ir
594
404
  });
595
- function ir(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({
405
+ function sr(e) {
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 sr(e) {
615
- return await _e(e);
424
+ async function lr(e) {
425
+ return await xe(e);
616
426
  }
617
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 = ir(u), d = await sr(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 lr({
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 cr({
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 ur = 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
- }), Dn = f(lr, {
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.
668
478
  Keywords: continuous color, hue, color, size, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease, amount
669
479
  Example: Color each feature based on the percentage of the population that owns a home and vary the size of each point based on total population.
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
- schema: ur
481
+ schema: dr
672
482
  });
673
- function dr(e) {
674
- const { fields: t, layer: r, view: o, colorSchemeTags: a } = e;
675
- let n;
676
- return a && (n = Ve({
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
- async function pr(e) {
694
- return await We(e);
503
+ async function hr(e) {
504
+ return await Ce(e);
695
505
  }
696
- async function hr({
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 = dr(c), l = await pr(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
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 hr({
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 yr = 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
- }), An = f(mr, {
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 yr = 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: yr
562
+ schema: gr
753
563
  });
754
564
  function fr(e) {
755
- const { fields: t, layer: r, view: o, colorSchemeTags: a } = e;
756
- let n;
565
+ const { fields: t, layer: r, view: a, colorSchemeTags: o } = e;
566
+ let i;
757
567
  const s = t[0];
758
- return a && (n = Ke({
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
- async function gr(e) {
769
- return await Ue(e);
578
+ async function wr(e) {
579
+ return await Pe(e);
770
580
  }
771
- async function wr({
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 = fr(c), l = await gr(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
- async function br({
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 wr({
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 Tr = 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
- }), Ln = f(br, {
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: Tr
630
+ schema: Sr
821
631
  });
822
632
  function vr(e) {
823
- const { fields: t, layer: r, view: o, styleName: a, colorSchemeTags: n } = e;
633
+ const { fields: t, layer: r, view: a, styleName: o, colorSchemeTags: i } = e;
824
634
  let s;
825
- return n && (s = He({
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 Sr(e) {
840
- return await Be(e);
649
+ async function Rr(e) {
650
+ return await ze(e);
841
651
  }
842
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 = vr(l), p = await Sr(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 Rr({
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 xr({
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 $r = 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
- }), Pn = f(Rr, {
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.
@@ -900,217 +710,217 @@ const $r = i.object({
900
710
  Fields: This style relies on 2-10 number fields.`,
901
711
  schema: $r
902
712
  });
903
- function Er(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 = Ze({
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 Cr(e) {
925
- return await Je(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 = Er(c), l = await Cr(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
- async function Fr({
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 kr = 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
- }), jn = f(Fr, {
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: kr
786
+ schema: Ar
977
787
  });
978
- function Nr(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 zr(e) {
991
- return await Ye(e);
800
+ async function Nr(e) {
801
+ return await Ne(e);
992
802
  }
993
- async function qr({
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 = Nr(u), d = await zr(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
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 qr({
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 Ar = 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
- }), Gn = f(Dr, {
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.
1044
854
  Keywords: since, age, how old, how long
1045
855
  Example: Change the size of features so older features are larger than new features.
1046
856
  Fields: This style requires at least one field with a date type.`,
1047
- schema: Ar
857
+ schema: Lr
1048
858
  });
1049
- function Lr(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
- async function Pr(e) {
1064
- return await Xe(e);
873
+ async function jr(e) {
874
+ return await Me(e);
1065
875
  }
1066
- async function jr({
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 = Lr(u), d = await Pr(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 Gr({
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 jr({
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 Or = 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
- }), On = f(Gr, {
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,949 +933,168 @@ const Or = 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: Or
936
+ schema: Qr
1127
937
  });
1128
- function Mr(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 = tt({
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 Qr(e) {
1146
- return await et(e);
955
+ async function Or(e) {
956
+ return await De(e);
1147
957
  }
1148
- async function _r({
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 = Mr(u), d = await Qr(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
- async function Wr({
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 _r({
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 Vr = 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
- }), Mn = f(Wr, {
1000
+ const Wr = 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: Vr
1203
- }), Qn = b.Root({
1204
- ...U(),
1205
- vectorSearchLayerIds: b(),
1206
- vectorSearchFieldResults: b(),
1207
- layerFieldInfo: b(),
1208
- selectedLayerId: b()
1209
- }), _n = b.Root({
1210
- ...U(),
1211
- vectorSearchLayerIds: b(),
1212
- vectorSearchFieldResults: b(),
1213
- layerFieldInfo: b(),
1214
- queryResponse: b(),
1215
- dataExplorationMessages: b({
1216
- reducer: me,
1217
- default: () => []
1218
- })
1219
- }), Ur = ["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 = Ur.filter((a) => !(a in r));
1225
- if (o.length)
1226
- throw new Error(`DataExplorationAgent context missing: ${o.join(", ")}`);
1227
- return r;
1228
- }
1229
- const Kr = (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
- }, Br = async (e, t) => {
1237
- const { mapView: r } = N(t);
1238
- return Kr(r);
1239
- }, Hr = f(Br, {
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
- }), Jr = 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
- }, Zr = async (e, t) => {
1251
- const { mapView: r } = N(t);
1252
- return await Jr(r);
1253
- }, Yr = f(Zr, {
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
- });
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 ye({
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
- (a) => a.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;
1280
- try {
1281
- const a = await r.queryFeatures({
1282
- where: e.where,
1283
- returnGeometry: !0,
1284
- outSpatialReference: t.spatialReference
1285
- });
1286
- if (!a.features.length)
1287
- return {
1288
- error: `No features found in geometry layer "${o}" with the specified where clause: ${e.where}`
1289
- };
1290
- let n;
1291
- if (a.features.length === 1) {
1292
- const s = a.features[0].geometry;
1293
- if (!s)
1294
- return { error: "The geometry of the first feature is undefined or null." };
1295
- n = s;
1296
- } else {
1297
- const s = a.features.map((u) => u.geometry), c = at.executeMany(s);
1298
- if (!c)
1299
- return { error: "Failed to create a combined geometry." };
1300
- n = c;
1301
- }
1302
- return n.spatialReference || (n.spatialReference = t.spatialReference), { geometry: n };
1303
- } catch (a) {
1304
- return { error: `Failed to query geometry: ${String(a)}` };
1305
- }
1306
- }
1307
- return { error: "Invalid geometry configuration provided" };
1308
- }, Xr = async (e, t, r, o, a, n) => {
1309
- const s = e.map?.allLayers.find((u) => u.id === t);
1310
- if (!s)
1311
- return { success: !1, error: `Layer '${t}' not found.` };
1312
- const c = s.createQuery();
1313
- c.where = r ?? "1=1", o && (c.geometry = o, c.spatialRelationship = "intersects", a && (c.distance = a), n && (c.units = n));
1314
- try {
1315
- const { extent: u, count: l } = await s.queryExtent(c);
1316
- return !u || l === 0 ? {
1317
- success: !1,
1318
- error: `No features found for filter (where: ${c.where}${o ? ", spatial filter used" : ""})`
1319
- } : (await e.goTo(u), { success: !0 });
1320
- } catch (u) {
1321
- return {
1322
- success: !1,
1323
- error: u instanceof Error ? u.message : String(u)
1324
- };
1325
- }
1326
- }, eo = async (e, t, r, o, a, n) => {
1327
- const s = t.map?.allLayers.find(
1328
- (p) => p.id === e.layerId
1329
- );
1330
- if (!s)
1331
- return `Could not find target layer with ID: ${e.layerId}`;
1332
- let c;
1333
- if (a) {
1334
- const p = await K(a, t);
1335
- if ("error" in p)
1336
- return p.error;
1337
- c = p.geometry;
1338
- }
1339
- if (s.featureEffect = null, s.featureEffect = new ot({
1340
- filter: new fe({
1341
- ...e.objectIds?.length ? { objectIds: e.objectIds } : { where: e.where },
1342
- geometry: c,
1343
- spatialRelationship: "intersects",
1344
- distance: a?.distance,
1345
- units: a?.units
1346
- }),
1347
- includedEffect: r,
1348
- excludedEffect: o
1349
- }), s.visible = !0, n)
1350
- return `Applied feature effects to "${s.title ?? e.layerId}" within current map extent.`;
1351
- const u = e.objectIds?.length ? `${s.objectIdField} IN (${e.objectIds.join(",")})` : e.where, l = await Xr(
1352
- t,
1353
- e.layerId,
1354
- u,
1355
- c,
1356
- a?.distance,
1357
- a?.units
1358
- ), d = s.title ?? e.layerId;
1359
- 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}`;
1360
- }, to = ["feet", "kilometers", "meters", "miles", "nautical-miles", "us-nautical-miles"], I = i.enum(to), ro = async ({
1361
- targetLayer: e,
1362
- geometryFilter: t,
1363
- useCurrentExtent: r,
1364
- includedEffect: o = "drop-shadow(2px, 2px, 2px, gray)",
1365
- excludedEffect: a = "grayscale(100%) opacity(60%) blur(2px)"
1366
- }, n) => {
1367
- const { mapView: s } = N(n);
1368
- return await eo(e, s, o, a, t, r);
1369
- }, oo = i.object({
1370
- layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1371
- where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1372
- distance: i.number().optional().describe("The buffer distance around the geometry."),
1373
- units: I.optional().describe("The units for the distance buffer.")
1374
- }), ao = i.object({
1375
- point: i.object({
1376
- x: i.number().describe("X coordinate (longitude) from navigation result"),
1377
- y: i.number().describe("Y coordinate (latitude) from navigation result"),
1378
- spatialReference: i.object({
1379
- wkid: i.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
1380
- }).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
1381
- }).describe("Point coordinates from a previous navigation/geocoding result"),
1382
- distance: i.number().optional().describe("Optional buffer distance around the point."),
1383
- units: I.optional().describe("The units for the distance buffer.")
1384
- }), no = i.object({
1385
- targetLayer: i.object({
1386
- layerId: i.string().describe("The layerId of the layer on which to set a feature effect."),
1387
- where: i.string().describe("The SQL-92 where clause representing the features to emphasize."),
1388
- objectIds: i.array(i.number()).optional().describe(
1389
- "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."
1390
- )
1391
- }),
1392
- geometryFilter: i.union([oo, ao]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),
1393
- useCurrentExtent: i.boolean().optional().describe(
1394
- "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."
1395
- ),
1396
- includedEffect: i.string().default("drop-shadow(2px, 2px, 2px, gray)").describe(
1397
- "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."
1398
- ),
1399
- excludedEffect: i.string().default("grayscale(100%) opacity(60%) blur(2px)").describe(
1400
- "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."
1401
- )
1402
- }), io = f(ro, {
1403
- name: "setFeatureEffect",
1404
- 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.",
1405
- schema: no
1406
- }), X = (e) => {
1407
- if (e instanceof Date)
1408
- return Number.isNaN(e.getTime()) ? null : e;
1409
- if (typeof e == "number" && Number.isFinite(e)) {
1410
- const t = new Date(e);
1411
- return Number.isNaN(t.getTime()) ? null : t;
1412
- }
1413
- return null;
1414
- }, so = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, co = (e) => {
1415
- if (typeof e == "string" && e)
1416
- return e;
1417
- const t = X(e);
1418
- return t ? t.toISOString().slice(0, 10) : null;
1419
- }, Wn = () => {
1420
- 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}`;
1421
- return { userTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone, userTimezoneOffset: a };
1422
- }, lo = (e, t, r) => {
1423
- const o = t?.toLowerCase();
1424
- if (o === "date-only") {
1425
- const n = co(e);
1426
- return n ? nt(n, M("short-date")) : e;
1427
- }
1428
- if (o === "time-only") {
1429
- if (typeof e == "string" && e)
1430
- return it(e, M("long-time"));
1431
- const n = X(e);
1432
- return n ? de(n, {
1433
- ...M("long-time"),
1434
- timeZone: "UTC"
1435
- }) : e;
1436
- }
1437
- const a = X(e);
1438
- return a ? de(a, {
1439
- ...M("short-date-short-time"),
1440
- timeZone: so(r)
1441
- }) : e;
1442
- }, be = (e, t, r) => {
1443
- if (e && typeof e != "function") {
1444
- const o = "getField" in r && r.getField?.(e), a = o && "getFieldDomain" in r && r.getFieldDomain ? r.getFieldDomain(o.name) : null;
1445
- if (a?.type === "coded-value") {
1446
- const s = a.codedValues.find((c) => c.code === t);
1447
- return s ? s.name : null;
1448
- }
1449
- }
1450
- return null;
1451
- }, uo = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, po = (e) => {
1452
- if (e instanceof Date)
1453
- return Number.isNaN(e.getTime()) ? null : e;
1454
- if (typeof e == "number" && Number.isFinite(e)) {
1455
- const t = new Date(e);
1456
- return Number.isNaN(t.getTime()) ? null : t;
1457
- }
1458
- if (typeof e == "string" && e) {
1459
- const t = new Date(e);
1460
- return Number.isNaN(t.getTime()) ? null : t;
1461
- }
1462
- return null;
1463
- }, ho = (e, t) => {
1464
- if (typeof e != "number")
1465
- return e;
1466
- const r = {};
1467
- 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);
1468
- try {
1469
- return new Intl.NumberFormat(void 0, r).format(e);
1470
- } catch {
1471
- return e;
1472
- }
1473
- }, mo = (e, t, r) => {
1474
- const o = po(e);
1475
- if (!o)
1476
- return e;
1477
- const a = {};
1478
- 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 = uo(r);
1479
- try {
1480
- return new Intl.DateTimeFormat(void 0, a).format(o);
1481
- } catch {
1482
- return e;
1483
- }
1484
- }, Te = (e, t) => e.getFieldAlias?.(t) ?? e.fieldsIndex?.get(t)?.alias ?? e.fieldsIndex?.get(t)?.name ?? t, ve = (e, t, r, o, a) => {
1485
- if (r == null)
1486
- return r;
1487
- const s = e.getFieldConfiguration?.(t)?.fieldFormat;
1488
- return s?.type === "number" ? ho(r, s) : s?.type === "date-time" ? mo(r, s, a) : lo(r, o, a);
1489
- }, yo = (e, t, r, o) => {
1490
- const a = e.fieldsIndex?.get(t), n = be(t, r, e) ?? r;
1491
- return ve(e, t, n, a?.type, o);
1492
- }, fo = (e, t) => Te(e, t), Se = (e, t, r) => {
1493
- const o = e.objectIdField, a = t.features.map(
1494
- (s) => s.attributes[o]
1495
- ), n = t.features.map((s) => {
1496
- const c = s.attributes, u = {};
1497
- return e.fields.forEach((l) => {
1498
- if (!Object.hasOwn(c, l.name))
1499
- return;
1500
- const d = c[l.name];
1501
- if (l.name === o) {
1502
- u[l.name] = d;
1503
- return;
1504
- }
1505
- const p = be(l.name, d, e) ?? d, h = Te(e, l.name);
1506
- u[h] = ve(e, l.name, p, l.type, r);
1507
- }), u;
1508
- });
1509
- return { objectIds: a, attributes: n };
1510
- }, go = (e, t, r) => {
1511
- const o = e.createQuery();
1512
- return o.outFields = [t], o.where = r || "1=1", o.num = 1, o;
1513
- }, wo = async (e, t, r, o) => {
1514
- const a = o.map?.allLayers.find((h) => h.id === e), n = go(a, t, r.where), c = (await a.queryFeatures(n)).features[0], u = c ? c.attributes[t] : null, l = yo(a, t, u, o.timeZone), d = fo(a, t);
1515
- return {
1516
- tool: "getAttribute",
1517
- layerName: a.title ?? e,
1518
- summary: `${d} = ${l}`,
1519
- details: {
1520
- fieldName: t,
1521
- fieldAlias: d !== t ? d : void 0,
1522
- value: l,
1523
- where: r.where
1524
- }
1525
- };
1526
- };
1527
- async function bo({ layerId: e, fieldName: t, query: r }, o) {
1528
- const { mapView: a } = N(o), n = await wo(e, t, r, a);
1529
- return JSON.stringify(n, null, 2);
1530
- }
1531
- const To = i.object({
1532
- layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
1533
- fieldName: i.string().describe("The name of the field/attribute from which to get a field value."),
1534
- query: i.object({
1535
- where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
1536
- })
1537
- }), vo = f(bo, {
1538
- name: "getAttribute",
1539
- description: "Returns an attribute value for a given feature.",
1540
- schema: To
1541
- }), oe = (e, t, r) => r ? e.hasAllFeaturesInView && e.availableFields === t : e.hasAllFeatures && e.availableFields === t;
1542
- function V(e, t) {
1543
- let r = e ?? "";
1544
- return t != null && t && (r = r ? `(${r}) AND (${t})` : t), r || null;
1545
- }
1546
- const So = async (e) => {
1547
- const { targetLayer: t, fieldName: r, statisticType: o, mapView: a, layersAndFieldsRegistry: n, geometryFilter: s } = e, c = a.map?.allLayers.find((v) => v.id === t.layerId);
1548
- if (!c)
1549
- throw new Error(`Layer '${t.layerId}' not found.`);
1550
- const u = await a.whenLayerView(c), d = n.get(t.layerId)?.fieldRegistry.get(r), p = d?.alias;
1551
- if (!d)
1552
- throw new Error(`Field '${r}' not found.`);
1553
- let h, m;
1554
- if (s) {
1555
- const v = await K(s, a);
1556
- if ("error" in v)
1557
- throw new Error(v.error);
1558
- if (!v.geometry)
1559
- throw P(s) ? new Error(`No features found matching: ${s.where}`) : new Error("Failed to create geometry");
1560
- if (P(s)) {
1561
- const O = a.map?.allLayers.find((A) => A.id === s.layerId);
1562
- h = {
1563
- geometryLayerName: O?.title ?? O?.id,
1564
- geometryLayerId: s.layerId,
1565
- geometryWhere: s.where,
1566
- distance: s.distance,
1567
- units: s.units,
1568
- applied: !0
1569
- };
1570
- } else W(s) && (h = {
1571
- point: s.point,
1572
- distance: s.distance,
1573
- units: s.units,
1574
- applied: !0
1575
- });
1576
- m = new fe({
1577
- geometry: v.geometry,
1578
- distance: s.distance,
1579
- units: s.units,
1580
- spatialRelationship: "intersects"
1581
- });
1582
- }
1583
- const w = oe(u, [r], !1);
1584
- let y = null, g = null;
1585
- const T = 10;
1586
- if (d.type !== "geometry" && d.type !== "oid" && d.type !== "global-id")
1587
- try {
1588
- const v = {
1589
- layer: c,
1590
- useFeaturesInView: w,
1591
- view: w ? a : void 0,
1592
- field: r,
1593
- sqlWhere: V(c.definitionExpression, t.where),
1594
- ...m && { filter: m },
1595
- outStatisticTypes: { include: [o] }
1596
- };
1597
- y = await st(v);
1598
- const O = ["string", "small-integer", "integer"], A = d.domain?.type === "coded-value" ? d.domain : null;
1599
- (O.includes(d.type) || A) && (g = (await ct({
1600
- layer: c,
1601
- useFeaturesInView: w,
1602
- view: w ? a : void 0,
1603
- field: r,
1604
- sqlWhere: V(c.definitionExpression, t.where),
1605
- ...m && { filter: m }
1606
- })).uniqueValueInfos.sort((q, ke) => ke.count - q.count).slice(0, T)), g && d.domain?.type === "coded-value" && (g = g.map((q) => ({
1607
- ...q,
1608
- value: A ? A.getName(q.value) ?? q.value : q.value
1609
- })));
1610
- } catch (v) {
1611
- console.error("Statistics error:", v);
1612
- }
1613
- return {
1614
- tool: "getStatistics",
1615
- layerName: c.title ?? t.layerId,
1616
- summary: `${o} = ${typeof y?.[o] == "number" ? y[o] : "N/A"}`,
1617
- details: {
1618
- fieldName: r,
1619
- fieldAlias: p,
1620
- statisticType: o,
1621
- statistic: y?.[o] ?? null,
1622
- summaryStatistics: y,
1623
- uniqueValues: g,
1624
- where: t.where,
1625
- spatialFilterInfo: h
1626
- }
1627
- };
1628
- };
1629
- async function xo({
1630
- targetLayer: e,
1631
- fieldName: t,
1632
- statisticType: r,
1633
- geometryFilter: o
1634
- }, a) {
1635
- const n = we(a, "layersAndFieldsRegistry"), { mapView: s } = N(a), c = await So({
1636
- targetLayer: e,
1637
- fieldName: t,
1638
- statisticType: r,
1639
- mapView: s,
1640
- layersAndFieldsRegistry: n,
1641
- geometryFilter: o
1642
- });
1643
- return JSON.stringify(c, null, 2);
1644
- }
1645
- const Ro = i.object({
1646
- layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1647
- where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1648
- distance: i.number().optional().describe("The buffer distance around the geometry."),
1649
- units: I.optional().describe("The units for the distance buffer.")
1650
- }), $o = i.object({
1651
- point: i.object({
1652
- x: i.number().describe("X coordinate (longitude) from navigation result"),
1653
- y: i.number().describe("Y coordinate (latitude) from navigation result"),
1654
- spatialReference: i.object({
1655
- wkid: i.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
1656
- }).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
1657
- }).describe("Point coordinates from a previous navigation/geocoding result"),
1658
- distance: i.number().optional().describe("Optional buffer distance around the point."),
1659
- units: I.optional().describe("The units for the distance buffer.")
1660
- }), Eo = i.object({
1661
- targetLayer: i.object({
1662
- layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
1663
- where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
1664
- }),
1665
- geometryFilter: i.union([Ro, $o]).optional().describe(
1666
- "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."
1667
- ),
1668
- fieldName: i.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),
1669
- statisticType: i.enum(["avg", "max", "median", "min", "stddev", "sum", "variance", "nullcount", "count"]).describe("The statistic type to calculate.")
1670
- }), Co = f(xo, {
1671
- name: "getStatistics",
1672
- 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.
1673
-
1674
- USE THIS TOOL FOR:
1675
- - "What is the average/maximum/minimum/total [field]?" — aggregate computations
1676
- - "Most common/frequent value of [field]?" — frequency analysis
1677
- - Questions requiring a mathematical aggregation across many features
1678
-
1679
- DO NOT USE FOR:
1680
- - "How many features match X?" — use queryFeatures instead (it returns totalCount)
1681
- - "Show / list / find features" — use queryFeatures instead
1682
- - Simple counts of features matching a condition — use queryFeatures instead
1683
-
1684
- 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.`,
1685
- schema: Eo
1686
- }), Io = async (e, t, r, o, a) => {
1687
- const n = r.map?.allLayers.find((h) => h.id === e.layerId), s = await r.whenLayerView(n), c = n.title ?? e.layerId;
1688
- let u;
1689
- if (o) {
1690
- const h = await K(o, r);
1691
- if ("error" in h)
1692
- return {
1693
- tool: "getTopFeatures",
1694
- layerName: c,
1695
- summary: "Geometry lookup failed",
1696
- details: { error: h.error }
1697
- };
1698
- if (!h.geometry)
1699
- return {
1700
- tool: "getTopFeatures",
1701
- layerName: c,
1702
- summary: "No features found for geometry filter",
1703
- details: {
1704
- error: `No features found matching: ${"where" in o ? o.where : "unknown criteria"}`
1705
- }
1706
- };
1707
- u = h.geometry;
1708
- } else a && (u = r.extent.clone());
1709
- const l = t.groupByFields && t.groupByFields.length > 0, d = n.objectIdField, p = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, d])];
1710
- try {
1711
- let h;
1712
- if (l) {
1713
- const y = new lt({
1714
- where: e.where || "1=1",
1715
- outFields: p,
1716
- orderByFields: e.orderByFields,
1717
- geometry: u,
1718
- spatialRelationship: u ? "intersects" : void 0,
1719
- distance: o?.distance,
1720
- units: o?.units,
1721
- topFilter: new ut({
1722
- topCount: t.topCount,
1723
- groupByFields: t.groupByFields,
1724
- orderByFields: t.orderByFields
1725
- })
1726
- });
1727
- h = await n.queryTopFeatures(y);
1728
- } else {
1729
- const y = n.createQuery();
1730
- 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;
1731
- const g = oe(s, e.outFields, a ?? !1);
1732
- try {
1733
- h = g ? await s.queryFeatures(y) : await n.queryFeatures(y);
1734
- } catch (T) {
1735
- console.warn("Client-side query failed, falling back to server:", T), h = await n.queryFeatures(y);
1736
- }
1737
- }
1738
- const m = h.features.map((y) => y.attributes[d]), { attributes: w } = Se(n, h, r.timeZone);
1739
- return {
1740
- tool: "getTopFeatures",
1741
- layerName: c,
1742
- summary: `Top ${t.topCount} features extracted`,
1743
- details: {
1744
- topCount: t.topCount,
1745
- attributes: w,
1746
- objectIds: m,
1747
- objectIdField: d,
1748
- where: e.where,
1749
- orderByFields: t.orderByFields,
1750
- ...l && { groupByFields: t.groupByFields }
1751
- }
1752
- };
1753
- } catch (h) {
1754
- return {
1755
- tool: "getTopFeatures",
1756
- layerName: c,
1757
- summary: "Query failed",
1758
- details: { error: h instanceof Error ? h.message : String(h) }
1759
- };
1760
- }
1761
- }, Fo = async ({
1762
- targetLayer: e,
1763
- topFilter: t,
1764
- geometryFilter: r,
1765
- useCurrentExtent: o
1766
- }, a) => {
1767
- const { mapView: n } = N(a), s = await Io(e, t, n, r, o);
1768
- return JSON.stringify(s, null, 2);
1769
- }, ko = i.object({
1770
- layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1771
- where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1772
- distance: i.number().optional().describe("The buffer distance around the geometry."),
1773
- units: I.optional().describe("The units for the distance buffer.")
1774
- }), No = i.object({
1775
- point: i.object({
1776
- x: i.number().describe("X coordinate (longitude) from navigation result"),
1777
- y: i.number().describe("Y coordinate (latitude) from navigation result"),
1778
- spatialReference: i.object({
1779
- wkid: i.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
1780
- }).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
1781
- }).describe("Point coordinates from a previous navigation/geocoding result"),
1782
- distance: i.number().optional().describe("Optional buffer distance around the point."),
1783
- units: I.optional().describe("The units for the distance buffer.")
1784
- }), zo = i.object({
1785
- targetLayer: i.object({
1786
- layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
1787
- where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),
1788
- orderByFields: i.array(i.string().describe("The field(s) and order for which to sort the resulting features.")),
1789
- outFields: i.array(
1790
- i.string().describe(
1791
- '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 ("*").'
1792
- ).default("*")
1793
- )
1794
- }),
1795
- geometryFilter: i.union([ko, No]).optional().describe(
1796
- "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."
1797
- ),
1798
- topFilter: i.object({
1799
- topCount: i.number().describe("Number of top features to return per group."),
1800
- orderByFields: i.array(
1801
- i.string().describe("Field(s) to rank by with ASC/DESC. Must be existing field names, not aggregate functions.")
1802
- ),
1803
- groupByFields: i.array(i.string().describe("Field(s) to group results by. Returns top N per group."))
1804
- }).required(),
1805
- useCurrentExtent: i.boolean().optional().describe(
1806
- "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)."
1807
- )
1808
- }), qo = f(Fo, {
1809
- name: "getTopFeatures",
1810
- 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.',
1811
- schema: zo
1812
- }), Z = 25, Do = async (e, t, r, o) => {
1813
- const a = t.map?.allLayers.find((y) => y.id === e.layerId), n = await t.whenLayerView(a), s = a.title ?? e.layerId;
1814
- let c;
1815
- if (r) {
1816
- const y = await K(r, t);
1817
- if ("error" in y) {
1818
- const g = { error: y.error };
1819
- if (P(r)) {
1820
- const T = t.map?.allLayers.find((E) => E.id === r.layerId);
1821
- g.geometryLayerName = T?.title ?? T?.id, g.geometryLayerId = r.layerId, g.geometryWhere = r.where;
1822
- } else W(r) && (g.point = r.point);
1823
- return {
1824
- tool: "queryFeatures",
1825
- layerName: s,
1826
- summary: "Geometry lookup failed",
1827
- details: g
1828
- };
1829
- }
1830
- if (!y.geometry) {
1831
- const g = {};
1832
- if (P(r)) {
1833
- const T = t.map?.allLayers.find((E) => E.id === r.layerId);
1834
- g.error = `No features found matching: ${r.where}`, g.geometryLayerName = T?.title ?? T?.id, g.geometryLayerId = r.layerId, g.geometryWhere = r.where;
1835
- } else W(r) && (g.error = "Failed to create point geometry", g.point = r.point);
1836
- return {
1837
- tool: "queryFeatures",
1838
- layerName: s,
1839
- summary: "No features found for geometry filter",
1840
- details: g
1841
- };
1842
- }
1843
- c = y.geometry;
1844
- } else o && (c = t.extent.clone());
1845
- const u = oe(n, e.outFields, o ?? !1), l = a.objectIdField, d = a.createQuery();
1846
- 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;
1847
- let p, h;
1848
- try {
1849
- p = u ? await n.queryFeatureCount(d) : await a.queryFeatureCount(d), p > 0 && p <= Z && (h = u ? await n.queryFeatures(d) : await a.queryFeatures(d));
1850
- } catch (y) {
1851
- 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));
1852
- }
1853
- const { objectIds: m, attributes: w } = h ? Se(a, h, t.timeZone) : { objectIds: void 0, attributes: void 0 };
1854
- return {
1855
- tool: "queryFeatures",
1856
- layerName: s,
1857
- summary: `${p} features found`,
1858
- details: {
1859
- totalCount: p,
1860
- where: e.where,
1861
- orderByFields: e.orderByFields,
1862
- outFields: e.outFields,
1863
- ...m && { objectIds: m, objectIdField: l },
1864
- ...w && { attributes: w },
1865
- ...p > Z && {
1866
- note: `${p} features found.`
1867
- }
1868
- }
1869
- };
1870
- };
1871
- async function Ao({
1872
- targetLayer: e,
1873
- geometryFilter: t,
1874
- useCurrentExtent: r
1875
- }, o) {
1876
- const { mapView: a } = N(o), n = await Do(e, a, t, r);
1877
- return JSON.stringify(n, null, 2);
1878
- }
1879
- const Lo = i.object({
1880
- layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
1881
- where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
1882
- distance: i.number().optional().describe("The buffer distance around the geometry."),
1883
- units: I.optional().describe("The units for the distance buffer.")
1884
- }), Po = i.object({
1885
- point: i.object({
1886
- x: i.number().describe("X coordinate (longitude) from navigation result"),
1887
- y: i.number().describe("Y coordinate (latitude) from navigation result"),
1888
- spatialReference: i.object({
1889
- wkid: i.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")
1890
- }).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")
1891
- }).describe("Point coordinates from a previous navigation/geocoding result"),
1892
- distance: i.number().optional().describe("Optional buffer distance around the point."),
1893
- units: I.optional().describe("The units for the distance buffer.")
1894
- }), jo = i.object({
1895
- targetLayer: i.object({
1896
- layerId: i.string().describe("The layerId of the layer containing the field from which to get a value."),
1897
- where: i.string().describe(
1898
- "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."
1899
- ),
1900
- orderByFields: i.array(i.string().describe("The field(s) and order for which to sort the resulting features.")),
1901
- outFields: i.array(
1902
- i.string().describe(
1903
- '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 ("*").'
1904
- ).default("*")
1905
- )
1906
- }),
1907
- geometryFilter: i.union([Lo, Po]).optional().describe(
1908
- "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."
1909
- ),
1910
- useCurrentExtent: i.boolean().optional().describe(
1911
- "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)."
1912
- )
1913
- }), Go = f(Ao, {
1914
- name: "queryFeatures",
1915
- description: `Queries features from a layer. Returns the total count of matching features, plus individual feature attributes if ≤25 features match.
1916
-
1917
- USE THIS TOOL FOR:
1918
- - "Show / display / list features where..." — finding and listing features
1919
- - "How many X are Y?" — counting features that match a condition
1920
- - "Which features..." / "Find features..." — identifying specific features
1921
- - Spatial queries — finding features near/within/intersecting other features
1922
- - Any question where the user wants to SEE or COUNT matching features
1923
-
1924
- This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
1925
- schema: jo
1926
- }), Oo = [vo, Co, qo, Go], Vn = [io, Yr, Hr], Mo = new rt(Oo);
1927
- async function Un(e, t) {
1928
- const { messages: r } = await Mo.invoke({ messages: e.dataExplorationMessages }, t), o = [], a = [];
1929
- for (const n of r) {
1930
- const s = n.content;
1931
- let c;
1932
- typeof s != "string" && (c = {
1933
- tool: n.name ?? "unknown",
1934
- layerName: "unknown",
1935
- summary: "Query failed",
1936
- details: { error: "Skipping non-string tool output:", raw: s }
1937
- });
1938
- try {
1939
- typeof s == "string" ? c = JSON.parse(s) : c = {
1940
- tool: n.name ?? "unknown",
1941
- layerName: "unknown",
1942
- summary: "Query failed",
1943
- details: { error: "Invalid tool output type", raw: s }
1944
- };
1945
- } catch {
1946
- c = {
1947
- tool: n.name ?? "unknown",
1948
- layerName: "unknown",
1949
- summary: "Query failed",
1950
- details: { error: s }
1951
- };
1952
- }
1953
- 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}`);
1954
- }
1955
- return await S({ text: `Finished executing layer query tool: ${a.join(", ")}` }, t), {
1956
- ...e,
1957
- dataExplorationMessages: [...e.dataExplorationMessages, ...r],
1958
- queryResponse: o,
1959
- status: "success",
1960
- outputMessage: a.join(`
1961
- `),
1962
- summary: a.length > 0 ? _t(a.join(`
1963
- `)) : "Query executed."
1964
- };
1965
- }
1966
- const Kn = b.Root({
1967
- ...U(),
1012
+ schema: Wr
1013
+ }), ja = m.Root({
1014
+ ...G(),
1015
+ vectorSearchLayerIds: m(),
1016
+ vectorSearchFieldResults: m(),
1017
+ layerFieldInfo: m(),
1018
+ selectedLayerId: m()
1019
+ }), Fa = m.Root({
1020
+ ...G(),
1968
1021
  // internal to the help agent
1969
- helpInternalState: b({
1970
- reducer: L,
1022
+ helpInternalState: m({
1023
+ reducer: k,
1971
1024
  default: () => ({
1972
1025
  toolCallMessage: void 0
1973
1026
  })
1974
1027
  })
1975
- }), Qo = (e, t) => {
1976
- const r = Array.from(e.values()).find(
1977
- ({ layerItem: n }) => n.title?.toLowerCase().includes(t.toLowerCase())
1978
- );
1979
- if (!r) {
1980
- const n = Array.from(e.values()).map((s) => s.layerItem.title).join(", ");
1981
- return `Could not find a layer matching "${t}". Available layers: ${n}`;
1982
- }
1983
- const o = Array.from(r.fieldRegistry.values()), a = o.map((n) => `- **${n.alias || n.name}** (\`${n.name}\`, ${n.type})${n.description ? `: ${n.description}` : ""}`).join(`
1984
- `);
1985
- return `**${r.layerItem.title}** has ${o.length} field(s):
1986
-
1987
- ${a}`;
1988
- }, _o = async ({ layerTitle: e }, t) => {
1989
- const r = we(t, "layersAndFieldsRegistry");
1990
- return Qo(r, e);
1991
- }, Bn = f(_o, {
1992
- name: "listLayerFields",
1993
- 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.",
1994
- schema: i.object({
1995
- layerTitle: i.string().describe("The title or partial title of the layer to list fields for.")
1996
- })
1997
- }), Hn = b.Root({
1998
- ...U(),
1999
- intent: b({
1028
+ }), _a = m.Root({
1029
+ ...G(),
1030
+ intent: m({
2000
1031
  reducer: (e, t) => t
2001
1032
  }),
2002
- arcgisKnowledgeMessages: b({
2003
- reducer: me,
1033
+ arcgisKnowledgeMessages: m({
1034
+ reducer: ee,
2004
1035
  default: () => []
2005
1036
  }),
2006
- arcgisKnowledgeToolResult: b({
1037
+ arcgisKnowledgeToolResult: m({
2007
1038
  reducer: (e, t) => t,
2008
1039
  default: () => null
2009
1040
  })
2010
- }), Q = {
2011
- conversationId: ""
2012
- };
2013
- function ae(e) {
1041
+ });
1042
+ function W(e) {
2014
1043
  const t = e.map?.allLayers.filter((r) => r.type === "knowledge-graph");
2015
1044
  if (!t || t?.length !== 1)
2016
1045
  throw new Error("The Knowledge Agent currently only supports maps with exactly one Knowledge Graph Layer.");
2017
1046
  }
2018
- function z(e) {
2019
- return !!e?.map && !("activeLinkChartLayer" in e.map);
1047
+ function x(e) {
1048
+ return !!e?.map && "activeLinkChartLayer" in e.map;
2020
1049
  }
2021
- async function B(e) {
2022
- !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);
2023
1052
  }
2024
- function H(e) {
1053
+ function q(e) {
2025
1054
  const r = e?.configurable?.context;
2026
1055
  if (!r || typeof r != "object")
2027
1056
  throw new Error("ArcgisKnowledgeAgent context missing");
2028
1057
  if (!("view" in r))
2029
1058
  throw new Error("View context missing");
2030
- const o = r.view;
2031
- return o.map && !("activeLinkChartLayer" in o.map) && ae(o), {
2032
- view: o
1059
+ const a = r.view;
1060
+ return a.map && !("activeLinkChartLayer" in a.map) && W(a), {
1061
+ view: a
2033
1062
  };
2034
1063
  }
2035
- function Jn(e) {
1064
+ function Qa(e) {
2036
1065
  const r = e?.configurable?.context;
2037
- if (xe(e) === "knowledgeGraph")
1066
+ if (te(e) === "knowledgeGraph")
2038
1067
  return "knowledgeGraph";
2039
- const a = r.view;
2040
- return z(a) ? (ae(a), "map") : "linkChart";
1068
+ const o = r.view;
1069
+ return x(o) ? "linkChart" : (W(o), "map");
2041
1070
  }
2042
- async function G(e) {
1071
+ async function N(e) {
2043
1072
  const r = e?.configurable?.context;
2044
- if (xe(e) === "knowledgeGraph")
1073
+ if (te(e) === "knowledgeGraph")
2045
1074
  return r;
2046
1075
  {
2047
- const a = r.view.map;
2048
- if (a && "activeLinkChartLayer" in a) {
2049
- const n = a.knowledgeGraph?.url;
2050
- if (!n)
1076
+ const o = r.view.map;
1077
+ if (o && "activeLinkChartLayer" in o) {
1078
+ const i = o.knowledgeGraph?.url;
1079
+ if (!i)
2051
1080
  throw new Error("Knowledge graph url missing from link chart.");
2052
1081
  return {
2053
- knowledgeGraph: await pe(n)
1082
+ knowledgeGraph: await Z(i)
2054
1083
  };
2055
1084
  } else {
2056
- ae(r.view);
1085
+ W(r.view);
2057
1086
  const s = (r.view.map?.allLayers.find(
2058
- (u) => u.type === "knowledge-graph"
1087
+ (l) => l.type === "knowledge-graph"
2059
1088
  )).url;
2060
1089
  if (!s)
2061
1090
  throw new Error("Knowledge graph url missing from map.");
2062
1091
  return {
2063
- knowledgeGraph: await pe(s)
1092
+ knowledgeGraph: await Z(s)
2064
1093
  };
2065
1094
  }
2066
1095
  }
2067
1096
  }
2068
- function xe(e) {
1097
+ function te(e) {
2069
1098
  const r = e?.configurable?.context;
2070
1099
  if (!r || typeof r != "object")
2071
1100
  throw new Error("ArcgisKnowledgeAgent context missing");
@@ -2077,12 +1106,12 @@ function xe(e) {
2077
1106
  return "view";
2078
1107
  throw new Error("ArcgisKnowledgeAgent context must have either a view or knowledgeGraph property.");
2079
1108
  }
2080
- class Wo {
1109
+ class Br {
2081
1110
  constructor(t) {
2082
- 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 = B.fromDataModel(t);
2083
1112
  }
2084
1113
  }
2085
- class ne {
1114
+ class B {
2086
1115
  constructor() {
2087
1116
  this.schemaType = "ArcgisGraphSchema", this.entityTypes = [], this.relationshipTypes = [], this.identifierInfo = {
2088
1117
  mappingInfo: {
@@ -2092,14 +1121,14 @@ class ne {
2092
1121
  };
2093
1122
  }
2094
1123
  static fromDataModel(t) {
2095
- const r = new ne();
2096
- for (const o of t.entityTypes)
2097
- r.entityTypes.push(j.fromEntityType(o));
2098
- for (const o of t.relationshipTypes)
2099
- r.relationshipTypes.push(Vo.fromRelationshipType(o));
1124
+ const r = new B();
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));
2100
1129
  return r.identifierInfo = {
2101
1130
  mappingInfo: {
2102
- identifierMapsTo: Uo(
1131
+ identifierMapsTo: Hr(
2103
1132
  t.identifierInfo.identifierMappingInfo.identifierInfoType
2104
1133
  ),
2105
1134
  identifierPropertyName: t.identifierInfo.identifierMappingInfo.uniformPropertyIdentifier.identifierPropertyName
@@ -2108,51 +1137,51 @@ class ne {
2108
1137
  }
2109
1138
  // Generates a short summary of the types in the data model for LLM consumption.
2110
1139
  static getDataModelTypesSummary(t) {
2111
- 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(", ");
2112
1141
  return `Entity Types: ${r}.
2113
- Relationship Types: ${o}.`;
1142
+ Relationship Types: ${a}.`;
2114
1143
  }
2115
1144
  }
2116
- class j {
1145
+ class A {
2117
1146
  constructor() {
2118
1147
  this.name = "", this.properties = [];
2119
1148
  }
2120
1149
  static fromEntityType(t) {
2121
- const r = new j();
2122
- r.name = t.name, r.alias = t.alias ? t.alias : void 0, r.role = Ko(t.role);
2123
- for (const o of t.properties) {
2124
- const a = {
2125
- name: o.name,
2126
- alias: o.alias ? o.alias : void 0,
2127
- fieldType: o.fieldType,
2128
- role: Bo(o.role),
2129
- geometryDef: o.fieldType === "esriFieldTypeGeometry" ? {
2130
- geometryType: o.geometryType ?? "esriGeometryAny",
2131
- hasM: o.hasM ? o.hasM : void 0,
2132
- 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: Yr(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
2133
1162
  } : void 0
2134
1163
  };
2135
- r.properties.push(a);
1164
+ r.properties.push(o);
2136
1165
  }
2137
1166
  return r;
2138
1167
  }
2139
1168
  }
2140
- class Vo extends j {
1169
+ class Ur extends A {
2141
1170
  constructor() {
2142
1171
  super(...arguments), this.observedEndPoints = [];
2143
1172
  }
2144
1173
  static fromRelationshipType(t) {
2145
- const r = j.fromEntityType(t);
1174
+ const r = A.fromEntityType(t);
2146
1175
  r.observedEndPoints = [];
2147
- for (const o of t.endPoints)
1176
+ for (const a of t.endPoints)
2148
1177
  r.observedEndPoints.push({
2149
- originEntityType: o.originEntityType,
2150
- destinationEntityType: o.destinationEntityType
1178
+ originEntityType: a.originEntityType,
1179
+ destinationEntityType: a.destinationEntityType
2151
1180
  });
2152
1181
  return r;
2153
1182
  }
2154
1183
  }
2155
- const Uo = (e) => {
1184
+ const Hr = (e) => {
2156
1185
  switch (e) {
2157
1186
  case "esriIdentifierInfoTypeUNSPECIFIED":
2158
1187
  return "UNSPECIFIED";
@@ -2163,7 +1192,7 @@ const Uo = (e) => {
2163
1192
  default:
2164
1193
  return e;
2165
1194
  }
2166
- }, Ko = (e) => {
1195
+ }, Jr = (e) => {
2167
1196
  switch (e) {
2168
1197
  case "Regular":
2169
1198
  return "esriGraphNamedObjectRegular";
@@ -2175,7 +1204,7 @@ const Uo = (e) => {
2175
1204
  return e;
2176
1205
  }
2177
1206
  };
2178
- function Bo(e) {
1207
+ function Yr(e) {
2179
1208
  switch (e) {
2180
1209
  case "esriGraphPropertyRegular":
2181
1210
  return "Regular";
@@ -2213,389 +1242,496 @@ function Bo(e) {
2213
1242
  return "Regular";
2214
1243
  }
2215
1244
  }
2216
- function Ho(e, t) {
2217
- return t ? `${e}
1245
+ function F(e) {
1246
+ return e?.signal;
1247
+ }
1248
+ async function Zr(e, t) {
1249
+ const r = await L("arcgis_knowledge_cypher_query_prompt");
1250
+ return t ? `${e} ${r}
2218
1251
 
2219
1252
  Your previous attempt to generate a cypher query failed. See the details below and generate a new cypher query that avoids this error.
2220
1253
 
2221
1254
  Attempt Number: ${t.attemptCount}
2222
1255
  Execution Error: ${t.executionError}
2223
1256
  Failed Query:
2224
- ${t.failedGraphQuery}` : e;
2225
- }
2226
- async function Jo(e, t, r, o) {
2227
- const { graphQuery: a, explanation: n } = await ie(e, t, r, o);
2228
- return `Generated Graph Query:
2229
- ${a}
2230
-
2231
- Explanation: ${n}`;
2232
- }
2233
- async function ie(e, t, r, o, a) {
2234
- const n = {
2235
- message: Ho(e, a),
2236
- context: new Wo(t)
2237
- };
2238
- Q.conversationId && (n.conversationId = Q.conversationId), await S({ text: "Attempting to generate a cypher query from your prompt..." }, o);
2239
- const s = await le(`${r}/chat`, {
1257
+ ${t.failedGraphQuery}` : `${e} ${r}`;
1258
+ }
1259
+ async function Xr(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 Zr(e, o),
1266
+ context: new Br(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`, {
2240
1270
  method: "post",
2241
- body: JSON.stringify(n),
1271
+ body: JSON.stringify(i),
2242
1272
  headers: {
2243
1273
  "Content-Type": "application/json",
2244
- token: ce.findCredential(k.getDefault().url)?.token ?? ""
2245
- }
1274
+ token: H.findCredential(P.getDefault().url)?.token ?? ""
1275
+ },
1276
+ signal: s
2246
1277
  });
2247
- if (s.httpStatus !== 200)
2248
- throw new Error(`Graph query service returned an error: ${s.httpStatus}`, {
2249
- cause: s.data
1278
+ if (n.httpStatus !== 200)
1279
+ throw new Error(`Graph query service returned an error: ${n.httpStatus}`, {
1280
+ cause: n.data
2250
1281
  });
2251
- Q.conversationId || (Q.conversationId = s.data.conversationId);
2252
- let c = !1;
2253
- const u = Date.now();
2254
- let l = s.data.sequenceNumber, d = "", p = "", h = 1;
2255
- for (; !c; ) {
2256
- await new Promise((w) => setTimeout(w, 1e3)), await S(
2257
- { text: `Periodically requesting status of job from ArcGIS AI Services${"...".substring(0, h)}` },
2258
- o
2259
- ), h = h % 3 + 1;
2260
- 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`, {
2261
1291
  method: "post",
2262
1292
  body: JSON.stringify({
2263
- conversationId: s.data.conversationId,
2264
- inquiryId: s.data.inquiryId,
2265
- ackSequenceNumber: l
1293
+ conversationId: n.data.conversationId,
1294
+ inquiryId: n.data.inquiryId,
1295
+ ackSequenceNumber: d
2266
1296
  }),
2267
1297
  headers: {
2268
1298
  "Content-Type": "application/json",
2269
- token: ce.findCredential(k.getDefault().url)?.token ?? ""
2270
- }
1299
+ token: H.findCredential(P.getDefault().url)?.token ?? ""
1300
+ },
1301
+ signal: s
2271
1302
  });
2272
- if (m.httpStatus !== 200)
2273
- throw new Error(`Graph query service polling returned an error: ${m.httpStatus}`, {
2274
- 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
2275
1306
  });
2276
- if (m.data.context)
2277
- d = m.data.context.graphQuery, p = m.data.message || "";
2278
- else if (!m.data.hasMore)
2279
- c = !0;
2280
- 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)
2281
1316
  throw new Error("Graph query service polling timed out after 1 minute.");
2282
- l = m.data.sequenceNumber;
1317
+ d = y.data.sequenceNumber;
2283
1318
  }
2284
- return { graphQuery: d, explanation: p };
1319
+ return { graphQuery: u, explanation: h };
2285
1320
  }
2286
- const F = 3;
2287
- function Re(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) {
2288
1391
  const r = {};
2289
- for (const o of Object.entries(e.properties ?? {})) {
2290
- const [a, n] = o;
2291
- 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;
2292
1395
  }
2293
1396
  return e.properties = r, e;
2294
1397
  }
2295
- function se(e) {
1398
+ function E(e) {
2296
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);
2297
1400
  }
2298
- const Zo = async ({
1401
+ const it = async ({
2299
1402
  kg: e,
2300
1403
  queryParams: t,
2301
1404
  targetStructure: r,
2302
- targetStructureReducer: o,
2303
- requestOptions: a,
2304
- queryRowLimit: n,
1405
+ targetStructureReducer: a,
1406
+ requestOptions: o,
1407
+ queryRowLimit: i,
2305
1408
  queryTimeoutMs: s
2306
1409
  }) => {
2307
- let c = null, u = r;
2308
- const l = new AbortController(), d = a?.signal, p = () => {
2309
- l.abort(d?.reason);
1410
+ let n = null, l = r;
1411
+ const p = new AbortController(), d = o?.signal, u = () => {
1412
+ p.abort(d?.reason);
2310
1413
  };
2311
- 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 }));
2312
1415
  try {
2313
- const h = await pt(e, t, a);
2314
- c = h.resultHeader;
2315
- const m = h.resultRowsStream.getReader();
2316
- let w = 0;
2317
- 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;
2318
1421
  for (; ; ) {
2319
- const { done: T, value: E } = await m.read();
2320
- if (T)
1422
+ const { done: R, value: z } = await f.read();
1423
+ if (R)
2321
1424
  break;
2322
- if (!g && s && Date.now() - y > s)
2323
- return l.abort(), { type: "timeout" };
2324
- for (const v of E) {
2325
- if (w++, n && w > n)
2326
- return l.abort(), { type: "success", rowLimitReached: !0, resultHeader: c, processedResult: u };
2327
- 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);
2328
1431
  }
2329
1432
  }
2330
1433
  } catch (h) {
2331
- 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 };
2332
1435
  } finally {
2333
- d?.removeEventListener("abort", p);
1436
+ d?.removeEventListener("abort", u);
2334
1437
  }
2335
- return { type: "success", rowLimitReached: !1, resultHeader: c, processedResult: u };
1438
+ return { type: "success", rowLimitReached: !1, resultHeader: n, processedResult: l };
2336
1439
  };
2337
- async function $e({
1440
+ async function oe({
2338
1441
  prompt: e,
2339
- kg: t,
2340
- graphQueryServiceUrl: r,
1442
+ bindParameters: t,
1443
+ kg: r,
1444
+ graphQueryServiceUrl: a,
2341
1445
  targetStructure: o,
2342
- targetStructureReducer: a,
2343
- requestOptions: n,
2344
- queryRowLimit: s,
2345
- queryTimeoutMs: c,
2346
- config: u
1446
+ targetStructureReducer: i,
1447
+ requestOptions: s,
1448
+ queryRowLimit: n,
1449
+ queryTimeoutMs: l,
1450
+ config: p
2347
1451
  }) {
2348
- let l;
2349
- for (let d = 1; d <= F; d++) {
2350
- let p;
1452
+ let d;
1453
+ for (let u = 1; u <= $; u++) {
1454
+ let h;
2351
1455
  try {
2352
- p = await ie(e, t.dataModel, r, u, l);
2353
- } catch (w) {
1456
+ h = await U(e, r.dataModel, a, p, d);
1457
+ } catch (b) {
2354
1458
  return {
2355
1459
  type: "generation-error",
2356
- errorMessage: se(w),
2357
- error: w
1460
+ errorMessage: E(b),
1461
+ error: b
2358
1462
  };
2359
1463
  }
2360
- await S(
1464
+ await T(
2361
1465
  {
2362
- 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 ? "..." : ""}`
2363
1467
  },
2364
- u
1468
+ p
2365
1469
  );
2366
- const h = await Zo({
2367
- kg: t,
2368
- queryParams: new ge({
2369
- 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
2370
1475
  }),
2371
1476
  targetStructure: o,
2372
- targetStructureReducer: a,
2373
- requestOptions: n,
2374
- queryRowLimit: s,
2375
- queryTimeoutMs: c
2376
- }), m = h.type === "aborted" ? "Query execution was aborted." : h.type === "timeout" ? "Query execution timed out." : h.type === "error" ? `Query failed with error: ${h.errorMessage}` : "";
2377
- 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")
2378
1483
  return {
2379
1484
  type: "success",
2380
- graphQuery: p.graphQuery,
2381
- explanation: p.explanation,
2382
- rowLimitReached: h.rowLimitReached,
2383
- resultHeader: h.resultHeader,
2384
- processedResult: h.processedResult
1485
+ graphQuery: h.graphQuery,
1486
+ explanation: h.explanation,
1487
+ rowLimitReached: y.rowLimitReached,
1488
+ resultHeader: y.resultHeader,
1489
+ processedResult: y.processedResult
2385
1490
  };
2386
- if (h.type === "aborted")
1491
+ if (y.type === "aborted")
2387
1492
  return {
2388
1493
  type: "aborted",
2389
- errorMessage: m,
2390
- graphQuery: p.graphQuery,
2391
- explanation: p.explanation
1494
+ errorMessage: w,
1495
+ graphQuery: h.graphQuery,
1496
+ explanation: h.explanation
2392
1497
  };
2393
- if (d >= F)
2394
- return h.type === "timeout" ? {
1498
+ if (u >= $)
1499
+ return y.type === "timeout" ? {
2395
1500
  type: "timeout",
2396
- errorMessage: m,
2397
- graphQuery: p.graphQuery,
2398
- explanation: p.explanation
1501
+ errorMessage: w,
1502
+ graphQuery: h.graphQuery,
1503
+ explanation: h.explanation
2399
1504
  } : {
2400
1505
  type: "execution-error",
2401
- errorMessage: m,
2402
- error: h.error,
2403
- graphQuery: p.graphQuery,
2404
- explanation: p.explanation
1506
+ errorMessage: w,
1507
+ error: y.error,
1508
+ graphQuery: h.graphQuery,
1509
+ explanation: h.explanation
2405
1510
  };
2406
- l = {
2407
- failedGraphQuery: p.graphQuery,
2408
- executionError: m,
2409
- attemptCount: d
2410
- }, await S(
2411
- { text: `Attempt ${d} failed with error: ${m}. Retrying...` },
2412
- 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
2413
1518
  );
2414
1519
  }
2415
1520
  throw new Error(
2416
- `Failed to execute generated cypher due to an unexpected error after ${F} attempts.`
1521
+ `Failed to execute generated cypher due to an unexpected error after ${$} attempts.`
2417
1522
  );
2418
1523
  }
2419
- const Yo = 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 ({
2420
1535
  kg: e,
2421
1536
  searchQuery: t,
2422
1537
  typeCategoryFilter: r,
2423
- namedTypesFilter: o,
2424
- searchResultLimit: a,
2425
- requestOptions: n
1538
+ namedTypesFilter: a,
1539
+ searchResultLimit: o,
1540
+ requestOptions: i
2426
1541
  }) => {
2427
1542
  const s = [];
2428
- let c = [r];
2429
- r === "both" && !e.serviceDefinition.serviceCapabilities.searchCapabilities.searchTypeFilterCapabilities.includes("esriTypeBoth") && (c = ["entity", "relationship"]);
2430
- 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;
2431
1546
  try {
2432
- for (const l of c) {
2433
- const d = u - s.length;
1547
+ for (const p of n) {
1548
+ const d = l - s.length;
2434
1549
  if (d <= 0)
2435
1550
  break;
2436
- const m = (await ht(
1551
+ const f = (await Fe(
2437
1552
  e,
2438
- new mt({
1553
+ new _e({
2439
1554
  searchQuery: t,
2440
- typeCategoryFilter: l,
2441
- namedTypesFilter: o ?? void 0,
1555
+ typeCategoryFilter: p,
1556
+ namedTypesFilter: a ?? void 0,
2442
1557
  num: d
2443
1558
  }),
2444
- n
1559
+ i
2445
1560
  )).resultRowsStream.getReader();
2446
- let w = !1;
2447
- for (; !w; ) {
2448
- const { done: y, value: g } = await m.read();
2449
- if (y) {
2450
- w = !0;
1561
+ let y = !1;
1562
+ for (; !y; ) {
1563
+ const { done: w, value: b } = await f.read();
1564
+ if (w) {
1565
+ y = !0;
2451
1566
  break;
2452
1567
  }
2453
- for (const T of g)
2454
- for (const E of T)
2455
- s.push(E);
1568
+ for (const R of b)
1569
+ for (const z of R)
1570
+ s.push(z);
2456
1571
  }
2457
1572
  }
2458
- } catch (l) {
2459
- return console.log('Error when running graph search with query: "', t, '" - error: ', l), n?.signal?.aborted ? {
2460
- type: "aborted"
2461
- } : { 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 };
2462
1580
  }
2463
1581
  return {
2464
1582
  type: "success",
2465
1583
  results: s
2466
1584
  };
2467
- };
2468
- function Xo(e, t) {
2469
- D(e, (r) => {
2470
- t.set(`${r.typeName}__${r.id}`, {
2471
- id: r.id,
2472
- typeName: r.typeName
2473
- });
2474
- });
2475
- }
2476
- function D(e, t) {
2477
- if (!(!e || typeof e != "object")) {
2478
- if (ta(e))
2479
- for (const r of e.path)
2480
- D(r, t);
2481
- else if (ea(e))
2482
- t(e);
2483
- else if (Array.isArray(e))
2484
- for (const r of e)
2485
- D(r, t);
2486
- else if (ra(e))
2487
- for (const r of Object.values(e.properties ?? {}))
2488
- D(r, t);
2489
- }
2490
- }
2491
- function ea(e) {
2492
- return !e || typeof e != "object" || Array.isArray(e) ? !1 : "id" in e && "typeName" in e;
2493
- }
2494
- function ta(e) {
2495
- return !e || typeof e != "object" || Array.isArray(e) ? !1 : e && "path" in e && Array.isArray(e.path);
2496
- }
2497
- function ra(e) {
2498
- return !e || typeof e != "object" || Array.isArray(e) || "id" in e ? !1 : "properties" in e && typeof e.properties == "object";
2499
- }
2500
- function oa(e, t) {
2501
- const r = [];
2502
- for (const o of [...t.dataModel.entityTypes, ...t.dataModel.relationshipTypes]) {
2503
- const a = e.getMemberIdsByType(o.name);
2504
- for (const n of a)
2505
- 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
+ };
2506
1602
  }
2507
- 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
+ };
2508
1626
  }
2509
- function aa(e) {
2510
- const t = [], r = [], a = e?.allLayers.find((n) => n.type === "knowledge-graph")?.inclusionModeDefinition;
2511
- if (a?.generateAllSublayers)
2512
- return { allNamedTypesFullyDynamic: !0, idTypePairs: t, dynamicTypes: r };
2513
- for (const [n, s] of a?.namedTypeDefinitions ?? [])
2514
- if (s.useAllData)
2515
- r.push(n);
2516
- else
2517
- for (const [c] of s.members)
2518
- t.push({ id: c, typeName: n });
2519
- return { allNamedTypesFullyDynamic: !1, idTypePairs: t, dynamicTypes: r };
2520
- }
2521
- async function na(e, t, r, o, a) {
2522
- const { view: n } = o, s = await $e({
1627
+ async function ct(e, t, r, a, o, i) {
1628
+ const { view: s } = o, n = await oe({
2523
1629
  prompt: e,
2524
- kg: t,
2525
- graphQueryServiceUrl: r,
1630
+ bindParameters: t,
1631
+ kg: r,
1632
+ graphQueryServiceUrl: a,
2526
1633
  targetStructure: /* @__PURE__ */ new Map(),
2527
- targetStructureReducer: (p, h) => {
2528
- for (const m of h)
2529
- Xo(m, p);
2530
- return p;
1634
+ targetStructureReducer: (h, f) => {
1635
+ for (const y of f)
1636
+ et(y, h);
1637
+ return h;
2531
1638
  },
2532
1639
  requestOptions: {
2533
- signal: a?.signal,
2534
- timeout: a?.timeout
1640
+ signal: F(i),
1641
+ timeout: i?.timeout
2535
1642
  },
2536
- config: a
1643
+ config: i
2537
1644
  });
2538
- if (s.type !== "success") {
2539
- const p = s.type === "generation-error" ? s.errorMessage : `${s.errorMessage} Cypher query: ${s.graphQuery}`;
2540
- 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}`);
2541
1648
  }
2542
- const { graphQuery: c, explanation: u, processedResult: l } = s, d = Array.from(l.values());
2543
- return await S(
1649
+ const { graphQuery: l, explanation: p, processedResult: d } = n, u = Array.from(d.values());
1650
+ return await T(
2544
1651
  {
2545
- 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...`
2546
1653
  },
2547
- a
2548
- ), !z(n) && n?.map ? (await n.map.addRecords(d), await B(n), `Link Chart updated successfully. Cypher Query used:
2549
- ${c}
2550
-
2551
- Explanation: ${u}`) : (await n?.map?.allLayers.find(
2552
- (h) => h.type === "knowledge-graph"
2553
- )?.addRecords(d), `Map updated successfully. Cypher Query used:
2554
- ${c}
2555
-
2556
- Explanation: ${u}`);
2557
- }
2558
- const Ee = "addRecords", ia = i.object({
2559
- prompt: i.string().describe("The user's inquiry into the knowledge graph that needs to be run.")
2560
- }), sa = async ({ prompt: e }, t) => {
2561
- const { knowledgeGraph: r } = await G(t), o = H(t), { view: a } = o, s = k.getDefault().helperServices;
2562
- let c = e;
2563
- if (!z(a) && a.map) {
2564
- const l = a.map, d = await Y("arcgis_knowledge_current_lc_context"), p = oa(l, r);
2565
- c = `${e}
2566
-
2567
- ${d}${JSON.stringify(p)}`;
2568
- } else {
2569
- const l = a.map, { allNamedTypesFullyDynamic: d, idTypePairs: p, dynamicTypes: h } = aa(l), m = await Y("arcgis_knowledge_current_map_context");
2570
- 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}
2571
1698
 
2572
- ${m}${JSON.stringify(p)} and all entities or relationships with the the following typeNames in the array: ${JSON.stringify(h)}`, d)
2573
- throw new Error(
2574
- "No records have been added to the map because all data in the knowledge graph is contained in the map."
2575
- );
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
+ };
2576
1714
  }
2577
- const u = await na(
2578
- c,
2579
- r,
2580
- `${s.aiAssistantServices.url}${s.aiAssistantServices.graphQueryAssistant}`,
2581
- o,
2582
- t
2583
- );
2584
- return {
2585
- toolName: Ee,
2586
- status: "success",
2587
- summary: u
2588
- };
2589
- }, Zn = f(sa, {
2590
- name: Ee,
2591
- 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.",
2592
- schema: ia
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
2593
1729
  });
2594
- async function ca(e, t) {
2595
- 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 };
2596
1732
  }
2597
- const ee = "applyLayout", la = i.object({
2598
- layout: i.enum([
1733
+ const _ = "applyLayout", ht = c.object({
1734
+ layout: c.enum([
2599
1735
  "organic-standard",
2600
1736
  "organic-community",
2601
1737
  "basic-grid",
@@ -2608,367 +1744,413 @@ const ee = "applyLayout", la = i.object({
2608
1744
  ]).describe(
2609
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"
2610
1746
  )
2611
- }), ua = async ({ layout: e }, t) => {
2612
- const { view: r } = H(t);
2613
- 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
2614
1760
  return {
2615
- toolName: ee,
1761
+ toolName: _,
2616
1762
  status: "error",
2617
1763
  errorMessage: "The applyLayout tool can only be used with a LinkChartView.",
2618
1764
  error: new Error()
2619
1765
  };
2620
- {
2621
- const o = await ca(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);
2622
1780
  return {
2623
- toolName: ee,
1781
+ toolName: Q,
2624
1782
  status: "success",
2625
- summary: o
1783
+ summary: `Successfully applied nonspatial visibility setting: ${a}.`,
1784
+ details: {
1785
+ appliedNonspatialDataDisplayMode: a
1786
+ }
2626
1787
  };
2627
- }
2628
- }, Yn = f(ua, {
2629
- name: ee,
2630
- description: "Apply a diagram layout to the link chart",
2631
- schema: la
2632
- });
2633
- async function da(e, t) {
2634
- return t.map?.changeNonspatialDataDisplay(e), await B(t), `Successfully applied nonspatial visibility setting: ${e}.`;
2635
- }
2636
- const te = "changeNonspatialVisibility", pa = i.object({
2637
- setting: i.enum(["hidden", "visible"]).describe("The setting of nonspatial visibility")
2638
- }), ha = async ({ setting: e }, t) => {
2639
- const { view: r } = H(t);
2640
- if (z(r))
1788
+ } else
2641
1789
  return {
2642
- toolName: te,
1790
+ toolName: Q,
2643
1791
  status: "error",
2644
1792
  errorMessage: "The changeNonspatialVisibility tool can only be used with a LinkChartView.",
2645
1793
  error: new Error()
2646
1794
  };
2647
- {
2648
- const o = await da(e, r);
2649
- return {
2650
- toolName: te,
2651
- status: "success",
2652
- summary: o
2653
- };
2654
- }
2655
- }, Xn = f(ha, {
2656
- name: te,
1795
+ }, Ka = g(ft, {
1796
+ name: Q,
2657
1797
  description: "Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",
2658
- schema: pa
1798
+ schema: gt
2659
1799
  });
2660
- async function ma(e, t, r, o, a) {
2661
- let n;
2662
- for (let s = 1; s <= F; s++) {
2663
- 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(
2664
1804
  e,
2665
1805
  t.dataModel,
2666
1806
  r,
2667
- a,
2668
- n
1807
+ o,
1808
+ i
2669
1809
  );
2670
1810
  try {
2671
- await S({ text: `Attempting to create link chart from derived query: ${c}` }, a);
2672
- const l = await dt.fromCypherQuery(
1811
+ await T({ text: `Attempting to create link chart from derived query: ${l}` }, o);
1812
+ const d = await Ge.fromCypherQuery(
2673
1813
  t,
2674
- new ge({
2675
- openCypherQuery: c
1814
+ new re({
1815
+ openCypherQuery: l
2676
1816
  })
2677
1817
  );
2678
- await S({ text: "Link chart created successfully, loading..." }, a), await l.load();
2679
- const d = o.map;
2680
- return o.map = l, await o.when(), await qe.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(), {
2681
1821
  type: "error",
2682
- message: `Query returned no results. Cypher Query used to create the link chart:
2683
- ${c}
1822
+ errorMessage: `Query returned no results. Cypher Query used to create the link chart:
1823
+ ${l}
2684
1824
 
2685
- Explanation: ${u}`
2686
- }) : (await B(o), {
1825
+ Explanation: ${p}`
1826
+ }) : (await j(a), {
2687
1827
  type: "success",
2688
- message: `Link chart created successfully. Cypher Query used to create the link chart:
2689
- ${c}
2690
-
2691
- Explanation: ${u}`
1828
+ graphQuery: l,
1829
+ explanation: p
2692
1830
  });
2693
- } catch (l) {
2694
- const d = l instanceof Error ? l.message : String(l);
2695
- if (s >= F)
2696
- throw new Error(
2697
- `Failed to create link chart after ${F} attempts. Last error: ${d}`
2698
- );
2699
- n = {
2700
- failedGraphQuery: c,
2701
- executionError: d,
2702
- attemptCount: s
2703
- }, await S(
2704
- { text: `Attempt ${s} to create link chart failed with error: ${d}. Retrying ...` },
2705
- 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
2706
1844
  );
2707
1845
  }
2708
1846
  }
2709
- throw new Error(`Failed to create link chart after ${F} attempts.`);
1847
+ return {
1848
+ type: "error",
1849
+ errorMessage: `Failed to create link chart after ${$} attempts. Last error: ${s}`
1850
+ };
2710
1851
  }
2711
- const _ = "createLinkChart", ya = i.object({
2712
- prompt: i.string().describe(
2713
- "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."
2714
1855
  )
2715
- }), fa = async ({ prompt: e }, t) => {
2716
- const { knowledgeGraph: r } = await G(t), { view: o } = H(t);
2717
- if (z(o))
2718
- return {
2719
- toolName: _,
2720
- status: "error",
2721
- errorMessage: "The createLinkChart tool can only be used with a LinkChartView.",
2722
- error: new Error()
2723
- };
2724
- {
2725
- const n = k.getDefault().helperServices, s = await ma(
2726
- 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}`,
2727
1863
  r,
2728
- `${n.aiAssistantServices.url}${n.aiAssistantServices.graphQueryAssistant}`,
2729
- o,
1864
+ `${i.aiAssistantServices.url}${i.aiAssistantServices.graphQueryAssistant}`,
1865
+ a,
2730
1866
  t
2731
1867
  );
2732
- return s.type === "error" ? {
2733
- 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,
2734
1891
  status: "error",
2735
- errorMessage: s.message,
1892
+ errorMessage: "The createLinkChart tool can only be used with a LinkChartView.",
2736
1893
  error: new Error()
2737
- } : {
2738
- toolName: _,
2739
- status: "success",
2740
- summary: s.message
2741
1894
  };
2742
- }
2743
- }, ei = f(fa, {
2744
- name: _,
2745
- 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.",
2746
- schema: ya
2747
- }), Ce = "queryGraphData", ga = i.object({
2748
- prompt: i.string().describe(
2749
- `The user's inquiry into the knowledge graph, from which a cypher query will be generated and executed to answer the inquiry. IMPORTANT:
2750
-
2751
- 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).
2752
-
2753
- 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."
2754
1902
  )
2755
- }), wa = async ({ prompt: e }, t) => {
2756
- const { knowledgeGraph: r } = await G(t), a = k.getDefault().helperServices, n = await $e({
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({
2757
1911
  prompt: e,
1912
+ view: n,
1913
+ knowledgeGraph: r,
1914
+ includeReturnEntityAndRelationshipContext: !1
1915
+ }));
1916
+ const l = await oe({
1917
+ prompt: i,
1918
+ bindParameters: s,
2758
1919
  kg: r,
2759
- graphQueryServiceUrl: `${a.aiAssistantServices.url}${a.aiAssistantServices.graphQueryAssistant}`,
1920
+ graphQueryServiceUrl: `${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
2760
1921
  targetStructure: new Array(),
2761
- targetStructureReducer: (h, m) => (h.push(m), h),
1922
+ targetStructureReducer: (b, R) => (b.push(R), b),
2762
1923
  requestOptions: {
2763
- signal: t?.signal,
1924
+ signal: F(t),
2764
1925
  timeout: t?.timeout
2765
1926
  },
2766
1927
  config: t
2767
1928
  });
2768
- if (n.type !== "success") {
2769
- const h = n.type === "generation-error" ? n.errorMessage : `${n.errorMessage} Cypher query: ${n.graphQuery}`;
2770
- 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
+ };
2771
1937
  }
2772
- const { graphQuery: s, processedResult: c, resultHeader: u } = n, l = u.headerKeys;
2773
- for (const h of c)
2774
- for (const m of h)
2775
- D(
2776
- m,
2777
- (w) => Re(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)
2778
1944
  );
2779
- 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));
2780
1946
  return {
2781
- toolName: Ce,
1947
+ toolName: I,
2782
1948
  status: "success",
2783
1949
  summary: `To answer the inquiry, the following cypher query was executed against the knowledge graph:
2784
1950
 
2785
1951
  \`\`\`cypher
2786
- ${s}
1952
+ ${p}
2787
1953
  \`\`\`
2788
1954
 
2789
1955
  Query Results:
2790
- ${p.length} result(s) found.
1956
+ ${w.length} result(s) found.
2791
1957
 
2792
- Column Headers: ${l.join(", ")}
1958
+ Column Headers: ${f.join(", ")}
2793
1959
 
2794
- ${p.length > d ? `Showing top ${d} results:
1960
+ ${w.length > y ? `Showing top ${y} results:
2795
1961
 
2796
1962
  ` : `Results:
2797
1963
 
2798
- `}${p.join(`
1964
+ `}${w.join(`
2799
1965
  `)}
2800
1966
  `,
2801
1967
  details: {
2802
- generatedQuery: s,
2803
- resultHeader: u,
2804
- queryResults: c
1968
+ generatedQuery: p,
1969
+ explanation: d,
1970
+ resultHeader: h,
1971
+ queryResults: u
2805
1972
  }
2806
1973
  };
2807
- }, ti = f(wa, {
2808
- name: Ce,
1974
+ }, Wa = g(vt, {
1975
+ name: I,
2809
1976
  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?'.",
2810
- schema: ga
2811
- }), Ie = "generateCypher", ba = i.object({
2812
- prompt: i.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")
2813
- }), Ta = async ({ prompt: e }, t) => {
2814
- const { knowledgeGraph: r } = await G(t), a = k.getDefault().helperServices, n = await Jo(
2815
- e,
2816
- r.dataModel,
2817
- `${a.aiAssistantServices.url}${a.aiAssistantServices.graphQueryAssistant}`,
2818
- t
2819
- );
2820
- return {
2821
- toolName: Ie,
2822
- status: "success",
2823
- summary: n
2824
- };
2825
- }, ri = f(Ta, {
2826
- name: Ie,
1977
+ schema: St
1978
+ }), O = "generateCypher", Rt = c.object({
1979
+ prompt: c.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")
1980
+ }), xt = async ({ prompt: e }, t) => {
1981
+ const { knowledgeGraph: r } = await N(t), o = P.getDefault().helperServices;
1982
+ try {
1983
+ const { graphQuery: i, explanation: s } = await Xr(
1984
+ e,
1985
+ r.dataModel,
1986
+ `${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
1987
+ t
1988
+ );
1989
+ return {
1990
+ toolName: O,
1991
+ status: "success",
1992
+ summary: `Generated Graph Query:
1993
+ ${i}
1994
+
1995
+ Explanation: ${s}`,
1996
+ details: {
1997
+ generatedQuery: i,
1998
+ explanation: s
1999
+ }
2000
+ };
2001
+ } catch (i) {
2002
+ const s = E(i);
2003
+ return {
2004
+ toolName: O,
2005
+ status: "error",
2006
+ errorMessage: `Failed to generate Cypher query. ${s}`,
2007
+ error: i
2008
+ };
2009
+ }
2010
+ }, Ba = g(xt, {
2011
+ name: O,
2827
2012
  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.",
2828
- schema: ba
2829
- }), va = (e) => {
2013
+ schema: Rt
2014
+ }), Ct = (e) => {
2830
2015
  const t = e.dataModel, r = /* @__PURE__ */ new Map();
2831
- for (const c of t.searchIndexes)
2832
- if (c.supportedCategory !== "esriTypeMetaEntityProvenance")
2833
- for (const [u, l] of c.searchProperties.entries()) {
2834
- const d = r.get(u) ?? /* @__PURE__ */ new Set();
2835
- l.propertyNames.forEach((p) => d.add(p)), r.set(u, d);
2016
+ for (const n of t.searchIndexes)
2017
+ if (n.supportedCategory !== "esriTypeMetaEntityProvenance")
2018
+ for (const [l, p] of n.searchProperties.entries()) {
2019
+ const d = r.get(l) ?? /* @__PURE__ */ new Set();
2020
+ p.propertyNames.forEach((u) => d.add(u)), r.set(l, d);
2836
2021
  }
2837
- const o = t.entityTypes.filter((c) => r.has(c.name)), a = t.relationshipTypes.filter((c) => r.has(c.name)), n = `Entity Types:
2838
- ${o.map(({ name: c }) => `${c}: [${Array.from(r.get(c) ?? []).join(", ")}]`).join(`
2022
+ const a = t.entityTypes.filter((n) => r.has(n.name)), o = t.relationshipTypes.filter((n) => r.has(n.name)), i = `Entity Types:
2023
+ ${a.map(({ name: n }) => `${n}: [${Array.from(r.get(n) ?? []).join(", ")}]`).join(`
2839
2024
  `)}`, s = `Relationship Types:
2840
- ${a.map(({ name: c }) => `${c}: [${Array.from(r.get(c) ?? []).join(", ")}]`).join(`
2025
+ ${o.map(({ name: n }) => `${n}: [${Array.from(r.get(n) ?? []).join(", ")}]`).join(`
2841
2026
  `)}`;
2842
- return `${n}
2027
+ return `${i}
2843
2028
 
2844
2029
  ${s}`;
2845
2030
  };
2846
- async function Sa(e, t) {
2847
- const r = await Y("arcgis_knowledge_lucene_generation_prompt"), o = {
2031
+ async function $t(e, t, r) {
2032
+ const a = await L("arcgis_knowledge_lucene_generation_prompt"), o = {
2848
2033
  inquiry: e,
2849
- dataModelForSearch: va(t)
2850
- }, 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(
2034
+ dataModelForSearch: Ct(t)
2035
+ }, 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(
2851
2036
  "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."
2852
- ), s = i.array(
2853
- i.enum(
2854
- t.dataModel.entityTypes.map((l) => l.name).concat(t.dataModel.relationshipTypes.map((l) => l.name))
2037
+ ), n = c.array(
2038
+ c.enum(
2039
+ t.dataModel.entityTypes.map((d) => d.name).concat(t.dataModel.relationshipTypes.map((d) => d.name))
2855
2040
  )
2856
- ).min(1), c = i.object({
2857
- query: i.string().describe("A lucene syntax query string to be executed against the knowledge graph search API"),
2858
- typeFilters: s.nullable().describe(
2041
+ ).min(1), l = c.object({
2042
+ query: c.string().describe("A lucene syntax query string to be executed against the knowledge graph search API"),
2043
+ typeFilters: n.nullable().describe(
2859
2044
  "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"
2860
2045
  ),
2861
- typeCategoryFilter: a,
2862
- resultLimit: n
2046
+ typeCategoryFilter: i,
2047
+ resultLimit: s
2863
2048
  });
2864
- return await ze({
2865
- promptText: r,
2049
+ return await le({
2050
+ promptText: a,
2866
2051
  inputVariables: o,
2867
- schema: c
2052
+ schema: l,
2053
+ config: r
2868
2054
  });
2869
2055
  }
2870
- const Fe = "searchGraphData", xa = i.object({
2871
- prompt: i.string().describe(
2056
+ const K = "searchGraphData", Pt = c.object({
2057
+ prompt: c.string().describe(
2872
2058
  "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."
2873
2059
  )
2874
- }), Ra = async ({ prompt: e }, t) => {
2875
- const { knowledgeGraph: r } = await G(t);
2876
- await S({ text: "Generating search query for the user inquiry" }, t);
2877
- const o = await Sa(e, r);
2878
- await S({ text: "Executing graph search with generated search query" }, t);
2879
- const a = await Yo({
2060
+ }), Et = async ({ prompt: e }, t) => {
2061
+ const { knowledgeGraph: r } = await N(t);
2062
+ await T({ text: "Generating search query for the user inquiry" }, t);
2063
+ const a = await $t(e, r, t);
2064
+ await T({ text: "Executing graph search with generated search query" }, t);
2065
+ const o = await lt({
2880
2066
  kg: r,
2881
- searchQuery: o.query,
2882
- typeCategoryFilter: o.typeCategoryFilter,
2883
- namedTypesFilter: o.typeFilters,
2884
- searchResultLimit: o.resultLimit,
2067
+ searchQuery: a.query,
2068
+ typeCategoryFilter: a.typeCategoryFilter,
2069
+ namedTypesFilter: a.typeFilters,
2070
+ searchResultLimit: a.resultLimit,
2885
2071
  requestOptions: {
2886
- signal: t?.signal,
2072
+ signal: F(t),
2887
2073
  timeout: t?.timeout
2888
2074
  }
2889
2075
  });
2890
- if (a.type !== "success")
2891
- throw new Error(
2892
- `Graph search failed with error: ${a.type === "error" ? a.errorMessage : "aborted"}`
2893
- );
2894
- for (const c of a.results)
2895
- D(
2896
- c,
2897
- (u) => Re(u)
2076
+ if (o.type !== "success")
2077
+ return {
2078
+ toolName: K,
2079
+ status: "error",
2080
+ errorMessage: o.errorMessage,
2081
+ error: "error" in o ? o.error : null
2082
+ };
2083
+ for (const n of o.results)
2084
+ C(
2085
+ n,
2086
+ (l) => ae(l)
2898
2087
  );
2899
- const n = 10, s = a.results.slice(0, n);
2088
+ const i = 10, s = o.results.slice(0, i);
2900
2089
  return {
2901
- toolName: Fe,
2090
+ toolName: K,
2902
2091
  status: "success",
2903
2092
  summary: `To answer the query, the following lucene query was generated and executed:
2904
- Query: ${o.query}
2905
- Type Category Filter: ${o.typeCategoryFilter}
2906
- Named Type Filters: ${o.typeFilters ? o.typeFilters.join(", ") : "None"}
2907
- Result Limit: ${o.resultLimit ?? "No limit"}
2093
+ Query: ${a.query}
2094
+ Type Category Filter: ${a.typeCategoryFilter}
2095
+ Named Type Filters: ${a.typeFilters ? a.typeFilters.join(", ") : "None"}
2096
+ Result Limit: ${a.resultLimit ?? "No limit"}
2908
2097
 
2909
- Search Results: ${a.results.length} result(s) found.
2098
+ Search Results: ${o.results.length} result(s) found.
2910
2099
 
2911
- ${a.results.length > n ? `Showing top ${n} results:
2100
+ ${o.results.length > i ? `Showing top ${i} results:
2912
2101
 
2913
- ` : ""}${s.map((c) => JSON.stringify(c)).join(`
2102
+ ` : ""}${s.map((n) => JSON.stringify(n)).join(`
2914
2103
  `)}`,
2915
2104
  details: {
2916
- generatedQuery: o,
2917
- searchResults: {
2918
- ...a
2919
- }
2105
+ generatedSearchQuery: a,
2106
+ searchResults: o.results
2920
2107
  }
2921
2108
  };
2922
- }, oi = f(Ra, {
2923
- name: Fe,
2924
- 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.",
2925
- schema: xa
2109
+ }, Ua = g(Et, {
2110
+ name: K,
2111
+ description: `
2112
+ 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.
2113
+ Example prompts:
2114
+ - "Find 'Bradley'"
2115
+ - "find the person john smith"
2116
+ - "find all people named smith"
2117
+ - "Find all references to 'delayed parts shipment'"
2118
+ - "Find all reports authored by someone with the title of 'Researcher'"
2119
+ - "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".
2120
+ - "Search for all john smiths and show their global ids`,
2121
+ schema: Pt
2926
2122
  });
2927
2123
  export {
2928
- zn as A,
2929
- qn as B,
2930
- Dn as C,
2931
- An as D,
2932
- Ln as E,
2933
- Pn as F,
2934
- ne as G,
2935
- Kn as H,
2936
- jn as I,
2937
- Gn as J,
2938
- On as K,
2939
- Mn as L,
2940
- Qn as M,
2941
- Tn as N,
2942
- Wn as O,
2943
- Vn as P,
2944
- Oo as Q,
2945
- N as R,
2946
- _n as S,
2947
- Un as T,
2948
- Yn as a,
2949
- ri as b,
2950
- Xn as c,
2951
- ei as d,
2952
- Zn as e,
2953
- we as f,
2954
- Y as g,
2955
- Jn as h,
2956
- G as i,
2957
- Hn as j,
2958
- vn as k,
2959
- Bn as l,
2960
- Sn as m,
2961
- xn as n,
2962
- Rn as o,
2963
- $n as p,
2964
- ti as q,
2965
- kn as r,
2966
- oi as s,
2967
- _t as t,
2968
- En as u,
2969
- Cn as v,
2970
- In as w,
2971
- Fn as x,
2972
- $ as y,
2973
- Nn as z
2124
+ Ga as A,
2125
+ xa as D,
2126
+ B as G,
2127
+ Fa as H,
2128
+ ja as L,
2129
+ va as N,
2130
+ Oa as a,
2131
+ Ba as b,
2132
+ Ka as c,
2133
+ Va as d,
2134
+ Ia as e,
2135
+ Qa as f,
2136
+ L as g,
2137
+ N as h,
2138
+ _a as i,
2139
+ Ca as j,
2140
+ Oe as k,
2141
+ $a as l,
2142
+ Pa as m,
2143
+ Ea as n,
2144
+ za as o,
2145
+ ka as p,
2146
+ Wa as q,
2147
+ Ra as r,
2148
+ Ua as s,
2149
+ Ie as t,
2150
+ Aa as u,
2151
+ qa as v,
2152
+ Na as w,
2153
+ Ma as x,
2154
+ Da as y,
2155
+ La as z
2974
2156
  };