@arcgis/ai-components 5.2.0-next.23 → 5.2.0-next.25

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