@arcgis/coding-components 5.1.0-next.13 → 5.1.0-next.15
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.
- package/dist/cdn/{JGASZMML.js → BVH2QXVK.js} +1 -1
- package/dist/cdn/DZ6A65Y5.js +60 -0
- package/dist/cdn/{VD5UOV5M.js → F75C3HE6.js} +1 -1
- package/dist/cdn/{CEX6Z6XG.js → FWVG6H2C.js} +1 -1
- package/dist/cdn/HPVGJHBT.js +4 -0
- package/dist/cdn/{YBTWB6XC.js → HZ5MCXUU.js} +1 -1
- package/dist/cdn/{V2SLLOQ5.js → JRXT6REI.js} +1 -1
- package/dist/cdn/{5XIHWLQI.js → KTJPAA4C.js} +1 -1
- package/dist/cdn/{JQTEKTO5.js → OSU57IUK.js} +1 -1
- package/dist/cdn/{S5RUOHYM.js → SXHJ77MK.js} +1 -1
- package/dist/cdn/{2TB2LHRA.js → THYQLG3F.js} +1 -1
- package/dist/cdn/{44MLHT3A.js → XTNBVMHY.js} +1 -1
- package/dist/cdn/{H75CMJQP.js → YLUPZ4JE.js} +1 -1
- package/dist/cdn/assets/code-editor/sql-expr.worker.js +2 -2
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/language-defaults-base.js +9 -9
- package/dist/chunks/markdown.js +409 -388
- package/dist/components/arcgis-arcade-coding-assistant/customElement.js +352 -302
- package/dist/components/arcgis-arcade-editor/customElement.js +11 -11
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/loader.js +1 -1
- package/dist/utils/arcade-assistant/types.d.ts +2 -0
- package/dist/utils/arcade-executor.d.ts +1 -1
- package/package.json +5 -5
- package/dist/cdn/2ORJ3A7K.js +0 -4
- package/dist/cdn/AQEEMLO5.js +0 -60
- /package/dist/cdn/{HVHTW7TF.js → 7LS3R4TH.js} +0 -0
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import { c as
|
|
3
|
-
import { css as
|
|
4
|
-
import { nothing as
|
|
5
|
-
import { ref as
|
|
6
|
-
import
|
|
7
|
-
import { u as
|
|
8
|
-
import { b as
|
|
9
|
-
import
|
|
10
|
-
import { e as
|
|
11
|
-
import { repeat as
|
|
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
|
|
13
|
+
import { generateGuid as ue } from "@arcgis/toolkit/string";
|
|
14
14
|
import { unsafeHTML as A } from "lit/directives/unsafe-html.js";
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import { log as
|
|
19
|
-
import { getDeclaredVoxelMembers as
|
|
20
|
-
import { s as
|
|
21
|
-
import { h as
|
|
22
|
-
import
|
|
23
|
-
import { property as f, subclass as
|
|
24
|
-
const
|
|
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:
|
|
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 =
|
|
33
|
+
super(e), this.name = "ArcadeAssistantError", this.code = t, this.subCode = o, this.details = s, this.source = n;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
if (!
|
|
36
|
+
function O(i) {
|
|
37
|
+
if (!i)
|
|
38
38
|
return;
|
|
39
|
-
const e =
|
|
39
|
+
const e = i.indexOf('{"error":');
|
|
40
40
|
if (e !== -1)
|
|
41
41
|
try {
|
|
42
|
-
const
|
|
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
|
|
50
|
-
const { baseUrl: e, skillId:
|
|
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:
|
|
52
|
+
context: c
|
|
53
53
|
};
|
|
54
54
|
n && (a.conversation_id = n);
|
|
55
|
-
let
|
|
55
|
+
let u;
|
|
56
56
|
try {
|
|
57
|
-
|
|
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,
|
|
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 =
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
let
|
|
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
|
|
79
|
+
const x = xe(w, $, P);
|
|
80
80
|
let k;
|
|
81
81
|
try {
|
|
82
|
-
k = await
|
|
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
|
|
93
|
-
throw
|
|
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 (
|
|
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
|
-
]),
|
|
129
|
+
]), r;
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function xe(i, e, t) {
|
|
132
132
|
return {
|
|
133
|
-
conversationId:
|
|
134
|
-
inquiryId:
|
|
133
|
+
conversationId: i,
|
|
134
|
+
inquiryId: t,
|
|
135
135
|
ackSequenceNumber: e
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
return
|
|
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
|
|
142
|
-
const e =
|
|
143
|
-
|
|
144
|
-
},
|
|
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 (
|
|
146
|
+
if (i && p.push({
|
|
147
147
|
id: "prompt-validation",
|
|
148
148
|
kind: "danger",
|
|
149
149
|
icon: "exclamation-mark-triangle",
|
|
150
|
-
title:
|
|
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
|
-
}),
|
|
160
|
-
const
|
|
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:
|
|
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
|
|
174
|
-
return d`<calcite-chip slot=header-actions-end scale=s appearance=outline-fill .label=${
|
|
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
|
|
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">${
|
|
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
|
|
180
|
-
return d`<div class="error-display"><calcite-input-message id=error-message status=invalid icon=exclamation-mark-triangle scale=m slot=${e ??
|
|
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:
|
|
183
|
-
return d`<calcite-alert slot=alerts .open=${
|
|
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
|
|
186
|
-
return
|
|
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:
|
|
189
|
-
const b =
|
|
190
|
-
promptValidationMessage:
|
|
191
|
-
errorMessage:
|
|
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">${
|
|
199
|
-
|
|
200
|
-
}} ${
|
|
201
|
-
o(!1),
|
|
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=${
|
|
203
|
-
o(!1),
|
|
204
|
-
}} class="hidden-below-380" scale=s>${l.startover ?? "Start Over"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${
|
|
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
|
|
210
|
-
}} class="hidden-below-380">${
|
|
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
|
|
216
|
-
}} class="hidden-above-380" .label=${
|
|
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
|
|
219
|
-
function
|
|
220
|
-
return
|
|
221
|
-
s({ ...
|
|
222
|
-
}} .disabled=${
|
|
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
|
|
225
|
-
return d`<calcite-block .label=${e.assistantinformation ?? "Assistant information"} slot=${
|
|
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
|
|
228
|
-
return d`<calcite-dialog close-disabled placement=top .heading=${
|
|
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:
|
|
231
|
-
return d`<calcite-block .heading=${
|
|
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
|
|
234
|
-
function
|
|
235
|
-
return d`<calcite-block .hidden=${
|
|
236
|
-
const l =
|
|
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}-${
|
|
241
|
-
const l =
|
|
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}-${
|
|
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:
|
|
248
|
-
const
|
|
249
|
-
return d`<calcite-tooltip .referenceElement=${o} placement=top-start class="contained-popover-or-tooltip">${s}</calcite-tooltip><calcite-chip .label=${
|
|
250
|
-
},
|
|
251
|
-
if (!
|
|
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
|
|
255
|
-
e.push(
|
|
254
|
+
return i.relationships?.forEach((t) => {
|
|
255
|
+
e.push(t.toJSON());
|
|
256
256
|
}), e;
|
|
257
|
-
},
|
|
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
|
-
})),
|
|
263
|
-
async function
|
|
264
|
-
const e = await
|
|
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:
|
|
266
|
+
name: i.name,
|
|
267
267
|
type: "featureSet",
|
|
268
|
-
isTable:
|
|
269
|
-
...
|
|
270
|
-
...
|
|
268
|
+
isTable: t,
|
|
269
|
+
...F(e?.fields),
|
|
270
|
+
...R(o)
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
|
-
async function
|
|
274
|
-
switch (
|
|
273
|
+
async function ee(i) {
|
|
274
|
+
switch (i.type) {
|
|
275
275
|
case "feature": {
|
|
276
|
-
const e = await
|
|
276
|
+
const e = await i.loadSource(), t = E(e);
|
|
277
277
|
return {
|
|
278
|
-
name:
|
|
279
|
-
type:
|
|
280
|
-
...
|
|
281
|
-
...
|
|
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
|
|
285
|
+
const e = await i.loadSource(), t = Z(e) && e.isTable;
|
|
286
286
|
return {
|
|
287
|
-
name:
|
|
287
|
+
name: i.name,
|
|
288
288
|
type: "featureSet",
|
|
289
|
-
...
|
|
290
|
-
...
|
|
291
|
-
...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
|
|
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:
|
|
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(
|
|
304
|
+
const e = await Promise.all(i.dictionaryVariables.map(ee));
|
|
305
305
|
return {
|
|
306
|
-
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
|
|
312
|
+
const e = await i.loadSource();
|
|
313
313
|
if (!e)
|
|
314
314
|
return {
|
|
315
|
-
name:
|
|
315
|
+
name: i.name,
|
|
316
316
|
type: "pixel"
|
|
317
317
|
};
|
|
318
|
-
const
|
|
318
|
+
const t = await fe(e);
|
|
319
319
|
return {
|
|
320
|
-
name:
|
|
320
|
+
name: i.name,
|
|
321
321
|
type: "pixel",
|
|
322
|
-
members:
|
|
322
|
+
members: t.map(J)
|
|
323
323
|
};
|
|
324
324
|
}
|
|
325
325
|
case "voxel": {
|
|
326
|
-
const e = await
|
|
326
|
+
const e = await i.loadSource();
|
|
327
327
|
if (!e)
|
|
328
328
|
return {
|
|
329
|
-
name:
|
|
329
|
+
name: i.name,
|
|
330
330
|
type: "voxel"
|
|
331
331
|
};
|
|
332
|
-
const
|
|
332
|
+
const t = await me(e);
|
|
333
333
|
return {
|
|
334
|
-
name:
|
|
334
|
+
name: i.name,
|
|
335
335
|
type: "voxel",
|
|
336
|
-
members:
|
|
336
|
+
members: t.map(J)
|
|
337
337
|
};
|
|
338
338
|
}
|
|
339
339
|
case "array":
|
|
340
340
|
return {
|
|
341
|
-
name:
|
|
341
|
+
name: i.name,
|
|
342
342
|
type: "array",
|
|
343
|
-
elementType:
|
|
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:
|
|
355
|
-
type:
|
|
354
|
+
name: i.name,
|
|
355
|
+
type: i.type
|
|
356
356
|
};
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
|
-
function
|
|
360
|
-
return
|
|
361
|
-
name:
|
|
359
|
+
function J(i) {
|
|
360
|
+
return i.type === "array" ? {
|
|
361
|
+
name: i.name,
|
|
362
362
|
type: "array",
|
|
363
|
-
elementType:
|
|
363
|
+
elementType: i.elementType.type
|
|
364
364
|
} : {
|
|
365
|
-
name:
|
|
366
|
-
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
|
|
370
|
+
async function Le(i) {
|
|
371
371
|
return {
|
|
372
|
-
variables: await Promise.all(
|
|
372
|
+
variables: await Promise.all(i.variables.map(ee))
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
375
|
const Oe = 1e5;
|
|
376
|
-
function ze(
|
|
377
|
-
const e = new TextEncoder().encode(
|
|
376
|
+
function ze(i) {
|
|
377
|
+
const e = new TextEncoder().encode(i).length;
|
|
378
378
|
return Math.ceil(e / 3.5);
|
|
379
379
|
}
|
|
380
|
-
function
|
|
381
|
-
return ze(JSON.stringify(
|
|
380
|
+
function M(i) {
|
|
381
|
+
return ze(JSON.stringify(i));
|
|
382
382
|
}
|
|
383
|
-
function
|
|
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
|
-
}),
|
|
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(
|
|
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:
|
|
430
|
+
variables: i.variables.map(t)
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
|
-
function
|
|
434
|
-
const e =
|
|
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:
|
|
437
|
+
wasReduced: t !== s.length,
|
|
438
438
|
reducedToVariableName: o?.name
|
|
439
439
|
};
|
|
440
440
|
}
|
|
441
|
-
function
|
|
442
|
-
return
|
|
441
|
+
function He(i) {
|
|
442
|
+
return M(i) > Oe;
|
|
443
443
|
}
|
|
444
|
-
var
|
|
445
|
-
for (var s = o > 1 ? void 0 : o ?
|
|
446
|
-
(
|
|
447
|
-
return o && 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
|
|
450
|
-
constructor(
|
|
451
|
-
super(
|
|
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
|
-
],
|
|
456
|
+
], h.prototype, "viewMode", 2);
|
|
457
457
|
m([
|
|
458
458
|
f()
|
|
459
|
-
],
|
|
459
|
+
], h.prototype, "confirmationActive", 2);
|
|
460
460
|
m([
|
|
461
461
|
f()
|
|
462
|
-
],
|
|
462
|
+
], h.prototype, "contextReducedNoticeDismissed", 2);
|
|
463
463
|
m([
|
|
464
464
|
f()
|
|
465
|
-
],
|
|
465
|
+
], h.prototype, "splashActive", 2);
|
|
466
466
|
m([
|
|
467
467
|
f()
|
|
468
|
-
],
|
|
468
|
+
], h.prototype, "isSubmitting", 2);
|
|
469
469
|
m([
|
|
470
470
|
f()
|
|
471
|
-
],
|
|
471
|
+
], h.prototype, "errorMessage", 2);
|
|
472
472
|
m([
|
|
473
473
|
f()
|
|
474
|
-
],
|
|
474
|
+
], h.prototype, "promptValidationMessage", 2);
|
|
475
475
|
m([
|
|
476
476
|
f()
|
|
477
|
-
],
|
|
477
|
+
], h.prototype, "question", 2);
|
|
478
478
|
m([
|
|
479
479
|
f()
|
|
480
|
-
],
|
|
480
|
+
], h.prototype, "history", 2);
|
|
481
481
|
m([
|
|
482
482
|
f()
|
|
483
|
-
],
|
|
483
|
+
], h.prototype, "feedback", 2);
|
|
484
484
|
m([
|
|
485
485
|
f()
|
|
486
|
-
],
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
],
|
|
490
|
-
const
|
|
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
|
|
502
|
-
class Ke extends
|
|
503
|
+
let Y = [], K = !0;
|
|
504
|
+
class Ke extends se {
|
|
503
505
|
constructor() {
|
|
504
|
-
super(...arguments), this.textAreaRef =
|
|
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:
|
|
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
|
|
520
|
-
!o && !this.appVersion &&
|
|
521
|
-
const { value: s, text: n, termsAccepted:
|
|
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:
|
|
529
|
+
_source: W,
|
|
534
530
|
version: this.appVersion || o || "NOT_SET",
|
|
535
|
-
context:
|
|
536
|
-
extras:
|
|
531
|
+
context: t ? JSON.stringify(t) : "",
|
|
532
|
+
extras: t?.profileId ?? "",
|
|
537
533
|
conversation_id: a ?? "",
|
|
538
|
-
privacy_statement:
|
|
534
|
+
privacy_statement: c ? "I_agree" : ""
|
|
539
535
|
};
|
|
540
536
|
try {
|
|
541
|
-
await e.applyEdits({ addFeatures: [new
|
|
537
|
+
await e.applyEdits({ addFeatures: [new L({ attributes: u })] });
|
|
542
538
|
} catch (l) {
|
|
543
|
-
|
|
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 =
|
|
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/
|
|
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:
|
|
571
|
+
super.connectedCallback(), this.updateViewState({ history: Y, splashActive: K });
|
|
576
572
|
}
|
|
577
573
|
load() {
|
|
578
574
|
const e = async () => {
|
|
579
|
-
const
|
|
580
|
-
if (!
|
|
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(
|
|
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((
|
|
591
|
-
|
|
586
|
+
e().catch((t) => {
|
|
587
|
+
y("error", this, "Error setting initial context.", { detail: { error: t } });
|
|
592
588
|
}), this.manager.onLifecycle(() => {
|
|
593
|
-
const
|
|
589
|
+
const t = D.onModelContextDidChange(async () => {
|
|
594
590
|
e().catch((s) => {
|
|
595
|
-
|
|
591
|
+
y("error", this, "Error setting context.", { detail: { error: s } });
|
|
596
592
|
});
|
|
597
593
|
});
|
|
598
594
|
return { remove: () => {
|
|
599
|
-
|
|
595
|
+
t.dispose();
|
|
600
596
|
} };
|
|
601
597
|
});
|
|
602
598
|
}
|
|
603
599
|
disconnectedCallback() {
|
|
604
|
-
super.disconnectedCallback(),
|
|
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
|
|
603
|
+
const t = je(e.metadata);
|
|
608
604
|
return {
|
|
609
605
|
...e,
|
|
610
|
-
metadata:
|
|
611
|
-
estimatedTokens:
|
|
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,
|
|
619
|
-
priorPrompt:
|
|
620
|
-
code:
|
|
621
|
-
profileId:
|
|
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
|
-
|
|
622
|
+
de(this.editorRef.editorInstance, t.formattedScript ?? "", o, this.disclaimerComment);
|
|
624
623
|
},
|
|
625
|
-
onThumbsUp: () => this.handleFeedbackButton("good",
|
|
626
|
-
onThumbsDown: () => this.handleFeedbackButton("bad",
|
|
627
|
-
conversationId:
|
|
628
|
-
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
|
|
635
|
+
const e = new he({ url: this.feedbackServiceUrl });
|
|
637
636
|
await e.load();
|
|
638
|
-
const
|
|
639
|
-
if (
|
|
640
|
-
|
|
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
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
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
|
-
|
|
662
|
-
|
|
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
|
-
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
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
|
|
750
|
+
const { token: e } = await ce.getCredential(this.portalUrl);
|
|
701
751
|
return e;
|
|
702
752
|
}
|
|
703
753
|
async getProfileAndMetadata(e) {
|
|
704
|
-
let
|
|
705
|
-
const o =
|
|
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 && (
|
|
709
|
-
const n = o ? await
|
|
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:
|
|
761
|
+
profileId: t,
|
|
712
762
|
metadata: a,
|
|
713
|
-
contextTooLarge:
|
|
763
|
+
contextTooLarge: c,
|
|
714
764
|
reducedToVariableName: p?.reducedToVariableName,
|
|
715
|
-
estimatedTokens:
|
|
765
|
+
estimatedTokens: u
|
|
716
766
|
};
|
|
717
767
|
}
|
|
718
768
|
onCopyCode(e) {
|
|
719
|
-
const
|
|
769
|
+
const t = e ? `${this.disclaimerComment}
|
|
720
770
|
${e}` : "";
|
|
721
|
-
return navigator.clipboard.writeText(
|
|
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",
|
|
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>` || ""}${
|
|
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>${
|
|
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:
|
|
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
|
-
})}${
|
|
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 ?
|
|
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 ?
|
|
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
|
-
|
|
807
|
+
ie("arcgis-arcade-coding-assistant", Ke);
|
|
758
808
|
export {
|
|
759
809
|
Ke as ArcgisArcadeCodingAssistant
|
|
760
810
|
};
|