@arcgis/ai-components 5.2.0-next.24 → 5.2.0-next.26

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