@arcgis/ai-components 5.2.0-next.105 → 5.2.0-next.107

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 (304) hide show
  1. package/dist/agent-utils/BaseAgent.js +1 -1
  2. package/dist/agent-utils/FunctionAgent.js +1 -1
  3. package/dist/agent-utils/LLMAgent.js +42 -41
  4. package/dist/agent-utils/WorkflowAgent.js +1 -1
  5. package/dist/agent-utils/index.js +1 -1
  6. package/dist/agent-utils/middlewares/humanInTheLoop.js +1 -1
  7. package/dist/agent-utils/middlewares/middleware.js +1 -1
  8. package/dist/agent-utils/middlewares/trace.js +6 -6
  9. package/dist/agent-utils/middlewares/types.js +1 -1
  10. package/dist/agent-utils/tools/FunctionTool.js +1 -1
  11. package/dist/agent-utils/workflows/ConditionalWorkflow.js +1 -1
  12. package/dist/agent-utils/workflows/LoopWorkflow.js +1 -1
  13. package/dist/agent-utils/workflows/ParallelWorkflow.js +1 -1
  14. package/dist/agent-utils/workflows/RouterWorkflow.js +1 -1
  15. package/dist/agent-utils/workflows/SequentialWorkflow.js +1 -1
  16. package/dist/agent-utils/workflows/SwitchWorkflow.js +1 -1
  17. package/dist/agents/runtime/skill/createSkillAgent.d.ts +31 -0
  18. package/dist/agents/runtime/skill/createSkillAgent.js +260 -0
  19. package/dist/agents/runtime/skill/loadAgentSkills.d.ts +16 -0
  20. package/dist/agents/runtime/skill/types.d.ts +28 -0
  21. package/dist/agents/runtime/skill/types.js +2 -0
  22. package/dist/agents/tools/filter/clearFilters/adapter.js +1 -1
  23. package/dist/agents/tools/filter/resetMap/adapter.js +1 -1
  24. package/dist/agents/tools/filter/setFeatureEffect/adapter.js +21 -20
  25. package/dist/agents/tools/help/listFields/adapter.js +1 -1
  26. package/dist/agents/tools/navigation/goToAddress/adapter.js +1 -1
  27. package/dist/agents/tools/navigation/goToBookmark/adapter.js +1 -1
  28. package/dist/agents/tools/navigation/goToFeatures/adapter.js +1 -1
  29. package/dist/agents/tools/navigation/goToFullExtent/adapter.js +1 -1
  30. package/dist/agents/tools/navigation/goToHomeExtent/adapter.js +1 -1
  31. package/dist/agents/tools/navigation/goToLayer/adapter.js +1 -1
  32. package/dist/agents/tools/navigation/goToScale/adapter.js +1 -1
  33. package/dist/agents/tools/navigation/goToViewpoint/adapter.js +1 -1
  34. package/dist/agents/tools/navigation/goToZoom/adapter.js +1 -1
  35. package/dist/agents/tools/query/getAttribute/adapter.js +1 -1
  36. package/dist/agents/tools/query/getStatistics/adapter.js +5 -4
  37. package/dist/agents/tools/query/getTopFeatures/adapter.js +5 -4
  38. package/dist/agents/tools/query/queryFeatures/adapter.js +5 -4
  39. package/dist/agents/tools/search/findRelevantFields/adapter.js +1 -1
  40. package/dist/agents/tools/search/findRelevantLayers/adapter.js +1 -1
  41. package/dist/agents/tools/shared/resolveToolArtifact.d.ts +22 -0
  42. package/dist/agents/tools/shared/resolveToolArtifact.js +20 -0
  43. package/dist/agents/tools/shared/types.d.ts +22 -0
  44. package/dist/agents/tools/shared/types.js +6 -0
  45. package/dist/cdn/25MBI4PD.js +2 -0
  46. package/dist/cdn/{LLUGJKAQ.js → 275FFTBE.js} +2 -2
  47. package/dist/cdn/2F4TPWZQ.js +2 -0
  48. package/dist/cdn/{HKOGIZDQ.js → 2LVYAXHG.js} +19 -19
  49. package/dist/cdn/{5MK44FNO.js → 2NRCE53B.js} +2 -2
  50. package/dist/cdn/{R2PQVY4O.js → 2WXXSZP5.js} +2 -2
  51. package/dist/cdn/{APFZY4PI.js → 3KNLFIM3.js} +2 -2
  52. package/dist/cdn/{NNXISHCA.js → 3PPXAIRE.js} +3 -3
  53. package/dist/cdn/{FUF3NAU7.js → 45BDE3MG.js} +2 -2
  54. package/dist/cdn/{VOKXKU7M.js → 477I66FH.js} +10 -10
  55. package/dist/cdn/4CFCV47G.js +2 -0
  56. package/dist/cdn/{TPULIO6I.js → 4IWDBEMN.js} +2 -2
  57. package/dist/cdn/{G2EGT3CF.js → 4OI4QEV7.js} +2 -2
  58. package/dist/cdn/{2W7LK4HA.js → 4UAREC76.js} +2 -2
  59. package/dist/cdn/{HHFNQR6Z.js → 4VBOTWC3.js} +2 -2
  60. package/dist/cdn/{RLEHNAIA.js → 4YOG5F3W.js} +1 -1
  61. package/dist/cdn/5X23DDDZ.js +2 -0
  62. package/dist/cdn/65ZACLYB.js +2 -0
  63. package/dist/cdn/{HDACNIZF.js → 6KWGSXIN.js} +2 -2
  64. package/dist/cdn/{O4NVW75A.js → 6MRTZ4OM.js} +2 -2
  65. package/dist/cdn/{DKZYPPJV.js → 77NAJM5H.js} +2 -2
  66. package/dist/cdn/{NEV6OZN3.js → 7DOYUO7L.js} +2 -2
  67. package/dist/cdn/{EYOWRGDP.js → 7JJX6VGI.js} +2 -2
  68. package/dist/cdn/{ONQ6JSBJ.js → A6LBMS7A.js} +1 -1
  69. package/dist/cdn/{ZDV4K4WG.js → AP3KPOHN.js} +2 -2
  70. package/dist/cdn/AUCKEB52.js +2 -0
  71. package/dist/cdn/B3HXSEBN.js +2 -0
  72. package/dist/cdn/{6ECRQVHY.js → BAKJLCYO.js} +2 -2
  73. package/dist/cdn/BJMGT6GV.js +19 -0
  74. package/dist/cdn/{HAEFC2SJ.js → BTOBEN7Q.js} +2 -2
  75. package/dist/cdn/BTTCBEPW.js +2 -0
  76. package/dist/cdn/{UZLQALHY.js → BVUCNXC5.js} +1 -1
  77. package/dist/cdn/{RFVZ7KCG.js → CAOMMQSY.js} +1 -1
  78. package/dist/cdn/{P4GFYBBO.js → CBYBFBD3.js} +2 -2
  79. package/dist/cdn/{VLLZ2FFU.js → CKUUYQLO.js} +2 -2
  80. package/dist/cdn/{MWYBF3F3.js → CSE6BHOJ.js} +2 -2
  81. package/dist/cdn/{7BCQMK6D.js → CX2HJ67C.js} +2 -2
  82. package/dist/cdn/EELMDCPV.js +2 -0
  83. package/dist/cdn/{7VUSIGEM.js → EGRRZTF6.js} +2 -2
  84. package/dist/cdn/EHYDAEGL.js +2 -0
  85. package/dist/cdn/{C4JT4S5E.js → EK3PM4L5.js} +2 -2
  86. package/dist/cdn/{PYGX4HN7.js → ENAEE4UU.js} +2 -2
  87. package/dist/cdn/EXMEB4X2.js +2 -0
  88. package/dist/cdn/{FG647IP6.js → EYGZJKVD.js} +2 -2
  89. package/dist/cdn/{4RDNI22D.js → FK2CVSXW.js} +5 -5
  90. package/dist/cdn/FLUI6GCU.js +2 -0
  91. package/dist/cdn/{ZU2FHVNK.js → FPH52WOH.js} +2 -2
  92. package/dist/cdn/FRYS2PZJ.js +2 -0
  93. package/dist/cdn/FSLQCZRN.js +2 -0
  94. package/dist/cdn/{PQ2DPOFM.js → FTTLFIBV.js} +2 -2
  95. package/dist/cdn/{NZSOJ726.js → FV6FHLYW.js} +2 -2
  96. package/dist/cdn/{WGO5SER7.js → G24MNC7D.js} +2 -2
  97. package/dist/cdn/{6OOZSZRJ.js → GN56DOYL.js} +2 -2
  98. package/dist/cdn/{ROQGPAR5.js → HIJGY4GU.js} +2 -2
  99. package/dist/cdn/{BL273EGZ.js → HMMYCSOK.js} +2 -2
  100. package/dist/cdn/{OE3GW5LE.js → HNTSDY3J.js} +2 -2
  101. package/dist/cdn/HQOK6DDH.js +2 -0
  102. package/dist/cdn/{K2R6XVK3.js → HV7MVIQV.js} +2 -2
  103. package/dist/cdn/I3SUE2TR.js +2 -0
  104. package/dist/cdn/{VAXH6RUQ.js → I72ST4JR.js} +2 -2
  105. package/dist/cdn/{FYZATVB3.js → IHUWQOMK.js} +2 -2
  106. package/dist/cdn/{J6A4AS7E.js → JMXXRRKQ.js} +2 -2
  107. package/dist/cdn/{5HBAJ57P.js → JPXEMNPR.js} +2 -2
  108. package/dist/cdn/{UHEYPSOR.js → JYNHWJUZ.js} +2 -2
  109. package/dist/cdn/KAX4A7SF.js +2 -0
  110. package/dist/cdn/{5ZFUGNRN.js → KBSXHSBX.js} +2 -2
  111. package/dist/cdn/{CCC6LBMY.js → KKCLHXHG.js} +1 -1
  112. package/dist/cdn/L2HLFWCV.js +72 -0
  113. package/dist/cdn/{LK7ZIQW6.js → L3BTURBA.js} +2 -2
  114. package/dist/cdn/{IBZ2NEAO.js → LBTGOMCT.js} +2 -2
  115. package/dist/cdn/{34O57OGV.js → LLY5A2E2.js} +1 -1
  116. package/dist/cdn/{Z5W4V7RC.js → LXIKAXUT.js} +2 -2
  117. package/dist/cdn/{AI6DYOKR.js → M2U456J5.js} +3 -3
  118. package/dist/cdn/{KWD2ECTM.js → M3KKORBG.js} +2 -2
  119. package/dist/cdn/M5B6X46F.js +2 -0
  120. package/dist/cdn/{SDWWUWAF.js → MZUDIQQH.js} +2 -2
  121. package/dist/cdn/{CEKOEHB3.js → NNPA3NLK.js} +2 -2
  122. package/dist/cdn/{MXTXJKFE.js → NPWLYHMU.js} +2 -2
  123. package/dist/cdn/NV7CL4S3.js +2 -0
  124. package/dist/cdn/{3UEKINYC.js → OALQBAZR.js} +2 -2
  125. package/dist/cdn/{RHYNE5OE.js → OF3TAARW.js} +1 -1
  126. package/dist/cdn/{F5NIRETW.js → P53TDER7.js} +2 -2
  127. package/dist/cdn/{SXM4NUT5.js → PJLGCS33.js} +2 -2
  128. package/dist/cdn/{BXQ4I5HB.js → PJPP6LOS.js} +3 -3
  129. package/dist/cdn/PUZ6RAFQ.js +2 -0
  130. package/dist/cdn/{IHP25JWI.js → QAX6UF4L.js} +2 -2
  131. package/dist/cdn/{JEBRN3EU.js → QTEPFTAU.js} +2 -2
  132. package/dist/cdn/ROS22KOA.js +2 -0
  133. package/dist/cdn/RPOFBIE7.js +2 -0
  134. package/dist/cdn/{COH3QXWG.js → S5GFNIHC.js} +3 -3
  135. package/dist/cdn/SBNNJ5WA.js +2 -0
  136. package/dist/cdn/SI22EJLC.js +2 -0
  137. package/dist/cdn/{5WYRJMBW.js → SJMAKF4P.js} +2 -2
  138. package/dist/cdn/{6P44KOKX.js → SKCUGZ7G.js} +2 -2
  139. package/dist/cdn/{V6HOUZPZ.js → SNG3WODY.js} +2 -2
  140. package/dist/cdn/{22KHSDJI.js → STOGCXJH.js} +2 -2
  141. package/dist/cdn/SUC2MIGE.js +2 -0
  142. package/dist/cdn/SXYKNDOF.js +2 -0
  143. package/dist/cdn/SZ2L5556.js +2 -0
  144. package/dist/cdn/{Y7XD7ZRD.js → T6W6F4TF.js} +2 -2
  145. package/dist/cdn/{WKTQVBFJ.js → TFAJNKBC.js} +2 -2
  146. package/dist/cdn/{R74ZHFA6.js → TLPZELG3.js} +1 -1
  147. package/dist/cdn/{2O4DON37.js → TNLFUXIB.js} +2 -2
  148. package/dist/cdn/{YEZ3AMNX.js → TXZQZR3I.js} +2 -2
  149. package/dist/cdn/UGIHS7OA.js +2 -0
  150. package/dist/cdn/{UDRKUVZP.js → UX457AQR.js} +2 -2
  151. package/dist/cdn/{ICBIUFK7.js → V266DJ5V.js} +2 -2
  152. package/dist/cdn/{FDOMMK2M.js → V4PJMCJZ.js} +1 -1
  153. package/dist/cdn/{7VAQUCBU.js → V52GSTOC.js} +2 -2
  154. package/dist/cdn/VGLBH473.js +2 -0
  155. package/dist/cdn/{WSWB3B7B.js → VHNTHPH7.js} +2 -2
  156. package/dist/cdn/{KITIP6J2.js → VK6CCPTG.js} +2 -2
  157. package/dist/cdn/{AOVJ34QE.js → VLPELJUS.js} +2 -2
  158. package/dist/cdn/VT5EWFH7.js +2 -0
  159. package/dist/cdn/{J6SZIQJA.js → VXLKTQ36.js} +2 -2
  160. package/dist/cdn/W54XYT2A.js +2 -0
  161. package/dist/cdn/{7SRLZQVC.js → X42ACC66.js} +2 -2
  162. package/dist/cdn/{CP5BVGJU.js → XNUWVZN7.js} +2 -2
  163. package/dist/cdn/XOTPSCNF.js +2 -0
  164. package/dist/cdn/XRVGYRXL.js +14 -0
  165. package/dist/cdn/{ANRQWYU2.js → XV7RMYLR.js} +2 -2
  166. package/dist/cdn/{5K5ZY267.js → XVJFPZTW.js} +2 -2
  167. package/dist/cdn/XZF7Y6B2.js +2 -0
  168. package/dist/cdn/Y4ZOB6UH.js +2 -0
  169. package/dist/cdn/Y6CV2NZR.js +2 -0
  170. package/dist/cdn/YMJKT5OK.js +2 -0
  171. package/dist/cdn/{655YIKL3.js → YOW3YKWR.js} +3 -3
  172. package/dist/cdn/{OKVLGJAG.js → ZA7ZU2F7.js} +2 -2
  173. package/dist/cdn/{EWLXNGKH.js → ZJWR4W2S.js} +16 -16
  174. package/dist/cdn/ZWIKFBOU.js +2 -0
  175. package/dist/cdn/ZY3JQCZQ.js +179 -0
  176. package/dist/cdn/agent-utils/index.js +2 -2
  177. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +2 -2
  178. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -2
  179. package/dist/cdn/agent-utils/middlewares/trace.js +2 -2
  180. package/dist/cdn/index.js +2 -2
  181. package/dist/chunks/BaseWorkflow.js +1 -1
  182. package/dist/chunks/SKILL.js +5 -0
  183. package/dist/chunks/SKILL2.js +5 -0
  184. package/dist/chunks/SKILL3.js +22 -0
  185. package/dist/chunks/SKILL4.js +5 -0
  186. package/dist/chunks/adapter.js +138 -141
  187. package/dist/chunks/aiFactory.js +94 -0
  188. package/dist/chunks/arcgisKnowledgeGraph.js +15 -14
  189. package/dist/chunks/arcgisToolRegistry.js +88 -0
  190. package/dist/chunks/arcgis_knowledge_current_lc_context.js +1 -1
  191. package/dist/chunks/arcgis_knowledge_current_map_context.js +1 -1
  192. package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +1 -1
  193. package/dist/chunks/arcgis_knowledge_lucene_generation_prompt.js +1 -1
  194. package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +1 -1
  195. package/dist/chunks/arcgis_knowledge_tool_prompt.js +1 -1
  196. package/dist/chunks/baseAgentState.js +3 -3
  197. package/dist/chunks/converterUtils.js +1 -1
  198. package/dist/chunks/dataExplorationAgent.js +19 -0
  199. package/dist/chunks/data_explore_filter_prompt.js +1 -1
  200. package/dist/chunks/data_explore_query_prompt.js +1 -1
  201. package/dist/chunks/embeddings.worker.js +1 -1
  202. package/dist/chunks/fetchAgentContext.js +1 -1
  203. package/dist/chunks/fetchService.js +1 -1
  204. package/dist/chunks/fieldStatistics.js +1 -1
  205. package/dist/chunks/field_descriptions_prompt.js +1 -1
  206. package/dist/chunks/formatFeatureAttributes.js +1 -1
  207. package/dist/chunks/generateLayerDescriptions.js +182 -269
  208. package/dist/chunks/graph.js +1 -1
  209. package/dist/chunks/helpAgent.js +34 -0
  210. package/dist/chunks/help_prompt.js +1 -1
  211. package/dist/chunks/index.js +1 -1
  212. package/dist/chunks/intent_prompt.js +1 -1
  213. package/dist/chunks/layerStylingGraph.js +92 -77
  214. package/dist/chunks/layer_descriptions_prompt.js +1 -1
  215. package/dist/chunks/layer_styling_prompt.js +1 -1
  216. package/dist/chunks/mergeWhereClauses.js +1 -1
  217. package/dist/chunks/navigationAgent.js +27 -0
  218. package/dist/chunks/navigation_intent_prompt.js +1 -1
  219. package/dist/chunks/navigation_tool_prompt.js +1 -1
  220. package/dist/chunks/orchestrator.js +14 -13
  221. package/dist/chunks/requireAgentServices.js +11 -0
  222. package/dist/chunks/resolvePointGeometryFilter.js +12 -12
  223. package/dist/chunks/runtime.js +2 -2
  224. package/dist/chunks/slottableRequestUtils.js +1 -1
  225. package/dist/chunks/state.js +1 -1
  226. package/dist/chunks/summarize_query_response_prompt.js +1 -1
  227. package/dist/chunks/useT9n.js +1 -1
  228. package/dist/chunks/utils.js +1 -1
  229. package/dist/chunks/utils2.js +1 -1
  230. package/dist/chunks/utils3.js +1 -1
  231. package/dist/components/arcgis-assistant/customElement.js +1 -1
  232. package/dist/components/arcgis-assistant-agent/customElement.js +130 -212
  233. package/dist/components/arcgis-assistant-chat/customElement.js +1 -1
  234. package/dist/components/arcgis-assistant-chat-entry/customElement.js +1 -1
  235. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +18 -7
  236. package/dist/components/arcgis-assistant-help-agent/customElement.js +4 -2
  237. package/dist/components/arcgis-assistant-interrupt/customElement.js +1 -1
  238. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +1 -1
  239. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +2 -1
  240. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +2 -1
  241. package/dist/components/arcgis-assistant-message/customElement.js +1 -1
  242. package/dist/components/arcgis-assistant-message-block/customElement.js +1 -1
  243. package/dist/components/arcgis-assistant-message-feedback/customElement.js +1 -1
  244. package/dist/components/arcgis-assistant-message-footer/customElement.js +1 -1
  245. package/dist/components/arcgis-assistant-message-loading/customElement.js +1 -1
  246. package/dist/components/arcgis-assistant-message-log/customElement.js +1 -1
  247. package/dist/components/arcgis-assistant-message-read-aloud/customElement.js +1 -1
  248. package/dist/components/arcgis-assistant-message-text/customElement.js +1 -1
  249. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +19 -8
  250. package/dist/components/arcgis-assistant-speech-input/customElement.js +1 -1
  251. package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +1 -1
  252. package/dist/components/arcgis-assistant-user-message/customElement.js +1 -1
  253. package/dist/docs/api.json +1 -1
  254. package/dist/docs/docs.json +1 -1
  255. package/dist/docs/web-types.json +1 -1
  256. package/dist/index.js +1 -1
  257. package/dist/loader.js +1 -1
  258. package/dist/orchestrator/models/types.d.ts +1 -0
  259. package/dist/orchestrator/providers/arcgis/aiFactory.d.ts +15 -0
  260. package/dist/orchestrator/registry/agentRegistry.d.ts +33 -0
  261. package/dist/orchestrator/types/types.d.ts +17 -0
  262. package/dist/utils/index.d.ts +13 -3
  263. package/dist/utils/index.js +707 -83
  264. package/package.json +9 -5
  265. package/dist/cdn/2EY3BQQX.js +0 -2
  266. package/dist/cdn/2NDBI2VA.js +0 -156
  267. package/dist/cdn/434TAA3J.js +0 -2
  268. package/dist/cdn/4OGR5QKS.js +0 -2
  269. package/dist/cdn/5X7EG7D2.js +0 -2
  270. package/dist/cdn/6FCU2KJP.js +0 -2
  271. package/dist/cdn/7BJ4JKLG.js +0 -2
  272. package/dist/cdn/7HS5KX3J.js +0 -2
  273. package/dist/cdn/7UUYJTKT.js +0 -2
  274. package/dist/cdn/7V6OSTFC.js +0 -2
  275. package/dist/cdn/7VYYQ7BT.js +0 -2
  276. package/dist/cdn/ACJTJLZN.js +0 -2
  277. package/dist/cdn/AKD5UOVX.js +0 -2
  278. package/dist/cdn/C7LGDNB3.js +0 -14
  279. package/dist/cdn/CGJINV7H.js +0 -2
  280. package/dist/cdn/CJMUJXPL.js +0 -2
  281. package/dist/cdn/D2SS763Z.js +0 -2
  282. package/dist/cdn/FJO4KNOZ.js +0 -2
  283. package/dist/cdn/G3SF6U2U.js +0 -2
  284. package/dist/cdn/G6CR7JVM.js +0 -22
  285. package/dist/cdn/GL7BPKBN.js +0 -2
  286. package/dist/cdn/JO5ETMPS.js +0 -2
  287. package/dist/cdn/NYJYRCGA.js +0 -2
  288. package/dist/cdn/PUHRBGKB.js +0 -2
  289. package/dist/cdn/Q57QWN5W.js +0 -2
  290. package/dist/cdn/QUKNPVAF.js +0 -2
  291. package/dist/cdn/RBE55SWR.js +0 -2
  292. package/dist/cdn/SWH6ZHD4.js +0 -18
  293. package/dist/cdn/SZ2QSSB3.js +0 -2
  294. package/dist/cdn/T4RIGOXB.js +0 -2
  295. package/dist/cdn/VXFQANGJ.js +0 -2
  296. package/dist/cdn/W4JQDITQ.js +0 -36
  297. package/dist/cdn/XX6GHMNR.js +0 -2
  298. package/dist/cdn/YLVJA4ZE.js +0 -2
  299. package/dist/cdn/ZOEMBHRF.js +0 -2
  300. package/dist/cdn/ZRVZMPFN.js +0 -2
  301. package/dist/chunks/dataExplorationGraph.js +0 -254
  302. package/dist/chunks/helpGraph.js +0 -133
  303. package/dist/chunks/navigationGraph.js +0 -290
  304. package/dist/chunks/toolCallResponse.js +0 -33
@@ -1,5 +1,5 @@
1
- /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{$ as Na,Dd as $a,d as dt,e as Ca,j as Gn,k as Oa,m as xc,n as Ec,o as Ra,u as $e,w as Sc,x as Tc}from"./MWYBF3F3.js";import{a as Qt,b as Ip,c as Hn}from"./UZLQALHY.js";var ld=Qt((JE,Os)=>{"use strict";var $m=Object.prototype.hasOwnProperty,ke="~";function mn(){}Object.create&&(mn.prototype=Object.create(null),new mn().__proto__||(ke=!1));function Pm(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function cd(e,t,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var a=new Pm(r,n||e,i),s=ke?ke+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],a]:e._events[s].push(a):(e._events[s]=a,e._eventsCount++),e}function bi(e,t){--e._eventsCount===0?e._events=new mn:delete e._events[t]}function xe(){this._events=new mn,this._eventsCount=0}xe.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)$m.call(r,n)&&t.push(ke?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};xe.prototype.listeners=function(t){var r=ke?ke+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,s=new Array(a);i<a;i++)s[i]=n[i].fn;return s};xe.prototype.listenerCount=function(t){var r=ke?ke+t:t,n=this._events[r];return n?n.fn?1:n.length:0};xe.prototype.emit=function(t,r,n,i,a,s){var o=ke?ke+t:t;if(!this._events[o])return!1;var c=this._events[o],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,i),!0;case 5:return c.fn.call(c.context,r,n,i,a),!0;case 6:return c.fn.call(c.context,r,n,i,a,s),!0}for(d=1,u=new Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(t,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,r);break;case 3:c[d].fn.call(c[d].context,r,n);break;case 4:c[d].fn.call(c[d].context,r,n,i);break;default:if(!u)for(p=1,u=new Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0};xe.prototype.on=function(t,r,n){return cd(this,t,r,n,!1)};xe.prototype.once=function(t,r,n){return cd(this,t,r,n,!0)};xe.prototype.removeListener=function(t,r,n,i){var a=ke?ke+t:t;if(!this._events[a])return this;if(!r)return bi(this,a),this;var s=this._events[a];if(s.fn)s.fn===r&&(!i||s.once)&&(!n||s.context===n)&&bi(this,a);else{for(var o=0,c=[],l=s.length;o<l;o++)(s[o].fn!==r||i&&!s[o].once||n&&s[o].context!==n)&&c.push(s[o]);c.length?this._events[a]=c.length===1?c[0]:c:bi(this,a)}return this};xe.prototype.removeAllListeners=function(t){var r;return t?(r=ke?ke+t:t,this._events[r]&&bi(this,r)):(this._events=new mn,this._eventsCount=0),this};xe.prototype.off=xe.prototype.removeListener;xe.prototype.addListener=xe.prototype.on;xe.prefixed=ke;xe.EventEmitter=xe;typeof Os<"u"&&(Os.exports=xe)});var dd=Qt((KE,ud)=>{"use strict";ud.exports=(e,t)=>(t=t||(()=>{}),e.then(r=>new Promise(n=>{n(t())}).then(()=>r),r=>new Promise(n=>{n(t())}).then(()=>{throw r})))});var pd=Qt((YE,xi)=>{"use strict";var Mm=dd(),vi=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},fd=(e,t,r)=>new Promise((n,i)=>{if(typeof t!="number"||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0){n(e);return}let a=setTimeout(()=>{if(typeof r=="function"){try{n(r())}catch(c){i(c)}return}let s=typeof r=="string"?r:`Promise timed out after ${t} milliseconds`,o=r instanceof Error?r:new vi(s);typeof e.cancel=="function"&&e.cancel(),i(o)},t);Mm(e.then(n,i),()=>{clearTimeout(a)})});xi.exports=fd;xi.exports.default=fd;xi.exports.TimeoutError=vi});var hd=Qt(Rs=>{"use strict";Object.defineProperty(Rs,"__esModule",{value:!0});function jm(e,t,r){let n=0,i=e.length;for(;i>0;){let a=i/2|0,s=n+a;r(e[s],t)<=0?(n=++s,i-=a+1):i=a}return n}Rs.default=jm});var md=Qt($s=>{"use strict";Object.defineProperty($s,"__esModule",{value:!0});var Lm=hd(),Ns=class{constructor(){this._queue=[]}enqueue(t,r){r=Object.assign({priority:0},r);let n={priority:r.priority,run:t};if(this.size&&this._queue[this.size-1].priority>=r.priority){this._queue.push(n);return}let i=Lm.default(this._queue,n,(a,s)=>s.priority-a.priority);this._queue.splice(i,0,n)}dequeue(){let t=this._queue.shift();return t?.run}filter(t){return this._queue.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this._queue.length}};$s.default=Ns});var Si=Qt(Ms=>{"use strict";Object.defineProperty(Ms,"__esModule",{value:!0});var Dm=ld(),gd=pd(),Um=md(),Ei=()=>{},zm=new gd.TimeoutError,Ps=class extends Dm{constructor(t){var r,n,i,a;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=Ei,this._resolveIdle=Ei,t=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:Um.default},t),!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(r=t.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(a=(i=t.interval)===null||i===void 0?void 0:i.toString())!==null&&a!==void 0?a:""}\` (${typeof t.interval})`);this._carryoverConcurrencyCount=t.carryoverConcurrencyCount,this._isIntervalIgnored=t.intervalCap===1/0||t.interval===0,this._intervalCap=t.intervalCap,this._interval=t.interval,this._queue=new t.queueClass,this._queueClass=t.queueClass,this.concurrency=t.concurrency,this._timeout=t.timeout,this._throwOnTimeout=t.throwOnTimeout===!0,this._isPaused=t.autoStart===!1}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount<this._intervalCap}get _doesConcurrentAllowAnother(){return this._pendingCount<this._concurrency}_next(){this._pendingCount--,this._tryToStartAnother(),this.emit("next")}_resolvePromises(){this._resolveEmpty(),this._resolveEmpty=Ei,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=Ei,this.emit("idle"))}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}_isIntervalPaused(){let t=Date.now();if(this._intervalId===void 0){let r=this._intervalEnd-t;if(r<0)this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0;else return this._timeoutId===void 0&&(this._timeoutId=setTimeout(()=>{this._onResumeInterval()},r)),!0}return!1}_tryToStartAnother(){if(this._queue.size===0)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){let t=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){let r=this._queue.dequeue();return r?(this.emit("active"),r(),t&&this._initializeIntervalIfNeeded(),!0):!1}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||this._intervalId!==void 0||(this._intervalId=setInterval(()=>{this._onInterval()},this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){this._intervalCount===0&&this._pendingCount===0&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this._concurrency=t,this._processQueue()}async add(t,r={}){return new Promise((n,i)=>{let a=async()=>{this._pendingCount++,this._intervalCount++;try{let s=this._timeout===void 0&&r.timeout===void 0?t():gd.default(Promise.resolve(t()),r.timeout===void 0?this._timeout:r.timeout,()=>{(r.throwOnTimeout===void 0?this._throwOnTimeout:r.throwOnTimeout)&&i(zm)});n(await s)}catch(s){i(s)}this._next()};this._queue.enqueue(a,r),this._tryToStartAnother(),this.emit("add")})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(this._queue.size!==0)return new Promise(t=>{let r=this._resolveEmpty;this._resolveEmpty=()=>{r(),t()}})}async onIdle(){if(!(this._pendingCount===0&&this._queue.size===0))return new Promise(t=>{let r=this._resolveIdle;this._resolveIdle=()=>{r(),t()}})}get size(){return this._queue.size}sizeBy(t){return this._queue.filter(t).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(t){this._timeout=t}};Ms.default=Ps});var _p=Qt(ga=>{"use strict";ga.byteLength=xw;ga.toByteArray=Sw;ga.fromByteArray=Iw;var St=[],Qe=[],vw=typeof Uint8Array<"u"?Uint8Array:Array,cc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Rr=0,mp=cc.length;Rr<mp;++Rr)St[Rr]=cc[Rr],Qe[cc.charCodeAt(Rr)]=Rr;var Rr,mp;Qe[45]=62;Qe[95]=63;function gp(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function xw(e){var t=gp(e),r=t[0],n=t[1];return(r+n)*3/4-n}function Ew(e,t,r){return(t+r)*3/4-r}function Sw(e){var t,r=gp(e),n=r[0],i=r[1],a=new vw(Ew(e,n,i)),s=0,o=i>0?n-4:n,c;for(c=0;c<o;c+=4)t=Qe[e.charCodeAt(c)]<<18|Qe[e.charCodeAt(c+1)]<<12|Qe[e.charCodeAt(c+2)]<<6|Qe[e.charCodeAt(c+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=t&255;return i===2&&(t=Qe[e.charCodeAt(c)]<<2|Qe[e.charCodeAt(c+1)]>>4,a[s++]=t&255),i===1&&(t=Qe[e.charCodeAt(c)]<<10|Qe[e.charCodeAt(c+1)]<<4|Qe[e.charCodeAt(c+2)]>>2,a[s++]=t>>8&255,a[s++]=t&255),a}function Tw(e){return St[e>>18&63]+St[e>>12&63]+St[e>>6&63]+St[e&63]}function Aw(e,t,r){for(var n,i=[],a=t;a<r;a+=3)n=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(Tw(n));return i.join("")}function Iw(e){for(var t,r=e.length,n=r%3,i=[],a=16383,s=0,o=r-n;s<o;s+=a)i.push(Aw(e,s,s+a>o?o:s+a));return n===1?(t=e[r-1],i.push(St[t>>2]+St[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(St[t>>10]+St[t>>4&63]+St[t<<2&63]+"=")),i.join("")}});var Ac=Object.defineProperty,L=(e,t)=>{let r={};for(var n in e)Ac(r,n,{get:e[n],enumerable:!0});return t||Ac(r,Symbol.toStringTag,{value:"Module"}),r};var kp=/([A-Z]+)([A-Z][a-z0-9]+)/g,Cp=/([a-z0-9])([A-Z])/g,Ic=/[-_\s]+/g;function Op(e){return e.replace(kp,"$1_$2").replace(Cp,"$1_$2").replace(Ic,"_").toLowerCase()}function Rp(e){let t=e.trim();return/[-_\s]/.test(t)?t.replace(Ic,"_").toLowerCase().replace(/_+([a-z0-9])/g,(r,n)=>n.toUpperCase()):t}function kc(e,t){return t?.[e]||Op(e)}function Zw(e,t){return t?.[e]||Rp(e)}function Cc(e,t,r){let n={};for(let i in e)Object.hasOwn(e,i)&&(n[t(i,r)]=e[i]);return n}var Rc="__lc_escaped__";function Np(e){return"lc"in e||Object.keys(e).length===1&&"__lc_escaped__"in e}function $p(e){return{[Rc]:e}}function Pp(e){return Object.keys(e).length===1&&"__lc_escaped__"in e}function Mp(e){return e!==null&&typeof e=="object"&&"lc_serializable"in e&&typeof e.toJSON=="function"}function jp(e){let t;return e!==null&&typeof e=="object"?"lc_id"in e&&Array.isArray(e.lc_id)?t=e.lc_id:t=[e.constructor?.name??"Object"]:t=[typeof e],{lc:1,type:"not_implemented",id:t}}function Vn(e,t=new WeakSet){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){if(t.has(e))return jp(e);if(Mp(e))return e;t.add(e);let r=e;if(Np(r))return t.delete(e),$p(r);let n={};for(let[i,a]of Object.entries(r))n[i]=Vn(a,t);return t.delete(e),n}return Array.isArray(e)?e.map(r=>Vn(r,t)):e}function Oc(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let t=e;if(Pp(t))return t[Rc];let r={};for(let[n,i]of Object.entries(t))r[n]=Oc(i);return r}return Array.isArray(e)?e.map(t=>Oc(t)):e}var Xw=L({Serializable:()=>ft,get_lc_unique_name:()=>Zn});function Nc(e){return Array.isArray(e)?[...e]:{...e}}function Lp(e,t){let r=Nc(e);for(let[n,i]of Object.entries(t)){let[a,...s]=n.split(".").reverse(),o=r;for(let c of s.reverse()){if(o[c]===void 0)break;o[c]=Nc(o[c]),o=o[c]}o[a]!==void 0&&(o[a]={lc:1,type:"secret",id:[i]})}return r}function Zn(e){let t=Object.getPrototypeOf(e);return typeof e.lc_name=="function"&&(typeof t.lc_name!="function"||e.lc_name()!==t.lc_name())?e.lc_name():e.name}var ft=class $c{lc_serializable=!1;lc_kwargs;static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,Zn(this.constructor)]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}constructor(t,...r){this.lc_serializable_keys!==void 0?this.lc_kwargs=Object.fromEntries(Object.entries(t||{}).filter(([n])=>this.lc_serializable_keys?.includes(n))):this.lc_kwargs=t??{}}toJSON(){if(!this.lc_serializable)return this.toJSONNotImplemented();if(this.lc_kwargs instanceof $c||typeof this.lc_kwargs!="object"||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();let t={},r={},n=Object.keys(this.lc_kwargs).reduce((o,c)=>(o[c]=c in this?this[c]:this.lc_kwargs[c],o),{});for(let o=Object.getPrototypeOf(this);o;o=Object.getPrototypeOf(o))Object.assign(t,Reflect.get(o,"lc_aliases",this)),Object.assign(r,Reflect.get(o,"lc_secrets",this)),Object.assign(n,Reflect.get(o,"lc_attributes",this));Object.keys(r).forEach(o=>{let c=this,l=n,[u,...d]=o.split(".").reverse();for(let f of d.reverse()){if(!(f in c)||c[f]===void 0)return;(!(f in l)||l[f]===void 0)&&(typeof c[f]=="object"&&c[f]!=null?l[f]={}:Array.isArray(c[f])&&(l[f]=[])),c=c[f],l=l[f]}u in c&&c[u]!==void 0&&(l[u]=l[u]||c[u])});let i={},a=new WeakSet;a.add(this);for(let[o,c]of Object.entries(n))i[o]=Vn(c,a);let s=Cc(Object.keys(r).length?Lp(i,r):i,kc,t);return{lc:1,type:"constructor",id:this.lc_id,kwargs:s}}toJSONNotImplemented(){return{lc:1,type:"not_implemented",id:this.lc_id}}};function Nt(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"&&"source_type"in e&&(e.source_type==="url"||e.source_type==="base64"||e.source_type==="text"||e.source_type==="id")}function Pc(e){return Nt(e)&&e.source_type==="url"&&"url"in e&&typeof e.url=="string"}function Mc(e){return Nt(e)&&e.source_type==="base64"&&"data"in e&&typeof e.data=="string"}function eb(e){return Nt(e)&&e.source_type==="text"&&"text"in e&&typeof e.text=="string"}function jc(e){return Nt(e)&&e.source_type==="id"&&"id"in e&&typeof e.id=="string"}function tb(e){if(Nt(e)){if(e.source_type==="url")return{type:"image_url",image_url:{url:e.url}};if(e.source_type==="base64"){if(!e.mime_type)throw new Error("mime_type key is required for base64 data.");return{type:"image_url",image_url:{url:`data:${e.mime_type};base64,${e.data}`}}}}throw new Error("Unsupported source type. Only 'url' and 'base64' are supported.")}function rb(e){let t=e.split(";")[0].split("/");if(t.length!==2)throw new Error(`Invalid mime type: "${e}" - does not match type/subtype format.`);let r=t[0].trim(),n=t[1].trim();if(r===""||n==="")throw new Error(`Invalid mime type: "${e}" - type or subtype is empty.`);let i={};for(let a of e.split(";").slice(1)){let s=a.split("=");if(s.length!==2)throw new Error(`Invalid parameter syntax in mime type: "${e}".`);let o=s[0].trim(),c=s[1].trim();if(o==="")throw new Error(`Invalid parameter syntax in mime type: "${e}".`);i[o]=c}return{type:r,subtype:n,parameters:i}}function Pa({dataUrl:e,asTypedArray:t=!1}){let r=e.match(/^data:(\w+\/\w+);base64,([A-Za-z0-9+/]+=*)$/),n;if(r){n=r[1].toLowerCase();let i=t?Uint8Array.from(atob(r[2]),a=>a.charCodeAt(0)):r[2];return{mime_type:n,data:i}}}function nb(e,t){if(e.type==="text"){if(!t.fromStandardTextBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardTextBlock\` method.`);return t.fromStandardTextBlock(e)}if(e.type==="image"){if(!t.fromStandardImageBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardImageBlock\` method.`);return t.fromStandardImageBlock(e)}if(e.type==="audio"){if(!t.fromStandardAudioBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardAudioBlock\` method.`);return t.fromStandardAudioBlock(e)}if(e.type==="file"){if(!t.fromStandardFileBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardFileBlock\` method.`);return t.fromStandardFileBlock(e)}throw new Error(`Unable to convert content block type '${e.type}' to provider-specific format: not recognized.`)}function S(e,t){return $(e)&&e.type===t}function $(e){return typeof e=="object"&&e!==null}function de(e){return Array.isArray(e)}function g(e){return typeof e=="string"}function De(e){return typeof e=="number"}function qn(e){return e instanceof Uint8Array}function Ma(e){try{return JSON.parse(e)}catch{return}}var Ue=e=>e();function Dp(e){if(e.type==="char_location"&&g(e.document_title)&&De(e.start_char_index)&&De(e.end_char_index)&&g(e.cited_text)){let{document_title:t,start_char_index:r,end_char_index:n,cited_text:i,...a}=e;return{...a,type:"citation",source:"char",title:t??void 0,startIndex:r,endIndex:n,citedText:i}}if(e.type==="page_location"&&g(e.document_title)&&De(e.start_page_number)&&De(e.end_page_number)&&g(e.cited_text)){let{document_title:t,start_page_number:r,end_page_number:n,cited_text:i,...a}=e;return{...a,type:"citation",source:"page",title:t??void 0,startIndex:r,endIndex:n,citedText:i}}if(e.type==="content_block_location"&&g(e.document_title)&&De(e.start_block_index)&&De(e.end_block_index)&&g(e.cited_text)){let{document_title:t,start_block_index:r,end_block_index:n,cited_text:i,...a}=e;return{...a,type:"citation",source:"block",title:t??void 0,startIndex:r,endIndex:n,citedText:i}}if(e.type==="web_search_result_location"&&g(e.url)&&g(e.title)&&g(e.encrypted_index)&&g(e.cited_text)){let{url:t,title:r,encrypted_index:n,cited_text:i,...a}=e;return{...a,type:"citation",source:"url",url:t,title:r,startIndex:Number(n),endIndex:Number(n),citedText:i}}if(e.type==="search_result_location"&&g(e.source)&&g(e.title)&&De(e.start_block_index)&&De(e.end_block_index)&&g(e.cited_text)){let{source:t,title:r,start_block_index:n,end_block_index:i,cited_text:a,...s}=e;return{...s,type:"citation",source:"search",url:t,title:r??void 0,startIndex:n,endIndex:i,citedText:a}}}function Dc(e){if(S(e,"document")&&$(e.source)&&"type"in e.source){if(e.source.type==="base64"&&g(e.source.media_type)&&g(e.source.data))return{type:"file",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&g(e.source.url))return{type:"file",url:e.source.url};if(e.source.type==="file"&&g(e.source.file_id))return{type:"file",fileId:e.source.file_id};if(e.source.type==="text"&&g(e.source.data))return{type:"file",mimeType:String(e.source.media_type??"text/plain"),data:e.source.data}}else if(S(e,"image")&&$(e.source)&&"type"in e.source){if(e.source.type==="base64"&&g(e.source.media_type)&&g(e.source.data))return{type:"image",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&g(e.source.url))return{type:"image",url:e.source.url};if(e.source.type==="file"&&g(e.source.file_id))return{type:"image",fileId:e.source.file_id}}}function Uc(e){function*t(){for(let r of e){let n=Dc(r);n?yield n:yield r}}return Array.from(t())}function Lc(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r){if(S(n,"text")&&g(n.text)){let{text:i,citations:a,...s}=n;if(de(a)&&a.length){let o=a.reduce((c,l)=>{let u=Dp(l);return u?[...c,u]:c},[]);yield{...s,type:"text",text:i,annotations:o};continue}else{yield{...s,type:"text",text:i};continue}}else if(S(n,"thinking")&&g(n.thinking)){let{thinking:i,signature:a,...s}=n;yield{...s,type:"reasoning",reasoning:i,signature:a};continue}else if(S(n,"redacted_thinking")){yield{type:"non_standard",value:n};continue}else if(S(n,"tool_use")&&g(n.name)&&g(n.id)){yield{type:"tool_call",id:n.id,name:n.name,args:n.input};continue}else if(S(n,"input_json_delta")){if(Up(e)&&e.tool_call_chunks?.length){let i=e.tool_call_chunks[0];yield{type:"tool_call_chunk",id:i.id,name:i.name,args:i.args,index:i.index};continue}}else if(S(n,"server_tool_use")&&g(n.name)&&g(n.id)){let{name:i,id:a}=n;if(i==="web_search"){yield{id:a,type:"server_tool_call",name:"web_search",args:{query:Ue(()=>{if(typeof n.input=="string")return n.input;if($(n.input)&&g(n.input.query))return n.input.query;if(g(n.partial_json)){let s=Ma(n.partial_json);if(s?.query)return s.query}return""})}};continue}else if(n.name==="code_execution"){yield{id:a,type:"server_tool_call",name:"code_execution",args:{code:Ue(()=>{if(typeof n.input=="string")return n.input;if($(n.input)&&g(n.input.code))return n.input.code;if(g(n.partial_json)){let s=Ma(n.partial_json);if(s?.code)return s.code}return""})}};continue}}else if(S(n,"web_search_tool_result")&&g(n.tool_use_id)&&de(n.content)){let{content:i,tool_use_id:a}=n;yield{type:"server_tool_call_result",name:"web_search",toolCallId:a,status:"success",output:{urls:i.reduce((s,o)=>S(o,"web_search_result")?[...s,o.url]:s,[])}};continue}else if(S(n,"code_execution_tool_result")&&g(n.tool_use_id)&&$(n.content)){yield{type:"server_tool_call_result",name:"code_execution",toolCallId:n.tool_use_id,status:"success",output:n.content};continue}else if(S(n,"mcp_tool_use")){yield{id:n.id,type:"server_tool_call",name:"mcp_tool_use",args:n.input};continue}else if(S(n,"mcp_tool_result")&&g(n.tool_use_id)&&$(n.content)){yield{type:"server_tool_call_result",name:"mcp_tool_use",toolCallId:n.tool_use_id,status:"success",output:n.content};continue}else if(S(n,"container_upload")){yield{type:"server_tool_call",name:"container_upload",args:n.input};continue}else if(S(n,"search_result")){yield{id:n.id,type:"non_standard",value:n};continue}else if(S(n,"tool_result")){yield{id:n.id,type:"non_standard",value:n};continue}else{let i=Dc(n);if(i){yield i;continue}}yield{type:"non_standard",value:n}}}return Array.from(t())}var zc={translateContent:Lc,translateContentChunk:Lc};function Up(e){return typeof e?._getType=="function"&&typeof e.concat=="function"&&e._getType()==="ai"}function zp(e){return Pc(e)?{type:e.type,mimeType:e.mime_type,url:e.url,metadata:e.metadata}:Mc(e)?{type:e.type,mimeType:e.mime_type??"application/octet-stream",data:e.data,metadata:e.metadata}:jc(e)?{type:e.type,mimeType:e.mime_type,fileId:e.id,metadata:e.metadata}:e}function Bc(e){return e.map(zp)}function Fc(e){return!!(S(e,"image_url")&&$(e.image_url)||S(e,"input_audio")&&$(e.input_audio)||S(e,"file")&&$(e.file))}function Hc(e){if(S(e,"image_url")&&$(e.image_url)&&g(e.image_url.url)){let t=Pa({dataUrl:e.image_url.url});return t?{type:"image",mimeType:t.mime_type,data:t.data}:{type:"image",url:e.image_url.url}}else{if(S(e,"input_audio")&&$(e.input_audio)&&g(e.input_audio.data)&&g(e.input_audio.format))return{type:"audio",data:e.input_audio.data,mimeType:`audio/${e.input_audio.format}`};if(S(e,"file")&&$(e.file)&&g(e.file.data)){let t=Pa({dataUrl:e.file.data});if(t)return{type:"file",data:t.data,mimeType:t.mime_type};if(g(e.file.file_id))return{type:"file",fileId:e.file.file_id}}}return e}function Bp(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...Wn(e.content));for(let r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}function Fp(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...Wn(e.content));for(let r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}function Wn(e){let t=[];for(let r of e)Fc(r)?t.push(Hc(r)):t.push(r);return t}function Hp(e){if(e.type==="url_citation"){let{url:t,title:r,start_index:n,end_index:i}=e;return{type:"citation",url:t,title:r,startIndex:n,endIndex:i}}if(e.type==="file_citation"){let{file_id:t,filename:r,index:n}=e;return{type:"citation",title:r,startIndex:n,endIndex:n,fileId:t}}return e}function Gc(e){function*t(){$(e.additional_kwargs?.reasoning)&&de(e.additional_kwargs.reasoning.summary)&&(yield{type:"reasoning",reasoning:e.additional_kwargs.reasoning.summary.reduce((n,i)=>$(i)&&g(i.text)?`${n}${i.text}`:n,"")});let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r)if(S(n,"text")){let{text:i,annotations:a,phase:s,extras:o,...c}=n,l=$(o)?{...o}:{};g(s)&&(l.phase=s);let u=Object.keys(l).length>0?{extras:l}:{};Array.isArray(a)?yield{...c,...u,type:"text",text:String(i),annotations:a.map(Hp)}:yield{...c,...u,type:"text",text:String(i)}}for(let n of e.tool_calls??[])yield{type:"tool_call",id:n.id,name:n.name,args:n.args};if($(e.additional_kwargs)&&de(e.additional_kwargs.tool_outputs))for(let n of e.additional_kwargs.tool_outputs){if(S(n,"web_search_call")){let i={};if($(n.action)&&g(n.action.query)&&(i.query=n.action.query),yield{id:n.id,type:"server_tool_call",name:"web_search",args:i},n.status==="completed"||n.status==="failed"){let a={};$(n.action)&&(a.action=n.action),yield{type:"server_tool_call_result",toolCallId:g(n.id)?n.id:"",status:n.status==="completed"?"success":"error",output:a}}continue}else if(S(n,"file_search_call")){yield{id:n.id,type:"server_tool_call",name:"file_search",args:{queries:de(n.queries)?n.queries:[]}},(n.status==="completed"||n.status==="failed")&&(yield{type:"server_tool_call_result",toolCallId:g(n.id)?n.id:"",status:n.status==="completed"?"success":"error",output:de(n.results)?{results:n.results}:{}});continue}else if(S(n,"computer_call")){yield{type:"non_standard",value:n};continue}else if(S(n,"code_interpreter_call")){if(g(n.code)&&(yield{id:n.id,type:"server_tool_call",name:"code_interpreter",args:{code:n.code}}),de(n.outputs)){let i=Ue(()=>{if(n.status!=="in_progress"){if(n.status==="completed")return 0;if(n.status==="incomplete")return 127;if(n.status!=="interpreting"&&n.status==="failed")return 1}});for(let a of n.outputs)if(S(a,"logs")){yield{type:"server_tool_call_result",toolCallId:n.id??"",status:"success",output:{type:"code_interpreter_output",returnCode:i??0,stderr:[0,void 0].includes(i)?void 0:String(a.logs),stdout:[0,void 0].includes(i)?String(a.logs):void 0}};continue}}continue}else if(S(n,"mcp_call")){yield{id:n.id,type:"server_tool_call",name:"mcp_call",args:n.input};continue}else if(S(n,"mcp_list_tools")){yield{id:n.id,type:"server_tool_call",name:"mcp_list_tools",args:n.input};continue}else if(S(n,"mcp_approval_request")){yield{type:"non_standard",value:n};continue}else if(S(n,"tool_search_call")){let i={};$(n.arguments)&&Object.assign(i,n.arguments);let a={};g(n.execution)&&(a.execution=n.execution),g(n.status)&&(a.status=n.status),g(n.call_id)&&(a.call_id=n.call_id),yield{id:g(n.id)?n.id:"",type:"server_tool_call",name:"tool_search",args:i,...Object.keys(a).length>0?{extras:a}:{}};continue}else if(S(n,"tool_search_output")){let i={name:"tool_search"};g(n.execution)&&(i.execution=n.execution),yield{type:"server_tool_call_result",toolCallId:g(n.id)?n.id:"",status:n.status==="completed"?"success":n.status==="failed"?"error":"success",output:{tools:de(n.tools)?n.tools:[]},extras:i};continue}else if(S(n,"image_generation_call")){g(n.result)&&(yield{type:"image",mimeType:"image/png",data:n.result,id:g(n.id)?n.id:void 0,metadata:{status:g(n.status)?n.status:void 0}}),yield{type:"non_standard",value:n};continue}$(n)&&(yield{type:"non_standard",value:n})}}return Array.from(t())}function Gp(e){function*t(){yield*Gc(e);for(let r of e.tool_call_chunks??[])yield{type:"tool_call_chunk",id:r.id,name:r.name,args:r.args}}return Array.from(t())}var Vc={translateContent:e=>typeof e.content=="string"?Bp(e):Gc(e),translateContentChunk:e=>typeof e.content=="string"?Fp(e):Gp(e)};function Zc(e){return typeof e=="object"&&e!==null&&"type"in e&&"content"in e&&(typeof e.content=="string"||Array.isArray(e.content))}function qc(e,t="pretty"){return t==="pretty"?Vp(e):JSON.stringify(e)}function Vp(e){let t=[],r=` ${e.type.charAt(0).toUpperCase()+e.type.slice(1)} Message `,n=Math.floor((80-r.length)/2),i="=".repeat(n),a=r.length%2===0?i:`${i}=`;if(t.push(`${i}${r}${a}`),e.type==="ai"){let s=e;if(s.tool_calls&&s.tool_calls.length>0){t.push("Tool Calls:");for(let o of s.tool_calls){t.push(` ${o.name} (${o.id})`),t.push(` Call ID: ${o.id}`),t.push(" Args:");for(let[c,l]of Object.entries(o.args))t.push(` ${c}: ${typeof l=="object"?JSON.stringify(l):l}`)}}}if(e.type==="tool"){let s=e;s.name&&t.push(`Name: ${s.name}`)}return typeof e.content=="string"&&e.content.trim()&&(t.length>1&&t.push(""),t.push(e.content)),t.join(`
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import{$ as Na,Dd as $a,d as dt,e as Ca,j as Gn,k as Oa,m as xc,n as Ec,o as Ra,u as $e,w as Sc,x as Tc}from"./CSE6BHOJ.js";import{a as Qt,b as Ip,c as Hn}from"./BVUCNXC5.js";var ld=Qt((JE,Os)=>{"use strict";var $m=Object.prototype.hasOwnProperty,ke="~";function mn(){}Object.create&&(mn.prototype=Object.create(null),new mn().__proto__||(ke=!1));function Pm(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function cd(e,t,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var a=new Pm(r,n||e,i),s=ke?ke+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],a]:e._events[s].push(a):(e._events[s]=a,e._eventsCount++),e}function bi(e,t){--e._eventsCount===0?e._events=new mn:delete e._events[t]}function xe(){this._events=new mn,this._eventsCount=0}xe.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)$m.call(r,n)&&t.push(ke?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};xe.prototype.listeners=function(t){var r=ke?ke+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,s=new Array(a);i<a;i++)s[i]=n[i].fn;return s};xe.prototype.listenerCount=function(t){var r=ke?ke+t:t,n=this._events[r];return n?n.fn?1:n.length:0};xe.prototype.emit=function(t,r,n,i,a,s){var o=ke?ke+t:t;if(!this._events[o])return!1;var c=this._events[o],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,i),!0;case 5:return c.fn.call(c.context,r,n,i,a),!0;case 6:return c.fn.call(c.context,r,n,i,a,s),!0}for(d=1,u=new Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(t,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,r);break;case 3:c[d].fn.call(c[d].context,r,n);break;case 4:c[d].fn.call(c[d].context,r,n,i);break;default:if(!u)for(p=1,u=new Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0};xe.prototype.on=function(t,r,n){return cd(this,t,r,n,!1)};xe.prototype.once=function(t,r,n){return cd(this,t,r,n,!0)};xe.prototype.removeListener=function(t,r,n,i){var a=ke?ke+t:t;if(!this._events[a])return this;if(!r)return bi(this,a),this;var s=this._events[a];if(s.fn)s.fn===r&&(!i||s.once)&&(!n||s.context===n)&&bi(this,a);else{for(var o=0,c=[],l=s.length;o<l;o++)(s[o].fn!==r||i&&!s[o].once||n&&s[o].context!==n)&&c.push(s[o]);c.length?this._events[a]=c.length===1?c[0]:c:bi(this,a)}return this};xe.prototype.removeAllListeners=function(t){var r;return t?(r=ke?ke+t:t,this._events[r]&&bi(this,r)):(this._events=new mn,this._eventsCount=0),this};xe.prototype.off=xe.prototype.removeListener;xe.prototype.addListener=xe.prototype.on;xe.prefixed=ke;xe.EventEmitter=xe;typeof Os<"u"&&(Os.exports=xe)});var dd=Qt((KE,ud)=>{"use strict";ud.exports=(e,t)=>(t=t||(()=>{}),e.then(r=>new Promise(n=>{n(t())}).then(()=>r),r=>new Promise(n=>{n(t())}).then(()=>{throw r})))});var pd=Qt((YE,xi)=>{"use strict";var Mm=dd(),vi=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},fd=(e,t,r)=>new Promise((n,i)=>{if(typeof t!="number"||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0){n(e);return}let a=setTimeout(()=>{if(typeof r=="function"){try{n(r())}catch(c){i(c)}return}let s=typeof r=="string"?r:`Promise timed out after ${t} milliseconds`,o=r instanceof Error?r:new vi(s);typeof e.cancel=="function"&&e.cancel(),i(o)},t);Mm(e.then(n,i),()=>{clearTimeout(a)})});xi.exports=fd;xi.exports.default=fd;xi.exports.TimeoutError=vi});var hd=Qt(Rs=>{"use strict";Object.defineProperty(Rs,"__esModule",{value:!0});function jm(e,t,r){let n=0,i=e.length;for(;i>0;){let a=i/2|0,s=n+a;r(e[s],t)<=0?(n=++s,i-=a+1):i=a}return n}Rs.default=jm});var md=Qt($s=>{"use strict";Object.defineProperty($s,"__esModule",{value:!0});var Lm=hd(),Ns=class{constructor(){this._queue=[]}enqueue(t,r){r=Object.assign({priority:0},r);let n={priority:r.priority,run:t};if(this.size&&this._queue[this.size-1].priority>=r.priority){this._queue.push(n);return}let i=Lm.default(this._queue,n,(a,s)=>s.priority-a.priority);this._queue.splice(i,0,n)}dequeue(){let t=this._queue.shift();return t?.run}filter(t){return this._queue.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this._queue.length}};$s.default=Ns});var Si=Qt(Ms=>{"use strict";Object.defineProperty(Ms,"__esModule",{value:!0});var Dm=ld(),gd=pd(),Um=md(),Ei=()=>{},zm=new gd.TimeoutError,Ps=class extends Dm{constructor(t){var r,n,i,a;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=Ei,this._resolveIdle=Ei,t=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:Um.default},t),!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(r=t.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(a=(i=t.interval)===null||i===void 0?void 0:i.toString())!==null&&a!==void 0?a:""}\` (${typeof t.interval})`);this._carryoverConcurrencyCount=t.carryoverConcurrencyCount,this._isIntervalIgnored=t.intervalCap===1/0||t.interval===0,this._intervalCap=t.intervalCap,this._interval=t.interval,this._queue=new t.queueClass,this._queueClass=t.queueClass,this.concurrency=t.concurrency,this._timeout=t.timeout,this._throwOnTimeout=t.throwOnTimeout===!0,this._isPaused=t.autoStart===!1}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount<this._intervalCap}get _doesConcurrentAllowAnother(){return this._pendingCount<this._concurrency}_next(){this._pendingCount--,this._tryToStartAnother(),this.emit("next")}_resolvePromises(){this._resolveEmpty(),this._resolveEmpty=Ei,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=Ei,this.emit("idle"))}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}_isIntervalPaused(){let t=Date.now();if(this._intervalId===void 0){let r=this._intervalEnd-t;if(r<0)this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0;else return this._timeoutId===void 0&&(this._timeoutId=setTimeout(()=>{this._onResumeInterval()},r)),!0}return!1}_tryToStartAnother(){if(this._queue.size===0)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){let t=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){let r=this._queue.dequeue();return r?(this.emit("active"),r(),t&&this._initializeIntervalIfNeeded(),!0):!1}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||this._intervalId!==void 0||(this._intervalId=setInterval(()=>{this._onInterval()},this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){this._intervalCount===0&&this._pendingCount===0&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this._concurrency=t,this._processQueue()}async add(t,r={}){return new Promise((n,i)=>{let a=async()=>{this._pendingCount++,this._intervalCount++;try{let s=this._timeout===void 0&&r.timeout===void 0?t():gd.default(Promise.resolve(t()),r.timeout===void 0?this._timeout:r.timeout,()=>{(r.throwOnTimeout===void 0?this._throwOnTimeout:r.throwOnTimeout)&&i(zm)});n(await s)}catch(s){i(s)}this._next()};this._queue.enqueue(a,r),this._tryToStartAnother(),this.emit("add")})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(this._queue.size!==0)return new Promise(t=>{let r=this._resolveEmpty;this._resolveEmpty=()=>{r(),t()}})}async onIdle(){if(!(this._pendingCount===0&&this._queue.size===0))return new Promise(t=>{let r=this._resolveIdle;this._resolveIdle=()=>{r(),t()}})}get size(){return this._queue.size}sizeBy(t){return this._queue.filter(t).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(t){this._timeout=t}};Ms.default=Ps});var _p=Qt(ga=>{"use strict";ga.byteLength=xw;ga.toByteArray=Sw;ga.fromByteArray=Iw;var St=[],Qe=[],vw=typeof Uint8Array<"u"?Uint8Array:Array,cc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Rr=0,mp=cc.length;Rr<mp;++Rr)St[Rr]=cc[Rr],Qe[cc.charCodeAt(Rr)]=Rr;var Rr,mp;Qe[45]=62;Qe[95]=63;function gp(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function xw(e){var t=gp(e),r=t[0],n=t[1];return(r+n)*3/4-n}function Ew(e,t,r){return(t+r)*3/4-r}function Sw(e){var t,r=gp(e),n=r[0],i=r[1],a=new vw(Ew(e,n,i)),s=0,o=i>0?n-4:n,c;for(c=0;c<o;c+=4)t=Qe[e.charCodeAt(c)]<<18|Qe[e.charCodeAt(c+1)]<<12|Qe[e.charCodeAt(c+2)]<<6|Qe[e.charCodeAt(c+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=t&255;return i===2&&(t=Qe[e.charCodeAt(c)]<<2|Qe[e.charCodeAt(c+1)]>>4,a[s++]=t&255),i===1&&(t=Qe[e.charCodeAt(c)]<<10|Qe[e.charCodeAt(c+1)]<<4|Qe[e.charCodeAt(c+2)]>>2,a[s++]=t>>8&255,a[s++]=t&255),a}function Tw(e){return St[e>>18&63]+St[e>>12&63]+St[e>>6&63]+St[e&63]}function Aw(e,t,r){for(var n,i=[],a=t;a<r;a+=3)n=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(Tw(n));return i.join("")}function Iw(e){for(var t,r=e.length,n=r%3,i=[],a=16383,s=0,o=r-n;s<o;s+=a)i.push(Aw(e,s,s+a>o?o:s+a));return n===1?(t=e[r-1],i.push(St[t>>2]+St[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(St[t>>10]+St[t>>4&63]+St[t<<2&63]+"=")),i.join("")}});var Ac=Object.defineProperty,L=(e,t)=>{let r={};for(var n in e)Ac(r,n,{get:e[n],enumerable:!0});return t||Ac(r,Symbol.toStringTag,{value:"Module"}),r};var kp=/([A-Z]+)([A-Z][a-z0-9]+)/g,Cp=/([a-z0-9])([A-Z])/g,Ic=/[-_\s]+/g;function Op(e){return e.replace(kp,"$1_$2").replace(Cp,"$1_$2").replace(Ic,"_").toLowerCase()}function Rp(e){let t=e.trim();return/[-_\s]/.test(t)?t.replace(Ic,"_").toLowerCase().replace(/_+([a-z0-9])/g,(r,n)=>n.toUpperCase()):t}function kc(e,t){return t?.[e]||Op(e)}function Zw(e,t){return t?.[e]||Rp(e)}function Cc(e,t,r){let n={};for(let i in e)Object.hasOwn(e,i)&&(n[t(i,r)]=e[i]);return n}var Rc="__lc_escaped__";function Np(e){return"lc"in e||Object.keys(e).length===1&&"__lc_escaped__"in e}function $p(e){return{[Rc]:e}}function Pp(e){return Object.keys(e).length===1&&"__lc_escaped__"in e}function Mp(e){return e!==null&&typeof e=="object"&&"lc_serializable"in e&&typeof e.toJSON=="function"}function jp(e){let t;return e!==null&&typeof e=="object"?"lc_id"in e&&Array.isArray(e.lc_id)?t=e.lc_id:t=[e.constructor?.name??"Object"]:t=[typeof e],{lc:1,type:"not_implemented",id:t}}function Vn(e,t=new WeakSet){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){if(t.has(e))return jp(e);if(Mp(e))return e;t.add(e);let r=e;if(Np(r))return t.delete(e),$p(r);let n={};for(let[i,a]of Object.entries(r))n[i]=Vn(a,t);return t.delete(e),n}return Array.isArray(e)?e.map(r=>Vn(r,t)):e}function Oc(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let t=e;if(Pp(t))return t[Rc];let r={};for(let[n,i]of Object.entries(t))r[n]=Oc(i);return r}return Array.isArray(e)?e.map(t=>Oc(t)):e}var Xw=L({Serializable:()=>ft,get_lc_unique_name:()=>Zn});function Nc(e){return Array.isArray(e)?[...e]:{...e}}function Lp(e,t){let r=Nc(e);for(let[n,i]of Object.entries(t)){let[a,...s]=n.split(".").reverse(),o=r;for(let c of s.reverse()){if(o[c]===void 0)break;o[c]=Nc(o[c]),o=o[c]}o[a]!==void 0&&(o[a]={lc:1,type:"secret",id:[i]})}return r}function Zn(e){let t=Object.getPrototypeOf(e);return typeof e.lc_name=="function"&&(typeof t.lc_name!="function"||e.lc_name()!==t.lc_name())?e.lc_name():e.name}var ft=class $c{lc_serializable=!1;lc_kwargs;static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,Zn(this.constructor)]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}constructor(t,...r){this.lc_serializable_keys!==void 0?this.lc_kwargs=Object.fromEntries(Object.entries(t||{}).filter(([n])=>this.lc_serializable_keys?.includes(n))):this.lc_kwargs=t??{}}toJSON(){if(!this.lc_serializable)return this.toJSONNotImplemented();if(this.lc_kwargs instanceof $c||typeof this.lc_kwargs!="object"||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();let t={},r={},n=Object.keys(this.lc_kwargs).reduce((o,c)=>(o[c]=c in this?this[c]:this.lc_kwargs[c],o),{});for(let o=Object.getPrototypeOf(this);o;o=Object.getPrototypeOf(o))Object.assign(t,Reflect.get(o,"lc_aliases",this)),Object.assign(r,Reflect.get(o,"lc_secrets",this)),Object.assign(n,Reflect.get(o,"lc_attributes",this));Object.keys(r).forEach(o=>{let c=this,l=n,[u,...d]=o.split(".").reverse();for(let f of d.reverse()){if(!(f in c)||c[f]===void 0)return;(!(f in l)||l[f]===void 0)&&(typeof c[f]=="object"&&c[f]!=null?l[f]={}:Array.isArray(c[f])&&(l[f]=[])),c=c[f],l=l[f]}u in c&&c[u]!==void 0&&(l[u]=l[u]||c[u])});let i={},a=new WeakSet;a.add(this);for(let[o,c]of Object.entries(n))i[o]=Vn(c,a);let s=Cc(Object.keys(r).length?Lp(i,r):i,kc,t);return{lc:1,type:"constructor",id:this.lc_id,kwargs:s}}toJSONNotImplemented(){return{lc:1,type:"not_implemented",id:this.lc_id}}};function Nt(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"&&"source_type"in e&&(e.source_type==="url"||e.source_type==="base64"||e.source_type==="text"||e.source_type==="id")}function Pc(e){return Nt(e)&&e.source_type==="url"&&"url"in e&&typeof e.url=="string"}function Mc(e){return Nt(e)&&e.source_type==="base64"&&"data"in e&&typeof e.data=="string"}function eb(e){return Nt(e)&&e.source_type==="text"&&"text"in e&&typeof e.text=="string"}function jc(e){return Nt(e)&&e.source_type==="id"&&"id"in e&&typeof e.id=="string"}function tb(e){if(Nt(e)){if(e.source_type==="url")return{type:"image_url",image_url:{url:e.url}};if(e.source_type==="base64"){if(!e.mime_type)throw new Error("mime_type key is required for base64 data.");return{type:"image_url",image_url:{url:`data:${e.mime_type};base64,${e.data}`}}}}throw new Error("Unsupported source type. Only 'url' and 'base64' are supported.")}function rb(e){let t=e.split(";")[0].split("/");if(t.length!==2)throw new Error(`Invalid mime type: "${e}" - does not match type/subtype format.`);let r=t[0].trim(),n=t[1].trim();if(r===""||n==="")throw new Error(`Invalid mime type: "${e}" - type or subtype is empty.`);let i={};for(let a of e.split(";").slice(1)){let s=a.split("=");if(s.length!==2)throw new Error(`Invalid parameter syntax in mime type: "${e}".`);let o=s[0].trim(),c=s[1].trim();if(o==="")throw new Error(`Invalid parameter syntax in mime type: "${e}".`);i[o]=c}return{type:r,subtype:n,parameters:i}}function Pa({dataUrl:e,asTypedArray:t=!1}){let r=e.match(/^data:(\w+\/\w+);base64,([A-Za-z0-9+/]+=*)$/),n;if(r){n=r[1].toLowerCase();let i=t?Uint8Array.from(atob(r[2]),a=>a.charCodeAt(0)):r[2];return{mime_type:n,data:i}}}function nb(e,t){if(e.type==="text"){if(!t.fromStandardTextBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardTextBlock\` method.`);return t.fromStandardTextBlock(e)}if(e.type==="image"){if(!t.fromStandardImageBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardImageBlock\` method.`);return t.fromStandardImageBlock(e)}if(e.type==="audio"){if(!t.fromStandardAudioBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardAudioBlock\` method.`);return t.fromStandardAudioBlock(e)}if(e.type==="file"){if(!t.fromStandardFileBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardFileBlock\` method.`);return t.fromStandardFileBlock(e)}throw new Error(`Unable to convert content block type '${e.type}' to provider-specific format: not recognized.`)}function S(e,t){return $(e)&&e.type===t}function $(e){return typeof e=="object"&&e!==null}function de(e){return Array.isArray(e)}function g(e){return typeof e=="string"}function De(e){return typeof e=="number"}function qn(e){return e instanceof Uint8Array}function Ma(e){try{return JSON.parse(e)}catch{return}}var Ue=e=>e();function Dp(e){if(e.type==="char_location"&&g(e.document_title)&&De(e.start_char_index)&&De(e.end_char_index)&&g(e.cited_text)){let{document_title:t,start_char_index:r,end_char_index:n,cited_text:i,...a}=e;return{...a,type:"citation",source:"char",title:t??void 0,startIndex:r,endIndex:n,citedText:i}}if(e.type==="page_location"&&g(e.document_title)&&De(e.start_page_number)&&De(e.end_page_number)&&g(e.cited_text)){let{document_title:t,start_page_number:r,end_page_number:n,cited_text:i,...a}=e;return{...a,type:"citation",source:"page",title:t??void 0,startIndex:r,endIndex:n,citedText:i}}if(e.type==="content_block_location"&&g(e.document_title)&&De(e.start_block_index)&&De(e.end_block_index)&&g(e.cited_text)){let{document_title:t,start_block_index:r,end_block_index:n,cited_text:i,...a}=e;return{...a,type:"citation",source:"block",title:t??void 0,startIndex:r,endIndex:n,citedText:i}}if(e.type==="web_search_result_location"&&g(e.url)&&g(e.title)&&g(e.encrypted_index)&&g(e.cited_text)){let{url:t,title:r,encrypted_index:n,cited_text:i,...a}=e;return{...a,type:"citation",source:"url",url:t,title:r,startIndex:Number(n),endIndex:Number(n),citedText:i}}if(e.type==="search_result_location"&&g(e.source)&&g(e.title)&&De(e.start_block_index)&&De(e.end_block_index)&&g(e.cited_text)){let{source:t,title:r,start_block_index:n,end_block_index:i,cited_text:a,...s}=e;return{...s,type:"citation",source:"search",url:t,title:r??void 0,startIndex:n,endIndex:i,citedText:a}}}function Dc(e){if(S(e,"document")&&$(e.source)&&"type"in e.source){if(e.source.type==="base64"&&g(e.source.media_type)&&g(e.source.data))return{type:"file",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&g(e.source.url))return{type:"file",url:e.source.url};if(e.source.type==="file"&&g(e.source.file_id))return{type:"file",fileId:e.source.file_id};if(e.source.type==="text"&&g(e.source.data))return{type:"file",mimeType:String(e.source.media_type??"text/plain"),data:e.source.data}}else if(S(e,"image")&&$(e.source)&&"type"in e.source){if(e.source.type==="base64"&&g(e.source.media_type)&&g(e.source.data))return{type:"image",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&g(e.source.url))return{type:"image",url:e.source.url};if(e.source.type==="file"&&g(e.source.file_id))return{type:"image",fileId:e.source.file_id}}}function Uc(e){function*t(){for(let r of e){let n=Dc(r);n?yield n:yield r}}return Array.from(t())}function Lc(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r){if(S(n,"text")&&g(n.text)){let{text:i,citations:a,...s}=n;if(de(a)&&a.length){let o=a.reduce((c,l)=>{let u=Dp(l);return u?[...c,u]:c},[]);yield{...s,type:"text",text:i,annotations:o};continue}else{yield{...s,type:"text",text:i};continue}}else if(S(n,"thinking")&&g(n.thinking)){let{thinking:i,signature:a,...s}=n;yield{...s,type:"reasoning",reasoning:i,signature:a};continue}else if(S(n,"redacted_thinking")){yield{type:"non_standard",value:n};continue}else if(S(n,"tool_use")&&g(n.name)&&g(n.id)){yield{type:"tool_call",id:n.id,name:n.name,args:n.input};continue}else if(S(n,"input_json_delta")){if(Up(e)&&e.tool_call_chunks?.length){let i=e.tool_call_chunks[0];yield{type:"tool_call_chunk",id:i.id,name:i.name,args:i.args,index:i.index};continue}}else if(S(n,"server_tool_use")&&g(n.name)&&g(n.id)){let{name:i,id:a}=n;if(i==="web_search"){yield{id:a,type:"server_tool_call",name:"web_search",args:{query:Ue(()=>{if(typeof n.input=="string")return n.input;if($(n.input)&&g(n.input.query))return n.input.query;if(g(n.partial_json)){let s=Ma(n.partial_json);if(s?.query)return s.query}return""})}};continue}else if(n.name==="code_execution"){yield{id:a,type:"server_tool_call",name:"code_execution",args:{code:Ue(()=>{if(typeof n.input=="string")return n.input;if($(n.input)&&g(n.input.code))return n.input.code;if(g(n.partial_json)){let s=Ma(n.partial_json);if(s?.code)return s.code}return""})}};continue}}else if(S(n,"web_search_tool_result")&&g(n.tool_use_id)&&de(n.content)){let{content:i,tool_use_id:a}=n;yield{type:"server_tool_call_result",name:"web_search",toolCallId:a,status:"success",output:{urls:i.reduce((s,o)=>S(o,"web_search_result")?[...s,o.url]:s,[])}};continue}else if(S(n,"code_execution_tool_result")&&g(n.tool_use_id)&&$(n.content)){yield{type:"server_tool_call_result",name:"code_execution",toolCallId:n.tool_use_id,status:"success",output:n.content};continue}else if(S(n,"mcp_tool_use")){yield{id:n.id,type:"server_tool_call",name:"mcp_tool_use",args:n.input};continue}else if(S(n,"mcp_tool_result")&&g(n.tool_use_id)&&$(n.content)){yield{type:"server_tool_call_result",name:"mcp_tool_use",toolCallId:n.tool_use_id,status:"success",output:n.content};continue}else if(S(n,"container_upload")){yield{type:"server_tool_call",name:"container_upload",args:n.input};continue}else if(S(n,"search_result")){yield{id:n.id,type:"non_standard",value:n};continue}else if(S(n,"tool_result")){yield{id:n.id,type:"non_standard",value:n};continue}else{let i=Dc(n);if(i){yield i;continue}}yield{type:"non_standard",value:n}}}return Array.from(t())}var zc={translateContent:Lc,translateContentChunk:Lc};function Up(e){return typeof e?._getType=="function"&&typeof e.concat=="function"&&e._getType()==="ai"}function zp(e){return Pc(e)?{type:e.type,mimeType:e.mime_type,url:e.url,metadata:e.metadata}:Mc(e)?{type:e.type,mimeType:e.mime_type??"application/octet-stream",data:e.data,metadata:e.metadata}:jc(e)?{type:e.type,mimeType:e.mime_type,fileId:e.id,metadata:e.metadata}:e}function Bc(e){return e.map(zp)}function Fc(e){return!!(S(e,"image_url")&&$(e.image_url)||S(e,"input_audio")&&$(e.input_audio)||S(e,"file")&&$(e.file))}function Hc(e){if(S(e,"image_url")&&$(e.image_url)&&g(e.image_url.url)){let t=Pa({dataUrl:e.image_url.url});return t?{type:"image",mimeType:t.mime_type,data:t.data}:{type:"image",url:e.image_url.url}}else{if(S(e,"input_audio")&&$(e.input_audio)&&g(e.input_audio.data)&&g(e.input_audio.format))return{type:"audio",data:e.input_audio.data,mimeType:`audio/${e.input_audio.format}`};if(S(e,"file")&&$(e.file)&&g(e.file.data)){let t=Pa({dataUrl:e.file.data});if(t)return{type:"file",data:t.data,mimeType:t.mime_type};if(g(e.file.file_id))return{type:"file",fileId:e.file.file_id}}}return e}function Bp(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...Wn(e.content));for(let r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}function Fp(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...Wn(e.content));for(let r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}function Wn(e){let t=[];for(let r of e)Fc(r)?t.push(Hc(r)):t.push(r);return t}function Hp(e){if(e.type==="url_citation"){let{url:t,title:r,start_index:n,end_index:i}=e;return{type:"citation",url:t,title:r,startIndex:n,endIndex:i}}if(e.type==="file_citation"){let{file_id:t,filename:r,index:n}=e;return{type:"citation",title:r,startIndex:n,endIndex:n,fileId:t}}return e}function Gc(e){function*t(){$(e.additional_kwargs?.reasoning)&&de(e.additional_kwargs.reasoning.summary)&&(yield{type:"reasoning",reasoning:e.additional_kwargs.reasoning.summary.reduce((n,i)=>$(i)&&g(i.text)?`${n}${i.text}`:n,"")});let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r)if(S(n,"text")){let{text:i,annotations:a,phase:s,extras:o,...c}=n,l=$(o)?{...o}:{};g(s)&&(l.phase=s);let u=Object.keys(l).length>0?{extras:l}:{};Array.isArray(a)?yield{...c,...u,type:"text",text:String(i),annotations:a.map(Hp)}:yield{...c,...u,type:"text",text:String(i)}}for(let n of e.tool_calls??[])yield{type:"tool_call",id:n.id,name:n.name,args:n.args};if($(e.additional_kwargs)&&de(e.additional_kwargs.tool_outputs))for(let n of e.additional_kwargs.tool_outputs){if(S(n,"web_search_call")){let i={};if($(n.action)&&g(n.action.query)&&(i.query=n.action.query),yield{id:n.id,type:"server_tool_call",name:"web_search",args:i},n.status==="completed"||n.status==="failed"){let a={};$(n.action)&&(a.action=n.action),yield{type:"server_tool_call_result",toolCallId:g(n.id)?n.id:"",status:n.status==="completed"?"success":"error",output:a}}continue}else if(S(n,"file_search_call")){yield{id:n.id,type:"server_tool_call",name:"file_search",args:{queries:de(n.queries)?n.queries:[]}},(n.status==="completed"||n.status==="failed")&&(yield{type:"server_tool_call_result",toolCallId:g(n.id)?n.id:"",status:n.status==="completed"?"success":"error",output:de(n.results)?{results:n.results}:{}});continue}else if(S(n,"computer_call")){yield{type:"non_standard",value:n};continue}else if(S(n,"code_interpreter_call")){if(g(n.code)&&(yield{id:n.id,type:"server_tool_call",name:"code_interpreter",args:{code:n.code}}),de(n.outputs)){let i=Ue(()=>{if(n.status!=="in_progress"){if(n.status==="completed")return 0;if(n.status==="incomplete")return 127;if(n.status!=="interpreting"&&n.status==="failed")return 1}});for(let a of n.outputs)if(S(a,"logs")){yield{type:"server_tool_call_result",toolCallId:n.id??"",status:"success",output:{type:"code_interpreter_output",returnCode:i??0,stderr:[0,void 0].includes(i)?void 0:String(a.logs),stdout:[0,void 0].includes(i)?String(a.logs):void 0}};continue}}continue}else if(S(n,"mcp_call")){yield{id:n.id,type:"server_tool_call",name:"mcp_call",args:n.input};continue}else if(S(n,"mcp_list_tools")){yield{id:n.id,type:"server_tool_call",name:"mcp_list_tools",args:n.input};continue}else if(S(n,"mcp_approval_request")){yield{type:"non_standard",value:n};continue}else if(S(n,"tool_search_call")){let i={};$(n.arguments)&&Object.assign(i,n.arguments);let a={};g(n.execution)&&(a.execution=n.execution),g(n.status)&&(a.status=n.status),g(n.call_id)&&(a.call_id=n.call_id),yield{id:g(n.id)?n.id:"",type:"server_tool_call",name:"tool_search",args:i,...Object.keys(a).length>0?{extras:a}:{}};continue}else if(S(n,"tool_search_output")){let i={name:"tool_search"};g(n.execution)&&(i.execution=n.execution),yield{type:"server_tool_call_result",toolCallId:g(n.id)?n.id:"",status:n.status==="completed"?"success":n.status==="failed"?"error":"success",output:{tools:de(n.tools)?n.tools:[]},extras:i};continue}else if(S(n,"image_generation_call")){g(n.result)&&(yield{type:"image",mimeType:"image/png",data:n.result,id:g(n.id)?n.id:void 0,metadata:{status:g(n.status)?n.status:void 0}}),yield{type:"non_standard",value:n};continue}$(n)&&(yield{type:"non_standard",value:n})}}return Array.from(t())}function Gp(e){function*t(){yield*Gc(e);for(let r of e.tool_call_chunks??[])yield{type:"tool_call_chunk",id:r.id,name:r.name,args:r.args}}return Array.from(t())}var Vc={translateContent:e=>typeof e.content=="string"?Bp(e):Gc(e),translateContentChunk:e=>typeof e.content=="string"?Fp(e):Gp(e)};function Zc(e){return typeof e=="object"&&e!==null&&"type"in e&&"content"in e&&(typeof e.content=="string"||Array.isArray(e.content))}function qc(e,t="pretty"){return t==="pretty"?Vp(e):JSON.stringify(e)}function Vp(e){let t=[],r=` ${e.type.charAt(0).toUpperCase()+e.type.slice(1)} Message `,n=Math.floor((80-r.length)/2),i="=".repeat(n),a=r.length%2===0?i:`${i}=`;if(t.push(`${i}${r}${a}`),e.type==="ai"){let s=e;if(s.tool_calls&&s.tool_calls.length>0){t.push("Tool Calls:");for(let o of s.tool_calls){t.push(` ${o.name} (${o.id})`),t.push(` Call ID: ${o.id}`),t.push(" Args:");for(let[c,l]of Object.entries(o.args))t.push(` ${c}: ${typeof l=="object"?JSON.stringify(l):l}`)}}}if(e.type==="tool"){let s=e;s.name&&t.push(`Name: ${s.name}`)}return typeof e.content=="string"&&e.content.trim()&&(t.length>1&&t.push(""),t.push(e.content)),t.join(`
3
3
  `)}var ja=Symbol.for("langchain.message");function Wc(e){return Array.isArray(e)?e:typeof e=="string"?e===""?[]:[{type:"text",text:e}]:e==null?[]:[e]}function Pe(e,t){if(typeof e=="string")return e===""?t:typeof t=="string"?e+t:Array.isArray(t)&&t.length===0?e:Array.isArray(t)&&t.some(r=>Nt(r))?[{type:"text",source_type:"text",text:e},...t]:[{type:"text",text:e},...t];if(Array.isArray(t)){let r=Wc(e);return Nr(r,t)??[...r,...t]}else return t===""?e:Array.isArray(e)&&e.some(r=>Nt(r))?[...e,{type:"file",source_type:"text",text:t}]:[...Wc(e),{type:"text",text:t}]}function Xc(e,t){return e==="error"||t==="error"?"error":"success"}function Zp(e,t){function r(n,i){if(typeof n!="object"||n===null||n===void 0)return n;if(i>=t)return Array.isArray(n)?"[Array]":"[Object]";if(Array.isArray(n))return n.map(s=>r(s,i+1));let a={};for(let s of Object.keys(n))a[s]=r(n[s],i+1);return a}return JSON.stringify(r(e,0),null,2)}var Ie=class extends ft{lc_namespace=["langchain_core","messages"];lc_serializable=!0;get lc_aliases(){return{additional_kwargs:"additional_kwargs",response_metadata:"response_metadata"}}[ja]=!0;id;name;content;additional_kwargs;response_metadata;_getType(){return this.type}getType(){return this._getType()}constructor(e){let t=typeof e=="string"||Array.isArray(e)?{content:e}:e;t.additional_kwargs||(t.additional_kwargs={}),t.response_metadata||(t.response_metadata={}),super(t),this.name=t.name,t.content===void 0&&t.contentBlocks!==void 0?(this.content=t.contentBlocks,this.response_metadata={output_version:"v1",...t.response_metadata}):t.content!==void 0?(this.content=t.content??[],this.response_metadata=t.response_metadata):(this.content=[],this.response_metadata=t.response_metadata),this.additional_kwargs=t.additional_kwargs,this.id=t.id}get text(){return typeof this.content=="string"?this.content:Array.isArray(this.content)?this.content.map(e=>typeof e=="string"?e:e.type==="text"?e.text:"").join(""):""}get contentBlocks(){let e=typeof this.content=="string"?[{type:"text",text:this.content}]:this.content;return[Bc,Wn,Uc].reduce((t,r)=>r(t),e)}toDict(){return{type:this.getType(),data:this.toJSON().kwargs}}static lc_name(){return"BaseMessage"}get _printableFields(){return{id:this.id,content:this.content,name:this.name,additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata}}static isInstance(e){return typeof e=="object"&&e!==null&&ja in e&&e[ja]===!0&&Zc(e)}static[Symbol.hasInstance](e){return this.isInstance(e)}_updateId(e){this.id=e,this.lc_kwargs.id=e}get[Symbol.toStringTag](){return this.constructor.lc_name()}[Symbol.for("nodejs.util.inspect.custom")](e){if(e===null)return this;let t=Zp(this._printableFields,Math.max(4,e));return`${this.constructor.lc_name()} ${t}`}toFormattedString(e="pretty"){return qc(this,e)}};function Eb(e){return Array.isArray(e)&&e.every(t=>typeof t.index=="number")}var qp=["index","created","timestamp"];function ce(e,t,r){let n=r?.ignoreKeys??qp;if(e==null&&t==null)return;if(e==null||t==null)return e??t;let i={...e};for(let[a,s]of Object.entries(t))if(i[a]==null)i[a]=s;else{if(s==null)continue;if(typeof i[a]!=typeof s||Array.isArray(i[a])!==Array.isArray(s))throw new Error(`field[${a}] already exists in the message chunk, but with a different type.`);if(typeof i[a]=="string"){if(a==="type")continue;if(["id","name","output_version","model_provider"].includes(a))s&&(i[a]=s);else{if(n.includes(a))continue;i[a]+=s}}else if(typeof i[a]=="number"){if(n.includes(a))continue;i[a]=i[a]+s}else if(typeof i[a]=="object"&&!Array.isArray(i[a]))i[a]=ce(i[a],s,r);else if(Array.isArray(i[a]))i[a]=Nr(i[a],s,r);else{if(i[a]===s)continue;console.warn(`field[${a}] already exists in this message chunk and value has unsupported type.`)}}return i}function Wp(e){return typeof e=="number"||typeof e=="string"}function Jc(e){return typeof e!="object"||e===null||!("index"in e)?!1:Wp(e.index)}function Kc(e){if(typeof e!="object"||e===null||!("id"in e))return!1;let t=e.id;return t!=null&&t!==""}function Yc(e){return e.endsWith("_delta")?e.slice(0,-6):e}function Jp(e,t){return typeof e!="object"||e===null||typeof t!="object"||t===null||!("type"in e)||!("type"in t)?!1:typeof e.type=="string"&&typeof t.type=="string"&&Yc(e.type)!==Yc(t.type)}function Kp(e,t){let r=Jc(t),n=Kc(t);return!r&&!n?-1:e.findIndex(i=>{let a=Jc(i),s=Kc(i);return r&&a?i.index!==t.index||Jp(i,t)?!1:s&&n?i.id===t.id:!0:!r&&!a&&n&&s?i.id===t.id:!1})}function Nr(e,t,r){if(!(e==null&&t==null)){if(e==null||t==null)return e||t;{let n=[...e];for(let i of t){let a=Kp(n,i);if(a!==-1)n[a]=ce(n[a],i,r);else{if(typeof i=="object"&&i!==null&&"text"in i&&i.text==="")continue;n.push(i)}}return n}}}function Qc(e,t,r){if(!(e==null&&t==null)){if(e==null||t==null)return e??t;if(typeof e!=typeof t)throw new Error(`Cannot merge objects of different types.
4
4
  Left ${typeof e}
5
5
  Right ${typeof t}`);if(typeof e=="string"&&typeof t=="string")return e+t;if(Array.isArray(e)&&Array.isArray(t))return Nr(e,t,r);if(typeof e=="object"&&typeof t=="object")return ce(e,t,r);if(e===t)return e;throw new Error(`Can not merge objects of different types.
@@ -178,4 +178,4 @@ Details: ${p.message}`),of(p)&&(h=`${h}
178
178
  ${$a.prettifyError(p)}`),new $r(h,JSON.stringify(e))}else{let p=re(n,this.schema);if(!p.valid){let h="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(h=`${h}
179
179
  Details: ${p.errors.map(m=>`${m.keywordLocation}: ${m.error}`).join(`
180
180
  `)}`),new $r(h,JSON.stringify(e))}i=n}let a=bn(t),s=nt.configure(a.callbacks,this.callbacks,a.tags||r,this.tags,a.metadata,this.metadata,{verbose:this.verbose}),o;$t(e)&&(o=e.id),!o&&Il(a)&&(o=a.toolCall.id);let c=await s?.handleToolStart(this.toJSON(),typeof e=="string"?e:JSON.stringify(e),a.runId,void 0,void 0,void 0,a.runName,o);delete a.runId;let l;try{let p=await this._call(i,c,a);l=Wo(p)?await kf(p,async h=>{try{await c?.handleToolEvent(h)}catch(m){await c?.handleToolError(m)}}):p}catch(p){throw await c?.handleToolError(p),p}let u,d;if(this.responseFormat==="content_and_artifact")if(Array.isArray(l)&&l.length===2)[u,d]=l;else throw new Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.
181
- Result: ${JSON.stringify(l)}`);else u=l;let f=Hw({content:u,artifact:d,toolCallId:o,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(f),f}},xp=class extends hc{schema=vt.object({input:vt.string().optional()}).transform(e=>e.input);constructor(e){super(e)}call(e,t){let r=typeof e=="string"||e==null?{input:e}:e;return super.call(r,t)}},Ep=class extends xp{static lc_name(){return"DynamicTool"}name;description;func;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect}async call(e,t){let r=bn(t);return r.runName===void 0&&(r.runName=this.name),super.call(e,r)}_call(e,t,r){return this.func(e,t,r)}},Sp=class extends hc{static lc_name(){return"DynamicStructuredTool"}description;func;schema;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect,this.schema=e.schema}async call(e,t,r){let n=bn(t);return n.runName===void 0&&(n.runName=this.name),super.call(e,n,r)}_call(e,t,r){return this.func(e,t,r)}},zw=class{getTools(){return this.tools}};function Bw(e,t){let r=Bi(t.schema),n=rn(t.schema);if(!t.schema||r||n)return new Ep({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(s,o,c)=>new Promise((l,u)=>{let d=ue(c,{callbacks:o?.getChild()});be.runWithConfig(We(d),async()=>{try{l(e(s,d))}catch(f){u(f)}})})});let i=t.schema,a=t.description??t.schema.description??`${t.name} tool`;return new Sp({...t,description:a,schema:i,func:async(s,o,c)=>new Promise((l,u)=>{let d,f=()=>{c?.signal&&d&&c.signal.removeEventListener("abort",d)};c?.signal&&(d=()=>{f(),u(Ht(c.signal))},c.signal.addEventListener("abort",d,{once:!0}));let p=ue(c,{callbacks:o?.getChild()});be.runWithConfig(We(p),async()=>{try{let h=await e(s,p);if(Wo(h)){l(h);return}if(c?.signal?.aborted){f();return}f(),l(h)}catch(h){f(),u(h)}})})})}function Fw(e){return typeof e=="object"&&e!==null&&"type"in e}function Hw(e){let{content:t,artifact:r,toolCallId:n,metadata:i}=e;return n&&!La(t)?typeof t=="string"||Array.isArray(t)&&t.every(Fw)?new er({status:"success",content:t,artifact:r,tool_call_id:n,name:e.name,metadata:i}):new er({status:"success",content:Gw(t),artifact:r,tool_call_id:n,name:e.name,metadata:i}):t}function Gw(e){try{return JSON.stringify(e)??""}catch{return`${e}`}}export{L as a,fx as b,Ka as c,Th as d,Ah as e,jr as f,Zw as g,Cc as h,Pp as i,Oc as j,Xw as k,Zn as l,ft as m,mx as n,nu as o,et as p,ea as q,zC as r,h0 as s,Ba as t,At as u,Fa as v,ah as w,sh as x,Nt as y,Pc as z,Mc as A,eb as B,jc as C,tb as D,rb as E,Pa as F,nb as G,Zc as H,Pe as I,Xc as J,Ie as K,Eb as L,qp as M,ce as N,Nr as O,Qc as P,ze as Q,tl as R,rl as S,Sb as T,Cb as U,La as V,er as W,Yp as X,Da as Y,Xp as Z,Qp as _,$r as $,b0 as aa,Ga as ba,vl as ca,Jn as da,Pr as ea,hv as fa,mv as ga,Mr as ha,Va as ia,Cl as ja,E0 as ka,S0 as la,Ol as ma,Rl as na,k0 as oa,C0 as pa,tr as qa,Nl as ra,P0 as sa,M0 as ta,$l as ua,Xn as va,Pl as wa,H0 as xa,G0 as ya,iv as za,Ml as Aa,Qn as Ba,qa as Ca,av as Da,sv as Ea,ov as Fa,jl as Ga,ZC as Ha,vx as Ia,Ch as Ja,Oh as Ka,nr as La,Lt as Ma,tT as Na,rt as Oa,sT as Pa,TT as Qa,$T as Ra,XT as Sa,bn as Ta,nt as Ua,Vr as Va,be as Wa,mA as Xa,qe as Ya,xn as Za,Y as _a,ue as $a,We as ab,it as bb,dO as cb,Re as db,ia as eb,Jt as fb,Cr as gb,sw as hb,NO as ib,LO as jb,cw as kb,$n as lb,lw as mb,nO as nb,Ir as ob,Yk as pb,uy as qb,oe as rb,he as sb,EA as tb,Zr as ub,zg as vb,Bg as wb,SA as xb,TA as yb,zi as zb,AA as Ab,IA as Bb,af as Cb,kA as Db,Bi as Eb,so as Fb,_t as Gb,oo as Hb,Fg as Ib,Hg as Jb,CA as Kb,rf as Lb,OA as Mb,RA as Nb,Ui as Ob,nf as Pb,NA as Qb,sf as Rb,$A as Sb,of as Tb,w as Ub,vt as Vb,Wt as Wb,Ki as Xb,RC as Yb,Zo as Zb,nR as _b,fa as $b,ge as ac,_e as bc,pa as cc,IR as dc,lp as ec,up as fc,ha as gc,pp as hc,kR as ic,gw as jc,Or as kc,_w as lc,yw as mc,sp as nc,BR as oc,sc as pc,oc as qc,bw as rc,tN as sc,uN as tc,bp as uc,jw as vc,Uw as wc,dc as xc,fc as yc,pc as zc,vp as Ac,MN as Bc,hc as Cc,Bw as Dc};
181
+ Result: ${JSON.stringify(l)}`);else u=l;let f=Hw({content:u,artifact:d,toolCallId:o,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(f),f}},xp=class extends hc{schema=vt.object({input:vt.string().optional()}).transform(e=>e.input);constructor(e){super(e)}call(e,t){let r=typeof e=="string"||e==null?{input:e}:e;return super.call(r,t)}},Ep=class extends xp{static lc_name(){return"DynamicTool"}name;description;func;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect}async call(e,t){let r=bn(t);return r.runName===void 0&&(r.runName=this.name),super.call(e,r)}_call(e,t,r){return this.func(e,t,r)}},Sp=class extends hc{static lc_name(){return"DynamicStructuredTool"}description;func;schema;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect,this.schema=e.schema}async call(e,t,r){let n=bn(t);return n.runName===void 0&&(n.runName=this.name),super.call(e,n,r)}_call(e,t,r){return this.func(e,t,r)}},zw=class{getTools(){return this.tools}};function Bw(e,t){let r=Bi(t.schema),n=rn(t.schema);if(!t.schema||r||n)return new Ep({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(s,o,c)=>new Promise((l,u)=>{let d=ue(c,{callbacks:o?.getChild()});be.runWithConfig(We(d),async()=>{try{l(e(s,d))}catch(f){u(f)}})})});let i=t.schema,a=t.description??t.schema.description??`${t.name} tool`;return new Sp({...t,description:a,schema:i,func:async(s,o,c)=>new Promise((l,u)=>{let d,f=()=>{c?.signal&&d&&c.signal.removeEventListener("abort",d)};c?.signal&&(d=()=>{f(),u(Ht(c.signal))},c.signal.addEventListener("abort",d,{once:!0}));let p=ue(c,{callbacks:o?.getChild()});be.runWithConfig(We(p),async()=>{try{let h=await e(s,p);if(Wo(h)){l(h);return}if(c?.signal?.aborted){f();return}f(),l(h)}catch(h){f(),u(h)}})})})}function Fw(e){return typeof e=="object"&&e!==null&&"type"in e}function Hw(e){let{content:t,artifact:r,toolCallId:n,metadata:i}=e;return n&&!La(t)?typeof t=="string"||Array.isArray(t)&&t.every(Fw)?new er({status:"success",content:t,artifact:r,tool_call_id:n,name:e.name,metadata:i}):new er({status:"success",content:Gw(t),artifact:r,tool_call_id:n,name:e.name,metadata:i}):t}function Gw(e){try{return JSON.stringify(e)??""}catch{return`${e}`}}export{L as a,h0 as b,Ba as c,At as d,Fa as e,ah as f,sh as g,Nt as h,Pc as i,Mc as j,eb as k,jc as l,tb as m,rb as n,Pa as o,nb as p,Zc as q,Zw as r,Cc as s,Pp as t,Oc as u,Xw as v,Zn as w,ft as x,Pe as y,Xc as z,Ie as A,Eb as B,qp as C,ce as D,Nr as E,Qc as F,ze as G,tl as H,rl as I,Sb as J,vl as K,Jn as L,Cb as M,La as N,er as O,Yp as P,Da as Q,Xp as R,Qp as S,$r as T,b0 as U,Ga as V,Va as W,Cl as X,E0 as Y,S0 as Z,Ol as _,Rl as $,k0 as aa,C0 as ba,tr as ca,Nl as da,P0 as ea,M0 as fa,$l as ga,Xn as ha,Pl as ia,H0 as ja,G0 as ka,iv as la,Ml as ma,Qn as na,qa as oa,av as pa,sv as qa,ov as ra,jl as sa,Pr as ta,hv as ua,mv as va,Mr as wa,fx as xa,Ka as ya,Th as za,Ah as Aa,jr as Ba,mx as Ca,nu as Da,et as Ea,vx as Fa,Ch as Ga,Oh as Ha,nr as Ia,Lt as Ja,tT as Ka,rt as La,sT as Ma,TT as Na,$T as Oa,XT as Pa,bn as Qa,nt as Ra,Vr as Sa,be as Ta,mA as Ua,qe as Va,xn as Wa,Y as Xa,ue as Ya,We as Za,it as _a,dO as $a,Re as ab,ia as bb,Jt as cb,Cr as db,sw as eb,NO as fb,LO as gb,cw as hb,$n as ib,lw as jb,nO as kb,Ir as lb,oe as mb,he as nb,EA as ob,Zr as pb,zg as qb,Bg as rb,SA as sb,TA as tb,zi as ub,AA as vb,IA as wb,af as xb,kA as yb,Bi as zb,so as Ab,_t as Bb,oo as Cb,Fg as Db,Hg as Eb,CA as Fb,rf as Gb,OA as Hb,RA as Ib,Ui as Jb,nf as Kb,NA as Lb,sf as Mb,$A as Nb,of as Ob,w as Pb,vt as Qb,Yk as Rb,uy as Sb,Wt as Tb,Ki as Ub,RC as Vb,Zo as Wb,nR as Xb,fa as Yb,ge as Zb,_e as _b,pa as $b,IR as ac,lp as bc,up as cc,ha as dc,pp as ec,kR as fc,gw as gc,Or as hc,_w as ic,yw as jc,sp as kc,dc as lc,fc as mc,pc as nc,vp as oc,ea as pc,zC as qc,ZC as rc,BR as sc,sc as tc,oc as uc,bw as vc,tN as wc,uN as xc,bp as yc,jw as zc,Uw as Ac,MN as Bc,hc as Cc,Bw as Dc};
@@ -1,2 +1,2 @@
1
- /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import a from"./CCC6LBMY.js";import{a as m}from"./ONQ6JSBJ.js";import{Dc as f}from"./AI6DYOKR.js";import{a as o}from"./VXFQANGJ.js";export default $arcgis.t(([{b:c,c:h}])=>{var g=(a,e,i)=>{let t=a.createQuery();return t.outFields=[e],t.where=i||"1=1",t.num=1,t},w=async(a,e,i,t)=>{let r=t.map?.allLayers.find(y=>y.id===a),n=g(r,e,i.where),s=(await r.queryFeatures(n)).features[0],d=s?s.attributes[e]:null,u=c(r,e,d,t.timeZone),l=h(r,e);return{tool:"getAttribute",layerName:r.title??a,summary:`${l} = ${u}`,details:{fieldName:e,fieldAlias:l!==e?l:void 0,value:u,where:i.where}}};async function b({layerId:a,fieldName:e,query:i},t){let{mapView:r}=m(t,["mapView"]),n=await w(a,e,i,r);return JSON.stringify(n,null,2)}var p=o.object({layerId:o.string().describe("The layerId of the layer containing the field from which to get a value."),fieldName:o.string().describe("The name of the field/attribute from which to get a field value."),query:o.object({where:o.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")})}),q=f(b,{name:"getAttribute",description:"Returns an attribute value for a given feature.",schema:p});return q},a)
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import a from"./KKCLHXHG.js";import{a as m}from"./A6LBMS7A.js";import{Dc as f}from"./M2U456J5.js";import{a as o}from"./5X23DDDZ.js";export default $arcgis.t(([{b:c,c:h}])=>{var g=(a,e,i)=>{let t=a.createQuery();return t.outFields=[e],t.where=i||"1=1",t.num=1,t},w=async(a,e,i,t)=>{let r=t.map?.allLayers.find(y=>y.id===a),n=g(r,e,i.where),s=(await r.queryFeatures(n)).features[0],d=s?s.attributes[e]:null,u=c(r,e,d,t.timeZone),l=h(r,e);return{tool:"getAttribute",layerName:r.title??a,summary:`${l} = ${u}`,details:{fieldName:e,fieldAlias:l!==e?l:void 0,value:u,where:i.where}}};async function b({layerId:a,fieldName:e,query:i},t){let{mapView:r}=m(t,["mapView"]),n=await w(a,e,i,r);return JSON.stringify(n,null,2)}var p=o.object({layerId:o.string().describe("The layerId of the layer containing the field from which to get a value."),fieldName:o.string().describe("The name of the field/attribute from which to get a field value."),query:o.object({where:o.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")})}),q=f(b,{name:"getAttribute",description:"Returns an attribute value for a given feature.",schema:p});return q},a)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ var a=new Map([["clearFilters",async()=>(await import("./SZ2L5556.js")).clearFiltersTool],["resetMap",async()=>(await import("./VT5EWFH7.js")).resetMapTool],["setFeatureEffect",async()=>(await import("./EXMEB4X2.js").then(m=>m.default.then(e=>({setFeatureEffectTool:e})))).setFeatureEffectTool],["listLayerFields",async()=>(await import("./BTTCBEPW.js")).listLayerFieldsTool],["goToAddress",async()=>(await import("./I3SUE2TR.js").then(m=>m.default.then(e=>({goToAddressTool:e})))).goToAddressTool],["goToBookmark",async()=>(await import("./UGIHS7OA.js")).goToBookmarkTool],["goToFeatures",async()=>(await import("./25MBI4PD.js")).goToFeaturesTool],["goToFullExtent",async()=>(await import("./FLUI6GCU.js").then(m=>m.default.then(e=>({goToFullExtentTool:e})))).goToFullExtentTool],["goToHomeExtent",async()=>(await import("./SXYKNDOF.js")).goToHomeExtentTool],["goToLayer",async()=>(await import("./KAX4A7SF.js")).goToLayerTool],["goToScale",async()=>(await import("./FRYS2PZJ.js")).goToScaleTool],["goToViewpoint",async()=>(await import("./Y4ZOB6UH.js").then(m=>m.default.then(e=>({goToViewpointTool:e})))).goToViewpointTool],["goToZoom",async()=>(await import("./SI22EJLC.js")).goToZoomTool],["findRelevantFields",async()=>(await import("./CX2HJ67C.js").then(m=>m.default.then(e=>({findRelevantFieldsTool:e})))).findRelevantFieldsTool],["findRelevantLayers",async()=>(await import("./LBTGOMCT.js")).findRelevantLayersTool],["getAttribute",async()=>(await import("./XZF7Y6B2.js").then(m=>m.default.then(e=>({getAttributeTool:e})))).getAttributeTool],["getStatistics",async()=>(await import("./AUCKEB52.js").then(m=>m.default.then(e=>({getStatisticsTool:e})))).getStatisticsTool],["getTopFeatures",async()=>(await import("./PUZ6RAFQ.js").then(m=>m.default.then(e=>({getTopFeaturesTool:e})))).getTopFeaturesTool],["queryFeatures",async()=>(await import("./FSLQCZRN.js").then(m=>m.default.then(e=>({queryFeaturesTool:e})))).queryFeaturesTool]]);async function e(o){let t=a.get(o);if(!t)throw new Error(`"${o}" tool not found`);return await t()}export{e as a};
@@ -1,5 +1,5 @@
1
- /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import"./UZLQALHY.js";var e=`# ArcGIS JavaScript SDK FeatureLayerView Query Assistant
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import"./BVUCNXC5.js";var e=`# ArcGIS JavaScript SDK FeatureLayerView Query Assistant
3
3
 
4
4
  You are a GIS assistant that generates query parameters for the ArcGIS JavaScript SDK FeatureLayerView \`queryFeatures()\` method.
5
5
 
@@ -1,5 +1,5 @@
1
- /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import"./UZLQALHY.js";var e=`## ArcgisKnowledge Agent - Lucene Generation for Graph Search
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import"./BVUCNXC5.js";var e=`## ArcgisKnowledge Agent - Lucene Generation for Graph Search
3
3
 
4
4
  You are an assistant that generates a lucene query for graph query searching.
5
5
 
@@ -1,2 +1,2 @@
1
- /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{b as o}from"./6OOZSZRJ.js";import"./RLEHNAIA.js";import{g as a,h as e,n as i,v as c,z as n}from"./COH3QXWG.js";import"./R74ZHFA6.js";import"./UZLQALHY.js";var r=a`.actions{display:flex;flex-direction:row;gap:var(--calcite-spacing-xs)}`,t=class extends c{constructor(){super(...arguments),this._messages=o({blocking:!0}),this.feedbackEnabled=!1,this.arcgisFeedback=i()}static{this.properties={feedbackEnabled:5,message:0}}static{this.styles=r}_handleFeedback(s){this.message&&(this.message.feedback=this.message.feedback?.positive===s?void 0:{positive:s},this.arcgisFeedback.emit(this.message),this.requestUpdate())}_getFeedback(){return this.message?.feedback?.positive}_renderThumbsUpButton(){return e`<calcite-action id=action-thumbs-up icon=thumbs-up scale=s .active=${this._getFeedback()===!0} @click=${()=>this._handleFeedback(!0)} text></calcite-action><calcite-tooltip reference-element=action-thumbs-up overlay-positioning=fixed placement=bottom><span>${this._messages.thumbsUpLabel}</span></calcite-tooltip>`}_renderThumbsDownButton(){return e`<calcite-action id=action-thumbs-down icon=thumbs-down scale=s .active=${this._getFeedback()===!1} @click=${()=>this._handleFeedback(!1)} text></calcite-action><calcite-tooltip reference-element=action-thumbs-down overlay-positioning=fixed placement=bottom><span>${this._messages.thumbsDownLabel}</span></calcite-tooltip>`}render(){return this.feedbackEnabled&&!this.message?.error?e`<div class="actions">${this._renderThumbsUpButton()}${this._renderThumbsDownButton()}</div>`:null}};n("arcgis-assistant-message-feedback",t);export{t as ArcgisAssistantMessageFeedback};
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import{b as o}from"./GN56DOYL.js";import"./4YOG5F3W.js";import{g as a,h as e,n as i,v as c,z as n}from"./S5GFNIHC.js";import"./TLPZELG3.js";import"./BVUCNXC5.js";var r=a`.actions{display:flex;flex-direction:row;gap:var(--calcite-spacing-xs)}`,t=class extends c{constructor(){super(...arguments),this._messages=o({blocking:!0}),this.feedbackEnabled=!1,this.arcgisFeedback=i()}static{this.properties={feedbackEnabled:5,message:0}}static{this.styles=r}_handleFeedback(s){this.message&&(this.message.feedback=this.message.feedback?.positive===s?void 0:{positive:s},this.arcgisFeedback.emit(this.message),this.requestUpdate())}_getFeedback(){return this.message?.feedback?.positive}_renderThumbsUpButton(){return e`<calcite-action id=action-thumbs-up icon=thumbs-up scale=s .active=${this._getFeedback()===!0} @click=${()=>this._handleFeedback(!0)} text></calcite-action><calcite-tooltip reference-element=action-thumbs-up overlay-positioning=fixed placement=bottom><span>${this._messages.thumbsUpLabel}</span></calcite-tooltip>`}_renderThumbsDownButton(){return e`<calcite-action id=action-thumbs-down icon=thumbs-down scale=s .active=${this._getFeedback()===!1} @click=${()=>this._handleFeedback(!1)} text></calcite-action><calcite-tooltip reference-element=action-thumbs-down overlay-positioning=fixed placement=bottom><span>${this._messages.thumbsDownLabel}</span></calcite-tooltip>`}render(){return this.feedbackEnabled&&!this.message?.error?e`<div class="actions">${this._renderThumbsUpButton()}${this._renderThumbsDownButton()}</div>`:null}};n("arcgis-assistant-message-feedback",t);export{t as ArcgisAssistantMessageFeedback};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import a from"./ZY3JQCZQ.js";export default $arcgis.t(([{a:i}])=>{var d=(s,e)=>{let n=Array.from(s?.values()??[]).map(({fieldRegistry:r,layerItem:t})=>{let a=Array.from(r.values(),({name:o})=>o);return{title:t.title,description:t.description,fields:a.slice(0,10),additionalFieldCount:Math.max(a.length-10,0)}}),l=(e?.list()??[]).map(({agent:{description:r,id:t,name:a}})=>({id:t,name:a,description:r}));return JSON.stringify({layers:n,agents:l},null,2)},p=({config:s})=>{let e=s?.configurable?.services;return d(e?.layersAndFieldsRegistry,e?.agentRegistry)},c=[async()=>(await import("./BJMGT6GV.js")).default],m=i({id:"help",name:"Help Agent",description:"Answers questions about the current map, its layers and fields, and available assistant capabilities. Use for general help, unsupported map actions, and unrelated requests that should be redirected to map-related questions.",skillLoaders:c,modelTier:"default",systemPrompt:"You are an ArcGIS map help agent.",runtimeContextLoader:p,fallbackMessage:"Help request completed.",failureMessage:"I couldn't complete the help request."});return m},a)
@@ -1,2 +1,2 @@
1
- /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{c as r}from"./RLEHNAIA.js";function s(e,n){return n?typeof n=="string"?l(e,n)??null:n:r(e,"arcgis-map")??null}function c(e,n){return n?typeof n=="string"?l(e,n)??null:n:r(e,"arcgis-link-chart")??r(e,"arcgis-map")??null}function l(e,n){let i=n.includes("#")||n.includes(".")||n.includes("["),t=e.getRootNode();return(i?void 0:t.querySelector(`#${n}`))??t.querySelector(n)??void 0}export{s as a,c as b};
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import{c as r}from"./4YOG5F3W.js";function s(e,n){return n?typeof n=="string"?l(e,n)??null:n:r(e,"arcgis-map")??null}function c(e,n){return n?typeof n=="string"?l(e,n)??null:n:r(e,"arcgis-link-chart")??r(e,"arcgis-map")??null}function l(e,n){let i=n.includes("#")||n.includes(".")||n.includes("["),t=e.getRootNode();return(i?void 0:t.querySelector(`#${n}`))??t.querySelector(n)??void 0}export{s as a,c as b};
@@ -1,2 +1,2 @@
1
- /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
2
  export default $arcgis.t(([F,$])=>{var w=10,N=["string","small-integer","integer"],b=async(l,e,{includeSummaryStatistics:d=!0,includeUniqueValues:f=!0}={})=>{let u=null,i=null;try{if(e.type!=="geometry"&&e.type!=="oid"&&e.type!=="global-id"){d&&(u=await F({layer:l,field:e.name}));let s=e.domain?.type==="coded-value"?e.domain:null;f&&(N.includes(e.type)||s)&&(i=(await $({layer:l,field:e.name})).uniqueValueInfos.sort((n,y)=>y.count-n.count).slice(0,w),s&&(i=i.map(n=>({...n,value:s.getName(n.value)??n.value}))))}}catch(s){console.error(`Error fetching statistics for field ${e.name}:`,s)}return{summaryStatistics:u,uniqueValues:i}};function x(l,e){return["string","small-integer","integer"].includes(l)||e==="coded-value"}async function j(l,e,d,f=!0){let u=[],i=[],s=[];for(let n of l){let y=function(a){let t=e.get(a)?.layerItem;return t?[t.name&&`Name: ${t.name}`,t.title&&`Title: ${t.title}`,t.description&&`Description: ${t.description}`].filter(Boolean).join(" | "):a},{layerId:r,results:I}=n,V=d.map?.allLayers.find(a=>a.id===r),p=e.get(r)?.fieldRegistry;if(!p)continue;let c=u.find(a=>a.layerId===r);c||(c={layerId:r,layerSummary:y(r),fieldInfos:[]},u.push(c));for(let a of I){let t=p.get(a.name);if(!t)continue;let o=t.statistics,g=f&&!o?.summaryStatistics,S=x(t.type,t.domain?.type)&&!o?.uniqueValues,h=g||S;if(s.push({layerId:r,fieldName:t.name,didFetchStatistics:h}),h){let v=b(V,t,{includeSummaryStatistics:g,includeUniqueValues:S}).then(q=>{let m={summaryStatistics:o?.summaryStatistics??null,uniqueValues:o?.uniqueValues??null};g&&(m.summaryStatistics=q.summaryStatistics),S&&(m.uniqueValues=q.uniqueValues),p.set(t.name,{...t,statistics:m}),t.statistics=m});i.push(v)}c.fieldInfos.push(t)}}return await Promise.all(i),{layerFieldInfo:u,didFetchStatistics:i.length>0,fieldStatisticsFetchStatus:s}}return j},"smartMapping/statistics/summaryStatistics","smartMapping/statistics/uniqueValues")
@@ -1,2 +1,2 @@
1
- /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{b as r}from"./6OOZSZRJ.js";import"./RLEHNAIA.js";import{g as a,h as e,n as s,v as c,z as l}from"./COH3QXWG.js";import"./R74ZHFA6.js";import"./UZLQALHY.js";var o=a`:host{padding:var(--calcite-spacing-md);background:var(--calcite-panel-background-color, var(--calcite-color-background))}calcite-panel{border-radius:var(--calcite-dialog-corner-radius, var(--calcite-corner-radius-sm));border:0 solid var(--calcite-color-brand);border-block-start-width:4px;box-shadow:var(--calcite-shadow-md);width:100%;--calcite-panel-border-color: none}.interrupt-content{padding:0 var(--calcite-spacing-md);background:var(--calcite-color-foreground-1)}`,i=class extends c{constructor(){super(...arguments),this._messages=r({blocking:!0}),this._selectedOptions=[],this.arcgisCancel=s(),this.arcgisSubmit=s()}static{this.properties={_selectedOptions:16,type:1,message:1,options:0}}static{this.styles=o}_renderInterruptOptions(){switch(this.type){case"single-select":return e`<calcite-list selection-mode=single-persist .label=${this._messages.optionsLabel} @calciteListChange=${t=>this._selectedOptions=t.target.selectedItems[0]?.value}>${this.options?.map(t=>e`<calcite-list-item .label=${t} .value=${t}></calcite-list-item>`)}</calcite-list>`;case"multi-select":return e`<calcite-list selection-mode=multiple .label=${this._messages.optionsLabel} @calciteListChange=${t=>this._selectedOptions=t.target.selectedItems.map(n=>n.value)}>${this.options?.map(t=>e`<calcite-list-item .label=${t} .value=${t}></calcite-list-item>`)}</calcite-list>`;case"boolean-choice":return null;case"text-input":return e`<calcite-input .label=${this._messages.enterTextLabel} @calciteInputInput=${t=>this._selectedOptions=t.target.value}></calcite-input>`}}render(){return e`<calcite-panel .description=${this.message}><div class="interrupt-content">${this._renderInterruptOptions()}</div>${this.type==="boolean-choice"?e`<calcite-button slot=footer-end appearance=outline @click=${()=>this.arcgisSubmit.emit(!1)}>${this._messages.declineButtonLabel}</calcite-button><calcite-button slot=footer-end appearance=solid @click=${()=>this.arcgisSubmit.emit(!0)}>${this._messages.approveButtonLabel}</calcite-button>`:e`<calcite-button slot=footer-end appearance=outline @click=${()=>this.arcgisCancel.emit()}>${this._messages.cancelButtonLabel}</calcite-button><calcite-button slot=footer-end appearance=solid .disabled=${!this._selectedOptions.length} @click=${()=>this.arcgisSubmit.emit(this._selectedOptions)}>${this._messages.submitButtonLabel}</calcite-button>`}</calcite-panel>`}};l("arcgis-assistant-interrupt",i);export{i as ArcgisAssistantInterrupt};
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import{b as r}from"./GN56DOYL.js";import"./4YOG5F3W.js";import{g as a,h as e,n as s,v as c,z as l}from"./S5GFNIHC.js";import"./TLPZELG3.js";import"./BVUCNXC5.js";var o=a`:host{padding:var(--calcite-spacing-md);background:var(--calcite-panel-background-color, var(--calcite-color-background))}calcite-panel{border-radius:var(--calcite-dialog-corner-radius, var(--calcite-corner-radius-sm));border:0 solid var(--calcite-color-brand);border-block-start-width:4px;box-shadow:var(--calcite-shadow-md);width:100%;--calcite-panel-border-color: none}.interrupt-content{padding:0 var(--calcite-spacing-md);background:var(--calcite-color-foreground-1)}`,i=class extends c{constructor(){super(...arguments),this._messages=r({blocking:!0}),this._selectedOptions=[],this.arcgisCancel=s(),this.arcgisSubmit=s()}static{this.properties={_selectedOptions:16,type:1,message:1,options:0}}static{this.styles=o}_renderInterruptOptions(){switch(this.type){case"single-select":return e`<calcite-list selection-mode=single-persist .label=${this._messages.optionsLabel} @calciteListChange=${t=>this._selectedOptions=t.target.selectedItems[0]?.value}>${this.options?.map(t=>e`<calcite-list-item .label=${t} .value=${t}></calcite-list-item>`)}</calcite-list>`;case"multi-select":return e`<calcite-list selection-mode=multiple .label=${this._messages.optionsLabel} @calciteListChange=${t=>this._selectedOptions=t.target.selectedItems.map(n=>n.value)}>${this.options?.map(t=>e`<calcite-list-item .label=${t} .value=${t}></calcite-list-item>`)}</calcite-list>`;case"boolean-choice":return null;case"text-input":return e`<calcite-input .label=${this._messages.enterTextLabel} @calciteInputInput=${t=>this._selectedOptions=t.target.value}></calcite-input>`}}render(){return e`<calcite-panel .description=${this.message}><div class="interrupt-content">${this._renderInterruptOptions()}</div>${this.type==="boolean-choice"?e`<calcite-button slot=footer-end appearance=outline @click=${()=>this.arcgisSubmit.emit(!1)}>${this._messages.declineButtonLabel}</calcite-button><calcite-button slot=footer-end appearance=solid @click=${()=>this.arcgisSubmit.emit(!0)}>${this._messages.approveButtonLabel}</calcite-button>`:e`<calcite-button slot=footer-end appearance=outline @click=${()=>this.arcgisCancel.emit()}>${this._messages.cancelButtonLabel}</calcite-button><calcite-button slot=footer-end appearance=solid .disabled=${!this._selectedOptions.length} @click=${()=>this.arcgisSubmit.emit(this._selectedOptions)}>${this._messages.submitButtonLabel}</calcite-button>`}</calcite-panel>`}};l("arcgis-assistant-interrupt",i);export{i as ArcgisAssistantInterrupt};
@@ -1,2 +1,2 @@
1
- /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{b as c}from"./6OOZSZRJ.js";import"./RLEHNAIA.js";import{g as i,h as s,n as r,v as a,z as p}from"./COH3QXWG.js";import"./R74ZHFA6.js";import"./UZLQALHY.js";var l=i`:host{display:block;max-width:100%}.group{max-width:100%}.prompt{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-style:normal;cursor:pointer;font-weight:var(--calcite-font-weight-regular)}calcite-chip{max-width:100%}`,e=class extends a{constructor(){super(...arguments),this._messages=c({blocking:!0}),this.prompts=[],this.arcgisPromptSelect=r()}static{this.properties={label:1,prompts:0}}static{this.styles=l}_emitPromptSelect(t){this.arcgisPromptSelect.emit({prompt:t})}render(){return this.prompts.length?s`<calcite-chip-group class="group" .label=${this.label??this._messages.suggestedPromptsLabel}>${this.prompts.map(t=>s`<calcite-chip .value=${t} .label=${t} appearance=outline-fill kind=brand @calciteChipSelect=${()=>this._emitPromptSelect(t)}><div class="prompt">${t}</div></calcite-chip>`)}</calcite-chip-group>`:null}};p("arcgis-assistant-suggested-prompts",e);export{e as ArcgisAssistantSuggestedPrompts};
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import{b as c}from"./GN56DOYL.js";import"./4YOG5F3W.js";import{g as i,h as s,n as r,v as a,z as p}from"./S5GFNIHC.js";import"./TLPZELG3.js";import"./BVUCNXC5.js";var l=i`:host{display:block;max-width:100%}.group{max-width:100%}.prompt{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-style:normal;cursor:pointer;font-weight:var(--calcite-font-weight-regular)}calcite-chip{max-width:100%}`,e=class extends a{constructor(){super(...arguments),this._messages=c({blocking:!0}),this.prompts=[],this.arcgisPromptSelect=r()}static{this.properties={label:1,prompts:0}}static{this.styles=l}_emitPromptSelect(t){this.arcgisPromptSelect.emit({prompt:t})}render(){return this.prompts.length?s`<calcite-chip-group class="group" .label=${this.label??this._messages.suggestedPromptsLabel}>${this.prompts.map(t=>s`<calcite-chip .value=${t} .label=${t} appearance=outline-fill kind=brand @calciteChipSelect=${()=>this._emitPromptSelect(t)}><div class="prompt">${t}</div></calcite-chip>`)}</calcite-chip-group>`:null}};p("arcgis-assistant-suggested-prompts",e);export{e as ArcgisAssistantSuggestedPrompts};
@@ -1,3 +1,3 @@
1
- /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import a from"./HKOGIZDQ.js";import{b as E}from"./R74ZHFA6.js";import{a as p}from"./7VAQUCBU.js";import{Ya as M,a as I,b,ea as $,y as S}from"./EWLXNGKH.js";import{La as k,ea as C,qa as A}from"./AI6DYOKR.js";export default $arcgis.t(([N,P,T,G,z,{a:_,b:D,c:R,e:L,f:W,m:q}])=>{var B=async e=>{let t=await Q(),n=await _("default"),s=P.getDefault(),r=(await N.getCredential(`${s.url}/sharing`)).token,a={type:"generateEmbeddings",webmapEmbeddings:e,auth:{apiUrl:n,token:r}};return t.postMessage(a),await new Promise((i,o)=>{let d=u=>{u.data==="completed"&&(t.removeEventListener("message",d),i())},c=u=>{t.removeEventListener("message",d),o(u instanceof Error?u:new Error("Embeddings worker error"))};t.addEventListener("message",d),t.addEventListener("error",c,{once:!0})}),t},Q=async()=>{{let e=(await import("./OKVLGJAG.js")).default;return new e}},J=e=>{e.currentIntent="none"},K=async(e,t)=>{let n=R(t);if(e.agentExecutionContext.userRequest){let r=new A(e.agentExecutionContext.userRequest.trim());e.agentExecutionContext.messages=[...e.agentExecutionContext.messages,r],J(e)}let s=n?.services.agentRegistry.list().map(r=>r.agent.id)??[];return await p({text:`Available agents: ${[...s].join(", ")}`},t),await p({text:"Analyzing user input"},t),e},V=async(e,t)=>(await p({text:"Exiting..."},t),e),F=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),X=(e,t)=>{if(!F(e)){e!==void 0&&console.warn(`Agent "${t}" returned invalid sharedStatePatch. Ignoring it.`);return}let n={};for(let[s,r]of Object.entries(e)){if(!F(r)||!("value"in r)){console.warn(`Agent "${t}" returned invalid sharedStatePatch entry for key "${s}". Ignoring that entry.`);continue}n[s]={value:r.value}}return n},Y=e=>{let{previousSharedState:t,patch:n,agentId:s}=e;if(!n)return t;let r=Date.now(),a={...t};for(let[i,o]of Object.entries(n))o?.value!==void 0&&(a[i]={value:o.value,meta:{updatedByAgentId:s,updatedAt:r}});return a},Z=256,ee=new Set(["point","polyline","polygon","extent","custom"]),te=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),re=(e,t)=>{if(e===void 0)return;if(!Array.isArray(e)){console.warn(`Agent "${t}" returned invalid sharedResourceAdditions. Ignoring it.`);return}let n=[];for(let[s,r]of e.entries()){if(!te(r)||typeof r.kind!="string"||!ee.has(r.kind)||typeof r.description!="string"||!r.description.trim()||!("payload"in r)||r.payload===void 0){console.warn(`Agent "${t}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`);continue}let a;try{a=structuredClone(r.payload)}catch{console.warn(`Agent "${t}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`);continue}n.push({kind:r.kind,description:r.description.trim().slice(0,Z),payload:a})}return n.length?n:void 0},ne=e=>{let{previousSharedResources:t,additions:n,agentId:s}=e;if(!n?.length)return t;let r=Date.now(),a=n.map(i=>({...i,id:E(),meta:{createdByAgentId:s,createdAt:r}}));return[...t,...a].slice(-50)},j=e=>typeof e!="string"?void 0:e.trim()||void 0,se=e=>{switch(e){case"failed":return"Agent failed without a summary.";case"unknown":return"Agent returned with unknown status.";case"success":return"Agent completed without a summary.";default:return"Agent completed without a summary."}},ae=(e,t)=>{let n=j(t?.outputMessage),s=j(t?.summary),r=t?.status,a=r==="success"||r==="failed"?r:"unknown";a==="unknown"&&console.warn(`Agent "${e}" returned missing/invalid status. Defaulting to "unknown".`);let i=X(t?.sharedStatePatch,e),o=re(t?.sharedResourceAdditions,e);return{outputMessage:n,summary:s??n??se(a),status:a,sharedStatePatch:i,sharedResourceAdditions:o}},H=4e3,ie=async(e,t)=>{let n=R(t);if(t?.signal?.aborted)return await p({text:"Run cancelled; skipping agent execution"},t),{...e,currentIntent:"none",requiresFollowUp:!1};let{agentRegistry:s}=n?.services??{},r=s?.get(e.currentIntent);if(!r)return console.warn(`No agent found for intent: ${e.currentIntent}`),e;await p({text:`Executing registered agent: ${r.agent.name}`},t);let a={...t??{},metadata:{...t?.metadata,agentId:r.agent.id},configurable:{...n??{},agentId:r.agent.id,context:r.getContext?await r.getContext():void 0}},i;try{let c=await r.agent.createGraph().compile().invoke({agentExecutionContext:{...e.agentExecutionContext,messages:[...e.agentExecutionContext.messages],priorSteps:structuredClone(e.agentExecutionContext.priorSteps??[]),sharedState:structuredClone(e.agentExecutionContext.sharedState??{}),sharedResources:structuredClone(e.agentExecutionContext.sharedResources??[])}},a);i=ae(r.agent.name,c),await p({text:`Finished executing registered agent: ${r.agent.name}`},t)}catch(c){if(S(c)||t?.signal?.aborted||c instanceof Error&&c.name==="AbortError")throw c;let u=c instanceof Error?c.message:String(c);console.error(`Agent "${r.agent.name}" failed:`,c),await p({text:`Registered agent failed: ${r.agent.name}. ${u}`},t),i={status:"failed",outputMessage:`Agent execution failed: ${u}`,summary:`Agent execution failed: ${u}`}}let o=i.outputMessage,d=[...e.agentExecutionContext.messages];if(o){let c=o.length>H?`${o.slice(0,H-14)}
3
- [truncated]`:o;d.push(new C(c))}return{...e,stepCount:e.stepCount+1,lastExecutedAgent:r.agent.id,requiresFollowUp:i.status==="failed"?!0:e.requiresFollowUp,finalOutputMessage:o??"",agentExecutionContext:{...e.agentExecutionContext,messages:d,priorSteps:[...e.agentExecutionContext.priorSteps??[],{agentId:r.agent.id,assignedTask:e.agentExecutionContext.assignedTask,summary:i?.summary||"No summary provided.",status:i?.status||"unknown"}],sharedState:Y({previousSharedState:e.agentExecutionContext.sharedState,patch:i.sharedStatePatch,agentId:r.agent.id}),sharedResources:ne({previousSharedResources:e.agentExecutionContext.sharedResources,additions:i.sharedResourceAdditions,agentId:r.agent.id})}}},oe=async(e,t)=>{if(e.routing.mode!=="direct")throw new Error("Direct agent assignment requires direct routing.");return await p({text:`Doing a direct route to agent: ${e.routing.agentId}`},t),{...e,currentIntent:e.routing.agentId,requiresFollowUp:!1,agentExecutionContext:{...e.agentExecutionContext,assignedTask:e.agentExecutionContext.userRequest}}},de=3,ce=e=>e.routing.mode==="direct"?"assignDirectAgent":"intentLLM",ue=e=>e.routing.mode==="direct"||e.stepCount>=de||!e.requiresFollowUp?"exit":"intentLLM",ge=()=>new M(D).addNode("ingestInput",K).addNode("assignDirectAgent",oe).addNode("intentLLM",W).addNode("executeRegisteredAgent",ie).addNode("exit",V).addEdge(I,"ingestInput").addConditionalEdges("ingestInput",ce).addEdge("assignDirectAgent","executeRegisteredAgent").addConditionalEdges("intentLLM",e=>e.currentIntent==="none"||e.currentIntent===e.lastExecutedAgent?"exit":"executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent",ue).addEdge("exit",b),le=(e,t)=>{let n=e.output?.usage_metadata??t.usage_metadata,s=e.output?.llmOutput?.tokenUsage,r=n?.input_tokens??s?.promptTokens,a=n?.output_tokens??s?.completionTokens,i=n?.total_tokens??s?.totalTokens;if(r===void 0||a===void 0||i===void 0)return;let o=n?.input_token_details?.cache_read,d=n?.output_token_details?.reasoning;return{input:r,output:a,total:i,...o!==void 0&&{cacheRead:o},...d!==void 0&&{reasoning:d}}},he=(e,t,n,s)=>{switch(e){case"chat_model":case"llm":return"model";case"tool":case"retriever":return e;case"chain":return!s||t==="LangGraph"?"workflow":n===t?"node":"chain";default:return}},pe=e=>{if(e instanceof Error)return{message:e.message,name:e.name};let t=e,n=typeof t?.message=="string"?t.message:String(e??"Unknown runtime error"),s=typeof t?.name=="string"?t.name:void 0;return{message:n,...s&&{name:s}}},me=({event:e,runId:t,parentSpanId:n,timestamp:s})=>{let r=/^on_(.+)_(start|end|error)$/u.exec(e.event);if(!r)return;let[,a,i]=r,o=e.metadata??{},d=o.langgraph_node,c=he(a,e.name,d,n);if(!c)return;let u=o.agentId,m=o.model??o.ls_model_name,l=e.data,g=i==="end"&&c==="model"?le(l,o):void 0,y=e.tags?.includes("langsmith:hidden")||d==="__start__",h={...m&&{model:m},...g&&{tokenUsage:g},...y&&{internal:!0}},w={id:e.run_id,...n&&{parentId:n},label:e.name,type:c,...Object.keys(h).length&&{metadata:h}},v={runId:t,timestamp:s,type:"runtime",...u&&{agentId:u}};switch(i){case"start":return{...v,phase:"started",span:{...w,...l?.input!==void 0&&{input:l.input}}};case"end":return{...v,phase:"completed",span:{...w,...l?.output!==void 0&&{output:l.output}}};case"error":return{...v,phase:"failed",span:{...w,error:pe(l?.error)}};default:return}},f=class{constructor(){this.agentRegistry=new Map}register(t){let{agent:n}=t;if(this.agentRegistry.has(n.id))throw new Error(`Duplicate agent id: ${n.id}`);this.agentRegistry.set(n.id,t)}get(t){return this.agentRegistry.get(t)}list(){return[...this.agentRegistry.values()]}},x=class{constructor(t,n){this.graph=t,this.config={...n}}async waitForUser(){return await new Promise((t,n)=>{this.resolveWait=t,this.rejectWait=n})}handle(t,n){try{let s={agentId:t.agentId,id:t.id,payload:n},r=this.graph.streamEvents(null,{...this.config,configurable:{...this.config.configurable,hitlResponse:s},subgraphs:!0,version:"v2"});this.resolveWait?.(r)}catch(s){this.rejectWait?.(s)}finally{this.resolveWait=void 0,this.rejectWait=void 0}}cancel(){this.rejectWait&&(this.rejectWait(new Error("Request cancelled by user.")),this.resolveWait=void 0,this.rejectWait=void 0)}},ye=async e=>{try{return await(await L()).embedDocuments(e)}catch(t){throw console.error("Failed to generate embeddings:",t),t}},U=async(e,t)=>{let n=t.get(e);if(n)return n;let s=await ye([e]);return t.set(e,s[0]),s[0]};async function we(e,t,n,s){let r=`req-${Date.now()}`,a={type:"layerSearch",precomputedEmbedding:s?await U(e,s):void 0,requestId:r,minScore:n};return await new Promise(i=>{let o=d=>{d.data.requestId===r&&i(d.data.results)};t.addEventListener("message",o,{once:!0}),t.postMessage(a)})}function fe(e){let{worker:t}=e;return{async searchLayers({text:n,minScore:s,embeddingCache:r}){return await we(n,t,s,r)}}}var ve=async({combinedQuery:e,layerIds:t,embeddingsWorker:n,minScore:s,topResults:r,embeddingCache:a})=>{let i=`req-${Date.now()}`,o=a?await U(e,a):void 0,d={type:"fieldSearch",layerIdForFieldsSearch:t,precomputedEmbedding:o,requestId:i,minScore:s,topResults:r};return await new Promise(c=>{let u=m=>{if(m.data.requestId!==i)return;let l=m.data.results.map(({layerId:g,results:y})=>({layerId:g,results:y}));c(l)};n.addEventListener("message",u,{once:!0}),n.postMessage(d)})};function Ee(e){let{worker:t}=e;return{async searchFields({text:n,layerIds:s,minScore:r,topResults:a,embeddingCache:i}){return await ve({combinedQuery:n,layerIds:s,embeddingsWorker:t,minScore:r,topResults:a,embeddingCache:i})}}}var Re=e=>{let t=q.safeParse(e);if(!t.success)throw new Error("Embeddings response validation failed. Regenerate embeddings.");return t.data},xe=(e,t)=>{let n=new Map,s=new Map;if(t.allLayers.forEach(r=>{r instanceof G&&s.set(r.id,r)}),e.length!==s.size)throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");for(let r of e){let a=s.get(r.id);if(!a)throw new Error(`Layer with ID ${r.id} not found in the original map during registry restoration. Regenerate embeddings.`);if(r.fields.length!==a.fields.length)throw new Error(`Field count mismatch for layer ID ${r.id} during registry restoration. Regenerate embeddings.`);let i={name:r.name,title:r.title,description:r.description},o=new Map;for(let d of r.fields){let c=a.fieldsIndex.get(d.name);if(!c)throw new Error(`Field with name ${d.name} not found in the original layer ${r.id} during registry restoration. Regenerate embeddings.`);o.set(d.name,{name:d.name,alias:a.getFieldAlias(d.name)??d.alias,description:d.description,type:c.type||"unknown",valueType:c.valueType||"unknown",domain:a.getFieldDomain(d.name)??void 0})}n.set(r.id,{layerItem:i,fieldRegistry:o})}return n},Ie=async e=>{try{return(await z(e,{responseType:"json"})).data}catch(t){throw new Error(`Failed to fetch data from ${e}: ${String(t)}`)}},be=async e=>{let t=e.map;if(!t?.portalItem)throw new Error("WebMap portal item is missing.");let{resources:n}=await t.portalItem.fetchResources(),s=n.find(a=>a.resource.path==="embeddings-v01.json");if(!s?.resource.url)throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");let r=await Ie(s.resource.url);return Re(r)},O=class e{constructor(){this.orchestratorReady=!1,this.chatHistory=[],this.priorSteps=[],this.sharedState={},this.sharedResources=[],this.agentRegistry=new f,this.activeRunId="",this.cancelledRunIds=new Set,this.parentRunIds=new Map,this.activeRuntimeSpans=new Map,this.runtimeEventsEnabled=!1,this.streamEpoch=0}static async init(t){let n=new e;n.runtimeEventsEnabled=t.runtimeEventsEnabled??!1;try{if(t.view?.map){await T.whenOnce(()=>t.view.ready);let s=await be(t.view),r=xe(s.layers,t.view.map);n.layersAndFieldsRegistry=r,n.embeddingsWorker=await B(s)}return t.agents?.forEach(s=>{n.agentRegistry.register(s)}),n.orchestratorReady=!0,n}catch(s){throw console.error("Orchestrator initialization failed:",s),s}}async*ask(t,n={}){if(!this.orchestratorReady)throw new Error("Orchestrator is not ready yet.");if(!this.agentRegistry.list().length)throw new Error("Orchestrator has no registered agents.");let s=this.createRequestAgentRegistry(n);if(!s.list().length)throw new Error("Orchestrator has no agents selected for this request.");if(++this.streamEpoch,!t.trim())return;let r=E();this.parentRunIds.clear(),this.activeRuntimeSpans.clear(),this.activeRunId=r,this.activeAbortController=new AbortController,this.graph||(this.graph=ge().compile({checkpointer:new $}));let a=this.embeddingsWorker?fe({worker:this.embeddingsWorker}):void 0,i=this.embeddingsWorker?Ee({worker:this.embeddingsWorker}):void 0,o=new Map,d=n.routing==="direct"?{mode:"direct",agentId:n.agentId}:{mode:"auto"},c={thread_id:r,hitlResponse:null,services:{layerSearch:a,fieldSearch:i,layersAndFieldsRegistry:this.layersAndFieldsRegistry,agentRegistry:s,embeddingCache:o}},u={version:"v2",streamMode:"custom",signal:this.activeAbortController.signal,...this.runtimeEventsEnabled&&{callbacks:[this.createHierarchyCallback()]},configurable:c,subgraphs:!0},m=this.graph?.streamEvents({routing:d,agentExecutionContext:{userRequest:t,messages:this.chatHistory,priorSteps:this.priorSteps,sharedState:this.sharedState,sharedResources:this.sharedResources}},u),l=++this.streamEpoch;if(yield*this.pipeStream(m,l,r),this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}for(;;){if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}let y=(await this.graph.getState(u,{subgraphs:!0})).tasks.find(h=>h.interrupts.length>0)?.interrupts[0]?.value;if(!y)break;this.currentInterrupt=y,this.interruptHandler=new x(this.graph,u),yield*this.closeActiveRuntimeSpans(r,"interrupted"),yield{runId:r,timestamp:Date.now(),type:"interrupt",interrupt:y};try{let h=await this.interruptHandler.waitForUser(),w=++this.streamEpoch;yield*this.pipeStream(h,w,r)}catch(h){if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}if(h){yield{runId:r,timestamp:Date.now(),type:"error",error:{message:h?.message}};return}}}if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}let g=(await this.graph.getState(u,{subgraphs:!0})).values;if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}this.chatHistory=g.agentExecutionContext.messages.length?g.agentExecutionContext.messages:this.chatHistory,this.priorSteps=g.agentExecutionContext.priorSteps?.slice(-5)??[],this.sharedState=g.agentExecutionContext.sharedState??{},this.sharedResources=g.agentExecutionContext.sharedResources??[],yield{runId:r,timestamp:Date.now(),type:"completed",result:{content:g.finalOutputMessage}}}newConversation(){this.chatHistory=[],this.priorSteps=[],this.sharedState={},this.sharedResources=[]}resumeInterrupt(t){if(!this.currentInterrupt||!this.interruptHandler)throw new Error("No pending interrupt to resume.");this.interruptHandler.handle(this.currentInterrupt,t)}cancelInterrupt(){this.interruptHandler&&this.interruptHandler.cancel()}cancel(){this.activeRunId&&(this.cancelledRunIds.add(this.activeRunId),this.activeAbortController?.abort(),++this.streamEpoch,this.interruptHandler?.cancel())}async*pipeStream(t,n,s){try{for await(let r of t){if(this.isRunCancelled(s)||n!==this.streamEpoch)break;if(this.runtimeEventsEnabled){let a=me({event:r,runId:s,parentSpanId:this.parentRunIds.get(r.run_id),timestamp:Date.now()});a&&(a.phase==="started"?this.activeRuntimeSpans.set(a.span.id,a):this.activeRuntimeSpans.delete(a.span.id),yield a)}r.event==="on_custom_event"&&r.name==="trace_message"?yield{runId:s,timestamp:Date.now(),type:"trace",data:r.data}:r.name==="graph_ux_suggestion"&&(yield{runId:s,timestamp:Date.now(),type:"ux-suggestion",suggestion:r.data})}}catch(r){if(!this.isRunCancelled(s))throw r}}*createCancellationEvents(t){yield*this.closeActiveRuntimeSpans(t,"cancelled"),yield{runId:t,timestamp:Date.now(),type:"cancelled",reason:"user"}}*closeActiveRuntimeSpans(t,n){let s=Date.now(),r=[...this.activeRuntimeSpans.values()].reverse();this.activeRuntimeSpans.clear();for(let a of r){let{input:i,...o}=a.span;yield{type:"runtime",phase:n,runId:t,timestamp:s,...a.agentId&&{agentId:a.agentId},span:o}}}createHierarchyCallback(){let t=(n,s)=>{s&&this.parentRunIds.set(n,s)};return k.fromMethods({handleLLMStart:(n,s,r,a)=>t(r,a),handleChatModelStart:(n,s,r,a)=>t(r,a),handleChainStart:(n,s,r,a)=>t(r,a),handleToolStart:(n,s,r,a)=>t(r,a),handleRetrieverStart:(n,s,r,a)=>t(r,a)})}isRunCancelled(t){return this.cancelledRunIds.has(t)}createRequestAgentRegistry(t){let n=t.routing==="direct"?[t.agentId]:t.agentIds,s=n?n.map(a=>{let i=this.agentRegistry.get(a);if(!i)throw new Error(`Agent is not registered: ${a}`);return i}):this.agentRegistry.list(),r=new f;return s.forEach(a=>r.register(a)),r}dispose(){this.sharedResources=[],this.embeddingsWorker&&(this.embeddingsWorker.terminate(),this.embeddingsWorker=void 0),this.orchestratorReady=!1}};return{a:ye,b:O}},"identity/IdentityManager","portal/Portal","core/reactiveUtils","layers/FeatureLayer","request",a)
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import a from"./2LVYAXHG.js";import{b as E}from"./TLPZELG3.js";import{a as p}from"./V52GSTOC.js";import{P as M,Ya as D,ea as _,r as k,s as $}from"./ZJWR4W2S.js";import{Ia as S,ca as I,ta as b}from"./M2U456J5.js";export default $arcgis.t(([N,P,T,G,z,{a:C,c:A,d:W,e:R,f:L,m:q}])=>{var B=async e=>{let t=await Q(),n=await C("default"),s=P.getDefault(),r=(await N.getCredential(`${s.url}/sharing`)).token,a={type:"generateEmbeddings",webmapEmbeddings:e,auth:{apiUrl:n,token:r}};return t.postMessage(a),await new Promise((i,o)=>{let d=u=>{u.data==="completed"&&(t.removeEventListener("message",d),i())},c=u=>{t.removeEventListener("message",d),o(u instanceof Error?u:new Error("Embeddings worker error"))};t.addEventListener("message",d),t.addEventListener("error",c,{once:!0})}),t},Q=async()=>{{let e=(await import("./ZA7ZU2F7.js")).default;return new e}},J=e=>{e.currentIntent="none"},K=async(e,t)=>{let n=R(t);if(e.agentExecutionContext.userRequest){let r=new I(e.agentExecutionContext.userRequest.trim());e.agentExecutionContext.messages=[...e.agentExecutionContext.messages,r],J(e)}let s=n?.services.agentRegistry.list().map(r=>r.agent.id)??[];return await p({text:`Available agents: ${[...s].join(", ")}`},t),await p({text:"Analyzing user input"},t),e},V=async(e,t)=>(await p({text:"Exiting..."},t),e),F=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),X=(e,t)=>{if(!F(e)){e!==void 0&&console.warn(`Agent "${t}" returned invalid sharedStatePatch. Ignoring it.`);return}let n={};for(let[s,r]of Object.entries(e)){if(!F(r)||!("value"in r)){console.warn(`Agent "${t}" returned invalid sharedStatePatch entry for key "${s}". Ignoring that entry.`);continue}n[s]={value:r.value}}return n},Y=e=>{let{previousSharedState:t,patch:n,agentId:s}=e;if(!n)return t;let r=Date.now(),a={...t};for(let[i,o]of Object.entries(n))o?.value!==void 0&&(a[i]={value:o.value,meta:{updatedByAgentId:s,updatedAt:r}});return a},Z=256,ee=new Set(["point","polyline","polygon","extent","custom"]),te=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),re=(e,t)=>{if(e===void 0)return;if(!Array.isArray(e)){console.warn(`Agent "${t}" returned invalid sharedResourceAdditions. Ignoring it.`);return}let n=[];for(let[s,r]of e.entries()){if(!te(r)||typeof r.kind!="string"||!ee.has(r.kind)||typeof r.description!="string"||!r.description.trim()||!("payload"in r)||r.payload===void 0){console.warn(`Agent "${t}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`);continue}let a;try{a=structuredClone(r.payload)}catch{console.warn(`Agent "${t}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`);continue}n.push({kind:r.kind,description:r.description.trim().slice(0,Z),payload:a})}return n.length?n:void 0},ne=e=>{let{previousSharedResources:t,additions:n,agentId:s}=e;if(!n?.length)return t;let r=Date.now(),a=n.map(i=>({...i,id:E(),meta:{createdByAgentId:s,createdAt:r}}));return[...t,...a].slice(-50)},H=e=>typeof e!="string"?void 0:e.trim()||void 0,se=e=>{switch(e){case"failed":return"Agent failed without a summary.";case"unknown":return"Agent returned with unknown status.";case"success":return"Agent completed without a summary.";default:return"Agent completed without a summary."}},ae=(e,t)=>{let n=H(t?.outputMessage),s=H(t?.summary),r=t?.status,a=r==="success"||r==="failed"?r:"unknown";a==="unknown"&&console.warn(`Agent "${e}" returned missing/invalid status. Defaulting to "unknown".`);let i=X(t?.sharedStatePatch,e),o=re(t?.sharedResourceAdditions,e);return{outputMessage:n,summary:s??n??se(a),status:a,sharedStatePatch:i,sharedResourceAdditions:o}},j=4e3,ie=async(e,t)=>{let n=R(t);if(t?.signal?.aborted)return await p({text:"Run cancelled; skipping agent execution"},t),{...e,currentIntent:"none",requiresFollowUp:!1};let{agentRegistry:s}=n?.services??{},r=s?.get(e.currentIntent);if(!r)return console.warn(`No agent found for intent: ${e.currentIntent}`),e;await p({text:`Executing registered agent: ${r.agent.name}`},t);let a={...t??{},metadata:{...t?.metadata,agentId:r.agent.id},configurable:{...n??{},agentId:r.agent.id,context:r.getContext?await r.getContext():void 0}},i;try{let c=await r.agent.createGraph().compile().invoke({agentExecutionContext:{...e.agentExecutionContext,messages:[...e.agentExecutionContext.messages],priorSteps:structuredClone(e.agentExecutionContext.priorSteps??[]),sharedState:structuredClone(e.agentExecutionContext.sharedState??{}),sharedResources:structuredClone(e.agentExecutionContext.sharedResources??[])}},a);i=ae(r.agent.name,c),await p({text:`Finished executing registered agent: ${r.agent.name}`},t)}catch(c){if(M(c)||t?.signal?.aborted||c instanceof Error&&c.name==="AbortError")throw c;let u=c instanceof Error?c.message:String(c);console.error(`Agent "${r.agent.name}" failed:`,c),await p({text:`Registered agent failed: ${r.agent.name}. ${u}`},t),i={status:"failed",outputMessage:`Agent execution failed: ${u}`,summary:`Agent execution failed: ${u}`}}let o=i.outputMessage,d=[...e.agentExecutionContext.messages];if(o){let c=o.length>j?`${o.slice(0,j-14)}
3
+ [truncated]`:o;d.push(new b(c))}return{...e,stepCount:e.stepCount+1,lastExecutedAgent:r.agent.id,requiresFollowUp:i.status==="failed"?!0:e.requiresFollowUp,finalOutputMessage:o??"",agentExecutionContext:{...e.agentExecutionContext,messages:d,priorSteps:[...e.agentExecutionContext.priorSteps??[],{agentId:r.agent.id,assignedTask:e.agentExecutionContext.assignedTask,summary:i?.summary||"No summary provided.",status:i?.status||"unknown"}],sharedState:Y({previousSharedState:e.agentExecutionContext.sharedState,patch:i.sharedStatePatch,agentId:r.agent.id}),sharedResources:ne({previousSharedResources:e.agentExecutionContext.sharedResources,additions:i.sharedResourceAdditions,agentId:r.agent.id})}}},oe=async(e,t)=>{if(e.routing.mode!=="direct")throw new Error("Direct agent assignment requires direct routing.");return await p({text:`Doing a direct route to agent: ${e.routing.agentId}`},t),{...e,currentIntent:e.routing.agentId,requiresFollowUp:!1,agentExecutionContext:{...e.agentExecutionContext,assignedTask:e.agentExecutionContext.userRequest}}},de=3,ce=e=>e.routing.mode==="direct"?"assignDirectAgent":"intentLLM",ue=e=>e.routing.mode==="direct"||e.stepCount>=de||!e.requiresFollowUp?"exit":"intentLLM",ge=()=>new D(W).addNode("ingestInput",K).addNode("assignDirectAgent",oe).addNode("intentLLM",L).addNode("executeRegisteredAgent",ie).addNode("exit",V).addEdge(k,"ingestInput").addConditionalEdges("ingestInput",ce).addEdge("assignDirectAgent","executeRegisteredAgent").addConditionalEdges("intentLLM",e=>e.currentIntent==="none"||e.currentIntent===e.lastExecutedAgent?"exit":"executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent",ue).addEdge("exit",$),le=(e,t)=>{let n=e.output?.usage_metadata??t.usage_metadata,s=e.output?.llmOutput?.tokenUsage,r=n?.input_tokens??s?.promptTokens,a=n?.output_tokens??s?.completionTokens,i=n?.total_tokens??s?.totalTokens;if(r===void 0||a===void 0||i===void 0)return;let o=n?.input_token_details?.cache_read,d=n?.output_token_details?.reasoning;return{input:r,output:a,total:i,...o!==void 0&&{cacheRead:o},...d!==void 0&&{reasoning:d}}},he=(e,t,n,s)=>{switch(e){case"chat_model":case"llm":return"model";case"tool":case"retriever":return e;case"chain":return!s||t==="LangGraph"?"workflow":n===t?"node":"chain";default:return}},pe=e=>{if(e instanceof Error)return{message:e.message,name:e.name};let t=e,n=typeof t?.message=="string"?t.message:String(e??"Unknown runtime error"),s=typeof t?.name=="string"?t.name:void 0;return{message:n,...s&&{name:s}}},me=({event:e,runId:t,parentSpanId:n,timestamp:s})=>{let r=/^on_(.+)_(start|end|error)$/u.exec(e.event);if(!r)return;let[,a,i]=r,o=e.metadata??{},d=o.langgraph_node,c=he(a,e.name,d,n);if(!c)return;let u=o.agentId,m=o.model??o.ls_model_name,l=e.data,g=i==="end"&&c==="model"?le(l,o):void 0,y=e.tags?.includes("langsmith:hidden")||d==="__start__",h={...m&&{model:m},...g&&{tokenUsage:g},...y&&{internal:!0}},w={id:e.run_id,...n&&{parentId:n},label:e.name,type:c,...Object.keys(h).length&&{metadata:h}},v={runId:t,timestamp:s,type:"runtime",...u&&{agentId:u}};switch(i){case"start":return{...v,phase:"started",span:{...w,...l?.input!==void 0&&{input:l.input}}};case"end":return{...v,phase:"completed",span:{...w,...l?.output!==void 0&&{output:l.output}}};case"error":return{...v,phase:"failed",span:{...w,error:pe(l?.error)}};default:return}},f=class{constructor(){this.agentRegistry=new Map}register(t){let{agent:n}=t;if(this.agentRegistry.has(n.id))throw new Error(`Duplicate agent id: ${n.id}`);this.agentRegistry.set(n.id,t)}get(t){return this.agentRegistry.get(t)}list(){return[...this.agentRegistry.values()]}},x=class{constructor(t,n){this.graph=t,this.config={...n}}async waitForUser(){return await new Promise((t,n)=>{this.resolveWait=t,this.rejectWait=n})}handle(t,n){try{let s={agentId:t.agentId,id:t.id,payload:n},r=this.graph.streamEvents(null,{...this.config,configurable:{...this.config.configurable,hitlResponse:s},subgraphs:!0,version:"v2"});this.resolveWait?.(r)}catch(s){this.rejectWait?.(s)}finally{this.resolveWait=void 0,this.rejectWait=void 0}}cancel(){this.rejectWait&&(this.rejectWait(new Error("Request cancelled by user.")),this.resolveWait=void 0,this.rejectWait=void 0)}},ye=async e=>{try{return await(await A()).embedDocuments(e)}catch(t){throw console.error("Failed to generate embeddings:",t),t}},U=async(e,t)=>{let n=t.get(e);if(n)return n;let s=await ye([e]);return t.set(e,s[0]),s[0]};async function we(e,t,n,s){let r=`req-${Date.now()}`,a={type:"layerSearch",precomputedEmbedding:s?await U(e,s):void 0,requestId:r,minScore:n};return await new Promise(i=>{let o=d=>{d.data.requestId===r&&i(d.data.results)};t.addEventListener("message",o,{once:!0}),t.postMessage(a)})}function fe(e){let{worker:t}=e;return{async searchLayers({text:n,minScore:s,embeddingCache:r}){return await we(n,t,s,r)}}}var ve=async({combinedQuery:e,layerIds:t,embeddingsWorker:n,minScore:s,topResults:r,embeddingCache:a})=>{let i=`req-${Date.now()}`,o=a?await U(e,a):void 0,d={type:"fieldSearch",layerIdForFieldsSearch:t,precomputedEmbedding:o,requestId:i,minScore:s,topResults:r};return await new Promise(c=>{let u=m=>{if(m.data.requestId!==i)return;let l=m.data.results.map(({layerId:g,results:y})=>({layerId:g,results:y}));c(l)};n.addEventListener("message",u,{once:!0}),n.postMessage(d)})};function Ee(e){let{worker:t}=e;return{async searchFields({text:n,layerIds:s,minScore:r,topResults:a,embeddingCache:i}){return await ve({combinedQuery:n,layerIds:s,embeddingsWorker:t,minScore:r,topResults:a,embeddingCache:i})}}}var Re=e=>{let t=q.safeParse(e);if(!t.success)throw new Error("Embeddings response validation failed. Regenerate embeddings.");return t.data},xe=(e,t)=>{let n=new Map,s=new Map;if(t.allLayers.forEach(r=>{r instanceof G&&s.set(r.id,r)}),e.length!==s.size)throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");for(let r of e){let a=s.get(r.id);if(!a)throw new Error(`Layer with ID ${r.id} not found in the original map during registry restoration. Regenerate embeddings.`);if(r.fields.length!==a.fields.length)throw new Error(`Field count mismatch for layer ID ${r.id} during registry restoration. Regenerate embeddings.`);let i={name:r.name,title:r.title,description:r.description},o=new Map;for(let d of r.fields){let c=a.fieldsIndex.get(d.name);if(!c)throw new Error(`Field with name ${d.name} not found in the original layer ${r.id} during registry restoration. Regenerate embeddings.`);o.set(d.name,{name:d.name,alias:a.getFieldAlias(d.name)??d.alias,description:d.description,type:c.type||"unknown",valueType:c.valueType||"unknown",domain:a.getFieldDomain(d.name)??void 0})}n.set(r.id,{layerItem:i,fieldRegistry:o})}return n},Ie=async e=>{try{return(await z(e,{responseType:"json"})).data}catch(t){throw new Error(`Failed to fetch data from ${e}: ${String(t)}`)}},be=async e=>{let t=e.map;if(!t?.portalItem)throw new Error("WebMap portal item is missing.");let{resources:n}=await t.portalItem.fetchResources(),s=n.find(a=>a.resource.path==="embeddings-v01.json");if(!s?.resource.url)throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");let r=await Ie(s.resource.url);return Re(r)},O=class e{constructor(){this.orchestratorReady=!1,this.chatHistory=[],this.priorSteps=[],this.sharedState={},this.sharedResources=[],this.agentRegistry=new f,this.activeRunId="",this.cancelledRunIds=new Set,this.parentRunIds=new Map,this.activeRuntimeSpans=new Map,this.runtimeEventsEnabled=!1,this.streamEpoch=0}static async init(t){let n=new e;n.runtimeEventsEnabled=t.runtimeEventsEnabled??!1;try{if(t.view?.map){await T.whenOnce(()=>t.view.ready);let s=await be(t.view),r=xe(s.layers,t.view.map);n.layersAndFieldsRegistry=r,n.embeddingsWorker=await B(s)}return t.agents?.forEach(s=>{n.agentRegistry.register(s)}),n.orchestratorReady=!0,n}catch(s){throw console.error("Orchestrator initialization failed:",s),s}}async*ask(t,n={}){if(!this.orchestratorReady)throw new Error("Orchestrator is not ready yet.");if(!this.agentRegistry.list().length)throw new Error("Orchestrator has no registered agents.");let s=this.createRequestAgentRegistry(n);if(!s.list().length)throw new Error("Orchestrator has no agents selected for this request.");if(++this.streamEpoch,!t.trim())return;let r=E();this.parentRunIds.clear(),this.activeRuntimeSpans.clear(),this.activeRunId=r,this.activeAbortController=new AbortController,this.graph||(this.graph=ge().compile({checkpointer:new _}));let a=this.embeddingsWorker?fe({worker:this.embeddingsWorker}):void 0,i=this.embeddingsWorker?Ee({worker:this.embeddingsWorker}):void 0,o=new Map,d=n.routing==="direct"?{mode:"direct",agentId:n.agentId}:{mode:"auto"},c={thread_id:r,hitlResponse:null,services:{layerSearch:a,fieldSearch:i,layersAndFieldsRegistry:this.layersAndFieldsRegistry,agentRegistry:s,embeddingCache:o}},u={version:"v2",streamMode:"custom",signal:this.activeAbortController.signal,...this.runtimeEventsEnabled&&{callbacks:[this.createHierarchyCallback()]},configurable:c,subgraphs:!0},m=this.graph?.streamEvents({routing:d,agentExecutionContext:{userRequest:t,messages:this.chatHistory,priorSteps:this.priorSteps,sharedState:this.sharedState,sharedResources:this.sharedResources}},u),l=++this.streamEpoch;if(yield*this.pipeStream(m,l,r),this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}for(;;){if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}let y=(await this.graph.getState(u,{subgraphs:!0})).tasks.find(h=>h.interrupts.length>0)?.interrupts[0]?.value;if(!y)break;this.currentInterrupt=y,this.interruptHandler=new x(this.graph,u),yield*this.closeActiveRuntimeSpans(r,"interrupted"),yield{runId:r,timestamp:Date.now(),type:"interrupt",interrupt:y};try{let h=await this.interruptHandler.waitForUser(),w=++this.streamEpoch;yield*this.pipeStream(h,w,r)}catch(h){if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}if(h){yield{runId:r,timestamp:Date.now(),type:"error",error:{message:h?.message}};return}}}if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}let g=(await this.graph.getState(u,{subgraphs:!0})).values;if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}this.chatHistory=g.agentExecutionContext.messages.length?g.agentExecutionContext.messages:this.chatHistory,this.priorSteps=g.agentExecutionContext.priorSteps?.slice(-5)??[],this.sharedState=g.agentExecutionContext.sharedState??{},this.sharedResources=g.agentExecutionContext.sharedResources??[],yield{runId:r,timestamp:Date.now(),type:"completed",result:{content:g.finalOutputMessage}}}newConversation(){this.chatHistory=[],this.priorSteps=[],this.sharedState={},this.sharedResources=[]}resumeInterrupt(t){if(!this.currentInterrupt||!this.interruptHandler)throw new Error("No pending interrupt to resume.");this.interruptHandler.handle(this.currentInterrupt,t)}cancelInterrupt(){this.interruptHandler&&this.interruptHandler.cancel()}cancel(){this.activeRunId&&(this.cancelledRunIds.add(this.activeRunId),this.activeAbortController?.abort(),++this.streamEpoch,this.interruptHandler?.cancel())}async*pipeStream(t,n,s){try{for await(let r of t){if(this.isRunCancelled(s)||n!==this.streamEpoch)break;if(this.runtimeEventsEnabled){let a=me({event:r,runId:s,parentSpanId:this.parentRunIds.get(r.run_id),timestamp:Date.now()});a&&(a.phase==="started"?this.activeRuntimeSpans.set(a.span.id,a):this.activeRuntimeSpans.delete(a.span.id),yield a)}r.event==="on_custom_event"&&r.name==="trace_message"?yield{runId:s,timestamp:Date.now(),type:"trace",data:r.data}:r.name==="graph_ux_suggestion"&&(yield{runId:s,timestamp:Date.now(),type:"ux-suggestion",suggestion:r.data})}}catch(r){if(!this.isRunCancelled(s))throw r}}*createCancellationEvents(t){yield*this.closeActiveRuntimeSpans(t,"cancelled"),yield{runId:t,timestamp:Date.now(),type:"cancelled",reason:"user"}}*closeActiveRuntimeSpans(t,n){let s=Date.now(),r=[...this.activeRuntimeSpans.values()].reverse();this.activeRuntimeSpans.clear();for(let a of r){let{input:i,...o}=a.span;yield{type:"runtime",phase:n,runId:t,timestamp:s,...a.agentId&&{agentId:a.agentId},span:o}}}createHierarchyCallback(){let t=(n,s)=>{s&&this.parentRunIds.set(n,s)};return S.fromMethods({handleLLMStart:(n,s,r,a)=>t(r,a),handleChatModelStart:(n,s,r,a)=>t(r,a),handleChainStart:(n,s,r,a)=>t(r,a),handleToolStart:(n,s,r,a)=>t(r,a),handleRetrieverStart:(n,s,r,a)=>t(r,a)})}isRunCancelled(t){return this.cancelledRunIds.has(t)}createRequestAgentRegistry(t){let n=t.routing==="direct"?[t.agentId]:t.agentIds,s=n?n.map(a=>{let i=this.agentRegistry.get(a);if(!i)throw new Error(`Agent is not registered: ${a}`);return i}):this.agentRegistry.list(),r=new f;return s.forEach(a=>r.register(a)),r}dispose(){this.sharedResources=[],this.embeddingsWorker&&(this.embeddingsWorker.terminate(),this.embeddingsWorker=void 0),this.orchestratorReady=!1}};return{a:ye,b:O}},"identity/IdentityManager","portal/Portal","core/reactiveUtils","layers/FeatureLayer","request",a)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import c from"./XVJFPZTW.js";import b from"./KKCLHXHG.js";import"./LLY5A2E2.js";import a from"./VGLBH473.js";import"./A6LBMS7A.js";import"./M2U456J5.js";import"./5X23DDDZ.js";import"./CSE6BHOJ.js";import"./BVUCNXC5.js";export default $arcgis.t(([,,a])=>{return a},a,b,c)
@@ -1,5 +1,5 @@
1
- /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import"./UZLQALHY.js";var e=`# ArcGIS Knowledge Graph Cypher Rules
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import"./BVUCNXC5.js";var e=`# ArcGIS Knowledge Graph Cypher Rules
3
3
 
4
4
  ## GOAL
5
5
 
@@ -1,5 +1,5 @@
1
- /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import"./UZLQALHY.js";var e=`## Navigation Agent - Tool Intent Classifier
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import"./BVUCNXC5.js";var e=`## Navigation Agent - Tool Intent Classifier
3
3
 
4
4
  You are an assistant that classifies the assigned task intent for navigation agent.
5
5
 
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import c from"./SBNNJ5WA.js";import"./XNUWVZN7.js";import b from"./EGRRZTF6.js";import"./2WXXSZP5.js";import a from"./2LVYAXHG.js";import"./4OI4QEV7.js";import"./TLPZELG3.js";import"./V52GSTOC.js";import"./4VBOTWC3.js";import"./477I66FH.js";import"./ZJWR4W2S.js";import"./M2U456J5.js";import"./5X23DDDZ.js";import"./CSE6BHOJ.js";import"./BVUCNXC5.js";export default $arcgis.t(([,,a])=>{return a},a,b,c)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import n from"./NV7CL4S3.js";import m from"./ZY3JQCZQ.js";import{a as o,c as p}from"./SNG3WODY.js";import"./M5B6X46F.js";import l from"./VK6CCPTG.js";import"./LXIKAXUT.js";import k from"./M3KKORBG.js";import j from"./3PPXAIRE.js";import h from"./XVJFPZTW.js";import g from"./YOW3YKWR.js";import f from"./KKCLHXHG.js";import"./LLY5A2E2.js";import"./X42ACC66.js";import"./V4PJMCJZ.js";import e from"./EK3PM4L5.js";import"./T6W6F4TF.js";import"./CKUUYQLO.js";import d from"./KBSXHSBX.js";import"./275FFTBE.js";import"./TFAJNKBC.js";import"./HV7MVIQV.js";import"./OALQBAZR.js";import"./4YOG5F3W.js";import c from"./2LVYAXHG.js";import"./4OI4QEV7.js";import"./SJMAKF4P.js";import"./TXZQZR3I.js";import b from"./STOGCXJH.js";import a from"./VGLBH473.js";import"./A6LBMS7A.js";import{v as i,z as r}from"./S5GFNIHC.js";import"./TLPZELG3.js";import"./V52GSTOC.js";import"./477I66FH.js";import"./ZJWR4W2S.js";import"./M2U456J5.js";import"./5X23DDDZ.js";import"./CSE6BHOJ.js";import"./BVUCNXC5.js";export default $arcgis.t(([,,,,,,,,,,,,,,,,,,,,,,m])=>{var t=class extends i{constructor(){super(...arguments),this.agent=m}static{this.properties={referenceElement:1}}#t;#i;getContext(){if(!this.#t)throw new Error("arcgis-assistant-help-agent requires a mapView");return{mapView:this.#t}}load(){this.#t=o(this,"arcgis-assistant-help-agent"),this.#i=p(this)}disconnectedCallback(){this.#i?.unregister(this.agent.id),super.disconnectedCallback()}};r("arcgis-assistant-help-agent",t);return t},"identity/IdentityManager","portal/Portal","request","config","core/reactiveUtils","layers/FeatureLayer","intl","smartMapping/statistics/summaryStatistics","smartMapping/statistics/uniqueValues","rest/knowledgeGraphService",a,b,c,d,e,f,g,h,j,k,l,m,n)