@esri/solutions-components 5.1.0-next.168 → 5.1.0-next.169

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 (97) hide show
  1. package/dist/cdn/{MXF4BYLT.js → 6F7QJJQO.js} +1 -1
  2. package/dist/cdn/{BU6BDYWD.js → CONTIW5Q.js} +4 -4
  3. package/dist/cdn/{YPBSKBT2.js → D6U5SMQX.js} +1 -1
  4. package/dist/cdn/{2LCG2XWX.js → ESJJVBZM.js} +1 -1
  5. package/dist/cdn/{ZWL4JFKS.js → IZSQYFWM.js} +1 -1
  6. package/dist/cdn/{BYOO7TWU.js → JINR6G2D.js} +1 -1
  7. package/dist/cdn/{CVHZAZLS.js → RLMMQ5UC.js} +1 -1
  8. package/dist/cdn/{UOQSRV3X.js → S26SZJC7.js} +3 -2
  9. package/dist/cdn/{LXGPZJIZ.js → S7HFWITF.js} +1 -1
  10. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.ar.json +1 -1
  11. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.bg.json +1 -1
  12. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.bs.json +1 -1
  13. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.ca.json +1 -1
  14. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.cs.json +1 -1
  15. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.da.json +1 -1
  16. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.de.json +1 -1
  17. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.el.json +1 -1
  18. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.es.json +1 -1
  19. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.et.json +1 -1
  20. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.fi.json +1 -1
  21. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.fr.json +1 -1
  22. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.he.json +1 -1
  23. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.hr.json +1 -1
  24. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.hu.json +1 -1
  25. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.id.json +1 -1
  26. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.it.json +1 -1
  27. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.ja.json +1 -1
  28. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.ko.json +1 -1
  29. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.lt.json +1 -1
  30. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.lv.json +1 -1
  31. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.nl.json +1 -1
  32. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.no.json +1 -1
  33. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.pl.json +1 -1
  34. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.pt-BR.json +1 -1
  35. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.pt-PT.json +1 -1
  36. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.ro.json +1 -1
  37. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.ru.json +1 -1
  38. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.sk.json +1 -1
  39. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.sl.json +1 -1
  40. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.sr.json +1 -1
  41. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.sv.json +1 -1
  42. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.th.json +1 -1
  43. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.tr.json +1 -1
  44. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.uk.json +1 -1
  45. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.vi.json +1 -1
  46. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.zh-CN.json +1 -1
  47. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.zh-HK.json +1 -1
  48. package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.zh-TW.json +1 -1
  49. package/dist/cdn/assets/solution-details-card/t9n/messages.ar.json +1 -1
  50. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.ar.json +1 -1
  51. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.bg.json +1 -1
  52. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.bs.json +1 -1
  53. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.ca.json +1 -1
  54. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.cs.json +1 -1
  55. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.da.json +1 -1
  56. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.de.json +1 -1
  57. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.el.json +1 -1
  58. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.es.json +1 -1
  59. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.et.json +1 -1
  60. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.fi.json +1 -1
  61. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.fr.json +1 -1
  62. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.he.json +1 -1
  63. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.hr.json +1 -1
  64. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.hu.json +1 -1
  65. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.id.json +1 -1
  66. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.it.json +1 -1
  67. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.ja.json +1 -1
  68. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.ko.json +1 -1
  69. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.lt.json +1 -1
  70. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.lv.json +1 -1
  71. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.nl.json +1 -1
  72. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.no.json +1 -1
  73. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.pl.json +1 -1
  74. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.pt-BR.json +1 -1
  75. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.pt-PT.json +1 -1
  76. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.ro.json +1 -1
  77. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.ru.json +1 -1
  78. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.sk.json +1 -1
  79. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.sl.json +1 -1
  80. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.sr.json +1 -1
  81. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.sv.json +1 -1
  82. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.th.json +1 -1
  83. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.tr.json +1 -1
  84. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.uk.json +1 -1
  85. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.vi.json +1 -1
  86. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.zh-CN.json +1 -1
  87. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.zh-HK.json +1 -1
  88. package/dist/cdn/assets/solutions-deploy-app/t9n/messages.zh-TW.json +1 -1
  89. package/dist/cdn/index.js +1 -1
  90. package/dist/chunks/assessBuildRequest.js +3 -2
  91. package/dist/chunks/converter.js +1 -1
  92. package/dist/components/arcgis-solutions-assistant/customElement.js +307 -289
  93. package/dist/docs/api.json +1 -1
  94. package/dist/docs/docs.json +1 -1
  95. package/dist/docs/web-types.json +1 -1
  96. package/dist/solutions-components_commit.txt +6 -6
  97. package/package.json +1 -1
@@ -5,19 +5,19 @@ import { LitElement as De, createEvent as ae, nothing as re } from "@arcgis/lumi
5
5
  import { css as Me, html as T } from "lit";
6
6
  import { unsafeHTML as Re } from "lit/directives/unsafe-html.js";
7
7
  import { useContextConsumer as le } from "@arcgis/lumina/context";
8
- import { c as Be, b as Pe } from "../../chunks/deployAppContexts.js";
8
+ import { c as Pe, b as Be } from "../../chunks/deployAppContexts.js";
9
9
  import { T as M } from "../../chunks/interfaces.js";
10
10
  import { m as qe } from "../../chunks/helpers.js";
11
11
  import G from "@arcgis/core/config.js";
12
12
  import { createRef as Ue, ref as Oe } from "lit-html/directives/ref.js";
13
- import { Annotation as x, StateGraph as K, START as W, END as A, NodeInterrupt as de } from "@langchain/langgraph/web";
14
- import { createAgentRuntimeState as X, sendTraceMessage as _, invokeStructuredPrompt as k, getEmbeddings as ze, cosineSimilarity as je, invokeTextPrompt as Ge } from "@arcgis/ai-components/utils/index.js";
13
+ import { Annotation as b, StateGraph as K, START as W, END as A, NodeInterrupt as de } from "@langchain/langgraph/web";
14
+ import { createAgentRuntimeState as X, sendTraceMessage as w, invokeStructuredPrompt as $, getEmbeddings as ze, cosineSimilarity as je, invokeTextPrompt as Ge } from "@arcgis/ai-components/utils/index.js";
15
15
  import l, { z as E } from "zod";
16
16
  import * as Y from "@esri/arcgis-rest-portal";
17
- import { applyPatch as He } from "fast-json-patch";
17
+ import { applyPatch as Je } from "fast-json-patch";
18
18
  import "@langchain/core/messages";
19
19
  import { C as pe } from "../../chunks/converter.js";
20
- import { v as H, b as J, S as Je, h as Ve, E as Qe, g as Ke } from "../../chunks/validators.js";
20
+ import { v as J, b as H, S as He, h as Ve, E as Qe, g as Ke } from "../../chunks/validators.js";
21
21
  import { invokeStructuredPrompt as We } from "@arcgis/ai-orchestrator";
22
22
  import { t as me, g as q, c as he, r as ge, d as F } from "../../chunks/templates.js";
23
23
  import Xe from "@arcgis/core/portal/Portal.js";
@@ -87,14 +87,14 @@ function st(s) {
87
87
  function it(s, e) {
88
88
  const t = [];
89
89
  return (e?.configurable?.context?.configContext.allCards ?? []).forEach((n) => {
90
- const o = n.title;
91
- if (!o)
90
+ const a = n.title;
91
+ if (!a)
92
92
  return;
93
- const a = new RegExp(`(?<![\\p{L}\\p{N}])${o}(?![\\p{L}\\p{N}])`, "giu");
93
+ const o = new RegExp(`(?<![\\p{L}\\p{N}])${a}(?![\\p{L}\\p{N}])`, "giu");
94
94
  let r = !1;
95
- s = s.replace(a, (c, d, h) => {
95
+ s = s.replace(o, (c, d, h) => {
96
96
  const y = h.slice(0, d);
97
- return /<img[^>]*alt\s*=\s*["'][^"']*$/i.test(y) ? c : (r = !0, `<a href="" target="solutionId:${n.deployCommonId}">${o}</a>`);
97
+ return /<img[^>]*alt\s*=\s*["'][^"']*$/i.test(y) ? c : (r = !0, `<a href="" target="solutionId:${n.deployCommonId}">${a}</a>`);
98
98
  }), r && t.push({
99
99
  solution: {
100
100
  title: n.title,
@@ -131,38 +131,38 @@ async function at(s, e) {
131
131
  if (!i || n.length <= 1 || i === "explorer")
132
132
  return t;
133
133
  try {
134
- const o = await v(be, "transformQuery"), a = await k({
135
- promptText: o,
134
+ const a = await v(be, "transformQuery"), o = await $({
135
+ promptText: a,
136
136
  modelTier: "advanced",
137
137
  temperature: 0,
138
138
  schema: et,
139
139
  messages: n.slice(-11),
140
140
  inputVariables: { query: t, lastTurnAgent: i }
141
141
  });
142
- if (a.needsContext && a.rewrittenQuery.trim())
143
- return console.debug(`Rephrased query from "${t}" to "${a.rewrittenQuery.trim()}"`), a.rewrittenQuery.trim();
142
+ if (o.needsContext && o.rewrittenQuery.trim())
143
+ return console.debug(`Rephrased query from "${t}" to "${o.rewrittenQuery.trim()}"`), o.rewrittenQuery.trim();
144
144
  } catch {
145
145
  }
146
146
  return t;
147
147
  }
148
- const rt = x.Root({
148
+ const rt = b.Root({
149
149
  // Provides agentExecutionContext, outputMessage, summary, and status
150
150
  // channels with the orchestrator's standard reducers/defaults so the
151
151
  // sub-agent reports back through the same shape the orchestrator
152
152
  // persists into priorSteps.
153
153
  ...X(),
154
- solutionResponse: x({
154
+ solutionResponse: b({
155
155
  reducer: (s, e) => e ?? null,
156
156
  default: () => null
157
157
  }),
158
- documentSkillUrl: x({
158
+ documentSkillUrl: b({
159
159
  reducer: (s, e) => e ?? null,
160
160
  default: () => null
161
161
  }),
162
162
  // Persisted across turns via the graph checkpointer so follow-up questions
163
163
  // continue the same service conversation. Null on the very first interaction
164
164
  // or after messages are cleared.
165
- conversationId: x({
165
+ conversationId: b({
166
166
  reducer: (s, e) => e ?? s,
167
167
  default: () => null
168
168
  })
@@ -170,7 +170,7 @@ const rt = x.Root({
170
170
  if (!s) return;
171
171
  const n = xe(s);
172
172
  if (!n) return;
173
- const a = { context: {
173
+ const o = { context: {
174
174
  kind: "DocAIAssistantRequest",
175
175
  filters: {
176
176
  products: "ArcGIS Solutions",
@@ -180,20 +180,20 @@ const rt = x.Root({
180
180
  }
181
181
  }
182
182
  } };
183
- i && (a.conversationId = i), Q(a, n, e ?? "");
183
+ i && (o.conversationId = i), Q(o, n, e ?? "");
184
184
  }, ct = async (s, e) => {
185
185
  if (ce(e))
186
186
  return {};
187
187
  const t = U(e), i = s.documentSkillUrl;
188
188
  let n = [];
189
- const o = await at(s, e);
190
- await _(
189
+ const a = await at(s, e);
190
+ await w(
191
191
  { text: t.agentProgress.explorerAgentSearching },
192
192
  e
193
193
  );
194
- let a = await Q(
194
+ let o = await Q(
195
195
  {
196
- message: o,
196
+ message: a,
197
197
  conversationId: e?.configurable?.context?.convoId ?? void 0,
198
198
  context: {
199
199
  kind: "DocAIAssistantRequest",
@@ -209,13 +209,13 @@ const rt = x.Root({
209
209
  i,
210
210
  e?.configurable?.context?.token ?? ""
211
211
  );
212
- a.conversationId && e?.configurable?.context?.setConversationId && e.configurable.context.setConversationId(a.conversationId);
212
+ o.conversationId && e?.configurable?.context?.setConversationId && e.configurable.context.setConversationId(o.conversationId);
213
213
  let r = {
214
- message: a.message,
215
- conversationId: a.conversationId,
216
- hasMore: a.hasMore,
217
- ackSequenceNumber: a.sequenceNumber,
218
- inquiryId: a.inquiryId
214
+ message: o.message,
215
+ conversationId: o.conversationId,
216
+ hasMore: o.hasMore,
217
+ ackSequenceNumber: o.sequenceNumber,
218
+ inquiryId: o.inquiryId
219
219
  }, c = "";
220
220
  const d = async (y) => {
221
221
  const u = y.context?.results?.[0]?.reply ?? "";
@@ -231,13 +231,13 @@ const rt = x.Root({
231
231
  const g = y.context?.results?.[0]?.status?.currentStatusStep;
232
232
  if (g) {
233
233
  let S = "";
234
- g === 1 ? S = t.agentProgress.explorerAgentReading : g === 2 ? S = t.agentProgress.explorerAgentReviewing : g === 3 && (S = t.agentProgress.explorerAgentPreparing), await _({ text: S }, e);
234
+ g === 1 ? S = t.agentProgress.explorerAgentReading : g === 2 ? S = t.agentProgress.explorerAgentReviewing : g === 3 && (S = t.agentProgress.explorerAgentPreparing), await w({ text: S }, e);
235
235
  }
236
236
  };
237
- for (await d(a); r.hasMore; ) {
237
+ for (await d(o); r.hasMore; ) {
238
238
  if (ce(e))
239
239
  return {};
240
- await ot(500), a = await Q(
240
+ await ot(500), o = await Q(
241
241
  {
242
242
  conversationId: r.conversationId,
243
243
  ackSequenceNumber: r.ackSequenceNumber,
@@ -246,12 +246,12 @@ const rt = x.Root({
246
246
  i,
247
247
  e?.configurable?.context?.token ?? ""
248
248
  ), r = {
249
- message: a.message,
250
- conversationId: a.conversationId,
251
- hasMore: a.hasMore,
252
- ackSequenceNumber: a.sequenceNumber,
253
- inquiryId: a.inquiryId
254
- }, await d(a);
249
+ message: o.message,
250
+ conversationId: o.conversationId,
251
+ hasMore: o.hasMore,
252
+ ackSequenceNumber: o.sequenceNumber,
253
+ inquiryId: o.inquiryId
254
+ }, await d(o);
255
255
  }
256
256
  return xe(e?.configurable?.context.portal) && ve(
257
257
  e?.configurable?.context.portal,
@@ -272,7 +272,7 @@ const rt = x.Root({
272
272
  };
273
273
  };
274
274
  await v(be, "solutions_explorer_description");
275
- const we = (s) => {
275
+ const _e = (s) => {
276
276
  if (s && Array.isArray(s.id) && s.id.length > 0)
277
277
  return s.id[s.id.length - 1].replace("Message", "").toLowerCase();
278
278
  if (s && typeof s._getType == "function")
@@ -283,7 +283,7 @@ const we = (s) => {
283
283
  }
284
284
  return "human";
285
285
  }, dt = (s) => {
286
- const e = we(s);
286
+ const e = _e(s);
287
287
  if (s && s.kwargs)
288
288
  return {
289
289
  role: e,
@@ -298,10 +298,10 @@ const we = (s) => {
298
298
  return s.id && (t.id = s.id), s.name && (t.name = s.name), s.additional_kwargs && (t.additional_kwargs = s.additional_kwargs), s.response_metadata && (t.response_metadata = s.response_metadata), t;
299
299
  }
300
300
  return { role: "human", content: String(s) };
301
- }, pt = (s) => we(s) === "human", mt = (s, e = 3) => s.filter((t) => pt(t)).slice(-e).map(dt), ht = (s, e = " ") => mt(s).map((n) => n.content).join(e).trim(), gt = { understandingRequest: "Understanding your request...", selectTemplatePrompt: "This use case could be supported in a few different ways. Choose the option that best matches what you want to accomplish.", searchingExistingSolutions: "Searching for existing solutions...", existingSolutionMatch: "I found one or more existing solutions that match your use case. These are ready-to-use solutions that may already meet your needs and can be deployed now. Do you want to continue building your own solution?", continueBuildingYes: "Yes, I want to build a new solution", continueBuildingNo: "No, I’ll review existing solutions", continueBuildingDeclined: "Sounds good. We can focus on existing solutions. Let me know if I can help answer any questions or provide more details.", creatingDesign: "Generating solution design...", updatingDesign: "Updating solution design...", applyChangeFailed: "I wasn't able to apply that change. The design was not modified. Please try rephrasing your request.", createDesignFailed: "I wasn't able to create a solution design from that request. Please try rephrasing and try again.", discardMessage: "Are you sure you want to discard your solution?", discardForNewSolution: "I can help you build a new solution, but I will need to discard your current solution design. Do you want to continue?" }, ft = {
301
+ }, pt = (s) => _e(s) === "human", mt = (s, e = 3) => s.filter((t) => pt(t)).slice(-e).map(dt), ht = (s, e = " ") => mt(s).map((n) => n.content).join(e).trim(), gt = { understandingRequest: "Understanding your request...", selectTemplatePrompt: "This use case could be supported in a few different ways. Choose the option that best matches what you want to accomplish.", searchingExistingSolutions: "Searching for existing solutions...", existingSolutionMatch: "I found one or more existing solutions that match your use case. These are ready-to-use solutions that may already meet your needs and can be deployed now. Do you want to continue building your own solution?", continueBuildingYes: "Yes, I want to build a new solution", continueBuildingNo: "No, I’ll review existing solutions", continueBuildingDeclined: "Sounds good. We can focus on existing solutions. Let me know if I can help answer any questions or provide more details.", creatingDesign: "Generating solution design...", updatingDesign: "Updating solution design...", applyChangeFailed: "I wasn't able to apply that change. The design was not modified. Please try rephrasing your request.", createDesignFailed: "I wasn't able to create a solution design from that request. Please try rephrasing and try again.", discardMessage: "Are you sure you want to discard your solution?", discardForNewSolution: "I can help you build a new solution, but I will need to discard your current solution design. Do you want to continue?" }, ft = {
302
302
  builderMessages: gt
303
303
  };
304
- class b {
304
+ class x {
305
305
  //--------------------------------------------------------------------------
306
306
  //
307
307
  // Public API
@@ -319,9 +319,6 @@ class b {
319
319
  static {
320
320
  this.DESCRIPTION_MAX_LENGTH = 2048;
321
321
  }
322
- static {
323
- this.SERVICE_NAME_MAX_LENGTH = 100;
324
- }
325
322
  static {
326
323
  this.FIELD_NAME_MAX_LENGTH = 31;
327
324
  }
@@ -362,8 +359,8 @@ class b {
362
359
  for (const n of this.response.solution.strings) {
363
360
  if (n.value)
364
361
  continue;
365
- const o = t.get(n.key)?.value;
366
- this.newDesign && o ? (n.value = o, this._logAutoFix(`String key '${n.key}' had no value. Auto-fixed by restoring the template value.`)) : this._logIssue(`String key '${n.key}' has no value in the design. It must be populated.`);
362
+ const a = t.get(n.key)?.value;
363
+ this.newDesign && a ? (n.value = a, this._logAutoFix(`String key '${n.key}' had no value. Auto-fixed by restoring the template value.`)) : this._logIssue(`String key '${n.key}' has no value in the design. It must be populated.`);
367
364
  }
368
365
  }
369
366
  /**
@@ -395,23 +392,23 @@ class b {
395
392
  * any other user-edited properties on the item.
396
393
  */
397
394
  _reconcileItems() {
398
- const e = new Set(this.template.items.map((a) => a.id)), t = new Set(this.response.items.map((a) => a.id)), i = [...t].filter((a) => !e.has(a)), n = [...e].filter((a) => !t.has(a));
395
+ const e = new Set(this.template.items.map((o) => o.id)), t = new Set(this.response.items.map((o) => o.id)), i = [...t].filter((o) => !e.has(o)), n = [...e].filter((o) => !t.has(o));
399
396
  if (e.size === t.size && i.length === 1 && n.length === 1) {
400
- const a = i[0], r = n[0], c = this.response.items.find((d) => d.id === a);
397
+ const o = i[0], r = n[0], c = this.response.items.find((d) => d.id === o);
401
398
  if (c) {
402
- c.id = r, this._logAutoFix(`Item id '${a}' did not match the template id '${r}'. Auto-fixed in place.`);
399
+ c.id = r, this._logAutoFix(`Item id '${o}' did not match the template id '${r}'. Auto-fixed in place.`);
403
400
  return;
404
401
  }
405
402
  }
406
- i.length && (this.response.items = this.response.items.filter((a) => e.has(a.id)), this._logAutoFix(`Removed items not present in the template: ${i.join(", ")}.`));
407
- const o = this.template.items.filter((a) => !t.has(a.id));
408
- if (o.length) {
403
+ i.length && (this.response.items = this.response.items.filter((o) => e.has(o.id)), this._logAutoFix(`Removed items not present in the template: ${i.join(", ")}.`));
404
+ const a = this.template.items.filter((o) => !t.has(o.id));
405
+ if (a.length) {
409
406
  this.response.items = [
410
- ...o.map((a) => ({ ...a })),
407
+ ...a.map((o) => ({ ...o })),
411
408
  ...this.response.items
412
409
  ];
413
- for (const a of o)
414
- this._logAutoFix(`Item '${a.id}' was missing from the design. Auto-fixed by adding it from the template.`);
410
+ for (const o of a)
411
+ this._logAutoFix(`Item '${o.id}' was missing from the design. Auto-fixed by adding it from the template.`);
415
412
  }
416
413
  }
417
414
  /**
@@ -424,22 +421,22 @@ class b {
424
421
  t.itemId = e.itemId, this._logAutoFix(`Feature Layer itemId '${i}' did not match the template. Auto-fixed to '${e.itemId}'.`);
425
422
  }
426
423
  if (!e.addLayers) {
427
- const i = new Set(e.layers.map((o) => o.id)), n = new Set(t.layers.map((o) => o.id));
428
- if (!(i.size === n.size && [...i].every((o) => n.has(o))))
424
+ const i = new Set(e.layers.map((a) => a.id)), n = new Set(t.layers.map((a) => a.id));
425
+ if (!(i.size === n.size && [...i].every((a) => n.has(a))))
429
426
  this._logIssue(`Feature Layer '${e.itemId}' had its layer ids altered.`);
430
427
  else
431
- for (const o of e.layers) {
432
- if (o.type) {
433
- const r = t.layers.find((c) => c.id === o.id);
434
- if (r && r.type !== o.type)
428
+ for (const a of e.layers) {
429
+ if (a.type) {
430
+ const r = t.layers.find((c) => c.id === a.id);
431
+ if (r && r.type !== a.type)
435
432
  if (this.newDesign) {
436
433
  const c = r.type;
437
- r.type = o.type, this._logAutoFix(`Layer '${o.id}' type '${c}' is immutable. Auto-fixed back to template type '${o.type}'.`);
434
+ r.type = a.type, this._logAutoFix(`Layer '${a.id}' type '${c}' is immutable. Auto-fixed back to template type '${a.type}'.`);
438
435
  } else
439
- this._logIssue(`Layer '${o.id}' type '${r.type}' does not match template type '${o.type}'. This layer type is immutable.`);
436
+ this._logIssue(`Layer '${a.id}' type '${r.type}' does not match template type '${a.type}'. This layer type is immutable.`);
440
437
  }
441
- const a = t.layers.find((r) => r.id === o.id);
442
- a && this._validateRequiredFields(a, o);
438
+ const o = t.layers.find((r) => r.id === a.id);
439
+ o && this._validateRequiredFields(o, a);
443
440
  }
444
441
  }
445
442
  }
@@ -456,12 +453,12 @@ class b {
456
453
  e.requiredFields.map((n) => [n.name.toLowerCase(), n])
457
454
  );
458
455
  for (const n of t.requiredFields) {
459
- const o = i.get(n.name.toLowerCase());
460
- if (!o) {
456
+ const a = i.get(n.name.toLowerCase());
457
+ if (!a) {
461
458
  this.newDesign ? (e.requiredFields.push({ ...n }), this._logAutoFix(`Layer '${e.name}' was missing required field '${n.name}'. Auto-fixed by re-adding it from the template.`)) : this._logIssue(`Layer '${e.name}' is missing required field '${n.name}'.`);
462
459
  continue;
463
460
  }
464
- this._enforceRequiredFieldImmutability(e, o, n);
461
+ this._enforceRequiredFieldImmutability(e, a, n);
465
462
  }
466
463
  }
467
464
  /**
@@ -473,8 +470,8 @@ class b {
473
470
  const n = [];
474
471
  if (t.type !== i.type && n.push("type"), (t.length ?? null) !== (i.length ?? null) && n.push("length"), this._choiceListsEqual(t.choiceList, i.choiceList) || n.push("choiceList"), !n.length)
475
472
  return;
476
- const o = n.length === 1 ? "property" : "properties";
477
- this.newDesign ? (t.type = i.type, t.length = i.length, t.choiceList = Array.isArray(i.choiceList) ? [...i.choiceList] : i.choiceList ?? null, this._logAutoFix(`Layer '${e.name}' required field '${i.name}' changed immutable ${o} (${n.join(", ")}). Auto-fixed by reverting to the template.`)) : this._logIssue(`Layer '${e.name}' required field '${i.name}' changed immutable ${o} (${n.join(", ")}). These cannot be modified.`);
473
+ const a = n.length === 1 ? "property" : "properties";
474
+ this.newDesign ? (t.type = i.type, t.length = i.length, t.choiceList = Array.isArray(i.choiceList) ? [...i.choiceList] : i.choiceList ?? null, this._logAutoFix(`Layer '${e.name}' required field '${i.name}' changed immutable ${a} (${n.join(", ")}). Auto-fixed by reverting to the template.`)) : this._logIssue(`Layer '${e.name}' required field '${i.name}' changed immutable ${a} (${n.join(", ")}). These cannot be modified.`);
478
475
  }
479
476
  /**
480
477
  * Set-based equality check for two choiceList values (order-insensitive),
@@ -486,8 +483,8 @@ class b {
486
483
  return !0;
487
484
  if (i === null || n === null)
488
485
  return !1;
489
- const o = new Set(i), a = new Set(n);
490
- return o.size === a.size && [...o].every((r) => a.has(r));
486
+ const a = new Set(i), o = new Set(n);
487
+ return a.size === o.size && [...a].every((r) => o.has(r));
491
488
  }
492
489
  //--------------------------------------------------------------------------
493
490
  //
@@ -500,39 +497,29 @@ class b {
500
497
  _validateSolutionProps() {
501
498
  const e = this.response.solution.title ?? "", t = this.response.solution.description, i = /[/\\]/u.test(e), n = this.newDesign ? e.replace(/[/\\]/gu, "") : e;
502
499
  this.newDesign && n !== e ? (this.response.solution.title = n, this._logAutoFix("Solution title contained forward or back slashes. Auto-fixed by removing them.")) : !this.newDesign && i && this._logIssue("Solution title contains forbidden forward or back slashes.");
503
- const o = H(n);
504
- if (o.isValid || this._tryFixName(o.errorType, n, (a) => {
505
- this.response.solution.title = a;
506
- }, "Solution title", "Solution Title") || this._logIssue(`Solution title is invalid (${o.errorType}).`), t) {
507
- const a = J(t, b.DESCRIPTION_MAX_LENGTH, !0);
508
- a.isValid || this._tryFixDescription(t, (r) => {
500
+ const a = J(n);
501
+ if (a.isValid || this._tryFixName(a.errorType, n, (o) => {
502
+ this.response.solution.title = o;
503
+ }, "Solution title", "Solution Title") || this._logIssue(`Solution title is invalid (${a.errorType}).`), t) {
504
+ const o = H(t, x.DESCRIPTION_MAX_LENGTH, !0);
505
+ o.isValid || this._tryFixDescription(t, (r) => {
509
506
  this.response.solution.description = r;
510
- }, "Solution description") || this._logIssue(`Solution description is invalid (${a.errorType}).`);
507
+ }, "Solution description") || this._logIssue(`Solution description is invalid (${o.errorType}).`);
511
508
  }
512
509
  }
513
510
  /**
514
511
  * Validates all items in the response.
515
512
  */
516
513
  _validateItems() {
517
- const e = /* @__PURE__ */ new Set([
518
- "Feature Layer (hosted)",
519
- "Feature Layer (hosted, view)"
520
- ]);
521
- for (const t of this.response.items) {
522
- if (e.has(t.type) && t.title.length > b.SERVICE_NAME_MAX_LENGTH)
523
- if (this.newDesign) {
524
- const n = t.title;
525
- t.title = t.title.slice(0, b.SERVICE_NAME_MAX_LENGTH).trim(), this._logAutoFix(`Service name '${n}' exceeded ${b.SERVICE_NAME_MAX_LENGTH} characters. Auto-fixed to '${t.title}'.`);
526
- } else
527
- this._logIssue(`Service name '${t.title}' exceeds 100 characters.`);
528
- const i = H(t.title ?? "");
529
- if (i.isValid || this._tryFixName(i.errorType, t.title ?? "", (n) => {
530
- t.title = n;
531
- }, `Item '${t.id}' title`, "Item Title") || this._logIssue(`Item '${t.id}' title is invalid (${i.errorType}).`), t.description) {
532
- const n = J(t.description, b.DESCRIPTION_MAX_LENGTH, !0);
533
- n.isValid || this._tryFixDescription(t.description, (o) => {
534
- t.description = o;
535
- }, `Item '${t.id}' description`) || this._logIssue(`Item '${t.id}' description is invalid (${n.errorType}).`);
514
+ for (const e of this.response.items) {
515
+ const t = J(e.title ?? "");
516
+ if (t.isValid || this._tryFixName(t.errorType, e.title ?? "", (i) => {
517
+ e.title = i;
518
+ }, `Item '${e.id}' title`, "Item Title") || this._logIssue(`Item '${e.id}' title is invalid (${t.errorType}).`), e.description) {
519
+ const i = H(e.description, x.DESCRIPTION_MAX_LENGTH, !0);
520
+ i.isValid || this._tryFixDescription(e.description, (n) => {
521
+ e.description = n;
522
+ }, `Item '${e.id}' description`) || this._logIssue(`Item '${e.id}' description is invalid (${i.errorType}).`);
536
523
  }
537
524
  }
538
525
  }
@@ -554,8 +541,8 @@ class b {
554
541
  for (const i of e) {
555
542
  const n = (i.name ?? "").toLowerCase();
556
543
  if (t.has(n)) {
557
- const o = i.name;
558
- i.name = this._makeUniqueName(i.name ?? "Layer", t), this._logAutoFix(`Duplicate layer name '${o}'. Auto-fixed to '${i.name}'.`);
544
+ const a = i.name;
545
+ i.name = this._makeUniqueName(i.name ?? "Layer", t), this._logAutoFix(`Duplicate layer name '${a}'. Auto-fixed to '${i.name}'.`);
559
546
  }
560
547
  t.add(i.name.toLowerCase());
561
548
  }
@@ -567,13 +554,13 @@ class b {
567
554
  !t && e.typeMutable === !0 && e.type === "Table" && (this.newDesign ? (e.type = "Point", this._logAutoFix(`Layer '${e.name}' cannot be a Table. Auto-fixed to 'Point'.`)) : this._logIssue(
568
555
  `Layer '${e.name}' cannot be a Table. It may be a Point, Line, or Polygon.`
569
556
  ));
570
- const i = H(e.name ?? "");
557
+ const i = J(e.name ?? "");
571
558
  if (i.isValid || this._tryFixName(i.errorType, e.name ?? "", (n) => {
572
559
  e.name = n;
573
560
  }, `Layer '${e.name}' name`, "Layer Title") || this._logIssue(`Layer '${e.name}' name is invalid (${i.errorType}).`), e.description) {
574
- const n = J(e.description, b.DESCRIPTION_MAX_LENGTH, !0);
575
- n.isValid || this._tryFixDescription(e.description, (o) => {
576
- e.description = o;
561
+ const n = H(e.description, x.DESCRIPTION_MAX_LENGTH, !0);
562
+ n.isValid || this._tryFixDescription(e.description, (a) => {
563
+ e.description = a;
577
564
  }, `Layer '${e.name}' description`) || this._logIssue(`Layer '${e.name}' description is invalid (${n.errorType}).`);
578
565
  }
579
566
  this._validateLayerFields(e);
@@ -590,23 +577,23 @@ class b {
590
577
  _validateLayerFields(e) {
591
578
  const t = e.systemFields ?? [];
592
579
  this.fieldNameRegistry = new Set(
593
- [...e.customFields, ...e.requiredFields, ...t].map((o) => o.name.toLowerCase())
580
+ [...e.customFields, ...e.requiredFields, ...t].map((a) => a.name.toLowerCase())
594
581
  );
595
- for (const o of [...e.customFields, ...e.requiredFields])
596
- this._validateField(o);
582
+ for (const a of [...e.customFields, ...e.requiredFields])
583
+ this._validateField(a);
597
584
  this.fieldNameRegistry = null;
598
- const i = new Set(e.requiredFields.map((o) => o.name.toLowerCase())), n = new Set(i);
599
- for (const o of e.customFields) {
600
- const a = o.name.toLowerCase();
601
- if (n.has(a)) {
602
- const r = i.has(a) ? "a required field name" : "another field with the same name";
585
+ const i = new Set(e.requiredFields.map((a) => a.name.toLowerCase())), n = new Set(i);
586
+ for (const a of e.customFields) {
587
+ const o = a.name.toLowerCase();
588
+ if (n.has(o)) {
589
+ const r = i.has(o) ? "a required field name" : "another field with the same name";
603
590
  if (this.newDesign) {
604
- const c = o.name;
605
- o.name = this._makeUniqueName(o.name, n), this._logAutoFix(`Layer '${e.name}' field '${c}' collided with ${r}. Auto-fixed to '${o.name}'.`);
591
+ const c = a.name;
592
+ a.name = this._makeUniqueName(a.name, n), this._logAutoFix(`Layer '${e.name}' field '${c}' collided with ${r}. Auto-fixed to '${a.name}'.`);
606
593
  } else
607
- this._logIssue(`Layer '${e.name}' field '${o.name}' collides with ${r}.`);
594
+ this._logIssue(`Layer '${e.name}' field '${a.name}' collides with ${r}.`);
608
595
  }
609
- n.add(o.name.toLowerCase());
596
+ n.add(a.name.toLowerCase());
610
597
  }
611
598
  }
612
599
  /**
@@ -615,36 +602,36 @@ class b {
615
602
  _validateField(e) {
616
603
  const t = /^\p{L}/u, i = /^.[\p{L}\p{M}\p{N}_]*$/u;
617
604
  e.alias || (this.newDesign ? (e.alias = e.name, this._logAutoFix(`Field '${e.name}' had no display name (alias). Auto-fixed to '${e.alias}'.`)) : this._logIssue(`Field '${e.name}' has no display name (alias).`));
618
- const n = t.test(e.name), o = i.test(e.name);
619
- if (!n || !o)
605
+ const n = t.test(e.name), a = i.test(e.name);
606
+ if (!n || !a)
620
607
  if (this.newDesign) {
621
- const a = e.name;
622
- e.name = this._makeUniqueName(this._sanitizeFieldName(e.name), this.fieldNameRegistry), this.fieldNameRegistry.add(e.name.toLowerCase()), this._logAutoFix(`Field '${a}' had an invalid name. Auto-fixed to '${e.name}'.`);
608
+ const o = e.name;
609
+ e.name = this._makeUniqueName(this._sanitizeFieldName(e.name), this.fieldNameRegistry), this.fieldNameRegistry.add(e.name.toLowerCase()), this._logAutoFix(`Field '${o}' had an invalid name. Auto-fixed to '${e.name}'.`);
623
610
  } else
624
- n || this._logIssue(`Field '${e.name}' does not start with a letter.`), o || this._logIssue(
611
+ n || this._logIssue(`Field '${e.name}' does not start with a letter.`), a || this._logIssue(
625
612
  `Field '${e.name}' contains invalid characters (only letters from any writing system, numbers, and underscores are allowed; emojis and punctuation are not allowed).`
626
613
  );
627
- if (e.name.length > b.FIELD_NAME_MAX_LENGTH)
614
+ if (e.name.length > x.FIELD_NAME_MAX_LENGTH)
628
615
  if (this.newDesign) {
629
- const a = e.name;
630
- e.name = this._getUniqueTruncatedFieldName(e.name, this.fieldNameRegistry), this.fieldNameRegistry.add(e.name.toLowerCase()), this._logAutoFix(`Field '${a}' exceeds ${b.FIELD_NAME_MAX_LENGTH} characters. Auto-fixing to '${e.name}'.`);
616
+ const o = e.name;
617
+ e.name = this._getUniqueTruncatedFieldName(e.name, this.fieldNameRegistry), this.fieldNameRegistry.add(e.name.toLowerCase()), this._logAutoFix(`Field '${o}' exceeds ${x.FIELD_NAME_MAX_LENGTH} characters. Auto-fixing to '${e.name}'.`);
631
618
  } else
632
- this._logIssue(`Field '${e.name}' exceeds ${b.FIELD_NAME_MAX_LENGTH} characters.`);
633
- if (Je.has(e.name.toLowerCase()))
619
+ this._logIssue(`Field '${e.name}' exceeds ${x.FIELD_NAME_MAX_LENGTH} characters.`);
620
+ if (He.has(e.name.toLowerCase()))
634
621
  if (this.newDesign) {
635
- const a = e.name;
636
- e.name = this._getUniqueTruncatedFieldName(a, this.fieldNameRegistry), this.fieldNameRegistry.add(e.name.toLowerCase()), this._logAutoFix(`Field '${a}' is a SQL reserved keyword. Auto-fixing to '${e.name}'.`);
622
+ const o = e.name;
623
+ e.name = this._getUniqueTruncatedFieldName(o, this.fieldNameRegistry), this.fieldNameRegistry.add(e.name.toLowerCase()), this._logAutoFix(`Field '${o}' is a SQL reserved keyword. Auto-fixing to '${e.name}'.`);
637
624
  } else
638
625
  this._logIssue(`Field '${e.name}' is a SQL reserved keyword.`);
639
626
  if (Ve.has(e.name.toLowerCase()))
640
627
  if (this.newDesign) {
641
- const a = e.name;
642
- e.name = this._getUniqueTruncatedFieldName(a, this.fieldNameRegistry), this.fieldNameRegistry.add(e.name.toLowerCase()), this._logAutoFix(`Field '${a}' is a reserved system field name. Auto-fixing to '${e.name}'.`);
628
+ const o = e.name;
629
+ e.name = this._getUniqueTruncatedFieldName(o, this.fieldNameRegistry), this.fieldNameRegistry.add(e.name.toLowerCase()), this._logAutoFix(`Field '${o}' is a reserved system field name. Auto-fixing to '${e.name}'.`);
643
630
  } else
644
631
  this._logIssue(`Field '${e.name}' is a reserved system field name.`);
645
632
  if (Array.isArray(e.choiceList) && e.type !== "string" && (this.newDesign ? e.choiceList.length ? (e.type = "string", this._logAutoFix(`Field '${e.name}' had a domain but was not of type 'string'. Auto-fixed by setting the type to 'string'.`)) : (e.choiceList = null, this._logAutoFix(`Field '${e.name}' had an empty domain but is not of type 'string'. Auto-fixed by removing the domain.`)) : this._logIssue(`Field '${e.name}' must be of type 'string' to have a domain.`)), e.type === "string" && this._validateStringFieldLength(e), Array.isArray(e.choiceList) && (this.newDesign ? this._autoFixChoiceList(e) : this._logChoiceListIssues(e)), Array.isArray(e.choiceList) && e.length != null) {
646
- const a = Math.max(...e.choiceList.map((r) => r.length));
647
- a > e.length && (this.newDesign ? (this._logAutoFix(`The choice provided for field '${e.name}' is too long. It must fit within ${e.length} characters, but the choice requires ${a} characters. Auto-fixing to ${a}.`), e.length = a) : this._logIssue(`The choice provided for field '${e.name}' is too long. It must fit within ${e.length} characters, but the choice requires ${a} characters.`));
633
+ const o = Math.max(...e.choiceList.map((r) => r.length));
634
+ o > e.length && (this.newDesign ? (this._logAutoFix(`The choice provided for field '${e.name}' is too long. It must fit within ${e.length} characters, but the choice requires ${o} characters. Auto-fixing to ${o}.`), e.length = o) : this._logIssue(`The choice provided for field '${e.name}' is too long. It must fit within ${e.length} characters, but the choice requires ${o} characters.`));
648
635
  }
649
636
  }
650
637
  /**
@@ -653,7 +640,7 @@ class b {
653
640
  */
654
641
  _autoFixChoiceList(e) {
655
642
  let t = e.choiceList;
656
- const i = t.filter((o) => o?.trim());
643
+ const i = t.filter((a) => a?.trim());
657
644
  i.length !== t.length && (this._logAutoFix(`Field '${e.name}' had blank domain values. Auto-fixed by removing them.`), t = i, e.choiceList = t);
658
645
  const n = [...new Set(t)];
659
646
  n.length !== t.length && (this._logAutoFix(`Field '${e.name}' had duplicate domain values. Auto-fixed by removing duplicates.`), t = n, e.choiceList = t), t.length || (this._logAutoFix(`Field '${e.name}' had an empty domain. Auto-fixed by removing the domain.`), e.choiceList = null);
@@ -712,28 +699,28 @@ class b {
712
699
  * appending a numeric suffix as needed.
713
700
  */
714
701
  _getUniqueTruncatedFieldName(e, t) {
715
- const i = b.FIELD_NAME_MAX_LENGTH, n = e.slice(0, i);
716
- let o = n, a = 1;
717
- for (; t.has(o.toLowerCase()); ) {
718
- const r = `_${a}`, c = Math.max(1, i - r.length);
719
- o = `${n.slice(0, c)}${r}`, a += 1;
702
+ const i = x.FIELD_NAME_MAX_LENGTH, n = e.slice(0, i);
703
+ let a = n, o = 1;
704
+ for (; t.has(a.toLowerCase()); ) {
705
+ const r = `_${o}`, c = Math.max(1, i - r.length);
706
+ a = `${n.slice(0, c)}${r}`, o += 1;
720
707
  }
721
- return o;
708
+ return a;
722
709
  }
723
710
  /**
724
711
  * Sanitizes an item-style name by stripping emojis and disallowed characters,
725
712
  * collapsing whitespace, trimming, and truncating to the name length limit.
726
713
  * May return an empty string when no valid characters remain.
727
714
  */
728
- _sanitizeItemName(e, t = b.NAME_MAX_LENGTH) {
729
- let i = (e ?? "").replace(new RegExp(Qe.source, "gu"), "").replace(b.INVALID_NAME_CHARS, "").replace(/\s+/gu, " ").trim();
715
+ _sanitizeItemName(e, t = x.NAME_MAX_LENGTH) {
716
+ let i = (e ?? "").replace(new RegExp(Qe.source, "gu"), "").replace(x.INVALID_NAME_CHARS, "").replace(/\s+/gu, " ").trim();
730
717
  return i.length > t && (i = i.slice(0, t).trim()), i;
731
718
  }
732
719
  /**
733
720
  * Sanitizes a description by stripping the disallowed `<` and `>` characters
734
721
  * (forward slash is allowed) and truncating to the description length limit.
735
722
  */
736
- _sanitizeDescription(e, t = b.DESCRIPTION_MAX_LENGTH) {
723
+ _sanitizeDescription(e, t = x.DESCRIPTION_MAX_LENGTH) {
737
724
  let i = (e ?? "").replace(/[<>]/gu, "");
738
725
  return i.length > t && (i = i.slice(0, t)), i;
739
726
  }
@@ -750,12 +737,12 @@ class b {
750
737
  * (or values that sanitize to empty) fall back to the supplied placeholder.
751
738
  * Returns true when fixed.
752
739
  */
753
- _tryFixName(e, t, i, n, o) {
740
+ _tryFixName(e, t, i, n, a) {
754
741
  if (!this.newDesign)
755
742
  return !1;
756
743
  if (e === "empty")
757
- return i(o), this._logAutoFix(`${n} was empty. Auto-fixed to '${o}'.`), !0;
758
- const r = this._sanitizeItemName(t) || o;
744
+ return i(a), this._logAutoFix(`${n} was empty. Auto-fixed to '${a}'.`), !0;
745
+ const r = this._sanitizeItemName(t) || a;
759
746
  return i(r), this._logAutoFix(`${n} was invalid (${e}). Auto-fixed to '${r}'.`), !0;
760
747
  }
761
748
  /**
@@ -840,14 +827,14 @@ const yt = l.object({
840
827
  }),
841
828
  items: l.array(bt).describe("ArcGIS items that belong to the solution (apps, maps, layers, etc.)."),
842
829
  featureLayer: vt.describe("Primary feature layer item and its schema/layers/tables details.")
843
- }), wt = l.object({
830
+ }), _t = l.object({
844
831
  op: l.enum(["add", "remove", "replace", "move", "copy"]).describe("RFC 6902 operation type."),
845
832
  path: l.string().describe("RFC 6901 JSON Pointer to the target location."),
846
833
  value: l.string().nullable().describe(`JSON-encoded value to apply (required for add and replace). Must be null — not an empty string — for remove, move, and copy operations. Serialize as a JSON string, e.g. '\\"text\\"' for a string, '[\\"a\\",\\"b\\"]' for an array, or '{\\"name\\":\\"x\\"}' for an object.`),
847
834
  from: l.string().nullable().describe("RFC 6901 JSON Pointer to the source location (required for move and copy). Must be null — not an empty string — for all other operations.")
848
- }), _t = l.object({
835
+ }), wt = l.object({
849
836
  response: l.string().describe("Conversational response describing the accepted design changes."),
850
- patches: l.array(wt).describe("Minimal RFC 6902 patch operations needed to update the current design.")
837
+ patches: l.array(_t).describe("Minimal RFC 6902 patch operations needed to update the current design.")
851
838
  }), St = l.object({
852
839
  response: l.string().describe("Short, user-friendly explanation of why the requested update was not applied.")
853
840
  }), It = l.object({
@@ -870,11 +857,11 @@ const yt = l.object({
870
857
  validationIssues: t,
871
858
  recentMessages: i,
872
859
  fallbackMessage: n,
873
- promptModules: o
860
+ promptModules: a
874
861
  } = s;
875
862
  try {
876
863
  return (await We({
877
- promptText: await v(o, "explainValidationFailure"),
864
+ promptText: await v(a, "explainValidationFailure"),
878
865
  modelTier: "fast",
879
866
  temperature: 0,
880
867
  schema: St,
@@ -885,14 +872,14 @@ const yt = l.object({
885
872
  validationIssues: Et(t)
886
873
  }
887
874
  })).response?.trim() || n;
888
- } catch (a) {
875
+ } catch (o) {
889
876
  return console.warn(
890
877
  "Natural language response failed:",
891
- { error: a }
878
+ { error: o }
892
879
  ), n;
893
880
  }
894
- }, ee = (s) => s in F, $t = 5, kt = 0.8, Nt = 0.5, Ft = "Web Mapping Application", Dt = "Embeddings";
895
- let R = null, V = null, B = null, P = null;
881
+ }, ee = (s) => s in F, kt = 5, $t = 0.8, Nt = 0.5, Ft = "Web Mapping Application", Dt = "Embeddings";
882
+ let R = null, V = null, P = null, B = null;
896
883
  const Mt = "Build", L = /* @__PURE__ */ Object.assign({
897
884
  "./prompts/assessBuildRequest.md": () => import("../../chunks/assessBuildRequest.js").then((s) => s.default),
898
885
  "./prompts/assessUpdateRequest.md": () => import("../../chunks/assessUpdateRequest.js").then((s) => s.default),
@@ -901,11 +888,11 @@ const Mt = "Build", L = /* @__PURE__ */ Object.assign({
901
888
  "./prompts/explainValidationFailure.md": () => import("../../chunks/explainValidationFailure.js").then((s) => s.default),
902
889
  "./prompts/findExistingSolution.md": () => import("../../chunks/findExistingSolution.js").then((s) => s.default),
903
890
  "./prompts/updateDesign.md": () => import("../../chunks/updateDesign.js").then((s) => s.default)
904
- }), Rt = ft.builderMessages, m = (s) => s?.signal?.aborted ?? !1, f = (s, e, t) => U(e)?.builderMessages?.[s] ?? Rt[s], _e = (s) => {
891
+ }), Rt = ft.builderMessages, m = (s) => s?.signal?.aborted ?? !1, f = (s, e, t) => U(e)?.builderMessages?.[s] ?? Rt[s], we = (s) => {
905
892
  typeof window < "u" && window.dispatchEvent(new CustomEvent("arcgis-solution-design-update", {
906
893
  detail: s
907
894
  }));
908
- }, Bt = async (s, e, t) => {
895
+ }, Pt = async (s, e, t) => {
909
896
  if (!s) return null;
910
897
  const i = `type:"${Ft}" AND typekeywords:${Dt} AND group:${s}`;
911
898
  return (await Y.searchItems({
@@ -915,13 +902,13 @@ const Mt = "Build", L = /* @__PURE__ */ Object.assign({
915
902
  num: 1
916
903
  }))?.results?.[0] ?? null;
917
904
  };
918
- async function Pt(s, e, t, i) {
905
+ async function Bt(s, e, t, i) {
919
906
  try {
920
- const n = await Bt(s, e, t);
907
+ const n = await Pt(s, e, t);
921
908
  if (!n || m(i))
922
909
  return null;
923
- const o = new Ye({ id: n.id });
924
- return await o.load(), m(i) ? null : await o.fetchData("json");
910
+ const a = new Ye({ id: n.id });
911
+ return await a.load(), m(i) ? null : await a.fetchData("json");
925
912
  } catch {
926
913
  return null;
927
914
  }
@@ -942,12 +929,12 @@ const qt = async (s, e, t) => {
942
929
  portal: t
943
930
  }), n = i?.buildSolution;
944
931
  if (!n) return null;
945
- const o = i?.params, a = o && typeof o == "object" && !Array.isArray(o) ? o : null;
946
- return { buildSolution: n, params: a };
932
+ const a = i?.params, o = a && typeof a == "object" && !Array.isArray(a) ? a : null;
933
+ return { buildSolution: n, params: o };
947
934
  } catch {
948
935
  return null;
949
936
  }
950
- }, $ = (s, e = {}) => {
937
+ }, k = (s, e = {}) => {
951
938
  let t = s;
952
939
  return "itemId" in e && (t = {
953
940
  ...t,
@@ -979,8 +966,8 @@ const qt = async (s, e, t) => {
979
966
  }
980
967
  }, te = async (s) => {
981
968
  if (V) {
982
- Object.entries(V).forEach(([a, r]) => {
983
- F[a] && (F[a].initialTemplate = r);
969
+ Object.entries(V).forEach(([o, r]) => {
970
+ F[o] && (F[o].initialTemplate = r);
984
971
  });
985
972
  return;
986
973
  }
@@ -989,36 +976,36 @@ const qt = async (s, e, t) => {
989
976
  console.warn("Solution Builder: missing primarySolutionsGroupId in appConfig; skipping live template hydration.");
990
977
  return;
991
978
  }
992
- const n = await qt(t, e, i), o = {};
993
- m(s) || (await Promise.all(n.map(async (a) => {
994
- const r = a.properties?.templateInfo;
979
+ const n = await qt(t, e, i), a = {};
980
+ m(s) || (await Promise.all(n.map(async (o) => {
981
+ const r = o.properties?.templateInfo;
995
982
  if (!r || typeof r != "object") return;
996
983
  const c = r.id;
997
- if (typeof c != "string" || o[c]) return;
998
- const d = await Ut(a.id, e, i);
984
+ if (typeof c != "string" || a[c]) return;
985
+ const d = await Ut(o.id, e, i);
999
986
  if (!d || m(s))
1000
987
  return;
1001
988
  const { buildSolution: h, params: y } = d;
1002
989
  if (typeof h == "object" && h !== null && "solution" in h) {
1003
990
  const g = h.solution;
1004
- g.thumbnailUrl = a.thumbnail ? `${i ?? "https://www.arcgis.com/sharing/rest"}/content/items/${a.id}/info/${a.thumbnail}` : void 0, g.item = a;
991
+ g.thumbnailUrl = o.thumbnail ? `${i ?? "https://www.arcgis.com/sharing/rest"}/content/items/${o.id}/info/${o.thumbnail}` : void 0, g.item = o;
1005
992
  }
1006
993
  const u = {
1007
994
  ...r,
1008
995
  buildSolution: h
1009
996
  };
1010
- o[c] = $(
997
+ a[c] = k(
1011
998
  new pe(u).dumpToLlmTemplate(),
1012
999
  {
1013
- itemId: a.id,
1000
+ itemId: o.id,
1014
1001
  sourceBuildSolution: structuredClone(h),
1015
1002
  params: y ? structuredClone(y) : null
1016
1003
  }
1017
1004
  ), F[c] = {
1018
1005
  ...r,
1019
- initialTemplate: o[c]
1006
+ initialTemplate: a[c]
1020
1007
  };
1021
- })), V = o);
1008
+ })), V = a);
1022
1009
  }, Ie = (s) => {
1023
1010
  const e = s?.configurable?.context?.token;
1024
1011
  return typeof e != "string" || !e.trim() ? null : e;
@@ -1036,9 +1023,9 @@ const qt = async (s, e, t) => {
1036
1023
  ]);
1037
1024
  }, Te = async (s) => {
1038
1025
  const e = Ie(s);
1039
- (!B || e && e !== P) && (P = e ?? P, B = Ot(s).catch((i) => {
1040
- throw B = null, P = null, i;
1041
- })), await B;
1026
+ (!P || e && e !== B) && (B = e ?? B, P = Ot(s).catch((i) => {
1027
+ throw P = null, B = null, i;
1028
+ })), await P;
1042
1029
  };
1043
1030
  async function Ee(s) {
1044
1031
  if (R) return R;
@@ -1048,8 +1035,8 @@ async function Ee(s) {
1048
1035
  const t = Ce(s), i = s?.configurable?.context?.configContext?.portalURL;
1049
1036
  if (await new Xe(i ? { url: i } : void 0).load(), m(s))
1050
1037
  return null;
1051
- const o = Ie(s) ?? void 0, a = await Pt(e, o, t, s);
1052
- return m(s) ? null : a ? (R = a.items, R) : null;
1038
+ const a = Ie(s) ?? void 0, o = await Bt(e, a, t, s);
1039
+ return m(s) ? null : o ? (R = o.items, R) : null;
1053
1040
  }
1054
1041
  const zt = () => Object.entries(F).map(([s, e]) => `ID: ${s}
1055
1042
  Label: ${e.label}
@@ -1060,15 +1047,15 @@ Description: ${e.description}`).join(`
1060
1047
  if (typeof e != "string" || !e.trim())
1061
1048
  return null;
1062
1049
  try {
1063
- const t = JSON.parse(e), i = $(
1050
+ const t = JSON.parse(e), i = k(
1064
1051
  { response: "", ...t },
1065
1052
  { itemId: t?.solution?.itemId ?? null }
1066
1053
  ), n = Z.safeParse(i);
1067
1054
  if (!n.success)
1068
1055
  return null;
1069
- const { response: o, ...a } = n.data, r = t.templateId, c = typeof r == "string" && ee(r) ? r : null;
1070
- return $(
1071
- a,
1056
+ const { response: a, ...o } = n.data, r = t.templateId, c = typeof r == "string" && ee(r) ? r : null;
1057
+ return k(
1058
+ o,
1072
1059
  {
1073
1060
  sourceBuildSolution: t.sourceBuildSolution,
1074
1061
  templateId: c,
@@ -1078,65 +1065,65 @@ Description: ${e.description}`).join(`
1078
1065
  } catch {
1079
1066
  return null;
1080
1067
  }
1081
- }, Gt = x.Root({
1068
+ }, Gt = b.Root({
1082
1069
  ...X(),
1083
1070
  /** Optional human-readable template description retained for UI use. */
1084
- templateDescription: x({
1071
+ templateDescription: b({
1085
1072
  reducer: (s, e) => typeof e == "string" || e === null ? e : s ?? null,
1086
1073
  default: () => null
1087
1074
  }),
1088
1075
  /** Current editable design payload being refined across turns. */
1089
- currentDesign: x({
1076
+ currentDesign: b({
1090
1077
  reducer: (s = null, e) => e === void 0 ? s : e ?? null,
1091
1078
  default: () => null
1092
1079
  }),
1093
1080
  /** Initial request assessment produced by the intake prompt. */
1094
- assessment: x({
1081
+ assessment: b({
1095
1082
  reducer: (s = null, e) => e === void 0 ? s : e ?? null,
1096
1083
  default: () => null
1097
1084
  }),
1098
1085
  /** Template selected automatically or by human-in-the-loop choice. */
1099
- selectedTemplate: x({
1086
+ selectedTemplate: b({
1100
1087
  reducer: (s = null, e) => e === void 0 ? s : e ?? null,
1101
1088
  default: () => null
1102
1089
  }),
1103
1090
  /** Update request assessment produced when an active design exists. */
1104
- updateAssessment: x({
1091
+ updateAssessment: b({
1105
1092
  reducer: (s = null, e) => e === void 0 ? s : e ?? null,
1106
1093
  default: () => null
1107
1094
  }),
1108
1095
  /** Existing solution matches surfaced before building a new solution. */
1109
- existingMatches: x({
1096
+ existingMatches: b({
1110
1097
  reducer: (s = [], e) => e === void 0 ? s : e ?? [],
1111
1098
  default: () => []
1112
1099
  }),
1113
1100
  /** User decision for whether to continue building after existing matches are shown. */
1114
- continueBuilding: x({
1101
+ continueBuilding: b({
1115
1102
  reducer: (s = null, e) => e === void 0 ? s : e ?? null,
1116
1103
  default: () => null
1117
1104
  })
1118
- }), Ht = (s, e) => {
1105
+ }), Jt = (s, e) => {
1119
1106
  if (m(e))
1120
1107
  return {};
1121
1108
  const t = jt(e), i = t?.templateId ?? null, n = {};
1122
1109
  return JSON.stringify(s.currentDesign) !== JSON.stringify(t) && (n.currentDesign = t), i && s.selectedTemplate !== i && (n.selectedTemplate = i), n;
1123
- }, Jt = async (s, e) => {
1110
+ }, Ht = async (s, e) => {
1124
1111
  if (m(e))
1125
1112
  return {};
1126
- await _({ text: f("understandingRequest", e) }, e), await Te(e);
1127
- const t = s.agentExecutionContext.userRequest, i = zt(), n = s.agentExecutionContext.messages.slice(-11), o = await k({
1113
+ await w({ text: f("understandingRequest", e) }, e), await Te(e);
1114
+ const t = s.agentExecutionContext.userRequest, i = zt(), n = s.agentExecutionContext.messages.slice(-11), a = await $({
1128
1115
  promptText: await v(L, "assessBuildRequest"),
1129
1116
  modelTier: "advanced",
1130
1117
  temperature: 0,
1131
1118
  schema: Tt,
1132
1119
  messages: n,
1133
1120
  inputVariables: { query: t, availableTemplates: i }
1134
- }), a = o.matchedTemplates.filter(
1121
+ }), o = a.matchedTemplates.filter(
1135
1122
  (u) => ee(u.templateId)
1136
1123
  ), r = {
1137
- ...o,
1138
- matchedTemplates: a
1139
- }, [c, d] = a, y = !!c && c.confidence >= kt && (d === void 0 || c.confidence - d.confidence >= Nt) ? c.templateId : null;
1124
+ ...a,
1125
+ matchedTemplates: o
1126
+ }, [c, d] = o, y = !!c && c.confidence >= $t && (d === void 0 || c.confidence - d.confidence >= Nt) ? c.templateId : null;
1140
1127
  return {
1141
1128
  assessment: r,
1142
1129
  selectedTemplate: y,
@@ -1161,10 +1148,10 @@ Description: ${e.description}`).join(`
1161
1148
  isValidUpdate: !0
1162
1149
  }
1163
1150
  };
1164
- await _({ text: f("understandingRequest", e) }, e);
1151
+ await w({ text: f("understandingRequest", e) }, e);
1165
1152
  const i = s.agentExecutionContext.userRequest, n = s.agentExecutionContext.messages.slice(-11);
1166
1153
  return {
1167
- updateAssessment: await k({
1154
+ updateAssessment: await $({
1168
1155
  promptText: await v(L, "assessUpdateRequest"),
1169
1156
  modelTier: "advanced",
1170
1157
  temperature: 0,
@@ -1188,25 +1175,25 @@ Description: ${e.description}`).join(`
1188
1175
  return {};
1189
1176
  const { hitlResponse: t } = e.configurable, i = "selectTemplate", n = s.assessment?.matchedTemplates.filter(
1190
1177
  (d) => ee(d.templateId)
1191
- ) ?? [], o = n.map((d) => `${d.templateDescription}`);
1178
+ ) ?? [], a = n.map((d) => `${d.templateDescription}`);
1192
1179
  if (t?.agentId !== "solutionBuilder" || t.id !== i) {
1193
1180
  const d = {
1194
1181
  agentId: "solutionBuilder",
1195
1182
  id: i,
1196
1183
  kind: "singleSelection",
1197
1184
  message: f("selectTemplatePrompt", e),
1198
- metadata: [...o]
1185
+ metadata: [...a]
1199
1186
  };
1200
1187
  throw new de(d);
1201
1188
  }
1202
- const a = String(t.payload ?? ""), r = o.findIndex((d) => d === a);
1189
+ const o = String(t.payload ?? ""), r = a.findIndex((d) => d === o);
1203
1190
  return {
1204
1191
  selectedTemplate: (r >= 0 ? n[r] : void 0)?.templateId ?? n[0]?.templateId ?? null
1205
1192
  };
1206
1193
  }, Xt = async (s, e) => {
1207
1194
  if (m(e))
1208
1195
  return {};
1209
- await _({ text: f("searchingExistingSolutions", e) }, e);
1196
+ await w({ text: f("searchingExistingSolutions", e) }, e);
1210
1197
  const t = s.agentExecutionContext.userRequest, i = ht(s.agentExecutionContext.messages) || t, n = await Ee(e);
1211
1198
  if (m(e))
1212
1199
  return {};
@@ -1214,15 +1201,15 @@ Description: ${e.description}`).join(`
1214
1201
  return console.warn("Solutions Search: failed to load solution embeddings cache; skipping search."), { existingMatches: [] };
1215
1202
  if (!n.length)
1216
1203
  return { existingMatches: [] };
1217
- const [o] = await ze([i]);
1204
+ const [a] = await ze([i]);
1218
1205
  if (m(e))
1219
1206
  return {};
1220
- const a = n.map((u) => ({
1207
+ const o = n.map((u) => ({
1221
1208
  solution: u,
1222
- score: je(o, u.embedding)
1209
+ score: je(a, u.embedding)
1223
1210
  }));
1224
- a.sort((u, g) => g.score - u.score);
1225
- const r = a.slice(0, $t);
1211
+ o.sort((u, g) => g.score - u.score);
1212
+ const r = o.slice(0, kt);
1226
1213
  if (!r.length)
1227
1214
  return { existingMatches: [] };
1228
1215
  const c = r.map(({ solution: u }) => `${u.title}
@@ -1230,7 +1217,7 @@ Snippet: ${u.snippet}
1230
1217
  Description: ${u.description}`).join(`
1231
1218
 
1232
1219
  `), d = s.agentExecutionContext.messages.slice(-11);
1233
- return { existingMatches: (await k({
1220
+ return { existingMatches: (await $({
1234
1221
  promptText: await v(L, "findExistingSolution"),
1235
1222
  modelTier: "fast",
1236
1223
  temperature: 0,
@@ -1256,8 +1243,8 @@ Description: ${u.description}`).join(`
1256
1243
  };
1257
1244
  throw new de(h);
1258
1245
  }
1259
- const o = String(i.payload ?? "").trim(), a = f("continueBuildingNo", e);
1260
- return { continueBuilding: o !== a };
1246
+ const a = String(i.payload ?? "").trim(), o = f("continueBuildingNo", e);
1247
+ return { continueBuilding: a !== o };
1261
1248
  }, Zt = (s, e) => {
1262
1249
  const t = f("continueBuildingDeclined", e);
1263
1250
  return {
@@ -1271,45 +1258,45 @@ Description: ${u.description}`).join(`
1271
1258
  if (await Te(e), m(e))
1272
1259
  return {};
1273
1260
  const { currentDesign: t } = s, i = s.agentExecutionContext.userRequest;
1274
- await _({ text: f("creatingDesign", e) }, e);
1261
+ await w({ text: f("creatingDesign", e) }, e);
1275
1262
  let n = q(s.selectedTemplate);
1276
1263
  if (n?.initialTemplate || (await te(e), n = q(s.selectedTemplate)), m(e))
1277
1264
  return {};
1278
1265
  if (!n?.initialTemplate)
1279
1266
  throw new Error("No hydrated templates are available for solution design.");
1280
- const o = $(
1267
+ const a = k(
1281
1268
  t ?? n.initialTemplate,
1282
1269
  {
1283
1270
  itemId: (t ?? n.initialTemplate)?.solution?.itemId ?? null,
1284
1271
  sourceBuildSolution: t?.sourceBuildSolution ?? n.initialTemplate.sourceBuildSolution,
1285
1272
  params: t?.params ?? n.initialTemplate.params ?? null
1286
1273
  }
1287
- ), a = s.agentExecutionContext.messages.slice(-11), r = await k({
1274
+ ), o = s.agentExecutionContext.messages.slice(-11), r = await $({
1288
1275
  promptText: await v(L, "designSolution"),
1289
1276
  modelTier: "advanced",
1290
1277
  temperature: 0,
1291
1278
  schema: Z,
1292
- messages: a,
1279
+ messages: o,
1293
1280
  inputVariables: {
1294
- currentDesign: JSON.stringify(he(o)),
1281
+ currentDesign: JSON.stringify(he(a)),
1295
1282
  templateInstructions: n.instructions,
1296
1283
  query: i
1297
1284
  }
1298
1285
  });
1299
- if (await _({ text: " of design solution 1" }, e), m(e))
1286
+ if (await w({ text: " of design solution 1" }, e), m(e))
1300
1287
  return {};
1301
1288
  const { response: c, featureLayer: d, ...h } = r, y = ge(
1302
1289
  d,
1303
- o.featureLayer
1304
- ), u = $(
1290
+ a.featureLayer
1291
+ ), u = k(
1305
1292
  { ...h, featureLayer: y },
1306
1293
  {
1307
- itemId: o?.solution?.itemId,
1308
- sourceBuildSolution: o.sourceBuildSolution,
1294
+ itemId: a?.solution?.itemId,
1295
+ sourceBuildSolution: a.sourceBuildSolution,
1309
1296
  templateId: s.selectedTemplate ?? null,
1310
- params: o.params ?? null
1297
+ params: a.params ?? null
1311
1298
  }
1312
- ), g = new b(u, n.initialTemplate);
1299
+ ), g = new x(u, n.initialTemplate);
1313
1300
  if (!g.isValid)
1314
1301
  return console.warn(
1315
1302
  "[SolutionBuilder] designSolution validation failed:",
@@ -1330,7 +1317,7 @@ Description: ${u.description}`).join(`
1330
1317
  status: "success"
1331
1318
  };
1332
1319
  }
1333
- return m(e) ? {} : (_e(u), {
1320
+ return m(e) ? {} : (we(u), {
1334
1321
  outputMessage: c,
1335
1322
  summary: c,
1336
1323
  status: "success",
@@ -1343,14 +1330,14 @@ Description: ${u.description}`).join(`
1343
1330
  if (!t)
1344
1331
  return Le(s, e);
1345
1332
  const i = s.agentExecutionContext.userRequest, n = s.agentExecutionContext.messages.slice(-11);
1346
- await _({ text: f("updatingDesign", e) }, e);
1347
- let o;
1333
+ await w({ text: f("updatingDesign", e) }, e);
1334
+ let a;
1348
1335
  try {
1349
- o = await k({
1336
+ a = await $({
1350
1337
  promptText: await v(L, "updateDesign"),
1351
1338
  modelTier: "advanced",
1352
1339
  temperature: 0,
1353
- schema: _t,
1340
+ schema: wt,
1354
1341
  messages: n,
1355
1342
  inputVariables: {
1356
1343
  currentDesign: JSON.stringify(me(t)),
@@ -1359,25 +1346,25 @@ Description: ${u.description}`).join(`
1359
1346
  });
1360
1347
  } catch (p) {
1361
1348
  console.warn("[SolutionBuilder] updateDesign structured prompt failed:", p);
1362
- const w = f("applyChangeFailed", e);
1349
+ const _ = f("applyChangeFailed", e);
1363
1350
  return {
1364
- outputMessage: w,
1365
- summary: w,
1351
+ outputMessage: _,
1352
+ summary: _,
1366
1353
  status: "success"
1367
1354
  };
1368
1355
  }
1369
- const { response: a, patches: r } = o;
1356
+ const { response: o, patches: r } = a;
1370
1357
  if (!r || r.length === 0)
1371
1358
  return {
1372
- outputMessage: a,
1373
- summary: a,
1359
+ outputMessage: o,
1360
+ summary: o,
1374
1361
  status: "success"
1375
1362
  };
1376
1363
  const c = (p) => {
1377
1364
  try {
1378
1365
  return JSON.parse(p);
1379
1366
  } catch {
1380
- const w = p.replace(/[\u0000-\u001F]/g, (oe) => {
1367
+ const _ = p.replace(/[\u0000-\u001F]/g, (oe) => {
1381
1368
  switch (oe) {
1382
1369
  case "\b":
1383
1370
  return "\\b";
@@ -1395,7 +1382,7 @@ Description: ${u.description}`).join(`
1395
1382
  }
1396
1383
  });
1397
1384
  try {
1398
- return JSON.parse(w);
1385
+ return JSON.parse(_);
1399
1386
  } catch {
1400
1387
  return p;
1401
1388
  }
@@ -1405,31 +1392,31 @@ Description: ${u.description}`).join(`
1405
1392
  path: p.path.replace(/\/+$/, ""),
1406
1393
  ...p.value != null && p.value !== "" ? { value: c(p.value) } : {},
1407
1394
  ...p.from != null && p.from !== "" ? { from: p.from } : {}
1408
- }))].sort((p, w) => p.op !== "remove" || w.op !== "remove" ? 0 : w.path.localeCompare(p.path, void 0, { numeric: !0 })), y = structuredClone(
1395
+ }))].sort((p, _) => p.op !== "remove" || _.op !== "remove" ? 0 : _.path.localeCompare(p.path, void 0, { numeric: !0 })), y = structuredClone(
1409
1396
  he(t)
1410
1397
  );
1411
1398
  try {
1412
- He(y, h, !0);
1399
+ Je(y, h, !0);
1413
1400
  } catch (p) {
1414
1401
  console.warn(
1415
1402
  "[SolutionBuilder] updateDesign JSON patch failed:",
1416
- { error: p, llmResponse: o, patches: h, patchTarget: y }
1403
+ { error: p, llmResponse: a, patches: h, patchTarget: y }
1417
1404
  );
1418
- const w = f("applyChangeFailed", e);
1405
+ const _ = f("applyChangeFailed", e);
1419
1406
  return {
1420
- outputMessage: w,
1421
- summary: w,
1407
+ outputMessage: _,
1408
+ summary: _,
1422
1409
  status: "success"
1423
1410
  };
1424
1411
  }
1425
- const u = $(
1412
+ const u = k(
1426
1413
  { response: "", ...y },
1427
1414
  { itemId: t.solution?.itemId ?? null }
1428
1415
  ), g = Z.safeParse(u);
1429
1416
  if (!g.success) {
1430
1417
  console.warn(
1431
1418
  "[SolutionBuilder] updateDesign schema validation failed:",
1432
- { errors: g.error.issues, llmResponse: o, patchedDesign: u }
1419
+ { errors: g.error.issues, llmResponse: a, patchedDesign: u }
1433
1420
  );
1434
1421
  const p = f("applyChangeFailed", e);
1435
1422
  return {
@@ -1441,7 +1428,7 @@ Description: ${u.description}`).join(`
1441
1428
  const { response: S, featureLayer: N, ...C } = g.data, z = ge(
1442
1429
  N,
1443
1430
  t.featureLayer
1444
- ), I = $(
1431
+ ), I = k(
1445
1432
  { ...C, featureLayer: z },
1446
1433
  {
1447
1434
  itemId: t.solution?.itemId,
@@ -1455,11 +1442,11 @@ Description: ${u.description}`).join(`
1455
1442
  return {};
1456
1443
  if (!D?.initialTemplate)
1457
1444
  throw new Error("No hydrated templates are available for solution design.");
1458
- const j = new b(I, D.initialTemplate, !1);
1445
+ const j = new x(I, D.initialTemplate, !1);
1459
1446
  if (!j.isValid) {
1460
1447
  console.warn(
1461
1448
  "[SolutionBuilder] updateDesign validation failed:",
1462
- { issues: j.issues, llmResponse: o, patchedDesign: I }
1449
+ { issues: j.issues, llmResponse: a, patchedDesign: I }
1463
1450
  );
1464
1451
  const p = await Lt({
1465
1452
  query: i,
@@ -1474,11 +1461,11 @@ Description: ${u.description}`).join(`
1474
1461
  status: "success"
1475
1462
  };
1476
1463
  }
1477
- const ke = I.sourceBuildSolution, ne = Se(I, ke);
1464
+ const $e = I.sourceBuildSolution, ne = Se(I, $e);
1478
1465
  if (!ne.ok) {
1479
1466
  console.warn(
1480
1467
  "[SolutionBuilder] updateDesign Esri JSON conversion failed:",
1481
- { error: ne.error, llmResponse: o, design: I }
1468
+ { error: ne.error, llmResponse: a, design: I }
1482
1469
  );
1483
1470
  const p = f("applyChangeFailed", e);
1484
1471
  return {
@@ -1487,13 +1474,13 @@ Description: ${u.description}`).join(`
1487
1474
  status: "success"
1488
1475
  };
1489
1476
  }
1490
- return m(e) ? {} : (_e(I), {
1491
- outputMessage: a,
1492
- summary: a,
1477
+ return m(e) ? {} : (we(I), {
1478
+ outputMessage: o,
1479
+ summary: o,
1493
1480
  status: "success",
1494
1481
  currentDesign: I
1495
1482
  });
1496
- }, ts = (s) => s.currentDesign !== null ? "assessUpdateRequest" : "assessBuildRequest", ss = (s) => !s.updateAssessment || !s.updateAssessment.isValidUpdate ? "invalidUpdateExit" : "updateDesign", is = (s) => !s.assessment || !s.assessment.isValidUseCase ? "invalidBuildExit" : !s.selectedTemplate && s.assessment.matchedTemplates.length > 1 ? "selectTemplateHIL" : "findExistingSolutions", ns = (s) => s.existingMatches.length > 0 ? "confirmContinueBuildingHIL" : "designSolution", os = (s) => s.continueBuilding === !1 ? "declineContinueBuildingExit" : "designSolution", as = () => new K(Gt).addNode("syncCurrentDesignFromContext", Ht).addNode("assessBuildRequest", Jt).addNode("assessUpdateRequest", Qt).addNode("invalidBuildExit", Vt).addNode("invalidUpdateExit", Kt).addNode("selectTemplateHIL", Wt).addNode("findExistingSolutions", Xt).addNode("confirmContinueBuildingHIL", Yt).addNode("declineContinueBuildingExit", Zt).addNode("designSolution", Le).addNode("updateDesign", es).addEdge(W, "syncCurrentDesignFromContext").addConditionalEdges("syncCurrentDesignFromContext", ts, {
1483
+ }, ts = (s) => s.currentDesign !== null ? "assessUpdateRequest" : "assessBuildRequest", ss = (s) => !s.updateAssessment || !s.updateAssessment.isValidUpdate ? "invalidUpdateExit" : "updateDesign", is = (s) => !s.assessment || !s.assessment.isValidUseCase ? "invalidBuildExit" : !s.selectedTemplate && s.assessment.matchedTemplates.length > 1 ? "selectTemplateHIL" : "findExistingSolutions", ns = (s) => s.existingMatches.length > 0 ? "confirmContinueBuildingHIL" : "designSolution", os = (s) => s.continueBuilding === !1 ? "declineContinueBuildingExit" : "designSolution", as = () => new K(Gt).addNode("syncCurrentDesignFromContext", Jt).addNode("assessBuildRequest", Ht).addNode("assessUpdateRequest", Qt).addNode("invalidBuildExit", Vt).addNode("invalidUpdateExit", Kt).addNode("selectTemplateHIL", Wt).addNode("findExistingSolutions", Xt).addNode("confirmContinueBuildingHIL", Yt).addNode("declineContinueBuildingExit", Zt).addNode("designSolution", Le).addNode("updateDesign", es).addEdge(W, "syncCurrentDesignFromContext").addConditionalEdges("syncCurrentDesignFromContext", ts, {
1497
1484
  assessUpdateRequest: "assessUpdateRequest",
1498
1485
  assessBuildRequest: "assessBuildRequest"
1499
1486
  }).addConditionalEdges("assessUpdateRequest", ss, {
@@ -1536,13 +1523,13 @@ const rs = E.object({
1536
1523
  detail: { finished: !0, agent: e }
1537
1524
  });
1538
1525
  window.dispatchEvent(i);
1539
- }, $e = x.Root({
1526
+ }, ke = b.Root({
1540
1527
  ...X(),
1541
- selectedTool: x({
1528
+ selectedTool: b({
1542
1529
  reducer: (s, e) => e ?? null,
1543
1530
  default: () => null
1544
1531
  }),
1545
- intentRationale: x({
1532
+ intentRationale: b({
1546
1533
  reducer: (s, e) => e ?? null,
1547
1534
  default: () => null
1548
1535
  })
@@ -1550,17 +1537,17 @@ const rs = E.object({
1550
1537
  if (O(e))
1551
1538
  return {};
1552
1539
  const t = U(e);
1553
- await _(
1540
+ await w(
1554
1541
  { text: t?.builderMessages.understandingRequest },
1555
1542
  e
1556
1543
  );
1557
- const i = s.agentExecutionContext.userRequest, n = s.agentExecutionContext.messages.slice(-11), { activeSolutionDesign: o, lastTool: a } = ls(e), r = await v(se, "classifyIntent"), c = await k({
1544
+ const i = s.agentExecutionContext.userRequest, n = s.agentExecutionContext.messages.slice(-11), { activeSolutionDesign: a, lastTool: o } = ls(e), r = await v(se, "classifyIntent"), c = await $({
1558
1545
  promptText: r,
1559
1546
  modelTier: "advanced",
1560
1547
  temperature: 0,
1561
1548
  schema: rs,
1562
1549
  messages: n,
1563
- inputVariables: { query: i, activeSolutionDesign: o, lastTool: a }
1550
+ inputVariables: { query: i, activeSolutionDesign: a, lastTool: o }
1564
1551
  });
1565
1552
  return {
1566
1553
  selectedTool: c.tool,
@@ -1580,23 +1567,23 @@ const rs = E.object({
1580
1567
  if (O(e))
1581
1568
  return {};
1582
1569
  const t = U(e), i = s.agentExecutionContext.userRequest;
1583
- await _(
1570
+ await w(
1584
1571
  { text: t?.executingSolutionsAssistantAgent },
1585
1572
  e
1586
1573
  );
1587
- const n = await v(se, "assistantResponse"), o = s.agentExecutionContext.messages.slice(-11), a = await Ge({
1574
+ const n = await v(se, "assistantResponse"), a = s.agentExecutionContext.messages.slice(-11), o = await Ge({
1588
1575
  promptText: n,
1589
1576
  modelTier: "advanced",
1590
1577
  temperature: 0,
1591
- messages: o,
1578
+ messages: a,
1592
1579
  inputVariables: { query: i }
1593
1580
  });
1594
1581
  return ie(e, "assistant"), {
1595
- outputMessage: a,
1596
- summary: a,
1582
+ outputMessage: o,
1583
+ summary: o,
1597
1584
  status: "success"
1598
1585
  };
1599
- }, ms = (s) => s.selectedTool ?? "other", hs = () => new K($e).addNode("classifyIntent", cs).addNode("routeToExplorer", us).addNode("routeToBuilder", ds).addNode("assistantResponse", ps).addEdge(W, "classifyIntent").addConditionalEdges("classifyIntent", ms, {
1586
+ }, ms = (s) => s.selectedTool ?? "other", hs = () => new K(ke).addNode("classifyIntent", cs).addNode("routeToExplorer", us).addNode("routeToBuilder", ds).addNode("assistantResponse", ps).addEdge(W, "classifyIntent").addConditionalEdges("classifyIntent", ms, {
1600
1587
  explorer: "routeToExplorer",
1601
1588
  builder: "routeToBuilder",
1602
1589
  other: "assistantResponse"
@@ -1605,37 +1592,39 @@ const rs = E.object({
1605
1592
  name: "Solutions Assistant Agent",
1606
1593
  description: gs,
1607
1594
  createGraph: hs,
1608
- workspace: $e
1595
+ workspace: ke
1609
1596
  }, ys = "https://links.esri.com/solutions/agol-organizational-account", bs = "https://links.esri.com/solutions/configure-assistants";
1610
1597
  class xs extends De {
1611
1598
  constructor() {
1612
- super(), this.open = !1, this.userFirstName = "", this.builderVisible = !1, this.hasActiveBuilderDesign = !1, this._conversationId = void 0, this._lastTurnAgent = void 0, this._orgSettings = {
1599
+ super(), this.open = !1, this.userFirstName = "", this.builderVisible = !1, this.hasActiveBuilderDesign = !1, this._conversationId = void 0, this._lastTurnAgent = void 0, this._lastResponseAgent = void 0, this._orgSettings = {
1613
1600
  aiAssistantsEnabled: !1,
1614
1601
  blockBetaApps: !0,
1615
1602
  colocateCompute: !1
1616
1603
  }, this._suggestedPrompts = [], this._hasInteracted = !1, this._isMobile = window.innerWidth <= 800, this._translations = Fe({ name: "arcgis-solutions-assistant", blocking: !0 }), this._builderWidth = 48, this._solutionDesignJson = '{ "solution": null }', this._isAssistantBusy = !1, this._isBuilderBusy = !1, this._preChatCheck = !1, this._showNewChatConfirm = !1, this._assistantRef = Ue(), this._configContextConsumer = le({
1617
- context: Be,
1604
+ context: Pe,
1618
1605
  subscribe: !0,
1619
1606
  callback: (e) => {
1620
1607
  e?.portalURL && (G.portalUrl = e.portalURL), e?.userSession && !this.userFirstName && this._loadUserFirstName(), e?.authentication?.PortalSubset?.orgSettings && (this._orgSettings = e?.authentication?.PortalSubset?.orgSettings);
1621
1608
  }
1622
1609
  }), this._builderDesignContextConsumer = le({
1623
- context: Pe,
1610
+ context: Be,
1624
1611
  subscribe: !0,
1625
1612
  callback: (e) => {
1626
1613
  e?.design && (this._solutionDesignJson = JSON.stringify(e.design, null, 2));
1627
1614
  }
1628
1615
  }), this._handleResize = () => {
1629
1616
  this._isMobile = window.innerWidth <= 800;
1630
- }, this._chatStartTime = null, this._handleAssistantProcessingFinished = (e) => {
1617
+ }, this._chatStartTime = null, this._responseMetadata = /* @__PURE__ */ new Map(), this._pendingResponseAgent = void 0, this._handleAssistantProcessingFinished = (e) => {
1631
1618
  const t = e;
1632
1619
  if (t.detail?.finished && this._chatStartTime !== null) {
1633
- const i = qe(this._chatStartTime);
1620
+ const i = t.detail.agent;
1621
+ this._lastResponseAgent = i, this._pendingResponseAgent = i;
1622
+ const n = qe(this._chatStartTime);
1634
1623
  this._telemetry?.logEvent({
1635
1624
  category: M.ASSISTANT,
1636
1625
  action: "Chat",
1637
- dimensions: [t.detail.agent],
1638
- metrics: [i]
1626
+ dimensions: [i],
1627
+ metrics: [n]
1639
1628
  }), this._chatStartTime = null;
1640
1629
  }
1641
1630
  }, this.closeAssistant = ae(), this.assistantProcessing = ae(), this._handleAssistantLinkClick = (e) => {
@@ -1654,14 +1643,14 @@ class xs extends De {
1654
1643
  }, this._checkURLOpenParameter = () => {
1655
1644
  this.open = this._configContextConsumer.value?.authentication?.SignInParam === "aiOpen" || this.open;
1656
1645
  }, this.listenOn(window, "arcgisFeedback", (e) => {
1657
- const t = e.detail, { agentPicked: i, taskAssigned: n, userMessage: o } = this._parseAgentPickedAndTask(t);
1658
- this._sendFeedback(t.content, o ?? n ?? "", t.feedback?.positive ? "Good" : t.feedback?.positive == "Bad" ? "Bad" : "N/A", i ?? "");
1646
+ const t = e.detail, { agentPicked: i, taskAssigned: n, userMessage: a } = this._parseAgentPickedAndTask(t), o = this._responseMetadata.get(t.id), r = o?.agent ?? i ?? "", c = o?.userMessage ?? o?.userMessage ?? a ?? n ?? "";
1647
+ this._sendFeedback(t.content, c, t.feedback?.positive ? "Good" : t.feedback?.positive === !1 ? "Bad" : "N/A", r);
1659
1648
  }), this.listenOn(window, "clearAssistantConversation", () => {
1660
1649
  this._clearConversation();
1661
1650
  });
1662
1651
  }
1663
1652
  static {
1664
- this.properties = { open: 5, userFirstName: 1, builderVisible: 5, hasActiveBuilderDesign: 5, _conversationId: 16, _lastTurnAgent: 16, _orgSettings: 16, _suggestedPrompts: 16, _hasInteracted: 16, _isMobile: 16, _translations: 16, _builderWidth: 16, _solutionDesignJson: 16, _isAssistantBusy: 16, _isBuilderBusy: 16, _preChatCheck: 16, _showNewChatConfirm: 16 };
1653
+ this.properties = { open: 5, userFirstName: 1, builderVisible: 5, hasActiveBuilderDesign: 5, _conversationId: 16, _lastTurnAgent: 16, _lastResponseAgent: 16, _orgSettings: 16, _suggestedPrompts: 16, _hasInteracted: 16, _isMobile: 16, _translations: 16, _builderWidth: 16, _solutionDesignJson: 16, _isAssistantBusy: 16, _isBuilderBusy: 16, _preChatCheck: 16, _showNewChatConfirm: 16 };
1665
1654
  }
1666
1655
  static {
1667
1656
  this.styles = Ze;
@@ -1704,8 +1693,19 @@ class xs extends De {
1704
1693
  }} scale=m slot=header-actions-end></calcite-action>` || ""}${!this._isMobile && T`<calcite-tooltip placement=bottom reference-element=solutionBuilderAction><span>${this._translations.tooltips.solutionBuilder}</span></calcite-tooltip>` || ""}<arcgis-assistant reference-element copy-enabled feedback-enabled heading description entry-message=${this._translations.defaultStartUpMessage ?? re} .suggestedPrompts=${e} @arcgisSubmit=${() => {
1705
1694
  this._suggestedPrompts = [], e = [], this._hasInteracted = !0, this._chatStartTime = Date.now(), this.assistantProcessing.emit(!0);
1706
1695
  }} @arcgisFeedback=${(t) => {
1707
- t.detail;
1696
+ t.detail && console.log("arcgis feedback: ", t.detail);
1708
1697
  }} @arcgisResponse=${() => {
1698
+ const t = this._pendingResponseAgent ?? this._lastResponseAgent;
1699
+ if (t) {
1700
+ const i = (n) => {
1701
+ if (this._captureResponseMetadata(t)) {
1702
+ this._pendingResponseAgent = void 0;
1703
+ return;
1704
+ }
1705
+ n < 3 && requestAnimationFrame(() => i(n + 1));
1706
+ };
1707
+ requestAnimationFrame(() => i(1));
1708
+ }
1709
1709
  this.assistantProcessing.emit(!1);
1710
1710
  }} ${Oe(this._assistantRef)}><calcite-button appearance=transparent id=newChatButton icon-start=speech-bubble-plus kind=neutral .label=${this._translations.tooltips.newChat} @click=${() => {
1711
1711
  this.hasActiveBuilderDesign ? this._showNewChatConfirm = !0 : (this._telemetry?.logEvent({
@@ -1744,11 +1744,11 @@ class xs extends De {
1744
1744
  }} slot=header-actions-end .text=${this._translations.tooltips.close}></calcite-action><calcite-tooltip placement=bottom reference-element=closeAssistantButton><span>${this._translations.tooltips.close}</span></calcite-tooltip></calcite-panel>`;
1745
1745
  }
1746
1746
  _clearConversation() {
1747
- this._conversationId = void 0, this._lastTurnAgent = void 0, this._suggestedPrompts = [], this._hasInteracted = !1, this._assistantRef.value?.clearChatHistory();
1747
+ this._conversationId = void 0, this._lastTurnAgent = void 0, this._lastResponseAgent = void 0, this._pendingResponseAgent = void 0, this._suggestedPrompts = [], this._hasInteracted = !1, this._responseMetadata.clear(), this._assistantRef.value?.clearChatHistory();
1748
1748
  }
1749
1749
  _sendFeedback(e, t, i, n) {
1750
- const o = `https://survey123.arcgis.com/share/6e349a50b4504ca6b6107216d568db5f?field:_source=${encodeURIComponent("Solutions Assistant")}&field:user_evaluation=${encodeURIComponent(i)}&field:question=${encodeURIComponent(t)}&field:answer=${encodeURIComponent(e)}&field:context=${encodeURIComponent(JSON.stringify({ agent: n }))}&field:version=${encodeURIComponent("v2")}`;
1751
- window.open(o, "_blank");
1750
+ const a = `https://survey123.arcgis.com/share/6e349a50b4504ca6b6107216d568db5f?field:_source=${encodeURIComponent("Solutions Assistant")}&field:user_evaluation=${encodeURIComponent(i)}&field:question=${encodeURIComponent(t)}&field:answer=${encodeURIComponent(e)}&field:context=${encodeURIComponent(JSON.stringify({ agent: n }))}&field:version=${encodeURIComponent("v2")}`;
1751
+ window.open(a, "_blank");
1752
1752
  }
1753
1753
  async _loadUserFirstName() {
1754
1754
  try {
@@ -1760,15 +1760,33 @@ class xs extends De {
1760
1760
  } catch {
1761
1761
  }
1762
1762
  }
1763
+ _captureResponseMetadata(e) {
1764
+ const t = Array.from(this._assistantRef.value?.messages || []);
1765
+ for (let i = t.length - 1; i >= 0; i--) {
1766
+ const n = t[i];
1767
+ if (n.role === "assistant" && !this._responseMetadata.has(n.id)) {
1768
+ let a;
1769
+ for (let o = i - 1; o >= 0; o--) {
1770
+ const r = t[o];
1771
+ if (r.role === "user") {
1772
+ a = r.content;
1773
+ break;
1774
+ }
1775
+ }
1776
+ return this._responseMetadata.set(n.id, { agent: e, userMessage: a }), !0;
1777
+ }
1778
+ }
1779
+ return !1;
1780
+ }
1763
1781
  _parseAgentPickedAndTask(e) {
1764
- const t = Array.from(this._assistantRef.value?.messages || []), i = e.log || [], a = [...t].sort((u, g) => g.id - u.id).find((u) => u.role === "user" && u.id <= e.id)?.content || null, r = i.find((u) => typeof u == "string" && u.includes("Agent picked:")) ?? null;
1782
+ const t = Array.from(this._assistantRef.value?.messages || []), i = e.log || [], o = [...t].sort((u, g) => g.id - u.id).find((u) => u.role === "user" && u.id <= e.id)?.content || null, r = i.find((u) => typeof u == "string" && u.includes("Agent picked:")) ?? null;
1765
1783
  if (!r)
1766
- return { agentPicked: null, taskAssigned: null, userMessage: a };
1784
+ return { agentPicked: null, taskAssigned: null, userMessage: o };
1767
1785
  const c = /Agent picked:\s*(.*?)\s*(?:\\n|\r?\n)\s*Task Assigned:\s*([\s\S]*)$/i, d = r.match(c);
1768
1786
  if (!d)
1769
- return { agentPicked: null, taskAssigned: null, userMessage: a };
1787
+ return { agentPicked: null, taskAssigned: null, userMessage: o };
1770
1788
  const h = d[1].trim(), y = d[2].trim();
1771
- return { agentPicked: h, taskAssigned: y, userMessage: a };
1789
+ return { agentPicked: h, taskAssigned: y, userMessage: o };
1772
1790
  }
1773
1791
  _emitItemIdFromAI(e) {
1774
1792
  const t = new CustomEvent("solutionIDFromAssistant", {