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

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