@ghuri/ai-widget 0.3.2 → 0.5.0
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/README.md +9 -3
- package/dist/core/client.d.ts +21 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/prepare.d.ts +10 -0
- package/dist/core/types.d.ts +46 -3
- package/dist/{core-vIc1mTTy.js → core-4zFtqSww.js} +200 -104
- package/dist/core-4zFtqSww.js.map +1 -0
- package/dist/core.js +1 -1
- package/dist/index.js +3 -3
- package/dist/react.js +1 -1
- package/dist/{src-DLeXsfmQ.js → src-COOw7K47.js} +446 -211
- package/dist/src-COOw7K47.js.map +1 -0
- package/dist/ui/element.d.ts +19 -0
- package/dist/ui/labels.d.ts +19 -0
- package/package.json +1 -1
- package/dist/core-vIc1mTTy.js.map +0 -1
- package/dist/src-DLeXsfmQ.js.map +0 -1
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { n as e, t } from "./core-
|
|
2
|
-
import { LitElement as
|
|
3
|
-
import { styleMap as
|
|
4
|
-
import { unsafeSVG as
|
|
5
|
-
import { Lexer as
|
|
1
|
+
import { n as e, r as t, t as n } from "./core-4zFtqSww.js";
|
|
2
|
+
import { LitElement as r, css as i, html as a, nothing as o, svg as s } from "lit";
|
|
3
|
+
import { styleMap as c } from "lit/directives/style-map.js";
|
|
4
|
+
import { unsafeSVG as l } from "lit/directives/unsafe-svg.js";
|
|
5
|
+
import { Lexer as u } from "marked";
|
|
6
6
|
// src/ui/format.ts
|
|
7
|
-
function
|
|
7
|
+
function d(e) {
|
|
8
8
|
let t = e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-.]+/g, " ").trim().toLowerCase();
|
|
9
9
|
return t ? t[0].toUpperCase() + t.slice(1) : e;
|
|
10
10
|
}
|
|
11
|
-
function d(e) {
|
|
12
|
-
return e == null ? "—" : typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : Array.isArray(e) && e.every((e) => typeof e != "object" || !e) ? e.map(d).join(", ") : JSON.stringify(e);
|
|
13
|
-
}
|
|
14
11
|
function f(e) {
|
|
15
|
-
return Array.isArray(e) && e.
|
|
12
|
+
return e == null ? "—" : typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : Array.isArray(e) && e.every((e) => typeof e != "object" || !e) ? e.map(f).join(", ") : JSON.stringify(e);
|
|
16
13
|
}
|
|
17
14
|
function p(e) {
|
|
15
|
+
return Array.isArray(e) && e.length > 0 && e.every((e) => e && typeof e == "object" && !Array.isArray(e));
|
|
16
|
+
}
|
|
17
|
+
function m(e) {
|
|
18
18
|
if (typeof e != "object" || !e || Array.isArray(e)) return e === void 0 ? [] : [{
|
|
19
19
|
label: "Value",
|
|
20
|
-
value:
|
|
20
|
+
value: f(e)
|
|
21
21
|
}];
|
|
22
22
|
let t = [];
|
|
23
|
-
for (let [n, r] of Object.entries(e)) if (
|
|
23
|
+
for (let [n, r] of Object.entries(e)) if (p(r)) r.forEach((e, r) => {
|
|
24
24
|
for (let [i, a] of Object.entries(e)) t.push({
|
|
25
|
-
label: `${
|
|
26
|
-
value:
|
|
25
|
+
label: `${d(n)} ${r + 1} · ${d(i)}`,
|
|
26
|
+
value: f(a)
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
else if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
30
30
|
let e = Object.entries(r);
|
|
31
31
|
e.length || t.push({
|
|
32
|
-
label:
|
|
32
|
+
label: d(n),
|
|
33
33
|
value: "{}"
|
|
34
34
|
});
|
|
35
35
|
for (let [r, i] of e) t.push({
|
|
36
|
-
label: `${
|
|
37
|
-
value:
|
|
36
|
+
label: `${d(n)} · ${d(r)}`,
|
|
37
|
+
value: f(i)
|
|
38
38
|
});
|
|
39
39
|
} else t.push({
|
|
40
|
-
label:
|
|
41
|
-
value:
|
|
40
|
+
label: d(n),
|
|
41
|
+
value: f(r)
|
|
42
42
|
});
|
|
43
43
|
return t;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function h(e) {
|
|
46
46
|
if (!e || typeof e != "object") return null;
|
|
47
47
|
let t = e;
|
|
48
48
|
if (typeof t.count == "number") return t.count;
|
|
@@ -55,8 +55,8 @@ function m(e) {
|
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
57
57
|
// src/ui/icons.ts
|
|
58
|
-
function
|
|
59
|
-
return
|
|
58
|
+
function g(e = 20) {
|
|
59
|
+
return s`<svg class="kite" width=${e} height=${e} viewBox="0 0 28 28" aria-hidden="true" focusable="false">
|
|
60
60
|
<path transform="translate(15.13 20.17)" fill="var(--ghuri-kite-green, #0e8a5f)" d="M1.24 0.02C1.34 -0.02 1.44 0 1.51 0.06L6.18 3.97C6.26 4.03 6.29 4.13 6.27 4.23C6.26 4.32 6.19 4.4 6.1 4.44L0.36 6.52C0.27 6.55 0.17 6.54 0.1 6.47C0.02 6.41 -0.01 6.31 0 6.22L1.07 0.23C1.1 0.11 1.16 0.05 1.24 0.02Z"/>
|
|
61
61
|
<path transform="translate(3.47 6)" fill="var(--ghuri-kite-maroon, #8e1b2b)" d="M8.22 3.24L6.92 6.03L9.71 7.33L12.47 14.91L0 9.09C1.82 4.24 4.19 1.29 7.04 0L8.22 3.24Z"/>
|
|
62
62
|
<path transform="translate(6.28 1.66)" fill="var(--ghuri-kite-maroon, #8e1b2b)" d="M3.74 2.97C2.36 3.57 1.12 4.49 0 5.69L2.65 0L3.74 2.97Z"/>
|
|
@@ -64,7 +64,7 @@ function h(e = 20) {
|
|
|
64
64
|
<path transform="translate(10.17 1.21)" fill="var(--ghuri-kite-red, #f2492e)" d="M5.69 2.65C4.06 2.45 2.52 2.55 1.08 2.97L0 0L5.69 2.65Z"/>
|
|
65
65
|
</svg>`;
|
|
66
66
|
}
|
|
67
|
-
var
|
|
67
|
+
var _ = {
|
|
68
68
|
history: "<path d=\"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"/><path d=\"M3 3v5h5\"/><path d=\"M12 7v5l4 2\"/>",
|
|
69
69
|
"square-pen": "<path d=\"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"/><path d=\"M18.38 2.62a2.12 2.12 0 1 1 3 3L12.36 14.64a2 2 0 0 1-.85.5l-2.87.84a.5.5 0 0 1-.62-.62l.84-2.87a2 2 0 0 1 .5-.85z\"/>",
|
|
70
70
|
x: "<path d=\"M18 6 6 18\"/><path d=\"m6 6 12 12\"/>",
|
|
@@ -82,16 +82,20 @@ var g = {
|
|
|
82
82
|
"wifi-off": "<path d=\"M12 20h.01\"/><path d=\"M8.5 16.43a5 5 0 0 1 7 0\"/><path d=\"M2 8.82a15 15 0 0 1 4.18-2.65\"/><path d=\"M19 12.86a10 10 0 0 0-2.55-1.86\"/><path d=\"M5 12.86a10 10 0 0 1 5.17-2.69\"/><path d=\"M22 8.82a15 15 0 0 0-11.29-3.76\"/><path d=\"m2 2 20 20\"/>",
|
|
83
83
|
"messages-square": "<path d=\"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z\"/><path d=\"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1\"/>",
|
|
84
84
|
"chevron-down": "<path d=\"m6 9 6 6 6-6\"/>",
|
|
85
|
+
"chevron-up": "<path d=\"m18 15-6-6-6 6\"/>",
|
|
86
|
+
"corner-down-right": "<path d=\"m15 10 5 5-5 5\"/><path d=\"M4 4v7a4 4 0 0 0 4 4h12\"/>",
|
|
87
|
+
"package-open": "<path d=\"M12 22v-9\"/><path d=\"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.66 1.66 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z\"/><path d=\"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13\"/><path d=\"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.64 1.64 0 0 0 1.63 0z\"/>",
|
|
88
|
+
play: "<polygon points=\"6 3 20 12 6 21 6 3\"/>",
|
|
85
89
|
ban: "<circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"m4.9 4.9 14.2 14.2\"/>",
|
|
86
90
|
"image-plus": "<path d=\"M16 5h6\"/><path d=\"M19 2v6\"/><path d=\"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5\"/><path d=\"m21 15-3.09-3.09a2 2 0 0 0-2.82 0L6 21\"/><circle cx=\"9\" cy=\"9\" r=\"2\"/>",
|
|
87
91
|
"image-off": "<line x1=\"2\" x2=\"22\" y1=\"2\" y2=\"22\"/><path d=\"M10.41 10.41a2 2 0 1 1-2.83-2.83\"/><line x1=\"13.5\" x2=\"6\" y1=\"13.5\" y2=\"21\"/><line x1=\"18\" x2=\"21\" y1=\"12\" y2=\"15\"/><path d=\"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59\"/><path d=\"M21 15V5a2 2 0 0 0-2-2H9\"/>"
|
|
88
92
|
};
|
|
89
|
-
function
|
|
90
|
-
return
|
|
91
|
-
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${
|
|
93
|
+
function v(e, t = 16) {
|
|
94
|
+
return s`<svg class="icon" width=${t} height=${t} viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
95
|
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${l(_[e] ?? "")}</svg>`;
|
|
92
96
|
}
|
|
93
97
|
// src/ui/labels.ts
|
|
94
|
-
var
|
|
98
|
+
var y = {
|
|
95
99
|
picture: "Picture",
|
|
96
100
|
showPicture: (e, t) => t > 1 ? `Show picture ${e} of ${t}` : "Show picture",
|
|
97
101
|
attachPhoto: "Add photos",
|
|
@@ -150,6 +154,23 @@ var v = {
|
|
|
150
154
|
askEveryTime: "Ask every time",
|
|
151
155
|
newConversation: "New conversation",
|
|
152
156
|
dismiss: "Dismiss",
|
|
157
|
+
full: {
|
|
158
|
+
title: "This conversation is full",
|
|
159
|
+
text: "Continue in a new conversation: I'll carry over what we were doing. This one stays in your history.",
|
|
160
|
+
textWaiting: "Confirm or cancel the change above, then continue in a new conversation. I'll carry over what we were doing.",
|
|
161
|
+
continue: "Continue in a new conversation",
|
|
162
|
+
startEmpty: "Start empty",
|
|
163
|
+
placeholder: "This conversation is full",
|
|
164
|
+
workingTitle: "Carrying the conversation over…",
|
|
165
|
+
workingText: "Writing down what we were doing, what is done and what is next.",
|
|
166
|
+
continuedFrom: (e) => `Continued from “${e}”`,
|
|
167
|
+
carriedOver: "What I carried over",
|
|
168
|
+
carriedNote: "A summary for the assistant, not instructions. Changes still ask for your OK; “Allow for this conversation” starts over here.",
|
|
169
|
+
carryOn: "Carry on with the task",
|
|
170
|
+
carryOnMessage: "Carry on with the task.",
|
|
171
|
+
continuedIn: "Continued in a new conversation",
|
|
172
|
+
open: "Open →"
|
|
173
|
+
},
|
|
153
174
|
problems: {
|
|
154
175
|
reconnecting: {
|
|
155
176
|
title: "Reconnecting…",
|
|
@@ -165,7 +186,7 @@ var v = {
|
|
|
165
186
|
},
|
|
166
187
|
"conversation-full": {
|
|
167
188
|
title: "This conversation is full",
|
|
168
|
-
text: () => "
|
|
189
|
+
text: () => "No new message fits here. Answer any change waiting above, then start a new conversation to keep going. This one stays in your history."
|
|
169
190
|
},
|
|
170
191
|
throttled: {
|
|
171
192
|
title: "Too many messages",
|
|
@@ -210,8 +231,8 @@ var v = {
|
|
|
210
231
|
},
|
|
211
232
|
noConversations: "No conversations yet.",
|
|
212
233
|
loading: "Loading…"
|
|
213
|
-
},
|
|
214
|
-
...
|
|
234
|
+
}, b = {
|
|
235
|
+
...y,
|
|
215
236
|
picture: "ছবি",
|
|
216
237
|
showPicture: (e, t) => t > 1 ? `ছবি ${e}/${t} বড় করে দেখুন` : "ছবি বড় করে দেখুন",
|
|
217
238
|
attachPhoto: "ছবি যোগ করুন",
|
|
@@ -236,9 +257,9 @@ var v = {
|
|
|
236
257
|
emptyTitle: "কী সাহায্য করতে পারি?",
|
|
237
258
|
confirm: "নিশ্চিত করুন",
|
|
238
259
|
cancel: "বাতিল",
|
|
239
|
-
confirmN: (e) => `${
|
|
260
|
+
confirmN: (e) => `${S(e)}টি নিশ্চিত করুন`,
|
|
240
261
|
cancelAll: "সব বাতিল",
|
|
241
|
-
changes: (e) => `${
|
|
262
|
+
changes: (e) => `${S(e)}টি পরিবর্তন`,
|
|
242
263
|
needsOk: "আপনার অনুমতি দরকার",
|
|
243
264
|
exactValues: "ঠিক যা পাঠানো হবে",
|
|
244
265
|
unticked: "টিক না থাকলে বাতিল",
|
|
@@ -249,9 +270,9 @@ var v = {
|
|
|
249
270
|
outcomeUnknown: "ফলাফল জানা নেই",
|
|
250
271
|
stepFailed: "হয়নি",
|
|
251
272
|
now: "এখন",
|
|
252
|
-
lines: (e) => `${
|
|
273
|
+
lines: (e) => `${S(e)} লাইন`,
|
|
253
274
|
running: "কাজ চলছে…",
|
|
254
|
-
found: (e) => `${
|
|
275
|
+
found: (e) => `${S(e)}টি পাওয়া গেছে`,
|
|
255
276
|
footer: "যেকোনো পরিবর্তনের আগে আপনার অনুমতি নেওয়া হয়। AI ভুল করতে পারে।",
|
|
256
277
|
footerAllowed: "উপরে যেগুলোর অনুমতি দিয়েছেন সেগুলো ছাড়া, পরিবর্তনের আগে অনুমতি নেওয়া হয়। AI ভুল করতে পারে।",
|
|
257
278
|
newMessageCancels: "নতুন মেসেজ পাঠালে অপেক্ষমাণ পরিবর্তন বাতিল হবে।",
|
|
@@ -270,6 +291,23 @@ var v = {
|
|
|
270
291
|
askEveryTime: "প্রতিবার জিজ্ঞেস করুন",
|
|
271
292
|
newConversation: "নতুন কথোপকথন",
|
|
272
293
|
dismiss: "ঠিক আছে",
|
|
294
|
+
full: {
|
|
295
|
+
title: "এই কথোপকথন ভরে গেছে",
|
|
296
|
+
text: "নতুন কথোপকথনে চালিয়ে যান: আমরা যা করছিলাম তা সাথে নিয়ে যাব। এটি আপনার ইতিহাসে থাকবে।",
|
|
297
|
+
textWaiting: "উপরের পরিবর্তনটি নিশ্চিত বা বাতিল করুন, তারপর নতুন কথোপকথনে চালিয়ে যান। আমরা যা করছিলাম তা সাথে নিয়ে যাব।",
|
|
298
|
+
continue: "নতুন কথোপকথনে চালিয়ে যান",
|
|
299
|
+
startEmpty: "খালি শুরু করুন",
|
|
300
|
+
placeholder: "এই কথোপকথন ভরে গেছে",
|
|
301
|
+
workingTitle: "কথোপকথন সাথে নেওয়া হচ্ছে…",
|
|
302
|
+
workingText: "আমরা কী করছিলাম, কী হয়েছে আর এরপর কী, তা লেখা হচ্ছে।",
|
|
303
|
+
continuedFrom: (e) => `“${e}” থেকে চালিয়ে যাওয়া`,
|
|
304
|
+
carriedOver: "কী সাথে আনা হয়েছে",
|
|
305
|
+
carriedNote: "এটি অ্যাসিস্ট্যান্টের জন্য সারাংশ, নির্দেশ নয়। পরিবর্তনে এখনো আপনার অনুমতি লাগবে; “এই কথোপকথনে অনুমতি” এখানে নতুন করে দিতে হবে।",
|
|
306
|
+
carryOn: "কাজটি চালিয়ে যান",
|
|
307
|
+
carryOnMessage: "কাজটি চালিয়ে যাও।",
|
|
308
|
+
continuedIn: "নতুন কথোপকথনে চালিয়ে যাওয়া হয়েছে",
|
|
309
|
+
open: "খুলুন →"
|
|
310
|
+
},
|
|
273
311
|
problems: {
|
|
274
312
|
reconnecting: {
|
|
275
313
|
title: "আবার সংযোগ হচ্ছে…",
|
|
@@ -285,11 +323,11 @@ var v = {
|
|
|
285
323
|
},
|
|
286
324
|
"conversation-full": {
|
|
287
325
|
title: "এই কথোপকথন ভরে গেছে",
|
|
288
|
-
text: () => "চালিয়ে যেতে নতুন কথোপকথন শুরু করুন। এটি আপনার ইতিহাসে থাকবে।"
|
|
326
|
+
text: () => "এখানে আর নতুন মেসেজ ধরবে না। উপরে কোনো পরিবর্তন অপেক্ষায় থাকলে তার উত্তর দিন, তারপর চালিয়ে যেতে নতুন কথোপকথন শুরু করুন। এটি আপনার ইতিহাসে থাকবে।"
|
|
289
327
|
},
|
|
290
328
|
throttled: {
|
|
291
329
|
title: "অনেক বেশি মেসেজ",
|
|
292
|
-
text: (e) => e ? `আরেকটি পাঠানোর আগে ${
|
|
330
|
+
text: (e) => e ? `আরেকটি পাঠানোর আগে ${S(e)} সেকেন্ড অপেক্ষা করুন।` : "আরেকটি পাঠানোর আগে একটু অপেক্ষা করুন।"
|
|
293
331
|
},
|
|
294
332
|
forbidden: {
|
|
295
333
|
title: "অনুমতি নেই",
|
|
@@ -330,105 +368,109 @@ var v = {
|
|
|
330
368
|
},
|
|
331
369
|
noConversations: "এখনো কোনো কথোপকথন নেই।",
|
|
332
370
|
loading: "লোড হচ্ছে…"
|
|
333
|
-
},
|
|
334
|
-
function
|
|
335
|
-
return String(e).replace(/\d/g, (e) =>
|
|
371
|
+
}, x = "০১২৩৪৫৬৭৮৯";
|
|
372
|
+
function S(e) {
|
|
373
|
+
return String(e).replace(/\d/g, (e) => x[Number(e)]);
|
|
336
374
|
}
|
|
337
|
-
function
|
|
338
|
-
let n = (e ?? "").toLowerCase().startsWith("bn") ?
|
|
375
|
+
function C(e, t = {}) {
|
|
376
|
+
let n = (e ?? "").toLowerCase().startsWith("bn") ? b : y;
|
|
339
377
|
return {
|
|
340
378
|
...n,
|
|
341
379
|
...t,
|
|
342
380
|
problems: {
|
|
343
381
|
...n.problems,
|
|
344
382
|
...t.problems ?? {}
|
|
383
|
+
},
|
|
384
|
+
full: {
|
|
385
|
+
...n.full,
|
|
386
|
+
...t.full ?? {}
|
|
345
387
|
}
|
|
346
388
|
};
|
|
347
389
|
}
|
|
348
390
|
// src/ui/markdown.ts
|
|
349
|
-
var
|
|
350
|
-
function w(e) {
|
|
351
|
-
let t = e.trim();
|
|
352
|
-
return C.test(t) ? t : null;
|
|
353
|
-
}
|
|
391
|
+
var w = /^(https?:|mailto:)/i;
|
|
354
392
|
function T(e) {
|
|
355
|
-
|
|
393
|
+
let t = e.trim();
|
|
394
|
+
return w.test(t) ? t : null;
|
|
356
395
|
}
|
|
357
396
|
function E(e) {
|
|
397
|
+
return (e ?? []).map((e) => D(e));
|
|
398
|
+
}
|
|
399
|
+
function D(e) {
|
|
358
400
|
switch (e.type) {
|
|
359
|
-
case "strong": return
|
|
360
|
-
case "em": return
|
|
361
|
-
case "del": return
|
|
362
|
-
case "codespan": return
|
|
363
|
-
case "br": return
|
|
401
|
+
case "strong": return a`<strong>${E(e.tokens)}</strong>`;
|
|
402
|
+
case "em": return a`<em>${E(e.tokens)}</em>`;
|
|
403
|
+
case "del": return a`<del>${E(e.tokens)}</del>`;
|
|
404
|
+
case "codespan": return a`<code>${e.text}</code>`;
|
|
405
|
+
case "br": return a`<br />`;
|
|
364
406
|
case "link": {
|
|
365
|
-
let t = e, n =
|
|
366
|
-
return n ?
|
|
407
|
+
let t = e, n = T(t.href);
|
|
408
|
+
return n ? a`<a href=${n} target="_blank" rel="noopener noreferrer nofollow">${E(t.tokens)}</a>` : a`${E(t.tokens)}`;
|
|
367
409
|
}
|
|
368
410
|
case "image": return e.text || "";
|
|
369
411
|
case "text": {
|
|
370
412
|
let t = e;
|
|
371
|
-
return t.tokens ?
|
|
413
|
+
return t.tokens ? a`${E(t.tokens)}` : O(t.text);
|
|
372
414
|
}
|
|
373
415
|
case "escape": return e.text;
|
|
374
416
|
case "html": return e.raw;
|
|
375
417
|
default: return "raw" in e ? String(e.raw) : "";
|
|
376
418
|
}
|
|
377
419
|
}
|
|
378
|
-
function
|
|
420
|
+
function O(e) {
|
|
379
421
|
return e.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, "\"").replace(/'/g, "'").replace(/&/g, "&");
|
|
380
422
|
}
|
|
381
|
-
function
|
|
423
|
+
function k(e) {
|
|
382
424
|
switch (e.type) {
|
|
383
|
-
case "paragraph": return
|
|
384
|
-
case "heading": return
|
|
425
|
+
case "paragraph": return a`<p>${E(e.tokens)}</p>`;
|
|
426
|
+
case "heading": return a`<p class="heading">${E(e.tokens)}</p>`;
|
|
385
427
|
case "list": {
|
|
386
|
-
let t = e, n = t.items.map((e) =>
|
|
387
|
-
return t.ordered ?
|
|
428
|
+
let t = e, n = t.items.map((e) => a`<li>${e.tokens.map(A)}</li>`);
|
|
429
|
+
return t.ordered ? a`<ol start=${typeof t.start == "number" ? t.start : 1}>${n}</ol>` : a`<ul>${n}</ul>`;
|
|
388
430
|
}
|
|
389
431
|
case "table": {
|
|
390
432
|
let t = e;
|
|
391
|
-
return
|
|
433
|
+
return a`<div class="table-wrap">
|
|
392
434
|
<table>
|
|
393
435
|
<thead>
|
|
394
436
|
<tr>
|
|
395
|
-
${t.header.map((e) =>
|
|
437
|
+
${t.header.map((e) => a`<th>${E(e.tokens)}</th>`)}
|
|
396
438
|
</tr>
|
|
397
439
|
</thead>
|
|
398
440
|
<tbody>
|
|
399
|
-
${t.rows.map((e) =>
|
|
441
|
+
${t.rows.map((e) => a`<tr>${e.map((e) => a`<td>${E(e.tokens)}</td>`)}</tr>`)}
|
|
400
442
|
</tbody>
|
|
401
443
|
</table>
|
|
402
444
|
</div>`;
|
|
403
445
|
}
|
|
404
|
-
case "code": return
|
|
405
|
-
case "blockquote": return
|
|
406
|
-
case "hr": return
|
|
407
|
-
case "html": return
|
|
446
|
+
case "code": return a`<pre><code>${e.text}</code></pre>`;
|
|
447
|
+
case "blockquote": return a`<blockquote>${e.tokens.map(k)}</blockquote>`;
|
|
448
|
+
case "hr": return a`<hr />`;
|
|
449
|
+
case "html": return a`<p>${e.raw}</p>`;
|
|
408
450
|
case "text": {
|
|
409
451
|
let t = e;
|
|
410
|
-
return
|
|
452
|
+
return a`<p>${t.tokens ? E(t.tokens) : O(t.text)}</p>`;
|
|
411
453
|
}
|
|
412
|
-
case "space": return
|
|
413
|
-
default: return "raw" in e ?
|
|
454
|
+
case "space": return o;
|
|
455
|
+
default: return "raw" in e ? a`<p>${String(e.raw)}</p>` : o;
|
|
414
456
|
}
|
|
415
457
|
}
|
|
416
|
-
function
|
|
458
|
+
function A(e) {
|
|
417
459
|
if (e.type === "text") {
|
|
418
460
|
let t = e;
|
|
419
|
-
return t.tokens ?
|
|
461
|
+
return t.tokens ? a`${E(t.tokens)}` : O(t.text);
|
|
420
462
|
}
|
|
421
|
-
return
|
|
463
|
+
return k(e);
|
|
422
464
|
}
|
|
423
|
-
function
|
|
424
|
-
let t =
|
|
465
|
+
function j(e) {
|
|
466
|
+
let t = u.lex(e, {
|
|
425
467
|
gfm: !0,
|
|
426
468
|
breaks: !0
|
|
427
469
|
});
|
|
428
|
-
return
|
|
470
|
+
return a`${t.map(k)}`;
|
|
429
471
|
}
|
|
430
472
|
// src/ui/styles.ts
|
|
431
|
-
var
|
|
473
|
+
var M = i`
|
|
432
474
|
:host {
|
|
433
475
|
--_accent: var(--ghuri-accent, #8e1b2b);
|
|
434
476
|
--_accent-text: var(--ghuri-accent-text, #ffffff);
|
|
@@ -1104,6 +1146,120 @@ var j = r`
|
|
|
1104
1146
|
margin-top: 6px;
|
|
1105
1147
|
}
|
|
1106
1148
|
|
|
1149
|
+
.problem.working > .icon {
|
|
1150
|
+
color: var(--_accent);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
/* --- a full conversation continued in a new one (docs/full-conversation.md) --- */
|
|
1154
|
+
.continued {
|
|
1155
|
+
display: flex;
|
|
1156
|
+
flex-direction: column;
|
|
1157
|
+
gap: 12px;
|
|
1158
|
+
}
|
|
1159
|
+
.continued-from {
|
|
1160
|
+
display: flex;
|
|
1161
|
+
align-items: center;
|
|
1162
|
+
gap: 8px;
|
|
1163
|
+
width: 100%;
|
|
1164
|
+
padding: 0;
|
|
1165
|
+
border: 0;
|
|
1166
|
+
background: none;
|
|
1167
|
+
color: var(--_muted);
|
|
1168
|
+
font: inherit;
|
|
1169
|
+
font-size: 12px;
|
|
1170
|
+
cursor: pointer;
|
|
1171
|
+
}
|
|
1172
|
+
.continued-from::before,
|
|
1173
|
+
.continued-from::after {
|
|
1174
|
+
content: '';
|
|
1175
|
+
flex: 1;
|
|
1176
|
+
height: 1px;
|
|
1177
|
+
background: var(--_border);
|
|
1178
|
+
}
|
|
1179
|
+
.continued-from:hover span {
|
|
1180
|
+
text-decoration: underline;
|
|
1181
|
+
}
|
|
1182
|
+
.carried {
|
|
1183
|
+
display: flex;
|
|
1184
|
+
flex-direction: column;
|
|
1185
|
+
gap: 8px;
|
|
1186
|
+
padding: 12px;
|
|
1187
|
+
border: 1px solid var(--_border);
|
|
1188
|
+
border-radius: 10px;
|
|
1189
|
+
background: var(--_background);
|
|
1190
|
+
}
|
|
1191
|
+
.carried-head {
|
|
1192
|
+
display: flex;
|
|
1193
|
+
align-items: center;
|
|
1194
|
+
justify-content: space-between;
|
|
1195
|
+
padding: 0;
|
|
1196
|
+
border: 0;
|
|
1197
|
+
background: none;
|
|
1198
|
+
color: var(--_muted);
|
|
1199
|
+
font: inherit;
|
|
1200
|
+
cursor: pointer;
|
|
1201
|
+
}
|
|
1202
|
+
.carried-head .name {
|
|
1203
|
+
display: flex;
|
|
1204
|
+
align-items: center;
|
|
1205
|
+
gap: 6px;
|
|
1206
|
+
color: var(--_text);
|
|
1207
|
+
font-size: 13px;
|
|
1208
|
+
font-weight: 600;
|
|
1209
|
+
}
|
|
1210
|
+
.carried-text {
|
|
1211
|
+
white-space: pre-wrap;
|
|
1212
|
+
overflow-wrap: anywhere;
|
|
1213
|
+
font-size: 12px;
|
|
1214
|
+
line-height: 18px;
|
|
1215
|
+
}
|
|
1216
|
+
.carried-note {
|
|
1217
|
+
color: var(--_muted);
|
|
1218
|
+
font-size: 11px;
|
|
1219
|
+
line-height: 16px;
|
|
1220
|
+
}
|
|
1221
|
+
.carry-on-row {
|
|
1222
|
+
display: flex;
|
|
1223
|
+
}
|
|
1224
|
+
.carry-on {
|
|
1225
|
+
display: inline-flex;
|
|
1226
|
+
align-items: center;
|
|
1227
|
+
gap: 6px;
|
|
1228
|
+
padding: 7px 12px;
|
|
1229
|
+
border: 1px solid var(--_accent-border);
|
|
1230
|
+
border-radius: var(--_radius-sm);
|
|
1231
|
+
background: var(--_accent-soft);
|
|
1232
|
+
color: var(--_accent-soft-text);
|
|
1233
|
+
font: inherit;
|
|
1234
|
+
font-size: 13px;
|
|
1235
|
+
font-weight: 500;
|
|
1236
|
+
cursor: pointer;
|
|
1237
|
+
}
|
|
1238
|
+
.continued-in {
|
|
1239
|
+
display: flex;
|
|
1240
|
+
align-items: center;
|
|
1241
|
+
gap: 8px;
|
|
1242
|
+
margin: 0 12px 12px;
|
|
1243
|
+
padding: 12px;
|
|
1244
|
+
border: 1px solid var(--_border);
|
|
1245
|
+
border-radius: var(--_radius-sm);
|
|
1246
|
+
background: var(--_background);
|
|
1247
|
+
color: var(--_muted);
|
|
1248
|
+
}
|
|
1249
|
+
.continued-in .text {
|
|
1250
|
+
flex: 1;
|
|
1251
|
+
color: var(--_text);
|
|
1252
|
+
}
|
|
1253
|
+
.continued-in .link {
|
|
1254
|
+
padding: 0;
|
|
1255
|
+
border: 0;
|
|
1256
|
+
background: none;
|
|
1257
|
+
color: var(--_accent);
|
|
1258
|
+
font: inherit;
|
|
1259
|
+
font-weight: 500;
|
|
1260
|
+
cursor: pointer;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1107
1263
|
/* --- composer --- */
|
|
1108
1264
|
.composer {
|
|
1109
1265
|
padding: 12px;
|
|
@@ -1499,8 +1655,8 @@ var j = r`
|
|
|
1499
1655
|
font-weight: 500;
|
|
1500
1656
|
min-height: 48px;
|
|
1501
1657
|
}
|
|
1502
|
-
`,
|
|
1503
|
-
static styles =
|
|
1658
|
+
`, N = "result was not recorded", P = class extends r {
|
|
1659
|
+
static styles = M;
|
|
1504
1660
|
static properties = {
|
|
1505
1661
|
layout: {
|
|
1506
1662
|
type: String,
|
|
@@ -1520,7 +1676,8 @@ var j = r`
|
|
|
1520
1676
|
expanded: { state: !0 },
|
|
1521
1677
|
unticked: { state: !0 },
|
|
1522
1678
|
dragging: { state: !0 },
|
|
1523
|
-
enlarged: { state: !0 }
|
|
1679
|
+
enlarged: { state: !0 },
|
|
1680
|
+
carriedClosed: { state: !0 }
|
|
1524
1681
|
};
|
|
1525
1682
|
chat = null;
|
|
1526
1683
|
options = null;
|
|
@@ -1533,7 +1690,7 @@ var j = r`
|
|
|
1533
1690
|
};
|
|
1534
1691
|
guarding = !1;
|
|
1535
1692
|
constructor() {
|
|
1536
|
-
super(), this.layout = "panel", this.open = !1, this.locale = "", this.heading = "", this.subtitle = "", this.state = null, this.view = "chat", this.conversations = null, this.draft = "", this.expanded = /* @__PURE__ */ new Set(), this.unticked = /* @__PURE__ */ new Set(), this.enlarged = null;
|
|
1693
|
+
super(), this.layout = "panel", this.carriedClosed = !1, this.open = !1, this.locale = "", this.heading = "", this.subtitle = "", this.state = null, this.view = "chat", this.conversations = null, this.draft = "", this.expanded = /* @__PURE__ */ new Set(), this.unticked = /* @__PURE__ */ new Set(), this.enlarged = null;
|
|
1537
1694
|
}
|
|
1538
1695
|
configure(t) {
|
|
1539
1696
|
this.detach(), this.options = t, t.layout && (this.layout = t.layout), t.title !== void 0 && (this.heading = t.title), t.subtitle !== void 0 && (this.subtitle = t.subtitle), t.locale && (this.locale = t.locale);
|
|
@@ -1576,7 +1733,10 @@ var j = r`
|
|
|
1576
1733
|
this.chat?.newConversation(), this.view = "chat", this.expanded = /* @__PURE__ */ new Set(), this.unticked = /* @__PURE__ */ new Set(), this.updateComplete.then(() => this.focusInput());
|
|
1577
1734
|
}
|
|
1578
1735
|
async openConversation(e) {
|
|
1579
|
-
this.view = "chat", await this.chat?.openConversation(e);
|
|
1736
|
+
this.view = "chat", this.carriedClosed = !1, await this.chat?.openConversation(e);
|
|
1737
|
+
}
|
|
1738
|
+
async continueConversation() {
|
|
1739
|
+
this.carriedClosed = !1, await this.chat?.continueConversation(), this.layout === "page" && this.loadConversations();
|
|
1580
1740
|
}
|
|
1581
1741
|
async end() {
|
|
1582
1742
|
await this.chat?.end(), this.conversations = null;
|
|
@@ -1591,7 +1751,7 @@ var j = r`
|
|
|
1591
1751
|
this.unsubscribe = [];
|
|
1592
1752
|
}
|
|
1593
1753
|
get labels() {
|
|
1594
|
-
return
|
|
1754
|
+
return C(this.locale || this.options?.locale || document.documentElement.lang || "en", this.options?.labels);
|
|
1595
1755
|
}
|
|
1596
1756
|
fire(e, t) {
|
|
1597
1757
|
this.dispatchEvent(new CustomEvent(`ghuri:${e}`, {
|
|
@@ -1631,9 +1791,12 @@ var j = r`
|
|
|
1631
1791
|
if (!this.canSend() || !this.chat || t === "sending" || t === "streaming") return;
|
|
1632
1792
|
this.draft = "", this.stickToBottom = !0;
|
|
1633
1793
|
let n = !this.state?.conversationId;
|
|
1634
|
-
await this.chat.send(e)
|
|
1794
|
+
await this.chat.send(e);
|
|
1795
|
+
let r = this.chat?.getState().problem?.code;
|
|
1796
|
+
r !== "photos-refused" && r !== "conversation-full" || this.draft || (this.draft = e), n && this.layout === "page" && this.loadConversations();
|
|
1635
1797
|
}
|
|
1636
1798
|
canSend() {
|
|
1799
|
+
if (this.state?.full) return !1;
|
|
1637
1800
|
let e = this.state?.uploads ?? [];
|
|
1638
1801
|
return e.some((e) => e.status === "preparing" || e.status === "uploading") || e.some((e) => e.status === "failed" && e.error === "upload") ? !1 : !!this.draft.trim() || e.some((e) => e.status === "ready");
|
|
1639
1802
|
}
|
|
@@ -1665,10 +1828,10 @@ var j = r`
|
|
|
1665
1828
|
}
|
|
1666
1829
|
renderAllowChoice(e) {
|
|
1667
1830
|
let t = e.filter((e) => e.allowable);
|
|
1668
|
-
if (!t.length) return
|
|
1831
|
+
if (!t.length) return o;
|
|
1669
1832
|
let n = this.labels, r = [...new Set(t.map((e) => this.toolLabel(e)))];
|
|
1670
|
-
return
|
|
1671
|
-
<span class="allow-head">${
|
|
1833
|
+
return a`<button class="allow-choice" part="button-allow" @click=${() => this.decideAll(!0, !0)}>
|
|
1834
|
+
<span class="allow-head">${v("shield-check", 15)} ${n.allowChoice}</span>
|
|
1672
1835
|
<span class="allow-hint">${n.allowHint(r, t.length < e.length)}</span>
|
|
1673
1836
|
</button>`;
|
|
1674
1837
|
}
|
|
@@ -1686,7 +1849,7 @@ var j = r`
|
|
|
1686
1849
|
slot: r.container.slot,
|
|
1687
1850
|
ctx: t,
|
|
1688
1851
|
render: n
|
|
1689
|
-
}),
|
|
1852
|
+
}), a`<slot name=${r.container.slot}></slot>`;
|
|
1690
1853
|
}
|
|
1691
1854
|
mountCards() {
|
|
1692
1855
|
for (let [e, t] of this.cards) {
|
|
@@ -1703,7 +1866,7 @@ var j = r`
|
|
|
1703
1866
|
}
|
|
1704
1867
|
}
|
|
1705
1868
|
render() {
|
|
1706
|
-
return this.wanted = /* @__PURE__ */ new Map(), this.layout === "page" ?
|
|
1869
|
+
return this.wanted = /* @__PURE__ */ new Map(), this.layout === "page" ? a`<div class="page">
|
|
1707
1870
|
<aside class="sidebar" part="history">${this.renderSidebar()}</aside>
|
|
1708
1871
|
<section class="main">
|
|
1709
1872
|
<div class="page-head" part="header">
|
|
@@ -1713,14 +1876,14 @@ var j = r`
|
|
|
1713
1876
|
${this.renderScroll()} ${this.renderBottom()}
|
|
1714
1877
|
</section>
|
|
1715
1878
|
${this.renderEnlarged()}
|
|
1716
|
-
</div>` :
|
|
1717
|
-
${this.view === "history" ? this.renderPanelHistory() :
|
|
1879
|
+
</div>` : a`${this.renderHeader()}
|
|
1880
|
+
${this.view === "history" ? this.renderPanelHistory() : a`${this.renderScroll()} ${this.renderBottom()}`}
|
|
1718
1881
|
${this.renderEnlarged()}`;
|
|
1719
1882
|
}
|
|
1720
1883
|
renderEnlarged() {
|
|
1721
|
-
if (!this.enlarged) return
|
|
1884
|
+
if (!this.enlarged) return o;
|
|
1722
1885
|
let e = this.labels;
|
|
1723
|
-
return
|
|
1886
|
+
return a`<div
|
|
1724
1887
|
class="lightbox"
|
|
1725
1888
|
part="lightbox"
|
|
1726
1889
|
role="dialog"
|
|
@@ -1733,7 +1896,7 @@ var j = r`
|
|
|
1733
1896
|
>
|
|
1734
1897
|
<img src=${this.enlarged} alt=${e.picture} @click=${(e) => e.stopPropagation()} />
|
|
1735
1898
|
<button class="lightbox-close" aria-label=${e.close} @click=${() => this.enlarged = null}>
|
|
1736
|
-
${
|
|
1899
|
+
${v("x", 16)}
|
|
1737
1900
|
</button>
|
|
1738
1901
|
</div>`;
|
|
1739
1902
|
}
|
|
@@ -1743,37 +1906,49 @@ var j = r`
|
|
|
1743
1906
|
}
|
|
1744
1907
|
renderHeader() {
|
|
1745
1908
|
let e = this.labels;
|
|
1746
|
-
return
|
|
1909
|
+
return a`<header class="header" part="header">
|
|
1747
1910
|
<div class="brand">
|
|
1748
|
-
<span class="avatar">${
|
|
1911
|
+
<span class="avatar">${g(20)}</span>
|
|
1749
1912
|
<span class="names">
|
|
1750
1913
|
<span class="title" part="title">${this.heading || "Ghuri AI"}</span>
|
|
1751
|
-
${this.subtitle ?
|
|
1914
|
+
${this.subtitle ? a`<span class="subtitle">${this.subtitle}</span>` : o}
|
|
1752
1915
|
</span>
|
|
1753
1916
|
</div>
|
|
1754
1917
|
<div class="tools">
|
|
1755
|
-
<button
|
|
1756
|
-
|
|
1918
|
+
<button
|
|
1919
|
+
class="icon-button"
|
|
1920
|
+
title=${e.history}
|
|
1921
|
+
aria-label=${e.history}
|
|
1922
|
+
?disabled=${!!this.state?.continuing}
|
|
1923
|
+
@click=${() => this.showHistory()}
|
|
1924
|
+
>
|
|
1925
|
+
${v("history")}
|
|
1757
1926
|
</button>
|
|
1758
|
-
<button
|
|
1759
|
-
|
|
1927
|
+
<button
|
|
1928
|
+
class="icon-button"
|
|
1929
|
+
title=${e.newChat}
|
|
1930
|
+
aria-label=${e.newChat}
|
|
1931
|
+
?disabled=${!!this.state?.continuing}
|
|
1932
|
+
@click=${() => this.newConversation()}
|
|
1933
|
+
>
|
|
1934
|
+
${v("square-pen")}
|
|
1760
1935
|
</button>
|
|
1761
1936
|
<button class="icon-button" title=${e.close} aria-label=${e.close} @click=${() => this.hide()}>
|
|
1762
|
-
${
|
|
1937
|
+
${v("x")}
|
|
1763
1938
|
</button>
|
|
1764
1939
|
</div>
|
|
1765
1940
|
</header>`;
|
|
1766
1941
|
}
|
|
1767
1942
|
renderConversationList() {
|
|
1768
1943
|
let e = this.labels;
|
|
1769
|
-
if (this.conversations === null) return
|
|
1770
|
-
if (!this.conversations.length) return
|
|
1944
|
+
if (this.conversations === null) return a`<div class="muted">${e.loading}</div>`;
|
|
1945
|
+
if (!this.conversations.length) return a`<div class="muted">${e.noConversations}</div>`;
|
|
1771
1946
|
let t = new Intl.DateTimeFormat(this.locale || void 0, {
|
|
1772
1947
|
dateStyle: "medium",
|
|
1773
1948
|
timeStyle: "short"
|
|
1774
1949
|
});
|
|
1775
|
-
return
|
|
1776
|
-
${this.conversations.map((e) =>
|
|
1950
|
+
return a`<nav class="history" aria-label=${e.conversations}>
|
|
1951
|
+
${this.conversations.map((e) => a`<button
|
|
1777
1952
|
class="conversation"
|
|
1778
1953
|
aria-current=${e.id === this.state?.conversationId ? "true" : "false"}
|
|
1779
1954
|
@click=${() => this.openConversation(e.id)}
|
|
@@ -1785,7 +1960,7 @@ var j = r`
|
|
|
1785
1960
|
}
|
|
1786
1961
|
renderPanelHistory() {
|
|
1787
1962
|
let e = this.labels;
|
|
1788
|
-
return
|
|
1963
|
+
return a`<div class="scroll">
|
|
1789
1964
|
<div class="history-head">
|
|
1790
1965
|
<span>${e.conversations}</span>
|
|
1791
1966
|
<button class="btn primary" @click=${() => this.newConversation()}>${e.newChat}</button>
|
|
@@ -1795,73 +1970,96 @@ var j = r`
|
|
|
1795
1970
|
}
|
|
1796
1971
|
renderSidebar() {
|
|
1797
1972
|
let e = this.labels;
|
|
1798
|
-
return
|
|
1799
|
-
<button class="new-chat" @click=${() => this.newConversation()}>${
|
|
1973
|
+
return a`<div class="side-brand">${g(24)}<span>${this.heading || "Ghuri AI"}</span></div>
|
|
1974
|
+
<button class="new-chat" @click=${() => this.newConversation()}>${v("square-pen", 15)} ${e.newChat}</button>
|
|
1800
1975
|
${this.renderConversationList()}`;
|
|
1801
1976
|
}
|
|
1802
1977
|
renderScroll() {
|
|
1803
|
-
let e = this.state, t = e?.messages ?? [], n = e?.status === "loading" ?
|
|
1804
|
-
${this.renderPending()}` : this.renderEmpty();
|
|
1805
|
-
return
|
|
1806
|
-
<div class="messages column" role="log" aria-live="polite" aria-busy=${e?.status === "streaming"}>${
|
|
1978
|
+
let e = this.state, t = e?.messages ?? [], n = e?.continuedFrom && e.status !== "loading" ? this.renderContinued() : o, r = e?.status === "loading" ? a`<div class="muted">${this.labels.loading}</div>` : t.length ? a`${n}${t.map((e, n) => this.renderMessage(e, n === t.length - 1))}
|
|
1979
|
+
${this.renderPending()}` : e?.continuedFrom ? n : this.renderEmpty();
|
|
1980
|
+
return a`<div class="scroll">
|
|
1981
|
+
<div class="messages column" role="log" aria-live="polite" aria-busy=${e?.status === "streaming"}>${r}</div>
|
|
1982
|
+
</div>`;
|
|
1983
|
+
}
|
|
1984
|
+
renderContinued() {
|
|
1985
|
+
let e = this.labels.full, n = this.state, r = n.continuedFrom, i = n.handover ? t(n.handover) : "", s = !this.carriedClosed, c = !n.messages.length && n.status === "idle";
|
|
1986
|
+
return a`<div class="continued" part="continued">
|
|
1987
|
+
<button class="continued-from" @click=${() => this.openConversation(r.id)}>
|
|
1988
|
+
${v("corner-down-right", 13)}<span>${e.continuedFrom(r.title)} ↗</span>
|
|
1989
|
+
</button>
|
|
1990
|
+
${i ? a`<div class="carried" part="carried-over">
|
|
1991
|
+
<button class="carried-head" aria-expanded=${s ? "true" : "false"} @click=${() => {
|
|
1992
|
+
this.carriedClosed = s;
|
|
1993
|
+
}}>
|
|
1994
|
+
<span class="name">${v("package-open", 14)}${e.carriedOver}</span>
|
|
1995
|
+
${v(s ? "chevron-up" : "chevron-down", 14)}
|
|
1996
|
+
</button>
|
|
1997
|
+
${s ? a`<div class="carried-text">${i}</div>
|
|
1998
|
+
<div class="carried-note">${e.carriedNote}</div>` : o}
|
|
1999
|
+
</div>` : o}
|
|
2000
|
+
${c ? a`<div class="carry-on-row">
|
|
2001
|
+
<button class="carry-on" part="carry-on" @click=${() => this.chat?.send(e.carryOnMessage)}>
|
|
2002
|
+
${v("play", 13)}${e.carryOn}
|
|
2003
|
+
</button>
|
|
2004
|
+
</div>` : o}
|
|
1807
2005
|
</div>`;
|
|
1808
2006
|
}
|
|
1809
2007
|
renderEmpty() {
|
|
1810
2008
|
let e = this.labels, t = this.options?.starters ?? [];
|
|
1811
|
-
return
|
|
1812
|
-
<span class="avatar">${
|
|
2009
|
+
return a`<div class="empty" part="empty">
|
|
2010
|
+
<span class="avatar">${g(24)}</span>
|
|
1813
2011
|
<span class="heading">${e.emptyTitle}</span>
|
|
1814
|
-
${t.length ?
|
|
1815
|
-
${t.map((e) =>
|
|
1816
|
-
</div>` :
|
|
2012
|
+
${t.length ? a`<div class="starters">
|
|
2013
|
+
${t.map((e) => a`<button class="starter" part="starter" @click=${() => this.chat?.send(e)}>${e}</button>`)}
|
|
2014
|
+
</div>` : o}
|
|
1817
2015
|
</div>`;
|
|
1818
2016
|
}
|
|
1819
2017
|
renderMessage(e, t) {
|
|
1820
2018
|
if (e.role === "user") {
|
|
1821
2019
|
let t = e.parts.map((e) => e.kind === "text" ? e.text : "").join(""), n = e.parts.flatMap((e) => e.kind === "attachments" ? e.attachments : []);
|
|
1822
|
-
return
|
|
2020
|
+
return a`${n.length ? a`<div class="photos" part="message-photos">${n.map((e) => this.renderPhoto(e))}</div>` : o}${t ? a`<div class="user" part="user-bubble">${t}</div>` : o}`;
|
|
1823
2021
|
}
|
|
1824
2022
|
let n = t && this.state?.status === "streaming", r = e.parts.map((t, r) => {
|
|
1825
2023
|
if (t.kind === "text") {
|
|
1826
|
-
if (!t.text) return
|
|
1827
|
-
let
|
|
1828
|
-
return
|
|
2024
|
+
if (!t.text) return o;
|
|
2025
|
+
let i = n && r === e.parts.length - 1;
|
|
2026
|
+
return a`<div class="md" part="assistant">${j(t.text)}${i ? a`<span class="caret"></span>` : o}</div>`;
|
|
1829
2027
|
}
|
|
1830
|
-
return t.kind === "tool" ? this.renderTool(t) :
|
|
1831
|
-
}),
|
|
2028
|
+
return t.kind === "tool" ? this.renderTool(t) : o;
|
|
2029
|
+
}), i = n && !e.parts.length, s = a`<div class="assistant">
|
|
1832
2030
|
${r}
|
|
1833
|
-
${
|
|
2031
|
+
${i ? a`<span class="step" part="tool-step">${v("loader", 13)}<span>${this.labels.running}</span></span>` : o}
|
|
1834
2032
|
</div>`;
|
|
1835
|
-
return this.layout === "page" ?
|
|
2033
|
+
return this.layout === "page" ? a`<div class="assistant-row"><span class="avatar">${g(18)}</span>${s}</div>` : s;
|
|
1836
2034
|
}
|
|
1837
2035
|
renderPhoto(e) {
|
|
1838
|
-
let t =
|
|
2036
|
+
let t = F(e.thumbnailUrl), n = (e.previewUrl?.startsWith("blob:") ? e.previewUrl : void 0) ?? t, r = a`<span class="photo-name">${v("image-off", 14)}<span>${e.name}</span></span>`, i = n ? a`<img
|
|
1839
2037
|
src=${n}
|
|
1840
2038
|
alt=${e.name}
|
|
1841
2039
|
loading="lazy"
|
|
1842
2040
|
@error=${(e) => e.target.closest(".photo")?.setAttribute("data-broken", "")}
|
|
1843
2041
|
/>${r}` : r;
|
|
1844
|
-
return t ?
|
|
2042
|
+
return t ? a`<a class="photo" href=${t} target="_blank" rel="noopener noreferrer" title=${e.name}>${i}</a>` : a`<span class="photo" data-broken=${n ? o : ""} title=${e.name}>${i}</span>`;
|
|
1845
2043
|
}
|
|
1846
2044
|
renderChip(e) {
|
|
1847
2045
|
let t = this.labels, n = e.status === "preparing" || e.status === "uploading", r = e.status === "failed";
|
|
1848
|
-
return
|
|
1849
|
-
${e.previewUrl && e.error !== "type" ?
|
|
1850
|
-
${n ?
|
|
2046
|
+
return a`<div class="chip" part="attachment-chip" data-status=${e.status} title=${e.name}>
|
|
2047
|
+
${e.previewUrl && e.error !== "type" ? a`<img src=${e.previewUrl} alt=${e.name} />` : a`<span class="chip-icon">${v("image-off", 18)}</span>`}
|
|
2048
|
+
${n ? a`<span
|
|
1851
2049
|
class="chip-progress"
|
|
1852
2050
|
role="progressbar"
|
|
1853
2051
|
aria-label=${e.name}
|
|
1854
2052
|
aria-valuemin="0"
|
|
1855
2053
|
aria-valuemax="100"
|
|
1856
2054
|
aria-valuenow=${Math.round(e.progress * 100)}
|
|
1857
|
-
><span style=${
|
|
1858
|
-
></span>` :
|
|
1859
|
-
${r && e.error ?
|
|
1860
|
-
${r && e.error === "upload" ?
|
|
1861
|
-
${
|
|
1862
|
-
</button>` :
|
|
2055
|
+
><span style=${c({ width: `${Math.max(8, Math.round(e.progress * 100))}%` })}></span
|
|
2056
|
+
></span>` : o}
|
|
2057
|
+
${r && e.error ? a`<span class="chip-error">${t.photoProblem[e.error]}</span>` : o}
|
|
2058
|
+
${r && e.error === "upload" ? a`<button class="chip-retry" aria-label=${t.retryPhoto} title=${t.retryPhoto} @click=${() => this.chat?.retryUpload(e.id)}>
|
|
2059
|
+
${v("refresh-cw", 12)}
|
|
2060
|
+
</button>` : o}
|
|
1863
2061
|
<button class="chip-remove" aria-label=${t.removePhoto} title=${t.removePhoto} @click=${() => this.chat?.removeUpload(e.id)}>
|
|
1864
|
-
${
|
|
2062
|
+
${v("x", 11)}
|
|
1865
2063
|
</button>
|
|
1866
2064
|
</div>`;
|
|
1867
2065
|
}
|
|
@@ -1886,13 +2084,13 @@ var j = r`
|
|
|
1886
2084
|
t.length && (e.preventDefault(), this.chat?.addFiles(t));
|
|
1887
2085
|
}
|
|
1888
2086
|
toolLabel(e) {
|
|
1889
|
-
return e.title ||
|
|
2087
|
+
return e.title || d(e.toolName);
|
|
1890
2088
|
}
|
|
1891
2089
|
renderTool(e) {
|
|
1892
2090
|
let t = this.labels;
|
|
1893
|
-
if (e.state === "awaiting-approval") return
|
|
2091
|
+
if (e.state === "awaiting-approval") return o;
|
|
1894
2092
|
if (e.approvalId) {
|
|
1895
|
-
let [n, r,
|
|
2093
|
+
let [n, r, i] = e.state === "done" ? [
|
|
1896
2094
|
"done",
|
|
1897
2095
|
"circle-check",
|
|
1898
2096
|
e.granted ? t.confirmedAllowed : t.confirmed
|
|
@@ -1903,17 +2101,17 @@ var j = r`
|
|
|
1903
2101
|
] : e.state === "error" ? [
|
|
1904
2102
|
"error",
|
|
1905
2103
|
"circle-alert",
|
|
1906
|
-
e.errorText?.includes(
|
|
2104
|
+
e.errorText?.includes(N) ? t.outcomeUnknown : t.stepFailed
|
|
1907
2105
|
] : [
|
|
1908
2106
|
"denied",
|
|
1909
2107
|
"loader",
|
|
1910
2108
|
t.running
|
|
1911
2109
|
];
|
|
1912
|
-
return
|
|
2110
|
+
return a`<div class="decided" part="decided" title=${e.state === "error" ? e.errorText ?? "" : ""}>
|
|
1913
2111
|
<span class="what"
|
|
1914
|
-
><span class=${n}>${
|
|
2112
|
+
><span class=${n}>${v(r, 15)}</span>${this.toolLabel(e)}${e.preview ? ` · ${e.preview.summary}` : ""}</span
|
|
1915
2113
|
>
|
|
1916
|
-
<span class=${n}>${
|
|
2114
|
+
<span class=${n}>${i}</span>
|
|
1917
2115
|
</div>`;
|
|
1918
2116
|
}
|
|
1919
2117
|
if (e.allowed) return this.renderAllowed(e);
|
|
@@ -1922,73 +2120,73 @@ var j = r`
|
|
|
1922
2120
|
part: e,
|
|
1923
2121
|
client: this.chat
|
|
1924
2122
|
}, n);
|
|
1925
|
-
if (this.options?.toolSteps === "hide") return
|
|
1926
|
-
let r = e.state === "done" ?
|
|
1927
|
-
${
|
|
2123
|
+
if (this.options?.toolSteps === "hide") return o;
|
|
2124
|
+
let r = e.state === "done" ? h(e.output) : null, i = e.state === "done" ? a`<span class="ok">${v("check", 13)}</span>` : e.state === "error" ? a`<span class="bad">${v("circle-alert", 13)}</span>` : e.state === "denied" ? v("ban", 13) : a`<span class="spin">${v("loader", 13)}</span>`, s = a`<span class="step" part="tool-step" title=${e.state === "error" ? e.errorText ?? "" : ""}>
|
|
2125
|
+
${i}<span>${this.toolLabel(e)}${r === null ? "" : ` · ${t.found(r)}`}</span>
|
|
1928
2126
|
</span>`;
|
|
1929
|
-
return e.state !== "done" || !e.images?.length ? s :
|
|
2127
|
+
return e.state !== "done" || !e.images?.length ? s : a`<div class="step-pictures" part="tool-pictures">
|
|
1930
2128
|
${s}
|
|
1931
2129
|
<div class="pictures">
|
|
1932
|
-
${e.images.map((n, r) =>
|
|
2130
|
+
${e.images.map((n, r) => a`<button
|
|
1933
2131
|
class="picture"
|
|
1934
2132
|
aria-label=${t.showPicture(r + 1, e.images.length)}
|
|
1935
|
-
@click=${() => this.enlarged =
|
|
2133
|
+
@click=${() => this.enlarged = L(n)}
|
|
1936
2134
|
>
|
|
1937
|
-
<img src=${
|
|
2135
|
+
<img src=${L(n)} alt=${t.showPicture(r + 1, e.images.length)} />
|
|
1938
2136
|
</button>`)}
|
|
1939
2137
|
</div>
|
|
1940
2138
|
</div>`;
|
|
1941
2139
|
}
|
|
1942
2140
|
renderAllowed(e) {
|
|
1943
|
-
let t = this.labels, n = this.state?.allowances.find((t) => t.toolName === e.toolName), r = e.state === "done" ?
|
|
1944
|
-
return
|
|
2141
|
+
let t = this.labels, n = this.state?.allowances.find((t) => t.toolName === e.toolName), r = e.state === "done" ? a`<span class="ok">${v("check", 13)}</span>` : e.state === "error" ? a`<span class="bad">${v("circle-alert", 13)}</span>` : a`<span class="spin">${v("loader", 13)}</span>`;
|
|
2142
|
+
return a`<div class="allowed" part="allowed-step" title=${e.state === "error" ? e.errorText ?? "" : ""}>
|
|
1945
2143
|
<div class="allowed-head">
|
|
1946
2144
|
<span class="what">${r}${this.toolLabel(e)}</span>
|
|
1947
|
-
<span class="allowed-tag">${
|
|
2145
|
+
<span class="allowed-tag">${v("shield-check", 12)} ${t.allowed}</span>
|
|
1948
2146
|
</div>
|
|
1949
2147
|
${e.preview ? this.renderPreview(e.preview) : this.renderRows(`allowed:${e.toolCallId}`, e.input)}
|
|
1950
|
-
${n ?
|
|
2148
|
+
${n ? a`<div class="allowed-by">${t.allowedAt(this.toolLabel(e), I(n.grantedAt))}</div>` : o}
|
|
1951
2149
|
</div>`;
|
|
1952
2150
|
}
|
|
1953
2151
|
renderAllowances() {
|
|
1954
2152
|
let e = this.state?.allowances ?? [];
|
|
1955
|
-
if (!e.length) return
|
|
2153
|
+
if (!e.length) return o;
|
|
1956
2154
|
let t = this.labels;
|
|
1957
|
-
return
|
|
1958
|
-
<span class="allowance-text">${
|
|
2155
|
+
return a`${e.map((e) => a`<div class="allowance" part="allowance-bar" role="status">
|
|
2156
|
+
<span class="allowance-text">${v("shield-check", 13)} ${t.allowanceBar(this.toolLabel(e))}</span>
|
|
1959
2157
|
<button class="link" @click=${() => this.chat?.revokeAllowance(e.toolName)}>${t.askEveryTime}</button>
|
|
1960
2158
|
</div>`)}`;
|
|
1961
2159
|
}
|
|
1962
2160
|
renderPreview(e) {
|
|
1963
|
-
if (!e) return
|
|
2161
|
+
if (!e) return o;
|
|
1964
2162
|
let t = this.labels;
|
|
1965
|
-
return
|
|
2163
|
+
return a`<div class="preview" part="preview">
|
|
1966
2164
|
<div class="preview-summary">${e.summary}</div>
|
|
1967
|
-
${e.changes.length ?
|
|
1968
|
-
${e.changes.map((e) =>
|
|
2165
|
+
${e.changes.length ? a`<ul class="preview-changes">
|
|
2166
|
+
${e.changes.map((e) => a`<li>
|
|
1969
2167
|
<span class="preview-label">${e.label}:</span>
|
|
1970
|
-
${e.current === void 0 ?
|
|
2168
|
+
${e.current === void 0 ? o : a`<span class="preview-now">${t.now} ${e.current}</span> → `}
|
|
1971
2169
|
<span class="preview-next">${e.next}</span>
|
|
1972
2170
|
</li>`)}
|
|
1973
|
-
</ul>` :
|
|
2171
|
+
</ul>` : o}
|
|
1974
2172
|
</div>`;
|
|
1975
2173
|
}
|
|
1976
2174
|
renderRows(e, t) {
|
|
1977
|
-
let n = this.labels, r =
|
|
1978
|
-
return
|
|
1979
|
-
${r.map((e) =>
|
|
2175
|
+
let n = this.labels, r = m(t), i = this.expanded.has(e), s = (e) => e.split("\n").length, c = (e) => s(e) > 1 ? `${e.split("\n")[0].slice(0, 160)}… (${n.lines(s(e))})` : e.length > 160 ? `${e.slice(0, 160)}…` : e, l = r.some((e) => e.value.length > 160 || s(e.value) > 1);
|
|
2176
|
+
return a`<div class="rows">
|
|
2177
|
+
${r.map((e) => a`<div class="row">
|
|
1980
2178
|
<span class="label">${e.label}</span>
|
|
1981
|
-
<span class="value">${
|
|
2179
|
+
<span class="value">${i ? e.value : c(e.value)}</span>
|
|
1982
2180
|
</div>`)}
|
|
1983
|
-
${l ?
|
|
2181
|
+
${l ? a`<button class="link" @click=${() => this.toggleRows(e)}>${i ? n.showLess : n.showMore}</button>` : o}
|
|
1984
2182
|
</div>`;
|
|
1985
2183
|
}
|
|
1986
2184
|
renderPending() {
|
|
1987
2185
|
let e = this.state?.pendingApprovals ?? [];
|
|
1988
|
-
if (!e.length || this.state?.status !== "awaiting-approval") return
|
|
2186
|
+
if (!e.length || this.state?.status !== "awaiting-approval") return o;
|
|
1989
2187
|
let t = this.labels;
|
|
1990
2188
|
if (e.length === 1) {
|
|
1991
|
-
let n = e[0], r = this.options?.cards?.[n.toolName]?.confirm,
|
|
2189
|
+
let n = e[0], r = this.options?.cards?.[n.toolName]?.confirm, i = {
|
|
1992
2190
|
kind: "tool",
|
|
1993
2191
|
toolCallId: n.toolCallId,
|
|
1994
2192
|
toolName: n.toolName,
|
|
@@ -2000,7 +2198,7 @@ var j = r`
|
|
|
2000
2198
|
if (r && this.chat) {
|
|
2001
2199
|
let e = this.chat;
|
|
2002
2200
|
return this.cardSlot(`confirm:${n.approvalId}`, {
|
|
2003
|
-
part:
|
|
2201
|
+
part: i,
|
|
2004
2202
|
approval: n,
|
|
2005
2203
|
client: e,
|
|
2006
2204
|
decide: (t, r) => e.decide([{
|
|
@@ -2010,13 +2208,13 @@ var j = r`
|
|
|
2010
2208
|
}])
|
|
2011
2209
|
}, r);
|
|
2012
2210
|
}
|
|
2013
|
-
return
|
|
2211
|
+
return a`<div class="confirm" part="confirm-card" role="group" aria-label=${this.toolLabel(n)}>
|
|
2014
2212
|
<div class="confirm-head" part="confirm-header">
|
|
2015
|
-
<span class="what">${
|
|
2213
|
+
<span class="what">${v("pencil-line", 15)} ${this.toolLabel(n)}</span>
|
|
2016
2214
|
<span class="badge">${t.needsOk}</span>
|
|
2017
2215
|
</div>
|
|
2018
2216
|
${this.renderPreview(n.preview)}
|
|
2019
|
-
${n.preview ?
|
|
2217
|
+
${n.preview ? a`<div class="exact-head">${t.exactValues}</div>` : o}
|
|
2020
2218
|
${this.renderRows(n.approvalId, n.input)}
|
|
2021
2219
|
<div class="confirm-foot">
|
|
2022
2220
|
<span class="hint">${n.preview ? "" : t.exactValues}</span>
|
|
@@ -2029,12 +2227,12 @@ var j = r`
|
|
|
2029
2227
|
</div>`;
|
|
2030
2228
|
}
|
|
2031
2229
|
let n = e.filter((e) => !this.unticked.has(e.approvalId)).length;
|
|
2032
|
-
return
|
|
2230
|
+
return a`<div class="confirm" part="confirm-card" role="group" aria-label=${t.changes(e.length)}>
|
|
2033
2231
|
<div class="confirm-head" part="confirm-header">
|
|
2034
2232
|
<span class="what">${t.changes(e.length)}</span>
|
|
2035
2233
|
<span class="badge">${t.needsOk}</span>
|
|
2036
2234
|
</div>
|
|
2037
|
-
${e.map((e) =>
|
|
2235
|
+
${e.map((e) => a`<div class="item">
|
|
2038
2236
|
<input
|
|
2039
2237
|
type="checkbox"
|
|
2040
2238
|
aria-label=${this.toolLabel(e)}
|
|
@@ -2044,7 +2242,7 @@ var j = r`
|
|
|
2044
2242
|
<span class="body">
|
|
2045
2243
|
<span class="name">${this.toolLabel(e)}</span>
|
|
2046
2244
|
${this.renderPreview(e.preview)}
|
|
2047
|
-
${e.preview ?
|
|
2245
|
+
${e.preview ? a`<span class="exact-head">${t.exactValues}</span>` : o}
|
|
2048
2246
|
${this.renderRows(e.approvalId, e.input)}
|
|
2049
2247
|
</span>
|
|
2050
2248
|
</div>`)}
|
|
@@ -2061,7 +2259,7 @@ var j = r`
|
|
|
2061
2259
|
</div>`;
|
|
2062
2260
|
}
|
|
2063
2261
|
renderProblem(e) {
|
|
2064
|
-
let t = this.labels, n = t.problems[e.code], r = this.chat,
|
|
2262
|
+
let t = this.labels, n = t.problems[e.code], r = this.chat, i = e.code === "reconnecting" || e.code === "in-progress" ? "" : e.code === "throttled" || e.code === "conversation-full" || e.code === "token-expired" || e.code === "too-long" || e.code === "answer-cut" || e.code === "step-limit" ? "warn" : "error", s = {
|
|
2065
2263
|
reconnecting: "refresh-cw",
|
|
2066
2264
|
"token-expired": "refresh-cw",
|
|
2067
2265
|
"in-progress": "clock",
|
|
@@ -2070,19 +2268,56 @@ var j = r`
|
|
|
2070
2268
|
"store-unreachable": "plug-zap",
|
|
2071
2269
|
"cut-off": "wifi-off",
|
|
2072
2270
|
unavailable: "wifi-off"
|
|
2073
|
-
}, c = e.code === "conversation-full" ?
|
|
2074
|
-
return
|
|
2075
|
-
<span class=${e.code === "reconnecting" ? "icon spin" : "icon"}>${
|
|
2271
|
+
}, c = e.code === "conversation-full" ? a`<button class="btn secondary" @click=${() => this.newConversation()}>${t.newConversation}</button>` : e.code === "cut-off" ? a`<button class="btn secondary" @click=${() => r?.reload()}>${t.reload}</button>` : e.code === "token-expired" || e.code === "answer-cut" || e.code === "step-limit" ? a`<button class="btn secondary" @click=${() => r?.send(t.continueMessage)}>${t.continue}</button>` : e.code === "too-long" ? a`<button class="btn secondary" @click=${() => r?.send(t.continueSmallerMessage)}>${t.continue}</button>` : e.code === "store-unreachable" || e.code === "unavailable" || e.code === "failed" || e.code === "in-progress" ? a`<button class="btn secondary" @click=${() => r?.retry()}>${t.tryAgain}</button>` : o, l = e.code === "reconnecting" ? o : a`<button class="btn secondary" @click=${() => r?.dismissProblem()}>${t.dismiss}</button>`;
|
|
2272
|
+
return a`<div class=${`problem ${i}`} part="problem" role="status">
|
|
2273
|
+
<span class=${e.code === "reconnecting" ? "icon spin" : "icon"}>${v(s[e.code] ?? "circle-alert", 16)}</span>
|
|
2076
2274
|
<span class="body">
|
|
2077
2275
|
<span class="head">${n.title}</span>
|
|
2078
2276
|
<span>${e.code === "failed" && e.message ? e.message : n.text(e.retryAfter)}</span>
|
|
2079
2277
|
<span class="actions">${c}${l}</span>
|
|
2080
2278
|
</span>
|
|
2279
|
+
</div>`;
|
|
2280
|
+
}
|
|
2281
|
+
renderFull() {
|
|
2282
|
+
let e = this.labels.full, t = this.state;
|
|
2283
|
+
if (t.continuing) return a`<div class="problem working" part="problem" role="status">
|
|
2284
|
+
<span class="icon spin">${v("loader", 16)}</span>
|
|
2285
|
+
<span class="body">
|
|
2286
|
+
<span class="head">${e.workingTitle}</span>
|
|
2287
|
+
<span>${e.workingText}</span>
|
|
2288
|
+
</span>
|
|
2289
|
+
</div>`;
|
|
2290
|
+
let n = t.pendingApprovals.length > 0, r = t.status === "sending" || t.status === "streaming" || t.status === "loading";
|
|
2291
|
+
return a`<div class="problem warn" part="problem" role="status">
|
|
2292
|
+
<span class="icon">${v("messages-square", 16)}</span>
|
|
2293
|
+
<span class="body">
|
|
2294
|
+
<span class="head">${e.title}</span>
|
|
2295
|
+
<span>${n ? e.textWaiting : e.text}</span>
|
|
2296
|
+
<span class="actions">
|
|
2297
|
+
<button class="btn primary" ?disabled=${n || r} @click=${() => this.continueConversation()}>
|
|
2298
|
+
${e.continue}
|
|
2299
|
+
</button>
|
|
2300
|
+
${n ? o : a`<button class="btn secondary" ?disabled=${r} @click=${() => this.newConversation()}>
|
|
2301
|
+
${e.startEmpty}
|
|
2302
|
+
</button>`}
|
|
2303
|
+
</span>
|
|
2304
|
+
</span>
|
|
2081
2305
|
</div>`;
|
|
2082
2306
|
}
|
|
2083
2307
|
renderBottom() {
|
|
2084
|
-
let e = this.labels,
|
|
2085
|
-
|
|
2308
|
+
let e = this.labels, t = this.state, r = t?.status === "sending" || t?.status === "streaming", i = t?.status === "awaiting-approval", s = !!t?.full, c = t?.problem && !(s && t.problem.code === "conversation-full") ? t.problem : null;
|
|
2309
|
+
if (s && t?.continuedIn) {
|
|
2310
|
+
let n = t.continuedIn;
|
|
2311
|
+
return a`${c ? a`<div class="column">${this.renderProblem(c)}</div>` : o}
|
|
2312
|
+
<div class="column">
|
|
2313
|
+
<div class="continued-in" part="continued-in">
|
|
2314
|
+
${v("corner-down-right", 16)}<span class="text">${e.full.continuedIn}</span>
|
|
2315
|
+
<button class="link" @click=${() => this.openConversation(n)}>${e.full.open}</button>
|
|
2316
|
+
</div>
|
|
2317
|
+
</div>`;
|
|
2318
|
+
}
|
|
2319
|
+
return a`${c ? a`<div class="column">${this.renderProblem(c)}</div>` : o}
|
|
2320
|
+
${s ? a`<div class="column">${this.renderFull()}</div>` : o}
|
|
2086
2321
|
<div
|
|
2087
2322
|
class="composer column"
|
|
2088
2323
|
part="composer"
|
|
@@ -2091,44 +2326,44 @@ var j = r`
|
|
|
2091
2326
|
@dragleave=${(e) => this.onDrag(e, !1)}
|
|
2092
2327
|
@drop=${this.onDrop}
|
|
2093
2328
|
>
|
|
2094
|
-
${
|
|
2095
|
-
${
|
|
2096
|
-
<div class="chips-note">${e.photosLimit(this.photoCount(), this.photoMb())}</div>` :
|
|
2097
|
-
${this.dragging ?
|
|
2329
|
+
${t?.allowances.length ? a`<div class="allowances">${this.renderAllowances()}</div>` : o}
|
|
2330
|
+
${t?.uploads.length ? a`<div class="chips" part="attachment-chips">${t.uploads.map((e) => this.renderChip(e))}</div>
|
|
2331
|
+
<div class="chips-note">${e.photosLimit(this.photoCount(), this.photoMb())}</div>` : o}
|
|
2332
|
+
${this.dragging ? a`<div class="drop-note">${e.dropPhotos}</div>` : o}
|
|
2098
2333
|
<div class="box">
|
|
2099
|
-
${
|
|
2334
|
+
${t?.canAttach ? a`<button
|
|
2100
2335
|
class="attach"
|
|
2101
2336
|
part="attach-button"
|
|
2102
2337
|
aria-label=${e.attachPhoto}
|
|
2103
2338
|
title=${e.attachPhoto}
|
|
2104
|
-
?disabled=${!this.chat}
|
|
2339
|
+
?disabled=${!this.chat || s}
|
|
2105
2340
|
@click=${() => this.pickPhotos()}
|
|
2106
2341
|
>
|
|
2107
|
-
${
|
|
2342
|
+
${v("image-plus", 17)}
|
|
2108
2343
|
</button>
|
|
2109
2344
|
<input
|
|
2110
2345
|
type="file"
|
|
2111
2346
|
hidden
|
|
2112
2347
|
multiple
|
|
2113
|
-
accept=${(this.chat?.attachmentLimits().accept ??
|
|
2348
|
+
accept=${(this.chat?.attachmentLimits().accept ?? n.accept).join(",")}
|
|
2114
2349
|
@change=${this.onPicked}
|
|
2115
|
-
/>` :
|
|
2350
|
+
/>` : o}
|
|
2116
2351
|
<label class="sr-only" for="input">${e.placeholder}</label>
|
|
2117
2352
|
<textarea
|
|
2118
2353
|
id="input"
|
|
2119
2354
|
part="input"
|
|
2120
2355
|
rows="1"
|
|
2121
|
-
lang=${this.locale ||
|
|
2122
|
-
placeholder=${e.placeholder}
|
|
2356
|
+
lang=${this.locale || o}
|
|
2357
|
+
placeholder=${s ? e.full.placeholder : e.placeholder}
|
|
2123
2358
|
.value=${this.draft}
|
|
2124
|
-
?disabled=${!this.chat}
|
|
2359
|
+
?disabled=${!this.chat || s}
|
|
2125
2360
|
@input=${this.onInput}
|
|
2126
2361
|
@keydown=${this.onKeydown}
|
|
2127
2362
|
@paste=${this.onPaste}
|
|
2128
2363
|
></textarea>
|
|
2129
|
-
${r ?
|
|
2364
|
+
${r ? a`<button class="stop" part="stop" @click=${() => this.chat?.stop()}>
|
|
2130
2365
|
<span class="square"></span>${e.stop}
|
|
2131
|
-
</button>` :
|
|
2366
|
+
</button>` : a`<button
|
|
2132
2367
|
class="send"
|
|
2133
2368
|
part="send"
|
|
2134
2369
|
aria-label=${e.send}
|
|
@@ -2136,24 +2371,24 @@ var j = r`
|
|
|
2136
2371
|
?disabled=${!this.canSend() || !this.chat}
|
|
2137
2372
|
@click=${() => this.submit()}
|
|
2138
2373
|
>
|
|
2139
|
-
${
|
|
2374
|
+
${v("arrow-up", 17)}
|
|
2140
2375
|
</button>`}
|
|
2141
2376
|
</div>
|
|
2142
2377
|
<div class="footer">
|
|
2143
|
-
<span class="ghuri">${
|
|
2144
|
-
<span>· ${
|
|
2378
|
+
<span class="ghuri">${g(12)} Ghuri AI</span>
|
|
2379
|
+
<span>· ${i && !s ? e.newMessageCancels : t?.allowances.length ? e.footerAllowed : e.footer}</span>
|
|
2145
2380
|
</div>
|
|
2146
2381
|
</div>`;
|
|
2147
2382
|
}
|
|
2148
2383
|
photoCount() {
|
|
2149
|
-
return this.chat?.attachmentLimits().maxCount ??
|
|
2384
|
+
return this.chat?.attachmentLimits().maxCount ?? n.maxCount;
|
|
2150
2385
|
}
|
|
2151
2386
|
photoMb() {
|
|
2152
|
-
let e = this.chat?.attachmentLimits().maxBytes ??
|
|
2387
|
+
let e = this.chat?.attachmentLimits().maxBytes ?? n.maxBytes;
|
|
2153
2388
|
return Math.round(e / 1048576 * 10) / 10;
|
|
2154
2389
|
}
|
|
2155
2390
|
};
|
|
2156
|
-
function
|
|
2391
|
+
function F(e) {
|
|
2157
2392
|
if (typeof e == "string") try {
|
|
2158
2393
|
let t = new URL(e);
|
|
2159
2394
|
return t.protocol === "https:" ? t.toString() : void 0;
|
|
@@ -2161,15 +2396,15 @@ function P(e) {
|
|
|
2161
2396
|
return;
|
|
2162
2397
|
}
|
|
2163
2398
|
}
|
|
2164
|
-
function
|
|
2399
|
+
function I(e) {
|
|
2165
2400
|
let t = new Date(e);
|
|
2166
2401
|
return Number.isNaN(t.getTime()) ? "" : `${String(t.getHours()).padStart(2, "0")}:${String(t.getMinutes()).padStart(2, "0")}`;
|
|
2167
2402
|
}
|
|
2168
|
-
function
|
|
2403
|
+
function L(e) {
|
|
2169
2404
|
return `data:${e.mediaType};base64,${e.data}`;
|
|
2170
2405
|
}
|
|
2171
2406
|
// src/index.ts
|
|
2172
|
-
typeof customElements < "u" && !customElements.get("ghuri-chat") && customElements.define("ghuri-chat",
|
|
2173
|
-
export {
|
|
2407
|
+
typeof customElements < "u" && !customElements.get("ghuri-chat") && customElements.define("ghuri-chat", P);
|
|
2408
|
+
export { P as t };
|
|
2174
2409
|
|
|
2175
|
-
//# sourceMappingURL=src-
|
|
2410
|
+
//# sourceMappingURL=src-COOw7K47.js.map
|