@arcgis/coding-components 5.1.0-next.13 → 5.1.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,60 +1,60 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import { c as Z } from "../../chunks/runtime.js";
3
- import { css as ee, html as d } from "lit";
4
- import { nothing as V, safeClassMap as te, LitElement as ie } from "@arcgis/lumina";
5
- import { ref as oe, createRef as ae } from "lit/directives/ref.js";
6
- import se from "@arcgis/core/identity/IdentityManager.js";
7
- import { u as ne } from "../../chunks/useT9n.js";
8
- import { b as N } from "../../chunks/arcade-defaults.js";
9
- import _ from "@arcgis/core/request.js";
10
- import { e as ce, a as re } from "../../chunks/utilities.js";
11
- import { repeat as Q } from "lit/directives/repeat.js";
2
+ import { c as ie } from "../../chunks/runtime.js";
3
+ import { css as oe, html as d } from "lit";
4
+ import { nothing as q, safeClassMap as ae, LitElement as se } from "@arcgis/lumina";
5
+ import { ref as ne, createRef as re } from "lit/directives/ref.js";
6
+ import ce from "@arcgis/core/identity/IdentityManager.js";
7
+ import { u as le } from "../../chunks/useT9n.js";
8
+ import { b as D } from "../../chunks/arcade-defaults.js";
9
+ import N from "@arcgis/core/request.js";
10
+ import { e as de, a as pe } from "../../chunks/utilities.js";
11
+ import { repeat as X } from "lit/directives/repeat.js";
12
12
  import "@arcgis/toolkit/function";
13
- import { generateGuid as le } from "@arcgis/toolkit/string";
13
+ import { generateGuid as ue } from "@arcgis/toolkit/string";
14
14
  import { unsafeHTML as A } from "lit/directives/unsafe-html.js";
15
- import de from "@arcgis/core/layers/FeatureLayer.js";
16
- import pe from "@arcgis/core/config.js";
17
- import ue from "@arcgis/core/Graphic.js";
18
- import { log as x } from "@arcgis/toolkit/log";
19
- import { getDeclaredVoxelMembers as he, getDeclaredPixelMembers as me } from "@arcgis/core/applications/Components/arcadeEditorUtils.js";
20
- import { s as fe } from "../../chunks/fields.js";
21
- import { h as Y, j as be } from "../../chunks/language-defaults-base.js";
22
- import ge from "@arcgis/core/core/Accessor.js";
23
- import { property as f, subclass as ve } from "@arcgis/core/core/accessorSupport/decorators.js";
24
- const ye = ee`:host(:not([closed])){container-type:size;--calcite-block-border-color: var(--calcite-color-transparent);box-sizing:border-box;.submission-actions-wrapper{display:flex;flex-direction:column;width:100%;gap:.75rem}.submission-actions{display:flex;flex-direction:row;gap:.5rem;justify-content:space-between}@container (max-width: 380px){.hidden-below-380{display:none}}@container (min-width: 380px){.hidden-above-380{display:none}}.gaps{display:flex;gap:.25rem}.align-inline-end{margin-inline-start:auto}.context-popover p{padding:0 .5rem;font-size:var(--calcite-font-size-sm)}.feedback-content{padding:var(--calcite-spacing-sm);display:flex;flex-direction:column;max-height:75cqb;overflow-y:auto;>*{margin-block-end:.5rem}>*:last-child,.terms-label{margin-block-end:0}calcite-text-area{--calcite-text-area-min-height: 4rem}calcite-notice{margin-block-start:0}}.feedback-sheet{--calcite-sheet-height: auto;--calcite-sheet-max-height: 100%;--calcite-sheet-min-height: auto}.feedback-footer{display:flex;justify-content:flex-end;gap:.5rem;width:100%}calcite-chip[slot=header-actions-end]{align-self:center;margin-inline-end:.5rem}calcite-flow-item calcite-shell{background:transparent}calcite-block{width:100%;max-width:100%;align-self:flex-end;background-color:transparent;margin-block:0}calcite-sheet{--calcite-sheet-scrim-background: rgba(200, 200, 200, .5)}calcite-list-item calcite-button{margin-inline-end:.25rem}calcite-flow-item calcite-shell calcite-notice{margin-block:1rem}calcite-block[open]:last-of-type{border-block-end:0}.text-area-wrapper{display:flex;border-radius:var(--calcite-corner-radius-round);margin:.75rem;overflow:hidden;--calcite-color-border-input: transparent;position:sticky;box-shadow:var(--calcite-shadow-sm);flex:none;flex-direction:column}calcite-text-area{height:auto;overflow:hidden;--calcite-font-weight-normal: 500;font-weight:500;line-height:1.2}calcite-flow{height:100%}calcite-popover calcite-list{--calcite-list-background-color: transparent;--calcite-input-border-color: transparent}calcite-popover calcite-list calcite-filter{--calcite-spacing-sm: 0}.contained-popover-or-tooltip{--calcite-popover-max-size-x: 100%;--calcite-tooltip-max-size-x: 100%}.info-heading{font-size:var(--calcite-font-size-0);color:var(--calcite-color-text-1);margin:0}.info-heading-row{display:flex;align-items:center;gap:var(--calcite-spacing-sm);flex-wrap:wrap}.unstyled-h3{margin:unset;font-size:var(--calcite-font-size-md)}.unstyled-shell{position:unset;inset:unset;display:unset;block-size:unset;inline-size:unset}.suggestion-button{font-weight:var(--calcite-font-weight-medium)}.suggestions{display:flex;flex-direction:row;gap:var(--calcite-spacing-xs);flex-wrap:wrap}.info-block{max-width:450px}#result-block{calcite-card-group{--calcite-card-group-gap: 1.25rem}calcite-card{--calcite-card-corner-radius: var(--calcite-corner-radius-round);--calcite-card-border-color: transparent;width:100%}.positioned-code-content{display:flex;flex-direction:row;gap:.5rem;padding:.5rem}calcite-card [slot=heading] calcite-chip{margin-block-start:.25rem}.code-response-wrapper{position:relative;background:var(--calcite-color-foreground-2);border-radius:var(--calcite-corner-radius-round);margin-top:-1.5rem}.prior-prompt{display:flex;flex-direction:row;padding:0;overflow-y:hidden;overflow-x:auto;margin:.25rem 0 .75rem;align-items:center;max-width:100%;span{overflow-x:auto;overflow-y:hidden}}.copy-feedback{display:none}.copy-prompt-button{align-self:flex-start;margin-inline-start:auto}.response-secondary-action-button[data-copied]+.copy-feedback,.copy-prompt-button[data-copied]+.copy-feedback{display:block;span{padding:.75rem 1rem;font-size:var(--calcite-font-size--2);line-height:1.375;color:var(--calcite-color-text--2);font-weight:var(--calcite-font-weight-medium)}}.copy-prompt-button[data-copied]~.copy-tooltip,.response-secondary-action-button[data-copied]~.copy-tooltip{display:none}code{white-space:pre;font-size:12px;margin:0;overflow-x:auto;font-family:Fira Mono,Consolas,Menlo,monospace;display:block;max-height:12rem;position:relative;padding:.5rem}.response-secondary-action-button{margin-left:.5rem}.add-to-editor-button{--calcite-internal-button-border-color: unset}}.collapsible-code{padding:.5rem}.collapsible-code summary{cursor:pointer;font-weight:500;color:var(--calcite-color-brand);outline:none;padding:.25rem 0}.collapsible-code[open] summary{color:var(--calcite-color-text-2)}.response-error-container{padding:.5rem;background:color-mix(in srgb,var(--calcite-color-status-warning) 10%,transparent);border-radius:var(--calcite-corner-radius-round);margin:1rem 0;font-size:var(--calcite-font-size--2);--calcite-input-message-icon-color: var(--calcite-color-status-warning)}.response-error-chip{--calcite-internal-chip-background-color: var(--calcite-color-status-warning);--calcite-chip-icon-color: var(--calcite-color-foreground-1);--calcite-chip-border-color: var(--calcite-color-transparent)}.feedback-actions{gap:unset}.contained{max-width:100%;max-height:100%;max-width:100cqi;max-height:75cqb;overflow-y:auto}.submission-notice{--calcite-notice-border-color: transparent;margin-block:0;width:100%;--calcite-font-size-relative-base: var(--calcite-font-size--2)}.border-block-end{border-block-end:1px solid var(--calcite-color-border-3)}.round-top{border-radius:var(--calcite-corner-radius-round) var(--calcite-corner-radius-round) 0 0}}:host([closed]){display:none}`;
15
+ import he from "@arcgis/core/layers/FeatureLayer.js";
16
+ import U from "@arcgis/core/config.js";
17
+ import L from "@arcgis/core/Graphic.js";
18
+ import { log as y } from "@arcgis/toolkit/log";
19
+ import { getDeclaredVoxelMembers as me, getDeclaredPixelMembers as fe } from "@arcgis/core/applications/Components/arcadeEditorUtils.js";
20
+ import { s as be } from "../../chunks/fields.js";
21
+ import { h as Z, j as ge } from "../../chunks/language-defaults-base.js";
22
+ import ve from "@arcgis/core/core/Accessor.js";
23
+ import { property as f, subclass as ye } from "@arcgis/core/core/accessorSupport/decorators.js";
24
+ const we = oe`:host(:not([closed])){container-type:size;--calcite-block-border-color: var(--calcite-color-transparent);box-sizing:border-box;.submission-actions-wrapper{display:flex;flex-direction:column;width:100%;gap:.75rem}.submission-actions{display:flex;flex-direction:row;gap:.5rem;justify-content:space-between}@container (max-width: 380px){.hidden-below-380{display:none}}@container (min-width: 380px){.hidden-above-380{display:none}}.gaps{display:flex;gap:.25rem}.align-inline-end{margin-inline-start:auto}.context-popover p{padding:0 .5rem;font-size:var(--calcite-font-size-sm)}.feedback-content{padding:var(--calcite-spacing-sm);display:flex;flex-direction:column;max-height:75cqb;overflow-y:auto;>*{margin-block-end:.5rem}>*:last-child,.terms-label{margin-block-end:0}calcite-text-area{--calcite-text-area-min-height: 4rem}calcite-notice{margin-block-start:0}}.feedback-sheet{--calcite-sheet-height: auto;--calcite-sheet-max-height: 100%;--calcite-sheet-min-height: auto}.feedback-footer{display:flex;justify-content:flex-end;gap:.5rem;width:100%}calcite-chip[slot=header-actions-end]{align-self:center;margin-inline-end:.5rem}calcite-flow-item calcite-shell{background:transparent}calcite-block{width:100%;max-width:100%;align-self:flex-end;background-color:transparent;margin-block:0}calcite-sheet{--calcite-sheet-scrim-background: rgba(200, 200, 200, .5)}calcite-list-item calcite-button{margin-inline-end:.25rem}calcite-flow-item calcite-shell calcite-notice{margin-block:1rem}calcite-block[open]:last-of-type{border-block-end:0}.text-area-wrapper{display:flex;border-radius:var(--calcite-corner-radius-round);margin:.75rem;overflow:hidden;--calcite-color-border-input: transparent;position:sticky;box-shadow:var(--calcite-shadow-sm);flex:none;flex-direction:column}calcite-text-area{height:auto;overflow:hidden;--calcite-font-weight-normal: 500;font-weight:500;line-height:1.2}calcite-flow{height:100%}calcite-popover calcite-list{--calcite-list-background-color: transparent;--calcite-input-border-color: transparent}calcite-popover calcite-list calcite-filter{--calcite-spacing-sm: 0}.contained-popover-or-tooltip{--calcite-popover-max-size-x: 100%;--calcite-tooltip-max-size-x: 100%}.info-heading{font-size:var(--calcite-font-size-0);color:var(--calcite-color-text-1);margin:0}.info-heading-row{display:flex;align-items:center;gap:var(--calcite-spacing-sm);flex-wrap:wrap}.unstyled-h3{margin:unset;font-size:var(--calcite-font-size-md)}.unstyled-shell{position:unset;inset:unset;display:unset;block-size:unset;inline-size:unset}.suggestion-button{font-weight:var(--calcite-font-weight-medium)}.suggestions{display:flex;flex-direction:row;gap:var(--calcite-spacing-xs);flex-wrap:wrap}.info-block{max-width:450px}#result-block{calcite-card-group{--calcite-card-group-gap: 1.25rem}calcite-card{--calcite-card-corner-radius: var(--calcite-corner-radius-round);--calcite-card-border-color: transparent;width:100%}.positioned-code-content{display:flex;flex-direction:row;gap:.5rem;padding:.5rem}calcite-card [slot=heading] calcite-chip{margin-block-start:.25rem}.code-response-wrapper{position:relative;background:var(--calcite-color-foreground-2);border-radius:var(--calcite-corner-radius-round);margin-top:-1.5rem}.prior-prompt{display:flex;flex-direction:row;padding:0;overflow-y:hidden;overflow-x:auto;margin:.25rem 0 .75rem;align-items:center;max-width:100%;span{overflow-x:auto;overflow-y:hidden}}.copy-feedback{display:none}.copy-prompt-button{align-self:flex-start;margin-inline-start:auto}.response-secondary-action-button[data-copied]+.copy-feedback,.copy-prompt-button[data-copied]+.copy-feedback{display:block;span{padding:.75rem 1rem;font-size:var(--calcite-font-size--2);line-height:1.375;color:var(--calcite-color-text--2);font-weight:var(--calcite-font-weight-medium)}}.copy-prompt-button[data-copied]~.copy-tooltip,.response-secondary-action-button[data-copied]~.copy-tooltip{display:none}code{white-space:pre;font-size:12px;margin:0;overflow-x:auto;font-family:Fira Mono,Consolas,Menlo,monospace;display:block;max-height:12rem;position:relative;padding:.5rem}.response-secondary-action-button{margin-left:.5rem}.add-to-editor-button{--calcite-internal-button-border-color: unset}}.collapsible-code{padding:.5rem}.collapsible-code summary{cursor:pointer;font-weight:500;color:var(--calcite-color-brand);outline:none;padding:.25rem 0}.collapsible-code[open] summary{color:var(--calcite-color-text-2)}.response-error-container{padding:.5rem;background:color-mix(in srgb,var(--calcite-color-status-warning) 10%,transparent);border-radius:var(--calcite-corner-radius-round);margin:1rem 0;font-size:var(--calcite-font-size--2);--calcite-input-message-icon-color: var(--calcite-color-status-warning)}.response-error-chip{--calcite-internal-chip-background-color: var(--calcite-color-status-warning);--calcite-chip-icon-color: var(--calcite-color-foreground-1);--calcite-chip-border-color: var(--calcite-color-transparent)}.feedback-actions{gap:unset}.contained{max-width:100%;max-height:100%;max-width:100cqi;max-height:75cqb;overflow-y:auto}.submission-notice{--calcite-notice-border-color: transparent;margin-block:0;width:100%;--calcite-font-size-relative-base: var(--calcite-font-size--2)}.border-block-end{border-block-end:1px solid var(--calcite-color-border-3)}.round-top{border-radius:var(--calcite-corner-radius-round) var(--calcite-corner-radius-round) 0 0}}:host([closed]){display:none}`;
25
25
  class C extends Error {
26
26
  constructor({
27
27
  message: e,
28
- code: i,
28
+ code: t,
29
29
  subCode: o,
30
30
  details: s,
31
31
  source: n
32
32
  }) {
33
- super(e), this.name = "ArcadeAssistantError", this.code = i, this.subCode = o, this.details = s, this.source = n;
33
+ super(e), this.name = "ArcadeAssistantError", this.code = t, this.subCode = o, this.details = s, this.source = n;
34
34
  }
35
35
  }
36
- function U(t) {
37
- if (!t)
36
+ function O(i) {
37
+ if (!i)
38
38
  return;
39
- const e = t.indexOf('{"error":');
39
+ const e = i.indexOf('{"error":');
40
40
  if (e !== -1)
41
41
  try {
42
- const i = t.slice(e), o = JSON.parse(i);
42
+ const t = i.slice(e), o = JSON.parse(t);
43
43
  if (o && typeof o == "object" && o.error)
44
44
  return o.error;
45
45
  } catch {
46
46
  return;
47
47
  }
48
48
  }
49
- async function we(t) {
50
- const { baseUrl: e, skillId: i, message: o, authToken: s, previousConversationId: n, context: r } = t, p = i ? `${e}/skills/${i}/chat` : `${e}/chat`, c = [], a = {
49
+ async function $e(i) {
50
+ const { baseUrl: e, skillId: t, message: o, authToken: s, previousConversationId: n, context: c } = i, p = t ? `${e}/skills/${t}/chat` : `${e}/chat`, r = [], a = {
51
51
  message: o,
52
- context: r
52
+ context: c
53
53
  };
54
54
  n && (a.conversation_id = n);
55
- let h;
55
+ let u;
56
56
  try {
57
- h = await _(p, {
57
+ u = await N(p, {
58
58
  method: "post",
59
59
  headers: {
60
60
  "Content-Type": "application/json",
@@ -64,33 +64,33 @@ async function we(t) {
64
64
  responseType: "json"
65
65
  });
66
66
  } catch (b) {
67
- const g = b, $ = g.details?.rawResponse || g.message || String(b), k = U($);
67
+ const g = b, x = g.details?.rawResponse || g.message || String(b), k = O(x);
68
68
  throw k ? new C(k) : b;
69
69
  }
70
- const l = h.data;
71
- c.push(l);
72
- const y = l.conversationId, q = l.inquiryId;
73
- let w = l.sequenceNumber;
70
+ const l = u.data;
71
+ r.push(l);
72
+ const w = l.conversationId, P = l.inquiryId;
73
+ let $ = l.sequenceNumber;
74
74
  async function T() {
75
75
  let b = 0;
76
76
  const g = 100;
77
77
  for (; b < g; ) {
78
78
  await new Promise((S) => setTimeout(S, 1e3));
79
- const $ = $e(y, w, q);
79
+ const x = xe(w, $, P);
80
80
  let k;
81
81
  try {
82
- k = await _(p, {
82
+ k = await N(p, {
83
83
  method: "post",
84
84
  headers: {
85
85
  "Content-Type": "application/json",
86
86
  token: s
87
87
  },
88
- body: JSON.stringify($),
88
+ body: JSON.stringify(x),
89
89
  responseType: "json"
90
90
  });
91
91
  } catch (S) {
92
- const F = S, X = F.details?.rawResponse || F.message || String(S), D = U(X);
93
- throw D ? new C(D) : S;
92
+ const V = S, te = V.details?.rawResponse || V.message || String(S), _ = O(te);
93
+ throw _ ? new C(_) : S;
94
94
  }
95
95
  const v = k.data;
96
96
  if (v.context?.kind === "ArcgisErrorAsContext" && v.context.error)
@@ -101,7 +101,7 @@ async function we(t) {
101
101
  details: v.context.error.details,
102
102
  source: "polling-response"
103
103
  });
104
- if (c.push(v), w = v.sequenceNumber, b++, !v.hasMore)
104
+ if (r.push(v), $ = v.sequenceNumber, b++, !v.hasMore)
105
105
  break;
106
106
  }
107
107
  if (b === g)
@@ -126,28 +126,28 @@ async function we(t) {
126
126
  I
127
127
  )
128
128
  )
129
- ]), c;
129
+ ]), r;
130
130
  }
131
- function $e(t, e, i) {
131
+ function xe(i, e, t) {
132
132
  return {
133
- conversationId: t,
134
- inquiryId: i,
133
+ conversationId: i,
134
+ inquiryId: t,
135
135
  ackSequenceNumber: e
136
136
  };
137
137
  }
138
- function xe(t) {
139
- return t.message.match(/Error in prompt shield/u) ? "I'm having trouble with this request. Try again by rephrasing the question." : t.code === "TIMEOUT" ? "Request timed out. Try again by re-asking the same question or rephrasing it." : t.message;
138
+ function ke(i) {
139
+ return i.message.match(/Error in prompt shield/u) ? "I'm having trouble with this request. Try again by rephrasing the question." : i.code === "TIMEOUT" ? "Request timed out. Try again by re-asking the same question or rephrasing it." : i.message;
140
140
  }
141
- const ke = ({ notices: t }) => t.length ? d`<div class="border-block-end">${Q(t, (e) => e.id ?? e.title, (e) => d`<calcite-notice class="submission-notice" .icon=${e.icon} .kind=${e.kind} scale=s open .closable=${e.closable} @calciteNoticeClose=${() => e.onClose?.()}><div slot=title>${e.title}</div>${e.message && d`<div slot=message>${e.message}</div>` || ""}${e.actionLinkMessage && e.onAction && d`<calcite-link slot=link @click=${() => e.onAction?.()}>${e.actionLinkMessage}</calcite-link>` || ""}</calcite-notice>`)}</div>` : null, Se = (t) => {
142
- const e = t.value.length, i = 72, o = 180, s = t.offsetWidth, r = Math.max(1, Math.floor(s / 8)), p = Math.ceil(e / r), c = i + (p - 2) * 24;
143
- t.style.setProperty("--calcite-text-area-min-height", `${Math.min(c, o)}px`);
144
- }, Ce = ({ promptValidationMessage: t, errorMessage: e, contextTooBig: i, contextReducedNoticeDismissed: o, setContextReducedNoticeDismissed: s, setErrorMessage: n, messages: r }) => {
141
+ const Se = ({ notices: i }) => i.length ? d`<div class="border-block-end">${X(i, (e) => e.id ?? e.title, (e) => d`<calcite-notice class="submission-notice" .icon=${e.icon} .kind=${e.kind} scale=s open .closable=${e.closable} @calciteNoticeClose=${() => e.onClose?.()}><div slot=title>${e.title}</div>${e.message && d`<div slot=message>${e.message}</div>` || ""}${e.actionLinkMessage && e.onAction && d`<calcite-link slot=link @click=${() => e.onAction?.()}>${e.actionLinkMessage}</calcite-link>` || ""}</calcite-notice>`)}</div>` : null, Ce = (i) => {
142
+ const e = i.value.length, t = 72, o = 180, s = i.offsetWidth, c = Math.max(1, Math.floor(s / 8)), p = Math.ceil(e / c), r = t + (p - 2) * 24;
143
+ i.style.setProperty("--calcite-text-area-min-height", `${Math.min(r, o)}px`);
144
+ }, Ae = ({ promptValidationMessage: i, errorMessage: e, contextTooBig: t, contextReducedNoticeDismissed: o, setContextReducedNoticeDismissed: s, setErrorMessage: n, messages: c }) => {
145
145
  const p = [];
146
- if (t && p.push({
146
+ if (i && p.push({
147
147
  id: "prompt-validation",
148
148
  kind: "danger",
149
149
  icon: "exclamation-mark-triangle",
150
- title: t,
150
+ title: i,
151
151
  closable: !0
152
152
  }), e && p.push({
153
153
  id: "assistant-error",
@@ -156,13 +156,13 @@ const ke = ({ notices: t }) => t.length ? d`<div class="border-block-end">${Q(t,
156
156
  title: e,
157
157
  closable: !0,
158
158
  onClose: () => n(void 0)
159
- }), i && !o) {
160
- const c = r.contextreduced ?? "Context reduced", a = r.contextreducedmessage ?? "The editor profile is too large for the assistant. It has been reduced in the assistant in order to ensure a successful request.";
159
+ }), t && !o) {
160
+ const r = c.contextreduced ?? "Context reduced", a = c.contextreducedmessage ?? "The editor profile is too large for the assistant. It has been reduced in the assistant in order to ensure a successful request.";
161
161
  p.push({
162
162
  id: "context-reduced",
163
163
  kind: "warning",
164
164
  icon: "exclamation-mark-triangle",
165
- title: c,
165
+ title: r,
166
166
  message: a,
167
167
  closable: !0,
168
168
  onClose: () => s(!0)
@@ -170,177 +170,177 @@ const ke = ({ notices: t }) => t.length ? d`<div class="border-block-end">${Q(t,
170
170
  }
171
171
  return p;
172
172
  };
173
- function Ae({ messages: t }) {
174
- return d`<calcite-chip slot=header-actions-end scale=s appearance=outline-fill .label=${t.beta ?? "Beta"}>${t.beta ?? "Beta"}</calcite-chip>`;
173
+ function Te({ messages: i }) {
174
+ return d`<calcite-chip slot=header-actions-end scale=s appearance=outline-fill .label=${i.beta ?? "Beta"}>${i.beta ?? "Beta"}</calcite-chip>`;
175
175
  }
176
- function Te({ popoverContent: t, messages: e }) {
177
- return d`<calcite-action icon=information slot=header-actions-end id=legal-disclaimer text></calcite-action><calcite-popover reference-element=legal-disclaimer .label=${e.legaldisclaimer ?? "Legal disclaimer"} placement=bottom auto-close focus-trap-disabled><div class="contained">${t}</div></calcite-popover>`;
176
+ function Ie({ popoverContent: i, messages: e }) {
177
+ return d`<calcite-action icon=information slot=header-actions-end id=legal-disclaimer text></calcite-action><calcite-popover reference-element=legal-disclaimer .label=${e.legaldisclaimer ?? "Legal disclaimer"} placement=bottom auto-close focus-trap-disabled><div class="contained">${i}</div></calcite-popover>`;
178
178
  }
179
- function Ie({ errorMessage: t, slot: e }) {
180
- return d`<div class="error-display"><calcite-input-message id=error-message status=invalid icon=exclamation-mark-triangle scale=m slot=${e ?? V}>${t}</calcite-input-message></div>`;
179
+ function Ee({ errorMessage: i, slot: e }) {
180
+ return d`<div class="error-display"><calcite-input-message id=error-message status=invalid icon=exclamation-mark-triangle scale=m slot=${e ?? q}>${i}</calcite-input-message></div>`;
181
181
  }
182
- function Re({ active: t, setActive: e, messages: i }) {
183
- return d`<calcite-alert slot=alerts .open=${t} placement=bottom kind=success icon=check-circle-f auto-close @calciteAlertClose=${() => e(!1)} .label=${i.expressionapplied ?? "Expression applied"}><div slot=message>${i.expressionapplied ?? "Expression applied to editor."}</div></calcite-alert>`;
182
+ function Re({ active: i, setActive: e, messages: t }) {
183
+ return d`<calcite-alert slot=alerts .open=${i} placement=bottom kind=success icon=check-circle-f auto-close @calciteAlertClose=${() => e(!1)} .label=${t.expressionapplied ?? "Expression applied"}><div slot=message>${t.expressionapplied ?? "Expression applied to editor."}</div></calcite-alert>`;
184
184
  }
185
- function Ee({ context: t, messages: e }) {
186
- return t ? d`<div class="gaps">${t.profileId && d`<calcite-popover auto-close placement=top .label=${(e.profilecontextlabel ?? "Profile context: {profileId}").replace("{profileId}", t.profileId)} reference-element=profile-context-button class="context-popover contained-popover-or-tooltip"><p>${(e.profilecontextlabel ?? "Profile context: {profileId}").replace("{profileId}", t.profileId)}</p></calcite-popover><calcite-button round kind=neutral icon-start=map-information id=profile-context-button scale=s></calcite-button>` || ""}</div>` : null;
185
+ function Fe({ context: i, messages: e }) {
186
+ return i ? d`<div class="gaps">${i.profileId && d`<calcite-popover auto-close placement=top .label=${(e.profilecontextlabel ?? "Profile context: {profileId}").replace("{profileId}", i.profileId)} reference-element=profile-context-button class="context-popover contained-popover-or-tooltip"><p>${(e.profilecontextlabel ?? "Profile context: {profileId}").replace("{profileId}", i.profileId)}</p></calcite-popover><calcite-button round kind=neutral icon-start=map-information id=profile-context-button scale=s></calcite-button>` || ""}</div>` : null;
187
187
  }
188
- function Me({ isDisabled: t, isReadOnly: e, setQuestion: i, setIsViewingResult: o, textAreaRef: s, question: n, errorMessage: r, setErrorMessage: p, promptValidationMessage: c, setPromptValidationMessage: a, submitQuestion: h, messages: l, mode: y, assistantRef: q, context: w, contextReducedNoticeDismissed: T, setContextReducedNoticeDismissed: I }) {
189
- const b = w?.contextTooLarge ?? !1, g = Ce({
190
- promptValidationMessage: c,
191
- errorMessage: r,
188
+ function Me({ isDisabled: i, isReadOnly: e, setQuestion: t, setIsViewingResult: o, textAreaRef: s, question: n, errorMessage: c, setErrorMessage: p, promptValidationMessage: r, setPromptValidationMessage: a, submitQuestion: u, messages: l, mode: w, assistantRef: P, context: $, contextReducedNoticeDismissed: T, setContextReducedNoticeDismissed: I }) {
189
+ const b = $?.contextTooLarge ?? !1, g = Ae({
190
+ promptValidationMessage: r,
191
+ errorMessage: c,
192
192
  contextTooBig: b,
193
193
  contextReducedNoticeDismissed: T,
194
194
  setContextReducedNoticeDismissed: I,
195
195
  setErrorMessage: p,
196
196
  messages: l
197
197
  });
198
- return d`<div class="text-area-wrapper">${ke({ notices: g })}<calcite-text-area scale=s resize=vertical .readOnly=${t || e} class=${te(g.length ? "submission-text-area" : "submission-text-area round-top")} .placeholder=${l.askaquestion ?? `Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${n} @calciteTextAreaInput=${($) => {
199
- Se($.target), i($.target.value);
200
- }} ${oe(s)}><div class="submission-actions-wrapper" slot=footer-start><div class="submission-actions">${w && Ee({ context: w, messages: l }) || ""}<div class="align-inline-end gaps"><calcite-button round kind=neutral .hidden=${y !== "refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid scale=s .disabled=${t} @click=${async () => {
201
- o(!1), i("");
202
- }} .label=${l.startover ?? "Start Over"} class="hidden-above-380" id=small-start-over-button></calcite-button><calcite-tooltip reference-element=small-start-over-button placement=top-start class="hidden-above-380">${l.startover ?? "Start Over"}</calcite-tooltip><calcite-button round kind=neutral .hidden=${y !== "refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid .disabled=${t} @click=${async () => {
203
- o(!1), i("");
204
- }} class="hidden-below-380" scale=s>${l.startover ?? "Start Over"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${t} .disabled=${t} @click=${async () => {
198
+ return d`<div class="text-area-wrapper">${Se({ notices: g })}<calcite-text-area scale=s resize=vertical .readOnly=${i || e} class=${ae(g.length ? "submission-text-area" : "submission-text-area round-top")} .placeholder=${l.askaquestion ?? `Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${n} @calciteTextAreaInput=${(x) => {
199
+ Ce(x.target), t(x.target.value);
200
+ }} ${ne(s)}><div class="submission-actions-wrapper" slot=footer-start><div class="submission-actions">${$ && Fe({ context: $, messages: l }) || ""}<div class="align-inline-end gaps"><calcite-button round kind=neutral .hidden=${w !== "refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid scale=s .disabled=${i} @click=${async () => {
201
+ o(!1), t("");
202
+ }} .label=${l.startover ?? "Start Over"} class="hidden-above-380" id=small-start-over-button></calcite-button><calcite-tooltip reference-element=small-start-over-button placement=top-start class="hidden-above-380">${l.startover ?? "Start Over"}</calcite-tooltip><calcite-button round kind=neutral .hidden=${w !== "refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid .disabled=${i} @click=${async () => {
203
+ o(!1), t("");
204
+ }} class="hidden-below-380" scale=s>${l.startover ?? "Start Over"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${i} .disabled=${i} @click=${async () => {
205
205
  if (p(""), !n) {
206
206
  a(l.enteraprompt ?? "Please enter a prompt");
207
207
  return;
208
208
  }
209
- a(void 0), await h();
210
- }} class="hidden-below-380">${y === "prompt" ? l.ask ?? "Generate" : l.refine ?? "Refine"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${t} .disabled=${t} id=small-submit-button @click=${async () => {
209
+ a(void 0), await u();
210
+ }} class="hidden-below-380">${w === "prompt" ? l.ask ?? "Generate" : l.refine ?? "Refine"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${i} .disabled=${i} id=small-submit-button @click=${async () => {
211
211
  if (p(""), !n) {
212
212
  a(l.enteraprompt ?? "Please enter a prompt");
213
213
  return;
214
214
  }
215
- a(void 0), await h();
216
- }} class="hidden-above-380" .label=${y === "prompt" ? l.ask ?? "Generate" : l.refine ?? "Refine"}></calcite-button><calcite-tooltip reference-element=small-submit-button placement=top-start class="hidden-above-380">${y === "prompt" ? l.ask ?? "Generate" : l.refine ?? "Refine"}</calcite-tooltip></div></div></div></calcite-text-area></div>`;
215
+ a(void 0), await u();
216
+ }} class="hidden-above-380" .label=${w === "prompt" ? l.ask ?? "Generate" : l.refine ?? "Refine"}></calcite-button><calcite-tooltip reference-element=small-submit-button placement=top-start class="hidden-above-380">${w === "prompt" ? l.ask ?? "Generate" : l.refine ?? "Refine"}</calcite-tooltip></div></div></div></calcite-text-area></div>`;
217
217
  }
218
- const Pe = "https://www.esri.com/en-us/privacy/privacy-statements/privacy-supplement", Ve = "https://www.esri.com/en-us/privacy/privacy-statements";
219
- function qe({ setOpen: t, messages: e, feedback: i, learnMoreUrl: o, setFeedback: s, onSubmit: n }) {
220
- return i.active ? d`<calcite-sheet class="feedback-sheet" .label=${e.feedback ?? "Feedback"} slot=sheets display-mode=float position=block-end .open=${i.active} @calciteSheetClose=${() => t(!1)}><calcite-panel .heading=${e.submitfeedback ?? "Submit feedback to Esri"} scale=s><div class="feedback-content"><calcite-text-area scale=s resize=vertical .value=${i.text} @calciteTextAreaInput=${(r) => s({ ...i, text: r.target.value })} .disabled=${i.submitting} .placeholder=${e.donotincludepersonalinfo ?? "Do not include personal or sensitive information"} rows=3></calcite-text-area><calcite-label layout=inline scale=s class="terms-label"><calcite-checkbox scale=l .checked=${i.termsAccepted} @calciteCheckboxChange=${(r) => {
221
- s({ ...i, termsAccepted: r.target.checked });
222
- }} .disabled=${i.submitting}></calcite-checkbox><span>${A((e.agreement ?? "I agree to the {EsriPrivacyStatement} (and {Supplement}).").replace("{EsriPrivacyStatement}", `<calcite-link href=${Ve} target="_blank">${e.esriprivacystatement ?? "Esri Privacy Statement"}</calcite-link>`).replace("{Supplement}", `<calcite-link href=${Pe} target="_blank">${e.supplement ?? "Supplement"}</calcite-link>`))}</span></calcite-label><calcite-notice scale=s open closable><span slot=message>${A((e.feedbackhelps ?? "Your feedback will be used to improve Esri products and services. {LearnMore} about how this data is used.").replace("{LearnMore}", `<calcite-link href=${o} target="_blank">${e.learnmore ?? "Learn more"}</calcite-link>`))}</span></calcite-notice></div><div slot=footer class="feedback-footer"><calcite-button kind=neutral appearance=outline @click=${() => t(!1)} .disabled=${i.submitting}>${e.cancel ?? "Cancel"}</calcite-button><calcite-button @click=${n} .disabled=${!i.termsAccepted || i.submitting} .loading=${i.submitting} data-testid=submit-feedback-button>${e.submit ?? "Submit"}</calcite-button></div></calcite-panel></calcite-sheet>` : null;
218
+ const qe = "https://www.esri.com/en-us/privacy/privacy-statements/privacy-supplement", Pe = "https://www.esri.com/en-us/privacy/privacy-statements";
219
+ function Ve({ setOpen: i, messages: e, feedback: t, learnMoreUrl: o, setFeedback: s, onSubmit: n }) {
220
+ return t.active ? d`<calcite-sheet class="feedback-sheet" .label=${e.feedback ?? "Feedback"} slot=sheets display-mode=float position=block-end .open=${t.active} @calciteSheetClose=${() => i(!1)}><calcite-panel .heading=${e.submitfeedback ?? "Submit feedback to Esri"} scale=s><div class="feedback-content"><calcite-text-area scale=s resize=vertical .value=${t.text} @calciteTextAreaInput=${(c) => s({ ...t, text: c.target.value })} .disabled=${t.submitting} .placeholder=${e.donotincludepersonalinfo ?? "Do not include personal or sensitive information"} rows=3></calcite-text-area><calcite-label layout=inline scale=s class="terms-label"><calcite-checkbox scale=l .checked=${t.termsAccepted} @calciteCheckboxChange=${(c) => {
221
+ s({ ...t, termsAccepted: c.target.checked });
222
+ }} .disabled=${t.submitting}></calcite-checkbox><span>${A((e.agreement ?? "I agree to the {EsriPrivacyStatement} (and {Supplement}).").replace("{EsriPrivacyStatement}", `<calcite-link href=${Pe} target="_blank">${e.esriprivacystatement ?? "Esri Privacy Statement"}</calcite-link>`).replace("{Supplement}", `<calcite-link href=${qe} target="_blank">${e.supplement ?? "Supplement"}</calcite-link>`))}</span></calcite-label><calcite-notice scale=s open closable><span slot=message>${A((e.feedbackhelps ?? "Your feedback will be used to improve Esri products and services. {LearnMore} about how this data is used.").replace("{LearnMore}", `<calcite-link href=${o} target="_blank">${e.learnmore ?? "Learn more"}</calcite-link>`))}</span></calcite-notice></div><div slot=footer class="feedback-footer"><calcite-button kind=neutral appearance=outline @click=${() => i(!1)} .disabled=${t.submitting}>${e.cancel ?? "Cancel"}</calcite-button><calcite-button @click=${n} .disabled=${!t.termsAccepted || t.submitting} .loading=${t.submitting} data-testid=submit-feedback-button>${e.submit ?? "Submit"}</calcite-button></div></calcite-panel></calcite-sheet>` : null;
223
223
  }
224
- function O({ assistantsEnabled: t, messages: e, slot: i, helpTopicUrl: o }) {
225
- return d`<calcite-block .label=${e.assistantinformation ?? "Assistant information"} slot=${i ?? V} expanded class="info-block" scale=s><div class="info-heading-row"><h1 class="info-heading">${e.introducing ?? "Introducing Arcade Assistant (beta)"}</h1><calcite-chip .label=${e.new ?? "New"} kind=brand scale=s>${e.new ?? "New"}</calcite-chip></div>${t ? d`<p>${e.capabilities ?? "The assistant uses artificial intelligence to generate Arcade expressions."}</p><p>${e.keepinmind ?? "Keep in mind the following:"}<ul><li>${e.beconsise ?? "Be concise, but also clear in your request"}</li><li>${e.avoidambiguity ?? "Avoid ambiguity and vagueness"}</li><li>${e.moredetails ?? "you do not need to use exact field names in your instructions, but more detail is generally better"}</li></ul>${A((e.seedocumentation ?? "Please see the {documentation} for more information, including limitations and additional resources.").replace("{documentation}", `<calcite-link href=${o} target="_blank">${e.documentation ?? "documentation"}</calcite-link>`))}</p>` : d`<p>${e.useofassistant ?? "The assistant uses artificial intelligence to generate Arcade expressions. To enable Arcade Assistant (beta), the following must be true:"}</p><ul><li>${e.enabledinorg ?? "AI assistants are enabled in the organization settings"}</li><li>${e.enabledbetaapps ?? "Beta apps and capabilities are not blocked"}</li><li>${e.enabledroleprivilege ?? "Your role privilege allows you to use AI assistants"}</li></ul>`}</calcite-block>`;
224
+ function z({ assistantsEnabled: i, messages: e, slot: t, helpTopicUrl: o }) {
225
+ return d`<calcite-block .label=${e.assistantinformation ?? "Assistant information"} slot=${t ?? q} expanded class="info-block" scale=s><div class="info-heading-row"><h1 class="info-heading">${e.introducing ?? "Introducing Arcade Assistant (beta)"}</h1><calcite-chip .label=${e.new ?? "New"} kind=brand scale=s>${e.new ?? "New"}</calcite-chip></div>${i ? d`<p>${e.capabilities ?? "The assistant uses artificial intelligence to generate Arcade expressions."}</p><p>${e.keepinmind ?? "Keep in mind the following:"}<ul><li>${e.beconsise ?? "Be concise, but also clear in your request"}</li><li>${e.avoidambiguity ?? "Avoid ambiguity and vagueness"}</li><li>${e.moredetails ?? "you do not need to use exact field names in your instructions, but more detail is generally better"}</li></ul>${A((e.seedocumentation ?? "Please see the {documentation} for more information, including limitations and additional resources.").replace("{documentation}", `<calcite-link href=${o} target="_blank">${e.documentation ?? "documentation"}</calcite-link>`))}</p>` : d`<p>${e.useofassistant ?? "The assistant uses artificial intelligence to generate Arcade expressions. To enable Arcade Assistant (beta), the following must be true:"}</p><ul><li>${e.enabledinorg ?? "AI assistants are enabled in the organization settings"}</li><li>${e.enabledbetaapps ?? "Beta apps and capabilities are not blocked"}</li><li>${e.enabledroleprivilege ?? "Your role privilege allows you to use AI assistants"}</li></ul>`}</calcite-block>`;
226
226
  }
227
- function Fe({ messages: t, onProceed: e, onExit: i, helpTopicUrl: o }) {
228
- return d`<calcite-dialog close-disabled placement=top .heading=${t.welcome ?? "Welcome to the new assistant experience"} slot=dialogs open width-scale=m id=welcome-dialog><h3 class="unstyled-h3">${t.beforeyougetstarted ?? "Before you get started be aware:"}</h3><ul><li>${t.maybeincorrect ?? "AI generated code may occasionally be incorrect or biased. Review carefully."}</li><li>${A((t.pleasereadhelp ?? "Read the Arcade Assistant (beta) {helpTopic} to get started and learn details on security, privacy and limitations.").replace("{helpTopic}", `<calcite-link href=${o} target="_blank">${t.helptopic ?? "help topic"}</calcite-link>`))}</li></ul><calcite-button id=welcome-proceed slot=footer-end @click=${e}>${t.proceed ?? "Proceed"}</calcite-button><calcite-button id=welcome-decline slot=footer-start @click=${i} kind=neutral>${t.exit ?? "Exit"}</calcite-button></calcite-dialog>`;
227
+ function _e({ messages: i, onProceed: e, onExit: t, helpTopicUrl: o }) {
228
+ return d`<calcite-dialog close-disabled placement=top .heading=${i.welcome ?? "Welcome to the new assistant experience"} slot=dialogs open width-scale=m id=welcome-dialog><h3 class="unstyled-h3">${i.beforeyougetstarted ?? "Before you get started be aware:"}</h3><ul><li>${i.maybeincorrect ?? "AI generated code may occasionally be incorrect or biased. Review carefully."}</li><li>${A((i.pleasereadhelp ?? "Read the Arcade Assistant (beta) {helpTopic} to get started and learn details on security, privacy and limitations.").replace("{helpTopic}", `<calcite-link href=${o} target="_blank">${i.helptopic ?? "help topic"}</calcite-link>`))}</li></ul><calcite-button id=welcome-proceed slot=footer-end @click=${e}>${i.proceed ?? "Proceed"}</calcite-button><calcite-button id=welcome-decline slot=footer-start @click=${t} kind=neutral>${i.exit ?? "Exit"}</calcite-button></calcite-dialog>`;
229
229
  }
230
- function De({ messages: t, suggestions: e, onSuggestionClick: i }) {
231
- return d`<calcite-block .heading=${t.promptsuggestions} expanded collapsible id=suggestion-block scale=s><div class="suggestions">${e.map((o) => d`<calcite-button round scale=s appearance=outline-fill kind=neutral .label=${t.promptsuggestion} class="suggestion-button" @click=${() => i?.(o)}>${o}</calcite-button>`)}</div></calcite-block>`;
230
+ function De({ messages: i, suggestions: e, onSuggestionClick: t }) {
231
+ return d`<calcite-block .heading=${i.promptsuggestions} expanded collapsible id=suggestion-block scale=s><div class="suggestions">${e.map((o) => d`<calcite-button round scale=s appearance=outline-fill kind=neutral .label=${i.promptsuggestion} class="suggestion-button" @click=${() => t?.(o)}>${o}</calcite-button>`)}</div></calcite-block>`;
232
232
  }
233
- const z = 200;
234
- function L({ hidden: t = !1, expanded: e = !1, messages: i, cards: o, heading: s, collapsible: n = !1, showEffectsIcon: r = !1, onCopyCode: p, standalone: c }) {
235
- return d`<calcite-block .hidden=${t} id=result-block .heading=${s ?? i.besteffort ?? "Here is the assistant's best effort"} .expanded=${e} .collapsible=${n}>${r && d`<calcite-chip .label=${i.assistantresponses ?? "Assistant responses"} slot=content-start icon=effects scale=m class="suggestion-chips"></calcite-chip>` || ""}<calcite-card-group .label=${i.assistantresponses ?? "Assistant responses"}>${Q(o, (a) => a.conversationId, (a) => d`<calcite-card><div slot=heading><div class="prior-prompt"><span>${a.priorPrompt.length > z ? `${a.priorPrompt.slice(0, z)}...` : a.priorPrompt}</span><calcite-action icon=duplicate scale=s slot=actions-end class="copy-prompt-button" text .id=${`copy-prompt-${a.conversationId}-${c ? "standalone" : "list"}`} @click=${(h) => {
236
- const l = h.currentTarget;
233
+ const j = 200;
234
+ function B({ hidden: i = !1, expanded: e = !1, messages: t, cards: o, heading: s, collapsible: n = !1, showEffectsIcon: c = !1, onCopyCode: p, standalone: r }) {
235
+ return d`<calcite-block .hidden=${i} id=result-block .heading=${s ?? t.besteffort ?? "Here is the assistant's best effort"} .expanded=${e} .collapsible=${n}>${c && d`<calcite-chip .label=${t.assistantresponses ?? "Assistant responses"} slot=content-start icon=effects scale=m class="suggestion-chips"></calcite-chip>` || ""}<calcite-card-group .label=${t.assistantresponses ?? "Assistant responses"}>${X(o, (a) => a.conversationId, (a) => d`<calcite-card><div slot=heading><div class="prior-prompt"><span>${a.priorPrompt.length > j ? `${a.priorPrompt.slice(0, j)}...` : a.priorPrompt}</span><calcite-action icon=duplicate scale=s slot=actions-end class="copy-prompt-button" text .id=${`copy-prompt-${a.conversationId}-${r ? "standalone" : "list"}`} @click=${(u) => {
236
+ const l = u.currentTarget;
237
237
  navigator.clipboard.writeText(a.priorPrompt).then(() => {
238
238
  l.setAttribute("data-copied", "true"), setTimeout(() => l.removeAttribute("data-copied"), 1500);
239
239
  });
240
- }}></calcite-action><calcite-popover .referenceElement=${`copy-prompt-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start class="copy-feedback" .label=${i.copiedsuccessfully ?? "copied successfully"} open trigger-disabled><span>${i.copiedsuccessfully ?? "copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-prompt-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start class="copy-tooltip">${i.copyprompttoclipboard ?? "Copy prompt to clipboard"}</calcite-tooltip></div>${a.message && c && d`<div class="response-error-container">${Ie({ errorMessage: a.message })}</div>` || ""}</div><div><div class="code-response-wrapper"><div class="positioned-code-content"><calcite-chip-group .label=${i.responsecontext ?? "Response Context"} scale=s>${a.message && !c && d`<calcite-tooltip .referenceElement=${`response-chip-${a.conversationId}-error`} placement=top-start>${a.message}</calcite-tooltip><calcite-chip .id=${`response-chip-${a.conversationId}-error`} .label=${i.error ?? "Error"} scale=s appearance=outline icon=exclamation-mark-triangle-f class="response-error-chip"></calcite-chip>` || ""}${Ne({ card: a, messages: i })}</calcite-chip-group></div><details class="collapsible-code" open><summary>Code response</summary><arcgis-code-viewer language=arcade round>${a.code}</arcgis-code-viewer></details></div></div><div slot=footer-start class="feedback-actions"><calcite-button class="add-to-editor-button hidden-above-380" @click=${() => a.onAddToEditor("add")} scale=s icon-start=plus round .label=${i.addtoeditor ?? "Add to editor"} .id=${`add-to-editor-button-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-button><calcite-tooltip class="hidden-above-380" .referenceElement=${`add-to-editor-button-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start>${i.addtoeditor ?? "Add to editor"}</calcite-tooltip><calcite-button class="add-to-editor-button hidden-below-380" @click=${() => a.onAddToEditor("add")} scale=s icon-start=plus round>${i.addtoeditor ?? "Add to editor"}</calcite-button><calcite-button round icon-start=file-code kind=neutral scale=s @click=${() => a.onAddToEditor("replace")} class="response-secondary-action-button" .id=${`replace-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-button><calcite-tooltip .referenceElement=${`replace-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start><span>${i.replaceineditor ?? "Replace all code in editor"}</span></calcite-tooltip><calcite-button round icon-start=copy-to-clipboard kind=neutral scale=s @click=${(h) => {
241
- const l = h.currentTarget;
240
+ }}></calcite-action><calcite-popover .referenceElement=${`copy-prompt-${a.conversationId}-${r ? "standalone" : "list"}`} placement=top-start class="copy-feedback" .label=${t.copiedsuccessfully ?? "copied successfully"} open trigger-disabled><span>${t.copiedsuccessfully ?? "copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-prompt-${a.conversationId}-${r ? "standalone" : "list"}`} placement=top-start class="copy-tooltip">${t.copyprompttoclipboard ?? "Copy prompt to clipboard"}</calcite-tooltip></div>${a.message && r && d`<div class="response-error-container">${Ee({ errorMessage: a.message })}</div>` || ""}</div><div><div class="code-response-wrapper"><div class="positioned-code-content"><calcite-chip-group .label=${t.responsecontext ?? "Response Context"} scale=s>${a.message && !r && d`<calcite-tooltip .referenceElement=${`response-chip-${a.conversationId}-error`} placement=top-start>${a.message}</calcite-tooltip><calcite-chip .id=${`response-chip-${a.conversationId}-error`} .label=${t.error ?? "Error"} scale=s appearance=outline icon=exclamation-mark-triangle-f class="response-error-chip"></calcite-chip>` || ""}${Ne({ card: a, messages: t })}</calcite-chip-group></div><details class="collapsible-code" open><summary>Code response</summary><arcgis-code-viewer language=arcade round>${a.code}</arcgis-code-viewer></details></div></div><div slot=footer-start class="feedback-actions"><calcite-button class="add-to-editor-button hidden-above-380" @click=${() => a.onAddToEditor("add")} scale=s icon-start=plus round .label=${t.addtoeditor ?? "Add to editor"} .id=${`add-to-editor-button-${a.conversationId}-${r ? "standalone" : "list"}`}></calcite-button><calcite-tooltip class="hidden-above-380" .referenceElement=${`add-to-editor-button-${a.conversationId}-${r ? "standalone" : "list"}`} placement=top-start>${t.addtoeditor ?? "Add to editor"}</calcite-tooltip><calcite-button class="add-to-editor-button hidden-below-380" @click=${() => a.onAddToEditor("add")} scale=s icon-start=plus round>${t.addtoeditor ?? "Add to editor"}</calcite-button><calcite-button round icon-start=file-code kind=neutral scale=s @click=${() => a.onAddToEditor("replace")} class="response-secondary-action-button" .id=${`replace-${a.conversationId}-${r ? "standalone" : "list"}`}></calcite-button><calcite-tooltip .referenceElement=${`replace-${a.conversationId}-${r ? "standalone" : "list"}`} placement=top-start><span>${t.replaceineditor ?? "Replace all code in editor"}</span></calcite-tooltip><calcite-button round icon-start=copy-to-clipboard kind=neutral scale=s @click=${(u) => {
241
+ const l = u.currentTarget;
242
242
  p(a.code).then(() => {
243
243
  l.setAttribute("data-copied", "true"), setTimeout(() => l.removeAttribute("data-copied"), 1500);
244
244
  });
245
- }} class="response-secondary-action-button" .id=${`copy-response-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-button><calcite-popover .referenceElement=${`copy-response-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start class="copy-feedback" .label=${i.copiedsuccessfully ?? "copied successfully"} open trigger-disabled><span>${i.copiedsuccessfully ?? "copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-response-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start class="copy-tooltip">${i.copytoclipboard ?? "Copy code to clipboard"}</calcite-tooltip></div><div slot=footer-end class="feedback-actions"><calcite-action .text=${i.thumbsup ?? "Thumbs up"} scale=s icon=thumbs-up @click=${a.onThumbsUp} .id=${`thumbs-up-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-up-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start><span>${i.helpful ?? "Helpful"}</span></calcite-tooltip><calcite-action .text=${i.thumbsdown ?? "Thumbs down"} scale=s icon=thumbs-down @click=${a.onThumbsDown} .id=${`thumbs-down-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-down-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start><span>${i.unhelpful ?? "Unhelpful"}</span></calcite-tooltip></div></calcite-card>`)}</calcite-card-group></calcite-block>`;
245
+ }} class="response-secondary-action-button" .id=${`copy-response-${a.conversationId}-${r ? "standalone" : "list"}`}></calcite-button><calcite-popover .referenceElement=${`copy-response-${a.conversationId}-${r ? "standalone" : "list"}`} placement=top-start class="copy-feedback" .label=${t.copiedsuccessfully ?? "copied successfully"} open trigger-disabled><span>${t.copiedsuccessfully ?? "copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-response-${a.conversationId}-${r ? "standalone" : "list"}`} placement=top-start class="copy-tooltip">${t.copytoclipboard ?? "Copy code to clipboard"}</calcite-tooltip></div><div slot=footer-end class="feedback-actions"><calcite-action .text=${t.thumbsup ?? "Thumbs up"} scale=s icon=thumbs-up @click=${a.onThumbsUp} .id=${`thumbs-up-${a.conversationId}-${r ? "standalone" : "list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-up-${a.conversationId}-${r ? "standalone" : "list"}`} placement=top-start><span>${t.helpful ?? "Helpful"}</span></calcite-tooltip><calcite-action .text=${t.thumbsdown ?? "Thumbs down"} scale=s icon=thumbs-down @click=${a.onThumbsDown} .id=${`thumbs-down-${a.conversationId}-${r ? "standalone" : "list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-down-${a.conversationId}-${r ? "standalone" : "list"}`} placement=top-start><span>${t.unhelpful ?? "Unhelpful"}</span></calcite-tooltip></div></calcite-card>`)}</calcite-card-group></calcite-block>`;
246
246
  }
247
- const Ne = ({ card: t, messages: e }) => {
248
- const i = le(), o = `response-chip-profile-${t.conversationId}-${i}`, s = (e.profilecontextlabel ?? "Profile context: {profileId}").replace("{profileId}", t.profileId);
249
- return d`<calcite-tooltip .referenceElement=${o} placement=top-start class="contained-popover-or-tooltip">${s}</calcite-tooltip><calcite-chip .label=${t.profileId} scale=s appearance=outline icon=map-information id=${o ?? V}>${t.profileId}</calcite-chip>`;
250
- }, j = (t) => t.type === "featureSet", R = (t) => {
251
- if (!be(t))
247
+ const Ne = ({ card: i, messages: e }) => {
248
+ const t = ue(), o = `response-chip-profile-${i.conversationId}-${t}`, s = (e.profilecontextlabel ?? "Profile context: {profileId}").replace("{profileId}", i.profileId);
249
+ return d`<calcite-tooltip .referenceElement=${o} placement=top-start class="contained-popover-or-tooltip">${s}</calcite-tooltip><calcite-chip .label=${i.profileId} scale=s appearance=outline icon=map-information id=${o ?? q}>${i.profileId}</calcite-chip>`;
250
+ }, H = (i) => i.type === "featureSet", E = (i) => {
251
+ if (!ge(i))
252
252
  return [];
253
253
  const e = [];
254
- return t.relationships?.forEach((i) => {
255
- e.push(i.toJSON());
254
+ return i.relationships?.forEach((t) => {
255
+ e.push(t.toJSON());
256
256
  }), e;
257
- }, E = (t) => t.length > 0 ? { relationships: t } : {}, _e = (t) => fe(t).map((e) => ({
257
+ }, R = (i) => i.length > 0 ? { relationships: i } : {}, Ue = (i) => be(i).map((e) => ({
258
258
  alias: e.alias,
259
259
  name: e.name,
260
260
  type: e.type,
261
261
  ...e.domain ? { domain: e.domain } : {}
262
- })), M = (t) => t ? { fields: _e(t) } : { fields: [] };
263
- async function B(t) {
264
- const e = await t.loadSource(), i = Y(e) && e.isTable, o = R(e);
262
+ })), F = (i) => i ? { fields: Ue(i) } : { fields: [] };
263
+ async function G(i) {
264
+ const e = await i.loadSource(), t = Z(e) && e.isTable, o = E(e);
265
265
  return {
266
- name: t.name,
266
+ name: i.name,
267
267
  type: "featureSet",
268
- isTable: i,
269
- ...M(e?.fields),
270
- ...E(o)
268
+ isTable: t,
269
+ ...F(e?.fields),
270
+ ...R(o)
271
271
  };
272
272
  }
273
- async function K(t) {
274
- switch (t.type) {
273
+ async function ee(i) {
274
+ switch (i.type) {
275
275
  case "feature": {
276
- const e = await t.loadSource(), i = R(e);
276
+ const e = await i.loadSource(), t = E(e);
277
277
  return {
278
- name: t.name,
279
- type: t.type,
280
- ...M(e?.fields),
281
- ...E(i)
278
+ name: i.name,
279
+ type: i.type,
280
+ ...F(e?.fields),
281
+ ...R(t)
282
282
  };
283
283
  }
284
284
  case "featureSet": {
285
- const e = await t.loadSource(), i = Y(e) && e.isTable;
285
+ const e = await i.loadSource(), t = Z(e) && e.isTable;
286
286
  return {
287
- name: t.name,
287
+ name: i.name,
288
288
  type: "featureSet",
289
- ...i ? { isTable: i } : {},
290
- ...M(e?.fields),
291
- ...E(R(e))
289
+ ...t ? { isTable: t } : {},
290
+ ...F(e?.fields),
291
+ ...R(E(e))
292
292
  };
293
293
  }
294
294
  case "featureSetCollection": {
295
- const e = await t.loadSource(), i = e?.layers.filter(j) ?? [], o = e?.tables.filter(j) ?? [], s = await Promise.all(i.map(B)), n = await Promise.all(o.map(B));
295
+ const e = await i.loadSource(), t = e?.layers.filter(H) ?? [], o = e?.tables.filter(H) ?? [], s = await Promise.all(t.map(G)), n = await Promise.all(o.map(G));
296
296
  return {
297
- name: t.name,
297
+ name: i.name,
298
298
  type: "featureSetCollection",
299
299
  layers: s,
300
300
  tables: n
301
301
  };
302
302
  }
303
303
  case "dictionary": {
304
- const e = await Promise.all(t.dictionaryVariables.map(K));
304
+ const e = await Promise.all(i.dictionaryVariables.map(ee));
305
305
  return {
306
- name: t.name,
306
+ name: i.name,
307
307
  type: "dictionary",
308
308
  attributes: e
309
309
  };
310
310
  }
311
311
  case "pixel": {
312
- const e = await t.loadSource();
312
+ const e = await i.loadSource();
313
313
  if (!e)
314
314
  return {
315
- name: t.name,
315
+ name: i.name,
316
316
  type: "pixel"
317
317
  };
318
- const i = await me(e);
318
+ const t = await fe(e);
319
319
  return {
320
- name: t.name,
320
+ name: i.name,
321
321
  type: "pixel",
322
- members: i.map(H)
322
+ members: t.map(J)
323
323
  };
324
324
  }
325
325
  case "voxel": {
326
- const e = await t.loadSource();
326
+ const e = await i.loadSource();
327
327
  if (!e)
328
328
  return {
329
- name: t.name,
329
+ name: i.name,
330
330
  type: "voxel"
331
331
  };
332
- const i = await he(e);
332
+ const t = await me(e);
333
333
  return {
334
- name: t.name,
334
+ name: i.name,
335
335
  type: "voxel",
336
- members: i.map(H)
336
+ members: t.map(J)
337
337
  };
338
338
  }
339
339
  case "array":
340
340
  return {
341
- name: t.name,
341
+ name: i.name,
342
342
  type: "array",
343
- elementType: t.elementType.type
343
+ elementType: i.elementType.type
344
344
  };
345
345
  case "number":
346
346
  case "text":
@@ -351,42 +351,42 @@ async function K(t) {
351
351
  case "geometry":
352
352
  case "time":
353
353
  return {
354
- name: t.name,
355
- type: t.type
354
+ name: i.name,
355
+ type: i.type
356
356
  };
357
357
  }
358
358
  }
359
- function H(t) {
360
- return t.type === "array" ? {
361
- name: t.name,
359
+ function J(i) {
360
+ return i.type === "array" ? {
361
+ name: i.name,
362
362
  type: "array",
363
- elementType: t.elementType.type
363
+ elementType: i.elementType.type
364
364
  } : {
365
- name: t.name,
366
- type: t.type
365
+ name: i.name,
366
+ type: i.type
367
367
  // casting bc member types shouldn't be feature, featureset, etc.
368
368
  };
369
369
  }
370
- async function Ue(t) {
370
+ async function Le(i) {
371
371
  return {
372
- variables: await Promise.all(t.variables.map(K))
372
+ variables: await Promise.all(i.variables.map(ee))
373
373
  };
374
374
  }
375
375
  const Oe = 1e5;
376
- function ze(t) {
377
- const e = new TextEncoder().encode(t).length;
376
+ function ze(i) {
377
+ const e = new TextEncoder().encode(i).length;
378
378
  return Math.ceil(e / 3.5);
379
379
  }
380
- function P(t) {
381
- return ze(JSON.stringify(t));
380
+ function M(i) {
381
+ return ze(JSON.stringify(i));
382
382
  }
383
- function Le(t) {
383
+ function je(i) {
384
384
  const e = (o) => ({
385
385
  name: o.name,
386
386
  type: o.type,
387
387
  ...o.isTable ? { isTable: o.isTable } : {},
388
388
  ...o.relationships ? { relationships: o.relationships } : {}
389
- }), i = (o) => {
389
+ }), t = (o) => {
390
390
  switch (o.type) {
391
391
  case "feature":
392
392
  case "featureSet":
@@ -408,7 +408,7 @@ function Le(t) {
408
408
  return {
409
409
  name: o.name,
410
410
  type: "dictionary",
411
- attributes: o.attributes.map(i)
411
+ attributes: o.attributes.map(t)
412
412
  };
413
413
  case "pixel":
414
414
  case "voxel":
@@ -427,67 +427,67 @@ function Le(t) {
427
427
  }
428
428
  };
429
429
  return {
430
- variables: t.variables.map(i)
430
+ variables: i.variables.map(t)
431
431
  };
432
432
  }
433
- function je(t) {
434
- const e = t.variables, i = e.length, o = e.find((n) => n.name === "$feature") ?? e.find((n) => n.type === "feature") ?? e[0], s = o ? [o] : [];
433
+ function Be(i) {
434
+ const e = i.variables, t = e.length, o = e.find((n) => n.name === "$feature") ?? e.find((n) => n.type === "feature") ?? e[0], s = o ? [o] : [];
435
435
  return {
436
436
  context: { variables: s },
437
- wasReduced: i !== s.length,
437
+ wasReduced: t !== s.length,
438
438
  reducedToVariableName: o?.name
439
439
  };
440
440
  }
441
- function Be(t) {
442
- return P(t) > Oe;
441
+ function He(i) {
442
+ return M(i) > Oe;
443
443
  }
444
- var He = Object.defineProperty, Ge = Object.getOwnPropertyDescriptor, m = (t, e, i, o) => {
445
- for (var s = o > 1 ? void 0 : o ? Ge(e, i) : e, n = t.length - 1, r; n >= 0; n--)
446
- (r = t[n]) && (s = (o ? r(e, i, s) : r(s)) || s);
447
- return o && s && He(e, i, s), s;
444
+ var Ge = Object.defineProperty, Je = Object.getOwnPropertyDescriptor, m = (i, e, t, o) => {
445
+ for (var s = o > 1 ? void 0 : o ? Je(e, t) : e, n = i.length - 1, c; n >= 0; n--)
446
+ (c = i[n]) && (s = (o ? c(e, t, s) : c(s)) || s);
447
+ return o && s && Ge(e, t, s), s;
448
448
  };
449
- let u = class extends ge {
450
- constructor(t) {
451
- super(t), this.viewMode = "prompt", this.confirmationActive = !1, this.contextReducedNoticeDismissed = !1, this.splashActive = !0, this.isSubmitting = !1, this.question = "", this.history = [], this.feedback = { active: !1 };
449
+ let h = class extends ve {
450
+ constructor(i) {
451
+ super(i), this.viewMode = "prompt", this.confirmationActive = !1, this.contextReducedNoticeDismissed = !1, this.splashActive = !0, this.isSubmitting = !1, this.question = "", this.history = [], this.feedback = { active: !1 };
452
452
  }
453
453
  };
454
454
  m([
455
455
  f()
456
- ], u.prototype, "viewMode", 2);
456
+ ], h.prototype, "viewMode", 2);
457
457
  m([
458
458
  f()
459
- ], u.prototype, "confirmationActive", 2);
459
+ ], h.prototype, "confirmationActive", 2);
460
460
  m([
461
461
  f()
462
- ], u.prototype, "contextReducedNoticeDismissed", 2);
462
+ ], h.prototype, "contextReducedNoticeDismissed", 2);
463
463
  m([
464
464
  f()
465
- ], u.prototype, "splashActive", 2);
465
+ ], h.prototype, "splashActive", 2);
466
466
  m([
467
467
  f()
468
- ], u.prototype, "isSubmitting", 2);
468
+ ], h.prototype, "isSubmitting", 2);
469
469
  m([
470
470
  f()
471
- ], u.prototype, "errorMessage", 2);
471
+ ], h.prototype, "errorMessage", 2);
472
472
  m([
473
473
  f()
474
- ], u.prototype, "promptValidationMessage", 2);
474
+ ], h.prototype, "promptValidationMessage", 2);
475
475
  m([
476
476
  f()
477
- ], u.prototype, "question", 2);
477
+ ], h.prototype, "question", 2);
478
478
  m([
479
479
  f()
480
- ], u.prototype, "history", 2);
480
+ ], h.prototype, "history", 2);
481
481
  m([
482
482
  f()
483
- ], u.prototype, "feedback", 2);
483
+ ], h.prototype, "feedback", 2);
484
484
  m([
485
485
  f()
486
- ], u.prototype, "context", 2);
487
- u = m([
488
- ve("ArcadeAssistantViewState")
489
- ], u);
490
- const Je = "arcade_generation", We = "ArcadeCodeRequest", G = "visualization", Qe = "ArcadeAssistant", Ye = [
486
+ ], h.prototype, "context", 2);
487
+ h = m([
488
+ ye("ArcadeAssistantViewState")
489
+ ], h);
490
+ const Qe = "arcade_generation", We = "ArcadeCodeRequest", Q = "visualization", W = "ArcadeAssistant", Ye = [
491
491
  "your_comments",
492
492
  "user_evaluation",
493
493
  "question",
@@ -496,14 +496,16 @@ const Je = "arcade_generation", We = "ArcadeCodeRequest", G = "visualization", Q
496
496
  "_source",
497
497
  "version",
498
498
  "context",
499
- "extras"
499
+ "extras",
500
+ "conversation_id",
501
+ "privacy_statement"
500
502
  ];
501
- let J = [], W = !0;
502
- class Ke extends ie {
503
+ let Y = [], K = !0;
504
+ class Ke extends se {
503
505
  constructor() {
504
- super(...arguments), this.textAreaRef = ae(), this.messages = ne(), this._feedbackService = void 0, this.viewState = new u(), this.handleFeedbackButton = (e, i) => {
506
+ super(...arguments), this.textAreaRef = re(), this.messages = le(), this._feedbackService = void 0, this.viewState = new h(), this.handleFeedbackButton = (e, t) => {
505
507
  this.updateViewState({
506
- feedback: { active: !0, value: e, item: i, termsAccepted: !1, text: "", submitting: !1 }
508
+ feedback: { active: !0, value: e, item: t, termsAccepted: !1, text: "", submitting: !1 }
507
509
  });
508
510
  }, this.handleFeedbackSheetClose = () => {
509
511
  this.updateViewState({ feedback: { active: !1 } });
@@ -516,31 +518,25 @@ class Ke extends ie {
516
518
  this.handleFeedbackSheetClose();
517
519
  return;
518
520
  }
519
- const i = this.viewState.feedback.item.contextSnapshot, o = pe.applicationName;
520
- !o && !this.appVersion && x("warn", this, "esriConfig.applicationName is not set. Consider setting it to help identify the application version in feedback.");
521
- const { value: s, text: n, termsAccepted: r, item: { question: p, formattedScript: c, conversationId: a } } = this.viewState.feedback, h = {
521
+ const t = this.viewState.feedback.item.contextSnapshot, o = U.applicationName;
522
+ !o && !this.appVersion && y("warn", this, "esriConfig.applicationName is not set. Consider setting it to help identify the application version in feedback.");
523
+ const { value: s, text: n, termsAccepted: c, item: { question: p, formattedScript: r, conversationId: a } } = this.viewState.feedback, u = {
522
524
  user_evaluation: s,
523
525
  your_comments: n || void 0,
524
526
  question: p ?? "",
525
- /**
526
- * The answer may contain invalid or partial HTML, which causes the feature service's HTML sanitizer to strip or reject it.
527
- * To preserve the content reliably, we encode it using encodeURIComponent, which escapes all non-ASCII and special characters.
528
- * This ensures the content passes through the sanitizer safely and can be decoded later. This is a temporary workaround until
529
- * the sanitizer can be disabled on the service.
530
- */
531
- answer: encodeURIComponent(c ?? ""),
527
+ answer: this.encodeAnswerForFeedback(r),
532
528
  useragent: navigator.userAgent,
533
- _source: Qe,
529
+ _source: W,
534
530
  version: this.appVersion || o || "NOT_SET",
535
- context: i ? JSON.stringify(i) : "",
536
- extras: i?.profileId ?? "",
531
+ context: t ? JSON.stringify(t) : "",
532
+ extras: t?.profileId ?? "",
537
533
  conversation_id: a ?? "",
538
- privacy_statement: r ? "I_agree" : ""
534
+ privacy_statement: c ? "I_agree" : ""
539
535
  };
540
536
  try {
541
- await e.applyEdits({ addFeatures: [new ue({ attributes: h })] });
537
+ await e.applyEdits({ addFeatures: [new L({ attributes: u })] });
542
538
  } catch (l) {
543
- x("error", this, "Error submitting feedback.", { detail: { error: l } });
539
+ y("error", this, "Error submitting feedback.", { detail: { error: l } });
544
540
  }
545
541
  this.handleFeedbackSheetClose();
546
542
  }, this.handleClose = (e) => {
@@ -551,13 +547,13 @@ class Ke extends ie {
551
547
  this.updateViewState({ feedback: e });
552
548
  }, this.onSuggestionClick = (e) => {
553
549
  this.textAreaRef.value && (this.textAreaRef.value.value = e, this.textAreaRef.value.setFocus(), this.setQuestionState(e));
554
- }, this.helpBase = "", this.assistantsEnabled = !1, this.closed = !1;
550
+ }, this.helpBase = "", this.assistantsEnabled = !1, this.closed = !1, this.disableQuestionAnswerLogging = !1;
555
551
  }
556
552
  static {
557
- this.properties = { closePanel: 0, insertText: 0, helpBase: 1, assistantsEnabled: 5, portalUrl: 1, serviceUrl: 1, closed: 7, editorRef: 0, feedbackServiceUrl: 1, appVersion: 1 };
553
+ this.properties = { closePanel: 0, insertText: 0, helpBase: 1, assistantsEnabled: 5, portalUrl: 1, serviceUrl: 1, closed: 7, editorRef: 0, feedbackServiceUrl: 1, appVersion: 1, disableQuestionAnswerLogging: 5 };
558
554
  }
559
555
  static {
560
- this.styles = ye;
556
+ this.styles = we;
561
557
  }
562
558
  get disclaimerComment() {
563
559
  return `// ${this.messages.disclaimercomment}
@@ -567,65 +563,68 @@ class Ke extends ie {
567
563
  return `${this.helpBase ?? "https://doc.arcgis.com/en/arcgis-online/"}create-maps/understand-arcade-assistant.htm`;
568
564
  }
569
565
  get usingTheAssitantDocUrl() {
570
- return `${this.helpBase ?? "https://doc.arcgis.com/en/arcgis-online/"}create-maps/use-arcade-assistant.htm`;
566
+ return `${this.helpBase ?? "https://doc.arcgis.com/en/arcgis-online/"}create-maps/understand-arcade-assistant.htm`;
571
567
  }
572
568
  async destroy() {
573
569
  }
574
570
  connectedCallback() {
575
- super.connectedCallback(), this.updateViewState({ history: J, splashActive: W });
571
+ super.connectedCallback(), this.updateViewState({ history: Y, splashActive: K });
576
572
  }
577
573
  load() {
578
574
  const e = async () => {
579
- const i = this.getModel();
580
- if (!i) {
575
+ const t = this.getModel();
576
+ if (!t) {
581
577
  this.updateViewState({ context: void 0 });
582
578
  return;
583
579
  }
584
- const o = await this.getProfileAndMetadata(i.uri);
580
+ const o = await this.getProfileAndMetadata(t.uri);
585
581
  this.updateViewState({
586
582
  context: o,
587
583
  contextReducedNoticeDismissed: o.contextTooLarge ? !1 : this.viewState.contextReducedNoticeDismissed
588
584
  });
589
585
  };
590
- e().catch((i) => {
591
- x("error", this, "Error setting initial context.", { detail: { error: i } });
586
+ e().catch((t) => {
587
+ y("error", this, "Error setting initial context.", { detail: { error: t } });
592
588
  }), this.manager.onLifecycle(() => {
593
- const i = N.onModelContextDidChange(async () => {
589
+ const t = D.onModelContextDidChange(async () => {
594
590
  e().catch((s) => {
595
- x("error", this, "Error setting context.", { detail: { error: s } });
591
+ y("error", this, "Error setting context.", { detail: { error: s } });
596
592
  });
597
593
  });
598
594
  return { remove: () => {
599
- i.dispose();
595
+ t.dispose();
600
596
  } };
601
597
  });
602
598
  }
603
599
  disconnectedCallback() {
604
- super.disconnectedCallback(), J = this.viewState.history, W = this.viewState.splashActive, this.copySuccessTimer && (clearTimeout(this.copySuccessTimer), this.copySuccessTimer = void 0);
600
+ super.disconnectedCallback(), Y = this.viewState.history, K = this.viewState.splashActive, this.copySuccessTimer && (clearTimeout(this.copySuccessTimer), this.copySuccessTimer = void 0);
605
601
  }
606
602
  createFeedbackContextSnapshot(e) {
607
- const i = Le(e.metadata);
603
+ const t = je(e.metadata);
608
604
  return {
609
605
  ...e,
610
- metadata: i,
611
- estimatedTokens: P(i)
606
+ metadata: t,
607
+ estimatedTokens: M(t)
612
608
  };
613
609
  }
610
+ encodeAnswerForFeedback(e) {
611
+ return encodeURIComponent(e ?? "");
612
+ }
614
613
  updateViewState(e) {
615
614
  this.viewState.set(e);
616
615
  }
617
616
  getHistoryCards() {
618
- return this.viewState.history.reduce((e, i) => (!i.script || (e.push({
619
- priorPrompt: i.question,
620
- code: i.formattedScript || i.error || "",
621
- profileId: i.profile ?? G,
617
+ return this.viewState.history.reduce((e, t) => (!t.script || (e.push({
618
+ priorPrompt: t.question,
619
+ code: t.formattedScript || t.error || "",
620
+ profileId: t.profile ?? Q,
622
621
  onAddToEditor: (o) => {
623
- ce(this.editorRef.editorInstance, i.formattedScript ?? "", o, this.disclaimerComment);
622
+ de(this.editorRef.editorInstance, t.formattedScript ?? "", o, this.disclaimerComment);
624
623
  },
625
- onThumbsUp: () => this.handleFeedbackButton("good", i),
626
- onThumbsDown: () => this.handleFeedbackButton("bad", i),
627
- conversationId: i.conversationId ?? "",
628
- message: i.message
624
+ onThumbsUp: () => this.handleFeedbackButton("good", t),
625
+ onThumbsDown: () => this.handleFeedbackButton("bad", t),
626
+ conversationId: t.conversationId ?? "",
627
+ message: t.message
629
628
  }), this.viewState.viewMode === "result"), e), []);
630
629
  }
631
630
  async ensureFeedbackService() {
@@ -633,111 +632,162 @@ class Ke extends ie {
633
632
  return this._feedbackService;
634
633
  if (!this.feedbackServiceUrl)
635
634
  return;
636
- const e = new de({ url: this.feedbackServiceUrl });
635
+ const e = new he({ url: this.feedbackServiceUrl });
637
636
  await e.load();
638
- const i = Ye.filter((o) => !e.fields.some((s) => s.name === o));
639
- if (i.length > 0) {
640
- x("error", this, `Missing the following fields in feedback service: ${i.join(", ")}. Feedback will not be logged.`);
637
+ const t = Ye.filter((o) => !e.fields.some((s) => s.name === o));
638
+ if (t.length > 0) {
639
+ y("error", this, `Missing the following fields in feedback service: ${t.join(", ")}. Feedback will not be logged.`);
641
640
  return;
642
641
  }
643
642
  return this._feedbackService = e, e;
644
643
  }
644
+ async logInteractionToFeedbackService(e) {
645
+ if (this.disableQuestionAnswerLogging || !e.question)
646
+ return;
647
+ let t;
648
+ try {
649
+ t = await this.ensureFeedbackService();
650
+ } catch (c) {
651
+ y("error", this, "Error initializing feedback service for interaction logging.", { detail: { error: c } });
652
+ return;
653
+ }
654
+ if (!t)
655
+ return;
656
+ const o = U.applicationName, s = e.contextSnapshot, n = {
657
+ question: e.question,
658
+ answer: this.encodeAnswerForFeedback(e.answer),
659
+ useragent: navigator.userAgent,
660
+ _source: W,
661
+ version: this.appVersion || o || "NOT_SET",
662
+ context: s ? JSON.stringify(s) : "",
663
+ extras: s?.profileId ?? "",
664
+ conversation_id: e.conversationId ?? "",
665
+ privacy_statement: ""
666
+ };
667
+ try {
668
+ await t.applyEdits({ addFeatures: [new L({ attributes: n })] });
669
+ } catch (c) {
670
+ y("error", this, "Error logging arcade assistant question/answer interaction.", { detail: { error: c } });
671
+ }
672
+ }
645
673
  getModel() {
646
674
  return this.editorRef.editorInstance?.getModel();
647
675
  }
648
676
  async submitQuestion() {
649
- if (this.viewState.question) {
650
- this.updateViewState({ isSubmitting: !0, errorMessage: void 0 });
651
- try {
652
- const e = await this.getToken(), i = this.getModel();
653
- if (!i || !this.serviceUrl)
654
- return;
655
- const o = this.viewState.context ?? await this.getProfileAndMetadata(i.uri), n = (await we({
656
- baseUrl: this.serviceUrl,
657
- skillId: Je,
658
- message: this.viewState.question,
659
- authToken: e,
677
+ if (!this.viewState.question)
678
+ return;
679
+ const e = this.viewState.question;
680
+ this.updateViewState({ isSubmitting: !0, errorMessage: void 0 });
681
+ let t, o;
682
+ try {
683
+ const s = this.getModel();
684
+ if (!s || !this.serviceUrl)
685
+ return;
686
+ const n = this.viewState.context ?? await this.getProfileAndMetadata(s.uri);
687
+ t = this.createFeedbackContextSnapshot(n);
688
+ const c = await this.getToken(), p = await $e({
689
+ baseUrl: this.serviceUrl,
690
+ skillId: Qe,
691
+ message: e,
692
+ authToken: c,
693
+ context: {
694
+ kind: We,
660
695
  context: {
661
- kind: We,
662
- context: {
663
- profile_id: o.profileId,
664
- metadata: [o.metadata]
665
- }
696
+ profile_id: n.profileId,
697
+ metadata: [n.metadata]
666
698
  }
667
- })).find((r) => r.context?.kind === "ArcadeCodeResponse");
668
- if (!n)
669
- return;
670
- if (n.context?.kind === "ArcadeCodeResponse") {
671
- const r = this.createFeedbackContextSnapshot(o);
672
- this.updateViewState({
673
- history: [
674
- {
675
- script: n?.context?.arcadeCode?.code,
676
- formattedScript: re(n?.context?.arcadeCode?.code ?? ""),
677
- error: void 0,
678
- question: this.viewState.question,
679
- profile: o.profileId,
680
- conversationId: n.conversationId,
681
- contextSnapshot: r,
682
- ...n.message ? { message: n.message } : {}
683
- },
684
- ...this.viewState.history
685
- ],
686
- viewMode: "result",
687
- errorMessage: void 0
688
- });
689
699
  }
690
- } catch (e) {
691
- e instanceof Error && e.name === "ArcadeAssistantError" ? this.updateViewState({
692
- errorMessage: xe(e) || this.messages.erroroccurred || "An error occurred."
693
- }) : this.updateViewState({ errorMessage: this.messages.erroroccurred || "An error occurred." }), x("error", this, "Error submitting question", { detail: { error: e } });
694
- } finally {
695
- this.updateViewState({ isSubmitting: !1 });
700
+ });
701
+ o = p?.[0]?.conversationId;
702
+ const r = p.find((a) => a.context?.kind === "ArcadeCodeResponse");
703
+ if (!r) {
704
+ await this.logInteractionToFeedbackService({
705
+ question: e,
706
+ answer: "No ArcadeCodeResponse returned.",
707
+ contextSnapshot: t,
708
+ conversationId: o
709
+ });
710
+ return;
711
+ }
712
+ if (r.context?.kind === "ArcadeCodeResponse") {
713
+ const a = this.createFeedbackContextSnapshot(n), u = pe(r?.context?.arcadeCode?.code ?? "");
714
+ this.updateViewState({
715
+ history: [
716
+ {
717
+ script: r?.context?.arcadeCode?.code,
718
+ formattedScript: u,
719
+ error: void 0,
720
+ question: e,
721
+ profile: n.profileId,
722
+ conversationId: r.conversationId,
723
+ contextSnapshot: a,
724
+ ...r.message ? { message: r.message } : {}
725
+ },
726
+ ...this.viewState.history
727
+ ],
728
+ viewMode: "result",
729
+ errorMessage: void 0
730
+ }), await this.logInteractionToFeedbackService({
731
+ question: e,
732
+ answer: u,
733
+ contextSnapshot: t,
734
+ conversationId: r.conversationId
735
+ });
696
736
  }
737
+ } catch (s) {
738
+ const n = s instanceof Error && s.name === "ArcadeAssistantError" ? ke(s) || this.messages.erroroccurred || "An error occurred." : this.messages.erroroccurred || "An error occurred.";
739
+ this.updateViewState({ errorMessage: n }), await this.logInteractionToFeedbackService({
740
+ question: e,
741
+ answer: n,
742
+ contextSnapshot: t,
743
+ conversationId: o
744
+ }), y("error", this, "Error submitting question", { detail: { error: s } });
745
+ } finally {
746
+ this.updateViewState({ isSubmitting: !1 });
697
747
  }
698
748
  }
699
749
  async getToken() {
700
- const { token: e } = await se.getCredential(this.portalUrl);
750
+ const { token: e } = await ce.getCredential(this.portalUrl);
701
751
  return e;
702
752
  }
703
753
  async getProfileAndMetadata(e) {
704
- let i = G;
705
- const o = N.getEditorProfileForModel(e);
754
+ let t = Q;
755
+ const o = D.getEditorProfileForModel(e);
706
756
  o?.loaded || await o?.loadSource();
707
757
  const s = this.editorRef.profile;
708
- s && "id" in s && (i = s.id);
709
- const n = o ? await Ue(o) : { variables: [] }, r = Be(n), p = r ? je(n) : void 0, a = p ? p.context : n, h = P(a);
758
+ s && "id" in s && (t = s.id);
759
+ const n = o ? await Le(o) : { variables: [] }, c = He(n), p = c ? Be(n) : void 0, a = p ? p.context : n, u = M(a);
710
760
  return {
711
- profileId: i,
761
+ profileId: t,
712
762
  metadata: a,
713
- contextTooLarge: r,
763
+ contextTooLarge: c,
714
764
  reducedToVariableName: p?.reducedToVariableName,
715
- estimatedTokens: h
765
+ estimatedTokens: u
716
766
  };
717
767
  }
718
768
  onCopyCode(e) {
719
- const i = e ? `${this.disclaimerComment}
769
+ const t = e ? `${this.disclaimerComment}
720
770
  ${e}` : "";
721
- return navigator.clipboard.writeText(i);
771
+ return navigator.clipboard.writeText(t);
722
772
  }
723
773
  render() {
724
774
  if (this.closed)
725
775
  return null;
726
- const e = this.viewState.viewMode === "result", i = this.getHistoryCards();
727
- return this.assistantsEnabled ? d`<calcite-flow><calcite-flow-item closable heading-level=2 .heading=${this.messages.arcadeassistant ?? "Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${this.viewState.splashActive && d`<calcite-scrim></calcite-scrim>` || ""}${Ae({ messages: this.messages })}${Te({ messages: this.messages, popoverContent: O({ assistantsEnabled: this.assistantsEnabled, messages: this.messages, helpTopicUrl: this.usingTheAssitantDocUrl }) })}<calcite-shell class="unstyled-shell">${this.viewState.splashActive && Fe({ messages: this.messages, onProceed: () => {
776
+ const e = this.viewState.viewMode === "result", t = this.getHistoryCards();
777
+ return this.assistantsEnabled ? d`<calcite-flow><calcite-flow-item closable heading-level=2 .heading=${this.messages.arcadeassistant ?? "Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${this.viewState.splashActive && d`<calcite-scrim></calcite-scrim>` || ""}${Te({ messages: this.messages })}${Ie({ messages: this.messages, popoverContent: z({ assistantsEnabled: this.assistantsEnabled, messages: this.messages, helpTopicUrl: this.usingTheAssitantDocUrl }) })}<calcite-shell class="unstyled-shell">${this.viewState.splashActive && _e({ messages: this.messages, onProceed: () => {
728
778
  this.updateViewState({ splashActive: !1 });
729
- }, helpTopicUrl: this.assistantOverviewDocUrl, onExit: (o) => this.closePanel?.(o) }) || ""}${Re({ active: this.viewState.confirmationActive, setActive: (o) => this.updateViewState({ confirmationActive: o }), messages: this.messages })}${Me({ isDisabled: this.viewState.isSubmitting, isReadOnly: !1, setQuestion: this.setQuestionState, setIsViewingResult: (o) => this.updateViewState({ viewMode: o ? "result" : "prompt" }), mode: e ? "refine" : "prompt", textAreaRef: this.textAreaRef, question: this.viewState.question, errorMessage: this.viewState.errorMessage, setErrorMessage: (o) => this.updateViewState({ errorMessage: o }), promptValidationMessage: this.viewState.promptValidationMessage, setPromptValidationMessage: (o) => this.updateViewState({ promptValidationMessage: o }), submitQuestion: this.submitQuestion.bind(this), assistantRef: this.el, messages: this.messages, context: this.viewState.context, contextReducedNoticeDismissed: this.viewState.contextReducedNoticeDismissed, setContextReducedNoticeDismissed: (o) => this.updateViewState({ contextReducedNoticeDismissed: o }) })}<calcite-block-group .label=${this.messages.interactiveblocks ?? "interactive blocks"}>${!e && !this.viewState.isSubmitting && De({ messages: this.messages, suggestions: [this.messages.prompsuggestion1 ?? "", this.messages.prompsuggestion2 ?? ""], onSuggestionClick: this.onSuggestionClick }) || ""}<calcite-block .hidden=${!this.viewState.isSubmitting} .heading=${this.messages.generatingresponse ?? "Generating response..."}></calcite-block>${L({
779
+ }, helpTopicUrl: this.assistantOverviewDocUrl, onExit: (o) => this.closePanel?.(o) }) || ""}${Re({ active: this.viewState.confirmationActive, setActive: (o) => this.updateViewState({ confirmationActive: o }), messages: this.messages })}${Me({ isDisabled: this.viewState.isSubmitting, isReadOnly: !1, setQuestion: this.setQuestionState, setIsViewingResult: (o) => this.updateViewState({ viewMode: o ? "result" : "prompt" }), mode: e ? "refine" : "prompt", textAreaRef: this.textAreaRef, question: this.viewState.question, errorMessage: this.viewState.errorMessage, setErrorMessage: (o) => this.updateViewState({ errorMessage: o }), promptValidationMessage: this.viewState.promptValidationMessage, setPromptValidationMessage: (o) => this.updateViewState({ promptValidationMessage: o }), submitQuestion: this.submitQuestion.bind(this), assistantRef: this.el, messages: this.messages, context: this.viewState.context, contextReducedNoticeDismissed: this.viewState.contextReducedNoticeDismissed, setContextReducedNoticeDismissed: (o) => this.updateViewState({ contextReducedNoticeDismissed: o }) })}<calcite-block-group .label=${this.messages.interactiveblocks ?? "interactive blocks"}>${!e && !this.viewState.isSubmitting && De({ messages: this.messages, suggestions: [this.messages.prompsuggestion1 ?? "", this.messages.prompsuggestion2 ?? ""], onSuggestionClick: this.onSuggestionClick }) || ""}<calcite-block .hidden=${!this.viewState.isSubmitting} .heading=${this.messages.generatingresponse ?? "Generating response..."}></calcite-block>${B({
730
780
  expanded: e,
731
781
  messages: this.messages,
732
782
  collapsible: !0,
733
783
  showEffectsIcon: !0,
734
784
  /** Only show the latest history card */
735
- cards: i.length ? [i[0]] : [],
785
+ cards: t.length ? [t[0]] : [],
736
786
  heading: this.messages.besteffort ?? "Here's the assistant's best effort",
737
787
  hidden: this.viewState.isSubmitting || !e,
738
788
  onCopyCode: this.onCopyCode.bind(this),
739
789
  standalone: !0
740
- })}${L({
790
+ })}${B({
741
791
  expanded: !e,
742
792
  messages: this.messages,
743
793
  collapsible: !0,
@@ -747,14 +797,14 @@ ${e}` : "";
747
797
  * To avoid showing the same card twice, we remove (slice out) the first card
748
798
  * from the list of recent prompts below.
749
799
  */
750
- cards: e ? i.slice(1) : i,
800
+ cards: e ? t.slice(1) : t,
751
801
  heading: this.messages.recentprompts ?? "Recent prompts",
752
802
  hidden: this.viewState.isSubmitting || this.viewState.history.length === 0,
753
803
  onCopyCode: this.onCopyCode.bind(this)
754
- })}</calcite-block-group>${this.viewState.feedback.active ? qe({ setOpen: this.handleFeedbackSheetClose, messages: this.messages, onSubmit: this.handleFeedbackSubmit, feedback: this.viewState.feedback, setFeedback: this.setFeedbackState, learnMoreUrl: this.assistantOverviewDocUrl }) : null}</calcite-shell></calcite-flow-item></calcite-flow>` : d`<calcite-flow><calcite-flow-item .selected=${!e} closable heading-level=2 .heading=${this.messages.arcadeassistant ?? "Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${O({ slot: "content-top", messages: this.messages, assistantsEnabled: this.assistantsEnabled, helpTopicUrl: this.usingTheAssitantDocUrl })}</calcite-flow-item></calcite-flow>`;
804
+ })}</calcite-block-group>${this.viewState.feedback.active ? Ve({ setOpen: this.handleFeedbackSheetClose, messages: this.messages, onSubmit: this.handleFeedbackSubmit, feedback: this.viewState.feedback, setFeedback: this.setFeedbackState, learnMoreUrl: this.assistantOverviewDocUrl }) : null}</calcite-shell></calcite-flow-item></calcite-flow>` : d`<calcite-flow><calcite-flow-item .selected=${!e} closable heading-level=2 .heading=${this.messages.arcadeassistant ?? "Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${z({ slot: "content-top", messages: this.messages, assistantsEnabled: this.assistantsEnabled, helpTopicUrl: this.usingTheAssitantDocUrl })}</calcite-flow-item></calcite-flow>`;
755
805
  }
756
806
  }
757
- Z("arcgis-arcade-coding-assistant", Ke);
807
+ ie("arcgis-arcade-coding-assistant", Ke);
758
808
  export {
759
809
  Ke as ArcgisArcadeCodingAssistant
760
810
  };