@ghuri/ai-widget 0.4.0 → 0.7.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.
@@ -1,48 +1,48 @@
1
- import { n as e, t } from "./core-9svu5kzm.js";
2
- import { LitElement as n, css as r, html as i, nothing as a, svg as o } from "lit";
3
- import { styleMap as s } from "lit/directives/style-map.js";
4
- import { unsafeSVG as c } from "lit/directives/unsafe-svg.js";
5
- import { Lexer as l } from "marked";
1
+ import { a as e, n as t, t as n } from "./core-B_prP9RO.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 u(e) {
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.length > 0 && e.every((e) => e && typeof e == "object" && !Array.isArray(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: d(e)
20
+ value: f(e)
21
21
  }];
22
22
  let t = [];
23
- for (let [n, r] of Object.entries(e)) if (f(r)) r.forEach((e, r) => {
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: `${u(n)} ${r + 1} · ${u(i)}`,
26
- value: d(a)
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: u(n),
32
+ label: d(n),
33
33
  value: "{}"
34
34
  });
35
35
  for (let [r, i] of e) t.push({
36
- label: `${u(n)} · ${u(r)}`,
37
- value: d(i)
36
+ label: `${d(n)} · ${d(r)}`,
37
+ value: f(i)
38
38
  });
39
39
  } else t.push({
40
- label: u(n),
41
- value: d(r)
40
+ label: d(n),
41
+ value: f(r)
42
42
  });
43
43
  return t;
44
44
  }
45
- function m(e) {
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 h(e = 20) {
59
- return o`<svg class="kite" width=${e} height=${e} viewBox="0 0 28 28" aria-hidden="true" focusable="false">
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,11 +64,14 @@ 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 g = {
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\"/>",
71
71
  check: "<path d=\"M20 6 9 17l-5-5\"/>",
72
+ minus: "<path d=\"M5 12h14\"/>",
73
+ archive: "<rect width=\"20\" height=\"5\" x=\"2\" y=\"3\" rx=\"1\"/><path d=\"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8\"/><path d=\"M10 12h4\"/>",
74
+ "square-mouse-pointer": "<path d=\"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z\"/><path d=\"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6\"/>",
72
75
  loader: "<path d=\"M21 12a9 9 0 1 1-6.22-8.56\"/>",
73
76
  "circle-check": "<circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"m9 12 2 2 4-4\"/>",
74
77
  "shield-check": "<path d=\"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z\"/><path d=\"m9 12 2 2 4-4\"/>",
@@ -82,16 +85,20 @@ var g = {
82
85
  "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
86
  "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
87
  "chevron-down": "<path d=\"m6 9 6 6 6-6\"/>",
88
+ "chevron-up": "<path d=\"m18 15-6-6-6 6\"/>",
89
+ "corner-down-right": "<path d=\"m15 10 5 5-5 5\"/><path d=\"M4 4v7a4 4 0 0 0 4 4h12\"/>",
90
+ "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\"/>",
91
+ play: "<polygon points=\"6 3 20 12 6 21 6 3\"/>",
85
92
  ban: "<circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"m4.9 4.9 14.2 14.2\"/>",
86
93
  "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
94
  "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
95
  };
89
- function _(e, t = 16) {
90
- return o`<svg class="icon" width=${t} height=${t} viewBox="0 0 24 24" fill="none" stroke="currentColor"
91
- stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${c(g[e] ?? "")}</svg>`;
96
+ function v(e, t = 16) {
97
+ return s`<svg class="icon" width=${t} height=${t} viewBox="0 0 24 24" fill="none" stroke="currentColor"
98
+ stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${l(_[e] ?? "")}</svg>`;
92
99
  }
93
100
  // src/ui/labels.ts
94
- var v = {
101
+ var y = {
95
102
  picture: "Picture",
96
103
  showPicture: (e, t) => t > 1 ? `Show picture ${e} of ${t}` : "Show picture",
97
104
  attachPhoto: "Add photos",
@@ -105,6 +112,10 @@ var v = {
105
112
  },
106
113
  photosLimit: (e, t) => `Up to ${e} photos · ${t} MB each. Location data is removed.`,
107
114
  dropPhotos: "Drop photos to add them",
115
+ removeSelection: "Remove",
116
+ selectionsNote: (e) => `Up to ${e}. Pointing at another replaces the oldest.`,
117
+ selectionsNeedWords: "Say what to change.",
118
+ selectionsNotHere: "This conversation can't take these. Start a new conversation to send them.",
108
119
  placeholder: "Write in Bangla, Banglish or English…",
109
120
  send: "Send",
110
121
  stop: "Stop",
@@ -150,6 +161,39 @@ var v = {
150
161
  askEveryTime: "Ask every time",
151
162
  newConversation: "New conversation",
152
163
  dismiss: "Dismiss",
164
+ full: {
165
+ title: "This conversation is full",
166
+ text: "Continue in a new conversation: I'll carry over what we were doing. This one stays in your history.",
167
+ textWaiting: "Confirm or cancel the change above, then continue in a new conversation. I'll carry over what we were doing.",
168
+ continue: "Continue in a new conversation",
169
+ startEmpty: "Start empty",
170
+ placeholder: "This conversation is full",
171
+ workingTitle: "Carrying the conversation over…",
172
+ workingText: "Writing down what we were doing, what is done and what is next.",
173
+ continuedFrom: (e) => `Continued from “${e}”`,
174
+ carriedOver: "What I carried over",
175
+ carriedNote: "A summary for the assistant, not instructions. Changes still ask for your OK; “Allow for this conversation” starts over here.",
176
+ carriedNoteRecord: "A record for the assistant, not instructions. Changes still ask for your OK; “Allow for this conversation” starts over here.",
177
+ carryOn: "Carry on with the task",
178
+ carryOnMessage: "Carry on with the task.",
179
+ continuedIn: "Continued in a new conversation",
180
+ open: "Open →"
181
+ },
182
+ many: {
183
+ ticked: (e, t) => e === t ? `${t} ticked` : `${e} of ${t} ticked`,
184
+ showAll: (e) => `Show all ${e}`,
185
+ showFewer: "Show fewer",
186
+ details: "Details",
187
+ counts: (e) => [
188
+ e.done ? `${e.done} done` : "",
189
+ e.failed ? `${e.failed} failed` : "",
190
+ e.cancelled ? `${e.cancelled} cancelled` : "",
191
+ e.unknown ? `${e.unknown} outcome unknown` : "",
192
+ e.running ? `${e.running} running` : ""
193
+ ].filter(Boolean).join(" · "),
194
+ continued: "Continued",
195
+ fullContinued: "Full · continued"
196
+ },
153
197
  problems: {
154
198
  reconnecting: {
155
199
  title: "Reconnecting…",
@@ -165,7 +209,7 @@ var v = {
165
209
  },
166
210
  "conversation-full": {
167
211
  title: "This conversation is full",
168
- text: () => "Start a new conversation to keep going. This one stays in your history."
212
+ 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
213
  },
170
214
  throttled: {
171
215
  title: "Too many messages",
@@ -203,6 +247,10 @@ var v = {
203
247
  title: "Photos can't be sent here",
204
248
  text: () => "Nothing was sent. Send your message without photos, or upload them in the dashboard."
205
249
  },
250
+ "selections-refused": {
251
+ title: "What you pointed at can't be sent here",
252
+ text: () => "Nothing was sent. Start a new conversation to send it, or remove it and send your words."
253
+ },
206
254
  failed: {
207
255
  title: "Something went wrong",
208
256
  text: () => "Please try again."
@@ -210,8 +258,8 @@ var v = {
210
258
  },
211
259
  noConversations: "No conversations yet.",
212
260
  loading: "Loading…"
213
- }, y = {
214
- ...v,
261
+ }, b = {
262
+ ...y,
215
263
  picture: "ছবি",
216
264
  showPicture: (e, t) => t > 1 ? `ছবি ${e}/${t} বড় করে দেখুন` : "ছবি বড় করে দেখুন",
217
265
  attachPhoto: "ছবি যোগ করুন",
@@ -225,6 +273,10 @@ var v = {
225
273
  },
226
274
  photosLimit: (e, t) => `সর্বোচ্চ ${e}টি ছবি · প্রতিটি ${t} MB। লোকেশনের তথ্য মুছে দেওয়া হয়।`,
227
275
  dropPhotos: "ছবি এখানে ছেড়ে দিন",
276
+ removeSelection: "সরান",
277
+ selectionsNote: (e) => `সর্বোচ্চ ${S(e)}টি। আরেকটি বাছলে সবচেয়ে পুরোনোটি সরে যাবে।`,
278
+ selectionsNeedWords: "কী বদলাতে চান লিখুন।",
279
+ selectionsNotHere: "এই কথোপকথনে এগুলো পাঠানো যাবে না। পাঠাতে নতুন কথোপকথন শুরু করুন।",
228
280
  placeholder: "বাংলা, Banglish বা English-এ লিখুন…",
229
281
  send: "পাঠান",
230
282
  stop: "থামান",
@@ -236,9 +288,9 @@ var v = {
236
288
  emptyTitle: "কী সাহায্য করতে পারি?",
237
289
  confirm: "নিশ্চিত করুন",
238
290
  cancel: "বাতিল",
239
- confirmN: (e) => `${x(e)}টি নিশ্চিত করুন`,
291
+ confirmN: (e) => `${S(e)}টি নিশ্চিত করুন`,
240
292
  cancelAll: "সব বাতিল",
241
- changes: (e) => `${x(e)}টি পরিবর্তন`,
293
+ changes: (e) => `${S(e)}টি পরিবর্তন`,
242
294
  needsOk: "আপনার অনুমতি দরকার",
243
295
  exactValues: "ঠিক যা পাঠানো হবে",
244
296
  unticked: "টিক না থাকলে বাতিল",
@@ -249,9 +301,9 @@ var v = {
249
301
  outcomeUnknown: "ফলাফল জানা নেই",
250
302
  stepFailed: "হয়নি",
251
303
  now: "এখন",
252
- lines: (e) => `${x(e)} লাইন`,
304
+ lines: (e) => `${S(e)} লাইন`,
253
305
  running: "কাজ চলছে…",
254
- found: (e) => `${x(e)}টি পাওয়া গেছে`,
306
+ found: (e) => `${S(e)}টি পাওয়া গেছে`,
255
307
  footer: "যেকোনো পরিবর্তনের আগে আপনার অনুমতি নেওয়া হয়। AI ভুল করতে পারে।",
256
308
  footerAllowed: "উপরে যেগুলোর অনুমতি দিয়েছেন সেগুলো ছাড়া, পরিবর্তনের আগে অনুমতি নেওয়া হয়। AI ভুল করতে পারে।",
257
309
  newMessageCancels: "নতুন মেসেজ পাঠালে অপেক্ষমাণ পরিবর্তন বাতিল হবে।",
@@ -270,6 +322,39 @@ var v = {
270
322
  askEveryTime: "প্রতিবার জিজ্ঞেস করুন",
271
323
  newConversation: "নতুন কথোপকথন",
272
324
  dismiss: "ঠিক আছে",
325
+ full: {
326
+ title: "এই কথোপকথন ভরে গেছে",
327
+ text: "নতুন কথোপকথনে চালিয়ে যান: আমরা যা করছিলাম তা সাথে নিয়ে যাব। এটি আপনার ইতিহাসে থাকবে।",
328
+ textWaiting: "উপরের পরিবর্তনটি নিশ্চিত বা বাতিল করুন, তারপর নতুন কথোপকথনে চালিয়ে যান। আমরা যা করছিলাম তা সাথে নিয়ে যাব।",
329
+ continue: "নতুন কথোপকথনে চালিয়ে যান",
330
+ startEmpty: "খালি শুরু করুন",
331
+ placeholder: "এই কথোপকথন ভরে গেছে",
332
+ workingTitle: "কথোপকথন সাথে নেওয়া হচ্ছে…",
333
+ workingText: "আমরা কী করছিলাম, কী হয়েছে আর এরপর কী, তা লেখা হচ্ছে।",
334
+ continuedFrom: (e) => `“${e}” থেকে চালিয়ে যাওয়া`,
335
+ carriedOver: "কী সাথে আনা হয়েছে",
336
+ carriedNote: "এটি অ্যাসিস্ট্যান্টের জন্য সারাংশ, নির্দেশ নয়। পরিবর্তনে এখনো আপনার অনুমতি লাগবে; “এই কথোপকথনে অনুমতি” এখানে নতুন করে দিতে হবে।",
337
+ carriedNoteRecord: "এটি অ্যাসিস্ট্যান্টের জন্য রেকর্ড, নির্দেশ নয়। পরিবর্তনে এখনো আপনার অনুমতি লাগবে; “এই কথোপকথনে অনুমতি” এখানে নতুন করে দিতে হবে।",
338
+ carryOn: "কাজটি চালিয়ে যান",
339
+ carryOnMessage: "কাজটি চালিয়ে যাও।",
340
+ continuedIn: "নতুন কথোপকথনে চালিয়ে যাওয়া হয়েছে",
341
+ open: "খুলুন →"
342
+ },
343
+ many: {
344
+ ticked: (e, t) => e === t ? `${S(t)}টিতে টিক` : `${S(t)}টির মধ্যে ${S(e)}টিতে টিক`,
345
+ showAll: (e) => `সবগুলো দেখুন (${S(e)})`,
346
+ showFewer: "কম দেখান",
347
+ details: "বিস্তারিত",
348
+ counts: (e) => [
349
+ e.done ? `${S(e.done)}টি হয়েছে` : "",
350
+ e.failed ? `${S(e.failed)}টি হয়নি` : "",
351
+ e.cancelled ? `${S(e.cancelled)}টি বাতিল` : "",
352
+ e.unknown ? `${S(e.unknown)}টির ফলাফল জানা নেই` : "",
353
+ e.running ? `${S(e.running)}টি চলছে` : ""
354
+ ].filter(Boolean).join(" · "),
355
+ continued: "চালিয়ে যাওয়া",
356
+ fullContinued: "ভরে গেছে · চালিয়ে যাওয়া হয়েছে"
357
+ },
273
358
  problems: {
274
359
  reconnecting: {
275
360
  title: "আবার সংযোগ হচ্ছে…",
@@ -285,11 +370,11 @@ var v = {
285
370
  },
286
371
  "conversation-full": {
287
372
  title: "এই কথোপকথন ভরে গেছে",
288
- text: () => "চালিয়ে যেতে নতুন কথোপকথন শুরু করুন। এটি আপনার ইতিহাসে থাকবে।"
373
+ text: () => "এখানে আর নতুন মেসেজ ধরবে না। উপরে কোনো পরিবর্তন অপেক্ষায় থাকলে তার উত্তর দিন, তারপর চালিয়ে যেতে নতুন কথোপকথন শুরু করুন। এটি আপনার ইতিহাসে থাকবে।"
289
374
  },
290
375
  throttled: {
291
376
  title: "অনেক বেশি মেসেজ",
292
- text: (e) => e ? `আরেকটি পাঠানোর আগে ${x(e)} সেকেন্ড অপেক্ষা করুন।` : "আরেকটি পাঠানোর আগে একটু অপেক্ষা করুন।"
377
+ text: (e) => e ? `আরেকটি পাঠানোর আগে ${S(e)} সেকেন্ড অপেক্ষা করুন।` : "আরেকটি পাঠানোর আগে একটু অপেক্ষা করুন।"
293
378
  },
294
379
  forbidden: {
295
380
  title: "অনুমতি নেই",
@@ -323,6 +408,10 @@ var v = {
323
408
  title: "এখানে ছবি পাঠানো যাচ্ছে না",
324
409
  text: () => "কিছুই পাঠানো হয়নি। ছবি ছাড়া মেসেজ পাঠান, বা ড্যাশবোর্ডে ছবি আপলোড করুন।"
325
410
  },
411
+ "selections-refused": {
412
+ title: "যা বেছেছেন তা এখানে পাঠানো যাচ্ছে না",
413
+ text: () => "কিছুই পাঠানো হয়নি। পাঠাতে নতুন কথোপকথন শুরু করুন, বা সেটি সরিয়ে শুধু লেখা পাঠান।"
414
+ },
326
415
  failed: {
327
416
  title: "কিছু একটা ভুল হয়েছে",
328
417
  text: () => "আবার চেষ্টা করুন।"
@@ -330,105 +419,113 @@ var v = {
330
419
  },
331
420
  noConversations: "এখনো কোনো কথোপকথন নেই।",
332
421
  loading: "লোড হচ্ছে…"
333
- }, b = "০১২৩৪৫৬৭৮৯";
334
- function x(e) {
335
- return String(e).replace(/\d/g, (e) => b[Number(e)]);
422
+ }, x = "০১২৩৪৫৬৭৮৯";
423
+ function S(e) {
424
+ return String(e).replace(/\d/g, (e) => x[Number(e)]);
336
425
  }
337
- function S(e, t = {}) {
338
- let n = (e ?? "").toLowerCase().startsWith("bn") ? y : v;
426
+ function C(e, t = {}) {
427
+ let n = (e ?? "").toLowerCase().startsWith("bn") ? b : y;
339
428
  return {
340
429
  ...n,
341
430
  ...t,
342
431
  problems: {
343
432
  ...n.problems,
344
433
  ...t.problems ?? {}
434
+ },
435
+ full: {
436
+ ...n.full,
437
+ ...t.full ?? {}
438
+ },
439
+ many: {
440
+ ...n.many,
441
+ ...t.many ?? {}
345
442
  }
346
443
  };
347
444
  }
348
445
  // src/ui/markdown.ts
349
- var C = /^(https?:|mailto:)/i;
350
- function w(e) {
351
- let t = e.trim();
352
- return C.test(t) ? t : null;
353
- }
446
+ var w = /^(https?:|mailto:)/i;
354
447
  function T(e) {
355
- return (e ?? []).map((e) => E(e));
448
+ let t = e.trim();
449
+ return w.test(t) ? t : null;
356
450
  }
357
451
  function E(e) {
452
+ return (e ?? []).map((e) => D(e));
453
+ }
454
+ function D(e) {
358
455
  switch (e.type) {
359
- case "strong": return i`<strong>${T(e.tokens)}</strong>`;
360
- case "em": return i`<em>${T(e.tokens)}</em>`;
361
- case "del": return i`<del>${T(e.tokens)}</del>`;
362
- case "codespan": return i`<code>${e.text}</code>`;
363
- case "br": return i`<br />`;
456
+ case "strong": return a`<strong>${E(e.tokens)}</strong>`;
457
+ case "em": return a`<em>${E(e.tokens)}</em>`;
458
+ case "del": return a`<del>${E(e.tokens)}</del>`;
459
+ case "codespan": return a`<code>${e.text}</code>`;
460
+ case "br": return a`<br />`;
364
461
  case "link": {
365
- let t = e, n = w(t.href);
366
- return n ? i`<a href=${n} target="_blank" rel="noopener noreferrer nofollow">${T(t.tokens)}</a>` : i`${T(t.tokens)}`;
462
+ let t = e, n = T(t.href);
463
+ return n ? a`<a href=${n} target="_blank" rel="noopener noreferrer nofollow">${E(t.tokens)}</a>` : a`${E(t.tokens)}`;
367
464
  }
368
465
  case "image": return e.text || "";
369
466
  case "text": {
370
467
  let t = e;
371
- return t.tokens ? i`${T(t.tokens)}` : D(t.text);
468
+ return t.tokens ? a`${E(t.tokens)}` : O(t.text);
372
469
  }
373
470
  case "escape": return e.text;
374
471
  case "html": return e.raw;
375
472
  default: return "raw" in e ? String(e.raw) : "";
376
473
  }
377
474
  }
378
- function D(e) {
475
+ function O(e) {
379
476
  return e.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&#39;/g, "'").replace(/&amp;/g, "&");
380
477
  }
381
- function O(e) {
478
+ function k(e) {
382
479
  switch (e.type) {
383
- case "paragraph": return i`<p>${T(e.tokens)}</p>`;
384
- case "heading": return i`<p class="heading">${T(e.tokens)}</p>`;
480
+ case "paragraph": return a`<p>${E(e.tokens)}</p>`;
481
+ case "heading": return a`<p class="heading">${E(e.tokens)}</p>`;
385
482
  case "list": {
386
- let t = e, n = t.items.map((e) => i`<li>${e.tokens.map(k)}</li>`);
387
- return t.ordered ? i`<ol start=${typeof t.start == "number" ? t.start : 1}>${n}</ol>` : i`<ul>${n}</ul>`;
483
+ let t = e, n = t.items.map((e) => a`<li>${e.tokens.map(A)}</li>`);
484
+ return t.ordered ? a`<ol start=${typeof t.start == "number" ? t.start : 1}>${n}</ol>` : a`<ul>${n}</ul>`;
388
485
  }
389
486
  case "table": {
390
487
  let t = e;
391
- return i`<div class="table-wrap">
488
+ return a`<div class="table-wrap">
392
489
  <table>
393
490
  <thead>
394
491
  <tr>
395
- ${t.header.map((e) => i`<th>${T(e.tokens)}</th>`)}
492
+ ${t.header.map((e) => a`<th>${E(e.tokens)}</th>`)}
396
493
  </tr>
397
494
  </thead>
398
495
  <tbody>
399
- ${t.rows.map((e) => i`<tr>${e.map((e) => i`<td>${T(e.tokens)}</td>`)}</tr>`)}
496
+ ${t.rows.map((e) => a`<tr>${e.map((e) => a`<td>${E(e.tokens)}</td>`)}</tr>`)}
400
497
  </tbody>
401
498
  </table>
402
499
  </div>`;
403
500
  }
404
- case "code": return i`<pre><code>${e.text}</code></pre>`;
405
- case "blockquote": return i`<blockquote>${e.tokens.map(O)}</blockquote>`;
406
- case "hr": return i`<hr />`;
407
- case "html": return i`<p>${e.raw}</p>`;
501
+ case "code": return a`<pre><code>${e.text}</code></pre>`;
502
+ case "blockquote": return a`<blockquote>${e.tokens.map(k)}</blockquote>`;
503
+ case "hr": return a`<hr />`;
504
+ case "html": return a`<p>${e.raw}</p>`;
408
505
  case "text": {
409
506
  let t = e;
410
- return i`<p>${t.tokens ? T(t.tokens) : D(t.text)}</p>`;
507
+ return a`<p>${t.tokens ? E(t.tokens) : O(t.text)}</p>`;
411
508
  }
412
- case "space": return a;
413
- default: return "raw" in e ? i`<p>${String(e.raw)}</p>` : a;
509
+ case "space": return o;
510
+ default: return "raw" in e ? a`<p>${String(e.raw)}</p>` : o;
414
511
  }
415
512
  }
416
- function k(e) {
513
+ function A(e) {
417
514
  if (e.type === "text") {
418
515
  let t = e;
419
- return t.tokens ? i`${T(t.tokens)}` : D(t.text);
516
+ return t.tokens ? a`${E(t.tokens)}` : O(t.text);
420
517
  }
421
- return O(e);
518
+ return k(e);
422
519
  }
423
- function A(e) {
424
- let t = l.lex(e, {
520
+ function j(e) {
521
+ let t = u.lex(e, {
425
522
  gfm: !0,
426
523
  breaks: !0
427
524
  });
428
- return i`${t.map(O)}`;
525
+ return a`${t.map(k)}`;
429
526
  }
430
527
  // src/ui/styles.ts
431
- var j = r`
528
+ var M = i`
432
529
  :host {
433
530
  --_accent: var(--ghuri-accent, #8e1b2b);
434
531
  --_accent-text: var(--ghuri-accent-text, #ffffff);
@@ -451,6 +548,9 @@ var j = r`
451
548
  pale mint in a dark dashboard that maps --ghuri-text but not these. */
452
549
  --_allowed: var(--ghuri-allowed, var(--_success));
453
550
  --_allowed-soft: var(--ghuri-allowed-soft, color-mix(in srgb, var(--_allowed) 12%, var(--_surface)));
551
+ --_select: var(--ghuri-select, #1d4ed8);
552
+ --_select-soft: var(--ghuri-select-soft, #eff6ff);
553
+ --_select-border: var(--ghuri-select-border, #93c5fd);
454
554
  --_radius: var(--ghuri-radius, 12px);
455
555
  --_radius-sm: var(--ghuri-radius-sm, 8px);
456
556
  --_bubble-radius: var(--ghuri-bubble-radius, 14px);
@@ -779,6 +879,190 @@ var j = r`
779
879
  color: var(--_warning);
780
880
  }
781
881
 
882
+ /* --- many changes of one tool (docs/many-changes.md) --- */
883
+ .group {
884
+ border-top: 1px solid var(--_border);
885
+ }
886
+ .group-head {
887
+ display: flex;
888
+ align-items: center;
889
+ gap: 8px;
890
+ padding: 8px 14px;
891
+ background: var(--_background);
892
+ border-bottom: 1px solid var(--_border);
893
+ cursor: pointer;
894
+ }
895
+ .group-head input,
896
+ .line-row input {
897
+ margin: 0;
898
+ flex: none;
899
+ accent-color: var(--_accent);
900
+ width: 15px;
901
+ height: 15px;
902
+ }
903
+ .group-name {
904
+ flex: 1;
905
+ min-width: 0;
906
+ font-size: 12px;
907
+ font-weight: 600;
908
+ }
909
+ .group-count {
910
+ font-size: 11px;
911
+ color: var(--_muted);
912
+ white-space: nowrap;
913
+ }
914
+ .line {
915
+ padding: 6px 14px;
916
+ }
917
+ .line-row {
918
+ display: flex;
919
+ align-items: center;
920
+ gap: 8px;
921
+ font-size: 12px;
922
+ }
923
+ .line-text {
924
+ flex: 1;
925
+ min-width: 0;
926
+ overflow-wrap: anywhere;
927
+ }
928
+ /* Exact values standing in for a description: one line, the full values one click away. */
929
+ .line-text.exact {
930
+ white-space: nowrap;
931
+ overflow: hidden;
932
+ text-overflow: ellipsis;
933
+ }
934
+ .line-value {
935
+ flex: none;
936
+ max-width: 45%;
937
+ color: var(--_muted);
938
+ text-align: right;
939
+ overflow-wrap: anywhere;
940
+ }
941
+ .line.off .line-text,
942
+ .line.off .line-value {
943
+ color: var(--_muted);
944
+ opacity: 0.75;
945
+ }
946
+ .chev {
947
+ flex: none;
948
+ display: inline-flex;
949
+ padding: 2px;
950
+ border: 0;
951
+ background: none;
952
+ color: var(--_muted);
953
+ cursor: pointer;
954
+ border-radius: 4px;
955
+ }
956
+ .chev:hover {
957
+ background: var(--_muted-surface);
958
+ }
959
+ .line-details {
960
+ margin: 6px 0 2px 23px;
961
+ padding: 6px 10px;
962
+ border-radius: 6px;
963
+ background: var(--_background);
964
+ }
965
+ .line-details .exact-head {
966
+ padding: 0;
967
+ }
968
+ .line-details .rows {
969
+ padding: 2px 0 0;
970
+ }
971
+ .link.group-more {
972
+ display: block;
973
+ width: 100%;
974
+ padding: 7px 14px;
975
+ border-top: 1px solid var(--_muted-surface);
976
+ text-align: left;
977
+ font-size: 12px;
978
+ font-weight: 500;
979
+ color: var(--_accent);
980
+ }
981
+ .fold {
982
+ border: 1px solid var(--_border);
983
+ border-radius: var(--_radius-sm);
984
+ background: var(--_background);
985
+ font-size: 13px;
986
+ }
987
+ .fold-head {
988
+ display: flex;
989
+ align-items: center;
990
+ gap: 8px;
991
+ width: 100%;
992
+ padding: 8px 12px;
993
+ border: 0;
994
+ background: none;
995
+ color: inherit;
996
+ font: inherit;
997
+ text-align: left;
998
+ cursor: pointer;
999
+ }
1000
+ .fold-head .what {
1001
+ flex: 1;
1002
+ min-width: 0;
1003
+ display: flex;
1004
+ align-items: center;
1005
+ gap: 8px;
1006
+ font-weight: 500;
1007
+ }
1008
+ .fold-head .done {
1009
+ color: var(--_success);
1010
+ }
1011
+ .fold-head .error {
1012
+ color: var(--_warning);
1013
+ }
1014
+ .fold-head .denied {
1015
+ color: var(--_muted);
1016
+ }
1017
+ .fold-count {
1018
+ font-size: 12px;
1019
+ color: var(--_muted);
1020
+ white-space: nowrap;
1021
+ }
1022
+ .fold-head > .icon {
1023
+ color: var(--_muted);
1024
+ }
1025
+ .fold-lines {
1026
+ display: flex;
1027
+ flex-direction: column;
1028
+ gap: 6px;
1029
+ padding: 6px 12px 10px;
1030
+ border-top: 1px solid var(--_muted-surface);
1031
+ }
1032
+ .fold-line {
1033
+ display: flex;
1034
+ align-items: center;
1035
+ gap: 8px;
1036
+ font-size: 12px;
1037
+ }
1038
+ .fold-line .ok {
1039
+ color: var(--_success);
1040
+ }
1041
+ .fold-line .off,
1042
+ .fold-line.off {
1043
+ color: var(--_muted);
1044
+ }
1045
+ .fold-text {
1046
+ flex: 1;
1047
+ min-width: 0;
1048
+ overflow-wrap: anywhere;
1049
+ }
1050
+ .fold-value {
1051
+ flex: none;
1052
+ color: var(--_muted);
1053
+ }
1054
+ .fold-problem {
1055
+ display: flex;
1056
+ flex-direction: column;
1057
+ gap: 4px;
1058
+ }
1059
+ .fold-error {
1060
+ padding: 0 12px;
1061
+ font-size: 12px;
1062
+ color: var(--_muted);
1063
+ overflow-wrap: anywhere;
1064
+ }
1065
+
782
1066
  /* --- "Allow for this conversation" --- */
783
1067
  .allow-choice {
784
1068
  display: flex;
@@ -1104,6 +1388,136 @@ var j = r`
1104
1388
  margin-top: 6px;
1105
1389
  }
1106
1390
 
1391
+ .problem.working > .icon {
1392
+ color: var(--_accent);
1393
+ }
1394
+
1395
+ /* --- a full conversation continued in a new one (docs/full-conversation.md) --- */
1396
+ .continued {
1397
+ display: flex;
1398
+ flex-direction: column;
1399
+ gap: 12px;
1400
+ }
1401
+ .continued-from {
1402
+ display: flex;
1403
+ align-items: center;
1404
+ gap: 8px;
1405
+ width: 100%;
1406
+ padding: 0;
1407
+ border: 0;
1408
+ background: none;
1409
+ color: var(--_muted);
1410
+ font: inherit;
1411
+ font-size: 12px;
1412
+ cursor: pointer;
1413
+ }
1414
+ .continued-from::before,
1415
+ .continued-from::after {
1416
+ content: '';
1417
+ flex: 1;
1418
+ height: 1px;
1419
+ background: var(--_border);
1420
+ }
1421
+ .continued-from:hover span {
1422
+ text-decoration: underline;
1423
+ }
1424
+ .carried {
1425
+ display: flex;
1426
+ flex-direction: column;
1427
+ gap: 8px;
1428
+ padding: 12px;
1429
+ border: 1px solid var(--_border);
1430
+ border-radius: 10px;
1431
+ background: var(--_background);
1432
+ }
1433
+ .carried-head {
1434
+ display: flex;
1435
+ align-items: center;
1436
+ justify-content: space-between;
1437
+ padding: 0;
1438
+ border: 0;
1439
+ background: none;
1440
+ color: var(--_muted);
1441
+ font: inherit;
1442
+ cursor: pointer;
1443
+ }
1444
+ .carried-head .name {
1445
+ display: flex;
1446
+ align-items: center;
1447
+ gap: 6px;
1448
+ color: var(--_text);
1449
+ font-size: 13px;
1450
+ font-weight: 600;
1451
+ }
1452
+ .carried-text {
1453
+ display: flex;
1454
+ flex-direction: column;
1455
+ overflow-wrap: anywhere;
1456
+ font-size: 12px;
1457
+ line-height: 18px;
1458
+ }
1459
+ .carried-heading,
1460
+ .carried-line {
1461
+ white-space: pre-wrap;
1462
+ }
1463
+ .carried-heading {
1464
+ margin-top: 6px;
1465
+ font-weight: 600;
1466
+ color: var(--_text);
1467
+ }
1468
+ .carried-heading:first-child {
1469
+ margin-top: 0;
1470
+ }
1471
+ .carried-line {
1472
+ color: var(--_text-soft, var(--_text));
1473
+ }
1474
+ .carried-note {
1475
+ color: var(--_muted);
1476
+ font-size: 11px;
1477
+ line-height: 16px;
1478
+ }
1479
+ .carry-on-row {
1480
+ display: flex;
1481
+ }
1482
+ .carry-on {
1483
+ display: inline-flex;
1484
+ align-items: center;
1485
+ gap: 6px;
1486
+ padding: 7px 12px;
1487
+ border: 1px solid var(--_accent-border);
1488
+ border-radius: var(--_radius-sm);
1489
+ background: var(--_accent-soft);
1490
+ color: var(--_accent-soft-text);
1491
+ font: inherit;
1492
+ font-size: 13px;
1493
+ font-weight: 500;
1494
+ cursor: pointer;
1495
+ }
1496
+ .continued-in {
1497
+ display: flex;
1498
+ align-items: center;
1499
+ gap: 8px;
1500
+ margin: 0 12px 12px;
1501
+ padding: 12px;
1502
+ border: 1px solid var(--_border);
1503
+ border-radius: var(--_radius-sm);
1504
+ background: var(--_background);
1505
+ color: var(--_muted);
1506
+ }
1507
+ .continued-in .text {
1508
+ flex: 1;
1509
+ color: var(--_text);
1510
+ }
1511
+ .continued-in .link {
1512
+ padding: 0;
1513
+ border: 0;
1514
+ background: none;
1515
+ color: var(--_accent);
1516
+ font: inherit;
1517
+ font-weight: 500;
1518
+ cursor: pointer;
1519
+ }
1520
+
1107
1521
  /* --- composer --- */
1108
1522
  .composer {
1109
1523
  padding: 12px;
@@ -1188,6 +1602,90 @@ var j = r`
1188
1602
  gap: 8px;
1189
1603
  margin-bottom: 6px;
1190
1604
  }
1605
+ .selections {
1606
+ display: flex;
1607
+ flex-wrap: wrap;
1608
+ gap: 6px;
1609
+ margin-bottom: 6px;
1610
+ }
1611
+ .user-selections {
1612
+ align-self: flex-end;
1613
+ justify-content: flex-end;
1614
+ max-width: 85%;
1615
+ margin-bottom: -6px;
1616
+ }
1617
+ .selection {
1618
+ display: inline-flex;
1619
+ align-items: center;
1620
+ gap: 6px;
1621
+ max-width: 100%;
1622
+ min-width: 0;
1623
+ padding: 4px 6px 4px 8px;
1624
+ border: 1px solid var(--_select-border);
1625
+ border-radius: var(--_radius-sm);
1626
+ background: var(--_select-soft);
1627
+ color: var(--_text);
1628
+ font-size: 12px;
1629
+ font-weight: 600;
1630
+ }
1631
+ .selection > svg {
1632
+ flex: none;
1633
+ color: var(--_select);
1634
+ }
1635
+ .selection .label {
1636
+ min-width: 0;
1637
+ overflow: hidden;
1638
+ white-space: nowrap;
1639
+ text-overflow: ellipsis;
1640
+ }
1641
+ .selection button {
1642
+ display: grid;
1643
+ place-items: center;
1644
+ flex: none;
1645
+ width: 18px;
1646
+ height: 18px;
1647
+ padding: 0;
1648
+ border: 0;
1649
+ border-radius: 4px;
1650
+ background: transparent;
1651
+ color: var(--_muted);
1652
+ cursor: pointer;
1653
+ }
1654
+ .selection button:hover {
1655
+ background: color-mix(in srgb, var(--_select) 12%, transparent);
1656
+ color: var(--_text);
1657
+ }
1658
+ .selections[data-blocked] .selection {
1659
+ border-color: var(--_border);
1660
+ background: var(--_muted-surface);
1661
+ opacity: 0.75;
1662
+ }
1663
+ .selections[data-blocked] .selection > svg {
1664
+ color: var(--_muted);
1665
+ }
1666
+ .selections-blocked {
1667
+ display: flex;
1668
+ align-items: flex-start;
1669
+ gap: 8px;
1670
+ margin: 0 0 6px;
1671
+ padding: 8px 10px;
1672
+ border-radius: var(--_radius-sm);
1673
+ background: var(--_warning-soft);
1674
+ color: var(--_warning);
1675
+ font-size: 12px;
1676
+ }
1677
+ .selections-blocked button {
1678
+ flex: none;
1679
+ margin-left: auto;
1680
+ padding: 0;
1681
+ border: 0;
1682
+ background: none;
1683
+ color: inherit;
1684
+ font: inherit;
1685
+ font-weight: 600;
1686
+ text-decoration: underline;
1687
+ cursor: pointer;
1688
+ }
1191
1689
  .chip {
1192
1690
  position: relative;
1193
1691
  display: grid;
@@ -1461,8 +1959,23 @@ var j = r`
1461
1959
  text-overflow: ellipsis;
1462
1960
  }
1463
1961
  .conversation .when {
1962
+ display: flex;
1963
+ align-items: center;
1964
+ gap: 4px;
1464
1965
  font-size: 11px;
1465
1966
  color: var(--_muted);
1967
+ white-space: nowrap;
1968
+ }
1969
+ .conversation .mark {
1970
+ display: inline-flex;
1971
+ align-items: center;
1972
+ gap: 4px;
1973
+ }
1974
+ .conversation .mark-continued {
1975
+ color: var(--_accent);
1976
+ }
1977
+ .conversation .sep {
1978
+ opacity: 0.6;
1466
1979
  }
1467
1980
  .panel-history {
1468
1981
  padding: 0 8px 12px;
@@ -1499,8 +2012,8 @@ var j = r`
1499
2012
  font-weight: 500;
1500
2013
  min-height: 48px;
1501
2014
  }
1502
- `, M = "result was not recorded", N = class extends n {
1503
- static styles = j;
2015
+ `, N = "result was not recorded", P = 3, F = 6, I = 3, L = class extends r {
2016
+ static styles = M;
1504
2017
  static properties = {
1505
2018
  layout: {
1506
2019
  type: String,
@@ -1520,7 +2033,8 @@ var j = r`
1520
2033
  expanded: { state: !0 },
1521
2034
  unticked: { state: !0 },
1522
2035
  dragging: { state: !0 },
1523
- enlarged: { state: !0 }
2036
+ enlarged: { state: !0 },
2037
+ carriedClosed: { state: !0 }
1524
2038
  };
1525
2039
  chat = null;
1526
2040
  options = null;
@@ -1533,18 +2047,20 @@ var j = r`
1533
2047
  };
1534
2048
  guarding = !1;
1535
2049
  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;
2050
+ 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
2051
  }
1538
- configure(t) {
1539
- 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);
1540
- let n = new e(t);
2052
+ configure(e) {
2053
+ this.detach(), this.options = e, e.layout && (this.layout = e.layout), e.title !== void 0 && (this.heading = e.title), e.subtitle !== void 0 && (this.subtitle = e.subtitle), e.locale && (this.locale = e.locale);
2054
+ let n = new t(e);
1541
2055
  this.chat = n, this.state = n.getState(), this.unsubscribe = [n.subscribe((e) => {
1542
2056
  this.state = e, this.guardUnload(e.status === "sending" || e.status === "streaming");
1543
2057
  }), ...[
1544
2058
  "tool-result",
1545
2059
  "approval-pending",
1546
2060
  "turn-end",
1547
- "attachment-error"
2061
+ "attachment-error",
2062
+ "selection-removed",
2063
+ "selection-sent"
1548
2064
  ].map((e) => n.on(e, (t) => this.fire(e, t)))], this.layout === "page" && this.loadConversations(), (this.open || this.layout === "page") && n.loadCapabilities();
1549
2065
  }
1550
2066
  setOptions(e) {
@@ -1572,11 +2088,26 @@ var j = r`
1572
2088
  async ask(e, t = {}) {
1573
2089
  this.show(), this.view = "chat", t.send === !1 ? (this.draft = e, await this.updateComplete, this.focusInput()) : await this.chat?.send(e);
1574
2090
  }
2091
+ addSelection(e) {
2092
+ return this.chat?.addSelection(e) ?? null;
2093
+ }
2094
+ removeSelection(e) {
2095
+ this.chat?.removeSelection(e);
2096
+ }
2097
+ clearSelections() {
2098
+ this.chat?.clearSelections();
2099
+ }
2100
+ get selections() {
2101
+ return this.state?.selections ?? [];
2102
+ }
1575
2103
  newConversation() {
1576
2104
  this.chat?.newConversation(), this.view = "chat", this.expanded = /* @__PURE__ */ new Set(), this.unticked = /* @__PURE__ */ new Set(), this.updateComplete.then(() => this.focusInput());
1577
2105
  }
1578
2106
  async openConversation(e) {
1579
- this.view = "chat", await this.chat?.openConversation(e);
2107
+ this.view = "chat", this.carriedClosed = !1, await this.chat?.openConversation(e);
2108
+ }
2109
+ async continueConversation() {
2110
+ this.carriedClosed = !1, await this.chat?.continueConversation(), this.layout === "page" && this.loadConversations();
1580
2111
  }
1581
2112
  async end() {
1582
2113
  await this.chat?.end(), this.conversations = null;
@@ -1591,7 +2122,7 @@ var j = r`
1591
2122
  this.unsubscribe = [];
1592
2123
  }
1593
2124
  get labels() {
1594
- return S(this.locale || this.options?.locale || document.documentElement.lang || "en", this.options?.labels);
2125
+ return C(this.locale || this.options?.locale || document.documentElement.lang || "en", this.options?.labels);
1595
2126
  }
1596
2127
  fire(e, t) {
1597
2128
  this.dispatchEvent(new CustomEvent(`ghuri:${e}`, {
@@ -1631,11 +2162,14 @@ var j = r`
1631
2162
  if (!this.canSend() || !this.chat || t === "sending" || t === "streaming") return;
1632
2163
  this.draft = "", this.stickToBottom = !0;
1633
2164
  let n = !this.state?.conversationId;
1634
- await this.chat.send(e), this.chat?.getState().problem?.code === "photos-refused" && !this.draft && (this.draft = e), n && this.layout === "page" && this.loadConversations();
2165
+ await this.chat.send(e);
2166
+ let r = this.chat?.getState().problem?.code;
2167
+ r !== "photos-refused" && r !== "selections-refused" && r !== "conversation-full" || this.draft || (this.draft = e), n && this.layout === "page" && this.loadConversations();
1635
2168
  }
1636
2169
  canSend() {
2170
+ if (this.state?.full) return !1;
1637
2171
  let e = this.state?.uploads ?? [];
1638
- 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");
2172
+ return e.some((e) => e.status === "preparing" || e.status === "uploading") || e.some((e) => e.status === "failed" && e.error === "upload") ? !1 : this.state?.selections.length ? !!this.draft.trim() && !!this.state.canSelect : !!this.draft.trim() || e.some((e) => e.status === "ready");
1639
2173
  }
1640
2174
  onKeydown(e) {
1641
2175
  e.key !== "Enter" || e.shiftKey || e.isComposing || e.keyCode === 229 || (e.preventDefault(), this.submit());
@@ -1648,6 +2182,11 @@ var j = r`
1648
2182
  let t = new Set(this.expanded);
1649
2183
  t.has(e) ? t.delete(e) : t.add(e), this.expanded = t;
1650
2184
  }
2185
+ tickAll(e, t) {
2186
+ let n = new Set(this.unticked);
2187
+ for (let r of e) t ? n.delete(r.approvalId) : n.add(r.approvalId);
2188
+ this.unticked = n;
2189
+ }
1651
2190
  tick(e, t) {
1652
2191
  let n = new Set(this.unticked);
1653
2192
  t ? n.delete(e) : n.add(e), this.unticked = n;
@@ -1665,10 +2204,10 @@ var j = r`
1665
2204
  }
1666
2205
  renderAllowChoice(e) {
1667
2206
  let t = e.filter((e) => e.allowable);
1668
- if (!t.length) return a;
2207
+ if (!t.length) return o;
1669
2208
  let n = this.labels, r = [...new Set(t.map((e) => this.toolLabel(e)))];
1670
- return i`<button class="allow-choice" part="button-allow" @click=${() => this.decideAll(!0, !0)}>
1671
- <span class="allow-head">${_("shield-check", 15)} ${n.allowChoice}</span>
2209
+ return a`<button class="allow-choice" part="button-allow" @click=${() => this.decideAll(!0, !0)}>
2210
+ <span class="allow-head">${v("shield-check", 15)} ${n.allowChoice}</span>
1672
2211
  <span class="allow-hint">${n.allowHint(r, t.length < e.length)}</span>
1673
2212
  </button>`;
1674
2213
  }
@@ -1686,7 +2225,7 @@ var j = r`
1686
2225
  slot: r.container.slot,
1687
2226
  ctx: t,
1688
2227
  render: n
1689
- }), i`<slot name=${r.container.slot}></slot>`;
2228
+ }), a`<slot name=${r.container.slot}></slot>`;
1690
2229
  }
1691
2230
  mountCards() {
1692
2231
  for (let [e, t] of this.cards) {
@@ -1703,7 +2242,7 @@ var j = r`
1703
2242
  }
1704
2243
  }
1705
2244
  render() {
1706
- return this.wanted = /* @__PURE__ */ new Map(), this.layout === "page" ? i`<div class="page">
2245
+ return this.wanted = /* @__PURE__ */ new Map(), this.layout === "page" ? a`<div class="page">
1707
2246
  <aside class="sidebar" part="history">${this.renderSidebar()}</aside>
1708
2247
  <section class="main">
1709
2248
  <div class="page-head" part="header">
@@ -1713,14 +2252,14 @@ var j = r`
1713
2252
  ${this.renderScroll()} ${this.renderBottom()}
1714
2253
  </section>
1715
2254
  ${this.renderEnlarged()}
1716
- </div>` : i`${this.renderHeader()}
1717
- ${this.view === "history" ? this.renderPanelHistory() : i`${this.renderScroll()} ${this.renderBottom()}`}
2255
+ </div>` : a`${this.renderHeader()}
2256
+ ${this.view === "history" ? this.renderPanelHistory() : a`${this.renderScroll()} ${this.renderBottom()}`}
1718
2257
  ${this.renderEnlarged()}`;
1719
2258
  }
1720
2259
  renderEnlarged() {
1721
- if (!this.enlarged) return a;
2260
+ if (!this.enlarged) return o;
1722
2261
  let e = this.labels;
1723
- return i`<div
2262
+ return a`<div
1724
2263
  class="lightbox"
1725
2264
  part="lightbox"
1726
2265
  role="dialog"
@@ -1733,7 +2272,7 @@ var j = r`
1733
2272
  >
1734
2273
  <img src=${this.enlarged} alt=${e.picture} @click=${(e) => e.stopPropagation()} />
1735
2274
  <button class="lightbox-close" aria-label=${e.close} @click=${() => this.enlarged = null}>
1736
- ${_("x", 16)}
2275
+ ${v("x", 16)}
1737
2276
  </button>
1738
2277
  </div>`;
1739
2278
  }
@@ -1743,49 +2282,65 @@ var j = r`
1743
2282
  }
1744
2283
  renderHeader() {
1745
2284
  let e = this.labels;
1746
- return i`<header class="header" part="header">
2285
+ return a`<header class="header" part="header">
1747
2286
  <div class="brand">
1748
- <span class="avatar">${h(20)}</span>
2287
+ <span class="avatar">${g(20)}</span>
1749
2288
  <span class="names">
1750
2289
  <span class="title" part="title">${this.heading || "Ghuri AI"}</span>
1751
- ${this.subtitle ? i`<span class="subtitle">${this.subtitle}</span>` : a}
2290
+ ${this.subtitle ? a`<span class="subtitle">${this.subtitle}</span>` : o}
1752
2291
  </span>
1753
2292
  </div>
1754
2293
  <div class="tools">
1755
- <button class="icon-button" title=${e.history} aria-label=${e.history} @click=${() => this.showHistory()}>
1756
- ${_("history")}
2294
+ <button
2295
+ class="icon-button"
2296
+ title=${e.history}
2297
+ aria-label=${e.history}
2298
+ ?disabled=${!!this.state?.continuing}
2299
+ @click=${() => this.showHistory()}
2300
+ >
2301
+ ${v("history")}
1757
2302
  </button>
1758
- <button class="icon-button" title=${e.newChat} aria-label=${e.newChat} @click=${() => this.newConversation()}>
1759
- ${_("square-pen")}
2303
+ <button
2304
+ class="icon-button"
2305
+ title=${e.newChat}
2306
+ aria-label=${e.newChat}
2307
+ ?disabled=${!!this.state?.continuing}
2308
+ @click=${() => this.newConversation()}
2309
+ >
2310
+ ${v("square-pen")}
1760
2311
  </button>
1761
2312
  <button class="icon-button" title=${e.close} aria-label=${e.close} @click=${() => this.hide()}>
1762
- ${_("x")}
2313
+ ${v("x")}
1763
2314
  </button>
1764
2315
  </div>
1765
2316
  </header>`;
1766
2317
  }
1767
2318
  renderConversationList() {
1768
2319
  let e = this.labels;
1769
- if (this.conversations === null) return i`<div class="muted">${e.loading}</div>`;
1770
- if (!this.conversations.length) return i`<div class="muted">${e.noConversations}</div>`;
2320
+ if (this.conversations === null) return a`<div class="muted">${e.loading}</div>`;
2321
+ if (!this.conversations.length) return a`<div class="muted">${e.noConversations}</div>`;
1771
2322
  let t = new Intl.DateTimeFormat(this.locale || void 0, {
1772
2323
  dateStyle: "medium",
1773
2324
  timeStyle: "short"
1774
2325
  });
1775
- return i`<nav class="history" aria-label=${e.conversations}>
1776
- ${this.conversations.map((e) => i`<button
2326
+ return a`<nav class="history" aria-label=${e.conversations}>
2327
+ ${this.conversations.map((e) => a`<button
1777
2328
  class="conversation"
1778
2329
  aria-current=${e.id === this.state?.conversationId ? "true" : "false"}
1779
2330
  @click=${() => this.openConversation(e.id)}
1780
2331
  >
1781
2332
  <span class="name">${e.title || "—"}</span>
1782
- <span class="when">${t.format(new Date(e.updatedAt))}</span>
2333
+ <span class="when">${this.renderListMark(e)}${t.format(new Date(e.updatedAt))}</span>
1783
2334
  </button>`)}
1784
2335
  </nav>`;
1785
2336
  }
2337
+ renderListMark(e) {
2338
+ let t = this.labels.many;
2339
+ return e.continuedIn ? a`<span class="mark mark-full">${v("archive", 12)}${t.fullContinued}</span><span class="sep">·</span>` : e.continuedFrom ? a`<span class="mark mark-continued">${v("corner-down-right", 12)}${t.continued}</span><span class="sep">·</span>` : o;
2340
+ }
1786
2341
  renderPanelHistory() {
1787
2342
  let e = this.labels;
1788
- return i`<div class="scroll">
2343
+ return a`<div class="scroll">
1789
2344
  <div class="history-head">
1790
2345
  <span>${e.conversations}</span>
1791
2346
  <button class="btn primary" @click=${() => this.newConversation()}>${e.newChat}</button>
@@ -1795,73 +2350,139 @@ var j = r`
1795
2350
  }
1796
2351
  renderSidebar() {
1797
2352
  let e = this.labels;
1798
- return i`<div class="side-brand">${h(24)}<span>${this.heading || "Ghuri AI"}</span></div>
1799
- <button class="new-chat" @click=${() => this.newConversation()}>${_("square-pen", 15)} ${e.newChat}</button>
2353
+ return a`<div class="side-brand">${g(24)}<span>${this.heading || "Ghuri AI"}</span></div>
2354
+ <button class="new-chat" @click=${() => this.newConversation()}>${v("square-pen", 15)} ${e.newChat}</button>
1800
2355
  ${this.renderConversationList()}`;
1801
2356
  }
1802
2357
  renderScroll() {
1803
- let e = this.state, t = e?.messages ?? [], n = e?.status === "loading" ? i`<div class="muted">${this.labels.loading}</div>` : t.length ? i`${t.map((e, n) => this.renderMessage(e, n === t.length - 1))}
1804
- ${this.renderPending()}` : this.renderEmpty();
1805
- return i`<div class="scroll">
1806
- <div class="messages column" role="log" aria-live="polite" aria-busy=${e?.status === "streaming"}>${n}</div>
2358
+ 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))}
2359
+ ${this.renderPending()}` : e?.continuedFrom ? n : this.renderEmpty();
2360
+ return a`<div class="scroll">
2361
+ <div class="messages column" role="log" aria-live="polite" aria-busy=${e?.status === "streaming"}>${r}</div>
2362
+ </div>`;
2363
+ }
2364
+ renderContinued() {
2365
+ let t = this.labels.full, n = this.state, r = n.continuedFrom, i = n.handover ? e(n.handover) : {
2366
+ summary: !1,
2367
+ lines: []
2368
+ }, s = i.lines, c = !this.carriedClosed, l = !n.messages.length && n.status === "idle";
2369
+ return a`<div class="continued" part="continued">
2370
+ <button class="continued-from" @click=${() => this.openConversation(r.id)}>
2371
+ ${v("corner-down-right", 13)}<span>${t.continuedFrom(r.title)} ↗</span>
2372
+ </button>
2373
+ ${s.length ? a`<div class="carried" part="carried-over">
2374
+ <button class="carried-head" aria-expanded=${c ? "true" : "false"} @click=${() => {
2375
+ this.carriedClosed = c;
2376
+ }}>
2377
+ <span class="name">${v("package-open", 14)}${t.carriedOver}</span>
2378
+ ${v(c ? "chevron-up" : "chevron-down", 14)}
2379
+ </button>
2380
+ ${c ? a`<div class="carried-text">
2381
+ ${s.map((e) => a`<div class=${e.heading ? "carried-heading" : "carried-line"}>${e.text}</div>`)}
2382
+ </div>
2383
+ <div class="carried-note">${i.summary ? t.carriedNote : t.carriedNoteRecord}</div>` : o}
2384
+ </div>` : o}
2385
+ ${l ? a`<div class="carry-on-row">
2386
+ <button class="carry-on" part="carry-on" @click=${() => this.chat?.send(t.carryOnMessage)}>
2387
+ ${v("play", 13)}${t.carryOn}
2388
+ </button>
2389
+ </div>` : o}
1807
2390
  </div>`;
1808
2391
  }
1809
2392
  renderEmpty() {
1810
2393
  let e = this.labels, t = this.options?.starters ?? [];
1811
- return i`<div class="empty" part="empty">
1812
- <span class="avatar">${h(24)}</span>
2394
+ return a`<div class="empty" part="empty">
2395
+ <span class="avatar">${g(24)}</span>
1813
2396
  <span class="heading">${e.emptyTitle}</span>
1814
- ${t.length ? i`<div class="starters">
1815
- ${t.map((e) => i`<button class="starter" part="starter" @click=${() => this.chat?.send(e)}>${e}</button>`)}
1816
- </div>` : a}
2397
+ ${t.length ? a`<div class="starters">
2398
+ ${t.map((e) => a`<button class="starter" part="starter" @click=${() => this.chat?.send(e)}>${e}</button>`)}
2399
+ </div>` : o}
1817
2400
  </div>`;
1818
2401
  }
1819
2402
  renderMessage(e, t) {
1820
2403
  if (e.role === "user") {
1821
- let t = e.parts.map((e) => e.kind === "text" ? e.text : "").join(""), n = e.parts.flatMap((e) => e.kind === "attachments" ? e.attachments : []);
1822
- return i`${n.length ? i`<div class="photos" part="message-photos">${n.map((e) => this.renderPhoto(e))}</div>` : a}${t ? i`<div class="user" part="user-bubble">${t}</div>` : a}`;
2404
+ let t = e.parts.map((e) => e.kind === "text" ? e.text : "").join(""), n = e.parts.flatMap((e) => e.kind === "attachments" ? e.attachments : []), r = e.parts.flatMap((e) => e.kind === "selections" ? e.selections : []);
2405
+ return a`${r.length ? a`<div class="selections user-selections" part="message-selections">
2406
+ ${r.map((e) => this.renderSelection(e))}
2407
+ </div>` : o}${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
2408
  }
1824
- let n = t && this.state?.status === "streaming", r = e.parts.map((t, r) => {
1825
- if (t.kind === "text") {
1826
- if (!t.text) return a;
1827
- let o = n && r === e.parts.length - 1;
1828
- return i`<div class="md" part="assistant">${A(t.text)}${o ? i`<span class="caret"></span>` : a}</div>`;
2409
+ let n = t && this.state?.status === "streaming", r = [];
2410
+ for (let t = 0; t < e.parts.length; t++) {
2411
+ let i = e.parts[t];
2412
+ if (i.kind === "text") {
2413
+ if (!i.text) continue;
2414
+ let s = n && t === e.parts.length - 1;
2415
+ r.push(a`<div class="md" part="assistant">${j(i.text)}${s ? a`<span class="caret"></span>` : o}</div>`);
2416
+ continue;
1829
2417
  }
1830
- return t.kind === "tool" ? this.renderTool(t) : a;
1831
- }), o = n && !e.parts.length, s = i`<div class="assistant">
2418
+ if (i.kind !== "tool") continue;
2419
+ let s = z(e.parts, t);
2420
+ s.length >= I ? (r.push(this.renderFold(s)), t += s.length - 1) : r.push(this.renderTool(i));
2421
+ }
2422
+ let i = n && !e.parts.length, s = a`<div class="assistant">
1832
2423
  ${r}
1833
- ${o ? i`<span class="step" part="tool-step">${_("loader", 13)}<span>${this.labels.running}</span></span>` : a}
2424
+ ${i ? a`<span class="step" part="tool-step">${v("loader", 13)}<span>${this.labels.running}</span></span>` : o}
1834
2425
  </div>`;
1835
- return this.layout === "page" ? i`<div class="assistant-row"><span class="avatar">${h(18)}</span>${s}</div>` : s;
2426
+ return this.layout === "page" ? a`<div class="assistant-row"><span class="avatar">${g(18)}</span>${s}</div>` : s;
2427
+ }
2428
+ renderSelection(e, t) {
2429
+ let n = [e.source?.file, e.page].filter(Boolean).join(" · ");
2430
+ return a`<span class="selection" part="selection-chip" title=${n || e.label}>
2431
+ ${v("square-mouse-pointer", 14)}<span class="label">${e.label}</span>${t ? a`<button
2432
+ type="button"
2433
+ aria-label=${`${this.labels.removeSelection}: ${e.label}`}
2434
+ title=${this.labels.removeSelection}
2435
+ @click=${() => this.chat?.removeSelection(t)}
2436
+ >
2437
+ ${v("x", 12)}
2438
+ </button>` : o}
2439
+ </span>`;
2440
+ }
2441
+ renderComposerSelections(e) {
2442
+ if (!e.selections.length) return o;
2443
+ let t = this.labels;
2444
+ if (e.full) return a`<div class="selections" part="selection-chips">
2445
+ ${e.selections.map((e) => this.renderSelection(e, e.id))}
2446
+ </div>`;
2447
+ let n = !e.canSelect;
2448
+ return a`${n ? a`<div class="selections-blocked" part="selections-blocked" role="status">
2449
+ ${v("circle-alert", 14)}<span>${t.selectionsNotHere}</span>
2450
+ <button type="button" @click=${() => this.newConversation()}>${t.newConversation}</button>
2451
+ </div>` : o}<div class="selections" part="selection-chips" ?data-blocked=${n}>
2452
+ ${e.selections.map((e) => this.renderSelection(e, e.id))}
2453
+ </div>
2454
+ ${n ? o : a`<div class="chips-note">
2455
+ ${this.draft.trim() ? t.selectionsNote(this.chat?.selectionLimit() ?? 3) : t.selectionsNeedWords}
2456
+ </div>`}`;
1836
2457
  }
1837
2458
  renderPhoto(e) {
1838
- let t = P(e.thumbnailUrl), n = (e.previewUrl?.startsWith("blob:") ? e.previewUrl : void 0) ?? t, r = i`<span class="photo-name">${_("image-off", 14)}<span>${e.name}</span></span>`, o = n ? i`<img
2459
+ let t = V(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
2460
  src=${n}
1840
2461
  alt=${e.name}
1841
2462
  loading="lazy"
1842
2463
  @error=${(e) => e.target.closest(".photo")?.setAttribute("data-broken", "")}
1843
2464
  />${r}` : r;
1844
- return t ? i`<a class="photo" href=${t} target="_blank" rel="noopener noreferrer" title=${e.name}>${o}</a>` : i`<span class="photo" data-broken=${n ? a : ""} title=${e.name}>${o}</span>`;
2465
+ 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
2466
  }
1846
2467
  renderChip(e) {
1847
2468
  let t = this.labels, n = e.status === "preparing" || e.status === "uploading", r = e.status === "failed";
1848
- return i`<div class="chip" part="attachment-chip" data-status=${e.status} title=${e.name}>
1849
- ${e.previewUrl && e.error !== "type" ? i`<img src=${e.previewUrl} alt=${e.name} />` : i`<span class="chip-icon">${_("image-off", 18)}</span>`}
1850
- ${n ? i`<span
2469
+ return a`<div class="chip" part="attachment-chip" data-status=${e.status} title=${e.name}>
2470
+ ${e.previewUrl && e.error !== "type" ? a`<img src=${e.previewUrl} alt=${e.name} />` : a`<span class="chip-icon">${v("image-off", 18)}</span>`}
2471
+ ${n ? a`<span
1851
2472
  class="chip-progress"
1852
2473
  role="progressbar"
1853
2474
  aria-label=${e.name}
1854
2475
  aria-valuemin="0"
1855
2476
  aria-valuemax="100"
1856
2477
  aria-valuenow=${Math.round(e.progress * 100)}
1857
- ><span style=${s({ width: `${Math.max(8, Math.round(e.progress * 100))}%` })}></span
1858
- ></span>` : a}
1859
- ${r && e.error ? i`<span class="chip-error">${t.photoProblem[e.error]}</span>` : a}
1860
- ${r && e.error === "upload" ? i`<button class="chip-retry" aria-label=${t.retryPhoto} title=${t.retryPhoto} @click=${() => this.chat?.retryUpload(e.id)}>
1861
- ${_("refresh-cw", 12)}
1862
- </button>` : a}
2478
+ ><span style=${c({ width: `${Math.max(8, Math.round(e.progress * 100))}%` })}></span
2479
+ ></span>` : o}
2480
+ ${r && e.error ? a`<span class="chip-error">${t.photoProblem[e.error]}</span>` : o}
2481
+ ${r && e.error === "upload" ? a`<button class="chip-retry" aria-label=${t.retryPhoto} title=${t.retryPhoto} @click=${() => this.chat?.retryUpload(e.id)}>
2482
+ ${v("refresh-cw", 12)}
2483
+ </button>` : o}
1863
2484
  <button class="chip-remove" aria-label=${t.removePhoto} title=${t.removePhoto} @click=${() => this.chat?.removeUpload(e.id)}>
1864
- ${_("x", 11)}
2485
+ ${v("x", 11)}
1865
2486
  </button>
1866
2487
  </div>`;
1867
2488
  }
@@ -1886,13 +2507,13 @@ var j = r`
1886
2507
  t.length && (e.preventDefault(), this.chat?.addFiles(t));
1887
2508
  }
1888
2509
  toolLabel(e) {
1889
- return e.title || u(e.toolName);
2510
+ return e.title || d(e.toolName);
1890
2511
  }
1891
2512
  renderTool(e) {
1892
2513
  let t = this.labels;
1893
- if (e.state === "awaiting-approval") return a;
2514
+ if (e.state === "awaiting-approval") return o;
1894
2515
  if (e.approvalId) {
1895
- let [n, r, a] = e.state === "done" ? [
2516
+ let [n, r, i] = e.state === "done" ? [
1896
2517
  "done",
1897
2518
  "circle-check",
1898
2519
  e.granted ? t.confirmedAllowed : t.confirmed
@@ -1903,17 +2524,17 @@ var j = r`
1903
2524
  ] : e.state === "error" ? [
1904
2525
  "error",
1905
2526
  "circle-alert",
1906
- e.errorText?.includes(M) ? t.outcomeUnknown : t.stepFailed
2527
+ e.errorText?.includes(N) ? t.outcomeUnknown : t.stepFailed
1907
2528
  ] : [
1908
2529
  "denied",
1909
2530
  "loader",
1910
2531
  t.running
1911
2532
  ];
1912
- return i`<div class="decided" part="decided" title=${e.state === "error" ? e.errorText ?? "" : ""}>
2533
+ return a`<div class="decided" part="decided" title=${e.state === "error" ? e.errorText ?? "" : ""}>
1913
2534
  <span class="what"
1914
- ><span class=${n}>${_(r, 15)}</span>${this.toolLabel(e)}${e.preview ? ` · ${e.preview.summary}` : ""}</span
2535
+ ><span class=${n}>${v(r, 15)}</span>${this.toolLabel(e)}${e.preview ? ` · ${e.preview.summary}` : ""}</span
1915
2536
  >
1916
- <span class=${n}>${a}</span>
2537
+ <span class=${n}>${i}</span>
1917
2538
  </div>`;
1918
2539
  }
1919
2540
  if (e.allowed) return this.renderAllowed(e);
@@ -1922,73 +2543,104 @@ var j = r`
1922
2543
  part: e,
1923
2544
  client: this.chat
1924
2545
  }, n);
1925
- if (this.options?.toolSteps === "hide") return a;
1926
- let r = e.state === "done" ? m(e.output) : null, o = e.state === "done" ? i`<span class="ok">${_("check", 13)}</span>` : e.state === "error" ? i`<span class="bad">${_("circle-alert", 13)}</span>` : e.state === "denied" ? _("ban", 13) : i`<span class="spin">${_("loader", 13)}</span>`, s = i`<span class="step" part="tool-step" title=${e.state === "error" ? e.errorText ?? "" : ""}>
1927
- ${o}<span>${this.toolLabel(e)}${r === null ? "" : ` · ${t.found(r)}`}</span>
2546
+ if (this.options?.toolSteps === "hide") return o;
2547
+ 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 ?? "" : ""}>
2548
+ ${i}<span>${this.toolLabel(e)}${r === null ? "" : ` · ${t.found(r)}`}</span>
1928
2549
  </span>`;
1929
- return e.state !== "done" || !e.images?.length ? s : i`<div class="step-pictures" part="tool-pictures">
2550
+ return e.state !== "done" || !e.images?.length ? s : a`<div class="step-pictures" part="tool-pictures">
1930
2551
  ${s}
1931
2552
  <div class="pictures">
1932
- ${e.images.map((n, r) => i`<button
2553
+ ${e.images.map((n, r) => a`<button
1933
2554
  class="picture"
1934
2555
  aria-label=${t.showPicture(r + 1, e.images.length)}
1935
- @click=${() => this.enlarged = I(n)}
2556
+ @click=${() => this.enlarged = U(n)}
1936
2557
  >
1937
- <img src=${I(n)} alt=${t.showPicture(r + 1, e.images.length)} />
2558
+ <img src=${U(n)} alt=${t.showPicture(r + 1, e.images.length)} />
1938
2559
  </button>`)}
1939
2560
  </div>
2561
+ </div>`;
2562
+ }
2563
+ renderFold(e) {
2564
+ let t = this.labels, n = `fold:${e[0].toolCallId}`, r = this.expanded.has(n), i = (e) => e.state === "error" && !!e.errorText?.includes(N), s = {
2565
+ done: e.filter((e) => e.state === "done").length,
2566
+ failed: e.filter((e) => e.state === "error" && !i(e)).length,
2567
+ cancelled: e.filter((e) => e.state === "denied").length,
2568
+ unknown: e.filter(i).length,
2569
+ running: e.filter((e) => e.state !== "done" && e.state !== "error" && e.state !== "denied").length
2570
+ }, c = e.filter((e) => e.state === "error"), [l, u] = s.running ? ["denied spin", "loader"] : c.length ? ["error", "circle-alert"] : s.done ? ["done", "circle-check"] : ["denied", "circle-x"];
2571
+ return a`<div class="fold" part="decided-group">
2572
+ <button class="fold-head" aria-expanded=${r ? "true" : "false"} @click=${() => this.toggleRows(n)}>
2573
+ <span class="what"><span class=${l}>${v(u, 15)}</span>${this.toolLabel(e[0])}</span>
2574
+ <span class="fold-count">${t.many.counts(s)}</span>
2575
+ ${v(r ? "chevron-up" : "chevron-down", 14)}
2576
+ </button>
2577
+ ${r ? a`<div class="fold-lines">
2578
+ ${e.filter((e) => e.state !== "error").map((e) => this.renderFoldLine(e))}
2579
+ </div>` : o}
2580
+ </div>
2581
+ ${c.map((e) => a`<div class="fold-problem">
2582
+ ${this.renderTool(e)}
2583
+ ${e.errorText ? a`<div class="fold-error">${e.errorText}</div>` : o}
2584
+ </div>`)}`;
2585
+ }
2586
+ renderFoldLine(e) {
2587
+ let t = this.labels, n = e.preview?.changes[0], [r, i] = e.state === "done" ? ["ok", "check"] : e.state === "denied" ? ["off", "ban"] : ["off spin", "loader"], o = e.state === "denied" ? t.cancelled : e.state === "done" && n ? `${n.current === void 0 ? "" : `${n.current} → `}${n.next}` : e.state === "done" ? t.confirmed : t.running;
2588
+ return a`<div class="fold-line ${e.state === "denied" ? "off" : ""}">
2589
+ <span class=${r}>${v(i, 12)}</span>
2590
+ <span class="fold-text">${e.preview?.summary ?? B(e.input)}</span>
2591
+ <span class="fold-value">${o}</span>
1940
2592
  </div>`;
1941
2593
  }
1942
2594
  renderAllowed(e) {
1943
- let t = this.labels, n = this.state?.allowances.find((t) => t.toolName === e.toolName), r = e.state === "done" ? i`<span class="ok">${_("check", 13)}</span>` : e.state === "error" ? i`<span class="bad">${_("circle-alert", 13)}</span>` : i`<span class="spin">${_("loader", 13)}</span>`;
1944
- return i`<div class="allowed" part="allowed-step" title=${e.state === "error" ? e.errorText ?? "" : ""}>
2595
+ 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>`;
2596
+ return a`<div class="allowed" part="allowed-step" title=${e.state === "error" ? e.errorText ?? "" : ""}>
1945
2597
  <div class="allowed-head">
1946
2598
  <span class="what">${r}${this.toolLabel(e)}</span>
1947
- <span class="allowed-tag">${_("shield-check", 12)} ${t.allowed}</span>
2599
+ <span class="allowed-tag">${v("shield-check", 12)} ${t.allowed}</span>
1948
2600
  </div>
1949
2601
  ${e.preview ? this.renderPreview(e.preview) : this.renderRows(`allowed:${e.toolCallId}`, e.input)}
1950
- ${n ? i`<div class="allowed-by">${t.allowedAt(this.toolLabel(e), F(n.grantedAt))}</div>` : a}
2602
+ ${n ? a`<div class="allowed-by">${t.allowedAt(this.toolLabel(e), H(n.grantedAt))}</div>` : o}
1951
2603
  </div>`;
1952
2604
  }
1953
2605
  renderAllowances() {
1954
2606
  let e = this.state?.allowances ?? [];
1955
- if (!e.length) return a;
2607
+ if (!e.length) return o;
1956
2608
  let t = this.labels;
1957
- return i`${e.map((e) => i`<div class="allowance" part="allowance-bar" role="status">
1958
- <span class="allowance-text">${_("shield-check", 13)} ${t.allowanceBar(this.toolLabel(e))}</span>
2609
+ return a`${e.map((e) => a`<div class="allowance" part="allowance-bar" role="status">
2610
+ <span class="allowance-text">${v("shield-check", 13)} ${t.allowanceBar(this.toolLabel(e))}</span>
1959
2611
  <button class="link" @click=${() => this.chat?.revokeAllowance(e.toolName)}>${t.askEveryTime}</button>
1960
2612
  </div>`)}`;
1961
2613
  }
1962
2614
  renderPreview(e) {
1963
- if (!e) return a;
2615
+ if (!e) return o;
1964
2616
  let t = this.labels;
1965
- return i`<div class="preview" part="preview">
2617
+ return a`<div class="preview" part="preview">
1966
2618
  <div class="preview-summary">${e.summary}</div>
1967
- ${e.changes.length ? i`<ul class="preview-changes">
1968
- ${e.changes.map((e) => i`<li>
2619
+ ${e.changes.length ? a`<ul class="preview-changes">
2620
+ ${e.changes.map((e) => a`<li>
1969
2621
  <span class="preview-label">${e.label}:</span>
1970
- ${e.current === void 0 ? a : i`<span class="preview-now">${t.now} ${e.current}</span> → `}
2622
+ ${e.current === void 0 ? o : a`<span class="preview-now">${t.now} ${e.current}</span> → `}
1971
2623
  <span class="preview-next">${e.next}</span>
1972
2624
  </li>`)}
1973
- </ul>` : a}
2625
+ </ul>` : o}
1974
2626
  </div>`;
1975
2627
  }
1976
2628
  renderRows(e, t) {
1977
- let n = this.labels, r = p(t), o = 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);
1978
- return i`<div class="rows">
1979
- ${r.map((e) => i`<div class="row">
2629
+ 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);
2630
+ return a`<div class="rows">
2631
+ ${r.map((e) => a`<div class="row">
1980
2632
  <span class="label">${e.label}</span>
1981
- <span class="value">${o ? e.value : c(e.value)}</span>
2633
+ <span class="value">${i ? e.value : c(e.value)}</span>
1982
2634
  </div>`)}
1983
- ${l ? i`<button class="link" @click=${() => this.toggleRows(e)}>${o ? n.showLess : n.showMore}</button>` : a}
2635
+ ${l ? a`<button class="link" @click=${() => this.toggleRows(e)}>${i ? n.showLess : n.showMore}</button>` : o}
1984
2636
  </div>`;
1985
2637
  }
1986
2638
  renderPending() {
1987
2639
  let e = this.state?.pendingApprovals ?? [];
1988
- if (!e.length || this.state?.status !== "awaiting-approval") return a;
2640
+ if (!e.length || this.state?.status !== "awaiting-approval") return o;
1989
2641
  let t = this.labels;
1990
2642
  if (e.length === 1) {
1991
- let n = e[0], r = this.options?.cards?.[n.toolName]?.confirm, o = {
2643
+ let n = e[0], r = this.options?.cards?.[n.toolName]?.confirm, i = {
1992
2644
  kind: "tool",
1993
2645
  toolCallId: n.toolCallId,
1994
2646
  toolName: n.toolName,
@@ -2000,7 +2652,7 @@ var j = r`
2000
2652
  if (r && this.chat) {
2001
2653
  let e = this.chat;
2002
2654
  return this.cardSlot(`confirm:${n.approvalId}`, {
2003
- part: o,
2655
+ part: i,
2004
2656
  approval: n,
2005
2657
  client: e,
2006
2658
  decide: (t, r) => e.decide([{
@@ -2010,13 +2662,13 @@ var j = r`
2010
2662
  }])
2011
2663
  }, r);
2012
2664
  }
2013
- return i`<div class="confirm" part="confirm-card" role="group" aria-label=${this.toolLabel(n)}>
2665
+ return a`<div class="confirm" part="confirm-card" role="group" aria-label=${this.toolLabel(n)}>
2014
2666
  <div class="confirm-head" part="confirm-header">
2015
- <span class="what">${_("pencil-line", 15)} ${this.toolLabel(n)}</span>
2667
+ <span class="what">${v("pencil-line", 15)} ${this.toolLabel(n)}</span>
2016
2668
  <span class="badge">${t.needsOk}</span>
2017
2669
  </div>
2018
2670
  ${this.renderPreview(n.preview)}
2019
- ${n.preview ? i`<div class="exact-head">${t.exactValues}</div>` : a}
2671
+ ${n.preview ? a`<div class="exact-head">${t.exactValues}</div>` : o}
2020
2672
  ${this.renderRows(n.approvalId, n.input)}
2021
2673
  <div class="confirm-foot">
2022
2674
  <span class="hint">${n.preview ? "" : t.exactValues}</span>
@@ -2029,25 +2681,12 @@ var j = r`
2029
2681
  </div>`;
2030
2682
  }
2031
2683
  let n = e.filter((e) => !this.unticked.has(e.approvalId)).length;
2032
- return i`<div class="confirm" part="confirm-card" role="group" aria-label=${t.changes(e.length)}>
2684
+ return a`<div class="confirm" part="confirm-card" role="group" aria-label=${t.changes(e.length)}>
2033
2685
  <div class="confirm-head" part="confirm-header">
2034
- <span class="what">${t.changes(e.length)}</span>
2686
+ <span class="what">${v("pencil-line", 15)} ${t.changes(e.length)}</span>
2035
2687
  <span class="badge">${t.needsOk}</span>
2036
2688
  </div>
2037
- ${e.map((e) => i`<div class="item">
2038
- <input
2039
- type="checkbox"
2040
- aria-label=${this.toolLabel(e)}
2041
- .checked=${!this.unticked.has(e.approvalId)}
2042
- @change=${(t) => this.tick(e.approvalId, t.target.checked)}
2043
- />
2044
- <span class="body">
2045
- <span class="name">${this.toolLabel(e)}</span>
2046
- ${this.renderPreview(e.preview)}
2047
- ${e.preview ? i`<span class="exact-head">${t.exactValues}</span>` : a}
2048
- ${this.renderRows(e.approvalId, e.input)}
2049
- </span>
2050
- </div>`)}
2689
+ ${R(e).map((e) => e.length >= P ? this.renderCompactGroup(e) : e.map((e) => this.renderItem(e)))}
2051
2690
  <div class="confirm-foot">
2052
2691
  <span class="hint">${t.unticked}</span>
2053
2692
  <span class="buttons">
@@ -2058,10 +2697,80 @@ var j = r`
2058
2697
  </span>
2059
2698
  ${this.renderAllowChoice(e.filter((e) => !this.unticked.has(e.approvalId)))}
2060
2699
  </div>
2700
+ </div>`;
2701
+ }
2702
+ renderItem(e) {
2703
+ let t = this.labels;
2704
+ return a`<div class="item">
2705
+ <input
2706
+ type="checkbox"
2707
+ aria-label=${this.toolLabel(e)}
2708
+ .checked=${!this.unticked.has(e.approvalId)}
2709
+ @change=${(t) => this.tick(e.approvalId, t.target.checked)}
2710
+ />
2711
+ <span class="body">
2712
+ <span class="name">${this.toolLabel(e)}</span>
2713
+ ${this.renderPreview(e.preview)}
2714
+ ${e.preview ? a`<span class="exact-head">${t.exactValues}</span>` : o}
2715
+ ${this.renderRows(e.approvalId, e.input)}
2716
+ </span>
2717
+ </div>`;
2718
+ }
2719
+ renderCompactGroup(e) {
2720
+ let t = this.labels, n = this.toolLabel(e[0]), r = `group:${e[0].approvalId}`, i = this.expanded.has(r), s = e.filter((e) => !this.unticked.has(e.approvalId)).length;
2721
+ return a`<div class="group" part="confirm-group" role="group" aria-label=${`${n} · ${e.length}`}>
2722
+ <label class="group-head">
2723
+ <input
2724
+ type="checkbox"
2725
+ .checked=${s === e.length}
2726
+ .indeterminate=${s > 0 && s < e.length}
2727
+ @change=${(t) => this.tickAll(e, t.target.checked)}
2728
+ />
2729
+ <span class="group-name">${n} · ${e.length}</span>
2730
+ <span class="group-count">${t.many.ticked(s, e.length)}</span>
2731
+ </label>
2732
+ ${(i ? e : e.slice(0, F)).map((e) => this.renderLine(e))}
2733
+ ${e.length > F ? a`<button class="link group-more" @click=${() => this.toggleRows(r)}>
2734
+ ${i ? t.many.showFewer : t.many.showAll(e.length)}
2735
+ </button>` : o}
2736
+ </div>`;
2737
+ }
2738
+ renderLine(e) {
2739
+ let t = this.labels, n = `line:${e.approvalId}`, r = this.expanded.has(n), i = !this.unticked.has(e.approvalId), s = e.preview?.changes[0], c = e.preview ? e.preview.summary : B(e.input), l = e.preview && e.preview.changes.length > 1 ? e.preview.changes : [];
2740
+ return a`<div class="line ${i ? "" : "off"}" part="confirm-line">
2741
+ <div class="line-row">
2742
+ <input
2743
+ type="checkbox"
2744
+ aria-label=${c}
2745
+ .checked=${i}
2746
+ @change=${(t) => this.tick(e.approvalId, t.target.checked)}
2747
+ />
2748
+ <span class="line-text ${e.preview ? "" : "exact"}" title=${c}>${c}</span>
2749
+ ${s ? a`<span class="line-value">${s.current === void 0 ? "" : `${t.now} ${s.current} → `}${s.next}</span>` : o}
2750
+ <button
2751
+ class="chev"
2752
+ aria-label=${t.many.details}
2753
+ aria-expanded=${r ? "true" : "false"}
2754
+ @click=${() => this.toggleRows(n)}
2755
+ >
2756
+ ${v(r ? "chevron-up" : "chevron-down", 13)}
2757
+ </button>
2758
+ </div>
2759
+ ${r ? a`<div class="line-details">
2760
+ ${l.length ? a`<ul class="preview-changes">
2761
+ ${l.map((e) => a`<li>
2762
+ <span class="preview-label">${e.label}:</span>
2763
+ ${e.current === void 0 ? o : a`<span class="preview-now">${t.now} ${e.current}</span> → `}
2764
+ <span class="preview-next">${e.next}</span>
2765
+ </li>`)}
2766
+ </ul>` : o}
2767
+ <span class="exact-head">${t.exactValues}</span>
2768
+ ${this.renderRows(e.approvalId, e.input)}
2769
+ </div>` : o}
2061
2770
  </div>`;
2062
2771
  }
2063
2772
  renderProblem(e) {
2064
- let t = this.labels, n = t.problems[e.code], r = this.chat, o = 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 = {
2773
+ 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
2774
  reconnecting: "refresh-cw",
2066
2775
  "token-expired": "refresh-cw",
2067
2776
  "in-progress": "clock",
@@ -2070,19 +2779,56 @@ var j = r`
2070
2779
  "store-unreachable": "plug-zap",
2071
2780
  "cut-off": "wifi-off",
2072
2781
  unavailable: "wifi-off"
2073
- }, c = e.code === "conversation-full" ? i`<button class="btn secondary" @click=${() => this.newConversation()}>${t.newConversation}</button>` : e.code === "cut-off" ? i`<button class="btn secondary" @click=${() => r?.reload()}>${t.reload}</button>` : e.code === "token-expired" || e.code === "answer-cut" || e.code === "step-limit" ? i`<button class="btn secondary" @click=${() => r?.send(t.continueMessage)}>${t.continue}</button>` : e.code === "too-long" ? i`<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" ? i`<button class="btn secondary" @click=${() => r?.retry()}>${t.tryAgain}</button>` : a, l = e.code === "reconnecting" ? a : i`<button class="btn secondary" @click=${() => r?.dismissProblem()}>${t.dismiss}</button>`;
2074
- return i`<div class=${`problem ${o}`} part="problem" role="status">
2075
- <span class=${e.code === "reconnecting" ? "icon spin" : "icon"}>${_(s[e.code] ?? "circle-alert", 16)}</span>
2782
+ }, 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>`;
2783
+ return a`<div class=${`problem ${i}`} part="problem" role="status">
2784
+ <span class=${e.code === "reconnecting" ? "icon spin" : "icon"}>${v(s[e.code] ?? "circle-alert", 16)}</span>
2076
2785
  <span class="body">
2077
2786
  <span class="head">${n.title}</span>
2078
2787
  <span>${e.code === "failed" && e.message ? e.message : n.text(e.retryAfter)}</span>
2079
2788
  <span class="actions">${c}${l}</span>
2080
2789
  </span>
2790
+ </div>`;
2791
+ }
2792
+ renderFull() {
2793
+ let e = this.labels.full, t = this.state;
2794
+ if (t.continuing) return a`<div class="problem working" part="problem" role="status">
2795
+ <span class="icon spin">${v("loader", 16)}</span>
2796
+ <span class="body">
2797
+ <span class="head">${e.workingTitle}</span>
2798
+ <span>${e.workingText}</span>
2799
+ </span>
2800
+ </div>`;
2801
+ let n = t.pendingApprovals.length > 0, r = t.status === "sending" || t.status === "streaming" || t.status === "loading";
2802
+ return a`<div class="problem warn" part="problem" role="status">
2803
+ <span class="icon">${v("messages-square", 16)}</span>
2804
+ <span class="body">
2805
+ <span class="head">${e.title}</span>
2806
+ <span>${n ? e.textWaiting : e.text}</span>
2807
+ <span class="actions">
2808
+ <button class="btn primary" ?disabled=${n || r} @click=${() => this.continueConversation()}>
2809
+ ${e.continue}
2810
+ </button>
2811
+ ${n ? o : a`<button class="btn secondary" ?disabled=${r} @click=${() => this.newConversation()}>
2812
+ ${e.startEmpty}
2813
+ </button>`}
2814
+ </span>
2815
+ </span>
2081
2816
  </div>`;
2082
2817
  }
2083
2818
  renderBottom() {
2084
- let e = this.labels, n = this.state, r = n?.status === "sending" || n?.status === "streaming", o = n?.status === "awaiting-approval";
2085
- return i`${n?.problem ? i`<div class="column">${this.renderProblem(n.problem)}</div>` : a}
2819
+ 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;
2820
+ if (s && t?.continuedIn) {
2821
+ let n = t.continuedIn;
2822
+ return a`${c ? a`<div class="column">${this.renderProblem(c)}</div>` : o}
2823
+ <div class="column">
2824
+ <div class="continued-in" part="continued-in">
2825
+ ${v("corner-down-right", 16)}<span class="text">${e.full.continuedIn}</span>
2826
+ <button class="link" @click=${() => this.openConversation(n)}>${e.full.open}</button>
2827
+ </div>
2828
+ </div>`;
2829
+ }
2830
+ return a`${c ? a`<div class="column">${this.renderProblem(c)}</div>` : o}
2831
+ ${s ? a`<div class="column">${this.renderFull()}</div>` : o}
2086
2832
  <div
2087
2833
  class="composer column"
2088
2834
  part="composer"
@@ -2091,44 +2837,45 @@ var j = r`
2091
2837
  @dragleave=${(e) => this.onDrag(e, !1)}
2092
2838
  @drop=${this.onDrop}
2093
2839
  >
2094
- ${n?.allowances.length ? i`<div class="allowances">${this.renderAllowances()}</div>` : a}
2095
- ${n?.uploads.length ? i`<div class="chips" part="attachment-chips">${n.uploads.map((e) => this.renderChip(e))}</div>
2096
- <div class="chips-note">${e.photosLimit(this.photoCount(), this.photoMb())}</div>` : a}
2097
- ${this.dragging ? i`<div class="drop-note">${e.dropPhotos}</div>` : a}
2840
+ ${t?.allowances.length ? a`<div class="allowances">${this.renderAllowances()}</div>` : o}
2841
+ ${t ? this.renderComposerSelections(t) : o}
2842
+ ${t?.uploads.length ? a`<div class="chips" part="attachment-chips">${t.uploads.map((e) => this.renderChip(e))}</div>
2843
+ <div class="chips-note">${e.photosLimit(this.photoCount(), this.photoMb())}</div>` : o}
2844
+ ${this.dragging ? a`<div class="drop-note">${e.dropPhotos}</div>` : o}
2098
2845
  <div class="box">
2099
- ${n?.canAttach ? i`<button
2846
+ ${t?.canAttach ? a`<button
2100
2847
  class="attach"
2101
2848
  part="attach-button"
2102
2849
  aria-label=${e.attachPhoto}
2103
2850
  title=${e.attachPhoto}
2104
- ?disabled=${!this.chat}
2851
+ ?disabled=${!this.chat || s}
2105
2852
  @click=${() => this.pickPhotos()}
2106
2853
  >
2107
- ${_("image-plus", 17)}
2854
+ ${v("image-plus", 17)}
2108
2855
  </button>
2109
2856
  <input
2110
2857
  type="file"
2111
2858
  hidden
2112
2859
  multiple
2113
- accept=${(this.chat?.attachmentLimits().accept ?? t.accept).join(",")}
2860
+ accept=${(this.chat?.attachmentLimits().accept ?? n.accept).join(",")}
2114
2861
  @change=${this.onPicked}
2115
- />` : a}
2862
+ />` : o}
2116
2863
  <label class="sr-only" for="input">${e.placeholder}</label>
2117
2864
  <textarea
2118
2865
  id="input"
2119
2866
  part="input"
2120
2867
  rows="1"
2121
- lang=${this.locale || a}
2122
- placeholder=${e.placeholder}
2868
+ lang=${this.locale || o}
2869
+ placeholder=${s ? e.full.placeholder : e.placeholder}
2123
2870
  .value=${this.draft}
2124
- ?disabled=${!this.chat}
2871
+ ?disabled=${!this.chat || s}
2125
2872
  @input=${this.onInput}
2126
2873
  @keydown=${this.onKeydown}
2127
2874
  @paste=${this.onPaste}
2128
2875
  ></textarea>
2129
- ${r ? i`<button class="stop" part="stop" @click=${() => this.chat?.stop()}>
2876
+ ${r ? a`<button class="stop" part="stop" @click=${() => this.chat?.stop()}>
2130
2877
  <span class="square"></span>${e.stop}
2131
- </button>` : i`<button
2878
+ </button>` : a`<button
2132
2879
  class="send"
2133
2880
  part="send"
2134
2881
  aria-label=${e.send}
@@ -2136,24 +2883,49 @@ var j = r`
2136
2883
  ?disabled=${!this.canSend() || !this.chat}
2137
2884
  @click=${() => this.submit()}
2138
2885
  >
2139
- ${_("arrow-up", 17)}
2886
+ ${v("arrow-up", 17)}
2140
2887
  </button>`}
2141
2888
  </div>
2142
2889
  <div class="footer">
2143
- <span class="ghuri">${h(12)} Ghuri AI</span>
2144
- <span>· ${o ? e.newMessageCancels : n?.allowances.length ? e.footerAllowed : e.footer}</span>
2890
+ <span class="ghuri">${g(12)} Ghuri AI</span>
2891
+ <span>· ${i && !s ? e.newMessageCancels : t?.allowances.length ? e.footerAllowed : e.footer}</span>
2145
2892
  </div>
2146
2893
  </div>`;
2147
2894
  }
2148
2895
  photoCount() {
2149
- return this.chat?.attachmentLimits().maxCount ?? t.maxCount;
2896
+ return this.chat?.attachmentLimits().maxCount ?? n.maxCount;
2150
2897
  }
2151
2898
  photoMb() {
2152
- let e = this.chat?.attachmentLimits().maxBytes ?? t.maxBytes;
2899
+ let e = this.chat?.attachmentLimits().maxBytes ?? n.maxBytes;
2153
2900
  return Math.round(e / 1048576 * 10) / 10;
2154
2901
  }
2155
2902
  };
2156
- function P(e) {
2903
+ function R(e) {
2904
+ let t = /* @__PURE__ */ new Map();
2905
+ for (let n of e) {
2906
+ let e = t.get(n.toolName);
2907
+ e ? e.push(n) : t.set(n.toolName, [n]);
2908
+ }
2909
+ return [...t.values()];
2910
+ }
2911
+ function z(e, t) {
2912
+ let n = e[t];
2913
+ if (n.kind !== "tool" || !n.approvalId || n.allowed || n.state === "awaiting-approval") return [];
2914
+ let r = [];
2915
+ for (let i = t; i < e.length; i++) {
2916
+ let t = e[i];
2917
+ if (t.kind !== "tool" || !t.approvalId || t.allowed || t.state === "awaiting-approval" || t.toolName !== n.toolName) break;
2918
+ r.push(t);
2919
+ }
2920
+ return r;
2921
+ }
2922
+ function B(e) {
2923
+ return m(e).map((e) => {
2924
+ let t = e.value.replace(/\s+/g, " ");
2925
+ return `${e.label} ${t.length > 16 ? `${t.slice(0, 9)}…` : t}`;
2926
+ }).join(", ");
2927
+ }
2928
+ function V(e) {
2157
2929
  if (typeof e == "string") try {
2158
2930
  let t = new URL(e);
2159
2931
  return t.protocol === "https:" ? t.toString() : void 0;
@@ -2161,15 +2933,15 @@ function P(e) {
2161
2933
  return;
2162
2934
  }
2163
2935
  }
2164
- function F(e) {
2936
+ function H(e) {
2165
2937
  let t = new Date(e);
2166
2938
  return Number.isNaN(t.getTime()) ? "" : `${String(t.getHours()).padStart(2, "0")}:${String(t.getMinutes()).padStart(2, "0")}`;
2167
2939
  }
2168
- function I(e) {
2940
+ function U(e) {
2169
2941
  return `data:${e.mediaType};base64,${e.data}`;
2170
2942
  }
2171
2943
  // src/index.ts
2172
- typeof customElements < "u" && !customElements.get("ghuri-chat") && customElements.define("ghuri-chat", N);
2173
- export { N as t };
2944
+ typeof customElements < "u" && !customElements.get("ghuri-chat") && customElements.define("ghuri-chat", L);
2945
+ export { L as t };
2174
2946
 
2175
- //# sourceMappingURL=src-Cr4A8kk0.js.map
2947
+ //# sourceMappingURL=src-CKqHiJZD.js.map