@arcgis/ai-components 5.2.0-next.13 → 5.2.0-next.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,58 +1,58 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import { c as $ } from "../../chunks/runtime.js";
3
- import { css as I, html as l } from "lit";
4
- import C from "@arcgis/core/core/Collection.js";
5
- import { whenOnce as P, watch as A, when as L } from "@arcgis/core/core/reactiveUtils.js";
6
- import x from "@arcgis/core/portal/Portal.js";
7
- import { LitElement as R, createEvent as p, nothing as k } from "@arcgis/lumina";
8
- import * as M from "@arcgis/toolkit/log";
9
- import { rethrowError as O } from "@arcgis/toolkit/log";
2
+ import { c as I } from "../../chunks/runtime.js";
3
+ import { css as C, html as c } from "lit";
4
+ import P from "@arcgis/core/core/Collection.js";
5
+ import { whenOnce as A, watch as L, when as x } from "@arcgis/core/core/reactiveUtils.js";
6
+ import R from "@arcgis/core/portal/Portal.js";
7
+ import { LitElement as M, createEvent as p, nothing as k } from "@arcgis/lumina";
8
+ import * as O from "@arcgis/toolkit/log";
9
+ import { rethrowError as D } from "@arcgis/toolkit/log";
10
10
  import { createRef as _, ref as v } from "lit/directives/ref.js";
11
- import { u as D } from "../../chunks/useT9n.js";
12
- import { O as T } from "../../chunks/orchestrator.js";
11
+ import { u as T } from "../../chunks/useT9n.js";
12
+ import { O as N } from "../../chunks/orchestrator.js";
13
13
  import "@langchain/core/callbacks/dispatch/web";
14
14
  import "@langchain/core/prompts";
15
15
  import "@langchain/openai";
16
- import N from "@arcgis/core/identity/IdentityManager.js";
16
+ import z from "@arcgis/core/identity/IdentityManager.js";
17
17
  import "@arcgis/toolkit/string";
18
18
  import "@arcgis/core/config.js";
19
19
  import "@langchain/core/messages";
20
20
  import "@arcgis/core/layers/FeatureLayer.js";
21
21
  import "../../chunks/generateLayerDescriptions.js";
22
22
  import "@langchain/langgraph/web";
23
- import z from "@arcgis/core/core/Accessor.js";
24
- import { property as b, subclass as B } from "@arcgis/core/core/accessorSupport/decorators.js";
25
- import { g as V } from "../../chunks/utils3.js";
23
+ import B from "@arcgis/core/core/Accessor.js";
24
+ import { property as b, subclass as V } from "@arcgis/core/core/accessorSupport/decorators.js";
25
+ import { g as j } from "../../chunks/utils3.js";
26
26
  import { g as w } from "../../chunks/slottableRequestUtils.js";
27
- const q = I`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%);--calcite-panel-content-bottom-space: 0}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%;background:var(--calcite-panel-background-color, var(--calcite-color-background))}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}.interrupt-waiting-message{font-style:italic;color:var(--calcite-color-text-2)}`;
28
- var H = Object.defineProperty, U = Object.getOwnPropertyDescriptor, m = (c, t, e, i) => {
29
- for (var r = i > 1 ? void 0 : i ? U(t, e) : t, n = c.length - 1, s; n >= 0; n--)
30
- (s = c[n]) && (r = (i ? s(t, e, r) : s(r)) || r);
31
- return i && r && H(t, e, r), r;
27
+ const q = C`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%);--calcite-panel-content-bottom-space: 0}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%;background:var(--calcite-panel-background-color, var(--calcite-color-background))}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}.interrupt-waiting-message{font-style:italic;color:var(--calcite-color-text-2)}`;
28
+ var H = Object.defineProperty, U = Object.getOwnPropertyDescriptor, m = (o, t, e, i) => {
29
+ for (var s = i > 1 ? void 0 : i ? U(t, e) : t, l = o.length - 1, r; l >= 0; l--)
30
+ (r = o[l]) && (s = (i ? r(t, e, s) : r(s)) || s);
31
+ return i && s && H(t, e, s), s;
32
32
  };
33
- const j = async (c) => await new Promise((t) => setTimeout(t, c));
34
- async function* F(c, {
33
+ const F = async (o) => await new Promise((t) => setTimeout(t, o)), E = (o) => !o || typeof o != "object" ? !1 : o.name === "AbortError";
34
+ async function* G(o, {
35
35
  chunkSize: t = 5,
36
36
  // chars per "token"
37
37
  delay: e = 20
38
38
  // ms between chunks
39
39
  } = {}) {
40
40
  let i = 0;
41
- for (; i < c.length; )
42
- yield c.slice(i, i + t), i += t, await j(e);
41
+ for (; i < o.length; )
42
+ yield o.slice(i, i + t), i += t, await F(e);
43
43
  }
44
- async function* E(c, t, e, i) {
45
- for await (const r of F(c)) {
44
+ async function* S(o, t, e, i) {
45
+ for await (const s of G(o)) {
46
46
  if (i?.aborted) {
47
47
  yield { type: "cancelled", log: e, runId: t };
48
48
  return;
49
49
  }
50
- yield { type: "block-data", blockType: "text", data: { content: r }, runId: t };
50
+ yield { type: "block-data", blockType: "text", data: { content: s }, runId: t };
51
51
  }
52
52
  }
53
- let d = class extends z {
54
- constructor(c) {
55
- super(c), this.view = null, this.loading = !1, this.processing = !1, this.processingStep = "";
53
+ let d = class extends B {
54
+ constructor(o) {
55
+ super(o), this.view = null, this.loading = !1, this.processing = !1, this.processingStep = "";
56
56
  }
57
57
  async load() {
58
58
  this._set("loading", !0);
@@ -66,14 +66,14 @@ let d = class extends z {
66
66
  this.orchestrator?.dispose(), super.destroy();
67
67
  }
68
68
  async _initialize() {
69
- this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await P(() => !this.view.updating), this._set(
69
+ this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await A(() => !this.view.updating), this._set(
70
70
  "orchestrator",
71
- await T.init({
71
+ await N.init({
72
72
  agents: [...this.agents],
73
73
  view: this.view ?? void 0
74
74
  })
75
75
  ), this.addHandles([
76
- A(
76
+ L(
77
77
  () => [this.view, this.agents],
78
78
  () => {
79
79
  this._initialize();
@@ -84,30 +84,29 @@ let d = class extends z {
84
84
  clearChatHistory() {
85
85
  this.orchestrator?.newConversation();
86
86
  }
87
- async *ask(c, t) {
87
+ async *ask(o, t) {
88
88
  if (!this.orchestrator)
89
89
  throw new Error("Orchestrator not initialized yet.");
90
90
  this._set("processing", !0), this._set("processingStep", "");
91
91
  const e = [];
92
- let i;
92
+ let i, s = "pending";
93
93
  try {
94
- const r = this.orchestrator.ask(c);
95
- for await (const n of r) {
96
- const s = n.runId;
97
- switch (n.type) {
94
+ const l = this.orchestrator.ask(o);
95
+ for await (const r of l)
96
+ switch (s = r.runId, r.type) {
98
97
  case "trace": {
99
- this._set("processingStep", n.data.text), e.push(n.data.text);
98
+ this._set("processingStep", r.data.text), e.push(r.data.text);
100
99
  break;
101
100
  }
102
101
  case "completed": {
103
102
  this._set("processing", !1), this._set("processingStep", "");
104
- const a = n.result, o = !!a.content.length, h = !!i?.length;
105
- if (!o && !h) {
103
+ const a = r.result, n = !!a.content.length, h = !!i?.length;
104
+ if (!n && !h) {
106
105
  yield { type: "completed", error: "No response received.", log: e, runId: s };
107
106
  return;
108
107
  }
109
108
  const g = a.content;
110
- if (yield { type: "block-start", blockType: "text", runId: s }, yield* E(g, s, e, t), yield { type: "block-end", blockType: "text", runId: s }, h)
109
+ if (yield { type: "block-start", blockType: "text", runId: s }, yield* S(g, s, e, t), yield { type: "block-end", blockType: "text", runId: s }, h)
111
110
  for (const f of i) {
112
111
  if (t?.aborted) {
113
112
  yield { type: "cancelled", log: e, runId: s };
@@ -115,8 +114,8 @@ let d = class extends z {
115
114
  }
116
115
  const { type: u, data: y } = f;
117
116
  if (yield { type: "block-start", blockType: u, runId: s }, u === "text") {
118
- const S = typeof y?.content == "string" ? y.content : "";
119
- yield* E(S, s, e, t);
117
+ const $ = typeof y?.content == "string" ? y.content : "";
118
+ yield* S($, s, e, t);
120
119
  } else
121
120
  yield { type: "block-data", blockType: u, data: y, runId: s };
122
121
  yield { type: "block-end", blockType: u, runId: s };
@@ -125,23 +124,23 @@ let d = class extends z {
125
124
  return;
126
125
  }
127
126
  case "ux-suggestion": {
128
- const a = n.suggestion;
127
+ const a = r.suggestion;
129
128
  i = i ? [...i, a] : [a];
130
129
  break;
131
130
  }
132
131
  case "interrupt": {
133
- const { kind: a, message: o, metadata: h } = n.interrupt, g = Array.isArray(h) ? h.filter((u) => typeof u == "string") : [], f = (() => {
132
+ const { kind: a, message: n, metadata: h } = r.interrupt, g = Array.isArray(h) ? h.filter((u) => typeof u == "string") : [], f = (() => {
134
133
  switch (a) {
135
134
  case "booleanChoice":
136
- return { type: "boolean-choice", message: o, options: g };
135
+ return { type: "boolean-choice", message: n, options: g };
137
136
  case "singleSelection":
138
- return { type: "single-select", message: o, options: g };
137
+ return { type: "single-select", message: n, options: g };
139
138
  case "multipleSelection":
140
- return { type: "multi-select", message: o, options: g };
139
+ return { type: "multi-select", message: n, options: g };
141
140
  case "textInput":
142
- return { type: "text-input", message: o };
141
+ return { type: "text-input", message: n };
143
142
  default:
144
- return { type: a, message: o, options: g };
143
+ return { type: a, message: n, options: g };
145
144
  }
146
145
  })();
147
146
  this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: f, runId: s };
@@ -152,17 +151,24 @@ let d = class extends z {
152
151
  return;
153
152
  }
154
153
  case "error": {
155
- yield { type: "completed", error: n.error.message, log: e, runId: s };
154
+ if (t?.aborted || E(r.error)) {
155
+ yield { type: "cancelled", log: e, runId: s };
156
+ return;
157
+ }
158
+ yield { type: "completed", error: r.error.message, log: e, runId: s };
156
159
  return;
157
160
  }
158
161
  default: {
159
- console.warn("Unknown event type:", n);
162
+ console.warn("Unknown event type:", r);
160
163
  break;
161
164
  }
162
165
  }
166
+ } catch (l) {
167
+ if (t?.aborted || E(l)) {
168
+ yield { type: "cancelled", log: e, runId: s };
169
+ return;
163
170
  }
164
- } catch (r) {
165
- console.warn("Error during message processing:", r), yield { type: "completed", error: "An error occurred during message processing.", log: e, runId: "error" };
171
+ console.warn("Error during message processing:", l), yield { type: "completed", error: "An error occurred during message processing.", log: e, runId: "error" };
166
172
  return;
167
173
  } finally {
168
174
  this._set("processing", !1);
@@ -194,12 +200,12 @@ m([
194
200
  b({ readOnly: !0 })
195
201
  ], d.prototype, "processingStep", 2);
196
202
  d = m([
197
- B("OrchestratorController")
203
+ V("OrchestratorController")
198
204
  ], d);
199
- const G = "Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.", W = "Embeddings not found for this web map.", Y = "https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings";
200
- class J extends R {
205
+ const W = "Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.", Y = "Embeddings not found for this web map.", J = "https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings";
206
+ class K extends M {
201
207
  constructor() {
202
- super(...arguments), this._messages = D({ blocking: !0 }), this.#t = _(), this.#n = _(), this.#s = _(), this.#e = null, this.#o = /* @__PURE__ */ new Map(), this.#i = x.getDefault(), this.#r = (t) => {
208
+ super(...arguments), this._messages = T({ blocking: !0 }), this.#t = _(), this.#n = _(), this.#s = _(), this.#e = null, this.#o = /* @__PURE__ */ new Map(), this.#r = R.getDefault(), this.#i = (t) => {
203
209
  t.stopPropagation(), this.cancelInterrupt();
204
210
  }, this.#a = (t) => {
205
211
  t.stopPropagation();
@@ -225,7 +231,7 @@ class J extends R {
225
231
  this._inputValue = e.prompt, this.arcgisPromptSelect.emit(e);
226
232
  }, this.#p = (t) => {
227
233
  this.arcgisSlottableRequest.emit(t.detail);
228
- }, this._orchestratorController = null, this._interrupt = null, this._interruptDetails = [], this._error = null, this._inputValue = "", this._isAnswering = !1, this._canceling = !1, this.messages = new C([]), this.referenceElement = null, this.suggestedPrompts = [], this.feedbackEnabled = !1, this.keepSuggestedPrompts = !1, this.logEnabled = !1, this.copyEnabled = !1, this.voiceInputEnabled = !1, this.readAloudEnabled = !1, this.assistantAvatarEnabled = !1, this.arcgisCancel = p(), this.arcgisError = p(), this.arcgisFeedback = p(), this.arcgisInterrupt = p(), this.arcgisInterruptCancel = p(), this.arcgisInterruptSubmit = p(), this.arcgisPromptSelect = p(), this.arcgisReady = p(), this.arcgisSubmit = p(), this.arcgisSlottableRequest = p({ bubbles: !1, composed: !1 }), this.arcgisResponse = p();
234
+ }, this._orchestratorController = null, this._interrupt = null, this._interruptDetails = [], this._error = null, this._inputValue = "", this._isAnswering = !1, this._canceling = !1, this.messages = new P([]), this.referenceElement = null, this.suggestedPrompts = [], this.feedbackEnabled = !1, this.keepSuggestedPrompts = !1, this.logEnabled = !1, this.copyEnabled = !1, this.voiceInputEnabled = !1, this.readAloudEnabled = !1, this.assistantAvatarEnabled = !1, this.arcgisCancel = p(), this.arcgisError = p(), this.arcgisFeedback = p(), this.arcgisInterrupt = p(), this.arcgisInterruptCancel = p(), this.arcgisInterruptSubmit = p(), this.arcgisPromptSelect = p(), this.arcgisReady = p(), this.arcgisSubmit = p(), this.arcgisSlottableRequest = p({ bubbles: !1, composed: !1 }), this.arcgisResponse = p();
229
235
  }
230
236
  static {
231
237
  this.properties = { _orchestratorController: 16, _interrupt: 16, _interruptDetails: 16, _error: 16, _inputValue: 16, _isAnswering: 16, _signedInUserId: 16, _canceling: 16, _isSignedIn: 16, _user: 16, awaitingResponse: 32, awaitingResponseStep: 32, interrupt: 32, messages: 0, orchestrator: 32, entryMessage: 1, heading: 1, description: 1, referenceElement: 1, suggestedPrompts: 0, feedbackEnabled: 5, keepSuggestedPrompts: 5, logEnabled: 5, copyEnabled: 5, voiceInputEnabled: 5, readAloudEnabled: 5, assistantAvatarEnabled: 5 };
@@ -238,8 +244,8 @@ class J extends R {
238
244
  #s;
239
245
  #e;
240
246
  #o;
241
- #i;
242
247
  #r;
248
+ #i;
243
249
  #a;
244
250
  #l;
245
251
  #c;
@@ -248,23 +254,23 @@ class J extends R {
248
254
  #p;
249
255
  async #d() {
250
256
  try {
251
- const t = V(this.el, this.referenceElement);
257
+ const t = j(this.el, this.referenceElement);
252
258
  await t?.componentOnReady();
253
259
  const e = [...this.#o.values()];
254
260
  return e.length ? (this._orchestratorController?.destroy(), this._orchestratorController = new d({
255
261
  agents: e,
256
- portal: this.#i,
262
+ portal: this.#r,
257
263
  view: t?.view
258
264
  }), await this._orchestratorController.load(), !0) : (this._error = "No agents found.", !1);
259
265
  } catch (t) {
260
- return this._error = t?.message ?? "Error initializing orchestrator.", O(this)(t), !1;
266
+ return this._error = t?.message ?? "Error initializing orchestrator.", D(this)(t), !1;
261
267
  }
262
268
  }
263
269
  get _isSignedIn() {
264
- return !!this.#i?.user || !!this._signedInUserId;
270
+ return !!this.#r?.user || !!this._signedInUserId;
265
271
  }
266
272
  get _user() {
267
- return this.#i?.user?.fullName || this.#i?.user?.username;
273
+ return this.#r?.user?.fullName || this.#r?.user?.username;
268
274
  }
269
275
  get awaitingResponse() {
270
276
  return this._orchestratorController?.processing ?? !1;
@@ -298,81 +304,81 @@ class J extends R {
298
304
  return;
299
305
  this.#e = new AbortController();
300
306
  const i = this._orchestratorController.ask(e, this.#e?.signal);
301
- for await (const r of i) {
302
- const n = r.runId, s = this.messages.at(-1);
303
- switch (r.type) {
307
+ for await (const s of i) {
308
+ const l = s.runId, r = this.messages.at(-1);
309
+ switch (s.type) {
304
310
  case "block-start": {
305
311
  this._isAnswering = !0;
306
- const a = { type: r.blockType, isPending: !0 };
307
- if (s?.role === "assistant" && s.id === n) {
308
- const o = [...s.blocks ?? [], a];
309
- this.messages.splice(-1, 1, { ...s, blocks: o });
312
+ const a = { type: s.blockType, isPending: !0 };
313
+ if (r?.role === "assistant" && r.id === l) {
314
+ const n = [...r.blocks ?? [], a];
315
+ this.messages.splice(-1, 1, { ...r, blocks: n });
310
316
  } else
311
317
  this.messages.push({
312
318
  role: "assistant",
313
319
  blocks: [a],
314
- id: n,
320
+ id: l,
315
321
  isStreaming: !0,
316
322
  interrupts: this._interruptDetails
317
323
  }), this._interruptDetails = [];
318
324
  break;
319
325
  }
320
326
  case "block-data": {
321
- if (s?.role !== "assistant" || s?.id !== n)
327
+ if (r?.role !== "assistant" || r?.id !== l)
322
328
  break;
323
- const a = [...s.blocks ?? []], o = a[a.length - 1], { blockType: h, data: g } = r;
324
- if (o?.type !== h || !o.isPending)
329
+ const a = [...r.blocks ?? []], n = a[a.length - 1], { blockType: h, data: g } = s;
330
+ if (n?.type !== h || !n.isPending)
325
331
  break;
326
332
  if (h === "text") {
327
- const f = typeof o.data?.content == "string" ? o.data.content : "", u = typeof g?.content == "string" ? g.content : "";
328
- a[a.length - 1] = { ...o, data: { ...o.data, content: f + u } };
333
+ const f = typeof n.data?.content == "string" ? n.data.content : "", u = typeof g?.content == "string" ? g.content : "";
334
+ a[a.length - 1] = { ...n, data: { ...n.data, content: f + u } };
329
335
  } else
330
- a[a.length - 1] = { ...o, data: { ...o.data, ...g ?? {} } };
331
- this.messages.splice(-1, 1, { ...s, blocks: a });
336
+ a[a.length - 1] = { ...n, data: { ...n.data, ...g ?? {} } };
337
+ this.messages.splice(-1, 1, { ...r, blocks: a });
332
338
  break;
333
339
  }
334
340
  case "block-end": {
335
- if (s?.role !== "assistant" || s?.id !== n)
341
+ if (r?.role !== "assistant" || r?.id !== l)
336
342
  break;
337
- const a = [...s.blocks ?? []], o = a[a.length - 1];
338
- if (o?.type !== r.blockType || !o.isPending)
343
+ const a = [...r.blocks ?? []], n = a[a.length - 1];
344
+ if (n?.type !== s.blockType || !n.isPending)
339
345
  break;
340
- const h = o;
341
- a[a.length - 1] = { ...h, data: { ...h.data }, isPending: !1 }, this.messages.splice(-1, 1, { ...s, blocks: a });
346
+ const h = n;
347
+ a[a.length - 1] = { ...h, data: { ...h.data }, isPending: !1 }, this.messages.splice(-1, 1, { ...r, blocks: a });
342
348
  break;
343
349
  }
344
350
  case "completed":
345
- r.error ? (this.messages.push({
351
+ s.error ? (this.messages.push({
346
352
  role: "assistant",
347
- log: r.log,
348
- error: r.error,
349
- id: n,
353
+ log: s.log,
354
+ error: s.error,
355
+ id: l,
350
356
  interrupts: this._interruptDetails
351
- }), this._interruptDetails = []) : s?.role === "assistant" && s.id === n && this.messages.splice(-1, 1, {
352
- ...s,
353
- content: r.response,
354
- blocks: s.blocks?.map((a) => ({ ...a, isPending: !1 })) ?? [],
357
+ }), this._interruptDetails = []) : r?.role === "assistant" && r.id === l && this.messages.splice(-1, 1, {
358
+ ...r,
359
+ content: s.response,
360
+ blocks: r.blocks?.map((a) => ({ ...a, isPending: !1 })) ?? [],
355
361
  isStreaming: !1,
356
- log: r.log
362
+ log: s.log
357
363
  }), this._isAnswering = !1, this.#e = null, this._canceling = !1;
358
364
  break;
359
365
  case "interrupt":
360
- this._interrupt = { ...r.payload, id: n }, this.arcgisInterrupt.emit(this._interrupt);
366
+ this._interrupt = { ...s.payload, id: l }, this.arcgisInterrupt.emit(this._interrupt);
361
367
  break;
362
368
  case "cancelled":
363
- s?.role === "assistant" && s.id === n ? this.messages.splice(-1, 1, {
364
- ...s,
365
- blocks: s.blocks?.filter((a) => a.type === "text" || !a.isPending) ?? [],
369
+ r?.role === "assistant" && r.id === l ? this.messages.splice(-1, 1, {
370
+ ...r,
371
+ blocks: r.blocks?.filter((a) => a.type === "text" || !a.isPending) ?? [],
366
372
  isStreaming: !1,
367
- log: r.log,
373
+ log: s.log,
368
374
  error: "(Stopped by user)"
369
375
  // TODO: use strings from t9n
370
376
  }) : (this.messages.push({
371
377
  role: "assistant",
372
- log: r.log,
378
+ log: s.log,
373
379
  error: "(Stopped by user)",
374
380
  // TODO: use strings from t9n
375
- id: n,
381
+ id: l,
376
382
  interrupts: this._interruptDetails
377
383
  }), this._interruptDetails = []), this._isAnswering = !1, this.#e = null, this._canceling = !1;
378
384
  break;
@@ -388,19 +394,19 @@ class J extends R {
388
394
  loaded() {
389
395
  this.manager.onLifecycle(() => {
390
396
  this.#t.value?.addEventListener("arcgisPromptSelect", this.#g), this.#t.value?.addEventListener("arcgisSubmit", this.#l), this.#t.value?.addEventListener("arcgisCancel", this.#c), this.#t.value?.addEventListener("arcgisFeedback", this.#h);
391
- const t = L(() => !!this._interrupt && !!this.#s.value, () => {
397
+ const t = x(() => !!this._interrupt && !!this.#s.value, () => {
392
398
  const i = this.#s.value;
393
- i.removeEventListener("arcgisSubmit", this.#a), i.removeEventListener("arcgisCancel", this.#r), i.addEventListener("arcgisSubmit", this.#a, { once: !0 }), i.addEventListener("arcgisCancel", this.#r, { once: !0 });
399
+ i.removeEventListener("arcgisSubmit", this.#a), i.removeEventListener("arcgisCancel", this.#i), i.addEventListener("arcgisSubmit", this.#a, { once: !0 }), i.addEventListener("arcgisCancel", this.#i, { once: !0 });
394
400
  }), e = this.messages.on("after-add", (i) => {
395
- const r = i.item;
396
- r.role === "assistant" && (r.error || r.content) && this.arcgisResponse.emit(r);
401
+ const s = i.item;
402
+ s.role === "assistant" && (s.error || s.content) && this.arcgisResponse.emit(s);
397
403
  });
398
404
  return queueMicrotask(() => {
399
405
  this.#d().then((i) => {
400
406
  i ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
401
407
  });
402
408
  }), () => {
403
- t.remove(), e.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#g), this.#s.value?.removeEventListener("arcgisSubmit", this.#a), this.#s.value?.removeEventListener("arcgisCancel", this.#r), this.#t.value?.removeEventListener("arcgisSubmit", this.#l), this.#t.value?.removeEventListener("arcgisCancel", this.#c), this.#t.value?.removeEventListener("arcgisFeedback", this.#h), this._orchestratorController?.destroy(), this._orchestratorController = null;
409
+ t.remove(), e.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#g), this.#s.value?.removeEventListener("arcgisSubmit", this.#a), this.#s.value?.removeEventListener("arcgisCancel", this.#i), this.#t.value?.removeEventListener("arcgisSubmit", this.#l), this.#t.value?.removeEventListener("arcgisCancel", this.#c), this.#t.value?.removeEventListener("arcgisFeedback", this.#h), this._orchestratorController?.destroy(), this._orchestratorController = null;
404
410
  };
405
411
  });
406
412
  }
@@ -408,29 +414,29 @@ class J extends R {
408
414
  this._orchestratorController?.cancel(), this.#e?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null, this._inputValue = "", this._signedInUserId = void 0;
409
415
  }
410
416
  _renderEntryMessage() {
411
- return this._isSignedIn ? this._error ? this._renderErrorNotice() : this.entryMessage ? this.messages.length > 0 ? null : l`<calcite-notice open kind=brand closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>` : l`<slot name=entry-message></slot>` : this._renderSignInNotice();
417
+ return this._isSignedIn ? this._error ? this._renderErrorNotice() : this.entryMessage ? this.messages.length > 0 ? null : c`<calcite-notice open kind=brand closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>` : c`<slot name=entry-message></slot>` : this._renderSignInNotice();
412
418
  }
413
419
  _renderSignInNotice() {
414
- const t = this.#i;
415
- return l`<calcite-notice slot=entry-message open kind=brand icon width=full><div slot=message>You need to sign in to use the assistant chat.</div>${t ? l`<calcite-link slot=link @click=${async () => {
420
+ const t = this.#r;
421
+ return c`<calcite-notice slot=entry-message open kind=brand icon width=full><div slot=message>You need to sign in to use the assistant chat.</div>${t ? c`<calcite-link slot=link @click=${async () => {
416
422
  try {
417
- const e = await N.getCredential(`${t.url}/sharing`);
423
+ const e = await z.getCredential(`${t.url}/sharing`);
418
424
  this._signedInUserId = e.userId, this._error = null, this.requestUpdate(), await this.#d() ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
419
425
  } catch (e) {
420
- this._error = e?.message ?? "Error signing in.", this.arcgisError.emit(new Error(this._error)), M.log("error", this, "Error signing in:", { detail: { error: e } });
426
+ this._error = e?.message ?? "Error signing in.", this.arcgisError.emit(new Error(this._error)), O.log("error", this, "Error signing in:", { detail: { error: e } });
421
427
  }
422
- }} target=_blank title="Sign in to ArcGIS Online">Sign in</calcite-link>` : l`<div slot=link>No portal information available</div>`}</calcite-notice>`;
428
+ }} target=_blank title="Sign in to ArcGIS Online">Sign in</calcite-link>` : c`<div slot=link>No portal information available</div>`}</calcite-notice>`;
423
429
  }
424
430
  _renderErrorNotice() {
425
- return this._error ? l`<calcite-notice slot=entry-message open kind=brand icon width=full>${this._error === G ? l`<div slot=message>${W}</div><calcite-link slot=link .href=${Y} target=_blank title="Learn about web map embeddings">Read more</calcite-link>` : l`<div slot=message>${this._error}</div>`}</calcite-notice>` : null;
431
+ return this._error ? c`<calcite-notice slot=entry-message open kind=brand icon width=full>${this._error === W ? c`<div slot=message>${Y}</div><calcite-link slot=link .href=${J} target=_blank title="Learn about web map embeddings">Read more</calcite-link>` : c`<div slot=message>${this._error}</div>`}</calcite-notice>` : null;
426
432
  }
427
433
  render() {
428
- return l`<calcite-panel .loading=${!this._orchestratorController && !this._error || this._orchestratorController?.loading} .heading=${this.heading ?? this._messages.assistantLabel} .description=${this.description} ${v(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages} .interrupt=${this._interrupt}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map((t) => t.role === "assistant" ? l`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#p} .assistantAvatarEnabled=${this.assistantAvatarEnabled}>${t.blocks?.map((e, i) => l`<slot name=${w(t.id, i) ?? k} slot=${w(t.id, i) ?? k}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>` : l`<arcgis-assistant-user-message .message=${t} .user=${this._user}></arcgis-assistant-user-message>`)}</slot>${this._interrupt ? l`<div slot=message-loading><div class="interrupt-waiting-message">waiting for user input...</div></div>` : l`<slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep} .assistantAvatarEnabled=${this.assistantAvatarEnabled} .interrupts=${this._interruptDetails}></arcgis-assistant-message-loading></slot>`}</arcgis-assistant-chat></div>${this._interrupt ? l`<slot name=interrupt><arcgis-assistant-interrupt slot=content-bottom .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${v(this.#s)}></arcgis-assistant-interrupt></slot>` : this.suggestedPrompts?.length ? l`<div class="suggested-prompts-container" slot=content-bottom><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>` : null}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse || this._isAnswering} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} .disabled=${this._canceling || !this._isSignedIn || !!this._interrupt} ${v(this.#n)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse || this._isAnswering ? "circle-stop" : "send"} @click=${() => {
434
+ return c`<calcite-panel .loading=${!this._orchestratorController && !this._error || this._orchestratorController?.loading} .heading=${this.heading ?? this._messages.assistantLabel} .description=${this.description} ${v(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages} .interrupt=${this._interrupt}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map((t) => t.role === "assistant" ? c`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#p} .assistantAvatarEnabled=${this.assistantAvatarEnabled}>${t.blocks?.map((e, i) => c`<slot name=${w(t.id, i) ?? k} slot=${w(t.id, i) ?? k}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>` : c`<arcgis-assistant-user-message .message=${t} .user=${this._user}></arcgis-assistant-user-message>`)}</slot>${this._interrupt ? c`<div slot=message-loading><div class="interrupt-waiting-message">waiting for user input...</div></div>` : c`<slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep} .assistantAvatarEnabled=${this.assistantAvatarEnabled} .interrupts=${this._interruptDetails}></arcgis-assistant-message-loading></slot>`}</arcgis-assistant-chat></div>${this._interrupt ? c`<slot name=interrupt><arcgis-assistant-interrupt slot=content-bottom .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${v(this.#s)}></arcgis-assistant-interrupt></slot>` : this.suggestedPrompts?.length ? c`<div class="suggested-prompts-container" slot=content-bottom><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>` : null}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse || this._isAnswering} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} .disabled=${this._canceling || !this._isSignedIn || !!this._interrupt} ${v(this.#n)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse || this._isAnswering ? "circle-stop" : "send"} @click=${() => {
429
435
  this.#n.value?.submitMessage();
430
436
  }} round>${this.awaitingResponse || this._isAnswering ? this._messages.stopButtonLabel : this._messages.askButtonLabel}</calcite-button></slot></arcgis-assistant-chat-entry></slot><slot name=footer-content></slot></div></calcite-panel>`;
431
437
  }
432
438
  }
433
- $("arcgis-assistant", J);
439
+ I("arcgis-assistant", K);
434
440
  export {
435
- J as ArcgisAssistant
441
+ K as ArcgisAssistant
436
442
  };