@arcgis/ai-components 5.1.0-next.127 → 5.1.0-next.128

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